xref: /freebsd/contrib/pkgconf/autogen.sh (revision a3cefe7f2b4df0f70ff92d4570ce18e517af43ec)
1#! /bin/sh
2
3TOP_DIR=$(dirname $0)
4LAST_DIR=$PWD
5
6if test ! -f $TOP_DIR/configure.ac ; then
7   echo "You must execute this script from the top level directory."
8   exit 1
9fi
10
11AUTOCONF=${AUTOCONF:-autoconf}
12ACLOCAL=${ACLOCAL:-aclocal}
13AUTOHEADER=${AUTOHEADER:-autoheader}
14AUTOMAKE=${AUTOMAKE:-automake}
15LIBTOOLIZE=${LIBTOOLIZE:-libtoolize}
16
17dump_help_screen ()
18{
19   echo "Usage: $0 [options]"
20   echo
21   echo "options:"
22   echo "  -n           skip CVS changelog creation"
23   echo "  -h,--help    show this help screen"
24   echo
25   exit 0
26}
27
28parse_options ()
29{
30   while test "$1" != "" ; do
31      case $1 in
32         -h|--help)
33            dump_help_screen
34            ;;
35         -n)
36            SKIP_CVS_CHANGELOG=yes
37            ;;
38         *)
39            echo Invalid argument - $1
40            dump_help_screen
41            ;;
42      esac
43      shift
44   done
45}
46
47run_or_die ()
48{
49   COMMAND=$1
50
51   # check for empty commands
52   if test -z "$COMMAND" ; then
53      echo "*warning* no command specified"
54      return 1
55   fi
56
57   shift;
58
59   OPTIONS="$@"
60
61   # print a message
62   echo -n "*info* running $COMMAND"
63   if test -n "$OPTIONS" ; then
64      echo " ($OPTIONS)"
65   else
66      echo
67   fi
68
69   # run or die
70   $COMMAND $OPTIONS ; RESULT=$?
71   if test $RESULT -ne 0 ; then
72      echo "*error* $COMMAND failed. (exit code = $RESULT)"
73      exit 1
74   fi
75
76   return 0
77}
78
79parse_options "$@"
80
81cd $TOP_DIR
82
83run_or_die $ACLOCAL
84run_or_die $AUTOHEADER
85run_or_die $AUTOCONF
86run_or_die $LIBTOOLIZE --install
87run_or_die $AUTOMAKE --add-missing
88