1.關於makefile變量賦值
+= := ?= =
http://stackoverflow.com/questions/448910/makefile-variable-assignment
2.makefile提供若干函數:
subst patsubst shell if foreach origin sort filter filter_out findstring strip word words firstword wordlist dir basename call etc.......
--------------------------------------------------- 分割線 ---------------------------------------------------
3.自動生成文件依賴 :
-include $(OBJS:.o=.d)
%.d:%.c
@set -e; \
rm -f $@; \
$(CC) -MM $< $(INCLUDEFLAGS) > $@.$$$$; \
sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
rm -f $@.$$$$
4.makefile 中文件依賴可以分成多個行寫
$(TARGET): $(LIBS)
$(TARGET): %: %.o
$(CC) $(CFLAGS) $< -o $@ $(LIBS)
但是最好只有一個依賴附帶執行命令序列,不然會給出警告.