bootstrap Autotools initialization script
bootstrap is a bash script that generates the boilerplate
initialization required to create a configure script
when using GNU Autotools. Also, it provides the ability to automate
the builds for different sets of configuration options, such as a
debug or release build. Savarese Software Research Corporation uses
bootstrap to generate all of its open source software releases
that use GNU Autotools as a build system.
bootstrap Usage
usage: bootstrap -help | -init [topdir] | -build [configure-options] | -clean |
-config [configure-options] | -rebuild [configure-options] |
-reconfig [configure-options]
OPTIONS
-help Displays this help message.
-init Initializes the source tree for use with bootstrap. This
consists merely of making a symbolic link to the bootstrap
script in the specified directory (or the current directory
if none is specified). bootstrap must be run from the link
for all other operations, or it will fail to find the
source tree.
-build Performs the same operations as -config, but additionally
builds the source. You can pass configure options after
-build just as you would with -config. Additionally, if
you specify a configuration name (see configure-options below)
any arguments after the configuration name are passed along
to the make command for building the source.
-clean Removes all of the configure support files created by
autotools. Specifying a configuration name will remove
the build directory for that configuration; otherwise the
default build directory is removed.
-config After prepping the source tree by running the autotools,
runs configure with the specified configure options,
readying the source tree for building.
-configonly Runs configure with the specified configure options without
readying the source tree for building.
-install Performs the same operations as -build, but in addition
installs the resulting build.
-mkdir Preps the source tree by running the autotools and then
creates an architecture-specific build directory. Specifying
a configuration name will create a build directory with a
suffix matching the configuration name.
-reconfig Performs the same operations as
bootstrap -clean
bootstrap -config [configure-options]
-rebuild Like -build, but does a -reconfig before building.
You can pass configure options after -build just as
you would with -config.
-version Print bootstrap version number.
SPECIAL ARGUMENTS
configure-options Argument may be options to pass to configure or the
name of a configuration in the bootstrap config file
that predefines the arguments to pass to configure.
Sample bootstrap.conf
Using bootstrap is largely self-explanatory from the help
and the code if you already understand Autotools, but the ability
to use a bootstrap.conf configuration file
requires some explanation. In the course of development, you may
want to maintain different build trees from the same source
checkout. For example, you may have a debug build and a non-debug
build. These builds must reside in different directories and
require different configuration options. Or perhaps you have an
installation tree in your home directory for individual testing
and a system-wide installation tree for continuous integration
testing. You can store build-specific options and associate them with
a configuration name in bootstrap.conf.
# -*- mode: shell-script; -*-
#
# Predefined configuration flags.
#
_install_dir="/opt/${PACKAGE_NAME}-${PACKAGE_VERSION}"
_conf_common="
--disable-libtool-lock
"
_conf_release_common="
$_conf_common
--prefix=$_install_dir
CFLAGS=-O2 -DNDEBUG
CXXFLAGS=-O2 -DNDEBUG
"
conf_dev="
$_conf_common
CFLAGS=-O0
CXXFLAGS=-O0
"
conf_debug="
--enable-debug
--disable-shared
--enable-static
$conf_dev
"
conf_dev_install="
--prefix=${_install_dir}-dev
$conf_dev
"
conf_debug_install="
--prefix=${_install_dir}-debug
$conf_debug
"
conf_release_shared="
--enable-shared
$_conf_release_common
"
conf_release_static="
--disable-shared
--enable-static
$_conf_release_common
"
conf_default="$conf_dev"
conf_release="$conf_release_static"
# Uncomment these to disable libtoolize and autoheader (e.g., for
# a project consisting only of shell scripts).
#function libtoolize() { return; }
#function autoheader() { return; }
Configuration names are prefixed by the
conf_ prefix. Each configuration is a shell
variable containing configure arguments. Each
argument must be separated by a newline. This allows whitespace
to be preserved in assignments such as CFLAGS=-O2
-DNDEBUG. When you pass a configuration name to
bootstrap, the arguments defined by the
configuration are passed along to configure.
For example, the following command will configure, build, and
install a project using the release
configuration:
./bootstrap -install release
The build directory generated to perform the build will contain a
suffix of .release as in
build/i686-redhat-linux-gnu.release/.
If a bootstrap.conf file exists and no
configuration name is specified for a bootstrap
run, then the value of conf_default is used.
You do not need to use bootstrap.conf to use
bootstrap. However, if you want to pass
arguments to configure, you will have to type
the arguments each time.
bootstrap expects to reside at the top
of the source tree. It can be run from anywhere, but the command
itself must be placed at the root of the source directory tree along
with configure.ac. Therefore, the convention is
to to run bootstrap -init from the top of your
source tree and then execute the instance of
bootstrap in your source tree for all future
operations related to that source tree. This avoids having to check
in a copy of the bootstrap script with every
project.
As of version 1.1.5 you can define
pre_bootstrap and
post_bootstrap functions in
bootstrap.conf to perform custom actions
before and after running autotools.