libvirt/bootstrap
Eric Blake 1a51d05f8b maint: start factoring bootstrap
Borrow ideas from gnulib/build-aux/bootstrap, in order to factor the
specifics of libvirt into bootstrap.conf, while allowing future
upgrades of bootstrap to happen with less effort.

* bootstrap (gnulib_tool): Update invocation to be closer to
gnulib's version.  Move libvirt specifics...
* bootstrap.conf: ...into new file.
2010-02-23 21:31:17 +01:00

146 lines
3.5 KiB
Bash
Executable File

#!/bin/sh
# Run this before autogen.sh, to pull in all of the gnulib-related bits.
usage() {
echo >&2 "\
Usage: $0 [OPTION]...
Bootstrap this package from the checked-out sources.
Options:
--gnulib-srcdir=DIRNAME Specify the local directory where gnulib
sources reside. Use this if you already
have gnulib sources on your machine, and
do not want to waste your bandwidth downloading
them again.
If the file bootstrap.conf exists in the current working directory, its
contents are read as shell variables to configure the bootstrap.
Running without arguments will suffice in most cases.
"
}
# Configuration.
# List of gnulib modules needed.
gnulib_modules=
extract_package_name='
/^AC_INIT(/{
/.*,.*,.*, */{
s///
s/[][]//g
s/)$//
p
q
}
s/AC_INIT(\[*//
s/]*,.*//
s/^GNU //
y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
s/[^A-Za-z0-9_]/-/g
p
}
'
package=`sed -n "$extract_package_name" configure.ac` || exit
gnulib_name=lib$package
build_aux=build-aux
source_base=lib
m4_base=m4
doc_base=doc
tests_base=tests
# Extra files from gnulib, which override files from other sources.
gnulib_extra_files="
$build_aux/install-sh
$build_aux/missing
$build_aux/mdate-sh
$build_aux/texinfo.tex
$build_aux/depcomp
$build_aux/config.guess
$build_aux/config.sub
doc/INSTALL
"
# Additional gnulib-tool options to use. Use "\newline" to break lines.
gnulib_tool_option_extras=
# Other locale categories that need message catalogs.
EXTRA_LOCALE_CATEGORIES=
# Additional xgettext options to use. Use "\\\newline" to break lines.
XGETTEXT_OPTIONS='\\\
--flag=_:1:pass-c-format\\\
--flag=N_:1:pass-c-format\\\
--flag=error:3:c-format --flag=error_at_line:5:c-format\\\
'
# Override the default configuration, if necessary.
# Make sure that bootstrap.conf is sourced from the current directory
# if we were invoked as "sh bootstrap".
case "$0" in
*/*) test -r "$0.conf" && . "$0.conf" ;;
*) test -r "$0.conf" && . ./"$0.conf" ;;
esac
# Parse options.
for option
do
case $option in
--help)
usage
exit;;
--gnulib-srcdir=*)
GNULIB_SRCDIR=`expr "$option" : '--gnulib-srcdir=\(.*\)'`;;
*)
echo >&2 "$0: $option: unknown option"
exit 1;;
esac
done
# Get gnulib files.
case ${GNULIB_SRCDIR--} in
-)
echo "$0: getting gnulib files..."
git submodule init || exit $?
git submodule update || exit $?
GNULIB_SRCDIR=.gnulib
;;
*)
# Redirect the gnulib submodule to the directory on the command line
# if possible.
if test -d "$GNULIB_SRCDIR"/.git && \
git config --file .gitmodules submodule.gnulib.url >/dev/null; then
git submodule init
GNULIB_SRCDIR=`cd $GNULIB_SRCDIR && pwd`
git config --replace-all submodule.gnulib.url $GNULIB_SRCDIR
echo "$0: getting gnulib files..."
git submodule update || exit $?
GNULIB_SRCDIR=.gnulib
else
echo >&2 "$0: invalid gnulib srcdir: $GNULIB_SRCDIR"
exit 1
fi
;;
esac
gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
<$gnulib_tool || exit
gnulib_tool_options="\
--import\
--no-changelog\
--aux-dir $build_aux\
--doc-base $doc_base\
--lib $gnulib_name\
--m4-base $m4_base/\
--source-base $source_base/\
--tests-base $tests_base\
$gnulib_tool_option_extras\
"
echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
$gnulib_tool $gnulib_tool_options --import $gnulib_modules