Imported from ../bash-2.05a.tar.gz.
[platform/upstream/bash.git] / support / mkversion.sh
index c668292..d641cf0 100755 (executable)
@@ -6,7 +6,9 @@
 # otherwise everything is echoed to the standard output.
 
 PROGNAME=`basename $0`
-USAGE="$PROGNAME [-b] -d version -p patchlevel [-s status] [-o outfile]"
+USAGE="$PROGNAME [-b] [-S srcdir] -d version -p patchlevel [-s status] [-o outfile]"
+
+source_dir="."
 
 while [ $# -gt 0 ]; do
        case "$1" in
@@ -15,6 +17,7 @@ while [ $# -gt 0 ]; do
        -s)     shift; rel_status=$1; shift ;;
        -p)     shift; patch_level=$1; shift ;;
        -d)     shift; dist_version=$1; shift ;;
+       -S)     shift; source_dir="$1"; shift ;;
        *)      echo "$PROGNAME: usage: $USAGE" >&2 ; exit 2 ;;
        esac
 done
@@ -26,11 +29,11 @@ if [ -z "$dist_version" ]; then
        exit 1
 fi
 
-if [ -z "$patch_level" ]; then
-       echo "${PROGNAME}: required argument -p missing" >&2
-       echo "$PROGNAME: usage: $USAGE" >&2
-       exit 1
-fi
+#if [ -z "$patch_level" ]; then
+#      echo "${PROGNAME}: required argument -p missing" >&2
+#      echo "$PROGNAME: usage: $USAGE" >&2
+#      exit 1
+#fi
 
 # Defaults
 if [ -z "$rel_status" ]; then
@@ -51,6 +54,17 @@ if [ -n "$inc_build" ]; then
        build_ver=`expr $build_ver + 1`
 fi
 
+# what's the patch level?
+if [ -z "$patch_level" ]; then
+       patchlevel_h=$source_dir/patchlevel.h
+       if [ -s $patchlevel_h ]; then
+               patch_level=`cat $patchlevel_h | grep '^#define[        ]*PATCHLEVEL' | awk '{print $NF}'`
+       fi
+fi
+if [ -z "$patch_level" ]; then
+       patch_level=0
+fi
+
 # If we have an output file specified, make it the standard output
 if [ -n "$OUTFILE" ]; then
        if exec >$OUTFILE; then
@@ -66,8 +80,11 @@ echo "/* Version control for the shell.  This file gets changed when you say"
 echo "   \`make version.h' to the Makefile.  It is created by mkversion. */"
 
 # Output the distribution version.  Single numbers are converted to x.00.
+# Allow, as a special case, `[:digit:].[:digit:][:digit:][:alpha:]' for
+# intermediate versions (e.g., `2.05a').
 # Any characters other than digits and `.' are invalid.
 case "$dist_version" in
+[0-9].[0-9][0-9][a-z]) ;;      # special case
 *[!0-9.]*)     echo "mkversion.sh: ${dist_version}: bad distribution version" >&2
                exit 1 ;;
 *.*)   ;;
@@ -80,6 +97,7 @@ dist_major=`echo $dist_version | sed 's:\..*$::'`
 dist_minor=`echo $dist_version | sed 's:^.*\.::'`
 case "$dist_minor" in
 "")    dist_minor=00 ;;
+[a-z]) dist_minor=00${dist_minor} ;;
 ?)     dist_minor=0${dist_minor} ;;
 *)     ;;
 esac
@@ -92,9 +110,9 @@ echo "/* The distribution version number of this shell. */"
 echo "#define DISTVERSION \"${float_dist}\""
 
 # Output the patch level
-echo
-echo "/* The patch level of this version of the shell. */"
-echo "#define PATCHLEVEL ${patch_level}"
+#echo
+#echo "/* The patch level of this version of the shell. */"
+#echo "#define PATCHLEVEL ${patch_level}"
 
 # Output the build version
 echo
@@ -112,6 +130,12 @@ echo
 echo "/* A version string for use by sccs and the what command. */"
 echo "#define SCCSVERSION \"@(#)Bash version ${sccs_string}\""
 
+# extern function declarations
+echo
+echo '/* Functions from version.c. */'
+echo 'extern char *shell_version_string __P((void));'
+echo 'extern void show_shell_version __P((int));'
+
 if [ -n "$inc_build" ]; then
        # Make sure we can write to .build
        if [ -f .build ] && [ ! -w .build ]; then