123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515 |
- #! /bin/sh
- scriptversion=2022-12-27.07;
- me="$0"
- medir=`dirname "$me"`
- scriptlibversion=2023-01-06.19;
- nl='
- '
- LC_ALL=C
- export LC_ALL
- PERL="${PERL-perl}"
- default_gnulib_url=https://git.savannah.gnu.org/git/gnulib.git
- copyright_year=`echo "$scriptlibversion" | sed -e 's/[^0-9].*//'`
- copyright="Copyright (C) ${copyright_year} Free Software Foundation, Inc.
- License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl.html>.
- This is free software: you are free to change and redistribute it.
- There is NO WARRANTY, to the extent permitted by law."
- warnf_ ()
- {
- warnf_format_=$1
- shift
- nl='
- '
- case $* in
- *$nl*) me_=$(printf "$me"|tr "$nl|" '??')
- printf "$warnf_format_" "$@" | sed "s|^|$me_: |" ;;
- *) printf "$me: $warnf_format_" "$@" ;;
- esac >&2
- }
- warn_ ()
- {
-
- case $IFS in
- ' '*) warnf_ '%s\n' "$*";;
- *) (IFS=' '; warn_ "$@");;
- esac
- }
- die() { warn_ "$@"; exit 1; }
- local_gl_dir=gl
- gnulib_mk=gnulib.mk
- gnulib_modules=
- gnulib_files=
- bootstrap_option_hook() { return 1; }
- bootstrap_print_option_usage_hook() { :; }
- bootstrap_post_pull_hook() { :; }
- bootstrap_post_import_hook() { :; }
- bootstrap_epilogue() { :; }
- po_download_command_format=\
- "wget --mirror --level=1 -nd -nv -A.po -P '%s' \
- https://translationproject.org/latest/%s/"
- extract_package_name='
- /^AC_INIT(\[*/{
- s///
- /^[^,]*,[^,]*,[^,]*,[ []*\([^][ ,)]\)/{
- s//\1/
- s/[],)].*//
- p
- q
- }
- s/[],)].*//
- s/^GNU //
- y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
- s/[^abcdefghijklmnopqrstuvwxyz0123456789_]/-/g
- p
- }
- '
- package=$(${AUTOCONF:-autoconf} --trace AC_INIT:\$4 configure.ac 2>/dev/null)
- if test -z "$package"; then
- package=$(sed -n "$extract_package_name" configure.ac) \
- || die 'cannot find package name in configure.ac'
- fi
- gnulib_name=lib$package
- build_aux=build-aux
- source_base=lib
- m4_base=m4
- doc_base=doc
- tests_base=tests
- gnulib_extra_files="
- build-aux/install-sh
- build-aux/mdate-sh
- build-aux/texinfo.tex
- build-aux/depcomp
- build-aux/config.guess
- build-aux/config.sub
- doc/INSTALL
- "
- gnulib_tool_option_extras=
- EXTRA_LOCALE_CATEGORIES=
- 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\\\
- '
- COPYRIGHT_HOLDER='Free Software Foundation, Inc.'
- MSGID_BUGS_ADDRESS=bug-$package@gnu.org
- excluded_files=
- checkout_only_file=README-hacking
- vc_ignore=auto
- bootstrap_sync=false
- conffile=`dirname "$me"`/bootstrap.conf
- test -r "$conffile" && . "$conffile"
- check_exists() {
- if test "$1" = "--verbose"; then
- ($2 --version </dev/null) >/dev/null 2>&1
- if test $? -ge 126; then
-
-
- ($2 --version </dev/null)
- fi
- else
- ($1 --version </dev/null) >/dev/null 2>&1
- fi
- test $? -lt 126
- }
- sort_ver() {
- ver1="$1"
- ver2="$2"
-
- i=1
- while : ; do
- p1=$(echo "$ver1" | cut -d. -f$i)
- p2=$(echo "$ver2" | cut -d. -f$i)
- if [ ! "$p1" ]; then
- echo "$1 $2"
- break
- elif [ ! "$p2" ]; then
- echo "$2 $1"
- break
- elif [ ! "$p1" = "$p2" ]; then
- if [ "$p1" -gt "$p2" ] 2>/dev/null; then
- echo "$2 $1"
- elif [ "$p2" -gt "$p1" ] 2>/dev/null; then
- echo "$1 $2"
- else
- lp=$(printf "%s\n%s\n" "$p1" "$p2" | LANG=C sort -n | tail -n1)
- if [ "$lp" = "$p2" ]; then
- echo "$1 $2"
- else
- echo "$2 $1"
- fi
- fi
- break
- fi
- i=$(($i+1))
- done
- }
- get_version_sed='
- # Move version to start of line.
- s/.*[v ]\([0-9]\)/\1/
- # Skip lines that do not start with version.
- /^[0-9]/!d
- # Remove characters after the version.
- s/[^.a-z0-9-].*//
- # The first component must be digits only.
- s/^\([0-9]*\)[a-z-].*/\1/
- #the following essentially does s/5.005/5.5/
- s/\.0*\([1-9]\)/.\1/g
- p
- q'
- get_version() {
- app=$1
- $app --version >/dev/null 2>&1 || { $app --version; return 1; }
- $app --version 2>&1 | sed -n "$get_version_sed"
- }
- check_versions() {
- ret=0
- while read app req_ver; do
-
- if test "$app" = libtool; then
- app=libtoolize
- fi
-
- if test "$app" = git; then
- $check_git || continue
- fi
-
- appvar=$(echo $app | LC_ALL=C tr '[a-z]-' '[A-Z]_')
- test "$appvar" = TAR && appvar=AMTAR
- case $appvar in
- GZIP) ;;
- PERL::*) ;;
- *) eval "app=\${$appvar-$app}" ;;
- esac
-
-
-
-
-
-
- case $app in
- automake-ng|aclocal-ng)
- app=${app%-ng}
- ($app --version | grep '(GNU automake-ng)') >/dev/null 2>&1 || {
- warn_ "Error: '$app' not found or not from Automake-NG"
- ret=1
- continue
- } ;;
-
-
- perl::*)
-
- app="${app#perl::}"
- if ! $PERL -m"$app" -e 'exit 0' >/dev/null 2>&1; then
- warn_ "Error: perl module '$app' not found"
- ret=1
- fi
- continue
- ;;
- esac
- if [ "$req_ver" = "-" ]; then
-
-
- if ! check_exists --verbose $app; then
- warn_ "Error: '$app' not found"
- ret=1
- fi
- else
-
- inst_ver=$(get_version $app)
- if [ ! "$inst_ver" ]; then
- warn_ "Error: '$app' not found"
- ret=1
- else
- latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
- if [ ! "$latest_ver" = "$inst_ver" ]; then
- warnf_ '%s\n' \
- "Error: '$app' version == $inst_ver is too old" \
- " '$app' version >= $req_ver is required"
- ret=1
- fi
- fi
- fi
- done
- return $ret
- }
- print_versions() {
- echo "Program Min_version"
- echo "----------------------"
- printf %s "$buildreq"
- echo "----------------------"
-
- }
- check_build_prerequisites()
- {
- check_git="$1"
-
-
- case $buildreq in
- *automake*) ;;
- *) buildreq="automake 1.9
- $buildreq" ;;
- esac
- case $buildreq in
- *autoconf*) ;;
- *) buildreq="autoconf 2.59
- $buildreq" ;;
- esac
-
-
- if test -d "$local_gl_dir" \
- && ! find "$local_gl_dir" -name '*.diff' -exec false {} +; then
- case $buildreq in
- *patch*) ;;
- *) buildreq="patch -
- $buildreq" ;;
- esac
- fi
- if ! printf '%s' "$buildreq" | check_versions; then
- echo >&2
- if test -f README-prereq; then
- die "See README-prereq for how to get the prerequisite programs"
- else
- die "Please install the prerequisite programs"
- fi
- fi
-
-
- probe=$(echo 'm4_quote([hi])' | autom4te -l M4sugar -t 'm4_quote:$%' -)
- if test "x$probe" != xhi; then
- warn_ "WARNING: your autom4te wrapper eats stdin;"
- warn_ "if bootstrap fails, consider upgrading your autotools"
- fi
- }
- find_tool ()
- {
- find_tool_envvar=$1
- shift
- find_tool_names=$@
- eval "find_tool_res=\$$find_tool_envvar"
- if test x"$find_tool_res" = x; then
- for i; do
- if check_exists $i; then
- find_tool_res=$i
- break
- fi
- done
- fi
- if test x"$find_tool_res" = x; then
- warn_ "one of these is required: $find_tool_names;"
- die "alternatively set $find_tool_envvar to a compatible tool"
- fi
- eval "$find_tool_envvar=\$find_tool_res"
- eval "export $find_tool_envvar"
- }
- cleanup_gnulib() {
- status=$?
-
-
- rm -fr "$gnulib_path"
- exit $status
- }
- git_modules_config () {
- test -f .gitmodules && git config --file .gitmodules "$@"
- }
- prepare_GNULIB_SRCDIR ()
- {
- if test -n "$GNULIB_SRCDIR"; then
-
-
-
- test -f "$GNULIB_SRCDIR/gnulib-tool" \
- || die "Error: --gnulib-srcdir or \$GNULIB_SRCDIR is specified, but does not contain gnulib-tool"
- elif $use_git; then
- gnulib_path=$(git_modules_config submodule.gnulib.path)
- test -z "$gnulib_path" && gnulib_path=gnulib
-
-
- if test -n "$GNULIB_REFDIR" && test -d "$GNULIB_REFDIR"/.git \
- && git_modules_config submodule.gnulib.url >/dev/null; then
-
- echo "$0: getting gnulib files..."
- if git submodule -h|grep -- --reference > /dev/null; then
-
- git submodule update --init --reference "$GNULIB_REFDIR" \
- "$gnulib_path" || exit $?
- else
-
- if test -f "$gnulib_path"/gnulib-tool; then
-
- git submodule update -- "$gnulib_path" || exit $?
- else
-
- rmdir "$gnulib_path" 2>/dev/null
- git clone --reference "$GNULIB_REFDIR" \
- "$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
- && git submodule init -- "$gnulib_path" \
- && git submodule update -- "$gnulib_path" \
- || exit $?
- fi
- fi
- else
-
- if git_modules_config submodule.gnulib.url >/dev/null; then
- echo "$0: getting gnulib files..."
- git submodule init -- "$gnulib_path" || exit $?
- git submodule update -- "$gnulib_path" || exit $?
- elif [ ! -d "$gnulib_path" ]; then
- echo "$0: getting gnulib files..."
- trap cleanup_gnulib HUP INT PIPE TERM
- shallow=
- if test -z "$GNULIB_REVISION"; then
- if git clone -h 2>&1 | grep -- --depth > /dev/null; then
- shallow='--depth 2'
- fi
- git clone $shallow ${GNULIB_URL:-$default_gnulib_url} "$gnulib_path" \
- || cleanup_gnulib
- else
- if git fetch -h 2>&1 | grep -- --depth > /dev/null; then
- shallow='--depth 2'
- fi
- mkdir -p "$gnulib_path"
-
-
-
-
-
-
-
- git -C "$gnulib_path" init
- git -C "$gnulib_path" remote add origin \
- ${GNULIB_URL:-$default_gnulib_url}
- git -C "$gnulib_path" fetch $shallow origin "$GNULIB_REVISION" \
- || git -C "$gnulib_path" fetch origin \
- || cleanup_gnulib
- git -C "$gnulib_path" reset --hard FETCH_HEAD
- fi
- trap - HUP INT PIPE TERM
- fi
- fi
- GNULIB_SRCDIR=$gnulib_path
-
- test -f "$gnulib_path/gnulib-tool" \
- || die "Error: $gnulib_path is supposed to contain a gnulib checkout, but does not contain gnulib-tool"
- fi
-
- if test -d "$GNULIB_SRCDIR"/.git && test -n "$GNULIB_REVISION" \
- && ! git_modules_config submodule.gnulib.url >/dev/null; then
- (cd "$GNULIB_SRCDIR" && git checkout "$GNULIB_REVISION") || cleanup_gnulib
- fi
-
-
- }
- upgrade_bootstrap ()
- {
- if test -f "$medir"/bootstrap-funclib.sh; then
- update_lib=true
- { cmp -s "$medir"/bootstrap "$GNULIB_SRCDIR/top/bootstrap" \
- && cmp -s "$medir"/bootstrap-funclib.sh "$GNULIB_SRCDIR/top/bootstrap-funclib.sh" \
- && cmp -s "$medir"/autopull.sh "$GNULIB_SRCDIR/top/autopull.sh" \
- && cmp -s "$medir"/autogen.sh "$GNULIB_SRCDIR/top/autogen.sh"; \
- }
- else
- update_lib=false
- cmp -s "$medir"/bootstrap "$GNULIB_SRCDIR/build-aux/bootstrap"
- fi || {
- if $update_lib; then
- echo "$0: updating bootstrap & companions and restarting..."
- else
- echo "$0: updating bootstrap and restarting..."
- fi
- case $(sh -c 'echo "$1"' -- a) in
- a) ignored=--;;
- *) ignored=ignored;;
- esac
- exec sh -c \
- '{ if '$update_lib' && test -f "$1"; then cp "$1" "$3"; else cp "$2" "$3"; fi; } && { if '$update_lib' && test -f "$4"; then cp "$4" "$5"; else rm -f "$5"; fi; } && { if '$update_lib' && test -f "$6"; then cp "$6" "$7"; else rm -f "$7"; fi; } && { if '$update_lib' && test -f "$8"; then cp "$8" "$9"; else rm -f "$9"; fi; } && shift && shift && shift && shift && shift && shift && shift && shift && shift && exec "${CONFIG_SHELL-/bin/sh}" "$@"' \
- $ignored \
- "$GNULIB_SRCDIR/top/bootstrap" "$GNULIB_SRCDIR/build-aux/bootstrap" "$medir/bootstrap" \
- "$GNULIB_SRCDIR/top/bootstrap-funclib.sh" "$medir/bootstrap-funclib.sh" \
- "$GNULIB_SRCDIR/top/autopull.sh" "$medir/autopull.sh" \
- "$GNULIB_SRCDIR/top/autogen.sh" "$medir/autogen.sh" \
- "$0" "$@" --no-bootstrap-sync
- }
- }
- if test x"$gnulib_modules$gnulib_files$gnulib_extra_files" = x; then
- use_gnulib=false
- else
- use_gnulib=true
- fi
- autopull_usage() {
- cat <<EOF
- Usage: $me [OPTION]...
- Bootstrap this package from the checked-out sources.
- Optional environment variables:
- GNULIB_SRCDIR Specifies the local directory where gnulib
- sources reside. Use this if you already
- have gnulib sources on your machine, and
- you want to use these sources.
- GNULIB_REFDIR Specifies the local directory where a gnulib
- repository (with a .git subdirectory) resides.
- Use this if you already have gnulib sources
- and history on your machine, and do not want
- to waste your bandwidth downloading them again.
- GNULIB_URL Cloneable URL of the gnulib repository.
- Options:
- --bootstrap-sync if this bootstrap script is not identical to
- the version in the local gnulib sources,
- update this script, and then restart it with
- /bin/sh or the shell \$CONFIG_SHELL
- --no-bootstrap-sync do not check whether bootstrap is out of sync
- --force attempt to bootstrap even if the sources seem
- not to have been checked out
- --no-git do not use git to update gnulib. Requires that
- \$GNULIB_SRCDIR or the --gnulib-srcdir option
- points to a gnulib repository with the correct
- revision
- --skip-po do not download po files
- EOF
- bootstrap_print_option_usage_hook
- cat <<EOF
- If the file bootstrap.conf exists in the same directory as this script, its
- contents are read as shell variables to configure the bootstrap.
- For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR
- are honored.
- Gnulib sources can be fetched in various ways:
- * If the environment variable GNULIB_SRCDIR is set (either as an
- environment variable or via the --gnulib-srcdir option), then sources
- are fetched from that local directory. If it is a git repository and
- the configuration variable GNULIB_REVISION is set in bootstrap.conf,
- then that revision is checked out.
- * Otherwise, if this package is in a git repository with a 'gnulib'
- submodule configured, then that submodule is initialized and updated
- and sources are fetched from there. If GNULIB_REFDIR is set (either
- as an environment variable or via the --gnulib-refdir option) and is
- a git repository, then it is used as a reference.
- * Otherwise, if the 'gnulib' directory does not exist, Gnulib sources
- are cloned into that directory using git from \$GNULIB_URL, defaulting
- to $default_gnulib_url.
- If the configuration variable GNULIB_REVISION is set in bootstrap.conf,
- then that revision is checked out.
- * Otherwise, the existing Gnulib sources in the 'gnulib' directory are
- used. If it is a git repository and the configuration variable
- GNULIB_REVISION is set in bootstrap.conf, then that revision is
- checked out.
- If you maintain a package and want to pin a particular revision of the
- Gnulib sources that has been tested with your package, then there are
- two possible approaches: either configure a 'gnulib' submodule with the
- appropriate revision, or set GNULIB_REVISION (and if necessary
- GNULIB_URL) in bootstrap.conf.
- Running without arguments will suffice in most cases.
- EOF
- }
- autopull()
- {
-
-
- (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
-
- use_git=true
- for option
- do
- case $option in
- --help)
- autopull_usage
- return;;
- --version)
- set -e
- echo "autopull.sh $scriptlibversion"
- echo "$copyright"
- return 0
- ;;
- --skip-po)
- SKIP_PO=t;;
- --force)
- checkout_only_file=;;
- --bootstrap-sync)
- bootstrap_sync=true;;
- --no-bootstrap-sync)
- bootstrap_sync=false;;
- --no-git)
- use_git=false;;
- *)
- bootstrap_option_hook $option || die "$option: unknown option";;
- esac
- done
- $use_git || test -n "$GNULIB_SRCDIR" \
- || die "Error: --no-git requires \$GNULIB_SRCDIR environment variable or --gnulib-srcdir option"
- test -z "$GNULIB_SRCDIR" || test -d "$GNULIB_SRCDIR" \
- || die "Error: \$GNULIB_SRCDIR environment variable or --gnulib-srcdir option is specified, but does not denote a directory"
- if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
- die "Running this script from a non-checked-out distribution is risky."
- fi
- check_build_prerequisites $use_git
- if $use_gnulib || $bootstrap_sync; then
- prepare_GNULIB_SRCDIR
- if $bootstrap_sync; then
- upgrade_bootstrap
- fi
- fi
-
-
- if test x"$SKIP_PO" = x; then
- find_tool SHA1SUM sha1sum gsha1sum shasum sha1
- fi
-
- if $use_git && test -d .git && check_exists git; then
- if git config merge.merge-changelog.driver >/dev/null ; then
- :
- elif check_exists git-merge-changelog; then
- echo "$0: initializing git-merge-changelog driver"
- git config merge.merge-changelog.name 'GNU-style ChangeLog merge driver'
- git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B'
- else
- echo "$0: consider installing git-merge-changelog from gnulib"
- fi
- fi
- case $SKIP_PO in
- '')
- if test -d po; then
- update_po_files po $package || return
- fi
- if test -d runtime-po; then
- update_po_files runtime-po $package-runtime || return
- fi;;
- esac
-
- bootstrap_post_pull_hook \
- || die "bootstrap_post_pull_hook failed"
-
-
-
-
-
- if $use_git; then
-
- uninitialized=`git submodule | grep '^-' | awk '{ print $2 }'`
- if test -n "$GNULIB_SRCDIR"; then
- uninitialized=`echo "$uninitialized" | grep -v '^gnulib$'`
- fi
- if test -n "$uninitialized"; then
- die "Some git submodules are not initialized: "`echo "$uninitialized" | tr '\n' ',' | sed -e 's|,$|.|'`" Either use option '--no-git', or run 'git submodule update --init' and bootstrap again."
- fi
- fi
- if test -f "$medir"/autogen.sh; then
- echo "$0: done. Now you can run '$medir/autogen.sh'."
- fi
- }
- download_po_files() {
- subdir=$1
- domain=$2
- echo "$me: getting translations into $subdir for $domain..."
- cmd=$(printf "$po_download_command_format" "$subdir" "$domain")
- eval "$cmd"
- }
- update_po_files() {
-
-
- po_dir=$1
- domain=$2
-
-
- ref_po_dir="$po_dir/.reference"
- test -d $ref_po_dir || mkdir $ref_po_dir || return
- download_po_files $ref_po_dir $domain \
- && ls "$ref_po_dir"/*.po 2>/dev/null |
- sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" || return
- langs=$(cd $ref_po_dir && echo *.po | sed 's/\.po//g')
- test "$langs" = '*' && langs=x
- for po in $langs; do
- case $po in x) continue;; esac
- new_po="$ref_po_dir/$po.po"
- cksum_file="$ref_po_dir/$po.s1"
- if ! test -f "$cksum_file" ||
- ! test -f "$po_dir/$po.po" ||
- ! $SHA1SUM -c "$cksum_file" < "$new_po" > /dev/null 2>&1; then
- echo "$me: updated $po_dir/$po.po..."
- cp "$new_po" "$po_dir/$po.po" \
- && $SHA1SUM < "$new_po" > "$cksum_file" || return
- fi
- done
- }
- autogen_usage() {
- cat <<EOF
- Usage: $me [OPTION]...
- Bootstrap this package from the checked-out sources.
- Optional environment variables:
- GNULIB_SRCDIR Specifies the local directory where gnulib
- sources reside. Use this if you already
- have gnulib sources on your machine, and
- you want to use these sources.
- Options:
- --copy copy files instead of creating symbolic links
- --force attempt to bootstrap even if the sources seem
- not to have been checked out
- EOF
- bootstrap_print_option_usage_hook
- cat <<EOF
- If the file bootstrap.conf exists in the same directory as this script, its
- contents are read as shell variables to configure the bootstrap.
- For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR
- are honored.
- Gnulib sources are assumed to be present:
- * in \$GNULIB_SRCDIR, if that environment variable is set,
- * otherwise, in the 'gnulib' submodule, if such a submodule is configured,
- * otherwise, in the 'gnulib' subdirectory.
- Running without arguments will suffice in most cases.
- EOF
- }
- version_controlled_file() {
- parent=$1
- file=$2
- if test -d .git; then
- git rm -n "$file" > /dev/null 2>&1
- elif test -d .svn; then
- svn log -r HEAD "$file" > /dev/null 2>&1
- elif test -d CVS; then
- grep -F "/${file##*/}/" "$parent/CVS/Entries" 2>/dev/null |
- grep '^/[^/]*/[0-9]' > /dev/null
- else
- warn_ "no version control for $file?"
- false
- fi
- }
- gitignore_entries() {
- sed '/^#/d; /^$/d' "$@"
- }
- insert_if_absent() {
- file=$1
- str=$2
- test -f $file || touch $file
- test -r $file || die "Error: failed to read ignore file: $file"
- duplicate_entries=$(gitignore_entries $file | sort | uniq -d)
- if [ "$duplicate_entries" ] ; then
- die "Error: Duplicate entries in $file: " $duplicate_entries
- fi
- linesold=$(gitignore_entries $file | wc -l)
- linesnew=$( { echo "$str"; cat $file; } | gitignore_entries | sort -u | wc -l)
- if [ $linesold != $linesnew ] ; then
- { echo "$str" | cat - $file > $file.bak && mv $file.bak $file; } \
- || die "insert_if_absent $file $str: failed"
- fi
- }
- insert_vc_ignore() {
- vc_ignore_file="$1"
- pattern="$2"
- case $vc_ignore_file in
- *.gitignore)
-
-
-
- pattern=$(echo "$pattern" | sed s,^,/,);;
- esac
- insert_if_absent "$vc_ignore_file" "$pattern"
- }
- symlink_to_dir()
- {
- src=$1/$2
- dst=${3-$2}
- test -f "$src" && {
-
-
- dst_dir=$(dirname "$dst")
- if ! test -d "$dst_dir"; then
- mkdir -p "$dst_dir"
-
-
-
- parent=$(dirname "$dst_dir")
- for dot_ig in x $vc_ignore; do
- test $dot_ig = x && continue
- ig=$parent/$dot_ig
- insert_vc_ignore $ig "${dst_dir##*/}"
- done
- fi
- if $copy; then
- {
- test ! -h "$dst" || {
- echo "$me: rm -f $dst" &&
- rm -f "$dst"
- }
- } &&
- test -f "$dst" &&
- cmp -s "$src" "$dst" || {
- echo "$me: cp -fp $src $dst" &&
- cp -fp "$src" "$dst"
- }
- else
-
-
-
-
-
-
- test -h "$dst" &&
- src_ls=$(ls -diL "$src" 2>/dev/null) && set $src_ls && src_i=$1 &&
- dst_ls=$(ls -diL "$dst" 2>/dev/null) && set $dst_ls && dst_i=$1 &&
- test "$src_i" = "$dst_i" &&
- both_ls=$(ls -dt "$src" "$dst") &&
- test "X$both_ls" = "X$dst$nl$src" || {
- dot_dots=
- case $src in
- /*) ;;
- *)
- case /$dst/ in
- *//* | */../* | */./* | /*/*/*/*/*/)
- die "invalid symlink calculation: $src -> $dst";;
- /*/*/*/*/) dot_dots=../../../;;
- /*/*/*/) dot_dots=../../;;
- /*/*/) dot_dots=../;;
- esac;;
- esac
- echo "$me: ln -fs $dot_dots$src $dst" &&
- ln -fs "$dot_dots$src" "$dst"
- }
- fi
- }
- }
- autogen()
- {
-
-
- (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
-
- : "${AUTOPOINT=autopoint}"
- : "${AUTORECONF=autoreconf}"
- if test "$vc_ignore" = auto; then
- vc_ignore=
- test -d .git && vc_ignore=.gitignore
- test -d CVS && vc_ignore="$vc_ignore .cvsignore"
- fi
-
-
- copy=false
- for option
- do
- case $option in
- --help)
- autogen_usage
- return;;
- --version)
- set -e
- echo "autogen.sh $scriptlibversion"
- echo "$copyright"
- return 0
- ;;
- --force)
- checkout_only_file=;;
- --copy)
- copy=true;;
- *)
- bootstrap_option_hook $option || die "$option: unknown option";;
- esac
- done
- test -z "$GNULIB_SRCDIR" || test -d "$GNULIB_SRCDIR" \
- || die "Error: \$GNULIB_SRCDIR environment variable or --gnulib-srcdir option is specified, but does not denote a directory"
- if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
- die "Running this script from a non-checked-out distribution is risky."
- fi
- if $use_gnulib; then
- if test -z "$GNULIB_SRCDIR"; then
- gnulib_path=$(test -f .gitmodules && git config --file .gitmodules submodule.gnulib.path)
- test -z "$gnulib_path" && gnulib_path=gnulib
- GNULIB_SRCDIR=$gnulib_path
- fi
- fi
-
- found_aux_dir=no
- grep '^[ ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'])' configure.ac \
- >/dev/null && found_aux_dir=yes
- grep '^[ ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \
- >/dev/null && found_aux_dir=yes
- test $found_aux_dir = yes \
- || die "configure.ac lacks 'AC_CONFIG_AUX_DIR([$build_aux])'; add it"
-
-
- if test ! -d $build_aux; then
- mkdir $build_aux
- for dot_ig in x $vc_ignore; do
- test $dot_ig = x && continue
- insert_vc_ignore $dot_ig $build_aux
- done
- fi
- check_build_prerequisites false
- use_libtool=0
-
-
-
- grep '^[ ]*A[CM]_PROG_LIBTOOL' configure.ac >/dev/null \
- && use_libtool=1
- grep '^[ ]*LT_INIT' configure.ac >/dev/null \
- && use_libtool=1
- if test $use_libtool = 1; then
- find_tool LIBTOOLIZE glibtoolize libtoolize
- fi
- if $use_gnulib; then
- gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
- <$gnulib_tool || return
- fi
-
-
-
-
-
-
-
- with_gettext=yes
- grep '^[ ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
- with_gettext=no
- if test $with_gettext = yes || test $use_libtool = 1; then
- tempbase=.bootstrap$$
- trap "rm -f $tempbase.0 $tempbase.1" HUP INT PIPE TERM
- > $tempbase.0 > $tempbase.1 &&
- find . ! -type d -print | sort > $tempbase.0 || return
- if test $with_gettext = yes; then
-
-
- echo "$0: $AUTOPOINT --force"
- $AUTOPOINT --force || return
- fi
-
-
-
-
-
- if test $use_libtool = 1; then
- install=
- case $($LIBTOOLIZE --help) in
- *--install*) install=--install ;;
- esac
- echo "running: $LIBTOOLIZE $install --copy"
- $LIBTOOLIZE $install --copy
- fi
- find . ! -type d -print | sort >$tempbase.1
- old_IFS=$IFS
- IFS=$nl
- for file in $(comm -13 $tempbase.0 $tempbase.1); do
- IFS=$old_IFS
- parent=${file%/*}
- version_controlled_file "$parent" "$file" || {
- for dot_ig in x $vc_ignore; do
- test $dot_ig = x && continue
- ig=$parent/$dot_ig
- insert_vc_ignore "$ig" "${file##*/}"
- done
- }
- done
- IFS=$old_IFS
- rm -f $tempbase.0 $tempbase.1
- trap - HUP INT PIPE TERM
- fi
-
- if $use_gnulib; then
- gnulib_tool_options="\
- --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\
- --local-dir=$local_gl_dir\
- $gnulib_tool_option_extras\
- "
- if test $use_libtool = 1; then
- case "$gnulib_tool_options " in
- *' --libtool '*) ;;
- *) gnulib_tool_options="$gnulib_tool_options --libtool" ;;
- esac
- fi
- echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
- $gnulib_tool $gnulib_tool_options --import $gnulib_modules \
- || die "gnulib-tool failed"
- for file in $gnulib_files; do
- symlink_to_dir "$GNULIB_SRCDIR" $file \
- || die "failed to symlink $file"
- done
- fi
- bootstrap_post_import_hook \
- || die "bootstrap_post_import_hook failed"
-
-
-
-
-
-
-
-
- find "$m4_base" "$source_base" \
- -depth \( -name '*.m4' -o -name '*.[ch]' \) \
- -type l -xtype l -delete > /dev/null 2>&1
-
-
- AUTORECONFFLAGS="--verbose --install --force -I $m4_base $ACLOCAL_FLAGS"
-
-
-
-
- case $($AUTORECONF --help) in
- *--no-recursive*) AUTORECONFFLAGS="$AUTORECONFFLAGS --no-recursive";;
- esac
-
- echo "running: AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS"
- AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS \
- || die "autoreconf failed"
-
- for file in $gnulib_extra_files; do
- case $file in
- */INSTALL) dst=INSTALL;;
- build-aux/*) dst=$build_aux/${file#build-aux/};;
- *) dst=$file;;
- esac
- symlink_to_dir "$GNULIB_SRCDIR" $file $dst \
- || die "failed to symlink $file"
- done
- if test $with_gettext = yes; then
-
- echo "$0: Creating po/Makevars from po/Makevars.template ..."
- rm -f po/Makevars
- sed '
- /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
- /^COPYRIGHT_HOLDER *=/s/=.*/= '"$COPYRIGHT_HOLDER"'/
- /^MSGID_BUGS_ADDRESS *=/s|=.*|= '"$MSGID_BUGS_ADDRESS"'|
- /^XGETTEXT_OPTIONS *=/{
- s/$/ \\/
- a\
- '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
- }
- ' po/Makevars.template >po/Makevars \
- || die 'cannot generate po/Makevars'
-
-
-
- case $gnulib_modules in
- *gettext-h*) ;;
- *gettext*)
- cp $GNULIB_SRCDIR/build-aux/po/Makefile.in.in po/Makefile.in.in \
- || die "cannot create po/Makefile.in.in"
- ;;
- esac
- if test -d runtime-po; then
-
- rm -f runtime-po/Makevars
- sed '
- /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/
- /^subdir *=.*/s/=.*/= runtime-po/
- /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
- /^XGETTEXT_OPTIONS *=/{
- s/$/ \\/
- a\
- '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
- }
- ' po/Makevars.template >runtime-po/Makevars \
- || die 'cannot generate runtime-po/Makevars'
-
- (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
- fi
- fi
- bootstrap_epilogue
- echo "$0: done. Now you can run './configure'."
- }
- usage() {
- cat <<EOF
- Usage: $me [OPTION]...
- Bootstrap this package from the checked-out sources.
- Optional environment variables:
- GNULIB_SRCDIR Specifies 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.
- GNULIB_URL Cloneable URL of the gnulib repository.
- Options:
- --pull Do phase 1: pull files from network
- --gen Do phase 2: generate from local files.
- (The default is to do both phases.)
- --gnulib-srcdir=DIRNAME specify the local directory where gnulib
- sources reside. Use this if you already
- have gnulib sources on your machine, and
- you want to use these sources. Defaults
- to \$GNULIB_SRCDIR
- --gnulib-refdir=DIRNAME specify the local directory where a gnulib
- repository (with a .git subdirectory) resides.
- Use this if you already have gnulib sources
- and history on your machine, and do not want
- to waste your bandwidth downloading them again.
- Defaults to \$GNULIB_REFDIR
- --bootstrap-sync if this bootstrap script is not identical to
- the version in the local gnulib sources,
- update this script, and then restart it with
- /bin/sh or the shell \$CONFIG_SHELL
- --no-bootstrap-sync do not check whether bootstrap is out of sync
- --copy copy files instead of creating symbolic links
- --force attempt to bootstrap even if the sources seem
- not to have been checked out
- --no-git do not use git to update gnulib. Requires that
- \$GNULIB_SRCDIR or the --gnulib-srcdir option
- points to a gnulib repository with the correct
- revision
- --skip-po do not download po files
- EOF
- bootstrap_print_option_usage_hook
- cat <<EOF
- If the file bootstrap.conf exists in the same directory as this script, its
- contents are read as shell variables to configure the bootstrap.
- For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR
- are honored.
- Gnulib sources can be fetched in various ways:
- * If the environment variable GNULIB_SRCDIR is set (either as an
- environment variable or via the --gnulib-srcdir option), then sources
- are fetched from that local directory. If it is a git repository and
- the configuration variable GNULIB_REVISION is set in bootstrap.conf,
- then that revision is checked out.
- * Otherwise, if this package is in a git repository with a 'gnulib'
- submodule configured, then that submodule is initialized and updated
- and sources are fetched from there. If GNULIB_REFDIR is set (either
- as an environment variable or via the --gnulib-refdir option) and is
- a git repository, then it is used as a reference.
- * Otherwise, if the 'gnulib' directory does not exist, Gnulib sources
- are cloned into that directory using git from \$GNULIB_URL, defaulting
- to $default_gnulib_url.
- If the configuration variable GNULIB_REVISION is set in bootstrap.conf,
- then that revision is checked out.
- * Otherwise, the existing Gnulib sources in the 'gnulib' directory are
- used. If it is a git repository and the configuration variable
- GNULIB_REVISION is set in bootstrap.conf, then that revision is
- checked out.
- If you maintain a package and want to pin a particular revision of the
- Gnulib sources that has been tested with your package, then there are
- two possible approaches: either configure a 'gnulib' submodule with the
- appropriate revision, or set GNULIB_REVISION (and if necessary
- GNULIB_URL) in bootstrap.conf.
- Running without arguments will suffice in most cases.
- EOF
- }
- pull=false
- gen=false
- copy=false
- use_git=true
- for option
- do
- case $option in
- --help)
- usage
- exit;;
- --version)
- set -e
- echo "bootstrap $scriptversion lib $scriptlibversion"
- echo "$copyright"
- exit 0
- ;;
- --pull)
- pull=true;;
- --gen)
- gen=true;;
- --gnulib-srcdir=*)
- GNULIB_SRCDIR=${option#--gnulib-srcdir=};;
- --gnulib-refdir=*)
- GNULIB_REFDIR=${option#--gnulib-refdir=};;
- --skip-po)
- SKIP_PO=t;;
- --force)
- checkout_only_file=;;
- --copy)
- copy=true;;
- --bootstrap-sync)
- bootstrap_sync=true;;
- --no-bootstrap-sync)
- bootstrap_sync=false;;
- --no-git)
- use_git=false;;
- *)
- bootstrap_option_hook $option || die "$option: unknown option";;
- esac
- done
- $pull || $gen || pull=true gen=true
- $use_git || test -n "$GNULIB_SRCDIR" \
- || die "Error: --no-git requires \$GNULIB_SRCDIR environment variable or --gnulib-srcdir option"
- test -z "$GNULIB_SRCDIR" || test -d "$GNULIB_SRCDIR" \
- || die "Error: \$GNULIB_SRCDIR environment variable or --gnulib-srcdir option is specified, but does not denote a directory"
- if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
- die "Bootstrapping from a non-checked-out distribution is risky."
- fi
- check_build_prerequisites $use_git
- if $bootstrap_sync; then
- prepare_GNULIB_SRCDIR
- upgrade_bootstrap
-
- bootstrap_sync=false
- fi
- echo "$0: Bootstrapping from checked-out $package sources..."
- export GNULIB_SRCDIR
- export GNULIB_REFDIR
- if $pull && { $use_git || test -z "$SKIP_PO"; }; then
- autopull \
- `if $bootstrap_sync; then echo ' --bootstrap-sync'; else echo ' --no-bootstrap-sync'; fi` \
- `if test -z "$checkout_only_file"; then echo ' --force'; fi` \
- `if ! $use_git; then echo ' --no-git'; fi` \
- `if test -n "$SKIP_PO"; then echo ' --skip-po'; fi` \
- || die "could not fetch auxiliary files"
- fi
- if $gen; then
- autogen \
- `if $copy; then echo ' --copy'; fi` \
- `if test -z "$checkout_only_file"; then echo ' --force'; fi` \
- || die "could not generate auxiliary files"
- fi
|