我得到一些意外的結果,從另一個調用一個生成文件。我有兩個makefile,一個叫做/path/to/project/makefile
,另一個叫/path/to/project/gtest-1.4.0/make/Makefile
。我試圖讓前者稱呼後者。在/路徑/到/項目/ Makefile中,我有如何從另一個Makefile調用Makefile?
dev: $(OBJ_FILES)
$(CPPC) $(LIBS) $(FLAGS_DEV) $(OBJ_FILES) -o $(BIN_DIR)/$(PROJECT)
$(MAKE) -f ./gtest-1.4.0/make/Makefile
clean:
rm -f ./*~ ./gmon.out ./core $(SRC_DIR)/*~ $(OBJ_DIR)/*.o
rm -f ../svn-commit.tmp~
rm -f $(BIN_DIR)/$(PROJECT)
make -f gtest-1.4.0/make/Makefile clean
而在/path/to/project/gtest-1.4.0/make/Makefile
我有
all: $(TESTS)
clean:
rm -f $(TESTS) gtest.a gtest_main.a *.o
發出以下:
cd /path/to/project
make
輸出:
make -f ./gtest-1.4.0/make/Makefile
make[1]: Entering directory `/path/to/project'
make[1]: Nothing to be done for `all'.
make[1]: Leaving directory `/path/to/project'
但是,當我發佈這些命令:
cd /path/to/project
make clean
我看到:
make -f gtest-1.4.0/make/Makefile clean
make[1]: Entering directory `/path/to/project'
rm -f gtest.a gtest_main.a *.o
make[1]: Leaving directory `/path/to/project'
我不明白:在這兩種情況下,/path/to/project/makefile
是告訴我它進入當前工作目錄。在第一種情況下,它不認爲它有工作要做(當它做),在第二種情況下,它能夠找到適當的指令(當輸出告訴我它正在尋找錯誤的目錄),但它嘗試運行rm
命令/path/to/project
而不是/path/to/makefile/gtest-1.4.0/make/
。
我是否錯過了從別的方面調用makefiles的基礎知識?我犯了一個嚴重的概念錯誤,還是遇到了一個常見的陷阱?如何有效更改目錄並從第一個內部調用第二個生成文件?我的理解是,簡單地調用make -f <name>
就足夠了。
這是在bash中的make/gmake 3.81。
我想,而不是'作,-f GTEST-1.4.0 /製造/ Makefile乾淨''你最好說'$(MAKE)-C gtest-1.4.0/make clean'。爲什麼你還沒有定義假目標? – 2010-06-22 15:43:22
http://stackoverflow.com/questions/3494999/subdirectories-and-makefiles – 2014-06-08 15:34:08