diff options
| author | Sam Ravnborg <sam@neptun.(none)> | 2007-10-14 16:21:35 -0400 |
|---|---|---|
| committer | Sam Ravnborg <sam@neptun.(none)> | 2007-10-14 16:21:35 -0400 |
| commit | a0f97e06a43cf524e616f09e6af3398e1e9c1c5b (patch) | |
| tree | 2503b24bdbc144aea9ea5bde6ead94b3406eaf98 /Makefile | |
| parent | 9a39e273d4df0560c724c5fe71f6314a0583ca2b (diff) | |
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 <sam@ravnborg.org>
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 20 |
1 files changed, 10 insertions, 10 deletions
| @@ -320,7 +320,7 @@ LINUXINCLUDE := -Iinclude \ | |||
| 320 | 320 | ||
| 321 | CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE) | 321 | CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE) |
| 322 | 322 | ||
| 323 | CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ | 323 | KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ |
| 324 | -fno-strict-aliasing -fno-common \ | 324 | -fno-strict-aliasing -fno-common \ |
| 325 | -Werror-implicit-function-declaration | 325 | -Werror-implicit-function-declaration |
| 326 | AFLAGS := -D__ASSEMBLY__ | 326 | AFLAGS := -D__ASSEMBLY__ |
| @@ -335,7 +335,7 @@ export CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE | |||
| 335 | export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS | 335 | export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS |
| 336 | 336 | ||
| 337 | export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS | 337 | export CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS |
| 338 | export CFLAGS CFLAGS_KERNEL CFLAGS_MODULE | 338 | export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE |
| 339 | export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE | 339 | export AFLAGS AFLAGS_KERNEL AFLAGS_MODULE |
| 340 | 340 | ||
| 341 | # When compiling out-of-tree modules, put MODVERDIR in the module | 341 | # When compiling out-of-tree modules, put MODVERDIR in the module |
| @@ -492,36 +492,36 @@ endif # $(dot-config) | |||
| 492 | all: vmlinux | 492 | all: vmlinux |
| 493 | 493 | ||
| 494 | ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE | 494 | ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE |
| 495 | CFLAGS += -Os | 495 | KBUILD_CFLAGS += -Os |
| 496 | else | 496 | else |
| 497 | CFLAGS += -O2 | 497 | KBUILD_CFLAGS += -O2 |
| 498 | endif | 498 | endif |
| 499 | 499 | ||
| 500 | include $(srctree)/arch/$(ARCH)/Makefile | 500 | include $(srctree)/arch/$(ARCH)/Makefile |
| 501 | 501 | ||
| 502 | ifdef CONFIG_FRAME_POINTER | 502 | ifdef CONFIG_FRAME_POINTER |
| 503 | CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls | 503 | KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls |
| 504 | else | 504 | else |
| 505 | CFLAGS += -fomit-frame-pointer | 505 | KBUILD_CFLAGS += -fomit-frame-pointer |
| 506 | endif | 506 | endif |
| 507 | 507 | ||
| 508 | ifdef CONFIG_DEBUG_INFO | 508 | ifdef CONFIG_DEBUG_INFO |
| 509 | CFLAGS += -g | 509 | KBUILD_CFLAGS += -g |
| 510 | AFLAGS += -gdwarf-2 | 510 | AFLAGS += -gdwarf-2 |
| 511 | endif | 511 | endif |
| 512 | 512 | ||
| 513 | # Force gcc to behave correct even for buggy distributions | 513 | # Force gcc to behave correct even for buggy distributions |
| 514 | CFLAGS += $(call cc-option, -fno-stack-protector) | 514 | KBUILD_CFLAGS += $(call cc-option, -fno-stack-protector) |
| 515 | 515 | ||
| 516 | # arch Makefile may override CC so keep this after arch Makefile is included | 516 | # arch Makefile may override CC so keep this after arch Makefile is included |
| 517 | NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) | 517 | NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) |
| 518 | CHECKFLAGS += $(NOSTDINC_FLAGS) | 518 | CHECKFLAGS += $(NOSTDINC_FLAGS) |
| 519 | 519 | ||
| 520 | # warn about C99 declaration after statement | 520 | # warn about C99 declaration after statement |
| 521 | CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) | 521 | KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) |
| 522 | 522 | ||
| 523 | # disable pointer signed / unsigned warnings in gcc 4.0 | 523 | # disable pointer signed / unsigned warnings in gcc 4.0 |
| 524 | CFLAGS += $(call cc-option,-Wno-pointer-sign,) | 524 | KBUILD_CFLAGS += $(call cc-option,-Wno-pointer-sign,) |
| 525 | 525 | ||
| 526 | # Use --build-id when available. | 526 | # Use --build-id when available. |
| 527 | LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\ | 527 | LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\ |
