diff options
-rw-r--r-- | Documentation/kbuild/kbuild.txt | 16 | ||||
-rw-r--r-- | Documentation/kbuild/makefiles.txt | 18 | ||||
-rw-r--r-- | Makefile | 13 | ||||
-rw-r--r-- | arch/avr32/Makefile | 2 | ||||
-rw-r--r-- | arch/blackfin/Makefile | 4 | ||||
-rw-r--r-- | arch/ia64/Makefile | 2 | ||||
-rw-r--r-- | arch/m32r/Makefile | 2 | ||||
-rw-r--r-- | arch/m68k/Makefile | 2 | ||||
-rw-r--r-- | arch/mips/Makefile | 6 | ||||
-rw-r--r-- | arch/powerpc/Makefile | 2 | ||||
-rw-r--r-- | arch/s390/Makefile | 3 | ||||
-rw-r--r-- | arch/score/Makefile | 3 | ||||
-rw-r--r-- | scripts/Makefile.build | 9 | ||||
-rw-r--r-- | scripts/Makefile.modpost | 7 |
14 files changed, 62 insertions, 27 deletions
diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt index 634c625da8ce..d9c655433ec6 100644 --- a/Documentation/kbuild/kbuild.txt +++ b/Documentation/kbuild/kbuild.txt | |||
@@ -22,11 +22,23 @@ building C files and assembler files. | |||
22 | 22 | ||
23 | KAFLAGS | 23 | KAFLAGS |
24 | -------------------------------------------------- | 24 | -------------------------------------------------- |
25 | Additional options to the assembler. | 25 | Additional options to the assembler (for built-in and modules). |
26 | |||
27 | AFLAGS_MODULE | ||
28 | -------------------------------------------------- | ||
29 | Addtional module specific options to use for $(AS). | ||
26 | 30 | ||
27 | KCFLAGS | 31 | KCFLAGS |
28 | -------------------------------------------------- | 32 | -------------------------------------------------- |
29 | Additional options to the C compiler. | 33 | Additional options to the C compiler (for built-in and modules). |
34 | |||
35 | CFLAGS_MODULE | ||
36 | -------------------------------------------------- | ||
37 | Addtional module specific options to use for $(CC). | ||
38 | |||
39 | LDFLAGS_MODULE | ||
40 | -------------------------------------------------- | ||
41 | Additional options used for $(LD) when linking modules. | ||
30 | 42 | ||
31 | KBUILD_VERBOSE | 43 | KBUILD_VERBOSE |
32 | -------------------------------------------------- | 44 | -------------------------------------------------- |
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index 71c602d61680..802341abf702 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt | |||
@@ -928,11 +928,23 @@ When kbuild executes, the following steps are followed (roughly): | |||
928 | $(CFLAGS_KERNEL) contains extra C compiler flags used to compile | 928 | $(CFLAGS_KERNEL) contains extra C compiler flags used to compile |
929 | resident kernel code. | 929 | resident kernel code. |
930 | 930 | ||
931 | CFLAGS_MODULE $(CC) options specific for modules | 931 | KBUILD_AFLAGS_MODULE Options for $(AS) when building modules |
932 | 932 | ||
933 | $(CFLAGS_MODULE) contains extra C compiler flags used to compile code | 933 | $(KBUILD_AFLAGS_MODULE) is used to add arch specific options that |
934 | for loadable kernel modules. | 934 | are used for $(AS). |
935 | From commandline AFLAGS_MODULE shall be used (see kbuild.txt). | ||
935 | 936 | ||
937 | KBUILD_CFLAGS_MODULE Options for $(CC) when building modules | ||
938 | |||
939 | $(KBUILD_CFLAGS_MODULE) is used to add arch specific options that | ||
940 | are used for $(CC). | ||
941 | From commandline CFLAGS_MODULE shall be used (see kbuild.txt). | ||
942 | |||
943 | KBUILD_LDFLAGS_MODULE Options for $(LD) when linking modules | ||
944 | |||
945 | $(KBUILD_LDFLAGS_MODULE) is used to add arch specific options | ||
946 | used when linking modules. This is often a linker script. | ||
947 | From commandline LDFLAGS_MODULE shall be used (see kbuild.txt). | ||
936 | 948 | ||
937 | --- 6.2 Add prerequisites to archprepare: | 949 | --- 6.2 Add prerequisites to archprepare: |
938 | 950 | ||
@@ -332,10 +332,9 @@ CHECK = sparse | |||
332 | 332 | ||
333 | CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ | 333 | CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ |
334 | -Wbitwise -Wno-return-void $(CF) | 334 | -Wbitwise -Wno-return-void $(CF) |
335 | MODFLAGS = -DMODULE | 335 | CFLAGS_MODULE = |
336 | CFLAGS_MODULE = $(MODFLAGS) | 336 | AFLAGS_MODULE = |
337 | AFLAGS_MODULE = $(MODFLAGS) | 337 | LDFLAGS_MODULE = |
338 | LDFLAGS_MODULE = -T $(srctree)/scripts/module-common.lds | ||
339 | CFLAGS_KERNEL = | 338 | CFLAGS_KERNEL = |
340 | AFLAGS_KERNEL = | 339 | AFLAGS_KERNEL = |
341 | CFLAGS_GCOV = -fprofile-arcs -ftest-coverage | 340 | CFLAGS_GCOV = -fprofile-arcs -ftest-coverage |
@@ -355,6 +354,9 @@ KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \ | |||
355 | -Wno-format-security \ | 354 | -Wno-format-security \ |
356 | -fno-delete-null-pointer-checks | 355 | -fno-delete-null-pointer-checks |
357 | KBUILD_AFLAGS := -D__ASSEMBLY__ | 356 | KBUILD_AFLAGS := -D__ASSEMBLY__ |
357 | KBUILD_AFLAGS_MODULE := -DMODULE | ||
358 | KBUILD_CFLAGS_MODULE := -DMODULE | ||
359 | KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds | ||
358 | 360 | ||
359 | # Read KERNELRELEASE from include/config/kernel.release (if it exists) | 361 | # Read KERNELRELEASE from include/config/kernel.release (if it exists) |
360 | KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) | 362 | KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null) |
@@ -369,6 +371,7 @@ export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS | |||
369 | export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS | 371 | export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS |
370 | export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV | 372 | export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV |
371 | export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE | 373 | export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE |
374 | export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE | ||
372 | 375 | ||
373 | # When compiling out-of-tree modules, put MODVERDIR in the module | 376 | # When compiling out-of-tree modules, put MODVERDIR in the module |
374 | # tree rather than in the kernel tree. The kernel tree might | 377 | # tree rather than in the kernel tree. The kernel tree might |
@@ -607,7 +610,7 @@ endif | |||
607 | # Use --build-id when available. | 610 | # Use --build-id when available. |
608 | LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\ | 611 | LDFLAGS_BUILD_ID = $(patsubst -Wl$(comma)%,%,\ |
609 | $(call cc-ldoption, -Wl$(comma)--build-id,)) | 612 | $(call cc-ldoption, -Wl$(comma)--build-id,)) |
610 | LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID) | 613 | KBUILD_LDFLAGS_MODULE += $(LDFLAGS_BUILD_ID) |
611 | LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID) | 614 | LDFLAGS_vmlinux += $(LDFLAGS_BUILD_ID) |
612 | 615 | ||
613 | ifeq ($(CONFIG_STRIP_ASM_SYMS),y) | 616 | ifeq ($(CONFIG_STRIP_ASM_SYMS),y) |
diff --git a/arch/avr32/Makefile b/arch/avr32/Makefile index ead8a75203a9..22fb66590dcd 100644 --- a/arch/avr32/Makefile +++ b/arch/avr32/Makefile | |||
@@ -13,7 +13,7 @@ KBUILD_DEFCONFIG := atstk1002_defconfig | |||
13 | 13 | ||
14 | KBUILD_CFLAGS += -pipe -fno-builtin -mno-pic | 14 | KBUILD_CFLAGS += -pipe -fno-builtin -mno-pic |
15 | KBUILD_AFLAGS += -mrelax -mno-pic | 15 | KBUILD_AFLAGS += -mrelax -mno-pic |
16 | CFLAGS_MODULE += -mno-relax | 16 | KBUILD_CFLAGS_MODULE += -mno-relax |
17 | LDFLAGS_vmlinux += --relax | 17 | LDFLAGS_vmlinux += --relax |
18 | 18 | ||
19 | cpuflags-$(CONFIG_PLATFORM_AT32AP) += -march=ap | 19 | cpuflags-$(CONFIG_PLATFORM_AT32AP) += -march=ap |
diff --git a/arch/blackfin/Makefile b/arch/blackfin/Makefile index d4c7177e7656..f7ef923297fc 100644 --- a/arch/blackfin/Makefile +++ b/arch/blackfin/Makefile | |||
@@ -15,8 +15,8 @@ GZFLAGS := -9 | |||
15 | 15 | ||
16 | KBUILD_CFLAGS += $(call cc-option,-mno-fdpic) | 16 | KBUILD_CFLAGS += $(call cc-option,-mno-fdpic) |
17 | KBUILD_AFLAGS += $(call cc-option,-mno-fdpic) | 17 | KBUILD_AFLAGS += $(call cc-option,-mno-fdpic) |
18 | CFLAGS_MODULE += -mlong-calls | 18 | KBUILD_CFLAGS_MODULE += -mlong-calls |
19 | LDFLAGS_MODULE += -m elf32bfin | 19 | KBUILD_LDFLAGS_MODULE += -m elf32bfin |
20 | KALLSYMS += --symbol-prefix=_ | 20 | KALLSYMS += --symbol-prefix=_ |
21 | 21 | ||
22 | KBUILD_DEFCONFIG := BF537-STAMP_defconfig | 22 | KBUILD_DEFCONFIG := BF537-STAMP_defconfig |
diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile index 475e2725fbde..5ab6af3361a8 100644 --- a/arch/ia64/Makefile +++ b/arch/ia64/Makefile | |||
@@ -22,7 +22,7 @@ CHECKFLAGS += -m64 -D__ia64=1 -D__ia64__=1 -D_LP64 -D__LP64__ | |||
22 | 22 | ||
23 | OBJCOPYFLAGS := --strip-all | 23 | OBJCOPYFLAGS := --strip-all |
24 | LDFLAGS_vmlinux := -static | 24 | LDFLAGS_vmlinux := -static |
25 | LDFLAGS_MODULE += -T $(srctree)/arch/ia64/module.lds | 25 | KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/ia64/module.lds |
26 | AFLAGS_KERNEL := -mconstant-gp | 26 | AFLAGS_KERNEL := -mconstant-gp |
27 | EXTRA := | 27 | EXTRA := |
28 | 28 | ||
diff --git a/arch/m32r/Makefile b/arch/m32r/Makefile index 469766b24e22..14a3c2314fef 100644 --- a/arch/m32r/Makefile +++ b/arch/m32r/Makefile | |||
@@ -13,7 +13,7 @@ LDFLAGS_vmlinux := | |||
13 | 13 | ||
14 | KBUILD_CFLAGS += -pipe -fno-schedule-insns | 14 | KBUILD_CFLAGS += -pipe -fno-schedule-insns |
15 | CFLAGS_KERNEL += -mmodel=medium | 15 | CFLAGS_KERNEL += -mmodel=medium |
16 | CFLAGS_MODULE += -mmodel=large | 16 | KBUILD_CFLAGS_MODULE += -mmodel=large |
17 | 17 | ||
18 | ifdef CONFIG_CHIP_VDEC2 | 18 | ifdef CONFIG_CHIP_VDEC2 |
19 | cflags-$(CONFIG_ISA_M32R2) += -DNO_FPU -Wa,-bitinst | 19 | cflags-$(CONFIG_ISA_M32R2) += -DNO_FPU -Wa,-bitinst |
diff --git a/arch/m68k/Makefile b/arch/m68k/Makefile index 570d85c3f97f..b06a7e3cbcd6 100644 --- a/arch/m68k/Makefile +++ b/arch/m68k/Makefile | |||
@@ -18,7 +18,7 @@ KBUILD_DEFCONFIG := multi_defconfig | |||
18 | # override top level makefile | 18 | # override top level makefile |
19 | AS += -m68020 | 19 | AS += -m68020 |
20 | LDFLAGS := -m m68kelf | 20 | LDFLAGS := -m m68kelf |
21 | LDFLAGS_MODULE += -T $(srctree)/arch/m68k/kernel/module.lds | 21 | KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/m68k/kernel/module.lds |
22 | ifneq ($(SUBARCH),$(ARCH)) | 22 | ifneq ($(SUBARCH),$(ARCH)) |
23 | ifeq ($(CROSS_COMPILE),) | 23 | ifeq ($(CROSS_COMPILE),) |
24 | CROSS_COMPILE := $(call cc-cross-prefix, \ | 24 | CROSS_COMPILE := $(call cc-cross-prefix, \ |
diff --git a/arch/mips/Makefile b/arch/mips/Makefile index 1893efd43fca..a77dcf35c14e 100644 --- a/arch/mips/Makefile +++ b/arch/mips/Makefile | |||
@@ -93,7 +93,8 @@ all-$(CONFIG_SYS_SUPPORTS_ZBOOT)+= vmlinuz | |||
93 | cflags-y += -G 0 -mno-abicalls -fno-pic -pipe | 93 | cflags-y += -G 0 -mno-abicalls -fno-pic -pipe |
94 | cflags-y += -msoft-float | 94 | cflags-y += -msoft-float |
95 | LDFLAGS_vmlinux += -G 0 -static -n -nostdlib | 95 | LDFLAGS_vmlinux += -G 0 -static -n -nostdlib |
96 | MODFLAGS += -mlong-calls | 96 | KBUILD_AFLAGS_MODULE += -mlong-calls |
97 | KBUILD_CFLAGS_MODULE += -mlong-calls | ||
97 | 98 | ||
98 | cflags-y += -ffreestanding | 99 | cflags-y += -ffreestanding |
99 | 100 | ||
@@ -172,7 +173,8 @@ cflags-$(CONFIG_CPU_DADDI_WORKAROUNDS) += $(call cc-option,-mno-daddi,) | |||
172 | 173 | ||
173 | ifdef CONFIG_CPU_SB1 | 174 | ifdef CONFIG_CPU_SB1 |
174 | ifdef CONFIG_SB1_PASS_1_WORKAROUNDS | 175 | ifdef CONFIG_SB1_PASS_1_WORKAROUNDS |
175 | MODFLAGS += -msb1-pass1-workarounds | 176 | KBUILD_AFLAGS_MODULE += -msb1-pass1-workarounds |
177 | KBUILD_CFLAGS_MODULE += -msb1-pass1-workarounds | ||
176 | endif | 178 | endif |
177 | endif | 179 | endif |
178 | 180 | ||
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile index 42dcd3f4ad7b..b68a83853e1c 100644 --- a/arch/powerpc/Makefile +++ b/arch/powerpc/Makefile | |||
@@ -93,7 +93,7 @@ else | |||
93 | KBUILD_CFLAGS += $(call cc-option,-mtune=power4) | 93 | KBUILD_CFLAGS += $(call cc-option,-mtune=power4) |
94 | endif | 94 | endif |
95 | else | 95 | else |
96 | LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o | 96 | KBUILD_LDFLAGS_MODULE += arch/powerpc/lib/crtsavres.o |
97 | endif | 97 | endif |
98 | 98 | ||
99 | ifeq ($(CONFIG_TUNE_CELL),y) | 99 | ifeq ($(CONFIG_TUNE_CELL),y) |
diff --git a/arch/s390/Makefile b/arch/s390/Makefile index fc8fb20e7fc0..83ef8724c833 100644 --- a/arch/s390/Makefile +++ b/arch/s390/Makefile | |||
@@ -22,7 +22,8 @@ STACK_SIZE := 8192 | |||
22 | CHECKFLAGS += -D__s390__ -msize-long | 22 | CHECKFLAGS += -D__s390__ -msize-long |
23 | else | 23 | else |
24 | LDFLAGS := -m elf64_s390 | 24 | LDFLAGS := -m elf64_s390 |
25 | MODFLAGS += -fpic -D__PIC__ | 25 | KBUILD_AFLAGS_MODULE += -fpic -D__PIC__ |
26 | KBUILD_CFLAGS_MODULE += -fpic -D__PIC__ | ||
26 | KBUILD_CFLAGS += -m64 | 27 | KBUILD_CFLAGS += -m64 |
27 | KBUILD_AFLAGS += -m64 | 28 | KBUILD_AFLAGS += -m64 |
28 | UTS_MACHINE := s390x | 29 | UTS_MACHINE := s390x |
diff --git a/arch/score/Makefile b/arch/score/Makefile index 68e0cd06d5c9..d77dc639d8e3 100644 --- a/arch/score/Makefile +++ b/arch/score/Makefile | |||
@@ -20,7 +20,8 @@ cflags-y += -G0 -pipe -mel -mnhwloop -D__SCOREEL__ \ | |||
20 | # | 20 | # |
21 | KBUILD_AFLAGS += $(cflags-y) | 21 | KBUILD_AFLAGS += $(cflags-y) |
22 | KBUILD_CFLAGS += $(cflags-y) | 22 | KBUILD_CFLAGS += $(cflags-y) |
23 | MODFLAGS += -mlong-calls | 23 | KBUILD_AFLAGS_MODULE += -mlong-calls |
24 | KBUILD_CFLAGS_MODULE += -mlong-calls | ||
24 | LDFLAGS += --oformat elf32-littlescore | 25 | LDFLAGS += --oformat elf32-littlescore |
25 | LDFLAGS_vmlinux += -G0 -static -nostdlib | 26 | LDFLAGS_vmlinux += -G0 -static -nostdlib |
26 | 27 | ||
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 390aae4bb222..5e7c40e16545 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build | |||
@@ -115,7 +115,10 @@ endif | |||
115 | # --------------------------------------------------------------------------- | 115 | # --------------------------------------------------------------------------- |
116 | 116 | ||
117 | # Default is built-in, unless we know otherwise | 117 | # Default is built-in, unless we know otherwise |
118 | modkern_cflags = $(if $(part-of-module), $(CFLAGS_MODULE), $(CFLAGS_KERNEL)) | 118 | modkern_cflags = \ |
119 | $(if $(part-of-module), \ | ||
120 | $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \ | ||
121 | $(CFLAGS_KERNEL)) | ||
119 | quiet_modtag := $(empty) $(empty) | 122 | quiet_modtag := $(empty) $(empty) |
120 | 123 | ||
121 | $(real-objs-m) : part-of-module := y | 124 | $(real-objs-m) : part-of-module := y |
@@ -250,8 +253,8 @@ $(obj)/%.lst: $(src)/%.c FORCE | |||
250 | 253 | ||
251 | modkern_aflags := $(AFLAGS_KERNEL) | 254 | modkern_aflags := $(AFLAGS_KERNEL) |
252 | 255 | ||
253 | $(real-objs-m) : modkern_aflags := $(AFLAGS_MODULE) | 256 | $(real-objs-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) |
254 | $(real-objs-m:.o=.s): modkern_aflags := $(AFLAGS_MODULE) | 257 | $(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE) |
255 | 258 | ||
256 | quiet_cmd_as_s_S = CPP $(quiet_modtag) $@ | 259 | quiet_cmd_as_s_S = CPP $(quiet_modtag) $@ |
257 | cmd_as_s_S = $(CPP) $(a_flags) -o $@ $< | 260 | cmd_as_s_S = $(CPP) $(a_flags) -o $@ $< |
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 8f14c81abbc7..3e3f02409bbd 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost | |||
@@ -107,7 +107,7 @@ $(modules:.ko=.mod.c): __modpost ; | |||
107 | modname = $(notdir $(@:.mod.o=)) | 107 | modname = $(notdir $(@:.mod.o=)) |
108 | 108 | ||
109 | quiet_cmd_cc_o_c = CC $@ | 109 | quiet_cmd_cc_o_c = CC $@ |
110 | cmd_cc_o_c = $(CC) $(c_flags) $(CFLAGS_MODULE) \ | 110 | cmd_cc_o_c = $(CC) $(c_flags) $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE) \ |
111 | -c -o $@ $< | 111 | -c -o $@ $< |
112 | 112 | ||
113 | $(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE | 113 | $(modules:.ko=.mod.o): %.mod.o: %.mod.c FORCE |
@@ -117,8 +117,9 @@ targets += $(modules:.ko=.mod.o) | |||
117 | 117 | ||
118 | # Step 6), final link of the modules | 118 | # Step 6), final link of the modules |
119 | quiet_cmd_ld_ko_o = LD [M] $@ | 119 | quiet_cmd_ld_ko_o = LD [M] $@ |
120 | cmd_ld_ko_o = $(LD) -r $(LDFLAGS) $(LDFLAGS_MODULE) -o $@ \ | 120 | cmd_ld_ko_o = $(LD) -r $(LDFLAGS) \ |
121 | $(filter-out FORCE,$^) | 121 | $(KBUILD_LDFLAGS_MODULE) $(LDFLAGS_MODULE) \ |
122 | -o $@ $(filter-out FORCE,$^) | ||
122 | 123 | ||
123 | $(modules): %.ko :%.o %.mod.o FORCE | 124 | $(modules): %.ko :%.o %.mod.o FORCE |
124 | $(call if_changed,ld_ko_o) | 125 | $(call if_changed,ld_ko_o) |