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 3 of the License, or
8 # (at your option) any later version.
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, see <http://www.gnu.org/licenses/>.
19 # This program is meant for authors or maintainers which want to import
20 # modules from gnulib into their packages.
24 cvsdatestamp='$Date: 2007-09-17 10:26:33 $'
25 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
26 # Sometimes last_checkin_date is "YYYY/MM/DD ...", sometimes "YYYY-MM-DD ...".
27 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
28 # version is in YYYY-MM-DD format.
33 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
37 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
38 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
42 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
45 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
48 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
49 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
50 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
51 AUTOCONF="${AUTOCONFPATH}autoconf"
53 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
54 AUTOHEADER="${AUTOCONFPATH}autoheader"
56 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
57 ACLOCAL="${AUTOMAKEPATH}aclocal"
59 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
60 AUTOMAKE="${AUTOMAKEPATH}automake"
62 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
63 AUTORECONF="${AUTOCONFPATH}autoreconf"
66 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
67 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
68 AUTOPOINT="${GETTEXTPATH}autopoint"
71 # When using GNU sed, turn off as many GNU extensions as possible,
72 # to minimize the risk of accidentally using non-portable features.
73 # However, do this only for gnulib-tool itself, not for the code that
74 # gnulib-tool generates, since we don't want "sed --posix" to leak
76 if (alias) > /dev/null 2>&1 && echo | sed --posix -e d >/dev/null 2>&1; then
77 # Define sed as an alias.
78 # It is not always possible to use aliases. Aliases are guaranteed to work
79 # if the executing shell is bash and either it is invoked as /bin/sh or
80 # is a version >= 2.0, supporting shopt. This is the common case.
81 # Two other approaches (use of a variable $sed or of a function func_sed
82 # instead of an alias) require massive, fragile code changes.
83 # An other approach (use of function sed) requires `which sed` - but 'which'
84 # is hard to emulate, due to missing "test -x" on some platforms.
85 if test -n "$BASH_VERSION"; then
86 shopt -s expand_aliases >/dev/null 2>&1
88 alias sed='sed --posix'
92 # outputs to stdout the --help usage message.
96 Usage: gnulib-tool --list
97 gnulib-tool --import [module1 ... moduleN]
99 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
100 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
101 gnulib-tool --test --dir=directory module1 ... moduleN
102 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
103 gnulib-tool --extract-description module
104 gnulib-tool --extract-notice module
105 gnulib-tool --extract-filelist module
106 gnulib-tool --extract-dependencies module
107 gnulib-tool --extract-autoconf-snippet module
108 gnulib-tool --extract-automake-snippet module
109 gnulib-tool --extract-include-directive module
110 gnulib-tool --extract-link-directive module
111 gnulib-tool --extract-license module
112 gnulib-tool --extract-maintainer module
113 gnulib-tool --extract-tests-module module
116 --list print the available module names
117 --import import the given modules into the current package;
118 if no modules are specified, update the current
119 package from the current gnulib
120 --update update the current package, restore files omitted
122 --create-testdir create a scratch package with the given modules
123 --create-megatestdir create a mega scratch package with the given modules
124 one by one and all together
125 --test test the combination of the given modules
126 (recommended to use CC=\"gcc -Wall\" here)
127 --megatest test the given modules one by one and all together
128 (recommended to use CC=\"gcc -Wall\" here)
129 --extract-description extract the description
130 --extract-notice extract the notice or banner
131 --extract-filelist extract the list of files
132 --extract-dependencies extract the dependencies
133 --extract-autoconf-snippet extract the snippet for configure.ac
134 --extract-automake-snippet extract the snippet for library makefile
135 --extract-include-directive extract the #include directive
136 --extract-link-directive extract the linker directive
137 --extract-license report the license terms of the source files
139 --extract-maintainer report the maintainer(s) inside gnulib
140 --extract-tests-module report the unit test module, if it exists
143 --dir=DIRECTORY Specify the target directory.
144 For --import, this specifies where your
145 configure.ac can be found. Defaults to current
147 --local-dir=DIRECTORY Specify a local override directory where to look
148 up files before looking in gnulib's directory.
149 --verbose Increase verbosity. May be repeated.
150 --quiet Decrease verbosity. May be repeated.
152 Options for --import:
153 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
154 --source-base=DIRECTORY
155 Directory relative to --dir where source code is
156 placed (default \"lib\").
157 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
158 placed (default \"m4\").
159 --po-base=DIRECTORY Directory relative to --dir where *.po files are
160 placed (default \"po\").
161 --doc-base=DIRECTORY Directory relative to --dir where doc files are
162 placed (default \"doc\").
163 --tests-base=DIRECTORY
164 Directory relative to --dir where unit tests are
165 placed (default \"tests\").
166 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
167 tools are placed (default \"build-aux\").
168 --with-tests Include unit tests for the included modules.
169 --avoid=MODULE Avoid including the given MODULE. Useful if you
170 have code that provides equivalent functionality.
171 This option can be repeated.
172 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
173 Also modify license template from GPL to LGPL.
174 The version number of the LGPL can be specified;
175 the default is currently LGPLv3.
176 --makefile-name=NAME Name of makefile in automake syntax in the
177 source-base and tests-base directories
178 (default \"Makefile.am\").
179 --libtool Use libtool rules.
180 --no-libtool Don't use libtool rules.
181 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
182 'gl_INIT'. Default is 'gl'.
183 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
184 the package name. A suffix '-gnulib' is appended.
185 --no-changelog don't update or create ChangeLog files
187 Options for --import and --update:
188 --dry-run For --import, only print what would have been done.
189 -s, --symbolic, --symlink Make symbolic links instead of copying files.
190 --local-symlink Make symbolic links instead of copying files, only
191 for files from the local override directory.
192 -S, --more-symlinks Make symbolic links instead of copying files, and
193 don't replace copyright notices.
195 Report bugs to <bug-gnulib@gnu.org>."
199 # outputs to stdout the --version message.
202 year=`echo "$version" | sed -e 's,-.*$,,'`
204 $progname (GNU $package) $version
205 Copyright (C) $year Free Software Foundation, Inc.
206 This is free software; see the source for copying conditions. There is NO
207 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
208 Written by" "Bruno Haible" "and" "Simon Josefsson"
211 # func_emit_copyright_notice
212 # outputs to stdout a header for a generated file.
213 func_emit_copyright_notice ()
215 echo "# Copyright (C) 2004-2007 Free Software Foundation, Inc."
217 echo "# This file is free software, distributed under the terms of the GNU"
218 echo "# General Public License. As a special exception to the GNU General"
219 echo "# Public License, this file may be distributed as part of a program"
220 echo "# that contains a configuration script generated by Autoconf, under"
221 echo "# the same distribution terms as the rest of that program."
223 echo "# Generated by gnulib-tool."
234 # creates a temporary directory.
236 # - tmp pathname of freshly created temporary directory
239 # Use the environment variable TMPDIR, falling back to /tmp. This allows
240 # users to specify a different temporary directory, for example, if their
241 # /tmp is filled up or too small.
244 # Use the mktemp program if available. If not available, hide the error
246 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
247 test -n "$tmp" && test -d "$tmp"
250 # Use a simple mkdir command. It is guaranteed to fail if the directory
251 # already exists. $RANDOM is bash specific and expands to empty in shells
252 # other than bash, ksh and zsh. Its use does not increase security;
253 # rather, it minimizes the probability of failure in a very cluttered /tmp
255 tmp=$TMPDIR/gl$$-$RANDOM
256 (umask 077 && mkdir "$tmp")
259 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
264 # func_append var value
265 # appends the given value to the shell variable var.
266 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
267 # Use bash's += operator. It reduces complexity of appending repeatedly to
268 # a single variable from O(n^2) to O(n).
276 eval "$1=\"\$$1\$2\""
280 # func_fatal_error message
281 # outputs to stderr a fatal error message, and terminates the program.
284 echo "gnulib-tool: *** $1" 1>&2
285 echo "gnulib-tool: *** Stop." 1>&2
289 # func_readlink SYMLINK
290 # outputs the target of the given symlink.
291 if (type -p readlink) > /dev/null 2>&1; then
294 # Use the readlink program from GNU coreutils.
300 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
301 # would do the wrong thing if the link target contains " -> ".
302 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
306 # func_relativize DIR1 DIR2
307 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
309 # - DIR1 relative pathname, relative to the current directory
310 # - DIR2 relative pathname, relative to the current directory
312 # - reldir relative pathname of DIR2, relative to DIR1
318 sed_first='s,^\([^/]*\)/.*$,\1,'
319 sed_rest='s,^[^/]*/*,,'
320 sed_last='s,^.*/\([^/]*\)$,\1,'
321 sed_butlast='s,/*[^/]*$,,'
322 while test -n "$dir1"; do
323 first=`echo "$dir1" | sed -e "$sed_first"`
324 if test "$first" != "."; then
325 if test "$first" = ".."; then
326 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
327 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
329 first2=`echo "$dir2" | sed -e "$sed_first"`
330 if test "$first2" = "$first"; then
331 dir2=`echo "$dir2" | sed -e "$sed_rest"`
335 dir0="$dir0"/"$first"
338 dir1=`echo "$dir1" | sed -e "$sed_rest"`
343 # func_relconcat DIR1 DIR2
344 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
346 # - DIR1 relative pathname, relative to the current directory
347 # - DIR2 relative pathname, relative to DIR1
349 # - relconcat DIR1/DIR2, relative to the current directory
354 sed_first='s,^\([^/]*\)/.*$,\1,'
355 sed_rest='s,^[^/]*/*,,'
356 sed_last='s,^.*/\([^/]*\)$,\1,'
357 sed_butlast='s,/*[^/]*$,,'
359 first=`echo "$dir2" | sed -e "$sed_first"`
360 if test "$first" = "."; then
361 dir2=`echo "$dir2" | sed -e "$sed_rest"`
362 if test -z "$dir2"; then
367 last=`echo "$dir1" | sed -e "$sed_last"`
368 while test "$last" = "."; do
369 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
370 last=`echo "$dir1" | sed -e "$sed_last"`
372 if test -z "$dir1"; then
376 if test "$first" = ".."; then
377 if test "$last" = ".."; then
378 relconcat="$dir1/$dir2"
381 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
382 dir2=`echo "$dir2" | sed -e "$sed_rest"`
383 if test -z "$dir1"; then
387 if test -z "$dir2"; then
392 relconcat="$dir1/$dir2"
400 # Like ln -s, except that SRC is given relative to the current directory (or
401 # absolute), not given relative to the directory of DEST.
407 *) # SRC is relative.
410 ln -s "`pwd`/$1" "$2" ;;
411 *) # DEST is relative too.
412 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
413 test -n "$ln_destdir" || ln_destdir="."
414 func_relativize "$ln_destdir" "$1"
422 # func_ln_if_changed SRC DEST
423 # Like func_ln, but avoids munging timestamps if the link is correct.
424 func_ln_if_changed ()
426 if test $# -ne 2; then
427 echo "usage: func_ln_if_changed SRC DEST" >&2
429 ln_target=`func_readlink "$2"`
430 if test -h "$2" && test "$1" = "$ln_target"; then
438 # Ensure an 'echo' command that does not interpret backslashes.
440 # echo '\n' | wc -l prints 1 when OK, 2 when KO
441 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
442 # This problem is a weird heritage from SVR4. BSD got it right (except that
443 # BSD echo interprets '-n' as an option, which is also not desirable).
444 # Nowadays the problem occurs in 4 situations:
445 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
446 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
447 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
448 # - in zsh, when sh-emulation is not set,
449 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
450 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
451 # - in Solaris /bin/sh and OSF/1 /bin/sh.
452 # We try the following workarounds:
453 # - for all: respawn using $CONFIG_SHELL if that is set and works.
454 # - for bash >= 2.04: unset the shell option xpg_echo.
455 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
456 # - for bash < 2.0: define echo to a function that uses cat of a here document.
457 # - for zsh: turn sh-emulation on.
458 # - for ksh: alias echo to 'print -r'.
459 # - for ksh: alias echo to a function that uses cat of a here document.
460 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
461 # the ksh workaround.
462 # - otherwise: respawn using /bin/sh and rely on the workarounds.
463 # When respawning, we pass --no-reexec as first argument, so as to avoid
464 # turning this script into a fork bomb in unlucky situations.
466 if echo '\t' | grep t > /dev/null; then
467 have_echo=yes # Lucky!
469 # Try the workarounds.
470 # Respawn using $CONFIG_SHELL if that is set and works.
471 if test -z "$have_echo" \
472 && test "X$1" != "X--no-reexec" \
473 && test -n "$CONFIG_SHELL" \
474 && test -f "$CONFIG_SHELL" \
475 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
476 exec $CONFIG_SHELL "$0" --no-reexec "$@"
479 # For bash >= 2.04: unset the shell option xpg_echo.
480 if test -z "$have_echo" \
481 && test -n "$BASH_VERSION" \
482 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
486 # For bash >= 2.0: define echo to a function that uses the printf built-in.
487 # For bash < 2.0: define echo to a function that uses cat of a here document.
488 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
489 if test -z "$have_echo" \
490 && test -n "$BASH_VERSION"; then \
491 if type printf 2>/dev/null | grep / > /dev/null; then
492 # 'printf' is not a shell built-in.
500 # 'printf' is a shell built-in.
506 if echo '\t' | grep t > /dev/null; then
510 # For zsh: turn sh-emulation on.
511 if test -z "$have_echo" \
512 && test -n "$ZSH_VERSION" \
513 && (emulate sh) >/dev/null 2>&1; then
516 # For ksh: alias echo to 'print -r'.
517 if test -z "$have_echo" \
518 && (type print) >/dev/null 2>&1; then
519 # A 'print' command exists.
520 if type print 2>/dev/null | grep / > /dev/null; then
523 # 'print' is a shell built-in.
524 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
525 # 'print' is the ksh shell built-in.
526 alias echo='print -r'
530 if test -z "$have_echo" \
531 && echo '\t' | grep t > /dev/null; then
534 # For ksh: alias echo to a function that uses cat of a here document.
535 # The ksh manual page says:
536 # "Aliasing is performed when scripts are read, not while they are executed.
537 # Therefore, for an alias to take effect, the alias definition command has
538 # to be executed before the command which references the alias is read."
539 # Because of this, we have to play strange tricks with have_echo, to ensure
540 # that the top-level statement containing the test starts after the 'alias'
542 if test -z "$have_echo"; then
549 alias echo=bsd_echo 2>/dev/null
551 if test -z "$have_echo" \
552 && echo '\t' | grep t > /dev/null; then
555 if test -z "$have_echo"; then
556 unalias echo 2>/dev/null
558 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
559 if test -z "$have_echo" \
560 && test "X$1" != "X--no-reexec" \
561 && test -f /bin/ksh; then
562 exec /bin/ksh "$0" --no-reexec "$@"
565 # Otherwise: respawn using /bin/sh.
566 if test -z "$have_echo" \
567 && test "X$1" != "X--no-reexec" \
568 && test -f /bin/sh; then
569 exec /bin/sh "$0" --no-reexec "$@"
572 if test -z "$have_echo"; then
573 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
575 if echo '\t' | grep t > /dev/null; then
578 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
580 if test "X$1" = "X--no-reexec"; then
584 # Command-line option processing.
585 # Removes the OPTIONS from the arguments. Sets the variables:
586 # - mode list or import or create-testdir or create-megatestdir
587 # - destdir from --dir
588 # - local_gnulib_dir from --local-dir
589 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
590 # - libname, supplied_libname from --lib
591 # - sourcebase from --source-base
592 # - m4base from --m4-base
593 # - pobase from --po-base
594 # - docbase from --doc-base
595 # - testsbase from --tests-base
596 # - auxdir from --aux-dir
597 # - inctests true if --with-tests was given, blank otherwise
598 # - avoidlist list of modules to avoid, from --avoid
599 # - lgpl yes or a number if --lgpl was given, blank otherwise
600 # - makefile_name from --makefile-name
601 # - libtool true if --libtool was given, false if --no-libtool was
602 # given, blank otherwise
603 # - macro_prefix from --macro-prefix
604 # - po_domain from --po-domain
605 # - autoconf_minversion minimum supported autoconf version
606 # - do_changelog false if --no-changelog was given, : otherwise
607 # - doit : if actions shall be executed, false if only to be printed
608 # - symbolic true if --symlink or --more-symlinks was given, blank
610 # - lsymbolic true if --local-symlink was given, blank otherwise
611 # - do_copyrights blank if --more-symlinks was given, true otherwise
640 while test $# -gt 0; do
645 --import | --impor | --impo | --imp | --im | --i )
648 --update | --updat | --upda | --upd | --up | --u )
651 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
654 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
655 mode=create-megatestdir
657 --test | --tes | --te | --t )
660 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
664 mode=`echo "X$1" | sed -e 's/^X--//'`
669 func_fatal_error "missing argument for --dir"
674 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
679 func_fatal_error "missing argument for --local-dir"
684 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
686 --verbose | --verbos | --verbo | --verb )
687 verbose=`expr $verbose + 1`
689 --quiet | --quie | --qui | --qu | --q )
690 verbose=`expr $verbose - 1`
695 func_fatal_error "missing argument for --lib"
698 supplied_libname=true
701 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
702 supplied_libname=true
707 func_fatal_error "missing argument for --source-base"
712 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
717 func_fatal_error "missing argument for --m4-base"
722 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
727 func_fatal_error "missing argument for --po-base"
732 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
737 func_fatal_error "missing argument for --doc-base"
742 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
747 func_fatal_error "missing argument for --tests-base"
752 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
757 func_fatal_error "missing argument for --aux-dir"
762 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
770 func_fatal_error "missing argument for --avoid"
772 func_append avoidlist " $1"
775 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
776 func_append avoidlist " $arg"
782 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
785 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
792 func_fatal_error "missing argument for --makefile-name"
797 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
808 func_fatal_error "missing argument for --macro-prefix"
813 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
818 func_fatal_error "missing argument for --po-domain"
823 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
825 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
831 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
834 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
837 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
841 --help | --hel | --he | --h )
844 --version | --versio | --versi | --vers )
848 # Stop option processing
852 echo "gnulib-tool: unknown option $1" 1>&2
853 echo "Try 'gnulib-tool --help' for more information." 1>&2
860 if test "$mode" = update; then
861 if test $# != 0; then
862 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
863 echo "Try 'gnulib-tool --help' for more information." 1>&2
864 echo "If you really want to modify the gnulib configuration of your project," 1>&2
865 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
868 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
869 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
870 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
871 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
872 || test -n "$makefile_name" || test -n "$macro_prefix" \
873 || test -n "$po_domain"; then
874 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
875 echo "Try 'gnulib-tool --help' for more information." 1>&2
876 echo "If you really want to modify the gnulib configuration of your project," 1>&2
877 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
882 if test -n "$pobase" && test -z "$po_domain"; then
883 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
884 echo "Try 'gnulib-tool --help' for more information." 1>&2
887 if test -z "$pobase" && test -n "$po_domain"; then
888 echo "gnulib-tool: warning: --po-domain has no effect without a --po-base option" 1>&2
891 # Determine the minimum supported autoconf version from the project's
893 DEFAULT_AUTOCONF_MINVERSION="2.59"
896 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
897 if test -f "$destdir"/configure.ac; then
898 configure_ac="$destdir/configure.ac"
900 if test -f "$destdir"/configure.in; then
901 configure_ac="$destdir/configure.in"
905 if test -f configure.ac; then
906 configure_ac="configure.ac"
908 if test -f configure.in; then
909 configure_ac="configure.in"
913 if test -n "$configure_ac"; then
914 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
915 # because when some m4 files are omitted from a CVS repository,
916 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
917 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
918 # autom4te: m4 failed with exit status: 1
925 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
927 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
928 if test -n "$prereqs"; then
929 autoconf_minversion=`
930 for version in $prereqs; do echo $version; done |
931 LC_ALL=C sort -nru | sed 1q
935 if test -z "$autoconf_minversion"; then
936 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
938 case "$autoconf_minversion" in
939 1.* | 2.[0-4]* | 2.5[0-8]*)
940 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
943 # Remove trailing slashes from the directory names. This is necessary for
944 # m4base (to avoid an error in func_import) and optional for the others.
945 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
946 case "$local_gnulib_dir" in
947 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
949 case "$sourcebase" in
950 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
953 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
956 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
959 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
962 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
965 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
970 /*) self_abspathname="$0" ;;
971 */*) self_abspathname=`pwd`/"$0" ;;
974 # Iterate through the elements of $PATH.
975 # We use IFS=: instead of
976 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
977 # because the latter does not work when some PATH element contains spaces.
978 # We use a canonicalized $pathx instead of $PATH, because empty PATH
979 # elements are by definition equivalent to '.', however field splitting
980 # according to IFS=: loses empty fields in many shells:
981 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
982 # beginning, at the end, and in the middle),
983 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
984 # at the beginning and at the end,
985 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
986 # Solaris lose empty fields at the end.
987 # The 'case' statement is an optimization, to avoid evaluating the
988 # explicit canonicalization command when $PATH contains no empty fields.
990 if test "${PATH_SEPARATOR+set}" != set; then
992 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
993 chmod +x "$tmp"/conf.sh
994 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
1001 if test "$PATH_SEPARATOR" = ";"; then
1002 # On Windows, programs are searched in "." before $PATH.
1005 # On Unix, we have to convert empty PATH elements to ".".
1009 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
1014 IFS="$PATH_SEPARATOR"
1018 if test -x "$d/$0" && test ! -d "$d/$0"; then
1019 self_abspathname="$d/$0"
1024 if test -z "$self_abspathname"; then
1025 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
1029 while test -h "$self_abspathname"; do
1030 # Resolve symbolic link.
1031 linkval=`func_readlink "$self_abspathname"`
1032 test -n "$linkval" || break
1034 /* ) self_abspathname="$linkval" ;;
1035 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
1038 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
1041 trap 'exit_status=$?
1042 if test "$signal" != 0; then
1043 echo "caught signal $signal" >&2
1046 exit $exit_status' 0
1047 for signal in 1 2 3 13 15; do
1048 trap '{ signal='$signal'; func_exit 1; }' $signal
1052 # func_lookup_file file
1053 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1056 # - local_gnulib_dir from --local-dir
1058 # - lookedup_file name of the merged (combined) file
1059 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1063 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1064 lookedup_file="$local_gnulib_dir/$lkfile"
1067 if test -f "$gnulib_dir/$lkfile"; then
1068 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1069 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1070 rm -f "$tmp/$lkbase"
1071 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1072 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1073 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1074 lookedup_file="$tmp/$lkbase"
1077 lookedup_file="$gnulib_dir/$lkfile"
1081 func_fatal_error "file $gnulib_dir/$lkfile not found"
1088 # - local_gnulib_dir from --local-dir
1091 # Filter out metainformation files like README, which are not modules.
1092 # Filter out unit test modules; they can be retrieved through
1093 # --extract-tests-module if desired.
1095 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1096 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1097 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1100 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1101 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1102 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1103 -e '/^README$/d' -e '/\/README$/d' \
1104 -e '/^TEMPLATE$/d' \
1105 -e '/^TEMPLATE-EXTENDED$/d' \
1106 -e '/^TEMPLATE-TESTS$/d' \
1109 | sed -e '/-tests$/d' \
1113 # func_verify_module
1114 # verifies a module name
1116 # - local_gnulib_dir from --local-dir
1117 # - module module name argument
1118 func_verify_module ()
1120 if { test -f "$gnulib_dir/modules/$module" \
1121 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1122 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1123 && test "CVS" != "$module" \
1124 && test "ChangeLog" != "$module" \
1125 && test "COPYING" != "$module" \
1126 && test "README" != "$module" \
1127 && test "TEMPLATE" != "$module" \
1128 && test "TEMPLATE-EXTENDED" != "$module" \
1129 && test "TEMPLATE-TESTS" != "$module"; then
1130 # OK, $module is a correct module name.
1131 # Verify that building the module description with 'patch' succeeds.
1132 func_lookup_file "modules/$module"
1134 echo "gnulib-tool: module $module doesn't exist" 1>&2
1139 # func_verify_nontests_module
1140 # verifies a module name, excluding tests modules
1142 # - local_gnulib_dir from --local-dir
1143 # - module module name argument
1144 func_verify_nontests_module ()
1147 *-tests ) module= ;;
1148 * ) func_verify_module ;;
1152 # func_verify_tests_module
1153 # verifies a module name, considering only tests modules
1155 # - local_gnulib_dir from --local-dir
1156 # - module module name argument
1157 func_verify_tests_module ()
1160 *-tests ) func_verify_module ;;
1165 sed_extract_prog=':[ ]*$/ {
1168 s/^Description:[ ]*$//
1171 s/^Depends-on:[ ]*$//
1172 s/^configure\.ac-early:[ ]*$//
1173 s/^configure\.ac:[ ]*$//
1174 s/^Makefile\.am:[ ]*$//
1178 s/^Maintainer:[ ]*$//
1185 # func_get_description module
1187 # - local_gnulib_dir from --local-dir
1188 func_get_description ()
1190 func_lookup_file "modules/$1"
1191 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1194 # func_get_notice module
1196 # - local_gnulib_dir from --local-dir
1199 func_lookup_file "modules/$1"
1200 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1203 # func_get_filelist module
1205 # - local_gnulib_dir from --local-dir
1206 func_get_filelist ()
1208 func_lookup_file "modules/$1"
1209 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1210 echo m4/gnulib-common.m4
1211 case "$autoconf_minversion" in
1213 #echo m4/onceonly.m4
1214 echo m4/onceonly_2_57.m4
1219 # func_get_dependencies module
1221 # - local_gnulib_dir from --local-dir
1222 func_get_dependencies ()
1224 # ${module}-tests always implicitly depends on ${module}.
1225 echo "$1" | sed -n -e 's/-tests$//p'
1226 # Then the explicit dependencies listed in the module description.
1227 func_lookup_file "modules/$1"
1228 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1231 # func_get_autoconf_early_snippet module
1233 # - local_gnulib_dir from --local-dir
1234 func_get_autoconf_early_snippet ()
1236 func_lookup_file "modules/$1"
1237 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1240 # func_get_autoconf_snippet module
1242 # - local_gnulib_dir from --local-dir
1243 func_get_autoconf_snippet ()
1245 func_lookup_file "modules/$1"
1246 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1249 # func_get_automake_snippet module
1251 # - local_gnulib_dir from --local-dir
1252 func_get_automake_snippet ()
1254 func_lookup_file "modules/$1"
1255 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1258 # *-tests module live in tests/, not lib/.
1259 # Synthesize an EXTRA_DIST augmentation.
1260 all_files=`func_get_filelist $1`
1261 tests_files=`for f in $all_files; do \
1263 tests/*) echo $f ;; \
1265 done | sed -e 's,^tests/,,'`
1266 extra_files="$tests_files"
1267 if test -n "$extra_files"; then
1268 echo "EXTRA_DIST +=" $extra_files
1273 # Synthesize an EXTRA_DIST augmentation.
1274 sed_combine_lines='/\\$/{
1281 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1282 already_mentioned_files=` \
1283 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1284 | sed -e "$sed_combine_lines" \
1285 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1286 all_files=`func_get_filelist $1`
1287 lib_files=`for f in $all_files; do \
1291 done | sed -e 's,^lib/,,'`
1292 # Remove $already_mentioned_files from $lib_files.
1293 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1294 extra_files=`for f in $already_mentioned_files; do echo $f; done \
1295 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1296 if test -n "$extra_files"; then
1297 echo "EXTRA_DIST +=" $extra_files
1300 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1301 # This is necessary so that automake can generate the right list of
1303 # A possible approach would be to use autom4te --trace of the redefined
1304 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1305 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1306 # inside autoconf's built-in macros are not missed).
1307 # But it's simpler and more robust to do it here, based on the file list.
1308 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1309 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1310 # automake will generate a useless dependency; this is harmless.
1312 relocatable-prog-wrapper) ;;
1314 sed_extract_c_files='/\.c$/p'
1315 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1316 if test -n "$extra_files"; then
1317 echo "EXTRA_lib_SOURCES +=" $extra_files
1322 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1323 buildaux_files=`for f in $all_files; do \
1325 build-aux/*) echo $f ;; \
1327 done | sed -e 's,^build-aux/,,'`
1328 if test -n "$buildaux_files"; then
1329 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1330 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1337 # func_get_include_directive module
1339 # - local_gnulib_dir from --local-dir
1340 func_get_include_directive ()
1342 func_lookup_file "modules/$1"
1343 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1344 sed -e 's/^\(["<]\)/#include \1/'
1347 # func_get_link_directive module
1349 # - local_gnulib_dir from --local-dir
1350 func_get_link_directive ()
1352 func_lookup_file "modules/$1"
1353 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1356 # func_get_license module
1358 # - local_gnulib_dir from --local-dir
1361 func_lookup_file "modules/$1"
1362 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1363 # The default is GPL.
1365 } | sed -e 's,^ *$,,' | sed -e 1q
1368 # func_get_maintainer module
1370 # - local_gnulib_dir from --local-dir
1371 func_get_maintainer ()
1373 func_lookup_file "modules/$1"
1374 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1377 # func_get_tests_module module
1379 # - local_gnulib_dir from --local-dir
1380 func_get_tests_module ()
1382 # The naming convention for tests modules is hardwired: ${module}-tests.
1383 if test -f "$gnulib_dir/modules/$1"-tests \
1384 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1385 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1390 # func_acceptable module
1391 # tests whether a module is acceptable.
1393 # - avoidlist list of modules to avoid
1396 for avoid in $avoidlist; do
1397 if test "$avoid" = "$1"; then
1404 # func_modules_transitive_closure
1406 # - local_gnulib_dir from --local-dir
1407 # - modules list of specified modules
1408 # - inctests true if tests should be included, blank otherwise
1409 # - avoidlist list of modules to avoid
1410 # - tmp pathname of a temporary directory
1412 # - modules list of modules, including dependencies
1413 func_modules_transitive_closure ()
1415 # In order to process every module only once (for speed), process an "input
1416 # list" of modules, producing an "output list" of modules. During each round,
1417 # more modules can be queued in the input list. Once a module on the input
1418 # list has been processed, it is added to the "handled list", so we can avoid
1419 # to process it again.
1421 inmodules="$modules"
1423 while test -n "$inmodules"; do
1424 inmodules_this_round="$inmodules"
1425 inmodules= # Accumulator, queue for next round
1426 for module in $inmodules_this_round; do
1428 if test -n "$module"; then
1429 if func_acceptable $module; then
1430 func_append outmodules " $module"
1431 deps=`func_get_dependencies $module`
1432 # Duplicate dependencies are harmless, but Jim wants a warning.
1433 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1434 if test -n "$duplicated_deps"; then
1435 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1437 func_append inmodules " $deps"
1438 if test -n "$inctests"; then
1439 testsmodule=`func_get_tests_module $module`
1440 if test -n "$testsmodule"; then
1441 func_append inmodules " $testsmodule"
1447 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1448 # Remove $handledmodules from $inmodules.
1449 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1450 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1452 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1453 rm -f "$tmp"/queued-modules
1456 # func_modules_add_dummy
1458 # - local_gnulib_dir from --local-dir
1459 # - modules list of modules, including dependencies
1461 # - modules list of modules, including 'dummy' if needed
1462 func_modules_add_dummy ()
1465 sed_remove_backslash_newline=':a
1472 for module in $modules; do
1473 func_verify_nontests_module
1474 if test -n "$module"; then
1475 # Extract the value of "lib_SOURCES += ...".
1476 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1477 # Ignore .h files since they are not compiled.
1480 *) have_lib_SOURCES=yes ;;
1485 # Add the dummy module, to make sure the library will be non-empty.
1486 if test -z "$have_lib_SOURCES"; then
1487 if func_acceptable "dummy"; then
1488 func_append modules " dummy"
1493 # func_modules_notice
1495 # - local_gnulib_dir from --local-dir
1496 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1497 # - modules list of modules, including dependencies
1498 func_modules_notice ()
1500 if test $verbose -ge -1; then
1501 for module in $modules; do
1503 if test -n "$module"; then
1504 msg=`func_get_notice $module`
1505 if test -n "$msg"; then
1506 echo "Notice from module $module:"
1507 echo "$msg" | sed -e 's/^/ /'
1514 # func_modules_to_filelist
1516 # - local_gnulib_dir from --local-dir
1517 # - modules list of modules, including dependencies
1519 # - files list of files
1520 func_modules_to_filelist ()
1523 for module in $modules; do
1525 if test -n "$module"; then
1526 fs=`func_get_filelist $module`
1527 func_append files " $fs"
1530 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1533 # func_execute_command command [args...]
1534 # Executes a command.
1535 # Uses also the variables
1536 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1537 func_execute_command ()
1539 if test $verbose -ge 0; then
1543 # Commands like automake produce output to stderr even when the succeed.
1544 # Turn this output off if the command succeeds.
1545 "$@" > "$tmp"/cmdout 2>&1
1547 if test $cmdret = 0; then
1551 cat "$tmp"/cmdout 1>&2
1558 # func_emit_lib_Makefile_am
1559 # emits the contents of library makefile to standard output.
1561 # - local_gnulib_dir from --local-dir
1562 # - modules list of modules, including dependencies
1563 # - libname library name
1564 # - pobase directory relative to destdir where to place *.po files
1565 # - auxdir directory relative to destdir where to place build aux files
1566 # - makefile_name from --makefile-name
1567 # - libtool true if libtool will be used, false or blank otherwise
1568 # - macro_prefix prefix of gl_LIBOBJS macros to use
1569 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1570 # - actioncmd (optional) command that will reproduce this invocation
1571 # - for_test true if creating a package for testing, false otherwise
1573 # - uses_subdirs nonempty if object files in subdirs exist
1574 func_emit_lib_Makefile_am ()
1576 # When creating an includable Makefile.am snippet, augment variables with
1577 # += instead of assigning them.
1578 if test -n "$makefile_name"; then
1583 if test "$libtool" = true; then
1586 sed_eliminate_LDFLAGS=
1590 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1593 # When creating a package for testing: Attempt to provoke failures,
1594 # especially link errors, already during "make" rather than during
1595 # "make check", because "make check" is not possible in a cross-compiling
1596 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1597 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1599 sed_transform_check_PROGRAMS=
1601 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1602 echo "## Process this file with automake to produce Makefile.in."
1603 func_emit_copyright_notice
1604 if test -n "$actioncmd"; then
1605 echo "# Reproduce by: $actioncmd"
1610 for module in $modules; do
1611 func_verify_nontests_module
1612 if test -n "$module"; then
1614 func_get_automake_snippet "$module" |
1615 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1616 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1617 -e "$sed_eliminate_LDFLAGS" \
1618 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1619 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1620 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1621 -e "$sed_transform_check_PROGRAMS"
1622 if test "$module" = 'alloca'; then
1623 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1624 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1627 # Skip the contents if its entirely empty.
1628 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1629 echo "## begin gnulib module $module"
1632 echo "## end gnulib module $module"
1636 # Test whether there are some source files in subdirectories.
1637 for f in `func_get_filelist "$module"`; do
1639 lib/*/*.c) uses_subdirs=yes ;;
1645 if test -z "$makefile_name"; then
1646 # If there are source files in subdirectories, prevent collision of the
1647 # object files (example: hash.c and libxml/hash.c).
1649 if test -n "$uses_subdirs"; then
1650 subdir_options=' subdir-objects'
1652 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1655 if test -z "$makefile_name"; then
1656 echo "noinst_HEADERS ="
1657 echo "noinst_LIBRARIES ="
1658 echo "noinst_LTLIBRARIES ="
1659 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1660 # if you specify pkgdata_DATA to empty. This is a workaround.
1661 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1662 echo "pkgdata_DATA ="
1665 echo "BUILT_SOURCES ="
1668 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1669 if test -z "$makefile_name"; then
1670 echo "MOSTLYCLEANDIRS ="
1672 echo "DISTCLEANFILES ="
1673 echo "MAINTAINERCLEANFILES ="
1675 echo "AM_CPPFLAGS ="
1678 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1679 # One of the snippets already specifies an installation location for the
1680 # library. Don't confuse automake by saying it should not be installed.
1683 # By default, the generated library should not be installed.
1684 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1687 echo "${libname}_${libext}_SOURCES ="
1688 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1689 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1690 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1691 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1692 echo "EXTRA_${libname}_${libext}_SOURCES ="
1693 if test "$libtool" = true; then
1694 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1697 if test -n "$pobase"; then
1698 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
1701 cat allsnippets.tmp \
1702 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1704 echo "mostlyclean-local: mostlyclean-generic"
1705 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1706 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1707 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1711 rm -f allsnippets.tmp
1714 # func_emit_po_Makevars
1715 # emits the contents of po/ makefile parametrization to standard output.
1717 # - local_gnulib_dir from --local-dir
1718 # - sourcebase directory relative to destdir where to place source code
1719 # - pobase directory relative to destdir where to place *.po files
1720 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1721 func_emit_po_Makevars ()
1723 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1724 func_emit_copyright_notice
1726 echo "# Usually the message domain is the same as the package name."
1727 echo "# But here it has a '-gnulib' suffix."
1728 echo "DOMAIN = ${po_domain}-gnulib"
1730 echo "# These two variables depend on the location of this directory."
1731 echo "subdir = ${pobase}"
1732 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
1735 # These options get passed to xgettext.
1736 XGETTEXT_OPTIONS = \
1737 --keyword=_ --flag=_:1:pass-c-format \
1738 --keyword=N_ --flag=N_:1:pass-c-format \
1739 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
1740 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
1741 --flag=error:3:c-format --flag=error_at_line:5:c-format
1743 # This is the copyright holder that gets inserted into the header of the
1744 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
1745 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
1747 # This is the email address or URL to which the translators shall report
1748 # bugs in the untranslated strings:
1749 # - Strings which are not entire sentences, see the maintainer guidelines
1750 # in the GNU gettext documentation, section 'Preparing Strings'.
1751 # - Strings which use unclear terms or require additional context to be
1753 # - Strings which make invalid assumptions about notation of date, time or
1755 # - Pluralisation problems.
1756 # - Incorrect English spelling.
1757 # - Incorrect formatting.
1758 # It can be your email address, or a mailing list address where translators
1759 # can write to without being subscribed, or the URL of a web page through
1760 # which the translators can contact you.
1761 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
1763 # This is the list of locale categories, beyond LC_MESSAGES, for which the
1764 # message catalogs shall be used. It is usually empty.
1765 EXTRA_LOCALE_CATEGORIES =
1767 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
1768 # context. Possible values are "yes" and "no". Set this to yes if the
1769 # package uses functions taking also a message context, like pgettext(), or
1770 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
1775 # func_emit_po_POTFILES_in
1776 # emits the file list to be passed to xgettext to standard output.
1778 # - local_gnulib_dir from --local-dir
1779 # - sourcebase directory relative to destdir where to place source code
1780 # - files list of new files
1781 func_emit_po_POTFILES_in ()
1783 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1784 func_emit_copyright_notice
1786 echo "# List of files which contain translatable strings."
1787 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
1790 # func_emit_tests_Makefile_am
1791 # emits the contents of tests makefile to standard output.
1793 # - local_gnulib_dir from --local-dir
1794 # - modules list of modules, including dependencies
1795 # - libname library name
1796 # - auxdir directory relative to destdir where to place build aux files
1797 # - makefile_name from --makefile-name
1798 # - libtool true if libtool will be used, false or blank otherwise
1799 # - sourcebase relative directory containing lib source code
1800 # - m4base relative directory containing autoconf macros
1801 # - testsbase relative directory containing unit test code
1802 # - macro_prefix prefix of gl_LIBOBJS macros to use
1803 # - for_test true if creating a package for testing, false otherwise
1804 # - use_libtests true if a libtests.a should be built, false otherwise
1806 # - uses_subdirs nonempty if object files in subdirs exist
1807 func_emit_tests_Makefile_am ()
1809 if test "$libtool" = true; then
1811 sed_eliminate_LDFLAGS=
1814 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1817 # When creating a package for testing: Attempt to provoke failures,
1818 # especially link errors, already during "make" rather than during
1819 # "make check", because "make check" is not possible in a cross-compiling
1820 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1821 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1823 sed_transform_check_PROGRAMS=
1825 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1826 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1827 echo "## Process this file with automake to produce Makefile.in."
1828 func_emit_copyright_notice
1832 for module in $modules; do
1834 func_verify_tests_module
1838 if test -n "$module"; then
1840 func_get_automake_snippet "$module" |
1841 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1842 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1843 -e "$sed_eliminate_LDFLAGS" \
1844 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
1845 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1846 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1847 -e "$sed_transform_check_PROGRAMS"
1848 if $use_libtests && test "$module" = 'alloca'; then
1849 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
1850 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1853 # Skip the contents if its entirely empty.
1854 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1855 echo "## begin gnulib module $module"
1858 echo "## end gnulib module $module"
1862 # Test whether there are some source files in subdirectories.
1863 for f in `func_get_filelist "$module"`; do
1865 lib/*/*.c | tests/*/*.c) uses_subdirs=yes ;;
1871 # Generate dependencies here, since it eases the debugging of test failures.
1872 # If there are source files in subdirectories, prevent collision of the
1873 # object files (example: hash.c and libxml/hash.c).
1875 if test -n "$uses_subdirs"; then
1876 subdir_options=' subdir-objects'
1878 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
1881 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1884 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1885 # variable is needed to avoid an error from automake:
1886 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1889 echo "TESTS_ENVIRONMENT ="
1890 echo "noinst_PROGRAMS ="
1891 if ! $for_test; then
1892 echo "check_PROGRAMS ="
1894 echo "noinst_HEADERS ="
1895 echo "noinst_LIBRARIES ="
1896 if $use_libtests; then
1898 echo "noinst_LIBRARIES += libtests.a"
1900 echo "check_LIBRARIES = libtests.a"
1903 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1904 # if you specify pkgdata_DATA to empty. This is a workaround.
1905 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1906 echo "pkgdata_DATA ="
1909 echo "BUILT_SOURCES ="
1911 echo "MOSTLYCLEANFILES = core *.stackdump"
1912 echo "MOSTLYCLEANDIRS ="
1914 echo "DISTCLEANFILES ="
1915 echo "MAINTAINERCLEANFILES ="
1917 echo "AM_CPPFLAGS = \\"
1918 echo " -I. -I\$(srcdir) \\"
1919 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1920 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1922 local_ldadd_before=''
1923 local_ldadd_after=''
1924 if $use_libtests; then
1925 # All test programs need to be linked with libtests.a.
1926 # It needs to be passed to the linker before ${libname}.${libext}, since
1927 # the tests-related modules depend on the main modules.
1928 # It also needs to be passed to the linker after ${libname}.${libext}
1929 # because the latter might contain incomplete modules (such as the 'error'
1930 # module whose dependency to 'progname' is voluntarily omitted).
1931 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
1933 local_ldadd_before=' libtests.a'
1934 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
1936 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
1938 if $use_libtests; then
1939 echo "libtests_a_SOURCES ="
1940 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1941 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1942 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
1943 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
1944 echo "EXTRA_libtests_a_SOURCES ="
1945 # The circular dependency in LDADD requires this.
1946 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
1949 cat allsnippets.tmp \
1950 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1951 echo "# Clean up after Solaris cc."
1953 echo " rm -rf SunWS_cache"
1955 echo "mostlyclean-local: mostlyclean-generic"
1956 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1957 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1958 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1962 rm -f allsnippets.tmp
1965 # func_emit_initmacro_start macro_prefix
1966 # emits the first few statements of the gl_INIT macro to standard output.
1967 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1968 func_emit_initmacro_start ()
1970 macro_prefix_arg="$1"
1971 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
1972 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
1973 # LIBOBJS. The purpose is to allow several gnulib instantiations under
1974 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
1976 # Furthermore it avoids an automake error like this when a Makefile.am
1977 # that uses pieces of gnulib also uses $(LIBOBJ):
1978 # automatically discovered file `error.c' should not be explicitly mentioned
1979 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
1980 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
1981 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
1982 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
1983 # automatically discovered file `error.c' should not be explicitly mentioned
1984 # We let automake know about the files to be distributed through the
1985 # EXTRA_lib_SOURCES variable.
1986 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
1989 # func_emit_initmacro_end macro_prefix
1990 # emits the last few statements of the gl_INIT macro to standard output.
1991 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1992 func_emit_initmacro_end ()
1994 macro_prefix_arg="$1"
1995 echo " m4_popdef([AC_LIBSOURCES])"
1996 echo " m4_popdef([AC_REPLACE_FUNCS])"
1997 echo " m4_popdef([AC_LIBOBJ])"
1998 echo " AC_CONFIG_COMMANDS_PRE(["
1999 echo " ${macro_prefix_arg}_libobjs="
2000 echo " ${macro_prefix_arg}_ltlibobjs="
2001 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
2002 echo " # Remove the extension."
2003 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
2004 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
2005 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
2006 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
2009 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
2010 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
2014 # func_emit_initmacro_done macro_prefix sourcebase
2015 # emits a few statements after the gl_INIT macro to standard output.
2016 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2017 # - sourcebase directory relative to destdir where to place source code
2018 func_emit_initmacro_done ()
2020 macro_prefix_arg="$1"
2023 echo "# Like AC_LIBOBJ, except that the module name goes"
2024 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2025 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
2026 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
2027 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
2030 echo "# m4_foreach_w is provided by autoconf-2.59c and later."
2031 echo "# This definition is to accommodate developers using versions"
2032 echo "# of autoconf older than that."
2033 echo "m4_ifndef([m4_foreach_w],"
2034 echo " [m4_define([m4_foreach_w],"
2035 echo " [m4_foreach([\$1], m4_split(m4_normalize([\$2]), [ ]), [\$3])])])"
2037 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
2038 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2039 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
2040 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
2041 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
2044 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
2045 echo "# expected is derived from the gnulib-tool parametrization,"
2046 echo "# and alloca is special cased (for the alloca-opt module)."
2047 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
2048 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
2049 echo " m4_foreach([_gl_NAME], [\$1], ["
2050 echo " m4_if(_gl_NAME, [alloca.c], [], ["
2051 echo " m4_syscmd([test -r $sourcebase_arg/]_gl_NAME[ || test ! -d $sourcebase_arg])dnl"
2052 echo " m4_if(m4_sysval, [0], [],"
2053 echo " [AC_FATAL([missing $sourcebase_arg/]_gl_NAME)])"
2059 # func_import modules
2060 # Uses also the variables
2061 # - destdir target directory
2062 # - local_gnulib_dir from --local-dir
2063 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2064 # - libname library name
2065 # - sourcebase directory relative to destdir where to place source code
2066 # - m4base directory relative to destdir where to place *.m4 macros
2067 # - pobase directory relative to destdir where to place *.po files
2068 # - docbase directory relative to destdir where to place doc files
2069 # - testsbase directory relative to destdir where to place unit test code
2070 # - auxdir directory relative to destdir where to place build aux files
2071 # - inctests true if --with-tests was given, blank otherwise
2072 # - avoidlist list of modules to avoid, from --avoid
2073 # - lgpl yes or a number if library's license shall be LGPL,
2075 # - makefile_name from --makefile-name
2076 # - libtool true if --libtool was given, false if --no-libtool was
2077 # given, blank otherwise
2078 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
2079 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2080 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2081 # - autoconf_minversion minimum supported autoconf version
2082 # - doit : if actions shall be executed, false if only to be printed
2083 # - symbolic true if files should be symlinked, copied otherwise
2084 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2086 # - do_copyrights true if copyright notices in files should be replaced,
2090 # Get the cached settings.
2091 cached_local_gnulib_dir=
2092 cached_specified_modules=
2102 cached_makefile_name=
2104 cached_macro_prefix=
2107 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2108 cached_libtool=false
2114 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
2117 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
2120 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
2123 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
2126 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
2129 s,^.*gl_PO_BASE([[ ]*\([^])]*\).*$,cached_pobase="\1",p
2132 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
2135 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
2138 s,^.*$,cached_inctests=true,p
2141 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
2144 s,^.*gl_LGPL([[ ]*\([^])]*\).*$,cached_lgpl="\1",p
2147 s,^.*$,cached_lgpl=yes,p
2149 /gl_MAKEFILE_NAME(/ {
2150 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
2153 s,^.*$,cached_libtool=true,p
2155 /gl_MACRO_PREFIX(/ {
2156 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
2159 s,^.*gl_PO_DOMAIN([[ ]*\([^])]*\).*$,cached_po_domain="\1",p
2161 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2162 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2167 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2168 s,^.*$,cached_files=",p
2180 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2184 # Merge the cached settings with the specified ones.
2185 # The m4base must be the same as expected from the pathname.
2186 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2187 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2189 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2190 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2191 if test -z "$local_gnulib_dir"; then
2192 if test -n "$cached_local_gnulib_dir"; then
2195 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2197 case "$cached_local_gnulib_dir" in
2199 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2201 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2202 local_gnulib_dir="$relconcat" ;;
2207 # Append the cached and the specified module names. So that
2208 # "gnulib-tool --import foo" means to add the module foo.
2209 specified_modules="$cached_specified_modules $1"
2210 # Append the cached and the specified avoidlist. This is probably better
2211 # than dropping the cached one when --avoid is specified at least once.
2212 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2213 avoidlist=`echo $avoidlist`
2215 # The sourcebase defaults to the cached one.
2216 if test -z "$sourcebase"; then
2217 sourcebase="$cached_sourcebase"
2218 if test -z "$sourcebase"; then
2219 func_fatal_error "missing --source-base option"
2222 # The pobase defaults to the cached one.
2223 if test -z "$pobase"; then
2224 pobase="$cached_pobase"
2226 # The docbase defaults to the cached one.
2227 if test -z "$docbase"; then
2228 docbase="$cached_docbase"
2229 if test -z "$docbase"; then
2230 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."
2233 # The testsbase defaults to the cached one.
2234 if test -z "$testsbase"; then
2235 testsbase="$cached_testsbase"
2236 if test -z "$testsbase"; then
2237 func_fatal_error "missing --tests-base option"
2240 # Require the tests if specified either way.
2241 if test -z "$inctests"; then
2242 inctests="$cached_inctests"
2244 # The libname defaults to the cached one.
2245 if test -z "$supplied_libname"; then
2246 libname="$cached_libname"
2247 if test -z "$libname"; then
2248 func_fatal_error "missing --lib option"
2251 # Require LGPL if specified either way.
2252 if test -z "$lgpl"; then
2255 # The makefile_name defaults to the cached one.
2256 if test -z "$makefile_name"; then
2257 makefile_name="$cached_makefile_name"
2259 # Use libtool if specified either way, or if guessed.
2260 if test -z "$libtool"; then
2261 if test -n "$cached_m4base"; then
2262 libtool="$cached_libtool"
2264 libtool="$guessed_libtool"
2267 # The macro_prefix defaults to the cached one.
2268 if test -z "$macro_prefix"; then
2269 macro_prefix="$cached_macro_prefix"
2270 if test -z "$macro_prefix"; then
2271 func_fatal_error "missing --macro-prefix option"
2274 # The po_domain defaults to the cached one.
2275 if test -z "$po_domain"; then
2276 po_domain="$cached_po_domain"
2279 # Canonicalize the list of specified modules.
2280 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2282 # Determine final module list.
2283 modules="$specified_modules"
2284 func_modules_transitive_closure
2285 if test $verbose -ge 0; then
2286 echo "Module list with included dependencies:"
2287 echo "$modules" | sed -e 's/^/ /'
2289 final_modules="$modules"
2291 # Determine main module list and tests-related module list separately.
2292 # The main module list is the transitive closure of the specified modules,
2293 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2294 # is specified, it will consist only of LGPLed source.
2295 # The tests-related module list is the transitive closure of the specified
2296 # modules, including tests modules, minus the main module list. Its lib/*
2297 # sources (brought in through dependencies of *-tests modules) go into
2298 # $testsbase/. It may contain GPLed source, even if --lgpl is specified.
2299 # Determine main module list.
2300 saved_inctests="$inctests"
2302 modules="$specified_modules"
2303 func_modules_transitive_closure
2304 main_modules="$modules"
2305 inctests="$saved_inctests"
2306 if test $verbose -ge 1; then
2307 echo "Main module list:"
2308 echo "$main_modules" | sed -e 's/^/ /'
2310 # Determine tests-related module list.
2311 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2312 testsrelated_modules=`echo "$main_modules" | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2313 if test $verbose -ge 1; then
2314 echo "Tests-related module list:"
2315 echo "$testsrelated_modules" | sed -e 's/^/ /'
2318 # Add the dummy module to the main module list if needed.
2319 modules="$main_modules"
2320 func_modules_add_dummy
2321 main_modules="$modules"
2323 # Determine whether a $testsbase/libtests.a is needed.
2325 for module in $testsrelated_modules; do
2326 func_verify_nontests_module
2327 if test -n "$module"; then
2328 all_files=`func_get_filelist $module`
2329 lib_files=`for f in $all_files; do \
2333 done | sed -e 's,^lib/,,'`
2334 if test -n "$lib_files"; then
2341 # Add the dummy module to the tests-related module list if needed.
2342 if $use_libtests; then
2343 modules="$testsrelated_modules"
2344 func_modules_add_dummy
2345 testsrelated_modules="$modules"
2348 # If --lgpl, verify that the licenses of modules are compatible.
2349 if test -n "$lgpl"; then
2350 for module in $main_modules; do
2351 license=`func_get_license $module`
2353 'GPLed build tool') ;;
2354 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2360 *) func_fatal_error "incompatible license on module $module: $license" ;;
2366 *) func_fatal_error "incompatible license on module $module: $license" ;;
2369 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2376 # Show banner notice of every module.
2377 modules="$main_modules"
2380 # Determine script to apply to imported library files.
2381 sed_transform_lib_file=
2382 for module in $main_modules; do
2383 if test $module = config-h; then
2384 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2385 sed_transform_lib_file=$sed_transform_lib_file'
2386 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2391 sed_transform_main_lib_file="$sed_transform_lib_file"
2392 if test -n "$do_copyrights"; then
2393 if test -n "$lgpl"; then
2397 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2398 s/GNU General/GNU Lesser General/g
2402 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2403 s/GNU General/GNU Lesser General/g
2404 s/version [23]\([ ,]\)/version 2.1\1/g
2407 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2411 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2412 s/GNU Lesser General/GNU General/g
2413 s/GNU Library General/GNU General/g
2414 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2419 # Determine script to apply to library files that go into $testsbase/.
2420 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
2421 if test -n "$do_copyrights"; then
2423 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
2424 s/GNU Lesser General/GNU General/g
2425 s/GNU Library General/GNU General/g
2426 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2430 # Determine the final file lists.
2431 # They must be computed separately, because files in lib/* go into
2432 # $sourcebase/ if they are in the main file list but into $testsbase/
2433 # if they are in the tests-related file list. Furthermore lib/dummy.c
2435 # Determine final main file list.
2436 modules="$main_modules"
2437 func_modules_to_filelist
2439 # Determine final tests-related file list.
2440 modules="$testsrelated_modules"
2441 func_modules_to_filelist
2442 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
2443 # Merge both file lists.
2444 sed_remove_empty_lines='/^$/d'
2445 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
2446 if test $verbose -ge 0; then
2448 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
2449 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
2453 || func_fatal_error "refusing to do nothing"
2455 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2456 new_files="$files m4/gnulib-tool.m4"
2457 old_files="$cached_files"
2458 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2459 func_append old_files " m4/gnulib-tool.m4"
2462 sed_rewrite_old_files="\
2463 s,^build-aux/,$auxdir/,
2464 s,^doc/,$cached_docbase/,
2465 s,^lib/,$cached_sourcebase/,
2466 s,^m4/,$cached_m4base/,
2467 s,^tests/,$cached_testsbase/,
2468 s,^tests=lib/,$cached_testsbase/,"
2469 sed_rewrite_new_files="\
2470 s,^build-aux/,$auxdir/,
2472 s,^lib/,$sourcebase/,
2474 s,^tests/,$testsbase/,
2475 s,^tests=lib/,$testsbase/,"
2477 # Create directories.
2478 { echo "$sourcebase"
2480 if test -n "$pobase"; then
2483 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2484 if test -n "$docfiles"; then
2487 if test -n "$inctests"; then
2491 for f in $files; do echo $f; done \
2492 | sed -e "$sed_rewrite_new_files" \
2493 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2496 { # Rearrange file descriptors. Needed because "while ... done < ..."
2497 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2498 exec 5<&0 < "$tmp"/dirs
2500 if test ! -d "$destdir/$d"; then
2502 echo "Creating directory $destdir/$d"
2503 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2505 echo "Create directory $destdir/$d"
2512 # func_dest_tmpfilename file
2513 # determines the name of a temporary file (file is relative to destdir).
2515 # - tmpfile absolute filename of the temporary file
2516 func_dest_tmpfilename ()
2519 # Put the new contents of $file in a file in the same directory (needed
2520 # to guarantee that an 'mv' to "$destdir/$file" works).
2521 tmpfile="$destdir/$1.tmp"
2523 # Put the new contents of $file in a file in a temporary directory
2524 # (because the directory of "$file" might not exist).
2525 tmpfile="$tmp"/`basename "$1"`.tmp
2529 # Copy files or make symbolic links. Remove obsolete files.
2533 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2534 # representing the files according to the last gnulib-tool invocation.
2535 for f in $old_files; do echo $f; done \
2536 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2539 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2540 # representing the files after this gnulib-tool invocation.
2541 for f in $new_files; do echo $f; done \
2542 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2545 # First the files that are in old-files, but not in new-files:
2546 sed_take_first_column='s,'"$delimiter"'.*,,'
2547 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2548 # Remove the file. Do nothing if the user already removed it.
2549 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
2551 echo "Removing file $g (backup in ${g}~)"
2552 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2554 echo "Remove file $g (backup in ${g}~)"
2556 func_append removed_files "$g$nl"
2559 # func_add_or_update handles a file that ought to be present afterwards.
2561 # - f the original file name
2562 # - g the rewritten file name
2563 # - already_present nonempty if the file already exists, empty otherwise
2564 func_add_or_update ()
2568 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
2570 func_dest_tmpfilename "$g"
2571 func_lookup_file "$f"
2572 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2573 if test -n "$sed_transform_main_lib_file"; then
2576 sed -e "$sed_transform_main_lib_file" \
2577 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2581 if test -n "$sed_transform_testsrelated_lib_file"; then
2584 sed -e "$sed_transform_testsrelated_lib_file" \
2585 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2589 if test -f "$destdir/$g"; then
2590 # The file already exists.
2591 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2592 : # The file has not changed.
2596 if test -n "$already_present"; then
2597 echo "Updating file $g (backup in ${g}~)"
2599 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
2601 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2602 if { test -n "$symbolic" \
2603 || { test -n "$lsymbolic" \
2604 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2605 && test -z "$lookedup_tmp" \
2606 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2607 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2609 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2612 if test -n "$already_present"; then
2613 echo "Update file $g (backup in ${g}~)"
2615 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
2621 # Don't protest if the file should be there but isn't: it happens
2622 # frequently that developers don't put autogenerated files into CVS.
2624 echo "Copying file $g"
2625 if { test -n "$symbolic" \
2626 || { test -n "$lsymbolic" \
2627 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2628 && test -z "$lookedup_tmp" \
2629 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2630 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2632 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2637 func_append added_files "$g$nl"
2641 # Then the files that are in new-files, but not in old-files:
2642 sed_take_last_column='s,^.*'"$delimiter"',,'
2644 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2645 | sed -e "$sed_take_last_column" \
2646 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2647 { # Rearrange file descriptors. Needed because "while ... done < ..."
2648 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2649 exec 5<&0 < "$tmp"/added-files
2655 # Then the files that are in new-files and in old-files:
2656 already_present=true
2657 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2658 | sed -e "$sed_take_last_column" \
2659 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2660 { # Rearrange file descriptors. Needed because "while ... done < ..."
2661 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2662 exec 5<&0 < "$tmp"/kept-files
2669 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2670 actioncmd="gnulib-tool --import"
2671 func_append actioncmd " --dir=$destdir"
2672 if test -n "$local_gnulib_dir"; then
2673 func_append actioncmd " --local-dir=$local_gnulib_dir"
2675 func_append actioncmd " --lib=$libname"
2676 func_append actioncmd " --source-base=$sourcebase"
2677 func_append actioncmd " --m4-base=$m4base"
2678 if test -n "$pobase"; then
2679 func_append actioncmd " --po-base=$pobase"
2681 func_append actioncmd " --doc-base=$docbase"
2682 func_append actioncmd " --aux-dir=$auxdir"
2683 if test -n "$inctests"; then
2684 func_append actioncmd " --with-tests"
2686 for module in $avoidlist; do
2687 func_append actioncmd " --avoid=$module"
2689 if test -n "$lgpl"; then
2690 if test "$lgpl" = yes; then
2691 func_append actioncmd " --lgpl"
2693 func_append actioncmd " --lgpl=$lgpl"
2696 if test -n "$makefile_name"; then
2697 func_append actioncmd " --makefile-name=$makefile_name"
2699 if test "$libtool" = true; then
2700 func_append actioncmd " --libtool"
2702 func_append actioncmd " --no-libtool"
2704 func_append actioncmd " --macro-prefix=$macro_prefix"
2705 if test -n "$po_domain"; then
2706 func_append actioncmd " --po-domain=$po_domain"
2708 func_append actioncmd " `echo $specified_modules`"
2710 # Default the makefile name to Makefile.am.
2711 if test -n "$makefile_name"; then
2712 makefile_am=$makefile_name
2714 makefile_am=Makefile.am
2717 # Create normal Makefile.ams.
2720 # Create library makefile.
2721 func_dest_tmpfilename $sourcebase/$makefile_am
2722 modules="$main_modules"
2723 func_emit_lib_Makefile_am > "$tmpfile"
2724 if test -f "$destdir"/$sourcebase/$makefile_am; then
2725 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
2729 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2730 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
2731 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2733 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2739 echo "Creating $sourcebase/$makefile_am"
2740 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2742 echo "Create $sourcebase/$makefile_am"
2745 func_append added_files "$sourcebase/$makefile_am$nl"
2748 # Create po/ directory.
2749 if test -n "$pobase"; then
2750 # Create po makefile and auxiliary files.
2751 for file in Makefile.in.in remove-potcdate.sin; do
2752 func_dest_tmpfilename $pobase/$file
2753 func_lookup_file build-aux/po/$file
2754 cat "$lookedup_file" > "$tmpfile"
2755 if test -f "$destdir"/$pobase/$file; then
2756 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
2760 echo "Updating $pobase/$file (backup in $pobase/$file~)"
2761 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
2762 mv -f "$tmpfile" "$destdir"/$pobase/$file
2764 echo "Update $pobase/$file (backup in $pobase/$file~)"
2770 echo "Creating $pobase/$file"
2771 mv -f "$tmpfile" "$destdir"/$pobase/$file
2773 echo "Create $pobase/$file"
2776 func_append added_files "$pobase/$file$nl"
2779 # Create po makefile parametrization, part 1.
2780 func_dest_tmpfilename $pobase/Makevars
2781 func_emit_po_Makevars > "$tmpfile"
2782 if test -f "$destdir"/$pobase/Makevars; then
2783 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
2787 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
2788 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
2789 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2791 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
2797 echo "Creating $pobase/Makevars"
2798 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2800 echo "Create $pobase/Makevars"
2803 func_append added_files "$pobase/Makevars$nl"
2805 # Create po makefile parametrization, part 2.
2806 func_dest_tmpfilename $pobase/POTFILES.in
2807 func_emit_po_POTFILES_in > "$tmpfile"
2808 if test -f "$destdir"/$pobase/POTFILES.in; then
2809 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
2813 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2814 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
2815 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2817 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2823 echo "Creating $pobase/POTFILES.in"
2824 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2826 echo "Create $pobase/POTFILES.in"
2829 func_append added_files "$pobase/POTFILES.in$nl"
2832 TP_URL="http://translationproject.org/latest/"
2833 TP_RSYNC_URI="translationproject.org::tp/latest/"
2835 echo "Fetching gnulib PO files from $TP_URL"
2836 (cd "$destdir"/$pobase \
2837 && { # Prefer rsync over wget if it is available, since it consumes
2838 # less network bandwidth, due to compression.
2839 if type rsync 2>/dev/null | grep / > /dev/null; then
2840 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
2842 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
2847 echo "Fetch gnulib PO files from $TP_URL"
2849 # Create po/LINGUAS.
2851 func_dest_tmpfilename $pobase/LINGUAS
2852 (cd "$destdir"/$pobase \
2853 && { echo '# Set of available languages.'
2854 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
2857 if test -f "$destdir"/$pobase/LINGUAS; then
2858 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
2861 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2862 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
2863 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2866 echo "Creating $pobase/LINGUAS"
2867 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2868 func_append added_files "$pobase/LINGUAS$nl"
2871 if test -f "$destdir"/$pobase/LINGUAS; then
2872 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2874 echo "Create $pobase/LINGUAS"
2879 # Create m4/gnulib-cache.m4.
2880 func_dest_tmpfilename $m4base/gnulib-cache.m4
2882 func_emit_copyright_notice
2884 echo "# This file represents the specification of how gnulib-tool is used."
2885 echo "# It acts as a cache: It is written and read by gnulib-tool."
2886 echo "# In projects using CVS, this file is meant to be stored in CVS,"
2887 echo "# like the configure.ac and various Makefile.am files."
2890 echo "# Specification in the form of a command-line invocation:"
2893 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
2894 # Store the local_gnulib_dir relative to destdir.
2895 case "$local_gnulib_dir" in
2897 relative_local_gnulib_dir="$local_gnulib_dir" ;;
2900 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
2902 # destdir, local_gnulib_dir are both relative.
2903 func_relativize "$destdir" "$local_gnulib_dir"
2904 relative_local_gnulib_dir="$reldir" ;;
2907 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
2908 echo "gl_MODULES(["`echo $specified_modules`"])"
2909 echo "gl_AVOID([$avoidlist])"
2910 echo "gl_SOURCE_BASE([$sourcebase])"
2911 echo "gl_M4_BASE([$m4base])"
2912 echo "gl_PO_BASE([$pobase])"
2913 echo "gl_DOC_BASE([$docbase])"
2914 echo "gl_TESTS_BASE([$testsbase])"
2915 test -z "$inctests" || echo "gl_WITH_TESTS"
2916 echo "gl_LIB([$libname])"
2917 if test -n "$lgpl"; then
2918 if test "$lgpl" = yes; then
2921 echo "gl_LGPL([$lgpl])"
2924 echo "gl_MAKEFILE_NAME([$makefile_name])"
2925 if test "$libtool" = true; then
2928 echo "gl_MACRO_PREFIX([$macro_prefix])"
2929 echo "gl_PO_DOMAIN([$po_domain])"
2931 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2932 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2936 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2937 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2938 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2940 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2944 echo "# gnulib-cache.m4 ends here"
2951 echo "Creating $m4base/gnulib-cache.m4"
2952 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2954 echo "Create $m4base/gnulib-cache.m4"
2960 # Create m4/gnulib-comp.m4.
2961 func_dest_tmpfilename $m4base/gnulib-comp.m4
2963 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2964 func_emit_copyright_notice
2966 echo "# This file represents the compiled summary of the specification in"
2967 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2968 echo "# to be invoked from configure.ac."
2969 echo "# In projects using CVS, this file can be treated like other built files."
2972 echo "# This macro should be invoked from $configure_ac, in the section"
2973 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2974 echo "# any checks for libraries, header files, types and library functions."
2975 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2977 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2978 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2979 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2980 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2981 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2982 if test -n "$uses_subdirs"; then
2983 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2985 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2986 echo " AC_REQUIRE([AC_GNU_SOURCE])"
2988 for module in $final_modules; do
2990 if test -n "$module"; then
2991 func_get_autoconf_early_snippet "$module"
2994 | sed -e '/^$/d;' -e 's/^/ /'
2997 echo "# This macro should be invoked from $configure_ac, in the section"
2998 echo "# \"Check for header files, types and library functions\"."
2999 echo "AC_DEFUN([${macro_prefix}_INIT],"
3001 if test "$libtool" = true; then
3002 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3003 echo " gl_cond_libtool=true"
3005 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3006 echo " gl_cond_libtool=false"
3008 echo " gl_ltlibdeps="
3010 if test "$auxdir" != "build-aux"; then
3011 sed_replace_build_aux='
3013 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3014 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3018 sed_replace_build_aux=
3020 func_emit_initmacro_start $macro_prefix
3021 echo " gl_source_base='$sourcebase'"
3022 for module in $main_modules; do
3024 if test -n "$module"; then
3025 func_get_autoconf_snippet "$module" \
3026 | sed -e '/^$/d;' -e 's/^/ /' \
3027 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3028 -e "$sed_replace_build_aux"
3029 if test "$module" = 'alloca' && test "$libtool" = true; then
3030 echo 'changequote(,)dnl'
3031 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3032 echo 'changequote([, ])dnl'
3033 echo 'AC_SUBST([LTALLOCA])'
3037 func_emit_initmacro_end $macro_prefix
3038 echo " gltests_libdeps="
3039 echo " gltests_ltlibdeps="
3040 func_emit_initmacro_start ${macro_prefix}tests
3041 echo " gl_source_base='$testsbase'"
3042 for module in $testsrelated_modules; do
3044 if test -n "$module"; then
3045 func_get_autoconf_snippet "$module" \
3046 | sed -e '/^$/d;' -e 's/^/ /' \
3047 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3048 -e "$sed_replace_build_aux" \
3049 -e 's/\$gl_cond_libtool/false/g' \
3050 -e 's/gl_libdeps/gltests_libdeps/g' \
3051 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3054 func_emit_initmacro_end ${macro_prefix}tests
3055 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3056 # created using libtool, because libtool already handles the dependencies.
3057 if test "$libtool" != true; then
3058 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3059 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3060 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3061 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3062 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3064 if $use_libtests; then
3065 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
3066 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
3069 func_emit_initmacro_done $macro_prefix $sourcebase
3070 func_emit_initmacro_done ${macro_prefix}tests $testsbase
3072 echo "# This macro records the list of files which have been installed by"
3073 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
3074 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
3075 echo "$files" | sed -e 's,^, ,'
3078 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3079 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
3083 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3084 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
3085 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3087 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3091 echo "# gnulib-comp.m4 ends here"
3098 echo "Creating $m4base/gnulib-comp.m4"
3099 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3101 echo "Create $m4base/gnulib-comp.m4"
3107 if test -n "$inctests"; then
3108 # Create tests makefile.
3109 func_dest_tmpfilename $testsbase/$makefile_am
3110 modules="$testsrelated_modules"
3111 func_emit_tests_Makefile_am > "$tmpfile"
3112 if test -f "$destdir"/$testsbase/$makefile_am; then
3113 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
3117 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3118 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
3119 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3121 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3127 echo "Creating $testsbase/$makefile_am"
3128 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3130 echo "Create $testsbase/$makefile_am"
3133 func_append added_files "$testsbase/$makefile_am$nl"
3137 # Update the .cvsignore and .gitignore files.
3138 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
3139 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
3140 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
3141 { # Rearrange file descriptors. Needed because "while ... done < ..."
3142 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3143 exec 5<&0 < "$tmp"/fileset-changes
3144 func_update_ignorelist ()
3147 if test -f "$destdir/$dir$ignore"; then
3148 if test -n "$dir_added" || test -n "$dir_removed"; then
3149 LC_ALL=C sort "$destdir/$dir$ignore" > "$tmp"/ignore
3150 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
3151 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-added
3152 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
3153 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-removed
3154 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
3156 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3157 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
3158 sed -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed > "$tmp"/sed-ignore-removed
3159 cat "$destdir/$dir$ignore"~ "$tmp"/ignore-added \
3160 | sed -f "$tmp"/sed-ignore-removed \
3161 > "$destdir/$dir$ignore"
3163 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3168 if test -n "$dir_added"; then
3170 echo "Creating $destdir/$dir$ignore"
3172 if test "$ignore" = .cvsignore; then
3174 # Automake generates Makefile rules that create .dirstamp files.
3177 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u
3178 } > "$destdir/$dir$ignore"
3180 echo "Create $destdir/$dir$ignore"
3190 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
3191 func_update_ignorelist .cvsignore
3193 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
3194 func_update_ignorelist .gitignore
3201 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
3202 next_dir=`echo "$line" | sed -e 's,|.*,,'`
3203 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
3204 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
3205 if test "$next_dir" != "$last_dir"; then
3206 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3207 last_dir="$next_dir"
3212 A) func_append last_dir_added "$file$nl";;
3213 R) func_append last_dir_removed "$file$nl";;
3216 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3222 echo "You may need to add #include directives for the following .h files."
3223 # Intersect $specified_modules and $main_modules
3224 # (since $specified_modules is not necessarily of subset of $main_modules
3225 # - some may have been skipped through --avoid, and since the elements of
3226 # $main_modules but not in $specified_modules can go away without explicit
3227 # notice - through changes in the module dependencies).
3228 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
3229 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
3230 # First the #include <...> directives without #ifs, sorted for convenience,
3231 # then the #include "..." directives without #ifs, sorted for convenience,
3232 # then the #include directives that are surrounded by #ifs. Not sorted.
3233 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
3234 include_directive=`func_get_include_directive "$module"`
3235 case "$nl$include_directive" in
3237 echo "$include_directive" 1>&5
3240 echo "$include_directive" | grep -v 'include "' 1>&6
3241 echo "$include_directive" | grep 'include "' 1>&7
3244 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
3246 LC_ALL=C sort -u "$tmp"/include-angles
3247 LC_ALL=C sort -u "$tmp"/include-quotes
3248 cat "$tmp"/include-if
3249 ) | sed -e '/^$/d' -e 's/^/ /'
3250 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
3252 for module in $main_modules; do
3253 func_get_link_directive "$module"
3255 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
3256 if test `wc -l < "$tmp"/link` != 0; then
3258 echo "You may need to use the following Makefile variables when linking."
3259 echo "Use them in <program>_LDADD when linking a program, or"
3260 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
3266 echo "Don't forget to"
3267 if test "$makefile_am" = Makefile.am; then
3268 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3270 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
3272 if test -n "$pobase"; then
3273 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
3275 if test -n "$inctests"; then
3276 if test "$makefile_am" = Makefile.am; then
3277 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3279 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
3282 if test "$makefile_am" = Makefile.am; then
3283 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3284 sourcebase_base=`basename "$sourcebase"`
3285 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
3287 if test -n "$pobase"; then
3288 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3289 pobase_base=`basename "$pobase"`
3290 echo " - mention \"${pobase_base}\" in SUBDIRS in ${pobase_dir}Makefile.am,"
3292 if test -n "$inctests"; then
3293 if test "$makefile_am" = Makefile.am; then
3294 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3295 testsbase_base=`basename "$testsbase"`
3296 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
3299 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
3300 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
3301 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
3304 # func_create_testdir testdir modules
3306 # - local_gnulib_dir from --local-dir
3307 # - auxdir directory relative to destdir where to place build aux files
3308 func_create_testdir ()
3312 if test -z "$modules"; then
3313 # All modules together.
3314 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3315 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3316 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
3317 modules=`func_all_modules`
3318 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
3320 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
3322 # Check that the license of every module is consistent with the license of
3324 saved_modules="$modules"
3325 saved_inctests="$inctests"
3326 # When computing transitive closures, don't consider $module to depend on
3327 # $module-tests. Need this becauses tests are implicitly GPL and may depend
3328 # on GPL modules - therefore we don't want a warning in this case.
3330 for requested_module in $saved_modules; do
3331 requested_license=`func_get_license "$requested_module"`
3332 if test "$requested_license" != GPL; then
3333 # Here we use func_modules_transitive_closure, not just
3334 # func_get_dependencies, so that we also detect weird situations like
3335 # an LGPL module which depends on a GPLed build tool module which depends
3337 modules="$requested_module"
3338 func_modules_transitive_closure
3339 for module in $modules; do
3340 license=`func_get_license "$module"`
3342 'GPLed build tool') ;;
3343 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3345 case "$requested_license" in
3348 GPLv2+ | LGPLv2+) ;;
3349 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3355 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3361 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3370 modules="$saved_modules"
3371 inctests="$saved_inctests"
3373 # Subdirectory names.
3382 # Determine final module list.
3383 func_modules_transitive_closure
3384 if test $verbose -ge 0; then
3385 echo "Module list with included dependencies:"
3386 echo "$modules" | sed -e 's/^/ /'
3389 # Add the dummy module if needed.
3390 func_modules_add_dummy
3392 # Show banner notice of every module.
3395 # Determine final file list.
3396 func_modules_to_filelist
3397 if test $verbose -ge 0; then
3399 echo "$files" | sed -e 's/^/ /'
3402 sed_rewrite_files="\
3403 s,^build-aux/,$auxdir/,
3405 s,^lib/,$sourcebase/,
3407 s,^tests/,$testsbase/,"
3409 # Create directories.
3410 for f in $files; do echo $f; done \
3411 | sed -e "$sed_rewrite_files" \
3412 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3413 | LC_ALL=C sort -u \
3415 { # Rearrange file descriptors. Needed because "while ... done < ..."
3416 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3417 exec 5<&0 < "$tmp"/dirs
3419 mkdir -p "$testdir/$d"
3424 # Copy files or make symbolic links.
3426 for f in $files; do echo $f; done \
3427 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3430 { # Rearrange file descriptors. Needed because "while ... done < ..."
3431 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3432 exec 5<&0 < "$tmp"/files
3434 func_lookup_file "$f"
3435 if test -n "$lookedup_tmp"; then
3436 cp -p "$lookedup_file" "$testdir/$g"
3438 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3439 if { test -n "$symbolic" \
3440 || { test -n "$lsymbolic" \
3441 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3442 func_ln "$lookedup_file" "$testdir/$g"
3444 cp -p "$lookedup_file" "$testdir/$g"
3451 # Create Makefile.ams that are for testing.
3454 # Create $sourcebase/Makefile.am.
3455 mkdir -p "$testdir/$sourcebase"
3456 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3457 any_uses_subdirs="$uses_subdirs"
3459 # Create $m4base/Makefile.am.
3460 mkdir -p "$testdir/$m4base"
3461 (echo "## Process this file with automake to produce Makefile.in."
3467 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
3470 ) > "$testdir/$m4base/Makefile.am"
3472 subdirs="$sourcebase $m4base"
3473 subdirs_with_configure_ac=""
3475 if false && test -f "$testdir"/$m4base/gettext.m4; then
3476 # Avoid stupid error message from automake:
3477 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
3478 mkdir -p "$testdir/po"
3479 (echo "## Process this file with automake to produce Makefile.in."
3480 ) > "$testdir/po/Makefile.am"
3481 func_append subdirs " po"
3484 if test -n "$inctests"; then
3485 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
3486 # Viewed from the $testsbase subdirectory, $auxdir is different.
3487 saved_auxdir="$auxdir"
3488 auxdir=`echo "$testsbase/"|sed 's%[^/][^/]*//*%../%g'`"$auxdir"
3489 # Create $testsbase/Makefile.am.
3491 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
3492 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
3493 # Create $testsbase/configure.ac.
3494 (echo "# Process this file with autoconf to produce a configure script."
3495 echo "AC_INIT([dummy], [0])"
3496 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3497 echo "AM_INIT_AUTOMAKE"
3499 echo "AM_CONFIG_HEADER([config.h])"
3502 echo "AC_PROG_INSTALL"
3503 echo "AC_PROG_MAKE_SET"
3504 echo "AC_PROG_RANLIB"
3506 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3507 echo "AC_GNU_SOURCE"
3510 for module in $modules; do
3512 if test -n "$module"; then
3513 func_get_autoconf_early_snippet "$module"
3516 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3517 if test "$libtool" = true; then
3518 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3519 echo "gl_cond_libtool=true"
3521 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3522 echo "gl_cond_libtool=false"
3524 echo "gl_ltlibdeps="
3526 # Wrap the set of autoconf snippets into an autoconf macro that is then
3527 # invoked. This is needed because autoconf does not support AC_REQUIRE
3529 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3530 # but we want the AC_REQUIRE to have its normal meaning (provide one
3531 # expansion of the required macro before the current point, and only one
3533 echo "AC_DEFUN([gl_INIT], ["
3534 sed_replace_build_aux='
3536 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3537 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3540 func_emit_initmacro_start $macro_prefix
3541 # We don't have explicit ordering constraints between the various
3542 # autoconf snippets. It's cleanest to put those of the library before
3543 # those of the tests.
3544 echo "gl_source_base='../$sourcebase'"
3545 for module in $modules; do
3546 func_verify_nontests_module
3547 if test -n "$module"; then
3548 func_get_autoconf_snippet "$module" \
3549 | sed -e "$sed_replace_build_aux"
3552 echo "gl_source_base='.'"
3553 for module in $modules; do
3554 func_verify_tests_module
3555 if test -n "$module"; then
3556 func_get_autoconf_snippet "$module" \
3557 | sed -e "$sed_replace_build_aux"
3560 func_emit_initmacro_end $macro_prefix
3561 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3562 # created using libtool, because libtool already handles the dependencies.
3563 if test "$libtool" != true; then
3564 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3565 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3566 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3567 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3568 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3571 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
3575 # Usually $testsbase/config.h will be a superset of config.h. Verify this
3576 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
3577 echo "AH_TOP([#include \"../config.h\"])"
3579 echo "AC_OUTPUT([Makefile])"
3580 ) > "$testdir/$testsbase/configure.ac"
3581 auxdir="$saved_auxdir"
3582 func_append subdirs " $testsbase"
3583 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
3586 # Create Makefile.am.
3587 (echo "## Process this file with automake to produce Makefile.in."
3589 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3591 echo "SUBDIRS = $subdirs"
3593 echo "ACLOCAL_AMFLAGS = -I $m4base"
3594 ) > "$testdir/Makefile.am"
3596 # Create configure.ac.
3597 (echo "# Process this file with autoconf to produce a configure script."
3598 echo "AC_INIT([dummy], [0])"
3599 if test "$auxdir" != "."; then
3600 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3602 echo "AM_INIT_AUTOMAKE"
3604 echo "AM_CONFIG_HEADER([config.h])"
3607 echo "AC_PROG_INSTALL"
3608 echo "AC_PROG_MAKE_SET"
3610 echo "# For autobuild."
3611 echo "AC_CANONICAL_BUILD"
3612 echo "AC_CANONICAL_HOST"
3614 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3615 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3616 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3617 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3619 echo "AC_PROG_RANLIB"
3621 if test -n "$any_uses_subdirs"; then
3622 echo "AM_PROG_CC_C_O"
3625 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3626 echo "AC_GNU_SOURCE"
3629 for module in $modules; do
3630 func_verify_nontests_module
3631 if test -n "$module"; then
3632 func_get_autoconf_early_snippet "$module"
3635 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3636 if test "$libtool" = true; then
3637 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3638 echo "gl_cond_libtool=true"
3640 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3641 echo "gl_cond_libtool=false"
3643 echo "gl_ltlibdeps="
3645 # Wrap the set of autoconf snippets into an autoconf macro that is then
3646 # invoked. This is needed because autoconf does not support AC_REQUIRE
3648 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3649 # but we want the AC_REQUIRE to have its normal meaning (provide one
3650 # expansion of the required macro before the current point, and only one
3652 echo "AC_DEFUN([gl_INIT], ["
3653 if test "$auxdir" != "build-aux"; then
3654 sed_replace_build_aux='
3656 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3657 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3661 sed_replace_build_aux=
3663 func_emit_initmacro_start $macro_prefix
3664 echo "gl_source_base='$sourcebase'"
3665 for module in $modules; do
3666 func_verify_nontests_module
3667 if test -n "$module"; then
3668 func_get_autoconf_snippet "$module" \
3669 | sed -e "$sed_replace_build_aux"
3672 func_emit_initmacro_end $macro_prefix
3673 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3674 # created using libtool, because libtool already handles the dependencies.
3675 if test "$libtool" != true; then
3676 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3677 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3678 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3679 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3680 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3683 func_emit_initmacro_done $macro_prefix $sourcebase
3687 if test -n "$subdirs_with_configure_ac"; then
3688 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
3690 makefiles="Makefile"
3691 for d in $subdirs; do
3692 # For subdirs that have a configure.ac by their own, it's the subdir's
3693 # configure.ac which creates the subdir's Makefile.am, not this one.
3694 case " $subdirs_with_configure_ac " in
3696 *) func_append makefiles " $d/Makefile" ;;
3699 echo "AC_OUTPUT([$makefiles])"
3700 ) > "$testdir/configure.ac"
3702 # Create autogenerated files.
3704 # Do not use "${AUTORECONF} --force --install", because it may invoke
3705 # autopoint, which brings in older versions of some of our .m4 files.
3706 if test -f $m4base/gettext.m4; then
3707 func_execute_command ${AUTOPOINT} --force || func_exit 1
3708 for f in $m4base/*.m4~; do
3709 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3712 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
3713 if ! test -d build-aux; then
3714 func_execute_command mkdir build-aux || func_exit 1
3716 func_execute_command ${AUTOCONF} || func_exit 1
3717 func_execute_command ${AUTOHEADER} || func_exit 1
3718 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3720 if test -n "$inctests"; then
3721 # Create autogenerated files.
3722 (cd "$testdir/$testsbase" || func_exit 1
3723 # Do not use "${AUTORECONF} --force --install", because it may invoke
3724 # autopoint, which brings in older versions of some of our .m4 files.
3725 if test -f ../$m4base/gettext.m4; then
3726 func_execute_command ${AUTOPOINT} --force || func_exit 1
3727 for f in ../$m4base/*.m4~; do
3728 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3731 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
3732 if ! test -d ../build-aux; then
3733 func_execute_command mkdir ../build-aux
3735 func_execute_command ${AUTOCONF} || func_exit 1
3736 func_execute_command ${AUTOHEADER} || func_exit 1
3737 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3740 # Need to run configure and make once, to create built files that are to be
3741 # distributed (such as getdate.c).
3742 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
3743 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3744 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
3745 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
3746 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
3747 # such $(FOO_H) because they don't refer to distributed files.
3748 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
3749 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3750 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
3751 | sed -e "$sed_remove_make_variables"`
3752 distributed_built_sources=`for file in $built_sources; do
3753 case "$cleaned_files" in
3758 if test -n "$distributed_built_sources"; then
3760 ./configure || func_exit 1
3762 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
3763 make built_sources || func_exit 1
3765 make distclean || func_exit 1
3770 # func_create_megatestdir megatestdir allmodules
3772 # - local_gnulib_dir from --local-dir
3773 # - auxdir directory relative to destdir where to place build aux files
3774 func_create_megatestdir ()
3778 if test -z "$allmodules"; then
3779 allmodules=`func_all_modules`
3783 # First, all modules one by one.
3784 for onemodule in $allmodules; do
3785 func_create_testdir "$megatestdir/$onemodule" $onemodule
3786 func_append megasubdirs "$onemodule "
3788 # Then, all modules all together.
3789 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3790 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3791 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
3792 func_create_testdir "$megatestdir/ALL" "$allmodules"
3793 func_append megasubdirs "ALL"
3796 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
3797 vc_witness="$gnulib_dir/CVS/Entries"; \
3799 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
3801 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
3802 | sed -e 's,January,01,' -e 's,Jan,01,' \
3803 -e 's,February,02,' -e 's,Feb,02,' \
3804 -e 's,March,03,' -e 's,Mar,03,' \
3805 -e 's,April,04,' -e 's,Apr,04,' \
3807 -e 's,June,06,' -e 's,Jun,06,' \
3808 -e 's,July,07,' -e 's,Jul,07,' \
3809 -e 's,August,08,' -e 's,Aug,08,' \
3810 -e 's,September,09,' -e 's,Sep,09,' \
3811 -e 's,October,10,' -e 's,Oct,10,' \
3812 -e 's,November,11,' -e 's,Nov,11,' \
3813 -e 's,December,12,' -e 's,Dec,12,' \
3814 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
3815 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
3817 echo "CVSDATE=$cvsdate"
3818 echo "test -d logs || mkdir logs"
3819 echo "for module in $megasubdirs; do"
3820 echo " echo \"Working on module \$module...\""
3821 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
3822 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
3825 echo " : autobuild project... \$module"
3826 echo " : autobuild revision... cvs-\$CVSDATE-000000"
3827 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
3828 echo " : autobuild hostname... \`hostname\`"
3829 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
3831 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
3833 ) > "$megatestdir/do-autobuild"
3834 chmod a+x "$megatestdir/do-autobuild"
3836 # Create Makefile.am.
3837 (echo "## Process this file with automake to produce Makefile.in."
3839 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3841 echo "SUBDIRS = $megasubdirs"
3843 echo "EXTRA_DIST = do-autobuild"
3844 ) > "$megatestdir/Makefile.am"
3846 # Create configure.ac.
3847 (echo "# Process this file with autoconf to produce a configure script."
3848 echo "AC_INIT([dummy], [0])"
3849 if test "$auxdir" != "."; then
3850 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3852 echo "AM_INIT_AUTOMAKE"
3854 echo "AC_PROG_MAKE_SET"
3856 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
3857 echo "AC_OUTPUT([Makefile])"
3858 ) > "$megatestdir/configure.ac"
3860 # Create autogenerated files.
3862 # Do not use "${AUTORECONF} --install", because autoreconf operates
3863 # recursively, but the subdirectories are already finished, therefore
3864 # calling autoreconf here would only waste lots of CPU time.
3865 func_execute_command ${ACLOCAL} || func_exit 1
3866 func_execute_command mkdir build-aux
3867 func_execute_command ${AUTOCONF} || func_exit 1
3868 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3874 func_fatal_error "no mode specified" ;;
3883 if test -z "$destdir"; then
3886 test -d "$destdir" \
3887 || func_fatal_error "destination directory does not exist: $destdir"
3889 # Prefer configure.ac to configure.in.
3890 if test -f "$destdir"/configure.ac; then
3891 configure_ac="$destdir/configure.ac"
3893 if test -f "$destdir"/configure.in; then
3894 configure_ac="$destdir/configure.in"
3896 func_fatal_error "cannot find $destdir/configure.ac"
3900 # Analyze configure.ac.
3902 guessed_libtool=false
3907 /AC_CONFIG_AUX_DIR/ {
3908 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
3910 /A[CM]_PROG_LIBTOOL/ {
3911 s,^.*$,guessed_libtool=true,p
3913 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
3915 if test -z "$auxdir"; then
3916 auxdir="$guessed_auxdir"
3919 # Determine where to apply func_import.
3920 if test -n "$m4base"; then
3921 # Apply func_import to a particular gnulib directory.
3922 # Any number of additional modules can be given.
3923 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
3924 # First use of gnulib in the given m4base.
3925 test -n "$supplied_libname" || supplied_libname=true
3926 test -n "$sourcebase" || sourcebase="lib"
3927 test -n "$docbase" || docbase="doc"
3928 test -n "$testsbase" || testsbase="tests"
3929 test -n "$macro_prefix" || macro_prefix="gl"
3933 # Apply func_import to all gnulib directories.
3934 # To get this list of directories, look at Makefile.am. (Not at
3935 # configure, because it may be omitted from CVS. Also, don't run
3936 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
3939 if test -f "$destdir"/Makefile.am; then
3940 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
3942 for arg in $aclocal_amflags; do
3943 if test -n "$m4dir_is_next"; then
3944 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
3948 if test -f "$destdir/$arg"/gnulib-cache.m4; then
3949 func_append m4dirs " $arg"
3950 m4dirs_count=`expr $m4dirs_count + 1`
3956 if test "X$arg" = "X-I"; then
3964 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
3965 if test -f "$destdir"/aclocal.m4; then
3966 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
3967 sedexpr2='s,^[^/]*$,.,'
3968 sedexpr3='s,/[^/]*$,,'
3969 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
3970 m4dirs_count=`echo "$m4dirs" | wc -l`
3973 if test $m4dirs_count = 0; then
3974 # First use of gnulib in a package.
3975 # Any number of additional modules can be given.
3976 test -n "$supplied_libname" || supplied_libname=true
3977 test -n "$sourcebase" || sourcebase="lib"
3979 test -n "$docbase" || docbase="doc"
3980 test -n "$testsbase" || testsbase="tests"
3981 test -n "$macro_prefix" || macro_prefix="gl"
3984 if test $m4dirs_count = 1; then
3985 # There's only one use of gnulib here. Assume the user means it.
3986 # Any number of additional modules can be given.
3987 for m4base in $m4dirs; do
3991 # Ambiguous - guess what the user meant.
3992 if test $# = 0; then
3993 # No further arguments. Guess the user wants to update all of them.
3994 for m4base in $m4dirs; do
3995 # Perform func_import in a subshell, so that variable values
3997 # local_gnulib_dir, avoidlist, sourcebase, m4base, pobase,
3998 # docbase, testsbase, inctests, libname, lgpl, makefile_name,
3999 # libtool, macro_prefix, po_domain
4000 # don't propagate from one directory to another.
4001 (func_import) || func_exit 1
4005 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
4013 if test -z "$destdir"; then
4014 func_fatal_error "please specify --dir option"
4017 test -d "$destdir" \
4018 || func_fatal_error "could not create destination directory"
4019 test -n "$auxdir" || auxdir="build-aux"
4020 func_create_testdir "$destdir" "$*"
4023 create-megatestdir )
4024 if test -z "$destdir"; then
4025 func_fatal_error "please specify --dir option"
4027 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4028 test -n "$auxdir" || auxdir="build-aux"
4029 func_create_megatestdir "$destdir" "$*"
4033 test -n "$destdir" || destdir=testdir$$
4034 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4035 test -n "$auxdir" || auxdir="build-aux"
4036 func_create_testdir "$destdir" "$*"
4040 ../configure || func_exit 1
4042 make check || func_exit 1
4043 make distclean || func_exit 1
4044 remaining=`find . -type f -print`
4045 if test -n "$remaining"; then
4046 echo "Remaining files:" $remaining 1>&2
4047 echo "gnulib-tool: *** Stop." 1>&2
4056 test -n "$destdir" || destdir=testdir$$
4057 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4058 test -n "$auxdir" || auxdir="build-aux"
4059 func_create_megatestdir "$destdir" "$*"
4067 remaining=`find . -type f -print`
4068 if test -n "$remaining"; then
4069 echo "Remaining files:" $remaining 1>&2
4070 echo "gnulib-tool: *** Stop." 1>&2
4078 extract-description )
4082 if test -n "$module"; then
4083 func_get_description "$module"
4092 if test -n "$module"; then
4093 func_get_notice "$module"
4102 if test -n "$module"; then
4103 func_get_filelist "$module"
4108 extract-dependencies )
4112 if test -n "$module"; then
4113 func_get_dependencies "$module"
4118 extract-autoconf-snippet )
4122 if test -n "$module"; then
4123 func_get_autoconf_snippet "$module"
4128 extract-automake-snippet )
4132 if test -n "$module"; then
4133 func_get_automake_snippet "$module"
4138 extract-include-directive )
4142 if test -n "$module"; then
4143 func_get_include_directive "$module"
4148 extract-link-directive )
4152 if test -n "$module"; then
4153 func_get_link_directive "$module"
4162 if test -n "$module"; then
4163 func_get_license "$module"
4168 extract-maintainer )
4172 if test -n "$module"; then
4173 func_get_maintainer "$module"
4178 extract-tests-module )
4182 if test -n "$module"; then
4183 func_get_tests_module "$module"
4189 func_fatal_error "unknown operation mode --$mode" ;;
4193 # Undo the effect of the previous 'trap' command. Some shellology:
4194 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
4195 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
4196 # exit); for the others we need to call 'exit' explicitly. The value of $? is
4197 # 128 + signal number and is set before the trap-registered command is run.
4199 trap 'func_exit $?' 1 2 3 13 15
4204 # indent-tabs-mode: nil
4205 # whitespace-check-buffer-indent: nil