makefile调用自己

时间:2012-02-09 19:50:45

标签: makefile

当makefile像

一样调用自身时
test : 
    @ mv $(BIN_SRC) $(BIN_SCR_TMP)
    @ mv $(BIN_TEST_SRC) $(BIN_TEST_SRC_TMP)
    @ make runtest
    @ mv $(BIN_SCR_TMP) $(BIN_SRC)
    @ mv $(BIN_TEST_SRC_TMP) $(BIN_TEST_SRC)

runtest : $(OBJS) $(LIB)
    g++ -o $(TEST_BIN_FILE) $(OBJS) $(LIB)
    @ chmod ugo+x $(TEST_BIN_FILE)
    $(TEST_BIN_FILE)

然后你运行make test它将它打印到终端:

make test

make[1]: Entering directory `/users/home2/admin/stringha/cs240/webcrawler'
g++ -o bin/webcrawler-tests  obj/URL.o  obj/webcrawler-tests.o lib/libcs240utils.a bin/webcrawler-tests
Hello webcrawler test!
make[1]: Leaving directory `/users/home2/admin/stringha/cs240/webcrawler'

我想知道如何让它不打印出来

make[1]: Entering directory `/users/home2/admin/stringha/cs240/webcrawler'

make[1]: Leaving directory `/users/home2/admin/stringha/cs240/webcrawler'

谢谢!

2 个答案:

答案 0 :(得分:3)

添加--no-print-directory flag

MAKEFLAGS += --no-print-directory

或直接将其添加到sub-make invocation命令:

test :
    ...
    @$(MAKE) runtest --no-print-directory
    ...

另请阅读有关使用MAKE variable

的信息

答案 1 :(得分:1)

将-no-print-directory添加到MAKEFLAGS:

$ export MAKEFLAGS=--no-print-directory

或将该选项添加到您调用make:

$ make test --no-print-directory