3 # Copyright (C) 2002-2007 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # This program is meant for authors or maintainers which want to import
21 # modules from gnulib into their packages.
25 cvsdatestamp='$Date: 2007-01-08 19:20:07 $'
26 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
27 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
31 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
35 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
36 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
40 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
43 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
46 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
47 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
48 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
49 AUTOCONF="${AUTOCONFPATH}autoconf"
51 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
52 AUTOHEADER="${AUTOCONFPATH}autoheader"
54 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
55 ACLOCAL="${AUTOMAKEPATH}aclocal"
57 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
58 AUTOMAKE="${AUTOMAKEPATH}automake"
60 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
61 AUTORECONF="${AUTOCONFPATH}autoreconf"
64 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
65 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
66 AUTOPOINT="${GETTEXTPATH}autopoint"
69 # When using GNU sed, turn off as many GNU extensions as possible,
70 # to minimize the risk of accidentally using non-portable features.
71 # However, do this only for gnulib-tool itself, not for the code that
72 # gnulib-tool generates, since we don't want "sed --posix" to leak
74 if (alias) > /dev/null 2>&1 && echo | sed --posix d >/dev/null 2>&1; then
75 alias sed='sed --posix'
79 # outputs to stdout the --help usage message.
83 Usage: gnulib-tool --list
84 gnulib-tool --import [module1 ... moduleN]
86 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
87 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
88 gnulib-tool --test --dir=directory module1 ... moduleN
89 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
90 gnulib-tool --extract-description module
91 gnulib-tool --extract-filelist module
92 gnulib-tool --extract-dependencies module
93 gnulib-tool --extract-autoconf-snippet module
94 gnulib-tool --extract-automake-snippet module
95 gnulib-tool --extract-include-directive module
96 gnulib-tool --extract-license module
97 gnulib-tool --extract-maintainer module
98 gnulib-tool --extract-tests-module module
101 --list print the available module names
102 --import import the given modules into the current package;
103 if no modules are specified, update the current
104 package from the current gnulib
105 --update update the current package, restore files omitted
107 --create-testdir create a scratch package with the given modules
108 --create-megatestdir create a mega scratch package with the given modules
109 one by one and all together
110 --test test the combination of the given modules
111 (recommended to use CC=\"gcc -Wall\" here)
112 --megatest test the given modules one by one and all together
113 (recommended to use CC=\"gcc -Wall\" here)
114 --extract-description extract the description
115 --extract-filelist extract the list of files
116 --extract-dependencies extract the dependencies
117 --extract-autoconf-snippet extract the snippet for configure.ac
118 --extract-automake-snippet extract the snippet for library makefile
119 --extract-include-directive extract the #include directive
120 --extract-license report the license terms of the source files
122 --extract-maintainer report the maintainer(s) inside gnulib
123 --extract-tests-module report the unit test module, if it exists
126 --dir=DIRECTORY Specify the target directory.
127 For --import, this specifies where your
128 configure.ac can be found. Defaults to current
130 --local-dir=DIRECTORY Specify a local override directory where to look
131 up files before looking in gnulib's directory.
133 Options for --import:
134 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
135 --source-base=DIRECTORY
136 Directory relative to --dir where source code is
137 placed (default \"lib\").
138 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
139 placed (default \"m4\").
140 --doc-base=DIRECTORY Directory relative to --dir where doc files are
141 placed (default \"doc\").
142 --tests-base=DIRECTORY
143 Directory relative to --dir where unit tests are
144 placed (default \"tests\").
145 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
146 tools are placed (default \"build-aux\").
147 --with-tests Include unit tests for the included modules.
148 --avoid=MODULE Avoid including the given MODULE. Useful if you
149 have code that provides equivalent functionality.
150 This option can be repeated.
151 --lgpl Abort if modules aren't available under the LGPL.
152 Also modify license template from GPL to LGPL.
153 --makefile-name=NAME Name of makefile in automake syntax in the
154 source-base and tests-base directories
155 (default \"Makefile.am\").
156 --libtool Use libtool rules.
157 --no-libtool Don't use libtool rules.
158 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
159 'gl_INIT'. Default is 'gl'.
160 --no-changelog don't update or create ChangeLog files
162 Options for --import and --update:
163 --dry-run For --import, only print what would have been done.
164 -s, --symbolic, --symlink Make symbolic links instead of copying files.
165 --local-symlink Make symbolic links instead of copying files, only
166 for files from the local override directory.
168 Report bugs to <bug-gnulib@gnu.org>."
172 # outputs to stdout the --version message.
175 year=`echo "$last_checkin_date" | sed -e 's,/.*$,,'`
177 $progname (GNU $package) $version
178 Copyright (C) $year Free Software Foundation, Inc.
179 This is free software; see the source for copying conditions. There is NO
180 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
181 Written by" "Bruno Haible" "and" "Simon Josefsson"
184 # func_emit_copyright_notice
185 # outputs to stdout a header for a generated file.
186 func_emit_copyright_notice ()
188 echo "# Copyright (C) 2004-2007 Free Software Foundation, Inc."
190 echo "# This file is free software, distributed under the terms of the GNU"
191 echo "# General Public License. As a special exception to the GNU General"
192 echo "# Public License, this file may be distributed as part of a program"
193 echo "# that contains a configuration script generated by Autoconf, under"
194 echo "# the same distribution terms as the rest of that program."
196 echo "# Generated by gnulib-tool."
207 # creates a temporary directory.
209 # - tmp pathname of freshly created temporary directory
212 # Use the environment variable TMPDIR, falling back to /tmp. This allows
213 # users to specify a different temporary directory, for example, if their
214 # /tmp is filled up or too small.
217 # Use the mktemp program if available. If not available, hide the error
219 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
220 test -n "$tmp" && test -d "$tmp"
223 # Use a simple mkdir command. It is guaranteed to fail if the directory
224 # already exists. $RANDOM is bash specific and expands to empty in shells
225 # other than bash, ksh and zsh. Its use does not increase security;
226 # rather, it minimizes the probability of failure in a very cluttered /tmp
228 tmp=$TMPDIR/gl$$-$RANDOM
229 (umask 077 && mkdir "$tmp")
232 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
237 # func_append var value
238 # appends the given value to the shell variable var.
239 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
240 # Use bash's += operator. It reduces complexity of appending repeatedly to
241 # a single variable from O(n^2) to O(n).
249 eval "$1=\"\$$1\$2\""
253 # func_fatal_error message
254 # outputs to stderr a fatal error message, and terminates the program.
257 echo "gnulib-tool: *** $1" 1>&2
258 echo "gnulib-tool: *** Stop." 1>&2
262 # func_readlink SYMLINK
263 # outputs the target of the given symlink.
264 if (type -p readlink) > /dev/null 2>&1; then
267 # Use the readlink program from GNU coreutils.
273 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
274 # would do the wrong thing if the link target contains " -> ".
275 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
279 # func_relativize DIR1 DIR2
280 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
282 # - DIR1 relative pathname, relative to the current directory
283 # - DIR2 relative pathname, relative to the current directory
285 # - reldir relative pathname of DIR2, relative to DIR1
291 sed_first='s,^\([^/]*\)/.*$,\1,'
292 sed_rest='s,^[^/]*/*,,'
293 sed_last='s,^.*/\([^/]*\)$,\1,'
294 sed_butlast='s,/*[^/]*$,,'
295 while test -n "$dir1"; do
296 first=`echo "$dir1" | sed -e "$sed_first"`
297 if test "$first" != "."; then
298 if test "$first" = ".."; then
299 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
300 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
302 first2=`echo "$dir2" | sed -e "$sed_first"`
303 if test "$first2" = "$first"; then
304 dir2=`echo "$dir2" | sed -e "$sed_rest"`
308 dir0="$dir0"/"$first"
311 dir1=`echo "$dir1" | sed -e "$sed_rest"`
316 # func_relconcat DIR1 DIR2
317 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
319 # - DIR1 relative pathname, relative to the current directory
320 # - DIR2 relative pathname, relative to DIR1
322 # - relconcat DIR1/DIR2, relative to the current directory
327 sed_first='s,^\([^/]*\)/.*$,\1,'
328 sed_rest='s,^[^/]*/*,,'
329 sed_last='s,^.*/\([^/]*\)$,\1,'
330 sed_butlast='s,/*[^/]*$,,'
332 first=`echo "$dir2" | sed -e "$sed_first"`
333 if test "$first" = "."; then
334 dir2=`echo "$dir2" | sed -e "$sed_rest"`
335 if test -z "$dir2"; then
340 last=`echo "$dir1" | sed -e "$sed_last"`
341 while test "$last" = "."; do
342 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
343 last=`echo "$dir1" | sed -e "$sed_last"`
345 if test -z "$dir1"; then
349 if test "$first" = ".."; then
350 if test "$last" = ".."; then
351 relconcat="$dir1/$dir2"
354 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
355 dir2=`echo "$dir2" | sed -e "$sed_rest"`
356 if test -z "$dir1"; then
360 if test -z "$dir2"; then
365 relconcat="$dir1/$dir2"
373 # Like ln -s, except that SRC is given relative to the current directory (or
374 # absolute), not given relative to the directory of DEST.
380 *) # SRC is relative.
383 ln -s "`pwd`/$1" "$2" ;;
384 *) # DEST is relative too.
385 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
386 test -n "$ln_destdir" || ln_destdir="."
387 func_relativize "$ln_destdir" "$1"
395 # func_ln_if_changed SRC DEST
396 # Like func_ln, but avoids munging timestamps if the link is correct.
397 func_ln_if_changed ()
399 if test $# -ne 2; then
400 echo "usage: func_ln_if_changed SRC DEST" >&2
402 ln_target=`func_readlink "$2"`
403 if test -L "$2" && test "$1" = "$ln_target"; then
411 # Command-line option processing.
412 # Removes the OPTIONS from the arguments. Sets the variables:
413 # - mode list or import or create-testdir or create-megatestdir
414 # - destdir from --dir
415 # - local_gnulib_dir from --local-dir
416 # - libname, supplied_libname from --lib
417 # - sourcebase from --source-base
418 # - m4base from --m4-base
419 # - docbase from --doc-base
420 # - testsbase from --tests-base
421 # - auxdir from --aux-dir
422 # - inctests true if --with-tests was given, blank otherwise
423 # - avoidlist list of modules to avoid, from --avoid
424 # - lgpl true if --lgpl was given, blank otherwise
425 # - makefile_name from --makefile-name
426 # - libtool true if --libtool was given, false if --no-libtool was
427 # given, blank otherwise
428 # - macro_prefix from --macro-prefix
429 # - autoconf_minversion minimum supported autoconf version
430 # - do_changelog false if --no-changelog was given, : otherwise
431 # - doit : if actions shall be executed, false if only to be printed
432 # - symbolic true if --symlink was given, blank otherwise
433 # - lsymbolic true if --local-symlink was given, blank otherwise
458 while test $# -gt 0; do
463 --import | --impor | --impo | --imp | --im | --i )
466 --update | --updat | --upda | --upd | --up | --u )
469 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
472 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
473 mode=create-megatestdir
475 --test | --tes | --te | --t )
478 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
482 mode=`echo "X$1" | sed -e 's/^X--//'`
487 func_fatal_error "missing argument for --dir"
492 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
497 func_fatal_error "missing argument for --local-dir"
502 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
507 func_fatal_error "missing argument for --lib"
510 supplied_libname=true
513 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
514 supplied_libname=true
519 func_fatal_error "missing argument for --source-base"
524 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
529 func_fatal_error "missing argument for --m4-base"
534 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
539 func_fatal_error "missing argument for --doc-base"
544 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
549 func_fatal_error "missing argument for --tests-base"
554 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
559 func_fatal_error "missing argument for --aux-dir"
564 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
572 func_fatal_error "missing argument for --avoid"
574 func_append avoidlist " $1"
577 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
578 func_append avoidlist " $arg"
586 func_fatal_error "missing argument for --makefile-name"
591 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
602 func_fatal_error "missing argument for --macro-prefix"
607 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
609 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
615 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
618 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
621 --help | --hel | --he | --h )
624 --version | --versio | --versi | --vers | --ver | --ve | --v )
628 # Stop option processing
632 echo "gnulib-tool: unknown option $1" 1>&2
633 echo "Try 'gnulib-tool --help' for more information." 1>&2
640 if test "$mode" = update; then
641 if test $# != 0; then
642 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
643 echo "Try 'gnulib-tool --help' for more information." 1>&2
644 echo "If you really want to modify the gnulib configuration of your project," 1>&2
645 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
648 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
649 || test -n "$sourcebase" || test -n "$m4base" \
650 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
651 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
652 || test -n "$makefile_name" || test -n "$macro_prefix"; then
653 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
654 echo "Try 'gnulib-tool --help' for more information." 1>&2
655 echo "If you really want to modify the gnulib configuration of your project," 1>&2
656 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
662 # Determine the minimum supported autoconf version from the project's
664 DEFAULT_AUTOCONF_MINVERSION="2.59"
667 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
668 if test -f "$destdir"/configure.ac; then
669 configure_ac="$destdir/configure.ac"
671 if test -f "$destdir"/configure.in; then
672 configure_ac="$destdir/configure.in"
676 if test -f configure.ac; then
677 configure_ac="configure.ac"
679 if test -f configure.in; then
680 configure_ac="configure.in"
684 if test -n "$configure_ac"; then
685 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
686 # because when some m4 files are omitted from a CVS repository,
687 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
688 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
689 # autom4te: m4 failed with exit status: 1
696 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
698 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
699 if test -n "$prereqs"; then
700 autoconf_minversion=`
701 for version in $prereqs; do echo $version; done |
702 LC_ALL=C sort -nru | sed 1q
706 if test -z "$autoconf_minversion"; then
707 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
709 case "$autoconf_minversion" in
710 1.* | 2.[0-4]* | 2.5[0-8]*)
711 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
714 # Remove trailing slashes from the directory names. This is necessary for
715 # m4base (to avoid an error in func_import) and optional for the others.
716 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
717 case "$local_gnulib_dir" in
718 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
720 case "$sourcebase" in
721 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
724 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
727 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
730 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
733 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
738 /*) self_abspathname="$0" ;;
739 */*) self_abspathname=`pwd`/"$0" ;;
740 *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
741 if test -x "$d/$0" && test ! -d "$d/$0"; then
742 self_abspathname="$d/$0"
746 if test -z "$self_abspathname"; then
747 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
751 while test -h "$self_abspathname"; do
752 # Resolve symbolic link.
753 linkval=`func_readlink "$self_abspathname"`
754 test -n "$linkval" || break
756 /* ) self_abspathname="$linkval" ;;
757 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
760 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
764 if test "$signal" != 0; then
765 echo "caught signal $signal" >&2
769 for signal in 1 2 3 13 15; do
770 trap '{ signal='$signal'; func_exit 1; }' $signal
774 # func_lookup_file file
775 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
778 # - local_gnulib_dir from --local-dir
780 # - lookedup_file name of the merged (combined) file
781 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
785 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
786 lookedup_file="$local_gnulib_dir/$lkfile"
789 if test -f "$gnulib_dir/$lkfile"; then
790 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
791 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
793 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
794 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
795 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
796 lookedup_file="$tmp/$lkbase"
799 lookedup_file="$gnulib_dir/$lkfile"
803 func_fatal_error "file $gnulib_dir/$lkfile not found"
810 # - local_gnulib_dir from --local-dir
813 # Filter out metainformation files like README, which are not modules.
814 # Filter out unit test modules; they can be retrieved through
815 # --extract-tests-module if desired.
817 (cd "$gnulib_dir/modules" && ls -1)
818 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
819 (cd "$local_gnulib_dir/modules" && ls -1 | sed -e 's,\.diff$,,')
822 | sed -e '/^CVS$/d' -e '/^ChangeLog$/d' -e '/^COPYING$/d' -e '/^README$/d' -e '/^TEMPLATE$/d' -e '/^TEMPLATE-TESTS$/d' -e '/~$/d' \
823 | sed -e '/-tests$/d' \
828 # verifies a module name
830 # - local_gnulib_dir from --local-dir
831 # - module module name argument
832 func_verify_module ()
834 if { test -f "$gnulib_dir/modules/$module" \
835 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
836 && test -f "$local_gnulib_dir/modules/$module"; }; } \
837 && test "CVS" != "$module" \
838 && test "ChangeLog" != "$module" \
839 && test "COPYING" != "$module" \
840 && test "README" != "$module" \
841 && test "TEMPLATE" != "$module" \
842 && test "TEMPLATE-TESTS" != "$module"; then
843 # OK, $module is a correct module name.
844 # Verify that building the module description with 'patch' succeeds.
845 func_lookup_file "modules/$module"
847 echo "gnulib-tool: module $module doesn't exist" 1>&2
852 # func_verify_nontests_module
853 # verifies a module name, excluding tests modules
855 # - local_gnulib_dir from --local-dir
856 # - module module name argument
857 func_verify_nontests_module ()
861 * ) func_verify_module ;;
865 # func_verify_tests_module
866 # verifies a module name, considering only tests modules
868 # - local_gnulib_dir from --local-dir
869 # - module module name argument
870 func_verify_tests_module ()
873 *-tests ) func_verify_module ;;
878 sed_extract_prog=':[ ]*$/ {
881 s/^Description:[ ]*$//
883 s/^Depends-on:[ ]*$//
884 s/^configure\.ac:[ ]*$//
885 s/^Makefile\.am:[ ]*$//
888 s/^Maintainer:[ ]*$//
895 # func_get_description module
897 # - local_gnulib_dir from --local-dir
898 func_get_description ()
900 func_lookup_file "modules/$1"
901 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
904 # func_get_filelist module
906 # - local_gnulib_dir from --local-dir
909 func_lookup_file "modules/$1"
910 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
911 echo m4/gnulib-common.m4
912 case "$autoconf_minversion" in
915 echo m4/onceonly_2_57.m4
920 # func_get_dependencies module
922 # - local_gnulib_dir from --local-dir
923 func_get_dependencies ()
925 # ${module}-tests always implicitly depends on ${module}.
926 echo "$1" | sed -n -e 's/-tests//p'
927 # Then the explicit dependencies listed in the module description.
928 func_lookup_file "modules/$1"
929 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
932 # func_get_autoconf_snippet module
934 # - local_gnulib_dir from --local-dir
935 func_get_autoconf_snippet ()
937 func_lookup_file "modules/$1"
938 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
941 # func_get_automake_snippet module
943 # - local_gnulib_dir from --local-dir
944 func_get_automake_snippet ()
946 func_lookup_file "modules/$1"
947 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
950 # *-tests module live in tests/, not lib/.
953 # Synthesize an EXTRA_DIST augmentation.
954 sed_combine_lines='/\\$/{
961 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
962 already_mentioned_files=` \
963 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
964 | sed -e "$sed_combine_lines" \
965 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
966 all_files=`func_get_filelist $1`
967 lib_files=`for f in $all_files; do \
971 done | sed -e 's,^lib/,,'`
972 # Remove $already_mentioned_files from $lib_files.
973 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
974 extra_files=`for f in $already_mentioned_files; do echo $f; done \
975 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
976 if test -n "$extra_files"; then
977 echo "EXTRA_DIST +=" $extra_files
980 # Synthesize also an EXTRA_lib_SOURCES augmentation.
981 # This is necessary so that automake can generate the right list of
983 # A possible approach would be to use autom4te --trace of the redefined
984 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
985 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
986 # inside autoconf's built-in macros are not missed).
987 # But it's simpler and more robust to do it here, based on the file list.
988 # If some .c file exists and is not used with AC_LIBOBJ - for example,
989 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
990 # automake will generate a useless dependency; this is harmless.
991 sed_extract_c_files='/\.c$/p'
992 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
993 if test -n "$extra_files"; then
994 echo "EXTRA_lib_SOURCES +=" $extra_files
1001 # func_get_include_directive module
1003 # - local_gnulib_dir from --local-dir
1004 func_get_include_directive ()
1006 func_lookup_file "modules/$1"
1007 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1008 sed -e 's/^\(["<]\)/#include \1/'
1011 # func_get_license module
1013 # - local_gnulib_dir from --local-dir
1016 func_lookup_file "modules/$1"
1017 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1020 # func_get_maintainer module
1022 # - local_gnulib_dir from --local-dir
1023 func_get_maintainer ()
1025 func_lookup_file "modules/$1"
1026 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1029 # func_get_tests_module module
1031 # - local_gnulib_dir from --local-dir
1032 func_get_tests_module ()
1034 # The naming convention for tests modules is hardwired: ${module}-tests.
1035 if test -f "$gnulib_dir/modules/$1"-tests \
1036 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1037 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1042 # func_acceptable module
1043 # tests whether a module is acceptable.
1045 # - avoidlist list of modules to avoid
1048 for avoid in $avoidlist; do
1049 if test "$avoid" = "$1"; then
1056 # func_modules_transitive_closure
1058 # - local_gnulib_dir from --local-dir
1059 # - modules list of specified modules
1060 # - inctests true if tests should be included, blank otherwise
1061 # - avoidlist list of modules to avoid
1062 # - tmp pathname of a temporary directory
1064 # - modules list of modules, including dependencies
1065 func_modules_transitive_closure ()
1067 # In order to process every module only once (for speed), process an "input
1068 # list" of modules, producing an "output list" of modules. During each round,
1069 # more modules can be queued in the input list. Once a module on the input
1070 # list has been processed, it is added to the "handled list", so we can avoid
1071 # to process it again.
1073 inmodules="$modules"
1075 while test -n "$inmodules"; do
1076 inmodules_this_round="$inmodules"
1077 inmodules= # Accumulator, queue for next round
1078 for module in $inmodules_this_round; do
1080 if test -n "$module"; then
1081 if func_acceptable $module; then
1082 func_append outmodules " $module"
1083 deps=`func_get_dependencies $module`
1084 # Duplicate dependencies are harmless, but Jim wants a warning.
1085 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1086 if test -n "$duplicated_deps"; then
1087 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1089 func_append inmodules " $deps"
1090 if test -n "$inctests"; then
1091 testsmodule=`func_get_tests_module $module`
1092 if test -n "$testsmodule"; then
1093 func_append inmodules " $testsmodule"
1099 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1100 # Remove $handledmodules from $inmodules.
1101 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1102 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1104 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1105 rm -f "$tmp"/queued-modules
1108 # func_modules_add_dummy
1110 # - local_gnulib_dir from --local-dir
1111 # - modules list of modules, including dependencies
1113 # - modules list of modules, including 'dummy' if needed
1114 func_modules_add_dummy ()
1117 sed_remove_backslash_newline=':a
1124 for module in $modules; do
1125 func_verify_nontests_module
1126 if test -n "$module"; then
1127 # Extract the value of "lib_SOURCES += ...".
1128 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1129 # Ignore .h files since they are not compiled.
1132 *) have_lib_SOURCES=yes ;;
1137 # Add the dummy module, to make sure the library will be non-empty.
1138 if test -z "$have_lib_SOURCES"; then
1139 func_append modules " dummy"
1143 # func_modules_to_filelist
1145 # - local_gnulib_dir from --local-dir
1146 # - modules list of modules, including dependencies
1148 # - files list of files
1149 func_modules_to_filelist ()
1152 for module in $modules; do
1154 if test -n "$module"; then
1155 fs=`func_get_filelist $module`
1156 func_append files " $fs"
1159 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1162 # func_emit_lib_Makefile_am
1163 # emits the contents of library makefile to standard output.
1165 # - local_gnulib_dir from --local-dir
1166 # - modules list of modules, including dependencies
1167 # - libname library name
1168 # - auxdir directory relative to destdir where to place build aux files
1169 # - makefile_name from --makefile-name
1170 # - libtool true if libtool will be used, false or blank otherwise
1171 # - macro_prefix prefix of gl_LIBOBJS macros to use
1172 # - actioncmd (optional) command that will reproduce this invocation
1174 # - uses_subdirs nonempty if object files in subdirs exist
1175 func_emit_lib_Makefile_am ()
1177 # When creating an includable Makefile.am snippet, augment variables with
1178 # += instead of assigning them.
1179 if test -n "$makefile_name"; then
1184 if test "$libtool" = true; then
1187 sed_eliminate_LDFLAGS=
1191 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1193 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1194 echo "## Process this file with automake to produce Makefile.in."
1195 func_emit_copyright_notice
1196 if test -n "$actioncmd"; then
1197 echo "# Reproduce by: $actioncmd"
1202 for module in $modules; do
1203 func_verify_nontests_module
1204 if test -n "$module"; then
1206 func_get_automake_snippet "$module" |
1207 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1208 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1209 sed -e "$sed_eliminate_LDFLAGS" |
1210 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1211 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1212 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
1213 if test "$module" = 'alloca'; then
1214 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1215 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1218 # Skip the contents if its entirely empty.
1219 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1220 echo "## begin gnulib module $module"
1223 echo "## end gnulib module $module"
1227 # Test whether there are some source files in subdirectories.
1228 for f in `func_get_filelist "$module"`; do
1230 lib/*/*.c) uses_subdirs=yes ;;
1236 if test -z "$makefile_name"; then
1237 # If there are source files in subdirectories, prevent collision of the
1238 # object files (example: hash.c and libxml/hash.c).
1240 if test -n "$uses_subdirs"; then
1241 subdir_options=' subdir-objects'
1243 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1246 if test -z "$makefile_name"; then
1247 echo "noinst_HEADERS ="
1248 echo "noinst_LIBRARIES ="
1249 echo "noinst_LTLIBRARIES ="
1250 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1251 # if you specify pkgdata_DATA to empty. This is a workaround.
1252 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1253 echo "pkgdata_DATA ="
1256 echo "BUILT_SOURCES ="
1259 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1260 if test -z "$makefile_name"; then
1261 echo "MOSTLYCLEANDIRS ="
1263 echo "DISTCLEANFILES ="
1264 echo "MAINTAINERCLEANFILES ="
1266 echo "AM_CPPFLAGS ="
1269 if grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1270 # One of the snippets already specifies an installation location for the
1271 # library. Don't confuse automake by saying it should not be installed.
1274 # By default, the generated library should not be installed.
1275 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1278 echo "${libname}_${libext}_SOURCES ="
1279 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1280 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1281 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1282 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1283 echo "EXTRA_${libname}_${libext}_SOURCES ="
1284 if test "$libtool" = true; then
1285 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1288 cat allsnippets.tmp \
1289 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1291 echo "mostlyclean-local: mostlyclean-generic"
1292 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1293 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1294 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1297 rm -f allsnippets.tmp
1300 # func_emit_tests_Makefile_am
1301 # emits the contents of tests makefile to standard output.
1303 # - local_gnulib_dir from --local-dir
1304 # - modules list of modules, including dependencies
1305 # - libname library name
1306 # - makefile_name from --makefile-name
1307 # - libtool true if libtool will be used, false or blank otherwise
1308 # - sourcebase relative directory containing lib source code
1309 # - m4base relative directory containing autoconf macros
1310 # - testsbase relative directory containing unit test code
1311 func_emit_tests_Makefile_am ()
1313 if test "$libtool" = true; then
1318 if test "$libtool" = true; then
1320 sed_eliminate_LDFLAGS=
1323 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1325 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1326 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1327 echo "## Process this file with automake to produce Makefile.in."
1328 func_emit_copyright_notice
1330 # Generate dependencies here, since it eases the debugging of test failures.
1331 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1333 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1336 for module in $modules; do
1337 func_verify_tests_module
1338 if test -n "$module"; then
1340 func_get_automake_snippet "$module" |
1341 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1342 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1343 sed -e "$sed_eliminate_LDFLAGS" |
1344 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1345 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1346 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
1348 # Skip the contents if its entirely empty.
1349 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1350 echo "## begin gnulib module $module"
1353 echo "## end gnulib module $module"
1360 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1361 # variable is needed to avoid an error from automake:
1362 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1365 echo "TESTS_ENVIRONMENT ="
1366 echo "noinst_PROGRAMS ="
1367 echo "check_PROGRAMS ="
1368 echo "noinst_HEADERS ="
1369 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1370 echo "pkgdata_DATA ="
1373 echo "BUILT_SOURCES ="
1375 echo "MOSTLYCLEANFILES = core *.stackdump"
1376 echo "MOSTLYCLEANDIRS ="
1378 echo "DISTCLEANFILES ="
1379 echo "MAINTAINERCLEANFILES ="
1381 echo "AM_CPPFLAGS = \\"
1382 echo " -I. -I\$(srcdir) \\"
1383 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1384 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1386 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1389 echo "# Clean up after Solaris cc."
1391 echo " rm -rf SunWS_cache"
1393 echo "mostlyclean-local: mostlyclean-generic"
1394 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1395 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1396 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1399 rm -f allsnippets.tmp
1402 # func_emit_initmacro_start
1403 # emits the first few statements of the gl_INIT macro to standard output.
1404 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1405 func_emit_initmacro_start ()
1407 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
1408 # platform-dependent object files in ${macro_prefix}_LIBOBJS instead of
1409 # LIBOBJS. The purpose is to allow several gnulib instantiations under
1410 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
1412 # Furthermore it avoids an automake error like this when a Makefile.am
1413 # that uses pieces of gnulib also uses $(LIBOBJ):
1414 # automatically discovered file `error.c' should not be explicitly mentioned
1415 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix}_LIBOBJ]))"
1416 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix}_REPLACE_FUNCS]))"
1417 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
1418 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
1419 # automatically discovered file `error.c' should not be explicitly mentioned
1420 # We let automake know about the files to be distributed through the
1421 # EXTRA_lib_SOURCES variable.
1422 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix}_LIBSOURCES]))"
1425 # func_emit_initmacro_end
1426 # emits the last few statements of the gl_INIT macro to standard output.
1427 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1428 func_emit_initmacro_end ()
1430 echo " m4_popdef([AC_LIBSOURCES])"
1431 echo " m4_popdef([AC_REPLACE_FUNCS])"
1432 echo " m4_popdef([AC_LIBOBJ])"
1433 echo " AC_CONFIG_COMMANDS_PRE(["
1434 echo " ${macro_prefix}_libobjs="
1435 echo " ${macro_prefix}_ltlibobjs="
1436 echo " if test -n \"\$${macro_prefix}_LIBOBJS\"; then"
1437 echo " # Remove the extension."
1438 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
1439 echo " for i in \`for i in \$${macro_prefix}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
1440 echo " ${macro_prefix}_libobjs=\"\$${macro_prefix}_libobjs \$i.\$ac_objext\""
1441 echo " ${macro_prefix}_ltlibobjs=\"\$${macro_prefix}_ltlibobjs \$i.lo\""
1444 echo " AC_SUBST([${macro_prefix}_LIBOBJS], [\$${macro_prefix}_libobjs])"
1445 echo " AC_SUBST([${macro_prefix}_LTLIBOBJS], [\$${macro_prefix}_ltlibobjs])"
1449 # func_emit_initmacro_done
1450 # emits a few statements after the gl_INIT macro to standard output.
1451 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1452 func_emit_initmacro_done ()
1455 echo "# Like AC_LIBOBJ, except that the module name goes"
1456 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1457 echo "AC_DEFUN([${macro_prefix}_LIBOBJ],"
1458 echo " [${macro_prefix}_LIBOBJS=\"\$${macro_prefix}_LIBOBJS \$1.\$ac_objext\"])"
1460 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
1461 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1462 echo "AC_DEFUN([${macro_prefix}_REPLACE_FUNCS],"
1463 echo " [AC_CHECK_FUNCS([\$1], , [${macro_prefix}_LIBOBJ(\$ac_func)])])"
1465 echo "# Like AC_LIBSOURCES, except that it does nothing."
1466 echo "# We rely on EXTRA_lib..._SOURCES instead."
1467 echo "AC_DEFUN([${macro_prefix}_LIBSOURCES],"
1471 # func_import modules
1472 # Uses also the variables
1473 # - destdir target directory
1474 # - local_gnulib_dir from --local-dir
1475 # - libname library name
1476 # - sourcebase directory relative to destdir where to place source code
1477 # - m4base directory relative to destdir where to place *.m4 macros
1478 # - docbase directory relative to destdir where to place doc files
1479 # - testsbase directory relative to destdir where to place unit test code
1480 # - auxdir directory relative to destdir where to place build aux files
1481 # - inctests true if --with-tests was given, blank otherwise
1482 # - avoidlist list of modules to avoid, from --avoid
1483 # - lgpl true if library's license shall be LGPL, blank otherwise
1484 # - makefile_name from --makefile-name
1485 # - libtool true if --libtool was given, false if --no-libtool was
1486 # given, blank otherwise
1487 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1488 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1489 # - autoconf_minversion minimum supported autoconf version
1490 # - doit : if actions shall be executed, false if only to be printed
1491 # - symbolic true if files should be symlinked, copied otherwise
1492 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1496 # Get the cached settings.
1497 cached_local_gnulib_dir=
1498 cached_specified_modules=
1506 cached_makefile_name=
1508 cached_macro_prefix=
1510 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1511 cached_libtool=false
1517 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
1520 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1523 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1526 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1529 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1532 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1535 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1538 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1541 s,^.*$,cached_lgpl=true,p
1543 /gl_MAKEFILE_NAME(/ {
1544 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
1547 s,^.*$,cached_libtool=true,p
1549 /gl_MACRO_PREFIX(/ {
1550 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
1552 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
1553 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1558 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
1559 s,^.*$,cached_files=",p
1571 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1575 # Merge the cached settings with the specified ones.
1576 # The m4base must be the same as expected from the pathname.
1577 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1578 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1580 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
1581 # is relative to $destdir, whereas the one we use is relative to . or absolute.
1582 if test -z "$local_gnulib_dir"; then
1583 if test -n "$cached_local_gnulib_dir"; then
1586 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1588 case "$cached_local_gnulib_dir" in
1590 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1592 func_relconcat "$destdir" "$cached_local_gnulib_dir"
1593 local_gnulib_dir="$relconcat" ;;
1598 # Append the cached and the specified module names. So that
1599 # "gnulib-tool --import foo" means to add the module foo.
1600 specified_modules="$cached_specified_modules $1"
1601 # Append the cached and the specified avoidlist. This is probably better
1602 # than dropping the cached one when --avoid is specified at least once.
1603 avoidlist=`echo $cached_avoidlist $avoidlist`
1604 # The sourcebase defaults to the cached one.
1605 if test -z "$sourcebase"; then
1606 sourcebase="$cached_sourcebase"
1607 if test -z "$sourcebase"; then
1608 func_fatal_error "missing --source-base option"
1611 # The docbase defaults to the cached one.
1612 if test -z "$docbase"; then
1613 docbase="$cached_docbase"
1614 if test -z "$docbase"; then
1615 func_fatal_error "missing --doc-base option. --doc-base has been introduced on 2006-07-11; if your last invocation of 'gnulib-tool --import' is before that date, you need to run 'gnulib-tool --import' once, with a --doc-base option."
1618 # The testsbase defaults to the cached one.
1619 if test -z "$testsbase"; then
1620 testsbase="$cached_testsbase"
1621 if test -z "$testsbase"; then
1622 func_fatal_error "missing --tests-base option"
1625 # The libname defaults to the cached one.
1626 if test -z "$supplied_libname"; then
1627 libname="$cached_libname"
1628 if test -z "$libname"; then
1629 func_fatal_error "missing --lib option"
1632 # Require LGPL if specified either way.
1633 if test -z "$lgpl"; then
1636 # The makefile_name defaults to the cached one.
1637 if test -z "$makefile_name"; then
1638 makefile_name="$cached_makefile_name"
1640 # Use libtool if specified either way, or if guessed.
1641 if test -z "$libtool"; then
1642 if test -n "$cached_m4base"; then
1643 libtool="$cached_libtool"
1645 libtool="$guessed_libtool"
1648 # The macro_prefix defaults to the cached one.
1649 if test -z "$macro_prefix"; then
1650 macro_prefix="$cached_macro_prefix"
1651 if test -z "$macro_prefix"; then
1652 func_fatal_error "missing --macro-prefix option"
1656 # Canonicalize the list of specified modules.
1657 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
1659 # Determine final module list.
1660 modules="$specified_modules"
1661 func_modules_transitive_closure
1662 echo "Module list with included dependencies:"
1663 echo "$modules" | sed -e 's/^/ /'
1665 # Add the dummy module if needed.
1666 func_modules_add_dummy
1668 # If --lgpl, verify that the licenses of modules are compatible.
1669 if test -n "$lgpl"; then
1670 for module in $modules; do
1671 license=`func_get_license $module`
1673 LGPL | 'GPLed build tool') ;;
1674 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
1675 *) func_fatal_error "incompatible license on module $module: $license" ;;
1680 # Determine script to apply to imported library files.
1681 sed_transform_lib_file=
1682 for module in $modules; do
1683 if test $module = config-h; then
1684 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
1685 sed_transform_lib_file=$sed_transform_lib_file'
1686 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
1691 if test -n "$lgpl"; then
1693 sed_transform_lib_file=$sed_transform_lib_file'
1694 s/GNU General/GNU Lesser General/g
1695 s/version 2\([ ,]\)/version 2.1\1/g
1699 # Determine final file list.
1700 func_modules_to_filelist
1702 echo "$files" | sed -e 's/^/ /'
1705 || func_fatal_error "refusing to do nothing"
1707 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
1708 new_files="$files m4/gnulib-tool.m4"
1709 old_files="$cached_files"
1710 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
1711 func_append old_files " m4/gnulib-tool.m4"
1714 sed_rewrite_old_files="\
1715 s,^build-aux/,$auxdir/,
1716 s,^doc/,$cached_docbase/,
1717 s,^lib/,$cached_sourcebase/,
1718 s,^m4/,$cached_m4base/,
1719 s,^tests/,$cached_testsbase/,"
1720 sed_rewrite_new_files="\
1721 s,^build-aux/,$auxdir/,
1723 s,^lib/,$sourcebase/,
1725 s,^tests/,$testsbase/,"
1727 # Create directories.
1728 { echo "$sourcebase"
1730 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
1731 if test -n "$docfiles"; then
1734 if test -n "$inctests"; then
1738 for f in $files; do echo $f; done \
1739 | sed -e "$sed_rewrite_new_files" \
1740 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
1743 { # Rearrange file descriptors. Needed because "while ... done < ..."
1744 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1745 exec 5<&0 < "$tmp"/dirs
1747 if test ! -d "$destdir/$d"; then
1749 echo "Creating directory $destdir/$d"
1750 mkdir -p "$destdir/$d" || func_fatal_error "failed"
1752 echo "Create directory $destdir/$d"
1759 # func_dest_tmpfilename file
1760 # determines the name of a temporary file (file is relative to destdir).
1762 # - tmpfile absolute filename of the temporary file
1763 func_dest_tmpfilename ()
1766 # Put the new contents of $file in a file in the same directory (needed
1767 # to guarantee that an 'mv' to "$destdir/$file" works).
1768 tmpfile="$destdir/$1.tmp"
1770 # Put the new contents of $file in a file in a temporary directory
1771 # (because the directory of "$file" might not exist).
1772 tmpfile="$tmp"/`basename "$1"`.tmp
1776 # Copy files or make symbolic links. Remove obsolete files.
1778 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1779 # representing the files according to the last gnulib-tool invocation.
1780 for f in $old_files; do echo $f; done \
1781 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
1784 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1785 # representing the files after this gnulib-tool invocation.
1786 for f in $new_files; do echo $f; done \
1787 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
1790 # First the files that are in old-files, but not in new-files:
1791 sed_take_first_column='s,'"$delimiter"'.*,,'
1792 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
1793 # Remove the file. Do nothing if the user already removed it.
1794 if test -f "$destdir/$g"; then
1796 echo "Removing file $g (backup in ${g}~)"
1797 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1799 echo "Remove file $g (backup in ${g}~)"
1803 # func_add_or_update handles a file that ought to be present afterwards.
1805 # - f the original file name
1806 # - g the rewritten file name
1807 # - already_present nonempty if the file already exists, empty otherwise
1808 func_add_or_update ()
1810 func_dest_tmpfilename "$g"
1811 func_lookup_file "$f"
1812 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
1813 if test -n "$sed_transform_lib_file"; then
1816 sed -e "$sed_transform_lib_file" \
1817 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
1821 if test -f "$destdir/$g"; then
1822 # The file already exists.
1823 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1824 : # The file has not changed.
1828 if test -n "$already_present"; then
1829 echo "Updating file $g (backup in ${g}~)"
1831 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
1833 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1834 if { test -n "$symbolic" \
1835 || { test -n "$lsymbolic" \
1836 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1837 && test -z "$lookedup_tmp" \
1838 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1839 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1841 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1844 if test -n "$already_present"; then
1845 echo "Update file $g (backup in ${g}~)"
1847 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
1853 # Don't protest if the file should be there but isn't: it happens
1854 # frequently that developers don't put autogenerated files into CVS.
1856 echo "Copying file $g"
1857 if { test -n "$symbolic" \
1858 || { test -n "$lsymbolic" \
1859 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1860 && test -z "$lookedup_tmp" \
1861 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1862 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1864 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1872 # Then the files that are in new-files, but not in old-files:
1873 sed_take_last_column='s,^.*'"$delimiter"',,'
1875 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
1876 | sed -e "$sed_take_last_column" \
1877 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
1878 { # Rearrange file descriptors. Needed because "while ... done < ..."
1879 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1880 exec 5<&0 < "$tmp"/added-files
1886 # Then the files that are in new-files and in old-files:
1887 already_present=true
1888 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
1889 | sed -e "$sed_take_last_column" \
1890 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
1891 { # Rearrange file descriptors. Needed because "while ... done < ..."
1892 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1893 exec 5<&0 < "$tmp"/kept-files
1900 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
1901 actioncmd="gnulib-tool --import"
1902 func_append actioncmd " --dir=$destdir"
1903 if test -n "$local_gnulib_dir"; then
1904 func_append actioncmd " --local-dir=$local_gnulib_dir"
1906 func_append actioncmd " --lib=$libname"
1907 func_append actioncmd " --source-base=$sourcebase"
1908 func_append actioncmd " --m4-base=$m4base"
1909 func_append actioncmd " --doc-base=$docbase"
1910 func_append actioncmd " --aux-dir=$auxdir"
1911 for module in $avoidlist; do
1912 func_append actioncmd " --avoid=$module"
1914 if test -n "$lgpl"; then
1915 func_append actioncmd " --lgpl"
1917 if test -n "$makefile_name"; then
1918 func_append actioncmd " --makefile-name=$makefile_name"
1920 if test "$libtool" = true; then
1921 func_append actioncmd " --libtool"
1923 func_append actioncmd " --no-libtool"
1925 func_append actioncmd " --macro-prefix=$macro_prefix"
1926 func_append actioncmd " `echo $specified_modules`"
1928 # Default the makefile name to Makefile.am.
1929 if test -n "$makefile_name"; then
1930 makefile_am=$makefile_name
1932 makefile_am=Makefile.am
1935 # Create library makefile.
1936 func_dest_tmpfilename $sourcebase/$makefile_am
1937 func_emit_lib_Makefile_am > "$tmpfile"
1938 if test -f "$destdir"/$sourcebase/$makefile_am; then
1939 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
1943 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
1944 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
1945 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
1947 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
1953 echo "Creating $sourcebase/$makefile_am"
1954 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
1956 echo "Create $sourcebase/$makefile_am"
1961 # Create m4/gnulib-cache.m4.
1962 func_dest_tmpfilename $m4base/gnulib-cache.m4
1964 func_emit_copyright_notice
1966 echo "# This file represents the specification of how gnulib-tool is used."
1967 echo "# It acts as a cache: It is written and read by gnulib-tool."
1968 echo "# In projects using CVS, this file is meant to be stored in CVS,"
1969 echo "# like the configure.ac and various Makefile.am files."
1972 echo "# Specification in the form of a command-line invocation:"
1975 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
1976 # Store the local_gnulib_dir relative to destdir.
1977 case "$local_gnulib_dir" in
1979 relative_local_gnulib_dir="$local_gnulib_dir" ;;
1982 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
1984 # destdir, local_gnulib_dir are both relative.
1985 func_relativize "$destdir" "$local_gnulib_dir"
1986 relative_local_gnulib_dir="$reldir" ;;
1989 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
1990 echo "gl_MODULES(["`echo $specified_modules`"])"
1991 echo "gl_AVOID([$avoidlist])"
1992 echo "gl_SOURCE_BASE([$sourcebase])"
1993 echo "gl_M4_BASE([$m4base])"
1994 echo "gl_DOC_BASE([$docbase])"
1995 echo "gl_TESTS_BASE([$testsbase])"
1996 echo "gl_LIB([$libname])"
1997 test -z "$lgpl" || echo "gl_LGPL"
1998 echo "gl_MAKEFILE_NAME([$makefile_name])"
1999 if test "$libtool" = true; then
2002 echo "gl_MACRO_PREFIX([$macro_prefix])"
2004 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2005 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2009 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2010 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2011 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2013 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2017 echo "# gnulib-cache.m4 ends here"
2024 echo "Creating $m4base/gnulib-cache.m4"
2025 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2027 echo "Create $m4base/gnulib-cache.m4"
2033 # Create m4/gnulib-comp.m4.
2034 func_dest_tmpfilename $m4base/gnulib-comp.m4
2036 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2037 func_emit_copyright_notice
2039 echo "# This file represents the compiled summary of the specification in"
2040 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2041 echo "# to be invoked from configure.ac."
2042 echo "# In projects using CVS, this file can be treated like other built files."
2045 echo "# This macro should be invoked from $configure_ac, in the section"
2046 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2047 echo "# any checks for libraries, header files, types and library functions."
2048 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2050 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2051 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2052 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2053 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2054 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2055 if test -n "$uses_subdirs"; then
2056 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2058 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2059 echo " AC_REQUIRE([AC_GNU_SOURCE])"
2061 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2062 echo " AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])"
2064 if grep gl_LOCK "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2065 echo " AC_REQUIRE([gl_LOCK_EARLY])"
2069 echo "# This macro should be invoked from $configure_ac, in the section"
2070 echo "# \"Check for header files, types and library functions\"."
2071 echo "AC_DEFUN([${macro_prefix}_INIT],"
2073 func_emit_initmacro_start
2074 if test "$libtool" = true; then
2075 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2076 echo " gl_cond_libtool=true"
2078 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2079 echo " gl_cond_libtool=false"
2081 echo " gl_ltlibdeps="
2083 echo " gl_source_base='$sourcebase'"
2084 if test "$auxdir" != "build-aux"; then
2085 sed_replace_build_aux='
2087 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2088 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2091 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2093 sed_replace_build_aux=
2095 for module in $modules; do
2097 if test -n "$module"; then
2098 func_get_autoconf_snippet "$module" \
2099 | sed -e '/^$/d;' -e 's/^/ /' \
2100 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
2101 -e "$sed_replace_build_aux"
2102 if test "$module" = 'alloca' && test "$libtool" = true; then
2103 echo 'changequote(,)dnl'
2104 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
2105 echo 'changequote([, ])dnl'
2106 echo 'AC_SUBST([LTALLOCA])'
2110 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2111 # created using libtool, because libtool already handles the dependencies.
2112 if test "$libtool" != true; then
2113 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2114 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2115 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2116 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2117 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2119 func_emit_initmacro_end
2121 func_emit_initmacro_done
2123 echo "# This macro records the list of files which have been installed by"
2124 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
2125 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
2126 echo "$files" | sed -e 's,^, ,'
2129 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2130 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
2134 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2135 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
2136 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2138 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2142 echo "# gnulib-comp.m4 ends here"
2149 echo "Creating $m4base/gnulib-comp.m4"
2150 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2152 echo "Create $m4base/gnulib-comp.m4"
2158 if test -n "$inctests"; then
2159 # Create tests makefile.
2160 func_dest_tmpfilename $testsbase/$makefile_am
2161 func_emit_tests_Makefile_am > "$tmpfile"
2162 if test -f "$destdir"/$testsbase/$makefile_am; then
2163 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
2167 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2168 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
2169 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2171 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2177 echo "Creating $testsbase/$makefile_am"
2178 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2180 echo "Create $testsbase/$makefile_am"
2188 echo "You may need to add #include directives for the following .h files."
2189 # Intersect $specified_modules and $modules
2190 # (since $specified_modules is not necessarily of subset of $modules - some
2191 # may have been skipped through --avoid, and since the elements of $modules
2192 # but not in $specified_modules can go away without explicit notice - through
2193 # changes in the module dependencies).
2194 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
2195 echo "$modules" > "$tmp"/modules2 # also a sorted list, one module per line
2196 # First the #include <...> directives without #ifs, sorted for convenience,
2197 # then the #include "..." directives without #ifs, sorted for convenience,
2198 # then the #include directives that are surrounded by #ifs. Not sorted.
2199 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
2200 include_directive=`func_get_include_directive "$module"`
2201 case "$nl$include_directive" in
2203 echo "$include_directive" 1>&5
2206 echo "$include_directive" | grep -v 'include "' 1>&6
2207 echo "$include_directive" | grep 'include "' 1>&7
2210 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
2212 LC_ALL=C sort -u "$tmp"/include-angles
2213 LC_ALL=C sort -u "$tmp"/include-quotes
2214 cat "$tmp"/include-if
2215 ) | sed -e '/^$/d' -e 's/^/ /'
2216 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
2219 echo "Don't forget to"
2220 if test "$makefile_am" = Makefile.am; then
2221 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2223 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
2225 if test -n "$inctests"; then
2226 if test "$makefile_am" = Makefile.am; then
2227 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2229 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
2232 if test "$makefile_am" = Makefile.am; then
2233 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
2234 sourcebase_base=`basename "$sourcebase"`
2235 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
2237 if test -n "$inctests"; then
2238 if test "$makefile_am" = Makefile.am; then
2239 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
2240 testsbase_base=`basename "$testsbase"`
2241 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
2244 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
2245 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
2246 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
2249 # func_create_testdir testdir modules
2251 # - local_gnulib_dir from --local-dir
2252 # - auxdir directory relative to destdir where to place build aux files
2253 func_create_testdir ()
2257 if test -z "$modules"; then
2258 # All modules together.
2259 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2260 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2261 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
2262 modules=`func_all_modules`
2263 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
2265 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
2267 # Check that the license of every module is consistent with the license of
2269 saved_modules="$modules"
2270 for requested_module in $saved_modules; do
2271 requested_license=`func_get_license "$requested_module"`
2272 if test "$requested_license" != GPL; then
2273 # Here we use func_modules_transitive_closure, not just
2274 # func_get_dependencies, so that we also detect weird situations like
2275 # an LGPL module which depends on a GPLed build tool module which depends
2277 modules="$requested_module"
2278 func_modules_transitive_closure
2279 for module in $modules; do
2280 license=`func_get_license "$module"`
2282 LGPL | 'GPLed build tool') ;;
2283 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2284 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
2289 modules="$saved_modules"
2291 # Subdirectory names.
2298 # Determine final module list.
2299 func_modules_transitive_closure
2300 echo "Module list with included dependencies:"
2301 echo "$modules" | sed -e 's/^/ /'
2303 # Add the dummy module if needed.
2304 func_modules_add_dummy
2306 # Determine final file list.
2307 func_modules_to_filelist
2309 echo "$files" | sed -e 's/^/ /'
2311 sed_rewrite_files="\
2312 s,^build-aux/,$auxdir/,
2314 s,^lib/,$sourcebase/,
2316 s,^tests/,$testsbase/,"
2318 # Create directories.
2319 for f in $files; do echo $f; done \
2320 | sed -e "$sed_rewrite_files" \
2321 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2322 | LC_ALL=C sort -u \
2324 { # Rearrange file descriptors. Needed because "while ... done < ..."
2325 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2326 exec 5<&0 < "$tmp"/dirs
2328 mkdir -p "$testdir/$d"
2333 # Copy files or make symbolic links.
2335 for f in $files; do echo $f; done \
2336 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
2339 { # Rearrange file descriptors. Needed because "while ... done < ..."
2340 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2341 exec 5<&0 < "$tmp"/files
2343 func_lookup_file "$f"
2344 if test -n "$lookedup_tmp"; then
2345 cp -p "$lookedup_file" "$testdir/$g"
2347 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
2348 if { test -n "$symbolic" \
2349 || { test -n "$lsymbolic" \
2350 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
2351 func_ln "$lookedup_file" "$testdir/$g"
2353 cp -p "$lookedup_file" "$testdir/$g"
2360 # Create $sourcebase/Makefile.am.
2361 mkdir -p "$testdir/$sourcebase"
2362 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
2364 # Create $m4base/Makefile.am.
2365 mkdir -p "$testdir/$m4base"
2366 (echo "## Process this file with automake to produce Makefile.in."
2372 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
2375 ) > "$testdir/$m4base/Makefile.am"
2377 subdirs="$sourcebase $m4base"
2378 subdirs_with_configure_ac=""
2380 if false && test -f "$testdir"/$m4base/gettext.m4; then
2381 # Avoid stupid error message from automake:
2382 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
2383 mkdir -p "$testdir/po"
2384 (echo "## Process this file with automake to produce Makefile.in."
2385 ) > "$testdir/po/Makefile.am"
2386 func_append subdirs " po"
2389 if test -n "$inctests"; then
2390 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
2391 # Create $testsbase/Makefile.am.
2392 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
2393 # Create $testsbase/configure.ac.
2394 (echo "# Process this file with autoconf to produce a configure script."
2395 echo "AC_INIT([dummy], [0])"
2396 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
2397 echo "AM_INIT_AUTOMAKE"
2399 echo "AM_CONFIG_HEADER([config.h])"
2402 echo "AC_PROG_INSTALL"
2403 echo "AC_PROG_MAKE_SET"
2404 echo "AC_PROG_RANLIB"
2406 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2407 echo "AC_GNU_SOURCE"
2410 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2411 echo "gl_USE_SYSTEM_EXTENSIONS"
2414 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2415 echo "gl_LOCK_EARLY"
2418 if test "$libtool" = true; then
2419 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2420 echo "gl_cond_libtool=true"
2422 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2423 echo "gl_cond_libtool=false"
2425 echo "gl_ltlibdeps="
2427 # Wrap the set of autoconf snippets into an autoconf macro that is then
2428 # invoked. This is needed because autoconf does not support AC_REQUIRE
2430 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2431 # but we want the AC_REQUIRE to have its normal meaning (provide one
2432 # expansion of the required macro before the current point, and only one
2434 echo "AC_DEFUN([gl_INIT], ["
2435 func_emit_initmacro_start
2436 sed_replace_build_aux='
2438 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2439 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
2442 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2443 # We don't have explicit ordering constraints between the various
2444 # autoconf snippets. It's cleanest to put those of the library before
2445 # those of the tests.
2446 echo "gl_source_base='../$sourcebase'"
2447 for module in $modules; do
2448 func_verify_nontests_module
2449 if test -n "$module"; then
2450 func_get_autoconf_snippet "$module" \
2451 | sed -e "$sed_replace_build_aux"
2454 echo "gl_source_base='.'"
2455 for module in $modules; do
2456 func_verify_tests_module
2457 if test -n "$module"; then
2458 func_get_autoconf_snippet "$module" \
2459 | sed -e "$sed_replace_build_aux"
2462 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2463 # created using libtool, because libtool already handles the dependencies.
2464 if test "$libtool" != true; then
2465 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2466 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2467 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2468 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2469 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2471 func_emit_initmacro_end
2473 func_emit_initmacro_done
2477 # Usually $testsbase/config.h will be a superset of config.h. Verify this
2478 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
2479 echo "AH_TOP([#include \"../config.h\"])"
2481 echo "AC_OUTPUT([Makefile])"
2482 ) > "$testdir/$testsbase/configure.ac"
2483 func_append subdirs " $testsbase"
2484 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
2487 # Create Makefile.am.
2488 (echo "## Process this file with automake to produce Makefile.in."
2490 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2492 echo "SUBDIRS = $subdirs"
2494 echo "ACLOCAL_AMFLAGS = -I $m4base"
2495 ) > "$testdir/Makefile.am"
2497 # Create configure.ac.
2498 (echo "# Process this file with autoconf to produce a configure script."
2499 echo "AC_INIT([dummy], [0])"
2500 if test "$auxdir" != "."; then
2501 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2503 echo "AM_INIT_AUTOMAKE"
2505 echo "AM_CONFIG_HEADER([config.h])"
2508 echo "AC_PROG_INSTALL"
2509 echo "AC_PROG_MAKE_SET"
2511 echo "# For autobuild."
2512 echo "AC_CANONICAL_BUILD"
2513 echo "AC_CANONICAL_HOST"
2515 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2516 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2517 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2518 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2520 echo "AC_PROG_RANLIB"
2522 if test -n "$uses_subdirs"; then
2523 echo "AM_PROG_CC_C_O"
2526 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2527 echo "AC_GNU_SOURCE"
2530 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2531 echo "gl_USE_SYSTEM_EXTENSIONS"
2534 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2535 echo "gl_LOCK_EARLY"
2538 if test "$libtool" = true; then
2539 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2540 echo "gl_cond_libtool=true"
2542 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2543 echo "gl_cond_libtool=false"
2545 echo "gl_ltlibdeps="
2547 echo "gl_source_base='$sourcebase'"
2548 # Wrap the set of autoconf snippets into an autoconf macro that is then
2549 # invoked. This is needed because autoconf does not support AC_REQUIRE
2551 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2552 # but we want the AC_REQUIRE to have its normal meaning (provide one
2553 # expansion of the required macro before the current point, and only one
2555 echo "AC_DEFUN([gl_INIT], ["
2556 func_emit_initmacro_start
2557 if test "$auxdir" != "build-aux"; then
2558 sed_replace_build_aux='
2560 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2561 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2564 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2566 sed_replace_build_aux=
2568 for module in $modules; do
2569 func_verify_nontests_module
2570 if test -n "$module"; then
2571 func_get_autoconf_snippet "$module" \
2572 | sed -e "$sed_replace_build_aux"
2575 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2576 # created using libtool, because libtool already handles the dependencies.
2577 if test "$libtool" != true; then
2578 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2579 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2580 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2581 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2582 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2584 func_emit_initmacro_end
2586 func_emit_initmacro_done
2590 if test -n "$subdirs_with_configure_ac"; then
2591 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
2593 makefiles="Makefile"
2594 for d in $subdirs; do
2595 # For subdirs that have a configure.ac by their own, it's the subdir's
2596 # configure.ac which creates the subdir's Makefile.am, not this one.
2597 case " $subdirs_with_configure_ac " in
2599 *) func_append makefiles " $d/Makefile" ;;
2602 echo "AC_OUTPUT([$makefiles])"
2603 ) > "$testdir/configure.ac"
2605 # Create autogenerated files.
2607 # Do not use "${AUTORECONF} --force --install", because it may invoke
2608 # autopoint, which brings in older versions of some of our .m4 files.
2609 if test -f $m4base/gettext.m4; then
2610 echo "executing ${AUTOPOINT} --force"
2611 ${AUTOPOINT} --force || func_exit 1
2612 for f in $m4base/*.m4~; do
2613 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2616 echo "executing ${ACLOCAL} -I $m4base"
2617 ${ACLOCAL} -I $m4base || func_exit 1
2618 if ! test -d build-aux; then
2619 echo "executing mkdir build-aux"
2620 mkdir build-aux || func_exit 1
2622 echo "executing ${AUTOCONF}"
2623 ${AUTOCONF} || func_exit 1
2624 echo "executing ${AUTOHEADER}"
2625 ${AUTOHEADER} || func_exit 1
2626 echo "executing ${AUTOMAKE} --add-missing --copy"
2627 ${AUTOMAKE} --add-missing --copy || func_exit 1
2629 if test -n "$inctests"; then
2630 # Create autogenerated files.
2631 (cd "$testdir/$testsbase" || func_exit 1
2632 # Do not use "${AUTORECONF} --force --install", because it may invoke
2633 # autopoint, which brings in older versions of some of our .m4 files.
2634 if test -f ../$m4base/gettext.m4; then
2635 echo "executing ${AUTOPOINT} --force"
2636 ${AUTOPOINT} --force || func_exit 1
2637 for f in ../$m4base/*.m4~; do
2638 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2641 echo "executing ${ACLOCAL} -I ../$m4base"
2642 ${ACLOCAL} -I ../$m4base || func_exit 1
2643 if ! test -d ../build-aux; then
2644 echo "executing mkdir ../build-aux"
2647 echo "executing ${AUTOCONF}"
2648 ${AUTOCONF} || func_exit 1
2649 echo "executing ${AUTOHEADER}"
2650 ${AUTOHEADER} || func_exit 1
2651 echo "executing ${AUTOMAKE} --add-missing --copy"
2652 ${AUTOMAKE} --add-missing --copy || func_exit 1
2655 if grep '^BUILT_SOURCES *+=' "$testdir/$sourcebase/Makefile.am" > /dev/null; then
2657 ./configure || func_exit 1
2659 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
2660 make built_sources || func_exit 1
2662 make distclean || func_exit 1
2667 # func_create_megatestdir megatestdir allmodules
2669 # - local_gnulib_dir from --local-dir
2670 # - auxdir directory relative to destdir where to place build aux files
2671 func_create_megatestdir ()
2675 if test -z "$allmodules"; then
2676 allmodules=`func_all_modules`
2680 # First, all modules one by one.
2681 for onemodule in $allmodules; do
2682 func_create_testdir "$megatestdir/$onemodule" $onemodule
2683 func_append megasubdirs "$onemodule "
2685 # Then, all modules all together.
2686 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2687 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2688 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
2689 func_create_testdir "$megatestdir/ALL" "$allmodules"
2690 func_append megasubdirs "ALL"
2692 # Create Makefile.am.
2693 (echo "## Process this file with automake to produce Makefile.in."
2695 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2697 echo "SUBDIRS = $megasubdirs"
2698 ) > "$megatestdir/Makefile.am"
2700 # Create configure.ac.
2701 (echo "# Process this file with autoconf to produce a configure script."
2702 echo "AC_INIT([dummy], [0])"
2703 if test "$auxdir" != "."; then
2704 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2706 echo "AM_INIT_AUTOMAKE"
2708 echo "AC_PROG_MAKE_SET"
2710 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
2711 echo "AC_OUTPUT([Makefile])"
2712 ) > "$megatestdir/configure.ac"
2714 # Create autogenerated files.
2716 # Do not use "${AUTORECONF} --install", because autoreconf operates
2717 # recursively, but the subdirectories are already finished, therefore
2718 # calling autoreconf here would only waste lots of CPU time.
2719 echo "executing ${ACLOCAL}"
2720 ${ACLOCAL} || func_exit 1
2721 echo "executing mkdir build-aux"
2723 echo "executing ${AUTOCONF}"
2724 ${AUTOCONF} || func_exit 1
2725 echo "executing ${AUTOMAKE} --add-missing --copy"
2726 ${AUTOMAKE} --add-missing --copy || func_exit 1
2732 func_fatal_error "no mode specified" ;;
2741 if test -z "$destdir"; then
2744 test -d "$destdir" \
2745 || func_fatal_error "destination directory does not exist: $destdir"
2747 # Prefer configure.ac to configure.in.
2748 if test -f "$destdir"/configure.ac; then
2749 configure_ac="$destdir/configure.ac"
2751 if test -f "$destdir"/configure.in; then
2752 configure_ac="$destdir/configure.in"
2754 func_fatal_error "cannot find $destdir/configure.ac"
2758 # Analyze configure.ac.
2760 guessed_libtool=false
2765 /AC_CONFIG_AUX_DIR/ {
2766 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
2768 /A[CM]_PROG_LIBTOOL/ {
2769 s,^.*$,guessed_libtool=true,p
2771 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
2773 if test -z "$auxdir"; then
2774 auxdir="$guessed_auxdir"
2777 # Determine where to apply func_import.
2778 if test -n "$m4base"; then
2779 # Apply func_import to a particular gnulib directory.
2780 # Any number of additional modules can be given.
2781 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
2782 # First use of gnulib in the given m4base.
2783 test -n "$supplied_libname" || supplied_libname=true
2784 test -n "$sourcebase" || sourcebase="lib"
2785 test -n "$docbase" || docbase="doc"
2786 test -n "$testsbase" || testsbase="tests"
2787 test -n "$macro_prefix" || macro_prefix="gl"
2791 # Apply func_import to all gnulib directories.
2792 # To get this list of directories, look at Makefile.am. (Not at
2793 # configure, because it may be omitted from CVS. Also, don't run
2794 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
2797 if test -f "$destdir"/Makefile.am; then
2798 aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$destdir"/Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'`
2800 for arg in $aclocal_amflags; do
2801 if test -n "$m4dir_is_next"; then
2802 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
2806 if test -f "$destdir/$arg"/gnulib-cache.m4; then
2807 func_append m4dirs " $arg"
2808 m4dirs_count=`expr $m4dirs_count + 1`
2813 if test "X$arg" = "X-I"; then
2821 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
2822 if test -f "$destdir"/aclocal.m4; then
2823 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
2824 sedexpr2='s,^[^/]*$,.,'
2825 sedexpr3='s,/[^/]*$,,'
2826 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
2827 m4dirs_count=`echo "$m4dirs" | wc -l`
2830 if test $m4dirs_count = 0; then
2831 # First use of gnulib in a package.
2832 # Any number of additional modules can be given.
2833 test -n "$supplied_libname" || supplied_libname=true
2834 test -n "$sourcebase" || sourcebase="lib"
2836 test -n "$docbase" || docbase="doc"
2837 test -n "$testsbase" || testsbase="tests"
2838 test -n "$macro_prefix" || macro_prefix="gl"
2841 if test $m4dirs_count = 1; then
2842 # There's only one use of gnulib here. Assume the user means it.
2843 # Any number of additional modules can be given.
2844 for m4base in $m4dirs; do
2848 # Ambiguous - guess what the user meant.
2849 if test $# = 0; then
2850 # No further arguments. Guess the user wants to update all of them.
2851 for m4base in $m4dirs; do
2852 # Perform func_import in a subshell, so that variable values
2854 # local_gnulib_dir, avoidlist, sourcebase, m4base, docbase,
2855 # testsbase, libname, lgpl, makefile_name, libtool, macro_prefix
2856 # don't propagate from one directory to another.
2857 (func_import) || func_exit 1
2861 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
2869 if test -z "$destdir"; then
2870 func_fatal_error "please specify --dir option"
2873 test -d "$destdir" \
2874 || func_fatal_error "could not create destination directory"
2875 test -n "$auxdir" || auxdir="build-aux"
2876 func_create_testdir "$destdir" "$*"
2879 create-megatestdir )
2880 if test -z "$destdir"; then
2881 func_fatal_error "please specify --dir option"
2883 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2884 test -n "$auxdir" || auxdir="build-aux"
2885 func_create_megatestdir "$destdir" "$*"
2889 test -n "$destdir" || destdir=testdir$$
2890 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2891 test -n "$auxdir" || auxdir="build-aux"
2892 func_create_testdir "$destdir" "$*"
2896 ../configure || func_exit 1
2898 make check || func_exit 1
2899 make distclean || func_exit 1
2900 remaining=`find . -type f -print`
2901 if test -n "$remaining"; then
2902 echo "Remaining files:" $remaining 1>&2
2903 echo "gnulib-tool: *** Stop." 1>&2
2912 test -n "$destdir" || destdir=testdir$$
2913 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2914 test -n "$auxdir" || auxdir="build-aux"
2915 func_create_megatestdir "$destdir" "$*"
2923 remaining=`find . -type f -print`
2924 if test -n "$remaining"; then
2925 echo "Remaining files:" $remaining 1>&2
2926 echo "gnulib-tool: *** Stop." 1>&2
2934 extract-description )
2938 if test -n "$module"; then
2939 func_get_description "$module"
2948 if test -n "$module"; then
2949 func_get_filelist "$module"
2954 extract-dependencies )
2958 if test -n "$module"; then
2959 func_get_dependencies "$module"
2964 extract-autoconf-snippet )
2968 if test -n "$module"; then
2969 func_get_autoconf_snippet "$module"
2974 extract-automake-snippet )
2978 if test -n "$module"; then
2979 func_get_automake_snippet "$module"
2984 extract-include-directive )
2988 if test -n "$module"; then
2989 func_get_include_directive "$module"
2998 if test -n "$module"; then
2999 func_get_license "$module"
3004 extract-maintainer )
3008 if test -n "$module"; then
3009 func_get_maintainer "$module"
3014 extract-tests-module )
3018 if test -n "$module"; then
3019 func_get_tests_module "$module"
3025 func_fatal_error "unknown operation mode --$mode" ;;
3029 # Undo the effect of the previous 'trap' command. Some shellology:
3030 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
3031 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
3032 # exit); for the others we need to call 'exit' explicitly. The value of $? is
3033 # 128 + signal number and is set before the trap-registered command is run.
3035 trap 'func_exit $?' 1 2 3 13 15
3040 # indent-tabs-mode: nil
3041 # whitespace-check-buffer-indent: nil