X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=Documentation%2Fkbuild%2Fmakefiles.txt;h=51104f9194a54feb64058f4b8f35f3b4d7cbc88f;hb=52435bfc665716fdf9a02f0d08e7ce50ddb9bf45;hp=f4779cd1542fd5ffadcfb6a5075695d4bcc7b44f;hpb=222d394d30e74bb7a2a65029fcea68107b0d0eb6;p=~andy%2Flinux diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt index f4779cd1542..51104f9194a 100644 --- a/Documentation/kbuild/makefiles.txt +++ b/Documentation/kbuild/makefiles.txt @@ -276,40 +276,39 @@ more details, with real examples. --- 3.7 Compilation flags - EXTRA_CFLAGS, EXTRA_AFLAGS, EXTRA_LDFLAGS + 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. + 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. - All the EXTRA_ variables apply only to the kbuild makefile - where they are assigned. The EXTRA_ variables apply to all - commands executed in the kbuild makefile. - - $(EXTRA_CFLAGS) specifies options for compiling C files with - $(CC). + ccflags-y specifies options for compiling C files with $(CC). Example: # drivers/sound/emu10k1/Makefile - EXTRA_CFLAGS += -I$(obj) - ifdef DEBUG - EXTRA_CFLAGS += -DEMU10K1_DEBUG - endif + ccflags-y += -I$(obj) + ccflags-$(DEBUG) += -DEMU10K1_DEBUG This variable is necessary because the top Makefile owns the variable $(KBUILD_CFLAGS) and uses it for compilation flags for the entire tree. - $(EXTRA_AFLAGS) is a similar string for per-directory options + asflags-y is a similar string for per-directory options when compiling assembly language source. Example: #arch/x86_64/kernel/Makefile - EXTRA_AFLAGS := -traditional + asflags-y := -traditional - $(EXTRA_LDFLAGS) is a string for per-directory options to $(LD). + ldflags-y is a string for per-directory options to $(LD). Example: #arch/m68k/fpsp040/Makefile - EXTRA_LDFLAGS := -x + ldflags-y := -x CFLAGS_$@, AFLAGS_$@ @@ -384,6 +383,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 @@ -495,9 +508,9 @@ more details, with real examples. Example: #fs/reiserfs/Makefile - EXTRA_CFLAGS := $(call cc-ifversion, -lt, 0402, -O1) + ccflags-y := $(call cc-ifversion, -lt, 0402, -O1) - In this example, EXTRA_CFLAGS will be assigned the value -O1 if the + In this example, ccflags-y will be assigned the value -O1 if the $(CC) version is less than 4.2. cc-ifversion takes all the shell operators: -eq, -ne, -lt, -le, -gt, and -ge @@ -519,6 +532,28 @@ more details, with real examples. In this example for a specific GCC version the build will error out explaining to the user why it stops. + cc-cross-prefix + 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 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 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: + #arch/m68k/Makefile + ifneq ($(SUBARCH),$(ARCH)) + ifeq ($(CROSS_COMPILE),) + CROSS_COMPILE := $(call cc-cross-prefix, m68k-linux-gnu-) + endif + endif + === 4 Host Program support Kbuild supports building executables on the host for use during the @@ -783,7 +818,7 @@ When kbuild executes, the following steps are followed (roughly): Example: #arch/s390/Makefile LDFLAGS := -m elf_s390 - Note: EXTRA_LDFLAGS can be used to further customise + Note: ldflags-y can be used to further customise the flags used. See chapter 3.7. LDFLAGS_MODULE Options for $(LD) when linking modules @@ -1099,8 +1134,8 @@ When kbuild executes, the following steps are followed (roughly): specified options when building the target vmlinux.lds. When building the *.lds target, kbuild uses the variables: - CPPFLAGS : Set in top-level Makefile - EXTRA_CPPFLAGS : May be set in the kbuild makefile + KBUILD_CPPFLAGS : Set in top-level Makefile + cppflags-y : May be set in the kbuild makefile CPPFLAGS_$(@F) : Target specific flags. Note that the full filename is used in this assignment.