2015-01-09 14:56:20 +03:00
# Copyright 1999-2015 Gentoo Foundation
2011-11-09 11:33:19 +04:00
# Distributed under the terms of the GNU General Public License v2
# @ECLASS: autotools.eclass
# @MAINTAINER:
# base-system@gentoo.org
# @BLURB: Regenerates auto* build scripts
# @DESCRIPTION:
# This eclass is for safely handling autotooled software packages that need to
# regenerate their build scripts. All functions will abort in case of errors.
2011-12-16 10:22:42 +04:00
# Note: We require GNU m4, as does autoconf. So feel free to use any features
# from the GNU version of m4 without worrying about other variants (i.e. BSD).
2014-11-15 17:03:11 +03:00
if [ [ ${ __AUTOTOOLS_AUTO_DEPEND +set } = = "set" ] ] ; then
# See if we were included already, but someone changed the value
# of AUTOTOOLS_AUTO_DEPEND on us. We could reload the entire
# eclass at that point, but that adds overhead, and it's trivial
# to re-order inherit in eclasses/ebuilds instead. #409611
if [ [ ${ __AUTOTOOLS_AUTO_DEPEND } != ${ AUTOTOOLS_AUTO_DEPEND } ] ] ; then
die " AUTOTOOLS_AUTO_DEPEND changed value between inherits; please inherit autotools.eclass first! ${ __AUTOTOOLS_AUTO_DEPEND } -> ${ AUTOTOOLS_AUTO_DEPEND } "
fi
fi
2014-07-11 23:20:24 +04:00
if [ [ -z ${ _AUTOTOOLS_ECLASS } ] ] ; then
_AUTOTOOLS_ECLASS = 1
2011-12-14 10:06:15 +04:00
2014-11-21 18:45:09 +03:00
inherit libtool
2011-11-09 11:33:19 +04:00
# @ECLASS-VARIABLE: WANT_AUTOCONF
# @DESCRIPTION:
# The major version of autoconf your package needs
: ${ WANT_AUTOCONF : =latest }
# @ECLASS-VARIABLE: WANT_AUTOMAKE
# @DESCRIPTION:
# The major version of automake your package needs
: ${ WANT_AUTOMAKE : =latest }
# @ECLASS-VARIABLE: WANT_LIBTOOL
# @DESCRIPTION:
# Do you want libtool? Valid values here are "latest" and "none".
: ${ WANT_LIBTOOL : =latest }
# @ECLASS-VARIABLE: _LATEST_AUTOMAKE
# @INTERNAL
# @DESCRIPTION:
# CONSTANT!
2012-03-21 16:32:45 +04:00
# The latest major version/slot of automake available on each arch. #312315
2013-04-24 10:05:57 +04:00
# We should list both the latest stable, and the latest unstable. #465732
# This way the stable builds will still work, but the unstable are allowed
# to build & test things for us ahead of time (if they have it installed).
2012-03-22 10:14:44 +04:00
# If a newer slot is stable on any arch, and is NOT reflected in this list,
2011-11-09 11:33:19 +04:00
# then circular dependencies may arise during emerge @system bootstraps.
2012-03-22 10:14:44 +04:00
# Do NOT change this variable in your ebuilds!
2012-03-21 16:32:45 +04:00
# If you want to force a newer minor version, you can specify the correct
2012-06-08 17:39:40 +04:00
# WANT value by using a colon: <PV>:<WANT_AUTOMAKE>
2015-07-18 22:34:49 +03:00
_LATEST_AUTOMAKE = ( 1.15:1.15 )
2011-11-09 11:33:19 +04:00
_automake_atom = "sys-devel/automake"
_autoconf_atom = "sys-devel/autoconf"
if [ [ -n ${ WANT_AUTOMAKE } ] ] ; then
case ${ WANT_AUTOMAKE } in
2012-05-20 22:47:27 +04:00
# Even if the package doesn't use automake, we still need to depend
# on it because we run aclocal to process m4 macros. This matches
# the autoreconf tool, so this requirement is correct. #401605
none) ; ;
2012-03-22 10:14:44 +04:00
latest)
# Use SLOT deps if we can. For EAPI=0, we get pretty close.
if [ [ ${ EAPI :- 0 } != 0 ] ] ; then
_automake_atom = " || ( `printf '>=sys-devel/automake-%s:%s ' ${ _LATEST_AUTOMAKE [@]/ : / } ` ) "
else
_automake_atom = " || ( `printf '>=sys-devel/automake-%s ' ${ _LATEST_AUTOMAKE [@]/% : * } ` ) "
fi
; ;
2011-11-09 11:33:19 +04:00
*) _automake_atom = " =sys-devel/automake- ${ WANT_AUTOMAKE } * " ; ;
esac
export WANT_AUTOMAKE
fi
if [ [ -n ${ WANT_AUTOCONF } ] ] ; then
case ${ WANT_AUTOCONF } in
none) _autoconf_atom = "" ; ; # some packages don't require autoconf at all
2015-09-15 09:05:03 +03:00
2.1) _autoconf_atom = "~sys-devel/autoconf-2.13" ; ;
2012-02-14 20:57:25 +04:00
# if you change the "latest" version here, change also autotools_env_setup
2014-08-13 18:55:29 +04:00
latest| 2.5) _autoconf_atom = ">=sys-devel/autoconf-2.69" ; ;
2011-11-09 11:33:19 +04:00
*) die " Invalid WANT_AUTOCONF value ' ${ WANT_AUTOCONF } ' " ; ;
esac
export WANT_AUTOCONF
fi
2014-11-14 10:42:58 +03:00
_libtool_atom = ">=sys-devel/libtool-2.4"
2011-11-09 11:33:19 +04:00
if [ [ -n ${ WANT_LIBTOOL } ] ] ; then
case ${ WANT_LIBTOOL } in
none) _libtool_atom = "" ; ;
latest) ; ;
*) die " Invalid WANT_LIBTOOL value ' ${ WANT_LIBTOOL } ' " ; ;
esac
export WANT_LIBTOOL
fi
2013-12-30 15:54:47 +04:00
# Force people (nicely) to upgrade to a newer version of gettext as
# older ones are known to be crappy. #496454
AUTOTOOLS_DEPEND = " !<sys-devel/gettext-0.18.1.1-r3
${ _automake_atom }
${ _autoconf_atom }
${ _libtool_atom } "
2011-11-09 11:33:19 +04:00
RDEPEND = ""
# @ECLASS-VARIABLE: AUTOTOOLS_AUTO_DEPEND
# @DESCRIPTION:
# Set to 'no' to disable automatically adding to DEPEND. This lets
# ebuilds former conditional depends by using ${AUTOTOOLS_DEPEND} in
# their own DEPEND string.
: ${ AUTOTOOLS_AUTO_DEPEND : =yes }
if [ [ ${ AUTOTOOLS_AUTO_DEPEND } != "no" ] ] ; then
DEPEND = ${ AUTOTOOLS_DEPEND }
fi
2014-11-15 17:03:11 +03:00
__AUTOTOOLS_AUTO_DEPEND = ${ AUTOTOOLS_AUTO_DEPEND } # See top of eclass
2011-11-09 11:33:19 +04:00
unset _automake_atom _autoconf_atom
# @ECLASS-VARIABLE: AM_OPTS
# @DEFAULT_UNSET
# @DESCRIPTION:
# Additional options to pass to automake during
# eautoreconf call.
2012-02-20 09:54:51 +04:00
# @ECLASS-VARIABLE: AT_NOEAUTOMAKE
# @DEFAULT_UNSET
# @DESCRIPTION:
2012-03-23 11:00:24 +04:00
# Don't run eautomake command if set to 'yes'; only used to workaround
# broken packages. Generally you should, instead, fix the package to
# not call AM_INIT_AUTOMAKE if it doesn't actually use automake.
2012-02-20 09:54:51 +04:00
2011-11-09 11:33:19 +04:00
# @ECLASS-VARIABLE: AT_NOELIBTOOLIZE
# @DEFAULT_UNSET
# @DESCRIPTION:
# Don't run elibtoolize command if set to 'yes',
# useful when elibtoolize needs to be ran with
# particular options
# @ECLASS-VARIABLE: AT_M4DIR
# @DESCRIPTION:
# Additional director(y|ies) aclocal should search
2011-12-16 10:22:42 +04:00
: ${ AT_M4DIR : = }
2011-11-09 11:33:19 +04:00
2011-12-14 10:06:15 +04:00
# @ECLASS-VARIABLE: AT_SYS_M4DIR
# @INTERNAL
# @DESCRIPTION:
# For system integrators, a list of additional aclocal search paths.
# This variable gets eval-ed, so you can use variables in the definition
# that may not be valid until eautoreconf & friends are run.
: ${ AT_SYS_M4DIR : = }
2011-11-09 11:33:19 +04:00
# @FUNCTION: eautoreconf
# @DESCRIPTION:
# This function mimes the behavior of autoreconf, but uses the different
# eauto* functions to run the tools. It doesn't accept parameters, but
# the directory with include files can be specified with AT_M4DIR variable.
#
# Should do a full autoreconf - normally what most people will be interested in.
# Also should handle additional directories specified by AC_CONFIG_SUBDIRS.
eautoreconf( ) {
2014-11-21 18:45:09 +03:00
local x g
# Subdirs often share a common build dir #529404. If so, we can't safely
# run in parallel because many tools clobber the content in there. Libtool
# and automake both `rm && cp` while aclocal reads the output. We might be
# able to handle this if we split the steps and grab locks on the dirs the
# tools actually write to. Then we'd run all the common tools that use
# those inputs. Doing this in bash does not scale easily.
# If we do re-enable parallel support, make sure #426512 is handled.
2012-06-07 13:48:12 +04:00
if [ [ -z ${ AT_NO_RECURSIVE } ] ] ; then
2011-11-09 11:33:19 +04:00
# Take care of subdirs
2012-05-20 22:47:27 +04:00
for x in $( autotools_check_macro_val AC_CONFIG_SUBDIRS) ; do
2011-11-09 11:33:19 +04:00
if [ [ -d ${ x } ] ] ; then
pushd " ${ x } " >/dev/null
2014-11-21 18:45:09 +03:00
# Avoid unsafe nested multijob_finish_one for bug #426512.
AT_NOELIBTOOLIZE = "yes" eautoreconf || die
2011-11-09 11:33:19 +04:00
popd >/dev/null
fi
done
fi
2012-03-23 11:00:24 +04:00
einfo " Running eautoreconf in ' ${ PWD } ' ... "
2012-05-20 22:47:27 +04:00
local m4dirs = $( autotools_check_macro_val AC_CONFIG_{ AUX,MACRO} _DIR)
[ [ -n ${ m4dirs } ] ] && mkdir -p ${ m4dirs }
2012-05-22 16:39:56 +04:00
# Run all the tools before aclocal so we can gather the .m4 files.
local i tools = (
# <tool> <was run> <command>
2012-06-07 09:16:01 +04:00
glibgettext false "autotools_run_tool glib-gettextize --copy --force"
2012-06-07 13:48:12 +04:00
gettext false "autotools_run_tool --at-missing autopoint --force"
2012-05-22 16:39:56 +04:00
# intltool must come after autopoint.
2012-06-07 09:16:01 +04:00
intltool false "autotools_run_tool intltoolize --automake --copy --force"
2012-06-07 13:48:12 +04:00
gtkdoc false "autotools_run_tool --at-missing gtkdocize --copy"
gnomedoc false "autotools_run_tool --at-missing gnome-doc-prepare --copy --force"
2015-09-29 21:37:10 +03:00
libtool false "_elibtoolize --auto-ltdl --install --copy --force"
2012-05-22 16:39:56 +04:00
)
for ( ( i = 0; i < ${# tools [@] } ; i += 3 ) ) ; do
if _at_uses_${ tools [i] } ; then
tools[ i+1] = true
${ tools [i+2] }
fi
done
# Generate aclocal.m4 with our up-to-date m4 files.
local rerun_aclocal = false
2012-03-23 11:00:24 +04:00
eaclocal
2012-05-22 16:39:56 +04:00
# Check to see if we had macros expanded by other macros or in other
# m4 files that we couldn't detect early. This is uncommon, but some
# packages do this, so we have to handle it correctly.
for ( ( i = 0; i < ${# tools [@] } ; i += 3 ) ) ; do
if ! ${ tools [i+1] } && _at_uses_${ tools [i] } ; then
${ tools [i+2] }
rerun_aclocal = true
fi
done
${ rerun_aclocal } && eaclocal
2015-01-13 10:10:30 +03:00
if [ [ ${ WANT_AUTOCONF } = 2.1 ] ] ; then
eautoconf
else
eautoconf --force
fi
2012-03-23 11:00:24 +04:00
eautoheader
2012-02-20 09:54:51 +04:00
[ [ ${ AT_NOEAUTOMAKE } != "yes" ] ] && FROM_EAUTORECONF = "yes" eautomake ${ AM_OPTS }
2011-11-09 11:33:19 +04:00
2012-06-07 13:48:12 +04:00
if [ [ ${ AT_NOELIBTOOLIZE } != "yes" ] ] ; then
# Call it here to prevent failures due to elibtoolize called _before_
2014-01-02 12:55:11 +04:00
# eautoreconf.
elibtoolize --force " ${ PWD } "
2012-06-07 13:48:12 +04:00
fi
2011-11-09 11:33:19 +04:00
return 0
}
2012-05-22 16:39:56 +04:00
# @FUNCTION: _at_uses_pkg
# @USAGE: <macros>
# @INTERNAL
# See if the specified macros are enabled.
_at_uses_pkg( ) {
2012-05-24 09:36:50 +04:00
if [ [ -n $( autotools_check_macro " $@ " ) ] ] ; then
return 0
2012-05-22 16:39:56 +04:00
else
2012-05-24 09:36:50 +04:00
# If the trace didn't find it (perhaps because aclocal.m4 hasn't
# been generated yet), cheat, but be conservative.
2012-05-22 16:39:56 +04:00
local macro args = ( )
for macro ; do
args += ( -e " ^[[:space:]]* ${ macro } \> " )
done
egrep -q " ${ args [@] } " configure.??
fi
}
2013-04-28 22:37:34 +04:00
_at_uses_autoheader( ) { _at_uses_pkg A{ C,M} _CONFIG_HEADER{ S,} ; }
2012-06-07 09:16:01 +04:00
_at_uses_automake( ) { _at_uses_pkg AM_INIT_AUTOMAKE; }
2015-10-17 22:12:48 +03:00
_at_uses_gettext( ) { _at_uses_pkg AM_GNU_GETTEXT_{ ,REQUIRE_} VERSION; }
2012-06-07 09:16:01 +04:00
_at_uses_glibgettext( ) { _at_uses_pkg AM_GLIB_GNU_GETTEXT; }
_at_uses_intltool( ) { _at_uses_pkg { AC,IT} _PROG_INTLTOOL; }
_at_uses_gtkdoc( ) { _at_uses_pkg GTK_DOC_CHECK; }
_at_uses_gnomedoc( ) { _at_uses_pkg GNOME_DOC_INIT; }
_at_uses_libtool( ) { _at_uses_pkg A{ C,M} _PROG_LIBTOOL LT_INIT; }
2015-09-29 21:37:10 +03:00
_at_uses_libltdl( ) { _at_uses_pkg LT_CONFIG_LTDL_DIR; }
2012-05-22 16:39:56 +04:00
2011-11-09 11:33:19 +04:00
# @FUNCTION: eaclocal_amflags
# @DESCRIPTION:
# Extract the ACLOCAL_AMFLAGS value from the Makefile.am and try to handle
# (most) of the crazy crap that people throw at us.
eaclocal_amflags( ) {
local aclocal_opts amflags_file
for amflags_file in GNUmakefile.am Makefile.am GNUmakefile.in Makefile.in ; do
[ [ -e ${ amflags_file } ] ] || continue
# setup the env in case the pkg does something crazy
# in their ACLOCAL_AMFLAGS. like run a shell script
# which turns around and runs autotools. #365401
# or split across multiple lines. #383525
autotools_env_setup
aclocal_opts = $( sed -n \
" /^ACLOCAL_AMFLAGS[[:space:]]*=/{ \
# match the first line
s:[ ^= ] *= ::p; \
# then gobble up all escaped lines
: nextline /\\ \\ $/{ n; p; b nextline; } \
} " ${ amflags_file } )
eval aclocal_opts = \" " ${ aclocal_opts } " \"
break
done
echo ${ aclocal_opts }
}
# @FUNCTION: eaclocal
# @DESCRIPTION:
# These functions runs the autotools using autotools_run_tool with the
# specified parametes. The name of the tool run is the same of the function
# without e prefix.
# They also force installing the support files for safety.
# Respects AT_M4DIR for additional directories to search for macro's.
eaclocal( ) {
[ [ ! -f aclocal.m4 || -n $( grep -e 'generated.*by aclocal' aclocal.m4) ] ] && \
2011-12-16 10:22:42 +04:00
autotools_run_tool --at-m4flags aclocal " $@ " $( eaclocal_amflags)
2011-11-09 11:33:19 +04:00
}
# @FUNCTION: _elibtoolize
# @DESCRIPTION:
2014-11-14 10:42:58 +03:00
# Runs libtoolize.
2012-05-20 22:47:27 +04:00
#
2014-11-14 10:42:58 +03:00
# Note the '_' prefix: avoid collision with elibtoolize() from libtool.eclass.
2011-11-09 11:33:19 +04:00
_elibtoolize( ) {
2012-07-25 00:47:26 +04:00
local LIBTOOLIZE = ${ LIBTOOLIZE :- $( type -P glibtoolize > /dev/null && echo glibtoolize || echo libtoolize) }
2012-05-20 22:47:27 +04:00
2015-09-29 21:37:10 +03:00
if [ [ $1 = = "--auto-ltdl" ] ] ; then
shift
_at_uses_libltdl && set -- " $@ " --ltdl
fi
2012-05-20 22:47:27 +04:00
[ [ -f GNUmakefile.am || -f Makefile.am ] ] && set -- " $@ " --automake
2011-11-09 11:33:19 +04:00
2014-11-14 10:42:58 +03:00
autotools_run_tool ${ LIBTOOLIZE } " $@ "
2011-11-09 11:33:19 +04:00
}
# @FUNCTION: eautoheader
# @DESCRIPTION:
# Runs autoheader.
eautoheader( ) {
2012-05-22 16:39:56 +04:00
_at_uses_autoheader || return 0
2011-12-16 10:22:42 +04:00
autotools_run_tool --at-no-fail --at-m4flags autoheader " $@ "
2011-11-09 11:33:19 +04:00
}
# @FUNCTION: eautoconf
# @DESCRIPTION:
# Runs autoconf.
eautoconf( ) {
if [ [ ! -f configure.ac && ! -f configure.in ] ] ; then
echo
eerror " No configure.{ac,in} present in ' ${ PWD } '! "
echo
die "No configure.{ac,in} present!"
fi
2015-03-20 09:21:17 +03:00
if [ [ ${ WANT_AUTOCONF } != "2.1" && -e configure.in ] ] ; then
2014-11-15 17:03:11 +03:00
eqawarn "This package has a configure.in file which has long been deprecated. Please"
eqawarn "update it to use configure.ac instead as newer versions of autotools will die"
eqawarn "when it finds this file. See https://bugs.gentoo.org/426262 for details."
fi
2011-11-09 11:33:19 +04:00
2011-12-16 10:22:42 +04:00
autotools_run_tool --at-m4flags autoconf " $@ "
2011-11-09 11:33:19 +04:00
}
# @FUNCTION: eautomake
# @DESCRIPTION:
# Runs automake.
eautomake( ) {
2014-02-18 14:40:08 +04:00
local extra_opts = ( )
2011-11-09 11:33:19 +04:00
local makefile_name
# Run automake if:
# - a Makefile.am type file exists
2012-02-08 10:13:10 +04:00
# - the configure script is using the AM_INIT_AUTOMAKE directive
for makefile_name in { GNUmakefile,{ M,m} akefile} .am "" ; do
2011-11-09 11:33:19 +04:00
[ [ -f ${ makefile_name } ] ] && break
done
2014-02-18 14:40:08 +04:00
_automake_version( ) {
2014-11-15 17:03:11 +03:00
autotools_run_tool --at-output automake --version 2>/dev/null |
sed -n -e '1{s:.*(GNU automake) ::p;q}'
2014-02-18 14:40:08 +04:00
}
2012-02-08 10:13:10 +04:00
if [ [ -z ${ makefile_name } ] ] ; then
2012-05-22 16:39:56 +04:00
_at_uses_automake || return 0
2011-11-09 11:33:19 +04:00
elif [ [ -z ${ FROM_EAUTORECONF } && -f ${ makefile_name %.am } .in ] ] ; then
local used_automake
local installed_automake
2014-02-18 14:40:08 +04:00
installed_automake = $( WANT_AUTOMAKE = _automake_version)
2011-11-09 11:33:19 +04:00
used_automake = $( head -n 1 < ${ makefile_name %.am } .in | \
sed -e 's:.*by automake \(.*\) from .*:\1:' )
if [ [ ${ installed_automake } != ${ used_automake } ] ] ; then
2014-11-15 17:03:11 +03:00
ewarn " Automake used for the package ( ${ used_automake } ) differs from " \
" the installed version ( ${ installed_automake } ). "
ewarn "Forcing a full rebuild of the autotools to workaround."
2011-11-09 11:33:19 +04:00
eautoreconf
return 0
fi
fi
[ [ -f INSTALL && -f AUTHORS && -f ChangeLog && -f NEWS && -f README ] ] \
2014-02-18 14:40:08 +04:00
|| extra_opts += ( --foreign )
# Older versions of automake do not support --force-missing. But we want
# to use this whenever possible to update random bundled files #133489.
case $( _automake_version) in
1.4| 1.4[ .-] *) ; ;
*) extra_opts += ( --force-missing ) ; ;
esac
2011-11-09 11:33:19 +04:00
2014-02-18 14:40:08 +04:00
autotools_run_tool automake --add-missing --copy " ${ extra_opts [@] } " " $@ "
2011-11-09 11:33:19 +04:00
}
# @FUNCTION: eautopoint
# @DESCRIPTION:
# Runs autopoint (from the gettext package).
eautopoint( ) {
autotools_run_tool autopoint " $@ "
}
2012-02-08 10:13:10 +04:00
# @FUNCTION: config_rpath_update
# @USAGE: [destination]
# @DESCRIPTION:
# Some packages utilize the config.rpath helper script, but don't
# use gettext directly. So we have to copy it in manually since
# we can't let `autopoint` do it for us.
config_rpath_update( ) {
local dst src = $( type -P gettext | sed 's:bin/gettext:share/gettext/config.rpath:' )
[ [ $# -eq 0 ] ] && set -- $( find -name config.rpath)
[ [ $# -eq 0 ] ] && return 0
einfo "Updating all config.rpath files"
for dst in " $@ " ; do
einfo " ${ dst } "
cp " ${ src } " " ${ dst } " || die
done
}
2012-05-20 22:47:27 +04:00
# @FUNCTION: autotools_env_setup
# @INTERNAL
# @DESCRIPTION:
# Process the WANT_AUTO{CONF,MAKE} flags.
2011-11-09 11:33:19 +04:00
autotools_env_setup( ) {
2012-02-14 20:57:25 +04:00
# We do the "latest" → version switch here because it solves
2011-11-09 11:33:19 +04:00
# possible order problems, see bug #270010 as an example.
if [ [ ${ WANT_AUTOMAKE } = = "latest" ] ] ; then
local pv
2012-03-21 16:32:45 +04:00
for pv in ${ _LATEST_AUTOMAKE [@]/#* : } ; do
2011-11-09 11:33:19 +04:00
# has_version respects ROOT, but in this case, we don't want it to,
# thus "ROOT=/" prefix:
2012-03-21 16:32:45 +04:00
ROOT = / has_version " =sys-devel/automake- ${ pv } * " && export WANT_AUTOMAKE = " ${ pv } "
2011-11-09 11:33:19 +04:00
done
[ [ ${ WANT_AUTOMAKE } = = "latest" ] ] && \
2014-11-15 17:03:11 +03:00
die " Cannot find the latest automake! Tried ${ _LATEST_AUTOMAKE [*] } "
2011-11-09 11:33:19 +04:00
fi
[ [ ${ WANT_AUTOCONF } = = "latest" ] ] && export WANT_AUTOCONF = 2.5
}
2012-05-20 22:47:27 +04:00
# @FUNCTION: autotools_run_tool
2014-11-15 17:03:11 +03:00
# @USAGE: [--at-no-fail] [--at-m4flags] [--at-missing] [--at-output] <autotool> [tool-specific flags]
2012-05-20 22:47:27 +04:00
# @INTERNAL
# @DESCRIPTION:
# Run the specified autotool helper, but do logging and error checking
# around it in the process.
2011-11-09 11:33:19 +04:00
autotools_run_tool( ) {
2011-12-16 10:22:42 +04:00
# Process our own internal flags first
2014-11-15 17:03:11 +03:00
local autofail = true m4flags = false missing_ok = false return_output = false
2011-12-16 10:22:42 +04:00
while [ [ -n $1 ] ] ; do
case $1 in
--at-no-fail) autofail = false; ;
--at-m4flags) m4flags = true; ;
2012-06-07 13:48:12 +04:00
--at-missing) missing_ok = true; ;
2014-11-15 17:03:11 +03:00
--at-output) return_output = true; ;
2011-12-16 10:22:42 +04:00
# whatever is left goes to the actual tool
*) break; ;
esac
shift
done
2011-11-09 11:33:19 +04:00
if [ [ ${ EBUILD_PHASE } != "unpack" && ${ EBUILD_PHASE } != "prepare" ] ] ; then
ewarn " QA Warning: running $1 in ${ EBUILD_PHASE } phase "
fi
2012-06-07 13:48:12 +04:00
if ${ missing_ok } && ! type -P ${ 1 } >/dev/null ; then
einfo " Skipping ' $* ' due $1 not installed "
return 0
fi
2011-11-09 11:33:19 +04:00
autotools_env_setup
2015-09-02 17:38:56 +03:00
# Allow people to pass in full paths. #549268
local STDERR_TARGET = " ${ T } / ${ 1 ##*/ } .out "
2011-11-09 11:33:19 +04:00
# most of the time, there will only be one run, but if there are
# more, make sure we get unique log filenames
if [ [ -e ${ STDERR_TARGET } ] ] ; then
local i = 1
while :; do
2015-09-02 17:38:56 +03:00
STDERR_TARGET = " ${ T } / ${ 1 ##*/ } - ${ i } .out "
2011-11-09 11:33:19 +04:00
[ [ -e ${ STDERR_TARGET } ] ] || break
: $(( i++ ))
done
fi
2011-12-16 10:22:42 +04:00
if ${ m4flags } ; then
set -- " ${ 1 } " $( autotools_m4dir_include) " ${ @ : 2 } " $( autotools_m4sysdir_include)
fi
2014-11-15 17:03:11 +03:00
# If the caller wants to probe something, then let them do it directly.
if ${ return_output } ; then
" $@ "
return
fi
2011-11-09 11:33:19 +04:00
printf " ***** $1 *****\n***** PWD: ${ PWD } \n***** $* \n\n " > " ${ STDERR_TARGET } "
ebegin " Running $@ "
" $@ " >> " ${ STDERR_TARGET } " 2>& 1
2011-12-16 10:22:42 +04:00
if ! eend $? && ${ autofail } ; then
2011-11-09 11:33:19 +04:00
echo
eerror " Failed Running $1 ! "
eerror
eerror "Include in your bugreport the contents of:"
eerror
eerror " ${ STDERR_TARGET } "
echo
die " Failed Running $1 ! "
fi
}
# Internal function to check for support
2012-05-20 22:47:27 +04:00
# Keep a list of all the macros we might use so that we only
# have to run the trace code once. Order doesn't matter.
ALL_AUTOTOOLS_MACROS = (
2015-09-29 21:37:10 +03:00
A{ C,M} _PROG_LIBTOOL LT_INIT LT_CONFIG_LTDL_DIR
2013-04-29 15:11:45 +04:00
A{ C,M} _CONFIG_HEADER{ S,}
2012-05-20 22:47:27 +04:00
AC_CONFIG_SUBDIRS
AC_CONFIG_AUX_DIR AC_CONFIG_MACRO_DIR
AM_INIT_AUTOMAKE
2012-06-07 09:16:01 +04:00
AM_GLIB_GNU_GETTEXT
2015-10-17 22:12:48 +03:00
AM_GNU_GETTEXT_{ ,REQUIRE_} VERSION
2012-05-22 16:39:56 +04:00
{ AC,IT} _PROG_INTLTOOL
2012-06-07 09:16:01 +04:00
GTK_DOC_CHECK
GNOME_DOC_INIT
2012-05-20 22:47:27 +04:00
)
2011-11-09 11:33:19 +04:00
autotools_check_macro( ) {
[ [ -f configure.ac || -f configure.in ] ] || return 0
2012-05-20 22:47:27 +04:00
# We can run in multiple dirs, so we have to cache the trace
# data in $PWD rather than an env var.
local trace_file = ".__autoconf_trace_data"
2012-09-21 10:03:25 +04:00
if [ [ ! -e ${ trace_file } ] ] || [ [ ! aclocal.m4 -ot ${ trace_file } ] ] ; then
2012-05-20 22:47:27 +04:00
WANT_AUTOCONF = "2.5" autoconf \
$( autotools_m4dir_include) \
${ ALL_AUTOTOOLS_MACROS [@]/#/--trace= } > ${ trace_file } 2>/dev/null
fi
local macro args = ( )
2011-11-09 11:33:19 +04:00
for macro ; do
2012-05-20 22:47:27 +04:00
has ${ macro } ${ ALL_AUTOTOOLS_MACROS [@] } || die " internal error: add ${ macro } to ALL_AUTOTOOLS_MACROS "
args += ( -e " : ${ macro } : " )
2011-11-09 11:33:19 +04:00
done
2012-05-20 22:47:27 +04:00
grep " ${ args [@] } " ${ trace_file }
2011-11-09 11:33:19 +04:00
}
2012-05-20 22:47:27 +04:00
# @FUNCTION: autotools_check_macro_val
# @USAGE: <macro> [macros]
# @INTERNAL
# @DESCRIPTION:
# Look for a macro and extract its value.
2011-12-14 10:06:15 +04:00
autotools_check_macro_val( ) {
2012-05-20 22:47:27 +04:00
local macro scan_out
2011-11-09 11:33:19 +04:00
2012-05-20 22:47:27 +04:00
for macro ; do
autotools_check_macro " ${ macro } " | \
gawk -v macro = " ${ macro } " \
' ( $0 !~ /^[ [ :space:] ] *( #|dnl)/) {
if ( match( $0 , macro " :(.*) $" , res) )
print res[ 1]
} ' | uniq
done
2011-11-09 11:33:19 +04:00
return 0
}
2011-12-16 10:22:42 +04:00
_autotools_m4dir_include( ) {
2013-01-28 09:11:55 +04:00
local x include_opts flag
# Use the right flag to autoconf based on the version #448986
[ [ ${ WANT_AUTOCONF } = = "2.1" ] ] \
&& flag = "l" \
|| flag = "I"
2011-11-09 11:33:19 +04:00
2011-12-16 10:22:42 +04:00
for x in " $@ " ; do
case ${ x } in
# We handle it below
2013-01-28 09:11:55 +04:00
-${ flag } ) ; ;
2011-11-09 11:33:19 +04:00
*)
[ [ ! -d ${ x } ] ] && ewarn " autotools.eclass: ' ${ x } ' does not exist "
2013-01-28 09:11:55 +04:00
include_opts += " - ${ flag } ${ x } "
2011-11-09 11:33:19 +04:00
; ;
esac
done
2011-12-14 10:06:15 +04:00
echo ${ include_opts }
2011-11-09 11:33:19 +04:00
}
2011-12-16 10:22:42 +04:00
autotools_m4dir_include( ) { _autotools_m4dir_include ${ AT_M4DIR } ; }
2015-06-03 08:47:52 +03:00
autotools_m4sysdir_include( ) {
# First try to use the paths the system integrator has set up.
local paths = ( $( eval echo ${ AT_SYS_M4DIR } ) )
if [ [ ${# paths [@] } -eq 0 && -n ${ SYSROOT } ] ] ; then
# If they didn't give us anything, then default to the SYSROOT.
# This helps when cross-compiling.
local path = " ${ SYSROOT } /usr/share/aclocal "
[ [ -d ${ path } ] ] && paths += ( " ${ path } " )
fi
_autotools_m4dir_include " ${ paths [@] } "
}
2011-12-14 10:06:15 +04:00
fi