linux-arch.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* kbuild: enable possibility to specify xFLAGS on commandline
@ 2007-09-09 18:02 Sam Ravnborg
  2007-09-09 18:04 ` [PATCH 1/4] kbuild: enable 'make CFLAGS=...' to add additional options to CC Sam Ravnborg
                   ` (4 more replies)
  0 siblings, 5 replies; 9+ messages in thread
From: Sam Ravnborg @ 2007-09-09 18:02 UTC (permalink / raw)
  To: linux arch, Andi Kleen, kbuild devel, Tony Luck; +Cc: Sam Ravnborg

Following patchset enable the possibility to specify 
CFLAGS, AFLAGS or CPPFLAGS on the commandline to add
additional options while building the kernel.

The patch prefix all uses of CFLAGS, AFLAGS and CPPFLAGS
with KBUILD_ which touches all arch Makefiles.

Regression testing was very simple. Since this patch did not
change behaviour adding the patch should not cause any recompile
and this was tested with defconfig on several architectures.
To be more specific on:
alpha arm i386 mips sparc sparc64 x86_64 ia64 m68k s390

powerpc I dave a toolchain but defconfig seems not to be present.
blackfin and um did not build.

A small cleanup patch for ia64 sneaked in too - to allow the
above mentioned regression test.

The patchset will conflict with a patch from Andi Kleen.
If the patch for x86_64 will be pushed for -rc - no troubles.
If the patch await next mergewindow I could take it in my tree
to avoid the conflict.

The patch in question is:
ftp://ftp.firstfloor.org/pub/ak/x86_64/quilt/patches/cflags-probe


The purpose of this patch is to make it much simpler to try out
different gcc options.
The receipe is the following:

make CFLAGS=-fmuch-quicker-kernel mm/slub.o
make KBUILD_NOCMDDEP=1

The KBUILD_NOCMDDEP=1 tell kbuild not to check any commandline
arguments and can be used to change options AND compiler.
Without this kbuild would detech changes in commandline options
and rebuild mm/slub.o again.

Any objections to this change?

	Sam


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH 1/4] kbuild: enable 'make CFLAGS=...' to add additional options to CC
  2007-09-09 18:02 kbuild: enable possibility to specify xFLAGS on commandline Sam Ravnborg
@ 2007-09-09 18:04 ` Sam Ravnborg
  2007-09-09 18:05 ` [PATCH 2/4] kbuild: enable 'make AFLAGS=...' to add additional options to AS Sam Ravnborg
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Sam Ravnborg @ 2007-09-09 18:04 UTC (permalink / raw)
  To: linux arch, Andi Kleen, kbuild devel, Tony Luck

The variable CFLAGS is a wellknown variable and the usage by
kbuild may result in unexpected behaviour.
On top of that several people over time has asked for a way to
pass in additional flags to gcc.

This patch replace use of CFLAGS with KBUILD_CFLAGS all over the
tree and enabling one to use:
make CFLAGS=...
to specify additional gcc commandline options.

One specific usecase are when trying to find gcc bugs but other
usages has been requested too.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
 Documentation/kbuild/makefiles.txt     |   15 +++++++++------
 Makefile                               |   23 +++++++++++++----------
 arch/alpha/Makefile                    |    2 +-
 arch/alpha/kernel/Makefile             |    2 +-
 arch/alpha/lib/Makefile                |    2 +-
 arch/arm/Makefile                      |    6 +++---
 arch/arm/boot/compressed/Makefile      |    2 +-
 arch/avr32/Makefile                    |    4 ++--
 arch/blackfin/Makefile                 |    2 +-
 arch/cris/Makefile                     |    8 ++++----
 arch/frv/Makefile                      |   22 +++++++++++-----------
 arch/h8300/Makefile                    |   12 ++++++------
 arch/i386/Makefile                     |   10 +++++-----
 arch/i386/boot/Makefile                |    4 ++--
 arch/i386/boot/compressed/Makefile     |    2 +-
 arch/i386/math-emu/Makefile            |    2 +-
 arch/ia64/Makefile                     |    2 +-
 arch/m32r/Makefile                     |    6 +++---
 arch/m68k/Makefile                     |    8 ++++----
 arch/m68knommu/Makefile                |    6 +++---
 arch/mips/Makefile                     |    6 +++---
 arch/mips/kernel/Makefile              |    2 +-
 arch/mips/lemote/lm2e/Makefile         |    2 +-
 arch/mips/sibyte/common/Makefile       |    2 +-
 arch/parisc/Makefile                   |    2 +-
 arch/powerpc/Makefile                  |   22 +++++++++++-----------
 arch/ppc/Makefile                      |   10 +++++-----
 arch/ppc/boot/Makefile                 |    2 +-
 arch/s390/Makefile                     |    8 ++++----
 arch/sh/Makefile                       |    4 ++--
 arch/sh/boot/compressed/Makefile       |    2 +-
 arch/sh64/Makefile                     |    4 ++--
 arch/sparc/Makefile                    |    6 +++---
 arch/sparc64/Makefile                  |    6 +++---
 arch/um/Makefile                       |   10 +++++-----
 arch/um/Makefile-i386                  |    4 ++--
 arch/um/Makefile-os-Linux              |    2 +-
 arch/um/Makefile-x86_64                |    2 +-
 arch/um/drivers/Makefile               |    2 +-
 arch/um/sys-i386/Makefile              |    2 +-
 arch/um/sys-x86_64/Makefile            |    2 +-
 arch/v850/Makefile                     |    8 ++++----
 arch/x86_64/Makefile                   |    2 +-
 arch/x86_64/boot/compressed/Makefile   |    4 ++--
 arch/x86_64/vdso/Makefile              |    4 ++--
 arch/xtensa/Makefile                   |    4 ++--
 arch/xtensa/boot/Makefile              |    4 ++--
 arch/xtensa/boot/boot-redboot/Makefile |    2 +-
 init/Makefile                          |    2 +-
 scripts/Kbuild.include                 |    6 +++---
 scripts/Makefile.lib                   |    2 +-
 51 files changed, 143 insertions(+), 137 deletions(-)

diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index e08ef87..4df47e4 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -294,7 +294,7 @@ more details, with real examples.
 
 
 	This variable is necessary because the top Makefile owns the
-	variable $(CFLAGS) and uses it for compilation flags for the
+	variable $(KBUILD_CFLAGS) and uses it for compilation flags for the
 	entire tree.
 
 	$(EXTRA_AFLAGS) is a similar string for per-directory options
@@ -438,6 +438,7 @@ more details, with real examples.
 	-march=pentium-mmx if supported by $(CC), otherwise -march=i586.
 	The second argument to cc-option is optional, and if omitted,
 	cflags-y will be assigned no value if first option is not supported.
+	Note: cc-option uses KBUILD_CFLAGS for $(CC) options
 
    cc-option-yn
 	cc-option-yn is used to check if gcc supports a given option
@@ -453,6 +454,7 @@ more details, with real examples.
 	option. When $(biarch) equals 'y', the expanded variables $(aflags-y)
 	and $(cflags-y) will be assigned the values -a32 and -m32,
 	respectively.
+	Note: cc-option-yn uses KBUILD_CFLAGS for $(CC) options
 
     cc-option-align
 	gcc versions >= 3.0 changed the type of options used to specify
@@ -464,10 +466,11 @@ more details, with real examples.
 		cc-option-align = -falign
 
 	Example:
-		CFLAGS += $(cc-option-align)-functions=4
+		KBUILD_CFLAGS += $(cc-option-align)-functions=4
 
 	In the above example, the option -falign-functions=4 is used for
 	gcc >= 3.00. For gcc < 3.00, -malign-functions=4 is used.
+	Note: cc-option-align uses KBUILD_CFLAGS for $(CC) options
 
     cc-version
 	cc-version returns a numerical version of the $(CC) compiler version.
@@ -826,17 +829,17 @@ When kbuild executes, the following steps are followed (roughly):
 		#arch/sparc64/Makefile
 		AFLAGS += -m64 -mcpu=ultrasparc
 
-    CFLAGS		$(CC) compiler flags
+    KBUILD_CFLAGS		$(CC) compiler flags
 
 	Default value - see top level Makefile
 	Append or modify as required per architecture.
 
-	Often, the CFLAGS variable depends on the configuration.
+	Often, the KBUILD_CFLAGS variable depends on the configuration.
 
 	Example:
 		#arch/i386/Makefile
 		cflags-$(CONFIG_M386) += -march=i386
-		CFLAGS += $(cflags-y)
+		KBUILD_CFLAGS += $(cflags-y)
 
 	Many arch Makefiles dynamically run the target C compiler to
 	probe supported options:
@@ -848,7 +851,7 @@ When kbuild executes, the following steps are followed (roughly):
 						-march=pentium2,-march=i686)
 		...
 		# Disable unit-at-a-time mode ...
-		CFLAGS += $(call cc-option,-fno-unit-at-a-time)
+		KBUILD_CFLAGS += $(call cc-option,-fno-unit-at-a-time)
 		...
 
 
diff --git a/Makefile b/Makefile
index 5118ae8..2a83bf3 100644
--- a/Makefile
+++ b/Makefile
@@ -312,7 +312,7 @@ LINUXINCLUDE    := -Iinclude \
 
 CPPFLAGS        := -D__KERNEL__ $(LINUXINCLUDE)
 
-CFLAGS          := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
+KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
 		   -fno-strict-aliasing -fno-common \
 		   -Werror-implicit-function-declaration
 AFLAGS          := -D__ASSEMBLY__
@@ -327,7 +327,7 @@ 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 CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
+export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
 export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
 
 # When compiling out-of-tree modules, put MODVERDIR in the module
@@ -484,35 +484,38 @@ endif # $(dot-config)
 all: vmlinux
 
 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
-CFLAGS		+= -Os
+KBUILD_CFLAGS += -Os
 else
-CFLAGS		+= -O2
+KBUILD_CFLAGS += -O2
 endif
 
 include $(srctree)/arch/$(ARCH)/Makefile
 
 ifdef CONFIG_FRAME_POINTER
-CFLAGS		+= -fno-omit-frame-pointer -fno-optimize-sibling-calls
+KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
 else
-CFLAGS		+= -fomit-frame-pointer
+KBUILD_CFLAGS += -fomit-frame-pointer
 endif
 
 ifdef CONFIG_DEBUG_INFO
-CFLAGS		+= -g
+KBUILD_CFLAGS += -g
 endif
 
 # Force gcc to behave correct even for buggy distributions
-CFLAGS          += $(call cc-option, -fno-stack-protector)
+KBUILD_CFLAGS += $(call cc-option, -fno-stack-protector)
 
 # arch Makefile may override CC so keep this after arch Makefile is included
 NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
 CHECKFLAGS     += $(NOSTDINC_FLAGS)
 
 # warn about C99 declaration after statement
-CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
+KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
 
 # disable pointer signed / unsigned warnings in gcc 4.0
-CFLAGS += $(call cc-option,-Wno-pointer-sign,)
+KBUILD_CFLAGS += $(call cc-option,-Wno-pointer-sign,)
+
+# Add user supplied CFLAGS as the last assignment
+KBUILD_CFLAGS += $(CFLAGS)
 
 # Use --build-id when available.
 LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\
diff --git a/arch/alpha/Makefile b/arch/alpha/Makefile
index 1b704ee..2f283b2 100644
--- a/arch/alpha/Makefile
+++ b/arch/alpha/Makefile
@@ -84,7 +84,7 @@ endif
 # For TSUNAMI, we must have the assembler not emulate our instructions.
 # The same is true for IRONGATE, POLARIS, PYXIS.
 # BWX is most important, but we don't really want any emulation ever.
-CFLAGS += $(cflags-y) -Wa,-mev6
+KBUILD_CFLAGS += $(cflags-y) -Wa,-mev6
 
 head-y := arch/alpha/kernel/head.o
 
diff --git a/arch/alpha/kernel/Makefile b/arch/alpha/kernel/Makefile
index ab6fa54..dccf052 100644
--- a/arch/alpha/kernel/Makefile
+++ b/arch/alpha/kernel/Makefile
@@ -3,7 +3,7 @@
 #
 
 extra-y		:= head.o vmlinux.lds
-EXTRA_AFLAGS	:= $(CFLAGS)
+EXTRA_AFLAGS	:= $(KBUILD_CFLAGS)
 EXTRA_CFLAGS	:= -Werror -Wno-sign-compare
 
 obj-y    := entry.o traps.o process.o init_task.o osf_sys.o irq.o \
diff --git a/arch/alpha/lib/Makefile b/arch/alpha/lib/Makefile
index 266f78e..9b72c59 100644
--- a/arch/alpha/lib/Makefile
+++ b/arch/alpha/lib/Makefile
@@ -2,7 +2,7 @@
 # Makefile for alpha-specific library files..
 #
 
-EXTRA_AFLAGS := $(CFLAGS)
+EXTRA_AFLAGS := $(KBUILD_CFLAGS)
 EXTRA_CFLAGS := -Werror
 
 # Many of these routines have implementations tuned for ev6.
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index fa4ea9f..6eff3c9 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -16,7 +16,7 @@ OBJCOPYFLAGS	:=-O binary -R .note -R .comment -S
 GZFLAGS		:=-9
 #CFLAGS		+=-pipe
 # Explicitly specifiy 32-bit ARM ISA since toolchain default can be -mthumb:
-CFLAGS		+=$(call cc-option,-marm,)
+KBUILD_CFLAGS	+=$(call cc-option,-marm,)
 
 # Do not use arch/arm/defconfig - it's always outdated.
 # Select a platform tht is kept up-to-date
@@ -28,7 +28,7 @@ MMUEXT		:= -nommu
 endif
 
 ifeq ($(CONFIG_FRAME_POINTER),y)
-CFLAGS		+=-fno-omit-frame-pointer -mapcs -mno-sched-prolog
+KBUILD_CFLAGS	+=-fno-omit-frame-pointer -mapcs -mno-sched-prolog
 endif
 
 ifeq ($(CONFIG_CPU_BIG_ENDIAN),y)
@@ -85,7 +85,7 @@ CFLAGS_ABI	:=$(call cc-option,-mapcs-32,-mabi=apcs-gnu) $(call cc-option,-mno-th
 endif
 
 # Need -Uarm for gcc < 3.x
-CFLAGS		+=$(CFLAGS_ABI) $(arch-y) $(tune-y) $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) -msoft-float -Uarm
+KBUILD_CFLAGS	+=$(CFLAGS_ABI) $(arch-y) $(tune-y) $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) -msoft-float -Uarm
 AFLAGS		+=$(CFLAGS_ABI) $(arch-y) $(tune-y) -msoft-float
 
 CHECKFLAGS	+= -D__arm__
