# 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
-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
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
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
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 ;;
*.*) ;;
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
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
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