【发布时间】:2012-08-14 18:36:22
【问题描述】:
作为 makefile 的一部分,我想生成目标的调试或发布版本。
功能上,一切正常,但是,我在运行 make 时收到警告
12 SRC := $(shell echo src/*.cpp)
13 SRC += $(shell echo $(TEST_ROOT)/*.cpp)
14
15 D_OBJECTS = $(SRC:.cpp=.o) # same objects will need to be built differently
16 R_OBJECTS = $(SRC:.cpp=.o) # same objects will need to be built differently
22 all: $(TARGET)
23
25 $(TARGET): $(D_OBJECTS)
26 $(CC) $(D_OBJECTS) -o $(TARGET)
27
28 $(D_OBJECTS) : %.o: %.cpp # ----- run with debug flags
29 $(CC) $(COMMON_FLAGS) $(DEBUG_FLAGS) -c $< -o $@
30
31 release: $(R_OBJECTS)
32 $(CC) $(R_OBJECTS) -o $(TARGET)
33
34 $(R_OBJECTS) : %.o: %.cpp # ----- run with release flags
35 $(CC) $(COMMON_FLAGS) $(RELEASE_FLAGS) -c $< -o $@
当我make 我得到调试版本,当我make release 我得到发布版本。
但我也收到警告:
Makefile:35: warning: overriding commands for target `src/Timer.o'
Makefile:29: warning: ignoring old commands for target `src/Timer.o'
Makefile:35: warning: overriding commands for target `test/TimerTest.o'
Makefile:29: warning: ignoring old commands for target `test/TimerTest.o'
这两个问题:
- 忽略警告的任何方式
- 我做对了吗?需要进行哪些更改?
【问题讨论】: