Blame bootstrap

Packit 33f14e
#! /bin/sh
Packit 33f14e
# Print a version string.
Packit 33f14e
scriptversion=2017-01-09.19; # UTC
Packit 33f14e
Packit 33f14e
# Bootstrap this package from checked-out sources.
Packit 33f14e
Packit 33f14e
# Copyright (C) 2003-2017 Free Software Foundation, Inc.
Packit 33f14e
Packit 33f14e
# This program is free software: you can redistribute it and/or modify
Packit 33f14e
# it under the terms of the GNU General Public License as published by
Packit 33f14e
# the Free Software Foundation, either version 3 of the License, or
Packit 33f14e
# (at your option) any later version.
Packit 33f14e
Packit 33f14e
# This program is distributed in the hope that it will be useful,
Packit 33f14e
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 33f14e
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 33f14e
# GNU General Public License for more details.
Packit 33f14e
Packit 33f14e
# You should have received a copy of the GNU General Public License
Packit 33f14e
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit 33f14e
Packit 33f14e
# Originally written by Paul Eggert.  The canonical version of this
Packit 33f14e
# script is maintained as build-aux/bootstrap in gnulib, however, to
Packit 33f14e
# be useful to your project, you should place a copy of it under
Packit 33f14e
# version control in the top-level directory of your project.  The
Packit 33f14e
# intent is that all customization can be done with a bootstrap.conf
Packit 33f14e
# file also maintained in your version control; gnulib comes with a
Packit 33f14e
# template build-aux/bootstrap.conf to get you started.
Packit 33f14e
Packit 33f14e
# Please report bugs or propose patches to bug-gnulib@gnu.org.
Packit 33f14e
Packit 33f14e
nl='
Packit 33f14e
'
Packit 33f14e
Packit 33f14e
# Ensure file names are sorted consistently across platforms.
Packit 33f14e
LC_ALL=C
Packit 33f14e
export LC_ALL
Packit 33f14e
Packit 33f14e
# Ensure that CDPATH is not set.  Otherwise, the output from cd
Packit 33f14e
# would cause trouble in at least one use below.
Packit 33f14e
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
Packit 33f14e
Packit 33f14e
local_gl_dir=gl
Packit 33f14e
Packit 33f14e
# Honor $PERL, but work even if there is none.
Packit 33f14e
PERL="${PERL-perl}"
Packit 33f14e
Packit 33f14e
me=$0
Packit 33f14e
Packit 33f14e
usage() {
Packit 33f14e
  cat <
Packit 33f14e
Usage: $me [OPTION]...
Packit 33f14e
Bootstrap this package from the checked-out sources.
Packit 33f14e
Packit 33f14e
Options:
Packit 33f14e
 --gnulib-srcdir=DIRNAME  specify the local directory where gnulib
Packit 33f14e
                          sources reside.  Use this if you already
Packit 33f14e
                          have gnulib sources on your machine, and
Packit 33f14e
                          do not want to waste your bandwidth downloading
Packit 33f14e
                          them again.  Defaults to \$GNULIB_SRCDIR
Packit 33f14e
 --bootstrap-sync         if this bootstrap script is not identical to
Packit 33f14e
                          the version in the local gnulib sources,
Packit 33f14e
                          update this script, and then restart it with
Packit 33f14e
                          /bin/sh or the shell \$CONFIG_SHELL
Packit 33f14e
 --no-bootstrap-sync      do not check whether bootstrap is out of sync
Packit 33f14e
 --copy                   copy files instead of creating symbolic links
Packit 33f14e
 --force                  attempt to bootstrap even if the sources seem
Packit 33f14e
                          not to have been checked out
Packit 33f14e
 --no-git                 do not use git to update gnulib.  Requires that
Packit 33f14e
                          --gnulib-srcdir point to a correct gnulib snapshot
Packit 33f14e
 --skip-po                do not download po files
Packit 33f14e
Packit 33f14e
If the file $me.conf exists in the same directory as this script, its
Packit 33f14e
contents are read as shell variables to configure the bootstrap.
Packit 33f14e
Packit 33f14e
For build prerequisites, environment variables like \$AUTOCONF and \$AMTAR
Packit 33f14e
are honored.
Packit 33f14e
Packit 33f14e
Running without arguments will suffice in most cases.
Packit 33f14e
EOF
Packit 33f14e
}
Packit 33f14e
Packit 33f14e
# warnf_ FORMAT-STRING ARG1...
Packit 33f14e
warnf_ ()
Packit 33f14e
{
Packit 33f14e
  warnf_format_=$1
Packit 33f14e
  shift
Packit 33f14e
  nl='
Packit 33f14e
'
Packit 33f14e
  case $* in
Packit 33f14e
    *$nl*) me_=$(printf "$me"|tr "$nl|" '??')
Packit 33f14e
       printf "$warnf_format_" "$@" | sed "s|^|$me_: |" ;;
Packit 33f14e
    *) printf "$me: $warnf_format_" "$@" ;;
Packit 33f14e
  esac >&2
Packit 33f14e
}
Packit 33f14e
Packit 33f14e
# warn_ WORD1...
Packit 33f14e
warn_ ()
Packit 33f14e
{
Packit 33f14e
  # If IFS does not start with ' ', set it and emit the warning in a subshell.
Packit 33f14e
  case $IFS in
Packit 33f14e
    ' '*) warnf_ '%s\n' "$*";;
Packit 33f14e
    *)    (IFS=' '; warn_ "$@");;
Packit 33f14e
  esac
Packit 33f14e
}
Packit 33f14e
Packit 33f14e
# die WORD1...
Packit 33f14e
die() { warn_ "$@"; exit 1; }
Packit 33f14e
Packit 33f14e
# Configuration.
Packit 33f14e
Packit 33f14e
# Name of the Makefile.am
Packit 33f14e
gnulib_mk=gnulib.mk
Packit 33f14e
Packit 33f14e
# List of gnulib modules needed.
Packit 33f14e
gnulib_modules=
Packit 33f14e
Packit 33f14e
# Any gnulib files needed that are not in modules.
Packit 33f14e
gnulib_files=
Packit 33f14e
Packit 33f14e
: ${AUTOPOINT=autopoint}
Packit 33f14e
: ${AUTORECONF=autoreconf}
Packit 33f14e
Packit 33f14e
# A function to be called right after gnulib-tool is run.
Packit 33f14e
# Override it via your own definition in bootstrap.conf.
Packit 33f14e
bootstrap_post_import_hook() { :; }
Packit 33f14e
Packit 33f14e
# A function to be called after everything else in this script.
Packit 33f14e
# Override it via your own definition in bootstrap.conf.
Packit 33f14e
bootstrap_epilogue() { :; }
Packit 33f14e
Packit 33f14e
# The command to download all .po files for a specified domain into
Packit 33f14e
# a specified directory.  Fill in the first %s is the domain name, and
Packit 33f14e
# the second with the destination directory.  Use rsync's -L and -r
Packit 33f14e
# options because the latest/%s directory and the .po files within are
Packit 33f14e
# all symlinks.
Packit 33f14e
po_download_command_format=\
Packit 33f14e
"rsync --delete --exclude '*.s1' -Lrtvz \
Packit 33f14e
 'translationproject.org::tp/latest/%s/' '%s'"
