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 /Documentation/kbuild/makefiles.txt | |
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 'Documentation/kbuild/makefiles.txt')
-rw-r--r-- | Documentation/kbuild/makefiles.txt | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index 54bbfd37f157..1ca535bcc8c7 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt | |||
@@ -294,7 +294,7 @@ more details, with real examples. | |||
294 | 294 | ||
295 | 295 | ||
296 | This variable is necessary because the top Makefile owns the | 296 | This variable is necessary because the top Makefile owns the |
297 | variable $(CFLAGS) and uses it for compilation flags for the | 297 | variable $(KBUILD_CFLAGS) and uses it for compilation flags for the |
298 | entire tree. | 298 | entire tree. |
299 | 299 | ||
300 | $(EXTRA_AFLAGS) is a similar string for per-directory options | 300 | $(EXTRA_AFLAGS) is a similar string for per-directory options |
@@ -437,6 +437,7 @@ more details, with real examples. | |||
437 | -march=pentium-mmx if supported by $(CC), otherwise -march=i586. | 437 | -march=pentium-mmx if supported by $(CC), otherwise -march=i586. |
438 | The second argument to cc-option is optional, and if omitted, | 438 | The second argument to cc-option is optional, and if omitted, |
439 | cflags-y will be assigned no value if first option is not supported. | 439 | cflags-y will be assigned no value if first option is not supported. |
440 | Note: cc-option uses KBUILD_CFLAGS for $(CC) options | ||
440 | 441 | ||
441 | cc-option-yn | 442 | cc-option-yn |
442 | cc-option-yn is used to check if gcc supports a given option | 443 | cc-option-yn is used to check if gcc supports a given option |
@@ -452,6 +453,7 @@ more details, with real examples. | |||
452 | option. When $(biarch) equals 'y', the expanded variables $(aflags-y) | 453 | option. When $(biarch) equals 'y', the expanded variables $(aflags-y) |
453 | and $(cflags-y) will be assigned the values -a32 and -m32, | 454 | and $(cflags-y) will be assigned the values -a32 and -m32, |
454 | respectively. | 455 | respectively. |
456 | Note: cc-option-yn uses KBUILD_CFLAGS for $(CC) options | ||
455 | 457 | ||
456 | cc-option-align | 458 | cc-option-align |
457 | gcc versions >= 3.0 changed the type of options used to specify | 459 | gcc versions >= 3.0 changed the type of options used to specify |
@@ -463,10 +465,11 @@ more details, with real examples. | |||
463 | cc-option-align = -falign | 465 | cc-option-align = -falign |
464 | 466 | ||
465 | Example: | 467 | Example: |
466 | CFLAGS += $(cc-option-align)-functions=4 | 468 | KBUILD_CFLAGS += $(cc-option-align)-functions=4 |
467 | 469 | ||
468 | In the above example, the option -falign-functions=4 is used for | 470 | In the above example, the option -falign-functions=4 is used for |
469 | gcc >= 3.00. For gcc < 3.00, -malign-functions=4 is used. | 471 | gcc >= 3.00. For gcc < 3.00, -malign-functions=4 is used. |
472 | Note: cc-option-align uses KBUILD_CFLAGS for $(CC) options | ||
470 | 473 | ||
471 | cc-version | 474 | cc-version |
472 | cc-version returns a numerical version of the $(CC) compiler version. | 475 | cc-version returns a numerical version of the $(CC) compiler version. |
@@ -825,17 +828,17 @@ When kbuild executes, the following steps are followed (roughly): | |||
825 | #arch/sparc64/Makefile | 828 | #arch/sparc64/Makefile |
826 | AFLAGS += -m64 -mcpu=ultrasparc | 829 | AFLAGS += -m64 -mcpu=ultrasparc |
827 | 830 | ||
828 | CFLAGS $(CC) compiler flags | 831 | KBUILD_CFLAGS $(CC) compiler flags |
829 | 832 | ||
830 | Default value - see top level Makefile | 833 | Default value - see top level Makefile |
831 | Append or modify as required per architecture. | 834 | Append or modify as required per architecture. |
832 | 835 | ||
833 | Often, the CFLAGS variable depends on the configuration. | 836 | Often, the KBUILD_CFLAGS variable depends on the configuration. |
834 | 837 | ||
835 | Example: | 838 | Example: |
836 | #arch/i386/Makefile | 839 | #arch/i386/Makefile |
837 | cflags-$(CONFIG_M386) += -march=i386 | 840 | cflags-$(CONFIG_M386) += -march=i386 |
838 | CFLAGS += $(cflags-y) | 841 | KBUILD_CFLAGS += $(cflags-y) |
839 | 842 | ||
840 | Many arch Makefiles dynamically run the target C compiler to | 843 | Many arch Makefiles dynamically run the target C compiler to |
841 | probe supported options: | 844 | probe supported options: |
@@ -847,7 +850,7 @@ When kbuild executes, the following steps are followed (roughly): | |||
847 | -march=pentium2,-march=i686) | 850 | -march=pentium2,-march=i686) |
848 | ... | 851 | ... |
849 | # Disable unit-at-a-time mode ... | 852 | # Disable unit-at-a-time mode ... |
850 | CFLAGS += $(call cc-option,-fno-unit-at-a-time) | 853 | KBUILD_CFLAGS += $(call cc-option,-fno-unit-at-a-time) |
851 | ... | 854 | ... |
852 | 855 | ||
853 | 856 | ||