2 # Run this to generate all the initial makefiles, etc.
5 PKG_NAME=${PKG_NAME:-Package}
8 # default version requirements ...
9 REQUIRED_AUTOCONF_VERSION=${REQUIRED_AUTOCONF_VERSION:-2.53}
10 REQUIRED_AUTOMAKE_VERSION=${REQUIRED_AUTOMAKE_VERSION:-1.9}
11 REQUIRED_LIBTOOL_VERSION=${REQUIRED_LIBTOOL_VERSION:-1.4.3}
12 REQUIRED_GETTEXT_VERSION=${REQUIRED_GETTEXT_VERSION:-0.10.40}
13 REQUIRED_GLIB_GETTEXT_VERSION=${REQUIRED_GLIB_GETTEXT_VERSION:-2.2.0}
14 REQUIRED_INTLTOOL_VERSION=${REQUIRED_INTLTOOL_VERSION:-0.25}
15 REQUIRED_PKG_CONFIG_VERSION=${REQUIRED_PKG_CONFIG_VERSION:-0.14.0}
16 REQUIRED_GTK_DOC_VERSION=${REQUIRED_GTK_DOC_VERSION:-1.0}
17 REQUIRED_DOC_COMMON_VERSION=${REQUIRED_DOC_COMMON_VERSION:-2.3.0}
18 REQUIRED_GNOME_DOC_UTILS_VERSION=${REQUIRED_GNOME_DOC_UTILS_VERSION:-0.4.2}
20 # a list of required m4 macros. Package can set an initial value
21 REQUIRED_M4MACROS=${REQUIRED_M4MACROS:-}
22 FORBIDDEN_M4MACROS=${FORBIDDEN_M4MACROS:-}
24 # Not all echo versions allow -n, so we check what is possible. This test is
25 # based on the one in autoconf.
38 # some terminal codes ...
39 boldface="`tput bold 2>/dev/null`"
40 normal="`tput sgr0 2>/dev/null`"
42 echo $ECHO_N "$boldface" $ECHO_C
44 echo $ECHO_N "$normal" $ECHO_C
51 # compare_versions MIN_VERSION ACTUAL_VERSION
52 # returns true if ACTUAL_VERSION >= MIN_VERSION
57 IFS="${IFS= }"; ch_save_IFS="$IFS"; IFS="."
58 set $ch_actual_version
59 for ch_min in $ch_min_version; do
60 ch_cur=`echo $1 | sed 's/[^0-9].*$//'`; shift # remove letter suffixes
61 if [ -z "$ch_min" ]; then break; fi
62 if [ -z "$ch_cur" ]; then ch_status=1; break; fi
63 if [ $ch_cur -gt $ch_min ]; then break; fi
64 if [ $ch_cur -lt $ch_min ]; then ch_status=1; break; fi
71 # version_check PACKAGE VARIABLE CHECKPROGS MIN_VERSION SOURCE
72 # checks to see if the package is available
81 vc_checkprog=`eval echo "\\$$vc_variable"`
82 if [ -n "$vc_checkprog" ]; then
83 printbold "using $vc_checkprog for $vc_package"
87 if test "x$vc_package" = "xautomake" -a "x$vc_min_version" = "x1.4"; then
92 printbold "checking for $vc_package $vc_comparator $vc_min_version..."
93 for vc_checkprog in $vc_checkprogs; do
94 echo $ECHO_N " testing $vc_checkprog... " $ECHO_C
95 if $vc_checkprog --version < /dev/null > /dev/null 2>&1; then
96 vc_actual_version=`$vc_checkprog --version | head -n 1 | \
97 sed 's/^.*[ ]\([0-9.]*[a-z]*\).*$/\1/'`
98 if compare_versions $vc_min_version $vc_actual_version; then
99 echo "found $vc_actual_version"
101 eval "$vc_variable=$vc_checkprog; \
102 ${vc_variable}_VERSION=$vc_actual_version"
106 echo "too old (found version $vc_actual_version)"
112 if [ "$vc_status" != 0 ]; then
113 printerr "***Error***: You must have $vc_package $vc_comparator $vc_min_version installed"
114 printerr " to build $PKG_NAME. Download the appropriate package for"
115 printerr " from your distribution or get the source tarball at"
116 printerr " $vc_source"
124 # require_m4macro filename.m4
125 # adds filename.m4 to the list of required macros
127 case "$REQUIRED_M4MACROS" in
128 $1\ * | *\ $1\ * | *\ $1) ;;
129 *) REQUIRED_M4MACROS="$REQUIRED_M4MACROS $1" ;;
134 case "$FORBIDDEN_M4MACROS" in
135 $1\ * | *\ $1\ * | *\ $1) ;;
136 *) FORBIDDEN_M4MACROS="$FORBIDDEN_M4MACROS $1" ;;
141 # add_to_cm_macrodirs dirname
142 # Adds the dir to $cm_macrodirs, if it's not there yet.
143 add_to_cm_macrodirs() {
144 case $cm_macrodirs in
145 "$1 "* | *" $1 "* | *" $1") ;;
146 *) cm_macrodirs="$cm_macrodirs $1";;
151 # print_m4macros_error
152 # Prints an error message saying that autoconf macros were misused
153 print_m4macros_error() {
154 printerr "***Error***: some autoconf macros required to build $PKG_NAME"
155 printerr " were not found in your aclocal path, or some forbidden"
156 printerr " macros were found. Perhaps you need to adjust your"
157 printerr " ACLOCAL_FLAGS?"
163 # Checks that all the requested macro files are in the aclocal macro path
164 # Uses REQUIRED_M4MACROS and ACLOCAL variables.
166 # construct list of macro directories
167 cm_macrodirs=`$ACLOCAL --print-ac-dir`
168 # aclocal also searches a version specific dir, eg. /usr/share/aclocal-1.9
169 # but it contains only Automake's own macros, so we can ignore it.
171 # Read the dirlist file, supported by Automake >= 1.7.
172 if compare_versions 1.7 $AUTOMAKE_VERSION && [ -s $cm_macrodirs/dirlist ]; then
173 cm_dirlist=`sed 's/[ ]*#.*//;/^$/d' $cm_macrodirs/dirlist`
174 if [ -n "$cm_dirlist" ] ; then
175 for cm_dir in $cm_dirlist; do
176 if [ -d $cm_dir ]; then
177 add_to_cm_macrodirs $cm_dir
183 # Parse $ACLOCAL_FLAGS
185 while [ $# -gt 0 ]; do
186 if [ "$1" = "-I" ]; then
187 add_to_cm_macrodirs "$2"
194 if [ -n "$REQUIRED_M4MACROS" ]; then
195 printbold "Checking for required M4 macros..."
196 # check that each macro file is in one of the macro dirs
197 for cm_macro in $REQUIRED_M4MACROS; do
199 for cm_dir in $cm_macrodirs; do
200 if [ -f "$cm_dir/$cm_macro" ]; then
204 # The macro dir in Cygwin environments may contain a file
205 # called dirlist containing other directories to look in.
206 if [ -f "$cm_dir/dirlist" ]; then
207 for cm_otherdir in `cat $cm_dir/dirlist`; do
208 if [ -f "$cm_otherdir/$cm_macro" ]; then
215 if $cm_macrofound; then
218 printerr " $cm_macro not found"
223 if [ "$cm_status" != 0 ]; then
227 if [ -n "$FORBIDDEN_M4MACROS" ]; then
228 printbold "Checking for forbidden M4 macros..."
229 # check that each macro file is in one of the macro dirs
230 for cm_macro in $FORBIDDEN_M4MACROS; do
232 for cm_dir in $cm_macrodirs; do
233 if [ -f "$cm_dir/$cm_macro" ]; then
238 if $cm_macrofound; then
239 printerr " $cm_macro found (should be cleared from macros dir)"
244 if [ "$cm_status" != 0 ]; then
250 # try to catch the case where the macros2/ directory hasn't been cleared out.
251 forbid_m4macro gnome-cxx-check.m4
255 want_glib_gettext=false
257 want_pkg_config=false
259 want_gnome_doc_utils=false
261 configure_files="`find $srcdir -name '{arch}' -prune -o -name '_darcs' -prune -o -name '.??*' -prune -o -name configure.ac -print -o -name configure.in -print`"
262 for configure_ac in $configure_files; do
263 dirname=`dirname $configure_ac`
264 if [ -f $dirname/NO-AUTO-GEN ]; then
265 echo skipping $dirname -- flagged as no auto-gen
268 if grep "^A[CM]_PROG_LIBTOOL" $configure_ac >/dev/null ||
269 grep "^LT_INIT" $configure_ac >/dev/null; then
272 if grep "^AM_GNU_GETTEXT" $configure_ac >/dev/null; then
275 if grep "^AM_GLIB_GNU_GETTEXT" $configure_ac >/dev/null; then
276 want_glib_gettext=true
278 if grep "^AC_PROG_INTLTOOL" $configure_ac >/dev/null ||
279 grep "^IT_PROG_INTLTOOL" $configure_ac >/dev/null; then
282 if grep "^PKG_CHECK_MODULES" $configure_ac >/dev/null; then
285 if grep "^GTK_DOC_CHECK" $configure_ac >/dev/null; then
288 if grep "^GNOME_DOC_INIT" $configure_ac >/dev/null; then
289 want_gnome_doc_utils=true
292 # check to make sure gnome-common macros can be found ...
293 if grep "^GNOME_COMMON_INIT" $configure_ac >/dev/null ||
294 grep "^GNOME_DEBUG_CHECK" $configure_ac >/dev/null ||
295 grep "^GNOME_MAINTAINER_MODE_DEFINES" $configure_ac >/dev/null; then
296 require_m4macro gnome-common.m4
298 if grep "^GNOME_COMPILE_WARNINGS" $configure_ac >/dev/null ||
299 grep "^GNOME_CXX_WARNINGS" $configure_ac >/dev/null; then
300 require_m4macro gnome-compiler-flags.m4
304 #tell Mandrake autoconf wrapper we want autoconf 2.5x, not 2.13
306 export WANT_AUTOCONF_2_5
307 version_check autoconf AUTOCONF 'autoconf2.50 autoconf autoconf-2.53' $REQUIRED_AUTOCONF_VERSION \
308 "http://ftp.gnu.org/pub/gnu/autoconf/autoconf-$REQUIRED_AUTOCONF_VERSION.tar.gz"
309 AUTOHEADER=`echo $AUTOCONF | sed s/autoconf/autoheader/`
311 case $REQUIRED_AUTOMAKE_VERSION in
312 1.4*) automake_progs="automake-1.4" ;;
313 1.5*) automake_progs="automake-1.10 automake-1.9 automake-1.8 automake-1.7 automake-1.6 automake-1.5" ;;
314 1.6*) automake_progs="automake-1.10 automake-1.9 automake-1.8 automake-1.7 automake-1.6" ;;
315 1.7*) automake_progs="automake-1.10 automake-1.9 automake-1.8 automake-1.7" ;;
316 1.8*) automake_progs="automake-1.10 automake-1.9 automake-1.8" ;;
317 1.9*) automake_progs="automake-1.10 automake-1.9" ;;
318 1.10*) automake_progs="automake-1.10" ;;
320 version_check automake AUTOMAKE "$automake_progs" $REQUIRED_AUTOMAKE_VERSION \
321 "http://ftp.gnu.org/pub/gnu/automake/automake-$REQUIRED_AUTOMAKE_VERSION.tar.gz"
322 ACLOCAL=`echo $AUTOMAKE | sed s/automake/aclocal/`
324 if $want_libtool; then
325 version_check libtool LIBTOOLIZE libtoolize $REQUIRED_LIBTOOL_VERSION \
326 "http://ftp.gnu.org/pub/gnu/libtool/libtool-$REQUIRED_LIBTOOL_VERSION.tar.gz"
327 require_m4macro libtool.m4
330 if $want_gettext; then
331 version_check gettext GETTEXTIZE gettextize $REQUIRED_GETTEXT_VERSION \
332 "http://ftp.gnu.org/pub/gnu/gettext/gettext-$REQUIRED_GETTEXT_VERSION.tar.gz"
333 require_m4macro gettext.m4
336 if $want_glib_gettext; then
337 version_check glib-gettext GLIB_GETTEXTIZE glib-gettextize $REQUIRED_GLIB_GETTEXT_VERSION \
338 "ftp://ftp.gtk.org/pub/gtk/v2.2/glib-$REQUIRED_GLIB_GETTEXT_VERSION.tar.gz"
339 require_m4macro glib-gettext.m4
342 if $want_intltool; then
343 version_check intltool INTLTOOLIZE intltoolize $REQUIRED_INTLTOOL_VERSION \
344 "http://ftp.gnome.org/pub/GNOME/sources/intltool/"
345 require_m4macro intltool.m4
348 if $want_pkg_config; then
349 version_check pkg-config PKG_CONFIG pkg-config $REQUIRED_PKG_CONFIG_VERSION \
350 "'http://www.freedesktop.org/software/pkgconfig/releases/pkgconfig-$REQUIRED_PKG_CONFIG_VERSION.tar.gz"
351 require_m4macro pkg.m4
354 if $want_gtk_doc; then
355 version_check gtk-doc GTKDOCIZE gtkdocize $REQUIRED_GTK_DOC_VERSION \
356 "http://ftp.gnome.org/pub/GNOME/sources/gtk-doc/"
357 require_m4macro gtk-doc.m4
360 if $want_gnome_doc_utils; then
361 version_check gnome-doc-utils GNOME_DOC_PREPARE gnome-doc-prepare $REQUIRED_GNOME_DOC_UTILS_VERSION \
362 "http://ftp.gnome.org/pub/GNOME/sources/gnome-doc-utils/"
365 if [ "x$USE_COMMON_DOC_BUILD" = "xyes" ]; then
366 version_check gnome-common DOC_COMMON gnome-doc-common \
367 $REQUIRED_DOC_COMMON_VERSION " "
372 if [ "$#" = 0 -a "x$NOCONFIGURE" = "x" ]; then
373 printerr "**Warning**: I am going to run \`configure' with no arguments."
374 printerr "If you wish to pass any to it, please specify them on the"
375 printerr \`$0\'" command line."
380 for configure_ac in $configure_files; do
381 dirname=`dirname $configure_ac`
382 basename=`basename $configure_ac`
383 if [ -f $dirname/NO-AUTO-GEN ]; then
384 echo skipping $dirname -- flagged as no auto-gen
385 elif [ ! -w $dirname ]; then
386 echo skipping $dirname -- directory is read only
388 printbold "Processing $configure_ac"
391 # Note that the order these tools are called should match what
392 # autoconf's "autoupdate" package does. See bug 138584 for
395 # programs that might install new macros get run before aclocal
396 if grep "^A[CM]_PROG_LIBTOOL" $basename >/dev/null ||
397 grep "^LT_INIT" $basename >/dev/null; then
398 printbold "Running $LIBTOOLIZE..."
399 $LIBTOOLIZE --force --copy || exit 1
402 if grep "^AM_GLIB_GNU_GETTEXT" $basename >/dev/null; then
403 printbold "Running $GLIB_GETTEXTIZE... Ignore non-fatal messages."
404 echo "no" | $GLIB_GETTEXTIZE --force --copy || exit 1
405 elif grep "^AM_GNU_GETTEXT" $basename >/dev/null; then
406 if grep "^AM_GNU_GETTEXT_VERSION" $basename > /dev/null; then
407 printbold "Running autopoint..."
408 autopoint --force || exit 1
410 printbold "Running $GETTEXTIZE... Ignore non-fatal messages."
411 echo "no" | $GETTEXTIZE --force --copy || exit 1
415 if grep "^AC_PROG_INTLTOOL" $basename >/dev/null ||
416 grep "^IT_PROG_INTLTOOL" $basename >/dev/null; then
417 printbold "Running $INTLTOOLIZE..."
418 $INTLTOOLIZE --force --copy --automake || exit 1
420 if grep "^GTK_DOC_CHECK" $basename >/dev/null; then
421 printbold "Running $GTKDOCIZE..."
422 $GTKDOCIZE --copy || exit 1
425 if [ "x$USE_COMMON_DOC_BUILD" = "xyes" ]; then
426 printbold "Running gnome-doc-common..."
427 gnome-doc-common --copy || exit 1
429 if grep "^GNOME_DOC_INIT" $basename >/dev/null; then
430 printbold "Running $GNOME_DOC_PREPARE..."
431 $GNOME_DOC_PREPARE --force --copy || exit 1
434 # Now run aclocal to pull in any additional macros needed
436 # if the AC_CONFIG_MACRO_DIR() macro is used, pass that
437 # directory to aclocal.
438 m4dir=`cat "$basename" | grep '^AC_CONFIG_MACRO_DIR' | sed -n -e 's/AC_CONFIG_MACRO_DIR(\([^()]*\))/\1/p' | sed -e 's/^\[\(.*\)\]$/\1/' | sed -e 1q`
439 if [ -n "$m4dir" ]; then
442 printbold "Running $ACLOCAL..."
443 $ACLOCAL $m4dir $ACLOCAL_FLAGS || exit 1
445 if grep "GNOME_AUTOGEN_OBSOLETE" aclocal.m4 >/dev/null; then
446 printerr "*** obsolete gnome macros were used in $configure_ac"
449 # Now that all the macros are sorted, run autoconf and autoheader ...
450 printbold "Running $AUTOCONF..."
452 if grep "^A[CM]_CONFIG_HEADER" $basename >/dev/null; then
453 printbold "Running $AUTOHEADER..."
454 $AUTOHEADER || exit 1
455 # this prevents automake from thinking config.h.in is out of
456 # date, since autoheader doesn't touch the file if it doesn't
458 test -f config.h.in && touch config.h.in
461 # Finally, run automake to create the makefiles ...
462 printbold "Running $AUTOMAKE..."
463 if [ -f COPYING ]; then
464 cp -pf COPYING COPYING.autogen_bak
466 if [ -f INSTALL ]; then
467 cp -pf INSTALL INSTALL.autogen_bak
469 if [ $REQUIRED_AUTOMAKE_VERSION != 1.4 ]; then
470 $AUTOMAKE --gnu --add-missing --force --copy || exit 1
472 $AUTOMAKE --gnu --add-missing --copy || exit 1
474 if [ -f COPYING.autogen_bak ]; then
475 cmp COPYING COPYING.autogen_bak > /dev/null || cp -pf COPYING.autogen_bak COPYING
476 rm -f COPYING.autogen_bak
478 if [ -f INSTALL.autogen_bak ]; then
479 cmp INSTALL INSTALL.autogen_bak > /dev/null || cp -pf INSTALL.autogen_bak INSTALL
480 rm -f INSTALL.autogen_bak
487 conf_flags="--enable-maintainer-mode"
489 if test x$NOCONFIGURE = x; then
490 printbold Running $srcdir/configure $conf_flags "$@" ...
491 $srcdir/configure $conf_flags "$@" \
492 && echo Now type \`make\' to compile $PKG_NAME || exit 1
494 echo Skipping configure process.