Back to home page

LXR

 
 

    


0001 #!/bin/sh
0002 
0003 TARGET=$1
0004 ARCH=$2
0005 SMP=$3
0006 PREEMPT=$4
0007 CC=$5
0008 
0009 vecho() { [ "${quiet}" = "silent_" ] || echo "$@" ; }
0010 
0011 # If compile.h exists already and we don't own autoconf.h
0012 # (i.e. we're not the same user who did make *config), don't
0013 # modify compile.h
0014 # So "sudo make install" won't change the "compiled by <user>"
0015 # do "compiled by root"
0016 
0017 if [ -r $TARGET -a ! -O include/generated/autoconf.h ]; then
0018   vecho "  SKIPPED $TARGET"
0019   exit 0
0020 fi
0021 
0022 # Do not expand names
0023 set -f
0024 
0025 # Fix the language to get consistent output
0026 LC_ALL=C
0027 export LC_ALL
0028 
0029 if [ -z "$KBUILD_BUILD_VERSION" ]; then
0030         if [ -r .version ]; then
0031                 VERSION=`cat .version`
0032         else
0033                 VERSION=0
0034                 echo 0 > .version
0035         fi
0036 else
0037         VERSION=$KBUILD_BUILD_VERSION
0038 fi
0039 
0040 if [ -z "$KBUILD_BUILD_TIMESTAMP" ]; then
0041         TIMESTAMP=`date`
0042 else
0043         TIMESTAMP=$KBUILD_BUILD_TIMESTAMP
0044 fi
0045 if test -z "$KBUILD_BUILD_USER"; then
0046         LINUX_COMPILE_BY=$(whoami | sed 's/\\/\\\\/')
0047 else
0048         LINUX_COMPILE_BY=$KBUILD_BUILD_USER
0049 fi
0050 if test -z "$KBUILD_BUILD_HOST"; then
0051         LINUX_COMPILE_HOST=`hostname`
0052 else
0053         LINUX_COMPILE_HOST=$KBUILD_BUILD_HOST
0054 fi
0055 
0056 UTS_VERSION="#$VERSION"
0057 CONFIG_FLAGS=""
0058 if [ -n "$SMP" ] ; then CONFIG_FLAGS="SMP"; fi
0059 if [ -n "$PREEMPT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS PREEMPT"; fi
0060 UTS_VERSION="$UTS_VERSION $CONFIG_FLAGS $TIMESTAMP"
0061 
0062 # Truncate to maximum length
0063 
0064 UTS_LEN=64
0065 UTS_TRUNCATE="cut -b -$UTS_LEN"
0066 
0067 # Generate a temporary compile.h
0068 
0069 ( echo /\* This file is auto generated, version $VERSION \*/
0070   if [ -n "$CONFIG_FLAGS" ] ; then echo "/* $CONFIG_FLAGS */"; fi
0071 
0072   echo \#define UTS_MACHINE \"$ARCH\"
0073 
0074   echo \#define UTS_VERSION \"`echo $UTS_VERSION | $UTS_TRUNCATE`\"
0075 
0076   echo \#define LINUX_COMPILE_BY \"`echo $LINUX_COMPILE_BY | $UTS_TRUNCATE`\"
0077   echo \#define LINUX_COMPILE_HOST \"`echo $LINUX_COMPILE_HOST | $UTS_TRUNCATE`\"
0078 
0079   echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | grep ' version '`\"
0080 ) > .tmpcompile
0081 
0082 # Only replace the real compile.h if the new one is different,
0083 # in order to preserve the timestamp and avoid unnecessary
0084 # recompilations.
0085 # We don't consider the file changed if only the date/time changed.
0086 # A kernel config change will increase the generation number, thus
0087 # causing compile.h to be updated (including date/time) due to the
0088 # changed comment in the
0089 # first line.
0090 
0091 if [ -r $TARGET ] && \
0092       grep -v 'UTS_VERSION' $TARGET > .tmpver.1 && \
0093       grep -v 'UTS_VERSION' .tmpcompile > .tmpver.2 && \
0094       cmp -s .tmpver.1 .tmpver.2; then
0095    rm -f .tmpcompile
0096 else
0097    vecho "  UPD     $TARGET"
0098    mv -f .tmpcompile $TARGET
0099 fi
0100 rm -f .tmpver.1 .tmpver.2