diff --git a/arch/arm/boot/compressed/Makefile b/arch/arm/boot/compressed/Makefile
index 6b8cbd6..5fde99f 100644
--- a/arch/arm/boot/compressed/Makefile
+++ b/arch/arm/boot/compressed/Makefile
@@ -87,7 +87,7 @@ ifneq ($(PARAMS_PHYS),)
 LDFLAGS_vmlinux += --defsym params_phys=$(PARAMS_PHYS)
 endif
 LDFLAGS_vmlinux += -p --no-undefined -X \
-	$(shell $(CC) $(CFLAGS) --print-libgcc-file-name) -T
+	$(shell $(CC) $(KBUILD_CFLAGS) --print-libgcc-file-name) -T
 
 # Don't allow any static data in misc.o, which
 # would otherwise mess up our GOT table
diff --git a/arch/avr32/Makefile b/arch/avr32/Makefile
index dc6bc01..9883c8b 100644
--- a/arch/avr32/Makefile
+++ b/arch/avr32/Makefile
@@ -11,14 +11,14 @@ all: uImage vmlinux.elf
 
 KBUILD_DEFCONFIG	:= atstk1002_defconfig
 
-CFLAGS		+= -pipe -fno-builtin -mno-pic
+KBUILD_CFLAGS	+= -pipe -fno-builtin -mno-pic
 AFLAGS		+= -mrelax -mno-pic
 CFLAGS_MODULE	+= -mno-relax
 LDFLAGS_vmlinux	+= --relax
 
 cpuflags-$(CONFIG_CPU_AT32AP7000)	+= -mcpu=ap7000
 
-CFLAGS		+= $(cpuflags-y)
+KBUILD_CFLAGS	+= $(cpuflags-y)
 AFLAGS		+= $(cpuflags-y)
 
 CHECKFLAGS	+= -D__avr32__ -D__BIG_ENDIAN
diff --git a/arch/blackfin/Makefile b/arch/blackfin/Makefile
index 2084166..52a6ac0 100644
--- a/arch/blackfin/Makefile
+++ b/arch/blackfin/Makefile
@@ -53,7 +53,7 @@ rev-$(CONFIG_BF_REV_0_5)  := 0.5
 rev-$(CONFIG_BF_REV_NONE) := none
 rev-$(CONFIG_BF_REV_ANY)  := any
 
-CFLAGS += -mcpu=$(cpu-y)-$(rev-y)
+KBUILD_CFLAGS += -mcpu=$(cpu-y)-$(rev-y)
 AFLAGS += -mcpu=$(cpu-y)-$(rev-y)
 
 head-y   := arch/$(ARCH)/mach-$(MACHINE)/head.o arch/$(ARCH)/kernel/init_task.o
diff --git a/arch/cris/Makefile b/arch/cris/Makefile
index ee11469..32ef6f3 100644
--- a/arch/cris/Makefile
+++ b/arch/cris/Makefile
@@ -31,16 +31,16 @@ OBJCOPYFLAGS := -O binary -R .note -R .comment -S
 CPPFLAGS_vmlinux.lds = -DDRAM_VIRTUAL_BASE=0x$(CONFIG_ETRAX_DRAM_VIRTUAL_BASE)
 AFLAGS += -mlinux
 
-CFLAGS := $(CFLAGS) -mlinux -march=$(arch-y) -pipe
+KBUILD_CFLAGS += -mlinux -march=$(arch-y) -pipe
 
 ifdef CONFIG_FRAME_POINTER
-CFLAGS := $(subst -fomit-frame-pointer,,$(CFLAGS)) -g
-CFLAGS += -fno-omit-frame-pointer
+KBUILD_CFLAGS := $(subst -fomit-frame-pointer,,$(KBUILD_CFLAGS)) -g
+KBUILD_CFLAGS += -fno-omit-frame-pointer
 endif
 
 head-y := arch/$(ARCH)/$(SARCH)/kernel/head.o
 
-LIBGCC = $(shell $(CC) $(CFLAGS) -print-file-name=libgcc.a)
+LIBGCC = $(shell $(CC) $(KBUILD_CFLAGS) -print-file-name=libgcc.a)
 
 core-y		+= arch/$(ARCH)/kernel/ arch/$(ARCH)/mm/
 core-y		+= arch/$(ARCH)/$(SARCH)/kernel/ arch/$(ARCH)/$(SARCH)/mm/
diff --git a/arch/frv/Makefile b/arch/frv/Makefile
index 9bf7345..ec89886 100644
--- a/arch/frv/Makefile
+++ b/arch/frv/Makefile
@@ -39,13 +39,13 @@ endif
 ARCHMODFLAGS	+= -G0 -mlong-calls
 
 ifdef CONFIG_GPREL_DATA_8
-CFLAGS		+= -G8
+KBUILD_CFLAGS	+= -G8
 else
 ifdef CONFIG_GPREL_DATA_4
-CFLAGS		+= -G4
+KBUILD_CFLAGS	+= -G4
 else
 ifdef CONFIG_GPREL_DATA_NONE
-CFLAGS		+= -G0
+KBUILD_CFLAGS	+= -G0
 endif
 endif
 endif
@@ -53,25 +53,25 @@ endif
 #LDFLAGS_vmlinux	:= -Map linkmap.txt
 
 ifdef CONFIG_GC_SECTIONS
-CFLAGS		+= -ffunction-sections -fdata-sections
+KBUILD_CFLAGS	+= -ffunction-sections -fdata-sections
 LINKFLAGS	+= --gc-sections
 endif
 
 ifndef CONFIG_FRAME_POINTER
-CFLAGS		+= -mno-linked-fp
+KBUILD_CFLAGS	+= -mno-linked-fp
 endif
 
 ifdef CONFIG_CPU_FR451_COMPILE
-CFLAGS		+= -mcpu=fr450
+KBUILD_CFLAGS	+= -mcpu=fr450
 AFLAGS		+= -mcpu=fr450
 ASFLAGS		+= -mcpu=fr450
 else
 ifdef CONFIG_CPU_FR551_COMPILE
-CFLAGS		+= -mcpu=fr550
+KBUILD_CFLAGS	+= -mcpu=fr550
 AFLAGS		+= -mcpu=fr550
 ASFLAGS		+= -mcpu=fr550
 else
-CFLAGS		+= -mcpu=fr400
+KBUILD_CFLAGS	+= -mcpu=fr400
 AFLAGS		+= -mcpu=fr400
 ASFLAGS		+= -mcpu=fr400
 endif
@@ -80,15 +80,15 @@ endif
 # pretend the kernel is going to run on an FR400 with no media-fp unit
 # - reserve CC3 for use with atomic ops
 # - all the extra registers are dealt with only at context switch time
-CFLAGS		+= -mno-fdpic -mgpr-32 -msoft-float -mno-media
-CFLAGS		+= -ffixed-fcc3 -ffixed-cc3 -ffixed-gr15 -ffixed-icc2
+KBUILD_CFLAGS	+= -mno-fdpic -mgpr-32 -msoft-float -mno-media
+KBUILD_CFLAGS	+= -ffixed-fcc3 -ffixed-cc3 -ffixed-gr15 -ffixed-icc2
 AFLAGS		+= -mno-fdpic
 ASFLAGS		+= -mno-fdpic
 
 # make sure the .S files get compiled with debug info
 # and disable optimisations that are unhelpful whilst debugging
 ifdef CONFIG_DEBUG_INFO
-#CFLAGS		+= -O1
+#KBUILD_CFLAGS	+= -O1
 AFLAGS		+= -Wa,--gdwarf2
 ASFLAGS		+= -Wa,--gdwarf2
 endif
diff --git a/arch/h8300/Makefile b/arch/h8300/Makefile
index 53b5c1e..330e05f 100644
--- a/arch/h8300/Makefile
+++ b/arch/h8300/Makefile
@@ -30,16 +30,16 @@ ldflags-$(CONFIG_CPU_H8300H)	:= -mh8300helf
 cflags-$(CONFIG_CPU_H8S)	:= -ms
 ldflags-$(CONFIG_CPU_H8S)	:= -mh8300self
 
-CFLAGS += $(cflags-y)
-CFLAGS += -mint32 -fno-builtin
-CFLAGS += -g
-CFLAGS += -D__linux__
-CFLAGS += -DUTS_SYSNAME=\"uClinux\"
+KBUILD_CFLAGS += $(cflags-y)
+KBUILD_CFLAGS += -mint32 -fno-builtin
+KBUILD_CFLAGS += -g
+KBUILD_CFLAGS += -D__linux__
+KBUILD_CFLAGS += -DUTS_SYSNAME=\"uClinux\"
 AFLAGS += -DPLATFORM=$(PLATFORM) -DMODEL=$(MODEL) $(cflags-y)
 LDFLAGS += $(ldflags-y)
 
 CROSS_COMPILE = h8300-elf-
-LIBGCC := $(shell $(CROSS-COMPILE)$(CC) $(CFLAGS) -print-libgcc-file-name)
+LIBGCC := $(shell $(CROSS-COMPILE)$(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
 
 head-y := arch/$(ARCH)/platform/$(PLATFORM)/$(BOARD)/crt0_$(MODEL).o
 
diff --git a/arch/i386/Makefile b/arch/i386/Makefile
index 52b9324..252fcc2 100644
--- a/arch/i386/Makefile
+++ b/arch/i386/Makefile
@@ -31,10 +31,10 @@ LDFLAGS_vmlinux := --emit-relocs
 endif
 CHECKFLAGS	+= -D__i386__
 
-CFLAGS += -pipe -msoft-float -mregparm=3 -freg-struct-return
+KBUILD_CFLAGS += -pipe -msoft-float -mregparm=3 -freg-struct-return
 
 # prevent gcc from keeping the stack 16 byte aligned
-CFLAGS += $(call cc-option,-mpreferred-stack-boundary=2)
+KBUILD_CFLAGS += $(call cc-option,-mpreferred-stack-boundary=2)
 
 # CPU-specific tuning. Anything which can be shared with UML should go here.
 include $(srctree)/arch/i386/Makefile.cpu
@@ -48,7 +48,7 @@ cflags-y += -maccumulate-outgoing-args
 
 # Disable unit-at-a-time mode on pre-gcc-4.0 compilers, it makes gcc use
 # a lot more stack due to the lack of sharing of stacklots:
-CFLAGS				+= $(shell if [ $(call cc-version) -lt 0400 ] ; then echo $(call cc-option,-fno-unit-at-a-time); fi ;)
+KBUILD_CFLAGS += $(shell if [ $(call cc-version) -lt 0400 ] ; then echo $(call cc-option,-fno-unit-at-a-time); fi ;)
 
 # do binutils support CFI?
 cflags-y += $(call as-instr,.cfi_startproc\n.cfi_rel_offset esp${comma}0\n.cfi_endproc,-DCONFIG_AS_CFI=1,)
@@ -58,7 +58,7 @@ AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_rel_offset esp${comma}0\n.cfi_end
 cflags-y += $(call as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc,-DCONFIG_AS_CFI_SIGNAL_FRAME=1,)
 AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc,-DCONFIG_AS_CFI_SIGNAL_FRAME=1,)
 
-CFLAGS += $(cflags-y)
+KBUILD_CFLAGS += $(cflags-y)
 
 # Default subarch .c files
 mcore-y  := mach-default
@@ -113,7 +113,7 @@ drivers-$(CONFIG_OPROFILE)		+= arch/i386/oprofile/
 drivers-$(CONFIG_PM)			+= arch/i386/power/
 drivers-$(CONFIG_FB)                    += arch/i386/video/
 
-CFLAGS += $(mflags-y)
+KBUILD_CFLAGS += $(mflags-y)
 AFLAGS += $(mflags-y)
 
 boot := arch/i386/boot
diff --git a/arch/i386/boot/Makefile b/arch/i386/boot/Makefile
index 93386a4..4e896dd 100644
--- a/arch/i386/boot/Makefile
+++ b/arch/i386/boot/Makefile
@@ -50,7 +50,7 @@ HOSTCFLAGS_build.o := $(LINUXINCLUDE)
 # that way we can complain to the user if the CPU is insufficient.
 cflags-i386   := 
 cflags-x86_64 := -m32
-CFLAGS		:= $(LINUXINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
+KBUILD_CFLAGS	:= $(LINUXINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
 		   $(cflags-$(ARCH)) \
 		   -Wall -Wstrict-prototypes \
 		   -march=i386 -mregparm=3 \
@@ -61,7 +61,7 @@ CFLAGS		:= $(LINUXINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
 			$(call cc-option, -fno-unit-at-a-time)) \
 		   $(call cc-option, -fno-stack-protector) \
 		   $(call cc-option, -mpreferred-stack-boundary=2)
-AFLAGS		:= $(CFLAGS) -D__ASSEMBLY__
+AFLAGS		:= $(KBUILD_CFLAGS) -D__ASSEMBLY__
 
 $(obj)/zImage:  IMAGE_OFFSET := 0x1000
 $(obj)/zImage:  EXTRA_AFLAGS := $(SVGA_MODE) $(RAMDISK)
diff --git a/arch/i386/boot/compressed/Makefile b/arch/i386/boot/compressed/Makefile
index 189fa1d..f625914 100644
--- a/arch/i386/boot/compressed/Makefile
+++ b/arch/i386/boot/compressed/Makefile
@@ -11,7 +11,7 @@ EXTRA_AFLAGS	:= -traditional
 LDFLAGS_vmlinux := -T
 hostprogs-y	:= relocs
 
-CFLAGS  := -m32 -D__KERNEL__ $(LINUX_INCLUDE) -O2 \
+KBUILD_CFLAGS  := -m32 -D__KERNEL__ $(LINUX_INCLUDE) -O2 \
 	   -fno-strict-aliasing -fPIC \
 	   $(call cc-option,-ffreestanding) \
 	   $(call cc-option,-fno-stack-protector)
diff --git a/arch/i386/math-emu/Makefile b/arch/i386/math-emu/Makefile
index 9c943fa..324836d 100644
--- a/arch/i386/math-emu/Makefile
+++ b/arch/i386/math-emu/Makefile
@@ -5,7 +5,7 @@
 #DEBUG	= -DDEBUGGING
 DEBUG	=
 PARANOID = -DPARANOID
-CFLAGS	:= $(CFLAGS) $(PARANOID) $(DEBUG) -fno-builtin $(MATH_EMULATION)
+KBUILD_CFLAGS += $(PARANOID) $(DEBUG) -fno-builtin $(MATH_EMULATION)
 
 EXTRA_AFLAGS	:= $(PARANOID)
 
diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile
index 21033ed..9708a29 100644
--- a/arch/ia64/Makefile
+++ b/arch/ia64/Makefile
@@ -44,7 +44,7 @@ ifeq ($(call cc-version),0304)
 	cflags-$(CONFIG_MCKINLEY)	+= -mtune=mckinley
 endif
 
-CFLAGS += $(cflags-y)
+KBUILD_CFLAGS += $(cflags-y)
 head-y := arch/ia64/kernel/head.o arch/ia64/kernel/init_task.o
 
 libs-y				+= arch/ia64/lib/
diff --git a/arch/m32r/Makefile b/arch/m32r/Makefile
index cdf63b2..6380ab6 100644
--- a/arch/m32r/Makefile
+++ b/arch/m32r/Makefile
@@ -9,7 +9,7 @@ LDFLAGS		:=
 OBJCOPYFLAGS	:= -O binary -R .note -R .comment -S
 LDFLAGS_vmlinux	:=
 
-CFLAGS += -pipe -fno-schedule-insns
+KBUILD_CFLAGS += -pipe -fno-schedule-insns
 CFLAGS_KERNEL += -mmodel=medium
 CFLAGS_MODULE += -mmodel=large
 
@@ -24,14 +24,14 @@ endif
 cflags-$(CONFIG_ISA_M32R)	+= -DNO_FPU
 aflags-$(CONFIG_ISA_M32R)	+= -DNO_FPU -O2 -Wa,-no-bitinst
 
-CFLAGS += $(cflags-y)
+KBUILD_CFLAGS += $(cflags-y)
 AFLAGS += $(aflags-y)
 
 CHECKFLAGS	+= -D__m32r__ -D__BIG_ENDIAN__=1
 
 head-y	:= arch/m32r/kernel/head.o arch/m32r/kernel/init_task.o
 
-LIBGCC	:= $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
+LIBGCC	:= $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
 
 libs-y	+= arch/m32r/lib/ $(LIBGCC)
 core-y	+= arch/m32r/kernel/	\
diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile
index aa383a5..4a1bd44 100644
--- a/arch/m68k/Makefile
+++ b/arch/m68k/Makefile
@@ -32,18 +32,18 @@ endif
 CHECKFLAGS += -D__mc68000__
 
 # without -fno-strength-reduce the 53c7xx.c driver fails ;-(
-CFLAGS += -pipe -fno-strength-reduce -ffixed-a2
+KBUILD_CFLAGS += -pipe -fno-strength-reduce -ffixed-a2
 
 # enable processor switch if compiled only for a single cpu
 ifndef CONFIG_M68020
 ifndef CONFIG_M68030
 
 ifndef CONFIG_M68060
-CFLAGS := $(CFLAGS) -m68040
+KBUILD_CFLAGS += -m68040
 endif
 
 ifndef CONFIG_M68040
-CFLAGS := $(CFLAGS) -m68060
+KBUILD_CFLAGS += -m68060
 endif
 
 endif
@@ -52,7 +52,7 @@ endif
 ifdef CONFIG_KGDB
 # If configured for kgdb support, include debugging infos and keep the
 # frame pointer
-CFLAGS := $(subst -fomit-frame-pointer,,$(CFLAGS)) -g
+KBUILD_CFLAGS := $(subst -fomit-frame-pointer,,$(KBUILD_CFLAGS)) -g
 endif
 
 ifndef CONFIG_SUN3
diff --git a/arch/m68knommu/Makefile b/arch/m68knommu/Makefile
index 1305cc9..1c1fbb6 100644
--- a/arch/m68knommu/Makefile
+++ b/arch/m68knommu/Makefile
@@ -104,9 +104,9 @@ cflags-$(CONFIG_M68360)		:= -m68332
 
 AFLAGS += $(cflags-y)
 
-CFLAGS += $(cflags-y)
-CFLAGS += -D__linux__
-CFLAGS += -DUTS_SYSNAME=\"uClinux\"
+KBUILD_CFLAGS += $(cflags-y)
+KBUILD_CFLAGS += -D__linux__
+KBUILD_CFLAGS += -DUTS_SYSNAME=\"uClinux\"
 
 head-y := arch/m68knommu/platform/$(cpuclass-y)/head.o
 
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 32c1c8f..6fc73c4 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -579,13 +579,13 @@ JIFFIES			= jiffies_64
 endif
 
 AFLAGS		+= $(cflags-y)
-CFLAGS		+= $(cflags-y) \
+KBUILD_CFLAGS	+= $(cflags-y) \
 			-D"VMLINUX_LOAD_ADDRESS=$(load-y)"
 
 LDFLAGS			+= -m $(ld-emul)
 
 ifdef CONFIG_MIPS
-CHECKFLAGS += $(shell $(CC) $(CFLAGS) -dM -E -xc /dev/null | \
+CHECKFLAGS += $(shell $(CC) $(KBUILD_CFLAGS) -dM -E -xc /dev/null | \
 	egrep -vw '__GNUC_(|MINOR_|PATCHLEVEL_)_' | \
 	sed -e 's/^\#define /-D/' -e "s/ /='/" -e "s/$$/'/")
 ifdef CONFIG_64BIT
@@ -602,7 +602,7 @@ OBJCOPYFLAGS		+= --remove-section=.reginfo
 #
 
 CPPFLAGS_vmlinux.lds := \
-	$(CFLAGS) \
+	$(KBUILD_CFLAGS) \
 	-D"LOADADDR=$(load-y)" \
 	-D"JIFFIES=$(JIFFIES)" \
 	-D"DATAOFFSET=$(if $(dataoffset-y),$(dataoffset-y),0)"
diff --git a/arch/mips/kernel/Makefile b/arch/mips/kernel/Makefile
index 2fd96d9..4937e46 100644
--- a/arch/mips/kernel/Makefile
+++ b/arch/mips/kernel/Makefile
@@ -69,7 +69,7 @@ obj-$(CONFIG_PCSPEAKER)		+= pcspeaker.o
 obj-$(CONFIG_KEXEC)		+= machine_kexec.o relocate_kernel.o
 obj-$(CONFIG_EARLY_PRINTK)	+= early_printk.o
 
-CFLAGS_cpu-bugs64.o	= $(shell if $(CC) $(CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi)
+CFLAGS_cpu-bugs64.o	= $(shell if $(CC) $(KBUILD_CFLAGS) -Wa,-mdaddi -c -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-DHAVE_AS_SET_DADDI"; fi)
 
 obj-$(CONFIG_HAVE_STD_PC_SERIAL_PORT)	+= 8250-platform.o
 
diff --git a/arch/mips/lemote/lm2e/Makefile b/arch/mips/lemote/lm2e/Makefile
index dcaf6f4..b014a47 100644
--- a/arch/mips/lemote/lm2e/Makefile
+++ b/arch/mips/lemote/lm2e/Makefile
@@ -4,5 +4,5 @@
 
 obj-y += setup.o prom.o reset.o irq.o pci.o bonito-irq.o dbg_io.o mem.o
 
-EXTRA_AFLAGS := $(CFLAGS)
+EXTRA_AFLAGS := $(KBUILD_CFLAGS)
 EXTRA_CFLAGS += -Werror
diff --git a/arch/mips/sibyte/common/Makefile b/arch/mips/sibyte/common/Makefile
index f8ae300..412fce4 100644
--- a/arch/mips/sibyte/common/Makefile
+++ b/arch/mips/sibyte/common/Makefile
@@ -2,5 +2,5 @@ obj-y :=
 
 obj-$(CONFIG_SIBYTE_TBPROF)		+= sb_tbprof.o
 
-EXTRA_AFLAGS := $(CFLAGS)
+EXTRA_AFLAGS := $(KBUILD_CFLAGS)
 EXTRA_CFLAGS += -Werror
diff --git a/arch/parisc/Makefile b/arch/parisc/Makefile
index 760567a..f3d0d7c 100644
--- a/arch/parisc/Makefile
+++ b/arch/parisc/Makefile
@@ -63,7 +63,7 @@ cflags-$(CONFIG_PA8X00)		+= -march=2.0 -mschedule=8000
 
 head-y			:= arch/parisc/kernel/head.o 
 
-CFLAGS	+= $(cflags-y)
+KBUILD_CFLAGS	+= $(cflags-y)
 
 kernel-y			:= mm/ kernel/ math-emu/ kernel/init_task.o
 kernel-$(CONFIG_HPUX)		+= hpux/
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 6c1e36c..6515965 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -70,8 +70,8 @@ CFLAGS-$(CONFIG_PPC64)	:= -mminimal-toc -mtraceback=none  -mcall-aixdesc
 CFLAGS-$(CONFIG_PPC32)	:= -Iarch/$(ARCH) -ffixed-r2 -mmultiple
 CPPFLAGS	+= $(CPPFLAGS-y)
 AFLAGS		+= $(AFLAGS-y)
-CFLAGS		+= -msoft-float -pipe $(CFLAGS-y)
-CPP		= $(CC) -E $(CFLAGS)
+KBUILD_CFLAGS	+= -msoft-float -pipe $(CFLAGS-y)
+CPP		= $(CC) -E $(KBUILD_CFLAGS)
 # Temporary hack until we have migrated to asm-powerpc
 LINUXINCLUDE-$(CONFIG_PPC32)	:= -Iarch/$(ARCH)/include
 LINUXINCLUDE    += $(LINUXINCLUDE-y)
@@ -84,31 +84,31 @@ GCC_BROKEN_VEC	:= $(shell if [ $(call cc-version) -lt 0400 ] ; then echo "y"; fi
 ifeq ($(CONFIG_POWER4_ONLY),y)
 ifeq ($(CONFIG_ALTIVEC),y)
 ifeq ($(GCC_BROKEN_VEC),y)
-	CFLAGS += $(call cc-option,-mcpu=970)
+        KBUILD_CFLAGS += $(call cc-option,-mcpu=970)
 else
-	CFLAGS += $(call cc-option,-mcpu=power4)
+        KBUILD_CFLAGS += $(call cc-option,-mcpu=power4)
 endif
 else
-	CFLAGS += $(call cc-option,-mcpu=power4)
+        KBUILD_CFLAGS += $(call cc-option,-mcpu=power4)
 endif
 else
-	CFLAGS += $(call cc-option,-mtune=power4)
+        KBUILD_CFLAGS += $(call cc-option,-mtune=power4)
 endif
 endif
 
 # No AltiVec instruction when building kernel
-CFLAGS += $(call cc-option,-mno-altivec)
+KBUILD_CFLAGS += $(call cc-option,-mno-altivec)
 
 # Enable unit-at-a-time mode when possible. It shrinks the
 # kernel considerably.
-CFLAGS += $(call cc-option,-funit-at-a-time)
+KBUILD_CFLAGS += $(call cc-option,-funit-at-a-time)
 
 # Never use string load/store instructions as they are
 # often slow when they are implemented at all
-CFLAGS		+= -mno-string
+KBUILD_CFLAGS += -mno-string
 
 ifeq ($(CONFIG_6xx),y)
-CFLAGS		+= -mcpu=powerpc
+KBUILD_CFLAGS += -mcpu=powerpc
 endif
 
 cpu-as-$(CONFIG_4xx)		+= -Wa,-m405
@@ -118,7 +118,7 @@ cpu-as-$(CONFIG_E500)		+= -Wa,-me500
 cpu-as-$(CONFIG_E200)		+= -Wa,-me200
 
 AFLAGS += $(cpu-as-y)
-CFLAGS += $(cpu-as-y)
+KBUILD_CFLAGS += $(cpu-as-y)
 
 head-y				:= arch/powerpc/kernel/head_32.o
 head-$(CONFIG_PPC64)		:= arch/powerpc/kernel/head_64.o
diff --git a/arch/ppc/Makefile b/arch/ppc/Makefile
index 0db66dc..f4f22f7 100644
--- a/arch/ppc/Makefile
+++ b/arch/ppc/Makefile
@@ -24,20 +24,20 @@ LDFLAGS_vmlinux	:= -Ttext $(KERNELLOAD) -Bstatic
 # The -Iarch/$(ARCH)/include is temporary while we are merging
 CPPFLAGS	+= -Iarch/$(ARCH) -Iarch/$(ARCH)/include
 AFLAGS		+= -Iarch/$(ARCH)
-CFLAGS		+= -Iarch/$(ARCH) -msoft-float -pipe \
+KBUILD_CFLAGS	+= -Iarch/$(ARCH) -msoft-float -pipe \
 		-ffixed-r2 -mmultiple
 
 # No AltiVec instruction when building kernel
-CFLAGS		+= $(call cc-option, -mno-altivec)
+KBUILD_CFLAGS	+= $(call cc-option, -mno-altivec)
 
-CPP		= $(CC) -E $(CFLAGS)
+CPP		= $(CC) -E $(KBUILD_CFLAGS)
 # Temporary hack until we have migrated to asm-powerpc
 LINUXINCLUDE    += -Iarch/$(ARCH)/include
 
 CHECKFLAGS	+= -D__powerpc__
 
 ifndef CONFIG_FSL_BOOKE
-CFLAGS		+= -mstring
+KBUILD_CFLAGS	+= -mstring
 endif
 
 cpu-as-$(CONFIG_4xx)		+= -Wa,-m405
@@ -46,7 +46,7 @@ cpu-as-$(CONFIG_E500)		+= -Wa,-me500
 cpu-as-$(CONFIG_E200)		+= -Wa,-me200
 
 AFLAGS += $(cpu-as-y)
-CFLAGS += $(cpu-as-y)
+KBUILD_CFLAGS += $(cpu-as-y)
 
 # Default to the common case.
 KBUILD_DEFCONFIG := common_defconfig
diff --git a/arch/ppc/boot/Makefile b/arch/ppc/boot/Makefile
index b739e25..b0c4628 100644
--- a/arch/ppc/boot/Makefile
+++ b/arch/ppc/boot/Makefile
@@ -13,7 +13,7 @@
 # modified by Cort (cort@cs.nmt.edu)
 #
 
-CFLAGS	 	+= -fno-builtin -D__BOOTER__ -Iarch/$(ARCH)/boot/include
+KBUILD_CFLAGS	+= -fno-builtin -D__BOOTER__ -Iarch/$(ARCH)/boot/include
 HOSTCFLAGS	+= -Iarch/$(ARCH)/boot/include
 
 BOOT_TARGETS	= zImage zImage.initrd znetboot znetboot.initrd
diff --git a/arch/s390/Makefile b/arch/s390/Makefile
index 143ed8e..62a0da4 100644
--- a/arch/s390/Makefile
+++ b/arch/s390/Makefile
@@ -15,7 +15,7 @@
 
 ifndef CONFIG_64BIT
 LDFLAGS		:= -m elf_s390
-CFLAGS		+= -m31
+KBUILD_CFLAGS	+= -m31
 AFLAGS		+= -m31
 UTS_MACHINE	:= s390
 STACK_SIZE	:= 8192
@@ -23,7 +23,7 @@ CHECKFLAGS	+= -D__s390__ -msize-long
 else
 LDFLAGS		:= -m elf64_s390
 MODFLAGS	+= -fpic -D__PIC__
-CFLAGS		+= -m64
+KBUILD_CFLAGS	+= -m64
 AFLAGS		+= -m64
 UTS_MACHINE	:= s390x
 STACK_SIZE	:= 16384
@@ -77,8 +77,8 @@ cflags-$(CONFIG_WARN_STACK) += -mwarn-dynamicstack
 cflags-$(CONFIG_WARN_STACK) += -mwarn-framesize=$(CONFIG_WARN_STACK_SIZE)
 endif
 
-CFLAGS		+= -mbackchain -msoft-float $(cflags-y)
-CFLAGS 		+= -pipe -fno-strength-reduce -Wno-sign-compare 
+KBUILD_CFLAGS	+= -mbackchain -msoft-float $(cflags-y)
+KBUILD_CFLAGS	+= -pipe -fno-strength-reduce -Wno-sign-compare
 AFLAGS		+= $(aflags-y)
 
 OBJCOPYFLAGS	:= -O binary
diff --git a/arch/sh/Makefile b/arch/sh/Makefile
index 97ac586..cd8a411 100644
--- a/arch/sh/Makefile
+++ b/arch/sh/Makefile
@@ -91,12 +91,12 @@ LDFLAGS_vmlinux		+= --defsym 'jiffies=jiffies_64+4'
 LDFLAGS			+= -EB
 endif
 
-CFLAGS		+= -pipe $(cflags-y)
+KBUILD_CFLAGS		+= -pipe $(cflags-y)
 AFLAGS		+= $(cflags-y)
 
 head-y := arch/sh/kernel/head.o arch/sh/kernel/init_task.o
 
-LIBGCC := $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
+LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
 
 core-y				+= arch/sh/kernel/ arch/sh/mm/
 core-$(CONFIG_SH_FPU_EMU)	+= arch/sh/math-emu/
diff --git a/arch/sh/boot/compressed/Makefile b/arch/sh/boot/compressed/Makefile
index 013504a..906a13f 100644
--- a/arch/sh/boot/compressed/Makefile
+++ b/arch/sh/boot/compressed/Makefile
@@ -21,7 +21,7 @@ IMAGE_OFFSET	:= $(shell /bin/bash -c 'printf "0x%08x" \
 			$(CONFIG_MEMORY_START) + \
 			$(CONFIG_BOOT_LINK_OFFSET)]')
 
-LIBGCC	:= $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
+LIBGCC	:= $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
 
 LDFLAGS_vmlinux := -Ttext $(IMAGE_OFFSET) -e startup -T $(obj)/../../kernel/vmlinux.lds
 
diff --git a/arch/sh64/Makefile b/arch/sh64/Makefile
index ebf2004..9e874de 100644
--- a/arch/sh64/Makefile
+++ b/arch/sh64/Makefile
@@ -26,7 +26,7 @@ LDFLAGS			+= -EB  -mshelf32_linux
 endif
 
 # No requirements for endianess support from AFLAGS, 'as' always run through gcc
-CFLAGS		+= $(cpu-y)
+KBUILD_CFLAGS		+= $(cpu-y)
 
 LDFLAGS_vmlinux	+= --defsym phys_stext=_stext-$(CONFIG_CACHED_MEMORY_OFFSET) \
 		  --defsym phys_stext_shmedia=phys_stext+1 \
@@ -57,7 +57,7 @@ ifneq ($(machine-y),)
 core-y	+= arch/sh64/mach-$(machine-y)/
 endif
 
-LIBGCC := $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
+LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
 libs-y	+= arch/$(ARCH)/lib/ $(LIBGCC)
 
 drivers-$(CONFIG_OPROFILE)	+= arch/sh64/oprofile/
diff --git a/arch/sparc/Makefile b/arch/sparc/Makefile
index f33c381..2ce781a 100644
--- a/arch/sparc/Makefile
+++ b/arch/sparc/Makefile
@@ -8,15 +8,15 @@
 #
 
 #
-# Uncomment the first CFLAGS if you are doing kgdb source level
+# Uncomment the first KBUILD_CFLAGS if you are doing kgdb source level
 # debugging of the kernel to get the proper debugging information.
 
 AS              := $(AS) -32
 LDFLAGS		:= -m elf32_sparc
 CHECKFLAGS	+= -D__sparc__
 
-#CFLAGS := $(CFLAGS) -g -pipe -fcall-used-g5 -fcall-used-g7
-CFLAGS := $(CFLAGS) -m32 -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7
+#KBUILD_CFLAGS += -g -pipe -fcall-used-g5 -fcall-used-g7
+KBUILD_CFLAGS += -m32 -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7
 AFLAGS := $(AFLAGS) -m32
 
 #LDFLAGS_vmlinux = -N -Ttext 0xf0004000
diff --git a/arch/sparc64/Makefile b/arch/sparc64/Makefile
index cad10c5..b083dc4 100644
--- a/arch/sparc64/Makefile
+++ b/arch/sparc64/Makefile
@@ -39,17 +39,17 @@ AS		:= $(AS) --undeclared-regs
 endif
 
 ifneq ($(NEW_GCC),y)
-  CFLAGS := $(CFLAGS) -pipe -mno-fpu -mtune=ultrasparc -mmedlow \
+  KBUILD_CFLAGS += -pipe -mno-fpu -mtune=ultrasparc -mmedlow \
 	    -ffixed-g4 -ffixed-g5 -fcall-used-g7 -Wno-sign-compare
 else
-  CFLAGS := $(CFLAGS) -m64 -pipe -mno-fpu -mcpu=ultrasparc -mcmodel=medlow \
+  KBUILD_CFLAGS += -m64 -pipe -mno-fpu -mcpu=ultrasparc -mcmodel=medlow \
 	    -ffixed-g4 -ffixed-g5 -fcall-used-g7 -Wno-sign-compare \
 	    $(CC_UNDECL)
   AFLAGS += -m64 -mcpu=ultrasparc $(CC_UNDECL)
 endif
 
 ifeq ($(CONFIG_MCOUNT),y)
-  CFLAGS := $(CFLAGS) -pg
+  KBUILD_CFLAGS += -pg
 endif
 
 head-y := arch/sparc64/kernel/head.o arch/sparc64/kernel/init_task.o
diff --git a/arch/um/Makefile b/arch/um/Makefile
index 989224f..18123bf 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -58,14 +58,14 @@ SYS_DIR		:= $(ARCH_DIR)/include/sysdep-$(SUBARCH)
 #
 # These apply to USER_CFLAGS to.
 
-CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\"	\
+KBUILD_CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\"	\
 	$(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap	\
 	-Din6addr_loopback=kernel_in6addr_loopback
 
 AFLAGS += $(ARCH_INCLUDE)
 
 USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
-	$(patsubst -I%,,$(CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
+	$(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
 	-D_FILE_OFFSET_BITS=64
 
 include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH)
@@ -75,14 +75,14 @@ include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
 
 # -Derrno=kernel_errno - This turns all kernel references to errno into
 # kernel_errno to separate them from the libc errno.  This allows -fno-common
-# in CFLAGS.  Otherwise, it would cause ld to complain about the two different
+# in KBUILD_CFLAGS.  Otherwise, it would cause ld to complain about the two different
 # errnos.
 # These apply to kernelspace only.
 
 KERNEL_DEFINES = -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \
 	-Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES)
-CFLAGS += $(KERNEL_DEFINES)
-CFLAGS += $(call cc-option,-fno-unit-at-a-time,)
+KBUILD_CFLAGS += $(KERNEL_DEFINES)
+KBUILD_CFLAGS += $(call cc-option,-fno-unit-at-a-time,)
 
 # These are needed for clean and mrproper, since in that case .config is not
 # included; the values here are meaningless
diff --git a/arch/um/Makefile-i386 b/arch/um/Makefile-i386
index c9f1c5b..26bc786 100644
--- a/arch/um/Makefile-i386
+++ b/arch/um/Makefile-i386
@@ -15,7 +15,7 @@ OBJCOPYFLAGS  		:= -O binary -R .note -R .comment -S
 
 ifeq ("$(origin SUBARCH)", "command line")
 ifneq ("$(shell uname -m | sed -e s/i.86/i386/)", "$(SUBARCH)")
-CFLAGS			+= $(call cc-option,-m32)
+KBUILD_CFLAGS		+= $(call cc-option,-m32)
 AFLAGS			+= $(call cc-option,-m32)
 LINK-y			+= $(call cc-option,-m32)
 UML_OBJCOPYFLAGS	+= -F $(ELF_FORMAT)
@@ -36,4 +36,4 @@ cflags-y += $(call cc-option,-mpreferred-stack-boundary=2)
 # an unresolved reference.
 cflags-y += -ffreestanding
 
-CFLAGS += $(cflags-y)
+KBUILD_CFLAGS += $(cflags-y)
diff --git a/arch/um/Makefile-os-Linux b/arch/um/Makefile-os-Linux
index 0c0f9a1..5285948 100644
--- a/arch/um/Makefile-os-Linux
+++ b/arch/um/Makefile-os-Linux
@@ -5,4 +5,4 @@
 
 # To get a definition of F_SETSIG
 USER_CFLAGS += -D_GNU_SOURCE -D_LARGEFILE64_SOURCE
-CFLAGS += -D_LARGEFILE64_SOURCE
+KBUILD_CFLAGS += -D_LARGEFILE64_SOURCE
diff --git a/arch/um/Makefile-x86_64 b/arch/um/Makefile-x86_64
index 69ecea6..36d2bb5 100644
--- a/arch/um/Makefile-x86_64
+++ b/arch/um/Makefile-x86_64
@@ -9,7 +9,7 @@ _extra_flags_ = -fno-builtin -m64
 #We #undef __x86_64__ for kernelspace, not for userspace where
 #it's needed for headers to work!
 ARCH_KERNEL_DEFINES = -U__$(SUBARCH)__
-CFLAGS += $(_extra_flags_)
+KBUILD_CFLAGS += $(_extra_flags_)
 
 CHECKFLAGS  += -m64
 AFLAGS += -m64
diff --git a/arch/um/drivers/Makefile b/arch/um/drivers/Makefile
index de17d4c..0f780dd 100644
--- a/arch/um/drivers/Makefile
+++ b/arch/um/drivers/Makefile
@@ -17,7 +17,7 @@ ubd-objs := ubd_kern.o ubd_user.o
 port-objs := port_kern.o port_user.o
 harddog-objs := harddog_kern.o harddog_user.o
 
-LDFLAGS_pcap.o := -r $(shell $(CC) $(CFLAGS) -print-file-name=libpcap.a)
+LDFLAGS_pcap.o := -r $(shell $(CC) $(KBUILD_CFLAGS) -print-file-name=libpcap.a)
 
 targets := pcap_kern.o pcap_user.o
 
diff --git a/arch/um/sys-i386/Makefile b/arch/um/sys-i386/Makefile
index d6b3ecd..8909b07 100644
--- a/arch/um/sys-i386/Makefile
+++ b/arch/um/sys-i386/Makefile
@@ -20,4 +20,4 @@ CFLAGS_stub_segv.o := $(CFLAGS_NO_HARDENING)
 
 include arch/um/scripts/Makefile.rules
 
-$(obj)/unmap.%: _c_flags = $(call unprofile,$(CFLAGS))
+$(obj)/unmap.%: _c_flags = $(call unprofile,$(KBUILD_CFLAGS))
diff --git a/arch/um/sys-x86_64/Makefile b/arch/um/sys-x86_64/Makefile
index 4d9e5ef..e446a99 100644
--- a/arch/um/sys-x86_64/Makefile
+++ b/arch/um/sys-x86_64/Makefile
@@ -28,4 +28,4 @@ CFLAGS_stub_segv.o := $(CFLAGS_NO_HARDENING)
 
 include arch/um/scripts/Makefile.rules
 
-$(obj)/unmap.%: _c_flags = $(call unprofile,$(CFLAGS))
+$(obj)/unmap.%: _c_flags = $(call unprofile,$(KBUILD_CFLAGS))
diff --git a/arch/v850/Makefile b/arch/v850/Makefile
index 8be9aac..8b629df 100644
--- a/arch/v850/Makefile
+++ b/arch/v850/Makefile
@@ -16,11 +16,11 @@
 
 arch_dir = arch/v850
 
-CFLAGS += -mv850e
+KBUILD_CFLAGS += -mv850e
 # r16 is a fixed pointer to the current task
-CFLAGS += -ffixed-r16 -mno-prolog-function
-CFLAGS += -fno-builtin
-CFLAGS += -D__linux__ -DUTS_SYSNAME=\"uClinux\"
+KBUILD_CFLAGS += -ffixed-r16 -mno-prolog-function
+KBUILD_CFLAGS += -fno-builtin
+KBUILD_CFLAGS += -D__linux__ -DUTS_SYSNAME=\"uClinux\"
 
 # By default, build a kernel that runs on the gdb v850 simulator.
 KBUILD_DEFCONFIG := sim_defconfig
diff --git a/arch/x86_64/Makefile b/arch/x86_64/Makefile
index b024e4a..876a85a 100644
--- a/arch/x86_64/Makefile
+++ b/arch/x86_64/Makefile
@@ -67,7 +67,7 @@ AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc,-DCONF
 cflags-$(CONFIG_CC_STACKPROTECTOR) += $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-x86_64-has-stack-protector.sh "$(CC)" -fstack-protector )
 cflags-$(CONFIG_CC_STACKPROTECTOR_ALL) += $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-x86_64-has-stack-protector.sh "$(CC)" -fstack-protector-all )
 
-CFLAGS += $(cflags-y)
+KBUILD_CFLAGS += $(cflags-y)
 CFLAGS_KERNEL += $(cflags-kernel-y)
 AFLAGS += -m64
 
diff --git a/arch/x86_64/boot/compressed/Makefile b/arch/x86_64/boot/compressed/Makefile
index 877c0bd..d89eda7 100644
--- a/arch/x86_64/boot/compressed/Makefile
+++ b/arch/x86_64/boot/compressed/Makefile
@@ -6,11 +6,11 @@
 
 targets		:= vmlinux vmlinux.bin vmlinux.bin.gz head.o misc.o piggy.o
 
-CFLAGS := -m64 -D__KERNEL__ $(LINUXINCLUDE) -O2  \
+KBUILD_CFLAGS := -m64 -D__KERNEL__ $(LINUXINCLUDE) -O2  \
 	  -fno-strict-aliasing -fPIC -mcmodel=small \
 	   $(call cc-option, -ffreestanding) \
 	   $(call cc-option, -fno-stack-protector)
-AFLAGS  := $(CFLAGS) -D__ASSEMBLY__
+AFLAGS  := $(KBUILD_CFLAGS) -D__ASSEMBLY__
 LDFLAGS := -m elf_x86_64
 
 LDFLAGS_vmlinux := -T
diff --git a/arch/x86_64/vdso/Makefile b/arch/x86_64/vdso/Makefile
index 8d03de0..dcd6bb9 100644
--- a/arch/x86_64/vdso/Makefile
+++ b/arch/x86_64/vdso/Makefile
@@ -34,8 +34,8 @@ $(obj)/vdso.so: $(src)/vdso.lds $(vobjs) FORCE
 
 CFL := $(PROFILING) -mcmodel=small -fPIC -g0 -O2 -fasynchronous-unwind-tables -m64
 
-$(obj)/vclock_gettime.o: CFLAGS = $(CFL)
-$(obj)/vgetcpu.o: CFLAGS = $(CFL)
+$(obj)/vclock_gettime.o: KBUILD_CFLAGS = $(CFL)
+$(obj)/vgetcpu.o: KBUILD_CFLAGS = $(CFL)
 
 # We also create a special relocatable object that should mirror the symbol
 # table and layout of the linked DSO.  With ld -R we can then refer to
diff --git a/arch/xtensa/Makefile b/arch/xtensa/Makefile
index 95f836d..5acd105 100644
--- a/arch/xtensa/Makefile
+++ b/arch/xtensa/Makefile
@@ -27,7 +27,7 @@ platform-$(CONFIG_XTENSA_PLATFORM_ISS)		:= iss
 PLATFORM = $(platform-y)
 export PLATFORM
 
-CFLAGS		+= -pipe -mlongcalls
+KBUILD_CFLAGS	+= -pipe -mlongcalls
 
 KBUILD_DEFCONFIG := iss_defconfig
 
@@ -51,7 +51,7 @@ endif
 
 #
 
-LIBGCC := $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
+LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
 
 head-y		:= arch/xtensa/kernel/head.o
 core-y		+= arch/xtensa/kernel/ arch/xtensa/mm/
diff --git a/arch/xtensa/boot/Makefile b/arch/xtensa/boot/Makefile
index 820b31d..217c82d 100644
--- a/arch/xtensa/boot/Makefile
+++ b/arch/xtensa/boot/Makefile
@@ -8,12 +8,12 @@
 #
 
 
-CFLAGS 		+= -fno-builtin -Iarch/$(ARCH)/boot/include
+KBUYILD_CFLAGS		+= -fno-builtin -Iarch/$(ARCH)/boot/include
 HOSTFLAGS	+= -Iarch/$(ARCH)/boot/include
 
 BIG_ENDIAN	:= $(shell echo -e __XTENSA_EB__ | $(CC) -E - | grep -v "\#")
 
-export CFLAGS
+export KBUILD_CFLAGS
 export AFLAGS
 export BIG_ENDIAN
 
diff --git a/arch/xtensa/boot/boot-redboot/Makefile b/arch/xtensa/boot/boot-redboot/Makefile
index f53262c..74d15d0 100644
--- a/arch/xtensa/boot/boot-redboot/Makefile
+++ b/arch/xtensa/boot/boot-redboot/Makefile
@@ -19,7 +19,7 @@ boot-y	:= bootstrap.o
 OBJS	:= $(addprefix $(obj)/,$(boot-y))
 LIBS	:= arch/xtensa/boot/lib/lib.a arch/xtensa/lib/lib.a
 
-LIBGCC := $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
+LIBGCC := $(shell $(CC) $(KBUILD_CFLAGS) -print-libgcc-file-name)
 
 zImage: vmlinux $(OBJS) $(LIBS)
 	$(OBJCOPY) --strip-all -R .comment -R .xt.insn -O binary \
diff --git a/init/Makefile b/init/Makefile
index 0154aea..633392f 100644
--- a/init/Makefile
+++ b/init/Makefile
@@ -30,4 +30,4 @@ $(obj)/version.o: include/linux/compile.h
 include/linux/compile.h: FORCE
 	@echo '  CHK     $@'
 	$(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkcompile_h $@ \
-	"$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT)" "$(CC) $(CFLAGS)"
+	"$(UTS_MACHINE)" "$(CONFIG_SMP)" "$(CONFIG_PREEMPT)" "$(CC) $(KBUILD_CFLAGS)"
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 677bc6c..b1a7c7d 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -75,7 +75,7 @@ try-run = $(shell set -e;		\
 # Usage: cflags-y += $(call as-option,-Wa$(comma)-isa=foo,)
 
 as-option = $(call try-run,\
-	$(CC) $(CFLAGS) $(1) -c -xassembler /dev/null -o "$$TMP",$(1),$(2))
+	$(CC) $(KBUILD_CFLAGS) $(1) -c -xassembler /dev/null -o "$$TMP",$(1),$(2))
 
 # as-instr
 # Usage: cflags-y += $(call as-instr,instr,option1,option2)
@@ -87,12 +87,12 @@ as-instr = $(call try-run,\
 # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
 
 cc-option = $(call try-run,\
-	$(CC) $(CFLAGS) $(1) -S -xc /dev/null -o "$$TMP",$(1),$(2))
+	$(CC) $(KBUILD_CFLAGS) $(1) -S -xc /dev/null -o "$$TMP",$(1),$(2))
 
 # cc-option-yn
 # Usage: flag := $(call cc-option-yn,-march=winchip-c6)
 cc-option-yn = $(call try-run,\
-	$(CC) $(CFLAGS) $(1) -S -xc /dev/null -o "$$TMP",y,n)
+	$(CC) $(KBUILD_CFLAGS) $(1) -S -xc /dev/null -o "$$TMP",y,n)
 
 # cc-option-align
 # Prefix align with either -falign or -malign
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index fc498fe..37de2a9 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -86,7 +86,7 @@ basename_flags = -D"KBUILD_BASENAME=KBUILD_STR($(call name-fix,$(basetarget)))"
 modname_flags  = $(if $(filter 1,$(words $(modname))),\
                  -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
 
-_c_flags       = $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(basetarget).o)
+_c_flags       = $(KBUILD_CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(basetarget).o)
 _a_flags       = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o)
 _cpp_flags     = $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CPPFLAGS_$(@F))
 
-- 
1.5.1.rc3.2928.g8e573-dirty


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 2/4] kbuild: enable 'make AFLAGS=...' to add additional options to AS
  2007-09-09 18:02 kbuild: enable possibility to specify xFLAGS on commandline Sam Ravnborg
  2007-09-09 18:04 ` [PATCH 1/4] kbuild: enable 'make CFLAGS=...' to add additional options to CC Sam Ravnborg
@ 2007-09-09 18:05 ` Sam Ravnborg
  2007-09-09 18:06 ` [PATCH 3/4] ia64: fix sn to add include files using EXTRA_CFLAGS Sam Ravnborg
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 9+ messages in thread
From: Sam Ravnborg @ 2007-09-09 18:05 UTC (permalink / raw)
  To: linux arch, Andi Kleen, kbuild devel, Tony Luck

The variable AFLAGS is a wellknown variable and the usage by
kbuild may result in unexpected behaviour.
On top of that several people over time has asked for a way to
pass in additional flags to gcc.

This patch replace use of AFLAGS with KBUILD_AFLAGS all over the
tree and enabling one to use:
make AFLAGS=...
to specify additional gcc (as) commandline options.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
 Documentation/kbuild/makefiles.txt     |    5 +++--
 Makefile                               |    9 +++++----
 arch/arm/Makefile                      |    2 +-
 arch/arm/vfp/Makefile                  |    2 +-
 arch/avr32/Makefile                    |    4 ++--
 arch/blackfin/Makefile                 |    2 +-
 arch/cris/Makefile                     |    2 +-
 arch/frv/Makefile                      |   10 +++++-----
 arch/h8300/Makefile                    |    2 +-
 arch/h8300/lib/Makefile                |    2 +-
 arch/i386/Makefile                     |    6 +++---
 arch/i386/boot/Makefile                |    2 +-
 arch/m32r/Makefile                     |    2 +-
 arch/m68knommu/Makefile                |    2 +-
 arch/m68knommu/platform/5206/Makefile  |    2 +-
 arch/m68knommu/platform/5206e/Makefile |    2 +-
 arch/m68knommu/platform/520x/Makefile  |    2 +-
 arch/m68knommu/platform/523x/Makefile  |    2 +-
 arch/m68knommu/platform/5249/Makefile  |    2 +-
 arch/m68knommu/platform/5272/Makefile  |    2 +-
 arch/m68knommu/platform/527x/Makefile  |    2 +-
 arch/m68knommu/platform/528x/Makefile  |    2 +-
 arch/m68knommu/platform/5307/Makefile  |    2 +-
 arch/m68knommu/platform/532x/Makefile  |    2 +-
 arch/m68knommu/platform/5407/Makefile  |    2 +-
 arch/mips/Makefile                     |    2 +-
 arch/powerpc/Makefile                  |    4 ++--
 arch/ppc/Makefile                      |    4 ++--
 arch/s390/Makefile                     |    6 +++---
 arch/sh/Makefile                       |    2 +-
 arch/sparc/Makefile                    |    2 +-
 arch/sparc64/Makefile                  |    2 +-
 arch/um/Makefile                       |    2 +-
 arch/um/Makefile-i386                  |    2 +-
 arch/um/Makefile-x86_64                |    2 +-
 arch/um/sys-ppc/Makefile               |    6 +++---
 arch/x86_64/Makefile                   |    6 +++---
 arch/x86_64/boot/compressed/Makefile   |    2 +-
 arch/xtensa/boot/Makefile              |    2 +-
 scripts/Kbuild.include                 |    2 +-
 scripts/Makefile.lib                   |    2 +-
 41 files changed, 62 insertions(+), 60 deletions(-)

diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 4df47e4..15b3c11 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -425,6 +425,7 @@ more details, with real examples.
 	as-instr checks if the assembler reports a specific instruction
 	and then outputs either option1 or option2
 	C escapes are supported in the test instruction
+	Note: as-instr-option uses KBUILD_AFLAGS for $(AS) options
 
     cc-option
 	cc-option is used to check if $(CC) supports a given option, and not
@@ -820,14 +821,14 @@ When kbuild executes, the following steps are followed (roughly):
 	In this example, the binary $(obj)/image is a binary version of
 	vmlinux. The usage of $(call if_changed,xxx) will be described later.
 
-    AFLAGS		$(AS) assembler flags
+    KBUILD_AFLAGS		$(AS) assembler flags
 
 	Default value - see top level Makefile
 	Append or modify as required per architecture.
 
 	Example:
 		#arch/sparc64/Makefile
-		AFLAGS += -m64 -mcpu=ultrasparc
+		KBUILD_AFLAGS += -m64 -mcpu=ultrasparc
 
     KBUILD_CFLAGS		$(CC) compiler flags
 
diff --git a/Makefile b/Makefile
index 2a83bf3..5b2dbdd 100644
--- a/Makefile
+++ b/Makefile
@@ -315,7 +315,7 @@ CPPFLAGS        := -D__KERNEL__ $(LINUXINCLUDE)
 KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
 		   -fno-strict-aliasing -fno-common \
 		   -Werror-implicit-function-declaration
-AFLAGS          := -D__ASSEMBLY__
+KBUILD_AFLAGS   := -D__ASSEMBLY__
 
 # Read KERNELRELEASE from include/config/kernel.release (if it exists)
 KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
@@ -328,7 +328,7 @@ export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
 
 export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
 export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE
-export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
+export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
 
 # When compiling out-of-tree modules, put MODVERDIR in the module
 # tree rather than in the kernel tree. The kernel tree might
@@ -514,7 +514,8 @@ 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 CFLAGS as the last assignment
+# Add user supplied AFLAGS and CFLAGS as the last assignments
+KBUILD_AFLAGS += $(AFLAGS)
 KBUILD_CFLAGS += $(CFLAGS)
 
 # Use --build-id when available.
@@ -1490,7 +1491,7 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN   $(wildcard $(rm-files))
       cmd_rmfiles = rm -f $(rm-files)
 
 
-a_flags = -Wp,-MD,$(depfile) $(AFLAGS) $(AFLAGS_KERNEL) \
+a_flags = -Wp,-MD,$(depfile) $(KBUILD_AFLAGS) $(AFLAGS_KERNEL) \
 	  $(NOSTDINC_FLAGS) $(CPPFLAGS) \
 	  $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o)
 
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index 6eff3c9..e7eab5b 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -86,7 +86,7 @@ endif
 
 # Need -Uarm for gcc < 3.x
 KBUILD_CFLAGS	+=$(CFLAGS_ABI) $(arch-y) $(tune-y) $(call cc-option,-mshort-load-bytes,$(call cc-option,-malignment-traps,)) -msoft-float -Uarm
-AFLAGS		+=$(CFLAGS_ABI) $(arch-y) $(tune-y) -msoft-float
+KBUILD_AFLAGS	+=$(CFLAGS_ABI) $(arch-y) $(tune-y) -msoft-float
 
 CHECKFLAGS	+= -D__arm__
 
diff --git a/arch/arm/vfp/Makefile b/arch/arm/vfp/Makefile
index 7e136e7..39f6d8e 100644
--- a/arch/arm/vfp/Makefile
+++ b/arch/arm/vfp/Makefile
@@ -7,7 +7,7 @@
 # EXTRA_CFLAGS := -DDEBUG
 # EXTRA_AFLAGS := -DDEBUG
 
-AFLAGS		:=$(AFLAGS:-msoft-float=-Wa,-mfpu=softvfp+vfp)
+KBUILD_AFLAGS	:=$(KBUILD_AFLAGS:-msoft-float=-Wa,-mfpu=softvfp+vfp)
 LDFLAGS		+=--no-warn-mismatch
 
 obj-y			+= vfp.o
diff --git a/arch/avr32/Makefile b/arch/avr32/Makefile
index 9883c8b..8791864 100644
--- a/arch/avr32/Makefile
+++ b/arch/avr32/Makefile
@@ -12,14 +12,14 @@ all: uImage vmlinux.elf
 KBUILD_DEFCONFIG	:= atstk1002_defconfig
 
 KBUILD_CFLAGS	+= -pipe -fno-builtin -mno-pic
-AFLAGS		+= -mrelax -mno-pic
+KBUILD_AFLAGS	+= -mrelax -mno-pic
 CFLAGS_MODULE	+= -mno-relax
 LDFLAGS_vmlinux	+= --relax
 
 cpuflags-$(CONFIG_CPU_AT32AP7000)	+= -mcpu=ap7000
 
 KBUILD_CFLAGS	+= $(cpuflags-y)
-AFLAGS		+= $(cpuflags-y)
+KBUILD_AFLAGS	+= $(cpuflags-y)
 
 CHECKFLAGS	+= -D__avr32__ -D__BIG_ENDIAN
 
diff --git a/arch/blackfin/Makefile b/arch/blackfin/Makefile
index 52a6ac0..3689337 100644
--- a/arch/blackfin/Makefile
+++ b/arch/blackfin/Makefile
@@ -54,7 +54,7 @@ rev-$(CONFIG_BF_REV_NONE) := none
 rev-$(CONFIG_BF_REV_ANY)  := any
 
 KBUILD_CFLAGS += -mcpu=$(cpu-y)-$(rev-y)
-AFLAGS += -mcpu=$(cpu-y)-$(rev-y)
+KBUILD_AFLAGS += -mcpu=$(cpu-y)-$(rev-y)
 
 head-y   := arch/$(ARCH)/mach-$(MACHINE)/head.o arch/$(ARCH)/kernel/init_task.o
 
diff --git a/arch/cris/Makefile b/arch/cris/Makefile
index 32ef6f3..e6bf00c 100644
--- a/arch/cris/Makefile
+++ b/arch/cris/Makefile
@@ -29,7 +29,7 @@ LD = $(CROSS_COMPILE)ld -mcrislinux
 OBJCOPYFLAGS := -O binary -R .note -R .comment -S
 
 CPPFLAGS_vmlinux.lds = -DDRAM_VIRTUAL_BASE=0x$(CONFIG_ETRAX_DRAM_VIRTUAL_BASE)
-AFLAGS += -mlinux
+KBUILD_AFLAGS += -mlinux
 
 KBUILD_CFLAGS += -mlinux -march=$(arch-y) -pipe
 
diff --git a/arch/frv/Makefile b/arch/frv/Makefile
index ec89886..310c47a 100644
--- a/arch/frv/Makefile
+++ b/arch/frv/Makefile
@@ -63,16 +63,16 @@ endif
 
 ifdef CONFIG_CPU_FR451_COMPILE
 KBUILD_CFLAGS	+= -mcpu=fr450
-AFLAGS		+= -mcpu=fr450
+KBUILD_AFLAGS	+= -mcpu=fr450
 ASFLAGS		+= -mcpu=fr450
 else
 ifdef CONFIG_CPU_FR551_COMPILE
 KBUILD_CFLAGS	+= -mcpu=fr550
-AFLAGS		+= -mcpu=fr550
+KBUILD_AFLAGS	+= -mcpu=fr550
 ASFLAGS		+= -mcpu=fr550
 else
 KBUILD_CFLAGS	+= -mcpu=fr400
-AFLAGS		+= -mcpu=fr400
+KBUILD_AFLAGS	+= -mcpu=fr400
 ASFLAGS		+= -mcpu=fr400
 endif
 endif
@@ -82,14 +82,14 @@ endif
 # - all the extra registers are dealt with only at context switch time
 KBUILD_CFLAGS	+= -mno-fdpic -mgpr-32 -msoft-float -mno-media
 KBUILD_CFLAGS	+= -ffixed-fcc3 -ffixed-cc3 -ffixed-gr15 -ffixed-icc2
-AFLAGS		+= -mno-fdpic
+KBUILD_AFLAGS	+= -mno-fdpic
 ASFLAGS		+= -mno-fdpic
 
 # make sure the .S files get compiled with debug info
 # and disable optimisations that are unhelpful whilst debugging
 ifdef CONFIG_DEBUG_INFO
 #KBUILD_CFLAGS	+= -O1
-AFLAGS		+= -Wa,--gdwarf2
+KBUILD_AFLAGS	+= -Wa,--gdwarf2
 ASFLAGS		+= -Wa,--gdwarf2
 endif
 
diff --git a/arch/h8300/Makefile b/arch/h8300/Makefile
index 330e05f..a556447 100644
--- a/arch/h8300/Makefile
+++ b/arch/h8300/Makefile
@@ -35,7 +35,7 @@ KBUILD_CFLAGS += -mint32 -fno-builtin
 KBUILD_CFLAGS += -g
 KBUILD_CFLAGS += -D__linux__
 KBUILD_CFLAGS += -DUTS_SYSNAME=\"uClinux\"
-AFLAGS += -DPLATFORM=$(PLATFORM) -DMODEL=$(MODEL) $(cflags-y)
+KBUILD_AFLAGS += -DPLATFORM=$(PLATFORM) -DMODEL=$(MODEL) $(cflags-y)
 LDFLAGS += $(ldflags-y)
 
 CROSS_COMPILE = h8300-elf-
diff --git a/arch/h8300/lib/Makefile b/arch/h8300/lib/Makefile
index 98272b6..9d5e1f8 100644
--- a/arch/h8300/lib/Makefile
+++ b/arch/h8300/lib/Makefile
@@ -3,6 +3,6 @@
 #
 
 .S.o:
-	$(CC) $(AFLAGS) -D__ASSEMBLY__ -c $< -o $@
+	$(CC) $(KBUILD_AFLAGS) -D__ASSEMBLY__ -c $< -o $@
 
 lib-y  = ashrdi3.o checksum.o memcpy.o memset.o abs.o romfs.o
diff --git a/arch/i386/Makefile b/arch/i386/Makefile
index 252fcc2..5761eb8 100644
--- a/arch/i386/Makefile
+++ b/arch/i386/Makefile
@@ -52,11 +52,11 @@ KBUILD_CFLAGS += $(shell if [ $(call cc-version) -lt 0400 ] ; then echo $(call c
 
 # do binutils support CFI?
 cflags-y += $(call as-instr,.cfi_startproc\n.cfi_rel_offset esp${comma}0\n.cfi_endproc,-DCONFIG_AS_CFI=1,)
-AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_rel_offset esp${comma}0\n.cfi_endproc,-DCONFIG_AS_CFI=1,)
+KBUILD_AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_rel_offset esp${comma}0\n.cfi_endproc,-DCONFIG_AS_CFI=1,)
 
 # is .cfi_signal_frame supported too?
 cflags-y += $(call as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc,-DCONFIG_AS_CFI_SIGNAL_FRAME=1,)
-AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc,-DCONFIG_AS_CFI_SIGNAL_FRAME=1,)
+KBUILD_AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc,-DCONFIG_AS_CFI_SIGNAL_FRAME=1,)
 
 KBUILD_CFLAGS += $(cflags-y)
 
@@ -114,7 +114,7 @@ drivers-$(CONFIG_PM)			+= arch/i386/power/
 drivers-$(CONFIG_FB)                    += arch/i386/video/
 
 KBUILD_CFLAGS += $(mflags-y)
-AFLAGS += $(mflags-y)
+KBUILD_AFLAGS += $(mflags-y)
 
 boot := arch/i386/boot
 
diff --git a/arch/i386/boot/Makefile b/arch/i386/boot/Makefile
index 4e896dd..af97ab0 100644
--- a/arch/i386/boot/Makefile
+++ b/arch/i386/boot/Makefile
@@ -61,7 +61,7 @@ KBUILD_CFLAGS	:= $(LINUXINCLUDE) -g -Os -D_SETUP -D__KERNEL__ \
 			$(call cc-option, -fno-unit-at-a-time)) \
 		   $(call cc-option, -fno-stack-protector) \
 		   $(call cc-option, -mpreferred-stack-boundary=2)
-AFLAGS		:= $(KBUILD_CFLAGS) -D__ASSEMBLY__
+KBUILD_AFLAGS	:= $(KBUILD_CFLAGS) -D__ASSEMBLY__
 
 $(obj)/zImage:  IMAGE_OFFSET := 0x1000
 $(obj)/zImage:  EXTRA_AFLAGS := $(SVGA_MODE) $(RAMDISK)
diff --git a/arch/m32r/Makefile b/arch/m32r/Makefile
index 6380ab6..48d3759 100644
--- a/arch/m32r/Makefile
+++ b/arch/m32r/Makefile
@@ -25,7 +25,7 @@ cflags-$(CONFIG_ISA_M32R)	+= -DNO_FPU
 aflags-$(CONFIG_ISA_M32R)	+= -DNO_FPU -O2 -Wa,-no-bitinst
 
 KBUILD_CFLAGS += $(cflags-y)
-AFLAGS += $(aflags-y)
+KBUILD_AFLAGS += $(aflags-y)
 
 CHECKFLAGS	+= -D__m32r__ -D__BIG_ENDIAN__=1
 
diff --git a/arch/m68knommu/Makefile b/arch/m68knommu/Makefile
index 1c1fbb6..92227aa 100644
--- a/arch/m68knommu/Makefile
+++ b/arch/m68knommu/Makefile
@@ -102,7 +102,7 @@ cflags-$(CONFIG_M68EZ328)	:= -m68000
 cflags-$(CONFIG_M68VZ328)	:= -m68000
 cflags-$(CONFIG_M68360)		:= -m68332
 
-AFLAGS += $(cflags-y)
+KBUILD_AFLAGS += $(cflags-y)
 
 KBUILD_CFLAGS += $(cflags-y)
 KBUILD_CFLAGS += -D__linux__
diff --git a/arch/m68knommu/platform/5206/Makefile b/arch/m68knommu/platform/5206/Makefile
index 701b7ab..494def8 100644
--- a/arch/m68knommu/platform/5206/Makefile
+++ b/arch/m68knommu/platform/5206/Makefile
@@ -13,7 +13,7 @@
 #
 
 ifdef CONFIG_FULLDEBUG
-AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
+KBUILD_AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
 endif
 
 obj-y := config.o
diff --git a/arch/m68knommu/platform/5206e/Makefile b/arch/m68knommu/platform/5206e/Makefile
index 701b7ab..494def8 100644
--- a/arch/m68knommu/platform/5206e/Makefile
+++ b/arch/m68knommu/platform/5206e/Makefile
@@ -13,7 +13,7 @@
 #
 
 ifdef CONFIG_FULLDEBUG
-AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
+KBUILD_AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
 endif
 
 obj-y := config.o
diff --git a/arch/m68knommu/platform/520x/Makefile b/arch/m68knommu/platform/520x/Makefile
index e861b05..5e74830 100644
--- a/arch/m68knommu/platform/520x/Makefile
+++ b/arch/m68knommu/platform/520x/Makefile
@@ -13,7 +13,7 @@
 #
 
 ifdef CONFIG_FULLDEBUG
-AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
+KBUILD_AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
 endif
 
 obj-y := config.o
diff --git a/arch/m68knommu/platform/523x/Makefile b/arch/m68knommu/platform/523x/Makefile
index c1578b0..fd2c46d 100644
--- a/arch/m68knommu/platform/523x/Makefile
+++ b/arch/m68knommu/platform/523x/Makefile
@@ -13,7 +13,7 @@
 #
 
 ifdef CONFIG_FULLDEBUG
-AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
+KBUILD_AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
 endif
 
 obj-y := config.o
diff --git a/arch/m68knommu/platform/5249/Makefile b/arch/m68knommu/platform/5249/Makefile
index 701b7ab..494def8 100644
--- a/arch/m68knommu/platform/5249/Makefile
+++ b/arch/m68knommu/platform/5249/Makefile
@@ -13,7 +13,7 @@
 #
 
 ifdef CONFIG_FULLDEBUG
-AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
+KBUILD_AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
 endif
 
 obj-y := config.o
diff --git a/arch/m68knommu/platform/5272/Makefile b/arch/m68knommu/platform/5272/Makefile
index 0871a29..c486b16 100644
--- a/arch/m68knommu/platform/5272/Makefile
+++ b/arch/m68knommu/platform/5272/Makefile
@@ -13,7 +13,7 @@
 #
 
 ifdef CONFIG_FULLDEBUG
-AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
+KBUILD_AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
 endif
 
 obj-y := config.o
diff --git a/arch/m68knommu/platform/527x/Makefile b/arch/m68knommu/platform/527x/Makefile
index 0871a29..c486b16 100644
--- a/arch/m68knommu/platform/527x/Makefile
+++ b/arch/m68knommu/platform/527x/Makefile
@@ -13,7 +13,7 @@
 #
 
 ifdef CONFIG_FULLDEBUG
-AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
+KBUILD_AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
 endif
 
 obj-y := config.o
diff --git a/arch/m68knommu/platform/528x/Makefile b/arch/m68knommu/platform/528x/Makefile
index 0871a29..c486b16 100644
--- a/arch/m68knommu/platform/528x/Makefile
+++ b/arch/m68knommu/platform/528x/Makefile
@@ -13,7 +13,7 @@
 #
 
 ifdef CONFIG_FULLDEBUG
-AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
+KBUILD_AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
 endif
 
 obj-y := config.o
diff --git a/arch/m68knommu/platform/5307/Makefile b/arch/m68knommu/platform/5307/Makefile
index 719a313..0dba9f7 100644
--- a/arch/m68knommu/platform/5307/Makefile
+++ b/arch/m68knommu/platform/5307/Makefile
@@ -13,7 +13,7 @@
 #
 
 ifdef CONFIG_FULLDEBUG
-AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
+KBUILD_AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
 endif
 
 obj-$(CONFIG_COLDFIRE)	+= entry.o vectors.o
diff --git a/arch/m68knommu/platform/532x/Makefile b/arch/m68knommu/platform/532x/Makefile
index 1230180..5d8575c 100644
--- a/arch/m68knommu/platform/532x/Makefile
+++ b/arch/m68knommu/platform/532x/Makefile
@@ -13,7 +13,7 @@
 #
 
 ifdef CONFIG_FULLDEBUG
-AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
+KBUILD_AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
 endif
 
 #obj-y := config.o usb-mcf532x.o spi-mcf532x.o
diff --git a/arch/m68knommu/platform/5407/Makefile b/arch/m68knommu/platform/5407/Makefile
index 91b2f49..cb7ecd3 100644
--- a/arch/m68knommu/platform/5407/Makefile
+++ b/arch/m68knommu/platform/5407/Makefile
@@ -13,7 +13,7 @@
 #
 
 ifdef CONFIG_FULLDEBUG
-AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
+KBUILD_AFLAGS += -DDEBUGGER_COMPATIBLE_CACHE=1
 endif
 
 obj-y := config.o
diff --git a/arch/mips/Makefile b/arch/mips/Makefile
index 6fc73c4..38ee1ad 100644
--- a/arch/mips/Makefile
+++ b/arch/mips/Makefile
@@ -578,7 +578,7 @@ else
 JIFFIES			= jiffies_64
 endif
 
-AFLAGS		+= $(cflags-y)
+KBUILD_AFLAGS	+= $(cflags-y)
 KBUILD_CFLAGS	+= $(cflags-y) \
 			-D"VMLINUX_LOAD_ADDRESS=$(load-y)"
 
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 6515965..02fbeb1 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -69,7 +69,7 @@ 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)
-AFLAGS		+= $(AFLAGS-y)
+KBUILD_AFLAGS	+= $(AFLAGS-y)
 KBUILD_CFLAGS	+= -msoft-float -pipe $(CFLAGS-y)
 CPP		= $(CC) -E $(KBUILD_CFLAGS)
 # Temporary hack until we have migrated to asm-powerpc
@@ -117,7 +117,7 @@ cpu-as-$(CONFIG_POWER4)		+= -Wa,-maltivec
 cpu-as-$(CONFIG_E500)		+= -Wa,-me500
 cpu-as-$(CONFIG_E200)		+= -Wa,-me200
 
-AFLAGS += $(cpu-as-y)
+KBUILD_AFLAGS += $(cpu-as-y)
 KBUILD_CFLAGS += $(cpu-as-y)
 
 head-y				:= arch/powerpc/kernel/head_32.o
diff --git a/arch/ppc/Makefile b/arch/ppc/Makefile
index f4f22f7..bfe9993 100644
--- a/arch/ppc/Makefile
+++ b/arch/ppc/Makefile
@@ -23,7 +23,7 @@ endif
 LDFLAGS_vmlinux	:= -Ttext $(KERNELLOAD) -Bstatic
 # The -Iarch/$(ARCH)/include is temporary while we are merging
 CPPFLAGS	+= -Iarch/$(ARCH) -Iarch/$(ARCH)/include
-AFLAGS		+= -Iarch/$(ARCH)
+KBUILD_AFLAGS	+= -Iarch/$(ARCH)
 KBUILD_CFLAGS	+= -Iarch/$(ARCH) -msoft-float -pipe \
 		-ffixed-r2 -mmultiple
 
@@ -45,7 +45,7 @@ cpu-as-$(CONFIG_6xx)		+= -Wa,-maltivec
 cpu-as-$(CONFIG_E500)		+= -Wa,-me500
 cpu-as-$(CONFIG_E200)		+= -Wa,-me200
 
-AFLAGS += $(cpu-as-y)
+KBUILD_AFLAGS += $(cpu-as-y)
 KBUILD_CFLAGS += $(cpu-as-y)
 
 # Default to the common case.
diff --git a/arch/s390/Makefile b/arch/s390/Makefile
index 62a0da4..f708be3 100644
--- a/arch/s390/Makefile
+++ b/arch/s390/Makefile
@@ -16,7 +16,7 @@
 ifndef CONFIG_64BIT
 LDFLAGS		:= -m elf_s390
 KBUILD_CFLAGS	+= -m31
-AFLAGS		+= -m31
+KBUILD_AFLAGS	+= -m31
 UTS_MACHINE	:= s390
 STACK_SIZE	:= 8192
 CHECKFLAGS	+= -D__s390__ -msize-long
@@ -24,7 +24,7 @@ else
 LDFLAGS		:= -m elf64_s390
 MODFLAGS	+= -fpic -D__PIC__
 KBUILD_CFLAGS	+= -m64
-AFLAGS		+= -m64
+KBUILD_AFLAGS	+= -m64
 UTS_MACHINE	:= s390x
 STACK_SIZE	:= 16384
 CHECKFLAGS	+= -D__s390__ -D__s390x__
@@ -79,7 +79,7 @@ endif
 
 KBUILD_CFLAGS	+= -mbackchain -msoft-float $(cflags-y)
 KBUILD_CFLAGS	+= -pipe -fno-strength-reduce -Wno-sign-compare
-AFLAGS		+= $(aflags-y)
+KBUILD_AFLAGS	+= $(aflags-y)
 
 OBJCOPYFLAGS	:= -O binary
 LDFLAGS_vmlinux := -e start
diff --git a/arch/sh/Makefile b/arch/sh/Makefile
index cd8a411..0353296 100644
--- a/arch/sh/Makefile
+++ b/arch/sh/Makefile
@@ -92,7 +92,7 @@ LDFLAGS			+= -EB
 endif
 
 KBUILD_CFLAGS		+= -pipe $(cflags-y)
-AFLAGS		+= $(cflags-y)
+KBUILD_AFLAGS		+= $(cflags-y)
 
 head-y := arch/sh/kernel/head.o arch/sh/kernel/init_task.o
 
diff --git a/arch/sparc/Makefile b/arch/sparc/Makefile
index 2ce781a..fef28e2 100644
--- a/arch/sparc/Makefile
+++ b/arch/sparc/Makefile
@@ -17,7 +17,7 @@ CHECKFLAGS	+= -D__sparc__
 
 #KBUILD_CFLAGS += -g -pipe -fcall-used-g5 -fcall-used-g7
 KBUILD_CFLAGS += -m32 -pipe -mno-fpu -fcall-used-g5 -fcall-used-g7
-AFLAGS := $(AFLAGS) -m32
+KBUILD_AFLAGS += -m32
 
 #LDFLAGS_vmlinux = -N -Ttext 0xf0004000
 #  Since 2.5.40, the first stage is left not btfix-ed.
diff --git a/arch/sparc64/Makefile b/arch/sparc64/Makefile
index b083dc4..6c92a42 100644
--- a/arch/sparc64/Makefile
+++ b/arch/sparc64/Makefile
@@ -45,7 +45,7 @@ else
   KBUILD_CFLAGS += -m64 -pipe -mno-fpu -mcpu=ultrasparc -mcmodel=medlow \
 	    -ffixed-g4 -ffixed-g5 -fcall-used-g7 -Wno-sign-compare \
 	    $(CC_UNDECL)
-  AFLAGS += -m64 -mcpu=ultrasparc $(CC_UNDECL)
+  KBUILD_AFLAGS += -m64 -mcpu=ultrasparc $(CC_UNDECL)
 endif
 
 ifeq ($(CONFIG_MCOUNT),y)
diff --git a/arch/um/Makefile b/arch/um/Makefile
index 18123bf..d08d3bc 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -62,7 +62,7 @@ KBUILD_CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\"	\
 	$(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap	\
 	-Din6addr_loopback=kernel_in6addr_loopback
 
-AFLAGS += $(ARCH_INCLUDE)
+KBUILD_AFLAGS += $(ARCH_INCLUDE)
 
 USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
 	$(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
diff --git a/arch/um/Makefile-i386 b/arch/um/Makefile-i386
index 26bc786..d10e4dc 100644
--- a/arch/um/Makefile-i386
+++ b/arch/um/Makefile-i386
@@ -16,7 +16,7 @@ OBJCOPYFLAGS  		:= -O binary -R .note -R .comment -S
 ifeq ("$(origin SUBARCH)", "command line")
 ifneq ("$(shell uname -m | sed -e s/i.86/i386/)", "$(SUBARCH)")
 KBUILD_CFLAGS		+= $(call cc-option,-m32)
-AFLAGS			+= $(call cc-option,-m32)
+KBUILD_AFLAGS		+= $(call cc-option,-m32)
 LINK-y			+= $(call cc-option,-m32)
 UML_OBJCOPYFLAGS	+= -F $(ELF_FORMAT)
 
diff --git a/arch/um/Makefile-x86_64 b/arch/um/Makefile-x86_64
index 36d2bb5..8836f0d 100644
--- a/arch/um/Makefile-x86_64
+++ b/arch/um/Makefile-x86_64
@@ -12,7 +12,7 @@ ARCH_KERNEL_DEFINES = -U__$(SUBARCH)__
 KBUILD_CFLAGS += $(_extra_flags_)
 
 CHECKFLAGS  += -m64
-AFLAGS += -m64
+KBUILD_AFLAGS += -m64
 LDFLAGS += -m elf_x86_64
 CPPFLAGS += -m64
 
diff --git a/arch/um/sys-ppc/Makefile b/arch/um/sys-ppc/Makefile
index af20026..a9814a7 100644
--- a/arch/um/sys-ppc/Makefile
+++ b/arch/um/sys-ppc/Makefile
@@ -1,7 +1,7 @@
 OBJ = built-in.o
 
 .S.o:
-	$(CC) $(AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c $< -o $*.o
+	$(CC) $(KBUILD_AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c $< -o $*.o
 
 OBJS = ptrace.o sigcontext.o semaphore.o checksum.o miscthings.o misc.o \
 	ptrace_user.o sysrq.o
@@ -57,13 +57,13 @@ ppc_defs.h: mk_defs.c ppc_defs.head \
 checksum.o: checksum.S
 	rm -f asm
 	ln -s $(TOPDIR)/include/asm-ppc asm
-	$(CC) $(EXTRA_AFLAGS) $(AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c $< -o $*.o
+	$(CC) $(EXTRA_AFLAGS) $(KBUILD_AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c $< -o $*.o
 	rm -f asm
 
 misc.o: misc.S ppc_defs.h
 	rm -f asm
 	ln -s $(TOPDIR)/include/asm-ppc asm
-	$(CC) $(EXTRA_AFLAGS) $(AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c $< -o $*.o
+	$(CC) $(EXTRA_AFLAGS) $(KBUILD_AFLAGS) -D__ASSEMBLY__ -D__UM_PPC__ -c $< -o $*.o
 	rm -f asm
 
 clean-files := $(OBJS) ppc_defs.h checksum.S semaphore.c mk_defs.c
diff --git a/arch/x86_64/Makefile b/arch/x86_64/Makefile
index 876a85a..01f76c2 100644
--- a/arch/x86_64/Makefile
+++ b/arch/x86_64/Makefile
@@ -58,18 +58,18 @@ cflags-y += -maccumulate-outgoing-args
 
 # do binutils support CFI?
 cflags-y += $(call as-instr,.cfi_startproc\n.cfi_rel_offset rsp${comma}0\n.cfi_endproc,-DCONFIG_AS_CFI=1,)
-AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_rel_offset rsp${comma}0\n.cfi_endproc,-DCONFIG_AS_CFI=1,)
+KBUILD_AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_rel_offset rsp${comma}0\n.cfi_endproc,-DCONFIG_AS_CFI=1,)
 
 # is .cfi_signal_frame supported too?
 cflags-y += $(call as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc,-DCONFIG_AS_CFI_SIGNAL_FRAME=1,)
-AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc,-DCONFIG_AS_CFI_SIGNAL_FRAME=1,)
+KBUILD_AFLAGS += $(call as-instr,.cfi_startproc\n.cfi_signal_frame\n.cfi_endproc,-DCONFIG_AS_CFI_SIGNAL_FRAME=1,)
 
 cflags-$(CONFIG_CC_STACKPROTECTOR) += $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-x86_64-has-stack-protector.sh "$(CC)" -fstack-protector )
 cflags-$(CONFIG_CC_STACKPROTECTOR_ALL) += $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-x86_64-has-stack-protector.sh "$(CC)" -fstack-protector-all )
 
 KBUILD_CFLAGS += $(cflags-y)
 CFLAGS_KERNEL += $(cflags-kernel-y)
-AFLAGS += -m64
+KBUILD_AFLAGS += -m64
 
 head-y := arch/x86_64/kernel/head.o arch/x86_64/kernel/head64.o arch/x86_64/kernel/init_task.o
 
diff --git a/arch/x86_64/boot/compressed/Makefile b/arch/x86_64/boot/compressed/Makefile
index d89eda7..d2fa8d0 100644
--- a/arch/x86_64/boot/compressed/Makefile
+++ b/arch/x86_64/boot/compressed/Makefile
@@ -10,7 +10,7 @@ KBUILD_CFLAGS := -m64 -D__KERNEL__ $(LINUXINCLUDE) -O2  \
 	  -fno-strict-aliasing -fPIC -mcmodel=small \
 	   $(call cc-option, -ffreestanding) \
 	   $(call cc-option, -fno-stack-protector)
-AFLAGS  := $(KBUILD_CFLAGS) -D__ASSEMBLY__
+KBUILD_AFLAGS  := $(KBUILD_CFLAGS) -D__ASSEMBLY__
 LDFLAGS := -m elf_x86_64
 
 LDFLAGS_vmlinux := -T
diff --git a/arch/xtensa/boot/Makefile b/arch/xtensa/boot/Makefile
index 217c82d..7dfb5b7 100644
--- a/arch/xtensa/boot/Makefile
+++ b/arch/xtensa/boot/Makefile
@@ -14,7 +14,7 @@ HOSTFLAGS	+= -Iarch/$(ARCH)/boot/include
 BIG_ENDIAN	:= $(shell echo -e __XTENSA_EB__ | $(CC) -E - | grep -v "\#")
 
 export KBUILD_CFLAGS
-export AFLAGS
+export KBUILD_AFLAGS
 export BIG_ENDIAN
 
 subdir-y	:= lib
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index b1a7c7d..de7bb28 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -81,7 +81,7 @@ as-option = $(call try-run,\
 # Usage: cflags-y += $(call as-instr,instr,option1,option2)
 
 as-instr = $(call try-run,\
-	echo -e "$(1)" | $(CC) $(AFLAGS) -c -xassembler -o "$$TMP" -,$(2),$(3))
+	echo -e "$(1)" | $(CC) $(KBUILD_AFLAGS) -c -xassembler -o "$$TMP" -,$(2),$(3))
 
 # cc-option
 # Usage: cflags-y += $(call cc-option,-march=winchip-c6,-march=i586)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 37de2a9..b13d14e 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -87,7 +87,7 @@ modname_flags  = $(if $(filter 1,$(words $(modname))),\
                  -D"KBUILD_MODNAME=KBUILD_STR($(call name-fix,$(modname)))")
 
 _c_flags       = $(KBUILD_CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$(basetarget).o)
-_a_flags       = $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o)
+_a_flags       = $(KBUILD_AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o)
 _cpp_flags     = $(CPPFLAGS) $(EXTRA_CPPFLAGS) $(CPPFLAGS_$(@F))
 
 # If building the kernel in a separate objtree expand all occurrences
-- 
1.5.1.rc3.2928.g8e573-dirty


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 3/4] ia64: fix sn to add include files using EXTRA_CFLAGS
  2007-09-09 18:02 kbuild: enable possibility to specify xFLAGS on commandline Sam Ravnborg
  2007-09-09 18:04 ` [PATCH 1/4] kbuild: enable 'make CFLAGS=...' to add additional options to CC Sam Ravnborg
  2007-09-09 18:05 ` [PATCH 2/4] kbuild: enable 'make AFLAGS=...' to add additional options to AS Sam Ravnborg
@ 2007-09-09 18:06 ` Sam Ravnborg
  2007-09-09 22:45   ` CPP includes ([PATCH 3/4] ia64: fix sn to add include files using EXTRA_CFLAGS) Oleg Verych
  2007-09-11 13:48   ` [PATCH 3/4] ia64: fix sn to add include files using EXTRA_CFLAGS Jes Sorensen
  2007-09-09 18:07 ` [PATCH 4/4] kbuild: enable 'make CPPFLAGS=...' to add additional options to CPP Sam Ravnborg
  2007-09-09 18:26 ` kbuild: enable possibility to specify xFLAGS on commandline Segher Boessenkool
  4 siblings, 2 replies; 9+ messages in thread
From: Sam Ravnborg @ 2007-09-09 18:06 UTC (permalink / raw)
  To: linux arch, Andi Kleen, kbuild devel, Tony Luck

Changing the global CPPFLAGS is not the recommended way
to add additional include dirs.
Changed to use EXTRA_CFLAGS.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
 arch/ia64/sn/kernel/Makefile     |    2 +-
 arch/ia64/sn/kernel/sn2/Makefile |    2 +-
 arch/ia64/sn/pci/Makefile        |    2 +-
 arch/ia64/sn/pci/pcibr/Makefile  |    2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/ia64/sn/kernel/Makefile b/arch/ia64/sn/kernel/Makefile
index 0a59371..688a3c2 100644
--- a/arch/ia64/sn/kernel/Makefile
+++ b/arch/ia64/sn/kernel/Makefile
@@ -7,7 +7,7 @@
 # Copyright (C) 1999,2001-2006 Silicon Graphics, Inc.  All Rights Reserved.
 #
 
-CPPFLAGS += -I$(srctree)/arch/ia64/sn/include
+EXTRA_CFLAGS += -Iarch/ia64/sn/include
 
 obj-y				+= setup.o bte.o bte_error.o irq.o mca.o idle.o \
 				   huberror.o io_acpi_init.o io_common.o \
diff --git a/arch/ia64/sn/kernel/sn2/Makefile b/arch/ia64/sn/kernel/sn2/Makefile
index 99e1776..08e6565 100644
--- a/arch/ia64/sn/kernel/sn2/Makefile
+++ b/arch/ia64/sn/kernel/sn2/Makefile
@@ -9,7 +9,7 @@
 # sn2 specific kernel files
 #
 
-CPPFLAGS += -I$(srctree)/arch/ia64/sn/include
+EXTRA_CFLAGS += -Iarch/ia64/sn/include
 
 obj-y += cache.o io.o ptc_deadlock.o sn2_smp.o sn_proc_fs.o \
 	 prominfo_proc.o timer.o timer_interrupt.o sn_hwperf.o
diff --git a/arch/ia64/sn/pci/Makefile b/arch/ia64/sn/pci/Makefile
index c694678..ad4ef34 100644
--- a/arch/ia64/sn/pci/Makefile
+++ b/arch/ia64/sn/pci/Makefile
@@ -7,6 +7,6 @@
 #
 # Makefile for the sn pci general routines.
 
-CPPFLAGS += -I$(srctree)/arch/ia64/sn/include
+EXTRA_CFLAGS += -Iarch/ia64/sn/include
 
 obj-y := pci_dma.o tioca_provider.o tioce_provider.o pcibr/
diff --git a/arch/ia64/sn/pci/pcibr/Makefile b/arch/ia64/sn/pci/pcibr/Makefile
index 3b403ea..01192d3 100644
--- a/arch/ia64/sn/pci/pcibr/Makefile
+++ b/arch/ia64/sn/pci/pcibr/Makefile
@@ -7,7 +7,7 @@
 #
 # Makefile for the sn2 io routines.
 
-CPPFLAGS += -I$(srctree)/arch/ia64/sn/include
+EXTRA_CFLAGS += -Iarch/ia64/sn/include
 
 obj-y				+=  pcibr_dma.o pcibr_reg.o \
 				    pcibr_ate.o pcibr_provider.o
-- 
1.5.1.rc3.2928.g8e573-dirty


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH 4/4] kbuild: enable 'make CPPFLAGS=...' to add additional options to CPP
  2007-09-09 18:02 kbuild: enable possibility to specify xFLAGS on commandline Sam Ravnborg
                   ` (2 preceding siblings ...)
  2007-09-09 18:06 ` [PATCH 3/4] ia64: fix sn to add include files using EXTRA_CFLAGS Sam Ravnborg
@ 2007-09-09 18:07 ` Sam Ravnborg
  2007-09-09 18:26 ` kbuild: enable possibility to specify xFLAGS on commandline Segher Boessenkool
  4 siblings, 0 replies; 9+ messages in thread
From: Sam Ravnborg @ 2007-09-09 18:07 UTC (permalink / raw)
  To: linux arch, Andi Kleen, kbuild devel, Tony Luck

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_AFLAGS all over the
tree and enabling one to use:
make CPPFLAGS=...
to specify additional CPP commandline options.

Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
---
 Documentation/kbuild/makefiles.txt |    2 +-
 Makefile                           |   13 +++++++------
 arch/arm/Makefile                  |    4 ++--
 arch/ia64/Makefile                 |    2 +-
 arch/powerpc/Makefile              |    2 +-
 arch/ppc/Makefile                  |    2 +-
 arch/um/Makefile-x86_64            |    2 +-
 drivers/atm/Makefile               |    2 +-
 scripts/Makefile.lib               |    6 +++---
 9 files changed, 18 insertions(+), 17 deletions(-)

diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 15b3c11..29d070f 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -1100,7 +1100,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
diff --git a/Makefile b/Makefile
index 5b2dbdd..771ecd8 100644
--- a/Makefile
+++ b/Makefile
@@ -310,7 +310,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 \
@@ -326,7 +326,7 @@ export ARCH 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
 
@@ -514,9 +514,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)%,%,\
@@ -1492,7 +1493,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      $@
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index e7eab5b..b315899 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -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
diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile
index 9708a29..34951aa 100644
--- a/arch/ia64/Makefile
+++ b/arch/ia64/Makefile
@@ -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	\
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 02fbeb1..8138ac2 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -68,7 +68,7 @@ CPPFLAGS-$(CONFIG_PPC32) := -Iarch/$(ARCH) -Iarch/$(ARCH)/include
 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)
diff --git a/arch/ppc/Makefile b/arch/ppc/Makefile
index bfe9993..3a743dc 100644
--- a/arch/ppc/Makefile
+++ b/arch/ppc/Makefile
@@ -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
diff --git a/arch/um/Makefile-x86_64 b/arch/um/Makefile-x86_64
index 8836f0d..bcfd6ea 100644
--- a/arch/um/Makefile-x86_64
+++ b/arch/um/Makefile-x86_64
@@ -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
diff --git a/drivers/atm/Makefile b/drivers/atm/Makefile
index 1b16f81..e4fa996 100644
--- a/drivers/atm/Makefile
+++ b/drivers/atm/Makefile
@@ -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
 
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index b13d14e..f57c829 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -88,7 +88,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 '/').
@@ -108,11 +108,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)
-- 
1.5.1.rc3.2928.g8e573-dirty


^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: kbuild: enable possibility to specify xFLAGS on commandline
  2007-09-09 18:02 kbuild: enable possibility to specify xFLAGS on commandline Sam Ravnborg
                   ` (3 preceding siblings ...)
  2007-09-09 18:07 ` [PATCH 4/4] kbuild: enable 'make CPPFLAGS=...' to add additional options to CPP Sam Ravnborg
@ 2007-09-09 18:26 ` Segher Boessenkool
  2007-09-10  1:17   ` Stephen Rothwell
  4 siblings, 1 reply; 9+ messages in thread
From: Segher Boessenkool @ 2007-09-09 18:26 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: Andi Kleen, linux arch, Tony Luck, kbuild devel

> powerpc I dave a toolchain but defconfig seems not to be present.

powerpc uses

	KBUILD_DEFCONFIG := $(shell uname -m)_defconfig

to automagically pick the defconfig you want, but that obviously
doesn't work for cross-builds.

pmac32_defconfig and pseries_defconfig are probably used the most,
you might want to test with one of those next time.


Segher


^ permalink raw reply	[flat|nested] 9+ messages in thread

* CPP includes ([PATCH 3/4] ia64: fix sn to add include files using EXTRA_CFLAGS)
  2007-09-09 18:06 ` [PATCH 3/4] ia64: fix sn to add include files using EXTRA_CFLAGS Sam Ravnborg
@ 2007-09-09 22:45   ` Oleg Verych
  2007-09-11 13:48   ` [PATCH 3/4] ia64: fix sn to add include files using EXTRA_CFLAGS Jes Sorensen
  1 sibling, 0 replies; 9+ messages in thread
From: Oleg Verych @ 2007-09-09 22:45 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: linux arch, Andi Kleen, kbuild devel, Tony Luck

On Sun, Sep 09, 2007 at 08:06:23PM +0200, Sam Ravnborg wrote:
> Changing the global CPPFLAGS is not the recommended way
> to add additional include dirs.
> Changed to use EXTRA_CFLAGS.

Maybe same magic can be applied to Rusty's "../../../" in i386
asm-offsets? Noone seems to use cpp's features much.

BTW, asm-values[0] are just don't needed any more?

[0] http://marc.info/?l=linux-kernel&s=asm-values
____

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: kbuild: enable possibility to specify xFLAGS on commandline
  2007-09-09 18:26 ` kbuild: enable possibility to specify xFLAGS on commandline Segher Boessenkool
@ 2007-09-10  1:17   ` Stephen Rothwell
  0 siblings, 0 replies; 9+ messages in thread
From: Stephen Rothwell @ 2007-09-10  1:17 UTC (permalink / raw)
  To: Segher Boessenkool
  Cc: Sam Ravnborg, Andi Kleen, linux arch, Tony Luck, kbuild devel

[-- Attachment #1: Type: text/plain, Size: 608 bytes --]

On Sun, 9 Sep 2007 20:26:16 +0200 Segher Boessenkool <segher@kernel.crashing.org> wrote:
>
> powerpc uses
> 
> 	KBUILD_DEFCONFIG := $(shell uname -m)_defconfig
> 
> to automagically pick the defconfig you want, but that obviously
> doesn't work for cross-builds.
> 
> pmac32_defconfig and pseries_defconfig are probably used the most,
> you might want to test with one of those next time.

As someone else said, ppc64_defconfig would be better as that builds all
the 64 bit platforms.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH 3/4] ia64: fix sn to add include files using EXTRA_CFLAGS
  2007-09-09 18:06 ` [PATCH 3/4] ia64: fix sn to add include files using EXTRA_CFLAGS Sam Ravnborg
  2007-09-09 22:45   ` CPP includes ([PATCH 3/4] ia64: fix sn to add include files using EXTRA_CFLAGS) Oleg Verych
@ 2007-09-11 13:48   ` Jes Sorensen
  1 sibling, 0 replies; 9+ messages in thread
From: Jes Sorensen @ 2007-09-11 13:48 UTC (permalink / raw)
  To: Sam Ravnborg; +Cc: linux arch, Andi Kleen, kbuild devel, Tony Luck

>>>>> "Sam" == Sam Ravnborg <sam@ravnborg.org> writes:

Sam> Changing the global CPPFLAGS is not the recommended way to add
Sam> additional include dirs.  Changed to use EXTRA_CFLAGS.

Sam> Signed-off-by: Sam Ravnborg <sam@ravnborg.org> ---

As SN maintainer I'll add an

Acked-by: Jes Sorensen <jes@sgi.com>

I haven't tested your patch, but I'll take your word for it being
correct - it seems the right thing to do.

Cheers,
Jes

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-09-11 13:48 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-09 18:02 kbuild: enable possibility to specify xFLAGS on commandline Sam Ravnborg
2007-09-09 18:04 ` [PATCH 1/4] kbuild: enable 'make CFLAGS=...' to add additional options to CC Sam Ravnborg
2007-09-09 18:05 ` [PATCH 2/4] kbuild: enable 'make AFLAGS=...' to add additional options to AS Sam Ravnborg
2007-09-09 18:06 ` [PATCH 3/4] ia64: fix sn to add include files using EXTRA_CFLAGS Sam Ravnborg
2007-09-09 22:45   ` CPP includes ([PATCH 3/4] ia64: fix sn to add include files using EXTRA_CFLAGS) Oleg Verych
2007-09-11 13:48   ` [PATCH 3/4] ia64: fix sn to add include files using EXTRA_CFLAGS Jes Sorensen
2007-09-09 18:07 ` [PATCH 4/4] kbuild: enable 'make CPPFLAGS=...' to add additional options to CPP Sam Ravnborg
2007-09-09 18:26 ` kbuild: enable possibility to specify xFLAGS on commandline Segher Boessenkool
2007-09-10  1:17   ` Stephen Rothwell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).