3 # Copyright (C) 2002-2006 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: 2006-12-26 01:51:36 $'
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 # GNU sort is needed. Set SORT to its location (not needed if it's called
70 # 'sort' and already in the PATH).
71 if test -z "$SORT"; then
75 # When using GNU sed, turn off as many GNU extensions as possible,
76 # to minimize the risk of accidentally using non-portable features.
77 # However, do this only for gnulib-tool itself, not for the code that
78 # gnulib-tool generates, since we don't want "sed --posix" to leak
80 if (alias) > /dev/null 2>&1 && echo | sed --posix d >/dev/null 2>&1; then
81 alias sed='sed --posix'
85 # outputs to stdout the --help usage message.
89 Usage: gnulib-tool --list
90 gnulib-tool --import [module1 ... moduleN]
92 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
93 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
94 gnulib-tool --test --dir=directory module1 ... moduleN
95 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
96 gnulib-tool --extract-description module
97 gnulib-tool --extract-filelist module
98 gnulib-tool --extract-dependencies module
99 gnulib-tool --extract-autoconf-snippet module
100 gnulib-tool --extract-automake-snippet module
101 gnulib-tool --extract-include-directive module
102 gnulib-tool --extract-license module
103 gnulib-tool --extract-maintainer module
104 gnulib-tool --extract-tests-module module
107 --list print the available module names
108 --import import the given modules into the current package;
109 if no modules are specified, update the current
110 package from the current gnulib
111 --update update the current package, restore files omitted
113 --create-testdir create a scratch package with the given modules
114 --create-megatestdir create a mega scratch package with the given modules
115 one by one and all together
116 --test test the combination of the given modules
117 (recommended to use CC=\"gcc -Wall\" here)
118 --megatest test the given modules one by one and all together
119 (recommended to use CC=\"gcc -Wall\" here)
120 --extract-description extract the description
121 --extract-filelist extract the list of files
122 --extract-dependencies extract the dependencies
123 --extract-autoconf-snippet extract the snippet for configure.ac
124 --extract-automake-snippet extract the snippet for library makefile
125 --extract-include-directive extract the #include directive
126 --extract-license report the license terms of the source files
128 --extract-maintainer report the maintainer(s) inside gnulib
129 --extract-tests-module report the unit test module, if it exists
132 --dir=DIRECTORY Specify the target directory.
133 For --import, this specifies where your
134 configure.ac can be found. Defaults to current
136 --local-dir=DIRECTORY Specify a local override directory where to look
137 up files before looking in gnulib's directory.
139 Options for --import:
140 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
141 --source-base=DIRECTORY
142 Directory relative to --dir where source code is
143 placed (default \"lib\").
144 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
145 placed (default \"m4\").
146 --doc-base=DIRECTORY Directory relative to --dir where doc files are
147 placed (default \"doc\").
148 --tests-base=DIRECTORY
149 Directory relative to --dir where unit tests are
150 placed (default \"tests\").
151 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
152 tools are placed (default \"build-aux\").
153 --with-tests Include unit tests for the included modules.
154 --avoid=MODULE Avoid including the given MODULE. Useful if you
155 have code that provides equivalent functionality.
156 This option can be repeated.
157 --lgpl Abort if modules aren't available under the LGPL.
158 Also modify license template from GPL to LGPL.
159 --makefile-name=NAME Name of makefile in automake syntax in the
160 source-base and tests-base directories
161 (default \"Makefile.am\").
162 --libtool Use libtool rules.
163 --no-libtool Don't use libtool rules.
164 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
165 'gl_INIT'. Default is 'gl'.
166 --no-changelog don't update or create ChangeLog files
168 Options for --import and --update:
169 --dry-run For --import, only print what would have been done.
170 -s, --symbolic, --symlink Make symbolic links instead of copying files.
171 --local-symlink Make symbolic links instead of copying files, only
172 for files from the local override directory.
174 Report bugs to <bug-gnulib@gnu.org>."
178 # outputs to stdout the --version message.
181 year=`echo "$last_checkin_date" | sed -e 's,/.*$,,'`
183 $progname (GNU $package) $version
184 Copyright (C) $year Free Software Foundation, Inc.
185 This is free software; see the source for copying conditions. There is NO
186 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
187 Written by" "Bruno Haible" "and" "Simon Josefsson"
190 # func_emit_copyright_notice
191 # outputs to stdout a header for a generated file.
192 func_emit_copyright_notice ()
194 echo "# Copyright (C) 2004-2006 Free Software Foundation, Inc."
196 echo "# This file is free software, distributed under the terms of the GNU"
197 echo "# General Public License. As a special exception to the GNU General"
198 echo "# Public License, this file may be distributed as part of a program"
199 echo "# that contains a configuration script generated by Autoconf, under"
200 echo "# the same distribution terms as the rest of that program."
202 echo "# Generated by gnulib-tool."
213 # creates a temporary directory.
215 # - tmp pathname of freshly created temporary directory
218 # Use the environment variable TMPDIR, falling back to /tmp. This allows
219 # users to specify a different temporary directory, for example, if their
220 # /tmp is filled up or too small.
223 # Use the mktemp program if available. If not available, hide the error
225 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
226 test -n "$tmp" && test -d "$tmp"
229 # Use a simple mkdir command. It is guaranteed to fail if the directory
230 # already exists. $RANDOM is bash specific and expands to empty in shells
231 # other than bash, ksh and zsh. Its use does not increase security;
232 # rather, it minimizes the probability of failure in a very cluttered /tmp
234 tmp=$TMPDIR/gl$$-$RANDOM
235 (umask 077 && mkdir "$tmp")
238 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
243 # func_append var value
244 # appends the given value to the shell variable var.
245 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
246 # Use bash's += operator. It reduces complexity of appending repeatedly to
247 # a single variable from O(n^2) to O(n).
255 eval "$1=\"\$$1\$2\""
259 # func_fatal_error message
260 # outputs to stderr a fatal error message, and terminates the program.
263 echo "gnulib-tool: *** $1" 1>&2
264 echo "gnulib-tool: *** Stop." 1>&2
268 # func_readlink SYMLINK
269 # outputs the target of the given symlink.
270 if (type -p readlink) > /dev/null 2>&1; then
273 # Use the readlink program from GNU coreutils.
279 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
280 # would do the wrong thing if the link target contains " -> ".
281 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
285 # func_relativize DIR1 DIR2
286 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
288 # - DIR1 relative pathname, relative to the current directory
289 # - DIR2 relative pathname, relative to the current directory
291 # - reldir relative pathname of DIR2, relative to DIR1
297 sed_first='s,^\([^/]*\)/.*$,\1,'
298 sed_rest='s,^[^/]*/*,,'
299 sed_last='s,^.*/\([^/]*\)$,\1,'
300 sed_butlast='s,/*[^/]*$,,'
301 while test -n "$dir1"; do
302 first=`echo "$dir1" | sed -e "$sed_first"`
303 if test "$first" != "."; then
304 if test "$first" = ".."; then
305 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
306 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
308 first2=`echo "$dir2" | sed -e "$sed_first"`
309 if test "$first2" = "$first"; then
310 dir2=`echo "$dir2" | sed -e "$sed_rest"`
314 dir0="$dir0"/"$first"
317 dir1=`echo "$dir1" | sed -e "$sed_rest"`
322 # func_relconcat DIR1 DIR2
323 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
325 # - DIR1 relative pathname, relative to the current directory
326 # - DIR2 relative pathname, relative to DIR1
328 # - relconcat DIR1/DIR2, relative to the current directory
333 sed_first='s,^\([^/]*\)/.*$,\1,'
334 sed_rest='s,^[^/]*/*,,'
335 sed_last='s,^.*/\([^/]*\)$,\1,'
336 sed_butlast='s,/*[^/]*$,,'
338 first=`echo "$dir2" | sed -e "$sed_first"`
339 if test "$first" = "."; then
340 dir2=`echo "$dir2" | sed -e "$sed_rest"`
341 if test -z "$dir2"; then
346 last=`echo "$dir1" | sed -e "$sed_last"`
347 while test "$last" = "."; do
348 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
349 last=`echo "$dir1" | sed -e "$sed_last"`
351 if test -z "$dir1"; then
355 if test "$first" = ".."; then
356 if test "$last" = ".."; then
357 relconcat="$dir1/$dir2"
360 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
361 dir2=`echo "$dir2" | sed -e "$sed_rest"`
362 if test -z "$dir1"; then
366 if test -z "$dir2"; then
371 relconcat="$dir1/$dir2"
379 # Like ln -s, except that SRC is given relative to the current directory (or
380 # absolute), not given relative to the directory of DEST.
386 *) # SRC is relative.
389 ln -s "`pwd`/$1" "$2" ;;
390 *) # DEST is relative too.
391 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
392 test -n "$ln_destdir" || ln_destdir="."
393 func_relativize "$ln_destdir" "$1"
401 # func_ln_if_changed SRC DEST
402 # Like func_ln, but avoids munging timestamps if the link is correct.
403 func_ln_if_changed ()
405 if test $# -ne 2; then
406 echo "usage: func_ln_if_changed SRC DEST" >&2
408 ln_target=`func_readlink "$2"`
409 if test -L "$2" && test "$1" = "$ln_target"; then
417 # Command-line option processing.
418 # Removes the OPTIONS from the arguments. Sets the variables:
419 # - mode list or import or create-testdir or create-megatestdir
420 # - destdir from --dir
421 # - local_gnulib_dir from --local-dir
422 # - libname, supplied_libname from --lib
423 # - sourcebase from --source-base
424 # - m4base from --m4-base
425 # - docbase from --doc-base
426 # - testsbase from --tests-base
427 # - auxdir from --aux-dir
428 # - inctests true if --with-tests was given, blank otherwise
429 # - avoidlist list of modules to avoid, from --avoid
430 # - lgpl true if --lgpl was given, blank otherwise
431 # - makefile_name from --makefile-name
432 # - libtool true if --libtool was given, false if --no-libtool was
433 # given, blank otherwise
434 # - macro_prefix from --macro-prefix
435 # - autoconf_minversion minimum supported autoconf version
436 # - do_changelog false if --no-changelog was given, : otherwise
437 # - doit : if actions shall be executed, false if only to be printed
438 # - symbolic true if --symlink was given, blank otherwise
439 # - lsymbolic true if --local-symlink was given, blank otherwise
464 while test $# -gt 0; do
469 --import | --impor | --impo | --imp | --im | --i )
472 --update | --updat | --upda | --upd | --up | --u )
475 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
478 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
479 mode=create-megatestdir
481 --test | --tes | --te | --t )
484 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
488 mode=`echo "X$1" | sed -e 's/^X--//'`
493 func_fatal_error "missing argument for --dir"
498 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
503 func_fatal_error "missing argument for --local-dir"
508 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
513 func_fatal_error "missing argument for --lib"
516 supplied_libname=true
519 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
520 supplied_libname=true
525 func_fatal_error "missing argument for --source-base"
530 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
535 func_fatal_error "missing argument for --m4-base"
540 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
545 func_fatal_error "missing argument for --doc-base"
550 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
555 func_fatal_error "missing argument for --tests-base"
560 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
565 func_fatal_error "missing argument for --aux-dir"
570 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
578 func_fatal_error "missing argument for --avoid"
580 func_append avoidlist " $1"
583 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
584 func_append avoidlist " $arg"
592 func_fatal_error "missing argument for --makefile-name"
597 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
608 func_fatal_error "missing argument for --macro-prefix"
613 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
615 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
621 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
624 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
627 --help | --hel | --he | --h )
630 --version | --versio | --versi | --vers | --ver | --ve | --v )
634 # Stop option processing
638 echo "gnulib-tool: unknown option $1" 1>&2
639 echo "Try 'gnulib-tool --help' for more information." 1>&2
646 if test "$mode" = update; then
647 if test $# != 0; then
648 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
649 echo "Try 'gnulib-tool --help' for more information." 1>&2
650 echo "If you really want to modify the gnulib configuration of your project," 1>&2
651 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
654 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
655 || test -n "$sourcebase" || test -n "$m4base" \
656 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
657 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
658 || test -n "$makefile_name" || test -n "$macro_prefix"; then
659 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
660 echo "Try 'gnulib-tool --help' for more information." 1>&2
661 echo "If you really want to modify the gnulib configuration of your project," 1>&2
662 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
668 # Determine the minimum supported autoconf version from the project's
670 DEFAULT_AUTOCONF_MINVERSION="2.59"
673 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
674 if test -f "$destdir"/configure.ac; then
675 configure_ac="$destdir/configure.ac"
677 if test -f "$destdir"/configure.in; then
678 configure_ac="$destdir/configure.in"
682 if test -f configure.ac; then
683 configure_ac="configure.ac"
685 if test -f configure.in; then
686 configure_ac="configure.in"
690 if test -n "$configure_ac"; then
691 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
692 # because when some m4 files are omitted from a CVS repository,
693 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
694 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
695 # autom4te: m4 failed with exit status: 1
702 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,prereqs="$prereqs \1",p
704 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
705 if test -n "$prereqs"; then
706 autoconf_minversion=`for version in $prereqs; do echo $version; done | $SORT -g -u | tail -1`
709 if test -z "$autoconf_minversion"; then
710 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
712 case "$autoconf_minversion" in
713 1.* | 2.[0-4]* | 2.5[0-8]*)
714 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
717 # Remove trailing slashes from the directory names. This is necessary for
718 # m4base (to avoid an error in func_import) and optional for the others.
719 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
720 case "$local_gnulib_dir" in
721 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
723 case "$sourcebase" in
724 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
727 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
730 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
733 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
736 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
741 /*) self_abspathname="$0" ;;
742 */*) self_abspathname=`pwd`/"$0" ;;
743 *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
744 if test -x "$d/$0" && test ! -d "$d/$0"; then
745 self_abspathname="$d/$0"
749 if test -z "$self_abspathname"; then
750 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
754 while test -h "$self_abspathname"; do
755 # Resolve symbolic link.
756 linkval=`func_readlink "$self_abspathname"`
757 test -n "$linkval" || break
759 /* ) self_abspathname="$linkval" ;;
760 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
763 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
767 if test "$signal" != 0; then
768 echo "caught signal $signal" >&2
772 for signal in 1 2 3 13 15; do
773 trap '{ signal='$signal'; func_exit 1; }' $signal
777 # func_lookup_file file
778 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
781 # - local_gnulib_dir from --local-dir
783 # - lookedup_file name of the merged (combined) file
784 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
788 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
789 lookedup_file="$local_gnulib_dir/$lkfile"
792 if test -f "$gnulib_dir/$lkfile"; then
793 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
794 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
796 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
797 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
798 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
799 lookedup_file="$tmp/$lkbase"
802 lookedup_file="$gnulib_dir/$lkfile"
806 func_fatal_error "file $gnulib_dir/$lkfile not found"
813 # - local_gnulib_dir from --local-dir
816 # Filter out metainformation files like README, which are not modules.
817 # Filter out unit test modules; they can be retrieved through
818 # --extract-tests-module if desired.
820 (cd "$gnulib_dir/modules" && ls -1)
821 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
822 (cd "$local_gnulib_dir/modules" && ls -1 | sed -e 's,\.diff$,,')
825 | sed -e '/^CVS$/d' -e '/^ChangeLog$/d' -e '/^COPYING$/d' -e '/^README$/d' -e '/^TEMPLATE$/d' -e '/^TEMPLATE-TESTS$/d' -e '/~$/d' \
826 | sed -e '/-tests$/d' \
831 # verifies a module name
833 # - local_gnulib_dir from --local-dir
834 # - module module name argument
835 func_verify_module ()
837 if { test -f "$gnulib_dir/modules/$module" \
838 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
839 && test -f "$local_gnulib_dir/modules/$module"; }; } \
840 && test "CVS" != "$module" \
841 && test "ChangeLog" != "$module" \
842 && test "COPYING" != "$module" \
843 && test "README" != "$module" \
844 && test "TEMPLATE" != "$module" \
845 && test "TEMPLATE-TESTS" != "$module"; then
846 # OK, $module is a correct module name.
847 # Verify that building the module description with 'patch' succeeds.
848 func_lookup_file "modules/$module"
850 echo "gnulib-tool: module $module doesn't exist" 1>&2
855 # func_verify_nontests_module
856 # verifies a module name, excluding tests modules
858 # - local_gnulib_dir from --local-dir
859 # - module module name argument
860 func_verify_nontests_module ()
864 * ) func_verify_module ;;
868 # func_verify_tests_module
869 # verifies a module name, considering only tests modules
871 # - local_gnulib_dir from --local-dir
872 # - module module name argument
873 func_verify_tests_module ()
876 *-tests ) func_verify_module ;;
881 sed_extract_prog=':[ ]*$/ {
884 s/^Description:[ ]*$//
886 s/^Depends-on:[ ]*$//
887 s/^configure\.ac:[ ]*$//
888 s/^Makefile\.am:[ ]*$//
891 s/^Maintainer:[ ]*$//
898 # func_get_description module
900 # - local_gnulib_dir from --local-dir
901 func_get_description ()
903 func_lookup_file "modules/$1"
904 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
907 # func_get_filelist module
909 # - local_gnulib_dir from --local-dir
912 func_lookup_file "modules/$1"
913 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
914 case "$autoconf_minversion" in
917 echo m4/onceonly_2_57.m4
922 # func_get_dependencies module
924 # - local_gnulib_dir from --local-dir
925 func_get_dependencies ()
927 # ${module}-tests always implicitly depends on ${module}.
928 echo "$1" | sed -n -e 's/-tests//p'
929 # Then the explicit dependencies listed in the module description.
930 func_lookup_file "modules/$1"
931 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
934 # func_get_autoconf_snippet module
936 # - local_gnulib_dir from --local-dir
937 func_get_autoconf_snippet ()
939 func_lookup_file "modules/$1"
940 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
943 # func_get_automake_snippet module
945 # - local_gnulib_dir from --local-dir
946 func_get_automake_snippet ()
948 func_lookup_file "modules/$1"
949 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
952 # *-tests module live in tests/, not lib/.
955 # Synthesize an EXTRA_DIST augmentation.
956 sed_combine_lines='/\\$/{
963 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
964 already_mentioned_files=` \
965 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
966 | sed -e "$sed_combine_lines" \
967 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
968 all_files=`func_get_filelist $1`
969 lib_files=`for f in $all_files; do \
973 done | sed -e 's,^lib/,,'`
974 # Remove $already_mentioned_files from $lib_files.
975 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
976 extra_files=`for f in $already_mentioned_files; do echo $f; done \
977 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
978 if test -n "$extra_files"; then
979 echo "EXTRA_DIST +=" $extra_files
982 # Synthesize also an EXTRA_lib_SOURCES augmentation.
983 # This is necessary so that automake can generate the right list of
985 # A possible approach would be to use autom4te --trace of the redefined
986 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
987 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
988 # inside autoconf's built-in macros are not missed).
989 # But it's simpler and more robust to do it here, based on the file list.
990 # If some .c file exists and is not used with AC_LIBOBJ - for example,
991 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
992 # automake will generate a useless dependency; this is harmless.
993 sed_extract_c_files='/\.c$/p'
994 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
995 if test -n "$extra_files"; then
996 echo "EXTRA_lib_SOURCES +=" $extra_files
1003 # func_get_include_directive module
1005 # - local_gnulib_dir from --local-dir
1006 func_get_include_directive ()
1008 func_lookup_file "modules/$1"
1009 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1010 sed -e 's/^\(["<]\)/#include \1/'
1013 # func_get_license module
1015 # - local_gnulib_dir from --local-dir
1018 func_lookup_file "modules/$1"
1019 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1022 # func_get_maintainer module
1024 # - local_gnulib_dir from --local-dir
1025 func_get_maintainer ()
1027 func_lookup_file "modules/$1"
1028 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1031 # func_get_tests_module module
1033 # - local_gnulib_dir from --local-dir
1034 func_get_tests_module ()
1036 # The naming convention for tests modules is hardwired: ${module}-tests.
1037 if test -f "$gnulib_dir/modules/$1"-tests \
1038 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1039 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1044 # func_acceptable module
1045 # tests whether a module is acceptable.
1047 # - avoidlist list of modules to avoid
1050 for avoid in $avoidlist; do
1051 if test "$avoid" = "$1"; then
1058 # func_modules_transitive_closure
1060 # - local_gnulib_dir from --local-dir
1061 # - modules list of specified modules
1062 # - inctests true if tests should be included, blank otherwise
1063 # - avoidlist list of modules to avoid
1064 # - tmp pathname of a temporary directory
1066 # - modules list of modules, including dependencies
1067 func_modules_transitive_closure ()
1069 # In order to process every module only once (for speed), process an "input
1070 # list" of modules, producing an "output list" of modules. During each round,
1071 # more modules can be queued in the input list. Once a module on the input
1072 # list has been processed, it is added to the "handled list", so we can avoid
1073 # to process it again.
1075 inmodules="$modules"
1077 while test -n "$inmodules"; do
1078 inmodules_this_round="$inmodules"
1079 inmodules= # Accumulator, queue for next round
1080 for module in $inmodules_this_round; do
1082 if test -n "$module"; then
1083 if func_acceptable $module; then
1084 func_append outmodules " $module"
1085 deps=`func_get_dependencies $module`
1086 # Duplicate dependencies are harmless, but Jim wants a warning.
1087 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1088 if test -n "$duplicated_deps"; then
1089 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1091 func_append inmodules " $deps"
1092 if test -n "$inctests"; then
1093 testsmodule=`func_get_tests_module $module`
1094 if test -n "$testsmodule"; then
1095 func_append inmodules " $testsmodule"
1101 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1102 # Remove $handledmodules from $inmodules.
1103 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1104 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1106 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1107 rm -f "$tmp"/queued-modules
1110 # func_modules_add_dummy
1112 # - local_gnulib_dir from --local-dir
1113 # - modules list of modules, including dependencies
1115 # - modules list of modules, including 'dummy' if needed
1116 func_modules_add_dummy ()
1119 sed_remove_backslash_newline=':a
1126 for module in $modules; do
1127 func_verify_nontests_module
1128 if test -n "$module"; then
1129 # Extract the value of "lib_SOURCES += ...".
1130 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1131 # Ignore .h files since they are not compiled.
1134 *) have_lib_SOURCES=yes ;;
1139 # Add the dummy module, to make sure the library will be non-empty.
1140 if test -z "$have_lib_SOURCES"; then
1141 func_append modules " dummy"
1145 # func_modules_to_filelist
1147 # - local_gnulib_dir from --local-dir
1148 # - modules list of modules, including dependencies
1150 # - files list of files
1151 func_modules_to_filelist ()
1154 for module in $modules; do
1156 if test -n "$module"; then
1157 fs=`func_get_filelist $module`
1158 func_append files " $fs"
1161 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1164 # func_emit_lib_Makefile_am
1165 # emits the contents of library makefile to standard output.
1167 # - local_gnulib_dir from --local-dir
1168 # - modules list of modules, including dependencies
1169 # - libname library name
1170 # - auxdir directory relative to destdir where to place build aux files
1171 # - makefile_name from --makefile-name
1172 # - libtool true if libtool will be used, false or blank otherwise
1173 # - macro_prefix prefix of gl_LIBOBJS macros to use
1174 # - actioncmd (optional) command that will reproduce this invocation
1176 # - uses_subdirs nonempty if object files in subdirs exist
1177 func_emit_lib_Makefile_am ()
1179 # When creating an includable Makefile.am snippet, augment variables with
1180 # += instead of assigning them.
1181 if test -n "$makefile_name"; then
1186 if test "$libtool" = true; then
1189 sed_eliminate_LDFLAGS=
1193 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1195 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1196 echo "## Process this file with automake to produce Makefile.in."
1197 func_emit_copyright_notice
1198 if test -n "$actioncmd"; then
1199 echo "# Reproduce by: $actioncmd"
1204 for module in $modules; do
1205 func_verify_nontests_module
1206 if test -n "$module"; then
1208 func_get_automake_snippet "$module" |
1209 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1210 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1211 sed -e "$sed_eliminate_LDFLAGS" |
1212 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1213 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1214 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
1215 if test "$module" = 'alloca'; then
1216 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1217 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1220 # Skip the contents if its entirely empty.
1221 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1222 echo "## begin gnulib module $module"
1225 echo "## end gnulib module $module"
1229 # Test whether there are some source files in subdirectories.
1230 for f in `func_get_filelist "$module"`; do
1232 lib/*/*.c) uses_subdirs=yes ;;
1238 if test -z "$makefile_name"; then
1239 # If there are source files in subdirectories, prevent collision of the
1240 # object files (example: hash.c and libxml/hash.c).
1242 if test -n "$uses_subdirs"; then
1243 subdir_options=' subdir-objects'
1245 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1248 if test -z "$makefile_name"; then
1249 echo "noinst_HEADERS ="
1250 echo "noinst_LIBRARIES ="
1251 echo "noinst_LTLIBRARIES ="
1252 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1253 # if you specify pkgdata_DATA to empty. This is a workaround.
1254 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1255 echo "pkgdata_DATA ="
1258 echo "BUILT_SOURCES ="
1261 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1262 if test -z "$makefile_name"; then
1263 echo "MOSTLYCLEANDIRS ="
1265 echo "DISTCLEANFILES ="
1266 echo "MAINTAINERCLEANFILES ="
1268 echo "AM_CPPFLAGS ="
1271 if grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1272 # One of the snippets already specifies an installation location for the
1273 # library. Don't confuse automake by saying it should not be installed.
1276 # By default, the generated library should not be installed.
1277 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1280 echo "${libname}_${libext}_SOURCES ="
1281 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1282 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1283 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1284 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1285 echo "EXTRA_${libname}_${libext}_SOURCES ="
1286 if test "$libtool" = true; then
1287 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1290 cat allsnippets.tmp \
1291 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1293 echo "mostlyclean-local: mostlyclean-generic"
1294 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1295 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1296 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1299 rm -f allsnippets.tmp
1302 # func_emit_tests_Makefile_am
1303 # emits the contents of tests makefile to standard output.
1305 # - local_gnulib_dir from --local-dir
1306 # - modules list of modules, including dependencies
1307 # - libname library name
1308 # - makefile_name from --makefile-name
1309 # - libtool true if libtool will be used, false or blank otherwise
1310 # - sourcebase relative directory containing lib source code
1311 # - m4base relative directory containing autoconf macros
1312 # - testsbase relative directory containing unit test code
1313 func_emit_tests_Makefile_am ()
1315 if test "$libtool" = true; then
1320 if test "$libtool" = true; then
1322 sed_eliminate_LDFLAGS=
1325 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1327 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1328 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1329 echo "## Process this file with automake to produce Makefile.in."
1330 func_emit_copyright_notice
1332 # Generate dependencies here, since it eases the debugging of test failures.
1333 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1335 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1338 for module in $modules; do
1339 func_verify_tests_module
1340 if test -n "$module"; then
1342 func_get_automake_snippet "$module" |
1343 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1344 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1345 sed -e "$sed_eliminate_LDFLAGS" |
1346 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1347 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1348 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
1350 # Skip the contents if its entirely empty.
1351 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1352 echo "## begin gnulib module $module"
1355 echo "## end gnulib module $module"
1362 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1363 # variable is needed to avoid an error from automake:
1364 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1367 echo "TESTS_ENVIRONMENT ="
1368 echo "noinst_PROGRAMS ="
1369 echo "check_PROGRAMS ="
1370 echo "noinst_HEADERS ="
1371 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1372 echo "pkgdata_DATA ="
1375 echo "BUILT_SOURCES ="
1377 echo "MOSTLYCLEANFILES = core *.stackdump"
1378 echo "MOSTLYCLEANDIRS ="
1380 echo "DISTCLEANFILES ="
1381 echo "MAINTAINERCLEANFILES ="
1383 echo "AM_CPPFLAGS = \\"
1384 echo " -I. -I\$(srcdir) \\"
1385 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1386 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1388 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1391 echo "# Clean up after Solaris cc."
1393 echo " rm -rf SunWS_cache"
1395 echo "mostlyclean-local: mostlyclean-generic"
1396 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1397 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1398 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1401 rm -f allsnippets.tmp
1404 # func_emit_initmacro_start
1405 # emits the first few statements of the gl_INIT macro to standard output.
1406 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1407 func_emit_initmacro_start ()
1409 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
1410 # platform-dependent object files in ${macro_prefix}_LIBOBJS instead of
1411 # LIBOBJS. The purpose is to allow several gnulib instantiations under
1412 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
1414 # Furthermore it avoids an automake error like this when a Makefile.am
1415 # that uses pieces of gnulib also uses $(LIBOBJ):
1416 # automatically discovered file `error.c' should not be explicitly mentioned
1417 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix}_LIBOBJ]))"
1418 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix}_REPLACE_FUNCS]))"
1419 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
1420 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
1421 # automatically discovered file `error.c' should not be explicitly mentioned
1422 # We let automake know about the files to be distributed through the
1423 # EXTRA_lib_SOURCES variable.
1424 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix}_LIBSOURCES]))"
1427 # func_emit_initmacro_end
1428 # emits the last few statements of the gl_INIT macro to standard output.
1429 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1430 func_emit_initmacro_end ()
1432 echo " m4_popdef([AC_LIBSOURCES])"
1433 echo " m4_popdef([AC_REPLACE_FUNCS])"
1434 echo " m4_popdef([AC_LIBOBJ])"
1435 echo " AC_CONFIG_COMMANDS_PRE(["
1436 echo " ${macro_prefix}_libobjs="
1437 echo " ${macro_prefix}_ltlibobjs="
1438 echo " if test -n \"\$${macro_prefix}_LIBOBJS\"; then"
1439 echo " # Remove the extension."
1440 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
1441 echo " for i in \`for i in \$${macro_prefix}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
1442 echo " ${macro_prefix}_libobjs=\"\$${macro_prefix}_libobjs \$i.\$ac_objext\""
1443 echo " ${macro_prefix}_ltlibobjs=\"\$${macro_prefix}_ltlibobjs \$i.lo\""
1446 echo " AC_SUBST([${macro_prefix}_LIBOBJS], [\$${macro_prefix}_libobjs])"
1447 echo " AC_SUBST([${macro_prefix}_LTLIBOBJS], [\$${macro_prefix}_ltlibobjs])"
1451 # func_emit_initmacro_done
1452 # emits a few statements after the gl_INIT macro to standard output.
1453 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1454 func_emit_initmacro_done ()
1457 echo "# Like AC_LIBOBJ, except that the module name goes"
1458 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1459 echo "AC_DEFUN([${macro_prefix}_LIBOBJ],"
1460 echo " [${macro_prefix}_LIBOBJS=\"\$${macro_prefix}_LIBOBJS \$1.\$ac_objext\"])"
1462 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
1463 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1464 echo "AC_DEFUN([${macro_prefix}_REPLACE_FUNCS],"
1465 echo " [AC_CHECK_FUNCS([\$1], , [${macro_prefix}_LIBOBJ(\$ac_func)])])"
1467 echo "# Like AC_LIBSOURCES, except that it does nothing."
1468 echo "# We rely on EXTRA_lib..._SOURCES instead."
1469 echo "AC_DEFUN([${macro_prefix}_LIBSOURCES],"
1473 # func_import modules
1474 # Uses also the variables
1475 # - destdir target directory
1476 # - local_gnulib_dir from --local-dir
1477 # - libname library name
1478 # - sourcebase directory relative to destdir where to place source code
1479 # - m4base directory relative to destdir where to place *.m4 macros
1480 # - docbase directory relative to destdir where to place doc files
1481 # - testsbase directory relative to destdir where to place unit test code
1482 # - auxdir directory relative to destdir where to place build aux files
1483 # - inctests true if --with-tests was given, blank otherwise
1484 # - avoidlist list of modules to avoid, from --avoid
1485 # - lgpl true if library's license shall be LGPL, blank otherwise
1486 # - makefile_name from --makefile-name
1487 # - libtool true if --libtool was given, false if --no-libtool was
1488 # given, blank otherwise
1489 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1490 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1491 # - autoconf_minversion minimum supported autoconf version
1492 # - doit : if actions shall be executed, false if only to be printed
1493 # - symbolic true if files should be symlinked, copied otherwise
1494 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1498 # Get the cached settings.
1499 cached_local_gnulib_dir=
1500 cached_specified_modules=
1508 cached_makefile_name=
1510 cached_macro_prefix=
1512 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1513 cached_libtool=false
1519 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
1522 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1525 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1528 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1531 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1534 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1537 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1540 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1543 s,^.*$,cached_lgpl=true,p
1545 /gl_MAKEFILE_NAME(/ {
1546 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
1549 s,^.*$,cached_libtool=true,p
1551 /gl_MACRO_PREFIX(/ {
1552 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
1554 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
1555 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1560 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
1561 s,^.*$,cached_files=",p
1573 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1577 # Merge the cached settings with the specified ones.
1578 # The m4base must be the same as expected from the pathname.
1579 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1580 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1582 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
1583 # is relative to $destdir, whereas the one we use is relative to . or absolute.
1584 if test -z "$local_gnulib_dir"; then
1585 if test -n "$cached_local_gnulib_dir"; then
1588 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1590 case "$cached_local_gnulib_dir" in
1592 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1594 func_relconcat "$destdir" "$cached_local_gnulib_dir"
1595 local_gnulib_dir="$relconcat" ;;
1600 # Append the cached and the specified module names. So that
1601 # "gnulib-tool --import foo" means to add the module foo.
1602 specified_modules="$cached_specified_modules $1"
1603 # Append the cached and the specified avoidlist. This is probably better
1604 # than dropping the cached one when --avoid is specified at least once.
1605 avoidlist=`echo $cached_avoidlist $avoidlist`
1606 # The sourcebase defaults to the cached one.
1607 if test -z "$sourcebase"; then
1608 sourcebase="$cached_sourcebase"
1609 if test -z "$sourcebase"; then
1610 func_fatal_error "missing --source-base option"
1613 # The docbase defaults to the cached one.
1614 if test -z "$docbase"; then
1615 docbase="$cached_docbase"
1616 if test -z "$docbase"; then
1617 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."
1620 # The testsbase defaults to the cached one.
1621 if test -z "$testsbase"; then
1622 testsbase="$cached_testsbase"
1623 if test -z "$testsbase"; then
1624 func_fatal_error "missing --tests-base option"
1627 # The libname defaults to the cached one.
1628 if test -z "$supplied_libname"; then
1629 libname="$cached_libname"
1630 if test -z "$libname"; then
1631 func_fatal_error "missing --lib option"
1634 # Require LGPL if specified either way.
1635 if test -z "$lgpl"; then
1638 # The makefile_name defaults to the cached one.
1639 if test -z "$makefile_name"; then
1640 makefile_name="$cached_makefile_name"
1642 # Use libtool if specified either way, or if guessed.
1643 if test -z "$libtool"; then
1644 if test -n "$cached_m4base"; then
1645 libtool="$cached_libtool"
1647 libtool="$guessed_libtool"
1650 # The macro_prefix defaults to the cached one.
1651 if test -z "$macro_prefix"; then
1652 macro_prefix="$cached_macro_prefix"
1653 if test -z "$macro_prefix"; then
1654 func_fatal_error "missing --macro-prefix option"
1658 # Canonicalize the list of specified modules.
1659 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
1661 # Determine final module list.
1662 modules="$specified_modules"
1663 func_modules_transitive_closure
1664 echo "Module list with included dependencies:"
1665 echo "$modules" | sed -e 's/^/ /'
1667 # Add the dummy module if needed.
1668 func_modules_add_dummy
1670 # If --lgpl, verify that the licenses of modules are compatible.
1671 if test -n "$lgpl"; then
1672 for module in $modules; do
1673 license=`func_get_license $module`
1675 LGPL | 'GPLed build tool') ;;
1676 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
1677 *) func_fatal_error "incompatible license on module $module: $license" ;;
1682 # Determine script to apply to imported library files.
1683 sed_transform_lib_file=
1684 for module in $modules; do
1685 if test $module = config-h; then
1686 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
1687 sed_transform_lib_file=$sed_transform_lib_file'
1688 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
1693 if test -n "$lgpl"; then
1695 sed_transform_lib_file=$sed_transform_lib_file'
1696 s/GNU General/GNU Lesser General/g
1697 s/version 2\([ ,]\)/version 2.1\1/g
1701 # Determine final file list.
1702 func_modules_to_filelist
1704 echo "$files" | sed -e 's/^/ /'
1707 || func_fatal_error "refusing to do nothing"
1709 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
1710 new_files="$files m4/gnulib-tool.m4"
1711 old_files="$cached_files"
1712 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
1713 func_append old_files " m4/gnulib-tool.m4"
1716 sed_rewrite_old_files="\
1717 s,^build-aux/,$auxdir/,
1718 s,^doc/,$cached_docbase/,
1719 s,^lib/,$cached_sourcebase/,
1720 s,^m4/,$cached_m4base/,
1721 s,^tests/,$cached_testsbase/,"
1722 sed_rewrite_new_files="\
1723 s,^build-aux/,$auxdir/,
1725 s,^lib/,$sourcebase/,
1727 s,^tests/,$testsbase/,"
1729 # Create directories.
1730 { echo "$sourcebase"
1732 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
1733 if test -n "$docfiles"; then
1736 if test -n "$inctests"; then
1740 for f in $files; do echo $f; done \
1741 | sed -e "$sed_rewrite_new_files" \
1742 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
1745 { # Rearrange file descriptors. Needed because "while ... done < ..."
1746 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1747 exec 5<&0 < "$tmp"/dirs
1749 if test ! -d "$destdir/$d"; then
1751 echo "Creating directory $destdir/$d"
1752 mkdir -p "$destdir/$d" || func_fatal_error "failed"
1754 echo "Create directory $destdir/$d"
1761 # func_dest_tmpfilename file
1762 # determines the name of a temporary file (file is relative to destdir).
1764 # - tmpfile absolute filename of the temporary file
1765 func_dest_tmpfilename ()
1768 # Put the new contents of $file in a file in the same directory (needed
1769 # to guarantee that an 'mv' to "$destdir/$file" works).
1770 tmpfile="$destdir/$1.tmp"
1772 # Put the new contents of $file in a file in a temporary directory
1773 # (because the directory of "$file" might not exist).
1774 tmpfile="$tmp"/`basename "$1"`.tmp
1778 # Copy files or make symbolic links. Remove obsolete files.
1780 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1781 # representing the files according to the last gnulib-tool invocation.
1782 for f in $old_files; do echo $f; done \
1783 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
1786 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1787 # representing the files after this gnulib-tool invocation.
1788 for f in $new_files; do echo $f; done \
1789 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
1792 # First the files that are in old-files, but not in new-files:
1793 sed_take_first_column='s,'"$delimiter"'.*,,'
1794 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
1795 # Remove the file. Do nothing if the user already removed it.
1796 if test -f "$destdir/$g"; then
1798 echo "Removing file $g (backup in ${g}~)"
1799 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1801 echo "Remove file $g (backup in ${g}~)"
1805 # func_add_or_update handles a file that ought to be present afterwards.
1807 # - f the original file name
1808 # - g the rewritten file name
1809 # - already_present nonempty if the file already exists, empty otherwise
1810 func_add_or_update ()
1812 func_dest_tmpfilename "$g"
1813 func_lookup_file "$f"
1814 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
1815 if test -n "$sed_transform_lib_file"; then
1818 sed -e "$sed_transform_lib_file" \
1819 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
1823 if test -f "$destdir/$g"; then
1824 # The file already exists.
1825 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1826 : # The file has not changed.
1830 if test -n "$already_present"; then
1831 echo "Updating file $g (backup in ${g}~)"
1833 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
1835 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1836 if { test -n "$symbolic" \
1837 || { test -n "$lsymbolic" \
1838 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1839 && test -z "$lookedup_tmp" \
1840 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1841 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1843 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1846 if test -n "$already_present"; then
1847 echo "Update file $g (backup in ${g}~)"
1849 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
1855 # Don't protest if the file should be there but isn't: it happens
1856 # frequently that developers don't put autogenerated files into CVS.
1858 echo "Copying file $g"
1859 if { test -n "$symbolic" \
1860 || { test -n "$lsymbolic" \
1861 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1862 && test -z "$lookedup_tmp" \
1863 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1864 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1866 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1874 # Then the files that are in new-files, but not in old-files:
1875 sed_take_last_column='s,^.*'"$delimiter"',,'
1877 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
1878 | sed -e "$sed_take_last_column" \
1879 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
1880 { # Rearrange file descriptors. Needed because "while ... done < ..."
1881 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1882 exec 5<&0 < "$tmp"/added-files
1888 # Then the files that are in new-files and in old-files:
1889 already_present=true
1890 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
1891 | sed -e "$sed_take_last_column" \
1892 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
1893 { # Rearrange file descriptors. Needed because "while ... done < ..."
1894 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1895 exec 5<&0 < "$tmp"/kept-files
1902 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
1903 actioncmd="gnulib-tool --import"
1904 func_append actioncmd " --dir=$destdir"
1905 if test -n "$local_gnulib_dir"; then
1906 func_append actioncmd " --local-dir=$local_gnulib_dir"
1908 func_append actioncmd " --lib=$libname"
1909 func_append actioncmd " --source-base=$sourcebase"
1910 func_append actioncmd " --m4-base=$m4base"
1911 func_append actioncmd " --doc-base=$docbase"
1912 func_append actioncmd " --aux-dir=$auxdir"
1913 for module in $avoidlist; do
1914 func_append actioncmd " --avoid=$module"
1916 if test -n "$lgpl"; then
1917 func_append actioncmd " --lgpl"
1919 if test -n "$makefile_name"; then
1920 func_append actioncmd " --makefile-name=$makefile_name"
1922 if test "$libtool" = true; then
1923 func_append actioncmd " --libtool"
1925 func_append actioncmd " --no-libtool"
1927 func_append actioncmd " --macro-prefix=$macro_prefix"
1928 func_append actioncmd " `echo $specified_modules`"
1930 # Default the makefile name to Makefile.am.
1931 if test -n "$makefile_name"; then
1932 makefile_am=$makefile_name
1934 makefile_am=Makefile.am
1937 # Create library makefile.
1938 func_dest_tmpfilename $sourcebase/$makefile_am
1939 func_emit_lib_Makefile_am > "$tmpfile"
1940 if test -f "$destdir"/$sourcebase/$makefile_am; then
1941 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
1945 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
1946 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
1947 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
1949 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
1955 echo "Creating $sourcebase/$makefile_am"
1956 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
1958 echo "Create $sourcebase/$makefile_am"
1963 # Create m4/gnulib-cache.m4.
1964 func_dest_tmpfilename $m4base/gnulib-cache.m4
1966 func_emit_copyright_notice
1968 echo "# This file represents the specification of how gnulib-tool is used."
1969 echo "# It acts as a cache: It is written and read by gnulib-tool."
1970 echo "# In projects using CVS, this file is meant to be stored in CVS,"
1971 echo "# like the configure.ac and various Makefile.am files."
1974 echo "# Specification in the form of a command-line invocation:"
1977 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
1978 # Store the local_gnulib_dir relative to destdir.
1979 case "$local_gnulib_dir" in
1981 relative_local_gnulib_dir="$local_gnulib_dir" ;;
1984 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
1986 # destdir, local_gnulib_dir are both relative.
1987 func_relativize "$destdir" "$local_gnulib_dir"
1988 relative_local_gnulib_dir="$reldir" ;;
1991 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
1992 echo "gl_MODULES(["`echo $specified_modules`"])"
1993 echo "gl_AVOID([$avoidlist])"
1994 echo "gl_SOURCE_BASE([$sourcebase])"
1995 echo "gl_M4_BASE([$m4base])"
1996 echo "gl_DOC_BASE([$docbase])"
1997 echo "gl_TESTS_BASE([$testsbase])"
1998 echo "gl_LIB([$libname])"
1999 test -z "$lgpl" || echo "gl_LGPL"
2000 echo "gl_MAKEFILE_NAME([$makefile_name])"
2001 if test "$libtool" = true; then
2004 echo "gl_MACRO_PREFIX([$macro_prefix])"
2006 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2007 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2011 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2012 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2013 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2015 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2019 echo "# gnulib-cache.m4 ends here"
2026 echo "Creating $m4base/gnulib-cache.m4"
2027 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2029 echo "Create $m4base/gnulib-cache.m4"
2035 # Create m4/gnulib-comp.m4.
2036 func_dest_tmpfilename $m4base/gnulib-comp.m4
2038 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2039 func_emit_copyright_notice
2041 echo "# This file represents the compiled summary of the specification in"
2042 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2043 echo "# to be invoked from configure.ac."
2044 echo "# In projects using CVS, this file can be treated like other built files."
2047 echo "# This macro should be invoked from $configure_ac, in the section"
2048 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2049 echo "# any checks for libraries, header files, types and library functions."
2050 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2052 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2053 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2054 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2055 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2056 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2057 if test -n "$uses_subdirs"; then
2058 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2060 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2061 echo " AC_REQUIRE([AC_GNU_SOURCE])"
2063 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2064 echo " AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])"
2066 if grep gl_LOCK "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2067 echo " AC_REQUIRE([gl_LOCK_EARLY])"
2071 echo "# This macro should be invoked from $configure_ac, in the section"
2072 echo "# \"Check for header files, types and library functions\"."
2073 echo "AC_DEFUN([${macro_prefix}_INIT],"
2075 func_emit_initmacro_start
2076 if test "$libtool" = true; then
2077 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2078 echo " gl_cond_libtool=true"
2080 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2081 echo " gl_cond_libtool=false"
2083 echo " gl_ltlibdeps="
2085 echo " gl_source_base='$sourcebase'"
2086 if test "$auxdir" != "build-aux"; then
2087 sed_replace_build_aux='
2089 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2090 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2093 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2095 sed_replace_build_aux=
2097 for module in $modules; do
2099 if test -n "$module"; then
2100 func_get_autoconf_snippet "$module" \
2101 | sed -e '/^$/d;' -e 's/^/ /' \
2102 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
2103 -e "$sed_replace_build_aux"
2104 if test "$module" = 'alloca' && test "$libtool" = true; then
2105 echo 'changequote(,)dnl'
2106 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
2107 echo 'changequote([, ])dnl'
2108 echo 'AC_SUBST([LTALLOCA])'
2112 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2113 # created using libtool, because libtool already handles the dependencies.
2114 if test "$libtool" != true; then
2115 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2116 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2117 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2118 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2119 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2121 func_emit_initmacro_end
2123 func_emit_initmacro_done
2125 echo "# This macro records the list of files which have been installed by"
2126 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
2127 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
2128 echo "$files" | sed -e 's,^, ,'
2131 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2132 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
2136 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2137 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
2138 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2140 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2144 echo "# gnulib-comp.m4 ends here"
2151 echo "Creating $m4base/gnulib-comp.m4"
2152 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2154 echo "Create $m4base/gnulib-comp.m4"
2160 if test -n "$inctests"; then
2161 # Create tests makefile.
2162 func_dest_tmpfilename $testsbase/$makefile_am
2163 func_emit_tests_Makefile_am > "$tmpfile"
2164 if test -f "$destdir"/$testsbase/$makefile_am; then
2165 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
2169 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2170 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
2171 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2173 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2179 echo "Creating $testsbase/$makefile_am"
2180 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2182 echo "Create $testsbase/$makefile_am"
2190 echo "You may need to add #include directives for the following .h files."
2191 # Intersect $specified_modules and $modules
2192 # (since $specified_modules is not necessarily of subset of $modules - some
2193 # may have been skipped through --avoid, and since the elements of $modules
2194 # but not in $specified_modules can go away without explicit notice - through
2195 # changes in the module dependencies).
2196 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
2197 echo "$modules" > "$tmp"/modules2 # also a sorted list, one module per line
2198 # First the #include <...> directives without #ifs, sorted for convenience,
2199 # then the #include "..." directives without #ifs, sorted for convenience,
2200 # then the #include directives that are surrounded by #ifs. Not sorted.
2201 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
2202 include_directive=`func_get_include_directive "$module"`
2203 case "$nl$include_directive" in
2205 echo "$include_directive" 1>&5
2208 echo "$include_directive" | grep -v 'include "' 1>&6
2209 echo "$include_directive" | grep 'include "' 1>&7
2212 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
2214 LC_ALL=C sort -u "$tmp"/include-angles
2215 LC_ALL=C sort -u "$tmp"/include-quotes
2216 cat "$tmp"/include-if
2217 ) | sed -e '/^$/d' -e 's/^/ /'
2218 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
2221 echo "Don't forget to"
2222 if test "$makefile_am" = Makefile.am; then
2223 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2225 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
2227 if test -n "$inctests"; then
2228 if test "$makefile_am" = Makefile.am; then
2229 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2231 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
2234 if test "$makefile_am" = Makefile.am; then
2235 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
2236 sourcebase_base=`basename "$sourcebase"`
2237 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
2239 if test -n "$inctests"; then
2240 if test "$makefile_am" = Makefile.am; then
2241 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
2242 testsbase_base=`basename "$testsbase"`
2243 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
2246 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
2247 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
2248 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
2251 # func_create_testdir testdir modules
2253 # - local_gnulib_dir from --local-dir
2254 # - auxdir directory relative to destdir where to place build aux files
2255 func_create_testdir ()
2259 if test -z "$modules"; then
2260 # All modules together.
2261 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2262 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2263 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
2264 modules=`func_all_modules`
2265 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
2267 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
2269 # Check that the license of every module is consistent with the license of
2271 saved_modules="$modules"
2272 for requested_module in $saved_modules; do
2273 requested_license=`func_get_license "$requested_module"`
2274 if test "$requested_license" != GPL; then
2275 # Here we use func_modules_transitive_closure, not just
2276 # func_get_dependencies, so that we also detect weird situations like
2277 # an LGPL module which depends on a GPLed build tool module which depends
2279 modules="$requested_module"
2280 func_modules_transitive_closure
2281 for module in $modules; do
2282 license=`func_get_license "$module"`
2284 LGPL | 'GPLed build tool') ;;
2285 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2286 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
2291 modules="$saved_modules"
2293 # Subdirectory names.
2300 # Determine final module list.
2301 func_modules_transitive_closure
2302 echo "Module list with included dependencies:"
2303 echo "$modules" | sed -e 's/^/ /'
2305 # Add the dummy module if needed.
2306 func_modules_add_dummy
2308 # Determine final file list.
2309 func_modules_to_filelist
2311 echo "$files" | sed -e 's/^/ /'
2313 sed_rewrite_files="\
2314 s,^build-aux/,$auxdir/,
2316 s,^lib/,$sourcebase/,
2318 s,^tests/,$testsbase/,"
2320 # Create directories.
2321 for f in $files; do echo $f; done \
2322 | sed -e "$sed_rewrite_files" \
2323 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2324 | LC_ALL=C sort -u \
2326 { # Rearrange file descriptors. Needed because "while ... done < ..."
2327 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2328 exec 5<&0 < "$tmp"/dirs
2330 mkdir -p "$testdir/$d"
2335 # Copy files or make symbolic links.
2337 for f in $files; do echo $f; done \
2338 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
2341 { # Rearrange file descriptors. Needed because "while ... done < ..."
2342 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2343 exec 5<&0 < "$tmp"/files
2345 func_lookup_file "$f"
2346 if test -n "$lookedup_tmp"; then
2347 cp -p "$lookedup_file" "$testdir/$g"
2349 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
2350 if { test -n "$symbolic" \
2351 || { test -n "$lsymbolic" \
2352 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
2353 func_ln "$lookedup_file" "$testdir/$g"
2355 cp -p "$lookedup_file" "$testdir/$g"
2362 # Create $sourcebase/Makefile.am.
2363 mkdir -p "$testdir/$sourcebase"
2364 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
2366 # Create $m4base/Makefile.am.
2367 mkdir -p "$testdir/$m4base"
2368 (echo "## Process this file with automake to produce Makefile.in."
2374 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
2377 ) > "$testdir/$m4base/Makefile.am"
2379 subdirs="$sourcebase $m4base"
2380 subdirs_with_configure_ac=""
2382 if false && test -f "$testdir"/$m4base/gettext.m4; then
2383 # Avoid stupid error message from automake:
2384 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
2385 mkdir -p "$testdir/po"
2386 (echo "## Process this file with automake to produce Makefile.in."
2387 ) > "$testdir/po/Makefile.am"
2388 func_append subdirs " po"
2391 if test -n "$inctests"; then
2392 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
2393 # Create $testsbase/Makefile.am.
2394 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
2395 # Create $testsbase/configure.ac.
2396 (echo "# Process this file with autoconf to produce a configure script."
2397 echo "AC_INIT([dummy], [0])"
2398 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
2399 echo "AM_INIT_AUTOMAKE"
2401 echo "AM_CONFIG_HEADER([config.h])"
2404 echo "AC_PROG_INSTALL"
2405 echo "AC_PROG_MAKE_SET"
2406 echo "AC_PROG_RANLIB"
2408 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2409 echo "AC_GNU_SOURCE"
2412 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2413 echo "gl_USE_SYSTEM_EXTENSIONS"
2416 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2417 echo "gl_LOCK_EARLY"
2420 if test "$libtool" = true; then
2421 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2422 echo "gl_cond_libtool=true"
2424 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2425 echo "gl_cond_libtool=false"
2427 echo "gl_ltlibdeps="
2429 # Wrap the set of autoconf snippets into an autoconf macro that is then
2430 # invoked. This is needed because autoconf does not support AC_REQUIRE
2432 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2433 # but we want the AC_REQUIRE to have its normal meaning (provide one
2434 # expansion of the required macro before the current point, and only one
2436 echo "AC_DEFUN([gl_INIT], ["
2437 func_emit_initmacro_start
2438 sed_replace_build_aux='
2440 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2441 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
2444 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2445 # We don't have explicit ordering constraints between the various
2446 # autoconf snippets. It's cleanest to put those of the library before
2447 # those of the tests.
2448 echo "gl_source_base='../$sourcebase'"
2449 for module in $modules; do
2450 func_verify_nontests_module
2451 if test -n "$module"; then
2452 func_get_autoconf_snippet "$module" \
2453 | sed -e "$sed_replace_build_aux"
2456 echo "gl_source_base='.'"
2457 for module in $modules; do
2458 func_verify_tests_module
2459 if test -n "$module"; then
2460 func_get_autoconf_snippet "$module" \
2461 | sed -e "$sed_replace_build_aux"
2464 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2465 # created using libtool, because libtool already handles the dependencies.
2466 if test "$libtool" != true; then
2467 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2468 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2469 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2470 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2471 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2473 func_emit_initmacro_end
2475 func_emit_initmacro_done
2479 # Usually $testsbase/config.h will be a superset of config.h. Verify this
2480 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
2481 echo "AH_TOP([#include \"../config.h\"])"
2483 echo "AC_OUTPUT([Makefile])"
2484 ) > "$testdir/$testsbase/configure.ac"
2485 func_append subdirs " $testsbase"
2486 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
2489 # Create Makefile.am.
2490 (echo "## Process this file with automake to produce Makefile.in."
2492 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2494 echo "SUBDIRS = $subdirs"
2496 echo "ACLOCAL_AMFLAGS = -I $m4base"
2497 ) > "$testdir/Makefile.am"
2499 # Create configure.ac.
2500 (echo "# Process this file with autoconf to produce a configure script."
2501 echo "AC_INIT([dummy], [0])"
2502 if test "$auxdir" != "."; then
2503 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2505 echo "AM_INIT_AUTOMAKE"
2507 echo "AM_CONFIG_HEADER([config.h])"
2510 echo "AC_PROG_INSTALL"
2511 echo "AC_PROG_MAKE_SET"
2513 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2514 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2515 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2516 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2518 echo "AC_PROG_RANLIB"
2520 if test -n "$uses_subdirs"; then
2521 echo "AM_PROG_CC_C_O"
2524 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2525 echo "AC_GNU_SOURCE"
2528 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2529 echo "gl_USE_SYSTEM_EXTENSIONS"
2532 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2533 echo "gl_LOCK_EARLY"
2536 if test "$libtool" = true; then
2537 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2538 echo "gl_cond_libtool=true"
2540 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2541 echo "gl_cond_libtool=false"
2543 echo "gl_ltlibdeps="
2545 echo "gl_source_base='$sourcebase'"
2546 # Wrap the set of autoconf snippets into an autoconf macro that is then
2547 # invoked. This is needed because autoconf does not support AC_REQUIRE
2549 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2550 # but we want the AC_REQUIRE to have its normal meaning (provide one
2551 # expansion of the required macro before the current point, and only one
2553 echo "AC_DEFUN([gl_INIT], ["
2554 func_emit_initmacro_start
2555 if test "$auxdir" != "build-aux"; then
2556 sed_replace_build_aux='
2558 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2559 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2562 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2564 sed_replace_build_aux=
2566 for module in $modules; do
2567 func_verify_nontests_module
2568 if test -n "$module"; then
2569 func_get_autoconf_snippet "$module" \
2570 | sed -e "$sed_replace_build_aux"
2573 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2574 # created using libtool, because libtool already handles the dependencies.
2575 if test "$libtool" != true; then
2576 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2577 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2578 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2579 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2580 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2582 func_emit_initmacro_end
2584 func_emit_initmacro_done
2588 if test -n "$subdirs_with_configure_ac"; then
2589 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
2591 makefiles="Makefile"
2592 for d in $subdirs; do
2593 # For subdirs that have a configure.ac by their own, it's the subdir's
2594 # configure.ac which creates the subdir's Makefile.am, not this one.
2595 case " $subdirs_with_configure_ac " in
2597 *) func_append makefiles " $d/Makefile" ;;
2600 echo "AC_OUTPUT([$makefiles])"
2601 ) > "$testdir/configure.ac"
2603 # Create autogenerated files.
2605 # Do not use "${AUTORECONF} --force --install", because it may invoke
2606 # autopoint, which brings in older versions of some of our .m4 files.
2607 if test -f $m4base/gettext.m4; then
2608 echo "executing ${AUTOPOINT} --force"
2609 ${AUTOPOINT} --force || func_exit 1
2610 for f in $m4base/*.m4~; do
2611 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2614 echo "executing ${ACLOCAL} -I $m4base"
2615 ${ACLOCAL} -I $m4base || func_exit 1
2616 if ! test -d build-aux; then
2617 echo "executing mkdir build-aux"
2618 mkdir build-aux || func_exit 1
2620 echo "executing ${AUTOCONF}"
2621 ${AUTOCONF} || func_exit 1
2622 echo "executing ${AUTOHEADER}"
2623 ${AUTOHEADER} || func_exit 1
2624 echo "executing ${AUTOMAKE} --add-missing --copy"
2625 ${AUTOMAKE} --add-missing --copy || func_exit 1
2627 if test -n "$inctests"; then
2628 # Create autogenerated files.
2629 (cd "$testdir/$testsbase" || func_exit 1
2630 # Do not use "${AUTORECONF} --force --install", because it may invoke
2631 # autopoint, which brings in older versions of some of our .m4 files.
2632 if test -f ../$m4base/gettext.m4; then
2633 echo "executing ${AUTOPOINT} --force"
2634 ${AUTOPOINT} --force || func_exit 1
2635 for f in ../$m4base/*.m4~; do
2636 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2639 echo "executing ${ACLOCAL} -I ../$m4base"
2640 ${ACLOCAL} -I ../$m4base || func_exit 1
2641 if ! test -d ../build-aux; then
2642 echo "executing mkdir ../build-aux"
2645 echo "executing ${AUTOCONF}"
2646 ${AUTOCONF} || func_exit 1
2647 echo "executing ${AUTOHEADER}"
2648 ${AUTOHEADER} || func_exit 1
2649 echo "executing ${AUTOMAKE} --add-missing --copy"
2650 ${AUTOMAKE} --add-missing --copy || func_exit 1
2653 if grep '^BUILT_SOURCES *+=' "$testdir/$sourcebase/Makefile.am" > /dev/null; then
2655 ./configure || func_exit 1
2657 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
2658 make built_sources || func_exit 1
2660 make distclean || func_exit 1
2665 # func_create_megatestdir megatestdir allmodules
2667 # - local_gnulib_dir from --local-dir
2668 # - auxdir directory relative to destdir where to place build aux files
2669 func_create_megatestdir ()
2673 if test -z "$allmodules"; then
2674 allmodules=`func_all_modules`
2678 # First, all modules one by one.
2679 for onemodule in $allmodules; do
2680 func_create_testdir "$megatestdir/$onemodule" $onemodule
2681 func_append megasubdirs "$onemodule "
2683 # Then, all modules all together.
2684 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2685 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2686 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
2687 func_create_testdir "$megatestdir/ALL" "$allmodules"
2688 func_append megasubdirs "ALL"
2690 # Create Makefile.am.
2691 (echo "## Process this file with automake to produce Makefile.in."
2693 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2695 echo "SUBDIRS = $megasubdirs"
2696 ) > "$megatestdir/Makefile.am"
2698 # Create configure.ac.
2699 (echo "# Process this file with autoconf to produce a configure script."
2700 echo "AC_INIT([dummy], [0])"
2701 if test "$auxdir" != "."; then
2702 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2704 echo "AM_INIT_AUTOMAKE"
2706 echo "AC_PROG_MAKE_SET"
2708 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
2709 echo "AC_OUTPUT([Makefile])"
2710 ) > "$megatestdir/configure.ac"
2712 # Create autogenerated files.
2714 # Do not use "${AUTORECONF} --install", because autoreconf operates
2715 # recursively, but the subdirectories are already finished, therefore
2716 # calling autoreconf here would only waste lots of CPU time.
2717 echo "executing ${ACLOCAL}"
2718 ${ACLOCAL} || func_exit 1
2719 echo "executing mkdir build-aux"
2721 echo "executing ${AUTOCONF}"
2722 ${AUTOCONF} || func_exit 1
2723 echo "executing ${AUTOMAKE} --add-missing --copy"
2724 ${AUTOMAKE} --add-missing --copy || func_exit 1
2730 func_fatal_error "no mode specified" ;;
2739 if test -z "$destdir"; then
2742 test -d "$destdir" \
2743 || func_fatal_error "destination directory does not exist: $destdir"
2745 # Prefer configure.ac to configure.in.
2746 if test -f "$destdir"/configure.ac; then
2747 configure_ac="$destdir/configure.ac"
2749 if test -f "$destdir"/configure.in; then
2750 configure_ac="$destdir/configure.in"
2752 func_fatal_error "cannot find $destdir/configure.ac"
2756 # Analyze configure.ac.
2758 guessed_libtool=false
2763 /AC_CONFIG_AUX_DIR/ {
2764 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
2766 /A[CM]_PROG_LIBTOOL/ {
2767 s,^.*$,guessed_libtool=true,p
2769 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
2771 if test -z "$auxdir"; then
2772 auxdir="$guessed_auxdir"
2775 # Determine where to apply func_import.
2776 if test -n "$m4base"; then
2777 # Apply func_import to a particular gnulib directory.
2778 # Any number of additional modules can be given.
2779 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
2780 # First use of gnulib in the given m4base.
2781 test -n "$supplied_libname" || supplied_libname=true
2782 test -n "$sourcebase" || sourcebase="lib"
2783 test -n "$docbase" || docbase="doc"
2784 test -n "$testsbase" || testsbase="tests"
2785 test -n "$macro_prefix" || macro_prefix="gl"
2789 # Apply func_import to all gnulib directories.
2790 # To get this list of directories, look at Makefile.am. (Not at
2791 # configure, because it may be omitted from CVS. Also, don't run
2792 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
2795 if test -f "$destdir"/Makefile.am; then
2796 aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$destdir"/Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'`
2798 for arg in $aclocal_amflags; do
2799 if test -n "$m4dir_is_next"; then
2800 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
2804 if test -f "$destdir/$arg"/gnulib-cache.m4; then
2805 func_append m4dirs " $arg"
2806 m4dirs_count=`expr $m4dirs_count + 1`
2811 if test "X$arg" = "X-I"; then
2819 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
2820 if test -f "$destdir"/aclocal.m4; then
2821 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
2822 sedexpr2='s,^[^/]*$,.,'
2823 sedexpr3='s,/[^/]*$,,'
2824 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
2825 m4dirs_count=`echo "$m4dirs" | wc -l`
2828 if test $m4dirs_count = 0; then
2829 # First use of gnulib in a package.
2830 # Any number of additional modules can be given.
2831 test -n "$supplied_libname" || supplied_libname=true
2832 test -n "$sourcebase" || sourcebase="lib"
2834 test -n "$docbase" || docbase="doc"
2835 test -n "$testsbase" || testsbase="tests"
2836 test -n "$macro_prefix" || macro_prefix="gl"
2839 if test $m4dirs_count = 1; then
2840 # There's only one use of gnulib here. Assume the user means it.
2841 # Any number of additional modules can be given.
2842 for m4base in $m4dirs; do
2846 # Ambiguous - guess what the user meant.
2847 if test $# = 0; then
2848 # No further arguments. Guess the user wants to update all of them.
2849 for m4base in $m4dirs; do
2850 # Perform func_import in a subshell, so that variable values
2852 # local_gnulib_dir, avoidlist, sourcebase, m4base, docbase,
2853 # testsbase, libname, lgpl, makefile_name, libtool, macro_prefix
2854 # don't propagate from one directory to another.
2855 (func_import) || func_exit 1
2859 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
2867 if test -z "$destdir"; then
2868 func_fatal_error "please specify --dir option"
2871 test -d "$destdir" \
2872 || func_fatal_error "could not create destination directory"
2873 test -n "$auxdir" || auxdir="build-aux"
2874 func_create_testdir "$destdir" "$*"
2877 create-megatestdir )
2878 if test -z "$destdir"; then
2879 func_fatal_error "please specify --dir option"
2881 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2882 test -n "$auxdir" || auxdir="build-aux"
2883 func_create_megatestdir "$destdir" "$*"
2887 test -n "$destdir" || destdir=testdir$$
2888 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2889 test -n "$auxdir" || auxdir="build-aux"
2890 func_create_testdir "$destdir" "$*"
2894 ../configure || func_exit 1
2896 make check || func_exit 1
2897 make distclean || func_exit 1
2898 remaining=`find . -type f -print`
2899 if test -n "$remaining"; then
2900 echo "Remaining files:" $remaining 1>&2
2901 echo "gnulib-tool: *** Stop." 1>&2
2910 test -n "$destdir" || destdir=testdir$$
2911 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2912 test -n "$auxdir" || auxdir="build-aux"
2913 func_create_megatestdir "$destdir" "$*"
2921 remaining=`find . -type f -print`
2922 if test -n "$remaining"; then
2923 echo "Remaining files:" $remaining 1>&2
2924 echo "gnulib-tool: *** Stop." 1>&2
2932 extract-description )
2936 if test -n "$module"; then
2937 func_get_description "$module"
2946 if test -n "$module"; then
2947 func_get_filelist "$module"
2952 extract-dependencies )
2956 if test -n "$module"; then
2957 func_get_dependencies "$module"
2962 extract-autoconf-snippet )
2966 if test -n "$module"; then
2967 func_get_autoconf_snippet "$module"
2972 extract-automake-snippet )
2976 if test -n "$module"; then
2977 func_get_automake_snippet "$module"
2982 extract-include-directive )
2986 if test -n "$module"; then
2987 func_get_include_directive "$module"
2996 if test -n "$module"; then
2997 func_get_license "$module"
3002 extract-maintainer )
3006 if test -n "$module"; then
3007 func_get_maintainer "$module"
3012 extract-tests-module )
3016 if test -n "$module"; then
3017 func_get_tests_module "$module"
3023 func_fatal_error "unknown operation mode --$mode" ;;
3027 # Undo the effect of the previous 'trap' command. Some shellology:
3028 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
3029 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
3030 # exit); for the others we need to call 'exit' explicitly. The value of $? is
3031 # 128 + signal number and is set before the trap-registered command is run.
3033 trap 'func_exit $?' 1 2 3 13 15
3038 # indent-tabs-mode: nil
3039 # whitespace-check-buffer-indent: nil