mkcompile_h 2.6 KB

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