14
メイクファイルの一部として、ターゲットのデバッグバージョンまたはリリースバージョンを生成したいと考えています。 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 [email protected]
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 [email protected]
私make
私はデバッグバージョンを取得
make release
私は、リリースバージョンを取得するとき。
しかし、私はまた、取得警告:
この2つの質問では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'
:
- 警告
- を無視する方法は私は正しいことをやっていますか?どのような変更が必要ですか?
あなたは、Makefileを自動生成するnetbeansでこれを行う方法を知っていますか? –
複数のバイナリに同じコードがある場合はライブラリを作成する – baptx