bootstrap Autotools initialization script

Software icon

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 [-build-dir dir] [-config-file file] [-src-dir dir] [-help | -init [topdir] | -build [configure-options | config-name [make-args]] -clean [config-name] | -config [configure-options] | -configonly [configure-options] | -install [configure-options] | -mkdir config-name | -rebuild [configure-options] | -reconfig [configure-options] | -version] OPTIONS -build-dir dir Sets its argument as the build directory where the configuration-specific build directories will be created. Overrides the default of "build/" in the top source directory. This option must precede any command options such as -config or -build. -config-file file Specifies the path name of the configuration file to use. If not specified, the default value is "bootstrap.conf". If -src-dir is not specified, the parent directory of the config file is used as the location of the source tree. This option must precede any command options such as -config or -build. -src-dir dir Sets the location of the source tree. This allows you to run bootstrap without installing it in the top of the source tree with -init. By default, the location of the source tree is the current working directory or the parent directory of the config file when -config-file is specified. The value of the -src-dir option takes precedence. This option must precede any command options such as -config or -build. -help Displays this help message. -build [configure-options | config-name [make-args]] 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 [config-name} 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 [configure-options] After prepping the source tree by running the autotools, runs configure with the specified configure options, readying the source tree for building. -configonly [configure-options] Runs configure with the specified configure options without readying the source tree for building. -install [configure-options] Performs the same operations as -build, but in addition installs the resulting build. -mkdir config-name 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. -rebuild [configure-options] Like -build, but does a -reconfig before building. You can pass configure options after -build just as you would with -config. -reconfig [configure-options] Performs the same operations as: bootstrap -clean bootstrap -config [configure-options] -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. DEPRECATED OPTIONS -init [topdir] 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 unless -src-dir or -config-file are specified.

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.

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.

As of version 1.1.10 you can use the -config-file and -src-dir options to run bootstrap from an arbitrary directory with the bootstrap config file and top source directory also residing at arbitrary locations.