3 # ngIRCd -- The Next Generation IRC Daemon
4 # Copyright (c)2001-2004 Alexander Barton <alex@barton.de>
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.
12 # $Id: autogen.sh,v 1.11 2004/03/19 11:47:51 alex Exp $
16 # Usage: [VAR=<value>] ./autogen.sh [<configure-args>]
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.
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.
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.
32 # You can tweak the behaviour using these environment variables:
34 # - ALICA=<cmd>, AUTOHEADER=<cmd>, AUTOMAKE=<cmd>, AUTOCONF=<cmd>
35 # Name and optionally path to the particular tool.
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.
40 # Output the detected names of the GNU automake and GNU autoconf tools.
42 # Call ./configure even if no arguments have been passed to autogen.sh.
47 # Generates the ./configure script.
49 # Generates the ./configure script and runs it as "./configure".
50 # - VERBOSE=1 ./autogen.sh --with-ident
51 # Show tool names, generates the ./configure script, and runs it with
52 # these arguments: "./configure --with-ident".
53 # - ACLOCAL=aclocal-1.6 GO=1 PREFIX=$HOME ./autogen.sh
54 # Uses "aclocal-1.6" as aclocal tool, generates the ./configure script,
55 # and runs it with these arguments: "./configure --prefix=$HOME".
60 [ $# -eq 2 ] || exit 1
66 which /bin/ls >/dev/null 2>&1
67 [ $? -eq 0 ] && exists="which" || exists="type"
69 [ -n "$PREFIX" ] && searchlist="${PREFIX}/$1 ${PREFIX}/bin/$1 $searchlist"
71 for name in $searchlist; do
72 $exists "${name}" >/dev/null 2>&1
79 while [ $minor -ge 0 ]; do
80 for name in $searchlist; do
81 $exists "${name}${major}${minor}" >/dev/null 2>&1
83 echo "${name}${major}${minor}"
86 $exists "${name}-${major}.${minor}" >/dev/null 2>&1
88 echo "${name}-${major}.${minor}" >/dev/null 2>&1
92 minor=`expr $minor - 1`
99 echo "Error: $* not found!"
100 echo "Please install recent versions of GNU autoconf and GNU automake."
104 # Reset locale settings to suppress warning messages of Perl
108 # We want to use GNU automake 1.7, if available (WANT_AUTOMAKE is used by
109 # the wrapper scripts of Gentoo Linux):
113 # Try to detect the needed tools when no environment variable already
115 echo "Searching tools ..."
116 [ -z "$ACLOCAL" ] && ACLOCAL=`Search aclocal 1`
117 [ "$VERBOSE" = "1" ] && echo "ACLOCAL=$ACLOCAL"
118 [ -z "$AUTOHEADER" ] && AUTOHEADER=`Search autoheader 2`
119 [ "$VERBOSE" = "1" ] && echo "AUTOHEADER=$AUTOHEADER"
120 [ -z "$AUTOMAKE" ] && AUTOMAKE=`Search automake 1`
121 [ "$VERBOSE" = "1" ] && echo "AUTOMAKE=$AUTOMAKE"
122 [ -z "$AUTOCONF" ] && AUTOCONF=`Search autoconf 2`
123 [ "$VERBOSE" = "1" ] && echo "AUTOCONF=$AUTOCONF"
125 # Call ./configure when parameters have been passed to this script and
126 # GO isn't already defined.
127 [ -z "$GO" -a $# -gt 0 ] && GO=1
129 # Verify that all tools have been found
130 [ -z "$AUTOCONF" ] && Notfounf autoconf
131 [ -z "$AUTOHEADER" ] && Notfound autoheader
132 [ -z "$AUTOMAKE" ] && Notfound automake
133 [ -z "$AUTOCONF" ] && Notfound autoconf
135 export AUTOCONF AUTOHEADER AUTOMAKE AUTOCONF
138 echo "Generating files ..."
141 $AUTOMAKE --add-missing && \
144 if [ $? -eq 0 -a -x ./configure ]; then
145 # Success: if we got some parameters we call ./configure and pass
147 if [ "$GO" = "1" ]; then
148 [ -n "$PREFIX" ] && p=" --prefix=$PREFIX" || p=""
149 [ -n "$*" ] && a=" $*" || a=""
150 c="./configure${p}${a}"
151 echo "Calling \"$c\" ..."
155 echo "Okay, autogen.sh done; now run the \"configure\" script."
160 echo "Error! Check your installation of GNU automake and autoconf!"