From 6588169d516560f68672e2928680b71c647b7806 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Wed, 28 Jul 2010 17:33:09 +0200 Subject: kbuild: allow assignment to {A,C,LD}FLAGS_MODULE on the command line It is now possible to assign options to AS, CC and LD on the command line - which is only used when building modules. {A,C,LD}FLAGS_MODULE was all used both in the top-level Makefile in the arch makefiles, thus users had no way to specify additional options to AS, CC, LD when building modules without overriding the original value. Introduce a new set of variables KBUILD_{A,C,LD}FLAGS_MODULE that is used by arch specific files and free up {A,C,LD}FLAGS_MODULE so they can be assigned on the command line. All arch Makefiles that used the old variables has been updated. Note: Previously we had a MODFLAGS variable for both AS and CC. But in favour of consistency this was dropped. So in some cases arch Makefile has one assignmnet replaced by two assignmnets. Note2: MODFLAGS was not documented and is dropped without any notice. I do not expect much/any breakage from this. Signed-off-by: Sam Ravnborg Cc: Denys Vlasenko Cc: Haavard Skinnemoen Cc: Mike Frysinger Cc: Tony Luck Cc: Geert Uytterhoeven Cc: Ralf Baechle Cc: Benjamin Herrenschmidt Cc: Martin Schwidefsky Cc: Chen Liqin Acked-by: Mike Frysinger [blackfin] Acked-by: Haavard Skinnemoen [avr32] Signed-off-by: Michal Marek --- Documentation/kbuild/kbuild.txt | 16 ++++++++++++++-- Documentation/kbuild/makefiles.txt | 18 +++++++++++++++--- 2 files changed, 29 insertions(+), 5 deletions(-) (limited to 'Documentation/kbuild') diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt index 634c625da8c..d9c655433ec 100644 --- a/Documentation/kbuild/kbuild.txt +++ b/Documentation/kbuild/kbuild.txt @@ -22,11 +22,23 @@ building C files and assembler files. KAFLAGS -------------------------------------------------- -Additional options to the assembler. +Additional options to the assembler (for built-in and modules). + +AFLAGS_MODULE +-------------------------------------------------- +Addtional module specific options to use for $(AS). KCFLAGS -------------------------------------------------- -Additional options to the C compiler. +Additional options to the C compiler (for built-in and modules). + +CFLAGS_MODULE +-------------------------------------------------- +Addtional module specific options to use for $(CC). + +LDFLAGS_MODULE +-------------------------------------------------- +Additional options used for $(LD) when linking modules. KBUILD_VERBOSE -------------------------------------------------- diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index 71c602d6168..802341abf70 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -928,11 +928,23 @@ When kbuild executes, the following steps are followed (roughly): $(CFLAGS_KERNEL) contains extra C compiler flags used to compile resident kernel code. - CFLAGS_MODULE $(CC) options specific for modules + KBUILD_AFLAGS_MODULE Options for $(AS) when building modules - $(CFLAGS_MODULE) contains extra C compiler flags used to compile code - for loadable kernel modules. + $(KBUILD_AFLAGS_MODULE) is used to add arch specific options that + are used for $(AS). + From commandline AFLAGS_MODULE shall be used (see kbuild.txt). + KBUILD_CFLAGS_MODULE Options for $(CC) when building modules + + $(KBUILD_CFLAGS_MODULE) is used to add arch specific options that + are used for $(CC). + From commandline CFLAGS_MODULE shall be used (see kbuild.txt). + + KBUILD_LDFLAGS_MODULE Options for $(LD) when linking modules + + $(KBUILD_LDFLAGS_MODULE) is used to add arch specific options + used when linking modules. This is often a linker script. + From commandline LDFLAGS_MODULE shall be used (see kbuild.txt). --- 6.2 Add prerequisites to archprepare: -- cgit v1.2.3 From 80c00ba942ee39c9a95c06959223560400bbb86e Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Wed, 28 Jul 2010 19:11:27 +0200 Subject: kbuild: allow assignment to {A,C}FLAGS_KERNEL on the command line It is now possible to assign options to AS and CC on the command line - which is only used for built-in code. {A,C}FLAGS_KERNEL was used both in the top-level Makefile in the arch makefiles, thus users had no way to specify additional options to AS, CC without overriding the original value. Introduce a new set of variables KBUILD_{A,C}FLAGS_KERNEL that is used by arch specific files and free up {A,C}FLAGS_KERNEL so they can be assigned on the command line. All arch Makefiles that used the old variables has been updated. Signed-off-by: Sam Ravnborg Cc: Tony Luck Cc: Hirokazu Takata Signed-off-by: Michal Marek --- Documentation/kbuild/kbuild.txt | 10 ++++++++++ Documentation/kbuild/makefiles.txt | 9 +++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'Documentation/kbuild') diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt index d9c655433ec..e903f20077c 100644 --- a/Documentation/kbuild/kbuild.txt +++ b/Documentation/kbuild/kbuild.txt @@ -28,10 +28,20 @@ AFLAGS_MODULE -------------------------------------------------- Addtional module specific options to use for $(AS). +AFLAGS_KERNEL +-------------------------------------------------- +Addtional options for $(AS) when used for assembler +code for code that is compiled as built-in. + KCFLAGS -------------------------------------------------- Additional options to the C compiler (for built-in and modules). +CFLAGS_KERNEL +-------------------------------------------------- +Addtional options for $(CC) when used to compile +code that is compiled as built-in. + CFLAGS_MODULE -------------------------------------------------- Addtional module specific options to use for $(CC). diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index 802341abf70..5c878cc6c0b 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -923,9 +923,9 @@ When kbuild executes, the following steps are followed (roughly): The first example utilises the trick that a config option expands to 'y' when selected. - CFLAGS_KERNEL $(CC) options specific for built-in + KBUILD_AFLAGS_KERNEL $(AS) options specific for built-in - $(CFLAGS_KERNEL) contains extra C compiler flags used to compile + $(KBUILD_AFLAGS_KERNEL) contains extra C compiler flags used to compile resident kernel code. KBUILD_AFLAGS_MODULE Options for $(AS) when building modules @@ -934,6 +934,11 @@ When kbuild executes, the following steps are followed (roughly): are used for $(AS). From commandline AFLAGS_MODULE shall be used (see kbuild.txt). + KBUILD_CFLAGS_KERNEL $(CC) options specific for built-in + + $(KBUILD_CFLAGS_KERNEL) contains extra C compiler flags used to compile + resident kernel code. + KBUILD_CFLAGS_MODULE Options for $(CC) when building modules $(KBUILD_CFLAGS_MODULE) is used to add arch specific options that -- cgit v1.2.3 From 4f8272802739f5c6ce6b0a548810a181d2f1b652 Mon Sep 17 00:00:00 2001 From: Matt Mooney Date: Thu, 5 Aug 2010 11:23:11 -0700 Subject: Documentation: update kbuild loadable modules goals & examples Update section 3.3 Loadable module goals - obj-m, from $(-objs) to $(-y) for easier addition of conditional objects to the module. The examples are also updated to reflect the current state of each Makefile used. Signed-off-by: matt mooney Reviewed-by: WANG Cong Signed-off-by: Randy Dunlap Signed-off-by: Linus Torvalds --- Documentation/kbuild/makefiles.txt | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) (limited to 'Documentation/kbuild') diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index 71c602d6168..f29dca374aa 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -187,34 +187,35 @@ more details, with real examples. Note: In this example $(CONFIG_ISDN_PPP_BSDCOMP) evaluates to 'm' If a kernel module is built from several source files, you specify - that you want to build a module in the same way as above. - - Kbuild needs to know which the parts that you want to build your - module from, so you have to tell it by setting an - $(-objs) variable. + that you want to build a module in the same way as above; however, + kbuild needs to know which object files you want to build your + module from, so you have to tell it by setting a $(-y) + variable. Example: #drivers/isdn/i4l/Makefile - obj-$(CONFIG_ISDN) += isdn.o - isdn-objs := isdn_net_lib.o isdn_v110.o isdn_common.o + obj-$(CONFIG_ISDN_I4L) += isdn.o + isdn-y := isdn_net_lib.o isdn_v110.o isdn_common.o In this example, the module name will be isdn.o. Kbuild will - compile the objects listed in $(isdn-objs) and then run + compile the objects listed in $(isdn-y) and then run "$(LD) -r" on the list of these files to generate isdn.o. - Kbuild recognises objects used for composite objects by the suffix - -objs, and the suffix -y. This allows the Makefiles to use - the value of a CONFIG_ symbol to determine if an object is part - of a composite object. + Due to kbuild recognizing $(-y) for composite objects, + you can use the value of a CONFIG_ symbol to optionally include an + object file as part of a composite object. Example: #fs/ext2/Makefile - obj-$(CONFIG_EXT2_FS) += ext2.o - ext2-y := balloc.o bitmap.o - ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o - - In this example, xattr.o is only part of the composite object - ext2.o if $(CONFIG_EXT2_FS_XATTR) evaluates to 'y'. + obj-$(CONFIG_EXT2_FS) += ext2.o + ext2-y := balloc.o dir.o file.o ialloc.o inode.o ioctl.o \ + namei.o super.o symlink.o + ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o xattr_user.o \ + xattr_trusted.o + + In this example, xattr.o, xattr_user.o and xattr_trusted.o are only + part of the composite object ext2.o if $(CONFIG_EXT2_FS_XATTR) + evaluates to 'y'. Note: Of course, when you are building objects into the kernel, the syntax above will also work. So, if you have CONFIG_EXT2_FS=y, -- cgit v1.2.3 From 2f5a2f81843ccef626c3db30aa19ed5abf8f0181 Mon Sep 17 00:00:00 2001 From: Matt Mooney Date: Thu, 5 Aug 2010 11:23:11 -0700 Subject: Documentation: update kbuild make examples#2 to reflect changes Update section 3.2 and 3.5 example, along with text in section 3.5 to reflect change. Signed-off-by: matt mooney Reviewed-by: WANG Cong Signed-off-by: Randy Dunlap Signed-off-by: Linus Torvalds --- Documentation/kbuild/makefiles.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'Documentation/kbuild') diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index f29dca374aa..d77e24e0055 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -168,7 +168,7 @@ more details, with real examples. #drivers/isdn/i4l/Makefile # Makefile for the kernel ISDN subsystem and device drivers. # Each configuration option enables a list of files. - obj-$(CONFIG_ISDN) += isdn.o + obj-$(CONFIG_ISDN_I4L) += isdn.o obj-$(CONFIG_ISDN_PPP_BSDCOMP) += isdn_bsdcomp.o --- 3.3 Loadable module goals - obj-m @@ -245,12 +245,12 @@ more details, with real examples. may contain both a built-in.o and a lib.a file. Example: - #arch/i386/lib/Makefile - lib-y := checksum.o delay.o + #arch/x86/lib/Makefile + lib-y := delay.o - This will create a library lib.a based on checksum.o and delay.o. - For kbuild to actually recognize that there is a lib.a being built, - the directory shall be listed in libs-y. + This will create a library lib.a based on delay.o. For kbuild to + actually recognize that there is a lib.a being built, the directory + shall be listed in libs-y. See also "6.3 List directories to visit when descending". Use of lib-y is normally restricted to lib/ and arch/*/lib. -- cgit v1.2.3 From eb07e1b4ac544abaf4ec8ad25cdbe39485de6842 Mon Sep 17 00:00:00 2001 From: Matt Mooney Date: Thu, 5 Aug 2010 11:23:11 -0700 Subject: Documentation: update kbuild make typos/grammar/text flow Update section 3.7 examples to reflect the current state of the Makefiles used. Fix spelling and grammar errors along with flow of text. Signed-off-by: matt mooney Reviewed-by: WANG Cong Signed-off-by: Randy Dunlap Signed-off-by: Linus Torvalds --- Documentation/kbuild/makefiles.txt | 53 ++++++++++++++++++-------------------- 1 file changed, 25 insertions(+), 28 deletions(-) (limited to 'Documentation/kbuild') diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index d77e24e0055..31bfcbf958f 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -285,45 +285,42 @@ more details, with real examples. --- 3.7 Compilation flags ccflags-y, asflags-y and ldflags-y - The three flags listed above applies only to the kbuild makefile - where they are assigned. They are used for all the normal - cc, as and ld invocation happenign during a recursive build. + The three flags listed above apply only to the kbuild makefile where + they are assigned (i.e., per-directory). They are used for all the + normal cc, as and ld invocation happening during a recursive build. Note: Flags with the same behaviour were previously named: - EXTRA_CFLAGS, EXTRA_AFLAGS and EXTRA_LDFLAGS. - They are yet supported but their use are deprecated. + EXTRA_CFLAGS, EXTRA_AFLAGS and EXTRA_LDFLAGS. They are still + supported but their use is deprecated. - ccflags-y specifies options for compiling C files with $(CC). + ccflags-y specifies options for compiling with $(CC). Example: - # drivers/sound/emu10k1/Makefile - ccflags-y += -I$(obj) - ccflags-$(DEBUG) += -DEMU10K1_DEBUG - + # drivers/acpi/Makefile + ccflags-y := -Os + ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT This variable is necessary because the top Makefile owns the variable $(KBUILD_CFLAGS) and uses it for compilation flags for the entire tree. - asflags-y is a similar string for per-directory options - when compiling assembly language source. + asflags-y specifies options for assembling with $(AS). Example: - #arch/x86_64/kernel/Makefile - asflags-y := -traditional - + #arch/sparc/kernel/Makefile + asflags-y := -ansi - ldflags-y is a string for per-directory options to $(LD). + ldflags-y specifies options for linking with $(LD). Example: - #arch/m68k/fpsp040/Makefile - ldflags-y := -x + #arch/cris/boot/compressed/Makefile + ldflags-y += -T $(srctree)/$(src)/decompress_$(arch-y).lds subdir-ccflags-y, subdir-asflags-y - The two flags listed above are similar to ccflags-y and as-falgs-y. - The difference is that the subdir- variants has effect for the kbuild - file where tey are present and all subdirectories. - Options specified using subdir-* are added to the commandline before - the options specified using the non-subdir variants. + The two flags listed above are similar to ccflags-y and asflags-y. + The difference is that the subdir- variants affect the kbuild + file where they are present and all subdirectories. Options specified + using subdir-* are added to the commandline before the options + specified using the non-subdir variants. Example: subdir-ccflags-y := -Werror @@ -341,18 +338,18 @@ more details, with real examples. CFLAGS_aha152x.o = -DAHA152X_STAT -DAUTOCONF CFLAGS_gdth.o = # -DDEBUG_GDTH=2 -D__SERIAL__ -D__COM2__ \ -DGDTH_STATISTICS - CFLAGS_seagate.o = -DARBITRATE -DPARITY -DSEAGATE_USE_ASM - These three lines specify compilation flags for aha152x.o, - gdth.o, and seagate.o + These two lines specify compilation flags for aha152x.o and gdth.o. $(AFLAGS_$@) is a similar feature for source files in assembly languages. Example: # arch/arm/kernel/Makefile - AFLAGS_head-armv.o := -DTEXTADDR=$(TEXTADDR) -traditional - AFLAGS_head-armo.o := -DTEXTADDR=$(TEXTADDR) -traditional + AFLAGS_head.o := -DTEXT_OFFSET=$(TEXT_OFFSET) + AFLAGS_crunch-bits.o := -Wa,-mcpu=ep9312 + AFLAGS_iwmmxt.o := -Wa,-mcpu=iwmmxt + --- 3.9 Dependency tracking -- cgit v1.2.3 From c95940f264e59ff8d21d76ace47bac1018912800 Mon Sep 17 00:00:00 2001 From: Nicolas Kaiser Date: Thu, 5 Aug 2010 11:23:11 -0700 Subject: Documentation: fix kbuild typos and wording Fixed some typos and wording. Signed-off-by: Nicolas Kaiser Signed-off-by: Linus Torvalds --- Documentation/kbuild/kbuild.txt | 8 ++++---- Documentation/kbuild/makefiles.txt | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'Documentation/kbuild') diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt index 634c625da8c..0d8addbb0fa 100644 --- a/Documentation/kbuild/kbuild.txt +++ b/Documentation/kbuild/kbuild.txt @@ -40,15 +40,15 @@ Set the directory to look for the kernel source when building external modules. The directory can be specified in several ways: 1) Use "M=..." on the command line -2) Environmnet variable KBUILD_EXTMOD -3) Environmnet variable SUBDIRS +2) Environment variable KBUILD_EXTMOD +3) Environment variable SUBDIRS The possibilities are listed in the order they take precedence. Using "M=..." will always override the others. KBUILD_OUTPUT -------------------------------------------------- Specify the output directory when building the kernel. -The output directory can also be specificed using "O=...". +The output directory can also be specified using "O=...". Setting "O=..." takes precedence over KBUILD_OUTPUT. ARCH @@ -90,7 +90,7 @@ The script will be called with the following arguments: $3 - kernel map file $4 - default install path (use root directory if blank) -The implmentation of "make install" is architecture specific +The implementation of "make install" is architecture specific and it may differ from the above. INSTALLKERNEL is provided to enable the possibility to diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index 31bfcbf958f..8abd041b605 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -285,12 +285,12 @@ more details, with real examples. --- 3.7 Compilation flags ccflags-y, asflags-y and ldflags-y - The three flags listed above apply only to the kbuild makefile where - they are assigned (i.e., per-directory). They are used for all the - normal cc, as and ld invocation happening during a recursive build. + These three flags apply only to the kbuild makefile in which they + are assigned. They are used for all the normal cc, as and ld + invocations happening during a recursive build. Note: Flags with the same behaviour were previously named: - EXTRA_CFLAGS, EXTRA_AFLAGS and EXTRA_LDFLAGS. They are still - supported but their use is deprecated. + EXTRA_CFLAGS, EXTRA_AFLAGS and EXTRA_LDFLAGS. + They are still supported but their usage is deprecated. ccflags-y specifies options for compiling with $(CC). @@ -317,10 +317,10 @@ more details, with real examples. subdir-ccflags-y, subdir-asflags-y The two flags listed above are similar to ccflags-y and asflags-y. - The difference is that the subdir- variants affect the kbuild - file where they are present and all subdirectories. Options specified - using subdir-* are added to the commandline before the options - specified using the non-subdir variants. + The difference is that the subdir- variants have effect for the kbuild + file where they are present and all subdirectories. + Options specified using subdir-* are added to the commandline before + the options specified using the non-subdir variants. Example: subdir-ccflags-y := -Werror @@ -1174,14 +1174,14 @@ When kbuild executes, the following steps are followed (roughly): === 7 Kbuild syntax for exported headers The kernel include a set of headers that is exported to userspace. -Many headers can be exported as-is but other headers requires a +Many headers can be exported as-is but other headers require a minimal pre-processing before they are ready for user-space. The pre-processing does: - drop kernel specific annotations - drop include of compiler.h -- drop all sections that is kernel internat (guarded by ifdef __KERNEL__) +- drop all sections that are kernel internal (guarded by ifdef __KERNEL__) -Each relevant directory contain a file name "Kbuild" which specify the +Each relevant directory contains a file name "Kbuild" which specifies the headers to be exported. See subsequent chapter for the syntax of the Kbuild file. -- cgit v1.2.3 From 7cfddeef357aac78179ea804b11cffb5fbba8288 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 14 Aug 2010 10:22:58 +0200 Subject: kbuild: drop unifdef-y support unifdef-y is not used anymore - drop remaining references Signed-off-by: Sam Ravnborg --- Documentation/kbuild/makefiles.txt | 6 ------ 1 file changed, 6 deletions(-) (limited to 'Documentation/kbuild') diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index c375313cb12..c787ae51212 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -45,7 +45,6 @@ This document describes the Linux kernel Makefiles. --- 7.1 header-y --- 7.2 objhdr-y --- 7.3 destination-y - --- 7.4 unifdef-y (deprecated) === 8 Kbuild Variables === 9 Makefile language @@ -1245,11 +1244,6 @@ See subsequent chapter for the syntax of the Kbuild file. will be located in the directory "include/linux" when exported. - --- 7.4 unifdef-y (deprecated) - - unifdef-y is deprecated. A direct replacement is header-y. - - === 8 Kbuild Variables The top Makefile exports the following variables: -- cgit v1.2.3