warnings: fix compilation with old autoconf
[gnulib/ericb.git] / gnulib-tool
blob48c15b3692b0feb923ecb26a8538045549c8cfcf
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.
298 -h, --hardlink Make hard links instead of copying files.
299 --local-hardlink Make hard links instead of copying files, only
300 for files from the local override directory.
302 Options for --import, --add/remove-import, --update:
304 -S, --more-symlinks Make symbolic links instead of copying files, and
305 don't replace copyright notices.
306 -H, --more-hardlinks Make hard links instead of copying files, and
307 don't replace copyright notices.
309 Report bugs to <bug-gnulib@gnu.org>."
312 # func_version
313 # outputs to stdout the --version message.
314 func_version ()
316 func_gnulib_dir
317 if test -d "$gnulib_dir"/.git \
318 && (git --version) >/dev/null 2>/dev/null \
319 && (date --version) >/dev/null 2>/dev/null; then
320 # gnulib checked out from git.
321 sed_extract_first_date='/^Date/{
322 s/^Date:[ ]*//p
325 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
326 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
327 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
328 date=`echo "$date" | sed -e "$sed_year_before_time"`
329 # Use GNU date to compute the time in GMT.
330 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
331 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
332 else
333 # gnulib copy without versioning information.
334 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
335 version=
337 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
338 echo "\
339 gnulib-tool (GNU $package $date)$version
340 Copyright (C) $year Free Software Foundation, Inc.
341 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
342 This is free software: you are free to change and redistribute it.
343 There is NO WARRANTY, to the extent permitted by law.
345 printf "Written by %s, %s, and %s.\n" "Bruno Haible" "Paul Eggert" "Simon Josefsson"
348 # func_emit_copyright_notice
349 # outputs to stdout a header for a generated file.
350 func_emit_copyright_notice ()
352 sed -n -e '/Copyright/ {
355 }' < "$self_abspathname"
356 echo "#"
357 echo "# This file is free software; you can redistribute it and/or modify"
358 echo "# it under the terms of the GNU General Public License as published by"
359 echo "# the Free Software Foundation; either version 3 of the License, or"
360 echo "# (at your option) any later version."
361 echo "#"
362 echo "# This file is distributed in the hope that it will be useful,"
363 echo "# but WITHOUT ANY WARRANTY; without even the implied warranty of"
364 echo "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
365 echo "# GNU General Public License for more details."
366 echo "#"
367 echo "# You should have received a copy of the GNU General Public License"
368 echo "# along with this file. If not, see <http://www.gnu.org/licenses/>."
369 echo "#"
370 echo "# As a special exception to the GNU General Public License,"
371 echo "# this file may be distributed as part of a program that"
372 echo "# contains a configuration script generated by Autoconf, under"
373 echo "# the same distribution terms as the rest of that program."
374 echo "#"
375 echo "# Generated by gnulib-tool."
378 # func_exit STATUS
379 # exits with a given status.
380 # This function needs to be used, rather than 'exit', when a 'trap' handler is
381 # in effect that refers to $?.
382 func_exit ()
384 (exit $1); exit $1
387 # func_gnulib_dir
388 # locates the directory where the gnulib repository lives
389 # Input:
390 # - progname name of this program
391 # Sets variables
392 # - self_abspathname absolute pathname of gnulib-tool
393 # - gnulib_dir absolute pathname of gnulib repository
394 func_gnulib_dir ()
396 case "$progname" in
397 /* | ?:*) self_abspathname="$progname" ;;
398 */*) self_abspathname=`pwd`/"$progname" ;;
400 # Look in $PATH.
401 # Iterate through the elements of $PATH.
402 # We use IFS=: instead of
403 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
404 # because the latter does not work when some PATH element contains spaces.
405 # We use a canonicalized $pathx instead of $PATH, because empty PATH
406 # elements are by definition equivalent to '.', however field splitting
407 # according to IFS=: loses empty fields in many shells:
408 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
409 # beginning, at the end, and in the middle),
410 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
411 # at the beginning and at the end,
412 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
413 # Solaris lose empty fields at the end.
414 # The 'case' statement is an optimization, to avoid evaluating the
415 # explicit canonicalization command when $PATH contains no empty fields.
416 self_abspathname=
417 if test "$PATH_SEPARATOR" = ";"; then
418 # On Windows, programs are searched in "." before $PATH.
419 pathx=".;$PATH"
420 else
421 # On Unix, we have to convert empty PATH elements to ".".
422 pathx="$PATH"
423 case :$PATH: in
424 *::*)
425 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
427 esac
429 save_IFS="$IFS"
430 IFS="$PATH_SEPARATOR"
431 for d in $pathx; do
432 IFS="$save_IFS"
433 test -z "$d" && d=.
434 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
435 self_abspathname="$d/$progname"
436 break
438 done
439 IFS="$save_IFS"
440 if test -z "$self_abspathname"; then
441 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
444 esac
445 while test -h "$self_abspathname"; do
446 # Resolve symbolic link.
447 linkval=`func_readlink "$self_abspathname"`
448 test -n "$linkval" || break
449 case "$linkval" in
450 /* | ?:* ) self_abspathname="$linkval" ;;
451 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
452 esac
453 done
454 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
457 # func_tmpdir
458 # creates a temporary directory.
459 # Input:
460 # - progname name of this program
461 # Sets variable
462 # - tmp pathname of freshly created temporary directory
463 func_tmpdir ()
465 # Use the environment variable TMPDIR, falling back to /tmp. This allows
466 # users to specify a different temporary directory, for example, if their
467 # /tmp is filled up or too small.
468 : ${TMPDIR=/tmp}
470 # Use the mktemp program if available. If not available, hide the error
471 # message.
472 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
473 test -n "$tmp" && test -d "$tmp"
474 } ||
476 # Use a simple mkdir command. It is guaranteed to fail if the directory
477 # already exists. $RANDOM is bash specific and expands to empty in shells
478 # other than bash, ksh and zsh. Its use does not increase security;
479 # rather, it minimizes the probability of failure in a very cluttered /tmp
480 # directory.
481 tmp=$TMPDIR/gl$$-$RANDOM
482 (umask 077 && mkdir "$tmp")
483 } ||
485 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
486 func_exit 1
490 # func_append var value
491 # appends the given value to the shell variable var.
492 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
493 # Use bash's += operator. It reduces complexity of appending repeatedly to
494 # a single variable from O(n^2) to O(n).
495 func_append ()
497 eval "$1+=\"\$2\""
499 fast_func_append=true
500 else
501 func_append ()
503 eval "$1=\"\$$1\$2\""
505 fast_func_append=false
508 # func_remove_prefix var prefix
509 # removes the given prefix from the value of the shell variable var.
510 # var should be the name of a shell variable.
511 # Its value should not contain a newline and not start or end with whitespace.
512 # prefix should not contain the characters "$`\{}[]^|.
513 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
514 func_remove_prefix ()
516 eval "$1=\${$1#\$2}"
518 fast_func_remove_prefix=true
519 else
520 func_remove_prefix ()
522 eval "value=\"\$$1\""
523 prefix="$2"
524 case "$prefix" in
525 *.*)
526 sed_escape_dots='s/\([.]\)/\\\1/g'
527 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
529 esac
530 value=`echo "$value" | sed -e "s|^${prefix}||"`
531 eval "$1=\"\$value\""
533 fast_func_remove_prefix=false
536 # Determine whether we should use ':' or ';' as PATH_SEPARATOR.
537 func_determine_path_separator ()
539 if test "${PATH_SEPARATOR+set}" != set; then
540 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
541 # contains only /bin. Note that ksh looks also at the FPATH variable,
542 # so we have to set that as well for the test.
543 PATH_SEPARATOR=:
544 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
545 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
546 || PATH_SEPARATOR=';'
551 # func_path_prepend pathvar directory
552 # puts directory before pathvar, delimiting directories by PATH_SEPARATOR.
553 # Newly added directory into pathvar has the highest priority.
554 func_path_prepend ()
556 if eval "test -n \"\$$1\""; then
557 eval "$1=\$2\$PATH_SEPARATOR\$$1"
558 else
559 eval "$1=\$2"
563 # func_path_append pathvar directory
564 # Similar to func_path_prepend except that the newest directory has the lowest
565 # priority.
566 func_path_append ()
568 if eval "test -n \"\$$1\""; then
569 func_append "$1" "$PATH_SEPARATOR$2"
570 else
571 eval "$1=\$2"
575 # func_path_foreach_inner
576 # helper for func_path_foreach because we need new 'args' array
577 # Input:
578 # - fpf_dir directory from local_gnulib_path
579 # - fpf_cb callback to be run for fpf_dir
580 func_path_foreach_inner ()
582 set %start% "$@"
583 for _fpf_arg
585 case $_fpf_arg in
586 %start%)
587 set dummy
589 %dir%)
590 set "$@" "$fpf_dir"
593 set "$@" "$_fpf_arg"
595 esac
596 done
597 shift
599 "$fpf_cb" "$@"
602 # func_path_foreach path method args
603 # Execute method for each directory in path. The method will be called
604 # like `method args` while any argument '%dir%' within args will be replaced
605 # with processed directory from path.
606 func_path_foreach ()
608 fpf_save_IFS=$IFS
609 fpf_dirs=$1 ; shift
610 fpf_cb=$1 ; shift
611 fpf_rc=false
613 IFS=$PATH_SEPARATOR
614 for fpf_dir in $fpf_dirs
616 func_path_foreach_inner "$@" && fpf_rc=:
617 done
618 IFS=$fpf_save_IFS
619 $fpf_rc
622 # func_remove_suffix var suffix
623 # removes the given suffix from the value of the shell variable var.
624 # var should be the name of a shell variable.
625 # Its value should not contain a newline and not start or end with whitespace.
626 # suffix should not contain the characters "$`\{}[]^|.
627 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
628 func_remove_suffix ()
630 eval "$1=\${$1%\$2}"
632 fast_func_remove_suffix=true
633 else
634 func_remove_suffix ()
636 eval "value=\"\$$1\""
637 suffix="$2"
638 case "$suffix" in
639 *.*)
640 sed_escape_dots='s/\([.]\)/\\\1/g'
641 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
643 esac
644 value=`echo "$value" | sed -e "s|${suffix}\$||"`
645 eval "$1=\"\$value\""
647 fast_func_remove_suffix=false
650 # func_fatal_error message
651 # outputs to stderr a fatal error message, and terminates the program.
652 # Input:
653 # - progname name of this program
654 func_fatal_error ()
656 echo "$progname: *** $1" 1>&2
657 echo "$progname: *** Stop." 1>&2
658 func_exit 1
661 # func_warning message
662 # Outputs to stderr a warning message,
663 func_warning ()
665 echo "gnulib-tool: warning: $1" 1>&2
668 # func_readlink SYMLINK
669 # outputs the target of the given symlink.
670 if (type readlink) > /dev/null 2>&1; then
671 func_readlink ()
673 # Use the readlink program from GNU coreutils.
674 readlink "$1"
676 else
677 func_readlink ()
679 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
680 # would do the wrong thing if the link target contains " -> ".
681 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
685 # func_relativize DIR1 DIR2
686 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
687 # Input:
688 # - DIR1 relative pathname, relative to the current directory
689 # - DIR2 relative pathname, relative to the current directory
690 # Output:
691 # - reldir relative pathname of DIR2, relative to DIR1
692 func_relativize ()
694 dir0=`pwd`
695 dir1="$1"
696 dir2="$2"
697 sed_first='s,^\([^/]*\)/.*$,\1,'
698 sed_rest='s,^[^/]*/*,,'
699 sed_last='s,^.*/\([^/]*\)$,\1,'
700 sed_butlast='s,/*[^/]*$,,'
701 while test -n "$dir1"; do
702 first=`echo "$dir1" | sed -e "$sed_first"`
703 if test "$first" != "."; then
704 if test "$first" = ".."; then
705 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
706 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
707 else
708 first2=`echo "$dir2" | sed -e "$sed_first"`
709 if test "$first2" = "$first"; then
710 dir2=`echo "$dir2" | sed -e "$sed_rest"`
711 else
712 dir2="../$dir2"
714 dir0="$dir0"/"$first"
717 dir1=`echo "$dir1" | sed -e "$sed_rest"`
718 done
719 reldir="$dir2"
722 # func_relconcat DIR1 DIR2
723 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
724 # Input:
725 # - DIR1 relative pathname, relative to the current directory
726 # - DIR2 relative pathname, relative to DIR1
727 # Output:
728 # - relconcat DIR1/DIR2, relative to the current directory
729 func_relconcat ()
731 dir1="$1"
732 dir2="$2"
733 sed_first='s,^\([^/]*\)/.*$,\1,'
734 sed_rest='s,^[^/]*/*,,'
735 sed_last='s,^.*/\([^/]*\)$,\1,'
736 sed_butlast='s,/*[^/]*$,,'
737 while true; do
738 first=`echo "$dir2" | sed -e "$sed_first"`
739 if test "$first" = "."; then
740 dir2=`echo "$dir2" | sed -e "$sed_rest"`
741 if test -z "$dir2"; then
742 relconcat="$dir1"
743 break
745 else
746 last=`echo "$dir1" | sed -e "$sed_last"`
747 while test "$last" = "."; do
748 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
749 last=`echo "$dir1" | sed -e "$sed_last"`
750 done
751 if test -z "$dir1"; then
752 relconcat="$dir2"
753 break
755 if test "$first" = ".."; then
756 if test "$last" = ".."; then
757 relconcat="$dir1/$dir2"
758 break
760 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
761 dir2=`echo "$dir2" | sed -e "$sed_rest"`
762 if test -z "$dir1"; then
763 relconcat="$dir2"
764 break
766 if test -z "$dir2"; then
767 relconcat="$dir1"
768 break
770 else
771 relconcat="$dir1/$dir2"
772 break
775 done
778 # func_ln_s SRC DEST
779 # Like ln -s, except use cp -p if ln -s fails.
780 func_ln_s ()
782 ln -s "$1" "$2" || {
783 echo "$progname: ln -s failed; falling back on cp -p" >&2
785 case "$1" in
786 /* | ?:*) # SRC is absolute.
787 cp_src="$1" ;;
788 *) # SRC is relative to the directory of DEST.
789 case "$2" in
790 */*) cp_src="${2%/*}/$1" ;;
791 *) cp_src="$1" ;;
792 esac
794 esac
796 cp -p "$cp_src" "$2"
800 # func_symlink_target SRC DEST
801 # Determines LINK_TARGET such that "ln -s LINK_TARGET DEST" will create a
802 # symbolic link DEST that points to SRC.
803 # Output:
804 # - link_target link target, relative to the directory of DEST
805 func_symlink_target ()
807 case "$1" in
808 /* | ?:*)
809 link_target="$1" ;;
810 *) # SRC is relative.
811 case "$2" in
812 /* | ?:*)
813 link_target="`pwd`/$1" ;;
814 *) # DEST is relative too.
815 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
816 test -n "$ln_destdir" || ln_destdir="."
817 func_relativize "$ln_destdir" "$1"
818 link_target="$reldir"
820 esac
822 esac
825 # func_symlink SRC DEST
826 # Like func_ln_s, except that SRC is given relative to the current directory (or
827 # absolute), not given relative to the directory of DEST.
828 func_symlink ()
830 func_symlink_target "$1" "$2"
831 func_ln_s "$link_target" "$2"
834 # func_symlink_if_changed SRC DEST
835 # Like func_symlink, but avoids munging timestamps if the link is correct.
836 # SRC is given relative to the current directory (or absolute).
837 func_symlink_if_changed ()
839 if test $# -ne 2; then
840 echo "usage: func_symlink_if_changed SRC DEST" >&2
842 func_symlink_target "$1" "$2"
843 ln_target=`func_readlink "$2"`
844 if test -h "$2" && test "$link_target" = "$ln_target"; then
846 else
847 rm -f "$2"
848 func_ln_s "$link_target" "$2"
852 # func_hardlink SRC DEST
853 # Like ln, except use cp -p if ln fails.
854 # SRC is given relative to the current directory (or absolute).
855 func_hardlink ()
857 ln "$1" "$2" || {
858 echo "$progname: ln failed; falling back on cp -p" >&2
859 cp -p "$1" "$2"
863 # Ensure an 'echo' command that
864 # 1. does not interpret backslashes and
865 # 2. does not print an error message "broken pipe" when writing into a pipe
866 # with no writers.
868 # Test cases for problem 1:
869 # echo '\n' | wc -l prints 1 when OK, 2 when KO
870 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
871 # Test cases for problem 2:
872 # echo hi | true frequently prints
873 # "bash: echo: write error: Broken pipe"
874 # to standard error in bash 3.2.
876 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
877 # BSD echo interprets '-n' as an option, which is also not desirable).
878 # Nowadays the problem occurs in 4 situations:
879 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
880 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
881 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
882 # - in zsh, when sh-emulation is not set,
883 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
884 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
885 # - in Solaris /bin/sh and OSF/1 /bin/sh.
886 # We try the following workarounds:
887 # - for all: respawn using $CONFIG_SHELL if that is set and works.
888 # - for bash >= 2.04: unset the shell option xpg_echo.
889 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
890 # - for bash < 2.0: define echo to a function that uses cat of a here document.
891 # - for zsh: turn sh-emulation on.
892 # - for ksh: alias echo to 'print -r'.
893 # - for ksh: alias echo to a function that uses cat of a here document.
894 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
895 # the ksh workaround.
896 # - otherwise: respawn using /bin/sh and rely on the workarounds.
897 # When respawning, we pass --no-reexec as first argument, so as to avoid
898 # turning this script into a fork bomb in unlucky situations.
900 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
901 # the 'printf' built-in. See
902 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
903 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
904 # The workaround is: define echo to a function that uses the printf built-in.
905 have_echo=
906 if echo '\t' | grep t > /dev/null; then
907 have_echo=yes # Lucky!
909 # Try the workarounds.
910 # Respawn using $CONFIG_SHELL if that is set and works.
911 if test -z "$have_echo" \
912 && test "X$1" != "X--no-reexec" \
913 && test -n "$CONFIG_SHELL" \
914 && test -f "$CONFIG_SHELL" \
915 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
916 exec $CONFIG_SHELL "$0" --no-reexec "$@"
917 exit 127
919 # For bash >= 2.04: unset the shell option xpg_echo.
920 if test -z "$have_echo" \
921 && test -n "$BASH_VERSION" \
922 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
923 shopt -o xpg_echo
924 have_echo=yes
926 # For bash >= 2.0: define echo to a function that uses the printf built-in.
927 # For bash < 2.0: define echo to a function that uses cat of a here document.
928 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
929 # Also handle problem 2, specific to bash 3.2, here.
930 if { test -z "$have_echo" \
931 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
933 && test -n "$BASH_VERSION"; then \
934 if type printf 2>/dev/null | grep / > /dev/null; then
935 # 'printf' is not a shell built-in.
936 echo ()
938 cat <<EOF
942 else
943 # 'printf' is a shell built-in.
944 echo ()
946 printf '%s\n' "$*"
949 if echo '\t' | grep t > /dev/null; then
950 have_echo=yes
953 # For zsh: turn sh-emulation on.
954 if test -z "$have_echo" \
955 && test -n "$ZSH_VERSION" \
956 && (emulate sh) >/dev/null 2>&1; then
957 emulate sh
959 # For ksh: alias echo to 'print -r'.
960 if test -z "$have_echo" \
961 && (type print) >/dev/null 2>&1; then
962 # A 'print' command exists.
963 if type print 2>/dev/null | grep / > /dev/null; then
965 else
966 # 'print' is a shell built-in.
967 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
968 # 'print' is the ksh shell built-in.
969 alias echo='print -r'
973 if test -z "$have_echo" \
974 && echo '\t' | grep t > /dev/null; then
975 have_echo=yes
977 # For ksh: alias echo to a function that uses cat of a here document.
978 # The ksh manual page says:
979 # "Aliasing is performed when scripts are read, not while they are executed.
980 # Therefore, for an alias to take effect, the alias definition command has
981 # to be executed before the command which references the alias is read."
982 # Because of this, we have to play strange tricks with have_echo, to ensure
983 # that the top-level statement containing the test starts after the 'alias'
984 # command.
985 if test -z "$have_echo"; then
986 bsd_echo ()
988 cat <<EOF
992 if (alias echo=bsd_echo) 2>/dev/null; then
993 alias echo=bsd_echo 2>/dev/null
996 if test -z "$have_echo" \
997 && echo '\t' | grep t > /dev/null; then
998 have_echo=yes
1000 if test -z "$have_echo"; then
1001 if (alias echo=bsd_echo) 2>/dev/null; then
1002 unalias echo 2>/dev/null
1005 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
1006 if test -z "$have_echo" \
1007 && test "X$1" != "X--no-reexec" \
1008 && test -f /bin/ksh; then
1009 exec /bin/ksh "$0" --no-reexec "$@"
1010 exit 127
1012 # Otherwise: respawn using /bin/sh.
1013 if test -z "$have_echo" \
1014 && test "X$1" != "X--no-reexec" \
1015 && test -f /bin/sh; then
1016 exec /bin/sh "$0" --no-reexec "$@"
1017 exit 127
1019 if test -z "$have_echo"; then
1020 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
1022 if echo '\t' | grep t > /dev/null; then
1023 : # Works fine now.
1024 else
1025 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
1027 if test "X$1" = "X--no-reexec"; then
1028 shift
1031 # Unset CDPATH. Otherwise, output from 'cd dir' can surprise callers.
1032 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
1034 # Determine the path separator early because the following option parsing code
1035 # requires that.
1036 func_determine_path_separator
1038 # Command-line option processing.
1039 # Removes the OPTIONS from the arguments. Sets the variables:
1040 # - mode one of: list, find, import, add-import, remove-import,
1041 # update, create-testdir, create-megatestdir, test, megatest,
1042 # copy-file
1043 # - destdir from --dir
1044 # - local_gnulib_path from --local-dir
1045 # - modcache true or false, from --cache-modules/--no-cache-modules
1046 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1047 # - libname, supplied_libname from --lib
1048 # - sourcebase from --source-base
1049 # - m4base from --m4-base
1050 # - pobase from --po-base
1051 # - docbase from --doc-base
1052 # - testsbase from --tests-base
1053 # - auxdir from --aux-dir
1054 # - inctests true if --with-tests was given, false if --without-tests
1055 # was given, blank otherwise
1056 # - incobsolete true if --with-obsolete was given, blank otherwise
1057 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
1058 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
1059 # otherwise
1060 # - inc_privileged_tests true if --with-privileged-tests was given, blank
1061 # otherwise
1062 # - inc_unportable_tests true if --with-unportable-tests was given, blank
1063 # otherwise
1064 # - inc_all_tests true if --with-all-tests was given, blank otherwise
1065 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
1066 # - excl_longrunning_tests true if --without-longrunning-tests was given,
1067 # blank otherwise
1068 # - excl_privileged_tests true if --without-privileged-tests was given, blank
1069 # otherwise
1070 # - excl_unportable_tests true if --without-unportable-tests was given, blank
1071 # otherwise
1072 # - single_configure true if --single-configure was given, false otherwise
1073 # - avoidlist list of modules to avoid, from --avoid
1074 # - cond_dependencies true if --conditional-dependencies was given, false if
1075 # --no-conditional-dependencies was given, blank otherwise
1076 # - lgpl yes or a number if --lgpl was given, blank otherwise
1077 # - gnu_make true if --gnu-make was given, false otherwise
1078 # - makefile_name from --makefile-name
1079 # - libtool true if --libtool was given, false if --no-libtool was
1080 # given, blank otherwise
1081 # - macro_prefix from --macro-prefix
1082 # - po_domain from --po-domain
1083 # - witness_c_macro from --witness-c-macro
1084 # - vc_files true if --vc-files was given, false if --no-vc-files was
1085 # given, blank otherwise
1086 # - autoconf_minversion minimum supported autoconf version
1087 # - doit : if actions shall be executed, false if only to be printed
1088 # - copymode symlink if --symlink or --more-symlinks was given,
1089 # hardlink if --hardlink or --more-hardlinks was given,
1090 # blank otherwise
1091 # - lcopymode symlink if --local-symlink was given,
1092 # hardlink if --local-hardlink was given,
1093 # blank otherwise
1094 # - do_copyrights blank if --more-symlinks or --more-hardlinks was given,
1095 # true otherwise
1097 mode=
1098 destdir=
1099 local_gnulib_path=
1100 modcache=true
1101 verbose=0
1102 libname=libgnu
1103 supplied_libname=
1104 sourcebase=
1105 m4base=
1106 pobase=
1107 docbase=
1108 testsbase=
1109 auxdir=
1110 inctests=
1111 incobsolete=
1112 inc_cxx_tests=
1113 inc_longrunning_tests=
1114 inc_privileged_tests=
1115 inc_unportable_tests=
1116 inc_all_tests=
1117 excl_cxx_tests=
1118 excl_longrunning_tests=
1119 excl_privileged_tests=
1120 excl_unportable_tests=
1121 single_configure=false
1122 avoidlist=
1123 cond_dependencies=
1124 lgpl=
1125 gnu_make=false
1126 makefile_name=
1127 libtool=
1128 macro_prefix=
1129 po_domain=
1130 witness_c_macro=
1131 vc_files=
1132 doit=:
1133 copymode=
1134 lcopymode=
1135 do_copyrights=true
1137 supplied_opts="$@"
1139 while test $# -gt 0; do
1140 case "$1" in
1141 --list | --lis )
1142 mode=list
1143 shift ;;
1144 --find | --fin | --fi | --f )
1145 mode=find
1146 shift ;;
1147 --import | --impor | --impo | --imp | --im | --i )
1148 mode=import
1149 shift ;;
1150 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
1151 mode=add-import
1152 shift ;;
1153 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
1154 mode=remove-import
1155 shift ;;
1156 --update | --updat | --upda | --upd | --up | --u )
1157 mode=update
1158 shift ;;
1159 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
1160 mode=create-testdir
1161 shift ;;
1162 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
1163 mode=create-megatestdir
1164 shift ;;
1165 --test | --tes | --te | --t )
1166 mode=test
1167 shift ;;
1168 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1169 mode=megatest
1170 shift ;;
1171 --extract-* )
1172 mode=`echo "X$1" | sed -e 's/^X--//'`
1173 shift ;;
1174 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop )
1175 mode=copy-file
1176 shift ;;
1177 --dir )
1178 shift
1179 if test $# = 0; then
1180 func_fatal_error "missing argument for --dir"
1182 destdir=$1
1183 shift ;;
1184 --dir=* )
1185 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1186 shift ;;
1187 --local-dir )
1188 shift
1189 if test $# = 0; then
1190 func_fatal_error "missing argument for --local-dir"
1192 func_path_prepend local_gnulib_path "$1"
1193 shift ;;
1194 --local-dir=* )
1195 local_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1196 func_path_prepend local_gnulib_path "$local_dir"
1197 shift ;;
1198 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1199 modcache=true
1200 shift ;;
1201 --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 )
1202 modcache=false
1203 shift ;;
1204 --verbose | --verbos | --verbo | --verb )
1205 verbose=`expr $verbose + 1`
1206 shift ;;
1207 --quiet | --quie | --qui | --qu | --q )
1208 verbose=`expr $verbose - 1`
1209 shift ;;
1210 --lib )
1211 shift
1212 if test $# = 0; then
1213 func_fatal_error "missing argument for --lib"
1215 libname=$1
1216 supplied_libname=true
1217 shift ;;
1218 --lib=* )
1219 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1220 supplied_libname=true
1221 shift ;;
1222 --source-base )
1223 shift
1224 if test $# = 0; then
1225 func_fatal_error "missing argument for --source-base"
1227 sourcebase=$1
1228 shift ;;
1229 --source-base=* )
1230 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1231 shift ;;
1232 --m4-base )
1233 shift
1234 if test $# = 0; then
1235 func_fatal_error "missing argument for --m4-base"
1237 m4base=$1
1238 shift ;;
1239 --m4-base=* )
1240 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1241 shift ;;
1242 --po-base )
1243 shift
1244 if test $# = 0; then
1245 func_fatal_error "missing argument for --po-base"
1247 pobase=$1
1248 shift ;;
1249 --po-base=* )
1250 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1251 shift ;;
1252 --doc-base )
1253 shift
1254 if test $# = 0; then
1255 func_fatal_error "missing argument for --doc-base"
1257 docbase=$1
1258 shift ;;
1259 --doc-base=* )
1260 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1261 shift ;;
1262 --tests-base )
1263 shift
1264 if test $# = 0; then
1265 func_fatal_error "missing argument for --tests-base"
1267 testsbase=$1
1268 shift ;;
1269 --tests-base=* )
1270 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1271 shift ;;
1272 --aux-dir )
1273 shift
1274 if test $# = 0; then
1275 func_fatal_error "missing argument for --aux-dir"
1277 auxdir=$1
1278 shift ;;
1279 --aux-dir=* )
1280 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1281 shift ;;
1282 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1283 inctests=true
1284 shift ;;
1285 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1286 incobsolete=true
1287 shift ;;
1288 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1289 inc_cxx_tests=true
1290 shift ;;
1291 --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)
1292 inc_longrunning_tests=true
1293 shift ;;
1294 --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)
1295 inc_privileged_tests=true
1296 shift ;;
1297 --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)
1298 inc_unportable_tests=true
1299 shift ;;
1300 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1301 inc_all_tests=true
1302 shift ;;
1303 --without-tests | --without-test | --without-tes | --without-te | --without-t)
1304 inctests=false
1305 shift ;;
1306 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1307 excl_cxx_tests=true
1308 shift ;;
1309 --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)
1310 excl_longrunning_tests=true
1311 shift ;;
1312 --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)
1313 excl_privileged_tests=true
1314 shift ;;
1315 --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)
1316 excl_unportable_tests=true
1317 shift ;;
1318 --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)
1319 single_configure=true
1320 shift ;;
1321 --avoid )
1322 shift
1323 if test $# = 0; then
1324 func_fatal_error "missing argument for --avoid"
1326 func_append avoidlist " $1"
1327 shift ;;
1328 --avoid=* )
1329 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1330 func_append avoidlist " $arg"
1331 shift ;;
1332 --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)
1333 cond_dependencies=true
1334 shift ;;
1335 --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)
1336 cond_dependencies=false
1337 shift ;;
1338 --lgpl )
1339 lgpl=yes
1340 shift ;;
1341 --lgpl=* )
1342 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1343 case "$arg" in
1344 2 | 3orGPLv2 | 3) ;;
1345 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1346 esac
1347 lgpl=$arg
1348 shift ;;
1349 --gnu-make )
1350 gnu_make=true
1351 shift ;;
1352 --makefile-name )
1353 shift
1354 if test $# = 0; then
1355 func_fatal_error "missing argument for --makefile-name"
1357 makefile_name="$1"
1358 shift ;;
1359 --makefile-name=* )
1360 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1361 shift ;;
1362 --libtool )
1363 libtool=true
1364 shift ;;
1365 --no-libtool )
1366 libtool=false
1367 shift ;;
1368 --macro-prefix )
1369 shift
1370 if test $# = 0; then
1371 func_fatal_error "missing argument for --macro-prefix"
1373 macro_prefix="$1"
1374 shift ;;
1375 --macro-prefix=* )
1376 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1377 shift ;;
1378 --po-domain )
1379 shift
1380 if test $# = 0; then
1381 func_fatal_error "missing argument for --po-domain"
1383 po_domain="$1"
1384 shift ;;
1385 --po-domain=* )
1386 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1387 shift ;;
1388 --witness-c-macro )
1389 shift
1390 if test $# = 0; then
1391 func_fatal_error "missing argument for --witness-c-macro"
1393 witness_c_macro="$1"
1394 shift ;;
1395 --witness-c-macro=* )
1396 witness_c_macro=`echo "X$1" | sed -e 's/^X--witness-c-macro=//'`
1397 shift ;;
1398 --vc-files )
1399 vc_files=true
1400 shift ;;
1401 --no-vc-files )
1402 vc_files=false
1403 shift ;;
1404 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1405 # A no-op for backward compatibility.
1406 shift ;;
1407 --dry-run )
1408 doit=false
1409 shift ;;
1410 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1411 copymode=symlink
1412 shift ;;
1413 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1414 lcopymode=symlink
1415 shift ;;
1416 -h | --hardlink | --hardlin | --hardli | --hardl | --hard | --har | --ha )
1417 copymode=hardlink
1418 shift ;;
1419 --local-hardlink | --local-hardlin | --local-hardli | --local-hardl | --local-hard | --local-har | --local-ha | --local-h )
1420 lcopymode=hardlink
1421 shift ;;
1422 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s )
1423 copymode=symlink
1424 do_copyrights=
1425 shift ;;
1426 -H | --more-hardlinks | --more-hardlink | --more-hardlin | --more-hardli | --more-hardl | --more-hard | --more-har | --more-ha | --more-h )
1427 copymode=hardlink
1428 do_copyrights=
1429 shift ;;
1430 --help | --hel | --he )
1431 func_usage
1432 func_exit $? ;;
1433 --version | --versio | --versi | --vers )
1434 func_version
1435 func_exit $? ;;
1436 -- )
1437 # Stop option processing
1438 shift
1439 break ;;
1440 -* )
1441 echo "gnulib-tool: unknown option $1" 1>&2
1442 echo "Try 'gnulib-tool --help' for more information." 1>&2
1443 func_exit 1 ;;
1445 break ;;
1446 esac
1447 done
1449 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1450 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1451 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1452 || test "$single_configure" != false; then
1453 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1454 echo "Try 'gnulib-tool --help' for more information." 1>&2
1455 func_exit 1
1458 if test "$mode" = update; then
1459 if test $# != 0; then
1460 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1461 echo "Try 'gnulib-tool --help' for more information." 1>&2
1462 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1463 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1464 func_exit 1
1466 if test -n "$local_gnulib_path" || test -n "$supplied_libname" \
1467 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1468 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1469 || test -n "$inctests" || test -n "$incobsolete" \
1470 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1471 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1472 || test -n "$inc_all_tests" \
1473 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1474 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1475 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1476 || test -n "$macro_prefix" || test -n "$po_domain" \
1477 || test -n "$witness_c_macro" || test -n "$vc_files"; then
1478 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1479 echo "Try 'gnulib-tool --help' for more information." 1>&2
1480 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1481 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1482 func_exit 1
1485 if test -n "$pobase" && test -z "$po_domain"; then
1486 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1487 echo "Try 'gnulib-tool --help' for more information." 1>&2
1488 func_exit 1
1490 if test -z "$pobase" && test -n "$po_domain"; then
1491 func_warning "--po-domain has no effect without a --po-base option"
1493 # Canonicalize the inctests variable.
1494 case "$mode" in
1495 import | add-import | remove-import | update)
1496 if test -z "$inctests"; then
1497 inctests=false
1500 create-testdir | create-megatestdir | test | megatest)
1501 if test -z "$inctests"; then
1502 inctests=true
1505 esac
1506 # Now the only possible values of "$inctests" are true and false
1507 # (or blank but then it is irrelevant).
1508 if test "$cond_dependencies" = true && test "$inctests" = true; then
1509 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
1510 func_exit 1
1513 # Determine the minimum supported autoconf version from the project's
1514 # configure.ac.
1515 DEFAULT_AUTOCONF_MINVERSION="2.59"
1516 autoconf_minversion=
1517 configure_ac=
1518 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1519 && test -n "$destdir"; then
1520 if test -f "$destdir"/configure.ac; then
1521 configure_ac="$destdir/configure.ac"
1522 else
1523 if test -f "$destdir"/configure.in; then
1524 configure_ac="$destdir/configure.in"
1527 else
1528 if test -f configure.ac; then
1529 configure_ac="configure.ac"
1530 else
1531 if test -f configure.in; then
1532 configure_ac="configure.in"
1536 if test -n "$configure_ac"; then
1537 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1538 # because when some m4 files are omitted from a version control repository,
1539 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1540 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1541 # autom4te: m4 failed with exit status: 1
1542 prereqs=
1543 my_sed_traces='
1544 s,#.*$,,
1545 s,^dnl .*$,,
1546 s, dnl .*$,,
1547 /AC_PREREQ/ {
1548 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1550 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1551 if test -n "$prereqs"; then
1552 autoconf_minversion=`
1553 for version in $prereqs; do echo $version; done |
1554 LC_ALL=C sort -nru | sed -e 1q
1558 if test -z "$autoconf_minversion"; then
1559 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1561 case "$autoconf_minversion" in
1562 1.* | 2.[0-4]* | 2.5[0-8]*)
1563 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1564 esac
1566 # Remove trailing slashes from the directory names. This is necessary for
1567 # m4base (to avoid an error in func_import) and optional for the others.
1568 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1569 old_local_gnulib_path=$local_gnulib_path
1570 save_IFS=$IFS
1571 IFS=:
1572 local_gnulib_path=
1573 for dir in $old_local_gnulib_path
1575 case "$dir" in
1576 */ ) dir=`echo "$dir" | sed -e "$sed_trimtrailingslashes"` ;;
1577 esac
1578 func_path_append local_gnulib_path "$dir"
1579 done
1580 IFS=$save_IFS
1581 case "$sourcebase" in
1582 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1583 esac
1584 case "$m4base" in
1585 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1586 esac
1587 case "$pobase" in
1588 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1589 esac
1590 case "$docbase" in
1591 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1592 esac
1593 case "$testsbase" in
1594 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1595 esac
1596 case "$auxdir" in
1597 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1598 esac
1601 func_gnulib_dir
1602 func_tmpdir
1603 trap 'exit_status=$?
1604 if test "$signal" != 0; then
1605 echo "caught signal $signal" >&2
1607 rm -rf "$tmp"
1608 exit $exit_status' 0
1609 for signal in 1 2 3 13 15; do
1610 trap '{ signal='$signal'; func_exit 1; }' $signal
1611 done
1612 signal=0
1614 # Note: The 'eval' silences stderr output in dash.
1615 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1616 # Zsh 4 and Bash 4 have associative arrays.
1617 have_associative=true
1618 else
1619 # For other shells, use 'eval' with computed shell variable names.
1620 have_associative=false
1623 # func_lookup_local_file_cb dir file
1624 # return true and set func_lookup_local_file_result if the file 'dir/file'
1625 # exists
1626 func_lookup_local_file_cb ()
1628 test -n "$func_lookup_local_file_result" && return 1 # already found?
1629 test -f "$1/$2" || return 1
1630 func_lookup_local_file_result=$1/$2
1634 # func_lookup_local_file file
1635 # looks up a file in $local_gnulib_path.
1636 # Input:
1637 # - local_gnulib_path from --local-dir
1638 # Output:
1639 # - func_lookup_local_file_result name of the file, valid only when the
1640 # function succeeded.
1641 func_lookup_local_file ()
1643 func_lookup_local_file_result=
1644 func_path_foreach "$local_gnulib_path" func_lookup_local_file_cb %dir% "$1"
1647 # func_lookup_file file
1648 # looks up a file in $local_gnulib_path or $gnulib_dir, or combines it through
1649 # 'patch'.
1650 # Input:
1651 # - local_gnulib_path from --local-dir
1652 # Output:
1653 # - lookedup_file name of the merged (combined) file
1654 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1655 func_lookup_file ()
1657 lkfile="$1"
1658 if func_lookup_local_file "$lkfile"; then
1659 lookedup_file=$func_lookup_local_file_result
1660 lookedup_tmp=
1661 else
1662 if test -f "$gnulib_dir/$lkfile"; then
1663 if func_lookup_local_file "$lkfile.diff"; then
1664 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1665 rm -f "$tmp/$lkbase"
1666 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1667 patch -s "$tmp/$lkbase" < "$func_lookup_local_file_result" >&2 \
1668 || func_fatal_error "patch file $func_lookup_local_file_result didn't apply cleanly"
1669 lookedup_file="$tmp/$lkbase"
1670 lookedup_tmp=true
1671 else
1672 lookedup_file="$gnulib_dir/$lkfile"
1673 lookedup_tmp=
1675 else
1676 func_fatal_error "file $gnulib_dir/$lkfile not found"
1681 # func_sanitize_modulelist
1682 # receives a list of possible module names on standard input, one per line.
1683 # It removes those which are just file names unrelated to modules, and outputs
1684 # the resulting list to standard output, one per line.
1685 func_sanitize_modulelist ()
1687 sed -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1688 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1689 -e '/^README$/d' -e '/\/README$/d' \
1690 -e '/^TEMPLATE$/d' \
1691 -e '/^TEMPLATE-EXTENDED$/d' \
1692 -e '/^TEMPLATE-TESTS$/d' \
1693 -e '/^\..*/d' \
1694 -e '/~$/d'
1698 # func_modules_in_dir dir
1699 # outputs all module files in dir to standard output.
1700 func_modules_in_dir ()
1702 (test -d "$1" && cd "$1" && find modules -type f -print)
1705 # func_all_modules
1706 # Input:
1707 # - local_gnulib_path from --local-dir
1708 func_all_modules ()
1710 # Filter out metainformation files like README, which are not modules.
1711 # Filter out unit test modules; they can be retrieved through
1712 # --extract-tests-module if desired.
1714 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1715 func_path_foreach "$local_gnulib_path" func_modules_in_dir %dir% | sed -e 's,^modules/,,' -e 's,\.diff$,,'
1717 | func_sanitize_modulelist \
1718 | sed -e '/-tests$/d' \
1719 | LC_ALL=C sort -u
1722 # func_exists_local_module dir module
1723 # returns true if module exists in dir
1724 func_exists_local_module ()
1726 test -d "$1/modules" && test -f "$1/modules/$2";
1729 # func_exists_module module
1730 # tests whether a module, given by name, exists
1731 # Input:
1732 # - local_gnulib_path from --local-dir
1733 func_exists_module ()
1735 { test -f "$gnulib_dir/modules/$1" \
1736 || func_path_foreach "$local_gnulib_path" func_exists_local_module %dir% "$1" ; } \
1737 && test "ChangeLog" != "$1" \
1738 && test "COPYING" != "$1" \
1739 && test "README" != "$1" \
1740 && test "TEMPLATE" != "$1" \
1741 && test "TEMPLATE-EXTENDED" != "$1" \
1742 && test "TEMPLATE-TESTS" != "$1"
1745 # func_verify_module
1746 # verifies a module name
1747 # Input:
1748 # - local_gnulib_path from --local-dir
1749 # - module module name argument
1750 func_verify_module ()
1752 if func_exists_module "$module"; then
1753 # OK, $module is a correct module name.
1754 # Verify that building the module description with 'patch' succeeds.
1755 func_lookup_file "modules/$module"
1756 else
1757 func_warning "module $module doesn't exist"
1758 module=
1762 # func_verify_nontests_module
1763 # verifies a module name, excluding tests modules
1764 # Input:
1765 # - local_gnulib_path from --local-dir
1766 # - module module name argument
1767 func_verify_nontests_module ()
1769 case "$module" in
1770 *-tests ) module= ;;
1771 * ) func_verify_module ;;
1772 esac
1775 # func_verify_tests_module
1776 # verifies a module name, considering only tests modules
1777 # Input:
1778 # - local_gnulib_path from --local-dir
1779 # - module module name argument
1780 func_verify_tests_module ()
1782 case "$module" in
1783 *-tests ) func_verify_module ;;
1784 * ) module= ;;
1785 esac
1788 # Suffix of a sed expression that extracts a particular field from a
1789 # module description.
1790 # A field starts with a line that contains a keyword, such as 'Description',
1791 # followed by a colon and optional whitespace. All following lines, up to
1792 # the next field (or end of file if there is none) form the contents of the
1793 # field.
1794 # An absent field is equivalent to a field with empty contents.
1795 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1796 sed_extract_prog=':[ ]*$/ {
1799 s/^Description:[ ]*$//
1800 s/^Comment:[ ]*$//
1801 s/^Status:[ ]*$//
1802 s/^Notice:[ ]*$//
1803 s/^Applicability:[ ]*$//
1804 s/^Files:[ ]*$//
1805 s/^Depends-on:[ ]*$//
1806 s/^configure\.ac-early:[ ]*$//
1807 s/^configure\.ac:[ ]*$//
1808 s/^Makefile\.am:[ ]*$//
1809 s/^Include:[ ]*$//
1810 s/^Link:[ ]*$//
1811 s/^License:[ ]*$//
1812 s/^Maintainer:[ ]*$//
1819 # Piece of a sed expression that converts a field header line to a shell
1820 # variable name,
1821 # NOTE: Keep this in sync with sed_extract_prog above!
1822 sed_extract_field_header='
1823 s/^Description:[ ]*$/description/
1824 s/^Comment:[ ]*$/comment/
1825 s/^Status:[ ]*$/status/
1826 s/^Notice:[ ]*$/notice/
1827 s/^Applicability:[ ]*$/applicability/
1828 s/^Files:[ ]*$/files/
1829 s/^Depends-on:[ ]*$/dependson/
1830 s/^configure\.ac-early:[ ]*$/configureac_early/
1831 s/^configure\.ac:[ ]*$/configureac/
1832 s/^Makefile\.am:[ ]*$/makefile/
1833 s/^Include:[ ]*$/include/
1834 s/^Link:[ ]*$/link/
1835 s/^License:[ ]*$/license/
1836 s/^Maintainer:[ ]*$/maintainer/'
1838 if $modcache; then
1840 if $have_associative; then
1842 # Declare the associative arrays.
1843 declare -A modcache_cached
1844 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1845 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1846 eval "$declare_script"
1848 else
1850 # func_cache_var module
1851 # computes the cache variable name corresponding to $module.
1852 # Note: This computation can map different module names to the same
1853 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1854 # to protect against this case.
1855 # Output:
1856 # - cachevar a shell variable name
1857 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1858 # Bash 2.0 and newer, ksh, and zsh support the syntax
1859 # ${param//pattern/replacement}
1860 # as a shorthand for
1861 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1862 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1863 eval 'func_cache_var ()
1865 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1867 else
1868 func_cache_var ()
1870 case $1 in
1871 *[!a-zA-Z0-9_]*)
1872 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1874 cachevar=c_$1 ;;
1875 esac
1881 # func_init_sed_convert_to_cache_statements
1882 # Input:
1883 # - modcachevar_assignment
1884 # Output:
1885 # - sed_convert_to_cache_statements
1886 func_init_sed_convert_to_cache_statements ()
1888 # 'sed' script that turns a module description into shell script
1889 # assignments, suitable to be eval'ed. All active characters are escaped.
1890 # This script turns
1891 # Description:
1892 # Some module's description
1894 # Files:
1895 # lib/file.h
1896 # into:
1897 # modcache_description[$1]=\
1898 # 'Some module'"'"'s description
1900 # modcache_files[$1]=\
1901 # 'lib/file.h'
1902 # or:
1903 # c_MODULE_description_set=set; c_MODULE_description=\
1904 # 'Some module'"'"'s description
1906 # c_MODULE_files_set=set; c_MODULE_files=\
1907 # 'lib/file.h'
1908 # The script consists of two parts:
1909 # 1) Ignore the lines before the first field header.
1910 # 2) A loop, treating non-field-header lines by escaping single quotes
1911 # and adding a closing quote in the last line,
1912 sed_convert_to_cache_statements="
1913 :llla
1914 # Here we have not yet seen a field header.
1916 # See if the current line contains a field header.
1917 t llla1
1918 :llla1
1919 ${sed_extract_field_header}
1920 t lllb
1922 # No field header. Ignore the line.
1924 # Read the next line. Upon EOF, just exit.
1926 b llla
1928 :lllb
1929 # The current line contains a field header.
1931 # Turn it into the beginning of an assignment.
1932 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1934 # Move it to the hold space. Don't print it yet,
1935 # because we want no assignment if the field is empty.
1938 # Read the next line.
1939 # Upon EOF, the field was empty. Print no assignment. Just exit.
1942 # See if the current line contains a field header.
1943 t lllb1
1944 :lllb1
1945 ${sed_extract_field_header}
1946 # If it is, the previous field was empty. Print no assignment.
1947 t lllb
1949 # Not a field header.
1951 # Print the previous line, held in the hold space.
1956 # Transform single quotes.
1957 s/'/'\"'\"'/g
1959 # Prepend a single quote.
1960 s/^/'/
1962 :lllc
1964 # Move it to the hold space.
1967 # Read the next line.
1968 # Upon EOF, branch.
1970 b llle
1974 # See if the current line contains a field header.
1975 t lllc1
1976 :lllc1
1977 ${sed_extract_field_header}
1978 t llld
1980 # Print the previous line, held in the hold space.
1985 # Transform single quotes.
1986 s/'/'\"'\"'/g
1988 b lllc
1990 :llld
1991 # A field header.
1992 # Print the previous line, held in the hold space, with a single quote
1993 # to end the assignment.
1995 s/\$/'/
1999 b lllb
2001 :llle
2002 # EOF seen.
2003 # Print the previous line, held in the hold space, with a single quote
2004 # to end the assignment.
2006 s/\$/'/
2008 # Exit.
2011 if ! $sed_comments; then
2012 # Remove comments.
2013 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
2014 | sed -e 's/^ *//' -e 's/^#.*//'`
2018 if $have_associative; then
2019 # sed_convert_to_cache_statements does not depend on the module.
2020 modcachevar_assignment='modcache_\1[$1]='
2021 func_init_sed_convert_to_cache_statements
2024 # func_cache_lookup_module module
2026 # looks up a module, like 'func_lookup_file modules/$module', and stores all
2027 # of its relevant data in a cache in the memory of the processing shell. If
2028 # already cached, it does not look it up again, thus saving file access time.
2029 # Parameters:
2030 # - module non-empty string
2031 # Output if $have_associative:
2032 # - modcache_cached[$module] set to yes
2033 # - modcache_description[$module] ==
2034 # - modcache_status[$module] \ set to the field's value, minus the
2035 # - ... / final newline,
2036 # - modcache_maintainer[$module] == or unset if the field's value is empty
2037 # Output if ! $have_associative:
2038 # - cachevar a shell variable name
2039 # - ${cachevar}_cached set to $module
2040 # - ${cachevar}_description ==
2041 # - ${cachevar}_status \ set to the field's value, minus the
2042 # - ... / final newline,
2043 # - ${cachevar}_maintainer == or unset if the field's value is empty
2044 # - ${cachevar}_description_set ==
2045 # - ${cachevar}_status_set \ set to non-empty if the field's value
2046 # - ... / is non-empty,
2047 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
2048 func_cache_lookup_module ()
2050 if $have_associative; then
2051 eval 'cached=${modcache_cached[$1]}'
2052 else
2053 func_cache_var "$1"
2054 eval "cached=\"\$${cachevar}_cached\""
2056 if test -z "$cached"; then
2057 # Not found in cache. Look it up on the file system.
2058 func_lookup_file "modules/$1"
2059 if $have_associative; then
2060 eval 'modcache_cached[$1]=yes'
2061 else
2062 eval "${cachevar}_cached=\"\$1\""
2064 if ! $have_associative; then
2065 # sed_convert_to_cache_statements depends on the module.
2066 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
2067 func_init_sed_convert_to_cache_statements
2069 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
2070 eval "$cache_statements"
2071 else
2072 if ! $have_associative; then
2073 if test "$1" != "$cached"; then
2074 func_fatal_error "cache variable collision between $1 and $cached"
2082 # func_get_description module
2083 # Input:
2084 # - local_gnulib_path from --local-dir
2085 # - modcache true or false, from --cache-modules/--no-cache-modules
2086 func_get_description ()
2088 if ! $modcache; then
2089 func_lookup_file "modules/$1"
2090 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
2091 else
2092 func_cache_lookup_module "$1"
2093 # Output the field's value, including the final newline (if any).
2094 if $have_associative; then
2095 if eval 'test -n "${modcache_description[$1]+set}"'; then
2096 eval 'echo "${modcache_description[$1]}"'
2098 else
2099 eval "field_set=\"\$${cachevar}_description_set\""
2100 if test -n "$field_set"; then
2101 eval "field_value=\"\$${cachevar}_description\""
2102 echo "${field_value}"
2108 # func_get_comment module
2109 # Input:
2110 # - local_gnulib_path from --local-dir
2111 # - modcache true or false, from --cache-modules/--no-cache-modules
2112 func_get_comment ()
2114 if ! $modcache; then
2115 func_lookup_file "modules/$1"
2116 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
2117 else
2118 func_cache_lookup_module "$1"
2119 # Output the field's value, including the final newline (if any).
2120 if $have_associative; then
2121 if eval 'test -n "${modcache_comment[$1]+set}"'; then
2122 eval 'echo "${modcache_comment[$1]}"'
2124 else
2125 eval "field_set=\"\$${cachevar}_comment_set\""
2126 if test -n "$field_set"; then
2127 eval "field_value=\"\$${cachevar}_comment\""
2128 echo "${field_value}"
2134 # func_get_status module
2135 # Input:
2136 # - local_gnulib_path from --local-dir
2137 # - modcache true or false, from --cache-modules/--no-cache-modules
2138 func_get_status ()
2140 if ! $modcache; then
2141 func_lookup_file "modules/$1"
2142 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
2143 else
2144 func_cache_lookup_module "$1"
2145 # Output the field's value, including the final newline (if any).
2146 if $have_associative; then
2147 if eval 'test -n "${modcache_status[$1]+set}"'; then
2148 eval 'echo "${modcache_status[$1]}"'
2150 else
2151 eval "field_set=\"\$${cachevar}_status_set\""
2152 if test -n "$field_set"; then
2153 eval "field_value=\"\$${cachevar}_status\""
2154 echo "${field_value}"
2160 # func_get_notice module
2161 # Input:
2162 # - local_gnulib_path from --local-dir
2163 # - modcache true or false, from --cache-modules/--no-cache-modules
2164 func_get_notice ()
2166 if ! $modcache; then
2167 func_lookup_file "modules/$1"
2168 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
2169 else
2170 func_cache_lookup_module "$1"
2171 # Output the field's value, including the final newline (if any).
2172 if $have_associative; then
2173 if eval 'test -n "${modcache_notice[$1]+set}"'; then
2174 eval 'echo "${modcache_notice[$1]}"'
2176 else
2177 eval "field_set=\"\$${cachevar}_notice_set\""
2178 if test -n "$field_set"; then
2179 eval "field_value=\"\$${cachevar}_notice\""
2180 echo "${field_value}"
2186 # func_get_applicability module
2187 # Input:
2188 # - local_gnulib_path from --local-dir
2189 # - modcache true or false, from --cache-modules/--no-cache-modules
2190 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
2191 func_get_applicability ()
2193 if ! $modcache; then
2194 func_lookup_file "modules/$1"
2195 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
2196 else
2197 func_cache_lookup_module "$1"
2198 # Get the field's value, without the final newline.
2199 if $have_associative; then
2200 eval 'my_applicability="${modcache_applicability[$1]}"'
2201 else
2202 eval "my_applicability=\"\$${cachevar}_applicability\""
2205 if test -n "$my_applicability"; then
2206 echo $my_applicability
2207 else
2208 # The default is 'main' or 'tests', depending on the module's name.
2209 case $1 in
2210 *-tests) echo "tests";;
2211 *) echo "main";;
2212 esac
2216 # func_get_filelist module
2217 # Input:
2218 # - local_gnulib_path from --local-dir
2219 # - modcache true or false, from --cache-modules/--no-cache-modules
2220 func_get_filelist ()
2222 if ! $modcache; then
2223 func_lookup_file "modules/$1"
2224 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
2225 else
2226 func_cache_lookup_module "$1"
2227 # Output the field's value, including the final newline (if any).
2228 if $have_associative; then
2229 if eval 'test -n "${modcache_files[$1]+set}"'; then
2230 eval 'echo "${modcache_files[$1]}"'
2232 else
2233 eval "field_set=\"\$${cachevar}_files_set\""
2234 if test -n "$field_set"; then
2235 eval "field_value=\"\$${cachevar}_files\""
2236 echo "${field_value}"
2240 echo m4/00gnulib.m4
2241 echo m4/gnulib-common.m4
2242 case "$autoconf_minversion" in
2243 2.59)
2244 echo m4/onceonly.m4
2246 esac
2249 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2250 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2251 # elements starting with prefix and ending with suffix are considered.
2252 # Processing: removed_prefix and removed_suffix are removed from each element,
2253 # added_prefix and added_suffix are added to each element.
2254 # prefix, suffix should not contain shell-special characters.
2255 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2256 # added_prefix, added_suffix should not contain the characters \|&.
2257 func_filter_filelist ()
2259 if test "$2" != "$nl" \
2260 || { $fast_func_append \
2261 && { test -z "$6" || $fast_func_remove_prefix; } \
2262 && { test -z "$7" || $fast_func_remove_suffix; }; \
2263 }; then
2264 ffflist=
2265 for fff in $3; do
2266 # Do not quote possibly-empty parameters in case patterns,
2267 # AIX and HP-UX ksh won't match them if they are empty.
2268 case "$fff" in
2269 $4*$5)
2270 if test -n "$6"; then
2271 func_remove_prefix fff "$6"
2273 if test -n "$7"; then
2274 func_remove_suffix fff "$7"
2276 fff="$8${fff}$9"
2277 if test -z "$ffflist"; then
2278 ffflist="${fff}"
2279 else
2280 func_append ffflist "$2${fff}"
2283 esac
2284 done
2285 else
2286 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2287 ffflist=`for fff in $3; do
2288 case "$fff" in
2289 $4*$5) echo "$fff" ;;
2290 esac
2291 done | sed -e "$sed_fff_filter"`
2293 eval "$1=\"\$ffflist\""
2296 # func_get_dependencies module
2297 # Input:
2298 # - local_gnulib_path from --local-dir
2299 # - modcache true or false, from --cache-modules/--no-cache-modules
2300 func_get_dependencies ()
2302 # ${module}-tests implicitly depends on ${module}, if that module exists.
2303 case "$1" in
2304 *-tests)
2305 fgd1="$1"
2306 func_remove_suffix fgd1 '-tests'
2307 if func_exists_module "$fgd1"; then
2308 echo "$fgd1"
2311 esac
2312 # Then the explicit dependencies listed in the module description.
2313 { if ! $modcache; then
2314 func_lookup_file "modules/$1"
2315 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2316 else
2317 func_cache_lookup_module "$1"
2318 # Output the field's value, including the final newline (if any).
2319 if $have_associative; then
2320 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2321 eval 'echo "${modcache_dependson[$1]}"'
2323 else
2324 eval "field_set=\"\$${cachevar}_dependson_set\""
2325 if test -n "$field_set"; then
2326 eval "field_value=\"\$${cachevar}_dependson\""
2327 echo "${field_value}"
2332 | sed -e '/^#/d'
2335 # func_get_autoconf_early_snippet module
2336 # Input:
2337 # - local_gnulib_path from --local-dir
2338 # - modcache true or false, from --cache-modules/--no-cache-modules
2339 func_get_autoconf_early_snippet ()
2341 if ! $modcache; then
2342 func_lookup_file "modules/$1"
2343 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2344 else
2345 func_cache_lookup_module "$1"
2346 # Output the field's value, including the final newline (if any).
2347 if $have_associative; then
2348 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2349 eval 'echo "${modcache_configureac_early[$1]}"'
2351 else
2352 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2353 if test -n "$field_set"; then
2354 eval "field_value=\"\$${cachevar}_configureac_early\""
2355 echo "${field_value}"
2361 # func_get_autoconf_snippet module
2362 # Input:
2363 # - local_gnulib_path from --local-dir
2364 # - modcache true or false, from --cache-modules/--no-cache-modules
2365 func_get_autoconf_snippet ()
2367 if ! $modcache; then
2368 func_lookup_file "modules/$1"
2369 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2370 else
2371 func_cache_lookup_module "$1"
2372 # Output the field's value, including the final newline (if any).
2373 if $have_associative; then
2374 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2375 eval 'echo "${modcache_configureac[$1]}"'
2377 else
2378 eval "field_set=\"\$${cachevar}_configureac_set\""
2379 if test -n "$field_set"; then
2380 eval "field_value=\"\$${cachevar}_configureac\""
2381 echo "${field_value}"
2387 # Concatenate lines with trailing slash.
2388 # $1 is an optional filter to restrict the
2389 # concatenation to groups starting with that expression
2390 combine_lines() {
2391 sed -e "/$1.*"'\\$/{
2394 s/\\\n/ /
2395 s/\\$/\\/
2400 # func_get_automake_snippet_conditional module
2401 # returns the part of the Makefile.am snippet that can be put inside Automake
2402 # conditionals.
2403 # Input:
2404 # - local_gnulib_path from --local-dir
2405 # - modcache true or false, from --cache-modules/--no-cache-modules
2406 func_get_automake_snippet_conditional ()
2408 if ! $modcache; then
2409 func_lookup_file "modules/$1"
2410 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2411 else
2412 func_cache_lookup_module "$1"
2413 # Output the field's value, including the final newline (if any).
2414 if $have_associative; then
2415 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2416 eval 'echo "${modcache_makefile[$1]}"'
2418 else
2419 eval "field_set=\"\$${cachevar}_makefile_set\""
2420 if test -n "$field_set"; then
2421 eval "field_value=\"\$${cachevar}_makefile\""
2422 echo "${field_value}"
2428 # func_get_automake_snippet_unconditional module
2429 # returns the part of the Makefile.am snippet that must stay outside of
2430 # Automake conditionals.
2431 # Input:
2432 # - local_gnulib_path from --local-dir
2433 # - modcache true or false, from --cache-modules/--no-cache-modules
2434 func_get_automake_snippet_unconditional ()
2436 case "$1" in
2437 *-tests)
2438 # *-tests module live in tests/, not lib/.
2439 # Synthesize an EXTRA_DIST augmentation.
2440 all_files=`func_get_filelist $1`
2441 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2442 extra_files="$tests_files"
2443 if test -n "$extra_files"; then
2444 echo "EXTRA_DIST +=" $extra_files
2445 echo
2449 # Synthesize an EXTRA_DIST augmentation.
2450 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2451 already_mentioned_files=` \
2452 { if ! $modcache; then
2453 func_lookup_file "modules/$1"
2454 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2455 else
2456 func_cache_lookup_module "$1"
2457 if $have_associative; then
2458 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2459 eval 'echo "${modcache_makefile[$1]}"'
2461 else
2462 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2463 if test -n "$field_set"; then
2464 eval 'field_value="$'"${cachevar}"'_makefile"'
2465 echo "${field_value}"
2470 | combine_lines \
2471 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2472 all_files=`func_get_filelist $1`
2473 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2474 # Remove $already_mentioned_files from $lib_files.
2475 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2476 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2477 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2478 if test -n "$extra_files"; then
2479 echo "EXTRA_DIST +=" $extra_files
2480 echo
2482 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2483 # This is necessary so that automake can generate the right list of
2484 # dependency rules.
2485 # A possible approach would be to use autom4te --trace of the redefined
2486 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2487 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2488 # inside autoconf's built-in macros are not missed).
2489 # But it's simpler and more robust to do it here, based on the file list.
2490 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2491 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2492 # automake will generate a useless dependency; this is harmless.
2493 case "$1" in
2494 relocatable-prog-wrapper) ;;
2495 pt_chown) ;;
2497 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2498 if test -n "$extra_files"; then
2499 echo "EXTRA_lib_SOURCES +=" $extra_files
2500 echo
2503 esac
2504 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2505 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2506 if test -n "$buildaux_files"; then
2507 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2508 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2509 echo
2512 esac
2515 # func_get_automake_snippet module
2516 # Input:
2517 # - local_gnulib_path from --local-dir
2518 # - modcache true or false, from --cache-modules/--no-cache-modules
2519 func_get_automake_snippet ()
2521 func_get_automake_snippet_conditional "$1"
2522 func_get_automake_snippet_unconditional "$1"
2525 # func_get_include_directive module
2526 # Input:
2527 # - local_gnulib_path from --local-dir
2528 # - modcache true or false, from --cache-modules/--no-cache-modules
2529 func_get_include_directive ()
2532 if ! $modcache; then
2533 func_lookup_file "modules/$1"
2534 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2535 else
2536 func_cache_lookup_module "$1"
2537 # Output the field's value, including the final newline (if any).
2538 if $have_associative; then
2539 if eval 'test -n "${modcache_include[$1]+set}"'; then
2540 eval 'echo "${modcache_include[$1]}"'
2542 else
2543 eval "field_set=\"\$${cachevar}_include_set\""
2544 if test -n "$field_set"; then
2545 eval "field_value=\"\$${cachevar}_include\""
2546 echo "${field_value}"
2550 } | sed -e 's/^\(["<]\)/#include \1/'
2553 # func_get_link_directive module
2554 # Input:
2555 # - local_gnulib_path from --local-dir
2556 # - modcache true or false, from --cache-modules/--no-cache-modules
2557 func_get_link_directive ()
2559 if ! $modcache; then
2560 func_lookup_file "modules/$1"
2561 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2562 else
2563 func_cache_lookup_module "$1"
2564 # Output the field's value, including the final newline (if any).
2565 if $have_associative; then
2566 if eval 'test -n "${modcache_link[$1]+set}"'; then
2567 eval 'echo "${modcache_link[$1]}"'
2569 else
2570 eval "field_set=\"\$${cachevar}_link_set\""
2571 if test -n "$field_set"; then
2572 eval "field_value=\"\$${cachevar}_link\""
2573 echo "${field_value}"
2579 # func_get_license_raw module
2580 # Input:
2581 # - local_gnulib_path from --local-dir
2582 # - modcache true or false, from --cache-modules/--no-cache-modules
2583 func_get_license_raw ()
2585 if ! $modcache; then
2586 func_lookup_file "modules/$1"
2587 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2588 else
2589 func_cache_lookup_module "$1"
2590 # Output the field's value, including the final newline (if any).
2591 if $have_associative; then
2592 if eval 'test -n "${modcache_license[$1]+set}"'; then
2593 eval 'echo "${modcache_license[$1]}"'
2595 else
2596 eval "field_set=\"\$${cachevar}_license_set\""
2597 if test -n "$field_set"; then
2598 eval "field_value=\"\$${cachevar}_license\""
2599 echo "${field_value}"
2605 # func_get_license module
2606 # Input:
2607 # - local_gnulib_path from --local-dir
2608 # - modcache true or false, from --cache-modules/--no-cache-modules
2609 func_get_license ()
2611 # Warn if the License field is missing.
2612 case "$1" in
2613 *-tests ) ;;
2615 license=`func_get_license_raw "$1"`
2616 if test -z "$license"; then
2617 func_warning "module $1 lacks a License"
2620 esac
2621 case "$1" in
2622 parse-datetime )
2623 # These modules are under a weaker license only for the purpose of some
2624 # users who hand-edit it and don't use gnulib-tool. For the regular
2625 # gnulib users they are under a stricter license.
2626 echo "GPL"
2630 func_get_license_raw "$1"
2631 # The default is GPL.
2632 echo "GPL"
2633 } | sed -e 's,^ *$,,' | sed -e 1q
2635 esac
2638 # func_get_maintainer module
2639 # Input:
2640 # - local_gnulib_path from --local-dir
2641 # - modcache true or false, from --cache-modules/--no-cache-modules
2642 func_get_maintainer ()
2644 if ! $modcache; then
2645 func_lookup_file "modules/$1"
2646 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2647 else
2648 func_cache_lookup_module "$1"
2649 # Output the field's value, including the final newline (if any).
2650 if $have_associative; then
2651 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2652 eval 'echo "${modcache_maintainer[$1]}"'
2654 else
2655 eval "field_set=\"\$${cachevar}_maintainer_set\""
2656 if test -n "$field_set"; then
2657 eval "field_value=\"\$${cachevar}_maintainer\""
2658 echo "${field_value}"
2664 # func_get_tests_module module
2665 # Input:
2666 # - local_gnulib_path from --local-dir
2667 func_get_tests_module ()
2669 # The naming convention for tests modules is hardwired: ${module}-tests.
2670 if test -f "$gnulib_dir/modules/$1"-tests \
2671 || func_path_foreach "$local_gnulib_path" func_exists_local_module %dir% "$1-tests"; then
2672 echo "$1"-tests
2676 # func_acceptable module
2677 # tests whether a module is acceptable.
2678 # Input:
2679 # - avoidlist list of modules to avoid
2680 func_acceptable ()
2682 for avoid in $avoidlist; do
2683 if test "$avoid" = "$1"; then
2684 return 1
2686 done
2687 return 0
2690 # sed expression to keep the first 32 characters of each line.
2691 sed_first_32_chars='s/^\(................................\).*/\1/'
2693 # func_module_shellfunc_name module
2694 # computes the shell function name that will contain the m4 macros for the module.
2695 # Input:
2696 # - macro_prefix prefix to use
2697 # Output:
2698 # - shellfunc shell function name
2699 func_module_shellfunc_name ()
2701 case $1 in
2702 *[!a-zA-Z0-9_]*)
2703 shellfunc=func_${macro_prefix}_gnulib_m4code_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2705 shellfunc=func_${macro_prefix}_gnulib_m4code_$1 ;;
2706 esac
2709 # func_module_shellvar_name module
2710 # computes the shell variable name the will be set to true once the m4 macros
2711 # for the module have been executed.
2712 # Output:
2713 # - shellvar shell variable name
2714 func_module_shellvar_name ()
2716 case $1 in
2717 *[!a-zA-Z0-9_]*)
2718 shellvar=${macro_prefix}_gnulib_enabled_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2720 shellvar=${macro_prefix}_gnulib_enabled_$1 ;;
2721 esac
2724 # func_module_conditional_name module
2725 # computes the automake conditional name for the module.
2726 # Output:
2727 # - conditional name of automake conditional
2728 func_module_conditional_name ()
2730 case $1 in
2731 *[!a-zA-Z0-9_]*)
2732 conditional=${macro_prefix}_GNULIB_ENABLED_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2734 conditional=${macro_prefix}_GNULIB_ENABLED_$1 ;;
2735 esac
2738 # func_uncond_add_module B
2739 # notes the presence of B as an unconditional module.
2741 # func_conddep_add_module A B cond
2742 # notes the presence of a conditional dependency from module A to module B,
2743 # subject to the condition that A is enabled and cond is true.
2745 # func_cond_module_p B
2746 # tests whether module B is conditional.
2748 # func_cond_module_condition A B
2749 # returns the condition when B should be enabled as a dependency of A, once the
2750 # m4 code for A has been executed.
2751 # Output: - condition
2753 if $have_associative; then
2754 declare -A conddep_isuncond
2755 declare -A conddep_dependers
2756 declare -A conddep_condition
2757 func_uncond_add_module ()
2759 eval 'conddep_isuncond[$1]=true'
2760 eval 'unset conddep_dependers[$1]'
2762 func_conddep_add_module ()
2764 eval 'isuncond="${conddep_isuncond[$2]}"'
2765 if test -z "$isuncond"; then
2766 # No unconditional dependency to B known at this point.
2767 eval 'conddep_dependers[$2]="${conddep_dependers[$2]} $1"'
2768 eval 'conddep_condition[$1---$2]="$3"'
2771 func_cond_module_p ()
2773 eval 'previous_dependers="${conddep_dependers[$1]}"'
2774 test -n "$previous_dependers"
2776 func_cond_module_condition ()
2778 eval 'condition="${conddep_condition[$1---$2]}"'
2780 else
2781 func_uncond_add_module ()
2783 case $1 in
2784 *[!a-zA-Z0-9_]*)
2785 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2787 suffix=$1 ;;
2788 esac
2789 eval 'conddep_isuncond_'"$suffix"'=true'
2790 eval 'unset conddep_dependers_'"$suffix"
2792 func_conddep_add_module ()
2794 case $2 in
2795 *[!a-zA-Z0-9_]*)
2796 suffix=`echo "$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2798 suffix=$2 ;;
2799 esac
2800 eval 'isuncond="${conddep_isuncond_'"$suffix"'}"'
2801 if test -z "$isuncond"; then
2802 eval 'conddep_dependers_'"$suffix"'="${conddep_dependers_'"$suffix"'} $1"'
2803 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2804 eval 'conddep_condition_'"$suffix"'="$3"'
2807 func_cond_module_p ()
2809 case $1 in
2810 *[!a-zA-Z0-9_]*)
2811 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2813 suffix=$1 ;;
2814 esac
2815 eval 'previous_dependers="${conddep_dependers_'"$suffix"'}"'
2816 test -n "$previous_dependers"
2818 func_cond_module_condition ()
2820 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2821 eval 'condition="${conddep_condition_'"$suffix"'}"'
2825 sed_dependencies_without_conditions='s/ *\[.*//'
2827 # func_modules_transitive_closure
2828 # Input:
2829 # - local_gnulib_path from --local-dir
2830 # - gnu_make true if --gnu-make was given, false otherwise
2831 # - modcache true or false, from --cache-modules/--no-cache-modules
2832 # - modules list of specified modules
2833 # - inctests true if tests should be included, false otherwise
2834 # - incobsolete true if obsolete modules among dependencies should be
2835 # included, blank otherwise
2836 # - inc_cxx_tests true if C++ interoperability tests should be included,
2837 # blank otherwise
2838 # - inc_longrunning_tests true if long-runnings tests should be included,
2839 # blank otherwise
2840 # - inc_privileged_tests true if tests that require root privileges should be
2841 # included, blank otherwise
2842 # - inc_unportable_tests true if tests that fail on some platforms should be
2843 # included, blank otherwise
2844 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2845 # the unit tests of the specified modules should be
2846 # included, blank otherwise
2847 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2848 # the unit tests of the dependencies should be
2849 # included, blank otherwise
2850 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2851 # blank otherwise
2852 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2853 # blank otherwise
2854 # - excl_privileged_tests true if tests that require root privileges should be
2855 # excluded, blank otherwise
2856 # - excl_unportable_tests true if tests that fail on some platforms should be
2857 # excluded, blank otherwise
2858 # - avoidlist list of modules to avoid
2859 # - cond_dependencies true if conditional dependencies shall be supported,
2860 # blank otherwise
2861 # - tmp pathname of a temporary directory
2862 # Output:
2863 # - modules list of modules, including dependencies
2864 # - conddep_dependers, conddep_condition information about conditionally
2865 # enabled modules
2866 func_modules_transitive_closure ()
2868 sed_escape_dependency='s|\([/.]\)|\\\1|g'
2869 # In order to process every module only once (for speed), process an "input
2870 # list" of modules, producing an "output list" of modules. During each round,
2871 # more modules can be queued in the input list. Once a module on the input
2872 # list has been processed, it is added to the "handled list", so we can avoid
2873 # to process it again.
2874 handledmodules=
2875 inmodules="$modules"
2876 outmodules=
2877 fmtc_inc_all_tests="$inc_all_direct_tests"
2878 if test "$cond_dependencies" = true; then
2879 for module in $inmodules; do
2880 func_verify_module
2881 if test -n "$module"; then
2882 if func_acceptable $module; then
2883 func_uncond_add_module $module
2886 done
2888 while test -n "$inmodules"; do
2889 inmodules_this_round="$inmodules"
2890 inmodules= # Accumulator, queue for next round
2891 for module in $inmodules_this_round; do
2892 func_verify_module
2893 if test -n "$module"; then
2894 if func_acceptable $module; then
2895 func_append outmodules " $module"
2896 if test "$cond_dependencies" = true; then
2897 if ! $gnu_make \
2898 && func_get_automake_snippet_conditional $module \
2899 | grep '^if ' > /dev/null; then
2900 # A module whose Makefile.am snippet contains a reference to an
2901 # automake conditional. If we were to use it conditionally, we
2902 # would get an error
2903 # configure: error: conditional "..." was never defined.
2904 # because automake 1.11.1 does not handle nested conditionals
2905 # correctly. As a workaround, make the module unconditional.
2906 func_uncond_add_module $module
2908 if func_cond_module_p $module; then
2909 conditional=true
2910 else
2911 conditional=false
2914 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2915 # Duplicate dependencies are harmless, but Jim wants a warning.
2916 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2917 if test -n "$duplicated_deps"; then
2918 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2920 if $inctests; then
2921 testsmodule=`func_get_tests_module $module`
2922 if test -n "$testsmodule"; then
2923 deps="$deps $testsmodule"
2926 for dep in $deps; do
2927 # Determine whether to include the dependency or tests module.
2928 inc=true
2929 for word in `func_get_status $dep`; do
2930 case "$word" in
2931 obsolete)
2932 test -n "$incobsolete" \
2933 || inc=false
2935 c++-test)
2936 test -z "$excl_cxx_tests" \
2937 || inc=false
2938 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2939 || inc=false
2941 longrunning-test)
2942 test -z "$excl_longrunning_tests" \
2943 || inc=false
2944 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2945 || inc=false
2947 privileged-test)
2948 test -z "$excl_privileged_tests" \
2949 || inc=false
2950 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2951 || inc=false
2953 unportable-test)
2954 test -z "$excl_unportable_tests" \
2955 || inc=false
2956 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2957 || inc=false
2959 *-test)
2960 test -n "$fmtc_inc_all_tests" \
2961 || inc=false
2963 esac
2964 done
2965 if $inc && func_acceptable "$dep"; then
2966 func_append inmodules " $dep"
2967 if test "$cond_dependencies" = true; then
2968 escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
2969 sed_extract_condition1='/^ *'"$escaped_dep"' *$/{
2970 s/^.*$/true/p
2972 sed_extract_condition2='/^ *'"$escaped_dep"' *\[.*\] *$/{
2973 s/^ *'"$escaped_dep"' *\[\(.*\)\] *$/\1/p
2975 condition=`func_get_dependencies $module | sed -n -e "$sed_extract_condition1" -e "$sed_extract_condition2"`
2976 if test "$condition" = true; then
2977 condition=
2979 if test -n "$condition"; then
2980 func_conddep_add_module "$module" "$dep" "$condition"
2981 else
2982 if $conditional; then
2983 func_conddep_add_module "$module" "$dep" true
2984 else
2985 func_uncond_add_module "$dep"
2990 done
2993 done
2994 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2995 # Remove $handledmodules from $inmodules.
2996 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2997 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2998 fmtc_inc_all_tests="$inc_all_indirect_tests"
2999 done
3000 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
3001 rm -f "$tmp"/queued-modules
3004 # func_show_module_list
3005 # Input:
3006 # - specified_modules list of specified modules (one per line, sorted)
3007 # - modules complete list of modules (one per line, sorted)
3008 # - tmp pathname of a temporary directory
3009 func_show_module_list ()
3011 if case "$TERM" in
3012 xterm*) test -t 1;;
3013 *) false;;
3014 esac; then
3015 # Assume xterm compatible escape sequences.
3016 bold_on=`printf '\033[1m'`
3017 bold_off=`printf '\033[0m'`
3018 else
3019 bold_on=
3020 bold_off=
3022 echo "Module list with included dependencies (indented):"
3023 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
3024 echo "$modules" | sed -e '/^$/d' \
3025 | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
3026 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
3029 # func_modules_transitive_closure_separately
3030 # Determine main module list and tests-related module list separately.
3031 # The main module list is the transitive closure of the specified modules,
3032 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3033 # is specified, it will consist only of LGPLed source.
3034 # The tests-related module list is the transitive closure of the specified
3035 # modules, including tests modules, minus the main module list excluding
3036 # modules of applicability 'all'. Its lib/* sources (brought in through
3037 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3038 # source, even if --lgpl is specified.
3039 # Input:
3040 # - local_gnulib_path from --local-dir
3041 # - modcache true or false, from --cache-modules/--no-cache-modules
3042 # - specified_modules list of specified modules
3043 # - inctests true if tests should be included, false otherwise
3044 # - incobsolete true if obsolete modules among dependencies should be
3045 # included, blank otherwise
3046 # - inc_cxx_tests true if C++ interoperability tests should be included,
3047 # blank otherwise
3048 # - inc_longrunning_tests true if long-runnings tests should be included,
3049 # blank otherwise
3050 # - inc_privileged_tests true if tests that require root privileges should be
3051 # included, blank otherwise
3052 # - inc_unportable_tests true if tests that fail on some platforms should be
3053 # included, blank otherwise
3054 # - inc_all_direct_tests true if all kinds of problematic unit tests among
3055 # the unit tests of the specified modules should be
3056 # included, blank otherwise
3057 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
3058 # the unit tests of the dependencies should be
3059 # included, blank otherwise
3060 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
3061 # blank otherwise
3062 # - excl_longrunning_tests true if long-runnings tests should be excluded,
3063 # blank otherwise
3064 # - excl_privileged_tests true if tests that require root privileges should be
3065 # excluded, blank otherwise
3066 # - excl_unportable_tests true if tests that fail on some platforms should be
3067 # excluded, blank otherwise
3068 # - avoidlist list of modules to avoid
3069 # - cond_dependencies true if conditional dependencies shall be supported,
3070 # blank otherwise
3071 # - tmp pathname of a temporary directory
3072 # Output:
3073 # - main_modules list of modules, including dependencies
3074 # - testsrelated_modules list of tests-related modules, including dependencies
3075 # - conddep_dependers, conddep_condition information about conditionally
3076 # enabled modules
3077 func_modules_transitive_closure_separately ()
3079 # Determine main module list.
3080 saved_inctests="$inctests"
3081 inctests=false
3082 modules="$specified_modules"
3083 func_modules_transitive_closure
3084 main_modules="$modules"
3085 inctests="$saved_inctests"
3086 if test $verbose -ge 1; then
3087 echo "Main module list:"
3088 echo "$main_modules" | sed -e 's/^/ /'
3090 # Determine tests-related module list.
3091 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3092 testsrelated_modules=`for module in $main_modules; do
3093 if test \`func_get_applicability $module\` = main; then
3094 echo $module
3096 done \
3097 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3098 # If testsrelated_modules consists only of modules with applicability 'all',
3099 # set it to empty (because such modules are only helper modules for other modules).
3100 have_nontrivial_testsrelated_modules=
3101 for module in $testsrelated_modules; do
3102 if test `func_get_applicability $module` != all; then
3103 have_nontrivial_testsrelated_modules=yes
3104 break
3106 done
3107 if test -z "$have_nontrivial_testsrelated_modules"; then
3108 testsrelated_modules=
3110 if test $verbose -ge 1; then
3111 echo "Tests-related module list:"
3112 echo "$testsrelated_modules" | sed -e 's/^/ /'
3116 # func_determine_use_libtests
3117 # Determines whether a $testsbase/libtests.a is needed.
3118 # Input:
3119 # - local_gnulib_path from --local-dir
3120 # - modcache true or false, from --cache-modules/--no-cache-modules
3121 # - testsrelated_modules list of tests-related modules, including dependencies
3122 # Output:
3123 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3124 func_determine_use_libtests ()
3126 use_libtests=false
3127 for module in $testsrelated_modules; do
3128 func_verify_nontests_module
3129 if test -n "$module"; then
3130 all_files=`func_get_filelist $module`
3131 # Test whether some file in $all_files lies in lib/.
3132 for f in $all_files; do
3133 case $f in
3134 lib/*)
3135 use_libtests=true
3136 break 2
3138 esac
3139 done
3141 done
3144 # func_modules_add_dummy
3145 # Input:
3146 # - local_gnulib_path from --local-dir
3147 # - modcache true or false, from --cache-modules/--no-cache-modules
3148 # - modules list of modules, including dependencies
3149 # Output:
3150 # - modules list of modules, including 'dummy' if needed
3151 func_modules_add_dummy ()
3153 # Determine whether any module provides a lib_SOURCES augmentation.
3154 have_lib_SOURCES=
3155 for module in $modules; do
3156 func_verify_nontests_module
3157 if test -n "$module"; then
3158 # Extract the value of "lib_SOURCES += ...".
3159 for file in `func_get_automake_snippet "$module" | combine_lines |
3160 sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
3161 # Ignore .h files since they are not compiled.
3162 case "$file" in
3163 *.h) ;;
3165 have_lib_SOURCES=yes
3166 break 2
3168 esac
3169 done
3171 done
3172 # Add the dummy module, to make sure the library will be non-empty.
3173 if test -z "$have_lib_SOURCES"; then
3174 if func_acceptable "dummy"; then
3175 func_append modules " dummy"
3180 # func_modules_add_dummy_separately
3181 # Input:
3182 # - local_gnulib_path from --local-dir
3183 # - modcache true or false, from --cache-modules/--no-cache-modules
3184 # - main_modules list of modules, including dependencies
3185 # - testsrelated_modules list of tests-related modules, including dependencies
3186 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3187 # Output:
3188 # - main_modules list of modules, including 'dummy' if needed
3189 # - testsrelated_modules list of tests-related modules, including 'dummy' if
3190 # needed
3191 func_modules_add_dummy_separately ()
3193 # Add the dummy module to the main module list if needed.
3194 modules="$main_modules"
3195 func_modules_add_dummy
3196 main_modules="$modules"
3198 # Add the dummy module to the tests-related module list if needed.
3199 if $use_libtests; then
3200 modules="$testsrelated_modules"
3201 func_modules_add_dummy
3202 testsrelated_modules="$modules"
3206 # func_modules_notice
3207 # Input:
3208 # - local_gnulib_path from --local-dir
3209 # - modcache true or false, from --cache-modules/--no-cache-modules
3210 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3211 # - modules list of modules, including dependencies
3212 func_modules_notice ()
3214 if test $verbose -ge -1; then
3215 for module in $modules; do
3216 func_verify_module
3217 if test -n "$module"; then
3218 msg=`func_get_notice $module`
3219 if test -n "$msg"; then
3220 echo "Notice from module $module:"
3221 echo "$msg" | sed -e 's/^/ /'
3224 done
3228 # func_modules_to_filelist
3229 # Input:
3230 # - local_gnulib_path from --local-dir
3231 # - modcache true or false, from --cache-modules/--no-cache-modules
3232 # - modules list of modules, including dependencies
3233 # Output:
3234 # - files list of files
3235 func_modules_to_filelist ()
3237 files=
3238 for module in $modules; do
3239 func_verify_module
3240 if test -n "$module"; then
3241 fs=`func_get_filelist $module`
3242 func_append files " $fs"
3244 done
3245 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
3248 # func_modules_to_filelist_separately
3249 # Determine the final file lists.
3250 # They must be computed separately, because files in lib/* go into
3251 # $sourcebase/ if they are in the main file list but into $testsbase/
3252 # if they are in the tests-related file list. Furthermore lib/dummy.c
3253 # can be in both.
3254 # Input:
3255 # - local_gnulib_path from --local-dir
3256 # - modcache true or false, from --cache-modules/--no-cache-modules
3257 # - main_modules list of modules, including dependencies
3258 # - testsrelated_modules list of tests-related modules, including dependencies
3259 func_modules_to_filelist_separately ()
3261 # Determine final main file list.
3262 modules="$main_modules"
3263 func_modules_to_filelist
3264 main_files="$files"
3265 # Determine final tests-related file list.
3266 modules="$testsrelated_modules"
3267 func_modules_to_filelist
3268 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3269 # Merge both file lists.
3270 sed_remove_empty_lines='/^$/d'
3271 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3272 if test $verbose -ge 0; then
3273 echo "File list:"
3274 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3275 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3279 # func_compute_include_guard_prefix
3280 # Determine include_guard_prefix.
3281 # Input:
3282 # - macro_prefix prefix of gl_LIBOBJS macros to use
3283 # Output:
3284 # - include_guard_prefix replacement for ${gl_include_guard_prefix}
3285 # - sed_replace_include_guard_prefix
3286 # sed expression for resolving ${gl_include_guard_prefix}
3287 func_compute_include_guard_prefix ()
3289 if test "$macro_prefix" = gl; then
3290 include_guard_prefix='GL'
3291 else
3292 include_guard_prefix='GL_'`echo "$macro_prefix" | LC_ALL=C tr '[a-z]' '[A-Z]'`
3294 sed_replace_include_guard_prefix='s/\${gl_include_guard_prefix}/'"${include_guard_prefix}"'/g'
3297 # func_execute_command command [args...]
3298 # Executes a command.
3299 # Uses also the variables
3300 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3301 func_execute_command ()
3303 if test $verbose -ge 0; then
3304 echo "executing $*"
3305 "$@"
3306 else
3307 # Commands like automake produce output to stderr even when they succeed.
3308 # Turn this output off if the command succeeds.
3309 "$@" > "$tmp"/cmdout 2>&1
3310 cmdret=$?
3311 if test $cmdret = 0; then
3312 rm -f "$tmp"/cmdout
3313 else
3314 echo "executing $*"
3315 cat "$tmp"/cmdout 1>&2
3316 rm -f "$tmp"/cmdout
3317 (exit $cmdret)
3322 # func_dest_tmpfilename file
3323 # determines the name of a temporary file (file is relative to destdir).
3324 # Input:
3325 # - destdir target directory
3326 # - doit : if actions shall be executed, false if only to be printed
3327 # - tmp pathname of a temporary directory
3328 # Sets variable:
3329 # - tmpfile absolute filename of the temporary file
3330 func_dest_tmpfilename ()
3332 if $doit; then
3333 # Put the new contents of $file in a file in the same directory (needed
3334 # to guarantee that an 'mv' to "$destdir/$file" works).
3335 tmpfile="$destdir/$1.tmp"
3336 else
3337 # Put the new contents of $file in a file in a temporary directory
3338 # (because the directory of "$file" might not exist).
3339 tmpfile="$tmp"/`basename "$1"`.tmp
3343 # func_is_local_file lookedup_file file
3344 # check whether file should be instantiated from local gnulib directory
3345 func_is_local_file ()
3347 dname=$1
3348 func_remove_suffix dname "/$2"
3349 func_path_foreach "$local_gnulib_path" test %dir% = "$dname"
3352 # func_should_link
3353 # determines whether the file $f should be copied, symlinked, or hardlinked.
3354 # Input:
3355 # - copymode copy mode for files in general
3356 # - lcopymode copy mode for files from local_gnulib_path
3357 # - f the original file name
3358 # - lookedup_file name of the merged (combined) file
3359 # Sets variable:
3360 # - copyaction copy or symlink or hardlink
3361 func_should_link ()
3363 if test -n "$lcopymode" && func_is_local_file "$lookedup_file" "$f"; then
3364 copyaction="$lcopymode"
3365 else
3366 if test -n "$copymode"; then
3367 copyaction="$copymode"
3368 else
3369 copyaction=copy
3374 # func_add_file
3375 # copies a file from gnulib into the destination directory. The destination
3376 # is known to not exist.
3377 # Input:
3378 # - destdir target directory
3379 # - local_gnulib_path from --local-dir
3380 # - modcache true or false, from --cache-modules/--no-cache-modules
3381 # - f the original file name
3382 # - lookedup_file name of the merged (combined) file
3383 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3384 # - g the rewritten file name
3385 # - tmpfile absolute filename of the temporary file
3386 # - doit : if actions shall be executed, false if only to be printed
3387 # - copymode copy mode for files in general
3388 # - lcopymode copy mode for files from local_gnulib_path
3389 func_add_file ()
3391 if $doit; then
3392 echo "Copying file $g"
3393 func_should_link
3394 if test "$copyaction" = symlink \
3395 && test -z "$lookedup_tmp" \
3396 && cmp -s "$lookedup_file" "$tmpfile"; then
3397 func_symlink_if_changed "$lookedup_file" "$destdir/$g"
3398 else
3399 if test "$copyaction" = hardlink \
3400 && test -z "$lookedup_tmp" \
3401 && cmp -s "$lookedup_file" "$tmpfile"; then
3402 func_hardlink "$lookedup_file" "$destdir/$g"
3403 else
3404 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3407 else
3408 echo "Copy file $g"
3412 # func_update_file
3413 # copies a file from gnulib into the destination directory. The destination
3414 # is known to exist.
3415 # Input:
3416 # - destdir target directory
3417 # - local_gnulib_path from --local-dir
3418 # - modcache true or false, from --cache-modules/--no-cache-modules
3419 # - f the original file name
3420 # - lookedup_file name of the merged (combined) file
3421 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3422 # - g the rewritten file name
3423 # - tmpfile absolute filename of the temporary file
3424 # - doit : if actions shall be executed, false if only to be printed
3425 # - copymode copy mode for files in general
3426 # - lcopymode copy mode for files from local_gnulib_path
3427 # - already_present nonempty if the file should already exist, empty otherwise
3428 func_update_file ()
3430 if cmp -s "$destdir/$g" "$tmpfile"; then
3431 : # The file has not changed.
3432 else
3433 # Replace the file.
3434 if $doit; then
3435 if test -n "$already_present"; then
3436 echo "Updating file $g (backup in ${g}~)"
3437 else
3438 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
3440 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3441 func_should_link
3442 if test "$copyaction" = symlink \
3443 && test -z "$lookedup_tmp" \
3444 && cmp -s "$lookedup_file" "$tmpfile"; then
3445 func_symlink_if_changed "$lookedup_file" "$destdir/$g"
3446 else
3447 if test "$copyaction" = hardlink \
3448 && test -z "$lookedup_tmp" \
3449 && cmp -s "$lookedup_file" "$tmpfile"; then
3450 func_hardlink "$lookedup_file" "$destdir/$g"
3451 else
3452 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3455 else
3456 if test -n "$already_present"; then
3457 echo "Update file $g (backup in ${g}~)"
3458 else
3459 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
3465 # func_emit_lib_Makefile_am
3466 # emits the contents of library makefile to standard output.
3467 # Input:
3468 # - local_gnulib_path from --local-dir
3469 # - modcache true or false, from --cache-modules/--no-cache-modules
3470 # - modules list of modules, including dependencies
3471 # - libname library name
3472 # - pobase directory relative to destdir where to place *.po files
3473 # - auxdir directory relative to destdir where to place build aux files
3474 # - gnu_make true if --gnu-make was given, false otherwise
3475 # - makefile_name from --makefile-name
3476 # - libtool true if libtool will be used, false or blank otherwise
3477 # - macro_prefix prefix of gl_LIBOBJS macros to use
3478 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3479 # - witness_c_macro from --witness-c-macro
3480 # - actioncmd (optional) command that will reproduce this invocation
3481 # - for_test true if creating a package for testing, false otherwise
3482 # - sed_replace_include_guard_prefix
3483 # sed expression for resolving ${gl_include_guard_prefix}
3484 # - destfile filename relative to destdir of makefile being generated
3485 # Input/Output:
3486 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3487 # list of edits to be done to Makefile.am variables
3488 # Output:
3489 # - uses_subdirs nonempty if object files in subdirs exist
3490 func_emit_lib_Makefile_am ()
3493 # When using GNU make, or when creating an includable Makefile.am snippet,
3494 # augment variables with += instead of assigning them.
3495 if $gnu_make || test -n "$makefile_name"; then
3496 assign='+='
3497 else
3498 assign='='
3500 if test "$libtool" = true; then
3501 libext=la
3502 perhapsLT=LT
3503 sed_eliminate_LDFLAGS="$sed_noop"
3504 else
3505 libext=a
3506 perhapsLT=
3507 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3509 if $for_test; then
3510 # When creating a package for testing: Attempt to provoke failures,
3511 # especially link errors, already during "make" rather than during
3512 # "make check", because "make check" is not possible in a cross-compiling
3513 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3514 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3515 else
3516 sed_transform_check_PROGRAMS="$sed_noop"
3518 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3519 echo "## Process this file with automake to produce Makefile.in."
3520 func_emit_copyright_notice
3521 if test -n "$actioncmd"; then
3522 # The maximum line length (excluding the terminating newline) of any file
3523 # that is to be preprocessed by config.status is 3070. config.status uses
3524 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
3525 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
3526 len=`echo "$actioncmd" | wc -c`
3527 if test -n "$len" && test "$len" -le 3000; then
3528 echo "# Reproduce by: $actioncmd"
3531 echo
3532 uses_subdirs=
3534 for module in $modules; do
3535 func_verify_nontests_module
3536 if test -n "$module"; then
3538 func_get_automake_snippet_conditional "$module" |
3539 LC_ALL=C \
3540 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3541 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3542 -e "$sed_eliminate_LDFLAGS" \
3543 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3544 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3545 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3546 -e "$sed_transform_check_PROGRAMS" \
3547 -e "$sed_replace_include_guard_prefix"
3548 if test "$module" = 'alloca'; then
3549 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
3550 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3552 } | combine_lines "${libname}_${libext}_SOURCES" > "$tmp"/amsnippet1
3554 func_get_automake_snippet_unconditional "$module" |
3555 LC_ALL=C sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
3556 } > "$tmp"/amsnippet2
3557 # Skip the contents if it's entirely empty.
3558 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
3559 echo "## begin gnulib module $module"
3560 if $gnu_make; then
3561 echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
3562 convert_to_gnu_make='s/^if \(.*\)/ifneq (,$(\1))/'
3563 else
3564 convert_to_gnu_make=
3566 echo
3567 if test "$cond_dependencies" = true; then
3568 if func_cond_module_p "$module"; then
3569 func_module_conditional_name "$module"
3570 if $gnu_make; then
3571 echo "ifneq (,\$($conditional))"
3572 else
3573 echo "if $conditional"
3577 sed "$convert_to_gnu_make" "$tmp"/amsnippet1
3578 if test "$cond_dependencies" = true; then
3579 if func_cond_module_p "$module"; then
3580 echo "endif"
3583 sed "$convert_to_gnu_make" "$tmp"/amsnippet2
3584 if $gnu_make; then
3585 echo "endif"
3587 echo "## end gnulib module $module"
3588 echo
3590 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
3591 # Test whether there are some source files in subdirectories.
3592 for f in `func_get_filelist "$module"`; do
3593 case $f in
3594 lib/*/*.c)
3595 uses_subdirs=yes
3596 break
3598 esac
3599 done
3601 done
3602 } > "$tmp"/allsnippets
3603 if test -z "$makefile_name"; then
3604 # If there are source files in subdirectories, prevent collision of the
3605 # object files (example: hash.c and libxml/hash.c).
3606 subdir_options=
3607 if test -n "$uses_subdirs"; then
3608 subdir_options=' subdir-objects'
3610 echo "AUTOMAKE_OPTIONS = 1.9.6 gnits${subdir_options}"
3612 echo
3613 if test -z "$makefile_name"; then
3614 echo "SUBDIRS ="
3615 echo "noinst_HEADERS ="
3616 echo "noinst_LIBRARIES ="
3617 echo "noinst_LTLIBRARIES ="
3618 # Automake versions < 1.11.4 create an empty pkgdatadir at
3619 # installation time if you specify pkgdata_DATA to empty.
3620 # See automake bugs #10997 and #11030:
3621 # * http://debbugs.gnu.org/10997
3622 # * http://debbugs.gnu.org/11030
3623 # So we need this workaround.
3624 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
3625 echo "pkgdata_DATA ="
3627 echo "EXTRA_DIST ="
3628 echo "BUILT_SOURCES ="
3629 echo "SUFFIXES ="
3631 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3632 if test -z "$makefile_name"; then
3633 echo "MOSTLYCLEANDIRS ="
3634 echo "CLEANFILES ="
3635 echo "DISTCLEANFILES ="
3636 echo "MAINTAINERCLEANFILES ="
3638 if $gnu_make; then
3639 echo "# Start of GNU Make output."
3641 # Put autoconf output into a temporary file, so that its exit status
3642 # can be checked from the shell. Signal any error by putting a
3643 # syntax error into the output makefile.
3644 ${AUTOCONF} -t 'AC_SUBST:$1 = @$1@' "$configure_ac" \
3645 >"$tmp"/makeout 2>"$tmp"/makeout2 &&
3646 LC_ALL=C sort -u "$tmp"/makeout || {
3647 echo "== gnulib-tool GNU Make output failed as follows =="
3648 sed 's/^/# stderr: /' "$tmp"/makeout2
3650 rm -f "$tmp"/makeout "$tmp"/makeout2
3652 echo "# End of GNU Make output."
3653 else
3654 echo "# No GNU Make output."
3656 # Execute edits that apply to the Makefile.am being generated.
3657 edit=0
3658 while test $edit != $makefile_am_edits; do
3659 edit=`expr $edit + 1`
3660 eval dir=\"\$makefile_am_edit${edit}_dir\"
3661 eval var=\"\$makefile_am_edit${edit}_var\"
3662 eval val=\"\$makefile_am_edit${edit}_val\"
3663 if test -n "$var"; then
3664 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3665 echo "${var} += ${val}"
3666 eval "makefile_am_edit${edit}_var="
3669 done
3670 if test -n "$witness_c_macro"; then
3671 cppflags_part1=" -D$witness_c_macro=1"
3672 else
3673 cppflags_part1=
3675 if $for_test; then
3676 cppflags_part2=" -DGNULIB_STRICT_CHECKING=1"
3677 else
3678 cppflags_part2=
3680 if test -z "$makefile_name"; then
3681 echo
3682 echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
3683 echo "AM_CFLAGS ="
3684 else
3685 if test -n "$cppflags_part1$cppflags_part2"; then
3686 echo
3687 echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
3690 echo
3691 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
3692 || { test -n "$makefile_name" \
3693 && test -f "$sourcebase/Makefile.am" \
3694 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
3695 }; then
3696 # One of the snippets or the user's Makefile.am already specifies an
3697 # installation location for the library. Don't confuse automake by saying
3698 # it should not be installed.
3700 else
3701 # By default, the generated library should not be installed.
3702 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3704 echo
3705 echo "${libname}_${libext}_SOURCES ="
3706 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3707 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3708 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3709 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3710 echo "EXTRA_${libname}_${libext}_SOURCES ="
3711 if test "$libtool" = true; then
3712 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3713 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3714 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3715 # the link dependencies of all modules.
3716 for module in $modules; do
3717 func_verify_nontests_module
3718 if test -n "$module"; then
3719 func_get_link_directive "$module"
3721 done \
3722 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
3723 | LC_ALL=C sort -u \
3724 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
3726 echo
3727 if test -n "$pobase"; then
3728 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
3729 echo
3731 cat "$tmp"/allsnippets \
3732 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3733 echo
3734 echo "mostlyclean-local: mostlyclean-generic"
3735 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3736 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3737 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3738 echo " fi; \\"
3739 echo " done; \\"
3740 echo " :"
3741 rm -f "$tmp"/allsnippets
3744 # func_emit_po_Makevars
3745 # emits the contents of po/ makefile parameterization to standard output.
3746 # Input:
3747 # - local_gnulib_path from --local-dir
3748 # - modcache true or false, from --cache-modules/--no-cache-modules
3749 # - sourcebase directory relative to destdir where to place source code
3750 # - pobase directory relative to destdir where to place *.po files
3751 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3752 func_emit_po_Makevars ()
3754 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3755 func_emit_copyright_notice
3756 echo
3757 echo "# Usually the message domain is the same as the package name."
3758 echo "# But here it has a '-gnulib' suffix."
3759 echo "DOMAIN = ${po_domain}-gnulib"
3760 echo
3761 echo "# These two variables depend on the location of this directory."
3762 echo "subdir = ${pobase}"
3763 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
3764 echo
3765 cat <<\EOF
3766 # These options get passed to xgettext.
3767 XGETTEXT_OPTIONS = \
3768 --keyword=_ --flag=_:1:pass-c-format \
3769 --keyword=N_ --flag=N_:1:pass-c-format \
3770 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
3771 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
3772 --flag=error:3:c-format --flag=error_at_line:5:c-format
3774 # This is the copyright holder that gets inserted into the header of the
3775 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
3776 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
3778 # This is the email address or URL to which the translators shall report
3779 # bugs in the untranslated strings:
3780 # - Strings which are not entire sentences, see the maintainer guidelines
3781 # in the GNU gettext documentation, section 'Preparing Strings'.
3782 # - Strings which use unclear terms or require additional context to be
3783 # understood.
3784 # - Strings which make invalid assumptions about notation of date, time or
3785 # money.
3786 # - Pluralisation problems.
3787 # - Incorrect English spelling.
3788 # - Incorrect formatting.
3789 # It can be your email address, or a mailing list address where translators
3790 # can write to without being subscribed, or the URL of a web page through
3791 # which the translators can contact you.
3792 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3794 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3795 # message catalogs shall be used. It is usually empty.
3796 EXTRA_LOCALE_CATEGORIES =
3798 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3799 # context. Possible values are "yes" and "no". Set this to yes if the
3800 # package uses functions taking also a message context, like pgettext(), or
3801 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3802 USE_MSGCTXT = no
3806 # func_emit_po_POTFILES_in
3807 # emits the file list to be passed to xgettext to standard output.
3808 # Input:
3809 # - local_gnulib_path from --local-dir
3810 # - modcache true or false, from --cache-modules/--no-cache-modules
3811 # - sourcebase directory relative to destdir where to place source code
3812 # - files list of new files
3813 func_emit_po_POTFILES_in ()
3815 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3816 func_emit_copyright_notice
3817 echo
3818 echo "# List of files which contain translatable strings."
3819 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3822 # func_emit_tests_Makefile_am witness_macro
3823 # emits the contents of tests makefile to standard output.
3824 # Input:
3825 # - local_gnulib_path from --local-dir
3826 # - modcache true or false, from --cache-modules/--no-cache-modules
3827 # - modules list of modules, including dependencies
3828 # - libname library name
3829 # - auxdir directory relative to destdir where to place build aux files
3830 # - gnu_make true if --gnu-make was given, false otherwise
3831 # - makefile_name from --makefile-name
3832 # - libtool true if libtool will be used, false or blank otherwise
3833 # - sourcebase relative directory containing lib source code
3834 # - m4base relative directory containing autoconf macros
3835 # - testsbase relative directory containing unit test code
3836 # - macro_prefix prefix of gl_LIBOBJS macros to use
3837 # - witness_c_macro from --witness-c-macro
3838 # - for_test true if creating a package for testing, false otherwise
3839 # - single_configure true if a single configure file should be generated,
3840 # false for a separate configure file for the tests
3841 # - use_libtests true if a libtests.a should be built, false otherwise
3842 # - sed_replace_include_guard_prefix
3843 # sed expression for resolving ${gl_include_guard_prefix}
3844 # - destfile filename relative to destdir of makefile being generated
3845 # Input/Output:
3846 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3847 # list of edits to be done to Makefile.am variables
3848 # Output:
3849 # - uses_subdirs nonempty if object files in subdirs exist
3850 func_emit_tests_Makefile_am ()
3852 witness_macro="$1"
3853 if test "$libtool" = true; then
3854 libext=la
3855 perhapsLT=LT
3856 sed_eliminate_LDFLAGS="$sed_noop"
3857 else
3858 libext=a
3859 perhapsLT=
3860 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3862 if $for_test; then
3863 # When creating a package for testing: Attempt to provoke failures,
3864 # especially link errors, already during "make" rather than during
3865 # "make check", because "make check" is not possible in a cross-compiling
3866 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3867 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3868 else
3869 sed_transform_check_PROGRAMS="$sed_noop"
3871 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3872 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3873 echo "## Process this file with automake to produce Makefile.in."
3874 func_emit_copyright_notice
3875 echo
3876 uses_subdirs=
3878 for module in $modules; do
3879 if $for_test && ! $single_configure; then
3880 func_verify_tests_module
3881 else
3882 func_verify_module
3884 if test -n "$module"; then
3886 func_get_automake_snippet "$module" |
3887 LC_ALL=C \
3888 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3889 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3890 -e "$sed_eliminate_LDFLAGS" \
3891 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3892 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3893 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3894 -e "$sed_transform_check_PROGRAMS" \
3895 -e "$sed_replace_include_guard_prefix"
3896 if $use_libtests && test "$module" = 'alloca'; then
3897 echo "libtests_a_LIBADD += @ALLOCA@"
3898 echo "libtests_a_DEPENDENCIES += @ALLOCA@"
3900 } > "$tmp"/amsnippet
3901 # Skip the contents if it's entirely empty.
3902 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3903 # Mention long-running tests at the end.
3904 ofd=3
3905 for word in `func_get_status "$module"`; do
3906 if test "$word" = 'longrunning-test'; then
3907 ofd=4
3908 break
3910 done
3911 { echo "## begin gnulib module $module"
3912 if $gnu_make; then
3913 echo "ifeq (,\$(OMIT_GNULIB_MODULE_$module))"
3915 echo
3916 cat "$tmp"/amsnippet
3917 if $gnu_make; then
3918 echo "endif"
3920 echo "## end gnulib module $module"
3921 echo
3922 } >&$ofd
3924 rm -f "$tmp"/amsnippet
3925 # Test whether there are some source files in subdirectories.
3926 for f in `func_get_filelist "$module"`; do
3927 case $f in
3928 lib/*/*.c | tests/*/*.c)
3929 uses_subdirs=yes
3930 break
3932 esac
3933 done
3935 done
3936 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3937 # Generate dependencies here, since it eases the debugging of test failures.
3938 # If there are source files in subdirectories, prevent collision of the
3939 # object files (example: hash.c and libxml/hash.c).
3940 subdir_options=
3941 if test -n "$uses_subdirs"; then
3942 subdir_options=' subdir-objects'
3944 echo "AUTOMAKE_OPTIONS = 1.9.6 foreign${subdir_options}"
3945 echo
3946 if $for_test && ! $single_configure; then
3947 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3948 echo
3950 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3951 # variable is needed to avoid an error from automake:
3952 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3953 echo "SUBDIRS = ."
3954 echo "TESTS ="
3955 echo "XFAIL_TESTS ="
3956 echo "TESTS_ENVIRONMENT ="
3957 echo "noinst_PROGRAMS ="
3958 if ! $for_test; then
3959 echo "check_PROGRAMS ="
3961 echo "EXTRA_PROGRAMS ="
3962 echo "noinst_HEADERS ="
3963 echo "noinst_LIBRARIES ="
3964 if $use_libtests; then
3965 if $for_test; then
3966 echo "noinst_LIBRARIES += libtests.a"
3967 else
3968 echo "check_LIBRARIES = libtests.a"
3971 # Automake versions < 1.11.4 create an empty pkgdatadir at
3972 # installation time if you specify pkgdata_DATA to empty.
3973 # See automake bugs #10997 and #11030:
3974 # * http://debbugs.gnu.org/10997
3975 # * http://debbugs.gnu.org/11030
3976 # So we need this workaround.
3977 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3978 echo "pkgdata_DATA ="
3980 echo "EXTRA_DIST ="
3981 echo "BUILT_SOURCES ="
3982 echo "SUFFIXES ="
3983 echo "MOSTLYCLEANFILES = core *.stackdump"
3984 echo "MOSTLYCLEANDIRS ="
3985 echo "CLEANFILES ="
3986 echo "DISTCLEANFILES ="
3987 echo "MAINTAINERCLEANFILES ="
3988 # Execute edits that apply to the Makefile.am being generated.
3989 edit=0
3990 while test $edit != $makefile_am_edits; do
3991 edit=`expr $edit + 1`
3992 eval dir=\"\$makefile_am_edit${edit}_dir\"
3993 eval var=\"\$makefile_am_edit${edit}_var\"
3994 eval val=\"\$makefile_am_edit${edit}_val\"
3995 if test -n "$var"; then
3996 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3997 echo "${var} += ${val}"
3998 eval "makefile_am_edit${edit}_var="
4001 done
4002 echo
4003 echo "AM_CPPFLAGS = \\"
4004 if $for_test; then
4005 echo " -DGNULIB_STRICT_CHECKING=1 \\"
4007 if test -n "$witness_c_macro"; then
4008 echo " -D$witness_c_macro=1 \\"
4010 if test -n "${witness_macro}"; then
4011 echo " -D@${witness_macro}@=1 \\"
4013 echo " -I. -I\$(srcdir) \\"
4014 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
4015 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
4016 echo
4017 local_ldadd_before=''
4018 local_ldadd_after=''
4019 if $use_libtests; then
4020 # All test programs need to be linked with libtests.a.
4021 # It needs to be passed to the linker before ${libname}.${libext}, since
4022 # the tests-related modules depend on the main modules.
4023 # It also needs to be passed to the linker after ${libname}.${libext}
4024 # because the latter might contain incomplete modules (such as the 'error'
4025 # module whose dependency to 'progname' is voluntarily omitted).
4026 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
4027 # not matter.
4028 local_ldadd_before=' libtests.a'
4029 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
4031 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
4032 echo
4033 if $use_libtests; then
4034 echo "libtests_a_SOURCES ="
4035 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
4036 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
4037 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
4038 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
4039 echo "EXTRA_libtests_a_SOURCES ="
4040 # The circular dependency in LDADD requires this.
4041 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
4042 echo
4044 # Many test scripts use ${EXEEXT} or ${srcdir}.
4045 # EXEEXT is defined by AC_PROG_CC through autoconf.
4046 # srcdir is defined by autoconf and automake.
4047 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
4048 echo
4049 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
4050 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
4051 echo "# Clean up after Solaris cc."
4052 echo "clean-local:"
4053 echo " rm -rf SunWS_cache"
4054 echo
4055 echo "mostlyclean-local: mostlyclean-generic"
4056 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
4057 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
4058 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
4059 echo " fi; \\"
4060 echo " done; \\"
4061 echo " :"
4062 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
4065 # func_emit_initmacro_start macro_prefix
4066 # emits the first few statements of the gl_INIT macro to standard output.
4067 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4068 func_emit_initmacro_start ()
4070 macro_prefix_arg="$1"
4071 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
4072 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
4073 # LIBOBJS. The purpose is to allow several gnulib instantiations under
4074 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
4075 # flexibility.)
4076 # Furthermore it avoids an automake error like this when a Makefile.am
4077 # that uses pieces of gnulib also uses $(LIBOBJ):
4078 # automatically discovered file `error.c' should not be explicitly mentioned
4079 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
4080 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
4081 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
4082 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
4083 # automatically discovered file `error.c' should not be explicitly mentioned
4084 # We let automake know about the files to be distributed through the
4085 # EXTRA_lib_SOURCES variable.
4086 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
4087 # Create data variables for checking the presence of files that are mentioned
4088 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
4089 # because we want the check to happen when the configure file is created,
4090 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
4091 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
4092 # in which to expect them.
4093 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
4094 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
4095 echo " gl_COMMON"
4098 # func_emit_initmacro_end macro_prefix
4099 # emits the last few statements of the gl_INIT macro to standard output.
4100 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4101 func_emit_initmacro_end ()
4103 macro_prefix_arg="$1"
4104 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
4105 # The check is performed only when autoconf is run from the directory where
4106 # the configure.ac resides; if it is run from a different directory, the
4107 # check is skipped.
4108 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
4109 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
4110 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
4111 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
4112 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
4113 echo " exit 1"
4114 echo " fi"
4115 echo " done])dnl"
4116 echo " m4_if(m4_sysval, [0], [],"
4117 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
4118 echo " ])"
4119 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
4120 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
4121 echo " m4_popdef([AC_LIBSOURCES])"
4122 echo " m4_popdef([AC_REPLACE_FUNCS])"
4123 echo " m4_popdef([AC_LIBOBJ])"
4124 echo " AC_CONFIG_COMMANDS_PRE(["
4125 echo " ${macro_prefix_arg}_libobjs="
4126 echo " ${macro_prefix_arg}_ltlibobjs="
4127 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
4128 echo " # Remove the extension."
4129 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
4130 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
4131 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
4132 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
4133 echo " done"
4134 echo " fi"
4135 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
4136 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
4137 echo " ])"
4140 # func_emit_initmacro_done macro_prefix sourcebase
4141 # emits a few statements after the gl_INIT macro to standard output.
4142 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4143 # - sourcebase directory relative to destdir where to place source code
4144 func_emit_initmacro_done ()
4146 macro_prefix_arg="$1"
4147 sourcebase_arg="$2"
4148 echo
4149 echo "# Like AC_LIBOBJ, except that the module name goes"
4150 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4151 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
4152 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
4153 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
4154 echo "])"
4155 echo
4156 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
4157 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4158 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
4159 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
4160 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
4161 echo "])"
4162 echo
4163 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
4164 echo "# expected is derived from the gnulib-tool parameterization,"
4165 echo "# and alloca is special cased (for the alloca-opt module)."
4166 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
4167 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
4168 echo " m4_foreach([_gl_NAME], [\$1], ["
4169 echo " m4_if(_gl_NAME, [alloca.c], [], ["
4170 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
4171 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
4172 echo " ])"
4173 echo " ])"
4174 echo "])"
4177 # func_emit_autoconf_snippet indentation
4178 # emits the autoconf snippet of a module.
4179 # Input:
4180 # - indentation spaces to prepend on each line
4181 # - local_gnulib_path from --local-dir
4182 # - modcache true or false, from --cache-modules/--no-cache-modules
4183 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4184 # - sed_replace_include_guard_prefix
4185 # sed expression for resolving ${gl_include_guard_prefix}
4186 # - module the module name
4187 # - toplevel true or false. 'false' means a subordinate use of
4188 # gnulib-tool.
4189 # - disable_libtool true or false. It tells whether to disable libtool
4190 # handling even if it has been specified through the
4191 # command line options.
4192 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4193 # invocations.
4194 func_emit_autoconf_snippet ()
4196 indentation="$1"
4197 if { case $module in
4198 gnumakefile | maintainer-makefile)
4199 # These modules are meant to be used only in the top-level directory.
4200 $toplevel ;;
4202 true ;;
4203 esac
4204 }; then
4205 func_get_autoconf_snippet "$module" \
4206 | sed -e '/^$/d;' -e "s/^/$indentation/" \
4207 -e "$sed_replace_build_aux" \
4208 -e "$sed_replace_include_guard_prefix" \
4209 | { if $disable_libtool; then
4210 sed -e 's/\$gl_cond_libtool/false/g' \
4211 -e 's/gl_libdeps/gltests_libdeps/g' \
4212 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4213 else
4217 | { if $disable_gettext; then
4218 sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
4219 else
4220 # Don't indent AM_GNU_GETTEXT_VERSION line, as that confuses
4221 # autopoint through at least GNU gettext version 0.18.2.
4222 sed -e 's/^ *AM_GNU_GETTEXT_VERSION/AM_GNU_GETTEXT_VERSION/'
4225 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
4226 echo 'changequote(,)dnl'
4227 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4228 echo 'changequote([, ])dnl'
4229 echo 'AC_SUBST([LTALLOCA])'
4234 # func_emit_autoconf_snippets modules verifier toplevel disable_libtool disable_gettext
4235 # collects and emit the autoconf snippets of a set of modules.
4236 # Input:
4237 # - local_gnulib_path from --local-dir
4238 # - modcache true or false, from --cache-modules/--no-cache-modules
4239 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4240 # - sed_replace_include_guard_prefix
4241 # sed expression for resolving ${gl_include_guard_prefix}
4242 # - modules the list of modules.
4243 # - verifier one of func_verify_module, func_verify_nontests_module,
4244 # func_verify_tests_module. It selects the subset of
4245 # $modules to consider.
4246 # - toplevel true or false. 'false' means a subordinate use of
4247 # gnulib-tool.
4248 # - disable_libtool true or false. It tells whether to disable libtool
4249 # handling even if it has been specified through the
4250 # command line options.
4251 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4252 # invocations.
4253 func_emit_autoconf_snippets ()
4255 verifier="$2"
4256 toplevel="$3"
4257 disable_libtool="$4"
4258 disable_gettext="$5"
4259 if test "$cond_dependencies" = true; then
4260 for m in $modules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/modules
4261 # Emit the autoconf code for the unconditional modules.
4262 for module in $1; do
4263 eval $verifier
4264 if test -n "$module"; then
4265 if func_cond_module_p "$module"; then
4267 else
4268 func_emit_autoconf_snippet " "
4271 done
4272 # Initialize the shell variables indicating that the modules are enabled.
4273 for module in $1; do
4274 eval $verifier
4275 if test -n "$module"; then
4276 if func_cond_module_p "$module"; then
4277 func_module_shellvar_name "$module"
4278 echo " $shellvar=false"
4281 done
4282 # Emit the autoconf code for the conditional modules, each in a separate
4283 # function. This makes it possible to support cycles among conditional
4284 # modules.
4285 for module in $1; do
4286 eval $verifier
4287 if test -n "$module"; then
4288 if func_cond_module_p "$module"; then
4289 func_module_shellfunc_name "$module"
4290 func_module_shellvar_name "$module"
4291 echo " $shellfunc ()"
4292 echo ' {'
4293 echo " if ! \$$shellvar; then"
4294 func_emit_autoconf_snippet " "
4295 echo " $shellvar=true"
4296 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4297 # Intersect $deps with the modules list $1.
4298 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4299 for dep in $deps; do
4300 if func_cond_module_p "$dep"; then
4301 func_module_shellfunc_name "$dep"
4302 func_cond_module_condition "$module" "$dep"
4303 if test "$condition" != true; then
4304 echo " if $condition; then"
4305 echo " $shellfunc"
4306 echo ' fi'
4307 else
4308 echo " $shellfunc"
4310 else
4311 # The autoconf code for $dep has already been emitted above and
4312 # therefore is already executed when this function is run.
4315 done
4316 echo ' fi'
4317 echo ' }'
4320 done
4321 # Emit the dependencies from the unconditional to the conditional modules.
4322 for module in $1; do
4323 eval $verifier
4324 if test -n "$module"; then
4325 if func_cond_module_p "$module"; then
4327 else
4328 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4329 # Intersect $deps with the modules list $1.
4330 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4331 for dep in $deps; do
4332 if func_cond_module_p "$dep"; then
4333 func_module_shellfunc_name "$dep"
4334 func_cond_module_condition "$module" "$dep"
4335 if test "$condition" != true; then
4336 echo " if $condition; then"
4337 echo " $shellfunc"
4338 echo ' fi'
4339 else
4340 echo " $shellfunc"
4342 else
4343 # The autoconf code for $dep has already been emitted above and
4344 # therefore is already executed when this code is run.
4347 done
4350 done
4351 # Define the Automake conditionals.
4352 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
4353 for module in $1; do
4354 eval $verifier
4355 if test -n "$module"; then
4356 if func_cond_module_p "$module"; then
4357 func_module_conditional_name "$module"
4358 func_module_shellvar_name "$module"
4359 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
4362 done
4363 else
4364 # Ignore the conditions, and enable all modules unconditionally.
4365 for module in $1; do
4366 eval $verifier
4367 if test -n "$module"; then
4368 func_emit_autoconf_snippet " "
4370 done
4374 # func_emit_pre_early_macros require indentation modules
4375 # The require parameter can be ':' (AC_REQUIRE) or 'false' (direct call).
4376 func_emit_pre_early_macros ()
4378 echo
4379 echo "${2}# Pre-early section."
4380 if $1; then
4381 _pre_early_snippet="echo \"${2}AC_REQUIRE([\$_pre_early_macro])\""
4382 else
4383 _pre_early_snippet="echo \"${2}\$_pre_early_macro\""
4386 # We need to call gl_USE_SYSTEM_EXTENSIONS before gl_PROG_AR_RANLIB. Doing
4387 # AC_REQUIRE in configure-ac.early is not early enough.
4388 _pre_early_macro="gl_USE_SYSTEM_EXTENSIONS"
4389 case "${nl}${3}${nl}" in
4390 *${nl}extensions${nl}*) eval "$_pre_early_snippet" ;;
4391 esac
4393 _pre_early_macro="gl_PROG_AR_RANLIB"
4394 eval "$_pre_early_snippet"
4395 echo
4398 # func_reconstruct_cached_dir
4399 # callback for func_reconstruct_cached_local_gnulib_path
4400 # Input:
4401 # - destdir from --dir
4402 # Output:
4403 # - local_gnulib_path restored '--local-dir' path from cache
4404 func_reconstruct_cached_dir ()
4406 cached_dir=$1
4407 if test -n "$cached_dir"; then
4408 case "$destdir" in
4410 func_path_append local_gnulib_path "$destdir/$cached_dir" ;;
4412 case "$cached_dir" in
4414 func_path_append local_gnulib_path "$destdir/$cached_dir" ;;
4416 func_relconcat "$destdir" "$cached_dir"
4417 func_path_append local_gnulib_path "$relconcat" ;;
4418 esac ;;
4419 esac
4423 # func_reconstruct_cached_local_gnulib_path
4424 # reconstruct local_gnulib_path from cached_local_gnulib_path to be set
4425 # relatively to $destdir again.
4426 # Input:
4427 # - cached_local_gnulib_path local_gnulib_path stored within gnulib-cache.m4
4428 # - destdir from --dir
4429 # Output:
4430 # - local_gnulib_path restored '--local-dir' path from cache
4431 func_reconstruct_cached_local_gnulib_path ()
4433 func_path_foreach "$cached_local_gnulib_path" func_reconstruct_cached_dir %dir%
4436 # func_import modules
4437 # Uses also the variables
4438 # - mode import or add-import or remove-import or update
4439 # - destdir target directory
4440 # - local_gnulib_path from --local-dir
4441 # - modcache true or false, from --cache-modules/--no-cache-modules
4442 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
4443 # - libname library name
4444 # - supplied_libname true if --lib was given, blank otherwise
4445 # - sourcebase directory relative to destdir where to place source code
4446 # - m4base directory relative to destdir where to place *.m4 macros
4447 # - pobase directory relative to destdir where to place *.po files
4448 # - docbase directory relative to destdir where to place doc files
4449 # - testsbase directory relative to destdir where to place unit test code
4450 # - auxdir directory relative to destdir where to place build aux files
4451 # - inctests true if --with-tests was given, false otherwise
4452 # - incobsolete true if --with-obsolete was given, blank otherwise
4453 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
4454 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
4455 # otherwise
4456 # - inc_privileged_tests true if --with-privileged-tests was given, blank
4457 # otherwise
4458 # - inc_unportable_tests true if --with-unportable-tests was given, blank
4459 # otherwise
4460 # - inc_all_tests true if --with-all-tests was given, blank otherwise
4461 # - avoidlist list of modules to avoid, from --avoid
4462 # - cond_dependencies true if --conditional-dependencies was given, false if
4463 # --no-conditional-dependencies was given, blank otherwise
4464 # - lgpl yes or a number if library's license shall be LGPL,
4465 # blank otherwise
4466 # - makefile_name from --makefile-name
4467 # - libtool true if --libtool was given, false if --no-libtool was
4468 # given, blank otherwise
4469 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
4470 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4471 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4472 # - witness_c_macro from --witness-c-macro
4473 # - vc_files true if --vc-files was given, false if --no-vc-files was
4474 # given, blank otherwise
4475 # - autoconf_minversion minimum supported autoconf version
4476 # - doit : if actions shall be executed, false if only to be printed
4477 # - copymode copy mode for files in general
4478 # - lcopymode copy mode for files from local_gnulib_path
4479 # - do_copyrights true if copyright notices in files should be replaced,
4480 # blank otherwise
4481 func_import ()
4483 # Get the cached settings.
4484 # In 'import' mode, we read them only for the purpose of knowing the old
4485 # installed file list, and don't use them as defaults.
4486 cached_local_gnulib_path=
4487 cached_specified_modules=
4488 cached_incobsolete=
4489 cached_inc_cxx_tests=
4490 cached_inc_longrunning_tests=
4491 cached_inc_privileged_tests=
4492 cached_inc_unportable_tests=
4493 cached_inc_all_tests=
4494 cached_avoidlist=
4495 cached_sourcebase=
4496 cached_m4base=
4497 cached_pobase=
4498 cached_docbase=
4499 cached_testsbase=
4500 cached_inctests=
4501 cached_libname=
4502 cached_lgpl=
4503 cached_makefile_name=
4504 cached_cond_dependencies=
4505 cached_libtool=
4506 cached_macro_prefix=
4507 cached_po_domain=
4508 cached_witness_c_macro=
4509 cached_vc_files=
4510 cached_files=
4511 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4512 cached_libtool=false
4513 my_sed_traces='
4514 s,#.*$,,
4515 s,^dnl .*$,,
4516 s, dnl .*$,,
4517 /gl_LOCAL_DIR(/ {
4518 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_path="\1",p
4520 /gl_MODULES(/ {
4523 s/)/)/
4528 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
4530 /gl_WITH_OBSOLETE/ {
4531 s,^.*$,cached_incobsolete=true,p
4533 /gl_WITH_CXX_TESTS/ {
4534 s,^.*$,cached_inc_cxx_tests=true,p
4536 /gl_WITH_LONGRUNNING_TESTS/ {
4537 s,^.*$,cached_inc_longrunning_tests=true,p
4539 /gl_WITH_PRIVILEGED_TESTS/ {
4540 s,^.*$,cached_inc_privileged_tests=true,p
4542 /gl_WITH_UNPORTABLE_TESTS/ {
4543 s,^.*$,cached_inc_unportable_tests=true,p
4545 /gl_WITH_ALL_TESTS/ {
4546 s,^.*$,cached_inc_all_tests=true,p
4548 /gl_AVOID(/ {
4549 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
4551 /gl_SOURCE_BASE(/ {
4552 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
4554 /gl_M4_BASE(/ {
4555 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
4557 /gl_PO_BASE(/ {
4558 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
4560 /gl_DOC_BASE(/ {
4561 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
4563 /gl_TESTS_BASE(/ {
4564 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
4566 /gl_WITH_TESTS/ {
4567 s,^.*$,cached_inctests=true,p
4569 /gl_LIB(/ {
4570 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
4572 /gl_LGPL(/ {
4573 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
4575 /gl_LGPL/ {
4576 s,^.*$,cached_lgpl=yes,p
4578 /gl_MAKEFILE_NAME(/ {
4579 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
4581 /gl_CONDITIONAL_DEPENDENCIES/ {
4582 s,^.*$,cached_cond_dependencies=true,p
4584 /gl_LIBTOOL/ {
4585 s,^.*$,cached_libtool=true,p
4587 /gl_MACRO_PREFIX(/ {
4588 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
4590 /gl_PO_DOMAIN(/ {
4591 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
4593 /gl_WITNESS_C_MACRO(/ {
4594 s,^.*gl_WITNESS_C_MACRO([[ ]*\([^]"$`\\)]*\).*$,cached_witness_c_macro="\1",p
4596 /gl_VC_FILES(/ {
4597 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
4599 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
4600 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4601 my_sed_traces='
4602 s,#.*$,,
4603 s,^dnl .*$,,
4604 s, dnl .*$,,
4605 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
4606 s,^.*$,cached_files=",p
4610 s,^\]).*$,",
4612 s,["$`\\],,g
4619 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
4623 if test "$mode" = import; then
4624 # In 'import' mode, the new set of specified modules overrides the cached
4625 # set of modules. Ignore the cached settings.
4626 specified_modules="$1"
4627 else
4628 # Merge the cached settings with the specified ones.
4629 # The m4base must be the same as expected from the pathname.
4630 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
4631 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
4633 # The local_gnulib_path defaults to the cached one. Recall that the cached one
4634 # is relative to $destdir, whereas the one we use is relative to . or absolute.
4635 if test -z "$local_gnulib_path"; then
4636 func_reconstruct_cached_local_gnulib_path
4638 case $mode in
4639 add-import)
4640 # Append the cached and the specified module names. So that
4641 # "gnulib-tool --add-import foo" means to add the module foo.
4642 specified_modules="$cached_specified_modules $1"
4644 remove-import)
4645 # Take the cached module names, minus the specified module names.
4646 specified_modules=
4647 if $have_associative; then
4648 # Use an associative array, for O(N) worst-case run time.
4649 declare -A to_remove
4650 for m in $1; do
4651 eval 'to_remove[$m]=yes'
4652 done
4653 for module in $cached_specified_modules; do
4654 if eval 'test -z "${to_remove[$module]}"'; then
4655 func_append specified_modules "$module "
4657 done
4658 else
4659 # This loop has O(N**2) worst-case run time.
4660 for module in $cached_specified_modules; do
4661 to_remove=
4662 for m in $1; do
4663 if test "$m" = "$module"; then
4664 to_remove=yes
4665 break
4667 done
4668 if test -z "$to_remove"; then
4669 func_append specified_modules "$module "
4671 done
4674 update)
4675 # Take the cached module names. There are no specified module names.
4676 specified_modules="$cached_specified_modules"
4678 esac
4679 # Included obsolete modules among the dependencies if specified either way.
4680 if test -z "$incobsolete"; then
4681 incobsolete="$cached_incobsolete"
4683 # Included special kinds of tests modules among the dependencies if specified
4684 # either way.
4685 if test -z "$inc_cxx_tests"; then
4686 inc_cxx_tests="$cached_inc_cxx_tests"
4688 if test -z "$inc_longrunning_tests"; then
4689 inc_longrunning_tests="$cached_inc_longrunning_tests"
4691 if test -z "$inc_privileged_tests"; then
4692 inc_privileged_tests="$cached_inc_privileged_tests"
4694 if test -z "$inc_unportable_tests"; then
4695 inc_unportable_tests="$cached_inc_unportable_tests"
4697 if test -z "$inc_all_tests"; then
4698 inc_all_tests="$cached_inc_all_tests"
4700 # Append the cached and the specified avoidlist. This is probably better
4701 # than dropping the cached one when --avoid is specified at least once.
4702 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
4703 avoidlist=`echo $avoidlist`
4705 # The sourcebase defaults to the cached one.
4706 if test -z "$sourcebase"; then
4707 sourcebase="$cached_sourcebase"
4708 if test -z "$sourcebase"; then
4709 func_fatal_error "missing --source-base option"
4712 # The pobase defaults to the cached one.
4713 if test -z "$pobase"; then
4714 pobase="$cached_pobase"
4716 # The docbase defaults to the cached one.
4717 if test -z "$docbase"; then
4718 docbase="$cached_docbase"
4719 if test -z "$docbase"; then
4720 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."
4723 # The testsbase defaults to the cached one.
4724 if test -z "$testsbase"; then
4725 testsbase="$cached_testsbase"
4726 if test -z "$testsbase"; then
4727 func_fatal_error "missing --tests-base option"
4730 # Require the tests if specified either way.
4731 if ! $inctests; then
4732 inctests="$cached_inctests"
4733 if test -z "$inctests"; then
4734 inctests=false
4737 # The libname defaults to the cached one.
4738 if test -z "$supplied_libname"; then
4739 libname="$cached_libname"
4740 if test -z "$libname"; then
4741 func_fatal_error "missing --lib option"
4744 # Require LGPL if specified either way.
4745 if test -z "$lgpl"; then
4746 lgpl="$cached_lgpl"
4748 # The makefile_name defaults to the cached one.
4749 if test -z "$makefile_name"; then
4750 makefile_name="$cached_makefile_name"
4752 # Use conditional dependencies if specified either way.
4753 if test -z "$cond_dependencies"; then
4754 cond_dependencies="$cached_cond_dependencies"
4756 # Use libtool if specified either way, or if guessed.
4757 if test -z "$libtool"; then
4758 if test -n "$cached_m4base"; then
4759 libtool="$cached_libtool"
4760 else
4761 libtool="$guessed_libtool"
4764 # The macro_prefix defaults to the cached one.
4765 if test -z "$macro_prefix"; then
4766 macro_prefix="$cached_macro_prefix"
4767 if test -z "$macro_prefix"; then
4768 func_fatal_error "missing --macro-prefix option"
4771 # The po_domain defaults to the cached one.
4772 if test -z "$po_domain"; then
4773 po_domain="$cached_po_domain"
4775 # The witness_c_macro defaults to the cached one.
4776 if test -z "$witness_c_macro"; then
4777 witness_c_macro="$cached_witness_c_macro"
4779 # The vc_files defaults to the cached one.
4780 if test -z "$vc_files"; then
4781 vc_files="$cached_vc_files"
4783 # Ensure constraints.
4784 if test "$cond_dependencies" = true && $inctests; then
4785 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
4786 func_exit 1
4789 # --without-*-tests options are not supported here.
4790 excl_cxx_tests=
4791 excl_longrunning_tests=
4792 excl_privileged_tests=
4793 excl_unportable_tests=
4795 # Canonicalize the list of specified modules.
4796 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4798 # Include all kinds of tests modules if --with-all-tests was specified.
4799 inc_all_direct_tests="$inc_all_tests"
4800 inc_all_indirect_tests="$inc_all_tests"
4802 # Determine final module list.
4803 modules="$specified_modules"
4804 func_modules_transitive_closure
4805 if test $verbose -ge 0; then
4806 func_show_module_list
4808 final_modules="$modules"
4810 # Determine main module list and tests-related module list separately.
4811 func_modules_transitive_closure_separately
4813 # Determine whether a $testsbase/libtests.a is needed.
4814 func_determine_use_libtests
4816 # Add the dummy module to the main module list or to the tests-related module
4817 # list if needed.
4818 func_modules_add_dummy_separately
4820 # If --lgpl, verify that the licenses of modules are compatible.
4821 if test -n "$lgpl"; then
4822 license_incompatibilities=
4823 for module in $main_modules; do
4824 license=`func_get_license $module`
4825 case $license in
4826 'GPLed build tool') ;;
4827 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4829 case "$lgpl" in
4830 yes | 3)
4831 case $license in
4832 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL) ;;
4833 *) func_append license_incompatibilities "$module $license$nl" ;;
4834 esac
4836 3orGPLv2)
4837 case $license in
4838 LGPLv2+ | 'LGPLv3+ or GPLv2') ;;
4839 *) func_append license_incompatibilities "$module $license$nl" ;;
4840 esac
4843 case $license in
4844 LGPLv2+) ;;
4845 *) func_append license_incompatibilities "$module $license$nl" ;;
4846 esac
4848 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4849 esac
4851 esac
4852 done
4853 if test -n "$license_incompatibilities"; then
4854 # Format the license incompatibilities as a table.
4855 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
4856 s,^\(.................................................[^ ]*\) *, \1 ,'
4857 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
4858 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
4862 # Show banner notice of every module.
4863 modules="$main_modules"
4864 func_modules_notice
4866 # Determine script to apply to imported library files.
4867 sed_transform_lib_file=
4868 for module in $main_modules; do
4869 if test $module = config-h; then
4870 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
4871 sed_transform_lib_file=$sed_transform_lib_file'
4872 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
4874 break
4876 done
4877 sed_transform_main_lib_file="$sed_transform_lib_file"
4878 if test -n "$do_copyrights"; then
4879 if test -n "$lgpl"; then
4880 # Update license.
4881 case "$lgpl" in
4882 yes | 3)
4883 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4884 s/GNU General/GNU Lesser General/g
4885 s/General Public License/Lesser General Public License/g
4886 s/Lesser Lesser General Public License/Lesser General Public License/g
4889 3orGPLv2)
4890 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4891 /^ *This program is free software/i\
4892 This program is free software: you can redistribute it and\/or\
4893 modify it under the terms of either:\
4895 * the GNU Lesser General Public License as published by the Free\
4896 Software Foundation; either version 3 of the License, or (at your\
4897 option) any later version.\
4901 * the GNU General Public License as published by the Free\
4902 Software Foundation; either version 2 of the License, or (at your\
4903 option) any later version.\
4905 or both in parallel, as here.
4906 /^ *This program is free software/,/^$/d
4910 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4911 s/GNU General/GNU Lesser General/g
4912 s/General Public License/Lesser General Public License/g
4913 s/Lesser Lesser General Public License/Lesser General Public License/g
4915 s/version [23]\([ ,]\)/version 2.1\1/g
4918 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4919 esac
4920 else
4921 # Update license.
4922 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4923 s/GNU Lesser General/GNU General/g
4924 s/Lesser General Public License/General Public License/g
4926 s/GNU Library General/GNU General/g
4927 s/Library General Public License/General Public License/g
4929 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4934 # Determine script to apply to auxiliary files that go into $auxdir/.
4935 sed_transform_build_aux_file=
4936 if test -n "$do_copyrights"; then
4937 # Update license.
4938 sed_transform_build_aux_file=$sed_transform_build_aux_file'
4939 s/GNU Lesser General/GNU General/g
4940 s/Lesser General Public License/General Public License/g
4942 s/GNU Library General/GNU General/g
4943 s/Library General Public License/General Public License/g
4945 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4949 # Determine script to apply to library files that go into $testsbase/.
4950 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
4951 if test -n "$do_copyrights"; then
4952 # Update license.
4953 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
4954 s/GNU Lesser General/GNU General/g
4955 s/Lesser General Public License/General Public License/g
4957 s/GNU Library General/GNU General/g
4958 s/Library General Public License/General Public License/g
4960 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4964 # Determine the final file lists.
4965 func_modules_to_filelist_separately
4967 test -n "$files" \
4968 || func_fatal_error "refusing to do nothing"
4970 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
4971 new_files="$files m4/gnulib-tool.m4"
4972 old_files="$cached_files"
4973 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
4974 func_append old_files " m4/gnulib-tool.m4"
4977 rewritten='%REWRITTEN%'
4978 sed_rewrite_old_files="\
4979 s,^build-aux/,$rewritten$auxdir/,
4980 s,^doc/,$rewritten$cached_docbase/,
4981 s,^lib/,$rewritten$cached_sourcebase/,
4982 s,^m4/,$rewritten$cached_m4base/,
4983 s,^tests/,$rewritten$cached_testsbase/,
4984 s,^tests=lib/,$rewritten$cached_testsbase/,
4985 s,^top/,$rewritten,
4986 s,^$rewritten,,"
4987 sed_rewrite_new_files="\
4988 s,^build-aux/,$rewritten$auxdir/,
4989 s,^doc/,$rewritten$docbase/,
4990 s,^lib/,$rewritten$sourcebase/,
4991 s,^m4/,$rewritten$m4base/,
4992 s,^tests/,$rewritten$testsbase/,
4993 s,^tests=lib/,$rewritten$testsbase/,
4994 s,^top/,$rewritten,
4995 s,^$rewritten,,"
4997 # Create directories.
4998 { echo "$sourcebase"
4999 echo "$m4base"
5000 if test -n "$pobase"; then
5001 echo "$pobase"
5003 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
5004 if test -n "$docfiles"; then
5005 echo "$docbase"
5007 if $inctests; then
5008 echo "$testsbase"
5010 echo "$auxdir"
5011 for f in $files; do echo $f; done \
5012 | sed -e "$sed_rewrite_new_files" \
5013 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5014 | LC_ALL=C sort -u
5015 } > "$tmp"/dirs
5016 { # Rearrange file descriptors. Needed because "while ... done < ..."
5017 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5018 exec 5<&0 < "$tmp"/dirs
5019 while read d; do
5020 if test ! -d "$destdir/$d"; then
5021 if $doit; then
5022 echo "Creating directory $destdir/$d"
5023 mkdir -p "$destdir/$d" || func_fatal_error "failed"
5024 else
5025 echo "Create directory $destdir/$d"
5028 done
5029 exec 0<&5 5<&-
5032 # Copy files or make symbolic links or hard links. Remove obsolete files.
5033 added_files=''
5034 removed_files=''
5035 delimiter=' '
5036 # Construct a table with 2 columns: rewritten-file-name original-file-name,
5037 # representing the files according to the last gnulib-tool invocation.
5038 for f in $old_files; do echo $f; done \
5039 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
5040 | LC_ALL=C sort \
5041 > "$tmp"/old-files
5042 # Construct a table with 2 columns: rewritten-file-name original-file-name,
5043 # representing the files after this gnulib-tool invocation.
5044 for f in $new_files; do echo $f; done \
5045 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
5046 | LC_ALL=C sort \
5047 > "$tmp"/new-files
5048 # First the files that are in old-files, but not in new-files:
5049 sed_take_first_column='s,'"$delimiter"'.*,,'
5050 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
5051 # Remove the file. Do nothing if the user already removed it.
5052 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
5053 if $doit; then
5054 echo "Removing file $g (backup in ${g}~)"
5055 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
5056 else
5057 echo "Remove file $g (backup in ${g}~)"
5059 func_append removed_files "$g$nl"
5061 done
5062 # func_add_or_update handles a file that ought to be present afterwards.
5063 # Uses parameters
5064 # - f the original file name
5065 # - g the rewritten file name
5066 # - already_present nonempty if the file should already exist, empty
5067 # otherwise
5068 func_add_or_update ()
5070 of="$f"
5071 case "$f" in
5072 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
5073 esac
5074 is_binary_file=
5075 case "$f" in
5076 *.class | *.mo ) is_binary_file=true ;;
5077 esac
5078 func_dest_tmpfilename "$g"
5079 func_lookup_file "$f"
5080 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5081 if test -n "$sed_transform_main_lib_file" \
5082 && test -z "$is_binary_file"; then
5083 case "$of" in
5084 lib/*)
5085 sed -e "$sed_transform_main_lib_file" \
5086 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5088 esac
5090 if test -n "$sed_transform_build_aux_file" \
5091 && test -z "$is_binary_file"; then
5092 case "$of" in
5093 build-aux/*)
5094 sed -e "$sed_transform_build_aux_file" \
5095 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5097 esac
5099 if test -n "$sed_transform_testsrelated_lib_file" \
5100 && test -z "$is_binary_file"; then
5101 case "$of" in
5102 tests=lib/*)
5103 sed -e "$sed_transform_testsrelated_lib_file" \
5104 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
5106 esac
5108 if test -f "$destdir/$g"; then
5109 # The file already exists.
5110 func_update_file
5111 else
5112 # Install the file.
5113 # Don't protest if the file should be there but isn't: it happens
5114 # frequently that developers don't put autogenerated files under version control.
5115 func_add_file
5116 func_append added_files "$g$nl"
5118 rm -f "$tmpfile"
5120 # Then the files that are in new-files, but not in old-files:
5121 sed_take_last_column='s,^.*'"$delimiter"',,'
5122 already_present=
5123 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
5124 | sed -e "$sed_take_last_column" \
5125 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
5126 { # Rearrange file descriptors. Needed because "while ... done < ..."
5127 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5128 exec 5<&0 < "$tmp"/added-files
5129 while read g f; do
5130 func_add_or_update
5131 done
5132 exec 0<&5 5<&-
5134 # Then the files that are in new-files and in old-files:
5135 already_present=true
5136 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
5137 | sed -e "$sed_take_last_column" \
5138 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
5139 { # Rearrange file descriptors. Needed because "while ... done < ..."
5140 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5141 exec 5<&0 < "$tmp"/kept-files
5142 while read g f; do
5143 func_add_or_update
5144 done
5145 exec 0<&5 5<&-
5148 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
5149 actioncmd="gnulib-tool --import"
5151 # Local helper.
5152 func_append_local_dir ()
5154 func_append "$1" " --local-dir=$2"
5156 func_path_foreach "$local_gnulib_path" func_append_local_dir actioncmd %dir%
5158 func_append actioncmd " --lib=$libname"
5159 func_append actioncmd " --source-base=$sourcebase"
5160 func_append actioncmd " --m4-base=$m4base"
5161 if test -n "$pobase"; then
5162 func_append actioncmd " --po-base=$pobase"
5164 func_append actioncmd " --doc-base=$docbase"
5165 func_append actioncmd " --tests-base=$testsbase"
5166 func_append actioncmd " --aux-dir=$auxdir"
5167 if $inctests; then
5168 func_append actioncmd " --with-tests"
5170 if test -n "$incobsolete"; then
5171 func_append actioncmd " --with-obsolete"
5173 if test -n "$inc_cxx_tests"; then
5174 func_append actioncmd " --with-c++-tests"
5176 if test -n "$inc_longrunning_tests"; then
5177 func_append actioncmd " --with-longrunning-tests"
5179 if test -n "$inc_privileged_tests"; then
5180 func_append actioncmd " --with-privileged-tests"
5182 if test -n "$inc_unportable_tests"; then
5183 func_append actioncmd " --with-unportable-tests"
5185 if test -n "$inc_all_tests"; then
5186 func_append actioncmd " --with-all-tests"
5188 for module in $avoidlist; do
5189 func_append actioncmd " --avoid=$module"
5190 done
5191 if test -n "$lgpl"; then
5192 if test "$lgpl" = yes; then
5193 func_append actioncmd " --lgpl"
5194 else
5195 func_append actioncmd " --lgpl=$lgpl"
5198 if $gnu_make; then
5199 func_append actioncmd " --gnu-make"
5201 if test -n "$makefile_name"; then
5202 func_append actioncmd " --makefile-name=$makefile_name"
5204 if test "$cond_dependencies" = true; then
5205 func_append actioncmd " --conditional-dependencies"
5206 else
5207 func_append actioncmd " --no-conditional-dependencies"
5209 if test "$libtool" = true; then
5210 func_append actioncmd " --libtool"
5211 else
5212 func_append actioncmd " --no-libtool"
5214 func_append actioncmd " --macro-prefix=$macro_prefix"
5215 if test -n "$po_domain"; then
5216 func_append actioncmd " --po-domain=$po_domain"
5218 if test -n "$witness_c_macro"; then
5219 func_append actioncmd " --witness-c-macro=$witness_c_macro"
5221 if test -n "$vc_files"; then
5222 if test "$vc_files" = true; then
5223 func_append actioncmd " --vc-files"
5224 else
5225 func_append actioncmd " --no-vc-files"
5228 func_append actioncmd " `echo $specified_modules`"
5230 # Determine include_guard_prefix.
5231 func_compute_include_guard_prefix
5233 # Default the makefile name to Makefile.am.
5234 if test -n "$makefile_name"; then
5235 makefile_am=$makefile_name
5236 else
5237 makefile_am=Makefile.am
5240 # Create normal Makefile.ams.
5241 for_test=false
5243 # Setup list of Makefile.am edits that are to be performed afterwards.
5244 # Some of these edits apply to files that we will generate; others are
5245 # under the responsibility of the developer.
5246 makefile_am_edits=0
5247 # func_note_Makefile_am_edit dir var value
5248 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
5249 # ${value}.
5250 func_note_Makefile_am_edit ()
5252 makefile_am_edits=`expr $makefile_am_edits + 1`
5253 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
5254 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
5255 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
5257 if test "$makefile_am" = Makefile.am; then
5258 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
5259 sourcebase_base=`basename "$sourcebase"`
5260 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
5262 if test -n "$pobase"; then
5263 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
5264 pobase_base=`basename "$pobase"`
5265 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
5267 if $inctests; then
5268 if test "$makefile_am" = Makefile.am; then
5269 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
5270 testsbase_base=`basename "$testsbase"`
5271 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
5274 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
5276 # Find the first parent directory of $m4base that contains or will contain
5277 # a Makefile.am.
5278 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
5279 s,//*$,/,'
5280 sed_butlast='s,[^/][^/]*//*$,,'
5281 dir1="${m4base}/"; dir2=""
5282 while test -n "$dir1" \
5283 && ! { test -f "${destdir}/${dir1}Makefile.am" \
5284 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
5285 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
5286 || { $inctests \
5287 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
5288 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
5289 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
5290 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
5291 done
5292 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
5295 # Create library makefile.
5296 func_dest_tmpfilename $sourcebase/$makefile_am
5297 destfile="$sourcebase/$makefile_am"
5298 modules="$main_modules"
5299 func_emit_lib_Makefile_am > "$tmpfile"
5300 if test -f "$destdir"/$sourcebase/$makefile_am; then
5301 if cmp -s "$destdir"/$sourcebase/$makefile_am "$tmpfile"; then
5302 rm -f "$tmpfile"
5303 else
5304 if $doit; then
5305 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
5306 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
5307 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
5308 else
5309 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
5310 rm -f "$tmpfile"
5313 else
5314 if $doit; then
5315 echo "Creating $sourcebase/$makefile_am"
5316 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
5317 else
5318 echo "Create $sourcebase/$makefile_am"
5319 rm -f "$tmpfile"
5321 func_append added_files "$sourcebase/$makefile_am$nl"
5324 # Create po/ directory.
5325 if test -n "$pobase"; then
5326 # Create po makefile and auxiliary files.
5327 for file in Makefile.in.in remove-potcdate.sin; do
5328 func_dest_tmpfilename $pobase/$file
5329 func_lookup_file build-aux/po/$file
5330 cat "$lookedup_file" > "$tmpfile"
5331 if test -f "$destdir"/$pobase/$file; then
5332 if cmp -s "$destdir"/$pobase/$file "$tmpfile"; then
5333 rm -f "$tmpfile"
5334 else
5335 if $doit; then
5336 echo "Updating $pobase/$file (backup in $pobase/$file~)"
5337 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
5338 mv -f "$tmpfile" "$destdir"/$pobase/$file
5339 else
5340 echo "Update $pobase/$file (backup in $pobase/$file~)"
5341 rm -f "$tmpfile"
5344 else
5345 if $doit; then
5346 echo "Creating $pobase/$file"
5347 mv -f "$tmpfile" "$destdir"/$pobase/$file
5348 else
5349 echo "Create $pobase/$file"
5350 rm -f "$tmpfile"
5352 func_append added_files "$pobase/$file$nl"
5354 done
5355 # Create po makefile parameterization, part 1.
5356 func_dest_tmpfilename $pobase/Makevars
5357 func_emit_po_Makevars > "$tmpfile"
5358 if test -f "$destdir"/$pobase/Makevars; then
5359 if cmp -s "$destdir"/$pobase/Makevars "$tmpfile"; then
5360 rm -f "$tmpfile"
5361 else
5362 if $doit; then
5363 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
5364 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
5365 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5366 else
5367 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
5368 rm -f "$tmpfile"
5371 else
5372 if $doit; then
5373 echo "Creating $pobase/Makevars"
5374 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5375 else
5376 echo "Create $pobase/Makevars"
5377 rm -f "$tmpfile"
5379 func_append added_files "$pobase/Makevars$nl"
5381 # Create po makefile parameterization, part 2.
5382 func_dest_tmpfilename $pobase/POTFILES.in
5383 func_emit_po_POTFILES_in > "$tmpfile"
5384 if test -f "$destdir"/$pobase/POTFILES.in; then
5385 if cmp -s "$destdir"/$pobase/POTFILES.in "$tmpfile"; then
5386 rm -f "$tmpfile"
5387 else
5388 if $doit; then
5389 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5390 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
5391 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5392 else
5393 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5394 rm -f "$tmpfile"
5397 else
5398 if $doit; then
5399 echo "Creating $pobase/POTFILES.in"
5400 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5401 else
5402 echo "Create $pobase/POTFILES.in"
5403 rm -f "$tmpfile"
5405 func_append added_files "$pobase/POTFILES.in$nl"
5407 # Fetch PO files.
5408 TP_URL="http://translationproject.org/latest/"
5409 TP_RSYNC_URI="translationproject.org::tp/latest/"
5410 if $doit; then
5411 echo "Fetching gnulib PO files from $TP_URL"
5412 (cd "$destdir"/$pobase \
5413 && { # Prefer rsync over wget if it is available, since it consumes
5414 # less network bandwidth, due to compression.
5415 if type rsync 2>/dev/null | grep / > /dev/null; then
5416 rsync --delete --exclude "*.s1" -Lrtz "${TP_RSYNC_URI}gnulib/" . && return
5419 wget --no-verbose --mirror -nd -np -A.po -P . "${TP_URL}gnulib/"
5422 else
5423 echo "Fetch gnulib PO files from $TP_URL"
5425 # Create po/LINGUAS.
5426 if $doit; then
5427 func_dest_tmpfilename $pobase/LINGUAS
5428 (cd "$destdir"/$pobase \
5429 && { echo '# Set of available languages.'
5430 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
5432 ) > "$tmpfile"
5433 if test -f "$destdir"/$pobase/LINGUAS; then
5434 if cmp -s "$destdir"/$pobase/LINGUAS "$tmpfile"; then
5435 rm -f "$tmpfile"
5436 else
5437 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5438 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
5439 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5441 else
5442 echo "Creating $pobase/LINGUAS"
5443 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5444 func_append added_files "$pobase/LINGUAS$nl"
5446 else
5447 if test -f "$destdir"/$pobase/LINGUAS; then
5448 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5449 else
5450 echo "Create $pobase/LINGUAS"
5455 # func_count_relative_local_gnulib_path
5456 # gl_LOCAL_DIR requires local_gnulib_path to be set relatively to destdir
5457 # Input:
5458 # - local_gnulib_path from --local-dir
5459 # - destdir from --dir
5460 # Output:
5461 # - relative_local_dir path to be stored into gl_LOCAL_DIR
5462 func_count_relative_local_gnulib_path ()
5464 save_IFS=$IFS
5465 IFS=$PATH_SEPARATOR
5466 relative_local_gnulib_path=
5467 for local_dir in $local_gnulib_path
5469 # Store the local_dir relative to destdir.
5470 case "$local_dir" in
5471 "" | /*)
5472 relative_local_dir="$local_dir" ;;
5474 case "$destdir" in
5475 /*) relative_local_dir="$local_dir" ;;
5477 # destdir, local_dir are both relative.
5478 func_relativize "$destdir" "$local_dir"
5479 relative_local_dir="$reldir" ;;
5480 esac ;;
5481 esac
5482 func_path_append relative_local_gnulib_path "$relative_local_dir"
5483 done
5484 IFS=$save_IFS
5487 # Create m4/gnulib-cache.m4.
5488 func_dest_tmpfilename $m4base/gnulib-cache.m4
5490 func_emit_copyright_notice
5491 echo "#"
5492 echo "# This file represents the specification of how gnulib-tool is used."
5493 echo "# It acts as a cache: It is written and read by gnulib-tool."
5494 echo "# In projects that use version control, this file is meant to be put under"
5495 echo "# version control, like the configure.ac and various Makefile.am files."
5496 echo
5497 echo
5498 echo "# Specification in the form of a command-line invocation:"
5499 echo "# $actioncmd"
5500 echo
5501 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
5502 func_count_relative_local_gnulib_path
5503 echo "gl_LOCAL_DIR([$relative_local_gnulib_path])"
5504 echo "gl_MODULES(["
5505 echo "$specified_modules" | sed -e 's/^/ /g'
5506 echo "])"
5507 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
5508 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
5509 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
5510 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
5511 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
5512 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
5513 echo "gl_AVOID([$avoidlist])"
5514 echo "gl_SOURCE_BASE([$sourcebase])"
5515 echo "gl_M4_BASE([$m4base])"
5516 echo "gl_PO_BASE([$pobase])"
5517 echo "gl_DOC_BASE([$docbase])"
5518 echo "gl_TESTS_BASE([$testsbase])"
5519 if $inctests; then
5520 echo "gl_WITH_TESTS"
5522 echo "gl_LIB([$libname])"
5523 if test -n "$lgpl"; then
5524 if test "$lgpl" = yes; then
5525 echo "gl_LGPL"
5526 else
5527 echo "gl_LGPL([$lgpl])"
5530 echo "gl_MAKEFILE_NAME([$makefile_name])"
5531 if test "$cond_dependencies" = true; then
5532 echo "gl_CONDITIONAL_DEPENDENCIES"
5534 if test "$libtool" = true; then
5535 echo "gl_LIBTOOL"
5537 echo "gl_MACRO_PREFIX([$macro_prefix])"
5538 echo "gl_PO_DOMAIN([$po_domain])"
5539 echo "gl_WITNESS_C_MACRO([$witness_c_macro])"
5540 if test -n "$vc_files"; then
5541 echo "gl_VC_FILES([$vc_files])"
5543 ) > "$tmpfile"
5544 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
5545 if cmp -s "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile"; then
5546 rm -f "$tmpfile"
5547 else
5548 if $doit; then
5549 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5550 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
5551 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5552 else
5553 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5554 if false; then
5555 cat "$tmpfile"
5556 echo
5557 echo "# gnulib-cache.m4 ends here"
5559 rm -f "$tmpfile"
5562 else
5563 if $doit; then
5564 echo "Creating $m4base/gnulib-cache.m4"
5565 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5566 else
5567 echo "Create $m4base/gnulib-cache.m4"
5568 cat "$tmpfile"
5569 rm -f "$tmpfile"
5573 # Create m4/gnulib-comp.m4.
5574 func_dest_tmpfilename $m4base/gnulib-comp.m4
5576 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
5577 func_emit_copyright_notice
5578 echo "#"
5579 echo "# This file represents the compiled summary of the specification in"
5580 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
5581 echo "# to be invoked from configure.ac."
5582 echo "# In projects that use version control, this file can be treated like"
5583 echo "# other built files."
5584 echo
5585 echo
5586 echo "# This macro should be invoked from $configure_ac, in the section"
5587 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
5588 echo "# any checks for libraries, header files, types and library functions."
5589 echo "AC_DEFUN([${macro_prefix}_EARLY],"
5590 echo "["
5591 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5592 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5593 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5594 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5596 func_emit_pre_early_macros : ' ' "$final_modules"
5598 if ! $gnu_make && test -n "$uses_subdirs"; then
5599 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
5601 for module in $final_modules; do
5602 func_verify_module
5603 if test -n "$module"; then
5604 echo "# Code from module $module:"
5605 func_get_autoconf_early_snippet "$module"
5607 done \
5608 | sed -e '/^$/d;' -e 's/^/ /'
5609 echo "])"
5610 echo
5611 echo "# This macro should be invoked from $configure_ac, in the section"
5612 echo "# \"Check for header files, types and library functions\"."
5613 echo "AC_DEFUN([${macro_prefix}_INIT],"
5614 echo "["
5615 if test "$libtool" = true; then
5616 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5617 echo " gl_cond_libtool=true"
5618 else
5619 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5620 echo " gl_cond_libtool=false"
5621 echo " gl_libdeps="
5622 echo " gl_ltlibdeps="
5624 if test "$auxdir" != "build-aux"; then
5625 sed_replace_build_aux='
5627 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5628 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5631 else
5632 sed_replace_build_aux="$sed_noop"
5634 echo " gl_m4_base='$m4base'"
5635 func_emit_initmacro_start $macro_prefix
5636 echo " gl_source_base='$sourcebase'"
5637 if test -n "$witness_c_macro"; then
5638 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
5640 func_emit_autoconf_snippets "$main_modules" func_verify_module true false true
5641 if test -n "$witness_c_macro"; then
5642 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5644 echo " # End of code from modules"
5645 func_emit_initmacro_end $macro_prefix
5646 echo " gltests_libdeps="
5647 echo " gltests_ltlibdeps="
5648 func_emit_initmacro_start ${macro_prefix}tests
5649 echo " gl_source_base='$testsbase'"
5650 # Define a tests witness macro that depends on the package.
5651 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
5652 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
5653 echo "changequote(,)dnl"
5654 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"
5655 echo "changequote([, ])dnl"
5656 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5657 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5658 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5659 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true true true
5660 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5661 func_emit_initmacro_end ${macro_prefix}tests
5662 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5663 # created using libtool, because libtool already handles the dependencies.
5664 if test "$libtool" != true; then
5665 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5666 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5667 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5668 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5669 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5671 if $use_libtests; then
5672 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5673 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5675 echo "])"
5676 func_emit_initmacro_done $macro_prefix $sourcebase
5677 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5678 echo
5679 echo "# This macro records the list of files which have been installed by"
5680 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
5681 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
5682 echo "$files" | sed -e 's,^, ,'
5683 echo "])"
5684 ) > "$tmpfile"
5685 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
5686 if cmp -s "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile"; then
5687 rm -f "$tmpfile"
5688 else
5689 if $doit; then
5690 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5691 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
5692 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5693 else
5694 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5695 if false; then
5696 cat "$tmpfile"
5697 echo
5698 echo "# gnulib-comp.m4 ends here"
5700 rm -f "$tmpfile"
5703 else
5704 if $doit; then
5705 echo "Creating $m4base/gnulib-comp.m4"
5706 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5707 else
5708 echo "Create $m4base/gnulib-comp.m4"
5709 cat "$tmpfile"
5710 rm -f "$tmpfile"
5714 if $inctests; then
5715 # Create tests makefile.
5716 func_dest_tmpfilename $testsbase/$makefile_am
5717 destfile="$testsbase/$makefile_am"
5718 modules="$testsrelated_modules"
5719 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
5720 if test -f "$destdir"/$testsbase/$makefile_am; then
5721 if cmp -s "$destdir"/$testsbase/$makefile_am "$tmpfile"; then
5722 rm -f "$tmpfile"
5723 else
5724 if $doit; then
5725 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5726 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
5727 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5728 else
5729 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5730 rm -f "$tmpfile"
5733 else
5734 if $doit; then
5735 echo "Creating $testsbase/$makefile_am"
5736 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5737 else
5738 echo "Create $testsbase/$makefile_am"
5739 rm -f "$tmpfile"
5741 func_append added_files "$testsbase/$makefile_am$nl"
5745 if test "$vc_files" != false; then
5746 # Update the .cvsignore and .gitignore files.
5747 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
5748 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
5749 # Treat gnulib-comp.m4 like an added file, even if it already existed.
5750 echo "$m4base/|A|gnulib-comp.m4"
5751 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
5752 { # Rearrange file descriptors. Needed because "while ... done < ..."
5753 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5754 exec 5<&0 < "$tmp"/fileset-changes
5755 func_update_ignorelist ()
5757 ignore="$1"
5758 if test "$ignore" = .gitignore; then
5759 # In a .gitignore file, "foo" applies to the current directory and all
5760 # subdirectories, whereas "/foo" applies to the current directory only.
5761 anchor='/'
5762 escaped_anchor='\/'
5763 doubly_escaped_anchor='\\/'
5764 else
5765 anchor=''
5766 escaped_anchor=''
5767 doubly_escaped_anchor=''
5769 if test -f "$destdir/$dir$ignore"; then
5770 if test -n "$dir_added" || test -n "$dir_removed"; then
5771 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
5772 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
5773 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
5774 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
5775 > "$tmp"/ignore-removed
5777 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
5778 if $doit; then
5779 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5780 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
5781 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
5782 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
5783 } > "$tmp"/sed-ignore-removed
5784 { cat "$destdir/$dir$ignore"~
5785 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
5786 } | sed -f "$tmp"/sed-ignore-removed \
5787 > "$destdir/$dir$ignore"
5788 else
5789 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5793 else
5794 if test -n "$dir_added"; then
5795 if $doit; then
5796 echo "Creating $destdir/$dir$ignore"
5798 if test "$ignore" = .cvsignore; then
5799 echo ".deps"
5800 # Automake generates Makefile rules that create .dirstamp files.
5801 echo ".dirstamp"
5803 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
5804 } > "$destdir/$dir$ignore"
5805 else
5806 echo "Create $destdir/$dir$ignore"
5811 func_done_dir ()
5813 dir="$1"
5814 dir_added="$2"
5815 dir_removed="$3"
5816 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
5817 func_update_ignorelist .cvsignore
5819 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
5820 func_update_ignorelist .gitignore
5823 last_dir=
5824 last_dir_added=
5825 last_dir_removed=
5826 while read line; do
5827 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
5828 next_dir=`echo "$line" | sed -e 's,|.*,,'`
5829 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
5830 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
5831 if test "$next_dir" != "$last_dir"; then
5832 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5833 last_dir="$next_dir"
5834 last_dir_added=
5835 last_dir_removed=
5837 case $op in
5838 A) func_append last_dir_added "$file$nl";;
5839 R) func_append last_dir_removed "$file$nl";;
5840 esac
5841 done
5842 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5843 exec 0<&5 5<&-
5847 echo "Finished."
5848 echo
5849 echo "You may need to add #include directives for the following .h files."
5850 # Intersect $specified_modules and $main_modules
5851 # (since $specified_modules is not necessarily of subset of $main_modules
5852 # - some may have been skipped through --avoid, and since the elements of
5853 # $main_modules but not in $specified_modules can go away without explicit
5854 # notice - through changes in the module dependencies).
5855 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
5856 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
5857 # First the #include <...> directives without #ifs, sorted for convenience,
5858 # then the #include "..." directives without #ifs, sorted for convenience,
5859 # then the #include directives that are surrounded by #ifs. Not sorted.
5860 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
5861 include_directive=`func_get_include_directive "$module"`
5862 case "$nl$include_directive" in
5863 *"$nl#if"*)
5864 echo "$include_directive" 1>&5
5867 echo "$include_directive" | grep -v 'include "' 1>&6
5868 echo "$include_directive" | grep 'include "' 1>&7
5870 esac
5871 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
5873 LC_ALL=C sort -u "$tmp"/include-angles
5874 LC_ALL=C sort -u "$tmp"/include-quotes
5875 cat "$tmp"/include-if
5876 ) | sed -e '/^$/d' -e 's/^/ /'
5877 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
5879 for module in $main_modules; do
5880 func_get_link_directive "$module"
5881 done \
5882 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
5883 if test `wc -l < "$tmp"/link` != 0; then
5884 echo
5885 echo "You may need to use the following Makefile variables when linking."
5886 echo "Use them in <program>_LDADD when linking a program, or"
5887 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
5888 cat "$tmp"/link
5890 rm -f "$tmp"/link
5892 echo
5893 echo "Don't forget to"
5894 if test "$makefile_am" = Makefile.am; then
5895 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5896 else
5897 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
5899 if test -n "$pobase"; then
5900 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
5902 if $inctests; then
5903 if test "$makefile_am" = Makefile.am; then
5904 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5905 else
5906 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
5909 edit=0
5910 while test $edit != $makefile_am_edits; do
5911 edit=`expr $edit + 1`
5912 eval dir=\"\$makefile_am_edit${edit}_dir\"
5913 eval var=\"\$makefile_am_edit${edit}_var\"
5914 eval val=\"\$makefile_am_edit${edit}_val\"
5915 if test -n "$var"; then
5916 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
5918 done
5919 if grep '^ *AC_PROG_CC_STDC' "$configure_ac" > /dev/null; then
5920 position_early_after=AC_PROG_CC_STDC
5921 else
5922 if grep '^ *AC_PROG_CC_C99' "$configure_ac" > /dev/null; then
5923 position_early_after=AC_PROG_CC_C99
5924 else
5925 position_early_after=AC_PROG_CC
5928 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after $position_early_after,"
5929 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
5932 # func_create_testdir testdir modules
5933 # Input:
5934 # - local_gnulib_path from --local-dir
5935 # - modcache true or false, from --cache-modules/--no-cache-modules
5936 # - auxdir directory relative to destdir where to place build aux files
5937 # - inctests true if tests should be included, false otherwise
5938 # - incobsolete true if obsolete modules among dependencies should be
5939 # included, blank otherwise
5940 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
5941 # blank otherwise
5942 # - excl_longrunning_tests true if long-runnings tests should be excluded,
5943 # blank otherwise
5944 # - excl_privileged_tests true if tests that require root privileges should be
5945 # excluded, blank otherwise
5946 # - excl_unportable_tests true if tests that fail on some platforms should be
5947 # excluded, blank otherwise
5948 # - single_configure true if a single configure file should be generated,
5949 # false for a separate configure file for the tests
5950 # - avoidlist list of modules to avoid
5951 # - cond_dependencies true if --conditional-dependencies was given, false if
5952 # --no-conditional-dependencies was given, blank otherwise
5953 # - libtool true if --libtool was given, false if --no-libtool was
5954 # given, blank otherwise
5955 # - copymode copy mode for files in general
5956 # - lcopymode copy mode for files from local_gnulib_path
5957 func_create_testdir ()
5959 testdir="$1"
5960 modules="$2"
5961 if test -z "$modules"; then
5962 # All modules together.
5963 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5964 # Except non-recursive-gnulib-prefix-hack, which represents a nonstandard
5965 # way of using Automake.
5966 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
5967 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
5968 modules=`func_all_modules`
5969 modules=`for m in $modules; do case $m in config-h | non-recursive-gnulib-prefix-hack | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
5971 specified_modules="$modules"
5973 # Canonicalize the list of specified modules.
5974 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
5976 # Test modules which invoke AC_CONFIG_FILES cannot be used with
5977 # --with-tests --single-configure. Avoid them.
5978 if $inctests && $single_configure; then
5979 avoidlist="$avoidlist havelib-tests"
5982 # Unlike in func_import, here we want to include all kinds of tests for the
5983 # directly specified modules, but not for dependencies.
5984 inc_all_direct_tests=true
5985 inc_all_indirect_tests="$inc_all_tests"
5987 # Check that the license of every module is consistent with the license of
5988 # its dependencies.
5989 saved_inctests="$inctests"
5990 # When computing transitive closures, don't consider $module to depend on
5991 # $module-tests. Need this because tests are implicitly GPL and may depend
5992 # on GPL modules - therefore we don't want a warning in this case.
5993 inctests=false
5994 for requested_module in $specified_modules; do
5995 requested_license=`func_get_license "$requested_module"`
5996 if test "$requested_license" != GPL; then
5997 # Here we use func_modules_transitive_closure, not just
5998 # func_get_dependencies, so that we also detect weird situations like
5999 # an LGPL module which depends on a GPLed build tool module which depends
6000 # on a GPL module.
6001 modules="$requested_module"
6002 func_modules_transitive_closure
6003 for module in $modules; do
6004 license=`func_get_license "$module"`
6005 case "$license" in
6006 'GPLed build tool') ;;
6007 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
6009 case "$requested_license" in
6010 GPLv3+ | GPL)
6011 case "$license" in
6012 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL | GPLv2+ | GPLv3+ | GPL) ;;
6013 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6014 esac
6016 GPLv2+)
6017 case "$license" in
6018 LGPLv2+ | 'LGPLv3+ or GPLv2' | GPLv2+) ;;
6019 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6020 esac
6022 LGPLv3+ | LGPL)
6023 case "$license" in
6024 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL) ;;
6025 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6026 esac
6028 'LGPLv3+ or GPLv2')
6029 case "$license" in
6030 LGPLv2+ | 'LGPLv3+ or GPLv2') ;;
6031 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6032 esac
6034 LGPLv2+)
6035 case "$license" in
6036 LGPLv2+) ;;
6037 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
6038 esac
6040 esac
6042 esac
6043 done
6045 done
6046 inctests="$saved_inctests"
6048 # Subdirectory names.
6049 sourcebase=gllib
6050 m4base=glm4
6051 pobase=
6052 docbase=gldoc
6053 testsbase=gltests
6054 macro_prefix=gl
6055 po_domain=
6056 witness_c_macro=
6057 vc_files=
6059 # Determine final module list.
6060 modules="$specified_modules"
6061 func_modules_transitive_closure
6062 if test $verbose -ge 0; then
6063 func_show_module_list
6065 final_modules="$modules"
6067 if $single_configure; then
6068 # Determine main module list and tests-related module list separately.
6069 func_modules_transitive_closure_separately
6072 if $single_configure; then
6073 # Determine whether a $testsbase/libtests.a is needed.
6074 func_determine_use_libtests
6077 # Add the dummy module if needed.
6078 if $single_configure; then
6079 func_modules_add_dummy_separately
6080 else
6081 func_modules_add_dummy
6084 # Show banner notice of every module.
6085 if $single_configure; then
6086 modules="$main_modules"
6087 func_modules_notice
6088 else
6089 func_modules_notice
6092 # Determine final file list.
6093 if $single_configure; then
6094 func_modules_to_filelist_separately
6095 else
6096 func_modules_to_filelist
6097 if test $verbose -ge 0; then
6098 echo "File list:"
6099 echo "$files" | sed -e 's/^/ /'
6102 # Add files for which the copy in gnulib is newer than the one that
6103 # "automake --add-missing --copy" would provide.
6104 files="$files build-aux/config.guess"
6105 files="$files build-aux/config.sub"
6106 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
6108 rewritten='%REWRITTEN%'
6109 sed_rewrite_files="\
6110 s,^build-aux/,$rewritten$auxdir/,
6111 s,^doc/,$rewritten$docbase/,
6112 s,^lib/,$rewritten$sourcebase/,
6113 s,^m4/,$rewritten$m4base/,
6114 s,^tests/,$rewritten$testsbase/,
6115 s,^tests=lib/,$rewritten$testsbase/,
6116 s,^top/,$rewritten,
6117 s,^$rewritten,,"
6119 # Create directories.
6120 for f in $files; do echo $f; done \
6121 | sed -e "$sed_rewrite_files" \
6122 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
6123 | LC_ALL=C sort -u \
6124 > "$tmp"/dirs
6125 { # Rearrange file descriptors. Needed because "while ... done < ..."
6126 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
6127 exec 5<&0 < "$tmp"/dirs
6128 while read d; do
6129 mkdir -p "$testdir/$d"
6130 done
6131 exec 0<&5 5<&-
6134 # Copy files or make symbolic links or hard links.
6135 delimiter=' '
6136 for f in $files; do echo $f; done \
6137 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
6138 | LC_ALL=C sort \
6139 > "$tmp"/files
6140 { # Rearrange file descriptors. Needed because "while ... done < ..."
6141 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
6142 exec 5<&0 < "$tmp"/files
6143 while read g f; do
6144 case "$f" in
6145 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
6146 esac
6147 func_lookup_file "$f"
6148 if test -n "$lookedup_tmp"; then
6149 cp -p "$lookedup_file" "$testdir/$g"
6150 else
6151 func_should_link
6152 if test "$copyaction" = symlink; then
6153 func_symlink "$lookedup_file" "$testdir/$g"
6154 else
6155 if test "$copyaction" = hardlink; then
6156 func_hardlink "$lookedup_file" "$testdir/$g"
6157 else
6158 cp -p "$lookedup_file" "$testdir/$g"
6162 done
6163 exec 0<&5 5<&-
6166 # Determine include_guard_prefix.
6167 func_compute_include_guard_prefix
6169 # Create Makefile.ams that are for testing.
6170 for_test=true
6172 # No special edits are needed.
6173 makefile_am_edits=0
6175 # Create $sourcebase/Makefile.am.
6176 mkdir -p "$testdir/$sourcebase"
6177 destfile="$sourcebase/Makefile.am"
6178 if $single_configure; then
6179 modules="$main_modules"
6181 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
6182 any_uses_subdirs="$uses_subdirs"
6184 # Create $m4base/Makefile.am.
6185 mkdir -p "$testdir/$m4base"
6186 (echo "## Process this file with automake to produce Makefile.in."
6187 echo
6188 echo "EXTRA_DIST ="
6189 for f in $files; do
6190 case "$f" in
6191 m4/* )
6192 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
6193 esac
6194 done
6195 ) > "$testdir/$m4base/Makefile.am"
6197 subdirs="$sourcebase $m4base"
6198 subdirs_with_configure_ac=""
6200 if false && test -f "$testdir"/$m4base/gettext.m4; then
6201 # Avoid stupid error message from automake:
6202 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
6203 mkdir -p "$testdir/po"
6204 (echo "## Process this file with automake to produce Makefile.in."
6205 ) > "$testdir/po/Makefile.am"
6206 func_append subdirs " po"
6209 if $inctests; then
6210 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
6211 if $single_configure; then
6212 # Create $testsbase/Makefile.am.
6213 destfile="$testsbase/Makefile.am"
6214 modules="$testsrelated_modules"
6215 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$testdir/$testsbase/Makefile.am"
6216 else
6217 # Viewed from the $testsbase subdirectory, $auxdir is different.
6218 saved_auxdir="$auxdir"
6219 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
6220 # Create $testsbase/Makefile.am.
6221 use_libtests=false
6222 destfile="$testsbase/Makefile.am"
6223 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
6224 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
6225 # Create $testsbase/configure.ac.
6226 (echo "# Process this file with autoconf to produce a configure script."
6227 echo "AC_INIT([dummy], [0])"
6228 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6229 echo "AM_INIT_AUTOMAKE"
6230 echo
6231 echo "AC_CONFIG_HEADERS([config.h])"
6232 echo
6233 echo "AC_PROG_CC"
6234 echo "AC_PROG_INSTALL"
6235 echo "AC_PROG_MAKE_SET"
6237 func_emit_pre_early_macros false '' "$modules"
6239 if test -n "$uses_subdirs"; then
6240 echo "AM_PROG_CC_C_O"
6241 echo
6243 for module in $modules; do
6244 func_verify_module
6245 if test -n "$module"; then
6246 case $module in
6247 gnumakefile | maintainer-makefile)
6248 # These modules are meant to be used only in the top-level directory.
6251 func_get_autoconf_early_snippet "$module"
6253 esac
6255 done \
6256 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
6257 if test "$libtool" = true; then
6258 echo "LT_INIT([win32-dll])"
6259 echo "LT_LANG([C++])"
6260 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6261 echo "gl_cond_libtool=true"
6262 else
6263 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6264 echo "gl_cond_libtool=false"
6265 echo "gl_libdeps="
6266 echo "gl_ltlibdeps="
6268 # Wrap the set of autoconf snippets into an autoconf macro that is then
6269 # invoked. This is needed because autoconf does not support AC_REQUIRE
6270 # at the top level:
6271 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6272 # but we want the AC_REQUIRE to have its normal meaning (provide one
6273 # expansion of the required macro before the current point, and only one
6274 # expansion total).
6275 echo "AC_DEFUN([gl_INIT], ["
6276 sed_replace_build_aux='
6278 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6279 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6282 echo "gl_m4_base='../$m4base'"
6283 func_emit_initmacro_start $macro_prefix
6284 # We don't have explicit ordering constraints between the various
6285 # autoconf snippets. It's cleanest to put those of the library before
6286 # those of the tests.
6287 echo "gl_source_base='../$sourcebase'"
6288 func_emit_autoconf_snippets "$modules" func_verify_nontests_module false false false
6289 echo "gl_source_base='.'"
6290 func_emit_autoconf_snippets "$modules" func_verify_tests_module false false false
6291 func_emit_initmacro_end $macro_prefix
6292 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6293 # created using libtool, because libtool already handles the dependencies.
6294 if test "$libtool" != true; then
6295 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6296 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6297 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6298 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6299 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6301 echo "])"
6302 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
6303 echo
6304 echo "gl_INIT"
6305 echo
6306 # Usually $testsbase/config.h will be a superset of config.h. Verify this
6307 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
6308 echo "AH_TOP([#include \"../config.h\"])"
6309 echo
6310 echo "AC_CONFIG_FILES([Makefile])"
6311 echo "AC_OUTPUT"
6312 ) > "$testdir/$testsbase/configure.ac"
6313 auxdir="$saved_auxdir"
6314 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
6316 func_append subdirs " $testsbase"
6319 # Create Makefile.am.
6320 (echo "## Process this file with automake to produce Makefile.in."
6321 echo
6322 echo "AUTOMAKE_OPTIONS = 1.9.6 foreign"
6323 echo
6324 echo "SUBDIRS = $subdirs"
6325 echo
6326 echo "ACLOCAL_AMFLAGS = -I $m4base"
6327 ) > "$testdir/Makefile.am"
6329 # Create configure.ac.
6330 (echo "# Process this file with autoconf to produce a configure script."
6331 echo "AC_INIT([dummy], [0])"
6332 if test "$auxdir" != "."; then
6333 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6335 echo "AM_INIT_AUTOMAKE"
6336 echo
6337 echo "AC_CONFIG_HEADERS([config.h])"
6338 echo
6339 echo "AC_PROG_CC"
6340 echo "AC_PROG_INSTALL"
6341 echo "AC_PROG_MAKE_SET"
6342 echo
6343 echo "# For autobuild."
6344 echo "AC_CANONICAL_BUILD"
6345 echo "AC_CANONICAL_HOST"
6346 echo
6347 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
6348 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
6349 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
6350 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
6352 func_emit_pre_early_macros false '' "$final_modules"
6354 if test -n "$any_uses_subdirs"; then
6355 echo "AM_PROG_CC_C_O"
6356 echo
6358 for module in $final_modules; do
6359 if $single_configure; then
6360 func_verify_module
6361 else
6362 func_verify_nontests_module
6364 if test -n "$module"; then
6365 func_get_autoconf_early_snippet "$module"
6367 done \
6368 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
6369 if test "$libtool" = true; then
6370 echo "LT_INIT([win32-dll])"
6371 echo "LT_LANG([C++])"
6372 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6373 echo "gl_cond_libtool=true"
6374 else
6375 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6376 echo "gl_cond_libtool=false"
6377 echo "gl_libdeps="
6378 echo "gl_ltlibdeps="
6380 # Wrap the set of autoconf snippets into an autoconf macro that is then
6381 # invoked. This is needed because autoconf does not support AC_REQUIRE
6382 # at the top level:
6383 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6384 # but we want the AC_REQUIRE to have its normal meaning (provide one
6385 # expansion of the required macro before the current point, and only one
6386 # expansion total).
6387 echo "AC_DEFUN([gl_INIT], ["
6388 if test "$auxdir" != "build-aux"; then
6389 sed_replace_build_aux='
6391 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6392 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6395 else
6396 sed_replace_build_aux="$sed_noop"
6398 echo "gl_m4_base='$m4base'"
6399 func_emit_initmacro_start $macro_prefix
6400 echo "gl_source_base='$sourcebase'"
6401 if $single_configure; then
6402 func_emit_autoconf_snippets "$main_modules" func_verify_module true false false
6403 else
6404 func_emit_autoconf_snippets "$modules" func_verify_nontests_module true false false
6406 func_emit_initmacro_end $macro_prefix
6407 if $single_configure; then
6408 echo " gltests_libdeps="
6409 echo " gltests_ltlibdeps="
6410 func_emit_initmacro_start ${macro_prefix}tests
6411 echo " gl_source_base='$testsbase'"
6412 # Define a tests witness macro.
6413 echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
6414 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
6415 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
6416 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
6417 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true false false
6418 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
6419 func_emit_initmacro_end ${macro_prefix}tests
6421 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6422 # created using libtool, because libtool already handles the dependencies.
6423 if test "$libtool" != true; then
6424 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6425 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6426 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6427 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6428 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6430 if $single_configure; then
6431 if $use_libtests; then
6432 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
6433 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
6436 echo "])"
6437 func_emit_initmacro_done $macro_prefix $sourcebase
6438 if $single_configure; then
6439 func_emit_initmacro_done ${macro_prefix}tests $testsbase
6441 echo
6442 echo "gl_INIT"
6443 echo
6444 if test -n "$subdirs_with_configure_ac"; then
6445 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
6447 makefiles="Makefile"
6448 for d in $subdirs; do
6449 # For subdirs that have a configure.ac by their own, it's the subdir's
6450 # configure.ac which creates the subdir's Makefile.am, not this one.
6451 case " $subdirs_with_configure_ac " in
6452 *" $d "*) ;;
6453 *) func_append makefiles " $d/Makefile" ;;
6454 esac
6455 done
6456 echo "AC_CONFIG_FILES([$makefiles])"
6457 echo "AC_OUTPUT"
6458 ) > "$testdir/configure.ac"
6460 # Create autogenerated files.
6461 (cd "$testdir"
6462 # Do not use "${AUTORECONF} --force --install", because it may invoke
6463 # autopoint, which brings in older versions of some of our .m4 files.
6464 if test -f $m4base/gettext.m4; then
6465 func_execute_command ${AUTOPOINT} --force || func_exit 1
6466 for f in $m4base/*.m4~; do
6467 if test -f $f; then
6468 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6470 done
6472 if test "$libtool" = true; then
6473 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
6475 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
6476 if ! test -d build-aux; then
6477 func_execute_command mkdir build-aux || func_exit 1
6479 func_execute_command ${AUTOCONF} || func_exit 1
6480 func_execute_command ${AUTOHEADER} || func_exit 1
6481 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6482 rm -rf autom4te.cache
6483 ) || func_exit 1
6484 if $inctests && ! $single_configure; then
6485 # Create autogenerated files.
6486 (cd "$testdir/$testsbase" || func_exit 1
6487 # Do not use "${AUTORECONF} --force --install", because it may invoke
6488 # autopoint, which brings in older versions of some of our .m4 files.
6489 if test -f ../$m4base/gettext.m4; then
6490 func_execute_command ${AUTOPOINT} --force || func_exit 1
6491 for f in ../$m4base/*.m4~; do
6492 if test -f $f; then
6493 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6495 done
6497 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
6498 if ! test -d ../build-aux; then
6499 func_execute_command mkdir ../build-aux
6501 func_execute_command ${AUTOCONF} || func_exit 1
6502 func_execute_command ${AUTOHEADER} || func_exit 1
6503 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6504 rm -rf autom4te.cache
6505 ) || func_exit 1
6507 # Need to run configure and make once, to create built files that are to be
6508 # distributed (such as parse-datetime.c).
6509 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
6510 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
6511 cleaned_files=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
6512 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6513 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
6514 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
6515 # such $(FOO_H) because they don't refer to distributed files.
6516 built_sources=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
6517 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6518 | sed -e "$sed_remove_make_variables"`
6519 distributed_built_sources=`for file in $built_sources; do
6520 case "$cleaned_files" in
6521 *" "$file" "*) ;;
6522 *) echo $file ;;
6523 esac;
6524 done`
6525 tests_distributed_built_sources=
6526 if $inctests; then
6527 # Likewise for built files in the $testsbase directory.
6528 tests_cleaned_files=`combine_lines < "$testdir/$testsbase/Makefile.am" \
6529 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6530 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
6531 tests_built_sources=`combine_lines < "$testdir/$testsbase/Makefile.am" \
6532 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6533 | sed -e "$sed_remove_make_variables"`
6534 tests_distributed_built_sources=`for file in $tests_built_sources; do
6535 case "$tests_cleaned_files" in
6536 *" "$file" "*) ;;
6537 *) echo $file ;;
6538 esac;
6539 done`
6541 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
6542 (cd "$testdir"
6543 ./configure || func_exit 1
6544 if test -n "$distributed_built_sources"; then
6545 cd "$sourcebase"
6546 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6547 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6548 built_sources \
6549 || func_exit 1
6550 cd ..
6552 if test -n "$tests_distributed_built_sources"; then
6553 cd "$testsbase"
6554 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6555 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6556 built_sources \
6557 || func_exit 1
6558 cd ..
6560 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6561 distclean \
6562 || func_exit 1
6563 ) || func_exit 1
6567 # func_create_megatestdir megatestdir allmodules
6568 # Input:
6569 # - local_gnulib_path from --local-dir
6570 # - modcache true or false, from --cache-modules/--no-cache-modules
6571 # - auxdir directory relative to destdir where to place build aux files
6572 func_create_megatestdir ()
6574 megatestdir="$1"
6575 allmodules="$2"
6576 if test -z "$allmodules"; then
6577 allmodules=`func_all_modules`
6580 megasubdirs=
6581 # First, all modules one by one.
6582 for onemodule in $allmodules; do
6583 func_create_testdir "$megatestdir/$onemodule" $onemodule
6584 func_append megasubdirs "$onemodule "
6585 done
6586 # Then, all modules all together.
6587 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6588 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
6589 func_create_testdir "$megatestdir/ALL" "$allmodules"
6590 func_append megasubdirs "ALL"
6592 # Create autobuild.
6593 cvsdate=`vc_witness="$gnulib_dir/.git/refs/heads/master"; \
6594 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
6595 | sed -e 's,January,01,' -e 's,Jan,01,' \
6596 -e 's,February,02,' -e 's,Feb,02,' \
6597 -e 's,March,03,' -e 's,Mar,03,' \
6598 -e 's,April,04,' -e 's,Apr,04,' \
6599 -e 's,May,05,' \
6600 -e 's,June,06,' -e 's,Jun,06,' \
6601 -e 's,July,07,' -e 's,Jul,07,' \
6602 -e 's,August,08,' -e 's,Aug,08,' \
6603 -e 's,September,09,' -e 's,Sep,09,' \
6604 -e 's,October,10,' -e 's,Oct,10,' \
6605 -e 's,November,11,' -e 's,Nov,11,' \
6606 -e 's,December,12,' -e 's,Dec,12,' \
6607 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
6608 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
6609 (echo '#!/bin/sh'
6610 echo "CVSDATE=$cvsdate"
6611 echo ": \${MAKE=make}"
6612 echo "test -d logs || mkdir logs"
6613 echo "for module in $megasubdirs; do"
6614 echo " echo \"Working on module \$module...\""
6615 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
6616 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
6617 echo " echo"
6618 echo " set -x"
6619 echo " : autobuild project... \$module"
6620 echo " : autobuild revision... cvs-\$CVSDATE-000000"
6621 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
6622 echo " : autobuild hostname... \`hostname\`"
6623 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
6624 echo " echo rc=\$?"
6625 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
6626 echo "done"
6627 ) > "$megatestdir/do-autobuild"
6628 chmod a+x "$megatestdir/do-autobuild"
6630 # Create Makefile.am.
6631 (echo "## Process this file with automake to produce Makefile.in."
6632 echo
6633 echo "AUTOMAKE_OPTIONS = 1.9.6 foreign"
6634 echo
6635 echo "SUBDIRS = $megasubdirs"
6636 echo
6637 echo "EXTRA_DIST = do-autobuild"
6638 ) > "$megatestdir/Makefile.am"
6640 # Create configure.ac.
6641 (echo "# Process this file with autoconf to produce a configure script."
6642 echo "AC_INIT([dummy], [0])"
6643 if test "$auxdir" != "."; then
6644 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6646 echo "AM_INIT_AUTOMAKE"
6647 echo
6648 echo "AC_PROG_MAKE_SET"
6649 echo
6650 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
6651 echo "AC_CONFIG_FILES([Makefile])"
6652 echo "AC_OUTPUT"
6653 ) > "$megatestdir/configure.ac"
6655 # Create autogenerated files.
6656 (cd "$megatestdir"
6657 # Do not use "${AUTORECONF} --install", because autoreconf operates
6658 # recursively, but the subdirectories are already finished, therefore
6659 # calling autoreconf here would only waste lots of CPU time.
6660 func_execute_command ${ACLOCAL} || func_exit 1
6661 func_execute_command mkdir build-aux
6662 func_execute_command ${AUTOCONF} || func_exit 1
6663 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6664 rm -rf autom4te.cache
6665 ) || func_exit 1
6668 case $mode in
6669 "" )
6670 func_fatal_error "no mode specified" ;;
6672 list )
6673 func_all_modules
6676 find )
6677 # sed expression that converts a literal to a basic regular expression.
6678 # Needs to handle . [ \ * ^ $.
6679 sed_literal_to_basic_regex='s/\\/\\\\/g
6680 s/\[/\\[/g
6681 s/\^/\\^/g
6682 s/\([.*$]\)/[\1]/g'
6683 for filename
6685 if test -f "$gnulib_dir/$filename" \
6686 || func_lookup_local_file "$filename"; then
6687 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
6688 filename_line_regex='^'"$filename_anywhere_regex"'$'
6689 module_candidates=`
6691 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
6692 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$,,'
6694 | func_sanitize_modulelist \
6695 | LC_ALL=C sort -u
6697 for module in $module_candidates; do
6698 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
6699 echo $module
6701 done
6702 else
6703 func_warning "file $filename does not exist"
6705 done
6708 import | add-import | remove-import | update )
6710 # Where to import.
6711 if test -z "$destdir"; then
6712 destdir=.
6714 test -d "$destdir" \
6715 || func_fatal_error "destination directory does not exist: $destdir"
6717 # Prefer configure.ac to configure.in.
6718 if test -f "$destdir"/configure.ac; then
6719 configure_ac="$destdir/configure.ac"
6720 else
6721 if test -f "$destdir"/configure.in; then
6722 configure_ac="$destdir/configure.in"
6723 else
6724 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
6728 # Analyze configure.ac.
6729 guessed_auxdir="."
6730 guessed_libtool=false
6731 my_sed_traces='
6732 s,#.*$,,
6733 s,^dnl .*$,,
6734 s, dnl .*$,,
6735 /AC_CONFIG_AUX_DIR/ {
6736 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
6738 /A[CM]_PROG_LIBTOOL/ {
6739 s,^.*$,guessed_libtool=true,p
6741 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
6743 if test -z "$auxdir"; then
6744 auxdir="$guessed_auxdir"
6747 # Determine where to apply func_import.
6748 if test "$mode" = import; then
6749 # Apply func_import to a particular gnulib directory.
6750 # The command line contains the complete specification; don't look at
6751 # the contents of gnulib-cache.m4.
6752 test -n "$supplied_libname" || supplied_libname=true
6753 test -n "$sourcebase" || sourcebase="lib"
6754 test -n "$m4base" || m4base="m4"
6755 test -n "$docbase" || docbase="doc"
6756 test -n "$testsbase" || testsbase="tests"
6757 test -n "$macro_prefix" || macro_prefix="gl"
6758 func_import "$*"
6759 else
6760 if test -n "$m4base"; then
6761 # Apply func_import to a particular gnulib directory.
6762 # Any number of additional modules can be given.
6763 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
6764 # First use of gnulib in the given m4base.
6765 test -n "$supplied_libname" || supplied_libname=true
6766 test -n "$sourcebase" || sourcebase="lib"
6767 test -n "$docbase" || docbase="doc"
6768 test -n "$testsbase" || testsbase="tests"
6769 test -n "$macro_prefix" || macro_prefix="gl"
6771 func_import "$*"
6772 else
6773 # Apply func_import to all gnulib directories.
6774 # To get this list of directories, look at Makefile.am. (Not at
6775 # configure, because it may be omitted from version control. Also,
6776 # don't run "find $destdir -name gnulib-cache.m4", as it might be
6777 # too expensive.)
6778 m4dirs=
6779 m4dirs_count=0
6780 if test -f "$destdir"/Makefile.am; then
6781 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
6782 m4dir_is_next=
6783 for arg in $aclocal_amflags; do
6784 if test -n "$m4dir_is_next"; then
6785 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
6786 case "$arg" in
6787 /*) ;;
6789 if test -f "$destdir/$arg"/gnulib-cache.m4; then
6790 func_append m4dirs " $arg"
6791 m4dirs_count=`expr $m4dirs_count + 1`
6794 esac
6795 m4dir_is_next=
6796 else
6797 if test "X$arg" = "X-I"; then
6798 m4dir_is_next=yes
6799 else
6800 m4dir_is_next=
6803 done
6804 else
6805 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
6806 if test -f "$destdir"/aclocal.m4; then
6807 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
6808 sedexpr2='s,^[^/]*$,.,'
6809 sedexpr3='s,/[^/]*$,,'
6810 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
6811 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
6812 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
6815 if test $m4dirs_count = 0; then
6816 # First use of gnulib in a package.
6817 # Any number of additional modules can be given.
6818 test -n "$supplied_libname" || supplied_libname=true
6819 test -n "$sourcebase" || sourcebase="lib"
6820 m4base="m4"
6821 test -n "$docbase" || docbase="doc"
6822 test -n "$testsbase" || testsbase="tests"
6823 test -n "$macro_prefix" || macro_prefix="gl"
6824 func_import "$*"
6825 else
6826 if test $m4dirs_count = 1; then
6827 # There's only one use of gnulib here. Assume the user means it.
6828 # Any number of additional modules can be given.
6829 for m4base in $m4dirs; do
6830 func_import "$*"
6831 done
6832 else
6833 # Ambiguous - guess what the user meant.
6834 if test $# = 0; then
6835 # No further arguments. Guess the user wants to update all of them.
6836 for m4base in $m4dirs; do
6837 # Perform func_import in a subshell, so that variable values
6838 # such as
6839 # local_gnulib_path, incobsolete, inc_cxx_tests,
6840 # inc_longrunning_tests, inc_privileged_tests,
6841 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
6842 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
6843 # makefile_name, libtool, macro_prefix, po_domain,
6844 # witness_c_macro, vc_files
6845 # don't propagate from one directory to another.
6846 (func_import) || func_exit 1
6847 done
6848 else
6849 # Really ambiguous.
6850 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
6858 create-testdir )
6859 if test -z "$destdir"; then
6860 func_fatal_error "please specify --dir option"
6862 mkdir "$destdir"
6863 test -d "$destdir" \
6864 || func_fatal_error "could not create destination directory"
6865 test -n "$auxdir" || auxdir="build-aux"
6866 func_create_testdir "$destdir" "$*"
6869 create-megatestdir )
6870 if test -z "$destdir"; then
6871 func_fatal_error "please specify --dir option"
6873 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6874 test -n "$auxdir" || auxdir="build-aux"
6875 func_create_megatestdir "$destdir" "$*"
6878 test )
6879 test -n "$destdir" || destdir=testdir$$
6880 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6881 test -n "$auxdir" || auxdir="build-aux"
6882 func_create_testdir "$destdir" "$*"
6883 cd "$destdir"
6884 mkdir build
6885 cd build
6886 ../configure || func_exit 1
6887 $MAKE || func_exit 1
6888 $MAKE check || func_exit 1
6889 $MAKE distclean || func_exit 1
6890 remaining=`find . -type f -print`
6891 if test -n "$remaining"; then
6892 echo "Remaining files:" $remaining 1>&2
6893 echo "gnulib-tool: *** Stop." 1>&2
6894 func_exit 1
6896 cd ..
6897 cd ..
6898 rm -rf "$destdir"
6901 megatest )
6902 test -n "$destdir" || destdir=testdir$$
6903 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6904 test -n "$auxdir" || auxdir="build-aux"
6905 func_create_megatestdir "$destdir" "$*"
6906 cd "$destdir"
6907 mkdir build
6908 cd build
6909 ../configure
6910 $MAKE
6911 $MAKE check
6912 $MAKE distclean
6913 remaining=`find . -type f -print`
6914 if test -n "$remaining"; then
6915 echo "Remaining files:" $remaining 1>&2
6916 echo "gnulib-tool: *** Stop." 1>&2
6917 func_exit 1
6919 cd ..
6920 cd ..
6921 rm -rf "$destdir"
6924 extract-description )
6925 for module
6927 func_verify_module
6928 if test -n "$module"; then
6929 func_get_description "$module"
6931 done
6934 extract-comment )
6935 for module
6937 func_verify_module
6938 if test -n "$module"; then
6939 func_get_comment "$module"
6941 done
6944 extract-status )
6945 for module
6947 func_verify_module
6948 if test -n "$module"; then
6949 func_get_status "$module"
6951 done
6954 extract-notice )
6955 for module
6957 func_verify_module
6958 if test -n "$module"; then
6959 func_get_notice "$module"
6961 done
6964 extract-applicability )
6965 for module
6967 func_verify_module
6968 if test -n "$module"; then
6969 func_get_applicability "$module"
6971 done
6974 extract-filelist )
6975 for module
6977 func_verify_module
6978 if test -n "$module"; then
6979 func_get_filelist "$module"
6981 done
6984 extract-dependencies )
6985 if test -n "$avoidlist"; then
6986 func_fatal_error "cannot combine --avoid and --extract-dependencies"
6988 for module
6990 func_verify_module
6991 if test -n "$module"; then
6992 func_get_dependencies "$module"
6994 done
6997 extract-autoconf-snippet )
6998 for module
7000 func_verify_module
7001 if test -n "$module"; then
7002 func_get_autoconf_snippet "$module"
7004 done
7007 extract-automake-snippet )
7008 for module
7010 func_verify_module
7011 if test -n "$module"; then
7012 func_get_automake_snippet "$module"
7014 done
7017 extract-include-directive )
7018 for module
7020 func_verify_module
7021 if test -n "$module"; then
7022 func_get_include_directive "$module"
7024 done
7027 extract-link-directive )
7028 for module
7030 func_verify_module
7031 if test -n "$module"; then
7032 func_get_link_directive "$module"
7034 done
7037 extract-license )
7038 for module
7040 func_verify_module
7041 if test -n "$module"; then
7042 func_get_license "$module"
7044 done
7047 extract-maintainer )
7048 for module
7050 func_verify_module
7051 if test -n "$module"; then
7052 func_get_maintainer "$module"
7054 done
7057 extract-tests-module )
7058 for module
7060 func_verify_module
7061 if test -n "$module"; then
7062 func_get_tests_module "$module"
7064 done
7067 copy-file )
7068 # Verify the number of arguments.
7069 if test $# -lt 1 || test $# -gt 2; then
7070 func_fatal_error "invalid number of arguments for --$mode"
7073 # The first argument is the file to be copied.
7074 f="$1"
7075 # Verify the file exists.
7076 func_lookup_file "$f"
7078 # The second argument is the destination; either a directory ot a file.
7079 # It defaults to the current directory.
7080 dest="$2"
7081 test -n "$dest" || dest='.'
7082 test -n "$sourcebase" || sourcebase="lib"
7083 test -n "$m4base" || m4base="m4"
7084 test -n "$docbase" || docbase="doc"
7085 test -n "$testsbase" || testsbase="tests"
7086 test -n "$auxdir" || auxdir="build-aux"
7087 rewritten='%REWRITTEN%'
7088 sed_rewrite_files="\
7089 s,^build-aux/,$rewritten$auxdir/,
7090 s,^doc/,$rewritten$docbase/,
7091 s,^lib/,$rewritten$sourcebase/,
7092 s,^m4/,$rewritten$m4base/,
7093 s,^tests/,$rewritten$testsbase/,
7094 s,^top/,$rewritten,
7095 s,^$rewritten,,"
7096 if test -d "$dest"; then
7097 destdir="$dest"
7098 g=`echo "$f" | sed -e "$sed_rewrite_files"`
7099 else
7100 destdir=`dirname "$dest"`
7101 g=`basename "$dest"`
7104 # Create the directory for destfile.
7105 d=`dirname "$destdir/$g"`
7106 if $doit; then
7107 if test -n "$d" && test ! -d "$d"; then
7108 mkdir -p "$d" || func_fatal_error "failed"
7111 # Copy the file.
7112 func_dest_tmpfilename "$g"
7113 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
7114 already_present=true
7115 if test -f "$destdir/$g"; then
7116 # The file already exists.
7117 func_update_file
7118 else
7119 # Install the file.
7120 # Don't protest if the file should be there but isn't: it happens
7121 # frequently that developers don't put autogenerated files under version
7122 # control.
7123 func_add_file
7125 rm -f "$tmpfile"
7129 func_fatal_error "unknown operation mode --$mode" ;;
7130 esac
7132 if test "$copymode" = hardlink -o "$lcopymode" = hardlink; then
7133 # Setting hard links modifies the ctime of files in the gnulib checkout.
7134 # This disturbs the result of the next "gitk" invocation.
7135 # Workaround: Let git scan the files. This can be done through
7136 # "git update-index --refresh" or "git status" or "git diff".
7137 if test -d "$gnulib_dir"/.git \
7138 && (git --version) >/dev/null 2>/dev/null; then
7139 (cd "$gnulib_dir" && git update-index --refresh >/dev/null)
7143 rm -rf "$tmp"
7144 # Undo the effect of the previous 'trap' command. Some shellology:
7145 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
7146 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
7147 # exit); for the others we need to call 'exit' explicitly. The value of $? is
7148 # 128 + signal number and is set before the trap-registered command is run.
7149 trap '' 0
7150 trap 'func_exit $?' 1 2 3 13 15
7152 exit 0
7154 # Local Variables:
7155 # indent-tabs-mode: nil
7156 # whitespace-check-buffer-indent: nil
7157 # End: