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 12:17:36 $'
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-notice module
93 gnulib-tool --extract-filelist module
94 gnulib-tool --extract-dependencies module
95 gnulib-tool --extract-autoconf-snippet module
96 gnulib-tool --extract-automake-snippet module
97 gnulib-tool --extract-include-directive module
98 gnulib-tool --extract-link-directive module
99 gnulib-tool --extract-license module
100 gnulib-tool --extract-maintainer module
101 gnulib-tool --extract-tests-module module
104 --list print the available module names
105 --import import the given modules into the current package;
106 if no modules are specified, update the current
107 package from the current gnulib
108 --update update the current package, restore files omitted
110 --create-testdir create a scratch package with the given modules
111 --create-megatestdir create a mega scratch package with the given modules
112 one by one and all together
113 --test test the combination of the given modules
114 (recommended to use CC=\"gcc -Wall\" here)
115 --megatest test the given modules one by one and all together
116 (recommended to use CC=\"gcc -Wall\" here)
117 --extract-description extract the description
118 --extract-notice extract the notice or banner
119 --extract-filelist extract the list of files
120 --extract-dependencies extract the dependencies
121 --extract-autoconf-snippet extract the snippet for configure.ac
122 --extract-automake-snippet extract the snippet for library makefile
123 --extract-include-directive extract the #include directive
124 --extract-link-directive extract the linker directive
125 --extract-license report the license terms of the source files
127 --extract-maintainer report the maintainer(s) inside gnulib
128 --extract-tests-module report the unit test module, if it exists
131 --dir=DIRECTORY Specify the target directory.
132 For --import, this specifies where your
133 configure.ac can be found. Defaults to current
135 --local-dir=DIRECTORY Specify a local override directory where to look
136 up files before looking in gnulib's directory.
137 --verbose Increase verbosity. May be repeated.
138 --quiet Decrease verbosity. May be repeated.
140 Options for --import:
141 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
142 --source-base=DIRECTORY
143 Directory relative to --dir where source code is
144 placed (default \"lib\").
145 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
146 placed (default \"m4\").
147 --po-base=DIRECTORY Directory relative to --dir where *.po files are
148 placed (default \"po\").
149 --doc-base=DIRECTORY Directory relative to --dir where doc files are
150 placed (default \"doc\").
151 --tests-base=DIRECTORY
152 Directory relative to --dir where unit tests are
153 placed (default \"tests\").
154 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
155 tools are placed (default \"build-aux\").
156 --with-tests Include unit tests for the included modules.
157 --avoid=MODULE Avoid including the given MODULE. Useful if you
158 have code that provides equivalent functionality.
159 This option can be repeated.
160 --lgpl Abort if modules aren't available under the LGPL.
161 Also modify license template from GPL to LGPL.
162 --makefile-name=NAME Name of makefile in automake syntax in the
163 source-base and tests-base directories
164 (default \"Makefile.am\").
165 --libtool Use libtool rules.
166 --no-libtool Don't use libtool rules.
167 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
168 'gl_INIT'. Default is 'gl'.
169 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
170 the package name. A suffix '-gnulib' is appended.
171 --no-changelog don't update or create ChangeLog files
173 Options for --import and --update:
174 --dry-run For --import, only print what would have been done.
175 -s, --symbolic, --symlink Make symbolic links instead of copying files.
176 --local-symlink Make symbolic links instead of copying files, only
177 for files from the local override directory.
178 -S, --more-symlinks Make symbolic links instead of copying files, and
179 don't replace copyright notices.
181 Report bugs to <bug-gnulib@gnu.org>."
185 # outputs to stdout the --version message.
188 year=`echo "$last_checkin_date" | sed -e 's,/.*$,,'`
190 $progname (GNU $package) $version
191 Copyright (C) $year Free Software Foundation, Inc.
192 This is free software; see the source for copying conditions. There is NO
193 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
194 Written by" "Bruno Haible" "and" "Simon Josefsson"
197 # func_emit_copyright_notice
198 # outputs to stdout a header for a generated file.
199 func_emit_copyright_notice ()
201 echo "# Copyright (C) 2004-2007 Free Software Foundation, Inc."
203 echo "# This file is free software, distributed under the terms of the GNU"
204 echo "# General Public License. As a special exception to the GNU General"
205 echo "# Public License, this file may be distributed as part of a program"
206 echo "# that contains a configuration script generated by Autoconf, under"
207 echo "# the same distribution terms as the rest of that program."
209 echo "# Generated by gnulib-tool."
220 # creates a temporary directory.
222 # - tmp pathname of freshly created temporary directory
225 # Use the environment variable TMPDIR, falling back to /tmp. This allows
226 # users to specify a different temporary directory, for example, if their
227 # /tmp is filled up or too small.
230 # Use the mktemp program if available. If not available, hide the error
232 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
233 test -n "$tmp" && test -d "$tmp"
236 # Use a simple mkdir command. It is guaranteed to fail if the directory
237 # already exists. $RANDOM is bash specific and expands to empty in shells
238 # other than bash, ksh and zsh. Its use does not increase security;
239 # rather, it minimizes the probability of failure in a very cluttered /tmp
241 tmp=$TMPDIR/gl$$-$RANDOM
242 (umask 077 && mkdir "$tmp")
245 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
250 # func_append var value
251 # appends the given value to the shell variable var.
252 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
253 # Use bash's += operator. It reduces complexity of appending repeatedly to
254 # a single variable from O(n^2) to O(n).
262 eval "$1=\"\$$1\$2\""
266 # func_fatal_error message
267 # outputs to stderr a fatal error message, and terminates the program.
270 echo "gnulib-tool: *** $1" 1>&2
271 echo "gnulib-tool: *** Stop." 1>&2
275 # func_readlink SYMLINK
276 # outputs the target of the given symlink.
277 if (type -p readlink) > /dev/null 2>&1; then
280 # Use the readlink program from GNU coreutils.
286 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
287 # would do the wrong thing if the link target contains " -> ".
288 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
292 # func_relativize DIR1 DIR2
293 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
295 # - DIR1 relative pathname, relative to the current directory
296 # - DIR2 relative pathname, relative to the current directory
298 # - reldir relative pathname of DIR2, relative to DIR1
304 sed_first='s,^\([^/]*\)/.*$,\1,'
305 sed_rest='s,^[^/]*/*,,'
306 sed_last='s,^.*/\([^/]*\)$,\1,'
307 sed_butlast='s,/*[^/]*$,,'
308 while test -n "$dir1"; do
309 first=`echo "$dir1" | sed -e "$sed_first"`
310 if test "$first" != "."; then
311 if test "$first" = ".."; then
312 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
313 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
315 first2=`echo "$dir2" | sed -e "$sed_first"`
316 if test "$first2" = "$first"; then
317 dir2=`echo "$dir2" | sed -e "$sed_rest"`
321 dir0="$dir0"/"$first"
324 dir1=`echo "$dir1" | sed -e "$sed_rest"`
329 # func_relconcat DIR1 DIR2
330 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
332 # - DIR1 relative pathname, relative to the current directory
333 # - DIR2 relative pathname, relative to DIR1
335 # - relconcat DIR1/DIR2, relative to the current directory
340 sed_first='s,^\([^/]*\)/.*$,\1,'
341 sed_rest='s,^[^/]*/*,,'
342 sed_last='s,^.*/\([^/]*\)$,\1,'
343 sed_butlast='s,/*[^/]*$,,'
345 first=`echo "$dir2" | sed -e "$sed_first"`
346 if test "$first" = "."; then
347 dir2=`echo "$dir2" | sed -e "$sed_rest"`
348 if test -z "$dir2"; then
353 last=`echo "$dir1" | sed -e "$sed_last"`
354 while test "$last" = "."; do
355 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
356 last=`echo "$dir1" | sed -e "$sed_last"`
358 if test -z "$dir1"; then
362 if test "$first" = ".."; then
363 if test "$last" = ".."; then
364 relconcat="$dir1/$dir2"
367 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
368 dir2=`echo "$dir2" | sed -e "$sed_rest"`
369 if test -z "$dir1"; then
373 if test -z "$dir2"; then
378 relconcat="$dir1/$dir2"
386 # Like ln -s, except that SRC is given relative to the current directory (or
387 # absolute), not given relative to the directory of DEST.
393 *) # SRC is relative.
396 ln -s "`pwd`/$1" "$2" ;;
397 *) # DEST is relative too.
398 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
399 test -n "$ln_destdir" || ln_destdir="."
400 func_relativize "$ln_destdir" "$1"
408 # func_ln_if_changed SRC DEST
409 # Like func_ln, but avoids munging timestamps if the link is correct.
410 func_ln_if_changed ()
412 if test $# -ne 2; then
413 echo "usage: func_ln_if_changed SRC DEST" >&2
415 ln_target=`func_readlink "$2"`
416 if test -h "$2" && test "$1" = "$ln_target"; then
424 # Ensure an 'echo' command that does not interpret backslashes.
426 # echo '\n' | wc -l prints 1 when OK, 2 when KO
427 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
428 # This problem is a weird heritage from SVR4. BSD got it right (except that
429 # BSD echo interprets '-n' as an option, which is also not desirable).
430 # Nowadays the problem occurs in 4 situations:
431 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
432 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
433 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
434 # - in zsh, when sh-emulation is not set,
435 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
436 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
437 # - in Solaris /bin/sh and OSF/1 /bin/sh.
438 # We try the following workarounds:
439 # - for all: respawn using $CONFIG_SHELL if that is set and works.
440 # - for bash >= 2.04: unset the shell option xpg_echo.
441 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
442 # - for bash < 2.0: define echo to a function that uses cat of a here document.
443 # - for zsh: turn sh-emulation on.
444 # - for ksh: alias echo to 'print -r'.
445 # - for ksh: alias echo to a function that uses cat of a here document.
446 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
447 # the ksh workaround.
448 # - otherwise: respawn using /bin/sh and rely on the workarounds.
449 # When respawning, we pass --no-reexec as first argument, so as to avoid
450 # turning this script into a fork bomb in unlucky situations.
452 if echo '\t' | grep t > /dev/null; then
453 have_echo=yes # Lucky!
455 # Try the workarounds.
456 # Respawn using $CONFIG_SHELL if that is set and works.
457 if test -z "$have_echo" \
458 && test "X$1" != "X--no-reexec" \
459 && test -n "$CONFIG_SHELL" \
460 && test -f "$CONFIG_SHELL" \
461 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
462 exec $CONFIG_SHELL "$0" --no-reexec "$@"
465 # For bash >= 2.04: unset the shell option xpg_echo.
466 if test -z "$have_echo" \
467 && test -n "$BASH_VERSION" \
468 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
472 # For bash >= 2.0: define echo to a function that uses the printf built-in.
473 # For bash < 2.0: define echo to a function that uses cat of a here document.
474 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
475 if test -z "$have_echo" \
476 && test -n "$BASH_VERSION"; then \
477 if type printf 2>/dev/null | grep / > /dev/null; then
478 # 'printf' is not a shell built-in.
486 # 'printf' is a shell built-in.
492 if echo '\t' | grep t > /dev/null; then
496 # For zsh: turn sh-emulation on.
497 if test -z "$have_echo" \
498 && test -n "$ZSH_VERSION" \
499 && (emulate sh) >/dev/null 2>&1; then
502 # For ksh: alias echo to 'print -r'.
503 if test -z "$have_echo" \
504 && (type print) >/dev/null 2>&1; then
505 # A 'print' command exists.
506 if type print 2>/dev/null | grep / > /dev/null; then
509 # 'print' is a shell built-in.
510 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
511 # 'print' is the ksh shell built-in.
512 alias echo='print -r'
516 if test -z "$have_echo" \
517 && echo '\t' | grep t > /dev/null; then
520 # For ksh: alias echo to a function that uses cat of a here document.
521 # The ksh manual page says:
522 # "Aliasing is performed when scripts are read, not while they are executed.
523 # Therefore, for an alias to take effect, the alias definition command has
524 # to be executed before the command which references the alias is read."
525 # Because of this, we have to play strange tricks with have_echo, to ensure
526 # that the top-level statement containing the test starts after the 'alias'
528 if test -z "$have_echo"; then
535 alias echo=bsd_echo 2>/dev/null
537 if test -z "$have_echo" \
538 && echo '\t' | grep t > /dev/null; then
541 if test -z "$have_echo"; then
542 unalias echo 2>/dev/null
544 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
545 if test -z "$have_echo" \
546 && test "X$1" != "X--no-reexec" \
547 && test -f /bin/ksh; then
548 exec /bin/ksh "$0" --no-reexec "$@"
551 # Otherwise: respawn using /bin/sh.
552 if test -z "$have_echo" \
553 && test "X$1" != "X--no-reexec" \
554 && test -f /bin/sh; then
555 exec /bin/sh "$0" --no-reexec "$@"
558 if test -z "$have_echo"; then
559 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
561 if echo '\t' | grep t > /dev/null; then
564 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
566 if test "X$1" = "X--no-reexec"; then
570 # Command-line option processing.
571 # Removes the OPTIONS from the arguments. Sets the variables:
572 # - mode list or import or create-testdir or create-megatestdir
573 # - destdir from --dir
574 # - local_gnulib_dir from --local-dir
575 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
576 # - libname, supplied_libname from --lib
577 # - sourcebase from --source-base
578 # - m4base from --m4-base
579 # - pobase from --po-base
580 # - docbase from --doc-base
581 # - testsbase from --tests-base
582 # - auxdir from --aux-dir
583 # - inctests true if --with-tests was given, blank otherwise
584 # - avoidlist list of modules to avoid, from --avoid
585 # - lgpl true if --lgpl was given, blank otherwise
586 # - makefile_name from --makefile-name
587 # - libtool true if --libtool was given, false if --no-libtool was
588 # given, blank otherwise
589 # - macro_prefix from --macro-prefix
590 # - po_domain from --po-domain
591 # - autoconf_minversion minimum supported autoconf version
592 # - do_changelog false if --no-changelog was given, : otherwise
593 # - doit : if actions shall be executed, false if only to be printed
594 # - symbolic true if --symlink or --more-symlinks was given, blank
596 # - lsymbolic true if --local-symlink was given, blank otherwise
597 # - do_copyrights blank if --more-symlinks was given, true otherwise
626 while test $# -gt 0; do
631 --import | --impor | --impo | --imp | --im | --i )
634 --update | --updat | --upda | --upd | --up | --u )
637 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
640 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
641 mode=create-megatestdir
643 --test | --tes | --te | --t )
646 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
650 mode=`echo "X$1" | sed -e 's/^X--//'`
655 func_fatal_error "missing argument for --dir"
660 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
665 func_fatal_error "missing argument for --local-dir"
670 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
672 --verbose | --verbos | --verbo | --verb )
673 verbose=`expr $verbose + 1`
675 --quiet | --quie | --qui | --qu | --q )
676 verbose=`expr $verbose - 1`
681 func_fatal_error "missing argument for --lib"
684 supplied_libname=true
687 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
688 supplied_libname=true
693 func_fatal_error "missing argument for --source-base"
698 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
703 func_fatal_error "missing argument for --m4-base"
708 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
713 func_fatal_error "missing argument for --po-base"
718 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
723 func_fatal_error "missing argument for --doc-base"
728 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
733 func_fatal_error "missing argument for --tests-base"
738 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
743 func_fatal_error "missing argument for --aux-dir"
748 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
756 func_fatal_error "missing argument for --avoid"
758 func_append avoidlist " $1"
761 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
762 func_append avoidlist " $arg"
770 func_fatal_error "missing argument for --makefile-name"
775 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
786 func_fatal_error "missing argument for --macro-prefix"
791 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
796 func_fatal_error "missing argument for --po-domain"
801 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
803 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
809 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
812 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
815 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
819 --help | --hel | --he | --h )
822 --version | --versio | --versi | --vers )
826 # Stop option processing
830 echo "gnulib-tool: unknown option $1" 1>&2
831 echo "Try 'gnulib-tool --help' for more information." 1>&2
838 if test "$mode" = update; then
839 if test $# != 0; then
840 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
841 echo "Try 'gnulib-tool --help' for more information." 1>&2
842 echo "If you really want to modify the gnulib configuration of your project," 1>&2
843 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
846 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
847 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
848 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
849 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
850 || test -n "$makefile_name" || test -n "$macro_prefix" \
851 || test -n "$po_domain"; then
852 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
853 echo "Try 'gnulib-tool --help' for more information." 1>&2
854 echo "If you really want to modify the gnulib configuration of your project," 1>&2
855 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
860 if test -n "$pobase" && test -z "$po_domain"; then
861 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
862 echo "Try 'gnulib-tool --help' for more information." 1>&2
865 if test -z "$pobase" && test -n "$po_domain"; then
866 echo "gnulib-tool: warning: --po-domain has no effect without a --po-base option" 1>&2
869 # Determine the minimum supported autoconf version from the project's
871 DEFAULT_AUTOCONF_MINVERSION="2.59"
874 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
875 if test -f "$destdir"/configure.ac; then
876 configure_ac="$destdir/configure.ac"
878 if test -f "$destdir"/configure.in; then
879 configure_ac="$destdir/configure.in"
883 if test -f configure.ac; then
884 configure_ac="configure.ac"
886 if test -f configure.in; then
887 configure_ac="configure.in"
891 if test -n "$configure_ac"; then
892 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
893 # because when some m4 files are omitted from a CVS repository,
894 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
895 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
896 # autom4te: m4 failed with exit status: 1
903 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
905 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
906 if test -n "$prereqs"; then
907 autoconf_minversion=`
908 for version in $prereqs; do echo $version; done |
909 LC_ALL=C sort -nru | sed 1q
913 if test -z "$autoconf_minversion"; then
914 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
916 case "$autoconf_minversion" in
917 1.* | 2.[0-4]* | 2.5[0-8]*)
918 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
921 # Remove trailing slashes from the directory names. This is necessary for
922 # m4base (to avoid an error in func_import) and optional for the others.
923 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
924 case "$local_gnulib_dir" in
925 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
927 case "$sourcebase" in
928 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
931 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
934 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
937 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
940 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
943 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
948 /*) self_abspathname="$0" ;;
949 */*) self_abspathname=`pwd`/"$0" ;;
952 # Iterate through the elements of $PATH.
953 # We use IFS=: instead of
954 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
955 # because the latter does not work when some PATH element contains spaces.
956 # We use a canonicalized $pathx instead of $PATH, because empty PATH
957 # elements are by definition equivalent to '.', however field splitting
958 # according to IFS=: loses empty fields in many shells:
959 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
960 # beginning, at the end, and in the middle),
961 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
962 # at the beginning and at the end,
963 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
964 # Solaris lose empty fields at the end.
965 # The 'case' statement is an optimization, to avoid evaluating the
966 # explicit canonicalization command when $PATH contains no empty fields.
968 if test "${PATH_SEPARATOR+set}" != set; then
970 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
971 chmod +x "$tmp"/conf.sh
972 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
979 if test "$PATH_SEPARATOR" = ";"; then
980 # On Windows, programs are searched in "." before $PATH.
983 # On Unix, we have to convert empty PATH elements to ".".
987 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
992 IFS="$PATH_SEPARATOR"
996 if test -x "$d/$0" && test ! -d "$d/$0"; then
997 self_abspathname="$d/$0"
1002 if test -z "$self_abspathname"; then
1003 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
1007 while test -h "$self_abspathname"; do
1008 # Resolve symbolic link.
1009 linkval=`func_readlink "$self_abspathname"`
1010 test -n "$linkval" || break
1012 /* ) self_abspathname="$linkval" ;;
1013 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
1016 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
1019 trap 'exit_status=$?
1020 if test "$signal" != 0; then
1021 echo "caught signal $signal" >&2
1024 exit $exit_status' 0
1025 for signal in 1 2 3 13 15; do
1026 trap '{ signal='$signal'; func_exit 1; }' $signal
1030 # func_lookup_file file
1031 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1034 # - local_gnulib_dir from --local-dir
1036 # - lookedup_file name of the merged (combined) file
1037 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1041 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1042 lookedup_file="$local_gnulib_dir/$lkfile"
1045 if test -f "$gnulib_dir/$lkfile"; then
1046 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1047 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1048 rm -f "$tmp/$lkbase"
1049 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1050 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1051 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1052 lookedup_file="$tmp/$lkbase"
1055 lookedup_file="$gnulib_dir/$lkfile"
1059 func_fatal_error "file $gnulib_dir/$lkfile not found"
1066 # - local_gnulib_dir from --local-dir
1069 # Filter out metainformation files like README, which are not modules.
1070 # Filter out unit test modules; they can be retrieved through
1071 # --extract-tests-module if desired.
1073 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1074 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1075 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1078 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1079 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1080 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1081 -e '/^README$/d' -e '/\/README$/d' \
1082 -e '/^TEMPLATE$/d' \
1083 -e '/^TEMPLATE-EXTENDED$/d' \
1084 -e '/^TEMPLATE-TESTS$/d' \
1087 | sed -e '/-tests$/d' \
1091 # func_verify_module
1092 # verifies a module name
1094 # - local_gnulib_dir from --local-dir
1095 # - module module name argument
1096 func_verify_module ()
1098 if { test -f "$gnulib_dir/modules/$module" \
1099 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1100 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1101 && test "CVS" != "$module" \
1102 && test "ChangeLog" != "$module" \
1103 && test "COPYING" != "$module" \
1104 && test "README" != "$module" \
1105 && test "TEMPLATE" != "$module" \
1106 && test "TEMPLATE-EXTENDED" != "$module" \
1107 && test "TEMPLATE-TESTS" != "$module"; then
1108 # OK, $module is a correct module name.
1109 # Verify that building the module description with 'patch' succeeds.
1110 func_lookup_file "modules/$module"
1112 echo "gnulib-tool: module $module doesn't exist" 1>&2
1117 # func_verify_nontests_module
1118 # verifies a module name, excluding tests modules
1120 # - local_gnulib_dir from --local-dir
1121 # - module module name argument
1122 func_verify_nontests_module ()
1125 *-tests ) module= ;;
1126 * ) func_verify_module ;;
1130 # func_verify_tests_module
1131 # verifies a module name, considering only tests modules
1133 # - local_gnulib_dir from --local-dir
1134 # - module module name argument
1135 func_verify_tests_module ()
1138 *-tests ) func_verify_module ;;
1143 sed_extract_prog=':[ ]*$/ {
1146 s/^Description:[ ]*$//
1149 s/^Depends-on:[ ]*$//
1150 s/^configure\.ac-early:[ ]*$//
1151 s/^configure\.ac:[ ]*$//
1152 s/^Makefile\.am:[ ]*$//
1156 s/^Maintainer:[ ]*$//
1163 # func_get_description module
1165 # - local_gnulib_dir from --local-dir
1166 func_get_description ()
1168 func_lookup_file "modules/$1"
1169 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1172 # func_get_notice module
1174 # - local_gnulib_dir from --local-dir
1177 func_lookup_file "modules/$1"
1178 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1181 # func_get_filelist module
1183 # - local_gnulib_dir from --local-dir
1184 func_get_filelist ()
1186 func_lookup_file "modules/$1"
1187 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1188 echo m4/gnulib-common.m4
1189 case "$autoconf_minversion" in
1191 #echo m4/onceonly.m4
1192 echo m4/onceonly_2_57.m4
1197 # func_get_dependencies module
1199 # - local_gnulib_dir from --local-dir
1200 func_get_dependencies ()
1202 # ${module}-tests always implicitly depends on ${module}.
1203 echo "$1" | sed -n -e 's/-tests//p'
1204 # Then the explicit dependencies listed in the module description.
1205 func_lookup_file "modules/$1"
1206 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1209 # func_get_autoconf_early_snippet module
1211 # - local_gnulib_dir from --local-dir
1212 func_get_autoconf_early_snippet ()
1214 func_lookup_file "modules/$1"
1215 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1218 # func_get_autoconf_snippet module
1220 # - local_gnulib_dir from --local-dir
1221 func_get_autoconf_snippet ()
1223 func_lookup_file "modules/$1"
1224 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1227 # func_get_automake_snippet module
1229 # - local_gnulib_dir from --local-dir
1230 func_get_automake_snippet ()
1232 func_lookup_file "modules/$1"
1233 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1236 # *-tests module live in tests/, not lib/.
1239 # Synthesize an EXTRA_DIST augmentation.
1240 sed_combine_lines='/\\$/{
1247 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1248 already_mentioned_files=` \
1249 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1250 | sed -e "$sed_combine_lines" \
1251 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1252 all_files=`func_get_filelist $1`
1253 lib_files=`for f in $all_files; do \
1257 done | sed -e 's,^lib/,,'`
1258 # Remove $already_mentioned_files from $lib_files.
1259 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1260 extra_files=`for f in $already_mentioned_files; do echo $f; done \
1261 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1262 if test -n "$extra_files"; then
1263 echo "EXTRA_DIST +=" $extra_files
1266 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1267 # This is necessary so that automake can generate the right list of
1269 # A possible approach would be to use autom4te --trace of the redefined
1270 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1271 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1272 # inside autoconf's built-in macros are not missed).
1273 # But it's simpler and more robust to do it here, based on the file list.
1274 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1275 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1276 # automake will generate a useless dependency; this is harmless.
1278 relocatable-prog-wrapper) ;;
1280 sed_extract_c_files='/\.c$/p'
1281 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1282 if test -n "$extra_files"; then
1283 echo "EXTRA_lib_SOURCES +=" $extra_files
1288 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1289 buildaux_files=`for f in $all_files; do \
1291 build-aux/*) echo $f ;; \
1293 done | sed -e 's,^build-aux/,,'`
1294 if test -n "$buildaux_files"; then
1295 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1296 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1303 # func_get_include_directive module
1305 # - local_gnulib_dir from --local-dir
1306 func_get_include_directive ()
1308 func_lookup_file "modules/$1"
1309 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1310 sed -e 's/^\(["<]\)/#include \1/'
1313 # func_get_link_directive module
1315 # - local_gnulib_dir from --local-dir
1316 func_get_link_directive ()
1318 func_lookup_file "modules/$1"
1319 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1322 # func_get_license module
1324 # - local_gnulib_dir from --local-dir
1327 func_lookup_file "modules/$1"
1328 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1329 # The default is GPL.
1331 } | sed -e 's,^ *$,,' | sed -e 1q
1334 # func_get_maintainer module
1336 # - local_gnulib_dir from --local-dir
1337 func_get_maintainer ()
1339 func_lookup_file "modules/$1"
1340 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1343 # func_get_tests_module module
1345 # - local_gnulib_dir from --local-dir
1346 func_get_tests_module ()
1348 # The naming convention for tests modules is hardwired: ${module}-tests.
1349 if test -f "$gnulib_dir/modules/$1"-tests \
1350 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1351 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1356 # func_acceptable module
1357 # tests whether a module is acceptable.
1359 # - avoidlist list of modules to avoid
1362 for avoid in $avoidlist; do
1363 if test "$avoid" = "$1"; then
1370 # func_modules_transitive_closure
1372 # - local_gnulib_dir from --local-dir
1373 # - modules list of specified modules
1374 # - inctests true if tests should be included, blank otherwise
1375 # - avoidlist list of modules to avoid
1376 # - tmp pathname of a temporary directory
1378 # - modules list of modules, including dependencies
1379 func_modules_transitive_closure ()
1381 # In order to process every module only once (for speed), process an "input
1382 # list" of modules, producing an "output list" of modules. During each round,
1383 # more modules can be queued in the input list. Once a module on the input
1384 # list has been processed, it is added to the "handled list", so we can avoid
1385 # to process it again.
1387 inmodules="$modules"
1389 while test -n "$inmodules"; do
1390 inmodules_this_round="$inmodules"
1391 inmodules= # Accumulator, queue for next round
1392 for module in $inmodules_this_round; do
1394 if test -n "$module"; then
1395 if func_acceptable $module; then
1396 func_append outmodules " $module"
1397 deps=`func_get_dependencies $module`
1398 # Duplicate dependencies are harmless, but Jim wants a warning.
1399 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1400 if test -n "$duplicated_deps"; then
1401 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1403 func_append inmodules " $deps"
1404 if test -n "$inctests"; then
1405 testsmodule=`func_get_tests_module $module`
1406 if test -n "$testsmodule"; then
1407 func_append inmodules " $testsmodule"
1413 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1414 # Remove $handledmodules from $inmodules.
1415 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1416 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1418 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1419 rm -f "$tmp"/queued-modules
1422 # func_modules_add_dummy
1424 # - local_gnulib_dir from --local-dir
1425 # - modules list of modules, including dependencies
1427 # - modules list of modules, including 'dummy' if needed
1428 func_modules_add_dummy ()
1431 sed_remove_backslash_newline=':a
1438 for module in $modules; do
1439 func_verify_nontests_module
1440 if test -n "$module"; then
1441 # Extract the value of "lib_SOURCES += ...".
1442 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1443 # Ignore .h files since they are not compiled.
1446 *) have_lib_SOURCES=yes ;;
1451 # Add the dummy module, to make sure the library will be non-empty.
1452 if test -z "$have_lib_SOURCES"; then
1453 if func_acceptable "dummy"; then
1454 func_append modules " dummy"
1459 # func_modules_notice
1461 # - local_gnulib_dir from --local-dir
1462 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1463 # - modules list of modules, including dependencies
1464 func_modules_notice ()
1466 if test $verbose -ge -1; then
1467 for module in $modules; do
1469 if test -n "$module"; then
1470 msg=`func_get_notice $module`
1471 if test -n "$msg"; then
1472 echo "Notice from module $module:"
1473 echo "$msg" | sed -e 's/^/ /'
1480 # func_modules_to_filelist
1482 # - local_gnulib_dir from --local-dir
1483 # - modules list of modules, including dependencies
1485 # - files list of files
1486 func_modules_to_filelist ()
1489 for module in $modules; do
1491 if test -n "$module"; then
1492 fs=`func_get_filelist $module`
1493 func_append files " $fs"
1496 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1499 # func_execute_command command [args...]
1500 # Executes a command.
1501 # Uses also the variables
1502 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1503 func_execute_command ()
1505 if test $verbose -ge 0; then
1509 # Commands like automake produce output to stderr even when the succeed.
1510 # Turn this output off if the command succeeds.
1511 "$@" > "$tmp"/cmdout 2>&1
1513 if test $cmdret = 0; then
1517 cat "$tmp"/cmdout 1>&2
1524 # func_emit_lib_Makefile_am
1525 # emits the contents of library makefile to standard output.
1527 # - local_gnulib_dir from --local-dir
1528 # - modules list of modules, including dependencies
1529 # - libname library name
1530 # - pobase directory relative to destdir where to place *.po files
1531 # - auxdir directory relative to destdir where to place build aux files
1532 # - makefile_name from --makefile-name
1533 # - libtool true if libtool will be used, false or blank otherwise
1534 # - macro_prefix prefix of gl_LIBOBJS macros to use
1535 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1536 # - actioncmd (optional) command that will reproduce this invocation
1537 # - for_test true if creating a package for testing, false otherwise
1539 # - uses_subdirs nonempty if object files in subdirs exist
1540 func_emit_lib_Makefile_am ()
1542 # When creating an includable Makefile.am snippet, augment variables with
1543 # += instead of assigning them.
1544 if test -n "$makefile_name"; then
1549 if test "$libtool" = true; then
1552 sed_eliminate_LDFLAGS=
1556 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1559 # When creating a package for testing: Attempt to provoke failures,
1560 # especially link errors, already during "make" rather than during
1561 # "make check", because "make check" is not possible in a cross-compiling
1562 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1563 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1565 sed_transform_check_PROGRAMS=
1567 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1568 echo "## Process this file with automake to produce Makefile.in."
1569 func_emit_copyright_notice
1570 if test -n "$actioncmd"; then
1571 echo "# Reproduce by: $actioncmd"
1576 for module in $modules; do
1577 func_verify_nontests_module
1578 if test -n "$module"; then
1580 func_get_automake_snippet "$module" |
1581 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1582 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1583 -e "$sed_eliminate_LDFLAGS" \
1584 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1585 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1586 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1587 -e "$sed_transform_check_PROGRAMS"
1588 if test "$module" = 'alloca'; then
1589 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1590 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1593 # Skip the contents if its entirely empty.
1594 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1595 echo "## begin gnulib module $module"
1598 echo "## end gnulib module $module"
1602 # Test whether there are some source files in subdirectories.
1603 for f in `func_get_filelist "$module"`; do
1605 lib/*/*.c) uses_subdirs=yes ;;
1611 if test -z "$makefile_name"; then
1612 # If there are source files in subdirectories, prevent collision of the
1613 # object files (example: hash.c and libxml/hash.c).
1615 if test -n "$uses_subdirs"; then
1616 subdir_options=' subdir-objects'
1618 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1621 if test -z "$makefile_name"; then
1622 echo "noinst_HEADERS ="
1623 echo "noinst_LIBRARIES ="
1624 echo "noinst_LTLIBRARIES ="
1625 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1626 # if you specify pkgdata_DATA to empty. This is a workaround.
1627 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1628 echo "pkgdata_DATA ="
1631 echo "BUILT_SOURCES ="
1634 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1635 if test -z "$makefile_name"; then
1636 echo "MOSTLYCLEANDIRS ="
1638 echo "DISTCLEANFILES ="
1639 echo "MAINTAINERCLEANFILES ="
1641 echo "AM_CPPFLAGS ="
1644 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1645 # One of the snippets already specifies an installation location for the
1646 # library. Don't confuse automake by saying it should not be installed.
1649 # By default, the generated library should not be installed.
1650 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1653 echo "${libname}_${libext}_SOURCES ="
1654 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1655 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1656 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1657 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1658 echo "EXTRA_${libname}_${libext}_SOURCES ="
1659 if test "$libtool" = true; then
1660 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1663 if test -n "$pobase"; then
1664 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
1667 cat allsnippets.tmp \
1668 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1670 echo "mostlyclean-local: mostlyclean-generic"
1671 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1672 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1673 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1677 rm -f allsnippets.tmp
1680 # func_emit_po_Makevars
1681 # emits the contents of po/ makefile parametrization to standard output.
1683 # - local_gnulib_dir from --local-dir
1684 # - sourcebase directory relative to destdir where to place source code
1685 # - pobase directory relative to destdir where to place *.po files
1686 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1687 func_emit_po_Makevars ()
1689 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1690 func_emit_copyright_notice
1692 echo "# Usually the message domain is the same as the package name."
1693 echo "# But here it has a '-gnulib' suffix."
1694 echo "DOMAIN = ${po_domain}-gnulib"
1696 echo "# These two variables depend on the location of this directory."
1697 echo "subdir = ${pobase}"
1698 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
1701 # These options get passed to xgettext.
1702 XGETTEXT_OPTIONS = \
1703 --keyword=_ --flag=_:1:pass-c-format \
1704 --keyword=N_ --flag=N_:1:pass-c-format \
1705 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
1706 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
1707 --flag=error:3:c-format --flag=error_at_line:5:c-format
1709 # This is the copyright holder that gets inserted into the header of the
1710 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
1711 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
1713 # This is the email address or URL to which the translators shall report
1714 # bugs in the untranslated strings:
1715 # - Strings which are not entire sentences, see the maintainer guidelines
1716 # in the GNU gettext documentation, section 'Preparing Strings'.
1717 # - Strings which use unclear terms or require additional context to be
1719 # - Strings which make invalid assumptions about notation of date, time or
1721 # - Pluralisation problems.
1722 # - Incorrect English spelling.
1723 # - Incorrect formatting.
1724 # It can be your email address, or a mailing list address where translators
1725 # can write to without being subscribed, or the URL of a web page through
1726 # which the translators can contact you.
1727 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
1729 # This is the list of locale categories, beyond LC_MESSAGES, for which the
1730 # message catalogs shall be used. It is usually empty.
1731 EXTRA_LOCALE_CATEGORIES =
1733 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
1734 # context. Possible values are "yes" and "no". Set this to yes if the
1735 # package uses functions taking also a message context, like pgettext(), or
1736 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
1741 # func_emit_po_POTFILES_in
1742 # emits the file list to be passed to xgettext to standard output.
1744 # - local_gnulib_dir from --local-dir
1745 # - sourcebase directory relative to destdir where to place source code
1746 # - files list of new files
1747 func_emit_po_POTFILES_in ()
1749 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1750 func_emit_copyright_notice
1752 echo "# List of files which contain translatable strings."
1753 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
1756 # func_emit_tests_Makefile_am
1757 # emits the contents of tests makefile to standard output.
1759 # - local_gnulib_dir from --local-dir
1760 # - modules list of modules, including dependencies
1761 # - libname library name
1762 # - makefile_name from --makefile-name
1763 # - libtool true if libtool will be used, false or blank otherwise
1764 # - sourcebase relative directory containing lib source code
1765 # - m4base relative directory containing autoconf macros
1766 # - testsbase relative directory containing unit test code
1767 # - for_test true if creating a package for testing, false otherwise
1768 func_emit_tests_Makefile_am ()
1770 if test "$libtool" = true; then
1775 if test "$libtool" = true; then
1777 sed_eliminate_LDFLAGS=
1780 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1783 # When creating a package for testing: Attempt to provoke failures,
1784 # especially link errors, already during "make" rather than during
1785 # "make check", because "make check" is not possible in a cross-compiling
1786 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1787 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1789 sed_transform_check_PROGRAMS=
1791 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1792 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1793 echo "## Process this file with automake to produce Makefile.in."
1794 func_emit_copyright_notice
1796 # Generate dependencies here, since it eases the debugging of test failures.
1797 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1799 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1802 for module in $modules; do
1803 func_verify_tests_module
1804 if test -n "$module"; then
1806 func_get_automake_snippet "$module" |
1807 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1808 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1809 -e "$sed_eliminate_LDFLAGS" \
1810 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1811 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1812 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1813 -e "$sed_transform_check_PROGRAMS"
1815 # Skip the contents if its entirely empty.
1816 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1817 echo "## begin gnulib module $module"
1820 echo "## end gnulib module $module"
1827 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1828 # variable is needed to avoid an error from automake:
1829 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1832 echo "TESTS_ENVIRONMENT ="
1833 echo "noinst_PROGRAMS ="
1834 if ! $for_test; then
1835 echo "check_PROGRAMS ="
1837 echo "noinst_HEADERS ="
1838 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1839 echo "pkgdata_DATA ="
1842 echo "BUILT_SOURCES ="
1844 echo "MOSTLYCLEANFILES = core *.stackdump"
1845 echo "MOSTLYCLEANDIRS ="
1847 echo "DISTCLEANFILES ="
1848 echo "MAINTAINERCLEANFILES ="
1850 echo "AM_CPPFLAGS = \\"
1851 echo " -I. -I\$(srcdir) \\"
1852 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1853 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1855 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1858 echo "# Clean up after Solaris cc."
1860 echo " rm -rf SunWS_cache"
1862 echo "mostlyclean-local: mostlyclean-generic"
1863 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1864 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1865 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1869 rm -f allsnippets.tmp
1872 # func_emit_initmacro_start
1873 # emits the first few statements of the gl_INIT macro to standard output.
1874 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1875 func_emit_initmacro_start ()
1877 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
1878 # platform-dependent object files in ${macro_prefix}_LIBOBJS instead of
1879 # LIBOBJS. The purpose is to allow several gnulib instantiations under
1880 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
1882 # Furthermore it avoids an automake error like this when a Makefile.am
1883 # that uses pieces of gnulib also uses $(LIBOBJ):
1884 # automatically discovered file `error.c' should not be explicitly mentioned
1885 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix}_LIBOBJ]))"
1886 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix}_REPLACE_FUNCS]))"
1887 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
1888 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
1889 # automatically discovered file `error.c' should not be explicitly mentioned
1890 # We let automake know about the files to be distributed through the
1891 # EXTRA_lib_SOURCES variable.
1892 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix}_LIBSOURCES]))"
1895 # func_emit_initmacro_end
1896 # emits the last few statements of the gl_INIT macro to standard output.
1897 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1898 func_emit_initmacro_end ()
1900 echo " m4_popdef([AC_LIBSOURCES])"
1901 echo " m4_popdef([AC_REPLACE_FUNCS])"
1902 echo " m4_popdef([AC_LIBOBJ])"
1903 echo " AC_CONFIG_COMMANDS_PRE(["
1904 echo " ${macro_prefix}_libobjs="
1905 echo " ${macro_prefix}_ltlibobjs="
1906 echo " if test -n \"\$${macro_prefix}_LIBOBJS\"; then"
1907 echo " # Remove the extension."
1908 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
1909 echo " for i in \`for i in \$${macro_prefix}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
1910 echo " ${macro_prefix}_libobjs=\"\$${macro_prefix}_libobjs \$i.\$ac_objext\""
1911 echo " ${macro_prefix}_ltlibobjs=\"\$${macro_prefix}_ltlibobjs \$i.lo\""
1914 echo " AC_SUBST([${macro_prefix}_LIBOBJS], [\$${macro_prefix}_libobjs])"
1915 echo " AC_SUBST([${macro_prefix}_LTLIBOBJS], [\$${macro_prefix}_ltlibobjs])"
1919 # func_emit_initmacro_done
1920 # emits a few statements after the gl_INIT macro to standard output.
1921 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1922 func_emit_initmacro_done ()
1925 echo "# Like AC_LIBOBJ, except that the module name goes"
1926 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1927 echo "AC_DEFUN([${macro_prefix}_LIBOBJ],"
1928 echo " [${macro_prefix}_LIBOBJS=\"\$${macro_prefix}_LIBOBJS \$1.\$ac_objext\"])"
1930 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
1931 echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1932 echo "AC_DEFUN([${macro_prefix}_REPLACE_FUNCS],"
1933 echo " [AC_CHECK_FUNCS([\$1], , [${macro_prefix}_LIBOBJ(\$ac_func)])])"
1935 echo "# Like AC_LIBSOURCES, except that it does nothing."
1936 echo "# We rely on EXTRA_lib..._SOURCES instead."
1937 echo "AC_DEFUN([${macro_prefix}_LIBSOURCES],"
1941 # func_import modules
1942 # Uses also the variables
1943 # - destdir target directory
1944 # - local_gnulib_dir from --local-dir
1945 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1946 # - libname library name
1947 # - sourcebase directory relative to destdir where to place source code
1948 # - m4base directory relative to destdir where to place *.m4 macros
1949 # - pobase directory relative to destdir where to place *.po files
1950 # - docbase directory relative to destdir where to place doc files
1951 # - testsbase directory relative to destdir where to place unit test code
1952 # - auxdir directory relative to destdir where to place build aux files
1953 # - inctests true if --with-tests was given, blank otherwise
1954 # - avoidlist list of modules to avoid, from --avoid
1955 # - lgpl true if library's license shall be LGPL, blank otherwise
1956 # - makefile_name from --makefile-name
1957 # - libtool true if --libtool was given, false if --no-libtool was
1958 # given, blank otherwise
1959 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1960 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1961 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1962 # - autoconf_minversion minimum supported autoconf version
1963 # - doit : if actions shall be executed, false if only to be printed
1964 # - symbolic true if files should be symlinked, copied otherwise
1965 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
1967 # - do_copyrights true if copyright notices in files should be replaced,
1971 # Get the cached settings.
1972 cached_local_gnulib_dir=
1973 cached_specified_modules=
1983 cached_makefile_name=
1985 cached_macro_prefix=
1988 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1989 cached_libtool=false
1995 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
1998 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
2001 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
2004 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
2007 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
2010 s,^.*gl_PO_BASE([[ ]*\([^])]*\).*$,cached_pobase="\1",p
2013 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
2016 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
2019 s,^.*$,cached_inctests=true,p
2022 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
2025 s,^.*$,cached_lgpl=true,p
2027 /gl_MAKEFILE_NAME(/ {
2028 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
2031 s,^.*$,cached_libtool=true,p
2033 /gl_MACRO_PREFIX(/ {
2034 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
2037 s,^.*gl_PO_DOMAIN([[ ]*\([^])]*\).*$,cached_po_domain="\1",p
2039 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2040 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2045 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2046 s,^.*$,cached_files=",p
2058 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2062 # Merge the cached settings with the specified ones.
2063 # The m4base must be the same as expected from the pathname.
2064 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2065 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2067 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2068 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2069 if test -z "$local_gnulib_dir"; then
2070 if test -n "$cached_local_gnulib_dir"; then
2073 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2075 case "$cached_local_gnulib_dir" in
2077 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2079 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2080 local_gnulib_dir="$relconcat" ;;
2085 # Append the cached and the specified module names. So that
2086 # "gnulib-tool --import foo" means to add the module foo.
2087 specified_modules="$cached_specified_modules $1"
2088 # Append the cached and the specified avoidlist. This is probably better
2089 # than dropping the cached one when --avoid is specified at least once.
2090 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2091 avoidlist=`echo $avoidlist`
2093 # The sourcebase defaults to the cached one.
2094 if test -z "$sourcebase"; then
2095 sourcebase="$cached_sourcebase"
2096 if test -z "$sourcebase"; then
2097 func_fatal_error "missing --source-base option"
2100 # The pobase defaults to the cached one.
2101 if test -z "$pobase"; then
2102 pobase="$cached_pobase"
2104 # The docbase defaults to the cached one.
2105 if test -z "$docbase"; then
2106 docbase="$cached_docbase"
2107 if test -z "$docbase"; then
2108 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."
2111 # The testsbase defaults to the cached one.
2112 if test -z "$testsbase"; then
2113 testsbase="$cached_testsbase"
2114 if test -z "$testsbase"; then
2115 func_fatal_error "missing --tests-base option"
2118 # Require the tests if specified either way.
2119 if test -z "$inctests"; then
2120 inctests="$cached_inctests"
2122 # The libname defaults to the cached one.
2123 if test -z "$supplied_libname"; then
2124 libname="$cached_libname"
2125 if test -z "$libname"; then
2126 func_fatal_error "missing --lib option"
2129 # Require LGPL if specified either way.
2130 if test -z "$lgpl"; then
2133 # The makefile_name defaults to the cached one.
2134 if test -z "$makefile_name"; then
2135 makefile_name="$cached_makefile_name"
2137 # Use libtool if specified either way, or if guessed.
2138 if test -z "$libtool"; then
2139 if test -n "$cached_m4base"; then
2140 libtool="$cached_libtool"
2142 libtool="$guessed_libtool"
2145 # The macro_prefix defaults to the cached one.
2146 if test -z "$macro_prefix"; then
2147 macro_prefix="$cached_macro_prefix"
2148 if test -z "$macro_prefix"; then
2149 func_fatal_error "missing --macro-prefix option"
2152 # The po_domain defaults to the cached one.
2153 if test -z "$po_domain"; then
2154 po_domain="$cached_po_domain"
2157 # Canonicalize the list of specified modules.
2158 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2160 # Determine final module list.
2161 modules="$specified_modules"
2162 func_modules_transitive_closure
2163 if test $verbose -ge 0; then
2164 echo "Module list with included dependencies:"
2165 echo "$modules" | sed -e 's/^/ /'
2168 # Add the dummy module if needed.
2169 func_modules_add_dummy
2171 # If --lgpl, verify that the licenses of modules are compatible.
2172 if test -n "$lgpl"; then
2173 for module in $modules; do
2174 license=`func_get_license $module`
2176 LGPL | LGPLv2+ | 'GPLed build tool') ;;
2177 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2178 *) func_fatal_error "incompatible license on module $module: $license" ;;
2183 # Show banner notice of every module.
2186 # Determine script to apply to imported library files.
2187 sed_transform_lib_file=
2188 for module in $modules; do
2189 if test $module = config-h; then
2190 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2191 sed_transform_lib_file=$sed_transform_lib_file'
2192 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2197 if test -n "$do_copyrights"; then
2198 if test -n "$lgpl"; then
2200 sed_transform_lib_file=$sed_transform_lib_file'
2201 s/GNU General/GNU Lesser General/g
2202 s/version 2\([ ,]\)/version 2.1\1/g
2207 # Determine final file list.
2208 func_modules_to_filelist
2209 if test $verbose -ge 0; then
2211 echo "$files" | sed -e 's/^/ /'
2215 || func_fatal_error "refusing to do nothing"
2217 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2218 new_files="$files m4/gnulib-tool.m4"
2219 old_files="$cached_files"
2220 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2221 func_append old_files " m4/gnulib-tool.m4"
2224 sed_rewrite_old_files="\
2225 s,^build-aux/,$auxdir/,
2226 s,^doc/,$cached_docbase/,
2227 s,^lib/,$cached_sourcebase/,
2228 s,^m4/,$cached_m4base/,
2229 s,^tests/,$cached_testsbase/,"
2230 sed_rewrite_new_files="\
2231 s,^build-aux/,$auxdir/,
2233 s,^lib/,$sourcebase/,
2235 s,^tests/,$testsbase/,"
2237 # Create directories.
2238 { echo "$sourcebase"
2240 if test -n "$pobase"; then
2243 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2244 if test -n "$docfiles"; then
2247 if test -n "$inctests"; then
2251 for f in $files; do echo $f; done \
2252 | sed -e "$sed_rewrite_new_files" \
2253 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2256 { # Rearrange file descriptors. Needed because "while ... done < ..."
2257 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2258 exec 5<&0 < "$tmp"/dirs
2260 if test ! -d "$destdir/$d"; then
2262 echo "Creating directory $destdir/$d"
2263 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2265 echo "Create directory $destdir/$d"
2272 # func_dest_tmpfilename file
2273 # determines the name of a temporary file (file is relative to destdir).
2275 # - tmpfile absolute filename of the temporary file
2276 func_dest_tmpfilename ()
2279 # Put the new contents of $file in a file in the same directory (needed
2280 # to guarantee that an 'mv' to "$destdir/$file" works).
2281 tmpfile="$destdir/$1.tmp"
2283 # Put the new contents of $file in a file in a temporary directory
2284 # (because the directory of "$file" might not exist).
2285 tmpfile="$tmp"/`basename "$1"`.tmp
2289 # Copy files or make symbolic links. Remove obsolete files.
2293 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2294 # representing the files according to the last gnulib-tool invocation.
2295 for f in $old_files; do echo $f; done \
2296 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2299 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2300 # representing the files after this gnulib-tool invocation.
2301 for f in $new_files; do echo $f; done \
2302 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2305 # First the files that are in old-files, but not in new-files:
2306 sed_take_first_column='s,'"$delimiter"'.*,,'
2307 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2308 # Remove the file. Do nothing if the user already removed it.
2309 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
2311 echo "Removing file $g (backup in ${g}~)"
2312 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2314 echo "Remove file $g (backup in ${g}~)"
2316 func_append removed_files "$g$nl"
2319 # func_add_or_update handles a file that ought to be present afterwards.
2321 # - f the original file name
2322 # - g the rewritten file name
2323 # - already_present nonempty if the file already exists, empty otherwise
2324 func_add_or_update ()
2326 func_dest_tmpfilename "$g"
2327 func_lookup_file "$f"
2328 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2329 if test -n "$sed_transform_lib_file"; then
2332 sed -e "$sed_transform_lib_file" \
2333 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2337 if test -f "$destdir/$g"; then
2338 # The file already exists.
2339 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2340 : # The file has not changed.
2344 if test -n "$already_present"; then
2345 echo "Updating file $g (backup in ${g}~)"
2347 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
2349 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2350 if { test -n "$symbolic" \
2351 || { test -n "$lsymbolic" \
2352 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2353 && test -z "$lookedup_tmp" \
2354 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2355 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2357 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2360 if test -n "$already_present"; then
2361 echo "Update file $g (backup in ${g}~)"
2363 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
2369 # Don't protest if the file should be there but isn't: it happens
2370 # frequently that developers don't put autogenerated files into CVS.
2372 echo "Copying file $g"
2373 if { test -n "$symbolic" \
2374 || { test -n "$lsymbolic" \
2375 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2376 && test -z "$lookedup_tmp" \
2377 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2378 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2380 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2385 func_append added_files "$g$nl"
2389 # Then the files that are in new-files, but not in old-files:
2390 sed_take_last_column='s,^.*'"$delimiter"',,'
2392 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2393 | sed -e "$sed_take_last_column" \
2394 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2395 { # Rearrange file descriptors. Needed because "while ... done < ..."
2396 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2397 exec 5<&0 < "$tmp"/added-files
2403 # Then the files that are in new-files and in old-files:
2404 already_present=true
2405 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2406 | sed -e "$sed_take_last_column" \
2407 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2408 { # Rearrange file descriptors. Needed because "while ... done < ..."
2409 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2410 exec 5<&0 < "$tmp"/kept-files
2417 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2418 actioncmd="gnulib-tool --import"
2419 func_append actioncmd " --dir=$destdir"
2420 if test -n "$local_gnulib_dir"; then
2421 func_append actioncmd " --local-dir=$local_gnulib_dir"
2423 func_append actioncmd " --lib=$libname"
2424 func_append actioncmd " --source-base=$sourcebase"
2425 func_append actioncmd " --m4-base=$m4base"
2426 if test -n "$pobase"; then
2427 func_append actioncmd " --po-base=$pobase"
2429 func_append actioncmd " --doc-base=$docbase"
2430 func_append actioncmd " --aux-dir=$auxdir"
2431 if test -n "$inctests"; then
2432 func_append actioncmd " --with-tests"
2434 for module in $avoidlist; do
2435 func_append actioncmd " --avoid=$module"
2437 if test -n "$lgpl"; then
2438 func_append actioncmd " --lgpl"
2440 if test -n "$makefile_name"; then
2441 func_append actioncmd " --makefile-name=$makefile_name"
2443 if test "$libtool" = true; then
2444 func_append actioncmd " --libtool"
2446 func_append actioncmd " --no-libtool"
2448 func_append actioncmd " --macro-prefix=$macro_prefix"
2449 if test -n "$po_domain"; then
2450 func_append actioncmd " --po-domain=$po_domain"
2452 func_append actioncmd " `echo $specified_modules`"
2454 # Default the makefile name to Makefile.am.
2455 if test -n "$makefile_name"; then
2456 makefile_am=$makefile_name
2458 makefile_am=Makefile.am
2461 # Create normal Makefile.ams.
2464 # Create library makefile.
2465 func_dest_tmpfilename $sourcebase/$makefile_am
2466 func_emit_lib_Makefile_am > "$tmpfile"
2467 if test -f "$destdir"/$sourcebase/$makefile_am; then
2468 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
2472 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2473 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
2474 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2476 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2482 echo "Creating $sourcebase/$makefile_am"
2483 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2485 echo "Create $sourcebase/$makefile_am"
2488 func_append added_files "$sourcebase/$makefile_am$nl"
2491 # Create po/ directory.
2492 if test -n "$pobase"; then
2493 # Create po makefile and auxiliary files.
2494 for file in Makefile.in.in remove-potcdate.sin; do
2495 func_dest_tmpfilename $pobase/$file
2496 func_lookup_file build-aux/po/$file
2497 cat "$lookedup_file" > "$tmpfile"
2498 if test -f "$destdir"/$pobase/$file; then
2499 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
2503 echo "Updating $pobase/$file (backup in $pobase/$file~)"
2504 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
2505 mv -f "$tmpfile" "$destdir"/$pobase/$file
2507 echo "Update $pobase/$file (backup in $pobase/$file~)"
2513 echo "Creating $pobase/$file"
2514 mv -f "$tmpfile" "$destdir"/$pobase/$file
2516 echo "Create $pobase/$file"
2519 func_append added_files "$pobase/$file$nl"
2522 # Create po makefile parametrization, part 1.
2523 func_dest_tmpfilename $pobase/Makevars
2524 func_emit_po_Makevars > "$tmpfile"
2525 if test -f "$destdir"/$pobase/Makevars; then
2526 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
2530 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
2531 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
2532 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2534 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
2540 echo "Creating $pobase/Makevars"
2541 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2543 echo "Create $pobase/Makevars"
2546 func_append added_files "$pobase/Makevars$nl"
2548 # Create po makefile parametrization, part 2.
2549 func_dest_tmpfilename $pobase/POTFILES.in
2550 func_emit_po_POTFILES_in > "$tmpfile"
2551 if test -f "$destdir"/$pobase/POTFILES.in; then
2552 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
2556 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2557 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
2558 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2560 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2566 echo "Creating $pobase/POTFILES.in"
2567 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2569 echo "Create $pobase/POTFILES.in"
2572 func_append added_files "$pobase/POTFILES.in$nl"
2575 TP_URL="http://translationproject.org/latest/"
2576 TP_RSYNC_URI="translationproject.org::tp/latest/"
2578 echo "Fetching gnulib PO files from $TP_URL"
2579 (cd "$destdir"/$pobase \
2580 && { # Prefer rsync over wget if it is available, since it consumes
2581 # less network bandwidth, due to compression.
2582 if type rsync 2>/dev/null | grep / > /dev/null; then
2583 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
2585 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
2590 echo "Fetch gnulib PO files from $TP_URL"
2592 # Create po/LINGUAS.
2594 func_dest_tmpfilename $pobase/LINGUAS
2595 (cd "$destdir"/$pobase \
2596 && { echo '# Set of available languages.'
2597 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
2600 if test -f "$destdir"/$pobase/LINGUAS; then
2601 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
2604 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2605 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
2606 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2609 echo "Creating $pobase/LINGUAS"
2610 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2611 func_append added_files "$pobase/LINGUAS$nl"
2614 if test -f "$destdir"/$pobase/LINGUAS; then
2615 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2617 echo "Create $pobase/LINGUAS"
2622 # Create m4/gnulib-cache.m4.
2623 func_dest_tmpfilename $m4base/gnulib-cache.m4
2625 func_emit_copyright_notice
2627 echo "# This file represents the specification of how gnulib-tool is used."
2628 echo "# It acts as a cache: It is written and read by gnulib-tool."
2629 echo "# In projects using CVS, this file is meant to be stored in CVS,"
2630 echo "# like the configure.ac and various Makefile.am files."
2633 echo "# Specification in the form of a command-line invocation:"
2636 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
2637 # Store the local_gnulib_dir relative to destdir.
2638 case "$local_gnulib_dir" in
2640 relative_local_gnulib_dir="$local_gnulib_dir" ;;
2643 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
2645 # destdir, local_gnulib_dir are both relative.
2646 func_relativize "$destdir" "$local_gnulib_dir"
2647 relative_local_gnulib_dir="$reldir" ;;
2650 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
2651 echo "gl_MODULES(["`echo $specified_modules`"])"
2652 echo "gl_AVOID([$avoidlist])"
2653 echo "gl_SOURCE_BASE([$sourcebase])"
2654 echo "gl_M4_BASE([$m4base])"
2655 echo "gl_PO_BASE([$pobase])"
2656 echo "gl_DOC_BASE([$docbase])"
2657 echo "gl_TESTS_BASE([$testsbase])"
2658 test -z "$inctests" || echo "gl_WITH_TESTS"
2659 echo "gl_LIB([$libname])"
2660 test -z "$lgpl" || echo "gl_LGPL"
2661 echo "gl_MAKEFILE_NAME([$makefile_name])"
2662 if test "$libtool" = true; then
2665 echo "gl_MACRO_PREFIX([$macro_prefix])"
2666 echo "gl_PO_DOMAIN([$po_domain])"
2668 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2669 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2673 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2674 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2675 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2677 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2681 echo "# gnulib-cache.m4 ends here"
2688 echo "Creating $m4base/gnulib-cache.m4"
2689 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2691 echo "Create $m4base/gnulib-cache.m4"
2697 # Create m4/gnulib-comp.m4.
2698 func_dest_tmpfilename $m4base/gnulib-comp.m4
2700 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
2701 func_emit_copyright_notice
2703 echo "# This file represents the compiled summary of the specification in"
2704 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
2705 echo "# to be invoked from configure.ac."
2706 echo "# In projects using CVS, this file can be treated like other built files."
2709 echo "# This macro should be invoked from $configure_ac, in the section"
2710 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2711 echo "# any checks for libraries, header files, types and library functions."
2712 echo "AC_DEFUN([${macro_prefix}_EARLY],"
2714 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2715 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2716 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2717 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2718 echo " AC_REQUIRE([AC_PROG_RANLIB])"
2719 if test -n "$uses_subdirs"; then
2720 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
2722 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2723 echo " AC_REQUIRE([AC_GNU_SOURCE])"
2725 for module in $modules; do
2727 if test -n "$module"; then
2728 func_get_autoconf_early_snippet "$module"
2731 | sed -e '/^$/d;' -e 's/^/ /'
2734 echo "# This macro should be invoked from $configure_ac, in the section"
2735 echo "# \"Check for header files, types and library functions\"."
2736 echo "AC_DEFUN([${macro_prefix}_INIT],"
2738 func_emit_initmacro_start
2739 if test "$libtool" = true; then
2740 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2741 echo " gl_cond_libtool=true"
2743 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2744 echo " gl_cond_libtool=false"
2746 echo " gl_ltlibdeps="
2748 echo " gl_source_base='$sourcebase'"
2749 if test "$auxdir" != "build-aux"; then
2750 sed_replace_build_aux='
2752 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2753 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2757 sed_replace_build_aux=
2759 for module in $modules; do
2761 if test -n "$module"; then
2762 func_get_autoconf_snippet "$module" \
2763 | sed -e '/^$/d;' -e 's/^/ /' \
2764 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
2765 -e "$sed_replace_build_aux"
2766 if test "$module" = 'alloca' && test "$libtool" = true; then
2767 echo 'changequote(,)dnl'
2768 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
2769 echo 'changequote([, ])dnl'
2770 echo 'AC_SUBST([LTALLOCA])'
2774 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2775 # created using libtool, because libtool already handles the dependencies.
2776 if test "$libtool" != true; then
2777 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
2778 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2779 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2780 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2781 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2783 func_emit_initmacro_end
2785 func_emit_initmacro_done
2787 echo "# This macro records the list of files which have been installed by"
2788 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
2789 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
2790 echo "$files" | sed -e 's,^, ,'
2793 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2794 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
2798 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2799 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
2800 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2802 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2806 echo "# gnulib-comp.m4 ends here"
2813 echo "Creating $m4base/gnulib-comp.m4"
2814 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2816 echo "Create $m4base/gnulib-comp.m4"
2822 if test -n "$inctests"; then
2823 # Create tests makefile.
2824 func_dest_tmpfilename $testsbase/$makefile_am
2825 func_emit_tests_Makefile_am > "$tmpfile"
2826 if test -f "$destdir"/$testsbase/$makefile_am; then
2827 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
2831 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2832 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
2833 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2835 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2841 echo "Creating $testsbase/$makefile_am"
2842 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2844 echo "Create $testsbase/$makefile_am"
2847 func_append added_files "$testsbase/$makefile_am$nl"
2851 # Update the .cvsignore and .gitignore files.
2852 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
2853 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
2854 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
2855 { # Rearrange file descriptors. Needed because "while ... done < ..."
2856 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2857 exec 5<&0 < "$tmp"/fileset-changes
2858 func_update_ignorelist ()
2861 if test -f "$destdir/$dir$ignore"; then
2862 if test -n "$dir_added" || test -n "$dir_removed"; then
2863 LC_ALL=C sort "$destdir/$dir$ignore" > "$tmp"/ignore
2864 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
2865 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-added
2866 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
2867 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-removed
2868 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
2870 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2871 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
2872 sed -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed > "$tmp"/sed-ignore-removed
2873 cat "$destdir/$dir$ignore"~ "$tmp"/ignore-added \
2874 | sed -f "$tmp"/sed-ignore-removed \
2875 > "$destdir/$dir$ignore"
2877 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
2882 if test -n "$dir_added"; then
2884 echo "Creating $destdir/$dir$ignore"
2886 if test "$ignore" = .cvsignore; then
2888 # Automake generates Makefile rules that create .dirstamp files.
2891 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u
2892 } > "$destdir/$dir$ignore"
2894 echo "Create $destdir/$dir$ignore"
2904 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
2905 func_update_ignorelist .cvsignore
2907 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
2908 func_update_ignorelist .gitignore
2915 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
2916 next_dir=`echo "$line" | sed -e 's,|.*,,'`
2917 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
2918 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
2919 if test "$next_dir" != "$last_dir"; then
2920 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2921 last_dir="$next_dir"
2926 A) func_append last_dir_added "$file$nl";;
2927 R) func_append last_dir_removed "$file$nl";;
2930 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
2936 echo "You may need to add #include directives for the following .h files."
2937 # Intersect $specified_modules and $modules
2938 # (since $specified_modules is not necessarily of subset of $modules - some
2939 # may have been skipped through --avoid, and since the elements of $modules
2940 # but not in $specified_modules can go away without explicit notice - through
2941 # changes in the module dependencies).
2942 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
2943 echo "$modules" > "$tmp"/modules2 # also a sorted list, one module per line
2944 # First the #include <...> directives without #ifs, sorted for convenience,
2945 # then the #include "..." directives without #ifs, sorted for convenience,
2946 # then the #include directives that are surrounded by #ifs. Not sorted.
2947 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
2948 include_directive=`func_get_include_directive "$module"`
2949 case "$nl$include_directive" in
2951 echo "$include_directive" 1>&5
2954 echo "$include_directive" | grep -v 'include "' 1>&6
2955 echo "$include_directive" | grep 'include "' 1>&7
2958 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
2960 LC_ALL=C sort -u "$tmp"/include-angles
2961 LC_ALL=C sort -u "$tmp"/include-quotes
2962 cat "$tmp"/include-if
2963 ) | sed -e '/^$/d' -e 's/^/ /'
2964 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
2966 for module in $modules; do
2967 func_get_link_directive "$module"
2969 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
2970 if test `wc -l < "$tmp"/link` != 0; then
2972 echo "You may need to use the following Makefile variables when linking."
2973 echo "Use them in <program>_LDADD when linking a program, or"
2974 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
2980 echo "Don't forget to"
2981 if test "$makefile_am" = Makefile.am; then
2982 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2984 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
2986 if test -n "$pobase"; then
2987 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
2989 if test -n "$inctests"; then
2990 if test "$makefile_am" = Makefile.am; then
2991 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2993 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
2996 if test "$makefile_am" = Makefile.am; then
2997 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
2998 sourcebase_base=`basename "$sourcebase"`
2999 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
3001 if test -n "$pobase"; then
3002 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3003 pobase_base=`basename "$pobase"`
3004 echo " - mention \"${pobase_base}\" in SUBDIRS in ${pobase_dir}Makefile.am,"
3006 if test -n "$inctests"; then
3007 if test "$makefile_am" = Makefile.am; then
3008 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3009 testsbase_base=`basename "$testsbase"`
3010 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
3013 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
3014 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
3015 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
3018 # func_create_testdir testdir modules
3020 # - local_gnulib_dir from --local-dir
3021 # - auxdir directory relative to destdir where to place build aux files
3022 func_create_testdir ()
3026 if test -z "$modules"; then
3027 # All modules together.
3028 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3029 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3030 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
3031 modules=`func_all_modules`
3032 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
3034 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
3036 # Check that the license of every module is consistent with the license of
3038 saved_modules="$modules"
3039 saved_inctests="$inctests"
3040 # When computing transitive closures, don't consider $module to depend on
3041 # $module-tests. Need this becauses tests are implicitly GPL and may depend
3042 # on GPL modules - therefore we don't want a warning in this case.
3044 for requested_module in $saved_modules; do
3045 requested_license=`func_get_license "$requested_module"`
3046 if test "$requested_license" != GPL; then
3047 # Here we use func_modules_transitive_closure, not just
3048 # func_get_dependencies, so that we also detect weird situations like
3049 # an LGPL module which depends on a GPLed build tool module which depends
3051 modules="$requested_module"
3052 func_modules_transitive_closure
3053 for module in $modules; do
3054 license=`func_get_license "$module"`
3056 'GPLed build tool') ;;
3057 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3059 case "$requested_license" in
3062 GPLv2+ | LGPLv2+) ;;
3063 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3069 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3075 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3084 modules="$saved_modules"
3085 inctests="$saved_inctests"
3087 # Subdirectory names.
3096 # Determine final module list.
3097 func_modules_transitive_closure
3098 if test $verbose -ge 0; then
3099 echo "Module list with included dependencies:"
3100 echo "$modules" | sed -e 's/^/ /'
3103 # Add the dummy module if needed.
3104 func_modules_add_dummy
3106 # Show banner notice of every module.
3109 # Determine final file list.
3110 func_modules_to_filelist
3111 if test $verbose -ge 0; then
3113 echo "$files" | sed -e 's/^/ /'
3116 sed_rewrite_files="\
3117 s,^build-aux/,$auxdir/,
3119 s,^lib/,$sourcebase/,
3121 s,^tests/,$testsbase/,"
3123 # Create directories.
3124 for f in $files; do echo $f; done \
3125 | sed -e "$sed_rewrite_files" \
3126 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3127 | LC_ALL=C sort -u \
3129 { # Rearrange file descriptors. Needed because "while ... done < ..."
3130 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3131 exec 5<&0 < "$tmp"/dirs
3133 mkdir -p "$testdir/$d"
3138 # Copy files or make symbolic links.
3140 for f in $files; do echo $f; done \
3141 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3144 { # Rearrange file descriptors. Needed because "while ... done < ..."
3145 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3146 exec 5<&0 < "$tmp"/files
3148 func_lookup_file "$f"
3149 if test -n "$lookedup_tmp"; then
3150 cp -p "$lookedup_file" "$testdir/$g"
3152 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3153 if { test -n "$symbolic" \
3154 || { test -n "$lsymbolic" \
3155 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3156 func_ln "$lookedup_file" "$testdir/$g"
3158 cp -p "$lookedup_file" "$testdir/$g"
3165 # Create Makefile.ams that are for testing.
3168 # Create $sourcebase/Makefile.am.
3169 mkdir -p "$testdir/$sourcebase"
3170 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3172 # Create $m4base/Makefile.am.
3173 mkdir -p "$testdir/$m4base"
3174 (echo "## Process this file with automake to produce Makefile.in."
3180 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
3183 ) > "$testdir/$m4base/Makefile.am"
3185 subdirs="$sourcebase $m4base"
3186 subdirs_with_configure_ac=""
3188 if false && test -f "$testdir"/$m4base/gettext.m4; then
3189 # Avoid stupid error message from automake:
3190 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
3191 mkdir -p "$testdir/po"
3192 (echo "## Process this file with automake to produce Makefile.in."
3193 ) > "$testdir/po/Makefile.am"
3194 func_append subdirs " po"
3197 if test -n "$inctests"; then
3198 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
3199 # Create $testsbase/Makefile.am.
3200 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
3201 # Create $testsbase/configure.ac.
3202 (echo "# Process this file with autoconf to produce a configure script."
3203 echo "AC_INIT([dummy], [0])"
3204 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
3205 echo "AM_INIT_AUTOMAKE"
3207 echo "AM_CONFIG_HEADER([config.h])"
3210 echo "AC_PROG_INSTALL"
3211 echo "AC_PROG_MAKE_SET"
3212 echo "AC_PROG_RANLIB"
3214 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3215 echo "AC_GNU_SOURCE"
3218 for module in $modules; do
3220 if test -n "$module"; then
3221 func_get_autoconf_early_snippet "$module"
3224 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3225 if test "$libtool" = true; then
3226 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3227 echo "gl_cond_libtool=true"
3229 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3230 echo "gl_cond_libtool=false"
3232 echo "gl_ltlibdeps="
3234 # Wrap the set of autoconf snippets into an autoconf macro that is then
3235 # invoked. This is needed because autoconf does not support AC_REQUIRE
3237 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3238 # but we want the AC_REQUIRE to have its normal meaning (provide one
3239 # expansion of the required macro before the current point, and only one
3241 echo "AC_DEFUN([gl_INIT], ["
3242 func_emit_initmacro_start
3243 sed_replace_build_aux='
3245 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3246 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
3249 # We don't have explicit ordering constraints between the various
3250 # autoconf snippets. It's cleanest to put those of the library before
3251 # those of the tests.
3252 echo "gl_source_base='../$sourcebase'"
3253 for module in $modules; do
3254 func_verify_nontests_module
3255 if test -n "$module"; then
3256 func_get_autoconf_snippet "$module" \
3257 | sed -e "$sed_replace_build_aux"
3260 echo "gl_source_base='.'"
3261 for module in $modules; do
3262 func_verify_tests_module
3263 if test -n "$module"; then
3264 func_get_autoconf_snippet "$module" \
3265 | sed -e "$sed_replace_build_aux"
3268 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3269 # created using libtool, because libtool already handles the dependencies.
3270 if test "$libtool" != true; then
3271 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3272 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3273 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3274 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3275 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3277 func_emit_initmacro_end
3279 func_emit_initmacro_done
3283 # Usually $testsbase/config.h will be a superset of config.h. Verify this
3284 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
3285 echo "AH_TOP([#include \"../config.h\"])"
3287 echo "AC_OUTPUT([Makefile])"
3288 ) > "$testdir/$testsbase/configure.ac"
3289 func_append subdirs " $testsbase"
3290 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
3293 # Create Makefile.am.
3294 (echo "## Process this file with automake to produce Makefile.in."
3296 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3298 echo "SUBDIRS = $subdirs"
3300 echo "ACLOCAL_AMFLAGS = -I $m4base"
3301 ) > "$testdir/Makefile.am"
3303 # Create configure.ac.
3304 (echo "# Process this file with autoconf to produce a configure script."
3305 echo "AC_INIT([dummy], [0])"
3306 if test "$auxdir" != "."; then
3307 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3309 echo "AM_INIT_AUTOMAKE"
3311 echo "AM_CONFIG_HEADER([config.h])"
3314 echo "AC_PROG_INSTALL"
3315 echo "AC_PROG_MAKE_SET"
3317 echo "# For autobuild."
3318 echo "AC_CANONICAL_BUILD"
3319 echo "AC_CANONICAL_HOST"
3321 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3322 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3323 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3324 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3326 echo "AC_PROG_RANLIB"
3328 if test -n "$uses_subdirs"; then
3329 echo "AM_PROG_CC_C_O"
3332 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3333 echo "AC_GNU_SOURCE"
3336 for module in $modules; do
3337 func_verify_nontests_module
3338 if test -n "$module"; then
3339 func_get_autoconf_early_snippet "$module"
3342 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3343 if test "$libtool" = true; then
3344 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3345 echo "gl_cond_libtool=true"
3347 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3348 echo "gl_cond_libtool=false"
3350 echo "gl_ltlibdeps="
3352 echo "gl_source_base='$sourcebase'"
3353 # Wrap the set of autoconf snippets into an autoconf macro that is then
3354 # invoked. This is needed because autoconf does not support AC_REQUIRE
3356 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3357 # but we want the AC_REQUIRE to have its normal meaning (provide one
3358 # expansion of the required macro before the current point, and only one
3360 echo "AC_DEFUN([gl_INIT], ["
3361 func_emit_initmacro_start
3362 if test "$auxdir" != "build-aux"; then
3363 sed_replace_build_aux='
3365 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3366 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3370 sed_replace_build_aux=
3372 for module in $modules; do
3373 func_verify_nontests_module
3374 if test -n "$module"; then
3375 func_get_autoconf_snippet "$module" \
3376 | sed -e "$sed_replace_build_aux"
3379 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3380 # created using libtool, because libtool already handles the dependencies.
3381 if test "$libtool" != true; then
3382 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3383 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3384 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3385 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3386 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3388 func_emit_initmacro_end
3390 func_emit_initmacro_done
3394 if test -n "$subdirs_with_configure_ac"; then
3395 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
3397 makefiles="Makefile"
3398 for d in $subdirs; do
3399 # For subdirs that have a configure.ac by their own, it's the subdir's
3400 # configure.ac which creates the subdir's Makefile.am, not this one.
3401 case " $subdirs_with_configure_ac " in
3403 *) func_append makefiles " $d/Makefile" ;;
3406 echo "AC_OUTPUT([$makefiles])"
3407 ) > "$testdir/configure.ac"
3409 # Create autogenerated files.
3411 # Do not use "${AUTORECONF} --force --install", because it may invoke
3412 # autopoint, which brings in older versions of some of our .m4 files.
3413 if test -f $m4base/gettext.m4; then
3414 func_execute_command ${AUTOPOINT} --force || func_exit 1
3415 for f in $m4base/*.m4~; do
3416 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3419 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
3420 if ! test -d build-aux; then
3421 func_execute_command mkdir build-aux || func_exit 1
3423 func_execute_command ${AUTOCONF} || func_exit 1
3424 func_execute_command ${AUTOHEADER} || func_exit 1
3425 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3427 if test -n "$inctests"; then
3428 # Create autogenerated files.
3429 (cd "$testdir/$testsbase" || func_exit 1
3430 # Do not use "${AUTORECONF} --force --install", because it may invoke
3431 # autopoint, which brings in older versions of some of our .m4 files.
3432 if test -f ../$m4base/gettext.m4; then
3433 func_execute_command ${AUTOPOINT} --force || func_exit 1
3434 for f in ../$m4base/*.m4~; do
3435 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3438 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
3439 if ! test -d ../build-aux; then
3440 func_execute_command mkdir ../build-aux
3442 func_execute_command ${AUTOCONF} || func_exit 1
3443 func_execute_command ${AUTOHEADER} || func_exit 1
3444 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3447 # Need to run configure and make once, to create built files that are to be
3448 # distributed (such as getdate.c).
3449 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
3450 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3451 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
3452 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
3453 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
3454 # such $(FOO_H) because they don't refer to distributed files.
3455 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
3456 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3457 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
3458 | sed -e "$sed_remove_make_variables"`
3459 distributed_built_sources=`for file in $built_sources; do
3460 case "$cleaned_files" in
3465 if test -n "$distributed_built_sources"; then
3467 ./configure || func_exit 1
3469 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
3470 make built_sources || func_exit 1
3472 make distclean || func_exit 1
3477 # func_create_megatestdir megatestdir allmodules
3479 # - local_gnulib_dir from --local-dir
3480 # - auxdir directory relative to destdir where to place build aux files
3481 func_create_megatestdir ()
3485 if test -z "$allmodules"; then
3486 allmodules=`func_all_modules`
3490 # First, all modules one by one.
3491 for onemodule in $allmodules; do
3492 func_create_testdir "$megatestdir/$onemodule" $onemodule
3493 func_append megasubdirs "$onemodule "
3495 # Then, all modules all together.
3496 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3497 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3498 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
3499 func_create_testdir "$megatestdir/ALL" "$allmodules"
3500 func_append megasubdirs "ALL"
3503 cvsdate=`sh "$gnulib_dir/build-aux/mdate-sh" "$gnulib_dir/CVS/Entries" \
3504 | sed -e 's,January,01,' -e 's,Jan,01,' \
3505 -e 's,February,02,' -e 's,Feb,02,' \
3506 -e 's,March,03,' -e 's,Mar,03,' \
3507 -e 's,April,04,' -e 's,Apr,04,' \
3509 -e 's,June,06,' -e 's,Jun,06,' \
3510 -e 's,July,07,' -e 's,Jul,07,' \
3511 -e 's,August,08,' -e 's,Aug,08,' \
3512 -e 's,September,09,' -e 's,Sep,09,' \
3513 -e 's,October,10,' -e 's,Oct,10,' \
3514 -e 's,November,11,' -e 's,Nov,11,' \
3515 -e 's,December,12,' -e 's,Dec,12,' \
3516 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
3517 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
3519 echo "CVSDATE=$cvsdate"
3520 echo "test -d logs || mkdir logs"
3521 echo "for module in $megasubdirs; do"
3522 echo " echo \"Working on module \$module...\""
3523 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
3524 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
3527 echo " : autobuild project... \$module"
3528 echo " : autobuild revision... cvs-\$CVSDATE-000000"
3529 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
3530 echo " : autobuild hostname... \`hostname\`"
3531 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
3533 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
3535 ) > "$megatestdir/do-autobuild"
3536 chmod a+x "$megatestdir/do-autobuild"
3538 # Create Makefile.am.
3539 (echo "## Process this file with automake to produce Makefile.in."
3541 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3543 echo "SUBDIRS = $megasubdirs"
3545 echo "EXTRA_DIST = do-autobuild"
3546 ) > "$megatestdir/Makefile.am"
3548 # Create configure.ac.
3549 (echo "# Process this file with autoconf to produce a configure script."
3550 echo "AC_INIT([dummy], [0])"
3551 if test "$auxdir" != "."; then
3552 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3554 echo "AM_INIT_AUTOMAKE"
3556 echo "AC_PROG_MAKE_SET"
3558 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
3559 echo "AC_OUTPUT([Makefile])"
3560 ) > "$megatestdir/configure.ac"
3562 # Create autogenerated files.
3564 # Do not use "${AUTORECONF} --install", because autoreconf operates
3565 # recursively, but the subdirectories are already finished, therefore
3566 # calling autoreconf here would only waste lots of CPU time.
3567 func_execute_command ${ACLOCAL} || func_exit 1
3568 func_execute_command mkdir build-aux
3569 func_execute_command ${AUTOCONF} || func_exit 1
3570 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3576 func_fatal_error "no mode specified" ;;
3585 if test -z "$destdir"; then
3588 test -d "$destdir" \
3589 || func_fatal_error "destination directory does not exist: $destdir"
3591 # Prefer configure.ac to configure.in.
3592 if test -f "$destdir"/configure.ac; then
3593 configure_ac="$destdir/configure.ac"
3595 if test -f "$destdir"/configure.in; then
3596 configure_ac="$destdir/configure.in"
3598 func_fatal_error "cannot find $destdir/configure.ac"
3602 # Analyze configure.ac.
3604 guessed_libtool=false
3609 /AC_CONFIG_AUX_DIR/ {
3610 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
3612 /A[CM]_PROG_LIBTOOL/ {
3613 s,^.*$,guessed_libtool=true,p
3615 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
3617 if test -z "$auxdir"; then
3618 auxdir="$guessed_auxdir"
3621 # Determine where to apply func_import.
3622 if test -n "$m4base"; then
3623 # Apply func_import to a particular gnulib directory.
3624 # Any number of additional modules can be given.
3625 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
3626 # First use of gnulib in the given m4base.
3627 test -n "$supplied_libname" || supplied_libname=true
3628 test -n "$sourcebase" || sourcebase="lib"
3629 test -n "$docbase" || docbase="doc"
3630 test -n "$testsbase" || testsbase="tests"
3631 test -n "$macro_prefix" || macro_prefix="gl"
3635 # Apply func_import to all gnulib directories.
3636 # To get this list of directories, look at Makefile.am. (Not at
3637 # configure, because it may be omitted from CVS. Also, don't run
3638 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
3641 if test -f "$destdir"/Makefile.am; then
3642 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
3644 for arg in $aclocal_amflags; do
3645 if test -n "$m4dir_is_next"; then
3646 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
3650 if test -f "$destdir/$arg"/gnulib-cache.m4; then
3651 func_append m4dirs " $arg"
3652 m4dirs_count=`expr $m4dirs_count + 1`
3658 if test "X$arg" = "X-I"; then
3666 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
3667 if test -f "$destdir"/aclocal.m4; then
3668 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
3669 sedexpr2='s,^[^/]*$,.,'
3670 sedexpr3='s,/[^/]*$,,'
3671 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
3672 m4dirs_count=`echo "$m4dirs" | wc -l`
3675 if test $m4dirs_count = 0; then
3676 # First use of gnulib in a package.
3677 # Any number of additional modules can be given.
3678 test -n "$supplied_libname" || supplied_libname=true
3679 test -n "$sourcebase" || sourcebase="lib"
3681 test -n "$docbase" || docbase="doc"
3682 test -n "$testsbase" || testsbase="tests"
3683 test -n "$macro_prefix" || macro_prefix="gl"
3686 if test $m4dirs_count = 1; then
3687 # There's only one use of gnulib here. Assume the user means it.
3688 # Any number of additional modules can be given.
3689 for m4base in $m4dirs; do
3693 # Ambiguous - guess what the user meant.
3694 if test $# = 0; then
3695 # No further arguments. Guess the user wants to update all of them.
3696 for m4base in $m4dirs; do
3697 # Perform func_import in a subshell, so that variable values
3699 # local_gnulib_dir, avoidlist, sourcebase, m4base, pobase,
3700 # docbase, testsbase, inctests, libname, lgpl, makefile_name,
3701 # libtool, macro_prefix, po_domain
3702 # don't propagate from one directory to another.
3703 (func_import) || func_exit 1
3707 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
3715 if test -z "$destdir"; then
3716 func_fatal_error "please specify --dir option"
3719 test -d "$destdir" \
3720 || func_fatal_error "could not create destination directory"
3721 test -n "$auxdir" || auxdir="build-aux"
3722 func_create_testdir "$destdir" "$*"
3725 create-megatestdir )
3726 if test -z "$destdir"; then
3727 func_fatal_error "please specify --dir option"
3729 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3730 test -n "$auxdir" || auxdir="build-aux"
3731 func_create_megatestdir "$destdir" "$*"
3735 test -n "$destdir" || destdir=testdir$$
3736 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3737 test -n "$auxdir" || auxdir="build-aux"
3738 func_create_testdir "$destdir" "$*"
3742 ../configure || func_exit 1
3744 make check || func_exit 1
3745 make distclean || func_exit 1
3746 remaining=`find . -type f -print`
3747 if test -n "$remaining"; then
3748 echo "Remaining files:" $remaining 1>&2
3749 echo "gnulib-tool: *** Stop." 1>&2
3758 test -n "$destdir" || destdir=testdir$$
3759 mkdir "$destdir" || func_fatal_error "could not create destination directory"
3760 test -n "$auxdir" || auxdir="build-aux"
3761 func_create_megatestdir "$destdir" "$*"
3769 remaining=`find . -type f -print`
3770 if test -n "$remaining"; then
3771 echo "Remaining files:" $remaining 1>&2
3772 echo "gnulib-tool: *** Stop." 1>&2
3780 extract-description )
3784 if test -n "$module"; then
3785 func_get_description "$module"
3794 if test -n "$module"; then
3795 func_get_notice "$module"
3804 if test -n "$module"; then
3805 func_get_filelist "$module"
3810 extract-dependencies )
3814 if test -n "$module"; then
3815 func_get_dependencies "$module"
3820 extract-autoconf-snippet )
3824 if test -n "$module"; then
3825 func_get_autoconf_snippet "$module"
3830 extract-automake-snippet )
3834 if test -n "$module"; then
3835 func_get_automake_snippet "$module"
3840 extract-include-directive )
3844 if test -n "$module"; then
3845 func_get_include_directive "$module"
3850 extract-link-directive )
3854 if test -n "$module"; then
3855 func_get_link_directive "$module"
3864 if test -n "$module"; then
3865 func_get_license "$module"
3870 extract-maintainer )
3874 if test -n "$module"; then
3875 func_get_maintainer "$module"
3880 extract-tests-module )
3884 if test -n "$module"; then
3885 func_get_tests_module "$module"
3891 func_fatal_error "unknown operation mode --$mode" ;;
3895 # Undo the effect of the previous 'trap' command. Some shellology:
3896 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
3897 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
3898 # exit); for the others we need to call 'exit' explicitly. The value of $? is
3899 # 128 + signal number and is set before the trap-registered command is run.
3901 trap 'func_exit $?' 1 2 3 13 15
3906 # indent-tabs-mode: nil
3907 # whitespace-check-buffer-indent: nil