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.
28 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
32 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
33 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
37 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
40 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
43 # You can set LIBTOOLPATH to empty if libtoolize 2.x is already in your PATH.
46 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
47 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
48 if test -z "${AUTOCONF}" ||
test -n "${AUTOCONFPATH}"; then
49 AUTOCONF
="${AUTOCONFPATH}autoconf"
51 if test -z "${AUTOHEADER}" ||
test -n "${AUTOCONFPATH}"; then
52 AUTOHEADER
="${AUTOCONFPATH}autoheader"
54 if test -z "${ACLOCAL}" ||
test -n "${AUTOMAKEPATH}"; then
55 ACLOCAL
="${AUTOMAKEPATH}aclocal"
57 if test -z "${AUTOMAKE}" ||
test -n "${AUTOMAKEPATH}"; then
58 AUTOMAKE
="${AUTOMAKEPATH}automake"
60 if test -z "${AUTORECONF}" ||
test -n "${AUTOCONFPATH}"; then
61 AUTORECONF
="${AUTOCONFPATH}autoreconf"
64 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
65 if test -z "${AUTOPOINT}" ||
test -n "${GETTEXTPATH}"; then
66 AUTOPOINT
="${GETTEXTPATH}autopoint"
69 # If you didn't set LIBTOOLPATH, you can also set the variable LIBTOOLIZE.
70 if test -z "${LIBTOOLIZE}" ||
test -n "${LIBTOOLPATH}"; then
71 LIBTOOLIZE
="${LIBTOOLPATH}libtoolize"
75 if test -z "${MAKE}"; then
79 # When using GNU sed, turn off as many GNU extensions as possible,
80 # to minimize the risk of accidentally using non-portable features.
81 # However, do this only for gnulib-tool itself, not for the code that
82 # gnulib-tool generates, since we don't want "sed --posix" to leak
83 # into makefiles. And do it only for sed versions 4.2 or newer,
84 # because "sed --posix" is buggy in GNU sed 4.1.5, see
85 # <http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00225.html>.
86 if (alias) > /dev
/null
2>&1 \
87 && echo |
sed --posix -e d
>/dev
/null
2>&1 \
88 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
89 [1-3]* |
4.
[01]*) false
;; \
93 # Define sed as an alias.
94 # It is not always possible to use aliases. Aliases are guaranteed to work
95 # if the executing shell is bash and either it is invoked as /bin/sh or
96 # is a version >= 2.0, supporting shopt. This is the common case.
97 # Two other approaches (use of a variable $sed or of a function func_sed
98 # instead of an alias) require massive, fragile code changes.
99 # An other approach (use of function sed) requires `which sed` - but
100 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
101 if test -n "$BASH_VERSION"; then
102 shopt -s expand_aliases
>/dev
/null
2>&1
104 alias sed='sed --posix'
107 # sed_noop is a sed expression that does nothing.
108 # An empty expression does not work with the native 'sed' on AIX 6.1.
111 # sed_comments is true or false, depending whether 'sed' supports comments.
112 # AIX 5.3 sed barfs over indented comments.
113 if echo fo |
sed -e 's/f/g/
116 s/o/e/' 2>/dev
/null |
grep ge
> /dev
/null
; then
123 # outputs to stdout the --help usage message.
127 Usage: gnulib-tool --list
128 gnulib-tool --find filename
129 gnulib-tool --import [module1 ... moduleN]
130 gnulib-tool --add-import [module1 ... moduleN]
131 gnulib-tool --remove-import [module1 ... moduleN]
133 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
134 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
135 gnulib-tool --test --dir=directory module1 ... moduleN
136 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
137 gnulib-tool --extract-description module
138 gnulib-tool --extract-comment module
139 gnulib-tool --extract-status module
140 gnulib-tool --extract-notice module
141 gnulib-tool --extract-applicability module
142 gnulib-tool --extract-filelist module
143 gnulib-tool --extract-dependencies module
144 gnulib-tool --extract-autoconf-snippet module
145 gnulib-tool --extract-automake-snippet module
146 gnulib-tool --extract-include-directive module
147 gnulib-tool --extract-link-directive module
148 gnulib-tool --extract-license module
149 gnulib-tool --extract-maintainer module
150 gnulib-tool --extract-tests-module module
151 gnulib-tool --copy-file file [destination]
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
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
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.
194 --dir=DIRECTORY Specify the target directory.
195 For --import, this specifies where your
196 configure.ac can be found. Defaults to current
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
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
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|=3] Abort if modules aren't available under the LGPL.
268 Also modify license template from GPL to LGPL.
269 The version number of the LGPL can be specified;
270 the default is currently LGPLv3.
271 --makefile-name=NAME Name of makefile in automake syntax in the
272 source-base and tests-base directories
273 (default \"Makefile.am\").
274 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
275 'gl_INIT'. Default is 'gl'.
276 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
277 the package name. A suffix '-gnulib' is appended.
278 --witness-c-macro=NAME Specify the C macro that is defined when the
279 sources in this directory are compiled or used.
280 --vc-files Update version control related files.
281 --no-vc-files Don't update version control related files
282 (.gitignore and/or .cvsignore).
284 Options for --create-[mega]testdir, --[mega]test:
286 --single-configure Generate a single configure file, not a separate
287 configure file for the tests directory.
289 Options for --import, --add/remove-import, --update,
290 --create-[mega]testdir, --[mega]test:
292 -s, --symbolic, --symlink Make symbolic links instead of copying files.
293 --local-symlink Make symbolic links instead of copying files, only
294 for files from the local override directory.
296 Options for --import, --add/remove-import, --update:
298 -S, --more-symlinks Make symbolic links instead of copying files, and
299 don't replace copyright notices.
301 Report bugs to <bug-gnulib@gnu.org>."
305 # outputs to stdout the --version message.
309 if test -d "$gnulib_dir"/.git \
310 && (git
--version) >/dev
/null
2>/dev
/null \
311 && (date --version) >/dev
/null
2>/dev
/null
; then
312 # gnulib checked out from git.
313 sed_extract_first_date
='/^Date/{
317 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
318 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
319 sed_year_before_time
='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
320 date=`echo "$date" | sed -e "$sed_year_before_time"`
321 # Use GNU date to compute the time in GMT.
322 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
323 version
=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
325 # gnulib copy without versioning information.
326 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
329 year
=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
331 gnulib-tool (GNU $package $date)$version
332 Copyright (C) $year Free Software Foundation, Inc.
333 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
334 This is free software: you are free to change and redistribute it.
335 There is NO WARRANTY, to the extent permitted by law.
337 printf "Written by %s, %s, and %s.\n" "Bruno Haible" "Paul Eggert" "Simon Josefsson"
340 # func_emit_copyright_notice
341 # outputs to stdout a header for a generated file.
342 func_emit_copyright_notice
()
344 sed -n -e '/Copyright/ {
347 }' < "$self_abspathname"
349 echo "# This file is free software; you can redistribute it and/or modify"
350 echo "# it under the terms of the GNU General Public License as published by"
351 echo "# the Free Software Foundation; either version 3 of the License, or"
352 echo "# (at your option) any later version."
354 echo "# This file is distributed in the hope that it will be useful,"
355 echo "# but WITHOUT ANY WARRANTY; without even the implied warranty of"
356 echo "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
357 echo "# GNU General Public License for more details."
359 echo "# You should have received a copy of the GNU General Public License"
360 echo "# along with this file. If not, see <http://www.gnu.org/licenses/>."
362 echo "# As a special exception to the GNU General Public License,"
363 echo "# this file may be distributed as part of a program that"
364 echo "# contains a configuration script generated by Autoconf, under"
365 echo "# the same distribution terms as the rest of that program."
367 echo "# Generated by gnulib-tool."
371 # exits with a given status.
372 # This function needs to be used, rather than 'exit', when a 'trap' handler is
373 # in effect that refers to $?.
380 # locates the directory where the gnulib repository lives
382 # - progname name of this program
384 # - self_abspathname absolute pathname of gnulib-tool
385 # - gnulib_dir absolute pathname of gnulib repository
389 /* | ?
:*) self_abspathname
="$progname" ;;
390 */*) self_abspathname
=`pwd`/"$progname" ;;
393 # Iterate through the elements of $PATH.
394 # We use IFS=: instead of
395 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
396 # because the latter does not work when some PATH element contains spaces.
397 # We use a canonicalized $pathx instead of $PATH, because empty PATH
398 # elements are by definition equivalent to '.', however field splitting
399 # according to IFS=: loses empty fields in many shells:
400 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
401 # beginning, at the end, and in the middle),
402 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
403 # at the beginning and at the end,
404 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
405 # Solaris lose empty fields at the end.
406 # The 'case' statement is an optimization, to avoid evaluating the
407 # explicit canonicalization command when $PATH contains no empty fields.
409 if test "$PATH_SEPARATOR" = ";"; then
410 # On Windows, programs are searched in "." before $PATH.
413 # On Unix, we have to convert empty PATH elements to ".".
417 pathx
=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
422 IFS
="$PATH_SEPARATOR"
426 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
427 self_abspathname
="$d/$progname"
432 if test -z "$self_abspathname"; then
433 func_fatal_error
"could not locate the gnulib-tool program - how did you invoke it?"
437 while test -h "$self_abspathname"; do
438 # Resolve symbolic link.
439 linkval
=`func_readlink "$self_abspathname"`
440 test -n "$linkval" ||
break
442 /* | ?
:* ) self_abspathname
="$linkval" ;;
443 * ) self_abspathname
=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
446 gnulib_dir
=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
450 # creates a temporary directory.
452 # - progname name of this program
454 # - tmp pathname of freshly created temporary directory
457 # Use the environment variable TMPDIR, falling back to /tmp. This allows
458 # users to specify a different temporary directory, for example, if their
459 # /tmp is filled up or too small.
462 # Use the mktemp program if available. If not available, hide the error
464 tmp
=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
465 test -n "$tmp" && test -d "$tmp"
468 # Use a simple mkdir command. It is guaranteed to fail if the directory
469 # already exists. $RANDOM is bash specific and expands to empty in shells
470 # other than bash, ksh and zsh. Its use does not increase security;
471 # rather, it minimizes the probability of failure in a very cluttered /tmp
473 tmp
=$TMPDIR/gl$$
-$RANDOM
474 (umask 077 && mkdir
"$tmp")
477 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
482 # func_append var value
483 # appends the given value to the shell variable var.
484 if ( foo
=bar
; foo
+=baz
&& test "$foo" = barbaz
) >/dev
/null
2>&1; then
485 # Use bash's += operator. It reduces complexity of appending repeatedly to
486 # a single variable from O(n^2) to O(n).
491 fast_func_append
=true
495 eval "$1=\"\$$1\$2\""
497 fast_func_append
=false
500 # func_remove_prefix var prefix
501 # removes the given prefix from the value of the shell variable var.
502 # var should be the name of a shell variable.
503 # Its value should not contain a newline and not start or end with whitespace.
504 # prefix should not contain the characters "$`\{}[]^|.
505 if ( foo
=bar
; eval 'test "${foo#b}" = ar' ) >/dev
/null
2>&1; then
506 func_remove_prefix
()
510 fast_func_remove_prefix
=true
512 func_remove_prefix
()
514 eval "value=\"\$$1\""
518 sed_escape_dots
='s/\([.]\)/\\\1/g'
519 prefix
=`echo "$prefix" | sed -e "$sed_escape_dots"`
522 value
=`echo "$value" | sed -e "s|^${prefix}||"`
523 eval "$1=\"\$value\""
525 fast_func_remove_prefix
=false
528 # Determine whether we should use ':' or ';' as PATH_SEPARATOR.
529 func_determine_path_separator
()
531 if test "${PATH_SEPARATOR+set}" != set; then
532 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
533 # contains only /bin. Note that ksh looks also at the FPATH variable,
534 # so we have to set that as well for the test.
536 (PATH
='/bin;/bin'; FPATH
=$PATH; sh
-c :) >/dev
/null
2>&1 \
537 && { (PATH
='/bin:/bin'; FPATH
=$PATH; sh
-c :) >/dev
/null
2>&1 \
538 || PATH_SEPARATOR
=';'
543 # func_path_prepend pathvar directory
544 # puts directory before pathvar, delimiting directories by PATH_SEPARATOR.
545 # Newly added directory into pathvar has the highest priority.
548 if eval "test -n \"\$$1\""; then
549 eval "$1=\$2\$PATH_SEPARATOR\$$1"
555 # func_path_append pathvar directory
556 # Similar to func_path_prepend except that the newest directory has the lowest
560 if eval "test -n \"\$$1\""; then
561 func_append
"$1" "$PATH_SEPARATOR$2"
567 # func_path_foreach_inner
568 # helper for func_path_foreach because we need new 'args' array
570 # - fpf_dir directory from local_gnulib_path
571 # - fpf_cb callback to be run for fpf_dir
572 func_path_foreach_inner
()
594 # func_path_foreach path method args
595 # Execute method for each directory in path. The method will be called
596 # like `method args` while any argument '%dir%' within args will be replaced
597 # with processed directory from path.
606 for fpf_dir
in $fpf_dirs
608 func_path_foreach_inner
"$@" && fpf_rc
=:
614 # func_remove_suffix var suffix
615 # removes the given suffix from the value of the shell variable var.
616 # var should be the name of a shell variable.
617 # Its value should not contain a newline and not start or end with whitespace.
618 # suffix should not contain the characters "$`\{}[]^|.
619 if ( foo
=bar
; eval 'test "${foo%r}" = ba' ) >/dev
/null
2>&1; then
620 func_remove_suffix
()
624 fast_func_remove_suffix
=true
626 func_remove_suffix
()
628 eval "value=\"\$$1\""
632 sed_escape_dots
='s/\([.]\)/\\\1/g'
633 suffix
=`echo "$suffix" | sed -e "$sed_escape_dots"`
636 value
=`echo "$value" | sed -e "s|${suffix}\$||"`
637 eval "$1=\"\$value\""
639 fast_func_remove_suffix
=false
642 # func_fatal_error message
643 # outputs to stderr a fatal error message, and terminates the program.
645 # - progname name of this program
648 echo "$progname: *** $1" 1>&2
649 echo "$progname: *** Stop." 1>&2
653 # func_warning message
654 # Outputs to stderr a warning message,
657 echo "gnulib-tool: warning: $1" 1>&2
660 # func_readlink SYMLINK
661 # outputs the target of the given symlink.
662 if (type readlink
) > /dev
/null
2>&1; then
665 # Use the readlink program from GNU coreutils.
671 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
672 # would do the wrong thing if the link target contains " -> ".
673 LC_ALL
=C
ls -l "$1" |
sed -e 's, -> ,#%%#,' |
sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
677 # func_relativize DIR1 DIR2
678 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
680 # - DIR1 relative pathname, relative to the current directory
681 # - DIR2 relative pathname, relative to the current directory
683 # - reldir relative pathname of DIR2, relative to DIR1
689 sed_first
='s,^\([^/]*\)/.*$,\1,'
690 sed_rest
='s,^[^/]*/*,,'
691 sed_last
='s,^.*/\([^/]*\)$,\1,'
692 sed_butlast
='s,/*[^/]*$,,'
693 while test -n "$dir1"; do
694 first
=`echo "$dir1" | sed -e "$sed_first"`
695 if test "$first" != "."; then
696 if test "$first" = ".."; then
697 dir2
=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
698 dir0
=`echo "$dir0" | sed -e "$sed_butlast"`
700 first2
=`echo "$dir2" | sed -e "$sed_first"`
701 if test "$first2" = "$first"; then
702 dir2
=`echo "$dir2" | sed -e "$sed_rest"`
706 dir0
="$dir0"/"$first"
709 dir1
=`echo "$dir1" | sed -e "$sed_rest"`
714 # func_relconcat DIR1 DIR2
715 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
717 # - DIR1 relative pathname, relative to the current directory
718 # - DIR2 relative pathname, relative to DIR1
720 # - relconcat DIR1/DIR2, relative to the current directory
725 sed_first
='s,^\([^/]*\)/.*$,\1,'
726 sed_rest
='s,^[^/]*/*,,'
727 sed_last
='s,^.*/\([^/]*\)$,\1,'
728 sed_butlast
='s,/*[^/]*$,,'
730 first
=`echo "$dir2" | sed -e "$sed_first"`
731 if test "$first" = "."; then
732 dir2
=`echo "$dir2" | sed -e "$sed_rest"`
733 if test -z "$dir2"; then
738 last
=`echo "$dir1" | sed -e "$sed_last"`
739 while test "$last" = "."; do
740 dir1
=`echo "$dir1" | sed -e "$sed_butlast"`
741 last
=`echo "$dir1" | sed -e "$sed_last"`
743 if test -z "$dir1"; then
747 if test "$first" = ".."; then
748 if test "$last" = ".."; then
749 relconcat
="$dir1/$dir2"
752 dir1
=`echo "$dir1" | sed -e "$sed_butlast"`
753 dir2
=`echo "$dir2" | sed -e "$sed_rest"`
754 if test -z "$dir1"; then
758 if test -z "$dir2"; then
763 relconcat
="$dir1/$dir2"
771 # Like ln -s, except that SRC is given relative to the current directory (or
772 # absolute), not given relative to the directory of DEST.
778 *) # SRC is relative.
781 ln -s "`pwd`/$1" "$2" ;;
782 *) # DEST is relative too.
783 ln_destdir
=`echo "$2" | sed -e 's,[^/]*$,,'`
784 test -n "$ln_destdir" || ln_destdir
="."
785 func_relativize
"$ln_destdir" "$1"
793 # func_ln_if_changed SRC DEST
794 # Like func_ln, but avoids munging timestamps if the link is correct.
795 func_ln_if_changed
()
797 if test $# -ne 2; then
798 echo "usage: func_ln_if_changed SRC DEST" >&2
800 ln_target
=`func_readlink "$2"`
801 if test -h "$2" && test "$1" = "$ln_target"; then
809 # Ensure an 'echo' command that
810 # 1. does not interpret backslashes and
811 # 2. does not print an error message "broken pipe" when writing into a pipe
814 # Test cases for problem 1:
815 # echo '\n' | wc -l prints 1 when OK, 2 when KO
816 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
817 # Test cases for problem 2:
818 # echo hi | true frequently prints
819 # "bash: echo: write error: Broken pipe"
820 # to standard error in bash 3.2.
822 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
823 # BSD echo interprets '-n' as an option, which is also not desirable).
824 # Nowadays the problem occurs in 4 situations:
825 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
826 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
827 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
828 # - in zsh, when sh-emulation is not set,
829 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
830 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
831 # - in Solaris /bin/sh and OSF/1 /bin/sh.
832 # We try the following workarounds:
833 # - for all: respawn using $CONFIG_SHELL if that is set and works.
834 # - for bash >= 2.04: unset the shell option xpg_echo.
835 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
836 # - for bash < 2.0: define echo to a function that uses cat of a here document.
837 # - for zsh: turn sh-emulation on.
838 # - for ksh: alias echo to 'print -r'.
839 # - for ksh: alias echo to a function that uses cat of a here document.
840 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
841 # the ksh workaround.
842 # - otherwise: respawn using /bin/sh and rely on the workarounds.
843 # When respawning, we pass --no-reexec as first argument, so as to avoid
844 # turning this script into a fork bomb in unlucky situations.
846 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
847 # the 'printf' built-in. See
848 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
849 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
850 # The workaround is: define echo to a function that uses the printf built-in.
852 if echo '\t' |
grep t
> /dev
/null
; then
853 have_echo
=yes # Lucky!
855 # Try the workarounds.
856 # Respawn using $CONFIG_SHELL if that is set and works.
857 if test -z "$have_echo" \
858 && test "X$1" != "X--no-reexec" \
859 && test -n "$CONFIG_SHELL" \
860 && test -f "$CONFIG_SHELL" \
861 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
862 exec $CONFIG_SHELL "$0" --no-reexec "$@"
865 # For bash >= 2.04: unset the shell option xpg_echo.
866 if test -z "$have_echo" \
867 && test -n "$BASH_VERSION" \
868 && (shopt -o xpg_echo
; echo '\t' |
grep t
> /dev
/null
) 2>/dev
/null
; then
872 # For bash >= 2.0: define echo to a function that uses the printf built-in.
873 # For bash < 2.0: define echo to a function that uses cat of a here document.
874 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
875 # Also handle problem 2, specific to bash 3.2, here.
876 if { test -z "$have_echo" \
877 ||
case "$BASH_VERSION" in 3.2*) true
;; *) false
;; esac; \
879 && test -n "$BASH_VERSION"; then \
880 if type printf 2>/dev
/null |
grep / > /dev
/null
; then
881 # 'printf' is not a shell built-in.
889 # 'printf' is a shell built-in.
895 if echo '\t' |
grep t
> /dev
/null
; then
899 # For zsh: turn sh-emulation on.
900 if test -z "$have_echo" \
901 && test -n "$ZSH_VERSION" \
902 && (emulate sh
) >/dev
/null
2>&1; then
905 # For ksh: alias echo to 'print -r'.
906 if test -z "$have_echo" \
907 && (type print
) >/dev
/null
2>&1; then
908 # A 'print' command exists.
909 if type print
2>/dev
/null |
grep / > /dev
/null
; then
912 # 'print' is a shell built-in.
913 if (print
-r '\told' |
grep told
> /dev
/null
) 2>/dev
/null
; then
914 # 'print' is the ksh shell built-in.
915 alias echo='print -r'
919 if test -z "$have_echo" \
920 && echo '\t' |
grep t
> /dev
/null
; then
923 # For ksh: alias echo to a function that uses cat of a here document.
924 # The ksh manual page says:
925 # "Aliasing is performed when scripts are read, not while they are executed.
926 # Therefore, for an alias to take effect, the alias definition command has
927 # to be executed before the command which references the alias is read."
928 # Because of this, we have to play strange tricks with have_echo, to ensure
929 # that the top-level statement containing the test starts after the 'alias'
931 if test -z "$have_echo"; then
938 if (alias echo=bsd_echo
) 2>/dev
/null
; then
939 alias echo=bsd_echo
2>/dev
/null
942 if test -z "$have_echo" \
943 && echo '\t' |
grep t
> /dev
/null
; then
946 if test -z "$have_echo"; then
947 if (alias echo=bsd_echo
) 2>/dev
/null
; then
948 unalias echo 2>/dev
/null
951 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
952 if test -z "$have_echo" \
953 && test "X$1" != "X--no-reexec" \
954 && test -f /bin
/ksh
; then
955 exec /bin
/ksh
"$0" --no-reexec "$@"
958 # Otherwise: respawn using /bin/sh.
959 if test -z "$have_echo" \
960 && test "X$1" != "X--no-reexec" \
961 && test -f /bin
/sh
; then
962 exec /bin
/sh
"$0" --no-reexec "$@"
965 if test -z "$have_echo"; then
966 func_fatal_error
"Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
968 if echo '\t' |
grep t
> /dev
/null
; then
971 func_fatal_error
"Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
973 if test "X$1" = "X--no-reexec"; then
977 # Unset CDPATH. Otherwise, output from 'cd dir' can surprise callers.
978 (unset CDPATH
) >/dev
/null
2>&1 && unset CDPATH
980 # Determine the path separator early because the following option parsing code
982 func_determine_path_separator
984 # Command-line option processing.
985 # Removes the OPTIONS from the arguments. Sets the variables:
986 # - mode one of: list, find, import, add-import, remove-import,
987 # update, create-testdir, create-megatestdir, test, megatest,
989 # - destdir from --dir
990 # - local_gnulib_path from --local-dir
991 # - modcache true or false, from --cache-modules/--no-cache-modules
992 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
993 # - libname, supplied_libname from --lib
994 # - sourcebase from --source-base
995 # - m4base from --m4-base
996 # - pobase from --po-base
997 # - docbase from --doc-base
998 # - testsbase from --tests-base
999 # - auxdir from --aux-dir
1000 # - inctests true if --with-tests was given, false if --without-tests
1001 # was given, blank otherwise
1002 # - incobsolete true if --with-obsolete was given, blank otherwise
1003 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
1004 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
1006 # - inc_privileged_tests true if --with-privileged-tests was given, blank
1008 # - inc_unportable_tests true if --with-unportable-tests was given, blank
1010 # - inc_all_tests true if --with-all-tests was given, blank otherwise
1011 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
1012 # - excl_longrunning_tests true if --without-longrunning-tests was given,
1014 # - excl_privileged_tests true if --without-privileged-tests was given, blank
1016 # - excl_unportable_tests true if --without-unportable-tests was given, blank
1018 # - single_configure true if --single-configure was given, false otherwise
1019 # - avoidlist list of modules to avoid, from --avoid
1020 # - cond_dependencies true if --conditional-dependencies was given, false if
1021 # --no-conditional-dependencies was given, blank otherwise
1022 # - lgpl yes or a number if --lgpl was given, blank otherwise
1023 # - makefile_name from --makefile-name
1024 # - libtool true if --libtool was given, false if --no-libtool was
1025 # given, blank otherwise
1026 # - macro_prefix from --macro-prefix
1027 # - po_domain from --po-domain
1028 # - witness_c_macro from --witness-c-macro
1029 # - vc_files true if --vc-files was given, false if --no-vc-files was
1030 # given, blank otherwise
1031 # - autoconf_minversion minimum supported autoconf version
1032 # - doit : if actions shall be executed, false if only to be printed
1033 # - symbolic true if --symlink or --more-symlinks was given, blank
1035 # - lsymbolic true if --local-symlink was given, blank otherwise
1036 # - do_copyrights blank if --more-symlinks was given, true otherwise
1054 inc_longrunning_tests
=
1055 inc_privileged_tests
=
1056 inc_unportable_tests
=
1059 excl_longrunning_tests
=
1060 excl_privileged_tests
=
1061 excl_unportable_tests
=
1062 single_configure
=false
1079 while test $# -gt 0; do
1084 --find |
--fin |
--fi |
--f )
1087 --import |
--impor |
--impo |
--imp |
--im |
--i )
1090 --add-import |
--add-impor |
--add-impo |
--add-imp |
--add-im |
--add-i |
--add- |
--add |
--ad )
1093 --remove-import |
--remove-impor |
--remove-impo |
--remove-imp |
--remove-im |
--remove-i |
--remove- |
--remove |
--remov |
--remo |
--rem |
--re |
--r )
1096 --update |
--updat |
--upda |
--upd |
--up |
--u )
1099 --create-testdir |
--create-testdi |
--create-testd |
--create-test |
--create-tes |
--create-te |
--create-t )
1102 --create-megatestdir |
--create-megatestdi |
--create-megatestd |
--create-megatest |
--create-megates |
--create-megate |
--create-megat |
--create-mega |
--create-meg |
--create-me |
--create-m )
1103 mode
=create-megatestdir
1105 --test |
--tes |
--te |
--t )
1108 --megatest |
--megates |
--megate |
--megat |
--mega |
--meg |
--me |
--m )
1112 mode
=`echo "X$1" | sed -e 's/^X--//'`
1114 --copy-file |
--copy-fil |
--copy-fi |
--copy-f |
--copy- |
--copy |
--cop )
1119 if test $# = 0; then
1120 func_fatal_error
"missing argument for --dir"
1125 destdir
=`echo "X$1" | sed -e 's/^X--dir=//'`
1129 if test $# = 0; then
1130 func_fatal_error
"missing argument for --local-dir"
1132 func_path_prepend local_gnulib_path
"$1"
1135 local_dir
=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1136 func_path_prepend local_gnulib_path
"$local_dir"
1138 --cache-modules |
--cache-module |
--cache-modul |
--cache-modu |
--cache-mod |
--cache-mo |
--cache-m |
--cache- |
--cache |
--cach |
--cac |
--ca )
1141 --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 )
1144 --verbose |
--verbos |
--verbo |
--verb )
1145 verbose
=`expr $verbose + 1`
1147 --quiet |
--quie |
--qui |
--qu |
--q )
1148 verbose
=`expr $verbose - 1`
1152 if test $# = 0; then
1153 func_fatal_error
"missing argument for --lib"
1156 supplied_libname
=true
1159 libname
=`echo "X$1" | sed -e 's/^X--lib=//'`
1160 supplied_libname
=true
1164 if test $# = 0; then
1165 func_fatal_error
"missing argument for --source-base"
1170 sourcebase
=`echo "X$1" | sed -e 's/^X--source-base=//'`
1174 if test $# = 0; then
1175 func_fatal_error
"missing argument for --m4-base"
1180 m4base
=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1184 if test $# = 0; then
1185 func_fatal_error
"missing argument for --po-base"
1190 pobase
=`echo "X$1" | sed -e 's/^X--po-base=//'`
1194 if test $# = 0; then
1195 func_fatal_error
"missing argument for --doc-base"
1200 docbase
=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1204 if test $# = 0; then
1205 func_fatal_error
"missing argument for --tests-base"
1210 testsbase
=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1214 if test $# = 0; then
1215 func_fatal_error
"missing argument for --aux-dir"
1220 auxdir
=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1222 --with-tests |
--with-test |
--with-tes |
--with-te |
--with-t)
1225 --with-obsolete |
--with-obsolet |
--with-obsole |
--with-obsol |
--with-obso |
--with-obs |
--with-ob |
--with-o)
1228 --with-c++-tests |
--with-c++-test |
--with-c++-tes |
--with-c++-te |
--with-c++-t |
--with-c++- |
--with-c++ |
--with-c+ |
--with-c)
1231 --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)
1232 inc_longrunning_tests
=true
1234 --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)
1235 inc_privileged_tests
=true
1237 --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)
1238 inc_unportable_tests
=true
1240 --with-all-tests |
--with-all-test |
--with-all-tes |
--with-all-te |
--with-all-t |
--with-all- |
--with-all |
--with-al |
--with-a)
1243 --without-tests |
--without-test |
--without-tes |
--without-te |
--without-t)
1246 --without-c++-tests |
--without-c++-test |
--without-c++-tes |
--without-c++-te |
--without-c++-t |
--without-c++- |
--without-c++ |
--without-c+ |
--without-c)
1249 --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)
1250 excl_longrunning_tests
=true
1252 --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)
1253 excl_privileged_tests
=true
1255 --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)
1256 excl_unportable_tests
=true
1258 --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)
1259 single_configure
=true
1263 if test $# = 0; then
1264 func_fatal_error
"missing argument for --avoid"
1266 func_append avoidlist
" $1"
1269 arg
=`echo "X$1" | sed -e 's/^X--avoid=//'`
1270 func_append avoidlist
" $arg"
1272 --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)
1273 cond_dependencies
=true
1275 --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)
1276 cond_dependencies
=false
1282 arg
=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1285 *) func_fatal_error
"invalid LGPL version number for --lgpl" ;;
1291 if test $# = 0; then
1292 func_fatal_error
"missing argument for --makefile-name"
1297 makefile_name
=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1307 if test $# = 0; then
1308 func_fatal_error
"missing argument for --macro-prefix"
1313 macro_prefix
=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1317 if test $# = 0; then
1318 func_fatal_error
"missing argument for --po-domain"
1323 po_domain
=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1327 if test $# = 0; then
1328 func_fatal_error
"missing argument for --witness-c-macro"
1330 witness_c_macro
="$1"
1332 --witness-c-macro=* )
1333 witness_c_macro
=`echo "X$1" | sed -e 's/^X--witness-c-macro=//'`
1341 --no-changelog |
--no-changelo |
--no-changel |
--no-change |
--no-chang |
--no-chan |
--no-cha |
--no-ch )
1342 # A no-op for backward compatibility.
1347 -s |
--symbolic |
--symboli |
--symbol |
--symbo |
--symb |
--symlink |
--symlin |
--symli |
--syml |
--sym |
--sy )
1350 --local-symlink |
--local-symlin |
--local-symli |
--local-syml |
--local-sym |
--local-sy |
--local-s )
1353 -S |
--more-symlinks |
--more-symlink |
--more-symlin |
--more-symli |
--more-syml |
--more-sym |
--more-sy |
--more-s |
--more- |
--more |
--mor |
--mo )
1357 --help |
--hel |
--he |
--h )
1360 --version |
--versio |
--versi |
--vers )
1364 # Stop option processing
1368 echo "gnulib-tool: unknown option $1" 1>&2
1369 echo "Try 'gnulib-tool --help' for more information." 1>&2
1376 if case "$mode" in import | add-import | remove-import
) true
;; *) false
;; esac; then
1377 if test -n "$excl_cxx_tests" ||
test -n "$excl_longrunning_tests" \
1378 ||
test -n "$excl_privileged_tests" ||
test -n "$excl_unportable_tests" \
1379 ||
test "$single_configure" != false
; then
1380 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1381 echo "Try 'gnulib-tool --help' for more information." 1>&2
1385 if test "$mode" = update
; then
1386 if test $# != 0; then
1387 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1388 echo "Try 'gnulib-tool --help' for more information." 1>&2
1389 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1390 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1393 if test -n "$local_gnulib_path" ||
test -n "$supplied_libname" \
1394 ||
test -n "$sourcebase" ||
test -n "$m4base" ||
test -n "$pobase" \
1395 ||
test -n "$docbase" ||
test -n "$testsbase" ||
test -n "$auxdir" \
1396 ||
test -n "$inctests" ||
test -n "$incobsolete" \
1397 ||
test -n "$inc_cxx_tests" ||
test -n "$inc_longrunning_tests" \
1398 ||
test -n "$inc_privileged_tests" ||
test -n "$inc_unportable_tests" \
1399 ||
test -n "$inc_all_tests" \
1400 ||
test -n "$excl_cxx_tests" ||
test -n "$excl_longrunning_tests" \
1401 ||
test -n "$excl_privileged_tests" ||
test -n "$excl_unportable_tests" \
1402 ||
test -n "$avoidlist" ||
test -n "$lgpl" ||
test -n "$makefile_name" \
1403 ||
test -n "$macro_prefix" ||
test -n "$po_domain" \
1404 ||
test -n "$witness_c_macro" ||
test -n "$vc_files"; then
1405 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1406 echo "Try 'gnulib-tool --help' for more information." 1>&2
1407 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1408 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1412 if test -n "$pobase" && test -z "$po_domain"; then
1413 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1414 echo "Try 'gnulib-tool --help' for more information." 1>&2
1417 if test -z "$pobase" && test -n "$po_domain"; then
1418 func_warning
"--po-domain has no effect without a --po-base option"
1420 # Canonicalize the inctests variable.
1422 import | add-import | remove-import | update
)
1423 if test -z "$inctests"; then
1427 create-testdir | create-megatestdir |
test | megatest
)
1428 if test -z "$inctests"; then
1433 # Now the only possible values of "$inctests" are true and false
1434 # (or blank but then it is irrelevant).
1435 if test "$cond_dependencies" = true
&& test "$inctests" = true
; then
1436 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
1440 # Determine the minimum supported autoconf version from the project's
1442 DEFAULT_AUTOCONF_MINVERSION
="2.59"
1443 autoconf_minversion
=
1445 if case "$mode" in import | add-import | remove-import | update
) true
;; *) false
;; esac \
1446 && test -n "$destdir"; then
1447 if test -f "$destdir"/configure.ac
; then
1448 configure_ac
="$destdir/configure.ac"
1450 if test -f "$destdir"/configure.
in; then
1451 configure_ac
="$destdir/configure.in"
1455 if test -f configure.ac
; then
1456 configure_ac
="configure.ac"
1458 if test -f configure.
in; then
1459 configure_ac
="configure.in"
1463 if test -n "$configure_ac"; then
1464 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1465 # because when some m4 files are omitted from a version control repository,
1466 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1467 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1468 # autom4te: m4 failed with exit status: 1
1475 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1477 prereqs
=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1478 if test -n "$prereqs"; then
1479 autoconf_minversion
=`
1480 for version in $prereqs; do echo $version; done |
1481 LC_ALL=C sort -nru | sed -e 1q
1485 if test -z "$autoconf_minversion"; then
1486 autoconf_minversion
=$DEFAULT_AUTOCONF_MINVERSION
1488 case "$autoconf_minversion" in
1489 1.
* |
2.
[0-4]* |
2.5[0-8]*)
1490 func_fatal_error
"minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1493 # Remove trailing slashes from the directory names. This is necessary for
1494 # m4base (to avoid an error in func_import) and optional for the others.
1495 sed_trimtrailingslashes
='s,\([^/]\)//*$,\1,'
1496 old_local_gnulib_path
=$local_gnulib_path
1500 for dir
in $old_local_gnulib_path
1503 */ ) dir
=`echo "$dir" | sed -e "$sed_trimtrailingslashes"` ;;
1505 func_path_append local_gnulib_path
"$dir"
1508 case "$sourcebase" in
1509 */ ) sourcebase
=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1512 */ ) m4base
=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1515 */ ) pobase
=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1518 */ ) docbase
=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1520 case "$testsbase" in
1521 */ ) testsbase
=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1524 */ ) auxdir
=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1530 trap 'exit_status=$?
1531 if test "$signal" != 0; then
1532 echo "caught signal $signal" >&2
1535 exit $exit_status' 0
1536 for signal
in 1 2 3 13 15; do
1537 trap '{ signal='$signal'; func_exit 1; }' $signal
1541 # Note: The 'eval' silences stderr output in dash.
1542 if (declare -A x
&& { x
[f
/2]='foo'; x
[f
/3]='bar'; eval test '${x[f/2]}' = foo
; }) 2>/dev
/null
; then
1543 # Zsh 4 and Bash 4 have associative arrays.
1544 have_associative
=true
1546 # For other shells, use 'eval' with computed shell variable names.
1547 have_associative
=false
1550 # func_lookup_local_file_cb dir file
1551 # return true and set func_lookup_local_file_result if the file 'dir/file'
1553 func_lookup_local_file_cb
()
1555 test -n "$func_lookup_local_file_result" && return 1 # already found?
1556 test -f "$1/$2" ||
return 1
1557 func_lookup_local_file_result
=$1/$2
1561 # func_lookup_local_file file
1562 # looks up a file in $local_gnulib_path.
1564 # - local_gnulib_path from --local-dir
1566 # - func_lookup_local_file_result name of the file, valid only when the
1567 # function succeeded.
1568 func_lookup_local_file
()
1570 func_lookup_local_file_result
=
1571 func_path_foreach
"$local_gnulib_path" func_lookup_local_file_cb
%dir
% "$1"
1574 # func_lookup_file file
1575 # looks up a file in $local_gnulib_path or $gnulib_dir, or combines it through
1578 # - local_gnulib_path from --local-dir
1580 # - lookedup_file name of the merged (combined) file
1581 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1585 if func_lookup_local_file
"$lkfile"; then
1586 lookedup_file
=$func_lookup_local_file_result
1589 if test -f "$gnulib_dir/$lkfile"; then
1590 if func_lookup_local_file
"$lkfile.diff"; then
1591 lkbase
=`echo "$lkfile" | sed -e 's,^.*/,,'`
1592 rm -f "$tmp/$lkbase"
1593 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1594 patch -s "$tmp/$lkbase" < "$func_lookup_local_file_result" >&2 \
1595 || func_fatal_error
"patch file $func_lookup_local_file_result didn't apply cleanly"
1596 lookedup_file
="$tmp/$lkbase"
1599 lookedup_file
="$gnulib_dir/$lkfile"
1603 func_fatal_error
"file $gnulib_dir/$lkfile not found"
1608 # func_sanitize_modulelist
1609 # receives a list of possible module names on standard input, one per line.
1610 # It removes those which are just file names unrelated to modules, and outputs
1611 # the resulting list to standard output, one per line.
1612 func_sanitize_modulelist
()
1614 sed -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1615 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1616 -e '/^README$/d' -e '/\/README$/d' \
1617 -e '/^TEMPLATE$/d' \
1618 -e '/^TEMPLATE-EXTENDED$/d' \
1619 -e '/^TEMPLATE-TESTS$/d' \
1625 # func_modules_in_dir dir
1626 # outputs all module files in dir to standard output.
1627 func_modules_in_dir
()
1629 (test -d "$1" && cd "$1" && find modules
-type f
-print)
1634 # - local_gnulib_path from --local-dir
1637 # Filter out metainformation files like README, which are not modules.
1638 # Filter out unit test modules; they can be retrieved through
1639 # --extract-tests-module if desired.
1641 (cd "$gnulib_dir" && find modules
-type f
-print |
sed -e 's,^modules/,,')
1642 func_path_foreach
"$local_gnulib_path" func_modules_in_dir
%dir
% |
sed -e 's,^modules/,,' -e 's,\.diff$,,'
1644 | func_sanitize_modulelist \
1645 |
sed -e '/-tests$/d' \
1649 # func_exists_local_module dir module
1650 # returns true if module exists in dir
1651 func_exists_local_module
()
1653 test -d "$1/modules" && test -f "$1/modules/$2";
1656 # func_exists_module module
1657 # tests whether a module, given by name, exists
1659 # - local_gnulib_path from --local-dir
1660 func_exists_module
()
1662 { test -f "$gnulib_dir/modules/$1" \
1663 || func_path_foreach
"$local_gnulib_path" func_exists_local_module
%dir
% "$1" ; } \
1664 && test "ChangeLog" != "$1" \
1665 && test "COPYING" != "$1" \
1666 && test "README" != "$1" \
1667 && test "TEMPLATE" != "$1" \
1668 && test "TEMPLATE-EXTENDED" != "$1" \
1669 && test "TEMPLATE-TESTS" != "$1"
1672 # func_verify_module
1673 # verifies a module name
1675 # - local_gnulib_path from --local-dir
1676 # - module module name argument
1677 func_verify_module
()
1679 if func_exists_module
"$module"; then
1680 # OK, $module is a correct module name.
1681 # Verify that building the module description with 'patch' succeeds.
1682 func_lookup_file
"modules/$module"
1684 func_warning
"module $module doesn't exist"
1689 # func_verify_nontests_module
1690 # verifies a module name, excluding tests modules
1692 # - local_gnulib_path from --local-dir
1693 # - module module name argument
1694 func_verify_nontests_module
()
1697 *-tests ) module
= ;;
1698 * ) func_verify_module
;;
1702 # func_verify_tests_module
1703 # verifies a module name, considering only tests modules
1705 # - local_gnulib_path from --local-dir
1706 # - module module name argument
1707 func_verify_tests_module
()
1710 *-tests ) func_verify_module
;;
1715 # Suffix of a sed expression that extracts a particular field from a
1716 # module description.
1717 # A field starts with a line that contains a keyword, such as 'Description',
1718 # followed by a colon and optional whitespace. All following lines, up to
1719 # the next field (or end of file if there is none) form the contents of the
1721 # An absent field is equivalent to a field with empty contents.
1722 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1723 sed_extract_prog
=':[ ]*$/ {
1726 s/^Description:[ ]*$//
1730 s/^Applicability:[ ]*$//
1732 s/^Depends-on:[ ]*$//
1733 s/^configure\.ac-early:[ ]*$//
1734 s/^configure\.ac:[ ]*$//
1735 s/^Makefile\.am:[ ]*$//
1739 s/^Maintainer:[ ]*$//
1746 # Piece of a sed expression that converts a field header line to a shell
1748 # NOTE: Keep this in sync with sed_extract_prog above!
1749 sed_extract_field_header
='
1750 s/^Description:[ ]*$/description/
1751 s/^Comment:[ ]*$/comment/
1752 s/^Status:[ ]*$/status/
1753 s/^Notice:[ ]*$/notice/
1754 s/^Applicability:[ ]*$/applicability/
1755 s/^Files:[ ]*$/files/
1756 s/^Depends-on:[ ]*$/dependson/
1757 s/^configure\.ac-early:[ ]*$/configureac_early/
1758 s/^configure\.ac:[ ]*$/configureac/
1759 s/^Makefile\.am:[ ]*$/makefile/
1760 s/^Include:[ ]*$/include/
1762 s/^License:[ ]*$/license/
1763 s/^Maintainer:[ ]*$/maintainer/'
1767 if $have_associative; then
1769 # Declare the associative arrays.
1770 declare -A modcache_cached
1771 sed_to_declare_statement
='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1772 declare_script
=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1773 eval "$declare_script"
1777 # func_cache_var module
1778 # computes the cache variable name corresponding to $module.
1779 # Note: This computation can map different module names to the same
1780 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1781 # to protect against this case.
1783 # - cachevar a shell variable name
1784 if (f
=foo
; eval echo '${f//o/e}') < /dev
/null
2>/dev
/null |
grep fee
>/dev
/null
; then
1785 # Bash 2.0 and newer, ksh, and zsh support the syntax
1786 # ${param//pattern/replacement}
1787 # as a shorthand for
1788 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1789 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1790 eval 'func_cache_var ()
1792 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1799 cachevar
=c_
`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1808 # func_init_sed_convert_to_cache_statements
1810 # - modcachevar_assignment
1812 # - sed_convert_to_cache_statements
1813 func_init_sed_convert_to_cache_statements
()
1815 # 'sed' script that turns a module description into shell script
1816 # assignments, suitable to be eval'ed. All active characters are escaped.
1819 # Some module's description
1824 # modcache_description[$1]=\
1825 # 'Some module'"'"'s description
1827 # modcache_files[$1]=\
1830 # c_MODULE_description_set=set; c_MODULE_description=\
1831 # 'Some module'"'"'s description
1833 # c_MODULE_files_set=set; c_MODULE_files=\
1835 # The script consists of two parts:
1836 # 1) Ignore the lines before the first field header.
1837 # 2) A loop, treating non-field-header lines by escaping single quotes
1838 # and adding a closing quote in the last line,
1839 sed_convert_to_cache_statements
="
1841 # Here we have not yet seen a field header.
1843 # See if the current line contains a field header.
1846 ${sed_extract_field_header}
1849 # No field header. Ignore the line.
1851 # Read the next line. Upon EOF, just exit.
1856 # The current line contains a field header.
1858 # Turn it into the beginning of an assignment.
1859 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1861 # Move it to the hold space. Don't print it yet,
1862 # because we want no assignment if the field is empty.
1865 # Read the next line.
1866 # Upon EOF, the field was empty. Print no assignment. Just exit.
1869 # See if the current line contains a field header.
1872 ${sed_extract_field_header}
1873 # If it is, the previous field was empty. Print no assignment.
1876 # Not a field header.
1878 # Print the previous line, held in the hold space.
1883 # Transform single quotes.
1886 # Prepend a single quote.
1891 # Move it to the hold space.
1894 # Read the next line.
1901 # See if the current line contains a field header.
1904 ${sed_extract_field_header}
1907 # Print the previous line, held in the hold space.
1912 # Transform single quotes.
1919 # Print the previous line, held in the hold space, with a single quote
1920 # to end the assignment.
1930 # Print the previous line, held in the hold space, with a single quote
1931 # to end the assignment.
1938 if ! $sed_comments; then
1940 sed_convert_to_cache_statements
=`echo "$sed_convert_to_cache_statements" \
1941 | sed -e 's/^ *//' -e 's/^#.*//'`
1945 if $have_associative; then
1946 # sed_convert_to_cache_statements does not depend on the module.
1947 modcachevar_assignment
='modcache_\1[$1]='
1948 func_init_sed_convert_to_cache_statements
1951 # func_cache_lookup_module module
1953 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1954 # of its relevant data in a cache in the memory of the processing shell. If
1955 # already cached, it does not look it up again, thus saving file access time.
1957 # - module non-empty string
1958 # Output if $have_associative:
1959 # - modcache_cached[$module] set to yes
1960 # - modcache_description[$module] ==
1961 # - modcache_status[$module] \ set to the field's value, minus the
1962 # - ... / final newline,
1963 # - modcache_maintainer[$module] == or unset if the field's value is empty
1964 # Output if ! $have_associative:
1965 # - cachevar a shell variable name
1966 # - ${cachevar}_cached set to $module
1967 # - ${cachevar}_description ==
1968 # - ${cachevar}_status \ set to the field's value, minus the
1969 # - ... / final newline,
1970 # - ${cachevar}_maintainer == or unset if the field's value is empty
1971 # - ${cachevar}_description_set ==
1972 # - ${cachevar}_status_set \ set to non-empty if the field's value
1973 # - ... / is non-empty,
1974 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1975 func_cache_lookup_module
()
1977 if $have_associative; then
1978 eval 'cached=${modcache_cached[$1]}'
1981 eval "cached=\"\$${cachevar}_cached\""
1983 if test -z "$cached"; then
1984 # Not found in cache. Look it up on the file system.
1985 func_lookup_file
"modules/$1"
1986 if $have_associative; then
1987 eval 'modcache_cached[$1]=yes'
1989 eval "${cachevar}_cached=\"\$1\""
1991 if ! $have_associative; then
1992 # sed_convert_to_cache_statements depends on the module.
1993 modcachevar_assignment
="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1994 func_init_sed_convert_to_cache_statements
1996 cache_statements
=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1997 eval "$cache_statements"
1999 if ! $have_associative; then
2000 if test "$1" != "$cached"; then
2001 func_fatal_error
"cache variable collision between $1 and $cached"
2009 # func_get_description module
2011 # - local_gnulib_path from --local-dir
2012 # - modcache true or false, from --cache-modules/--no-cache-modules
2013 func_get_description
()
2015 if ! $modcache; then
2016 func_lookup_file
"modules/$1"
2017 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
2019 func_cache_lookup_module
"$1"
2020 # Output the field's value, including the final newline (if any).
2021 if $have_associative; then
2022 if eval 'test -n "${modcache_description[$1]+set}"'; then
2023 eval 'echo "${modcache_description[$1]}"'
2026 eval "field_set=\"\$${cachevar}_description_set\""
2027 if test -n "$field_set"; then
2028 eval "field_value=\"\$${cachevar}_description\""
2029 echo "${field_value}"
2035 # func_get_comment module
2037 # - local_gnulib_path from --local-dir
2038 # - modcache true or false, from --cache-modules/--no-cache-modules
2041 if ! $modcache; then
2042 func_lookup_file
"modules/$1"
2043 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
2045 func_cache_lookup_module
"$1"
2046 # Output the field's value, including the final newline (if any).
2047 if $have_associative; then
2048 if eval 'test -n "${modcache_comment[$1]+set}"'; then
2049 eval 'echo "${modcache_comment[$1]}"'
2052 eval "field_set=\"\$${cachevar}_comment_set\""
2053 if test -n "$field_set"; then
2054 eval "field_value=\"\$${cachevar}_comment\""
2055 echo "${field_value}"
2061 # func_get_status module
2063 # - local_gnulib_path from --local-dir
2064 # - modcache true or false, from --cache-modules/--no-cache-modules
2067 if ! $modcache; then
2068 func_lookup_file
"modules/$1"
2069 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
2071 func_cache_lookup_module
"$1"
2072 # Output the field's value, including the final newline (if any).
2073 if $have_associative; then
2074 if eval 'test -n "${modcache_status[$1]+set}"'; then
2075 eval 'echo "${modcache_status[$1]}"'
2078 eval "field_set=\"\$${cachevar}_status_set\""
2079 if test -n "$field_set"; then
2080 eval "field_value=\"\$${cachevar}_status\""
2081 echo "${field_value}"
2087 # func_get_notice module
2089 # - local_gnulib_path from --local-dir
2090 # - modcache true or false, from --cache-modules/--no-cache-modules
2093 if ! $modcache; then
2094 func_lookup_file
"modules/$1"
2095 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
2097 func_cache_lookup_module
"$1"
2098 # Output the field's value, including the final newline (if any).
2099 if $have_associative; then
2100 if eval 'test -n "${modcache_notice[$1]+set}"'; then
2101 eval 'echo "${modcache_notice[$1]}"'
2104 eval "field_set=\"\$${cachevar}_notice_set\""
2105 if test -n "$field_set"; then
2106 eval "field_value=\"\$${cachevar}_notice\""
2107 echo "${field_value}"
2113 # func_get_applicability module
2115 # - local_gnulib_path from --local-dir
2116 # - modcache true or false, from --cache-modules/--no-cache-modules
2117 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
2118 func_get_applicability
()
2120 if ! $modcache; then
2121 func_lookup_file
"modules/$1"
2122 my_applicability
=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
2124 func_cache_lookup_module
"$1"
2125 # Get the field's value, without the final newline.
2126 if $have_associative; then
2127 eval 'my_applicability="${modcache_applicability[$1]}"'
2129 eval "my_applicability=\"\$${cachevar}_applicability\""
2132 if test -n "$my_applicability"; then
2133 echo $my_applicability
2135 # The default is 'main' or 'tests', depending on the module's name.
2137 *-tests) echo "tests";;
2143 # func_get_filelist module
2145 # - local_gnulib_path from --local-dir
2146 # - modcache true or false, from --cache-modules/--no-cache-modules
2147 func_get_filelist
()
2149 if ! $modcache; then
2150 func_lookup_file
"modules/$1"
2151 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
2153 func_cache_lookup_module
"$1"
2154 # Output the field's value, including the final newline (if any).
2155 if $have_associative; then
2156 if eval 'test -n "${modcache_files[$1]+set}"'; then
2157 eval 'echo "${modcache_files[$1]}"'
2160 eval "field_set=\"\$${cachevar}_files_set\""
2161 if test -n "$field_set"; then
2162 eval "field_value=\"\$${cachevar}_files\""
2163 echo "${field_value}"
2168 echo m
4/gnulib-common.
m4
2169 case "$autoconf_minversion" in
2176 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2177 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2178 # elements starting with prefix and ending with suffix are considered.
2179 # Processing: removed_prefix and removed_suffix are removed from each element,
2180 # added_prefix and added_suffix are added to each element.
2181 # prefix, suffix should not contain shell-special characters.
2182 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2183 # added_prefix, added_suffix should not contain the characters \|&.
2184 func_filter_filelist
()
2186 if test "$2" != "$nl" \
2187 ||
{ $fast_func_append \
2188 && { test -z "$6" ||
$fast_func_remove_prefix; } \
2189 && { test -z "$7" ||
$fast_func_remove_suffix; }; \
2193 # Do not quote possibly-empty parameters in case patterns,
2194 # AIX and HP-UX ksh won't match them if they are empty.
2197 if test -n "$6"; then
2198 func_remove_prefix fff
"$6"
2200 if test -n "$7"; then
2201 func_remove_suffix fff
"$7"
2204 if test -z "$ffflist"; then
2207 func_append ffflist
"$2${fff}"
2213 sed_fff_filter
="s|^$6\(.*\)$7\$|$8\\1$9|"
2214 ffflist
=`for fff in $3; do
2216 $4*$5) echo "$fff" ;;
2218 done | sed -e "$sed_fff_filter"`
2220 eval "$1=\"\$ffflist\""
2223 # func_get_dependencies module
2225 # - local_gnulib_path from --local-dir
2226 # - modcache true or false, from --cache-modules/--no-cache-modules
2227 func_get_dependencies
()
2229 # ${module}-tests implicitly depends on ${module}, if that module exists.
2233 func_remove_suffix fgd1
'-tests'
2234 if func_exists_module
"$fgd1"; then
2239 # Then the explicit dependencies listed in the module description.
2240 { if ! $modcache; then
2241 func_lookup_file
"modules/$1"
2242 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2244 func_cache_lookup_module
"$1"
2245 # Output the field's value, including the final newline (if any).
2246 if $have_associative; then
2247 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2248 eval 'echo "${modcache_dependson[$1]}"'
2251 eval "field_set=\"\$${cachevar}_dependson_set\""
2252 if test -n "$field_set"; then
2253 eval "field_value=\"\$${cachevar}_dependson\""
2254 echo "${field_value}"
2262 # func_get_autoconf_early_snippet module
2264 # - local_gnulib_path from --local-dir
2265 # - modcache true or false, from --cache-modules/--no-cache-modules
2266 func_get_autoconf_early_snippet
()
2268 if ! $modcache; then
2269 func_lookup_file
"modules/$1"
2270 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2272 func_cache_lookup_module
"$1"
2273 # Output the field's value, including the final newline (if any).
2274 if $have_associative; then
2275 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2276 eval 'echo "${modcache_configureac_early[$1]}"'
2279 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2280 if test -n "$field_set"; then
2281 eval "field_value=\"\$${cachevar}_configureac_early\""
2282 echo "${field_value}"
2288 # func_get_autoconf_snippet module
2290 # - local_gnulib_path from --local-dir
2291 # - modcache true or false, from --cache-modules/--no-cache-modules
2292 func_get_autoconf_snippet
()
2294 if ! $modcache; then
2295 func_lookup_file
"modules/$1"
2296 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2298 func_cache_lookup_module
"$1"
2299 # Output the field's value, including the final newline (if any).
2300 if $have_associative; then
2301 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2302 eval 'echo "${modcache_configureac[$1]}"'
2305 eval "field_set=\"\$${cachevar}_configureac_set\""
2306 if test -n "$field_set"; then
2307 eval "field_value=\"\$${cachevar}_configureac\""
2308 echo "${field_value}"
2314 # Concatenate lines with trailing slash.
2315 # $1 is an optional filter to restrict the
2316 # concatenation to groups starting with that expression
2318 sed -e "/$1.*"'\\$/{
2327 # func_get_automake_snippet_conditional module
2328 # returns the part of the Makefile.am snippet that can be put inside Automake
2331 # - local_gnulib_path from --local-dir
2332 # - modcache true or false, from --cache-modules/--no-cache-modules
2333 func_get_automake_snippet_conditional
()
2335 if ! $modcache; then
2336 func_lookup_file
"modules/$1"
2337 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2339 func_cache_lookup_module
"$1"
2340 # Output the field's value, including the final newline (if any).
2341 if $have_associative; then
2342 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2343 eval 'echo "${modcache_makefile[$1]}"'
2346 eval "field_set=\"\$${cachevar}_makefile_set\""
2347 if test -n "$field_set"; then
2348 eval "field_value=\"\$${cachevar}_makefile\""
2349 echo "${field_value}"
2355 # func_get_automake_snippet_unconditional module
2356 # returns the part of the Makefile.am snippet that must stay outside of
2357 # Automake conditionals.
2359 # - local_gnulib_path from --local-dir
2360 # - modcache true or false, from --cache-modules/--no-cache-modules
2361 func_get_automake_snippet_unconditional
()
2365 # *-tests module live in tests/, not lib/.
2366 # Synthesize an EXTRA_DIST augmentation.
2367 all_files
=`func_get_filelist $1`
2368 func_filter_filelist tests_files
" " "$all_files" 'tests/' '' 'tests/' ''
2369 extra_files
="$tests_files"
2370 if test -n "$extra_files"; then
2371 echo "EXTRA_DIST +=" $extra_files
2376 # Synthesize an EXTRA_DIST augmentation.
2377 sed_extract_mentioned_files
='s/^lib_SOURCES[ ]*+=[ ]*//p'
2378 already_mentioned_files
=` \
2379 { if ! $modcache; then
2380 func_lookup_file "modules/$1"
2381 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2383 func_cache_lookup_module "$1"
2384 if $have_associative; then
2385 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2386 eval 'echo "${modcache_makefile[$1]}"'
2389 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2390 if test -n "$field_set"; then
2391 eval 'field_value="$'"${cachevar}"'_makefile"'
2392 echo "${field_value}"
2398 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2399 all_files
=`func_get_filelist $1`
2400 func_filter_filelist lib_files
"$nl" "$all_files" 'lib/' '' 'lib/' ''
2401 # Remove $already_mentioned_files from $lib_files.
2402 echo "$lib_files" | LC_ALL
=C
sort -u > "$tmp"/lib-files
2403 extra_files
=`for f in $already_mentioned_files; do echo $f; done \
2404 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2405 if test -n "$extra_files"; then
2406 echo "EXTRA_DIST +=" $extra_files
2409 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2410 # This is necessary so that automake can generate the right list of
2412 # A possible approach would be to use autom4te --trace of the redefined
2413 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2414 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2415 # inside autoconf's built-in macros are not missed).
2416 # But it's simpler and more robust to do it here, based on the file list.
2417 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2418 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2419 # automake will generate a useless dependency; this is harmless.
2421 relocatable-prog-wrapper
) ;;
2424 func_filter_filelist extra_files
"$nl" "$extra_files" '' '.c' '' ''
2425 if test -n "$extra_files"; then
2426 echo "EXTRA_lib_SOURCES +=" $extra_files
2431 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2432 func_filter_filelist buildaux_files
"$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2433 if test -n "$buildaux_files"; then
2434 sed_prepend_auxdir
='s,^,$(top_srcdir)/'"$auxdir"'/,'
2435 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2438 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2439 func_filter_filelist top_files
"$nl" "$all_files" 'top/' '' 'top/' ''
2440 if test -n "$top_files"; then
2441 sed_prepend_topdir
='s,^,$(top_srcdir)/,'
2442 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2449 # func_get_automake_snippet module
2451 # - local_gnulib_path from --local-dir
2452 # - modcache true or false, from --cache-modules/--no-cache-modules
2453 func_get_automake_snippet
()
2455 func_get_automake_snippet_conditional
"$1"
2456 func_get_automake_snippet_unconditional
"$1"
2459 # func_get_include_directive module
2461 # - local_gnulib_path from --local-dir
2462 # - modcache true or false, from --cache-modules/--no-cache-modules
2463 func_get_include_directive
()
2466 if ! $modcache; then
2467 func_lookup_file
"modules/$1"
2468 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2470 func_cache_lookup_module
"$1"
2471 # Output the field's value, including the final newline (if any).
2472 if $have_associative; then
2473 if eval 'test -n "${modcache_include[$1]+set}"'; then
2474 eval 'echo "${modcache_include[$1]}"'
2477 eval "field_set=\"\$${cachevar}_include_set\""
2478 if test -n "$field_set"; then
2479 eval "field_value=\"\$${cachevar}_include\""
2480 echo "${field_value}"
2484 } |
sed -e 's/^\(["<]\)/#include \1/'
2487 # func_get_link_directive module
2489 # - local_gnulib_path from --local-dir
2490 # - modcache true or false, from --cache-modules/--no-cache-modules
2491 func_get_link_directive
()
2493 if ! $modcache; then
2494 func_lookup_file
"modules/$1"
2495 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2497 func_cache_lookup_module
"$1"
2498 # Output the field's value, including the final newline (if any).
2499 if $have_associative; then
2500 if eval 'test -n "${modcache_link[$1]+set}"'; then
2501 eval 'echo "${modcache_link[$1]}"'
2504 eval "field_set=\"\$${cachevar}_link_set\""
2505 if test -n "$field_set"; then
2506 eval "field_value=\"\$${cachevar}_link\""
2507 echo "${field_value}"
2513 # func_get_license_raw module
2515 # - local_gnulib_path from --local-dir
2516 # - modcache true or false, from --cache-modules/--no-cache-modules
2517 func_get_license_raw
()
2519 if ! $modcache; then
2520 func_lookup_file
"modules/$1"
2521 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2523 func_cache_lookup_module
"$1"
2524 # Output the field's value, including the final newline (if any).
2525 if $have_associative; then
2526 if eval 'test -n "${modcache_license[$1]+set}"'; then
2527 eval 'echo "${modcache_license[$1]}"'
2530 eval "field_set=\"\$${cachevar}_license_set\""
2531 if test -n "$field_set"; then
2532 eval "field_value=\"\$${cachevar}_license\""
2533 echo "${field_value}"
2539 # func_get_license module
2541 # - local_gnulib_path from --local-dir
2542 # - modcache true or false, from --cache-modules/--no-cache-modules
2545 # Warn if the License field is missing.
2549 license
=`func_get_license_raw "$1"`
2550 if test -z "$license"; then
2551 func_warning
"module $1 lacks a License"
2556 func_get_license_raw
"$1"
2557 # The default is GPL.
2559 } |
sed -e 's,^ *$,,' |
sed -e 1q
2562 # func_get_maintainer module
2564 # - local_gnulib_path from --local-dir
2565 # - modcache true or false, from --cache-modules/--no-cache-modules
2566 func_get_maintainer
()
2568 if ! $modcache; then
2569 func_lookup_file
"modules/$1"
2570 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2572 func_cache_lookup_module
"$1"
2573 # Output the field's value, including the final newline (if any).
2574 if $have_associative; then
2575 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2576 eval 'echo "${modcache_maintainer[$1]}"'
2579 eval "field_set=\"\$${cachevar}_maintainer_set\""
2580 if test -n "$field_set"; then
2581 eval "field_value=\"\$${cachevar}_maintainer\""
2582 echo "${field_value}"
2588 # func_get_tests_module module
2590 # - local_gnulib_path from --local-dir
2591 func_get_tests_module
()
2593 # The naming convention for tests modules is hardwired: ${module}-tests.
2594 if test -f "$gnulib_dir/modules/$1"-tests \
2595 || func_path_foreach
"$local_gnulib_path" func_exists_local_module
%dir
% "$1-tests"; then
2600 # func_acceptable module
2601 # tests whether a module is acceptable.
2603 # - avoidlist list of modules to avoid
2606 for avoid
in $avoidlist; do
2607 if test "$avoid" = "$1"; then
2614 # sed expression to keep the first 32 characters of each line.
2615 sed_first_32_chars
='s/^\(................................\).*/\1/'
2617 # func_module_shellfunc_name module
2618 # computes the shell function name that will contain the m4 macros for the module.
2620 # - macro_prefix prefix to use
2622 # - shellfunc shell function name
2623 func_module_shellfunc_name
()
2627 shellfunc
=func_
${macro_prefix}_gnulib_m4code_
`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2629 shellfunc
=func_
${macro_prefix}_gnulib_m4code_
$1 ;;
2633 # func_module_shellvar_name module
2634 # computes the shell variable name the will be set to true once the m4 macros
2635 # for the module have been executed.
2637 # - shellvar shell variable name
2638 func_module_shellvar_name
()
2642 shellvar
=${macro_prefix}_gnulib_enabled_
`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2644 shellvar
=${macro_prefix}_gnulib_enabled_
$1 ;;
2648 # func_module_conditional_name module
2649 # computes the automake conditional name for the module.
2651 # - conditional name of automake conditional
2652 func_module_conditional_name
()
2656 conditional
=${macro_prefix}_GNULIB_ENABLED_
`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2658 conditional
=${macro_prefix}_GNULIB_ENABLED_
$1 ;;
2662 # func_uncond_add_module B
2663 # notes the presence of B as an unconditional module.
2665 # func_conddep_add_module A B cond
2666 # notes the presence of a conditional dependency from module A to module B,
2667 # subject to the condition that A is enabled and cond is true.
2669 # func_cond_module_p B
2670 # tests whether module B is conditional.
2672 # func_cond_module_condition A B
2673 # returns the condition when B should be enabled as a dependency of A, once the
2674 # m4 code for A has been executed.
2675 # Output: - condition
2677 if $have_associative; then
2678 declare -A conddep_isuncond
2679 declare -A conddep_dependers
2680 declare -A conddep_condition
2681 func_uncond_add_module
()
2683 eval 'conddep_isuncond[$1]=true'
2684 eval 'unset conddep_dependers[$1]'
2686 func_conddep_add_module
()
2688 eval 'isuncond="${conddep_isuncond[$2]}"'
2689 if test -z "$isuncond"; then
2690 # No unconditional dependency to B known at this point.
2691 eval 'conddep_dependers[$2]="${conddep_dependers[$2]} $1"'
2692 eval 'conddep_condition[$1---$2]="$3"'
2695 func_cond_module_p
()
2697 eval 'previous_dependers="${conddep_dependers[$1]}"'
2698 test -n "$previous_dependers"
2700 func_cond_module_condition
()
2702 eval 'condition="${conddep_condition[$1---$2]}"'
2705 func_uncond_add_module
()
2709 suffix
=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2713 eval 'conddep_isuncond_'"$suffix"'=true'
2714 eval 'unset conddep_dependers_'"$suffix"
2716 func_conddep_add_module
()
2720 suffix
=`echo "$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2724 eval 'isuncond="${conddep_isuncond_'"$suffix"'}"'
2725 if test -z "$isuncond"; then
2726 eval 'conddep_dependers_'"$suffix"'="${conddep_dependers_'"$suffix"'} $1"'
2727 suffix
=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2728 eval 'conddep_condition_'"$suffix"'="$3"'
2731 func_cond_module_p
()
2735 suffix
=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2739 eval 'previous_dependers="${conddep_dependers_'"$suffix"'}"'
2740 test -n "$previous_dependers"
2742 func_cond_module_condition
()
2744 suffix
=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2745 eval 'condition="${conddep_condition_'"$suffix"'}"'
2749 sed_dependencies_without_conditions
='s/ *\[.*//'
2751 # func_modules_transitive_closure
2753 # - local_gnulib_path from --local-dir
2754 # - modcache true or false, from --cache-modules/--no-cache-modules
2755 # - modules list of specified modules
2756 # - inctests true if tests should be included, false otherwise
2757 # - incobsolete true if obsolete modules among dependencies should be
2758 # included, blank otherwise
2759 # - inc_cxx_tests true if C++ interoperability tests should be included,
2761 # - inc_longrunning_tests true if long-runnings tests should be included,
2763 # - inc_privileged_tests true if tests that require root privileges should be
2764 # included, blank otherwise
2765 # - inc_unportable_tests true if tests that fail on some platforms should be
2766 # included, blank otherwise
2767 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2768 # the unit tests of the specified modules should be
2769 # included, blank otherwise
2770 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2771 # the unit tests of the dependencies should be
2772 # included, blank otherwise
2773 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2775 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2777 # - excl_privileged_tests true if tests that require root privileges should be
2778 # excluded, blank otherwise
2779 # - excl_unportable_tests true if tests that fail on some platforms should be
2780 # excluded, blank otherwise
2781 # - avoidlist list of modules to avoid
2782 # - cond_dependencies true if conditional dependencies shall be supported,
2784 # - tmp pathname of a temporary directory
2786 # - modules list of modules, including dependencies
2787 # - conddep_dependers, conddep_condition information about conditionally
2789 func_modules_transitive_closure
()
2791 sed_escape_dependency
='s|\([/.]\)|\\\1|g'
2792 # In order to process every module only once (for speed), process an "input
2793 # list" of modules, producing an "output list" of modules. During each round,
2794 # more modules can be queued in the input list. Once a module on the input
2795 # list has been processed, it is added to the "handled list", so we can avoid
2796 # to process it again.
2798 inmodules
="$modules"
2800 fmtc_inc_all_tests
="$inc_all_direct_tests"
2801 if test "$cond_dependencies" = true
; then
2802 for module
in $inmodules; do
2804 if test -n "$module"; then
2805 if func_acceptable
$module; then
2806 func_uncond_add_module
$module
2811 while test -n "$inmodules"; do
2812 inmodules_this_round
="$inmodules"
2813 inmodules
= # Accumulator, queue for next round
2814 for module
in $inmodules_this_round; do
2816 if test -n "$module"; then
2817 if func_acceptable
$module; then
2818 func_append outmodules
" $module"
2819 if test "$cond_dependencies" = true
; then
2820 if func_get_automake_snippet_conditional
$module |
grep '^if ' > /dev
/null
; then
2821 # A module whose Makefile.am snippet contains a reference to an
2822 # automake conditional. If we were to use it conditionally, we
2823 # would get an error
2824 # configure: error: conditional "..." was never defined.
2825 # because automake 1.11.1 does not handle nested conditionals
2826 # correctly. As a workaround, make the module unconditional.
2827 func_uncond_add_module
$module
2829 if func_cond_module_p
$module; then
2835 deps
=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2836 # Duplicate dependencies are harmless, but Jim wants a warning.
2837 duplicated_deps
=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2838 if test -n "$duplicated_deps"; then
2839 func_warning
"module $module has duplicated dependencies: "`echo $duplicated_deps`
2842 testsmodule
=`func_get_tests_module $module`
2843 if test -n "$testsmodule"; then
2844 deps
="$deps $testsmodule"
2847 for dep
in $deps; do
2848 # Determine whether to include the dependency or tests module.
2850 for word
in `func_get_status $dep`; do
2853 test -n "$incobsolete" \
2857 test -z "$excl_cxx_tests" \
2859 test -n "$fmtc_inc_all_tests" ||
test -n "$inc_cxx_tests" \
2863 test -z "$excl_longrunning_tests" \
2865 test -n "$fmtc_inc_all_tests" ||
test -n "$inc_longrunning_tests" \
2869 test -z "$excl_privileged_tests" \
2871 test -n "$fmtc_inc_all_tests" ||
test -n "$inc_privileged_tests" \
2875 test -z "$excl_unportable_tests" \
2877 test -n "$fmtc_inc_all_tests" ||
test -n "$inc_unportable_tests" \
2881 test -n "$fmtc_inc_all_tests" \
2886 if $inc && func_acceptable
"$dep"; then
2887 func_append inmodules
" $dep"
2888 if test "$cond_dependencies" = true
; then
2889 escaped_dep
=`echo "$dep" | sed -e "$sed_escape_dependency"`
2890 sed_extract_condition1
='/^ *'"$escaped_dep"' *$/{
2893 sed_extract_condition2
='/^ *'"$escaped_dep"' *\[.*\] *$/{
2894 s/^ *'"$escaped_dep"' *\[\(.*\)\] *$/\1/p
2896 condition
=`func_get_dependencies $module | sed -n -e "$sed_extract_condition1" -e "$sed_extract_condition2"`
2897 if test "$condition" = true
; then
2900 if test -n "$condition"; then
2901 func_conddep_add_module
"$module" "$dep" "$condition"
2903 if $conditional; then
2904 func_conddep_add_module
"$module" "$dep" true
2906 func_uncond_add_module
"$dep"
2915 handledmodules
=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2916 # Remove $handledmodules from $inmodules.
2917 for m
in $inmodules; do echo $m; done | LC_ALL
=C
sort -u > "$tmp"/queued-modules
2918 inmodules
=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2919 fmtc_inc_all_tests
="$inc_all_indirect_tests"
2921 modules
=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2922 rm -f "$tmp"/queued-modules
2925 # func_show_module_list
2927 # - specified_modules list of specified modules (one per line, sorted)
2928 # - modules complete list of modules (one per line, sorted)
2929 # - tmp pathname of a temporary directory
2930 func_show_module_list
()
2936 # Assume xterm compatible escape sequences.
2937 bold_on
=`printf '\033[1m'`
2938 bold_off
=`printf '\033[0m'`
2943 echo "Module list with included dependencies (indented):"
2944 echo "$specified_modules" |
sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2945 echo "$modules" |
sed -e '/^$/d' \
2946 | LC_ALL
=C
join -t '|' -a2 "$tmp"/specified-modules
- \
2947 |
sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2950 # func_modules_transitive_closure_separately
2951 # Determine main module list and tests-related module list separately.
2952 # The main module list is the transitive closure of the specified modules,
2953 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2954 # is specified, it will consist only of LGPLed source.
2955 # The tests-related module list is the transitive closure of the specified
2956 # modules, including tests modules, minus the main module list excluding
2957 # modules of applicability 'all'. Its lib/* sources (brought in through
2958 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
2959 # source, even if --lgpl is specified.
2961 # - local_gnulib_path from --local-dir
2962 # - modcache true or false, from --cache-modules/--no-cache-modules
2963 # - specified_modules list of specified modules
2964 # - inctests true if tests should be included, false otherwise
2965 # - incobsolete true if obsolete modules among dependencies should be
2966 # included, blank otherwise
2967 # - inc_cxx_tests true if C++ interoperability tests should be included,
2969 # - inc_longrunning_tests true if long-runnings tests should be included,
2971 # - inc_privileged_tests true if tests that require root privileges should be
2972 # included, blank otherwise
2973 # - inc_unportable_tests true if tests that fail on some platforms should be
2974 # included, blank otherwise
2975 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2976 # the unit tests of the specified modules should be
2977 # included, blank otherwise
2978 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2979 # the unit tests of the dependencies should be
2980 # included, blank otherwise
2981 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2983 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2985 # - excl_privileged_tests true if tests that require root privileges should be
2986 # excluded, blank otherwise
2987 # - excl_unportable_tests true if tests that fail on some platforms should be
2988 # excluded, blank otherwise
2989 # - avoidlist list of modules to avoid
2990 # - cond_dependencies true if conditional dependencies shall be supported,
2992 # - tmp pathname of a temporary directory
2994 # - main_modules list of modules, including dependencies
2995 # - testsrelated_modules list of tests-related modules, including dependencies
2996 # - conddep_dependers, conddep_condition information about conditionally
2998 func_modules_transitive_closure_separately
()
3000 # Determine main module list.
3001 saved_inctests
="$inctests"
3003 modules
="$specified_modules"
3004 func_modules_transitive_closure
3005 main_modules
="$modules"
3006 inctests
="$saved_inctests"
3007 if test $verbose -ge 1; then
3008 echo "Main module list:"
3009 echo "$main_modules" |
sed -e 's/^/ /'
3011 # Determine tests-related module list.
3012 echo "$final_modules" | LC_ALL
=C
sort -u > "$tmp"/final-modules
3013 testsrelated_modules
=`for module in $main_modules; do
3014 if test \`func_get_applicability
$module\
` = main; then
3018 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3019 if test $verbose -ge 1; then
3020 echo "Tests-related module list:"
3021 echo "$testsrelated_modules" |
sed -e 's/^/ /'
3025 # func_determine_use_libtests
3026 # Determines whether a $testsbase/libtests.a is needed.
3028 # - local_gnulib_path from --local-dir
3029 # - modcache true or false, from --cache-modules/--no-cache-modules
3030 # - testsrelated_modules list of tests-related modules, including dependencies
3032 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3033 func_determine_use_libtests
()
3036 for module
in $testsrelated_modules; do
3037 func_verify_nontests_module
3038 if test -n "$module"; then
3039 all_files
=`func_get_filelist $module`
3040 # Test whether some file in $all_files lies in lib/.
3041 for f
in $all_files; do
3053 # func_modules_add_dummy
3055 # - local_gnulib_path from --local-dir
3056 # - modcache true or false, from --cache-modules/--no-cache-modules
3057 # - modules list of modules, including dependencies
3059 # - modules list of modules, including 'dummy' if needed
3060 func_modules_add_dummy
()
3062 # Determine whether any module provides a lib_SOURCES augmentation.
3064 for module
in $modules; do
3065 func_verify_nontests_module
3066 if test -n "$module"; then
3067 # Extract the value of "lib_SOURCES += ...".
3068 for file in `func_get_automake_snippet "$module" | combine_lines |
3069 sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
3070 # Ignore .h files since they are not compiled.
3074 have_lib_SOURCES
=yes
3081 # Add the dummy module, to make sure the library will be non-empty.
3082 if test -z "$have_lib_SOURCES"; then
3083 if func_acceptable
"dummy"; then
3084 func_append modules
" dummy"
3089 # func_modules_add_dummy_separately
3091 # - local_gnulib_path from --local-dir
3092 # - modcache true or false, from --cache-modules/--no-cache-modules
3093 # - main_modules list of modules, including dependencies
3094 # - testsrelated_modules list of tests-related modules, including dependencies
3095 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3097 # - main_modules list of modules, including 'dummy' if needed
3098 # - testsrelated_modules list of tests-related modules, including 'dummy' if
3100 func_modules_add_dummy_separately
()
3102 # Add the dummy module to the main module list if needed.
3103 modules
="$main_modules"
3104 func_modules_add_dummy
3105 main_modules
="$modules"
3107 # Add the dummy module to the tests-related module list if needed.
3108 if $use_libtests; then
3109 modules
="$testsrelated_modules"
3110 func_modules_add_dummy
3111 testsrelated_modules
="$modules"
3115 # func_modules_notice
3117 # - local_gnulib_path from --local-dir
3118 # - modcache true or false, from --cache-modules/--no-cache-modules
3119 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3120 # - modules list of modules, including dependencies
3121 func_modules_notice
()
3123 if test $verbose -ge -1; then
3124 for module
in $modules; do
3126 if test -n "$module"; then
3127 msg
=`func_get_notice $module`
3128 if test -n "$msg"; then
3129 echo "Notice from module $module:"
3130 echo "$msg" |
sed -e 's/^/ /'
3137 # func_modules_to_filelist
3139 # - local_gnulib_path from --local-dir
3140 # - modcache true or false, from --cache-modules/--no-cache-modules
3141 # - modules list of modules, including dependencies
3143 # - files list of files
3144 func_modules_to_filelist
()
3147 for module
in $modules; do
3149 if test -n "$module"; then
3150 fs
=`func_get_filelist $module`
3151 func_append files
" $fs"
3154 files
=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
3157 # func_modules_to_filelist_separately
3158 # Determine the final file lists.
3159 # They must be computed separately, because files in lib/* go into
3160 # $sourcebase/ if they are in the main file list but into $testsbase/
3161 # if they are in the tests-related file list. Furthermore lib/dummy.c
3164 # - local_gnulib_path from --local-dir
3165 # - modcache true or false, from --cache-modules/--no-cache-modules
3166 # - main_modules list of modules, including dependencies
3167 # - testsrelated_modules list of tests-related modules, including dependencies
3168 func_modules_to_filelist_separately
()
3170 # Determine final main file list.
3171 modules
="$main_modules"
3172 func_modules_to_filelist
3174 # Determine final tests-related file list.
3175 modules
="$testsrelated_modules"
3176 func_modules_to_filelist
3177 testsrelated_files
=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3178 # Merge both file lists.
3179 sed_remove_empty_lines
='/^$/d'
3180 files
=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3181 if test $verbose -ge 0; then
3183 sed_prettyprint_files
='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3184 echo "$files" |
sed -e "$sed_prettyprint_files" -e 's/^/ /'
3188 # func_compute_include_guard_prefix
3189 # Determine include_guard_prefix.
3191 # - macro_prefix prefix of gl_LIBOBJS macros to use
3193 # - include_guard_prefix replacement for ${gl_include_guard_prefix}
3194 # - sed_replace_include_guard_prefix
3195 # sed expression for resolving ${gl_include_guard_prefix}
3196 func_compute_include_guard_prefix
()
3198 if test "$macro_prefix" = gl
; then
3199 include_guard_prefix
='GL'
3201 include_guard_prefix
='GL_'`echo "$macro_prefix" | LC_ALL=C tr '[a-z]' '[A-Z]'`
3203 sed_replace_include_guard_prefix
='s/\${gl_include_guard_prefix}/'"${include_guard_prefix}"'/g'
3206 # func_execute_command command [args...]
3207 # Executes a command.
3208 # Uses also the variables
3209 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3210 func_execute_command
()
3212 if test $verbose -ge 0; then
3216 # Commands like automake produce output to stderr even when they succeed.
3217 # Turn this output off if the command succeeds.
3218 "$@" > "$tmp"/cmdout
2>&1
3220 if test $cmdret = 0; then
3224 cat "$tmp"/cmdout
1>&2
3231 # func_dest_tmpfilename file
3232 # determines the name of a temporary file (file is relative to destdir).
3234 # - destdir target directory
3235 # - doit : if actions shall be executed, false if only to be printed
3236 # - tmp pathname of a temporary directory
3238 # - tmpfile absolute filename of the temporary file
3239 func_dest_tmpfilename
()
3242 # Put the new contents of $file in a file in the same directory (needed
3243 # to guarantee that an 'mv' to "$destdir/$file" works).
3244 tmpfile
="$destdir/$1.tmp"
3246 # Put the new contents of $file in a file in a temporary directory
3247 # (because the directory of "$file" might not exist).
3248 tmpfile
="$tmp"/`basename "$1"`.tmp
3252 # func_is_local_file lookedup_file file
3253 # check whether file should be instantiated from local gnulib directory
3254 func_is_local_file
()
3257 func_remove_suffix dname
"/$2"
3258 func_path_foreach
"$local_gnulib_path" test %dir
% = "$dname"
3261 # func_should_symlink
3262 # returns 0 when the file $f should be symlinked
3264 # - symbolic true if files should be symlinked, copied otherwise
3265 # - lsymbolic true if files from local_gnulib_path should be symlinked,
3267 # - f the original file name
3268 # - lookedup_file name of the merged (combined) file
3269 func_should_symlink
()
3271 test -n "$symbolic" \
3272 ||
{ test -n "$lsymbolic" \
3273 && func_is_local_file
"$lookedup_file" "$f"; }
3277 # copies a file from gnulib into the destination directory. The destination
3278 # is known to not exist.
3280 # - destdir target directory
3281 # - local_gnulib_path from --local-dir
3282 # - modcache true or false, from --cache-modules/--no-cache-modules
3283 # - f the original file name
3284 # - lookedup_file name of the merged (combined) file
3285 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3286 # - g the rewritten file name
3287 # - tmpfile absolute filename of the temporary file
3288 # - doit : if actions shall be executed, false if only to be printed
3289 # - symbolic true if files should be symlinked, copied otherwise
3290 # - lsymbolic true if files from local_gnulib_path should be symlinked,
3295 echo "Copying file $g"
3296 if func_should_symlink \
3297 && test -z "$lookedup_tmp" \
3298 && cmp -s "$lookedup_file" "$tmpfile"; then
3299 func_ln_if_changed
"$lookedup_file" "$destdir/$g"
3301 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error
"failed"
3309 # copies a file from gnulib into the destination directory. The destination
3310 # is known to exist.
3312 # - destdir target directory
3313 # - local_gnulib_path from --local-dir
3314 # - modcache true or false, from --cache-modules/--no-cache-modules
3315 # - f the original file name
3316 # - lookedup_file name of the merged (combined) file
3317 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3318 # - g the rewritten file name
3319 # - tmpfile absolute filename of the temporary file
3320 # - doit : if actions shall be executed, false if only to be printed
3321 # - symbolic true if files should be symlinked, copied otherwise
3322 # - lsymbolic true if files from local_gnulib_path should be symlinked,
3324 # - already_present nonempty if the file should already exist, empty otherwise
3327 if cmp -s "$destdir/$g" "$tmpfile"; then
3328 : # The file has not changed.
3332 if test -n "$already_present"; then
3333 echo "Updating file $g (backup in ${g}~)"
3335 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
3337 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error
"failed"
3338 if func_should_symlink \
3339 && test -z "$lookedup_tmp" \
3340 && cmp -s "$lookedup_file" "$tmpfile"; then
3341 func_ln_if_changed
"$lookedup_file" "$destdir/$g"
3343 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error
"failed"
3346 if test -n "$already_present"; then
3347 echo "Update file $g (backup in ${g}~)"
3349 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
3355 # func_emit_lib_Makefile_am
3356 # emits the contents of library makefile to standard output.
3358 # - local_gnulib_path from --local-dir
3359 # - modcache true or false, from --cache-modules/--no-cache-modules
3360 # - modules list of modules, including dependencies
3361 # - libname library name
3362 # - pobase directory relative to destdir where to place *.po files
3363 # - auxdir directory relative to destdir where to place build aux files
3364 # - makefile_name from --makefile-name
3365 # - libtool true if libtool will be used, false or blank otherwise
3366 # - macro_prefix prefix of gl_LIBOBJS macros to use
3367 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3368 # - witness_c_macro from --witness-c-macro
3369 # - actioncmd (optional) command that will reproduce this invocation
3370 # - for_test true if creating a package for testing, false otherwise
3371 # - sed_replace_include_guard_prefix
3372 # sed expression for resolving ${gl_include_guard_prefix}
3373 # - destfile filename relative to destdir of makefile being generated
3375 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3376 # list of edits to be done to Makefile.am variables
3378 # - uses_subdirs nonempty if object files in subdirs exist
3379 func_emit_lib_Makefile_am
()
3381 # When creating an includable Makefile.am snippet, augment variables with
3382 # += instead of assigning them.
3383 if test -n "$makefile_name"; then
3388 if test "$libtool" = true
; then
3391 sed_eliminate_LDFLAGS
="$sed_noop"
3395 sed_eliminate_LDFLAGS
='/^lib_LDFLAGS[ ]*+=/d'
3398 # When creating a package for testing: Attempt to provoke failures,
3399 # especially link errors, already during "make" rather than during
3400 # "make check", because "make check" is not possible in a cross-compiling
3401 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3402 sed_transform_check_PROGRAMS
='s,check_PROGRAMS,noinst_PROGRAMS,g'
3404 sed_transform_check_PROGRAMS
="$sed_noop"
3406 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3407 echo "## Process this file with automake to produce Makefile.in."
3408 func_emit_copyright_notice
3409 if test -n "$actioncmd"; then
3410 # The maximum line length (excluding the terminating newline) of any file
3411 # that is to be preprocessed by config.status is 3070. config.status uses
3412 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
3413 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
3414 len
=`echo "$actioncmd" | wc -c`
3415 if test -n "$len" && test "$len" -le 3000; then
3416 echo "# Reproduce by: $actioncmd"
3422 for module
in $modules; do
3423 func_verify_nontests_module
3424 if test -n "$module"; then
3426 func_get_automake_snippet_conditional
"$module" |
3428 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3429 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3430 -e "$sed_eliminate_LDFLAGS" \
3431 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3432 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3433 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3434 -e "$sed_transform_check_PROGRAMS" \
3435 -e "$sed_replace_include_guard_prefix"
3436 if test "$module" = 'alloca'; then
3437 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
3438 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3440 } | combine_lines
"${libname}_${libext}_SOURCES" > "$tmp"/amsnippet1
3442 func_get_automake_snippet_unconditional
"$module" |
3443 LC_ALL
=C
sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
3444 } > "$tmp"/amsnippet2
3445 # Skip the contents if it's entirely empty.
3446 if grep '[^ ]' "$tmp"/amsnippet1
"$tmp"/amsnippet2
> /dev
/null
; then
3447 echo "## begin gnulib module $module"
3449 if test "$cond_dependencies" = true
; then
3450 if func_cond_module_p
"$module"; then
3451 func_module_conditional_name
"$module"
3452 echo "if $conditional"
3455 cat "$tmp"/amsnippet1
3456 if test "$cond_dependencies" = true
; then
3457 if func_cond_module_p
"$module"; then
3461 cat "$tmp"/amsnippet2
3462 echo "## end gnulib module $module"
3465 rm -f "$tmp"/amsnippet1
"$tmp"/amsnippet2
3466 # Test whether there are some source files in subdirectories.
3467 for f
in `func_get_filelist "$module"`; do
3477 } > "$tmp"/allsnippets
3478 if test -z "$makefile_name"; then
3479 # If there are source files in subdirectories, prevent collision of the
3480 # object files (example: hash.c and libxml/hash.c).
3482 if test -n "$uses_subdirs"; then
3483 subdir_options
=' subdir-objects'
3485 echo "AUTOMAKE_OPTIONS = 1.9.6 gnits${subdir_options}"
3488 if test -z "$makefile_name"; then
3490 echo "noinst_HEADERS ="
3491 echo "noinst_LIBRARIES ="
3492 echo "noinst_LTLIBRARIES ="
3493 # Automake versions < 1.11.4 create an empty pkgdatadir at
3494 # installation time if you specify pkgdata_DATA to empty.
3495 # See automake bugs #10997 and #11030:
3496 # * http://debbugs.gnu.org/10997
3497 # * http://debbugs.gnu.org/11030
3498 # So we need this workaround.
3499 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets
> /dev
/null
; then
3500 echo "pkgdata_DATA ="
3503 echo "BUILT_SOURCES ="
3506 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3507 if test -z "$makefile_name"; then
3508 echo "MOSTLYCLEANDIRS ="
3510 echo "DISTCLEANFILES ="
3511 echo "MAINTAINERCLEANFILES ="
3513 # Execute edits that apply to the Makefile.am being generated.
3515 while test $edit != $makefile_am_edits; do
3516 edit
=`expr $edit + 1`
3517 eval dir
=\"\
$makefile_am_edit${edit}_dir
\"
3518 eval var
=\"\
$makefile_am_edit${edit}_var
\"
3519 eval val
=\"\
$makefile_am_edit${edit}_val
\"
3520 if test -n "$var"; then
3521 if test "${dir}Makefile.am" = "$destfile" ||
test "./${dir}Makefile.am" = "$destfile"; then
3522 echo "${var} += ${val}"
3523 eval "makefile_am_edit${edit}_var="
3527 if test -n "$witness_c_macro"; then
3528 cppflags_part1
=" -D$witness_c_macro=1"
3533 cppflags_part2
=" -DGNULIB_STRICT_CHECKING=1"
3537 if test -z "$makefile_name"; then
3539 echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
3542 if test -n "$cppflags_part1$cppflags_part2"; then
3544 echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
3548 if LC_ALL
=C
grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets
> /dev
/null \
3549 ||
{ test -n "$makefile_name" \
3550 && test -f "$sourcebase/Makefile.am" \
3551 && LC_ALL
=C
grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev
/null
; \
3553 # One of the snippets or the user's Makefile.am already specifies an
3554 # installation location for the library. Don't confuse automake by saying
3555 # it should not be installed.
3558 # By default, the generated library should not be installed.
3559 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3562 echo "${libname}_${libext}_SOURCES ="
3563 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3564 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3565 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3566 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3567 echo "EXTRA_${libname}_${libext}_SOURCES ="
3568 if test "$libtool" = true
; then
3569 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3570 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3571 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3572 # the link dependencies of all modules.
3573 for module
in $modules; do
3574 func_verify_nontests_module
3575 if test -n "$module"; then
3576 func_get_link_directive
"$module"
3579 | LC_ALL
=C
sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
3580 | LC_ALL
=C
sort -u \
3581 | LC_ALL
=C
sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
3584 if test -n "$pobase"; then
3585 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
3588 cat "$tmp"/allsnippets \
3589 |
sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3591 echo "mostlyclean-local: mostlyclean-generic"
3592 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3593 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3594 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3598 rm -f "$tmp"/allsnippets
3601 # func_emit_po_Makevars
3602 # emits the contents of po/ makefile parameterization to standard output.
3604 # - local_gnulib_path from --local-dir
3605 # - modcache true or false, from --cache-modules/--no-cache-modules
3606 # - sourcebase directory relative to destdir where to place source code
3607 # - pobase directory relative to destdir where to place *.po files
3608 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3609 func_emit_po_Makevars
()
3611 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3612 func_emit_copyright_notice
3614 echo "# Usually the message domain is the same as the package name."
3615 echo "# But here it has a '-gnulib' suffix."
3616 echo "DOMAIN = ${po_domain}-gnulib"
3618 echo "# These two variables depend on the location of this directory."
3619 echo "subdir = ${pobase}"
3620 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
3623 # These options get passed to xgettext.
3624 XGETTEXT_OPTIONS
= \
3625 --keyword=_
--flag=_
:1:pass-c-format \
3626 --keyword=N_
--flag=N_
:1:pass-c-format \
3627 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
3628 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
3629 --flag=error
:3:c-format
--flag=error_at_line
:5:c-format
3631 # This is the copyright holder that gets inserted into the header of the
3632 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
3633 COPYRIGHT_HOLDER
= Free Software Foundation
, Inc.
3635 # This is the email address or URL to which the translators shall report
3636 # bugs in the untranslated strings:
3637 # - Strings which are not entire sentences, see the maintainer guidelines
3638 # in the GNU gettext documentation, section 'Preparing Strings'.
3639 # - Strings which use unclear terms or require additional context to be
3641 # - Strings which make invalid assumptions about notation of date, time or
3643 # - Pluralisation problems.
3644 # - Incorrect English spelling.
3645 # - Incorrect formatting.
3646 # It can be your email address, or a mailing list address where translators
3647 # can write to without being subscribed, or the URL of a web page through
3648 # which the translators can contact you.
3649 MSGID_BUGS_ADDRESS
= bug-gnulib@gnu.org
3651 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3652 # message catalogs shall be used. It is usually empty.
3653 EXTRA_LOCALE_CATEGORIES
=
3655 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3656 # context. Possible values are "yes" and "no". Set this to yes if the
3657 # package uses functions taking also a message context, like pgettext(), or
3658 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3663 # func_emit_po_POTFILES_in
3664 # emits the file list to be passed to xgettext to standard output.
3666 # - local_gnulib_path from --local-dir
3667 # - modcache true or false, from --cache-modules/--no-cache-modules
3668 # - sourcebase directory relative to destdir where to place source code
3669 # - files list of new files
3670 func_emit_po_POTFILES_in
()
3672 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3673 func_emit_copyright_notice
3675 echo "# List of files which contain translatable strings."
3676 echo "$files" |
sed -n -e "s,^lib/,$sourcebase/,p"
3679 # func_emit_tests_Makefile_am witness_macro
3680 # emits the contents of tests makefile to standard output.
3682 # - local_gnulib_path from --local-dir
3683 # - modcache true or false, from --cache-modules/--no-cache-modules
3684 # - modules list of modules, including dependencies
3685 # - libname library name
3686 # - auxdir directory relative to destdir where to place build aux files
3687 # - makefile_name from --makefile-name
3688 # - libtool true if libtool will be used, false or blank otherwise
3689 # - sourcebase relative directory containing lib source code
3690 # - m4base relative directory containing autoconf macros
3691 # - testsbase relative directory containing unit test code
3692 # - macro_prefix prefix of gl_LIBOBJS macros to use
3693 # - witness_c_macro from --witness-c-macro
3694 # - for_test true if creating a package for testing, false otherwise
3695 # - single_configure true if a single configure file should be generated,
3696 # false for a separate configure file for the tests
3697 # - use_libtests true if a libtests.a should be built, false otherwise
3698 # - sed_replace_include_guard_prefix
3699 # sed expression for resolving ${gl_include_guard_prefix}
3700 # - destfile filename relative to destdir of makefile being generated
3702 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3703 # list of edits to be done to Makefile.am variables
3705 # - uses_subdirs nonempty if object files in subdirs exist
3706 func_emit_tests_Makefile_am
()
3709 if test "$libtool" = true
; then
3712 sed_eliminate_LDFLAGS
="$sed_noop"
3716 sed_eliminate_LDFLAGS
='/^lib_LDFLAGS[ ]*+=/d'
3719 # When creating a package for testing: Attempt to provoke failures,
3720 # especially link errors, already during "make" rather than during
3721 # "make check", because "make check" is not possible in a cross-compiling
3722 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3723 sed_transform_check_PROGRAMS
='s,check_PROGRAMS,noinst_PROGRAMS,g'
3725 sed_transform_check_PROGRAMS
="$sed_noop"
3727 testsbase_inverse
=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3728 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3729 echo "## Process this file with automake to produce Makefile.in."
3730 func_emit_copyright_notice
3734 for module
in $modules; do
3735 if $for_test && ! $single_configure; then
3736 func_verify_tests_module
3740 if test -n "$module"; then
3742 func_get_automake_snippet
"$module" |
3744 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3745 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3746 -e "$sed_eliminate_LDFLAGS" \
3747 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3748 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3749 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3750 -e "$sed_transform_check_PROGRAMS" \
3751 -e "$sed_replace_include_guard_prefix"
3752 if $use_libtests && test "$module" = 'alloca'; then
3753 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3754 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3756 } > "$tmp"/amsnippet
3757 # Skip the contents if it's entirely empty.
3758 if grep '[^ ]' "$tmp"/amsnippet
> /dev
/null
; then
3759 # Mention long-running tests at the end.
3761 for word
in `func_get_status "$module"`; do
3762 if test "$word" = 'longrunning-test'; then
3767 { echo "## begin gnulib module $module"
3769 cat "$tmp"/amsnippet
3770 echo "## end gnulib module $module"
3774 rm -f "$tmp"/amsnippet
3775 # Test whether there are some source files in subdirectories.
3776 for f
in `func_get_filelist "$module"`; do
3778 lib
/*/*.c |
tests
/*/*.c
)
3786 } 3> "$tmp"/main_snippets
4> "$tmp"/longrunning_snippets
3787 # Generate dependencies here, since it eases the debugging of test failures.
3788 # If there are source files in subdirectories, prevent collision of the
3789 # object files (example: hash.c and libxml/hash.c).
3791 if test -n "$uses_subdirs"; then
3792 subdir_options
=' subdir-objects'
3794 echo "AUTOMAKE_OPTIONS = 1.9.6 foreign${subdir_options}"
3796 if $for_test && ! $single_configure; then
3797 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3800 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3801 # variable is needed to avoid an error from automake:
3802 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3805 echo "XFAIL_TESTS ="
3806 echo "TESTS_ENVIRONMENT ="
3807 echo "noinst_PROGRAMS ="
3808 if ! $for_test; then
3809 echo "check_PROGRAMS ="
3811 echo "noinst_HEADERS ="
3812 echo "noinst_LIBRARIES ="
3813 if $use_libtests; then
3815 echo "noinst_LIBRARIES += libtests.a"
3817 echo "check_LIBRARIES = libtests.a"
3820 # Automake versions < 1.11.4 create an empty pkgdatadir at
3821 # installation time if you specify pkgdata_DATA to empty.
3822 # See automake bugs #10997 and #11030:
3823 # * http://debbugs.gnu.org/10997
3824 # * http://debbugs.gnu.org/11030
3825 # So we need this workaround.
3826 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets
"$tmp"/longrunning_snippets
> /dev
/null
; then
3827 echo "pkgdata_DATA ="
3830 echo "BUILT_SOURCES ="
3832 echo "MOSTLYCLEANFILES = core *.stackdump"
3833 echo "MOSTLYCLEANDIRS ="
3835 echo "DISTCLEANFILES ="
3836 echo "MAINTAINERCLEANFILES ="
3837 # Execute edits that apply to the Makefile.am being generated.
3839 while test $edit != $makefile_am_edits; do
3840 edit
=`expr $edit + 1`
3841 eval dir
=\"\
$makefile_am_edit${edit}_dir
\"
3842 eval var
=\"\
$makefile_am_edit${edit}_var
\"
3843 eval val
=\"\
$makefile_am_edit${edit}_val
\"
3844 if test -n "$var"; then
3845 if test "${dir}Makefile.am" = "$destfile" ||
test "./${dir}Makefile.am" = "$destfile"; then
3846 echo "${var} += ${val}"
3847 eval "makefile_am_edit${edit}_var="
3852 echo "AM_CPPFLAGS = \\"
3854 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3856 if test -n "$witness_c_macro"; then
3857 echo " -D$witness_c_macro=1 \\"
3859 if test -n "${witness_macro}"; then
3860 echo " -D@${witness_macro}@=1 \\"
3862 echo " -I. -I\$(srcdir) \\"
3863 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3864 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3866 local_ldadd_before
=''
3867 local_ldadd_after
=''
3868 if $use_libtests; then
3869 # All test programs need to be linked with libtests.a.
3870 # It needs to be passed to the linker before ${libname}.${libext}, since
3871 # the tests-related modules depend on the main modules.
3872 # It also needs to be passed to the linker after ${libname}.${libext}
3873 # because the latter might contain incomplete modules (such as the 'error'
3874 # module whose dependency to 'progname' is voluntarily omitted).
3875 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3877 local_ldadd_before
=' libtests.a'
3878 local_ldadd_after
=' libtests.a $(LIBTESTS_LIBDEPS)'
3880 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3882 if $use_libtests; then
3883 echo "libtests_a_SOURCES ="
3884 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3885 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3886 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3887 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3888 echo "EXTRA_libtests_a_SOURCES ="
3889 # The circular dependency in LDADD requires this.
3890 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3893 # Many test scripts use ${EXEEXT} or ${srcdir}.
3894 # EXEEXT is defined by AC_PROG_CC through autoconf.
3895 # srcdir is defined by autoconf and automake.
3896 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3898 cat "$tmp"/main_snippets
"$tmp"/longrunning_snippets \
3899 |
sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3900 echo "# Clean up after Solaris cc."
3902 echo " rm -rf SunWS_cache"
3904 echo "mostlyclean-local: mostlyclean-generic"
3905 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3906 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3907 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3911 rm -f "$tmp"/main_snippets
"$tmp"/longrunning_snippets
3914 # func_emit_initmacro_start macro_prefix
3915 # emits the first few statements of the gl_INIT macro to standard output.
3916 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3917 func_emit_initmacro_start
()
3919 macro_prefix_arg
="$1"
3920 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3921 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3922 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3923 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3925 # Furthermore it avoids an automake error like this when a Makefile.am
3926 # that uses pieces of gnulib also uses $(LIBOBJ):
3927 # automatically discovered file `error.c' should not be explicitly mentioned
3928 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3929 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3930 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3931 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3932 # automatically discovered file `error.c' should not be explicitly mentioned
3933 # We let automake know about the files to be distributed through the
3934 # EXTRA_lib_SOURCES variable.
3935 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3936 # Create data variables for checking the presence of files that are mentioned
3937 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3938 # because we want the check to happen when the configure file is created,
3939 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3940 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3941 # in which to expect them.
3942 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3943 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3947 # func_emit_initmacro_end macro_prefix
3948 # emits the last few statements of the gl_INIT macro to standard output.
3949 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3950 func_emit_initmacro_end
()
3952 macro_prefix_arg
="$1"
3953 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3954 # The check is performed only when autoconf is run from the directory where
3955 # the configure.ac resides; if it is run from a different directory, the
3957 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3958 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3959 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3960 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3961 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3965 echo " m4_if(m4_sysval, [0], [],"
3966 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3968 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3969 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3970 echo " m4_popdef([AC_LIBSOURCES])"
3971 echo " m4_popdef([AC_REPLACE_FUNCS])"
3972 echo " m4_popdef([AC_LIBOBJ])"
3973 echo " AC_CONFIG_COMMANDS_PRE(["
3974 echo " ${macro_prefix_arg}_libobjs="
3975 echo " ${macro_prefix_arg}_ltlibobjs="
3976 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3977 echo " # Remove the extension."
3978 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3979 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3980 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3981 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3984 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3985 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3989 # func_emit_initmacro_done macro_prefix sourcebase
3990 # emits a few statements after the gl_INIT macro to standard output.
3991 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3992 # - sourcebase directory relative to destdir where to place source code
3993 func_emit_initmacro_done
()
3995 macro_prefix_arg
="$1"
3998 echo "# Like AC_LIBOBJ, except that the module name goes"
3999 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4000 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
4001 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
4002 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
4005 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
4006 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4007 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
4008 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
4009 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
4012 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
4013 echo "# expected is derived from the gnulib-tool parameterization,"
4014 echo "# and alloca is special cased (for the alloca-opt module)."
4015 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
4016 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
4017 echo " m4_foreach([_gl_NAME], [\$1], ["
4018 echo " m4_if(_gl_NAME, [alloca.c], [], ["
4019 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
4020 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
4026 # func_emit_autoconf_snippet indentation
4027 # emits the autoconf snippet of a module.
4029 # - indentation spaces to prepend on each line
4030 # - local_gnulib_path from --local-dir
4031 # - modcache true or false, from --cache-modules/--no-cache-modules
4032 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4033 # - sed_replace_include_guard_prefix
4034 # sed expression for resolving ${gl_include_guard_prefix}
4035 # - module the module name
4036 # - toplevel true or false. 'false' means a subordinate use of
4038 # - disable_libtool true or false. It tells whether to disable libtool
4039 # handling even if it has been specified through the
4040 # command line options.
4041 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4043 func_emit_autoconf_snippet
()
4046 if { case $module in
4047 gnumakefile | maintainer-makefile
)
4048 # These modules are meant to be used only in the top-level directory.
4054 func_get_autoconf_snippet
"$module" \
4055 |
sed -e '/^$/d;' -e "s/^/$indentation/" \
4056 -e "$sed_replace_build_aux" \
4057 -e "$sed_replace_include_guard_prefix" \
4058 |
{ if $disable_libtool; then
4059 sed -e 's/\$gl_cond_libtool/false/g' \
4060 -e 's/gl_libdeps/gltests_libdeps/g' \
4061 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4066 |
{ if $disable_gettext; then
4067 sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
4069 # Don't indent AM_GNU_GETTEXT_VERSION line, as that confuses
4070 # autopoint through at least GNU gettext version 0.18.2.
4071 sed -e 's/^ *AM_GNU_GETTEXT_VERSION/AM_GNU_GETTEXT_VERSION/'
4074 if test "$module" = 'alloca' && test "$libtool" = true
&& ! $disable_libtool; then
4075 echo 'changequote(,)dnl'
4076 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4077 echo 'changequote([, ])dnl'
4078 echo 'AC_SUBST([LTALLOCA])'
4083 # func_emit_autoconf_snippets modules verifier toplevel disable_libtool disable_gettext
4084 # collects and emit the autoconf snippets of a set of modules.
4086 # - local_gnulib_path from --local-dir
4087 # - modcache true or false, from --cache-modules/--no-cache-modules
4088 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4089 # - sed_replace_include_guard_prefix
4090 # sed expression for resolving ${gl_include_guard_prefix}
4091 # - modules the list of modules.
4092 # - verifier one of func_verify_module, func_verify_nontests_module,
4093 # func_verify_tests_module. It selects the subset of
4094 # $modules to consider.
4095 # - toplevel true or false. 'false' means a subordinate use of
4097 # - disable_libtool true or false. It tells whether to disable libtool
4098 # handling even if it has been specified through the
4099 # command line options.
4100 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4102 func_emit_autoconf_snippets
()
4106 disable_libtool
="$4"
4107 disable_gettext
="$5"
4108 if test "$cond_dependencies" = true
; then
4109 for m
in $modules; do echo $m; done | LC_ALL
=C
sort -u > "$tmp"/modules
4110 # Emit the autoconf code for the unconditional modules.
4111 for module
in $1; do
4113 if test -n "$module"; then
4114 if func_cond_module_p
"$module"; then
4117 func_emit_autoconf_snippet
" "
4121 # Initialize the shell variables indicating that the modules are enabled.
4122 for module
in $1; do
4124 if test -n "$module"; then
4125 if func_cond_module_p
"$module"; then
4126 func_module_shellvar_name
"$module"
4127 echo " $shellvar=false"
4131 # Emit the autoconf code for the conditional modules, each in a separate
4132 # function. This makes it possible to support cycles among conditional
4134 for module
in $1; do
4136 if test -n "$module"; then
4137 if func_cond_module_p
"$module"; then
4138 func_module_shellfunc_name
"$module"
4139 func_module_shellvar_name
"$module"
4140 echo " $shellfunc ()"
4142 echo " if ! \$$shellvar; then"
4143 func_emit_autoconf_snippet
" "
4144 echo " $shellvar=true"
4145 deps
=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4146 # Intersect $deps with the modules list $1.
4147 deps
=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4148 for dep
in $deps; do
4149 if func_cond_module_p
"$dep"; then
4150 func_module_shellfunc_name
"$dep"
4151 func_cond_module_condition
"$module" "$dep"
4152 if test "$condition" != true
; then
4153 echo " if $condition; then"
4160 # The autoconf code for $dep has already been emitted above and
4161 # therefore is already executed when this function is run.
4170 # Emit the dependencies from the unconditional to the conditional modules.
4171 for module
in $1; do
4173 if test -n "$module"; then
4174 if func_cond_module_p
"$module"; then
4177 deps
=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4178 # Intersect $deps with the modules list $1.
4179 deps
=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4180 for dep
in $deps; do
4181 if func_cond_module_p
"$dep"; then
4182 func_module_shellfunc_name
"$dep"
4183 func_cond_module_condition
"$module" "$dep"
4184 if test "$condition" != true
; then
4185 echo " if $condition; then"
4192 # The autoconf code for $dep has already been emitted above and
4193 # therefore is already executed when this code is run.
4200 # Define the Automake conditionals.
4201 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
4202 for module
in $1; do
4204 if test -n "$module"; then
4205 if func_cond_module_p
"$module"; then
4206 func_module_conditional_name
"$module"
4207 func_module_shellvar_name
"$module"
4208 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
4213 # Ignore the conditions, and enable all modules unconditionally.
4214 for module
in $1; do
4216 if test -n "$module"; then
4217 func_emit_autoconf_snippet
" "
4223 # func_emit_pre_early_macros require indentation modules
4224 # The require parameter can be ':' (AC_REQUIRE) or 'false' (direct call).
4225 func_emit_pre_early_macros
()
4228 echo "${2}# Pre-early section."
4230 _pre_early_snippet
="echo \"${2}AC_REQUIRE([\$_pre_early_macro])\""
4232 _pre_early_snippet
="echo \"${2}\$_pre_early_macro\""
4235 # We need to call gl_USE_SYSTEM_EXTENSIONS before gl_PROG_AR_RANLIB. Doing
4236 # AC_REQUIRE in configure-ac.early is not early enough.
4237 _pre_early_macro
="gl_USE_SYSTEM_EXTENSIONS"
4238 case "${nl}${3}${nl}" in
4239 *${nl}extensions
${nl}*) eval "$_pre_early_snippet" ;;
4242 _pre_early_macro
="gl_PROG_AR_RANLIB"
4243 eval "$_pre_early_snippet"
4247 # func_reconstruct_cached_dir
4248 # callback for func_reconstruct_cached_local_gnulib_path
4250 # - destdir from --dir
4252 # - local_gnulib_path restored '--local-dir' path from cache
4253 func_reconstruct_cached_dir
()
4256 if test -n "$cached_dir"; then
4259 func_path_append local_gnulib_path
"$destdir/$cached_dir" ;;
4261 case "$cached_dir" in
4263 func_path_append local_gnulib_path
"$destdir/$cached_dir" ;;
4265 func_relconcat
"$destdir" "$cached_dir"
4266 func_path_append local_gnulib_path
"$relconcat" ;;
4272 # func_reconstruct_cached_local_gnulib_path
4273 # reconstruct local_gnulib_path from cached_local_gnulib_path to be set
4274 # relatively to $destdir again.
4276 # - cached_local_gnulib_path local_gnulib_path stored within gnulib-cache.m4
4277 # - destdir from --dir
4279 # - local_gnulib_path restored '--local-dir' path from cache
4280 func_reconstruct_cached_local_gnulib_path
()
4282 func_path_foreach
"$cached_local_gnulib_path" func_reconstruct_cached_dir
%dir
%
4285 # func_import modules
4286 # Uses also the variables
4287 # - mode import or add-import or remove-import or update
4288 # - destdir target directory
4289 # - local_gnulib_path from --local-dir
4290 # - modcache true or false, from --cache-modules/--no-cache-modules
4291 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
4292 # - libname library name
4293 # - supplied_libname true if --lib was given, blank otherwise
4294 # - sourcebase directory relative to destdir where to place source code
4295 # - m4base directory relative to destdir where to place *.m4 macros
4296 # - pobase directory relative to destdir where to place *.po files
4297 # - docbase directory relative to destdir where to place doc files
4298 # - testsbase directory relative to destdir where to place unit test code
4299 # - auxdir directory relative to destdir where to place build aux files
4300 # - inctests true if --with-tests was given, false otherwise
4301 # - incobsolete true if --with-obsolete was given, blank otherwise
4302 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
4303 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
4305 # - inc_privileged_tests true if --with-privileged-tests was given, blank
4307 # - inc_unportable_tests true if --with-unportable-tests was given, blank
4309 # - inc_all_tests true if --with-all-tests was given, blank otherwise
4310 # - avoidlist list of modules to avoid, from --avoid
4311 # - cond_dependencies true if --conditional-dependencies was given, false if
4312 # --no-conditional-dependencies was given, blank otherwise
4313 # - lgpl yes or a number if library's license shall be LGPL,
4315 # - makefile_name from --makefile-name
4316 # - libtool true if --libtool was given, false if --no-libtool was
4317 # given, blank otherwise
4318 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
4319 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4320 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4321 # - witness_c_macro from --witness-c-macro
4322 # - vc_files true if --vc-files was given, false if --no-vc-files was
4323 # given, blank otherwise
4324 # - autoconf_minversion minimum supported autoconf version
4325 # - doit : if actions shall be executed, false if only to be printed
4326 # - symbolic true if files should be symlinked, copied otherwise
4327 # - lsymbolic true if files from local_gnulib_path should be symlinked,
4329 # - do_copyrights true if copyright notices in files should be replaced,
4333 # Get the cached settings.
4334 # In 'import' mode, we read them only for the purpose of knowing the old
4335 # installed file list, and don't use them as defaults.
4336 cached_local_gnulib_path
=
4337 cached_specified_modules
=
4339 cached_inc_cxx_tests
=
4340 cached_inc_longrunning_tests
=
4341 cached_inc_privileged_tests
=
4342 cached_inc_unportable_tests
=
4343 cached_inc_all_tests
=
4353 cached_makefile_name
=
4354 cached_cond_dependencies
=
4356 cached_macro_prefix
=
4358 cached_witness_c_macro
=
4361 if test -f "$destdir"/$m4base/gnulib-cache.
m4; then
4362 cached_libtool
=false
4368 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_path="\1",p
4378 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
4380 /gl_WITH_OBSOLETE/ {
4381 s,^.*$,cached_incobsolete=true,p
4383 /gl_WITH_CXX_TESTS/ {
4384 s,^.*$,cached_inc_cxx_tests=true,p
4386 /gl_WITH_LONGRUNNING_TESTS/ {
4387 s,^.*$,cached_inc_longrunning_tests=true,p
4389 /gl_WITH_PRIVILEGED_TESTS/ {
4390 s,^.*$,cached_inc_privileged_tests=true,p
4392 /gl_WITH_UNPORTABLE_TESTS/ {
4393 s,^.*$,cached_inc_unportable_tests=true,p
4395 /gl_WITH_ALL_TESTS/ {
4396 s,^.*$,cached_inc_all_tests=true,p
4399 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
4402 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
4405 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
4408 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
4411 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
4414 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
4417 s,^.*$,cached_inctests=true,p
4420 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
4423 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
4426 s,^.*$,cached_lgpl=yes,p
4428 /gl_MAKEFILE_NAME(/ {
4429 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
4431 /gl_CONDITIONAL_DEPENDENCIES/ {
4432 s,^.*$,cached_cond_dependencies=true,p
4435 s,^.*$,cached_libtool=true,p
4437 /gl_MACRO_PREFIX(/ {
4438 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
4441 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
4443 /gl_WITNESS_C_MACRO(/ {
4444 s,^.*gl_WITNESS_C_MACRO([[ ]*\([^]"$`\\)]*\).*$,cached_witness_c_macro="\1",p
4447 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
4449 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
4450 if test -f "$destdir"/$m4base/gnulib-comp.
m4; then
4455 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
4456 s,^.*$,cached_files=",p
4469 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
4473 if test "$mode" = import
; then
4474 # In 'import' mode, the new set of specified modules overrides the cached
4475 # set of modules. Ignore the cached settings.
4476 specified_modules
="$1"
4478 # Merge the cached settings with the specified ones.
4479 # The m4base must be the same as expected from the pathname.
4480 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
4481 func_fatal_error
"$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
4483 # The local_gnulib_path defaults to the cached one. Recall that the cached one
4484 # is relative to $destdir, whereas the one we use is relative to . or absolute.
4485 if test -z "$local_gnulib_path"; then
4486 func_reconstruct_cached_local_gnulib_path
4490 # Append the cached and the specified module names. So that
4491 # "gnulib-tool --add-import foo" means to add the module foo.
4492 specified_modules
="$cached_specified_modules $1"
4495 # Take the cached module names, minus the specified module names.
4497 if $have_associative; then
4498 # Use an associative array, for O(N) worst-case run time.
4499 declare -A to_remove
4501 eval 'to_remove[$m]=yes'
4503 for module
in $cached_specified_modules; do
4504 if eval 'test -z "${to_remove[$module]}"'; then
4505 func_append specified_modules
"$module "
4509 # This loop has O(N**2) worst-case run time.
4510 for module
in $cached_specified_modules; do
4513 if test "$m" = "$module"; then
4518 if test -z "$to_remove"; then
4519 func_append specified_modules
"$module "
4525 # Take the cached module names. There are no specified module names.
4526 specified_modules
="$cached_specified_modules"
4529 # Included obsolete modules among the dependencies if specified either way.
4530 if test -z "$incobsolete"; then
4531 incobsolete
="$cached_incobsolete"
4533 # Included special kinds of tests modules among the dependencies if specified
4535 if test -z "$inc_cxx_tests"; then
4536 inc_cxx_tests
="$cached_inc_cxx_tests"
4538 if test -z "$inc_longrunning_tests"; then
4539 inc_longrunning_tests
="$cached_inc_longrunning_tests"
4541 if test -z "$inc_privileged_tests"; then
4542 inc_privileged_tests
="$cached_inc_privileged_tests"
4544 if test -z "$inc_unportable_tests"; then
4545 inc_unportable_tests
="$cached_inc_unportable_tests"
4547 if test -z "$inc_all_tests"; then
4548 inc_all_tests
="$cached_inc_all_tests"
4550 # Append the cached and the specified avoidlist. This is probably better
4551 # than dropping the cached one when --avoid is specified at least once.
4552 avoidlist
=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
4553 avoidlist
=`echo $avoidlist`
4555 # The sourcebase defaults to the cached one.
4556 if test -z "$sourcebase"; then
4557 sourcebase
="$cached_sourcebase"
4558 if test -z "$sourcebase"; then
4559 func_fatal_error
"missing --source-base option"
4562 # The pobase defaults to the cached one.
4563 if test -z "$pobase"; then
4564 pobase
="$cached_pobase"
4566 # The docbase defaults to the cached one.
4567 if test -z "$docbase"; then
4568 docbase
="$cached_docbase"
4569 if test -z "$docbase"; then
4570 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."
4573 # The testsbase defaults to the cached one.
4574 if test -z "$testsbase"; then
4575 testsbase
="$cached_testsbase"
4576 if test -z "$testsbase"; then
4577 func_fatal_error
"missing --tests-base option"
4580 # Require the tests if specified either way.
4581 if ! $inctests; then
4582 inctests
="$cached_inctests"
4583 if test -z "$inctests"; then
4587 # The libname defaults to the cached one.
4588 if test -z "$supplied_libname"; then
4589 libname
="$cached_libname"
4590 if test -z "$libname"; then
4591 func_fatal_error
"missing --lib option"
4594 # Require LGPL if specified either way.
4595 if test -z "$lgpl"; then
4598 # The makefile_name defaults to the cached one.
4599 if test -z "$makefile_name"; then
4600 makefile_name
="$cached_makefile_name"
4602 # Use conditional dependencies if specified either way.
4603 if test -z "$cond_dependencies"; then
4604 cond_dependencies
="$cached_cond_dependencies"
4606 # Use libtool if specified either way, or if guessed.
4607 if test -z "$libtool"; then
4608 if test -n "$cached_m4base"; then
4609 libtool
="$cached_libtool"
4611 libtool
="$guessed_libtool"
4614 # The macro_prefix defaults to the cached one.
4615 if test -z "$macro_prefix"; then
4616 macro_prefix
="$cached_macro_prefix"
4617 if test -z "$macro_prefix"; then
4618 func_fatal_error
"missing --macro-prefix option"
4621 # The po_domain defaults to the cached one.
4622 if test -z "$po_domain"; then
4623 po_domain
="$cached_po_domain"
4625 # The witness_c_macro defaults to the cached one.
4626 if test -z "$witness_c_macro"; then
4627 witness_c_macro
="$cached_witness_c_macro"
4629 # The vc_files defaults to the cached one.
4630 if test -z "$vc_files"; then
4631 vc_files
="$cached_vc_files"
4633 # Ensure constraints.
4634 if test "$cond_dependencies" = true
&& $inctests; then
4635 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
4639 # --without-*-tests options are not supported here.
4641 excl_longrunning_tests
=
4642 excl_privileged_tests
=
4643 excl_unportable_tests
=
4645 # Canonicalize the list of specified modules.
4646 specified_modules
=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4648 # Include all kinds of tests modules if --with-all-tests was specified.
4649 inc_all_direct_tests
="$inc_all_tests"
4650 inc_all_indirect_tests
="$inc_all_tests"
4652 # Determine final module list.
4653 modules
="$specified_modules"
4654 func_modules_transitive_closure
4655 if test $verbose -ge 0; then
4656 func_show_module_list
4658 final_modules
="$modules"
4660 # Determine main module list and tests-related module list separately.
4661 func_modules_transitive_closure_separately
4663 # Determine whether a $testsbase/libtests.a is needed.
4664 func_determine_use_libtests
4666 # Add the dummy module to the main module list or to the tests-related module
4668 func_modules_add_dummy_separately
4670 # If --lgpl, verify that the licenses of modules are compatible.
4671 if test -n "$lgpl"; then
4672 license_incompatibilities
=
4673 for module
in $main_modules; do
4674 license
=`func_get_license $module`
4676 'GPLed build tool') ;;
4677 'public domain' |
'unlimited' |
'unmodifiable license text') ;;
4682 LGPL | LGPLv2
+ | LGPLv3
+) ;;
4683 *) func_append license_incompatibilities
"$module $license$nl" ;;
4689 *) func_append license_incompatibilities
"$module $license$nl" ;;
4692 *) func_fatal_error
"invalid value lgpl=$lgpl" ;;
4697 if test -n "$license_incompatibilities"; then
4698 # Format the license incompatibilities as a table.
4699 sed_expand_column1_width50_indent17
='s,^\([^ ]*\) ,\1 ,
4700 s,^\(.................................................[^ ]*\) *, \1 ,'
4701 license_incompatibilities
=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
4702 func_fatal_error
"incompatible license on modules:$nl$license_incompatibilities"
4706 # Show banner notice of every module.
4707 modules
="$main_modules"
4710 # Determine script to apply to imported library files.
4711 sed_transform_lib_file
=
4712 for module
in $main_modules; do
4713 if test $module = config-h
; then
4714 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
4715 sed_transform_lib_file
=$sed_transform_lib_file'
4716 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
4721 sed_transform_main_lib_file
="$sed_transform_lib_file"
4722 if test -n "$do_copyrights"; then
4723 if test -n "$lgpl"; then
4727 sed_transform_main_lib_file
=$sed_transform_main_lib_file'
4728 s/GNU General/GNU Lesser General/g
4729 s/General Public License/Lesser General Public License/g
4730 s/Lesser Lesser General Public License/Lesser General Public License/g
4734 sed_transform_main_lib_file
=$sed_transform_main_lib_file'
4735 s/GNU General/GNU Lesser General/g
4736 s/General Public License/Lesser General Public License/g
4737 s/Lesser Lesser General Public License/Lesser General Public License/g
4739 s/version [23]\([ ,]\)/version 2.1\1/g
4742 *) func_fatal_error
"invalid value lgpl=$lgpl" ;;
4746 sed_transform_main_lib_file
=$sed_transform_main_lib_file'
4747 s/GNU Lesser General/GNU General/g
4748 s/Lesser General Public License/General Public License/g
4750 s/GNU Library General/GNU General/g
4751 s/Library General Public License/General Public License/g
4753 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4758 # Determine script to apply to auxiliary files that go into $auxdir/.
4759 sed_transform_build_aux_file
=
4760 if test -n "$do_copyrights"; then
4762 sed_transform_build_aux_file
=$sed_transform_build_aux_file'
4763 s/GNU Lesser General/GNU General/g
4764 s/Lesser General Public License/General Public License/g
4766 s/GNU Library General/GNU General/g
4767 s/Library General Public License/General Public License/g
4769 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4773 # Determine script to apply to library files that go into $testsbase/.
4774 sed_transform_testsrelated_lib_file
="$sed_transform_lib_file"
4775 if test -n "$do_copyrights"; then
4777 sed_transform_testsrelated_lib_file
=$sed_transform_testsrelated_lib_file'
4778 s/GNU Lesser General/GNU General/g
4779 s/Lesser General Public License/General Public License/g
4781 s/GNU Library General/GNU General/g
4782 s/Library General Public License/General Public License/g
4784 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4788 # Determine the final file lists.
4789 func_modules_to_filelist_separately
4792 || func_fatal_error
"refusing to do nothing"
4794 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
4795 new_files
="$files m4/gnulib-tool.m4"
4796 old_files
="$cached_files"
4797 if test -f "$destdir"/$m4base/gnulib-tool.
m4; then
4798 func_append old_files
" m4/gnulib-tool.m4"
4801 rewritten
='%REWRITTEN%'
4802 sed_rewrite_old_files
="\
4803 s,^build-aux/,$rewritten$auxdir/,
4804 s,^doc/,$rewritten$cached_docbase/,
4805 s,^lib/,$rewritten$cached_sourcebase/,
4806 s,^m4/,$rewritten$cached_m4base/,
4807 s,^tests/,$rewritten$cached_testsbase/,
4808 s,^tests=lib/,$rewritten$cached_testsbase/,
4811 sed_rewrite_new_files
="\
4812 s,^build-aux/,$rewritten$auxdir/,
4813 s,^doc/,$rewritten$docbase/,
4814 s,^lib/,$rewritten$sourcebase/,
4815 s,^m4/,$rewritten$m4base/,
4816 s,^tests/,$rewritten$testsbase/,
4817 s,^tests=lib/,$rewritten$testsbase/,
4821 # Create directories.
4822 { echo "$sourcebase"
4824 if test -n "$pobase"; then
4827 docfiles
=`echo "$files" | sed -n -e 's,^doc/,,p'`
4828 if test -n "$docfiles"; then
4835 for f
in $files; do echo $f; done \
4836 |
sed -e "$sed_rewrite_new_files" \
4837 |
sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4840 { # Rearrange file descriptors. Needed because "while ... done < ..."
4841 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4842 exec 5<&0 < "$tmp"/dirs
4844 if test ! -d "$destdir/$d"; then
4846 echo "Creating directory $destdir/$d"
4847 mkdir
-p "$destdir/$d" || func_fatal_error
"failed"
4849 echo "Create directory $destdir/$d"
4856 # Copy files or make symbolic links. Remove obsolete files.
4860 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4861 # representing the files according to the last gnulib-tool invocation.
4862 for f
in $old_files; do echo $f; done \
4863 |
sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
4866 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4867 # representing the files after this gnulib-tool invocation.
4868 for f
in $new_files; do echo $f; done \
4869 |
sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
4872 # First the files that are in old-files, but not in new-files:
4873 sed_take_first_column
='s,'"$delimiter"'.*,,'
4874 for g
in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
4875 # Remove the file. Do nothing if the user already removed it.
4876 if test -f "$destdir/$g" ||
test -h "$destdir/$g"; then
4878 echo "Removing file $g (backup in ${g}~)"
4879 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error
"failed"
4881 echo "Remove file $g (backup in ${g}~)"
4883 func_append removed_files
"$g$nl"
4886 # func_add_or_update handles a file that ought to be present afterwards.
4888 # - f the original file name
4889 # - g the rewritten file name
4890 # - already_present nonempty if the file should already exist, empty
4892 func_add_or_update
()
4896 tests
=lib
/*) f
=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
4900 *.class |
*.mo
) is_binary_file
=true
;;
4902 func_dest_tmpfilename
"$g"
4903 func_lookup_file
"$f"
4904 cp "$lookedup_file" "$tmpfile" || func_fatal_error
"failed"
4905 if test -n "$sed_transform_main_lib_file" \
4906 && test -z "$is_binary_file"; then
4909 sed -e "$sed_transform_main_lib_file" \
4910 < "$lookedup_file" > "$tmpfile" || func_fatal_error
"failed"
4914 if test -n "$sed_transform_build_aux_file" \
4915 && test -z "$is_binary_file"; then
4918 sed -e "$sed_transform_build_aux_file" \
4919 < "$lookedup_file" > "$tmpfile" || func_fatal_error
"failed"
4923 if test -n "$sed_transform_testsrelated_lib_file" \
4924 && test -z "$is_binary_file"; then
4927 sed -e "$sed_transform_testsrelated_lib_file" \
4928 < "$lookedup_file" > "$tmpfile" || func_fatal_error
"failed"
4932 if test -f "$destdir/$g"; then
4933 # The file already exists.
4937 # Don't protest if the file should be there but isn't: it happens
4938 # frequently that developers don't put autogenerated files under version control.
4940 func_append added_files
"$g$nl"
4944 # Then the files that are in new-files, but not in old-files:
4945 sed_take_last_column
='s,^.*'"$delimiter"',,'
4947 LC_ALL
=C
join -t"$delimiter" -v2 "$tmp"/old-files
"$tmp"/new-files \
4948 |
sed -e "$sed_take_last_column" \
4949 |
sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
4950 { # Rearrange file descriptors. Needed because "while ... done < ..."
4951 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4952 exec 5<&0 < "$tmp"/added-files
4958 # Then the files that are in new-files and in old-files:
4959 already_present
=true
4960 LC_ALL
=C
join -t"$delimiter" "$tmp"/old-files
"$tmp"/new-files \
4961 |
sed -e "$sed_take_last_column" \
4962 |
sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
4963 { # Rearrange file descriptors. Needed because "while ... done < ..."
4964 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4965 exec 5<&0 < "$tmp"/kept-files
4972 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
4973 actioncmd
="gnulib-tool --import"
4976 func_append_local_dir
()
4978 func_append
"$1" " --local-dir=$2"
4980 func_path_foreach
"$local_gnulib_path" func_append_local_dir actioncmd
%dir
%
4982 func_append actioncmd
" --lib=$libname"
4983 func_append actioncmd
" --source-base=$sourcebase"
4984 func_append actioncmd
" --m4-base=$m4base"
4985 if test -n "$pobase"; then
4986 func_append actioncmd
" --po-base=$pobase"
4988 func_append actioncmd
" --doc-base=$docbase"
4989 func_append actioncmd
" --tests-base=$testsbase"
4990 func_append actioncmd
" --aux-dir=$auxdir"
4992 func_append actioncmd
" --with-tests"
4994 if test -n "$incobsolete"; then
4995 func_append actioncmd
" --with-obsolete"
4997 if test -n "$inc_cxx_tests"; then
4998 func_append actioncmd
" --with-c++-tests"
5000 if test -n "$inc_longrunning_tests"; then
5001 func_append actioncmd
" --with-longrunning-tests"
5003 if test -n "$inc_privileged_tests"; then
5004 func_append actioncmd
" --with-privileged-tests"
5006 if test -n "$inc_unportable_tests"; then
5007 func_append actioncmd
" --with-unportable-tests"
5009 if test -n "$inc_all_tests"; then
5010 func_append actioncmd
" --with-all-tests"
5012 for module
in $avoidlist; do
5013 func_append actioncmd
" --avoid=$module"
5015 if test -n "$lgpl"; then
5016 if test "$lgpl" = yes; then
5017 func_append actioncmd
" --lgpl"
5019 func_append actioncmd
" --lgpl=$lgpl"
5022 if test -n "$makefile_name"; then
5023 func_append actioncmd
" --makefile-name=$makefile_name"
5025 if test "$cond_dependencies" = true
; then
5026 func_append actioncmd
" --conditional-dependencies"
5028 func_append actioncmd
" --no-conditional-dependencies"
5030 if test "$libtool" = true
; then
5031 func_append actioncmd
" --libtool"
5033 func_append actioncmd
" --no-libtool"
5035 func_append actioncmd
" --macro-prefix=$macro_prefix"
5036 if test -n "$po_domain"; then
5037 func_append actioncmd
" --po-domain=$po_domain"
5039 if test -n "$witness_c_macro"; then
5040 func_append actioncmd
" --witness-c-macro=$witness_c_macro"
5042 if test -n "$vc_files"; then
5043 if test "$vc_files" = true
; then
5044 func_append actioncmd
" --vc-files"
5046 func_append actioncmd
" --no-vc-files"
5049 func_append actioncmd
" `echo $specified_modules`"
5051 # Determine include_guard_prefix.
5052 func_compute_include_guard_prefix
5054 # Default the makefile name to Makefile.am.
5055 if test -n "$makefile_name"; then
5056 makefile_am
=$makefile_name
5058 makefile_am
=Makefile.am
5061 # Create normal Makefile.ams.
5064 # Setup list of Makefile.am edits that are to be performed afterwards.
5065 # Some of these edits apply to files that we will generate; others are
5066 # under the responsibility of the developer.
5068 # func_note_Makefile_am_edit dir var value
5069 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
5071 func_note_Makefile_am_edit
()
5073 makefile_am_edits
=`expr $makefile_am_edits + 1`
5074 eval makefile_am_edit
${makefile_am_edits}_dir
=\"\
$1\"
5075 eval makefile_am_edit
${makefile_am_edits}_var
=\"\
$2\"
5076 eval makefile_am_edit
${makefile_am_edits}_val
=\"\
$3\"
5078 if test "$makefile_am" = Makefile.am
; then
5079 sourcebase_dir
=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
5080 sourcebase_base
=`basename "$sourcebase"`
5081 func_note_Makefile_am_edit
"$sourcebase_dir" SUBDIRS
"$sourcebase_base"
5083 if test -n "$pobase"; then
5084 pobase_dir
=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
5085 pobase_base
=`basename "$pobase"`
5086 func_note_Makefile_am_edit
"$pobase_dir" SUBDIRS
"$pobase_base"
5089 if test "$makefile_am" = Makefile.am
; then
5090 testsbase_dir
=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
5091 testsbase_base
=`basename "$testsbase"`
5092 func_note_Makefile_am_edit
"$testsbase_dir" SUBDIRS
"$testsbase_base"
5095 func_note_Makefile_am_edit
"" ACLOCAL_AMFLAGS
"-I ${m4base}"
5097 # Find the first parent directory of $m4base that contains or will contain
5099 sed_last
='s,^.*/\([^/][^/]*\)//*$,\1/,
5101 sed_butlast
='s,[^/][^/]*//*$,,'
5102 dir1
="${m4base}/"; dir2
=""
5103 while test -n "$dir1" \
5104 && ! { test -f "${destdir}/${dir1}Makefile.am" \
5105 ||
test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
5106 ||
test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
5108 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
5109 ||
test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
5110 dir2
=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
5111 dir1
=`echo "$dir1" | sed -e "$sed_butlast"`
5113 func_note_Makefile_am_edit
"$dir1" EXTRA_DIST
"${dir2}gnulib-cache.m4"
5116 # Create library makefile.
5117 func_dest_tmpfilename
$sourcebase/$makefile_am
5118 destfile
="$sourcebase/$makefile_am"
5119 modules
="$main_modules"
5120 func_emit_lib_Makefile_am
> "$tmpfile"
5121 if test -f "$destdir"/$sourcebase/$makefile_am; then
5122 if cmp -s "$destdir"/$sourcebase/$makefile_am "$tmpfile"; then
5126 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
5127 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
5128 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
5130 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
5136 echo "Creating $sourcebase/$makefile_am"
5137 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
5139 echo "Create $sourcebase/$makefile_am"
5142 func_append added_files
"$sourcebase/$makefile_am$nl"
5145 # Create po/ directory.
5146 if test -n "$pobase"; then
5147 # Create po makefile and auxiliary files.
5148 for file in Makefile.
in.
in remove-potcdate.sin
; do
5149 func_dest_tmpfilename
$pobase/$file
5150 func_lookup_file build-aux
/po
/$file
5151 cat "$lookedup_file" > "$tmpfile"
5152 if test -f "$destdir"/$pobase/$file; then
5153 if cmp -s "$destdir"/$pobase/$file "$tmpfile"; then
5157 echo "Updating $pobase/$file (backup in $pobase/$file~)"
5158 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
5159 mv -f "$tmpfile" "$destdir"/$pobase/$file
5161 echo "Update $pobase/$file (backup in $pobase/$file~)"
5167 echo "Creating $pobase/$file"
5168 mv -f "$tmpfile" "$destdir"/$pobase/$file
5170 echo "Create $pobase/$file"
5173 func_append added_files
"$pobase/$file$nl"
5176 # Create po makefile parameterization, part 1.
5177 func_dest_tmpfilename
$pobase/Makevars
5178 func_emit_po_Makevars
> "$tmpfile"
5179 if test -f "$destdir"/$pobase/Makevars
; then
5180 if cmp -s "$destdir"/$pobase/Makevars
"$tmpfile"; then
5184 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
5185 mv -f "$destdir"/$pobase/Makevars
"$destdir"/$pobase/Makevars~
5186 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5188 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
5194 echo "Creating $pobase/Makevars"
5195 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5197 echo "Create $pobase/Makevars"
5200 func_append added_files
"$pobase/Makevars$nl"
5202 # Create po makefile parameterization, part 2.
5203 func_dest_tmpfilename
$pobase/POTFILES.
in
5204 func_emit_po_POTFILES_in
> "$tmpfile"
5205 if test -f "$destdir"/$pobase/POTFILES.
in; then
5206 if cmp -s "$destdir"/$pobase/POTFILES.
in "$tmpfile"; then
5210 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5211 mv -f "$destdir"/$pobase/POTFILES.
in "$destdir"/$pobase/POTFILES.
in~
5212 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.
in
5214 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5220 echo "Creating $pobase/POTFILES.in"
5221 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.
in
5223 echo "Create $pobase/POTFILES.in"
5226 func_append added_files
"$pobase/POTFILES.in$nl"
5229 TP_URL
="http://translationproject.org/latest/"
5230 TP_RSYNC_URI
="translationproject.org::tp/latest/"
5232 echo "Fetching gnulib PO files from $TP_URL"
5233 (cd "$destdir"/$pobase \
5234 && { # Prefer rsync over wget if it is available, since it consumes
5235 # less network bandwidth, due to compression.
5236 if type rsync
2>/dev
/null |
grep / > /dev
/null
; then
5237 rsync
--delete --exclude "*.s1" -Lrtz "${TP_RSYNC_URI}gnulib/" .
&& return
5240 wget
--no-verbose --mirror -nd -np -A.po
-P .
"${TP_URL}gnulib/"
5244 echo "Fetch gnulib PO files from $TP_URL"
5246 # Create po/LINGUAS.
5248 func_dest_tmpfilename
$pobase/LINGUAS
5249 (cd "$destdir"/$pobase \
5250 && { echo '# Set of available languages.'
5251 LC_ALL
=C
ls -1 *.po |
sed -e 's,\.po$,,'
5254 if test -f "$destdir"/$pobase/LINGUAS
; then
5255 if cmp -s "$destdir"/$pobase/LINGUAS
"$tmpfile"; then
5258 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5259 mv -f "$destdir"/$pobase/LINGUAS
"$destdir"/$pobase/LINGUAS~
5260 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5263 echo "Creating $pobase/LINGUAS"
5264 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5265 func_append added_files
"$pobase/LINGUAS$nl"
5268 if test -f "$destdir"/$pobase/LINGUAS
; then
5269 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5271 echo "Create $pobase/LINGUAS"
5276 # func_count_relative_local_gnulib_path
5277 # gl_LOCAL_DIR requires local_gnulib_path to be set relatively to destdir
5279 # - local_gnulib_path from --local-dir
5280 # - destdir from --dir
5282 # - relative_local_dir path to be stored into gl_LOCAL_DIR
5283 func_count_relative_local_gnulib_path
()
5287 relative_local_gnulib_path
=
5288 for local_dir
in $local_gnulib_path
5290 # Store the local_dir relative to destdir.
5291 case "$local_dir" in
5293 relative_local_dir
="$local_dir" ;;
5296 /*) relative_local_dir
="$local_dir" ;;
5298 # destdir, local_dir are both relative.
5299 func_relativize
"$destdir" "$local_dir"
5300 relative_local_dir
="$reldir" ;;
5303 func_path_append relative_local_gnulib_path
"$relative_local_dir"
5308 # Create m4/gnulib-cache.m4.
5309 func_dest_tmpfilename
$m4base/gnulib-cache.
m4
5311 func_emit_copyright_notice
5313 echo "# This file represents the specification of how gnulib-tool is used."
5314 echo "# It acts as a cache: It is written and read by gnulib-tool."
5315 echo "# In projects that use version control, this file is meant to be put under"
5316 echo "# version control, like the configure.ac and various Makefile.am files."
5319 echo "# Specification in the form of a command-line invocation:"
5322 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
5323 func_count_relative_local_gnulib_path
5324 echo "gl_LOCAL_DIR([$relative_local_gnulib_path])"
5326 echo "$specified_modules" |
sed -e 's/^/ /g'
5328 test -z "$incobsolete" ||
echo "gl_WITH_OBSOLETE"
5329 test -z "$inc_cxx_tests" ||
echo "gl_WITH_CXX_TESTS"
5330 test -z "$inc_longrunning_tests" ||
echo "gl_WITH_LONGRUNNING_TESTS"
5331 test -z "$inc_privileged_tests" ||
echo "gl_WITH_PRIVILEGED_TESTS"
5332 test -z "$inc_unportable_tests" ||
echo "gl_WITH_UNPORTABLE_TESTS"
5333 test -z "$inc_all_tests" ||
echo "gl_WITH_ALL_TESTS"
5334 echo "gl_AVOID([$avoidlist])"
5335 echo "gl_SOURCE_BASE([$sourcebase])"
5336 echo "gl_M4_BASE([$m4base])"
5337 echo "gl_PO_BASE([$pobase])"
5338 echo "gl_DOC_BASE([$docbase])"
5339 echo "gl_TESTS_BASE([$testsbase])"
5341 echo "gl_WITH_TESTS"
5343 echo "gl_LIB([$libname])"
5344 if test -n "$lgpl"; then
5345 if test "$lgpl" = yes; then
5348 echo "gl_LGPL([$lgpl])"
5351 echo "gl_MAKEFILE_NAME([$makefile_name])"
5352 if test "$cond_dependencies" = true
; then
5353 echo "gl_CONDITIONAL_DEPENDENCIES"
5355 if test "$libtool" = true
; then
5358 echo "gl_MACRO_PREFIX([$macro_prefix])"
5359 echo "gl_PO_DOMAIN([$po_domain])"
5360 echo "gl_WITNESS_C_MACRO([$witness_c_macro])"
5361 if test -n "$vc_files"; then
5362 echo "gl_VC_FILES([$vc_files])"
5365 if test -f "$destdir"/$m4base/gnulib-cache.
m4; then
5366 if cmp -s "$destdir"/$m4base/gnulib-cache.
m4 "$tmpfile"; then
5370 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5371 mv -f "$destdir"/$m4base/gnulib-cache.
m4 "$destdir"/$m4base/gnulib-cache.
m4~
5372 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.
m4
5374 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5378 echo "# gnulib-cache.m4 ends here"
5385 echo "Creating $m4base/gnulib-cache.m4"
5386 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.
m4
5388 echo "Create $m4base/gnulib-cache.m4"
5394 # Create m4/gnulib-comp.m4.
5395 func_dest_tmpfilename
$m4base/gnulib-comp.
m4
5397 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
5398 func_emit_copyright_notice
5400 echo "# This file represents the compiled summary of the specification in"
5401 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
5402 echo "# to be invoked from configure.ac."
5403 echo "# In projects that use version control, this file can be treated like"
5404 echo "# other built files."
5407 echo "# This macro should be invoked from $configure_ac, in the section"
5408 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
5409 echo "# any checks for libraries, header files, types and library functions."
5410 echo "AC_DEFUN([${macro_prefix}_EARLY],"
5412 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5413 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5414 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5415 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5417 func_emit_pre_early_macros
: ' ' "$final_modules"
5419 if test -n "$uses_subdirs"; then
5420 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
5422 for module
in $final_modules; do
5424 if test -n "$module"; then
5425 echo "# Code from module $module:"
5426 func_get_autoconf_early_snippet
"$module"
5429 |
sed -e '/^$/d;' -e 's/^/ /'
5432 echo "# This macro should be invoked from $configure_ac, in the section"
5433 echo "# \"Check for header files, types and library functions\"."
5434 echo "AC_DEFUN([${macro_prefix}_INIT],"
5436 if test "$libtool" = true
; then
5437 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5438 echo " gl_cond_libtool=true"
5440 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5441 echo " gl_cond_libtool=false"
5443 echo " gl_ltlibdeps="
5445 if test "$auxdir" != "build-aux"; then
5446 sed_replace_build_aux
='
5448 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5449 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5453 sed_replace_build_aux
="$sed_noop"
5455 echo " gl_m4_base='$m4base'"
5456 func_emit_initmacro_start
$macro_prefix
5457 echo " gl_source_base='$sourcebase'"
5458 if test -n "$witness_c_macro"; then
5459 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
5461 func_emit_autoconf_snippets
"$main_modules" func_verify_module true false true
5462 if test -n "$witness_c_macro"; then
5463 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5465 echo " # End of code from modules"
5466 func_emit_initmacro_end
$macro_prefix
5467 echo " gltests_libdeps="
5468 echo " gltests_ltlibdeps="
5469 func_emit_initmacro_start
${macro_prefix}tests
5470 echo " gl_source_base='$testsbase'"
5471 # Define a tests witness macro that depends on the package.
5472 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
5473 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
5474 echo "changequote(,)dnl"
5475 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"
5476 echo "changequote([, ])dnl"
5477 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5478 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5479 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5480 func_emit_autoconf_snippets
"$testsrelated_modules" func_verify_module true true true
5481 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5482 func_emit_initmacro_end
${macro_prefix}tests
5483 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5484 # created using libtool, because libtool already handles the dependencies.
5485 if test "$libtool" != true
; then
5486 libname_upper
=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5487 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5488 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5489 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5490 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5492 if $use_libtests; then
5493 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5494 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5497 func_emit_initmacro_done
$macro_prefix $sourcebase
5498 func_emit_initmacro_done
${macro_prefix}tests
$testsbase
5500 echo "# This macro records the list of files which have been installed by"
5501 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
5502 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
5503 echo "$files" |
sed -e 's,^, ,'
5506 if test -f "$destdir"/$m4base/gnulib-comp.
m4; then
5507 if cmp -s "$destdir"/$m4base/gnulib-comp.
m4 "$tmpfile"; then
5511 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5512 mv -f "$destdir"/$m4base/gnulib-comp.
m4 "$destdir"/$m4base/gnulib-comp.
m4~
5513 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.
m4
5515 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5519 echo "# gnulib-comp.m4 ends here"
5526 echo "Creating $m4base/gnulib-comp.m4"
5527 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.
m4
5529 echo "Create $m4base/gnulib-comp.m4"
5536 # Create tests makefile.
5537 func_dest_tmpfilename
$testsbase/$makefile_am
5538 destfile
="$testsbase/$makefile_am"
5539 modules
="$testsrelated_modules"
5540 func_emit_tests_Makefile_am
"${macro_prefix}tests_WITNESS" > "$tmpfile"
5541 if test -f "$destdir"/$testsbase/$makefile_am; then
5542 if cmp -s "$destdir"/$testsbase/$makefile_am "$tmpfile"; then
5546 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5547 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
5548 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5550 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5556 echo "Creating $testsbase/$makefile_am"
5557 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5559 echo "Create $testsbase/$makefile_am"
5562 func_append added_files
"$testsbase/$makefile_am$nl"
5566 if test "$vc_files" != false
; then
5567 # Update the .cvsignore and .gitignore files.
5568 { echo "$added_files" |
sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
5569 echo "$removed_files" |
sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
5570 # Treat gnulib-comp.m4 like an added file, even if it already existed.
5571 echo "$m4base/|A|gnulib-comp.m4"
5572 } | LC_ALL
=C
sort -t'|' -k1,1 > "$tmp"/fileset-changes
5573 { # Rearrange file descriptors. Needed because "while ... done < ..."
5574 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5575 exec 5<&0 < "$tmp"/fileset-changes
5576 func_update_ignorelist
()
5579 if test "$ignore" = .gitignore
; then
5580 # In a .gitignore file, "foo" applies to the current directory and all
5581 # subdirectories, whereas "/foo" applies to the current directory only.
5584 doubly_escaped_anchor
='\\/'
5588 doubly_escaped_anchor
=''
5590 if test -f "$destdir/$dir$ignore"; then
5591 if test -n "$dir_added" ||
test -n "$dir_removed"; then
5592 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL
=C
sort > "$tmp"/ignore
5593 (echo "$dir_added" |
sed -e '/^$/d' | LC_ALL
=C
sort -u \
5594 | LC_ALL
=C
join -v 1 - "$tmp"/ignore
> "$tmp"/ignore-added
5595 echo "$dir_removed" |
sed -e '/^$/d' | LC_ALL
=C
sort -u \
5596 > "$tmp"/ignore-removed
5598 if test -s "$tmp"/ignore-added ||
test -s "$tmp"/ignore-removed
; then
5600 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5601 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
5602 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
5603 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed
; fi
5604 } > "$tmp"/sed-ignore-removed
5605 { cat "$destdir/$dir$ignore"~
5606 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
5607 } |
sed -f "$tmp"/sed-ignore-removed \
5608 > "$destdir/$dir$ignore"
5610 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5615 if test -n "$dir_added"; then
5617 echo "Creating $destdir/$dir$ignore"
5619 if test "$ignore" = .cvsignore
; then
5621 # Automake generates Makefile rules that create .dirstamp files.
5624 echo "$dir_added" |
sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL
=C
sort -u
5625 } > "$destdir/$dir$ignore"
5627 echo "Create $destdir/$dir$ignore"
5637 if test -d "$destdir/CVS" ||
test -d "$destdir/${dir}CVS" ||
test -f "$destdir/${dir}.cvsignore"; then
5638 func_update_ignorelist .cvsignore
5640 if test -d "$destdir/.git" ||
test -f "$destdir/${dir}.gitignore"; then
5641 func_update_ignorelist .gitignore
5648 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
5649 next_dir
=`echo "$line" | sed -e 's,|.*,,'`
5650 op
=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
5651 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
5652 if test "$next_dir" != "$last_dir"; then
5653 func_done_dir
"$last_dir" "$last_dir_added" "$last_dir_removed"
5654 last_dir
="$next_dir"
5659 A
) func_append last_dir_added
"$file$nl";;
5660 R
) func_append last_dir_removed
"$file$nl";;
5663 func_done_dir
"$last_dir" "$last_dir_added" "$last_dir_removed"
5670 echo "You may need to add #include directives for the following .h files."
5671 # Intersect $specified_modules and $main_modules
5672 # (since $specified_modules is not necessarily of subset of $main_modules
5673 # - some may have been skipped through --avoid, and since the elements of
5674 # $main_modules but not in $specified_modules can go away without explicit
5675 # notice - through changes in the module dependencies).
5676 echo "$specified_modules" > "$tmp"/modules1
# a sorted list, one module per line
5677 echo "$main_modules" > "$tmp"/modules2
# also a sorted list, one module per line
5678 # First the #include <...> directives without #ifs, sorted for convenience,
5679 # then the #include "..." directives without #ifs, sorted for convenience,
5680 # then the #include directives that are surrounded by #ifs. Not sorted.
5681 for module
in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
5682 include_directive
=`func_get_include_directive "$module"`
5683 case "$nl$include_directive" in
5685 echo "$include_directive" 1>&5
5688 echo "$include_directive" |
grep -v 'include "' 1>&6
5689 echo "$include_directive" |
grep 'include "' 1>&7
5692 done 5> "$tmp"/include-if
6> "$tmp"/include-angles
7> "$tmp"/include-quotes
5694 LC_ALL
=C
sort -u "$tmp"/include-angles
5695 LC_ALL
=C
sort -u "$tmp"/include-quotes
5696 cat "$tmp"/include-if
5697 ) |
sed -e '/^$/d' -e 's/^/ /'
5698 rm -f "$tmp"/include-angles
"$tmp"/include-quotes
"$tmp"/include-if
5700 for module
in $main_modules; do
5701 func_get_link_directive
"$module"
5703 | LC_ALL
=C
sort -u |
sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
5704 if test `wc -l < "$tmp"/link` != 0; then
5706 echo "You may need to use the following Makefile variables when linking."
5707 echo "Use them in <program>_LDADD when linking a program, or"
5708 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
5714 echo "Don't forget to"
5715 if test "$makefile_am" = Makefile.am
; then
5716 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5718 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
5720 if test -n "$pobase"; then
5721 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
5724 if test "$makefile_am" = Makefile.am
; then
5725 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5727 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
5731 while test $edit != $makefile_am_edits; do
5732 edit
=`expr $edit + 1`
5733 eval dir
=\"\
$makefile_am_edit${edit}_dir
\"
5734 eval var
=\"\
$makefile_am_edit${edit}_var
\"
5735 eval val
=\"\
$makefile_am_edit${edit}_val
\"
5736 if test -n "$var"; then
5737 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
5740 if grep '^ *AC_PROG_CC_STDC' "$configure_ac" > /dev
/null
; then
5741 position_early_after
=AC_PROG_CC_STDC
5743 if grep '^ *AC_PROG_CC_C99' "$configure_ac" > /dev
/null
; then
5744 position_early_after
=AC_PROG_CC_C99
5746 position_early_after
=AC_PROG_CC
5749 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after $position_early_after,"
5750 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
5753 # func_create_testdir testdir modules
5755 # - local_gnulib_path from --local-dir
5756 # - modcache true or false, from --cache-modules/--no-cache-modules
5757 # - auxdir directory relative to destdir where to place build aux files
5758 # - inctests true if tests should be included, false otherwise
5759 # - incobsolete true if obsolete modules among dependencies should be
5760 # included, blank otherwise
5761 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
5763 # - excl_longrunning_tests true if long-runnings tests should be excluded,
5765 # - excl_privileged_tests true if tests that require root privileges should be
5766 # excluded, blank otherwise
5767 # - excl_unportable_tests true if tests that fail on some platforms should be
5768 # excluded, blank otherwise
5769 # - single_configure true if a single configure file should be generated,
5770 # false for a separate configure file for the tests
5771 # - avoidlist list of modules to avoid
5772 # - cond_dependencies true if --conditional-dependencies was given, false if
5773 # --no-conditional-dependencies was given, blank otherwise
5774 # - libtool true if --libtool was given, false if --no-libtool was
5775 # given, blank otherwise
5776 # - symbolic true if files should be symlinked, copied otherwise
5777 # - lsymbolic true if files from local_gnulib_path should be symlinked,
5779 func_create_testdir
()
5783 if test -z "$modules"; then
5784 # All modules together.
5785 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5786 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
5787 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
5788 modules
=`func_all_modules`
5789 modules
=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
5791 specified_modules
="$modules"
5793 # Canonicalize the list of specified modules.
5794 specified_modules
=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
5796 # Unlike in func_import, here we want to include all kinds of tests for the
5797 # directly specified modules, but not for dependencies.
5798 inc_all_direct_tests
=true
5799 inc_all_indirect_tests
="$inc_all_tests"
5801 # Check that the license of every module is consistent with the license of
5803 saved_inctests
="$inctests"
5804 # When computing transitive closures, don't consider $module to depend on
5805 # $module-tests. Need this because tests are implicitly GPL and may depend
5806 # on GPL modules - therefore we don't want a warning in this case.
5808 for requested_module
in $specified_modules; do
5809 requested_license
=`func_get_license "$requested_module"`
5810 if test "$requested_license" != GPL
; then
5811 # Here we use func_modules_transitive_closure, not just
5812 # func_get_dependencies, so that we also detect weird situations like
5813 # an LGPL module which depends on a GPLed build tool module which depends
5815 modules
="$requested_module"
5816 func_modules_transitive_closure
5817 for module
in $modules; do
5818 license
=`func_get_license "$module"`
5820 'GPLed build tool') ;;
5821 'public domain' |
'unlimited' |
'unmodifiable license text') ;;
5823 case "$requested_license" in
5826 GPLv2
+ | LGPLv2
+) ;;
5827 *) func_warning
"module $requested_module depends on a module with an incompatible license: $module" ;;
5833 *) func_warning
"module $requested_module depends on a module with an incompatible license: $module" ;;
5839 *) func_warning
"module $requested_module depends on a module with an incompatible license: $module" ;;
5848 inctests
="$saved_inctests"
5850 # Subdirectory names.
5861 # Determine final module list.
5862 modules
="$specified_modules"
5863 func_modules_transitive_closure
5864 if test $verbose -ge 0; then
5865 func_show_module_list
5867 final_modules
="$modules"
5869 if $single_configure; then
5870 # Determine main module list and tests-related module list separately.
5871 func_modules_transitive_closure_separately
5874 if $single_configure; then
5875 # Determine whether a $testsbase/libtests.a is needed.
5876 func_determine_use_libtests
5879 # Add the dummy module if needed.
5880 if $single_configure; then
5881 func_modules_add_dummy_separately
5883 func_modules_add_dummy
5886 # Show banner notice of every module.
5887 if $single_configure; then
5888 modules
="$main_modules"
5894 # Determine final file list.
5895 if $single_configure; then
5896 func_modules_to_filelist_separately
5898 func_modules_to_filelist
5899 if test $verbose -ge 0; then
5901 echo "$files" |
sed -e 's/^/ /'
5904 # Add files for which the copy in gnulib is newer than the one that
5905 # "automake --add-missing --copy" would provide.
5906 files
="$files build-aux/config.guess"
5907 files
="$files build-aux/config.sub"
5908 files
=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
5910 rewritten
='%REWRITTEN%'
5911 sed_rewrite_files
="\
5912 s,^build-aux/,$rewritten$auxdir/,
5913 s,^doc/,$rewritten$docbase/,
5914 s,^lib/,$rewritten$sourcebase/,
5915 s,^m4/,$rewritten$m4base/,
5916 s,^tests/,$rewritten$testsbase/,
5917 s,^tests=lib/,$rewritten$testsbase/,
5921 # Create directories.
5922 for f
in $files; do echo $f; done \
5923 |
sed -e "$sed_rewrite_files" \
5924 |
sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5925 | LC_ALL
=C
sort -u \
5927 { # Rearrange file descriptors. Needed because "while ... done < ..."
5928 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5929 exec 5<&0 < "$tmp"/dirs
5931 mkdir
-p "$testdir/$d"
5936 # Copy files or make symbolic links.
5938 for f
in $files; do echo $f; done \
5939 |
sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
5942 { # Rearrange file descriptors. Needed because "while ... done < ..."
5943 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5944 exec 5<&0 < "$tmp"/files
5947 tests
=lib
/*) f
=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
5949 func_lookup_file
"$f"
5950 if test -n "$lookedup_tmp"; then
5951 cp -p "$lookedup_file" "$testdir/$g"
5953 ln "$lookedup_file" "$testdir/$g" 2>/dev
/null ||
5954 if func_should_symlink
; then
5955 func_ln
"$lookedup_file" "$testdir/$g"
5957 cp -p "$lookedup_file" "$testdir/$g"
5964 # Determine include_guard_prefix.
5965 func_compute_include_guard_prefix
5967 # Create Makefile.ams that are for testing.
5970 # No special edits are needed.
5973 # Create $sourcebase/Makefile.am.
5974 mkdir
-p "$testdir/$sourcebase"
5975 destfile
="$sourcebase/Makefile.am"
5976 if $single_configure; then
5977 modules
="$main_modules"
5979 func_emit_lib_Makefile_am
> "$testdir/$sourcebase/Makefile.am"
5980 any_uses_subdirs
="$uses_subdirs"
5982 # Create $m4base/Makefile.am.
5983 mkdir
-p "$testdir/$m4base"
5984 (echo "## Process this file with automake to produce Makefile.in."
5990 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
5993 ) > "$testdir/$m4base/Makefile.am"
5995 subdirs
="$sourcebase $m4base"
5996 subdirs_with_configure_ac
=""
5998 if false
&& test -f "$testdir"/$m4base/gettext.
m4; then
5999 # Avoid stupid error message from automake:
6000 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
6001 mkdir
-p "$testdir/po"
6002 (echo "## Process this file with automake to produce Makefile.in."
6003 ) > "$testdir/po/Makefile.am"
6004 func_append subdirs
" po"
6008 test -d "$testdir/$testsbase" || mkdir
"$testdir/$testsbase"
6009 if $single_configure; then
6010 # Create $testsbase/Makefile.am.
6011 destfile
="$testsbase/Makefile.am"
6012 modules
="$testsrelated_modules"
6013 func_emit_tests_Makefile_am
"${macro_prefix}tests_WITNESS" > "$testdir/$testsbase/Makefile.am"
6015 # Viewed from the $testsbase subdirectory, $auxdir is different.
6016 saved_auxdir
="$auxdir"
6017 auxdir
=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
6018 # Create $testsbase/Makefile.am.
6020 destfile
="$testsbase/Makefile.am"
6021 func_emit_tests_Makefile_am
"" > "$testdir/$testsbase/Makefile.am"
6022 any_uses_subdirs
="$any_uses_subdirs$uses_subdirs"
6023 # Create $testsbase/configure.ac.
6024 (echo "# Process this file with autoconf to produce a configure script."
6025 echo "AC_INIT([dummy], [0])"
6026 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6027 echo "AM_INIT_AUTOMAKE"
6029 echo "AC_CONFIG_HEADERS([config.h])"
6032 echo "AC_PROG_INSTALL"
6033 echo "AC_PROG_MAKE_SET"
6035 func_emit_pre_early_macros false
'' "$modules"
6037 if test -n "$uses_subdirs"; then
6038 echo "AM_PROG_CC_C_O"
6041 for module
in $modules; do
6043 if test -n "$module"; then
6045 gnumakefile | maintainer-makefile
)
6046 # These modules are meant to be used only in the top-level directory.
6049 func_get_autoconf_early_snippet
"$module"
6054 |
sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
6055 if test "$libtool" = true
; then
6056 echo "LT_INIT([win32-dll])"
6057 echo "LT_LANG([C++])"
6058 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6059 echo "gl_cond_libtool=true"
6061 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6062 echo "gl_cond_libtool=false"
6064 echo "gl_ltlibdeps="
6066 # Wrap the set of autoconf snippets into an autoconf macro that is then
6067 # invoked. This is needed because autoconf does not support AC_REQUIRE
6069 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6070 # but we want the AC_REQUIRE to have its normal meaning (provide one
6071 # expansion of the required macro before the current point, and only one
6073 echo "AC_DEFUN([gl_INIT], ["
6074 sed_replace_build_aux
='
6076 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6077 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6080 echo "gl_m4_base='../$m4base'"
6081 func_emit_initmacro_start
$macro_prefix
6082 # We don't have explicit ordering constraints between the various
6083 # autoconf snippets. It's cleanest to put those of the library before
6084 # those of the tests.
6085 echo "gl_source_base='../$sourcebase'"
6086 func_emit_autoconf_snippets
"$modules" func_verify_nontests_module false false false
6087 echo "gl_source_base='.'"
6088 func_emit_autoconf_snippets
"$modules" func_verify_tests_module false false false
6089 func_emit_initmacro_end
$macro_prefix
6090 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6091 # created using libtool, because libtool already handles the dependencies.
6092 if test "$libtool" != true
; then
6093 libname_upper
=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6094 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6095 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6096 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6097 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6100 func_emit_initmacro_done
$macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
6104 # Usually $testsbase/config.h will be a superset of config.h. Verify this
6105 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
6106 echo "AH_TOP([#include \"../config.h\"])"
6108 echo "AC_CONFIG_FILES([Makefile])"
6110 ) > "$testdir/$testsbase/configure.ac"
6111 auxdir
="$saved_auxdir"
6112 subdirs_with_configure_ac
="$subdirs_with_configure_ac $testsbase"
6114 func_append subdirs
" $testsbase"
6117 # Create Makefile.am.
6118 (echo "## Process this file with automake to produce Makefile.in."
6120 echo "AUTOMAKE_OPTIONS = 1.9.6 foreign"
6122 echo "SUBDIRS = $subdirs"
6124 echo "ACLOCAL_AMFLAGS = -I $m4base"
6125 ) > "$testdir/Makefile.am"
6127 # Create configure.ac.
6128 (echo "# Process this file with autoconf to produce a configure script."
6129 echo "AC_INIT([dummy], [0])"
6130 if test "$auxdir" != "."; then
6131 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6133 echo "AM_INIT_AUTOMAKE"
6135 echo "AC_CONFIG_HEADERS([config.h])"
6138 echo "AC_PROG_INSTALL"
6139 echo "AC_PROG_MAKE_SET"
6141 echo "# For autobuild."
6142 echo "AC_CANONICAL_BUILD"
6143 echo "AC_CANONICAL_HOST"
6145 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
6146 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
6147 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
6148 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
6150 func_emit_pre_early_macros false
'' "$final_modules"
6152 if test -n "$any_uses_subdirs"; then
6153 echo "AM_PROG_CC_C_O"
6156 for module
in $final_modules; do
6157 if $single_configure; then
6160 func_verify_nontests_module
6162 if test -n "$module"; then
6163 func_get_autoconf_early_snippet
"$module"
6166 |
sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
6167 if test "$libtool" = true
; then
6168 echo "LT_INIT([win32-dll])"
6169 echo "LT_LANG([C++])"
6170 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6171 echo "gl_cond_libtool=true"
6173 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6174 echo "gl_cond_libtool=false"
6176 echo "gl_ltlibdeps="
6178 # Wrap the set of autoconf snippets into an autoconf macro that is then
6179 # invoked. This is needed because autoconf does not support AC_REQUIRE
6181 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6182 # but we want the AC_REQUIRE to have its normal meaning (provide one
6183 # expansion of the required macro before the current point, and only one
6185 echo "AC_DEFUN([gl_INIT], ["
6186 if test "$auxdir" != "build-aux"; then
6187 sed_replace_build_aux
='
6189 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6190 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6194 sed_replace_build_aux
="$sed_noop"
6196 echo "gl_m4_base='$m4base'"
6197 func_emit_initmacro_start
$macro_prefix
6198 echo "gl_source_base='$sourcebase'"
6199 if $single_configure; then
6200 func_emit_autoconf_snippets
"$main_modules" func_verify_module true false false
6202 func_emit_autoconf_snippets
"$modules" func_verify_nontests_module true false false
6204 func_emit_initmacro_end
$macro_prefix
6205 if $single_configure; then
6206 echo " gltests_libdeps="
6207 echo " gltests_ltlibdeps="
6208 func_emit_initmacro_start
${macro_prefix}tests
6209 echo " gl_source_base='$testsbase'"
6210 # Define a tests witness macro.
6211 echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
6212 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
6213 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
6214 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
6215 func_emit_autoconf_snippets
"$testsrelated_modules" func_verify_module true false false
6216 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
6217 func_emit_initmacro_end
${macro_prefix}tests
6219 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6220 # created using libtool, because libtool already handles the dependencies.
6221 if test "$libtool" != true
; then
6222 libname_upper
=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6223 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6224 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6225 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6226 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6228 if $single_configure; then
6229 if $use_libtests; then
6230 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
6231 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
6235 func_emit_initmacro_done
$macro_prefix $sourcebase
6236 if $single_configure; then
6237 func_emit_initmacro_done
${macro_prefix}tests
$testsbase
6242 if test -n "$subdirs_with_configure_ac"; then
6243 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
6245 makefiles
="Makefile"
6246 for d
in $subdirs; do
6247 # For subdirs that have a configure.ac by their own, it's the subdir's
6248 # configure.ac which creates the subdir's Makefile.am, not this one.
6249 case " $subdirs_with_configure_ac " in
6251 *) func_append makefiles
" $d/Makefile" ;;
6254 echo "AC_CONFIG_FILES([$makefiles])"
6256 ) > "$testdir/configure.ac"
6258 # Create autogenerated files.
6260 # Do not use "${AUTORECONF} --force --install", because it may invoke
6261 # autopoint, which brings in older versions of some of our .m4 files.
6262 if test -f $m4base/gettext.
m4; then
6263 func_execute_command
${AUTOPOINT} --force || func_exit
1
6264 for f
in $m4base/*.
m4~
; do
6266 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit
1
6270 if test "$libtool" = true
; then
6271 func_execute_command
${LIBTOOLIZE} --copy || func_exit
1
6273 func_execute_command
${ACLOCAL} -I $m4base || func_exit
1
6274 if ! test -d build-aux
; then
6275 func_execute_command mkdir build-aux || func_exit
1
6277 func_execute_command
${AUTOCONF} || func_exit
1
6278 func_execute_command
${AUTOHEADER} || func_exit
1
6279 func_execute_command
${AUTOMAKE} --add-missing --copy || func_exit
1
6281 if $inctests && ! $single_configure; then
6282 # Create autogenerated files.
6283 (cd "$testdir/$testsbase" || func_exit
1
6284 # Do not use "${AUTORECONF} --force --install", because it may invoke
6285 # autopoint, which brings in older versions of some of our .m4 files.
6286 if test -f ..
/$m4base/gettext.
m4; then
6287 func_execute_command
${AUTOPOINT} --force || func_exit
1
6288 for f
in ..
/$m4base/*.
m4~
; do
6290 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit
1
6294 func_execute_command
${ACLOCAL} -I ..
/$m4base || func_exit
1
6295 if ! test -d ..
/build-aux
; then
6296 func_execute_command mkdir ..
/build-aux
6298 func_execute_command
${AUTOCONF} || func_exit
1
6299 func_execute_command
${AUTOHEADER} || func_exit
1
6300 func_execute_command
${AUTOMAKE} --add-missing --copy || func_exit
1
6303 # Need to run configure and make once, to create built files that are to be
6304 # distributed (such as parse-datetime.c).
6305 sed_remove_make_variables
='s,[$]([A-Za-z0-9_]*),,g'
6306 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
6307 cleaned_files
=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
6308 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6309 cleaned_files
=`for file in $cleaned_files; do echo " $file "; done`
6310 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
6311 # such $(FOO_H) because they don't refer to distributed files.
6312 built_sources
=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
6313 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6314 | sed -e "$sed_remove_make_variables"`
6315 distributed_built_sources
=`for file in $built_sources; do
6316 case "$cleaned_files" in
6321 tests_distributed_built_sources
=
6323 # Likewise for built files in the $testsbase directory.
6324 tests_cleaned_files
=`combine_lines < "$testdir/$testsbase/Makefile.am" \
6325 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6326 tests_cleaned_files
=`for file in $tests_cleaned_files; do echo " $file "; done`
6327 tests_built_sources
=`combine_lines < "$testdir/$testsbase/Makefile.am" \
6328 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6329 | sed -e "$sed_remove_make_variables"`
6330 tests_distributed_built_sources
=`for file in $tests_built_sources; do
6331 case "$tests_cleaned_files" in
6337 if test -n "$distributed_built_sources" ||
test -n "$tests_distributed_built_sources"; then
6339 .
/configure || func_exit
1
6340 if test -n "$distributed_built_sources"; then
6342 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6343 $MAKE AUTOCONF
="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6348 if test -n "$tests_distributed_built_sources"; then
6350 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6351 $MAKE AUTOCONF
="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6356 $MAKE AUTOCONF
="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6363 # func_create_megatestdir megatestdir allmodules
6365 # - local_gnulib_path from --local-dir
6366 # - modcache true or false, from --cache-modules/--no-cache-modules
6367 # - auxdir directory relative to destdir where to place build aux files
6368 func_create_megatestdir
()
6372 if test -z "$allmodules"; then
6373 allmodules
=`func_all_modules`
6377 # First, all modules one by one.
6378 for onemodule
in $allmodules; do
6379 func_create_testdir
"$megatestdir/$onemodule" $onemodule
6380 func_append megasubdirs
"$onemodule "
6382 # Then, all modules all together.
6383 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6384 allmodules
=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
6385 func_create_testdir
"$megatestdir/ALL" "$allmodules"
6386 func_append megasubdirs
"ALL"
6389 cvsdate
=`vc_witness="$gnulib_dir/.git/refs/heads/master"; \
6390 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
6391 | sed -e 's,January,01,' -e 's,Jan,01,' \
6392 -e 's,February,02,' -e 's,Feb,02,' \
6393 -e 's,March,03,' -e 's,Mar,03,' \
6394 -e 's,April,04,' -e 's,Apr,04,' \
6396 -e 's,June,06,' -e 's,Jun,06,' \
6397 -e 's,July,07,' -e 's,Jul,07,' \
6398 -e 's,August,08,' -e 's,Aug,08,' \
6399 -e 's,September,09,' -e 's,Sep,09,' \
6400 -e 's,October,10,' -e 's,Oct,10,' \
6401 -e 's,November,11,' -e 's,Nov,11,' \
6402 -e 's,December,12,' -e 's,Dec,12,' \
6403 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
6404 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
6406 echo "CVSDATE=$cvsdate"
6407 echo ": \${MAKE=make}"
6408 echo "test -d logs || mkdir logs"
6409 echo "for module in $megasubdirs; do"
6410 echo " echo \"Working on module \$module...\""
6411 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
6412 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
6415 echo " : autobuild project... \$module"
6416 echo " : autobuild revision... cvs-\$CVSDATE-000000"
6417 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
6418 echo " : autobuild hostname... \`hostname\`"
6419 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
6421 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
6423 ) > "$megatestdir/do-autobuild"
6424 chmod a
+x
"$megatestdir/do-autobuild"
6426 # Create Makefile.am.
6427 (echo "## Process this file with automake to produce Makefile.in."
6429 echo "AUTOMAKE_OPTIONS = 1.9.6 foreign"
6431 echo "SUBDIRS = $megasubdirs"
6433 echo "EXTRA_DIST = do-autobuild"
6434 ) > "$megatestdir/Makefile.am"
6436 # Create configure.ac.
6437 (echo "# Process this file with autoconf to produce a configure script."
6438 echo "AC_INIT([dummy], [0])"
6439 if test "$auxdir" != "."; then
6440 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6442 echo "AM_INIT_AUTOMAKE"
6444 echo "AC_PROG_MAKE_SET"
6446 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
6447 echo "AC_CONFIG_FILES([Makefile])"
6449 ) > "$megatestdir/configure.ac"
6451 # Create autogenerated files.
6453 # Do not use "${AUTORECONF} --install", because autoreconf operates
6454 # recursively, but the subdirectories are already finished, therefore
6455 # calling autoreconf here would only waste lots of CPU time.
6456 func_execute_command
${ACLOCAL} || func_exit
1
6457 func_execute_command mkdir build-aux
6458 func_execute_command
${AUTOCONF} || func_exit
1
6459 func_execute_command
${AUTOMAKE} --add-missing --copy || func_exit
1
6465 func_fatal_error
"no mode specified" ;;
6472 # sed expression that converts a literal to a basic regular expression.
6473 # Needs to handle . [ \ * ^ $.
6474 sed_literal_to_basic_regex
='s/\\/\\\\/g
6480 if test -f "$gnulib_dir/$filename" \
6481 || func_lookup_local_file
"$filename"; then
6482 filename_anywhere_regex
=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
6483 filename_line_regex
='^'"$filename_anywhere_regex"'$'
6486 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
6487 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$,,'
6489 | func_sanitize_modulelist \
6492 for module
in $module_candidates; do
6493 if func_get_filelist
$module |
grep "$filename_line_regex" > /dev
/null
; then
6498 func_warning
"file $filename does not exist"
6503 import | add-import | remove-import | update
)
6506 if test -z "$destdir"; then
6509 test -d "$destdir" \
6510 || func_fatal_error
"destination directory does not exist: $destdir"
6512 # Prefer configure.ac to configure.in.
6513 if test -f "$destdir"/configure.ac
; then
6514 configure_ac
="$destdir/configure.ac"
6516 if test -f "$destdir"/configure.
in; then
6517 configure_ac
="$destdir/configure.in"
6519 func_fatal_error
"cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
6523 # Analyze configure.ac.
6525 guessed_libtool
=false
6530 /AC_CONFIG_AUX_DIR/ {
6531 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
6533 /A[CM]_PROG_LIBTOOL/ {
6534 s,^.*$,guessed_libtool=true,p
6536 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
6538 if test -z "$auxdir"; then
6539 auxdir
="$guessed_auxdir"
6542 # Determine where to apply func_import.
6543 if test "$mode" = import
; then
6544 # Apply func_import to a particular gnulib directory.
6545 # The command line contains the complete specification; don't look at
6546 # the contents of gnulib-cache.m4.
6547 test -n "$supplied_libname" || supplied_libname
=true
6548 test -n "$sourcebase" || sourcebase
="lib"
6549 test -n "$m4base" || m4base
="m4"
6550 test -n "$docbase" || docbase
="doc"
6551 test -n "$testsbase" || testsbase
="tests"
6552 test -n "$macro_prefix" || macro_prefix
="gl"
6555 if test -n "$m4base"; then
6556 # Apply func_import to a particular gnulib directory.
6557 # Any number of additional modules can be given.
6558 if test ! -f "$destdir/$m4base"/gnulib-cache.
m4; then
6559 # First use of gnulib in the given m4base.
6560 test -n "$supplied_libname" || supplied_libname
=true
6561 test -n "$sourcebase" || sourcebase
="lib"
6562 test -n "$docbase" || docbase
="doc"
6563 test -n "$testsbase" || testsbase
="tests"
6564 test -n "$macro_prefix" || macro_prefix
="gl"
6568 # Apply func_import to all gnulib directories.
6569 # To get this list of directories, look at Makefile.am. (Not at
6570 # configure, because it may be omitted from version control. Also,
6571 # don't run "find $destdir -name gnulib-cache.m4", as it might be
6575 if test -f "$destdir"/Makefile.am
; then
6576 aclocal_amflags
=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
6578 for arg
in $aclocal_amflags; do
6579 if test -n "$m4dir_is_next"; then
6580 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
6584 if test -f "$destdir/$arg"/gnulib-cache.
m4; then
6585 func_append m4dirs
" $arg"
6586 m4dirs_count
=`expr $m4dirs_count + 1`
6592 if test "X$arg" = "X-I"; then
6600 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
6601 if test -f "$destdir"/aclocal.
m4; then
6602 sedexpr1
='s,^m4_include(\[\(.*\)])$,\1,p'
6603 sedexpr2
='s,^[^/]*$,.,'
6604 sedexpr3
='s,/[^/]*$,,'
6605 m4dirs
=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
6606 m4dirs
=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
6607 m4dirs_count
=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
6610 if test $m4dirs_count = 0; then
6611 # First use of gnulib in a package.
6612 # Any number of additional modules can be given.
6613 test -n "$supplied_libname" || supplied_libname
=true
6614 test -n "$sourcebase" || sourcebase
="lib"
6616 test -n "$docbase" || docbase
="doc"
6617 test -n "$testsbase" || testsbase
="tests"
6618 test -n "$macro_prefix" || macro_prefix
="gl"
6621 if test $m4dirs_count = 1; then
6622 # There's only one use of gnulib here. Assume the user means it.
6623 # Any number of additional modules can be given.
6624 for m4base
in $m4dirs; do
6628 # Ambiguous - guess what the user meant.
6629 if test $# = 0; then
6630 # No further arguments. Guess the user wants to update all of them.
6631 for m4base
in $m4dirs; do
6632 # Perform func_import in a subshell, so that variable values
6634 # local_gnulib_path, incobsolete, inc_cxx_tests,
6635 # inc_longrunning_tests, inc_privileged_tests,
6636 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
6637 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
6638 # makefile_name, libtool, macro_prefix, po_domain,
6639 # witness_c_macro, vc_files
6640 # don't propagate from one directory to another.
6641 (func_import
) || func_exit
1
6645 func_fatal_error
"Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
6654 if test -z "$destdir"; then
6655 func_fatal_error
"please specify --dir option"
6658 test -d "$destdir" \
6659 || func_fatal_error
"could not create destination directory"
6660 test -n "$auxdir" || auxdir
="build-aux"
6661 func_create_testdir
"$destdir" "$*"
6664 create-megatestdir
)
6665 if test -z "$destdir"; then
6666 func_fatal_error
"please specify --dir option"
6668 mkdir
"$destdir" || func_fatal_error
"could not create destination directory"
6669 test -n "$auxdir" || auxdir
="build-aux"
6670 func_create_megatestdir
"$destdir" "$*"
6674 test -n "$destdir" || destdir
=testdir$$
6675 mkdir
"$destdir" || func_fatal_error
"could not create destination directory"
6676 test -n "$auxdir" || auxdir
="build-aux"
6677 func_create_testdir
"$destdir" "$*"
6681 ..
/configure || func_exit
1
6682 $MAKE || func_exit
1
6683 $MAKE check || func_exit
1
6684 $MAKE distclean || func_exit
1
6685 remaining
=`find . -type f -print`
6686 if test -n "$remaining"; then
6687 echo "Remaining files:" $remaining 1>&2
6688 echo "gnulib-tool: *** Stop." 1>&2
6697 test -n "$destdir" || destdir
=testdir$$
6698 mkdir
"$destdir" || func_fatal_error
"could not create destination directory"
6699 test -n "$auxdir" || auxdir
="build-aux"
6700 func_create_megatestdir
"$destdir" "$*"
6708 remaining
=`find . -type f -print`
6709 if test -n "$remaining"; then
6710 echo "Remaining files:" $remaining 1>&2
6711 echo "gnulib-tool: *** Stop." 1>&2
6719 extract-description
)
6723 if test -n "$module"; then
6724 func_get_description
"$module"
6733 if test -n "$module"; then
6734 func_get_comment
"$module"
6743 if test -n "$module"; then
6744 func_get_status
"$module"
6753 if test -n "$module"; then
6754 func_get_notice
"$module"
6759 extract-applicability
)
6763 if test -n "$module"; then
6764 func_get_applicability
"$module"
6773 if test -n "$module"; then
6774 func_get_filelist
"$module"
6779 extract-dependencies
)
6780 if test -n "$avoidlist"; then
6781 func_fatal_error
"cannot combine --avoid and --extract-dependencies"
6786 if test -n "$module"; then
6787 func_get_dependencies
"$module"
6792 extract-autoconf-snippet
)
6796 if test -n "$module"; then
6797 func_get_autoconf_snippet
"$module"
6802 extract-automake-snippet
)
6806 if test -n "$module"; then
6807 func_get_automake_snippet
"$module"
6812 extract-include-directive
)
6816 if test -n "$module"; then
6817 func_get_include_directive
"$module"
6822 extract-link-directive
)
6826 if test -n "$module"; then
6827 func_get_link_directive
"$module"
6836 if test -n "$module"; then
6837 func_get_license
"$module"
6842 extract-maintainer
)
6846 if test -n "$module"; then
6847 func_get_maintainer
"$module"
6852 extract-tests-module
)
6856 if test -n "$module"; then
6857 func_get_tests_module
"$module"
6863 # Verify the number of arguments.
6864 if test $# -lt 1 ||
test $# -gt 2; then
6865 func_fatal_error
"invalid number of arguments for --$mode"
6868 # The first argument is the file to be copied.
6870 # Verify the file exists.
6871 func_lookup_file
"$f"
6873 # The second argument is the destination; either a directory ot a file.
6874 # It defaults to the current directory.
6876 test -n "$dest" || dest
='.'
6877 test -n "$sourcebase" || sourcebase
="lib"
6878 test -n "$m4base" || m4base
="m4"
6879 test -n "$docbase" || docbase
="doc"
6880 test -n "$testsbase" || testsbase
="tests"
6881 test -n "$auxdir" || auxdir
="build-aux"
6882 rewritten
='%REWRITTEN%'
6883 sed_rewrite_files
="\
6884 s,^build-aux/,$rewritten$auxdir/,
6885 s,^doc/,$rewritten$docbase/,
6886 s,^lib/,$rewritten$sourcebase/,
6887 s,^m4/,$rewritten$m4base/,
6888 s,^tests/,$rewritten$testsbase/,
6891 if test -d "$dest"; then
6893 g
=`echo "$f" | sed -e "$sed_rewrite_files"`
6895 destdir
=`dirname "$dest"`
6896 g
=`basename "$dest"`
6899 # Create the directory for destfile.
6900 d
=`dirname "$destdir/$g"`
6902 if test -n "$d" && test ! -d "$d"; then
6903 mkdir
-p "$d" || func_fatal_error
"failed"
6907 func_dest_tmpfilename
"$g"
6908 cp "$lookedup_file" "$tmpfile" || func_fatal_error
"failed"
6909 already_present
=true
6910 if test -f "$destdir/$g"; then
6911 # The file already exists.
6915 # Don't protest if the file should be there but isn't: it happens
6916 # frequently that developers don't put autogenerated files under version
6924 func_fatal_error
"unknown operation mode --$mode" ;;
6928 # Undo the effect of the previous 'trap' command. Some shellology:
6929 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
6930 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
6931 # exit); for the others we need to call 'exit' explicitly. The value of $? is
6932 # 128 + signal number and is set before the trap-registered command is run.
6934 trap 'func_exit $?' 1 2 3 13 15
6939 # indent-tabs-mode: nil
6940 # whitespace-check-buffer-indent: nil