···10331034 Example:1035 #arch/i386/Makefile1036- GCC_VERSION := $(call cc-version)1037 cflags-y += $(shell \1038- if [ $(GCC_VERSION) -ge 0300 ] ; then echo "-mregparm=3"; fi ;)010391040 In the above example -mregparm=3 is only used for gcc version greater1041 than or equal to gcc 3.0.
···10331034 Example:1035 #arch/i386/Makefile01036 cflags-y += $(shell \1037+ if [ $(call cc-version) -ge 0300 ] ; then \1038+ echo "-mregparm=3"; fi ;)10391040 In the above example -mregparm=3 is only used for gcc version greater1041 than or equal to gcc 3.0.
···141142export srctree objtree VPATH TOPDIR143144-nullstring :=145-space := $(nullstring) # end of line146-147-# Take the contents of any files called localversion* and the config148-# variable CONFIG_LOCALVERSION and append them to KERNELRELEASE. Be149-# careful not to include files twice if building in the source150-# directory. LOCALVERSION from the command line override all of this151-152-localver := $(objtree)/localversion* $(srctree)/localversion*153-localver := $(sort $(wildcard $(localver)))154-# skip backup files (containing '~')155-localver := $(foreach f, $(localver), $(if $(findstring ~, $(f)),,$(f)))156-157-LOCALVERSION = $(subst $(space),, \158- $(shell cat /dev/null $(localver)) \159- $(patsubst "%",%,$(CONFIG_LOCALVERSION)))160-161-KERNELRELEASE=$(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)$(LOCALVERSION)162163# SUBARCH tells the usermode build what the underlying arch is. That is set164# first, and if a usermode build is happening, the "ARCH=um" on the command···335 -ffreestanding336AFLAGS := -D__ASSEMBLY__337338-export VERSION PATCHLEVEL SUBLEVEL EXTRAVERSION LOCALVERSION KERNELRELEASE \000339 ARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \340 CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \341 HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS···535# INSTALL_PATH specifies where to place the updated kernel and system map536# images. Default is /boot, but you can set it to other values537export INSTALL_PATH ?= /boot538-539-# If CONFIG_LOCALVERSION_AUTO is set, we automatically perform some tests540-# and try to determine if the current source tree is a release tree, of any sort,541-# or if is a pure development tree.542-#543-# A 'release tree' is any tree with a git TAG associated544-# with it. The primary goal of this is to make it safe for a native545-# git/CVS/SVN user to build a release tree (i.e, 2.6.9) and also to546-# continue developing against the current Linus tree, without having the Linus547-# tree overwrite the 2.6.9 tree when installed.548-#549-# Currently, only git is supported.550-# Other SCMs can edit scripts/setlocalversion and add the appropriate551-# checks as needed.552-553-554-ifdef CONFIG_LOCALVERSION_AUTO555- localversion-auto := $(shell $(PERL) $(srctree)/scripts/setlocalversion $(srctree))556- LOCALVERSION := $(LOCALVERSION)$(localversion-auto)557-endif558559#560# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory···747$(vmlinux-dirs): prepare scripts748 $(Q)$(MAKE) $(build)=$@74900000000000000000000000000000000000000000000750# Things we need to do before we recursively start building the kernel751# or the modules are listed in "prepare".752# A multi level approach is used. prepareN is processed before prepareN-1.···807# and if so do:808# 1) Check that make has not been executed in the kernel src $(srctree)809# 2) Create the include2 directory, used for the second asm symlink810-811-prepare3:812ifneq ($(KBUILD_SRC),)813 @echo ' Using $(srctree) as source for kernel'814 $(Q)if [ -f $(srctree)/.config ]; then \···992993# Directories & files removed with 'make mrproper'994MRPROPER_DIRS += include/config include2995-MRPROPER_FILES += .config .config.old include/asm .version \996 include/linux/autoconf.h include/linux/version.h \997- Module.symvers tags TAGS cscope*998999# clean - Delete most, but leave enough to build external modules1000#···1080 @echo ' tags/TAGS - Generate tags file for editors'1081 @echo ' cscope - Generate cscope index'1082 @echo ' kernelrelease - Output the release version string'01083 @echo ''1084 @echo 'Static analysers'1085 @echo ' buildcheck - List dangling references to vmlinux discarded sections'···13021303kernelrelease:1304 @echo $(KERNELRELEASE)0013051306# FIXME Should go into a make.lib or something 1307# ===========================================================================
···141142export srctree objtree VPATH TOPDIR143000000000000000000144145# SUBARCH tells the usermode build what the underlying arch is. That is set146# first, and if a usermode build is happening, the "ARCH=um" on the command···353 -ffreestanding354AFLAGS := -D__ASSEMBLY__355356+# Read KERNELRELEASE from .kernelrelease (if it exists)357+KERNELRELEASE = $(shell cat .kernelrelease 2> /dev/null)358+359+export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE \360 ARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC \361 CPP AR NM STRIP OBJCOPY OBJDUMP MAKE AWK GENKSYMS PERL UTS_MACHINE \362 HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS···550# INSTALL_PATH specifies where to place the updated kernel and system map551# images. Default is /boot, but you can set it to other values552export INSTALL_PATH ?= /boot00000000000000000000553554#555# INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory···782$(vmlinux-dirs): prepare scripts783 $(Q)$(MAKE) $(build)=$@784785+# Build the kernel release string786+# The KERNELRELEASE is stored in a file named .kernelrelease787+# to be used when executing for example make install or make modules_install788+#789+# Take the contents of any files called localversion* and the config790+# variable CONFIG_LOCALVERSION and append them to KERNELRELEASE.791+# LOCALVERSION from the command line override all of this792+793+nullstring :=794+space := $(nullstring) # end of line795+796+___localver = $(objtree)/localversion* $(srctree)/localversion*797+__localver = $(sort $(wildcard $(___localver)))798+# skip backup files (containing '~')799+_localver = $(foreach f, $(__localver), $(if $(findstring ~, $(f)),,$(f)))800+801+localver = $(subst $(space),, \802+ $(shell cat /dev/null $(_localver)) \803+ $(patsubst "%",%,$(CONFIG_LOCALVERSION)))804+805+# If CONFIG_LOCALVERSION_AUTO is set scripts/setlocalversion is called806+# and if the SCM is know a tag from the SCM is appended.807+# The appended tag is determinded by the SCM used.808+#809+# Currently, only git is supported.810+# Other SCMs can edit scripts/setlocalversion and add the appropriate811+# checks as needed.812+ifdef CONFIG_LOCALVERSION_AUTO813+ _localver-auto = $(shell $(CONFIG_SHELL) \814+ $(srctree)/scripts/setlocalversion $(srctree))815+ localver-auto = $(LOCALVERSION)$(_localver-auto)816+endif817+818+localver-full = $(localver)$(localver-auto)819+820+# Store (new) KERNELRELASE string in .kernelrelease821+kernelrelease = \822+ $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)$(localver-full)823+.kernelrelease: FORCE824+ $(Q)rm -f .kernelrelease825+ $(Q)echo $(kernelrelease) > .kernelrelease826+ $(Q)echo " Building kernel $(kernelrelease)"827+828+829# Things we need to do before we recursively start building the kernel830# or the modules are listed in "prepare".831# A multi level approach is used. prepareN is processed before prepareN-1.···798# and if so do:799# 1) Check that make has not been executed in the kernel src $(srctree)800# 2) Create the include2 directory, used for the second asm symlink801+prepare3: .kernelrelease0802ifneq ($(KBUILD_SRC),)803 @echo ' Using $(srctree) as source for kernel'804 $(Q)if [ -f $(srctree)/.config ]; then \···984985# Directories & files removed with 'make mrproper'986MRPROPER_DIRS += include/config include2987+MRPROPER_FILES += .config .config.old include/asm .version .old_version \988 include/linux/autoconf.h include/linux/version.h \989+ .kernelrelease Module.symvers tags TAGS cscope*990991# clean - Delete most, but leave enough to build external modules992#···1072 @echo ' tags/TAGS - Generate tags file for editors'1073 @echo ' cscope - Generate cscope index'1074 @echo ' kernelrelease - Output the release version string'1075+ @echo ' kernelversion - Output the version stored in Makefile'1076 @echo ''1077 @echo 'Static analysers'1078 @echo ' buildcheck - List dangling references to vmlinux discarded sections'···12931294kernelrelease:1295 @echo $(KERNELRELEASE)1296+kernelversion:1297+ @echo $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION)12981299# FIXME Should go into a make.lib or something 1300# ===========================================================================
+2-2
arch/frv/boot/Makefile
···57# installation58#59install: $(CONFIGURE) Image60- sh ./install.sh $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) Image $(TOPDIR)/System.map "$(INSTALL_PATH)"6162zinstall: $(CONFIGURE) zImage63- sh ./install.sh $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)$(EXTRAVERSION) zImage $(TOPDIR)/System.map "$(INSTALL_PATH)"6465#66# miscellany
···57# installation58#59install: $(CONFIGURE) Image60+ sh ./install.sh $(KERNELRELEASE) Image $(TOPDIR)/System.map "$(INSTALL_PATH)"6162zinstall: $(CONFIGURE) zImage63+ sh ./install.sh $(KERNELRELEASE) zImage $(TOPDIR)/System.map "$(INSTALL_PATH)"6465#66# miscellany
+6-4
arch/i386/Makefile
···37# CPU-specific tuning. Anything which can be shared with UML should go here.38include $(srctree)/arch/i386/Makefile.cpu3940-cflags-$(CONFIG_REGPARM) += -mregparm=30004142# Disable unit-at-a-time mode, it makes gcc use a lot more stack43# due to the lack of sharing of stacklots.···103boot := arch/i386/boot104105.PHONY: zImage bzImage compressed zlilo bzlilo \106- zdisk bzdisk fdimage fdimage144 fdimage288 install kernel_install107108all: bzImage109···125fdimage fdimage144 fdimage288: vmlinux126 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) $@127128-install: vmlinux129-install kernel_install:130 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) install131132archclean:
···37# CPU-specific tuning. Anything which can be shared with UML should go here.38include $(srctree)/arch/i386/Makefile.cpu3940+# -mregparm=3 works ok on gcc-3.0 and later41+#42+cflags-$(CONFIG_REGPARM) += $(shell if [ $(call cc-version) -ge 0300 ] ; then \43+ echo "-mregparm=3"; fi ;)4445# Disable unit-at-a-time mode, it makes gcc use a lot more stack46# due to the lack of sharing of stacklots.···100boot := arch/i386/boot101102.PHONY: zImage bzImage compressed zlilo bzlilo \103+ zdisk bzdisk fdimage fdimage144 fdimage288 install104105all: bzImage106···122fdimage fdimage144 fdimage288: vmlinux123 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) $@124125+install:0126 $(Q)$(MAKE) $(build)=$(boot) BOOTIMAGE=$(KBUILD_IMAGE) install127128archclean:
+1-1
arch/i386/boot/Makefile
···100 cp System.map $(INSTALL_PATH)/101 if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi102103-install: $(BOOTIMAGE)104 sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $< System.map "$(INSTALL_PATH)"
···100 cp System.map $(INSTALL_PATH)/101 if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi102103+install:104 sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $< System.map "$(INSTALL_PATH)"
+14
arch/i386/boot/install.sh
···19# $4 - default install path (blank if root directory)20#210000000000000022# User may have a custom install script2324if [ -x ~/bin/${CROSS_COMPILE}installkernel ]; then exec ~/bin/${CROSS_COMPILE}installkernel "$@"; fi
···19# $4 - default install path (blank if root directory)20#2122+verify () {23+ if [ ! -f "$1" ]; then24+ echo "" 1>&225+ echo " *** Missing file: $1" 1>&226+ echo ' *** You need to run "make" before "make install".' 1>&227+ echo "" 1>&228+ exit 129+ fi30+}31+32+# Make sure the files actually exist33+verify "$2"34+verify "$3"35+36# User may have a custom install script3738if [ -x ~/bin/${CROSS_COMPILE}installkernel ]; then exec ~/bin/${CROSS_COMPILE}installkernel "$@"; fi
···76CHECKFLAGS += -m$(SZ) -D__powerpc__ -D__powerpc$(SZ)__7778ifeq ($(CONFIG_PPC64),y)79-GCC_VERSION := $(call cc-version)80-GCC_BROKEN_VEC := $(shell if [ $(GCC_VERSION) -lt 0400 ] ; then echo "y"; fi)8182ifeq ($(CONFIG_POWER4_ONLY),y)83ifeq ($(CONFIG_ALTIVEC),y)···188# Ensure this is binutils 2.12.1 (or 2.12.90.0.7) or later for altivec189# instructions.190# gcc-3.4 and binutils-2.14 are a fatal combination.191-GCC_VERSION := $(call cc-version)192193checkbin:194- @if test "$(GCC_VERSION)" = "0304" ; then \195 if ! /bin/echo mftb 5 | $(AS) -v -mppc -many -o $(TOUT) >/dev/null 2>&1 ; then \196 echo -n '*** ${VERSION}.${PATCHLEVEL} kernels no longer build '; \197 echo 'correctly with gcc-3.4 and your version of binutils.'; \
···76CHECKFLAGS += -m$(SZ) -D__powerpc__ -D__powerpc$(SZ)__7778ifeq ($(CONFIG_PPC64),y)79+GCC_BROKEN_VEC := $(shell if [ $(call cc-version) -lt 0400 ] ; then echo "y"; fi)08081ifeq ($(CONFIG_POWER4_ONLY),y)82ifeq ($(CONFIG_ALTIVEC),y)···189# Ensure this is binutils 2.12.1 (or 2.12.90.0.7) or later for altivec190# instructions.191# gcc-3.4 and binutils-2.14 are a fatal combination.0192193checkbin:194+ @if test "$(call cc-version)" = "0304" ; then \195 if ! /bin/echo mftb 5 | $(AS) -v -mppc -many -o $(TOUT) >/dev/null 2>&1 ; then \196 echo -n '*** ${VERSION}.${PATCHLEVEL} kernels no longer build '; \197 echo 'correctly with gcc-3.4 and your version of binutils.'; \
+1-2
arch/ppc/Makefile
···128# Ensure this is binutils 2.12.1 (or 2.12.90.0.7) or later for altivec129# instructions.130# gcc-3.4 and binutils-2.14 are a fatal combination.131-GCC_VERSION := $(call cc-version)132133checkbin:134- @if test "$(GCC_VERSION)" = "0304" ; then \135 if ! /bin/echo mftb 5 | $(AS) -v -mppc -many -o $(TOUT) >/dev/null 2>&1 ; then \136 echo -n '*** ${VERSION}.${PATCHLEVEL} kernels no longer build '; \137 echo 'correctly with gcc-3.4 and your version of binutils.'; \
···128# Ensure this is binutils 2.12.1 (or 2.12.90.0.7) or later for altivec129# instructions.130# gcc-3.4 and binutils-2.14 are a fatal combination.0131132checkbin:133+ @if test "$(call cc-version)" = "0304" ; then \134 if ! /bin/echo mftb 5 | $(AS) -v -mppc -many -o $(TOUT) >/dev/null 2>&1 ; then \135 echo -n '*** ${VERSION}.${PATCHLEVEL} kernels no longer build '; \136 echo 'correctly with gcc-3.4 and your version of binutils.'; \
···98 cp System.map $(INSTALL_PATH)/99 if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi100101-install: $(BOOTIMAGE)102 sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)"
···98 cp System.map $(INSTALL_PATH)/99 if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi100101+install:102 sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)"
+1-39
arch/x86_64/boot/install.sh
···1#!/bin/sh2-#3-# arch/x86_64/boot/install.sh4-#5-# This file is subject to the terms and conditions of the GNU General Public6-# License. See the file "COPYING" in the main directory of this archive7-# for more details.8-#9-# Copyright (C) 1995 by Linus Torvalds10-#11-# Adapted from code in arch/i386/boot/Makefile by H. Peter Anvin12-#13-# "make install" script for i386 architecture14-#15-# Arguments:16-# $1 - kernel version17-# $2 - kernel image file18-# $3 - kernel map file19-# $4 - default install path (blank if root directory)20-#21-22-# User may have a custom install script23-24-if [ -x ~/bin/${CROSS_COMPILE}installkernel ]; then exec ~/bin/${CROSS_COMPILE}installkernel "$@"; fi25-if [ -x /sbin/${CROSS_COMPILE}installkernel ]; then exec /sbin/${CROSS_COMPILE}installkernel "$@"; fi26-27-# Default install - same as make zlilo28-29-if [ -f $4/vmlinuz ]; then30- mv $4/vmlinuz $4/vmlinuz.old31-fi32-33-if [ -f $4/System.map ]; then34- mv $4/System.map $4/System.old35-fi36-37-cat $2 > $4/vmlinuz38-cp $3 $4/System.map39-40-if [ -x /sbin/lilo ]; then /sbin/lilo; else /etc/lilo/install; fi
···1+#2+# The xfs people like to share Makefile with 2.6 and 2.4.3+# Utilise file named Kbuild file which has precedence over Makefile.4+#5+6+include $(srctree)/$(obj)/Makefile-linux-2.6
+9-4
scripts/Kbuild.include
···34# Convinient variables5comma := ,06empty :=7space := $(empty) $(empty)8···11# The temporary file to save gcc -MD generated dependencies must not12# contain a comma13depfile = $(subst $(comma),_,$(@D)/.$(@F).d)00001415###16# filechk is used to check if the content of a generated file is updated.···5253# If quiet is set, only print short version of command54cmd = @$(if $($(quiet)cmd_$(1)),\55- echo ' $(subst ','\'',$($(quiet)cmd_$(1)))' &&) $(cmd_$(1))5657# Add $(obj)/ for paths that is not absolute58objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o)))···7374# echo command. Short version is $(quiet) equals quiet, otherwise full command75echo-cmd = $(if $($(quiet)cmd_$(1)), \76- echo ' $(subst ','\'',$($(quiet)cmd_$(1)))';)7778# function to only execute the passed command if necessary79# >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file···83 @set -e; \84 $(echo-cmd) \85 $(cmd_$(1)); \86- echo 'cmd_$@ := $(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).cmd)8788# execute the command and also postprocess generated .d dependencies89# file···92 @set -e; \93 $(echo-cmd) \94 $(cmd_$(1)); \95- scripts/basic/fixdep $(depfile) $@ '$(subst $$,$$$$,$(subst ','\'',$(cmd_$(1))))' > $(@D)/.$(@F).tmp; \96 rm -f $(depfile); \97 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd)98
···34# Convinient variables5comma := ,6+squote := '7empty :=8space := $(empty) $(empty)9···10# The temporary file to save gcc -MD generated dependencies must not11# contain a comma12depfile = $(subst $(comma),_,$(@D)/.$(@F).d)13+14+###15+# Escape single quote for use in echo statements16+escsq = $(subst $(squote),'\$(squote)',$1)1718###19# filechk is used to check if the content of a generated file is updated.···4748# If quiet is set, only print short version of command49cmd = @$(if $($(quiet)cmd_$(1)),\50+ echo ' $(call escsq,$($(quiet)cmd_$(1)))' &&) $(cmd_$(1))5152# Add $(obj)/ for paths that is not absolute53objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o)))···6869# echo command. Short version is $(quiet) equals quiet, otherwise full command70echo-cmd = $(if $($(quiet)cmd_$(1)), \71+ echo ' $(call escsq,$($(quiet)cmd_$(1)))';)7273# function to only execute the passed command if necessary74# >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file···78 @set -e; \79 $(echo-cmd) \80 $(cmd_$(1)); \81+ echo 'cmd_$@ := $(subst $$,$$$$,$(call escsq,$(cmd_$(1))))' > $(@D)/.$(@F).cmd)8283# execute the command and also postprocess generated .d dependencies84# file···87 @set -e; \88 $(echo-cmd) \89 $(cmd_$(1)); \90+ scripts/basic/fixdep $(depfile) $@ '$(subst $$,$$$$,$(call escsq,$(cmd_$(1))))' > $(@D)/.$(@F).tmp; \91 rm -f $(depfile); \92 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd)93