From a0f97e06a43cf524e616f09e6af3398e1e9c1c5b Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 14 Oct 2007 22:21:35 +0200 Subject: kbuild: enable 'make CFLAGS=...' to add additional options to CC 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 usecase is when trying to find gcc bugs but other use cases has been requested too. Patch was tested on following architectures: alpha, arm, i386, x86_64, mips, sparc, sparc64, ia64, m68k Test was simple to do a defconfig build, apply the patch and check that nothing got rebuild. Signed-off-by: Sam Ravnborg --- 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 +- 7 files changed, 12 insertions(+), 12 deletions(-) (limited to 'arch/um') diff --git a/arch/um/Makefile b/arch/um/Makefile index 989224f2134..18123bf7b64 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 c9f1c5b24c9..26bc786fc61 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 0c0f9a1cbba..52859487c95 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 69ecea63fda..36d2bb5e419 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 de17d4c6e02..0f780dd0d4c 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 d6b3ecd4b77..8909b07d9ee 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 4d9e5efa6fb..e446a9916fd 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)) -- cgit v1.2.3 From 222d394d30e74bb7a2a65029fcea68107b0d0eb6 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Mon, 15 Oct 2007 21:59:31 +0200 Subject: kbuild: enable 'make AFLAGS=...' to add additional options to AS 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. Patch was tested on following architectures: alpha, arm, i386, x86_64, mips, sparc, sparc64, ia64, m68k, s390 Signed-off-by: Sam Ravnborg --- arch/um/Makefile | 2 +- arch/um/Makefile-i386 | 2 +- arch/um/Makefile-x86_64 | 2 +- arch/um/sys-ppc/Makefile | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) (limited to 'arch/um') diff --git a/arch/um/Makefile b/arch/um/Makefile index 18123bf7b64..d08d3bc518e 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 26bc786fc61..d10e4dc0dae 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 36d2bb5e419..8836f0df36a 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 af200268fdd..a9814a7ae60 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 -- cgit v1.2.3 From 06c5040cdb13d27adad118f2fbfae905a1911b37 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Mon, 15 Oct 2007 22:17:25 +0200 Subject: kbuild: enable 'make CPPFLAGS=...' to add additional options to CPP 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 --- arch/um/Makefile-x86_64 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/um') diff --git a/arch/um/Makefile-x86_64 b/arch/um/Makefile-x86_64 index 8836f0df36a..bcfd6ea3003 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 -- cgit v1.2.3