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
19 self="$(basename "$0")"
20 autogen_version="0.3.2"
23 ########################################################################
28 $self - initialize automake/autoconf/gettext/libtool based build system
31 $self [<command>...] [<directory>...]
33 Runs given command sequence on all given directories, in sequence.
34 If there is no command given, --init is assumed.
35 If there is no directory given, the location of $self is assumed.
41 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
52 $self depends on automake, autoconf, libtool and gettext.
54 You may want to set AUTOCONF, AUTOHEADER, AUTOMAKE, ACLOCAL,
55 AUTOPOINT, LIBTOOLIZE to use specific version of these tools, and
56 AUTORECONF_OPTS to add options to the call to autoreconf.
61 ########################################################################
62 # Print software versions
65 echo "${self} (ndim's autogen) ${autogen_version}"
67 "${AUTOCONF-autoconf}" \
68 "${AUTOMAKE-automake}" \
69 "${AUTOPOINT-autopoint}" \
70 "${LIBTOOLIZE-libtoolize}"
72 "$tool" --version 2>&1 | sed '1q'
77 ########################################################################
78 # Initialize variables for configure.{in,ac} in $1
82 echo -n "Looking for \`${dir}/configure.{ac,in}'..."
83 # There are shells which don't understand {,} wildcards
85 for tmp in "${dir}/configure.ac" "${dir}/configure.in"; do
86 if test -f "$tmp"; then
92 if test "x$CONFIGURE_AC" = "x"; then
98 if test "$(uname -o)" = "Cygwin"; then
99 # Cygwin autoreconf doesn't understand -Wall
100 AUTORECONF_OPTS="$AUTORECONF_OPTS --verbose"
102 AUTORECONF_OPTS="$AUTORECONF_OPTS --verbose -Wall"
106 echo -n "Initializing variables for \`${dir}'..."
107 # FIXME: Just getting those directories and cleaning them isn't enough.
108 # OK, the "init" part is done recursively by autopoint, so that is easy.
109 # But the cleaning should also work recursively, but that is difficult
110 # with the current structure of the script.
111 AG_SUBDIRS="$(for k in $(sed -n 's/^[[:space:]]*AC_CONFIG_SUBDIRS(\[\{0,1\}\([^])]*\).*/\1/p' "$CONFIGURE_AC"); do echo "${dir}/${k}"; done)"
112 AG_AUX="$(sed -n 's/^AC_CONFIG_AUX_DIR(\[\{0,1\}\([^])]*\).*/\1/p' < "$CONFIGURE_AC")"
113 if test "x$AG_AUX" = "x"; then
116 AG_CONFIG_H="$(sed -n 's/^\(A[CM]_CONFIG_HEADERS\?\)(\[\{0,1\}\([^]),]*\).*/\2/p' < "$CONFIGURE_AC")"
117 AG_CONFIG_K="$(sed -n 's/^\(A[CM]_CONFIG_HEADERS\?\)(\[\{0,1\}\([^]),]*\).*/\1/p' < "$CONFIGURE_AC")"
118 if echo "x$AG_CONFIG_H" | grep -q ':'; then
119 echo "$AG_CONFIG_K contains unsupported \`:' character: \`$AG_CONFIG_H'"
122 if test "x$AG_CONFIG_H" != "x"; then
123 AG_CONFIG_DIR="$(dirname "${AG_CONFIG_H}")"
124 AG_GEN_CONFIG_H="${AG_CONFIG_H} ${AG_CONFIG_H}.in ${AG_CONFIG_DIR}/stamp-h1 ${AG_CONFIG_DIR}/stamp-h2"
129 for d in "$AG_AUX" "$AG_CONFIG_DIR"; do
130 if test -n "$d" && test ! -d "$d"; then
134 AG_GEN_ACAM="aclocal.m4 configure $AG_AUX/config.guess $AG_AUX/config.sub $AG_AUX/compile"
135 AG_GEN_RECONF="$AG_AUX/install-sh $AG_AUX/missing $AG_AUX/depcomp"
136 AG_GEN_GETTEXT="$AG_AUX/mkinstalldirs $AG_AUX/config.rpath ABOUT-NLS"
138 AG_GEN_GETTEXT="${AG_GEN_GETTEXT} ${file}"
200 po/en@boldquot.header
204 po/remove-potcdate.sin
207 AG_GEN_CONF="config.status config.log"
208 AG_GEN_LIBTOOL="$AG_AUX/ltmain.sh libtool"
209 AG_GEN_FILES="$AG_GEN_ACAM $AG_GEN_RECONF $AG_GEN_GETTEXT"
210 AG_GEN_FILES="$AG_GEN_FILES $AG_GEN_CONFIG_H $AG_GEN_CONF $AG_GEN_LIBTOOL"
211 AG_GEN_DIRS="autom4te.cache"
214 if "$debug"; then set | grep '^AG_'; fi
218 ########################################################################
219 # Clean generated files from $* directories
222 if test "x$AG_GEN_FILES" = "x"; then echo "Internal error"; exit 2; fi
224 while test "$dir"; do
225 echo "$self:clean: Entering directory \`${dir}'"
228 echo -n "Cleaning autogen generated files..."
229 rm -rf ${AG_GEN_DIRS}
230 rm -f ${AG_GEN_FILES}
232 if test -h INSTALL; then rm -f INSTALL; fi
233 echo -n "Cleaning generated Makefile, Makefile.in files..."
234 if "$debug"; then echo; fi
235 find . -type f -name 'Makefile.am' -print | \
237 echo "$file" | grep -q '/{arch}' && continue
238 echo "$file" | grep -q '/\.svn' && continue
239 echo "$file" | grep -q '/CVS' && continue
240 base="$(dirname "$file")/$(basename "$file" .am)"
242 echo -e " Removing files created from ${file}"
244 rm -f "${base}" "${base}.in"
246 if "$debug"; then :; else echo " done."; fi
247 echo -n "Removing *~ backup files..."
248 find . -type f -name '*~' -exec rm -f {} \;
252 echo "$self:clean: Left directory \`${dir}'"
259 ########################################################################
260 # Initialize build system in $1 directory
264 if test "x$AG_GEN_FILES" = "x"; then echo "Internal error"; exit 2; fi
265 echo "$self:init: Entering directory \`${dir}'"
268 echo "Running <<" autoreconf --install --symlink ${AUTORECONF_OPTS} ">>"
269 if autoreconf --install --symlink ${AUTORECONF_OPTS}; then
272 echo "autoreconf quit with exit code $status, aborting."
275 echo "You may run ./configure now in \`${dir}'."
276 echo "Run as \"./configure --help\" to find out about config options."
281 # Just error propagation
283 echo "$self:init: Left directory \`${dir}'"
284 if test "$status" -ne "0"; then
290 ########################################################################
291 # Parse command line.
292 # This still accepts more than the help text says it does, but that
295 commands="init" # default command in case none is given
298 dirs="$(dirname "$0")"
299 #dirs="$(cd "$dirs" && pwd)"
301 # Yes, unquoted $@ isn't space safe, but it works with simple shells.
305 pcommands="$pcommands clean"
308 pcommands="$pcommands init"
323 echo "Unhandled $self option: $param"
327 pdirs="${pdirs} ${param}"
331 if test "x$pcommands" != "x"; then
332 # commands given on command line? use them!
333 commands="$pcommands"
337 if test "x$pdirs" != "x"; then
338 # dirs given on command line? use them!
342 if "$check_versions"; then
343 # check tool versions
347 while read tool minversion; do
348 version="$("$tool" --version | sed 's/^.*(.*) *\(.*\)$/\1/g;1q')"
349 first="$(echo "$version$lf$minversion" | sort -n | sed '1q')"
350 if test "x$minversion" != "x$first" && test "x$version" = "x$first"; then
351 echo "Version \`$version' of \`$tool' not sufficient. At least \`$minversion' required."
355 ${ACLOCAL-"aclocal"} 1.8
356 ${AUTOMAKE-"automake"} 1.8
357 ${AUTOCONF-"autoconf"} 2.59
358 ${AUTOHEADER-"autoheader"} 2.59
359 ${AUTOPOINT-"autopoint"} 0.14.1
360 ${LIBTOOLIZE-"libtoolize"} 1.4
363 echo "Please update your toolset."
364 echo "If you want to continue regardless of your old toolset, press ENTER."
370 ########################################################################
371 # Actually run the commands
373 for dir in ${dirs}; do
374 echo "Running commands on directory \`${dir}'"
375 if test ! -d "$dir"; then
376 echo "Could not find directory \`${dir}'"
379 for command in ${commands}; do
380 "$command" "$dir" ${AG_SUBDIRS}
386 # Please do not remove this:
387 # filetype: 89b1e88e-4cf2-44f1-980d-730067367775
388 # I use this to find all the different instances of this file which
389 # are supposed to be synchronized.