]> arthur.barton.de Git - ngircd-alex.git/blob - autogen.sh
Reworked configure system: it should be more compatible to most systems
[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.8 2004/03/11 22:21:20 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                 fi
39                 minor=`expr $minor - 1`
40         done
41         return 1
42 }
43
44 Notfound()
45 {
46         echo "Error: $* not found!"
47         echo "Please install recent versions of GNU autoconf and GNU automake."
48         exit 1
49 }
50
51 # Reset locale settings to suppress warning messages of Perl
52 unset LC_ALL
53 unset LANG
54
55 # We want to use GNU automake 1.7, if available (WANT_AUTOMAKE is used by
56 # the wrapper scripts of Gentoo Linux):
57 WANT_AUTOMAKE=1.7
58 export WANT_AUTOMAKE
59
60 # Try to detect the needed tools when no environment variable already
61 # spezifies one:
62 echo "Searching tools ..."
63 [ -z "$ACLOCAL" ] && ACLOCAL=`Search aclocal 1`
64 [ -z "$AUTOHEADER" ] && AUTOHEADER=`Search autoheader 2`
65 [ -z "$AUTOMAKE" ] && AUTOMAKE=`Search automake 1`
66 [ -z "$AUTOCONF" ] && AUTOCONF=`Search autoconf 2`
67
68 # Some debugging output ...
69 if [ -n "$DEBUG" ]; then
70         echo "ACLOCAL=$ACLOCAL"
71         echo "AUTOHEADER=$AUTOHEADER"
72         echo "AUTOMAKE=$AUTOMAKE"
73         echo "AUTOCONF=$AUTOCONF"
74 fi
75
76 # Verify that all tools have been found
77 [ -z "$AUTOCONF" ] && Notfounf autoconf
78 [ -z "$AUTOHEADER" ] && Notfound autoheader
79 [ -z "$AUTOMAKE" ] && Notfound automake
80 [ -z "$AUTOCONF" ] && Notfound autoconf
81
82 export AUTOCONF AUTOHEADER AUTOMAKE AUTOCONF
83
84 # Generate files
85 echo "Generating files ..."
86 $ACLOCAL && \
87         $AUTOHEADER && \
88         $AUTOMAKE --add-missing && \
89         $AUTOCONF
90
91 if [ $? -eq 0 ]; then
92         # Success: if we got some parameters we call ./configure and pass
93         # all of them to it.
94         if [ -n "$*" -a -x ./configure ]; then
95                 echo "Calling generated \"configure\" script ..."
96                 ./configure $*
97                 exit $?
98         else
99                 echo "Okay, autogen.sh done; now run the \"configure\" script."
100                 exit 0
101         fi
102 else
103         # Failure!?
104         echo "Error! Check your installation of GNU automake and autoconf!"
105         exit 1
106 fi
107
108 # -eof-