progname=$0
package=gnulib
-cvsdatestamp='$Date: 2006-08-28 15:21:25 $'
+cvsdatestamp='$Date: 2006-09-09 19:02:08 $'
last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
SORT=sort
fi
-nl='
-'
-
# func_usage
# outputs to stdout the --help usage message.
func_usage ()
--extract-filelist extract the list of files
--extract-dependencies extract the dependencies
--extract-autoconf-snippet extract the snippet for configure.ac
- --extract-automake-snippet extract the snippet for lib/Makefile.am
+ --extract-automake-snippet extract the snippet for library makefile
--extract-include-directive extract the #include directive
--extract-license report the license terms of the source files
under lib/
This option can be repeated.
--lgpl Abort if modules aren't available under the LGPL.
Also modify license template from GPL to LGPL.
+ --makefile-name=NAME Name of makefile in automake syntax in the
+ source-base and tests-base directories
+ (default \"Makefile.am\").
--libtool Use libtool rules.
--no-libtool Don't use libtool rules.
--macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
# - inctests true if --with-tests was given, blank otherwise
# - avoidlist list of modules to avoid, from --avoid
# - lgpl true if --lgpl was given, blank otherwise
+# - makefile_name from --makefile-name
# - libtool true if --libtool was given, false if --no-libtool was
# given, blank otherwise
# - macro_prefix from --macro-prefix
inctests=
avoidlist=
lgpl=
+ makefile_name=
libtool=
macro_prefix=
do_changelog=:
--lgpl )
lgpl=true
shift ;;
+ --makefile-name )
+ shift
+ if test $# = 0; then
+ func_fatal_error "missing argument for --makefile-name"
+ fi
+ makefile_name="$1"
+ shift ;;
+ --makefile-name=* )
+ makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
+ shift ;;
--libtool )
libtool=true
shift ;;
|| test -n "$sourcebase" || test -n "$m4base" \
|| test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
|| test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
- || test -n "$macro_prefix"; then
+ || test -n "$makefile_name" || test -n "$macro_prefix"; 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
}
# func_emit_lib_Makefile_am
-# emits the contents of lib/Makefile.am to standard output.
+# emits the contents of library makefile to standard output.
# Input:
# - local_gnulib_dir from --local-dir
# - modules list of modules, including dependencies
# - libname library name
+# - makefile_name from --makefile-name
# - libtool true if libtool will be used, false or blank otherwise
# - actioncmd (optional) command that will reproduce this invocation
func_emit_lib_Makefile_am ()
{
+ # When creating an includable Makefile.am snippet, augment variables with
+ # += instead of assigning them.
+ if test -n "$makefile_name"; then
+ assign='+='
+ else
+ assign='='
+ fi
if test "$libtool" = true; then
libext=la
perhapsLT=LT
+ sed_eliminate_LDFLAGS=
else
libext=a
perhapsLT=
+ sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
fi
echo "## Process this file with automake to produce Makefile.in."
func_emit_copyright_notice
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"
+ if test -z "$makefile_name"; then
+ # No need to generate dependencies since the sources are in gnulib, not here.
+ echo "AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies"
+ fi
echo
(
for module in $modules; do
func_get_automake_snippet "$module" |
sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
-e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
+ sed -e "$sed_eliminate_LDFLAGS" |
sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
-e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
:
else
# By default, the generated library should not be installed.
- echo "noinst_${perhapsLT}LIBRARIES = $libname.$libext"
+ echo "noinst_${perhapsLT}LIBRARIES $assign $libname.$libext"
fi
echo
echo "${libname}_${libext}_SOURCES ="
echo "${libname}_${libext}_LIBADD = @${perhapsLT}LIBOBJS@"
- echo "noinst_HEADERS ="
- if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
- echo "pkgdata_DATA ="
+ if test "$libtool" = true; then
+ echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
+ fi
+ if test -z "$makefile_name"; then
+ echo "noinst_HEADERS ="
+ # Automake versions < 1.9b create an empty pkgdatadir at installation time
+ # if you specify pkgdata_DATA to empty. This is a workaround.
+ if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
+ echo "pkgdata_DATA ="
+ fi
+ echo "EXTRA_DIST ="
+ echo "BUILT_SOURCES ="
+ echo "SUFFIXES ="
+ fi
+ echo "MOSTLYCLEANFILES $assign core *.stackdump"
+ if test -z "$makefile_name"; then
+ echo "MOSTLYCLEANDIRS ="
+ echo "CLEANFILES ="
+ echo "DISTCLEANFILES ="
+ echo "MAINTAINERCLEANFILES ="
+ echo
+ echo "AM_CPPFLAGS ="
fi
- echo "EXTRA_DIST ="
- echo "BUILT_SOURCES ="
- echo "SUFFIXES ="
- echo "MOSTLYCLEANFILES = core *.stackdump"
- echo "MOSTLYCLEANDIRS ="
- echo "CLEANFILES ="
- echo "DISTCLEANFILES ="
- echo "MAINTAINERCLEANFILES ="
- echo
- echo "AM_CPPFLAGS ="
echo
cat allsnippets.tmp
echo
echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
echo " fi; \\"
echo " done"
- echo
- echo "# Makefile.am ends here"
rm -f allsnippets.tmp
}
# func_emit_tests_Makefile_am
-# emits the contents of tests/Makefile.am to standard output.
+# emits the contents of tests makefile to standard output.
# Input:
# - local_gnulib_dir from --local-dir
# - modules list of modules, including dependencies
# - libname library name
+# - makefile_name from --makefile-name
# - libtool true if libtool will be used, false or blank otherwise
# - sourcebase relative directory containing lib source code
# - m4base relative directory containing autoconf macros
else
libext=a
fi
+ if test "$libtool" = true; then
+ libext=la
+ sed_eliminate_LDFLAGS=
+ else
+ libext=a
+ sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
+ 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
for module in $modules; do
func_verify_tests_module
if test -n "$module"; then
- func_get_automake_snippet "$module" > amsnippet.tmp
+ {
+ func_get_automake_snippet "$module" |
+ sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
+ -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
+ sed -e "$sed_eliminate_LDFLAGS" |
+ sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
+ sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
+ -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
+ } > amsnippet.tmp
# Skip the contents if its entirely empty.
if grep '[^ ]' amsnippet.tmp > /dev/null ; then
echo "## begin gnulib module $module"
echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
echo " fi; \\"
echo " done"
- echo
- echo "# Makefile.am ends here"
rm -f allsnippets.tmp
}
# - 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
+# - makefile_name from --makefile-name
# - libtool true if --libtool was given, false if --no-libtool was
# given, blank otherwise
# - guessed_libtool true if the configure.ac file uses libtool, false otherwise
cached_testsbase=
cached_libname=
cached_lgpl=
+ cached_makefile_name=
cached_libtool=
cached_macro_prefix=
cached_files=
/gl_LGPL/ {
s,^.*$,cached_lgpl=true,p
}
+ /gl_MAKEFILE_NAME(/ {
+ s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
+ }
/gl_LIBTOOL/ {
s,^.*$,cached_libtool=true,p
}
if test -z "$lgpl"; then
lgpl="$cached_lgpl"
fi
+ # The makefile_name defaults to the cached one.
+ if test -z "$makefile_name"; then
+ makefile_name="$cached_makefile_name"
+ fi
# Use libtool if specified either way, or if guessed.
if test -z "$libtool"; then
if test -n "$cached_m4base"; then
# Add the dummy module if needed.
func_modules_add_dummy
- # If --lgpl, check the license of modules are compatible.
+ # If --lgpl, verify that the licenses 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') ;;
+ LGPL | 'GPLed build tool') ;;
+ 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
*) func_fatal_error "incompatible license on module $module: $license" ;;
esac
done
# Determine script to apply to imported library files.
sed_transform_lib_file=
- case $nl$modules$nl in
- *"${nl}config-h$nl"*)
+ for module in $modules; do
+ if test $module = config-h; then
# Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
sed_transform_lib_file=$sed_transform_lib_file'
- s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
- ' ;;
- esac
+ s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
+ '
+ break
+ fi
+ done
if test -n "$lgpl"; then
# Update license.
sed_transform_lib_file=$sed_transform_lib_file'
func_dest_tmpfilename "$g"
func_lookup_file "$f"
cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
- if test -n "sed_transform_lib_file"; then
+ if test -n "$sed_transform_lib_file"; then
case "$f" in
lib/*)
sed -e "$sed_transform_lib_file" \
if test -n "$lgpl"; then
actioncmd="$actioncmd --lgpl"
fi
+ if test -n "$makefile_name"; then
+ actioncmd="$actioncmd --makefile_name=$makefile_name"
+ fi
if test "$libtool" = true; then
actioncmd="$actioncmd --libtool"
else
actioncmd="$actioncmd --macro-prefix=$macro_prefix"
actioncmd="$actioncmd `echo $specified_modules`"
- # Create lib/Makefile.am.
- func_dest_tmpfilename $sourcebase/Makefile.am
+ # Default the makefile name to Makefile.am.
+ if test -n "$makefile_name"; then
+ makefile_am=$makefile_name
+ else
+ makefile_am=Makefile.am
+ fi
+
+ # Create library makefile.
+ 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
+ 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
+ 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~)"
+ 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
+ echo "Creating $sourcebase/$makefile_am"
+ mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
else
- echo "Create $sourcebase/Makefile.am"
+ echo "Create $sourcebase/$makefile_am"
rm -f "$tmpfile"
fi
fi
echo "gl_TESTS_BASE([$testsbase])"
echo "gl_LIB([$libname])"
test -z "$lgpl" || echo "gl_LGPL"
+ echo "gl_MAKEFILE_NAME([$makefile_name])"
if test "$libtool" = true; then
echo "gl_LIBTOOL"
fi
echo "["
if test "$libtool" = true; then
echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
+ echo " gl_cond_libtool=true"
else
echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
+ echo " gl_cond_libtool=false"
+ echo " gl_libdeps="
+ echo " gl_ltlibdeps="
fi
if test "$auxdir" != "build-aux"; then
sed_replace_build_aux='
fi
fi
done
+ # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
+ # created using libtool, because libtool already handles the dependencies.
+ if test "$libtool" != true; then
+ libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
+ echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
+ echo " AC_SUBST([${libname_upper}_LIBDEPS])"
+ echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
+ echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
+ fi
echo "])"
echo
echo "# This macro records the list of files which have been installed by"
fi
if test -n "$inctests"; then
- # Create tests/Makefile.am.
- func_dest_tmpfilename $testsbase/Makefile.am
+ # Create tests makefile.
+ 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
+ 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
+ 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~)"
+ 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
+ echo "Creating $testsbase/$makefile_am"
+ mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
else
- echo "Create $testsbase/Makefile.am"
+ echo "Create $testsbase/$makefile_am"
rm -f "$tmpfile"
fi
fi
) | sed -e '/^$/d;' -e 's/^/ /'
echo
echo "Don't forget to"
- echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
+ if test "$makefile_am" = Makefile.am; then
+ echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
+ else
+ echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
+ fi
if test -n "$inctests"; then
- echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
+ if test "$makefile_am" = Makefile.am; then
+ echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
+ else
+ echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
+ fi
+ fi
+ if test "$makefile_am" = Makefile.am; then
+ sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
+ sourcebase_base=`basename "$sourcebase"`
+ echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
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,"
+ if test "$makefile_am" = Makefile.am; 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
fi
echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
fi
if test "$libtool" = true; then
echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
+ echo "gl_cond_libtool=true"
else
echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
+ echo "gl_cond_libtool=false"
+ echo "gl_libdeps="
+ echo "gl_ltlibdeps="
fi
# Wrap the set of autoconf snippets into an autoconf macro that is then
# invoked. This is needed because autoconf does not support AC_REQUIRE
| sed -e "$sed_replace_build_aux"
fi
done
+ # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
+ # created using libtool, because libtool already handles the dependencies.
+ if test "$libtool" != true; then
+ libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
+ echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
+ echo " AC_SUBST([${libname_upper}_LIBDEPS])"
+ echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
+ echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
+ fi
echo "])"
echo "gl_INIT"
echo
fi
if test "$libtool" = true; then
echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
+ echo "gl_cond_libtool=true"
else
echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
+ echo "gl_cond_libtool=false"
+ echo "gl_libdeps="
+ echo "gl_ltlibdeps="
fi
# Wrap the set of autoconf snippets into an autoconf macro that is then
# invoked. This is needed because autoconf does not support AC_REQUIRE
| sed -e "$sed_replace_build_aux"
fi
done
+ # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
+ # created using libtool, because libtool already handles the dependencies.
+ if test "$libtool" != true; then
+ libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
+ echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
+ echo " AC_SUBST([${libname_upper}_LIBDEPS])"
+ echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
+ echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
+ fi
echo "])"
echo "gl_INIT"
echo
if test $# = 0; then
# No further arguments. Guess the user wants to update all of them.
for m4base in $m4dirs; do
- func_import
+ # Perform func_import in a subshell, so that variable values
+ # such as
+ # local_gnulib_dir, avoidlist, sourcebase, m4base, docbase,
+ # testsbase, libname, lgpl, makefile_name, libtool, macro_prefix
+ # don't propagate from one directory to another.
+ (func_import) || exit 1
done
else
# Really ambiguous.
trap 'exit $?' 1 2 3 15
exit 0
+
+# Local Variables:
+# indent-tabs-mode: nil
+# whitespace-check-buffer-indent: nil
+# End: