README: Don't ask people to read a TeXinfo file.
[gnulib.git] / gnulib-tool
blobf3463b67e8da765673c6c06794dc56d879d195e5
1 #! /bin/sh
3 # Copyright (C) 2002-2017 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.
22 progname=$0
23 package=gnulib
24 nl='
26 IFS=" "" $nl"
28 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
29 AUTOCONFPATH=
30 #case $USER in
31 # bruno )
32 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
33 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
34 # ;;
35 #esac
37 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
38 AUTOMAKEPATH=
40 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
41 GETTEXTPATH=
43 # You can set LIBTOOLPATH to empty if libtoolize 2.x is already in your PATH.
44 LIBTOOLPATH=
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"
74 # You can set MAKE.
75 if test -z "${MAKE}"; then
76 MAKE=make
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;; \
90 *) true;; \
91 esac \
92 ; then
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.
109 sed_noop='s,x,x,'
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/
114 # s/o/u/
115 # indented comment
116 s/o/e/' 2>/dev/null | grep ge > /dev/null; then
117 sed_comments=true
118 else
119 sed_comments=false
122 # func_usage
123 # outputs to stdout the --help usage message.
124 func_usage ()
126 echo "\
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]
132 gnulib-tool --update
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]
153 Operation modes:
155 --list print the available module names
156 --find find the modules which contain the specified file
157 --import import the given modules into the current package
158 --add-import augment the list of imports from gnulib into the
159 current package, by adding the given modules;
160 if no modules are specified, update the current
161 package from the current gnulib
162 --remove-import reduce the list of imports from gnulib into the
163 current package, by removing the given modules
164 --update update the current package, restore files omitted
165 from version control
166 --create-testdir create a scratch package with the given modules
167 --create-megatestdir create a mega scratch package with the given modules
168 one by one and all together
169 --test test the combination of the given modules
170 (recommended to use CC=\"gcc -Wall\" here)
171 --megatest test the given modules one by one and all together
172 (recommended to use CC=\"gcc -Wall\" here)
173 --extract-description extract the description
174 --extract-comment extract the comment
175 --extract-status extract the status (obsolete etc.)
176 --extract-notice extract the notice or banner
177 --extract-applicability extract the applicability
178 --extract-filelist extract the list of files
179 --extract-dependencies extract the dependencies
180 --extract-autoconf-snippet extract the snippet for configure.ac
181 --extract-automake-snippet extract the snippet for library makefile
182 --extract-include-directive extract the #include directive
183 --extract-link-directive extract the linker directive
184 --extract-license report the license terms of the source files
185 under lib/
186 --extract-maintainer report the maintainer(s) inside gnulib
187 --extract-tests-module report the unit test module, if it exists
188 --copy-file copy a file that is not part of any module
189 --help Show this help text.
190 --version Show version and authorship information.
192 General options:
194 --dir=DIRECTORY Specify the target directory.
195 For --import, this specifies where your
196 configure.ac can be found. Defaults to current
197 directory.
198 --local-dir=DIRECTORY Specify a local override directory where to look
199 up files before looking in gnulib's directory.
200 --cache-modules Enable module caching optimization.
201 --no-cache-modules Disable module caching optimization.
202 --verbose Increase verbosity. May be repeated.
203 --quiet Decrease verbosity. May be repeated.
205 Options for --import, --add/remove-import, --update:
207 --dry-run Only print what would have been done.
209 Options for --import, --add/remove-import:
211 --with-tests Include unit tests for the included modules.
213 Options for --create-[mega]testdir, --[mega]test:
215 --without-tests Don't include unit tests for the included modules.
217 Options for --import, --add/remove-import,
218 --create-[mega]testdir, --[mega]test:
220 --with-obsolete Include obsolete modules when they occur among the
221 dependencies. By default, dependencies to obsolete
222 modules are ignored.
223 --with-c++-tests Include even unit tests for C++ interoperability.
224 --without-c++-tests Exclude unit tests for C++ interoperability.
225 --with-longrunning-tests
226 Include even unit tests that are long-runners.
227 --without-longrunning-tests
228 Exclude unit tests that are long-runners.
229 --with-privileged-tests
230 Include even unit tests that require root
231 privileges.
232 --without-privileged-tests
233 Exclude unit tests that require root privileges.
234 --with-unportable-tests
235 Include even unit tests that fail on some platforms.
236 --without-unportable-tests
237 Exclude unit tests that fail on some platforms.
238 --with-all-tests Include all kinds of problematic unit tests.
239 --avoid=MODULE Avoid including the given MODULE. Useful if you
240 have code that provides equivalent functionality.
241 This option can be repeated.
242 --conditional-dependencies
243 Support conditional dependencies (may save configure
244 time and object code).
245 --no-conditional-dependencies
246 Don't use conditional dependencies.
247 --libtool Use libtool rules.
248 --no-libtool Don't use libtool rules.
250 Options for --import, --add/remove-import:
252 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
253 --source-base=DIRECTORY
254 Directory relative to --dir where source code is
255 placed (default \"lib\").
256 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
257 placed (default \"m4\").
258 --po-base=DIRECTORY Directory relative to --dir where *.po files are
259 placed (default \"po\").
260 --doc-base=DIRECTORY Directory relative to --dir where doc files are
261 placed (default \"doc\").
262 --tests-base=DIRECTORY
263 Directory relative to --dir where unit tests are
264 placed (default \"tests\").
265 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
266 tools are placed (default comes from configure.ac).
267 --gnu-make Output for GNU Make instead of for the default
268 Automake
269 --lgpl[=2|=3orGPLv2|=3]
270 Abort if modules aren't available under the LGPL.
271 Also modify license template from GPL to LGPL.
272 The version number of the LGPL can be specified;
273 the default is currently LGPLv3.
274 --makefile-name=NAME Name of makefile in the source-base and tests-base
275 directories (default \"Makefile.am\", or
276 \"Makefile.in\" if --gnu-make).
277 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
278 'gl_INIT'. Default is 'gl'.
279 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
280 the package name. A suffix '-gnulib' is appended.
281 --witness-c-macro=NAME Specify the C macro that is defined when the
282 sources in this directory are compiled or used.
283 --vc-files Update version control related files.
284 --no-vc-files Don't update version control related files
285 (.gitignore and/or .cvsignore).
287 Options for --create-[mega]testdir, --[mega]test:
289 --single-configure Generate a single configure file, not a separate
290 configure file for the tests directory.
292 Options for --import, --add/remove-import, --update,
293 --create-[mega]testdir, --[mega]test:
295 -s, --symbolic, --symlink Make symbolic links instead of copying files.
296 --local-symlink Make symbolic links instead of copying files, only
297 for files from the local override directory.
299 Options for --import, --add/remove-import, --update:
301 -S, --more-symlinks Make symbolic links instead of copying files, and
302 don't replace copyright notices.
304 Report bugs to <bug-gnulib@gnu.org>."
307 # func_version
308 # outputs to stdout the --version message.
309 func_version ()
311 func_gnulib_dir
312 if test -d "$gnulib_dir"/.git \
313 && (git --version) >/dev/null 2>/dev/null \
314 && (date --version) >/dev/null 2>/dev/null; then
315 # gnulib checked out from git.
316 sed_extract_first_date='/^Date/{
317 s/^Date:[ ]*//p
320 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
321 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
322 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
323 date=`echo "$date" | sed -e "$sed_year_before_time"`
324 # Use GNU date to compute the time in GMT.
325 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
326 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
327 else
328 # gnulib copy without versioning information.
329 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
330 version=
332 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
333 echo "\
334 gnulib-tool (GNU $package $date)$version
335 Copyright (C) $year Free Software Foundation, Inc.
336 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
337 This is free software: you are free to change and redistribute it.
338 There is NO WARRANTY, to the extent permitted by law.
340 printf "Written by %s, %s, and %s.\n" "Bruno Haible" "Paul Eggert" "Simon Josefsson"
343 # func_emit_copyright_notice
344 # outputs to stdout a header for a generated file.
345 func_emit_copyright_notice ()
347 sed -n -e '/Copyright/ {
350 }' < "$self_abspathname"
351 echo "#"
352 echo "# This file is free software; you can redistribute it and/or modify"
353 echo "# it under the terms of the GNU General Public License as published by"
354 echo "# the Free Software Foundation; either version 3 of the License, or"
355 echo "# (at your option) any later version."
356 echo "#"
357 echo "# This file is distributed in the hope that it will be useful,"
358 echo "# but WITHOUT ANY WARRANTY; without even the implied warranty of"
359 echo "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
360 echo "# GNU General Public License for more details."
361 echo "#"
362 echo "# You should have received a copy of the GNU General Public License"
363 echo "# along with this file. If not, see <http://www.gnu.org/licenses/>."
364 echo "#"
365 echo "# As a special exception to the GNU General Public License,"
366 echo "# this file may be distributed as part of a program that"
367 echo "# contains a configuration script generated by Autoconf, under"
368 echo "# the same distribution terms as the rest of that program."
369 echo "#"
370 echo "# Generated by gnulib-tool."
373 # func_exit STATUS
374 # exits with a given status.
375 # This function needs to be used, rather than 'exit', when a 'trap' handler is
376 # in effect that refers to $?.
377 func_exit ()
379 (exit $1); exit $1
382 # func_gnulib_dir
383 # locates the directory where the gnulib repository lives
384 # Input:
385 # - progname name of this program
386 # Sets variables
387 # - self_abspathname absolute pathname of gnulib-tool
388 # - gnulib_dir absolute pathname of gnulib repository
389 func_gnulib_dir ()
391 case "$progname" in
392 /* | ?:*) self_abspathname="$progname" ;;
393 */*) self_abspathname=`pwd`/"$progname" ;;
395 # Look in $PATH.
396 # Iterate through the elements of $PATH.
397 # We use IFS=: instead of
398 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
399 # because the latter does not work when some PATH element contains spaces.
400 # We use a canonicalized $pathx instead of $PATH, because empty PATH
401 # elements are by definition equivalent to '.', however field splitting
402 # according to IFS=: loses empty fields in many shells:
403 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
404 # beginning, at the end, and in the middle),
405 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
406 # at the beginning and at the end,
407 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
408 # Solaris lose empty fields at the end.
409 # The 'case' statement is an optimization, to avoid evaluating the
410 # explicit canonicalization command when $PATH contains no empty fields.
411 self_abspathname=
412 if test "$PATH_SEPARATOR" = ";"; then
413 # On Windows, programs are searched in "." before $PATH.
414 pathx=".;$PATH"
415 else
416 # On Unix, we have to convert empty PATH elements to ".".
417 pathx="$PATH"
418 case :$PATH: in
419 *::*)
420 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
422 esac
424 save_IFS="$IFS"
425 IFS="$PATH_SEPARATOR"
426 for d in $pathx; do
427 IFS="$save_IFS"
428 test -z "$d" && d=.
429 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
430 self_abspathname="$d/$progname"
431 break
433 done
434 IFS="$save_IFS"
435 if test -z "$self_abspathname"; then
436 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
439 esac
440 while test -h "$self_abspathname"; do
441 # Resolve symbolic link.
442 linkval=`func_readlink "$self_abspathname"`
443 test -n "$linkval" || break
444 case "$linkval" in
445 /* | ?:* ) self_abspathname="$linkval" ;;
446 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
447 esac
448 done
449 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
452 # func_tmpdir
453 # creates a temporary directory.
454 # Input:
455 # - progname name of this program
456 # Sets variable
457 # - tmp pathname of freshly created temporary directory
458 func_tmpdir ()
460 # Use the environment variable TMPDIR, falling back to /tmp. This allows
461 # users to specify a different temporary directory, for example, if their
462 # /tmp is filled up or too small.
463 : ${TMPDIR=/tmp}
465 # Use the mktemp program if available. If not available, hide the error
466 # message.
467 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
468 test -n "$tmp" && test -d "$tmp"
469 } ||
471 # Use a simple mkdir command. It is guaranteed to fail if the directory
472 # already exists. $RANDOM is bash specific and expands to empty in shells
473 # other than bash, ksh and zsh. Its use does not increase security;
474 # rather, it minimizes the probability of failure in a very cluttered /tmp
475 # directory.
476 tmp=$TMPDIR/gl$$-$RANDOM
477 (umask 077 && mkdir "$tmp")
478 } ||
480 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
481 func_exit 1
485 # func_append var value
486 # appends the given value to the shell variable var.
487 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
488 # Use bash's += operator. It reduces complexity of appending repeatedly to
489 # a single variable from O(n^2) to O(n).
490 func_append ()
492 eval "$1+=\"\$2\""
494 fast_func_append=true
495 else
496 func_append ()
498 eval "$1=\"\$$1\$2\""
500 fast_func_append=false
503 # func_remove_prefix var prefix
504 # removes the given prefix from the value of the shell variable var.
505 # var should be the name of a shell variable.
506 # Its value should not contain a newline and not start or end with whitespace.
507 # prefix should not contain the characters "$`\{}[]^|.
508 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
509 func_remove_prefix ()
511 eval "$1=\${$1#\$2}"
513 fast_func_remove_prefix=true
514 else
515 func_remove_prefix ()
517 eval "value=\"\$$1\""
518 prefix="$2"
519 case "$prefix" in
520 *.*)
521 sed_escape_dots='s/\([.]\)/\\\1/g'
522 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
524 esac
525 value=`echo "$value" | sed -e "s|^${prefix}||"`
526 eval "$1=\"\$value\""
528 fast_func_remove_prefix=false
531 # Determine whether we should use ':' or ';' as PATH_SEPARATOR.
532 func_determine_path_separator ()
534 if test "${PATH_SEPARATOR+set}" != set; then
535 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
536 # contains only /bin. Note that ksh looks also at the FPATH variable,
537 # so we have to set that as well for the test.
538 PATH_SEPARATOR=:
539 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
540 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
541 || PATH_SEPARATOR=';'
546 # func_path_prepend pathvar directory
547 # puts directory before pathvar, delimiting directories by PATH_SEPARATOR.
548 # Newly added directory into pathvar has the highest priority.
549 func_path_prepend ()
551 if eval "test -n \"\$$1\""; then
552 eval "$1=\$2\$PATH_SEPARATOR\$$1"
553 else
554 eval "$1=\$2"
558 # func_path_append pathvar directory
559 # Similar to func_path_prepend except that the newest directory has the lowest
560 # priority.
561 func_path_append ()
563 if eval "test -n \"\$$1\""; then
564 func_append "$1" "$PATH_SEPARATOR$2"
565 else
566 eval "$1=\$2"
570 # func_path_foreach_inner
571 # helper for func_path_foreach because we need new 'args' array
572 # Input:
573 # - fpf_dir directory from local_gnulib_path
574 # - fpf_cb callback to be run for fpf_dir
575 func_path_foreach_inner ()
577 set %start% "$@"
578 for _fpf_arg
580 case $_fpf_arg in
581 %start%)
582 set dummy
584 %dir%)
585 set "$@" "$fpf_dir"
588 set "$@" "$_fpf_arg"
590 esac
591 done
592 shift
594 "$fpf_cb" "$@"
597 # func_path_foreach path method args
598 # Execute method for each directory in path. The method will be called
599 # like `method args` while any argument '%dir%' within args will be replaced
600 # with processed directory from path.
601 func_path_foreach ()
603 fpf_save_IFS=$IFS
604 fpf_dirs=$1 ; shift
605 fpf_cb=$1 ; shift
606 fpf_rc=false
608 IFS=$PATH_SEPARATOR
609 for fpf_dir in $fpf_dirs
611 func_path_foreach_inner "$@" && fpf_rc=:
612 done
613 IFS=$fpf_save_IFS
614 $fpf_rc
617 # func_remove_suffix var suffix
618 # removes the given suffix from the value of the shell variable var.
619 # var should be the name of a shell variable.
620 # Its value should not contain a newline and not start or end with whitespace.
621 # suffix should not contain the characters "$`\{}[]^|.
622 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
623 func_remove_suffix ()
625 eval "$1=\${$1%\$2}"
627 fast_func_remove_suffix=true
628 else
629 func_remove_suffix ()
631 eval "value=\"\$$1\""
632 suffix="$2"
633 case "$suffix" in
634 *.*)
635 sed_escape_dots='s/\([.]\)/\\\1/g'
636 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
638 esac
639 value=`echo "$value" | sed -e "s|${suffix}\$||"`
640 eval "$1=\"\$value\""
642 fast_func_remove_suffix=false
645 # func_fatal_error message
646 # outputs to stderr a fatal error message, and terminates the program.
647 # Input:
648 # - progname name of this program
649 func_fatal_error ()
651 echo "$progname: *** $1" 1>&2
652 echo "$progname: *** Stop." 1>&2
653 func_exit 1
656 # func_warning message
657 # Outputs to stderr a warning message,
658 func_warning ()
660 echo "gnulib-tool: warning: $1" 1>&2
663 # func_readlink SYMLINK
664 # outputs the target of the given symlink.
665 if (type readlink) > /dev/null 2>&1; then
666 func_readlink ()
668 # Use the readlink program from GNU coreutils.
669 readlink "$1"
671 else
672 func_readlink ()
674 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
675 # would do the wrong thing if the link target contains " -> ".
676 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
680 # func_relativize DIR1 DIR2
681 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
682 # Input:
683 # - DIR1 relative pathname, relative to the current directory
684 # - DIR2 relative pathname, relative to the current directory
685 # Output:
686 # - reldir relative pathname of DIR2, relative to DIR1
687 func_relativize ()
689 dir0=`pwd`
690 dir1="$1"
691 dir2="$2"
692 sed_first='s,^\([^/]*\)/.*$,\1,'
693 sed_rest='s,^[^/]*/*,,'
694 sed_last='s,^.*/\([^/]*\)$,\1,'
695 sed_butlast='s,/*[^/]*$,,'
696 while test -n "$dir1"; do
697 first=`echo "$dir1" | sed -e "$sed_first"`
698 if test "$first" != "."; then
699 if test "$first" = ".."; then
700 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
701 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
702 else
703 first2=`echo "$dir2" | sed -e "$sed_first"`
704 if test "$first2" = "$first"; then
705 dir2=`echo "$dir2" | sed -e "$sed_rest"`
706 else
707 dir2="../$dir2"
709 dir0="$dir0"/"$first"
712 dir1=`echo "$dir1" | sed -e "$sed_rest"`
713 done
714 reldir="$dir2"
717 # func_relconcat DIR1 DIR2
718 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
719 # Input:
720 # - DIR1 relative pathname, relative to the current directory
721 # - DIR2 relative pathname, relative to DIR1
722 # Output:
723 # - relconcat DIR1/DIR2, relative to the current directory
724 func_relconcat ()
726 dir1="$1"
727 dir2="$2"
728 sed_first='s,^\([^/]*\)/.*$,\1,'
729 sed_rest='s,^[^/]*/*,,'
730 sed_last='s,^.*/\([^/]*\)$,\1,'
731 sed_butlast='s,/*[^/]*$,,'
732 while true; do
733 first=`echo "$dir2" | sed -e "$sed_first"`
734 if test "$first" = "."; then
735 dir2=`echo "$dir2" | sed -e "$sed_rest"`
736 if test -z "$dir2"; then
737 relconcat="$dir1"
738 break
740 else
741 last=`echo "$dir1" | sed -e "$sed_last"`
742 while test "$last" = "."; do
743 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
744 last=`echo "$dir1" | sed -e "$sed_last"`
745 done
746 if test -z "$dir1"; then
747 relconcat="$dir2"
748 break
750 if test "$first" = ".."; then
751 if test "$last" = ".."; then
752 relconcat="$dir1/$dir2"
753 break
755 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
756 dir2=`echo "$dir2" | sed -e "$sed_rest"`
757 if test -z "$dir1"; then
758 relconcat="$dir2"
759 break
761 if test -z "$dir2"; then
762 relconcat="$dir1"
763 break
765 else
766 relconcat="$dir1/$dir2"
767 break
770 done
773 # func_ln_s SRC DEST
774 # Like ln -s, except use cp -p if ln -s fails.
775 func_ln_s ()
777 ln -s "$1" "$2" || {
778 echo "$progname: ln -s failed; falling back on cp -p" >&2
780 case "$1" in
781 /* | ?:*) # SRC is absolute.
782 cp_src=$1 ;;
783 *) # SRC is relative to the directory of DEST.
784 cp_src=${2%/*}/$1 ;;
785 esac
787 cp -p "$cp_src" "$2"
791 # func_ln SRC DEST
792 # Like func_ln_s, except that SRC is given relative to the current directory (or
793 # absolute), not given relative to the directory of DEST.
794 func_ln ()
796 case "$1" in
797 /* | ?:*)
798 func_ln_s "$1" "$2" ;;
799 *) # SRC is relative.
800 case "$2" in
801 /* | ?:*)
802 func_ln_s "`pwd`/$1" "$2" ;;
803 *) # DEST is relative too.
804 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
805 test -n "$ln_destdir" || ln_destdir="."
806 func_relativize "$ln_destdir" "$1"
807 func_ln_s "$reldir" "$2"
809 esac
811 esac
814 # func_ln_if_changed SRC DEST
815 # Like func_ln, but avoids munging timestamps if the link is correct.
816 func_ln_if_changed ()
818 if test $# -ne 2; then
819 echo "usage: func_ln_if_changed SRC DEST" >&2
821 ln_target=`func_readlink "$2"`
822 if test -h "$2" && test "$1" = "$ln_target"; then
824 else
825 rm -f "$2"
826 func_ln "$1" "$2"
830 # Ensure an 'echo' command that
831 # 1. does not interpret backslashes and
832 # 2. does not print an error message "broken pipe" when writing into a pipe
833 # with no writers.
835 # Test cases for problem 1:
836 # echo '\n' | wc -l prints 1 when OK, 2 when KO
837 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
838 # Test cases for problem 2:
839 # echo hi | true frequently prints
840 # "bash: echo: write error: Broken pipe"
841 # to standard error in bash 3.2.
843 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
844 # BSD echo interprets '-n' as an option, which is also not desirable).
845 # Nowadays the problem occurs in 4 situations:
846 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
847 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
848 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
849 # - in zsh, when sh-emulation is not set,
850 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
851 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
852 # - in Solaris /bin/sh and OSF/1 /bin/sh.
853 # We try the following workarounds:
854 # - for all: respawn using $CONFIG_SHELL if that is set and works.
855 # - for bash >= 2.04: unset the shell option xpg_echo.
856 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
857 # - for bash < 2.0: define echo to a function that uses cat of a here document.
858 # - for zsh: turn sh-emulation on.
859 # - for ksh: alias echo to 'print -r'.
860 # - for ksh: alias echo to a function that uses cat of a here document.
861 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
862 # the ksh workaround.
863 # - otherwise: respawn using /bin/sh and rely on the workarounds.
864 # When respawning, we pass --no-reexec as first argument, so as to avoid
865 # turning this script into a fork bomb in unlucky situations.
867 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
868 # the 'printf' built-in. See
869 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
870 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
871 # The workaround is: define echo to a function that uses the printf built-in.
872 have_echo=
873 if echo '\t' | grep t > /dev/null; then
874 have_echo=yes # Lucky!
876 # Try the workarounds.
877 # Respawn using $CONFIG_SHELL if that is set and works.
878 if test -z "$have_echo" \
879 && test "X$1" != "X--no-reexec" \
880 && test -n "$CONFIG_SHELL" \
881 && test -f "$CONFIG_SHELL" \
882 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
883 exec $CONFIG_SHELL "$0" --no-reexec "$@"
884 exit 127
886 # For bash >= 2.04: unset the shell option xpg_echo.
887 if test -z "$have_echo" \
888 && test -n "$BASH_VERSION" \
889 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
890 shopt -o xpg_echo
891 have_echo=yes
893 # For bash >= 2.0: define echo to a function that uses the printf built-in.
894 # For bash < 2.0: define echo to a function that uses cat of a here document.
895 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
896 # Also handle problem 2, specific to bash 3.2, here.
897 if { test -z "$have_echo" \
898 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
900 && test -n "$BASH_VERSION"; then \
901 if type printf 2>/dev/null | grep / > /dev/null; then
902 # 'printf' is not a shell built-in.
903 echo ()
905 cat <<EOF
909 else
910 # 'printf' is a shell built-in.
911 echo ()
913 printf '%s\n' "$*"
916 if echo '\t' | grep t > /dev/null; then
917 have_echo=yes
920 # For zsh: turn sh-emulation on.
921 if test -z "$have_echo" \
922 && test -n "$ZSH_VERSION" \
923 && (emulate sh) >/dev/null 2>&1; then
924 emulate sh
926 # For ksh: alias echo to 'print -r'.
927 if test -z "$have_echo" \
928 && (type print) >/dev/null 2>&1; then
929 # A 'print' command exists.
930 if type print 2>/dev/null | grep / > /dev/null; then
932 else
933 # 'print' is a shell built-in.
934 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
935 # 'print' is the ksh shell built-in.
936 alias echo='print -r'
940 if test -z "$have_echo" \
941 && echo '\t' | grep t > /dev/null; then
942 have_echo=yes
944 # For ksh: alias echo to a function that uses cat of a here document.
945 # The ksh manual page says:
946 # "Aliasing is performed when scripts are read, not while they are executed.
947 # Therefore, for an alias to take effect, the alias definition command has
948 # to be executed before the command which references the alias is read."
949 # Because of this, we have to play strange tricks with have_echo, to ensure
950 # that the top-level statement containing the test starts after the 'alias'
951 # command.
952 if test -z "$have_echo"; then
953 bsd_echo ()
955 cat <<EOF
959 if (alias echo=bsd_echo) 2>/dev/null; then
960 alias echo=bsd_echo 2>/dev/null
963 if test -z "$have_echo" \
964 && echo '\t' | grep t > /dev/null; then
965 have_echo=yes
967 if test -z "$have_echo"; then
968 if (alias echo=bsd_echo) 2>/dev/null; then
969 unalias echo 2>/dev/null
972 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
973 if test -z "$have_echo" \
974 && test "X$1" != "X--no-reexec" \
975 && test -f /bin/ksh; then
976 exec /bin/ksh "$0" --no-reexec "$@"
977 exit 127
979 # Otherwise: respawn using /bin/sh.
980 if test -z "$have_echo" \
981 && test "X$1" != "X--no-reexec" \
982 && test -f /bin/sh; then
983 exec /bin/sh "$0" --no-reexec "$@"
984 exit 127
986 if test -z "$have_echo"; then
987 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
989 if echo '\t' | grep t > /dev/null; then
990 : # Works fine now.
991 else
992 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
994 if test "X$1" = "X--no-reexec"; then
995 shift
998 # Unset CDPATH. Otherwise, output from 'cd dir' can surprise callers.
999 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
1001 # Determine the path separator early because the following option parsing code
1002 # requires that.
1003 func_determine_path_separator
1005 # Command-line option processing.
1006 # Removes the OPTIONS from the arguments. Sets the variables:
1007 # - mode one of: list, find, import, add-import, remove-import,
1008 # update, create-testdir, create-megatestdir, test, megatest,
1009 # copy-file
1010 # - destdir from --dir
1011 # - local_gnulib_path from --local-dir
1012 # - modcache true or false, from --cache-modules/--no-cache-modules
1013 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1014 # - libname, supplied_libname from --lib
1015 # - sourcebase from --source-base
1016 # - m4base from --m4-base
1017 # - pobase from --po-base
1018 # - docbase from --doc-base
1019 # - testsbase from --tests-base
1020 # - auxdir from --aux-dir
1021 # - inctests true if --with-tests was given, false if --without-tests
1022 # was given, blank otherwise
1023 # - incobsolete true if --with-obsolete was given, blank otherwise
1024 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
1025 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
1026 # otherwise
1027 # - inc_privileged_tests true if --with-privileged-tests was given, blank
1028 # otherwise
1029 # - inc_unportable_tests true if --with-unportable-tests was given, blank
1030 # otherwise
1031 # - inc_all_tests true if --with-all-tests was given, blank otherwise
1032 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
1033 # - excl_longrunning_tests true if --without-longrunning-tests was given,
1034 # blank otherwise
1035 # - excl_privileged_tests true if --without-privileged-tests was given, blank
1036 # otherwise
1037 # - excl_unportable_tests true if --without-unportable-tests was given, blank
1038 # otherwise
1039 # - single_configure true if --single-configure was given, false otherwise
1040 # - avoidlist list of modules to avoid, from --avoid
1041 # - cond_dependencies true if --conditional-dependencies was given, false if
1042 # --no-conditional-dependencies was given, blank otherwise
1043 # - lgpl yes or a number if --lgpl was given, blank otherwise
1044 # - gnu_make true if --gnu-make was given, false otherwise
1045 # - makefile_name from --makefile-name
1046 # - libtool true if --libtool was given, false if --no-libtool was
1047 # given, blank otherwise
1048 # - macro_prefix from --macro-prefix
1049 # - po_domain from --po-domain
1050 # - witness_c_macro from --witness-c-macro
1051 # - vc_files true if --vc-files was given, false if --no-vc-files was
1052 # given, blank otherwise
1053 # - autoconf_minversion minimum supported autoconf version
1054 # - doit : if actions shall be executed, false if only to be printed
1055 # - symbolic true if --symlink or --more-symlinks was given, blank
1056 # otherwise
1057 # - lsymbolic true if --local-symlink was given, blank otherwise
1058 # - do_copyrights blank if --more-symlinks was given, true otherwise
1060 mode=
1061 destdir=
1062 local_gnulib_path=
1063 modcache=true
1064 verbose=0
1065 libname=libgnu
1066 supplied_libname=
1067 sourcebase=
1068 m4base=
1069 pobase=
1070 docbase=
1071 testsbase=
1072 auxdir=
1073 inctests=
1074 incobsolete=
1075 inc_cxx_tests=
1076 inc_longrunning_tests=
1077 inc_privileged_tests=
1078 inc_unportable_tests=
1079 inc_all_tests=
1080 excl_cxx_tests=
1081 excl_longrunning_tests=
1082 excl_privileged_tests=
1083 excl_unportable_tests=
1084 single_configure=false
1085 avoidlist=
1086 cond_dependencies=
1087 lgpl=
1088 gnu_make=false
1089 makefile_name=
1090 libtool=
1091 macro_prefix=
1092 po_domain=
1093 witness_c_macro=
1094 vc_files=
1095 doit=:
1096 symbolic=
1097 lsymbolic=
1098 do_copyrights=true
1100 supplied_opts="$@"
1102 while test $# -gt 0; do
1103 case "$1" in
1104 --list | --lis )
1105 mode=list
1106 shift ;;
1107 --find | --fin | --fi | --f )
1108 mode=find
1109 shift ;;
1110 --import | --impor | --impo | --imp | --im | --i )
1111 mode=import
1112 shift ;;
1113 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
1114 mode=add-import
1115 shift ;;
1116 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
1117 mode=remove-import
1118 shift ;;
1119 --update | --updat | --upda | --upd | --up | --u )
1120 mode=update
1121 shift ;;
1122 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
1123 mode=create-testdir
1124 shift ;;
1125 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
1126 mode=create-megatestdir
1127 shift ;;
1128 --test | --tes | --te | --t )
1129 mode=test
1130 shift ;;
1131 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1132 mode=megatest
1133 shift ;;
1134 --extract-* )
1135 mode=`echo "X$1" | sed -e 's/^X--//'`
1136 shift ;;
1137 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop )
1138 mode=copy-file
1139 shift ;;
1140 --dir )
1141 shift
1142 if test $# = 0; then
1143 func_fatal_error "missing argument for --dir"
1145 destdir=$1
1146 shift ;;
1147 --dir=* )
1148 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1149 shift ;;
1150 --local-dir )
1151 shift
1152 if test $# = 0; then
1153 func_fatal_error "missing argument for --local-dir"
1155 func_path_prepend local_gnulib_path "$1"
1156 shift ;;
1157 --local-dir=* )
1158 local_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1159 func_path_prepend local_gnulib_path "$local_dir"
1160 shift ;;
1161 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1162 modcache=true
1163 shift ;;
1164 --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 )
1165 modcache=false
1166 shift ;;
1167 --verbose | --verbos | --verbo | --verb )
1168 verbose=`expr $verbose + 1`
1169 shift ;;
1170 --quiet | --quie | --qui | --qu | --q )
1171 verbose=`expr $verbose - 1`
1172 shift ;;
1173 --lib )
1174 shift
1175 if test $# = 0; then
1176 func_fatal_error "missing argument for --lib"
1178 libname=$1
1179 supplied_libname=true
1180 shift ;;
1181 --lib=* )
1182 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1183 supplied_libname=true
1184 shift ;;
1185 --source-base )
1186 shift
1187 if test $# = 0; then
1188 func_fatal_error "missing argument for --source-base"
1190 sourcebase=$1
1191 shift ;;
1192 --source-base=* )
1193 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1194 shift ;;
1195 --m4-base )
1196 shift
1197 if test $# = 0; then
1198 func_fatal_error "missing argument for --m4-base"
1200 m4base=$1
1201 shift ;;
1202 --m4-base=* )
1203 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1204 shift ;;
1205 --po-base )
1206 shift
1207 if test $# = 0; then
1208 func_fatal_error "missing argument for --po-base"
1210 pobase=$1
1211 shift ;;
1212 --po-base=* )
1213 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1214 shift ;;
1215 --doc-base )
1216 shift
1217 if test $# = 0; then
1218 func_fatal_error "missing argument for --doc-base"
1220 docbase=$1
1221 shift ;;
1222 --doc-base=* )
1223 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1224 shift ;;
1225 --tests-base )
1226 shift
1227 if test $# = 0; then
1228 func_fatal_error "missing argument for --tests-base"
1230 testsbase=$1
1231 shift ;;
1232 --tests-base=* )
1233 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1234 shift ;;
1235 --aux-dir )
1236 shift
1237 if test $# = 0; then
1238 func_fatal_error "missing argument for --aux-dir"
1240 auxdir=$1
1241 shift ;;
1242 --aux-dir=* )
1243 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1244 shift ;;
1245 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1246 inctests=true
1247 shift ;;
1248 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1249 incobsolete=true
1250 shift ;;
1251 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1252 inc_cxx_tests=true
1253 shift ;;
1254 --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)
1255 inc_longrunning_tests=true
1256 shift ;;
1257 --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)
1258 inc_privileged_tests=true
1259 shift ;;
1260 --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)
1261 inc_unportable_tests=true
1262 shift ;;
1263 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1264 inc_all_tests=true
1265 shift ;;
1266 --without-tests | --without-test | --without-tes | --without-te | --without-t)
1267 inctests=false
1268 shift ;;
1269 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1270 excl_cxx_tests=true
1271 shift ;;
1272 --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)
1273 excl_longrunning_tests=true
1274 shift ;;
1275 --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)
1276 excl_privileged_tests=true
1277 shift ;;
1278 --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)
1279 excl_unportable_tests=true
1280 shift ;;
1281 --single-configure | --single-configur | --single-configu | --single-config | --single-confi | --single-conf | --single-con | --single-con | --single-co | --single-c | --single- | --single | --singl | --sing | --sin | --si)
1282 single_configure=true
1283 shift ;;
1284 --avoid )
1285 shift
1286 if test $# = 0; then
1287 func_fatal_error "missing argument for --avoid"
1289 func_append avoidlist " $1"
1290 shift ;;
1291 --avoid=* )
1292 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1293 func_append avoidlist " $arg"
1294 shift ;;
1295 --conditional-dependencies | --conditional-dependencie | --conditional-dependenci | --conditional-dependenc | --conditional-dependen | --conditional-depende | --conditional-depend | --conditional-depen | --conditional-depe | --conditional-dep | --conditional-de | --conditional-d | --conditional- | --conditional | --conditiona | --condition | --conditio | --conditi | --condit | --condi | --cond | --con)
1296 cond_dependencies=true
1297 shift ;;
1298 --no-conditional-dependencies | --no-conditional-dependencie | --no-conditional-dependenci | --no-conditional-dependenc | --no-conditional-dependen | --no-conditional-depende | --no-conditional-depend | --no-conditional-depen | --no-conditional-depe | --no-conditional-dep | --no-conditional-de | --no-conditional-d | --no-conditional- | --no-conditional | --no-conditiona | --no-condition | --no-conditio | --no-conditi | --no-condit | --no-condi | --no-cond | --no-con | --no-co)
1299 cond_dependencies=false
1300 shift ;;
1301 --lgpl )
1302 lgpl=yes
1303 shift ;;
1304 --lgpl=* )
1305 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1306 case "$arg" in
1307 2 | 3orGPLv2 | 3) ;;
1308 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1309 esac
1310 lgpl=$arg
1311 shift ;;
1312 --gnu-make )
1313 gnu_make=true
1314 shift ;;
1315 --makefile-name )
1316 shift
1317 if test $# = 0; then
1318 func_fatal_error "missing argument for --makefile-name"
1320 makefile_name="$1"
1321 shift ;;
1322 --makefile-name=* )
1323 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1324 shift ;;
1325 --libtool )
1326 libtool=true
1327 shift ;;
1328 --no-libtool )
1329 libtool=false
1330 shift ;;
1331 --macro-prefix )
1332 shift
1333 if test $# = 0; then
1334 func_fatal_error "missing argument for --macro-prefix"
1336 macro_prefix="$1"
1337 shift ;;
1338 --macro-prefix=* )
1339 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1340 shift ;;
1341 --po-domain )
1342 shift
1343 if test $# = 0; then
1344 func_fatal_error "missing argument for --po-domain"
1346 po_domain="$1"
1347 shift ;;
1348 --po-domain=* )
1349 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1350 shift ;;
1351 --witness-c-macro )
1352 shift
1353 if test $# = 0; then
1354 func_fatal_error "missing argument for --witness-c-macro"
1356 witness_c_macro="$1"
1357 shift ;;
1358 --witness-c-macro=* )
1359 witness_c_macro=`echo "X$1" | sed -e 's/^X--witness-c-macro=//'`
1360 shift ;;
1361 --vc-files )
1362 vc_files=true
1363 shift ;;
1364 --no-vc-files )
1365 vc_files=false
1366 shift ;;
1367 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1368 # A no-op for backward compatibility.
1369 shift ;;
1370 --dry-run )
1371 doit=false
1372 shift ;;
1373 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1374 symbolic=true
1375 shift ;;
1376 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1377 lsymbolic=true
1378 shift ;;
1379 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1380 symbolic=true
1381 do_copyrights=
1382 shift ;;
1383 --help | --hel | --he | --h )
1384 func_usage
1385 func_exit $? ;;
1386 --version | --versio | --versi | --vers )
1387 func_version
1388 func_exit $? ;;
1389 -- )
1390 # Stop option processing
1391 shift
1392 break ;;
1393 -* )
1394 echo "gnulib-tool: unknown option $1" 1>&2
1395 echo "Try 'gnulib-tool --help' for more information." 1>&2
1396 func_exit 1 ;;
1398 break ;;
1399 esac
1400 done
1402 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1403 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1404 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1405 || test "$single_configure" != false; then
1406 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1407 echo "Try 'gnulib-tool --help' for more information." 1>&2
1408 func_exit 1
1411 if test "$mode" = update; then
1412 if test $# != 0; then
1413 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1414 echo "Try 'gnulib-tool --help' for more information." 1>&2
1415 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1416 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1417 func_exit 1
1419 if test -n "$local_gnulib_path" || test -n "$supplied_libname" \
1420 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1421 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1422 || test -n "$inctests" || test -n "$incobsolete" \
1423 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1424 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1425 || test -n "$inc_all_tests" \
1426 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1427 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1428 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1429 || test -n "$macro_prefix" || test -n "$po_domain" \
1430 || test -n "$witness_c_macro" || test -n "$vc_files"; then
1431 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1432 echo "Try 'gnulib-tool --help' for more information." 1>&2
1433 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1434 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1435 func_exit 1
1438 if test -n "$pobase" && test -z "$po_domain"; then
1439 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1440 echo "Try 'gnulib-tool --help' for more information." 1>&2
1441 func_exit 1
1443 if test -z "$pobase" && test -n "$po_domain"; then
1444 func_warning "--po-domain has no effect without a --po-base option"
1446 # Canonicalize the inctests variable.
1447 case "$mode" in
1448 import | add-import | remove-import | update)
1449 if test -z "$inctests"; then
1450 inctests=false
1453 create-testdir | create-megatestdir | test | megatest)
1454 if test -z "$inctests"; then
1455 inctests=true
1458 esac
1459 # Now the only possible values of "$inctests" are true and false
1460 # (or blank but then it is irrelevant).
1461 if test "$cond_dependencies" = true && test "$inctests" = true; then
1462 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
1463 func_exit 1
1466 # Determine the minimum supported autoconf version from the project's
1467 # configure.ac.
1468 DEFAULT_AUTOCONF_MINVERSION="2.59"
1469 autoconf_minversion=
1470 configure_ac=
1471 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1472 && test -n "$destdir"; then
1473 if test -f "$destdir"/configure.ac; then
1474 configure_ac="$destdir/configure.ac"
1475 else
1476 if test -f "$destdir"/configure.in; then
1477 configure_ac="$destdir/configure.in"
1480 else
1481 if test -f configure.ac; then
1482 configure_ac="configure.ac"
1483 else
1484 if test -f configure.in; then
1485 configure_ac="configure.in"
1489 if test -n "$configure_ac"; then
1490 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1491 # because when some m4 files are omitted from a version control repository,
1492 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1493 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1494 # autom4te: m4 failed with exit status: 1
1495 prereqs=
1496 my_sed_traces='
1497 s,#.*$,,
1498 s,^dnl .*$,,
1499 s, dnl .*$,,
1500 /AC_PREREQ/ {
1501 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1503 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1504 if test -n "$prereqs"; then
1505 autoconf_minversion=`
1506 for version in $prereqs; do echo $version; done |
1507 LC_ALL=C sort -nru | sed -e 1q
1511 if test -z "$autoconf_minversion"; then
1512 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1514 case "$autoconf_minversion" in
1515 1.* | 2.[0-4]* | 2.5[0-8]*)
1516 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1517 esac
1519 # Remove trailing slashes from the directory names. This is necessary for
1520 # m4base (to avoid an error in func_import) and optional for the others.
1521 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1522 old_local_gnulib_path=$local_gnulib_path
1523 save_IFS=$IFS
1524 IFS=:
1525 local_gnulib_path=
1526 for dir in $old_local_gnulib_path
1528 case "$dir" in
1529 */ ) dir=`echo "$dir" | sed -e "$sed_trimtrailingslashes"` ;;
1530 esac
1531 func_path_append local_gnulib_path "$dir"
1532 done
1533 IFS=$save_IFS
1534 case "$sourcebase" in
1535 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1536 esac
1537 case "$m4base" in
1538 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1539 esac
1540 case "$pobase" in
1541 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1542 esac
1543 case "$docbase" in
1544 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1545 esac
1546 case "$testsbase" in
1547 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1548 esac
1549 case "$auxdir" in
1550 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1551 esac
1554 func_gnulib_dir
1555 func_tmpdir
1556 trap 'exit_status=$?
1557 if test "$signal" != 0; then
1558 echo "caught signal $signal" >&2
1560 rm -rf "$tmp"
1561 exit $exit_status' 0
1562 for signal in 1 2 3 13 15; do
1563 trap '{ signal='$signal'; func_exit 1; }' $signal
1564 done
1565 signal=0
1567 # Note: The 'eval' silences stderr output in dash.
1568 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1569 # Zsh 4 and Bash 4 have associative arrays.
1570 have_associative=true
1571 else
1572 # For other shells, use 'eval' with computed shell variable names.
1573 have_associative=false
1576 # func_lookup_local_file_cb dir file
1577 # return true and set func_lookup_local_file_result if the file 'dir/file'
1578 # exists
1579 func_lookup_local_file_cb ()
1581 test -n "$func_lookup_local_file_result" && return 1 # already found?
1582 test -f "$1/$2" || return 1
1583 func_lookup_local_file_result=$1/$2
1587 # func_lookup_local_file file
1588 # looks up a file in $local_gnulib_path.
1589 # Input:
1590 # - local_gnulib_path from --local-dir
1591 # Output:
1592 # - func_lookup_local_file_result name of the file, valid only when the
1593 # function succeeded.
1594 func_lookup_local_file ()
1596 func_lookup_local_file_result=
1597 func_path_foreach "$local_gnulib_path" func_lookup_local_file_cb %dir% "$1"
1600 # func_lookup_file file
1601 # looks up a file in $local_gnulib_path or $gnulib_dir, or combines it through
1602 # 'patch'.
1603 # Input:
1604 # - local_gnulib_path from --local-dir
1605 # Output:
1606 # - lookedup_file name of the merged (combined) file
1607 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1608 func_lookup_file ()
1610 lkfile="$1"
1611 if func_lookup_local_file "$lkfile"; then
1612 lookedup_file=$func_lookup_local_file_result
1613 lookedup_tmp=
1614 else
1615 if test -f "$gnulib_dir/$lkfile"; then
1616 if func_lookup_local_file "$lkfile.diff"; then
1617 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1618 rm -f "$tmp/$lkbase"
1619 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1620 patch -s "$tmp/$lkbase" < "$func_lookup_local_file_result" >&2 \
1621 || func_fatal_error "patch file $func_lookup_local_file_result didn't apply cleanly"
1622 lookedup_file="$tmp/$lkbase"
1623 lookedup_tmp=true
1624 else
1625 lookedup_file="$gnulib_dir/$lkfile"
1626 lookedup_tmp=
1628 else
1629 func_fatal_error "file $gnulib_dir/$lkfile not found"
1634 # func_sanitize_modulelist
1635 # receives a list of possible module names on standard input, one per line.
1636 # It removes those which are just file names unrelated to modules, and outputs
1637 # the resulting list to standard output, one per line.
1638 func_sanitize_modulelist ()
1640 sed -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1641 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1642 -e '/^README$/d' -e '/\/README$/d' \
1643 -e '/^TEMPLATE$/d' \
1644 -e '/^TEMPLATE-EXTENDED$/d' \
1645 -e '/^TEMPLATE-TESTS$/d' \
1646 -e '/^\..*/d' \
1647 -e '/~$/d'
1651 # func_modules_in_dir dir
1652 # outputs all module files in dir to standard output.
1653 func_modules_in_dir ()
1655 (test -d "$1" && cd "$1" && find modules -type f -print)
1658 # func_all_modules
1659 # Input:
1660 # - local_gnulib_path from --local-dir
1661 func_all_modules ()
1663 # Filter out metainformation files like README, which are not modules.
1664 # Filter out unit test modules; they can be retrieved through
1665 # --extract-tests-module if desired.
1667 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1668 func_path_foreach "$local_gnulib_path" func_modules_in_dir %dir% | sed -e 's,^modules/,,' -e 's,\.diff$,,'
1670 | func_sanitize_modulelist \
1671 | sed -e '/-tests$/d' \
1672 | LC_ALL=C sort -u
1675 # func_exists_local_module dir module
1676 # returns true if module exists in dir
1677 func_exists_local_module ()
1679 test -d "$1/modules" && test -f "$1/modules/$2";
1682 # func_exists_module module
1683 # tests whether a module, given by name, exists
1684 # Input:
1685 # - local_gnulib_path from --local-dir
1686 func_exists_module ()
1688 { test -f "$gnulib_dir/modules/$1" \
1689 || func_path_foreach "$local_gnulib_path" func_exists_local_module %dir% "$1" ; } \
1690 && test "ChangeLog" != "$1" \
1691 && test "COPYING" != "$1" \
1692 && test "README" != "$1" \
1693 && test "TEMPLATE" != "$1" \
1694 && test "TEMPLATE-EXTENDED" != "$1" \
1695 && test "TEMPLATE-TESTS" != "$1"
1698 # func_verify_module
1699 # verifies a module name
1700 # Input:
1701 # - local_gnulib_path from --local-dir
1702 # - module module name argument
1703 func_verify_module ()
1705 if func_exists_module "$module"; then
1706 # OK, $module is a correct module name.
1707 # Verify that building the module description with 'patch' succeeds.
1708 func_lookup_file "modules/$module"
1709 else
1710 func_warning "module $module doesn't exist"
1711 module=
1715 # func_verify_nontests_module
1716 # verifies a module name, excluding tests modules
1717 # Input:
1718 # - local_gnulib_path from --local-dir
1719 # - module module name argument
1720 func_verify_nontests_module ()
1722 case "$module" in
1723 *-tests ) module= ;;
1724 * ) func_verify_module ;;
1725 esac
1728 # func_verify_tests_module
1729 # verifies a module name, considering only tests modules
1730 # Input:
1731 # - local_gnulib_path from --local-dir
1732 # - module module name argument
1733 func_verify_tests_module ()
1735 case "$module" in
1736 *-tests ) func_verify_module ;;
1737 * ) module= ;;
1738 esac
1741 # Suffix of a sed expression that extracts a particular field from a
1742 # module description.
1743 # A field starts with a line that contains a keyword, such as 'Description',
1744 # followed by a colon and optional whitespace. All following lines, up to
1745 # the next field (or end of file if there is none) form the contents of the
1746 # field.
1747 # An absent field is equivalent to a field with empty contents.
1748 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1749 sed_extract_prog=':[ ]*$/ {
1752 s/^Description:[ ]*$//
1753 s/^Comment:[ ]*$//
1754 s/^Status:[ ]*$//
1755 s/^Notice:[ ]*$//
1756 s/^Applicability:[ ]*$//
1757 s/^Files:[ ]*$//
1758 s/^Depends-on:[ ]*$//
1759 s/^configure\.ac-early:[ ]*$//
1760 s/^configure\.ac:[ ]*$//
1761 s/^Makefile\.am:[ ]*$//
1762 s/^Include:[ ]*$//
1763 s/^Link:[ ]*$//
1764 s/^License:[ ]*$//
1765 s/^Maintainer:[ ]*$//
1772 # Piece of a sed expression that converts a field header line to a shell
1773 # variable name,
1774 # NOTE: Keep this in sync with sed_extract_prog above!
1775 sed_extract_field_header='
1776 s/^Description:[ ]*$/description/
1777 s/^Comment:[ ]*$/comment/
1778 s/^Status:[ ]*$/status/
1779 s/^Notice:[ ]*$/notice/
1780 s/^Applicability:[ ]*$/applicability/
1781 s/^Files:[ ]*$/files/
1782 s/^Depends-on:[ ]*$/dependson/
1783 s/^configure\.ac-early:[ ]*$/configureac_early/
1784 s/^configure\.ac:[ ]*$/configureac/
1785 s/^Makefile\.am:[ ]*$/makefile/
1786 s/^Include:[ ]*$/include/
1787 s/^Link:[ ]*$/link/
1788 s/^License:[ ]*$/license/
1789 s/^Maintainer:[ ]*$/maintainer/'
1791 if $modcache; then
1793 if $have_associative; then
1795 # Declare the associative arrays.
1796 declare -A modcache_cached
1797 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1798 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1799 eval "$declare_script"
1801 else
1803 # func_cache_var module
1804 # computes the cache variable name corresponding to $module.
1805 # Note: This computation can map different module names to the same
1806 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1807 # to protect against this case.
1808 # Output:
1809 # - cachevar a shell variable name
1810 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1811 # Bash 2.0 and newer, ksh, and zsh support the syntax
1812 # ${param//pattern/replacement}
1813 # as a shorthand for
1814 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1815 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1816 eval 'func_cache_var ()
1818 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1820 else
1821 func_cache_var ()
1823 case $1 in
1824 *[!a-zA-Z0-9_]*)
1825 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1827 cachevar=c_$1 ;;
1828 esac
1834 # func_init_sed_convert_to_cache_statements
1835 # Input:
1836 # - modcachevar_assignment
1837 # Output:
1838 # - sed_convert_to_cache_statements
1839 func_init_sed_convert_to_cache_statements ()
1841 # 'sed' script that turns a module description into shell script
1842 # assignments, suitable to be eval'ed. All active characters are escaped.
1843 # This script turns
1844 # Description:
1845 # Some module's description
1847 # Files:
1848 # lib/file.h
1849 # into:
1850 # modcache_description[$1]=\
1851 # 'Some module'"'"'s description
1853 # modcache_files[$1]=\
1854 # 'lib/file.h'
1855 # or:
1856 # c_MODULE_description_set=set; c_MODULE_description=\
1857 # 'Some module'"'"'s description
1859 # c_MODULE_files_set=set; c_MODULE_files=\
1860 # 'lib/file.h'
1861 # The script consists of two parts:
1862 # 1) Ignore the lines before the first field header.
1863 # 2) A loop, treating non-field-header lines by escaping single quotes
1864 # and adding a closing quote in the last line,
1865 sed_convert_to_cache_statements="
1866 :llla
1867 # Here we have not yet seen a field header.
1869 # See if the current line contains a field header.
1870 t llla1
1871 :llla1
1872 ${sed_extract_field_header}
1873 t lllb
1875 # No field header. Ignore the line.
1877 # Read the next line. Upon EOF, just exit.
1879 b llla
1881 :lllb
1882 # The current line contains a field header.
1884 # Turn it into the beginning of an assignment.
1885 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1887 # Move it to the hold space. Don't print it yet,
1888 # because we want no assignment if the field is empty.
1891 # Read the next line.
1892 # Upon EOF, the field was empty. Print no assignment. Just exit.
1895 # See if the current line contains a field header.
1896 t lllb1
1897 :lllb1
1898 ${sed_extract_field_header}
1899 # If it is, the previous field was empty. Print no assignment.
1900 t lllb
1902 # Not a field header.
1904 # Print the previous line, held in the hold space.
1909 # Transform single quotes.
1910 s/'/'\"'\"'/g
1912 # Prepend a single quote.
1913 s/^/'/
1915 :lllc
1917 # Move it to the hold space.
1920 # Read the next line.
1921 # Upon EOF, branch.
1923 b llle
1927 # See if the current line contains a field header.
1928 t lllc1
1929 :lllc1
1930 ${sed_extract_field_header}
1931 t llld
1933 # Print the previous line, held in the hold space.
1938 # Transform single quotes.
1939 s/'/'\"'\"'/g
1941 b lllc
1943 :llld
1944 # A field header.
1945 # Print the previous line, held in the hold space, with a single quote
1946 # to end the assignment.
1948 s/\$/'/
1952 b lllb
1954 :llle
1955 # EOF seen.
1956 # Print the previous line, held in the hold space, with a single quote
1957 # to end the assignment.
1959 s/\$/'/
1961 # Exit.
1964 if ! $sed_comments; then
1965 # Remove comments.
1966 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1967 | sed -e 's/^ *//' -e 's/^#.*//'`
1971 if $have_associative; then
1972 # sed_convert_to_cache_statements does not depend on the module.
1973 modcachevar_assignment='modcache_\1[$1]='
1974 func_init_sed_convert_to_cache_statements
1977 # func_cache_lookup_module module
1979 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1980 # of its relevant data in a cache in the memory of the processing shell. If
1981 # already cached, it does not look it up again, thus saving file access time.
1982 # Parameters:
1983 # - module non-empty string
1984 # Output if $have_associative:
1985 # - modcache_cached[$module] set to yes
1986 # - modcache_description[$module] ==
1987 # - modcache_status[$module] \ set to the field's value, minus the
1988 # - ... / final newline,
1989 # - modcache_maintainer[$module] == or unset if the field's value is empty
1990 # Output if ! $have_associative:
1991 # - cachevar a shell variable name
1992 # - ${cachevar}_cached set to $module
1993 # - ${cachevar}_description ==
1994 # - ${cachevar}_status \ set to the field's value, minus the
1995 # - ... / final newline,
1996 # - ${cachevar}_maintainer == or unset if the field's value is empty
1997 # - ${cachevar}_description_set ==
1998 # - ${cachevar}_status_set \ set to non-empty if the field's value
1999 # - ... / is non-empty,
2000 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
2001 func_cache_lookup_module ()
2003 if $have_associative; then
2004 eval 'cached=${modcache_cached[$1]}'
2005 else
2006 func_cache_var "$1"
2007 eval "cached=\"\$${cachevar}_cached\""
2009 if test -z "$cached"; then
2010 # Not found in cache. Look it up on the file system.
2011 func_lookup_file "modules/$1"
2012 if $have_associative; then
2013 eval 'modcache_cached[$1]=yes'
2014 else
2015 eval "${cachevar}_cached=\"\$1\""
2017 if ! $have_associative; then
2018 # sed_convert_to_cache_statements depends on the module.
2019 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
2020 func_init_sed_convert_to_cache_statements
2022 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
2023 eval "$cache_statements"
2024 else
2025 if ! $have_associative; then
2026 if test "$1" != "$cached"; then
2027 func_fatal_error "cache variable collision between $1 and $cached"
2035 # func_get_description module
2036 # Input:
2037 # - local_gnulib_path from --local-dir
2038 # - modcache true or false, from --cache-modules/--no-cache-modules
2039 func_get_description ()
2041 if ! $modcache; then
2042 func_lookup_file "modules/$1"
2043 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
2044 else
2045 func_cache_lookup_module "$1"
2046 # Output the field's value, including the final newline (if any).
2047 if $have_associative; then
2048 if eval 'test -n "${modcache_description[$1]+set}"'; then
2049 eval 'echo "${modcache_description[$1]}"'
2051 else
2052 eval "field_set=\"\$${cachevar}_description_set\""
2053 if test -n "$field_set"; then
2054 eval "field_value=\"\$${cachevar}_description\""
2055 echo "${field_value}"
2061 # func_get_comment module
2062 # Input:
2063 # - local_gnulib_path from --local-dir
2064 # - modcache true or false, from --cache-modules/--no-cache-modules
2065 func_get_comment ()
2067 if ! $modcache; then
2068 func_lookup_file "modules/$1"
2069 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
2070 else
2071 func_cache_lookup_module "$1"
2072 # Output the field's value, including the final newline (if any).
2073 if $have_associative; then
2074 if eval 'test -n "${modcache_comment[$1]+set}"'; then
2075 eval 'echo "${modcache_comment[$1]}"'
2077 else
2078 eval "field_set=\"\$${cachevar}_comment_set\""
2079 if test -n "$field_set"; then
2080 eval "field_value=\"\$${cachevar}_comment\""
2081 echo "${field_value}"
2087 # func_get_status module
2088 # Input:
2089 # - local_gnulib_path from --local-dir
2090 # - modcache true or false, from --cache-modules/--no-cache-modules
2091 func_get_status ()
2093 if ! $modcache; then
2094 func_lookup_file "modules/$1"
2095 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
2096 else
2097 func_cache_lookup_module "$1"
2098 # Output the field's value, including the final newline (if any).
2099 if $have_associative; then
2100 if eval 'test -n "${modcache_status[$1]+set}"'; then
2101 eval 'echo "${modcache_status[$1]}"'
2103 else
2104 eval "field_set=\"\$${cachevar}_status_set\""
2105 if test -n "$field_set"; then
2106 eval "field_value=\"\$${cachevar}_status\""
2107 echo "${field_value}"
2113 # func_get_notice module
2114 # Input:
2115 # - local_gnulib_path from --local-dir
2116 # - modcache true or false, from --cache-modules/--no-cache-modules
2117 func_get_notice ()
2119 if ! $modcache; then
2120 func_lookup_file "modules/$1"
2121 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
2122 else
2123 func_cache_lookup_module "$1"
2124 # Output the field's value, including the final newline (if any).
2125 if $have_associative; then
2126 if eval 'test -n "${modcache_notice[$1]+set}"'; then
2127 eval 'echo "${modcache_notice[$1]}"'
2129 else
2130 eval "field_set=\"\$${cachevar}_notice_set\""
2131 if test -n "$field_set"; then
2132 eval "field_value=\"\$${cachevar}_notice\""
2133 echo "${field_value}"
2139 # func_get_applicability module
2140 # Input:
2141 # - local_gnulib_path from --local-dir
2142 # - modcache true or false, from --cache-modules/--no-cache-modules
2143 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
2144 func_get_applicability ()
2146 if ! $modcache; then
2147 func_lookup_file "modules/$1"
2148 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
2149 else
2150 func_cache_lookup_module "$1"
2151 # Get the field's value, without the final newline.
2152 if $have_associative; then
2153 eval 'my_applicability="${modcache_applicability[$1]}"'
2154 else
2155 eval "my_applicability=\"\$${cachevar}_applicability\""
2158 if test -n "$my_applicability"; then
2159 echo $my_applicability
2160 else
2161 # The default is 'main' or 'tests', depending on the module's name.
2162 case $1 in
2163 *-tests) echo "tests";;
2164 *) echo "main";;
2165 esac
2169 # func_get_filelist module
2170 # Input:
2171 # - local_gnulib_path from --local-dir
2172 # - modcache true or false, from --cache-modules/--no-cache-modules
2173 func_get_filelist ()
2175 if ! $modcache; then
2176 func_lookup_file "modules/$1"
2177 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
2178 else
2179 func_cache_lookup_module "$1"
2180 # Output the field's value, including the final newline (if any).
2181 if $have_associative; then
2182 if eval 'test -n "${modcache_files[$1]+set}"'; then
2183 eval 'echo "${modcache_files[$1]}"'
2185 else
2186 eval "field_set=\"\$${cachevar}_files_set\""
2187 if test -n "$field_set"; then
2188 eval "field_value=\"\$${cachevar}_files\""
2189 echo "${field_value}"
2193 echo m4/00gnulib.m4
2194 echo m4/gnulib-common.m4
2195 case "$autoconf_minversion" in
2196 2.59)
2197 echo m4/onceonly.m4
2199 esac
2202 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2203 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2204 # elements starting with prefix and ending with suffix are considered.
2205 # Processing: removed_prefix and removed_suffix are removed from each element,
2206 # added_prefix and added_suffix are added to each element.
2207 # prefix, suffix should not contain shell-special characters.
2208 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2209 # added_prefix, added_suffix should not contain the characters \|&.
2210 func_filter_filelist ()
2212 if test "$2" != "$nl" \
2213 || { $fast_func_append \
2214 && { test -z "$6" || $fast_func_remove_prefix; } \
2215 && { test -z "$7" || $fast_func_remove_suffix; }; \
2216 }; then
2217 ffflist=
2218 for fff in $3; do
2219 # Do not quote possibly-empty parameters in case patterns,
2220 # AIX and HP-UX ksh won't match them if they are empty.
2221 case "$fff" in
2222 $4*$5)
2223 if test -n "$6"; then
2224 func_remove_prefix fff "$6"
2226 if test -n "$7"; then
2227 func_remove_suffix fff "$7"
2229 fff="$8${fff}$9"
2230 if test -z "$ffflist"; then
2231 ffflist="${fff}"
2232 else
2233 func_append ffflist "$2${fff}"
2236 esac
2237 done
2238 else
2239 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2240 ffflist=`for fff in $3; do
2241 case "$fff" in
2242 $4*$5) echo "$fff" ;;
2243 esac
2244 done | sed -e "$sed_fff_filter"`
2246 eval "$1=\"\$ffflist\""
2249 # func_get_dependencies module
2250 # Input:
2251 # - local_gnulib_path from --local-dir
2252 # - modcache true or false, from --cache-modules/--no-cache-modules
2253 func_get_dependencies ()
2255 # ${module}-tests implicitly depends on ${module}, if that module exists.
2256 case "$1" in
2257 *-tests)
2258 fgd1="$1"
2259 func_remove_suffix fgd1 '-tests'
2260 if func_exists_module "$fgd1"; then
2261 echo "$fgd1"
2264 esac
2265 # Then the explicit dependencies listed in the module description.
2266 { if ! $modcache; then
2267 func_lookup_file "modules/$1"
2268 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2269 else
2270 func_cache_lookup_module "$1"
2271 # Output the field's value, including the final newline (if any).
2272 if $have_associative; then
2273 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2274 eval 'echo "${modcache_dependson[$1]}"'
2276 else
2277 eval "field_set=\"\$${cachevar}_dependson_set\""
2278 if test -n "$field_set"; then
2279 eval "field_value=\"\$${cachevar}_dependson\""
2280 echo "${field_value}"
2285 | sed -e '/^#/d'
2288 # func_get_autoconf_early_snippet module
2289 # Input:
2290 # - local_gnulib_path from --local-dir
2291 # - modcache true or false, from --cache-modules/--no-cache-modules
2292 func_get_autoconf_early_snippet ()
2294 if ! $modcache; then
2295 func_lookup_file "modules/$1"
2296 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2297 else
2298 func_cache_lookup_module "$1"
2299 # Output the field's value, including the final newline (if any).
2300 if $have_associative; then
2301 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2302 eval 'echo "${modcache_configureac_early[$1]}"'
2304 else
2305 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2306 if test -n "$field_set"; then
2307 eval "field_value=\"\$${cachevar}_configureac_early\""
2308 echo "${field_value}"
2314 # func_get_autoconf_snippet module
2315 # Input:
2316 # - local_gnulib_path from --local-dir
2317 # - modcache true or false, from --cache-modules/--no-cache-modules
2318 func_get_autoconf_snippet ()
2320 if ! $modcache; then
2321 func_lookup_file "modules/$1"
2322 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2323 else
2324 func_cache_lookup_module "$1"
2325 # Output the field's value, including the final newline (if any).
2326 if $have_associative; then
2327 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2328 eval 'echo "${modcache_configureac[$1]}"'
2330 else
2331 eval "field_set=\"\$${cachevar}_configureac_set\""
2332 if test -n "$field_set"; then
2333 eval "field_value=\"\$${cachevar}_configureac\""
2334 echo "${field_value}"
2340 # Concatenate lines with trailing slash.
2341 # $1 is an optional filter to restrict the
2342 # concatenation to groups starting with that expression
2343 combine_lines() {
2344 sed -e "/$1.*"'\\$/{
2347 s/\\\n/ /
2348 s/\\$/\\/
2353 # func_get_automake_snippet_conditional module
2354 # returns the part of the Makefile.am snippet that can be put inside Automake
2355 # conditionals.
2356 # Input:
2357 # - local_gnulib_path from --local-dir
2358 # - modcache true or false, from --cache-modules/--no-cache-modules
2359 func_get_automake_snippet_conditional ()
2361 if ! $modcache; then
2362 func_lookup_file "modules/$1"
2363 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2364 else
2365 func_cache_lookup_module "$1"
2366 # Output the field's value, including the final newline (if any).
2367 if $have_associative; then
2368 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2369 eval 'echo "${modcache_makefile[$1]}"'
2371 else
2372 eval "field_set=\"\$${cachevar}_makefile_set\""
2373 if test -n "$field_set"; then
2374 eval "field_value=\"\$${cachevar}_makefile\""
2375 echo "${field_value}"
2381 # func_get_automake_snippet_unconditional module
2382 # returns the part of the Makefile.am snippet that must stay outside of
2383 # Automake conditionals.
2384 # Input:
2385 # - local_gnulib_path from --local-dir
2386 # - modcache true or false, from --cache-modules/--no-cache-modules
2387 func_get_automake_snippet_unconditional ()
2389 case "$1" in
2390 *-tests)
2391 # *-tests module live in tests/, not lib/.
2392 # Synthesize an EXTRA_DIST augmentation.
2393 all_files=`func_get_filelist $1`
2394 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2395 extra_files="$tests_files"
2396 if test -n "$extra_files"; then
2397 echo "EXTRA_DIST +=" $extra_files
2398 echo
2402 # Synthesize an EXTRA_DIST augmentation.
2403 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2404 already_mentioned_files=` \
2405 { if ! $modcache; then
2406 func_lookup_file "modules/$1"
2407 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2408 else
2409 func_cache_lookup_module "$1"
2410 if $have_associative; then
2411 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2412 eval 'echo "${modcache_makefile[$1]}"'
2414 else
2415 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2416 if test -n "$field_set"; then
2417 eval 'field_value="$'"${cachevar}"'_makefile"'
2418 echo "${field_value}"
2423 | combine_lines \
2424 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2425 all_files=`func_get_filelist $1`
2426 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2427 # Remove $already_mentioned_files from $lib_files.
2428 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2429 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2430 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2431 if test -n "$extra_files"; then
2432 echo "EXTRA_DIST +=" $extra_files
2433 echo
2435 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2436 # This is necessary so that automake can generate the right list of
2437 # dependency rules.
2438 # A possible approach would be to use autom4te --trace of the redefined
2439 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2440 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2441 # inside autoconf's built-in macros are not missed).
2442 # But it's simpler and more robust to do it here, based on the file list.
2443 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2444 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2445 # automake will generate a useless dependency; this is harmless.
2446 case "$1" in
2447 relocatable-prog-wrapper) ;;
2448 pt_chown) ;;
2450 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2451 if test -n "$extra_files"; then
2452 echo "EXTRA_lib_SOURCES +=" $extra_files
2453 echo
2456 esac
2457 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2458 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2459 if test -n "$buildaux_files"; then
2460 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2461 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2462 echo
2465 esac
2468 # func_get_automake_snippet module
2469 # Input:
2470 # - local_gnulib_path from --local-dir
2471 # - modcache true or false, from --cache-modules/--no-cache-modules
2472 func_get_automake_snippet ()
2474 func_get_automake_snippet_conditional "$1"
2475 func_get_automake_snippet_unconditional "$1"
2478 # func_get_include_directive module
2479 # Input:
2480 # - local_gnulib_path from --local-dir
2481 # - modcache true or false, from --cache-modules/--no-cache-modules
2482 func_get_include_directive ()
2485 if ! $modcache; then
2486 func_lookup_file "modules/$1"
2487 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2488 else
2489 func_cache_lookup_module "$1"
2490 # Output the field's value, including the final newline (if any).
2491 if $have_associative; then
2492 if eval 'test -n "${modcache_include[$1]+set}"'; then
2493 eval 'echo "${modcache_include[$1]}"'
2495 else
2496 eval "field_set=\"\$${cachevar}_include_set\""
2497 if test -n "$field_set"; then
2498 eval "field_value=\"\$${cachevar}_include\""
2499 echo "${field_value}"
2503 } | sed -e 's/^\(["<]\)/#include \1/'
2506 # func_get_link_directive module
2507 # Input:
2508 # - local_gnulib_path from --local-dir
2509 # - modcache true or false, from --cache-modules/--no-cache-modules
2510 func_get_link_directive ()
2512 if ! $modcache; then
2513 func_lookup_file "modules/$1"
2514 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2515 else
2516 func_cache_lookup_module "$1"
2517 # Output the field's value, including the final newline (if any).
2518 if $have_associative; then
2519 if eval 'test -n "${modcache_link[$1]+set}"'; then
2520 eval 'echo "${modcache_link[$1]}"'
2522 else
2523 eval "field_set=\"\$${cachevar}_link_set\""
2524 if test -n "$field_set"; then
2525 eval "field_value=\"\$${cachevar}_link\""
2526 echo "${field_value}"
2532 # func_get_license_raw module
2533 # Input:
2534 # - local_gnulib_path from --local-dir
2535 # - modcache true or false, from --cache-modules/--no-cache-modules
2536 func_get_license_raw ()
2538 if ! $modcache; then
2539 func_lookup_file "modules/$1"
2540 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2541 else
2542 func_cache_lookup_module "$1"
2543 # Output the field's value, including the final newline (if any).
2544 if $have_associative; then
2545 if eval 'test -n "${modcache_license[$1]+set}"'; then
2546 eval 'echo "${modcache_license[$1]}"'
2548 else
2549 eval "field_set=\"\$${cachevar}_license_set\""
2550 if test -n "$field_set"; then
2551 eval "field_value=\"\$${cachevar}_license\""
2552 echo "${field_value}"
2558 # func_get_license module
2559 # Input:
2560 # - local_gnulib_path from --local-dir
2561 # - modcache true or false, from --cache-modules/--no-cache-modules
2562 func_get_license ()
2564 # Warn if the License field is missing.
2565 case "$1" in
2566 *-tests ) ;;
2568 license=`func_get_license_raw "$1"`
2569 if test -z "$license"; then
2570 func_warning "module $1 lacks a License"
2573 esac
2574 case "$1" in
2575 parse-datetime )
2576 # These modules are under a weaker license only for the purpose of some
2577 # users who hand-edit it and don't use gnulib-tool. For the regular
2578 # gnulib users they are under a stricter license.
2579 echo "GPL"
2583 func_get_license_raw "$1"
2584 # The default is GPL.
2585 echo "GPL"
2586 } | sed -e 's,^ *$,,' | sed -e 1q
2588 esac
2591 # func_get_maintainer module
2592 # Input:
2593 # - local_gnulib_path from --local-dir
2594 # - modcache true or false, from --cache-modules/--no-cache-modules
2595 func_get_maintainer ()
2597 if ! $modcache; then
2598 func_lookup_file "modules/$1"
2599 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2600 else
2601 func_cache_lookup_module "$1"
2602 # Output the field's value, including the final newline (if any).
2603 if $have_associative; then
2604 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2605 eval 'echo "${modcache_maintainer[$1]}"'
2607 else
2608 eval "field_set=\"\$${cachevar}_maintainer_set\""
2609 if test -n "$field_set"; then
2610 eval "field_value=\"\$${cachevar}_maintainer\""
2611 echo "${field_value}"
2617 # func_get_tests_module module
2618 # Input:
2619 # - local_gnulib_path from --local-dir
2620 func_get_tests_module ()
2622 # The naming convention for tests modules is hardwired: ${module}-tests.
2623 if test -f "$gnulib_dir/modules/$1"-tests \
2624 || func_path_foreach "$local_gnulib_path" func_exists_local_module %dir% "$1-tests"; then
2625 echo "$1"-tests
2629 # func_acceptable module
2630 # tests whether a module is acceptable.
2631 # Input:
2632 # - avoidlist list of modules to avoid
2633 func_acceptable ()
2635 for avoid in $avoidlist; do
2636 if test "$avoid" = "$1"; then
2637 return 1
2639 done
2640 return 0
2643 # sed expression to keep the first 32 characters of each line.
2644 sed_first_32_chars='s/^\(................................\).*/\1/'
2646 # func_module_shellfunc_name module
2647 # computes the shell function name that will contain the m4 macros for the module.
2648 # Input:
2649 # - macro_prefix prefix to use
2650 # Output:
2651 # - shellfunc shell function name
2652 func_module_shellfunc_name ()
2654 case $1 in
2655 *[!a-zA-Z0-9_]*)
2656 shellfunc=func_${macro_prefix}_gnulib_m4code_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2658 shellfunc=func_${macro_prefix}_gnulib_m4code_$1 ;;
2659 esac
2662 # func_module_shellvar_name module
2663 # computes the shell variable name the will be set to true once the m4 macros
2664 # for the module have been executed.
2665 # Output:
2666 # - shellvar shell variable name
2667 func_module_shellvar_name ()
2669 case $1 in
2670 *[!a-zA-Z0-9_]*)
2671 shellvar=${macro_prefix}_gnulib_enabled_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2673 shellvar=${macro_prefix}_gnulib_enabled_$1 ;;
2674 esac
2677 # func_module_conditional_name module
2678 # computes the automake conditional name for the module.
2679 # Output:
2680 # - conditional name of automake conditional
2681 func_module_conditional_name ()
2683 case $1 in
2684 *[!a-zA-Z0-9_]*)
2685 conditional=${macro_prefix}_GNULIB_ENABLED_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2687 conditional=${macro_prefix}_GNULIB_ENABLED_$1 ;;
2688 esac
2691 # func_uncond_add_module B
2692 # notes the presence of B as an unconditional module.
2694 # func_conddep_add_module A B cond
2695 # notes the presence of a conditional dependency from module A to module B,
2696 # subject to the condition that A is enabled and cond is true.
2698 # func_cond_module_p B
2699 # tests whether module B is conditional.
2701 # func_cond_module_condition A B
2702 # returns the condition when B should be enabled as a dependency of A, once the
2703 # m4 code for A has been executed.
2704 # Output: - condition
2706 if $have_associative; then
2707 declare -A conddep_isuncond
2708 declare -A conddep_dependers
2709 declare -A conddep_condition
2710 func_uncond_add_module ()
2712 eval 'conddep_isuncond[$1]=true'
2713 eval 'unset conddep_dependers[$1]'
2715 func_conddep_add_module ()
2717 eval 'isuncond="${conddep_isuncond[$2]}"'
2718 if test -z "$isuncond"; then
2719 # No unconditional dependency to B known at this point.
2720 eval 'conddep_dependers[$2]="${conddep_dependers[$2]} $1"'
2721 eval 'conddep_condition[$1---$2]="$3"'
2724 func_cond_module_p ()
2726 eval 'previous_dependers="${conddep_dependers[$1]}"'
2727 test -n "$previous_dependers"
2729 func_cond_module_condition ()
2731 eval 'condition="${conddep_condition[$1---$2]}"'
2733 else
2734 func_uncond_add_module ()
2736 case $1 in
2737 *[!a-zA-Z0-9_]*)
2738 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2740 suffix=$1 ;;
2741 esac
2742 eval 'conddep_isuncond_'"$suffix"'=true'
2743 eval 'unset conddep_dependers_'"$suffix"
2745 func_conddep_add_module ()
2747 case $2 in
2748 *[!a-zA-Z0-9_]*)
2749 suffix=`echo "$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2751 suffix=$2 ;;
2752 esac
2753 eval 'isuncond="${conddep_isuncond_'"$suffix"'}"'
2754 if test -z "$isuncond"; then
2755 eval 'conddep_dependers_'"$suffix"'="${conddep_dependers_'"$suffix"'} $1"'
2756 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2757 eval 'conddep_condition_'"$suffix"'="$3"'
2760 func_cond_module_p ()
2762 case $1 in
2763 *[!a-zA-Z0-9_]*)
2764 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2766 suffix=$1 ;;
2767 esac
2768 eval 'previous_dependers="${conddep_dependers_'"$suffix"'}"'
2769 test -n "$previous_dependers"
2771 func_cond_module_condition ()
2773 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2774 eval 'condition="${conddep_condition_'"$suffix"'}"'
2778 sed_dependencies_without_conditions='s/ *\[.*//'
2780 # func_modules_transitive_closure
2781 # Input:
2782 # - local_gnulib_path from --local-dir
2783 # - gnu_make true if --gnu-make was given, false otherwise
2784 # - modcache true or false, from --cache-modules/--no-cache-modules
2785 # - modules list of specified modules
2786 # - inctests true if tests should be included, false otherwise
2787 # - incobsolete true if obsolete modules among dependencies should be
2788 # included, blank otherwise
2789 # - inc_cxx_tests true if C++ interoperability tests should be included,
2790 # blank otherwise
2791 # - inc_longrunning_tests true if long-runnings tests should be included,
2792 # blank otherwise
2793 # - inc_privileged_tests true if tests that require root privileges should be
2794 # included, blank otherwise
2795 # - inc_unportable_tests true if tests that fail on some platforms should be
2796 # included, blank otherwise
2797 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2798 # the unit tests of the specified modules should be
2799 # included, blank otherwise
2800 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2801 # the unit tests of the dependencies should be
2802 # included, blank otherwise
2803 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2804 # blank otherwise
2805 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2806 # blank otherwise
2807 # - excl_privileged_tests true if tests that require root privileges should be
2808 # excluded, blank otherwise
2809 # - excl_unportable_tests true if tests that fail on some platforms should be
2810 # excluded, blank otherwise
2811 # - avoidlist list of modules to avoid
2812 # - cond_dependencies true if conditional dependencies shall be supported,
2813 # blank otherwise
2814 # - tmp pathname of a temporary directory
2815 # Output:
2816 # - modules list of modules, including dependencies
2817 # - conddep_dependers, conddep_condition information about conditionally
2818 # enabled modules
2819 func_modules_transitive_closure ()
2821 sed_escape_dependency='s|\([/.]\)|\\\1|g'
2822 # In order to process every module only once (for speed), process an "input
2823 # list" of modules, producing an "output list" of modules. During each round,
2824 # more modules can be queued in the input list. Once a module on the input
2825 # list has been processed, it is added to the "handled list", so we can avoid
2826 # to process it again.
2827 handledmodules=
2828 inmodules="$modules"
2829 outmodules=
2830 fmtc_inc_all_tests="$inc_all_direct_tests"
2831 if test "$cond_dependencies" = true; then
2832 for module in $inmodules; do
2833 func_verify_module
2834 if test -n "$module"; then
2835 if func_acceptable $module; then
2836 func_uncond_add_module $module
2839 done
2841 while test -n "$inmodules"; do
2842 inmodules_this_round="$inmodules"
2843 inmodules= # Accumulator, queue for next round
2844 for module in $inmodules_this_round; do
2845 func_verify_module
2846 if test -n "$module"; then
2847 if func_acceptable $module; then
2848 func_append outmodules " $module"
2849 if test "$cond_dependencies" = true; then
2850 if ! $gnu_make \
2851 && func_get_automake_snippet_conditional $module \
2852 | grep '^if ' > /dev/null; then
2853 # A module whose Makefile.am snippet contains a reference to an
2854 # automake conditional. If we were to use it conditionally, we
2855 # would get an error
2856 # configure: error: conditional "..." was never defined.
2857 # because automake 1.11.1 does not handle nested conditionals
2858 # correctly. As a workaround, make the module unconditional.
2859 func_uncond_add_module $module
2861 if func_cond_module_p $module; then
2862 conditional=true
2863 else
2864 conditional=false
2867 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2868 # Duplicate dependencies are harmless, but Jim wants a warning.
2869 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2870 if test -n "$duplicated_deps"; then
2871 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2873 if $inctests; then
2874 testsmodule=`func_get_tests_module $module`
2875 if test -n "$testsmodule"; then
2876 deps="$deps $testsmodule"
2879 for dep in $deps; do
2880 # Determine whether to include the dependency or tests module.
2881 inc=true
2882 for word in `func_get_status $dep`; do
2883 case "$word" in
2884 obsolete)
2885 test -n "$incobsolete" \
2886 || inc=false
2888 c++-test)
2889 test -z "$excl_cxx_tests" \
2890 || inc=false
2891 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2892 || inc=false
2894 longrunning-test)
2895 test -z "$excl_longrunning_tests" \
2896 || inc=false
2897 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2898 || inc=false
2900 privileged-test)
2901 test -z "$excl_privileged_tests" \
2902 || inc=false
2903 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2904 || inc=false
2906 unportable-test)
2907 test -z "$excl_unportable_tests" \
2908 || inc=false
2909 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2910 || inc=false
2912 *-test)
2913 test -n "$fmtc_inc_all_tests" \
2914 || inc=false
2916 esac
2917 done
2918 if $inc && func_acceptable "$dep"; then
2919 func_append inmodules " $dep"
2920 if test "$cond_dependencies" = true; then
2921 escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
2922 sed_extract_condition1='/^ *'"$escaped_dep"' *$/{
2923 s/^.*$/true/p
2925 sed_extract_condition2='/^ *'"$escaped_dep"' *\[.*\] *$/{
2926 s/^ *'"$escaped_dep"' *\[\(.*\)\] *$/\1/p
2928 condition=`func_get_dependencies $module | sed -n -e "$sed_extract_condition1" -e "$sed_extract_condition2"`
2929 if test "$condition" = true; then
2930 condition=
2932 if test -n "$condition"; then
2933 func_conddep_add_module "$module" "$dep" "$condition"
2934 else
2935 if $conditional; then
2936 func_conddep_add_module "$module" "$dep" true
2937 else
2938 func_uncond_add_module "$dep"
2943 done
2946 done
2947 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2948 # Remove $handledmodules from $inmodules.
2949 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2950 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2951 fmtc_inc_all_tests="$inc_all_indirect_tests"
2952 done
2953 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2954 rm -f "$tmp"/queued-modules
2957 # func_show_module_list
2958 # Input:
2959 # - specified_modules list of specified modules (one per line, sorted)
2960 # - modules complete list of modules (one per line, sorted)
2961 # - tmp pathname of a temporary directory
2962 func_show_module_list ()
2964 if case "$TERM" in
2965 xterm*) test -t 1;;
2966 *) false;;
2967 esac; then
2968 # Assume xterm compatible escape sequences.
2969 bold_on=`printf '\033[1m'`
2970 bold_off=`printf '\033[0m'`
2971 else
2972 bold_on=
2973 bold_off=
2975 echo "Module list with included dependencies (indented):"
2976 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2977 echo "$modules" | sed -e '/^$/d' \
2978 | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
2979 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2982 # func_modules_transitive_closure_separately
2983 # Determine main module list and tests-related module list separately.
2984 # The main module list is the transitive closure of the specified modules,
2985 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2986 # is specified, it will consist only of LGPLed source.
2987 # The tests-related module list is the transitive closure of the specified
2988 # modules, including tests modules, minus the main module list excluding
2989 # modules of applicability 'all'. Its lib/* sources (brought in through
2990 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
2991 # source, even if --lgpl is specified.
2992 # Input:
2993 # - local_gnulib_path from --local-dir
2994 # - modcache true or false, from --cache-modules/--no-cache-modules
2995 # - specified_modules list of specified modules
2996 # - inctests true if tests should be included, false otherwise
2997 # - incobsolete true if obsolete modules among dependencies should be
2998 # included, blank otherwise
2999 # - inc_cxx_tests true if C++ interoperability tests should be included,
3000 # blank otherwise
3001 # - inc_longrunning_tests true if long-runnings tests should be included,
3002 # blank otherwise
3003 # - inc_privileged_tests true if tests that require root privileges should be
3004 # included, blank otherwise
3005 # - inc_unportable_tests true if tests that fail on some platforms should be
3006 # included, blank otherwise
3007 # - inc_all_direct_tests true if all kinds of problematic unit tests among
3008 # the unit tests of the specified modules should be
3009 # included, blank otherwise
3010 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
3011 # the unit tests of the dependencies should be
3012 # included, blank otherwise
3013 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
3014 # blank otherwise
3015 # - excl_longrunning_tests true if long-runnings tests should be excluded,
3016 # blank otherwise
3017 # - excl_privileged_tests true if tests that require root privileges should be
3018 # excluded, blank otherwise
3019 # - excl_unportable_tests true if tests that fail on some platforms should be
3020 # excluded, blank otherwise
3021 # - avoidlist list of modules to avoid
3022 # - cond_dependencies true if conditional dependencies shall be supported,
3023 # blank otherwise
3024 # - tmp pathname of a temporary directory
3025 # Output:
3026 # - main_modules list of modules, including dependencies
3027 # - testsrelated_modules list of tests-related modules, including dependencies
3028 # - conddep_dependers, conddep_condition information about conditionally
3029 # enabled modules
3030 func_modules_transitive_closure_separately ()
3032 # Determine main module list.
3033 saved_inctests="$inctests"
3034 inctests=false
3035 modules="$specified_modules"
3036 func_modules_transitive_closure
3037 main_modules="$modules"
3038 inctests="$saved_inctests"
3039 if test $verbose -ge 1; then
3040 echo "Main module list:"
3041 echo "$main_modules" | sed -e 's/^/ /'
3043 # Determine tests-related module list.
3044 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3045 testsrelated_modules=`for module in $main_modules; do
3046 if test \`func_get_applicability $module\` = main; then
3047 echo $module
3049 done \
3050 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3051 # If testsrelated_modules consists only of modules with applicability 'all',
3052 # set it to empty (because such modules are only helper modules for other modules).
3053 have_nontrivial_testsrelated_modules=
3054 for module in $testsrelated_modules; do
3055 if test `func_get_applicability $module` != all; then
3056 have_nontrivial_testsrelated_modules=yes
3057 break
3059 done
3060 if test -z "$have_nontrivial_testsrelated_modules"; then
3061 testsrelated_modules=
3063 if test $verbose -ge 1; then
3064 echo "Tests-related module list:"
3065 echo "$testsrelated_modules" | sed -e 's/^/ /'
3069 # func_determine_use_libtests
3070 # Determines whether a $testsbase/libtests.a is needed.
3071 # Input:
3072 # - local_gnulib_path from --local-dir
3073 # - modcache true or false, from --cache-modules/--no-cache-modules
3074 # - testsrelated_modules list of tests-related modules, including dependencies
3075 # Output:
3076 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3077 func_determine_use_libtests ()
3079 use_libtests=false
3080 for module in $testsrelated_modules; do
3081 func_verify_nontests_module
3082 if test -n "$module"; then
3083 all_files=`func_get_filelist $module`
3084 # Test whether some file in $all_files lies in lib/.
3085 for f in $all_files; do
3086 case $f in
3087 lib/*)
3088 use_libtests=true
3089 break 2
3091 esac
3092 done
3094 done
3097 # func_modules_add_dummy
3098 # Input:
3099 # - local_gnulib_path from --local-dir
3100 # - modcache true or false, from --cache-modules/--no-cache-modules
3101 # - modules list of modules, including dependencies
3102 # Output:
3103 # - modules list of modules, including 'dummy' if needed
3104 func_modules_add_dummy ()
3106 # Determine whether any module provides a lib_SOURCES augmentation.
3107 have_lib_SOURCES=
3108 for module in $modules; do
3109 func_verify_nontests_module
3110 if test -n "$module"; then
3111 # Extract the value of "lib_SOURCES += ...".
3112 for file in `func_get_automake_snippet "$module" | combine_lines |
3113 sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
3114 # Ignore .h files since they are not compiled.
3115 case "$file" in
3116 *.h) ;;
3118 have_lib_SOURCES=yes
3119 break 2
3121 esac
3122 done
3124 done
3125 # Add the dummy module, to make sure the library will be non-empty.
3126 if test -z "$have_lib_SOURCES"; then
3127 if func_acceptable "dummy"; then
3128 func_append modules " dummy"
3133 # func_modules_add_dummy_separately
3134 # Input:
3135 # - local_gnulib_path from --local-dir
3136 # - modcache true or false, from --cache-modules/--no-cache-modules
3137 # - main_modules list of modules, including dependencies
3138 # - testsrelated_modules list of tests-related modules, including dependencies
3139 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3140 # Output:
3141 # - main_modules list of modules, including 'dummy' if needed
3142 # - testsrelated_modules list of tests-related modules, including 'dummy' if
3143 # needed
3144 func_modules_add_dummy_separately ()
3146 # Add the dummy module to the main module list if needed.
3147 modules="$main_modules"
3148 func_modules_add_dummy
3149 main_modules="$modules"
3151 # Add the dummy module to the tests-related module list if needed.
3152 if $use_libtests; then
3153 modules="$testsrelated_modules"
3154 func_modules_add_dummy
3155 testsrelated_modules="$modules"
3159 # func_modules_notice
3160 # Input:
3161 # - local_gnulib_path from --local-dir
3162 # - modcache true or false, from --cache-modules/--no-cache-modules
3163 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3164 # - modules list of modules, including dependencies
3165 func_modules_notice ()
3167 if test $verbose -ge -1; then
3168 for module in $modules; do
3169 func_verify_module
3170 if test -n "$module"; then
3171 msg=`func_get_notice $module`
3172 if test -n "$msg"; then
3173 echo "Notice from module $module:"
3174 echo "$msg" | sed -e 's/^/ /'
3177 done
3181 # func_modules_to_filelist
3182 # Input:
3183 # - local_gnulib_path from --local-dir
3184 # - modcache true or false, from --cache-modules/--no-cache-modules
3185 # - modules list of modules, including dependencies
3186 # Output:
3187 # - files list of files
3188 func_modules_to_filelist ()
3190 files=
3191 for module in $modules; do
3192 func_verify_module
3193 if test -n "$module"; then
3194 fs=`func_get_filelist $module`
3195 func_append files " $fs"
3197 done
3198 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
3201 # func_modules_to_filelist_separately
3202 # Determine the final file lists.
3203 # They must be computed separately, because files in lib/* go into
3204 # $sourcebase/ if they are in the main file list but into $testsbase/
3205 # if they are in the tests-related file list. Furthermore lib/dummy.c
3206 # can be in both.
3207 # Input:
3208 # - local_gnulib_path from --local-dir
3209 # - modcache true or false, from --cache-modules/--no-cache-modules
3210 # - main_modules list of modules, including dependencies
3211 # - testsrelated_modules list of tests-related modules, including dependencies
3212 func_modules_to_filelist_separately ()
3214 # Determine final main file list.
3215 modules="$main_modules"
3216 func_modules_to_filelist
3217 main_files="$files"
3218 # Determine final tests-related file list.
3219 modules="$testsrelated_modules"
3220 func_modules_to_filelist
3221 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3222 # Merge both file lists.
3223 sed_remove_empty_lines='/^$/d'
3224 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3225 if test $verbose -ge 0; then
3226 echo "File list:"
3227 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3228 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3232 # func_compute_include_guard_prefix
3233 # Determine include_guard_prefix.
3234 # Input:
3235 # - macro_prefix prefix of gl_LIBOBJS macros to use
3236 # Output:
3237 # - include_guard_prefix replacement for ${gl_include_guard_prefix}
3238 # - sed_replace_include_guard_prefix
3239 # sed expression for resolving ${gl_include_guard_prefix}
3240 func_compute_include_guard_prefix ()
3242 if test "$macro_prefix" = gl; then
3243 include_guard_prefix='GL'
3244 else
3245 include_guard_prefix='GL_'`echo "$macro_prefix" | LC_ALL=C tr '[a-z]' '[A-Z]'`
3247 sed_replace_include_guard_prefix='s/\${gl_include_guard_prefix}/'"${include_guard_prefix}"'/g'
3250 # func_execute_command command [args...]
3251 # Executes a command.
3252 # Uses also the variables
3253 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3254 func_execute_command ()
3256 if test $verbose -ge 0; then
3257 echo "executing $*"
3258 "$@"
3259 else
3260 # Commands like automake produce output to stderr even when they succeed.
3261 # Turn this output off if the command succeeds.
3262 "$@" > "$tmp"/cmdout 2>&1
3263 cmdret=$?
3264 if test $cmdret = 0; then
3265 rm -f "$tmp"/cmdout
3266 else
3267 echo "executing $*"
3268 cat "$tmp"/cmdout 1>&2
3269 rm -f "$tmp"/cmdout
3270 (exit $cmdret)
3275 # func_dest_tmpfilename file
3276 # determines the name of a temporary file (file is relative to destdir).
3277 # Input:
3278 # - destdir target directory
3279 # - doit : if actions shall be executed, false if only to be printed
3280 # - tmp pathname of a temporary directory
3281 # Sets variable:
3282 # - tmpfile absolute filename of the temporary file
3283 func_dest_tmpfilename ()
3285 if $doit; then
3286 # Put the new contents of $file in a file in the same directory (needed
3287 # to guarantee that an 'mv' to "$destdir/$file" works).
3288 tmpfile="$destdir/$1.tmp"
3289 else
3290 # Put the new contents of $file in a file in a temporary directory
3291 # (because the directory of "$file" might not exist).
3292 tmpfile="$tmp"/`basename "$1"`.tmp
3296 # func_is_local_file lookedup_file file
3297 # check whether file should be instantiated from local gnulib directory
3298 func_is_local_file ()
3300 dname=$1
3301 func_remove_suffix dname "/$2"
3302 func_path_foreach "$local_gnulib_path" test %dir% = "$dname"
3305 # func_should_symlink
3306 # returns 0 when the file $f should be symlinked
3307 # Input:
3308 # - symbolic true if files should be symlinked, copied otherwise
3309 # - lsymbolic true if files from local_gnulib_path should be symlinked,
3310 # copied otherwise
3311 # - f the original file name
3312 # - lookedup_file name of the merged (combined) file
3313 func_should_symlink ()
3315 test -n "$symbolic" \
3316 || { test -n "$lsymbolic" \
3317 && func_is_local_file "$lookedup_file" "$f"; }
3320 # func_add_file
3321 # copies a file from gnulib into the destination directory. The destination
3322 # is known to not exist.
3323 # Input:
3324 # - destdir target directory
3325 # - local_gnulib_path from --local-dir
3326 # - modcache true or false, from --cache-modules/--no-cache-modules
3327 # - f the original file name
3328 # - lookedup_file name of the merged (combined) file
3329 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3330 # - g the rewritten file name
3331 # - tmpfile absolute filename of the temporary file
3332 # - doit : if actions shall be executed, false if only to be printed
3333 # - symbolic true if files should be symlinked, copied otherwise
3334 # - lsymbolic true if files from local_gnulib_path should be symlinked,
3335 # copied otherwise
3336 func_add_file ()
3338 if $doit; then
3339 echo "Copying file $g"
3340 if func_should_symlink \
3341 && test -z "$lookedup_tmp" \
3342 && cmp -s "$lookedup_file" "$tmpfile"; then
3343 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3344 else
3345 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3347 else
3348 echo "Copy file $g"
3352 # func_update_file
3353 # copies a file from gnulib into the destination directory. The destination
3354 # is known to exist.
3355 # Input:
3356 # - destdir target directory
3357 # - local_gnulib_path from --local-dir
3358 # - modcache true or false, from --cache-modules/--no-cache-modules
3359 # - f the original file name
3360 # - lookedup_file name of the merged (combined) file
3361 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3362 # - g the rewritten file name
3363 # - tmpfile absolute filename of the temporary file
3364 # - doit : if actions shall be executed, false if only to be printed
3365 # - symbolic true if files should be symlinked, copied otherwise
3366 # - lsymbolic true if files from local_gnulib_path should be symlinked,
3367 # copied otherwise
3368 # - already_present nonempty if the file should already exist, empty otherwise
3369 func_update_file ()
3371 if cmp -s "$destdir/$g" "$tmpfile"; then
3372 : # The file has not changed.
3373 else
3374 # Replace the file.
3375 if $doit; then
3376 if test -n "$already_present"; then
3377 echo "Updating file $g (backup in ${g}~)"
3378 else
3379 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
3381 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3382 if func_should_symlink \
3383 && test -z "$lookedup_tmp" \
3384 && cmp -s "$lookedup_file" "$tmpfile"; then
3385 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3386 else
3387 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3389 else
3390 if test -n "$already_present"; then
3391 echo "Update file $g (backup in ${g}~)"
3392 else
3393 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
3399 # func_emit_lib_Makefile_am
3400 # emits the contents of library makefile to standard output.
3401 # Input:
3402 # - local_gnulib_path from --local-dir
3403 # - modcache true or false, from --cache-modules/--no-cache-modules
3404 # - modules list of modules, including dependencies
3405 # - libname library name
3406 # - pobase directory relative to destdir where to place *.po files
3407 # - auxdir directory relative to destdir where to place build aux files
3408 # - gnu_make true if --gnu-make was given, false otherwise
3409 # - makefile_name from --makefile-name
3410 # - libtool true if libtool will be used, false or blank otherwise
3411 # - macro_prefix prefix of gl_LIBOBJS macros to use
3412 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3413 # - witness_c_macro from --witness-c-macro
3414 # - actioncmd (optional) command that will reproduce this invocation
3415 # - for_test true if creating a package for testing, false otherwise
3416 # - sed_replace_include_guard_prefix
3417 # sed expression for resolving ${gl_include_guard_prefix}
3418 # - destfile filename relative to destdir of makefile being generated
3419 # Input/Output:
3420 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3421 # list of edits to be done to Makefile.am variables
3422 # Output:
3423 # - uses_subdirs nonempty if object files in subdirs exist
3424 func_emit_lib_Makefile_am ()
3427 # When using GNU make, or when creating an includable Makefile.am snippet,
3428 # augment variables with += instead of assigning them.
3429 if $gnu_make || test -n "$makefile_name"; then
3430 assign='+='
3431 else
3432 assign='='
3434 if test "$libtool" = true; then
3435 libext=la
3436 perhapsLT=LT
3437 sed_eliminate_LDFLAGS="$sed_noop"
3438 else
3439 libext=a
3440 perhapsLT=
3441 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3443 if $for_test; then
3444 # When creating a package for testing: Attempt to provoke failures,
3445 # especially link errors, already during "make" rather than during
3446 # "make check", because "make check" is not possible in a cross-compiling
3447 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3448 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3449 else
3450 sed_transform_check_PROGRAMS="$sed_noop"
3452 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3453 echo "## Process this file with automake to produce Makefile.in."
3454 func_emit_copyright_notice
3455 if test -n "$actioncmd"; then
3456 # The maximum line length (excluding the terminating newline) of any file
3457 # that is to be preprocessed by config.status is 3070. config.status uses
3458 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
3459 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
3460 len=`echo "$actioncmd" | wc -c`
3461 if test -n "$len" && test "$len" -le 3000; then
3462 echo "# Reproduce by: $actioncmd"
3465 echo
3466 uses_subdirs=
3468 for module in $modules; do
3469 func_verify_nontests_module
3470 if test -n "$module"; then
3472 func_get_automake_snippet_conditional "$module" |
3473 LC_ALL=C \
3474 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3475 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3476 -e "$sed_eliminate_LDFLAGS" \
3477 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3478 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3479 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3480 -e "$sed_transform_check_PROGRAMS" \
3481 -e "$sed_replace_include_guard_prefix"
3482 if test "$module" = 'alloca'; then
3483 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
3484 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3486 } | combine_lines "${libname}_${libext}_SOURCES" > "$tmp"/amsnippet1
3488 func_get_automake_snippet_unconditional "$module" |
3489 LC_ALL=C sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
3490 } > "$tmp"/amsnippet2
3491 # Skip the contents if it's entirely empty.
3492 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
3493 echo "## begin gnulib module $module"
3494 if $gnu_make; then
3495 echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
3496 convert_to_gnu_make='s/^if \(.*\)/ifneq (,$(\1))/'
3497 else
3498 convert_to_gnu_make=
3500 echo
3501 if test "$cond_dependencies" = true; then
3502 if func_cond_module_p "$module"; then
3503 func_module_conditional_name "$module"
3504 if $gnu_make; then
3505 echo "ifneq (,\$($conditional))"
3506 else
3507 echo "if $conditional"
3511 sed "$convert_to_gnu_make" "$tmp"/amsnippet1
3512 if test "$cond_dependencies" = true; then
3513 if func_cond_module_p "$module"; then
3514 echo "endif"
3517 sed "$convert_to_gnu_make" "$tmp"/amsnippet2
3518 if $gnu_make; then
3519 echo "endif"
3521 echo "## end gnulib module $module"
3522 echo
3524 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
3525 # Test whether there are some source files in subdirectories.
3526 for f in `func_get_filelist "$module"`; do
3527 case $f in
3528 lib/*/*.c)
3529 uses_subdirs=yes
3530 break
3532 esac
3533 done
3535 done
3536 } > "$tmp"/allsnippets
3537 if test -z "$makefile_name"; then
3538 # If there are source files in subdirectories, prevent collision of the
3539 # object files (example: hash.c and libxml/hash.c).
3540 subdir_options=
3541 if test -n "$uses_subdirs"; then
3542 subdir_options=' subdir-objects'
3544 echo "AUTOMAKE_OPTIONS = 1.9.6 gnits${subdir_options}"
3546 echo
3547 if test -z "$makefile_name"; then
3548 echo "SUBDIRS ="
3549 echo "noinst_HEADERS ="
3550 echo "noinst_LIBRARIES ="
3551 echo "noinst_LTLIBRARIES ="
3552 # Automake versions < 1.11.4 create an empty pkgdatadir at
3553 # installation time if you specify pkgdata_DATA to empty.
3554 # See automake bugs #10997 and #11030:
3555 # * http://debbugs.gnu.org/10997
3556 # * http://debbugs.gnu.org/11030
3557 # So we need this workaround.
3558 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
3559 echo "pkgdata_DATA ="
3561 echo "EXTRA_DIST ="
3562 echo "BUILT_SOURCES ="
3563 echo "SUFFIXES ="
3565 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3566 if test -z "$makefile_name"; then
3567 echo "MOSTLYCLEANDIRS ="
3568 echo "CLEANFILES ="
3569 echo "DISTCLEANFILES ="
3570 echo "MAINTAINERCLEANFILES ="
3572 if $gnu_make; then
3573 echo "# Start of GNU Make output."
3575 # Put autoconf output into a temporary file, so that its exit status
3576 # can be checked from the shell. Signal any error by putting a
3577 # syntax error into the output makefile.
3578 ${AUTOCONF} -t 'AC_SUBST:$1 = @$1@' "$configure_ac" \
3579 >"$tmp"/makeout 2>"$tmp"/makeout2 &&
3580 LC_ALL=C sort -u "$tmp"/makeout || {
3581 echo "== gnulib-tool GNU Make output failed as follows =="
3582 sed 's/^/# stderr: /' "$tmp"/makeout2
3584 rm -f "$tmp"/makeout "$tmp"/makeout2
3586 echo "# End of GNU Make output."
3587 else
3588 echo "# No GNU Make output."
3590 # Execute edits that apply to the Makefile.am being generated.
3591 edit=0
3592 while test $edit != $makefile_am_edits; do
3593 edit=`expr $edit + 1`
3594 eval dir=\"\$makefile_am_edit${edit}_dir\"
3595 eval var=\"\$makefile_am_edit${edit}_var\"
3596 eval val=\"\$makefile_am_edit${edit}_val\"
3597 if test -n "$var"; then
3598 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3599 echo "${var} += ${val}"
3600 eval "makefile_am_edit${edit}_var="
3603 done
3604 if test -n "$witness_c_macro"; then
3605 cppflags_part1=" -D$witness_c_macro=1"
3606 else
3607 cppflags_part1=
3609 if $for_test; then
3610 cppflags_part2=" -DGNULIB_STRICT_CHECKING=1"
3611 else
3612 cppflags_part2=
3614 if test -z "$makefile_name"; then
3615 echo
3616 echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
3617 echo "AM_CFLAGS ="
3618 else
3619 if test -n "$cppflags_part1$cppflags_part2"; then
3620 echo
3621 echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
3624 echo
3625 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
3626 || { test -n "$makefile_name" \
3627 && test -f "$sourcebase/Makefile.am" \
3628 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
3629 }; then
3630 # One of the snippets or the user's Makefile.am already specifies an
3631 # installation location for the library. Don't confuse automake by saying
3632 # it should not be installed.
3634 else
3635 # By default, the generated library should not be installed.
3636 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3638 echo
3639 echo "${libname}_${libext}_SOURCES ="
3640 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3641 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3642 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3643 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3644 echo "EXTRA_${libname}_${libext}_SOURCES ="
3645 if test "$libtool" = true; then
3646 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3647 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3648 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3649 # the link dependencies of all modules.
3650 for module in $modules; do
3651 func_verify_nontests_module
3652 if test -n "$module"; then
3653 func_get_link_directive "$module"
3655 done \
3656 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
3657 | LC_ALL=C sort -u \
3658 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
3660 echo
3661 if test -n "$pobase"; then
3662 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
3663 echo
3665 cat "$tmp"/allsnippets \
3666 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3667 echo
3668 echo "mostlyclean-local: mostlyclean-generic"
3669 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3670 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3671 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3672 echo " fi; \\"
3673 echo " done; \\"
3674 echo " :"
3675 rm -f "$tmp"/allsnippets
3678 # func_emit_po_Makevars
3679 # emits the contents of po/ makefile parameterization to standard output.
3680 # Input:
3681 # - local_gnulib_path from --local-dir
3682 # - modcache true or false, from --cache-modules/--no-cache-modules
3683 # - sourcebase directory relative to destdir where to place source code
3684 # - pobase directory relative to destdir where to place *.po files
3685 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3686 func_emit_po_Makevars ()
3688 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3689 func_emit_copyright_notice
3690 echo
3691 echo "# Usually the message domain is the same as the package name."
3692 echo "# But here it has a '-gnulib' suffix."
3693 echo "DOMAIN = ${po_domain}-gnulib"
3694 echo
3695 echo "# These two variables depend on the location of this directory."
3696 echo "subdir = ${pobase}"
3697 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
3698 echo
3699 cat <<\EOF
3700 # These options get passed to xgettext.
3701 XGETTEXT_OPTIONS = \
3702 --keyword=_ --flag=_:1:pass-c-format \
3703 --keyword=N_ --flag=N_:1:pass-c-format \
3704 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
3705 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
3706 --flag=error:3:c-format --flag=error_at_line:5:c-format
3708 # This is the copyright holder that gets inserted into the header of the
3709 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
3710 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
3712 # This is the email address or URL to which the translators shall report
3713 # bugs in the untranslated strings:
3714 # - Strings which are not entire sentences, see the maintainer guidelines
3715 # in the GNU gettext documentation, section 'Preparing Strings'.
3716 # - Strings which use unclear terms or require additional context to be
3717 # understood.
3718 # - Strings which make invalid assumptions about notation of date, time or
3719 # money.
3720 # - Pluralisation problems.
3721 # - Incorrect English spelling.
3722 # - Incorrect formatting.
3723 # It can be your email address, or a mailing list address where translators
3724 # can write to without being subscribed, or the URL of a web page through
3725 # which the translators can contact you.
3726 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3728 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3729 # message catalogs shall be used. It is usually empty.
3730 EXTRA_LOCALE_CATEGORIES =
3732 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3733 # context. Possible values are "yes" and "no". Set this to yes if the
3734 # package uses functions taking also a message context, like pgettext(), or
3735 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3736 USE_MSGCTXT = no
3740 # func_emit_po_POTFILES_in
3741 # emits the file list to be passed to xgettext to standard output.
3742 # Input:
3743 # - local_gnulib_path from --local-dir
3744 # - modcache true or false, from --cache-modules/--no-cache-modules
3745 # - sourcebase directory relative to destdir where to place source code
3746 # - files list of new files
3747 func_emit_po_POTFILES_in ()
3749 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3750 func_emit_copyright_notice
3751 echo
3752 echo "# List of files which contain translatable strings."
3753 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3756 # func_emit_tests_Makefile_am witness_macro
3757 # emits the contents of tests makefile to standard output.
3758 # Input:
3759 # - local_gnulib_path from --local-dir
3760 # - modcache true or false, from --cache-modules/--no-cache-modules
3761 # - modules list of modules, including dependencies
3762 # - libname library name
3763 # - auxdir directory relative to destdir where to place build aux files
3764 # - gnu_make true if --gnu-make was given, false otherwise
3765 # - makefile_name from --makefile-name
3766 # - libtool true if libtool will be used, false or blank otherwise
3767 # - sourcebase relative directory containing lib source code
3768 # - m4base relative directory containing autoconf macros
3769 # - testsbase relative directory containing unit test code
3770 # - macro_prefix prefix of gl_LIBOBJS macros to use
3771 # - witness_c_macro from --witness-c-macro
3772 # - for_test true if creating a package for testing, false otherwise
3773 # - single_configure true if a single configure file should be generated,
3774 # false for a separate configure file for the tests
3775 # - use_libtests true if a libtests.a should be built, false otherwise
3776 # - sed_replace_include_guard_prefix
3777 # sed expression for resolving ${gl_include_guard_prefix}
3778 # - destfile filename relative to destdir of makefile being generated
3779 # Input/Output:
3780 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3781 # list of edits to be done to Makefile.am variables
3782 # Output:
3783 # - uses_subdirs nonempty if object files in subdirs exist
3784 func_emit_tests_Makefile_am ()
3786 witness_macro="$1"
3787 if test "$libtool" = true; then
3788 libext=la
3789 perhapsLT=LT
3790 sed_eliminate_LDFLAGS="$sed_noop"
3791 else
3792 libext=a
3793 perhapsLT=
3794 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3796 if $for_test; then
3797 # When creating a package for testing: Attempt to provoke failures,
3798 # especially link errors, already during "make" rather than during
3799 # "make check", because "make check" is not possible in a cross-compiling
3800 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3801 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3802 else
3803 sed_transform_check_PROGRAMS="$sed_noop"
3805 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3806 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3807 echo "## Process this file with automake to produce Makefile.in."
3808 func_emit_copyright_notice
3809 echo
3810 uses_subdirs=
3812 for module in $modules; do
3813 if $for_test && ! $single_configure; then
3814 func_verify_tests_module
3815 else
3816 func_verify_module
3818 if test -n "$module"; then
3820 func_get_automake_snippet "$module" |
3821 LC_ALL=C \
3822 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3823 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3824 -e "$sed_eliminate_LDFLAGS" \
3825 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3826 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3827 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3828 -e "$sed_transform_check_PROGRAMS" \
3829 -e "$sed_replace_include_guard_prefix"
3830 if $use_libtests && test "$module" = 'alloca'; then
3831 echo "libtests_a_LIBADD += @ALLOCA@"
3832 echo "libtests_a_DEPENDENCIES += @ALLOCA@"
3834 } > "$tmp"/amsnippet
3835 # Skip the contents if it's entirely empty.
3836 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3837 # Mention long-running tests at the end.
3838 ofd=3
3839 for word in `func_get_status "$module"`; do
3840 if test "$word" = 'longrunning-test'; then
3841 ofd=4
3842 break
3844 done
3845 { echo "## begin gnulib module $module"
3846 if $gnu_make; then
3847 echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
3849 echo
3850 cat "$tmp"/amsnippet
3851 if $gnu_make; then
3852 echo "endif"
3854 echo "## end gnulib module $module"
3855 echo
3856 } >&$ofd
3858 rm -f "$tmp"/amsnippet
3859 # Test whether there are some source files in subdirectories.
3860 for f in `func_get_filelist "$module"`; do
3861 case $f in
3862 lib/*/*.c | tests/*/*.c)
3863 uses_subdirs=yes
3864 break
3866 esac
3867 done
3869 done
3870 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3871 # Generate dependencies here, since it eases the debugging of test failures.
3872 # If there are source files in subdirectories, prevent collision of the
3873 # object files (example: hash.c and libxml/hash.c).
3874 subdir_options=
3875 if test -n "$uses_subdirs"; then
3876 subdir_options=' subdir-objects'
3878 echo "AUTOMAKE_OPTIONS = 1.9.6 foreign${subdir_options}"
3879 echo
3880 if $for_test && ! $single_configure; then
3881 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3882 echo
3884 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3885 # variable is needed to avoid an error from automake:
3886 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3887 echo "SUBDIRS = ."
3888 echo "TESTS ="
3889 echo "XFAIL_TESTS ="
3890 echo "TESTS_ENVIRONMENT ="
3891 echo "noinst_PROGRAMS ="
3892 if ! $for_test; then
3893 echo "check_PROGRAMS ="
3895 echo "EXTRA_PROGRAMS ="
3896 echo "noinst_HEADERS ="
3897 echo "noinst_LIBRARIES ="
3898 if $use_libtests; then
3899 if $for_test; then
3900 echo "noinst_LIBRARIES += libtests.a"
3901 else
3902 echo "check_LIBRARIES = libtests.a"
3905 # Automake versions < 1.11.4 create an empty pkgdatadir at
3906 # installation time if you specify pkgdata_DATA to empty.
3907 # See automake bugs #10997 and #11030:
3908 # * http://debbugs.gnu.org/10997
3909 # * http://debbugs.gnu.org/11030
3910 # So we need this workaround.
3911 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3912 echo "pkgdata_DATA ="
3914 echo "EXTRA_DIST ="
3915 echo "BUILT_SOURCES ="
3916 echo "SUFFIXES ="
3917 echo "MOSTLYCLEANFILES = core *.stackdump"
3918 echo "MOSTLYCLEANDIRS ="
3919 echo "CLEANFILES ="
3920 echo "DISTCLEANFILES ="
3921 echo "MAINTAINERCLEANFILES ="
3922 # Execute edits that apply to the Makefile.am being generated.
3923 edit=0
3924 while test $edit != $makefile_am_edits; do
3925 edit=`expr $edit + 1`
3926 eval dir=\"\$makefile_am_edit${edit}_dir\"
3927 eval var=\"\$makefile_am_edit${edit}_var\"
3928 eval val=\"\$makefile_am_edit${edit}_val\"
3929 if test -n "$var"; then
3930 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3931 echo "${var} += ${val}"
3932 eval "makefile_am_edit${edit}_var="
3935 done
3936 echo
3937 echo "AM_CPPFLAGS = \\"
3938 if $for_test; then
3939 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3941 if test -n "$witness_c_macro"; then
3942 echo " -D$witness_c_macro=1 \\"
3944 if test -n "${witness_macro}"; then
3945 echo " -D@${witness_macro}@=1 \\"
3947 echo " -I. -I\$(srcdir) \\"
3948 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3949 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3950 echo
3951 local_ldadd_before=''
3952 local_ldadd_after=''
3953 if $use_libtests; then
3954 # All test programs need to be linked with libtests.a.
3955 # It needs to be passed to the linker before ${libname}.${libext}, since
3956 # the tests-related modules depend on the main modules.
3957 # It also needs to be passed to the linker after ${libname}.${libext}
3958 # because the latter might contain incomplete modules (such as the 'error'
3959 # module whose dependency to 'progname' is voluntarily omitted).
3960 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3961 # not matter.
3962 local_ldadd_before=' libtests.a'
3963 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3965 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3966 echo
3967 if $use_libtests; then
3968 echo "libtests_a_SOURCES ="
3969 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3970 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3971 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3972 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3973 echo "EXTRA_libtests_a_SOURCES ="
3974 # The circular dependency in LDADD requires this.
3975 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3976 echo
3978 # Many test scripts use ${EXEEXT} or ${srcdir}.
3979 # EXEEXT is defined by AC_PROG_CC through autoconf.
3980 # srcdir is defined by autoconf and automake.
3981 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3982 echo
3983 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3984 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3985 echo "# Clean up after Solaris cc."
3986 echo "clean-local:"
3987 echo " rm -rf SunWS_cache"
3988 echo
3989 echo "mostlyclean-local: mostlyclean-generic"
3990 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3991 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3992 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3993 echo " fi; \\"
3994 echo " done; \\"
3995 echo " :"
3996 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3999 # func_emit_initmacro_start macro_prefix
4000 # emits the first few statements of the gl_INIT macro to standard output.
4001 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4002 func_emit_initmacro_start ()
4004 macro_prefix_arg="$1"
4005 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
4006 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
4007 # LIBOBJS. The purpose is to allow several gnulib instantiations under
4008 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
4009 # flexibility.)
4010 # Furthermore it avoids an automake error like this when a Makefile.am
4011 # that uses pieces of gnulib also uses $(LIBOBJ):
4012 # automatically discovered file `error.c' should not be explicitly mentioned
4013 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
4014 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
4015 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
4016 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
4017 # automatically discovered file `error.c' should not be explicitly mentioned
4018 # We let automake know about the files to be distributed through the
4019 # EXTRA_lib_SOURCES variable.
4020 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
4021 # Create data variables for checking the presence of files that are mentioned
4022 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
4023 # because we want the check to happen when the configure file is created,
4024 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
4025 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
4026 # in which to expect them.
4027 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
4028 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
4029 echo " gl_COMMON"
4032 # func_emit_initmacro_end macro_prefix
4033 # emits the last few statements of the gl_INIT macro to standard output.
4034 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4035 func_emit_initmacro_end ()
4037 macro_prefix_arg="$1"
4038 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
4039 # The check is performed only when autoconf is run from the directory where
4040 # the configure.ac resides; if it is run from a different directory, the
4041 # check is skipped.
4042 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
4043 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
4044 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
4045 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
4046 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
4047 echo " exit 1"
4048 echo " fi"
4049 echo " done])dnl"
4050 echo " m4_if(m4_sysval, [0], [],"
4051 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
4052 echo " ])"
4053 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
4054 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
4055 echo " m4_popdef([AC_LIBSOURCES])"
4056 echo " m4_popdef([AC_REPLACE_FUNCS])"
4057 echo " m4_popdef([AC_LIBOBJ])"
4058 echo " AC_CONFIG_COMMANDS_PRE(["
4059 echo " ${macro_prefix_arg}_libobjs="
4060 echo " ${macro_prefix_arg}_ltlibobjs="
4061 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
4062 echo " # Remove the extension."
4063 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
4064 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
4065 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
4066 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
4067 echo " done"
4068 echo " fi"
4069 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
4070 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
4071 echo " ])"
4074 # func_emit_initmacro_done macro_prefix sourcebase
4075 # emits a few statements after the gl_INIT macro to standard output.
4076 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4077 # - sourcebase directory relative to destdir where to place source code
4078 func_emit_initmacro_done ()
4080 macro_prefix_arg="$1"
4081 sourcebase_arg="$2"
4082 echo
4083 echo "# Like AC_LIBOBJ, except that the module name goes"
4084 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4085 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
4086 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
4087 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
4088 echo "])"
4089 echo
4090 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
4091 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4092 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
4093 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
4094 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
4095 echo "])"
4096 echo
4097 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
4098 echo "# expected is derived from the gnulib-tool parameterization,"
4099 echo "# and alloca is special cased (for the alloca-opt module)."
4100 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
4101 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
4102 echo " m4_foreach([_gl_NAME], [\$1], ["
4103 echo " m4_if(_gl_NAME, [alloca.c], [], ["
4104 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
4105 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
4106 echo " ])"
4107 echo " ])"
4108 echo "])"
4111 # func_emit_autoconf_snippet indentation
4112 # emits the autoconf snippet of a module.
4113 # Input:
4114 # - indentation spaces to prepend on each line
4115 # - local_gnulib_path from --local-dir
4116 # - modcache true or false, from --cache-modules/--no-cache-modules
4117 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4118 # - sed_replace_include_guard_prefix
4119 # sed expression for resolving ${gl_include_guard_prefix}
4120 # - module the module name
4121 # - toplevel true or false. 'false' means a subordinate use of
4122 # gnulib-tool.
4123 # - disable_libtool true or false. It tells whether to disable libtool
4124 # handling even if it has been specified through the
4125 # command line options.
4126 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4127 # invocations.
4128 func_emit_autoconf_snippet ()
4130 indentation="$1"
4131 if { case $module in
4132 gnumakefile | maintainer-makefile)
4133 # These modules are meant to be used only in the top-level directory.
4134 $toplevel ;;
4136 true ;;
4137 esac
4138 }; then
4139 func_get_autoconf_snippet "$module" \
4140 | sed -e '/^$/d;' -e "s/^/$indentation/" \
4141 -e "$sed_replace_build_aux" \
4142 -e "$sed_replace_include_guard_prefix" \
4143 | { if $disable_libtool; then
4144 sed -e 's/\$gl_cond_libtool/false/g' \
4145 -e 's/gl_libdeps/gltests_libdeps/g' \
4146 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4147 else
4151 | { if $disable_gettext; then
4152 sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
4153 else
4154 # Don't indent AM_GNU_GETTEXT_VERSION line, as that confuses
4155 # autopoint through at least GNU gettext version 0.18.2.
4156 sed -e 's/^ *AM_GNU_GETTEXT_VERSION/AM_GNU_GETTEXT_VERSION/'
4159 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
4160 echo 'changequote(,)dnl'
4161 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4162 echo 'changequote([, ])dnl'
4163 echo 'AC_SUBST([LTALLOCA])'
4168 # func_emit_autoconf_snippets modules verifier toplevel disable_libtool disable_gettext
4169 # collects and emit the autoconf snippets of a set of modules.
4170 # Input:
4171 # - local_gnulib_path from --local-dir
4172 # - modcache true or false, from --cache-modules/--no-cache-modules
4173 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4174 # - sed_replace_include_guard_prefix
4175 # sed expression for resolving ${gl_include_guard_prefix}
4176 # - modules the list of modules.
4177 # - verifier one of func_verify_module, func_verify_nontests_module,
4178 # func_verify_tests_module. It selects the subset of
4179 # $modules to consider.
4180 # - toplevel true or false. 'false' means a subordinate use of
4181 # gnulib-tool.
4182 # - disable_libtool true or false. It tells whether to disable libtool
4183 # handling even if it has been specified through the
4184 # command line options.
4185 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4186 # invocations.
4187 func_emit_autoconf_snippets ()
4189 verifier="$2"
4190 toplevel="$3"
4191 disable_libtool="$4"
4192 disable_gettext="$5"
4193 if test "$cond_dependencies" = true; then
4194 for m in $modules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/modules
4195 # Emit the autoconf code for the unconditional modules.
4196 for module in $1; do
4197 eval $verifier
4198 if test -n "$module"; then
4199 if func_cond_module_p "$module"; then
4201 else
4202 func_emit_autoconf_snippet " "
4205 done
4206 # Initialize the shell variables indicating that the modules are enabled.
4207 for module in $1; do
4208 eval $verifier
4209 if test -n "$module"; then
4210 if func_cond_module_p "$module"; then
4211 func_module_shellvar_name "$module"
4212 echo " $shellvar=false"
4215 done
4216 # Emit the autoconf code for the conditional modules, each in a separate
4217 # function. This makes it possible to support cycles among conditional
4218 # modules.
4219 for module in $1; do
4220 eval $verifier
4221 if test -n "$module"; then
4222 if func_cond_module_p "$module"; then
4223 func_module_shellfunc_name "$module"
4224 func_module_shellvar_name "$module"
4225 echo " $shellfunc ()"
4226 echo ' {'
4227 echo " if ! \$$shellvar; then"
4228 func_emit_autoconf_snippet " "
4229 echo " $shellvar=true"
4230 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4231 # Intersect $deps with the modules list $1.
4232 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4233 for dep in $deps; do
4234 if func_cond_module_p "$dep"; then
4235 func_module_shellfunc_name "$dep"
4236 func_cond_module_condition "$module" "$dep"
4237 if test "$condition" != true; then
4238 echo " if $condition; then"
4239 echo " $shellfunc"
4240 echo ' fi'
4241 else
4242 echo " $shellfunc"
4244 else
4245 # The autoconf code for $dep has already been emitted above and
4246 # therefore is already executed when this function is run.
4249 done
4250 echo ' fi'
4251 echo ' }'
4254 done
4255 # Emit the dependencies from the unconditional to the conditional modules.
4256 for module in $1; do
4257 eval $verifier
4258 if test -n "$module"; then
4259 if func_cond_module_p "$module"; then
4261 else
4262 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4263 # Intersect $deps with the modules list $1.
4264 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4265 for dep in $deps; do
4266 if func_cond_module_p "$dep"; then
4267 func_module_shellfunc_name "$dep"
4268 func_cond_module_condition "$module" "$dep"
4269 if test "$condition" != true; then
4270 echo " if $condition; then"
4271 echo " $shellfunc"
4272 echo ' fi'
4273 else
4274 echo " $shellfunc"
4276 else
4277 # The autoconf code for $dep has already been emitted above and
4278 # therefore is already executed when this code is run.
4281 done
4284 done
4285 # Define the Automake conditionals.
4286 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
4287 for module in $1; do
4288 eval $verifier
4289 if test -n "$module"; then
4290 if func_cond_module_p "$module"; then
4291 func_module_conditional_name "$module"
4292 func_module_shellvar_name "$module"
4293 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
4296 done
4297 else
4298 # Ignore the conditions, and enable all modules unconditionally.
4299 for module in $1; do
4300 eval $verifier
4301 if test -n "$module"; then
4302 func_emit_autoconf_snippet " "
4304 done
4308 # func_emit_pre_early_macros require indentation modules
4309 # The require parameter can be ':' (AC_REQUIRE) or 'false' (direct call).
4310 func_emit_pre_early_macros ()
4312 echo
4313 echo "${2}# Pre-early section."
4314 if $1; then
4315 _pre_early_snippet="echo \"${2}AC_REQUIRE([\$_pre_early_macro])\""
4316 else
4317 _pre_early_snippet="echo \"${2}\$_pre_early_macro\""
4320 # We need to call gl_USE_SYSTEM_EXTENSIONS before gl_PROG_AR_RANLIB. Doing
4321 # AC_REQUIRE in configure-ac.early is not early enough.
4322 _pre_early_macro="gl_USE_SYSTEM_EXTENSIONS"
4323 case "${nl}${3}${nl}" in
4324 *${nl}extensions${nl}*) eval "$_pre_early_snippet" ;;
4325 esac
4327 _pre_early_macro="gl_PROG_AR_RANLIB"
4328 eval "$_pre_early_snippet"
4329 echo
4332 # func_reconstruct_cached_dir
4333 # callback for func_reconstruct_cached_local_gnulib_path
4334 # Input:
4335 # - destdir from --dir
4336 # Output:
4337 # - local_gnulib_path restored '--local-dir' path from cache
4338 func_reconstruct_cached_dir ()
4340 cached_dir=$1
4341 if test -n "$cached_dir"; then
4342 case "$destdir" in
4344 func_path_append local_gnulib_path "$destdir/$cached_dir" ;;
4346 case "$cached_dir" in
4348 func_path_append local_gnulib_path "$destdir/$cached_dir" ;;
4350 func_relconcat "$destdir" "$cached_dir"
4351 func_path_append local_gnulib_path "$relconcat" ;;
4352 esac ;;
4353 esac
4357 # func_reconstruct_cached_local_gnulib_path
4358 # reconstruct local_gnulib_path from cached_local_gnulib_path to be set
4359 # relatively to $destdir again.
4360 # Input:
4361 # - cached_local_gnulib_path local_gnulib_path stored within gnulib-cache.m4
4362 # - destdir from --dir
4363 # Output:
4364 # - local_gnulib_path restored '--local-dir' path from cache
4365 func_reconstruct_cached_local_gnulib_path ()
4367 func_path_foreach "$cached_local_gnulib_path" func_reconstruct_cached_dir %dir%
4370 # func_import modules
4371 # Uses also the variables
4372 # - mode import or add-import or remove-import or update
4373 # - destdir target directory
4374 # - local_gnulib_path from --local-dir
4375 # - modcache true or false, from --cache-modules/--no-cache-modules
4376 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
4377 # - libname library name
4378 # - supplied_libname true if --lib was given, blank otherwise
4379 # - sourcebase directory relative to destdir where to place source code
4380 # - m4base directory relative to destdir where to place *.m4 macros
4381 # - pobase directory relative to destdir where to place *.po files
4382 # - docbase directory relative to destdir where to place doc files
4383 # - testsbase directory relative to destdir where to place unit test code
4384 # - auxdir directory relative to destdir where to place build aux files
4385 # - inctests true if --with-tests was given, false otherwise
4386 # - incobsolete true if --with-obsolete was given, blank otherwise
4387 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
4388 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
4389 # otherwise
4390 # - inc_privileged_tests true if --with-privileged-tests was given, blank
4391 # otherwise
4392 # - inc_unportable_tests true if --with-unportable-tests was given, blank
4393 # otherwise
4394 # - inc_all_tests true if --with-all-tests was given, blank otherwise
4395 # - avoidlist list of modules to avoid, from --avoid
4396 # - cond_dependencies true if --conditional-dependencies was given, false if
4397 # --no-conditional-dependencies was given, blank otherwise
4398 # - lgpl yes or a number if library's license shall be LGPL,
4399 # blank otherwise
4400 # - makefile_name from --makefile-name
4401 # - libtool true if --libtool was given, false if --no-libtool was
4402 # given, blank otherwise
4403 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
4404 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4405 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4406 # - witness_c_macro from --witness-c-macro
4407 # - vc_files true if --vc-files was given, false if --no-vc-files was
4408 # given, blank otherwise
4409 # - autoconf_minversion minimum supported autoconf version
4410 # - doit : if actions shall be executed, false if only to be printed
4411 # - symbolic true if files should be symlinked, copied otherwise
4412 # - lsymbolic true if files from local_gnulib_path should be symlinked,
4413 # copied otherwise
4414 # - do_copyrights true if copyright notices in files should be replaced,
4415 # blank otherwise
4416 func_import ()
4418 # Get the cached settings.
4419 # In 'import' mode, we read them only for the purpose of knowing the old
4420 # installed file list, and don't use them as defaults.
4421 cached_local_gnulib_path=
4422 cached_specified_modules=
4423 cached_incobsolete=
4424 cached_inc_cxx_tests=
4425 cached_inc_longrunning_tests=
4426 cached_inc_privileged_tests=
4427 cached_inc_unportable_tests=
4428 cached_inc_all_tests=
4429 cached_avoidlist=
4430 cached_sourcebase=
4431 cached_m4base=
4432 cached_pobase=
4433 cached_docbase=
4434 cached_testsbase=
4435 cached_inctests=
4436 cached_libname=
4437 cached_lgpl=
4438 cached_makefile_name=
4439 cached_cond_dependencies=
4440 cached_libtool=
4441 cached_macro_prefix=
4442 cached_po_domain=
4443 cached_witness_c_macro=
4444 cached_vc_files=
4445 cached_files=
4446 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4447 cached_libtool=false
4448 my_sed_traces='
4449 s,#.*$,,
4450 s,^dnl .*$,,
4451 s, dnl .*$,,
4452 /gl_LOCAL_DIR(/ {
4453 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_path="\1",p
4455 /gl_MODULES(/ {
4458 s/)/)/
4463 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
4465 /gl_WITH_OBSOLETE/ {
4466 s,^.*$,cached_incobsolete=true,p
4468 /gl_WITH_CXX_TESTS/ {
4469 s,^.*$,cached_inc_cxx_tests=true,p
4471 /gl_WITH_LONGRUNNING_TESTS/ {
4472 s,^.*$,cached_inc_longrunning_tests=true,p
4474 /gl_WITH_PRIVILEGED_TESTS/ {
4475 s,^.*$,cached_inc_privileged_tests=true,p
4477 /gl_WITH_UNPORTABLE_TESTS/ {
4478 s,^.*$,cached_inc_unportable_tests=true,p
4480 /gl_WITH_ALL_TESTS/ {
4481 s,^.*$,cached_inc_all_tests=true,p
4483 /gl_AVOID(/ {
4484 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
4486 /gl_SOURCE_BASE(/ {
4487 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
4489 /gl_M4_BASE(/ {
4490 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
4492 /gl_PO_BASE(/ {
4493 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
4495 /gl_DOC_BASE(/ {
4496 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
4498 /gl_TESTS_BASE(/ {
4499 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
4501 /gl_WITH_TESTS/ {
4502 s,^.*$,cached_inctests=true,p
4504 /gl_LIB(/ {
4505 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
4507 /gl_LGPL(/ {
4508 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
4510 /gl_LGPL/ {
4511 s,^.*$,cached_lgpl=yes,p
4513 /gl_MAKEFILE_NAME(/ {
4514 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
4516 /gl_CONDITIONAL_DEPENDENCIES/ {
4517 s,^.*$,cached_cond_dependencies=true,p
4519 /gl_LIBTOOL/ {
4520 s,^.*$,cached_libtool=true,p
4522 /gl_MACRO_PREFIX(/ {
4523 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
4525 /gl_PO_DOMAIN(/ {
4526 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
4528 /gl_WITNESS_C_MACRO(/ {
4529 s,^.*gl_WITNESS_C_MACRO([[ ]*\([^]"$`\\)]*\).*$,cached_witness_c_macro="\1",p
4531 /gl_VC_FILES(/ {
4532 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
4534 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
4535 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4536 my_sed_traces='
4537 s,#.*$,,
4538 s,^dnl .*$,,
4539 s, dnl .*$,,
4540 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
4541 s,^.*$,cached_files=",p
4545 s,^\]).*$,",
4547 s,["$`\\],,g
4554 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
4558 if test "$mode" = import; then
4559 # In 'import' mode, the new set of specified modules overrides the cached
4560 # set of modules. Ignore the cached settings.
4561 specified_modules="$1"
4562 else
4563 # Merge the cached settings with the specified ones.
4564 # The m4base must be the same as expected from the pathname.
4565 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
4566 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
4568 # The local_gnulib_path defaults to the cached one. Recall that the cached one
4569 # is relative to $destdir, whereas the one we use is relative to . or absolute.
4570 if test -z "$local_gnulib_path"; then
4571 func_reconstruct_cached_local_gnulib_path
4573 case $mode in
4574 add-import)
4575 # Append the cached and the specified module names. So that
4576 # "gnulib-tool --add-import foo" means to add the module foo.
4577 specified_modules="$cached_specified_modules $1"
4579 remove-import)
4580 # Take the cached module names, minus the specified module names.
4581 specified_modules=
4582 if $have_associative; then
4583 # Use an associative array, for O(N) worst-case run time.
4584 declare -A to_remove
4585 for m in $1; do
4586 eval 'to_remove[$m]=yes'
4587 done
4588 for module in $cached_specified_modules; do
4589 if eval 'test -z "${to_remove[$module]}"'; then
4590 func_append specified_modules "$module "
4592 done
4593 else
4594 # This loop has O(N**2) worst-case run time.
4595 for module in $cached_specified_modules; do
4596 to_remove=
4597 for m in $1; do
4598 if test "$m" = "$module"; then
4599 to_remove=yes
4600 break
4602 done
4603 if test -z "$to_remove"; then
4604 func_append specified_modules "$module "
4606 done
4609 update)
4610 # Take the cached module names. There are no specified module names.
4611 specified_modules="$cached_specified_modules"
4613 esac
4614 # Included obsolete modules among the dependencies if specified either way.
4615 if test -z "$incobsolete"; then
4616 incobsolete="$cached_incobsolete"
4618 # Included special kinds of tests modules among the dependencies if specified
4619 # either way.
4620 if test -z "$inc_cxx_tests"; then
4621 inc_cxx_tests="$cached_inc_cxx_tests"
4623 if test -z "$inc_longrunning_tests"; then
4624 inc_longrunning_tests="$cached_inc_longrunning_tests"
4626 if test -z "$inc_privileged_tests"; then
4627 inc_privileged_tests="$cached_inc_privileged_tests"
4629 if test -z "$inc_unportable_tests"; then
4630 inc_unportable_tests="$cached_inc_unportable_tests"
4632 if test -z "$inc_all_tests"; then
4633 inc_all_tests="$cached_inc_all_tests"
4635 # Append the cached and the specified avoidlist. This is probably better
4636 # than dropping the cached one when --avoid is specified at least once.
4637 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
4638 avoidlist=`echo $avoidlist`
4640 # The sourcebase defaults to the cached one.
4641 if test -z "$sourcebase"; then
4642 sourcebase="$cached_sourcebase"
4643 if test -z "$sourcebase"; then
4644 func_fatal_error "missing --source-base option"
4647 # The pobase defaults to the cached one.
4648 if test -z "$pobase"; then
4649 pobase="$cached_pobase"
4651 # The docbase defaults to the cached one.
4652 if test -z "$docbase"; then
4653 docbase="$cached_docbase"
4654 if test -z "$docbase"; then
4655 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."
4658 # The testsbase defaults to the cached one.
4659 if test -z "$testsbase"; then
4660 testsbase="$cached_testsbase"
4661 if test -z "$testsbase"; then
4662 func_fatal_error "missing --tests-base option"
4665 # Require the tests if specified either way.
4666 if ! $inctests; then
4667 inctests="$cached_inctests"
4668 if test -z "$inctests"; then
4669 inctests=false
4672 # The libname defaults to the cached one.
4673 if test -z "$supplied_libname"; then
4674 libname="$cached_libname"
4675 if test -z "$libname"; then
4676 func_fatal_error "missing --lib option"
4679 # Require LGPL if specified either way.
4680 if test -z "$lgpl"; then
4681 lgpl="$cached_lgpl"
4683 # The makefile_name defaults to the cached one.
4684 if test -z "$makefile_name"; then
4685 makefile_name="$cached_makefile_name"
4687 # Use conditional dependencies if specified either way.
4688 if test -z "$cond_dependencies"; then
4689 cond_dependencies="$cached_cond_dependencies"
4691 # Use libtool if specified either way, or if guessed.
4692 if test -z "$libtool"; then
4693 if test -n "$cached_m4base"; then
4694 libtool="$cached_libtool"
4695 else
4696 libtool="$guessed_libtool"
4699 # The macro_prefix defaults to the cached one.
4700 if test -z "$macro_prefix"; then
4701 macro_prefix="$cached_macro_prefix"
4702 if test -z "$macro_prefix"; then
4703 func_fatal_error "missing --macro-prefix option"
4706 # The po_domain defaults to the cached one.
4707 if test -z "$po_domain"; then
4708 po_domain="$cached_po_domain"
4710 # The witness_c_macro defaults to the cached one.
4711 if test -z "$witness_c_macro"; then
4712 witness_c_macro="$cached_witness_c_macro"
4714 # The vc_files defaults to the cached one.
4715 if test -z "$vc_files"; then
4716 vc_files="$cached_vc_files"
4718 # Ensure constraints.
4719 if test "$cond_dependencies" = true && $inctests; then
4720 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
4721 func_exit 1
4724 # --without-*-tests options are not supported here.
4725 excl_cxx_tests=
4726 excl_longrunning_tests=
4727 excl_privileged_tests=
4728 excl_unportable_tests=
4730 # Canonicalize the list of specified modules.
4731 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4733 # Include all kinds of tests modules if --with-all-tests was specified.
4734 inc_all_direct_tests="$inc_all_tests"
4735 inc_all_indirect_tests="$inc_all_tests"
4737 # Determine final module list.
4738 modules="$specified_modules"
4739 func_modules_transitive_closure
4740 if test $verbose -ge 0; then
4741 func_show_module_list
4743 final_modules="$modules"
4745 # Determine main module list and tests-related module list separately.
4746 func_modules_transitive_closure_separately
4748 # Determine whether a $testsbase/libtests.a is needed.
4749 func_determine_use_libtests
4751 # Add the dummy module to the main module list or to the tests-related module
4752 # list if needed.
4753 func_modules_add_dummy_separately
4755 # If --lgpl, verify that the licenses of modules are compatible.
4756 if test -n "$lgpl"; then
4757 license_incompatibilities=
4758 for module in $main_modules; do
4759 license=`func_get_license $module`
4760 case $license in
4761 'GPLed build tool') ;;
4762 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4764 case "$lgpl" in
4765 yes | 3)
4766 case $license in
4767 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL) ;;
4768 *) func_append license_incompatibilities "$module $license$nl" ;;
4769 esac
4771 3orGPLv2)
4772 case $license in
4773 LGPLv2+ | 'LGPLv3+ or GPLv2') ;;
4774 *) func_append license_incompatibilities "$module $license$nl" ;;
4775 esac
4778 case $license in
4779 LGPLv2+) ;;
4780 *) func_append license_incompatibilities "$module $license$nl" ;;
4781 esac
4783 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4784 esac
4786 esac
4787 done
4788 if test -n "$license_incompatibilities"; then
4789 # Format the license incompatibilities as a table.
4790 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
4791 s,^\(.................................................[^ ]*\) *, \1 ,'
4792 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
4793 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
4797 # Show banner notice of every module.
4798 modules="$main_modules"
4799 func_modules_notice
4801 # Determine script to apply to imported library files.
4802 sed_transform_lib_file=
4803 for module in $main_modules; do
4804 if test $module = config-h; then
4805 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
4806 sed_transform_lib_file=$sed_transform_lib_file'
4807 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
4809 break
4811 done
4812 sed_transform_main_lib_file="$sed_transform_lib_file"
4813 if test -n "$do_copyrights"; then
4814 if test -n "$lgpl"; then
4815 # Update license.
4816 case "$lgpl" in
4817 yes | 3)
4818 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4819 s/GNU General/GNU Lesser General/g
4820 s/General Public License/Lesser General Public License/g
4821 s/Lesser Lesser General Public License/Lesser General Public License/g
4824 3orGPLv2)
4825 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4826 /^ *This program is free software/i\
4827 This program is free software: you can redistribute it and\/or\
4828 modify it under the terms of either:\
4830 * the GNU Lesser General Public License as published by the Free\
4831 Software Foundation; either version 3 of the License, or (at your\
4832 option) any later version.\
4836 * the GNU General Public License as published by the Free\
4837 Software Foundation; either version 2 of the License, or (at your\
4838 option) any later version.\
4840 or both in parallel, as here.
4841 /^ *This program is free software/,/^$/d
4845 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4846 s/GNU General/GNU Lesser General/g
4847 s/General Public License/Lesser General Public License/g
4848 s/Lesser Lesser General Public License/Lesser General Public License/g
4850 s/version [23]\([ ,]\)/version 2.1\1/g
4853 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4854 esac
4855 else
4856 # Update license.
4857 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4858 s/GNU Lesser General/GNU General/g
4859 s/Lesser General Public License/General Public License/g
4861 s/GNU Library General/GNU General/g
4862 s/Library General Public License/General Public License/g
4864 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4869 # Determine script to apply to auxiliary files that go into $auxdir/.
4870 sed_transform_build_aux_file=
4871 if test -n "$do_copyrights"; then
4872 # Update license.
4873 sed_transform_build_aux_file=$sed_transform_build_aux_file'
4874 s/GNU Lesser General/GNU General/g
4875 s/Lesser General Public License/General Public License/g
4877 s/GNU Library General/GNU General/g
4878 s/Library General Public License/General Public License/g
4880 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4884 # Determine script to apply to library files that go into $testsbase/.
4885 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
4886 if test -n "$do_copyrights"; then
4887 # Update license.
4888 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
4889 s/GNU Lesser General/GNU General/g
4890 s/Lesser General Public License/General Public License/g
4892 s/GNU Library General/GNU General/g
4893 s/Library General Public License/General Public License/g
4895 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4899 # Determine the final file lists.
4900 func_modules_to_filelist_separately
4902 test -n "$files" \
4903 || func_fatal_error "refusing to do nothing"
4905 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
4906 new_files="$files m4/gnulib-tool.m4"
4907 old_files="$cached_files"
4908 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
4909 func_append old_files " m4/gnulib-tool.m4"
4912 rewritten='%REWRITTEN%'
4913 sed_rewrite_old_files="\
4914 s,^build-aux/,$rewritten$auxdir/,
4915 s,^doc/,$rewritten$cached_docbase/,
4916 s,^lib/,$rewritten$cached_sourcebase/,
4917 s,^m4/,$rewritten$cached_m4base/,
4918 s,^tests/,$rewritten$cached_testsbase/,
4919 s,^tests=lib/,$rewritten$cached_testsbase/,
4920 s,^top/,$rewritten,
4921 s,^$rewritten,,"
4922 sed_rewrite_new_files="\
4923 s,^build-aux/,$rewritten$auxdir/,
4924 s,^doc/,$rewritten$docbase/,
4925 s,^lib/,$rewritten$sourcebase/,
4926 s,^m4/,$rewritten$m4base/,
4927 s,^tests/,$rewritten$testsbase/,
4928 s,^tests=lib/,$rewritten$testsbase/,
4929 s,^top/,$rewritten,
4930 s,^$rewritten,,"
4932 # Create directories.
4933 { echo "$sourcebase"
4934 echo "$m4base"
4935 if test -n "$pobase"; then
4936 echo "$pobase"
4938 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
4939 if test -n "$docfiles"; then
4940 echo "$docbase"
4942 if $inctests; then
4943 echo "$testsbase"
4945 echo "$auxdir"
4946 for f in $files; do echo $f; done \
4947 | sed -e "$sed_rewrite_new_files" \
4948 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4949 | LC_ALL=C sort -u
4950 } > "$tmp"/dirs
4951 { # Rearrange file descriptors. Needed because "while ... done < ..."
4952 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4953 exec 5<&0 < "$tmp"/dirs
4954 while read d; do
4955 if test ! -d "$destdir/$d"; then
4956 if $doit; then
4957 echo "Creating directory $destdir/$d"
4958 mkdir -p "$destdir/$d" || func_fatal_error "failed"
4959 else
4960 echo "Create directory $destdir/$d"
4963 done
4964 exec 0<&5 5<&-
4967 # Copy files or make symbolic links. Remove obsolete files.
4968 added_files=''
4969 removed_files=''
4970 delimiter=' '
4971 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4972 # representing the files according to the last gnulib-tool invocation.
4973 for f in $old_files; do echo $f; done \
4974 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
4975 | LC_ALL=C sort \
4976 > "$tmp"/old-files
4977 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4978 # representing the files after this gnulib-tool invocation.
4979 for f in $new_files; do echo $f; done \
4980 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
4981 | LC_ALL=C sort \
4982 > "$tmp"/new-files
4983 # First the files that are in old-files, but not in new-files:
4984 sed_take_first_column='s,'"$delimiter"'.*,,'
4985 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
4986 # Remove the file. Do nothing if the user already removed it.
4987 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
4988 if $doit; then
4989 echo "Removing file $g (backup in ${g}~)"
4990 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
4991 else
4992 echo "Remove file $g (backup in ${g}~)"
4994 func_append removed_files "$g$nl"
4996 done
4997 # func_add_or_update handles a file that ought to be present afterwards.
4998 # Uses parameters
4999 # - f the original file name
5000 # - g the rewritten file name
5001 # - already_present nonempty if the file should already exist, empty
5002 # otherwise
5003 func_add_or_update ()
5005 of="$f"
5006 case "$f" in
5007 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
5008 esac
5009 is_binary_file=
5010 case "$f" in
5011 *.class | *.mo ) is_binary_file=true ;;
5012 esac
5013 func_dest_tmpfilename "$g"
5014 func_lookup_file "$f"
5015 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5016 if test -n "$sed_transform_main_lib_file" \
5017 && test -z "$is_binary_file"; then
5018 case "$of" in
5019 lib/*)
5020 sed -e "$sed_transform_main_lib_file" \
5021 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5023 esac
5025 if test -n "$sed_transform_build_aux_file" \
5026 && test -z "$is_binary_file"; then
5027 case "$of" in
5028 build-aux/*)
5029 sed -e "$sed_transform_build_aux_file" \
5030 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5032 esac
5034 if test -n "$sed_transform_testsrelated_lib_file" \
5035 && test -z "$is_binary_file"; then
5036 case "$of" in
5037 tests=lib/*)
5038 sed -e "$sed_transform_testsrelated_lib_file" \
5039 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5041 esac
5043 if test -f "$destdir/$g"; then
5044 # The file already exists.
5045 func_update_file
5046 else
5047 # Install the file.
5048 # Don't protest if the file should be there but isn't: it happens
5049 # frequently that developers don't put autogenerated files under version control.
5050 func_add_file
5051 func_append added_files "$g$nl"
5053 rm -f "$tmpfile"
5055 # Then the files that are in new-files, but not in old-files:
5056 sed_take_last_column='s,^.*'"$delimiter"',,'
5057 already_present=
5058 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
5059 | sed -e "$sed_take_last_column" \
5060 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
5061 { # Rearrange file descriptors. Needed because "while ... done < ..."
5062 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5063 exec 5<&0 < "$tmp"/added-files
5064 while read g f; do
5065 func_add_or_update
5066 done
5067 exec 0<&5 5<&-
5069 # Then the files that are in new-files and in old-files:
5070 already_present=true
5071 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
5072 | sed -e "$sed_take_last_column" \
5073 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
5074 { # Rearrange file descriptors. Needed because "while ... done < ..."
5075 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5076 exec 5<&0 < "$tmp"/kept-files
5077 while read g f; do
5078 func_add_or_update
5079 done
5080 exec 0<&5 5<&-
5083 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
5084 actioncmd="gnulib-tool --import"
5086 # Local helper.
5087 func_append_local_dir ()
5089 func_append "$1" " --local-dir=$2"
5091 func_path_foreach "$local_gnulib_path" func_append_local_dir actioncmd %dir%
5093 func_append actioncmd " --lib=$libname"
5094 func_append actioncmd " --source-base=$sourcebase"
5095 func_append actioncmd " --m4-base=$m4base"
5096 if test -n "$pobase"; then
5097 func_append actioncmd " --po-base=$pobase"
5099 func_append actioncmd " --doc-base=$docbase"
5100 func_append actioncmd " --tests-base=$testsbase"
5101 func_append actioncmd " --aux-dir=$auxdir"
5102 if $inctests; then
5103 func_append actioncmd " --with-tests"
5105 if test -n "$incobsolete"; then
5106 func_append actioncmd " --with-obsolete"
5108 if test -n "$inc_cxx_tests"; then
5109 func_append actioncmd " --with-c++-tests"
5111 if test -n "$inc_longrunning_tests"; then
5112 func_append actioncmd " --with-longrunning-tests"
5114 if test -n "$inc_privileged_tests"; then
5115 func_append actioncmd " --with-privileged-tests"
5117 if test -n "$inc_unportable_tests"; then
5118 func_append actioncmd " --with-unportable-tests"
5120 if test -n "$inc_all_tests"; then
5121 func_append actioncmd " --with-all-tests"
5123 for module in $avoidlist; do
5124 func_append actioncmd " --avoid=$module"
5125 done
5126 if test -n "$lgpl"; then
5127 if test "$lgpl" = yes; then
5128 func_append actioncmd " --lgpl"
5129 else
5130 func_append actioncmd " --lgpl=$lgpl"
5133 if $gnu_make; then
5134 func_append actioncmd " --gnu-make"
5136 if test -n "$makefile_name"; then
5137 func_append actioncmd " --makefile-name=$makefile_name"
5139 if test "$cond_dependencies" = true; then
5140 func_append actioncmd " --conditional-dependencies"
5141 else
5142 func_append actioncmd " --no-conditional-dependencies"
5144 if test "$libtool" = true; then
5145 func_append actioncmd " --libtool"
5146 else
5147 func_append actioncmd " --no-libtool"
5149 func_append actioncmd " --macro-prefix=$macro_prefix"
5150 if test -n "$po_domain"; then
5151 func_append actioncmd " --po-domain=$po_domain"
5153 if test -n "$witness_c_macro"; then
5154 func_append actioncmd " --witness-c-macro=$witness_c_macro"
5156 if test -n "$vc_files"; then
5157 if test "$vc_files" = true; then
5158 func_append actioncmd " --vc-files"
5159 else
5160 func_append actioncmd " --no-vc-files"
5163 func_append actioncmd " `echo $specified_modules`"
5165 # Determine include_guard_prefix.
5166 func_compute_include_guard_prefix
5168 # Default the makefile name to Makefile.am.
5169 if test -n "$makefile_name"; then
5170 makefile_am=$makefile_name
5171 else
5172 makefile_am=Makefile.am
5175 # Create normal Makefile.ams.
5176 for_test=false
5178 # Setup list of Makefile.am edits that are to be performed afterwards.
5179 # Some of these edits apply to files that we will generate; others are
5180 # under the responsibility of the developer.
5181 makefile_am_edits=0
5182 # func_note_Makefile_am_edit dir var value
5183 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
5184 # ${value}.
5185 func_note_Makefile_am_edit ()
5187 makefile_am_edits=`expr $makefile_am_edits + 1`
5188 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
5189 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
5190 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
5192 if test "$makefile_am" = Makefile.am; then
5193 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
5194 sourcebase_base=`basename "$sourcebase"`
5195 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
5197 if test -n "$pobase"; then
5198 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
5199 pobase_base=`basename "$pobase"`
5200 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
5202 if $inctests; then
5203 if test "$makefile_am" = Makefile.am; then
5204 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
5205 testsbase_base=`basename "$testsbase"`
5206 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
5209 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
5211 # Find the first parent directory of $m4base that contains or will contain
5212 # a Makefile.am.
5213 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
5214 s,//*$,/,'
5215 sed_butlast='s,[^/][^/]*//*$,,'
5216 dir1="${m4base}/"; dir2=""
5217 while test -n "$dir1" \
5218 && ! { test -f "${destdir}/${dir1}Makefile.am" \
5219 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
5220 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
5221 || { $inctests \
5222 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
5223 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
5224 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
5225 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
5226 done
5227 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
5230 # Create library makefile.
5231 func_dest_tmpfilename $sourcebase/$makefile_am
5232 destfile="$sourcebase/$makefile_am"
5233 modules="$main_modules"
5234 func_emit_lib_Makefile_am > "$tmpfile"
5235 if test -f "$destdir"/$sourcebase/$makefile_am; then
5236 if cmp -s "$destdir"/$sourcebase/$makefile_am "$tmpfile"; then
5237 rm -f "$tmpfile"
5238 else
5239 if $doit; then
5240 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
5241 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
5242 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
5243 else
5244 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
5245 rm -f "$tmpfile"
5248 else
5249 if $doit; then
5250 echo "Creating $sourcebase/$makefile_am"
5251 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
5252 else
5253 echo "Create $sourcebase/$makefile_am"
5254 rm -f "$tmpfile"
5256 func_append added_files "$sourcebase/$makefile_am$nl"
5259 # Create po/ directory.
5260 if test -n "$pobase"; then
5261 # Create po makefile and auxiliary files.
5262 for file in Makefile.in.in remove-potcdate.sin; do
5263 func_dest_tmpfilename $pobase/$file
5264 func_lookup_file build-aux/po/$file
5265 cat "$lookedup_file" > "$tmpfile"
5266 if test -f "$destdir"/$pobase/$file; then
5267 if cmp -s "$destdir"/$pobase/$file "$tmpfile"; then
5268 rm -f "$tmpfile"
5269 else
5270 if $doit; then
5271 echo "Updating $pobase/$file (backup in $pobase/$file~)"
5272 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
5273 mv -f "$tmpfile" "$destdir"/$pobase/$file
5274 else
5275 echo "Update $pobase/$file (backup in $pobase/$file~)"
5276 rm -f "$tmpfile"
5279 else
5280 if $doit; then
5281 echo "Creating $pobase/$file"
5282 mv -f "$tmpfile" "$destdir"/$pobase/$file
5283 else
5284 echo "Create $pobase/$file"
5285 rm -f "$tmpfile"
5287 func_append added_files "$pobase/$file$nl"
5289 done
5290 # Create po makefile parameterization, part 1.
5291 func_dest_tmpfilename $pobase/Makevars
5292 func_emit_po_Makevars > "$tmpfile"
5293 if test -f "$destdir"/$pobase/Makevars; then
5294 if cmp -s "$destdir"/$pobase/Makevars "$tmpfile"; then
5295 rm -f "$tmpfile"
5296 else
5297 if $doit; then
5298 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
5299 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
5300 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5301 else
5302 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
5303 rm -f "$tmpfile"
5306 else
5307 if $doit; then
5308 echo "Creating $pobase/Makevars"
5309 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5310 else
5311 echo "Create $pobase/Makevars"
5312 rm -f "$tmpfile"
5314 func_append added_files "$pobase/Makevars$nl"
5316 # Create po makefile parameterization, part 2.
5317 func_dest_tmpfilename $pobase/POTFILES.in
5318 func_emit_po_POTFILES_in > "$tmpfile"
5319 if test -f "$destdir"/$pobase/POTFILES.in; then
5320 if cmp -s "$destdir"/$pobase/POTFILES.in "$tmpfile"; then
5321 rm -f "$tmpfile"
5322 else
5323 if $doit; then
5324 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5325 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
5326 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5327 else
5328 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5329 rm -f "$tmpfile"
5332 else
5333 if $doit; then
5334 echo "Creating $pobase/POTFILES.in"
5335 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5336 else
5337 echo "Create $pobase/POTFILES.in"
5338 rm -f "$tmpfile"
5340 func_append added_files "$pobase/POTFILES.in$nl"
5342 # Fetch PO files.
5343 TP_URL="http://translationproject.org/latest/"
5344 TP_RSYNC_URI="translationproject.org::tp/latest/"
5345 if $doit; then
5346 echo "Fetching gnulib PO files from $TP_URL"
5347 (cd "$destdir"/$pobase \
5348 && { # Prefer rsync over wget if it is available, since it consumes
5349 # less network bandwidth, due to compression.
5350 if type rsync 2>/dev/null | grep / > /dev/null; then
5351 rsync --delete --exclude "*.s1" -Lrtz "${TP_RSYNC_URI}gnulib/" . && return
5354 wget --no-verbose --mirror -nd -np -A.po -P . "${TP_URL}gnulib/"
5357 else
5358 echo "Fetch gnulib PO files from $TP_URL"
5360 # Create po/LINGUAS.
5361 if $doit; then
5362 func_dest_tmpfilename $pobase/LINGUAS
5363 (cd "$destdir"/$pobase \
5364 && { echo '# Set of available languages.'
5365 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
5367 ) > "$tmpfile"
5368 if test -f "$destdir"/$pobase/LINGUAS; then
5369 if cmp -s "$destdir"/$pobase/LINGUAS "$tmpfile"; then
5370 rm -f "$tmpfile"
5371 else
5372 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5373 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
5374 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5376 else
5377 echo "Creating $pobase/LINGUAS"
5378 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5379 func_append added_files "$pobase/LINGUAS$nl"
5381 else
5382 if test -f "$destdir"/$pobase/LINGUAS; then
5383 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5384 else
5385 echo "Create $pobase/LINGUAS"
5390 # func_count_relative_local_gnulib_path
5391 # gl_LOCAL_DIR requires local_gnulib_path to be set relatively to destdir
5392 # Input:
5393 # - local_gnulib_path from --local-dir
5394 # - destdir from --dir
5395 # Output:
5396 # - relative_local_dir path to be stored into gl_LOCAL_DIR
5397 func_count_relative_local_gnulib_path ()
5399 save_IFS=$IFS
5400 IFS=$PATH_SEPARATOR
5401 relative_local_gnulib_path=
5402 for local_dir in $local_gnulib_path
5404 # Store the local_dir relative to destdir.
5405 case "$local_dir" in
5406 "" | /*)
5407 relative_local_dir="$local_dir" ;;
5409 case "$destdir" in
5410 /*) relative_local_dir="$local_dir" ;;
5412 # destdir, local_dir are both relative.
5413 func_relativize "$destdir" "$local_dir"
5414 relative_local_dir="$reldir" ;;
5415 esac ;;
5416 esac
5417 func_path_append relative_local_gnulib_path "$relative_local_dir"
5418 done
5419 IFS=$save_IFS
5422 # Create m4/gnulib-cache.m4.
5423 func_dest_tmpfilename $m4base/gnulib-cache.m4
5425 func_emit_copyright_notice
5426 echo "#"
5427 echo "# This file represents the specification of how gnulib-tool is used."
5428 echo "# It acts as a cache: It is written and read by gnulib-tool."
5429 echo "# In projects that use version control, this file is meant to be put under"
5430 echo "# version control, like the configure.ac and various Makefile.am files."
5431 echo
5432 echo
5433 echo "# Specification in the form of a command-line invocation:"
5434 echo "# $actioncmd"
5435 echo
5436 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
5437 func_count_relative_local_gnulib_path
5438 echo "gl_LOCAL_DIR([$relative_local_gnulib_path])"
5439 echo "gl_MODULES(["
5440 echo "$specified_modules" | sed -e 's/^/ /g'
5441 echo "])"
5442 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
5443 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
5444 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
5445 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
5446 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
5447 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
5448 echo "gl_AVOID([$avoidlist])"
5449 echo "gl_SOURCE_BASE([$sourcebase])"
5450 echo "gl_M4_BASE([$m4base])"
5451 echo "gl_PO_BASE([$pobase])"
5452 echo "gl_DOC_BASE([$docbase])"
5453 echo "gl_TESTS_BASE([$testsbase])"
5454 if $inctests; then
5455 echo "gl_WITH_TESTS"
5457 echo "gl_LIB([$libname])"
5458 if test -n "$lgpl"; then
5459 if test "$lgpl" = yes; then
5460 echo "gl_LGPL"
5461 else
5462 echo "gl_LGPL([$lgpl])"
5465 echo "gl_MAKEFILE_NAME([$makefile_name])"
5466 if test "$cond_dependencies" = true; then
5467 echo "gl_CONDITIONAL_DEPENDENCIES"
5469 if test "$libtool" = true; then
5470 echo "gl_LIBTOOL"
5472 echo "gl_MACRO_PREFIX([$macro_prefix])"
5473 echo "gl_PO_DOMAIN([$po_domain])"
5474 echo "gl_WITNESS_C_MACRO([$witness_c_macro])"
5475 if test -n "$vc_files"; then
5476 echo "gl_VC_FILES([$vc_files])"
5478 ) > "$tmpfile"
5479 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
5480 if cmp -s "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile"; then
5481 rm -f "$tmpfile"
5482 else
5483 if $doit; then
5484 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5485 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
5486 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5487 else
5488 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5489 if false; then
5490 cat "$tmpfile"
5491 echo
5492 echo "# gnulib-cache.m4 ends here"
5494 rm -f "$tmpfile"
5497 else
5498 if $doit; then
5499 echo "Creating $m4base/gnulib-cache.m4"
5500 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5501 else
5502 echo "Create $m4base/gnulib-cache.m4"
5503 cat "$tmpfile"
5504 rm -f "$tmpfile"
5508 # Create m4/gnulib-comp.m4.
5509 func_dest_tmpfilename $m4base/gnulib-comp.m4
5511 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
5512 func_emit_copyright_notice
5513 echo "#"
5514 echo "# This file represents the compiled summary of the specification in"
5515 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
5516 echo "# to be invoked from configure.ac."
5517 echo "# In projects that use version control, this file can be treated like"
5518 echo "# other built files."
5519 echo
5520 echo
5521 echo "# This macro should be invoked from $configure_ac, in the section"
5522 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
5523 echo "# any checks for libraries, header files, types and library functions."
5524 echo "AC_DEFUN([${macro_prefix}_EARLY],"
5525 echo "["
5526 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5527 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5528 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5529 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5531 func_emit_pre_early_macros : ' ' "$final_modules"
5533 if ! $gnu_make && test -n "$uses_subdirs"; then
5534 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
5536 for module in $final_modules; do
5537 func_verify_module
5538 if test -n "$module"; then
5539 echo "# Code from module $module:"
5540 func_get_autoconf_early_snippet "$module"
5542 done \
5543 | sed -e '/^$/d;' -e 's/^/ /'
5544 echo "])"
5545 echo
5546 echo "# This macro should be invoked from $configure_ac, in the section"
5547 echo "# \"Check for header files, types and library functions\"."
5548 echo "AC_DEFUN([${macro_prefix}_INIT],"
5549 echo "["
5550 if test "$libtool" = true; then
5551 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5552 echo " gl_cond_libtool=true"
5553 else
5554 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5555 echo " gl_cond_libtool=false"
5556 echo " gl_libdeps="
5557 echo " gl_ltlibdeps="
5559 if test "$auxdir" != "build-aux"; then
5560 sed_replace_build_aux='
5562 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5563 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5566 else
5567 sed_replace_build_aux="$sed_noop"
5569 echo " gl_m4_base='$m4base'"
5570 func_emit_initmacro_start $macro_prefix
5571 echo " gl_source_base='$sourcebase'"
5572 if test -n "$witness_c_macro"; then
5573 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
5575 func_emit_autoconf_snippets "$main_modules" func_verify_module true false true
5576 if test -n "$witness_c_macro"; then
5577 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5579 echo " # End of code from modules"
5580 func_emit_initmacro_end $macro_prefix
5581 echo " gltests_libdeps="
5582 echo " gltests_ltlibdeps="
5583 func_emit_initmacro_start ${macro_prefix}tests
5584 echo " gl_source_base='$testsbase'"
5585 # Define a tests witness macro that depends on the package.
5586 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
5587 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
5588 echo "changequote(,)dnl"
5589 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"
5590 echo "changequote([, ])dnl"
5591 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5592 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5593 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5594 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true true true
5595 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5596 func_emit_initmacro_end ${macro_prefix}tests
5597 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5598 # created using libtool, because libtool already handles the dependencies.
5599 if test "$libtool" != true; then
5600 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5601 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5602 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5603 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5604 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5606 if $use_libtests; then
5607 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5608 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5610 echo "])"
5611 func_emit_initmacro_done $macro_prefix $sourcebase
5612 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5613 echo
5614 echo "# This macro records the list of files which have been installed by"
5615 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
5616 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
5617 echo "$files" | sed -e 's,^, ,'
5618 echo "])"
5619 ) > "$tmpfile"
5620 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
5621 if cmp -s "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile"; then
5622 rm -f "$tmpfile"
5623 else
5624 if $doit; then
5625 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5626 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
5627 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5628 else
5629 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5630 if false; then
5631 cat "$tmpfile"
5632 echo
5633 echo "# gnulib-comp.m4 ends here"
5635 rm -f "$tmpfile"
5638 else
5639 if $doit; then
5640 echo "Creating $m4base/gnulib-comp.m4"
5641 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5642 else
5643 echo "Create $m4base/gnulib-comp.m4"
5644 cat "$tmpfile"
5645 rm -f "$tmpfile"
5649 if $inctests; then
5650 # Create tests makefile.
5651 func_dest_tmpfilename $testsbase/$makefile_am
5652 destfile="$testsbase/$makefile_am"
5653 modules="$testsrelated_modules"
5654 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
5655 if test -f "$destdir"/$testsbase/$makefile_am; then
5656 if cmp -s "$destdir"/$testsbase/$makefile_am "$tmpfile"; then
5657 rm -f "$tmpfile"
5658 else
5659 if $doit; then
5660 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5661 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
5662 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5663 else
5664 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5665 rm -f "$tmpfile"
5668 else
5669 if $doit; then
5670 echo "Creating $testsbase/$makefile_am"
5671 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5672 else
5673 echo "Create $testsbase/$makefile_am"
5674 rm -f "$tmpfile"
5676 func_append added_files "$testsbase/$makefile_am$nl"
5680 if test "$vc_files" != false; then
5681 # Update the .cvsignore and .gitignore files.
5682 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
5683 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
5684 # Treat gnulib-comp.m4 like an added file, even if it already existed.
5685 echo "$m4base/|A|gnulib-comp.m4"
5686 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
5687 { # Rearrange file descriptors. Needed because "while ... done < ..."
5688 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5689 exec 5<&0 < "$tmp"/fileset-changes
5690 func_update_ignorelist ()
5692 ignore="$1"
5693 if test "$ignore" = .gitignore; then
5694 # In a .gitignore file, "foo" applies to the current directory and all
5695 # subdirectories, whereas "/foo" applies to the current directory only.
5696 anchor='/'
5697 escaped_anchor='\/'
5698 doubly_escaped_anchor='\\/'
5699 else
5700 anchor=''
5701 escaped_anchor=''
5702 doubly_escaped_anchor=''
5704 if test -f "$destdir/$dir$ignore"; then
5705 if test -n "$dir_added" || test -n "$dir_removed"; then
5706 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
5707 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
5708 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
5709 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
5710 > "$tmp"/ignore-removed
5712 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
5713 if $doit; then
5714 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5715 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
5716 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
5717 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
5718 } > "$tmp"/sed-ignore-removed
5719 { cat "$destdir/$dir$ignore"~
5720 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
5721 } | sed -f "$tmp"/sed-ignore-removed \
5722 > "$destdir/$dir$ignore"
5723 else
5724 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5728 else
5729 if test -n "$dir_added"; then
5730 if $doit; then
5731 echo "Creating $destdir/$dir$ignore"
5733 if test "$ignore" = .cvsignore; then
5734 echo ".deps"
5735 # Automake generates Makefile rules that create .dirstamp files.
5736 echo ".dirstamp"
5738 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
5739 } > "$destdir/$dir$ignore"
5740 else
5741 echo "Create $destdir/$dir$ignore"
5746 func_done_dir ()
5748 dir="$1"
5749 dir_added="$2"
5750 dir_removed="$3"
5751 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
5752 func_update_ignorelist .cvsignore
5754 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
5755 func_update_ignorelist .gitignore
5758 last_dir=
5759 last_dir_added=
5760 last_dir_removed=
5761 while read line; do
5762 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
5763 next_dir=`echo "$line" | sed -e 's,|.*,,'`
5764 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
5765 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
5766 if test "$next_dir" != "$last_dir"; then
5767 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5768 last_dir="$next_dir"
5769 last_dir_added=
5770 last_dir_removed=
5772 case $op in
5773 A) func_append last_dir_added "$file$nl";;
5774 R) func_append last_dir_removed "$file$nl";;
5775 esac
5776 done
5777 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5778 exec 0<&5 5<&-
5782 echo "Finished."
5783 echo
5784 echo "You may need to add #include directives for the following .h files."
5785 # Intersect $specified_modules and $main_modules
5786 # (since $specified_modules is not necessarily of subset of $main_modules
5787 # - some may have been skipped through --avoid, and since the elements of
5788 # $main_modules but not in $specified_modules can go away without explicit
5789 # notice - through changes in the module dependencies).
5790 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
5791 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
5792 # First the #include <...> directives without #ifs, sorted for convenience,
5793 # then the #include "..." directives without #ifs, sorted for convenience,
5794 # then the #include directives that are surrounded by #ifs. Not sorted.
5795 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
5796 include_directive=`func_get_include_directive "$module"`
5797 case "$nl$include_directive" in
5798 *"$nl#if"*)
5799 echo "$include_directive" 1>&5
5802 echo "$include_directive" | grep -v 'include "' 1>&6
5803 echo "$include_directive" | grep 'include "' 1>&7
5805 esac
5806 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
5808 LC_ALL=C sort -u "$tmp"/include-angles
5809 LC_ALL=C sort -u "$tmp"/include-quotes
5810 cat "$tmp"/include-if
5811 ) | sed -e '/^$/d' -e 's/^/ /'
5812 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
5814 for module in $main_modules; do
5815 func_get_link_directive "$module"
5816 done \
5817 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
5818 if test `wc -l < "$tmp"/link` != 0; then
5819 echo
5820 echo "You may need to use the following Makefile variables when linking."
5821 echo "Use them in <program>_LDADD when linking a program, or"
5822 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
5823 cat "$tmp"/link
5825 rm -f "$tmp"/link
5827 echo
5828 echo "Don't forget to"
5829 if test "$makefile_am" = Makefile.am; then
5830 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5831 else
5832 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
5834 if test -n "$pobase"; then
5835 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
5837 if $inctests; then
5838 if test "$makefile_am" = Makefile.am; then
5839 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5840 else
5841 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
5844 edit=0
5845 while test $edit != $makefile_am_edits; do
5846 edit=`expr $edit + 1`
5847 eval dir=\"\$makefile_am_edit${edit}_dir\"
5848 eval var=\"\$makefile_am_edit${edit}_var\"
5849 eval val=\"\$makefile_am_edit${edit}_val\"
5850 if test -n "$var"; then
5851 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
5853 done
5854 if grep '^ *AC_PROG_CC_STDC' "$configure_ac" > /dev/null; then
5855 position_early_after=AC_PROG_CC_STDC
5856 else
5857 if grep '^ *AC_PROG_CC_C99' "$configure_ac" > /dev/null; then
5858 position_early_after=AC_PROG_CC_C99
5859 else
5860 position_early_after=AC_PROG_CC
5863 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after $position_early_after,"
5864 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
5867 # func_create_testdir testdir modules
5868 # Input:
5869 # - local_gnulib_path from --local-dir
5870 # - modcache true or false, from --cache-modules/--no-cache-modules
5871 # - auxdir directory relative to destdir where to place build aux files
5872 # - inctests true if tests should be included, false otherwise
5873 # - incobsolete true if obsolete modules among dependencies should be
5874 # included, blank otherwise
5875 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
5876 # blank otherwise
5877 # - excl_longrunning_tests true if long-runnings tests should be excluded,
5878 # blank otherwise
5879 # - excl_privileged_tests true if tests that require root privileges should be
5880 # excluded, blank otherwise
5881 # - excl_unportable_tests true if tests that fail on some platforms should be
5882 # excluded, blank otherwise
5883 # - single_configure true if a single configure file should be generated,
5884 # false for a separate configure file for the tests
5885 # - avoidlist list of modules to avoid
5886 # - cond_dependencies true if --conditional-dependencies was given, false if
5887 # --no-conditional-dependencies was given, blank otherwise
5888 # - libtool true if --libtool was given, false if --no-libtool was
5889 # given, blank otherwise
5890 # - symbolic true if files should be symlinked, copied otherwise
5891 # - lsymbolic true if files from local_gnulib_path should be symlinked,
5892 # copied otherwise
5893 func_create_testdir ()
5895 testdir="$1"
5896 modules="$2"
5897 if test -z "$modules"; then
5898 # All modules together.
5899 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5900 # Except non-recursive-gnulib-prefix-hack, which represents a nonstandard
5901 # way of using Automake.
5902 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
5903 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
5904 modules=`func_all_modules`
5905 modules=`for m in $modules; do case $m in config-h | non-recursive-gnulib-prefix-hack | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
5907 specified_modules="$modules"
5909 # Canonicalize the list of specified modules.
5910 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
5912 # Test modules which invoke AC_CONFIG_FILES cannot be used with
5913 # --with-tests --single-configure. Avoid them.
5914 if $inctests && $single_configure; then
5915 avoidlist="$avoidlist havelib-tests"
5918 # Unlike in func_import, here we want to include all kinds of tests for the
5919 # directly specified modules, but not for dependencies.
5920 inc_all_direct_tests=true
5921 inc_all_indirect_tests="$inc_all_tests"
5923 # Check that the license of every module is consistent with the license of
5924 # its dependencies.
5925 saved_inctests="$inctests"
5926 # When computing transitive closures, don't consider $module to depend on
5927 # $module-tests. Need this because tests are implicitly GPL and may depend
5928 # on GPL modules - therefore we don't want a warning in this case.
5929 inctests=false
5930 for requested_module in $specified_modules; do
5931 requested_license=`func_get_license "$requested_module"`
5932 if test "$requested_license" != GPL; then
5933 # Here we use func_modules_transitive_closure, not just
5934 # func_get_dependencies, so that we also detect weird situations like
5935 # an LGPL module which depends on a GPLed build tool module which depends
5936 # on a GPL module.
5937 modules="$requested_module"
5938 func_modules_transitive_closure
5939 for module in $modules; do
5940 license=`func_get_license "$module"`
5941 case "$license" in
5942 'GPLed build tool') ;;
5943 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
5945 case "$requested_license" in
5946 GPLv3+ | GPL)
5947 case "$license" in
5948 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL | GPLv2+ | GPLv3+ | GPL) ;;
5949 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5950 esac
5952 GPLv2+)
5953 case "$license" in
5954 LGPLv2+ | 'LGPLv3+ or GPLv2' | GPLv2+) ;;
5955 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5956 esac
5958 LGPLv3+ | LGPL)
5959 case "$license" in
5960 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL) ;;
5961 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5962 esac
5964 'LGPLv3+ or GPLv2')
5965 case "$license" in
5966 LGPLv2+ | 'LGPLv3+ or GPLv2') ;;
5967 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5968 esac
5970 LGPLv2+)
5971 case "$license" in
5972 LGPLv2+) ;;
5973 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5974 esac
5976 esac
5978 esac
5979 done
5981 done
5982 inctests="$saved_inctests"
5984 # Subdirectory names.
5985 sourcebase=gllib
5986 m4base=glm4
5987 pobase=
5988 docbase=gldoc
5989 testsbase=gltests
5990 macro_prefix=gl
5991 po_domain=
5992 witness_c_macro=
5993 vc_files=
5995 # Determine final module list.
5996 modules="$specified_modules"
5997 func_modules_transitive_closure
5998 if test $verbose -ge 0; then
5999 func_show_module_list
6001 final_modules="$modules"
6003 if $single_configure; then
6004 # Determine main module list and tests-related module list separately.
6005 func_modules_transitive_closure_separately
6008 if $single_configure; then
6009 # Determine whether a $testsbase/libtests.a is needed.
6010 func_determine_use_libtests
6013 # Add the dummy module if needed.
6014 if $single_configure; then
6015 func_modules_add_dummy_separately
6016 else
6017 func_modules_add_dummy
6020 # Show banner notice of every module.
6021 if $single_configure; then
6022 modules="$main_modules"
6023 func_modules_notice
6024 else
6025 func_modules_notice
6028 # Determine final file list.
6029 if $single_configure; then
6030 func_modules_to_filelist_separately
6031 else
6032 func_modules_to_filelist
6033 if test $verbose -ge 0; then
6034 echo "File list:"
6035 echo "$files" | sed -e 's/^/ /'
6038 # Add files for which the copy in gnulib is newer than the one that
6039 # "automake --add-missing --copy" would provide.
6040 files="$files build-aux/config.guess"
6041 files="$files build-aux/config.sub"
6042 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
6044 rewritten='%REWRITTEN%'
6045 sed_rewrite_files="\
6046 s,^build-aux/,$rewritten$auxdir/,
6047 s,^doc/,$rewritten$docbase/,
6048 s,^lib/,$rewritten$sourcebase/,
6049 s,^m4/,$rewritten$m4base/,
6050 s,^tests/,$rewritten$testsbase/,
6051 s,^tests=lib/,$rewritten$testsbase/,
6052 s,^top/,$rewritten,
6053 s,^$rewritten,,"
6055 # Create directories.
6056 for f in $files; do echo $f; done \
6057 | sed -e "$sed_rewrite_files" \
6058 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
6059 | LC_ALL=C sort -u \
6060 > "$tmp"/dirs
6061 { # Rearrange file descriptors. Needed because "while ... done < ..."
6062 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
6063 exec 5<&0 < "$tmp"/dirs
6064 while read d; do
6065 mkdir -p "$testdir/$d"
6066 done
6067 exec 0<&5 5<&-
6070 # Copy files or make symbolic links.
6071 delimiter=' '
6072 for f in $files; do echo $f; done \
6073 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
6074 | LC_ALL=C sort \
6075 > "$tmp"/files
6076 { # Rearrange file descriptors. Needed because "while ... done < ..."
6077 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
6078 exec 5<&0 < "$tmp"/files
6079 while read g f; do
6080 case "$f" in
6081 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
6082 esac
6083 func_lookup_file "$f"
6084 if test -n "$lookedup_tmp"; then
6085 cp -p "$lookedup_file" "$testdir/$g"
6086 else
6087 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
6088 if func_should_symlink; then
6089 func_ln "$lookedup_file" "$testdir/$g"
6090 else
6091 cp -p "$lookedup_file" "$testdir/$g"
6094 done
6095 exec 0<&5 5<&-
6098 # Determine include_guard_prefix.
6099 func_compute_include_guard_prefix
6101 # Create Makefile.ams that are for testing.
6102 for_test=true
6104 # No special edits are needed.
6105 makefile_am_edits=0
6107 # Create $sourcebase/Makefile.am.
6108 mkdir -p "$testdir/$sourcebase"
6109 destfile="$sourcebase/Makefile.am"
6110 if $single_configure; then
6111 modules="$main_modules"
6113 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
6114 any_uses_subdirs="$uses_subdirs"
6116 # Create $m4base/Makefile.am.
6117 mkdir -p "$testdir/$m4base"
6118 (echo "## Process this file with automake to produce Makefile.in."
6119 echo
6120 echo "EXTRA_DIST ="
6121 for f in $files; do
6122 case "$f" in
6123 m4/* )
6124 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
6125 esac
6126 done
6127 ) > "$testdir/$m4base/Makefile.am"
6129 subdirs="$sourcebase $m4base"
6130 subdirs_with_configure_ac=""
6132 if false && test -f "$testdir"/$m4base/gettext.m4; then
6133 # Avoid stupid error message from automake:
6134 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
6135 mkdir -p "$testdir/po"
6136 (echo "## Process this file with automake to produce Makefile.in."
6137 ) > "$testdir/po/Makefile.am"
6138 func_append subdirs " po"
6141 if $inctests; then
6142 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
6143 if $single_configure; then
6144 # Create $testsbase/Makefile.am.
6145 destfile="$testsbase/Makefile.am"
6146 modules="$testsrelated_modules"
6147 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$testdir/$testsbase/Makefile.am"
6148 else
6149 # Viewed from the $testsbase subdirectory, $auxdir is different.
6150 saved_auxdir="$auxdir"
6151 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
6152 # Create $testsbase/Makefile.am.
6153 use_libtests=false
6154 destfile="$testsbase/Makefile.am"
6155 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
6156 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
6157 # Create $testsbase/configure.ac.
6158 (echo "# Process this file with autoconf to produce a configure script."
6159 echo "AC_INIT([dummy], [0])"
6160 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6161 echo "AM_INIT_AUTOMAKE"
6162 echo
6163 echo "AC_CONFIG_HEADERS([config.h])"
6164 echo
6165 echo "AC_PROG_CC"
6166 echo "AC_PROG_INSTALL"
6167 echo "AC_PROG_MAKE_SET"
6169 func_emit_pre_early_macros false '' "$modules"
6171 if test -n "$uses_subdirs"; then
6172 echo "AM_PROG_CC_C_O"
6173 echo
6175 for module in $modules; do
6176 func_verify_module
6177 if test -n "$module"; then
6178 case $module in
6179 gnumakefile | maintainer-makefile)
6180 # These modules are meant to be used only in the top-level directory.
6183 func_get_autoconf_early_snippet "$module"
6185 esac
6187 done \
6188 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
6189 if test "$libtool" = true; then
6190 echo "LT_INIT([win32-dll])"
6191 echo "LT_LANG([C++])"
6192 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6193 echo "gl_cond_libtool=true"
6194 else
6195 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6196 echo "gl_cond_libtool=false"
6197 echo "gl_libdeps="
6198 echo "gl_ltlibdeps="
6200 # Wrap the set of autoconf snippets into an autoconf macro that is then
6201 # invoked. This is needed because autoconf does not support AC_REQUIRE
6202 # at the top level:
6203 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6204 # but we want the AC_REQUIRE to have its normal meaning (provide one
6205 # expansion of the required macro before the current point, and only one
6206 # expansion total).
6207 echo "AC_DEFUN([gl_INIT], ["
6208 sed_replace_build_aux='
6210 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6211 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6214 echo "gl_m4_base='../$m4base'"
6215 func_emit_initmacro_start $macro_prefix
6216 # We don't have explicit ordering constraints between the various
6217 # autoconf snippets. It's cleanest to put those of the library before
6218 # those of the tests.
6219 echo "gl_source_base='../$sourcebase'"
6220 func_emit_autoconf_snippets "$modules" func_verify_nontests_module false false false
6221 echo "gl_source_base='.'"
6222 func_emit_autoconf_snippets "$modules" func_verify_tests_module false false false
6223 func_emit_initmacro_end $macro_prefix
6224 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6225 # created using libtool, because libtool already handles the dependencies.
6226 if test "$libtool" != true; then
6227 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6228 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6229 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6230 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6231 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6233 echo "])"
6234 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
6235 echo
6236 echo "gl_INIT"
6237 echo
6238 # Usually $testsbase/config.h will be a superset of config.h. Verify this
6239 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
6240 echo "AH_TOP([#include \"../config.h\"])"
6241 echo
6242 echo "AC_CONFIG_FILES([Makefile])"
6243 echo "AC_OUTPUT"
6244 ) > "$testdir/$testsbase/configure.ac"
6245 auxdir="$saved_auxdir"
6246 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
6248 func_append subdirs " $testsbase"
6251 # Create Makefile.am.
6252 (echo "## Process this file with automake to produce Makefile.in."
6253 echo
6254 echo "AUTOMAKE_OPTIONS = 1.9.6 foreign"
6255 echo
6256 echo "SUBDIRS = $subdirs"
6257 echo
6258 echo "ACLOCAL_AMFLAGS = -I $m4base"
6259 ) > "$testdir/Makefile.am"
6261 # Create configure.ac.
6262 (echo "# Process this file with autoconf to produce a configure script."
6263 echo "AC_INIT([dummy], [0])"
6264 if test "$auxdir" != "."; then
6265 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6267 echo "AM_INIT_AUTOMAKE"
6268 echo
6269 echo "AC_CONFIG_HEADERS([config.h])"
6270 echo
6271 echo "AC_PROG_CC"
6272 echo "AC_PROG_INSTALL"
6273 echo "AC_PROG_MAKE_SET"
6274 echo
6275 echo "# For autobuild."
6276 echo "AC_CANONICAL_BUILD"
6277 echo "AC_CANONICAL_HOST"
6278 echo
6279 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
6280 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
6281 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
6282 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
6284 func_emit_pre_early_macros false '' "$final_modules"
6286 if test -n "$any_uses_subdirs"; then
6287 echo "AM_PROG_CC_C_O"
6288 echo
6290 for module in $final_modules; do
6291 if $single_configure; then
6292 func_verify_module
6293 else
6294 func_verify_nontests_module
6296 if test -n "$module"; then
6297 func_get_autoconf_early_snippet "$module"
6299 done \
6300 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
6301 if test "$libtool" = true; then
6302 echo "LT_INIT([win32-dll])"
6303 echo "LT_LANG([C++])"
6304 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6305 echo "gl_cond_libtool=true"
6306 else
6307 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6308 echo "gl_cond_libtool=false"
6309 echo "gl_libdeps="
6310 echo "gl_ltlibdeps="
6312 # Wrap the set of autoconf snippets into an autoconf macro that is then
6313 # invoked. This is needed because autoconf does not support AC_REQUIRE
6314 # at the top level:
6315 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6316 # but we want the AC_REQUIRE to have its normal meaning (provide one
6317 # expansion of the required macro before the current point, and only one
6318 # expansion total).
6319 echo "AC_DEFUN([gl_INIT], ["
6320 if test "$auxdir" != "build-aux"; then
6321 sed_replace_build_aux='
6323 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6324 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6327 else
6328 sed_replace_build_aux="$sed_noop"
6330 echo "gl_m4_base='$m4base'"
6331 func_emit_initmacro_start $macro_prefix
6332 echo "gl_source_base='$sourcebase'"
6333 if $single_configure; then
6334 func_emit_autoconf_snippets "$main_modules" func_verify_module true false false
6335 else
6336 func_emit_autoconf_snippets "$modules" func_verify_nontests_module true false false
6338 func_emit_initmacro_end $macro_prefix
6339 if $single_configure; then
6340 echo " gltests_libdeps="
6341 echo " gltests_ltlibdeps="
6342 func_emit_initmacro_start ${macro_prefix}tests
6343 echo " gl_source_base='$testsbase'"
6344 # Define a tests witness macro.
6345 echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
6346 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
6347 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
6348 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
6349 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true false false
6350 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
6351 func_emit_initmacro_end ${macro_prefix}tests
6353 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6354 # created using libtool, because libtool already handles the dependencies.
6355 if test "$libtool" != true; then
6356 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6357 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6358 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6359 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6360 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6362 if $single_configure; then
6363 if $use_libtests; then
6364 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
6365 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
6368 echo "])"
6369 func_emit_initmacro_done $macro_prefix $sourcebase
6370 if $single_configure; then
6371 func_emit_initmacro_done ${macro_prefix}tests $testsbase
6373 echo
6374 echo "gl_INIT"
6375 echo
6376 if test -n "$subdirs_with_configure_ac"; then
6377 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
6379 makefiles="Makefile"
6380 for d in $subdirs; do
6381 # For subdirs that have a configure.ac by their own, it's the subdir's
6382 # configure.ac which creates the subdir's Makefile.am, not this one.
6383 case " $subdirs_with_configure_ac " in
6384 *" $d "*) ;;
6385 *) func_append makefiles " $d/Makefile" ;;
6386 esac
6387 done
6388 echo "AC_CONFIG_FILES([$makefiles])"
6389 echo "AC_OUTPUT"
6390 ) > "$testdir/configure.ac"
6392 # Create autogenerated files.
6393 (cd "$testdir"
6394 # Do not use "${AUTORECONF} --force --install", because it may invoke
6395 # autopoint, which brings in older versions of some of our .m4 files.
6396 if test -f $m4base/gettext.m4; then
6397 func_execute_command ${AUTOPOINT} --force || func_exit 1
6398 for f in $m4base/*.m4~; do
6399 if test -f $f; then
6400 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6402 done
6404 if test "$libtool" = true; then
6405 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
6407 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
6408 if ! test -d build-aux; then
6409 func_execute_command mkdir build-aux || func_exit 1
6411 func_execute_command ${AUTOCONF} || func_exit 1
6412 func_execute_command ${AUTOHEADER} || func_exit 1
6413 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6414 ) || func_exit 1
6415 if $inctests && ! $single_configure; then
6416 # Create autogenerated files.
6417 (cd "$testdir/$testsbase" || func_exit 1
6418 # Do not use "${AUTORECONF} --force --install", because it may invoke
6419 # autopoint, which brings in older versions of some of our .m4 files.
6420 if test -f ../$m4base/gettext.m4; then
6421 func_execute_command ${AUTOPOINT} --force || func_exit 1
6422 for f in ../$m4base/*.m4~; do
6423 if test -f $f; then
6424 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6426 done
6428 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
6429 if ! test -d ../build-aux; then
6430 func_execute_command mkdir ../build-aux
6432 func_execute_command ${AUTOCONF} || func_exit 1
6433 func_execute_command ${AUTOHEADER} || func_exit 1
6434 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6435 ) || func_exit 1
6437 # Need to run configure and make once, to create built files that are to be
6438 # distributed (such as parse-datetime.c).
6439 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
6440 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
6441 cleaned_files=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
6442 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6443 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
6444 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
6445 # such $(FOO_H) because they don't refer to distributed files.
6446 built_sources=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
6447 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6448 | sed -e "$sed_remove_make_variables"`
6449 distributed_built_sources=`for file in $built_sources; do
6450 case "$cleaned_files" in
6451 *" "$file" "*) ;;
6452 *) echo $file ;;
6453 esac;
6454 done`
6455 tests_distributed_built_sources=
6456 if $inctests; then
6457 # Likewise for built files in the $testsbase directory.
6458 tests_cleaned_files=`combine_lines < "$testdir/$testsbase/Makefile.am" \
6459 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6460 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
6461 tests_built_sources=`combine_lines < "$testdir/$testsbase/Makefile.am" \
6462 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6463 | sed -e "$sed_remove_make_variables"`
6464 tests_distributed_built_sources=`for file in $tests_built_sources; do
6465 case "$tests_cleaned_files" in
6466 *" "$file" "*) ;;
6467 *) echo $file ;;
6468 esac;
6469 done`
6471 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
6472 (cd "$testdir"
6473 ./configure || func_exit 1
6474 if test -n "$distributed_built_sources"; then
6475 cd "$sourcebase"
6476 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6477 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6478 built_sources \
6479 || func_exit 1
6480 cd ..
6482 if test -n "$tests_distributed_built_sources"; then
6483 cd "$testsbase"
6484 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6485 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6486 built_sources \
6487 || func_exit 1
6488 cd ..
6490 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6491 distclean \
6492 || func_exit 1
6493 ) || func_exit 1
6497 # func_create_megatestdir megatestdir allmodules
6498 # Input:
6499 # - local_gnulib_path from --local-dir
6500 # - modcache true or false, from --cache-modules/--no-cache-modules
6501 # - auxdir directory relative to destdir where to place build aux files
6502 func_create_megatestdir ()
6504 megatestdir="$1"
6505 allmodules="$2"
6506 if test -z "$allmodules"; then
6507 allmodules=`func_all_modules`
6510 megasubdirs=
6511 # First, all modules one by one.
6512 for onemodule in $allmodules; do
6513 func_create_testdir "$megatestdir/$onemodule" $onemodule
6514 func_append megasubdirs "$onemodule "
6515 done
6516 # Then, all modules all together.
6517 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6518 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
6519 func_create_testdir "$megatestdir/ALL" "$allmodules"
6520 func_append megasubdirs "ALL"
6522 # Create autobuild.
6523 cvsdate=`vc_witness="$gnulib_dir/.git/refs/heads/master"; \
6524 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
6525 | sed -e 's,January,01,' -e 's,Jan,01,' \
6526 -e 's,February,02,' -e 's,Feb,02,' \
6527 -e 's,March,03,' -e 's,Mar,03,' \
6528 -e 's,April,04,' -e 's,Apr,04,' \
6529 -e 's,May,05,' \
6530 -e 's,June,06,' -e 's,Jun,06,' \
6531 -e 's,July,07,' -e 's,Jul,07,' \
6532 -e 's,August,08,' -e 's,Aug,08,' \
6533 -e 's,September,09,' -e 's,Sep,09,' \
6534 -e 's,October,10,' -e 's,Oct,10,' \
6535 -e 's,November,11,' -e 's,Nov,11,' \
6536 -e 's,December,12,' -e 's,Dec,12,' \
6537 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
6538 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
6539 (echo '#!/bin/sh'
6540 echo "CVSDATE=$cvsdate"
6541 echo ": \${MAKE=make}"
6542 echo "test -d logs || mkdir logs"
6543 echo "for module in $megasubdirs; do"
6544 echo " echo \"Working on module \$module...\""
6545 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
6546 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
6547 echo " echo"
6548 echo " set -x"
6549 echo " : autobuild project... \$module"
6550 echo " : autobuild revision... cvs-\$CVSDATE-000000"
6551 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
6552 echo " : autobuild hostname... \`hostname\`"
6553 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
6554 echo " echo rc=\$?"
6555 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
6556 echo "done"
6557 ) > "$megatestdir/do-autobuild"
6558 chmod a+x "$megatestdir/do-autobuild"
6560 # Create Makefile.am.
6561 (echo "## Process this file with automake to produce Makefile.in."
6562 echo
6563 echo "AUTOMAKE_OPTIONS = 1.9.6 foreign"
6564 echo
6565 echo "SUBDIRS = $megasubdirs"
6566 echo
6567 echo "EXTRA_DIST = do-autobuild"
6568 ) > "$megatestdir/Makefile.am"
6570 # Create configure.ac.
6571 (echo "# Process this file with autoconf to produce a configure script."
6572 echo "AC_INIT([dummy], [0])"
6573 if test "$auxdir" != "."; then
6574 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6576 echo "AM_INIT_AUTOMAKE"
6577 echo
6578 echo "AC_PROG_MAKE_SET"
6579 echo
6580 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
6581 echo "AC_CONFIG_FILES([Makefile])"
6582 echo "AC_OUTPUT"
6583 ) > "$megatestdir/configure.ac"
6585 # Create autogenerated files.
6586 (cd "$megatestdir"
6587 # Do not use "${AUTORECONF} --install", because autoreconf operates
6588 # recursively, but the subdirectories are already finished, therefore
6589 # calling autoreconf here would only waste lots of CPU time.
6590 func_execute_command ${ACLOCAL} || func_exit 1
6591 func_execute_command mkdir build-aux
6592 func_execute_command ${AUTOCONF} || func_exit 1
6593 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6594 ) || func_exit 1
6597 case $mode in
6598 "" )
6599 func_fatal_error "no mode specified" ;;
6601 list )
6602 func_all_modules
6605 find )
6606 # sed expression that converts a literal to a basic regular expression.
6607 # Needs to handle . [ \ * ^ $.
6608 sed_literal_to_basic_regex='s/\\/\\\\/g
6609 s/\[/\\[/g
6610 s/\^/\\^/g
6611 s/\([.*$]\)/[\1]/g'
6612 for filename
6614 if test -f "$gnulib_dir/$filename" \
6615 || func_lookup_local_file "$filename"; then
6616 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
6617 filename_line_regex='^'"$filename_anywhere_regex"'$'
6618 module_candidates=`
6620 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
6621 func_path_foreach "$local_gnulib_path" func_modules_in_dir %dir% | xargs -n 100 grep -l "$filename_anywhere_regex" /dev/null | sed -e 's,^modules/,,' -e 's,\.diff$,,'
6623 | func_sanitize_modulelist \
6624 | LC_ALL=C sort -u
6626 for module in $module_candidates; do
6627 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
6628 echo $module
6630 done
6631 else
6632 func_warning "file $filename does not exist"
6634 done
6637 import | add-import | remove-import | update )
6639 # Where to import.
6640 if test -z "$destdir"; then
6641 destdir=.
6643 test -d "$destdir" \
6644 || func_fatal_error "destination directory does not exist: $destdir"
6646 # Prefer configure.ac to configure.in.
6647 if test -f "$destdir"/configure.ac; then
6648 configure_ac="$destdir/configure.ac"
6649 else
6650 if test -f "$destdir"/configure.in; then
6651 configure_ac="$destdir/configure.in"
6652 else
6653 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
6657 # Analyze configure.ac.
6658 guessed_auxdir="."
6659 guessed_libtool=false
6660 my_sed_traces='
6661 s,#.*$,,
6662 s,^dnl .*$,,
6663 s, dnl .*$,,
6664 /AC_CONFIG_AUX_DIR/ {
6665 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
6667 /A[CM]_PROG_LIBTOOL/ {
6668 s,^.*$,guessed_libtool=true,p
6670 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
6672 if test -z "$auxdir"; then
6673 auxdir="$guessed_auxdir"
6676 # Determine where to apply func_import.
6677 if test "$mode" = import; then
6678 # Apply func_import to a particular gnulib directory.
6679 # The command line contains the complete specification; don't look at
6680 # the contents of gnulib-cache.m4.
6681 test -n "$supplied_libname" || supplied_libname=true
6682 test -n "$sourcebase" || sourcebase="lib"
6683 test -n "$m4base" || m4base="m4"
6684 test -n "$docbase" || docbase="doc"
6685 test -n "$testsbase" || testsbase="tests"
6686 test -n "$macro_prefix" || macro_prefix="gl"
6687 func_import "$*"
6688 else
6689 if test -n "$m4base"; then
6690 # Apply func_import to a particular gnulib directory.
6691 # Any number of additional modules can be given.
6692 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
6693 # First use of gnulib in the given m4base.
6694 test -n "$supplied_libname" || supplied_libname=true
6695 test -n "$sourcebase" || sourcebase="lib"
6696 test -n "$docbase" || docbase="doc"
6697 test -n "$testsbase" || testsbase="tests"
6698 test -n "$macro_prefix" || macro_prefix="gl"
6700 func_import "$*"
6701 else
6702 # Apply func_import to all gnulib directories.
6703 # To get this list of directories, look at Makefile.am. (Not at
6704 # configure, because it may be omitted from version control. Also,
6705 # don't run "find $destdir -name gnulib-cache.m4", as it might be
6706 # too expensive.)
6707 m4dirs=
6708 m4dirs_count=0
6709 if test -f "$destdir"/Makefile.am; then
6710 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
6711 m4dir_is_next=
6712 for arg in $aclocal_amflags; do
6713 if test -n "$m4dir_is_next"; then
6714 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
6715 case "$arg" in
6716 /*) ;;
6718 if test -f "$destdir/$arg"/gnulib-cache.m4; then
6719 func_append m4dirs " $arg"
6720 m4dirs_count=`expr $m4dirs_count + 1`
6723 esac
6724 m4dir_is_next=
6725 else
6726 if test "X$arg" = "X-I"; then
6727 m4dir_is_next=yes
6728 else
6729 m4dir_is_next=
6732 done
6733 else
6734 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
6735 if test -f "$destdir"/aclocal.m4; then
6736 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
6737 sedexpr2='s,^[^/]*$,.,'
6738 sedexpr3='s,/[^/]*$,,'
6739 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
6740 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
6741 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
6744 if test $m4dirs_count = 0; then
6745 # First use of gnulib in a package.
6746 # Any number of additional modules can be given.
6747 test -n "$supplied_libname" || supplied_libname=true
6748 test -n "$sourcebase" || sourcebase="lib"
6749 m4base="m4"
6750 test -n "$docbase" || docbase="doc"
6751 test -n "$testsbase" || testsbase="tests"
6752 test -n "$macro_prefix" || macro_prefix="gl"
6753 func_import "$*"
6754 else
6755 if test $m4dirs_count = 1; then
6756 # There's only one use of gnulib here. Assume the user means it.
6757 # Any number of additional modules can be given.
6758 for m4base in $m4dirs; do
6759 func_import "$*"
6760 done
6761 else
6762 # Ambiguous - guess what the user meant.
6763 if test $# = 0; then
6764 # No further arguments. Guess the user wants to update all of them.
6765 for m4base in $m4dirs; do
6766 # Perform func_import in a subshell, so that variable values
6767 # such as
6768 # local_gnulib_path, incobsolete, inc_cxx_tests,
6769 # inc_longrunning_tests, inc_privileged_tests,
6770 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
6771 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
6772 # makefile_name, libtool, macro_prefix, po_domain,
6773 # witness_c_macro, vc_files
6774 # don't propagate from one directory to another.
6775 (func_import) || func_exit 1
6776 done
6777 else
6778 # Really ambiguous.
6779 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
6787 create-testdir )
6788 if test -z "$destdir"; then
6789 func_fatal_error "please specify --dir option"
6791 mkdir "$destdir"
6792 test -d "$destdir" \
6793 || func_fatal_error "could not create destination directory"
6794 test -n "$auxdir" || auxdir="build-aux"
6795 func_create_testdir "$destdir" "$*"
6798 create-megatestdir )
6799 if test -z "$destdir"; then
6800 func_fatal_error "please specify --dir option"
6802 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6803 test -n "$auxdir" || auxdir="build-aux"
6804 func_create_megatestdir "$destdir" "$*"
6807 test )
6808 test -n "$destdir" || destdir=testdir$$
6809 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6810 test -n "$auxdir" || auxdir="build-aux"
6811 func_create_testdir "$destdir" "$*"
6812 cd "$destdir"
6813 mkdir build
6814 cd build
6815 ../configure || func_exit 1
6816 $MAKE || func_exit 1
6817 $MAKE check || func_exit 1
6818 $MAKE distclean || func_exit 1
6819 remaining=`find . -type f -print`
6820 if test -n "$remaining"; then
6821 echo "Remaining files:" $remaining 1>&2
6822 echo "gnulib-tool: *** Stop." 1>&2
6823 func_exit 1
6825 cd ..
6826 cd ..
6827 rm -rf "$destdir"
6830 megatest )
6831 test -n "$destdir" || destdir=testdir$$
6832 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6833 test -n "$auxdir" || auxdir="build-aux"
6834 func_create_megatestdir "$destdir" "$*"
6835 cd "$destdir"
6836 mkdir build
6837 cd build
6838 ../configure
6839 $MAKE
6840 $MAKE check
6841 $MAKE distclean
6842 remaining=`find . -type f -print`
6843 if test -n "$remaining"; then
6844 echo "Remaining files:" $remaining 1>&2
6845 echo "gnulib-tool: *** Stop." 1>&2
6846 func_exit 1
6848 cd ..
6849 cd ..
6850 rm -rf "$destdir"
6853 extract-description )
6854 for module
6856 func_verify_module
6857 if test -n "$module"; then
6858 func_get_description "$module"
6860 done
6863 extract-comment )
6864 for module
6866 func_verify_module
6867 if test -n "$module"; then
6868 func_get_comment "$module"
6870 done
6873 extract-status )
6874 for module
6876 func_verify_module
6877 if test -n "$module"; then
6878 func_get_status "$module"
6880 done
6883 extract-notice )
6884 for module
6886 func_verify_module
6887 if test -n "$module"; then
6888 func_get_notice "$module"
6890 done
6893 extract-applicability )
6894 for module
6896 func_verify_module
6897 if test -n "$module"; then
6898 func_get_applicability "$module"
6900 done
6903 extract-filelist )
6904 for module
6906 func_verify_module
6907 if test -n "$module"; then
6908 func_get_filelist "$module"
6910 done
6913 extract-dependencies )
6914 if test -n "$avoidlist"; then
6915 func_fatal_error "cannot combine --avoid and --extract-dependencies"
6917 for module
6919 func_verify_module
6920 if test -n "$module"; then
6921 func_get_dependencies "$module"
6923 done
6926 extract-autoconf-snippet )
6927 for module
6929 func_verify_module
6930 if test -n "$module"; then
6931 func_get_autoconf_snippet "$module"
6933 done
6936 extract-automake-snippet )
6937 for module
6939 func_verify_module
6940 if test -n "$module"; then
6941 func_get_automake_snippet "$module"
6943 done
6946 extract-include-directive )
6947 for module
6949 func_verify_module
6950 if test -n "$module"; then
6951 func_get_include_directive "$module"
6953 done
6956 extract-link-directive )
6957 for module
6959 func_verify_module
6960 if test -n "$module"; then
6961 func_get_link_directive "$module"
6963 done
6966 extract-license )
6967 for module
6969 func_verify_module
6970 if test -n "$module"; then
6971 func_get_license "$module"
6973 done
6976 extract-maintainer )
6977 for module
6979 func_verify_module
6980 if test -n "$module"; then
6981 func_get_maintainer "$module"
6983 done
6986 extract-tests-module )
6987 for module
6989 func_verify_module
6990 if test -n "$module"; then
6991 func_get_tests_module "$module"
6993 done
6996 copy-file )
6997 # Verify the number of arguments.
6998 if test $# -lt 1 || test $# -gt 2; then
6999 func_fatal_error "invalid number of arguments for --$mode"
7002 # The first argument is the file to be copied.
7003 f="$1"
7004 # Verify the file exists.
7005 func_lookup_file "$f"
7007 # The second argument is the destination; either a directory ot a file.
7008 # It defaults to the current directory.
7009 dest="$2"
7010 test -n "$dest" || dest='.'
7011 test -n "$sourcebase" || sourcebase="lib"
7012 test -n "$m4base" || m4base="m4"
7013 test -n "$docbase" || docbase="doc"
7014 test -n "$testsbase" || testsbase="tests"
7015 test -n "$auxdir" || auxdir="build-aux"
7016 rewritten='%REWRITTEN%'
7017 sed_rewrite_files="\
7018 s,^build-aux/,$rewritten$auxdir/,
7019 s,^doc/,$rewritten$docbase/,
7020 s,^lib/,$rewritten$sourcebase/,
7021 s,^m4/,$rewritten$m4base/,
7022 s,^tests/,$rewritten$testsbase/,
7023 s,^top/,$rewritten,
7024 s,^$rewritten,,"
7025 if test -d "$dest"; then
7026 destdir="$dest"
7027 g=`echo "$f" | sed -e "$sed_rewrite_files"`
7028 else
7029 destdir=`dirname "$dest"`
7030 g=`basename "$dest"`
7033 # Create the directory for destfile.
7034 d=`dirname "$destdir/$g"`
7035 if $doit; then
7036 if test -n "$d" && test ! -d "$d"; then
7037 mkdir -p "$d" || func_fatal_error "failed"
7040 # Copy the file.
7041 func_dest_tmpfilename "$g"
7042 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
7043 already_present=true
7044 if test -f "$destdir/$g"; then
7045 # The file already exists.
7046 func_update_file
7047 else
7048 # Install the file.
7049 # Don't protest if the file should be there but isn't: it happens
7050 # frequently that developers don't put autogenerated files under version
7051 # control.
7052 func_add_file
7054 rm -f "$tmpfile"
7058 func_fatal_error "unknown operation mode --$mode" ;;
7059 esac
7061 rm -rf "$tmp"
7062 # Undo the effect of the previous 'trap' command. Some shellology:
7063 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
7064 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
7065 # exit); for the others we need to call 'exit' explicitly. The value of $? is
7066 # 128 + signal number and is set before the trap-registered command is run.
7067 trap '' 0
7068 trap 'func_exit $?' 1 2 3 13 15
7070 exit 0
7072 # Local Variables:
7073 # indent-tabs-mode: nil
7074 # whitespace-check-buffer-indent: nil
7075 # End: