3 # Copyright (C) 2002-2006 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # This program is meant for authors or maintainers which want to import
21 # modules from gnulib into their packages.
25 cvsdatestamp='$Date: 2006-12-31 06:29:50 $'
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 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-license module
97 gnulib-tool --extract-maintainer module
98 gnulib-tool --extract-tests-module module
101 --list print the available module names
102 --import import the given modules into the current package;
103 if no modules are specified, update the current
104 package from the current gnulib
105 --update update the current package, restore files omitted
107 --create-testdir create a scratch package with the given modules
108 --create-megatestdir create a mega scratch package with the given modules
109 one by one and all together
110 --test test the combination of the given modules
111 (recommended to use CC=\"gcc -Wall\" here)
112 --megatest test the given modules one by one and all together
113 (recommended to use CC=\"gcc -Wall\" here)
114 --extract-description extract the description
115 --extract-filelist extract the list of files
116 --extract-dependencies extract the dependencies
117 --extract-autoconf-snippet extract the snippet for configure.ac
118 --extract-automake-snippet extract the snippet for library makefile
119 --extract-include-directive extract the #include directive
120 --extract-license report the license terms of the source files
122 --extract-maintainer report the maintainer(s) inside gnulib
123 --extract-tests-module report the unit test module, if it exists
126 --dir=DIRECTORY Specify the target directory.
127 For --import, this specifies where your
128 configure.ac can be found. Defaults to current
130 --local-dir=DIRECTORY Specify a local override directory where to look
131 up files before looking in gnulib's directory.
133 Options for --import:
134 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
135 --source-base=DIRECTORY
136 Directory relative to --dir where source code is
137 placed (default \"lib\").
138 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
139 placed (default \"m4\").
140 --doc-base=DIRECTORY Directory relative to --dir where doc files are
141 placed (default \"doc\").
142 --tests-base=DIRECTORY
143 Directory relative to --dir where unit tests are
144 placed (default \"tests\").
145 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
146 tools are placed (default \"build-aux\").
147 --with-tests Include unit tests for the included modules.
148 --avoid=MODULE Avoid including the given MODULE. Useful if you
149 have code that provides equivalent functionality.
150 This option can be repeated.
151 --lgpl Abort if modules aren't available under the LGPL.
152 Also modify license template from GPL to LGPL.
153 --makefile-name=NAME Name of makefile in automake syntax in the
154 source-base and tests-base directories
155 (default \"Makefile.am\").
156 --libtool Use libtool rules.
157 --no-libtool Don't use libtool rules.
158 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
159 'gl_INIT'. Default is 'gl'.
160 --no-changelog don't update or create ChangeLog files
162 Options for --import and --update:
163 --dry-run For --import, only print what would have been done.
164 -s, --symbolic, --symlink Make symbolic links instead of copying files.
165 --local-symlink Make symbolic links instead of copying files, only
166 for files from the local override directory.
168 Report bugs to <bug-gnulib@gnu.org>."
172 # outputs to stdout the --version message.
175 year=`echo "$last_checkin_date" | sed -e 's,/.*$,,'`
177 $progname (GNU $package) $version
178 Copyright (C) $year Free Software Foundation, Inc.
179 This is free software; see the source for copying conditions. There is NO
180 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
181 Written by" "Bruno Haible" "and" "Simon Josefsson"
184 # func_emit_copyright_notice
185 # outputs to stdout a header for a generated file.
186 func_emit_copyright_notice ()
188 echo "# Copyright (C) 2004-2006 Free Software Foundation, Inc."
190 echo "# This file is free software, distributed under the terms of the GNU"
191 echo "# General Public License. As a special exception to the GNU General"
192 echo "# Public License, this file may be distributed as part of a program"
193 echo "# that contains a configuration script generated by Autoconf, under"
194 echo "# the same distribution terms as the rest of that program."
196 echo "# Generated by gnulib-tool."
207 # creates a temporary directory.
209 # - tmp pathname of freshly created temporary directory
212 # Use the environment variable TMPDIR, falling back to /tmp. This allows
213 # users to specify a different temporary directory, for example, if their
214 # /tmp is filled up or too small.
217 # Use the mktemp program if available. If not available, hide the error
219 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
220 test -n "$tmp" && test -d "$tmp"
223 # Use a simple mkdir command. It is guaranteed to fail if the directory
224 # already exists. $RANDOM is bash specific and expands to empty in shells
225 # other than bash, ksh and zsh. Its use does not increase security;
226 # rather, it minimizes the probability of failure in a very cluttered /tmp
228 tmp=$TMPDIR/gl$$-$RANDOM
229 (umask 077 && mkdir "$tmp")
232 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
237 # func_append var value
238 # appends the given value to the shell variable var.
239 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
240 # Use bash's += operator. It reduces complexity of appending repeatedly to
241 # a single variable from O(n^2) to O(n).
249 eval "$1=\"\$$1\$2\""
253 # func_fatal_error message
254 # outputs to stderr a fatal error message, and terminates the program.
257 echo "gnulib-tool: *** $1" 1>&2
258 echo "gnulib-tool: *** Stop." 1>&2
262 # func_readlink SYMLINK
263 # outputs the target of the given symlink.
264 if (type -p readlink) > /dev/null 2>&1; then
267 # Use the readlink program from GNU coreutils.
273 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
274 # would do the wrong thing if the link target contains " -> ".
275 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
279 # func_relativize DIR1 DIR2
280 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
282 # - DIR1 relative pathname, relative to the current directory
283 # - DIR2 relative pathname, relative to the current directory
285 # - reldir relative pathname of DIR2, relative to DIR1
291 sed_first='s,^\([^/]*\)/.*$,\1,'
292 sed_rest='s,^[^/]*/*,,'
293 sed_last='s,^.*/\([^/]*\)$,\1,'
294 sed_butlast='s,/*[^/]*$,,'
295 while test -n "$dir1"; do
296 first=`echo "$dir1" | sed -e "$sed_first"`
297 if test "$first" != "."; then
298 if test "$first" = ".."; then
299 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
300 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
302 first2=`echo "$dir2" | sed -e "$sed_first"`
303 if test "$first2" = "$first"; then
304 dir2=`echo "$dir2" | sed -e "$sed_rest"`
308 dir0="$dir0"/"$first"
311 dir1=`echo "$dir1" | sed -e "$sed_rest"`
316 # func_relconcat DIR1 DIR2
317 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
319 # - DIR1 relative pathname, relative to the current directory
320 # - DIR2 relative pathname, relative to DIR1
322 # - relconcat DIR1/DIR2, relative to the current directory
327 sed_first='s,^\([^/]*\)/.*$,\1,'
328 sed_rest='s,^[^/]*/*,,'
329 sed_last='s,^.*/\([^/]*\)$,\1,'
330 sed_butlast='s,/*[^/]*$,,'
332 first=`echo "$dir2" | sed -e "$sed_first"`
333 if test "$first" = "."; then
334 dir2=`echo "$dir2" | sed -e "$sed_rest"`
335 if test -z "$dir2"; then
340 last=`echo "$dir1" | sed -e "$sed_last"`
341 while test "$last" = "."; do
342 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
343 last=`echo "$dir1" | sed -e "$sed_last"`
345 if test -z "$dir1"; then
349 if test "$first" = ".."; then
350 if test "$last" = ".."; then
351 relconcat="$dir1/$dir2"
354 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
355 dir2=`echo "$dir2" | sed -e "$sed_rest"`
356 if test -z "$dir1"; then
360 if test -z "$dir2"; then
365 relconcat="$dir1/$dir2"
373 # Like ln -s, except that SRC is given relative to the current directory (or
374 # absolute), not given relative to the directory of DEST.
380 *) # SRC is relative.
383 ln -s "`pwd`/$1" "$2" ;;
384 *) # DEST is relative too.
385 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
386 test -n "$ln_destdir" || ln_destdir="."
387 func_relativize "$ln_destdir" "$1"
395 # func_ln_if_changed SRC DEST
396 # Like func_ln, but avoids munging timestamps if the link is correct.
397 func_ln_if_changed ()
399 if test $# -ne 2; then
400 echo "usage: func_ln_if_changed SRC DEST" >&2
402 ln_target=`func_readlink "$2"`
403 if test -L "$2" && test "$1" = "$ln_target"; then
411 # Command-line option processing.
412 # Removes the OPTIONS from the arguments. Sets the variables:
413 # - mode list or import or create-testdir or create-megatestdir
414 # - destdir from --dir
415 # - local_gnulib_dir from --local-dir
416 # - libname, supplied_libname from --lib
417 # - sourcebase from --source-base
418 # - m4base from --m4-base
419 # - docbase from --doc-base
420 # - testsbase from --tests-base
421 # - auxdir from --aux-dir
422 # - inctests true if --with-tests was given, blank otherwise
423 # - avoidlist list of modules to avoid, from --avoid
424 # - lgpl true if --lgpl was given, blank otherwise
425 # - makefile_name from --makefile-name
426 # - libtool true if --libtool was given, false if --no-libtool was
427 # given, blank otherwise
428 # - macro_prefix from --macro-prefix
429 # - autoconf_minversion minimum supported autoconf version
430 # - do_changelog false if --no-changelog was given, : otherwise
431 # - doit : if actions shall be executed, false if only to be printed
432 # - symbolic true if --symlink was given, blank otherwise
433 # - lsymbolic true if --local-symlink was given, blank otherwise
458 while test $# -gt 0; do
463 --import | --impor | --impo | --imp | --im | --i )
466 --update | --updat | --upda | --upd | --up | --u )
469 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
472 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
473 mode=create-megatestdir
475 --test | --tes | --te | --t )
478 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
482 mode=`echo "X$1" | sed -e 's/^X--//'`
487 func_fatal_error "missing argument for --dir"
492 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
497 func_fatal_error "missing argument for --local-dir"
502 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
507 func_fatal_error "missing argument for --lib"
510 supplied_libname=true
513 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
514 supplied_libname=true
519 func_fatal_error "missing argument for --source-base"
524 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
529 func_fatal_error "missing argument for --m4-base"
534 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
539 func_fatal_error "missing argument for --doc-base"
544 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
549 func_fatal_error "missing argument for --tests-base"
554 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
559 func_fatal_error "missing argument for --aux-dir"
564 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
572 func_fatal_error "missing argument for --avoid"
574 func_append avoidlist " $1"
577 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
578 func_append avoidlist " $arg"
586 func_fatal_error "missing argument for --makefile-name"
591 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
602 func_fatal_error "missing argument for --macro-prefix"
607 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
609 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
615 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
618 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
621 --help | --hel | --he | --h )
624 --version | --versio | --versi | --vers | --ver | --ve | --v )
628 # Stop option processing
632 echo "gnulib-tool: unknown option $1" 1>&2
633 echo "Try 'gnulib-tool --help' for more information." 1>&2
640 if test "$mode" = update; then
641 if test $# != 0; then
642 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
643 echo "Try 'gnulib-tool --help' for more information." 1>&2
644 echo "If you really want to modify the gnulib configuration of your project," 1>&2
645 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
648 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
649 || test -n "$sourcebase" || test -n "$m4base" \
650 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
651 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
652 || test -n "$makefile_name" || test -n "$macro_prefix"; then
653 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
654 echo "Try 'gnulib-tool --help' for more information." 1>&2
655 echo "If you really want to modify the gnulib configuration of your project," 1>&2
656 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
662 # Determine the minimum supported autoconf version from the project's
664 DEFAULT_AUTOCONF_MINVERSION="2.59"
667 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
668 if test -f "$destdir"/configure.ac; then
669 configure_ac="$destdir/configure.ac"
671 if test -f "$destdir"/configure.in; then
672 configure_ac="$destdir/configure.in"
676 if test -f configure.ac; then
677 configure_ac="configure.ac"
679 if test -f configure.in; then
680 configure_ac="configure.in"
684 if test -n "$configure_ac"; then
685 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
686 # because when some m4 files are omitted from a CVS repository,
687 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
688 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
689 # autom4te: m4 failed with exit status: 1
696 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
698 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
699 if test -n "$prereqs"; then
700 autoconf_minversion=`
701 for version in $prereqs; do echo $version; done |
702 LC_ALL=C sort -nu | sed 1q
706 if test -z "$autoconf_minversion"; then
707 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
709 case "$autoconf_minversion" in
710 1.* | 2.[0-4]* | 2.5[0-8]*)
711 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
714 # Remove trailing slashes from the directory names. This is necessary for
715 # m4base (to avoid an error in func_import) and optional for the others.
716 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
717 case "$local_gnulib_dir" in
718 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
720 case "$sourcebase" in
721 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
724 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
727 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
730 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
733 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
738 /*) self_abspathname="$0" ;;
739 */*) self_abspathname=`pwd`/"$0" ;;
740 *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
741 if test -x "$d/$0" && test ! -d "$d/$0"; then
742 self_abspathname="$d/$0"
746 if test -z "$self_abspathname"; then
747 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
751 while test -h "$self_abspathname"; do
752 # Resolve symbolic link.
753 linkval=`func_readlink "$self_abspathname"`
754 test -n "$linkval" || break
756 /* ) self_abspathname="$linkval" ;;
757 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
760 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
764 if test "$signal" != 0; then
765 echo "caught signal $signal" >&2
769 for signal in 1 2 3 13 15; do
770 trap '{ signal='$signal'; func_exit 1; }' $signal
774 # func_lookup_file file
775 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
778 # - local_gnulib_dir from --local-dir
780 # - lookedup_file name of the merged (combined) file
781 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
785 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
786 lookedup_file="$local_gnulib_dir/$lkfile"
789 if test -f "$gnulib_dir/$lkfile"; then
790 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
791 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
793 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
794 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
795 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
796 lookedup_file="$tmp/$lkbase"
799 lookedup_file="$gnulib_dir/$lkfile"
803 func_fatal_error "file $gnulib_dir/$lkfile not found"
810 # - local_gnulib_dir from --local-dir
813 # Filter out metainformation files like README, which are not modules.
814 # Filter out unit test modules; they can be retrieved through
815 # --extract-tests-module if desired.
817 (cd "$gnulib_dir/modules" && ls -1)
818 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
819 (cd "$local_gnulib_dir/modules" && ls -1 | sed -e 's,\.diff$,,')
822 | sed -e '/^CVS$/d' -e '/^ChangeLog$/d' -e '/^COPYING$/d' -e '/^README$/d' -e '/^TEMPLATE$/d' -e '/^TEMPLATE-TESTS$/d' -e '/~$/d' \
823 | sed -e '/-tests$/d' \
828 # verifies a module name
830 # - local_gnulib_dir from --local-dir
831 # - module module name argument
832 func_verify_module ()
834 if { test -f "$gnulib_dir/modules/$module" \
835 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
836 && test -f "$local_gnulib_dir/modules/$module"; }; } \
837 && test "CVS" != "$module" \
838 && test "ChangeLog" != "$module" \
839 && test "COPYING" != "$module" \
840 && test "README" != "$module" \
841 && test "TEMPLATE" != "$module" \
842 && test "TEMPLATE-TESTS" != "$module"; then
843 # OK, $module is a correct module name.
844 # Verify that building the module description with 'patch' succeeds.
845 func_lookup_file "modules/$module"
847 echo "gnulib-tool: module $module doesn't exist" 1>&2
852 # func_verify_nontests_module
853 # verifies a module name, excluding tests modules
855 # - local_gnulib_dir from --local-dir
856 # - module module name argument
857 func_verify_nontests_module ()
861 * ) func_verify_module ;;
865 # func_verify_tests_module
866 # verifies a module name, considering only tests modules
868 # - local_gnulib_dir from --local-dir
869 # - module module name argument
870 func_verify_tests_module ()
873 *-tests ) func_verify_module ;;
878 sed_extract_prog=':[ ]*$/ {
881 s/^Description:[ ]*$//
883 s/^Depends-on:[ ]*$//
884 s/^configure\.ac:[ ]*$//
885 s/^Makefile\.am:[ ]*$//
888 s/^Maintainer:[ ]*$//
895 # func_get_description module
897 # - local_gnulib_dir from --local-dir
898 func_get_description ()
900 func_lookup_file "modules/$1"
901 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
904 # func_get_filelist module
906 # - local_gnulib_dir from --local-dir
909 func_lookup_file "modules/$1"
910 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
911 case "$autoconf_minversion" in
914 echo m4/onceonly_2_57.m4
919 # func_get_dependencies module
921 # - local_gnulib_dir from --local-dir
922 func_get_dependencies ()
924 # ${module}-tests always implicitly depends on ${module}.
925 echo "$1" | sed -n -e 's/-tests//p'
926 # Then the explicit dependencies listed in the module description.
927 func_lookup_file "modules/$1"
928 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
931 # func_get_autoconf_snippet module
933 # - local_gnulib_dir from --local-dir
934 func_get_autoconf_snippet ()
936 func_lookup_file "modules/$1"
937 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
940 # func_get_automake_snippet module
942 # - local_gnulib_dir from --local-dir
943 func_get_automake_snippet ()
945 func_lookup_file "modules/$1"
946 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
949 # *-tests module live in tests/, not lib/.
952 # Synthesize an EXTRA_DIST augmentation.
953 sed_combine_lines='/\\$/{
960 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
961 already_mentioned_files=` \
962 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
963 | sed -e "$sed_combine_lines" \
964 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
965 all_files=`func_get_filelist $1`
966 lib_files=`for f in $all_files; do \
970 done | sed -e 's,^lib/,,'`
971 # Remove $already_mentioned_files from $lib_files.
972 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
973 extra_files=`for f in $already_mentioned_files; do echo $f; done \
974 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
975 if test -n "$extra_files"; then
976 echo "EXTRA_DIST +=" $extra_files
979 # Synthesize also an EXTRA_lib_SOURCES augmentation.
980 # This is necessary so that automake can generate the right list of
982 # A possible approach would be to use autom4te --trace of the redefined
983 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
984 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
985 # inside autoconf's built-in macros are not missed).
986 # But it's simpler and more robust to do it here, based on the file list.
987 # If some .c file exists and is not used with AC_LIBOBJ - for example,
988 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
989 # automake will generate a useless dependency; this is harmless.
990 sed_extract_c_files='/\.c$/p'
991 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
992 if test -n "$extra_files"; then
993 echo "EXTRA_lib_SOURCES +=" $extra_files
1000 # func_get_include_directive module
1002 # - local_gnulib_dir from --local-dir
1003 func_get_include_directive ()
1005 func_lookup_file "modules/$1"
1006 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1007 sed -e 's/^\(["<]\)/#include \1/'
1010 # func_get_license module
1012 # - local_gnulib_dir from --local-dir
1015 func_lookup_file "modules/$1"
1016 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1019 # func_get_maintainer module
1021 # - local_gnulib_dir from --local-dir
1022 func_get_maintainer ()
1024 func_lookup_file "modules/$1"
1025 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1028 # func_get_tests_module module
1030 # - local_gnulib_dir from --local-dir
1031 func_get_tests_module ()
1033 # The naming convention for tests modules is hardwired: ${module}-tests.
1034 if test -f "$gnulib_dir/modules/$1"-tests \
1035 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1036 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1041 # func_acceptable module
1042 # tests whether a module is acceptable.
1044 # - avoidlist list of modules to avoid
1047 for avoid in $avoidlist; do
1048 if test "$avoid" = "$1"; then
1055 # func_modules_transitive_closure
1057 # - local_gnulib_dir from --local-dir
1058 # - modules list of specified modules
1059 # - inctests true if tests should be included, blank otherwise
1060 # - avoidlist list of modules to avoid
1061 # - tmp pathname of a temporary directory
1063 # - modules list of modules, including dependencies
1064 func_modules_transitive_closure ()
1066 # In order to process every module only once (for speed), process an "input
1067 # list" of modules, producing an "output list" of modules. During each round,
1068 # more modules can be queued in the input list. Once a module on the input
1069 # list has been processed, it is added to the "handled list", so we can avoid
1070 # to process it again.
1072 inmodules="$modules"
1074 while test -n "$inmodules"; do
1075 inmodules_this_round="$inmodules"
1076 inmodules= # Accumulator, queue for next round
1077 for module in $inmodules_this_round; do
1079 if test -n "$module"; then
1080 if func_acceptable $module; then
1081 func_append outmodules " $module"
1082 deps=`func_get_dependencies $module`
1083 # Duplicate dependencies are harmless, but Jim wants a warning.
1084 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1085 if test -n "$duplicated_deps"; then
1086 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1088 func_append inmodules " $deps"
1089 if test -n "$inctests"; then
1090 testsmodule=`func_get_tests_module $module`
1091 if test -n "$testsmodule"; then
1092 func_append inmodules " $testsmodule"
1098 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1099 # Remove $handledmodules from $inmodules.
1100 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1101 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1103 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1104 rm -f "$tmp"/queued-modules
1107 # func_modules_add_dummy
1109 # - local_gnulib_dir from --local-dir
1110 # - modules list of modules, including dependencies
1112 # - modules list of modules, including 'dummy' if needed
1113 func_modules_add_dummy ()
1116 sed_remove_backslash_newline=':a
1123 for module in $modules; do
1124 func_verify_nontests_module
1125 if test -n "$module"; then
1126 # Extract the value of "lib_SOURCES += ...".
1127 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1128 # Ignore .h files since they are not compiled.
1131 *) have_lib_SOURCES=yes ;;
1136 # Add the dummy module, to make sure the library will be non-empty.
1137 if test -z "$have_lib_SOURCES"; then
1138 func_append modules " dummy"
1142 # func_modules_to_filelist
1144 # - local_gnulib_dir from --local-dir
1145 # - modules list of modules, including dependencies
1147 # - files list of files
1148 func_modules_to_filelist ()
1151 for module in $modules; do
1153 if test -n "$module"; then
1154 fs=`func_get_filelist $module`
1155 func_append files " $fs"
1158 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1161 # func_emit_lib_Makefile_am
1162 # emits the contents of library makefile to standard output.
1164 # - local_gnulib_dir from --local-dir
1165 # - modules list of modules, including dependencies
1166 # - libname library name
1167 # - auxdir directory relative to destdir where to place build aux files
1168 # - makefile_name from --makefile-name
1169 # - libtool true if libtool will be used, false or blank otherwise
1170 # - macro_prefix prefix of gl_LIBOBJS macros to use
1171 # - actioncmd (optional) command that will reproduce this invocation
1173 # - uses_subdirs nonempty if object files in subdirs exist
1174 func_emit_lib_Makefile_am ()
1176 # When creating an includable Makefile.am snippet, augment variables with
1177 # += instead of assigning them.
1178 if test -n "$makefile_name"; then
1183 if test "$libtool" = true; then
1186 sed_eliminate_LDFLAGS=
1190 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1192 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1193 echo "## Process this file with automake to produce Makefile.in."
1194 func_emit_copyright_notice
1195 if test -n "$actioncmd"; then
1196 echo "# Reproduce by: $actioncmd"
1201 for module in $modules; do
1202 func_verify_nontests_module
1203 if test -n "$module"; then
1205 func_get_automake_snippet "$module" |
1206 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1207 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1208 sed -e "$sed_eliminate_LDFLAGS" |
1209 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1210 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1211 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
1212 if test "$module" = 'alloca'; then
1213 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1214 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1217 # Skip the contents if its entirely empty.
1218 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1219 echo "## begin gnulib module $module"
1222 echo "## end gnulib module $module"
1226 # Test whether there are some source files in subdirectories.
1227 for f in `func_get_filelist "$module"`; do
1229 lib/*/*.c) uses_subdirs=yes ;;
1235 if test -z "$makefile_name"; then
1236 # If there are source files in subdirectories, prevent collision of the
1237 # object files (example: hash.c and libxml/hash.c).
1239 if test -n "$uses_subdirs"; then
1240 subdir_options=' subdir-objects'
1242 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1245 if test -z "$makefile_name"; then
1246 echo "noinst_HEADERS ="
1247 echo "noinst_LIBRARIES ="
1248 echo "noinst_LTLIBRARIES ="
1249 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1250 # if you specify pkgdata_DATA to empty. This is a workaround.
1251 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1252 echo "pkgdata_DATA ="
1255 echo "BUILT_SOURCES ="
1258 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1259 if test -z "$makefile_name"; then
1260 echo "MOSTLYCLEANDIRS ="
1262 echo "DISTCLEANFILES ="
1263 echo "MAINTAINERCLEANFILES ="
1265 echo "AM_CPPFLAGS ="
1268 if grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1269 # One of the snippets already specifies an installation location for the
1270 # library. Don't confuse automake by saying it should not be installed.
1273 # By default, the generated library should not be installed.
1274 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1277 echo "${libname}_${libext}_SOURCES ="
1278 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1279 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1280 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1281 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1282 echo "EXTRA_${libname}_${libext}_SOURCES ="
1283 if test "$libtool" = true; then
1284 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1287 cat allsnippets.tmp \
1288 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1290 echo "mostlyclean-local: mostlyclean-generic"
1291 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1292 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1293 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1296 rm -f allsnippets.tmp
1299 # func_emit_tests_Makefile_am
1300 # emits the contents of tests makefile to standard output.
1302 # - local_gnulib_dir from --local-dir
1303 # - modules list of modules, including dependencies
1304 # - libname library name
1305 # - makefile_name from --makefile-name
1306 # - libtool true if libtool will be used, false or blank otherwise
1307 # - sourcebase relative directory containing lib source code
1308 # - m4base relative directory containing autoconf macros
1309 # - testsbase relative directory containing unit test code
1310 func_emit_tests_Makefile_am ()
1312 if test "$libtool" = true; then
1317 if test "$libtool" = true; then
1319 sed_eliminate_LDFLAGS=
1322 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1324 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1325 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1326 echo "## Process this file with automake to produce Makefile.in."
1327 func_emit_copyright_notice
1329 # Generate dependencies here, since it eases the debugging of test failures.
1330 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1332 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1335 for module in $modules; do
1336 func_verify_tests_module
1337 if test -n "$module"; then
1339 func_get_automake_snippet "$module" |
1340 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1341 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1342 sed -e "$sed_eliminate_LDFLAGS" |
1343 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1344 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1345 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
1347 # Skip the contents if its entirely empty.
1348 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1349 echo "## begin gnulib module $module"
1352 echo "## end gnulib module $module"
1359 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1360 # variable is needed to avoid an error from automake:
1361 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1364 echo "TESTS_ENVIRONMENT ="
1365 echo "noinst_PROGRAMS ="
1366 echo "check_PROGRAMS ="
1367 echo "noinst_HEADERS ="
1368 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1369 echo "pkgdata_DATA ="
1372 echo "BUILT_SOURCES ="
1374 echo "MOSTLYCLEANFILES = core *.stackdump"
1375 echo "MOSTLYCLEANDIRS ="
1377 echo "DISTCLEANFILES ="
1378 echo "MAINTAINERCLEANFILES ="
1380 echo "AM_CPPFLAGS = \\"
1381 echo " -I. -I\$(srcdir) \\"
1382 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1383 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1385 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1388 echo "# Clean up after Solaris cc."
1390 echo " rm -rf SunWS_cache"
1392 echo "mostlyclean-local: mostlyclean-generic"
1393 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1394 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1395 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1398 rm -f allsnippets.tmp
1401 # func_emit_initmacro_start
1402 # emits the first few statements of the gl_INIT macro to standard output.
1403 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1404 func_emit_initmacro_start ()
1406 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
1407 # platform-dependent object files in ${macro_prefix}_LIBOBJS instead of
1408 # LIBOBJS. The purpose is to allow several gnulib instantiations under
1409 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
1411 # Furthermore it avoids an automake error like this when a Makefile.am
1412 # that uses pieces of gnulib also uses $(LIBOBJ):
1413 # automatically discovered file `error.c' should not be explicitly mentioned
1414 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix}_LIBOBJ]))"
1415 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix}_REPLACE_FUNCS]))"
1416 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
1417 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
1418 # automatically discovered file `error.c' should not be explicitly mentioned
1419 # We let automake know about the files to be distributed through the
1420 # EXTRA_lib_SOURCES variable.
1421 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix}_LIBSOURCES]))"
1424 # func_emit_initmacro_end
1425 # emits the last few statements of the gl_INIT macro to standard output.
1426 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1427 func_emit_initmacro_end ()
1429 echo " m4_popdef([AC_LIBSOURCES])"
1430 echo " m4_popdef([AC_REPLACE_FUNCS])"
1431 echo " m4_popdef([AC_LIBOBJ])"
1432 echo " AC_CONFIG_COMMANDS_PRE(["
1433 echo " ${macro_prefix}_libobjs="
1434 echo " ${macro_prefix}_ltlibobjs="
1435 echo " if test -n \"\$${macro_prefix}_LIBOBJS\"; then"
1436 echo " # Remove the extension."
1437 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
1438 echo " for i in \`for i in \$${macro_prefix}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
1439 echo " ${macro_prefix}_libobjs=\"\$${macro_prefix}_libobjs \$i.\$ac_objext\""
1440 echo " ${macro_prefix}_ltlibobjs=\"\$${macro_prefix}_ltlibobjs \$i.lo\""
1443 echo " AC_SUBST([${macro_prefix}_LIBOBJS], [\$${macro_prefix}_libobjs])"
1444 echo " AC_SUBST([${macro_prefix}_LTLIBOBJS], [\$${macro_prefix}_ltlibobjs])"
1448 # func_emit_initmacro_done
1449 # emits a few statements after the gl_INIT macro to standard output.
1450 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1451 func_emit_initmacro_done ()
1454 echo "# Like AC_LIBOBJ, except that the module name goes"
1455 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1456 echo "AC_DEFUN([${macro_prefix}_LIBOBJ],"
1457 echo " [${macro_prefix}_LIBOBJS=\"\$${macro_prefix}_LIBOBJS \$1.\$ac_objext\"])"
1459 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
1460 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1461 echo "AC_DEFUN([${macro_prefix}_REPLACE_FUNCS],"
1462 echo " [AC_CHECK_FUNCS([\$1], , [${macro_prefix}_LIBOBJ(\$ac_func)])])"
1464 echo "# Like AC_LIBSOURCES, except that it does nothing."
1465 echo "# We rely on EXTRA_lib..._SOURCES instead."
1466 echo "AC_DEFUN([${macro_prefix}_LIBSOURCES],"
1470 # func_import modules
1471 # Uses also the variables
1472 # - destdir target directory
1473 # - local_gnulib_dir from --local-dir
1474 # - libname library name
1475 # - sourcebase directory relative to destdir where to place source code
1476 # - m4base directory relative to destdir where to place *.m4 macros
1477 # - docbase directory relative to destdir where to place doc files
1478 # - testsbase directory relative to destdir where to place unit test code
1479 # - auxdir directory relative to destdir where to place build aux files
1480 # - inctests true if --with-tests was given, blank otherwise
1481 # - avoidlist list of modules to avoid, from --avoid
1482 # - lgpl true if library's license shall be LGPL, blank otherwise
1483 # - makefile_name from --makefile-name
1484 # - libtool true if --libtool was given, false if --no-libtool was
1485 # given, blank otherwise
1486 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1487 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1488 # - autoconf_minversion minimum supported autoconf version
1489 # - doit : if actions shall be executed, false if only to be printed
1490 # - symbolic true if files should be symlinked, copied otherwise
1491 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1495 # Get the cached settings.
1496 cached_local_gnulib_dir=
1497 cached_specified_modules=
1505 cached_makefile_name=
1507 cached_macro_prefix=
1509 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1510 cached_libtool=false
1516 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
1519 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1522 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1525 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1528 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1531 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1534 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1537 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1540 s,^.*$,cached_lgpl=true,p
1542 /gl_MAKEFILE_NAME(/ {
1543 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
1546 s,^.*$,cached_libtool=true,p
1548 /gl_MACRO_PREFIX(/ {
1549 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
1551 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
1552 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1557 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
1558 s,^.*$,cached_files=",p
1570 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1574 # Merge the cached settings with the specified ones.
1575 # The m4base must be the same as expected from the pathname.
1576 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1577 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1579 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
1580 # is relative to $destdir, whereas the one we use is relative to . or absolute.
1581 if test -z "$local_gnulib_dir"; then
1582 if test -n "$cached_local_gnulib_dir"; then
1585 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1587 case "$cached_local_gnulib_dir" in
1589 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1591 func_relconcat "$destdir" "$cached_local_gnulib_dir"
1592 local_gnulib_dir="$relconcat" ;;
1597 # Append the cached and the specified module names. So that
1598 # "gnulib-tool --import foo" means to add the module foo.
1599 specified_modules="$cached_specified_modules $1"
1600 # Append the cached and the specified avoidlist. This is probably better
1601 # than dropping the cached one when --avoid is specified at least once.
1602 avoidlist=`echo $cached_avoidlist $avoidlist`
1603 # The sourcebase defaults to the cached one.
1604 if test -z "$sourcebase"; then
1605 sourcebase="$cached_sourcebase"
1606 if test -z "$sourcebase"; then
1607 func_fatal_error "missing --source-base option"
1610 # The docbase defaults to the cached one.
1611 if test -z "$docbase"; then
1612 docbase="$cached_docbase"
1613 if test -z "$docbase"; then
1614 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."
1617 # The testsbase defaults to the cached one.
1618 if test -z "$testsbase"; then
1619 testsbase="$cached_testsbase"
1620 if test -z "$testsbase"; then
1621 func_fatal_error "missing --tests-base option"
1624 # The libname defaults to the cached one.
1625 if test -z "$supplied_libname"; then
1626 libname="$cached_libname"
1627 if test -z "$libname"; then
1628 func_fatal_error "missing --lib option"
1631 # Require LGPL if specified either way.
1632 if test -z "$lgpl"; then
1635 # The makefile_name defaults to the cached one.
1636 if test -z "$makefile_name"; then
1637 makefile_name="$cached_makefile_name"
1639 # Use libtool if specified either way, or if guessed.
1640 if test -z "$libtool"; then
1641 if test -n "$cached_m4base"; then
1642 libtool="$cached_libtool"
1644 libtool="$guessed_libtool"
1647 # The macro_prefix defaults to the cached one.
1648 if test -z "$macro_prefix"; then
1649 macro_prefix="$cached_macro_prefix"
1650 if test -z "$macro_prefix"; then
1651 func_fatal_error "missing --macro-prefix option"
1655 # Canonicalize the list of specified modules.
1656 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
1658 # Determine final module list.
1659 modules="$specified_modules"
1660 func_modules_transitive_closure
1661 echo "Module list with included dependencies:"
1662 echo "$modules" | sed -e 's/^/ /'
1664 # Add the dummy module if needed.
1665 func_modules_add_dummy
1667 # If --lgpl, verify that the licenses of modules are compatible.
1668 if test -n "$lgpl"; then
1669 for module in $modules; do
1670 license=`func_get_license $module`
1672 LGPL | 'GPLed build tool') ;;
1673 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
1674 *) func_fatal_error "incompatible license on module $module: $license" ;;
1679 # Determine script to apply to imported library files.
1680 sed_transform_lib_file=
1681 for module in $modules; do
1682 if test $module = config-h; then
1683 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
1684 sed_transform_lib_file=$sed_transform_lib_file'
1685 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
1690 if test -n "$lgpl"; then
1692 sed_transform_lib_file=$sed_transform_lib_file'
1693 s/GNU General/GNU Lesser General/g
1694 s/version 2\([ ,]\)/version 2.1\1/g
1698 # Determine final file list.
1699 func_modules_to_filelist
1701 echo "$files" | sed -e 's/^/ /'
1704 || func_fatal_error "refusing to do nothing"
1706 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
1707 new_files="$files m4/gnulib-tool.m4"
1708 old_files="$cached_files"
1709 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
1710 func_append old_files " m4/gnulib-tool.m4"
1713 sed_rewrite_old_files="\
1714 s,^build-aux/,$auxdir/,
1715 s,^doc/,$cached_docbase/,
1716 s,^lib/,$cached_sourcebase/,
1717 s,^m4/,$cached_m4base/,
1718 s,^tests/,$cached_testsbase/,"
1719 sed_rewrite_new_files="\
1720 s,^build-aux/,$auxdir/,
1722 s,^lib/,$sourcebase/,
1724 s,^tests/,$testsbase/,"
1726 # Create directories.
1727 { echo "$sourcebase"
1729 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
1730 if test -n "$docfiles"; then
1733 if test -n "$inctests"; then
1737 for f in $files; do echo $f; done \
1738 | sed -e "$sed_rewrite_new_files" \
1739 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
1742 { # Rearrange file descriptors. Needed because "while ... done < ..."
1743 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1744 exec 5<&0 < "$tmp"/dirs
1746 if test ! -d "$destdir/$d"; then
1748 echo "Creating directory $destdir/$d"
1749 mkdir -p "$destdir/$d" || func_fatal_error "failed"
1751 echo "Create directory $destdir/$d"
1758 # func_dest_tmpfilename file
1759 # determines the name of a temporary file (file is relative to destdir).
1761 # - tmpfile absolute filename of the temporary file
1762 func_dest_tmpfilename ()
1765 # Put the new contents of $file in a file in the same directory (needed
1766 # to guarantee that an 'mv' to "$destdir/$file" works).
1767 tmpfile="$destdir/$1.tmp"
1769 # Put the new contents of $file in a file in a temporary directory
1770 # (because the directory of "$file" might not exist).
1771 tmpfile="$tmp"/`basename "$1"`.tmp
1775 # Copy files or make symbolic links. Remove obsolete files.
1777 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1778 # representing the files according to the last gnulib-tool invocation.
1779 for f in $old_files; do echo $f; done \
1780 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
1783 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1784 # representing the files after this gnulib-tool invocation.
1785 for f in $new_files; do echo $f; done \
1786 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
1789 # First the files that are in old-files, but not in new-files:
1790 sed_take_first_column='s,'"$delimiter"'.*,,'
1791 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
1792 # Remove the file. Do nothing if the user already removed it.
1793 if test -f "$destdir/$g"; then
1795 echo "Removing file $g (backup in ${g}~)"
1796 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1798 echo "Remove file $g (backup in ${g}~)"
1802 # func_add_or_update handles a file that ought to be present afterwards.
1804 # - f the original file name
1805 # - g the rewritten file name
1806 # - already_present nonempty if the file already exists, empty otherwise
1807 func_add_or_update ()
1809 func_dest_tmpfilename "$g"
1810 func_lookup_file "$f"
1811 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
1812 if test -n "$sed_transform_lib_file"; then
1815 sed -e "$sed_transform_lib_file" \
1816 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
1820 if test -f "$destdir/$g"; then
1821 # The file already exists.
1822 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1823 : # The file has not changed.
1827 if test -n "$already_present"; then
1828 echo "Updating file $g (backup in ${g}~)"
1830 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
1832 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1833 if { test -n "$symbolic" \
1834 || { test -n "$lsymbolic" \
1835 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1836 && test -z "$lookedup_tmp" \
1837 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1838 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1840 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1843 if test -n "$already_present"; then
1844 echo "Update file $g (backup in ${g}~)"
1846 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
1852 # Don't protest if the file should be there but isn't: it happens
1853 # frequently that developers don't put autogenerated files into CVS.
1855 echo "Copying file $g"
1856 if { test -n "$symbolic" \
1857 || { test -n "$lsymbolic" \
1858 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
1859 && test -z "$lookedup_tmp" \
1860 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1861 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1863 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1871 # Then the files that are in new-files, but not in old-files:
1872 sed_take_last_column='s,^.*'"$delimiter"',,'
1874 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
1875 | sed -e "$sed_take_last_column" \
1876 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
1877 { # Rearrange file descriptors. Needed because "while ... done < ..."
1878 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1879 exec 5<&0 < "$tmp"/added-files
1885 # Then the files that are in new-files and in old-files:
1886 already_present=true
1887 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
1888 | sed -e "$sed_take_last_column" \
1889 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
1890 { # Rearrange file descriptors. Needed because "while ... done < ..."
1891 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1892 exec 5<&0 < "$tmp"/kept-files
1899 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
1900 actioncmd="gnulib-tool --import"
1901 func_append actioncmd " --dir=$destdir"
1902 if test -n "$local_gnulib_dir"; then
1903 func_append actioncmd " --local-dir=$local_gnulib_dir"
1905 func_append actioncmd " --lib=$libname"
1906 func_append actioncmd " --source-base=$sourcebase"
1907 func_append actioncmd " --m4-base=$m4base"
1908 func_append actioncmd " --doc-base=$docbase"
1909 func_append actioncmd " --aux-dir=$auxdir"
1910 for module in $avoidlist; do
1911 func_append actioncmd " --avoid=$module"
1913 if test -n "$lgpl"; then
1914 func_append actioncmd " --lgpl"
1916 if test -n "$makefile_name"; then
1917 func_append actioncmd " --makefile-name=$makefile_name"
1919 if test "$libtool" = true; then
1920 func_append actioncmd " --libtool"
1922 func_append actioncmd " --no-libtool"
1924 func_append actioncmd " --macro-prefix=$macro_prefix"
1925 func_append actioncmd " `echo $specified_modules`"
1927 # Default the makefile name to Makefile.am.
1928 if test -n "$makefile_name"; then
1929 makefile_am=$makefile_name
1931 makefile_am=Makefile.am
1934 # Create library makefile.
1935 func_dest_tmpfilename $sourcebase/$makefile_am
1936 func_emit_lib_Makefile_am > "$tmpfile"
1937 if test -f "$destdir"/$sourcebase/$makefile_am; then
1938 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
1942 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
1943 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
1944 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
1946 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
1952 echo "Creating $sourcebase/$makefile_am"
1953 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
1955 echo "Create $sourcebase/$makefile_am"
1960 # Create m4/gnulib-cache.m4.
1961 func_dest_tmpfilename $m4base/gnulib-cache.m4
1963 func_emit_copyright_notice
1965 echo "# This file represents the specification of how gnulib-tool is used."
1966 echo "# It acts as a cache: It is written and read by gnulib-tool."
1967 echo "# In projects using CVS, this file is meant to be stored in CVS,"
1968 echo "# like the configure.ac and various Makefile.am files."
1971 echo "# Specification in the form of a command-line invocation:"
1974 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
1975 # Store the local_gnulib_dir relative to destdir.
1976 case "$local_gnulib_dir" in
1978 relative_local_gnulib_dir="$local_gnulib_dir" ;;
1981 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
1983 # destdir, local_gnulib_dir are both relative.
1984 func_relativize "$destdir" "$local_gnulib_dir"
1985 relative_local_gnulib_dir="$reldir" ;;
1988 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
1989 echo "gl_MODULES(["`echo $specified_modules`"])"
1990 echo "gl_AVOID([$avoidlist])"
1991 echo "gl_SOURCE_BASE([$sourcebase])"
1992 echo "gl_M4_BASE([$m4base])"
1993 echo "gl_DOC_BASE([$docbase])"
1994 echo "gl_TESTS_BASE([$testsbase])"
1995 echo "gl_LIB([$libname])"
1996 test -z "$lgpl" || echo "gl_LGPL"
1997 echo "gl_MAKEFILE_NAME([$makefile_name])"
1998 if test "$libtool" = true; then
2001 echo "gl_MACRO_PREFIX([$macro_prefix])"
2003 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2004 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2008 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2009 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2010 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2012 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2016 echo "# gnulib-cache.m4 ends here"
2023 echo "Creating $m4base/gnulib-cache.m4"
2024 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2026 echo "Create $m4base/gnulib-cache.m4"
2032 # Create m4/gnulib-comp.m4.
2033 func_dest_tmpfilename $m4base/gnulib-comp.m4
2035 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2036 func_emit_copyright_notice
2038 echo "# This file represents the compiled summary of the specification in"
2039 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2040 echo "# to be invoked from configure.ac."
2041 echo "# In projects using CVS, this file can be treated like other built files."
2044 echo "# This macro should be invoked from $configure_ac, in the section"
2045 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2046 echo "# any checks for libraries, header files, types and library functions."
2047 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2049 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2050 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2051 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2052 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2053 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2054 if test -n "$uses_subdirs"; then
2055 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2057 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2058 echo " AC_REQUIRE([AC_GNU_SOURCE])"
2060 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2061 echo " AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])"
2063 if grep gl_LOCK "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2064 echo " AC_REQUIRE([gl_LOCK_EARLY])"
2068 echo "# This macro should be invoked from $configure_ac, in the section"
2069 echo "# \"Check for header files, types and library functions\"."
2070 echo "AC_DEFUN([${macro_prefix}_INIT],"
2072 func_emit_initmacro_start
2073 if test "$libtool" = true; then
2074 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2075 echo " gl_cond_libtool=true"
2077 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2078 echo " gl_cond_libtool=false"
2080 echo " gl_ltlibdeps="
2082 echo " gl_source_base='$sourcebase'"
2083 if test "$auxdir" != "build-aux"; then
2084 sed_replace_build_aux='
2086 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2087 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2090 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2092 sed_replace_build_aux=
2094 for module in $modules; do
2096 if test -n "$module"; then
2097 func_get_autoconf_snippet "$module" \
2098 | sed -e '/^$/d;' -e 's/^/ /' \
2099 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
2100 -e "$sed_replace_build_aux"
2101 if test "$module" = 'alloca' && test "$libtool" = true; then
2102 echo 'changequote(,)dnl'
2103 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
2104 echo 'changequote([, ])dnl'
2105 echo 'AC_SUBST([LTALLOCA])'
2109 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2110 # created using libtool, because libtool already handles the dependencies.
2111 if test "$libtool" != true; then
2112 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2113 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2114 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2115 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2116 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2118 func_emit_initmacro_end
2120 func_emit_initmacro_done
2122 echo "# This macro records the list of files which have been installed by"
2123 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
2124 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
2125 echo "$files" | sed -e 's,^, ,'
2128 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2129 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
2133 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2134 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
2135 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2137 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2141 echo "# gnulib-comp.m4 ends here"
2148 echo "Creating $m4base/gnulib-comp.m4"
2149 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2151 echo "Create $m4base/gnulib-comp.m4"
2157 if test -n "$inctests"; then
2158 # Create tests makefile.
2159 func_dest_tmpfilename $testsbase/$makefile_am
2160 func_emit_tests_Makefile_am > "$tmpfile"
2161 if test -f "$destdir"/$testsbase/$makefile_am; then
2162 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
2166 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2167 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
2168 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2170 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2176 echo "Creating $testsbase/$makefile_am"
2177 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2179 echo "Create $testsbase/$makefile_am"
2187 echo "You may need to add #include directives for the following .h files."
2188 # Intersect $specified_modules and $modules
2189 # (since $specified_modules is not necessarily of subset of $modules - some
2190 # may have been skipped through --avoid, and since the elements of $modules
2191 # but not in $specified_modules can go away without explicit notice - through
2192 # changes in the module dependencies).
2193 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
2194 echo "$modules" > "$tmp"/modules2 # also a sorted list, one module per line
2195 # First the #include <...> directives without #ifs, sorted for convenience,
2196 # then the #include "..." directives without #ifs, sorted for convenience,
2197 # then the #include directives that are surrounded by #ifs. Not sorted.
2198 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
2199 include_directive=`func_get_include_directive "$module"`
2200 case "$nl$include_directive" in
2202 echo "$include_directive" 1>&5
2205 echo "$include_directive" | grep -v 'include "' 1>&6
2206 echo "$include_directive" | grep 'include "' 1>&7
2209 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
2211 LC_ALL=C sort -u "$tmp"/include-angles
2212 LC_ALL=C sort -u "$tmp"/include-quotes
2213 cat "$tmp"/include-if
2214 ) | sed -e '/^$/d' -e 's/^/ /'
2215 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
2218 echo "Don't forget to"
2219 if test "$makefile_am" = Makefile.am; then
2220 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2222 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
2224 if test -n "$inctests"; then
2225 if test "$makefile_am" = Makefile.am; then
2226 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2228 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
2231 if test "$makefile_am" = Makefile.am; then
2232 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
2233 sourcebase_base=`basename "$sourcebase"`
2234 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
2236 if test -n "$inctests"; then
2237 if test "$makefile_am" = Makefile.am; then
2238 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
2239 testsbase_base=`basename "$testsbase"`
2240 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
2243 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
2244 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
2245 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
2248 # func_create_testdir testdir modules
2250 # - local_gnulib_dir from --local-dir
2251 # - auxdir directory relative to destdir where to place build aux files
2252 func_create_testdir ()
2256 if test -z "$modules"; then
2257 # All modules together.
2258 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2259 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2260 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
2261 modules=`func_all_modules`
2262 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
2264 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
2266 # Check that the license of every module is consistent with the license of
2268 saved_modules="$modules"
2269 for requested_module in $saved_modules; do
2270 requested_license=`func_get_license "$requested_module"`
2271 if test "$requested_license" != GPL; then
2272 # Here we use func_modules_transitive_closure, not just
2273 # func_get_dependencies, so that we also detect weird situations like
2274 # an LGPL module which depends on a GPLed build tool module which depends
2276 modules="$requested_module"
2277 func_modules_transitive_closure
2278 for module in $modules; do
2279 license=`func_get_license "$module"`
2281 LGPL | 'GPLed build tool') ;;
2282 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2283 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
2288 modules="$saved_modules"
2290 # Subdirectory names.
2297 # Determine final module list.
2298 func_modules_transitive_closure
2299 echo "Module list with included dependencies:"
2300 echo "$modules" | sed -e 's/^/ /'
2302 # Add the dummy module if needed.
2303 func_modules_add_dummy
2305 # Determine final file list.
2306 func_modules_to_filelist
2308 echo "$files" | sed -e 's/^/ /'
2310 sed_rewrite_files="\
2311 s,^build-aux/,$auxdir/,
2313 s,^lib/,$sourcebase/,
2315 s,^tests/,$testsbase/,"
2317 # Create directories.
2318 for f in $files; do echo $f; done \
2319 | sed -e "$sed_rewrite_files" \
2320 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2321 | LC_ALL=C sort -u \
2323 { # Rearrange file descriptors. Needed because "while ... done < ..."
2324 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2325 exec 5<&0 < "$tmp"/dirs
2327 mkdir -p "$testdir/$d"
2332 # Copy files or make symbolic links.
2334 for f in $files; do echo $f; done \
2335 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
2338 { # Rearrange file descriptors. Needed because "while ... done < ..."
2339 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2340 exec 5<&0 < "$tmp"/files
2342 func_lookup_file "$f"
2343 if test -n "$lookedup_tmp"; then
2344 cp -p "$lookedup_file" "$testdir/$g"
2346 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
2347 if { test -n "$symbolic" \
2348 || { test -n "$lsymbolic" \
2349 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
2350 func_ln "$lookedup_file" "$testdir/$g"
2352 cp -p "$lookedup_file" "$testdir/$g"
2359 # Create $sourcebase/Makefile.am.
2360 mkdir -p "$testdir/$sourcebase"
2361 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
2363 # Create $m4base/Makefile.am.
2364 mkdir -p "$testdir/$m4base"
2365 (echo "## Process this file with automake to produce Makefile.in."
2371 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
2374 ) > "$testdir/$m4base/Makefile.am"
2376 subdirs="$sourcebase $m4base"
2377 subdirs_with_configure_ac=""
2379 if false && test -f "$testdir"/$m4base/gettext.m4; then
2380 # Avoid stupid error message from automake:
2381 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
2382 mkdir -p "$testdir/po"
2383 (echo "## Process this file with automake to produce Makefile.in."
2384 ) > "$testdir/po/Makefile.am"
2385 func_append subdirs " po"
2388 if test -n "$inctests"; then
2389 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
2390 # Create $testsbase/Makefile.am.
2391 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
2392 # Create $testsbase/configure.ac.
2393 (echo "# Process this file with autoconf to produce a configure script."
2394 echo "AC_INIT([dummy], [0])"
2395 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
2396 echo "AM_INIT_AUTOMAKE"
2398 echo "AM_CONFIG_HEADER([config.h])"
2401 echo "AC_PROG_INSTALL"
2402 echo "AC_PROG_MAKE_SET"
2403 echo "AC_PROG_RANLIB"
2405 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2406 echo "AC_GNU_SOURCE"
2409 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2410 echo "gl_USE_SYSTEM_EXTENSIONS"
2413 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2414 echo "gl_LOCK_EARLY"
2417 if test "$libtool" = true; then
2418 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2419 echo "gl_cond_libtool=true"
2421 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2422 echo "gl_cond_libtool=false"
2424 echo "gl_ltlibdeps="
2426 # Wrap the set of autoconf snippets into an autoconf macro that is then
2427 # invoked. This is needed because autoconf does not support AC_REQUIRE
2429 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2430 # but we want the AC_REQUIRE to have its normal meaning (provide one
2431 # expansion of the required macro before the current point, and only one
2433 echo "AC_DEFUN([gl_INIT], ["
2434 func_emit_initmacro_start
2435 sed_replace_build_aux='
2437 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2438 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
2441 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2442 # We don't have explicit ordering constraints between the various
2443 # autoconf snippets. It's cleanest to put those of the library before
2444 # those of the tests.
2445 echo "gl_source_base='../$sourcebase'"
2446 for module in $modules; do
2447 func_verify_nontests_module
2448 if test -n "$module"; then
2449 func_get_autoconf_snippet "$module" \
2450 | sed -e "$sed_replace_build_aux"
2453 echo "gl_source_base='.'"
2454 for module in $modules; do
2455 func_verify_tests_module
2456 if test -n "$module"; then
2457 func_get_autoconf_snippet "$module" \
2458 | sed -e "$sed_replace_build_aux"
2461 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2462 # created using libtool, because libtool already handles the dependencies.
2463 if test "$libtool" != true; then
2464 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2465 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2466 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2467 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2468 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2470 func_emit_initmacro_end
2472 func_emit_initmacro_done
2476 # Usually $testsbase/config.h will be a superset of config.h. Verify this
2477 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
2478 echo "AH_TOP([#include \"../config.h\"])"
2480 echo "AC_OUTPUT([Makefile])"
2481 ) > "$testdir/$testsbase/configure.ac"
2482 func_append subdirs " $testsbase"
2483 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
2486 # Create Makefile.am.
2487 (echo "## Process this file with automake to produce Makefile.in."
2489 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2491 echo "SUBDIRS = $subdirs"
2493 echo "ACLOCAL_AMFLAGS = -I $m4base"
2494 ) > "$testdir/Makefile.am"
2496 # Create configure.ac.
2497 (echo "# Process this file with autoconf to produce a configure script."
2498 echo "AC_INIT([dummy], [0])"
2499 if test "$auxdir" != "."; then
2500 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2502 echo "AM_INIT_AUTOMAKE"
2504 echo "AM_CONFIG_HEADER([config.h])"
2507 echo "AC_PROG_INSTALL"
2508 echo "AC_PROG_MAKE_SET"
2510 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2511 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2512 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2513 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2515 echo "AC_PROG_RANLIB"
2517 if test -n "$uses_subdirs"; then
2518 echo "AM_PROG_CC_C_O"
2521 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2522 echo "AC_GNU_SOURCE"
2525 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2526 echo "gl_USE_SYSTEM_EXTENSIONS"
2529 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2530 echo "gl_LOCK_EARLY"
2533 if test "$libtool" = true; then
2534 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2535 echo "gl_cond_libtool=true"
2537 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2538 echo "gl_cond_libtool=false"
2540 echo "gl_ltlibdeps="
2542 echo "gl_source_base='$sourcebase'"
2543 # Wrap the set of autoconf snippets into an autoconf macro that is then
2544 # invoked. This is needed because autoconf does not support AC_REQUIRE
2546 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2547 # but we want the AC_REQUIRE to have its normal meaning (provide one
2548 # expansion of the required macro before the current point, and only one
2550 echo "AC_DEFUN([gl_INIT], ["
2551 func_emit_initmacro_start
2552 if test "$auxdir" != "build-aux"; then
2553 sed_replace_build_aux='
2555 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2556 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2559 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2561 sed_replace_build_aux=
2563 for module in $modules; do
2564 func_verify_nontests_module
2565 if test -n "$module"; then
2566 func_get_autoconf_snippet "$module" \
2567 | sed -e "$sed_replace_build_aux"
2570 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2571 # created using libtool, because libtool already handles the dependencies.
2572 if test "$libtool" != true; then
2573 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2574 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2575 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2576 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2577 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2579 func_emit_initmacro_end
2581 func_emit_initmacro_done
2585 if test -n "$subdirs_with_configure_ac"; then
2586 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
2588 makefiles="Makefile"
2589 for d in $subdirs; do
2590 # For subdirs that have a configure.ac by their own, it's the subdir's
2591 # configure.ac which creates the subdir's Makefile.am, not this one.
2592 case " $subdirs_with_configure_ac " in
2594 *) func_append makefiles " $d/Makefile" ;;
2597 echo "AC_OUTPUT([$makefiles])"
2598 ) > "$testdir/configure.ac"
2600 # Create autogenerated files.
2602 # Do not use "${AUTORECONF} --force --install", because it may invoke
2603 # autopoint, which brings in older versions of some of our .m4 files.
2604 if test -f $m4base/gettext.m4; then
2605 echo "executing ${AUTOPOINT} --force"
2606 ${AUTOPOINT} --force || func_exit 1
2607 for f in $m4base/*.m4~; do
2608 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2611 echo "executing ${ACLOCAL} -I $m4base"
2612 ${ACLOCAL} -I $m4base || func_exit 1
2613 if ! test -d build-aux; then
2614 echo "executing mkdir build-aux"
2615 mkdir build-aux || func_exit 1
2617 echo "executing ${AUTOCONF}"
2618 ${AUTOCONF} || func_exit 1
2619 echo "executing ${AUTOHEADER}"
2620 ${AUTOHEADER} || func_exit 1
2621 echo "executing ${AUTOMAKE} --add-missing --copy"
2622 ${AUTOMAKE} --add-missing --copy || func_exit 1
2624 if test -n "$inctests"; then
2625 # Create autogenerated files.
2626 (cd "$testdir/$testsbase" || func_exit 1
2627 # Do not use "${AUTORECONF} --force --install", because it may invoke
2628 # autopoint, which brings in older versions of some of our .m4 files.
2629 if test -f ../$m4base/gettext.m4; then
2630 echo "executing ${AUTOPOINT} --force"
2631 ${AUTOPOINT} --force || func_exit 1
2632 for f in ../$m4base/*.m4~; do
2633 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2636 echo "executing ${ACLOCAL} -I ../$m4base"
2637 ${ACLOCAL} -I ../$m4base || func_exit 1
2638 if ! test -d ../build-aux; then
2639 echo "executing mkdir ../build-aux"
2642 echo "executing ${AUTOCONF}"
2643 ${AUTOCONF} || func_exit 1
2644 echo "executing ${AUTOHEADER}"
2645 ${AUTOHEADER} || func_exit 1
2646 echo "executing ${AUTOMAKE} --add-missing --copy"
2647 ${AUTOMAKE} --add-missing --copy || func_exit 1
2650 if grep '^BUILT_SOURCES *+=' "$testdir/$sourcebase/Makefile.am" > /dev/null; then
2652 ./configure || func_exit 1
2654 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
2655 make built_sources || func_exit 1
2657 make distclean || func_exit 1
2662 # func_create_megatestdir megatestdir allmodules
2664 # - local_gnulib_dir from --local-dir
2665 # - auxdir directory relative to destdir where to place build aux files
2666 func_create_megatestdir ()
2670 if test -z "$allmodules"; then
2671 allmodules=`func_all_modules`
2675 # First, all modules one by one.
2676 for onemodule in $allmodules; do
2677 func_create_testdir "$megatestdir/$onemodule" $onemodule
2678 func_append megasubdirs "$onemodule "
2680 # Then, all modules all together.
2681 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2682 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2683 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
2684 func_create_testdir "$megatestdir/ALL" "$allmodules"
2685 func_append megasubdirs "ALL"
2687 # Create Makefile.am.
2688 (echo "## Process this file with automake to produce Makefile.in."
2690 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2692 echo "SUBDIRS = $megasubdirs"
2693 ) > "$megatestdir/Makefile.am"
2695 # Create configure.ac.
2696 (echo "# Process this file with autoconf to produce a configure script."
2697 echo "AC_INIT([dummy], [0])"
2698 if test "$auxdir" != "."; then
2699 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2701 echo "AM_INIT_AUTOMAKE"
2703 echo "AC_PROG_MAKE_SET"
2705 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
2706 echo "AC_OUTPUT([Makefile])"
2707 ) > "$megatestdir/configure.ac"
2709 # Create autogenerated files.
2711 # Do not use "${AUTORECONF} --install", because autoreconf operates
2712 # recursively, but the subdirectories are already finished, therefore
2713 # calling autoreconf here would only waste lots of CPU time.
2714 echo "executing ${ACLOCAL}"
2715 ${ACLOCAL} || func_exit 1
2716 echo "executing mkdir build-aux"
2718 echo "executing ${AUTOCONF}"
2719 ${AUTOCONF} || func_exit 1
2720 echo "executing ${AUTOMAKE} --add-missing --copy"
2721 ${AUTOMAKE} --add-missing --copy || func_exit 1
2727 func_fatal_error "no mode specified" ;;
2736 if test -z "$destdir"; then
2739 test -d "$destdir" \
2740 || func_fatal_error "destination directory does not exist: $destdir"
2742 # Prefer configure.ac to configure.in.
2743 if test -f "$destdir"/configure.ac; then
2744 configure_ac="$destdir/configure.ac"
2746 if test -f "$destdir"/configure.in; then
2747 configure_ac="$destdir/configure.in"
2749 func_fatal_error "cannot find $destdir/configure.ac"
2753 # Analyze configure.ac.
2755 guessed_libtool=false
2760 /AC_CONFIG_AUX_DIR/ {
2761 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
2763 /A[CM]_PROG_LIBTOOL/ {
2764 s,^.*$,guessed_libtool=true,p
2766 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
2768 if test -z "$auxdir"; then
2769 auxdir="$guessed_auxdir"
2772 # Determine where to apply func_import.
2773 if test -n "$m4base"; then
2774 # Apply func_import to a particular gnulib directory.
2775 # Any number of additional modules can be given.
2776 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
2777 # First use of gnulib in the given m4base.
2778 test -n "$supplied_libname" || supplied_libname=true
2779 test -n "$sourcebase" || sourcebase="lib"
2780 test -n "$docbase" || docbase="doc"
2781 test -n "$testsbase" || testsbase="tests"
2782 test -n "$macro_prefix" || macro_prefix="gl"
2786 # Apply func_import to all gnulib directories.
2787 # To get this list of directories, look at Makefile.am. (Not at
2788 # configure, because it may be omitted from CVS. Also, don't run
2789 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
2792 if test -f "$destdir"/Makefile.am; then
2793 aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$destdir"/Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'`
2795 for arg in $aclocal_amflags; do
2796 if test -n "$m4dir_is_next"; then
2797 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
2801 if test -f "$destdir/$arg"/gnulib-cache.m4; then
2802 func_append m4dirs " $arg"
2803 m4dirs_count=`expr $m4dirs_count + 1`
2808 if test "X$arg" = "X-I"; then
2816 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
2817 if test -f "$destdir"/aclocal.m4; then
2818 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
2819 sedexpr2='s,^[^/]*$,.,'
2820 sedexpr3='s,/[^/]*$,,'
2821 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
2822 m4dirs_count=`echo "$m4dirs" | wc -l`
2825 if test $m4dirs_count = 0; then
2826 # First use of gnulib in a package.
2827 # Any number of additional modules can be given.
2828 test -n "$supplied_libname" || supplied_libname=true
2829 test -n "$sourcebase" || sourcebase="lib"
2831 test -n "$docbase" || docbase="doc"
2832 test -n "$testsbase" || testsbase="tests"
2833 test -n "$macro_prefix" || macro_prefix="gl"
2836 if test $m4dirs_count = 1; then
2837 # There's only one use of gnulib here. Assume the user means it.
2838 # Any number of additional modules can be given.
2839 for m4base in $m4dirs; do
2843 # Ambiguous - guess what the user meant.
2844 if test $# = 0; then
2845 # No further arguments. Guess the user wants to update all of them.
2846 for m4base in $m4dirs; do
2847 # Perform func_import in a subshell, so that variable values
2849 # local_gnulib_dir, avoidlist, sourcebase, m4base, docbase,
2850 # testsbase, libname, lgpl, makefile_name, libtool, macro_prefix
2851 # don't propagate from one directory to another.
2852 (func_import) || func_exit 1
2856 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
2864 if test -z "$destdir"; then
2865 func_fatal_error "please specify --dir option"
2868 test -d "$destdir" \
2869 || func_fatal_error "could not create destination directory"
2870 test -n "$auxdir" || auxdir="build-aux"
2871 func_create_testdir "$destdir" "$*"
2874 create-megatestdir )
2875 if test -z "$destdir"; then
2876 func_fatal_error "please specify --dir option"
2878 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2879 test -n "$auxdir" || auxdir="build-aux"
2880 func_create_megatestdir "$destdir" "$*"
2884 test -n "$destdir" || destdir=testdir$$
2885 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2886 test -n "$auxdir" || auxdir="build-aux"
2887 func_create_testdir "$destdir" "$*"
2891 ../configure || func_exit 1
2893 make check || func_exit 1
2894 make distclean || func_exit 1
2895 remaining=`find . -type f -print`
2896 if test -n "$remaining"; then
2897 echo "Remaining files:" $remaining 1>&2
2898 echo "gnulib-tool: *** Stop." 1>&2
2907 test -n "$destdir" || destdir=testdir$$
2908 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2909 test -n "$auxdir" || auxdir="build-aux"
2910 func_create_megatestdir "$destdir" "$*"
2918 remaining=`find . -type f -print`
2919 if test -n "$remaining"; then
2920 echo "Remaining files:" $remaining 1>&2
2921 echo "gnulib-tool: *** Stop." 1>&2
2929 extract-description )
2933 if test -n "$module"; then
2934 func_get_description "$module"
2943 if test -n "$module"; then
2944 func_get_filelist "$module"
2949 extract-dependencies )
2953 if test -n "$module"; then
2954 func_get_dependencies "$module"
2959 extract-autoconf-snippet )
2963 if test -n "$module"; then
2964 func_get_autoconf_snippet "$module"
2969 extract-automake-snippet )
2973 if test -n "$module"; then
2974 func_get_automake_snippet "$module"
2979 extract-include-directive )
2983 if test -n "$module"; then
2984 func_get_include_directive "$module"
2993 if test -n "$module"; then
2994 func_get_license "$module"
2999 extract-maintainer )
3003 if test -n "$module"; then
3004 func_get_maintainer "$module"
3009 extract-tests-module )
3013 if test -n "$module"; then
3014 func_get_tests_module "$module"
3020 func_fatal_error "unknown operation mode --$mode" ;;
3024 # Undo the effect of the previous 'trap' command. Some shellology:
3025 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
3026 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
3027 # exit); for the others we need to call 'exit' explicitly. The value of $? is
3028 # 128 + signal number and is set before the trap-registered command is run.
3030 trap 'func_exit $?' 1 2 3 13 15
3035 # indent-tabs-mode: nil
3036 # whitespace-check-buffer-indent: nil