]> arthur.barton.de Git - ngircd-alex.git/blob - autogen.sh
Include flags in RPL_WHOREPLY messages.
[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.15 2007/10/07 13:02:15 alex Exp $
13 #
14
15 #
16 # Usage: [VAR=<value>] ./autogen.sh [<configure-args>]
17 #
18 # This script generates the ./configure script using GNU automake and
19 # GNU autoconf. It tries to be smart in finding the correct/usable/available
20 # installed versions of these tools on your system.
21 #
22 # The following strategy is used for each of aclocal, autoheader, automake,
23 # and autoconf: first, "tool" (the regular name of the tool, e. g. "autoconf"
24 # or "automake") is checked. If this fails, "tool<major><minor>" (for example
25 # "automake16") and "tool-<major>.<minor>" (e. g. "autoconf-2.54") are tried
26 # with <major> being 2 for tool of GNU autoconf and 1 for tools of automake;
27 # <minor> is tried from 99 to 0. The first occurrence will be used.
28 #
29 # When you pass <configure-args> to autogen.sh it will call the generated
30 # ./configure script on success and pass these parameters to it.
31 #
32 # You can tweak the behaviour using these environment variables:
33 #
34 # - ACLOCAL=<cmd>, AUTOHEADER=<cmd>, AUTOMAKE=<cmd>, AUTOCONF=<cmd>
35 #   Name and optionally path to the particular tool.
36 # - PREFIX=<path>
37 #   Search the GNU autoconf and GNU automake tools in <path> first. If the
38 #   generated ./configure script will be called, pass "--prefix=<path>" to it.
39 # - EXIST=<tool>
40 #   Use <tool> to test for aclocal, autoheader etc. pp. ...
41 #   When not specified, either "type" or "which" is used.
42 # - VERBOSE=1
43 #   Output the detected names of the GNU automake and GNU autoconf tools.
44 # - GO=1
45 #   Call ./configure even if no arguments have been passed to autogen.sh.
46 #
47 # Examples:
48 #
49 # - ./autogen.sh
50 #   Generates the ./configure script.
51 # - GO=1 ./autogen.sh
52 #   Generates the ./configure script and runs it as "./configure".
53 # - VERBOSE=1 ./autogen.sh --with-ident
54 #   Show tool names, generates the ./configure script, and runs it with
55 #   these arguments: "./configure --with-ident".
56 # - ACLOCAL=aclocal-1.6 GO=1 PREFIX=$HOME ./autogen.sh
57 #   Uses "aclocal-1.6" as aclocal tool, generates the ./configure script,
58 #   and runs it with these arguments: "./configure --prefix=$HOME".
59 #
60
61 Search()
62 {
63         [ $# -eq 2 ] || exit 1
64
65         searchlist="$1"
66         major="$2"
67         minor=99
68
69         [ -n "$PREFIX" ] && searchlist="${PREFIX}/$1 ${PREFIX}/bin/$1 $searchlist"
70
71         for name in $searchlist; do
72                 $EXIST "${name}" >/dev/null 2>&1
73                 if [ $? -eq 0 ]; then
74                         echo "${name}"
75                         return 0
76                 fi
77         done
78
79         while [ $minor -ge 0 ]; do
80                 for name in $searchlist; do
81                         $EXIST "${name}${major}${minor}" >/dev/null 2>&1
82                         if [ $? -eq 0 ]; then
83                                 echo "${name}${major}${minor}"
84                                 return 0
85                         fi
86                         $EXIST "${name}-${major}.${minor}" >/dev/null 2>&1
87                         if [ $? -eq 0 ]; then
88                                 echo "${name}-${major}.${minor}"
89                                 return 0
90                         fi
91                 done
92                 minor=`expr $minor - 1`
93         done
94         return 1
95 }
96
97 Notfound()
98 {
99         echo "Error: $* not found!"
100         echo "Please install recent versions of GNU autoconf and GNU automake."
101         exit 1
102 }
103
104 # Reset locale settings to suppress warning messages of Perl
105 unset LC_ALL
106 unset LANG
107
108 # Which command should be used to detect the automake/autoconf tools?
109 [ -z "$EXIST" ] && existlist="type which" || existlist="$EXIST"
110 EXIST=""
111 for t in $existlist; do
112         $t /bin/ls >/dev/null 2>&1
113         if [ $? -eq 0 ]; then
114                 rm -f /tmp/test.$$
115                 $t /tmp/test.$$ >/dev/null 2>&1
116                 [ $? -ne 0 ] && EXIST="$t"
117         fi
118         [ -n "$EXIST" ] && break
119 done
120 if [ -z "$EXIST" ]; then
121         echo "Didn't detect a working command to test for the autoconf/automake tools!"
122         echo "Searchlist: $existlist"
123         exit 1
124 fi
125 [ "$VERBOSE" = "1" ] && echo "Using \"$EXIST\" to test for tools."
126
127 # We want to use GNU automake 1.9, if available (WANT_AUTOMAKE is used by
128 # the wrapper scripts of Gentoo Linux, AUTOMAKE_VERSION is used by OpenBSD);
129 # same applies for GNU autoconf, we want to use version 2.59. -- But only
130 # set these preferences if not already set!
131 if [ -z "$AUTOMAKE_VERSION" -a -z "$WANT_AUTOMAKE" ]; then
132         AUTOMAKE_VERSION=1.9
133         WANT_AUTOMAKE=1.9
134 fi
135 if [ -z "$AUTOCONF_VERSION" -a -z "$WANT_AUTOCONF" ]; then
136         AUTOCONF_VERSION=2.59
137         WANT_AUTOCONF=2.59
138 fi
139 export AUTOMAKE_VERSION WANT_AUTOMAKE AUTOCONF_VERSION WANT_AUTOCONF
140
141 # Try to detect the needed tools when no environment variable already
142 # specifies one:
143 echo "Searching tools ..."
144 [ -z "$ACLOCAL" ] && ACLOCAL=`Search aclocal 1`
145 [ "$VERBOSE" = "1" ] && echo "ACLOCAL=$ACLOCAL"
146 [ -z "$AUTOHEADER" ] && AUTOHEADER=`Search autoheader 2`
147 [ "$VERBOSE" = "1" ] && echo "AUTOHEADER=$AUTOHEADER"
148 [ -z "$AUTOMAKE" ] && AUTOMAKE=`Search automake 1`
149 [ "$VERBOSE" = "1" ] && echo "AUTOMAKE=$AUTOMAKE"
150 [ -z "$AUTOCONF" ] && AUTOCONF=`Search autoconf 2`
151 [ "$VERBOSE" = "1" ] && echo "AUTOCONF=$AUTOCONF"
152
153 # Call ./configure when parameters have been passed to this script and
154 # GO isn't already defined.
155 [ -z "$GO" -a $# -gt 0 ] && GO=1
156
157 # Verify that all tools have been found
158 [ -z "$AUTOCONF" ] && Notfound autoconf
159 [ -z "$AUTOHEADER" ] && Notfound autoheader
160 [ -z "$AUTOMAKE" ] && Notfound automake
161 [ -z "$AUTOCONF" ] && Notfound autoconf
162
163 export AUTOCONF AUTOHEADER AUTOMAKE AUTOCONF
164
165 # Generate files
166 echo "Generating files ..."
167 $ACLOCAL && \
168         $AUTOHEADER && \
169         $AUTOMAKE --add-missing && \
170         $AUTOCONF
171
172 if [ $? -eq 0 -a -x ./configure ]; then
173         # Success: if we got some parameters we call ./configure and pass
174         # all of them to it.
175         if [ "$GO" = "1" ]; then
176                 [ -n "$PREFIX" ] && p=" --prefix=$PREFIX" || p=""
177                 [ -n "$*" ] && a=" $*" || a=""
178                 c="./configure${p}${a}"
179                 echo "Calling \"$c\" ..."
180                 $c
181                 exit $?
182         else
183                 echo "Okay, autogen.sh done; now run the \"configure\" script."
184                 exit 0
185         fi
186 else
187         # Failure!?
188         echo "Error! Check your installation of GNU automake and autoconf!"
189         exit 1
190 fi
191
192 # -eof-