?? makefile
字號:
## Makefile for some libs needed in the kernel.## Note! Dependencies are done automagically by 'make dep', which also# removes any old dependencies. DON'T put your own dependencies here# unless it's something special (ie not a .c file).## 內核需要用到的libs 庫文件程序的Makefile。## 注意!依賴關系是由'make dep'自動進行的,它也會自動去除原來的依賴信息。不要把你自己的# 依賴關系信息放在這里,除非是特別文件的(也即不是一個.c 文件的信息)。AR =gar # GNU 的二進制文件處理程序,用于創建、修改以及從歸檔文件中抽取文件。12.2 Makefile 文件AS =gas # GNU 的匯編程序。LD =gld # GNU 的連接程序。LDFLAGS =-s -x # 連接程序所有的參數,-s 輸出文件中省略所有符號信息。-x 刪除所有局部符號。CC =gcc # GNU C 語言編譯器。CFLAGS =-Wall -O -fstrength-reduce -fomit-frame-pointer -fcombine-regs \-finline-functions -mstring-insns -nostdinc -I../include# C 編譯程序選項。-Wall 顯示所有的警告信息;-O 優化選項,優化代碼長度和執行時間;# -fstrength-reduce 優化循環執行代碼,排除重復變量;-fomit-frame-pointer 省略保存不必要# 的框架指針;-fcombine-regs 合并寄存器,減少寄存器類的使用;-finline-functions 將所有簡# 單短小的函數代碼嵌入調用程序中;-mstring-insns Linus 自己填加的優化選項,以后不再使用;# -nostdinc -I../include 不使用默認路徑中的包含文件,而使用這里指定目錄中的(../include)。CPP =gcc -E -nostdinc -I../include# C 前處理選項。-E 只運行C 前處理,對所有指定的C 程序進行預處理并將處理結果輸出到標準輸# 出設備或指定的輸出文件中;-nostdinc -I../include 同前。# 下面的規則指示make 利用下面的命令將所有的.c 文件編譯生成.s 匯編程序。該規則的命令# 指使gcc 采用CFLAGS 所指定的選項對C 代碼編譯后不進行匯編就停止(-S),從而產生與# 輸入的各個C 文件對應的匯編代碼文件。默認情況下所產生的匯編程序文件名是原C 文件名# 去掉.c 而加上.s 后綴。-o 表示其后是輸出文件的名稱。其中$*.s(或$@)是自動目標變量,# $<代表第一個先決條件,這里即是符合條件*.c 的文件。.c.s:$(CC) $(CFLAGS) \-S -o $*.s $<# 下面規則表示將所有.s 匯編程序文件編譯成.o 目標文件。22 行是實現該操作的具體命令。.s.o:$(AS) -c -o $*.o $<.c.o: # 類似上面,*.c 文件-??*.o 目標文件。不進行連接。$(CC) $(CFLAGS) \-c -o $*.o $<# 下面定義目標文件變量OBJS。OBJS = ctype.o _exit.o open.o close.o errno.o write.o dup.o setsid.o \execve.o wait.o string.o malloc.o# 在有了先決條件OBJS 后使用下面的命令連接成目標lib.a 庫文件。lib.a: $(OBJS)$(AR) rcs lib.a $(OBJS)sync# 下面的規則用于清理工作。當執行'make clean'時,就會執行下面的命令,去除所有編譯# 連接生成的文件。'rm'是文件刪除命令,選項-f 含義是忽略不存在的文件,并且不顯示刪除信息。clean:rm -f core *.o *.a tmp_makefor i in *.c;do rm -f `basename $$i .c`.s;done# 下面得目標或規則用于檢查各文件之間的依賴關系。方法如下:# 使用字符串編輯程序sed 對Makefile 文件(即是本文件)進行處理,輸出為刪除Makefile# 文件中'### Dependencies'行后面的所有行(下面從45 開始的行),并生成tmp_make# 臨時文件(39 行的作用)。然后對kernel/blk_drv/目錄下的每個C 文件執行gcc 預處理操作.# -M 標志告訴預處理程序輸出描述每個目標文件相關性的規則,并且這些規則符合make 語法。# 對于每一個源文件,預處理程序輸出一個make 規則,其結果形式是相應源程序文件的目標# 文件名加上其依賴關系--該源文件中包含的所有頭文件列表。把預處理結果都添加到臨時# 文件tmp_make 中,然后將該臨時文件復制成新的Makefile 文件。dep:sed '/\#\#\# Dependencies/q' < Makefile > tmp_make(for i in *.c;do echo -n `echo $$i | sed 's,\.c,\.s,'`" "; \$(CPP) -M $$i;done) >> tmp_makecp tmp_make Makefile### Dependencies:_exit.s _exit.o : _exit.c ../include/unistd.h ../include/sys/stat.h \../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \../include/utime.hclose.s close.o : close.c ../include/unistd.h ../include/sys/stat.h \../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \../include/utime.hctype.s ctype.o : ctype.c ../include/ctype.hdup.s dup.o : dup.c ../include/unistd.h ../include/sys/stat.h \../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \../include/utime.herrno.s errno.o : errno.cexecve.s execve.o : execve.c ../include/unistd.h ../include/sys/stat.h \../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \../include/utime.hmalloc.s malloc.o : malloc.c ../include/linux/kernel.h ../include/linux/mm.h \../include/asm/system.hopen.s open.o : open.c ../include/unistd.h ../include/sys/stat.h \../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \../include/utime.h ../include/stdarg.hsetsid.s setsid.o : setsid.c ../include/unistd.h ../include/sys/stat.h \../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \../include/utime.hstring.s string.o : string.c ../include/string.hwait.s wait.o : wait.c ../include/unistd.h ../include/sys/stat.h \../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \../include/utime.h ../include/sys/wait.hwrite.s write.o : write.c ../include/unistd.h ../include/sys/stat.h \../include/sys/types.h ../include/sys/times.h ../include/sys/utsname.h \../include/utime.h
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -