aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/kbuild/makefiles.txt
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/kbuild/makefiles.txt')
-rw-r--r--Documentation/kbuild/makefiles.txt100
1 files changed, 49 insertions, 51 deletions
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 71c602d61680..8abd041b605d 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -168,7 +168,7 @@ more details, with real examples.
168 #drivers/isdn/i4l/Makefile 168 #drivers/isdn/i4l/Makefile
169 # Makefile for the kernel ISDN subsystem and device drivers. 169 # Makefile for the kernel ISDN subsystem and device drivers.
170 # Each configuration option enables a list of files. 170 # Each configuration option enables a list of files.
171 obj-$(CONFIG_ISDN) += isdn.o 171 obj-$(CONFIG_ISDN_I4L) += isdn.o
172 obj-$(CONFIG_ISDN_PPP_BSDCOMP) += isdn_bsdcomp.o 172 obj-$(CONFIG_ISDN_PPP_BSDCOMP) += isdn_bsdcomp.o
173 173
174--- 3.3 Loadable module goals - obj-m 174--- 3.3 Loadable module goals - obj-m
@@ -187,34 +187,35 @@ more details, with real examples.
187 Note: In this example $(CONFIG_ISDN_PPP_BSDCOMP) evaluates to 'm' 187 Note: In this example $(CONFIG_ISDN_PPP_BSDCOMP) evaluates to 'm'
188 188
189 If a kernel module is built from several source files, you specify 189 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. 190 that you want to build a module in the same way as above; however,
191 191 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 192 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 193 variable.
194 $(<module_name>-objs) variable.
195 194
196 Example: 195 Example:
197 #drivers/isdn/i4l/Makefile 196 #drivers/isdn/i4l/Makefile
198 obj-$(CONFIG_ISDN) += isdn.o 197 obj-$(CONFIG_ISDN_I4L) += isdn.o
199 isdn-objs := isdn_net_lib.o isdn_v110.o isdn_common.o 198 isdn-y := isdn_net_lib.o isdn_v110.o isdn_common.o
200 199
201 In this example, the module name will be isdn.o. Kbuild will 200 In this example, the module name will be isdn.o. Kbuild will
202 compile the objects listed in $(isdn-objs) and then run 201 compile the objects listed in $(isdn-y) and then run
203 "$(LD) -r" on the list of these files to generate isdn.o. 202 "$(LD) -r" on the list of these files to generate isdn.o.
204 203
205 Kbuild recognises objects used for composite objects by the suffix 204 Due to kbuild recognizing $(<module_name>-y) for composite objects,
206 -objs, and the suffix -y. This allows the Makefiles to use 205 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 206 object file as part of a composite object.
208 of a composite object.
209 207
210 Example: 208 Example:
211 #fs/ext2/Makefile 209 #fs/ext2/Makefile
212 obj-$(CONFIG_EXT2_FS) += ext2.o 210 obj-$(CONFIG_EXT2_FS) += ext2.o
213 ext2-y := balloc.o bitmap.o 211 ext2-y := balloc.o dir.o file.o ialloc.o inode.o ioctl.o \
214 ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o 212 namei.o super.o symlink.o
213 ext2-$(CONFIG_EXT2_FS_XATTR) += xattr.o xattr_user.o \
214 xattr_trusted.o
215 215
216 In this example, xattr.o is only part of the composite object 216 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'. 217 part of the composite object ext2.o if $(CONFIG_EXT2_FS_XATTR)
218 evaluates to 'y'.
218 219
219 Note: Of course, when you are building objects into the kernel, 220 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, 221 the syntax above will also work. So, if you have CONFIG_EXT2_FS=y,
@@ -244,12 +245,12 @@ more details, with real examples.
244 may contain both a built-in.o and a lib.a file. 245 may contain both a built-in.o and a lib.a file.
245 246
246 Example: 247 Example:
247 #arch/i386/lib/Makefile 248 #arch/x86/lib/Makefile
248 lib-y := checksum.o delay.o 249 lib-y := delay.o
249 250
250 This will create a library lib.a based on checksum.o and delay.o. 251 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, 252 actually recognize that there is a lib.a being built, the directory
252 the directory shall be listed in libs-y. 253 shall be listed in libs-y.
253 See also "6.3 List directories to visit when descending". 254 See also "6.3 List directories to visit when descending".
254 255
255 Use of lib-y is normally restricted to lib/ and arch/*/lib. 256 Use of lib-y is normally restricted to lib/ and arch/*/lib.
@@ -284,43 +285,40 @@ more details, with real examples.
284--- 3.7 Compilation flags 285--- 3.7 Compilation flags
285 286
286 ccflags-y, asflags-y and ldflags-y 287 ccflags-y, asflags-y and ldflags-y
287 The three flags listed above applies only to the kbuild makefile 288 These three flags apply only to the kbuild makefile in which they
288 where they are assigned. They are used for all the normal 289 are assigned. They are used for all the normal cc, as and ld
289 cc, as and ld invocation happenign during a recursive build. 290 invocations happening during a recursive build.
290 Note: Flags with the same behaviour were previously named: 291 Note: Flags with the same behaviour were previously named:
291 EXTRA_CFLAGS, EXTRA_AFLAGS and EXTRA_LDFLAGS. 292 EXTRA_CFLAGS, EXTRA_AFLAGS and EXTRA_LDFLAGS.
292 They are yet supported but their use are deprecated. 293 They are still supported but their usage is deprecated.
293 294
294 ccflags-y specifies options for compiling C files with $(CC). 295 ccflags-y specifies options for compiling with $(CC).
295 296
296 Example: 297 Example:
297 # drivers/sound/emu10k1/Makefile 298 # drivers/acpi/Makefile
298 ccflags-y += -I$(obj) 299 ccflags-y := -Os
299 ccflags-$(DEBUG) += -DEMU10K1_DEBUG 300 ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT
300
301 301
302 This variable is necessary because the top Makefile owns the 302 This variable is necessary because the top Makefile owns the
303 variable $(KBUILD_CFLAGS) and uses it for compilation flags for the 303 variable $(KBUILD_CFLAGS) and uses it for compilation flags for the
304 entire tree. 304 entire tree.
305 305
306 asflags-y is a similar string for per-directory options 306 asflags-y specifies options for assembling with $(AS).
307 when compiling assembly language source.
308 307
309 Example: 308 Example:
310 #arch/x86_64/kernel/Makefile 309 #arch/sparc/kernel/Makefile
311 asflags-y := -traditional 310 asflags-y := -ansi
312 311
313 312 ldflags-y specifies options for linking with $(LD).
314 ldflags-y is a string for per-directory options to $(LD).
315 313
316 Example: 314 Example:
317 #arch/m68k/fpsp040/Makefile 315 #arch/cris/boot/compressed/Makefile
318 ldflags-y := -x 316 ldflags-y += -T $(srctree)/$(src)/decompress_$(arch-y).lds
319 317
320 subdir-ccflags-y, subdir-asflags-y 318 subdir-ccflags-y, subdir-asflags-y
321 The two flags listed above are similar to ccflags-y and as-falgs-y. 319 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 320 The difference is that the subdir- variants have effect for the kbuild
323 file where tey are present and all subdirectories. 321 file where they are present and all subdirectories.
324 Options specified using subdir-* are added to the commandline before 322 Options specified using subdir-* are added to the commandline before
325 the options specified using the non-subdir variants. 323 the options specified using the non-subdir variants.
326 324
@@ -340,18 +338,18 @@ more details, with real examples.
340 CFLAGS_aha152x.o = -DAHA152X_STAT -DAUTOCONF 338 CFLAGS_aha152x.o = -DAHA152X_STAT -DAUTOCONF
341 CFLAGS_gdth.o = # -DDEBUG_GDTH=2 -D__SERIAL__ -D__COM2__ \ 339 CFLAGS_gdth.o = # -DDEBUG_GDTH=2 -D__SERIAL__ -D__COM2__ \
342 -DGDTH_STATISTICS 340 -DGDTH_STATISTICS
343 CFLAGS_seagate.o = -DARBITRATE -DPARITY -DSEAGATE_USE_ASM
344 341
345 These three lines specify compilation flags for aha152x.o, 342 These two lines specify compilation flags for aha152x.o and gdth.o.
346 gdth.o, and seagate.o
347 343
348 $(AFLAGS_$@) is a similar feature for source files in assembly 344 $(AFLAGS_$@) is a similar feature for source files in assembly
349 languages. 345 languages.
350 346
351 Example: 347 Example:
352 # arch/arm/kernel/Makefile 348 # arch/arm/kernel/Makefile
353 AFLAGS_head-armv.o := -DTEXTADDR=$(TEXTADDR) -traditional 349 AFLAGS_head.o := -DTEXT_OFFSET=$(TEXT_OFFSET)
354 AFLAGS_head-armo.o := -DTEXTADDR=$(TEXTADDR) -traditional 350 AFLAGS_crunch-bits.o := -Wa,-mcpu=ep9312
351 AFLAGS_iwmmxt.o := -Wa,-mcpu=iwmmxt
352
355 353
356--- 3.9 Dependency tracking 354--- 3.9 Dependency tracking
357 355
@@ -1176,14 +1174,14 @@ When kbuild executes, the following steps are followed (roughly):
1176=== 7 Kbuild syntax for exported headers 1174=== 7 Kbuild syntax for exported headers
1177 1175
1178The kernel include a set of headers that is exported to userspace. 1176The kernel include a set of headers that is exported to userspace.
1179Many headers can be exported as-is but other headers requires a 1177Many headers can be exported as-is but other headers require a
1180minimal pre-processing before they are ready for user-space. 1178minimal pre-processing before they are ready for user-space.
1181The pre-processing does: 1179The pre-processing does:
1182- drop kernel specific annotations 1180- drop kernel specific annotations
1183- drop include of compiler.h 1181- drop include of compiler.h
1184- drop all sections that is kernel internat (guarded by ifdef __KERNEL__) 1182- drop all sections that are kernel internal (guarded by ifdef __KERNEL__)
1185 1183
1186Each relevant directory contain a file name "Kbuild" which specify the 1184Each relevant directory contains a file name "Kbuild" which specifies the
1187headers to be exported. 1185headers to be exported.
1188See subsequent chapter for the syntax of the Kbuild file. 1186See subsequent chapter for the syntax of the Kbuild file.
1189 1187