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-11 12:41: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 # 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
76 # outputs to stdout the --help usage message.
80 Usage: gnulib-tool --list
81 gnulib-tool --import [module1 ... moduleN]
83 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
84 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
85 gnulib-tool --test --dir=directory module1 ... moduleN
86 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
87 gnulib-tool --extract-description module
88 gnulib-tool --extract-filelist module
89 gnulib-tool --extract-dependencies module
90 gnulib-tool --extract-autoconf-snippet module
91 gnulib-tool --extract-automake-snippet module
92 gnulib-tool --extract-include-directive module
93 gnulib-tool --extract-license module
94 gnulib-tool --extract-maintainer module
95 gnulib-tool --extract-tests-module module
98 --list print the available module names
99 --import import the given modules into the current package;
100 if no modules are specified, update the current
101 package from the current gnulib
102 --update update the current package, restore files omitted
104 --create-testdir create a scratch package with the given modules
105 --create-megatestdir create a mega scratch package with the given modules
106 one by one and all together
107 --test test the combination of the given modules
108 (recommended to use CC=\"gcc -Wall\" here)
109 --megatest test the given modules one by one and all together
110 (recommended to use CC=\"gcc -Wall\" here)
111 --extract-description extract the description
112 --extract-filelist extract the list of files
113 --extract-dependencies extract the dependencies
114 --extract-autoconf-snippet extract the snippet for configure.ac
115 --extract-automake-snippet extract the snippet for library makefile
116 --extract-include-directive extract the #include directive
117 --extract-license report the license terms of the source files
119 --extract-maintainer report the maintainer(s) inside gnulib
120 --extract-tests-module report the unit test module, if it exists
123 --dir=DIRECTORY Specify the target directory.
124 For --import, this specifies where your
125 configure.ac can be found. Defaults to current
127 --local-dir=DIRECTORY Specify a local override directory where to look
128 up files before looking in gnulib's directory.
130 Options for --import:
131 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
132 --source-base=DIRECTORY
133 Directory relative to --dir where source code is
134 placed (default \"lib\").
135 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
136 placed (default \"m4\").
137 --doc-base=DIRECTORY Directory relative to --dir where doc files are
138 placed (default \"doc\").
139 --tests-base=DIRECTORY
140 Directory relative to --dir where unit tests are
141 placed (default \"tests\").
142 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
143 tools are placed (default \"build-aux\").
144 --with-tests Include unit tests for the included modules.
145 --avoid=MODULE Avoid including the given MODULE. Useful if you
146 have code that provides equivalent functionality.
147 This option can be repeated.
148 --lgpl Abort if modules aren't available under the LGPL.
149 Also modify license template from GPL to LGPL.
150 --makefile-name=NAME Name of makefile in automake syntax in the
151 source-base and tests-base directories
152 (default \"Makefile.am\").
153 --libtool Use libtool rules.
154 --no-libtool Don't use libtool rules.
155 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
156 'gl_INIT'. Default is 'gl'.
157 --no-changelog don't update or create ChangeLog files
159 Options for --import and --update:
160 --dry-run For --import, only print what would have been done.
161 -s, --symbolic, --symlink Make symbolic links instead of copying files.
162 --local-symlink Make symbolic links instead of copying files, only
163 for files from the local override directory.
165 Report bugs to <bug-gnulib@gnu.org>."
169 # outputs to stdout the --version message.
172 year=`echo "$last_checkin_date" | sed -e 's,/.*$,,'`
174 $progname (GNU $package) $version
175 Copyright (C) $year Free Software Foundation, Inc.
176 This is free software; see the source for copying conditions. There is NO
177 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
178 Written by" "Bruno Haible" "and" "Simon Josefsson"
181 # func_emit_copyright_notice
182 # outputs to stdout a header for a generated file.
183 func_emit_copyright_notice ()
185 echo "# Copyright (C) 2004-2006 Free Software Foundation, Inc."
187 echo "# This file is free software, distributed under the terms of the GNU"
188 echo "# General Public License. As a special exception to the GNU General"
189 echo "# Public License, this file may be distributed as part of a program"
190 echo "# that contains a configuration script generated by Autoconf, under"
191 echo "# the same distribution terms as the rest of that program."
193 echo "# Generated by gnulib-tool."
204 # creates a temporary directory.
206 # - tmp pathname of freshly created temporary directory
209 # Use the environment variable TMPDIR, falling back to /tmp. This allows
210 # users to specify a different temporary directory, for example, if their
211 # /tmp is filled up or too small.
214 # Use the mktemp program if available. If not available, hide the error
216 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
217 test -n "$tmp" && test -d "$tmp"
220 # Use a simple mkdir command. It is guaranteed to fail if the directory
221 # already exists. $RANDOM is bash specific and expands to empty in shells
222 # other than bash, ksh and zsh. Its use does not increase security;
223 # rather, it minimizes the probability of failure in a very cluttered /tmp
225 tmp=$TMPDIR/gl$$-$RANDOM
226 (umask 077 && mkdir "$tmp")
229 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
234 # func_append var value
235 # appends the given value to the shell variable var.
236 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
237 # Use bash's += operator. It reduces complexity of appending repeatedly to
238 # a single variable from O(n^2) to O(n).
246 eval "$1=\"\$$1\$2\""
250 # func_fatal_error message
251 # outputs to stderr a fatal error message, and terminates the program.
254 echo "gnulib-tool: *** $1" 1>&2
255 echo "gnulib-tool: *** Stop." 1>&2
259 # func_readlink SYMLINK
260 # outputs the target of the given symlink.
261 if (type -p readlink) > /dev/null 2>&1; then
264 # Use the readlink program from GNU coreutils.
270 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
271 # would do the wrong thing if the link target contains " -> ".
272 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
276 # func_relativize DIR1 DIR2
277 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
279 # - DIR1 relative pathname, relative to the current directory
280 # - DIR2 relative pathname, relative to the current directory
282 # - reldir relative pathname of DIR2, relative to DIR1
288 sed_first='s,^\([^/]*\)/.*$,\1,'
289 sed_rest='s,^[^/]*/*,,'
290 sed_last='s,^.*/\([^/]*\)$,\1,'
291 sed_butlast='s,/*[^/]*$,,'
292 while test -n "$dir1"; do
293 first=`echo "$dir1" | sed -e "$sed_first"`
294 if test "$first" != "."; then
295 if test "$first" = ".."; then
296 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
297 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
299 first2=`echo "$dir2" | sed -e "$sed_first"`
300 if test "$first2" = "$first"; then
301 dir2=`echo "$dir2" | sed -e "$sed_rest"`
305 dir0="$dir0"/"$first"
308 dir1=`echo "$dir1" | sed -e "$sed_rest"`
313 # func_relconcat DIR1 DIR2
314 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
316 # - DIR1 relative pathname, relative to the current directory
317 # - DIR2 relative pathname, relative to DIR1
319 # - relconcat DIR1/DIR2, relative to the current directory
324 sed_first='s,^\([^/]*\)/.*$,\1,'
325 sed_rest='s,^[^/]*/*,,'
326 sed_last='s,^.*/\([^/]*\)$,\1,'
327 sed_butlast='s,/*[^/]*$,,'
329 first=`echo "$dir2" | sed -e "$sed_first"`
330 if test "$first" = "."; then
331 dir2=`echo "$dir2" | sed -e "$sed_rest"`
332 if test -z "$dir2"; then
337 last=`echo "$dir1" | sed -e "$sed_last"`
338 while test "$last" = "."; do
339 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
340 last=`echo "$dir1" | sed -e "$sed_last"`
342 if test -z "$dir1"; then
346 if test "$first" = ".."; then
347 if test "$last" = ".."; then
348 relconcat="$dir1/$dir2"
351 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
352 dir2=`echo "$dir2" | sed -e "$sed_rest"`
353 if test -z "$dir1"; then
357 if test -z "$dir2"; then
362 relconcat="$dir1/$dir2"
370 # Like ln -s, except that SRC is given relative to the current directory (or
371 # absolute), not given relative to the directory of DEST.
377 *) # SRC is relative.
380 ln -s "`pwd`/$1" "$2" ;;
381 *) # DEST is relative too.
382 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
383 test -n "$ln_destdir" || ln_destdir="."
384 func_relativize "$ln_destdir" "$1"
392 # func_ln_if_changed SRC DEST
393 # Like func_ln, but avoids munging timestamps if the link is correct.
394 func_ln_if_changed ()
396 if test $# -ne 2; then
397 echo "usage: func_ln_if_changed SRC DEST" >&2
399 ln_target=`func_readlink "$2"`
400 if test -L "$2" && test "$1" = "$ln_target"; then
408 # Command-line option processing.
409 # Removes the OPTIONS from the arguments. Sets the variables:
410 # - mode list or import or create-testdir or create-megatestdir
411 # - destdir from --dir
412 # - local_gnulib_dir from --local-dir
413 # - libname, supplied_libname from --lib
414 # - sourcebase from --source-base
415 # - m4base from --m4-base
416 # - docbase from --doc-base
417 # - testsbase from --tests-base
418 # - auxdir from --aux-dir
419 # - inctests true if --with-tests was given, blank otherwise
420 # - avoidlist list of modules to avoid, from --avoid
421 # - lgpl true if --lgpl was given, blank otherwise
422 # - makefile_name from --makefile-name
423 # - libtool true if --libtool was given, false if --no-libtool was
424 # given, blank otherwise
425 # - macro_prefix from --macro-prefix
426 # - autoconf_minversion minimum supported autoconf version
427 # - do_changelog false if --no-changelog was given, : otherwise
428 # - doit : if actions shall be executed, false if only to be printed
429 # - symbolic true if --symlink was given, blank otherwise
430 # - lsymbolic true if --local-symlink was given, blank otherwise
455 while test $# -gt 0; do
460 --import | --impor | --impo | --imp | --im | --i )
463 --update | --updat | --upda | --upd | --up | --u )
466 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
469 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
470 mode=create-megatestdir
472 --test | --tes | --te | --t )
475 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
479 mode=`echo "X$1" | sed -e 's/^X--//'`
484 func_fatal_error "missing argument for --dir"
489 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
494 func_fatal_error "missing argument for --local-dir"
499 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
504 func_fatal_error "missing argument for --lib"
507 supplied_libname=true
510 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
511 supplied_libname=true
516 func_fatal_error "missing argument for --source-base"
521 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
526 func_fatal_error "missing argument for --m4-base"
531 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
536 func_fatal_error "missing argument for --doc-base"
541 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
546 func_fatal_error "missing argument for --tests-base"
551 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
556 func_fatal_error "missing argument for --aux-dir"
561 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
569 func_fatal_error "missing argument for --avoid"
571 func_append avoidlist " $1"
574 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
575 func_append avoidlist " $arg"
583 func_fatal_error "missing argument for --makefile-name"
588 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
599 func_fatal_error "missing argument for --macro-prefix"
604 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
606 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
612 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
615 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
618 --help | --hel | --he | --h )
621 --version | --versio | --versi | --vers | --ver | --ve | --v )
625 # Stop option processing
629 echo "gnulib-tool: unknown option $1" 1>&2
630 echo "Try 'gnulib-tool --help' for more information." 1>&2
637 if test "$mode" = update; then
638 if test $# != 0; then
639 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
640 echo "Try 'gnulib-tool --help' for more information." 1>&2
641 echo "If you really want to modify the gnulib configuration of your project," 1>&2
642 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
645 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
646 || test -n "$sourcebase" || test -n "$m4base" \
647 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
648 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
649 || test -n "$makefile_name" || test -n "$macro_prefix"; then
650 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
651 echo "Try 'gnulib-tool --help' for more information." 1>&2
652 echo "If you really want to modify the gnulib configuration of your project," 1>&2
653 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
659 # Determine the minimum supported autoconf version from the project's
661 DEFAULT_AUTOCONF_MINVERSION="2.59"
664 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
665 if test -f "$destdir"/configure.ac; then
666 configure_ac="$destdir/configure.ac"
668 if test -f "$destdir"/configure.in; then
669 configure_ac="$destdir/configure.in"
673 if test -f configure.ac; then
674 configure_ac="configure.ac"
676 if test -f configure.in; then
677 configure_ac="configure.in"
681 if test -n "$configure_ac"; then
682 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
683 # because when some m4 files are omitted from a CVS repository,
684 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
685 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
686 # autom4te: m4 failed with exit status: 1
693 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,prereqs="$prereqs \1",p
695 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
696 if test -n "$prereqs"; then
697 autoconf_minversion=`for version in $prereqs; do echo $version; done | $SORT -g -u | tail -1`
700 if test -z "$autoconf_minversion"; then
701 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
703 case "$autoconf_minversion" in
704 1.* | 2.[0-4]* | 2.5[0-8]*)
705 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
708 # Remove trailing slashes from the directory names. This is necessary for
709 # m4base (to avoid an error in func_import) and optional for the others.
710 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
711 case "$local_gnulib_dir" in
712 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
714 case "$sourcebase" in
715 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
718 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
721 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
724 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
727 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
732 /*) self_abspathname="$0" ;;
733 */*) self_abspathname=`pwd`/"$0" ;;
734 *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
735 if test -x "$d/$0" && test ! -d "$d/$0"; then
736 self_abspathname="$d/$0"
740 if test -z "$self_abspathname"; then
741 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
745 while test -h "$self_abspathname"; do
746 # Resolve symbolic link.
747 linkval=`func_readlink "$self_abspathname"`
748 test -n "$linkval" || break
750 /* ) self_abspathname="$linkval" ;;
751 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
754 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
758 if test "$signal" != 0; then
759 echo "caught signal $signal" >&2
763 for signal in 1 2 3 13 15; do
764 trap '{ signal='$signal'; func_exit 1; }' $signal
768 # func_lookup_file file
769 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
772 # - local_gnulib_dir from --local-dir
774 # - lookedup_file name of the merged (combined) file
775 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
779 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
780 lookedup_file="$local_gnulib_dir/$lkfile"
783 if test -f "$gnulib_dir/$lkfile"; then
784 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
785 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
787 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
788 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
789 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
790 lookedup_file="$tmp/$lkbase"
793 lookedup_file="$gnulib_dir/$lkfile"
797 func_fatal_error "file $gnulib_dir/$lkfile not found"
804 # - local_gnulib_dir from --local-dir
807 # Filter out metainformation files like README, which are not modules.
808 # Filter out unit test modules; they can be retrieved through
809 # --extract-tests-module if desired.
811 (cd "$gnulib_dir/modules" && ls -1)
812 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
813 (cd "$local_gnulib_dir/modules" && ls -1 | sed -e 's,\.diff$,,')
816 | sed -e '/^CVS$/d' -e '/^ChangeLog$/d' -e '/^COPYING$/d' -e '/^README$/d' -e '/^TEMPLATE$/d' -e '/^TEMPLATE-TESTS$/d' -e '/~$/d' \
817 | sed -e '/-tests$/d' \
822 # verifies a module name
824 # - local_gnulib_dir from --local-dir
825 # - module module name argument
826 func_verify_module ()
828 if { test -f "$gnulib_dir/modules/$module" \
829 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
830 && test -f "$local_gnulib_dir/modules/$module"; }; } \
831 && test "CVS" != "$module" \
832 && test "ChangeLog" != "$module" \
833 && test "COPYING" != "$module" \
834 && test "README" != "$module" \
835 && test "TEMPLATE" != "$module" \
836 && test "TEMPLATE-TESTS" != "$module"; then
837 # OK, $module is a correct module name.
838 # Verify that building the module description with 'patch' succeeds.
839 func_lookup_file "modules/$module"
841 echo "gnulib-tool: module $module doesn't exist" 1>&2
846 # func_verify_nontests_module
847 # verifies a module name, excluding tests modules
849 # - local_gnulib_dir from --local-dir
850 # - module module name argument
851 func_verify_nontests_module ()
855 * ) func_verify_module ;;
859 # func_verify_tests_module
860 # verifies a module name, considering only tests modules
862 # - local_gnulib_dir from --local-dir
863 # - module module name argument
864 func_verify_tests_module ()
867 *-tests ) func_verify_module ;;
872 sed_extract_prog=':[ ]*$/ {
875 s/^Description:[ ]*$//
877 s/^Depends-on:[ ]*$//
878 s/^configure\.ac:[ ]*$//
879 s/^Makefile\.am:[ ]*$//
882 s/^Maintainer:[ ]*$//
889 # func_get_description module
891 # - local_gnulib_dir from --local-dir
892 func_get_description ()
894 func_lookup_file "modules/$1"
895 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
898 # func_get_filelist module
900 # - local_gnulib_dir from --local-dir
903 func_lookup_file "modules/$1"
904 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
905 case "$autoconf_minversion" in
908 echo m4/onceonly_2_57.m4
913 # func_get_dependencies module
915 # - local_gnulib_dir from --local-dir
916 func_get_dependencies ()
918 # ${module}-tests always implicitly depends on ${module}.
919 echo "$1" | sed -n -e 's/-tests//p'
920 # Then the explicit dependencies listed in the module description.
921 func_lookup_file "modules/$1"
922 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
925 # func_get_autoconf_snippet module
927 # - local_gnulib_dir from --local-dir
928 func_get_autoconf_snippet ()
930 func_lookup_file "modules/$1"
931 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
934 # func_get_automake_snippet module
936 # - local_gnulib_dir from --local-dir
937 func_get_automake_snippet ()
939 func_lookup_file "modules/$1"
940 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
943 # *-tests module live in tests/, not lib/.
946 # Synthesize an EXTRA_DIST augmentation.
947 sed_combine_lines='/\\$/{
954 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
955 already_mentioned_files=` \
956 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
957 | sed -e "$sed_combine_lines" \
958 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
959 all_files=`func_get_filelist $1`
960 lib_files=`for f in $all_files; do \
964 done | sed -e 's,^lib/,,'`
965 # Remove $already_mentioned_files from $lib_files.
966 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
967 extra_files=`for f in $already_mentioned_files; do echo $f; done \
968 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
969 if test -n "$extra_files"; then
970 echo "EXTRA_DIST +=" $extra_files
973 # Synthesize also an EXTRA_lib_SOURCES augmentation.
974 # This is necessary so that automake can generate the right list of
976 # A possible approach would be to use autom4te --trace of the redefined
977 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
978 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
979 # inside autoconf's built-in macros are not missed).
980 # But it's simpler and more robust to do it here, based on the file list.
981 # If some .c file exists and is not used with AC_LIBOBJ - for example,
982 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
983 # automake will generate a useless dependency; this is harmless.
984 sed_extract_c_files='/\.c$/p'
985 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
986 if test -n "$extra_files"; then
987 echo "EXTRA_lib_SOURCES +=" $extra_files
994 # func_get_include_directive module
996 # - local_gnulib_dir from --local-dir
997 func_get_include_directive ()
999 func_lookup_file "modules/$1"
1000 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1001 sed -e 's/^\(["<]\)/#include \1/'
1004 # func_get_license module
1006 # - local_gnulib_dir from --local-dir
1009 func_lookup_file "modules/$1"
1010 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1013 # func_get_maintainer module
1015 # - local_gnulib_dir from --local-dir
1016 func_get_maintainer ()
1018 func_lookup_file "modules/$1"
1019 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1022 # func_get_tests_module module
1024 # - local_gnulib_dir from --local-dir
1025 func_get_tests_module ()
1027 # The naming convention for tests modules is hardwired: ${module}-tests.
1028 if test -f "$gnulib_dir/modules/$1"-tests \
1029 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1030 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1035 # func_acceptable module
1036 # tests whether a module is acceptable.
1038 # - avoidlist list of modules to avoid
1041 for avoid in $avoidlist; do
1042 if test "$avoid" = "$1"; then
1049 # func_modules_transitive_closure
1051 # - local_gnulib_dir from --local-dir
1052 # - modules list of specified modules
1053 # - inctests true if tests should be included, blank otherwise
1054 # - avoidlist list of modules to avoid
1055 # - tmp pathname of a temporary directory
1057 # - modules list of modules, including dependencies
1058 func_modules_transitive_closure ()
1060 # In order to process every module only once (for speed), process an "input
1061 # list" of modules, producing an "output list" of modules. During each round,
1062 # more modules can be queued in the input list. Once a module on the input
1063 # list has been processed, it is added to the "handled list", so we can avoid
1064 # to process it again.
1066 inmodules="$modules"
1068 while test -n "$inmodules"; do
1069 inmodules_this_round="$inmodules"
1070 inmodules= # Accumulator, queue for next round
1071 for module in $inmodules_this_round; do
1073 if test -n "$module"; then
1074 if func_acceptable $module; then
1075 func_append outmodules " $module"
1076 deps=`func_get_dependencies $module`
1077 # Duplicate dependencies are harmless, but Jim wants a warning.
1078 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1079 if test -n "$duplicated_deps"; then
1080 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1082 func_append inmodules " $deps"
1083 if test -n "$inctests"; then
1084 testsmodule=`func_get_tests_module $module`
1085 if test -n "$testsmodule"; then
1086 func_append inmodules " $testsmodule"
1092 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1093 # Remove $handledmodules from $inmodules.
1094 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1095 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1097 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1098 rm -f "$tmp"/queued-modules
1101 # func_modules_add_dummy
1103 # - local_gnulib_dir from --local-dir
1104 # - modules list of modules, including dependencies
1106 # - modules list of modules, including 'dummy' if needed
1107 func_modules_add_dummy ()
1110 sed_remove_backslash_newline=':a
1117 for module in $modules; do
1118 func_verify_nontests_module
1119 if test -n "$module"; then
1120 # Extract the value of "lib_SOURCES += ...".
1121 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1122 # Ignore .h files since they are not compiled.
1125 *) have_lib_SOURCES=yes ;;
1130 # Add the dummy module, to make sure the library will be non-empty.
1131 if test -z "$have_lib_SOURCES"; then
1132 func_append modules " dummy"
1136 # func_modules_to_filelist
1138 # - local_gnulib_dir from --local-dir
1139 # - modules list of modules, including dependencies
1141 # - files list of files
1142 func_modules_to_filelist ()
1145 for module in $modules; do
1147 if test -n "$module"; then
1148 fs=`func_get_filelist $module`
1149 func_append files " $fs"
1152 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1155 # func_emit_lib_Makefile_am
1156 # emits the contents of library makefile to standard output.
1158 # - local_gnulib_dir from --local-dir
1159 # - modules list of modules, including dependencies
1160 # - libname library name
1161 # - auxdir directory relative to destdir where to place build aux files
1162 # - makefile_name from --makefile-name
1163 # - libtool true if libtool will be used, false or blank otherwise
1164 # - macro_prefix prefix of gl_LIBOBJS macros to use
1165 # - actioncmd (optional) command that will reproduce this invocation
1167 # - uses_subdirs nonempty if object files in subdirs exist
1168 func_emit_lib_Makefile_am ()
1170 # When creating an includable Makefile.am snippet, augment variables with
1171 # += instead of assigning them.
1172 if test -n "$makefile_name"; then
1177 if test "$libtool" = true; then
1180 sed_eliminate_LDFLAGS=
1184 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1186 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1187 echo "## Process this file with automake to produce Makefile.in."
1188 func_emit_copyright_notice
1189 if test -n "$actioncmd"; then
1190 echo "# Reproduce by: $actioncmd"
1195 for module in $modules; do
1196 func_verify_nontests_module
1197 if test -n "$module"; then
1199 func_get_automake_snippet "$module" |
1200 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1201 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1202 sed -e "$sed_eliminate_LDFLAGS" |
1203 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1204 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1205 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
1206 if test "$module" = 'alloca'; then
1207 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1208 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1211 # Skip the contents if its entirely empty.
1212 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1213 echo "## begin gnulib module $module"
1216 echo "## end gnulib module $module"
1220 # Test whether there are some source files in subdirectories.
1221 for f in `func_get_filelist "$module"`; do
1223 lib/*/*.c) uses_subdirs=yes ;;
1229 if test -z "$makefile_name"; then
1230 # If there are source files in subdirectories, prevent collision of the
1231 # object files (example: hash.c and libxml/hash.c).
1233 if test -n "$uses_subdirs"; then
1234 subdir_options=' subdir-objects'
1236 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1239 if test -z "$makefile_name"; then
1240 echo "noinst_HEADERS ="
1241 echo "noinst_LIBRARIES ="
1242 echo "noinst_LTLIBRARIES ="
1243 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1244 # if you specify pkgdata_DATA to empty. This is a workaround.
1245 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1246 echo "pkgdata_DATA ="
1249 echo "BUILT_SOURCES ="
1252 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1253 if test -z "$makefile_name"; then
1254 echo "MOSTLYCLEANDIRS ="
1256 echo "DISTCLEANFILES ="
1257 echo "MAINTAINERCLEANFILES ="
1259 echo "AM_CPPFLAGS ="
1262 if grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1263 # One of the snippets already specifies an installation location for the
1264 # library. Don't confuse automake by saying it should not be installed.
1267 # By default, the generated library should not be installed.
1268 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1271 echo "${libname}_${libext}_SOURCES ="
1272 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1273 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1274 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1275 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1276 echo "EXTRA_${libname}_${libext}_SOURCES ="
1277 if test "$libtool" = true; then
1278 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1281 cat allsnippets.tmp \
1282 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1284 echo "mostlyclean-local: mostlyclean-generic"
1285 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1286 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1287 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1290 rm -f allsnippets.tmp
1293 # func_emit_tests_Makefile_am
1294 # emits the contents of tests makefile to standard output.
1296 # - local_gnulib_dir from --local-dir
1297 # - modules list of modules, including dependencies
1298 # - libname library name
1299 # - makefile_name from --makefile-name
1300 # - libtool true if libtool will be used, false or blank otherwise
1301 # - sourcebase relative directory containing lib source code
1302 # - m4base relative directory containing autoconf macros
1303 # - testsbase relative directory containing unit test code
1304 func_emit_tests_Makefile_am ()
1306 if test "$libtool" = true; then
1311 if test "$libtool" = true; then
1313 sed_eliminate_LDFLAGS=
1316 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1318 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1319 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1320 echo "## Process this file with automake to produce Makefile.in."
1321 func_emit_copyright_notice
1323 # Generate dependencies here, since it eases the debugging of test failures.
1324 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1326 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1329 for module in $modules; do
1330 func_verify_tests_module
1331 if test -n "$module"; then
1333 func_get_automake_snippet "$module" |
1334 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1335 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1336 sed -e "$sed_eliminate_LDFLAGS" |
1337 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1338 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1339 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
1341 # Skip the contents if its entirely empty.
1342 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1343 echo "## begin gnulib module $module"
1346 echo "## end gnulib module $module"
1353 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1354 # variable is needed to avoid an error from automake:
1355 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1358 echo "TESTS_ENVIRONMENT ="
1359 echo "noinst_PROGRAMS ="
1360 echo "check_PROGRAMS ="
1361 echo "noinst_HEADERS ="
1362 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1363 echo "pkgdata_DATA ="
1366 echo "BUILT_SOURCES ="
1368 echo "MOSTLYCLEANFILES = core *.stackdump"
1369 echo "MOSTLYCLEANDIRS ="
1371 echo "DISTCLEANFILES ="
1372 echo "MAINTAINERCLEANFILES ="
1374 echo "AM_CPPFLAGS = \\"
1375 echo " -I. -I\$(srcdir) \\"
1376 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1377 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1379 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1382 echo "# Clean up after Solaris cc."
1384 echo " rm -rf SunWS_cache"
1386 echo "mostlyclean-local: mostlyclean-generic"
1387 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1388 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1389 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1392 rm -f allsnippets.tmp
1395 # func_emit_initmacro_start
1396 # emits the first few statements of the gl_INIT macro to standard output.
1397 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1398 func_emit_initmacro_start ()
1400 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
1401 # platform-dependent object files in ${macro_prefix}_LIBOBJS instead of
1402 # LIBOBJS. The purpose is to allow several gnulib instantiations under
1403 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
1405 # Furthermore it avoids an automake error like this when a Makefile.am
1406 # that uses pieces of gnulib also uses $(LIBOBJ):
1407 # automatically discovered file `error.c' should not be explicitly mentioned
1408 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix}_LIBOBJ]))"
1409 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix}_REPLACE_FUNCS]))"
1410 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
1411 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
1412 # automatically discovered file `error.c' should not be explicitly mentioned
1413 # We let automake know about the files to be distributed through the
1414 # EXTRA_lib_SOURCES variable.
1415 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix}_LIBSOURCES]))"
1418 # func_emit_initmacro_end
1419 # emits the last few statements of the gl_INIT macro to standard output.
1420 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1421 func_emit_initmacro_end ()
1423 echo " m4_popdef([AC_LIBSOURCES])"
1424 echo " m4_popdef([AC_REPLACE_FUNCS])"
1425 echo " m4_popdef([AC_LIBOBJ])"
1426 echo " AC_CONFIG_COMMANDS_PRE(["
1427 echo " ${macro_prefix}_libobjs="
1428 echo " ${macro_prefix}_ltlibobjs="
1429 echo " if test -n \"\$${macro_prefix}_LIBOBJS\"; then"
1430 echo " # Remove the extension."
1431 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
1432 echo " for i in \`for i in \$${macro_prefix}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
1433 echo " ${macro_prefix}_libobjs=\"\$${macro_prefix}_libobjs \$i.\$ac_objext\""
1434 echo " ${macro_prefix}_ltlibobjs=\"\$${macro_prefix}_ltlibobjs \$i.lo\""
1437 echo " AC_SUBST([${macro_prefix}_LIBOBJS], [\$${macro_prefix}_libobjs])"
1438 echo " AC_SUBST([${macro_prefix}_LTLIBOBJS], [\$${macro_prefix}_ltlibobjs])"
1442 # func_emit_initmacro_done
1443 # emits a few statements after the gl_INIT macro to standard output.
1444 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1445 func_emit_initmacro_done ()
1448 echo "# Like AC_LIBOBJ, except that the module name goes"
1449 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1450 echo "AC_DEFUN([${macro_prefix}_LIBOBJ],"
1451 echo " [${macro_prefix}_LIBOBJS=\"\$${macro_prefix}_LIBOBJS \$1.\$ac_objext\"])"
1453 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
1454 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1455 echo "AC_DEFUN([${macro_prefix}_REPLACE_FUNCS],"
1456 echo " [AC_CHECK_FUNCS([\$1], , [${macro_prefix}_LIBOBJ(\$ac_func)])])"
1458 echo "# Like AC_LIBSOURCES, except that it does nothing."
1459 echo "# We rely on EXTRA_lib..._SOURCES instead."
1460 echo "AC_DEFUN([${macro_prefix}_LIBSOURCES],"
1464 # func_import modules
1465 # Uses also the variables
1466 # - destdir target directory
1467 # - local_gnulib_dir from --local-dir
1468 # - libname library name
1469 # - sourcebase directory relative to destdir where to place source code
1470 # - m4base directory relative to destdir where to place *.m4 macros
1471 # - docbase directory relative to destdir where to place doc files
1472 # - testsbase directory relative to destdir where to place unit test code
1473 # - auxdir directory relative to destdir where to place build aux files
1474 # - inctests true if --with-tests was given, blank otherwise
1475 # - avoidlist list of modules to avoid, from --avoid
1476 # - lgpl true if library's license shall be LGPL, blank otherwise
1477 # - makefile_name from --makefile-name
1478 # - libtool true if --libtool was given, false if --no-libtool was
1479 # given, blank otherwise
1480 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1481 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1482 # - autoconf_minversion minimum supported autoconf version
1483 # - doit : if actions shall be executed, false if only to be printed
1484 # - symbolic true if files should be symlinked, copied otherwise
1485 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1489 # Get the cached settings.
1490 cached_local_gnulib_dir=
1491 cached_specified_modules=
1499 cached_makefile_name=
1501 cached_macro_prefix=
1503 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1504 cached_libtool=false
1510 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
1513 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1516 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1519 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1522 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1525 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1528 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1531 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1534 s,^.*$,cached_lgpl=true,p
1536 /gl_MAKEFILE_NAME(/ {
1537 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
1540 s,^.*$,cached_libtool=true,p
1542 /gl_MACRO_PREFIX(/ {
1543 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
1545 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
1546 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1551 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
1552 s,^.*$,cached_files=",p
1564 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1568 # Merge the cached settings with the specified ones.
1569 # The m4base must be the same as expected from the pathname.
1570 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1571 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1573 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
1574 # is relative to $destdir, whereas the one we use is relative to . or absolute.
1575 if test -z "$local_gnulib_dir"; then
1576 if test -n "$cached_local_gnulib_dir"; then
1579 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1581 case "$cached_local_gnulib_dir" in
1583 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1585 func_relconcat "$destdir" "$cached_local_gnulib_dir"
1586 local_gnulib_dir="$relconcat" ;;
1591 # Append the cached and the specified module names. So that
1592 # "gnulib-tool --import foo" means to add the module foo.
1593 specified_modules="$cached_specified_modules $1"
1594 # Append the cached and the specified avoidlist. This is probably better
1595 # than dropping the cached one when --avoid is specified at least once.
1596 avoidlist=`echo $cached_avoidlist $avoidlist`
1597 # The sourcebase defaults to the cached one.
1598 if test -z "$sourcebase"; then
1599 sourcebase="$cached_sourcebase"
1600 if test -z "$sourcebase"; then
1601 func_fatal_error "missing --source-base option"
1604 # The docbase defaults to the cached one.
1605 if test -z "$docbase"; then
1606 docbase="$cached_docbase"
1607 if test -z "$docbase"; then
1608 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."
1611 # The testsbase defaults to the cached one.
1612 if test -z "$testsbase"; then
1613 testsbase="$cached_testsbase"
1614 if test -z "$testsbase"; then
1615 func_fatal_error "missing --tests-base option"
1618 # The libname defaults to the cached one.
1619 if test -z "$supplied_libname"; then
1620 libname="$cached_libname"
1621 if test -z "$libname"; then
1622 func_fatal_error "missing --lib option"
1625 # Require LGPL if specified either way.
1626 if test -z "$lgpl"; then
1629 # The makefile_name defaults to the cached one.
1630 if test -z "$makefile_name"; then
1631 makefile_name="$cached_makefile_name"
1633 # Use libtool if specified either way, or if guessed.
1634 if test -z "$libtool"; then
1635 if test -n "$cached_m4base"; then
1636 libtool="$cached_libtool"
1638 libtool="$guessed_libtool"
1641 # The macro_prefix defaults to the cached one.
1642 if test -z "$macro_prefix"; then
1643 macro_prefix="$cached_macro_prefix"
1644 if test -z "$macro_prefix"; then
1645 func_fatal_error "missing --macro-prefix option"
1649 # Canonicalize the list of specified modules.
1650 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
1652 # Determine final module list.
1653 modules="$specified_modules"
1654 func_modules_transitive_closure
1655 echo "Module list with included dependencies:"
1656 echo "$modules" | sed -e 's/^/ /'
1658 # Add the dummy module if needed.
1659 func_modules_add_dummy
1661 # If --lgpl, verify that the licenses of modules are compatible.
1662 if test -n "$lgpl"; then
1663 for module in $modules; do
1664 license=`func_get_license $module`
1666 LGPL | 'GPLed build tool') ;;
1667 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
1668 *) func_fatal_error "incompatible license on module $module: $license" ;;
1673 # Determine script to apply to imported library files.
1674 sed_transform_lib_file=
1675 for module in $modules; do
1676 if test $module = config-h; then
1677 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
1678 sed_transform_lib_file=$sed_transform_lib_file'
1679 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
1684 if test -n "$lgpl"; then
1686 sed_transform_lib_file=$sed_transform_lib_file'
1687 s/GNU General/GNU Lesser General/g
1688 s/version 2\([ ,]\)/version 2.1\1/g
1692 # Determine final file list.
1693 func_modules_to_filelist
1695 echo "$files" | sed -e 's/^/ /'
1698 || func_fatal_error "refusing to do nothing"
1700 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
1701 new_files="$files m4/gnulib-tool.m4"
1702 old_files="$cached_files"
1703 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
1704 func_append old_files " m4/gnulib-tool.m4"
1707 sed_rewrite_old_files="\
1708 s,^build-aux/,$auxdir/,
1709 s,^doc/,$cached_docbase/,
1710 s,^lib/,$cached_sourcebase/,
1711 s,^m4/,$cached_m4base/,
1712 s,^tests/,$cached_testsbase/,"
1713 sed_rewrite_new_files="\
1714 s,^build-aux/,$auxdir/,
1716 s,^lib/,$sourcebase/,
1718 s,^tests/,$testsbase/,"
1720 # Create directories.
1721 { echo "$sourcebase"
1723 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
1724 if test -n "$docfiles"; then
1727 if test -n "$inctests"; then
1731 for f in $files; do echo $f; done \
1732 | sed -e "$sed_rewrite_new_files" \
1733 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
1736 { # Rearrange file descriptors. Needed because "while ... done < ..."
1737 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1738 exec 5<&0 < "$tmp"/dirs
1740 if test ! -d "$destdir/$d"; then
1742 echo "Creating directory $destdir/$d"
1743 mkdir -p "$destdir/$d" || func_fatal_error "failed"
1745 echo "Create directory $destdir/$d"
1752 # func_dest_tmpfilename file
1753 # determines the name of a temporary file (file is relative to destdir).
1755 # - tmpfile absolute filename of the temporary file
1756 func_dest_tmpfilename ()
1759 # Put the new contents of $file in a file in the same directory (needed
1760 # to guarantee that an 'mv' to "$destdir/$file" works).
1761 tmpfile="$destdir/$1.tmp"
1763 # Put the new contents of $file in a file in a temporary directory
1764 # (because the directory of "$file" might not exist).
1765 tmpfile="$tmp"/`basename "$1"`.tmp
1769 # Copy files or make symbolic links. Remove obsolete files.
1771 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1772 # representing the files according to the last gnulib-tool invocation.
1773 for f in $old_files; do echo $f; done \
1774 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
1777 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1778 # representing the files after this gnulib-tool invocation.
1779 for f in $new_files; do echo $f; done \
1780 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
1783 # First the files that are in old-files, but not in new-files:
1784 sed_take_first_column='s,'"$delimiter"'.*,,'
1785 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
1786 # Remove the file. Do nothing if the user already removed it.
1787 if test -f "$destdir/$g"; then
1789 echo "Removing file $g (backup in ${g}~)"
1790 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1792 echo "Remove file $g (backup in ${g}~)"
1796 # func_add_or_update handles a file that ought to be present afterwards.
1798 # - f the original file name
1799 # - g the rewritten file name
1800 # - already_present nonempty if the file already exists, empty otherwise
1801 func_add_or_update ()
1803 func_dest_tmpfilename "$g"
1804 func_lookup_file "$f"
1805 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
1806 if test -n "$sed_transform_lib_file"; then
1809 sed -e "$sed_transform_lib_file" \
1810 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
1814 if test -f "$destdir/$g"; then
1815 # The file already exists.
1816 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1817 : # The file has not changed.
1821 if test -n "$already_present"; then
1822 echo "Updating file $g (backup in ${g}~)"
1824 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
1826 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1827 if { test -n "$symbolic" \
1828 || { test -n "$lsymbolic" \
1829 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1830 && test -z "$lookedup_tmp" \
1831 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1832 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1834 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1837 if test -n "$already_present"; then
1838 echo "Update file $g (backup in ${g}~)"
1840 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
1846 # Don't protest if the file should be there but isn't: it happens
1847 # frequently that developers don't put autogenerated files into CVS.
1849 echo "Copying file $g"
1850 if { test -n "$symbolic" \
1851 || { test -n "$lsymbolic" \
1852 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1853 && test -z "$lookedup_tmp" \
1854 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1855 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1857 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1865 # Then the files that are in new-files, but not in old-files:
1866 sed_take_last_column='s,^.*'"$delimiter"',,'
1868 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
1869 | sed -e "$sed_take_last_column" \
1870 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
1871 { # Rearrange file descriptors. Needed because "while ... done < ..."
1872 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1873 exec 5<&0 < "$tmp"/added-files
1879 # Then the files that are in new-files and in old-files:
1880 already_present=true
1881 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
1882 | sed -e "$sed_take_last_column" \
1883 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
1884 { # Rearrange file descriptors. Needed because "while ... done < ..."
1885 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1886 exec 5<&0 < "$tmp"/kept-files
1893 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
1894 actioncmd="gnulib-tool --import"
1895 func_append actioncmd " --dir=$destdir"
1896 if test -n "$local_gnulib_dir"; then
1897 func_append actioncmd " --local-dir=$local_gnulib_dir"
1899 func_append actioncmd " --lib=$libname"
1900 func_append actioncmd " --source-base=$sourcebase"
1901 func_append actioncmd " --m4-base=$m4base"
1902 func_append actioncmd " --doc-base=$docbase"
1903 func_append actioncmd " --aux-dir=$auxdir"
1904 for module in $avoidlist; do
1905 func_append actioncmd " --avoid=$module"
1907 if test -n "$lgpl"; then
1908 func_append actioncmd " --lgpl"
1910 if test -n "$makefile_name"; then
1911 func_append actioncmd " --makefile-name=$makefile_name"
1913 if test "$libtool" = true; then
1914 func_append actioncmd " --libtool"
1916 func_append actioncmd " --no-libtool"
1918 func_append actioncmd " --macro-prefix=$macro_prefix"
1919 func_append actioncmd " `echo $specified_modules`"
1921 # Default the makefile name to Makefile.am.
1922 if test -n "$makefile_name"; then
1923 makefile_am=$makefile_name
1925 makefile_am=Makefile.am
1928 # Create library makefile.
1929 func_dest_tmpfilename $sourcebase/$makefile_am
1930 func_emit_lib_Makefile_am > "$tmpfile"
1931 if test -f "$destdir"/$sourcebase/$makefile_am; then
1932 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
1936 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
1937 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
1938 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
1940 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
1946 echo "Creating $sourcebase/$makefile_am"
1947 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
1949 echo "Create $sourcebase/$makefile_am"
1954 # Create m4/gnulib-cache.m4.
1955 func_dest_tmpfilename $m4base/gnulib-cache.m4
1957 func_emit_copyright_notice
1959 echo "# This file represents the specification of how gnulib-tool is used."
1960 echo "# It acts as a cache: It is written and read by gnulib-tool."
1961 echo "# In projects using CVS, this file is meant to be stored in CVS,"
1962 echo "# like the configure.ac and various Makefile.am files."
1965 echo "# Specification in the form of a command-line invocation:"
1968 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
1969 # Store the local_gnulib_dir relative to destdir.
1970 case "$local_gnulib_dir" in
1972 relative_local_gnulib_dir="$local_gnulib_dir" ;;
1975 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
1977 # destdir, local_gnulib_dir are both relative.
1978 func_relativize "$destdir" "$local_gnulib_dir"
1979 relative_local_gnulib_dir="$reldir" ;;
1982 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
1983 echo "gl_MODULES(["`echo $specified_modules`"])"
1984 echo "gl_AVOID([$avoidlist])"
1985 echo "gl_SOURCE_BASE([$sourcebase])"
1986 echo "gl_M4_BASE([$m4base])"
1987 echo "gl_DOC_BASE([$docbase])"
1988 echo "gl_TESTS_BASE([$testsbase])"
1989 echo "gl_LIB([$libname])"
1990 test -z "$lgpl" || echo "gl_LGPL"
1991 echo "gl_MAKEFILE_NAME([$makefile_name])"
1992 if test "$libtool" = true; then
1995 echo "gl_MACRO_PREFIX([$macro_prefix])"
1997 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1998 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2002 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2003 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2004 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2006 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2010 echo "# gnulib-cache.m4 ends here"
2017 echo "Creating $m4base/gnulib-cache.m4"
2018 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2020 echo "Create $m4base/gnulib-cache.m4"
2026 # Create m4/gnulib-comp.m4.
2027 func_dest_tmpfilename $m4base/gnulib-comp.m4
2029 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2030 func_emit_copyright_notice
2032 echo "# This file represents the compiled summary of the specification in"
2033 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2034 echo "# to be invoked from configure.ac."
2035 echo "# In projects using CVS, this file can be treated like other built files."
2038 echo "# This macro should be invoked from $configure_ac, in the section"
2039 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2040 echo "# any checks for libraries, header files, types and library functions."
2041 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2043 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2044 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2045 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2046 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2047 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2048 if test -n "$uses_subdirs"; then
2049 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2051 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2052 echo " AC_REQUIRE([AC_GNU_SOURCE])"
2054 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2055 echo " AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])"
2057 if grep gl_LOCK "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2058 echo " AC_REQUIRE([gl_LOCK_EARLY])"
2062 echo "# This macro should be invoked from $configure_ac, in the section"
2063 echo "# \"Check for header files, types and library functions\"."
2064 echo "AC_DEFUN([${macro_prefix}_INIT],"
2066 func_emit_initmacro_start
2067 if test "$libtool" = true; then
2068 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2069 echo " gl_cond_libtool=true"
2071 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2072 echo " gl_cond_libtool=false"
2074 echo " gl_ltlibdeps="
2076 echo " gl_source_base='$sourcebase'"
2077 if test "$auxdir" != "build-aux"; then
2078 sed_replace_build_aux='
2080 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2081 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2084 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2086 sed_replace_build_aux=
2088 for module in $modules; do
2090 if test -n "$module"; then
2091 func_get_autoconf_snippet "$module" \
2092 | sed -e '/^$/d;' -e 's/^/ /' \
2093 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
2094 -e "$sed_replace_build_aux"
2095 if test "$module" = 'alloca' && test "$libtool" = true; then
2096 echo 'changequote(,)dnl'
2097 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
2098 echo 'changequote([, ])dnl'
2099 echo 'AC_SUBST([LTALLOCA])'
2103 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2104 # created using libtool, because libtool already handles the dependencies.
2105 if test "$libtool" != true; then
2106 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2107 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2108 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2109 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2110 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2112 func_emit_initmacro_end
2114 func_emit_initmacro_done
2116 echo "# This macro records the list of files which have been installed by"
2117 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
2118 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
2119 echo "$files" | sed -e 's,^, ,'
2122 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2123 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
2127 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2128 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
2129 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2131 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2135 echo "# gnulib-comp.m4 ends here"
2142 echo "Creating $m4base/gnulib-comp.m4"
2143 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2145 echo "Create $m4base/gnulib-comp.m4"
2151 if test -n "$inctests"; then
2152 # Create tests makefile.
2153 func_dest_tmpfilename $testsbase/$makefile_am
2154 func_emit_tests_Makefile_am > "$tmpfile"
2155 if test -f "$destdir"/$testsbase/$makefile_am; then
2156 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
2160 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2161 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
2162 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2164 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2170 echo "Creating $testsbase/$makefile_am"
2171 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2173 echo "Create $testsbase/$makefile_am"
2181 echo "You may need to add #include directives for the following .h files."
2182 # Intersect $specified_modules and $modules
2183 # (since $specified_modules is not necessarily of subset of $modules - some
2184 # may have been skipped through --avoid, and since the elements of $modules
2185 # but not in $specified_modules can go away without explicit notice - through
2186 # changes in the module dependencies).
2187 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
2188 echo "$modules" > "$tmp"/modules2 # also a sorted list, one module per line
2189 # First the #include <...> directives without #ifs, sorted for convenience,
2190 # then the #include "..." directives without #ifs, sorted for convenience,
2191 # then the #include directives that are surrounded by #ifs. Not sorted.
2192 for module in `join "$tmp"/modules1 "$tmp"/modules2`; do
2193 include_directive=`func_get_include_directive "$module"`
2194 case "$nl$include_directive" in
2196 echo "$include_directive" 1>&5
2199 echo "$include_directive" | grep -v 'include "' 1>&6
2200 echo "$include_directive" | grep 'include "' 1>&7
2203 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
2205 LC_ALL=C sort -u "$tmp"/include-angles
2206 LC_ALL=C sort -u "$tmp"/include-quotes
2207 cat "$tmp"/include-if
2208 ) | sed -e '/^$/d' -e 's/^/ /'
2209 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
2212 echo "Don't forget to"
2213 if test "$makefile_am" = Makefile.am; then
2214 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2216 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
2218 if test -n "$inctests"; then
2219 if test "$makefile_am" = Makefile.am; then
2220 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2222 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
2225 if test "$makefile_am" = Makefile.am; then
2226 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
2227 sourcebase_base=`basename "$sourcebase"`
2228 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
2230 if test -n "$inctests"; then
2231 if test "$makefile_am" = Makefile.am; then
2232 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
2233 testsbase_base=`basename "$testsbase"`
2234 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
2237 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
2238 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
2239 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
2242 # func_create_testdir testdir modules
2244 # - local_gnulib_dir from --local-dir
2245 # - auxdir directory relative to destdir where to place build aux files
2246 func_create_testdir ()
2250 if test -z "$modules"; then
2251 # All modules together.
2252 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2253 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2254 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
2255 modules=`func_all_modules`
2256 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
2258 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
2260 # Check that the license of every module is consistent with the license of
2262 saved_modules="$modules"
2263 for requested_module in $saved_modules; do
2264 requested_license=`func_get_license "$requested_module"`
2265 if test "$requested_license" != GPL; then
2266 # Here we use func_modules_transitive_closure, not just
2267 # func_get_dependencies, so that we also detect weird situations like
2268 # an LGPL module which depends on a GPLed build tool module which depends
2270 modules="$requested_module"
2271 func_modules_transitive_closure
2272 for module in $modules; do
2273 license=`func_get_license "$module"`
2275 LGPL | 'GPLed build tool') ;;
2276 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2277 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
2282 modules="$saved_modules"
2284 # Subdirectory names.
2291 # Determine final module list.
2292 func_modules_transitive_closure
2293 echo "Module list with included dependencies:"
2294 echo "$modules" | sed -e 's/^/ /'
2296 # Add the dummy module if needed.
2297 func_modules_add_dummy
2299 # Determine final file list.
2300 func_modules_to_filelist
2302 echo "$files" | sed -e 's/^/ /'
2304 sed_rewrite_files="\
2305 s,^build-aux/,$auxdir/,
2307 s,^lib/,$sourcebase/,
2309 s,^tests/,$testsbase/,"
2311 # Create directories.
2312 for f in $files; do echo $f; done \
2313 | sed -e "$sed_rewrite_files" \
2314 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2315 | LC_ALL=C sort -u \
2317 { # Rearrange file descriptors. Needed because "while ... done < ..."
2318 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2319 exec 5<&0 < "$tmp"/dirs
2321 mkdir -p "$testdir/$d"
2326 # Copy files or make symbolic links.
2328 for f in $files; do echo $f; done \
2329 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
2332 { # Rearrange file descriptors. Needed because "while ... done < ..."
2333 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2334 exec 5<&0 < "$tmp"/files
2336 func_lookup_file "$f"
2337 if test -n "$lookedup_tmp"; then
2338 cp -p "$lookedup_file" "$testdir/$g"
2340 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
2341 if { test -n "$symbolic" \
2342 || { test -n "$lsymbolic" \
2343 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
2344 func_ln "$lookedup_file" "$testdir/$g"
2346 cp -p "$lookedup_file" "$testdir/$g"
2353 # Create $sourcebase/Makefile.am.
2354 mkdir -p "$testdir/$sourcebase"
2355 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
2357 # Create $m4base/Makefile.am.
2358 mkdir -p "$testdir/$m4base"
2359 (echo "## Process this file with automake to produce Makefile.in."
2365 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
2368 ) > "$testdir/$m4base/Makefile.am"
2370 subdirs="$sourcebase $m4base"
2371 subdirs_with_configure_ac=""
2373 if false && test -f "$testdir"/$m4base/gettext.m4; then
2374 # Avoid stupid error message from automake:
2375 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
2376 mkdir -p "$testdir/po"
2377 (echo "## Process this file with automake to produce Makefile.in."
2378 ) > "$testdir/po/Makefile.am"
2379 func_append subdirs " po"
2382 if test -n "$inctests"; then
2383 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
2384 # Create $testsbase/Makefile.am.
2385 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
2386 # Create $testsbase/configure.ac.
2387 (echo "# Process this file with autoconf to produce a configure script."
2388 echo "AC_INIT([dummy], [0])"
2389 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
2390 echo "AM_INIT_AUTOMAKE"
2392 echo "AM_CONFIG_HEADER([config.h])"
2395 echo "AC_PROG_INSTALL"
2396 echo "AC_PROG_MAKE_SET"
2397 echo "AC_PROG_RANLIB"
2399 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2400 echo "AC_GNU_SOURCE"
2403 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2404 echo "gl_USE_SYSTEM_EXTENSIONS"
2407 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2408 echo "gl_LOCK_EARLY"
2411 if test "$libtool" = true; then
2412 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2413 echo "gl_cond_libtool=true"
2415 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2416 echo "gl_cond_libtool=false"
2418 echo "gl_ltlibdeps="
2420 # Wrap the set of autoconf snippets into an autoconf macro that is then
2421 # invoked. This is needed because autoconf does not support AC_REQUIRE
2423 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2424 # but we want the AC_REQUIRE to have its normal meaning (provide one
2425 # expansion of the required macro before the current point, and only one
2427 echo "AC_DEFUN([gl_INIT], ["
2428 func_emit_initmacro_start
2429 sed_replace_build_aux='
2431 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2432 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
2435 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2436 # We don't have explicit ordering constraints between the various
2437 # autoconf snippets. It's cleanest to put those of the library before
2438 # those of the tests.
2439 echo "gl_source_base='../$sourcebase'"
2440 for module in $modules; do
2441 func_verify_nontests_module
2442 if test -n "$module"; then
2443 func_get_autoconf_snippet "$module" \
2444 | sed -e "$sed_replace_build_aux"
2447 echo "gl_source_base='.'"
2448 for module in $modules; do
2449 func_verify_tests_module
2450 if test -n "$module"; then
2451 func_get_autoconf_snippet "$module" \
2452 | sed -e "$sed_replace_build_aux"
2455 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2456 # created using libtool, because libtool already handles the dependencies.
2457 if test "$libtool" != true; then
2458 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2459 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2460 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2461 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2462 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2464 func_emit_initmacro_end
2466 func_emit_initmacro_done
2470 # Usually $testsbase/config.h will be a superset of config.h. Verify this
2471 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
2472 echo "AH_TOP([#include \"../config.h\"])"
2474 echo "AC_OUTPUT([Makefile])"
2475 ) > "$testdir/$testsbase/configure.ac"
2476 func_append subdirs " $testsbase"
2477 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
2480 # Create Makefile.am.
2481 (echo "## Process this file with automake to produce Makefile.in."
2483 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2485 echo "SUBDIRS = $subdirs"
2487 echo "ACLOCAL_AMFLAGS = -I $m4base"
2488 ) > "$testdir/Makefile.am"
2490 # Create configure.ac.
2491 (echo "# Process this file with autoconf to produce a configure script."
2492 echo "AC_INIT([dummy], [0])"
2493 if test "$auxdir" != "."; then
2494 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2496 echo "AM_INIT_AUTOMAKE"
2498 echo "AM_CONFIG_HEADER([config.h])"
2501 echo "AC_PROG_INSTALL"
2502 echo "AC_PROG_MAKE_SET"
2504 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2505 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2506 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2507 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2509 echo "AC_PROG_RANLIB"
2511 if test -n "$uses_subdirs"; then
2512 echo "AM_PROG_CC_C_O"
2515 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2516 echo "AC_GNU_SOURCE"
2519 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2520 echo "gl_USE_SYSTEM_EXTENSIONS"
2523 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2524 echo "gl_LOCK_EARLY"
2527 if test "$libtool" = true; then
2528 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2529 echo "gl_cond_libtool=true"
2531 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2532 echo "gl_cond_libtool=false"
2534 echo "gl_ltlibdeps="
2536 echo "gl_source_base='$sourcebase'"
2537 # Wrap the set of autoconf snippets into an autoconf macro that is then
2538 # invoked. This is needed because autoconf does not support AC_REQUIRE
2540 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2541 # but we want the AC_REQUIRE to have its normal meaning (provide one
2542 # expansion of the required macro before the current point, and only one
2544 echo "AC_DEFUN([gl_INIT], ["
2545 func_emit_initmacro_start
2546 if test "$auxdir" != "build-aux"; then
2547 sed_replace_build_aux='
2549 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2550 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2553 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2555 sed_replace_build_aux=
2557 for module in $modules; do
2558 func_verify_nontests_module
2559 if test -n "$module"; then
2560 func_get_autoconf_snippet "$module" \
2561 | sed -e "$sed_replace_build_aux"
2564 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2565 # created using libtool, because libtool already handles the dependencies.
2566 if test "$libtool" != true; then
2567 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2568 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2569 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2570 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2571 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2573 func_emit_initmacro_end
2575 func_emit_initmacro_done
2579 if test -n "$subdirs_with_configure_ac"; then
2580 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
2582 makefiles="Makefile"
2583 for d in $subdirs; do
2584 # For subdirs that have a configure.ac by their own, it's the subdir's
2585 # configure.ac which creates the subdir's Makefile.am, not this one.
2586 case " $subdirs_with_configure_ac " in
2588 *) func_append makefiles " $d/Makefile" ;;
2591 echo "AC_OUTPUT([$makefiles])"
2592 ) > "$testdir/configure.ac"
2594 # Create autogenerated files.
2596 # Do not use "${AUTORECONF} --force --install", because it may invoke
2597 # autopoint, which brings in older versions of some of our .m4 files.
2598 if test -f $m4base/gettext.m4; then
2599 echo "executing ${AUTOPOINT} --force"
2600 ${AUTOPOINT} --force || func_exit 1
2601 for f in $m4base/*.m4~; do
2602 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2605 echo "executing ${ACLOCAL} -I $m4base"
2606 ${ACLOCAL} -I $m4base || func_exit 1
2607 if ! test -d build-aux; then
2608 echo "executing mkdir build-aux"
2609 mkdir build-aux || func_exit 1
2611 echo "executing ${AUTOCONF}"
2612 ${AUTOCONF} || func_exit 1
2613 echo "executing ${AUTOHEADER}"
2614 ${AUTOHEADER} || func_exit 1
2615 echo "executing ${AUTOMAKE} --add-missing --copy"
2616 ${AUTOMAKE} --add-missing --copy || func_exit 1
2618 if test -n "$inctests"; then
2619 # Create autogenerated files.
2620 (cd "$testdir/$testsbase" || func_exit 1
2621 # Do not use "${AUTORECONF} --force --install", because it may invoke
2622 # autopoint, which brings in older versions of some of our .m4 files.
2623 if test -f ../$m4base/gettext.m4; then
2624 echo "executing ${AUTOPOINT} --force"
2625 ${AUTOPOINT} --force || func_exit 1
2626 for f in ../$m4base/*.m4~; do
2627 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2630 echo "executing ${ACLOCAL} -I ../$m4base"
2631 ${ACLOCAL} -I ../$m4base || func_exit 1
2632 if ! test -d ../build-aux; then
2633 echo "executing mkdir ../build-aux"
2636 echo "executing ${AUTOCONF}"
2637 ${AUTOCONF} || func_exit 1
2638 echo "executing ${AUTOHEADER}"
2639 ${AUTOHEADER} || func_exit 1
2640 echo "executing ${AUTOMAKE} --add-missing --copy"
2641 ${AUTOMAKE} --add-missing --copy || func_exit 1
2644 if grep '^BUILT_SOURCES *+=' "$testdir/$sourcebase/Makefile.am" > /dev/null; then
2646 ./configure || func_exit 1
2648 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
2649 make built_sources || func_exit 1
2651 make distclean || func_exit 1
2656 # func_create_megatestdir megatestdir allmodules
2658 # - local_gnulib_dir from --local-dir
2659 # - auxdir directory relative to destdir where to place build aux files
2660 func_create_megatestdir ()
2664 if test -z "$allmodules"; then
2665 allmodules=`func_all_modules`
2669 # First, all modules one by one.
2670 for onemodule in $allmodules; do
2671 func_create_testdir "$megatestdir/$onemodule" $onemodule
2672 func_append megasubdirs "$onemodule "
2674 # Then, all modules all together.
2675 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2676 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2677 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
2678 func_create_testdir "$megatestdir/ALL" "$allmodules"
2679 func_append megasubdirs "ALL"
2681 # Create Makefile.am.
2682 (echo "## Process this file with automake to produce Makefile.in."
2684 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2686 echo "SUBDIRS = $megasubdirs"
2687 ) > "$megatestdir/Makefile.am"
2689 # Create configure.ac.
2690 (echo "# Process this file with autoconf to produce a configure script."
2691 echo "AC_INIT([dummy], [0])"
2692 if test "$auxdir" != "."; then
2693 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2695 echo "AM_INIT_AUTOMAKE"
2697 echo "AC_PROG_MAKE_SET"
2699 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
2700 echo "AC_OUTPUT([Makefile])"
2701 ) > "$megatestdir/configure.ac"
2703 # Create autogenerated files.
2705 # Do not use "${AUTORECONF} --install", because autoreconf operates
2706 # recursively, but the subdirectories are already finished, therefore
2707 # calling autoreconf here would only waste lots of CPU time.
2708 echo "executing ${ACLOCAL}"
2709 ${ACLOCAL} || func_exit 1
2710 echo "executing mkdir build-aux"
2712 echo "executing ${AUTOCONF}"
2713 ${AUTOCONF} || func_exit 1
2714 echo "executing ${AUTOMAKE} --add-missing --copy"
2715 ${AUTOMAKE} --add-missing --copy || func_exit 1
2721 func_fatal_error "no mode specified" ;;
2730 if test -z "$destdir"; then
2733 test -d "$destdir" \
2734 || func_fatal_error "destination directory does not exist: $destdir"
2736 # Prefer configure.ac to configure.in.
2737 if test -f "$destdir"/configure.ac; then
2738 configure_ac="$destdir/configure.ac"
2740 if test -f "$destdir"/configure.in; then
2741 configure_ac="$destdir/configure.in"
2743 func_fatal_error "cannot find $destdir/configure.ac"
2747 # Analyze configure.ac.
2749 guessed_libtool=false
2754 /AC_CONFIG_AUX_DIR/ {
2755 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
2757 /A[CM]_PROG_LIBTOOL/ {
2758 s,^.*$,guessed_libtool=true,p
2760 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
2762 if test -z "$auxdir"; then
2763 auxdir="$guessed_auxdir"
2766 # Determine where to apply func_import.
2767 if test -n "$m4base"; then
2768 # Apply func_import to a particular gnulib directory.
2769 # Any number of additional modules can be given.
2770 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
2771 # First use of gnulib in the given m4base.
2772 test -n "$supplied_libname" || supplied_libname=true
2773 test -n "$sourcebase" || sourcebase="lib"
2774 test -n "$docbase" || docbase="doc"
2775 test -n "$testsbase" || testsbase="tests"
2776 test -n "$macro_prefix" || macro_prefix="gl"
2780 # Apply func_import to all gnulib directories.
2781 # To get this list of directories, look at Makefile.am. (Not at
2782 # configure, because it may be omitted from CVS. Also, don't run
2783 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
2786 if test -f "$destdir"/Makefile.am; then
2787 aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$destdir"/Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'`
2789 for arg in $aclocal_amflags; do
2790 if test -n "$m4dir_is_next"; then
2791 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
2795 if test -f "$destdir/$arg"/gnulib-cache.m4; then
2796 func_append m4dirs " $arg"
2797 m4dirs_count=`expr $m4dirs_count + 1`
2802 if test "X$arg" = "X-I"; then
2810 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
2811 if test -f "$destdir"/aclocal.m4; then
2812 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
2813 sedexpr2='s,^[^/]*$,.,'
2814 sedexpr3='s,/[^/]*$,,'
2815 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
2816 m4dirs_count=`echo "$m4dirs" | wc -l`
2819 if test $m4dirs_count = 0; then
2820 # First use of gnulib in a package.
2821 # Any number of additional modules can be given.
2822 test -n "$supplied_libname" || supplied_libname=true
2823 test -n "$sourcebase" || sourcebase="lib"
2825 test -n "$docbase" || docbase="doc"
2826 test -n "$testsbase" || testsbase="tests"
2827 test -n "$macro_prefix" || macro_prefix="gl"
2830 if test $m4dirs_count = 1; then
2831 # There's only one use of gnulib here. Assume the user means it.
2832 # Any number of additional modules can be given.
2833 for m4base in $m4dirs; do
2837 # Ambiguous - guess what the user meant.
2838 if test $# = 0; then
2839 # No further arguments. Guess the user wants to update all of them.
2840 for m4base in $m4dirs; do
2841 # Perform func_import in a subshell, so that variable values
2843 # local_gnulib_dir, avoidlist, sourcebase, m4base, docbase,
2844 # testsbase, libname, lgpl, makefile_name, libtool, macro_prefix
2845 # don't propagate from one directory to another.
2846 (func_import) || func_exit 1
2850 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
2858 if test -z "$destdir"; then
2859 func_fatal_error "please specify --dir option"
2862 test -d "$destdir" \
2863 || func_fatal_error "could not create destination directory"
2864 test -n "$auxdir" || auxdir="build-aux"
2865 func_create_testdir "$destdir" "$*"
2868 create-megatestdir )
2869 if test -z "$destdir"; then
2870 func_fatal_error "please specify --dir option"
2872 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2873 test -n "$auxdir" || auxdir="build-aux"
2874 func_create_megatestdir "$destdir" "$*"
2878 test -n "$destdir" || destdir=testdir$$
2879 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2880 test -n "$auxdir" || auxdir="build-aux"
2881 func_create_testdir "$destdir" "$*"
2885 ../configure || func_exit 1
2887 make check || func_exit 1
2888 make distclean || func_exit 1
2889 remaining=`find . -type f -print`
2890 if test -n "$remaining"; then
2891 echo "Remaining files:" $remaining 1>&2
2892 echo "gnulib-tool: *** Stop." 1>&2
2901 test -n "$destdir" || destdir=testdir$$
2902 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2903 test -n "$auxdir" || auxdir="build-aux"
2904 func_create_megatestdir "$destdir" "$*"
2912 remaining=`find . -type f -print`
2913 if test -n "$remaining"; then
2914 echo "Remaining files:" $remaining 1>&2
2915 echo "gnulib-tool: *** Stop." 1>&2
2923 extract-description )
2927 if test -n "$module"; then
2928 func_get_description "$module"
2937 if test -n "$module"; then
2938 func_get_filelist "$module"
2943 extract-dependencies )
2947 if test -n "$module"; then
2948 func_get_dependencies "$module"
2953 extract-autoconf-snippet )
2957 if test -n "$module"; then
2958 func_get_autoconf_snippet "$module"
2963 extract-automake-snippet )
2967 if test -n "$module"; then
2968 func_get_automake_snippet "$module"
2973 extract-include-directive )
2977 if test -n "$module"; then
2978 func_get_include_directive "$module"
2987 if test -n "$module"; then
2988 func_get_license "$module"
2993 extract-maintainer )
2997 if test -n "$module"; then
2998 func_get_maintainer "$module"
3003 extract-tests-module )
3007 if test -n "$module"; then
3008 func_get_tests_module "$module"
3014 func_fatal_error "unknown operation mode --$mode" ;;
3018 # Undo the effect of the previous 'trap' command. Some shellology:
3019 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
3020 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
3021 # exit); for the others we need to call 'exit' explicitly. The value of $? is
3022 # 128 + signal number and is set before the trap-registered command is run.
3024 trap 'func_exit $?' 1 2 3 13 15
3029 # indent-tabs-mode: nil
3030 # whitespace-check-buffer-indent: nil