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