3 # Copyright (C) 2002-2007 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # This program is meant for authors or maintainers which want to import
21 # modules from gnulib into their packages.
25 cvsdatestamp='$Date: 2007-04-12 13:02:00 $'
26 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
27 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
31 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
35 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
36 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
40 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
43 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
46 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
47 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
48 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
49 AUTOCONF="${AUTOCONFPATH}autoconf"
51 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
52 AUTOHEADER="${AUTOCONFPATH}autoheader"
54 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
55 ACLOCAL="${AUTOMAKEPATH}aclocal"
57 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
58 AUTOMAKE="${AUTOMAKEPATH}automake"
60 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
61 AUTORECONF="${AUTOCONFPATH}autoreconf"
64 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
65 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
66 AUTOPOINT="${GETTEXTPATH}autopoint"
69 # When using GNU sed, turn off as many GNU extensions as possible,
70 # to minimize the risk of accidentally using non-portable features.
71 # However, do this only for gnulib-tool itself, not for the code that
72 # gnulib-tool generates, since we don't want "sed --posix" to leak
74 if (alias) > /dev/null 2>&1 && echo | sed --posix -e d >/dev/null 2>&1; then
75 alias sed='sed --posix'
79 # outputs to stdout the --help usage message.
83 Usage: gnulib-tool --list
84 gnulib-tool --import [module1 ... moduleN]
86 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
87 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
88 gnulib-tool --test --dir=directory module1 ... moduleN
89 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
90 gnulib-tool --extract-description module
91 gnulib-tool --extract-filelist module
92 gnulib-tool --extract-dependencies module
93 gnulib-tool --extract-autoconf-snippet module
94 gnulib-tool --extract-automake-snippet module
95 gnulib-tool --extract-include-directive module
96 gnulib-tool --extract-link-directive module
97 gnulib-tool --extract-license module
98 gnulib-tool --extract-maintainer module
99 gnulib-tool --extract-tests-module module
102 --list print the available module names
103 --import import the given modules into the current package;
104 if no modules are specified, update the current
105 package from the current gnulib
106 --update update the current package, restore files omitted
108 --create-testdir create a scratch package with the given modules
109 --create-megatestdir create a mega scratch package with the given modules
110 one by one and all together
111 --test test the combination of the given modules
112 (recommended to use CC=\"gcc -Wall\" here)
113 --megatest test the given modules one by one and all together
114 (recommended to use CC=\"gcc -Wall\" here)
115 --extract-description extract the description
116 --extract-filelist extract the list of files
117 --extract-dependencies extract the dependencies
118 --extract-autoconf-snippet extract the snippet for configure.ac
119 --extract-automake-snippet extract the snippet for library makefile
120 --extract-include-directive extract the #include directive
121 --extract-link-directive extract the linker directive
122 --extract-license report the license terms of the source files
124 --extract-maintainer report the maintainer(s) inside gnulib
125 --extract-tests-module report the unit test module, if it exists
128 --dir=DIRECTORY Specify the target directory.
129 For --import, this specifies where your
130 configure.ac can be found. Defaults to current
132 --local-dir=DIRECTORY Specify a local override directory where to look
133 up files before looking in gnulib's directory.
135 Options for --import:
136 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
137 --source-base=DIRECTORY
138 Directory relative to --dir where source code is
139 placed (default \"lib\").
140 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
141 placed (default \"m4\").
142 --doc-base=DIRECTORY Directory relative to --dir where doc files are
143 placed (default \"doc\").
144 --tests-base=DIRECTORY
145 Directory relative to --dir where unit tests are
146 placed (default \"tests\").
147 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
148 tools are placed (default \"build-aux\").
149 --with-tests Include unit tests for the included modules.
150 --avoid=MODULE Avoid including the given MODULE. Useful if you
151 have code that provides equivalent functionality.
152 This option can be repeated.
153 --lgpl Abort if modules aren't available under the LGPL.
154 Also modify license template from GPL to LGPL.
155 --makefile-name=NAME Name of makefile in automake syntax in the
156 source-base and tests-base directories
157 (default \"Makefile.am\").
158 --libtool Use libtool rules.
159 --no-libtool Don't use libtool rules.
160 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
161 'gl_INIT'. Default is 'gl'.
162 --no-changelog don't update or create ChangeLog files
164 Options for --import and --update:
165 --dry-run For --import, only print what would have been done.
166 -s, --symbolic, --symlink Make symbolic links instead of copying files.
167 --local-symlink Make symbolic links instead of copying files, only
168 for files from the local override directory.
170 Report bugs to <bug-gnulib@gnu.org>."
174 # outputs to stdout the --version message.
177 year=`echo "$last_checkin_date" | sed -e 's,/.*$,,'`
179 $progname (GNU $package) $version
180 Copyright (C) $year Free Software Foundation, Inc.
181 This is free software; see the source for copying conditions. There is NO
182 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
183 Written by" "Bruno Haible" "and" "Simon Josefsson"
186 # func_emit_copyright_notice
187 # outputs to stdout a header for a generated file.
188 func_emit_copyright_notice ()
190 echo "# Copyright (C) 2004-2007 Free Software Foundation, Inc."
192 echo "# This file is free software, distributed under the terms of the GNU"
193 echo "# General Public License. As a special exception to the GNU General"
194 echo "# Public License, this file may be distributed as part of a program"
195 echo "# that contains a configuration script generated by Autoconf, under"
196 echo "# the same distribution terms as the rest of that program."
198 echo "# Generated by gnulib-tool."
209 # creates a temporary directory.
211 # - tmp pathname of freshly created temporary directory
214 # Use the environment variable TMPDIR, falling back to /tmp. This allows
215 # users to specify a different temporary directory, for example, if their
216 # /tmp is filled up or too small.
219 # Use the mktemp program if available. If not available, hide the error
221 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
222 test -n "$tmp" && test -d "$tmp"
225 # Use a simple mkdir command. It is guaranteed to fail if the directory
226 # already exists. $RANDOM is bash specific and expands to empty in shells
227 # other than bash, ksh and zsh. Its use does not increase security;
228 # rather, it minimizes the probability of failure in a very cluttered /tmp
230 tmp=$TMPDIR/gl$$-$RANDOM
231 (umask 077 && mkdir "$tmp")
234 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
239 # func_append var value
240 # appends the given value to the shell variable var.
241 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
242 # Use bash's += operator. It reduces complexity of appending repeatedly to
243 # a single variable from O(n^2) to O(n).
251 eval "$1=\"\$$1\$2\""
255 # func_fatal_error message
256 # outputs to stderr a fatal error message, and terminates the program.
259 echo "gnulib-tool: *** $1" 1>&2
260 echo "gnulib-tool: *** Stop." 1>&2
264 # func_readlink SYMLINK
265 # outputs the target of the given symlink.
266 if (type -p readlink) > /dev/null 2>&1; then
269 # Use the readlink program from GNU coreutils.
275 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
276 # would do the wrong thing if the link target contains " -> ".
277 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
281 # func_relativize DIR1 DIR2
282 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
284 # - DIR1 relative pathname, relative to the current directory
285 # - DIR2 relative pathname, relative to the current directory
287 # - reldir relative pathname of DIR2, relative to DIR1
293 sed_first='s,^\([^/]*\)/.*$,\1,'
294 sed_rest='s,^[^/]*/*,,'
295 sed_last='s,^.*/\([^/]*\)$,\1,'
296 sed_butlast='s,/*[^/]*$,,'
297 while test -n "$dir1"; do
298 first=`echo "$dir1" | sed -e "$sed_first"`
299 if test "$first" != "."; then
300 if test "$first" = ".."; then
301 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
302 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
304 first2=`echo "$dir2" | sed -e "$sed_first"`
305 if test "$first2" = "$first"; then
306 dir2=`echo "$dir2" | sed -e "$sed_rest"`
310 dir0="$dir0"/"$first"
313 dir1=`echo "$dir1" | sed -e "$sed_rest"`
318 # func_relconcat DIR1 DIR2
319 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
321 # - DIR1 relative pathname, relative to the current directory
322 # - DIR2 relative pathname, relative to DIR1
324 # - relconcat DIR1/DIR2, relative to the current directory
329 sed_first='s,^\([^/]*\)/.*$,\1,'
330 sed_rest='s,^[^/]*/*,,'
331 sed_last='s,^.*/\([^/]*\)$,\1,'
332 sed_butlast='s,/*[^/]*$,,'
334 first=`echo "$dir2" | sed -e "$sed_first"`
335 if test "$first" = "."; then
336 dir2=`echo "$dir2" | sed -e "$sed_rest"`
337 if test -z "$dir2"; then
342 last=`echo "$dir1" | sed -e "$sed_last"`
343 while test "$last" = "."; do
344 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
345 last=`echo "$dir1" | sed -e "$sed_last"`
347 if test -z "$dir1"; then
351 if test "$first" = ".."; then
352 if test "$last" = ".."; then
353 relconcat="$dir1/$dir2"
356 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
357 dir2=`echo "$dir2" | sed -e "$sed_rest"`
358 if test -z "$dir1"; then
362 if test -z "$dir2"; then
367 relconcat="$dir1/$dir2"
375 # Like ln -s, except that SRC is given relative to the current directory (or
376 # absolute), not given relative to the directory of DEST.
382 *) # SRC is relative.
385 ln -s "`pwd`/$1" "$2" ;;
386 *) # DEST is relative too.
387 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
388 test -n "$ln_destdir" || ln_destdir="."
389 func_relativize "$ln_destdir" "$1"
397 # func_ln_if_changed SRC DEST
398 # Like func_ln, but avoids munging timestamps if the link is correct.
399 func_ln_if_changed ()
401 if test $# -ne 2; then
402 echo "usage: func_ln_if_changed SRC DEST" >&2
404 ln_target=`func_readlink "$2"`
405 if test -L "$2" && test "$1" = "$ln_target"; then
413 # Command-line option processing.
414 # Removes the OPTIONS from the arguments. Sets the variables:
415 # - mode list or import or create-testdir or create-megatestdir
416 # - destdir from --dir
417 # - local_gnulib_dir from --local-dir
418 # - libname, supplied_libname from --lib
419 # - sourcebase from --source-base
420 # - m4base from --m4-base
421 # - docbase from --doc-base
422 # - testsbase from --tests-base
423 # - auxdir from --aux-dir
424 # - inctests true if --with-tests was given, blank otherwise
425 # - avoidlist list of modules to avoid, from --avoid
426 # - lgpl true if --lgpl was given, blank otherwise
427 # - makefile_name from --makefile-name
428 # - libtool true if --libtool was given, false if --no-libtool was
429 # given, blank otherwise
430 # - macro_prefix from --macro-prefix
431 # - autoconf_minversion minimum supported autoconf version
432 # - do_changelog false if --no-changelog was given, : otherwise
433 # - doit : if actions shall be executed, false if only to be printed
434 # - symbolic true if --symlink was given, blank otherwise
435 # - lsymbolic true if --local-symlink was given, blank otherwise
460 while test $# -gt 0; do
465 --import | --impor | --impo | --imp | --im | --i )
468 --update | --updat | --upda | --upd | --up | --u )
471 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
474 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
475 mode=create-megatestdir
477 --test | --tes | --te | --t )
480 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
484 mode=`echo "X$1" | sed -e 's/^X--//'`
489 func_fatal_error "missing argument for --dir"
494 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
499 func_fatal_error "missing argument for --local-dir"
504 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
509 func_fatal_error "missing argument for --lib"
512 supplied_libname=true
515 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
516 supplied_libname=true
521 func_fatal_error "missing argument for --source-base"
526 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
531 func_fatal_error "missing argument for --m4-base"
536 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
541 func_fatal_error "missing argument for --doc-base"
546 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
551 func_fatal_error "missing argument for --tests-base"
556 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
561 func_fatal_error "missing argument for --aux-dir"
566 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
574 func_fatal_error "missing argument for --avoid"
576 func_append avoidlist " $1"
579 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
580 func_append avoidlist " $arg"
588 func_fatal_error "missing argument for --makefile-name"
593 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
604 func_fatal_error "missing argument for --macro-prefix"
609 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
611 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
617 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
620 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
623 --help | --hel | --he | --h )
626 --version | --versio | --versi | --vers | --ver | --ve | --v )
630 # Stop option processing
634 echo "gnulib-tool: unknown option $1" 1>&2
635 echo "Try 'gnulib-tool --help' for more information." 1>&2
642 if test "$mode" = update; then
643 if test $# != 0; then
644 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
645 echo "Try 'gnulib-tool --help' for more information." 1>&2
646 echo "If you really want to modify the gnulib configuration of your project," 1>&2
647 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
650 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
651 || test -n "$sourcebase" || test -n "$m4base" \
652 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
653 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
654 || test -n "$makefile_name" || test -n "$macro_prefix"; then
655 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
656 echo "Try 'gnulib-tool --help' for more information." 1>&2
657 echo "If you really want to modify the gnulib configuration of your project," 1>&2
658 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
664 # Determine the minimum supported autoconf version from the project's
666 DEFAULT_AUTOCONF_MINVERSION="2.59"
669 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
670 if test -f "$destdir"/configure.ac; then
671 configure_ac="$destdir/configure.ac"
673 if test -f "$destdir"/configure.in; then
674 configure_ac="$destdir/configure.in"
678 if test -f configure.ac; then
679 configure_ac="configure.ac"
681 if test -f configure.in; then
682 configure_ac="configure.in"
686 if test -n "$configure_ac"; then
687 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
688 # because when some m4 files are omitted from a CVS repository,
689 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
690 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
691 # autom4te: m4 failed with exit status: 1
698 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
700 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
701 if test -n "$prereqs"; then
702 autoconf_minversion=`
703 for version in $prereqs; do echo $version; done |
704 LC_ALL=C sort -nru | sed 1q
708 if test -z "$autoconf_minversion"; then
709 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
711 case "$autoconf_minversion" in
712 1.* | 2.[0-4]* | 2.5[0-8]*)
713 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
716 # Remove trailing slashes from the directory names. This is necessary for
717 # m4base (to avoid an error in func_import) and optional for the others.
718 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
719 case "$local_gnulib_dir" in
720 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
722 case "$sourcebase" in
723 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
726 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
729 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
732 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
735 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
740 /*) self_abspathname="$0" ;;
741 */*) self_abspathname=`pwd`/"$0" ;;
742 *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
743 if test -x "$d/$0" && test ! -d "$d/$0"; then
744 self_abspathname="$d/$0"
748 if test -z "$self_abspathname"; then
749 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
753 while test -h "$self_abspathname"; do
754 # Resolve symbolic link.
755 linkval=`func_readlink "$self_abspathname"`
756 test -n "$linkval" || break
758 /* ) self_abspathname="$linkval" ;;
759 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
762 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
766 if test "$signal" != 0; then
767 echo "caught signal $signal" >&2
771 for signal in 1 2 3 13 15; do
772 trap '{ signal='$signal'; func_exit 1; }' $signal
776 # func_lookup_file file
777 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
780 # - local_gnulib_dir from --local-dir
782 # - lookedup_file name of the merged (combined) file
783 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
787 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
788 lookedup_file="$local_gnulib_dir/$lkfile"
791 if test -f "$gnulib_dir/$lkfile"; then
792 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
793 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
795 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
796 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
797 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
798 lookedup_file="$tmp/$lkbase"
801 lookedup_file="$gnulib_dir/$lkfile"
805 func_fatal_error "file $gnulib_dir/$lkfile not found"
812 # - local_gnulib_dir from --local-dir
815 # Filter out metainformation files like README, which are not modules.
816 # Filter out unit test modules; they can be retrieved through
817 # --extract-tests-module if desired.
819 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
820 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
821 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
824 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
825 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
826 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
827 -e '/^README$/d' -e '/\/README$/d' \
829 -e '/^TEMPLATE-EXTENDED$/d' \
830 -e '/^TEMPLATE-TESTS$/d' \
833 | sed -e '/-tests$/d' \
838 # verifies a module name
840 # - local_gnulib_dir from --local-dir
841 # - module module name argument
842 func_verify_module ()
844 if { test -f "$gnulib_dir/modules/$module" \
845 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
846 && test -f "$local_gnulib_dir/modules/$module"; }; } \
847 && test "CVS" != "$module" \
848 && test "ChangeLog" != "$module" \
849 && test "COPYING" != "$module" \
850 && test "README" != "$module" \
851 && test "TEMPLATE" != "$module" \
852 && test "TEMPLATE-EXTENDED" != "$module" \
853 && test "TEMPLATE-TESTS" != "$module"; then
854 # OK, $module is a correct module name.
855 # Verify that building the module description with 'patch' succeeds.
856 func_lookup_file "modules/$module"
858 echo "gnulib-tool: module $module doesn't exist" 1>&2
863 # func_verify_nontests_module
864 # verifies a module name, excluding tests modules
866 # - local_gnulib_dir from --local-dir
867 # - module module name argument
868 func_verify_nontests_module ()
872 * ) func_verify_module ;;
876 # func_verify_tests_module
877 # verifies a module name, considering only tests modules
879 # - local_gnulib_dir from --local-dir
880 # - module module name argument
881 func_verify_tests_module ()
884 *-tests ) func_verify_module ;;
889 sed_extract_prog=':[ ]*$/ {
892 s/^Description:[ ]*$//
894 s/^Depends-on:[ ]*$//
895 s/^configure\.ac-early:[ ]*$//
896 s/^configure\.ac:[ ]*$//
897 s/^Makefile\.am:[ ]*$//
901 s/^Maintainer:[ ]*$//
908 # func_get_description module
910 # - local_gnulib_dir from --local-dir
911 func_get_description ()
913 func_lookup_file "modules/$1"
914 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
917 # func_get_filelist module
919 # - local_gnulib_dir from --local-dir
922 func_lookup_file "modules/$1"
923 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
924 echo m4/gnulib-common.m4
925 case "$autoconf_minversion" in
928 echo m4/onceonly_2_57.m4
933 # func_get_dependencies module
935 # - local_gnulib_dir from --local-dir
936 func_get_dependencies ()
938 # ${module}-tests always implicitly depends on ${module}.
939 echo "$1" | sed -n -e 's/-tests//p'
940 # Then the explicit dependencies listed in the module description.
941 func_lookup_file "modules/$1"
942 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
945 # func_get_autoconf_early_snippet module
947 # - local_gnulib_dir from --local-dir
948 func_get_autoconf_early_snippet ()
950 func_lookup_file "modules/$1"
951 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
954 # func_get_autoconf_snippet module
956 # - local_gnulib_dir from --local-dir
957 func_get_autoconf_snippet ()
959 func_lookup_file "modules/$1"
960 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
963 # func_get_automake_snippet module
965 # - local_gnulib_dir from --local-dir
966 func_get_automake_snippet ()
968 func_lookup_file "modules/$1"
969 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
972 # *-tests module live in tests/, not lib/.
975 # Synthesize an EXTRA_DIST augmentation.
976 sed_combine_lines='/\\$/{
983 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
984 already_mentioned_files=` \
985 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
986 | sed -e "$sed_combine_lines" \
987 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
988 all_files=`func_get_filelist $1`
989 lib_files=`for f in $all_files; do \
993 done | sed -e 's,^lib/,,'`
994 # Remove $already_mentioned_files from $lib_files.
995 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
996 extra_files=`for f in $already_mentioned_files; do echo $f; done \
997 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
998 if test -n "$extra_files"; then
999 echo "EXTRA_DIST +=" $extra_files
1002 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1003 # This is necessary so that automake can generate the right list of
1005 # A possible approach would be to use autom4te --trace of the redefined
1006 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1007 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1008 # inside autoconf's built-in macros are not missed).
1009 # But it's simpler and more robust to do it here, based on the file list.
1010 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1011 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1012 # automake will generate a useless dependency; this is harmless.
1014 relocatable-prog-wrapper) ;;
1016 sed_extract_c_files='/\.c$/p'
1017 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1018 if test -n "$extra_files"; then
1019 echo "EXTRA_lib_SOURCES +=" $extra_files
1028 # func_get_include_directive module
1030 # - local_gnulib_dir from --local-dir
1031 func_get_include_directive ()
1033 func_lookup_file "modules/$1"
1034 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1035 sed -e 's/^\(["<]\)/#include \1/'
1038 # func_get_link_directive module
1040 # - local_gnulib_dir from --local-dir
1041 func_get_link_directive ()
1043 func_lookup_file "modules/$1"
1044 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1047 # func_get_license module
1049 # - local_gnulib_dir from --local-dir
1052 func_lookup_file "modules/$1"
1053 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1054 # The default is GPL.
1056 } | sed -e 's,^ *$,,' | sed -e 1q
1059 # func_get_maintainer module
1061 # - local_gnulib_dir from --local-dir
1062 func_get_maintainer ()
1064 func_lookup_file "modules/$1"
1065 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1068 # func_get_tests_module module
1070 # - local_gnulib_dir from --local-dir
1071 func_get_tests_module ()
1073 # The naming convention for tests modules is hardwired: ${module}-tests.
1074 if test -f "$gnulib_dir/modules/$1"-tests \
1075 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1076 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1081 # func_acceptable module
1082 # tests whether a module is acceptable.
1084 # - avoidlist list of modules to avoid
1087 for avoid in $avoidlist; do
1088 if test "$avoid" = "$1"; then
1095 # func_modules_transitive_closure
1097 # - local_gnulib_dir from --local-dir
1098 # - modules list of specified modules
1099 # - inctests true if tests should be included, blank otherwise
1100 # - avoidlist list of modules to avoid
1101 # - tmp pathname of a temporary directory
1103 # - modules list of modules, including dependencies
1104 func_modules_transitive_closure ()
1106 # In order to process every module only once (for speed), process an "input
1107 # list" of modules, producing an "output list" of modules. During each round,
1108 # more modules can be queued in the input list. Once a module on the input
1109 # list has been processed, it is added to the "handled list", so we can avoid
1110 # to process it again.
1112 inmodules="$modules"
1114 while test -n "$inmodules"; do
1115 inmodules_this_round="$inmodules"
1116 inmodules= # Accumulator, queue for next round
1117 for module in $inmodules_this_round; do
1119 if test -n "$module"; then
1120 if func_acceptable $module; then
1121 func_append outmodules " $module"
1122 deps=`func_get_dependencies $module`
1123 # Duplicate dependencies are harmless, but Jim wants a warning.
1124 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1125 if test -n "$duplicated_deps"; then
1126 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1128 func_append inmodules " $deps"
1129 if test -n "$inctests"; then
1130 testsmodule=`func_get_tests_module $module`
1131 if test -n "$testsmodule"; then
1132 func_append inmodules " $testsmodule"
1138 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1139 # Remove $handledmodules from $inmodules.
1140 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1141 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1143 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1144 rm -f "$tmp"/queued-modules
1147 # func_modules_add_dummy
1149 # - local_gnulib_dir from --local-dir
1150 # - modules list of modules, including dependencies
1152 # - modules list of modules, including 'dummy' if needed
1153 func_modules_add_dummy ()
1156 sed_remove_backslash_newline=':a
1163 for module in $modules; do
1164 func_verify_nontests_module
1165 if test -n "$module"; then
1166 # Extract the value of "lib_SOURCES += ...".
1167 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1168 # Ignore .h files since they are not compiled.
1171 *) have_lib_SOURCES=yes ;;
1176 # Add the dummy module, to make sure the library will be non-empty.
1177 if test -z "$have_lib_SOURCES"; then
1178 if func_acceptable "dummy"; then
1179 func_append modules " dummy"
1184 # func_modules_to_filelist
1186 # - local_gnulib_dir from --local-dir
1187 # - modules list of modules, including dependencies
1189 # - files list of files
1190 func_modules_to_filelist ()
1193 for module in $modules; do
1195 if test -n "$module"; then
1196 fs=`func_get_filelist $module`
1197 func_append files " $fs"
1200 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1203 # func_emit_lib_Makefile_am
1204 # emits the contents of library makefile to standard output.
1206 # - local_gnulib_dir from --local-dir
1207 # - modules list of modules, including dependencies
1208 # - libname library name
1209 # - auxdir directory relative to destdir where to place build aux files
1210 # - makefile_name from --makefile-name
1211 # - libtool true if libtool will be used, false or blank otherwise
1212 # - macro_prefix prefix of gl_LIBOBJS macros to use
1213 # - actioncmd (optional) command that will reproduce this invocation
1214 # - for_test true if creating a package for testing, false otherwise
1216 # - uses_subdirs nonempty if object files in subdirs exist
1217 func_emit_lib_Makefile_am ()
1219 # When creating an includable Makefile.am snippet, augment variables with
1220 # += instead of assigning them.
1221 if test -n "$makefile_name"; then
1226 if test "$libtool" = true; then
1229 sed_eliminate_LDFLAGS=
1233 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1236 # When creating a package for testing: Attempt to provoke failures,
1237 # especially link errors, already during "make" rather than during
1238 # "make check", because "make check" is not possible in a cross-compiling
1239 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1240 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1242 sed_transform_check_PROGRAMS=
1244 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1245 echo "## Process this file with automake to produce Makefile.in."
1246 func_emit_copyright_notice
1247 if test -n "$actioncmd"; then
1248 echo "# Reproduce by: $actioncmd"
1253 for module in $modules; do
1254 func_verify_nontests_module
1255 if test -n "$module"; then
1257 func_get_automake_snippet "$module" |
1258 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1259 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1260 sed -e "$sed_eliminate_LDFLAGS" |
1261 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1262 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1263 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' |
1264 sed -e "$sed_transform_check_PROGRAMS"
1265 if test "$module" = 'alloca'; then
1266 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1267 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1270 # Skip the contents if its entirely empty.
1271 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1272 echo "## begin gnulib module $module"
1275 echo "## end gnulib module $module"
1279 # Test whether there are some source files in subdirectories.
1280 for f in `func_get_filelist "$module"`; do
1282 lib/*/*.c) uses_subdirs=yes ;;
1288 if test -z "$makefile_name"; then
1289 # If there are source files in subdirectories, prevent collision of the
1290 # object files (example: hash.c and libxml/hash.c).
1292 if test -n "$uses_subdirs"; then
1293 subdir_options=' subdir-objects'
1295 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1298 if test -z "$makefile_name"; then
1299 echo "noinst_HEADERS ="
1300 echo "noinst_LIBRARIES ="
1301 echo "noinst_LTLIBRARIES ="
1302 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1303 # if you specify pkgdata_DATA to empty. This is a workaround.
1304 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1305 echo "pkgdata_DATA ="
1308 echo "BUILT_SOURCES ="
1311 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1312 if test -z "$makefile_name"; then
1313 echo "MOSTLYCLEANDIRS ="
1315 echo "DISTCLEANFILES ="
1316 echo "MAINTAINERCLEANFILES ="
1318 echo "AM_CPPFLAGS ="
1321 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1322 # One of the snippets already specifies an installation location for the
1323 # library. Don't confuse automake by saying it should not be installed.
1326 # By default, the generated library should not be installed.
1327 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1330 echo "${libname}_${libext}_SOURCES ="
1331 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1332 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1333 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1334 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1335 echo "EXTRA_${libname}_${libext}_SOURCES ="
1336 if test "$libtool" = true; then
1337 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1340 cat allsnippets.tmp \
1341 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1343 echo "mostlyclean-local: mostlyclean-generic"
1344 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1345 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1346 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1349 rm -f allsnippets.tmp
1352 # func_emit_tests_Makefile_am
1353 # emits the contents of tests makefile to standard output.
1355 # - local_gnulib_dir from --local-dir
1356 # - modules list of modules, including dependencies
1357 # - libname library name
1358 # - makefile_name from --makefile-name
1359 # - libtool true if libtool will be used, false or blank otherwise
1360 # - sourcebase relative directory containing lib source code
1361 # - m4base relative directory containing autoconf macros
1362 # - testsbase relative directory containing unit test code
1363 # - for_test true if creating a package for testing, false otherwise
1364 func_emit_tests_Makefile_am ()
1366 if test "$libtool" = true; then
1371 if test "$libtool" = true; then
1373 sed_eliminate_LDFLAGS=
1376 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1379 # When creating a package for testing: Attempt to provoke failures,
1380 # especially link errors, already during "make" rather than during
1381 # "make check", because "make check" is not possible in a cross-compiling
1382 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1383 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1385 sed_transform_check_PROGRAMS=
1387 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1388 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1389 echo "## Process this file with automake to produce Makefile.in."
1390 func_emit_copyright_notice
1392 # Generate dependencies here, since it eases the debugging of test failures.
1393 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1395 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1398 for module in $modules; do
1399 func_verify_tests_module
1400 if test -n "$module"; then
1402 func_get_automake_snippet "$module" |
1403 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1404 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1405 sed -e "$sed_eliminate_LDFLAGS" |
1406 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1407 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1408 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' |
1409 sed -e "$sed_transform_check_PROGRAMS"
1411 # Skip the contents if its entirely empty.
1412 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1413 echo "## begin gnulib module $module"
1416 echo "## end gnulib module $module"
1423 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1424 # variable is needed to avoid an error from automake:
1425 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1428 echo "TESTS_ENVIRONMENT ="
1429 echo "noinst_PROGRAMS ="
1430 if ! $for_test; then
1431 echo "check_PROGRAMS ="
1433 echo "noinst_HEADERS ="
1434 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1435 echo "pkgdata_DATA ="
1438 echo "BUILT_SOURCES ="
1440 echo "MOSTLYCLEANFILES = core *.stackdump"
1441 echo "MOSTLYCLEANDIRS ="
1443 echo "DISTCLEANFILES ="
1444 echo "MAINTAINERCLEANFILES ="
1446 echo "AM_CPPFLAGS = \\"
1447 echo " -I. -I\$(srcdir) \\"
1448 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1449 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1451 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1454 echo "# Clean up after Solaris cc."
1456 echo " rm -rf SunWS_cache"
1458 echo "mostlyclean-local: mostlyclean-generic"
1459 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1460 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1461 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1464 rm -f allsnippets.tmp
1467 # func_emit_initmacro_start
1468 # emits the first few statements of the gl_INIT macro to standard output.
1469 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1470 func_emit_initmacro_start ()
1472 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
1473 # platform-dependent object files in ${macro_prefix}_LIBOBJS instead of
1474 # LIBOBJS. The purpose is to allow several gnulib instantiations under
1475 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
1477 # Furthermore it avoids an automake error like this when a Makefile.am
1478 # that uses pieces of gnulib also uses $(LIBOBJ):
1479 # automatically discovered file `error.c' should not be explicitly mentioned
1480 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix}_LIBOBJ]))"
1481 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix}_REPLACE_FUNCS]))"
1482 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
1483 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
1484 # automatically discovered file `error.c' should not be explicitly mentioned
1485 # We let automake know about the files to be distributed through the
1486 # EXTRA_lib_SOURCES variable.
1487 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix}_LIBSOURCES]))"
1490 # func_emit_initmacro_end
1491 # emits the last few statements of the gl_INIT macro to standard output.
1492 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1493 func_emit_initmacro_end ()
1495 echo " m4_popdef([AC_LIBSOURCES])"
1496 echo " m4_popdef([AC_REPLACE_FUNCS])"
1497 echo " m4_popdef([AC_LIBOBJ])"
1498 echo " AC_CONFIG_COMMANDS_PRE(["
1499 echo " ${macro_prefix}_libobjs="
1500 echo " ${macro_prefix}_ltlibobjs="
1501 echo " if test -n \"\$${macro_prefix}_LIBOBJS\"; then"
1502 echo " # Remove the extension."
1503 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
1504 echo " for i in \`for i in \$${macro_prefix}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
1505 echo " ${macro_prefix}_libobjs=\"\$${macro_prefix}_libobjs \$i.\$ac_objext\""
1506 echo " ${macro_prefix}_ltlibobjs=\"\$${macro_prefix}_ltlibobjs \$i.lo\""
1509 echo " AC_SUBST([${macro_prefix}_LIBOBJS], [\$${macro_prefix}_libobjs])"
1510 echo " AC_SUBST([${macro_prefix}_LTLIBOBJS], [\$${macro_prefix}_ltlibobjs])"
1514 # func_emit_initmacro_done
1515 # emits a few statements after the gl_INIT macro to standard output.
1516 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1517 func_emit_initmacro_done ()
1520 echo "# Like AC_LIBOBJ, except that the module name goes"
1521 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1522 echo "AC_DEFUN([${macro_prefix}_LIBOBJ],"
1523 echo " [${macro_prefix}_LIBOBJS=\"\$${macro_prefix}_LIBOBJS \$1.\$ac_objext\"])"
1525 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
1526 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1527 echo "AC_DEFUN([${macro_prefix}_REPLACE_FUNCS],"
1528 echo " [AC_CHECK_FUNCS([\$1], , [${macro_prefix}_LIBOBJ(\$ac_func)])])"
1530 echo "# Like AC_LIBSOURCES, except that it does nothing."
1531 echo "# We rely on EXTRA_lib..._SOURCES instead."
1532 echo "AC_DEFUN([${macro_prefix}_LIBSOURCES],"
1536 # func_import modules
1537 # Uses also the variables
1538 # - destdir target directory
1539 # - local_gnulib_dir from --local-dir
1540 # - libname library name
1541 # - sourcebase directory relative to destdir where to place source code
1542 # - m4base directory relative to destdir where to place *.m4 macros
1543 # - docbase directory relative to destdir where to place doc files
1544 # - testsbase directory relative to destdir where to place unit test code
1545 # - auxdir directory relative to destdir where to place build aux files
1546 # - inctests true if --with-tests was given, blank otherwise
1547 # - avoidlist list of modules to avoid, from --avoid
1548 # - lgpl true if library's license shall be LGPL, blank otherwise
1549 # - makefile_name from --makefile-name
1550 # - libtool true if --libtool was given, false if --no-libtool was
1551 # given, blank otherwise
1552 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1553 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1554 # - autoconf_minversion minimum supported autoconf version
1555 # - doit : if actions shall be executed, false if only to be printed
1556 # - symbolic true if files should be symlinked, copied otherwise
1557 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1561 # Get the cached settings.
1562 cached_local_gnulib_dir=
1563 cached_specified_modules=
1571 cached_makefile_name=
1573 cached_macro_prefix=
1575 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1576 cached_libtool=false
1582 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
1585 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1588 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1591 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1594 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1597 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1600 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1603 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1606 s,^.*$,cached_lgpl=true,p
1608 /gl_MAKEFILE_NAME(/ {
1609 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
1612 s,^.*$,cached_libtool=true,p
1614 /gl_MACRO_PREFIX(/ {
1615 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
1617 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
1618 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1623 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
1624 s,^.*$,cached_files=",p
1636 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1640 # Merge the cached settings with the specified ones.
1641 # The m4base must be the same as expected from the pathname.
1642 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1643 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1645 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
1646 # is relative to $destdir, whereas the one we use is relative to . or absolute.
1647 if test -z "$local_gnulib_dir"; then
1648 if test -n "$cached_local_gnulib_dir"; then
1651 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1653 case "$cached_local_gnulib_dir" in
1655 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1657 func_relconcat "$destdir" "$cached_local_gnulib_dir"
1658 local_gnulib_dir="$relconcat" ;;
1663 # Append the cached and the specified module names. So that
1664 # "gnulib-tool --import foo" means to add the module foo.
1665 specified_modules="$cached_specified_modules $1"
1666 # Append the cached and the specified avoidlist. This is probably better
1667 # than dropping the cached one when --avoid is specified at least once.
1668 avoidlist=`echo $cached_avoidlist $avoidlist`
1669 # The sourcebase defaults to the cached one.
1670 if test -z "$sourcebase"; then
1671 sourcebase="$cached_sourcebase"
1672 if test -z "$sourcebase"; then
1673 func_fatal_error "missing --source-base option"
1676 # The docbase defaults to the cached one.
1677 if test -z "$docbase"; then
1678 docbase="$cached_docbase"
1679 if test -z "$docbase"; then
1680 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."
1683 # The testsbase defaults to the cached one.
1684 if test -z "$testsbase"; then
1685 testsbase="$cached_testsbase"
1686 if test -z "$testsbase"; then
1687 func_fatal_error "missing --tests-base option"
1690 # The libname defaults to the cached one.
1691 if test -z "$supplied_libname"; then
1692 libname="$cached_libname"
1693 if test -z "$libname"; then
1694 func_fatal_error "missing --lib option"
1697 # Require LGPL if specified either way.
1698 if test -z "$lgpl"; then
1701 # The makefile_name defaults to the cached one.
1702 if test -z "$makefile_name"; then
1703 makefile_name="$cached_makefile_name"
1705 # Use libtool if specified either way, or if guessed.
1706 if test -z "$libtool"; then
1707 if test -n "$cached_m4base"; then
1708 libtool="$cached_libtool"
1710 libtool="$guessed_libtool"
1713 # The macro_prefix defaults to the cached one.
1714 if test -z "$macro_prefix"; then
1715 macro_prefix="$cached_macro_prefix"
1716 if test -z "$macro_prefix"; then
1717 func_fatal_error "missing --macro-prefix option"
1721 # Canonicalize the list of specified modules.
1722 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
1724 # Determine final module list.
1725 modules="$specified_modules"
1726 func_modules_transitive_closure
1727 echo "Module list with included dependencies:"
1728 echo "$modules" | sed -e 's/^/ /'
1730 # Add the dummy module if needed.
1731 func_modules_add_dummy
1733 # If --lgpl, verify that the licenses of modules are compatible.
1734 if test -n "$lgpl"; then
1735 for module in $modules; do
1736 license=`func_get_license $module`
1738 LGPL | 'GPLed build tool') ;;
1739 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
1740 *) func_fatal_error "incompatible license on module $module: $license" ;;
1745 # Determine script to apply to imported library files.
1746 sed_transform_lib_file=
1747 for module in $modules; do
1748 if test $module = config-h; then
1749 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
1750 sed_transform_lib_file=$sed_transform_lib_file'
1751 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
1756 if test -n "$lgpl"; then
1758 sed_transform_lib_file=$sed_transform_lib_file'
1759 s/GNU General/GNU Lesser General/g
1760 s/version 2\([ ,]\)/version 2.1\1/g
1764 # Determine final file list.
1765 func_modules_to_filelist
1767 echo "$files" | sed -e 's/^/ /'
1770 || func_fatal_error "refusing to do nothing"
1772 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
1773 new_files="$files m4/gnulib-tool.m4"
1774 old_files="$cached_files"
1775 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
1776 func_append old_files " m4/gnulib-tool.m4"
1779 sed_rewrite_old_files="\
1780 s,^build-aux/,$auxdir/,
1781 s,^doc/,$cached_docbase/,
1782 s,^lib/,$cached_sourcebase/,
1783 s,^m4/,$cached_m4base/,
1784 s,^tests/,$cached_testsbase/,"
1785 sed_rewrite_new_files="\
1786 s,^build-aux/,$auxdir/,
1788 s,^lib/,$sourcebase/,
1790 s,^tests/,$testsbase/,"
1792 # Create directories.
1793 { echo "$sourcebase"
1795 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
1796 if test -n "$docfiles"; then
1799 if test -n "$inctests"; then
1803 for f in $files; do echo $f; done \
1804 | sed -e "$sed_rewrite_new_files" \
1805 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
1808 { # Rearrange file descriptors. Needed because "while ... done < ..."
1809 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1810 exec 5<&0 < "$tmp"/dirs
1812 if test ! -d "$destdir/$d"; then
1814 echo "Creating directory $destdir/$d"
1815 mkdir -p "$destdir/$d" || func_fatal_error "failed"
1817 echo "Create directory $destdir/$d"
1824 # func_dest_tmpfilename file
1825 # determines the name of a temporary file (file is relative to destdir).
1827 # - tmpfile absolute filename of the temporary file
1828 func_dest_tmpfilename ()
1831 # Put the new contents of $file in a file in the same directory (needed
1832 # to guarantee that an 'mv' to "$destdir/$file" works).
1833 tmpfile="$destdir/$1.tmp"
1835 # Put the new contents of $file in a file in a temporary directory
1836 # (because the directory of "$file" might not exist).
1837 tmpfile="$tmp"/`basename "$1"`.tmp
1841 # Copy files or make symbolic links. Remove obsolete files.
1845 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1846 # representing the files according to the last gnulib-tool invocation.
1847 for f in $old_files; do echo $f; done \
1848 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
1851 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1852 # representing the files after this gnulib-tool invocation.
1853 for f in $new_files; do echo $f; done \
1854 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
1857 # First the files that are in old-files, but not in new-files:
1858 sed_take_first_column='s,'"$delimiter"'.*,,'
1859 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
1860 # Remove the file. Do nothing if the user already removed it.
1861 if test -f "$destdir/$g"; then
1863 echo "Removing file $g (backup in ${g}~)"
1864 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1866 echo "Remove file $g (backup in ${g}~)"
1868 func_append removed_files "$g$nl"
1871 # func_add_or_update handles a file that ought to be present afterwards.
1873 # - f the original file name
1874 # - g the rewritten file name
1875 # - already_present nonempty if the file already exists, empty otherwise
1876 func_add_or_update ()
1878 func_dest_tmpfilename "$g"
1879 func_lookup_file "$f"
1880 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
1881 if test -n "$sed_transform_lib_file"; then
1884 sed -e "$sed_transform_lib_file" \
1885 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
1889 if test -f "$destdir/$g"; then
1890 # The file already exists.
1891 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1892 : # The file has not changed.
1896 if test -n "$already_present"; then
1897 echo "Updating file $g (backup in ${g}~)"
1899 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
1901 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1902 if { test -n "$symbolic" \
1903 || { test -n "$lsymbolic" \
1904 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1905 && test -z "$lookedup_tmp" \
1906 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1907 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1909 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1912 if test -n "$already_present"; then
1913 echo "Update file $g (backup in ${g}~)"
1915 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
1921 # Don't protest if the file should be there but isn't: it happens
1922 # frequently that developers don't put autogenerated files into CVS.
1924 echo "Copying file $g"
1925 if { test -n "$symbolic" \
1926 || { test -n "$lsymbolic" \
1927 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1928 && test -z "$lookedup_tmp" \
1929 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1930 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1932 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1937 func_append added_files "$g$nl"
1941 # Then the files that are in new-files, but not in old-files:
1942 sed_take_last_column='s,^.*'"$delimiter"',,'
1944 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
1945 | sed -e "$sed_take_last_column" \
1946 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
1947 { # Rearrange file descriptors. Needed because "while ... done < ..."
1948 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1949 exec 5<&0 < "$tmp"/added-files
1955 # Then the files that are in new-files and in old-files:
1956 already_present=true
1957 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
1958 | sed -e "$sed_take_last_column" \
1959 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
1960 { # Rearrange file descriptors. Needed because "while ... done < ..."
1961 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1962 exec 5<&0 < "$tmp"/kept-files
1969 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
1970 actioncmd="gnulib-tool --import"
1971 func_append actioncmd " --dir=$destdir"
1972 if test -n "$local_gnulib_dir"; then
1973 func_append actioncmd " --local-dir=$local_gnulib_dir"
1975 func_append actioncmd " --lib=$libname"
1976 func_append actioncmd " --source-base=$sourcebase"
1977 func_append actioncmd " --m4-base=$m4base"
1978 func_append actioncmd " --doc-base=$docbase"
1979 func_append actioncmd " --aux-dir=$auxdir"
1980 for module in $avoidlist; do
1981 func_append actioncmd " --avoid=$module"
1983 if test -n "$lgpl"; then
1984 func_append actioncmd " --lgpl"
1986 if test -n "$makefile_name"; then
1987 func_append actioncmd " --makefile-name=$makefile_name"
1989 if test "$libtool" = true; then
1990 func_append actioncmd " --libtool"
1992 func_append actioncmd " --no-libtool"
1994 func_append actioncmd " --macro-prefix=$macro_prefix"
1995 func_append actioncmd " `echo $specified_modules`"
1997 # Default the makefile name to Makefile.am.
1998 if test -n "$makefile_name"; then
1999 makefile_am=$makefile_name
2001 makefile_am=Makefile.am
2004 # Create normal Makefile.ams.
2007 # Create library makefile.
2008 func_dest_tmpfilename $sourcebase/$makefile_am
2009 func_emit_lib_Makefile_am > "$tmpfile"
2010 if test -f "$destdir"/$sourcebase/$makefile_am; then
2011 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
2015 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2016 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
2017 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2019 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2025 echo "Creating $sourcebase/$makefile_am"
2026 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2028 echo "Create $sourcebase/$makefile_am"
2031 func_append added_files "$sourcebase/$makefile_am$nl"
2034 # Create m4/gnulib-cache.m4.
2035 func_dest_tmpfilename $m4base/gnulib-cache.m4
2037 func_emit_copyright_notice
2039 echo "# This file represents the specification of how gnulib-tool is used."
2040 echo "# It acts as a cache: It is written and read by gnulib-tool."
2041 echo "# In projects using CVS, this file is meant to be stored in CVS,"
2042 echo "# like the configure.ac and various Makefile.am files."
2045 echo "# Specification in the form of a command-line invocation:"
2048 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
2049 # Store the local_gnulib_dir relative to destdir.
2050 case "$local_gnulib_dir" in
2052 relative_local_gnulib_dir="$local_gnulib_dir" ;;
2055 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
2057 # destdir, local_gnulib_dir are both relative.
2058 func_relativize "$destdir" "$local_gnulib_dir"
2059 relative_local_gnulib_dir="$reldir" ;;
2062 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
2063 echo "gl_MODULES(["`echo $specified_modules`"])"
2064 echo "gl_AVOID([$avoidlist])"
2065 echo "gl_SOURCE_BASE([$sourcebase])"
2066 echo "gl_M4_BASE([$m4base])"
2067 echo "gl_DOC_BASE([$docbase])"
2068 echo "gl_TESTS_BASE([$testsbase])"
2069 echo "gl_LIB([$libname])"
2070 test -z "$lgpl" || echo "gl_LGPL"
2071 echo "gl_MAKEFILE_NAME([$makefile_name])"
2072 if test "$libtool" = true; then
2075 echo "gl_MACRO_PREFIX([$macro_prefix])"
2077 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2078 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2082 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2083 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2084 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2086 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2090 echo "# gnulib-cache.m4 ends here"
2097 echo "Creating $m4base/gnulib-cache.m4"
2098 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2100 echo "Create $m4base/gnulib-cache.m4"
2106 # Create m4/gnulib-comp.m4.
2107 func_dest_tmpfilename $m4base/gnulib-comp.m4
2109 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2110 func_emit_copyright_notice
2112 echo "# This file represents the compiled summary of the specification in"
2113 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2114 echo "# to be invoked from configure.ac."
2115 echo "# In projects using CVS, this file can be treated like other built files."
2118 echo "# This macro should be invoked from $configure_ac, in the section"
2119 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2120 echo "# any checks for libraries, header files, types and library functions."
2121 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2123 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2124 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2125 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2126 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2127 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2128 if test -n "$uses_subdirs"; then
2129 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2131 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2132 echo " AC_REQUIRE([AC_GNU_SOURCE])"
2134 for module in $modules; do
2136 if test -n "$module"; then
2137 func_get_autoconf_early_snippet "$module"
2140 | sed -e '/^$/d;' -e 's/^/ /'
2143 echo "# This macro should be invoked from $configure_ac, in the section"
2144 echo "# \"Check for header files, types and library functions\"."
2145 echo "AC_DEFUN([${macro_prefix}_INIT],"
2147 func_emit_initmacro_start
2148 if test "$libtool" = true; then
2149 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2150 echo " gl_cond_libtool=true"
2152 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2153 echo " gl_cond_libtool=false"
2155 echo " gl_ltlibdeps="
2157 echo " gl_source_base='$sourcebase'"
2158 if test "$auxdir" != "build-aux"; then
2159 sed_replace_build_aux='
2161 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2162 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2165 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2167 sed_replace_build_aux=
2169 for module in $modules; do
2171 if test -n "$module"; then
2172 func_get_autoconf_snippet "$module" \
2173 | sed -e '/^$/d;' -e 's/^/ /' \
2174 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
2175 -e "$sed_replace_build_aux"
2176 if test "$module" = 'alloca' && test "$libtool" = true; then
2177 echo 'changequote(,)dnl'
2178 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
2179 echo 'changequote([, ])dnl'
2180 echo 'AC_SUBST([LTALLOCA])'
2184 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2185 # created using libtool, because libtool already handles the dependencies.
2186 if test "$libtool" != true; then
2187 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z' 'A-Z'`
2188 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2189 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2190 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2191 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2193 func_emit_initmacro_end
2195 func_emit_initmacro_done
2197 echo "# This macro records the list of files which have been installed by"
2198 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
2199 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
2200 echo "$files" | sed -e 's,^, ,'
2203 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2204 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
2208 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2209 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
2210 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2212 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2216 echo "# gnulib-comp.m4 ends here"
2223 echo "Creating $m4base/gnulib-comp.m4"
2224 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2226 echo "Create $m4base/gnulib-comp.m4"
2232 if test -n "$inctests"; then
2233 # Create tests makefile.
2234 func_dest_tmpfilename $testsbase/$makefile_am
2235 func_emit_tests_Makefile_am > "$tmpfile"
2236 if test -f "$destdir"/$testsbase/$makefile_am; then
2237 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
2241 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2242 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
2243 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2245 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2251 echo "Creating $testsbase/$makefile_am"
2252 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2254 echo "Create $testsbase/$makefile_am"
2257 func_append added_files "$testsbase/$makefile_am$nl"
2261 # Update the .cvsignore and .gitignore files.
2262 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
2263 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
2264 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
2265 { # Rearrange file descriptors. Needed because "while ... done < ..."
2266 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2267 exec 5<&0 < "$tmp"/fileset-changes
2268 func_update_ignorelist ()
2271 if test -f "$destdir/$dir$ignore"; then
2272 if test -n "$dir_added" || test -n "$dir_removed"; then
2273 LC_ALL=C sort "$destdir/$dir$ignore" > "$tmp"/ignore
2274 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
2275 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-added
2276 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
2277 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-removed
2278 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
2280 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2281 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
2282 sed -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed > "$tmp"/sed-ignore-removed
2283 cat "$destdir/$dir$ignore"~ "$tmp"/ignore-added \
2284 | sed -f "$tmp"/sed-ignore-removed \
2285 > "$destdir/$dir$ignore"
2287 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2292 if test -n "$dir_added"; then
2294 echo "Creating $destdir/$dir$ignore"
2295 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u > "$destdir/$dir$ignore"
2297 echo "Create $destdir/$dir$ignore"
2307 if test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
2308 func_update_ignorelist .cvsignore
2310 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
2311 func_update_ignorelist .gitignore
2318 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
2319 next_dir=`echo "$line" | sed -e 's,|.*,,'`
2320 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
2321 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
2322 if test "$next_dir" != "$last_dir"; then
2323 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2324 last_dir="$next_dir"
2329 A) func_append last_dir_added "$file$nl";;
2330 R) func_append last_dir_removed "$file$nl";;
2333 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2339 echo "You may need to add #include directives for the following .h files."
2340 # Intersect $specified_modules and $modules
2341 # (since $specified_modules is not necessarily of subset of $modules - some
2342 # may have been skipped through --avoid, and since the elements of $modules
2343 # but not in $specified_modules can go away without explicit notice - through
2344 # changes in the module dependencies).
2345 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
2346 echo "$modules" > "$tmp"/modules2 # also a sorted list, one module per line
2347 # First the #include <...> directives without #ifs, sorted for convenience,
2348 # then the #include "..." directives without #ifs, sorted for convenience,
2349 # then the #include directives that are surrounded by #ifs. Not sorted.
2350 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
2351 include_directive=`func_get_include_directive "$module"`
2352 case "$nl$include_directive" in
2354 echo "$include_directive" 1>&5
2357 echo "$include_directive" | grep -v 'include "' 1>&6
2358 echo "$include_directive" | grep 'include "' 1>&7
2361 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
2363 LC_ALL=C sort -u "$tmp"/include-angles
2364 LC_ALL=C sort -u "$tmp"/include-quotes
2365 cat "$tmp"/include-if
2366 ) | sed -e '/^$/d' -e 's/^/ /'
2367 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
2369 for module in $modules; do
2370 func_get_link_directive "$module"
2372 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
2373 if test `wc -l < "$tmp"/link` != 0; then
2375 echo "You may need to use the following Makefile variables when linking."
2376 echo "Use them in <program>_LDADD when linking a program, or"
2377 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
2383 echo "Don't forget to"
2384 if test "$makefile_am" = Makefile.am; then
2385 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2387 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
2389 if test -n "$inctests"; then
2390 if test "$makefile_am" = Makefile.am; then
2391 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2393 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
2396 if test "$makefile_am" = Makefile.am; then
2397 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
2398 sourcebase_base=`basename "$sourcebase"`
2399 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
2401 if test -n "$inctests"; then
2402 if test "$makefile_am" = Makefile.am; then
2403 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
2404 testsbase_base=`basename "$testsbase"`
2405 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
2408 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
2409 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
2410 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
2413 # func_create_testdir testdir modules
2415 # - local_gnulib_dir from --local-dir
2416 # - auxdir directory relative to destdir where to place build aux files
2417 func_create_testdir ()
2421 if test -z "$modules"; then
2422 # All modules together.
2423 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2424 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2425 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
2426 modules=`func_all_modules`
2427 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
2429 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
2431 # Check that the license of every module is consistent with the license of
2433 saved_modules="$modules"
2434 saved_inctests="$inctests"
2435 # When computing transitive closures, don't consider $module to depend on
2436 # $module-tests. Need this becauses tests are implicitly GPL and may depend
2437 # on GPL modules - therefore we don't want a warning in this case.
2439 for requested_module in $saved_modules; do
2440 requested_license=`func_get_license "$requested_module"`
2441 if test "$requested_license" != GPL; then
2442 # Here we use func_modules_transitive_closure, not just
2443 # func_get_dependencies, so that we also detect weird situations like
2444 # an LGPL module which depends on a GPLed build tool module which depends
2446 modules="$requested_module"
2447 func_modules_transitive_closure
2448 for module in $modules; do
2449 license=`func_get_license "$module"`
2451 LGPL | 'GPLed build tool') ;;
2452 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2453 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
2458 modules="$saved_modules"
2459 inctests="$saved_inctests"
2461 # Subdirectory names.
2468 # Determine final module list.
2469 func_modules_transitive_closure
2470 echo "Module list with included dependencies:"
2471 echo "$modules" | sed -e 's/^/ /'
2473 # Add the dummy module if needed.
2474 func_modules_add_dummy
2476 # Determine final file list.
2477 func_modules_to_filelist
2479 echo "$files" | sed -e 's/^/ /'
2481 sed_rewrite_files="\
2482 s,^build-aux/,$auxdir/,
2484 s,^lib/,$sourcebase/,
2486 s,^tests/,$testsbase/,"
2488 # Create directories.
2489 for f in $files; do echo $f; done \
2490 | sed -e "$sed_rewrite_files" \
2491 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2492 | LC_ALL=C sort -u \
2494 { # Rearrange file descriptors. Needed because "while ... done < ..."
2495 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2496 exec 5<&0 < "$tmp"/dirs
2498 mkdir -p "$testdir/$d"
2503 # Copy files or make symbolic links.
2505 for f in $files; do echo $f; done \
2506 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
2509 { # Rearrange file descriptors. Needed because "while ... done < ..."
2510 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2511 exec 5<&0 < "$tmp"/files
2513 func_lookup_file "$f"
2514 if test -n "$lookedup_tmp"; then
2515 cp -p "$lookedup_file" "$testdir/$g"
2517 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
2518 if { test -n "$symbolic" \
2519 || { test -n "$lsymbolic" \
2520 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
2521 func_ln "$lookedup_file" "$testdir/$g"
2523 cp -p "$lookedup_file" "$testdir/$g"
2530 # Create Makefile.ams that are for testing.
2533 # Create $sourcebase/Makefile.am.
2534 mkdir -p "$testdir/$sourcebase"
2535 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
2537 # Create $m4base/Makefile.am.
2538 mkdir -p "$testdir/$m4base"
2539 (echo "## Process this file with automake to produce Makefile.in."
2545 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
2548 ) > "$testdir/$m4base/Makefile.am"
2550 subdirs="$sourcebase $m4base"
2551 subdirs_with_configure_ac=""
2553 if false && test -f "$testdir"/$m4base/gettext.m4; then
2554 # Avoid stupid error message from automake:
2555 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
2556 mkdir -p "$testdir/po"
2557 (echo "## Process this file with automake to produce Makefile.in."
2558 ) > "$testdir/po/Makefile.am"
2559 func_append subdirs " po"
2562 if test -n "$inctests"; then
2563 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
2564 # Create $testsbase/Makefile.am.
2565 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
2566 # Create $testsbase/configure.ac.
2567 (echo "# Process this file with autoconf to produce a configure script."
2568 echo "AC_INIT([dummy], [0])"
2569 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
2570 echo "AM_INIT_AUTOMAKE"
2572 echo "AM_CONFIG_HEADER([config.h])"
2575 echo "AC_PROG_INSTALL"
2576 echo "AC_PROG_MAKE_SET"
2577 echo "AC_PROG_RANLIB"
2579 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2580 echo "AC_GNU_SOURCE"
2583 for module in $modules; do
2585 if test -n "$module"; then
2586 func_get_autoconf_early_snippet "$module"
2589 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
2590 if test "$libtool" = true; then
2591 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2592 echo "gl_cond_libtool=true"
2594 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2595 echo "gl_cond_libtool=false"
2597 echo "gl_ltlibdeps="
2599 # Wrap the set of autoconf snippets into an autoconf macro that is then
2600 # invoked. This is needed because autoconf does not support AC_REQUIRE
2602 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2603 # but we want the AC_REQUIRE to have its normal meaning (provide one
2604 # expansion of the required macro before the current point, and only one
2606 echo "AC_DEFUN([gl_INIT], ["
2607 func_emit_initmacro_start
2608 sed_replace_build_aux='
2610 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2611 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
2614 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2615 # We don't have explicit ordering constraints between the various
2616 # autoconf snippets. It's cleanest to put those of the library before
2617 # those of the tests.
2618 echo "gl_source_base='../$sourcebase'"
2619 for module in $modules; do
2620 func_verify_nontests_module
2621 if test -n "$module"; then
2622 func_get_autoconf_snippet "$module" \
2623 | sed -e "$sed_replace_build_aux"
2626 echo "gl_source_base='.'"
2627 for module in $modules; do
2628 func_verify_tests_module
2629 if test -n "$module"; then
2630 func_get_autoconf_snippet "$module" \
2631 | sed -e "$sed_replace_build_aux"
2634 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2635 # created using libtool, because libtool already handles the dependencies.
2636 if test "$libtool" != true; then
2637 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z' 'A-Z'`
2638 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2639 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2640 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2641 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2643 func_emit_initmacro_end
2645 func_emit_initmacro_done
2649 # Usually $testsbase/config.h will be a superset of config.h. Verify this
2650 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
2651 echo "AH_TOP([#include \"../config.h\"])"
2653 echo "AC_OUTPUT([Makefile])"
2654 ) > "$testdir/$testsbase/configure.ac"
2655 func_append subdirs " $testsbase"
2656 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
2659 # Create Makefile.am.
2660 (echo "## Process this file with automake to produce Makefile.in."
2662 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2664 echo "SUBDIRS = $subdirs"
2666 echo "ACLOCAL_AMFLAGS = -I $m4base"
2667 ) > "$testdir/Makefile.am"
2669 # Create configure.ac.
2670 (echo "# Process this file with autoconf to produce a configure script."
2671 echo "AC_INIT([dummy], [0])"
2672 if test "$auxdir" != "."; then
2673 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2675 echo "AM_INIT_AUTOMAKE"
2677 echo "AM_CONFIG_HEADER([config.h])"
2680 echo "AC_PROG_INSTALL"
2681 echo "AC_PROG_MAKE_SET"
2683 echo "# For autobuild."
2684 echo "AC_CANONICAL_BUILD"
2685 echo "AC_CANONICAL_HOST"
2687 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2688 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2689 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2690 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2692 echo "AC_PROG_RANLIB"
2694 if test -n "$uses_subdirs"; then
2695 echo "AM_PROG_CC_C_O"
2698 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2699 echo "AC_GNU_SOURCE"
2702 for module in $modules; do
2703 func_verify_nontests_module
2704 if test -n "$module"; then
2705 func_get_autoconf_early_snippet "$module"
2708 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
2709 if test "$libtool" = true; then
2710 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2711 echo "gl_cond_libtool=true"
2713 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2714 echo "gl_cond_libtool=false"
2716 echo "gl_ltlibdeps="
2718 echo "gl_source_base='$sourcebase'"
2719 # Wrap the set of autoconf snippets into an autoconf macro that is then
2720 # invoked. This is needed because autoconf does not support AC_REQUIRE
2722 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2723 # but we want the AC_REQUIRE to have its normal meaning (provide one
2724 # expansion of the required macro before the current point, and only one
2726 echo "AC_DEFUN([gl_INIT], ["
2727 func_emit_initmacro_start
2728 if test "$auxdir" != "build-aux"; then
2729 sed_replace_build_aux='
2731 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2732 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2735 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2737 sed_replace_build_aux=
2739 for module in $modules; do
2740 func_verify_nontests_module
2741 if test -n "$module"; then
2742 func_get_autoconf_snippet "$module" \
2743 | sed -e "$sed_replace_build_aux"
2746 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2747 # created using libtool, because libtool already handles the dependencies.
2748 if test "$libtool" != true; then
2749 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z' 'A-Z'`
2750 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2751 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2752 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2753 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2755 func_emit_initmacro_end
2757 func_emit_initmacro_done
2761 if test -n "$subdirs_with_configure_ac"; then
2762 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
2764 makefiles="Makefile"
2765 for d in $subdirs; do
2766 # For subdirs that have a configure.ac by their own, it's the subdir's
2767 # configure.ac which creates the subdir's Makefile.am, not this one.
2768 case " $subdirs_with_configure_ac " in
2770 *) func_append makefiles " $d/Makefile" ;;
2773 echo "AC_OUTPUT([$makefiles])"
2774 ) > "$testdir/configure.ac"
2776 # Create autogenerated files.
2778 # Do not use "${AUTORECONF} --force --install", because it may invoke
2779 # autopoint, which brings in older versions of some of our .m4 files.
2780 if test -f $m4base/gettext.m4; then
2781 echo "executing ${AUTOPOINT} --force"
2782 ${AUTOPOINT} --force || func_exit 1
2783 for f in $m4base/*.m4~; do
2784 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2787 echo "executing ${ACLOCAL} -I $m4base"
2788 ${ACLOCAL} -I $m4base || func_exit 1
2789 if ! test -d build-aux; then
2790 echo "executing mkdir build-aux"
2791 mkdir build-aux || func_exit 1
2793 echo "executing ${AUTOCONF}"
2794 ${AUTOCONF} || func_exit 1
2795 echo "executing ${AUTOHEADER}"
2796 ${AUTOHEADER} || func_exit 1
2797 echo "executing ${AUTOMAKE} --add-missing --copy"
2798 ${AUTOMAKE} --add-missing --copy || func_exit 1
2800 if test -n "$inctests"; then
2801 # Create autogenerated files.
2802 (cd "$testdir/$testsbase" || func_exit 1
2803 # Do not use "${AUTORECONF} --force --install", because it may invoke
2804 # autopoint, which brings in older versions of some of our .m4 files.
2805 if test -f ../$m4base/gettext.m4; then
2806 echo "executing ${AUTOPOINT} --force"
2807 ${AUTOPOINT} --force || func_exit 1
2808 for f in ../$m4base/*.m4~; do
2809 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2812 echo "executing ${ACLOCAL} -I ../$m4base"
2813 ${ACLOCAL} -I ../$m4base || func_exit 1
2814 if ! test -d ../build-aux; then
2815 echo "executing mkdir ../build-aux"
2818 echo "executing ${AUTOCONF}"
2819 ${AUTOCONF} || func_exit 1
2820 echo "executing ${AUTOHEADER}"
2821 ${AUTOHEADER} || func_exit 1
2822 echo "executing ${AUTOMAKE} --add-missing --copy"
2823 ${AUTOMAKE} --add-missing --copy || func_exit 1
2826 # Need to run configure and make once, to create built files that are to be
2827 # distributed (such as getdate.c).
2828 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
2829 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
2830 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
2831 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
2832 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
2833 # such $(FOO_H) because they don't refer to distributed files.
2834 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
2835 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
2836 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
2837 | sed -e "$sed_remove_make_variables"`
2838 distributed_built_sources=`for file in $built_sources; do
2839 case "$cleaned_files" in
2844 if test -n "$distributed_built_sources"; then
2846 ./configure || func_exit 1
2848 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
2849 make built_sources || func_exit 1
2851 make distclean || func_exit 1
2856 # func_create_megatestdir megatestdir allmodules
2858 # - local_gnulib_dir from --local-dir
2859 # - auxdir directory relative to destdir where to place build aux files
2860 func_create_megatestdir ()
2864 if test -z "$allmodules"; then
2865 allmodules=`func_all_modules`
2869 # First, all modules one by one.
2870 for onemodule in $allmodules; do
2871 func_create_testdir "$megatestdir/$onemodule" $onemodule
2872 func_append megasubdirs "$onemodule "
2874 # Then, all modules all together.
2875 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2876 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2877 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
2878 func_create_testdir "$megatestdir/ALL" "$allmodules"
2879 func_append megasubdirs "ALL"
2882 cvsdate=`sh "$gnulib_dir/build-aux/mdate-sh" "$gnulib_dir/CVS/Entries" \
2883 | sed -e 's,January,01,' -e 's,Jan,01,' \
2884 -e 's,February,02,' -e 's,Feb,02,' \
2885 -e 's,March,03,' -e 's,Mar,03,' \
2886 -e 's,April,04,' -e 's,Apr,04,' \
2888 -e 's,June,06,' -e 's,Jun,06,' \
2889 -e 's,July,07,' -e 's,Jul,07,' \
2890 -e 's,August,08,' -e 's,Aug,08,' \
2891 -e 's,September,09,' -e 's,Sep,09,' \
2892 -e 's,October,10,' -e 's,Oct,10,' \
2893 -e 's,November,11,' -e 's,Nov,11,' \
2894 -e 's,December,12,' -e 's,Dec,12,' \
2895 | sed -e 's,^,00,' | sed -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
2896 | sed -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
2898 echo "CVSDATE=$cvsdate"
2899 echo "test -d logs || mkdir logs"
2900 echo "for module in $megasubdirs; do"
2901 echo " echo \"Working on module \$module...\""
2902 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
2903 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
2906 echo " : autobuild project... \$module"
2907 echo " : autobuild revision... cvs-\$CVSDATE-000000"
2908 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
2909 echo " : autobuild hostname... \`hostname\`"
2910 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
2912 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
2914 ) > "$megatestdir/do-autobuild"
2915 chmod a+x "$megatestdir/do-autobuild"
2917 # Create Makefile.am.
2918 (echo "## Process this file with automake to produce Makefile.in."
2920 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2922 echo "SUBDIRS = $megasubdirs"
2924 echo "EXTRA_DIST = do-autobuild"
2925 ) > "$megatestdir/Makefile.am"
2927 # Create configure.ac.
2928 (echo "# Process this file with autoconf to produce a configure script."
2929 echo "AC_INIT([dummy], [0])"
2930 if test "$auxdir" != "."; then
2931 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2933 echo "AM_INIT_AUTOMAKE"
2935 echo "AC_PROG_MAKE_SET"
2937 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
2938 echo "AC_OUTPUT([Makefile])"
2939 ) > "$megatestdir/configure.ac"
2941 # Create autogenerated files.
2943 # Do not use "${AUTORECONF} --install", because autoreconf operates
2944 # recursively, but the subdirectories are already finished, therefore
2945 # calling autoreconf here would only waste lots of CPU time.
2946 echo "executing ${ACLOCAL}"
2947 ${ACLOCAL} || func_exit 1
2948 echo "executing mkdir build-aux"
2950 echo "executing ${AUTOCONF}"
2951 ${AUTOCONF} || func_exit 1
2952 echo "executing ${AUTOMAKE} --add-missing --copy"
2953 ${AUTOMAKE} --add-missing --copy || func_exit 1
2959 func_fatal_error "no mode specified" ;;
2968 if test -z "$destdir"; then
2971 test -d "$destdir" \
2972 || func_fatal_error "destination directory does not exist: $destdir"
2974 # Prefer configure.ac to configure.in.
2975 if test -f "$destdir"/configure.ac; then
2976 configure_ac="$destdir/configure.ac"
2978 if test -f "$destdir"/configure.in; then
2979 configure_ac="$destdir/configure.in"
2981 func_fatal_error "cannot find $destdir/configure.ac"
2985 # Analyze configure.ac.
2987 guessed_libtool=false
2992 /AC_CONFIG_AUX_DIR/ {
2993 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
2995 /A[CM]_PROG_LIBTOOL/ {
2996 s,^.*$,guessed_libtool=true,p
2998 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
3000 if test -z "$auxdir"; then
3001 auxdir="$guessed_auxdir"
3004 # Determine where to apply func_import.
3005 if test -n "$m4base"; then
3006 # Apply func_import to a particular gnulib directory.
3007 # Any number of additional modules can be given.
3008 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
3009 # First use of gnulib in the given m4base.
3010 test -n "$supplied_libname" || supplied_libname=true
3011 test -n "$sourcebase" || sourcebase="lib"
3012 test -n "$docbase" || docbase="doc"
3013 test -n "$testsbase" || testsbase="tests"
3014 test -n "$macro_prefix" || macro_prefix="gl"
3018 # Apply func_import to all gnulib directories.
3019 # To get this list of directories, look at Makefile.am. (Not at
3020 # configure, because it may be omitted from CVS. Also, don't run
3021 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
3024 if test -f "$destdir"/Makefile.am; then
3025 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
3027 for arg in $aclocal_amflags; do
3028 if test -n "$m4dir_is_next"; then
3029 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
3033 if test -f "$destdir/$arg"/gnulib-cache.m4; then
3034 func_append m4dirs " $arg"
3035 m4dirs_count=`expr $m4dirs_count + 1`
3041 if test "X$arg" = "X-I"; then
3049 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
3050 if test -f "$destdir"/aclocal.m4; then
3051 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
3052 sedexpr2='s,^[^/]*$,.,'
3053 sedexpr3='s,/[^/]*$,,'
3054 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
3055 m4dirs_count=`echo "$m4dirs" | wc -l`
3058 if test $m4dirs_count = 0; then
3059 # First use of gnulib in a package.
3060 # Any number of additional modules can be given.
3061 test -n "$supplied_libname" || supplied_libname=true
3062 test -n "$sourcebase" || sourcebase="lib"
3064 test -n "$docbase" || docbase="doc"
3065 test -n "$testsbase" || testsbase="tests"
3066 test -n "$macro_prefix" || macro_prefix="gl"
3069 if test $m4dirs_count = 1; then
3070 # There's only one use of gnulib here. Assume the user means it.
3071 # Any number of additional modules can be given.
3072 for m4base in $m4dirs; do
3076 # Ambiguous - guess what the user meant.
3077 if test $# = 0; then
3078 # No further arguments. Guess the user wants to update all of them.
3079 for m4base in $m4dirs; do
3080 # Perform func_import in a subshell, so that variable values
3082 # local_gnulib_dir, avoidlist, sourcebase, m4base, docbase,
3083 # testsbase, libname, lgpl, makefile_name, libtool, macro_prefix
3084 # don't propagate from one directory to another.
3085 (func_import) || func_exit 1
3089 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
3097 if test -z "$destdir"; then
3098 func_fatal_error "please specify --dir option"
3101 test -d "$destdir" \
3102 || func_fatal_error "could not create destination directory"
3103 test -n "$auxdir" || auxdir="build-aux"
3104 func_create_testdir "$destdir" "$*"
3107 create-megatestdir )
3108 if test -z "$destdir"; then
3109 func_fatal_error "please specify --dir option"
3111 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3112 test -n "$auxdir" || auxdir="build-aux"
3113 func_create_megatestdir "$destdir" "$*"
3117 test -n "$destdir" || destdir=testdir$$
3118 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3119 test -n "$auxdir" || auxdir="build-aux"
3120 func_create_testdir "$destdir" "$*"
3124 ../configure || func_exit 1
3126 make check || func_exit 1
3127 make distclean || func_exit 1
3128 remaining=`find . -type f -print`
3129 if test -n "$remaining"; then
3130 echo "Remaining files:" $remaining 1>&2
3131 echo "gnulib-tool: *** Stop." 1>&2
3140 test -n "$destdir" || destdir=testdir$$
3141 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3142 test -n "$auxdir" || auxdir="build-aux"
3143 func_create_megatestdir "$destdir" "$*"
3151 remaining=`find . -type f -print`
3152 if test -n "$remaining"; then
3153 echo "Remaining files:" $remaining 1>&2
3154 echo "gnulib-tool: *** Stop." 1>&2
3162 extract-description )
3166 if test -n "$module"; then
3167 func_get_description "$module"
3176 if test -n "$module"; then
3177 func_get_filelist "$module"
3182 extract-dependencies )
3186 if test -n "$module"; then
3187 func_get_dependencies "$module"
3192 extract-autoconf-snippet )
3196 if test -n "$module"; then
3197 func_get_autoconf_snippet "$module"
3202 extract-automake-snippet )
3206 if test -n "$module"; then
3207 func_get_automake_snippet "$module"
3212 extract-include-directive )
3216 if test -n "$module"; then
3217 func_get_include_directive "$module"
3222 extract-link-directive )
3226 if test -n "$module"; then
3227 func_get_link_directive "$module"
3236 if test -n "$module"; then
3237 func_get_license "$module"
3242 extract-maintainer )
3246 if test -n "$module"; then
3247 func_get_maintainer "$module"
3252 extract-tests-module )
3256 if test -n "$module"; then
3257 func_get_tests_module "$module"
3263 func_fatal_error "unknown operation mode --$mode" ;;
3267 # Undo the effect of the previous 'trap' command. Some shellology:
3268 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
3269 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
3270 # exit); for the others we need to call 'exit' explicitly. The value of $? is
3271 # 128 + signal number and is set before the trap-registered command is run.
3273 trap 'func_exit $?' 1 2 3 13 15
3278 # indent-tabs-mode: nil
3279 # whitespace-check-buffer-indent: nil