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.4}
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.3.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.
26 case `echo "testing\c"; echo 1,2,3`,`echo -n testing; echo 1,2,3` in
32 # some terminal codes ...
33 boldface
="`tput bold 2>/dev/null`"
34 normal
="`tput sgr0 2>/dev/null`"
36 echo $ECHO_N "$boldface"
38 echo $ECHO_N "$normal"
45 # compare_versions MIN_VERSION ACTUAL_VERSION
46 # returns true if ACTUAL_VERSION >= MIN_VERSION
51 IFS
="${IFS= }"; ch_save_IFS
="$IFS"; IFS
="."
52 set $ch_actual_version
53 for ch_min
in $ch_min_version; do
54 ch_cur
=`echo $1 | sed 's/[^0-9].*$//'`; shift # remove letter suffixes
55 if [ -z "$ch_min" ]; then break; fi
56 if [ -z "$ch_cur" ]; then ch_status
=1; break; fi
57 if [ $ch_cur -gt $ch_min ]; then break; fi
58 if [ $ch_cur -lt $ch_min ]; then ch_status
=1; break; fi
65 # version_check PACKAGE VARIABLE CHECKPROGS MIN_VERSION SOURCE
66 # checks to see if the package is available
75 vc_checkprog
=`eval echo "\\$$vc_variable"`
76 if [ -n "$vc_checkprog" ]; then
77 printbold
"using $vc_checkprog for $vc_package"
81 if test "x$vc_package" = "xautomake" -a "x$vc_min_version" = "x1.4"; then
86 printbold
"checking for $vc_package $vc_comparator $vc_min_version..."
87 for vc_checkprog
in $vc_checkprogs; do
88 echo $ECHO_N " testing $vc_checkprog... "
89 if $vc_checkprog --version < /dev
/null
> /dev
/null
2>&1; then
90 vc_actual_version
=`$vc_checkprog --version | head -n 1 | \
91 sed 's/^.*[ ]\([0-9.]*[a-z]*\).*$/\1/'`
92 if compare_versions
$vc_min_version $vc_actual_version; then
93 echo "found $vc_actual_version"
95 eval "$vc_variable=$vc_checkprog; \
96 ${vc_variable}_VERSION=$vc_actual_version"
100 echo "too old (found version $vc_actual_version)"
106 if [ "$vc_status" != 0 ]; then
107 printerr
"***Error***: You must have $vc_package $vc_comparator $vc_min_version installed"
108 printerr
" to build $PKG_NAME. Download the appropriate package for"
109 printerr
" from your distribution or get the source tarball at"
110 printerr
" $vc_source"
117 # require_m4macro filename.m4
118 # adds filename.m4 to the list of required macros
120 case "$REQUIRED_M4MACROS" in
121 $1\
* |
*\
$1\
* |
*\
$1) ;;
122 *) REQUIRED_M4MACROS
="$REQUIRED_M4MACROS $1" ;;
127 case "$FORBIDDEN_M4MACROS" in
128 $1\
* |
*\
$1\
* |
*\
$1) ;;
129 *) FORBIDDEN_M4MACROS
="$FORBIDDEN_M4MACROS $1" ;;
134 # add_to_cm_macrodirs dirname
135 # Adds the dir to $cm_macrodirs, if it's not there yet.
136 add_to_cm_macrodirs
() {
137 case $cm_macrodirs in
138 "$1 "* |
*" $1 "* |
*" $1") ;;
139 *) cm_macrodirs
="$cm_macrodirs $1";;
145 # Checks that all the requested macro files are in the aclocal macro path
146 # Uses REQUIRED_M4MACROS and ACLOCAL variables.
148 # construct list of macro directories
149 cm_macrodirs
=`$ACLOCAL --print-ac-dir`
150 # aclocal also searches a version specific dir, eg. /usr/share/aclocal-1.9
151 # but it contains only Automake's own macros, so we can ignore it.
153 # Read the dirlist file, supported by Automake >= 1.7.
154 if compare_versions
1.7 $AUTOMAKE_VERSION && [ -s $cm_macrodirs/dirlist
]; then
155 cm_dirlist
=`sed 's/[ ]*#.*//;/^$/d' $cm_macrodirs/dirlist`
156 if [ -n "$cm_dirlist" ] ; then
157 for cm_dir
in $cm_dirlist; do
158 if [ -d $cm_dir ]; then
159 add_to_cm_macrodirs
$cm_dir
165 # Parse $ACLOCAL_FLAGS
167 while [ $# -gt 0 ]; do
168 if [ "$1" = "-I" ]; then
169 add_to_cm_macrodirs
"$2"
176 if [ -n "$REQUIRED_M4MACROS" ]; then
177 printbold
"Checking for required M4 macros..."
178 # check that each macro file is in one of the macro dirs
179 for cm_macro
in $REQUIRED_M4MACROS; do
181 for cm_dir
in $cm_macrodirs; do
182 if [ -f "$cm_dir/$cm_macro" ]; then
186 # The macro dir in Cygwin environments may contain a file
187 # called dirlist containing other directories to look in.
188 if [ -f "$cm_dir/dirlist" ]; then
189 for cm_otherdir
in `cat $cm_dir/dirlist`; do
190 if [ -f "$cm_otherdir/$cm_macro" ]; then
197 if $cm_macrofound; then
200 printerr
" $cm_macro not found"
205 if [ -n "$FORBIDDEN_M4MACROS" ]; then
206 printbold
"Checking for forbidden M4 macros..."
207 # check that each macro file is in one of the macro dirs
208 for cm_macro
in $FORBIDDEN_M4MACROS; do
210 for cm_dir
in $cm_macrodirs; do
211 if [ -f "$cm_dir/$cm_macro" ]; then
216 if $cm_macrofound; then
217 printerr
" $cm_macro found (should be cleared from macros dir)"
222 if [ "$cm_status" != 0 ]; then
223 printerr
"***Error***: some autoconf macros required to build $PKG_NAME"
224 printerr
" were not found in your aclocal path, or some forbidden"
225 printerr
" macros were found. Perhaps you need to adjust your"
226 printerr
" ACLOCAL_FLAGS?"
232 # try to catch the case where the macros2/ directory hasn't been cleared out.
233 forbid_m4macro gnome-cxx-check.
m4
237 want_glib_gettext
=false
239 want_pkg_config
=false
241 want_gnome_doc_utils
=false
243 configure_files
="`find $srcdir -name '{arch}' -prune -o -name '.?*' -prune -o -name configure.ac -print -o -name configure.in -print`"
244 for configure_ac
in $configure_files; do
245 if grep "^A[CM]_PROG_LIBTOOL" $configure_ac >/dev
/null ||
246 grep "^LT_INIT" $configure_ac >/dev
/null
; then
249 if grep "^AM_GNU_GETTEXT" $configure_ac >/dev
/null
; then
252 if grep "^AM_GLIB_GNU_GETTEXT" $configure_ac >/dev
/null
; then
253 want_glib_gettext
=true
255 if grep "^AC_PROG_INTLTOOL" $configure_ac >/dev
/null ||
256 grep "^IT_PROG_INTLTOOL" $configure_ac >/dev
/null
; then
259 if grep "^PKG_CHECK_MODULES" $configure_ac >/dev
/null
; then
262 if grep "^GTK_DOC_CHECK" $configure_ac >/dev
/null
; then
265 if grep "^GNOME_DOC_INIT" $configure_ac >/dev
/null
; then
266 want_gnome_doc_utils
=true
269 # check to make sure gnome-common macros can be found ...
270 if grep "^GNOME_COMMON_INIT" $configure_ac >/dev
/null ||
271 grep "^GNOME_DEBUG_CHECK" $configure_ac >/dev
/null ||
272 grep "^GNOME_MAINTAINER_MODE_DEFINES" $configure_ac >/dev
/null
; then
273 require_m4macro gnome-common.
m4
275 if grep "^GNOME_COMPILE_WARNINGS" $configure_ac >/dev
/null ||
276 grep "^GNOME_CXX_WARNINGS" $configure_ac >/dev
/null
; then
277 require_m4macro gnome-compiler-flags.
m4
283 #tell Mandrake autoconf wrapper we want autoconf 2.5x, not 2.13
285 export WANT_AUTOCONF_2_5
286 version_check autoconf AUTOCONF
'autoconf2.50 autoconf autoconf-2.53' $REQUIRED_AUTOCONF_VERSION \
287 "http://ftp.gnu.org/pub/gnu/autoconf/autoconf-$REQUIRED_AUTOCONF_VERSION.tar.gz" || DIE
=1
288 AUTOHEADER
=`echo $AUTOCONF | sed s/autoconf/autoheader/`
290 case $REQUIRED_AUTOMAKE_VERSION in
291 1.4*) automake_progs
="automake-1.4" ;;
292 1.5*) automake_progs
="automake-1.5 automake-1.6 automake-1.7 automake-1.8 automake-1.9" ;;
293 1.6*) automake_progs
="automake-1.6 automake-1.7 automake-1.8 automake-1.9" ;;
294 1.7*) automake_progs
="automake-1.7 automake-1.8 automake-1.9" ;;
295 1.8*) automake_progs
="automake-1.8 automake-1.9" ;;
296 1.9*) automake_progs
="automake-1.9" ;;
298 version_check automake AUTOMAKE
"$automake_progs" $REQUIRED_AUTOMAKE_VERSION \
299 "http://ftp.gnu.org/pub/gnu/automake/automake-$REQUIRED_AUTOMAKE_VERSION.tar.gz" || DIE
=1
300 ACLOCAL
=`echo $AUTOMAKE | sed s/automake/aclocal/`
302 if $want_libtool; then
303 version_check libtool LIBTOOLIZE libtoolize
$REQUIRED_LIBTOOL_VERSION \
304 "http://ftp.gnu.org/pub/gnu/libtool/libtool-$REQUIRED_LIBTOOL_VERSION.tar.gz" || DIE
=1
305 require_m4macro libtool.
m4
308 if $want_gettext; then
309 version_check
gettext GETTEXTIZE gettextize
$REQUIRED_GETTEXT_VERSION \
310 "http://ftp.gnu.org/pub/gnu/gettext/gettext-$REQUIRED_GETTEXT_VERSION.tar.gz" || DIE
=1
311 require_m4macro
gettext.
m4
314 if $want_glib_gettext; then
315 version_check glib-gettext GLIB_GETTEXTIZE glib-gettextize
$REQUIRED_GLIB_GETTEXT_VERSION \
316 "ftp://ftp.gtk.org/pub/gtk/v2.2/glib-$REQUIRED_GLIB_GETTEXT_VERSION.tar.gz" || DIE
=1
317 require_m4macro glib-gettext.
m4
320 if $want_intltool; then
321 version_check intltool INTLTOOLIZE intltoolize
$REQUIRED_INTLTOOL_VERSION \
322 "http://ftp.gnome.org/pub/GNOME/sources/intltool/" || DIE
=1
323 require_m4macro intltool.
m4
326 if $want_pkg_config; then
327 version_check pkg-config PKG_CONFIG pkg-config
$REQUIRED_PKG_CONFIG_VERSION \
328 "'http://www.freedesktop.org/software/pkgconfig/releases/pkgconfig-$REQUIRED_PKG_CONFIG_VERSION.tar.gz" || DIE
=1
329 require_m4macro pkg.
m4
332 if $want_gtk_doc; then
333 version_check gtk-doc GTKDOCIZE gtkdocize
$REQUIRED_GTK_DOC_VERSION \
334 "http://ftp.gnome.org/pub/GNOME/sources/gtk-doc/" || DIE
=1
335 require_m4macro gtk-doc.
m4
338 if $want_gnome_doc_utils; then
339 version_check gnome-doc-utils GNOME_DOC_PREPARE gnome-doc-prepare
$REQUIRED_GNOME_DOC_UTILS_VERSION \
340 "http://ftp.gnome.org/pub/GNOME/sources/gnome-doc-utils/" || DIE
=1
343 if [ "x$USE_COMMON_DOC_BUILD" = "xyes" ]; then
344 version_check gnome-common DOC_COMMON gnome-doc-common \
345 $REQUIRED_DOC_COMMON_VERSION " " || DIE
=1
348 check_m4macros || DIE
=1
350 if [ "$DIE" -eq 1 ]; then
354 if [ "$#" = 0 ]; then
355 printerr
"**Warning**: I am going to run \`configure' with no arguments."
356 printerr
"If you wish to pass any to it, please specify them on the"
357 printerr \
`$0\'" command line."
362 for configure_ac in $configure_files; do
363 dirname=`dirname $configure_ac`
364 basename=`basename $configure_ac`
365 if [ -f $dirname/NO-AUTO-GEN ]; then
366 echo skipping $dirname -- flagged as no auto-gen
367 elif [ ! -w $dirname ]; then
368 echo skipping $dirname -- directory is read only
370 printbold "Processing $configure_ac"
373 # Note that the order these tools are called should match what
374 # autoconf's "autoupdate" package does. See bug 138584 for
377 # programs that might install new macros get run before aclocal
378 if grep "^A[CM]_PROG_LIBTOOL" $basename >/dev/null ||
379 grep "^LT_INIT" $basename >/dev/null; then
380 printbold "Running $LIBTOOLIZE..."
381 $LIBTOOLIZE --force --copy || exit 1
384 if grep "^AM_GLIB_GNU_GETTEXT" $basename >/dev/null; then
385 printbold "Running $GLIB_GETTEXTIZE... Ignore non-fatal messages."
386 echo "no" | $GLIB_GETTEXTIZE --force --copy || exit 1
387 elif grep "^AM_GNU_GETTEXT" $basename >/dev/null; then
388 if grep "^AM_GNU_GETTEXT_VERSION" $basename > /dev/null; then
389 printbold "Running autopoint..."
390 autopoint --force || exit 1
392 printbold "Running $GETTEXTIZE... Ignore non-fatal messages."
393 echo "no" | $GETTEXTIZE --force --copy || exit 1
397 if grep "^AC_PROG_INTLTOOL" $basename >/dev/null ||
398 grep "^IT_PROG_INTLTOOL" $basename >/dev/null; then
399 printbold "Running $INTLTOOLIZE..."
400 $INTLTOOLIZE --force --copy --automake || exit 1
402 if grep "^GTK_DOC_CHECK" $basename >/dev/null; then
403 printbold "Running $GTKDOCIZE..."
404 $GTKDOCIZE --copy || exit 1
407 if [ "x$USE_COMMON_DOC_BUILD" = "xyes" ]; then
408 printbold "Running gnome-doc-common..."
409 gnome-doc-common --copy || exit 1
411 if grep "^GNOME_DOC_INIT" $basename >/dev/null; then
412 printbold "Running $GNOME_DOC_PREPARE..."
413 $GNOME_DOC_PREPARE --force --copy || exit 1
416 # Now run aclocal to pull in any additional macros needed
418 # if the AC_CONFIG_MACRO_DIR() macro is used, pass that
419 # directory to aclocal.
420 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
`
421 if [ -n "$m4dir" ]; then
424 printbold "Running $ACLOCAL..."
425 $ACLOCAL $m4dir $ACLOCAL_FLAGS || exit 1
427 if grep "GNOME_AUTOGEN_OBSOLETE" aclocal.m4 >/dev/null; then
428 printerr "*** obsolete gnome macros were used in $configure_ac"
431 # Now that all the macros are sorted, run autoconf and autoheader ...
432 printbold "Running $AUTOCONF..."
434 if grep "^A[CM]_CONFIG_HEADER" $basename >/dev/null; then
435 printbold "Running $AUTOHEADER..."
436 $AUTOHEADER || exit 1
437 # this prevents automake from thinking config.h.in is out of
438 # date, since autoheader doesn't touch the file if it doesn't
440 test -f config.h.in && touch config.h.in
443 # Finally, run automake to create the makefiles ...
444 printbold "Running $AUTOMAKE..."
445 cp -pf COPYING COPYING.autogen_bak
446 cp -pf INSTALL INSTALL.autogen_bak
447 if [ $REQUIRED_AUTOMAKE_VERSION != 1.4 ]; then
448 $AUTOMAKE --gnu --add-missing --force --copy || exit 1
450 $AUTOMAKE --gnu --add-missing --copy || exit 1
452 cmp COPYING COPYING.autogen_bak || cp -pf COPYING.autogen_bak COPYING
453 cmp INSTALL INSTALL.autogen_bak || cp -pf INSTALL.autogen_bak INSTALL
454 rm -f COPYING.autogen_bak INSTALL.autogen_bak
460 conf_flags="--enable-maintainer-mode"
462 if test x$NOCONFIGURE = x; then
463 printbold Running $srcdir/configure $conf_flags "$@" ...
464 $srcdir/configure $conf_flags "$@" \
465 && echo Now type \`make\' to compile
$PKG_NAME ||
exit 1
467 echo Skipping configure process.