autogen.sh是个shell脚本,用来简化生成configure的。
下面是常用的autogen.sh内容,可以看出就是检查环境并依次调用 aclocal、autoconf、autoheader、libtoolize、automake 这些命令来生成configure,把这些命令封装、不需要一条条执行,只需要执行autogen.sh脚本即可。
[root@localhost autogen_test]# vim autogen.sh
[root@localhost autogen_test]# cat autogen.sh
#!/bin/sh
echo
echo ... auto_test autogen ...
echo
## Check all dependencies are present
MISSING=""
# Check for aclocal
env aclocal --version > /dev/null 2>&1
if [ $? -eq 0 ]; then
ACLOCAL=aclocal
else
MISSING="$MISSING aclocal"
fi
# Check for autoconf
env autoconf --version > /dev/null 2>&1
if [ $? -eq 0 ]; then
AUTOCONF=autoconf
else
MISSING="$MISSING autoconf"
fi
# Check for autoheader
env autoheader --version > /dev/null 2>&1
if [ $? -eq 0 ]; then
AUTOHEADER=autoheader
else
MISSING="$MISSING autoheader"
fi
# Check for automake
env automake --version > /dev/null 2>&1
if [ $? -eq 0 ]; then
AUTOMAKE=automake
else
MISSING="$MISSING automake"
fi
# Check for libtoolize or glibtoolize
env libtoolize --version > /dev/null 2>&1
if [ $? -eq 0 ]; then
# libtoolize was found, so use it
TOOL=libtoolize
else
# libtoolize wasn't found, so check for glibtoolize
env glibtoolize --version > /dev/null 2>&1
if [ $? -eq 0 ]; then
TOOL=glibtoolize
else
MISSING="$MISSING libtoolize/glibtoolize"
fi
fi
# Check for tar
env tar -cf /dev/null /dev/null > /dev/null 2>&1
if [ $? -ne 0 ]; then
MISSING="$MISSING tar"
fi
## If dependencies are missing, warn the user and abort
if [ "x$MISSING" != "x" ]; then
echo "Aborting."
echo
echo "The following build tools are missing:"
echo
for pkg in $MISSING; do
echo " * $pkg"
done
echo
echo "Please install them and try again."
echo
exit 1
fi
## Do the autogeneration
echo Running ${ACLOCAL}...
$ACLOCAL
echo Running ${AUTOHEADER}...
$AUTOHEADER
echo Running ${TOOL}...
$TOOL --automake --copy --force
echo Running ${AUTOCONF}...
$AUTOCONF
echo Running ${AUTOMAKE}...
$AUTOMAKE --add-missing --force-missing --copy --foreign
# Run autogen in the argp-standalone sub-directory
#echo "Running autogen.sh in argp-standalone ..."
#( cd contrib/argp-standalone;./autogen.sh )
# Instruct user on next steps
echo
echo "Please proceed with configuring, compiling, and installing."
还有一种使用autoreconf的
GNU autoconf工具。通过在指定目录和子目录中运行autoconf,autoheader,aclocal,automake和libtoolize更新配置脚本。很少手动调用此命令。通常可以从其他autoconf工具中自动调用它
#!/bin/sh
# Run this to generate configure, Makefile.in's, etc
(autoreconf --version) < /dev/null > /dev/null 2>&1 || {
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
echo
echo "**Error**: You must have the GNU Build System (autoconf, automake, "
echo "libtool, etc) to update the build system. Download the "
echo "appropriate packages for your distribution, or get the source "
echo "tar balls from ftp://ftp.gnu.org/pub/gnu/."
exit 1
}
echo
echo "**Error**: Your version of autoconf is too old (you need at least 2.57)"
echo "to update the build system. Download the appropriate "
echo "updated package for your distribution, or get the source tar ball "
echo "from ftp://ftp.gnu.org/pub/gnu/."
exit 1
}
echo Running autoreconf --verbose --install --force
autoreconf --verbose --install --force