···1033103310341034 Example:10351035 #arch/i386/Makefile10361036- GCC_VERSION := $(call cc-version)10371036 cflags-y += $(shell \10381038- if [ $(GCC_VERSION) -ge 0300 ] ; then echo "-mregparm=3"; fi ;)10371037+ if [ $(call cc-version) -ge 0300 ] ; then \10381038+ echo "-mregparm=3"; fi ;)1039103910401040 In the above example -mregparm=3 is only used for gcc version greater10411041 than or equal to gcc 3.0.
···141141142142export srctree objtree VPATH TOPDIR143143144144-nullstring :=145145-space := $(nullstring) # end of line146146-147147-# Take the contents of any files called localversion* and the config148148-# variable CONFIG_LOCALVERSION and append them to KERNELRELEASE. Be149149-# careful not to include files twice if building in the source150150-# directory. LOCALVERSION from the command line override all of this151151-152152-localver := $(objtree)/localversion* $(srctree)/localversion*153153-localver := $(sort $(wildcard $(localver)))154154-# skip backup files (containing '~')155155-localver := $(foreach f, $(localver), $(if $(findstring ~, $(f)),,$(f)))156156-157157-LOCALVERSION = $(subst $(space),, \158158- $(shell cat /dev/null $(localver)) \159159- $(patsubst "%",%,$(CONFIG_LOCALVERSION)))160160-161161-KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)$(LOCALVERSION)162144163145# SUBARCH tells the usermode build what the underlying arch is. That is set164146# first, and if a usermode build is happening, the "ARCH=um" on the command···335353 -ffreestanding336354AFLAGS := -D__ASSEMBLY__337355338338-export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION LOCALVERSION KERNELRELEASE \356356+# Read KERNELRELEASE from .kernelrelease (if it exists)357357+KERNELRELEASE = $(shell cat .kernelrelease 2> /dev/null)358358+359359+export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE \339360 ARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \340361 CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \341362 HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS···535550# INSTALL_PATH specifies where to place the updated kernel and system map536551# images. Default is /boot, but you can set it to other values537552export INSTALL_PATH ?= /boot538538-539539-# If CONFIG_LOCALVERSION_AUTO is set, we automatically perform some tests540540-# and try to determine if the current source tree is a release tree, of any sort,541541-# or if is a pure development tree.542542-#543543-# A 'release tree' is any tree with a git TAG associated544544-# with it. The primary goal of this is to make it safe for a native545545-# git/CVS/SVN user to build a release tree (i.e, 2.6.9) and also to546546-# continue developing against the current Linus tree, without having the Linus547547-# tree overwrite the 2.6.9 tree when installed.548548-#549549-# Currently, only git is supported.550550-# Other SCMs can edit scripts/setlocalversion and add the appropriate551551-# checks as needed.552552-553553-554554-ifdef CONFIG_LOCALVERSION_AUTO555555- localversion-auto := $(shell $(PERL) $(srctree)/scripts/setlocalversion $(srctree))556556- LOCALVERSION := $(LOCALVERSION)$(localversion-auto)557557-endif558553559554#560555# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory···747782$(vmlinux-dirs): prepare scripts748783 $(Q)$(MAKE) $(build)=$@749784785785+# Build the kernel release string786786+# The KERNELRELEASE is stored in a file named .kernelrelease787787+# to be used when executing for example make install or make modules_install788788+#789789+# Take the contents of any files called localversion* and the config790790+# variable CONFIG_LOCALVERSION and append them to KERNELRELEASE.791791+# LOCALVERSION from the command line override all of this792792+793793+nullstring :=794794+space := $(nullstring) # end of line795795+796796+___localver = $(objtree)/localversion* $(srctree)/localversion*797797+__localver = $(sort $(wildcard $(___localver)))798798+# skip backup files (containing '~')799799+_localver = $(foreach f, $(__localver), $(if $(findstring ~, $(f)),,$(f)))800800+801801+localver = $(subst $(space),, \802802+ $(shell cat /dev/null $(_localver)) \803803+ $(patsubst "%",%,$(CONFIG_LOCALVERSION)))804804+805805+# If CONFIG_LOCALVERSION_AUTO is set scripts/setlocalversion is called806806+# and if the SCM is know a tag from the SCM is appended.807807+# The appended tag is determinded by the SCM used.808808+#809809+# Currently, only git is supported.810810+# Other SCMs can edit scripts/setlocalversion and add the appropriate811811+# checks as needed.812812+ifdef CONFIG_LOCALVERSION_AUTO813813+ _localver-auto = $(shell $(CONFIG_SHELL) \814814+ $(srctree)/scripts/setlocalversion $(srctree))815815+ localver-auto = $(LOCALVERSION)$(_localver-auto)816816+endif817817+818818+localver-full = $(localver)$(localver-auto)819819+820820+# Store (new) KERNELRELASE string in .kernelrelease821821+kernelrelease = \822822+ $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)$(localver-full)823823+.kernelrelease: FORCE824824+ $(Q)rm -f .kernelrelease825825+ $(Q)echo $(kernelrelease) > .kernelrelease826826+ $(Q)echo " Building kernel $(kernelrelease)"827827+828828+750829# Things we need to do before we recursively start building the kernel751830# or the modules are listed in "prepare".752831# A multi level approach is used. prepareN is processed before prepareN-1.···807798# and if so do:808799# 1) Check that make has not been executed in the kernel src $(srctree)809800# 2) Create the include2 directory, used for the second asm symlink810810-811811-prepare3:801801+prepare3: .kernelrelease812802ifneq ($(KBUILD_SRC),)813803 @echo ' Using $(srctree) as source for kernel'814804 $(Q)if [ -f $(srctree)/.config ]; then \···992984993985# Directories & files removed with 'make mrproper'994986MRPROPER_DIRS += include/config include2995995-MRPROPER_FILES += .config .config.old include/asm .version \987987+MRPROPER_FILES += .config .config.old include/asm .version .old_version \996988 include/linux/autoconf.h include/linux/version.h \997997- Module.symvers tags TAGS cscope*989989+ .kernelrelease Module.symvers tags TAGS cscope*998990999991# clean - Delete most, but leave enough to build external modules1000992#···10801072 @echo ' tags/TAGS - Generate tags file for editors'10811073 @echo ' cscope - Generate cscope index'10821074 @echo ' kernelrelease - Output the release version string'10751075+ @echo ' kernelversion - Output the version stored in Makefile'10831076 @echo ''10841077 @echo 'Static analysers'10851078 @echo ' buildcheck - List dangling references to vmlinux discarded sections'···1302129313031294kernelrelease:13041295 @echo $(KERNELRELEASE)12961296+kernelversion:12971297+ @echo $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)1305129813061299# FIXME Should go into a make.lib or something 13071300# ===========================================================================
+2-2
arch/frv/boot/Makefile
···5757# installation5858#5959install: $(CONFIGURE) Image6060- sh ./install.sh $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) Image $(TOPDIR)/System.map "$(INSTALL_PATH)"6060+ sh ./install.sh $(KERNELRELEASE) Image $(TOPDIR)/System.map "$(INSTALL_PATH)"61616262zinstall: $(CONFIGURE) zImage6363- sh ./install.sh $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) zImage $(TOPDIR)/System.map "$(INSTALL_PATH)"6363+ sh ./install.sh $(KERNELRELEASE) zImage $(TOPDIR)/System.map "$(INSTALL_PATH)"64646565#6666# miscellany
+6-4
arch/i386/Makefile
···3737# CPU-specific tuning. Anything which can be shared with UML should go here.3838include $(srctree)/arch/i386/Makefile.cpu39394040-cflags-$(CONFIG_REGPARM) += -mregparm=34040+# -mregparm=3 works ok on gcc-3.0 and later4141+#4242+cflags-$(CONFIG_REGPARM) += $(shell if [ $(call cc-version) -ge 0300 ] ; then \4343+ echo "-mregparm=3"; fi ;)41444245# Disable unit-at-a-time mode, it makes gcc use a lot more stack4346# due to the lack of sharing of stacklots.···103100boot := arch/i386/boot104101105102.PHONY: zImage bzImage compressed zlilo bzlilo \106106- zdisk bzdisk fdimage fdimage144 fdimage288 install kernel_install103103+ zdisk bzdisk fdimage fdimage144 fdimage288 install107104108105all: bzImage109106···125122fdimage fdimage144 fdimage288: vmlinux126123 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) $@127124128128-install: vmlinux129129-install kernel_install:125125+install:130126 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) install131127132128archclean:
+1-1
arch/i386/boot/Makefile
···100100 cp System.map $(INSTALL_PATH)/101101 if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi102102103103-install: $(BOOTIMAGE)103103+install:104104 sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $< System.map "$(INSTALL_PATH)"
+14
arch/i386/boot/install.sh
···1919# $4 - default install path (blank if root directory)2020#21212222+verify () {2323+ if [ ! -f "$1" ]; then2424+ echo "" 1>&22525+ echo " *** Missing file: $1" 1>&22626+ echo ' *** You need to run "make" before "make install".' 1>&22727+ echo "" 1>&22828+ exit 12929+ fi3030+}3131+3232+# Make sure the files actually exist3333+verify "$2"3434+verify "$3"3535+2236# User may have a custom install script23372438if [ -x ~/bin/${CROSS_COMPILE}installkernel ]; then exec ~/bin/${CROSS_COMPILE}installkernel "$@"; fi
···7676CHECKFLAGS += -m$(SZ) -D__powerpc__ -D__powerpc$(SZ)__77777878ifeq ($(CONFIG_PPC64),y)7979-GCC_VERSION := $(call cc-version)8080-GCC_BROKEN_VEC := $(shell if [ $(GCC_VERSION) -lt 0400 ] ; then echo "y"; fi)7979+GCC_BROKEN_VEC := $(shell if [ $(call cc-version) -lt 0400 ] ; then echo "y"; fi)81808281ifeq ($(CONFIG_POWER4_ONLY),y)8382ifeq ($(CONFIG_ALTIVEC),y)···188189# Ensure this is binutils 2.12.1 (or 2.12.90.0.7) or later for altivec189190# instructions.190191# gcc-3.4 and binutils-2.14 are a fatal combination.191191-GCC_VERSION := $(call cc-version)192192193193checkbin:194194- @if test "$(GCC_VERSION)" = "0304" ; then \194194+ @if test "$(call cc-version)" = "0304" ; then \195195 if ! /bin/echo mftb 5 | $(AS) -v -mppc -many -o $(TOUT) >/dev/null 2>&1 ; then \196196 echo -n '*** ${VERSION}.${PATCHLEVEL} kernels no longer build '; \197197 echo 'correctly with gcc-3.4 and your version of binutils.'; \
+1-2
arch/ppc/Makefile
···128128# Ensure this is binutils 2.12.1 (or 2.12.90.0.7) or later for altivec129129# instructions.130130# gcc-3.4 and binutils-2.14 are a fatal combination.131131-GCC_VERSION := $(call cc-version)132131133132checkbin:134134- @if test "$(GCC_VERSION)" = "0304" ; then \133133+ @if test "$(call cc-version)" = "0304" ; then \135134 if ! /bin/echo mftb 5 | $(AS) -v -mppc -many -o $(TOUT) >/dev/null 2>&1 ; then \136135 echo -n '*** ${VERSION}.${PATCHLEVEL} kernels no longer build '; \137136 echo 'correctly with gcc-3.4 and your version of binutils.'; \
···9898 cp System.map $(INSTALL_PATH)/9999 if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi100100101101-install: $(BOOTIMAGE)101101+install:102102 sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)"
+1-39
arch/x86_64/boot/install.sh
···11#!/bin/sh22-#33-# arch/x86_64/boot/install.sh44-#55-# This file is subject to the terms and conditions of the GNU General Public66-# License. See the file "COPYING" in the main directory of this archive77-# for more details.88-#99-# Copyright (C) 1995 by Linus Torvalds1010-#1111-# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin1212-#1313-# "make install" script for i386 architecture1414-#1515-# Arguments:1616-# $1 - kernel version1717-# $2 - kernel image file1818-# $3 - kernel map file1919-# $4 - default install path (blank if root directory)2020-#2121-2222-# User may have a custom install script2323-2424-if [ -x ~/bin/${CROSS_COMPILE}installkernel ]; then exec ~/bin/${CROSS_COMPILE}installkernel "$@"; fi2525-if [ -x /sbin/${CROSS_COMPILE}installkernel ]; then exec /sbin/${CROSS_COMPILE}installkernel "$@"; fi2626-2727-# Default install - same as make zlilo2828-2929-if [ -f $4/vmlinuz ]; then3030- mv $4/vmlinuz $4/vmlinuz.old3131-fi3232-3333-if [ -f $4/System.map ]; then3434- mv $4/System.map $4/System.old3535-fi3636-3737-cat $2 > $4/vmlinuz3838-cp $3 $4/System.map3939-4040-if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi22+. $srctree/arch/i386/boot/install.sh
+6
fs/xfs/Kbuild
···11+#22+# The xfs people like to share Makefile with 2.6 and 2.4.33+# Utilise file named Kbuild file which has precedence over Makefile.44+#55+66+include $(srctree)/$(obj)/Makefile-linux-2.6
+9-4
scripts/Kbuild.include
···3344# Convinient variables55comma := ,66+squote := '67empty :=78space := $(empty) $(empty)89···1110# The temporary file to save gcc -MD generated dependencies must not1211# contain a comma1312depfile = $(subst $(comma),_,$(@D)/.$(@F).d)1313+1414+###1515+# Escape single quote for use in echo statements1616+escsq = $(subst $(squote),'\$(squote)',$1)14171518###1619# filechk is used to check if the content of a generated file is updated.···52475348# If quiet is set, only print short version of command5449cmd = @$(if $($(quiet)cmd_$(1)),\5555- echo ' $(subst ','\'',$($(quiet)cmd_$(1)))' &&) $(cmd_$(1))5050+ echo ' $(call escsq,$($(quiet)cmd_$(1)))' &&) $(cmd_$(1))56515752# Add $(obj)/ for paths that is not absolute5853objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o)))···73687469# echo command. Short version is $(quiet) equals quiet, otherwise full command7570echo-cmd = $(if $($(quiet)cmd_$(1)), \7676- echo ' $(subst ','\'',$($(quiet)cmd_$(1)))';)7171+ echo ' $(call escsq,$($(quiet)cmd_$(1)))';)77727873# function to only execute the passed command if necessary7974# >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file···8378 @set -e; \8479 $(echo-cmd) \8580 $(cmd_$(1)); \8686- echo 'cmd_$@ := $(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).cmd)8181+ echo 'cmd_$@ := $(subst $$,$$$$,$(call escsq,$(cmd_$(1))))' > $(@D)/.$(@F).cmd)87828883# execute the command and also postprocess generated .d dependencies8984# file···9287 @set -e; \9388 $(echo-cmd) \9489 $(cmd_$(1)); \9595- scripts/basic/fixdep $(depfile) $@ '$(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).tmp; \9090+ scripts/basic/fixdep $(depfile) $@ '$(subst $$,$$$$,$(call escsq,$(cmd_$(1))))' > $(@D)/.$(@F).tmp; \9691 rm -f $(depfile); \9792 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd)9893