3 # Copyright (C) 2002-2007 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # This program is meant for authors or maintainers which want to import
21 # modules from gnulib into their packages.
25 cvsdatestamp='$Date: 2007-09-09 11:49:58 $'
26 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
27 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
32 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
36 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
37 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
41 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
44 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
47 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
48 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
49 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
50 AUTOCONF="${AUTOCONFPATH}autoconf"
52 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
53 AUTOHEADER="${AUTOCONFPATH}autoheader"
55 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
56 ACLOCAL="${AUTOMAKEPATH}aclocal"
58 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
59 AUTOMAKE="${AUTOMAKEPATH}automake"
61 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
62 AUTORECONF="${AUTOCONFPATH}autoreconf"
65 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
66 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
67 AUTOPOINT="${GETTEXTPATH}autopoint"
70 # When using GNU sed, turn off as many GNU extensions as possible,
71 # to minimize the risk of accidentally using non-portable features.
72 # However, do this only for gnulib-tool itself, not for the code that
73 # gnulib-tool generates, since we don't want "sed --posix" to leak
75 if (alias) > /dev/null 2>&1 && echo | sed --posix -e d >/dev/null 2>&1; then
76 alias sed='sed --posix'
80 # outputs to stdout the --help usage message.
84 Usage: gnulib-tool --list
85 gnulib-tool --import [module1 ... moduleN]
87 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
88 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
89 gnulib-tool --test --dir=directory module1 ... moduleN
90 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
91 gnulib-tool --extract-description module
92 gnulib-tool --extract-filelist module
93 gnulib-tool --extract-dependencies module
94 gnulib-tool --extract-autoconf-snippet module
95 gnulib-tool --extract-automake-snippet module
96 gnulib-tool --extract-include-directive module
97 gnulib-tool --extract-link-directive module
98 gnulib-tool --extract-license module
99 gnulib-tool --extract-maintainer module
100 gnulib-tool --extract-tests-module module
103 --list print the available module names
104 --import import the given modules into the current package;
105 if no modules are specified, update the current
106 package from the current gnulib
107 --update update the current package, restore files omitted
109 --create-testdir create a scratch package with the given modules
110 --create-megatestdir create a mega scratch package with the given modules
111 one by one and all together
112 --test test the combination of the given modules
113 (recommended to use CC=\"gcc -Wall\" here)
114 --megatest test the given modules one by one and all together
115 (recommended to use CC=\"gcc -Wall\" here)
116 --extract-description extract the description
117 --extract-filelist extract the list of files
118 --extract-dependencies extract the dependencies
119 --extract-autoconf-snippet extract the snippet for configure.ac
120 --extract-automake-snippet extract the snippet for library makefile
121 --extract-include-directive extract the #include directive
122 --extract-link-directive extract the linker directive
123 --extract-license report the license terms of the source files
125 --extract-maintainer report the maintainer(s) inside gnulib
126 --extract-tests-module report the unit test module, if it exists
129 --dir=DIRECTORY Specify the target directory.
130 For --import, this specifies where your
131 configure.ac can be found. Defaults to current
133 --local-dir=DIRECTORY Specify a local override directory where to look
134 up files before looking in gnulib's directory.
135 --verbose Increase verbosity. May be repeated.
136 --quiet Decrease verbosity. May be repeated.
138 Options for --import:
139 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
140 --source-base=DIRECTORY
141 Directory relative to --dir where source code is
142 placed (default \"lib\").
143 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
144 placed (default \"m4\").
145 --po-base=DIRECTORY Directory relative to --dir where *.po files are
146 placed (default \"po\").
147 --doc-base=DIRECTORY Directory relative to --dir where doc files are
148 placed (default \"doc\").
149 --tests-base=DIRECTORY
150 Directory relative to --dir where unit tests are
151 placed (default \"tests\").
152 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
153 tools are placed (default \"build-aux\").
154 --with-tests Include unit tests for the included modules.
155 --avoid=MODULE Avoid including the given MODULE. Useful if you
156 have code that provides equivalent functionality.
157 This option can be repeated.
158 --lgpl Abort if modules aren't available under the LGPL.
159 Also modify license template from GPL to LGPL.
160 --makefile-name=NAME Name of makefile in automake syntax in the
161 source-base and tests-base directories
162 (default \"Makefile.am\").
163 --libtool Use libtool rules.
164 --no-libtool Don't use libtool rules.
165 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
166 'gl_INIT'. Default is 'gl'.
167 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
168 the package name. A suffix '-gnulib' is appended.
169 --no-changelog don't update or create ChangeLog files
171 Options for --import and --update:
172 --dry-run For --import, only print what would have been done.
173 -s, --symbolic, --symlink Make symbolic links instead of copying files.
174 --local-symlink Make symbolic links instead of copying files, only
175 for files from the local override directory.
176 -S, --more-symlinks Make symbolic links instead of copying files, and
177 don't replace copyright notices.
179 Report bugs to <bug-gnulib@gnu.org>."
183 # outputs to stdout the --version message.
186 year=`echo "$last_checkin_date" | sed -e 's,/.*$,,'`
188 $progname (GNU $package) $version
189 Copyright (C) $year Free Software Foundation, Inc.
190 This is free software; see the source for copying conditions. There is NO
191 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
192 Written by" "Bruno Haible" "and" "Simon Josefsson"
195 # func_emit_copyright_notice
196 # outputs to stdout a header for a generated file.
197 func_emit_copyright_notice ()
199 echo "# Copyright (C) 2004-2007 Free Software Foundation, Inc."
201 echo "# This file is free software, distributed under the terms of the GNU"
202 echo "# General Public License. As a special exception to the GNU General"
203 echo "# Public License, this file may be distributed as part of a program"
204 echo "# that contains a configuration script generated by Autoconf, under"
205 echo "# the same distribution terms as the rest of that program."
207 echo "# Generated by gnulib-tool."
218 # creates a temporary directory.
220 # - tmp pathname of freshly created temporary directory
223 # Use the environment variable TMPDIR, falling back to /tmp. This allows
224 # users to specify a different temporary directory, for example, if their
225 # /tmp is filled up or too small.
228 # Use the mktemp program if available. If not available, hide the error
230 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
231 test -n "$tmp" && test -d "$tmp"
234 # Use a simple mkdir command. It is guaranteed to fail if the directory
235 # already exists. $RANDOM is bash specific and expands to empty in shells
236 # other than bash, ksh and zsh. Its use does not increase security;
237 # rather, it minimizes the probability of failure in a very cluttered /tmp
239 tmp=$TMPDIR/gl$$-$RANDOM
240 (umask 077 && mkdir "$tmp")
243 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
248 # func_append var value
249 # appends the given value to the shell variable var.
250 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
251 # Use bash's += operator. It reduces complexity of appending repeatedly to
252 # a single variable from O(n^2) to O(n).
260 eval "$1=\"\$$1\$2\""
264 # func_fatal_error message
265 # outputs to stderr a fatal error message, and terminates the program.
268 echo "gnulib-tool: *** $1" 1>&2
269 echo "gnulib-tool: *** Stop." 1>&2
273 # func_readlink SYMLINK
274 # outputs the target of the given symlink.
275 if (type -p readlink) > /dev/null 2>&1; then
278 # Use the readlink program from GNU coreutils.
284 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
285 # would do the wrong thing if the link target contains " -> ".
286 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
290 # func_relativize DIR1 DIR2
291 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
293 # - DIR1 relative pathname, relative to the current directory
294 # - DIR2 relative pathname, relative to the current directory
296 # - reldir relative pathname of DIR2, relative to DIR1
302 sed_first='s,^\([^/]*\)/.*$,\1,'
303 sed_rest='s,^[^/]*/*,,'
304 sed_last='s,^.*/\([^/]*\)$,\1,'
305 sed_butlast='s,/*[^/]*$,,'
306 while test -n "$dir1"; do
307 first=`echo "$dir1" | sed -e "$sed_first"`
308 if test "$first" != "."; then
309 if test "$first" = ".."; then
310 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
311 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
313 first2=`echo "$dir2" | sed -e "$sed_first"`
314 if test "$first2" = "$first"; then
315 dir2=`echo "$dir2" | sed -e "$sed_rest"`
319 dir0="$dir0"/"$first"
322 dir1=`echo "$dir1" | sed -e "$sed_rest"`
327 # func_relconcat DIR1 DIR2
328 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
330 # - DIR1 relative pathname, relative to the current directory
331 # - DIR2 relative pathname, relative to DIR1
333 # - relconcat DIR1/DIR2, relative to the current directory
338 sed_first='s,^\([^/]*\)/.*$,\1,'
339 sed_rest='s,^[^/]*/*,,'
340 sed_last='s,^.*/\([^/]*\)$,\1,'
341 sed_butlast='s,/*[^/]*$,,'
343 first=`echo "$dir2" | sed -e "$sed_first"`
344 if test "$first" = "."; then
345 dir2=`echo "$dir2" | sed -e "$sed_rest"`
346 if test -z "$dir2"; then
351 last=`echo "$dir1" | sed -e "$sed_last"`
352 while test "$last" = "."; do
353 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
354 last=`echo "$dir1" | sed -e "$sed_last"`
356 if test -z "$dir1"; then
360 if test "$first" = ".."; then
361 if test "$last" = ".."; then
362 relconcat="$dir1/$dir2"
365 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
366 dir2=`echo "$dir2" | sed -e "$sed_rest"`
367 if test -z "$dir1"; then
371 if test -z "$dir2"; then
376 relconcat="$dir1/$dir2"
384 # Like ln -s, except that SRC is given relative to the current directory (or
385 # absolute), not given relative to the directory of DEST.
391 *) # SRC is relative.
394 ln -s "`pwd`/$1" "$2" ;;
395 *) # DEST is relative too.
396 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
397 test -n "$ln_destdir" || ln_destdir="."
398 func_relativize "$ln_destdir" "$1"
406 # func_ln_if_changed SRC DEST
407 # Like func_ln, but avoids munging timestamps if the link is correct.
408 func_ln_if_changed ()
410 if test $# -ne 2; then
411 echo "usage: func_ln_if_changed SRC DEST" >&2
413 ln_target=`func_readlink "$2"`
414 if test -h "$2" && test "$1" = "$ln_target"; then
422 # Ensure an 'echo' command that does not interpret backslashes.
424 # echo '\n' | wc -l prints 1 when OK, 2 when KO
425 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
426 # This problem is a weird heritage from SVR4. BSD got it right (except that
427 # BSD echo interprets '-n' as an option, which is also not desirable).
428 # Nowadays the problem occurs in 4 situations:
429 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
430 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
431 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
432 # - in zsh, when sh-emulation is not set,
433 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
434 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
435 # - in Solaris /bin/sh and OSF/1 /bin/sh.
436 # We try the following workarounds:
437 # - for all: respawn using $CONFIG_SHELL if that is set and works.
438 # - for bash >= 2.04: unset the shell option xpg_echo.
439 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
440 # - for bash < 2.0: define echo to a function that uses cat of a here document.
441 # - for zsh: turn sh-emulation on.
442 # - for ksh: alias echo to 'print -r'.
443 # - for ksh: alias echo to a function that uses cat of a here document.
444 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
445 # the ksh workaround.
446 # - otherwise: respawn using /bin/sh and rely on the workarounds.
447 # When respawning, we pass --no-reexec as first argument, so as to avoid
448 # turning this script into a fork bomb in unlucky situations.
450 if echo '\t' | grep t > /dev/null; then
451 have_echo=yes # Lucky!
453 # Try the workarounds.
454 # Respawn using $CONFIG_SHELL if that is set and works.
455 if test -z "$have_echo" \
456 && test "X$1" != "X--no-reexec" \
457 && test -n "$CONFIG_SHELL" \
458 && test -f "$CONFIG_SHELL" \
459 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
460 exec $CONFIG_SHELL "$0" --no-reexec "$@"
463 # For bash >= 2.04: unset the shell option xpg_echo.
464 if test -z "$have_echo" \
465 && test -n "$BASH_VERSION" \
466 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
470 # For bash >= 2.0: define echo to a function that uses the printf built-in.
471 # For bash < 2.0: define echo to a function that uses cat of a here document.
472 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
473 if test -z "$have_echo" \
474 && test -n "$BASH_VERSION"; then \
475 if type printf 2>/dev/null | grep / > /dev/null; then
476 # 'printf' is not a shell built-in.
484 # 'printf' is a shell built-in.
490 if echo '\t' | grep t > /dev/null; then
494 # For zsh: turn sh-emulation on.
495 if test -z "$have_echo" \
496 && test -n "$ZSH_VERSION" \
497 && (emulate sh) >/dev/null 2>&1; then
500 # For ksh: alias echo to 'print -r'.
501 if test -z "$have_echo" \
502 && (type print) >/dev/null 2>&1; then
503 # A 'print' command exists.
504 if type print 2>/dev/null | grep / > /dev/null; then
507 # 'print' is a shell built-in.
508 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
509 # 'print' is the ksh shell built-in.
510 alias echo='print -r'
514 if test -z "$have_echo" \
515 && echo '\t' | grep t > /dev/null; then
518 # For ksh: alias echo to a function that uses cat of a here document.
519 # The ksh manual page says:
520 # "Aliasing is performed when scripts are read, not while they are executed.
521 # Therefore, for an alias to take effect, the alias definition command has
522 # to be executed before the command which references the alias is read."
523 # Because of this, we have to play strange tricks with have_echo, to ensure
524 # that the top-level statement containing the test starts after the 'alias'
526 if test -z "$have_echo"; then
533 alias echo=bsd_echo 2>/dev/null
535 if test -z "$have_echo" \
536 && echo '\t' | grep t > /dev/null; then
539 if test -z "$have_echo"; then
540 unalias echo 2>/dev/null
542 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
543 if test -z "$have_echo" \
544 && test "X$1" != "X--no-reexec" \
545 && test -f /bin/ksh; then
546 exec /bin/ksh "$0" --no-reexec "$@"
549 # Otherwise: respawn using /bin/sh.
550 if test -z "$have_echo" \
551 && test "X$1" != "X--no-reexec" \
552 && test -f /bin/sh; then
553 exec /bin/sh "$0" --no-reexec "$@"
556 if test -z "$have_echo"; then
557 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
559 if echo '\t' | grep t > /dev/null; then
562 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
564 if test "X$1" = "X--no-reexec"; then
568 # Command-line option processing.
569 # Removes the OPTIONS from the arguments. Sets the variables:
570 # - mode list or import or create-testdir or create-megatestdir
571 # - destdir from --dir
572 # - local_gnulib_dir from --local-dir
573 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
574 # - libname, supplied_libname from --lib
575 # - sourcebase from --source-base
576 # - m4base from --m4-base
577 # - pobase from --po-base
578 # - docbase from --doc-base
579 # - testsbase from --tests-base
580 # - auxdir from --aux-dir
581 # - inctests true if --with-tests was given, blank otherwise
582 # - avoidlist list of modules to avoid, from --avoid
583 # - lgpl true if --lgpl was given, blank otherwise
584 # - makefile_name from --makefile-name
585 # - libtool true if --libtool was given, false if --no-libtool was
586 # given, blank otherwise
587 # - macro_prefix from --macro-prefix
588 # - po_domain from --po-domain
589 # - autoconf_minversion minimum supported autoconf version
590 # - do_changelog false if --no-changelog was given, : otherwise
591 # - doit : if actions shall be executed, false if only to be printed
592 # - symbolic true if --symlink or --more-symlinks was given, blank
594 # - lsymbolic true if --local-symlink was given, blank otherwise
595 # - do_copyrights blank if --more-symlinks was given, true otherwise
624 while test $# -gt 0; do
629 --import | --impor | --impo | --imp | --im | --i )
632 --update | --updat | --upda | --upd | --up | --u )
635 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
638 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
639 mode=create-megatestdir
641 --test | --tes | --te | --t )
644 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
648 mode=`echo "X$1" | sed -e 's/^X--//'`
653 func_fatal_error "missing argument for --dir"
658 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
663 func_fatal_error "missing argument for --local-dir"
668 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
670 --verbose | --verbos | --verbo | --verb )
671 verbose=`expr $verbose + 1`
673 --quiet | --quie | --qui | --qu | --q )
674 verbose=`expr $verbose - 1`
679 func_fatal_error "missing argument for --lib"
682 supplied_libname=true
685 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
686 supplied_libname=true
691 func_fatal_error "missing argument for --source-base"
696 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
701 func_fatal_error "missing argument for --m4-base"
706 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
711 func_fatal_error "missing argument for --po-base"
716 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
721 func_fatal_error "missing argument for --doc-base"
726 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
731 func_fatal_error "missing argument for --tests-base"
736 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
741 func_fatal_error "missing argument for --aux-dir"
746 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
754 func_fatal_error "missing argument for --avoid"
756 func_append avoidlist " $1"
759 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
760 func_append avoidlist " $arg"
768 func_fatal_error "missing argument for --makefile-name"
773 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
784 func_fatal_error "missing argument for --macro-prefix"
789 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
794 func_fatal_error "missing argument for --po-domain"
799 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
801 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
807 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
810 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
813 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
817 --help | --hel | --he | --h )
820 --version | --versio | --versi | --vers )
824 # Stop option processing
828 echo "gnulib-tool: unknown option $1" 1>&2
829 echo "Try 'gnulib-tool --help' for more information." 1>&2
836 if test "$mode" = update; then
837 if test $# != 0; then
838 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
839 echo "Try 'gnulib-tool --help' for more information." 1>&2
840 echo "If you really want to modify the gnulib configuration of your project," 1>&2
841 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
844 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
845 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
846 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
847 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
848 || test -n "$makefile_name" || test -n "$macro_prefix" \
849 || test -n "$po_domain"; then
850 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
851 echo "Try 'gnulib-tool --help' for more information." 1>&2
852 echo "If you really want to modify the gnulib configuration of your project," 1>&2
853 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
858 if test -n "$pobase" && test -z "$po_domain"; then
859 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
860 echo "Try 'gnulib-tool --help' for more information." 1>&2
863 if test -z "$pobase" && test -n "$po_domain"; then
864 echo "gnulib-tool: warning: --po-domain has no effect without a --po-base option" 1>&2
867 # Determine the minimum supported autoconf version from the project's
869 DEFAULT_AUTOCONF_MINVERSION="2.59"
872 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
873 if test -f "$destdir"/configure.ac; then
874 configure_ac="$destdir/configure.ac"
876 if test -f "$destdir"/configure.in; then
877 configure_ac="$destdir/configure.in"
881 if test -f configure.ac; then
882 configure_ac="configure.ac"
884 if test -f configure.in; then
885 configure_ac="configure.in"
889 if test -n "$configure_ac"; then
890 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
891 # because when some m4 files are omitted from a CVS repository,
892 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
893 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
894 # autom4te: m4 failed with exit status: 1
901 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
903 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
904 if test -n "$prereqs"; then
905 autoconf_minversion=`
906 for version in $prereqs; do echo $version; done |
907 LC_ALL=C sort -nru | sed 1q
911 if test -z "$autoconf_minversion"; then
912 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
914 case "$autoconf_minversion" in
915 1.* | 2.[0-4]* | 2.5[0-8]*)
916 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
919 # Remove trailing slashes from the directory names. This is necessary for
920 # m4base (to avoid an error in func_import) and optional for the others.
921 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
922 case "$local_gnulib_dir" in
923 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
925 case "$sourcebase" in
926 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
929 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
932 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
935 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
938 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
941 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
946 /*) self_abspathname="$0" ;;
947 */*) self_abspathname=`pwd`/"$0" ;;
950 # Iterate through the elements of $PATH.
951 # We use IFS=: instead of
952 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
953 # because the latter does not work when some PATH element contains spaces.
954 # We use a canonicalized $pathx instead of $PATH, because empty PATH
955 # elements are by definition equivalent to '.', however field splitting
956 # according to IFS=: loses empty fields in many shells:
957 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
958 # beginning, at the end, and in the middle),
959 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
960 # at the beginning and at the end,
961 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
962 # Solaris lose empty fields at the end.
963 # The 'case' statement is an optimization, to avoid evaluating the
964 # explicit canonicalization command when $PATH contains no empty fields.
966 if test "${PATH_SEPARATOR+set}" != set; then
968 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
969 chmod +x "$tmp"/conf.sh
970 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
977 if test "$PATH_SEPARATOR" = ";"; then
978 # On Windows, programs are searched in "." before $PATH.
981 # On Unix, we have to convert empty PATH elements to ".".
985 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
990 IFS="$PATH_SEPARATOR"
994 if test -x "$d/$0" && test ! -d "$d/$0"; then
995 self_abspathname="$d/$0"
1000 if test -z "$self_abspathname"; then
1001 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
1005 while test -h "$self_abspathname"; do
1006 # Resolve symbolic link.
1007 linkval=`func_readlink "$self_abspathname"`
1008 test -n "$linkval" || break
1010 /* ) self_abspathname="$linkval" ;;
1011 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
1014 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
1017 trap 'exit_status=$?
1018 if test "$signal" != 0; then
1019 echo "caught signal $signal" >&2
1022 exit $exit_status' 0
1023 for signal in 1 2 3 13 15; do
1024 trap '{ signal='$signal'; func_exit 1; }' $signal
1028 # func_lookup_file file
1029 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1032 # - local_gnulib_dir from --local-dir
1034 # - lookedup_file name of the merged (combined) file
1035 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1039 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1040 lookedup_file="$local_gnulib_dir/$lkfile"
1043 if test -f "$gnulib_dir/$lkfile"; then
1044 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1045 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1046 rm -f "$tmp/$lkbase"
1047 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1048 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1049 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1050 lookedup_file="$tmp/$lkbase"
1053 lookedup_file="$gnulib_dir/$lkfile"
1057 func_fatal_error "file $gnulib_dir/$lkfile not found"
1064 # - local_gnulib_dir from --local-dir
1067 # Filter out metainformation files like README, which are not modules.
1068 # Filter out unit test modules; they can be retrieved through
1069 # --extract-tests-module if desired.
1071 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1072 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1073 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1076 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1077 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1078 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1079 -e '/^README$/d' -e '/\/README$/d' \
1080 -e '/^TEMPLATE$/d' \
1081 -e '/^TEMPLATE-EXTENDED$/d' \
1082 -e '/^TEMPLATE-TESTS$/d' \
1085 | sed -e '/-tests$/d' \
1089 # func_verify_module
1090 # verifies a module name
1092 # - local_gnulib_dir from --local-dir
1093 # - module module name argument
1094 func_verify_module ()
1096 if { test -f "$gnulib_dir/modules/$module" \
1097 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1098 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1099 && test "CVS" != "$module" \
1100 && test "ChangeLog" != "$module" \
1101 && test "COPYING" != "$module" \
1102 && test "README" != "$module" \
1103 && test "TEMPLATE" != "$module" \
1104 && test "TEMPLATE-EXTENDED" != "$module" \
1105 && test "TEMPLATE-TESTS" != "$module"; then
1106 # OK, $module is a correct module name.
1107 # Verify that building the module description with 'patch' succeeds.
1108 func_lookup_file "modules/$module"
1110 echo "gnulib-tool: module $module doesn't exist" 1>&2
1115 # func_verify_nontests_module
1116 # verifies a module name, excluding tests modules
1118 # - local_gnulib_dir from --local-dir
1119 # - module module name argument
1120 func_verify_nontests_module ()
1123 *-tests ) module= ;;
1124 * ) func_verify_module ;;
1128 # func_verify_tests_module
1129 # verifies a module name, considering only tests modules
1131 # - local_gnulib_dir from --local-dir
1132 # - module module name argument
1133 func_verify_tests_module ()
1136 *-tests ) func_verify_module ;;
1141 sed_extract_prog=':[ ]*$/ {
1144 s/^Description:[ ]*$//
1146 s/^Depends-on:[ ]*$//
1147 s/^configure\.ac-early:[ ]*$//
1148 s/^configure\.ac:[ ]*$//
1149 s/^Makefile\.am:[ ]*$//
1153 s/^Maintainer:[ ]*$//
1160 # func_get_description module
1162 # - local_gnulib_dir from --local-dir
1163 func_get_description ()
1165 func_lookup_file "modules/$1"
1166 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1169 # func_get_filelist module
1171 # - local_gnulib_dir from --local-dir
1172 func_get_filelist ()
1174 func_lookup_file "modules/$1"
1175 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1176 echo m4/gnulib-common.m4
1177 case "$autoconf_minversion" in
1179 #echo m4/onceonly.m4
1180 echo m4/onceonly_2_57.m4
1185 # func_get_dependencies module
1187 # - local_gnulib_dir from --local-dir
1188 func_get_dependencies ()
1190 # ${module}-tests always implicitly depends on ${module}.
1191 echo "$1" | sed -n -e 's/-tests//p'
1192 # Then the explicit dependencies listed in the module description.
1193 func_lookup_file "modules/$1"
1194 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1197 # func_get_autoconf_early_snippet module
1199 # - local_gnulib_dir from --local-dir
1200 func_get_autoconf_early_snippet ()
1202 func_lookup_file "modules/$1"
1203 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1206 # func_get_autoconf_snippet module
1208 # - local_gnulib_dir from --local-dir
1209 func_get_autoconf_snippet ()
1211 func_lookup_file "modules/$1"
1212 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1215 # func_get_automake_snippet module
1217 # - local_gnulib_dir from --local-dir
1218 func_get_automake_snippet ()
1220 func_lookup_file "modules/$1"
1221 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1224 # *-tests module live in tests/, not lib/.
1227 # Synthesize an EXTRA_DIST augmentation.
1228 sed_combine_lines='/\\$/{
1235 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1236 already_mentioned_files=` \
1237 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1238 | sed -e "$sed_combine_lines" \
1239 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1240 all_files=`func_get_filelist $1`
1241 lib_files=`for f in $all_files; do \
1245 done | sed -e 's,^lib/,,'`
1246 # Remove $already_mentioned_files from $lib_files.
1247 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1248 extra_files=`for f in $already_mentioned_files; do echo $f; done \
1249 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1250 if test -n "$extra_files"; then
1251 echo "EXTRA_DIST +=" $extra_files
1254 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1255 # This is necessary so that automake can generate the right list of
1257 # A possible approach would be to use autom4te --trace of the redefined
1258 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1259 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1260 # inside autoconf's built-in macros are not missed).
1261 # But it's simpler and more robust to do it here, based on the file list.
1262 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1263 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1264 # automake will generate a useless dependency; this is harmless.
1266 relocatable-prog-wrapper) ;;
1268 sed_extract_c_files='/\.c$/p'
1269 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1270 if test -n "$extra_files"; then
1271 echo "EXTRA_lib_SOURCES +=" $extra_files
1276 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1277 buildaux_files=`for f in $all_files; do \
1279 build-aux/*) echo $f ;; \
1281 done | sed -e 's,^build-aux/,,'`
1282 if test -n "$buildaux_files"; then
1283 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1284 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1291 # func_get_include_directive module
1293 # - local_gnulib_dir from --local-dir
1294 func_get_include_directive ()
1296 func_lookup_file "modules/$1"
1297 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1298 sed -e 's/^\(["<]\)/#include \1/'
1301 # func_get_link_directive module
1303 # - local_gnulib_dir from --local-dir
1304 func_get_link_directive ()
1306 func_lookup_file "modules/$1"
1307 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1310 # func_get_license module
1312 # - local_gnulib_dir from --local-dir
1315 func_lookup_file "modules/$1"
1316 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1317 # The default is GPL.
1319 } | sed -e 's,^ *$,,' | sed -e 1q
1322 # func_get_maintainer module
1324 # - local_gnulib_dir from --local-dir
1325 func_get_maintainer ()
1327 func_lookup_file "modules/$1"
1328 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1331 # func_get_tests_module module
1333 # - local_gnulib_dir from --local-dir
1334 func_get_tests_module ()
1336 # The naming convention for tests modules is hardwired: ${module}-tests.
1337 if test -f "$gnulib_dir/modules/$1"-tests \
1338 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1339 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1344 # func_acceptable module
1345 # tests whether a module is acceptable.
1347 # - avoidlist list of modules to avoid
1350 for avoid in $avoidlist; do
1351 if test "$avoid" = "$1"; then
1358 # func_modules_transitive_closure
1360 # - local_gnulib_dir from --local-dir
1361 # - modules list of specified modules
1362 # - inctests true if tests should be included, blank otherwise
1363 # - avoidlist list of modules to avoid
1364 # - tmp pathname of a temporary directory
1366 # - modules list of modules, including dependencies
1367 func_modules_transitive_closure ()
1369 # In order to process every module only once (for speed), process an "input
1370 # list" of modules, producing an "output list" of modules. During each round,
1371 # more modules can be queued in the input list. Once a module on the input
1372 # list has been processed, it is added to the "handled list", so we can avoid
1373 # to process it again.
1375 inmodules="$modules"
1377 while test -n "$inmodules"; do
1378 inmodules_this_round="$inmodules"
1379 inmodules= # Accumulator, queue for next round
1380 for module in $inmodules_this_round; do
1382 if test -n "$module"; then
1383 if func_acceptable $module; then
1384 func_append outmodules " $module"
1385 deps=`func_get_dependencies $module`
1386 # Duplicate dependencies are harmless, but Jim wants a warning.
1387 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1388 if test -n "$duplicated_deps"; then
1389 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1391 func_append inmodules " $deps"
1392 if test -n "$inctests"; then
1393 testsmodule=`func_get_tests_module $module`
1394 if test -n "$testsmodule"; then
1395 func_append inmodules " $testsmodule"
1401 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1402 # Remove $handledmodules from $inmodules.
1403 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1404 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1406 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1407 rm -f "$tmp"/queued-modules
1410 # func_modules_add_dummy
1412 # - local_gnulib_dir from --local-dir
1413 # - modules list of modules, including dependencies
1415 # - modules list of modules, including 'dummy' if needed
1416 func_modules_add_dummy ()
1419 sed_remove_backslash_newline=':a
1426 for module in $modules; do
1427 func_verify_nontests_module
1428 if test -n "$module"; then
1429 # Extract the value of "lib_SOURCES += ...".
1430 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1431 # Ignore .h files since they are not compiled.
1434 *) have_lib_SOURCES=yes ;;
1439 # Add the dummy module, to make sure the library will be non-empty.
1440 if test -z "$have_lib_SOURCES"; then
1441 if func_acceptable "dummy"; then
1442 func_append modules " dummy"
1447 # func_modules_to_filelist
1449 # - local_gnulib_dir from --local-dir
1450 # - modules list of modules, including dependencies
1452 # - files list of files
1453 func_modules_to_filelist ()
1456 for module in $modules; do
1458 if test -n "$module"; then
1459 fs=`func_get_filelist $module`
1460 func_append files " $fs"
1463 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1467 # func_execute_command command [args...]
1468 # Executes a command.
1469 # Uses also the variables
1470 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1471 func_execute_command ()
1473 if test $verbose -ge 0; then
1477 # Commands like automake produce output to stderr even when the succeed.
1478 # Turn this output off if the command succeeds.
1479 "$@" > "$tmp"/cmdout 2>&1
1481 if test $cmdret = 0; then
1485 cat "$tmp"/cmdout 1>&2
1492 # func_emit_lib_Makefile_am
1493 # emits the contents of library makefile to standard output.
1495 # - local_gnulib_dir from --local-dir
1496 # - modules list of modules, including dependencies
1497 # - libname library name
1498 # - pobase directory relative to destdir where to place *.po files
1499 # - auxdir directory relative to destdir where to place build aux files
1500 # - makefile_name from --makefile-name
1501 # - libtool true if libtool will be used, false or blank otherwise
1502 # - macro_prefix prefix of gl_LIBOBJS macros to use
1503 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1504 # - actioncmd (optional) command that will reproduce this invocation
1505 # - for_test true if creating a package for testing, false otherwise
1507 # - uses_subdirs nonempty if object files in subdirs exist
1508 func_emit_lib_Makefile_am ()
1510 # When creating an includable Makefile.am snippet, augment variables with
1511 # += instead of assigning them.
1512 if test -n "$makefile_name"; then
1517 if test "$libtool" = true; then
1520 sed_eliminate_LDFLAGS=
1524 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1527 # When creating a package for testing: Attempt to provoke failures,
1528 # especially link errors, already during "make" rather than during
1529 # "make check", because "make check" is not possible in a cross-compiling
1530 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1531 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1533 sed_transform_check_PROGRAMS=
1535 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1536 echo "## Process this file with automake to produce Makefile.in."
1537 func_emit_copyright_notice
1538 if test -n "$actioncmd"; then
1539 echo "# Reproduce by: $actioncmd"
1544 for module in $modules; do
1545 func_verify_nontests_module
1546 if test -n "$module"; then
1548 func_get_automake_snippet "$module" |
1549 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1550 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1551 -e "$sed_eliminate_LDFLAGS" \
1552 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1553 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1554 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1555 -e "$sed_transform_check_PROGRAMS"
1556 if test "$module" = 'alloca'; then
1557 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1558 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1561 # Skip the contents if its entirely empty.
1562 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1563 echo "## begin gnulib module $module"
1566 echo "## end gnulib module $module"
1570 # Test whether there are some source files in subdirectories.
1571 for f in `func_get_filelist "$module"`; do
1573 lib/*/*.c) uses_subdirs=yes ;;
1579 if test -z "$makefile_name"; then
1580 # If there are source files in subdirectories, prevent collision of the
1581 # object files (example: hash.c and libxml/hash.c).
1583 if test -n "$uses_subdirs"; then
1584 subdir_options=' subdir-objects'
1586 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1589 if test -z "$makefile_name"; then
1590 echo "noinst_HEADERS ="
1591 echo "noinst_LIBRARIES ="
1592 echo "noinst_LTLIBRARIES ="
1593 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1594 # if you specify pkgdata_DATA to empty. This is a workaround.
1595 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1596 echo "pkgdata_DATA ="
1599 echo "BUILT_SOURCES ="
1602 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1603 if test -z "$makefile_name"; then
1604 echo "MOSTLYCLEANDIRS ="
1606 echo "DISTCLEANFILES ="
1607 echo "MAINTAINERCLEANFILES ="
1609 echo "AM_CPPFLAGS ="
1612 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1613 # One of the snippets already specifies an installation location for the
1614 # library. Don't confuse automake by saying it should not be installed.
1617 # By default, the generated library should not be installed.
1618 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1621 echo "${libname}_${libext}_SOURCES ="
1622 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1623 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1624 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1625 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1626 echo "EXTRA_${libname}_${libext}_SOURCES ="
1627 if test "$libtool" = true; then
1628 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1631 if test -n "$pobase"; then
1632 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
1635 cat allsnippets.tmp \
1636 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1638 echo "mostlyclean-local: mostlyclean-generic"
1639 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1640 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1641 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1645 rm -f allsnippets.tmp
1648 # func_emit_po_Makevars
1649 # emits the contents of po/ makefile parametrization to standard output.
1651 # - local_gnulib_dir from --local-dir
1652 # - sourcebase directory relative to destdir where to place source code
1653 # - pobase directory relative to destdir where to place *.po files
1654 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1655 func_emit_po_Makevars ()
1657 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1658 func_emit_copyright_notice
1660 echo "# Usually the message domain is the same as the package name."
1661 echo "# But here it has a '-gnulib' suffix."
1662 echo "DOMAIN = ${po_domain}-gnulib"
1664 echo "# These two variables depend on the location of this directory."
1665 echo "subdir = ${pobase}"
1666 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
1669 # These options get passed to xgettext.
1670 XGETTEXT_OPTIONS = \
1671 --keyword=_ --flag=_:1:pass-c-format \
1672 --keyword=N_ --flag=N_:1:pass-c-format \
1673 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
1674 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
1675 --flag=error:3:c-format --flag=error_at_line:5:c-format
1677 # This is the copyright holder that gets inserted into the header of the
1678 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
1679 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
1681 # This is the email address or URL to which the translators shall report
1682 # bugs in the untranslated strings:
1683 # - Strings which are not entire sentences, see the maintainer guidelines
1684 # in the GNU gettext documentation, section 'Preparing Strings'.
1685 # - Strings which use unclear terms or require additional context to be
1687 # - Strings which make invalid assumptions about notation of date, time or
1689 # - Pluralisation problems.
1690 # - Incorrect English spelling.
1691 # - Incorrect formatting.
1692 # It can be your email address, or a mailing list address where translators
1693 # can write to without being subscribed, or the URL of a web page through
1694 # which the translators can contact you.
1695 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
1697 # This is the list of locale categories, beyond LC_MESSAGES, for which the
1698 # message catalogs shall be used. It is usually empty.
1699 EXTRA_LOCALE_CATEGORIES =
1701 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
1702 # context. Possible values are "yes" and "no". Set this to yes if the
1703 # package uses functions taking also a message context, like pgettext(), or
1704 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
1709 # func_emit_po_POTFILES_in
1710 # emits the file list to be passed to xgettext to standard output.
1712 # - local_gnulib_dir from --local-dir
1713 # - sourcebase directory relative to destdir where to place source code
1714 # - files list of new files
1715 func_emit_po_POTFILES_in ()
1717 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1718 func_emit_copyright_notice
1720 echo "# List of files which contain translatable strings."
1721 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
1724 # func_emit_tests_Makefile_am
1725 # emits the contents of tests makefile to standard output.
1727 # - local_gnulib_dir from --local-dir
1728 # - modules list of modules, including dependencies
1729 # - libname library name
1730 # - makefile_name from --makefile-name
1731 # - libtool true if libtool will be used, false or blank otherwise
1732 # - sourcebase relative directory containing lib source code
1733 # - m4base relative directory containing autoconf macros
1734 # - testsbase relative directory containing unit test code
1735 # - for_test true if creating a package for testing, false otherwise
1736 func_emit_tests_Makefile_am ()
1738 if test "$libtool" = true; then
1743 if test "$libtool" = true; then
1745 sed_eliminate_LDFLAGS=
1748 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1751 # When creating a package for testing: Attempt to provoke failures,
1752 # especially link errors, already during "make" rather than during
1753 # "make check", because "make check" is not possible in a cross-compiling
1754 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1755 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1757 sed_transform_check_PROGRAMS=
1759 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1760 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1761 echo "## Process this file with automake to produce Makefile.in."
1762 func_emit_copyright_notice
1764 # Generate dependencies here, since it eases the debugging of test failures.
1765 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1767 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1770 for module in $modules; do
1771 func_verify_tests_module
1772 if test -n "$module"; then
1774 func_get_automake_snippet "$module" |
1775 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1776 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1777 -e "$sed_eliminate_LDFLAGS" \
1778 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1779 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1780 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1781 -e "$sed_transform_check_PROGRAMS"
1783 # Skip the contents if its entirely empty.
1784 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1785 echo "## begin gnulib module $module"
1788 echo "## end gnulib module $module"
1795 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1796 # variable is needed to avoid an error from automake:
1797 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1800 echo "TESTS_ENVIRONMENT ="
1801 echo "noinst_PROGRAMS ="
1802 if ! $for_test; then
1803 echo "check_PROGRAMS ="
1805 echo "noinst_HEADERS ="
1806 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1807 echo "pkgdata_DATA ="
1810 echo "BUILT_SOURCES ="
1812 echo "MOSTLYCLEANFILES = core *.stackdump"
1813 echo "MOSTLYCLEANDIRS ="
1815 echo "DISTCLEANFILES ="
1816 echo "MAINTAINERCLEANFILES ="
1818 echo "AM_CPPFLAGS = \\"
1819 echo " -I. -I\$(srcdir) \\"
1820 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1821 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1823 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1826 echo "# Clean up after Solaris cc."
1828 echo " rm -rf SunWS_cache"
1830 echo "mostlyclean-local: mostlyclean-generic"
1831 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1832 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1833 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1837 rm -f allsnippets.tmp
1840 # func_emit_initmacro_start
1841 # emits the first few statements of the gl_INIT macro to standard output.
1842 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1843 func_emit_initmacro_start ()
1845 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
1846 # platform-dependent object files in ${macro_prefix}_LIBOBJS instead of
1847 # LIBOBJS. The purpose is to allow several gnulib instantiations under
1848 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
1850 # Furthermore it avoids an automake error like this when a Makefile.am
1851 # that uses pieces of gnulib also uses $(LIBOBJ):
1852 # automatically discovered file `error.c' should not be explicitly mentioned
1853 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix}_LIBOBJ]))"
1854 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix}_REPLACE_FUNCS]))"
1855 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
1856 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
1857 # automatically discovered file `error.c' should not be explicitly mentioned
1858 # We let automake know about the files to be distributed through the
1859 # EXTRA_lib_SOURCES variable.
1860 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix}_LIBSOURCES]))"
1863 # func_emit_initmacro_end
1864 # emits the last few statements of the gl_INIT macro to standard output.
1865 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1866 func_emit_initmacro_end ()
1868 echo " m4_popdef([AC_LIBSOURCES])"
1869 echo " m4_popdef([AC_REPLACE_FUNCS])"
1870 echo " m4_popdef([AC_LIBOBJ])"
1871 echo " AC_CONFIG_COMMANDS_PRE(["
1872 echo " ${macro_prefix}_libobjs="
1873 echo " ${macro_prefix}_ltlibobjs="
1874 echo " if test -n \"\$${macro_prefix}_LIBOBJS\"; then"
1875 echo " # Remove the extension."
1876 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
1877 echo " for i in \`for i in \$${macro_prefix}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
1878 echo " ${macro_prefix}_libobjs=\"\$${macro_prefix}_libobjs \$i.\$ac_objext\""
1879 echo " ${macro_prefix}_ltlibobjs=\"\$${macro_prefix}_ltlibobjs \$i.lo\""
1882 echo " AC_SUBST([${macro_prefix}_LIBOBJS], [\$${macro_prefix}_libobjs])"
1883 echo " AC_SUBST([${macro_prefix}_LTLIBOBJS], [\$${macro_prefix}_ltlibobjs])"
1887 # func_emit_initmacro_done
1888 # emits a few statements after the gl_INIT macro to standard output.
1889 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1890 func_emit_initmacro_done ()
1893 echo "# Like AC_LIBOBJ, except that the module name goes"
1894 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1895 echo "AC_DEFUN([${macro_prefix}_LIBOBJ],"
1896 echo " [${macro_prefix}_LIBOBJS=\"\$${macro_prefix}_LIBOBJS \$1.\$ac_objext\"])"
1898 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
1899 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1900 echo "AC_DEFUN([${macro_prefix}_REPLACE_FUNCS],"
1901 echo " [AC_CHECK_FUNCS([\$1], , [${macro_prefix}_LIBOBJ(\$ac_func)])])"
1903 echo "# Like AC_LIBSOURCES, except that it does nothing."
1904 echo "# We rely on EXTRA_lib..._SOURCES instead."
1905 echo "AC_DEFUN([${macro_prefix}_LIBSOURCES],"
1909 # func_import modules
1910 # Uses also the variables
1911 # - destdir target directory
1912 # - local_gnulib_dir from --local-dir
1913 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1914 # - libname library name
1915 # - sourcebase directory relative to destdir where to place source code
1916 # - m4base directory relative to destdir where to place *.m4 macros
1917 # - pobase directory relative to destdir where to place *.po files
1918 # - docbase directory relative to destdir where to place doc files
1919 # - testsbase directory relative to destdir where to place unit test code
1920 # - auxdir directory relative to destdir where to place build aux files
1921 # - inctests true if --with-tests was given, blank otherwise
1922 # - avoidlist list of modules to avoid, from --avoid
1923 # - lgpl true if library's license shall be LGPL, blank otherwise
1924 # - makefile_name from --makefile-name
1925 # - libtool true if --libtool was given, false if --no-libtool was
1926 # given, blank otherwise
1927 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1928 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1929 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1930 # - autoconf_minversion minimum supported autoconf version
1931 # - doit : if actions shall be executed, false if only to be printed
1932 # - symbolic true if files should be symlinked, copied otherwise
1933 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1935 # - do_copyrights true if copyright notices in files should be replaced,
1939 # Get the cached settings.
1940 cached_local_gnulib_dir=
1941 cached_specified_modules=
1951 cached_makefile_name=
1953 cached_macro_prefix=
1956 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1957 cached_libtool=false
1963 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
1966 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1969 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1972 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1975 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1978 s,^.*gl_PO_BASE([[ ]*\([^])]*\).*$,cached_pobase="\1",p
1981 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1984 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1987 s,^.*$,cached_inctests=true,p
1990 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1993 s,^.*$,cached_lgpl=true,p
1995 /gl_MAKEFILE_NAME(/ {
1996 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
1999 s,^.*$,cached_libtool=true,p
2001 /gl_MACRO_PREFIX(/ {
2002 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
2005 s,^.*gl_PO_DOMAIN([[ ]*\([^])]*\).*$,cached_po_domain="\1",p
2007 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2008 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2013 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2014 s,^.*$,cached_files=",p
2026 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2030 # Merge the cached settings with the specified ones.
2031 # The m4base must be the same as expected from the pathname.
2032 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2033 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2035 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2036 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2037 if test -z "$local_gnulib_dir"; then
2038 if test -n "$cached_local_gnulib_dir"; then
2041 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2043 case "$cached_local_gnulib_dir" in
2045 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2047 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2048 local_gnulib_dir="$relconcat" ;;
2053 # Append the cached and the specified module names. So that
2054 # "gnulib-tool --import foo" means to add the module foo.
2055 specified_modules="$cached_specified_modules $1"
2056 # Append the cached and the specified avoidlist. This is probably better
2057 # than dropping the cached one when --avoid is specified at least once.
2058 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2059 avoidlist=`echo $avoidlist`
2061 # The sourcebase defaults to the cached one.
2062 if test -z "$sourcebase"; then
2063 sourcebase="$cached_sourcebase"
2064 if test -z "$sourcebase"; then
2065 func_fatal_error "missing --source-base option"
2068 # The pobase defaults to the cached one.
2069 if test -z "$pobase"; then
2070 pobase="$cached_pobase"
2072 # The docbase defaults to the cached one.
2073 if test -z "$docbase"; then
2074 docbase="$cached_docbase"
2075 if test -z "$docbase"; then
2076 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."
2079 # The testsbase defaults to the cached one.
2080 if test -z "$testsbase"; then
2081 testsbase="$cached_testsbase"
2082 if test -z "$testsbase"; then
2083 func_fatal_error "missing --tests-base option"
2086 # Require the tests if specified either way.
2087 if test -z "$inctests"; then
2088 inctests="$cached_inctests"
2090 # The libname defaults to the cached one.
2091 if test -z "$supplied_libname"; then
2092 libname="$cached_libname"
2093 if test -z "$libname"; then
2094 func_fatal_error "missing --lib option"
2097 # Require LGPL if specified either way.
2098 if test -z "$lgpl"; then
2101 # The makefile_name defaults to the cached one.
2102 if test -z "$makefile_name"; then
2103 makefile_name="$cached_makefile_name"
2105 # Use libtool if specified either way, or if guessed.
2106 if test -z "$libtool"; then
2107 if test -n "$cached_m4base"; then
2108 libtool="$cached_libtool"
2110 libtool="$guessed_libtool"
2113 # The macro_prefix defaults to the cached one.
2114 if test -z "$macro_prefix"; then
2115 macro_prefix="$cached_macro_prefix"
2116 if test -z "$macro_prefix"; then
2117 func_fatal_error "missing --macro-prefix option"
2120 # The po_domain defaults to the cached one.
2121 if test -z "$po_domain"; then
2122 po_domain="$cached_po_domain"
2125 # Canonicalize the list of specified modules.
2126 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2128 # Determine final module list.
2129 modules="$specified_modules"
2130 func_modules_transitive_closure
2131 if test $verbose -ge 0; then
2132 echo "Module list with included dependencies:"
2133 echo "$modules" | sed -e 's/^/ /'
2136 # Add the dummy module if needed.
2137 func_modules_add_dummy
2139 # If --lgpl, verify that the licenses of modules are compatible.
2140 if test -n "$lgpl"; then
2141 for module in $modules; do
2142 license=`func_get_license $module`
2144 LGPL | LGPLv2+ | 'GPLed build tool') ;;
2145 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2146 *) func_fatal_error "incompatible license on module $module: $license" ;;
2151 # Determine script to apply to imported library files.
2152 sed_transform_lib_file=
2153 for module in $modules; do
2154 if test $module = config-h; then
2155 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2156 sed_transform_lib_file=$sed_transform_lib_file'
2157 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2162 if test -n "$do_copyrights"; then
2163 if test -n "$lgpl"; then
2165 sed_transform_lib_file=$sed_transform_lib_file'
2166 s/GNU General/GNU Lesser General/g
2167 s/version 2\([ ,]\)/version 2.1\1/g
2172 # Determine final file list.
2173 func_modules_to_filelist
2174 if test $verbose -ge 0; then
2176 echo "$files" | sed -e 's/^/ /'
2180 || func_fatal_error "refusing to do nothing"
2182 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2183 new_files="$files m4/gnulib-tool.m4"
2184 old_files="$cached_files"
2185 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2186 func_append old_files " m4/gnulib-tool.m4"
2189 sed_rewrite_old_files="\
2190 s,^build-aux/,$auxdir/,
2191 s,^doc/,$cached_docbase/,
2192 s,^lib/,$cached_sourcebase/,
2193 s,^m4/,$cached_m4base/,
2194 s,^tests/,$cached_testsbase/,"
2195 sed_rewrite_new_files="\
2196 s,^build-aux/,$auxdir/,
2198 s,^lib/,$sourcebase/,
2200 s,^tests/,$testsbase/,"
2202 # Create directories.
2203 { echo "$sourcebase"
2205 if test -n "$pobase"; then
2208 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2209 if test -n "$docfiles"; then
2212 if test -n "$inctests"; then
2216 for f in $files; do echo $f; done \
2217 | sed -e "$sed_rewrite_new_files" \
2218 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2221 { # Rearrange file descriptors. Needed because "while ... done < ..."
2222 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2223 exec 5<&0 < "$tmp"/dirs
2225 if test ! -d "$destdir/$d"; then
2227 echo "Creating directory $destdir/$d"
2228 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2230 echo "Create directory $destdir/$d"
2237 # func_dest_tmpfilename file
2238 # determines the name of a temporary file (file is relative to destdir).
2240 # - tmpfile absolute filename of the temporary file
2241 func_dest_tmpfilename ()
2244 # Put the new contents of $file in a file in the same directory (needed
2245 # to guarantee that an 'mv' to "$destdir/$file" works).
2246 tmpfile="$destdir/$1.tmp"
2248 # Put the new contents of $file in a file in a temporary directory
2249 # (because the directory of "$file" might not exist).
2250 tmpfile="$tmp"/`basename "$1"`.tmp
2254 # Copy files or make symbolic links. Remove obsolete files.
2258 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2259 # representing the files according to the last gnulib-tool invocation.
2260 for f in $old_files; do echo $f; done \
2261 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2264 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2265 # representing the files after this gnulib-tool invocation.
2266 for f in $new_files; do echo $f; done \
2267 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2270 # First the files that are in old-files, but not in new-files:
2271 sed_take_first_column='s,'"$delimiter"'.*,,'
2272 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2273 # Remove the file. Do nothing if the user already removed it.
2274 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
2276 echo "Removing file $g (backup in ${g}~)"
2277 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2279 echo "Remove file $g (backup in ${g}~)"
2281 func_append removed_files "$g$nl"
2284 # func_add_or_update handles a file that ought to be present afterwards.
2286 # - f the original file name
2287 # - g the rewritten file name
2288 # - already_present nonempty if the file already exists, empty otherwise
2289 func_add_or_update ()
2291 func_dest_tmpfilename "$g"
2292 func_lookup_file "$f"
2293 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2294 if test -n "$sed_transform_lib_file"; then
2297 sed -e "$sed_transform_lib_file" \
2298 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2302 if test -f "$destdir/$g"; then
2303 # The file already exists.
2304 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2305 : # The file has not changed.
2309 if test -n "$already_present"; then
2310 echo "Updating file $g (backup in ${g}~)"
2312 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
2314 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2315 if { test -n "$symbolic" \
2316 || { test -n "$lsymbolic" \
2317 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2318 && test -z "$lookedup_tmp" \
2319 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2320 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2322 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2325 if test -n "$already_present"; then
2326 echo "Update file $g (backup in ${g}~)"
2328 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
2334 # Don't protest if the file should be there but isn't: it happens
2335 # frequently that developers don't put autogenerated files into CVS.
2337 echo "Copying file $g"
2338 if { test -n "$symbolic" \
2339 || { test -n "$lsymbolic" \
2340 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2341 && test -z "$lookedup_tmp" \
2342 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2343 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2345 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2350 func_append added_files "$g$nl"
2354 # Then the files that are in new-files, but not in old-files:
2355 sed_take_last_column='s,^.*'"$delimiter"',,'
2357 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2358 | sed -e "$sed_take_last_column" \
2359 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2360 { # Rearrange file descriptors. Needed because "while ... done < ..."
2361 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2362 exec 5<&0 < "$tmp"/added-files
2368 # Then the files that are in new-files and in old-files:
2369 already_present=true
2370 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2371 | sed -e "$sed_take_last_column" \
2372 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2373 { # Rearrange file descriptors. Needed because "while ... done < ..."
2374 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2375 exec 5<&0 < "$tmp"/kept-files
2382 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2383 actioncmd="gnulib-tool --import"
2384 func_append actioncmd " --dir=$destdir"
2385 if test -n "$local_gnulib_dir"; then
2386 func_append actioncmd " --local-dir=$local_gnulib_dir"
2388 func_append actioncmd " --lib=$libname"
2389 func_append actioncmd " --source-base=$sourcebase"
2390 func_append actioncmd " --m4-base=$m4base"
2391 if test -n "$pobase"; then
2392 func_append actioncmd " --po-base=$pobase"
2394 func_append actioncmd " --doc-base=$docbase"
2395 func_append actioncmd " --aux-dir=$auxdir"
2396 if test -n "$inctests"; then
2397 func_append actioncmd " --with-tests"
2399 for module in $avoidlist; do
2400 func_append actioncmd " --avoid=$module"
2402 if test -n "$lgpl"; then
2403 func_append actioncmd " --lgpl"
2405 if test -n "$makefile_name"; then
2406 func_append actioncmd " --makefile-name=$makefile_name"
2408 if test "$libtool" = true; then
2409 func_append actioncmd " --libtool"
2411 func_append actioncmd " --no-libtool"
2413 func_append actioncmd " --macro-prefix=$macro_prefix"
2414 if test -n "$po_domain"; then
2415 func_append actioncmd " --po-domain=$po_domain"
2417 func_append actioncmd " `echo $specified_modules`"
2419 # Default the makefile name to Makefile.am.
2420 if test -n "$makefile_name"; then
2421 makefile_am=$makefile_name
2423 makefile_am=Makefile.am
2426 # Create normal Makefile.ams.
2429 # Create library makefile.
2430 func_dest_tmpfilename $sourcebase/$makefile_am
2431 func_emit_lib_Makefile_am > "$tmpfile"
2432 if test -f "$destdir"/$sourcebase/$makefile_am; then
2433 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
2437 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2438 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
2439 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2441 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2447 echo "Creating $sourcebase/$makefile_am"
2448 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2450 echo "Create $sourcebase/$makefile_am"
2453 func_append added_files "$sourcebase/$makefile_am$nl"
2456 # Create po/ directory.
2457 if test -n "$pobase"; then
2458 # Create po makefile and auxiliary files.
2459 for file in Makefile.in.in remove-potcdate.sin; do
2460 func_dest_tmpfilename $pobase/$file
2461 func_lookup_file build-aux/po/$file
2462 cat "$lookedup_file" > "$tmpfile"
2463 if test -f "$destdir"/$pobase/$file; then
2464 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
2468 echo "Updating $pobase/$file (backup in $pobase/$file~)"
2469 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
2470 mv -f "$tmpfile" "$destdir"/$pobase/$file
2472 echo "Update $pobase/$file (backup in $pobase/$file~)"
2478 echo "Creating $pobase/$file"
2479 mv -f "$tmpfile" "$destdir"/$pobase/$file
2481 echo "Create $pobase/$file"
2484 func_append added_files "$pobase/$file$nl"
2487 # Create po makefile parametrization, part 1.
2488 func_dest_tmpfilename $pobase/Makevars
2489 func_emit_po_Makevars > "$tmpfile"
2490 if test -f "$destdir"/$pobase/Makevars; then
2491 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
2495 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
2496 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
2497 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2499 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
2505 echo "Creating $pobase/Makevars"
2506 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2508 echo "Create $pobase/Makevars"
2511 func_append added_files "$pobase/Makevars$nl"
2513 # Create po makefile parametrization, part 2.
2514 func_dest_tmpfilename $pobase/POTFILES.in
2515 func_emit_po_POTFILES_in > "$tmpfile"
2516 if test -f "$destdir"/$pobase/POTFILES.in; then
2517 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
2521 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2522 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
2523 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2525 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2531 echo "Creating $pobase/POTFILES.in"
2532 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2534 echo "Create $pobase/POTFILES.in"
2537 func_append added_files "$pobase/POTFILES.in$nl"
2540 TP_URL="http://translationproject.org/latest/"
2541 TP_RSYNC_URI="translationproject.org::tp/latest/"
2543 echo "Fetching gnulib PO files from $TP_URL"
2544 (cd "$destdir"/$pobase \
2545 && { # Prefer rsync over wget if it is available, since it consumes
2546 # less network bandwidth, due to compression.
2547 if type rsync 2>/dev/null | grep / > /dev/null; then
2548 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
2550 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
2555 echo "Fetch gnulib PO files from $TP_URL"
2557 # Create po/LINGUAS.
2559 func_dest_tmpfilename $pobase/LINGUAS
2560 (cd "$destdir"/$pobase \
2561 && { echo '# Set of available languages.'
2562 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
2565 if test -f "$destdir"/$pobase/LINGUAS; then
2566 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
2569 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2570 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
2571 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2574 echo "Creating $pobase/LINGUAS"
2575 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2576 func_append added_files "$pobase/LINGUAS$nl"
2579 if test -f "$destdir"/$pobase/LINGUAS; then
2580 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2582 echo "Create $pobase/LINGUAS"
2587 # Create m4/gnulib-cache.m4.
2588 func_dest_tmpfilename $m4base/gnulib-cache.m4
2590 func_emit_copyright_notice
2592 echo "# This file represents the specification of how gnulib-tool is used."
2593 echo "# It acts as a cache: It is written and read by gnulib-tool."
2594 echo "# In projects using CVS, this file is meant to be stored in CVS,"
2595 echo "# like the configure.ac and various Makefile.am files."
2598 echo "# Specification in the form of a command-line invocation:"
2601 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
2602 # Store the local_gnulib_dir relative to destdir.
2603 case "$local_gnulib_dir" in
2605 relative_local_gnulib_dir="$local_gnulib_dir" ;;
2608 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
2610 # destdir, local_gnulib_dir are both relative.
2611 func_relativize "$destdir" "$local_gnulib_dir"
2612 relative_local_gnulib_dir="$reldir" ;;
2615 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
2616 echo "gl_MODULES(["`echo $specified_modules`"])"
2617 echo "gl_AVOID([$avoidlist])"
2618 echo "gl_SOURCE_BASE([$sourcebase])"
2619 echo "gl_M4_BASE([$m4base])"
2620 echo "gl_PO_BASE([$pobase])"
2621 echo "gl_DOC_BASE([$docbase])"
2622 echo "gl_TESTS_BASE([$testsbase])"
2623 test -z "$inctests" || echo "gl_WITH_TESTS"
2624 echo "gl_LIB([$libname])"
2625 test -z "$lgpl" || echo "gl_LGPL"
2626 echo "gl_MAKEFILE_NAME([$makefile_name])"
2627 if test "$libtool" = true; then
2630 echo "gl_MACRO_PREFIX([$macro_prefix])"
2631 echo "gl_PO_DOMAIN([$po_domain])"
2633 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2634 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2638 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2639 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2640 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2642 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2646 echo "# gnulib-cache.m4 ends here"
2653 echo "Creating $m4base/gnulib-cache.m4"
2654 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2656 echo "Create $m4base/gnulib-cache.m4"
2662 # Create m4/gnulib-comp.m4.
2663 func_dest_tmpfilename $m4base/gnulib-comp.m4
2665 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2666 func_emit_copyright_notice
2668 echo "# This file represents the compiled summary of the specification in"
2669 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2670 echo "# to be invoked from configure.ac."
2671 echo "# In projects using CVS, this file can be treated like other built files."
2674 echo "# This macro should be invoked from $configure_ac, in the section"
2675 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2676 echo "# any checks for libraries, header files, types and library functions."
2677 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2679 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2680 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2681 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2682 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2683 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2684 if test -n "$uses_subdirs"; then
2685 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2687 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2688 echo " AC_REQUIRE([AC_GNU_SOURCE])"
2690 for module in $modules; do
2692 if test -n "$module"; then
2693 func_get_autoconf_early_snippet "$module"
2696 | sed -e '/^$/d;' -e 's/^/ /'
2699 echo "# This macro should be invoked from $configure_ac, in the section"
2700 echo "# \"Check for header files, types and library functions\"."
2701 echo "AC_DEFUN([${macro_prefix}_INIT],"
2703 func_emit_initmacro_start
2704 if test "$libtool" = true; then
2705 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2706 echo " gl_cond_libtool=true"
2708 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2709 echo " gl_cond_libtool=false"
2711 echo " gl_ltlibdeps="
2713 echo " gl_source_base='$sourcebase'"
2714 if test "$auxdir" != "build-aux"; then
2715 sed_replace_build_aux='
2717 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2718 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2722 sed_replace_build_aux=
2724 for module in $modules; do
2726 if test -n "$module"; then
2727 func_get_autoconf_snippet "$module" \
2728 | sed -e '/^$/d;' -e 's/^/ /' \
2729 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
2730 -e "$sed_replace_build_aux"
2731 if test "$module" = 'alloca' && test "$libtool" = true; then
2732 echo 'changequote(,)dnl'
2733 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
2734 echo 'changequote([, ])dnl'
2735 echo 'AC_SUBST([LTALLOCA])'
2739 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2740 # created using libtool, because libtool already handles the dependencies.
2741 if test "$libtool" != true; then
2742 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
2743 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2744 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2745 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2746 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2748 func_emit_initmacro_end
2750 func_emit_initmacro_done
2752 echo "# This macro records the list of files which have been installed by"
2753 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
2754 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
2755 echo "$files" | sed -e 's,^, ,'
2758 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2759 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
2763 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2764 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
2765 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2767 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2771 echo "# gnulib-comp.m4 ends here"
2778 echo "Creating $m4base/gnulib-comp.m4"
2779 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2781 echo "Create $m4base/gnulib-comp.m4"
2787 if test -n "$inctests"; then
2788 # Create tests makefile.
2789 func_dest_tmpfilename $testsbase/$makefile_am
2790 func_emit_tests_Makefile_am > "$tmpfile"
2791 if test -f "$destdir"/$testsbase/$makefile_am; then
2792 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
2796 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2797 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
2798 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2800 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2806 echo "Creating $testsbase/$makefile_am"
2807 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2809 echo "Create $testsbase/$makefile_am"
2812 func_append added_files "$testsbase/$makefile_am$nl"
2816 # Update the .cvsignore and .gitignore files.
2817 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
2818 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
2819 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
2820 { # Rearrange file descriptors. Needed because "while ... done < ..."
2821 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2822 exec 5<&0 < "$tmp"/fileset-changes
2823 func_update_ignorelist ()
2826 if test -f "$destdir/$dir$ignore"; then
2827 if test -n "$dir_added" || test -n "$dir_removed"; then
2828 LC_ALL=C sort "$destdir/$dir$ignore" > "$tmp"/ignore
2829 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
2830 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-added
2831 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
2832 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-removed
2833 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
2835 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2836 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
2837 sed -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed > "$tmp"/sed-ignore-removed
2838 cat "$destdir/$dir$ignore"~ "$tmp"/ignore-added \
2839 | sed -f "$tmp"/sed-ignore-removed \
2840 > "$destdir/$dir$ignore"
2842 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2847 if test -n "$dir_added"; then
2849 echo "Creating $destdir/$dir$ignore"
2851 if test "$ignore" = .cvsignore; then
2853 # Automake generates Makefile rules that create .dirstamp files.
2856 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u
2857 } > "$destdir/$dir$ignore"
2859 echo "Create $destdir/$dir$ignore"
2869 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
2870 func_update_ignorelist .cvsignore
2872 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
2873 func_update_ignorelist .gitignore
2880 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
2881 next_dir=`echo "$line" | sed -e 's,|.*,,'`
2882 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
2883 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
2884 if test "$next_dir" != "$last_dir"; then
2885 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2886 last_dir="$next_dir"
2891 A) func_append last_dir_added "$file$nl";;
2892 R) func_append last_dir_removed "$file$nl";;
2895 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2901 echo "You may need to add #include directives for the following .h files."
2902 # Intersect $specified_modules and $modules
2903 # (since $specified_modules is not necessarily of subset of $modules - some
2904 # may have been skipped through --avoid, and since the elements of $modules
2905 # but not in $specified_modules can go away without explicit notice - through
2906 # changes in the module dependencies).
2907 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
2908 echo "$modules" > "$tmp"/modules2 # also a sorted list, one module per line
2909 # First the #include <...> directives without #ifs, sorted for convenience,
2910 # then the #include "..." directives without #ifs, sorted for convenience,
2911 # then the #include directives that are surrounded by #ifs. Not sorted.
2912 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
2913 include_directive=`func_get_include_directive "$module"`
2914 case "$nl$include_directive" in
2916 echo "$include_directive" 1>&5
2919 echo "$include_directive" | grep -v 'include "' 1>&6
2920 echo "$include_directive" | grep 'include "' 1>&7
2923 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
2925 LC_ALL=C sort -u "$tmp"/include-angles
2926 LC_ALL=C sort -u "$tmp"/include-quotes
2927 cat "$tmp"/include-if
2928 ) | sed -e '/^$/d' -e 's/^/ /'
2929 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
2931 for module in $modules; do
2932 func_get_link_directive "$module"
2934 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
2935 if test `wc -l < "$tmp"/link` != 0; then
2937 echo "You may need to use the following Makefile variables when linking."
2938 echo "Use them in <program>_LDADD when linking a program, or"
2939 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
2945 echo "Don't forget to"
2946 if test "$makefile_am" = Makefile.am; then
2947 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2949 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
2951 if test -n "$pobase"; then
2952 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
2954 if test -n "$inctests"; then
2955 if test "$makefile_am" = Makefile.am; then
2956 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2958 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
2961 if test "$makefile_am" = Makefile.am; then
2962 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
2963 sourcebase_base=`basename "$sourcebase"`
2964 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
2966 if test -n "$pobase"; then
2967 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
2968 pobase_base=`basename "$pobase"`
2969 echo " - mention \"${pobase_base}\" in SUBDIRS in ${pobase_dir}Makefile.am,"
2971 if test -n "$inctests"; then
2972 if test "$makefile_am" = Makefile.am; then
2973 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
2974 testsbase_base=`basename "$testsbase"`
2975 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
2978 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
2979 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
2980 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
2983 # func_create_testdir testdir modules
2985 # - local_gnulib_dir from --local-dir
2986 # - auxdir directory relative to destdir where to place build aux files
2987 func_create_testdir ()
2991 if test -z "$modules"; then
2992 # All modules together.
2993 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2994 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2995 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
2996 modules=`func_all_modules`
2997 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
2999 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
3001 # Check that the license of every module is consistent with the license of
3003 saved_modules="$modules"
3004 saved_inctests="$inctests"
3005 # When computing transitive closures, don't consider $module to depend on
3006 # $module-tests. Need this becauses tests are implicitly GPL and may depend
3007 # on GPL modules - therefore we don't want a warning in this case.
3009 for requested_module in $saved_modules; do
3010 requested_license=`func_get_license "$requested_module"`
3011 if test "$requested_license" != GPL; then
3012 # Here we use func_modules_transitive_closure, not just
3013 # func_get_dependencies, so that we also detect weird situations like
3014 # an LGPL module which depends on a GPLed build tool module which depends
3016 modules="$requested_module"
3017 func_modules_transitive_closure
3018 for module in $modules; do
3019 license=`func_get_license "$module"`
3021 'GPLed build tool') ;;
3022 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3024 case "$requested_license" in
3027 GPLv2+ | LGPLv2+) ;;
3028 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3034 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3040 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3049 modules="$saved_modules"
3050 inctests="$saved_inctests"
3052 # Subdirectory names.
3061 # Determine final module list.
3062 func_modules_transitive_closure
3063 if test $verbose -ge 0; then
3064 echo "Module list with included dependencies:"
3065 echo "$modules" | sed -e 's/^/ /'
3068 # Add the dummy module if needed.
3069 func_modules_add_dummy
3071 # Determine final file list.
3072 func_modules_to_filelist
3073 if test $verbose -ge 0; then
3075 echo "$files" | sed -e 's/^/ /'
3078 sed_rewrite_files="\
3079 s,^build-aux/,$auxdir/,
3081 s,^lib/,$sourcebase/,
3083 s,^tests/,$testsbase/,"
3085 # Create directories.
3086 for f in $files; do echo $f; done \
3087 | sed -e "$sed_rewrite_files" \
3088 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3089 | LC_ALL=C sort -u \
3091 { # Rearrange file descriptors. Needed because "while ... done < ..."
3092 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3093 exec 5<&0 < "$tmp"/dirs
3095 mkdir -p "$testdir/$d"
3100 # Copy files or make symbolic links.
3102 for f in $files; do echo $f; done \
3103 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3106 { # Rearrange file descriptors. Needed because "while ... done < ..."
3107 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3108 exec 5<&0 < "$tmp"/files
3110 func_lookup_file "$f"
3111 if test -n "$lookedup_tmp"; then
3112 cp -p "$lookedup_file" "$testdir/$g"
3114 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3115 if { test -n "$symbolic" \
3116 || { test -n "$lsymbolic" \
3117 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3118 func_ln "$lookedup_file" "$testdir/$g"
3120 cp -p "$lookedup_file" "$testdir/$g"
3127 # Create Makefile.ams that are for testing.
3130 # Create $sourcebase/Makefile.am.
3131 mkdir -p "$testdir/$sourcebase"
3132 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3134 # Create $m4base/Makefile.am.
3135 mkdir -p "$testdir/$m4base"
3136 (echo "## Process this file with automake to produce Makefile.in."
3142 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
3145 ) > "$testdir/$m4base/Makefile.am"
3147 subdirs="$sourcebase $m4base"
3148 subdirs_with_configure_ac=""
3150 if false && test -f "$testdir"/$m4base/gettext.m4; then
3151 # Avoid stupid error message from automake:
3152 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
3153 mkdir -p "$testdir/po"
3154 (echo "## Process this file with automake to produce Makefile.in."
3155 ) > "$testdir/po/Makefile.am"
3156 func_append subdirs " po"
3159 if test -n "$inctests"; then
3160 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
3161 # Create $testsbase/Makefile.am.
3162 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
3163 # Create $testsbase/configure.ac.
3164 (echo "# Process this file with autoconf to produce a configure script."
3165 echo "AC_INIT([dummy], [0])"
3166 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
3167 echo "AM_INIT_AUTOMAKE"
3169 echo "AM_CONFIG_HEADER([config.h])"
3172 echo "AC_PROG_INSTALL"
3173 echo "AC_PROG_MAKE_SET"
3174 echo "AC_PROG_RANLIB"
3176 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3177 echo "AC_GNU_SOURCE"
3180 for module in $modules; do
3182 if test -n "$module"; then
3183 func_get_autoconf_early_snippet "$module"
3186 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3187 if test "$libtool" = true; then
3188 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3189 echo "gl_cond_libtool=true"
3191 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3192 echo "gl_cond_libtool=false"
3194 echo "gl_ltlibdeps="
3196 # Wrap the set of autoconf snippets into an autoconf macro that is then
3197 # invoked. This is needed because autoconf does not support AC_REQUIRE
3199 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3200 # but we want the AC_REQUIRE to have its normal meaning (provide one
3201 # expansion of the required macro before the current point, and only one
3203 echo "AC_DEFUN([gl_INIT], ["
3204 func_emit_initmacro_start
3205 sed_replace_build_aux='
3207 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3208 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
3211 # We don't have explicit ordering constraints between the various
3212 # autoconf snippets. It's cleanest to put those of the library before
3213 # those of the tests.
3214 echo "gl_source_base='../$sourcebase'"
3215 for module in $modules; do
3216 func_verify_nontests_module
3217 if test -n "$module"; then
3218 func_get_autoconf_snippet "$module" \
3219 | sed -e "$sed_replace_build_aux"
3222 echo "gl_source_base='.'"
3223 for module in $modules; do
3224 func_verify_tests_module
3225 if test -n "$module"; then
3226 func_get_autoconf_snippet "$module" \
3227 | sed -e "$sed_replace_build_aux"
3230 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3231 # created using libtool, because libtool already handles the dependencies.
3232 if test "$libtool" != true; then
3233 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3234 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3235 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3236 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3237 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3239 func_emit_initmacro_end
3241 func_emit_initmacro_done
3245 # Usually $testsbase/config.h will be a superset of config.h. Verify this
3246 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
3247 echo "AH_TOP([#include \"../config.h\"])"
3249 echo "AC_OUTPUT([Makefile])"
3250 ) > "$testdir/$testsbase/configure.ac"
3251 func_append subdirs " $testsbase"
3252 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
3255 # Create Makefile.am.
3256 (echo "## Process this file with automake to produce Makefile.in."
3258 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3260 echo "SUBDIRS = $subdirs"
3262 echo "ACLOCAL_AMFLAGS = -I $m4base"
3263 ) > "$testdir/Makefile.am"
3265 # Create configure.ac.
3266 (echo "# Process this file with autoconf to produce a configure script."
3267 echo "AC_INIT([dummy], [0])"
3268 if test "$auxdir" != "."; then
3269 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3271 echo "AM_INIT_AUTOMAKE"
3273 echo "AM_CONFIG_HEADER([config.h])"
3276 echo "AC_PROG_INSTALL"
3277 echo "AC_PROG_MAKE_SET"
3279 echo "# For autobuild."
3280 echo "AC_CANONICAL_BUILD"
3281 echo "AC_CANONICAL_HOST"
3283 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3284 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3285 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3286 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3288 echo "AC_PROG_RANLIB"
3290 if test -n "$uses_subdirs"; then
3291 echo "AM_PROG_CC_C_O"
3294 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3295 echo "AC_GNU_SOURCE"
3298 for module in $modules; do
3299 func_verify_nontests_module
3300 if test -n "$module"; then
3301 func_get_autoconf_early_snippet "$module"
3304 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3305 if test "$libtool" = true; then
3306 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3307 echo "gl_cond_libtool=true"
3309 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3310 echo "gl_cond_libtool=false"
3312 echo "gl_ltlibdeps="
3314 echo "gl_source_base='$sourcebase'"
3315 # Wrap the set of autoconf snippets into an autoconf macro that is then
3316 # invoked. This is needed because autoconf does not support AC_REQUIRE
3318 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3319 # but we want the AC_REQUIRE to have its normal meaning (provide one
3320 # expansion of the required macro before the current point, and only one
3322 echo "AC_DEFUN([gl_INIT], ["
3323 func_emit_initmacro_start
3324 if test "$auxdir" != "build-aux"; then
3325 sed_replace_build_aux='
3327 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3328 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3332 sed_replace_build_aux=
3334 for module in $modules; do
3335 func_verify_nontests_module
3336 if test -n "$module"; then
3337 func_get_autoconf_snippet "$module" \
3338 | sed -e "$sed_replace_build_aux"
3341 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3342 # created using libtool, because libtool already handles the dependencies.
3343 if test "$libtool" != true; then
3344 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3345 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3346 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3347 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3348 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3350 func_emit_initmacro_end
3352 func_emit_initmacro_done
3356 if test -n "$subdirs_with_configure_ac"; then
3357 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
3359 makefiles="Makefile"
3360 for d in $subdirs; do
3361 # For subdirs that have a configure.ac by their own, it's the subdir's
3362 # configure.ac which creates the subdir's Makefile.am, not this one.
3363 case " $subdirs_with_configure_ac " in
3365 *) func_append makefiles " $d/Makefile" ;;
3368 echo "AC_OUTPUT([$makefiles])"
3369 ) > "$testdir/configure.ac"
3371 # Create autogenerated files.
3373 # Do not use "${AUTORECONF} --force --install", because it may invoke
3374 # autopoint, which brings in older versions of some of our .m4 files.
3375 if test -f $m4base/gettext.m4; then
3376 func_execute_command ${AUTOPOINT} --force || func_exit 1
3377 for f in $m4base/*.m4~; do
3378 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3381 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
3382 if ! test -d build-aux; then
3383 func_execute_command mkdir build-aux || func_exit 1
3385 func_execute_command ${AUTOCONF} || func_exit 1
3386 func_execute_command ${AUTOHEADER} || func_exit 1
3387 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3389 if test -n "$inctests"; then
3390 # Create autogenerated files.
3391 (cd "$testdir/$testsbase" || func_exit 1
3392 # Do not use "${AUTORECONF} --force --install", because it may invoke
3393 # autopoint, which brings in older versions of some of our .m4 files.
3394 if test -f ../$m4base/gettext.m4; then
3395 func_execute_command ${AUTOPOINT} --force || func_exit 1
3396 for f in ../$m4base/*.m4~; do
3397 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3400 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
3401 if ! test -d ../build-aux; then
3402 func_execute_command mkdir ../build-aux
3404 func_execute_command ${AUTOCONF} || func_exit 1
3405 func_execute_command ${AUTOHEADER} || func_exit 1
3406 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3409 # Need to run configure and make once, to create built files that are to be
3410 # distributed (such as getdate.c).
3411 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
3412 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3413 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
3414 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
3415 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
3416 # such $(FOO_H) because they don't refer to distributed files.
3417 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
3418 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3419 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
3420 | sed -e "$sed_remove_make_variables"`
3421 distributed_built_sources=`for file in $built_sources; do
3422 case "$cleaned_files" in
3427 if test -n "$distributed_built_sources"; then
3429 ./configure || func_exit 1
3431 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
3432 make built_sources || func_exit 1
3434 make distclean || func_exit 1
3439 # func_create_megatestdir megatestdir allmodules
3441 # - local_gnulib_dir from --local-dir
3442 # - auxdir directory relative to destdir where to place build aux files
3443 func_create_megatestdir ()
3447 if test -z "$allmodules"; then
3448 allmodules=`func_all_modules`
3452 # First, all modules one by one.
3453 for onemodule in $allmodules; do
3454 func_create_testdir "$megatestdir/$onemodule" $onemodule
3455 func_append megasubdirs "$onemodule "
3457 # Then, all modules all together.
3458 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3459 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3460 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
3461 func_create_testdir "$megatestdir/ALL" "$allmodules"
3462 func_append megasubdirs "ALL"
3465 cvsdate=`sh "$gnulib_dir/build-aux/mdate-sh" "$gnulib_dir/CVS/Entries" \
3466 | sed -e 's,January,01,' -e 's,Jan,01,' \
3467 -e 's,February,02,' -e 's,Feb,02,' \
3468 -e 's,March,03,' -e 's,Mar,03,' \
3469 -e 's,April,04,' -e 's,Apr,04,' \
3471 -e 's,June,06,' -e 's,Jun,06,' \
3472 -e 's,July,07,' -e 's,Jul,07,' \
3473 -e 's,August,08,' -e 's,Aug,08,' \
3474 -e 's,September,09,' -e 's,Sep,09,' \
3475 -e 's,October,10,' -e 's,Oct,10,' \
3476 -e 's,November,11,' -e 's,Nov,11,' \
3477 -e 's,December,12,' -e 's,Dec,12,' \
3478 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
3479 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
3481 echo "CVSDATE=$cvsdate"
3482 echo "test -d logs || mkdir logs"
3483 echo "for module in $megasubdirs; do"
3484 echo " echo \"Working on module \$module...\""
3485 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
3486 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
3489 echo " : autobuild project... \$module"
3490 echo " : autobuild revision... cvs-\$CVSDATE-000000"
3491 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
3492 echo " : autobuild hostname... \`hostname\`"
3493 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
3495 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
3497 ) > "$megatestdir/do-autobuild"
3498 chmod a+x "$megatestdir/do-autobuild"
3500 # Create Makefile.am.
3501 (echo "## Process this file with automake to produce Makefile.in."
3503 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3505 echo "SUBDIRS = $megasubdirs"
3507 echo "EXTRA_DIST = do-autobuild"
3508 ) > "$megatestdir/Makefile.am"
3510 # Create configure.ac.
3511 (echo "# Process this file with autoconf to produce a configure script."
3512 echo "AC_INIT([dummy], [0])"
3513 if test "$auxdir" != "."; then
3514 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3516 echo "AM_INIT_AUTOMAKE"
3518 echo "AC_PROG_MAKE_SET"
3520 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
3521 echo "AC_OUTPUT([Makefile])"
3522 ) > "$megatestdir/configure.ac"
3524 # Create autogenerated files.
3526 # Do not use "${AUTORECONF} --install", because autoreconf operates
3527 # recursively, but the subdirectories are already finished, therefore
3528 # calling autoreconf here would only waste lots of CPU time.
3529 func_execute_command ${ACLOCAL} || func_exit 1
3530 func_execute_command mkdir build-aux
3531 func_execute_command ${AUTOCONF} || func_exit 1
3532 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3538 func_fatal_error "no mode specified" ;;
3547 if test -z "$destdir"; then
3550 test -d "$destdir" \
3551 || func_fatal_error "destination directory does not exist: $destdir"
3553 # Prefer configure.ac to configure.in.
3554 if test -f "$destdir"/configure.ac; then
3555 configure_ac="$destdir/configure.ac"
3557 if test -f "$destdir"/configure.in; then
3558 configure_ac="$destdir/configure.in"
3560 func_fatal_error "cannot find $destdir/configure.ac"
3564 # Analyze configure.ac.
3566 guessed_libtool=false
3571 /AC_CONFIG_AUX_DIR/ {
3572 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
3574 /A[CM]_PROG_LIBTOOL/ {
3575 s,^.*$,guessed_libtool=true,p
3577 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
3579 if test -z "$auxdir"; then
3580 auxdir="$guessed_auxdir"
3583 # Determine where to apply func_import.
3584 if test -n "$m4base"; then
3585 # Apply func_import to a particular gnulib directory.
3586 # Any number of additional modules can be given.
3587 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
3588 # First use of gnulib in the given m4base.
3589 test -n "$supplied_libname" || supplied_libname=true
3590 test -n "$sourcebase" || sourcebase="lib"
3591 test -n "$docbase" || docbase="doc"
3592 test -n "$testsbase" || testsbase="tests"
3593 test -n "$macro_prefix" || macro_prefix="gl"
3597 # Apply func_import to all gnulib directories.
3598 # To get this list of directories, look at Makefile.am. (Not at
3599 # configure, because it may be omitted from CVS. Also, don't run
3600 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
3603 if test -f "$destdir"/Makefile.am; then
3604 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
3606 for arg in $aclocal_amflags; do
3607 if test -n "$m4dir_is_next"; then
3608 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
3612 if test -f "$destdir/$arg"/gnulib-cache.m4; then
3613 func_append m4dirs " $arg"
3614 m4dirs_count=`expr $m4dirs_count + 1`
3620 if test "X$arg" = "X-I"; then
3628 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
3629 if test -f "$destdir"/aclocal.m4; then
3630 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
3631 sedexpr2='s,^[^/]*$,.,'
3632 sedexpr3='s,/[^/]*$,,'
3633 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
3634 m4dirs_count=`echo "$m4dirs" | wc -l`
3637 if test $m4dirs_count = 0; then
3638 # First use of gnulib in a package.
3639 # Any number of additional modules can be given.
3640 test -n "$supplied_libname" || supplied_libname=true
3641 test -n "$sourcebase" || sourcebase="lib"
3643 test -n "$docbase" || docbase="doc"
3644 test -n "$testsbase" || testsbase="tests"
3645 test -n "$macro_prefix" || macro_prefix="gl"
3648 if test $m4dirs_count = 1; then
3649 # There's only one use of gnulib here. Assume the user means it.
3650 # Any number of additional modules can be given.
3651 for m4base in $m4dirs; do
3655 # Ambiguous - guess what the user meant.
3656 if test $# = 0; then
3657 # No further arguments. Guess the user wants to update all of them.
3658 for m4base in $m4dirs; do
3659 # Perform func_import in a subshell, so that variable values
3661 # local_gnulib_dir, avoidlist, sourcebase, m4base, pobase,
3662 # docbase, testsbase, inctests, libname, lgpl, makefile_name,
3663 # libtool, macro_prefix, po_domain
3664 # don't propagate from one directory to another.
3665 (func_import) || func_exit 1
3669 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
3677 if test -z "$destdir"; then
3678 func_fatal_error "please specify --dir option"
3681 test -d "$destdir" \
3682 || func_fatal_error "could not create destination directory"
3683 test -n "$auxdir" || auxdir="build-aux"
3684 func_create_testdir "$destdir" "$*"
3687 create-megatestdir )
3688 if test -z "$destdir"; then
3689 func_fatal_error "please specify --dir option"
3691 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3692 test -n "$auxdir" || auxdir="build-aux"
3693 func_create_megatestdir "$destdir" "$*"
3697 test -n "$destdir" || destdir=testdir$$
3698 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3699 test -n "$auxdir" || auxdir="build-aux"
3700 func_create_testdir "$destdir" "$*"
3704 ../configure || func_exit 1
3706 make check || func_exit 1
3707 make distclean || func_exit 1
3708 remaining=`find . -type f -print`
3709 if test -n "$remaining"; then
3710 echo "Remaining files:" $remaining 1>&2
3711 echo "gnulib-tool: *** Stop." 1>&2
3720 test -n "$destdir" || destdir=testdir$$
3721 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3722 test -n "$auxdir" || auxdir="build-aux"
3723 func_create_megatestdir "$destdir" "$*"
3731 remaining=`find . -type f -print`
3732 if test -n "$remaining"; then
3733 echo "Remaining files:" $remaining 1>&2
3734 echo "gnulib-tool: *** Stop." 1>&2
3742 extract-description )
3746 if test -n "$module"; then
3747 func_get_description "$module"
3756 if test -n "$module"; then
3757 func_get_filelist "$module"
3762 extract-dependencies )
3766 if test -n "$module"; then
3767 func_get_dependencies "$module"
3772 extract-autoconf-snippet )
3776 if test -n "$module"; then
3777 func_get_autoconf_snippet "$module"
3782 extract-automake-snippet )
3786 if test -n "$module"; then
3787 func_get_automake_snippet "$module"
3792 extract-include-directive )
3796 if test -n "$module"; then
3797 func_get_include_directive "$module"
3802 extract-link-directive )
3806 if test -n "$module"; then
3807 func_get_link_directive "$module"
3816 if test -n "$module"; then
3817 func_get_license "$module"
3822 extract-maintainer )
3826 if test -n "$module"; then
3827 func_get_maintainer "$module"
3832 extract-tests-module )
3836 if test -n "$module"; then
3837 func_get_tests_module "$module"
3843 func_fatal_error "unknown operation mode --$mode" ;;
3847 # Undo the effect of the previous 'trap' command. Some shellology:
3848 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
3849 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
3850 # exit); for the others we need to call 'exit' explicitly. The value of $? is
3851 # 128 + signal number and is set before the trap-registered command is run.
3853 trap 'func_exit $?' 1 2 3 13 15
3858 # indent-tabs-mode: nil
3859 # whitespace-check-buffer-indent: nil