···883883$(vmlinux-dirs): prepare scripts884884 $(Q)$(MAKE) $(build)=$@885885886886-# Build the kernel release string887887-#888888-# The KERNELRELEASE value built here is stored in the file889889-# include/config/kernel.release, and is used when executing several890890-# make targets, such as "make install" or "make modules_install."891891-#892892-# The eventual kernel release string consists of the following fields,893893-# shown in a hierarchical format to show how smaller parts are concatenated894894-# to form the larger and final value, with values coming from places like895895-# the Makefile, kernel config options, make command line options and/or896896-# SCM tag information.897897-#898898-# $(KERNELVERSION)899899-# $(VERSION) eg, 2900900-# $(PATCHLEVEL) eg, 6901901-# $(SUBLEVEL) eg, 18902902-# $(EXTRAVERSION) eg, -rc6903903-# $(localver-full)904904-# $(localver)905905-# localversion* (files without backups, containing '~')906906-# $(CONFIG_LOCALVERSION) (from kernel config setting)907907-# $(LOCALVERSION) (from make command line, if provided)908908-# $(localver-extra)909909-# $(scm-identifier) (unique SCM tag, if one exists)910910-# ./scripts/setlocalversion (only with CONFIG_LOCALVERSION_AUTO)911911-# .scmversion (only with CONFIG_LOCALVERSION_AUTO)912912-# + (only without CONFIG_LOCALVERSION_AUTO913913-# and without LOCALVERSION= and914914-# repository is at non-tagged commit)915915-#916916-# For kernels without CONFIG_LOCALVERSION_AUTO compiled from an SCM that has917917-# been revised beyond a tagged commit, `+' is appended to the version string918918-# when not overridden by using "make LOCALVERSION=". This indicates that the919919-# kernel is not a vanilla release version and has been modified.920920-921921-pattern = ".*/localversion[^~]*"922922-string = $(shell cat /dev/null \923923- `find $(objtree) $(srctree) -maxdepth 1 -regex $(pattern) | sort -u`)924924-925925-localver = $(subst $(space),, $(string) \926926- $(patsubst "%",%,$(CONFIG_LOCALVERSION)))927927-928928-# scripts/setlocalversion is called to create a unique identifier if the source929929-# is managed by a known SCM and the repository has been revised since the last930930-# tagged (release) commit. The format of the identifier is determined by the931931-# SCM's implementation.932932-#933933-# .scmversion is used when generating rpm packages so we do not loose934934-# the version information from the SCM when we do the build of the kernel935935-# from the copied source936936-ifeq ($(wildcard .scmversion),)937937- scm-identifier = $(shell $(CONFIG_SHELL) \938938- $(srctree)/scripts/setlocalversion $(srctree))939939-else940940- scm-identifier = $(shell cat .scmversion 2> /dev/null)941941-endif942942-943943-ifdef CONFIG_LOCALVERSION_AUTO944944- localver-extra = $(scm-identifier)945945-else946946- ifneq ($(scm-identifier),)947947- ifeq ("$(origin LOCALVERSION)", "undefined")948948- localver-extra = +949949- endif950950- endif951951-endif952952-953953-localver-full = $(localver)$(LOCALVERSION)$(localver-extra)954954-955886# Store (new) KERNELRELASE string in include/config/kernel.release956956-kernelrelease = $(KERNELVERSION)$(localver-full)957887include/config/kernel.release: include/config/auto.conf FORCE958888 $(Q)rm -f $@959959- $(Q)echo $(kernelrelease) > $@889889+ $(Q)echo "$(KERNELVERSION)$$($(CONFIG_SHELL) scripts/setlocalversion $(srctree))" > $@960890961891962892# Things we need to do before we recursively start building the kernel
···1010#11111212usage() {1313- echo "Usage: $0 [srctree]" >&21313+ echo "Usage: $0 [--scm-only] [srctree]" >&21414 exit 11515}16161717-cd "${1:-.}" || usage1717+scm_only=false1818+srctree=.1919+if test "$1" = "--scm-only"; then2020+ scm_only=true2121+ shift2222+fi2323+if test $# -gt 0; then2424+ srctree=$12525+ shift2626+fi2727+if test $# -gt 0 -o ! -d "$srctree"; then2828+ usage2929+fi18301919-# Check for git and a git repo.2020-if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then3131+scm_version()3232+{3333+ local short=false21342222- # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore it,2323- # because this version is defined in the top level Makefile.2424- if [ -z "`git describe --exact-match 2>/dev/null`" ]; then3535+ cd "$srctree"3636+ if test -e .scmversion; then3737+ cat "$_"3838+ return3939+ fi4040+ if test "$1" = "--short"; then4141+ short=true4242+ fi25432626- # If we are past a tagged commit (like "v2.6.30-rc5-302-g72357d5"),2727- # we pretty print it.2828- if atag="`git describe 2>/dev/null`"; then2929- echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'4444+ # Check for git and a git repo.4545+ if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then30463131- # If we don't have a tag at all we print -g{commitish}.3232- else3333- printf '%s%s' -g $head4747+ # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore4848+ # it, because this version is defined in the top level Makefile.4949+ if [ -z "`git describe --exact-match 2>/dev/null`" ]; then5050+5151+ # If only the short version is requested, don't bother5252+ # running further git commands5353+ if $short; then5454+ echo "+"5555+ return5656+ fi5757+ # If we are past a tagged commit (like5858+ # "v2.6.30-rc5-302-g72357d5"), we pretty print it.5959+ if atag="`git describe 2>/dev/null`"; then6060+ echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'6161+6262+ # If we don't have a tag at all we print -g{commitish}.6363+ else6464+ printf '%s%s' -g $head6565+ fi3466 fi6767+6868+ # Is this git on svn?6969+ if git config --get svn-remote.svn.url >/dev/null; then7070+ printf -- '-svn%s' "`git svn find-rev $head`"7171+ fi7272+7373+ # Update index only on r/w media7474+ [ -w . ] && git update-index --refresh --unmerged > /dev/null7575+7676+ # Check for uncommitted changes7777+ if git diff-index --name-only HEAD | grep -v "^scripts/package" \7878+ | read dummy; then7979+ printf '%s' -dirty8080+ fi8181+8282+ # All done with git8383+ return3584 fi36853737- # Is this git on svn?3838- if git config --get svn-remote.svn.url >/dev/null; then3939- printf -- '-svn%s' "`git svn find-rev $head`"8686+ # Check for mercurial and a mercurial repo.8787+ if hgid=`hg id 2>/dev/null`; then8888+ tag=`printf '%s' "$hgid" | cut -d' ' -f2`8989+9090+ # Do we have an untagged version?9191+ if [ -z "$tag" -o "$tag" = tip ]; then9292+ id=`printf '%s' "$hgid" | sed 's/[+ ].*//'`9393+ printf '%s%s' -hg "$id"9494+ fi9595+9696+ # Are there uncommitted changes?9797+ # These are represented by + after the changeset id.9898+ case "$hgid" in9999+ *+|*+\ *) printf '%s' -dirty ;;100100+ esac101101+102102+ # All done with mercurial103103+ return40104 fi411054242- # Update index only on r/w media4343- [ -w . ] && git update-index --refresh --unmerged > /dev/null106106+ # Check for svn and a svn repo.107107+ if rev=`svn info 2>/dev/null | grep '^Last Changed Rev'`; then108108+ rev=`echo $rev | awk '{print $NF}'`109109+ printf -- '-svn%s' "$rev"441104545- # Check for uncommitted changes4646- if git diff-index --name-only HEAD | grep -v "^scripts/package" \4747- | read dummy; then4848- printf '%s' -dirty111111+ # All done with svn112112+ return49113 fi114114+}501155151- # All done with git116116+collect_files()117117+{118118+ local file res119119+120120+ for file; do121121+ case "$file" in122122+ *\~*)123123+ continue124124+ ;;125125+ esac126126+ if test -e "$file"; then127127+ res="$res$(cat "$file")"128128+ fi129129+ done130130+ echo "$res"131131+}132132+133133+if $scm_only; then134134+ scm_version52135 exit53136fi541375555-# Check for mercurial and a mercurial repo.5656-if hgid=`hg id 2>/dev/null`; then5757- tag=`printf '%s' "$hgid" | cut -d' ' -f2`138138+if test -e include/config/auto.conf; then139139+ source "$_"140140+else141141+ echo "Error: kernelrelease not valid - run 'make prepare' to update it"142142+ exit 1143143+fi581445959- # Do we have an untagged version?6060- if [ -z "$tag" -o "$tag" = tip ]; then6161- id=`printf '%s' "$hgid" | sed 's/[+ ].*//'`6262- printf '%s%s' -hg "$id"145145+# localversion* files in the build and source directory146146+res="$(collect_files localversion*)"147147+if test ! "$srctree" -ef .; then148148+ res="$res$(collect_files "$srctree"/localversion*)"149149+fi150150+151151+# CONFIG_LOCALVERSION and LOCALVERSION (if set)152152+res="${res}${CONFIG_LOCALVERSION}${LOCALVERSION}"153153+154154+# scm version string if not at a tagged commit155155+if test "$CONFIG_LOCALVERSION_AUTO" = "y"; then156156+ # full scm version string157157+ res="$res$(scm_version)"158158+else159159+ # apped a plus sign if the repository is not in a clean tagged160160+ # state and LOCALVERSION= is not specified161161+ if test "${LOCALVERSION+set}" != "set"; then162162+ scm=$(scm_version --short)163163+ res="$res${scm:++}"63164 fi6464-6565- # Are there uncommitted changes?6666- # These are represented by + after the changeset id.6767- case "$hgid" in6868- *+|*+\ *) printf '%s' -dirty ;;6969- esac7070-7171- # All done with mercurial7272- exit73165fi741667575-# Check for svn and a svn repo.7676-if rev=`svn info 2>/dev/null | grep '^Last Changed Rev'`; then7777- rev=`echo $rev | awk '{print $NF}'`7878- printf -- '-svn%s' "$rev"7979-8080- # All done with svn8181- exit8282-fi167167+echo "$res"