diff options
Diffstat (limited to 'Documentation/kbuild')
-rw-r--r-- | Documentation/kbuild/kbuild.txt | 34 | ||||
-rw-r--r-- | Documentation/kbuild/makefiles.txt | 133 |
2 files changed, 99 insertions, 68 deletions
diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt index 634c625da8ce..1e5165aa9e4e 100644 --- a/Documentation/kbuild/kbuild.txt +++ b/Documentation/kbuild/kbuild.txt | |||
@@ -22,11 +22,33 @@ 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). | ||
30 | |||
31 | AFLAGS_KERNEL | ||
32 | -------------------------------------------------- | ||
33 | Addtional options for $(AS) when used for assembler | ||
34 | code for code that is compiled as built-in. | ||
26 | 35 | ||
27 | KCFLAGS | 36 | KCFLAGS |
28 | -------------------------------------------------- | 37 | -------------------------------------------------- |
29 | Additional options to the C compiler. | 38 | Additional options to the C compiler (for built-in and modules). |
39 | |||
40 | CFLAGS_KERNEL | ||
41 | -------------------------------------------------- | ||
42 | Addtional options for $(CC) when used to compile | ||
43 | code that is compiled as built-in. | ||
44 | |||
45 | CFLAGS_MODULE | ||
46 | -------------------------------------------------- | ||
47 | Addtional module specific options to use for $(CC). | ||
48 | |||
49 | LDFLAGS_MODULE | ||
50 | -------------------------------------------------- | ||
51 | Additional options used for $(LD) when linking modules. | ||
30 | 52 | ||
31 | KBUILD_VERBOSE | 53 | KBUILD_VERBOSE |
32 | -------------------------------------------------- | 54 | -------------------------------------------------- |
@@ -40,15 +62,15 @@ Set the directory to look for the kernel source when building external | |||
40 | modules. | 62 | modules. |
41 | The directory can be specified in several ways: | 63 | The directory can be specified in several ways: |
42 | 1) Use "M=..." on the command line | 64 | 1) Use "M=..." on the command line |
43 | 2) Environmnet variable KBUILD_EXTMOD | 65 | 2) Environment variable KBUILD_EXTMOD |
44 | 3) Environmnet variable SUBDIRS | 66 | 3) Environment variable SUBDIRS |
45 | The possibilities are listed in the order they take precedence. | 67 | The possibilities are listed in the order they take precedence. |
46 | Using "M=..." will always override the others. | 68 | Using "M=..." will always override the others. |
47 | 69 | ||
48 | KBUILD_OUTPUT | 70 | KBUILD_OUTPUT |
49 | -------------------------------------------------- | 71 | -------------------------------------------------- |
50 | Specify the output directory when building the kernel. | 72 | Specify the output directory when building the kernel. |
51 | The output directory can also be specificed using "O=...". | 73 | The output directory can also be specified using "O=...". |
52 | Setting "O=..." takes precedence over KBUILD_OUTPUT. | 74 | Setting "O=..." takes precedence over KBUILD_OUTPUT. |
53 | 75 | ||
54 | ARCH | 76 | ARCH |
@@ -90,7 +112,7 @@ The script will be called with the following arguments: | |||
90 | $3 - kernel map file | 112 | $3 - kernel map file |
91 | $4 - default install path (use root directory if blank) | 113 | $4 - default install path (use root directory if blank) |
92 | 114 | ||
93 | The implmentation of "make install" is architecture specific | 115 | The implementation of "make install" is architecture specific |
94 | and it may differ from the above. | 116 | and it may differ from the above. |
95 | 117 | ||
96 | INSTALLKERNEL is provided to enable the possibility to | 118 | INSTALLKERNEL is provided to enable the possibility to |
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index 71c602d61680..c787ae512120 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt | |||
@@ -45,7 +45,6 @@ This document describes the Linux kernel Makefiles. | |||
45 | --- 7.1 header-y | 45 | --- 7.1 header-y |
46 | --- 7.2 objhdr-y | 46 | --- 7.2 objhdr-y |
47 | --- 7.3 destination-y | 47 | --- 7.3 destination-y |
48 | --- 7.4 unifdef-y (deprecated) | ||
49 | 48 | ||
50 | === 8 Kbuild Variables | 49 | === 8 Kbuild Variables |
51 | === 9 Makefile language | 50 | === 9 Makefile language |
@@ -168,7 +167,7 @@ more details, with real examples. | |||
168 | #drivers/isdn/i4l/Makefile | 167 | #drivers/isdn/i4l/Makefile |
169 | # Makefile for the kernel ISDN subsystem and device drivers. | 168 | # Makefile for the kernel ISDN subsystem and device drivers. |
170 | # Each configuration option enables a list of files. | 169 | # Each configuration option enables a list of files. |
171 | obj-$(CONFIG_ISDN) += isdn.o | 170 | obj-$(CONFIG_ISDN_I4L) += isdn.o |
172 | obj-$(CONFIG_ISDN_PPP_BSDCOMP) += isdn_bsdcomp.o | 171 | obj-$(CONFIG_ISDN_PPP_BSDCOMP) += isdn_bsdcomp.o |
173 | 172 | ||
174 | --- 3.3 Loadable module goals - obj-m | 173 | --- 3.3 Loadable module goals - obj-m |
@@ -187,34 +186,35 @@ more details, with real examples. | |||
187 | Note: In this example $(CONFIG_ISDN_PPP_BSDCOMP) evaluates to 'm' | 186 | Note: In this example $(CONFIG_ISDN_PPP_BSDCOMP) evaluates to 'm' |
188 | 187 | ||
189 | If a kernel module is built from several source files, you specify | 188 | If a kernel module is built from several source files, you specify |
190 | that you want to build a module in the same way as above. | 189 | that you want to build a module in the same way as above; however, |
191 | 190 | kbuild needs to know which object files you want to build your | |
192 | Kbuild needs to know which the parts that you want to build your | 191 | module from, so you have to tell it by setting a $(<module_name>-y) |
193 | module from, so you have to tell it by setting an | 192 | variable. |
194 | $(<module_name>-objs) variable. | ||
195 | 193 | ||
196 | Example: | 194 | Example: |
197 | #drivers/isdn/i4l/Makefile | 195 | #drivers/isdn/i4l/Makefile |
198 | obj-$(CONFIG_ISDN) += isdn.o | 196 | obj-$(CONFIG_ISDN_I4L) += isdn.o |
199 | isdn-objs := isdn_net_lib.o isdn_v110.o isdn_common.o | 197 | isdn-y := isdn_net_lib.o isdn_v110.o isdn_common.o |
200 | 198 | ||
201 | In this example, the module name will be isdn.o. Kbuild will | 199 | In this example, the module name will be isdn.o. Kbuild will |
202 | compile the objects listed in $(isdn-objs) and then run | 200 | compile the objects listed in $(isdn-y) and then run |
203 | "$(LD) -r" on the list of these files to generate isdn.o. | 201 | "$(LD) -r" on the list of these files to generate isdn.o. |
204 | 202 | ||
205 | Kbuild recognises objects used for composite objects by the suffix | 203 | Due to kbuild recognizing $(<module_name>-y) for composite objects, |
206 | -objs, and the suffix -y. This allows the Makefiles to use | 204 | you can use the value of a CONFIG_ symbol to optionally include an |
207 | the value of a CONFIG_ symbol to determine if an object is part | 205 | object file as part of a composite object. |
208 | of a composite object. | ||
209 | 206 | ||
210 | Example: | 207 | Example: |
211 | #fs/ext2/Makefile | 208 | #fs/ext2/Makefile |
212 | obj-$(CONFIG_EXT2_FS) += ext2.o | 209 | obj-$(CONFIG_EXT2_FS) += ext2.o |
213 | ext2-y := balloc.o bitmap.o | 210 | ext2-y := balloc.o dir.o file.o ialloc.o inode.o ioctl.o \ |
214 | ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o | 211 | namei.o super.o symlink.o |
212 | ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o xattr_user.o \ | ||
213 | xattr_trusted.o | ||
215 | 214 | ||
216 | In this example, xattr.o is only part of the composite object | 215 | In this example, xattr.o, xattr_user.o and xattr_trusted.o are only |
217 | ext2.o if $(CONFIG_EXT2_FS_XATTR) evaluates to 'y'. | 216 | part of the composite object ext2.o if $(CONFIG_EXT2_FS_XATTR) |
217 | evaluates to 'y'. | ||
218 | 218 | ||
219 | Note: Of course, when you are building objects into the kernel, | 219 | Note: Of course, when you are building objects into the kernel, |
220 | the syntax above will also work. So, if you have CONFIG_EXT2_FS=y, | 220 | the syntax above will also work. So, if you have CONFIG_EXT2_FS=y, |
@@ -244,12 +244,12 @@ more details, with real examples. | |||
244 | may contain both a built-in.o and a lib.a file. | 244 | may contain both a built-in.o and a lib.a file. |
245 | 245 | ||
246 | Example: | 246 | Example: |
247 | #arch/i386/lib/Makefile | 247 | #arch/x86/lib/Makefile |
248 | lib-y := checksum.o delay.o | 248 | lib-y := delay.o |
249 | 249 | ||
250 | This will create a library lib.a based on checksum.o and delay.o. | 250 | This will create a library lib.a based on delay.o. For kbuild to |
251 | For kbuild to actually recognize that there is a lib.a being built, | 251 | actually recognize that there is a lib.a being built, the directory |
252 | the directory shall be listed in libs-y. | 252 | shall be listed in libs-y. |
253 | See also "6.3 List directories to visit when descending". | 253 | See also "6.3 List directories to visit when descending". |
254 | 254 | ||
255 | Use of lib-y is normally restricted to lib/ and arch/*/lib. | 255 | Use of lib-y is normally restricted to lib/ and arch/*/lib. |
@@ -284,43 +284,40 @@ more details, with real examples. | |||
284 | --- 3.7 Compilation flags | 284 | --- 3.7 Compilation flags |
285 | 285 | ||
286 | ccflags-y, asflags-y and ldflags-y | 286 | ccflags-y, asflags-y and ldflags-y |
287 | The three flags listed above applies only to the kbuild makefile | 287 | These three flags apply only to the kbuild makefile in which they |
288 | where they are assigned. They are used for all the normal | 288 | are assigned. They are used for all the normal cc, as and ld |
289 | cc, as and ld invocation happenign during a recursive build. | 289 | invocations happening during a recursive build. |
290 | Note: Flags with the same behaviour were previously named: | 290 | Note: Flags with the same behaviour were previously named: |
291 | EXTRA_CFLAGS, EXTRA_AFLAGS and EXTRA_LDFLAGS. | 291 | EXTRA_CFLAGS, EXTRA_AFLAGS and EXTRA_LDFLAGS. |
292 | They are yet supported but their use are deprecated. | 292 | They are still supported but their usage is deprecated. |
293 | 293 | ||
294 | ccflags-y specifies options for compiling C files with $(CC). | 294 | ccflags-y specifies options for compiling with $(CC). |
295 | 295 | ||
296 | Example: | 296 | Example: |
297 | # drivers/sound/emu10k1/Makefile | 297 | # drivers/acpi/Makefile |
298 | ccflags-y += -I$(obj) | 298 | ccflags-y := -Os |
299 | ccflags-$(DEBUG) += -DEMU10K1_DEBUG | 299 | ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT |
300 | |||
301 | 300 | ||
302 | This variable is necessary because the top Makefile owns the | 301 | This variable is necessary because the top Makefile owns the |
303 | variable $(KBUILD_CFLAGS) and uses it for compilation flags for the | 302 | variable $(KBUILD_CFLAGS) and uses it for compilation flags for the |
304 | entire tree. | 303 | entire tree. |
305 | 304 | ||
306 | asflags-y is a similar string for per-directory options | 305 | asflags-y specifies options for assembling with $(AS). |
307 | when compiling assembly language source. | ||
308 | 306 | ||
309 | Example: | 307 | Example: |
310 | #arch/x86_64/kernel/Makefile | 308 | #arch/sparc/kernel/Makefile |
311 | asflags-y := -traditional | 309 | asflags-y := -ansi |
312 | 310 | ||
313 | 311 | ldflags-y specifies options for linking with $(LD). | |
314 | ldflags-y is a string for per-directory options to $(LD). | ||
315 | 312 | ||
316 | Example: | 313 | Example: |
317 | #arch/m68k/fpsp040/Makefile | 314 | #arch/cris/boot/compressed/Makefile |
318 | ldflags-y := -x | 315 | ldflags-y += -T $(srctree)/$(src)/decompress_$(arch-y).lds |
319 | 316 | ||
320 | subdir-ccflags-y, subdir-asflags-y | 317 | subdir-ccflags-y, subdir-asflags-y |
321 | The two flags listed above are similar to ccflags-y and as-falgs-y. | 318 | The two flags listed above are similar to ccflags-y and asflags-y. |
322 | The difference is that the subdir- variants has effect for the kbuild | 319 | The difference is that the subdir- variants have effect for the kbuild |
323 | file where tey are present and all subdirectories. | 320 | file where they are present and all subdirectories. |
324 | Options specified using subdir-* are added to the commandline before | 321 | Options specified using subdir-* are added to the commandline before |
325 | the options specified using the non-subdir variants. | 322 | the options specified using the non-subdir variants. |
326 | 323 | ||
@@ -340,18 +337,18 @@ more details, with real examples. | |||
340 | CFLAGS_aha152x.o = -DAHA152X_STAT -DAUTOCONF | 337 | CFLAGS_aha152x.o = -DAHA152X_STAT -DAUTOCONF |
341 | CFLAGS_gdth.o = # -DDEBUG_GDTH=2 -D__SERIAL__ -D__COM2__ \ | 338 | CFLAGS_gdth.o = # -DDEBUG_GDTH=2 -D__SERIAL__ -D__COM2__ \ |
342 | -DGDTH_STATISTICS | 339 | -DGDTH_STATISTICS |
343 | CFLAGS_seagate.o = -DARBITRATE -DPARITY -DSEAGATE_USE_ASM | ||
344 | 340 | ||
345 | These three lines specify compilation flags for aha152x.o, | 341 | These two lines specify compilation flags for aha152x.o and gdth.o. |
346 | gdth.o, and seagate.o | ||
347 | 342 | ||
348 | $(AFLAGS_$@) is a similar feature for source files in assembly | 343 | $(AFLAGS_$@) is a similar feature for source files in assembly |
349 | languages. | 344 | languages. |
350 | 345 | ||
351 | Example: | 346 | Example: |
352 | # arch/arm/kernel/Makefile | 347 | # arch/arm/kernel/Makefile |
353 | AFLAGS_head-armv.o := -DTEXTADDR=$(TEXTADDR) -traditional | 348 | AFLAGS_head.o := -DTEXT_OFFSET=$(TEXT_OFFSET) |
354 | AFLAGS_head-armo.o := -DTEXTADDR=$(TEXTADDR) -traditional | 349 | AFLAGS_crunch-bits.o := -Wa,-mcpu=ep9312 |
350 | AFLAGS_iwmmxt.o := -Wa,-mcpu=iwmmxt | ||
351 | |||
355 | 352 | ||
356 | --- 3.9 Dependency tracking | 353 | --- 3.9 Dependency tracking |
357 | 354 | ||
@@ -923,16 +920,33 @@ When kbuild executes, the following steps are followed (roughly): | |||
923 | The first example utilises the trick that a config option expands | 920 | The first example utilises the trick that a config option expands |
924 | to 'y' when selected. | 921 | to 'y' when selected. |
925 | 922 | ||
926 | CFLAGS_KERNEL $(CC) options specific for built-in | 923 | KBUILD_AFLAGS_KERNEL $(AS) options specific for built-in |
927 | 924 | ||
928 | $(CFLAGS_KERNEL) contains extra C compiler flags used to compile | 925 | $(KBUILD_AFLAGS_KERNEL) contains extra C compiler flags used to compile |
929 | resident kernel code. | 926 | resident kernel code. |
930 | 927 | ||
931 | CFLAGS_MODULE $(CC) options specific for modules | 928 | KBUILD_AFLAGS_MODULE Options for $(AS) when building modules |
932 | 929 | ||
933 | $(CFLAGS_MODULE) contains extra C compiler flags used to compile code | 930 | $(KBUILD_AFLAGS_MODULE) is used to add arch specific options that |
934 | for loadable kernel modules. | 931 | are used for $(AS). |
932 | From commandline AFLAGS_MODULE shall be used (see kbuild.txt). | ||
933 | |||
934 | KBUILD_CFLAGS_KERNEL $(CC) options specific for built-in | ||
935 | |||
936 | $(KBUILD_CFLAGS_KERNEL) contains extra C compiler flags used to compile | ||
937 | resident kernel code. | ||
935 | 938 | ||
939 | KBUILD_CFLAGS_MODULE Options for $(CC) when building modules | ||
940 | |||
941 | $(KBUILD_CFLAGS_MODULE) is used to add arch specific options that | ||
942 | are used for $(CC). | ||
943 | From commandline CFLAGS_MODULE shall be used (see kbuild.txt). | ||
944 | |||
945 | KBUILD_LDFLAGS_MODULE Options for $(LD) when linking modules | ||
946 | |||
947 | $(KBUILD_LDFLAGS_MODULE) is used to add arch specific options | ||
948 | used when linking modules. This is often a linker script. | ||
949 | From commandline LDFLAGS_MODULE shall be used (see kbuild.txt). | ||
936 | 950 | ||
937 | --- 6.2 Add prerequisites to archprepare: | 951 | --- 6.2 Add prerequisites to archprepare: |
938 | 952 | ||
@@ -1176,14 +1190,14 @@ When kbuild executes, the following steps are followed (roughly): | |||
1176 | === 7 Kbuild syntax for exported headers | 1190 | === 7 Kbuild syntax for exported headers |
1177 | 1191 | ||
1178 | The kernel include a set of headers that is exported to userspace. | 1192 | The kernel include a set of headers that is exported to userspace. |
1179 | Many headers can be exported as-is but other headers requires a | 1193 | Many headers can be exported as-is but other headers require a |
1180 | minimal pre-processing before they are ready for user-space. | 1194 | minimal pre-processing before they are ready for user-space. |
1181 | The pre-processing does: | 1195 | The pre-processing does: |
1182 | - drop kernel specific annotations | 1196 | - drop kernel specific annotations |
1183 | - drop include of compiler.h | 1197 | - drop include of compiler.h |
1184 | - drop all sections that is kernel internat (guarded by ifdef __KERNEL__) | 1198 | - drop all sections that are kernel internal (guarded by ifdef __KERNEL__) |
1185 | 1199 | ||
1186 | Each relevant directory contain a file name "Kbuild" which specify the | 1200 | Each relevant directory contains a file name "Kbuild" which specifies the |
1187 | headers to be exported. | 1201 | headers to be exported. |
1188 | See subsequent chapter for the syntax of the Kbuild file. | 1202 | See subsequent chapter for the syntax of the Kbuild file. |
1189 | 1203 | ||
@@ -1230,11 +1244,6 @@ See subsequent chapter for the syntax of the Kbuild file. | |||
1230 | will be located in the directory "include/linux" when exported. | 1244 | will be located in the directory "include/linux" when exported. |
1231 | 1245 | ||
1232 | 1246 | ||
1233 | --- 7.4 unifdef-y (deprecated) | ||
1234 | |||
1235 | unifdef-y is deprecated. A direct replacement is header-y. | ||
1236 | |||
1237 | |||
1238 | === 8 Kbuild Variables | 1247 | === 8 Kbuild Variables |
1239 | 1248 | ||
1240 | The top Makefile exports the following variables: | 1249 | The top Makefile exports the following variables: |