Fix some typoes, and update some Makefile excerpts in the
makefiles.txt file, so that the examples reflect actual existing code.

Signed-off-by: Robert P. J. Day <[EMAIL PROTECTED]>

---

  the biggest set of patches was to just replace out-of-date Makefile
snippets with existing snippets.


diff --git a/Documentation/kbuild/makefiles.txt 
b/Documentation/kbuild/makefiles.txt
index 7a77533..af6c798 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -53,7 +53,7 @@ The Makefiles have five parts:
        .config                 the kernel configuration file.
        arch/$(ARCH)/Makefile   the arch Makefile.
        scripts/Makefile.*      common rules etc. for all kbuild Makefiles.
-       kbuild Makefiles        there are about 500 of these.
+       kbuild Makefiles        there are about 1000 of these.

 The top Makefile reads the .config file, which comes from the kernel
 configuration process.
@@ -277,9 +277,9 @@ 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
+       The three flags listed above apply 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.
+       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.
@@ -287,9 +287,8 @@ more details, with real examples.
        ccflags-y specifies options for compiling C files with $(CC).

        Example:
-               # drivers/sound/emu10k1/Makefile
-               ccflags-y += -I$(obj)
-               ccflags-$(DEBUG) += -DEMU10K1_DEBUG
+               #arch/x86/boot/Makefile
+               $(obj)/bzImage: ccflags-y := -D__BIG_KERNEL__


        This variable is necessary because the top Makefile owns the
@@ -300,15 +299,15 @@ more details, with real examples.
        when compiling assembly language source.

        Example:
-               #arch/x86_64/kernel/Makefile
-               asflags-y := -traditional
+               #arch/x86/boot/Makefile
+               $(obj)/zImage:  asflags-y := $(SVGA_MODE) $(RAMDISK)


        ldflags-y is a string for per-directory options to $(LD).

        Example:
-               #arch/m68k/fpsp040/Makefile
-               ldflags-y := -x
+               #arch/h8300/Makefile
+               LDFLAGS += $(ldflags-y)

     CFLAGS_$@, AFLAGS_$@

@@ -398,9 +397,9 @@ more details, with real examples.

        Example:
                #arch/sh/Makefile
-               cflags-y += $(call as-option,-Wa$(comma)-isa=$(isa-y),)
+               isaflags-y := $(call as-option,-Wa$(comma)-isa=$(isa-y),)

-       In the above example, cflags-y will be assigned the option
+       In the above example, isaflags-y will be assigned the option
        -Wa$(comma)-isa=$(isa-y) if it is supported by $(CC).
        The second argument is optional, and if supplied will be used
        if first argument is not supported.
@@ -411,10 +410,13 @@ more details, with real examples.
        specified if first option are not supported.

        Example:
-               #arch/i386/kernel/Makefile
-               vsyscall-flags += $(call ld-option, 
-Wl$(comma)--hash-style=sysv)
+               #arch/x86/vdso/Makefile
+               vdso-flags = -fPIC -shared -Wl,-soname=linux-vdso.so.1 \
+                 $(call ld-option, -Wl$(comma)--hash-style=sysv) \
+                 -Wl,-z,max-page-size=4096 -Wl,-z,common-page-size=4096
+

-       In the above example, vsyscall-flags will be assigned the option
+       In the above example, vdso-flags will use the option
        -Wl$(comma)--hash-style=sysv if it is supported by $(CC).
        The second argument is optional, and if supplied will be used
        if first argument is not supported.
@@ -423,20 +425,19 @@ more details, with real examples.
        as-instr checks if the assembler reports a specific instruction
        and then outputs either option1 or option2
        C escapes are supported in the test instruction
-       Note: as-instr-option uses KBUILD_AFLAGS for $(AS) options

     cc-option
        cc-option is used to check if $(CC) supports a given option, and not
        supported to use an optional second option.

        Example:
-               #arch/i386/Makefile
-               cflags-y += $(call cc-option,-march=pentium-mmx,-march=i586)
+               #arch/x86/Makefile_64
+               cflags-y += $(call cc-option,-funit-at-a-time)

-       In the above example, cflags-y will be assigned the option
-       -march=pentium-mmx if supported by $(CC), otherwise -march=i586.
-       The second argument to cc-option is optional, and if omitted,
-       cflags-y will be assigned no value if first option is not supported.
+       In the above example, cflags-y will have appended to it the
+       option -funit-at-a-time if supported by $(CC).  The second
+       argument to cc-option is optional and, if omitted, will be
+       represented by no value if the first option is not supported.
        Note: cc-option uses KBUILD_CFLAGS for $(CC) options

    cc-option-yn
@@ -445,14 +446,16 @@ more details, with real examples.

        Example:
                #arch/ppc/Makefile
-               biarch := $(call cc-option-yn, -m32)
-               aflags-$(biarch) += -a32
-               cflags-$(biarch) += -m32
-
-       In the above example, $(biarch) is set to y if $(CC) supports the -m32
-       option. When $(biarch) equals 'y', the expanded variables $(aflags-y)
-       and $(cflags-y) will be assigned the values -a32 and -m32,
-       respectively.
+               HAS_BIARCH      := $(call cc-option-yn, -m32)
+               ifeq ($(HAS_BIARCH),y)
+               AS              := $(AS) -a32
+               LD              := $(LD) -m elf32ppc
+               CC              := $(CC) -m32
+               endif
+
+       In the above example, $(HAS_BIARCH) is set to y if $(CC) supports
+       the -m32 option, which subsequently affects the values of $(AS),
+       $(LD) and $(CC).
        Note: cc-option-yn uses KBUILD_CFLAGS for $(CC) options

     cc-option-align
@@ -464,7 +467,13 @@ more details, with real examples.
        gcc >= 3.00
                cc-option-align = -falign

-       Example:
+       The correct value is set automatically in scripts/Kbuild.include:
+               # cc-option-align
+               # Prefix align with either -falign or -malign
+               cc-option-align = $(subst -functions=0,,\
+                 $(call cc-option,-falign-functions=0,-malign-functions=0))
+
+       Example usage:
                KBUILD_CFLAGS += $(cc-option-align)-functions=4

        In the above example, the option -falign-functions=4 is used for
@@ -475,18 +484,16 @@ more details, with real examples.
        cc-version returns a numerical version of the $(CC) compiler version.
        The format is <major><minor> where both are two digits. So for example
        gcc 3.41 would return 0341.
-       cc-version is useful when a specific $(CC) version is faulty in one
-       area, for example -mregparm=3 was broken in some gcc versions
-       even though the option was accepted by gcc.

        Example:
-               #arch/i386/Makefile
-               cflags-y += $(shell \
-               if [ $(call cc-version) -ge 0300 ] ; then \
-                       echo "-mregparm=3"; fi ;)
+               #arch/ia64/Makefile
+               ifeq ($(call cc-version),0304)
+                       cflags-$(CONFIG_ITANIUM)        += -mtune=merced
+                       cflags-$(CONFIG_MCKINLEY)       += -mtune=mckinley
+               endif

-       In the above example, -mregparm=3 is only used for gcc version greater
-       than or equal to gcc 3.0.
+       In the above example, the "cflags" variable(s) will have some
+       specific options appended if gcc 3.4 is being used.

     cc-ifversion
        cc-ifversion tests the version of $(CC) and equals last argument if
@@ -494,10 +501,10 @@ more details, with real examples.

        Example:
                #fs/reiserfs/Makefile
-               ccflags-y := $(call cc-ifversion, -lt, 0402, -O1)
+               EXTRA_CFLAGS := $(call cc-ifversion, -lt, 0400, -O1)

-       In this example, ccflags-y will be assigned the value -O1 if the
-       $(CC) version is less than 4.2.
+       In this example, EXTRA_CFLAGS will be assigned the value -O1 if the
+       $(CC) version is less than 4.0.
        cc-ifversion takes all the shell operators:
        -eq, -ne, -lt, -le, -gt, and -ge
        The third parameter may be a text as in this example, but it may also
@@ -509,12 +516,16 @@ more details, with real examples.
        cc-fullversion points out a more specific version than cc-version does.

        Example:
-               #arch/powerpc/Makefile
-               $(Q)if test "$(call cc-fullversion)" = "040200" ; then \
+               @if test "$(call cc-fullversion)" = "040200" \
+                   && test "x${CONFIG_MODULES}${CONFIG_PPC64}" = "xyy" ; then \
                        echo -n '*** GCC-4.2.0 cannot compile the 64-bit 
powerpc ' ; \
+                       echo 'kernel with modules enabled.' ; \
+                       echo -n '*** Please use a different GCC version or ' ; \
+                       echo 'disable kernel modules' ; \
                        false ; \
                fi

+
        In this example for a specific GCC version the build will error out 
explaining
        to the user why it stops.

@@ -533,11 +544,14 @@ more details, with real examples.
        is already set then leave it with the old value.

        Example:
-               #arch/m68k/Makefile
+               #arch/mips/Makefile
                ifneq ($(SUBARCH),$(ARCH))
-                       ifeq ($(CROSS_COMPILE),)
-                              CROSS_COMPILE := $(call cc-cross-prefix, 
m68k-linux-gnu-)
-                       endif
+                 ifeq ($(CROSS_COMPILE),)
+                   CROSS_COMPILE := $(call cc-cross-prefix,
+                     $(tool-archpref)-linux-
+                     $(tool-archpref)-linux-gnu-
+                     $(tool-archpref)-unknown-linux-gnu-)
+                 endif
                endif

 === 4 Host Program support
========================================================================
Robert P. J. Day
Linux Consulting, Training and Annoying Kernel Pedantry
Waterloo, Ontario, CANADA

http://crashcourse.ca
========================================================================
-
To unsubscribe from this list: send the line "unsubscribe linux-kbuild" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to