#! /bin/sh
#
-# Copyright (C) 2002-2009 Free Software Foundation, Inc.
+# Copyright (C) 2002-2010 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
gnulib-tool --extract-description module
gnulib-tool --extract-status module
gnulib-tool --extract-notice module
+ gnulib-tool --extract-applicability module
gnulib-tool --extract-filelist module
gnulib-tool --extract-dependencies module
gnulib-tool --extract-autoconf-snippet module
fi
version=
fi
- year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed 's,^.* ,,'`
+ year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
echo "\
gnulib-tool (GNU $package $date)$version
Copyright (C) $year Free Software Foundation, Inc.
# outputs to stdout a header for a generated file.
func_emit_copyright_notice ()
{
- sed -n '/Copyright/ {
- p
- q
- }' < "$self_abspathname"
+ sed -n -e '/Copyright/ {
+ p
+ 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"
func_exit 1
}
+# func_warning message
+# Outputs to stderr a warning message,
+func_warning ()
+{
+ echo "gnulib-tool: warning: $1" 1>&2
+}
+
# func_readlink SYMLINK
# outputs the target of the given symlink.
if (type -p readlink) > /dev/null 2>&1; then
func_exit 1
fi
if test -z "$pobase" && test -n "$po_domain"; then
- echo "gnulib-tool: warning: --po-domain has no effect without a --po-base option" 1>&2
+ func_warning "--po-domain has no effect without a --po-base option"
fi
# Determine the minimum supported autoconf version from the project's
if test -n "$prereqs"; then
autoconf_minversion=`
for version in $prereqs; do echo $version; done |
- LC_ALL=C sort -nru | sed 1q
+ LC_ALL=C sort -nru | sed -e 1q
`
fi
fi
# Verify that building the module description with 'patch' succeeds.
func_lookup_file "modules/$module"
else
- echo "gnulib-tool: module $module doesn't exist" 1>&2
+ func_warning "module $module doesn't exist"
module=
fi
}
s/^Description:[ ]*$//
s/^Status:[ ]*$//
s/^Notice:[ ]*$//
+ s/^Applicability:[ ]*$//
s/^Files:[ ]*$//
s/^Depends-on:[ ]*$//
s/^configure\.ac-early:[ ]*$//
sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
}
+# func_get_applicability module
+# Input:
+# - local_gnulib_dir from --local-dir
+# The expected result (on stdout) is either 'main', or 'tests', or 'all'.
+func_get_applicability ()
+{
+ func_lookup_file "modules/$1"
+ { sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"
+ # The default is 'main' or 'tests', depending on the module's name.
+ case "$1" in
+ *-tests) echo "tests";;
+ *) echo "main";;
+ esac
+ } | sed -e 's,^ *$,,' | sed -e 1q
+}
+
# func_get_filelist module
# Input:
# - local_gnulib_dir from --local-dir
# elements starting with prefix and ending with suffix are considered.
# Processing: removed_prefix and removed_suffix are removed from each element,
# added_prefix and added_suffix are added to each element.
+# prefix, suffix should not contain shell-special characters.
# removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
# added_prefix, added_suffix should not contain the characters \|&.
func_filter_filelist ()
}; then
ffflist=
for fff in $3; do
+ # Do not quote possibly-empty parameters in case patterns,
+ # AIX and HP-UX ksh won't match them if they are empty.
case "$fff" in
- "$4"*"$5")
+ $4*$5)
if test -n "$6"; then
func_remove_prefix fff "$6"
fi
sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
ffflist=`for fff in $3; do
case "$fff" in
- "$4"*"$5") echo "$fff" ;;
+ $4*$5) echo "$fff" ;;
esac
done | sed -e "$sed_fff_filter"`
fi
# Duplicate dependencies are harmless, but Jim wants a warning.
duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
if test -n "$duplicated_deps"; then
- echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
+ func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
fi
for dep in $deps; do
if test -n "$incobsolete" \
echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
fi
- } > amsnippet.tmp
+ } > "$tmp"/amsnippet
# Skip the contents if it's entirely empty.
- if grep '[^ ]' amsnippet.tmp > /dev/null ; then
+ if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
echo "## begin gnulib module $module"
echo
- cat amsnippet.tmp
+ cat "$tmp"/amsnippet
echo "## end gnulib module $module"
echo
fi
- rm -f amsnippet.tmp
+ rm -f "$tmp"/amsnippet
# Test whether there are some source files in subdirectories.
for f in `func_get_filelist "$module"`; do
case $f in
done
fi
done
- } > allsnippets.tmp
+ } > "$tmp"/allsnippets
if test -z "$makefile_name"; then
# If there are source files in subdirectories, prevent collision of the
# object files (example: hash.c and libxml/hash.c).
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.
- if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
+ if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
echo "pkgdata_DATA ="
fi
echo "EXTRA_DIST ="
echo "AM_CFLAGS ="
fi
echo
- if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" allsnippets.tmp > /dev/null \
+ if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
|| { test -n "$makefile_name" \
&& test -f "$sourcebase/Makefile.am" \
&& LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
echo
fi
- cat allsnippets.tmp \
+ cat "$tmp"/allsnippets \
| sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
echo
echo "mostlyclean-local: mostlyclean-generic"
echo " fi; \\"
echo " done; \\"
echo " :"
- rm -f allsnippets.tmp
+ rm -f "$tmp"/allsnippets
}
# func_emit_po_Makevars
echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
fi
- } > amsnippet.tmp
+ } > "$tmp"/amsnippet
# Skip the contents if it's entirely empty.
- if grep '[^ ]' amsnippet.tmp > /dev/null ; then
+ if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
echo "## begin gnulib module $module"
echo
- cat amsnippet.tmp
+ cat "$tmp"/amsnippet
echo "## end gnulib module $module"
echo
fi
- rm -f amsnippet.tmp
+ rm -f "$tmp"/amsnippet
# Test whether there are some source files in subdirectories.
for f in `func_get_filelist "$module"`; do
case $f in
done
fi
done
- } > allsnippets.tmp
+ } > "$tmp"/allsnippets
# Generate dependencies here, since it eases the debugging of test failures.
# If there are source files in subdirectories, prevent collision of the
# object files (example: hash.c and libxml/hash.c).
fi
# 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
+ if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
echo "pkgdata_DATA ="
fi
echo "EXTRA_DIST ="
echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
echo
fi
- cat allsnippets.tmp \
+ # Many test scripts use ${EXEEXT} or ${srcdir}.
+ # EXEEXT is defined by AC_PROG_CC through autoconf.
+ # srcdir is defined by autoconf and automake.
+ echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
+ echo
+ cat "$tmp"/allsnippets \
| sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
echo "# Clean up after Solaris cc."
echo "clean-local:"
echo " fi; \\"
echo " done; \\"
echo " :"
- rm -f allsnippets.tmp
+ rm -f "$tmp"/allsnippets
}
# func_emit_initmacro_start macro_prefix
echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
echo " # Remove the extension."
echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
- echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
+ echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
echo " done"
# is specified, it will consist only of LGPLed source.
# The tests-related module list is the transitive closure of the specified
# modules, including tests modules, minus the main module list excluding
- # 'link-warning'. Its lib/* sources (brought in through dependencies of
- # *-tests modules) go into $testsbase/. It may contain GPLed source, even if
- # --lgpl is specified.
+ # modules of applicability 'all'. Its lib/* sources (brought in through
+ # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
+ # source, even if --lgpl is specified.
# Determine main module list.
saved_inctests="$inctests"
inctests=""
fi
# Determine tests-related module list.
echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
- sed_remove_link_warning='/^link-warning$/d'
- testsrelated_modules=`func_reset_sigpipe; echo "$main_modules" | LC_ALL=C sort -u | sed -e "$sed_remove_link_warning" | LC_ALL=C join -v 2 - "$tmp"/final-modules`
+ testsrelated_modules=`func_reset_sigpipe
+ for module in $main_modules; do
+ if test \`func_get_applicability $module\` = main; then
+ echo $module
+ fi
+ done \
+ | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
if test $verbose -ge 1; then
echo "Tests-related module list:"
echo "$testsrelated_modules" | sed -e 's/^/ /'
esac
echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
echo "gl_MODULES(["
- echo "$specified_modules" | sed 's/^/ /g'
+ echo "$specified_modules" | sed -e 's/^/ /g'
echo "])"
test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
echo "gl_AVOID([$avoidlist])"
-e "$sed_replace_build_aux"
if test "$module" = 'alloca' && test "$libtool" = true; then
echo 'changequote(,)dnl'
- echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
+ echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
echo 'changequote([, ])dnl'
echo 'AC_SUBST([LTALLOCA])'
fi
GPLv2+)
case "$license" in
GPLv2+ | LGPLv2+) ;;
- *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
+ *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
esac
;;
LGPL)
case "$license" in
LGPL | LGPLv2+) ;;
- *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
+ *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
esac
;;
LGPLv2+)
case "$license" in
LGPLv2+) ;;
- *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
+ *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
esac
;;
esac
test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
# Viewed from the $testsbase subdirectory, $auxdir is different.
saved_auxdir="$auxdir"
- auxdir=`echo "$testsbase/"|sed 's%[^/][^/]*//*%../%g'`"$auxdir"
+ auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
# Create $testsbase/Makefile.am.
use_libtests=false
destfile="$testsbase/Makefile.am"
m4dirs=
m4dirs_count=0
if test -f "$destdir"/Makefile.am; then
- aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
+ aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
m4dir_is_next=
for arg in $aclocal_amflags; do
if test -n "$m4dir_is_next"; then
done
;;
+ extract-applicability )
+ for module
+ do
+ func_verify_module
+ if test -n "$module"; then
+ func_get_applicability "$module"
+ fi
+ done
+ ;;
+
extract-filelist )
for module
do