From f7066d7dcaed828bbf61ba9a9d7526516a96b445 Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Fri, 22 Feb 2013 18:08:56 +0400 Subject: [PATCH] make: Provide mandatory options in cflags-y variable In case if CFLAGS is overriden from command line we don't see our headers anymore. So provide mandatory options in ccflags-y variable to fix that. https://bugzilla.openvz.org/show_bug.cgi?id=2521 Reported-by: Jan Engelhardt Signed-off-by: Cyrill Gorcunov Tested-by: Alexander Kartashov Signed-off-by: Pavel Emelyanov --- Makefile | 7 +++++-- pie/Makefile | 2 +- scripts/Makefile.rules | 14 +++++++------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 6bfc0d8a5..c2b2d7b76 100644 --- a/Makefile +++ b/Makefile @@ -76,8 +76,10 @@ ARCH_DIR := arch/$(ARCH) $(if $(wildcard $(ARCH_DIR)),,$(error "The architecture $(ARCH) isn't supported")) -CFLAGS += -iquote include -iquote pie -iquote . -iquote $(ARCH_DIR) -CFLAGS += -iquote $(ARCH_DIR)/include -fno-strict-aliasing +cflags-y += -iquote include -iquote pie -iquote . +cflags-y += -iquote $(ARCH_DIR) -iquote $(ARCH_DIR)/include +cflags-y += -fno-strict-aliasing +export cflags-y LIBS := -lrt -lpthread -lprotobuf-c @@ -103,6 +105,7 @@ ARCH-LIB := arch/$(ARCH)/crtools.built-in.o export E Q CC ECHO MAKE CFLAGS LIBS ARCH DEFINES MAKEFLAGS export SRC_DIR SYSCALL-LIB SH RM ARCH_DIR OBJCOPY LDARCH LD +export cflags-y include scripts/Makefile.version include scripts/Makefile.rules diff --git a/pie/Makefile b/pie/Makefile index b82a563a2..408d9550f 100644 --- a/pie/Makefile +++ b/pie/Makefile @@ -12,7 +12,7 @@ restorer-obj-y += restorer.o restorer-obj-e += $(ARCH_DIR)/restorer.o restorer-libs-e += $(SYSCALL-LIB) -CFLAGS += -fpie -Wa,--noexecstack -fno-strict-aliasing +cflags-y += -fpie -Wa,--noexecstack -fno-strict-aliasing ASMFLAGS += -D__ASSEMBLY__ GEN-OFFSETS := gen-offsets.sh diff --git a/scripts/Makefile.rules b/scripts/Makefile.rules index c19767897..194dca7bf 100644 --- a/scripts/Makefile.rules +++ b/scripts/Makefile.rules @@ -5,43 +5,43 @@ define gen-rule-o-from-c-by-name $(1).o: $(1).c $$(E) " CC " $$@ - $$(Q) $$(CC) -c $$(CFLAGS) $(2) $$< -o $$@ + $$(Q) $$(CC) -c $$(CFLAGS) $$(cflags-y) $(2) $$< -o $$@ endef define gen-rule-i-from-c-by-name $(1).i: $(1).c $$(E) " CC " $$@ - $$(Q) $$(CC) -E $$(CFLAGS) $(2) $$< -o $$@ + $$(Q) $$(CC) -E $$(CFLAGS) $$(cflags-y) $(2) $$< -o $$@ endef define gen-rule-s-from-c-by-name $(1).s: $(1).c $$(E) " CC " $$@ - $$(Q) $$(CC) -S $$(CFLAGS) $(2) -fverbose-asm $$< -o $$@ + $$(Q) $$(CC) -S $$(CFLAGS) $$(cflags-y) $(2) -fverbose-asm $$< -o $$@ endef define gen-rule-o-from-S-by-name $(1).o: $(1).S $$(E) " CC " $$@ - $$(Q) $$(CC) -c $$(CFLAGS) $(2) $$(ASMFLAGS) $(3) $$< -o $$@ + $$(Q) $$(CC) -c $$(CFLAGS) $$(cflags-y) $(2) $$(ASMFLAGS) $(3) $$< -o $$@ endef define gen-rule-d-from-c-by-name $(1).d: $(1).c $$(E) " DEP " $$@ - $$(Q) $$(CC) -M -MT $$@ -MT $$(patsubst %.d,%.o,$$@) $$(CFLAGS) $(2) $$< -o $$@ + $$(Q) $$(CC) -M -MT $$@ -MT $$(patsubst %.d,%.o,$$@) $$(CFLAGS) $$(cflags-y) $(2) $$< -o $$@ endef define gen-rule-d-from-S-by-name $(1).d: $(1).S $$(E) " DEP " $$@ - $$(Q) $$(CC) -M -MT $$@ -MT $$(patsubst %.d,%.o,$$@) $$(CFLAGS) $(2) $$< -o $$@ + $$(Q) $$(CC) -M -MT $$@ -MT $$(patsubst %.d,%.o,$$@) $$(CFLAGS) $$(cflags-y) $(2) $$< -o $$@ endef define gen-rule-i-from-S-by-name $(1).i: $(1).S $$(E) " CC " $$@ - $$(Q) $$(CC) -E $$(CFLAGS) $(2) $$< -o $$@ + $$(Q) $$(CC) -E $$(CFLAGS) $$(cflags-y) $(2) $$< -o $$@ endef ##