+ files=`for f in $files; do echo $f; done | LC_ALL=C sort | LC_ALL=C uniq`
+}
+
+# func_emit_lib_Makefile_am
+# emits the contents of lib/Makefile.am to standard output.
+# Input:
+# - modules list of modules, including dependencies
+# - libname library name
+# - libtool true if libtool will be used, blank otherwise
+# - actioncmd (optional) command that will reproduce this invocation
+func_emit_lib_Makefile_am ()
+{
+ if test -n "$libtool"; then
+ libext=la
+ perhapsLT=LT
+ else
+ libext=a
+ perhapsLT=
+ fi
+ echo "## Process this file with automake to produce Makefile.in."
+ func_emit_copyright_notice
+ if test -n "$actioncmd"; then
+ echo "# Reproduce by: $actioncmd"
+ fi
+ echo
+ # No need to generate dependencies since the sources are in gnulib, not here.
+ echo "AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies"
+ echo
+ echo "noinst_${perhapsLT}LIBRARIES = $libname.$libext"
+ echo
+ echo "${libname}_${libext}_SOURCES ="
+ echo "${libname}_${libext}_LIBADD = @${perhapsLT}LIBOBJS@"
+ echo "noinst_HEADERS ="
+ echo "EXTRA_DIST ="
+ echo "BUILT_SOURCES ="
+ echo "SUFFIXES ="
+ echo "MOSTLYCLEANFILES ="
+ echo "MOSTLYCLEANDIRS ="
+ echo "CLEANFILES ="
+ echo "DISTCLEANFILES ="
+ echo "MAINTAINERCLEANFILES ="
+ echo
+ echo "AM_CPPFLAGS ="
+ echo
+ for module in $modules; do
+ func_verify_nontests_module
+ if test -n "$module"; then
+ {
+ func_get_automake_snippet "$module" |
+ sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
+ if test "$module" = 'alloca'; then
+ echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
+ fi
+ } > amsnippet.tmp
+ # Skip the contents if its entirely empty.
+ if grep '[^ ]' amsnippet.tmp > /dev/null ; then
+ echo "## begin gnulib module $module"
+ echo
+ cat amsnippet.tmp
+ echo "## end gnulib module $module"
+ echo
+ fi
+ rm -f amsnippet.tmp
+ fi
+ done
+ echo
+ echo "mostlyclean-local:"
+ echo " @test -z \"\$(MOSTLYCLEANDIRS)\" || \\"
+ echo " for dir in \$(MOSTLYCLEANDIRS); do \\"
+ echo " if test -d \$\$dir; then \\"
+ echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
+ echo " fi; \\"
+ echo " done"
+ echo
+ echo "# Makefile.am ends here"
+}
+
+# func_emit_tests_Makefile_am
+# emits the contents of tests/Makefile.am to standard output.
+# Input:
+# - modules list of modules, including dependencies
+# - libname library name
+# - libtool true if libtool will be used, blank otherwise
+# - sourcebase relative directory containing lib source code
+# - m4base relative directory containing autoconf macros
+# - testsbase relative directory containing unit test code
+func_emit_tests_Makefile_am ()
+{
+ if test -n "$libtool"; then
+ libext=la
+ else
+ libext=a
+ fi
+ testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
+ echo "## Process this file with automake to produce Makefile.in."
+ func_emit_copyright_notice
+ echo
+ # Generate dependencies here, since it eases the debugging of test failures.
+ echo "AUTOMAKE_OPTIONS = 1.5 foreign"
+ echo
+ echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
+ echo
+ # Nothing is being added to SUBDIRS; nevertheless the existence of this
+ # variable is needed to avoid an error from automake:
+ # "AM_GNU_GETTEXT used but SUBDIRS not defined"
+ echo "SUBDIRS ="
+ echo "TESTS ="
+ echo "TESTS_ENVIRONMENT ="
+ echo "noinst_PROGRAMS ="
+ echo "check_PROGRAMS ="
+ echo "noinst_HEADERS ="
+ echo "EXTRA_DIST ="
+ echo "BUILT_SOURCES ="
+ echo "SUFFIXES ="
+ echo "MOSTLYCLEANFILES ="
+ echo "MOSTLYCLEANDIRS ="
+ echo "CLEANFILES ="
+ echo "DISTCLEANFILES ="
+ echo "MAINTAINERCLEANFILES ="
+ echo
+ echo "AM_CPPFLAGS = \\"
+ echo " -I. -I\$(srcdir) \\"
+ echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
+ echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
+ echo
+ echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
+ echo
+ for module in $modules; do
+ func_verify_tests_module
+ if test -n "$module"; then
+ func_get_automake_snippet "$module" > amsnippet.tmp
+ # Skip the contents if its entirely empty.
+ if grep '[^ ]' amsnippet.tmp > /dev/null ; then
+ echo "## begin gnulib module $module"
+ echo
+ cat amsnippet.tmp
+ echo "## end gnulib module $module"
+ echo
+ fi
+ rm -f amsnippet.tmp
+ fi
+ done
+ echo "# Clean up after Solaris cc."
+ echo "clean-local:"
+ echo " rm -rf SunWS_cache"
+ echo
+ echo "mostlyclean-local:"
+ echo " @test -z \"\$(MOSTLYCLEANDIRS)\" || \\"
+ echo " for dir in \$(MOSTLYCLEANDIRS); do \\"
+ echo " if test -d \$\$dir; then \\"
+ echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
+ echo " fi; \\"
+ echo " done"
+ echo
+ echo "# Makefile.am ends here"
+}
+
+# func_import modules
+# Uses also the variables
+# - destdir target directory
+# - libname library name
+# - sourcebase directory relative to destdir where to place source code
+# - m4base directory relative to destdir where to place *.m4 macros
+# - docbase directory relative to destdir where to place doc files
+# - testsbase directory relative to destdir where to place unit test code
+# - auxdir directory relative to destdir where to place build aux files
+# - inctests true if --with-tests was given, blank otherwise
+# - avoidlist list of modules to avoid, from --avoid
+# - lgpl true if library's license shall be LGPL, blank otherwise
+# - libtool true if libtool will be used, blank otherwise
+# - guessed_libtool true if the configure.ac file uses libtool, blank otherwise
+# - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
+# - autoconf_minversion minimum supported autoconf version
+# - doit : if actions shall be executed, false if only to be printed
+# - symbolic true if files should be symlinked, copied otherwise
+func_import ()
+{
+ # Get the cached settings.
+ cached_specified_modules=
+ cached_avoidlist=
+ cached_sourcebase=
+ cached_m4base=
+ cached_docbase=
+ cached_testsbase=
+ cached_libname=
+ cached_lgpl=
+ cached_libtool=
+ cached_macro_prefix=
+ cached_autoconf_minversion=
+ cached_files=
+ if test -f "$destdir"/$m4base/gnulib-cache.m4; then
+ my_sed_traces='
+ s,#.*$,,
+ s,^dnl .*$,,
+ s, dnl .*$,,
+ /gl_MODULES(/ {
+ s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
+ }
+ /gl_AVOID(/ {
+ s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
+ }
+ /gl_SOURCE_BASE(/ {
+ s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
+ }
+ /gl_M4_BASE(/ {
+ s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
+ }
+ /gl_DOC_BASE(/ {
+ s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
+ }
+ /gl_TESTS_BASE(/ {
+ s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
+ }
+ /gl_LIB(/ {
+ s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
+ }
+ /gl_LGPL/ {
+ s,^.*$,cached_lgpl=true,p
+ }
+ /gl_LIBTOOL/ {
+ s,^.*$,cached_libtool=true,p
+ }
+ /gl_MACRO_PREFIX(/ {
+ s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
+ }
+ /gl_AUTOCONF_MINVERSION(/ {
+ s,^.*gl_AUTOCONF_MINVERSION([[ ]*\([^])]*\).*$,cached_autoconf_minversion="\1",p
+ }'
+ eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
+ if test -f "$destdir"/$m4base/gnulib-comp.m4; then
+ my_sed_traces='
+ s,#.*$,,
+ s,^dnl .*$,,
+ s, dnl .*$,,
+ /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
+ s,^.*$,cached_files=",p
+ n
+ ta
+ :a
+ s,^\]).*$,",
+ tb
+ p
+ n
+ ba
+ :b
+ p
+ }'
+ eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
+ fi
+ fi
+
+ # Merge the cached settings with the specified ones.
+ # The m4base must be the same as expected from the pathname.
+ if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
+ func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
+ fi
+ # Append the cached and the specified module names. So that
+ # "gnulib-tool --import foo" means to add the module foo.
+ specified_modules="$cached_specified_modules $1"
+ # Append the cached and the specified avoidlist. This is probably better
+ # than dropping the cached one when --avoid is specified at least once.
+ avoidlist=`echo $cached_avoidlist $avoidlist`
+ # The sourcebase defaults to the cached one.
+ if test -z "$sourcebase"; then
+ sourcebase="$cached_sourcebase"
+ if test -z "$sourcebase"; then
+ func_fatal_error "missing --source-base option"
+ fi
+ fi
+ # The docbase defaults to the cached one.
+ if test -z "$docbase"; then
+ docbase="$cached_docbase"
+ if test -z "$docbase"; then
+ func_fatal_error "missing --doc-base option"
+ fi
+ fi
+ # The testsbase defaults to the cached one.
+ if test -z "$testsbase"; then
+ testsbase="$cached_testsbase"
+ if test -z "$testsbase"; then
+ func_fatal_error "missing --tests-base option"
+ fi
+ fi
+ # The libname defaults to the cached one.
+ if test -z "$supplied_libname"; then
+ libname="$cached_libname"
+ if test -z "$libname"; then
+ func_fatal_error "missing --lib option"
+ fi
+ fi
+ # Require LGPL if specified either way.
+ if test -z "$lgpl"; then
+ lgpl="$cached_lgpl"
+ fi
+ # Use libtool if specified either way, or if guessed.
+ if test -z "$libtool"; then
+ if test -n "$cached_m4base"; then
+ libtool="$cached_libtool"
+ else
+ libtool="$guessed_libtool"
+ fi
+ fi
+ # The macro_prefix defaults to the cached one.
+ if test -z "$macro_prefix"; then
+ macro_prefix="$cached_macro_prefix"
+ if test -z "$macro_prefix"; then
+ func_fatal_error "missing --macro-prefix option"
+ fi
+ fi
+ # The autoconf_minversion defaults to the cached one.
+ if test -z "$autoconf_minversion"; then
+ autoconf_minversion="$cached_autoconf_minversion"
+ if test -z "$autoconf_minversion"; then
+ autoconf_minversion="$DEFAULT_AUTOCONF_MINVERSION"
+ fi
+ fi
+
+ # Canonicalize the list of specified modules.
+ specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
+
+ # Determine final module list.
+ modules="$specified_modules"
+ func_modules_transitive_closure
+ echo "Module list with included dependencies:"
+ echo "$modules" | sed -e 's/^/ /'
+
+ # Add the dummy module if needed.
+ func_modules_add_dummy
+
+ # If --lgpl, check the license of modules are compatible.
+ if test -n "$lgpl"; then
+ for module in $modules; do
+ license=`func_get_license $module`
+ case $license in
+ LGPL | 'GPLed build tool' | 'public domain' | 'unlimited') ;;
+ *) func_fatal_error "incompatible license on module $module: $license" ;;
+ esac
+ done
+ fi
+
+ # Determine final file list.
+ func_modules_to_filelist
+ echo "File list:"
+ echo "$files" | sed -e 's/^/ /'
+
+ test -n "$files" \
+ || func_fatal_error "refusing to do nothing"
+
+ # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
+ new_files="$files m4/gnulib-tool.m4"
+ old_files="$cached_files"
+ if test -f "$destdir"/$m4base/gnulib-tool.m4; then
+ old_files="$old_files m4/gnulib-tool.m4"
+ fi
+
+ # Create directories.
+ if test ! -d "$destdir/$sourcebase"; then
+ if $doit; then
+ echo "Creating directory $destdir/$sourcebase"
+ mkdir "$destdir/$sourcebase" || func_fatal_error "failed"
+ else
+ echo "Create directory $destdir/$sourcebase"
+ fi
+ fi
+ if test ! -d "$destdir/$m4base"; then
+ if $doit; then
+ echo "Creating directory $destdir/$m4base"
+ mkdir "$destdir/$m4base" || func_fatal_error "failed"
+ else
+ echo "Create directory $destdir/$m4base"
+ fi
+ fi
+ if test ! -d "$destdir/$docbase"; then
+ if $doit; then
+ echo "Creating directory $destdir/$docbase"
+ mkdir "$destdir/$docbase" || func_fatal_error "failed"
+ else
+ echo "Create directory $destdir/$docbase"
+ fi
+ fi
+ if test -n "$inctests"; then
+ if test ! -d "$destdir/$testsbase"; then
+ if $doit; then
+ echo "Creating directory $destdir/$testsbase"
+ mkdir "$destdir/$testsbase" || func_fatal_error "failed"
+ else
+ echo "Create directory $destdir/$testsbase"
+ fi
+ fi
+ fi
+ if test ! -d "$destdir/$auxdir"; then
+ if $doit; then
+ echo "Creating directory $destdir/$auxdir"
+ mkdir "$destdir/$auxdir" || func_fatal_error "failed"
+ else
+ echo "Create directory $destdir/$auxdir"
+ fi
+ fi
+
+ func_tmpdir
+ trap 'rm -rf "$tmp"' 0 1 2 3 15
+ # func_dest_tmpfilename file
+ # determines the name of a temporary file (file is relative to destdir).
+ # Sets variable:
+ # - tmpfile absolute filename of the temporary file
+ func_dest_tmpfilename ()
+ {
+ if $doit; then
+ # Put the new contents of $file in a file in the same directory (needed
+ # to guarantee that an 'mv' to "$destdir/$file" works).
+ tmpfile="$destdir/$1.tmp"
+ else
+ # Put the new contents of $file in a file in a temporary directory
+ # (because the directory of "$file" might not exist).
+ tmpfile="$tmp"/`basename "$1"`.tmp
+ fi
+ }
+
+ # Copy files or make symbolic links. Remove obsolete files.
+ delimiter=' '
+ for f in $old_files; do
+ case "$f" in
+ build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
+ doc/*) g=`echo "$f" | sed -e "s,^doc/,$cached_docbase/,"` ;;
+ lib/*) g=`echo "$f" | sed -e "s,^lib/,$cached_sourcebase/,"` ;;
+ m4/*) g=`echo "$f" | sed -e "s,^m4/,$cached_m4base/,"` ;;
+ tests/*) g=`echo "$f" | sed -e "s,^tests/,$cached_testsbase/,"` ;;
+ *) g="$f" ;;
+ esac
+ echo "$g""$delimiter""$f"
+ done | LC_ALL=C sort > "$tmp"/old-files
+ for f in $new_files; do
+ case "$f" in
+ build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
+ doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
+ lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
+ m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
+ tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
+ *) g="$f" ;;
+ esac
+ echo "$g""$delimiter""$f"
+ done | LC_ALL=C sort > "$tmp"/new-files
+ # First the files that are in old-files, but not in new-files:
+ sed_take_first_column='s,'"$delimiter"'.*,,'
+ for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
+ # Remove the file. Do nothing if the user already removed it.
+ if test -f "$destdir/$g"; then
+ if $doit; then
+ echo "Removing file $g (backup in ${g}~)"
+ mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
+ else
+ echo "Remove file $g (backup in ${g}~)"
+ fi
+ fi
+ done
+ # func_add_or_update handles a file that ought to be present afterwards.
+ # Uses parameters f, g, already_present.
+ func_add_or_update ()
+ {
+ func_dest_tmpfilename "$g"
+ cp "$gnulib_dir/$f" "$tmpfile" || func_fatal_error "failed"
+ if test -n "$lgpl"; then
+ # Update license.
+ case "$f" in
+ lib/*)
+ sed -e 's/GNU General/GNU Lesser General/g' \
+ -e 's/version 2\([ ,]\)/version 2.1\1/g' \
+ < "$gnulib_dir/$f" > "$tmpfile" || func_fatal_error "failed"
+ ;;
+ esac
+ fi
+ if test -f "$destdir/$g"; then
+ # The file already exists.
+ if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
+ : # The file has not changed.
+ else
+ # Replace the file.
+ if $doit; then
+ if test -n "$already_present"; then
+ echo "Updating file $g (backup in ${g}~)"
+ else
+ echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
+ fi
+ mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
+ if test -n "$symbolic" && cmp "$gnulib_dir/$f" "$tmpfile" > /dev/null; then
+ func_ln_if_changed "$gnulib_dir/$f" "$destdir/$g"
+ else
+ mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
+ fi
+ else
+ if test -n "$already_present"; then
+ echo "Update file $g (backup in ${g}~)"
+ else
+ echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
+ fi
+ fi
+ fi
+ else
+ # Install the file.
+ # Don't protest if the file should be there but isn't: it happens
+ # frequently that developers don't put autogenerated files into CVS.
+ if $doit; then
+ echo "Copying file $g"
+ if test -n "$symbolic" && cmp "$gnulib_dir/$f" "$tmpfile" > /dev/null; then
+ func_ln_if_changed "$gnulib_dir/$f" "$destdir/$g"
+ else
+ mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
+ fi
+ else
+ echo "Copy file $g"
+ fi
+ fi
+ rm -f "$tmpfile"
+ }
+ # Then the files that are in new-files, but not in old-files:
+ sed_take_last_column='s,^.*'"$delimiter"',,'
+ already_present=
+ for f in `LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_last_column"`; do
+ case "$f" in
+ build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
+ doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
+ lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
+ m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
+ tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
+ *) g="$f" ;;
+ esac
+ func_add_or_update
+ done
+ # Then the files that are in new-files and in old-files:
+ already_present=true
+ for f in `LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_last_column"`; do
+ case "$f" in
+ build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
+ doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
+ lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
+ m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
+ tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
+ *) g="$f" ;;
+ esac
+ func_add_or_update
+ done
+
+ # Command-line invocation printed in a comment in generated gnulib-cache.m4.
+ actioncmd="gnulib-tool --import"
+ actioncmd="$actioncmd --dir=$destdir"
+ actioncmd="$actioncmd --lib=$libname"
+ actioncmd="$actioncmd --source-base=$sourcebase"
+ actioncmd="$actioncmd --m4-base=$m4base"
+ actioncmd="$actioncmd --doc-base=$docbase"
+ actioncmd="$actioncmd --aux-dir=$auxdir"
+ for module in $avoidlist; do
+ actioncmd="$actioncmd --avoid=$module"
+ done
+ if test -n "$lgpl"; then
+ actioncmd="$actioncmd --lgpl"
+ fi
+ if test -n "$libtool"; then
+ actioncmd="$actioncmd --libtool"
+ fi
+ actioncmd="$actioncmd --macro-prefix=$macro_prefix"
+ actioncmd="$actioncmd --assume-autoconf=$autoconf_minversion"
+ actioncmd="$actioncmd `echo $specified_modules`"
+
+ # Create lib/Makefile.am.
+ func_dest_tmpfilename $sourcebase/Makefile.am
+ func_emit_lib_Makefile_am > "$tmpfile"
+ if test -f "$destdir"/$sourcebase/Makefile.am; then
+ if cmp "$destdir"/$sourcebase/Makefile.am "$tmpfile" > /dev/null; then
+ rm -f "$tmpfile"
+ else
+ if $doit; then
+ echo "Updating $sourcebase/Makefile.am (backup in $sourcebase/Makefile.am~)"
+ mv -f "$destdir"/$sourcebase/Makefile.am "$destdir"/$sourcebase/Makefile.am~
+ mv -f "$tmpfile" "$destdir"/$sourcebase/Makefile.am
+ else
+ echo "Update $sourcebase/Makefile.am (backup in $sourcebase/Makefile.am~)"
+ rm -f "$tmpfile"
+ fi
+ fi
+ else
+ if $doit; then
+ echo "Creating $sourcebase/Makefile.am"
+ mv -f "$tmpfile" "$destdir"/$sourcebase/Makefile.am
+ else
+ echo "Create $sourcebase/Makefile.am"
+ rm -f "$tmpfile"
+ fi
+ fi
+
+ # Create m4/gnulib-cache.m4.
+ func_dest_tmpfilename $m4base/gnulib-cache.m4
+ (
+ func_emit_copyright_notice
+ echo "#"
+ echo "# This file represents the specification of how gnulib-tool is used."
+ echo "# It acts as a cache: It is written and read by gnulib-tool."
+ echo "# In projects using CVS, this file is meant to be stored in CVS,"
+ echo "# like the configure.ac and various Makefile.am files."
+ echo
+ echo
+ echo "# Specification in the form of a command-line invocation:"
+ echo "# $actioncmd"
+ echo
+ echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
+ echo "gl_MODULES(["`echo $specified_modules`"])"
+ echo "gl_AVOID([$avoidlist])"
+ echo "gl_SOURCE_BASE([$sourcebase])"
+ echo "gl_M4_BASE([$m4base])"
+ echo "gl_DOC_BASE([$docbase])"
+ echo "gl_TESTS_BASE([$testsbase])"
+ echo "gl_LIB([$libname])"
+ test -z "$lgpl" || echo "gl_LGPL"
+ test -z "$libtool" || echo "gl_LIBTOOL"
+ echo "gl_MACRO_PREFIX([$macro_prefix])"
+ echo "gl_AUTOCONF_MINVERSION([$autoconf_minversion])"
+ ) > "$tmpfile"
+ if test -f "$destdir"/$m4base/gnulib-cache.m4; then
+ if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
+ rm -f "$tmpfile"
+ else
+ if $doit; then
+ echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
+ mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
+ mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
+ else
+ echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
+ if false; then
+ cat "$tmpfile"
+ echo
+ echo "# gnulib-cache.m4 ends here"
+ fi
+ rm -f "$tmpfile"
+ fi
+ fi
+ else
+ if $doit; then
+ echo "Creating $m4base/gnulib-cache.m4"
+ mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
+ else
+ echo "Create $m4base/gnulib-cache.m4"
+ cat "$tmpfile"
+ rm -f "$tmpfile"
+ fi
+ fi
+
+ # Create m4/gnulib-comp.m4.
+ func_dest_tmpfilename $m4base/gnulib-comp.m4
+ (
+ func_emit_copyright_notice
+ echo "#"
+ echo "# This file represents the compiled summary of the specification in"
+ echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
+ echo "# to be invoked from configure.ac."
+ echo "# In projects using CVS, this file can be treated like other built files."
+ echo
+ echo
+ echo "# This macro should be invoked from $configure_ac, in the section"
+ echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
+ echo "# any checks for libraries, header files, types and library functions."
+ echo "AC_DEFUN([${macro_prefix}_EARLY],"
+ echo "["
+ echo " AC_REQUIRE([AC_PROG_RANLIB])"
+ if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
+ echo " AC_REQUIRE([AC_GNU_SOURCE])"
+ fi
+ if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
+ echo " AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])"
+ fi
+ if grep gl_LOCK "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
+ echo " AC_REQUIRE([gl_LOCK])"
+ fi
+ echo "])"
+ echo
+ echo "# This macro should be invoked from $configure_ac, in the section"
+ echo "# \"Check for header files, types and library functions\"."
+ echo "AC_DEFUN([${macro_prefix}_INIT],"
+ echo "["
+ if test -z "$libtool"; then
+ echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
+ else
+ echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
+ fi
+ if test "$auxdir" != "build-aux"; then
+ sed_replace_build_aux='
+ :a
+ /AC_CONFIG_FILES(.*:build-aux\/.*)/{
+ s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
+ ba
+ }'
+ sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
+ else
+ sed_replace_build_aux=
+ fi
+ for module in $modules; do
+ func_verify_module
+ if test -n "$module"; then
+ func_get_autoconf_snippet "$module" \
+ | sed -e '/^$/d;' -e 's/^/ /' \
+ -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
+ -e "$sed_replace_build_aux"
+ if test "$module" = 'alloca' && test -n "$libtool"; then
+ echo 'changequote(,)dnl'
+ echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
+ echo 'changequote([, ])dnl'
+ echo 'AC_SUBST([LTALLOCA])'
+ fi
+ fi
+ done
+ echo "])"
+ echo
+ echo "# This macro records the list of files which have been installed by"
+ echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
+ echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
+ echo "$files" | sed -e 's,^, ,'
+ echo "])"
+ ) > "$tmpfile"
+ if test -f "$destdir"/$m4base/gnulib-comp.m4; then
+ if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
+ rm -f "$tmpfile"
+ else
+ if $doit; then
+ echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
+ mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
+ mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
+ else
+ echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
+ if false; then
+ cat "$tmpfile"
+ echo
+ echo "# gnulib-comp.m4 ends here"
+ fi
+ rm -f "$tmpfile"
+ fi
+ fi
+ else
+ if $doit; then
+ echo "Creating $m4base/gnulib-comp.m4"
+ mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
+ else
+ echo "Create $m4base/gnulib-comp.m4"
+ cat "$tmpfile"
+ rm -f "$tmpfile"
+ fi
+ fi
+
+ if test -n "$inctests"; then
+ # Create tests/Makefile.am.
+ func_dest_tmpfilename $testsbase/Makefile.am
+ func_emit_tests_Makefile_am > "$tmpfile"
+ if test -f "$destdir"/$testsbase/Makefile.am; then
+ if cmp "$destdir"/$testsbase/Makefile.am "$tmpfile" > /dev/null; then
+ rm -f "$tmpfile"
+ else
+ if $doit; then
+ echo "Updating $testsbase/Makefile.am (backup in $testsbase/Makefile.am~)"
+ mv -f "$destdir"/$testsbase/Makefile.am "$destdir"/$testsbase/Makefile.am~
+ mv -f "$tmpfile" "$destdir"/$testsbase/Makefile.am
+ else
+ echo "Update $testsbase/Makefile.am (backup in $testsbase/Makefile.am~)"
+ rm -f "$tmpfile"
+ fi
+ fi
+ else
+ if $doit; then
+ echo "Creating $testsbase/Makefile.am"
+ mv -f "$tmpfile" "$destdir"/$testsbase/Makefile.am
+ else
+ echo "Create $testsbase/Makefile.am"
+ rm -f "$tmpfile"
+ fi
+ fi
+ fi
+
+ rm -rf "$tmp"
+ # Undo the effect of the previous 'trap' command. Some shellology:
+ # We cannot use "trap - 0 1 2 3 15", because Solaris sh would attempt to
+ # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
+ # exit); for the others we need to call 'exit' explicitly. The value of $? is
+ # 128 + signal number and is set before the trap-registered command is run.
+ trap '' 0
+ trap 'exit $?' 1 2 3 15
+
+ echo "Finished."
+ echo
+ echo "You may need to add #include directives for the following .h files."
+ (
+ # First the #include <...> directives without #ifs, sorted for convenience.
+ for module in $modules; do
+ if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
+ :
+ else
+ func_get_include_directive "$module" | grep -v 'include "'
+ fi
+ done | LC_ALL=C sort -u
+ # Then the #include "..." directives without #ifs, sorted for convenience.
+ for module in $modules; do
+ if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
+ :
+ else
+ func_get_include_directive "$module" | grep 'include "'
+ fi
+ done | LC_ALL=C sort -u
+ # Then the #include directives that are surrounded by #ifs. Not sorted.
+ for module in $modules; do
+ if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
+ func_get_include_directive "$module"
+ fi
+ done
+ ) | sed -e '/^$/d;' -e 's/^/ /'
+ echo
+ echo "Don't forget to"
+ echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
+ if test -n "$inctests"; then
+ echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
+ fi
+ sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
+ sourcebase_base=`basename "$sourcebase"`
+ echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
+ if test -n "$inctests"; then
+ testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
+ testsbase_base=`basename "$testsbase"`
+ echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
+ fi
+ echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
+ echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
+ echo " - invoke ${macro_prefix}_INIT in $configure_ac."
+}
+
+# func_create_testdir testdir modules
+# Input:
+# - auxdir directory relative to destdir where to place build aux files
+func_create_testdir ()
+{
+ testdir="$1"
+ modules="$2"
+ modules=`for m in $modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
+
+ # Determine final module list.
+ func_modules_transitive_closure
+ echo "Module list with included dependencies:"
+ echo "$modules" | sed -e 's/^/ /'
+
+ # Add the dummy module if needed.
+ func_modules_add_dummy
+
+ # Determine final file list.
+ func_modules_to_filelist