Makefile 调用自身

5

当一个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个回答

6

Add --no-print-directory flag:

MAKEFLAGS += --no-print-directory

或者直接将其添加到子make调用命令中:

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

阅读关于使用MAKE变量的内容。


3

在MAKEFLAGS中添加 --no-print-directory:

$ export MAKEFLAGS=--no-print-directory

或者在make的调用中添加该选项:

$ make test --no-print-directory

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接