newvers.sh 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/bin/sh
  2. #
  3. # newvers.sh - increment build number in current directory (a build directory)
  4. # and emit vers.c.
  5. # The build number is kept in the file "version".
  6. #
  7. # Usage: newvers.sh CONFIGNAME
  8. #
  9. # Copyright (c) 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009
  10. # The President and Fellows of Harvard College.
  11. #
  12. # Redistribution and use in source and binary forms, with or without
  13. # modification, are permitted provided that the following conditions
  14. # are met:
  15. # 1. Redistributions of source code must retain the above copyright
  16. # notice, this list of conditions and the following disclaimer.
  17. # 2. Redistributions in binary form must reproduce the above copyright
  18. # notice, this list of conditions and the following disclaimer in the
  19. # documentation and/or other materials provided with the distribution.
  20. # 3. Neither the name of the University nor the names of its contributors
  21. # may be used to endorse or promote products derived from this software
  22. # without specific prior written permission.
  23. #
  24. # THIS SOFTWARE IS PROVIDED BY THE UNIVERSITY AND CONTRIBUTORS ``AS IS'' AND
  25. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  27. # ARE DISCLAIMED. IN NO EVENT SHALL THE UNIVERSITY OR CONTRIBUTORS BE LIABLE
  28. # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  30. # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  31. # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  32. # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  33. # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  34. # SUCH DAMAGE.
  35. #
  36. if [ ! -f autoconf.c ]; then
  37. #
  38. # If there's no file autoconf.c, we are in the wrong place.
  39. #
  40. echo "$0: Not in a kernel build directory"
  41. exit 1
  42. fi
  43. if [ "x$1" = x ]; then
  44. echo "Usage: $0 CONFIGNAME"
  45. exit 1
  46. fi
  47. CONFIG="$1"
  48. #
  49. # Get and increment the version number
  50. #
  51. VERS=`cat version 2>/dev/null || echo 0`
  52. VERS=`expr $VERS + 1`
  53. echo "$VERS" > version
  54. #
  55. # Write vers.c
  56. #
  57. echo '/* This file is automatically generated. Edits will be lost.*/' > vers.c
  58. echo "const int buildversion = $VERS;" >> vers.c
  59. echo 'const char buildconfig[] = "'"$CONFIG"'";' >> vers.c
  60. #
  61. # Announce it in the hopes that it'll still be visible when the build
  62. # finishes.
  63. #
  64. echo "*** This is $CONFIG build "'#'"$VERS ***"