標題: 絕對強大的Makefile [打印本頁]

作者: daniu    時間: 2014-12-27 13:59
標題: 絕對強大的Makefile


今天  我在網(wǎng)上無意發(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中調(diào)用自己寫的函數(shù)

我知道用call  但是這個函數(shù)怎么寫呢







歡迎光臨 (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1