sys_socket: typedef sa_family_t correctly on OS/2 kLIBC
[gnulib.git] / gnulib-tool
blob5145d47bdfafc74ccfd80a9d268f827cb6eee5bf
1 #! /bin/sh
3 # Copyright (C) 2002-2016 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 --lgpl[=2|=3orGPLv2|=3]
268 Abort if modules aren't available under the LGPL.
269 Also modify license template from GPL to LGPL.
270 The version number of the LGPL can be specified;
271 the default is currently LGPLv3.
272 --makefile-name=NAME Name of makefile in automake syntax in the
273 source-base and tests-base directories
274 (default \"Makefile.am\").
275 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
276 'gl_INIT'. Default is 'gl'.
277 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
278 the package name. A suffix '-gnulib' is appended.
279 --witness-c-macro=NAME Specify the C macro that is defined when the
280 sources in this directory are compiled or used.
281 --vc-files Update version control related files.
282 --no-vc-files Don't update version control related files
283 (.gitignore and/or .cvsignore).
285 Options for --create-[mega]testdir, --[mega]test:
287 --single-configure Generate a single configure file, not a separate
288 configure file for the tests directory.
290 Options for --import, --add/remove-import, --update,
291 --create-[mega]testdir, --[mega]test:
293 -s, --symbolic, --symlink Make symbolic links instead of copying files.
294 --local-symlink Make symbolic links instead of copying files, only
295 for files from the local override directory.
297 Options for --import, --add/remove-import, --update:
299 -S, --more-symlinks Make symbolic links instead of copying files, and
300 don't replace copyright notices.
302 Report bugs to <bug-gnulib@gnu.org>."
305 # func_version
306 # outputs to stdout the --version message.
307 func_version ()
309 func_gnulib_dir
310 if test -d "$gnulib_dir"/.git \
311 && (git --version) >/dev/null 2>/dev/null \
312 && (date --version) >/dev/null 2>/dev/null; then
313 # gnulib checked out from git.
314 sed_extract_first_date='/^Date/{
315 s/^Date:[ ]*//p
318 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
319 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
320 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
321 date=`echo "$date" | sed -e "$sed_year_before_time"`
322 # Use GNU date to compute the time in GMT.
323 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
324 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
325 else
326 # gnulib copy without versioning information.
327 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
328 version=
330 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
331 echo "\
332 gnulib-tool (GNU $package $date)$version
333 Copyright (C) $year Free Software Foundation, Inc.
334 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
335 This is free software: you are free to change and redistribute it.
336 There is NO WARRANTY, to the extent permitted by law.
338 printf "Written by %s, %s, and %s.\n" "Bruno Haible" "Paul Eggert" "Simon Josefsson"
341 # func_emit_copyright_notice
342 # outputs to stdout a header for a generated file.
343 func_emit_copyright_notice ()
345 sed -n -e '/Copyright/ {
348 }' < "$self_abspathname"
349 echo "#"
350 echo "# This file is free software; you can redistribute it and/or modify"
351 echo "# it under the terms of the GNU General Public License as published by"
352 echo "# the Free Software Foundation; either version 3 of the License, or"
353 echo "# (at your option) any later version."
354 echo "#"
355 echo "# This file is distributed in the hope that it will be useful,"
356 echo "# but WITHOUT ANY WARRANTY; without even the implied warranty of"
357 echo "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
358 echo "# GNU General Public License for more details."
359 echo "#"
360 echo "# You should have received a copy of the GNU General Public License"
361 echo "# along with this file. If not, see <http://www.gnu.org/licenses/>."
362 echo "#"
363 echo "# As a special exception to the GNU General Public License,"
364 echo "# this file may be distributed as part of a program that"
365 echo "# contains a configuration script generated by Autoconf, under"
366 echo "# the same distribution terms as the rest of that program."
367 echo "#"
368 echo "# Generated by gnulib-tool."
371 # func_exit STATUS
372 # exits with a given status.
373 # This function needs to be used, rather than 'exit', when a 'trap' handler is
374 # in effect that refers to $?.
375 func_exit ()
377 (exit $1); exit $1
380 # func_gnulib_dir
381 # locates the directory where the gnulib repository lives
382 # Input:
383 # - progname name of this program
384 # Sets variables
385 # - self_abspathname absolute pathname of gnulib-tool
386 # - gnulib_dir absolute pathname of gnulib repository
387 func_gnulib_dir ()
389 case "$progname" in
390 /* | ?:*) self_abspathname="$progname" ;;
391 */*) self_abspathname=`pwd`/"$progname" ;;
393 # Look in $PATH.
394 # Iterate through the elements of $PATH.
395 # We use IFS=: instead of
396 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
397 # because the latter does not work when some PATH element contains spaces.
398 # We use a canonicalized $pathx instead of $PATH, because empty PATH
399 # elements are by definition equivalent to '.', however field splitting
400 # according to IFS=: loses empty fields in many shells:
401 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
402 # beginning, at the end, and in the middle),
403 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
404 # at the beginning and at the end,
405 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
406 # Solaris lose empty fields at the end.
407 # The 'case' statement is an optimization, to avoid evaluating the
408 # explicit canonicalization command when $PATH contains no empty fields.
409 self_abspathname=
410 if test "$PATH_SEPARATOR" = ";"; then
411 # On Windows, programs are searched in "." before $PATH.
412 pathx=".;$PATH"
413 else
414 # On Unix, we have to convert empty PATH elements to ".".
415 pathx="$PATH"
416 case :$PATH: in
417 *::*)
418 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
420 esac
422 save_IFS="$IFS"
423 IFS="$PATH_SEPARATOR"
424 for d in $pathx; do
425 IFS="$save_IFS"
426 test -z "$d" && d=.
427 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
428 self_abspathname="$d/$progname"
429 break
431 done
432 IFS="$save_IFS"
433 if test -z "$self_abspathname"; then
434 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
437 esac
438 while test -h "$self_abspathname"; do
439 # Resolve symbolic link.
440 linkval=`func_readlink "$self_abspathname"`
441 test -n "$linkval" || break
442 case "$linkval" in
443 /* | ?:* ) self_abspathname="$linkval" ;;
444 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
445 esac
446 done
447 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
450 # func_tmpdir
451 # creates a temporary directory.
452 # Input:
453 # - progname name of this program
454 # Sets variable
455 # - tmp pathname of freshly created temporary directory
456 func_tmpdir ()
458 # Use the environment variable TMPDIR, falling back to /tmp. This allows
459 # users to specify a different temporary directory, for example, if their
460 # /tmp is filled up or too small.
461 : ${TMPDIR=/tmp}
463 # Use the mktemp program if available. If not available, hide the error
464 # message.
465 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
466 test -n "$tmp" && test -d "$tmp"
467 } ||
469 # Use a simple mkdir command. It is guaranteed to fail if the directory
470 # already exists. $RANDOM is bash specific and expands to empty in shells
471 # other than bash, ksh and zsh. Its use does not increase security;
472 # rather, it minimizes the probability of failure in a very cluttered /tmp
473 # directory.
474 tmp=$TMPDIR/gl$$-$RANDOM
475 (umask 077 && mkdir "$tmp")
476 } ||
478 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
479 func_exit 1
483 # func_append var value
484 # appends the given value to the shell variable var.
485 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
486 # Use bash's += operator. It reduces complexity of appending repeatedly to
487 # a single variable from O(n^2) to O(n).
488 func_append ()
490 eval "$1+=\"\$2\""
492 fast_func_append=true
493 else
494 func_append ()
496 eval "$1=\"\$$1\$2\""
498 fast_func_append=false
501 # func_remove_prefix var prefix
502 # removes the given prefix from the value of the shell variable var.
503 # var should be the name of a shell variable.
504 # Its value should not contain a newline and not start or end with whitespace.
505 # prefix should not contain the characters "$`\{}[]^|.
506 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
507 func_remove_prefix ()
509 eval "$1=\${$1#\$2}"
511 fast_func_remove_prefix=true
512 else
513 func_remove_prefix ()
515 eval "value=\"\$$1\""
516 prefix="$2"
517 case "$prefix" in
518 *.*)
519 sed_escape_dots='s/\([.]\)/\\\1/g'
520 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
522 esac
523 value=`echo "$value" | sed -e "s|^${prefix}||"`
524 eval "$1=\"\$value\""
526 fast_func_remove_prefix=false
529 # Determine whether we should use ':' or ';' as PATH_SEPARATOR.
530 func_determine_path_separator ()
532 if test "${PATH_SEPARATOR+set}" != set; then
533 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
534 # contains only /bin. Note that ksh looks also at the FPATH variable,
535 # so we have to set that as well for the test.
536 PATH_SEPARATOR=:
537 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
538 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
539 || PATH_SEPARATOR=';'
544 # func_path_prepend pathvar directory
545 # puts directory before pathvar, delimiting directories by PATH_SEPARATOR.
546 # Newly added directory into pathvar has the highest priority.
547 func_path_prepend ()
549 if eval "test -n \"\$$1\""; then
550 eval "$1=\$2\$PATH_SEPARATOR\$$1"
551 else
552 eval "$1=\$2"
556 # func_path_append pathvar directory
557 # Similar to func_path_prepend except that the newest directory has the lowest
558 # priority.
559 func_path_append ()
561 if eval "test -n \"\$$1\""; then
562 func_append "$1" "$PATH_SEPARATOR$2"
563 else
564 eval "$1=\$2"
568 # func_path_foreach_inner
569 # helper for func_path_foreach because we need new 'args' array
570 # Input:
571 # - fpf_dir directory from local_gnulib_path
572 # - fpf_cb callback to be run for fpf_dir
573 func_path_foreach_inner ()
575 set %start% "$@"
576 for _fpf_arg
578 case $_fpf_arg in
579 %start%)
580 set dummy
582 %dir%)
583 set "$@" "$fpf_dir"
586 set "$@" "$_fpf_arg"
588 esac
589 done
590 shift
592 "$fpf_cb" "$@"
595 # func_path_foreach path method args
596 # Execute method for each directory in path. The method will be called
597 # like `method args` while any argument '%dir%' within args will be replaced
598 # with processed directory from path.
599 func_path_foreach ()
601 fpf_save_IFS=$IFS
602 fpf_dirs=$1 ; shift
603 fpf_cb=$1 ; shift
604 fpf_rc=false
606 IFS=$PATH_SEPARATOR
607 for fpf_dir in $fpf_dirs
609 func_path_foreach_inner "$@" && fpf_rc=:
610 done
611 IFS=$fpf_save_IFS
612 $fpf_rc
615 # func_remove_suffix var suffix
616 # removes the given suffix from the value of the shell variable var.
617 # var should be the name of a shell variable.
618 # Its value should not contain a newline and not start or end with whitespace.
619 # suffix should not contain the characters "$`\{}[]^|.
620 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
621 func_remove_suffix ()
623 eval "$1=\${$1%\$2}"
625 fast_func_remove_suffix=true
626 else
627 func_remove_suffix ()
629 eval "value=\"\$$1\""
630 suffix="$2"
631 case "$suffix" in
632 *.*)
633 sed_escape_dots='s/\([.]\)/\\\1/g'
634 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
636 esac
637 value=`echo "$value" | sed -e "s|${suffix}\$||"`
638 eval "$1=\"\$value\""
640 fast_func_remove_suffix=false
643 # func_fatal_error message
644 # outputs to stderr a fatal error message, and terminates the program.
645 # Input:
646 # - progname name of this program
647 func_fatal_error ()
649 echo "$progname: *** $1" 1>&2
650 echo "$progname: *** Stop." 1>&2
651 func_exit 1
654 # func_warning message
655 # Outputs to stderr a warning message,
656 func_warning ()
658 echo "gnulib-tool: warning: $1" 1>&2
661 # func_readlink SYMLINK
662 # outputs the target of the given symlink.
663 if (type readlink) > /dev/null 2>&1; then
664 func_readlink ()
666 # Use the readlink program from GNU coreutils.
667 readlink "$1"
669 else
670 func_readlink ()
672 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
673 # would do the wrong thing if the link target contains " -> ".
674 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
678 # func_relativize DIR1 DIR2
679 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
680 # Input:
681 # - DIR1 relative pathname, relative to the current directory
682 # - DIR2 relative pathname, relative to the current directory
683 # Output:
684 # - reldir relative pathname of DIR2, relative to DIR1
685 func_relativize ()
687 dir0=`pwd`
688 dir1="$1"
689 dir2="$2"
690 sed_first='s,^\([^/]*\)/.*$,\1,'
691 sed_rest='s,^[^/]*/*,,'
692 sed_last='s,^.*/\([^/]*\)$,\1,'
693 sed_butlast='s,/*[^/]*$,,'
694 while test -n "$dir1"; do
695 first=`echo "$dir1" | sed -e "$sed_first"`
696 if test "$first" != "."; then
697 if test "$first" = ".."; then
698 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
699 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
700 else
701 first2=`echo "$dir2" | sed -e "$sed_first"`
702 if test "$first2" = "$first"; then
703 dir2=`echo "$dir2" | sed -e "$sed_rest"`
704 else
705 dir2="../$dir2"
707 dir0="$dir0"/"$first"
710 dir1=`echo "$dir1" | sed -e "$sed_rest"`
711 done
712 reldir="$dir2"
715 # func_relconcat DIR1 DIR2
716 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
717 # Input:
718 # - DIR1 relative pathname, relative to the current directory
719 # - DIR2 relative pathname, relative to DIR1
720 # Output:
721 # - relconcat DIR1/DIR2, relative to the current directory
722 func_relconcat ()
724 dir1="$1"
725 dir2="$2"
726 sed_first='s,^\([^/]*\)/.*$,\1,'
727 sed_rest='s,^[^/]*/*,,'
728 sed_last='s,^.*/\([^/]*\)$,\1,'
729 sed_butlast='s,/*[^/]*$,,'
730 while true; do
731 first=`echo "$dir2" | sed -e "$sed_first"`
732 if test "$first" = "."; then
733 dir2=`echo "$dir2" | sed -e "$sed_rest"`
734 if test -z "$dir2"; then
735 relconcat="$dir1"
736 break
738 else
739 last=`echo "$dir1" | sed -e "$sed_last"`
740 while test "$last" = "."; do
741 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
742 last=`echo "$dir1" | sed -e "$sed_last"`
743 done
744 if test -z "$dir1"; then
745 relconcat="$dir2"
746 break
748 if test "$first" = ".."; then
749 if test "$last" = ".."; then
750 relconcat="$dir1/$dir2"
751 break
753 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
754 dir2=`echo "$dir2" | sed -e "$sed_rest"`
755 if test -z "$dir1"; then
756 relconcat="$dir2"
757 break
759 if test -z "$dir2"; then
760 relconcat="$dir1"
761 break
763 else
764 relconcat="$dir1/$dir2"
765 break
768 done
771 # func_ln_s SRC DEST
772 # Like ln -s, except use cp -p if ln -s fails.
773 func_ln_s ()
775 ln -s "$1" "$2" || {
776 echo "$progname: ln -s failed; falling back on cp -p" >&2
778 case "$1" in
779 /* | ?:*) # SRC is absolute.
780 cp_src=$1 ;;
781 *) # SRC is relative to the directory of DEST.
782 cp_src=${2%/*}/$1 ;;
783 esac
785 cp -p "$cp_src" "$2"
789 # func_ln SRC DEST
790 # Like func_ln_s, except that SRC is given relative to the current directory (or
791 # absolute), not given relative to the directory of DEST.
792 func_ln ()
794 case "$1" in
795 /* | ?:*)
796 func_ln_s "$1" "$2" ;;
797 *) # SRC is relative.
798 case "$2" in
799 /* | ?:*)
800 func_ln_s "`pwd`/$1" "$2" ;;
801 *) # DEST is relative too.
802 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
803 test -n "$ln_destdir" || ln_destdir="."
804 func_relativize "$ln_destdir" "$1"
805 func_ln_s "$reldir" "$2"
807 esac
809 esac
812 # func_ln_if_changed SRC DEST
813 # Like func_ln, but avoids munging timestamps if the link is correct.
814 func_ln_if_changed ()
816 if test $# -ne 2; then
817 echo "usage: func_ln_if_changed SRC DEST" >&2
819 ln_target=`func_readlink "$2"`
820 if test -h "$2" && test "$1" = "$ln_target"; then
822 else
823 rm -f "$2"
824 func_ln "$1" "$2"
828 # Ensure an 'echo' command that
829 # 1. does not interpret backslashes and
830 # 2. does not print an error message "broken pipe" when writing into a pipe
831 # with no writers.
833 # Test cases for problem 1:
834 # echo '\n' | wc -l prints 1 when OK, 2 when KO
835 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
836 # Test cases for problem 2:
837 # echo hi | true frequently prints
838 # "bash: echo: write error: Broken pipe"
839 # to standard error in bash 3.2.
841 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
842 # BSD echo interprets '-n' as an option, which is also not desirable).
843 # Nowadays the problem occurs in 4 situations:
844 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
845 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
846 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
847 # - in zsh, when sh-emulation is not set,
848 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
849 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
850 # - in Solaris /bin/sh and OSF/1 /bin/sh.
851 # We try the following workarounds:
852 # - for all: respawn using $CONFIG_SHELL if that is set and works.
853 # - for bash >= 2.04: unset the shell option xpg_echo.
854 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
855 # - for bash < 2.0: define echo to a function that uses cat of a here document.
856 # - for zsh: turn sh-emulation on.
857 # - for ksh: alias echo to 'print -r'.
858 # - for ksh: alias echo to a function that uses cat of a here document.
859 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
860 # the ksh workaround.
861 # - otherwise: respawn using /bin/sh and rely on the workarounds.
862 # When respawning, we pass --no-reexec as first argument, so as to avoid
863 # turning this script into a fork bomb in unlucky situations.
865 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
866 # the 'printf' built-in. See
867 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
868 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
869 # The workaround is: define echo to a function that uses the printf built-in.
870 have_echo=
871 if echo '\t' | grep t > /dev/null; then
872 have_echo=yes # Lucky!
874 # Try the workarounds.
875 # Respawn using $CONFIG_SHELL if that is set and works.
876 if test -z "$have_echo" \
877 && test "X$1" != "X--no-reexec" \
878 && test -n "$CONFIG_SHELL" \
879 && test -f "$CONFIG_SHELL" \
880 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
881 exec $CONFIG_SHELL "$0" --no-reexec "$@"
882 exit 127
884 # For bash >= 2.04: unset the shell option xpg_echo.
885 if test -z "$have_echo" \
886 && test -n "$BASH_VERSION" \
887 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
888 shopt -o xpg_echo
889 have_echo=yes
891 # For bash >= 2.0: define echo to a function that uses the printf built-in.
892 # For bash < 2.0: define echo to a function that uses cat of a here document.
893 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
894 # Also handle problem 2, specific to bash 3.2, here.
895 if { test -z "$have_echo" \
896 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
898 && test -n "$BASH_VERSION"; then \
899 if type printf 2>/dev/null | grep / > /dev/null; then
900 # 'printf' is not a shell built-in.
901 echo ()
903 cat <<EOF
907 else
908 # 'printf' is a shell built-in.
909 echo ()
911 printf '%s\n' "$*"
914 if echo '\t' | grep t > /dev/null; then
915 have_echo=yes
918 # For zsh: turn sh-emulation on.
919 if test -z "$have_echo" \
920 && test -n "$ZSH_VERSION" \
921 && (emulate sh) >/dev/null 2>&1; then
922 emulate sh
924 # For ksh: alias echo to 'print -r'.
925 if test -z "$have_echo" \
926 && (type print) >/dev/null 2>&1; then
927 # A 'print' command exists.
928 if type print 2>/dev/null | grep / > /dev/null; then
930 else
931 # 'print' is a shell built-in.
932 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
933 # 'print' is the ksh shell built-in.
934 alias echo='print -r'
938 if test -z "$have_echo" \
939 && echo '\t' | grep t > /dev/null; then
940 have_echo=yes
942 # For ksh: alias echo to a function that uses cat of a here document.
943 # The ksh manual page says:
944 # "Aliasing is performed when scripts are read, not while they are executed.
945 # Therefore, for an alias to take effect, the alias definition command has
946 # to be executed before the command which references the alias is read."
947 # Because of this, we have to play strange tricks with have_echo, to ensure
948 # that the top-level statement containing the test starts after the 'alias'
949 # command.
950 if test -z "$have_echo"; then
951 bsd_echo ()
953 cat <<EOF
957 if (alias echo=bsd_echo) 2>/dev/null; then
958 alias echo=bsd_echo 2>/dev/null
961 if test -z "$have_echo" \
962 && echo '\t' | grep t > /dev/null; then
963 have_echo=yes
965 if test -z "$have_echo"; then
966 if (alias echo=bsd_echo) 2>/dev/null; then
967 unalias echo 2>/dev/null
970 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
971 if test -z "$have_echo" \
972 && test "X$1" != "X--no-reexec" \
973 && test -f /bin/ksh; then
974 exec /bin/ksh "$0" --no-reexec "$@"
975 exit 127
977 # Otherwise: respawn using /bin/sh.
978 if test -z "$have_echo" \
979 && test "X$1" != "X--no-reexec" \
980 && test -f /bin/sh; then
981 exec /bin/sh "$0" --no-reexec "$@"
982 exit 127
984 if test -z "$have_echo"; then
985 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
987 if echo '\t' | grep t > /dev/null; then
988 : # Works fine now.
989 else
990 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
992 if test "X$1" = "X--no-reexec"; then
993 shift
996 # Unset CDPATH. Otherwise, output from 'cd dir' can surprise callers.
997 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
999 # Determine the path separator early because the following option parsing code
1000 # requires that.
1001 func_determine_path_separator
1003 # Command-line option processing.
1004 # Removes the OPTIONS from the arguments. Sets the variables:
1005 # - mode one of: list, find, import, add-import, remove-import,
1006 # update, create-testdir, create-megatestdir, test, megatest,
1007 # copy-file
1008 # - destdir from --dir
1009 # - local_gnulib_path from --local-dir
1010 # - modcache true or false, from --cache-modules/--no-cache-modules
1011 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1012 # - libname, supplied_libname from --lib
1013 # - sourcebase from --source-base
1014 # - m4base from --m4-base
1015 # - pobase from --po-base
1016 # - docbase from --doc-base
1017 # - testsbase from --tests-base
1018 # - auxdir from --aux-dir
1019 # - inctests true if --with-tests was given, false if --without-tests
1020 # was given, blank otherwise
1021 # - incobsolete true if --with-obsolete was given, blank otherwise
1022 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
1023 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
1024 # otherwise
1025 # - inc_privileged_tests true if --with-privileged-tests was given, blank
1026 # otherwise
1027 # - inc_unportable_tests true if --with-unportable-tests was given, blank
1028 # otherwise
1029 # - inc_all_tests true if --with-all-tests was given, blank otherwise
1030 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
1031 # - excl_longrunning_tests true if --without-longrunning-tests was given,
1032 # blank otherwise
1033 # - excl_privileged_tests true if --without-privileged-tests was given, blank
1034 # otherwise
1035 # - excl_unportable_tests true if --without-unportable-tests was given, blank
1036 # otherwise
1037 # - single_configure true if --single-configure was given, false otherwise
1038 # - avoidlist list of modules to avoid, from --avoid
1039 # - cond_dependencies true if --conditional-dependencies was given, false if
1040 # --no-conditional-dependencies was given, blank otherwise
1041 # - lgpl yes or a number if --lgpl was given, blank otherwise
1042 # - makefile_name from --makefile-name
1043 # - libtool true if --libtool was given, false if --no-libtool was
1044 # given, blank otherwise
1045 # - macro_prefix from --macro-prefix
1046 # - po_domain from --po-domain
1047 # - witness_c_macro from --witness-c-macro
1048 # - vc_files true if --vc-files was given, false if --no-vc-files was
1049 # given, blank otherwise
1050 # - autoconf_minversion minimum supported autoconf version
1051 # - doit : if actions shall be executed, false if only to be printed
1052 # - symbolic true if --symlink or --more-symlinks was given, blank
1053 # otherwise
1054 # - lsymbolic true if --local-symlink was given, blank otherwise
1055 # - do_copyrights blank if --more-symlinks was given, true otherwise
1057 mode=
1058 destdir=
1059 local_gnulib_path=
1060 modcache=true
1061 verbose=0
1062 libname=libgnu
1063 supplied_libname=
1064 sourcebase=
1065 m4base=
1066 pobase=
1067 docbase=
1068 testsbase=
1069 auxdir=
1070 inctests=
1071 incobsolete=
1072 inc_cxx_tests=
1073 inc_longrunning_tests=
1074 inc_privileged_tests=
1075 inc_unportable_tests=
1076 inc_all_tests=
1077 excl_cxx_tests=
1078 excl_longrunning_tests=
1079 excl_privileged_tests=
1080 excl_unportable_tests=
1081 single_configure=false
1082 avoidlist=
1083 cond_dependencies=
1084 lgpl=
1085 makefile_name=
1086 libtool=
1087 macro_prefix=
1088 po_domain=
1089 witness_c_macro=
1090 vc_files=
1091 doit=:
1092 symbolic=
1093 lsymbolic=
1094 do_copyrights=true
1096 supplied_opts="$@"
1098 while test $# -gt 0; do
1099 case "$1" in
1100 --list | --lis )
1101 mode=list
1102 shift ;;
1103 --find | --fin | --fi | --f )
1104 mode=find
1105 shift ;;
1106 --import | --impor | --impo | --imp | --im | --i )
1107 mode=import
1108 shift ;;
1109 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
1110 mode=add-import
1111 shift ;;
1112 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
1113 mode=remove-import
1114 shift ;;
1115 --update | --updat | --upda | --upd | --up | --u )
1116 mode=update
1117 shift ;;
1118 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
1119 mode=create-testdir
1120 shift ;;
1121 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
1122 mode=create-megatestdir
1123 shift ;;
1124 --test | --tes | --te | --t )
1125 mode=test
1126 shift ;;
1127 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1128 mode=megatest
1129 shift ;;
1130 --extract-* )
1131 mode=`echo "X$1" | sed -e 's/^X--//'`
1132 shift ;;
1133 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop )
1134 mode=copy-file
1135 shift ;;
1136 --dir )
1137 shift
1138 if test $# = 0; then
1139 func_fatal_error "missing argument for --dir"
1141 destdir=$1
1142 shift ;;
1143 --dir=* )
1144 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1145 shift ;;
1146 --local-dir )
1147 shift
1148 if test $# = 0; then
1149 func_fatal_error "missing argument for --local-dir"
1151 func_path_prepend local_gnulib_path "$1"
1152 shift ;;
1153 --local-dir=* )
1154 local_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1155 func_path_prepend local_gnulib_path "$local_dir"
1156 shift ;;
1157 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1158 modcache=true
1159 shift ;;
1160 --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 )
1161 modcache=false
1162 shift ;;
1163 --verbose | --verbos | --verbo | --verb )
1164 verbose=`expr $verbose + 1`
1165 shift ;;
1166 --quiet | --quie | --qui | --qu | --q )
1167 verbose=`expr $verbose - 1`
1168 shift ;;
1169 --lib )
1170 shift
1171 if test $# = 0; then
1172 func_fatal_error "missing argument for --lib"
1174 libname=$1
1175 supplied_libname=true
1176 shift ;;
1177 --lib=* )
1178 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1179 supplied_libname=true
1180 shift ;;
1181 --source-base )
1182 shift
1183 if test $# = 0; then
1184 func_fatal_error "missing argument for --source-base"
1186 sourcebase=$1
1187 shift ;;
1188 --source-base=* )
1189 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1190 shift ;;
1191 --m4-base )
1192 shift
1193 if test $# = 0; then
1194 func_fatal_error "missing argument for --m4-base"
1196 m4base=$1
1197 shift ;;
1198 --m4-base=* )
1199 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1200 shift ;;
1201 --po-base )
1202 shift
1203 if test $# = 0; then
1204 func_fatal_error "missing argument for --po-base"
1206 pobase=$1
1207 shift ;;
1208 --po-base=* )
1209 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1210 shift ;;
1211 --doc-base )
1212 shift
1213 if test $# = 0; then
1214 func_fatal_error "missing argument for --doc-base"
1216 docbase=$1
1217 shift ;;
1218 --doc-base=* )
1219 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1220 shift ;;
1221 --tests-base )
1222 shift
1223 if test $# = 0; then
1224 func_fatal_error "missing argument for --tests-base"
1226 testsbase=$1
1227 shift ;;
1228 --tests-base=* )
1229 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1230 shift ;;
1231 --aux-dir )
1232 shift
1233 if test $# = 0; then
1234 func_fatal_error "missing argument for --aux-dir"
1236 auxdir=$1
1237 shift ;;
1238 --aux-dir=* )
1239 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1240 shift ;;
1241 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1242 inctests=true
1243 shift ;;
1244 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1245 incobsolete=true
1246 shift ;;
1247 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1248 inc_cxx_tests=true
1249 shift ;;
1250 --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)
1251 inc_longrunning_tests=true
1252 shift ;;
1253 --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)
1254 inc_privileged_tests=true
1255 shift ;;
1256 --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)
1257 inc_unportable_tests=true
1258 shift ;;
1259 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1260 inc_all_tests=true
1261 shift ;;
1262 --without-tests | --without-test | --without-tes | --without-te | --without-t)
1263 inctests=false
1264 shift ;;
1265 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1266 excl_cxx_tests=true
1267 shift ;;
1268 --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)
1269 excl_longrunning_tests=true
1270 shift ;;
1271 --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)
1272 excl_privileged_tests=true
1273 shift ;;
1274 --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)
1275 excl_unportable_tests=true
1276 shift ;;
1277 --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)
1278 single_configure=true
1279 shift ;;
1280 --avoid )
1281 shift
1282 if test $# = 0; then
1283 func_fatal_error "missing argument for --avoid"
1285 func_append avoidlist " $1"
1286 shift ;;
1287 --avoid=* )
1288 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1289 func_append avoidlist " $arg"
1290 shift ;;
1291 --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)
1292 cond_dependencies=true
1293 shift ;;
1294 --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)
1295 cond_dependencies=false
1296 shift ;;
1297 --lgpl )
1298 lgpl=yes
1299 shift ;;
1300 --lgpl=* )
1301 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1302 case "$arg" in
1303 2 | 3orGPLv2 | 3) ;;
1304 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1305 esac
1306 lgpl=$arg
1307 shift ;;
1308 --makefile-name )
1309 shift
1310 if test $# = 0; then
1311 func_fatal_error "missing argument for --makefile-name"
1313 makefile_name="$1"
1314 shift ;;
1315 --makefile-name=* )
1316 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1317 shift ;;
1318 --libtool )
1319 libtool=true
1320 shift ;;
1321 --no-libtool )
1322 libtool=false
1323 shift ;;
1324 --macro-prefix )
1325 shift
1326 if test $# = 0; then
1327 func_fatal_error "missing argument for --macro-prefix"
1329 macro_prefix="$1"
1330 shift ;;
1331 --macro-prefix=* )
1332 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1333 shift ;;
1334 --po-domain )
1335 shift
1336 if test $# = 0; then
1337 func_fatal_error "missing argument for --po-domain"
1339 po_domain="$1"
1340 shift ;;
1341 --po-domain=* )
1342 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1343 shift ;;
1344 --witness-c-macro )
1345 shift
1346 if test $# = 0; then
1347 func_fatal_error "missing argument for --witness-c-macro"
1349 witness_c_macro="$1"
1350 shift ;;
1351 --witness-c-macro=* )
1352 witness_c_macro=`echo "X$1" | sed -e 's/^X--witness-c-macro=//'`
1353 shift ;;
1354 --vc-files )
1355 vc_files=true
1356 shift ;;
1357 --no-vc-files )
1358 vc_files=false
1359 shift ;;
1360 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1361 # A no-op for backward compatibility.
1362 shift ;;
1363 --dry-run )
1364 doit=false
1365 shift ;;
1366 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1367 symbolic=true
1368 shift ;;
1369 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1370 lsymbolic=true
1371 shift ;;
1372 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1373 symbolic=true
1374 do_copyrights=
1375 shift ;;
1376 --help | --hel | --he | --h )
1377 func_usage
1378 func_exit $? ;;
1379 --version | --versio | --versi | --vers )
1380 func_version
1381 func_exit $? ;;
1382 -- )
1383 # Stop option processing
1384 shift
1385 break ;;
1386 -* )
1387 echo "gnulib-tool: unknown option $1" 1>&2
1388 echo "Try 'gnulib-tool --help' for more information." 1>&2
1389 func_exit 1 ;;
1391 break ;;
1392 esac
1393 done
1395 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1396 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1397 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1398 || test "$single_configure" != false; then
1399 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1400 echo "Try 'gnulib-tool --help' for more information." 1>&2
1401 func_exit 1
1404 if test "$mode" = update; then
1405 if test $# != 0; then
1406 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1407 echo "Try 'gnulib-tool --help' for more information." 1>&2
1408 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1409 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1410 func_exit 1
1412 if test -n "$local_gnulib_path" || test -n "$supplied_libname" \
1413 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1414 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1415 || test -n "$inctests" || test -n "$incobsolete" \
1416 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1417 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1418 || test -n "$inc_all_tests" \
1419 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1420 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1421 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1422 || test -n "$macro_prefix" || test -n "$po_domain" \
1423 || test -n "$witness_c_macro" || test -n "$vc_files"; then
1424 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1425 echo "Try 'gnulib-tool --help' for more information." 1>&2
1426 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1427 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1428 func_exit 1
1431 if test -n "$pobase" && test -z "$po_domain"; then
1432 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1433 echo "Try 'gnulib-tool --help' for more information." 1>&2
1434 func_exit 1
1436 if test -z "$pobase" && test -n "$po_domain"; then
1437 func_warning "--po-domain has no effect without a --po-base option"
1439 # Canonicalize the inctests variable.
1440 case "$mode" in
1441 import | add-import | remove-import | update)
1442 if test -z "$inctests"; then
1443 inctests=false
1446 create-testdir | create-megatestdir | test | megatest)
1447 if test -z "$inctests"; then
1448 inctests=true
1451 esac
1452 # Now the only possible values of "$inctests" are true and false
1453 # (or blank but then it is irrelevant).
1454 if test "$cond_dependencies" = true && test "$inctests" = true; then
1455 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
1456 func_exit 1
1459 # Determine the minimum supported autoconf version from the project's
1460 # configure.ac.
1461 DEFAULT_AUTOCONF_MINVERSION="2.59"
1462 autoconf_minversion=
1463 configure_ac=
1464 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1465 && test -n "$destdir"; then
1466 if test -f "$destdir"/configure.ac; then
1467 configure_ac="$destdir/configure.ac"
1468 else
1469 if test -f "$destdir"/configure.in; then
1470 configure_ac="$destdir/configure.in"
1473 else
1474 if test -f configure.ac; then
1475 configure_ac="configure.ac"
1476 else
1477 if test -f configure.in; then
1478 configure_ac="configure.in"
1482 if test -n "$configure_ac"; then
1483 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1484 # because when some m4 files are omitted from a version control repository,
1485 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1486 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1487 # autom4te: m4 failed with exit status: 1
1488 prereqs=
1489 my_sed_traces='
1490 s,#.*$,,
1491 s,^dnl .*$,,
1492 s, dnl .*$,,
1493 /AC_PREREQ/ {
1494 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1496 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1497 if test -n "$prereqs"; then
1498 autoconf_minversion=`
1499 for version in $prereqs; do echo $version; done |
1500 LC_ALL=C sort -nru | sed -e 1q
1504 if test -z "$autoconf_minversion"; then
1505 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1507 case "$autoconf_minversion" in
1508 1.* | 2.[0-4]* | 2.5[0-8]*)
1509 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1510 esac
1512 # Remove trailing slashes from the directory names. This is necessary for
1513 # m4base (to avoid an error in func_import) and optional for the others.
1514 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1515 old_local_gnulib_path=$local_gnulib_path
1516 save_IFS=$IFS
1517 IFS=:
1518 local_gnulib_path=
1519 for dir in $old_local_gnulib_path
1521 case "$dir" in
1522 */ ) dir=`echo "$dir" | sed -e "$sed_trimtrailingslashes"` ;;
1523 esac
1524 func_path_append local_gnulib_path "$dir"
1525 done
1526 IFS=$save_IFS
1527 case "$sourcebase" in
1528 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1529 esac
1530 case "$m4base" in
1531 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1532 esac
1533 case "$pobase" in
1534 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1535 esac
1536 case "$docbase" in
1537 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1538 esac
1539 case "$testsbase" in
1540 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1541 esac
1542 case "$auxdir" in
1543 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1544 esac
1547 func_gnulib_dir
1548 func_tmpdir
1549 trap 'exit_status=$?
1550 if test "$signal" != 0; then
1551 echo "caught signal $signal" >&2
1553 rm -rf "$tmp"
1554 exit $exit_status' 0
1555 for signal in 1 2 3 13 15; do
1556 trap '{ signal='$signal'; func_exit 1; }' $signal
1557 done
1558 signal=0
1560 # Note: The 'eval' silences stderr output in dash.
1561 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1562 # Zsh 4 and Bash 4 have associative arrays.
1563 have_associative=true
1564 else
1565 # For other shells, use 'eval' with computed shell variable names.
1566 have_associative=false
1569 # func_lookup_local_file_cb dir file
1570 # return true and set func_lookup_local_file_result if the file 'dir/file'
1571 # exists
1572 func_lookup_local_file_cb ()
1574 test -n "$func_lookup_local_file_result" && return 1 # already found?
1575 test -f "$1/$2" || return 1
1576 func_lookup_local_file_result=$1/$2
1580 # func_lookup_local_file file
1581 # looks up a file in $local_gnulib_path.
1582 # Input:
1583 # - local_gnulib_path from --local-dir
1584 # Output:
1585 # - func_lookup_local_file_result name of the file, valid only when the
1586 # function succeeded.
1587 func_lookup_local_file ()
1589 func_lookup_local_file_result=
1590 func_path_foreach "$local_gnulib_path" func_lookup_local_file_cb %dir% "$1"
1593 # func_lookup_file file
1594 # looks up a file in $local_gnulib_path or $gnulib_dir, or combines it through
1595 # 'patch'.
1596 # Input:
1597 # - local_gnulib_path from --local-dir
1598 # Output:
1599 # - lookedup_file name of the merged (combined) file
1600 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1601 func_lookup_file ()
1603 lkfile="$1"
1604 if func_lookup_local_file "$lkfile"; then
1605 lookedup_file=$func_lookup_local_file_result
1606 lookedup_tmp=
1607 else
1608 if test -f "$gnulib_dir/$lkfile"; then
1609 if func_lookup_local_file "$lkfile.diff"; then
1610 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1611 rm -f "$tmp/$lkbase"
1612 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1613 patch -s "$tmp/$lkbase" < "$func_lookup_local_file_result" >&2 \
1614 || func_fatal_error "patch file $func_lookup_local_file_result didn't apply cleanly"
1615 lookedup_file="$tmp/$lkbase"
1616 lookedup_tmp=true
1617 else
1618 lookedup_file="$gnulib_dir/$lkfile"
1619 lookedup_tmp=
1621 else
1622 func_fatal_error "file $gnulib_dir/$lkfile not found"
1627 # func_sanitize_modulelist
1628 # receives a list of possible module names on standard input, one per line.
1629 # It removes those which are just file names unrelated to modules, and outputs
1630 # the resulting list to standard output, one per line.
1631 func_sanitize_modulelist ()
1633 sed -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1634 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1635 -e '/^README$/d' -e '/\/README$/d' \
1636 -e '/^TEMPLATE$/d' \
1637 -e '/^TEMPLATE-EXTENDED$/d' \
1638 -e '/^TEMPLATE-TESTS$/d' \
1639 -e '/^\..*/d' \
1640 -e '/~$/d'
1644 # func_modules_in_dir dir
1645 # outputs all module files in dir to standard output.
1646 func_modules_in_dir ()
1648 (test -d "$1" && cd "$1" && find modules -type f -print)
1651 # func_all_modules
1652 # Input:
1653 # - local_gnulib_path from --local-dir
1654 func_all_modules ()
1656 # Filter out metainformation files like README, which are not modules.
1657 # Filter out unit test modules; they can be retrieved through
1658 # --extract-tests-module if desired.
1660 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1661 func_path_foreach "$local_gnulib_path" func_modules_in_dir %dir% | sed -e 's,^modules/,,' -e 's,\.diff$,,'
1663 | func_sanitize_modulelist \
1664 | sed -e '/-tests$/d' \
1665 | LC_ALL=C sort -u
1668 # func_exists_local_module dir module
1669 # returns true if module exists in dir
1670 func_exists_local_module ()
1672 test -d "$1/modules" && test -f "$1/modules/$2";
1675 # func_exists_module module
1676 # tests whether a module, given by name, exists
1677 # Input:
1678 # - local_gnulib_path from --local-dir
1679 func_exists_module ()
1681 { test -f "$gnulib_dir/modules/$1" \
1682 || func_path_foreach "$local_gnulib_path" func_exists_local_module %dir% "$1" ; } \
1683 && test "ChangeLog" != "$1" \
1684 && test "COPYING" != "$1" \
1685 && test "README" != "$1" \
1686 && test "TEMPLATE" != "$1" \
1687 && test "TEMPLATE-EXTENDED" != "$1" \
1688 && test "TEMPLATE-TESTS" != "$1"
1691 # func_verify_module
1692 # verifies a module name
1693 # Input:
1694 # - local_gnulib_path from --local-dir
1695 # - module module name argument
1696 func_verify_module ()
1698 if func_exists_module "$module"; then
1699 # OK, $module is a correct module name.
1700 # Verify that building the module description with 'patch' succeeds.
1701 func_lookup_file "modules/$module"
1702 else
1703 func_warning "module $module doesn't exist"
1704 module=
1708 # func_verify_nontests_module
1709 # verifies a module name, excluding tests modules
1710 # Input:
1711 # - local_gnulib_path from --local-dir
1712 # - module module name argument
1713 func_verify_nontests_module ()
1715 case "$module" in
1716 *-tests ) module= ;;
1717 * ) func_verify_module ;;
1718 esac
1721 # func_verify_tests_module
1722 # verifies a module name, considering only tests modules
1723 # Input:
1724 # - local_gnulib_path from --local-dir
1725 # - module module name argument
1726 func_verify_tests_module ()
1728 case "$module" in
1729 *-tests ) func_verify_module ;;
1730 * ) module= ;;
1731 esac
1734 # Suffix of a sed expression that extracts a particular field from a
1735 # module description.
1736 # A field starts with a line that contains a keyword, such as 'Description',
1737 # followed by a colon and optional whitespace. All following lines, up to
1738 # the next field (or end of file if there is none) form the contents of the
1739 # field.
1740 # An absent field is equivalent to a field with empty contents.
1741 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1742 sed_extract_prog=':[ ]*$/ {
1745 s/^Description:[ ]*$//
1746 s/^Comment:[ ]*$//
1747 s/^Status:[ ]*$//
1748 s/^Notice:[ ]*$//
1749 s/^Applicability:[ ]*$//
1750 s/^Files:[ ]*$//
1751 s/^Depends-on:[ ]*$//
1752 s/^configure\.ac-early:[ ]*$//
1753 s/^configure\.ac:[ ]*$//
1754 s/^Makefile\.am:[ ]*$//
1755 s/^Include:[ ]*$//
1756 s/^Link:[ ]*$//
1757 s/^License:[ ]*$//
1758 s/^Maintainer:[ ]*$//
1765 # Piece of a sed expression that converts a field header line to a shell
1766 # variable name,
1767 # NOTE: Keep this in sync with sed_extract_prog above!
1768 sed_extract_field_header='
1769 s/^Description:[ ]*$/description/
1770 s/^Comment:[ ]*$/comment/
1771 s/^Status:[ ]*$/status/
1772 s/^Notice:[ ]*$/notice/
1773 s/^Applicability:[ ]*$/applicability/
1774 s/^Files:[ ]*$/files/
1775 s/^Depends-on:[ ]*$/dependson/
1776 s/^configure\.ac-early:[ ]*$/configureac_early/
1777 s/^configure\.ac:[ ]*$/configureac/
1778 s/^Makefile\.am:[ ]*$/makefile/
1779 s/^Include:[ ]*$/include/
1780 s/^Link:[ ]*$/link/
1781 s/^License:[ ]*$/license/
1782 s/^Maintainer:[ ]*$/maintainer/'
1784 if $modcache; then
1786 if $have_associative; then
1788 # Declare the associative arrays.
1789 declare -A modcache_cached
1790 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1791 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1792 eval "$declare_script"
1794 else
1796 # func_cache_var module
1797 # computes the cache variable name corresponding to $module.
1798 # Note: This computation can map different module names to the same
1799 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1800 # to protect against this case.
1801 # Output:
1802 # - cachevar a shell variable name
1803 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1804 # Bash 2.0 and newer, ksh, and zsh support the syntax
1805 # ${param//pattern/replacement}
1806 # as a shorthand for
1807 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1808 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1809 eval 'func_cache_var ()
1811 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1813 else
1814 func_cache_var ()
1816 case $1 in
1817 *[!a-zA-Z0-9_]*)
1818 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1820 cachevar=c_$1 ;;
1821 esac
1827 # func_init_sed_convert_to_cache_statements
1828 # Input:
1829 # - modcachevar_assignment
1830 # Output:
1831 # - sed_convert_to_cache_statements
1832 func_init_sed_convert_to_cache_statements ()
1834 # 'sed' script that turns a module description into shell script
1835 # assignments, suitable to be eval'ed. All active characters are escaped.
1836 # This script turns
1837 # Description:
1838 # Some module's description
1840 # Files:
1841 # lib/file.h
1842 # into:
1843 # modcache_description[$1]=\
1844 # 'Some module'"'"'s description
1846 # modcache_files[$1]=\
1847 # 'lib/file.h'
1848 # or:
1849 # c_MODULE_description_set=set; c_MODULE_description=\
1850 # 'Some module'"'"'s description
1852 # c_MODULE_files_set=set; c_MODULE_files=\
1853 # 'lib/file.h'
1854 # The script consists of two parts:
1855 # 1) Ignore the lines before the first field header.
1856 # 2) A loop, treating non-field-header lines by escaping single quotes
1857 # and adding a closing quote in the last line,
1858 sed_convert_to_cache_statements="
1859 :llla
1860 # Here we have not yet seen a field header.
1862 # See if the current line contains a field header.
1863 t llla1
1864 :llla1
1865 ${sed_extract_field_header}
1866 t lllb
1868 # No field header. Ignore the line.
1870 # Read the next line. Upon EOF, just exit.
1872 b llla
1874 :lllb
1875 # The current line contains a field header.
1877 # Turn it into the beginning of an assignment.
1878 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1880 # Move it to the hold space. Don't print it yet,
1881 # because we want no assignment if the field is empty.
1884 # Read the next line.
1885 # Upon EOF, the field was empty. Print no assignment. Just exit.
1888 # See if the current line contains a field header.
1889 t lllb1
1890 :lllb1
1891 ${sed_extract_field_header}
1892 # If it is, the previous field was empty. Print no assignment.
1893 t lllb
1895 # Not a field header.
1897 # Print the previous line, held in the hold space.
1902 # Transform single quotes.
1903 s/'/'\"'\"'/g
1905 # Prepend a single quote.
1906 s/^/'/
1908 :lllc
1910 # Move it to the hold space.
1913 # Read the next line.
1914 # Upon EOF, branch.
1916 b llle
1920 # See if the current line contains a field header.
1921 t lllc1
1922 :lllc1
1923 ${sed_extract_field_header}
1924 t llld
1926 # Print the previous line, held in the hold space.
1931 # Transform single quotes.
1932 s/'/'\"'\"'/g
1934 b lllc
1936 :llld
1937 # A field header.
1938 # Print the previous line, held in the hold space, with a single quote
1939 # to end the assignment.
1941 s/\$/'/
1945 b lllb
1947 :llle
1948 # EOF seen.
1949 # Print the previous line, held in the hold space, with a single quote
1950 # to end the assignment.
1952 s/\$/'/
1954 # Exit.
1957 if ! $sed_comments; then
1958 # Remove comments.
1959 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1960 | sed -e 's/^ *//' -e 's/^#.*//'`
1964 if $have_associative; then
1965 # sed_convert_to_cache_statements does not depend on the module.
1966 modcachevar_assignment='modcache_\1[$1]='
1967 func_init_sed_convert_to_cache_statements
1970 # func_cache_lookup_module module
1972 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1973 # of its relevant data in a cache in the memory of the processing shell. If
1974 # already cached, it does not look it up again, thus saving file access time.
1975 # Parameters:
1976 # - module non-empty string
1977 # Output if $have_associative:
1978 # - modcache_cached[$module] set to yes
1979 # - modcache_description[$module] ==
1980 # - modcache_status[$module] \ set to the field's value, minus the
1981 # - ... / final newline,
1982 # - modcache_maintainer[$module] == or unset if the field's value is empty
1983 # Output if ! $have_associative:
1984 # - cachevar a shell variable name
1985 # - ${cachevar}_cached set to $module
1986 # - ${cachevar}_description ==
1987 # - ${cachevar}_status \ set to the field's value, minus the
1988 # - ... / final newline,
1989 # - ${cachevar}_maintainer == or unset if the field's value is empty
1990 # - ${cachevar}_description_set ==
1991 # - ${cachevar}_status_set \ set to non-empty if the field's value
1992 # - ... / is non-empty,
1993 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1994 func_cache_lookup_module ()
1996 if $have_associative; then
1997 eval 'cached=${modcache_cached[$1]}'
1998 else
1999 func_cache_var "$1"
2000 eval "cached=\"\$${cachevar}_cached\""
2002 if test -z "$cached"; then
2003 # Not found in cache. Look it up on the file system.
2004 func_lookup_file "modules/$1"
2005 if $have_associative; then
2006 eval 'modcache_cached[$1]=yes'
2007 else
2008 eval "${cachevar}_cached=\"\$1\""
2010 if ! $have_associative; then
2011 # sed_convert_to_cache_statements depends on the module.
2012 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
2013 func_init_sed_convert_to_cache_statements
2015 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
2016 eval "$cache_statements"
2017 else
2018 if ! $have_associative; then
2019 if test "$1" != "$cached"; then
2020 func_fatal_error "cache variable collision between $1 and $cached"
2028 # func_get_description module
2029 # Input:
2030 # - local_gnulib_path from --local-dir
2031 # - modcache true or false, from --cache-modules/--no-cache-modules
2032 func_get_description ()
2034 if ! $modcache; then
2035 func_lookup_file "modules/$1"
2036 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
2037 else
2038 func_cache_lookup_module "$1"
2039 # Output the field's value, including the final newline (if any).
2040 if $have_associative; then
2041 if eval 'test -n "${modcache_description[$1]+set}"'; then
2042 eval 'echo "${modcache_description[$1]}"'
2044 else
2045 eval "field_set=\"\$${cachevar}_description_set\""
2046 if test -n "$field_set"; then
2047 eval "field_value=\"\$${cachevar}_description\""
2048 echo "${field_value}"
2054 # func_get_comment module
2055 # Input:
2056 # - local_gnulib_path from --local-dir
2057 # - modcache true or false, from --cache-modules/--no-cache-modules
2058 func_get_comment ()
2060 if ! $modcache; then
2061 func_lookup_file "modules/$1"
2062 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
2063 else
2064 func_cache_lookup_module "$1"
2065 # Output the field's value, including the final newline (if any).
2066 if $have_associative; then
2067 if eval 'test -n "${modcache_comment[$1]+set}"'; then
2068 eval 'echo "${modcache_comment[$1]}"'
2070 else
2071 eval "field_set=\"\$${cachevar}_comment_set\""
2072 if test -n "$field_set"; then
2073 eval "field_value=\"\$${cachevar}_comment\""
2074 echo "${field_value}"
2080 # func_get_status module
2081 # Input:
2082 # - local_gnulib_path from --local-dir
2083 # - modcache true or false, from --cache-modules/--no-cache-modules
2084 func_get_status ()
2086 if ! $modcache; then
2087 func_lookup_file "modules/$1"
2088 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
2089 else
2090 func_cache_lookup_module "$1"
2091 # Output the field's value, including the final newline (if any).
2092 if $have_associative; then
2093 if eval 'test -n "${modcache_status[$1]+set}"'; then
2094 eval 'echo "${modcache_status[$1]}"'
2096 else
2097 eval "field_set=\"\$${cachevar}_status_set\""
2098 if test -n "$field_set"; then
2099 eval "field_value=\"\$${cachevar}_status\""
2100 echo "${field_value}"
2106 # func_get_notice module
2107 # Input:
2108 # - local_gnulib_path from --local-dir
2109 # - modcache true or false, from --cache-modules/--no-cache-modules
2110 func_get_notice ()
2112 if ! $modcache; then
2113 func_lookup_file "modules/$1"
2114 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
2115 else
2116 func_cache_lookup_module "$1"
2117 # Output the field's value, including the final newline (if any).
2118 if $have_associative; then
2119 if eval 'test -n "${modcache_notice[$1]+set}"'; then
2120 eval 'echo "${modcache_notice[$1]}"'
2122 else
2123 eval "field_set=\"\$${cachevar}_notice_set\""
2124 if test -n "$field_set"; then
2125 eval "field_value=\"\$${cachevar}_notice\""
2126 echo "${field_value}"
2132 # func_get_applicability module
2133 # Input:
2134 # - local_gnulib_path from --local-dir
2135 # - modcache true or false, from --cache-modules/--no-cache-modules
2136 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
2137 func_get_applicability ()
2139 if ! $modcache; then
2140 func_lookup_file "modules/$1"
2141 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
2142 else
2143 func_cache_lookup_module "$1"
2144 # Get the field's value, without the final newline.
2145 if $have_associative; then
2146 eval 'my_applicability="${modcache_applicability[$1]}"'
2147 else
2148 eval "my_applicability=\"\$${cachevar}_applicability\""
2151 if test -n "$my_applicability"; then
2152 echo $my_applicability
2153 else
2154 # The default is 'main' or 'tests', depending on the module's name.
2155 case $1 in
2156 *-tests) echo "tests";;
2157 *) echo "main";;
2158 esac
2162 # func_get_filelist module
2163 # Input:
2164 # - local_gnulib_path from --local-dir
2165 # - modcache true or false, from --cache-modules/--no-cache-modules
2166 func_get_filelist ()
2168 if ! $modcache; then
2169 func_lookup_file "modules/$1"
2170 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
2171 else
2172 func_cache_lookup_module "$1"
2173 # Output the field's value, including the final newline (if any).
2174 if $have_associative; then
2175 if eval 'test -n "${modcache_files[$1]+set}"'; then
2176 eval 'echo "${modcache_files[$1]}"'
2178 else
2179 eval "field_set=\"\$${cachevar}_files_set\""
2180 if test -n "$field_set"; then
2181 eval "field_value=\"\$${cachevar}_files\""
2182 echo "${field_value}"
2186 echo m4/00gnulib.m4
2187 echo m4/gnulib-common.m4
2188 case "$autoconf_minversion" in
2189 2.59)
2190 echo m4/onceonly.m4
2192 esac
2195 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2196 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2197 # elements starting with prefix and ending with suffix are considered.
2198 # Processing: removed_prefix and removed_suffix are removed from each element,
2199 # added_prefix and added_suffix are added to each element.
2200 # prefix, suffix should not contain shell-special characters.
2201 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2202 # added_prefix, added_suffix should not contain the characters \|&.
2203 func_filter_filelist ()
2205 if test "$2" != "$nl" \
2206 || { $fast_func_append \
2207 && { test -z "$6" || $fast_func_remove_prefix; } \
2208 && { test -z "$7" || $fast_func_remove_suffix; }; \
2209 }; then
2210 ffflist=
2211 for fff in $3; do
2212 # Do not quote possibly-empty parameters in case patterns,
2213 # AIX and HP-UX ksh won't match them if they are empty.
2214 case "$fff" in
2215 $4*$5)
2216 if test -n "$6"; then
2217 func_remove_prefix fff "$6"
2219 if test -n "$7"; then
2220 func_remove_suffix fff "$7"
2222 fff="$8${fff}$9"
2223 if test -z "$ffflist"; then
2224 ffflist="${fff}"
2225 else
2226 func_append ffflist "$2${fff}"
2229 esac
2230 done
2231 else
2232 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2233 ffflist=`for fff in $3; do
2234 case "$fff" in
2235 $4*$5) echo "$fff" ;;
2236 esac
2237 done | sed -e "$sed_fff_filter"`
2239 eval "$1=\"\$ffflist\""
2242 # func_get_dependencies module
2243 # Input:
2244 # - local_gnulib_path from --local-dir
2245 # - modcache true or false, from --cache-modules/--no-cache-modules
2246 func_get_dependencies ()
2248 # ${module}-tests implicitly depends on ${module}, if that module exists.
2249 case "$1" in
2250 *-tests)
2251 fgd1="$1"
2252 func_remove_suffix fgd1 '-tests'
2253 if func_exists_module "$fgd1"; then
2254 echo "$fgd1"
2257 esac
2258 # Then the explicit dependencies listed in the module description.
2259 { if ! $modcache; then
2260 func_lookup_file "modules/$1"
2261 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2262 else
2263 func_cache_lookup_module "$1"
2264 # Output the field's value, including the final newline (if any).
2265 if $have_associative; then
2266 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2267 eval 'echo "${modcache_dependson[$1]}"'
2269 else
2270 eval "field_set=\"\$${cachevar}_dependson_set\""
2271 if test -n "$field_set"; then
2272 eval "field_value=\"\$${cachevar}_dependson\""
2273 echo "${field_value}"
2278 | sed -e '/^#/d'
2281 # func_get_autoconf_early_snippet module
2282 # Input:
2283 # - local_gnulib_path from --local-dir
2284 # - modcache true or false, from --cache-modules/--no-cache-modules
2285 func_get_autoconf_early_snippet ()
2287 if ! $modcache; then
2288 func_lookup_file "modules/$1"
2289 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2290 else
2291 func_cache_lookup_module "$1"
2292 # Output the field's value, including the final newline (if any).
2293 if $have_associative; then
2294 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2295 eval 'echo "${modcache_configureac_early[$1]}"'
2297 else
2298 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2299 if test -n "$field_set"; then
2300 eval "field_value=\"\$${cachevar}_configureac_early\""
2301 echo "${field_value}"
2307 # func_get_autoconf_snippet module
2308 # Input:
2309 # - local_gnulib_path from --local-dir
2310 # - modcache true or false, from --cache-modules/--no-cache-modules
2311 func_get_autoconf_snippet ()
2313 if ! $modcache; then
2314 func_lookup_file "modules/$1"
2315 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2316 else
2317 func_cache_lookup_module "$1"
2318 # Output the field's value, including the final newline (if any).
2319 if $have_associative; then
2320 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2321 eval 'echo "${modcache_configureac[$1]}"'
2323 else
2324 eval "field_set=\"\$${cachevar}_configureac_set\""
2325 if test -n "$field_set"; then
2326 eval "field_value=\"\$${cachevar}_configureac\""
2327 echo "${field_value}"
2333 # Concatenate lines with trailing slash.
2334 # $1 is an optional filter to restrict the
2335 # concatenation to groups starting with that expression
2336 combine_lines() {
2337 sed -e "/$1.*"'\\$/{
2340 s/\\\n/ /
2341 s/\\$/\\/
2346 # func_get_automake_snippet_conditional module
2347 # returns the part of the Makefile.am snippet that can be put inside Automake
2348 # conditionals.
2349 # Input:
2350 # - local_gnulib_path from --local-dir
2351 # - modcache true or false, from --cache-modules/--no-cache-modules
2352 func_get_automake_snippet_conditional ()
2354 if ! $modcache; then
2355 func_lookup_file "modules/$1"
2356 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2357 else
2358 func_cache_lookup_module "$1"
2359 # Output the field's value, including the final newline (if any).
2360 if $have_associative; then
2361 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2362 eval 'echo "${modcache_makefile[$1]}"'
2364 else
2365 eval "field_set=\"\$${cachevar}_makefile_set\""
2366 if test -n "$field_set"; then
2367 eval "field_value=\"\$${cachevar}_makefile\""
2368 echo "${field_value}"
2374 # func_get_automake_snippet_unconditional module
2375 # returns the part of the Makefile.am snippet that must stay outside of
2376 # Automake conditionals.
2377 # Input:
2378 # - local_gnulib_path from --local-dir
2379 # - modcache true or false, from --cache-modules/--no-cache-modules
2380 func_get_automake_snippet_unconditional ()
2382 case "$1" in
2383 *-tests)
2384 # *-tests module live in tests/, not lib/.
2385 # Synthesize an EXTRA_DIST augmentation.
2386 all_files=`func_get_filelist $1`
2387 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2388 extra_files="$tests_files"
2389 if test -n "$extra_files"; then
2390 echo "EXTRA_DIST +=" $extra_files
2391 echo
2395 # Synthesize an EXTRA_DIST augmentation.
2396 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2397 already_mentioned_files=` \
2398 { if ! $modcache; then
2399 func_lookup_file "modules/$1"
2400 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2401 else
2402 func_cache_lookup_module "$1"
2403 if $have_associative; then
2404 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2405 eval 'echo "${modcache_makefile[$1]}"'
2407 else
2408 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2409 if test -n "$field_set"; then
2410 eval 'field_value="$'"${cachevar}"'_makefile"'
2411 echo "${field_value}"
2416 | combine_lines \
2417 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2418 all_files=`func_get_filelist $1`
2419 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2420 # Remove $already_mentioned_files from $lib_files.
2421 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2422 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2423 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2424 if test -n "$extra_files"; then
2425 echo "EXTRA_DIST +=" $extra_files
2426 echo
2428 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2429 # This is necessary so that automake can generate the right list of
2430 # dependency rules.
2431 # A possible approach would be to use autom4te --trace of the redefined
2432 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2433 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2434 # inside autoconf's built-in macros are not missed).
2435 # But it's simpler and more robust to do it here, based on the file list.
2436 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2437 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2438 # automake will generate a useless dependency; this is harmless.
2439 case "$1" in
2440 relocatable-prog-wrapper) ;;
2441 pt_chown) ;;
2443 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2444 if test -n "$extra_files"; then
2445 echo "EXTRA_lib_SOURCES +=" $extra_files
2446 echo
2449 esac
2450 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2451 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2452 if test -n "$buildaux_files"; then
2453 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2454 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2455 echo
2457 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2458 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2459 if test -n "$top_files"; then
2460 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2461 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
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 # - modcache true or false, from --cache-modules/--no-cache-modules
2784 # - modules list of specified modules
2785 # - inctests true if tests should be included, false otherwise
2786 # - incobsolete true if obsolete modules among dependencies should be
2787 # included, blank otherwise
2788 # - inc_cxx_tests true if C++ interoperability tests should be included,
2789 # blank otherwise
2790 # - inc_longrunning_tests true if long-runnings tests should be included,
2791 # blank otherwise
2792 # - inc_privileged_tests true if tests that require root privileges should be
2793 # included, blank otherwise
2794 # - inc_unportable_tests true if tests that fail on some platforms should be
2795 # included, blank otherwise
2796 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2797 # the unit tests of the specified modules should be
2798 # included, blank otherwise
2799 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2800 # the unit tests of the dependencies should be
2801 # included, blank otherwise
2802 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2803 # blank otherwise
2804 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2805 # blank otherwise
2806 # - excl_privileged_tests true if tests that require root privileges should be
2807 # excluded, blank otherwise
2808 # - excl_unportable_tests true if tests that fail on some platforms should be
2809 # excluded, blank otherwise
2810 # - avoidlist list of modules to avoid
2811 # - cond_dependencies true if conditional dependencies shall be supported,
2812 # blank otherwise
2813 # - tmp pathname of a temporary directory
2814 # Output:
2815 # - modules list of modules, including dependencies
2816 # - conddep_dependers, conddep_condition information about conditionally
2817 # enabled modules
2818 func_modules_transitive_closure ()
2820 sed_escape_dependency='s|\([/.]\)|\\\1|g'
2821 # In order to process every module only once (for speed), process an "input
2822 # list" of modules, producing an "output list" of modules. During each round,
2823 # more modules can be queued in the input list. Once a module on the input
2824 # list has been processed, it is added to the "handled list", so we can avoid
2825 # to process it again.
2826 handledmodules=
2827 inmodules="$modules"
2828 outmodules=
2829 fmtc_inc_all_tests="$inc_all_direct_tests"
2830 if test "$cond_dependencies" = true; then
2831 for module in $inmodules; do
2832 func_verify_module
2833 if test -n "$module"; then
2834 if func_acceptable $module; then
2835 func_uncond_add_module $module
2838 done
2840 while test -n "$inmodules"; do
2841 inmodules_this_round="$inmodules"
2842 inmodules= # Accumulator, queue for next round
2843 for module in $inmodules_this_round; do
2844 func_verify_module
2845 if test -n "$module"; then
2846 if func_acceptable $module; then
2847 func_append outmodules " $module"
2848 if test "$cond_dependencies" = true; then
2849 if func_get_automake_snippet_conditional $module | grep '^if ' > /dev/null; then
2850 # A module whose Makefile.am snippet contains a reference to an
2851 # automake conditional. If we were to use it conditionally, we
2852 # would get an error
2853 # configure: error: conditional "..." was never defined.
2854 # because automake 1.11.1 does not handle nested conditionals
2855 # correctly. As a workaround, make the module unconditional.
2856 func_uncond_add_module $module
2858 if func_cond_module_p $module; then
2859 conditional=true
2860 else
2861 conditional=false
2864 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2865 # Duplicate dependencies are harmless, but Jim wants a warning.
2866 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2867 if test -n "$duplicated_deps"; then
2868 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2870 if $inctests; then
2871 testsmodule=`func_get_tests_module $module`
2872 if test -n "$testsmodule"; then
2873 deps="$deps $testsmodule"
2876 for dep in $deps; do
2877 # Determine whether to include the dependency or tests module.
2878 inc=true
2879 for word in `func_get_status $dep`; do
2880 case "$word" in
2881 obsolete)
2882 test -n "$incobsolete" \
2883 || inc=false
2885 c++-test)
2886 test -z "$excl_cxx_tests" \
2887 || inc=false
2888 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2889 || inc=false
2891 longrunning-test)
2892 test -z "$excl_longrunning_tests" \
2893 || inc=false
2894 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2895 || inc=false
2897 privileged-test)
2898 test -z "$excl_privileged_tests" \
2899 || inc=false
2900 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2901 || inc=false
2903 unportable-test)
2904 test -z "$excl_unportable_tests" \
2905 || inc=false
2906 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2907 || inc=false
2909 *-test)
2910 test -n "$fmtc_inc_all_tests" \
2911 || inc=false
2913 esac
2914 done
2915 if $inc && func_acceptable "$dep"; then
2916 func_append inmodules " $dep"
2917 if test "$cond_dependencies" = true; then
2918 escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
2919 sed_extract_condition1='/^ *'"$escaped_dep"' *$/{
2920 s/^.*$/true/p
2922 sed_extract_condition2='/^ *'"$escaped_dep"' *\[.*\] *$/{
2923 s/^ *'"$escaped_dep"' *\[\(.*\)\] *$/\1/p
2925 condition=`func_get_dependencies $module | sed -n -e "$sed_extract_condition1" -e "$sed_extract_condition2"`
2926 if test "$condition" = true; then
2927 condition=
2929 if test -n "$condition"; then
2930 func_conddep_add_module "$module" "$dep" "$condition"
2931 else
2932 if $conditional; then
2933 func_conddep_add_module "$module" "$dep" true
2934 else
2935 func_uncond_add_module "$dep"
2940 done
2943 done
2944 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2945 # Remove $handledmodules from $inmodules.
2946 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2947 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2948 fmtc_inc_all_tests="$inc_all_indirect_tests"
2949 done
2950 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2951 rm -f "$tmp"/queued-modules
2954 # func_show_module_list
2955 # Input:
2956 # - specified_modules list of specified modules (one per line, sorted)
2957 # - modules complete list of modules (one per line, sorted)
2958 # - tmp pathname of a temporary directory
2959 func_show_module_list ()
2961 if case "$TERM" in
2962 xterm*) test -t 1;;
2963 *) false;;
2964 esac; then
2965 # Assume xterm compatible escape sequences.
2966 bold_on=`printf '\033[1m'`
2967 bold_off=`printf '\033[0m'`
2968 else
2969 bold_on=
2970 bold_off=
2972 echo "Module list with included dependencies (indented):"
2973 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2974 echo "$modules" | sed -e '/^$/d' \
2975 | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
2976 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2979 # func_modules_transitive_closure_separately
2980 # Determine main module list and tests-related module list separately.
2981 # The main module list is the transitive closure of the specified modules,
2982 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2983 # is specified, it will consist only of LGPLed source.
2984 # The tests-related module list is the transitive closure of the specified
2985 # modules, including tests modules, minus the main module list excluding
2986 # modules of applicability 'all'. Its lib/* sources (brought in through
2987 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
2988 # source, even if --lgpl is specified.
2989 # Input:
2990 # - local_gnulib_path from --local-dir
2991 # - modcache true or false, from --cache-modules/--no-cache-modules
2992 # - specified_modules list of specified modules
2993 # - inctests true if tests should be included, false otherwise
2994 # - incobsolete true if obsolete modules among dependencies should be
2995 # included, blank otherwise
2996 # - inc_cxx_tests true if C++ interoperability tests should be included,
2997 # blank otherwise
2998 # - inc_longrunning_tests true if long-runnings tests should be included,
2999 # blank otherwise
3000 # - inc_privileged_tests true if tests that require root privileges should be
3001 # included, blank otherwise
3002 # - inc_unportable_tests true if tests that fail on some platforms should be
3003 # included, blank otherwise
3004 # - inc_all_direct_tests true if all kinds of problematic unit tests among
3005 # the unit tests of the specified modules should be
3006 # included, blank otherwise
3007 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
3008 # the unit tests of the dependencies should be
3009 # included, blank otherwise
3010 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
3011 # blank otherwise
3012 # - excl_longrunning_tests true if long-runnings tests should be excluded,
3013 # blank otherwise
3014 # - excl_privileged_tests true if tests that require root privileges should be
3015 # excluded, blank otherwise
3016 # - excl_unportable_tests true if tests that fail on some platforms should be
3017 # excluded, blank otherwise
3018 # - avoidlist list of modules to avoid
3019 # - cond_dependencies true if conditional dependencies shall be supported,
3020 # blank otherwise
3021 # - tmp pathname of a temporary directory
3022 # Output:
3023 # - main_modules list of modules, including dependencies
3024 # - testsrelated_modules list of tests-related modules, including dependencies
3025 # - conddep_dependers, conddep_condition information about conditionally
3026 # enabled modules
3027 func_modules_transitive_closure_separately ()
3029 # Determine main module list.
3030 saved_inctests="$inctests"
3031 inctests=false
3032 modules="$specified_modules"
3033 func_modules_transitive_closure
3034 main_modules="$modules"
3035 inctests="$saved_inctests"
3036 if test $verbose -ge 1; then
3037 echo "Main module list:"
3038 echo "$main_modules" | sed -e 's/^/ /'
3040 # Determine tests-related module list.
3041 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3042 testsrelated_modules=`for module in $main_modules; do
3043 if test \`func_get_applicability $module\` = main; then
3044 echo $module
3046 done \
3047 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3048 if test $verbose -ge 1; then
3049 echo "Tests-related module list:"
3050 echo "$testsrelated_modules" | sed -e 's/^/ /'
3054 # func_determine_use_libtests
3055 # Determines whether a $testsbase/libtests.a is needed.
3056 # Input:
3057 # - local_gnulib_path from --local-dir
3058 # - modcache true or false, from --cache-modules/--no-cache-modules
3059 # - testsrelated_modules list of tests-related modules, including dependencies
3060 # Output:
3061 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3062 func_determine_use_libtests ()
3064 use_libtests=false
3065 for module in $testsrelated_modules; do
3066 func_verify_nontests_module
3067 if test -n "$module"; then
3068 all_files=`func_get_filelist $module`
3069 # Test whether some file in $all_files lies in lib/.
3070 for f in $all_files; do
3071 case $f in
3072 lib/*)
3073 use_libtests=true
3074 break 2
3076 esac
3077 done
3079 done
3082 # func_modules_add_dummy
3083 # Input:
3084 # - local_gnulib_path from --local-dir
3085 # - modcache true or false, from --cache-modules/--no-cache-modules
3086 # - modules list of modules, including dependencies
3087 # Output:
3088 # - modules list of modules, including 'dummy' if needed
3089 func_modules_add_dummy ()
3091 # Determine whether any module provides a lib_SOURCES augmentation.
3092 have_lib_SOURCES=
3093 for module in $modules; do
3094 func_verify_nontests_module
3095 if test -n "$module"; then
3096 # Extract the value of "lib_SOURCES += ...".
3097 for file in `func_get_automake_snippet "$module" | combine_lines |
3098 sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
3099 # Ignore .h files since they are not compiled.
3100 case "$file" in
3101 *.h) ;;
3103 have_lib_SOURCES=yes
3104 break 2
3106 esac
3107 done
3109 done
3110 # Add the dummy module, to make sure the library will be non-empty.
3111 if test -z "$have_lib_SOURCES"; then
3112 if func_acceptable "dummy"; then
3113 func_append modules " dummy"
3118 # func_modules_add_dummy_separately
3119 # Input:
3120 # - local_gnulib_path from --local-dir
3121 # - modcache true or false, from --cache-modules/--no-cache-modules
3122 # - main_modules list of modules, including dependencies
3123 # - testsrelated_modules list of tests-related modules, including dependencies
3124 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3125 # Output:
3126 # - main_modules list of modules, including 'dummy' if needed
3127 # - testsrelated_modules list of tests-related modules, including 'dummy' if
3128 # needed
3129 func_modules_add_dummy_separately ()
3131 # Add the dummy module to the main module list if needed.
3132 modules="$main_modules"
3133 func_modules_add_dummy
3134 main_modules="$modules"
3136 # Add the dummy module to the tests-related module list if needed.
3137 if $use_libtests; then
3138 modules="$testsrelated_modules"
3139 func_modules_add_dummy
3140 testsrelated_modules="$modules"
3144 # func_modules_notice
3145 # Input:
3146 # - local_gnulib_path from --local-dir
3147 # - modcache true or false, from --cache-modules/--no-cache-modules
3148 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3149 # - modules list of modules, including dependencies
3150 func_modules_notice ()
3152 if test $verbose -ge -1; then
3153 for module in $modules; do
3154 func_verify_module
3155 if test -n "$module"; then
3156 msg=`func_get_notice $module`
3157 if test -n "$msg"; then
3158 echo "Notice from module $module:"
3159 echo "$msg" | sed -e 's/^/ /'
3162 done
3166 # func_modules_to_filelist
3167 # Input:
3168 # - local_gnulib_path from --local-dir
3169 # - modcache true or false, from --cache-modules/--no-cache-modules
3170 # - modules list of modules, including dependencies
3171 # Output:
3172 # - files list of files
3173 func_modules_to_filelist ()
3175 files=
3176 for module in $modules; do
3177 func_verify_module
3178 if test -n "$module"; then
3179 fs=`func_get_filelist $module`
3180 func_append files " $fs"
3182 done
3183 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
3186 # func_modules_to_filelist_separately
3187 # Determine the final file lists.
3188 # They must be computed separately, because files in lib/* go into
3189 # $sourcebase/ if they are in the main file list but into $testsbase/
3190 # if they are in the tests-related file list. Furthermore lib/dummy.c
3191 # can be in both.
3192 # Input:
3193 # - local_gnulib_path from --local-dir
3194 # - modcache true or false, from --cache-modules/--no-cache-modules
3195 # - main_modules list of modules, including dependencies
3196 # - testsrelated_modules list of tests-related modules, including dependencies
3197 func_modules_to_filelist_separately ()
3199 # Determine final main file list.
3200 modules="$main_modules"
3201 func_modules_to_filelist
3202 main_files="$files"
3203 # Determine final tests-related file list.
3204 modules="$testsrelated_modules"
3205 func_modules_to_filelist
3206 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3207 # Merge both file lists.
3208 sed_remove_empty_lines='/^$/d'
3209 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3210 if test $verbose -ge 0; then
3211 echo "File list:"
3212 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3213 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3217 # func_compute_include_guard_prefix
3218 # Determine include_guard_prefix.
3219 # Input:
3220 # - macro_prefix prefix of gl_LIBOBJS macros to use
3221 # Output:
3222 # - include_guard_prefix replacement for ${gl_include_guard_prefix}
3223 # - sed_replace_include_guard_prefix
3224 # sed expression for resolving ${gl_include_guard_prefix}
3225 func_compute_include_guard_prefix ()
3227 if test "$macro_prefix" = gl; then
3228 include_guard_prefix='GL'
3229 else
3230 include_guard_prefix='GL_'`echo "$macro_prefix" | LC_ALL=C tr '[a-z]' '[A-Z]'`
3232 sed_replace_include_guard_prefix='s/\${gl_include_guard_prefix}/'"${include_guard_prefix}"'/g'
3235 # func_execute_command command [args...]
3236 # Executes a command.
3237 # Uses also the variables
3238 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3239 func_execute_command ()
3241 if test $verbose -ge 0; then
3242 echo "executing $*"
3243 "$@"
3244 else
3245 # Commands like automake produce output to stderr even when they succeed.
3246 # Turn this output off if the command succeeds.
3247 "$@" > "$tmp"/cmdout 2>&1
3248 cmdret=$?
3249 if test $cmdret = 0; then
3250 rm -f "$tmp"/cmdout
3251 else
3252 echo "executing $*"
3253 cat "$tmp"/cmdout 1>&2
3254 rm -f "$tmp"/cmdout
3255 (exit $cmdret)
3260 # func_dest_tmpfilename file
3261 # determines the name of a temporary file (file is relative to destdir).
3262 # Input:
3263 # - destdir target directory
3264 # - doit : if actions shall be executed, false if only to be printed
3265 # - tmp pathname of a temporary directory
3266 # Sets variable:
3267 # - tmpfile absolute filename of the temporary file
3268 func_dest_tmpfilename ()
3270 if $doit; then
3271 # Put the new contents of $file in a file in the same directory (needed
3272 # to guarantee that an 'mv' to "$destdir/$file" works).
3273 tmpfile="$destdir/$1.tmp"
3274 else
3275 # Put the new contents of $file in a file in a temporary directory
3276 # (because the directory of "$file" might not exist).
3277 tmpfile="$tmp"/`basename "$1"`.tmp
3281 # func_is_local_file lookedup_file file
3282 # check whether file should be instantiated from local gnulib directory
3283 func_is_local_file ()
3285 dname=$1
3286 func_remove_suffix dname "/$2"
3287 func_path_foreach "$local_gnulib_path" test %dir% = "$dname"
3290 # func_should_symlink
3291 # returns 0 when the file $f should be symlinked
3292 # Input:
3293 # - symbolic true if files should be symlinked, copied otherwise
3294 # - lsymbolic true if files from local_gnulib_path should be symlinked,
3295 # copied otherwise
3296 # - f the original file name
3297 # - lookedup_file name of the merged (combined) file
3298 func_should_symlink ()
3300 test -n "$symbolic" \
3301 || { test -n "$lsymbolic" \
3302 && func_is_local_file "$lookedup_file" "$f"; }
3305 # func_add_file
3306 # copies a file from gnulib into the destination directory. The destination
3307 # is known to not exist.
3308 # Input:
3309 # - destdir target directory
3310 # - local_gnulib_path from --local-dir
3311 # - modcache true or false, from --cache-modules/--no-cache-modules
3312 # - f the original file name
3313 # - lookedup_file name of the merged (combined) file
3314 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3315 # - g the rewritten file name
3316 # - tmpfile absolute filename of the temporary file
3317 # - doit : if actions shall be executed, false if only to be printed
3318 # - symbolic true if files should be symlinked, copied otherwise
3319 # - lsymbolic true if files from local_gnulib_path should be symlinked,
3320 # copied otherwise
3321 func_add_file ()
3323 if $doit; then
3324 echo "Copying file $g"
3325 if func_should_symlink \
3326 && test -z "$lookedup_tmp" \
3327 && cmp -s "$lookedup_file" "$tmpfile"; then
3328 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3329 else
3330 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3332 else
3333 echo "Copy file $g"
3337 # func_update_file
3338 # copies a file from gnulib into the destination directory. The destination
3339 # is known to exist.
3340 # Input:
3341 # - destdir target directory
3342 # - local_gnulib_path from --local-dir
3343 # - modcache true or false, from --cache-modules/--no-cache-modules
3344 # - f the original file name
3345 # - lookedup_file name of the merged (combined) file
3346 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3347 # - g the rewritten file name
3348 # - tmpfile absolute filename of the temporary file
3349 # - doit : if actions shall be executed, false if only to be printed
3350 # - symbolic true if files should be symlinked, copied otherwise
3351 # - lsymbolic true if files from local_gnulib_path should be symlinked,
3352 # copied otherwise
3353 # - already_present nonempty if the file should already exist, empty otherwise
3354 func_update_file ()
3356 if cmp -s "$destdir/$g" "$tmpfile"; then
3357 : # The file has not changed.
3358 else
3359 # Replace the file.
3360 if $doit; then
3361 if test -n "$already_present"; then
3362 echo "Updating file $g (backup in ${g}~)"
3363 else
3364 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
3366 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3367 if func_should_symlink \
3368 && test -z "$lookedup_tmp" \
3369 && cmp -s "$lookedup_file" "$tmpfile"; then
3370 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3371 else
3372 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3374 else
3375 if test -n "$already_present"; then
3376 echo "Update file $g (backup in ${g}~)"
3377 else
3378 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
3384 # func_emit_lib_Makefile_am
3385 # emits the contents of library makefile to standard output.
3386 # Input:
3387 # - local_gnulib_path from --local-dir
3388 # - modcache true or false, from --cache-modules/--no-cache-modules
3389 # - modules list of modules, including dependencies
3390 # - libname library name
3391 # - pobase directory relative to destdir where to place *.po files
3392 # - auxdir directory relative to destdir where to place build aux files
3393 # - makefile_name from --makefile-name
3394 # - libtool true if libtool will be used, false or blank otherwise
3395 # - macro_prefix prefix of gl_LIBOBJS macros to use
3396 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3397 # - witness_c_macro from --witness-c-macro
3398 # - actioncmd (optional) command that will reproduce this invocation
3399 # - for_test true if creating a package for testing, false otherwise
3400 # - sed_replace_include_guard_prefix
3401 # sed expression for resolving ${gl_include_guard_prefix}
3402 # - destfile filename relative to destdir of makefile being generated
3403 # Input/Output:
3404 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3405 # list of edits to be done to Makefile.am variables
3406 # Output:
3407 # - uses_subdirs nonempty if object files in subdirs exist
3408 func_emit_lib_Makefile_am ()
3410 # When creating an includable Makefile.am snippet, augment variables with
3411 # += instead of assigning them.
3412 if test -n "$makefile_name"; then
3413 assign='+='
3414 else
3415 assign='='
3417 if test "$libtool" = true; then
3418 libext=la
3419 perhapsLT=LT
3420 sed_eliminate_LDFLAGS="$sed_noop"
3421 else
3422 libext=a
3423 perhapsLT=
3424 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3426 if $for_test; then
3427 # When creating a package for testing: Attempt to provoke failures,
3428 # especially link errors, already during "make" rather than during
3429 # "make check", because "make check" is not possible in a cross-compiling
3430 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3431 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3432 else
3433 sed_transform_check_PROGRAMS="$sed_noop"
3435 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3436 echo "## Process this file with automake to produce Makefile.in."
3437 func_emit_copyright_notice
3438 if test -n "$actioncmd"; then
3439 # The maximum line length (excluding the terminating newline) of any file
3440 # that is to be preprocessed by config.status is 3070. config.status uses
3441 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
3442 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
3443 len=`echo "$actioncmd" | wc -c`
3444 if test -n "$len" && test "$len" -le 3000; then
3445 echo "# Reproduce by: $actioncmd"
3448 echo
3449 uses_subdirs=
3451 for module in $modules; do
3452 func_verify_nontests_module
3453 if test -n "$module"; then
3455 func_get_automake_snippet_conditional "$module" |
3456 LC_ALL=C \
3457 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3458 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3459 -e "$sed_eliminate_LDFLAGS" \
3460 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3461 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3462 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3463 -e "$sed_transform_check_PROGRAMS" \
3464 -e "$sed_replace_include_guard_prefix"
3465 if test "$module" = 'alloca'; then
3466 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
3467 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3469 } | combine_lines "${libname}_${libext}_SOURCES" > "$tmp"/amsnippet1
3471 func_get_automake_snippet_unconditional "$module" |
3472 LC_ALL=C sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
3473 } > "$tmp"/amsnippet2
3474 # Skip the contents if it's entirely empty.
3475 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
3476 echo "## begin gnulib module $module"
3477 echo
3478 if test "$cond_dependencies" = true; then
3479 if func_cond_module_p "$module"; then
3480 func_module_conditional_name "$module"
3481 echo "if $conditional"
3484 cat "$tmp"/amsnippet1
3485 if test "$cond_dependencies" = true; then
3486 if func_cond_module_p "$module"; then
3487 echo "endif"
3490 cat "$tmp"/amsnippet2
3491 echo "## end gnulib module $module"
3492 echo
3494 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
3495 # Test whether there are some source files in subdirectories.
3496 for f in `func_get_filelist "$module"`; do
3497 case $f in
3498 lib/*/*.c)
3499 uses_subdirs=yes
3500 break
3502 esac
3503 done
3505 done
3506 } > "$tmp"/allsnippets
3507 if test -z "$makefile_name"; then
3508 # If there are source files in subdirectories, prevent collision of the
3509 # object files (example: hash.c and libxml/hash.c).
3510 subdir_options=
3511 if test -n "$uses_subdirs"; then
3512 subdir_options=' subdir-objects'
3514 echo "AUTOMAKE_OPTIONS = 1.9.6 gnits${subdir_options}"
3516 echo
3517 if test -z "$makefile_name"; then
3518 echo "SUBDIRS ="
3519 echo "noinst_HEADERS ="
3520 echo "noinst_LIBRARIES ="
3521 echo "noinst_LTLIBRARIES ="
3522 # Automake versions < 1.11.4 create an empty pkgdatadir at
3523 # installation time if you specify pkgdata_DATA to empty.
3524 # See automake bugs #10997 and #11030:
3525 # * http://debbugs.gnu.org/10997
3526 # * http://debbugs.gnu.org/11030
3527 # So we need this workaround.
3528 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
3529 echo "pkgdata_DATA ="
3531 echo "EXTRA_DIST ="
3532 echo "BUILT_SOURCES ="
3533 echo "SUFFIXES ="
3535 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3536 if test -z "$makefile_name"; then
3537 echo "MOSTLYCLEANDIRS ="
3538 echo "CLEANFILES ="
3539 echo "DISTCLEANFILES ="
3540 echo "MAINTAINERCLEANFILES ="
3542 # Execute edits that apply to the Makefile.am being generated.
3543 edit=0
3544 while test $edit != $makefile_am_edits; do
3545 edit=`expr $edit + 1`
3546 eval dir=\"\$makefile_am_edit${edit}_dir\"
3547 eval var=\"\$makefile_am_edit${edit}_var\"
3548 eval val=\"\$makefile_am_edit${edit}_val\"
3549 if test -n "$var"; then
3550 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3551 echo "${var} += ${val}"
3552 eval "makefile_am_edit${edit}_var="
3555 done
3556 if test -n "$witness_c_macro"; then
3557 cppflags_part1=" -D$witness_c_macro=1"
3558 else
3559 cppflags_part1=
3561 if $for_test; then
3562 cppflags_part2=" -DGNULIB_STRICT_CHECKING=1"
3563 else
3564 cppflags_part2=
3566 if test -z "$makefile_name"; then
3567 echo
3568 echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
3569 echo "AM_CFLAGS ="
3570 else
3571 if test -n "$cppflags_part1$cppflags_part2"; then
3572 echo
3573 echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
3576 echo
3577 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
3578 || { test -n "$makefile_name" \
3579 && test -f "$sourcebase/Makefile.am" \
3580 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
3581 }; then
3582 # One of the snippets or the user's Makefile.am already specifies an
3583 # installation location for the library. Don't confuse automake by saying
3584 # it should not be installed.
3586 else
3587 # By default, the generated library should not be installed.
3588 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3590 echo
3591 echo "${libname}_${libext}_SOURCES ="
3592 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3593 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3594 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3595 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3596 echo "EXTRA_${libname}_${libext}_SOURCES ="
3597 if test "$libtool" = true; then
3598 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3599 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3600 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3601 # the link dependencies of all modules.
3602 for module in $modules; do
3603 func_verify_nontests_module
3604 if test -n "$module"; then
3605 func_get_link_directive "$module"
3607 done \
3608 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
3609 | LC_ALL=C sort -u \
3610 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
3612 echo
3613 if test -n "$pobase"; then
3614 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
3615 echo
3617 cat "$tmp"/allsnippets \
3618 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3619 echo
3620 echo "mostlyclean-local: mostlyclean-generic"
3621 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3622 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3623 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3624 echo " fi; \\"
3625 echo " done; \\"
3626 echo " :"
3627 rm -f "$tmp"/allsnippets
3630 # func_emit_po_Makevars
3631 # emits the contents of po/ makefile parameterization to standard output.
3632 # Input:
3633 # - local_gnulib_path from --local-dir
3634 # - modcache true or false, from --cache-modules/--no-cache-modules
3635 # - sourcebase directory relative to destdir where to place source code
3636 # - pobase directory relative to destdir where to place *.po files
3637 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3638 func_emit_po_Makevars ()
3640 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3641 func_emit_copyright_notice
3642 echo
3643 echo "# Usually the message domain is the same as the package name."
3644 echo "# But here it has a '-gnulib' suffix."
3645 echo "DOMAIN = ${po_domain}-gnulib"
3646 echo
3647 echo "# These two variables depend on the location of this directory."
3648 echo "subdir = ${pobase}"
3649 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
3650 echo
3651 cat <<\EOF
3652 # These options get passed to xgettext.
3653 XGETTEXT_OPTIONS = \
3654 --keyword=_ --flag=_:1:pass-c-format \
3655 --keyword=N_ --flag=N_:1:pass-c-format \
3656 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
3657 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
3658 --flag=error:3:c-format --flag=error_at_line:5:c-format
3660 # This is the copyright holder that gets inserted into the header of the
3661 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
3662 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
3664 # This is the email address or URL to which the translators shall report
3665 # bugs in the untranslated strings:
3666 # - Strings which are not entire sentences, see the maintainer guidelines
3667 # in the GNU gettext documentation, section 'Preparing Strings'.
3668 # - Strings which use unclear terms or require additional context to be
3669 # understood.
3670 # - Strings which make invalid assumptions about notation of date, time or
3671 # money.
3672 # - Pluralisation problems.
3673 # - Incorrect English spelling.
3674 # - Incorrect formatting.
3675 # It can be your email address, or a mailing list address where translators
3676 # can write to without being subscribed, or the URL of a web page through
3677 # which the translators can contact you.
3678 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3680 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3681 # message catalogs shall be used. It is usually empty.
3682 EXTRA_LOCALE_CATEGORIES =
3684 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3685 # context. Possible values are "yes" and "no". Set this to yes if the
3686 # package uses functions taking also a message context, like pgettext(), or
3687 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3688 USE_MSGCTXT = no
3692 # func_emit_po_POTFILES_in
3693 # emits the file list to be passed to xgettext to standard output.
3694 # Input:
3695 # - local_gnulib_path from --local-dir
3696 # - modcache true or false, from --cache-modules/--no-cache-modules
3697 # - sourcebase directory relative to destdir where to place source code
3698 # - files list of new files
3699 func_emit_po_POTFILES_in ()
3701 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3702 func_emit_copyright_notice
3703 echo
3704 echo "# List of files which contain translatable strings."
3705 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3708 # func_emit_tests_Makefile_am witness_macro
3709 # emits the contents of tests makefile to standard output.
3710 # Input:
3711 # - local_gnulib_path from --local-dir
3712 # - modcache true or false, from --cache-modules/--no-cache-modules
3713 # - modules list of modules, including dependencies
3714 # - libname library name
3715 # - auxdir directory relative to destdir where to place build aux files
3716 # - makefile_name from --makefile-name
3717 # - libtool true if libtool will be used, false or blank otherwise
3718 # - sourcebase relative directory containing lib source code
3719 # - m4base relative directory containing autoconf macros
3720 # - testsbase relative directory containing unit test code
3721 # - macro_prefix prefix of gl_LIBOBJS macros to use
3722 # - witness_c_macro from --witness-c-macro
3723 # - for_test true if creating a package for testing, false otherwise
3724 # - single_configure true if a single configure file should be generated,
3725 # false for a separate configure file for the tests
3726 # - use_libtests true if a libtests.a should be built, false otherwise
3727 # - sed_replace_include_guard_prefix
3728 # sed expression for resolving ${gl_include_guard_prefix}
3729 # - destfile filename relative to destdir of makefile being generated
3730 # Input/Output:
3731 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3732 # list of edits to be done to Makefile.am variables
3733 # Output:
3734 # - uses_subdirs nonempty if object files in subdirs exist
3735 func_emit_tests_Makefile_am ()
3737 witness_macro="$1"
3738 if test "$libtool" = true; then
3739 libext=la
3740 perhapsLT=LT
3741 sed_eliminate_LDFLAGS="$sed_noop"
3742 else
3743 libext=a
3744 perhapsLT=
3745 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3747 if $for_test; then
3748 # When creating a package for testing: Attempt to provoke failures,
3749 # especially link errors, already during "make" rather than during
3750 # "make check", because "make check" is not possible in a cross-compiling
3751 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3752 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3753 else
3754 sed_transform_check_PROGRAMS="$sed_noop"
3756 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3757 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3758 echo "## Process this file with automake to produce Makefile.in."
3759 func_emit_copyright_notice
3760 echo
3761 uses_subdirs=
3763 for module in $modules; do
3764 if $for_test && ! $single_configure; then
3765 func_verify_tests_module
3766 else
3767 func_verify_module
3769 if test -n "$module"; then
3771 func_get_automake_snippet "$module" |
3772 LC_ALL=C \
3773 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3774 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3775 -e "$sed_eliminate_LDFLAGS" \
3776 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3777 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3778 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3779 -e "$sed_transform_check_PROGRAMS" \
3780 -e "$sed_replace_include_guard_prefix"
3781 if $use_libtests && test "$module" = 'alloca'; then
3782 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3783 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3785 } > "$tmp"/amsnippet
3786 # Skip the contents if it's entirely empty.
3787 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3788 # Mention long-running tests at the end.
3789 ofd=3
3790 for word in `func_get_status "$module"`; do
3791 if test "$word" = 'longrunning-test'; then
3792 ofd=4
3793 break
3795 done
3796 { echo "## begin gnulib module $module"
3797 echo
3798 cat "$tmp"/amsnippet
3799 echo "## end gnulib module $module"
3800 echo
3801 } >&$ofd
3803 rm -f "$tmp"/amsnippet
3804 # Test whether there are some source files in subdirectories.
3805 for f in `func_get_filelist "$module"`; do
3806 case $f in
3807 lib/*/*.c | tests/*/*.c)
3808 uses_subdirs=yes
3809 break
3811 esac
3812 done
3814 done
3815 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3816 # Generate dependencies here, since it eases the debugging of test failures.
3817 # If there are source files in subdirectories, prevent collision of the
3818 # object files (example: hash.c and libxml/hash.c).
3819 subdir_options=
3820 if test -n "$uses_subdirs"; then
3821 subdir_options=' subdir-objects'
3823 echo "AUTOMAKE_OPTIONS = 1.9.6 foreign${subdir_options}"
3824 echo
3825 if $for_test && ! $single_configure; then
3826 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3827 echo
3829 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3830 # variable is needed to avoid an error from automake:
3831 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3832 echo "SUBDIRS = ."
3833 echo "TESTS ="
3834 echo "XFAIL_TESTS ="
3835 echo "TESTS_ENVIRONMENT ="
3836 echo "noinst_PROGRAMS ="
3837 if ! $for_test; then
3838 echo "check_PROGRAMS ="
3840 echo "noinst_HEADERS ="
3841 echo "noinst_LIBRARIES ="
3842 if $use_libtests; then
3843 if $for_test; then
3844 echo "noinst_LIBRARIES += libtests.a"
3845 else
3846 echo "check_LIBRARIES = libtests.a"
3849 # Automake versions < 1.11.4 create an empty pkgdatadir at
3850 # installation time if you specify pkgdata_DATA to empty.
3851 # See automake bugs #10997 and #11030:
3852 # * http://debbugs.gnu.org/10997
3853 # * http://debbugs.gnu.org/11030
3854 # So we need this workaround.
3855 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3856 echo "pkgdata_DATA ="
3858 echo "EXTRA_DIST ="
3859 echo "BUILT_SOURCES ="
3860 echo "SUFFIXES ="
3861 echo "MOSTLYCLEANFILES = core *.stackdump"
3862 echo "MOSTLYCLEANDIRS ="
3863 echo "CLEANFILES ="
3864 echo "DISTCLEANFILES ="
3865 echo "MAINTAINERCLEANFILES ="
3866 # Execute edits that apply to the Makefile.am being generated.
3867 edit=0
3868 while test $edit != $makefile_am_edits; do
3869 edit=`expr $edit + 1`
3870 eval dir=\"\$makefile_am_edit${edit}_dir\"
3871 eval var=\"\$makefile_am_edit${edit}_var\"
3872 eval val=\"\$makefile_am_edit${edit}_val\"
3873 if test -n "$var"; then
3874 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3875 echo "${var} += ${val}"
3876 eval "makefile_am_edit${edit}_var="
3879 done
3880 echo
3881 echo "AM_CPPFLAGS = \\"
3882 if $for_test; then
3883 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3885 if test -n "$witness_c_macro"; then
3886 echo " -D$witness_c_macro=1 \\"
3888 if test -n "${witness_macro}"; then
3889 echo " -D@${witness_macro}@=1 \\"
3891 echo " -I. -I\$(srcdir) \\"
3892 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3893 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3894 echo
3895 local_ldadd_before=''
3896 local_ldadd_after=''
3897 if $use_libtests; then
3898 # All test programs need to be linked with libtests.a.
3899 # It needs to be passed to the linker before ${libname}.${libext}, since
3900 # the tests-related modules depend on the main modules.
3901 # It also needs to be passed to the linker after ${libname}.${libext}
3902 # because the latter might contain incomplete modules (such as the 'error'
3903 # module whose dependency to 'progname' is voluntarily omitted).
3904 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3905 # not matter.
3906 local_ldadd_before=' libtests.a'
3907 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3909 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3910 echo
3911 if $use_libtests; then
3912 echo "libtests_a_SOURCES ="
3913 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3914 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3915 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3916 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3917 echo "EXTRA_libtests_a_SOURCES ="
3918 # The circular dependency in LDADD requires this.
3919 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3920 echo
3922 # Many test scripts use ${EXEEXT} or ${srcdir}.
3923 # EXEEXT is defined by AC_PROG_CC through autoconf.
3924 # srcdir is defined by autoconf and automake.
3925 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3926 echo
3927 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3928 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3929 echo "# Clean up after Solaris cc."
3930 echo "clean-local:"
3931 echo " rm -rf SunWS_cache"
3932 echo
3933 echo "mostlyclean-local: mostlyclean-generic"
3934 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3935 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3936 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3937 echo " fi; \\"
3938 echo " done; \\"
3939 echo " :"
3940 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3943 # func_emit_initmacro_start macro_prefix
3944 # emits the first few statements of the gl_INIT macro to standard output.
3945 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3946 func_emit_initmacro_start ()
3948 macro_prefix_arg="$1"
3949 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3950 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3951 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3952 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3953 # flexibility.)
3954 # Furthermore it avoids an automake error like this when a Makefile.am
3955 # that uses pieces of gnulib also uses $(LIBOBJ):
3956 # automatically discovered file `error.c' should not be explicitly mentioned
3957 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3958 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3959 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3960 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3961 # automatically discovered file `error.c' should not be explicitly mentioned
3962 # We let automake know about the files to be distributed through the
3963 # EXTRA_lib_SOURCES variable.
3964 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3965 # Create data variables for checking the presence of files that are mentioned
3966 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3967 # because we want the check to happen when the configure file is created,
3968 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3969 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3970 # in which to expect them.
3971 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3972 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3973 echo " gl_COMMON"
3976 # func_emit_initmacro_end macro_prefix
3977 # emits the last few statements of the gl_INIT macro to standard output.
3978 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3979 func_emit_initmacro_end ()
3981 macro_prefix_arg="$1"
3982 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3983 # The check is performed only when autoconf is run from the directory where
3984 # the configure.ac resides; if it is run from a different directory, the
3985 # check is skipped.
3986 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3987 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3988 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3989 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3990 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3991 echo " exit 1"
3992 echo " fi"
3993 echo " done])dnl"
3994 echo " m4_if(m4_sysval, [0], [],"
3995 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3996 echo " ])"
3997 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3998 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3999 echo " m4_popdef([AC_LIBSOURCES])"
4000 echo " m4_popdef([AC_REPLACE_FUNCS])"
4001 echo " m4_popdef([AC_LIBOBJ])"
4002 echo " AC_CONFIG_COMMANDS_PRE(["
4003 echo " ${macro_prefix_arg}_libobjs="
4004 echo " ${macro_prefix_arg}_ltlibobjs="
4005 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
4006 echo " # Remove the extension."
4007 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
4008 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
4009 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
4010 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
4011 echo " done"
4012 echo " fi"
4013 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
4014 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
4015 echo " ])"
4018 # func_emit_initmacro_done macro_prefix sourcebase
4019 # emits a few statements after the gl_INIT macro to standard output.
4020 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4021 # - sourcebase directory relative to destdir where to place source code
4022 func_emit_initmacro_done ()
4024 macro_prefix_arg="$1"
4025 sourcebase_arg="$2"
4026 echo
4027 echo "# Like AC_LIBOBJ, except that the module name goes"
4028 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4029 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
4030 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
4031 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
4032 echo "])"
4033 echo
4034 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
4035 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4036 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
4037 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
4038 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
4039 echo "])"
4040 echo
4041 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
4042 echo "# expected is derived from the gnulib-tool parameterization,"
4043 echo "# and alloca is special cased (for the alloca-opt module)."
4044 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
4045 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
4046 echo " m4_foreach([_gl_NAME], [\$1], ["
4047 echo " m4_if(_gl_NAME, [alloca.c], [], ["
4048 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
4049 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
4050 echo " ])"
4051 echo " ])"
4052 echo "])"
4055 # func_emit_autoconf_snippet indentation
4056 # emits the autoconf snippet of a module.
4057 # Input:
4058 # - indentation spaces to prepend on each line
4059 # - local_gnulib_path from --local-dir
4060 # - modcache true or false, from --cache-modules/--no-cache-modules
4061 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4062 # - sed_replace_include_guard_prefix
4063 # sed expression for resolving ${gl_include_guard_prefix}
4064 # - module the module name
4065 # - toplevel true or false. 'false' means a subordinate use of
4066 # gnulib-tool.
4067 # - disable_libtool true or false. It tells whether to disable libtool
4068 # handling even if it has been specified through the
4069 # command line options.
4070 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4071 # invocations.
4072 func_emit_autoconf_snippet ()
4074 indentation="$1"
4075 if { case $module in
4076 gnumakefile | maintainer-makefile)
4077 # These modules are meant to be used only in the top-level directory.
4078 $toplevel ;;
4080 true ;;
4081 esac
4082 }; then
4083 func_get_autoconf_snippet "$module" \
4084 | sed -e '/^$/d;' -e "s/^/$indentation/" \
4085 -e "$sed_replace_build_aux" \
4086 -e "$sed_replace_include_guard_prefix" \
4087 | { if $disable_libtool; then
4088 sed -e 's/\$gl_cond_libtool/false/g' \
4089 -e 's/gl_libdeps/gltests_libdeps/g' \
4090 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4091 else
4095 | { if $disable_gettext; then
4096 sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
4097 else
4098 # Don't indent AM_GNU_GETTEXT_VERSION line, as that confuses
4099 # autopoint through at least GNU gettext version 0.18.2.
4100 sed -e 's/^ *AM_GNU_GETTEXT_VERSION/AM_GNU_GETTEXT_VERSION/'
4103 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
4104 echo 'changequote(,)dnl'
4105 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4106 echo 'changequote([, ])dnl'
4107 echo 'AC_SUBST([LTALLOCA])'
4112 # func_emit_autoconf_snippets modules verifier toplevel disable_libtool disable_gettext
4113 # collects and emit the autoconf snippets of a set of modules.
4114 # Input:
4115 # - local_gnulib_path from --local-dir
4116 # - modcache true or false, from --cache-modules/--no-cache-modules
4117 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4118 # - sed_replace_include_guard_prefix
4119 # sed expression for resolving ${gl_include_guard_prefix}
4120 # - modules the list of modules.
4121 # - verifier one of func_verify_module, func_verify_nontests_module,
4122 # func_verify_tests_module. It selects the subset of
4123 # $modules to consider.
4124 # - toplevel true or false. 'false' means a subordinate use of
4125 # gnulib-tool.
4126 # - disable_libtool true or false. It tells whether to disable libtool
4127 # handling even if it has been specified through the
4128 # command line options.
4129 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4130 # invocations.
4131 func_emit_autoconf_snippets ()
4133 verifier="$2"
4134 toplevel="$3"
4135 disable_libtool="$4"
4136 disable_gettext="$5"
4137 if test "$cond_dependencies" = true; then
4138 for m in $modules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/modules
4139 # Emit the autoconf code for the unconditional modules.
4140 for module in $1; do
4141 eval $verifier
4142 if test -n "$module"; then
4143 if func_cond_module_p "$module"; then
4145 else
4146 func_emit_autoconf_snippet " "
4149 done
4150 # Initialize the shell variables indicating that the modules are enabled.
4151 for module in $1; do
4152 eval $verifier
4153 if test -n "$module"; then
4154 if func_cond_module_p "$module"; then
4155 func_module_shellvar_name "$module"
4156 echo " $shellvar=false"
4159 done
4160 # Emit the autoconf code for the conditional modules, each in a separate
4161 # function. This makes it possible to support cycles among conditional
4162 # modules.
4163 for module in $1; do
4164 eval $verifier
4165 if test -n "$module"; then
4166 if func_cond_module_p "$module"; then
4167 func_module_shellfunc_name "$module"
4168 func_module_shellvar_name "$module"
4169 echo " $shellfunc ()"
4170 echo ' {'
4171 echo " if ! \$$shellvar; then"
4172 func_emit_autoconf_snippet " "
4173 echo " $shellvar=true"
4174 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4175 # Intersect $deps with the modules list $1.
4176 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4177 for dep in $deps; do
4178 if func_cond_module_p "$dep"; then
4179 func_module_shellfunc_name "$dep"
4180 func_cond_module_condition "$module" "$dep"
4181 if test "$condition" != true; then
4182 echo " if $condition; then"
4183 echo " $shellfunc"
4184 echo ' fi'
4185 else
4186 echo " $shellfunc"
4188 else
4189 # The autoconf code for $dep has already been emitted above and
4190 # therefore is already executed when this function is run.
4193 done
4194 echo ' fi'
4195 echo ' }'
4198 done
4199 # Emit the dependencies from the unconditional to the conditional modules.
4200 for module in $1; do
4201 eval $verifier
4202 if test -n "$module"; then
4203 if func_cond_module_p "$module"; then
4205 else
4206 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4207 # Intersect $deps with the modules list $1.
4208 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4209 for dep in $deps; do
4210 if func_cond_module_p "$dep"; then
4211 func_module_shellfunc_name "$dep"
4212 func_cond_module_condition "$module" "$dep"
4213 if test "$condition" != true; then
4214 echo " if $condition; then"
4215 echo " $shellfunc"
4216 echo ' fi'
4217 else
4218 echo " $shellfunc"
4220 else
4221 # The autoconf code for $dep has already been emitted above and
4222 # therefore is already executed when this code is run.
4225 done
4228 done
4229 # Define the Automake conditionals.
4230 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
4231 for module in $1; do
4232 eval $verifier
4233 if test -n "$module"; then
4234 if func_cond_module_p "$module"; then
4235 func_module_conditional_name "$module"
4236 func_module_shellvar_name "$module"
4237 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
4240 done
4241 else
4242 # Ignore the conditions, and enable all modules unconditionally.
4243 for module in $1; do
4244 eval $verifier
4245 if test -n "$module"; then
4246 func_emit_autoconf_snippet " "
4248 done
4252 # func_emit_pre_early_macros require indentation modules
4253 # The require parameter can be ':' (AC_REQUIRE) or 'false' (direct call).
4254 func_emit_pre_early_macros ()
4256 echo
4257 echo "${2}# Pre-early section."
4258 if $1; then
4259 _pre_early_snippet="echo \"${2}AC_REQUIRE([\$_pre_early_macro])\""
4260 else
4261 _pre_early_snippet="echo \"${2}\$_pre_early_macro\""
4264 # We need to call gl_USE_SYSTEM_EXTENSIONS before gl_PROG_AR_RANLIB. Doing
4265 # AC_REQUIRE in configure-ac.early is not early enough.
4266 _pre_early_macro="gl_USE_SYSTEM_EXTENSIONS"
4267 case "${nl}${3}${nl}" in
4268 *${nl}extensions${nl}*) eval "$_pre_early_snippet" ;;
4269 esac
4271 _pre_early_macro="gl_PROG_AR_RANLIB"
4272 eval "$_pre_early_snippet"
4273 echo
4276 # func_reconstruct_cached_dir
4277 # callback for func_reconstruct_cached_local_gnulib_path
4278 # Input:
4279 # - destdir from --dir
4280 # Output:
4281 # - local_gnulib_path restored '--local-dir' path from cache
4282 func_reconstruct_cached_dir ()
4284 cached_dir=$1
4285 if test -n "$cached_dir"; then
4286 case "$destdir" in
4288 func_path_append local_gnulib_path "$destdir/$cached_dir" ;;
4290 case "$cached_dir" in
4292 func_path_append local_gnulib_path "$destdir/$cached_dir" ;;
4294 func_relconcat "$destdir" "$cached_dir"
4295 func_path_append local_gnulib_path "$relconcat" ;;
4296 esac ;;
4297 esac
4301 # func_reconstruct_cached_local_gnulib_path
4302 # reconstruct local_gnulib_path from cached_local_gnulib_path to be set
4303 # relatively to $destdir again.
4304 # Input:
4305 # - cached_local_gnulib_path local_gnulib_path stored within gnulib-cache.m4
4306 # - destdir from --dir
4307 # Output:
4308 # - local_gnulib_path restored '--local-dir' path from cache
4309 func_reconstruct_cached_local_gnulib_path ()
4311 func_path_foreach "$cached_local_gnulib_path" func_reconstruct_cached_dir %dir%
4314 # func_import modules
4315 # Uses also the variables
4316 # - mode import or add-import or remove-import or update
4317 # - destdir target directory
4318 # - local_gnulib_path from --local-dir
4319 # - modcache true or false, from --cache-modules/--no-cache-modules
4320 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
4321 # - libname library name
4322 # - supplied_libname true if --lib was given, blank otherwise
4323 # - sourcebase directory relative to destdir where to place source code
4324 # - m4base directory relative to destdir where to place *.m4 macros
4325 # - pobase directory relative to destdir where to place *.po files
4326 # - docbase directory relative to destdir where to place doc files
4327 # - testsbase directory relative to destdir where to place unit test code
4328 # - auxdir directory relative to destdir where to place build aux files
4329 # - inctests true if --with-tests was given, false otherwise
4330 # - incobsolete true if --with-obsolete was given, blank otherwise
4331 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
4332 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
4333 # otherwise
4334 # - inc_privileged_tests true if --with-privileged-tests was given, blank
4335 # otherwise
4336 # - inc_unportable_tests true if --with-unportable-tests was given, blank
4337 # otherwise
4338 # - inc_all_tests true if --with-all-tests was given, blank otherwise
4339 # - avoidlist list of modules to avoid, from --avoid
4340 # - cond_dependencies true if --conditional-dependencies was given, false if
4341 # --no-conditional-dependencies was given, blank otherwise
4342 # - lgpl yes or a number if library's license shall be LGPL,
4343 # blank otherwise
4344 # - makefile_name from --makefile-name
4345 # - libtool true if --libtool was given, false if --no-libtool was
4346 # given, blank otherwise
4347 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
4348 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4349 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4350 # - witness_c_macro from --witness-c-macro
4351 # - vc_files true if --vc-files was given, false if --no-vc-files was
4352 # given, blank otherwise
4353 # - autoconf_minversion minimum supported autoconf version
4354 # - doit : if actions shall be executed, false if only to be printed
4355 # - symbolic true if files should be symlinked, copied otherwise
4356 # - lsymbolic true if files from local_gnulib_path should be symlinked,
4357 # copied otherwise
4358 # - do_copyrights true if copyright notices in files should be replaced,
4359 # blank otherwise
4360 func_import ()
4362 # Get the cached settings.
4363 # In 'import' mode, we read them only for the purpose of knowing the old
4364 # installed file list, and don't use them as defaults.
4365 cached_local_gnulib_path=
4366 cached_specified_modules=
4367 cached_incobsolete=
4368 cached_inc_cxx_tests=
4369 cached_inc_longrunning_tests=
4370 cached_inc_privileged_tests=
4371 cached_inc_unportable_tests=
4372 cached_inc_all_tests=
4373 cached_avoidlist=
4374 cached_sourcebase=
4375 cached_m4base=
4376 cached_pobase=
4377 cached_docbase=
4378 cached_testsbase=
4379 cached_inctests=
4380 cached_libname=
4381 cached_lgpl=
4382 cached_makefile_name=
4383 cached_cond_dependencies=
4384 cached_libtool=
4385 cached_macro_prefix=
4386 cached_po_domain=
4387 cached_witness_c_macro=
4388 cached_vc_files=
4389 cached_files=
4390 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4391 cached_libtool=false
4392 my_sed_traces='
4393 s,#.*$,,
4394 s,^dnl .*$,,
4395 s, dnl .*$,,
4396 /gl_LOCAL_DIR(/ {
4397 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_path="\1",p
4399 /gl_MODULES(/ {
4402 s/)/)/
4407 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
4409 /gl_WITH_OBSOLETE/ {
4410 s,^.*$,cached_incobsolete=true,p
4412 /gl_WITH_CXX_TESTS/ {
4413 s,^.*$,cached_inc_cxx_tests=true,p
4415 /gl_WITH_LONGRUNNING_TESTS/ {
4416 s,^.*$,cached_inc_longrunning_tests=true,p
4418 /gl_WITH_PRIVILEGED_TESTS/ {
4419 s,^.*$,cached_inc_privileged_tests=true,p
4421 /gl_WITH_UNPORTABLE_TESTS/ {
4422 s,^.*$,cached_inc_unportable_tests=true,p
4424 /gl_WITH_ALL_TESTS/ {
4425 s,^.*$,cached_inc_all_tests=true,p
4427 /gl_AVOID(/ {
4428 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
4430 /gl_SOURCE_BASE(/ {
4431 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
4433 /gl_M4_BASE(/ {
4434 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
4436 /gl_PO_BASE(/ {
4437 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
4439 /gl_DOC_BASE(/ {
4440 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
4442 /gl_TESTS_BASE(/ {
4443 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
4445 /gl_WITH_TESTS/ {
4446 s,^.*$,cached_inctests=true,p
4448 /gl_LIB(/ {
4449 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
4451 /gl_LGPL(/ {
4452 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
4454 /gl_LGPL/ {
4455 s,^.*$,cached_lgpl=yes,p
4457 /gl_MAKEFILE_NAME(/ {
4458 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
4460 /gl_CONDITIONAL_DEPENDENCIES/ {
4461 s,^.*$,cached_cond_dependencies=true,p
4463 /gl_LIBTOOL/ {
4464 s,^.*$,cached_libtool=true,p
4466 /gl_MACRO_PREFIX(/ {
4467 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
4469 /gl_PO_DOMAIN(/ {
4470 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
4472 /gl_WITNESS_C_MACRO(/ {
4473 s,^.*gl_WITNESS_C_MACRO([[ ]*\([^]"$`\\)]*\).*$,cached_witness_c_macro="\1",p
4475 /gl_VC_FILES(/ {
4476 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
4478 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
4479 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4480 my_sed_traces='
4481 s,#.*$,,
4482 s,^dnl .*$,,
4483 s, dnl .*$,,
4484 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
4485 s,^.*$,cached_files=",p
4489 s,^\]).*$,",
4491 s,["$`\\],,g
4498 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
4502 if test "$mode" = import; then
4503 # In 'import' mode, the new set of specified modules overrides the cached
4504 # set of modules. Ignore the cached settings.
4505 specified_modules="$1"
4506 else
4507 # Merge the cached settings with the specified ones.
4508 # The m4base must be the same as expected from the pathname.
4509 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
4510 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
4512 # The local_gnulib_path defaults to the cached one. Recall that the cached one
4513 # is relative to $destdir, whereas the one we use is relative to . or absolute.
4514 if test -z "$local_gnulib_path"; then
4515 func_reconstruct_cached_local_gnulib_path
4517 case $mode in
4518 add-import)
4519 # Append the cached and the specified module names. So that
4520 # "gnulib-tool --add-import foo" means to add the module foo.
4521 specified_modules="$cached_specified_modules $1"
4523 remove-import)
4524 # Take the cached module names, minus the specified module names.
4525 specified_modules=
4526 if $have_associative; then
4527 # Use an associative array, for O(N) worst-case run time.
4528 declare -A to_remove
4529 for m in $1; do
4530 eval 'to_remove[$m]=yes'
4531 done
4532 for module in $cached_specified_modules; do
4533 if eval 'test -z "${to_remove[$module]}"'; then
4534 func_append specified_modules "$module "
4536 done
4537 else
4538 # This loop has O(N**2) worst-case run time.
4539 for module in $cached_specified_modules; do
4540 to_remove=
4541 for m in $1; do
4542 if test "$m" = "$module"; then
4543 to_remove=yes
4544 break
4546 done
4547 if test -z "$to_remove"; then
4548 func_append specified_modules "$module "
4550 done
4553 update)
4554 # Take the cached module names. There are no specified module names.
4555 specified_modules="$cached_specified_modules"
4557 esac
4558 # Included obsolete modules among the dependencies if specified either way.
4559 if test -z "$incobsolete"; then
4560 incobsolete="$cached_incobsolete"
4562 # Included special kinds of tests modules among the dependencies if specified
4563 # either way.
4564 if test -z "$inc_cxx_tests"; then
4565 inc_cxx_tests="$cached_inc_cxx_tests"
4567 if test -z "$inc_longrunning_tests"; then
4568 inc_longrunning_tests="$cached_inc_longrunning_tests"
4570 if test -z "$inc_privileged_tests"; then
4571 inc_privileged_tests="$cached_inc_privileged_tests"
4573 if test -z "$inc_unportable_tests"; then
4574 inc_unportable_tests="$cached_inc_unportable_tests"
4576 if test -z "$inc_all_tests"; then
4577 inc_all_tests="$cached_inc_all_tests"
4579 # Append the cached and the specified avoidlist. This is probably better
4580 # than dropping the cached one when --avoid is specified at least once.
4581 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
4582 avoidlist=`echo $avoidlist`
4584 # The sourcebase defaults to the cached one.
4585 if test -z "$sourcebase"; then
4586 sourcebase="$cached_sourcebase"
4587 if test -z "$sourcebase"; then
4588 func_fatal_error "missing --source-base option"
4591 # The pobase defaults to the cached one.
4592 if test -z "$pobase"; then
4593 pobase="$cached_pobase"
4595 # The docbase defaults to the cached one.
4596 if test -z "$docbase"; then
4597 docbase="$cached_docbase"
4598 if test -z "$docbase"; then
4599 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."
4602 # The testsbase defaults to the cached one.
4603 if test -z "$testsbase"; then
4604 testsbase="$cached_testsbase"
4605 if test -z "$testsbase"; then
4606 func_fatal_error "missing --tests-base option"
4609 # Require the tests if specified either way.
4610 if ! $inctests; then
4611 inctests="$cached_inctests"
4612 if test -z "$inctests"; then
4613 inctests=false
4616 # The libname defaults to the cached one.
4617 if test -z "$supplied_libname"; then
4618 libname="$cached_libname"
4619 if test -z "$libname"; then
4620 func_fatal_error "missing --lib option"
4623 # Require LGPL if specified either way.
4624 if test -z "$lgpl"; then
4625 lgpl="$cached_lgpl"
4627 # The makefile_name defaults to the cached one.
4628 if test -z "$makefile_name"; then
4629 makefile_name="$cached_makefile_name"
4631 # Use conditional dependencies if specified either way.
4632 if test -z "$cond_dependencies"; then
4633 cond_dependencies="$cached_cond_dependencies"
4635 # Use libtool if specified either way, or if guessed.
4636 if test -z "$libtool"; then
4637 if test -n "$cached_m4base"; then
4638 libtool="$cached_libtool"
4639 else
4640 libtool="$guessed_libtool"
4643 # The macro_prefix defaults to the cached one.
4644 if test -z "$macro_prefix"; then
4645 macro_prefix="$cached_macro_prefix"
4646 if test -z "$macro_prefix"; then
4647 func_fatal_error "missing --macro-prefix option"
4650 # The po_domain defaults to the cached one.
4651 if test -z "$po_domain"; then
4652 po_domain="$cached_po_domain"
4654 # The witness_c_macro defaults to the cached one.
4655 if test -z "$witness_c_macro"; then
4656 witness_c_macro="$cached_witness_c_macro"
4658 # The vc_files defaults to the cached one.
4659 if test -z "$vc_files"; then
4660 vc_files="$cached_vc_files"
4662 # Ensure constraints.
4663 if test "$cond_dependencies" = true && $inctests; then
4664 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
4665 func_exit 1
4668 # --without-*-tests options are not supported here.
4669 excl_cxx_tests=
4670 excl_longrunning_tests=
4671 excl_privileged_tests=
4672 excl_unportable_tests=
4674 # Canonicalize the list of specified modules.
4675 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4677 # Include all kinds of tests modules if --with-all-tests was specified.
4678 inc_all_direct_tests="$inc_all_tests"
4679 inc_all_indirect_tests="$inc_all_tests"
4681 # Determine final module list.
4682 modules="$specified_modules"
4683 func_modules_transitive_closure
4684 if test $verbose -ge 0; then
4685 func_show_module_list
4687 final_modules="$modules"
4689 # Determine main module list and tests-related module list separately.
4690 func_modules_transitive_closure_separately
4692 # Determine whether a $testsbase/libtests.a is needed.
4693 func_determine_use_libtests
4695 # Add the dummy module to the main module list or to the tests-related module
4696 # list if needed.
4697 func_modules_add_dummy_separately
4699 # If --lgpl, verify that the licenses of modules are compatible.
4700 if test -n "$lgpl"; then
4701 license_incompatibilities=
4702 for module in $main_modules; do
4703 license=`func_get_license $module`
4704 case $license in
4705 'GPLed build tool') ;;
4706 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4708 case "$lgpl" in
4709 yes | 3)
4710 case $license in
4711 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL) ;;
4712 *) func_append license_incompatibilities "$module $license$nl" ;;
4713 esac
4715 3orGPLv2)
4716 case $license in
4717 LGPLv2+ | 'LGPLv3+ or GPLv2') ;;
4718 *) func_append license_incompatibilities "$module $license$nl" ;;
4719 esac
4722 case $license in
4723 LGPLv2+) ;;
4724 *) func_append license_incompatibilities "$module $license$nl" ;;
4725 esac
4727 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4728 esac
4730 esac
4731 done
4732 if test -n "$license_incompatibilities"; then
4733 # Format the license incompatibilities as a table.
4734 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
4735 s,^\(.................................................[^ ]*\) *, \1 ,'
4736 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
4737 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
4741 # Show banner notice of every module.
4742 modules="$main_modules"
4743 func_modules_notice
4745 # Determine script to apply to imported library files.
4746 sed_transform_lib_file=
4747 for module in $main_modules; do
4748 if test $module = config-h; then
4749 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
4750 sed_transform_lib_file=$sed_transform_lib_file'
4751 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
4753 break
4755 done
4756 sed_transform_main_lib_file="$sed_transform_lib_file"
4757 if test -n "$do_copyrights"; then
4758 if test -n "$lgpl"; then
4759 # Update license.
4760 case "$lgpl" in
4761 yes | 3 | 3orGPLv2)
4762 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4763 s/GNU General/GNU Lesser General/g
4764 s/General Public License/Lesser General Public License/g
4765 s/Lesser Lesser General Public License/Lesser General Public License/g
4769 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4770 s/GNU General/GNU Lesser General/g
4771 s/General Public License/Lesser General Public License/g
4772 s/Lesser Lesser General Public License/Lesser General Public License/g
4774 s/version [23]\([ ,]\)/version 2.1\1/g
4777 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4778 esac
4779 else
4780 # Update license.
4781 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4782 s/GNU Lesser General/GNU General/g
4783 s/Lesser General Public License/General Public License/g
4785 s/GNU Library General/GNU General/g
4786 s/Library General Public License/General Public License/g
4788 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4793 # Determine script to apply to auxiliary files that go into $auxdir/.
4794 sed_transform_build_aux_file=
4795 if test -n "$do_copyrights"; then
4796 # Update license.
4797 sed_transform_build_aux_file=$sed_transform_build_aux_file'
4798 s/GNU Lesser General/GNU General/g
4799 s/Lesser General Public License/General Public License/g
4801 s/GNU Library General/GNU General/g
4802 s/Library General Public License/General Public License/g
4804 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4808 # Determine script to apply to library files that go into $testsbase/.
4809 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
4810 if test -n "$do_copyrights"; then
4811 # Update license.
4812 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
4813 s/GNU Lesser General/GNU General/g
4814 s/Lesser General Public License/General Public License/g
4816 s/GNU Library General/GNU General/g
4817 s/Library General Public License/General Public License/g
4819 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4823 # Determine the final file lists.
4824 func_modules_to_filelist_separately
4826 test -n "$files" \
4827 || func_fatal_error "refusing to do nothing"
4829 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
4830 new_files="$files m4/gnulib-tool.m4"
4831 old_files="$cached_files"
4832 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
4833 func_append old_files " m4/gnulib-tool.m4"
4836 rewritten='%REWRITTEN%'
4837 sed_rewrite_old_files="\
4838 s,^build-aux/,$rewritten$auxdir/,
4839 s,^doc/,$rewritten$cached_docbase/,
4840 s,^lib/,$rewritten$cached_sourcebase/,
4841 s,^m4/,$rewritten$cached_m4base/,
4842 s,^tests/,$rewritten$cached_testsbase/,
4843 s,^tests=lib/,$rewritten$cached_testsbase/,
4844 s,^top/,$rewritten,
4845 s,^$rewritten,,"
4846 sed_rewrite_new_files="\
4847 s,^build-aux/,$rewritten$auxdir/,
4848 s,^doc/,$rewritten$docbase/,
4849 s,^lib/,$rewritten$sourcebase/,
4850 s,^m4/,$rewritten$m4base/,
4851 s,^tests/,$rewritten$testsbase/,
4852 s,^tests=lib/,$rewritten$testsbase/,
4853 s,^top/,$rewritten,
4854 s,^$rewritten,,"
4856 # Create directories.
4857 { echo "$sourcebase"
4858 echo "$m4base"
4859 if test -n "$pobase"; then
4860 echo "$pobase"
4862 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
4863 if test -n "$docfiles"; then
4864 echo "$docbase"
4866 if $inctests; then
4867 echo "$testsbase"
4869 echo "$auxdir"
4870 for f in $files; do echo $f; done \
4871 | sed -e "$sed_rewrite_new_files" \
4872 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4873 | LC_ALL=C sort -u
4874 } > "$tmp"/dirs
4875 { # Rearrange file descriptors. Needed because "while ... done < ..."
4876 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4877 exec 5<&0 < "$tmp"/dirs
4878 while read d; do
4879 if test ! -d "$destdir/$d"; then
4880 if $doit; then
4881 echo "Creating directory $destdir/$d"
4882 mkdir -p "$destdir/$d" || func_fatal_error "failed"
4883 else
4884 echo "Create directory $destdir/$d"
4887 done
4888 exec 0<&5 5<&-
4891 # Copy files or make symbolic links. Remove obsolete files.
4892 added_files=''
4893 removed_files=''
4894 delimiter=' '
4895 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4896 # representing the files according to the last gnulib-tool invocation.
4897 for f in $old_files; do echo $f; done \
4898 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
4899 | LC_ALL=C sort \
4900 > "$tmp"/old-files
4901 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4902 # representing the files after this gnulib-tool invocation.
4903 for f in $new_files; do echo $f; done \
4904 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
4905 | LC_ALL=C sort \
4906 > "$tmp"/new-files
4907 # First the files that are in old-files, but not in new-files:
4908 sed_take_first_column='s,'"$delimiter"'.*,,'
4909 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
4910 # Remove the file. Do nothing if the user already removed it.
4911 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
4912 if $doit; then
4913 echo "Removing file $g (backup in ${g}~)"
4914 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
4915 else
4916 echo "Remove file $g (backup in ${g}~)"
4918 func_append removed_files "$g$nl"
4920 done
4921 # func_add_or_update handles a file that ought to be present afterwards.
4922 # Uses parameters
4923 # - f the original file name
4924 # - g the rewritten file name
4925 # - already_present nonempty if the file should already exist, empty
4926 # otherwise
4927 func_add_or_update ()
4929 of="$f"
4930 case "$f" in
4931 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
4932 esac
4933 is_binary_file=
4934 case "$f" in
4935 *.class | *.mo ) is_binary_file=true ;;
4936 esac
4937 func_dest_tmpfilename "$g"
4938 func_lookup_file "$f"
4939 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4940 if test -n "$sed_transform_main_lib_file" \
4941 && test -z "$is_binary_file"; then
4942 case "$of" in
4943 lib/*)
4944 sed -e "$sed_transform_main_lib_file" \
4945 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4947 esac
4949 if test -n "$sed_transform_build_aux_file" \
4950 && test -z "$is_binary_file"; then
4951 case "$of" in
4952 build-aux/*)
4953 sed -e "$sed_transform_build_aux_file" \
4954 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4956 esac
4958 if test -n "$sed_transform_testsrelated_lib_file" \
4959 && test -z "$is_binary_file"; then
4960 case "$of" in
4961 tests=lib/*)
4962 sed -e "$sed_transform_testsrelated_lib_file" \
4963 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4965 esac
4967 if test -f "$destdir/$g"; then
4968 # The file already exists.
4969 func_update_file
4970 else
4971 # Install the file.
4972 # Don't protest if the file should be there but isn't: it happens
4973 # frequently that developers don't put autogenerated files under version control.
4974 func_add_file
4975 func_append added_files "$g$nl"
4977 rm -f "$tmpfile"
4979 # Then the files that are in new-files, but not in old-files:
4980 sed_take_last_column='s,^.*'"$delimiter"',,'
4981 already_present=
4982 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
4983 | sed -e "$sed_take_last_column" \
4984 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
4985 { # Rearrange file descriptors. Needed because "while ... done < ..."
4986 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4987 exec 5<&0 < "$tmp"/added-files
4988 while read g f; do
4989 func_add_or_update
4990 done
4991 exec 0<&5 5<&-
4993 # Then the files that are in new-files and in old-files:
4994 already_present=true
4995 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
4996 | sed -e "$sed_take_last_column" \
4997 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
4998 { # Rearrange file descriptors. Needed because "while ... done < ..."
4999 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5000 exec 5<&0 < "$tmp"/kept-files
5001 while read g f; do
5002 func_add_or_update
5003 done
5004 exec 0<&5 5<&-
5007 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
5008 actioncmd="gnulib-tool --import"
5010 # Local helper.
5011 func_append_local_dir ()
5013 func_append "$1" " --local-dir=$2"
5015 func_path_foreach "$local_gnulib_path" func_append_local_dir actioncmd %dir%
5017 func_append actioncmd " --lib=$libname"
5018 func_append actioncmd " --source-base=$sourcebase"
5019 func_append actioncmd " --m4-base=$m4base"
5020 if test -n "$pobase"; then
5021 func_append actioncmd " --po-base=$pobase"
5023 func_append actioncmd " --doc-base=$docbase"
5024 func_append actioncmd " --tests-base=$testsbase"
5025 func_append actioncmd " --aux-dir=$auxdir"
5026 if $inctests; then
5027 func_append actioncmd " --with-tests"
5029 if test -n "$incobsolete"; then
5030 func_append actioncmd " --with-obsolete"
5032 if test -n "$inc_cxx_tests"; then
5033 func_append actioncmd " --with-c++-tests"
5035 if test -n "$inc_longrunning_tests"; then
5036 func_append actioncmd " --with-longrunning-tests"
5038 if test -n "$inc_privileged_tests"; then
5039 func_append actioncmd " --with-privileged-tests"
5041 if test -n "$inc_unportable_tests"; then
5042 func_append actioncmd " --with-unportable-tests"
5044 if test -n "$inc_all_tests"; then
5045 func_append actioncmd " --with-all-tests"
5047 for module in $avoidlist; do
5048 func_append actioncmd " --avoid=$module"
5049 done
5050 if test -n "$lgpl"; then
5051 if test "$lgpl" = yes; then
5052 func_append actioncmd " --lgpl"
5053 else
5054 func_append actioncmd " --lgpl=$lgpl"
5057 if test -n "$makefile_name"; then
5058 func_append actioncmd " --makefile-name=$makefile_name"
5060 if test "$cond_dependencies" = true; then
5061 func_append actioncmd " --conditional-dependencies"
5062 else
5063 func_append actioncmd " --no-conditional-dependencies"
5065 if test "$libtool" = true; then
5066 func_append actioncmd " --libtool"
5067 else
5068 func_append actioncmd " --no-libtool"
5070 func_append actioncmd " --macro-prefix=$macro_prefix"
5071 if test -n "$po_domain"; then
5072 func_append actioncmd " --po-domain=$po_domain"
5074 if test -n "$witness_c_macro"; then
5075 func_append actioncmd " --witness-c-macro=$witness_c_macro"
5077 if test -n "$vc_files"; then
5078 if test "$vc_files" = true; then
5079 func_append actioncmd " --vc-files"
5080 else
5081 func_append actioncmd " --no-vc-files"
5084 func_append actioncmd " `echo $specified_modules`"
5086 # Determine include_guard_prefix.
5087 func_compute_include_guard_prefix
5089 # Default the makefile name to Makefile.am.
5090 if test -n "$makefile_name"; then
5091 makefile_am=$makefile_name
5092 else
5093 makefile_am=Makefile.am
5096 # Create normal Makefile.ams.
5097 for_test=false
5099 # Setup list of Makefile.am edits that are to be performed afterwards.
5100 # Some of these edits apply to files that we will generate; others are
5101 # under the responsibility of the developer.
5102 makefile_am_edits=0
5103 # func_note_Makefile_am_edit dir var value
5104 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
5105 # ${value}.
5106 func_note_Makefile_am_edit ()
5108 makefile_am_edits=`expr $makefile_am_edits + 1`
5109 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
5110 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
5111 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
5113 if test "$makefile_am" = Makefile.am; then
5114 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
5115 sourcebase_base=`basename "$sourcebase"`
5116 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
5118 if test -n "$pobase"; then
5119 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
5120 pobase_base=`basename "$pobase"`
5121 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
5123 if $inctests; then
5124 if test "$makefile_am" = Makefile.am; then
5125 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
5126 testsbase_base=`basename "$testsbase"`
5127 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
5130 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
5132 # Find the first parent directory of $m4base that contains or will contain
5133 # a Makefile.am.
5134 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
5135 s,//*$,/,'
5136 sed_butlast='s,[^/][^/]*//*$,,'
5137 dir1="${m4base}/"; dir2=""
5138 while test -n "$dir1" \
5139 && ! { test -f "${destdir}/${dir1}Makefile.am" \
5140 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
5141 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
5142 || { $inctests \
5143 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
5144 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
5145 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
5146 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
5147 done
5148 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
5151 # Create library makefile.
5152 func_dest_tmpfilename $sourcebase/$makefile_am
5153 destfile="$sourcebase/$makefile_am"
5154 modules="$main_modules"
5155 func_emit_lib_Makefile_am > "$tmpfile"
5156 if test -f "$destdir"/$sourcebase/$makefile_am; then
5157 if cmp -s "$destdir"/$sourcebase/$makefile_am "$tmpfile"; then
5158 rm -f "$tmpfile"
5159 else
5160 if $doit; then
5161 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
5162 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
5163 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
5164 else
5165 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
5166 rm -f "$tmpfile"
5169 else
5170 if $doit; then
5171 echo "Creating $sourcebase/$makefile_am"
5172 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
5173 else
5174 echo "Create $sourcebase/$makefile_am"
5175 rm -f "$tmpfile"
5177 func_append added_files "$sourcebase/$makefile_am$nl"
5180 # Create po/ directory.
5181 if test -n "$pobase"; then
5182 # Create po makefile and auxiliary files.
5183 for file in Makefile.in.in remove-potcdate.sin; do
5184 func_dest_tmpfilename $pobase/$file
5185 func_lookup_file build-aux/po/$file
5186 cat "$lookedup_file" > "$tmpfile"
5187 if test -f "$destdir"/$pobase/$file; then
5188 if cmp -s "$destdir"/$pobase/$file "$tmpfile"; then
5189 rm -f "$tmpfile"
5190 else
5191 if $doit; then
5192 echo "Updating $pobase/$file (backup in $pobase/$file~)"
5193 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
5194 mv -f "$tmpfile" "$destdir"/$pobase/$file
5195 else
5196 echo "Update $pobase/$file (backup in $pobase/$file~)"
5197 rm -f "$tmpfile"
5200 else
5201 if $doit; then
5202 echo "Creating $pobase/$file"
5203 mv -f "$tmpfile" "$destdir"/$pobase/$file
5204 else
5205 echo "Create $pobase/$file"
5206 rm -f "$tmpfile"
5208 func_append added_files "$pobase/$file$nl"
5210 done
5211 # Create po makefile parameterization, part 1.
5212 func_dest_tmpfilename $pobase/Makevars
5213 func_emit_po_Makevars > "$tmpfile"
5214 if test -f "$destdir"/$pobase/Makevars; then
5215 if cmp -s "$destdir"/$pobase/Makevars "$tmpfile"; then
5216 rm -f "$tmpfile"
5217 else
5218 if $doit; then
5219 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
5220 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
5221 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5222 else
5223 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
5224 rm -f "$tmpfile"
5227 else
5228 if $doit; then
5229 echo "Creating $pobase/Makevars"
5230 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5231 else
5232 echo "Create $pobase/Makevars"
5233 rm -f "$tmpfile"
5235 func_append added_files "$pobase/Makevars$nl"
5237 # Create po makefile parameterization, part 2.
5238 func_dest_tmpfilename $pobase/POTFILES.in
5239 func_emit_po_POTFILES_in > "$tmpfile"
5240 if test -f "$destdir"/$pobase/POTFILES.in; then
5241 if cmp -s "$destdir"/$pobase/POTFILES.in "$tmpfile"; then
5242 rm -f "$tmpfile"
5243 else
5244 if $doit; then
5245 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5246 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
5247 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5248 else
5249 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5250 rm -f "$tmpfile"
5253 else
5254 if $doit; then
5255 echo "Creating $pobase/POTFILES.in"
5256 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5257 else
5258 echo "Create $pobase/POTFILES.in"
5259 rm -f "$tmpfile"
5261 func_append added_files "$pobase/POTFILES.in$nl"
5263 # Fetch PO files.
5264 TP_URL="http://translationproject.org/latest/"
5265 TP_RSYNC_URI="translationproject.org::tp/latest/"
5266 if $doit; then
5267 echo "Fetching gnulib PO files from $TP_URL"
5268 (cd "$destdir"/$pobase \
5269 && { # Prefer rsync over wget if it is available, since it consumes
5270 # less network bandwidth, due to compression.
5271 if type rsync 2>/dev/null | grep / > /dev/null; then
5272 rsync --delete --exclude "*.s1" -Lrtz "${TP_RSYNC_URI}gnulib/" . && return
5275 wget --no-verbose --mirror -nd -np -A.po -P . "${TP_URL}gnulib/"
5278 else
5279 echo "Fetch gnulib PO files from $TP_URL"
5281 # Create po/LINGUAS.
5282 if $doit; then
5283 func_dest_tmpfilename $pobase/LINGUAS
5284 (cd "$destdir"/$pobase \
5285 && { echo '# Set of available languages.'
5286 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
5288 ) > "$tmpfile"
5289 if test -f "$destdir"/$pobase/LINGUAS; then
5290 if cmp -s "$destdir"/$pobase/LINGUAS "$tmpfile"; then
5291 rm -f "$tmpfile"
5292 else
5293 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5294 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
5295 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5297 else
5298 echo "Creating $pobase/LINGUAS"
5299 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5300 func_append added_files "$pobase/LINGUAS$nl"
5302 else
5303 if test -f "$destdir"/$pobase/LINGUAS; then
5304 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5305 else
5306 echo "Create $pobase/LINGUAS"
5311 # func_count_relative_local_gnulib_path
5312 # gl_LOCAL_DIR requires local_gnulib_path to be set relatively to destdir
5313 # Input:
5314 # - local_gnulib_path from --local-dir
5315 # - destdir from --dir
5316 # Output:
5317 # - relative_local_dir path to be stored into gl_LOCAL_DIR
5318 func_count_relative_local_gnulib_path ()
5320 save_IFS=$IFS
5321 IFS=$PATH_SEPARATOR
5322 relative_local_gnulib_path=
5323 for local_dir in $local_gnulib_path
5325 # Store the local_dir relative to destdir.
5326 case "$local_dir" in
5327 "" | /*)
5328 relative_local_dir="$local_dir" ;;
5330 case "$destdir" in
5331 /*) relative_local_dir="$local_dir" ;;
5333 # destdir, local_dir are both relative.
5334 func_relativize "$destdir" "$local_dir"
5335 relative_local_dir="$reldir" ;;
5336 esac ;;
5337 esac
5338 func_path_append relative_local_gnulib_path "$relative_local_dir"
5339 done
5340 IFS=$save_IFS
5343 # Create m4/gnulib-cache.m4.
5344 func_dest_tmpfilename $m4base/gnulib-cache.m4
5346 func_emit_copyright_notice
5347 echo "#"
5348 echo "# This file represents the specification of how gnulib-tool is used."
5349 echo "# It acts as a cache: It is written and read by gnulib-tool."
5350 echo "# In projects that use version control, this file is meant to be put under"
5351 echo "# version control, like the configure.ac and various Makefile.am files."
5352 echo
5353 echo
5354 echo "# Specification in the form of a command-line invocation:"
5355 echo "# $actioncmd"
5356 echo
5357 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
5358 func_count_relative_local_gnulib_path
5359 echo "gl_LOCAL_DIR([$relative_local_gnulib_path])"
5360 echo "gl_MODULES(["
5361 echo "$specified_modules" | sed -e 's/^/ /g'
5362 echo "])"
5363 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
5364 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
5365 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
5366 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
5367 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
5368 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
5369 echo "gl_AVOID([$avoidlist])"
5370 echo "gl_SOURCE_BASE([$sourcebase])"
5371 echo "gl_M4_BASE([$m4base])"
5372 echo "gl_PO_BASE([$pobase])"
5373 echo "gl_DOC_BASE([$docbase])"
5374 echo "gl_TESTS_BASE([$testsbase])"
5375 if $inctests; then
5376 echo "gl_WITH_TESTS"
5378 echo "gl_LIB([$libname])"
5379 if test -n "$lgpl"; then
5380 if test "$lgpl" = yes; then
5381 echo "gl_LGPL"
5382 else
5383 echo "gl_LGPL([$lgpl])"
5386 echo "gl_MAKEFILE_NAME([$makefile_name])"
5387 if test "$cond_dependencies" = true; then
5388 echo "gl_CONDITIONAL_DEPENDENCIES"
5390 if test "$libtool" = true; then
5391 echo "gl_LIBTOOL"
5393 echo "gl_MACRO_PREFIX([$macro_prefix])"
5394 echo "gl_PO_DOMAIN([$po_domain])"
5395 echo "gl_WITNESS_C_MACRO([$witness_c_macro])"
5396 if test -n "$vc_files"; then
5397 echo "gl_VC_FILES([$vc_files])"
5399 ) > "$tmpfile"
5400 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
5401 if cmp -s "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile"; then
5402 rm -f "$tmpfile"
5403 else
5404 if $doit; then
5405 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5406 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
5407 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5408 else
5409 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5410 if false; then
5411 cat "$tmpfile"
5412 echo
5413 echo "# gnulib-cache.m4 ends here"
5415 rm -f "$tmpfile"
5418 else
5419 if $doit; then
5420 echo "Creating $m4base/gnulib-cache.m4"
5421 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5422 else
5423 echo "Create $m4base/gnulib-cache.m4"
5424 cat "$tmpfile"
5425 rm -f "$tmpfile"
5429 # Create m4/gnulib-comp.m4.
5430 func_dest_tmpfilename $m4base/gnulib-comp.m4
5432 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
5433 func_emit_copyright_notice
5434 echo "#"
5435 echo "# This file represents the compiled summary of the specification in"
5436 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
5437 echo "# to be invoked from configure.ac."
5438 echo "# In projects that use version control, this file can be treated like"
5439 echo "# other built files."
5440 echo
5441 echo
5442 echo "# This macro should be invoked from $configure_ac, in the section"
5443 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
5444 echo "# any checks for libraries, header files, types and library functions."
5445 echo "AC_DEFUN([${macro_prefix}_EARLY],"
5446 echo "["
5447 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5448 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5449 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5450 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5452 func_emit_pre_early_macros : ' ' "$final_modules"
5454 if test -n "$uses_subdirs"; then
5455 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
5457 for module in $final_modules; do
5458 func_verify_module
5459 if test -n "$module"; then
5460 echo "# Code from module $module:"
5461 func_get_autoconf_early_snippet "$module"
5463 done \
5464 | sed -e '/^$/d;' -e 's/^/ /'
5465 echo "])"
5466 echo
5467 echo "# This macro should be invoked from $configure_ac, in the section"
5468 echo "# \"Check for header files, types and library functions\"."
5469 echo "AC_DEFUN([${macro_prefix}_INIT],"
5470 echo "["
5471 if test "$libtool" = true; then
5472 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5473 echo " gl_cond_libtool=true"
5474 else
5475 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5476 echo " gl_cond_libtool=false"
5477 echo " gl_libdeps="
5478 echo " gl_ltlibdeps="
5480 if test "$auxdir" != "build-aux"; then
5481 sed_replace_build_aux='
5483 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5484 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5487 else
5488 sed_replace_build_aux="$sed_noop"
5490 echo " gl_m4_base='$m4base'"
5491 func_emit_initmacro_start $macro_prefix
5492 echo " gl_source_base='$sourcebase'"
5493 if test -n "$witness_c_macro"; then
5494 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
5496 func_emit_autoconf_snippets "$main_modules" func_verify_module true false true
5497 if test -n "$witness_c_macro"; then
5498 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5500 echo " # End of code from modules"
5501 func_emit_initmacro_end $macro_prefix
5502 echo " gltests_libdeps="
5503 echo " gltests_ltlibdeps="
5504 func_emit_initmacro_start ${macro_prefix}tests
5505 echo " gl_source_base='$testsbase'"
5506 # Define a tests witness macro that depends on the package.
5507 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
5508 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
5509 echo "changequote(,)dnl"
5510 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"
5511 echo "changequote([, ])dnl"
5512 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5513 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5514 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5515 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true true true
5516 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5517 func_emit_initmacro_end ${macro_prefix}tests
5518 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5519 # created using libtool, because libtool already handles the dependencies.
5520 if test "$libtool" != true; then
5521 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5522 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5523 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5524 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5525 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5527 if $use_libtests; then
5528 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5529 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5531 echo "])"
5532 func_emit_initmacro_done $macro_prefix $sourcebase
5533 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5534 echo
5535 echo "# This macro records the list of files which have been installed by"
5536 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
5537 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
5538 echo "$files" | sed -e 's,^, ,'
5539 echo "])"
5540 ) > "$tmpfile"
5541 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
5542 if cmp -s "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile"; then
5543 rm -f "$tmpfile"
5544 else
5545 if $doit; then
5546 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5547 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
5548 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5549 else
5550 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5551 if false; then
5552 cat "$tmpfile"
5553 echo
5554 echo "# gnulib-comp.m4 ends here"
5556 rm -f "$tmpfile"
5559 else
5560 if $doit; then
5561 echo "Creating $m4base/gnulib-comp.m4"
5562 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5563 else
5564 echo "Create $m4base/gnulib-comp.m4"
5565 cat "$tmpfile"
5566 rm -f "$tmpfile"
5570 if $inctests; then
5571 # Create tests makefile.
5572 func_dest_tmpfilename $testsbase/$makefile_am
5573 destfile="$testsbase/$makefile_am"
5574 modules="$testsrelated_modules"
5575 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
5576 if test -f "$destdir"/$testsbase/$makefile_am; then
5577 if cmp -s "$destdir"/$testsbase/$makefile_am "$tmpfile"; then
5578 rm -f "$tmpfile"
5579 else
5580 if $doit; then
5581 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5582 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
5583 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5584 else
5585 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5586 rm -f "$tmpfile"
5589 else
5590 if $doit; then
5591 echo "Creating $testsbase/$makefile_am"
5592 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5593 else
5594 echo "Create $testsbase/$makefile_am"
5595 rm -f "$tmpfile"
5597 func_append added_files "$testsbase/$makefile_am$nl"
5601 if test "$vc_files" != false; then
5602 # Update the .cvsignore and .gitignore files.
5603 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
5604 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
5605 # Treat gnulib-comp.m4 like an added file, even if it already existed.
5606 echo "$m4base/|A|gnulib-comp.m4"
5607 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
5608 { # Rearrange file descriptors. Needed because "while ... done < ..."
5609 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5610 exec 5<&0 < "$tmp"/fileset-changes
5611 func_update_ignorelist ()
5613 ignore="$1"
5614 if test "$ignore" = .gitignore; then
5615 # In a .gitignore file, "foo" applies to the current directory and all
5616 # subdirectories, whereas "/foo" applies to the current directory only.
5617 anchor='/'
5618 escaped_anchor='\/'
5619 doubly_escaped_anchor='\\/'
5620 else
5621 anchor=''
5622 escaped_anchor=''
5623 doubly_escaped_anchor=''
5625 if test -f "$destdir/$dir$ignore"; then
5626 if test -n "$dir_added" || test -n "$dir_removed"; then
5627 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
5628 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
5629 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
5630 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
5631 > "$tmp"/ignore-removed
5633 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
5634 if $doit; then
5635 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5636 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
5637 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
5638 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
5639 } > "$tmp"/sed-ignore-removed
5640 { cat "$destdir/$dir$ignore"~
5641 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
5642 } | sed -f "$tmp"/sed-ignore-removed \
5643 > "$destdir/$dir$ignore"
5644 else
5645 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5649 else
5650 if test -n "$dir_added"; then
5651 if $doit; then
5652 echo "Creating $destdir/$dir$ignore"
5654 if test "$ignore" = .cvsignore; then
5655 echo ".deps"
5656 # Automake generates Makefile rules that create .dirstamp files.
5657 echo ".dirstamp"
5659 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
5660 } > "$destdir/$dir$ignore"
5661 else
5662 echo "Create $destdir/$dir$ignore"
5667 func_done_dir ()
5669 dir="$1"
5670 dir_added="$2"
5671 dir_removed="$3"
5672 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
5673 func_update_ignorelist .cvsignore
5675 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
5676 func_update_ignorelist .gitignore
5679 last_dir=
5680 last_dir_added=
5681 last_dir_removed=
5682 while read line; do
5683 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
5684 next_dir=`echo "$line" | sed -e 's,|.*,,'`
5685 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
5686 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
5687 if test "$next_dir" != "$last_dir"; then
5688 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5689 last_dir="$next_dir"
5690 last_dir_added=
5691 last_dir_removed=
5693 case $op in
5694 A) func_append last_dir_added "$file$nl";;
5695 R) func_append last_dir_removed "$file$nl";;
5696 esac
5697 done
5698 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5699 exec 0<&5 5<&-
5703 echo "Finished."
5704 echo
5705 echo "You may need to add #include directives for the following .h files."
5706 # Intersect $specified_modules and $main_modules
5707 # (since $specified_modules is not necessarily of subset of $main_modules
5708 # - some may have been skipped through --avoid, and since the elements of
5709 # $main_modules but not in $specified_modules can go away without explicit
5710 # notice - through changes in the module dependencies).
5711 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
5712 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
5713 # First the #include <...> directives without #ifs, sorted for convenience,
5714 # then the #include "..." directives without #ifs, sorted for convenience,
5715 # then the #include directives that are surrounded by #ifs. Not sorted.
5716 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
5717 include_directive=`func_get_include_directive "$module"`
5718 case "$nl$include_directive" in
5719 *"$nl#if"*)
5720 echo "$include_directive" 1>&5
5723 echo "$include_directive" | grep -v 'include "' 1>&6
5724 echo "$include_directive" | grep 'include "' 1>&7
5726 esac
5727 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
5729 LC_ALL=C sort -u "$tmp"/include-angles
5730 LC_ALL=C sort -u "$tmp"/include-quotes
5731 cat "$tmp"/include-if
5732 ) | sed -e '/^$/d' -e 's/^/ /'
5733 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
5735 for module in $main_modules; do
5736 func_get_link_directive "$module"
5737 done \
5738 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
5739 if test `wc -l < "$tmp"/link` != 0; then
5740 echo
5741 echo "You may need to use the following Makefile variables when linking."
5742 echo "Use them in <program>_LDADD when linking a program, or"
5743 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
5744 cat "$tmp"/link
5746 rm -f "$tmp"/link
5748 echo
5749 echo "Don't forget to"
5750 if test "$makefile_am" = Makefile.am; then
5751 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5752 else
5753 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
5755 if test -n "$pobase"; then
5756 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
5758 if $inctests; then
5759 if test "$makefile_am" = Makefile.am; then
5760 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5761 else
5762 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
5765 edit=0
5766 while test $edit != $makefile_am_edits; do
5767 edit=`expr $edit + 1`
5768 eval dir=\"\$makefile_am_edit${edit}_dir\"
5769 eval var=\"\$makefile_am_edit${edit}_var\"
5770 eval val=\"\$makefile_am_edit${edit}_val\"
5771 if test -n "$var"; then
5772 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
5774 done
5775 if grep '^ *AC_PROG_CC_STDC' "$configure_ac" > /dev/null; then
5776 position_early_after=AC_PROG_CC_STDC
5777 else
5778 if grep '^ *AC_PROG_CC_C99' "$configure_ac" > /dev/null; then
5779 position_early_after=AC_PROG_CC_C99
5780 else
5781 position_early_after=AC_PROG_CC
5784 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after $position_early_after,"
5785 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
5788 # func_create_testdir testdir modules
5789 # Input:
5790 # - local_gnulib_path from --local-dir
5791 # - modcache true or false, from --cache-modules/--no-cache-modules
5792 # - auxdir directory relative to destdir where to place build aux files
5793 # - inctests true if tests should be included, false otherwise
5794 # - incobsolete true if obsolete modules among dependencies should be
5795 # included, blank otherwise
5796 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
5797 # blank otherwise
5798 # - excl_longrunning_tests true if long-runnings tests should be excluded,
5799 # blank otherwise
5800 # - excl_privileged_tests true if tests that require root privileges should be
5801 # excluded, blank otherwise
5802 # - excl_unportable_tests true if tests that fail on some platforms should be
5803 # excluded, blank otherwise
5804 # - single_configure true if a single configure file should be generated,
5805 # false for a separate configure file for the tests
5806 # - avoidlist list of modules to avoid
5807 # - cond_dependencies true if --conditional-dependencies was given, false if
5808 # --no-conditional-dependencies was given, blank otherwise
5809 # - libtool true if --libtool was given, false if --no-libtool was
5810 # given, blank otherwise
5811 # - symbolic true if files should be symlinked, copied otherwise
5812 # - lsymbolic true if files from local_gnulib_path should be symlinked,
5813 # copied otherwise
5814 func_create_testdir ()
5816 testdir="$1"
5817 modules="$2"
5818 if test -z "$modules"; then
5819 # All modules together.
5820 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5821 # Except non-recursive-gnulib-prefix-hack, which represents a nonstandard
5822 # way of using Automake.
5823 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
5824 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
5825 modules=`func_all_modules`
5826 modules=`for m in $modules; do case $m in config-h | non-recursive-gnulib-prefix-hack | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
5828 specified_modules="$modules"
5830 # Canonicalize the list of specified modules.
5831 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
5833 # Unlike in func_import, here we want to include all kinds of tests for the
5834 # directly specified modules, but not for dependencies.
5835 inc_all_direct_tests=true
5836 inc_all_indirect_tests="$inc_all_tests"
5838 # Check that the license of every module is consistent with the license of
5839 # its dependencies.
5840 saved_inctests="$inctests"
5841 # When computing transitive closures, don't consider $module to depend on
5842 # $module-tests. Need this because tests are implicitly GPL and may depend
5843 # on GPL modules - therefore we don't want a warning in this case.
5844 inctests=false
5845 for requested_module in $specified_modules; do
5846 requested_license=`func_get_license "$requested_module"`
5847 if test "$requested_license" != GPL; then
5848 # Here we use func_modules_transitive_closure, not just
5849 # func_get_dependencies, so that we also detect weird situations like
5850 # an LGPL module which depends on a GPLed build tool module which depends
5851 # on a GPL module.
5852 modules="$requested_module"
5853 func_modules_transitive_closure
5854 for module in $modules; do
5855 license=`func_get_license "$module"`
5856 case "$license" in
5857 'GPLed build tool') ;;
5858 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
5860 case "$requested_license" in
5861 GPLv3+ | GPL)
5862 case "$license" in
5863 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL | GPLv2+ | GPLv3+ | GPL) ;;
5864 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5865 esac
5867 GPLv2+)
5868 case "$license" in
5869 LGPLv2+ | 'LGPLv3+ or GPLv2' | GPLv2+) ;;
5870 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5871 esac
5873 LGPLv3+ | LGPL)
5874 case "$license" in
5875 LGPLv2+ | 'LGPLv3+ or GPLv2' | LGPLv3+ | LGPL) ;;
5876 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5877 esac
5879 'LGPLv3+ or GPLv2')
5880 case "$license" in
5881 LGPLv2+ | 'LGPLv3+ or GPLv2') ;;
5882 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5883 esac
5885 LGPLv2+)
5886 case "$license" in
5887 LGPLv2+) ;;
5888 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5889 esac
5891 esac
5893 esac
5894 done
5896 done
5897 inctests="$saved_inctests"
5899 # Subdirectory names.
5900 sourcebase=gllib
5901 m4base=glm4
5902 pobase=
5903 docbase=gldoc
5904 testsbase=gltests
5905 macro_prefix=gl
5906 po_domain=
5907 witness_c_macro=
5908 vc_files=
5910 # Determine final module list.
5911 modules="$specified_modules"
5912 func_modules_transitive_closure
5913 if test $verbose -ge 0; then
5914 func_show_module_list
5916 final_modules="$modules"
5918 if $single_configure; then
5919 # Determine main module list and tests-related module list separately.
5920 func_modules_transitive_closure_separately
5923 if $single_configure; then
5924 # Determine whether a $testsbase/libtests.a is needed.
5925 func_determine_use_libtests
5928 # Add the dummy module if needed.
5929 if $single_configure; then
5930 func_modules_add_dummy_separately
5931 else
5932 func_modules_add_dummy
5935 # Show banner notice of every module.
5936 if $single_configure; then
5937 modules="$main_modules"
5938 func_modules_notice
5939 else
5940 func_modules_notice
5943 # Determine final file list.
5944 if $single_configure; then
5945 func_modules_to_filelist_separately
5946 else
5947 func_modules_to_filelist
5948 if test $verbose -ge 0; then
5949 echo "File list:"
5950 echo "$files" | sed -e 's/^/ /'
5953 # Add files for which the copy in gnulib is newer than the one that
5954 # "automake --add-missing --copy" would provide.
5955 files="$files build-aux/config.guess"
5956 files="$files build-aux/config.sub"
5957 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
5959 rewritten='%REWRITTEN%'
5960 sed_rewrite_files="\
5961 s,^build-aux/,$rewritten$auxdir/,
5962 s,^doc/,$rewritten$docbase/,
5963 s,^lib/,$rewritten$sourcebase/,
5964 s,^m4/,$rewritten$m4base/,
5965 s,^tests/,$rewritten$testsbase/,
5966 s,^tests=lib/,$rewritten$testsbase/,
5967 s,^top/,$rewritten,
5968 s,^$rewritten,,"
5970 # Create directories.
5971 for f in $files; do echo $f; done \
5972 | sed -e "$sed_rewrite_files" \
5973 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5974 | LC_ALL=C sort -u \
5975 > "$tmp"/dirs
5976 { # Rearrange file descriptors. Needed because "while ... done < ..."
5977 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5978 exec 5<&0 < "$tmp"/dirs
5979 while read d; do
5980 mkdir -p "$testdir/$d"
5981 done
5982 exec 0<&5 5<&-
5985 # Copy files or make symbolic links.
5986 delimiter=' '
5987 for f in $files; do echo $f; done \
5988 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
5989 | LC_ALL=C sort \
5990 > "$tmp"/files
5991 { # Rearrange file descriptors. Needed because "while ... done < ..."
5992 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5993 exec 5<&0 < "$tmp"/files
5994 while read g f; do
5995 case "$f" in
5996 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
5997 esac
5998 func_lookup_file "$f"
5999 if test -n "$lookedup_tmp"; then
6000 cp -p "$lookedup_file" "$testdir/$g"
6001 else
6002 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
6003 if func_should_symlink; then
6004 func_ln "$lookedup_file" "$testdir/$g"
6005 else
6006 cp -p "$lookedup_file" "$testdir/$g"
6009 done
6010 exec 0<&5 5<&-
6013 # Determine include_guard_prefix.
6014 func_compute_include_guard_prefix
6016 # Create Makefile.ams that are for testing.
6017 for_test=true
6019 # No special edits are needed.
6020 makefile_am_edits=0
6022 # Create $sourcebase/Makefile.am.
6023 mkdir -p "$testdir/$sourcebase"
6024 destfile="$sourcebase/Makefile.am"
6025 if $single_configure; then
6026 modules="$main_modules"
6028 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
6029 any_uses_subdirs="$uses_subdirs"
6031 # Create $m4base/Makefile.am.
6032 mkdir -p "$testdir/$m4base"
6033 (echo "## Process this file with automake to produce Makefile.in."
6034 echo
6035 echo "EXTRA_DIST ="
6036 for f in $files; do
6037 case "$f" in
6038 m4/* )
6039 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
6040 esac
6041 done
6042 ) > "$testdir/$m4base/Makefile.am"
6044 subdirs="$sourcebase $m4base"
6045 subdirs_with_configure_ac=""
6047 if false && test -f "$testdir"/$m4base/gettext.m4; then
6048 # Avoid stupid error message from automake:
6049 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
6050 mkdir -p "$testdir/po"
6051 (echo "## Process this file with automake to produce Makefile.in."
6052 ) > "$testdir/po/Makefile.am"
6053 func_append subdirs " po"
6056 if $inctests; then
6057 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
6058 if $single_configure; then
6059 # Create $testsbase/Makefile.am.
6060 destfile="$testsbase/Makefile.am"
6061 modules="$testsrelated_modules"
6062 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$testdir/$testsbase/Makefile.am"
6063 else
6064 # Viewed from the $testsbase subdirectory, $auxdir is different.
6065 saved_auxdir="$auxdir"
6066 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
6067 # Create $testsbase/Makefile.am.
6068 use_libtests=false
6069 destfile="$testsbase/Makefile.am"
6070 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
6071 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
6072 # Create $testsbase/configure.ac.
6073 (echo "# Process this file with autoconf to produce a configure script."
6074 echo "AC_INIT([dummy], [0])"
6075 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6076 echo "AM_INIT_AUTOMAKE"
6077 echo
6078 echo "AC_CONFIG_HEADERS([config.h])"
6079 echo
6080 echo "AC_PROG_CC"
6081 echo "AC_PROG_INSTALL"
6082 echo "AC_PROG_MAKE_SET"
6084 func_emit_pre_early_macros false '' "$modules"
6086 if test -n "$uses_subdirs"; then
6087 echo "AM_PROG_CC_C_O"
6088 echo
6090 for module in $modules; do
6091 func_verify_module
6092 if test -n "$module"; then
6093 case $module in
6094 gnumakefile | maintainer-makefile)
6095 # These modules are meant to be used only in the top-level directory.
6098 func_get_autoconf_early_snippet "$module"
6100 esac
6102 done \
6103 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
6104 if test "$libtool" = true; then
6105 echo "LT_INIT([win32-dll])"
6106 echo "LT_LANG([C++])"
6107 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6108 echo "gl_cond_libtool=true"
6109 else
6110 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6111 echo "gl_cond_libtool=false"
6112 echo "gl_libdeps="
6113 echo "gl_ltlibdeps="
6115 # Wrap the set of autoconf snippets into an autoconf macro that is then
6116 # invoked. This is needed because autoconf does not support AC_REQUIRE
6117 # at the top level:
6118 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6119 # but we want the AC_REQUIRE to have its normal meaning (provide one
6120 # expansion of the required macro before the current point, and only one
6121 # expansion total).
6122 echo "AC_DEFUN([gl_INIT], ["
6123 sed_replace_build_aux='
6125 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6126 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6129 echo "gl_m4_base='../$m4base'"
6130 func_emit_initmacro_start $macro_prefix
6131 # We don't have explicit ordering constraints between the various
6132 # autoconf snippets. It's cleanest to put those of the library before
6133 # those of the tests.
6134 echo "gl_source_base='../$sourcebase'"
6135 func_emit_autoconf_snippets "$modules" func_verify_nontests_module false false false
6136 echo "gl_source_base='.'"
6137 func_emit_autoconf_snippets "$modules" func_verify_tests_module false false false
6138 func_emit_initmacro_end $macro_prefix
6139 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6140 # created using libtool, because libtool already handles the dependencies.
6141 if test "$libtool" != true; then
6142 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6143 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6144 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6145 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6146 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6148 echo "])"
6149 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
6150 echo
6151 echo "gl_INIT"
6152 echo
6153 # Usually $testsbase/config.h will be a superset of config.h. Verify this
6154 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
6155 echo "AH_TOP([#include \"../config.h\"])"
6156 echo
6157 echo "AC_CONFIG_FILES([Makefile])"
6158 echo "AC_OUTPUT"
6159 ) > "$testdir/$testsbase/configure.ac"
6160 auxdir="$saved_auxdir"
6161 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
6163 func_append subdirs " $testsbase"
6166 # Create Makefile.am.
6167 (echo "## Process this file with automake to produce Makefile.in."
6168 echo
6169 echo "AUTOMAKE_OPTIONS = 1.9.6 foreign"
6170 echo
6171 echo "SUBDIRS = $subdirs"
6172 echo
6173 echo "ACLOCAL_AMFLAGS = -I $m4base"
6174 ) > "$testdir/Makefile.am"
6176 # Create configure.ac.
6177 (echo "# Process this file with autoconf to produce a configure script."
6178 echo "AC_INIT([dummy], [0])"
6179 if test "$auxdir" != "."; then
6180 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6182 echo "AM_INIT_AUTOMAKE"
6183 echo
6184 echo "AC_CONFIG_HEADERS([config.h])"
6185 echo
6186 echo "AC_PROG_CC"
6187 echo "AC_PROG_INSTALL"
6188 echo "AC_PROG_MAKE_SET"
6189 echo
6190 echo "# For autobuild."
6191 echo "AC_CANONICAL_BUILD"
6192 echo "AC_CANONICAL_HOST"
6193 echo
6194 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
6195 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
6196 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
6197 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
6199 func_emit_pre_early_macros false '' "$final_modules"
6201 if test -n "$any_uses_subdirs"; then
6202 echo "AM_PROG_CC_C_O"
6203 echo
6205 for module in $final_modules; do
6206 if $single_configure; then
6207 func_verify_module
6208 else
6209 func_verify_nontests_module
6211 if test -n "$module"; then
6212 func_get_autoconf_early_snippet "$module"
6214 done \
6215 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
6216 if test "$libtool" = true; then
6217 echo "LT_INIT([win32-dll])"
6218 echo "LT_LANG([C++])"
6219 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6220 echo "gl_cond_libtool=true"
6221 else
6222 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6223 echo "gl_cond_libtool=false"
6224 echo "gl_libdeps="
6225 echo "gl_ltlibdeps="
6227 # Wrap the set of autoconf snippets into an autoconf macro that is then
6228 # invoked. This is needed because autoconf does not support AC_REQUIRE
6229 # at the top level:
6230 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6231 # but we want the AC_REQUIRE to have its normal meaning (provide one
6232 # expansion of the required macro before the current point, and only one
6233 # expansion total).
6234 echo "AC_DEFUN([gl_INIT], ["
6235 if test "$auxdir" != "build-aux"; then
6236 sed_replace_build_aux='
6238 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6239 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6242 else
6243 sed_replace_build_aux="$sed_noop"
6245 echo "gl_m4_base='$m4base'"
6246 func_emit_initmacro_start $macro_prefix
6247 echo "gl_source_base='$sourcebase'"
6248 if $single_configure; then
6249 func_emit_autoconf_snippets "$main_modules" func_verify_module true false false
6250 else
6251 func_emit_autoconf_snippets "$modules" func_verify_nontests_module true false false
6253 func_emit_initmacro_end $macro_prefix
6254 if $single_configure; then
6255 echo " gltests_libdeps="
6256 echo " gltests_ltlibdeps="
6257 func_emit_initmacro_start ${macro_prefix}tests
6258 echo " gl_source_base='$testsbase'"
6259 # Define a tests witness macro.
6260 echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
6261 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
6262 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
6263 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
6264 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true false false
6265 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
6266 func_emit_initmacro_end ${macro_prefix}tests
6268 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6269 # created using libtool, because libtool already handles the dependencies.
6270 if test "$libtool" != true; then
6271 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6272 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6273 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6274 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6275 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6277 if $single_configure; then
6278 if $use_libtests; then
6279 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
6280 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
6283 echo "])"
6284 func_emit_initmacro_done $macro_prefix $sourcebase
6285 if $single_configure; then
6286 func_emit_initmacro_done ${macro_prefix}tests $testsbase
6288 echo
6289 echo "gl_INIT"
6290 echo
6291 if test -n "$subdirs_with_configure_ac"; then
6292 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
6294 makefiles="Makefile"
6295 for d in $subdirs; do
6296 # For subdirs that have a configure.ac by their own, it's the subdir's
6297 # configure.ac which creates the subdir's Makefile.am, not this one.
6298 case " $subdirs_with_configure_ac " in
6299 *" $d "*) ;;
6300 *) func_append makefiles " $d/Makefile" ;;
6301 esac
6302 done
6303 echo "AC_CONFIG_FILES([$makefiles])"
6304 echo "AC_OUTPUT"
6305 ) > "$testdir/configure.ac"
6307 # Create autogenerated files.
6308 (cd "$testdir"
6309 # Do not use "${AUTORECONF} --force --install", because it may invoke
6310 # autopoint, which brings in older versions of some of our .m4 files.
6311 if test -f $m4base/gettext.m4; then
6312 func_execute_command ${AUTOPOINT} --force || func_exit 1
6313 for f in $m4base/*.m4~; do
6314 if test -f $f; then
6315 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6317 done
6319 if test "$libtool" = true; then
6320 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
6322 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
6323 if ! test -d build-aux; then
6324 func_execute_command mkdir build-aux || func_exit 1
6326 func_execute_command ${AUTOCONF} || func_exit 1
6327 func_execute_command ${AUTOHEADER} || func_exit 1
6328 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6329 ) || func_exit 1
6330 if $inctests && ! $single_configure; then
6331 # Create autogenerated files.
6332 (cd "$testdir/$testsbase" || func_exit 1
6333 # Do not use "${AUTORECONF} --force --install", because it may invoke
6334 # autopoint, which brings in older versions of some of our .m4 files.
6335 if test -f ../$m4base/gettext.m4; then
6336 func_execute_command ${AUTOPOINT} --force || func_exit 1
6337 for f in ../$m4base/*.m4~; do
6338 if test -f $f; then
6339 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6341 done
6343 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
6344 if ! test -d ../build-aux; then
6345 func_execute_command mkdir ../build-aux
6347 func_execute_command ${AUTOCONF} || func_exit 1
6348 func_execute_command ${AUTOHEADER} || func_exit 1
6349 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6350 ) || func_exit 1
6352 # Need to run configure and make once, to create built files that are to be
6353 # distributed (such as parse-datetime.c).
6354 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
6355 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
6356 cleaned_files=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
6357 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6358 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
6359 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
6360 # such $(FOO_H) because they don't refer to distributed files.
6361 built_sources=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
6362 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6363 | sed -e "$sed_remove_make_variables"`
6364 distributed_built_sources=`for file in $built_sources; do
6365 case "$cleaned_files" in
6366 *" "$file" "*) ;;
6367 *) echo $file ;;
6368 esac;
6369 done`
6370 tests_distributed_built_sources=
6371 if $inctests; then
6372 # Likewise for built files in the $testsbase directory.
6373 tests_cleaned_files=`combine_lines < "$testdir/$testsbase/Makefile.am" \
6374 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6375 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
6376 tests_built_sources=`combine_lines < "$testdir/$testsbase/Makefile.am" \
6377 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6378 | sed -e "$sed_remove_make_variables"`
6379 tests_distributed_built_sources=`for file in $tests_built_sources; do
6380 case "$tests_cleaned_files" in
6381 *" "$file" "*) ;;
6382 *) echo $file ;;
6383 esac;
6384 done`
6386 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
6387 (cd "$testdir"
6388 ./configure || func_exit 1
6389 if test -n "$distributed_built_sources"; then
6390 cd "$sourcebase"
6391 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6392 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6393 built_sources \
6394 || func_exit 1
6395 cd ..
6397 if test -n "$tests_distributed_built_sources"; then
6398 cd "$testsbase"
6399 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6400 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6401 built_sources \
6402 || func_exit 1
6403 cd ..
6405 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6406 distclean \
6407 || func_exit 1
6408 ) || func_exit 1
6412 # func_create_megatestdir megatestdir allmodules
6413 # Input:
6414 # - local_gnulib_path from --local-dir
6415 # - modcache true or false, from --cache-modules/--no-cache-modules
6416 # - auxdir directory relative to destdir where to place build aux files
6417 func_create_megatestdir ()
6419 megatestdir="$1"
6420 allmodules="$2"
6421 if test -z "$allmodules"; then
6422 allmodules=`func_all_modules`
6425 megasubdirs=
6426 # First, all modules one by one.
6427 for onemodule in $allmodules; do
6428 func_create_testdir "$megatestdir/$onemodule" $onemodule
6429 func_append megasubdirs "$onemodule "
6430 done
6431 # Then, all modules all together.
6432 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6433 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
6434 func_create_testdir "$megatestdir/ALL" "$allmodules"
6435 func_append megasubdirs "ALL"
6437 # Create autobuild.
6438 cvsdate=`vc_witness="$gnulib_dir/.git/refs/heads/master"; \
6439 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
6440 | sed -e 's,January,01,' -e 's,Jan,01,' \
6441 -e 's,February,02,' -e 's,Feb,02,' \
6442 -e 's,March,03,' -e 's,Mar,03,' \
6443 -e 's,April,04,' -e 's,Apr,04,' \
6444 -e 's,May,05,' \
6445 -e 's,June,06,' -e 's,Jun,06,' \
6446 -e 's,July,07,' -e 's,Jul,07,' \
6447 -e 's,August,08,' -e 's,Aug,08,' \
6448 -e 's,September,09,' -e 's,Sep,09,' \
6449 -e 's,October,10,' -e 's,Oct,10,' \
6450 -e 's,November,11,' -e 's,Nov,11,' \
6451 -e 's,December,12,' -e 's,Dec,12,' \
6452 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
6453 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
6454 (echo '#!/bin/sh'
6455 echo "CVSDATE=$cvsdate"
6456 echo ": \${MAKE=make}"
6457 echo "test -d logs || mkdir logs"
6458 echo "for module in $megasubdirs; do"
6459 echo " echo \"Working on module \$module...\""
6460 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
6461 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
6462 echo " echo"
6463 echo " set -x"
6464 echo " : autobuild project... \$module"
6465 echo " : autobuild revision... cvs-\$CVSDATE-000000"
6466 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
6467 echo " : autobuild hostname... \`hostname\`"
6468 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
6469 echo " echo rc=\$?"
6470 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
6471 echo "done"
6472 ) > "$megatestdir/do-autobuild"
6473 chmod a+x "$megatestdir/do-autobuild"
6475 # Create Makefile.am.
6476 (echo "## Process this file with automake to produce Makefile.in."
6477 echo
6478 echo "AUTOMAKE_OPTIONS = 1.9.6 foreign"
6479 echo
6480 echo "SUBDIRS = $megasubdirs"
6481 echo
6482 echo "EXTRA_DIST = do-autobuild"
6483 ) > "$megatestdir/Makefile.am"
6485 # Create configure.ac.
6486 (echo "# Process this file with autoconf to produce a configure script."
6487 echo "AC_INIT([dummy], [0])"
6488 if test "$auxdir" != "."; then
6489 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6491 echo "AM_INIT_AUTOMAKE"
6492 echo
6493 echo "AC_PROG_MAKE_SET"
6494 echo
6495 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
6496 echo "AC_CONFIG_FILES([Makefile])"
6497 echo "AC_OUTPUT"
6498 ) > "$megatestdir/configure.ac"
6500 # Create autogenerated files.
6501 (cd "$megatestdir"
6502 # Do not use "${AUTORECONF} --install", because autoreconf operates
6503 # recursively, but the subdirectories are already finished, therefore
6504 # calling autoreconf here would only waste lots of CPU time.
6505 func_execute_command ${ACLOCAL} || func_exit 1
6506 func_execute_command mkdir build-aux
6507 func_execute_command ${AUTOCONF} || func_exit 1
6508 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6509 ) || func_exit 1
6512 case $mode in
6513 "" )
6514 func_fatal_error "no mode specified" ;;
6516 list )
6517 func_all_modules
6520 find )
6521 # sed expression that converts a literal to a basic regular expression.
6522 # Needs to handle . [ \ * ^ $.
6523 sed_literal_to_basic_regex='s/\\/\\\\/g
6524 s/\[/\\[/g
6525 s/\^/\\^/g
6526 s/\([.*$]\)/[\1]/g'
6527 for filename
6529 if test -f "$gnulib_dir/$filename" \
6530 || func_lookup_local_file "$filename"; then
6531 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
6532 filename_line_regex='^'"$filename_anywhere_regex"'$'
6533 module_candidates=`
6535 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
6536 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$,,'
6538 | func_sanitize_modulelist \
6539 | LC_ALL=C sort -u
6541 for module in $module_candidates; do
6542 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
6543 echo $module
6545 done
6546 else
6547 func_warning "file $filename does not exist"
6549 done
6552 import | add-import | remove-import | update )
6554 # Where to import.
6555 if test -z "$destdir"; then
6556 destdir=.
6558 test -d "$destdir" \
6559 || func_fatal_error "destination directory does not exist: $destdir"
6561 # Prefer configure.ac to configure.in.
6562 if test -f "$destdir"/configure.ac; then
6563 configure_ac="$destdir/configure.ac"
6564 else
6565 if test -f "$destdir"/configure.in; then
6566 configure_ac="$destdir/configure.in"
6567 else
6568 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
6572 # Analyze configure.ac.
6573 guessed_auxdir="."
6574 guessed_libtool=false
6575 my_sed_traces='
6576 s,#.*$,,
6577 s,^dnl .*$,,
6578 s, dnl .*$,,
6579 /AC_CONFIG_AUX_DIR/ {
6580 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
6582 /A[CM]_PROG_LIBTOOL/ {
6583 s,^.*$,guessed_libtool=true,p
6585 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
6587 if test -z "$auxdir"; then
6588 auxdir="$guessed_auxdir"
6591 # Determine where to apply func_import.
6592 if test "$mode" = import; then
6593 # Apply func_import to a particular gnulib directory.
6594 # The command line contains the complete specification; don't look at
6595 # the contents of gnulib-cache.m4.
6596 test -n "$supplied_libname" || supplied_libname=true
6597 test -n "$sourcebase" || sourcebase="lib"
6598 test -n "$m4base" || m4base="m4"
6599 test -n "$docbase" || docbase="doc"
6600 test -n "$testsbase" || testsbase="tests"
6601 test -n "$macro_prefix" || macro_prefix="gl"
6602 func_import "$*"
6603 else
6604 if test -n "$m4base"; then
6605 # Apply func_import to a particular gnulib directory.
6606 # Any number of additional modules can be given.
6607 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
6608 # First use of gnulib in the given m4base.
6609 test -n "$supplied_libname" || supplied_libname=true
6610 test -n "$sourcebase" || sourcebase="lib"
6611 test -n "$docbase" || docbase="doc"
6612 test -n "$testsbase" || testsbase="tests"
6613 test -n "$macro_prefix" || macro_prefix="gl"
6615 func_import "$*"
6616 else
6617 # Apply func_import to all gnulib directories.
6618 # To get this list of directories, look at Makefile.am. (Not at
6619 # configure, because it may be omitted from version control. Also,
6620 # don't run "find $destdir -name gnulib-cache.m4", as it might be
6621 # too expensive.)
6622 m4dirs=
6623 m4dirs_count=0
6624 if test -f "$destdir"/Makefile.am; then
6625 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
6626 m4dir_is_next=
6627 for arg in $aclocal_amflags; do
6628 if test -n "$m4dir_is_next"; then
6629 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
6630 case "$arg" in
6631 /*) ;;
6633 if test -f "$destdir/$arg"/gnulib-cache.m4; then
6634 func_append m4dirs " $arg"
6635 m4dirs_count=`expr $m4dirs_count + 1`
6638 esac
6639 m4dir_is_next=
6640 else
6641 if test "X$arg" = "X-I"; then
6642 m4dir_is_next=yes
6643 else
6644 m4dir_is_next=
6647 done
6648 else
6649 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
6650 if test -f "$destdir"/aclocal.m4; then
6651 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
6652 sedexpr2='s,^[^/]*$,.,'
6653 sedexpr3='s,/[^/]*$,,'
6654 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
6655 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
6656 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
6659 if test $m4dirs_count = 0; then
6660 # First use of gnulib in a package.
6661 # Any number of additional modules can be given.
6662 test -n "$supplied_libname" || supplied_libname=true
6663 test -n "$sourcebase" || sourcebase="lib"
6664 m4base="m4"
6665 test -n "$docbase" || docbase="doc"
6666 test -n "$testsbase" || testsbase="tests"
6667 test -n "$macro_prefix" || macro_prefix="gl"
6668 func_import "$*"
6669 else
6670 if test $m4dirs_count = 1; then
6671 # There's only one use of gnulib here. Assume the user means it.
6672 # Any number of additional modules can be given.
6673 for m4base in $m4dirs; do
6674 func_import "$*"
6675 done
6676 else
6677 # Ambiguous - guess what the user meant.
6678 if test $# = 0; then
6679 # No further arguments. Guess the user wants to update all of them.
6680 for m4base in $m4dirs; do
6681 # Perform func_import in a subshell, so that variable values
6682 # such as
6683 # local_gnulib_path, incobsolete, inc_cxx_tests,
6684 # inc_longrunning_tests, inc_privileged_tests,
6685 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
6686 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
6687 # makefile_name, libtool, macro_prefix, po_domain,
6688 # witness_c_macro, vc_files
6689 # don't propagate from one directory to another.
6690 (func_import) || func_exit 1
6691 done
6692 else
6693 # Really ambiguous.
6694 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
6702 create-testdir )
6703 if test -z "$destdir"; then
6704 func_fatal_error "please specify --dir option"
6706 mkdir "$destdir"
6707 test -d "$destdir" \
6708 || func_fatal_error "could not create destination directory"
6709 test -n "$auxdir" || auxdir="build-aux"
6710 func_create_testdir "$destdir" "$*"
6713 create-megatestdir )
6714 if test -z "$destdir"; then
6715 func_fatal_error "please specify --dir option"
6717 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6718 test -n "$auxdir" || auxdir="build-aux"
6719 func_create_megatestdir "$destdir" "$*"
6722 test )
6723 test -n "$destdir" || destdir=testdir$$
6724 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6725 test -n "$auxdir" || auxdir="build-aux"
6726 func_create_testdir "$destdir" "$*"
6727 cd "$destdir"
6728 mkdir build
6729 cd build
6730 ../configure || func_exit 1
6731 $MAKE || func_exit 1
6732 $MAKE check || func_exit 1
6733 $MAKE distclean || func_exit 1
6734 remaining=`find . -type f -print`
6735 if test -n "$remaining"; then
6736 echo "Remaining files:" $remaining 1>&2
6737 echo "gnulib-tool: *** Stop." 1>&2
6738 func_exit 1
6740 cd ..
6741 cd ..
6742 rm -rf "$destdir"
6745 megatest )
6746 test -n "$destdir" || destdir=testdir$$
6747 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6748 test -n "$auxdir" || auxdir="build-aux"
6749 func_create_megatestdir "$destdir" "$*"
6750 cd "$destdir"
6751 mkdir build
6752 cd build
6753 ../configure
6754 $MAKE
6755 $MAKE check
6756 $MAKE distclean
6757 remaining=`find . -type f -print`
6758 if test -n "$remaining"; then
6759 echo "Remaining files:" $remaining 1>&2
6760 echo "gnulib-tool: *** Stop." 1>&2
6761 func_exit 1
6763 cd ..
6764 cd ..
6765 rm -rf "$destdir"
6768 extract-description )
6769 for module
6771 func_verify_module
6772 if test -n "$module"; then
6773 func_get_description "$module"
6775 done
6778 extract-comment )
6779 for module
6781 func_verify_module
6782 if test -n "$module"; then
6783 func_get_comment "$module"
6785 done
6788 extract-status )
6789 for module
6791 func_verify_module
6792 if test -n "$module"; then
6793 func_get_status "$module"
6795 done
6798 extract-notice )
6799 for module
6801 func_verify_module
6802 if test -n "$module"; then
6803 func_get_notice "$module"
6805 done
6808 extract-applicability )
6809 for module
6811 func_verify_module
6812 if test -n "$module"; then
6813 func_get_applicability "$module"
6815 done
6818 extract-filelist )
6819 for module
6821 func_verify_module
6822 if test -n "$module"; then
6823 func_get_filelist "$module"
6825 done
6828 extract-dependencies )
6829 if test -n "$avoidlist"; then
6830 func_fatal_error "cannot combine --avoid and --extract-dependencies"
6832 for module
6834 func_verify_module
6835 if test -n "$module"; then
6836 func_get_dependencies "$module"
6838 done
6841 extract-autoconf-snippet )
6842 for module
6844 func_verify_module
6845 if test -n "$module"; then
6846 func_get_autoconf_snippet "$module"
6848 done
6851 extract-automake-snippet )
6852 for module
6854 func_verify_module
6855 if test -n "$module"; then
6856 func_get_automake_snippet "$module"
6858 done
6861 extract-include-directive )
6862 for module
6864 func_verify_module
6865 if test -n "$module"; then
6866 func_get_include_directive "$module"
6868 done
6871 extract-link-directive )
6872 for module
6874 func_verify_module
6875 if test -n "$module"; then
6876 func_get_link_directive "$module"
6878 done
6881 extract-license )
6882 for module
6884 func_verify_module
6885 if test -n "$module"; then
6886 func_get_license "$module"
6888 done
6891 extract-maintainer )
6892 for module
6894 func_verify_module
6895 if test -n "$module"; then
6896 func_get_maintainer "$module"
6898 done
6901 extract-tests-module )
6902 for module
6904 func_verify_module
6905 if test -n "$module"; then
6906 func_get_tests_module "$module"
6908 done
6911 copy-file )
6912 # Verify the number of arguments.
6913 if test $# -lt 1 || test $# -gt 2; then
6914 func_fatal_error "invalid number of arguments for --$mode"
6917 # The first argument is the file to be copied.
6918 f="$1"
6919 # Verify the file exists.
6920 func_lookup_file "$f"
6922 # The second argument is the destination; either a directory ot a file.
6923 # It defaults to the current directory.
6924 dest="$2"
6925 test -n "$dest" || dest='.'
6926 test -n "$sourcebase" || sourcebase="lib"
6927 test -n "$m4base" || m4base="m4"
6928 test -n "$docbase" || docbase="doc"
6929 test -n "$testsbase" || testsbase="tests"
6930 test -n "$auxdir" || auxdir="build-aux"
6931 rewritten='%REWRITTEN%'
6932 sed_rewrite_files="\
6933 s,^build-aux/,$rewritten$auxdir/,
6934 s,^doc/,$rewritten$docbase/,
6935 s,^lib/,$rewritten$sourcebase/,
6936 s,^m4/,$rewritten$m4base/,
6937 s,^tests/,$rewritten$testsbase/,
6938 s,^top/,$rewritten,
6939 s,^$rewritten,,"
6940 if test -d "$dest"; then
6941 destdir="$dest"
6942 g=`echo "$f" | sed -e "$sed_rewrite_files"`
6943 else
6944 destdir=`dirname "$dest"`
6945 g=`basename "$dest"`
6948 # Create the directory for destfile.
6949 d=`dirname "$destdir/$g"`
6950 if $doit; then
6951 if test -n "$d" && test ! -d "$d"; then
6952 mkdir -p "$d" || func_fatal_error "failed"
6955 # Copy the file.
6956 func_dest_tmpfilename "$g"
6957 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
6958 already_present=true
6959 if test -f "$destdir/$g"; then
6960 # The file already exists.
6961 func_update_file
6962 else
6963 # Install the file.
6964 # Don't protest if the file should be there but isn't: it happens
6965 # frequently that developers don't put autogenerated files under version
6966 # control.
6967 func_add_file
6969 rm -f "$tmpfile"
6973 func_fatal_error "unknown operation mode --$mode" ;;
6974 esac
6976 rm -rf "$tmp"
6977 # Undo the effect of the previous 'trap' command. Some shellology:
6978 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
6979 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
6980 # exit); for the others we need to call 'exit' explicitly. The value of $? is
6981 # 128 + signal number and is set before the trap-registered command is run.
6982 trap '' 0
6983 trap 'func_exit $?' 1 2 3 13 15
6985 exit 0
6987 # Local Variables:
6988 # indent-tabs-mode: nil
6989 # whitespace-check-buffer-indent: nil
6990 # End: