mqueue: apply mathematics distributivity on mq_bytes calculation
[safe/jmp/linux-2.6] / Documentation / kbuild / makefiles.txt
index 6166e2d..71c602d 100644 (file)
@@ -18,6 +18,7 @@ This document describes the Linux kernel Makefiles.
           --- 3.9 Dependency tracking
           --- 3.10 Special Rules
           --- 3.11 $(CC) support functions
+          --- 3.12 $(LD) support functions
 
        === 4 Host Program support
           --- 4.1 Simple Host Program
@@ -40,10 +41,16 @@ This document describes the Linux kernel Makefiles.
           --- 6.7 Custom kbuild commands
           --- 6.8 Preprocessing linker scripts
 
-       === 7 Kbuild Variables
-       === 8 Makefile language
-       === 9 Credits
-       === 10 TODO
+       === 7 Kbuild syntax for exported headers
+               --- 7.1 header-y
+               --- 7.2 objhdr-y
+               --- 7.3 destination-y
+               --- 7.4 unifdef-y (deprecated)
+
+       === 8 Kbuild Variables
+       === 9 Makefile language
+       === 10 Credits
+       === 11 TODO
 
 === 1 Overview
 
@@ -310,6 +317,16 @@ more details, with real examples.
                #arch/m68k/fpsp040/Makefile
                ldflags-y := -x
 
+    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.
+
+       Example:
+               subdir-ccflags-y := -Werror
+
     CFLAGS_$@, AFLAGS_$@
 
        CFLAGS_$@ and AFLAGS_$@ only apply to commands in current
@@ -383,6 +400,20 @@ more details, with real examples.
        to prerequisites are referenced with $(src) (because they are not
        generated files).
 
+    $(kecho)
+       echoing information to user in a rule is often a good practice
+       but when execution "make -s" one does not expect to see any output
+       except for warnings/errors.
+       To support this kbuild define $(kecho) which will echo out the
+       text following $(kecho) to stdout except if "make -s" is used.
+
+       Example:
+               #arch/blackfin/boot/Makefile
+               $(obj)/vmImage: $(obj)/vmlinux.gz
+                       $(call if_changed,uimage)
+                       @$(kecho) 'Kernel: $@ is ready'
+
+
 --- 3.11 $(CC) support functions
 
        The kernel may be built with several different versions of
@@ -405,14 +436,14 @@ more details, with real examples.
        The second argument is optional, and if supplied will be used
        if first argument is not supported.
 
-    ld-option
-       ld-option is used to check if $(CC) when used to link object files
+    cc-ldoption
+       cc-ldoption is used to check if $(CC) when used to link object files
        supports the given option.  An optional second option may be
        specified if first option are not supported.
 
        Example:
                #arch/i386/kernel/Makefile
-               vsyscall-flags += $(call ld-option, -Wl$(comma)--hash-style=sysv)
+               vsyscall-flags += $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
 
        In the above example, vsyscall-flags will be assigned the option
        -Wl$(comma)--hash-style=sysv if it is supported by $(CC).
@@ -519,17 +550,17 @@ more details, with real examples.
        to the user why it stops.
 
     cc-cross-prefix
-       cc-cross-prefix is used to check if there exist a $(CC) in path with
+       cc-cross-prefix is used to check if there exists a $(CC) in path with
        one of the listed prefixes. The first prefix where there exist a
        prefix$(CC) in the PATH is returned - and if no prefix$(CC) is found
        then nothing is returned.
        Additional prefixes are separated by a single space in the
        call of cc-cross-prefix.
-       This functionality is usefull for architecture Makefile that try
-       to set CROSS_COMPILE to well know values but may have several
+       This functionality is useful for architecture Makefiles that try
+       to set CROSS_COMPILE to well-known values but may have several
        values to select between.
-       It is recommended only to try to set CROSS_COMPILE is it is a cross
-       build (host arch is different from target arch). And is CROSS_COMPILE
+       It is recommended only to try to set CROSS_COMPILE if it is a cross
+       build (host arch is different from target arch). And if CROSS_COMPILE
        is already set then leave it with the old value.
 
        Example:
@@ -540,6 +571,19 @@ more details, with real examples.
                        endif
                endif
 
+--- 3.12 $(LD) support functions
+
+    ld-option
+       ld-option is used to check if $(LD) supports the supplied option.
+       ld-option takes two options as arguments.
+       The second argument is an optional option that can be used if the
+       first option is not supported by $(LD).
+
+       Example:
+               #Makefile
+               LDFLAGS_vmlinux += $(call really-ld-option, -X)
+
+
 === 4 Host Program support
 
 Kbuild supports building executables on the host for use during the
@@ -1129,8 +1173,69 @@ When kbuild executes, the following steps are followed (roughly):
        The kbuild infrastructure for *lds file are used in several
        architecture-specific files.
 
+=== 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
+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__)
+
+Each relevant directory contain a file name "Kbuild" which specify the
+headers to be exported.
+See subsequent chapter for the syntax of the Kbuild file.
+
+       --- 7.1 header-y
+
+       header-y specify header files to be exported.
+
+               Example:
+                       #include/linux/Kbuild
+                       header-y += usb/
+                       header-y += aio_abi.h
+
+       The convention is to list one file per line and
+       preferably in alphabetic order.
+
+       header-y also specify which subdirectories to visit.
+       A subdirectory is identified by a trailing '/' which
+       can be seen in the example above for the usb subdirectory.
+
+       Subdirectories are visited before their parent directories.
+
+       --- 7.2 objhdr-y
+
+       objhdr-y specifies generated files to be exported.
+       Generated files are special as they need to be looked
+       up in another directory when doing 'make O=...' builds.
+
+               Example:
+                       #include/linux/Kbuild
+                       objhdr-y += version.h
+
+       --- 7.3 destination-y
+
+       When an architecture have a set of exported headers that needs to be
+       exported to a different directory destination-y is used.
+       destination-y specify the destination directory for all exported
+       headers in the file where it is present.
+
+               Example:
+                       #arch/xtensa/platforms/s6105/include/platform/Kbuild
+                       destination-y := include/linux
+
+       In the example above all exported headers in 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.
+
 
-=== 7 Kbuild Variables
+=== 8 Kbuild Variables
 
 The top Makefile exports the following variables:
 
@@ -1192,7 +1297,7 @@ The top Makefile exports the following variables:
        INSTALL_MOD_STRIP will used as the option(s) to the strip command.
 
 
-=== 8 Makefile language
+=== 9 Makefile language
 
 The kernel Makefiles are designed to be run with GNU Make.  The Makefiles
 use only the documented features of GNU Make, but they do use many
@@ -1211,14 +1316,14 @@ time the left-hand side is used.
 There are some cases where "=" is appropriate.  Usually, though, ":="
 is the right choice.
 
-=== 9 Credits
+=== 10 Credits
 
 Original version made by Michael Elizabeth Chastain, <mailto:mec@shout.net>
 Updates by Kai Germaschewski <kai@tp1.ruhr-uni-bochum.de>
 Updates by Sam Ravnborg <sam@ravnborg.org>
 Language QA by Jan Engelhardt <jengelh@gmx.de>
 
-=== 10 TODO
+=== 11 TODO
 
 - Describe how kbuild supports shipped files with _shipped.
 - Generating offset header files.