From 6281d3c3633fb1de98ff6010212325e45c226f3c Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 9 Jan 2017 13:46:04 +0100 Subject: make: Append instead of override CPPFLAGS and CFLAGS passed by user Distribution build scripts commonly assume the CPPFLAGS, CFLAGS and LDFLAGS passed via command line or environment to be appended to the base set of flags defined in the Makefile. Follow this assumption instead of overriding the already defined values. Also treat these three variables entriely independently instead of appending CPPFLAGS to CFLAGS. Reported-by: @pali Really-fixes: #17 Signed-off-by: Tobias Klauser --- Makefile | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index a0d55bf..0de1919 100644 --- a/Makefile +++ b/Makefile @@ -18,7 +18,6 @@ CC = $(CROSS_COMPILE)gcc INSTALL = install CPPFLAGS ?= -CFLAGS ?= -W -Wall -O2 $(CPPFLAGS) LDFLAGS ?= ifeq ($(shell git rev-parse > /dev/null 2>&1; echo $$?), 0) @@ -27,12 +26,14 @@ else GIT_VERSION = endif -CFLAGS += -DVERSION_STRING=\"v$(VERSION)\" -DGIT_VERSION=\"$(GIT_VERSION)\" - +CFLAGS_MIN := -W -Wall -DVERSION_STRING=\"v$(VERSION)\" -DGIT_VERSION=\"$(GIT_VERSION)\" ifeq ($(DEBUG), 1) - CFLAGS += -g -DDEBUG + CFLAGS_MIN += -g -DDEBUG endif +CFLAGS ?= -O2 +override CFLAGS := $(CFLAGS_MIN) $(CFLAGS) + Q ?= @ ifeq ($(Q),) CCQ = $(CC) @@ -57,10 +58,10 @@ $(Q_P): $(Q_OBJS) $(LDQ) $(LDFLAGS) -o $@ $(Q_OBJS) $(Q_LIBS) %.o: %.c %.h - $(CCQ) $(CFLAGS) -o $@ -c $< + $(CCQ) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< %.o: %.c - $(CCQ) $(CFLAGS) -o $@ -c $< + $(CCQ) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< install_$(D_P): $(D_P) @echo " INSTALL $(D_P)" -- cgit v1.2.3-54-g00ecf