#! /bin/sh
#
-# Copyright (C) 2002-2013 Free Software Foundation, Inc.
+# Copyright (C) 2002-2015 Free Software Foundation, Inc.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
progname=$0
package=@PACKAGE@
version=@VERSION@
+archive_version=@ARCHIVE_VERSION@
# Set variables
-# - gettext_dir directory where the sources are stored.
+# - gettext_datadir directory where the data files are stored.
prefix="@prefix@"
datarootdir="@datarootdir@"
-gettext_dir="@datadir@/gettext"
+: ${gettext_datadir="@datadir@/gettext"}
+: ${AUTOM4TE=autom4te}
# func_tmpdir
# creates a temporary directory.
func_find_curr_installdir # determine curr_installdir
func_find_prefixes
# Relocate the directory variables that we use.
- gettext_dir=`echo "$gettext_dir/" | sed -e "s%^${orig_installprefix}/%${curr_installprefix}/%" | sed -e 's,/$,,'`
+ gettext_datadir=`echo "$gettext_datadir/" | sed -e "s%^${orig_installprefix}/%${curr_installprefix}/%" | sed -e 's,/$,,'`
fi
-# func_trace macro
-# traces an Autoconf macro call and outputs the arguments to stdout.
-func_trace ()
+# func_trace_autoconf macro configure.ac
+# traces an Autoconf macro call and outputs the arguments to stdout,
+# using autom4te.
+func_trace_autoconf ()
{
echo '\
-dnl disable macros which may abort autom4te
-m4_undefine([m4_assert])
-m4_undefine([m4_fatal])
-m4_undefine([m4_warn])
-m4_undefine([m4_errprintn])
-m4_undefine([m4_exit])
-m4_undefine([m4_include])
-m4_undefine([m4_esyscmd])
-dnl macros which needs to be traced without aclocal.m4
-m4_define([AM_GNU_GETTEXT], [])
-m4_define([AM_GNU_GETTEXT_VERSION], [])
+dnl replace macros which may abort autom4te with a no-op variant
+m4_pushdef([m4_assert])
+m4_pushdef([m4_fatal])
+m4_pushdef([m4_warn])
+m4_pushdef([m4_errprintn])
+m4_pushdef([m4_exit])
+m4_pushdef([m4_include])
+m4_pushdef([m4_esyscmd])
' \
- | ${AUTOM4TE:-autom4te} --no-cache --language=Autoconf-without-aclocal-m4 \
+ | "$AUTOM4TE" --no-cache --language=Autoconf-without-aclocal-m4 \
--trace="$1":\$% - "$2" 2>/dev/null
}
+# func_trace_sed macro configure.ac
+# traces an Autoconf macro call and outputs the arguments to stdout,
+# using sed.
+func_trace_sed ()
+{
+ sed_extract_arguments='
+s,#.*$,,; s,^dnl .*$,,; s, dnl .*$,,;
+/'"$1"'(/ {
+ ta
+ :a
+ s/)/)/
+ tb
+ s/\\$//
+ N
+ ba
+ :b
+ s,^.*'"$1"'([[ ]*\([^]"$`\\)]*\).*$,\1,p
+}
+d'
+ sed -e "$sed_extract_arguments" "$2"
+}
+
# func_usage
# outputs to stdout the --help usage message.
func_usage ()
exit 1
}
+# Nuisances.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+# Unset more variables known to interfere with behavior of common tools.
+CLICOLOR_FORCE= GREP_OPTIONS=
+unset CLICOLOR_FORCE GREP_OPTIONS
+
# Command-line option processing.
# Removes the OPTIONS from the arguments. Sets the variables:
# - force yes if --force was given, empty otherwise
fi
fi
-# Check whether the -V option and the version number in configure.in match.
-# At least one of the two must be given. If both are given, they must agree.
-xver=`func_trace AM_GNU_GETTEXT_VERSION "$configure_in"`
-if test -z "$xver" && test -f intl/VERSION; then
- xver=`cat intl/VERSION | LC_ALL=C sed -n -e 's/^.*gettext-\([-+_.0-9A-Za-z]*\).*$/\1/p'`
+# Select the method for Autoconf macro tracing. func_trace_autoconf
+# is more accurate than func_trace_sed, but it only works with
+# autoconf >= 2.69.
+if echo "AC_PREREQ([2.69])" \
+ | "$AUTOM4TE" --no-cache --language=Autoconf-without-aclocal-m4 - 2>&1; then
+ func_trace=func_trace_autoconf
+else
+ func_trace=func_trace_sed
fi
-if test -n "$xver"; then
- if test -n "$ver"; then
- if test "X$ver" != "X$xver"; then
- func_fatal_error "Version mismatch: specified -V $ver but the package uses gettext version $xver"
- fi
+
+# func_version_prereq required_version version
+# compares the required version and the latest archive version.
+func_version_prereq ()
+{
+ req="$1"
+ ver="$2"
+ echo "m4_if(m4_version_compare([$ver], [$req]), [-1], [m4_exit([1])])" \
+ | "$AUTOM4TE" --language=M4sugar 2>&1 >/dev/null
+}
+
+# If AM_GNU_GETTEXT_REQUIRE_VERSION is used and archive_version is newer than
+# that, use archive_version.
+xreq=`func_trace_sed AM_GNU_GETTEXT_REQUIRE_VERSION "$configure_in"`
+
+# Need to use func_trace_sed instead of $func_trace, since
+# AM_GNU_GETTEXT_VERSION is not a standard Autoconf trace.
+xver=`func_trace_sed AM_GNU_GETTEXT_VERSION "$configure_in"`
+
+# Prefer AM_GNU_GETTEXT_REQUIRE_VERSION over AM_GNU_GETTEXT_VERSION if both are
+# specified.
+if test -n "$xreq" && test -n "$xver"; then
+ echo "autopoint: using AM_GNU_GETTEXT_REQUIRE_VERSION instead of AM_GNU_GETTEXT_VERSION"
+fi
+
+if test -n "$xreq"; then
+ if func_version_prereq "$xreq" "$archive_version"; then
+ ver="$archive_version"
else
- ver="$xver"
+ func_fatal_error "gettext version $xreq or newer is required"
fi
else
- if test -z "$ver"; then
- func_fatal_error "Missing version: please specify in $configure_in through a line 'AM_GNU_GETTEXT_VERSION(x.yy.zz)' the gettext version the package is using"
+ if test -z "$xver" && test -f intl/VERSION; then
+ xver=`cat intl/VERSION | LC_ALL=C sed -n -e 's/^.*gettext-\([-+_.0-9A-Za-z]*\).*$/\1/p'`
+ fi
+
+ # Check whether the -V option and the version number in configure.in match.
+ # At least one of the two must be given. If both are given, they must agree.
+
+ if test -n "$xver"; then
+ if test -n "$ver"; then
+ if test "X$ver" != "X$xver"; then
+ func_fatal_error "Version mismatch: specified -V $ver but the package uses gettext version $xver"
+ fi
+ else
+ ver="$xver"
+ fi
fi
fi
+if test -z "$ver"; then
+ func_fatal_error "Missing version: please specify in $configure_in through a line 'AM_GNU_GETTEXT_VERSION(x.yy.zz)' the gettext version the package is using"
+fi
+
# Check whether the version number is supported.
case "$ver" in
0.10.35 | 0.10.36 | 0.10.37 | 0.10.38 | 0.10.39 | 0.10.40 | \
0.15 | \
0.16 | 0.16.1 | \
0.17 | \
- 0.18 | 0.18.1 | 0.18.2 | 0.18.3 )
+ 0.18 | 0.18.1 | 0.18.2 | 0.18.3 | \
+ 0.19 | 0.19.1 | 0.19.2 | 0.19.3 | 0.19.4 | 0.19.5 | 0.19.6 | 0.19.7 )
;;
*)
func_fatal_error "The AM_GNU_GETTEXT_VERSION declaration in your $configure_in
esac
# Check in which directory config.rpath, mkinstalldirs etc. belong.
-auxdir=`func_trace AC_CONFIG_AUX_DIR "$configure_in"`
+auxdir=`"$func_trace" AC_CONFIG_AUX_DIR "$configure_in"`
if test -n "$auxdir"; then
auxdir="$auxdir/"
fi
# Check in which directory the *.m4 macros belong.
-macrodirs=`func_trace AC_CONFIG_MACRO_DIR_TRACE "$configure_in"`
+macrodirs=`"$func_trace" AC_CONFIG_MACRO_DIR_TRACE "$configure_in"`
if test -z "$macrodirs"; then
- macrodirs=`func_trace AC_CONFIG_MACRO_DIR "$configure_in"`
+ macrodirs=`"$func_trace" AC_CONFIG_MACRO_DIR "$configure_in"`
fi
for arg in $macrodirs; do
m4dir="$arg"
# Check whether to omit the intl/ directory.
omitintl=
-xargs=`func_trace AM_GNU_GETTEXT "$configure_in"`
+# Need to use func_trace_sed instead of $func_trace, since
+# AM_GNU_GETTEXT is not a standard Autoconf trace.
+xargs=`func_trace_sed AM_GNU_GETTEXT "$configure_in"`
save_IFS="$IFS"; IFS=:
for arg in $xargs; do
if test 'external' = "$arg"; then
IFS="$save_IFS"
# Check in which directory or directories the po/* infrastructure belongs.
-configfiles=`func_trace AC_CONFIG_FILES "$configure_in"`
+configfiles=`"$func_trace" AC_CONFIG_FILES "$configure_in"`
# PO directories have a Makefile.in generated from Makefile.in.in.
# Treat a directory as a PO directory if and only if it has a
# POTFILES.in file. This allows packages to have multiple PO
# The archive of different versions is very large (unless xz compression is
# used), but using it does not require special tools.
case "@ARCHIVE_FORMAT@" in
- dirgz) gzip -d -c < "$gettext_dir/archive.dir.tar.gz" ;;
- dirbz2) bzip2 -d -c < "$gettext_dir/archive.dir.tar.bz2" ;;
- dirxz) xz -d -c < "$gettext_dir/archive.dir.tar.xz" ;;
+ dirgz) gzip -d -c < "$gettext_datadir/archive.dir.tar.gz" ;;
+ dirbz2) bzip2 -d -c < "$gettext_datadir/archive.dir.tar.bz2" ;;
+ dirxz) xz -d -c < "$gettext_datadir/archive.dir.tar.xz" ;;
esac \
| (cd "$work_dir" && tar xf - "gettext-$ver")
if test `find "$work_dir" -type f -print | wc -l` = 0; then
# Set up a temporary CVS repository.
# We need the temporary CVS repository because any checkout needs write
- # access to the CVSROOT/history file, so it cannot be under $gettext_dir.
+ # access to the CVSROOT/history file, so it cannot be under $gettext_datadir.
# We need the temporary checkout directory because when --force was not
# given, we need to compare the existing files with the checked out ones.
# Set variables
# Need to pass -d "$CVSROOT", because there may be a CVS directory in the
# current directory.
cvs -d "$CVSROOT" init
- gzip -d -c < "$gettext_dir/archive.cvs.tar.gz" | (cd "$cvs_dir" && tar xf -)
+ gzip -d -c < "$gettext_datadir/archive.cvs.tar.gz" | (cd "$cvs_dir" && tar xf -)
cd "$work_dir"
cvsver=gettext-`echo "$ver" | sed -e 's/\./_/g'`
# Check availability of the git program.
(git --version) >/dev/null 2>/dev/null || func_fatal_error "git program not found"
mkdir "$work_dir/archive"
- gzip -d -c < "$gettext_dir/archive.git.tar.gz" | (cd "$work_dir/archive" && tar xf -)
+ gzip -d -c < "$gettext_datadir/archive.git.tar.gz" | (cd "$work_dir/archive" && tar xf -)
(cd "$work_dir/archive" && git checkout -q "gettext-$ver") || {
rm -rf "$work_dir"
func_fatal_error "infrastructure files for version $ver not found; this is autopoint from GNU $package $version"