2
# autogen.sh - initialize and clean automake&co based build trees
4
# For more detailed info, run "autogen.sh --help" or scroll down to the
5
# print_help() function.
8
if test "$(pwd)" != "`pwd`"
10
echo "Urgh. Dinosaur shell, eh?"
15
########################################################################
16
# Constant and initial values
21
self="$(basename "$0")"
22
autogen_version="0.4.5"
25
########################################################################
30
${self} - initialize automake/autoconf/gettext/libtool based build system
33
${self} [<command>|<flag>|...] [<directory>...]
35
Runs given command sequence on all given directories, in sequence.
36
If there is no command given, --init is assumed.
37
If there is no directory given, the location of ${self} is assumed.
43
Print the tool versions
46
Clean all files and directories generated by "$self --init"
48
Converts untouched CVS checkout into a build tree which
49
can be processed further by running the classic
50
./configure && make && make install
56
Only print the commands to be run, not actually execute
59
Used internally. Do everything which doesn't recurse on
62
${self} depends on automake, autoconf, libtool and gettext.
64
You may want to set AUTOCONF, AUTOHEADER, AUTOMAKE, AUTORECONF, ACLOCAL,
65
AUTOPOINT, LIBTOOLIZE to use specific version of these tools, and
66
AUTORECONF_OPTS to add options to the call to autoreconf.
68
If none of these variables are set, ${self} tries to find the most
69
adequate version in \$PATH.
74
########################################################################
75
# Print software versions
78
echo "${self} (ndim's autogen) ${autogen_version}"
80
"${AUTOCONF-autoconf}" \
81
"${AUTOMAKE-automake}" \
82
"${AUTOPOINT-autopoint}" \
83
"${LIBTOOLIZE-libtoolize}"
85
"$tool" --version 2>&1 | sed '1q'
90
########################################################################
91
# Initialize variables for configure.{in,ac} in $1
95
echo -n "Looking for \`${dir}/configure.{ac,in}'..."
96
# There are shells which don't understand {,} wildcards
98
for tmp in "${dir}/configure.ac" "${dir}/configure.in"; do
99
if test -f "$tmp"; then
105
if test "x$CONFIGURE_AC" = "x"; then
111
if test "$(uname -o)" = "Cygwin"; then
112
# Cygwin autoreconf doesn't understand -Wall
113
AUTORECONF_OPTS="$AUTORECONF_OPTS --verbose"
115
AUTORECONF_OPTS="$AUTORECONF_OPTS --verbose -Wall"
119
"$debug" && echo -n "Initializing variables for \`${dir}'..."
120
# FIXME: Just getting those directories and cleaning them isn't enough.
121
# OK, the "init" part is done recursively by autopoint, so that is easy.
122
# But the cleaning should also work recursively, but that is difficult
123
# with the current structure of the script.
124
AG_SUBDIRS="$(for k in $(sed -n 's/^[[:space:]]*GP_AUTOGEN_SUBDIR(\[\{0,1\}\([^])]*\).*/\1/p' "$CONFIGURE_AC"); do echo "${k}"; done)"
125
AG_LIBLTDL_DIR="$(sed -n 's/^[[:space:]]*AC_LIBLTDL_\(INSTALLABLE\|CONVENIENCE\)(\[\{0,1\}\([^])]*\).*/\2/p' < "$CONFIGURE_AC")"
126
if test "x$AG_LIBLTDL_DIR" = "x"; then
127
tmp="$(sed -n 's/^[[:space:]]*\(AC_LIBLTDL_\)\(INSTALLABLE\|CONVENIENCE\)(\[\{0,1\}\([^])]*\).*/\1/p' < "$CONFIGURE_AC")"
128
if test "x$tmp" = "xAC_LIBLTDL_"; then
129
AG_LIBLTDL_DIR="libltdl"
134
AG_AUX="$(sed -n 's/^AC_CONFIG_AUX_DIR(\[\{0,1\}\([^])]*\).*/\1/p' < "$CONFIGURE_AC")"
135
if test "x$AG_AUX" = "x"; then
138
AG_CONFIG_H="$(sed -n 's/^\(A[CM]_CONFIG_HEADERS\?\)(\[\{0,1\}\([^]),]*\).*/\2/p' < "$CONFIGURE_AC")"
139
AG_CONFIG_K="$(sed -n 's/^\(A[CM]_CONFIG_HEADERS\?\)(\[\{0,1\}\([^]),]*\).*/\1/p' < "$CONFIGURE_AC")"
140
if echo "x$AG_CONFIG_H" | grep -q ':'; then
141
echo "$AG_CONFIG_K contains unsupported \`:' character: \`$AG_CONFIG_H'"
144
if test "x$AG_CONFIG_H" != "x"; then
145
AG_CONFIG_DIR="$(dirname "${AG_CONFIG_H}")"
146
AG_GEN_CONFIG_H="${AG_CONFIG_H} ${AG_CONFIG_H}.in ${AG_CONFIG_DIR}/stamp-h1 ${AG_CONFIG_DIR}/stamp-h2"
151
for d in "$AG_AUX" "$AG_CONFIG_DIR"; do
152
if test -n "$d" && test ! -d "$d"; then
156
AG_GEN_ACAM="aclocal.m4 configure $AG_AUX/config.guess $AG_AUX/config.sub $AG_AUX/compile"
157
AG_GEN_RECONF="$AG_AUX/install-sh $AG_AUX/missing $AG_AUX/depcomp"
158
AG_GEN_LIBTOOL="$AG_AUX/ltmain.sh libtool"
160
AG_GEN_LIBTOOL="${AG_GEN_LIBTOOL} ${AG_LIBLTDL_DIR}/${file}"
178
AG_GEN_GETTEXT="$AG_AUX/mkinstalldirs $AG_AUX/config.rpath ABOUT-NLS"
180
AG_GEN_GETTEXT="${AG_GEN_GETTEXT} m4/${file} m4m/${file}"
212
AG_GEN_GETTEXT="${AG_GEN_GETTEXT} po/${file}"
225
AG_GEN_CONF="config.status config.log"
226
AG_GEN_FILES="$AG_GEN_ACAM $AG_GEN_RECONF $AG_GEN_GETTEXT"
227
AG_GEN_FILES="$AG_GEN_FILES $AG_GEN_CONFIG_H $AG_GEN_CONF $AG_GEN_LIBTOOL"
228
AG_GEN_DIRS="autom4te.cache ${AG_LIBLTDL_DIR}/autom4te.cache ${AG_LIBLTDL_DIR}"
229
"$debug" && echo " done."
231
if "$debug"; then set | grep '^AG_'; fi
233
if "$dryrun"; then dryrun_param="--dry-run"; fi
237
########################################################################
238
# Print command to be executed and, if not dryrun, actually execute it.
241
if "$dryrun" || "$debug"; then
242
echo "Running <<" "$@" ">>"
244
if "$dryrun"; then :; else
250
########################################################################
251
# Clean generated files from $* directories
254
if test "x$AG_GEN_FILES" = "x"; then echo "Internal error"; exit 2; fi
256
#while test "$dir"; do
257
echo "$self:clean: Entering directory \`${dir}'"
260
echo -n "Cleaning autogen generated files..."
261
execute_command rm -rf ${AG_GEN_DIRS}
262
execute_command rm -f ${AG_GEN_FILES}
264
if test -h INSTALL; then execute_command rm -f INSTALL; fi
265
echo -n "Cleaning generated Makefile, Makefile.in files..."
266
if "$debug"; then echo; fi
267
find . -type f -name 'Makefile.am' -print | \
269
echo "$file" | grep -q '/{arch}' && continue
270
echo "$file" | grep -q '/\.svn' && continue
271
echo "$file" | grep -q '/CVS' && continue
272
base="$(dirname "$file")/$(basename "$file" .am)"
274
echo -e " Removing files created from ${file}"
276
execute_command rm -f "${base}" "${base}.in"
278
if "$debug"; then :; else echo " done."; fi
279
echo -n "Removing *~ backup files..."
280
find . -type f -name '*~' -print | while read fname; do
281
execute_command rm -f "$fname"
284
if test -n "${AG_SUBDIRS}"; then
285
"$0" --clean ${dryrun_param} --recursive ${AG_SUBDIRS}
289
echo "$self:clean: Left directory \`${dir}'"
296
########################################################################
297
# Initialize build system in $1 directory
301
if test "x$AG_GEN_FILES" = "x"; then echo "Internal error"; exit 2; fi
302
echo "$self:init: Entering directory \`${dir}'"
305
if test "x$AG_LIBLTDL_DIR" != "x"; then
306
# We have to run libtoolize --ltdl ourselves because
307
# - autoreconf doesn't run it at all
308
execute_command "${LIBTOOLIZE-"libtoolize"}" --ltdl
309
# And we have to clean up the generated files after libtoolize because
310
# - we still want symlinks for the files
311
# - but we want to (implicitly) AC_CONFIG_SUBDIR and that writes to
313
if test ! -d "${AG_LIBLTDL_DIR}" || test ! -f "${AG_LIBLTDL_DIR}/Makefile.am"; then
314
echo "Could not create libltdl directory \`${AG_LIBLTDL_DIR}'."
315
echo "Leaving \`$(pwd)' and aborting."
318
(cd "${AG_LIBLTDL_DIR}" && execute_command rm -f aclocal.m4 config.guess config.sub configure install-sh ltmain.sh Makefile.in missing)
320
if test -n "${AG_SUBDIRS}"; then
321
"$0" --init ${dryrun_param} --recursive ${AG_SUBDIRS}
323
if test "$status" -ne 0; then exit "$status"; fi
325
if "$recursive"; then :; else
326
if execute_command ${AUTORECONF-"autoreconf"} --install --symlink ${AUTORECONF_OPTS}; then
329
echo "autoreconf quit with exit code $status, aborting."
332
echo "You may run ./configure now in \`${dir}'."
333
echo "Run as \"./configure --help\" to find out about config options."
339
# Just error propagation
341
echo "$self:init: Left directory \`${dir}'"
342
if "$recursive"; then
344
elif test "$status" -ne "0"; then
350
########################################################################
351
# Parse command line.
352
# This still accepts more than the help text says it does, but that
355
commands="init" # default command in case none is given
358
dirs="$(dirname "$0")"
359
#dirs="$(cd "$dirs" && pwd)"
361
# Yes, unquoted $@ isn't space safe, but it works with simple shells.
365
pcommands="$pcommands clean"
368
pcommands="$pcommands init"
389
echo "Unhandled $self option: $param"
393
pdirs="${pdirs} ${param}"
397
if test "x$pcommands" != "x"; then
398
# commands given on command line? use them!
399
commands="$pcommands"
403
if test "x$pdirs" != "x"; then
404
# dirs given on command line? use them!
409
########################################################################
410
# If not explicitly given, try to find most convenient tools in $PATH
412
# This method only works for tools made for parallel installation with
413
# a version suffix, i.e. autoconf and automake.
415
# libtool and gettext do not support that, so you'll still have to
416
# manually set the respective variables if the default does not work
420
oldversion="oldversion"
421
while read flag variable binary version restofline; do
424
if "$skip"; then skip=false; fi
425
if test -n "`eval echo \$\{$variable+"set"\}`"; then
428
if test -x "`which ${binary}${version}`"; then
429
export "$variable"="${binary}${version}"
430
oldversion="${version}"
437
if "$skip"; then :; else
438
export "$variable"="${binary}${oldversion}"
443
+ AUTOMAKE automake -1.9
445
+ AUTOMAKE automake -1.8
447
+ AUTOCONF autoconf 2.59
448
- AUTOHEADER autoheader
449
- AUTORECONF autoreconf
450
+ AUTOCONF autoconf 2.50
451
- AUTOHEADER autoheader
452
- AUTORECONF autoreconf
456
########################################################################
457
# Check that tool versions satisfy our needs
459
if "$check_versions"; then
460
# check tool versions
464
while read tool minversion; do
465
version="$("$tool" --version | sed 's/^.*(.*) *\(.*\)$/\1/g;1q')"
466
# compare version and minversion
467
first="$(echo "$version$lf$minversion" | sort -n | sed '1q')"
468
if test "x$minversion" != "x$first" && test "x$version" = "x$first"; then
469
echo "Version \`$version' of \`$tool' not sufficient. At least \`$minversion' required."
473
${ACLOCAL-"aclocal"} 1.8
474
${AUTOMAKE-"automake"} 1.8
475
${AUTOCONF-"autoconf"} 2.59
476
${AUTOHEADER-"autoheader"} 2.59
477
${AUTOPOINT-"autopoint"} 0.14.1
478
${LIBTOOLIZE-"libtoolize"} 1.4
481
echo "Please update your toolset."
482
echo "If you want to continue regardless of your old toolset, press ENTER."
488
########################################################################
489
# Actually run the commands
491
for dir in ${dirs}; do
492
"$debug" && echo "Running commands on directory \`${dir}'"
493
if test ! -d "$dir"; then
494
echo "Could not find directory \`${dir}'"
497
for command in ${commands}; do
498
"command_$command" "$dir"
505
# Please do not remove this:
506
# filetype: 89b1e88e-4cf2-44f1-980d-730067367775
507
# I use this to find all the different instances of this file which
508
# are supposed to be synchronized.