home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Makefiles / VersioningSystems / next-cvs_project_version.sh next >
Linux/UNIX/POSIX Shell Script  |  1996-12-05  |  2KB  |  113 lines

  1. #!/bin/sh
  2. #ident $Id: next-cvs_project_version.sh,v 1.1.1.1 1996/12/04 00:05:57 mmonegan Exp $
  3. #
  4.  
  5. # from /usr/bin/vers_string
  6.  
  7. test=test
  8. projectInfo=projectInfo
  9.  
  10. # default vers file is ./CVSVersionInfo.txt
  11. versFile=CVSVersionInfo.txt
  12.  
  13. cflag=0
  14. fflag=0
  15. lflag=0
  16. Bflag=0
  17. nflag=0
  18.  
  19. while $test $# -gt 0 ; do
  20.     case $1 in
  21.         -c) cflag=1;;
  22.         -l) lflag=1;;
  23.         -f) fflag=1;;
  24.         -B) Bflag=1;;
  25.         -n) nflag=1;;
  26.         -V) versFile=$2;;
  27.         *) argProjName=$1;;
  28.     esac
  29.     shift
  30. done
  31.  
  32. #echo cflag $cflag
  33. #echo fflag $fflag
  34. #echo lflag $lflag
  35. #echo Bflag $Bflag
  36. #echo nflag $nflag
  37.  
  38. if $test '!' -r $versFile ; then
  39. #    echo no CVSVersionInfo.txt
  40.     wd=`pwd`
  41.     rootProjDir=`$projectInfo -rootProjectDir -inDirectory $wd`
  42.     versFile=$rootProjDir/CVSVersionInfo.txt
  43. #    echo versFile $versFile
  44.     if $test '!' -r $versFile ; then
  45.         vers_string $*
  46.         exit 0
  47.     fi
  48. fi
  49.  
  50.  
  51. isWinNT=`arch | grep winnt`
  52.  
  53. # on OpenStep For Windows we have to use gawk
  54. case $isWinNT in
  55.     *winnt*) awk=gawk;;
  56.     *) awk=awk;;
  57. esac
  58.  
  59.  
  60. user=`$awk '/\\$\Id:/ {print $7;}' $versFile`
  61. timestamp=`$awk '/\\$\Id:/ {print $5 " " $6;}' $versFile`
  62. fileVers=`$awk '/\\$\Id:/ {print $4;}' $versFile`
  63. name=`$awk '/^ProjectName:/ {print $2;}' $versFile`
  64. tag=`$awk '/\\$\Name:/ {print $3;}' $versFile`
  65. versNum=`$awk '/^ProjectVersion:/ {print $2;}' $versFile`
  66.  
  67.  
  68. PROJ=${argProjName-$name}
  69. clean_proj_name=`echo $PROJ | sed 's/[^0-9A-Za-z]/_/g'`
  70.  
  71.  
  72. #debugging 
  73. #echo user $user 
  74. #echo timestamp $timestamp 
  75. #echo fileVers $fileVers
  76. #echo name $name
  77. #echo PROJ $PROJ
  78. #echo clean_proj_name $clean_proj_name
  79. #echo tag $tag
  80. #echo versNum $versNum
  81.  
  82.  
  83. # the keyword name is the current tag and only gets filled in if 
  84. # the files are extracted at that tag. If the tag has a value,
  85. # then it is a released version, if the tag is '$' then
  86. # it has no value and is a development version.
  87. #
  88. case $tag in
  89.     '$') vers="$versNum.dev";;
  90.     *)   vers=$versNum;;
  91. esac
  92.  
  93. q='"'
  94.  
  95. if $test $fflag = 1 ; then
  96.     echo $PROJ-$vers
  97. elif $test $nflag = 1 ; then
  98.     echo $versNum
  99. else
  100.     vers_str="Project:$PROJ Version:$vers (Checkpoint by:$user on:$timestamp revision:$fileVers)"
  101.  
  102.     if $test $lflag = 1 ; then    
  103.         echo "const char "$clean_proj_name"_VERS_STRING[200] = $q@(#)$vers_str$q;"
  104.     elif $test $cflag = 1 ; then
  105.         echo "const char "$clean_proj_name"_VERS_STRING[200] = $q@(#)$vers_str$q;"
  106.         echo "const char "$clean_proj_name"_VERS_NUM[32] = $q$vers$q;"
  107.     else
  108.         echo $vers_str
  109.     fi
  110. fi
  111.  
  112. exit 0
  113.