mkcompile_h 1.54 KB
Newer Older
1 2 3 4 5
TARGET=$1
ARCH=$2
SMP=$3
CC=$4

6 7 8 9 10 11 12
if [ -r ../.version ]; then
  VERSION=`cat ../.version`
else
  VERSION=0
  echo 0 > ../.version
fi

13 14
# Generate a temporary compile.h

15
( echo /\* This file is auto generated, version $VERSION \*/
16 17

  echo \#define UTS_MACHINE \"$ARCH\"
18

19
  echo -n \#define UTS_VERSION \"\#$VERSION
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
  if [ -n "$SMP" ] ; then echo -n " SMP"; fi
  echo ' '`date`'"'

  echo \#define LINUX_COMPILE_TIME \"`date +%T`\"
  echo \#define LINUX_COMPILE_BY \"`whoami`\"
  echo \#define LINUX_COMPILE_HOST \"`hostname`\"

  if [ -x /bin/dnsdomainname ]; then
    echo \#define LINUX_COMPILE_DOMAIN \"`dnsdomainname`\"
  elif [ -x /bin/domainname ]; then
    echo \#define LINUX_COMPILE_DOMAIN \"`domainname`\"
  else
    echo \#define LINUX_COMPILE_DOMAIN
  fi

  echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | tail -1`\"
) > .tmpcompile

38 39 40 41 42 43 44 45 46 47 48 49 50
# Only replace the real compile.h if the new one is different,
# in order to preserve the timestamp and avoid unnecessary
# recompilations.
# We don't consider the file changed if only the date/time changed.
# A kernel config change will increase the generation number, thus
# causing compile.h to be updated (including date/time) due to the 
# changed comment in the
# first line.

if [ -r $TARGET ] && \
      grep -v 'UTS_VERSION\|LINUX_COMPILE_TIME' $TARGET > .tmpver.1 && \
      grep -v 'UTS_VERSION\|LINUX_COMPILE_TIME' .tmpcompile > .tmpver.2 && \
      cmp -s .tmpver.1 .tmpver.2; then
51
   echo $TARGET was not updated;
52 53
   rm -f .tmpcompile
else
54
   echo $TARGET was updated
55 56 57
   mv -f .tmpcompile $TARGET
fi
rm -f .tmpver.1 .tmpver.2