]> arthur.barton.de Git - ngircd-alex.git/blob - autogen.sh
Added missing "return 0" ... oops.
[ngircd-alex.git] / autogen.sh
1 #!/bin/sh
2 #
3 # ngIRCd -- The Next Generation IRC Daemon
4 # Copyright (c)2001-2004 Alexander Barton <alex@barton.de>
5 #
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10 # Please read the file COPYING, README and AUTHORS for more information.
11 #
12 # $Id: autogen.sh,v 1.9 2004/03/15 18:59:12 alex Exp $
13 #
14
15 Search()
16 {
17         [ $# -eq 2 ] || exit 1
18
19         name="$1"
20         major="$2"
21         minor=99
22
23         type "${name}" >/dev/null 2>&1
24         if [ $? -eq 0 ]; then
25                 echo "${name}"
26                 return 0
27         fi
28
29         while [ $minor -ge 0 ]; do
30                 type "${name}${major}${minor}" >/dev/null 2>&1
31                 if [ $? -eq 0 ]; then
32                         echo "${name}${major}${minor}"
33                         return 0
34                 fi
35                 type "${name}-${major}.${minor}" >/dev/null 2>&1
36                 if [ $? -eq 0 ]; then
37                         echo "${name}-${major}.${minor}" >/dev/null 2>&1
38                         return 0
39                 fi
40                 minor=`expr $minor - 1`
41         done
42         return 1
43 }
44
45 Notfound()
46 {
47         echo "Error: $* not found!"
48         echo "Please install recent versions of GNU autoconf and GNU automake."
49         exit 1
50 }
51
52 # Reset locale settings to suppress warning messages of Perl
53 unset LC_ALL
54 unset LANG
55
56 # We want to use GNU automake 1.7, if available (WANT_AUTOMAKE is used by
57 # the wrapper scripts of Gentoo Linux):
58 WANT_AUTOMAKE=1.7
59 export WANT_AUTOMAKE
60
61 # Try to detect the needed tools when no environment variable already
62 # spezifies one:
63 echo "Searching tools ..."
64 [ -z "$ACLOCAL" ] && ACLOCAL=`Search aclocal 1`
65 [ -z "$AUTOHEADER" ] && AUTOHEADER=`Search autoheader 2`
66 [ -z "$AUTOMAKE" ] && AUTOMAKE=`Search automake 1`
67 [ -z "$AUTOCONF" ] && AUTOCONF=`Search autoconf 2`
68
69 # Some debugging output ...
70 if [ -n "$DEBUG" ]; then
71         echo "ACLOCAL=$ACLOCAL"
72         echo "AUTOHEADER=$AUTOHEADER"
73         echo "AUTOMAKE=$AUTOMAKE"
74         echo "AUTOCONF=$AUTOCONF"
75 fi
76
77 # Verify that all tools have been found
78 [ -z "$AUTOCONF" ] && Notfounf autoconf
79 [ -z "$AUTOHEADER" ] && Notfound autoheader
80 [ -z "$AUTOMAKE" ] && Notfound automake
81 [ -z "$AUTOCONF" ] && Notfound autoconf
82
83 export AUTOCONF AUTOHEADER AUTOMAKE AUTOCONF
84
85 # Generate files
86 echo "Generating files ..."
87 $ACLOCAL && \
88         $AUTOHEADER && \
89         $AUTOMAKE --add-missing && \
90         $AUTOCONF
91
92 if [ $? -eq 0 ]; then
93         # Success: if we got some parameters we call ./configure and pass
94         # all of them to it.
95         if [ -n "$*" -a -x ./configure ]; then
96                 echo "Calling generated \"configure\" script ..."
97                 ./configure $*
98                 exit $?
99         else
100                 echo "Okay, autogen.sh done; now run the \"configure\" script."
101                 exit 0
102         fi
103 else
104         # Failure!?
105         echo "Error! Check your installation of GNU automake and autoconf!"
106         exit 1
107 fi
108
109 # -eof-