]> bbs.cooldavid.org Git - net-next-2.6.git/commitdiff
kbuild: enable 'make CPPFLAGS=...' to add additional options to CPP
authorSam Ravnborg <sam@neptun.(none)>
Mon, 15 Oct 2007 20:17:25 +0000 (22:17 +0200)
committerSam Ravnborg <sam@neptun.(none)>
Mon, 15 Oct 2007 20:17:25 +0000 (22:17 +0200)
The variable CPPFLAGS is a wellknown variable and the usage by
kbuild may result in unexpected behaviour.

This patch replace use of CPPFLAGS with KBUILD_CPPFLAGS all over the
tree and enabling one to use:
make CPPFLAGS=...
to specify additional CPP commandline options.

Patch was tested on following architectures:
alpha, arm, i386, x86_64, mips, sparc, sparc64, ia64, m68k, s390

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Documentation/kbuild/makefiles.txt
Makefile
arch/arm/Makefile
arch/ia64/Makefile
arch/powerpc/Makefile
arch/ppc/Makefile
arch/um/Makefile-x86_64
drivers/atm/Makefile
scripts/Makefile.lib

index f4779cd1542fd5ffadcfb6a5075695d4bcc7b44f..08fbe6cd309d7368cf529dc4a0b7299fd91e63be 100644 (file)
@@ -1099,7 +1099,7 @@ When kbuild executes, the following steps are followed (roughly):
        specified options when building the target vmlinux.lds.
 
        When building the *.lds target, kbuild uses the variables:
-       CPPFLAGS        : Set in top-level Makefile
+       KBUILD_CPPFLAGS : Set in top-level Makefile
        EXTRA_CPPFLAGS  : May be set in the kbuild makefile
        CPPFLAGS_$(@F)  : Target specific flags.
                          Note that the full filename is used in this
index ad0add0fa7d42ca5d4c8391f67fbb77c7a1aeda4..ed65de7078c7df3772651a0f8dc8f931e6d6559d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -318,7 +318,7 @@ LINUXINCLUDE    := -Iinclude \
                    $(if $(KBUILD_SRC),-Iinclude2 -I$(srctree)/include) \
                   -include include/linux/autoconf.h
 
-CPPFLAGS        := -D__KERNEL__ $(LINUXINCLUDE)
+KBUILD_CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE)
 
 KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
                   -fno-strict-aliasing -fno-common \
@@ -334,7 +334,7 @@ export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
 export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE
 export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
 
-export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
+export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
 export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
 export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
 
@@ -523,9 +523,10 @@ KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
 # disable pointer signed / unsigned warnings in gcc 4.0
 KBUILD_CFLAGS += $(call cc-option,-Wno-pointer-sign,)
 
-# Add user supplied AFLAGS and CFLAGS as the last assignments
-KBUILD_AFLAGS += $(AFLAGS)
-KBUILD_CFLAGS += $(CFLAGS)
+# Add user supplied CPPFLAGS, AFLAGS and CFLAGS as the last assignments
+KBUILD_CPPFLAGS += $(CPPFLAGS)
+KBUILD_AFLAGS   += $(AFLAGS)
+KBUILD_CFLAGS   += $(CFLAGS)
 
 # Use --build-id when available.
 LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\
@@ -1507,7 +1508,7 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN   $(wildcard $(rm-files))
 
 
 a_flags = -Wp,-MD,$(depfile) $(KBUILD_AFLAGS) $(AFLAGS_KERNEL) \
-         $(NOSTDINC_FLAGS) $(CPPFLAGS) \
+         $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \
          $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o)
 
 quiet_cmd_as_o_S = AS      $@
index b762d235b81a9846e36f087958d46585c9f0d869..0d450e757e0e6561c36aa3598214a9e7bf63c8b1 100644 (file)
@@ -32,11 +32,11 @@ KBUILD_CFLAGS       +=-fno-omit-frame-pointer -mapcs -mno-sched-prolog
 endif
 
 ifeq ($(CONFIG_CPU_BIG_ENDIAN),y)
-CPPFLAGS       += -mbig-endian
+KBUILD_CPPFLAGS        += -mbig-endian
 AS             += -EB
 LD             += -EB
 else
-CPPFLAGS       += -mlittle-endian
+KBUILD_CPPFLAGS        += -mlittle-endian
 AS             += -EL
 LD             += -EL
 endif
index 9708a29c70b59951a7d379b86d91dc46a866002b..34951aa2370b861d0f0b2b8e91cdf70188cadbd3 100644 (file)
@@ -29,7 +29,7 @@ cflags-y      := -pipe $(EXTRA) -ffixed-r13 -mfixed-range=f12-f15,f32-f127 \
 CFLAGS_KERNEL  := -mconstant-gp
 
 GAS_STATUS     = $(shell $(srctree)/arch/ia64/scripts/check-gas "$(CC)" "$(OBJDUMP)")
