3 # ngIRCd -- The Next Generation IRC Daemon
4 # Copyright (c)2001-2013 Alexander Barton (alex@barton.de) and Contributors
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.
13 # [VAR=<value>] ./autogen.sh [<configure-args>]
15 # This script generates the ./configure script using GNU automake and
16 # GNU autoconf. It tries to be smart in finding the correct/usable/available
17 # installed versions of these tools on your system.
19 # In addition, it enables or disables the "de-ANSI-fication" support of GNU
20 # automake, which is supported up to autoconf 1.11.x an has been removed
21 # in automake 1.12 -- make sure to use a version of automake supporting it
22 # when generating distribution archives!
24 # The following strategy is used for each of aclocal, autoheader, automake,
25 # and autoconf: first, "tool" (the regular name of the tool, e. g. "autoconf"
26 # or "automake") is checked. If this fails, "tool<major><minor>" (for example
27 # "automake16") and "tool-<major>.<minor>" (e. g. "autoconf-2.54") are tried
28 # with <major> being 2 for tool of GNU autoconf and 1 for tools of automake;
29 # <minor> is tried from 99 to 0. The first occurrence will be used.
31 # When you pass <configure-args> to autogen.sh it will call the generated
32 # ./configure script on success and pass these parameters to it.
34 # You can tweak the behaviour using these environment variables:
36 # - ACLOCAL=<cmd>, AUTOHEADER=<cmd>, AUTOMAKE=<cmd>, AUTOCONF=<cmd>
37 # Name and optionally path to the particular tool.
39 # Search the GNU autoconf and GNU automake tools in <path> first. If the
40 # generated ./configure script will be called, pass "--prefix=<path>" to it.
42 # Use <tool> to test for aclocal, autoheader etc. pp. ...
43 # When not specified, either "type" or "which" is used.
45 # Output the detected names of the GNU automake and GNU autoconf tools.
47 # Call ./configure even if no arguments have been passed to autogen.sh.
52 # Generates the ./configure script.
54 # Generates the ./configure script and runs it as "./configure".
55 # - VERBOSE=1 ./autogen.sh --with-ident
56 # Show tool names, generates the ./configure script, and runs it with
57 # these arguments: "./configure --with-ident".
58 # - ACLOCAL=aclocal-1.6 GO=1 PREFIX=$HOME ./autogen.sh
59 # Uses "aclocal-1.6" as aclocal tool, generates the ./configure script,
60 # and runs it with these arguments: "./configure --prefix=$HOME".
65 [ $# -eq 2 ] || exit 1
71 [ -n "$PREFIX" ] && searchlist="${PREFIX}/$1 ${PREFIX}/bin/$1 $searchlist"
73 for name in $searchlist; do
74 $EXIST "${name}" >/dev/null 2>&1
81 while [ $minor -ge 0 ]; do
82 for name in $searchlist; do
83 $EXIST "${name}${major}${minor}" >/dev/null 2>&1
85 echo "${name}${major}${minor}"
88 $EXIST "${name}-${major}.${minor}" >/dev/null 2>&1
90 echo "${name}-${major}.${minor}"
94 minor=`expr $minor - 1`
101 echo "Error: $* not found!"
102 echo "Please install recent versions of GNU autoconf and GNU automake."
108 [ "$VERBOSE" = "1" ] && echo " - running \"$@\" ..."
112 # Reset locale settings to suppress warning messages of Perl
116 # Which command should be used to detect the automake/autoconf tools?
117 [ -z "$EXIST" ] && existlist="type which" || existlist="$EXIST"
119 for t in $existlist; do
120 $t /bin/ls >/dev/null 2>&1
121 if [ $? -eq 0 ]; then
123 $t /tmp/test.$$ >/dev/null 2>&1
124 [ $? -ne 0 ] && EXIST="$t"
126 [ -n "$EXIST" ] && break
128 if [ -z "$EXIST" ]; then
129 echo "Didn't detect a working command to test for the autoconf/automake tools!"
130 echo "Searchlist: $existlist"
133 [ "$VERBOSE" = "1" ] && echo "Using \"$EXIST\" to test for tools."
135 # Try to detect the needed tools when no environment variable already
137 echo "Searching for required tools ..."
138 [ -z "$ACLOCAL" ] && ACLOCAL=`Search aclocal 1`
139 [ "$VERBOSE" = "1" ] && echo " - ACLOCAL=$ACLOCAL"
140 [ -z "$AUTOHEADER" ] && AUTOHEADER=`Search autoheader 2`
141 [ "$VERBOSE" = "1" ] && echo " - AUTOHEADER=$AUTOHEADER"
142 [ -z "$AUTOMAKE" ] && AUTOMAKE=`Search automake 1`
143 [ "$VERBOSE" = "1" ] && echo " - AUTOMAKE=$AUTOMAKE"
144 [ -z "$AUTOCONF" ] && AUTOCONF=`Search autoconf 2`
145 [ "$VERBOSE" = "1" ] && echo " - AUTOCONF=$AUTOCONF"
147 [ $# -gt 0 ] && CONFIGURE_ARGS=" $@" || CONFIGURE_ARGS=""
148 [ -z "$GO" -a -n "$CONFIGURE_ARGS" ] && GO=1
150 # Verify that all tools have been found
151 [ -z "$ACLOCAL" ] && Notfound aclocal
152 [ -z "$AUTOHEADER" ] && Notfound autoheader
153 [ -z "$AUTOMAKE" ] && Notfound automake
154 [ -z "$AUTOCONF" ] && Notfound autoconf
156 AM_VERSION=`$AUTOMAKE --version|head -n 1|egrep -o "([1-9]\.[0-9]+(\.[0-9]+)*)"`
157 ifs=$IFS; IFS="."; set $AM_VERSION; IFS=$ifs
158 AM_MAJOR="$1"; AM_MINOR="$2"; AM_PATCHLEVEL="$3"
159 echo "Detected automake $AM_VERSION ..."
161 AM_MAKEFILES="src/ipaddr/Makefile.ng src/ngircd/Makefile.ng src/testsuite/Makefile.ng src/tool/Makefile.ng"
164 if [ "$AM_MAJOR" -eq "1" -a "$AM_MINOR" -lt "12" ]; then
165 # automake < 1.12 => automatic de-ANSI-fication support available
166 echo " - Enabling de-ANSI-fication support."
167 sed -e "s|^__ng_PROTOTYPES__|AM_C_PROTOTYPES|g" configure.ng >configure.ac
171 # automake >= 1.12 => no de-ANSI-fication support available
172 echo " - Disabling de-ANSI-fication support."
173 sed -e "s|^__ng_PROTOTYPES__|AC_C_PROTOTYPES|g" configure.ng >configure.ac
175 DEANSI_END=" (disabled by ./autogen.sh script)"
177 sed -e "s|^__ng_Makefile_am_template__|${DEANSI_START}AUTOMAKE_OPTIONS = ansi2knr${DEANSI_END}|g" \
178 src/portab/Makefile.ng >src/portab/Makefile.am
179 for makefile_ng in $AM_MAKEFILES; do
180 makefile_am=`echo "$makefile_ng" | sed -e "s|\.ng\$|\.am|g"`
181 sed -e "s|^__ng_Makefile_am_template__|${DEANSI_START}AUTOMAKE_OPTIONS = ../portab/ansi2knr${DEANSI_END}|g" \
182 $makefile_ng >$makefile_am
185 export ACLOCAL AUTOHEADER AUTOMAKE AUTOCONF
188 echo "Generating files using GNU $AUTOCONF and $AUTOMAKE ..."
192 Run $AUTOMAKE --add-missing --no-force
194 if [ $? -eq 0 -a -x ./configure ]; then
195 # Success: if we got some parameters we call ./configure and pass
197 NAME=`grep PACKAGE_STRING= configure | cut -d"'" -f2`
198 if [ "$GO" = "1" ]; then
199 [ -n "$PREFIX" ] && p=" --prefix=$PREFIX" || p=""
200 c="./configure${p}${CONFIGURE_ARGS}"
201 echo "Okay, autogen.sh for $NAME done."
202 echo "Calling \"$c\" ..."
206 echo "Okay, autogen.sh for $NAME done."
207 echo "Now run the \"./configure\" script."
212 echo "Error! Check your installation of GNU automake and autoconf!"