3 # Copyright (C) 2002-2010 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # This program is meant for authors or maintainers which want to import
20 # modules from gnulib into their packages.
28 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
32 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
33 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
37 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
40 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
43 # You can set LIBTOOLPATH to empty if libtoolize 2.x is already in your PATH.
46 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
47 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
48 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
49 AUTOCONF="${AUTOCONFPATH}autoconf"
51 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
52 AUTOHEADER="${AUTOCONFPATH}autoheader"
54 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
55 ACLOCAL="${AUTOMAKEPATH}aclocal"
57 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
58 AUTOMAKE="${AUTOMAKEPATH}automake"
60 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
61 AUTORECONF="${AUTOCONFPATH}autoreconf"
64 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
65 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
66 AUTOPOINT="${GETTEXTPATH}autopoint"
69 # If you didn't set LIBTOOLPATH, you can also set the variable LIBTOOLIZE.
70 if test -z "${LIBTOOLIZE}" || test -n "${LIBTOOLPATH}"; then
71 LIBTOOLIZE="${LIBTOOLPATH}libtoolize"
75 if test -z "${MAKE}"; then
79 # When using GNU sed, turn off as many GNU extensions as possible,
80 # to minimize the risk of accidentally using non-portable features.
81 # However, do this only for gnulib-tool itself, not for the code that
82 # gnulib-tool generates, since we don't want "sed --posix" to leak
83 # into makefiles. And do it only for sed versions 4.2 or newer,
84 # because "sed --posix" is buggy in GNU sed 4.1.5, see
85 # <http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00225.html>.
86 if (alias) > /dev/null 2>&1 \
87 && echo | sed --posix -e d >/dev/null 2>&1 \
88 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
89 [1-3]* | 4.[01]*) false;; \
93 # Define sed as an alias.
94 # It is not always possible to use aliases. Aliases are guaranteed to work
95 # if the executing shell is bash and either it is invoked as /bin/sh or
96 # is a version >= 2.0, supporting shopt. This is the common case.
97 # Two other approaches (use of a variable $sed or of a function func_sed
98 # instead of an alias) require massive, fragile code changes.
99 # An other approach (use of function sed) requires `which sed` - but
100 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
101 if test -n "$BASH_VERSION"; then
102 shopt -s expand_aliases >/dev/null 2>&1
104 alias sed='sed --posix'
107 # sed_noop is a sed expression that does nothing.
108 # An empty expression does not work with the native 'sed' on AIX 6.1.
111 # sed_comments is true or false, depending whether 'sed' supports comments.
112 # AIX 5.3 sed barfs over indented comments.
113 if echo fo | sed -e 's/f/g/
116 s/o/e/' 2>/dev/null | grep ge > /dev/null; then
123 # outputs to stdout the --help usage message.
127 Usage: gnulib-tool --list
128 gnulib-tool --find filename
129 gnulib-tool --import [module1 ... moduleN]
130 gnulib-tool --add-import [module1 ... moduleN]
131 gnulib-tool --remove-import [module1 ... moduleN]
133 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
134 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
135 gnulib-tool --test --dir=directory module1 ... moduleN
136 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
137 gnulib-tool --extract-description module
138 gnulib-tool --extract-comment module
139 gnulib-tool --extract-status module
140 gnulib-tool --extract-notice module
141 gnulib-tool --extract-applicability module
142 gnulib-tool --extract-filelist module
143 gnulib-tool --extract-dependencies module
144 gnulib-tool --extract-autoconf-snippet module
145 gnulib-tool --extract-automake-snippet module
146 gnulib-tool --extract-include-directive module
147 gnulib-tool --extract-link-directive module
148 gnulib-tool --extract-license module
149 gnulib-tool --extract-maintainer module
150 gnulib-tool --extract-tests-module module
151 gnulib-tool --copy-file file [destination]
154 --list print the available module names
155 --find find the modules which contain the specified file
156 --import import the given modules into the current package
157 --add-import augment the list of imports from gnulib into the
158 current package, by adding the given modules;
159 if no modules are specified, update the current
160 package from the current gnulib
161 --remove-import reduce the list of imports from gnulib into the
162 current package, by removing the given modules
163 --update update the current package, restore files omitted
165 --create-testdir create a scratch package with the given modules
166 --create-megatestdir create a mega scratch package with the given modules
167 one by one and all together
168 --test test the combination of the given modules
169 (recommended to use CC=\"gcc -Wall\" here)
170 --megatest test the given modules one by one and all together
171 (recommended to use CC=\"gcc -Wall\" here)
172 --extract-description extract the description
173 --extract-comment extract the comment
174 --extract-status extract the status (obsolete etc.)
175 --extract-notice extract the notice or banner
176 --extract-applicability extract the applicability
177 --extract-filelist extract the list of files
178 --extract-dependencies extract the dependencies
179 --extract-autoconf-snippet extract the snippet for configure.ac
180 --extract-automake-snippet extract the snippet for library makefile
181 --extract-include-directive extract the #include directive
182 --extract-link-directive extract the linker directive
183 --extract-license report the license terms of the source files
185 --extract-maintainer report the maintainer(s) inside gnulib
186 --extract-tests-module report the unit test module, if it exists
187 --copy-file copy a file that is not part of any module
190 --dir=DIRECTORY Specify the target directory.
191 For --import, this specifies where your
192 configure.ac can be found. Defaults to current
194 --local-dir=DIRECTORY Specify a local override directory where to look
195 up files before looking in gnulib's directory.
196 --cache-modules Enable module caching optimization.
197 --no-cache-modules Disable module caching optimization.
198 --verbose Increase verbosity. May be repeated.
199 --quiet Decrease verbosity. May be repeated.
201 Options for --import, --update:
202 --dry-run Only print what would have been done.
204 Options for --import, --create-[mega]testdir, --[mega]test:
205 --with-tests Include unit tests for the included modules.
206 --with-obsolete Include obsolete modules when they occur among the
207 dependencies. By default, dependencies to obsolete
209 --with-c++-tests Include even unit tests for C++ interoperability.
210 --with-longrunning-tests
211 Include even unit tests that are long-runners.
212 --with-privileged-tests
213 Include even unit tests that require root
215 --with-unportable-tests
216 Include even unit tests that fail on some platforms.
217 --with-all-tests Include all kinds of problematic unit tests.
218 --avoid=MODULE Avoid including the given MODULE. Useful if you
219 have code that provides equivalent functionality.
220 This option can be repeated.
221 --libtool Use libtool rules.
222 --no-libtool Don't use libtool rules.
224 Options for --import:
225 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
226 --source-base=DIRECTORY
227 Directory relative to --dir where source code is
228 placed (default \"lib\").
229 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
230 placed (default \"m4\").
231 --po-base=DIRECTORY Directory relative to --dir where *.po files are
232 placed (default \"po\").
233 --doc-base=DIRECTORY Directory relative to --dir where doc files are
234 placed (default \"doc\").
235 --tests-base=DIRECTORY
236 Directory relative to --dir where unit tests are
237 placed (default \"tests\").
238 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
239 tools are placed (default \"build-aux\").
240 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
241 Also modify license template from GPL to LGPL.
242 The version number of the LGPL can be specified;
243 the default is currently LGPLv3.
244 --makefile-name=NAME Name of makefile in automake syntax in the
245 source-base and tests-base directories
246 (default \"Makefile.am\").
247 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
248 'gl_INIT'. Default is 'gl'.
249 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
250 the package name. A suffix '-gnulib' is appended.
251 --vc-files Update version control related files.
252 --no-vc-files Don't update version control related files
253 (.gitignore and/or .cvsignore).
254 --no-changelog Don't update or create ChangeLog files.
256 Options for --create-[mega]testdir, --[mega]test:
257 --without-c++-tests Exclude unit tests for C++ interoperability.
258 --without-longrunning-tests
259 Exclude unit tests that are long-runners.
260 --without-privileged-tests
261 Exclude unit tests that require root privileges.
262 --without-unportable-tests
263 Exclude unit tests that fail on some platforms.
265 Options for --import, --update, --create-[mega]testdir, --[mega]test:
266 -s, --symbolic, --symlink Make symbolic links instead of copying files.
267 --local-symlink Make symbolic links instead of copying files, only
268 for files from the local override directory.
270 Options for --import, --update:
271 -S, --more-symlinks Make symbolic links instead of copying files, and
272 don't replace copyright notices.
274 Report bugs to <bug-gnulib@gnu.org>."
278 # outputs to stdout the --version message.
282 if test -d "$gnulib_dir"/.git \
283 && (git --version) >/dev/null 2>/dev/null \
284 && (date --version) >/dev/null 2>/dev/null; then
285 # gnulib checked out from git.
286 sed_extract_first_date='/^Date/{
290 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
291 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
292 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
293 date=`echo "$date" | sed -e "$sed_year_before_time"`
294 # Use GNU date to compute the time in GMT.
295 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
296 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
298 if test -d "$gnulib_dir"/CVS \
299 && (cvs --version) >/dev/null 2>/dev/null; then
300 # gnulib checked out from CVS.
301 sed_extract_first_date='/^date: /{
302 s/^date: \([0-9][0-9][0-9][0-9]\).\([0-9][0-9]\).\([0-9][0-9]\) \([0-9][0-9]:[0-9][0-9]:[0-9][0-9]\).*/\1-\2-\3 \4/p
305 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
307 # gnulib copy without versioning information.
308 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
312 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
314 gnulib-tool (GNU $package $date)$version
315 Copyright (C) $year Free Software Foundation, Inc.
316 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
317 This is free software: you are free to change and redistribute it.
318 There is NO WARRANTY, to the extent permitted by law.
320 Written by" "Bruno Haible" "and" "Simon Josefsson"
323 # func_emit_copyright_notice
324 # outputs to stdout a header for a generated file.
325 func_emit_copyright_notice ()
327 sed -n -e '/Copyright/ {
330 }' < "$self_abspathname"
332 echo "# This file is free software, distributed under the terms of the GNU"
333 echo "# General Public License. As a special exception to the GNU General"
334 echo "# Public License, this file may be distributed as part of a program"
335 echo "# that contains a configuration script generated by Autoconf, under"
336 echo "# the same distribution terms as the rest of that program."
338 echo "# Generated by gnulib-tool."
342 # exits with a given status.
343 # This function needs to be used, rather than 'exit', when a 'trap' handler is
344 # in effect that refers to $?.
351 # locates the directory where the gnulib repository lives
353 # - progname name of this program
355 # - self_abspathname absolute pathname of gnulib-tool
356 # - gnulib_dir absolute pathname of gnulib repository
360 /*) self_abspathname="$progname" ;;
361 */*) self_abspathname=`pwd`/"$progname" ;;
364 # Iterate through the elements of $PATH.
365 # We use IFS=: instead of
366 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
367 # because the latter does not work when some PATH element contains spaces.
368 # We use a canonicalized $pathx instead of $PATH, because empty PATH
369 # elements are by definition equivalent to '.', however field splitting
370 # according to IFS=: loses empty fields in many shells:
371 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
372 # beginning, at the end, and in the middle),
373 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
374 # at the beginning and at the end,
375 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
376 # Solaris lose empty fields at the end.
377 # The 'case' statement is an optimization, to avoid evaluating the
378 # explicit canonicalization command when $PATH contains no empty fields.
380 if test "${PATH_SEPARATOR+set}" != set; then
381 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
382 # contains only /bin. Note that ksh looks also at the FPATH variable,
383 # so we have to set that as well for the test.
385 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
386 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
387 || PATH_SEPARATOR=';'
390 if test "$PATH_SEPARATOR" = ";"; then
391 # On Windows, programs are searched in "." before $PATH.
394 # On Unix, we have to convert empty PATH elements to ".".
398 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
403 IFS="$PATH_SEPARATOR"
407 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
408 self_abspathname="$d/$progname"
413 if test -z "$self_abspathname"; then
414 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
418 while test -h "$self_abspathname"; do
419 # Resolve symbolic link.
420 linkval=`func_readlink "$self_abspathname"`
421 test -n "$linkval" || break
423 /* ) self_abspathname="$linkval" ;;
424 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
427 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
431 # creates a temporary directory.
433 # - progname name of this program
435 # - tmp pathname of freshly created temporary directory
438 # Use the environment variable TMPDIR, falling back to /tmp. This allows
439 # users to specify a different temporary directory, for example, if their
440 # /tmp is filled up or too small.
443 # Use the mktemp program if available. If not available, hide the error
445 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
446 test -n "$tmp" && test -d "$tmp"
449 # Use a simple mkdir command. It is guaranteed to fail if the directory
450 # already exists. $RANDOM is bash specific and expands to empty in shells
451 # other than bash, ksh and zsh. Its use does not increase security;
452 # rather, it minimizes the probability of failure in a very cluttered /tmp
454 tmp=$TMPDIR/gl$$-$RANDOM
455 (umask 077 && mkdir "$tmp")
458 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
463 # func_append var value
464 # appends the given value to the shell variable var.
465 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
466 # Use bash's += operator. It reduces complexity of appending repeatedly to
467 # a single variable from O(n^2) to O(n).
472 fast_func_append=true
476 eval "$1=\"\$$1\$2\""
478 fast_func_append=false
481 # func_remove_prefix var prefix
482 # removes the given prefix from the value of the shell variable var.
483 # var should be the name of a shell variable.
484 # Its value should not contain a newline and not start or end with whitespace.
485 # prefix should not contain the characters "$`\{}[]^|.
486 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
487 func_remove_prefix ()
491 fast_func_remove_prefix=true
493 func_remove_prefix ()
495 eval "value=\"\$$1\""
499 sed_escape_dots='s/\([.]\)/\\\1/g'
500 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
503 value=`echo "$value" | sed -e "s|^${prefix}||"`
504 eval "$1=\"\$value\""
506 fast_func_remove_prefix=false
509 # func_remove_suffix var suffix
510 # removes the given suffix from the value of the shell variable var.
511 # var should be the name of a shell variable.
512 # Its value should not contain a newline and not start or end with whitespace.
513 # suffix should not contain the characters "$`\{}[]^|.
514 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
515 func_remove_suffix ()
519 fast_func_remove_suffix=true
521 func_remove_suffix ()
523 eval "value=\"\$$1\""
527 sed_escape_dots='s/\([.]\)/\\\1/g'
528 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
531 value=`echo "$value" | sed -e "s|${suffix}\$||"`
532 eval "$1=\"\$value\""
534 fast_func_remove_suffix=false
537 # func_fatal_error message
538 # outputs to stderr a fatal error message, and terminates the program.
540 # - progname name of this program
543 echo "$progname: *** $1" 1>&2
544 echo "$progname: *** Stop." 1>&2
548 # func_warning message
549 # Outputs to stderr a warning message,
552 echo "gnulib-tool: warning: $1" 1>&2
555 # func_readlink SYMLINK
556 # outputs the target of the given symlink.
557 if (type -p readlink) > /dev/null 2>&1; then
560 # Use the readlink program from GNU coreutils.
566 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
567 # would do the wrong thing if the link target contains " -> ".
568 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
572 # func_relativize DIR1 DIR2
573 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
575 # - DIR1 relative pathname, relative to the current directory
576 # - DIR2 relative pathname, relative to the current directory
578 # - reldir relative pathname of DIR2, relative to DIR1
584 sed_first='s,^\([^/]*\)/.*$,\1,'
585 sed_rest='s,^[^/]*/*,,'
586 sed_last='s,^.*/\([^/]*\)$,\1,'
587 sed_butlast='s,/*[^/]*$,,'
588 while test -n "$dir1"; do
589 first=`echo "$dir1" | sed -e "$sed_first"`
590 if test "$first" != "."; then
591 if test "$first" = ".."; then
592 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
593 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
595 first2=`echo "$dir2" | sed -e "$sed_first"`
596 if test "$first2" = "$first"; then
597 dir2=`echo "$dir2" | sed -e "$sed_rest"`
601 dir0="$dir0"/"$first"
604 dir1=`echo "$dir1" | sed -e "$sed_rest"`
609 # func_relconcat DIR1 DIR2
610 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
612 # - DIR1 relative pathname, relative to the current directory
613 # - DIR2 relative pathname, relative to DIR1
615 # - relconcat DIR1/DIR2, relative to the current directory
620 sed_first='s,^\([^/]*\)/.*$,\1,'
621 sed_rest='s,^[^/]*/*,,'
622 sed_last='s,^.*/\([^/]*\)$,\1,'
623 sed_butlast='s,/*[^/]*$,,'
625 first=`echo "$dir2" | sed -e "$sed_first"`
626 if test "$first" = "."; then
627 dir2=`echo "$dir2" | sed -e "$sed_rest"`
628 if test -z "$dir2"; then
633 last=`echo "$dir1" | sed -e "$sed_last"`
634 while test "$last" = "."; do
635 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
636 last=`echo "$dir1" | sed -e "$sed_last"`
638 if test -z "$dir1"; then
642 if test "$first" = ".."; then
643 if test "$last" = ".."; then
644 relconcat="$dir1/$dir2"
647 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
648 dir2=`echo "$dir2" | sed -e "$sed_rest"`
649 if test -z "$dir1"; then
653 if test -z "$dir2"; then
658 relconcat="$dir1/$dir2"
666 # Like ln -s, except that SRC is given relative to the current directory (or
667 # absolute), not given relative to the directory of DEST.
673 *) # SRC is relative.
676 ln -s "`pwd`/$1" "$2" ;;
677 *) # DEST is relative too.
678 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
679 test -n "$ln_destdir" || ln_destdir="."
680 func_relativize "$ln_destdir" "$1"
688 # func_ln_if_changed SRC DEST
689 # Like func_ln, but avoids munging timestamps if the link is correct.
690 func_ln_if_changed ()
692 if test $# -ne 2; then
693 echo "usage: func_ln_if_changed SRC DEST" >&2
695 ln_target=`func_readlink "$2"`
696 if test -h "$2" && test "$1" = "$ln_target"; then
704 # Ensure an 'echo' command that
705 # 1. does not interpret backslashes and
706 # 2. does not print an error message "broken pipe" when writing into a pipe
709 # Test cases for problem 1:
710 # echo '\n' | wc -l prints 1 when OK, 2 when KO
711 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
712 # Test cases for problem 2:
713 # echo hi | true frequently prints
714 # "bash: echo: write error: Broken pipe"
715 # to standard error in bash 3.2.
717 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
718 # BSD echo interprets '-n' as an option, which is also not desirable).
719 # Nowadays the problem occurs in 4 situations:
720 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
721 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
722 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
723 # - in zsh, when sh-emulation is not set,
724 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
725 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
726 # - in Solaris /bin/sh and OSF/1 /bin/sh.
727 # We try the following workarounds:
728 # - for all: respawn using $CONFIG_SHELL if that is set and works.
729 # - for bash >= 2.04: unset the shell option xpg_echo.
730 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
731 # - for bash < 2.0: define echo to a function that uses cat of a here document.
732 # - for zsh: turn sh-emulation on.
733 # - for ksh: alias echo to 'print -r'.
734 # - for ksh: alias echo to a function that uses cat of a here document.
735 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
736 # the ksh workaround.
737 # - otherwise: respawn using /bin/sh and rely on the workarounds.
738 # When respawning, we pass --no-reexec as first argument, so as to avoid
739 # turning this script into a fork bomb in unlucky situations.
741 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
742 # the 'printf' built-in. See
743 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
744 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
745 # The workaround is: define echo to a function that uses the printf built-in.
747 if echo '\t' | grep t > /dev/null; then
748 have_echo=yes # Lucky!
750 # Try the workarounds.
751 # Respawn using $CONFIG_SHELL if that is set and works.
752 if test -z "$have_echo" \
753 && test "X$1" != "X--no-reexec" \
754 && test -n "$CONFIG_SHELL" \
755 && test -f "$CONFIG_SHELL" \
756 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
757 exec $CONFIG_SHELL "$0" --no-reexec "$@"
760 # For bash >= 2.04: unset the shell option xpg_echo.
761 if test -z "$have_echo" \
762 && test -n "$BASH_VERSION" \
763 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
767 # For bash >= 2.0: define echo to a function that uses the printf built-in.
768 # For bash < 2.0: define echo to a function that uses cat of a here document.
769 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
770 # Also handle problem 2, specific to bash 3.2, here.
771 if { test -z "$have_echo" \
772 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
774 && test -n "$BASH_VERSION"; then \
775 if type printf 2>/dev/null | grep / > /dev/null; then
776 # 'printf' is not a shell built-in.
784 # 'printf' is a shell built-in.
790 if echo '\t' | grep t > /dev/null; then
794 # For zsh: turn sh-emulation on.
795 if test -z "$have_echo" \
796 && test -n "$ZSH_VERSION" \
797 && (emulate sh) >/dev/null 2>&1; then
800 # For ksh: alias echo to 'print -r'.
801 if test -z "$have_echo" \
802 && (type print) >/dev/null 2>&1; then
803 # A 'print' command exists.
804 if type print 2>/dev/null | grep / > /dev/null; then
807 # 'print' is a shell built-in.
808 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
809 # 'print' is the ksh shell built-in.
810 alias echo='print -r'
814 if test -z "$have_echo" \
815 && echo '\t' | grep t > /dev/null; then
818 # For ksh: alias echo to a function that uses cat of a here document.
819 # The ksh manual page says:
820 # "Aliasing is performed when scripts are read, not while they are executed.
821 # Therefore, for an alias to take effect, the alias definition command has
822 # to be executed before the command which references the alias is read."
823 # Because of this, we have to play strange tricks with have_echo, to ensure
824 # that the top-level statement containing the test starts after the 'alias'
826 if test -z "$have_echo"; then
833 alias echo=bsd_echo 2>/dev/null
835 if test -z "$have_echo" \
836 && echo '\t' | grep t > /dev/null; then
839 if test -z "$have_echo"; then
840 unalias echo 2>/dev/null
842 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
843 if test -z "$have_echo" \
844 && test "X$1" != "X--no-reexec" \
845 && test -f /bin/ksh; then
846 exec /bin/ksh "$0" --no-reexec "$@"
849 # Otherwise: respawn using /bin/sh.
850 if test -z "$have_echo" \
851 && test "X$1" != "X--no-reexec" \
852 && test -f /bin/sh; then
853 exec /bin/sh "$0" --no-reexec "$@"
856 if test -z "$have_echo"; then
857 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
859 if echo '\t' | grep t > /dev/null; then
862 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
864 if test "X$1" = "X--no-reexec"; then
868 # Command-line option processing.
869 # Removes the OPTIONS from the arguments. Sets the variables:
870 # - mode list or import or add-import or remove-import or update
871 # or create-testdir or create-megatestdir
872 # - destdir from --dir
873 # - local_gnulib_dir from --local-dir
874 # - modcache true or false, from --cache-modules/--no-cache-modules
875 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
876 # - libname, supplied_libname from --lib
877 # - sourcebase from --source-base
878 # - m4base from --m4-base
879 # - pobase from --po-base
880 # - docbase from --doc-base
881 # - testsbase from --tests-base
882 # - auxdir from --aux-dir
883 # - inctests true if --with-tests was given, blank otherwise
884 # - incobsolete true if --with-obsolete was given, blank otherwise
885 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
886 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
888 # - inc_privileged_tests true if --with-privileged-tests was given, blank
890 # - inc_unportable_tests true if --with-unportable-tests was given, blank
892 # - inc_all_tests true if --with-all-tests was given, blank otherwise
893 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
894 # - excl_longrunning_tests true if --without-longrunning-tests was given,
896 # - excl_privileged_tests true if --without-privileged-tests was given, blank
898 # - excl_unportable_tests true if --without-unportable-tests was given, blank
900 # - avoidlist list of modules to avoid, from --avoid
901 # - lgpl yes or a number if --lgpl was given, blank otherwise
902 # - makefile_name from --makefile-name
903 # - libtool true if --libtool was given, false if --no-libtool was
904 # given, blank otherwise
905 # - macro_prefix from --macro-prefix
906 # - po_domain from --po-domain
907 # - vc_files true if --vc-files was given, false if --no-vc-files was
908 # given, blank otherwise
909 # - autoconf_minversion minimum supported autoconf version
910 # - do_changelog false if --no-changelog was given, : otherwise
911 # - doit : if actions shall be executed, false if only to be printed
912 # - symbolic true if --symlink or --more-symlinks was given, blank
914 # - lsymbolic true if --local-symlink was given, blank otherwise
915 # - do_copyrights blank if --more-symlinks was given, true otherwise
933 inc_longrunning_tests=
934 inc_privileged_tests=
935 inc_unportable_tests=
938 excl_longrunning_tests=
939 excl_privileged_tests=
940 excl_unportable_tests=
956 while test $# -gt 0; do
961 --find | --fin | --fi | --f )
964 --import | --impor | --impo | --imp | --im | --i )
967 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
970 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
973 --update | --updat | --upda | --upd | --up | --u )
976 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
979 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
980 mode=create-megatestdir
982 --test | --tes | --te | --t )
985 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
989 mode=`echo "X$1" | sed -e 's/^X--//'`
991 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop | --co )
997 func_fatal_error "missing argument for --dir"
1002 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1006 if test $# = 0; then
1007 func_fatal_error "missing argument for --local-dir"
1012 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1014 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1017 --no-cache-modules | --no-cache-module | --no-cache-modul | --no-cache-modu | --no-cache-mod | --no-cache-mo | --no-cache-m | --no-cache- | --no-cache | --no-cach | --no-cac | --no-ca )
1020 --verbose | --verbos | --verbo | --verb )
1021 verbose=`expr $verbose + 1`
1023 --quiet | --quie | --qui | --qu | --q )
1024 verbose=`expr $verbose - 1`
1028 if test $# = 0; then
1029 func_fatal_error "missing argument for --lib"
1032 supplied_libname=true
1035 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1036 supplied_libname=true
1040 if test $# = 0; then
1041 func_fatal_error "missing argument for --source-base"
1046 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1050 if test $# = 0; then
1051 func_fatal_error "missing argument for --m4-base"
1056 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1060 if test $# = 0; then
1061 func_fatal_error "missing argument for --po-base"
1066 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1070 if test $# = 0; then
1071 func_fatal_error "missing argument for --doc-base"
1076 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1080 if test $# = 0; then
1081 func_fatal_error "missing argument for --tests-base"
1086 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1090 if test $# = 0; then
1091 func_fatal_error "missing argument for --aux-dir"
1096 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1098 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1101 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1104 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1107 --with-longrunning-tests | --with-longrunning-test | --with-longrunning-tes | --with-longrunning-te | --with-longrunning-t | --with-longrunning- | --with-longrunning | --with-longrunnin | --with-longrunni | --with-longrunn | --with-longrun | --with-longru | --with-longr | --with-long | --with-lon | --with-lo | --with-l)
1108 inc_longrunning_tests=true
1110 --with-privileged-tests | --with-privileged-test | --with-privileged-tes | --with-privileged-te | --with-privileged-t | --with-privileged- | --with-privileged | --with-privilege | --with-privileg | --with-privile | --with-privil | --with-privi | --with-priv | --with-pri | --with-pr | --with-p)
1111 inc_privileged_tests=true
1113 --with-unportable-tests | --with-unportable-test | --with-unportable-tes | --with-unportable-te | --with-unportable-t | --with-unportable- | --with-unportable | --with-unportabl | --with-unportab | --with-unporta | --with-unport | --with-unpor | --with-unpo | --with-unp | --with-un | --with-u)
1114 inc_unportable_tests=true
1116 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1119 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1122 --without-longrunning-tests | --without-longrunning-test | --without-longrunning-tes | --without-longrunning-te | --without-longrunning-t | --without-longrunning- | --without-longrunning | --without-longrunnin | --without-longrunni | --without-longrunn | --without-longrun | --without-longru | --without-longr | --without-long | --without-lon | --without-lo | --without-l)
1123 excl_longrunning_tests=true
1125 --without-privileged-tests | --without-privileged-test | --without-privileged-tes | --without-privileged-te | --without-privileged-t | --without-privileged- | --without-privileged | --without-privilege | --without-privileg | --without-privile | --without-privil | --without-privi | --without-priv | --without-pri | --without-pr | --without-p)
1126 excl_privileged_tests=true
1128 --without-unportable-tests | --without-unportable-test | --without-unportable-tes | --without-unportable-te | --without-unportable-t | --without-unportable- | --without-unportable | --without-unportabl | --without-unportab | --without-unporta | --without-unport | --without-unpor | --without-unpo | --without-unp | --without-un | --without-u)
1129 excl_unportable_tests=true
1133 if test $# = 0; then
1134 func_fatal_error "missing argument for --avoid"
1136 func_append avoidlist " $1"
1139 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1140 func_append avoidlist " $arg"
1146 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1149 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1155 if test $# = 0; then
1156 func_fatal_error "missing argument for --makefile-name"
1161 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1171 if test $# = 0; then
1172 func_fatal_error "missing argument for --macro-prefix"
1177 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1181 if test $# = 0; then
1182 func_fatal_error "missing argument for --po-domain"
1187 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1195 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1201 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1204 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1207 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1211 --help | --hel | --he | --h )
1214 --version | --versio | --versi | --vers )
1218 # Stop option processing
1222 echo "gnulib-tool: unknown option $1" 1>&2
1223 echo "Try 'gnulib-tool --help' for more information." 1>&2
1230 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1231 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1232 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests"; then
1233 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1234 echo "Try 'gnulib-tool --help' for more information." 1>&2
1238 if test "$mode" = update; then
1239 if test $# != 0; then
1240 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1241 echo "Try 'gnulib-tool --help' for more information." 1>&2
1242 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1243 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1246 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1247 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1248 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1249 || test -n "$inctests" || test -n "$incobsolete" \
1250 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1251 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1252 || test -n "$inc_all_tests" \
1253 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1254 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1255 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1256 || test -n "$macro_prefix" || test -n "$po_domain" \
1257 || test -n "$vc_files"; then
1258 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1259 echo "Try 'gnulib-tool --help' for more information." 1>&2
1260 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1261 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1266 if test -n "$pobase" && test -z "$po_domain"; then
1267 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1268 echo "Try 'gnulib-tool --help' for more information." 1>&2
1271 if test -z "$pobase" && test -n "$po_domain"; then
1272 func_warning "--po-domain has no effect without a --po-base option"
1275 # Determine the minimum supported autoconf version from the project's
1277 DEFAULT_AUTOCONF_MINVERSION="2.59"
1278 autoconf_minversion=
1280 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1281 && test -n "$destdir"; then
1282 if test -f "$destdir"/configure.ac; then
1283 configure_ac="$destdir/configure.ac"
1285 if test -f "$destdir"/configure.in; then
1286 configure_ac="$destdir/configure.in"
1290 if test -f configure.ac; then
1291 configure_ac="configure.ac"
1293 if test -f configure.in; then
1294 configure_ac="configure.in"
1298 if test -n "$configure_ac"; then
1299 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1300 # because when some m4 files are omitted from a version control repository,
1301 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1302 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1303 # autom4te: m4 failed with exit status: 1
1310 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1312 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1313 if test -n "$prereqs"; then
1314 autoconf_minversion=`
1315 for version in $prereqs; do echo $version; done |
1316 LC_ALL=C sort -nru | sed -e 1q
1320 if test -z "$autoconf_minversion"; then
1321 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1323 case "$autoconf_minversion" in
1324 1.* | 2.[0-4]* | 2.5[0-8]*)
1325 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1328 # Remove trailing slashes from the directory names. This is necessary for
1329 # m4base (to avoid an error in func_import) and optional for the others.
1330 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1331 case "$local_gnulib_dir" in
1332 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1334 case "$sourcebase" in
1335 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1338 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1341 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1344 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1346 case "$testsbase" in
1347 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1350 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1356 trap 'exit_status=$?
1357 if test "$signal" != 0; then
1358 echo "caught signal $signal" >&2
1361 exit $exit_status' 0
1362 for signal in 1 2 3 13 15; do
1363 trap '{ signal='$signal'; func_exit 1; }' $signal
1367 # Note: The 'eval' silences stderr output in dash.
1368 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1369 # Zsh 4 and Bash 4 have associative arrays.
1370 have_associative=true
1372 # For other shells, use 'eval' with computed shell variable names.
1373 have_associative=false
1376 # func_lookup_file file
1377 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1380 # - local_gnulib_dir from --local-dir
1382 # - lookedup_file name of the merged (combined) file
1383 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1387 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1388 lookedup_file="$local_gnulib_dir/$lkfile"
1391 if test -f "$gnulib_dir/$lkfile"; then
1392 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1393 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1394 rm -f "$tmp/$lkbase"
1395 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1396 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1397 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1398 lookedup_file="$tmp/$lkbase"
1401 lookedup_file="$gnulib_dir/$lkfile"
1405 func_fatal_error "file $gnulib_dir/$lkfile not found"
1410 # func_sanitize_modulelist
1411 # receives a list of possible module names on standard input, one per line.
1412 # It removes those which are just file names unrelated to modules, and outputs
1413 # the resulting list to standard output, one per line.
1414 func_sanitize_modulelist ()
1416 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1417 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1418 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1419 -e '/^README$/d' -e '/\/README$/d' \
1420 -e '/^TEMPLATE$/d' \
1421 -e '/^TEMPLATE-EXTENDED$/d' \
1422 -e '/^TEMPLATE-TESTS$/d' \
1429 # - local_gnulib_dir from --local-dir
1432 # Filter out metainformation files like README, which are not modules.
1433 # Filter out unit test modules; they can be retrieved through
1434 # --extract-tests-module if desired.
1436 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1437 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1438 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1441 | func_sanitize_modulelist \
1442 | sed -e '/-tests$/d' \
1446 # func_exists_module module
1447 # tests whether a module, given by name, exists
1449 # - local_gnulib_dir from --local-dir
1450 func_exists_module ()
1452 { test -f "$gnulib_dir/modules/$1" \
1453 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1454 && test -f "$local_gnulib_dir/modules/$1"; }; } \
1455 && test "CVS" != "$1" \
1456 && test "ChangeLog" != "$1" \
1457 && test "COPYING" != "$1" \
1458 && test "README" != "$1" \
1459 && test "TEMPLATE" != "$1" \
1460 && test "TEMPLATE-EXTENDED" != "$1" \
1461 && test "TEMPLATE-TESTS" != "$1"
1464 # func_verify_module
1465 # verifies a module name
1467 # - local_gnulib_dir from --local-dir
1468 # - module module name argument
1469 func_verify_module ()
1471 if func_exists_module "$module"; then
1472 # OK, $module is a correct module name.
1473 # Verify that building the module description with 'patch' succeeds.
1474 func_lookup_file "modules/$module"
1476 func_warning "module $module doesn't exist"
1481 # func_verify_nontests_module
1482 # verifies a module name, excluding tests modules
1484 # - local_gnulib_dir from --local-dir
1485 # - module module name argument
1486 func_verify_nontests_module ()
1489 *-tests ) module= ;;
1490 * ) func_verify_module ;;
1494 # func_verify_tests_module
1495 # verifies a module name, considering only tests modules
1497 # - local_gnulib_dir from --local-dir
1498 # - module module name argument
1499 func_verify_tests_module ()
1502 *-tests ) func_verify_module ;;
1507 # Suffix of a sed expression that extracts a particular field from a
1508 # module description.
1509 # A field starts with a line that contains a keyword, such as 'Description',
1510 # followed by a colon and optional whitespace. All following lines, up to
1511 # the next field (or end of file if there is none) form the contents of the
1513 # An absent field is equivalent to a field with empty contents.
1514 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1515 sed_extract_prog=':[ ]*$/ {
1518 s/^Description:[ ]*$//
1522 s/^Applicability:[ ]*$//
1524 s/^Depends-on:[ ]*$//
1525 s/^configure\.ac-early:[ ]*$//
1526 s/^configure\.ac:[ ]*$//
1527 s/^Makefile\.am:[ ]*$//
1531 s/^Maintainer:[ ]*$//
1538 # Piece of a sed expression that converts a field header line to a shell
1540 # NOTE: Keep this in sync with sed_extract_prog above!
1541 sed_extract_field_header='
1542 s/^Description:[ ]*$/description/
1543 s/^Comment:[ ]*$/comment/
1544 s/^Status:[ ]*$/status/
1545 s/^Notice:[ ]*$/notice/
1546 s/^Applicability:[ ]*$/applicability/
1547 s/^Files:[ ]*$/files/
1548 s/^Depends-on:[ ]*$/dependson/
1549 s/^configure\.ac-early:[ ]*$/configureac_early/
1550 s/^configure\.ac:[ ]*$/configureac/
1551 s/^Makefile\.am:[ ]*$/makefile/
1552 s/^Include:[ ]*$/include/
1554 s/^License:[ ]*$/license/
1555 s/^Maintainer:[ ]*$/maintainer/'
1559 if $have_associative; then
1561 # Declare the associative arrays.
1562 declare -A modcache_cached
1563 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1564 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1565 eval "$declare_script"
1569 # func_cache_var module
1570 # computes the cache variable name corresponding to $module.
1571 # Note: This computation can map different module names to the same
1572 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1573 # to protect against this case.
1575 # - cachevar a shell variable name
1576 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1577 # Bash 2.0 and newer, ksh, and zsh support the syntax
1578 # ${param//pattern/replacement}
1579 # as a shorthand for
1580 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1581 # Note: The 'eval' above silences stderr output in dash.
1584 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1591 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1600 # func_init_sed_convert_to_cache_statements
1602 # - modcachevar_assignment
1604 # - sed_convert_to_cache_statements
1605 func_init_sed_convert_to_cache_statements ()
1607 # 'sed' script that turns a module description into shell script
1608 # assignments, suitable to be eval'ed. All active characters are escaped.
1611 # Some module's description
1616 # modcache_description[$1]=\
1617 # 'Some module'"'"'s description
1619 # modcache_files[$1]=\
1622 # c_MODULE_description_set=set; c_MODULE_description=\
1623 # 'Some module'"'"'s description
1625 # c_MODULE_files_set=set; c_MODULE_files=\
1627 # The script consists of two parts:
1628 # 1) Ignore the lines before the first field header.
1629 # 2) A loop, treating non-field-header lines by escaping single quotes
1630 # and adding a closing quote in the last line,
1631 sed_convert_to_cache_statements="
1633 # Here we have not yet seen a field header.
1635 # See if the current line contains a field header.
1638 ${sed_extract_field_header}
1641 # No field header. Ignore the line.
1643 # Read the next line. Upon EOF, just exit.
1648 # The current line contains a field header.
1650 # Turn it into the beginning of an assignment.
1651 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1653 # Move it to the hold space. Don't print it yet,
1654 # because we want no assignment if the field is empty.
1657 # Read the next line.
1658 # Upon EOF, the field was empty. Print no assignment. Just exit.
1661 # See if the current line contains a field header.
1664 ${sed_extract_field_header}
1665 # If it is, the previous field was empty. Print no assignment.
1668 # Not a field header.
1670 # Print the previous line, held in the hold space.
1675 # Transform single quotes.
1678 # Prepend a single quote.
1683 # Move it to the hold space.
1686 # Read the next line.
1693 # See if the current line contains a field header.
1696 ${sed_extract_field_header}
1699 # Print the previous line, held in the hold space.
1704 # Transform single quotes.
1711 # Print the previous line, held in the hold space, with a single quote
1712 # to end the assignment.
1722 # Print the previous line, held in the hold space, with a single quote
1723 # to end the assignment.
1730 if ! $sed_comments; then
1732 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1733 | sed -e 's/^ *//' -e 's/^#.*//'`
1737 if $have_associative; then
1738 # sed_convert_to_cache_statements does not depend on the module.
1739 modcachevar_assignment='modcache_\1[$1]='
1740 func_init_sed_convert_to_cache_statements
1743 # func_cache_lookup_module module
1745 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1746 # of its relevant data in a cache in the memory of the processing shell. If
1747 # already cached, it does not look it up again, thus saving file access time.
1749 # - module non-empty string
1750 # Output if $have_associative:
1751 # - modcache_cached[$module] set to yes
1752 # - modcache_description[$module] ==
1753 # - modcache_status[$module] \ set to the field's value, minus the
1754 # - ... / final newline,
1755 # - modcache_maintainer[$module] == or unset if the field's value is empty
1756 # Output if ! $have_associative:
1757 # - cachevar a shell variable name
1758 # - ${cachevar}_cached set to $module
1759 # - ${cachevar}_description ==
1760 # - ${cachevar}_status \ set to the field's value, minus the
1761 # - ... / final newline,
1762 # - ${cachevar}_maintainer == or unset if the field's value is empty
1763 # - ${cachevar}_description_set ==
1764 # - ${cachevar}_status_set \ set to non-empty if the field's value
1765 # - ... / is non-empty,
1766 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1767 func_cache_lookup_module ()
1769 if $have_associative; then
1770 cached=${modcache_cached[$1]}
1773 eval "cached=\"\$${cachevar}_cached\""
1775 if test -z "$cached"; then
1776 # Not found in cache. Look it up on the file system.
1777 func_lookup_file "modules/$1"
1778 if $have_associative; then
1779 modcache_cached[$1]=yes
1781 eval "${cachevar}_cached=\"\$1\""
1783 if ! $have_associative; then
1784 # sed_convert_to_cache_statements depends on the module.
1785 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1786 func_init_sed_convert_to_cache_statements
1788 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1789 eval "$cache_statements"
1791 if ! $have_associative; then
1792 if test "$1" != "$cached"; then
1793 func_fatal_error "cache variable collision between $1 and $cached"
1801 # func_get_description module
1803 # - local_gnulib_dir from --local-dir
1804 # - modcache true or false, from --cache-modules/--no-cache-modules
1805 func_get_description ()
1807 if ! $modcache; then
1808 func_lookup_file "modules/$1"
1809 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1811 func_cache_lookup_module "$1"
1812 # Output the field's value, including the final newline (if any).
1813 if $have_associative; then
1814 if test -n "${modcache_description[$1]+set}"; then
1815 echo "${modcache_description[$1]}"
1818 eval "field_set=\"\$${cachevar}_description_set\""
1819 if test -n "$field_set"; then
1820 eval "field_value=\"\$${cachevar}_description\""
1821 echo "${field_value}"
1827 # func_get_comment module
1829 # - local_gnulib_dir from --local-dir
1830 # - modcache true or false, from --cache-modules/--no-cache-modules
1833 if ! $modcache; then
1834 func_lookup_file "modules/$1"
1835 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
1837 func_cache_lookup_module "$1"
1838 # Output the field's value, including the final newline (if any).
1839 if $have_associative; then
1840 if test -n "${modcache_comment[$1]+set}"; then
1841 echo "${modcache_comment[$1]}"
1844 eval "field_set=\"\$${cachevar}_comment_set\""
1845 if test -n "$field_set"; then
1846 eval "field_value=\"\$${cachevar}_comment\""
1847 echo "${field_value}"
1853 # func_get_status module
1855 # - local_gnulib_dir from --local-dir
1856 # - modcache true or false, from --cache-modules/--no-cache-modules
1859 if ! $modcache; then
1860 func_lookup_file "modules/$1"
1861 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1863 func_cache_lookup_module "$1"
1864 # Output the field's value, including the final newline (if any).
1865 if $have_associative; then
1866 if test -n "${modcache_status[$1]+set}"; then
1867 echo "${modcache_status[$1]}"
1870 eval "field_set=\"\$${cachevar}_status_set\""
1871 if test -n "$field_set"; then
1872 eval "field_value=\"\$${cachevar}_status\""
1873 echo "${field_value}"
1879 # func_get_notice module
1881 # - local_gnulib_dir from --local-dir
1882 # - modcache true or false, from --cache-modules/--no-cache-modules
1885 if ! $modcache; then
1886 func_lookup_file "modules/$1"
1887 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1889 func_cache_lookup_module "$1"
1890 # Output the field's value, including the final newline (if any).
1891 if $have_associative; then
1892 if test -n "${modcache_notice[$1]+set}"; then
1893 echo "${modcache_notice[$1]}"
1896 eval "field_set=\"\$${cachevar}_notice_set\""
1897 if test -n "$field_set"; then
1898 eval "field_value=\"\$${cachevar}_notice\""
1899 echo "${field_value}"
1905 # func_get_applicability module
1907 # - local_gnulib_dir from --local-dir
1908 # - modcache true or false, from --cache-modules/--no-cache-modules
1909 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1910 func_get_applicability ()
1912 if ! $modcache; then
1913 func_lookup_file "modules/$1"
1914 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1916 func_cache_lookup_module "$1"
1917 # Get the field's value, without the final newline.
1918 if $have_associative; then
1919 my_applicability="${modcache_applicability[$1]}"
1921 eval "my_applicability=\"\$${cachevar}_applicability\""
1924 if test -n "$my_applicability"; then
1925 echo $my_applicability
1927 # The default is 'main' or 'tests', depending on the module's name.
1929 *-tests) echo "tests";;
1935 # func_get_filelist module
1937 # - local_gnulib_dir from --local-dir
1938 # - modcache true or false, from --cache-modules/--no-cache-modules
1939 func_get_filelist ()
1941 if ! $modcache; then
1942 func_lookup_file "modules/$1"
1943 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1945 func_cache_lookup_module "$1"
1946 # Output the field's value, including the final newline (if any).
1947 if $have_associative; then
1948 if test -n "${modcache_files[$1]+set}"; then
1949 echo "${modcache_files[$1]}"
1952 eval "field_set=\"\$${cachevar}_files_set\""
1953 if test -n "$field_set"; then
1954 eval "field_value=\"\$${cachevar}_files\""
1955 echo "${field_value}"
1960 echo m4/gnulib-common.m4
1961 case "$autoconf_minversion" in
1968 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
1969 # stores in outputvar the filtered and processed filelist. Filtering: Only the
1970 # elements starting with prefix and ending with suffix are considered.
1971 # Processing: removed_prefix and removed_suffix are removed from each element,
1972 # added_prefix and added_suffix are added to each element.
1973 # prefix, suffix should not contain shell-special characters.
1974 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
1975 # added_prefix, added_suffix should not contain the characters \|&.
1976 func_filter_filelist ()
1978 if test "$2" != "$nl" \
1979 || { $fast_func_append \
1980 && { test -z "$6" || $fast_func_remove_prefix; } \
1981 && { test -z "$7" || $fast_func_remove_suffix; }; \
1985 # Do not quote possibly-empty parameters in case patterns,
1986 # AIX and HP-UX ksh won't match them if they are empty.
1989 if test -n "$6"; then
1990 func_remove_prefix fff "$6"
1992 if test -n "$7"; then
1993 func_remove_suffix fff "$7"
1996 if test -z "$ffflist"; then
1999 func_append ffflist "$2${fff}"
2005 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2006 ffflist=`for fff in $3; do
2008 $4*$5) echo "$fff" ;;
2010 done | sed -e "$sed_fff_filter"`
2012 eval "$1=\"\$ffflist\""
2015 # func_get_dependencies module
2017 # - local_gnulib_dir from --local-dir
2018 # - modcache true or false, from --cache-modules/--no-cache-modules
2019 func_get_dependencies ()
2021 # ${module}-tests implicitly depends on ${module}, if that module exists.
2025 func_remove_suffix fgd1 '-tests'
2026 if func_exists_module "$fgd1"; then
2031 # Then the explicit dependencies listed in the module description.
2032 if ! $modcache; then
2033 func_lookup_file "modules/$1"
2034 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2036 func_cache_lookup_module "$1"
2037 # Output the field's value, including the final newline (if any).
2038 if $have_associative; then
2039 if test -n "${modcache_dependson[$1]+set}"; then
2040 echo "${modcache_dependson[$1]}"
2043 eval "field_set=\"\$${cachevar}_dependson_set\""
2044 if test -n "$field_set"; then
2045 eval "field_value=\"\$${cachevar}_dependson\""
2046 echo "${field_value}"
2052 # func_get_autoconf_early_snippet module
2054 # - local_gnulib_dir from --local-dir
2055 # - modcache true or false, from --cache-modules/--no-cache-modules
2056 func_get_autoconf_early_snippet ()
2058 if ! $modcache; then
2059 func_lookup_file "modules/$1"
2060 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2062 func_cache_lookup_module "$1"
2063 # Output the field's value, including the final newline (if any).
2064 if $have_associative; then
2065 if test -n "${modcache_configureac_early[$1]+set}"; then
2066 echo "${modcache_configureac_early[$1]}"
2069 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2070 if test -n "$field_set"; then
2071 eval "field_value=\"\$${cachevar}_configureac_early\""
2072 echo "${field_value}"
2078 # func_get_autoconf_snippet module
2080 # - local_gnulib_dir from --local-dir
2081 # - modcache true or false, from --cache-modules/--no-cache-modules
2082 func_get_autoconf_snippet ()
2084 if ! $modcache; then
2085 func_lookup_file "modules/$1"
2086 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2088 func_cache_lookup_module "$1"
2089 # Output the field's value, including the final newline (if any).
2090 if $have_associative; then
2091 if test -n "${modcache_configureac[$1]+set}"; then
2092 echo "${modcache_configureac[$1]}"
2095 eval "field_set=\"\$${cachevar}_configureac_set\""
2096 if test -n "$field_set"; then
2097 eval "field_value=\"\$${cachevar}_configureac\""
2098 echo "${field_value}"
2104 # func_get_automake_snippet module
2106 # - local_gnulib_dir from --local-dir
2107 # - modcache true or false, from --cache-modules/--no-cache-modules
2108 func_get_automake_snippet ()
2110 if ! $modcache; then
2111 func_lookup_file "modules/$1"
2112 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2114 func_cache_lookup_module "$1"
2115 # Output the field's value, including the final newline (if any).
2116 if $have_associative; then
2117 if test -n "${modcache_makefile[$1]+set}"; then
2118 echo "${modcache_makefile[$1]}"
2121 eval "field_set=\"\$${cachevar}_makefile_set\""
2122 if test -n "$field_set"; then
2123 eval "field_value=\"\$${cachevar}_makefile\""
2124 echo "${field_value}"
2130 # *-tests module live in tests/, not lib/.
2131 # Synthesize an EXTRA_DIST augmentation.
2132 all_files=`func_get_filelist $1`
2133 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2134 extra_files="$tests_files"
2135 if test -n "$extra_files"; then
2136 echo "EXTRA_DIST +=" $extra_files
2141 # Synthesize an EXTRA_DIST augmentation.
2142 sed_combine_lines='/\\$/{
2149 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2150 already_mentioned_files=` \
2151 { if ! $modcache; then
2152 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2154 if $have_associative; then
2155 if test -n "${modcache_makefile[$1]+set}"; then
2156 echo "${modcache_makefile[$1]}"
2159 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2160 if test -n "$field_set"; then
2161 eval 'field_value="$'"${cachevar}"'_makefile"'
2162 echo "${field_value}"
2167 | sed -e "$sed_combine_lines" \
2168 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2169 all_files=`func_get_filelist $1`
2170 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2171 # Remove $already_mentioned_files from $lib_files.
2172 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2173 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2174 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2175 if test -n "$extra_files"; then
2176 echo "EXTRA_DIST +=" $extra_files
2179 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2180 # This is necessary so that automake can generate the right list of
2182 # A possible approach would be to use autom4te --trace of the redefined
2183 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2184 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2185 # inside autoconf's built-in macros are not missed).
2186 # But it's simpler and more robust to do it here, based on the file list.
2187 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2188 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2189 # automake will generate a useless dependency; this is harmless.
2191 relocatable-prog-wrapper) ;;
2193 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2194 if test -n "$extra_files"; then
2195 echo "EXTRA_lib_SOURCES +=" $extra_files
2200 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2201 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2202 if test -n "$buildaux_files"; then
2203 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2204 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2207 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2208 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2209 if test -n "$top_files"; then
2210 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2211 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2218 # func_get_include_directive module
2220 # - local_gnulib_dir from --local-dir
2221 # - modcache true or false, from --cache-modules/--no-cache-modules
2222 func_get_include_directive ()
2225 if ! $modcache; then
2226 func_lookup_file "modules/$1"
2227 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2229 func_cache_lookup_module "$1"
2230 # Output the field's value, including the final newline (if any).
2231 if $have_associative; then
2232 if test -n "${modcache_include[$1]+set}"; then
2233 echo "${modcache_include[$1]}"
2236 eval "field_set=\"\$${cachevar}_include_set\""
2237 if test -n "$field_set"; then
2238 eval "field_value=\"\$${cachevar}_include\""
2239 echo "${field_value}"
2243 } | sed -e 's/^\(["<]\)/#include \1/'
2246 # func_get_link_directive module
2248 # - local_gnulib_dir from --local-dir
2249 # - modcache true or false, from --cache-modules/--no-cache-modules
2250 func_get_link_directive ()
2252 if ! $modcache; then
2253 func_lookup_file "modules/$1"
2254 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2256 func_cache_lookup_module "$1"
2257 # Output the field's value, including the final newline (if any).
2258 if $have_associative; then
2259 if test -n "${modcache_link[$1]+set}"; then
2260 echo "${modcache_link[$1]}"
2263 eval "field_set=\"\$${cachevar}_link_set\""
2264 if test -n "$field_set"; then
2265 eval "field_value=\"\$${cachevar}_link\""
2266 echo "${field_value}"
2272 # func_get_license module
2274 # - local_gnulib_dir from --local-dir
2275 # - modcache true or false, from --cache-modules/--no-cache-modules
2279 if ! $modcache; then
2280 func_lookup_file "modules/$1"
2281 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2283 func_cache_lookup_module "$1"
2284 # Output the field's value, including the final newline (if any).
2285 if $have_associative; then
2286 if test -n "${modcache_license[$1]+set}"; then
2287 echo "${modcache_license[$1]}"
2290 eval "field_set=\"\$${cachevar}_license_set\""
2291 if test -n "$field_set"; then
2292 eval "field_value=\"\$${cachevar}_license\""
2293 echo "${field_value}"
2297 # The default is GPL.
2299 } | sed -e 's,^ *$,,' | sed -e 1q
2302 # func_get_maintainer module
2304 # - local_gnulib_dir from --local-dir
2305 # - modcache true or false, from --cache-modules/--no-cache-modules
2306 func_get_maintainer ()
2308 if ! $modcache; then
2309 func_lookup_file "modules/$1"
2310 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2312 func_cache_lookup_module "$1"
2313 # Output the field's value, including the final newline (if any).
2314 if $have_associative; then
2315 if test -n "${modcache_maintainer[$1]+set}"; then
2316 echo "${modcache_maintainer[$1]}"
2319 eval "field_set=\"\$${cachevar}_maintainer_set\""
2320 if test -n "$field_set"; then
2321 eval "field_value=\"\$${cachevar}_maintainer\""
2322 echo "${field_value}"
2328 # func_get_tests_module module
2330 # - local_gnulib_dir from --local-dir
2331 func_get_tests_module ()
2333 # The naming convention for tests modules is hardwired: ${module}-tests.
2334 if test -f "$gnulib_dir/modules/$1"-tests \
2335 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2336 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2341 # func_acceptable module
2342 # tests whether a module is acceptable.
2344 # - avoidlist list of modules to avoid
2347 for avoid in $avoidlist; do
2348 if test "$avoid" = "$1"; then
2355 # func_modules_transitive_closure
2357 # - local_gnulib_dir from --local-dir
2358 # - modcache true or false, from --cache-modules/--no-cache-modules
2359 # - modules list of specified modules
2360 # - inctests true if tests should be included, blank otherwise
2361 # - incobsolete true if obsolete modules among dependencies should be
2362 # included, blank otherwise
2363 # - inc_cxx_tests true if C++ interoperability tests should be included,
2365 # - inc_longrunning_tests true if long-runnings tests should be included,
2367 # - inc_privileged_tests true if tests that require root privileges should be
2368 # included, blank otherwise
2369 # - inc_unportable_tests true if tests that fail on some platforms should be
2370 # included, blank otherwise
2371 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2372 # the unit tests of the specified modules should be
2373 # included, blank otherwise
2374 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2375 # the unit tests of the dependencies should be
2376 # included, blank otherwise
2377 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2379 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2381 # - excl_privileged_tests true if tests that require root privileges should be
2382 # excluded, blank otherwise
2383 # - excl_unportable_tests true if tests that fail on some platforms should be
2384 # excluded, blank otherwise
2385 # - avoidlist list of modules to avoid
2386 # - tmp pathname of a temporary directory
2388 # - modules list of modules, including dependencies
2389 func_modules_transitive_closure ()
2391 # In order to process every module only once (for speed), process an "input
2392 # list" of modules, producing an "output list" of modules. During each round,
2393 # more modules can be queued in the input list. Once a module on the input
2394 # list has been processed, it is added to the "handled list", so we can avoid
2395 # to process it again.
2397 inmodules="$modules"
2399 fmtc_inc_all_tests="$inc_all_direct_tests"
2400 while test -n "$inmodules"; do
2401 inmodules_this_round="$inmodules"
2402 inmodules= # Accumulator, queue for next round
2403 for module in $inmodules_this_round; do
2405 if test -n "$module"; then
2406 if func_acceptable $module; then
2407 func_append outmodules " $module"
2408 deps=`func_get_dependencies $module`
2409 # Duplicate dependencies are harmless, but Jim wants a warning.
2410 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2411 if test -n "$duplicated_deps"; then
2412 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2414 if test -n "$inctests"; then
2415 testsmodule=`func_get_tests_module $module`
2416 if test -n "$testsmodule"; then
2417 deps="$deps $testsmodule"
2420 for dep in $deps; do
2421 # Determine whether to include the dependency or tests module.
2423 for word in `func_get_status $dep`; do
2426 test -n "$incobsolete" \
2430 test -z "$excl_cxx_tests" \
2432 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2436 test -z "$excl_longrunning_tests" \
2438 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2442 test -z "$excl_privileged_tests" \
2444 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2448 test -z "$excl_unportable_tests" \
2450 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2454 test -n "$fmtc_inc_all_tests" \
2460 func_append inmodules " $dep"
2466 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2467 # Remove $handledmodules from $inmodules.
2468 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2469 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2470 fmtc_inc_all_tests="$inc_all_indirect_tests"
2472 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2473 rm -f "$tmp"/queued-modules
2476 # func_show_module_list
2478 # - specified_modules list of specified modules (one per line, sorted)
2479 # - modules complete list of modules (one per line, sorted)
2480 # - tmp pathname of a temporary directory
2481 func_show_module_list ()
2487 # Assume xterm compatible escape sequences.
2488 bold_on=`printf '\x1b[1m'`
2489 bold_off=`printf '\x1b[0m'`
2494 echo "Module list with included dependencies (indented):"
2495 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2496 echo "$modules" | sed -e '/^$/d' \
2497 | LC_ALL=C join -t '|' -a 2 "$tmp"/specified-modules - \
2498 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2501 # func_modules_add_dummy
2503 # - local_gnulib_dir from --local-dir
2504 # - modcache true or false, from --cache-modules/--no-cache-modules
2505 # - modules list of modules, including dependencies
2507 # - modules list of modules, including 'dummy' if needed
2508 func_modules_add_dummy ()
2510 # Determine whether any module provides a lib_SOURCES augmentation.
2512 sed_remove_backslash_newline=':a
2519 for module in $modules; do
2520 func_verify_nontests_module
2521 if test -n "$module"; then
2522 # Extract the value of "lib_SOURCES += ...".
2523 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2524 # Ignore .h files since they are not compiled.
2528 have_lib_SOURCES=yes
2535 # Add the dummy module, to make sure the library will be non-empty.
2536 if test -z "$have_lib_SOURCES"; then
2537 if func_acceptable "dummy"; then
2538 func_append modules " dummy"
2543 # func_modules_notice
2545 # - local_gnulib_dir from --local-dir
2546 # - modcache true or false, from --cache-modules/--no-cache-modules
2547 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2548 # - modules list of modules, including dependencies
2549 func_modules_notice ()
2551 if test $verbose -ge -1; then
2552 for module in $modules; do
2554 if test -n "$module"; then
2555 msg=`func_get_notice $module`
2556 if test -n "$msg"; then
2557 echo "Notice from module $module:"
2558 echo "$msg" | sed -e 's/^/ /'
2565 # func_modules_to_filelist
2567 # - local_gnulib_dir from --local-dir
2568 # - modcache true or false, from --cache-modules/--no-cache-modules
2569 # - modules list of modules, including dependencies
2571 # - files list of files
2572 func_modules_to_filelist ()
2575 for module in $modules; do
2577 if test -n "$module"; then
2578 fs=`func_get_filelist $module`
2579 func_append files " $fs"
2582 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2585 # func_execute_command command [args...]
2586 # Executes a command.
2587 # Uses also the variables
2588 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2589 func_execute_command ()
2591 if test $verbose -ge 0; then
2595 # Commands like automake produce output to stderr even when they succeed.
2596 # Turn this output off if the command succeeds.
2597 "$@" > "$tmp"/cmdout 2>&1
2599 if test $cmdret = 0; then
2603 cat "$tmp"/cmdout 1>&2
2610 # func_dest_tmpfilename file
2611 # determines the name of a temporary file (file is relative to destdir).
2613 # - destdir target directory
2614 # - doit : if actions shall be executed, false if only to be printed
2615 # - tmp pathname of a temporary directory
2617 # - tmpfile absolute filename of the temporary file
2618 func_dest_tmpfilename ()
2621 # Put the new contents of $file in a file in the same directory (needed
2622 # to guarantee that an 'mv' to "$destdir/$file" works).
2623 tmpfile="$destdir/$1.tmp"
2625 # Put the new contents of $file in a file in a temporary directory
2626 # (because the directory of "$file" might not exist).
2627 tmpfile="$tmp"/`basename "$1"`.tmp
2632 # copies a file from gnulib into the destination directory. The destination
2633 # is known to not exist.
2635 # - destdir target directory
2636 # - local_gnulib_dir from --local-dir
2637 # - modcache true or false, from --cache-modules/--no-cache-modules
2638 # - f the original file name
2639 # - lookedup_file name of the merged (combined) file
2640 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2641 # - g the rewritten file name
2642 # - tmpfile absolute filename of the temporary file
2643 # - doit : if actions shall be executed, false if only to be printed
2644 # - symbolic true if files should be symlinked, copied otherwise
2645 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2650 echo "Copying file $g"
2651 if { test -n "$symbolic" \
2652 || { test -n "$lsymbolic" \
2653 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2654 && test -z "$lookedup_tmp" \
2655 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2656 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2658 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2666 # copies a file from gnulib into the destination directory. The destination
2667 # is known to exist.
2669 # - destdir target directory
2670 # - local_gnulib_dir from --local-dir
2671 # - modcache true or false, from --cache-modules/--no-cache-modules
2672 # - f the original file name
2673 # - lookedup_file name of the merged (combined) file
2674 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2675 # - g the rewritten file name
2676 # - tmpfile absolute filename of the temporary file
2677 # - doit : if actions shall be executed, false if only to be printed
2678 # - symbolic true if files should be symlinked, copied otherwise
2679 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2681 # - already_present nonempty if the file should already exist, empty otherwise
2684 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2685 : # The file has not changed.
2689 if test -n "$already_present"; then
2690 echo "Updating file $g (backup in ${g}~)"
2692 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2694 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2695 if { test -n "$symbolic" \
2696 || { test -n "$lsymbolic" \
2697 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2698 && test -z "$lookedup_tmp" \
2699 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2700 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2702 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2705 if test -n "$already_present"; then
2706 echo "Update file $g (backup in ${g}~)"
2708 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2714 # func_emit_lib_Makefile_am
2715 # emits the contents of library makefile to standard output.
2717 # - local_gnulib_dir from --local-dir
2718 # - modcache true or false, from --cache-modules/--no-cache-modules
2719 # - modules list of modules, including dependencies
2720 # - libname library name
2721 # - pobase directory relative to destdir where to place *.po files
2722 # - auxdir directory relative to destdir where to place build aux files
2723 # - makefile_name from --makefile-name
2724 # - libtool true if libtool will be used, false or blank otherwise
2725 # - macro_prefix prefix of gl_LIBOBJS macros to use
2726 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2727 # - actioncmd (optional) command that will reproduce this invocation
2728 # - for_test true if creating a package for testing, false otherwise
2729 # - destfile filename relative to destdir of makefile being generated
2731 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2732 # list of edits to be done to Makefile.am variables
2734 # - uses_subdirs nonempty if object files in subdirs exist
2735 func_emit_lib_Makefile_am ()
2737 # When creating an includable Makefile.am snippet, augment variables with
2738 # += instead of assigning them.
2739 if test -n "$makefile_name"; then
2744 if test "$libtool" = true; then
2747 sed_eliminate_LDFLAGS="$sed_noop"
2751 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2754 # When creating a package for testing: Attempt to provoke failures,
2755 # especially link errors, already during "make" rather than during
2756 # "make check", because "make check" is not possible in a cross-compiling
2757 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2758 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2760 sed_transform_check_PROGRAMS="$sed_noop"
2762 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2763 echo "## Process this file with automake to produce Makefile.in."
2764 func_emit_copyright_notice
2765 if test -n "$actioncmd"; then
2766 # The maximum line length (excluding the terminating newline) of any file
2767 # that is to be preprocessed by config.status is 3070. config.status uses
2768 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
2769 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
2770 len=`echo "$actioncmd" | wc -c`
2771 if test -n "$len" && test "$len" -le 3000; then
2772 echo "# Reproduce by: $actioncmd"
2778 for module in $modules; do
2779 func_verify_nontests_module
2780 if test -n "$module"; then
2782 func_get_automake_snippet "$module" |
2784 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2785 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2786 -e "$sed_eliminate_LDFLAGS" \
2787 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
2788 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2789 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2790 -e "$sed_transform_check_PROGRAMS"
2791 if test "$module" = 'alloca'; then
2792 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2793 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2795 } > "$tmp"/amsnippet
2796 # Skip the contents if it's entirely empty.
2797 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2798 echo "## begin gnulib module $module"
2800 cat "$tmp"/amsnippet
2801 echo "## end gnulib module $module"
2804 rm -f "$tmp"/amsnippet
2805 # Test whether there are some source files in subdirectories.
2806 for f in `func_get_filelist "$module"`; do
2816 } > "$tmp"/allsnippets
2817 if test -z "$makefile_name"; then
2818 # If there are source files in subdirectories, prevent collision of the
2819 # object files (example: hash.c and libxml/hash.c).
2821 if test -n "$uses_subdirs"; then
2822 subdir_options=' subdir-objects'
2824 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2827 if test -z "$makefile_name"; then
2829 echo "noinst_HEADERS ="
2830 echo "noinst_LIBRARIES ="
2831 echo "noinst_LTLIBRARIES ="
2832 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2833 # if you specify pkgdata_DATA to empty. This is a workaround.
2834 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2835 echo "pkgdata_DATA ="
2838 echo "BUILT_SOURCES ="
2841 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2842 if test -z "$makefile_name"; then
2843 echo "MOSTLYCLEANDIRS ="
2845 echo "DISTCLEANFILES ="
2846 echo "MAINTAINERCLEANFILES ="
2848 # Execute edits that apply to the Makefile.am being generated.
2850 while test $edit != $makefile_am_edits; do
2851 edit=`expr $edit + 1`
2852 eval dir=\"\$makefile_am_edit${edit}_dir\"
2853 eval var=\"\$makefile_am_edit${edit}_var\"
2854 eval val=\"\$makefile_am_edit${edit}_val\"
2855 if test -n "$var"; then
2856 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2857 echo "${var} += ${val}"
2858 eval "makefile_am_edit${edit}_var="
2862 if test -z "$makefile_name"; then
2865 echo "AM_CPPFLAGS = -DGNULIB_STRICT_CHECKING=1"
2867 echo "AM_CPPFLAGS ="
2872 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
2873 || { test -n "$makefile_name" \
2874 && test -f "$sourcebase/Makefile.am" \
2875 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2877 # One of the snippets or the user's Makefile.am already specifies an
2878 # installation location for the library. Don't confuse automake by saying
2879 # it should not be installed.
2882 # By default, the generated library should not be installed.
2883 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2886 echo "${libname}_${libext}_SOURCES ="
2887 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2888 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2889 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2890 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2891 echo "EXTRA_${libname}_${libext}_SOURCES ="
2892 if test "$libtool" = true; then
2893 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2896 if test -n "$pobase"; then
2897 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2900 cat "$tmp"/allsnippets \
2901 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2903 echo "mostlyclean-local: mostlyclean-generic"
2904 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2905 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2906 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2910 rm -f "$tmp"/allsnippets
2913 # func_emit_po_Makevars
2914 # emits the contents of po/ makefile parameterization to standard output.
2916 # - local_gnulib_dir from --local-dir
2917 # - modcache true or false, from --cache-modules/--no-cache-modules
2918 # - sourcebase directory relative to destdir where to place source code
2919 # - pobase directory relative to destdir where to place *.po files
2920 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2921 func_emit_po_Makevars ()
2923 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2924 func_emit_copyright_notice
2926 echo "# Usually the message domain is the same as the package name."
2927 echo "# But here it has a '-gnulib' suffix."
2928 echo "DOMAIN = ${po_domain}-gnulib"
2930 echo "# These two variables depend on the location of this directory."
2931 echo "subdir = ${pobase}"
2932 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2935 # These options get passed to xgettext.
2936 XGETTEXT_OPTIONS = \
2937 --keyword=_ --flag=_:1:pass-c-format \
2938 --keyword=N_ --flag=N_:1:pass-c-format \
2939 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2940 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2941 --flag=error:3:c-format --flag=error_at_line:5:c-format
2943 # This is the copyright holder that gets inserted into the header of the
2944 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2945 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2947 # This is the email address or URL to which the translators shall report
2948 # bugs in the untranslated strings:
2949 # - Strings which are not entire sentences, see the maintainer guidelines
2950 # in the GNU gettext documentation, section 'Preparing Strings'.
2951 # - Strings which use unclear terms or require additional context to be
2953 # - Strings which make invalid assumptions about notation of date, time or
2955 # - Pluralisation problems.
2956 # - Incorrect English spelling.
2957 # - Incorrect formatting.
2958 # It can be your email address, or a mailing list address where translators
2959 # can write to without being subscribed, or the URL of a web page through
2960 # which the translators can contact you.
2961 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2963 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2964 # message catalogs shall be used. It is usually empty.
2965 EXTRA_LOCALE_CATEGORIES =
2967 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2968 # context. Possible values are "yes" and "no". Set this to yes if the
2969 # package uses functions taking also a message context, like pgettext(), or
2970 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
2975 # func_emit_po_POTFILES_in
2976 # emits the file list to be passed to xgettext to standard output.
2978 # - local_gnulib_dir from --local-dir
2979 # - modcache true or false, from --cache-modules/--no-cache-modules
2980 # - sourcebase directory relative to destdir where to place source code
2981 # - files list of new files
2982 func_emit_po_POTFILES_in ()
2984 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2985 func_emit_copyright_notice
2987 echo "# List of files which contain translatable strings."
2988 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
2991 # func_emit_tests_Makefile_am witness_macro
2992 # emits the contents of tests makefile to standard output.
2994 # - local_gnulib_dir from --local-dir
2995 # - modcache true or false, from --cache-modules/--no-cache-modules
2996 # - modules list of modules, including dependencies
2997 # - libname library name
2998 # - auxdir directory relative to destdir where to place build aux files
2999 # - makefile_name from --makefile-name
3000 # - libtool true if libtool will be used, false or blank otherwise
3001 # - sourcebase relative directory containing lib source code
3002 # - m4base relative directory containing autoconf macros
3003 # - testsbase relative directory containing unit test code
3004 # - macro_prefix prefix of gl_LIBOBJS macros to use
3005 # - for_test true if creating a package for testing, false otherwise
3006 # - use_libtests true if a libtests.a should be built, false otherwise
3007 # - destfile filename relative to destdir of makefile being generated
3009 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3010 # list of edits to be done to Makefile.am variables
3012 # - uses_subdirs nonempty if object files in subdirs exist
3013 func_emit_tests_Makefile_am ()
3016 if test "$libtool" = true; then
3018 sed_eliminate_LDFLAGS="$sed_noop"
3021 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3024 # When creating a package for testing: Attempt to provoke failures,
3025 # especially link errors, already during "make" rather than during
3026 # "make check", because "make check" is not possible in a cross-compiling
3027 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3028 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3030 sed_transform_check_PROGRAMS="$sed_noop"
3032 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3033 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3034 echo "## Process this file with automake to produce Makefile.in."
3035 func_emit_copyright_notice
3039 for module in $modules; do
3041 func_verify_tests_module
3045 if test -n "$module"; then
3047 func_get_automake_snippet "$module" |
3049 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3050 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3051 -e "$sed_eliminate_LDFLAGS" \
3052 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3053 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3054 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3055 -e "$sed_transform_check_PROGRAMS"
3056 if $use_libtests && test "$module" = 'alloca'; then
3057 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3058 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3060 } > "$tmp"/amsnippet
3061 # Skip the contents if it's entirely empty.
3062 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3063 # Mention long-running tests at the end.
3065 for word in `func_get_status "$module"`; do
3066 if test "$word" = 'longrunning-test'; then
3071 { echo "## begin gnulib module $module"
3073 cat "$tmp"/amsnippet
3074 echo "## end gnulib module $module"
3078 rm -f "$tmp"/amsnippet
3079 # Test whether there are some source files in subdirectories.
3080 for f in `func_get_filelist "$module"`; do
3082 lib/*/*.c | tests/*/*.c)
3090 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3091 # Generate dependencies here, since it eases the debugging of test failures.
3092 # If there are source files in subdirectories, prevent collision of the
3093 # object files (example: hash.c and libxml/hash.c).
3095 if test -n "$uses_subdirs"; then
3096 subdir_options=' subdir-objects'
3098 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
3101 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3104 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3105 # variable is needed to avoid an error from automake:
3106 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3109 echo "XFAIL_TESTS ="
3110 echo "TESTS_ENVIRONMENT ="
3111 echo "noinst_PROGRAMS ="
3112 if ! $for_test; then
3113 echo "check_PROGRAMS ="
3115 echo "noinst_HEADERS ="
3116 echo "noinst_LIBRARIES ="
3117 if $use_libtests; then
3119 echo "noinst_LIBRARIES += libtests.a"
3121 echo "check_LIBRARIES = libtests.a"
3124 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3125 # if you specify pkgdata_DATA to empty. This is a workaround.
3126 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3127 echo "pkgdata_DATA ="
3130 echo "BUILT_SOURCES ="
3132 echo "MOSTLYCLEANFILES = core *.stackdump"
3133 echo "MOSTLYCLEANDIRS ="
3135 echo "DISTCLEANFILES ="
3136 echo "MAINTAINERCLEANFILES ="
3137 # Execute edits that apply to the Makefile.am being generated.
3139 while test $edit != $makefile_am_edits; do
3140 edit=`expr $edit + 1`
3141 eval dir=\"\$makefile_am_edit${edit}_dir\"
3142 eval var=\"\$makefile_am_edit${edit}_var\"
3143 eval val=\"\$makefile_am_edit${edit}_val\"
3144 if test -n "$var"; then
3145 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3146 echo "${var} += ${val}"
3147 eval "makefile_am_edit${edit}_var="
3152 echo "AM_CPPFLAGS = \\"
3154 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3156 if test -n "${witness_macro}"; then
3157 echo " -D@${witness_macro}@=1 \\"
3159 echo " -I. -I\$(srcdir) \\"
3160 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3161 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3163 local_ldadd_before=''
3164 local_ldadd_after=''
3165 if $use_libtests; then
3166 # All test programs need to be linked with libtests.a.
3167 # It needs to be passed to the linker before ${libname}.${libext}, since
3168 # the tests-related modules depend on the main modules.
3169 # It also needs to be passed to the linker after ${libname}.${libext}
3170 # because the latter might contain incomplete modules (such as the 'error'
3171 # module whose dependency to 'progname' is voluntarily omitted).
3172 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3174 local_ldadd_before=' libtests.a'
3175 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3177 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3179 if $use_libtests; then
3180 echo "libtests_a_SOURCES ="
3181 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3182 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3183 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3184 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3185 echo "EXTRA_libtests_a_SOURCES ="
3186 # The circular dependency in LDADD requires this.
3187 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3190 # Many test scripts use ${EXEEXT} or ${srcdir}.
3191 # EXEEXT is defined by AC_PROG_CC through autoconf.
3192 # srcdir is defined by autoconf and automake.
3193 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3195 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3196 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3197 echo "# Clean up after Solaris cc."
3199 echo " rm -rf SunWS_cache"
3201 echo "mostlyclean-local: mostlyclean-generic"
3202 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3203 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3204 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3208 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3211 # func_emit_initmacro_start macro_prefix
3212 # emits the first few statements of the gl_INIT macro to standard output.
3213 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3214 func_emit_initmacro_start ()
3216 macro_prefix_arg="$1"
3217 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3218 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3219 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3220 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3222 # Furthermore it avoids an automake error like this when a Makefile.am
3223 # that uses pieces of gnulib also uses $(LIBOBJ):
3224 # automatically discovered file `error.c' should not be explicitly mentioned
3225 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3226 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3227 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3228 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3229 # automatically discovered file `error.c' should not be explicitly mentioned
3230 # We let automake know about the files to be distributed through the
3231 # EXTRA_lib_SOURCES variable.
3232 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3233 # Create data variables for checking the presence of files that are mentioned
3234 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3235 # because we want the check to happen when the configure file is created,
3236 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3237 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3238 # in which to expect them.
3239 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3240 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3244 # func_emit_initmacro_end macro_prefix
3245 # emits the last few statements of the gl_INIT macro to standard output.
3246 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3247 func_emit_initmacro_end ()
3249 macro_prefix_arg="$1"
3250 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3251 # The check is performed only when autoconf is run from the directory where
3252 # the configure.ac resides; if it is run from a different directory, the
3254 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3255 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3256 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3257 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3258 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3262 echo " m4_if(m4_sysval, [0], [],"
3263 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3265 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3266 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3267 echo " m4_popdef([AC_LIBSOURCES])"
3268 echo " m4_popdef([AC_REPLACE_FUNCS])"
3269 echo " m4_popdef([AC_LIBOBJ])"
3270 echo " AC_CONFIG_COMMANDS_PRE(["
3271 echo " ${macro_prefix_arg}_libobjs="
3272 echo " ${macro_prefix_arg}_ltlibobjs="
3273 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3274 echo " # Remove the extension."
3275 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3276 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3277 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3278 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3281 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3282 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3286 # func_emit_initmacro_done macro_prefix sourcebase
3287 # emits a few statements after the gl_INIT macro to standard output.
3288 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3289 # - sourcebase directory relative to destdir where to place source code
3290 func_emit_initmacro_done ()
3292 macro_prefix_arg="$1"
3295 echo "# Like AC_LIBOBJ, except that the module name goes"
3296 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3297 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3298 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3299 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3302 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3303 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3304 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3305 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3306 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3309 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3310 echo "# expected is derived from the gnulib-tool parameterization,"
3311 echo "# and alloca is special cased (for the alloca-opt module)."
3312 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3313 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3314 echo " m4_foreach([_gl_NAME], [\$1], ["
3315 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3316 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3317 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3323 # func_import modules
3324 # Uses also the variables
3325 # - mode import or add-import or remove-import or update
3326 # - destdir target directory
3327 # - local_gnulib_dir from --local-dir
3328 # - modcache true or false, from --cache-modules/--no-cache-modules
3329 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3330 # - libname library name
3331 # - supplied_libname true if --lib was given, blank otherwise
3332 # - sourcebase directory relative to destdir where to place source code
3333 # - m4base directory relative to destdir where to place *.m4 macros
3334 # - pobase directory relative to destdir where to place *.po files
3335 # - docbase directory relative to destdir where to place doc files
3336 # - testsbase directory relative to destdir where to place unit test code
3337 # - auxdir directory relative to destdir where to place build aux files
3338 # - inctests true if --with-tests was given, blank otherwise
3339 # - incobsolete true if --with-obsolete was given, blank otherwise
3340 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
3341 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
3343 # - inc_privileged_tests true if --with-privileged-tests was given, blank
3345 # - inc_unportable_tests true if --with-unportable-tests was given, blank
3347 # - inc_all_tests true if --with-all-tests was given, blank otherwise
3348 # - avoidlist list of modules to avoid, from --avoid
3349 # - lgpl yes or a number if library's license shall be LGPL,
3351 # - makefile_name from --makefile-name
3352 # - libtool true if --libtool was given, false if --no-libtool was
3353 # given, blank otherwise
3354 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
3355 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3356 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3357 # - vc_files true if --vc-files was given, false if --no-vc-files was
3358 # given, blank otherwise
3359 # - autoconf_minversion minimum supported autoconf version
3360 # - doit : if actions shall be executed, false if only to be printed
3361 # - symbolic true if files should be symlinked, copied otherwise
3362 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3364 # - do_copyrights true if copyright notices in files should be replaced,
3368 # Get the cached settings.
3369 # In 'import' mode, we read them only for the purpose of knowing the old
3370 # installed file list, and don't use them as defaults.
3371 cached_local_gnulib_dir=
3372 cached_specified_modules=
3374 cached_inc_cxx_tests=
3375 cached_inc_longrunning_tests=
3376 cached_inc_privileged_tests=
3377 cached_inc_unportable_tests=
3378 cached_inc_all_tests=
3388 cached_makefile_name=
3390 cached_macro_prefix=
3394 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3395 cached_libtool=false
3401 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
3411 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
3413 /gl_WITH_OBSOLETE/ {
3414 s,^.*$,cached_incobsolete=true,p
3416 /gl_WITH_CXX_TESTS/ {
3417 s,^.*$,cached_inc_cxx_tests=true,p
3419 /gl_WITH_LONGRUNNING_TESTS/ {
3420 s,^.*$,cached_inc_longrunning_tests=true,p
3422 /gl_WITH_PRIVILEGED_TESTS/ {
3423 s,^.*$,cached_inc_privileged_tests=true,p
3425 /gl_WITH_UNPORTABLE_TESTS/ {
3426 s,^.*$,cached_inc_unportable_tests=true,p
3428 /gl_WITH_ALL_TESTS/ {
3429 s,^.*$,cached_inc_all_tests=true,p
3432 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
3435 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
3438 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
3441 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
3444 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
3447 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
3450 s,^.*$,cached_inctests=true,p
3453 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
3456 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
3459 s,^.*$,cached_lgpl=yes,p
3461 /gl_MAKEFILE_NAME(/ {
3462 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
3465 s,^.*$,cached_libtool=true,p
3467 /gl_MACRO_PREFIX(/ {
3468 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
3471 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
3474 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
3476 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
3477 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3482 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
3483 s,^.*$,cached_files=",p
3496 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
3500 if test "$mode" = import; then
3501 # In 'import' mode, the new set of specified modules overrides the cached
3502 # set of modules. Ignore the cached settings.
3503 specified_modules="$1"
3505 # Merge the cached settings with the specified ones.
3506 # The m4base must be the same as expected from the pathname.
3507 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
3508 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
3510 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
3511 # is relative to $destdir, whereas the one we use is relative to . or absolute.
3512 if test -z "$local_gnulib_dir"; then
3513 if test -n "$cached_local_gnulib_dir"; then
3516 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3518 case "$cached_local_gnulib_dir" in
3520 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3522 func_relconcat "$destdir" "$cached_local_gnulib_dir"
3523 local_gnulib_dir="$relconcat" ;;
3530 # Append the cached and the specified module names. So that
3531 # "gnulib-tool --add-import foo" means to add the module foo.
3532 specified_modules="$cached_specified_modules $1"
3535 # Take the cached module names, minus the specified module names.
3537 if $have_associative; then
3538 # Use an associative array, for O(N) worst-case run time.
3539 declare -A to_remove
3543 for module in $cached_specified_modules; do
3544 if test -z "${to_remove[$module]}"; then
3545 func_append specified_modules "$module "
3549 # This loop has O(N²) worst-case run time.
3550 for module in $cached_specified_modules; do
3553 if test "$m" = "$module"; then
3558 if test -z "$to_remove"; then
3559 func_append specified_modules "$module "
3565 # Take the cached module names. There are no specified module names.
3566 specified_modules="$cached_specified_modules"
3569 # Included obsolete modules among the dependencies if specified either way.
3570 if test -z "$incobsolete"; then
3571 incobsolete="$cached_incobsolete"
3573 # Included special kinds of tests modules among the dependencies if specified
3575 if test -z "$inc_cxx_tests"; then
3576 inc_cxx_tests="$cached_inc_cxx_tests"
3578 if test -z "$inc_longrunning_tests"; then
3579 inc_longrunning_tests="$cached_inc_longrunning_tests"
3581 if test -z "$inc_privileged_tests"; then
3582 inc_privileged_tests="$cached_inc_privileged_tests"
3584 if test -z "$inc_unportable_tests"; then
3585 inc_unportable_tests="$cached_inc_unportable_tests"
3587 if test -z "$inc_all_tests"; then
3588 inc_all_tests="$cached_inc_all_tests"
3590 # Append the cached and the specified avoidlist. This is probably better
3591 # than dropping the cached one when --avoid is specified at least once.
3592 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
3593 avoidlist=`echo $avoidlist`
3595 # The sourcebase defaults to the cached one.
3596 if test -z "$sourcebase"; then
3597 sourcebase="$cached_sourcebase"
3598 if test -z "$sourcebase"; then
3599 func_fatal_error "missing --source-base option"
3602 # The pobase defaults to the cached one.
3603 if test -z "$pobase"; then
3604 pobase="$cached_pobase"
3606 # The docbase defaults to the cached one.
3607 if test -z "$docbase"; then
3608 docbase="$cached_docbase"
3609 if test -z "$docbase"; then
3610 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."
3613 # The testsbase defaults to the cached one.
3614 if test -z "$testsbase"; then
3615 testsbase="$cached_testsbase"
3616 if test -z "$testsbase"; then
3617 func_fatal_error "missing --tests-base option"
3620 # Require the tests if specified either way.
3621 if test -z "$inctests"; then
3622 inctests="$cached_inctests"
3624 # The libname defaults to the cached one.
3625 if test -z "$supplied_libname"; then
3626 libname="$cached_libname"
3627 if test -z "$libname"; then
3628 func_fatal_error "missing --lib option"
3631 # Require LGPL if specified either way.
3632 if test -z "$lgpl"; then
3635 # The makefile_name defaults to the cached one.
3636 if test -z "$makefile_name"; then
3637 makefile_name="$cached_makefile_name"
3639 # Use libtool if specified either way, or if guessed.
3640 if test -z "$libtool"; then
3641 if test -n "$cached_m4base"; then
3642 libtool="$cached_libtool"
3644 libtool="$guessed_libtool"
3647 # The macro_prefix defaults to the cached one.
3648 if test -z "$macro_prefix"; then
3649 macro_prefix="$cached_macro_prefix"
3650 if test -z "$macro_prefix"; then
3651 func_fatal_error "missing --macro-prefix option"
3654 # The po_domain defaults to the cached one.
3655 if test -z "$po_domain"; then
3656 po_domain="$cached_po_domain"
3658 # The vc_files defaults to the cached one.
3659 if test -z "$vc_files"; then
3660 vc_files="$cached_vc_files"
3663 # --without-*-tests options are not supported here.
3665 excl_longrunning_tests=
3666 excl_privileged_tests=
3667 excl_unportable_tests=
3669 # Canonicalize the list of specified modules.
3670 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
3672 # Include all kinds of tests modules if --with-all-tests was specified.
3673 inc_all_direct_tests="$inc_all_tests"
3674 inc_all_indirect_tests="$inc_all_tests"
3676 # Determine final module list.
3677 modules="$specified_modules"
3678 func_modules_transitive_closure
3679 if test $verbose -ge 0; then
3680 func_show_module_list
3682 final_modules="$modules"
3684 # Determine main module list and tests-related module list separately.
3685 # The main module list is the transitive closure of the specified modules,
3686 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3687 # is specified, it will consist only of LGPLed source.
3688 # The tests-related module list is the transitive closure of the specified
3689 # modules, including tests modules, minus the main module list excluding
3690 # modules of applicability 'all'. Its lib/* sources (brought in through
3691 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3692 # source, even if --lgpl is specified.
3693 # Determine main module list.
3694 saved_inctests="$inctests"
3696 modules="$specified_modules"
3697 func_modules_transitive_closure
3698 main_modules="$modules"
3699 inctests="$saved_inctests"
3700 if test $verbose -ge 1; then
3701 echo "Main module list:"
3702 echo "$main_modules" | sed -e 's/^/ /'
3704 # Determine tests-related module list.
3705 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3706 testsrelated_modules=`for module in $main_modules; do
3707 if test \`func_get_applicability $module\` = main; then
3711 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3712 if test $verbose -ge 1; then
3713 echo "Tests-related module list:"
3714 echo "$testsrelated_modules" | sed -e 's/^/ /'
3717 # Add the dummy module to the main module list if needed.
3718 modules="$main_modules"
3719 func_modules_add_dummy
3720 main_modules="$modules"
3722 # Determine whether a $testsbase/libtests.a is needed.
3724 for module in $testsrelated_modules; do
3725 func_verify_nontests_module
3726 if test -n "$module"; then
3727 all_files=`func_get_filelist $module`
3728 # Test whether some file in $all_files lies in lib/.
3729 for f in $all_files; do
3740 # Add the dummy module to the tests-related module list if needed.
3741 if $use_libtests; then
3742 modules="$testsrelated_modules"
3743 func_modules_add_dummy
3744 testsrelated_modules="$modules"
3747 # If --lgpl, verify that the licenses of modules are compatible.
3748 if test -n "$lgpl"; then
3749 license_incompatibilities=
3750 for module in $main_modules; do
3751 license=`func_get_license $module`
3753 'GPLed build tool') ;;
3754 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3759 LGPL | LGPLv2+ | LGPLv3+) ;;
3760 *) func_append license_incompatibilities "$module $license$nl" ;;
3766 *) func_append license_incompatibilities "$module $license$nl" ;;
3769 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3774 if test -n "$license_incompatibilities"; then
3775 # Format the license incompatibilities as a table.
3776 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
3777 s,^\(.................................................[^ ]*\) *, \1 ,'
3778 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
3779 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
3783 # Show banner notice of every module.
3784 modules="$main_modules"
3787 # Determine script to apply to imported library files.
3788 sed_transform_lib_file=
3789 for module in $main_modules; do
3790 if test $module = config-h; then
3791 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
3792 sed_transform_lib_file=$sed_transform_lib_file'
3793 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
3798 sed_transform_main_lib_file="$sed_transform_lib_file"
3799 if test -n "$do_copyrights"; then
3800 if test -n "$lgpl"; then
3804 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3805 s/GNU General/GNU Lesser General/g
3809 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3810 s/GNU General/GNU Lesser General/g
3811 s/version [23]\([ ,]\)/version 2.1\1/g
3814 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3818 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3819 s/GNU Lesser General/GNU General/g
3820 s/GNU Library General/GNU General/g
3821 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3826 # Determine script to apply to auxiliary files that go into $auxdir/.
3827 sed_transform_build_aux_file=
3828 if test -n "$do_copyrights"; then
3830 sed_transform_build_aux_file=$sed_transform_build_aux_file'
3831 s/GNU Lesser General/GNU General/g
3832 s/GNU Library General/GNU General/g
3833 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3837 # Determine script to apply to library files that go into $testsbase/.
3838 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
3839 if test -n "$do_copyrights"; then
3841 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
3842 s/GNU Lesser General/GNU General/g
3843 s/GNU Library General/GNU General/g
3844 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3848 # Determine the final file lists.
3849 # They must be computed separately, because files in lib/* go into
3850 # $sourcebase/ if they are in the main file list but into $testsbase/
3851 # if they are in the tests-related file list. Furthermore lib/dummy.c
3853 # Determine final main file list.
3854 modules="$main_modules"
3855 func_modules_to_filelist
3857 # Determine final tests-related file list.
3858 modules="$testsrelated_modules"
3859 func_modules_to_filelist
3860 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3861 # Merge both file lists.
3862 sed_remove_empty_lines='/^$/d'
3863 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3864 if test $verbose -ge 0; then
3866 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3867 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3871 || func_fatal_error "refusing to do nothing"
3873 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
3874 new_files="$files m4/gnulib-tool.m4"
3875 old_files="$cached_files"
3876 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
3877 func_append old_files " m4/gnulib-tool.m4"
3880 rewritten='%REWRITTEN%'
3881 sed_rewrite_old_files="\
3882 s,^build-aux/,$rewritten$auxdir/,
3883 s,^doc/,$rewritten$cached_docbase/,
3884 s,^lib/,$rewritten$cached_sourcebase/,
3885 s,^m4/,$rewritten$cached_m4base/,
3886 s,^tests/,$rewritten$cached_testsbase/,
3887 s,^tests=lib/,$rewritten$cached_testsbase/,
3890 sed_rewrite_new_files="\
3891 s,^build-aux/,$rewritten$auxdir/,
3892 s,^doc/,$rewritten$docbase/,
3893 s,^lib/,$rewritten$sourcebase/,
3894 s,^m4/,$rewritten$m4base/,
3895 s,^tests/,$rewritten$testsbase/,
3896 s,^tests=lib/,$rewritten$testsbase/,
3900 # Create directories.
3901 { echo "$sourcebase"
3903 if test -n "$pobase"; then
3906 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
3907 if test -n "$docfiles"; then
3910 if test -n "$inctests"; then
3914 for f in $files; do echo $f; done \
3915 | sed -e "$sed_rewrite_new_files" \
3916 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3919 { # Rearrange file descriptors. Needed because "while ... done < ..."
3920 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3921 exec 5<&0 < "$tmp"/dirs
3923 if test ! -d "$destdir/$d"; then
3925 echo "Creating directory $destdir/$d"
3926 mkdir -p "$destdir/$d" || func_fatal_error "failed"
3928 echo "Create directory $destdir/$d"
3935 # Copy files or make symbolic links. Remove obsolete files.
3939 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3940 # representing the files according to the last gnulib-tool invocation.
3941 for f in $old_files; do echo $f; done \
3942 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
3945 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3946 # representing the files after this gnulib-tool invocation.
3947 for f in $new_files; do echo $f; done \
3948 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
3951 # First the files that are in old-files, but not in new-files:
3952 sed_take_first_column='s,'"$delimiter"'.*,,'
3953 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
3954 # Remove the file. Do nothing if the user already removed it.
3955 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
3957 echo "Removing file $g (backup in ${g}~)"
3958 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3960 echo "Remove file $g (backup in ${g}~)"
3962 func_append removed_files "$g$nl"
3965 # func_add_or_update handles a file that ought to be present afterwards.
3967 # - f the original file name
3968 # - g the rewritten file name
3969 # - already_present nonempty if the file should already exist, empty
3971 func_add_or_update ()
3975 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
3977 func_dest_tmpfilename "$g"
3978 func_lookup_file "$f"
3979 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
3980 if test -n "$sed_transform_main_lib_file"; then
3983 sed -e "$sed_transform_main_lib_file" \
3984 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3988 if test -n "$sed_transform_build_aux_file"; then
3991 sed -e "$sed_transform_build_aux_file" \
3992 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3996 if test -n "$sed_transform_testsrelated_lib_file"; then
3999 sed -e "$sed_transform_testsrelated_lib_file" \
4000 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4004 if test -f "$destdir/$g"; then
4005 # The file already exists.
4009 # Don't protest if the file should be there but isn't: it happens
4010 # frequently that developers don't put autogenerated files under version control.
4012 func_append added_files "$g$nl"
4016 # Then the files that are in new-files, but not in old-files:
4017 sed_take_last_column='s,^.*'"$delimiter"',,'
4019 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
4020 | sed -e "$sed_take_last_column" \
4021 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
4022 { # Rearrange file descriptors. Needed because "while ... done < ..."
4023 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4024 exec 5<&0 < "$tmp"/added-files
4030 # Then the files that are in new-files and in old-files:
4031 already_present=true
4032 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
4033 | sed -e "$sed_take_last_column" \
4034 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
4035 { # Rearrange file descriptors. Needed because "while ... done < ..."
4036 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4037 exec 5<&0 < "$tmp"/kept-files
4044 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
4045 actioncmd="gnulib-tool --import"
4046 func_append actioncmd " --dir=$destdir"
4047 if test -n "$local_gnulib_dir"; then
4048 func_append actioncmd " --local-dir=$local_gnulib_dir"
4050 func_append actioncmd " --lib=$libname"
4051 func_append actioncmd " --source-base=$sourcebase"
4052 func_append actioncmd " --m4-base=$m4base"
4053 if test -n "$pobase"; then
4054 func_append actioncmd " --po-base=$pobase"
4056 func_append actioncmd " --doc-base=$docbase"
4057 func_append actioncmd " --tests-base=$testsbase"
4058 func_append actioncmd " --aux-dir=$auxdir"
4059 if test -n "$inctests"; then
4060 func_append actioncmd " --with-tests"
4062 if test -n "$incobsolete"; then
4063 func_append actioncmd " --with-obsolete"
4065 if test -n "$inc_cxx_tests"; then
4066 func_append actioncmd " --with-c++-tests"
4068 if test -n "$inc_longrunning_tests"; then
4069 func_append actioncmd " --with-longrunning-tests"
4071 if test -n "$inc_privileged_tests"; then
4072 func_append actioncmd " --with-privileged-tests"
4074 if test -n "$inc_unportable_tests"; then
4075 func_append actioncmd " --with-unportable-tests"
4077 if test -n "$inc_all_tests"; then
4078 func_append actioncmd " --with-all-tests"
4080 for module in $avoidlist; do
4081 func_append actioncmd " --avoid=$module"
4083 if test -n "$lgpl"; then
4084 if test "$lgpl" = yes; then
4085 func_append actioncmd " --lgpl"
4087 func_append actioncmd " --lgpl=$lgpl"
4090 if test -n "$makefile_name"; then
4091 func_append actioncmd " --makefile-name=$makefile_name"
4093 if test "$libtool" = true; then
4094 func_append actioncmd " --libtool"
4096 func_append actioncmd " --no-libtool"
4098 func_append actioncmd " --macro-prefix=$macro_prefix"
4099 if test -n "$po_domain"; then
4100 func_append actioncmd " --po-domain=$po_domain"
4102 if test -n "$vc_files"; then
4103 if test "$vc_files" = true; then
4104 func_append actioncmd " --vc-files"
4106 func_append actioncmd " --no-vc-files"
4109 func_append actioncmd " `echo $specified_modules`"
4111 # Default the makefile name to Makefile.am.
4112 if test -n "$makefile_name"; then
4113 makefile_am=$makefile_name
4115 makefile_am=Makefile.am
4118 # Create normal Makefile.ams.
4121 # Setup list of Makefile.am edits that are to be performed afterwards.
4122 # Some of these edits apply to files that we will generate; others are
4123 # under the responsibility of the developer.
4125 # func_note_Makefile_am_edit dir var value
4126 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
4128 func_note_Makefile_am_edit ()
4130 makefile_am_edits=`expr $makefile_am_edits + 1`
4131 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
4132 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
4133 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
4135 if test "$makefile_am" = Makefile.am; then
4136 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
4137 sourcebase_base=`basename "$sourcebase"`
4138 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
4140 if test -n "$pobase"; then
4141 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
4142 pobase_base=`basename "$pobase"`
4143 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4145 if test -n "$inctests"; then
4146 if test "$makefile_am" = Makefile.am; then
4147 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4148 testsbase_base=`basename "$testsbase"`
4149 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4152 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4154 # Find the first parent directory of $m4base that contains or will contain
4156 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4158 sed_butlast='s,[^/][^/]*//*$,,'
4159 dir1="${m4base}/"; dir2=""
4160 while test -n "$dir1" \
4161 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4162 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4163 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4164 || { test -n "$inctests" \
4165 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4166 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4167 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4168 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4170 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4173 # Create library makefile.
4174 func_dest_tmpfilename $sourcebase/$makefile_am
4175 destfile="$sourcebase/$makefile_am"
4176 modules="$main_modules"
4177 func_emit_lib_Makefile_am > "$tmpfile"
4178 if test -f "$destdir"/$sourcebase/$makefile_am; then
4179 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
4183 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4184 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4185 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4187 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4193 echo "Creating $sourcebase/$makefile_am"
4194 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4196 echo "Create $sourcebase/$makefile_am"
4199 func_append added_files "$sourcebase/$makefile_am$nl"
4202 # Create po/ directory.
4203 if test -n "$pobase"; then
4204 # Create po makefile and auxiliary files.
4205 for file in Makefile.in.in remove-potcdate.sin; do
4206 func_dest_tmpfilename $pobase/$file
4207 func_lookup_file build-aux/po/$file
4208 cat "$lookedup_file" > "$tmpfile"
4209 if test -f "$destdir"/$pobase/$file; then
4210 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
4214 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4215 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4216 mv -f "$tmpfile" "$destdir"/$pobase/$file
4218 echo "Update $pobase/$file (backup in $pobase/$file~)"
4224 echo "Creating $pobase/$file"
4225 mv -f "$tmpfile" "$destdir"/$pobase/$file
4227 echo "Create $pobase/$file"
4230 func_append added_files "$pobase/$file$nl"
4233 # Create po makefile parameterization, part 1.
4234 func_dest_tmpfilename $pobase/Makevars
4235 func_emit_po_Makevars > "$tmpfile"
4236 if test -f "$destdir"/$pobase/Makevars; then
4237 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
4241 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4242 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4243 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4245 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4251 echo "Creating $pobase/Makevars"
4252 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4254 echo "Create $pobase/Makevars"
4257 func_append added_files "$pobase/Makevars$nl"
4259 # Create po makefile parameterization, part 2.
4260 func_dest_tmpfilename $pobase/POTFILES.in
4261 func_emit_po_POTFILES_in > "$tmpfile"
4262 if test -f "$destdir"/$pobase/POTFILES.in; then
4263 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
4267 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4268 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
4269 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4271 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4277 echo "Creating $pobase/POTFILES.in"
4278 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4280 echo "Create $pobase/POTFILES.in"
4283 func_append added_files "$pobase/POTFILES.in$nl"
4286 TP_URL="http://translationproject.org/latest/"
4287 TP_RSYNC_URI="translationproject.org::tp/latest/"
4289 echo "Fetching gnulib PO files from $TP_URL"
4290 (cd "$destdir"/$pobase \
4291 && { # Prefer rsync over wget if it is available, since it consumes
4292 # less network bandwidth, due to compression.
4293 if type rsync 2>/dev/null | grep / > /dev/null; then
4294 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
4296 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
4301 echo "Fetch gnulib PO files from $TP_URL"
4303 # Create po/LINGUAS.
4305 func_dest_tmpfilename $pobase/LINGUAS
4306 (cd "$destdir"/$pobase \
4307 && { echo '# Set of available languages.'
4308 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
4311 if test -f "$destdir"/$pobase/LINGUAS; then
4312 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
4315 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4316 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
4317 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4320 echo "Creating $pobase/LINGUAS"
4321 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4322 func_append added_files "$pobase/LINGUAS$nl"
4325 if test -f "$destdir"/$pobase/LINGUAS; then
4326 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4328 echo "Create $pobase/LINGUAS"
4333 # Create m4/gnulib-cache.m4.
4334 func_dest_tmpfilename $m4base/gnulib-cache.m4
4336 func_emit_copyright_notice
4338 echo "# This file represents the specification of how gnulib-tool is used."
4339 echo "# It acts as a cache: It is written and read by gnulib-tool."
4340 echo "# In projects that use version control, this file is meant to be put under"
4341 echo "# version control, like the configure.ac and various Makefile.am files."
4344 echo "# Specification in the form of a command-line invocation:"
4347 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
4348 # Store the local_gnulib_dir relative to destdir.
4349 case "$local_gnulib_dir" in
4351 relative_local_gnulib_dir="$local_gnulib_dir" ;;
4354 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
4356 # destdir, local_gnulib_dir are both relative.
4357 func_relativize "$destdir" "$local_gnulib_dir"
4358 relative_local_gnulib_dir="$reldir" ;;
4361 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
4363 echo "$specified_modules" | sed -e 's/^/ /g'
4365 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
4366 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
4367 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
4368 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
4369 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
4370 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
4371 echo "gl_AVOID([$avoidlist])"
4372 echo "gl_SOURCE_BASE([$sourcebase])"
4373 echo "gl_M4_BASE([$m4base])"
4374 echo "gl_PO_BASE([$pobase])"
4375 echo "gl_DOC_BASE([$docbase])"
4376 echo "gl_TESTS_BASE([$testsbase])"
4377 test -z "$inctests" || echo "gl_WITH_TESTS"
4378 echo "gl_LIB([$libname])"
4379 if test -n "$lgpl"; then
4380 if test "$lgpl" = yes; then
4383 echo "gl_LGPL([$lgpl])"
4386 echo "gl_MAKEFILE_NAME([$makefile_name])"
4387 if test "$libtool" = true; then
4390 echo "gl_MACRO_PREFIX([$macro_prefix])"
4391 echo "gl_PO_DOMAIN([$po_domain])"
4392 if test -n "$vc_files"; then
4393 echo "gl_VC_FILES([$vc_files])"
4396 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4397 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
4401 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4402 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
4403 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4405 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4409 echo "# gnulib-cache.m4 ends here"
4416 echo "Creating $m4base/gnulib-cache.m4"
4417 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4419 echo "Create $m4base/gnulib-cache.m4"
4425 # Create m4/gnulib-comp.m4.
4426 func_dest_tmpfilename $m4base/gnulib-comp.m4
4428 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
4429 func_emit_copyright_notice
4431 echo "# This file represents the compiled summary of the specification in"
4432 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
4433 echo "# to be invoked from configure.ac."
4434 echo "# In projects that use version control, this file can be treated like"
4435 echo "# other built files."
4438 echo "# This macro should be invoked from $configure_ac, in the section"
4439 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
4440 echo "# any checks for libraries, header files, types and library functions."
4441 echo "AC_DEFUN([${macro_prefix}_EARLY],"
4443 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4444 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4445 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4446 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4447 echo " AC_REQUIRE([AC_PROG_RANLIB])"
4448 if test -n "$uses_subdirs"; then
4449 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
4451 for module in $final_modules; do
4453 if test -n "$module"; then
4454 echo "# Code from module $module:"
4455 func_get_autoconf_early_snippet "$module"
4458 | sed -e '/^$/d;' -e 's/^/ /'
4461 echo "# This macro should be invoked from $configure_ac, in the section"
4462 echo "# \"Check for header files, types and library functions\"."
4463 echo "AC_DEFUN([${macro_prefix}_INIT],"
4465 if test "$libtool" = true; then
4466 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4467 echo " gl_cond_libtool=true"
4469 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4470 echo " gl_cond_libtool=false"
4472 echo " gl_ltlibdeps="
4474 if test "$auxdir" != "build-aux"; then
4475 sed_replace_build_aux='
4477 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4478 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4482 sed_replace_build_aux="$sed_noop"
4484 echo " gl_m4_base='$m4base'"
4485 func_emit_initmacro_start $macro_prefix
4486 echo " gl_source_base='$sourcebase'"
4487 for module in $main_modules; do
4489 if test -n "$module"; then
4490 echo " # Code from module $module:"
4491 func_get_autoconf_snippet "$module" \
4492 | sed -e '/^$/d;' -e 's/^/ /' \
4493 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4494 -e "$sed_replace_build_aux"
4495 if test "$module" = 'alloca' && test "$libtool" = true; then
4496 echo 'changequote(,)dnl'
4497 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4498 echo 'changequote([, ])dnl'
4499 echo 'AC_SUBST([LTALLOCA])'
4503 echo " # End of code from modules"
4504 func_emit_initmacro_end $macro_prefix
4505 echo " gltests_libdeps="
4506 echo " gltests_ltlibdeps="
4507 func_emit_initmacro_start ${macro_prefix}tests
4508 echo " gl_source_base='$testsbase'"
4509 # Define a tests witness macro that depends on the package.
4510 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
4511 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
4512 echo "changequote(,)dnl"
4513 echo " ${macro_prefix}tests_WITNESS=IN_\`echo \"\${PACKAGE-\$PACKAGE_TARNAME}\" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'\`_GNULIB_TESTS"
4514 echo "changequote([, ])dnl"
4515 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
4516 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
4517 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
4518 for module in $testsrelated_modules; do
4520 if test -n "$module"; then
4521 func_get_autoconf_snippet "$module" \
4522 | sed -e '/^$/d;' -e 's/^/ /' \
4523 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4524 -e "$sed_replace_build_aux" \
4525 -e 's/\$gl_cond_libtool/false/g' \
4526 -e 's/gl_libdeps/gltests_libdeps/g' \
4527 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4530 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
4531 func_emit_initmacro_end ${macro_prefix}tests
4532 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4533 # created using libtool, because libtool already handles the dependencies.
4534 if test "$libtool" != true; then
4535 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4536 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4537 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4538 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4539 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4541 if $use_libtests; then
4542 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
4543 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
4546 func_emit_initmacro_done $macro_prefix $sourcebase
4547 func_emit_initmacro_done ${macro_prefix}tests $testsbase
4549 echo "# This macro records the list of files which have been installed by"
4550 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
4551 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
4552 echo "$files" | sed -e 's,^, ,'
4555 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4556 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
4560 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4561 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
4562 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4564 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4568 echo "# gnulib-comp.m4 ends here"
4575 echo "Creating $m4base/gnulib-comp.m4"
4576 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4578 echo "Create $m4base/gnulib-comp.m4"
4584 if test -n "$inctests"; then
4585 # Create tests makefile.
4586 func_dest_tmpfilename $testsbase/$makefile_am
4587 destfile="$testsbase/$makefile_am"
4588 modules="$testsrelated_modules"
4589 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
4590 if test -f "$destdir"/$testsbase/$makefile_am; then
4591 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
4595 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4596 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
4597 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4599 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4605 echo "Creating $testsbase/$makefile_am"
4606 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4608 echo "Create $testsbase/$makefile_am"
4611 func_append added_files "$testsbase/$makefile_am$nl"
4615 if test "$vc_files" != false; then
4616 # Update the .cvsignore and .gitignore files.
4617 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
4618 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
4619 # Treat gnulib-comp.m4 like an added file, even if it already existed.
4620 echo "$m4base/|A|gnulib-comp.m4"
4621 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
4622 { # Rearrange file descriptors. Needed because "while ... done < ..."
4623 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4624 exec 5<&0 < "$tmp"/fileset-changes
4625 func_update_ignorelist ()
4628 if test "$ignore" = .gitignore; then
4629 # In a .gitignore file, "foo" applies to the current directory and all
4630 # subdirectories, whereas "/foo" applies to the current directory only.
4633 doubly_escaped_anchor='\\/'
4637 doubly_escaped_anchor=''
4639 if test -f "$destdir/$dir$ignore"; then
4640 if test -n "$dir_added" || test -n "$dir_removed"; then
4641 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
4642 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
4643 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
4644 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
4645 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
4647 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
4649 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4650 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
4651 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
4652 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
4653 } > "$tmp"/sed-ignore-removed
4654 { cat "$destdir/$dir$ignore"~
4655 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
4656 } | sed -f "$tmp"/sed-ignore-removed \
4657 > "$destdir/$dir$ignore"
4659 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4664 if test -n "$dir_added"; then
4666 echo "Creating $destdir/$dir$ignore"
4668 if test "$ignore" = .cvsignore; then
4670 # Automake generates Makefile rules that create .dirstamp files.
4673 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
4674 } > "$destdir/$dir$ignore"
4676 echo "Create $destdir/$dir$ignore"
4686 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
4687 func_update_ignorelist .cvsignore
4689 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
4690 func_update_ignorelist .gitignore
4697 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
4698 next_dir=`echo "$line" | sed -e 's,|.*,,'`
4699 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
4700 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
4701 if test "$next_dir" != "$last_dir"; then
4702 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4703 last_dir="$next_dir"
4708 A) func_append last_dir_added "$file$nl";;
4709 R) func_append last_dir_removed "$file$nl";;
4712 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4719 echo "You may need to add #include directives for the following .h files."
4720 # Intersect $specified_modules and $main_modules
4721 # (since $specified_modules is not necessarily of subset of $main_modules
4722 # - some may have been skipped through --avoid, and since the elements of
4723 # $main_modules but not in $specified_modules can go away without explicit
4724 # notice - through changes in the module dependencies).
4725 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
4726 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
4727 # First the #include <...> directives without #ifs, sorted for convenience,
4728 # then the #include "..." directives without #ifs, sorted for convenience,
4729 # then the #include directives that are surrounded by #ifs. Not sorted.
4730 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
4731 include_directive=`func_get_include_directive "$module"`
4732 case "$nl$include_directive" in
4734 echo "$include_directive" 1>&5
4737 echo "$include_directive" | grep -v 'include "' 1>&6
4738 echo "$include_directive" | grep 'include "' 1>&7
4741 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
4743 LC_ALL=C sort -u "$tmp"/include-angles
4744 LC_ALL=C sort -u "$tmp"/include-quotes
4745 cat "$tmp"/include-if
4746 ) | sed -e '/^$/d' -e 's/^/ /'
4747 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
4749 for module in $main_modules; do
4750 func_get_link_directive "$module"
4752 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
4753 if test `wc -l < "$tmp"/link` != 0; then
4755 echo "You may need to use the following Makefile variables when linking."
4756 echo "Use them in <program>_LDADD when linking a program, or"
4757 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
4763 echo "Don't forget to"
4764 if test "$makefile_am" = Makefile.am; then
4765 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4767 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
4769 if test -n "$pobase"; then
4770 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
4772 if test -n "$inctests"; then
4773 if test "$makefile_am" = Makefile.am; then
4774 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4776 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
4780 while test $edit != $makefile_am_edits; do
4781 edit=`expr $edit + 1`
4782 eval dir=\"\$makefile_am_edit${edit}_dir\"
4783 eval var=\"\$makefile_am_edit${edit}_var\"
4784 eval val=\"\$makefile_am_edit${edit}_val\"
4785 if test -n "$var"; then
4786 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
4789 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
4790 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
4793 # func_create_testdir testdir modules
4795 # - local_gnulib_dir from --local-dir
4796 # - modcache true or false, from --cache-modules/--no-cache-modules
4797 # - auxdir directory relative to destdir where to place build aux files
4798 # - inctests true if tests should be included, blank otherwise
4799 # - incobsolete true if obsolete modules among dependencies should be
4800 # included, blank otherwise
4801 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
4803 # - excl_longrunning_tests true if long-runnings tests should be excluded,
4805 # - excl_privileged_tests true if tests that require root privileges should be
4806 # excluded, blank otherwise
4807 # - excl_unportable_tests true if tests that fail on some platforms should be
4808 # excluded, blank otherwise
4809 # - avoidlist list of modules to avoid
4810 # - libtool true if --libtool was given, false if --no-libtool was
4811 # given, blank otherwise
4812 # - symbolic true if files should be symlinked, copied otherwise
4813 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4815 func_create_testdir ()
4819 if test -z "$modules"; then
4820 # All modules together.
4821 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4822 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
4823 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
4824 modules=`func_all_modules`
4825 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
4827 specified_modules="$modules"
4829 # Canonicalize the list of specified modules.
4830 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4832 # Unlike in func_import, here we want to include all kinds of tests for the
4833 # directly specified modules, but not for dependencies.
4834 inc_all_direct_tests=true
4835 inc_all_indirect_tests="$inc_all_tests"
4837 # Check that the license of every module is consistent with the license of
4839 saved_inctests="$inctests"
4840 # When computing transitive closures, don't consider $module to depend on
4841 # $module-tests. Need this becauses tests are implicitly GPL and may depend
4842 # on GPL modules - therefore we don't want a warning in this case.
4844 for requested_module in $specified_modules; do
4845 requested_license=`func_get_license "$requested_module"`
4846 if test "$requested_license" != GPL; then
4847 # Here we use func_modules_transitive_closure, not just
4848 # func_get_dependencies, so that we also detect weird situations like
4849 # an LGPL module which depends on a GPLed build tool module which depends
4851 modules="$requested_module"
4852 func_modules_transitive_closure
4853 for module in $modules; do
4854 license=`func_get_license "$module"`
4856 'GPLed build tool') ;;
4857 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4859 case "$requested_license" in
4862 GPLv2+ | LGPLv2+) ;;
4863 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4869 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4875 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4884 inctests="$saved_inctests"
4886 # Subdirectory names.
4896 # Determine final module list.
4897 modules="$specified_modules"
4898 func_modules_transitive_closure
4899 if test $verbose -ge 0; then
4900 func_show_module_list
4903 # Add the dummy module if needed.
4904 func_modules_add_dummy
4906 # Show banner notice of every module.
4909 # Determine final file list.
4910 func_modules_to_filelist
4911 if test $verbose -ge 0; then
4913 echo "$files" | sed -e 's/^/ /'
4916 rewritten='%REWRITTEN%'
4917 sed_rewrite_files="\
4918 s,^build-aux/,$rewritten$auxdir/,
4919 s,^doc/,$rewritten$docbase/,
4920 s,^lib/,$rewritten$sourcebase/,
4921 s,^m4/,$rewritten$m4base/,
4922 s,^tests/,$rewritten$testsbase/,
4926 # Create directories.
4927 for f in $files; do echo $f; done \
4928 | sed -e "$sed_rewrite_files" \
4929 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4930 | LC_ALL=C sort -u \
4932 { # Rearrange file descriptors. Needed because "while ... done < ..."
4933 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4934 exec 5<&0 < "$tmp"/dirs
4936 mkdir -p "$testdir/$d"
4941 # Copy files or make symbolic links.
4943 for f in $files; do echo $f; done \
4944 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
4947 { # Rearrange file descriptors. Needed because "while ... done < ..."
4948 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4949 exec 5<&0 < "$tmp"/files
4951 func_lookup_file "$f"
4952 if test -n "$lookedup_tmp"; then
4953 cp -p "$lookedup_file" "$testdir/$g"
4955 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
4956 if { test -n "$symbolic" \
4957 || { test -n "$lsymbolic" \
4958 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
4959 func_ln "$lookedup_file" "$testdir/$g"
4961 cp -p "$lookedup_file" "$testdir/$g"
4968 # Create Makefile.ams that are for testing.
4971 # No special edits are needed.
4974 # Create $sourcebase/Makefile.am.
4975 mkdir -p "$testdir/$sourcebase"
4976 destfile="$sourcebase/Makefile.am"
4977 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
4978 any_uses_subdirs="$uses_subdirs"
4980 # Create $m4base/Makefile.am.
4981 mkdir -p "$testdir/$m4base"
4982 (echo "## Process this file with automake to produce Makefile.in."
4988 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
4991 ) > "$testdir/$m4base/Makefile.am"
4993 subdirs="$sourcebase $m4base"
4994 subdirs_with_configure_ac=""
4996 if false && test -f "$testdir"/$m4base/gettext.m4; then
4997 # Avoid stupid error message from automake:
4998 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
4999 mkdir -p "$testdir/po"
5000 (echo "## Process this file with automake to produce Makefile.in."
5001 ) > "$testdir/po/Makefile.am"
5002 func_append subdirs " po"
5005 if test -n "$inctests"; then
5006 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
5007 # Viewed from the $testsbase subdirectory, $auxdir is different.
5008 saved_auxdir="$auxdir"
5009 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
5010 # Create $testsbase/Makefile.am.
5012 destfile="$testsbase/Makefile.am"
5013 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
5014 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
5015 # Create $testsbase/configure.ac.
5016 (echo "# Process this file with autoconf to produce a configure script."
5017 echo "AC_INIT([dummy], [0])"
5018 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5019 echo "AM_INIT_AUTOMAKE"
5021 echo "AC_CONFIG_HEADERS([config.h])"
5024 echo "AC_PROG_INSTALL"
5025 echo "AC_PROG_MAKE_SET"
5026 echo "AC_PROG_RANLIB"
5028 if test -n "$uses_subdirs"; then
5029 echo "AM_PROG_CC_C_O"
5032 for module in $modules; do
5034 if test -n "$module"; then
5036 gnumakefile | maintainer-makefile)
5037 # These modules are meant to be used only in the top-level directory.
5040 func_get_autoconf_early_snippet "$module"
5045 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5046 if test "$libtool" = true; then
5047 echo "LT_INIT([win32-dll])"
5048 echo "LT_LANG([C++])"
5049 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5050 echo "gl_cond_libtool=true"
5052 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5053 echo "gl_cond_libtool=false"
5055 echo "gl_ltlibdeps="
5057 # Wrap the set of autoconf snippets into an autoconf macro that is then
5058 # invoked. This is needed because autoconf does not support AC_REQUIRE
5060 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5061 # but we want the AC_REQUIRE to have its normal meaning (provide one
5062 # expansion of the required macro before the current point, and only one
5064 echo "AC_DEFUN([gl_INIT], ["
5065 sed_replace_build_aux='
5067 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5068 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5071 echo "gl_m4_base='../$m4base'"
5072 func_emit_initmacro_start $macro_prefix
5073 # We don't have explicit ordering constraints between the various
5074 # autoconf snippets. It's cleanest to put those of the library before
5075 # those of the tests.
5076 echo "gl_source_base='../$sourcebase'"
5077 for module in $modules; do
5078 func_verify_nontests_module
5079 if test -n "$module"; then
5081 gnumakefile | maintainer-makefile)
5082 # These modules are meant to be used only in the top-level directory.
5085 func_get_autoconf_snippet "$module" \
5086 | sed -e "$sed_replace_build_aux"
5091 echo "gl_source_base='.'"
5092 for module in $modules; do
5093 func_verify_tests_module
5094 if test -n "$module"; then
5095 func_get_autoconf_snippet "$module" \
5096 | sed -e "$sed_replace_build_aux"
5099 func_emit_initmacro_end $macro_prefix
5100 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5101 # created using libtool, because libtool already handles the dependencies.
5102 if test "$libtool" != true; then
5103 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
5104 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5105 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5106 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5107 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5110 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
5114 # Usually $testsbase/config.h will be a superset of config.h. Verify this
5115 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
5116 echo "AH_TOP([#include \"../config.h\"])"
5118 echo "AC_CONFIG_FILES([Makefile])"
5120 ) > "$testdir/$testsbase/configure.ac"
5121 auxdir="$saved_auxdir"
5122 func_append subdirs " $testsbase"
5123 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
5126 # Create Makefile.am.
5127 (echo "## Process this file with automake to produce Makefile.in."
5129 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5131 echo "SUBDIRS = $subdirs"
5133 echo "ACLOCAL_AMFLAGS = -I $m4base"
5134 ) > "$testdir/Makefile.am"
5136 # Create configure.ac.
5137 (echo "# Process this file with autoconf to produce a configure script."
5138 echo "AC_INIT([dummy], [0])"
5139 if test "$auxdir" != "."; then
5140 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5142 echo "AM_INIT_AUTOMAKE"
5144 echo "AC_CONFIG_HEADERS([config.h])"
5147 echo "AC_PROG_INSTALL"
5148 echo "AC_PROG_MAKE_SET"
5150 echo "# For autobuild."
5151 echo "AC_CANONICAL_BUILD"
5152 echo "AC_CANONICAL_HOST"
5154 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5155 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5156 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5157 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5159 echo "AC_PROG_RANLIB"
5161 if test -n "$any_uses_subdirs"; then
5162 echo "AM_PROG_CC_C_O"
5165 for module in $modules; do
5166 func_verify_nontests_module
5167 if test -n "$module"; then
5168 func_get_autoconf_early_snippet "$module"
5171 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5172 if test "$libtool" = true; then
5173 echo "LT_INIT([win32-dll])"
5174 echo "LT_LANG([C++])"
5175 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5176 echo "gl_cond_libtool=true"
5178 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5179 echo "gl_cond_libtool=false"
5181 echo "gl_ltlibdeps="
5183 # Wrap the set of autoconf snippets into an autoconf macro that is then
5184 # invoked. This is needed because autoconf does not support AC_REQUIRE
5186 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5187 # but we want the AC_REQUIRE to have its normal meaning (provide one
5188 # expansion of the required macro before the current point, and only one
5190 echo "AC_DEFUN([gl_INIT], ["
5191 if test "$auxdir" != "build-aux"; then
5192 sed_replace_build_aux='
5194 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5195 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5199 sed_replace_build_aux="$sed_noop"
5201 echo "gl_m4_base='$m4base'"
5202 func_emit_initmacro_start $macro_prefix
5203 echo "gl_source_base='$sourcebase'"
5204 for module in $modules; do
5205 func_verify_nontests_module
5206 if test -n "$module"; then
5207 func_get_autoconf_snippet "$module" \
5208 | sed -e "$sed_replace_build_aux"
5211 func_emit_initmacro_end $macro_prefix
5212 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5213 # created using libtool, because libtool already handles the dependencies.
5214 if test "$libtool" != true; then
5215 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
5216 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5217 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5218 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5219 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5222 func_emit_initmacro_done $macro_prefix $sourcebase
5226 if test -n "$subdirs_with_configure_ac"; then
5227 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
5229 makefiles="Makefile"
5230 for d in $subdirs; do
5231 # For subdirs that have a configure.ac by their own, it's the subdir's
5232 # configure.ac which creates the subdir's Makefile.am, not this one.
5233 case " $subdirs_with_configure_ac " in
5235 *) func_append makefiles " $d/Makefile" ;;
5238 echo "AC_CONFIG_FILES([$makefiles])"
5240 ) > "$testdir/configure.ac"
5242 # Create autogenerated files.
5244 # Do not use "${AUTORECONF} --force --install", because it may invoke
5245 # autopoint, which brings in older versions of some of our .m4 files.
5246 if test -f $m4base/gettext.m4; then
5247 func_execute_command ${AUTOPOINT} --force || func_exit 1
5248 for f in $m4base/*.m4~; do
5250 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5254 if test "$libtool" = true; then
5255 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
5257 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
5258 if ! test -d build-aux; then
5259 func_execute_command mkdir build-aux || func_exit 1
5261 func_execute_command ${AUTOCONF} || func_exit 1
5262 func_execute_command ${AUTOHEADER} || func_exit 1
5263 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5265 if test -n "$inctests"; then
5266 # Create autogenerated files.
5267 (cd "$testdir/$testsbase" || func_exit 1
5268 # Do not use "${AUTORECONF} --force --install", because it may invoke
5269 # autopoint, which brings in older versions of some of our .m4 files.
5270 if test -f ../$m4base/gettext.m4; then
5271 func_execute_command ${AUTOPOINT} --force || func_exit 1
5272 for f in ../$m4base/*.m4~; do
5274 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5278 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
5279 if ! test -d ../build-aux; then
5280 func_execute_command mkdir ../build-aux
5282 func_execute_command ${AUTOCONF} || func_exit 1
5283 func_execute_command ${AUTOHEADER} || func_exit 1
5284 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5287 # Need to run configure and make once, to create built files that are to be
5288 # distributed (such as getdate.c).
5289 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
5290 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
5291 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5292 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5293 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
5294 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
5295 # such $(FOO_H) because they don't refer to distributed files.
5296 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5297 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5298 | sed -e "$sed_remove_make_variables"`
5299 distributed_built_sources=`for file in $built_sources; do
5300 case "$cleaned_files" in
5305 tests_distributed_built_sources=
5306 if test -n "$inctests"; then
5307 # Likewise for built files in the $testsbase directory.
5308 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5309 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5310 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
5311 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5312 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5313 | sed -e "$sed_remove_make_variables"`
5314 tests_distributed_built_sources=`for file in $tests_built_sources; do
5315 case "$tests_cleaned_files" in
5321 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
5323 ./configure || func_exit 1
5324 if test -n "$distributed_built_sources"; then
5326 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5327 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5332 if test -n "$tests_distributed_built_sources"; then
5334 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5335 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5340 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5347 # func_create_megatestdir megatestdir allmodules
5349 # - local_gnulib_dir from --local-dir
5350 # - modcache true or false, from --cache-modules/--no-cache-modules
5351 # - auxdir directory relative to destdir where to place build aux files
5352 func_create_megatestdir ()
5356 if test -z "$allmodules"; then
5357 allmodules=`func_all_modules`
5361 # First, all modules one by one.
5362 for onemodule in $allmodules; do
5363 func_create_testdir "$megatestdir/$onemodule" $onemodule
5364 func_append megasubdirs "$onemodule "
5366 # Then, all modules all together.
5367 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5368 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
5369 func_create_testdir "$megatestdir/ALL" "$allmodules"
5370 func_append megasubdirs "ALL"
5373 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
5374 vc_witness="$gnulib_dir/CVS/Entries"; \
5376 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
5378 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
5379 | sed -e 's,January,01,' -e 's,Jan,01,' \
5380 -e 's,February,02,' -e 's,Feb,02,' \
5381 -e 's,March,03,' -e 's,Mar,03,' \
5382 -e 's,April,04,' -e 's,Apr,04,' \
5384 -e 's,June,06,' -e 's,Jun,06,' \
5385 -e 's,July,07,' -e 's,Jul,07,' \
5386 -e 's,August,08,' -e 's,Aug,08,' \
5387 -e 's,September,09,' -e 's,Sep,09,' \
5388 -e 's,October,10,' -e 's,Oct,10,' \
5389 -e 's,November,11,' -e 's,Nov,11,' \
5390 -e 's,December,12,' -e 's,Dec,12,' \
5391 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
5392 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
5394 echo "CVSDATE=$cvsdate"
5395 echo ": \${MAKE=make}"
5396 echo "test -d logs || mkdir logs"
5397 echo "for module in $megasubdirs; do"
5398 echo " echo \"Working on module \$module...\""
5399 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
5400 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
5403 echo " : autobuild project... \$module"
5404 echo " : autobuild revision... cvs-\$CVSDATE-000000"
5405 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
5406 echo " : autobuild hostname... \`hostname\`"
5407 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
5409 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
5411 ) > "$megatestdir/do-autobuild"
5412 chmod a+x "$megatestdir/do-autobuild"
5414 # Create Makefile.am.
5415 (echo "## Process this file with automake to produce Makefile.in."
5417 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5419 echo "SUBDIRS = $megasubdirs"
5421 echo "EXTRA_DIST = do-autobuild"
5422 ) > "$megatestdir/Makefile.am"
5424 # Create configure.ac.
5425 (echo "# Process this file with autoconf to produce a configure script."
5426 echo "AC_INIT([dummy], [0])"
5427 if test "$auxdir" != "."; then
5428 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5430 echo "AM_INIT_AUTOMAKE"
5432 echo "AC_PROG_MAKE_SET"
5434 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
5435 echo "AC_CONFIG_FILES([Makefile])"
5437 ) > "$megatestdir/configure.ac"
5439 # Create autogenerated files.
5441 # Do not use "${AUTORECONF} --install", because autoreconf operates
5442 # recursively, but the subdirectories are already finished, therefore
5443 # calling autoreconf here would only waste lots of CPU time.
5444 func_execute_command ${ACLOCAL} || func_exit 1
5445 func_execute_command mkdir build-aux
5446 func_execute_command ${AUTOCONF} || func_exit 1
5447 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5453 func_fatal_error "no mode specified" ;;
5460 # sed expression that converts a literal to a basic regular expression.
5461 # Needs to handle . [ \ * ^ $.
5462 sed_literal_to_basic_regex='s/\\/\\\\/g
5468 if test -f "$gnulib_dir/$filename" \
5469 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
5470 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
5471 filename_line_regex='^'"$filename_anywhere_regex"'$'
5474 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
5475 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
5476 (cd "$local_gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_anywhere_regex" /dev/null | sed -e 's,^modules/,,' -e 's,\.diff$,,')
5479 | func_sanitize_modulelist \
5482 for module in $module_candidates; do
5483 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
5488 func_warning "file $filename does not exist"
5493 import | add-import | remove-import | update )
5496 if test -z "$destdir"; then
5499 test -d "$destdir" \
5500 || func_fatal_error "destination directory does not exist: $destdir"
5502 # Prefer configure.ac to configure.in.
5503 if test -f "$destdir"/configure.ac; then
5504 configure_ac="$destdir/configure.ac"
5506 if test -f "$destdir"/configure.in; then
5507 configure_ac="$destdir/configure.in"
5509 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
5513 # Analyze configure.ac.
5515 guessed_libtool=false
5520 /AC_CONFIG_AUX_DIR/ {
5521 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
5523 /A[CM]_PROG_LIBTOOL/ {
5524 s,^.*$,guessed_libtool=true,p
5526 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
5528 if test -z "$auxdir"; then
5529 auxdir="$guessed_auxdir"
5532 # Determine where to apply func_import.
5533 if test "$mode" = import; then
5534 # Apply func_import to a particular gnulib directory.
5535 # The command line contains the complete specification; don't look at
5536 # the contents of gnulib-cache.m4.
5537 test -n "$supplied_libname" || supplied_libname=true
5538 test -n "$sourcebase" || sourcebase="lib"
5539 test -n "$m4base" || m4base="m4"
5540 test -n "$docbase" || docbase="doc"
5541 test -n "$testsbase" || testsbase="tests"
5542 test -n "$macro_prefix" || macro_prefix="gl"
5545 if test -n "$m4base"; then
5546 # Apply func_import to a particular gnulib directory.
5547 # Any number of additional modules can be given.
5548 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
5549 # First use of gnulib in the given m4base.
5550 test -n "$supplied_libname" || supplied_libname=true
5551 test -n "$sourcebase" || sourcebase="lib"
5552 test -n "$docbase" || docbase="doc"
5553 test -n "$testsbase" || testsbase="tests"
5554 test -n "$macro_prefix" || macro_prefix="gl"
5558 # Apply func_import to all gnulib directories.
5559 # To get this list of directories, look at Makefile.am. (Not at
5560 # configure, because it may be omitted from version control. Also,
5561 # don't run "find $destdir -name gnulib-cache.m4", as it might be
5565 if test -f "$destdir"/Makefile.am; then
5566 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
5568 for arg in $aclocal_amflags; do
5569 if test -n "$m4dir_is_next"; then
5570 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
5574 if test -f "$destdir/$arg"/gnulib-cache.m4; then
5575 func_append m4dirs " $arg"
5576 m4dirs_count=`expr $m4dirs_count + 1`
5582 if test "X$arg" = "X-I"; then
5590 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
5591 if test -f "$destdir"/aclocal.m4; then
5592 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
5593 sedexpr2='s,^[^/]*$,.,'
5594 sedexpr3='s,/[^/]*$,,'
5595 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
5596 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
5597 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
5600 if test $m4dirs_count = 0; then
5601 # First use of gnulib in a package.
5602 # Any number of additional modules can be given.
5603 test -n "$supplied_libname" || supplied_libname=true
5604 test -n "$sourcebase" || sourcebase="lib"
5606 test -n "$docbase" || docbase="doc"
5607 test -n "$testsbase" || testsbase="tests"
5608 test -n "$macro_prefix" || macro_prefix="gl"
5611 if test $m4dirs_count = 1; then
5612 # There's only one use of gnulib here. Assume the user means it.
5613 # Any number of additional modules can be given.
5614 for m4base in $m4dirs; do
5618 # Ambiguous - guess what the user meant.
5619 if test $# = 0; then
5620 # No further arguments. Guess the user wants to update all of them.
5621 for m4base in $m4dirs; do
5622 # Perform func_import in a subshell, so that variable values
5624 # local_gnulib_dir, incobsolete, inc_cxx_tests,
5625 # inc_longrunning_tests, inc_privileged_tests,
5626 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
5627 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
5628 # makefile_name, libtool, macro_prefix, po_domain, vc_files
5629 # don't propagate from one directory to another.
5630 (func_import) || func_exit 1
5634 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
5643 if test -z "$destdir"; then
5644 func_fatal_error "please specify --dir option"
5647 test -d "$destdir" \
5648 || func_fatal_error "could not create destination directory"
5649 test -n "$auxdir" || auxdir="build-aux"
5650 func_create_testdir "$destdir" "$*"
5653 create-megatestdir )
5654 if test -z "$destdir"; then
5655 func_fatal_error "please specify --dir option"
5657 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5658 test -n "$auxdir" || auxdir="build-aux"
5659 func_create_megatestdir "$destdir" "$*"
5663 test -n "$destdir" || destdir=testdir$$
5664 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5665 test -n "$auxdir" || auxdir="build-aux"
5666 func_create_testdir "$destdir" "$*"
5670 ../configure || func_exit 1
5671 $MAKE || func_exit 1
5672 $MAKE check || func_exit 1
5673 $MAKE distclean || func_exit 1
5674 remaining=`find . -type f -print`
5675 if test -n "$remaining"; then
5676 echo "Remaining files:" $remaining 1>&2
5677 echo "gnulib-tool: *** Stop." 1>&2
5686 test -n "$destdir" || destdir=testdir$$
5687 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5688 test -n "$auxdir" || auxdir="build-aux"
5689 func_create_megatestdir "$destdir" "$*"
5697 remaining=`find . -type f -print`
5698 if test -n "$remaining"; then
5699 echo "Remaining files:" $remaining 1>&2
5700 echo "gnulib-tool: *** Stop." 1>&2
5708 extract-description )
5712 if test -n "$module"; then
5713 func_get_description "$module"
5722 if test -n "$module"; then
5723 func_get_comment "$module"
5732 if test -n "$module"; then
5733 func_get_status "$module"
5742 if test -n "$module"; then
5743 func_get_notice "$module"
5748 extract-applicability )
5752 if test -n "$module"; then
5753 func_get_applicability "$module"
5762 if test -n "$module"; then
5763 func_get_filelist "$module"
5768 extract-dependencies )
5772 if test -n "$module"; then
5773 func_get_dependencies "$module"
5778 extract-autoconf-snippet )
5782 if test -n "$module"; then
5783 func_get_autoconf_snippet "$module"
5788 extract-automake-snippet )
5792 if test -n "$module"; then
5793 func_get_automake_snippet "$module"
5798 extract-include-directive )
5802 if test -n "$module"; then
5803 func_get_include_directive "$module"
5808 extract-link-directive )
5812 if test -n "$module"; then
5813 func_get_link_directive "$module"
5822 if test -n "$module"; then
5823 func_get_license "$module"
5828 extract-maintainer )
5832 if test -n "$module"; then
5833 func_get_maintainer "$module"
5838 extract-tests-module )
5842 if test -n "$module"; then
5843 func_get_tests_module "$module"
5849 # Verify the number of arguments.
5850 if test $# -lt 1 || test $# -gt 2; then
5851 func_fatal_error "invalid number of arguments for --$mode"
5854 # The first argument is the file to be copied.
5856 # Verify the file exists.
5857 func_lookup_file "$f"
5859 # The second argument is the destination; either a directory ot a file.
5860 # It defaults to the current directory.
5862 test -n "$dest" || dest='.'
5863 test -n "$sourcebase" || sourcebase="lib"
5864 test -n "$m4base" || m4base="m4"
5865 test -n "$docbase" || docbase="doc"
5866 test -n "$testsbase" || testsbase="tests"
5867 test -n "$auxdir" || auxdir="build-aux"
5868 rewritten='%REWRITTEN%'
5869 sed_rewrite_files="\
5870 s,^build-aux/,$rewritten$auxdir/,
5871 s,^doc/,$rewritten$docbase/,
5872 s,^lib/,$rewritten$sourcebase/,
5873 s,^m4/,$rewritten$m4base/,
5874 s,^tests/,$rewritten$testsbase/,
5877 if test -d "$dest"; then
5879 g=`echo "$f" | sed -e "$sed_rewrite_files"`
5881 destdir=`dirname "$dest"`
5882 g=`basename "$dest"`
5885 # Create the directory for destfile.
5886 d=`dirname "$destdir/$g"`
5888 if test -n "$d" && test ! -d "$d"; then
5889 mkdir -p "$d" || func_fatal_error "failed"
5893 func_dest_tmpfilename "$g"
5894 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5895 already_present=true
5896 if test -f "$destdir/$g"; then
5897 # The file already exists.
5901 # Don't protest if the file should be there but isn't: it happens
5902 # frequently that developers don't put autogenerated files under version
5910 func_fatal_error "unknown operation mode --$mode" ;;
5914 # Undo the effect of the previous 'trap' command. Some shellology:
5915 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
5916 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
5917 # exit); for the others we need to call 'exit' explicitly. The value of $? is
5918 # 128 + signal number and is set before the trap-registered command is run.
5920 trap 'func_exit $?' 1 2 3 13 15
5925 # indent-tabs-mode: nil
5926 # whitespace-check-buffer-indent: nil