Packit 33f14e
Packit 33f14e
# Fallback for downloading .po files (if rsync fails).
Packit 33f14e
po_download_command_format2=\
Packit 33f14e
"wget --mirror -nd -q -np -A.po -P '%s' \
Packit 33f14e
 http://translationproject.org/latest/%s/"
Packit 33f14e
Packit 33f14e
# Prefer a non-empty tarname (4th argument of AC_INIT if given), else
Packit 33f14e
# fall back to the package name (1st argument with munging)
Packit 33f14e
extract_package_name='
Packit 33f14e
  /^AC_INIT(\[*/{
Packit 33f14e
     s///
Packit 33f14e
     /^[^,]*,[^,]*,[^,]*,[ []*\([^][ ,)]\)/{
Packit 33f14e
       s//\1/
Packit 33f14e
       s/[],)].*//
Packit 33f14e
       p
Packit 33f14e
       q
Packit 33f14e
     }
Packit 33f14e
     s/[],)].*//
Packit 33f14e
     s/^GNU //
Packit 33f14e
     y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
Packit 33f14e
     s/[^abcdefghijklmnopqrstuvwxyz0123456789_]/-/g
Packit 33f14e
     p
Packit 33f14e
  }
Packit 33f14e
'
Packit 33f14e
package=$(sed -n "$extract_package_name" configure.ac) \
Packit 33f14e
  || die 'cannot find package name in configure.ac'
Packit 33f14e
gnulib_name=lib$package
Packit 33f14e
Packit 33f14e
build_aux=build-aux
Packit 33f14e
source_base=lib
Packit 33f14e
m4_base=m4
Packit 33f14e
doc_base=doc
Packit 33f14e
tests_base=tests
Packit 33f14e
gnulib_extra_files=''
Packit 33f14e
Packit 33f14e
# Additional gnulib-tool options to use.  Use "\newline" to break lines.
Packit 33f14e
gnulib_tool_option_extras=
Packit 33f14e
Packit 33f14e
# Other locale categories that need message catalogs.
Packit 33f14e
EXTRA_LOCALE_CATEGORIES=
Packit 33f14e
Packit 33f14e
# Additional xgettext options to use.  Use "\\\newline" to break lines.
Packit 33f14e
XGETTEXT_OPTIONS='\\\
Packit 33f14e
 --flag=_:1:pass-c-format\\\
Packit 33f14e
 --flag=N_:1:pass-c-format\\\
Packit 33f14e
 --flag=error:3:c-format --flag=error_at_line:5:c-format\\\
