#! /bin/sh
#
-# Copyright (C) 2002-2011 Free Software Foundation, Inc.
+# Copyright (C) 2002-2012 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
--update update the current package, restore files omitted
from version control
--create-testdir create a scratch package with the given modules
+ (pass --with-tests to include the unit tests)
--create-megatestdir create a mega scratch package with the given modules
one by one and all together
+ (pass --with-tests to include the unit tests)
--test test the combination of the given modules
+ (pass --with-tests to include the unit tests)
(recommended to use CC=\"gcc -Wall\" here)
--megatest test the given modules one by one and all together
+ (pass --with-tests to include the unit tests)
(recommended to use CC=\"gcc -Wall\" here)
--extract-description extract the description
--extract-comment extract the comment
--extract-maintainer report the maintainer(s) inside gnulib
--extract-tests-module report the unit test module, if it exists
--copy-file copy a file that is not part of any module
+ --help Show this help text.
+ --version Show version and authorship information.
General options:
'gl_INIT'. Default is 'gl'.
--po-domain=NAME Specify the prefix of the i18n domain. Usually use
the package name. A suffix '-gnulib' is appended.
+ --witness-c-macro=NAME Specify the C macro that is defined when the
+ sources in this directory are compiled or used.
--vc-files Update version control related files.
--no-vc-files Don't update version control related files
(.gitignore and/or .cvsignore).
q
}' < "$self_abspathname"
echo "#"
- echo "# This file is free software, distributed under the terms of the GNU"
- echo "# General Public License. As a special exception to the GNU General"
- echo "# Public License, this file may be distributed as part of a program"
- echo "# that contains a configuration script generated by Autoconf, under"
+ echo "# This file is free software; you can redistribute it and/or modify"
+ echo "# it under the terms of the GNU General Public License as published by"
+ echo "# the Free Software Foundation; either version 3 of the License, or"
+ echo "# (at your option) any later version."
+ echo "#"
+ echo "# This file is distributed in the hope that it will be useful,"
+ echo "# but WITHOUT ANY WARRANTY; without even the implied warranty of"
+ echo "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
+ echo "# GNU General Public License for more details."
+ echo "#"
+ echo "# You should have received a copy of the GNU General Public License"
+ echo "# along with this file. If not, see <http://www.gnu.org/licenses/>."
+ echo "#"
+ echo "# As a special exception to the GNU General Public License,"
+ echo "# this file may be distributed as part of a program that"
+ echo "# contains a configuration script generated by Autoconf, under"
echo "# the same distribution terms as the rest of that program."
echo "#"
echo "# Generated by gnulib-tool."
# given, blank otherwise
# - macro_prefix from --macro-prefix
# - po_domain from --po-domain
+# - witness_c_macro from --witness-c-macro
# - vc_files true if --vc-files was given, false if --no-vc-files was
# given, blank otherwise
# - autoconf_minversion minimum supported autoconf version
libtool=
macro_prefix=
po_domain=
+ witness_c_macro=
vc_files=
do_changelog=:
doit=:
--po-domain=* )
po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
shift ;;
+ --witness-c-macro )
+ shift
+ if test $# = 0; then
+ func_fatal_error "missing argument for --witness-c-macro"
+ fi
+ witness_c_macro="$1"
+ shift ;;
+ --witness-c-macro=* )
+ witness_c_macro=`echo "X$1" | sed -e 's/^X--witness-c-macro=//'`
+ shift ;;
--vc-files )
vc_files=true
shift ;;
|| test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
|| test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
|| test -n "$macro_prefix" || test -n "$po_domain" \
- || test -n "$vc_files"; then
+ || test -n "$witness_c_macro" || test -n "$vc_files"; then
echo "gnulib-tool: invalid options for 'update' mode" 1>&2
echo "Try 'gnulib-tool --help' for more information." 1>&2
echo "If you really want to modify the gnulib configuration of your project," 1>&2
;;
esac
# Then the explicit dependencies listed in the module description.
- if ! $modcache; then
- func_lookup_file "modules/$1"
- sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
- else
- func_cache_lookup_module "$1"
- # Output the field's value, including the final newline (if any).
- if $have_associative; then
- if eval 'test -n "${modcache_dependson[$1]+set}"'; then
- eval 'echo "${modcache_dependson[$1]}"'
- fi
+ { if ! $modcache; then
+ func_lookup_file "modules/$1"
+ sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
else
- eval "field_set=\"\$${cachevar}_dependson_set\""
- if test -n "$field_set"; then
- eval "field_value=\"\$${cachevar}_dependson\""
- echo "${field_value}"
+ func_cache_lookup_module "$1"
+ # Output the field's value, including the final newline (if any).
+ if $have_associative; then
+ if eval 'test -n "${modcache_dependson[$1]+set}"'; then
+ eval 'echo "${modcache_dependson[$1]}"'
+ fi
+ else
+ eval "field_set=\"\$${cachevar}_dependson_set\""
+ if test -n "$field_set"; then
+ eval "field_value=\"\$${cachevar}_dependson\""
+ echo "${field_value}"
+ fi
fi
fi
- fi
+ } \
+ | sed -e '/^#/d'
}
# func_get_autoconf_early_snippet module
fi
}
-# func_get_license module
+# func_get_license_raw module
# Input:
# - local_gnulib_dir from --local-dir
# - modcache true or false, from --cache-modules/--no-cache-modules
-func_get_license ()
+func_get_license_raw ()
{
- {
- if ! $modcache; then
- func_lookup_file "modules/$1"
- sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
+ if ! $modcache; then
+ func_lookup_file "modules/$1"
+ sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
+ else
+ func_cache_lookup_module "$1"
+ # Output the field's value, including the final newline (if any).
+ if $have_associative; then
+ if eval 'test -n "${modcache_license[$1]+set}"'; then
+ eval 'echo "${modcache_license[$1]}"'
+ fi
else
- func_cache_lookup_module "$1"
- # Output the field's value, including the final newline (if any).
- if $have_associative; then
- if eval 'test -n "${modcache_license[$1]+set}"'; then
- eval 'echo "${modcache_license[$1]}"'
- fi
- else
- eval "field_set=\"\$${cachevar}_license_set\""
- if test -n "$field_set"; then
- eval "field_value=\"\$${cachevar}_license\""
- echo "${field_value}"
- fi
+ eval "field_set=\"\$${cachevar}_license_set\""
+ if test -n "$field_set"; then
+ eval "field_value=\"\$${cachevar}_license\""
+ echo "${field_value}"
fi
fi
+ fi
+}
+
+# func_get_license module
+# Input:
+# - local_gnulib_dir from --local-dir
+# - modcache true or false, from --cache-modules/--no-cache-modules
+func_get_license ()
+{
+ # Warn if the License field is missing.
+ case "$1" in
+ *-tests ) ;;
+ * )
+ license=`func_get_license_raw "$1"`
+ if test -z "$license"; then
+ func_warning "module $1 lacks a License"
+ fi
+ ;;
+ esac
+ {
+ func_get_license_raw "$1"
# The default is GPL.
echo "GPL"
} | sed -e 's,^ *$,,' | sed -e 1q
;;
esac
done
- if $inc; then
+ if $inc && func_acceptable "$dep"; then
func_append inmodules " $dep"
if test "$cond_dependencies" = true; then
escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
|| { test -n "$lsymbolic" \
&& test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
&& test -z "$lookedup_tmp" \
- && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
+ && cmp -s "$lookedup_file" "$tmpfile"; then
func_ln_if_changed "$lookedup_file" "$destdir/$g"
else
mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
# - already_present nonempty if the file should already exist, empty otherwise
func_update_file ()
{
- if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
+ if cmp -s "$destdir/$g" "$tmpfile"; then
: # The file has not changed.
else
# Replace the file.
|| { test -n "$lsymbolic" \
&& test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
&& test -z "$lookedup_tmp" \
- && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
+ && cmp -s "$lookedup_file" "$tmpfile"; then
func_ln_if_changed "$lookedup_file" "$destdir/$g"
else
mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
# - libtool true if libtool will be used, false or blank otherwise
# - macro_prefix prefix of gl_LIBOBJS macros to use
# - po_domain prefix of i18n domain to use (without -gnulib suffix)
+# - witness_c_macro from --witness-c-macro
# - actioncmd (optional) command that will reproduce this invocation
# - for_test true if creating a package for testing, false otherwise
# - sed_replace_include_guard_prefix
echo "noinst_HEADERS ="
echo "noinst_LIBRARIES ="
echo "noinst_LTLIBRARIES ="
- # Automake versions < 1.9b create an empty pkgdatadir at installation time
- # if you specify pkgdata_DATA to empty. This is a workaround.
+ # Automake versions < 1.11.4 create an empty pkgdatadir at
+ # installation time if you specify pkgdata_DATA to empty.
+ # See automake bugs #10997 and #11030:
+ # * http://debbugs.gnu.org/10997
+ # * http://debbugs.gnu.org/11030
+ # So we need this workaround.
if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
echo "pkgdata_DATA ="
fi
fi
fi
done
+ if test -n "$witness_c_macro"; then
+ cppflags_part1=" -D$witness_c_macro=1"
+ else
+ cppflags_part1=
+ fi
+ if $for_test; then
+ cppflags_part2=" -DGNULIB_STRICT_CHECKING=1"
+ else
+ cppflags_part2=
+ fi
if test -z "$makefile_name"; then
echo
- if $for_test; then
- echo "AM_CPPFLAGS = -DGNULIB_STRICT_CHECKING=1"
- else
- echo "AM_CPPFLAGS ="
- fi
+ echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
echo "AM_CFLAGS ="
+ else
+ if test -n "$cppflags_part1$cppflags_part2"; then
+ echo
+ echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
+ fi
fi
echo
if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
# - m4base relative directory containing autoconf macros
# - testsbase relative directory containing unit test code
# - macro_prefix prefix of gl_LIBOBJS macros to use
+# - witness_c_macro from --witness-c-macro
# - for_test true if creating a package for testing, false otherwise
# - single_configure true if a single configure file should be generated,
# false for a separate configure file for the tests
echo "check_LIBRARIES = libtests.a"
fi
fi
- # Automake versions < 1.9b create an empty pkgdatadir at installation time
- # if you specify pkgdata_DATA to empty. This is a workaround.
+ # Automake versions < 1.11.4 create an empty pkgdatadir at
+ # installation time if you specify pkgdata_DATA to empty.
+ # See automake bugs #10997 and #11030:
+ # * http://debbugs.gnu.org/10997
+ # * http://debbugs.gnu.org/11030
+ # So we need this workaround.
if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
echo "pkgdata_DATA ="
fi
if $for_test; then
echo " -DGNULIB_STRICT_CHECKING=1 \\"
fi
+ if test -n "$witness_c_macro"; then
+ echo " -D$witness_c_macro=1 \\"
+ fi
if test -n "${witness_macro}"; then
echo " -D@${witness_macro}@=1 \\"
fi
# - local_gnulib_dir from --local-dir
# - modcache true or false, from --cache-modules/--no-cache-modules
# - sed_replace_build_aux sed expression that replaces reference to build-aux
+# - sed_replace_include_guard_prefix
+# sed expression for resolving ${gl_include_guard_prefix}
# - module the module name
# - toplevel true or false. 'false' means a subordinate use of
# gnulib-tool.
func_get_autoconf_snippet "$module" \
| sed -e '/^$/d;' -e "s/^/$indentation/" \
-e "$sed_replace_build_aux" \
+ -e "$sed_replace_include_guard_prefix" \
| { if $disable_libtool; then
sed -e 's/\$gl_cond_libtool/false/g' \
-e 's/gl_libdeps/gltests_libdeps/g' \
# - local_gnulib_dir from --local-dir
# - modcache true or false, from --cache-modules/--no-cache-modules
# - sed_replace_build_aux sed expression that replaces reference to build-aux
+# - sed_replace_include_guard_prefix
+# sed expression for resolving ${gl_include_guard_prefix}
# - modules the list of modules.
# - verifier one of func_verify_module, func_verify_nontests_module,
# func_verify_tests_module. It selects the subset of
disable_libtool="$4"
disable_gettext="$5"
if test "$cond_dependencies" = true; then
+ for m in $modules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/modules
# Emit the autoconf code for the unconditional modules.
for module in $1; do
eval $verifier
func_emit_autoconf_snippet " "
echo " $shellvar=true"
deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
+ # Intersect $deps with the modules list $1.
+ deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
for dep in $deps; do
if func_cond_module_p "$dep"; then
func_module_shellfunc_name "$dep"
func_cond_module_condition "$module" "$dep"
if test "$condition" != true; then
- echo ' if $condition; then'
+ echo " if $condition; then"
echo " $shellfunc"
echo ' fi'
else
:
else
deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
+ # Intersect $deps with the modules list $1.
+ deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
for dep in $deps; do
if func_cond_module_p "$dep"; then
func_module_shellfunc_name "$dep"
# - guessed_libtool true if the configure.ac file uses libtool, false otherwise
# - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
# - po_domain prefix of i18n domain to use (without -gnulib suffix)
+# - witness_c_macro from --witness-c-macro
# - vc_files true if --vc-files was given, false if --no-vc-files was
# given, blank otherwise
# - autoconf_minversion minimum supported autoconf version
cached_libtool=
cached_macro_prefix=
cached_po_domain=
+ cached_witness_c_macro=
cached_vc_files=
cached_files=
if test -f "$destdir"/$m4base/gnulib-cache.m4; then
/gl_PO_DOMAIN(/ {
s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
}
+ /gl_WITNESS_C_MACRO(/ {
+ s,^.*gl_WITNESS_C_MACRO([[ ]*\([^]"$`\\)]*\).*$,cached_witness_c_macro="\1",p
+ }
/gl_VC_FILES(/ {
s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
}'
if test -z "$po_domain"; then
po_domain="$cached_po_domain"
fi
+ # The witness_c_macro defaults to the cached one.
+ if test -z "$witness_c_macro"; then
+ witness_c_macro="$cached_witness_c_macro"
+ fi
# The vc_files defaults to the cached one.
if test -z "$vc_files"; then
vc_files="$cached_vc_files"
if test -n "$po_domain"; then
func_append actioncmd " --po-domain=$po_domain"
fi
+ if test -n "$witness_c_macro"; then
+ func_append actioncmd " --witness-c-macro=$witness_c_macro"
+ fi
if test -n "$vc_files"; then
if test "$vc_files" = true; then
func_append actioncmd " --vc-files"
modules="$main_modules"
func_emit_lib_Makefile_am > "$tmpfile"
if test -f "$destdir"/$sourcebase/$makefile_am; then
- if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
+ if cmp -s "$destdir"/$sourcebase/$makefile_am "$tmpfile"; then
rm -f "$tmpfile"
else
if $doit; then
func_lookup_file build-aux/po/$file
cat "$lookedup_file" > "$tmpfile"
if test -f "$destdir"/$pobase/$file; then
- if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
+ if cmp -s "$destdir"/$pobase/$file "$tmpfile"; then
rm -f "$tmpfile"
else
if $doit; then
func_dest_tmpfilename $pobase/Makevars
func_emit_po_Makevars > "$tmpfile"
if test -f "$destdir"/$pobase/Makevars; then
- if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
+ if cmp -s "$destdir"/$pobase/Makevars "$tmpfile"; then
rm -f "$tmpfile"
else
if $doit; then
func_dest_tmpfilename $pobase/POTFILES.in
func_emit_po_POTFILES_in > "$tmpfile"
if test -f "$destdir"/$pobase/POTFILES.in; then
- if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
+ if cmp -s "$destdir"/$pobase/POTFILES.in "$tmpfile"; then
rm -f "$tmpfile"
else
if $doit; then
}
) > "$tmpfile"
if test -f "$destdir"/$pobase/LINGUAS; then
- if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
+ if cmp -s "$destdir"/$pobase/LINGUAS "$tmpfile"; then
rm -f "$tmpfile"
else
echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
fi
echo "gl_MACRO_PREFIX([$macro_prefix])"
echo "gl_PO_DOMAIN([$po_domain])"
+ echo "gl_WITNESS_C_DOMAIN([$witness_c_macro])"
if test -n "$vc_files"; then
echo "gl_VC_FILES([$vc_files])"
fi
) > "$tmpfile"
if test -f "$destdir"/$m4base/gnulib-cache.m4; then
- if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
+ if cmp -s "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile"; then
rm -f "$tmpfile"
else
if $doit; then
echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
- echo " AC_REQUIRE([AC_PROG_RANLIB])"
+ echo " AC_REQUIRE([gl_PROG_AR_RANLIB])"
if test -n "$uses_subdirs"; then
echo " AC_REQUIRE([AM_PROG_CC_C_O])"
fi
echo " gl_m4_base='$m4base'"
func_emit_initmacro_start $macro_prefix
echo " gl_source_base='$sourcebase'"
+ if test -n "$witness_c_macro"; then
+ echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
+ fi
func_emit_autoconf_snippets "$main_modules" func_verify_module true false true
+ if test -n "$witness_c_macro"; then
+ echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
+ fi
echo " # End of code from modules"
func_emit_initmacro_end $macro_prefix
echo " gltests_libdeps="
echo "])"
) > "$tmpfile"
if test -f "$destdir"/$m4base/gnulib-comp.m4; then
- if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
+ if cmp -s "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile"; then
rm -f "$tmpfile"
else
if $doit; then
modules="$testsrelated_modules"
func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
if test -f "$destdir"/$testsbase/$makefile_am; then
- if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
+ if cmp -s "$destdir"/$testsbase/$makefile_am "$tmpfile"; then
rm -f "$tmpfile"
else
if $doit; then
echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
fi
done
- echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
+ if grep '^ *AC_PROG_CC_STDC' "$configure_ac" > /dev/null; then
+ position_early_after=AC_PROG_CC_STDC
+ else
+ if grep '^ *AC_PROG_CC_C99' "$configure_ac" > /dev/null; then
+ position_early_after=AC_PROG_CC_C99
+ else
+ position_early_after=AC_PROG_CC
+ fi
+ fi
+ echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after $position_early_after,"
echo " - invoke ${macro_prefix}_INIT in $configure_ac."
}
# its dependencies.
saved_inctests="$inctests"
# When computing transitive closures, don't consider $module to depend on
- # $module-tests. Need this becauses tests are implicitly GPL and may depend
+ # $module-tests. Need this because tests are implicitly GPL and may depend
# on GPL modules - therefore we don't want a warning in this case.
inctests=""
for requested_module in $specified_modules; do
testsbase=gltests
macro_prefix=gl
po_domain=
+ witness_c_macro=
vc_files=
# Determine final module list.
echo "AC_PROG_CC"
echo "AC_PROG_INSTALL"
echo "AC_PROG_MAKE_SET"
- echo "AC_PROG_RANLIB"
+ echo "gl_PROG_AR_RANLIB"
echo
if test -n "$uses_subdirs"; then
echo "AM_PROG_CC_C_O"
echo "AC_OUTPUT"
) > "$testdir/$testsbase/configure.ac"
auxdir="$saved_auxdir"
- func_append subdirs " $testsbase"
subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
fi
- subdirs="$subdirs $testsbase"
+ func_append subdirs " $testsbase"
fi
# Create Makefile.am.
echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
echo
- echo "AC_PROG_RANLIB"
+ echo "gl_PROG_AR_RANLIB"
echo
if test -n "$any_uses_subdirs"; then
echo "AM_PROG_CC_C_O"
# inc_longrunning_tests, inc_privileged_tests,
# inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
# m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
- # makefile_name, libtool, macro_prefix, po_domain, vc_files
+ # makefile_name, libtool, macro_prefix, po_domain,
+ # witness_c_macro, vc_files
# don't propagate from one directory to another.
(func_import) || func_exit 1
done
;;
extract-dependencies )
+ if test -n "$avoidlist"; then
+ func_fatal_error "cannot combine --avoid and --extract-dependencies"
+ fi
for module
do
func_verify_module