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-28 15:20:22 $'
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 lib/Makefile.am
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 --libtool Use libtool rules.
141 --no-libtool Don't use libtool rules.
142 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
143 'gl_INIT'. Default is 'gl'.
144 --no-changelog don't update or create ChangeLog files
146 Options for --import and --update:
147 --dry-run For --import, only print what would have been done.
148 -s, --symbolic, --symlink Make symbolic links instead of copying files.
150 Report bugs to <bug-gnulib@gnu.org>."
154 # outputs to stdout the --version message.
157 year=`echo "$last_checkin_date" | sed -e 's,/.*$,,'`
158 echo "$progname (GNU $package) $version"
159 echo "Copyright (C) $year Free Software Foundation, Inc.
160 This is free software; see the source for copying conditions. There is NO
161 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
162 echo "Written by" "Bruno Haible" "and" "Simon Josefsson"
165 # func_emit_copyright_notice
166 # outputs to stdout a header for a generated file.
167 func_emit_copyright_notice ()
169 echo "# Copyright (C) 2004-2006 Free Software Foundation, Inc."
171 echo "# This file is free software, distributed under the terms of the GNU"
172 echo "# General Public License. As a special exception to the GNU General"
173 echo "# Public License, this file may be distributed as part of a program"
174 echo "# that contains a configuration script generated by Autoconf, under"
175 echo "# the same distribution terms as the rest of that program."
177 echo "# Generated by gnulib-tool."
181 # creates a temporary directory.
183 # - tmp pathname of freshly created temporary directory
186 # Use the environment variable TMPDIR, falling back to /tmp. This allows
187 # users to specify a different temporary directory, for example, if their
188 # /tmp is filled up or too small.
191 # Use the mktemp program if available. If not available, hide the error
193 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
194 test -n "$tmp" && test -d "$tmp"
197 # Use a simple mkdir command. It is guaranteed to fail if the directory
198 # already exists. $RANDOM is bash specific and expands to empty in shells
199 # other than bash, ksh and zsh. Its use does not increase security;
200 # rather, it minimizes the probability of failure in a very cluttered /tmp
202 tmp=$TMPDIR/gl$$-$RANDOM
203 (umask 077 && mkdir "$tmp")
206 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
207 { (exit 1); exit 1; }
211 # func_fatal_error message
212 # outputs to stderr a fatal error message, and terminates the program.
215 echo "gnulib-tool: *** $1" 1>&2
216 echo "gnulib-tool: *** Stop." 1>&2
220 # func_readlink SYMLINK
221 # outputs the target of the given symlink.
222 if (type -p readlink) > /dev/null 2>&1; then
225 # Use the readlink program from GNU coreutils.
231 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
232 # would do the wrong thing if the link target contains " -> ".
233 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
237 # func_ln_if_changed SRC DEST
238 # Like ln -s, but avoids munging timestamps if the link is correct.
239 func_ln_if_changed ()
241 if test $# -ne 2; then
242 echo "usage: func_ln_if_changed SRC DEST" >&2
244 if test -L "$2" && test "$1" = "`func_readlink "$2"`"; then
252 # func_relativize DIR1 DIR2
253 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
255 # - DIR1 relative pathname, relative to the current directory
256 # - DIR2 relative pathname, relative to the current directory
258 # - reldir relative pathname of DIR2, relative to DIR1
264 sed_first='s,^\([^/]*\)/.*$,\1,'
265 sed_rest='s,^[^/]*/*,,'
266 sed_last='s,^.*/\([^/]*\)$,\1,'
267 sed_butlast='s,/*[^/]*$,,'
268 while test -n "$dir1"; do
269 first=`echo "$dir1" | sed -e "$sed_first"`
270 if test "$first" != "."; then
271 if test "$first" = ".."; then
272 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
273 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
275 first2=`echo "$dir2" | sed -e "$sed_first"`
276 if test "$first2" = "$first"; then
277 dir2=`echo "$dir2" | sed -e "$sed_rest"`
281 dir0="$dir0"/"$first"
284 dir1=`echo "$dir1" | sed -e "$sed_rest"`
289 # func_relconcat DIR1 DIR2
290 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
292 # - DIR1 relative pathname, relative to the current directory
293 # - DIR2 relative pathname, relative to DIR1
295 # - relconcat DIR1/DIR2, relative to the current directory
300 sed_first='s,^\([^/]*\)/.*$,\1,'
301 sed_rest='s,^[^/]*/*,,'
302 sed_last='s,^.*/\([^/]*\)$,\1,'
303 sed_butlast='s,/*[^/]*$,,'
305 first=`echo "$dir2" | sed -e "$sed_first"`
306 if test "$first" = "."; then
307 dir2=`echo "$dir2" | sed -e "$sed_rest"`
308 if test -z "$dir2"; then
313 last=`echo "$dir1" | sed -e "$sed_last"`
314 while test "$last" = "."; do
315 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
316 last=`echo "$dir1" | sed -e "$sed_last"`
318 if test -z "$dir1"; then
322 if test "$first" = ".."; then
323 if test "$last" = ".."; then
324 relconcat="$dir1/$dir2"
327 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
328 dir2=`echo "$dir2" | sed -e "$sed_rest"`
329 if test -z "$dir1"; then
333 if test -z "$dir2"; then
338 relconcat="$dir1/$dir2"
345 # Command-line option processing.
346 # Removes the OPTIONS from the arguments. Sets the variables:
347 # - mode list or import or create-testdir or create-megatestdir
348 # - destdir from --dir
349 # - libname, supplied_libname from --lib
350 # - sourcebase from --source-base
351 # - m4base from --m4-base
352 # - docbase from --doc-base
353 # - testsbase from --tests-base
354 # - auxdir from --aux-dir
355 # - inctests true if --with-tests was given, blank otherwise
356 # - avoidlist list of modules to avoid, from --avoid
357 # - lgpl true if --lgpl was given, blank otherwise
358 # - libtool true if --libtool was given, false if --no-libtool was
359 # given, blank otherwise
360 # - macro_prefix from --macro-prefix
361 # - autoconf_minversion minimum supported autoconf version
362 # - do_changelog false if --no-changelog was given, : otherwise
363 # - doit : if actions shall be executed, false if only to be printed
364 # - local_gnulib_dir from --local-dir
365 # - symbolic true if --symbolic was given, blank otherwise
388 while test $# -gt 0; do
393 --import | --impor | --impo | --imp | --im | --i )
396 --update | --updat | --upda | --upd | --up | --u )
399 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
402 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
403 mode=create-megatestdir
405 --test | --tes | --te | --t )
408 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
412 mode=`echo "X$1" | sed -e 's/^X--//'`
417 func_fatal_error "missing argument for --dir"
422 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
427 func_fatal_error "missing argument for --lib"
430 supplied_libname=true
433 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
434 supplied_libname=true
439 func_fatal_error "missing argument for --source-base"
444 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
449 func_fatal_error "missing argument for --m4-base"
454 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
459 func_fatal_error "missing argument for --doc-base"
464 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
469 func_fatal_error "missing argument for --tests-base"
474 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
479 func_fatal_error "missing argument for --aux-dir"
484 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
492 func_fatal_error "missing argument for --avoid"
494 avoidlist="$avoidlist $1"
497 avoidlist="$avoidlist "`echo "X$1" | sed -e 's/^X--avoid=//'`
511 func_fatal_error "missing argument for --macro-prefix"
516 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
518 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
527 func_fatal_error "missing argument for --local-dir"
532 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
534 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
537 --help | --hel | --he | --h )
540 --version | --versio | --versi | --vers | --ver | --ve | --v )
544 # Stop option processing
548 echo "gnulib-tool: unknown option $1" 1>&2
549 echo "Try 'gnulib-tool --help' for more information." 1>&2
556 if test "$mode" = update; then
557 if test $# != 0; then
558 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
559 echo "Try 'gnulib-tool --help' for more information." 1>&2
560 echo "If you really want to modify the gnulib configuration of your project," 1>&2
561 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
564 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
565 || test -n "$sourcebase" || test -n "$m4base" \
566 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
567 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
568 || test -n "$macro_prefix"; then
569 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
570 echo "Try 'gnulib-tool --help' for more information." 1>&2
571 echo "If you really want to modify the gnulib configuration of your project," 1>&2
572 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
578 # Determine the minimum supported autoconf version from the project's
580 DEFAULT_AUTOCONF_MINVERSION="2.59"
583 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
584 if test -f "$destdir"/configure.ac; then
585 configure_ac="$destdir/configure.ac"
587 if test -f "$destdir"/configure.in; then
588 configure_ac="$destdir/configure.in"
592 if test -f configure.ac; then
593 configure_ac="configure.ac"
595 if test -f configure.in; then
596 configure_ac="configure.in"
600 if test -n "$configure_ac"; then
601 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
602 # because when some m4 files are omitted from a CVS repository,
603 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
604 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
605 # autom4te: m4 failed with exit status: 1
612 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,prereqs="$prereqs \1",p
614 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
615 if test -n "$prereqs"; then
616 autoconf_minversion=`for version in $prereqs; do echo $version; done | $SORT -g | uniq | tail -1`
619 if test -z "$autoconf_minversion"; then
620 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
622 case "$autoconf_minversion" in
623 1.* | 2.[0-4]* | 2.5[0-8]*)
624 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
627 # Remove trailing slashes from the directory names. This is necessary for
628 # m4base (to avoid an error in func_import) and optional for the others.
629 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
630 case "$local_gnulib_dir" in
631 */ ) sourcebase=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
633 case "$sourcebase" in
634 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
637 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
640 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
643 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
646 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
651 /*) self_abspathname="$0" ;;
652 */*) self_abspathname=`pwd`/"$0" ;;
653 *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
654 if test -x "$d/$0" && test ! -d "$d/$0"; then
655 self_abspathname="$d/$0"
659 if test -z "$self_abspathname"; then
660 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
664 while test -h "$self_abspathname"; do
665 # Resolve symbolic link.
666 linkval=`func_readlink "$self_abspathname"`
667 test -n "$linkval" || break
669 /* ) self_abspathname="$linkval" ;;
670 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
673 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
676 trap 'rm -rf "$tmp"' 0 1 2 3 15
678 # func_lookup_file file
679 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
682 # - local_gnulib_dir from --local-dir
684 # - lookedup_file name of the merged (combined) file
685 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
689 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
690 lookedup_file="$local_gnulib_dir/$lkfile"
693 if test -f "$gnulib_dir/$lkfile"; then
694 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
695 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
697 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
698 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
699 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
700 lookedup_file="$tmp/$lkbase"
703 lookedup_file="$gnulib_dir/$lkfile"
707 func_fatal_error "file $gnulib_dir/$lkfile not found"
714 # - local_gnulib_dir from --local-dir
717 # Filter out metainformation files like README, which are not modules.
718 # Filter out unit test modules; they can be retrieved through
719 # --extract-tests-module if desired.
721 (cd "$gnulib_dir/modules" && ls -1)
722 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
723 (cd "$local_gnulib_dir/modules" && ls -1 | sed -e 's,\.diff$,,')
726 | sed -e '/^CVS$/d' -e '/^ChangeLog$/d' -e '/^COPYING$/d' -e '/^README$/d' -e '/^TEMPLATE$/d' -e '/^TEMPLATE-TESTS$/d' -e '/~$/d' \
727 | sed -e '/-tests$/d' \
733 # verifies a module name
735 # - local_gnulib_dir from --local-dir
736 # - module module name argument
737 func_verify_module ()
739 if { test -f "$gnulib_dir/modules/$module" \
740 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
741 && test -f "$local_gnulib_dir/modules/$module"; }; } \
742 && test "CVS" != "$module" \
743 && test "ChangeLog" != "$module" \
744 && test "COPYING" != "$module" \
745 && test "README" != "$module" \
746 && test "TEMPLATE" != "$module" \
747 && test "TEMPLATE-TESTS" != "$module"; then
748 # OK, $module is a correct module name.
749 # Verify that building the module description with 'patch' succeeds.
750 func_lookup_file "modules/$module"
752 echo "gnulib-tool: module $module doesn't exist" 1>&2
757 # func_verify_nontests_module
758 # verifies a module name, excluding tests modules
760 # - local_gnulib_dir from --local-dir
761 # - module module name argument
762 func_verify_nontests_module ()
766 * ) func_verify_module ;;
770 # func_verify_tests_module
771 # verifies a module name, considering only tests modules
773 # - local_gnulib_dir from --local-dir
774 # - module module name argument
775 func_verify_tests_module ()
778 *-tests ) func_verify_module ;;
783 sed_extract_prog=':[ ]*$/ {
786 s/^Description:[ ]*$//
788 s/^Depends-on:[ ]*$//
789 s/^configure\.ac:[ ]*$//
790 s/^Makefile\.am:[ ]*$//
793 s/^Maintainer:[ ]*$//
800 # func_get_description module
802 # - local_gnulib_dir from --local-dir
803 func_get_description ()
805 func_lookup_file "modules/$1"
806 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
809 # func_get_filelist module
811 # - local_gnulib_dir from --local-dir
814 func_lookup_file "modules/$1"
815 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
816 case "$autoconf_minversion" in
819 echo m4/onceonly_2_57.m4
824 # func_get_dependencies module
826 # - local_gnulib_dir from --local-dir
827 func_get_dependencies ()
829 # ${module}-tests always implicitly depends on ${module}.
830 echo "$1" | sed -n -e 's/-tests//p'
831 # Then the explicit dependencies listed in the module description.
832 func_lookup_file "modules/$1"
833 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
836 # func_get_autoconf_snippet module
838 # - local_gnulib_dir from --local-dir
839 func_get_autoconf_snippet ()
841 func_lookup_file "modules/$1"
842 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
845 # func_get_automake_snippet module
847 # - local_gnulib_dir from --local-dir
848 func_get_automake_snippet ()
850 func_lookup_file "modules/$1"
851 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
854 # func_get_include_directive module
856 # - local_gnulib_dir from --local-dir
857 func_get_include_directive ()
859 func_lookup_file "modules/$1"
860 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
861 sed -e 's/^\(["<]\)/#include \1/'
864 # func_get_license module
866 # - local_gnulib_dir from --local-dir
869 func_lookup_file "modules/$1"
870 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
873 # func_get_maintainer module
875 # - local_gnulib_dir from --local-dir
876 func_get_maintainer ()
878 func_lookup_file "modules/$1"
879 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
882 # func_get_tests_module module
884 # - local_gnulib_dir from --local-dir
885 func_get_tests_module ()
887 # The naming convention for tests modules is hardwired: ${module}-tests.
888 if test -f "$gnulib_dir/modules/$1"-tests \
889 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
890 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
895 # func_acceptable module
896 # tests whether a module is acceptable.
898 # - avoidlist list of modules to avoid
901 for avoid in $avoidlist; do
902 if test "$avoid" = "$1"; then
909 # func_modules_transitive_closure
911 # - local_gnulib_dir from --local-dir
912 # - modules list of specified modules
913 # - inctests true if tests should be included, blank otherwise
914 # - avoidlist list of modules to avoid
916 # - modules list of modules, including dependencies
917 func_modules_transitive_closure ()
921 for module in $modules; do
923 if test -n "$module"; then
924 # Duplicate dependencies are harmless, but Jim wants a warning.
925 duplicated_deps=`func_get_dependencies $module | LC_ALL=C sort | LC_ALL=C uniq -d`
926 if test -n "$duplicated_deps"; then
927 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
929 if func_acceptable $module; then
930 xmodules="$xmodules $module"
931 for depmodule in `func_get_dependencies $module`; do
932 if func_acceptable $depmodule; then
933 xmodules="$xmodules $depmodule"
936 if test -n "$inctests"; then
937 testsmodule=`func_get_tests_module $module`
938 if test -n "$testsmodule"; then
939 if func_acceptable $testsmodule; then
940 xmodules="$xmodules $testsmodule"
941 for depmodule in `func_get_dependencies $testsmodule`; do
942 if func_acceptable $depmodule; then
943 xmodules="$xmodules $depmodule"
952 xmodules=`for m in $xmodules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
953 if test "$xmodules" = "$modules"; then
960 # func_modules_add_dummy
962 # - local_gnulib_dir from --local-dir
963 # - modules list of modules, including dependencies
965 # - modules list of modules, including 'dummy' if needed
966 func_modules_add_dummy ()
969 sed_remove_backslash_newline=':a
976 for module in $modules; do
977 func_verify_nontests_module
978 if test -n "$module"; then
979 # Extract the value of "lib_SOURCES += ...".
980 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
981 # Ignore .h files since they are not compiled.
984 *) have_lib_SOURCES=yes ;;
989 # Add the dummy module, to make sure the library will be non-empty.
990 if test -z "$have_lib_SOURCES"; then
991 modules="$modules dummy"
995 # func_modules_to_filelist
997 # - local_gnulib_dir from --local-dir
998 # - modules list of modules, including dependencies
1000 # - files list of files
1001 func_modules_to_filelist ()
1004 for module in $modules; do
1006 if test -n "$module"; then
1007 files="$files "`func_get_filelist $module`
1010 files=`for f in $files; do echo $f; done | LC_ALL=C sort | LC_ALL=C uniq`
1013 # func_emit_lib_Makefile_am
1014 # emits the contents of lib/Makefile.am to standard output.
1016 # - local_gnulib_dir from --local-dir
1017 # - modules list of modules, including dependencies
1018 # - libname library name
1019 # - libtool true if libtool will be used, false or blank otherwise
1020 # - actioncmd (optional) command that will reproduce this invocation
1021 func_emit_lib_Makefile_am ()
1023 if test "$libtool" = true; then
1030 echo "## Process this file with automake to produce Makefile.in."
1031 func_emit_copyright_notice
1032 if test -n "$actioncmd"; then
1033 echo "# Reproduce by: $actioncmd"
1036 # No need to generate dependencies since the sources are in gnulib, not here.
1037 echo "AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies"
1040 for module in $modules; do
1041 func_verify_nontests_module
1042 if test -n "$module"; then
1044 func_get_automake_snippet "$module" |
1045 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1046 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1047 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1048 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1049 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
1050 if test "$module" = 'alloca'; then
1051 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1054 # Skip the contents if its entirely empty.
1055 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1056 echo "## begin gnulib module $module"
1059 echo "## end gnulib module $module"
1066 if grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1067 # One of the snippets already specifies an installation location for the
1068 # library. Don't confuse automake by saying it should not be installed.
1071 # By default, the generated library should not be installed.
1072 echo "noinst_${perhapsLT}LIBRARIES = $libname.$libext"
1075 echo "${libname}_${libext}_SOURCES ="
1076 echo "${libname}_${libext}_LIBADD = @${perhapsLT}LIBOBJS@"
1077 echo "noinst_HEADERS ="
1078 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1079 echo "pkgdata_DATA ="
1082 echo "BUILT_SOURCES ="
1084 echo "MOSTLYCLEANFILES = core *.stackdump"
1085 echo "MOSTLYCLEANDIRS ="
1087 echo "DISTCLEANFILES ="
1088 echo "MAINTAINERCLEANFILES ="
1090 echo "AM_CPPFLAGS ="
1094 echo "mostlyclean-local: mostlyclean-generic"
1095 echo " @test -z \"\$(MOSTLYCLEANDIRS)\" || \\"
1096 echo " for dir in \$(MOSTLYCLEANDIRS); do \\"
1097 echo " if test -d \$\$dir; then \\"
1098 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1102 echo "# Makefile.am ends here"
1103 rm -f allsnippets.tmp
1106 # func_emit_tests_Makefile_am
1107 # emits the contents of tests/Makefile.am to standard output.
1109 # - local_gnulib_dir from --local-dir
1110 # - modules list of modules, including dependencies
1111 # - libname library name
1112 # - libtool true if libtool will be used, false or blank otherwise
1113 # - sourcebase relative directory containing lib source code
1114 # - m4base relative directory containing autoconf macros
1115 # - testsbase relative directory containing unit test code
1116 func_emit_tests_Makefile_am ()
1118 if test "$libtool" = true; then
1123 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1124 echo "## Process this file with automake to produce Makefile.in."
1125 func_emit_copyright_notice
1127 # Generate dependencies here, since it eases the debugging of test failures.
1128 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1130 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1133 for module in $modules; do
1134 func_verify_tests_module
1135 if test -n "$module"; then
1136 func_get_automake_snippet "$module" > amsnippet.tmp
1137 # Skip the contents if its entirely empty.
1138 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1139 echo "## begin gnulib module $module"
1142 echo "## end gnulib module $module"
1149 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1150 # variable is needed to avoid an error from automake:
1151 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1154 echo "TESTS_ENVIRONMENT ="
1155 echo "noinst_PROGRAMS ="
1156 echo "check_PROGRAMS ="
1157 echo "noinst_HEADERS ="
1158 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1159 echo "pkgdata_DATA ="
1162 echo "BUILT_SOURCES ="
1164 echo "MOSTLYCLEANFILES = core *.stackdump"
1165 echo "MOSTLYCLEANDIRS ="
1167 echo "DISTCLEANFILES ="
1168 echo "MAINTAINERCLEANFILES ="
1170 echo "AM_CPPFLAGS = \\"
1171 echo " -I. -I\$(srcdir) \\"
1172 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1173 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1175 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1178 echo "# Clean up after Solaris cc."
1180 echo " rm -rf SunWS_cache"
1182 echo "mostlyclean-local: mostlyclean-generic"
1183 echo " @test -z \"\$(MOSTLYCLEANDIRS)\" || \\"
1184 echo " for dir in \$(MOSTLYCLEANDIRS); do \\"
1185 echo " if test -d \$\$dir; then \\"
1186 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1190 echo "# Makefile.am ends here"
1191 rm -f allsnippets.tmp
1194 # func_import modules
1195 # Uses also the variables
1196 # - destdir target directory
1197 # - local_gnulib_dir from --local-dir
1198 # - libname library name
1199 # - sourcebase directory relative to destdir where to place source code
1200 # - m4base directory relative to destdir where to place *.m4 macros
1201 # - docbase directory relative to destdir where to place doc files
1202 # - testsbase directory relative to destdir where to place unit test code
1203 # - auxdir directory relative to destdir where to place build aux files
1204 # - inctests true if --with-tests was given, blank otherwise
1205 # - avoidlist list of modules to avoid, from --avoid
1206 # - lgpl true if library's license shall be LGPL, blank otherwise
1207 # - libtool true if --libtool was given, false if --no-libtool was
1208 # given, blank otherwise
1209 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1210 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1211 # - autoconf_minversion minimum supported autoconf version
1212 # - doit : if actions shall be executed, false if only to be printed
1213 # - symbolic true if files should be symlinked, copied otherwise
1216 # Get the cached settings.
1217 cached_local_gnulib_dir=
1218 cached_specified_modules=
1227 cached_macro_prefix=
1229 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1230 cached_libtool=false
1236 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
1239 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1242 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1245 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1248 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1251 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1254 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1257 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1260 s,^.*$,cached_lgpl=true,p
1263 s,^.*$,cached_libtool=true,p
1265 /gl_MACRO_PREFIX(/ {
1266 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
1268 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
1269 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1274 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
1275 s,^.*$,cached_files=",p
1287 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1291 # Merge the cached settings with the specified ones.
1292 # The m4base must be the same as expected from the pathname.
1293 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1294 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1296 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
1297 # is relative to $destdir, whereas the one we use is relative to . or absolute.
1298 if test -z "$local_gnulib_dir"; then
1299 if test -n "$cached_local_gnulib_dir"; then
1302 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1304 case "$cached_local_gnulib_dir" in
1306 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1308 func_relconcat "$destdir" "$cached_local_gnulib_dir"
1309 local_gnulib_dir="$relconcat" ;;
1314 # Append the cached and the specified module names. So that
1315 # "gnulib-tool --import foo" means to add the module foo.
1316 specified_modules="$cached_specified_modules $1"
1317 # Append the cached and the specified avoidlist. This is probably better
1318 # than dropping the cached one when --avoid is specified at least once.
1319 avoidlist=`echo $cached_avoidlist $avoidlist`
1320 # The sourcebase defaults to the cached one.
1321 if test -z "$sourcebase"; then
1322 sourcebase="$cached_sourcebase"
1323 if test -z "$sourcebase"; then
1324 func_fatal_error "missing --source-base option"
1327 # The docbase defaults to the cached one.
1328 if test -z "$docbase"; then
1329 docbase="$cached_docbase"
1330 if test -z "$docbase"; then
1331 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."
1334 # The testsbase defaults to the cached one.
1335 if test -z "$testsbase"; then
1336 testsbase="$cached_testsbase"
1337 if test -z "$testsbase"; then
1338 func_fatal_error "missing --tests-base option"
1341 # The libname defaults to the cached one.
1342 if test -z "$supplied_libname"; then
1343 libname="$cached_libname"
1344 if test -z "$libname"; then
1345 func_fatal_error "missing --lib option"
1348 # Require LGPL if specified either way.
1349 if test -z "$lgpl"; then
1352 # Use libtool if specified either way, or if guessed.
1353 if test -z "$libtool"; then
1354 if test -n "$cached_m4base"; then
1355 libtool="$cached_libtool"
1357 libtool="$guessed_libtool"
1360 # The macro_prefix defaults to the cached one.
1361 if test -z "$macro_prefix"; then
1362 macro_prefix="$cached_macro_prefix"
1363 if test -z "$macro_prefix"; then
1364 func_fatal_error "missing --macro-prefix option"
1368 # Canonicalize the list of specified modules.
1369 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
1371 # Determine final module list.
1372 modules="$specified_modules"
1373 func_modules_transitive_closure
1374 echo "Module list with included dependencies:"
1375 echo "$modules" | sed -e 's/^/ /'
1377 # Add the dummy module if needed.
1378 func_modules_add_dummy
1380 # If --lgpl, check the license of modules are compatible.
1381 if test -n "$lgpl"; then
1382 for module in $modules; do
1383 license=`func_get_license $module`
1385 LGPL | 'GPLed build tool' | 'public domain' | 'unlimited') ;;
1386 *) func_fatal_error "incompatible license on module $module: $license" ;;
1391 # Determine script to apply to imported library files.
1392 sed_transform_lib_file=
1393 case $nl$modules$nl in
1394 *"${nl}config-h$nl"*)
1395 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
1396 sed_transform_lib_file=$sed_transform_lib_file'
1397 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
1400 if test -n "$lgpl"; then
1402 sed_transform_lib_file=$sed_transform_lib_file'
1403 s/GNU General/GNU Lesser General/g
1404 s/version 2\([ ,]\)/version 2.1\1/g
1408 # Determine final file list.
1409 func_modules_to_filelist
1411 echo "$files" | sed -e 's/^/ /'
1414 || func_fatal_error "refusing to do nothing"
1416 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
1417 new_files="$files m4/gnulib-tool.m4"
1418 old_files="$cached_files"
1419 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
1420 old_files="$old_files m4/gnulib-tool.m4"
1423 # Create directories.
1424 if test ! -d "$destdir/$sourcebase"; then
1426 echo "Creating directory $destdir/$sourcebase"
1427 mkdir "$destdir/$sourcebase" || func_fatal_error "failed"
1429 echo "Create directory $destdir/$sourcebase"
1432 if test ! -d "$destdir/$m4base"; then
1434 echo "Creating directory $destdir/$m4base"
1435 mkdir "$destdir/$m4base" || func_fatal_error "failed"
1437 echo "Create directory $destdir/$m4base"
1440 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
1441 if test -n "$docfiles"; then
1442 if test ! -d "$destdir/$docbase"; then
1444 echo "Creating directory $destdir/$docbase"
1445 mkdir "$destdir/$docbase" || func_fatal_error "failed"
1447 echo "Create directory $destdir/$docbase"
1451 if test -n "$inctests"; then
1452 if test ! -d "$destdir/$testsbase"; then
1454 echo "Creating directory $destdir/$testsbase"
1455 mkdir "$destdir/$testsbase" || func_fatal_error "failed"
1457 echo "Create directory $destdir/$testsbase"
1461 if test ! -d "$destdir/$auxdir"; then
1463 echo "Creating directory $destdir/$auxdir"
1464 mkdir "$destdir/$auxdir" || func_fatal_error "failed"
1466 echo "Create directory $destdir/$auxdir"
1470 # func_dest_tmpfilename file
1471 # determines the name of a temporary file (file is relative to destdir).
1473 # - tmpfile absolute filename of the temporary file
1474 func_dest_tmpfilename ()
1477 # Put the new contents of $file in a file in the same directory (needed
1478 # to guarantee that an 'mv' to "$destdir/$file" works).
1479 tmpfile="$destdir/$1.tmp"
1481 # Put the new contents of $file in a file in a temporary directory
1482 # (because the directory of "$file" might not exist).
1483 tmpfile="$tmp"/`basename "$1"`.tmp
1487 # Copy files or make symbolic links. Remove obsolete files.
1489 for f in $old_files; do
1491 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1492 doc/*) g=`echo "$f" | sed -e "s,^doc/,$cached_docbase/,"` ;;
1493 lib/*) g=`echo "$f" | sed -e "s,^lib/,$cached_sourcebase/,"` ;;
1494 m4/*) g=`echo "$f" | sed -e "s,^m4/,$cached_m4base/,"` ;;
1495 tests/*) g=`echo "$f" | sed -e "s,^tests/,$cached_testsbase/,"` ;;
1498 echo "$g""$delimiter""$f"
1499 done | LC_ALL=C sort > "$tmp"/old-files
1500 for f in $new_files; do
1502 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1503 doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
1504 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1505 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1506 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1509 echo "$g""$delimiter""$f"
1510 done | LC_ALL=C sort > "$tmp"/new-files
1511 # First the files that are in old-files, but not in new-files:
1512 sed_take_first_column='s,'"$delimiter"'.*,,'
1513 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
1514 # Remove the file. Do nothing if the user already removed it.
1515 if test -f "$destdir/$g"; then
1517 echo "Removing file $g (backup in ${g}~)"
1518 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1520 echo "Remove file $g (backup in ${g}~)"
1524 # func_add_or_update handles a file that ought to be present afterwards.
1525 # Uses parameters f, g, already_present.
1526 func_add_or_update ()
1528 func_dest_tmpfilename "$g"
1529 func_lookup_file "$f"
1530 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
1531 if test -n "sed_transform_lib_file"; then
1534 sed -e "$sed_transform_lib_file" \
1535 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
1539 if test -f "$destdir/$g"; then
1540 # The file already exists.
1541 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1542 : # The file has not changed.
1546 if test -n "$already_present"; then
1547 echo "Updating file $g (backup in ${g}~)"
1549 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
1551 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1552 if test -n "$symbolic" && test -z "$lookedup_tmp" \
1553 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1554 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1556 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1559 if test -n "$already_present"; then
1560 echo "Update file $g (backup in ${g}~)"
1562 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
1568 # Don't protest if the file should be there but isn't: it happens
1569 # frequently that developers don't put autogenerated files into CVS.
1571 echo "Copying file $g"
1572 if test -n "$symbolic" && test -z "$lookedup_tmp" \
1573 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1574 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1576 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1584 # Then the files that are in new-files, but not in old-files:
1585 sed_take_last_column='s,^.*'"$delimiter"',,'
1587 for f in `LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_last_column"`; do
1589 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1590 doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
1591 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1592 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1593 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1598 # Then the files that are in new-files and in old-files:
1599 already_present=true
1600 for f in `LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_last_column"`; do
1602 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1603 doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
1604 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1605 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1606 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1612 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
1613 actioncmd="gnulib-tool --import"
1614 actioncmd="$actioncmd --dir=$destdir"
1615 if test -n "$local_gnulib_dir"; then
1616 actioncmd="$actioncmd --local-dir=$local_gnulib_dir"
1618 actioncmd="$actioncmd --lib=$libname"
1619 actioncmd="$actioncmd --source-base=$sourcebase"
1620 actioncmd="$actioncmd --m4-base=$m4base"
1621 actioncmd="$actioncmd --doc-base=$docbase"
1622 actioncmd="$actioncmd --aux-dir=$auxdir"
1623 for module in $avoidlist; do
1624 actioncmd="$actioncmd --avoid=$module"
1626 if test -n "$lgpl"; then
1627 actioncmd="$actioncmd --lgpl"
1629 if test "$libtool" = true; then
1630 actioncmd="$actioncmd --libtool"
1632 actioncmd="$actioncmd --no-libtool"
1634 actioncmd="$actioncmd --macro-prefix=$macro_prefix"
1635 actioncmd="$actioncmd `echo $specified_modules`"
1637 # Create lib/Makefile.am.
1638 func_dest_tmpfilename $sourcebase/Makefile.am
1639 func_emit_lib_Makefile_am > "$tmpfile"
1640 if test -f "$destdir"/$sourcebase/Makefile.am; then
1641 if cmp "$destdir"/$sourcebase/Makefile.am "$tmpfile" > /dev/null; then
1645 echo "Updating $sourcebase/Makefile.am (backup in $sourcebase/Makefile.am~)"
1646 mv -f "$destdir"/$sourcebase/Makefile.am "$destdir"/$sourcebase/Makefile.am~
1647 mv -f "$tmpfile" "$destdir"/$sourcebase/Makefile.am
1649 echo "Update $sourcebase/Makefile.am (backup in $sourcebase/Makefile.am~)"
1655 echo "Creating $sourcebase/Makefile.am"
1656 mv -f "$tmpfile" "$destdir"/$sourcebase/Makefile.am
1658 echo "Create $sourcebase/Makefile.am"
1663 # Create m4/gnulib-cache.m4.
1664 func_dest_tmpfilename $m4base/gnulib-cache.m4
1666 func_emit_copyright_notice
1668 echo "# This file represents the specification of how gnulib-tool is used."
1669 echo "# It acts as a cache: It is written and read by gnulib-tool."
1670 echo "# In projects using CVS, this file is meant to be stored in CVS,"
1671 echo "# like the configure.ac and various Makefile.am files."
1674 echo "# Specification in the form of a command-line invocation:"
1677 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
1678 # Store the local_gnulib_dir relative to destdir.
1679 case "$local_gnulib_dir" in
1681 relative_local_gnulib_dir="$local_gnulib_dir" ;;
1684 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
1686 # destdir, local_gnulib_dir are both relative.
1687 func_relativize "$destdir" "$local_gnulib_dir"
1688 relative_local_gnulib_dir="$reldir" ;;
1691 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
1692 echo "gl_MODULES(["`echo $specified_modules`"])"
1693 echo "gl_AVOID([$avoidlist])"
1694 echo "gl_SOURCE_BASE([$sourcebase])"
1695 echo "gl_M4_BASE([$m4base])"
1696 echo "gl_DOC_BASE([$docbase])"
1697 echo "gl_TESTS_BASE([$testsbase])"
1698 echo "gl_LIB([$libname])"
1699 test -z "$lgpl" || echo "gl_LGPL"
1700 if test "$libtool" = true; then
1703 echo "gl_MACRO_PREFIX([$macro_prefix])"
1705 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1706 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
1710 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1711 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
1712 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
1714 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1718 echo "# gnulib-cache.m4 ends here"
1725 echo "Creating $m4base/gnulib-cache.m4"
1726 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
1728 echo "Create $m4base/gnulib-cache.m4"
1734 # Create m4/gnulib-comp.m4.
1735 func_dest_tmpfilename $m4base/gnulib-comp.m4
1737 func_emit_copyright_notice
1739 echo "# This file represents the compiled summary of the specification in"
1740 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
1741 echo "# to be invoked from configure.ac."
1742 echo "# In projects using CVS, this file can be treated like other built files."
1745 echo "# This macro should be invoked from $configure_ac, in the section"
1746 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
1747 echo "# any checks for libraries, header files, types and library functions."
1748 echo "AC_DEFUN([${macro_prefix}_EARLY],"
1750 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
1751 echo " m4_pattern_allow([^gl_ES$])dnl a valid locale name"
1752 echo " AC_REQUIRE([AC_PROG_RANLIB])"
1753 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1754 echo " AC_REQUIRE([AC_GNU_SOURCE])"
1756 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1757 echo " AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])"
1759 if grep gl_LOCK "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1760 echo " AC_REQUIRE([gl_LOCK_EARLY])"
1764 echo "# This macro should be invoked from $configure_ac, in the section"
1765 echo "# \"Check for header files, types and library functions\"."
1766 echo "AC_DEFUN([${macro_prefix}_INIT],"
1768 if test "$libtool" = true; then
1769 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1771 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1773 if test "$auxdir" != "build-aux"; then
1774 sed_replace_build_aux='
1776 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
1777 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
1780 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
1782 sed_replace_build_aux=
1784 for module in $modules; do
1786 if test -n "$module"; then
1787 func_get_autoconf_snippet "$module" \
1788 | sed -e '/^$/d;' -e 's/^/ /' \
1789 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
1790 -e "$sed_replace_build_aux"
1791 if test "$module" = 'alloca' && test "$libtool" = true; then
1792 echo 'changequote(,)dnl'
1793 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
1794 echo 'changequote([, ])dnl'
1795 echo 'AC_SUBST([LTALLOCA])'
1801 echo "# This macro records the list of files which have been installed by"
1802 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
1803 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
1804 echo "$files" | sed -e 's,^, ,'
1807 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1808 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
1812 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1813 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
1814 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
1816 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1820 echo "# gnulib-comp.m4 ends here"
1827 echo "Creating $m4base/gnulib-comp.m4"
1828 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
1830 echo "Create $m4base/gnulib-comp.m4"
1836 if test -n "$inctests"; then
1837 # Create tests/Makefile.am.
1838 func_dest_tmpfilename $testsbase/Makefile.am
1839 func_emit_tests_Makefile_am > "$tmpfile"
1840 if test -f "$destdir"/$testsbase/Makefile.am; then
1841 if cmp "$destdir"/$testsbase/Makefile.am "$tmpfile" > /dev/null; then
1845 echo "Updating $testsbase/Makefile.am (backup in $testsbase/Makefile.am~)"
1846 mv -f "$destdir"/$testsbase/Makefile.am "$destdir"/$testsbase/Makefile.am~
1847 mv -f "$tmpfile" "$destdir"/$testsbase/Makefile.am
1849 echo "Update $testsbase/Makefile.am (backup in $testsbase/Makefile.am~)"
1855 echo "Creating $testsbase/Makefile.am"
1856 mv -f "$tmpfile" "$destdir"/$testsbase/Makefile.am
1858 echo "Create $testsbase/Makefile.am"
1866 echo "You may need to add #include directives for the following .h files."
1868 # First the #include <...> directives without #ifs, sorted for convenience.
1869 for module in $modules; do
1870 if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
1873 func_get_include_directive "$module" | grep -v 'include "'
1875 done | LC_ALL=C sort -u
1876 # Then the #include "..." directives without #ifs, sorted for convenience.
1877 for module in $modules; do
1878 if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
1881 func_get_include_directive "$module" | grep 'include "'
1883 done | LC_ALL=C sort -u
1884 # Then the #include directives that are surrounded by #ifs. Not sorted.
1885 for module in $modules; do
1886 if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
1887 func_get_include_directive "$module"
1890 ) | sed -e '/^$/d;' -e 's/^/ /'
1892 echo "Don't forget to"
1893 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1894 if test -n "$inctests"; then
1895 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1897 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
1898 sourcebase_base=`basename "$sourcebase"`
1899 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
1900 if test -n "$inctests"; then
1901 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
1902 testsbase_base=`basename "$testsbase"`
1903 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
1905 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
1906 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
1907 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
1910 # func_create_testdir testdir modules
1912 # - local_gnulib_dir from --local-dir
1913 # - auxdir directory relative to destdir where to place build aux files
1914 func_create_testdir ()
1918 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
1920 # Subdirectory names.
1925 # Determine final module list.
1926 func_modules_transitive_closure
1927 echo "Module list with included dependencies:"
1928 echo "$modules" | sed -e 's/^/ /'
1930 # Add the dummy module if needed.
1931 func_modules_add_dummy
1933 # Determine final file list.
1934 func_modules_to_filelist
1936 echo "$files" | sed -e 's/^/ /'
1938 # Create directories.
1939 for d in `echo "$files" | sed -n -e 's,^\(.*\)/[^/]*,\1,p'`; do
1941 build-aux) mkdir -p "$testdir/$auxdir" ;;
1942 lib) mkdir -p "$testdir/$sourcebase" ;;
1943 m4) mkdir -p "$testdir/$m4base" ;;
1944 tests) mkdir -p "$testdir/$testsbase" ;;
1945 *) mkdir -p "$testdir/$d" ;;
1949 # Copy files or make symbolic links.
1951 func_lookup_file "$f"
1953 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1954 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1955 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1956 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1959 if test -n "$lookedup_tmp"; then
1960 cp -p "$lookedup_file" "$testdir/$g"
1962 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
1963 if test -z "$symbolic"; then
1964 cp -p "$lookedup_file" "$testdir/$g"
1966 ln -s "$lookedup_file" "$testdir/$g"
1971 # Create $sourcebase/Makefile.am.
1972 mkdir -p "$testdir/$sourcebase"
1973 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
1975 # Create $m4base/Makefile.am.
1976 mkdir -p "$testdir/$m4base"
1977 (echo "## Process this file with automake to produce Makefile.in."
1983 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
1986 ) > "$testdir/$m4base/Makefile.am"
1988 subdirs="$sourcebase $m4base"
1989 subdirs_with_configure_ac=""
1991 if test -f "$testdir"/$m4base/gettext.m4; then
1992 # Avoid stupid error message from automake:
1993 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
1994 mkdir -p "$testdir/po"
1995 (echo "## Process this file with automake to produce Makefile.in."
1996 ) > "$testdir/po/Makefile.am"
1997 subdirs="$subdirs po"
2000 if test -n "$inctests"; then
2001 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
2002 # Create $testsbase/Makefile.am.
2003 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
2004 # Create $testsbase/configure.ac.
2005 (echo "# Process this file with autoconf to produce a configure script."
2006 echo "AC_INIT([dummy], [0])"
2007 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
2008 echo "AM_INIT_AUTOMAKE"
2010 echo "AM_CONFIG_HEADER([config.h])"
2013 echo "AC_PROG_INSTALL"
2014 echo "AC_PROG_MAKE_SET"
2015 echo "AC_PROG_RANLIB"
2017 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2018 echo "AC_GNU_SOURCE"
2021 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2022 echo "gl_USE_SYSTEM_EXTENSIONS"
2025 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2026 echo "gl_LOCK_EARLY"
2029 if test "$libtool" = true; then
2030 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2032 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2034 # Wrap the set of autoconf snippets into an autoconf macro that is then
2035 # invoked. This is needed because autoconf does not support AC_REQUIRE
2037 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2038 # but we want the AC_REQUIRE to have its normal meaning (provide one
2039 # expansion of the required macro before the current point, and only one
2041 echo "AC_DEFUN([gl_INIT], ["
2042 if test "$auxdir" != "build-aux"; then
2043 sed_replace_build_aux='
2045 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2046 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
2049 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2051 sed_replace_build_aux=
2053 # We don't have explicit ordering constraints between the various
2054 # autoconf snippets. It's cleanest to put those of the library before
2055 # those of the tests.
2056 for module in $modules; do
2057 func_verify_nontests_module
2058 if test -n "$module"; then
2059 func_get_autoconf_snippet "$module" \
2060 | sed -e "$sed_replace_build_aux"
2063 for module in $modules; do
2064 func_verify_tests_module
2065 if test -n "$module"; then
2066 func_get_autoconf_snippet "$module" \
2067 | sed -e "$sed_replace_build_aux"
2073 # Usually $testsbase/config.h will be a superset of config.h. Verify this
2074 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
2075 echo "AH_TOP([#include \"../config.h\"])"
2077 echo "AC_OUTPUT([Makefile])"
2078 ) > "$testdir/$testsbase/configure.ac"
2079 subdirs="$subdirs $testsbase"
2080 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
2083 # Create Makefile.am.
2084 (echo "## Process this file with automake to produce Makefile.in."
2086 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2088 echo "SUBDIRS = $subdirs"
2090 echo "ACLOCAL_AMFLAGS = -I $m4base"
2091 ) > "$testdir/Makefile.am"
2093 # Create configure.ac.
2094 (echo "# Process this file with autoconf to produce a configure script."
2095 echo "AC_INIT([dummy], [0])"
2096 if test "$auxdir" != "."; then
2097 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2099 echo "AM_INIT_AUTOMAKE"
2101 echo "AM_CONFIG_HEADER([config.h])"
2104 echo "AC_PROG_INSTALL"
2105 echo "AC_PROG_MAKE_SET"
2107 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2108 echo "m4_pattern_allow([^gl_ES$])dnl a valid locale name"
2110 echo "AC_PROG_RANLIB"
2112 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2113 echo "AC_GNU_SOURCE"
2116 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2117 echo "gl_USE_SYSTEM_EXTENSIONS"
2120 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2121 echo "gl_LOCK_EARLY"
2124 if test "$libtool" = true; then
2125 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2127 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2129 # Wrap the set of autoconf snippets into an autoconf macro that is then
2130 # invoked. This is needed because autoconf does not support AC_REQUIRE
2132 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2133 # but we want the AC_REQUIRE to have its normal meaning (provide one
2134 # expansion of the required macro before the current point, and only one
2136 echo "AC_DEFUN([gl_INIT], ["
2137 if test "$auxdir" != "build-aux"; then
2138 sed_replace_build_aux='
2140 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2141 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2144 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2146 sed_replace_build_aux=
2148 for module in $modules; do
2149 func_verify_nontests_module
2150 if test -n "$module"; then
2151 func_get_autoconf_snippet "$module" \
2152 | sed -e "$sed_replace_build_aux"
2158 if test -n "$subdirs_with_configure_ac"; then
2159 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
2161 makefiles="Makefile"
2162 for d in $subdirs; do
2163 # For subdirs that have a configure.ac by their own, it's the subdir's
2164 # configure.ac which creates the subdir's Makefile.am, not this one.
2165 case " $subdirs_with_configure_ac " in
2167 *) makefiles="$makefiles $d/Makefile" ;;
2170 echo "AC_OUTPUT([$makefiles])"
2171 ) > "$testdir/configure.ac"
2173 # Create autogenerated files.
2175 echo "executing ${AUTORECONF} --force --install"
2176 ${AUTORECONF} --force --install
2178 if grep '^BUILT_SOURCES *+=' "$testdir/$sourcebase/Makefile.am" > /dev/null; then
2182 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
2190 # func_create_megatestdir megatestdir allmodules
2192 # - local_gnulib_dir from --local-dir
2193 # - auxdir directory relative to destdir where to place build aux files
2194 func_create_megatestdir ()
2198 if test -z "$allmodules"; then
2199 allmodules=`func_all_modules`
2203 # First, all modules one by one.
2204 for onemodule in $allmodules; do
2205 func_create_testdir "$megatestdir/$onemodule" $onemodule
2206 megasubdirs="${megasubdirs}$onemodule "
2208 # Then, all modules all together.
2209 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2210 allmodules=`for m in $allmodules; do if test $m != fnmatch-posix; then echo $m; fi; done`
2211 func_create_testdir "$megatestdir/ALL" "$allmodules"
2212 megasubdirs="${megasubdirs}ALL"
2214 # Create Makefile.am.
2215 (echo "## Process this file with automake to produce Makefile.in."
2217 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2219 echo "SUBDIRS = $megasubdirs"
2220 ) > "$megatestdir/Makefile.am"
2222 # Create configure.ac.
2223 (echo "# Process this file with autoconf to produce a configure script."
2224 echo "AC_INIT([dummy], [0])"
2225 if test "$auxdir" != "."; then
2226 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2228 echo "AM_INIT_AUTOMAKE"
2230 echo "AC_PROG_MAKE_SET"
2232 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
2233 echo "AC_OUTPUT([Makefile])"
2234 ) > "$megatestdir/configure.ac"
2236 # Create autogenerated files.
2238 # Do not use "${AUTORECONF} --install", because autoreconf operates
2239 # recursively, but the subdirectories are already finished, therefore
2240 # calling autoreconf here would only waste lots of CPU time.
2241 echo "executing ${ACLOCAL}"
2243 echo "executing mkdir build-aux"
2245 echo "executing ${AUTOCONF}"
2247 echo "executing ${AUTOMAKE} --add-missing --copy"
2248 ${AUTOMAKE} --add-missing --copy
2254 func_fatal_error "no mode specified" ;;
2263 if test -z "$destdir"; then
2266 test -d "$destdir" \
2267 || func_fatal_error "destination directory does not exist: $destdir"
2269 # Prefer configure.ac to configure.in.
2270 if test -f "$destdir"/configure.ac; then
2271 configure_ac="$destdir/configure.ac"
2273 if test -f "$destdir"/configure.in; then
2274 configure_ac="$destdir/configure.in"
2276 func_fatal_error "cannot find $destdir/configure.ac"
2280 # Analyze configure.ac.
2282 guessed_libtool=false
2287 /AC_CONFIG_AUX_DIR/ {
2288 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
2290 /A[CM]_PROG_LIBTOOL/ {
2291 s,^.*$,guessed_libtool=true,p
2293 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
2295 if test -z "$auxdir"; then
2296 auxdir="$guessed_auxdir"
2299 # Determine where to apply func_import.
2300 if test -n "$m4base"; then
2301 # Apply func_import to a particular gnulib directory.
2302 # Any number of additional modules can be given.
2303 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
2304 # First use of gnulib in the given m4base.
2305 test -n "$supplied_libname" || supplied_libname=true
2306 test -n "$sourcebase" || sourcebase="lib"
2307 test -n "$docbase" || docbase="doc"
2308 test -n "$testsbase" || testsbase="tests"
2309 test -n "$macro_prefix" || macro_prefix="gl"
2313 # Apply func_import to all gnulib directories.
2314 # To get this list of directories, look at Makefile.am. (Not at
2315 # configure, because it may be omitted from CVS. Also, don't run
2316 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
2319 if test -f "$destdir"/Makefile.am; then
2320 aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$destdir"/Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'`
2322 for arg in $aclocal_amflags; do
2323 if test -n "$m4dir_is_next"; then
2324 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
2328 if test -f "$destdir/$arg"/gnulib-cache.m4; then
2329 m4dirs="$m4dirs $arg"
2330 m4dirs_count=`expr $m4dirs_count + 1`
2335 if test "X$arg" = "X-I"; then
2343 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
2344 if test -f "$destdir"/aclocal.m4; then
2345 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
2346 sedexpr2='s,^[^/]*$,.,'
2347 sedexpr3='s,/[^/]*$,,'
2348 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort | LC_ALL=C uniq`
2349 m4dirs_count=`echo "$m4dirs" | wc -l`
2352 if test $m4dirs_count = 0; then
2353 # First use of gnulib in a package.
2354 # Any number of additional modules can be given.
2355 test -n "$supplied_libname" || supplied_libname=true
2356 test -n "$sourcebase" || sourcebase="lib"
2358 test -n "$docbase" || docbase="doc"
2359 test -n "$testsbase" || testsbase="tests"
2360 test -n "$macro_prefix" || macro_prefix="gl"
2363 if test $m4dirs_count = 1; then
2364 # There's only one use of gnulib here. Assume the user means it.
2365 # Any number of additional modules can be given.
2366 for m4base in $m4dirs; do
2370 # Ambiguous - guess what the user meant.
2371 if test $# = 0; then
2372 # No further arguments. Guess the user wants to update all of them.
2373 for m4base in $m4dirs; do
2378 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
2386 if test -z "$destdir"; then
2387 func_fatal_error "please specify --dir option"
2390 test -d "$destdir" \
2391 || func_fatal_error "could not create destination directory"
2392 test -n "$auxdir" || auxdir="build-aux"
2393 func_create_testdir "$destdir" "$*"
2396 create-megatestdir )
2397 if test -z "$destdir"; then
2398 func_fatal_error "please specify --dir option"
2400 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2401 test -n "$auxdir" || auxdir="build-aux"
2402 func_create_megatestdir "$destdir" "$*"
2406 test -n "$destdir" || destdir=testdir$$
2407 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2408 test -n "$auxdir" || auxdir="build-aux"
2409 func_create_testdir "$destdir" "$*"
2417 remaining=`find . -type f -print`
2418 if test -n "$remaining"; then
2419 echo "Remaining files:" $remaining 1>&2
2420 echo "gnulib-tool: *** Stop." 1>&2
2429 test -n "$destdir" || destdir=testdir$$
2430 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2431 test -n "$auxdir" || auxdir="build-aux"
2432 func_create_megatestdir "$destdir" "$*"
2440 remaining=`find . -type f -print`
2441 if test -n "$remaining"; then
2442 echo "Remaining files:" $remaining 1>&2
2443 echo "gnulib-tool: *** Stop." 1>&2
2451 extract-description )
2455 if test -n "$module"; then
2456 func_get_description "$module"
2465 if test -n "$module"; then
2466 func_get_filelist "$module"
2471 extract-dependencies )
2475 if test -n "$module"; then
2476 func_get_dependencies "$module"
2481 extract-autoconf-snippet )
2485 if test -n "$module"; then
2486 func_get_autoconf_snippet "$module"
2491 extract-automake-snippet )
2495 if test -n "$module"; then
2496 func_get_automake_snippet "$module"
2501 extract-include-directive )
2505 if test -n "$module"; then
2506 func_get_include_directive "$module"
2515 if test -n "$module"; then
2516 func_get_license "$module"
2521 extract-maintainer )
2525 if test -n "$module"; then
2526 func_get_maintainer "$module"
2531 extract-tests-module )
2535 if test -n "$module"; then
2536 func_get_tests_module "$module"
2542 func_fatal_error "unknown operation mode --$mode" ;;
2546 # Undo the effect of the previous 'trap' command. Some shellology:
2547 # We cannot use "trap - 0 1 2 3 15", because Solaris sh would attempt to
2548 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
2549 # exit); for the others we need to call 'exit' explicitly. The value of $? is
2550 # 128 + signal number and is set before the trap-registered command is run.
2552 trap 'exit $?' 1 2 3 15