Append to GNU make variables via command line

前端 未结 4 757
执念已碎
执念已碎 2020-12-07 20:14

I am using a GNU-make Makefile to build a C project with several targets (all, clean, and a few project specific targets). In the process of debugg

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-07 20:23

    Check out the override directive. You will probably need to modify the makefile once, but it should do what you want.

    Example makefile:

    override CFLAGS += -Wall
    
    app: main.c
        gcc $(CFLAGS) -o app main.c 
    

    Example command lines:

    $ make
    gcc -Wall -o app main.c 
    $ make CFLAGS=-g
    gcc -g -Wall -o app main.c 
    

提交回复
热议问题