1#!/bin/sh
2
3######
4###### Some defs
5######
6
7PKG_NAME="xbubble"
8# a list of all dirs containing possibly some macros
9acmacrodirs="${HOME}/share/aclocal ${PWD}/tools/acmacro ${PWD}/m4"
10
11######
12###### End of conf part
13######
14for dir in $acmacrodirs ; do
15   if test -d $dir ; then
16       aclocalinclude="$aclocalinclude -I $dir";
17   fi
18done
19
20srcdir=`dirname $0`
21test -z "$srcdir" && srcdir=.
22
23echo "Autoregenerate package \`$PKG_NAME' in directory \`$srcdir'";
24
25(test -f $srcdir/configure.ac \
26  && test -f $srcdir/src/board.c) || {
27    echo -n "**Error**: Directory "\`$srcdir\'" does not look like the"
28    echo " top-level $PKG_NAME directory"
29    exit 1
30}
31
32######
33###### Some tests (borrowed from Mt who borrowed it from
34###### macros/autogen.sh from achtung)
35######
36DIE=0
37
38(autoconf --version) < /dev/null > /dev/null 2>&1 || {
39  echo
40  echo "**Error**: You must have \`autoconf' installed to compile $PKG_NAME."
41  echo "Download the appropriate package for your distribution,"
42  echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
43  DIE=1
44}
45
46(grep "^AM_PROG_LIBTOOL" $srcdir/configure.ac >/dev/null) && {
47  (libtool --version) < /dev/null > /dev/null 2>&1 || {
48    echo
49    echo "**Error**: You must have \`libtool' installed to compile $PKG_NAME."
50    echo "Get ftp://ftp.gnu.org/pub/gnu/libtool-1.4.tar.gz"
51    echo "(or a newer version if it is available)"
52    DIE=1
53  }
54}
55
56(automake-1.7 --version) < /dev/null > /dev/null 2>&1 || {
57  echo
58  echo "**Error**: You must have \`automake' 1.7 installed to compile $PKG_NAME."
59  echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.7.tar.gz"
60  echo "(or a newer version if it is available)"
61  DIE=1
62  NO_AUTOMAKE=yes
63}
64
65# if no automake, don't bother testing for aclocal
66test -n "$NO_AUTOMAKE" || (aclocal --version) < /dev/null > /dev/null 2>&1 || {
67  echo
68  echo "**Error**: Missing \`aclocal'.  The version of \`automake'"
69  echo "installed doesn't appear recent enough."
70  echo "Get ftp://ftp.gnu.org/pub/gnu/automake-1.3.tar.gz"
71  echo "(or a newer version if it is available)"
72  DIE=1
73}
74
75if test "$DIE" -eq 1; then
76  exit 1
77fi
78###### END of test part
79
80
81######
82###### Action part
83######
84if test -z "$*"; then
85  echo "**Warning**: I am going to run \`configure' with no arguments."
86  echo "If you wish to pass any to it, please specify them on the"
87  echo \`$0\'" command line."
88  echo
89fi
90echo "Generating configuration files for xbubble, please wait...."
91echo;
92
93case $CC in
94xlc )
95  am_opt=--include-deps;;
96esac
97
98#for coin in  `find $srcdir -name configure.ac -print `\
99#             `find $srcdir -name configure.in -print`
100for coin in $srcdir/configure.ac
101do
102  dr=`dirname $coin`
103  if test -f $dr/NO-AUTO-GEN; then
104    echo skipping $dr -- flagged as no auto-gen
105  else
106    echo "************"
107    echo "* Processing directory $dr"
108    echo "************"
109
110    if [ -e $dr/configure.in ] ; then
111       configfile="configure.in"
112    else
113       configfile="configure.ac"
114    fi
115    macrodirs=`sed -n -e 's,AM_ACLOCAL_INCLUDE(\(.*\)),\1,gp' < $coin`
116      pwd=`pwd`
117      cd $dr
118      if grep "^AM_PROG_LIBTOOL" $configfile >/dev/null; then
119	if test -z "$NO_LIBTOOLIZE" ; then
120	  echo "Running libtoolize --force --copy in "`pwd`"..."
121	  libtoolize --force --copy
122	fi
123      fi
124      echo "Running aclocal-1.7 $aclocalinclude..."
125      aclocal-1.7 $aclocalinclude
126      if grep "^AM_CONFIG_HEADER" $configfile >/dev/null; then
127	echo "Running autoheader in "`pwd`"..."
128	autoheader
129      fi
130      echo "Running automake-1.7 --gnu --add-missing $am_opt ..."
131      automake-1.7 --gnu --add-missing $am_opt
132#      echo "Running automake m4/Makefile ..."
133#      automake m4/Makefile
134      echo "Running autoconf..."
135      autoconf
136      cd $pwd
137  fi
138done
139
140#conf_flags="--enable-maintainer-mode"
141
142if test x$NOCONFIGURE = x; then
143  echo "************"
144  echo "* Running $srcdir/configure $conf_flags $@ ..."
145  echo "************"
146
147  $srcdir/configure $conf_flags "$@" || exit 1
148else
149  echo Skipping configure process.
150fi
151
152echo Now type \`make\' to compile $PKG_NAME
153
154