Controlling verbosity of make

后端 未结 5 627
粉色の甜心
粉色の甜心 2021-02-04 11:10

I\'m using a makefile to compile a program made of many .c files, and any time make is invoked it only compiles those files modified after the last run

5条回答
  •  臣服心动
    2021-02-04 11:24

    I'd do it the way automake does:

    V = 0
    ACTUAL_CC := $(CC)
    CC_0 = @echo "Compiling $<..."; $(ACTUAL_CC)
    CC_1 = $(ACTUAL_CC)
    CC = $(CC_$(V))
    
    %.o: %.c $(h1) $(h3) %.h
            $(CC) $(CFLAGS) -c $< -o $(libDir)$@$(MATHOPTS)
    

    If you need to execute other commands in your rules, I like the following snippet. Write $(AT) instead of @ and it will be silent when V=0 but printed when V=1.

    AT_0 := @
    AT_1 := 
    AT = $(AT_$(V))
    

提交回复
热议问题