Packit 33f14e
'
Packit 33f14e
Packit 33f14e
# Package bug report address and copyright holder for gettext files
Packit 33f14e
COPYRIGHT_HOLDER='Free Software Foundation, Inc.'
Packit 33f14e
MSGID_BUGS_ADDRESS=bug-$package@gnu.org
Packit 33f14e
Packit 33f14e
# Files we don't want to import.
Packit 33f14e
excluded_files=
Packit 33f14e
Packit 33f14e
# File that should exist in the top directory of a checked out hierarchy,
Packit 33f14e
# but not in a distribution tarball.
Packit 33f14e
checkout_only_file=README-hacking
Packit 33f14e
Packit 33f14e
# Whether to use copies instead of symlinks.
Packit 33f14e
copy=false
Packit 33f14e
Packit 33f14e
# Set this to '.cvsignore .gitignore' in bootstrap.conf if you want
Packit 33f14e
# those files to be generated in directories like lib/, m4/, and po/.
Packit 33f14e
# Or set it to 'auto' to make this script select which to use based
Packit 33f14e
# on which version control system (if any) is used in the source directory.
Packit 33f14e
vc_ignore=auto
Packit 33f14e
Packit 33f14e
# Set this to true in bootstrap.conf to enable --bootstrap-sync by
Packit 33f14e
# default.
Packit 33f14e
bootstrap_sync=false
Packit 33f14e
Packit 33f14e
# Use git to update gnulib sources
Packit 33f14e
use_git=true
Packit 33f14e
Packit 33f14e
check_exists() {
Packit 33f14e
  if test "$1" = "--verbose"; then
Packit 33f14e
    ($2 --version </dev/null) >/dev/null 2>&1
Packit 33f14e
    if test $? -ge 126; then
Packit 33f14e
      # If not found, run with diagnostics as one may be
Packit 33f14e
      # presented with env variables to set to find the right version
Packit 33f14e
      ($2 --version 
Packit 33f14e
    fi
Packit 33f14e
  else
Packit 33f14e
    ($1 --version </dev/null) >/dev/null 2>&1
Packit 33f14e
  fi
Packit 33f14e
Packit 33f14e
  test $? -lt 126
Packit 33f14e
}
Packit 33f14e
Packit 33f14e
# find_tool ENVVAR NAMES...
Packit 33f14e
# -------------------------
Packit 33f14e
# Search for a required program.  Use the value of ENVVAR, if set,
Packit 33f14e
# otherwise find the first of the NAMES that can be run.
Packit 33f14e
# If found, set ENVVAR to the program name, die otherwise.
Packit 33f14e
#
Packit 33f14e
# FIXME: code duplication, see also gnu-web-doc-update.
Packit 33f14e
find_tool ()
Packit 33f14e
{
Packit 33f14e
  find_tool_envvar=$1
Packit 33f14e
  shift
Packit 33f14e
  find_tool_names=$@
Packit 33f14e
  eval "find_tool_res=\$$find_tool_envvar"
Packit 33f14e
  if test x"$find_tool_res" = x; then
Packit 33f14e
    for i; do
Packit 33f14e
      if check_exists $i; then
Packit 33f14e
        find_tool_res=$i
Packit 33f14e
        break
Packit 33f14e
      fi
Packit 33f14e
    done
Packit 33f14e
  fi
Packit 33f14e
  if test x"$find_tool_res" = x; then
Packit 33f14e
    warn_ "one of these is required: $find_tool_names;"
Packit 33f14e
    die   "alternatively set $find_tool_envvar to a compatible tool"
Packit 33f14e
  fi
Packit 33f14e
  eval "$find_tool_envvar=\$find_tool_res"
Packit 33f14e
  eval "export $find_tool_envvar"
Packit 33f14e
}
Packit 33f14e
Packit 33f14e
# Override the default configuration, if necessary.
Packit 33f14e
# Make sure that bootstrap.conf is sourced from the current directory
Packit 33f14e
# if we were invoked as "sh bootstrap".
Packit 33f14e
case "$0" in
Packit 33f14e
  */*) test -r "$0.conf" && . "$0.conf" ;;
Packit 33f14e
  *) test -r "$0.conf" && . ./"$0.conf" ;;
Packit 33f14e
esac
Packit 33f14e
Packit 33f14e
# Extra files from gnulib, which override files from other sources.
Packit 33f14e
test -z "${gnulib_extra_files}" && \
Packit 33f14e
  gnulib_extra_files="
Packit 33f14e
        build-aux/install-sh
Packit 33f14e
        build-aux/mdate-sh
Packit 33f14e
        build-aux/texinfo.tex
Packit 33f14e
        build-aux/depcomp
Packit 33f14e
        build-aux/config.guess
Packit 33f14e
        build-aux/config.sub
Packit 33f14e
        doc/INSTALL
Packit 33f14e
"
Packit 33f14e
Packit 33f14e
if test "$vc_ignore" = auto; then
Packit 33f14e
  vc_ignore=
Packit 33f14e
  test -d .git && vc_ignore=.gitignore
Packit 33f14e
  test -d CVS && vc_ignore="$vc_ignore .cvsignore"
Packit 33f14e
fi
Packit 33f14e
Packit 33f14e
# Translate configuration into internal form.
Packit 33f14e
Packit 33f14e
# Parse options.
Packit 33f14e
Packit 33f14e
for option
Packit 33f14e
do
Packit 33f14e
  case $option in
Packit 33f14e
  --help)
Packit 33f14e
    usage
Packit 33f14e
    exit;;
Packit 33f14e
  --gnulib-srcdir=*)
Packit 33f14e
    GNULIB_SRCDIR=${option#--gnulib-srcdir=};;
Packit 33f14e
  --skip-po)
Packit 33f14e
    SKIP_PO=t;;
Packit 33f14e
  --force)
Packit 33f14e
    checkout_only_file=;;
Packit 33f14e
  --copy)
Packit 33f14e
    copy=true;;
Packit 33f14e
  --bootstrap-sync)
Packit 33f14e
    bootstrap_sync=true;;
Packit 33f14e
  --no-bootstrap-sync)
Packit 33f14e
    bootstrap_sync=false;;
Packit 33f14e
  --no-git)
Packit 33f14e
    use_git=false;;
Packit 33f14e
  *)
Packit 33f14e
    die "$option: unknown option";;
Packit 33f14e
  esac
Packit 33f14e
done
Packit 33f14e
Packit 33f14e
$use_git || test -d "$GNULIB_SRCDIR" \
Packit 33f14e
  || die "Error: --no-git requires --gnulib-srcdir"
Packit 33f14e
Packit 33f14e
if test -n "$checkout_only_file" && test ! -r "$checkout_only_file"; then
Packit 33f14e
  die "Bootstrapping from a non-checked-out distribution is risky."
Packit 33f14e
fi
Packit 33f14e
Packit 33f14e
# Strip blank and comment lines to leave significant entries.
Packit 33f14e
gitignore_entries() {
Packit 33f14e
  sed '/^#/d; /^$/d' "$@"
Packit 33f14e
}
Packit 33f14e
Packit 33f14e
# If $STR is not already on a line by itself in $FILE, insert it at the start.
Packit 33f14e
# Entries are inserted at the start of the ignore list to ensure existing
Packit 33f14e
# entries starting with ! are not overridden.  Such entries support
Packit 33f14e
# whitelisting exceptions after a more generic blacklist pattern.
Packit 33f14e
insert_if_absent() {
Packit 33f14e
  file=$1
Packit 33f14e
  str=$2
Packit 33f14e
  test -f $file || touch $file
Packit 33f14e
  test -r $file || die "Error: failed to read ignore file: $file"
Packit 33f14e
  duplicate_entries=$(gitignore_entries $file | sort | uniq -d)
Packit 33f14e
  if [ "$duplicate_entries" ] ; then
Packit 33f14e
    die "Error: Duplicate entries in $file: " $duplicate_entries
Packit 33f14e
  fi
Packit 33f14e
  linesold=$(gitignore_entries $file | wc -l)
Packit 33f14e
  linesnew=$( { echo "$str"; cat $file; } | gitignore_entries | sort -u | wc -l)
Packit 33f14e
  if [ $linesold != $linesnew ] ; then
Packit 33f14e
    { echo "$str" | cat - $file > $file.bak && mv $file.bak $file; } \
Packit 33f14e
      || die "insert_if_absent $file $str: failed"
Packit 33f14e
  fi
Packit 33f14e
}
Packit 33f14e
Packit 33f14e
# Adjust $PATTERN for $VC_IGNORE_FILE and insert it with
Packit 33f14e
# insert_if_absent.
Packit 33f14e
insert_vc_ignore() {
Packit 33f14e
  vc_ignore_file="$1"
Packit 33f14e
  pattern="$2"
Packit 33f14e
  case $vc_ignore_file in
Packit 33f14e
  *.gitignore)
Packit 33f14e
    # A .gitignore entry that does not start with '/' applies
Packit 33f14e
    # recursively to subdirectories, so prepend '/' to every
Packit 33f14e
    # .gitignore entry.
Packit 33f14e
    pattern=$(echo "$pattern" | sed s,^,/,);;
Packit 33f14e
  esac
Packit 33f14e
  insert_if_absent "$vc_ignore_file" "$pattern"
Packit 33f14e
}
Packit 33f14e
Packit 33f14e
# Die if there is no AC_CONFIG_AUX_DIR($build_aux) line in configure.ac.
Packit 33f14e
found_aux_dir=no
Packit 33f14e
grep '^[	 ]*AC_CONFIG_AUX_DIR(\['"$build_aux"'\])' configure.ac \
Packit 33f14e
    >/dev/null && found_aux_dir=yes
Packit 33f14e
grep '^[	 ]*AC_CONFIG_AUX_DIR('"$build_aux"')' configure.ac \
Packit 33f14e
    >/dev/null && found_aux_dir=yes
Packit 33f14e
test $found_aux_dir = yes \
Packit 33f14e
  || die "configure.ac lacks 'AC_CONFIG_AUX_DIR([$build_aux])'; add it"
Packit 33f14e
Packit 33f14e
# If $build_aux doesn't exist, create it now, otherwise some bits
Packit 33f14e
# below will malfunction.  If creating it, also mark it as ignored.
Packit 33f14e
if test ! -d $build_aux; then
Packit 33f14e
  mkdir $build_aux
Packit 33f14e
  for dot_ig in x $vc_ignore; do
Packit 33f14e
    test $dot_ig = x && continue
Packit 33f14e
    insert_vc_ignore $dot_ig $build_aux
Packit 33f14e
  done
Packit 33f14e
fi
Packit 33f14e
Packit 33f14e
# Note this deviates from the version comparison in automake
Packit 33f14e
# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
Packit 33f14e
# but this should suffice as we won't be specifying old
Packit 33f14e
# version formats or redundant trailing .0 in bootstrap.conf.
Packit 33f14e
# If we did want full compatibility then we should probably
Packit 33f14e
# use m4_version_compare from autoconf.
Packit 33f14e
sort_ver() { # sort -V is not generally available
Packit 33f14e
  ver1="$1"
Packit 33f14e
  ver2="$2"
Packit 33f14e
Packit 33f14e
  # split on '.' and compare each component
Packit 33f14e
  i=1
Packit 33f14e
  while : ; do
Packit 33f14e
    p1=$(echo "$ver1" | cut -d. -f$i)
Packit 33f14e
    p2=$(echo "$ver2" | cut -d. -f$i)
Packit 33f14e
    if [ ! "$p1" ]; then
Packit 33f14e
      echo "$1 $2"
Packit 33f14e
      break
Packit 33f14e
    elif [ ! "$p2" ]; then
Packit 33f14e
      echo "$2 $1"
Packit 33f14e
      break
Packit 33f14e
    elif [ ! "$p1" = "$p2" ]; then
Packit 33f14e
      if [ "$p1" -gt "$p2" ] 2>/dev/null; then # numeric comparison
Packit 33f14e
        echo "$2 $1"
Packit 33f14e
      elif [ "$p2" -gt "$p1" ] 2>/dev/null; then # numeric comparison
Packit 33f14e
        echo "$1 $2"
Packit 33f14e
      else # numeric, then lexicographic comparison
Packit 33f14e
        lp=$(printf "$p1\n$p2\n" | LANG=C sort -n | tail -n1)
Packit 33f14e
        if [ "$lp" = "$p2" ]; then
Packit 33f14e
          echo "$1 $2"
Packit 33f14e
        else
Packit 33f14e
          echo "$2 $1"
Packit 33f14e
        fi
Packit 33f14e
      fi
Packit 33f14e
      break
Packit 33f14e
    fi
Packit 33f14e
    i=$(($i+1))
Packit 33f14e
  done
Packit 33f14e
}
Packit 33f14e
Packit 33f14e
get_version_sed='
Packit 33f14e
# Move version to start of line.
Packit 33f14e
s/.*[v ]\([0-9]\)/\1/
Packit 33f14e
Packit 33f14e
# Skip lines that do not start with version.
Packit 33f14e
/^[0-9]/!d
Packit 33f14e
Packit 33f14e
# Remove characters after the version.
Packit 33f14e
s/[^.a-z0-9-].*//
Packit 33f14e
Packit 33f14e
# The first component must be digits only.
Packit 33f14e
s/^\([0-9]*\)[a-z-].*/\1/
Packit 33f14e
Packit 33f14e
#the following essentially does s/5.005/5.5/
Packit 33f14e
s/\.0*\([1-9]\)/.\1/g
Packit 33f14e
p
Packit 33f14e
q'
Packit 33f14e
Packit 33f14e
get_version() {
Packit 33f14e
  app=$1
Packit 33f14e
Packit 33f14e
  $app --version >/dev/null 2>&1 || { $app --version; return 1; }
Packit 33f14e
Packit 33f14e
  $app --version 2>&1 | sed -n "$get_version_sed"
Packit 33f14e
}
Packit 33f14e
Packit 33f14e
check_versions() {
Packit 33f14e
  ret=0
Packit 33f14e
Packit 33f14e
  while read app req_ver; do
Packit 33f14e
    # We only need libtoolize from the libtool package.
Packit 33f14e
    if test "$app" = libtool; then
Packit 33f14e
      app=libtoolize
Packit 33f14e
    fi
Packit 33f14e
    # Exempt git if --no-git is in effect.
Packit 33f14e
    if test "$app" = git; then
Packit 33f14e
      $use_git || continue
Packit 33f14e
    fi
Packit 33f14e
    # Honor $APP variables ($TAR, $AUTOCONF, etc.)
Packit 33f14e
    appvar=$(echo $app | LC_ALL=C tr '[a-z]-' '[A-Z]_')
Packit 33f14e
    test "$appvar" = TAR && appvar=AMTAR
Packit 33f14e
    case $appvar in
Packit 33f14e
        GZIP) ;; # Do not use $GZIP:  it contains gzip options.
Packit 33f14e
        PERL::*) ;; # Keep perl modules as-is
