Controlling verbosity of make

后端 未结 5 629
粉色の甜心
粉色の甜心 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条回答
  •  闹比i
    闹比i (楼主)
    2021-02-04 11:14

    Another solution (one which I like because it's flexible)

    ifeq ("$(BUILD_VERBOSE)","1")
    Q :=
    vecho = @echo
    else
    Q := @
    vecho = @true
    endif
    
    %.o: %.c
        $(vecho) "-> Compiling $@"
        $(Q)$(CC) $(CFLAGS) -c $< -o $@
    

    You can skip the vecho stuff, but it does come in handy at times.

提交回复
热议问题