背景:
当前目录下有include ,src两个目录,include放头文件,src有四个源文件。写了如下makefile文件。可以生成目标。hello
问题:当我更新了头文件之后,重新make竟然提示我当前hello已经是最新的了。28行以后的东西难道没有起作用?28行-32行好多教程里面都是这么写的呀。包括gnu make中文手册,跟我写makefile.
09 OBJ_DIR=./src
10 VPATH=src:include
11 #vpath %.h include
12 sources=$(wildcard $(OBJ_DIR)/*.c)
13 objects=$(patsubst %.c,%.o,$(sources))
14 #echo $(sources)
15 hello : $(objects)
16 @echo "$$ ^ >" $^
17 @echo "$$ @ >" $@
18 cc $^ -o $@
19 clean:
20 -rm hello $(OBJ_DIR)/*.o
21 -rm $(OBJ_DIR)/*.d*
22 display:
23 @echo "VPATH>>" $(VPATH)
24 @echo "sources>>"$(sources)
25
当前目录下有include ,src两个目录,include放头文件,src有四个源文件。写了如下makefile文件。可以生成目标。hello
问题:当我更新了头文件之后,重新make竟然提示我当前hello已经是最新的了。28行以后的东西难道没有起作用?28行-32行好多教程里面都是这么写的呀。包括gnu make中文手册,跟我写makefile.
09 OBJ_DIR=./src
10 VPATH=src:include
11 #vpath %.h include
12 sources=$(wildcard $(OBJ_DIR)/*.c)
13 objects=$(patsubst %.c,%.o,$(sources))
14 #echo $(sources)
15 hello : $(objects)
16 @echo "$$ ^ >" $^
17 @echo "$$ @ >" $@
18 cc $^ -o $@
19 clean:
20 -rm hello $(OBJ_DIR)/*.o
21 -rm $(OBJ_DIR)/*.d*
22 display:
23 @echo "VPATH>>" $(VPATH)
24 @echo "sources>>"$(sources)
25