Packit 33f14e
        *) eval "app=\${$appvar-$app}" ;;
Packit 33f14e
    esac
Packit 33f14e
Packit 33f14e
    # Handle the still-experimental Automake-NG programs specially.
Packit 33f14e
    # They remain named as the mainstream Automake programs ("automake",
Packit 33f14e
    # and "aclocal") to avoid gratuitous incompatibilities with
Packit 33f14e
    # pre-existing usages (by, say, autoreconf, or custom autogen.sh
Packit 33f14e
    # scripts), but correctly identify themselves (as being part of
Packit 33f14e
    # "GNU automake-ng") when asked their version.
Packit 33f14e
    case $app in
Packit 33f14e
      automake-ng|aclocal-ng)
Packit 33f14e
        app=${app%-ng}
Packit 33f14e
        ($app --version | grep '(GNU automake-ng)') >/dev/null 2>&1 || {
Packit 33f14e
          warn_ "Error: '$app' not found or not from Automake-NG"
Packit 33f14e
          ret=1
Packit 33f14e
          continue
Packit 33f14e
        } ;;
Packit 33f14e
      # Another check is for perl modules.  These can be written as
Packit 33f14e
      # e.g. perl::XML::XPath in case of XML::XPath module, etc.
Packit 33f14e
      perl::*)
Packit 33f14e
        # Extract module name
Packit 33f14e
        app="${app#perl::}"
Packit 33f14e
        if ! $PERL -m"$app" -e 'exit 0' >/dev/null 2>&1; then
Packit 33f14e
          warn_ "Error: perl module '$app' not found"
Packit 33f14e
          ret=1
Packit 33f14e
        fi
Packit 33f14e
        continue
Packit 33f14e
        ;;
Packit 33f14e
    esac
Packit 33f14e
    if [ "$req_ver" = "-" ]; then
Packit 33f14e
      # Merely require app to exist; not all prereq apps are well-behaved
Packit 33f14e
      # so we have to rely on $? rather than get_version.
Packit 33f14e
      if ! check_exists --verbose $app; then
Packit 33f14e
        warn_ "Error: '$app' not found"
Packit 33f14e
        ret=1
Packit 33f14e
      fi
Packit 33f14e
    else
Packit 33f14e
      # Require app to produce a new enough version string.
Packit 33f14e
      inst_ver=$(get_version $app)
Packit 33f14e
      if [ ! "$inst_ver" ]; then
Packit 33f14e
        warn_ "Error: '$app' not found"
Packit 33f14e
        ret=1
Packit 33f14e
      else
Packit 33f14e
        latest_ver=$(sort_ver $req_ver $inst_ver | cut -d' ' -f2)
Packit 33f14e
        if [ ! "$latest_ver" = "$inst_ver" ]; then
Packit 33f14e
          warnf_ '%s\n'                                        \
Packit 33f14e
              "Error: '$app' version == $inst_ver is too old"  \
Packit 33f14e
              "       '$app' version >= $req_ver is required"
Packit 33f14e
          ret=1
Packit 33f14e
        fi
Packit 33f14e
      fi
Packit 33f14e
    fi
Packit 33f14e
  done
Packit 33f14e
Packit 33f14e
  return $ret
Packit 33f14e
}
Packit 33f14e
Packit 33f14e
print_versions() {
Packit 33f14e
  echo "Program    Min_version"
Packit 33f14e
  echo "----------------------"
Packit 33f14e
  printf %s "$buildreq"
Packit 33f14e
  echo "----------------------"
Packit 33f14e
  # can't depend on column -t
Packit 33f14e
}
Packit 33f14e
Packit 33f14e
# Find sha1sum, named gsha1sum on MacPorts, shasum on Mac OS X 10.6.
Packit 33f14e
# Also find the compatible sha1 utility on the BSDs
Packit 33f14e
if test x"$SKIP_PO" = x; then
Packit 33f14e
  find_tool SHA1SUM sha1sum gsha1sum shasum sha1
Packit 33f14e
fi
Packit 33f14e
Packit 33f14e
use_libtool=0
Packit 33f14e
# We'd like to use grep -E, to see if any of LT_INIT,
Packit 33f14e
# AC_PROG_LIBTOOL, AM_PROG_LIBTOOL is used in configure.ac,
Packit 33f14e
# but that's not portable enough (e.g., for Solaris).
Packit 33f14e
grep '^[	 ]*A[CM]_PROG_LIBTOOL' configure.ac >/dev/null \
Packit 33f14e
  && use_libtool=1
