Run application handlers on stream error.
[jelmer/loudmouth.git] / autogen.sh
1 #!/bin/sh
2 # Run this to generate all the initial makefiles, etc.
3
4 : ${AUTOCONF=autoconf}
5 : ${AUTOHEADER=autoheader}
6 : ${AUTOMAKE=automake-1.9}
7 : ${ACLOCAL=aclocal-1.9}
8 : ${LIBTOOLIZE=libtoolize}
9 : ${INTLTOOLIZE=intltoolize}
10 : ${LIBTOOL=libtool}
11 : ${GNOME_DOC_PREPARE=gnome-doc-prepare}
12 : ${GTKDOCIZE=gtkdocize}
13
14 srcdir=`dirname $0`
15 test -z "$srcdir" && srcdir=.
16
17 ORIGDIR=`pwd`
18 cd $srcdir
19 PROJECT="loudmouth"
20 TEST_TYPE=-f
21 FILE=loudmouth/loudmouth.h
22 CONFIGURE=configure.ac
23
24 DIE=0
25
26 ($AUTOCONF --version) < /dev/null > /dev/null 2>&1 || {
27         echo
28         echo "You must have autoconf installed to compile $PROJECT."
29         echo "Download the appropriate package for your distribution,"
30         echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
31         DIE=1
32 }
33
34 (grep "^AC_PROG_INTLTOOL" $srcdir/$CONFIGURE >/dev/null) && {
35   ($INTLTOOLIZE --version) < /dev/null > /dev/null 2>&1 || {
36     echo
37     echo "You must have \`intltoolize' installed to compile $PROJECT."
38     echo "Get ftp://ftp.gnome.org/pub/GNOME/stable/sources/intltool/intltool-0.22.tar.gz"
39     echo "(or a newer version if it is available)"
40     DIE=1
41   }
42 }
43
44 (grep "^GNOME_DOC_INIT" $srcdir/$CONFIGURE >/dev/null) && {
45   ($GNOME_DOC_PREPARE --version) < /dev/null > /dev/null 2>&1 || {
46     echo
47     echo "You must have \`gnome-doc-prepare' installed to compile $PROJECT."
48     #echo "Get ftp://ftp.gnome.org/pub/GNOME/stable/sources/intltool/intltool-0.22.tar.gz"
49     #echo "(or a newer version if it is available)"
50     DIE=1
51   }
52 }
53
54 if grep "^GTK_DOC_CHECK" $srcdir/$CONFIGURE; then
55         ($GTKDOCIZE --version) < /dev/null > /dev/null 2>&1 || {
56                 echo;
57                 echo "You need gtk-doc to build $PACKAGE";
58                 echo;
59         }
60 fi
61
62 ($AUTOMAKE --version) < /dev/null > /dev/null 2>&1 || {
63         echo
64         echo "You must have automake installed to compile $PROJECT."
65         echo "Get ftp://sourceware.cygnus.com/pub/automake/automake-1.9.tar.gz"
66         echo "(or a newer version if it is available)"
67         DIE=1
68 }
69
70 (grep "^AM_PROG_LIBTOOL" $CONFIGURE >/dev/null) && {
71   ($LIBTOOL --version) < /dev/null > /dev/null 2>&1 || {
72     echo
73     echo "**Error**: You must have \`libtool' installed to compile $PROJECT."
74     echo "Get ftp://ftp.gnu.org/pub/gnu/libtool-1.4.tar.gz"
75     echo "(or a newer version if it is available)"
76     DIE=1
77   }
78 }
79
80 if grep "^AM_[A-Z0-9_]\{1,\}_GETTEXT" "$CONFIGURE" >/dev/null; then
81   if grep "sed.*POTFILES" "$CONFIGURE" >/dev/null; then
82     GETTEXTIZE=""
83   else
84     if grep "^AM_GLIB_GNU_GETTEXT" "$CONFIGURE" >/dev/null; then
85       GETTEXTIZE="glib-gettextize"
86       GETTEXTIZE_URL="ftp://ftp.gtk.org/pub/gtk/v2.0/glib-2.0.0.tar.gz"
87     else
88       GETTEXTIZE="gettextize"
89       GETTEXTIZE_URL="ftp://alpha.gnu.org/gnu/gettext-0.10.35.tar.gz"
90     fi
91                                                                                                           
92     $GETTEXTIZE --version < /dev/null > /dev/null 2>&1
93     if test $? -ne 0; then
94       echo
95       echo "**Error**: You must have \`$GETTEXTIZE' installed to compile $PKG_NAME."
96       echo "Get $GETTEXTIZE_URL"
97       echo "(or a newer version if it is available)"
98       DIE=1
99     fi
100   fi
101 fi
102
103
104 if test "$DIE" -eq 1; then
105         exit 1
106 fi
107
108 test $TEST_TYPE $FILE || {
109         echo "You must run this script in the top-level $PROJECT directory"
110         exit 1
111 }
112
113 #if test -z "$*"; then
114 #       echo "I am going to run ./configure with no arguments - if you wish "
115 #        echo "to pass any to it, please specify them on the $0 command line."
116 #fi
117
118 case $CC in
119 *xlc | *xlc\ * | *lcc | *lcc\ *) am_opt=--include-deps;;
120 esac
121
122 for coin in .
123 do 
124   dr=`dirname $coin`
125   if test -f $dr/NO-AUTO-GEN; then
126     echo skipping $dr -- flagged as no auto-gen
127   else
128     echo processing $dr
129     macrodirs= #`sed -n -e 's,AM_ACLOCAL_INCLUDE(\(.*\)),\1,gp' < $coin`
130     ( cd $dr
131       aclocalinclude="$ACLOCAL_FLAGS"
132       for k in $macrodirs; do
133         if test -d $k; then
134           aclocalinclude="$aclocalinclude -I $k"
135         ##else 
136         ##  echo "**Warning**: No such directory \`$k'.  Ignored."
137         fi
138       done
139       if grep "^AM_GLIB_GNU_GETTEXT" $CONFIGURE >/dev/null; then
140         if grep "sed.*POTFILES" $CONFIGURE >/dev/null; then
141           : do nothing -- we still have an old unmodified $CONFIGURE
142         else
143           echo "Creating $dr/aclocal.m4 ..."
144           test -r $dr/aclocal.m4 || touch $dr/aclocal.m4
145           echo "Running glib-gettextize...  Ignore non-fatal messages."
146           echo "no" | glib-gettextize --force --copy
147           echo "Making $dr/aclocal.m4 writable ..."
148           test -r $dr/aclocal.m4 && chmod u+w $dr/aclocal.m4
149         fi
150       fi
151       if grep "^AC_PROG_INTLTOOL" $CONFIGURE >/dev/null; then
152         echo "Running intltoolize..."
153         intltoolize --copy --force --automake
154       fi
155       if grep "^GNOME_DOC_INIT" $CONFIGURE >/dev/null; then
156         echo "Running $GNOME_DOC_PREPARE..."
157         $GNOME_DOC_PREPARE --force --copy || exit 1
158       fi
159       if grep "^AM_PROG_LIBTOOL" $CONFIGURE >/dev/null; then
160         echo "Running $LIBTOOLIZE..."
161         $LIBTOOLIZE --force --copy
162       fi
163       echo "Running $ACLOCAL $aclocalinclude ..."
164       $ACLOCAL $aclocalinclude
165       if grep "^GTK_DOC_CHECK" $CONFIGURE > /dev/null; then
166         echo "Running $GTKDOCIZE..."
167         $GTKDOCIZE
168       fi
169       if grep "^AM_CONFIG_HEADER" $CONFIGURE >/dev/null; then
170         echo "Running $AUTOHEADER..."
171         $AUTOHEADER
172       fi
173       echo "Running $AUTOMAKE --gnu $am_opt ..."
174       $AUTOMAKE --add-missing --gnu $am_opt
175       echo "Running $AUTOCONF ..."
176       $AUTOCONF
177     )
178   fi
179 done
180
181 conf_flags="--enable-maintainer-mode"
182
183 cd "$ORIGDIR"
184
185 if test x$NOCONFIGURE = x; then
186   echo Running $srcdir/configure $conf_flags "$@" ...
187   $srcdir/configure $conf_flags "$@" \
188   && echo Now type \`make\' to compile $PROJECT  || exit 1
189 else
190   echo Skipping configure process.
191 fi