-CPPFLAGS += $(shell $(srctree)/arch/ia64/scripts/toolchain-flags "$(CC)" "$(OBJDUMP)" "$(READELF)")
+KBUILD_CPPFLAGS += $(shell $(srctree)/arch/ia64/scripts/toolchain-flags "$(CC)" "$(OBJDUMP)" "$(READELF)")
 
 ifeq ($(GAS_STATUS),buggy)
 $(error Sorry, you need a newer version of the assember, one that is built from        \
index 462bb89b67e8ccf920c4ea90202a002df9094369..4e165342210aa84b508a91e11ef6a8c44148b980 100644 (file)
@@ -75,7 +75,7 @@ CPPFLAGS-$(CONFIG_PPC32) := -Iarch/$(ARCH)
 AFLAGS-$(CONFIG_PPC32) := -Iarch/$(ARCH)
 CFLAGS-$(CONFIG_PPC64) := -mminimal-toc -mtraceback=none  -mcall-aixdesc
 CFLAGS-$(CONFIG_PPC32) := -Iarch/$(ARCH) -ffixed-r2 -mmultiple
-CPPFLAGS       += $(CPPFLAGS-y)
+KBUILD_CPPFLAGS        += $(CPPFLAGS-y)
 KBUILD_AFLAGS  += $(AFLAGS-y)
 KBUILD_CFLAGS  += -msoft-float -pipe $(CFLAGS-y)
 CPP            = $(CC) -E $(KBUILD_CFLAGS)
index dd63ccb6673218e12f8406ffbe91c6a9bee3fa9e..95894ef7beaaded9dfc993904e275a1a9f874e41 100644 (file)
@@ -22,7 +22,7 @@ endif
 
 LDFLAGS_vmlinux        := -Ttext $(KERNELLOAD) -Bstatic
 # The -Iarch/$(ARCH)/include is temporary while we are merging
-CPPFLAGS       += -Iarch/$(ARCH) -Iarch/$(ARCH)/include
+KBUILD_CPPFLAGS        += -Iarch/$(ARCH) -Iarch/$(ARCH)/include
 KBUILD_AFLAGS  += -Iarch/$(ARCH)
 KBUILD_CFLAGS  += -Iarch/$(ARCH) -msoft-float -pipe \
                -ffixed-r2 -mmultiple
index 8836f0df36aa703d07ac3c8f96632114d9a7495b..bcfd6ea3003044f9351989063e8e8181129c3045 100644 (file)
@@ -14,7 +14,7 @@ KBUILD_CFLAGS += $(_extra_flags_)
 CHECKFLAGS  += -m64
 KBUILD_AFLAGS += -m64
 LDFLAGS += -m elf_x86_64
-CPPFLAGS += -m64
+KBUILD_CPPFLAGS += -m64
 
 ELF_ARCH := i386:x86-64
 ELF_FORMAT := elf64-x86-64
index 1b16f8166b094ae474b94f6da5401fe3a9179c19..e4fa99658699a8d0240e6febd9107ed48b4078d4 100644 (file)
@@ -41,7 +41,7 @@ ifeq ($(CONFIG_ATM_FORE200E_PCA),y)
   # guess the target endianess to choose the right PCA-200E firmware image
   ifeq ($(CONFIG_ATM_FORE200E_PCA_DEFAULT_FW),y)
     byteorder.h                        := include$(if $(patsubst $(srctree),,$(objtree)),2)/asm/byteorder.h
-    CONFIG_ATM_FORE200E_PCA_FW := $(obj)/pca200e$(if $(shell $(CC) $(CPPFLAGS) -E -dM $(byteorder.h) | grep ' __LITTLE_ENDIAN '),.bin,_ecd.bin2)
+    CONFIG_ATM_FORE200E_PCA_FW := $(obj)/pca200e$(if $(shell $(CC) $(KBUILD_CPPFLAGS) -E -dM $(byteorder.h) | grep ' __LITTLE_ENDIAN '),.bin,_ecd.bin2)
   endif
 endif
 
index 2837adaa9850bc246afc7909296d8421293786fc..95e6e0fbdbd0cee33ad9649a5db8f2d9d330b266 100644 (file)
@@ -86,7 +86,7 @@ modname_flags  = $(if $(filter 1,$(words $(modname))),\
 
 _c_flags       = $(KBUILD_CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(basetarget).o)
 _a_flags       = $(KBUILD_AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o)
-_cpp_flags     = $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CPPFLAGS_$(@F))
+_cpp_flags     = $(KBUILD_CPPFLAGS) $(EXTRA_CPPFLAGS) $(CPPFLAGS_$(@F))
 
 # If building the kernel in a separate objtree expand all occurrences
 # of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
@@ -106,11 +106,11 @@ __a_flags =                          $(call flags,_a_flags)
 __cpp_flags     =                          $(call flags,_cpp_flags)
 endif
 
-c_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \
+c_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \
                 $(__c_flags) $(modkern_cflags) \
                 -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags)
 
-a_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(CPPFLAGS) \
+a_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \
                 $(__a_flags) $(modkern_aflags)
 
 cpp_flags      = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(__cpp_flags)