autogen.sh

3670 ワード

autogen.shはshellスクリプトで、configureの生成を簡略化します.
次はよく使われるautogenです.shの内容は、環境をチェックするaclocal、autoconf、autoheader、libtoolize、automakeのコマンドを順次呼び出してconfigureを生成し、これらのコマンドをカプセル化し、1つの実行を必要とせず、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