Packit 33f14e
grep '^[	 ]*LT_INIT' configure.ac >/dev/null \
Packit 33f14e
  && use_libtool=1
Packit 33f14e
if test $use_libtool = 1; then
Packit 33f14e
  find_tool LIBTOOLIZE glibtoolize libtoolize
Packit 33f14e
fi
Packit 33f14e
Packit 33f14e
# gnulib-tool requires at least automake and autoconf.
Packit 33f14e
# If either is not listed, add it (with minimum version) as a prerequisite.
Packit 33f14e
case $buildreq in
Packit 33f14e
  *automake*) ;;
Packit 33f14e
  *) buildreq="automake 1.9
Packit 33f14e
$buildreq" ;;
Packit 33f14e
esac
Packit 33f14e
case $buildreq in
Packit 33f14e
  *autoconf*) ;;
Packit 33f14e
  *) buildreq="autoconf 2.59
Packit 33f14e
$buildreq" ;;
Packit 33f14e
esac
Packit 33f14e
Packit 33f14e
# When we can deduce that gnulib-tool will require patch,
Packit 33f14e
# and when patch is not already listed as a prerequisite, add it, too.
Packit 33f14e
if test -d "$local_gl_dir" \
Packit 33f14e
    && ! find "$local_gl_dir" -name '*.diff' -exec false {} +; then
Packit 33f14e
  case $buildreq in
Packit 33f14e
    *patch*) ;;
Packit 33f14e
    *) buildreq="patch -
Packit 33f14e
$buildreq" ;;
Packit 33f14e
  esac
Packit 33f14e
fi
Packit 33f14e
Packit 33f14e
if ! printf "$buildreq" | check_versions; then
Packit 33f14e
  echo >&2
Packit 33f14e
  if test -f README-prereq; then
Packit 33f14e
    die "See README-prereq for how to get the prerequisite programs"
Packit 33f14e
  else
Packit 33f14e
    die "Please install the prerequisite programs"
Packit 33f14e
  fi
Packit 33f14e
fi
Packit 33f14e
Packit 33f14e
# Warn the user if autom4te appears to be broken; this causes known
Packit 33f14e
# issues with at least gettext 0.18.3.
Packit 33f14e
probe=$(echo 'm4_quote([hi])' | autom4te -l M4sugar -t 'm4_quote:$%' -)
Packit 33f14e
if test "x$probe" != xhi; then
Packit 33f14e
  warn_ "WARNING: your autom4te wrapper eats stdin;"
Packit 33f14e
  warn_ "if bootstrap fails, consider upgrading your autotools"
Packit 33f14e
fi
Packit 33f14e
Packit 33f14e
echo "$0: Bootstrapping from checked-out $package sources..."
Packit 33f14e
Packit 33f14e
# See if we can use gnulib's git-merge-changelog merge driver.
Packit 33f14e
if $use_git && test -d .git && check_exists git; then
Packit 33f14e
  if git config merge.merge-changelog.driver >/dev/null ; then
Packit 33f14e
    :
Packit 33f14e
  elif check_exists git-merge-changelog; then
Packit 33f14e
    echo "$0: initializing git-merge-changelog driver"
Packit 33f14e
    git config merge.merge-changelog.name 'GNU-style ChangeLog merge driver'
Packit 33f14e
    git config merge.merge-changelog.driver 'git-merge-changelog %O %A %B'
Packit 33f14e
  else
Packit 33f14e
    echo "$0: consider installing git-merge-changelog from gnulib"
Packit 33f14e
  fi
Packit 33f14e
fi
Packit 33f14e
Packit 33f14e
Packit 33f14e
cleanup_gnulib() {
Packit 33f14e
  status=$?
Packit 33f14e
  rm -fr "$gnulib_path"
Packit 33f14e
  exit $status
Packit 33f14e
}
Packit 33f14e
Packit 33f14e
git_modules_config () {
Packit 33f14e
  test -f .gitmodules && git config --file .gitmodules "$@"
Packit 33f14e
}
Packit 33f14e
Packit 33f14e
if $use_git; then
Packit 33f14e
  gnulib_path=$(git_modules_config submodule.gnulib.path)
Packit 33f14e
  test -z "$gnulib_path" && gnulib_path=gnulib
Packit 33f14e
fi
Packit 33f14e
Packit 33f14e
# Get gnulib files.  Populate $GNULIB_SRCDIR, possibly updating a
Packit 33f14e
# submodule, for use in the rest of the script.
Packit 33f14e
Packit 33f14e
case ${GNULIB_SRCDIR--} in
Packit 33f14e
-)
Packit 33f14e
  # Note that $use_git is necessarily true in this case.
Packit 33f14e
  if git_modules_config submodule.gnulib.url >/dev/null; then
Packit 33f14e
    echo "$0: getting gnulib files..."
Packit 33f14e
    git submodule init -- "$gnulib_path" || exit $?
Packit 33f14e
    git submodule update -- "$gnulib_path" || exit $?
Packit 33f14e
Packit 33f14e
  elif [ ! -d "$gnulib_path" ]; then
Packit 33f14e
    echo "$0: getting gnulib files..."
Packit 33f14e
Packit 33f14e
    trap cleanup_gnulib 1 2 13 15
Packit 33f14e
Packit 33f14e
    shallow=
Packit 33f14e
    git clone -h 2>&1 | grep -- --depth > /dev/null && shallow='--depth 2'
Packit 33f14e
    git clone $shallow git://git.sv.gnu.org/gnulib "$gnulib_path" ||
Packit 33f14e
      cleanup_gnulib
Packit 33f14e
Packit 33f14e
    trap - 1 2 13 15
Packit 33f14e
  fi
Packit 33f14e
  GNULIB_SRCDIR=$gnulib_path
Packit 33f14e
  ;;
Packit 33f14e
*)
Packit 33f14e
  # Use GNULIB_SRCDIR directly or as a reference.
Packit 33f14e
  if $use_git && test -d "$GNULIB_SRCDIR"/.git && \
Packit 33f14e
        git_modules_config submodule.gnulib.url >/dev/null; then
Packit 33f14e
    echo "$0: getting gnulib files..."
Packit 33f14e
    if git submodule -h|grep -- --reference > /dev/null; then
Packit 33f14e
      # Prefer the one-liner available in git 1.6.4 or newer.
Packit 33f14e
      git submodule update --init --reference "$GNULIB_SRCDIR" \
Packit 33f14e
        "$gnulib_path" || exit $?
Packit 33f14e
    else
Packit 33f14e
      # This fallback allows at least git 1.5.5.
Packit 33f14e
      if test -f "$gnulib_path"/gnulib-tool; then
Packit 33f14e
        # Since file already exists, assume submodule init already complete.
Packit 33f14e
        git submodule update -- "$gnulib_path" || exit $?
Packit 33f14e
      else
Packit 33f14e
        # Older git can't clone into an empty directory.
Packit 33f14e
        rmdir "$gnulib_path" 2>/dev/null
Packit 33f14e
        git clone --reference "$GNULIB_SRCDIR" \
