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-02-01 01:52:34 $'
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:[ ]*$//
894 s/^Makefile\.am:[ ]*$//
898 s/^Maintainer:[ ]*$//
905 # func_get_description module
907 # - local_gnulib_dir from --local-dir
908 func_get_description ()
910 func_lookup_file "modules/$1"
911 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
914 # func_get_filelist module
916 # - local_gnulib_dir from --local-dir
919 func_lookup_file "modules/$1"
920 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
921 echo m4/gnulib-common.m4
922 case "$autoconf_minversion" in
925 echo m4/onceonly_2_57.m4
930 # func_get_dependencies module
932 # - local_gnulib_dir from --local-dir
933 func_get_dependencies ()
935 # ${module}-tests always implicitly depends on ${module}.
936 echo "$1" | sed -n -e 's/-tests//p'
937 # Then the explicit dependencies listed in the module description.
938 func_lookup_file "modules/$1"
939 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
942 # func_get_autoconf_snippet module
944 # - local_gnulib_dir from --local-dir
945 func_get_autoconf_snippet ()
947 func_lookup_file "modules/$1"
948 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
951 # func_get_automake_snippet module
953 # - local_gnulib_dir from --local-dir
954 func_get_automake_snippet ()
956 func_lookup_file "modules/$1"
957 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
960 # *-tests module live in tests/, not lib/.
963 # Synthesize an EXTRA_DIST augmentation.
964 sed_combine_lines='/\\$/{
971 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
972 already_mentioned_files=` \
973 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
974 | sed -e "$sed_combine_lines" \
975 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
976 all_files=`func_get_filelist $1`
977 lib_files=`for f in $all_files; do \
981 done | sed -e 's,^lib/,,'`
982 # Remove $already_mentioned_files from $lib_files.
983 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
984 extra_files=`for f in $already_mentioned_files; do echo $f; done \
985 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
986 if test -n "$extra_files"; then
987 echo "EXTRA_DIST +=" $extra_files
990 # Synthesize also an EXTRA_lib_SOURCES augmentation.
991 # This is necessary so that automake can generate the right list of
993 # A possible approach would be to use autom4te --trace of the redefined
994 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
995 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
996 # inside autoconf's built-in macros are not missed).
997 # But it's simpler and more robust to do it here, based on the file list.
998 # If some .c file exists and is not used with AC_LIBOBJ - for example,
999 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1000 # automake will generate a useless dependency; this is harmless.
1001 sed_extract_c_files='/\.c$/p'
1002 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1003 if test -n "$extra_files"; then
1004 echo "EXTRA_lib_SOURCES +=" $extra_files
1011 # func_get_include_directive module
1013 # - local_gnulib_dir from --local-dir
1014 func_get_include_directive ()
1016 func_lookup_file "modules/$1"
1017 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1018 sed -e 's/^\(["<]\)/#include \1/'
1021 # func_get_link_directive module
1023 # - local_gnulib_dir from --local-dir
1024 func_get_link_directive ()
1026 func_lookup_file "modules/$1"
1027 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1030 # func_get_license module
1032 # - local_gnulib_dir from --local-dir
1035 func_lookup_file "modules/$1"
1036 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1037 # The default is GPL.
1039 } | sed -e 's,^ *$,,' | sed -e 1q
1042 # func_get_maintainer module
1044 # - local_gnulib_dir from --local-dir
1045 func_get_maintainer ()
1047 func_lookup_file "modules/$1"
1048 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1051 # func_get_tests_module module
1053 # - local_gnulib_dir from --local-dir
1054 func_get_tests_module ()
1056 # The naming convention for tests modules is hardwired: ${module}-tests.
1057 if test -f "$gnulib_dir/modules/$1"-tests \
1058 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1059 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1064 # func_acceptable module
1065 # tests whether a module is acceptable.
1067 # - avoidlist list of modules to avoid
1070 for avoid in $avoidlist; do
1071 if test "$avoid" = "$1"; then
1078 # func_modules_transitive_closure
1080 # - local_gnulib_dir from --local-dir
1081 # - modules list of specified modules
1082 # - inctests true if tests should be included, blank otherwise
1083 # - avoidlist list of modules to avoid
1084 # - tmp pathname of a temporary directory
1086 # - modules list of modules, including dependencies
1087 func_modules_transitive_closure ()
1089 # In order to process every module only once (for speed), process an "input
1090 # list" of modules, producing an "output list" of modules. During each round,
1091 # more modules can be queued in the input list. Once a module on the input
1092 # list has been processed, it is added to the "handled list", so we can avoid
1093 # to process it again.
1095 inmodules="$modules"
1097 while test -n "$inmodules"; do
1098 inmodules_this_round="$inmodules"
1099 inmodules= # Accumulator, queue for next round
1100 for module in $inmodules_this_round; do
1102 if test -n "$module"; then
1103 if func_acceptable $module; then
1104 func_append outmodules " $module"
1105 deps=`func_get_dependencies $module`
1106 # Duplicate dependencies are harmless, but Jim wants a warning.
1107 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1108 if test -n "$duplicated_deps"; then
1109 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1111 func_append inmodules " $deps"
1112 if test -n "$inctests"; then
1113 testsmodule=`func_get_tests_module $module`
1114 if test -n "$testsmodule"; then
1115 func_append inmodules " $testsmodule"
1121 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1122 # Remove $handledmodules from $inmodules.
1123 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1124 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1126 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1127 rm -f "$tmp"/queued-modules
1130 # func_modules_add_dummy
1132 # - local_gnulib_dir from --local-dir
1133 # - modules list of modules, including dependencies
1135 # - modules list of modules, including 'dummy' if needed
1136 func_modules_add_dummy ()
1139 sed_remove_backslash_newline=':a
1146 for module in $modules; do
1147 func_verify_nontests_module
1148 if test -n "$module"; then
1149 # Extract the value of "lib_SOURCES += ...".
1150 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1151 # Ignore .h files since they are not compiled.
1154 *) have_lib_SOURCES=yes ;;
1159 # Add the dummy module, to make sure the library will be non-empty.
1160 if test -z "$have_lib_SOURCES"; then
1161 func_append modules " dummy"
1165 # func_modules_to_filelist
1167 # - local_gnulib_dir from --local-dir
1168 # - modules list of modules, including dependencies
1170 # - files list of files
1171 func_modules_to_filelist ()
1174 for module in $modules; do
1176 if test -n "$module"; then
1177 fs=`func_get_filelist $module`
1178 func_append files " $fs"
1181 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1184 # func_emit_lib_Makefile_am
1185 # emits the contents of library makefile to standard output.
1187 # - local_gnulib_dir from --local-dir
1188 # - modules list of modules, including dependencies
1189 # - libname library name
1190 # - auxdir directory relative to destdir where to place build aux files
1191 # - makefile_name from --makefile-name
1192 # - libtool true if libtool will be used, false or blank otherwise
1193 # - macro_prefix prefix of gl_LIBOBJS macros to use
1194 # - actioncmd (optional) command that will reproduce this invocation
1195 # - for_test true if creating a package for testing, false otherwise
1197 # - uses_subdirs nonempty if object files in subdirs exist
1198 func_emit_lib_Makefile_am ()
1200 # When creating an includable Makefile.am snippet, augment variables with
1201 # += instead of assigning them.
1202 if test -n "$makefile_name"; then
1207 if test "$libtool" = true; then
1210 sed_eliminate_LDFLAGS=
1214 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1217 # When creating a package for testing: Attempt to provoke failures,
1218 # especially link errors, already during "make" rather than during
1219 # "make check", because "make check" is not possible in a cross-compiling
1220 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1221 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1223 sed_transform_check_PROGRAMS=
1225 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1226 echo "## Process this file with automake to produce Makefile.in."
1227 func_emit_copyright_notice
1228 if test -n "$actioncmd"; then
1229 echo "# Reproduce by: $actioncmd"
1234 for module in $modules; do
1235 func_verify_nontests_module
1236 if test -n "$module"; then
1238 func_get_automake_snippet "$module" |
1239 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1240 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1241 sed -e "$sed_eliminate_LDFLAGS" |
1242 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1243 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1244 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' |
1245 sed -e "$sed_transform_check_PROGRAMS"
1246 if test "$module" = 'alloca'; then
1247 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1248 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1251 # Skip the contents if its entirely empty.
1252 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1253 echo "## begin gnulib module $module"
1256 echo "## end gnulib module $module"
1260 # Test whether there are some source files in subdirectories.
1261 for f in `func_get_filelist "$module"`; do
1263 lib/*/*.c) uses_subdirs=yes ;;
1269 if test -z "$makefile_name"; then
1270 # If there are source files in subdirectories, prevent collision of the
1271 # object files (example: hash.c and libxml/hash.c).
1273 if test -n "$uses_subdirs"; then
1274 subdir_options=' subdir-objects'
1276 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1279 if test -z "$makefile_name"; then
1280 echo "noinst_HEADERS ="
1281 echo "noinst_LIBRARIES ="
1282 echo "noinst_LTLIBRARIES ="
1283 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1284 # if you specify pkgdata_DATA to empty. This is a workaround.
1285 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1286 echo "pkgdata_DATA ="
1289 echo "BUILT_SOURCES ="
1292 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1293 if test -z "$makefile_name"; then
1294 echo "MOSTLYCLEANDIRS ="
1296 echo "DISTCLEANFILES ="
1297 echo "MAINTAINERCLEANFILES ="
1299 echo "AM_CPPFLAGS ="
1302 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1303 # One of the snippets already specifies an installation location for the
1304 # library. Don't confuse automake by saying it should not be installed.
1307 # By default, the generated library should not be installed.
1308 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1311 echo "${libname}_${libext}_SOURCES ="
1312 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1313 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1314 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1315 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1316 echo "EXTRA_${libname}_${libext}_SOURCES ="
1317 if test "$libtool" = true; then
1318 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1321 cat allsnippets.tmp \
1322 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1324 echo "mostlyclean-local: mostlyclean-generic"
1325 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1326 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1327 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1330 rm -f allsnippets.tmp
1333 # func_emit_tests_Makefile_am
1334 # emits the contents of tests makefile to standard output.
1336 # - local_gnulib_dir from --local-dir
1337 # - modules list of modules, including dependencies
1338 # - libname library name
1339 # - makefile_name from --makefile-name
1340 # - libtool true if libtool will be used, false or blank otherwise
1341 # - sourcebase relative directory containing lib source code
1342 # - m4base relative directory containing autoconf macros
1343 # - testsbase relative directory containing unit test code
1344 # - for_test true if creating a package for testing, false otherwise
1345 func_emit_tests_Makefile_am ()
1347 if test "$libtool" = true; then
1352 if test "$libtool" = true; then
1354 sed_eliminate_LDFLAGS=
1357 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1360 # When creating a package for testing: Attempt to provoke failures,
1361 # especially link errors, already during "make" rather than during
1362 # "make check", because "make check" is not possible in a cross-compiling
1363 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1364 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1366 sed_transform_check_PROGRAMS=
1368 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1369 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1370 echo "## Process this file with automake to produce Makefile.in."
1371 func_emit_copyright_notice
1373 # Generate dependencies here, since it eases the debugging of test failures.
1374 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1376 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1379 for module in $modules; do
1380 func_verify_tests_module
1381 if test -n "$module"; then
1383 func_get_automake_snippet "$module" |
1384 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1385 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1386 sed -e "$sed_eliminate_LDFLAGS" |
1387 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1388 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1389 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' |
1390 sed -e "$sed_transform_check_PROGRAMS"
1392 # Skip the contents if its entirely empty.
1393 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1394 echo "## begin gnulib module $module"
1397 echo "## end gnulib module $module"
1404 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1405 # variable is needed to avoid an error from automake:
1406 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1409 echo "TESTS_ENVIRONMENT ="
1410 echo "noinst_PROGRAMS ="
1411 if ! $for_test; then
1412 echo "check_PROGRAMS ="
1414 echo "noinst_HEADERS ="
1415 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1416 echo "pkgdata_DATA ="
1419 echo "BUILT_SOURCES ="
1421 echo "MOSTLYCLEANFILES = core *.stackdump"
1422 echo "MOSTLYCLEANDIRS ="
1424 echo "DISTCLEANFILES ="
1425 echo "MAINTAINERCLEANFILES ="
1427 echo "AM_CPPFLAGS = \\"
1428 echo " -I. -I\$(srcdir) \\"
1429 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1430 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1432 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1435 echo "# Clean up after Solaris cc."
1437 echo " rm -rf SunWS_cache"
1439 echo "mostlyclean-local: mostlyclean-generic"
1440 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1441 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1442 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1445 rm -f allsnippets.tmp
1448 # func_emit_initmacro_start
1449 # emits the first few statements of the gl_INIT macro to standard output.
1450 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1451 func_emit_initmacro_start ()
1453 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
1454 # platform-dependent object files in ${macro_prefix}_LIBOBJS instead of
1455 # LIBOBJS. The purpose is to allow several gnulib instantiations under
1456 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
1458 # Furthermore it avoids an automake error like this when a Makefile.am
1459 # that uses pieces of gnulib also uses $(LIBOBJ):
1460 # automatically discovered file `error.c' should not be explicitly mentioned
1461 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix}_LIBOBJ]))"
1462 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix}_REPLACE_FUNCS]))"
1463 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
1464 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
1465 # automatically discovered file `error.c' should not be explicitly mentioned
1466 # We let automake know about the files to be distributed through the
1467 # EXTRA_lib_SOURCES variable.
1468 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix}_LIBSOURCES]))"
1471 # func_emit_initmacro_end
1472 # emits the last few statements of the gl_INIT macro to standard output.
1473 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1474 func_emit_initmacro_end ()
1476 echo " m4_popdef([AC_LIBSOURCES])"
1477 echo " m4_popdef([AC_REPLACE_FUNCS])"
1478 echo " m4_popdef([AC_LIBOBJ])"
1479 echo " AC_CONFIG_COMMANDS_PRE(["
1480 echo " ${macro_prefix}_libobjs="
1481 echo " ${macro_prefix}_ltlibobjs="
1482 echo " if test -n \"\$${macro_prefix}_LIBOBJS\"; then"
1483 echo " # Remove the extension."
1484 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
1485 echo " for i in \`for i in \$${macro_prefix}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
1486 echo " ${macro_prefix}_libobjs=\"\$${macro_prefix}_libobjs \$i.\$ac_objext\""
1487 echo " ${macro_prefix}_ltlibobjs=\"\$${macro_prefix}_ltlibobjs \$i.lo\""
1490 echo " AC_SUBST([${macro_prefix}_LIBOBJS], [\$${macro_prefix}_libobjs])"
1491 echo " AC_SUBST([${macro_prefix}_LTLIBOBJS], [\$${macro_prefix}_ltlibobjs])"
1495 # func_emit_initmacro_done
1496 # emits a few statements after the gl_INIT macro to standard output.
1497 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1498 func_emit_initmacro_done ()
1501 echo "# Like AC_LIBOBJ, except that the module name goes"
1502 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1503 echo "AC_DEFUN([${macro_prefix}_LIBOBJ],"
1504 echo " [${macro_prefix}_LIBOBJS=\"\$${macro_prefix}_LIBOBJS \$1.\$ac_objext\"])"
1506 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
1507 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1508 echo "AC_DEFUN([${macro_prefix}_REPLACE_FUNCS],"
1509 echo " [AC_CHECK_FUNCS([\$1], , [${macro_prefix}_LIBOBJ(\$ac_func)])])"
1511 echo "# Like AC_LIBSOURCES, except that it does nothing."
1512 echo "# We rely on EXTRA_lib..._SOURCES instead."
1513 echo "AC_DEFUN([${macro_prefix}_LIBSOURCES],"
1517 # func_import modules
1518 # Uses also the variables
1519 # - destdir target directory
1520 # - local_gnulib_dir from --local-dir
1521 # - libname library name
1522 # - sourcebase directory relative to destdir where to place source code
1523 # - m4base directory relative to destdir where to place *.m4 macros
1524 # - docbase directory relative to destdir where to place doc files
1525 # - testsbase directory relative to destdir where to place unit test code
1526 # - auxdir directory relative to destdir where to place build aux files
1527 # - inctests true if --with-tests was given, blank otherwise
1528 # - avoidlist list of modules to avoid, from --avoid
1529 # - lgpl true if library's license shall be LGPL, blank otherwise
1530 # - makefile_name from --makefile-name
1531 # - libtool true if --libtool was given, false if --no-libtool was
1532 # given, blank otherwise
1533 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1534 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1535 # - autoconf_minversion minimum supported autoconf version
1536 # - doit : if actions shall be executed, false if only to be printed
1537 # - symbolic true if files should be symlinked, copied otherwise
1538 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1542 # Get the cached settings.
1543 cached_local_gnulib_dir=
1544 cached_specified_modules=
1552 cached_makefile_name=
1554 cached_macro_prefix=
1556 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1557 cached_libtool=false
1563 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
1566 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1569 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1572 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1575 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1578 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1581 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1584 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1587 s,^.*$,cached_lgpl=true,p
1589 /gl_MAKEFILE_NAME(/ {
1590 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
1593 s,^.*$,cached_libtool=true,p
1595 /gl_MACRO_PREFIX(/ {
1596 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
1598 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
1599 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1604 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
1605 s,^.*$,cached_files=",p
1617 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1621 # Merge the cached settings with the specified ones.
1622 # The m4base must be the same as expected from the pathname.
1623 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1624 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1626 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
1627 # is relative to $destdir, whereas the one we use is relative to . or absolute.
1628 if test -z "$local_gnulib_dir"; then
1629 if test -n "$cached_local_gnulib_dir"; then
1632 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1634 case "$cached_local_gnulib_dir" in
1636 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1638 func_relconcat "$destdir" "$cached_local_gnulib_dir"
1639 local_gnulib_dir="$relconcat" ;;
1644 # Append the cached and the specified module names. So that
1645 # "gnulib-tool --import foo" means to add the module foo.
1646 specified_modules="$cached_specified_modules $1"
1647 # Append the cached and the specified avoidlist. This is probably better
1648 # than dropping the cached one when --avoid is specified at least once.
1649 avoidlist=`echo $cached_avoidlist $avoidlist`
1650 # The sourcebase defaults to the cached one.
1651 if test -z "$sourcebase"; then
1652 sourcebase="$cached_sourcebase"
1653 if test -z "$sourcebase"; then
1654 func_fatal_error "missing --source-base option"
1657 # The docbase defaults to the cached one.
1658 if test -z "$docbase"; then
1659 docbase="$cached_docbase"
1660 if test -z "$docbase"; then
1661 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."
1664 # The testsbase defaults to the cached one.
1665 if test -z "$testsbase"; then
1666 testsbase="$cached_testsbase"
1667 if test -z "$testsbase"; then
1668 func_fatal_error "missing --tests-base option"
1671 # The libname defaults to the cached one.
1672 if test -z "$supplied_libname"; then
1673 libname="$cached_libname"
1674 if test -z "$libname"; then
1675 func_fatal_error "missing --lib option"
1678 # Require LGPL if specified either way.
1679 if test -z "$lgpl"; then
1682 # The makefile_name defaults to the cached one.
1683 if test -z "$makefile_name"; then
1684 makefile_name="$cached_makefile_name"
1686 # Use libtool if specified either way, or if guessed.
1687 if test -z "$libtool"; then
1688 if test -n "$cached_m4base"; then
1689 libtool="$cached_libtool"
1691 libtool="$guessed_libtool"
1694 # The macro_prefix defaults to the cached one.
1695 if test -z "$macro_prefix"; then
1696 macro_prefix="$cached_macro_prefix"
1697 if test -z "$macro_prefix"; then
1698 func_fatal_error "missing --macro-prefix option"
1702 # Canonicalize the list of specified modules.
1703 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
1705 # Determine final module list.
1706 modules="$specified_modules"
1707 func_modules_transitive_closure
1708 echo "Module list with included dependencies:"
1709 echo "$modules" | sed -e 's/^/ /'
1711 # Add the dummy module if needed.
1712 func_modules_add_dummy
1714 # If --lgpl, verify that the licenses of modules are compatible.
1715 if test -n "$lgpl"; then
1716 for module in $modules; do
1717 license=`func_get_license $module`
1719 LGPL | 'GPLed build tool') ;;
1720 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
1721 *) func_fatal_error "incompatible license on module $module: $license" ;;
1726 # Determine script to apply to imported library files.
1727 sed_transform_lib_file=
1728 for module in $modules; do
1729 if test $module = config-h; then
1730 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
1731 sed_transform_lib_file=$sed_transform_lib_file'
1732 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
1737 if test -n "$lgpl"; then
1739 sed_transform_lib_file=$sed_transform_lib_file'
1740 s/GNU General/GNU Lesser General/g
1741 s/version 2\([ ,]\)/version 2.1\1/g
1745 # Determine final file list.
1746 func_modules_to_filelist
1748 echo "$files" | sed -e 's/^/ /'
1751 || func_fatal_error "refusing to do nothing"
1753 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
1754 new_files="$files m4/gnulib-tool.m4"
1755 old_files="$cached_files"
1756 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
1757 func_append old_files " m4/gnulib-tool.m4"
1760 sed_rewrite_old_files="\
1761 s,^build-aux/,$auxdir/,
1762 s,^doc/,$cached_docbase/,
1763 s,^lib/,$cached_sourcebase/,
1764 s,^m4/,$cached_m4base/,
1765 s,^tests/,$cached_testsbase/,"
1766 sed_rewrite_new_files="\
1767 s,^build-aux/,$auxdir/,
1769 s,^lib/,$sourcebase/,
1771 s,^tests/,$testsbase/,"
1773 # Create directories.
1774 { echo "$sourcebase"
1776 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
1777 if test -n "$docfiles"; then
1780 if test -n "$inctests"; then
1784 for f in $files; do echo $f; done \
1785 | sed -e "$sed_rewrite_new_files" \
1786 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
1789 { # Rearrange file descriptors. Needed because "while ... done < ..."
1790 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1791 exec 5<&0 < "$tmp"/dirs
1793 if test ! -d "$destdir/$d"; then
1795 echo "Creating directory $destdir/$d"
1796 mkdir -p "$destdir/$d" || func_fatal_error "failed"
1798 echo "Create directory $destdir/$d"
1805 # func_dest_tmpfilename file
1806 # determines the name of a temporary file (file is relative to destdir).
1808 # - tmpfile absolute filename of the temporary file
1809 func_dest_tmpfilename ()
1812 # Put the new contents of $file in a file in the same directory (needed
1813 # to guarantee that an 'mv' to "$destdir/$file" works).
1814 tmpfile="$destdir/$1.tmp"
1816 # Put the new contents of $file in a file in a temporary directory
1817 # (because the directory of "$file" might not exist).
1818 tmpfile="$tmp"/`basename "$1"`.tmp
1822 # Copy files or make symbolic links. Remove obsolete files.
1824 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1825 # representing the files according to the last gnulib-tool invocation.
1826 for f in $old_files; do echo $f; done \
1827 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
1830 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1831 # representing the files after this gnulib-tool invocation.
1832 for f in $new_files; do echo $f; done \
1833 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
1836 # First the files that are in old-files, but not in new-files:
1837 sed_take_first_column='s,'"$delimiter"'.*,,'
1838 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
1839 # Remove the file. Do nothing if the user already removed it.
1840 if test -f "$destdir/$g"; then
1842 echo "Removing file $g (backup in ${g}~)"
1843 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1845 echo "Remove file $g (backup in ${g}~)"
1849 # func_add_or_update handles a file that ought to be present afterwards.
1851 # - f the original file name
1852 # - g the rewritten file name
1853 # - already_present nonempty if the file already exists, empty otherwise
1854 func_add_or_update ()
1856 func_dest_tmpfilename "$g"
1857 func_lookup_file "$f"
1858 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
1859 if test -n "$sed_transform_lib_file"; then
1862 sed -e "$sed_transform_lib_file" \
1863 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
1867 if test -f "$destdir/$g"; then
1868 # The file already exists.
1869 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1870 : # The file has not changed.
1874 if test -n "$already_present"; then
1875 echo "Updating file $g (backup in ${g}~)"
1877 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
1879 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1880 if { test -n "$symbolic" \
1881 || { test -n "$lsymbolic" \
1882 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1883 && test -z "$lookedup_tmp" \
1884 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1885 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1887 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1890 if test -n "$already_present"; then
1891 echo "Update file $g (backup in ${g}~)"
1893 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
1899 # Don't protest if the file should be there but isn't: it happens
1900 # frequently that developers don't put autogenerated files into CVS.
1902 echo "Copying file $g"
1903 if { test -n "$symbolic" \
1904 || { test -n "$lsymbolic" \
1905 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1906 && test -z "$lookedup_tmp" \
1907 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1908 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1910 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1918 # Then the files that are in new-files, but not in old-files:
1919 sed_take_last_column='s,^.*'"$delimiter"',,'
1921 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
1922 | sed -e "$sed_take_last_column" \
1923 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
1924 { # Rearrange file descriptors. Needed because "while ... done < ..."
1925 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1926 exec 5<&0 < "$tmp"/added-files
1932 # Then the files that are in new-files and in old-files:
1933 already_present=true
1934 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
1935 | sed -e "$sed_take_last_column" \
1936 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
1937 { # Rearrange file descriptors. Needed because "while ... done < ..."
1938 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1939 exec 5<&0 < "$tmp"/kept-files
1946 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
1947 actioncmd="gnulib-tool --import"
1948 func_append actioncmd " --dir=$destdir"
1949 if test -n "$local_gnulib_dir"; then
1950 func_append actioncmd " --local-dir=$local_gnulib_dir"
1952 func_append actioncmd " --lib=$libname"
1953 func_append actioncmd " --source-base=$sourcebase"
1954 func_append actioncmd " --m4-base=$m4base"
1955 func_append actioncmd " --doc-base=$docbase"
1956 func_append actioncmd " --aux-dir=$auxdir"
1957 for module in $avoidlist; do
1958 func_append actioncmd " --avoid=$module"
1960 if test -n "$lgpl"; then
1961 func_append actioncmd " --lgpl"
1963 if test -n "$makefile_name"; then
1964 func_append actioncmd " --makefile-name=$makefile_name"
1966 if test "$libtool" = true; then
1967 func_append actioncmd " --libtool"
1969 func_append actioncmd " --no-libtool"
1971 func_append actioncmd " --macro-prefix=$macro_prefix"
1972 func_append actioncmd " `echo $specified_modules`"
1974 # Default the makefile name to Makefile.am.
1975 if test -n "$makefile_name"; then
1976 makefile_am=$makefile_name
1978 makefile_am=Makefile.am
1981 # Create normal Makefile.ams.
1984 # Create library makefile.
1985 func_dest_tmpfilename $sourcebase/$makefile_am
1986 func_emit_lib_Makefile_am > "$tmpfile"
1987 if test -f "$destdir"/$sourcebase/$makefile_am; then
1988 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
1992 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
1993 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
1994 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
1996 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2002 echo "Creating $sourcebase/$makefile_am"
2003 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2005 echo "Create $sourcebase/$makefile_am"
2010 # Create m4/gnulib-cache.m4.
2011 func_dest_tmpfilename $m4base/gnulib-cache.m4
2013 func_emit_copyright_notice
2015 echo "# This file represents the specification of how gnulib-tool is used."
2016 echo "# It acts as a cache: It is written and read by gnulib-tool."
2017 echo "# In projects using CVS, this file is meant to be stored in CVS,"
2018 echo "# like the configure.ac and various Makefile.am files."
2021 echo "# Specification in the form of a command-line invocation:"
2024 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
2025 # Store the local_gnulib_dir relative to destdir.
2026 case "$local_gnulib_dir" in
2028 relative_local_gnulib_dir="$local_gnulib_dir" ;;
2031 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
2033 # destdir, local_gnulib_dir are both relative.
2034 func_relativize "$destdir" "$local_gnulib_dir"
2035 relative_local_gnulib_dir="$reldir" ;;
2038 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
2039 echo "gl_MODULES(["`echo $specified_modules`"])"
2040 echo "gl_AVOID([$avoidlist])"
2041 echo "gl_SOURCE_BASE([$sourcebase])"
2042 echo "gl_M4_BASE([$m4base])"
2043 echo "gl_DOC_BASE([$docbase])"
2044 echo "gl_TESTS_BASE([$testsbase])"
2045 echo "gl_LIB([$libname])"
2046 test -z "$lgpl" || echo "gl_LGPL"
2047 echo "gl_MAKEFILE_NAME([$makefile_name])"
2048 if test "$libtool" = true; then
2051 echo "gl_MACRO_PREFIX([$macro_prefix])"
2053 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2054 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2058 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2059 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2060 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2062 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2066 echo "# gnulib-cache.m4 ends here"
2073 echo "Creating $m4base/gnulib-cache.m4"
2074 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2076 echo "Create $m4base/gnulib-cache.m4"
2082 # Create m4/gnulib-comp.m4.
2083 func_dest_tmpfilename $m4base/gnulib-comp.m4
2085 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2086 func_emit_copyright_notice
2088 echo "# This file represents the compiled summary of the specification in"
2089 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2090 echo "# to be invoked from configure.ac."
2091 echo "# In projects using CVS, this file can be treated like other built files."
2094 echo "# This macro should be invoked from $configure_ac, in the section"
2095 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2096 echo "# any checks for libraries, header files, types and library functions."
2097 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2099 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2100 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2101 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2102 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2103 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2104 if test -n "$uses_subdirs"; then
2105 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2107 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2108 echo " AC_REQUIRE([AC_GNU_SOURCE])"
2110 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2111 echo " AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])"
2113 if grep gl_LOCK "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2114 echo " AC_REQUIRE([gl_LOCK_EARLY])"
2118 echo "# This macro should be invoked from $configure_ac, in the section"
2119 echo "# \"Check for header files, types and library functions\"."
2120 echo "AC_DEFUN([${macro_prefix}_INIT],"
2122 func_emit_initmacro_start
2123 if test "$libtool" = true; then
2124 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2125 echo " gl_cond_libtool=true"
2127 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2128 echo " gl_cond_libtool=false"
2130 echo " gl_ltlibdeps="
2132 echo " gl_source_base='$sourcebase'"
2133 if test "$auxdir" != "build-aux"; then
2134 sed_replace_build_aux='
2136 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2137 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2140 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2142 sed_replace_build_aux=
2144 for module in $modules; do
2146 if test -n "$module"; then
2147 func_get_autoconf_snippet "$module" \
2148 | sed -e '/^$/d;' -e 's/^/ /' \
2149 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
2150 -e "$sed_replace_build_aux"
2151 if test "$module" = 'alloca' && test "$libtool" = true; then
2152 echo 'changequote(,)dnl'
2153 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
2154 echo 'changequote([, ])dnl'
2155 echo 'AC_SUBST([LTALLOCA])'
2159 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2160 # created using libtool, because libtool already handles the dependencies.
2161 if test "$libtool" != true; then
2162 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z' 'A-Z'`
2163 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2164 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2165 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2166 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2168 func_emit_initmacro_end
2170 func_emit_initmacro_done
2172 echo "# This macro records the list of files which have been installed by"
2173 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
2174 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
2175 echo "$files" | sed -e 's,^, ,'
2178 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2179 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
2183 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2184 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
2185 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2187 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2191 echo "# gnulib-comp.m4 ends here"
2198 echo "Creating $m4base/gnulib-comp.m4"
2199 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2201 echo "Create $m4base/gnulib-comp.m4"
2207 if test -n "$inctests"; then
2208 # Create tests makefile.
2209 func_dest_tmpfilename $testsbase/$makefile_am
2210 func_emit_tests_Makefile_am > "$tmpfile"
2211 if test -f "$destdir"/$testsbase/$makefile_am; then
2212 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
2216 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2217 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
2218 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2220 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2226 echo "Creating $testsbase/$makefile_am"
2227 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2229 echo "Create $testsbase/$makefile_am"
2237 echo "You may need to add #include directives for the following .h files."
2238 # Intersect $specified_modules and $modules
2239 # (since $specified_modules is not necessarily of subset of $modules - some
2240 # may have been skipped through --avoid, and since the elements of $modules
2241 # but not in $specified_modules can go away without explicit notice - through
2242 # changes in the module dependencies).
2243 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
2244 echo "$modules" > "$tmp"/modules2 # also a sorted list, one module per line
2245 # First the #include <...> directives without #ifs, sorted for convenience,
2246 # then the #include "..." directives without #ifs, sorted for convenience,
2247 # then the #include directives that are surrounded by #ifs. Not sorted.
2248 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
2249 include_directive=`func_get_include_directive "$module"`
2250 case "$nl$include_directive" in
2252 echo "$include_directive" 1>&5
2255 echo "$include_directive" | grep -v 'include "' 1>&6
2256 echo "$include_directive" | grep 'include "' 1>&7
2259 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
2261 LC_ALL=C sort -u "$tmp"/include-angles
2262 LC_ALL=C sort -u "$tmp"/include-quotes
2263 cat "$tmp"/include-if
2264 ) | sed -e '/^$/d' -e 's/^/ /'
2265 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
2267 for module in $modules; do
2268 func_get_link_directive "$module"
2270 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
2271 if test `wc -l < "$tmp"/link` != 0; then
2273 echo "You may need to use the following Makefile variables when linking."
2274 echo "Use them in <program>_LDADD when linking a program, or"
2275 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
2281 echo "Don't forget to"
2282 if test "$makefile_am" = Makefile.am; then
2283 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2285 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
2287 if test -n "$inctests"; then
2288 if test "$makefile_am" = Makefile.am; then
2289 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2291 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
2294 if test "$makefile_am" = Makefile.am; then
2295 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
2296 sourcebase_base=`basename "$sourcebase"`
2297 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
2299 if test -n "$inctests"; then
2300 if test "$makefile_am" = Makefile.am; then
2301 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
2302 testsbase_base=`basename "$testsbase"`
2303 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
2306 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
2307 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
2308 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
2311 # func_create_testdir testdir modules
2313 # - local_gnulib_dir from --local-dir
2314 # - auxdir directory relative to destdir where to place build aux files
2315 func_create_testdir ()
2319 if test -z "$modules"; then
2320 # All modules together.
2321 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2322 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2323 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
2324 modules=`func_all_modules`
2325 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
2327 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
2329 # Check that the license of every module is consistent with the license of
2331 saved_modules="$modules"
2332 saved_inctests="$inctests"
2333 # When computing transitive closures, don't consider $module to depend on
2334 # $module-tests. Need this becauses tests are implicitly GPL and may depend
2335 # on GPL modules - therefore we don't want a warning in this case.
2337 for requested_module in $saved_modules; do
2338 requested_license=`func_get_license "$requested_module"`
2339 if test "$requested_license" != GPL; then
2340 # Here we use func_modules_transitive_closure, not just
2341 # func_get_dependencies, so that we also detect weird situations like
2342 # an LGPL module which depends on a GPLed build tool module which depends
2344 modules="$requested_module"
2345 func_modules_transitive_closure
2346 for module in $modules; do
2347 license=`func_get_license "$module"`
2349 LGPL | 'GPLed build tool') ;;
2350 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2351 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
2356 modules="$saved_modules"
2357 inctests="$saved_inctests"
2359 # Subdirectory names.
2366 # Determine final module list.
2367 func_modules_transitive_closure
2368 echo "Module list with included dependencies:"
2369 echo "$modules" | sed -e 's/^/ /'
2371 # Add the dummy module if needed.
2372 func_modules_add_dummy
2374 # Determine final file list.
2375 func_modules_to_filelist
2377 echo "$files" | sed -e 's/^/ /'
2379 sed_rewrite_files="\
2380 s,^build-aux/,$auxdir/,
2382 s,^lib/,$sourcebase/,
2384 s,^tests/,$testsbase/,"
2386 # Create directories.
2387 for f in $files; do echo $f; done \
2388 | sed -e "$sed_rewrite_files" \
2389 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2390 | LC_ALL=C sort -u \
2392 { # Rearrange file descriptors. Needed because "while ... done < ..."
2393 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2394 exec 5<&0 < "$tmp"/dirs
2396 mkdir -p "$testdir/$d"
2401 # Copy files or make symbolic links.
2403 for f in $files; do echo $f; done \
2404 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
2407 { # Rearrange file descriptors. Needed because "while ... done < ..."
2408 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2409 exec 5<&0 < "$tmp"/files
2411 func_lookup_file "$f"
2412 if test -n "$lookedup_tmp"; then
2413 cp -p "$lookedup_file" "$testdir/$g"
2415 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
2416 if { test -n "$symbolic" \
2417 || { test -n "$lsymbolic" \
2418 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
2419 func_ln "$lookedup_file" "$testdir/$g"
2421 cp -p "$lookedup_file" "$testdir/$g"
2428 # Create Makefile.ams that are for testing.
2431 # Create $sourcebase/Makefile.am.
2432 mkdir -p "$testdir/$sourcebase"
2433 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
2435 # Create $m4base/Makefile.am.
2436 mkdir -p "$testdir/$m4base"
2437 (echo "## Process this file with automake to produce Makefile.in."
2443 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
2446 ) > "$testdir/$m4base/Makefile.am"
2448 subdirs="$sourcebase $m4base"
2449 subdirs_with_configure_ac=""
2451 if false && test -f "$testdir"/$m4base/gettext.m4; then
2452 # Avoid stupid error message from automake:
2453 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
2454 mkdir -p "$testdir/po"
2455 (echo "## Process this file with automake to produce Makefile.in."
2456 ) > "$testdir/po/Makefile.am"
2457 func_append subdirs " po"
2460 if test -n "$inctests"; then
2461 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
2462 # Create $testsbase/Makefile.am.
2463 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
2464 # Create $testsbase/configure.ac.
2465 (echo "# Process this file with autoconf to produce a configure script."
2466 echo "AC_INIT([dummy], [0])"
2467 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
2468 echo "AM_INIT_AUTOMAKE"
2470 echo "AM_CONFIG_HEADER([config.h])"
2473 echo "AC_PROG_INSTALL"
2474 echo "AC_PROG_MAKE_SET"
2475 echo "AC_PROG_RANLIB"
2477 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2478 echo "AC_GNU_SOURCE"
2481 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2482 echo "gl_USE_SYSTEM_EXTENSIONS"
2485 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2486 echo "gl_LOCK_EARLY"
2489 if test "$libtool" = true; then
2490 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2491 echo "gl_cond_libtool=true"
2493 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2494 echo "gl_cond_libtool=false"
2496 echo "gl_ltlibdeps="
2498 # Wrap the set of autoconf snippets into an autoconf macro that is then
2499 # invoked. This is needed because autoconf does not support AC_REQUIRE
2501 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2502 # but we want the AC_REQUIRE to have its normal meaning (provide one
2503 # expansion of the required macro before the current point, and only one
2505 echo "AC_DEFUN([gl_INIT], ["
2506 func_emit_initmacro_start
2507 sed_replace_build_aux='
2509 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2510 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
2513 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2514 # We don't have explicit ordering constraints between the various
2515 # autoconf snippets. It's cleanest to put those of the library before
2516 # those of the tests.
2517 echo "gl_source_base='../$sourcebase'"
2518 for module in $modules; do
2519 func_verify_nontests_module
2520 if test -n "$module"; then
2521 func_get_autoconf_snippet "$module" \
2522 | sed -e "$sed_replace_build_aux"
2525 echo "gl_source_base='.'"
2526 for module in $modules; do
2527 func_verify_tests_module
2528 if test -n "$module"; then
2529 func_get_autoconf_snippet "$module" \
2530 | sed -e "$sed_replace_build_aux"
2533 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2534 # created using libtool, because libtool already handles the dependencies.
2535 if test "$libtool" != true; then
2536 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z' 'A-Z'`
2537 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2538 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2539 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2540 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2542 func_emit_initmacro_end
2544 func_emit_initmacro_done
2548 # Usually $testsbase/config.h will be a superset of config.h. Verify this
2549 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
2550 echo "AH_TOP([#include \"../config.h\"])"
2552 echo "AC_OUTPUT([Makefile])"
2553 ) > "$testdir/$testsbase/configure.ac"
2554 func_append subdirs " $testsbase"
2555 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
2558 # Create Makefile.am.
2559 (echo "## Process this file with automake to produce Makefile.in."
2561 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2563 echo "SUBDIRS = $subdirs"
2565 echo "ACLOCAL_AMFLAGS = -I $m4base"
2566 ) > "$testdir/Makefile.am"
2568 # Create configure.ac.
2569 (echo "# Process this file with autoconf to produce a configure script."
2570 echo "AC_INIT([dummy], [0])"
2571 if test "$auxdir" != "."; then
2572 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2574 echo "AM_INIT_AUTOMAKE"
2576 echo "AM_CONFIG_HEADER([config.h])"
2579 echo "AC_PROG_INSTALL"
2580 echo "AC_PROG_MAKE_SET"
2582 echo "# For autobuild."
2583 echo "AC_CANONICAL_BUILD"
2584 echo "AC_CANONICAL_HOST"
2586 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2587 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2588 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2589 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2591 echo "AC_PROG_RANLIB"
2593 if test -n "$uses_subdirs"; then
2594 echo "AM_PROG_CC_C_O"
2597 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2598 echo "AC_GNU_SOURCE"
2601 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2602 echo "gl_USE_SYSTEM_EXTENSIONS"
2605 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2606 echo "gl_LOCK_EARLY"
2609 if test "$libtool" = true; then
2610 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2611 echo "gl_cond_libtool=true"
2613 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2614 echo "gl_cond_libtool=false"
2616 echo "gl_ltlibdeps="
2618 echo "gl_source_base='$sourcebase'"
2619 # Wrap the set of autoconf snippets into an autoconf macro that is then
2620 # invoked. This is needed because autoconf does not support AC_REQUIRE
2622 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2623 # but we want the AC_REQUIRE to have its normal meaning (provide one
2624 # expansion of the required macro before the current point, and only one
2626 echo "AC_DEFUN([gl_INIT], ["
2627 func_emit_initmacro_start
2628 if test "$auxdir" != "build-aux"; then
2629 sed_replace_build_aux='
2631 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2632 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2635 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2637 sed_replace_build_aux=
2639 for module in $modules; do
2640 func_verify_nontests_module
2641 if test -n "$module"; then
2642 func_get_autoconf_snippet "$module" \
2643 | sed -e "$sed_replace_build_aux"
2646 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2647 # created using libtool, because libtool already handles the dependencies.
2648 if test "$libtool" != true; then
2649 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z' 'A-Z'`
2650 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2651 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2652 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2653 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2655 func_emit_initmacro_end
2657 func_emit_initmacro_done
2661 if test -n "$subdirs_with_configure_ac"; then
2662 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
2664 makefiles="Makefile"
2665 for d in $subdirs; do
2666 # For subdirs that have a configure.ac by their own, it's the subdir's
2667 # configure.ac which creates the subdir's Makefile.am, not this one.
2668 case " $subdirs_with_configure_ac " in
2670 *) func_append makefiles " $d/Makefile" ;;
2673 echo "AC_OUTPUT([$makefiles])"
2674 ) > "$testdir/configure.ac"
2676 # Create autogenerated files.
2678 # Do not use "${AUTORECONF} --force --install", because it may invoke
2679 # autopoint, which brings in older versions of some of our .m4 files.
2680 if test -f $m4base/gettext.m4; then
2681 echo "executing ${AUTOPOINT} --force"
2682 ${AUTOPOINT} --force || func_exit 1
2683 for f in $m4base/*.m4~; do
2684 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2687 echo "executing ${ACLOCAL} -I $m4base"
2688 ${ACLOCAL} -I $m4base || func_exit 1
2689 if ! test -d build-aux; then
2690 echo "executing mkdir build-aux"
2691 mkdir build-aux || func_exit 1
2693 echo "executing ${AUTOCONF}"
2694 ${AUTOCONF} || func_exit 1
2695 echo "executing ${AUTOHEADER}"
2696 ${AUTOHEADER} || func_exit 1
2697 echo "executing ${AUTOMAKE} --add-missing --copy"
2698 ${AUTOMAKE} --add-missing --copy || func_exit 1
2700 if test -n "$inctests"; then
2701 # Create autogenerated files.
2702 (cd "$testdir/$testsbase" || func_exit 1
2703 # Do not use "${AUTORECONF} --force --install", because it may invoke
2704 # autopoint, which brings in older versions of some of our .m4 files.
2705 if test -f ../$m4base/gettext.m4; then
2706 echo "executing ${AUTOPOINT} --force"
2707 ${AUTOPOINT} --force || func_exit 1
2708 for f in ../$m4base/*.m4~; do
2709 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2712 echo "executing ${ACLOCAL} -I ../$m4base"
2713 ${ACLOCAL} -I ../$m4base || func_exit 1
2714 if ! test -d ../build-aux; then
2715 echo "executing mkdir ../build-aux"
2718 echo "executing ${AUTOCONF}"
2719 ${AUTOCONF} || func_exit 1
2720 echo "executing ${AUTOHEADER}"
2721 ${AUTOHEADER} || func_exit 1
2722 echo "executing ${AUTOMAKE} --add-missing --copy"
2723 ${AUTOMAKE} --add-missing --copy || func_exit 1
2726 # Need to run configure and make once, to create built files that are to be
2727 # distributed (such as getdate.c).
2728 # Extract the value of "CLEANFILES += ...".
2729 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
2730 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
2731 cleaned_files=" "`for file in $cleaned_files; do echo "$file"; done`" "
2732 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
2733 # such $(FOO_H) because they don't refer to distributed files.
2734 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
2735 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
2736 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
2737 | sed -e "$sed_remove_make_variables"`
2738 distributed_built_sources=`for file in $built_sources; do
2739 case "$cleaned_files" in
2744 if test -n "$distributed_built_sources"; then
2746 ./configure || func_exit 1
2748 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
2749 make built_sources || func_exit 1
2751 make distclean || func_exit 1
2756 # func_create_megatestdir megatestdir allmodules
2758 # - local_gnulib_dir from --local-dir
2759 # - auxdir directory relative to destdir where to place build aux files
2760 func_create_megatestdir ()
2764 if test -z "$allmodules"; then
2765 allmodules=`func_all_modules`
2769 # First, all modules one by one.
2770 for onemodule in $allmodules; do
2771 func_create_testdir "$megatestdir/$onemodule" $onemodule
2772 func_append megasubdirs "$onemodule "
2774 # Then, all modules all together.
2775 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2776 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2777 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
2778 func_create_testdir "$megatestdir/ALL" "$allmodules"
2779 func_append megasubdirs "ALL"
2781 # Create Makefile.am.
2782 (echo "## Process this file with automake to produce Makefile.in."
2784 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2786 echo "SUBDIRS = $megasubdirs"
2787 ) > "$megatestdir/Makefile.am"
2789 # Create configure.ac.
2790 (echo "# Process this file with autoconf to produce a configure script."
2791 echo "AC_INIT([dummy], [0])"
2792 if test "$auxdir" != "."; then
2793 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2795 echo "AM_INIT_AUTOMAKE"
2797 echo "AC_PROG_MAKE_SET"
2799 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
2800 echo "AC_OUTPUT([Makefile])"
2801 ) > "$megatestdir/configure.ac"
2803 # Create autogenerated files.
2805 # Do not use "${AUTORECONF} --install", because autoreconf operates
2806 # recursively, but the subdirectories are already finished, therefore
2807 # calling autoreconf here would only waste lots of CPU time.
2808 echo "executing ${ACLOCAL}"
2809 ${ACLOCAL} || func_exit 1
2810 echo "executing mkdir build-aux"
2812 echo "executing ${AUTOCONF}"
2813 ${AUTOCONF} || func_exit 1
2814 echo "executing ${AUTOMAKE} --add-missing --copy"
2815 ${AUTOMAKE} --add-missing --copy || func_exit 1
2821 func_fatal_error "no mode specified" ;;
2830 if test -z "$destdir"; then
2833 test -d "$destdir" \
2834 || func_fatal_error "destination directory does not exist: $destdir"
2836 # Prefer configure.ac to configure.in.
2837 if test -f "$destdir"/configure.ac; then
2838 configure_ac="$destdir/configure.ac"
2840 if test -f "$destdir"/configure.in; then
2841 configure_ac="$destdir/configure.in"
2843 func_fatal_error "cannot find $destdir/configure.ac"
2847 # Analyze configure.ac.
2849 guessed_libtool=false
2854 /AC_CONFIG_AUX_DIR/ {
2855 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
2857 /A[CM]_PROG_LIBTOOL/ {
2858 s,^.*$,guessed_libtool=true,p
2860 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
2862 if test -z "$auxdir"; then
2863 auxdir="$guessed_auxdir"
2866 # Determine where to apply func_import.
2867 if test -n "$m4base"; then
2868 # Apply func_import to a particular gnulib directory.
2869 # Any number of additional modules can be given.
2870 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
2871 # First use of gnulib in the given m4base.
2872 test -n "$supplied_libname" || supplied_libname=true
2873 test -n "$sourcebase" || sourcebase="lib"
2874 test -n "$docbase" || docbase="doc"
2875 test -n "$testsbase" || testsbase="tests"
2876 test -n "$macro_prefix" || macro_prefix="gl"
2880 # Apply func_import to all gnulib directories.
2881 # To get this list of directories, look at Makefile.am. (Not at
2882 # configure, because it may be omitted from CVS. Also, don't run
2883 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
2886 if test -f "$destdir"/Makefile.am; then
2887 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
2889 for arg in $aclocal_amflags; do
2890 if test -n "$m4dir_is_next"; then
2891 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
2895 if test -f "$destdir/$arg"/gnulib-cache.m4; then
2896 func_append m4dirs " $arg"
2897 m4dirs_count=`expr $m4dirs_count + 1`
2903 if test "X$arg" = "X-I"; then
2911 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
2912 if test -f "$destdir"/aclocal.m4; then
2913 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
2914 sedexpr2='s,^[^/]*$,.,'
2915 sedexpr3='s,/[^/]*$,,'
2916 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
2917 m4dirs_count=`echo "$m4dirs" | wc -l`
2920 if test $m4dirs_count = 0; then
2921 # First use of gnulib in a package.
2922 # Any number of additional modules can be given.
2923 test -n "$supplied_libname" || supplied_libname=true
2924 test -n "$sourcebase" || sourcebase="lib"
2926 test -n "$docbase" || docbase="doc"
2927 test -n "$testsbase" || testsbase="tests"
2928 test -n "$macro_prefix" || macro_prefix="gl"
2931 if test $m4dirs_count = 1; then
2932 # There's only one use of gnulib here. Assume the user means it.
2933 # Any number of additional modules can be given.
2934 for m4base in $m4dirs; do
2938 # Ambiguous - guess what the user meant.
2939 if test $# = 0; then
2940 # No further arguments. Guess the user wants to update all of them.
2941 for m4base in $m4dirs; do
2942 # Perform func_import in a subshell, so that variable values
2944 # local_gnulib_dir, avoidlist, sourcebase, m4base, docbase,
2945 # testsbase, libname, lgpl, makefile_name, libtool, macro_prefix
2946 # don't propagate from one directory to another.
2947 (func_import) || func_exit 1
2951 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
2959 if test -z "$destdir"; then
2960 func_fatal_error "please specify --dir option"
2963 test -d "$destdir" \
2964 || func_fatal_error "could not create destination directory"
2965 test -n "$auxdir" || auxdir="build-aux"
2966 func_create_testdir "$destdir" "$*"
2969 create-megatestdir )
2970 if test -z "$destdir"; then
2971 func_fatal_error "please specify --dir option"
2973 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2974 test -n "$auxdir" || auxdir="build-aux"
2975 func_create_megatestdir "$destdir" "$*"
2979 test -n "$destdir" || destdir=testdir$$
2980 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2981 test -n "$auxdir" || auxdir="build-aux"
2982 func_create_testdir "$destdir" "$*"
2986 ../configure || func_exit 1
2988 make check || func_exit 1
2989 make distclean || func_exit 1
2990 remaining=`find . -type f -print`
2991 if test -n "$remaining"; then
2992 echo "Remaining files:" $remaining 1>&2
2993 echo "gnulib-tool: *** Stop." 1>&2
3002 test -n "$destdir" || destdir=testdir$$
3003 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3004 test -n "$auxdir" || auxdir="build-aux"
3005 func_create_megatestdir "$destdir" "$*"
3013 remaining=`find . -type f -print`
3014 if test -n "$remaining"; then
3015 echo "Remaining files:" $remaining 1>&2
3016 echo "gnulib-tool: *** Stop." 1>&2
3024 extract-description )
3028 if test -n "$module"; then
3029 func_get_description "$module"
3038 if test -n "$module"; then
3039 func_get_filelist "$module"
3044 extract-dependencies )
3048 if test -n "$module"; then
3049 func_get_dependencies "$module"
3054 extract-autoconf-snippet )
3058 if test -n "$module"; then
3059 func_get_autoconf_snippet "$module"
3064 extract-automake-snippet )
3068 if test -n "$module"; then
3069 func_get_automake_snippet "$module"
3074 extract-include-directive )
3078 if test -n "$module"; then
3079 func_get_include_directive "$module"
3084 extract-link-directive )
3088 if test -n "$module"; then
3089 func_get_link_directive "$module"
3098 if test -n "$module"; then
3099 func_get_license "$module"
3104 extract-maintainer )
3108 if test -n "$module"; then
3109 func_get_maintainer "$module"
3114 extract-tests-module )
3118 if test -n "$module"; then
3119 func_get_tests_module "$module"
3125 func_fatal_error "unknown operation mode --$mode" ;;
3129 # Undo the effect of the previous 'trap' command. Some shellology:
3130 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
3131 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
3132 # exit); for the others we need to call 'exit' explicitly. The value of $? is
3133 # 128 + signal number and is set before the trap-registered command is run.
3135 trap 'func_exit $?' 1 2 3 13 15
3140 # indent-tabs-mode: nil
3141 # whitespace-check-buffer-indent: nil