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-08-30 18:13:34 $'
26 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
27 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
29 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
33 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
34 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
38 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
41 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
42 # variables AUTOCONF, ACLOCAL, AUTOMAKE, AUTORECONF individually.
43 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
44 AUTOCONF="${AUTOCONFPATH}autoconf"
46 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
47 ACLOCAL="${AUTOMAKEPATH}aclocal"
49 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
50 AUTOMAKE="${AUTOMAKEPATH}automake"
52 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
53 AUTORECONF="${AUTOCONFPATH}autoreconf"
56 # GNU sort is needed. Set SORT to its location (not needed if it's called
57 # 'sort' and already in the PATH).
58 if test -z "$SORT"; then
66 # outputs to stdout the --help usage message.
70 Usage: gnulib-tool --list
71 gnulib-tool --import [module1 ... moduleN]
73 gnulib-tool --create-testdir --dir=directory module1 ... moduleN
74 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
75 gnulib-tool --test --dir=directory module1 ... moduleN
76 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
77 gnulib-tool --extract-description module
78 gnulib-tool --extract-filelist module
79 gnulib-tool --extract-dependencies module
80 gnulib-tool --extract-autoconf-snippet module
81 gnulib-tool --extract-automake-snippet module
82 gnulib-tool --extract-include-directive module
83 gnulib-tool --extract-license module
84 gnulib-tool --extract-maintainer module
85 gnulib-tool --extract-tests-module module
88 --list print the available module names
89 --import import the given modules into the current package;
90 if no modules are specified, update the current
91 package from the current gnulib
92 --update update the current package, restore files omitted
94 --create-testdir create a scratch package with the given modules
95 --create-megatestdir create a mega scratch package with the given modules
96 one by one and all together
97 --test test the combination of the given modules
98 (recommended to use CC=\"gcc -Wall\" here)
99 --megatest test the given modules one by one and all together
100 (recommended to use CC=\"gcc -Wall\" here)
101 --extract-description extract the description
102 --extract-filelist extract the list of files
103 --extract-dependencies extract the dependencies
104 --extract-autoconf-snippet extract the snippet for configure.ac
105 --extract-automake-snippet extract the snippet for library makefile
106 --extract-include-directive extract the #include directive
107 --extract-license report the license terms of the source files
109 --extract-maintainer report the maintainer(s) inside gnulib
110 --extract-tests-module report the unit test module, if it exists
113 --dir=DIRECTORY Specify the target directory.
114 For --import, this specifies where your
115 configure.ac can be found. Defaults to current
117 --local-dir=DIRECTORY Specify a local override directory where to look
118 up files before looking in gnulib's directory.
120 Options for --import:
121 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
122 --source-base=DIRECTORY
123 Directory relative to --dir where source code is
124 placed (default \"lib\").
125 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
126 placed (default \"m4\").
127 --doc-base=DIRECTORY Directory relative to --dir where doc files are
128 placed (default \"doc\").
129 --tests-base=DIRECTORY
130 Directory relative to --dir where unit tests are
131 placed (default \"tests\").
132 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
133 tools are placed (default \"build-aux\").
134 --with-tests Include unit tests for the included modules.
135 --avoid=MODULE Avoid including the given MODULE. Useful if you
136 have code that provides equivalent functionality.
137 This option can be repeated.
138 --lgpl Abort if modules aren't available under the LGPL.
139 Also modify license template from GPL to LGPL.
140 --makefile-name=NAME Name of makefile in automake syntax in the
141 source-base and tests-base directories
142 (default \"Makefile.am\").
143 --libtool Use libtool rules.
144 --no-libtool Don't use libtool rules.
145 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
146 'gl_INIT'. Default is 'gl'.
147 --no-changelog don't update or create ChangeLog files
149 Options for --import and --update:
150 --dry-run For --import, only print what would have been done.
151 -s, --symbolic, --symlink Make symbolic links instead of copying files.
153 Report bugs to <bug-gnulib@gnu.org>."
157 # outputs to stdout the --version message.
160 year=`echo "$last_checkin_date" | sed -e 's,/.*$,,'`
161 echo "$progname (GNU $package) $version"
162 echo "Copyright (C) $year Free Software Foundation, Inc.
163 This is free software; see the source for copying conditions. There is NO
164 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
165 echo "Written by" "Bruno Haible" "and" "Simon Josefsson"
168 # func_emit_copyright_notice
169 # outputs to stdout a header for a generated file.
170 func_emit_copyright_notice ()
172 echo "# Copyright (C) 2004-2006 Free Software Foundation, Inc."
174 echo "# This file is free software, distributed under the terms of the GNU"
175 echo "# General Public License. As a special exception to the GNU General"
176 echo "# Public License, this file may be distributed as part of a program"
177 echo "# that contains a configuration script generated by Autoconf, under"
178 echo "# the same distribution terms as the rest of that program."
180 echo "# Generated by gnulib-tool."
184 # creates a temporary directory.
186 # - tmp pathname of freshly created temporary directory
189 # Use the environment variable TMPDIR, falling back to /tmp. This allows
190 # users to specify a different temporary directory, for example, if their
191 # /tmp is filled up or too small.
194 # Use the mktemp program if available. If not available, hide the error
196 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
197 test -n "$tmp" && test -d "$tmp"
200 # Use a simple mkdir command. It is guaranteed to fail if the directory
201 # already exists. $RANDOM is bash specific and expands to empty in shells
202 # other than bash, ksh and zsh. Its use does not increase security;
203 # rather, it minimizes the probability of failure in a very cluttered /tmp
205 tmp=$TMPDIR/gl$$-$RANDOM
206 (umask 077 && mkdir "$tmp")
209 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
210 { (exit 1); exit 1; }
214 # func_fatal_error message
215 # outputs to stderr a fatal error message, and terminates the program.
218 echo "gnulib-tool: *** $1" 1>&2
219 echo "gnulib-tool: *** Stop." 1>&2
223 # func_readlink SYMLINK
224 # outputs the target of the given symlink.
225 if (type -p readlink) > /dev/null 2>&1; then
228 # Use the readlink program from GNU coreutils.
234 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
235 # would do the wrong thing if the link target contains " -> ".
236 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
240 # func_ln_if_changed SRC DEST
241 # Like ln -s, but avoids munging timestamps if the link is correct.
242 func_ln_if_changed ()
244 if test $# -ne 2; then
245 echo "usage: func_ln_if_changed SRC DEST" >&2
247 if test -L "$2" && test "$1" = "`func_readlink "$2"`"; then
255 # func_relativize DIR1 DIR2
256 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
258 # - DIR1 relative pathname, relative to the current directory
259 # - DIR2 relative pathname, relative to the current directory
261 # - reldir relative pathname of DIR2, relative to DIR1
267 sed_first='s,^\([^/]*\)/.*$,\1,'
268 sed_rest='s,^[^/]*/*,,'
269 sed_last='s,^.*/\([^/]*\)$,\1,'
270 sed_butlast='s,/*[^/]*$,,'
271 while test -n "$dir1"; do
272 first=`echo "$dir1" | sed -e "$sed_first"`
273 if test "$first" != "."; then
274 if test "$first" = ".."; then
275 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
276 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
278 first2=`echo "$dir2" | sed -e "$sed_first"`
279 if test "$first2" = "$first"; then
280 dir2=`echo "$dir2" | sed -e "$sed_rest"`
284 dir0="$dir0"/"$first"
287 dir1=`echo "$dir1" | sed -e "$sed_rest"`
292 # func_relconcat DIR1 DIR2
293 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
295 # - DIR1 relative pathname, relative to the current directory
296 # - DIR2 relative pathname, relative to DIR1
298 # - relconcat DIR1/DIR2, relative to the current directory
303 sed_first='s,^\([^/]*\)/.*$,\1,'
304 sed_rest='s,^[^/]*/*,,'
305 sed_last='s,^.*/\([^/]*\)$,\1,'
306 sed_butlast='s,/*[^/]*$,,'
308 first=`echo "$dir2" | sed -e "$sed_first"`
309 if test "$first" = "."; then
310 dir2=`echo "$dir2" | sed -e "$sed_rest"`
311 if test -z "$dir2"; then
316 last=`echo "$dir1" | sed -e "$sed_last"`
317 while test "$last" = "."; do
318 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
319 last=`echo "$dir1" | sed -e "$sed_last"`
321 if test -z "$dir1"; then
325 if test "$first" = ".."; then
326 if test "$last" = ".."; then
327 relconcat="$dir1/$dir2"
330 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
331 dir2=`echo "$dir2" | sed -e "$sed_rest"`
332 if test -z "$dir1"; then
336 if test -z "$dir2"; then
341 relconcat="$dir1/$dir2"
348 # Command-line option processing.
349 # Removes the OPTIONS from the arguments. Sets the variables:
350 # - mode list or import or create-testdir or create-megatestdir
351 # - destdir from --dir
352 # - local_gnulib_dir from --local-dir
353 # - libname, supplied_libname from --lib
354 # - sourcebase from --source-base
355 # - m4base from --m4-base
356 # - docbase from --doc-base
357 # - testsbase from --tests-base
358 # - auxdir from --aux-dir
359 # - inctests true if --with-tests was given, blank otherwise
360 # - avoidlist list of modules to avoid, from --avoid
361 # - lgpl true if --lgpl was given, blank otherwise
362 # - makefile_name from --makefile-name
363 # - libtool true if --libtool was given, false if --no-libtool was
364 # given, blank otherwise
365 # - macro_prefix from --macro-prefix
366 # - autoconf_minversion minimum supported autoconf version
367 # - do_changelog false if --no-changelog was given, : otherwise
368 # - doit : if actions shall be executed, false if only to be printed
369 # - symbolic true if --symbolic was given, blank otherwise
393 while test $# -gt 0; do
398 --import | --impor | --impo | --imp | --im | --i )
401 --update | --updat | --upda | --upd | --up | --u )
404 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
407 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
408 mode=create-megatestdir
410 --test | --tes | --te | --t )
413 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
417 mode=`echo "X$1" | sed -e 's/^X--//'`
422 func_fatal_error "missing argument for --dir"
427 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
432 func_fatal_error "missing argument for --local-dir"
437 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
442 func_fatal_error "missing argument for --lib"
445 supplied_libname=true
448 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
449 supplied_libname=true
454 func_fatal_error "missing argument for --source-base"
459 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
464 func_fatal_error "missing argument for --m4-base"
469 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
474 func_fatal_error "missing argument for --doc-base"
479 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
484 func_fatal_error "missing argument for --tests-base"
489 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
494 func_fatal_error "missing argument for --aux-dir"
499 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
507 func_fatal_error "missing argument for --avoid"
509 avoidlist="$avoidlist $1"
512 avoidlist="$avoidlist "`echo "X$1" | sed -e 's/^X--avoid=//'`
520 func_fatal_error "missing argument for --makefile-name"
525 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
536 func_fatal_error "missing argument for --macro-prefix"
541 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
543 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
549 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
552 --help | --hel | --he | --h )
555 --version | --versio | --versi | --vers | --ver | --ve | --v )
559 # Stop option processing
563 echo "gnulib-tool: unknown option $1" 1>&2
564 echo "Try 'gnulib-tool --help' for more information." 1>&2
571 if test "$mode" = update; then
572 if test $# != 0; then
573 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
574 echo "Try 'gnulib-tool --help' for more information." 1>&2
575 echo "If you really want to modify the gnulib configuration of your project," 1>&2
576 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
579 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
580 || test -n "$sourcebase" || test -n "$m4base" \
581 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
582 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
583 || test -n "$makefile_name" || test -n "$macro_prefix"; then
584 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
585 echo "Try 'gnulib-tool --help' for more information." 1>&2
586 echo "If you really want to modify the gnulib configuration of your project," 1>&2
587 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
593 # Determine the minimum supported autoconf version from the project's
595 DEFAULT_AUTOCONF_MINVERSION="2.59"
598 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
599 if test -f "$destdir"/configure.ac; then
600 configure_ac="$destdir/configure.ac"
602 if test -f "$destdir"/configure.in; then
603 configure_ac="$destdir/configure.in"
607 if test -f configure.ac; then
608 configure_ac="configure.ac"
610 if test -f configure.in; then
611 configure_ac="configure.in"
615 if test -n "$configure_ac"; then
616 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
617 # because when some m4 files are omitted from a CVS repository,
618 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
619 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
620 # autom4te: m4 failed with exit status: 1
627 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,prereqs="$prereqs \1",p
629 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
630 if test -n "$prereqs"; then
631 autoconf_minversion=`for version in $prereqs; do echo $version; done | $SORT -g | uniq | tail -1`
634 if test -z "$autoconf_minversion"; then
635 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
637 case "$autoconf_minversion" in
638 1.* | 2.[0-4]* | 2.5[0-8]*)
639 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
642 # Remove trailing slashes from the directory names. This is necessary for
643 # m4base (to avoid an error in func_import) and optional for the others.
644 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
645 case "$local_gnulib_dir" in
646 */ ) sourcebase=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
648 case "$sourcebase" in
649 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
652 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
655 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
658 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
661 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
666 /*) self_abspathname="$0" ;;
667 */*) self_abspathname=`pwd`/"$0" ;;
668 *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
669 if test -x "$d/$0" && test ! -d "$d/$0"; then
670 self_abspathname="$d/$0"
674 if test -z "$self_abspathname"; then
675 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
679 while test -h "$self_abspathname"; do
680 # Resolve symbolic link.
681 linkval=`func_readlink "$self_abspathname"`
682 test -n "$linkval" || break
684 /* ) self_abspathname="$linkval" ;;
685 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
688 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
691 trap 'rm -rf "$tmp"' 0 1 2 3 15
693 # func_lookup_file file
694 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
697 # - local_gnulib_dir from --local-dir
699 # - lookedup_file name of the merged (combined) file
700 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
704 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
705 lookedup_file="$local_gnulib_dir/$lkfile"
708 if test -f "$gnulib_dir/$lkfile"; then
709 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
710 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
712 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
713 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
714 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
715 lookedup_file="$tmp/$lkbase"
718 lookedup_file="$gnulib_dir/$lkfile"
722 func_fatal_error "file $gnulib_dir/$lkfile not found"
729 # - local_gnulib_dir from --local-dir
732 # Filter out metainformation files like README, which are not modules.
733 # Filter out unit test modules; they can be retrieved through
734 # --extract-tests-module if desired.
736 (cd "$gnulib_dir/modules" && ls -1)
737 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
738 (cd "$local_gnulib_dir/modules" && ls -1 | sed -e 's,\.diff$,,')
741 | sed -e '/^CVS$/d' -e '/^ChangeLog$/d' -e '/^COPYING$/d' -e '/^README$/d' -e '/^TEMPLATE$/d' -e '/^TEMPLATE-TESTS$/d' -e '/~$/d' \
742 | sed -e '/-tests$/d' \
748 # verifies a module name
750 # - local_gnulib_dir from --local-dir
751 # - module module name argument
752 func_verify_module ()
754 if { test -f "$gnulib_dir/modules/$module" \
755 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
756 && test -f "$local_gnulib_dir/modules/$module"; }; } \
757 && test "CVS" != "$module" \
758 && test "ChangeLog" != "$module" \
759 && test "COPYING" != "$module" \
760 && test "README" != "$module" \
761 && test "TEMPLATE" != "$module" \
762 && test "TEMPLATE-TESTS" != "$module"; then
763 # OK, $module is a correct module name.
764 # Verify that building the module description with 'patch' succeeds.
765 func_lookup_file "modules/$module"
767 echo "gnulib-tool: module $module doesn't exist" 1>&2
772 # func_verify_nontests_module
773 # verifies a module name, excluding tests modules
775 # - local_gnulib_dir from --local-dir
776 # - module module name argument
777 func_verify_nontests_module ()
781 * ) func_verify_module ;;
785 # func_verify_tests_module
786 # verifies a module name, considering only tests modules
788 # - local_gnulib_dir from --local-dir
789 # - module module name argument
790 func_verify_tests_module ()
793 *-tests ) func_verify_module ;;
798 sed_extract_prog=':[ ]*$/ {
801 s/^Description:[ ]*$//
803 s/^Depends-on:[ ]*$//
804 s/^configure\.ac:[ ]*$//
805 s/^Makefile\.am:[ ]*$//
808 s/^Maintainer:[ ]*$//
815 # func_get_description module
817 # - local_gnulib_dir from --local-dir
818 func_get_description ()
820 func_lookup_file "modules/$1"
821 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
824 # func_get_filelist module
826 # - local_gnulib_dir from --local-dir
829 func_lookup_file "modules/$1"
830 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
831 case "$autoconf_minversion" in
834 echo m4/onceonly_2_57.m4
839 # func_get_dependencies module
841 # - local_gnulib_dir from --local-dir
842 func_get_dependencies ()
844 # ${module}-tests always implicitly depends on ${module}.
845 echo "$1" | sed -n -e 's/-tests//p'
846 # Then the explicit dependencies listed in the module description.
847 func_lookup_file "modules/$1"
848 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
851 # func_get_autoconf_snippet module
853 # - local_gnulib_dir from --local-dir
854 func_get_autoconf_snippet ()
856 func_lookup_file "modules/$1"
857 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
860 # func_get_automake_snippet module
862 # - local_gnulib_dir from --local-dir
863 func_get_automake_snippet ()
865 func_lookup_file "modules/$1"
866 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
869 # func_get_include_directive module
871 # - local_gnulib_dir from --local-dir
872 func_get_include_directive ()
874 func_lookup_file "modules/$1"
875 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
876 sed -e 's/^\(["<]\)/#include \1/'
879 # func_get_license module
881 # - local_gnulib_dir from --local-dir
884 func_lookup_file "modules/$1"
885 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
888 # func_get_maintainer module
890 # - local_gnulib_dir from --local-dir
891 func_get_maintainer ()
893 func_lookup_file "modules/$1"
894 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
897 # func_get_tests_module module
899 # - local_gnulib_dir from --local-dir
900 func_get_tests_module ()
902 # The naming convention for tests modules is hardwired: ${module}-tests.
903 if test -f "$gnulib_dir/modules/$1"-tests \
904 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
905 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
910 # func_acceptable module
911 # tests whether a module is acceptable.
913 # - avoidlist list of modules to avoid
916 for avoid in $avoidlist; do
917 if test "$avoid" = "$1"; then
924 # func_modules_transitive_closure
926 # - local_gnulib_dir from --local-dir
927 # - modules list of specified modules
928 # - inctests true if tests should be included, blank otherwise
929 # - avoidlist list of modules to avoid
931 # - modules list of modules, including dependencies
932 func_modules_transitive_closure ()
936 for module in $modules; do
938 if test -n "$module"; then
939 # Duplicate dependencies are harmless, but Jim wants a warning.
940 duplicated_deps=`func_get_dependencies $module | LC_ALL=C sort | LC_ALL=C uniq -d`
941 if test -n "$duplicated_deps"; then
942 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
944 if func_acceptable $module; then
945 xmodules="$xmodules $module"
946 for depmodule in `func_get_dependencies $module`; do
947 if func_acceptable $depmodule; then
948 xmodules="$xmodules $depmodule"
951 if test -n "$inctests"; then
952 testsmodule=`func_get_tests_module $module`
953 if test -n "$testsmodule"; then
954 if func_acceptable $testsmodule; then
955 xmodules="$xmodules $testsmodule"
956 for depmodule in `func_get_dependencies $testsmodule`; do
957 if func_acceptable $depmodule; then
958 xmodules="$xmodules $depmodule"
967 xmodules=`for m in $xmodules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
968 if test "$xmodules" = "$modules"; then
975 # func_modules_add_dummy
977 # - local_gnulib_dir from --local-dir
978 # - modules list of modules, including dependencies
980 # - modules list of modules, including 'dummy' if needed
981 func_modules_add_dummy ()
984 sed_remove_backslash_newline=':a
991 for module in $modules; do
992 func_verify_nontests_module
993 if test -n "$module"; then
994 # Extract the value of "lib_SOURCES += ...".
995 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
996 # Ignore .h files since they are not compiled.
999 *) have_lib_SOURCES=yes ;;
1004 # Add the dummy module, to make sure the library will be non-empty.
1005 if test -z "$have_lib_SOURCES"; then
1006 modules="$modules dummy"
1010 # func_modules_to_filelist
1012 # - local_gnulib_dir from --local-dir
1013 # - modules list of modules, including dependencies
1015 # - files list of files
1016 func_modules_to_filelist ()
1019 for module in $modules; do
1021 if test -n "$module"; then
1022 files="$files "`func_get_filelist $module`
1025 files=`for f in $files; do echo $f; done | LC_ALL=C sort | LC_ALL=C uniq`
1028 # func_emit_lib_Makefile_am
1029 # emits the contents of library makefile to standard output.
1031 # - local_gnulib_dir from --local-dir
1032 # - modules list of modules, including dependencies
1033 # - libname library name
1034 # - makefile_name from --makefile-name
1035 # - libtool true if libtool will be used, false or blank otherwise
1036 # - actioncmd (optional) command that will reproduce this invocation
1037 func_emit_lib_Makefile_am ()
1039 if test "$libtool" = true; then
1046 echo "## Process this file with automake to produce Makefile.in."
1047 func_emit_copyright_notice
1048 if test -n "$actioncmd"; then
1049 echo "# Reproduce by: $actioncmd"
1052 # No need to generate dependencies since the sources are in gnulib, not here.
1053 echo "AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies"
1056 for module in $modules; do
1057 func_verify_nontests_module
1058 if test -n "$module"; then
1060 func_get_automake_snippet "$module" |
1061 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1062 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1063 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1064 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1065 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
1066 if test "$module" = 'alloca'; then
1067 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1070 # Skip the contents if its entirely empty.
1071 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1072 echo "## begin gnulib module $module"
1075 echo "## end gnulib module $module"
1082 if grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1083 # One of the snippets already specifies an installation location for the
1084 # library. Don't confuse automake by saying it should not be installed.
1087 # By default, the generated library should not be installed.
1088 echo "noinst_${perhapsLT}LIBRARIES = $libname.$libext"
1091 echo "${libname}_${libext}_SOURCES ="
1092 echo "${libname}_${libext}_LIBADD = @${perhapsLT}LIBOBJS@"
1093 echo "noinst_HEADERS ="
1094 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1095 echo "pkgdata_DATA ="
1098 echo "BUILT_SOURCES ="
1100 echo "MOSTLYCLEANFILES = core *.stackdump"
1101 echo "MOSTLYCLEANDIRS ="
1103 echo "DISTCLEANFILES ="
1104 echo "MAINTAINERCLEANFILES ="
1106 echo "AM_CPPFLAGS ="
1110 echo "mostlyclean-local: mostlyclean-generic"
1111 echo " @test -z \"\$(MOSTLYCLEANDIRS)\" || \\"
1112 echo " for dir in \$(MOSTLYCLEANDIRS); do \\"
1113 echo " if test -d \$\$dir; then \\"
1114 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1117 rm -f allsnippets.tmp
1120 # func_emit_tests_Makefile_am
1121 # emits the contents of tests makefile to standard output.
1123 # - local_gnulib_dir from --local-dir
1124 # - modules list of modules, including dependencies
1125 # - libname library name
1126 # - makefile_name from --makefile-name
1127 # - libtool true if libtool will be used, false or blank otherwise
1128 # - sourcebase relative directory containing lib source code
1129 # - m4base relative directory containing autoconf macros
1130 # - testsbase relative directory containing unit test code
1131 func_emit_tests_Makefile_am ()
1133 if test "$libtool" = true; then
1138 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1139 echo "## Process this file with automake to produce Makefile.in."
1140 func_emit_copyright_notice
1142 # Generate dependencies here, since it eases the debugging of test failures.
1143 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1145 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1148 for module in $modules; do
1149 func_verify_tests_module
1150 if test -n "$module"; then
1151 func_get_automake_snippet "$module" > amsnippet.tmp
1152 # Skip the contents if its entirely empty.
1153 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1154 echo "## begin gnulib module $module"
1157 echo "## end gnulib module $module"
1164 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1165 # variable is needed to avoid an error from automake:
1166 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1169 echo "TESTS_ENVIRONMENT ="
1170 echo "noinst_PROGRAMS ="
1171 echo "check_PROGRAMS ="
1172 echo "noinst_HEADERS ="
1173 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1174 echo "pkgdata_DATA ="
1177 echo "BUILT_SOURCES ="
1179 echo "MOSTLYCLEANFILES = core *.stackdump"
1180 echo "MOSTLYCLEANDIRS ="
1182 echo "DISTCLEANFILES ="
1183 echo "MAINTAINERCLEANFILES ="
1185 echo "AM_CPPFLAGS = \\"
1186 echo " -I. -I\$(srcdir) \\"
1187 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1188 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1190 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1193 echo "# Clean up after Solaris cc."
1195 echo " rm -rf SunWS_cache"
1197 echo "mostlyclean-local: mostlyclean-generic"
1198 echo " @test -z \"\$(MOSTLYCLEANDIRS)\" || \\"
1199 echo " for dir in \$(MOSTLYCLEANDIRS); do \\"
1200 echo " if test -d \$\$dir; then \\"
1201 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1204 rm -f allsnippets.tmp
1207 # func_import modules
1208 # Uses also the variables
1209 # - destdir target directory
1210 # - local_gnulib_dir from --local-dir
1211 # - libname library name
1212 # - sourcebase directory relative to destdir where to place source code
1213 # - m4base directory relative to destdir where to place *.m4 macros
1214 # - docbase directory relative to destdir where to place doc files
1215 # - testsbase directory relative to destdir where to place unit test code
1216 # - auxdir directory relative to destdir where to place build aux files
1217 # - inctests true if --with-tests was given, blank otherwise
1218 # - avoidlist list of modules to avoid, from --avoid
1219 # - lgpl true if library's license shall be LGPL, blank otherwise
1220 # - makefile_name from --makefile-name
1221 # - libtool true if --libtool was given, false if --no-libtool was
1222 # given, blank otherwise
1223 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1224 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1225 # - autoconf_minversion minimum supported autoconf version
1226 # - doit : if actions shall be executed, false if only to be printed
1227 # - symbolic true if files should be symlinked, copied otherwise
1230 # Get the cached settings.
1231 cached_local_gnulib_dir=
1232 cached_specified_modules=
1240 cached_makefile_name=
1242 cached_macro_prefix=
1244 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1245 cached_libtool=false
1251 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
1254 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1257 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1260 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1263 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1266 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1269 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1272 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1275 s,^.*$,cached_lgpl=true,p
1277 /gl_MAKEFILE_NAME(/ {
1278 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
1281 s,^.*$,cached_libtool=true,p
1283 /gl_MACRO_PREFIX(/ {
1284 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
1286 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
1287 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1292 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
1293 s,^.*$,cached_files=",p
1305 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1309 # Merge the cached settings with the specified ones.
1310 # The m4base must be the same as expected from the pathname.
1311 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1312 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1314 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
1315 # is relative to $destdir, whereas the one we use is relative to . or absolute.
1316 if test -z "$local_gnulib_dir"; then
1317 if test -n "$cached_local_gnulib_dir"; then
1320 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1322 case "$cached_local_gnulib_dir" in
1324 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1326 func_relconcat "$destdir" "$cached_local_gnulib_dir"
1327 local_gnulib_dir="$relconcat" ;;
1332 # Append the cached and the specified module names. So that
1333 # "gnulib-tool --import foo" means to add the module foo.
1334 specified_modules="$cached_specified_modules $1"
1335 # Append the cached and the specified avoidlist. This is probably better
1336 # than dropping the cached one when --avoid is specified at least once.
1337 avoidlist=`echo $cached_avoidlist $avoidlist`
1338 # The sourcebase defaults to the cached one.
1339 if test -z "$sourcebase"; then
1340 sourcebase="$cached_sourcebase"
1341 if test -z "$sourcebase"; then
1342 func_fatal_error "missing --source-base option"
1345 # The docbase defaults to the cached one.
1346 if test -z "$docbase"; then
1347 docbase="$cached_docbase"
1348 if test -z "$docbase"; then
1349 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."
1352 # The testsbase defaults to the cached one.
1353 if test -z "$testsbase"; then
1354 testsbase="$cached_testsbase"
1355 if test -z "$testsbase"; then
1356 func_fatal_error "missing --tests-base option"
1359 # The libname defaults to the cached one.
1360 if test -z "$supplied_libname"; then
1361 libname="$cached_libname"
1362 if test -z "$libname"; then
1363 func_fatal_error "missing --lib option"
1366 # Require LGPL if specified either way.
1367 if test -z "$lgpl"; then
1370 # The makefile_name defaults to the cached one.
1371 if test -z "$makefile_name"; then
1372 makefile_name="$cached_makefile_name"
1374 # Use libtool if specified either way, or if guessed.
1375 if test -z "$libtool"; then
1376 if test -n "$cached_m4base"; then
1377 libtool="$cached_libtool"
1379 libtool="$guessed_libtool"
1382 # The macro_prefix defaults to the cached one.
1383 if test -z "$macro_prefix"; then
1384 macro_prefix="$cached_macro_prefix"
1385 if test -z "$macro_prefix"; then
1386 func_fatal_error "missing --macro-prefix option"
1390 # Canonicalize the list of specified modules.
1391 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
1393 # Determine final module list.
1394 modules="$specified_modules"
1395 func_modules_transitive_closure
1396 echo "Module list with included dependencies:"
1397 echo "$modules" | sed -e 's/^/ /'
1399 # Add the dummy module if needed.
1400 func_modules_add_dummy
1402 # If --lgpl, verify that the licenses of modules are compatible.
1403 if test -n "$lgpl"; then
1404 for module in $modules; do
1405 license=`func_get_license $module`
1407 LGPL | 'GPLed build tool') ;;
1408 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
1409 *) func_fatal_error "incompatible license on module $module: $license" ;;
1414 # Determine script to apply to imported library files.
1415 sed_transform_lib_file=
1416 case $nl$modules$nl in
1417 *"${nl}config-h$nl"*)
1418 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
1419 sed_transform_lib_file=$sed_transform_lib_file'
1420 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
1423 if test -n "$lgpl"; then
1425 sed_transform_lib_file=$sed_transform_lib_file'
1426 s/GNU General/GNU Lesser General/g
1427 s/version 2\([ ,]\)/version 2.1\1/g
1431 # Determine final file list.
1432 func_modules_to_filelist
1434 echo "$files" | sed -e 's/^/ /'
1437 || func_fatal_error "refusing to do nothing"
1439 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
1440 new_files="$files m4/gnulib-tool.m4"
1441 old_files="$cached_files"
1442 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
1443 old_files="$old_files m4/gnulib-tool.m4"
1446 # Create directories.
1447 if test ! -d "$destdir/$sourcebase"; then
1449 echo "Creating directory $destdir/$sourcebase"
1450 mkdir "$destdir/$sourcebase" || func_fatal_error "failed"
1452 echo "Create directory $destdir/$sourcebase"
1455 if test ! -d "$destdir/$m4base"; then
1457 echo "Creating directory $destdir/$m4base"
1458 mkdir "$destdir/$m4base" || func_fatal_error "failed"
1460 echo "Create directory $destdir/$m4base"
1463 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
1464 if test -n "$docfiles"; then
1465 if test ! -d "$destdir/$docbase"; then
1467 echo "Creating directory $destdir/$docbase"
1468 mkdir "$destdir/$docbase" || func_fatal_error "failed"
1470 echo "Create directory $destdir/$docbase"
1474 if test -n "$inctests"; then
1475 if test ! -d "$destdir/$testsbase"; then
1477 echo "Creating directory $destdir/$testsbase"
1478 mkdir "$destdir/$testsbase" || func_fatal_error "failed"
1480 echo "Create directory $destdir/$testsbase"
1484 if test ! -d "$destdir/$auxdir"; then
1486 echo "Creating directory $destdir/$auxdir"
1487 mkdir "$destdir/$auxdir" || func_fatal_error "failed"
1489 echo "Create directory $destdir/$auxdir"
1493 # func_dest_tmpfilename file
1494 # determines the name of a temporary file (file is relative to destdir).
1496 # - tmpfile absolute filename of the temporary file
1497 func_dest_tmpfilename ()
1500 # Put the new contents of $file in a file in the same directory (needed
1501 # to guarantee that an 'mv' to "$destdir/$file" works).
1502 tmpfile="$destdir/$1.tmp"
1504 # Put the new contents of $file in a file in a temporary directory
1505 # (because the directory of "$file" might not exist).
1506 tmpfile="$tmp"/`basename "$1"`.tmp
1510 # Copy files or make symbolic links. Remove obsolete files.
1512 for f in $old_files; do
1514 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1515 doc/*) g=`echo "$f" | sed -e "s,^doc/,$cached_docbase/,"` ;;
1516 lib/*) g=`echo "$f" | sed -e "s,^lib/,$cached_sourcebase/,"` ;;
1517 m4/*) g=`echo "$f" | sed -e "s,^m4/,$cached_m4base/,"` ;;
1518 tests/*) g=`echo "$f" | sed -e "s,^tests/,$cached_testsbase/,"` ;;
1521 echo "$g""$delimiter""$f"
1522 done | LC_ALL=C sort > "$tmp"/old-files
1523 for f in $new_files; do
1525 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1526 doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
1527 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1528 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1529 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1532 echo "$g""$delimiter""$f"
1533 done | LC_ALL=C sort > "$tmp"/new-files
1534 # First the files that are in old-files, but not in new-files:
1535 sed_take_first_column='s,'"$delimiter"'.*,,'
1536 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
1537 # Remove the file. Do nothing if the user already removed it.
1538 if test -f "$destdir/$g"; then
1540 echo "Removing file $g (backup in ${g}~)"
1541 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1543 echo "Remove file $g (backup in ${g}~)"
1547 # func_add_or_update handles a file that ought to be present afterwards.
1548 # Uses parameters f, g, already_present.
1549 func_add_or_update ()
1551 func_dest_tmpfilename "$g"
1552 func_lookup_file "$f"
1553 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
1554 if test -n "sed_transform_lib_file"; then
1557 sed -e "$sed_transform_lib_file" \
1558 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
1562 if test -f "$destdir/$g"; then
1563 # The file already exists.
1564 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1565 : # The file has not changed.
1569 if test -n "$already_present"; then
1570 echo "Updating file $g (backup in ${g}~)"
1572 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
1574 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1575 if test -n "$symbolic" && test -z "$lookedup_tmp" \
1576 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1577 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1579 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1582 if test -n "$already_present"; then
1583 echo "Update file $g (backup in ${g}~)"
1585 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
1591 # Don't protest if the file should be there but isn't: it happens
1592 # frequently that developers don't put autogenerated files into CVS.
1594 echo "Copying file $g"
1595 if test -n "$symbolic" && test -z "$lookedup_tmp" \
1596 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1597 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1599 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1607 # Then the files that are in new-files, but not in old-files:
1608 sed_take_last_column='s,^.*'"$delimiter"',,'
1610 for f in `LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_last_column"`; do
1612 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1613 doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
1614 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1615 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1616 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1621 # Then the files that are in new-files and in old-files:
1622 already_present=true
1623 for f in `LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_last_column"`; do
1625 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1626 doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
1627 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1628 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1629 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1635 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
1636 actioncmd="gnulib-tool --import"
1637 actioncmd="$actioncmd --dir=$destdir"
1638 if test -n "$local_gnulib_dir"; then
1639 actioncmd="$actioncmd --local-dir=$local_gnulib_dir"
1641 actioncmd="$actioncmd --lib=$libname"
1642 actioncmd="$actioncmd --source-base=$sourcebase"
1643 actioncmd="$actioncmd --m4-base=$m4base"
1644 actioncmd="$actioncmd --doc-base=$docbase"
1645 actioncmd="$actioncmd --aux-dir=$auxdir"
1646 for module in $avoidlist; do
1647 actioncmd="$actioncmd --avoid=$module"
1649 if test -n "$lgpl"; then
1650 actioncmd="$actioncmd --lgpl"
1652 if test -n "$makefile_name"; then
1653 actioncmd="$actioncmd --makefile_name=$makefile_name"
1655 if test "$libtool" = true; then
1656 actioncmd="$actioncmd --libtool"
1658 actioncmd="$actioncmd --no-libtool"
1660 actioncmd="$actioncmd --macro-prefix=$macro_prefix"
1661 actioncmd="$actioncmd `echo $specified_modules`"
1663 # Default the makefile name to Makefile.am.
1664 if test -n "$makefile_name"; then
1665 makefile_am=$makefile_name
1667 makefile_am=Makefile.am
1670 # Create library makefile.
1671 func_dest_tmpfilename $sourcebase/$makefile_am
1672 func_emit_lib_Makefile_am > "$tmpfile"
1673 if test -f "$destdir"/$sourcebase/$makefile_am; then
1674 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
1678 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
1679 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
1680 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
1682 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
1688 echo "Creating $sourcebase/$makefile_am"
1689 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
1691 echo "Create $sourcebase/$makefile_am"
1696 # Create m4/gnulib-cache.m4.
1697 func_dest_tmpfilename $m4base/gnulib-cache.m4
1699 func_emit_copyright_notice
1701 echo "# This file represents the specification of how gnulib-tool is used."
1702 echo "# It acts as a cache: It is written and read by gnulib-tool."
1703 echo "# In projects using CVS, this file is meant to be stored in CVS,"
1704 echo "# like the configure.ac and various Makefile.am files."
1707 echo "# Specification in the form of a command-line invocation:"
1710 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
1711 # Store the local_gnulib_dir relative to destdir.
1712 case "$local_gnulib_dir" in
1714 relative_local_gnulib_dir="$local_gnulib_dir" ;;
1717 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
1719 # destdir, local_gnulib_dir are both relative.
1720 func_relativize "$destdir" "$local_gnulib_dir"
1721 relative_local_gnulib_dir="$reldir" ;;
1724 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
1725 echo "gl_MODULES(["`echo $specified_modules`"])"
1726 echo "gl_AVOID([$avoidlist])"
1727 echo "gl_SOURCE_BASE([$sourcebase])"
1728 echo "gl_M4_BASE([$m4base])"
1729 echo "gl_DOC_BASE([$docbase])"
1730 echo "gl_TESTS_BASE([$testsbase])"
1731 echo "gl_LIB([$libname])"
1732 test -z "$lgpl" || echo "gl_LGPL"
1733 echo "gl_MAKEFILE_NAME([$makefile_name])"
1734 if test "$libtool" = true; then
1737 echo "gl_MACRO_PREFIX([$macro_prefix])"
1739 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1740 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
1744 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1745 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
1746 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
1748 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1752 echo "# gnulib-cache.m4 ends here"
1759 echo "Creating $m4base/gnulib-cache.m4"
1760 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
1762 echo "Create $m4base/gnulib-cache.m4"
1768 # Create m4/gnulib-comp.m4.
1769 func_dest_tmpfilename $m4base/gnulib-comp.m4
1771 func_emit_copyright_notice
1773 echo "# This file represents the compiled summary of the specification in"
1774 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
1775 echo "# to be invoked from configure.ac."
1776 echo "# In projects using CVS, this file can be treated like other built files."
1779 echo "# This macro should be invoked from $configure_ac, in the section"
1780 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
1781 echo "# any checks for libraries, header files, types and library functions."
1782 echo "AC_DEFUN([${macro_prefix}_EARLY],"
1784 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
1785 echo " m4_pattern_allow([^gl_ES$])dnl a valid locale name"
1786 echo " AC_REQUIRE([AC_PROG_RANLIB])"
1787 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1788 echo " AC_REQUIRE([AC_GNU_SOURCE])"
1790 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1791 echo " AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])"
1793 if grep gl_LOCK "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1794 echo " AC_REQUIRE([gl_LOCK_EARLY])"
1798 echo "# This macro should be invoked from $configure_ac, in the section"
1799 echo "# \"Check for header files, types and library functions\"."
1800 echo "AC_DEFUN([${macro_prefix}_INIT],"
1802 if test "$libtool" = true; then
1803 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1805 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1807 if test "$auxdir" != "build-aux"; then
1808 sed_replace_build_aux='
1810 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
1811 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
1814 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
1816 sed_replace_build_aux=
1818 for module in $modules; do
1820 if test -n "$module"; then
1821 func_get_autoconf_snippet "$module" \
1822 | sed -e '/^$/d;' -e 's/^/ /' \
1823 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
1824 -e "$sed_replace_build_aux"
1825 if test "$module" = 'alloca' && test "$libtool" = true; then
1826 echo 'changequote(,)dnl'
1827 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
1828 echo 'changequote([, ])dnl'
1829 echo 'AC_SUBST([LTALLOCA])'
1835 echo "# This macro records the list of files which have been installed by"
1836 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
1837 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
1838 echo "$files" | sed -e 's,^, ,'
1841 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1842 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
1846 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1847 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
1848 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
1850 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1854 echo "# gnulib-comp.m4 ends here"
1861 echo "Creating $m4base/gnulib-comp.m4"
1862 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
1864 echo "Create $m4base/gnulib-comp.m4"
1870 if test -n "$inctests"; then
1871 # Create tests makefile.
1872 func_dest_tmpfilename $testsbase/$makefile_am
1873 func_emit_tests_Makefile_am > "$tmpfile"
1874 if test -f "$destdir"/$testsbase/$makefile_am; then
1875 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
1879 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
1880 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
1881 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
1883 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
1889 echo "Creating $testsbase/$makefile_am"
1890 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
1892 echo "Create $testsbase/$makefile_am"
1900 echo "You may need to add #include directives for the following .h files."
1902 # First the #include <...> directives without #ifs, sorted for convenience.
1903 for module in $modules; do
1904 if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
1907 func_get_include_directive "$module" | grep -v 'include "'
1909 done | LC_ALL=C sort -u
1910 # Then the #include "..." directives without #ifs, sorted for convenience.
1911 for module in $modules; do
1912 if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
1915 func_get_include_directive "$module" | grep 'include "'
1917 done | LC_ALL=C sort -u
1918 # Then the #include directives that are surrounded by #ifs. Not sorted.
1919 for module in $modules; do
1920 if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
1921 func_get_include_directive "$module"
1924 ) | sed -e '/^$/d;' -e 's/^/ /'
1926 echo "Don't forget to"
1927 if test "$makefile_am" = Makefile.am; then
1928 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1930 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
1932 if test -n "$inctests"; then
1933 if test "$makefile_am" = Makefile.am; then
1934 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1936 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
1939 if test "$makefile_am" = Makefile.am; then
1940 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
1941 sourcebase_base=`basename "$sourcebase"`
1942 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
1944 if test -n "$inctests"; then
1945 if test "$makefile_am" = Makefile.am; then
1946 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
1947 testsbase_base=`basename "$testsbase"`
1948 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
1951 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
1952 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
1953 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
1956 # func_create_testdir testdir modules
1958 # - local_gnulib_dir from --local-dir
1959 # - auxdir directory relative to destdir where to place build aux files
1960 func_create_testdir ()
1964 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
1966 # Subdirectory names.
1971 # Determine final module list.
1972 func_modules_transitive_closure
1973 echo "Module list with included dependencies:"
1974 echo "$modules" | sed -e 's/^/ /'
1976 # Add the dummy module if needed.
1977 func_modules_add_dummy
1979 # Determine final file list.
1980 func_modules_to_filelist
1982 echo "$files" | sed -e 's/^/ /'
1984 # Create directories.
1985 for d in `echo "$files" | sed -n -e 's,^\(.*\)/[^/]*,\1,p'`; do
1987 build-aux) mkdir -p "$testdir/$auxdir" ;;
1988 lib) mkdir -p "$testdir/$sourcebase" ;;
1989 m4) mkdir -p "$testdir/$m4base" ;;
1990 tests) mkdir -p "$testdir/$testsbase" ;;
1991 *) mkdir -p "$testdir/$d" ;;
1995 # Copy files or make symbolic links.
1997 func_lookup_file "$f"
1999 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
2000 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
2001 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
2002 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
2005 if test -n "$lookedup_tmp"; then
2006 cp -p "$lookedup_file" "$testdir/$g"
2008 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
2009 if test -z "$symbolic"; then
2010 cp -p "$lookedup_file" "$testdir/$g"
2012 ln -s "$lookedup_file" "$testdir/$g"
2017 # Create $sourcebase/Makefile.am.
2018 mkdir -p "$testdir/$sourcebase"
2019 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
2021 # Create $m4base/Makefile.am.
2022 mkdir -p "$testdir/$m4base"
2023 (echo "## Process this file with automake to produce Makefile.in."
2029 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
2032 ) > "$testdir/$m4base/Makefile.am"
2034 subdirs="$sourcebase $m4base"
2035 subdirs_with_configure_ac=""
2037 if test -f "$testdir"/$m4base/gettext.m4; then
2038 # Avoid stupid error message from automake:
2039 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
2040 mkdir -p "$testdir/po"
2041 (echo "## Process this file with automake to produce Makefile.in."
2042 ) > "$testdir/po/Makefile.am"
2043 subdirs="$subdirs po"
2046 if test -n "$inctests"; then
2047 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
2048 # Create $testsbase/Makefile.am.
2049 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
2050 # Create $testsbase/configure.ac.
2051 (echo "# Process this file with autoconf to produce a configure script."
2052 echo "AC_INIT([dummy], [0])"
2053 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
2054 echo "AM_INIT_AUTOMAKE"
2056 echo "AM_CONFIG_HEADER([config.h])"
2059 echo "AC_PROG_INSTALL"
2060 echo "AC_PROG_MAKE_SET"
2061 echo "AC_PROG_RANLIB"
2063 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2064 echo "AC_GNU_SOURCE"
2067 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2068 echo "gl_USE_SYSTEM_EXTENSIONS"
2071 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2072 echo "gl_LOCK_EARLY"
2075 if test "$libtool" = true; then
2076 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2078 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2080 # Wrap the set of autoconf snippets into an autoconf macro that is then
2081 # invoked. This is needed because autoconf does not support AC_REQUIRE
2083 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2084 # but we want the AC_REQUIRE to have its normal meaning (provide one
2085 # expansion of the required macro before the current point, and only one
2087 echo "AC_DEFUN([gl_INIT], ["
2088 if test "$auxdir" != "build-aux"; then
2089 sed_replace_build_aux='
2091 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2092 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
2095 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2097 sed_replace_build_aux=
2099 # We don't have explicit ordering constraints between the various
2100 # autoconf snippets. It's cleanest to put those of the library before
2101 # those of the tests.
2102 for module in $modules; do
2103 func_verify_nontests_module
2104 if test -n "$module"; then
2105 func_get_autoconf_snippet "$module" \
2106 | sed -e "$sed_replace_build_aux"
2109 for module in $modules; do
2110 func_verify_tests_module
2111 if test -n "$module"; then
2112 func_get_autoconf_snippet "$module" \
2113 | sed -e "$sed_replace_build_aux"
2119 # Usually $testsbase/config.h will be a superset of config.h. Verify this
2120 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
2121 echo "AH_TOP([#include \"../config.h\"])"
2123 echo "AC_OUTPUT([Makefile])"
2124 ) > "$testdir/$testsbase/configure.ac"
2125 subdirs="$subdirs $testsbase"
2126 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
2129 # Create Makefile.am.
2130 (echo "## Process this file with automake to produce Makefile.in."
2132 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2134 echo "SUBDIRS = $subdirs"
2136 echo "ACLOCAL_AMFLAGS = -I $m4base"
2137 ) > "$testdir/Makefile.am"
2139 # Create configure.ac.
2140 (echo "# Process this file with autoconf to produce a configure script."
2141 echo "AC_INIT([dummy], [0])"
2142 if test "$auxdir" != "."; then
2143 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2145 echo "AM_INIT_AUTOMAKE"
2147 echo "AM_CONFIG_HEADER([config.h])"
2150 echo "AC_PROG_INSTALL"
2151 echo "AC_PROG_MAKE_SET"
2153 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2154 echo "m4_pattern_allow([^gl_ES$])dnl a valid locale name"
2156 echo "AC_PROG_RANLIB"
2158 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2159 echo "AC_GNU_SOURCE"
2162 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2163 echo "gl_USE_SYSTEM_EXTENSIONS"
2166 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2167 echo "gl_LOCK_EARLY"
2170 if test "$libtool" = true; then
2171 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2173 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2175 # Wrap the set of autoconf snippets into an autoconf macro that is then
2176 # invoked. This is needed because autoconf does not support AC_REQUIRE
2178 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2179 # but we want the AC_REQUIRE to have its normal meaning (provide one
2180 # expansion of the required macro before the current point, and only one
2182 echo "AC_DEFUN([gl_INIT], ["
2183 if test "$auxdir" != "build-aux"; then
2184 sed_replace_build_aux='
2186 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2187 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2190 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2192 sed_replace_build_aux=
2194 for module in $modules; do
2195 func_verify_nontests_module
2196 if test -n "$module"; then
2197 func_get_autoconf_snippet "$module" \
2198 | sed -e "$sed_replace_build_aux"
2204 if test -n "$subdirs_with_configure_ac"; then
2205 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
2207 makefiles="Makefile"
2208 for d in $subdirs; do
2209 # For subdirs that have a configure.ac by their own, it's the subdir's
2210 # configure.ac which creates the subdir's Makefile.am, not this one.
2211 case " $subdirs_with_configure_ac " in
2213 *) makefiles="$makefiles $d/Makefile" ;;
2216 echo "AC_OUTPUT([$makefiles])"
2217 ) > "$testdir/configure.ac"
2219 # Create autogenerated files.
2221 echo "executing ${AUTORECONF} --force --install"
2222 ${AUTORECONF} --force --install
2224 if grep '^BUILT_SOURCES *+=' "$testdir/$sourcebase/Makefile.am" > /dev/null; then
2228 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
2236 # func_create_megatestdir megatestdir allmodules
2238 # - local_gnulib_dir from --local-dir
2239 # - auxdir directory relative to destdir where to place build aux files
2240 func_create_megatestdir ()
2244 if test -z "$allmodules"; then
2245 allmodules=`func_all_modules`
2249 # First, all modules one by one.
2250 for onemodule in $allmodules; do
2251 func_create_testdir "$megatestdir/$onemodule" $onemodule
2252 megasubdirs="${megasubdirs}$onemodule "
2254 # Then, all modules all together.
2255 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2256 allmodules=`for m in $allmodules; do if test $m != fnmatch-posix; then echo $m; fi; done`
2257 func_create_testdir "$megatestdir/ALL" "$allmodules"
2258 megasubdirs="${megasubdirs}ALL"
2260 # Create Makefile.am.
2261 (echo "## Process this file with automake to produce Makefile.in."
2263 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2265 echo "SUBDIRS = $megasubdirs"
2266 ) > "$megatestdir/Makefile.am"
2268 # Create configure.ac.
2269 (echo "# Process this file with autoconf to produce a configure script."
2270 echo "AC_INIT([dummy], [0])"
2271 if test "$auxdir" != "."; then
2272 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2274 echo "AM_INIT_AUTOMAKE"
2276 echo "AC_PROG_MAKE_SET"
2278 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
2279 echo "AC_OUTPUT([Makefile])"
2280 ) > "$megatestdir/configure.ac"
2282 # Create autogenerated files.
2284 # Do not use "${AUTORECONF} --install", because autoreconf operates
2285 # recursively, but the subdirectories are already finished, therefore
2286 # calling autoreconf here would only waste lots of CPU time.
2287 echo "executing ${ACLOCAL}"
2289 echo "executing mkdir build-aux"
2291 echo "executing ${AUTOCONF}"
2293 echo "executing ${AUTOMAKE} --add-missing --copy"
2294 ${AUTOMAKE} --add-missing --copy
2300 func_fatal_error "no mode specified" ;;
2309 if test -z "$destdir"; then
2312 test -d "$destdir" \
2313 || func_fatal_error "destination directory does not exist: $destdir"
2315 # Prefer configure.ac to configure.in.
2316 if test -f "$destdir"/configure.ac; then
2317 configure_ac="$destdir/configure.ac"
2319 if test -f "$destdir"/configure.in; then
2320 configure_ac="$destdir/configure.in"
2322 func_fatal_error "cannot find $destdir/configure.ac"
2326 # Analyze configure.ac.
2328 guessed_libtool=false
2333 /AC_CONFIG_AUX_DIR/ {
2334 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
2336 /A[CM]_PROG_LIBTOOL/ {
2337 s,^.*$,guessed_libtool=true,p
2339 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
2341 if test -z "$auxdir"; then
2342 auxdir="$guessed_auxdir"
2345 # Determine where to apply func_import.
2346 if test -n "$m4base"; then
2347 # Apply func_import to a particular gnulib directory.
2348 # Any number of additional modules can be given.
2349 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
2350 # First use of gnulib in the given m4base.
2351 test -n "$supplied_libname" || supplied_libname=true
2352 test -n "$sourcebase" || sourcebase="lib"
2353 test -n "$docbase" || docbase="doc"
2354 test -n "$testsbase" || testsbase="tests"
2355 test -n "$macro_prefix" || macro_prefix="gl"
2359 # Apply func_import to all gnulib directories.
2360 # To get this list of directories, look at Makefile.am. (Not at
2361 # configure, because it may be omitted from CVS. Also, don't run
2362 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
2365 if test -f "$destdir"/Makefile.am; then
2366 aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$destdir"/Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'`
2368 for arg in $aclocal_amflags; do
2369 if test -n "$m4dir_is_next"; then
2370 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
2374 if test -f "$destdir/$arg"/gnulib-cache.m4; then
2375 m4dirs="$m4dirs $arg"
2376 m4dirs_count=`expr $m4dirs_count + 1`
2381 if test "X$arg" = "X-I"; then
2389 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
2390 if test -f "$destdir"/aclocal.m4; then
2391 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
2392 sedexpr2='s,^[^/]*$,.,'
2393 sedexpr3='s,/[^/]*$,,'
2394 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort | LC_ALL=C uniq`
2395 m4dirs_count=`echo "$m4dirs" | wc -l`
2398 if test $m4dirs_count = 0; then
2399 # First use of gnulib in a package.
2400 # Any number of additional modules can be given.
2401 test -n "$supplied_libname" || supplied_libname=true
2402 test -n "$sourcebase" || sourcebase="lib"
2404 test -n "$docbase" || docbase="doc"
2405 test -n "$testsbase" || testsbase="tests"
2406 test -n "$macro_prefix" || macro_prefix="gl"
2409 if test $m4dirs_count = 1; then
2410 # There's only one use of gnulib here. Assume the user means it.
2411 # Any number of additional modules can be given.
2412 for m4base in $m4dirs; do
2416 # Ambiguous - guess what the user meant.
2417 if test $# = 0; then
2418 # No further arguments. Guess the user wants to update all of them.
2419 for m4base in $m4dirs; do
2424 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
2432 if test -z "$destdir"; then
2433 func_fatal_error "please specify --dir option"
2436 test -d "$destdir" \
2437 || func_fatal_error "could not create destination directory"
2438 test -n "$auxdir" || auxdir="build-aux"
2439 func_create_testdir "$destdir" "$*"
2442 create-megatestdir )
2443 if test -z "$destdir"; then
2444 func_fatal_error "please specify --dir option"
2446 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2447 test -n "$auxdir" || auxdir="build-aux"
2448 func_create_megatestdir "$destdir" "$*"
2452 test -n "$destdir" || destdir=testdir$$
2453 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2454 test -n "$auxdir" || auxdir="build-aux"
2455 func_create_testdir "$destdir" "$*"
2463 remaining=`find . -type f -print`
2464 if test -n "$remaining"; then
2465 echo "Remaining files:" $remaining 1>&2
2466 echo "gnulib-tool: *** Stop." 1>&2
2475 test -n "$destdir" || destdir=testdir$$
2476 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2477 test -n "$auxdir" || auxdir="build-aux"
2478 func_create_megatestdir "$destdir" "$*"
2486 remaining=`find . -type f -print`
2487 if test -n "$remaining"; then
2488 echo "Remaining files:" $remaining 1>&2
2489 echo "gnulib-tool: *** Stop." 1>&2
2497 extract-description )
2501 if test -n "$module"; then
2502 func_get_description "$module"
2511 if test -n "$module"; then
2512 func_get_filelist "$module"
2517 extract-dependencies )
2521 if test -n "$module"; then
2522 func_get_dependencies "$module"
2527 extract-autoconf-snippet )
2531 if test -n "$module"; then
2532 func_get_autoconf_snippet "$module"
2537 extract-automake-snippet )
2541 if test -n "$module"; then
2542 func_get_automake_snippet "$module"
2547 extract-include-directive )
2551 if test -n "$module"; then
2552 func_get_include_directive "$module"
2561 if test -n "$module"; then
2562 func_get_license "$module"
2567 extract-maintainer )
2571 if test -n "$module"; then
2572 func_get_maintainer "$module"
2577 extract-tests-module )
2581 if test -n "$module"; then
2582 func_get_tests_module "$module"
2588 func_fatal_error "unknown operation mode --$mode" ;;
2592 # Undo the effect of the previous 'trap' command. Some shellology:
2593 # We cannot use "trap - 0 1 2 3 15", because Solaris sh would attempt to
2594 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
2595 # exit); for the others we need to call 'exit' explicitly. The value of $? is
2596 # 128 + signal number and is set before the trap-registered command is run.
2598 trap 'exit $?' 1 2 3 15