How to compile different c files with different CFLAGS using Makefile?

前端 未结 3 1184
无人及你
无人及你 2020-12-23 09:54

all. Let\'s say I have a program that contains a long list of C source files, A.c, B.c, ...., Z.c, now I want to compile A.c, B.c with certain CFLAGS, and compile the rest p

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-23 10:33

    The approach taken by linux kernel build system:

    CFLAGS += $(CFLAGS-$@)
    

    And then,

    CFLAGS-A.o += -DEXTRA
    CFLAGS-B.o += -DEXTRA
    

提交回复
热议问题