11da177e4SLinus TorvaldsTARGET=$1 21da177e4SLinus TorvaldsARCH=$2 31da177e4SLinus TorvaldsSMP=$3 4bd5bdd87SSam RavnborgPREEMPT=$4 5bd5bdd87SSam RavnborgCC=$5 61da177e4SLinus Torvalds 71da177e4SLinus Torvalds# If compile.h exists already and we don't own autoconf.h 81da177e4SLinus Torvalds# (i.e. we're not the same user who did make *config), don't 91da177e4SLinus Torvalds# modify compile.h 101da177e4SLinus Torvalds# So "sudo make install" won't change the "compiled by <user>" 111da177e4SLinus Torvalds# do "compiled by root" 121da177e4SLinus Torvalds 131da177e4SLinus Torvaldsif [ -r $TARGET -a ! -O include/linux/autoconf.h ]; then 141da177e4SLinus Torvalds echo " SKIPPED $TARGET" 151da177e4SLinus Torvalds exit 0 161da177e4SLinus Torvaldsfi 171da177e4SLinus Torvalds 181da177e4SLinus Torvalds# Do not expand names 191da177e4SLinus Torvaldsset -f 201da177e4SLinus Torvalds 211da177e4SLinus Torvaldsif [ -r .version ]; then 221da177e4SLinus Torvalds VERSION=`cat .version` 231da177e4SLinus Torvaldselse 241da177e4SLinus Torvalds VERSION=0 251da177e4SLinus Torvalds echo 0 > .version 261da177e4SLinus Torvaldsfi 271da177e4SLinus Torvalds 281da177e4SLinus Torvalds 291da177e4SLinus TorvaldsUTS_VERSION="#$VERSION" 30bd5bdd87SSam RavnborgCONFIG_FLAGS="" 31bd5bdd87SSam Ravnborgif [ -n "$SMP" ] ; then CONFIG_FLAGS="SMP"; fi 32bd5bdd87SSam Ravnborgif [ -n "$PREEMPT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS PREEMPT"; fi 33bd5bdd87SSam RavnborgUTS_VERSION="$UTS_VERSION $CONFIG_FLAGS `LC_ALL=C LANG=C date`" 341da177e4SLinus Torvalds 351da177e4SLinus Torvalds# Truncate to maximum length 361da177e4SLinus Torvalds 371da177e4SLinus TorvaldsUTS_LEN=64 381da177e4SLinus TorvaldsUTS_TRUNCATE="sed -e s/\(.\{1,$UTS_LEN\}\).*/\1/" 391da177e4SLinus Torvalds 401da177e4SLinus Torvalds# Generate a temporary compile.h 411da177e4SLinus Torvalds 421da177e4SLinus Torvalds( echo /\* This file is auto generated, version $VERSION \*/ 43bd5bdd87SSam Ravnborg if [ -n "$CONFIG_FLAGS" ] ; then echo "/* $CONFIG_FLAGS */"; fi 441da177e4SLinus Torvalds 451da177e4SLinus Torvalds echo \#define UTS_MACHINE \"$ARCH\" 461da177e4SLinus Torvalds 471da177e4SLinus Torvalds echo \#define UTS_VERSION \"`echo $UTS_VERSION | $UTS_TRUNCATE`\" 481da177e4SLinus Torvalds 491da177e4SLinus Torvalds echo \#define LINUX_COMPILE_TIME \"`LC_ALL=C LANG=C date +%T`\" 501da177e4SLinus Torvalds echo \#define LINUX_COMPILE_BY \"`whoami`\" 511da177e4SLinus Torvalds echo \#define LINUX_COMPILE_HOST \"`hostname | $UTS_TRUNCATE`\" 521da177e4SLinus Torvalds 531da177e4SLinus Torvalds if [ -x /bin/dnsdomainname ]; then 541da177e4SLinus Torvalds echo \#define LINUX_COMPILE_DOMAIN \"`dnsdomainname | $UTS_TRUNCATE`\" 551da177e4SLinus Torvalds elif [ -x /bin/domainname ]; then 561da177e4SLinus Torvalds echo \#define LINUX_COMPILE_DOMAIN \"`domainname | $UTS_TRUNCATE`\" 571da177e4SLinus Torvalds else 581da177e4SLinus Torvalds echo \#define LINUX_COMPILE_DOMAIN 591da177e4SLinus Torvalds fi 601da177e4SLinus Torvalds 611da177e4SLinus Torvalds echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | tail -n 1`\" 621da177e4SLinus Torvalds) > .tmpcompile 631da177e4SLinus Torvalds 641da177e4SLinus Torvalds# Only replace the real compile.h if the new one is different, 651da177e4SLinus Torvalds# in order to preserve the timestamp and avoid unnecessary 661da177e4SLinus Torvalds# recompilations. 671da177e4SLinus Torvalds# We don't consider the file changed if only the date/time changed. 681da177e4SLinus Torvalds# A kernel config change will increase the generation number, thus 691da177e4SLinus Torvalds# causing compile.h to be updated (including date/time) due to the 701da177e4SLinus Torvalds# changed comment in the 711da177e4SLinus Torvalds# first line. 721da177e4SLinus Torvalds 731da177e4SLinus Torvaldsif [ -r $TARGET ] && \ 741da177e4SLinus Torvalds grep -v 'UTS_VERSION\|LINUX_COMPILE_TIME' $TARGET > .tmpver.1 && \ 751da177e4SLinus Torvalds grep -v 'UTS_VERSION\|LINUX_COMPILE_TIME' .tmpcompile > .tmpver.2 && \ 761da177e4SLinus Torvalds cmp -s .tmpver.1 .tmpver.2; then 771da177e4SLinus Torvalds rm -f .tmpcompile 781da177e4SLinus Torvaldselse 791da177e4SLinus Torvalds echo " UPD $TARGET" 801da177e4SLinus Torvalds mv -f .tmpcompile $TARGET 811da177e4SLinus Torvaldsfi 821da177e4SLinus Torvaldsrm -f .tmpver.1 .tmpver.2 83