From 93f906308dd2338a593bbf3ee5411aa418dcfff0 Mon Sep 17 00:00:00 2001 From: Michael Stapelberg Date: Wed, 13 Jul 2011 13:22:15 +0200 Subject: [PATCH] makefiles: respect and use the CPPFLAGS variable (Thanks Kacper) See also: http://stackoverflow.com/questions/2754966/cflags-vs-cppflags --- Makefile | 10 +++++----- common.mk | 10 +++++----- i3-config-wizard/Makefile | 6 +++--- i3-input/Makefile | 2 +- i3-msg/Makefile | 2 +- i3-nagbar/Makefile | 2 +- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index e6063d45..d628eaf7 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ endif # Depend on the specific file (.c for each .o) and on all headers src/%.o: src/%.c ${HEADERS} echo "CC $<" - $(CC) $(CFLAGS) -DLOGLEVEL="((uint64_t)1 << $(shell awk '/$(shell basename $< .c)/ { print NR; exit 0; }' loglevels.tmp))" -c -o $@ $< + $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="((uint64_t)1 << $(shell awk '/$(shell basename $< .c)/ { print NR; exit 0; }' loglevels.tmp))" -c -o $@ $< all: src/cfgparse.y.o src/cfgparse.yy.o src/cmdparse.y.o src/cmdparse.yy.o ${FILES} echo "LINK i3" @@ -42,23 +42,23 @@ loglevels.h: src/cfgparse.yy.o: src/cfgparse.l src/cfgparse.y.o ${HEADERS} echo "LEX $<" flex -i -o$(@:.o=.c) $< - $(CC) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cfgparse.l/ { print NR }' loglevels.tmp))" -c -o $@ $(@:.o=.c) + $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cfgparse.l/ { print NR }' loglevels.tmp))" -c -o $@ $(@:.o=.c) src/cmdparse.yy.o: src/cmdparse.l src/cmdparse.y.o ${HEADERS} echo "LEX $<" flex -Pcmdyy -i -o$(@:.o=.c) $< - $(CC) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cmdparse.l/ { print NR }' loglevels.tmp))" -c -o $@ $(@:.o=.c) + $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cmdparse.l/ { print NR }' loglevels.tmp))" -c -o $@ $(@:.o=.c) src/cfgparse.y.o: src/cfgparse.y ${HEADERS} echo "YACC $<" bison --debug --verbose -b $(basename $< .y) -d $< - $(CC) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cfgparse.y/ { print NR }' loglevels.tmp))" -c -o $@ $(<:.y=.tab.c) + $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cfgparse.y/ { print NR }' loglevels.tmp))" -c -o $@ $(<:.y=.tab.c) src/cmdparse.y.o: src/cmdparse.y ${HEADERS} echo "YACC $<" bison -p cmdyy --debug --verbose -b $(basename $< .y) -d $< - $(CC) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cmdparse.y/ { print NR }' loglevels.tmp))" -c -o $@ $(<:.y=.tab.c) + $(CC) $(CPPFLAGS) $(CFLAGS) -DLOGLEVEL="(1 << $(shell awk '/cmdparse.y/ { print NR }' loglevels.tmp))" -c -o $@ $(<:.y=.tab.c) install: all diff --git a/common.mk b/common.mk index ff12bdb0..c7131f22 100644 --- a/common.mk +++ b/common.mk @@ -31,7 +31,7 @@ CFLAGS += -Wunused-value CFLAGS += -Iinclude CFLAGS += $(call cflags_for_lib, xcb-keysyms) ifeq ($(shell pkg-config --exists xcb-util || echo 1),1) -CFLAGS += -DXCB_COMPAT +CPPFLAGS += -DXCB_COMPAT CFLAGS += $(call cflags_for_lib, xcb-atom) CFLAGS += $(call cflags_for_lib, xcb-aux) else @@ -45,9 +45,9 @@ CFLAGS += $(call cflags_for_lib, xcursor) CFLAGS += $(call cflags_for_lib, x11) CFLAGS += $(call cflags_for_lib, yajl) CFLAGS += $(call cflags_for_lib, libev) -CFLAGS += -DI3_VERSION=\"${GIT_VERSION}\" -CFLAGS += -DSYSCONFDIR=\"${SYSCONFDIR}\" -CFLAGS += -DTERM_EMU=\"$(TERM_EMU)\" +CPPFLAGS += -DI3_VERSION=\"${GIT_VERSION}\" +CPPFLAGS += -DSYSCONFDIR=\"${SYSCONFDIR}\" +CPPFLAGS += -DTERM_EMU=\"$(TERM_EMU)\" LDFLAGS += -lm LDFLAGS += $(call ldflags_for_lib, xcb-event, xcb-event) @@ -88,7 +88,7 @@ endif CFLAGS += -idirafter yajl-fallback ifneq (,$(filter Linux GNU GNU/%, $(UNAME))) -CFLAGS += -D_GNU_SOURCE +CPPFLAGS += -D_GNU_SOURCE endif ifeq ($(DEBUG),1) diff --git a/i3-config-wizard/Makefile b/i3-config-wizard/Makefile index 07d6484d..51b030f2 100644 --- a/i3-config-wizard/Makefile +++ b/i3-config-wizard/Makefile @@ -11,7 +11,7 @@ HEADERS:=$(wildcard *.h) # Depend on the specific file (.c for each .o) and on all headers %.o: %.c ${HEADERS} echo "CC $<" - $(CC) $(CFLAGS) -c -o $@ $< + $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< all: cfgparse.y.o cfgparse.yy.o ${FILES} echo "LINK i3-config-wizard" @@ -20,12 +20,12 @@ all: cfgparse.y.o cfgparse.yy.o ${FILES} cfgparse.yy.o: cfgparse.l cfgparse.y.o ${HEADERS} echo "LEX $<" flex -i -o$(@:.o=.c) $< - $(CC) $(CFLAGS) -c -o $@ $(@:.o=.c) + $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(@:.o=.c) cfgparse.y.o: cfgparse.y ${HEADERS} echo "YACC $<" bison --debug --verbose -b $(basename $< .y) -d $< - $(CC) $(CFLAGS) -c -o $@ $(<:.y=.tab.c) + $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $(<:.y=.tab.c) install: all diff --git a/i3-input/Makefile b/i3-input/Makefile index 74f3f8da..12658dcd 100644 --- a/i3-input/Makefile +++ b/i3-input/Makefile @@ -10,7 +10,7 @@ HEADERS=$(wildcard *.h) # Depend on the specific file (.c for each .o) and on all headers %.o: %.c ${HEADERS} echo "CC $<" - $(CC) $(CFLAGS) -c -o $@ $< + $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< all: ${FILES} echo "LINK i3-input" diff --git a/i3-msg/Makefile b/i3-msg/Makefile index d75d807c..29de9263 100644 --- a/i3-msg/Makefile +++ b/i3-msg/Makefile @@ -12,7 +12,7 @@ HEADERS=$(wildcard *.h) # Depend on the specific file (.c for each .o) and on all headers %.o: %.c ${HEADERS} echo "CC $<" - $(CC) $(CFLAGS) -c -o $@ $< + $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< all: ${FILES} echo "LINK i3-msg" diff --git a/i3-nagbar/Makefile b/i3-nagbar/Makefile index 8d9283bc..76b1ca4c 100644 --- a/i3-nagbar/Makefile +++ b/i3-nagbar/Makefile @@ -10,7 +10,7 @@ HEADERS=$(wildcard *.h) # Depend on the specific file (.c for each .o) and on all headers %.o: %.c ${HEADERS} echo "CC $<" - $(CC) $(CFLAGS) -c -o $@ $< + $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $< all: ${FILES} echo "LINK i3-nagbar"