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-03-06 03:38:30 $'
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-TESTS$/d' \
832 | sed -e '/-tests$/d' \
837 # verifies a module name
839 # - local_gnulib_dir from --local-dir
840 # - module module name argument
841 func_verify_module ()
843 if { test -f "$gnulib_dir/modules/$module" \
844 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
845 && test -f "$local_gnulib_dir/modules/$module"; }; } \
846 && test "CVS" != "$module" \
847 && test "ChangeLog" != "$module" \
848 && test "COPYING" != "$module" \
849 && test "README" != "$module" \
850 && test "TEMPLATE" != "$module" \
851 && test "TEMPLATE-TESTS" != "$module"; then
852 # OK, $module is a correct module name.
853 # Verify that building the module description with 'patch' succeeds.
854 func_lookup_file "modules/$module"
856 echo "gnulib-tool: module $module doesn't exist" 1>&2
861 # func_verify_nontests_module
862 # verifies a module name, excluding tests modules
864 # - local_gnulib_dir from --local-dir
865 # - module module name argument
866 func_verify_nontests_module ()
870 * ) func_verify_module ;;
874 # func_verify_tests_module
875 # verifies a module name, considering only tests modules
877 # - local_gnulib_dir from --local-dir
878 # - module module name argument
879 func_verify_tests_module ()
882 *-tests ) func_verify_module ;;
887 sed_extract_prog=':[ ]*$/ {
890 s/^Description:[ ]*$//
892 s/^Depends-on:[ ]*$//
893 s/^configure\.ac-early:[ ]*$//
894 s/^configure\.ac:[ ]*$//
895 s/^Makefile\.am:[ ]*$//
899 s/^Maintainer:[ ]*$//
906 # func_get_description module
908 # - local_gnulib_dir from --local-dir
909 func_get_description ()
911 func_lookup_file "modules/$1"
912 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
915 # func_get_filelist module
917 # - local_gnulib_dir from --local-dir
920 func_lookup_file "modules/$1"
921 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
922 echo m4/gnulib-common.m4
923 case "$autoconf_minversion" in
926 echo m4/onceonly_2_57.m4
931 # func_get_dependencies module
933 # - local_gnulib_dir from --local-dir
934 func_get_dependencies ()
936 # ${module}-tests always implicitly depends on ${module}.
937 echo "$1" | sed -n -e 's/-tests//p'
938 # Then the explicit dependencies listed in the module description.
939 func_lookup_file "modules/$1"
940 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
943 # func_get_autoconf_early_snippet module
945 # - local_gnulib_dir from --local-dir
946 func_get_autoconf_early_snippet ()
948 func_lookup_file "modules/$1"
949 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
952 # func_get_autoconf_snippet module
954 # - local_gnulib_dir from --local-dir
955 func_get_autoconf_snippet ()
957 func_lookup_file "modules/$1"
958 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
961 # func_get_automake_snippet module
963 # - local_gnulib_dir from --local-dir
964 func_get_automake_snippet ()
966 func_lookup_file "modules/$1"
967 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
970 # *-tests module live in tests/, not lib/.
973 # Synthesize an EXTRA_DIST augmentation.
974 sed_combine_lines='/\\$/{
981 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
982 already_mentioned_files=` \
983 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
984 | sed -e "$sed_combine_lines" \
985 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
986 all_files=`func_get_filelist $1`
987 lib_files=`for f in $all_files; do \
991 done | sed -e 's,^lib/,,'`
992 # Remove $already_mentioned_files from $lib_files.
993 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
994 extra_files=`for f in $already_mentioned_files; do echo $f; done \
995 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
996 if test -n "$extra_files"; then
997 echo "EXTRA_DIST +=" $extra_files
1000 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1001 # This is necessary so that automake can generate the right list of
1003 # A possible approach would be to use autom4te --trace of the redefined
1004 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1005 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1006 # inside autoconf's built-in macros are not missed).
1007 # But it's simpler and more robust to do it here, based on the file list.
1008 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1009 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1010 # automake will generate a useless dependency; this is harmless.
1012 relocatable-prog-wrapper) ;;
1014 sed_extract_c_files='/\.c$/p'
1015 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1016 if test -n "$extra_files"; then
1017 echo "EXTRA_lib_SOURCES +=" $extra_files
1026 # func_get_include_directive module
1028 # - local_gnulib_dir from --local-dir
1029 func_get_include_directive ()
1031 func_lookup_file "modules/$1"
1032 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1033 sed -e 's/^\(["<]\)/#include \1/'
1036 # func_get_link_directive module
1038 # - local_gnulib_dir from --local-dir
1039 func_get_link_directive ()
1041 func_lookup_file "modules/$1"
1042 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1045 # func_get_license module
1047 # - local_gnulib_dir from --local-dir
1050 func_lookup_file "modules/$1"
1051 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1052 # The default is GPL.
1054 } | sed -e 's,^ *$,,' | sed -e 1q
1057 # func_get_maintainer module
1059 # - local_gnulib_dir from --local-dir
1060 func_get_maintainer ()
1062 func_lookup_file "modules/$1"
1063 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1066 # func_get_tests_module module
1068 # - local_gnulib_dir from --local-dir
1069 func_get_tests_module ()
1071 # The naming convention for tests modules is hardwired: ${module}-tests.
1072 if test -f "$gnulib_dir/modules/$1"-tests \
1073 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1074 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1079 # func_acceptable module
1080 # tests whether a module is acceptable.
1082 # - avoidlist list of modules to avoid
1085 for avoid in $avoidlist; do
1086 if test "$avoid" = "$1"; then
1093 # func_modules_transitive_closure
1095 # - local_gnulib_dir from --local-dir
1096 # - modules list of specified modules
1097 # - inctests true if tests should be included, blank otherwise
1098 # - avoidlist list of modules to avoid
1099 # - tmp pathname of a temporary directory
1101 # - modules list of modules, including dependencies
1102 func_modules_transitive_closure ()
1104 # In order to process every module only once (for speed), process an "input
1105 # list" of modules, producing an "output list" of modules. During each round,
1106 # more modules can be queued in the input list. Once a module on the input
1107 # list has been processed, it is added to the "handled list", so we can avoid
1108 # to process it again.
1110 inmodules="$modules"
1112 while test -n "$inmodules"; do
1113 inmodules_this_round="$inmodules"
1114 inmodules= # Accumulator, queue for next round
1115 for module in $inmodules_this_round; do
1117 if test -n "$module"; then
1118 if func_acceptable $module; then
1119 func_append outmodules " $module"
1120 deps=`func_get_dependencies $module`
1121 # Duplicate dependencies are harmless, but Jim wants a warning.
1122 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1123 if test -n "$duplicated_deps"; then
1124 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1126 func_append inmodules " $deps"
1127 if test -n "$inctests"; then
1128 testsmodule=`func_get_tests_module $module`
1129 if test -n "$testsmodule"; then
1130 func_append inmodules " $testsmodule"
1136 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1137 # Remove $handledmodules from $inmodules.
1138 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1139 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1141 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1142 rm -f "$tmp"/queued-modules
1145 # func_modules_add_dummy
1147 # - local_gnulib_dir from --local-dir
1148 # - modules list of modules, including dependencies
1150 # - modules list of modules, including 'dummy' if needed
1151 func_modules_add_dummy ()
1154 sed_remove_backslash_newline=':a
1161 for module in $modules; do
1162 func_verify_nontests_module
1163 if test -n "$module"; then
1164 # Extract the value of "lib_SOURCES += ...".
1165 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1166 # Ignore .h files since they are not compiled.
1169 *) have_lib_SOURCES=yes ;;
1174 # Add the dummy module, to make sure the library will be non-empty.
1175 if test -z "$have_lib_SOURCES"; then
1176 func_append modules " dummy"
1180 # func_modules_to_filelist
1182 # - local_gnulib_dir from --local-dir
1183 # - modules list of modules, including dependencies
1185 # - files list of files
1186 func_modules_to_filelist ()
1189 for module in $modules; do
1191 if test -n "$module"; then
1192 fs=`func_get_filelist $module`
1193 func_append files " $fs"
1196 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1199 # func_emit_lib_Makefile_am
1200 # emits the contents of library makefile to standard output.
1202 # - local_gnulib_dir from --local-dir
1203 # - modules list of modules, including dependencies
1204 # - libname library name
1205 # - auxdir directory relative to destdir where to place build aux files
1206 # - makefile_name from --makefile-name
1207 # - libtool true if libtool will be used, false or blank otherwise
1208 # - macro_prefix prefix of gl_LIBOBJS macros to use
1209 # - actioncmd (optional) command that will reproduce this invocation
1210 # - for_test true if creating a package for testing, false otherwise
1212 # - uses_subdirs nonempty if object files in subdirs exist
1213 func_emit_lib_Makefile_am ()
1215 # When creating an includable Makefile.am snippet, augment variables with
1216 # += instead of assigning them.
1217 if test -n "$makefile_name"; then
1222 if test "$libtool" = true; then
1225 sed_eliminate_LDFLAGS=
1229 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1232 # When creating a package for testing: Attempt to provoke failures,
1233 # especially link errors, already during "make" rather than during
1234 # "make check", because "make check" is not possible in a cross-compiling
1235 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1236 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1238 sed_transform_check_PROGRAMS=
1240 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1241 echo "## Process this file with automake to produce Makefile.in."
1242 func_emit_copyright_notice
1243 if test -n "$actioncmd"; then
1244 echo "# Reproduce by: $actioncmd"
1249 for module in $modules; do
1250 func_verify_nontests_module
1251 if test -n "$module"; then
1253 func_get_automake_snippet "$module" |
1254 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1255 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1256 sed -e "$sed_eliminate_LDFLAGS" |
1257 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1258 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1259 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' |
1260 sed -e "$sed_transform_check_PROGRAMS"
1261 if test "$module" = 'alloca'; then
1262 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1263 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1266 # Skip the contents if its entirely empty.
1267 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1268 echo "## begin gnulib module $module"
1271 echo "## end gnulib module $module"
1275 # Test whether there are some source files in subdirectories.
1276 for f in `func_get_filelist "$module"`; do
1278 lib/*/*.c) uses_subdirs=yes ;;
1284 if test -z "$makefile_name"; then
1285 # If there are source files in subdirectories, prevent collision of the
1286 # object files (example: hash.c and libxml/hash.c).
1288 if test -n "$uses_subdirs"; then
1289 subdir_options=' subdir-objects'
1291 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1294 if test -z "$makefile_name"; then
1295 echo "noinst_HEADERS ="
1296 echo "noinst_LIBRARIES ="
1297 echo "noinst_LTLIBRARIES ="
1298 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1299 # if you specify pkgdata_DATA to empty. This is a workaround.
1300 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1301 echo "pkgdata_DATA ="
1304 echo "BUILT_SOURCES ="
1307 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1308 if test -z "$makefile_name"; then
1309 echo "MOSTLYCLEANDIRS ="
1311 echo "DISTCLEANFILES ="
1312 echo "MAINTAINERCLEANFILES ="
1314 echo "AM_CPPFLAGS ="
1317 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1318 # One of the snippets already specifies an installation location for the
1319 # library. Don't confuse automake by saying it should not be installed.
1322 # By default, the generated library should not be installed.
1323 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1326 echo "${libname}_${libext}_SOURCES ="
1327 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1328 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1329 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1330 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1331 echo "EXTRA_${libname}_${libext}_SOURCES ="
1332 if test "$libtool" = true; then
1333 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1336 cat allsnippets.tmp \
1337 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1339 echo "mostlyclean-local: mostlyclean-generic"
1340 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1341 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1342 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1345 rm -f allsnippets.tmp
1348 # func_emit_tests_Makefile_am
1349 # emits the contents of tests makefile to standard output.
1351 # - local_gnulib_dir from --local-dir
1352 # - modules list of modules, including dependencies
1353 # - libname library name
1354 # - makefile_name from --makefile-name
1355 # - libtool true if libtool will be used, false or blank otherwise
1356 # - sourcebase relative directory containing lib source code
1357 # - m4base relative directory containing autoconf macros
1358 # - testsbase relative directory containing unit test code
1359 # - for_test true if creating a package for testing, false otherwise
1360 func_emit_tests_Makefile_am ()
1362 if test "$libtool" = true; then
1367 if test "$libtool" = true; then
1369 sed_eliminate_LDFLAGS=
1372 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1375 # When creating a package for testing: Attempt to provoke failures,
1376 # especially link errors, already during "make" rather than during
1377 # "make check", because "make check" is not possible in a cross-compiling
1378 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1379 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1381 sed_transform_check_PROGRAMS=
1383 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1384 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1385 echo "## Process this file with automake to produce Makefile.in."
1386 func_emit_copyright_notice
1388 # Generate dependencies here, since it eases the debugging of test failures.
1389 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1391 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1394 for module in $modules; do
1395 func_verify_tests_module
1396 if test -n "$module"; then
1398 func_get_automake_snippet "$module" |
1399 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1400 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1401 sed -e "$sed_eliminate_LDFLAGS" |
1402 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1403 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1404 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' |
1405 sed -e "$sed_transform_check_PROGRAMS"
1407 # Skip the contents if its entirely empty.
1408 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1409 echo "## begin gnulib module $module"
1412 echo "## end gnulib module $module"
1419 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1420 # variable is needed to avoid an error from automake:
1421 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1424 echo "TESTS_ENVIRONMENT ="
1425 echo "noinst_PROGRAMS ="
1426 if ! $for_test; then
1427 echo "check_PROGRAMS ="
1429 echo "noinst_HEADERS ="
1430 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1431 echo "pkgdata_DATA ="
1434 echo "BUILT_SOURCES ="
1436 echo "MOSTLYCLEANFILES = core *.stackdump"
1437 echo "MOSTLYCLEANDIRS ="
1439 echo "DISTCLEANFILES ="
1440 echo "MAINTAINERCLEANFILES ="
1442 echo "AM_CPPFLAGS = \\"
1443 echo " -I. -I\$(srcdir) \\"
1444 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1445 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1447 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1450 echo "# Clean up after Solaris cc."
1452 echo " rm -rf SunWS_cache"
1454 echo "mostlyclean-local: mostlyclean-generic"
1455 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1456 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1457 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1460 rm -f allsnippets.tmp
1463 # func_emit_initmacro_start
1464 # emits the first few statements of the gl_INIT macro to standard output.
1465 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1466 func_emit_initmacro_start ()
1468 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
1469 # platform-dependent object files in ${macro_prefix}_LIBOBJS instead of
1470 # LIBOBJS. The purpose is to allow several gnulib instantiations under
1471 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
1473 # Furthermore it avoids an automake error like this when a Makefile.am
1474 # that uses pieces of gnulib also uses $(LIBOBJ):
1475 # automatically discovered file `error.c' should not be explicitly mentioned
1476 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix}_LIBOBJ]))"
1477 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix}_REPLACE_FUNCS]))"
1478 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
1479 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
1480 # automatically discovered file `error.c' should not be explicitly mentioned
1481 # We let automake know about the files to be distributed through the
1482 # EXTRA_lib_SOURCES variable.
1483 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix}_LIBSOURCES]))"
1486 # func_emit_initmacro_end
1487 # emits the last few statements of the gl_INIT macro to standard output.
1488 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1489 func_emit_initmacro_end ()
1491 echo " m4_popdef([AC_LIBSOURCES])"
1492 echo " m4_popdef([AC_REPLACE_FUNCS])"
1493 echo " m4_popdef([AC_LIBOBJ])"
1494 echo " AC_CONFIG_COMMANDS_PRE(["
1495 echo " ${macro_prefix}_libobjs="
1496 echo " ${macro_prefix}_ltlibobjs="
1497 echo " if test -n \"\$${macro_prefix}_LIBOBJS\"; then"
1498 echo " # Remove the extension."
1499 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
1500 echo " for i in \`for i in \$${macro_prefix}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
1501 echo " ${macro_prefix}_libobjs=\"\$${macro_prefix}_libobjs \$i.\$ac_objext\""
1502 echo " ${macro_prefix}_ltlibobjs=\"\$${macro_prefix}_ltlibobjs \$i.lo\""
1505 echo " AC_SUBST([${macro_prefix}_LIBOBJS], [\$${macro_prefix}_libobjs])"
1506 echo " AC_SUBST([${macro_prefix}_LTLIBOBJS], [\$${macro_prefix}_ltlibobjs])"
1510 # func_emit_initmacro_done
1511 # emits a few statements after the gl_INIT macro to standard output.
1512 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1513 func_emit_initmacro_done ()
1516 echo "# Like AC_LIBOBJ, except that the module name goes"
1517 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1518 echo "AC_DEFUN([${macro_prefix}_LIBOBJ],"
1519 echo " [${macro_prefix}_LIBOBJS=\"\$${macro_prefix}_LIBOBJS \$1.\$ac_objext\"])"
1521 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
1522 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1523 echo "AC_DEFUN([${macro_prefix}_REPLACE_FUNCS],"
1524 echo " [AC_CHECK_FUNCS([\$1], , [${macro_prefix}_LIBOBJ(\$ac_func)])])"
1526 echo "# Like AC_LIBSOURCES, except that it does nothing."
1527 echo "# We rely on EXTRA_lib..._SOURCES instead."
1528 echo "AC_DEFUN([${macro_prefix}_LIBSOURCES],"
1532 # func_import modules
1533 # Uses also the variables
1534 # - destdir target directory
1535 # - local_gnulib_dir from --local-dir
1536 # - libname library name
1537 # - sourcebase directory relative to destdir where to place source code
1538 # - m4base directory relative to destdir where to place *.m4 macros
1539 # - docbase directory relative to destdir where to place doc files
1540 # - testsbase directory relative to destdir where to place unit test code
1541 # - auxdir directory relative to destdir where to place build aux files
1542 # - inctests true if --with-tests was given, blank otherwise
1543 # - avoidlist list of modules to avoid, from --avoid
1544 # - lgpl true if library's license shall be LGPL, blank otherwise
1545 # - makefile_name from --makefile-name
1546 # - libtool true if --libtool was given, false if --no-libtool was
1547 # given, blank otherwise
1548 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1549 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1550 # - autoconf_minversion minimum supported autoconf version
1551 # - doit : if actions shall be executed, false if only to be printed
1552 # - symbolic true if files should be symlinked, copied otherwise
1553 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1557 # Get the cached settings.
1558 cached_local_gnulib_dir=
1559 cached_specified_modules=
1567 cached_makefile_name=
1569 cached_macro_prefix=
1571 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1572 cached_libtool=false
1578 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
1581 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1584 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1587 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1590 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1593 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1596 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1599 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1602 s,^.*$,cached_lgpl=true,p
1604 /gl_MAKEFILE_NAME(/ {
1605 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
1608 s,^.*$,cached_libtool=true,p
1610 /gl_MACRO_PREFIX(/ {
1611 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
1613 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
1614 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1619 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
1620 s,^.*$,cached_files=",p
1632 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1636 # Merge the cached settings with the specified ones.
1637 # The m4base must be the same as expected from the pathname.
1638 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1639 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1641 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
1642 # is relative to $destdir, whereas the one we use is relative to . or absolute.
1643 if test -z "$local_gnulib_dir"; then
1644 if test -n "$cached_local_gnulib_dir"; then
1647 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1649 case "$cached_local_gnulib_dir" in
1651 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1653 func_relconcat "$destdir" "$cached_local_gnulib_dir"
1654 local_gnulib_dir="$relconcat" ;;
1659 # Append the cached and the specified module names. So that
1660 # "gnulib-tool --import foo" means to add the module foo.
1661 specified_modules="$cached_specified_modules $1"
1662 # Append the cached and the specified avoidlist. This is probably better
1663 # than dropping the cached one when --avoid is specified at least once.
1664 avoidlist=`echo $cached_avoidlist $avoidlist`
1665 # The sourcebase defaults to the cached one.
1666 if test -z "$sourcebase"; then
1667 sourcebase="$cached_sourcebase"
1668 if test -z "$sourcebase"; then
1669 func_fatal_error "missing --source-base option"
1672 # The docbase defaults to the cached one.
1673 if test -z "$docbase"; then
1674 docbase="$cached_docbase"
1675 if test -z "$docbase"; then
1676 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."
1679 # The testsbase defaults to the cached one.
1680 if test -z "$testsbase"; then
1681 testsbase="$cached_testsbase"
1682 if test -z "$testsbase"; then
1683 func_fatal_error "missing --tests-base option"
1686 # The libname defaults to the cached one.
1687 if test -z "$supplied_libname"; then
1688 libname="$cached_libname"
1689 if test -z "$libname"; then
1690 func_fatal_error "missing --lib option"
1693 # Require LGPL if specified either way.
1694 if test -z "$lgpl"; then
1697 # The makefile_name defaults to the cached one.
1698 if test -z "$makefile_name"; then
1699 makefile_name="$cached_makefile_name"
1701 # Use libtool if specified either way, or if guessed.
1702 if test -z "$libtool"; then
1703 if test -n "$cached_m4base"; then
1704 libtool="$cached_libtool"
1706 libtool="$guessed_libtool"
1709 # The macro_prefix defaults to the cached one.
1710 if test -z "$macro_prefix"; then
1711 macro_prefix="$cached_macro_prefix"
1712 if test -z "$macro_prefix"; then
1713 func_fatal_error "missing --macro-prefix option"
1717 # Canonicalize the list of specified modules.
1718 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
1720 # Determine final module list.
1721 modules="$specified_modules"
1722 func_modules_transitive_closure
1723 echo "Module list with included dependencies:"
1724 echo "$modules" | sed -e 's/^/ /'
1726 # Add the dummy module if needed.
1727 func_modules_add_dummy
1729 # If --lgpl, verify that the licenses of modules are compatible.
1730 if test -n "$lgpl"; then
1731 for module in $modules; do
1732 license=`func_get_license $module`
1734 LGPL | 'GPLed build tool') ;;
1735 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
1736 *) func_fatal_error "incompatible license on module $module: $license" ;;
1741 # Determine script to apply to imported library files.
1742 sed_transform_lib_file=
1743 for module in $modules; do
1744 if test $module = config-h; then
1745 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
1746 sed_transform_lib_file=$sed_transform_lib_file'
1747 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
1752 if test -n "$lgpl"; then
1754 sed_transform_lib_file=$sed_transform_lib_file'
1755 s/GNU General/GNU Lesser General/g
1756 s/version 2\([ ,]\)/version 2.1\1/g
1760 # Determine final file list.
1761 func_modules_to_filelist
1763 echo "$files" | sed -e 's/^/ /'
1766 || func_fatal_error "refusing to do nothing"
1768 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
1769 new_files="$files m4/gnulib-tool.m4"
1770 old_files="$cached_files"
1771 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
1772 func_append old_files " m4/gnulib-tool.m4"
1775 sed_rewrite_old_files="\
1776 s,^build-aux/,$auxdir/,
1777 s,^doc/,$cached_docbase/,
1778 s,^lib/,$cached_sourcebase/,
1779 s,^m4/,$cached_m4base/,
1780 s,^tests/,$cached_testsbase/,"
1781 sed_rewrite_new_files="\
1782 s,^build-aux/,$auxdir/,
1784 s,^lib/,$sourcebase/,
1786 s,^tests/,$testsbase/,"
1788 # Create directories.
1789 { echo "$sourcebase"
1791 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
1792 if test -n "$docfiles"; then
1795 if test -n "$inctests"; then
1799 for f in $files; do echo $f; done \
1800 | sed -e "$sed_rewrite_new_files" \
1801 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
1804 { # Rearrange file descriptors. Needed because "while ... done < ..."
1805 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1806 exec 5<&0 < "$tmp"/dirs
1808 if test ! -d "$destdir/$d"; then
1810 echo "Creating directory $destdir/$d"
1811 mkdir -p "$destdir/$d" || func_fatal_error "failed"
1813 echo "Create directory $destdir/$d"
1820 # func_dest_tmpfilename file
1821 # determines the name of a temporary file (file is relative to destdir).
1823 # - tmpfile absolute filename of the temporary file
1824 func_dest_tmpfilename ()
1827 # Put the new contents of $file in a file in the same directory (needed
1828 # to guarantee that an 'mv' to "$destdir/$file" works).
1829 tmpfile="$destdir/$1.tmp"
1831 # Put the new contents of $file in a file in a temporary directory
1832 # (because the directory of "$file" might not exist).
1833 tmpfile="$tmp"/`basename "$1"`.tmp
1837 # Copy files or make symbolic links. Remove obsolete files.
1839 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1840 # representing the files according to the last gnulib-tool invocation.
1841 for f in $old_files; do echo $f; done \
1842 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
1845 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1846 # representing the files after this gnulib-tool invocation.
1847 for f in $new_files; do echo $f; done \
1848 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
1851 # First the files that are in old-files, but not in new-files:
1852 sed_take_first_column='s,'"$delimiter"'.*,,'
1853 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
1854 # Remove the file. Do nothing if the user already removed it.
1855 if test -f "$destdir/$g"; then
1857 echo "Removing file $g (backup in ${g}~)"
1858 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1860 echo "Remove file $g (backup in ${g}~)"
1864 # func_add_or_update handles a file that ought to be present afterwards.
1866 # - f the original file name
1867 # - g the rewritten file name
1868 # - already_present nonempty if the file already exists, empty otherwise
1869 func_add_or_update ()
1871 func_dest_tmpfilename "$g"
1872 func_lookup_file "$f"
1873 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
1874 if test -n "$sed_transform_lib_file"; then
1877 sed -e "$sed_transform_lib_file" \
1878 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
1882 if test -f "$destdir/$g"; then
1883 # The file already exists.
1884 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1885 : # The file has not changed.
1889 if test -n "$already_present"; then
1890 echo "Updating file $g (backup in ${g}~)"
1892 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
1894 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1895 if { test -n "$symbolic" \
1896 || { test -n "$lsymbolic" \
1897 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1898 && test -z "$lookedup_tmp" \
1899 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1900 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1902 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1905 if test -n "$already_present"; then
1906 echo "Update file $g (backup in ${g}~)"
1908 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
1914 # Don't protest if the file should be there but isn't: it happens
1915 # frequently that developers don't put autogenerated files into CVS.
1917 echo "Copying file $g"
1918 if { test -n "$symbolic" \
1919 || { test -n "$lsymbolic" \
1920 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1921 && test -z "$lookedup_tmp" \
1922 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1923 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1925 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1933 # Then the files that are in new-files, but not in old-files:
1934 sed_take_last_column='s,^.*'"$delimiter"',,'
1936 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
1937 | sed -e "$sed_take_last_column" \
1938 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
1939 { # Rearrange file descriptors. Needed because "while ... done < ..."
1940 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1941 exec 5<&0 < "$tmp"/added-files
1947 # Then the files that are in new-files and in old-files:
1948 already_present=true
1949 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
1950 | sed -e "$sed_take_last_column" \
1951 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
1952 { # Rearrange file descriptors. Needed because "while ... done < ..."
1953 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1954 exec 5<&0 < "$tmp"/kept-files
1961 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
1962 actioncmd="gnulib-tool --import"
1963 func_append actioncmd " --dir=$destdir"
1964 if test -n "$local_gnulib_dir"; then
1965 func_append actioncmd " --local-dir=$local_gnulib_dir"
1967 func_append actioncmd " --lib=$libname"
1968 func_append actioncmd " --source-base=$sourcebase"
1969 func_append actioncmd " --m4-base=$m4base"
1970 func_append actioncmd " --doc-base=$docbase"
1971 func_append actioncmd " --aux-dir=$auxdir"
1972 for module in $avoidlist; do
1973 func_append actioncmd " --avoid=$module"
1975 if test -n "$lgpl"; then
1976 func_append actioncmd " --lgpl"
1978 if test -n "$makefile_name"; then
1979 func_append actioncmd " --makefile-name=$makefile_name"
1981 if test "$libtool" = true; then
1982 func_append actioncmd " --libtool"
1984 func_append actioncmd " --no-libtool"
1986 func_append actioncmd " --macro-prefix=$macro_prefix"
1987 func_append actioncmd " `echo $specified_modules`"
1989 # Default the makefile name to Makefile.am.
1990 if test -n "$makefile_name"; then
1991 makefile_am=$makefile_name
1993 makefile_am=Makefile.am
1996 # Create normal Makefile.ams.
1999 # Create library makefile.
2000 func_dest_tmpfilename $sourcebase/$makefile_am
2001 func_emit_lib_Makefile_am > "$tmpfile"
2002 if test -f "$destdir"/$sourcebase/$makefile_am; then
2003 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
2007 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2008 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
2009 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2011 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2017 echo "Creating $sourcebase/$makefile_am"
2018 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2020 echo "Create $sourcebase/$makefile_am"
2025 # Create m4/gnulib-cache.m4.
2026 func_dest_tmpfilename $m4base/gnulib-cache.m4
2028 func_emit_copyright_notice
2030 echo "# This file represents the specification of how gnulib-tool is used."
2031 echo "# It acts as a cache: It is written and read by gnulib-tool."
2032 echo "# In projects using CVS, this file is meant to be stored in CVS,"
2033 echo "# like the configure.ac and various Makefile.am files."
2036 echo "# Specification in the form of a command-line invocation:"
2039 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
2040 # Store the local_gnulib_dir relative to destdir.
2041 case "$local_gnulib_dir" in
2043 relative_local_gnulib_dir="$local_gnulib_dir" ;;
2046 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
2048 # destdir, local_gnulib_dir are both relative.
2049 func_relativize "$destdir" "$local_gnulib_dir"
2050 relative_local_gnulib_dir="$reldir" ;;
2053 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
2054 echo "gl_MODULES(["`echo $specified_modules`"])"
2055 echo "gl_AVOID([$avoidlist])"
2056 echo "gl_SOURCE_BASE([$sourcebase])"
2057 echo "gl_M4_BASE([$m4base])"
2058 echo "gl_DOC_BASE([$docbase])"
2059 echo "gl_TESTS_BASE([$testsbase])"
2060 echo "gl_LIB([$libname])"
2061 test -z "$lgpl" || echo "gl_LGPL"
2062 echo "gl_MAKEFILE_NAME([$makefile_name])"
2063 if test "$libtool" = true; then
2066 echo "gl_MACRO_PREFIX([$macro_prefix])"
2068 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2069 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2073 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2074 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2075 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2077 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2081 echo "# gnulib-cache.m4 ends here"
2088 echo "Creating $m4base/gnulib-cache.m4"
2089 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2091 echo "Create $m4base/gnulib-cache.m4"
2097 # Create m4/gnulib-comp.m4.
2098 func_dest_tmpfilename $m4base/gnulib-comp.m4
2100 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2101 func_emit_copyright_notice
2103 echo "# This file represents the compiled summary of the specification in"
2104 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2105 echo "# to be invoked from configure.ac."
2106 echo "# In projects using CVS, this file can be treated like other built files."
2109 echo "# This macro should be invoked from $configure_ac, in the section"
2110 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2111 echo "# any checks for libraries, header files, types and library functions."
2112 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2114 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2115 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2116 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2117 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2118 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2119 if test -n "$uses_subdirs"; then
2120 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2122 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2123 echo " AC_REQUIRE([AC_GNU_SOURCE])"
2125 for module in $modules; do
2127 if test -n "$module"; then
2128 func_get_autoconf_early_snippet "$module"
2131 | sed -e '/^$/d;' -e 's/^/ /'
2134 echo "# This macro should be invoked from $configure_ac, in the section"
2135 echo "# \"Check for header files, types and library functions\"."
2136 echo "AC_DEFUN([${macro_prefix}_INIT],"
2138 func_emit_initmacro_start
2139 if test "$libtool" = true; then
2140 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2141 echo " gl_cond_libtool=true"
2143 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2144 echo " gl_cond_libtool=false"
2146 echo " gl_ltlibdeps="
2148 echo " gl_source_base='$sourcebase'"
2149 if test "$auxdir" != "build-aux"; then
2150 sed_replace_build_aux='
2152 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2153 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2156 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2158 sed_replace_build_aux=
2160 for module in $modules; do
2162 if test -n "$module"; then
2163 func_get_autoconf_snippet "$module" \
2164 | sed -e '/^$/d;' -e 's/^/ /' \
2165 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
2166 -e "$sed_replace_build_aux"
2167 if test "$module" = 'alloca' && test "$libtool" = true; then
2168 echo 'changequote(,)dnl'
2169 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
2170 echo 'changequote([, ])dnl'
2171 echo 'AC_SUBST([LTALLOCA])'
2175 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2176 # created using libtool, because libtool already handles the dependencies.
2177 if test "$libtool" != true; then
2178 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z' 'A-Z'`
2179 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2180 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2181 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2182 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2184 func_emit_initmacro_end
2186 func_emit_initmacro_done
2188 echo "# This macro records the list of files which have been installed by"
2189 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
2190 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
2191 echo "$files" | sed -e 's,^, ,'
2194 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2195 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
2199 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2200 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
2201 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2203 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2207 echo "# gnulib-comp.m4 ends here"
2214 echo "Creating $m4base/gnulib-comp.m4"
2215 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2217 echo "Create $m4base/gnulib-comp.m4"
2223 if test -n "$inctests"; then
2224 # Create tests makefile.
2225 func_dest_tmpfilename $testsbase/$makefile_am
2226 func_emit_tests_Makefile_am > "$tmpfile"
2227 if test -f "$destdir"/$testsbase/$makefile_am; then
2228 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
2232 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2233 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
2234 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2236 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2242 echo "Creating $testsbase/$makefile_am"
2243 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2245 echo "Create $testsbase/$makefile_am"
2253 echo "You may need to add #include directives for the following .h files."
2254 # Intersect $specified_modules and $modules
2255 # (since $specified_modules is not necessarily of subset of $modules - some
2256 # may have been skipped through --avoid, and since the elements of $modules
2257 # but not in $specified_modules can go away without explicit notice - through
2258 # changes in the module dependencies).
2259 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
2260 echo "$modules" > "$tmp"/modules2 # also a sorted list, one module per line
2261 # First the #include <...> directives without #ifs, sorted for convenience,
2262 # then the #include "..." directives without #ifs, sorted for convenience,
2263 # then the #include directives that are surrounded by #ifs. Not sorted.
2264 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
2265 include_directive=`func_get_include_directive "$module"`
2266 case "$nl$include_directive" in
2268 echo "$include_directive" 1>&5
2271 echo "$include_directive" | grep -v 'include "' 1>&6
2272 echo "$include_directive" | grep 'include "' 1>&7
2275 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
2277 LC_ALL=C sort -u "$tmp"/include-angles
2278 LC_ALL=C sort -u "$tmp"/include-quotes
2279 cat "$tmp"/include-if
2280 ) | sed -e '/^$/d' -e 's/^/ /'
2281 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
2283 for module in $modules; do
2284 func_get_link_directive "$module"
2286 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
2287 if test `wc -l < "$tmp"/link` != 0; then
2289 echo "You may need to use the following Makefile variables when linking."
2290 echo "Use them in <program>_LDADD when linking a program, or"
2291 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
2297 echo "Don't forget to"
2298 if test "$makefile_am" = Makefile.am; then
2299 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2301 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
2303 if test -n "$inctests"; then
2304 if test "$makefile_am" = Makefile.am; then
2305 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2307 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
2310 if test "$makefile_am" = Makefile.am; then
2311 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
2312 sourcebase_base=`basename "$sourcebase"`
2313 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
2315 if test -n "$inctests"; then
2316 if test "$makefile_am" = Makefile.am; then
2317 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
2318 testsbase_base=`basename "$testsbase"`
2319 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
2322 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
2323 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
2324 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
2327 # func_create_testdir testdir modules
2329 # - local_gnulib_dir from --local-dir
2330 # - auxdir directory relative to destdir where to place build aux files
2331 func_create_testdir ()
2335 if test -z "$modules"; then
2336 # All modules together.
2337 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2338 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2339 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
2340 modules=`func_all_modules`
2341 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
2343 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
2345 # Check that the license of every module is consistent with the license of
2347 saved_modules="$modules"
2348 saved_inctests="$inctests"
2349 # When computing transitive closures, don't consider $module to depend on
2350 # $module-tests. Need this becauses tests are implicitly GPL and may depend
2351 # on GPL modules - therefore we don't want a warning in this case.
2353 for requested_module in $saved_modules; do
2354 requested_license=`func_get_license "$requested_module"`
2355 if test "$requested_license" != GPL; then
2356 # Here we use func_modules_transitive_closure, not just
2357 # func_get_dependencies, so that we also detect weird situations like
2358 # an LGPL module which depends on a GPLed build tool module which depends
2360 modules="$requested_module"
2361 func_modules_transitive_closure
2362 for module in $modules; do
2363 license=`func_get_license "$module"`
2365 LGPL | 'GPLed build tool') ;;
2366 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2367 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
2372 modules="$saved_modules"
2373 inctests="$saved_inctests"
2375 # Subdirectory names.
2382 # Determine final module list.
2383 func_modules_transitive_closure
2384 echo "Module list with included dependencies:"
2385 echo "$modules" | sed -e 's/^/ /'
2387 # Add the dummy module if needed.
2388 func_modules_add_dummy
2390 # Determine final file list.
2391 func_modules_to_filelist
2393 echo "$files" | sed -e 's/^/ /'
2395 sed_rewrite_files="\
2396 s,^build-aux/,$auxdir/,
2398 s,^lib/,$sourcebase/,
2400 s,^tests/,$testsbase/,"
2402 # Create directories.
2403 for f in $files; do echo $f; done \
2404 | sed -e "$sed_rewrite_files" \
2405 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2406 | LC_ALL=C sort -u \
2408 { # Rearrange file descriptors. Needed because "while ... done < ..."
2409 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2410 exec 5<&0 < "$tmp"/dirs
2412 mkdir -p "$testdir/$d"
2417 # Copy files or make symbolic links.
2419 for f in $files; do echo $f; done \
2420 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
2423 { # Rearrange file descriptors. Needed because "while ... done < ..."
2424 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2425 exec 5<&0 < "$tmp"/files
2427 func_lookup_file "$f"
2428 if test -n "$lookedup_tmp"; then
2429 cp -p "$lookedup_file" "$testdir/$g"
2431 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
2432 if { test -n "$symbolic" \
2433 || { test -n "$lsymbolic" \
2434 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
2435 func_ln "$lookedup_file" "$testdir/$g"
2437 cp -p "$lookedup_file" "$testdir/$g"
2444 # Create Makefile.ams that are for testing.
2447 # Create $sourcebase/Makefile.am.
2448 mkdir -p "$testdir/$sourcebase"
2449 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
2451 # Create $m4base/Makefile.am.
2452 mkdir -p "$testdir/$m4base"
2453 (echo "## Process this file with automake to produce Makefile.in."
2459 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
2462 ) > "$testdir/$m4base/Makefile.am"
2464 subdirs="$sourcebase $m4base"
2465 subdirs_with_configure_ac=""
2467 if false && test -f "$testdir"/$m4base/gettext.m4; then
2468 # Avoid stupid error message from automake:
2469 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
2470 mkdir -p "$testdir/po"
2471 (echo "## Process this file with automake to produce Makefile.in."
2472 ) > "$testdir/po/Makefile.am"
2473 func_append subdirs " po"
2476 if test -n "$inctests"; then
2477 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
2478 # Create $testsbase/Makefile.am.
2479 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
2480 # Create $testsbase/configure.ac.
2481 (echo "# Process this file with autoconf to produce a configure script."
2482 echo "AC_INIT([dummy], [0])"
2483 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
2484 echo "AM_INIT_AUTOMAKE"
2486 echo "AM_CONFIG_HEADER([config.h])"
2489 echo "AC_PROG_INSTALL"
2490 echo "AC_PROG_MAKE_SET"
2491 echo "AC_PROG_RANLIB"
2493 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2494 echo "AC_GNU_SOURCE"
2497 for module in $modules; do
2499 if test -n "$module"; then
2500 func_get_autoconf_early_snippet "$module"
2503 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
2504 if test "$libtool" = true; then
2505 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2506 echo "gl_cond_libtool=true"
2508 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2509 echo "gl_cond_libtool=false"
2511 echo "gl_ltlibdeps="
2513 # Wrap the set of autoconf snippets into an autoconf macro that is then
2514 # invoked. This is needed because autoconf does not support AC_REQUIRE
2516 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2517 # but we want the AC_REQUIRE to have its normal meaning (provide one
2518 # expansion of the required macro before the current point, and only one
2520 echo "AC_DEFUN([gl_INIT], ["
2521 func_emit_initmacro_start
2522 sed_replace_build_aux='
2524 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2525 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
2528 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2529 # We don't have explicit ordering constraints between the various
2530 # autoconf snippets. It's cleanest to put those of the library before
2531 # those of the tests.
2532 echo "gl_source_base='../$sourcebase'"
2533 for module in $modules; do
2534 func_verify_nontests_module
2535 if test -n "$module"; then
2536 func_get_autoconf_snippet "$module" \
2537 | sed -e "$sed_replace_build_aux"
2540 echo "gl_source_base='.'"
2541 for module in $modules; do
2542 func_verify_tests_module
2543 if test -n "$module"; then
2544 func_get_autoconf_snippet "$module" \
2545 | sed -e "$sed_replace_build_aux"
2548 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2549 # created using libtool, because libtool already handles the dependencies.
2550 if test "$libtool" != true; then
2551 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z' 'A-Z'`
2552 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2553 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2554 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2555 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2557 func_emit_initmacro_end
2559 func_emit_initmacro_done
2563 # Usually $testsbase/config.h will be a superset of config.h. Verify this
2564 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
2565 echo "AH_TOP([#include \"../config.h\"])"
2567 echo "AC_OUTPUT([Makefile])"
2568 ) > "$testdir/$testsbase/configure.ac"
2569 func_append subdirs " $testsbase"
2570 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
2573 # Create Makefile.am.
2574 (echo "## Process this file with automake to produce Makefile.in."
2576 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2578 echo "SUBDIRS = $subdirs"
2580 echo "ACLOCAL_AMFLAGS = -I $m4base"
2581 ) > "$testdir/Makefile.am"
2583 # Create configure.ac.
2584 (echo "# Process this file with autoconf to produce a configure script."
2585 echo "AC_INIT([dummy], [0])"
2586 if test "$auxdir" != "."; then
2587 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2589 echo "AM_INIT_AUTOMAKE"
2591 echo "AM_CONFIG_HEADER([config.h])"
2594 echo "AC_PROG_INSTALL"
2595 echo "AC_PROG_MAKE_SET"
2597 echo "# For autobuild."
2598 echo "AC_CANONICAL_BUILD"
2599 echo "AC_CANONICAL_HOST"
2601 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2602 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2603 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2604 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2606 echo "AC_PROG_RANLIB"
2608 if test -n "$uses_subdirs"; then
2609 echo "AM_PROG_CC_C_O"
2612 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2613 echo "AC_GNU_SOURCE"
2616 for module in $modules; do
2617 func_verify_nontests_module
2618 if test -n "$module"; then
2619 func_get_autoconf_early_snippet "$module"
2622 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
2623 if test "$libtool" = true; then
2624 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2625 echo "gl_cond_libtool=true"
2627 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2628 echo "gl_cond_libtool=false"
2630 echo "gl_ltlibdeps="
2632 echo "gl_source_base='$sourcebase'"
2633 # Wrap the set of autoconf snippets into an autoconf macro that is then
2634 # invoked. This is needed because autoconf does not support AC_REQUIRE
2636 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2637 # but we want the AC_REQUIRE to have its normal meaning (provide one
2638 # expansion of the required macro before the current point, and only one
2640 echo "AC_DEFUN([gl_INIT], ["
2641 func_emit_initmacro_start
2642 if test "$auxdir" != "build-aux"; then
2643 sed_replace_build_aux='
2645 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2646 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2649 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2651 sed_replace_build_aux=
2653 for module in $modules; do
2654 func_verify_nontests_module
2655 if test -n "$module"; then
2656 func_get_autoconf_snippet "$module" \
2657 | sed -e "$sed_replace_build_aux"
2660 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2661 # created using libtool, because libtool already handles the dependencies.
2662 if test "$libtool" != true; then
2663 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z' 'A-Z'`
2664 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2665 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2666 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2667 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2669 func_emit_initmacro_end
2671 func_emit_initmacro_done
2675 if test -n "$subdirs_with_configure_ac"; then
2676 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
2678 makefiles="Makefile"
2679 for d in $subdirs; do
2680 # For subdirs that have a configure.ac by their own, it's the subdir's
2681 # configure.ac which creates the subdir's Makefile.am, not this one.
2682 case " $subdirs_with_configure_ac " in
2684 *) func_append makefiles " $d/Makefile" ;;
2687 echo "AC_OUTPUT([$makefiles])"
2688 ) > "$testdir/configure.ac"
2690 # Create autogenerated files.
2692 # Do not use "${AUTORECONF} --force --install", because it may invoke
2693 # autopoint, which brings in older versions of some of our .m4 files.
2694 if test -f $m4base/gettext.m4; then
2695 echo "executing ${AUTOPOINT} --force"
2696 ${AUTOPOINT} --force || func_exit 1
2697 for f in $m4base/*.m4~; do
2698 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2701 echo "executing ${ACLOCAL} -I $m4base"
2702 ${ACLOCAL} -I $m4base || func_exit 1
2703 if ! test -d build-aux; then
2704 echo "executing mkdir build-aux"
2705 mkdir build-aux || func_exit 1
2707 echo "executing ${AUTOCONF}"
2708 ${AUTOCONF} || func_exit 1
2709 echo "executing ${AUTOHEADER}"
2710 ${AUTOHEADER} || func_exit 1
2711 echo "executing ${AUTOMAKE} --add-missing --copy"
2712 ${AUTOMAKE} --add-missing --copy || func_exit 1
2714 if test -n "$inctests"; then
2715 # Create autogenerated files.
2716 (cd "$testdir/$testsbase" || func_exit 1
2717 # Do not use "${AUTORECONF} --force --install", because it may invoke
2718 # autopoint, which brings in older versions of some of our .m4 files.
2719 if test -f ../$m4base/gettext.m4; then
2720 echo "executing ${AUTOPOINT} --force"
2721 ${AUTOPOINT} --force || func_exit 1
2722 for f in ../$m4base/*.m4~; do
2723 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2726 echo "executing ${ACLOCAL} -I ../$m4base"
2727 ${ACLOCAL} -I ../$m4base || func_exit 1
2728 if ! test -d ../build-aux; then
2729 echo "executing mkdir ../build-aux"
2732 echo "executing ${AUTOCONF}"
2733 ${AUTOCONF} || func_exit 1
2734 echo "executing ${AUTOHEADER}"
2735 ${AUTOHEADER} || func_exit 1
2736 echo "executing ${AUTOMAKE} --add-missing --copy"
2737 ${AUTOMAKE} --add-missing --copy || func_exit 1
2740 # Need to run configure and make once, to create built files that are to be
2741 # distributed (such as getdate.c).
2742 # Extract the value of "CLEANFILES += ...".
2743 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
2744 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
2745 cleaned_files=" "`for file in $cleaned_files; do echo "$file"; done`" "
2746 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
2747 # such $(FOO_H) because they don't refer to distributed files.
2748 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
2749 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
2750 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
2751 | sed -e "$sed_remove_make_variables"`
2752 distributed_built_sources=`for file in $built_sources; do
2753 case "$cleaned_files" in
2758 if test -n "$distributed_built_sources"; then
2760 ./configure || func_exit 1
2762 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
2763 make built_sources || func_exit 1
2765 make distclean || func_exit 1
2770 # func_create_megatestdir megatestdir allmodules
2772 # - local_gnulib_dir from --local-dir
2773 # - auxdir directory relative to destdir where to place build aux files
2774 func_create_megatestdir ()
2778 if test -z "$allmodules"; then
2779 allmodules=`func_all_modules`
2783 # First, all modules one by one.
2784 for onemodule in $allmodules; do
2785 func_create_testdir "$megatestdir/$onemodule" $onemodule
2786 func_append megasubdirs "$onemodule "
2788 # Then, all modules all together.
2789 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2790 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2791 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
2792 func_create_testdir "$megatestdir/ALL" "$allmodules"
2793 func_append megasubdirs "ALL"
2795 # Create Makefile.am.
2796 (echo "## Process this file with automake to produce Makefile.in."
2798 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2800 echo "SUBDIRS = $megasubdirs"
2801 ) > "$megatestdir/Makefile.am"
2803 # Create configure.ac.
2804 (echo "# Process this file with autoconf to produce a configure script."
2805 echo "AC_INIT([dummy], [0])"
2806 if test "$auxdir" != "."; then
2807 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2809 echo "AM_INIT_AUTOMAKE"
2811 echo "AC_PROG_MAKE_SET"
2813 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
2814 echo "AC_OUTPUT([Makefile])"
2815 ) > "$megatestdir/configure.ac"
2817 # Create autogenerated files.
2819 # Do not use "${AUTORECONF} --install", because autoreconf operates
2820 # recursively, but the subdirectories are already finished, therefore
2821 # calling autoreconf here would only waste lots of CPU time.
2822 echo "executing ${ACLOCAL}"
2823 ${ACLOCAL} || func_exit 1
2824 echo "executing mkdir build-aux"
2826 echo "executing ${AUTOCONF}"
2827 ${AUTOCONF} || func_exit 1
2828 echo "executing ${AUTOMAKE} --add-missing --copy"
2829 ${AUTOMAKE} --add-missing --copy || func_exit 1
2835 func_fatal_error "no mode specified" ;;
2844 if test -z "$destdir"; then
2847 test -d "$destdir" \
2848 || func_fatal_error "destination directory does not exist: $destdir"
2850 # Prefer configure.ac to configure.in.
2851 if test -f "$destdir"/configure.ac; then
2852 configure_ac="$destdir/configure.ac"
2854 if test -f "$destdir"/configure.in; then
2855 configure_ac="$destdir/configure.in"
2857 func_fatal_error "cannot find $destdir/configure.ac"
2861 # Analyze configure.ac.
2863 guessed_libtool=false
2868 /AC_CONFIG_AUX_DIR/ {
2869 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
2871 /A[CM]_PROG_LIBTOOL/ {
2872 s,^.*$,guessed_libtool=true,p
2874 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
2876 if test -z "$auxdir"; then
2877 auxdir="$guessed_auxdir"
2880 # Determine where to apply func_import.
2881 if test -n "$m4base"; then
2882 # Apply func_import to a particular gnulib directory.
2883 # Any number of additional modules can be given.
2884 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
2885 # First use of gnulib in the given m4base.
2886 test -n "$supplied_libname" || supplied_libname=true
2887 test -n "$sourcebase" || sourcebase="lib"
2888 test -n "$docbase" || docbase="doc"
2889 test -n "$testsbase" || testsbase="tests"
2890 test -n "$macro_prefix" || macro_prefix="gl"
2894 # Apply func_import to all gnulib directories.
2895 # To get this list of directories, look at Makefile.am. (Not at
2896 # configure, because it may be omitted from CVS. Also, don't run
2897 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
2900 if test -f "$destdir"/Makefile.am; then
2901 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
2903 for arg in $aclocal_amflags; do
2904 if test -n "$m4dir_is_next"; then
2905 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
2909 if test -f "$destdir/$arg"/gnulib-cache.m4; then
2910 func_append m4dirs " $arg"
2911 m4dirs_count=`expr $m4dirs_count + 1`
2917 if test "X$arg" = "X-I"; then
2925 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
2926 if test -f "$destdir"/aclocal.m4; then
2927 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
2928 sedexpr2='s,^[^/]*$,.,'
2929 sedexpr3='s,/[^/]*$,,'
2930 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
2931 m4dirs_count=`echo "$m4dirs" | wc -l`
2934 if test $m4dirs_count = 0; then
2935 # First use of gnulib in a package.
2936 # Any number of additional modules can be given.
2937 test -n "$supplied_libname" || supplied_libname=true
2938 test -n "$sourcebase" || sourcebase="lib"
2940 test -n "$docbase" || docbase="doc"
2941 test -n "$testsbase" || testsbase="tests"
2942 test -n "$macro_prefix" || macro_prefix="gl"
2945 if test $m4dirs_count = 1; then
2946 # There's only one use of gnulib here. Assume the user means it.
2947 # Any number of additional modules can be given.
2948 for m4base in $m4dirs; do
2952 # Ambiguous - guess what the user meant.
2953 if test $# = 0; then
2954 # No further arguments. Guess the user wants to update all of them.
2955 for m4base in $m4dirs; do
2956 # Perform func_import in a subshell, so that variable values
2958 # local_gnulib_dir, avoidlist, sourcebase, m4base, docbase,
2959 # testsbase, libname, lgpl, makefile_name, libtool, macro_prefix
2960 # don't propagate from one directory to another.
2961 (func_import) || func_exit 1
2965 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
2973 if test -z "$destdir"; then
2974 func_fatal_error "please specify --dir option"
2977 test -d "$destdir" \
2978 || func_fatal_error "could not create destination directory"
2979 test -n "$auxdir" || auxdir="build-aux"
2980 func_create_testdir "$destdir" "$*"
2983 create-megatestdir )
2984 if test -z "$destdir"; then
2985 func_fatal_error "please specify --dir option"
2987 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2988 test -n "$auxdir" || auxdir="build-aux"
2989 func_create_megatestdir "$destdir" "$*"
2993 test -n "$destdir" || destdir=testdir$$
2994 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2995 test -n "$auxdir" || auxdir="build-aux"
2996 func_create_testdir "$destdir" "$*"
3000 ../configure || func_exit 1
3002 make check || func_exit 1
3003 make distclean || func_exit 1
3004 remaining=`find . -type f -print`
3005 if test -n "$remaining"; then
3006 echo "Remaining files:" $remaining 1>&2
3007 echo "gnulib-tool: *** Stop." 1>&2
3016 test -n "$destdir" || destdir=testdir$$
3017 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3018 test -n "$auxdir" || auxdir="build-aux"
3019 func_create_megatestdir "$destdir" "$*"
3027 remaining=`find . -type f -print`
3028 if test -n "$remaining"; then
3029 echo "Remaining files:" $remaining 1>&2
3030 echo "gnulib-tool: *** Stop." 1>&2
3038 extract-description )
3042 if test -n "$module"; then
3043 func_get_description "$module"
3052 if test -n "$module"; then
3053 func_get_filelist "$module"
3058 extract-dependencies )
3062 if test -n "$module"; then
3063 func_get_dependencies "$module"
3068 extract-autoconf-snippet )
3072 if test -n "$module"; then
3073 func_get_autoconf_snippet "$module"
3078 extract-automake-snippet )
3082 if test -n "$module"; then
3083 func_get_automake_snippet "$module"
3088 extract-include-directive )
3092 if test -n "$module"; then
3093 func_get_include_directive "$module"
3098 extract-link-directive )
3102 if test -n "$module"; then
3103 func_get_link_directive "$module"
3112 if test -n "$module"; then
3113 func_get_license "$module"
3118 extract-maintainer )
3122 if test -n "$module"; then
3123 func_get_maintainer "$module"
3128 extract-tests-module )
3132 if test -n "$module"; then
3133 func_get_tests_module "$module"
3139 func_fatal_error "unknown operation mode --$mode" ;;
3143 # Undo the effect of the previous 'trap' command. Some shellology:
3144 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
3145 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
3146 # exit); for the others we need to call 'exit' explicitly. The value of $? is
3147 # 128 + signal number and is set before the trap-registered command is run.
3149 trap 'func_exit $?' 1 2 3 13 15
3154 # indent-tabs-mode: nil
3155 # whitespace-check-buffer-indent: nil