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-21 20:07:09 $'
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 -e 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" && find modules -type f -print | sed -e 's,^modules/,,')
818 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
819 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
822 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
823 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
824 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
825 -e '/^README$/d' -e '/\/README$/d' \
827 -e '/^TEMPLATE-TESTS$/d' \
830 | sed -e '/-tests$/d' \
835 # verifies a module name
837 # - local_gnulib_dir from --local-dir
838 # - module module name argument
839 func_verify_module ()
841 if { test -f "$gnulib_dir/modules/$module" \
842 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
843 && test -f "$local_gnulib_dir/modules/$module"; }; } \
844 && test "CVS" != "$module" \
845 && test "ChangeLog" != "$module" \
846 && test "COPYING" != "$module" \
847 && test "README" != "$module" \
848 && test "TEMPLATE" != "$module" \
849 && test "TEMPLATE-TESTS" != "$module"; then
850 # OK, $module is a correct module name.
851 # Verify that building the module description with 'patch' succeeds.
852 func_lookup_file "modules/$module"
854 echo "gnulib-tool: module $module doesn't exist" 1>&2
859 # func_verify_nontests_module
860 # verifies a module name, excluding tests modules
862 # - local_gnulib_dir from --local-dir
863 # - module module name argument
864 func_verify_nontests_module ()
868 * ) func_verify_module ;;
872 # func_verify_tests_module
873 # verifies a module name, considering only tests modules
875 # - local_gnulib_dir from --local-dir
876 # - module module name argument
877 func_verify_tests_module ()
880 *-tests ) func_verify_module ;;
885 sed_extract_prog=':[ ]*$/ {
888 s/^Description:[ ]*$//
890 s/^Depends-on:[ ]*$//
891 s/^configure\.ac:[ ]*$//
892 s/^Makefile\.am:[ ]*$//
895 s/^Maintainer:[ ]*$//
902 # func_get_description module
904 # - local_gnulib_dir from --local-dir
905 func_get_description ()
907 func_lookup_file "modules/$1"
908 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
911 # func_get_filelist module
913 # - local_gnulib_dir from --local-dir
916 func_lookup_file "modules/$1"
917 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
918 echo m4/gnulib-common.m4
919 case "$autoconf_minversion" in
922 echo m4/onceonly_2_57.m4
927 # func_get_dependencies module
929 # - local_gnulib_dir from --local-dir
930 func_get_dependencies ()
932 # ${module}-tests always implicitly depends on ${module}.
933 echo "$1" | sed -n -e 's/-tests//p'
934 # Then the explicit dependencies listed in the module description.
935 func_lookup_file "modules/$1"
936 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
939 # func_get_autoconf_snippet module
941 # - local_gnulib_dir from --local-dir
942 func_get_autoconf_snippet ()
944 func_lookup_file "modules/$1"
945 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
948 # func_get_automake_snippet module
950 # - local_gnulib_dir from --local-dir
951 func_get_automake_snippet ()
953 func_lookup_file "modules/$1"
954 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
957 # *-tests module live in tests/, not lib/.
960 # Synthesize an EXTRA_DIST augmentation.
961 sed_combine_lines='/\\$/{
968 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
969 already_mentioned_files=` \
970 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
971 | sed -e "$sed_combine_lines" \
972 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
973 all_files=`func_get_filelist $1`
974 lib_files=`for f in $all_files; do \
978 done | sed -e 's,^lib/,,'`
979 # Remove $already_mentioned_files from $lib_files.
980 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
981 extra_files=`for f in $already_mentioned_files; do echo $f; done \
982 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
983 if test -n "$extra_files"; then
984 echo "EXTRA_DIST +=" $extra_files
987 # Synthesize also an EXTRA_lib_SOURCES augmentation.
988 # This is necessary so that automake can generate the right list of
990 # A possible approach would be to use autom4te --trace of the redefined
991 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
992 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
993 # inside autoconf's built-in macros are not missed).
994 # But it's simpler and more robust to do it here, based on the file list.
995 # If some .c file exists and is not used with AC_LIBOBJ - for example,
996 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
997 # automake will generate a useless dependency; this is harmless.
998 sed_extract_c_files='/\.c$/p'
999 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1000 if test -n "$extra_files"; then
1001 echo "EXTRA_lib_SOURCES +=" $extra_files
1008 # func_get_include_directive module
1010 # - local_gnulib_dir from --local-dir
1011 func_get_include_directive ()
1013 func_lookup_file "modules/$1"
1014 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1015 sed -e 's/^\(["<]\)/#include \1/'
1018 # func_get_license module
1020 # - local_gnulib_dir from --local-dir
1023 func_lookup_file "modules/$1"
1024 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1025 # The default is GPL.
1027 } | sed -e 's,^ *$,,' | sed -e 1q
1030 # func_get_maintainer module
1032 # - local_gnulib_dir from --local-dir
1033 func_get_maintainer ()
1035 func_lookup_file "modules/$1"
1036 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1039 # func_get_tests_module module
1041 # - local_gnulib_dir from --local-dir
1042 func_get_tests_module ()
1044 # The naming convention for tests modules is hardwired: ${module}-tests.
1045 if test -f "$gnulib_dir/modules/$1"-tests \
1046 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1047 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1052 # func_acceptable module
1053 # tests whether a module is acceptable.
1055 # - avoidlist list of modules to avoid
1058 for avoid in $avoidlist; do
1059 if test "$avoid" = "$1"; then
1066 # func_modules_transitive_closure
1068 # - local_gnulib_dir from --local-dir
1069 # - modules list of specified modules
1070 # - inctests true if tests should be included, blank otherwise
1071 # - avoidlist list of modules to avoid
1072 # - tmp pathname of a temporary directory
1074 # - modules list of modules, including dependencies
1075 func_modules_transitive_closure ()
1077 # In order to process every module only once (for speed), process an "input
1078 # list" of modules, producing an "output list" of modules. During each round,
1079 # more modules can be queued in the input list. Once a module on the input
1080 # list has been processed, it is added to the "handled list", so we can avoid
1081 # to process it again.
1083 inmodules="$modules"
1085 while test -n "$inmodules"; do
1086 inmodules_this_round="$inmodules"
1087 inmodules= # Accumulator, queue for next round
1088 for module in $inmodules_this_round; do
1090 if test -n "$module"; then
1091 if func_acceptable $module; then
1092 func_append outmodules " $module"
1093 deps=`func_get_dependencies $module`
1094 # Duplicate dependencies are harmless, but Jim wants a warning.
1095 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1096 if test -n "$duplicated_deps"; then
1097 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1099 func_append inmodules " $deps"
1100 if test -n "$inctests"; then
1101 testsmodule=`func_get_tests_module $module`
1102 if test -n "$testsmodule"; then
1103 func_append inmodules " $testsmodule"
1109 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1110 # Remove $handledmodules from $inmodules.
1111 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1112 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1114 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1115 rm -f "$tmp"/queued-modules
1118 # func_modules_add_dummy
1120 # - local_gnulib_dir from --local-dir
1121 # - modules list of modules, including dependencies
1123 # - modules list of modules, including 'dummy' if needed
1124 func_modules_add_dummy ()
1127 sed_remove_backslash_newline=':a
1134 for module in $modules; do
1135 func_verify_nontests_module
1136 if test -n "$module"; then
1137 # Extract the value of "lib_SOURCES += ...".
1138 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1139 # Ignore .h files since they are not compiled.
1142 *) have_lib_SOURCES=yes ;;
1147 # Add the dummy module, to make sure the library will be non-empty.
1148 if test -z "$have_lib_SOURCES"; then
1149 func_append modules " dummy"
1153 # func_modules_to_filelist
1155 # - local_gnulib_dir from --local-dir
1156 # - modules list of modules, including dependencies
1158 # - files list of files
1159 func_modules_to_filelist ()
1162 for module in $modules; do
1164 if test -n "$module"; then
1165 fs=`func_get_filelist $module`
1166 func_append files " $fs"
1169 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1172 # func_emit_lib_Makefile_am
1173 # emits the contents of library makefile to standard output.
1175 # - local_gnulib_dir from --local-dir
1176 # - modules list of modules, including dependencies
1177 # - libname library name
1178 # - auxdir directory relative to destdir where to place build aux files
1179 # - makefile_name from --makefile-name
1180 # - libtool true if libtool will be used, false or blank otherwise
1181 # - macro_prefix prefix of gl_LIBOBJS macros to use
1182 # - actioncmd (optional) command that will reproduce this invocation
1184 # - uses_subdirs nonempty if object files in subdirs exist
1185 func_emit_lib_Makefile_am ()
1187 # When creating an includable Makefile.am snippet, augment variables with
1188 # += instead of assigning them.
1189 if test -n "$makefile_name"; then
1194 if test "$libtool" = true; then
1197 sed_eliminate_LDFLAGS=
1201 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1203 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1204 echo "## Process this file with automake to produce Makefile.in."
1205 func_emit_copyright_notice
1206 if test -n "$actioncmd"; then
1207 echo "# Reproduce by: $actioncmd"
1212 for module in $modules; do
1213 func_verify_nontests_module
1214 if test -n "$module"; then
1216 func_get_automake_snippet "$module" |
1217 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1218 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1219 sed -e "$sed_eliminate_LDFLAGS" |
1220 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1221 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1222 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
1223 if test "$module" = 'alloca'; then
1224 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1225 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1228 # Skip the contents if its entirely empty.
1229 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1230 echo "## begin gnulib module $module"
1233 echo "## end gnulib module $module"
1237 # Test whether there are some source files in subdirectories.
1238 for f in `func_get_filelist "$module"`; do
1240 lib/*/*.c) uses_subdirs=yes ;;
1246 if test -z "$makefile_name"; then
1247 # If there are source files in subdirectories, prevent collision of the
1248 # object files (example: hash.c and libxml/hash.c).
1250 if test -n "$uses_subdirs"; then
1251 subdir_options=' subdir-objects'
1253 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1256 if test -z "$makefile_name"; then
1257 echo "noinst_HEADERS ="
1258 echo "noinst_LIBRARIES ="
1259 echo "noinst_LTLIBRARIES ="
1260 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1261 # if you specify pkgdata_DATA to empty. This is a workaround.
1262 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1263 echo "pkgdata_DATA ="
1266 echo "BUILT_SOURCES ="
1269 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1270 if test -z "$makefile_name"; then
1271 echo "MOSTLYCLEANDIRS ="
1273 echo "DISTCLEANFILES ="
1274 echo "MAINTAINERCLEANFILES ="
1276 echo "AM_CPPFLAGS ="
1279 if grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1280 # One of the snippets already specifies an installation location for the
1281 # library. Don't confuse automake by saying it should not be installed.
1284 # By default, the generated library should not be installed.
1285 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1288 echo "${libname}_${libext}_SOURCES ="
1289 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1290 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1291 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1292 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1293 echo "EXTRA_${libname}_${libext}_SOURCES ="
1294 if test "$libtool" = true; then
1295 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1298 cat allsnippets.tmp \
1299 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1301 echo "mostlyclean-local: mostlyclean-generic"
1302 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1303 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1304 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1307 rm -f allsnippets.tmp
1310 # func_emit_tests_Makefile_am
1311 # emits the contents of tests makefile to standard output.
1313 # - local_gnulib_dir from --local-dir
1314 # - modules list of modules, including dependencies
1315 # - libname library name
1316 # - makefile_name from --makefile-name
1317 # - libtool true if libtool will be used, false or blank otherwise
1318 # - sourcebase relative directory containing lib source code
1319 # - m4base relative directory containing autoconf macros
1320 # - testsbase relative directory containing unit test code
1321 func_emit_tests_Makefile_am ()
1323 if test "$libtool" = true; then
1328 if test "$libtool" = true; then
1330 sed_eliminate_LDFLAGS=
1333 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1335 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1336 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1337 echo "## Process this file with automake to produce Makefile.in."
1338 func_emit_copyright_notice
1340 # Generate dependencies here, since it eases the debugging of test failures.
1341 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1343 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1346 for module in $modules; do
1347 func_verify_tests_module
1348 if test -n "$module"; then
1350 func_get_automake_snippet "$module" |
1351 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1352 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1353 sed -e "$sed_eliminate_LDFLAGS" |
1354 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1355 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1356 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
1358 # Skip the contents if its entirely empty.
1359 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1360 echo "## begin gnulib module $module"
1363 echo "## end gnulib module $module"
1370 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1371 # variable is needed to avoid an error from automake:
1372 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1375 echo "TESTS_ENVIRONMENT ="
1376 echo "noinst_PROGRAMS ="
1377 echo "check_PROGRAMS ="
1378 echo "noinst_HEADERS ="
1379 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1380 echo "pkgdata_DATA ="
1383 echo "BUILT_SOURCES ="
1385 echo "MOSTLYCLEANFILES = core *.stackdump"
1386 echo "MOSTLYCLEANDIRS ="
1388 echo "DISTCLEANFILES ="
1389 echo "MAINTAINERCLEANFILES ="
1391 echo "AM_CPPFLAGS = \\"
1392 echo " -I. -I\$(srcdir) \\"
1393 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1394 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1396 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1399 echo "# Clean up after Solaris cc."
1401 echo " rm -rf SunWS_cache"
1403 echo "mostlyclean-local: mostlyclean-generic"
1404 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1405 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1406 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1409 rm -f allsnippets.tmp
1412 # func_emit_initmacro_start
1413 # emits the first few statements of the gl_INIT macro to standard output.
1414 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1415 func_emit_initmacro_start ()
1417 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
1418 # platform-dependent object files in ${macro_prefix}_LIBOBJS instead of
1419 # LIBOBJS. The purpose is to allow several gnulib instantiations under
1420 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
1422 # Furthermore it avoids an automake error like this when a Makefile.am
1423 # that uses pieces of gnulib also uses $(LIBOBJ):
1424 # automatically discovered file `error.c' should not be explicitly mentioned
1425 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix}_LIBOBJ]))"
1426 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix}_REPLACE_FUNCS]))"
1427 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
1428 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
1429 # automatically discovered file `error.c' should not be explicitly mentioned
1430 # We let automake know about the files to be distributed through the
1431 # EXTRA_lib_SOURCES variable.
1432 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix}_LIBSOURCES]))"
1435 # func_emit_initmacro_end
1436 # emits the last few statements of the gl_INIT macro to standard output.
1437 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1438 func_emit_initmacro_end ()
1440 echo " m4_popdef([AC_LIBSOURCES])"
1441 echo " m4_popdef([AC_REPLACE_FUNCS])"
1442 echo " m4_popdef([AC_LIBOBJ])"
1443 echo " AC_CONFIG_COMMANDS_PRE(["
1444 echo " ${macro_prefix}_libobjs="
1445 echo " ${macro_prefix}_ltlibobjs="
1446 echo " if test -n \"\$${macro_prefix}_LIBOBJS\"; then"
1447 echo " # Remove the extension."
1448 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
1449 echo " for i in \`for i in \$${macro_prefix}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
1450 echo " ${macro_prefix}_libobjs=\"\$${macro_prefix}_libobjs \$i.\$ac_objext\""
1451 echo " ${macro_prefix}_ltlibobjs=\"\$${macro_prefix}_ltlibobjs \$i.lo\""
1454 echo " AC_SUBST([${macro_prefix}_LIBOBJS], [\$${macro_prefix}_libobjs])"
1455 echo " AC_SUBST([${macro_prefix}_LTLIBOBJS], [\$${macro_prefix}_ltlibobjs])"
1459 # func_emit_initmacro_done
1460 # emits a few statements after the gl_INIT macro to standard output.
1461 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1462 func_emit_initmacro_done ()
1465 echo "# Like AC_LIBOBJ, except that the module name goes"
1466 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1467 echo "AC_DEFUN([${macro_prefix}_LIBOBJ],"
1468 echo " [${macro_prefix}_LIBOBJS=\"\$${macro_prefix}_LIBOBJS \$1.\$ac_objext\"])"
1470 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
1471 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1472 echo "AC_DEFUN([${macro_prefix}_REPLACE_FUNCS],"
1473 echo " [AC_CHECK_FUNCS([\$1], , [${macro_prefix}_LIBOBJ(\$ac_func)])])"
1475 echo "# Like AC_LIBSOURCES, except that it does nothing."
1476 echo "# We rely on EXTRA_lib..._SOURCES instead."
1477 echo "AC_DEFUN([${macro_prefix}_LIBSOURCES],"
1481 # func_import modules
1482 # Uses also the variables
1483 # - destdir target directory
1484 # - local_gnulib_dir from --local-dir
1485 # - libname library name
1486 # - sourcebase directory relative to destdir where to place source code
1487 # - m4base directory relative to destdir where to place *.m4 macros
1488 # - docbase directory relative to destdir where to place doc files
1489 # - testsbase directory relative to destdir where to place unit test code
1490 # - auxdir directory relative to destdir where to place build aux files
1491 # - inctests true if --with-tests was given, blank otherwise
1492 # - avoidlist list of modules to avoid, from --avoid
1493 # - lgpl true if library's license shall be LGPL, blank otherwise
1494 # - makefile_name from --makefile-name
1495 # - libtool true if --libtool was given, false if --no-libtool was
1496 # given, blank otherwise
1497 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1498 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1499 # - autoconf_minversion minimum supported autoconf version
1500 # - doit : if actions shall be executed, false if only to be printed
1501 # - symbolic true if files should be symlinked, copied otherwise
1502 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1506 # Get the cached settings.
1507 cached_local_gnulib_dir=
1508 cached_specified_modules=
1516 cached_makefile_name=
1518 cached_macro_prefix=
1520 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1521 cached_libtool=false
1527 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
1530 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1533 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1536 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1539 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1542 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1545 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1548 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1551 s,^.*$,cached_lgpl=true,p
1553 /gl_MAKEFILE_NAME(/ {
1554 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
1557 s,^.*$,cached_libtool=true,p
1559 /gl_MACRO_PREFIX(/ {
1560 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
1562 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
1563 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1568 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
1569 s,^.*$,cached_files=",p
1581 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1585 # Merge the cached settings with the specified ones.
1586 # The m4base must be the same as expected from the pathname.
1587 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1588 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1590 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
1591 # is relative to $destdir, whereas the one we use is relative to . or absolute.
1592 if test -z "$local_gnulib_dir"; then
1593 if test -n "$cached_local_gnulib_dir"; then
1596 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1598 case "$cached_local_gnulib_dir" in
1600 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1602 func_relconcat "$destdir" "$cached_local_gnulib_dir"
1603 local_gnulib_dir="$relconcat" ;;
1608 # Append the cached and the specified module names. So that
1609 # "gnulib-tool --import foo" means to add the module foo.
1610 specified_modules="$cached_specified_modules $1"
1611 # Append the cached and the specified avoidlist. This is probably better
1612 # than dropping the cached one when --avoid is specified at least once.
1613 avoidlist=`echo $cached_avoidlist $avoidlist`
1614 # The sourcebase defaults to the cached one.
1615 if test -z "$sourcebase"; then
1616 sourcebase="$cached_sourcebase"
1617 if test -z "$sourcebase"; then
1618 func_fatal_error "missing --source-base option"
1621 # The docbase defaults to the cached one.
1622 if test -z "$docbase"; then
1623 docbase="$cached_docbase"
1624 if test -z "$docbase"; then
1625 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."
1628 # The testsbase defaults to the cached one.
1629 if test -z "$testsbase"; then
1630 testsbase="$cached_testsbase"
1631 if test -z "$testsbase"; then
1632 func_fatal_error "missing --tests-base option"
1635 # The libname defaults to the cached one.
1636 if test -z "$supplied_libname"; then
1637 libname="$cached_libname"
1638 if test -z "$libname"; then
1639 func_fatal_error "missing --lib option"
1642 # Require LGPL if specified either way.
1643 if test -z "$lgpl"; then
1646 # The makefile_name defaults to the cached one.
1647 if test -z "$makefile_name"; then
1648 makefile_name="$cached_makefile_name"
1650 # Use libtool if specified either way, or if guessed.
1651 if test -z "$libtool"; then
1652 if test -n "$cached_m4base"; then
1653 libtool="$cached_libtool"
1655 libtool="$guessed_libtool"
1658 # The macro_prefix defaults to the cached one.
1659 if test -z "$macro_prefix"; then
1660 macro_prefix="$cached_macro_prefix"
1661 if test -z "$macro_prefix"; then
1662 func_fatal_error "missing --macro-prefix option"
1666 # Canonicalize the list of specified modules.
1667 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
1669 # Determine final module list.
1670 modules="$specified_modules"
1671 func_modules_transitive_closure
1672 echo "Module list with included dependencies:"
1673 echo "$modules" | sed -e 's/^/ /'
1675 # Add the dummy module if needed.
1676 func_modules_add_dummy
1678 # If --lgpl, verify that the licenses of modules are compatible.
1679 if test -n "$lgpl"; then
1680 for module in $modules; do
1681 license=`func_get_license $module`
1683 LGPL | 'GPLed build tool') ;;
1684 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
1685 *) func_fatal_error "incompatible license on module $module: $license" ;;
1690 # Determine script to apply to imported library files.
1691 sed_transform_lib_file=
1692 for module in $modules; do
1693 if test $module = config-h; then
1694 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
1695 sed_transform_lib_file=$sed_transform_lib_file'
1696 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
1701 if test -n "$lgpl"; then
1703 sed_transform_lib_file=$sed_transform_lib_file'
1704 s/GNU General/GNU Lesser General/g
1705 s/version 2\([ ,]\)/version 2.1\1/g
1709 # Determine final file list.
1710 func_modules_to_filelist
1712 echo "$files" | sed -e 's/^/ /'
1715 || func_fatal_error "refusing to do nothing"
1717 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
1718 new_files="$files m4/gnulib-tool.m4"
1719 old_files="$cached_files"
1720 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
1721 func_append old_files " m4/gnulib-tool.m4"
1724 sed_rewrite_old_files="\
1725 s,^build-aux/,$auxdir/,
1726 s,^doc/,$cached_docbase/,
1727 s,^lib/,$cached_sourcebase/,
1728 s,^m4/,$cached_m4base/,
1729 s,^tests/,$cached_testsbase/,"
1730 sed_rewrite_new_files="\
1731 s,^build-aux/,$auxdir/,
1733 s,^lib/,$sourcebase/,
1735 s,^tests/,$testsbase/,"
1737 # Create directories.
1738 { echo "$sourcebase"
1740 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
1741 if test -n "$docfiles"; then
1744 if test -n "$inctests"; then
1748 for f in $files; do echo $f; done \
1749 | sed -e "$sed_rewrite_new_files" \
1750 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
1753 { # Rearrange file descriptors. Needed because "while ... done < ..."
1754 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1755 exec 5<&0 < "$tmp"/dirs
1757 if test ! -d "$destdir/$d"; then
1759 echo "Creating directory $destdir/$d"
1760 mkdir -p "$destdir/$d" || func_fatal_error "failed"
1762 echo "Create directory $destdir/$d"
1769 # func_dest_tmpfilename file
1770 # determines the name of a temporary file (file is relative to destdir).
1772 # - tmpfile absolute filename of the temporary file
1773 func_dest_tmpfilename ()
1776 # Put the new contents of $file in a file in the same directory (needed
1777 # to guarantee that an 'mv' to "$destdir/$file" works).
1778 tmpfile="$destdir/$1.tmp"
1780 # Put the new contents of $file in a file in a temporary directory
1781 # (because the directory of "$file" might not exist).
1782 tmpfile="$tmp"/`basename "$1"`.tmp
1786 # Copy files or make symbolic links. Remove obsolete files.
1788 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1789 # representing the files according to the last gnulib-tool invocation.
1790 for f in $old_files; do echo $f; done \
1791 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
1794 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1795 # representing the files after this gnulib-tool invocation.
1796 for f in $new_files; do echo $f; done \
1797 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
1800 # First the files that are in old-files, but not in new-files:
1801 sed_take_first_column='s,'"$delimiter"'.*,,'
1802 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
1803 # Remove the file. Do nothing if the user already removed it.
1804 if test -f "$destdir/$g"; then
1806 echo "Removing file $g (backup in ${g}~)"
1807 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1809 echo "Remove file $g (backup in ${g}~)"
1813 # func_add_or_update handles a file that ought to be present afterwards.
1815 # - f the original file name
1816 # - g the rewritten file name
1817 # - already_present nonempty if the file already exists, empty otherwise
1818 func_add_or_update ()
1820 func_dest_tmpfilename "$g"
1821 func_lookup_file "$f"
1822 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
1823 if test -n "$sed_transform_lib_file"; then
1826 sed -e "$sed_transform_lib_file" \
1827 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
1831 if test -f "$destdir/$g"; then
1832 # The file already exists.
1833 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1834 : # The file has not changed.
1838 if test -n "$already_present"; then
1839 echo "Updating file $g (backup in ${g}~)"
1841 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
1843 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1844 if { test -n "$symbolic" \
1845 || { test -n "$lsymbolic" \
1846 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1847 && test -z "$lookedup_tmp" \
1848 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1849 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1851 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1854 if test -n "$already_present"; then
1855 echo "Update file $g (backup in ${g}~)"
1857 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
1863 # Don't protest if the file should be there but isn't: it happens
1864 # frequently that developers don't put autogenerated files into CVS.
1866 echo "Copying file $g"
1867 if { test -n "$symbolic" \
1868 || { test -n "$lsymbolic" \
1869 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1870 && test -z "$lookedup_tmp" \
1871 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1872 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1874 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1882 # Then the files that are in new-files, but not in old-files:
1883 sed_take_last_column='s,^.*'"$delimiter"',,'
1885 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
1886 | sed -e "$sed_take_last_column" \
1887 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
1888 { # Rearrange file descriptors. Needed because "while ... done < ..."
1889 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1890 exec 5<&0 < "$tmp"/added-files
1896 # Then the files that are in new-files and in old-files:
1897 already_present=true
1898 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
1899 | sed -e "$sed_take_last_column" \
1900 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
1901 { # Rearrange file descriptors. Needed because "while ... done < ..."
1902 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1903 exec 5<&0 < "$tmp"/kept-files
1910 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
1911 actioncmd="gnulib-tool --import"
1912 func_append actioncmd " --dir=$destdir"
1913 if test -n "$local_gnulib_dir"; then
1914 func_append actioncmd " --local-dir=$local_gnulib_dir"
1916 func_append actioncmd " --lib=$libname"
1917 func_append actioncmd " --source-base=$sourcebase"
1918 func_append actioncmd " --m4-base=$m4base"
1919 func_append actioncmd " --doc-base=$docbase"
1920 func_append actioncmd " --aux-dir=$auxdir"
1921 for module in $avoidlist; do
1922 func_append actioncmd " --avoid=$module"
1924 if test -n "$lgpl"; then
1925 func_append actioncmd " --lgpl"
1927 if test -n "$makefile_name"; then
1928 func_append actioncmd " --makefile-name=$makefile_name"
1930 if test "$libtool" = true; then
1931 func_append actioncmd " --libtool"
1933 func_append actioncmd " --no-libtool"
1935 func_append actioncmd " --macro-prefix=$macro_prefix"
1936 func_append actioncmd " `echo $specified_modules`"
1938 # Default the makefile name to Makefile.am.
1939 if test -n "$makefile_name"; then
1940 makefile_am=$makefile_name
1942 makefile_am=Makefile.am
1945 # Create library makefile.
1946 func_dest_tmpfilename $sourcebase/$makefile_am
1947 func_emit_lib_Makefile_am > "$tmpfile"
1948 if test -f "$destdir"/$sourcebase/$makefile_am; then
1949 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
1953 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
1954 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
1955 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
1957 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
1963 echo "Creating $sourcebase/$makefile_am"
1964 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
1966 echo "Create $sourcebase/$makefile_am"
1971 # Create m4/gnulib-cache.m4.
1972 func_dest_tmpfilename $m4base/gnulib-cache.m4
1974 func_emit_copyright_notice
1976 echo "# This file represents the specification of how gnulib-tool is used."
1977 echo "# It acts as a cache: It is written and read by gnulib-tool."
1978 echo "# In projects using CVS, this file is meant to be stored in CVS,"
1979 echo "# like the configure.ac and various Makefile.am files."
1982 echo "# Specification in the form of a command-line invocation:"
1985 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
1986 # Store the local_gnulib_dir relative to destdir.
1987 case "$local_gnulib_dir" in
1989 relative_local_gnulib_dir="$local_gnulib_dir" ;;
1992 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
1994 # destdir, local_gnulib_dir are both relative.
1995 func_relativize "$destdir" "$local_gnulib_dir"
1996 relative_local_gnulib_dir="$reldir" ;;
1999 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
2000 echo "gl_MODULES(["`echo $specified_modules`"])"
2001 echo "gl_AVOID([$avoidlist])"
2002 echo "gl_SOURCE_BASE([$sourcebase])"
2003 echo "gl_M4_BASE([$m4base])"
2004 echo "gl_DOC_BASE([$docbase])"
2005 echo "gl_TESTS_BASE([$testsbase])"
2006 echo "gl_LIB([$libname])"
2007 test -z "$lgpl" || echo "gl_LGPL"
2008 echo "gl_MAKEFILE_NAME([$makefile_name])"
2009 if test "$libtool" = true; then
2012 echo "gl_MACRO_PREFIX([$macro_prefix])"
2014 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2015 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2019 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2020 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2021 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2023 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2027 echo "# gnulib-cache.m4 ends here"
2034 echo "Creating $m4base/gnulib-cache.m4"
2035 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2037 echo "Create $m4base/gnulib-cache.m4"
2043 # Create m4/gnulib-comp.m4.
2044 func_dest_tmpfilename $m4base/gnulib-comp.m4
2046 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2047 func_emit_copyright_notice
2049 echo "# This file represents the compiled summary of the specification in"
2050 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2051 echo "# to be invoked from configure.ac."
2052 echo "# In projects using CVS, this file can be treated like other built files."
2055 echo "# This macro should be invoked from $configure_ac, in the section"
2056 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2057 echo "# any checks for libraries, header files, types and library functions."
2058 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2060 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2061 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2062 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2063 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2064 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2065 if test -n "$uses_subdirs"; then
2066 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2068 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2069 echo " AC_REQUIRE([AC_GNU_SOURCE])"
2071 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2072 echo " AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])"
2074 if grep gl_LOCK "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2075 echo " AC_REQUIRE([gl_LOCK_EARLY])"
2079 echo "# This macro should be invoked from $configure_ac, in the section"
2080 echo "# \"Check for header files, types and library functions\"."
2081 echo "AC_DEFUN([${macro_prefix}_INIT],"
2083 func_emit_initmacro_start
2084 if test "$libtool" = true; then
2085 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2086 echo " gl_cond_libtool=true"
2088 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2089 echo " gl_cond_libtool=false"
2091 echo " gl_ltlibdeps="
2093 echo " gl_source_base='$sourcebase'"
2094 if test "$auxdir" != "build-aux"; then
2095 sed_replace_build_aux='
2097 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2098 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2101 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2103 sed_replace_build_aux=
2105 for module in $modules; do
2107 if test -n "$module"; then
2108 func_get_autoconf_snippet "$module" \
2109 | sed -e '/^$/d;' -e 's/^/ /' \
2110 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
2111 -e "$sed_replace_build_aux"
2112 if test "$module" = 'alloca' && test "$libtool" = true; then
2113 echo 'changequote(,)dnl'
2114 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
2115 echo 'changequote([, ])dnl'
2116 echo 'AC_SUBST([LTALLOCA])'
2120 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2121 # created using libtool, because libtool already handles the dependencies.
2122 if test "$libtool" != true; then
2123 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2124 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2125 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2126 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2127 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2129 func_emit_initmacro_end
2131 func_emit_initmacro_done
2133 echo "# This macro records the list of files which have been installed by"
2134 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
2135 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
2136 echo "$files" | sed -e 's,^, ,'
2139 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2140 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
2144 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2145 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
2146 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2148 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2152 echo "# gnulib-comp.m4 ends here"
2159 echo "Creating $m4base/gnulib-comp.m4"
2160 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2162 echo "Create $m4base/gnulib-comp.m4"
2168 if test -n "$inctests"; then
2169 # Create tests makefile.
2170 func_dest_tmpfilename $testsbase/$makefile_am
2171 func_emit_tests_Makefile_am > "$tmpfile"
2172 if test -f "$destdir"/$testsbase/$makefile_am; then
2173 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
2177 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2178 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
2179 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2181 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2187 echo "Creating $testsbase/$makefile_am"
2188 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2190 echo "Create $testsbase/$makefile_am"
2198 echo "You may need to add #include directives for the following .h files."
2199 # Intersect $specified_modules and $modules
2200 # (since $specified_modules is not necessarily of subset of $modules - some
2201 # may have been skipped through --avoid, and since the elements of $modules
2202 # but not in $specified_modules can go away without explicit notice - through
2203 # changes in the module dependencies).
2204 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
2205 echo "$modules" > "$tmp"/modules2 # also a sorted list, one module per line
2206 # First the #include <...> directives without #ifs, sorted for convenience,
2207 # then the #include "..." directives without #ifs, sorted for convenience,
2208 # then the #include directives that are surrounded by #ifs. Not sorted.
2209 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
2210 include_directive=`func_get_include_directive "$module"`
2211 case "$nl$include_directive" in
2213 echo "$include_directive" 1>&5
2216 echo "$include_directive" | grep -v 'include "' 1>&6
2217 echo "$include_directive" | grep 'include "' 1>&7
2220 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
2222 LC_ALL=C sort -u "$tmp"/include-angles
2223 LC_ALL=C sort -u "$tmp"/include-quotes
2224 cat "$tmp"/include-if
2225 ) | sed -e '/^$/d' -e 's/^/ /'
2226 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
2229 echo "Don't forget to"
2230 if test "$makefile_am" = Makefile.am; then
2231 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2233 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
2235 if test -n "$inctests"; then
2236 if test "$makefile_am" = Makefile.am; then
2237 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2239 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
2242 if test "$makefile_am" = Makefile.am; then
2243 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
2244 sourcebase_base=`basename "$sourcebase"`
2245 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
2247 if test -n "$inctests"; then
2248 if test "$makefile_am" = Makefile.am; then
2249 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
2250 testsbase_base=`basename "$testsbase"`
2251 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
2254 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
2255 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
2256 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
2259 # func_create_testdir testdir modules
2261 # - local_gnulib_dir from --local-dir
2262 # - auxdir directory relative to destdir where to place build aux files
2263 func_create_testdir ()
2267 if test -z "$modules"; then
2268 # All modules together.
2269 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2270 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2271 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
2272 modules=`func_all_modules`
2273 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
2275 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
2277 # Check that the license of every module is consistent with the license of
2279 saved_modules="$modules"
2280 saved_inctests="$inctests"
2281 # When computing transitive closures, don't consider $module to depend on
2282 # $module-tests. Need this becauses tests are implicitly GPL and may depend
2283 # on GPL modules - therefore we don't want a warning in this case.
2285 for requested_module in $saved_modules; do
2286 requested_license=`func_get_license "$requested_module"`
2287 if test "$requested_license" != GPL; then
2288 # Here we use func_modules_transitive_closure, not just
2289 # func_get_dependencies, so that we also detect weird situations like
2290 # an LGPL module which depends on a GPLed build tool module which depends
2292 modules="$requested_module"
2293 func_modules_transitive_closure
2294 for module in $modules; do
2295 license=`func_get_license "$module"`
2297 LGPL | 'GPLed build tool') ;;
2298 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2299 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
2304 modules="$saved_modules"
2305 inctests="$saved_inctests"
2307 # Subdirectory names.
2314 # Determine final module list.
2315 func_modules_transitive_closure
2316 echo "Module list with included dependencies:"
2317 echo "$modules" | sed -e 's/^/ /'
2319 # Add the dummy module if needed.
2320 func_modules_add_dummy
2322 # Determine final file list.
2323 func_modules_to_filelist
2325 echo "$files" | sed -e 's/^/ /'
2327 sed_rewrite_files="\
2328 s,^build-aux/,$auxdir/,
2330 s,^lib/,$sourcebase/,
2332 s,^tests/,$testsbase/,"
2334 # Create directories.
2335 for f in $files; do echo $f; done \
2336 | sed -e "$sed_rewrite_files" \
2337 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2338 | LC_ALL=C sort -u \
2340 { # Rearrange file descriptors. Needed because "while ... done < ..."
2341 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2342 exec 5<&0 < "$tmp"/dirs
2344 mkdir -p "$testdir/$d"
2349 # Copy files or make symbolic links.
2351 for f in $files; do echo $f; done \
2352 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
2355 { # Rearrange file descriptors. Needed because "while ... done < ..."
2356 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2357 exec 5<&0 < "$tmp"/files
2359 func_lookup_file "$f"
2360 if test -n "$lookedup_tmp"; then
2361 cp -p "$lookedup_file" "$testdir/$g"
2363 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
2364 if { test -n "$symbolic" \
2365 || { test -n "$lsymbolic" \
2366 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
2367 func_ln "$lookedup_file" "$testdir/$g"
2369 cp -p "$lookedup_file" "$testdir/$g"
2376 # Create $sourcebase/Makefile.am.
2377 mkdir -p "$testdir/$sourcebase"
2378 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
2380 # Create $m4base/Makefile.am.
2381 mkdir -p "$testdir/$m4base"
2382 (echo "## Process this file with automake to produce Makefile.in."
2388 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
2391 ) > "$testdir/$m4base/Makefile.am"
2393 subdirs="$sourcebase $m4base"
2394 subdirs_with_configure_ac=""
2396 if false && test -f "$testdir"/$m4base/gettext.m4; then
2397 # Avoid stupid error message from automake:
2398 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
2399 mkdir -p "$testdir/po"
2400 (echo "## Process this file with automake to produce Makefile.in."
2401 ) > "$testdir/po/Makefile.am"
2402 func_append subdirs " po"
2405 if test -n "$inctests"; then
2406 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
2407 # Create $testsbase/Makefile.am.
2408 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
2409 # Create $testsbase/configure.ac.
2410 (echo "# Process this file with autoconf to produce a configure script."
2411 echo "AC_INIT([dummy], [0])"
2412 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
2413 echo "AM_INIT_AUTOMAKE"
2415 echo "AM_CONFIG_HEADER([config.h])"
2418 echo "AC_PROG_INSTALL"
2419 echo "AC_PROG_MAKE_SET"
2420 echo "AC_PROG_RANLIB"
2422 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2423 echo "AC_GNU_SOURCE"
2426 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2427 echo "gl_USE_SYSTEM_EXTENSIONS"
2430 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2431 echo "gl_LOCK_EARLY"
2434 if test "$libtool" = true; then
2435 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2436 echo "gl_cond_libtool=true"
2438 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2439 echo "gl_cond_libtool=false"
2441 echo "gl_ltlibdeps="
2443 # Wrap the set of autoconf snippets into an autoconf macro that is then
2444 # invoked. This is needed because autoconf does not support AC_REQUIRE
2446 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2447 # but we want the AC_REQUIRE to have its normal meaning (provide one
2448 # expansion of the required macro before the current point, and only one
2450 echo "AC_DEFUN([gl_INIT], ["
2451 func_emit_initmacro_start
2452 sed_replace_build_aux='
2454 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2455 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
2458 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2459 # We don't have explicit ordering constraints between the various
2460 # autoconf snippets. It's cleanest to put those of the library before
2461 # those of the tests.
2462 echo "gl_source_base='../$sourcebase'"
2463 for module in $modules; do
2464 func_verify_nontests_module
2465 if test -n "$module"; then
2466 func_get_autoconf_snippet "$module" \
2467 | sed -e "$sed_replace_build_aux"
2470 echo "gl_source_base='.'"
2471 for module in $modules; do
2472 func_verify_tests_module
2473 if test -n "$module"; then
2474 func_get_autoconf_snippet "$module" \
2475 | sed -e "$sed_replace_build_aux"
2478 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2479 # created using libtool, because libtool already handles the dependencies.
2480 if test "$libtool" != true; then
2481 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2482 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2483 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2484 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2485 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2487 func_emit_initmacro_end
2489 func_emit_initmacro_done
2493 # Usually $testsbase/config.h will be a superset of config.h. Verify this
2494 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
2495 echo "AH_TOP([#include \"../config.h\"])"
2497 echo "AC_OUTPUT([Makefile])"
2498 ) > "$testdir/$testsbase/configure.ac"
2499 func_append subdirs " $testsbase"
2500 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
2503 # Create Makefile.am.
2504 (echo "## Process this file with automake to produce Makefile.in."
2506 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2508 echo "SUBDIRS = $subdirs"
2510 echo "ACLOCAL_AMFLAGS = -I $m4base"
2511 ) > "$testdir/Makefile.am"
2513 # Create configure.ac.
2514 (echo "# Process this file with autoconf to produce a configure script."
2515 echo "AC_INIT([dummy], [0])"
2516 if test "$auxdir" != "."; then
2517 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2519 echo "AM_INIT_AUTOMAKE"
2521 echo "AM_CONFIG_HEADER([config.h])"
2524 echo "AC_PROG_INSTALL"
2525 echo "AC_PROG_MAKE_SET"
2527 echo "# For autobuild."
2528 echo "AC_CANONICAL_BUILD"
2529 echo "AC_CANONICAL_HOST"
2531 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2532 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2533 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2534 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2536 echo "AC_PROG_RANLIB"
2538 if test -n "$uses_subdirs"; then
2539 echo "AM_PROG_CC_C_O"
2542 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2543 echo "AC_GNU_SOURCE"
2546 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2547 echo "gl_USE_SYSTEM_EXTENSIONS"
2550 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2551 echo "gl_LOCK_EARLY"
2554 if test "$libtool" = true; then
2555 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2556 echo "gl_cond_libtool=true"
2558 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2559 echo "gl_cond_libtool=false"
2561 echo "gl_ltlibdeps="
2563 echo "gl_source_base='$sourcebase'"
2564 # Wrap the set of autoconf snippets into an autoconf macro that is then
2565 # invoked. This is needed because autoconf does not support AC_REQUIRE
2567 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2568 # but we want the AC_REQUIRE to have its normal meaning (provide one
2569 # expansion of the required macro before the current point, and only one
2571 echo "AC_DEFUN([gl_INIT], ["
2572 func_emit_initmacro_start
2573 if test "$auxdir" != "build-aux"; then
2574 sed_replace_build_aux='
2576 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2577 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2580 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2582 sed_replace_build_aux=
2584 for module in $modules; do
2585 func_verify_nontests_module
2586 if test -n "$module"; then
2587 func_get_autoconf_snippet "$module" \
2588 | sed -e "$sed_replace_build_aux"
2591 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2592 # created using libtool, because libtool already handles the dependencies.
2593 if test "$libtool" != true; then
2594 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2595 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2596 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2597 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2598 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2600 func_emit_initmacro_end
2602 func_emit_initmacro_done
2606 if test -n "$subdirs_with_configure_ac"; then
2607 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
2609 makefiles="Makefile"
2610 for d in $subdirs; do
2611 # For subdirs that have a configure.ac by their own, it's the subdir's
2612 # configure.ac which creates the subdir's Makefile.am, not this one.
2613 case " $subdirs_with_configure_ac " in
2615 *) func_append makefiles " $d/Makefile" ;;
2618 echo "AC_OUTPUT([$makefiles])"
2619 ) > "$testdir/configure.ac"
2621 # Create autogenerated files.
2623 # Do not use "${AUTORECONF} --force --install", because it may invoke
2624 # autopoint, which brings in older versions of some of our .m4 files.
2625 if test -f $m4base/gettext.m4; then
2626 echo "executing ${AUTOPOINT} --force"
2627 ${AUTOPOINT} --force || func_exit 1
2628 for f in $m4base/*.m4~; do
2629 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2632 echo "executing ${ACLOCAL} -I $m4base"
2633 ${ACLOCAL} -I $m4base || func_exit 1
2634 if ! test -d build-aux; then
2635 echo "executing mkdir build-aux"
2636 mkdir build-aux || func_exit 1
2638 echo "executing ${AUTOCONF}"
2639 ${AUTOCONF} || func_exit 1
2640 echo "executing ${AUTOHEADER}"
2641 ${AUTOHEADER} || func_exit 1
2642 echo "executing ${AUTOMAKE} --add-missing --copy"
2643 ${AUTOMAKE} --add-missing --copy || func_exit 1
2645 if test -n "$inctests"; then
2646 # Create autogenerated files.
2647 (cd "$testdir/$testsbase" || func_exit 1
2648 # Do not use "${AUTORECONF} --force --install", because it may invoke
2649 # autopoint, which brings in older versions of some of our .m4 files.
2650 if test -f ../$m4base/gettext.m4; then
2651 echo "executing ${AUTOPOINT} --force"
2652 ${AUTOPOINT} --force || func_exit 1
2653 for f in ../$m4base/*.m4~; do
2654 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2657 echo "executing ${ACLOCAL} -I ../$m4base"
2658 ${ACLOCAL} -I ../$m4base || func_exit 1
2659 if ! test -d ../build-aux; then
2660 echo "executing mkdir ../build-aux"
2663 echo "executing ${AUTOCONF}"
2664 ${AUTOCONF} || func_exit 1
2665 echo "executing ${AUTOHEADER}"
2666 ${AUTOHEADER} || func_exit 1
2667 echo "executing ${AUTOMAKE} --add-missing --copy"
2668 ${AUTOMAKE} --add-missing --copy || func_exit 1
2671 # Need to run configure and make once, to create built files that are to be
2672 # distributed (such as getdate.c).
2673 # Extract the value of "CLEANFILES += ...".
2674 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
2675 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
2676 cleaned_files=" "`for file in $cleaned_files; do echo "$file"; done`" "
2677 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
2678 # such $(FOO_H) because they don't refer to distributed files.
2679 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
2680 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
2681 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
2682 | sed -e "$sed_remove_make_variables"`
2683 distributed_built_sources=`for file in $built_sources; do
2684 case "$cleaned_files" in
2689 if test -n "$distributed_built_sources"; then
2691 ./configure || func_exit 1
2693 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
2694 make built_sources || func_exit 1
2696 make distclean || func_exit 1
2701 # func_create_megatestdir megatestdir allmodules
2703 # - local_gnulib_dir from --local-dir
2704 # - auxdir directory relative to destdir where to place build aux files
2705 func_create_megatestdir ()
2709 if test -z "$allmodules"; then
2710 allmodules=`func_all_modules`
2714 # First, all modules one by one.
2715 for onemodule in $allmodules; do
2716 func_create_testdir "$megatestdir/$onemodule" $onemodule
2717 func_append megasubdirs "$onemodule "
2719 # Then, all modules all together.
2720 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2721 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2722 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
2723 func_create_testdir "$megatestdir/ALL" "$allmodules"
2724 func_append megasubdirs "ALL"
2726 # Create Makefile.am.
2727 (echo "## Process this file with automake to produce Makefile.in."
2729 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2731 echo "SUBDIRS = $megasubdirs"
2732 ) > "$megatestdir/Makefile.am"
2734 # Create configure.ac.
2735 (echo "# Process this file with autoconf to produce a configure script."
2736 echo "AC_INIT([dummy], [0])"
2737 if test "$auxdir" != "."; then
2738 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2740 echo "AM_INIT_AUTOMAKE"
2742 echo "AC_PROG_MAKE_SET"
2744 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
2745 echo "AC_OUTPUT([Makefile])"
2746 ) > "$megatestdir/configure.ac"
2748 # Create autogenerated files.
2750 # Do not use "${AUTORECONF} --install", because autoreconf operates
2751 # recursively, but the subdirectories are already finished, therefore
2752 # calling autoreconf here would only waste lots of CPU time.
2753 echo "executing ${ACLOCAL}"
2754 ${ACLOCAL} || func_exit 1
2755 echo "executing mkdir build-aux"
2757 echo "executing ${AUTOCONF}"
2758 ${AUTOCONF} || func_exit 1
2759 echo "executing ${AUTOMAKE} --add-missing --copy"
2760 ${AUTOMAKE} --add-missing --copy || func_exit 1
2766 func_fatal_error "no mode specified" ;;
2775 if test -z "$destdir"; then
2778 test -d "$destdir" \
2779 || func_fatal_error "destination directory does not exist: $destdir"
2781 # Prefer configure.ac to configure.in.
2782 if test -f "$destdir"/configure.ac; then
2783 configure_ac="$destdir/configure.ac"
2785 if test -f "$destdir"/configure.in; then
2786 configure_ac="$destdir/configure.in"
2788 func_fatal_error "cannot find $destdir/configure.ac"
2792 # Analyze configure.ac.
2794 guessed_libtool=false
2799 /AC_CONFIG_AUX_DIR/ {
2800 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
2802 /A[CM]_PROG_LIBTOOL/ {
2803 s,^.*$,guessed_libtool=true,p
2805 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
2807 if test -z "$auxdir"; then
2808 auxdir="$guessed_auxdir"
2811 # Determine where to apply func_import.
2812 if test -n "$m4base"; then
2813 # Apply func_import to a particular gnulib directory.
2814 # Any number of additional modules can be given.
2815 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
2816 # First use of gnulib in the given m4base.
2817 test -n "$supplied_libname" || supplied_libname=true
2818 test -n "$sourcebase" || sourcebase="lib"
2819 test -n "$docbase" || docbase="doc"
2820 test -n "$testsbase" || testsbase="tests"
2821 test -n "$macro_prefix" || macro_prefix="gl"
2825 # Apply func_import to all gnulib directories.
2826 # To get this list of directories, look at Makefile.am. (Not at
2827 # configure, because it may be omitted from CVS. Also, don't run
2828 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
2831 if test -f "$destdir"/Makefile.am; then
2832 aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$destdir"/Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'`
2834 for arg in $aclocal_amflags; do
2835 if test -n "$m4dir_is_next"; then
2836 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
2840 if test -f "$destdir/$arg"/gnulib-cache.m4; then
2841 func_append m4dirs " $arg"
2842 m4dirs_count=`expr $m4dirs_count + 1`
2847 if test "X$arg" = "X-I"; then
2855 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
2856 if test -f "$destdir"/aclocal.m4; then
2857 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
2858 sedexpr2='s,^[^/]*$,.,'
2859 sedexpr3='s,/[^/]*$,,'
2860 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
2861 m4dirs_count=`echo "$m4dirs" | wc -l`
2864 if test $m4dirs_count = 0; then
2865 # First use of gnulib in a package.
2866 # Any number of additional modules can be given.
2867 test -n "$supplied_libname" || supplied_libname=true
2868 test -n "$sourcebase" || sourcebase="lib"
2870 test -n "$docbase" || docbase="doc"
2871 test -n "$testsbase" || testsbase="tests"
2872 test -n "$macro_prefix" || macro_prefix="gl"
2875 if test $m4dirs_count = 1; then
2876 # There's only one use of gnulib here. Assume the user means it.
2877 # Any number of additional modules can be given.
2878 for m4base in $m4dirs; do
2882 # Ambiguous - guess what the user meant.
2883 if test $# = 0; then
2884 # No further arguments. Guess the user wants to update all of them.
2885 for m4base in $m4dirs; do
2886 # Perform func_import in a subshell, so that variable values
2888 # local_gnulib_dir, avoidlist, sourcebase, m4base, docbase,
2889 # testsbase, libname, lgpl, makefile_name, libtool, macro_prefix
2890 # don't propagate from one directory to another.
2891 (func_import) || func_exit 1
2895 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
2903 if test -z "$destdir"; then
2904 func_fatal_error "please specify --dir option"
2907 test -d "$destdir" \
2908 || func_fatal_error "could not create destination directory"
2909 test -n "$auxdir" || auxdir="build-aux"
2910 func_create_testdir "$destdir" "$*"
2913 create-megatestdir )
2914 if test -z "$destdir"; then
2915 func_fatal_error "please specify --dir option"
2917 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2918 test -n "$auxdir" || auxdir="build-aux"
2919 func_create_megatestdir "$destdir" "$*"
2923 test -n "$destdir" || destdir=testdir$$
2924 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2925 test -n "$auxdir" || auxdir="build-aux"
2926 func_create_testdir "$destdir" "$*"
2930 ../configure || func_exit 1
2932 make check || func_exit 1
2933 make distclean || func_exit 1
2934 remaining=`find . -type f -print`
2935 if test -n "$remaining"; then
2936 echo "Remaining files:" $remaining 1>&2
2937 echo "gnulib-tool: *** Stop." 1>&2
2946 test -n "$destdir" || destdir=testdir$$
2947 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2948 test -n "$auxdir" || auxdir="build-aux"
2949 func_create_megatestdir "$destdir" "$*"
2957 remaining=`find . -type f -print`
2958 if test -n "$remaining"; then
2959 echo "Remaining files:" $remaining 1>&2
2960 echo "gnulib-tool: *** Stop." 1>&2
2968 extract-description )
2972 if test -n "$module"; then
2973 func_get_description "$module"
2982 if test -n "$module"; then
2983 func_get_filelist "$module"
2988 extract-dependencies )
2992 if test -n "$module"; then
2993 func_get_dependencies "$module"
2998 extract-autoconf-snippet )
3002 if test -n "$module"; then
3003 func_get_autoconf_snippet "$module"
3008 extract-automake-snippet )
3012 if test -n "$module"; then
3013 func_get_automake_snippet "$module"
3018 extract-include-directive )
3022 if test -n "$module"; then
3023 func_get_include_directive "$module"
3032 if test -n "$module"; then
3033 func_get_license "$module"
3038 extract-maintainer )
3042 if test -n "$module"; then
3043 func_get_maintainer "$module"
3048 extract-tests-module )
3052 if test -n "$module"; then
3053 func_get_tests_module "$module"
3059 func_fatal_error "unknown operation mode --$mode" ;;
3063 # Undo the effect of the previous 'trap' command. Some shellology:
3064 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
3065 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
3066 # exit); for the others we need to call 'exit' explicitly. The value of $? is
3067 # 128 + signal number and is set before the trap-registered command is run.
3069 trap 'func_exit $?' 1 2 3 13 15
3074 # indent-tabs-mode: nil
3075 # whitespace-check-buffer-indent: nil