12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508 |
- #! /bin/sh
- scriptversion=2022-12-27.07;
- me="$0"
- medir=`dirname "$me"`
- scriptlibversion=2023-06-06.21;
- 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"
- AUTORECONFFLAGS="$AUTORECONFFLAGS --no-recursive"
-
- 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
|