Packit 33f14e
          "$(git_modules_config submodule.gnulib.url)" "$gnulib_path" \
Packit 33f14e
          && git submodule init -- "$gnulib_path" \
Packit 33f14e
          && git submodule update -- "$gnulib_path" \
Packit 33f14e
          || exit $?
Packit 33f14e
      fi
Packit 33f14e
    fi
Packit 33f14e
    GNULIB_SRCDIR=$gnulib_path
Packit 33f14e
  fi
Packit 33f14e
  ;;
Packit 33f14e
esac
Packit 33f14e
Packit 33f14e
# $GNULIB_SRCDIR now points to the version of gnulib to use, and
Packit 33f14e
# we no longer need to use git or $gnulib_path below here.
Packit 33f14e
Packit 33f14e
if $bootstrap_sync; then
Packit 33f14e
  cmp -s "$0" "$GNULIB_SRCDIR/build-aux/bootstrap" || {
Packit 33f14e
    echo "$0: updating bootstrap and restarting..."
Packit 33f14e
    case $(sh -c 'echo "$1"' -- a) in
Packit 33f14e
      a) ignored=--;;
Packit 33f14e
      *) ignored=ignored;;
Packit 33f14e
    esac
Packit 33f14e
    exec sh -c \
Packit 33f14e
      'cp "$1" "$2" && shift && exec "${CONFIG_SHELL-/bin/sh}" "$@"' \
Packit 33f14e
      $ignored "$GNULIB_SRCDIR/build-aux/bootstrap" \
Packit 33f14e
      "$0" "$@" --no-bootstrap-sync
Packit 33f14e
  }
Packit 33f14e
fi
Packit 33f14e
Packit 33f14e
gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
Packit 33f14e
<$gnulib_tool || exit $?
Packit 33f14e
Packit 33f14e
# Get translations.
Packit 33f14e
Packit 33f14e
download_po_files() {
Packit 33f14e
  subdir=$1
Packit 33f14e
  domain=$2
Packit 33f14e
  echo "$me: getting translations into $subdir for $domain..."
Packit 33f14e
  cmd=$(printf "$po_download_command_format" "$domain" "$subdir")
Packit 33f14e
  eval "$cmd" && return
Packit 33f14e
  # Fallback to HTTP.
Packit 33f14e
  cmd=$(printf "$po_download_command_format2" "$subdir" "$domain")
Packit 33f14e
  eval "$cmd"
Packit 33f14e
}
Packit 33f14e
Packit 33f14e
# Mirror .po files to $po_dir/.reference and copy only the new
Packit 33f14e
# or modified ones into $po_dir.  Also update $po_dir/LINGUAS.
Packit 33f14e
# Note po files that exist locally only are left in $po_dir but will
Packit 33f14e
# not be included in LINGUAS and hence will not be distributed.
Packit 33f14e
update_po_files() {
Packit 33f14e
  # Directory containing primary .po files.
Packit 33f14e
  # Overwrite them only when we're sure a .po file is new.
Packit 33f14e
  po_dir=$1
Packit 33f14e
  domain=$2
Packit 33f14e
Packit 33f14e
  # Mirror *.po files into this dir.
Packit 33f14e
  # Usually contains *.s1 checksum files.
Packit 33f14e
  ref_po_dir="$po_dir/.reference"
Packit 33f14e
Packit 33f14e
  test -d $ref_po_dir || mkdir $ref_po_dir || return
Packit 33f14e
  download_po_files $ref_po_dir $domain \
Packit 33f14e
    && ls "$ref_po_dir"/*.po 2>/dev/null |
Packit 33f14e
      sed 's|.*/||; s|\.po$||' > "$po_dir/LINGUAS" || return
Packit 33f14e
Packit 33f14e
  langs=$(cd $ref_po_dir && echo *.po | sed 's/\.po//g')
Packit 33f14e
  test "$langs" = '*' && langs=x
Packit 33f14e
  for po in $langs; do
Packit 33f14e
    case $po in x) continue;; esac
Packit 33f14e
    new_po="$ref_po_dir/$po.po"
Packit 33f14e
    cksum_file="$ref_po_dir/$po.s1"
Packit 33f14e
    if ! test -f "$cksum_file" ||
Packit 33f14e
        ! test -f "$po_dir/$po.po" ||
Packit 33f14e
        ! $SHA1SUM -c "$cksum_file" < "$new_po" > /dev/null 2>&1; then
Packit 33f14e
      echo "$me: updated $po_dir/$po.po..."
Packit 33f14e
      cp "$new_po" "$po_dir/$po.po" \
Packit 33f14e
          && $SHA1SUM < "$new_po" > "$cksum_file" || return
Packit 33f14e
    fi
Packit 33f14e
  done
Packit 33f14e
}
Packit 33f14e
Packit 33f14e
case $SKIP_PO in
Packit 33f14e
'')
Packit 33f14e
  if test -d po; then
Packit 33f14e
    update_po_files po $package || exit
Packit 33f14e
  fi
Packit 33f14e
Packit 33f14e
  if test -d runtime-po; then
Packit 33f14e
    update_po_files runtime-po $package-runtime || exit
Packit 33f14e
  fi;;
Packit 33f14e
esac
Packit 33f14e
Packit 33f14e
symlink_to_dir()
Packit 33f14e
{
Packit 33f14e
  src=$1/$2
Packit 33f14e
  dst=${3-$2}
Packit 33f14e
Packit 33f14e
  test -f "$src" && {
Packit 33f14e
Packit 33f14e
    # If the destination directory doesn't exist, create it.
Packit 33f14e
    # This is required at least for "lib/uniwidth/cjk.h".
Packit 33f14e
    dst_dir=$(dirname "$dst")
Packit 33f14e
    if ! test -d "$dst_dir"; then
Packit 33f14e
      mkdir -p "$dst_dir"
Packit 33f14e
Packit 33f14e
      # If we've just created a directory like lib/uniwidth,
Packit 33f14e
      # tell version control system(s) it's ignorable.
Packit 33f14e
      # FIXME: for now, this does only one level
Packit 33f14e
      parent=$(dirname "$dst_dir")
Packit 33f14e
      for dot_ig in x $vc_ignore; do
Packit 33f14e
        test $dot_ig = x && continue
Packit 33f14e
        ig=$parent/$dot_ig
Packit 33f14e
        insert_vc_ignore $ig "${dst_dir##*/}"
Packit 33f14e
      done
Packit 33f14e
    fi
Packit 33f14e
Packit 33f14e
    if $copy; then
Packit 33f14e
      {
Packit 33f14e
        test ! -h "$dst" || {
Packit 33f14e
          echo "$me: rm -f $dst" &&
Packit 33f14e
          rm -f "$dst"
Packit 33f14e
        }
Packit 33f14e
      } &&
Packit 33f14e
      test -f "$dst" &&
Packit 33f14e
      cmp -s "$src" "$dst" || {
Packit 33f14e
        echo "$me: cp -fp $src $dst" &&
Packit 33f14e
        cp -fp "$src" "$dst"
Packit 33f14e
      }
Packit 33f14e
    else
Packit 33f14e
      # Leave any existing symlink alone, if it already points to the source,
Packit 33f14e
      # so that broken build tools that care about symlink times
Packit 33f14e
      # aren't confused into doing unnecessary builds.  Conversely, if the
Packit 33f14e
      # existing symlink's timestamp is older than the source, make it afresh,
Packit 33f14e
      # so that broken tools aren't confused into skipping needed builds.  See
Packit 33f14e
      # <http://lists.gnu.org/archive/html/bug-gnulib/2011-05/msg00326.html>.
Packit 33f14e
      test -h "$dst" &&
Packit 33f14e
      src_ls=$(ls -diL "$src" 2>/dev/null) && set $src_ls && src_i=$1 &&
Packit 33f14e
      dst_ls=$(ls -diL "$dst" 2>/dev/null) && set $dst_ls && dst_i=$1 &&
Packit 33f14e
      test "$src_i" = "$dst_i" &&
Packit 33f14e
      both_ls=$(ls -dt "$src" "$dst") &&
Packit 33f14e
      test "X$both_ls" = "X$dst$nl$src" || {
Packit 33f14e
        dot_dots=
Packit 33f14e
        case $src in
Packit 33f14e
        /*) ;;
Packit 33f14e
        *)
Packit 33f14e
          case /$dst/ in
Packit 33f14e
          *//* | */../* | */./* | /*/*/*/*/*/)
Packit 33f14e
             die "invalid symlink calculation: $src -> $dst";;
Packit 33f14e
          /*/*/*/*/)    dot_dots=../../../;;
Packit 33f14e
          /*/*/*/)      dot_dots=../../;;
Packit 33f14e
          /*/*/)        dot_dots=../;;
Packit 33f14e
          esac;;
Packit 33f14e
        esac
Packit 33f14e
Packit 33f14e
        echo "$me: ln -fs $dot_dots$src $dst" &&
Packit 33f14e
        ln -fs "$dot_dots$src" "$dst"
Packit 33f14e
      }
