+}
+
+# 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
+# - cmd (optional) command that led to this invocation
+# - 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."
+ echo "# Copyright (C) 2004 Free Software Foundation, Inc."
+ 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 Automake, under"
+ echo "# the same distribution terms as the rest of that program."
+ echo "#"
+ echo "# Generated by gnulib-tool."
+ if test -n "$cmd"; then
+ echo "# Invoked as: $cmd"
+ fi
+ 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 "EXTRA_DIST ="
+ echo "BUILT_SOURCES ="
+ echo "SUFFIXES ="
+ echo "MOSTLYCLEANFILES ="
+ echo "CLEANFILES ="
+ echo "DISTCLEANFILES ="
+ echo "MAINTAINERCLEANFILES ="
+ 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 "# 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
+func_emit_tests_Makefile_am ()
+{
+ if test -n "$libtool"; then
+ libext=la
+ else
+ libext=a
+ fi
+ echo "## Process this file with automake to produce Makefile.in."
+ echo "# Copyright (C) 2004-2005 Free Software Foundation, Inc."
+ 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 Automake, under"
+ echo "# the same distribution terms as the rest of that program."
+ echo "#"
+ echo "# Generated by gnulib-tool."
+ echo
+ # Generate dependencies here, since it eases the debugging of test failures.
+ echo "AUTOMAKE_OPTIONS = 1.5 foreign"
+ echo
+ echo "ACLOCAL_AMFLAGS = -I ../m4"
+ echo
+ echo "TESTS ="
+ echo "noinst_PROGRAMS ="
+ echo "EXTRA_DIST ="
+ echo "BUILT_SOURCES ="
+ echo "SUFFIXES ="
+ echo "MOSTLYCLEANFILES ="
+ echo "CLEANFILES ="
+ echo "DISTCLEANFILES ="
+ echo "MAINTAINERCLEANFILES ="
+ echo
+ echo "AM_CPPFLAGS = \\"
+ echo " -I. -I\$(srcdir) \\"
+ echo " -I.. -I\$(srcdir)/.. \\"
+ echo " -I../${sourcebase-lib} -I\$(srcdir)/../${sourcebase-lib}"
+ echo
+ echo "LDADD = ../${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 "# 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
+# - auxdir directory relative to destdir where to place build aux files
+# - 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
+# - dry_run true if actions shall only be printed, blank otherwise
+# - symbolic true if files should be symlinked, copied otherwise
+# - supplied_opts all options passed to gnulib-tool
+func_import ()
+{
+ modules="$1"
+ modules=`for m in $modules; do echo $m; done | sort | uniq`
+
+ # Determine final module list.
+ func_modules_transitive_closure
+ echo "Module list with included dependencies:"
+ echo "$modules" | sed -e 's/^/ /'
+
+ # 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 | '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"
+
+ # Copy files or make symbolic links.
+ for f in $files; do
+ source=
+ case "$f" in
+ build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
+ lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"`; source=true ;;
+ m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
+ *) g="$f" ;;
+ esac
+ if test -z "$symbolic"; then
+ func_cp_if_changed "$gnulib_dir/$f" "$destdir/$g"
+ else
+ func_ln_if_changed "$gnulib_dir/$f" "$destdir/$g"
+ fi
+ # Update license.
+ if test -z "$dry_run" && test -n "$lgpl" && test -n "$source"; then
+ perl -pi -e 's/GNU General/GNU Lesser General/g;' \
+ -e 's/version 2([ ,])/version 2.1\1/g' \
+ $destdir/$g
+ fi
+ done
+
+ # Commands printed in a comment in generated files.
+ cmd="gnulib-tool $supplied_opts"
+ opt_libtool=
+ if test -n "$libtool"; then
+ opt_libtool="--libtool"
+ fi
+ opt_lgpl=
+ if test -n "$lgpl"; then
+ opt_lgpl="--lgpl"
+ fi
+ actioncmd="gnulib-tool --import --dir=$destdir --lib=$libname --source-base=$sourcebase --m4-base=$m4base --aux-dir=$auxdir $opt_libtool $opt_lgpl `echo $modules`"
+
+ # Create lib/Makefile.am.
+ echo "Creating $destdir/$sourcebase/Makefile.am..."
+ if test -z "$dry_run"; then
+ func_emit_lib_Makefile_am > $destdir/$sourcebase/Makefile.am.new
+ else
+ func_emit_lib_Makefile_am
+ fi
+ func_mv_if_changed $destdir/$sourcebase/Makefile.am.new \
+ $destdir/$sourcebase/Makefile.am
+
+ # Create gnulib.m4.
+ echo "Creating $destdir/$m4base/gnulib.m4..."
+ (
+ if test -z "$dry_run"; then
+ exec > $destdir/$m4base/gnulib.m4.new
+ else
+ echo "# $destdir/$m4base/gnulib.m4"
+ fi
+ echo "# Copyright (C) 2004 Free Software Foundation, Inc."
+ 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 "# the same distribution terms as the rest of that program."
+ echo "#"
+ echo "# Generated by gnulib-tool."
+ echo "#"
+ echo "# Invoked as: $cmd"
+ echo "# Reproduce by: $actioncmd"
+ echo
+ echo "AC_DEFUN([gl_EARLY],"
+ echo "["
+ if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 > /dev/null; then
+ echo " AC_GNU_SOURCE"
+ fi
+ if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 > /dev/null; then
+ echo " gl_USE_SYSTEM_EXTENSIONS"
+ fi
+ echo "])"
+ echo
+ echo "AC_DEFUN([gl_INIT],"
+ echo "["
+ 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./'
+ 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 "dnl Usage: gl_MODULES([module1 module2 ...])"
+ echo "AC_DEFUN([gl_MODULES], [])"
+ echo
+ echo "dnl Usage: gl_AVOID([module1 module2 ...])"
+ echo "AC_DEFUN([gl_AVOID], [])"
+ echo
+ echo "dnl Usage: gl_SOURCE_BASE([DIR])"
+ echo "AC_DEFUN([gl_SOURCE_BASE], [])"
+ echo
+ echo "dnl Usage: gl_M4_BASE([DIR])"
+ echo "AC_DEFUN([gl_M4_BASE], [])"
+ echo
+ echo "dnl Usage: gl_LIB([LIBNAME])"
+ echo "AC_DEFUN([gl_LIB], [])"
+ echo
+ echo "dnl Usage: gl_LGPL"
+ echo "AC_DEFUN([gl_LGPL], [])"
+ echo
+ echo "# gnulib.m4 ends here"
+ )
+ func_mv_if_changed $destdir/$m4base/gnulib.m4.new $destdir/$m4base/gnulib.m4
+ echo "Finished."
+ echo
+ echo "You may need to add #include directives for the following .h files."
+ for module in $modules; do
+ func_get_include_directive "$module"
+ done | LC_ALL=C sort -u | sed -e '/^$/d;' -e 's/^/ /'
+ echo
+ echo "Don't forget to add \"$sourcebase/Makefile\""
+ echo "to AC_CONFIG_FILES in \"$configure_ac\" and to mention"
+ echo "\"`basename $sourcebase`\" in SUBDIRS in some Makefile.am."
+}
+
+# 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 | sort | uniq`
+
+ # Determine final module list.
+ func_modules_transitive_closure
+ echo "Module list with included dependencies:"
+ echo "$modules" | sed -e 's/^/ /'
+
+ # Determine final file list.
+ func_modules_to_filelist