Import expat-2.0.1
[dragonfly.git] / contrib / expat / conftools / get-version.sh
1 #!/bin/sh
2 #
3 # USAGE: get-version.sh path/to/expat.h
4 #
5 # This script will print Expat's version number on stdout. For example:
6 #
7 #   $ ./conftools/get-version.sh ./lib/expat.h
8 #   1.95.3
9 #   $
10 #
11
12 if test $# = 0; then
13   echo "ERROR: pathname for expat.h was not provided."
14   echo ""
15   echo "USAGE: $0 path/to/expat.h"
16   exit 1
17 fi
18 if test $# != 1; then
19   echo "ERROR: too many arguments were provided."
20   echo ""
21   echo "USAGE: $0 path/to/expat.h"
22   exit 1
23 fi
24
25 hdr="$1"
26 if test ! -r "$hdr"; then
27   echo "ERROR: '$hdr' does not exist, or is not readable."
28   exit 1
29 fi
30
31 MAJOR_VERSION="`sed -n -e '/MAJOR_VERSION/s/[^0-9]*//gp' $hdr`"
32 MINOR_VERSION="`sed -n -e '/MINOR_VERSION/s/[^0-9]*//gp' $hdr`"
33 MICRO_VERSION="`sed -n -e '/MICRO_VERSION/s/[^0-9]*//gp' $hdr`"
34
35 # Determine how to tell echo not to print the trailing \n. This is
36 # similar to Autoconf's @ECHO_C@ and @ECHO_N@; however, we don't
37 #  generate this file via autoconf (in fact, get-version.sh is used
38 # to *create* ./configure), so we just do something similar inline.
39 case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
40   *c*,-n*) ECHO_N= ECHO_C='
41 ' ;;
42   *c*,*  ) ECHO_N=-n ECHO_C= ;;
43   *)      ECHO_N= ECHO_C='\c' ;;
44 esac
45
46 echo $ECHO_N "$MAJOR_VERSION.$MINOR_VERSION.$MICRO_VERSION$ECHO_C"