Packit 33f14e
    fi
Packit 33f14e
  }
Packit 33f14e
}
Packit 33f14e
Packit 33f14e
version_controlled_file() {
Packit 33f14e
  parent=$1
Packit 33f14e
  file=$2
Packit 33f14e
  if test -d .git; then
Packit 33f14e
    git rm -n "$file" > /dev/null 2>&1
Packit 33f14e
  elif test -d .svn; then
Packit 33f14e
    svn log -r HEAD "$file" > /dev/null 2>&1
Packit 33f14e
  elif test -d CVS; then
Packit 33f14e
    grep -F "/${file##*/}/" "$parent/CVS/Entries" 2>/dev/null |
Packit 33f14e
             grep '^/[^/]*/[0-9]' > /dev/null
Packit 33f14e
  else
Packit 33f14e
    warn_ "no version control for $file?"
Packit 33f14e
    false
Packit 33f14e
  fi
Packit 33f14e
}
Packit 33f14e
Packit 33f14e
# NOTE: we have to be careful to run both autopoint and libtoolize
Packit 33f14e
# before gnulib-tool, since gnulib-tool is likely to provide newer
Packit 33f14e
# versions of files "installed" by these two programs.
Packit 33f14e
# Then, *after* gnulib-tool (see below), we have to be careful to
Packit 33f14e
# run autoreconf in such a way that it does not run either of these
Packit 33f14e
# two just-pre-run programs.
Packit 33f14e
Packit 33f14e
# Import from gettext.
Packit 33f14e
with_gettext=yes
Packit 33f14e
grep '^[	 ]*AM_GNU_GETTEXT_VERSION(' configure.ac >/dev/null || \
Packit 33f14e
    with_gettext=no
Packit 33f14e
Packit 33f14e
if test $with_gettext = yes || test $use_libtool = 1; then
Packit 33f14e
Packit 33f14e
  tempbase=.bootstrap$$
Packit 33f14e
  trap "rm -f $tempbase.0 $tempbase.1" 1 2 13 15
Packit 33f14e
Packit 33f14e
  > $tempbase.0 > $tempbase.1 &&
Packit 33f14e
  find . ! -type d -print | sort > $tempbase.0 || exit
Packit 33f14e
Packit 33f14e
  if test $with_gettext = yes; then
Packit 33f14e
    # Released autopoint has the tendency to install macros that have been
Packit 33f14e
    # obsoleted in current gnulib, so run this before gnulib-tool.
Packit 33f14e
    echo "$0: $AUTOPOINT --force"
Packit 33f14e
    $AUTOPOINT --force || exit
Packit 33f14e
  fi
Packit 33f14e
Packit 33f14e
  # Autoreconf runs aclocal before libtoolize, which causes spurious
Packit 33f14e
  # warnings if the initial aclocal is confused by the libtoolized
Packit 33f14e
  # (or worse out-of-date) macro directory.
Packit 33f14e
  # libtoolize 1.9b added the --install option; but we support back
Packit 33f14e
  # to libtoolize 1.5.22, where the install action was default.
Packit 33f14e
  if test $use_libtool = 1; then
Packit 33f14e
    install=
Packit 33f14e
    case $($LIBTOOLIZE --help) in
Packit 33f14e
      *--install*) install=--install ;;
Packit 33f14e
    esac
Packit 33f14e
    echo "running: $LIBTOOLIZE $install --copy"
Packit 33f14e
    $LIBTOOLIZE $install --copy
Packit 33f14e
  fi
Packit 33f14e
Packit 33f14e
  find . ! -type d -print | sort >$tempbase.1
Packit 33f14e
  old_IFS=$IFS
Packit 33f14e
  IFS=$nl
Packit 33f14e
  for file in $(comm -13 $tempbase.0 $tempbase.1); do
Packit 33f14e
    IFS=$old_IFS
Packit 33f14e
    parent=${file%/*}
Packit 33f14e
    version_controlled_file "$parent" "$file" || {
Packit 33f14e
      for dot_ig in x $vc_ignore; do
Packit 33f14e
        test $dot_ig = x && continue
Packit 33f14e
        ig=$parent/$dot_ig
Packit 33f14e
        insert_vc_ignore "$ig" "${file##*/}"
Packit 33f14e
      done
Packit 33f14e
    }
Packit 33f14e
  done
Packit 33f14e
  IFS=$old_IFS
Packit 33f14e
Packit 33f14e
  rm -f $tempbase.0 $tempbase.1
Packit 33f14e
  trap - 1 2 13 15
Packit 33f14e
fi
Packit 33f14e
Packit 33f14e
# Import from gnulib.
Packit 33f14e
Packit 33f14e
gnulib_tool_options="\
Packit 33f14e
 --import\
Packit 33f14e
 --no-changelog\
Packit 33f14e
 --aux-dir $build_aux\
Packit 33f14e
 --doc-base $doc_base\
Packit 33f14e
 --lib $gnulib_name\
Packit 33f14e
 --m4-base $m4_base/\
Packit 33f14e
 --source-base $source_base/\
Packit 33f14e
 --tests-base $tests_base\
Packit 33f14e
 --local-dir $local_gl_dir\
Packit 33f14e
 $gnulib_tool_option_extras\
Packit 33f14e
"
Packit 33f14e
if test $use_libtool = 1; then
Packit 33f14e
  case "$gnulib_tool_options " in
Packit 33f14e
    *' --libtool '*) ;;
Packit 33f14e
    *) gnulib_tool_options="$gnulib_tool_options --libtool" ;;
Packit 33f14e
  esac
