今天 我在網上無意發(fā)現(xiàn)了一個腳本文件,寫這個腳本的人,實在是太牛了!
首先要運行如下腳本:
find . -type d > tmp_include_config
find . -iname "*.c" > config_src_c
awk '{print "CFLAGS += -I" $1} ' tmp_include_config > cflags_include
awk '{ gsub(/.c/,".o")}; 1' config_src_c > obj_config
awk '{print "OBJ +=" $1} ' obj_config > src
以下是我寫的Makefile:
include ./src
include ./cflags_include
Target := exe
CC := gcc
$(Target):$(OBJ)
$(CC) $(CFLAGS) $^ -o $@
.PHONY:clean
clean:
-rm $(OBJ) $(Target)
無論你當前目錄下有多少個子目錄,子目錄下有多少個.c文件,以上腳本和Makefile都有用!
今天 好開心啊!!!
不過還是要請教大師一個問題 如何在Makefile中調用自己寫的函數(shù)
我知道用call 但是這個函數(shù)怎么寫呢
|