progname=$0
package=gnulib
-cvsdatestamp='$Date: 2007-09-08 23:07:48 $'
+cvsdatestamp='$Date: 2007-09-17 10:26:33 $'
last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
+# Sometimes last_checkin_date is "YYYY/MM/DD ...", sometimes "YYYY-MM-DD ...".
version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
+# version is in YYYY-MM-DD format.
nl='
'
IFS=" "" $nl"
# gnulib-tool generates, since we don't want "sed --posix" to leak
# into makefiles.
if (alias) > /dev/null 2>&1 && echo | sed --posix -e d >/dev/null 2>&1; then
+ # Define sed as an alias.
+ # It is not always possible to use aliases. Aliases are guaranteed to work
+ # if the executing shell is bash and either it is invoked as /bin/sh or
+ # is a version >= 2.0, supporting shopt. This is the common case.
+ # Two other approaches (use of a variable $sed or of a function func_sed
+ # instead of an alias) require massive, fragile code changes.
+ # An other approach (use of function sed) requires `which sed` - but 'which'
+ # is hard to emulate, due to missing "test -x" on some platforms.
+ if test -n "$BASH_VERSION"; then
+ shopt -s expand_aliases >/dev/null 2>&1
+ fi
alias sed='sed --posix'
fi
gnulib-tool --test --dir=directory module1 ... moduleN
gnulib-tool --megatest --dir=directory [module1 ... moduleN]
gnulib-tool --extract-description module
+ gnulib-tool --extract-notice module
gnulib-tool --extract-filelist module
gnulib-tool --extract-dependencies module
gnulib-tool --extract-autoconf-snippet module
--megatest test the given modules one by one and all together
(recommended to use CC=\"gcc -Wall\" here)
--extract-description extract the description
+ --extract-notice extract the notice or banner
--extract-filelist extract the list of files
--extract-dependencies extract the dependencies
--extract-autoconf-snippet extract the snippet for configure.ac
directory.
--local-dir=DIRECTORY Specify a local override directory where to look
up files before looking in gnulib's directory.
+ --verbose Increase verbosity. May be repeated.
+ --quiet Decrease verbosity. May be repeated.
Options for --import:
--lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
# outputs to stdout the --version message.
func_version ()
{
- year=`echo "$last_checkin_date" | sed -e 's,/.*$,,'`
+ year=`echo "$version" | sed -e 's,-.*$,,'`
echo "\
$progname (GNU $package) $version
Copyright (C) $year Free Software Foundation, Inc.
# - mode list or import or create-testdir or create-megatestdir
# - destdir from --dir
# - local_gnulib_dir from --local-dir
+# - verbose integer, default 0, inc/decremented by --verbose/--quiet
# - libname, supplied_libname from --lib
# - sourcebase from --source-base
# - m4base from --m4-base
mode=
destdir=
local_gnulib_dir=
+ verbose=0
libname=libgnu
supplied_libname=
sourcebase=
--local-dir=* )
local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
shift ;;
+ --verbose | --verbos | --verbo | --verb )
+ verbose=`expr $verbose + 1`
+ shift ;;
+ --quiet | --quie | --qui | --qu | --q )
+ verbose=`expr $verbose - 1`
+ shift ;;
--lib )
shift
if test $# = 0; then
--help | --hel | --he | --h )
func_usage
func_exit $? ;;
- --version | --versio | --versi | --vers | --ver | --ve | --v )
+ --version | --versio | --versi | --vers )
func_version
func_exit $? ;;
-- )
:a
n
s/^Description:[ ]*$//
+ s/^Notice:[ ]*$//
s/^Files:[ ]*$//
s/^Depends-on:[ ]*$//
s/^configure\.ac-early:[ ]*$//
sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
}
+# func_get_notice module
+# Input:
+# - local_gnulib_dir from --local-dir
+func_get_notice ()
+{
+ func_lookup_file "modules/$1"
+ sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
+}
+
# func_get_filelist module
# Input:
# - local_gnulib_dir from --local-dir
fi
}
+# func_modules_notice
+# Input:
+# - local_gnulib_dir from --local-dir
+# - verbose integer, default 0, inc/decremented by --verbose/--quiet
+# - modules list of modules, including dependencies
+func_modules_notice ()
+{
+ if test $verbose -ge -1; then
+ for module in $modules; do
+ func_verify_module
+ if test -n "$module"; then
+ msg=`func_get_notice $module`
+ if test -n "$msg"; then
+ echo "Notice from module $module:"
+ echo "$msg" | sed -e 's/^/ /'
+ fi
+ fi
+ done
+ fi
+}
+
# func_modules_to_filelist
# Input:
# - local_gnulib_dir from --local-dir
files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
}
+# func_execute_command command [args...]
+# Executes a command.
+# Uses also the variables
+# - verbose integer, default 0, inc/decremented by --verbose/--quiet
+func_execute_command ()
+{
+ if test $verbose -ge 0; then
+ echo "executing $*"
+ "$@"
+ else
+ # Commands like automake produce output to stderr even when the succeed.
+ # Turn this output off if the command succeeds.
+ "$@" > "$tmp"/cmdout 2>&1
+ cmdret=$?
+ if test $cmdret = 0; then
+ rm -f "$tmp"/cmdout
+ else
+ echo "executing $*"
+ cat "$tmp"/cmdout 1>&2
+ rm -f "$tmp"/cmdout
+ (exit $cmdret)
+ fi
+ fi
+}
+
# func_emit_lib_Makefile_am
# emits the contents of library makefile to standard output.
# Input:
# func_emit_initmacro_done
# emits a few statements after the gl_INIT macro to standard output.
# - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
+# - sourcebase directory relative to destdir where to place source code
func_emit_initmacro_done ()
{
echo
echo "# Like AC_LIBOBJ, except that the module name goes"
echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
- echo "AC_DEFUN([${macro_prefix}_LIBOBJ],"
- echo " [${macro_prefix}_LIBOBJS=\"\$${macro_prefix}_LIBOBJS \$1.\$ac_objext\"])"
+ echo "AC_DEFUN([${macro_prefix}_LIBOBJ], ["
+ echo " AS_LITERAL_IF([\$1], [${macro_prefix}_LIBSOURCES([\$1.c])])dnl"
+ echo " ${macro_prefix}_LIBOBJS=\"\$${macro_prefix}_LIBOBJS \$1.\$ac_objext\""
+ echo "])"
echo
echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
- echo "AC_DEFUN([${macro_prefix}_REPLACE_FUNCS],"
- echo " [AC_CHECK_FUNCS([\$1], , [${macro_prefix}_LIBOBJ(\$ac_func)])])"
+ echo "AC_DEFUN([${macro_prefix}_REPLACE_FUNCS], ["
+ echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
+ echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix}_LIBOBJ(\$ac_func)])"
+ echo "])"
echo
- echo "# Like AC_LIBSOURCES, except that it does nothing."
- echo "# We rely on EXTRA_lib..._SOURCES instead."
- echo "AC_DEFUN([${macro_prefix}_LIBSOURCES],"
- echo " [])"
+ echo "# Like AC_LIBSOURCES, except the directory where the source file is"
+ echo "# expected is derived from the gnulib-tool parametrization,"
+ echo "# and alloca is special cased (for the alloca-opt module)."
+ echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
+ echo "AC_DEFUN([${macro_prefix}_LIBSOURCES], ["
+ echo " m4_foreach([_gl_NAME], [\$1], ["
+ echo " m4_if(_gl_NAME, [alloca.c], [], ["
+ echo " m4_syscmd([test -r $sourcebase/]_gl_NAME[ || test ! -d $sourcebase])dnl"
+ echo " m4_if(m4_sysval, [0], [],"
+ echo " [AC_FATAL([missing $sourcebase/]_gl_NAME)])"
+ echo " ])"
+ echo " ])"
+ echo "])"
}
# func_import modules
# Uses also the variables
# - destdir target directory
# - local_gnulib_dir from --local-dir
+# - verbose integer, default 0, inc/decremented by --verbose/--quiet
# - libname library name
# - sourcebase directory relative to destdir where to place source code
# - m4base directory relative to destdir where to place *.m4 macros
# Determine final module list.
modules="$specified_modules"
func_modules_transitive_closure
- echo "Module list with included dependencies:"
- echo "$modules" | sed -e 's/^/ /'
+ if test $verbose -ge 0; then
+ echo "Module list with included dependencies:"
+ echo "$modules" | sed -e 's/^/ /'
+ fi
# Add the dummy module if needed.
func_modules_add_dummy
done
fi
+ # Show banner notice of every module.
+ func_modules_notice
+
# Determine script to apply to imported library files.
sed_transform_lib_file=
for module in $modules; do
# Determine final file list.
func_modules_to_filelist
- echo "File list:"
- echo "$files" | sed -e 's/^/ /'
+ if test $verbose -ge 0; then
+ echo "File list:"
+ echo "$files" | sed -e 's/^/ /'
+ fi
test -n "$files" \
|| func_fatal_error "refusing to do nothing"
# Determine final module list.
func_modules_transitive_closure
- echo "Module list with included dependencies:"
- echo "$modules" | sed -e 's/^/ /'
+ if test $verbose -ge 0; then
+ echo "Module list with included dependencies:"
+ echo "$modules" | sed -e 's/^/ /'
+ fi
# Add the dummy module if needed.
func_modules_add_dummy
+ # Show banner notice of every module.
+ func_modules_notice
+
# Determine final file list.
func_modules_to_filelist
- echo "File list:"
- echo "$files" | sed -e 's/^/ /'
+ if test $verbose -ge 0; then
+ echo "File list:"
+ echo "$files" | sed -e 's/^/ /'
+ fi
sed_rewrite_files="\
s,^build-aux/,$auxdir/,
# Do not use "${AUTORECONF} --force --install", because it may invoke
# autopoint, which brings in older versions of some of our .m4 files.
if test -f $m4base/gettext.m4; then
- echo "executing ${AUTOPOINT} --force"
- ${AUTOPOINT} --force || func_exit 1
+ func_execute_command ${AUTOPOINT} --force || func_exit 1
for f in $m4base/*.m4~; do
mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
done
fi
- echo "executing ${ACLOCAL} -I $m4base"
- ${ACLOCAL} -I $m4base || func_exit 1
+ func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
if ! test -d build-aux; then
- echo "executing mkdir build-aux"
- mkdir build-aux || func_exit 1
+ func_execute_command mkdir build-aux || func_exit 1
fi
- echo "executing ${AUTOCONF}"
- ${AUTOCONF} || func_exit 1
- echo "executing ${AUTOHEADER}"
- ${AUTOHEADER} || func_exit 1
- echo "executing ${AUTOMAKE} --add-missing --copy"
- ${AUTOMAKE} --add-missing --copy || func_exit 1
+ func_execute_command ${AUTOCONF} || func_exit 1
+ func_execute_command ${AUTOHEADER} || func_exit 1
+ func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
) || func_exit 1
if test -n "$inctests"; then
# Create autogenerated files.
# Do not use "${AUTORECONF} --force --install", because it may invoke
# autopoint, which brings in older versions of some of our .m4 files.
if test -f ../$m4base/gettext.m4; then
- echo "executing ${AUTOPOINT} --force"
- ${AUTOPOINT} --force || func_exit 1
+ func_execute_command ${AUTOPOINT} --force || func_exit 1
for f in ../$m4base/*.m4~; do
mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
done
fi
- echo "executing ${ACLOCAL} -I ../$m4base"
- ${ACLOCAL} -I ../$m4base || func_exit 1
+ func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
if ! test -d ../build-aux; then
- echo "executing mkdir ../build-aux"
- mkdir ../build-aux
+ func_execute_command mkdir ../build-aux
fi
- echo "executing ${AUTOCONF}"
- ${AUTOCONF} || func_exit 1
- echo "executing ${AUTOHEADER}"
- ${AUTOHEADER} || func_exit 1
- echo "executing ${AUTOMAKE} --add-missing --copy"
- ${AUTOMAKE} --add-missing --copy || func_exit 1
+ func_execute_command ${AUTOCONF} || func_exit 1
+ func_execute_command ${AUTOHEADER} || func_exit 1
+ func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
) || func_exit 1
fi
# Need to run configure and make once, to create built files that are to be
# Do not use "${AUTORECONF} --install", because autoreconf operates
# recursively, but the subdirectories are already finished, therefore
# calling autoreconf here would only waste lots of CPU time.
- echo "executing ${ACLOCAL}"
- ${ACLOCAL} || func_exit 1
- echo "executing mkdir build-aux"
- mkdir build-aux
- echo "executing ${AUTOCONF}"
- ${AUTOCONF} || func_exit 1
- echo "executing ${AUTOMAKE} --add-missing --copy"
- ${AUTOMAKE} --add-missing --copy || func_exit 1
+ func_execute_command ${ACLOCAL} || func_exit 1
+ func_execute_command mkdir build-aux
+ func_execute_command ${AUTOCONF} || func_exit 1
+ func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
) || func_exit 1
}
done
;;
+ extract-notice )
+ for module
+ do
+ func_verify_module
+ if test -n "$module"; then
+ func_get_notice "$module"
+ fi
+ done
+ ;;
+
extract-filelist )
for module
do