home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / MISC / GNU / GPTX01AS.ZIP / VERSION.AWK < prev    next >
Encoding:
Text File  |  1990-07-04  |  3.1 KB  |  101 lines

  1. # Augment the installation number in the version string.
  2. # Copyright (C) 1990 Free Software Foundation, Inc.
  3. # Francois Pinard <pinard@iro.umontreal.ca>, March 1990.
  4.  
  5.  
  6. # PURPOSE OF THIS SCRIPT.
  7. #  
  8. # The script reads its input and copies it verbatim, except for one line
  9. # line which, usually, looks like:
  10. #    #define VERSION "I.J.K"
  11. # where I, J and K are decimal numbers.  The third number will have
  12. # its value bumped up by one before the copy.  This special line can
  13. # also look like:
  14. #
  15. #    #define VERSION "I.J"
  16. #    #define VERSION "I"
  17. #    #define VERSION ""
  18. # Missing numbers, if any, are assumed to have the value zero, before
  19. # the bumping.  After the bumping, all three numbers will show.
  20. #
  21. #
  22. # MORE ABOUT THE VERSION STRING.
  23. # The version is a string containing three numbers separated by two
  24. # periods.  The first number indicates the major revision, the second
  25. # number indicates the minor revision, and the third number indicates
  26. # the installation number.  The first two numbers pertain to the
  27. # distributor, while the third pertains to the local installator.
  28. # This third number usually counts the number of times the package has
  29. # been locally re-installed to be made accessible to the users.
  30. # Interim modifications to a package which does not lead to a user
  31. # installation are considered experimental and, then, not worth a
  32. # change in the installation number.  It is mostly when a package is
  33. # made available to users that some feedback is expected, so the
  34. # installation number changes should be delayed until then.
  35. #
  36. #
  37. # INTERACTION WITH THE MAKEFILE.
  38. # A nice way to use this is to keep some `version.c' file in the
  39. # project containing such a #define, and to modify the install goal in
  40. # the Makefile.  Suppose the install goal was:
  41. #
  42. #    install: $(PROGRAMS)
  43. #        $(INSTALL) $(PROGRAMS) $(BINDIR)
  44. #
  45. # Then, modify it so it looks like this:
  46. #
  47. #    install: $(PROGRAMS)
  48. #        $(INSTALL) $(PROGRAMS) $(BINDIR)
  49. #        gawk -f version.awk version.c >newversion.c
  50. #        @mv version.c version.c~
  51. #        @mv newversion.c version.c
  52. # Given this provision, at each `make install' or `make -k install',
  53. # the local installation number will be bumped after the install,
  54. # but only if it was successful.  So, all local experimentation will
  55. # use this new version number, until another install is done.  Right
  56. # *after* the next install, the installation number will be bumped
  57. # again, and so on.
  58.  
  59.  
  60. # Look for the #define VERSION line.
  61.  
  62. /^[ \t]*#[ \t]*define[ \t][ \t]*VERSION[ \t][ \t]*"[^"]*"/ {
  63.  
  64.   # Split the version into numbers.
  65.  
  66.   match ($0, /"[^"]*"/)
  67.   version = substr ($0, RSTART + 1, RLENGTH - 2)
  68.   number = split (version, numbers, ".")
  69.  
  70.   # Insure three numbers, defaulting to 0.0.0; then bump the third up.
  71.  
  72.   if (number < 1) {
  73.     numbers[1] = "0"
  74.   }
  75.   if (number < 2) {
  76.     numbers[2] = "0"
  77.   }
  78.   if (number < 3) {
  79.     numbers[3] = "0"
  80.   }
  81.   numbers[3]++
  82.  
  83.   # Replace the new version numbers in the #define and write it out.
  84.  
  85.   sub (/"[^"]*"/, "\"" numbers[1] "." numbers[2] "." numbers[3] "\"", $0)
  86.   print
  87.   next
  88. }
  89.  
  90.  
  91. # Copy all other lines without change.
  92.  
  93. //
  94.