0

Makefile like this:

CFLAGS := $(CFLAGS) -O3

test: main.o
        gcc $(CFLAGS) -o $@ $^

clean:
        rm test *.o -f

compile 1: command: make, output: gcc -O3 -o test main.c

compile 2: command: make CFLAGS="-Wall -Werror", output: gcc -Wall -Werror -o test main.c

question: why not output: gcc -Wall -Werror -O3 -o test main.c ?

minchai
  • 13
  • 3

1 Answers1

0

use override directive:

override CFLAGS := $(CFLAGS) -O3

or

override CFLAGS += -O3
minchai
  • 13
  • 3