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.2"
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, ACLOCAL,
65
AUTOPOINT, LIBTOOLIZE to use specific version of these tools, and
66
AUTORECONF_OPTS to add options to the call to autoreconf.
71
########################################################################
72
# Print software versions
75
echo "${self} (ndim's autogen) ${autogen_version}"
77
"${AUTOCONF-autoconf}" \
78
"${AUTOMAKE-automake}" \
79
"${AUTOPOINT-autopoint}" \
80
"${LIBTOOLIZE-libtoolize}"
82
"$tool" --version 2>&1 | sed '1q'
87
########################################################################
88
# Initialize variables for configure.{in,ac} in $1
92
echo -n "Looking for \`${dir}/configure.{ac,in}'..."
93
# There are shells which don't understand {,} wildcards
95
for tmp in "${dir}/configure.ac" "${dir}/configure.in"; do
96
if test -f "$tmp"; then
102
if test "x$CONFIGURE_AC" = "x"; then
108
if test "$(uname -o)" = "Cygwin"; then
109
# Cygwin autoreconf doesn't understand -Wall
110
AUTORECONF_OPTS="$AUTORECONF_OPTS --verbose"
112
AUTORECONF_OPTS="$AUTORECONF_OPTS --verbose -Wall"
116
"$debug" && echo -n "Initializing variables for \`${dir}'..."
117
# FIXME: Just getting those directories and cleaning them isn't enough.
118
# OK, the "init" part is done recursively by autopoint, so that is easy.
119
# But the cleaning should also work recursively, but that is difficult
120
# with the current structure of the script.
121
AG_SUBDIRS="$(for k in $(sed -n 's/^[[:space:]]*AC_CONFIG_SUBDIRS(\[\{0,1\}\([^])]*\).*/\1/p' "$CONFIGURE_AC"); do echo "${k}"; done)"
122
AG_LIBLTDL_DIR="$(sed -n 's/^[[:space:]]*AC_LIBLTDL_\(INSTALLABLE\|CONVENIENCE\)(\[\{0,1\}\([^])]*\).*/\2/p' < "$CONFIGURE_AC")"
123
if test "x$AG_LIBLTDL_DIR" = "x"; then
124
tmp="$(sed -n 's/^[[:space:]]*\(AC_LIBLTDL_\)\(INSTALLABLE\|CONVENIENCE\)(\[\{0,1\}\([^])]*\).*/\1/p' < "$CONFIGURE_AC")"
125
if test "x$tmp" = "xAC_LIBLTDL_"; then
126
AG_LIBLTDL_DIR="libltdl"
131
AG_AUX="$(sed -n 's/^AC_CONFIG_AUX_DIR(\[\{0,1\}\([^])]*\).*/\1/p' < "$CONFIGURE_AC")"
132
if test "x$AG_AUX" = "x"; then
135
AG_CONFIG_H="$(sed -n 's/^\(A[CM]_CONFIG_HEADERS\?\)(\[\{0,1\}\([^]),]*\).*/\2/p' < "$CONFIGURE_AC")"
136
AG_CONFIG_K="$(sed -n 's/^\(A[CM]_CONFIG_HEADERS\?\)(\[\{0,1\}\([^]),]*\).*/\1/p' < "$CONFIGURE_AC")"
137
if echo "x$AG_CONFIG_H" | grep -q ':'; then
138
echo "$AG_CONFIG_K contains unsupported \`:' character: \`$AG_CONFIG_H'"
141
if test "x$AG_CONFIG_H" != "x"; then
142
AG_CONFIG_DIR="$(dirname "${AG_CONFIG_H}")"
143
AG_GEN_CONFIG_H="${AG_CONFIG_H} ${AG_CONFIG_H}.in ${AG_CONFIG_DIR}/stamp-h1 ${AG_CONFIG_DIR}/stamp-h2"
148
for d in "$AG_AUX" "$AG_CONFIG_DIR"; do
149
if test -n "$d" && test ! -d "$d"; then
153
AG_GEN_ACAM="aclocal.m4 configure $AG_AUX/config.guess $AG_AUX/config.sub $AG_AUX/compile"
154
AG_GEN_RECONF="$AG_AUX/install-sh $AG_AUX/missing $AG_AUX/depcomp"
155
AG_GEN_LIBTOOL="$AG_AUX/ltmain.sh libtool"
157
AG_GEN_LIBTOOL="${AG_GEN_LIBTOOL} ${AG_LIBLTDL_DIR}/${file}"
175
AG_GEN_GETTEXT="$AG_AUX/mkinstalldirs $AG_AUX/config.rpath ABOUT-NLS"
177
AG_GEN_GETTEXT="${AG_GEN_GETTEXT} m4/${file} m4m/${file}"
209
AG_GEN_GETTEXT="${AG_GEN_GETTEXT} po/${file}"
222
AG_GEN_CONF="config.status config.log"
223
AG_GEN_FILES="$AG_GEN_ACAM $AG_GEN_RECONF $AG_GEN_GETTEXT"
224
AG_GEN_FILES="$AG_GEN_FILES $AG_GEN_CONFIG_H $AG_GEN_CONF $AG_GEN_LIBTOOL"
225
AG_GEN_DIRS="autom4te.cache ${AG_LIBLTDL_DIR}/autom4te.cache ${AG_LIBLTDL_DIR}"
226
"$debug" && echo " done."
228
if "$debug"; then set | grep '^AG_'; fi
230
if "$dryrun"; then dryrun_param="--dry-run"; fi
234
########################################################################
235
# Print command to be executed and, if not dryrun, actually execute it.
238
if "$dryrun" || "$debug"; then
239
echo "Running <<" "$@" ">>"
241
if "$dryrun"; then :; else
247
########################################################################
248
# Clean generated files from $* directories
251
if test "x$AG_GEN_FILES" = "x"; then echo "Internal error"; exit 2; fi
253
#while test "$dir"; do
254
echo "$self:clean: Entering directory \`${dir}'"
257
echo -n "Cleaning autogen generated files..."
258
execute_command rm -rf ${AG_GEN_DIRS}
259
execute_command rm -f ${AG_GEN_FILES}
261
if test -h INSTALL; then execute_command rm -f INSTALL; fi
262
echo -n "Cleaning generated Makefile, Makefile.in files..."
263
if "$debug"; then echo; fi
264
find . -type f -name 'Makefile.am' -print | \
266
echo "$file" | grep -q '/{arch}' && continue
267
echo "$file" | grep -q '/\.svn' && continue
268
echo "$file" | grep -q '/CVS' && continue
269
base="$(dirname "$file")/$(basename "$file" .am)"
271
echo -e " Removing files created from ${file}"
273
execute_command rm -f "${base}" "${base}.in"
275
if "$debug"; then :; else echo " done."; fi
276
echo -n "Removing *~ backup files..."
277
find . -type f -name '*~' -print | while read fname; do
278
execute_command rm -f "$fname"
281
if test -n "${AG_SUBDIRS}"; then
282
"$0" --clean ${dryrun_param} --recursive ${AG_SUBDIRS}
286
echo "$self:clean: Left directory \`${dir}'"
293
########################################################################
294
# Initialize build system in $1 directory
298
if test "x$AG_GEN_FILES" = "x"; then echo "Internal error"; exit 2; fi
299
echo "$self:init: Entering directory \`${dir}'"
302
if test "x$AG_LIBLTDL_DIR" != "x"; then
303
# We have to run libtoolize --ltdl ourselves because
304
# - autoreconf doesn't run it at all
305
execute_command "${LIBTOOLIZE-"libtoolize"}" --ltdl
306
# And we have to clean up the generated files after libtoolize because
307
# - we still want symlinks for the files
308
# - but we want to (implicitly) AC_CONFIG_SUBDIR and that writes to
310
if test ! -d "${AG_LIBLTDL_DIR}" || test ! -f "${AG_LIBLTDL_DIR}/Makefile.am"; then
311
echo "Could not create libltdl directory \`${AG_LIBLTDL_DIR}'."
312
echo "Leaving \`$(pwd)' and aborting."
315
(cd "${AG_LIBLTDL_DIR}" && execute_command rm -f aclocal.m4 config.guess config.sub configure install-sh ltmain.sh Makefile.in missing)
317
if test -n "${AG_SUBDIRS}"; then
318
"$0" --init ${dryrun_param} --recursive ${AG_SUBDIRS}
320
if test "$status" -ne 0; then exit "$status"; fi
322
if "$recursive"; then :; else
323
if execute_command autoreconf --install --symlink ${AUTORECONF_OPTS}; then
326
echo "autoreconf quit with exit code $status, aborting."
329
echo "You may run ./configure now in \`${dir}'."
330
echo "Run as \"./configure --help\" to find out about config options."
336
# Just error propagation
338
echo "$self:init: Left directory \`${dir}'"
339
if test "$status" -ne "0"; then
345
########################################################################
346
# Parse command line.
347
# This still accepts more than the help text says it does, but that
350
commands="init" # default command in case none is given
353
dirs="$(dirname "$0")"
354
#dirs="$(cd "$dirs" && pwd)"
356
# Yes, unquoted $@ isn't space safe, but it works with simple shells.
360
pcommands="$pcommands clean"
363
pcommands="$pcommands init"
384
echo "Unhandled $self option: $param"
388
pdirs="${pdirs} ${param}"
392
if test "x$pcommands" != "x"; then
393
# commands given on command line? use them!
394
commands="$pcommands"
398
if test "x$pdirs" != "x"; then
399
# dirs given on command line? use them!
403
if "$check_versions"; then
404
# check tool versions
408
while read tool minversion; do
409
version="$("$tool" --version | sed 's/^.*(.*) *\(.*\)$/\1/g;1q')"
410
# compare version and minversion
411
first="$(echo "$version$lf$minversion" | sort -n | sed '1q')"
412
if test "x$minversion" != "x$first" && test "x$version" = "x$first"; then
413
echo "Version \`$version' of \`$tool' not sufficient. At least \`$minversion' required."
417
${ACLOCAL-"aclocal"} 1.8
418
${AUTOMAKE-"automake"} 1.8
419
${AUTOCONF-"autoconf"} 2.59
420
${AUTOHEADER-"autoheader"} 2.59
421
${AUTOPOINT-"autopoint"} 0.14.1
422
${LIBTOOLIZE-"libtoolize"} 1.4
425
echo "Please update your toolset."
426
echo "If you want to continue regardless of your old toolset, press ENTER."
432
########################################################################
433
# Actually run the commands
435
for dir in ${dirs}; do
436
"$debug" && echo "Running commands on directory \`${dir}'"
437
if test ! -d "$dir"; then
438
echo "Could not find directory \`${dir}'"
441
for command in ${commands}; do
442
"command_$command" "$dir"
448
# Please do not remove this:
449
# filetype: 89b1e88e-4cf2-44f1-980d-730067367775
450
# I use this to find all the different instances of this file which
451
# are supposed to be synchronized.