Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | TARGET=$1 |
| 2 | ARCH=$2 |
| 3 | SMP=$3 |
Sam Ravnborg | bd5bdd8 | 2005-07-14 20:18:07 +0000 | [diff] [blame] | 4 | PREEMPT=$4 |
| 5 | CC=$5 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | |
| 7 | # If compile.h exists already and we don't own autoconf.h |
| 8 | # (i.e. we're not the same user who did make *config), don't |
| 9 | # modify compile.h |
| 10 | # So "sudo make install" won't change the "compiled by <user>" |
| 11 | # do "compiled by root" |
| 12 | |
| 13 | if [ -r $TARGET -a ! -O include/linux/autoconf.h ]; then |
| 14 | echo " SKIPPED $TARGET" |
| 15 | exit 0 |
| 16 | fi |
| 17 | |
| 18 | # Do not expand names |
| 19 | set -f |
| 20 | |
| 21 | if [ -r .version ]; then |
| 22 | VERSION=`cat .version` |
| 23 | else |
| 24 | VERSION=0 |
| 25 | echo 0 > .version |
| 26 | fi |
| 27 | |
| 28 | |
| 29 | UTS_VERSION="#$VERSION" |
Sam Ravnborg | bd5bdd8 | 2005-07-14 20:18:07 +0000 | [diff] [blame] | 30 | CONFIG_FLAGS="" |
| 31 | if [ -n "$SMP" ] ; then CONFIG_FLAGS="SMP"; fi |
| 32 | if [ -n "$PREEMPT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS PREEMPT"; fi |
| 33 | UTS_VERSION="$UTS_VERSION $CONFIG_FLAGS `LC_ALL=C LANG=C date`" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
| 35 | # Truncate to maximum length |
| 36 | |
| 37 | UTS_LEN=64 |
| 38 | UTS_TRUNCATE="sed -e s/\(.\{1,$UTS_LEN\}\).*/\1/" |
| 39 | |
| 40 | # Generate a temporary compile.h |
| 41 | |
| 42 | ( echo /\* This file is auto generated, version $VERSION \*/ |
Sam Ravnborg | bd5bdd8 | 2005-07-14 20:18:07 +0000 | [diff] [blame] | 43 | if [ -n "$CONFIG_FLAGS" ] ; then echo "/* $CONFIG_FLAGS */"; fi |
| 44 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | echo \#define UTS_MACHINE \"$ARCH\" |
| 46 | |
| 47 | echo \#define UTS_VERSION \"`echo $UTS_VERSION | $UTS_TRUNCATE`\" |
| 48 | |
| 49 | echo \#define LINUX_COMPILE_TIME \"`LC_ALL=C LANG=C date +%T`\" |
| 50 | echo \#define LINUX_COMPILE_BY \"`whoami`\" |
| 51 | echo \#define LINUX_COMPILE_HOST \"`hostname | $UTS_TRUNCATE`\" |
| 52 | |
| 53 | if [ -x /bin/dnsdomainname ]; then |
| 54 | echo \#define LINUX_COMPILE_DOMAIN \"`dnsdomainname | $UTS_TRUNCATE`\" |
| 55 | elif [ -x /bin/domainname ]; then |
| 56 | echo \#define LINUX_COMPILE_DOMAIN \"`domainname | $UTS_TRUNCATE`\" |
| 57 | else |
| 58 | echo \#define LINUX_COMPILE_DOMAIN |
| 59 | fi |
| 60 | |
s situert | 895a39a | 2007-02-14 00:32:55 -0800 | [diff] [blame] | 61 | echo \#define LINUX_COMPILER \"`LC_ALL=C LANG=C $CC -v 2>&1 | tail -n 1`\" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | ) > .tmpcompile |
| 63 | |
| 64 | # Only replace the real compile.h if the new one is different, |
| 65 | # in order to preserve the timestamp and avoid unnecessary |
| 66 | # recompilations. |
| 67 | # We don't consider the file changed if only the date/time changed. |
| 68 | # A kernel config change will increase the generation number, thus |
| 69 | # causing compile.h to be updated (including date/time) due to the |
| 70 | # changed comment in the |
| 71 | # first line. |
| 72 | |
| 73 | if [ -r $TARGET ] && \ |
| 74 | grep -v 'UTS_VERSION\|LINUX_COMPILE_TIME' $TARGET > .tmpver.1 && \ |
| 75 | grep -v 'UTS_VERSION\|LINUX_COMPILE_TIME' .tmpcompile > .tmpver.2 && \ |
| 76 | cmp -s .tmpver.1 .tmpver.2; then |
| 77 | rm -f .tmpcompile |
| 78 | else |
| 79 | echo " UPD $TARGET" |
| 80 | mv -f .tmpcompile $TARGET |
| 81 | fi |
| 82 | rm -f .tmpver.1 .tmpver.2 |