Packit 33f14e
fi
Packit 33f14e
echo "$0: $gnulib_tool $gnulib_tool_options --import ..."
Packit 33f14e
$gnulib_tool $gnulib_tool_options --import $gnulib_modules \
Packit 33f14e
  || die "gnulib-tool failed"
Packit 33f14e
Packit 33f14e
for file in $gnulib_files; do
Packit 33f14e
  symlink_to_dir "$GNULIB_SRCDIR" $file \
Packit 33f14e
    || die "failed to symlink $file"
Packit 33f14e
done
Packit 33f14e
Packit 33f14e
bootstrap_post_import_hook \
Packit 33f14e
  || die "bootstrap_post_import_hook failed"
Packit 33f14e
Packit 33f14e
# Remove any dangling symlink matching "*.m4" or "*.[ch]" in some
Packit 33f14e
# gnulib-populated directories.  Such .m4 files would cause aclocal to fail.
Packit 33f14e
# The following requires GNU find 4.2.3 or newer.  Considering the usual
Packit 33f14e
# portability constraints of this script, that may seem a very demanding
Packit 33f14e
# requirement, but it should be ok.  Ignore any failure, which is fine,
Packit 33f14e
# since this is only a convenience to help developers avoid the relatively
Packit 33f14e
# unusual case in which a symlinked-to .m4 file is git-removed from gnulib
Packit 33f14e
# between successive runs of this script.
Packit 33f14e
find "$m4_base" "$source_base" \
Packit 33f14e
  -depth \( -name '*.m4' -o -name '*.[ch]' \) \
Packit 33f14e
  -type l -xtype l -delete > /dev/null 2>&1
Packit 33f14e
Packit 33f14e
# Invoke autoreconf with --force --install to ensure upgrades of tools
Packit 33f14e
# such as ylwrap.
Packit 33f14e
AUTORECONFFLAGS="--verbose --install --force -I $m4_base $ACLOCAL_FLAGS"
Packit 33f14e
Packit 33f14e
# Some systems (RHEL 5) are using ancient autotools, for which the
Packit 33f14e
# --no-recursive option had not been invented.  Detect that lack and
Packit 33f14e
# omit the option when it's not supported.  FIXME in 2017: remove this
Packit 33f14e
# hack when RHEL 5 autotools are updated, or when they become irrelevant.
Packit 33f14e
case $($AUTORECONF --help) in
Packit 33f14e
  *--no-recursive*) AUTORECONFFLAGS="$AUTORECONFFLAGS --no-recursive";;
Packit 33f14e
esac
Packit 33f14e
Packit 33f14e
# Tell autoreconf not to invoke autopoint or libtoolize; they were run above.
Packit 33f14e
echo "running: AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS"
Packit 33f14e
AUTOPOINT=true LIBTOOLIZE=true $AUTORECONF $AUTORECONFFLAGS \
Packit 33f14e
  || die "autoreconf failed"
Packit 33f14e
Packit 33f14e
# Get some extra files from gnulib, overriding existing files.
Packit 33f14e
for file in $gnulib_extra_files; do
Packit 33f14e
  case $file in
Packit 33f14e
  */INSTALL) dst=INSTALL;;
Packit 33f14e
  build-aux/*) dst=$build_aux/${file#build-aux/};;
Packit 33f14e
  *) dst=$file;;
Packit 33f14e
  esac
Packit 33f14e
  symlink_to_dir "$GNULIB_SRCDIR" $file $dst \
Packit 33f14e
    || die "failed to symlink $file"
Packit 33f14e
done
Packit 33f14e
Packit 33f14e
if test $with_gettext = yes; then
Packit 33f14e
  # Create gettext configuration.
Packit 33f14e
  echo "$0: Creating po/Makevars from po/Makevars.template ..."
Packit 33f14e
  rm -f po/Makevars
Packit 33f14e
  sed '
Packit 33f14e
    /^EXTRA_LOCALE_CATEGORIES *=/s/=.*/= '"$EXTRA_LOCALE_CATEGORIES"'/
Packit 33f14e
    /^COPYRIGHT_HOLDER *=/s/=.*/= '"$COPYRIGHT_HOLDER"'/
Packit 33f14e
    /^MSGID_BUGS_ADDRESS *=/s|=.*|= '"$MSGID_BUGS_ADDRESS"'|
Packit 33f14e
    /^XGETTEXT_OPTIONS *=/{
Packit 33f14e
      s/$/ \\/
Packit 33f14e
      a\
Packit 33f14e
          '"$XGETTEXT_OPTIONS"' $${end_of_xgettext_options+}
Packit 33f14e
    }
Packit 33f14e
  ' po/Makevars.template >po/Makevars \
Packit 33f14e
    || die 'cannot generate po/Makevars'
Packit 33f14e
Packit 33f14e
  # If the 'gettext' module is in use, grab the latest Makefile.in.in.
Packit 33f14e
  # If only the 'gettext-h' module is in use, assume autopoint already
Packit 33f14e
  # put the correct version of this file into place.
Packit 33f14e
  case $gnulib_modules in
Packit 33f14e
  *gettext-h*) ;;
Packit 33f14e
  *gettext*)
Packit 33f14e
    cp $GNULIB_SRCDIR/build-aux/po/Makefile.in.in po/Makefile.in.in \
Packit 33f14e
      || die "cannot create po/Makefile.in.in"
Packit 33f14e
    ;;
Packit 33f14e
  esac
Packit 33f14e
Packit 33f14e
  if test -d runtime-po; then
Packit 33f14e
    # Similarly for runtime-po/Makevars, but not quite the same.
Packit 33f14e
    rm -f runtime-po/Makevars
Packit 33f14e
    sed '
Packit 33f14e
      /^DOMAIN *=.*/s/=.*/= '"$package"'-runtime/
Packit 33f14e
      /^subdir *=.*/s/=.*/= runtime-po/
Packit 33f14e
      /^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-'"$package"'@gnu.org/
Packit 33f14e
      /^XGETTEXT_OPTIONS *=/{
Packit 33f14e
        s/$/ \\/
Packit 33f14e
        a\
Packit 33f14e
            '"$XGETTEXT_OPTIONS_RUNTIME"' $${end_of_xgettext_options+}
Packit 33f14e
      }
Packit 33f14e
    ' po/Makevars.template >runtime-po/Makevars \
Packit 33f14e
    || die 'cannot generate runtime-po/Makevars'
Packit 33f14e
Packit 33f14e
    # Copy identical files from po to runtime-po.
Packit 33f14e
    (cd po && cp -p Makefile.in.in *-quot *.header *.sed *.sin ../runtime-po)
Packit 33f14e
  fi
Packit 33f14e
fi
Packit 33f14e
Packit 33f14e
bootstrap_epilogue
Packit 33f14e
Packit 33f14e
echo "$0: done.  Now you can run './configure'."
Packit 33f14e
Packit 33f14e
# Local variables:
Packit 33f14e
# eval: (add-hook 'write-file-hooks 'time-stamp)
Packit 33f14e
# time-stamp-start: "scriptversion="
Packit 33f14e
# time-stamp-format: "%:y-%02m-%02d.%02H"
Packit 33f14e
# time-stamp-time-zone: "UTC0"
Packit 33f14e
# time-stamp-end: "; # UTC"
Packit 33f14e
# End: