head 1.2; access; symbols SHTOOL_1_0_0:1.1.1.1 RSE:1.1.1; locks; strict; comment @# @; 1.2 date 99.04.29.11.21.30; author rse; state dead; branches; next 1.1; 1.1 date 99.04.29.11.19.34; author rse; state Exp; branches 1.1.1.1; next ; 1.1.1.1 date 99.04.29.11.19.34; author rse; state Exp; branches; next ; desc @@ 1.2 log @*** empty log message *** @ text @#!/bin/sh - ## ## newvers -- Generate and maintain a version information file ## Copyright (c) 1994-1999 Ralf S. Engelschall ## Usage: newvers [-l ] [-n ] [-p ] [-r .[.pb]

] [-i v|r|P|p|b|a|s] [-d short|long|libtool|hex] ## LANGUAGE=txt NAME=unknown PREFIX=unknown FULLVERSION=unknown REPORT=NO INCREASE=P USAGE=NO FILE="" while [ ".$1" != . ]; do case $1 in -l) LANGUAGE=$2; shift; shift; continue ;; -n) NAME=$2; shift; shift; continue ;; -p) PREFIX=$2; shift; shift; continue ;; -r) FULLVERSION=$2; shift; shift; continue ;; -i) INCREASE=$2; shift; shift; continue ;; -d) REPORT=$2; shift; shift; continue ;; -h) USAGE=YES; shift; continue ;; *) break; esac done if [ $# -ne 1 ]; then USAGE=YES else FILE=$1 fi if [ ".$USAGE" = .YES ]; then echo "$0:Usage: newvers [options] file" echo "Options are:" echo "-l set language to one of 'txt', 'c' or 'perl'" echo "-n set program name" echo "-p set symbol prefix" echo "-r .[.pb]

set release version string" echo "-i v|r|P|p|b|a|s increase version, revision or {alpha,batch,patch,snap} level" echo "-d short|long|libtool|hex display current version only" echo "-h print this page" exit 0 fi # determine language if [ ".$LANGUAGE" = .unknown ]; then case $FILE in *.txt ) LANGUAGE=txt ;; *.c ) LANGUAGE=c ;; *.pl | *.pm ) LANGUAGE=perl ;; * ) echo "$0:Error: Unknown language type" 1>&2; exit 1 ;; esac fi # determine prefix from name and vice versa if [ ".$PREFIX" = . -o ".$PREFIX" = .unknown ]; then if [ ".$NAME" != . -a ".$NAME" != .unknown ]; then PREFIX="$NAME" fi fi if [ ".$NAME" = . -o ".$NAME" = .unknown ]; then if [ ".$PREFIX" != . -a ".$PREFIX" != .unknown ]; then NAME="$PREFIX" fi fi # determine version date=unknown if [ ".$FULLVERSION" = .unknown ]; then if [ -r "$FILE" ]; then # grep out current information id=`grep 'Version [0-9]*.[0-9]*[.abps][0-9]* ([0-9]*-[a-zA-Z]*-[0-9]*)' $FILE | \ head -1 | \ sed -e 's%.*Version \([0-9]*\)\.\([0-9]*\)\([.abps]\)\([0-9]*\) (\([0-9]*-[a-zA-Z]*-[0-9]*\)).*%\1:\2:\3:\4:\5%'` version=`echo $id | awk -F: '{ print $1 }'` revision=`echo $id | awk -F: '{ print $2 }'` bptype=`echo $id | awk -F: '{ print $3 }'` bplevel=`echo $id | awk -F: '{ print $4 }'` date=`echo $id | awk -F: '{ print $5 }'` if [ .$REPORT = .NO ]; then case $INCREASE in b ) bplevel=`expr $bplevel + 1` bptype=b ;; a ) bplevel=`expr $bplevel + 1` bptype=a ;; s ) bplevel=`expr $bplevel + 1` bptype=s ;; P ) bplevel=`expr $bplevel + 1` bptype=. ;; p ) bplevel=`expr $bplevel + 1` bptype=p ;; r ) revision=`expr $revision + 1` bplevel=0 ;; v ) version=`expr $version + 1` revision=0 bplevel=0 ;; esac date=calc fi FULLVERSION="$version.$revision$bptype$bplevel" else # intialise to first version version=0 revision=5 bptype=b bplevel=0 date=calc fi else # take given version V=`echo $FULLVERSION | sed -e 's%\([0-9]*\)\.\([0-9]*\)\([.abps]\)\([0-9]*\).*%\1:\2:\3:\4%'` version=`echo $V | awk -F: '{ print $1 }'` revision=`echo $V | awk -F: '{ print $2 }'` bptype=`echo $V | awk -F: '{ print $3 }'` bplevel=`echo $V | awk -F: '{ print $4 }'` date=calc fi # determine hex value of version case $FULLVERSION in *.*a* ) HEX=`echo "$FULLVERSION" | sed -e 's/a.*//' | awk -F. '{ printf("%d%02d", $1, $2); }' && echo "$FULLVERSION" | sed -e 's/.*a//' | awk '{ printf("0%02d", $1); }'` ;; *.*b* ) HEX=`echo "$FULLVERSION" | sed -e 's/b.*//' | awk -F. '{ printf("%d%02d", $1, $2); }' && echo "$FULLVERSION" | sed -e 's/.*b//' | awk '{ printf("1%02d", $1); }'` ;; *.*.* ) HEX=`echo "$FULLVERSION" | awk -F. '{ printf("%d%02d2%02d", $1, $2, $3); }'` ;; esac # determine libtool version case $FULLVERSION in *.*a* ) LTV=`echo "$FULLVERSION" | sed -e 's/a.*//' | awk -F. '{ printf("%d:0", $1*10+$2); }'` ;; *.*b* ) LTV=`echo "$FULLVERSION" | sed -e 's/b.*//' | awk -F. '{ printf("%d:0", $1*10+$2); }'` ;; *.*.* ) LTV=`echo "$FULLVERSION" | awk -F. '{ printf("%d:%d", $1*10+$2, $3); }'` ;; esac # determine string out of filename FILESTR=`echo "$FILE" | tr '[a-z./%+\-]' '[A-Z______]'` # determine date if [ ".$date" = .calc ]; then day="`date '+%d' | awk '{ printf("%s", $1); }'`" month="`date '+%m' | awk '{ printf("%s", $1); }'`" year="`date '+%Y' 2>/dev/null | awk '{ printf("%s", $1); }'`" if test ".$time_year" = .; then year="`date '+%y' | awk '{ printf("%s", $1); }'`" case $year in 9[0-9]*) year="19$year" ;; *) year="20$year" ;; esac fi case $month in 1|01) month='Jan' ;; 2|02) month='Feb' ;; 3|03) month='Mar' ;; 4|04) month='Apr' ;; 5|05) month='May' ;; 6|06) month='Jun' ;; 7|07) month='Jul' ;; 8|08) month='Aug' ;; 9|09) month='Sep' ;; 10) month='Oct' ;; 11) month='Nov' ;; 12) month='Dec' ;; esac date="${day}-${month}-${year}" fi if [ .$REPORT != .NO ]; then case $REPORT in long ) echo "$version.$revision$bptype$bplevel ($date)" ;; short ) echo "$version.$revision$bptype$bplevel" ;; libtool ) echo "$LTV" ;; hex ) echo "0x$HEX" ;; esac exit 0 fi # create the version file according the the selected language echo "new version: $version.$revision$bptype$bplevel ($date)" tmpfile="/tmp/newvers.tmp.$$" rm -f $tmpfile >/dev/null 2>&1 case $LANGUAGE in txt ) cat >$tmpfile <<'EOT' This is @@NAME@@ Version @@VERSION@@.@@REVISION@@@@BPTYPE@@@@BPLEVEL@@ (@@DAY@@-@@MONTH@@-@@YEAR@@) EOT ;; c ) cat >$tmpfile <<'EOT' /* ** @@FILE@@ -- Version File (automatically generated and maintained by NEWVERS) */ #ifdef AS_HEADER #ifndef @@FILESTR@@ #define @@FILESTR@@ #define @@PREFIX@@_VERSION 0x@@HEX@@ extern const int @@PREFIX@@_Version; extern const char @@PREFIX@@_VersionStr[]; extern const char @@PREFIX@@_Hello[]; extern const char @@PREFIX@@_GNUVersion[]; extern const char @@PREFIX@@_WhatID[]; extern const char @@PREFIX@@_RCSIdentID[]; extern const char @@PREFIX@@_WebID[]; extern const char @@PREFIX@@_PlainID[]; #endif #else const int @@PREFIX@@_Version = 0x@@HEX@@; const char @@PREFIX@@_VersionStr[] = "@@VERSION@@.@@REVISION@@@@BPTYPE@@@@BPLEVEL@@ (@@DAY@@-@@MONTH@@-@@YEAR@@)"; const char @@PREFIX@@_Hello[] = "This is @@NAME@@ Version @@VERSION@@.@@REVISION@@@@BPTYPE@@@@BPLEVEL@@ (@@DAY@@-@@MONTH@@-@@YEAR@@)"; const char @@PREFIX@@_GNUVersion[] = "@@NAME@@ Version @@VERSION@@.@@REVISION@@@@BPTYPE@@@@BPLEVEL@@"; const char @@PREFIX@@_WhatID[] = "@@(#)@@NAME@@ Version @@VERSION@@.@@REVISION@@@@BPTYPE@@@@BPLEVEL@@ (@@DAY@@-@@MONTH@@-@@YEAR@@)"; const char @@PREFIX@@_RCSIdentID[] = "$Id: newvers.sh,v 1.1 1999/04/29 11:19:34 rse Exp $"; const char @@PREFIX@@_WebID[] = "@@NAME@@/@@VERSION@@.@@REVISION@@@@BPTYPE@@@@BPLEVEL@@"; const char @@PREFIX@@_PlainID[] = "@@VERSION@@.@@REVISION@@@@BPTYPE@@@@BPLEVEL@@"; #endif EOT ;; perl ) cat >$tmpfile <<'EOT' ## ## @@FILE@@ -- Version File (automatically generated and maintained by NEWVERS) ## $@@PREFIX@@_Version = 0x@@HEX@@; $@@PREFIX@@_VersionStr = "@@VERSION@@.@@REVISION@@@@BPTYPE@@@@BPLEVEL@@ (@@DAY@@-@@MONTH@@-@@YEAR@@)"; $@@PREFIX@@_Hello = "This is @@NAME@@ Version @@VERSION@@.@@REVISION@@@@BPTYPE@@@@BPLEVEL@@ (@@DAY@@-@@MONTH@@-@@YEAR@@)"; $@@PREFIX@@_GNUVersion = "@@NAME@@ Version @@VERSION@@.@@REVISION@@@@BPTYPE@@@@BPLEVEL@@"; $@@PREFIX@@_WhatID = "@@(#)@@NAME@@ Version @@VERSION@@.@@REVISION@@@@BPTYPE@@@@BPLEVEL@@ (@@DAY@@-@@MONTH@@-@@YEAR@@)"; $@@PREFIX@@_RCSIdentID = "\$Id: newvers.sh,v 1.1 1999/04/29 11:19:34 rse Exp $"; $@@PREFIX@@_WebID = "@@NAME@@/@@VERSION@@.@@REVISION@@@@BPTYPE@@@@BPLEVEL@@"; $@@PREFIX@@_PlainID = "@@VERSION@@.@@REVISION@@@@BPTYPE@@@@BPLEVEL@@"; 1; EOT ;; esac # now create the version file rm -f $FILE >/dev/null 2>&1 sed \ -e "s|@@FILE@@|$FILE|g" \ -e "s|@@FILESTR@@|$FILESTR|g" \ -e "s|@@PREFIX@@|$PREFIX|g" \ -e "s|@@NAME@@|$NAME|g" \ -e "s|@@HEX@@|$HEX|g" \ -e "s|@@VERSION@@|$version|g" \ -e "s|@@REVISION@@|$revision|g" \ -e "s|@@BPTYPE@@|$bptype|g" \ -e "s|@@BPLEVEL@@|$bplevel|g" \ -e "s|@@YEAR@@|$year|g" \ -e "s|@@MONTH@@|$month|g" \ -e "s|@@DAY@@|$day|g" <$tmpfile >$FILE rm -f $tmpfile >/dev/null 2>&1 exit 0 @ 1.1 log @Initial revision @ text @d246 1 a246 1 const char @@PREFIX@@_RCSIdentID[] = "$Id: @@NAME@@ @@VERSION@@.@@REVISION@@@@BPTYPE@@@@BPLEVEL@@ @@DAY@@-@@MONTH@@-@@YEAR@@ $"; d265 1 a265 1 $@@PREFIX@@_RCSIdentID = "\$Id: @@NAME@@ @@VERSION@@.@@REVISION@@@@BPTYPE@@@@BPLEVEL@@ @@DAY@@-@@MONTH@@-@@YEAR@@ \$"; @ 1.1.1.1 log @Import of shtool 1.0.0 @ text @@