mkcompile_h 2.1 KB

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