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 use cp -p if ln -s fails.
775 echo "$progname: ln -s failed; falling back on cp -p" >&2
778 /* | ?:*) # SRC is absolute.
780 *) # SRC is relative to the directory of DEST.
789 # Like func_ln_s, except that SRC is given relative to the current directory (or
790 # absolute), not given relative to the directory of DEST.
795 func_ln_s "$1" "$2" ;;
796 *) # SRC is relative.
799 func_ln_s "`pwd`/$1" "$2" ;;
800 *) # DEST is relative too.
801 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
802 test -n "$ln_destdir" || ln_destdir="."
803 func_relativize "$ln_destdir" "$1"
804 func_ln_s "$reldir" "$2"
811 # func_ln_if_changed SRC DEST
812 # Like func_ln, but avoids munging timestamps if the link is correct.
813 func_ln_if_changed ()
815 if test $# -ne 2; then
816 echo "usage: func_ln_if_changed SRC DEST" >&2
818 ln_target=`func_readlink "$2"`
819 if test -h "$2" && test "$1" = "$ln_target"; then
827 # Ensure an 'echo' command that
828 # 1. does not interpret backslashes and
829 # 2. does not print an error message "broken pipe" when writing into a pipe
832 # Test cases for problem 1:
833 # echo '\n' | wc -l prints 1 when OK, 2 when KO
834 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
835 # Test cases for problem 2:
836 # echo hi | true frequently prints
837 # "bash: echo: write error: Broken pipe"
838 # to standard error in bash 3.2.
840 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
841 # BSD echo interprets '-n' as an option, which is also not desirable).
842 # Nowadays the problem occurs in 4 situations:
843 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
844 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
845 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
846 # - in zsh, when sh-emulation is not set,
847 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
848 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
849 # - in Solaris /bin/sh and OSF/1 /bin/sh.
850 # We try the following workarounds:
851 # - for all: respawn using $CONFIG_SHELL if that is set and works.
852 # - for bash >= 2.04: unset the shell option xpg_echo.
853 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
854 # - for bash < 2.0: define echo to a function that uses cat of a here document.
855 # - for zsh: turn sh-emulation on.
856 # - for ksh: alias echo to 'print -r'.
857 # - for ksh: alias echo to a function that uses cat of a here document.
858 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
859 # the ksh workaround.
860 # - otherwise: respawn using /bin/sh and rely on the workarounds.
861 # When respawning, we pass --no-reexec as first argument, so as to avoid
862 # turning this script into a fork bomb in unlucky situations.
864 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
865 # the 'printf' built-in. See
866 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
867 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
868 # The workaround is: define echo to a function that uses the printf built-in.
870 if echo '\t' | grep t > /dev/null; then
871 have_echo=yes # Lucky!
873 # Try the workarounds.
874 # Respawn using $CONFIG_SHELL if that is set and works.
875 if test -z "$have_echo" \
876 && test "X$1" != "X--no-reexec" \
877 && test -n "$CONFIG_SHELL" \
878 && test -f "$CONFIG_SHELL" \
879 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
880 exec $CONFIG_SHELL "$0" --no-reexec "$@"
883 # For bash >= 2.04: unset the shell option xpg_echo.
884 if test -z "$have_echo" \
885 && test -n "$BASH_VERSION" \
886 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
890 # For bash >= 2.0: define echo to a function that uses the printf built-in.
891 # For bash < 2.0: define echo to a function that uses cat of a here document.
892 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
893 # Also handle problem 2, specific to bash 3.2, here.
894 if { test -z "$have_echo" \
895 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
897 && test -n "$BASH_VERSION"; then \
898 if type printf 2>/dev/null | grep / > /dev/null; then
899 # 'printf' is not a shell built-in.
907 # 'printf' is a shell built-in.
913 if echo '\t' | grep t > /dev/null; then
917 # For zsh: turn sh-emulation on.
918 if test -z "$have_echo" \
919 && test -n "$ZSH_VERSION" \
920 && (emulate sh) >/dev/null 2>&1; then
923 # For ksh: alias echo to 'print -r'.
924 if test -z "$have_echo" \
925 && (type print) >/dev/null 2>&1; then
926 # A 'print' command exists.
927 if type print 2>/dev/null | grep / > /dev/null; then
930 # 'print' is a shell built-in.
931 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
932 # 'print' is the ksh shell built-in.
933 alias echo='print -r'
937 if test -z "$have_echo" \
938 && echo '\t' | grep t > /dev/null; then
941 # For ksh: alias echo to a function that uses cat of a here document.
942 # The ksh manual page says:
943 # "Aliasing is performed when scripts are read, not while they are executed.
944 # Therefore, for an alias to take effect, the alias definition command has
945 # to be executed before the command which references the alias is read."
946 # Because of this, we have to play strange tricks with have_echo, to ensure
947 # that the top-level statement containing the test starts after the 'alias'
949 if test -z "$have_echo"; then
956 if (alias echo=bsd_echo) 2>/dev/null; then
957 alias echo=bsd_echo 2>/dev/null
960 if test -z "$have_echo" \
961 && echo '\t' | grep t > /dev/null; then
964 if test -z "$have_echo"; then
965 if (alias echo=bsd_echo) 2>/dev/null; then
966 unalias echo 2>/dev/null
969 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
970 if test -z "$have_echo" \
971 && test "X$1" != "X--no-reexec" \
972 && test -f /bin/ksh; then
973 exec /bin/ksh "$0" --no-reexec "$@"
976 # Otherwise: respawn using /bin/sh.
977 if test -z "$have_echo" \
978 && test "X$1" != "X--no-reexec" \
979 && test -f /bin/sh; then
980 exec /bin/sh "$0" --no-reexec "$@"
983 if test -z "$have_echo"; then
984 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
986 if echo '\t' | grep t > /dev/null; then
989 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
991 if test "X$1" = "X--no-reexec"; then
995 # Unset CDPATH. Otherwise, output from 'cd dir' can surprise callers.
996 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
998 # Determine the path separator early because the following option parsing code
1000 func_determine_path_separator
1002 # Command-line option processing.
1003 # Removes the OPTIONS from the arguments. Sets the variables:
1004 # - mode one of: list, find, import, add-import, remove-import,
1005 # update, create-testdir, create-megatestdir, test, megatest,
1007 # - destdir from --dir
1008 # - local_gnulib_path from --local-dir
1009 # - modcache true or false, from --cache-modules/--no-cache-modules
1010 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1011 # - libname, supplied_libname from --lib
1012 # - sourcebase from --source-base
1013 # - m4base from --m4-base
1014 # - pobase from --po-base
1015 # - docbase from --doc-base
1016 # - testsbase from --tests-base
1017 # - auxdir from --aux-dir
1018 # - inctests true if --with-tests was given, false if --without-tests
1019 # was given, blank otherwise
1020 # - incobsolete true if --with-obsolete was given, blank otherwise
1021 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
1022 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
1024 # - inc_privileged_tests true if --with-privileged-tests was given, blank
1026 # - inc_unportable_tests true if --with-unportable-tests was given, blank
1028 # - inc_all_tests true if --with-all-tests was given, blank otherwise
1029 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
1030 # - excl_longrunning_tests true if --without-longrunning-tests was given,
1032 # - excl_privileged_tests true if --without-privileged-tests was given, blank
1034 # - excl_unportable_tests true if --without-unportable-tests was given, blank
1036 # - single_configure true if --single-configure was given, false otherwise
1037 # - avoidlist list of modules to avoid, from --avoid
1038 # - cond_dependencies true if --conditional-dependencies was given, false if
1039 # --no-conditional-dependencies was given, blank otherwise
1040 # - lgpl yes or a number if --lgpl was given, blank otherwise
1041 # - makefile_name from --makefile-name
1042 # - libtool true if --libtool was given, false if --no-libtool was
1043 # given, blank otherwise
1044 # - macro_prefix from --macro-prefix
1045 # - po_domain from --po-domain
1046 # - witness_c_macro from --witness-c-macro
1047 # - vc_files true if --vc-files was given, false if --no-vc-files was
1048 # given, blank otherwise
1049 # - autoconf_minversion minimum supported autoconf version
1050 # - doit : if actions shall be executed, false if only to be printed
1051 # - symbolic true if --symlink or --more-symlinks was given, blank
1053 # - lsymbolic true if --local-symlink was given, blank otherwise
1054 # - do_copyrights blank if --more-symlinks was given, true otherwise
1072 inc_longrunning_tests=
1073 inc_privileged_tests=
1074 inc_unportable_tests=
1077 excl_longrunning_tests=
1078 excl_privileged_tests=
1079 excl_unportable_tests=
1080 single_configure=false
1097 while test $# -gt 0; do
1102 --find | --fin | --fi | --f )
1105 --import | --impor | --impo | --imp | --im | --i )
1108 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
1111 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
1114 --update | --updat | --upda | --upd | --up | --u )
1117 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
1120 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
1121 mode=create-megatestdir
1123 --test | --tes | --te | --t )
1126 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1130 mode=`echo "X$1" | sed -e 's/^X--//'`
1132 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop )
1137 if test $# = 0; then
1138 func_fatal_error "missing argument for --dir"
1143 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1147 if test $# = 0; then
1148 func_fatal_error "missing argument for --local-dir"
1150 func_path_prepend local_gnulib_path "$1"
1153 local_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1154 func_path_prepend local_gnulib_path "$local_dir"
1156 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1159 --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 )
1162 --verbose | --verbos | --verbo | --verb )
1163 verbose=`expr $verbose + 1`
1165 --quiet | --quie | --qui | --qu | --q )
1166 verbose=`expr $verbose - 1`
1170 if test $# = 0; then
1171 func_fatal_error "missing argument for --lib"
1174 supplied_libname=true
1177 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1178 supplied_libname=true
1182 if test $# = 0; then
1183 func_fatal_error "missing argument for --source-base"
1188 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1192 if test $# = 0; then
1193 func_fatal_error "missing argument for --m4-base"
1198 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1202 if test $# = 0; then
1203 func_fatal_error "missing argument for --po-base"
1208 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1212 if test $# = 0; then
1213 func_fatal_error "missing argument for --doc-base"
1218 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1222 if test $# = 0; then
1223 func_fatal_error "missing argument for --tests-base"
1228 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1232 if test $# = 0; then
1233 func_fatal_error "missing argument for --aux-dir"
1238 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1240 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1243 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1246 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1249 --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)
1250 inc_longrunning_tests=true
1252 --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)
1253 inc_privileged_tests=true
1255 --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)
1256 inc_unportable_tests=true
1258 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1261 --without-tests | --without-test | --without-tes | --without-te | --without-t)
1264 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1267 --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)
1268 excl_longrunning_tests=true
1270 --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)
1271 excl_privileged_tests=true
1273 --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)
1274 excl_unportable_tests=true
1276 --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)
1277 single_configure=true
1281 if test $# = 0; then
1282 func_fatal_error "missing argument for --avoid"
1284 func_append avoidlist " $1"
1287 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1288 func_append avoidlist " $arg"
1290 --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)
1291 cond_dependencies=true
1293 --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)
1294 cond_dependencies=false
1300 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1303 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1309 if test $# = 0; then
1310 func_fatal_error "missing argument for --makefile-name"
1315 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1325 if test $# = 0; then
1326 func_fatal_error "missing argument for --macro-prefix"
1331 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1335 if test $# = 0; then
1336 func_fatal_error "missing argument for --po-domain"
1341 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1345 if test $# = 0; then
1346 func_fatal_error "missing argument for --witness-c-macro"
1348 witness_c_macro="$1"
1350 --witness-c-macro=* )
1351 witness_c_macro=`echo "X$1" | sed -e 's/^X--witness-c-macro=//'`
1359 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1360 # A no-op for backward compatibility.
1365 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1368 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1371 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1375 --help | --hel | --he | --h )
1378 --version | --versio | --versi | --vers )
1382 # Stop option processing
1386 echo "gnulib-tool: unknown option $1" 1>&2
1387 echo "Try 'gnulib-tool --help' for more information." 1>&2
1394 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1395 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1396 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1397 || test "$single_configure" != false; then
1398 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1399 echo "Try 'gnulib-tool --help' for more information." 1>&2
1403 if test "$mode" = update; then
1404 if test $# != 0; then
1405 echo "gnulib-tool: too many arguments in '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
1411 if test -n "$local_gnulib_path" || test -n "$supplied_libname" \
1412 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1413 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1414 || test -n "$inctests" || test -n "$incobsolete" \
1415 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1416 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1417 || test -n "$inc_all_tests" \
1418 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1419 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1420 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1421 || test -n "$macro_prefix" || test -n "$po_domain" \
1422 || test -n "$witness_c_macro" || test -n "$vc_files"; then
1423 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1424 echo "Try 'gnulib-tool --help' for more information." 1>&2
1425 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1426 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1430 if test -n "$pobase" && test -z "$po_domain"; then
1431 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1432 echo "Try 'gnulib-tool --help' for more information." 1>&2
1435 if test -z "$pobase" && test -n "$po_domain"; then
1436 func_warning "--po-domain has no effect without a --po-base option"
1438 # Canonicalize the inctests variable.
1440 import | add-import | remove-import | update)
1441 if test -z "$inctests"; then
1445 create-testdir | create-megatestdir | test | megatest)
1446 if test -z "$inctests"; then
1451 # Now the only possible values of "$inctests" are true and false
1452 # (or blank but then it is irrelevant).
1453 if test "$cond_dependencies" = true && test "$inctests" = true; then
1454 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
1458 # Determine the minimum supported autoconf version from the project's
1460 DEFAULT_AUTOCONF_MINVERSION="2.59"
1461 autoconf_minversion=
1463 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1464 && test -n "$destdir"; then
1465 if test -f "$destdir"/configure.ac; then
1466 configure_ac="$destdir/configure.ac"
1468 if test -f "$destdir"/configure.in; then
1469 configure_ac="$destdir/configure.in"
1473 if test -f configure.ac; then
1474 configure_ac="configure.ac"
1476 if test -f configure.in; then
1477 configure_ac="configure.in"
1481 if test -n "$configure_ac"; then
1482 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1483 # because when some m4 files are omitted from a version control repository,
1484 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1485 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1486 # autom4te: m4 failed with exit status: 1
1493 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1495 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1496 if test -n "$prereqs"; then
1497 autoconf_minversion=`
1498 for version in $prereqs; do echo $version; done |
1499 LC_ALL=C sort -nru | sed -e 1q
1503 if test -z "$autoconf_minversion"; then
1504 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1506 case "$autoconf_minversion" in
1507 1.* | 2.[0-4]* | 2.5[0-8]*)
1508 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1511 # Remove trailing slashes from the directory names. This is necessary for
1512 # m4base (to avoid an error in func_import) and optional for the others.
1513 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1514 old_local_gnulib_path=$local_gnulib_path
1518 for dir in $old_local_gnulib_path
1521 */ ) dir=`echo "$dir" | sed -e "$sed_trimtrailingslashes"` ;;
1523 func_path_append local_gnulib_path "$dir"
1526 case "$sourcebase" in
1527 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1530 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1533 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1536 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1538 case "$testsbase" in
1539 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1542 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1548 trap 'exit_status=$?
1549 if test "$signal" != 0; then
1550 echo "caught signal $signal" >&2
1553 exit $exit_status' 0
1554 for signal in 1 2 3 13 15; do
1555 trap '{ signal='$signal'; func_exit 1; }' $signal
1559 # Note: The 'eval' silences stderr output in dash.
1560 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1561 # Zsh 4 and Bash 4 have associative arrays.
1562 have_associative=true
1564 # For other shells, use 'eval' with computed shell variable names.
1565 have_associative=false
1568 # func_lookup_local_file_cb dir file
1569 # return true and set func_lookup_local_file_result if the file 'dir/file'
1571 func_lookup_local_file_cb ()
1573 test -n "$func_lookup_local_file_result" && return 1 # already found?
1574 test -f "$1/$2" || return 1
1575 func_lookup_local_file_result=$1/$2
1579 # func_lookup_local_file file
1580 # looks up a file in $local_gnulib_path.
1582 # - local_gnulib_path from --local-dir
1584 # - func_lookup_local_file_result name of the file, valid only when the
1585 # function succeeded.
1586 func_lookup_local_file ()
1588 func_lookup_local_file_result=
1589 func_path_foreach "$local_gnulib_path" func_lookup_local_file_cb %dir% "$1"
1592 # func_lookup_file file
1593 # looks up a file in $local_gnulib_path or $gnulib_dir, or combines it through
1596 # - local_gnulib_path from --local-dir
1598 # - lookedup_file name of the merged (combined) file
1599 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1603 if func_lookup_local_file "$lkfile"; then
1604 lookedup_file=$func_lookup_local_file_result
1607 if test -f "$gnulib_dir/$lkfile"; then
1608 if func_lookup_local_file "$lkfile.diff"; then
1609 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1610 rm -f "$tmp/$lkbase"
1611 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1612 patch -s "$tmp/$lkbase" < "$func_lookup_local_file_result" >&2 \
1613 || func_fatal_error "patch file $func_lookup_local_file_result didn't apply cleanly"
1614 lookedup_file="$tmp/$lkbase"
1617 lookedup_file="$gnulib_dir/$lkfile"
1621 func_fatal_error "file $gnulib_dir/$lkfile not found"
1626 # func_sanitize_modulelist
1627 # receives a list of possible module names on standard input, one per line.
1628 # It removes those which are just file names unrelated to modules, and outputs
1629 # the resulting list to standard output, one per line.
1630 func_sanitize_modulelist ()
1632 sed -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1633 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1634 -e '/^README$/d' -e '/\/README$/d' \
1635 -e '/^TEMPLATE$/d' \
1636 -e '/^TEMPLATE-EXTENDED$/d' \
1637 -e '/^TEMPLATE-TESTS$/d' \
1643 # func_modules_in_dir dir
1644 # outputs all module files in dir to standard output.
1645 func_modules_in_dir ()
1647 (test -d "$1" && cd "$1" && find modules -type f -print)
1652 # - local_gnulib_path from --local-dir
1655 # Filter out metainformation files like README, which are not modules.
1656 # Filter out unit test modules; they can be retrieved through
1657 # --extract-tests-module if desired.
1659 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1660 func_path_foreach "$local_gnulib_path" func_modules_in_dir %dir% | sed -e 's,^modules/,,' -e 's,\.diff$,,'
1662 | func_sanitize_modulelist \
1663 | sed -e '/-tests$/d' \
1667 # func_exists_local_module dir module
1668 # returns true if module exists in dir
1669 func_exists_local_module ()
1671 test -d "$1/modules" && test -f "$1/modules/$2";
1674 # func_exists_module module
1675 # tests whether a module, given by name, exists
1677 # - local_gnulib_path from --local-dir
1678 func_exists_module ()
1680 { test -f "$gnulib_dir/modules/$1" \
1681 || func_path_foreach "$local_gnulib_path" func_exists_local_module %dir% "$1" ; } \
1682 && test "ChangeLog" != "$1" \
1683 && test "COPYING" != "$1" \
1684 && test "README" != "$1" \
1685 && test "TEMPLATE" != "$1" \
1686 && test "TEMPLATE-EXTENDED" != "$1" \
1687 && test "TEMPLATE-TESTS" != "$1"
1690 # func_verify_module
1691 # verifies a module name
1693 # - local_gnulib_path from --local-dir
1694 # - module module name argument
1695 func_verify_module ()
1697 if func_exists_module "$module"; then
1698 # OK, $module is a correct module name.
1699 # Verify that building the module description with 'patch' succeeds.
1700 func_lookup_file "modules/$module"
1702 func_warning "module $module doesn't exist"
1707 # func_verify_nontests_module
1708 # verifies a module name, excluding tests modules
1710 # - local_gnulib_path from --local-dir
1711 # - module module name argument
1712 func_verify_nontests_module ()
1715 *-tests ) module= ;;
1716 * ) func_verify_module ;;
1720 # func_verify_tests_module
1721 # verifies a module name, considering only tests modules
1723 # - local_gnulib_path from --local-dir
1724 # - module module name argument
1725 func_verify_tests_module ()
1728 *-tests ) func_verify_module ;;
1733 # Suffix of a sed expression that extracts a particular field from a
1734 # module description.
1735 # A field starts with a line that contains a keyword, such as 'Description',
1736 # followed by a colon and optional whitespace. All following lines, up to
1737 # the next field (or end of file if there is none) form the contents of the
1739 # An absent field is equivalent to a field with empty contents.
1740 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1741 sed_extract_prog=':[ ]*$/ {
1744 s/^Description:[ ]*$//
1748 s/^Applicability:[ ]*$//
1750 s/^Depends-on:[ ]*$//
1751 s/^configure\.ac-early:[ ]*$//
1752 s/^configure\.ac:[ ]*$//
1753 s/^Makefile\.am:[ ]*$//
1757 s/^Maintainer:[ ]*$//
1764 # Piece of a sed expression that converts a field header line to a shell
1766 # NOTE: Keep this in sync with sed_extract_prog above!
1767 sed_extract_field_header='
1768 s/^Description:[ ]*$/description/
1769 s/^Comment:[ ]*$/comment/
1770 s/^Status:[ ]*$/status/
1771 s/^Notice:[ ]*$/notice/
1772 s/^Applicability:[ ]*$/applicability/
1773 s/^Files:[ ]*$/files/
1774 s/^Depends-on:[ ]*$/dependson/
1775 s/^configure\.ac-early:[ ]*$/configureac_early/
1776 s/^configure\.ac:[ ]*$/configureac/
1777 s/^Makefile\.am:[ ]*$/makefile/
1778 s/^Include:[ ]*$/include/
1780 s/^License:[ ]*$/license/
1781 s/^Maintainer:[ ]*$/maintainer/'
1785 if $have_associative; then
1787 # Declare the associative arrays.
1788 declare -A modcache_cached
1789 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1790 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1791 eval "$declare_script"
1795 # func_cache_var module
1796 # computes the cache variable name corresponding to $module.
1797 # Note: This computation can map different module names to the same
1798 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1799 # to protect against this case.
1801 # - cachevar a shell variable name
1802 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1803 # Bash 2.0 and newer, ksh, and zsh support the syntax
1804 # ${param//pattern/replacement}
1805 # as a shorthand for
1806 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1807 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1808 eval 'func_cache_var ()
1810 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1817 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1826 # func_init_sed_convert_to_cache_statements
1828 # - modcachevar_assignment
1830 # - sed_convert_to_cache_statements
1831 func_init_sed_convert_to_cache_statements ()
1833 # 'sed' script that turns a module description into shell script
1834 # assignments, suitable to be eval'ed. All active characters are escaped.
1837 # Some module's description
1842 # modcache_description[$1]=\
1843 # 'Some module'"'"'s description
1845 # modcache_files[$1]=\
1848 # c_MODULE_description_set=set; c_MODULE_description=\
1849 # 'Some module'"'"'s description
1851 # c_MODULE_files_set=set; c_MODULE_files=\
1853 # The script consists of two parts:
1854 # 1) Ignore the lines before the first field header.
1855 # 2) A loop, treating non-field-header lines by escaping single quotes
1856 # and adding a closing quote in the last line,
1857 sed_convert_to_cache_statements="
1859 # Here we have not yet seen a field header.
1861 # See if the current line contains a field header.
1864 ${sed_extract_field_header}
1867 # No field header. Ignore the line.
1869 # Read the next line. Upon EOF, just exit.
1874 # The current line contains a field header.
1876 # Turn it into the beginning of an assignment.
1877 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1879 # Move it to the hold space. Don't print it yet,
1880 # because we want no assignment if the field is empty.
1883 # Read the next line.
1884 # Upon EOF, the field was empty. Print no assignment. Just exit.
1887 # See if the current line contains a field header.
1890 ${sed_extract_field_header}
1891 # If it is, the previous field was empty. Print no assignment.
1894 # Not a field header.
1896 # Print the previous line, held in the hold space.
1901 # Transform single quotes.
1904 # Prepend a single quote.
1909 # Move it to the hold space.
1912 # Read the next line.
1919 # See if the current line contains a field header.
1922 ${sed_extract_field_header}
1925 # Print the previous line, held in the hold space.
1930 # Transform single quotes.
1937 # Print the previous line, held in the hold space, with a single quote
1938 # to end the assignment.
1948 # Print the previous line, held in the hold space, with a single quote
1949 # to end the assignment.
1956 if ! $sed_comments; then
1958 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1959 | sed -e 's/^ *//' -e 's/^#.*//'`
1963 if $have_associative; then
1964 # sed_convert_to_cache_statements does not depend on the module.
1965 modcachevar_assignment='modcache_\1[$1]='
1966 func_init_sed_convert_to_cache_statements
1969 # func_cache_lookup_module module
1971 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1972 # of its relevant data in a cache in the memory of the processing shell. If
1973 # already cached, it does not look it up again, thus saving file access time.
1975 # - module non-empty string
1976 # Output if $have_associative:
1977 # - modcache_cached[$module] set to yes
1978 # - modcache_description[$module] ==
1979 # - modcache_status[$module] \ set to the field's value, minus the
1980 # - ... / final newline,
1981 # - modcache_maintainer[$module] == or unset if the field's value is empty
1982 # Output if ! $have_associative:
1983 # - cachevar a shell variable name
1984 # - ${cachevar}_cached set to $module
1985 # - ${cachevar}_description ==
1986 # - ${cachevar}_status \ set to the field's value, minus the
1987 # - ... / final newline,
1988 # - ${cachevar}_maintainer == or unset if the field's value is empty
1989 # - ${cachevar}_description_set ==
1990 # - ${cachevar}_status_set \ set to non-empty if the field's value
1991 # - ... / is non-empty,
1992 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1993 func_cache_lookup_module ()
1995 if $have_associative; then
1996 eval 'cached=${modcache_cached[$1]}'
1999 eval "cached=\"\$${cachevar}_cached\""
2001 if test -z "$cached"; then
2002 # Not found in cache. Look it up on the file system.
2003 func_lookup_file "modules/$1"
2004 if $have_associative; then
2005 eval 'modcache_cached[$1]=yes'
2007 eval "${cachevar}_cached=\"\$1\""
2009 if ! $have_associative; then
2010 # sed_convert_to_cache_statements depends on the module.
2011 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
2012 func_init_sed_convert_to_cache_statements
2014 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
2015 eval "$cache_statements"
2017 if ! $have_associative; then
2018 if test "$1" != "$cached"; then
2019 func_fatal_error "cache variable collision between $1 and $cached"
2027 # func_get_description module
2029 # - local_gnulib_path from --local-dir
2030 # - modcache true or false, from --cache-modules/--no-cache-modules
2031 func_get_description ()
2033 if ! $modcache; then
2034 func_lookup_file "modules/$1"
2035 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
2037 func_cache_lookup_module "$1"
2038 # Output the field's value, including the final newline (if any).
2039 if $have_associative; then
2040 if eval 'test -n "${modcache_description[$1]+set}"'; then
2041 eval 'echo "${modcache_description[$1]}"'
2044 eval "field_set=\"\$${cachevar}_description_set\""
2045 if test -n "$field_set"; then
2046 eval "field_value=\"\$${cachevar}_description\""
2047 echo "${field_value}"
2053 # func_get_comment module
2055 # - local_gnulib_path from --local-dir
2056 # - modcache true or false, from --cache-modules/--no-cache-modules
2059 if ! $modcache; then
2060 func_lookup_file "modules/$1"
2061 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
2063 func_cache_lookup_module "$1"
2064 # Output the field's value, including the final newline (if any).
2065 if $have_associative; then
2066 if eval 'test -n "${modcache_comment[$1]+set}"'; then
2067 eval 'echo "${modcache_comment[$1]}"'
2070 eval "field_set=\"\$${cachevar}_comment_set\""
2071 if test -n "$field_set"; then
2072 eval "field_value=\"\$${cachevar}_comment\""
2073 echo "${field_value}"
2079 # func_get_status module
2081 # - local_gnulib_path from --local-dir
2082 # - modcache true or false, from --cache-modules/--no-cache-modules
2085 if ! $modcache; then
2086 func_lookup_file "modules/$1"
2087 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
2089 func_cache_lookup_module "$1"
2090 # Output the field's value, including the final newline (if any).
2091 if $have_associative; then
2092 if eval 'test -n "${modcache_status[$1]+set}"'; then
2093 eval 'echo "${modcache_status[$1]}"'
2096 eval "field_set=\"\$${cachevar}_status_set\""
2097 if test -n "$field_set"; then
2098 eval "field_value=\"\$${cachevar}_status\""
2099 echo "${field_value}"
2105 # func_get_notice module
2107 # - local_gnulib_path from --local-dir
2108 # - modcache true or false, from --cache-modules/--no-cache-modules
2111 if ! $modcache; then
2112 func_lookup_file "modules/$1"
2113 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
2115 func_cache_lookup_module "$1"
2116 # Output the field's value, including the final newline (if any).
2117 if $have_associative; then
2118 if eval 'test -n "${modcache_notice[$1]+set}"'; then
2119 eval 'echo "${modcache_notice[$1]}"'
2122 eval "field_set=\"\$${cachevar}_notice_set\""
2123 if test -n "$field_set"; then
2124 eval "field_value=\"\$${cachevar}_notice\""
2125 echo "${field_value}"
2131 # func_get_applicability module
2133 # - local_gnulib_path from --local-dir
2134 # - modcache true or false, from --cache-modules/--no-cache-modules
2135 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
2136 func_get_applicability ()
2138 if ! $modcache; then
2139 func_lookup_file "modules/$1"
2140 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
2142 func_cache_lookup_module "$1"
2143 # Get the field's value, without the final newline.
2144 if $have_associative; then
2145 eval 'my_applicability="${modcache_applicability[$1]}"'
2147 eval "my_applicability=\"\$${cachevar}_applicability\""
2150 if test -n "$my_applicability"; then
2151 echo $my_applicability
2153 # The default is 'main' or 'tests', depending on the module's name.
2155 *-tests) echo "tests";;
2161 # func_get_filelist module
2163 # - local_gnulib_path from --local-dir
2164 # - modcache true or false, from --cache-modules/--no-cache-modules
2165 func_get_filelist ()
2167 if ! $modcache; then
2168 func_lookup_file "modules/$1"
2169 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
2171 func_cache_lookup_module "$1"
2172 # Output the field's value, including the final newline (if any).
2173 if $have_associative; then
2174 if eval 'test -n "${modcache_files[$1]+set}"'; then
2175 eval 'echo "${modcache_files[$1]}"'
2178 eval "field_set=\"\$${cachevar}_files_set\""
2179 if test -n "$field_set"; then
2180 eval "field_value=\"\$${cachevar}_files\""
2181 echo "${field_value}"
2186 echo m4/gnulib-common.m4
2187 case "$autoconf_minversion" in
2194 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2195 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2196 # elements starting with prefix and ending with suffix are considered.
2197 # Processing: removed_prefix and removed_suffix are removed from each element,
2198 # added_prefix and added_suffix are added to each element.
2199 # prefix, suffix should not contain shell-special characters.
2200 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2201 # added_prefix, added_suffix should not contain the characters \|&.
2202 func_filter_filelist ()
2204 if test "$2" != "$nl" \
2205 || { $fast_func_append \
2206 && { test -z "$6" || $fast_func_remove_prefix; } \
2207 && { test -z "$7" || $fast_func_remove_suffix; }; \
2211 # Do not quote possibly-empty parameters in case patterns,
2212 # AIX and HP-UX ksh won't match them if they are empty.
2215 if test -n "$6"; then
2216 func_remove_prefix fff "$6"
2218 if test -n "$7"; then
2219 func_remove_suffix fff "$7"
2222 if test -z "$ffflist"; then
2225 func_append ffflist "$2${fff}"
2231 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2232 ffflist=`for fff in $3; do
2234 $4*$5) echo "$fff" ;;
2236 done | sed -e "$sed_fff_filter"`
2238 eval "$1=\"\$ffflist\""
2241 # func_get_dependencies module
2243 # - local_gnulib_path from --local-dir
2244 # - modcache true or false, from --cache-modules/--no-cache-modules
2245 func_get_dependencies ()
2247 # ${module}-tests implicitly depends on ${module}, if that module exists.
2251 func_remove_suffix fgd1 '-tests'
2252 if func_exists_module "$fgd1"; then
2257 # Then the explicit dependencies listed in the module description.
2258 { if ! $modcache; then
2259 func_lookup_file "modules/$1"
2260 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2262 func_cache_lookup_module "$1"
2263 # Output the field's value, including the final newline (if any).
2264 if $have_associative; then
2265 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2266 eval 'echo "${modcache_dependson[$1]}"'
2269 eval "field_set=\"\$${cachevar}_dependson_set\""
2270 if test -n "$field_set"; then
2271 eval "field_value=\"\$${cachevar}_dependson\""
2272 echo "${field_value}"
2280 # func_get_autoconf_early_snippet module
2282 # - local_gnulib_path from --local-dir
2283 # - modcache true or false, from --cache-modules/--no-cache-modules
2284 func_get_autoconf_early_snippet ()
2286 if ! $modcache; then
2287 func_lookup_file "modules/$1"
2288 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2290 func_cache_lookup_module "$1"
2291 # Output the field's value, including the final newline (if any).
2292 if $have_associative; then
2293 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2294 eval 'echo "${modcache_configureac_early[$1]}"'
2297 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2298 if test -n "$field_set"; then
2299 eval "field_value=\"\$${cachevar}_configureac_early\""
2300 echo "${field_value}"
2306 # func_get_autoconf_snippet module
2308 # - local_gnulib_path from --local-dir
2309 # - modcache true or false, from --cache-modules/--no-cache-modules
2310 func_get_autoconf_snippet ()
2312 if ! $modcache; then
2313 func_lookup_file "modules/$1"
2314 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2316 func_cache_lookup_module "$1"
2317 # Output the field's value, including the final newline (if any).
2318 if $have_associative; then
2319 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2320 eval 'echo "${modcache_configureac[$1]}"'
2323 eval "field_set=\"\$${cachevar}_configureac_set\""
2324 if test -n "$field_set"; then
2325 eval "field_value=\"\$${cachevar}_configureac\""
2326 echo "${field_value}"
2332 # Concatenate lines with trailing slash.
2333 # $1 is an optional filter to restrict the
2334 # concatenation to groups starting with that expression
2336 sed -e "/$1.*"'\\$/{
2345 # func_get_automake_snippet_conditional module
2346 # returns the part of the Makefile.am snippet that can be put inside Automake
2349 # - local_gnulib_path from --local-dir
2350 # - modcache true or false, from --cache-modules/--no-cache-modules
2351 func_get_automake_snippet_conditional ()
2353 if ! $modcache; then
2354 func_lookup_file "modules/$1"
2355 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2357 func_cache_lookup_module "$1"
2358 # Output the field's value, including the final newline (if any).
2359 if $have_associative; then
2360 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2361 eval 'echo "${modcache_makefile[$1]}"'
2364 eval "field_set=\"\$${cachevar}_makefile_set\""
2365 if test -n "$field_set"; then
2366 eval "field_value=\"\$${cachevar}_makefile\""
2367 echo "${field_value}"
2373 # func_get_automake_snippet_unconditional module
2374 # returns the part of the Makefile.am snippet that must stay outside of
2375 # Automake conditionals.
2377 # - local_gnulib_path from --local-dir
2378 # - modcache true or false, from --cache-modules/--no-cache-modules
2379 func_get_automake_snippet_unconditional ()
2383 # *-tests module live in tests/, not lib/.
2384 # Synthesize an EXTRA_DIST augmentation.
2385 all_files=`func_get_filelist $1`
2386 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2387 extra_files="$tests_files"
2388 if test -n "$extra_files"; then
2389 echo "EXTRA_DIST +=" $extra_files
2394 # Synthesize an EXTRA_DIST augmentation.
2395 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2396 already_mentioned_files=` \
2397 { if ! $modcache; then
2398 func_lookup_file "modules/$1"
2399 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2401 func_cache_lookup_module "$1"
2402 if $have_associative; then
2403 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2404 eval 'echo "${modcache_makefile[$1]}"'
2407 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2408 if test -n "$field_set"; then
2409 eval 'field_value="$'"${cachevar}"'_makefile"'
2410 echo "${field_value}"
2416 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2417 all_files=`func_get_filelist $1`
2418 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2419 # Remove $already_mentioned_files from $lib_files.
2420 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2421 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2422 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2423 if test -n "$extra_files"; then
2424 echo "EXTRA_DIST +=" $extra_files
2427 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2428 # This is necessary so that automake can generate the right list of
2430 # A possible approach would be to use autom4te --trace of the redefined
2431 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2432 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2433 # inside autoconf's built-in macros are not missed).
2434 # But it's simpler and more robust to do it here, based on the file list.
2435 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2436 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2437 # automake will generate a useless dependency; this is harmless.
2439 relocatable-prog-wrapper) ;;
2442 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2443 if test -n "$extra_files"; then
2444 echo "EXTRA_lib_SOURCES +=" $extra_files
2449 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2450 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2451 if test -n "$buildaux_files"; then
2452 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2453 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2456 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2457 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2458 if test -n "$top_files"; then
2459 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2460 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2467 # func_get_automake_snippet module
2469 # - local_gnulib_path from --local-dir
2470 # - modcache true or false, from --cache-modules/--no-cache-modules
2471 func_get_automake_snippet ()
2473 func_get_automake_snippet_conditional "$1"
2474 func_get_automake_snippet_unconditional "$1"
2477 # func_get_include_directive module
2479 # - local_gnulib_path from --local-dir
2480 # - modcache true or false, from --cache-modules/--no-cache-modules
2481 func_get_include_directive ()
2484 if ! $modcache; then
2485 func_lookup_file "modules/$1"
2486 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2488 func_cache_lookup_module "$1"
2489 # Output the field's value, including the final newline (if any).
2490 if $have_associative; then
2491 if eval 'test -n "${modcache_include[$1]+set}"'; then
2492 eval 'echo "${modcache_include[$1]}"'
2495 eval "field_set=\"\$${cachevar}_include_set\""
2496 if test -n "$field_set"; then
2497 eval "field_value=\"\$${cachevar}_include\""
2498 echo "${field_value}"
2502 } | sed -e 's/^\(["<]\)/#include \1/'
2505 # func_get_link_directive module
2507 # - local_gnulib_path from --local-dir
2508 # - modcache true or false, from --cache-modules/--no-cache-modules
2509 func_get_link_directive ()
2511 if ! $modcache; then
2512 func_lookup_file "modules/$1"
2513 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2515 func_cache_lookup_module "$1"
2516 # Output the field's value, including the final newline (if any).
2517 if $have_associative; then
2518 if eval 'test -n "${modcache_link[$1]+set}"'; then
2519 eval 'echo "${modcache_link[$1]}"'
2522 eval "field_set=\"\$${cachevar}_link_set\""
2523 if test -n "$field_set"; then
2524 eval "field_value=\"\$${cachevar}_link\""
2525 echo "${field_value}"
2531 # func_get_license_raw module
2533 # - local_gnulib_path from --local-dir
2534 # - modcache true or false, from --cache-modules/--no-cache-modules
2535 func_get_license_raw ()
2537 if ! $modcache; then
2538 func_lookup_file "modules/$1"
2539 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2541 func_cache_lookup_module "$1"
2542 # Output the field's value, including the final newline (if any).
2543 if $have_associative; then
2544 if eval 'test -n "${modcache_license[$1]+set}"'; then
2545 eval 'echo "${modcache_license[$1]}"'
2548 eval "field_set=\"\$${cachevar}_license_set\""
2549 if test -n "$field_set"; then
2550 eval "field_value=\"\$${cachevar}_license\""
2551 echo "${field_value}"
2557 # func_get_license module
2559 # - local_gnulib_path from --local-dir
2560 # - modcache true or false, from --cache-modules/--no-cache-modules
2563 # Warn if the License field is missing.
2567 license=`func_get_license_raw "$1"`
2568 if test -z "$license"; then
2569 func_warning "module $1 lacks a License"
2574 func_get_license_raw "$1"
2575 # The default is GPL.
2577 } | sed -e 's,^ *$,,' | sed -e 1q
2580 # func_get_maintainer module
2582 # - local_gnulib_path from --local-dir
2583 # - modcache true or false, from --cache-modules/--no-cache-modules
2584 func_get_maintainer ()
2586 if ! $modcache; then
2587 func_lookup_file "modules/$1"
2588 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2590 func_cache_lookup_module "$1"
2591 # Output the field's value, including the final newline (if any).
2592 if $have_associative; then
2593 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2594 eval 'echo "${modcache_maintainer[$1]}"'
2597 eval "field_set=\"\$${cachevar}_maintainer_set\""
2598 if test -n "$field_set"; then
2599 eval "field_value=\"\$${cachevar}_maintainer\""
2600 echo "${field_value}"
2606 # func_get_tests_module module
2608 # - local_gnulib_path from --local-dir
2609 func_get_tests_module ()
2611 # The naming convention for tests modules is hardwired: ${module}-tests.
2612 if test -f "$gnulib_dir/modules/$1"-tests \
2613 || func_path_foreach "$local_gnulib_path" func_exists_local_module %dir% "$1-tests"; then
2618 # func_acceptable module
2619 # tests whether a module is acceptable.
2621 # - avoidlist list of modules to avoid
2624 for avoid in $avoidlist; do
2625 if test "$avoid" = "$1"; then
2632 # sed expression to keep the first 32 characters of each line.
2633 sed_first_32_chars='s/^\(................................\).*/\1/'
2635 # func_module_shellfunc_name module
2636 # computes the shell function name that will contain the m4 macros for the module.
2638 # - macro_prefix prefix to use
2640 # - shellfunc shell function name
2641 func_module_shellfunc_name ()
2645 shellfunc=func_${macro_prefix}_gnulib_m4code_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2647 shellfunc=func_${macro_prefix}_gnulib_m4code_$1 ;;
2651 # func_module_shellvar_name module
2652 # computes the shell variable name the will be set to true once the m4 macros
2653 # for the module have been executed.
2655 # - shellvar shell variable name
2656 func_module_shellvar_name ()
2660 shellvar=${macro_prefix}_gnulib_enabled_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2662 shellvar=${macro_prefix}_gnulib_enabled_$1 ;;
2666 # func_module_conditional_name module
2667 # computes the automake conditional name for the module.
2669 # - conditional name of automake conditional
2670 func_module_conditional_name ()
2674 conditional=${macro_prefix}_GNULIB_ENABLED_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2676 conditional=${macro_prefix}_GNULIB_ENABLED_$1 ;;
2680 # func_uncond_add_module B
2681 # notes the presence of B as an unconditional module.
2683 # func_conddep_add_module A B cond
2684 # notes the presence of a conditional dependency from module A to module B,
2685 # subject to the condition that A is enabled and cond is true.
2687 # func_cond_module_p B
2688 # tests whether module B is conditional.
2690 # func_cond_module_condition A B
2691 # returns the condition when B should be enabled as a dependency of A, once the
2692 # m4 code for A has been executed.
2693 # Output: - condition
2695 if $have_associative; then
2696 declare -A conddep_isuncond
2697 declare -A conddep_dependers
2698 declare -A conddep_condition
2699 func_uncond_add_module ()
2701 eval 'conddep_isuncond[$1]=true'
2702 eval 'unset conddep_dependers[$1]'
2704 func_conddep_add_module ()
2706 eval 'isuncond="${conddep_isuncond[$2]}"'
2707 if test -z "$isuncond"; then
2708 # No unconditional dependency to B known at this point.
2709 eval 'conddep_dependers[$2]="${conddep_dependers[$2]} $1"'
2710 eval 'conddep_condition[$1---$2]="$3"'
2713 func_cond_module_p ()
2715 eval 'previous_dependers="${conddep_dependers[$1]}"'
2716 test -n "$previous_dependers"
2718 func_cond_module_condition ()
2720 eval 'condition="${conddep_condition[$1---$2]}"'
2723 func_uncond_add_module ()
2727 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2731 eval 'conddep_isuncond_'"$suffix"'=true'
2732 eval 'unset conddep_dependers_'"$suffix"
2734 func_conddep_add_module ()
2738 suffix=`echo "$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2742 eval 'isuncond="${conddep_isuncond_'"$suffix"'}"'
2743 if test -z "$isuncond"; then
2744 eval 'conddep_dependers_'"$suffix"'="${conddep_dependers_'"$suffix"'} $1"'
2745 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2746 eval 'conddep_condition_'"$suffix"'="$3"'
2749 func_cond_module_p ()
2753 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2757 eval 'previous_dependers="${conddep_dependers_'"$suffix"'}"'
2758 test -n "$previous_dependers"
2760 func_cond_module_condition ()
2762 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2763 eval 'condition="${conddep_condition_'"$suffix"'}"'
2767 sed_dependencies_without_conditions='s/ *\[.*//'
2769 # func_modules_transitive_closure
2771 # - local_gnulib_path from --local-dir
2772 # - modcache true or false, from --cache-modules/--no-cache-modules
2773 # - modules list of specified modules
2774 # - inctests true if tests should be included, false otherwise
2775 # - incobsolete true if obsolete modules among dependencies should be
2776 # included, blank otherwise
2777 # - inc_cxx_tests true if C++ interoperability tests should be included,
2779 # - inc_longrunning_tests true if long-runnings tests should be included,
2781 # - inc_privileged_tests true if tests that require root privileges should be
2782 # included, blank otherwise
2783 # - inc_unportable_tests true if tests that fail on some platforms should be
2784 # included, blank otherwise
2785 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2786 # the unit tests of the specified modules should be
2787 # included, blank otherwise
2788 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2789 # the unit tests of the dependencies should be
2790 # included, blank otherwise
2791 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2793 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2795 # - excl_privileged_tests true if tests that require root privileges should be
2796 # excluded, blank otherwise
2797 # - excl_unportable_tests true if tests that fail on some platforms should be
2798 # excluded, blank otherwise
2799 # - avoidlist list of modules to avoid
2800 # - cond_dependencies true if conditional dependencies shall be supported,
2802 # - tmp pathname of a temporary directory
2804 # - modules list of modules, including dependencies
2805 # - conddep_dependers, conddep_condition information about conditionally
2807 func_modules_transitive_closure ()
2809 sed_escape_dependency='s|\([/.]\)|\\\1|g'
2810 # In order to process every module only once (for speed), process an "input
2811 # list" of modules, producing an "output list" of modules. During each round,
2812 # more modules can be queued in the input list. Once a module on the input
2813 # list has been processed, it is added to the "handled list", so we can avoid
2814 # to process it again.
2816 inmodules="$modules"
2818 fmtc_inc_all_tests="$inc_all_direct_tests"
2819 if test "$cond_dependencies" = true; then
2820 for module in $inmodules; do
2822 if test -n "$module"; then
2823 if func_acceptable $module; then
2824 func_uncond_add_module $module
2829 while test -n "$inmodules"; do
2830 inmodules_this_round="$inmodules"
2831 inmodules= # Accumulator, queue for next round
2832 for module in $inmodules_this_round; do
2834 if test -n "$module"; then
2835 if func_acceptable $module; then
2836 func_append outmodules " $module"
2837 if test "$cond_dependencies" = true; then
2838 if func_get_automake_snippet_conditional $module | grep '^if ' > /dev/null; then
2839 # A module whose Makefile.am snippet contains a reference to an
2840 # automake conditional. If we were to use it conditionally, we
2841 # would get an error
2842 # configure: error: conditional "..." was never defined.
2843 # because automake 1.11.1 does not handle nested conditionals
2844 # correctly. As a workaround, make the module unconditional.
2845 func_uncond_add_module $module
2847 if func_cond_module_p $module; then
2853 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2854 # Duplicate dependencies are harmless, but Jim wants a warning.
2855 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2856 if test -n "$duplicated_deps"; then
2857 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2860 testsmodule=`func_get_tests_module $module`
2861 if test -n "$testsmodule"; then
2862 deps="$deps $testsmodule"
2865 for dep in $deps; do
2866 # Determine whether to include the dependency or tests module.
2868 for word in `func_get_status $dep`; do
2871 test -n "$incobsolete" \
2875 test -z "$excl_cxx_tests" \
2877 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2881 test -z "$excl_longrunning_tests" \
2883 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2887 test -z "$excl_privileged_tests" \
2889 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2893 test -z "$excl_unportable_tests" \
2895 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2899 test -n "$fmtc_inc_all_tests" \
2904 if $inc && func_acceptable "$dep"; then
2905 func_append inmodules " $dep"
2906 if test "$cond_dependencies" = true; then
2907 escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
2908 sed_extract_condition1='/^ *'"$escaped_dep"' *$/{
2911 sed_extract_condition2='/^ *'"$escaped_dep"' *\[.*\] *$/{
2912 s/^ *'"$escaped_dep"' *\[\(.*\)\] *$/\1/p
2914 condition=`func_get_dependencies $module | sed -n -e "$sed_extract_condition1" -e "$sed_extract_condition2"`
2915 if test "$condition" = true; then
2918 if test -n "$condition"; then
2919 func_conddep_add_module "$module" "$dep" "$condition"
2921 if $conditional; then
2922 func_conddep_add_module "$module" "$dep" true
2924 func_uncond_add_module "$dep"
2933 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2934 # Remove $handledmodules from $inmodules.
2935 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2936 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2937 fmtc_inc_all_tests="$inc_all_indirect_tests"
2939 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2940 rm -f "$tmp"/queued-modules
2943 # func_show_module_list
2945 # - specified_modules list of specified modules (one per line, sorted)
2946 # - modules complete list of modules (one per line, sorted)
2947 # - tmp pathname of a temporary directory
2948 func_show_module_list ()
2954 # Assume xterm compatible escape sequences.
2955 bold_on=`printf '\033[1m'`
2956 bold_off=`printf '\033[0m'`
2961 echo "Module list with included dependencies (indented):"
2962 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2963 echo "$modules" | sed -e '/^$/d' \
2964 | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
2965 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2968 # func_modules_transitive_closure_separately
2969 # Determine main module list and tests-related module list separately.
2970 # The main module list is the transitive closure of the specified modules,
2971 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2972 # is specified, it will consist only of LGPLed source.
2973 # The tests-related module list is the transitive closure of the specified
2974 # modules, including tests modules, minus the main module list excluding
2975 # modules of applicability 'all'. Its lib/* sources (brought in through
2976 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
2977 # source, even if --lgpl is specified.
2979 # - local_gnulib_path from --local-dir
2980 # - modcache true or false, from --cache-modules/--no-cache-modules
2981 # - specified_modules list of specified modules
2982 # - inctests true if tests should be included, false otherwise
2983 # - incobsolete true if obsolete modules among dependencies should be
2984 # included, blank otherwise
2985 # - inc_cxx_tests true if C++ interoperability tests should be included,
2987 # - inc_longrunning_tests true if long-runnings tests should be included,
2989 # - inc_privileged_tests true if tests that require root privileges should be
2990 # included, blank otherwise
2991 # - inc_unportable_tests true if tests that fail on some platforms should be
2992 # included, blank otherwise
2993 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2994 # the unit tests of the specified modules should be
2995 # included, blank otherwise
2996 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2997 # the unit tests of the dependencies should be
2998 # included, blank otherwise
2999 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
3001 # - excl_longrunning_tests true if long-runnings tests should be excluded,
3003 # - excl_privileged_tests true if tests that require root privileges should be
3004 # excluded, blank otherwise
3005 # - excl_unportable_tests true if tests that fail on some platforms should be
3006 # excluded, blank otherwise
3007 # - avoidlist list of modules to avoid
3008 # - cond_dependencies true if conditional dependencies shall be supported,
3010 # - tmp pathname of a temporary directory
3012 # - main_modules list of modules, including dependencies
3013 # - testsrelated_modules list of tests-related modules, including dependencies
3014 # - conddep_dependers, conddep_condition information about conditionally
3016 func_modules_transitive_closure_separately ()
3018 # Determine main module list.
3019 saved_inctests="$inctests"
3021 modules="$specified_modules"
3022 func_modules_transitive_closure
3023 main_modules="$modules"
3024 inctests="$saved_inctests"
3025 if test $verbose -ge 1; then
3026 echo "Main module list:"
3027 echo "$main_modules" | sed -e 's/^/ /'
3029 # Determine tests-related module list.
3030 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3031 testsrelated_modules=`for module in $main_modules; do
3032 if test \`func_get_applicability $module\` = main; then
3036 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3037 if test $verbose -ge 1; then
3038 echo "Tests-related module list:"
3039 echo "$testsrelated_modules" | sed -e 's/^/ /'
3043 # func_determine_use_libtests
3044 # Determines whether a $testsbase/libtests.a is needed.
3046 # - local_gnulib_path from --local-dir
3047 # - modcache true or false, from --cache-modules/--no-cache-modules
3048 # - testsrelated_modules list of tests-related modules, including dependencies
3050 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3051 func_determine_use_libtests ()
3054 for module in $testsrelated_modules; do
3055 func_verify_nontests_module
3056 if test -n "$module"; then
3057 all_files=`func_get_filelist $module`
3058 # Test whether some file in $all_files lies in lib/.
3059 for f in $all_files; do
3071 # func_modules_add_dummy
3073 # - local_gnulib_path from --local-dir
3074 # - modcache true or false, from --cache-modules/--no-cache-modules
3075 # - modules list of modules, including dependencies
3077 # - modules list of modules, including 'dummy' if needed
3078 func_modules_add_dummy ()
3080 # Determine whether any module provides a lib_SOURCES augmentation.
3082 for module in $modules; do
3083 func_verify_nontests_module
3084 if test -n "$module"; then
3085 # Extract the value of "lib_SOURCES += ...".
3086 for file in `func_get_automake_snippet "$module" | combine_lines |
3087 sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
3088 # Ignore .h files since they are not compiled.
3092 have_lib_SOURCES=yes
3099 # Add the dummy module, to make sure the library will be non-empty.
3100 if test -z "$have_lib_SOURCES"; then
3101 if func_acceptable "dummy"; then
3102 func_append modules " dummy"
3107 # func_modules_add_dummy_separately
3109 # - local_gnulib_path from --local-dir
3110 # - modcache true or false, from --cache-modules/--no-cache-modules
3111 # - main_modules list of modules, including dependencies
3112 # - testsrelated_modules list of tests-related modules, including dependencies
3113 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
3115 # - main_modules list of modules, including 'dummy' if needed
3116 # - testsrelated_modules list of tests-related modules, including 'dummy' if
3118 func_modules_add_dummy_separately ()
3120 # Add the dummy module to the main module list if needed.
3121 modules="$main_modules"
3122 func_modules_add_dummy
3123 main_modules="$modules"
3125 # Add the dummy module to the tests-related module list if needed.
3126 if $use_libtests; then
3127 modules="$testsrelated_modules"
3128 func_modules_add_dummy
3129 testsrelated_modules="$modules"
3133 # func_modules_notice
3135 # - local_gnulib_path from --local-dir
3136 # - modcache true or false, from --cache-modules/--no-cache-modules
3137 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3138 # - modules list of modules, including dependencies
3139 func_modules_notice ()
3141 if test $verbose -ge -1; then
3142 for module in $modules; do
3144 if test -n "$module"; then
3145 msg=`func_get_notice $module`
3146 if test -n "$msg"; then
3147 echo "Notice from module $module:"
3148 echo "$msg" | sed -e 's/^/ /'
3155 # func_modules_to_filelist
3157 # - local_gnulib_path from --local-dir
3158 # - modcache true or false, from --cache-modules/--no-cache-modules
3159 # - modules list of modules, including dependencies
3161 # - files list of files
3162 func_modules_to_filelist ()
3165 for module in $modules; do
3167 if test -n "$module"; then
3168 fs=`func_get_filelist $module`
3169 func_append files " $fs"
3172 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
3175 # func_modules_to_filelist_separately
3176 # Determine the final file lists.
3177 # They must be computed separately, because files in lib/* go into
3178 # $sourcebase/ if they are in the main file list but into $testsbase/
3179 # if they are in the tests-related file list. Furthermore lib/dummy.c
3182 # - local_gnulib_path from --local-dir
3183 # - modcache true or false, from --cache-modules/--no-cache-modules
3184 # - main_modules list of modules, including dependencies
3185 # - testsrelated_modules list of tests-related modules, including dependencies
3186 func_modules_to_filelist_separately ()
3188 # Determine final main file list.
3189 modules="$main_modules"
3190 func_modules_to_filelist
3192 # Determine final tests-related file list.
3193 modules="$testsrelated_modules"
3194 func_modules_to_filelist
3195 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3196 # Merge both file lists.
3197 sed_remove_empty_lines='/^$/d'
3198 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3199 if test $verbose -ge 0; then
3201 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3202 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3206 # func_compute_include_guard_prefix
3207 # Determine include_guard_prefix.
3209 # - macro_prefix prefix of gl_LIBOBJS macros to use
3211 # - include_guard_prefix replacement for ${gl_include_guard_prefix}
3212 # - sed_replace_include_guard_prefix
3213 # sed expression for resolving ${gl_include_guard_prefix}
3214 func_compute_include_guard_prefix ()
3216 if test "$macro_prefix" = gl; then
3217 include_guard_prefix='GL'
3219 include_guard_prefix='GL_'`echo "$macro_prefix" | LC_ALL=C tr '[a-z]' '[A-Z]'`
3221 sed_replace_include_guard_prefix='s/\${gl_include_guard_prefix}/'"${include_guard_prefix}"'/g'
3224 # func_execute_command command [args...]
3225 # Executes a command.
3226 # Uses also the variables
3227 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3228 func_execute_command ()
3230 if test $verbose -ge 0; then
3234 # Commands like automake produce output to stderr even when they succeed.
3235 # Turn this output off if the command succeeds.
3236 "$@" > "$tmp"/cmdout 2>&1
3238 if test $cmdret = 0; then
3242 cat "$tmp"/cmdout 1>&2
3249 # func_dest_tmpfilename file
3250 # determines the name of a temporary file (file is relative to destdir).
3252 # - destdir target directory
3253 # - doit : if actions shall be executed, false if only to be printed
3254 # - tmp pathname of a temporary directory
3256 # - tmpfile absolute filename of the temporary file
3257 func_dest_tmpfilename ()
3260 # Put the new contents of $file in a file in the same directory (needed
3261 # to guarantee that an 'mv' to "$destdir/$file" works).
3262 tmpfile="$destdir/$1.tmp"
3264 # Put the new contents of $file in a file in a temporary directory
3265 # (because the directory of "$file" might not exist).
3266 tmpfile="$tmp"/`basename "$1"`.tmp
3270 # func_is_local_file lookedup_file file
3271 # check whether file should be instantiated from local gnulib directory
3272 func_is_local_file ()
3275 func_remove_suffix dname "/$2"
3276 func_path_foreach "$local_gnulib_path" test %dir% = "$dname"
3279 # func_should_symlink
3280 # returns 0 when the file $f should be symlinked
3282 # - symbolic true if files should be symlinked, copied otherwise
3283 # - lsymbolic true if files from local_gnulib_path should be symlinked,
3285 # - f the original file name
3286 # - lookedup_file name of the merged (combined) file
3287 func_should_symlink ()
3289 test -n "$symbolic" \
3290 || { test -n "$lsymbolic" \
3291 && func_is_local_file "$lookedup_file" "$f"; }
3295 # copies a file from gnulib into the destination directory. The destination
3296 # is known to not exist.
3298 # - destdir target directory
3299 # - local_gnulib_path from --local-dir
3300 # - modcache true or false, from --cache-modules/--no-cache-modules
3301 # - f the original file name
3302 # - lookedup_file name of the merged (combined) file
3303 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3304 # - g the rewritten file name
3305 # - tmpfile absolute filename of the temporary file
3306 # - doit : if actions shall be executed, false if only to be printed
3307 # - symbolic true if files should be symlinked, copied otherwise
3308 # - lsymbolic true if files from local_gnulib_path should be symlinked,
3313 echo "Copying file $g"
3314 if func_should_symlink \
3315 && test -z "$lookedup_tmp" \
3316 && cmp -s "$lookedup_file" "$tmpfile"; then
3317 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3319 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3327 # copies a file from gnulib into the destination directory. The destination
3328 # is known to exist.
3330 # - destdir target directory
3331 # - local_gnulib_path from --local-dir
3332 # - modcache true or false, from --cache-modules/--no-cache-modules
3333 # - f the original file name
3334 # - lookedup_file name of the merged (combined) file
3335 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3336 # - g the rewritten file name
3337 # - tmpfile absolute filename of the temporary file
3338 # - doit : if actions shall be executed, false if only to be printed
3339 # - symbolic true if files should be symlinked, copied otherwise
3340 # - lsymbolic true if files from local_gnulib_path should be symlinked,
3342 # - already_present nonempty if the file should already exist, empty otherwise
3345 if cmp -s "$destdir/$g" "$tmpfile"; then
3346 : # The file has not changed.
3350 if test -n "$already_present"; then
3351 echo "Updating file $g (backup in ${g}~)"
3353 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
3355 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3356 if func_should_symlink \
3357 && test -z "$lookedup_tmp" \
3358 && cmp -s "$lookedup_file" "$tmpfile"; then
3359 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3361 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3364 if test -n "$already_present"; then
3365 echo "Update file $g (backup in ${g}~)"
3367 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
3373 # func_emit_lib_Makefile_am
3374 # emits the contents of library makefile to standard output.
3376 # - local_gnulib_path from --local-dir
3377 # - modcache true or false, from --cache-modules/--no-cache-modules
3378 # - modules list of modules, including dependencies
3379 # - libname library name
3380 # - pobase directory relative to destdir where to place *.po files
3381 # - auxdir directory relative to destdir where to place build aux files
3382 # - makefile_name from --makefile-name
3383 # - libtool true if libtool will be used, false or blank otherwise
3384 # - macro_prefix prefix of gl_LIBOBJS macros to use
3385 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3386 # - witness_c_macro from --witness-c-macro
3387 # - actioncmd (optional) command that will reproduce this invocation
3388 # - for_test true if creating a package for testing, false otherwise
3389 # - sed_replace_include_guard_prefix
3390 # sed expression for resolving ${gl_include_guard_prefix}
3391 # - destfile filename relative to destdir of makefile being generated
3393 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3394 # list of edits to be done to Makefile.am variables
3396 # - uses_subdirs nonempty if object files in subdirs exist
3397 func_emit_lib_Makefile_am ()
3399 # When creating an includable Makefile.am snippet, augment variables with
3400 # += instead of assigning them.
3401 if test -n "$makefile_name"; then
3406 if test "$libtool" = true; then
3409 sed_eliminate_LDFLAGS="$sed_noop"
3413 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3416 # When creating a package for testing: Attempt to provoke failures,
3417 # especially link errors, already during "make" rather than during
3418 # "make check", because "make check" is not possible in a cross-compiling
3419 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3420 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3422 sed_transform_check_PROGRAMS="$sed_noop"
3424 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3425 echo "## Process this file with automake to produce Makefile.in."
3426 func_emit_copyright_notice
3427 if test -n "$actioncmd"; then
3428 # The maximum line length (excluding the terminating newline) of any file
3429 # that is to be preprocessed by config.status is 3070. config.status uses
3430 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
3431 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
3432 len=`echo "$actioncmd" | wc -c`
3433 if test -n "$len" && test "$len" -le 3000; then
3434 echo "# Reproduce by: $actioncmd"
3440 for module in $modules; do
3441 func_verify_nontests_module
3442 if test -n "$module"; then
3444 func_get_automake_snippet_conditional "$module" |
3446 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3447 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3448 -e "$sed_eliminate_LDFLAGS" \
3449 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3450 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3451 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3452 -e "$sed_transform_check_PROGRAMS" \
3453 -e "$sed_replace_include_guard_prefix"
3454 if test "$module" = 'alloca'; then
3455 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
3456 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3458 } | combine_lines "${libname}_${libext}_SOURCES" > "$tmp"/amsnippet1
3460 func_get_automake_snippet_unconditional "$module" |
3461 LC_ALL=C sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
3462 } > "$tmp"/amsnippet2
3463 # Skip the contents if it's entirely empty.
3464 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
3465 echo "## begin gnulib module $module"
3467 if test "$cond_dependencies" = true; then
3468 if func_cond_module_p "$module"; then
3469 func_module_conditional_name "$module"
3470 echo "if $conditional"
3473 cat "$tmp"/amsnippet1
3474 if test "$cond_dependencies" = true; then
3475 if func_cond_module_p "$module"; then
3479 cat "$tmp"/amsnippet2
3480 echo "## end gnulib module $module"
3483 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
3484 # Test whether there are some source files in subdirectories.
3485 for f in `func_get_filelist "$module"`; do
3495 } > "$tmp"/allsnippets
3496 if test -z "$makefile_name"; then
3497 # If there are source files in subdirectories, prevent collision of the
3498 # object files (example: hash.c and libxml/hash.c).
3500 if test -n "$uses_subdirs"; then
3501 subdir_options=' subdir-objects'
3503 echo "AUTOMAKE_OPTIONS = 1.9.6 gnits${subdir_options}"
3506 if test -z "$makefile_name"; then
3508 echo "noinst_HEADERS ="
3509 echo "noinst_LIBRARIES ="
3510 echo "noinst_LTLIBRARIES ="
3511 # Automake versions < 1.11.4 create an empty pkgdatadir at
3512 # installation time if you specify pkgdata_DATA to empty.
3513 # See automake bugs #10997 and #11030:
3514 # * http://debbugs.gnu.org/10997
3515 # * http://debbugs.gnu.org/11030
3516 # So we need this workaround.
3517 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
3518 echo "pkgdata_DATA ="
3521 echo "BUILT_SOURCES ="
3524 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3525 if test -z "$makefile_name"; then
3526 echo "MOSTLYCLEANDIRS ="
3528 echo "DISTCLEANFILES ="
3529 echo "MAINTAINERCLEANFILES ="
3531 # Execute edits that apply to the Makefile.am being generated.
3533 while test $edit != $makefile_am_edits; do
3534 edit=`expr $edit + 1`
3535 eval dir=\"\$makefile_am_edit${edit}_dir\"
3536 eval var=\"\$makefile_am_edit${edit}_var\"
3537 eval val=\"\$makefile_am_edit${edit}_val\"
3538 if test -n "$var"; then
3539 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3540 echo "${var} += ${val}"
3541 eval "makefile_am_edit${edit}_var="
3545 if test -n "$witness_c_macro"; then
3546 cppflags_part1=" -D$witness_c_macro=1"
3551 cppflags_part2=" -DGNULIB_STRICT_CHECKING=1"
3555 if test -z "$makefile_name"; then
3557 echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
3560 if test -n "$cppflags_part1$cppflags_part2"; then
3562 echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
3566 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
3567 || { test -n "$makefile_name" \
3568 && test -f "$sourcebase/Makefile.am" \
3569 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
3571 # One of the snippets or the user's Makefile.am already specifies an
3572 # installation location for the library. Don't confuse automake by saying
3573 # it should not be installed.
3576 # By default, the generated library should not be installed.
3577 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3580 echo "${libname}_${libext}_SOURCES ="
3581 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3582 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3583 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3584 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3585 echo "EXTRA_${libname}_${libext}_SOURCES ="
3586 if test "$libtool" = true; then
3587 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3588 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3589 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3590 # the link dependencies of all modules.
3591 for module in $modules; do
3592 func_verify_nontests_module
3593 if test -n "$module"; then
3594 func_get_link_directive "$module"
3597 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
3598 | LC_ALL=C sort -u \
3599 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
3602 if test -n "$pobase"; then
3603 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
3606 cat "$tmp"/allsnippets \
3607 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3609 echo "mostlyclean-local: mostlyclean-generic"
3610 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3611 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3612 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3616 rm -f "$tmp"/allsnippets
3619 # func_emit_po_Makevars
3620 # emits the contents of po/ makefile parameterization to standard output.
3622 # - local_gnulib_path from --local-dir
3623 # - modcache true or false, from --cache-modules/--no-cache-modules
3624 # - sourcebase directory relative to destdir where to place source code
3625 # - pobase directory relative to destdir where to place *.po files
3626 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3627 func_emit_po_Makevars ()
3629 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3630 func_emit_copyright_notice
3632 echo "# Usually the message domain is the same as the package name."
3633 echo "# But here it has a '-gnulib' suffix."
3634 echo "DOMAIN = ${po_domain}-gnulib"
3636 echo "# These two variables depend on the location of this directory."
3637 echo "subdir = ${pobase}"
3638 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
3641 # These options get passed to xgettext.
3642 XGETTEXT_OPTIONS = \
3643 --keyword=_ --flag=_:1:pass-c-format \
3644 --keyword=N_ --flag=N_:1:pass-c-format \
3645 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
3646 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
3647 --flag=error:3:c-format --flag=error_at_line:5:c-format
3649 # This is the copyright holder that gets inserted into the header of the
3650 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
3651 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
3653 # This is the email address or URL to which the translators shall report
3654 # bugs in the untranslated strings:
3655 # - Strings which are not entire sentences, see the maintainer guidelines
3656 # in the GNU gettext documentation, section 'Preparing Strings'.
3657 # - Strings which use unclear terms or require additional context to be
3659 # - Strings which make invalid assumptions about notation of date, time or
3661 # - Pluralisation problems.
3662 # - Incorrect English spelling.
3663 # - Incorrect formatting.
3664 # It can be your email address, or a mailing list address where translators
3665 # can write to without being subscribed, or the URL of a web page through
3666 # which the translators can contact you.
3667 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3669 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3670 # message catalogs shall be used. It is usually empty.
3671 EXTRA_LOCALE_CATEGORIES =
3673 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3674 # context. Possible values are "yes" and "no". Set this to yes if the
3675 # package uses functions taking also a message context, like pgettext(), or
3676 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3681 # func_emit_po_POTFILES_in
3682 # emits the file list to be passed to xgettext to standard output.
3684 # - local_gnulib_path from --local-dir
3685 # - modcache true or false, from --cache-modules/--no-cache-modules
3686 # - sourcebase directory relative to destdir where to place source code
3687 # - files list of new files
3688 func_emit_po_POTFILES_in ()
3690 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3691 func_emit_copyright_notice
3693 echo "# List of files which contain translatable strings."
3694 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3697 # func_emit_tests_Makefile_am witness_macro
3698 # emits the contents of tests makefile to standard output.
3700 # - local_gnulib_path from --local-dir
3701 # - modcache true or false, from --cache-modules/--no-cache-modules
3702 # - modules list of modules, including dependencies
3703 # - libname library name
3704 # - auxdir directory relative to destdir where to place build aux files
3705 # - makefile_name from --makefile-name
3706 # - libtool true if libtool will be used, false or blank otherwise
3707 # - sourcebase relative directory containing lib source code
3708 # - m4base relative directory containing autoconf macros
3709 # - testsbase relative directory containing unit test code
3710 # - macro_prefix prefix of gl_LIBOBJS macros to use
3711 # - witness_c_macro from --witness-c-macro
3712 # - for_test true if creating a package for testing, false otherwise
3713 # - single_configure true if a single configure file should be generated,
3714 # false for a separate configure file for the tests
3715 # - use_libtests true if a libtests.a should be built, false otherwise
3716 # - sed_replace_include_guard_prefix
3717 # sed expression for resolving ${gl_include_guard_prefix}
3718 # - destfile filename relative to destdir of makefile being generated
3720 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3721 # list of edits to be done to Makefile.am variables
3723 # - uses_subdirs nonempty if object files in subdirs exist
3724 func_emit_tests_Makefile_am ()
3727 if test "$libtool" = true; then
3730 sed_eliminate_LDFLAGS="$sed_noop"
3734 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3737 # When creating a package for testing: Attempt to provoke failures,
3738 # especially link errors, already during "make" rather than during
3739 # "make check", because "make check" is not possible in a cross-compiling
3740 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3741 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3743 sed_transform_check_PROGRAMS="$sed_noop"
3745 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3746 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3747 echo "## Process this file with automake to produce Makefile.in."
3748 func_emit_copyright_notice
3752 for module in $modules; do
3753 if $for_test && ! $single_configure; then
3754 func_verify_tests_module
3758 if test -n "$module"; then
3760 func_get_automake_snippet "$module" |
3762 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3763 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3764 -e "$sed_eliminate_LDFLAGS" \
3765 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3766 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3767 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3768 -e "$sed_transform_check_PROGRAMS" \
3769 -e "$sed_replace_include_guard_prefix"
3770 if $use_libtests && test "$module" = 'alloca'; then
3771 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3772 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3774 } > "$tmp"/amsnippet
3775 # Skip the contents if it's entirely empty.
3776 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3777 # Mention long-running tests at the end.
3779 for word in `func_get_status "$module"`; do
3780 if test "$word" = 'longrunning-test'; then
3785 { echo "## begin gnulib module $module"
3787 cat "$tmp"/amsnippet
3788 echo "## end gnulib module $module"
3792 rm -f "$tmp"/amsnippet
3793 # Test whether there are some source files in subdirectories.
3794 for f in `func_get_filelist "$module"`; do
3796 lib/*/*.c | tests/*/*.c)
3804 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3805 # Generate dependencies here, since it eases the debugging of test failures.
3806 # If there are source files in subdirectories, prevent collision of the
3807 # object files (example: hash.c and libxml/hash.c).
3809 if test -n "$uses_subdirs"; then
3810 subdir_options=' subdir-objects'
3812 echo "AUTOMAKE_OPTIONS = 1.9.6 foreign${subdir_options}"
3814 if $for_test && ! $single_configure; then
3815 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3818 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3819 # variable is needed to avoid an error from automake:
3820 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3823 echo "XFAIL_TESTS ="
3824 echo "TESTS_ENVIRONMENT ="
3825 echo "noinst_PROGRAMS ="
3826 if ! $for_test; then
3827 echo "check_PROGRAMS ="
3829 echo "noinst_HEADERS ="
3830 echo "noinst_LIBRARIES ="
3831 if $use_libtests; then
3833 echo "noinst_LIBRARIES += libtests.a"
3835 echo "check_LIBRARIES = libtests.a"
3838 # Automake versions < 1.11.4 create an empty pkgdatadir at
3839 # installation time if you specify pkgdata_DATA to empty.
3840 # See automake bugs #10997 and #11030:
3841 # * http://debbugs.gnu.org/10997
3842 # * http://debbugs.gnu.org/11030
3843 # So we need this workaround.
3844 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3845 echo "pkgdata_DATA ="
3848 echo "BUILT_SOURCES ="
3850 echo "MOSTLYCLEANFILES = core *.stackdump"
3851 echo "MOSTLYCLEANDIRS ="
3853 echo "DISTCLEANFILES ="
3854 echo "MAINTAINERCLEANFILES ="
3855 # Execute edits that apply to the Makefile.am being generated.
3857 while test $edit != $makefile_am_edits; do
3858 edit=`expr $edit + 1`
3859 eval dir=\"\$makefile_am_edit${edit}_dir\"
3860 eval var=\"\$makefile_am_edit${edit}_var\"
3861 eval val=\"\$makefile_am_edit${edit}_val\"
3862 if test -n "$var"; then
3863 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3864 echo "${var} += ${val}"
3865 eval "makefile_am_edit${edit}_var="
3870 echo "AM_CPPFLAGS = \\"
3872 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3874 if test -n "$witness_c_macro"; then
3875 echo " -D$witness_c_macro=1 \\"
3877 if test -n "${witness_macro}"; then
3878 echo " -D@${witness_macro}@=1 \\"
3880 echo " -I. -I\$(srcdir) \\"
3881 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3882 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3884 local_ldadd_before=''
3885 local_ldadd_after=''
3886 if $use_libtests; then
3887 # All test programs need to be linked with libtests.a.
3888 # It needs to be passed to the linker before ${libname}.${libext}, since
3889 # the tests-related modules depend on the main modules.
3890 # It also needs to be passed to the linker after ${libname}.${libext}
3891 # because the latter might contain incomplete modules (such as the 'error'
3892 # module whose dependency to 'progname' is voluntarily omitted).
3893 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3895 local_ldadd_before=' libtests.a'
3896 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3898 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3900 if $use_libtests; then
3901 echo "libtests_a_SOURCES ="
3902 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3903 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3904 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3905 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3906 echo "EXTRA_libtests_a_SOURCES ="
3907 # The circular dependency in LDADD requires this.
3908 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3911 # Many test scripts use ${EXEEXT} or ${srcdir}.
3912 # EXEEXT is defined by AC_PROG_CC through autoconf.
3913 # srcdir is defined by autoconf and automake.
3914 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3916 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3917 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3918 echo "# Clean up after Solaris cc."
3920 echo " rm -rf SunWS_cache"
3922 echo "mostlyclean-local: mostlyclean-generic"
3923 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3924 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3925 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3929 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3932 # func_emit_initmacro_start macro_prefix
3933 # emits the first few statements of the gl_INIT macro to standard output.
3934 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3935 func_emit_initmacro_start ()
3937 macro_prefix_arg="$1"
3938 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3939 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3940 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3941 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3943 # Furthermore it avoids an automake error like this when a Makefile.am
3944 # that uses pieces of gnulib also uses $(LIBOBJ):
3945 # automatically discovered file `error.c' should not be explicitly mentioned
3946 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3947 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3948 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3949 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3950 # automatically discovered file `error.c' should not be explicitly mentioned
3951 # We let automake know about the files to be distributed through the
3952 # EXTRA_lib_SOURCES variable.
3953 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3954 # Create data variables for checking the presence of files that are mentioned
3955 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3956 # because we want the check to happen when the configure file is created,
3957 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3958 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3959 # in which to expect them.
3960 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3961 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3965 # func_emit_initmacro_end macro_prefix
3966 # emits the last few statements of the gl_INIT macro to standard output.
3967 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3968 func_emit_initmacro_end ()
3970 macro_prefix_arg="$1"
3971 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3972 # The check is performed only when autoconf is run from the directory where
3973 # the configure.ac resides; if it is run from a different directory, the
3975 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3976 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3977 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3978 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3979 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3983 echo " m4_if(m4_sysval, [0], [],"
3984 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3986 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3987 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3988 echo " m4_popdef([AC_LIBSOURCES])"
3989 echo " m4_popdef([AC_REPLACE_FUNCS])"
3990 echo " m4_popdef([AC_LIBOBJ])"
3991 echo " AC_CONFIG_COMMANDS_PRE(["
3992 echo " ${macro_prefix_arg}_libobjs="
3993 echo " ${macro_prefix_arg}_ltlibobjs="
3994 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3995 echo " # Remove the extension."
3996 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3997 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3998 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3999 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
4002 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
4003 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
4007 # func_emit_initmacro_done macro_prefix sourcebase
4008 # emits a few statements after the gl_INIT macro to standard output.
4009 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4010 # - sourcebase directory relative to destdir where to place source code
4011 func_emit_initmacro_done ()
4013 macro_prefix_arg="$1"
4016 echo "# Like AC_LIBOBJ, except that the module name goes"
4017 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4018 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
4019 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
4020 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
4023 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
4024 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
4025 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
4026 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
4027 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
4030 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
4031 echo "# expected is derived from the gnulib-tool parameterization,"
4032 echo "# and alloca is special cased (for the alloca-opt module)."
4033 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
4034 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
4035 echo " m4_foreach([_gl_NAME], [\$1], ["
4036 echo " m4_if(_gl_NAME, [alloca.c], [], ["
4037 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
4038 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
4044 # func_emit_autoconf_snippet indentation
4045 # emits the autoconf snippet of a module.
4047 # - indentation spaces to prepend on each line
4048 # - local_gnulib_path from --local-dir
4049 # - modcache true or false, from --cache-modules/--no-cache-modules
4050 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4051 # - sed_replace_include_guard_prefix
4052 # sed expression for resolving ${gl_include_guard_prefix}
4053 # - module the module name
4054 # - toplevel true or false. 'false' means a subordinate use of
4056 # - disable_libtool true or false. It tells whether to disable libtool
4057 # handling even if it has been specified through the
4058 # command line options.
4059 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4061 func_emit_autoconf_snippet ()
4064 if { case $module in
4065 gnumakefile | maintainer-makefile)
4066 # These modules are meant to be used only in the top-level directory.
4072 func_get_autoconf_snippet "$module" \
4073 | sed -e '/^$/d;' -e "s/^/$indentation/" \
4074 -e "$sed_replace_build_aux" \
4075 -e "$sed_replace_include_guard_prefix" \
4076 | { if $disable_libtool; then
4077 sed -e 's/\$gl_cond_libtool/false/g' \
4078 -e 's/gl_libdeps/gltests_libdeps/g' \
4079 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4084 | { if $disable_gettext; then
4085 sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
4087 # Don't indent AM_GNU_GETTEXT_VERSION line, as that confuses
4088 # autopoint through at least GNU gettext version 0.18.2.
4089 sed -e 's/^ *AM_GNU_GETTEXT_VERSION/AM_GNU_GETTEXT_VERSION/'
4092 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
4093 echo 'changequote(,)dnl'
4094 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4095 echo 'changequote([, ])dnl'
4096 echo 'AC_SUBST([LTALLOCA])'
4101 # func_emit_autoconf_snippets modules verifier toplevel disable_libtool disable_gettext
4102 # collects and emit the autoconf snippets of a set of modules.
4104 # - local_gnulib_path from --local-dir
4105 # - modcache true or false, from --cache-modules/--no-cache-modules
4106 # - sed_replace_build_aux sed expression that replaces reference to build-aux
4107 # - sed_replace_include_guard_prefix
4108 # sed expression for resolving ${gl_include_guard_prefix}
4109 # - modules the list of modules.
4110 # - verifier one of func_verify_module, func_verify_nontests_module,
4111 # func_verify_tests_module. It selects the subset of
4112 # $modules to consider.
4113 # - toplevel true or false. 'false' means a subordinate use of
4115 # - disable_libtool true or false. It tells whether to disable libtool
4116 # handling even if it has been specified through the
4117 # command line options.
4118 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
4120 func_emit_autoconf_snippets ()
4124 disable_libtool="$4"
4125 disable_gettext="$5"
4126 if test "$cond_dependencies" = true; then
4127 for m in $modules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/modules
4128 # Emit the autoconf code for the unconditional modules.
4129 for module in $1; do
4131 if test -n "$module"; then
4132 if func_cond_module_p "$module"; then
4135 func_emit_autoconf_snippet " "
4139 # Initialize the shell variables indicating that the modules are enabled.
4140 for module in $1; do
4142 if test -n "$module"; then
4143 if func_cond_module_p "$module"; then
4144 func_module_shellvar_name "$module"
4145 echo " $shellvar=false"
4149 # Emit the autoconf code for the conditional modules, each in a separate
4150 # function. This makes it possible to support cycles among conditional
4152 for module in $1; do
4154 if test -n "$module"; then
4155 if func_cond_module_p "$module"; then
4156 func_module_shellfunc_name "$module"
4157 func_module_shellvar_name "$module"
4158 echo " $shellfunc ()"
4160 echo " if ! \$$shellvar; then"
4161 func_emit_autoconf_snippet " "
4162 echo " $shellvar=true"
4163 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4164 # Intersect $deps with the modules list $1.
4165 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4166 for dep in $deps; do
4167 if func_cond_module_p "$dep"; then
4168 func_module_shellfunc_name "$dep"
4169 func_cond_module_condition "$module" "$dep"
4170 if test "$condition" != true; then
4171 echo " if $condition; then"
4178 # The autoconf code for $dep has already been emitted above and
4179 # therefore is already executed when this function is run.
4188 # Emit the dependencies from the unconditional to the conditional modules.
4189 for module in $1; do
4191 if test -n "$module"; then
4192 if func_cond_module_p "$module"; then
4195 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4196 # Intersect $deps with the modules list $1.
4197 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4198 for dep in $deps; do
4199 if func_cond_module_p "$dep"; then
4200 func_module_shellfunc_name "$dep"
4201 func_cond_module_condition "$module" "$dep"
4202 if test "$condition" != true; then
4203 echo " if $condition; then"
4210 # The autoconf code for $dep has already been emitted above and
4211 # therefore is already executed when this code is run.
4218 # Define the Automake conditionals.
4219 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
4220 for module in $1; do
4222 if test -n "$module"; then
4223 if func_cond_module_p "$module"; then
4224 func_module_conditional_name "$module"
4225 func_module_shellvar_name "$module"
4226 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
4231 # Ignore the conditions, and enable all modules unconditionally.
4232 for module in $1; do
4234 if test -n "$module"; then
4235 func_emit_autoconf_snippet " "
4241 # func_emit_pre_early_macros require indentation modules
4242 # The require parameter can be ':' (AC_REQUIRE) or 'false' (direct call).
4243 func_emit_pre_early_macros ()
4246 echo "${2}# Pre-early section."
4248 _pre_early_snippet="echo \"${2}AC_REQUIRE([\$_pre_early_macro])\""
4250 _pre_early_snippet="echo \"${2}\$_pre_early_macro\""
4253 # We need to call gl_USE_SYSTEM_EXTENSIONS before gl_PROG_AR_RANLIB. Doing
4254 # AC_REQUIRE in configure-ac.early is not early enough.
4255 _pre_early_macro="gl_USE_SYSTEM_EXTENSIONS"
4256 case "${nl}${3}${nl}" in
4257 *${nl}extensions${nl}*) eval "$_pre_early_snippet" ;;
4260 _pre_early_macro="gl_PROG_AR_RANLIB"
4261 eval "$_pre_early_snippet"
4265 # func_reconstruct_cached_dir
4266 # callback for func_reconstruct_cached_local_gnulib_path
4268 # - destdir from --dir
4270 # - local_gnulib_path restored '--local-dir' path from cache
4271 func_reconstruct_cached_dir ()
4274 if test -n "$cached_dir"; then
4277 func_path_append local_gnulib_path "$destdir/$cached_dir" ;;
4279 case "$cached_dir" in
4281 func_path_append local_gnulib_path "$destdir/$cached_dir" ;;
4283 func_relconcat "$destdir" "$cached_dir"
4284 func_path_append local_gnulib_path "$relconcat" ;;
4290 # func_reconstruct_cached_local_gnulib_path
4291 # reconstruct local_gnulib_path from cached_local_gnulib_path to be set
4292 # relatively to $destdir again.
4294 # - cached_local_gnulib_path local_gnulib_path stored within gnulib-cache.m4
4295 # - destdir from --dir
4297 # - local_gnulib_path restored '--local-dir' path from cache
4298 func_reconstruct_cached_local_gnulib_path ()
4300 func_path_foreach "$cached_local_gnulib_path" func_reconstruct_cached_dir %dir%
4303 # func_import modules
4304 # Uses also the variables
4305 # - mode import or add-import or remove-import or update
4306 # - destdir target directory
4307 # - local_gnulib_path from --local-dir
4308 # - modcache true or false, from --cache-modules/--no-cache-modules
4309 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
4310 # - libname library name
4311 # - supplied_libname true if --lib was given, blank otherwise
4312 # - sourcebase directory relative to destdir where to place source code
4313 # - m4base directory relative to destdir where to place *.m4 macros
4314 # - pobase directory relative to destdir where to place *.po files
4315 # - docbase directory relative to destdir where to place doc files
4316 # - testsbase directory relative to destdir where to place unit test code
4317 # - auxdir directory relative to destdir where to place build aux files
4318 # - inctests true if --with-tests was given, false otherwise
4319 # - incobsolete true if --with-obsolete was given, blank otherwise
4320 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
4321 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
4323 # - inc_privileged_tests true if --with-privileged-tests was given, blank
4325 # - inc_unportable_tests true if --with-unportable-tests was given, blank
4327 # - inc_all_tests true if --with-all-tests was given, blank otherwise
4328 # - avoidlist list of modules to avoid, from --avoid
4329 # - cond_dependencies true if --conditional-dependencies was given, false if
4330 # --no-conditional-dependencies was given, blank otherwise
4331 # - lgpl yes or a number if library's license shall be LGPL,
4333 # - makefile_name from --makefile-name
4334 # - libtool true if --libtool was given, false if --no-libtool was
4335 # given, blank otherwise
4336 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
4337 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4338 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4339 # - witness_c_macro from --witness-c-macro
4340 # - vc_files true if --vc-files was given, false if --no-vc-files was
4341 # given, blank otherwise
4342 # - autoconf_minversion minimum supported autoconf version
4343 # - doit : if actions shall be executed, false if only to be printed
4344 # - symbolic true if files should be symlinked, copied otherwise
4345 # - lsymbolic true if files from local_gnulib_path should be symlinked,
4347 # - do_copyrights true if copyright notices in files should be replaced,
4351 # Get the cached settings.
4352 # In 'import' mode, we read them only for the purpose of knowing the old
4353 # installed file list, and don't use them as defaults.
4354 cached_local_gnulib_path=
4355 cached_specified_modules=
4357 cached_inc_cxx_tests=
4358 cached_inc_longrunning_tests=
4359 cached_inc_privileged_tests=
4360 cached_inc_unportable_tests=
4361 cached_inc_all_tests=
4371 cached_makefile_name=
4372 cached_cond_dependencies=
4374 cached_macro_prefix=
4376 cached_witness_c_macro=
4379 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4380 cached_libtool=false
4386 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_path="\1",p
4396 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
4398 /gl_WITH_OBSOLETE/ {
4399 s,^.*$,cached_incobsolete=true,p
4401 /gl_WITH_CXX_TESTS/ {
4402 s,^.*$,cached_inc_cxx_tests=true,p
4404 /gl_WITH_LONGRUNNING_TESTS/ {
4405 s,^.*$,cached_inc_longrunning_tests=true,p
4407 /gl_WITH_PRIVILEGED_TESTS/ {
4408 s,^.*$,cached_inc_privileged_tests=true,p
4410 /gl_WITH_UNPORTABLE_TESTS/ {
4411 s,^.*$,cached_inc_unportable_tests=true,p
4413 /gl_WITH_ALL_TESTS/ {
4414 s,^.*$,cached_inc_all_tests=true,p
4417 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
4420 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
4423 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
4426 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
4429 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
4432 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
4435 s,^.*$,cached_inctests=true,p
4438 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
4441 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
4444 s,^.*$,cached_lgpl=yes,p
4446 /gl_MAKEFILE_NAME(/ {
4447 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
4449 /gl_CONDITIONAL_DEPENDENCIES/ {
4450 s,^.*$,cached_cond_dependencies=true,p
4453 s,^.*$,cached_libtool=true,p
4455 /gl_MACRO_PREFIX(/ {
4456 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
4459 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
4461 /gl_WITNESS_C_MACRO(/ {
4462 s,^.*gl_WITNESS_C_MACRO([[ ]*\([^]"$`\\)]*\).*$,cached_witness_c_macro="\1",p
4465 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
4467 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
4468 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4473 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
4474 s,^.*$,cached_files=",p
4487 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
4491 if test "$mode" = import; then
4492 # In 'import' mode, the new set of specified modules overrides the cached
4493 # set of modules. Ignore the cached settings.
4494 specified_modules="$1"
4496 # Merge the cached settings with the specified ones.
4497 # The m4base must be the same as expected from the pathname.
4498 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
4499 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
4501 # The local_gnulib_path defaults to the cached one. Recall that the cached one
4502 # is relative to $destdir, whereas the one we use is relative to . or absolute.
4503 if test -z "$local_gnulib_path"; then
4504 func_reconstruct_cached_local_gnulib_path
4508 # Append the cached and the specified module names. So that
4509 # "gnulib-tool --add-import foo" means to add the module foo.
4510 specified_modules="$cached_specified_modules $1"
4513 # Take the cached module names, minus the specified module names.
4515 if $have_associative; then
4516 # Use an associative array, for O(N) worst-case run time.
4517 declare -A to_remove
4519 eval 'to_remove[$m]=yes'
4521 for module in $cached_specified_modules; do
4522 if eval 'test -z "${to_remove[$module]}"'; then
4523 func_append specified_modules "$module "
4527 # This loop has O(N**2) worst-case run time.
4528 for module in $cached_specified_modules; do
4531 if test "$m" = "$module"; then
4536 if test -z "$to_remove"; then
4537 func_append specified_modules "$module "
4543 # Take the cached module names. There are no specified module names.
4544 specified_modules="$cached_specified_modules"
4547 # Included obsolete modules among the dependencies if specified either way.
4548 if test -z "$incobsolete"; then
4549 incobsolete="$cached_incobsolete"
4551 # Included special kinds of tests modules among the dependencies if specified
4553 if test -z "$inc_cxx_tests"; then
4554 inc_cxx_tests="$cached_inc_cxx_tests"
4556 if test -z "$inc_longrunning_tests"; then
4557 inc_longrunning_tests="$cached_inc_longrunning_tests"
4559 if test -z "$inc_privileged_tests"; then
4560 inc_privileged_tests="$cached_inc_privileged_tests"
4562 if test -z "$inc_unportable_tests"; then
4563 inc_unportable_tests="$cached_inc_unportable_tests"
4565 if test -z "$inc_all_tests"; then
4566 inc_all_tests="$cached_inc_all_tests"
4568 # Append the cached and the specified avoidlist. This is probably better
4569 # than dropping the cached one when --avoid is specified at least once.
4570 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
4571 avoidlist=`echo $avoidlist`
4573 # The sourcebase defaults to the cached one.
4574 if test -z "$sourcebase"; then
4575 sourcebase="$cached_sourcebase"
4576 if test -z "$sourcebase"; then
4577 func_fatal_error "missing --source-base option"
4580 # The pobase defaults to the cached one.
4581 if test -z "$pobase"; then
4582 pobase="$cached_pobase"
4584 # The docbase defaults to the cached one.
4585 if test -z "$docbase"; then
4586 docbase="$cached_docbase"
4587 if test -z "$docbase"; then
4588 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."
4591 # The testsbase defaults to the cached one.
4592 if test -z "$testsbase"; then
4593 testsbase="$cached_testsbase"
4594 if test -z "$testsbase"; then
4595 func_fatal_error "missing --tests-base option"
4598 # Require the tests if specified either way.
4599 if ! $inctests; then
4600 inctests="$cached_inctests"
4601 if test -z "$inctests"; then
4605 # The libname defaults to the cached one.
4606 if test -z "$supplied_libname"; then
4607 libname="$cached_libname"
4608 if test -z "$libname"; then
4609 func_fatal_error "missing --lib option"
4612 # Require LGPL if specified either way.
4613 if test -z "$lgpl"; then
4616 # The makefile_name defaults to the cached one.
4617 if test -z "$makefile_name"; then
4618 makefile_name="$cached_makefile_name"
4620 # Use conditional dependencies if specified either way.
4621 if test -z "$cond_dependencies"; then
4622 cond_dependencies="$cached_cond_dependencies"
4624 # Use libtool if specified either way, or if guessed.
4625 if test -z "$libtool"; then
4626 if test -n "$cached_m4base"; then
4627 libtool="$cached_libtool"
4629 libtool="$guessed_libtool"
4632 # The macro_prefix defaults to the cached one.
4633 if test -z "$macro_prefix"; then
4634 macro_prefix="$cached_macro_prefix"
4635 if test -z "$macro_prefix"; then
4636 func_fatal_error "missing --macro-prefix option"
4639 # The po_domain defaults to the cached one.
4640 if test -z "$po_domain"; then
4641 po_domain="$cached_po_domain"
4643 # The witness_c_macro defaults to the cached one.
4644 if test -z "$witness_c_macro"; then
4645 witness_c_macro="$cached_witness_c_macro"
4647 # The vc_files defaults to the cached one.
4648 if test -z "$vc_files"; then
4649 vc_files="$cached_vc_files"
4651 # Ensure constraints.
4652 if test "$cond_dependencies" = true && $inctests; then
4653 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
4657 # --without-*-tests options are not supported here.
4659 excl_longrunning_tests=
4660 excl_privileged_tests=
4661 excl_unportable_tests=
4663 # Canonicalize the list of specified modules.
4664 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4666 # Include all kinds of tests modules if --with-all-tests was specified.
4667 inc_all_direct_tests="$inc_all_tests"
4668 inc_all_indirect_tests="$inc_all_tests"
4670 # Determine final module list.
4671 modules="$specified_modules"
4672 func_modules_transitive_closure
4673 if test $verbose -ge 0; then
4674 func_show_module_list
4676 final_modules="$modules"
4678 # Determine main module list and tests-related module list separately.
4679 func_modules_transitive_closure_separately
4681 # Determine whether a $testsbase/libtests.a is needed.
4682 func_determine_use_libtests
4684 # Add the dummy module to the main module list or to the tests-related module
4686 func_modules_add_dummy_separately
4688 # If --lgpl, verify that the licenses of modules are compatible.
4689 if test -n "$lgpl"; then
4690 license_incompatibilities=
4691 for module in $main_modules; do
4692 license=`func_get_license $module`
4694 'GPLed build tool') ;;
4695 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4700 LGPL | LGPLv2+ | LGPLv3+) ;;
4701 *) func_append license_incompatibilities "$module $license$nl" ;;
4707 *) func_append license_incompatibilities "$module $license$nl" ;;
4710 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4715 if test -n "$license_incompatibilities"; then
4716 # Format the license incompatibilities as a table.
4717 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
4718 s,^\(.................................................[^ ]*\) *, \1 ,'
4719 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
4720 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
4724 # Show banner notice of every module.
4725 modules="$main_modules"
4728 # Determine script to apply to imported library files.
4729 sed_transform_lib_file=
4730 for module in $main_modules; do
4731 if test $module = config-h; then
4732 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
4733 sed_transform_lib_file=$sed_transform_lib_file'
4734 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
4739 sed_transform_main_lib_file="$sed_transform_lib_file"
4740 if test -n "$do_copyrights"; then
4741 if test -n "$lgpl"; then
4745 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4746 s/GNU General/GNU Lesser General/g
4747 s/General Public License/Lesser General Public License/g
4748 s/Lesser Lesser General Public License/Lesser General Public License/g
4752 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4753 s/GNU General/GNU Lesser General/g
4754 s/General Public License/Lesser General Public License/g
4755 s/Lesser Lesser General Public License/Lesser General Public License/g
4757 s/version [23]\([ ,]\)/version 2.1\1/g
4760 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4764 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4765 s/GNU Lesser General/GNU General/g
4766 s/Lesser General Public License/General Public License/g
4768 s/GNU Library General/GNU General/g
4769 s/Library General Public License/General Public License/g
4771 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4776 # Determine script to apply to auxiliary files that go into $auxdir/.
4777 sed_transform_build_aux_file=
4778 if test -n "$do_copyrights"; then
4780 sed_transform_build_aux_file=$sed_transform_build_aux_file'
4781 s/GNU Lesser General/GNU General/g
4782 s/Lesser General Public License/General Public License/g
4784 s/GNU Library General/GNU General/g
4785 s/Library General Public License/General Public License/g
4787 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4791 # Determine script to apply to library files that go into $testsbase/.
4792 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
4793 if test -n "$do_copyrights"; then
4795 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
4796 s/GNU Lesser General/GNU General/g
4797 s/Lesser General Public License/General Public License/g
4799 s/GNU Library General/GNU General/g
4800 s/Library General Public License/General Public License/g
4802 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4806 # Determine the final file lists.
4807 func_modules_to_filelist_separately
4810 || func_fatal_error "refusing to do nothing"
4812 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
4813 new_files="$files m4/gnulib-tool.m4"
4814 old_files="$cached_files"
4815 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
4816 func_append old_files " m4/gnulib-tool.m4"
4819 rewritten='%REWRITTEN%'
4820 sed_rewrite_old_files="\
4821 s,^build-aux/,$rewritten$auxdir/,
4822 s,^doc/,$rewritten$cached_docbase/,
4823 s,^lib/,$rewritten$cached_sourcebase/,
4824 s,^m4/,$rewritten$cached_m4base/,
4825 s,^tests/,$rewritten$cached_testsbase/,
4826 s,^tests=lib/,$rewritten$cached_testsbase/,
4829 sed_rewrite_new_files="\
4830 s,^build-aux/,$rewritten$auxdir/,
4831 s,^doc/,$rewritten$docbase/,
4832 s,^lib/,$rewritten$sourcebase/,
4833 s,^m4/,$rewritten$m4base/,
4834 s,^tests/,$rewritten$testsbase/,
4835 s,^tests=lib/,$rewritten$testsbase/,
4839 # Create directories.
4840 { echo "$sourcebase"
4842 if test -n "$pobase"; then
4845 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
4846 if test -n "$docfiles"; then
4853 for f in $files; do echo $f; done \
4854 | sed -e "$sed_rewrite_new_files" \
4855 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4858 { # Rearrange file descriptors. Needed because "while ... done < ..."
4859 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4860 exec 5<&0 < "$tmp"/dirs
4862 if test ! -d "$destdir/$d"; then
4864 echo "Creating directory $destdir/$d"
4865 mkdir -p "$destdir/$d" || func_fatal_error "failed"
4867 echo "Create directory $destdir/$d"
4874 # Copy files or make symbolic links. Remove obsolete files.
4878 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4879 # representing the files according to the last gnulib-tool invocation.
4880 for f in $old_files; do echo $f; done \
4881 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
4884 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4885 # representing the files after this gnulib-tool invocation.
4886 for f in $new_files; do echo $f; done \
4887 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
4890 # First the files that are in old-files, but not in new-files:
4891 sed_take_first_column='s,'"$delimiter"'.*,,'
4892 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
4893 # Remove the file. Do nothing if the user already removed it.
4894 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
4896 echo "Removing file $g (backup in ${g}~)"
4897 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
4899 echo "Remove file $g (backup in ${g}~)"
4901 func_append removed_files "$g$nl"
4904 # func_add_or_update handles a file that ought to be present afterwards.
4906 # - f the original file name
4907 # - g the rewritten file name
4908 # - already_present nonempty if the file should already exist, empty
4910 func_add_or_update ()
4914 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
4918 *.class | *.mo ) is_binary_file=true ;;
4920 func_dest_tmpfilename "$g"
4921 func_lookup_file "$f"
4922 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4923 if test -n "$sed_transform_main_lib_file" \
4924 && test -z "$is_binary_file"; then
4927 sed -e "$sed_transform_main_lib_file" \
4928 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4932 if test -n "$sed_transform_build_aux_file" \
4933 && test -z "$is_binary_file"; then
4936 sed -e "$sed_transform_build_aux_file" \
4937 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4941 if test -n "$sed_transform_testsrelated_lib_file" \
4942 && test -z "$is_binary_file"; then
4945 sed -e "$sed_transform_testsrelated_lib_file" \
4946 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4950 if test -f "$destdir/$g"; then
4951 # The file already exists.
4955 # Don't protest if the file should be there but isn't: it happens
4956 # frequently that developers don't put autogenerated files under version control.
4958 func_append added_files "$g$nl"
4962 # Then the files that are in new-files, but not in old-files:
4963 sed_take_last_column='s,^.*'"$delimiter"',,'
4965 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
4966 | sed -e "$sed_take_last_column" \
4967 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
4968 { # Rearrange file descriptors. Needed because "while ... done < ..."
4969 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4970 exec 5<&0 < "$tmp"/added-files
4976 # Then the files that are in new-files and in old-files:
4977 already_present=true
4978 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
4979 | sed -e "$sed_take_last_column" \
4980 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
4981 { # Rearrange file descriptors. Needed because "while ... done < ..."
4982 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4983 exec 5<&0 < "$tmp"/kept-files
4990 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
4991 actioncmd="gnulib-tool --import"
4994 func_append_local_dir ()
4996 func_append "$1" " --local-dir=$2"
4998 func_path_foreach "$local_gnulib_path" func_append_local_dir actioncmd %dir%
5000 func_append actioncmd " --lib=$libname"
5001 func_append actioncmd " --source-base=$sourcebase"
5002 func_append actioncmd " --m4-base=$m4base"
5003 if test -n "$pobase"; then
5004 func_append actioncmd " --po-base=$pobase"
5006 func_append actioncmd " --doc-base=$docbase"
5007 func_append actioncmd " --tests-base=$testsbase"
5008 func_append actioncmd " --aux-dir=$auxdir"
5010 func_append actioncmd " --with-tests"
5012 if test -n "$incobsolete"; then
5013 func_append actioncmd " --with-obsolete"
5015 if test -n "$inc_cxx_tests"; then
5016 func_append actioncmd " --with-c++-tests"
5018 if test -n "$inc_longrunning_tests"; then
5019 func_append actioncmd " --with-longrunning-tests"
5021 if test -n "$inc_privileged_tests"; then
5022 func_append actioncmd " --with-privileged-tests"
5024 if test -n "$inc_unportable_tests"; then
5025 func_append actioncmd " --with-unportable-tests"
5027 if test -n "$inc_all_tests"; then
5028 func_append actioncmd " --with-all-tests"
5030 for module in $avoidlist; do
5031 func_append actioncmd " --avoid=$module"
5033 if test -n "$lgpl"; then
5034 if test "$lgpl" = yes; then
5035 func_append actioncmd " --lgpl"
5037 func_append actioncmd " --lgpl=$lgpl"
5040 if test -n "$makefile_name"; then
5041 func_append actioncmd " --makefile-name=$makefile_name"
5043 if test "$cond_dependencies" = true; then
5044 func_append actioncmd " --conditional-dependencies"
5046 func_append actioncmd " --no-conditional-dependencies"
5048 if test "$libtool" = true; then
5049 func_append actioncmd " --libtool"
5051 func_append actioncmd " --no-libtool"
5053 func_append actioncmd " --macro-prefix=$macro_prefix"
5054 if test -n "$po_domain"; then
5055 func_append actioncmd " --po-domain=$po_domain"
5057 if test -n "$witness_c_macro"; then
5058 func_append actioncmd " --witness-c-macro=$witness_c_macro"
5060 if test -n "$vc_files"; then
5061 if test "$vc_files" = true; then
5062 func_append actioncmd " --vc-files"
5064 func_append actioncmd " --no-vc-files"
5067 func_append actioncmd " `echo $specified_modules`"
5069 # Determine include_guard_prefix.
5070 func_compute_include_guard_prefix
5072 # Default the makefile name to Makefile.am.
5073 if test -n "$makefile_name"; then
5074 makefile_am=$makefile_name
5076 makefile_am=Makefile.am
5079 # Create normal Makefile.ams.
5082 # Setup list of Makefile.am edits that are to be performed afterwards.
5083 # Some of these edits apply to files that we will generate; others are
5084 # under the responsibility of the developer.
5086 # func_note_Makefile_am_edit dir var value
5087 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
5089 func_note_Makefile_am_edit ()
5091 makefile_am_edits=`expr $makefile_am_edits + 1`
5092 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
5093 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
5094 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
5096 if test "$makefile_am" = Makefile.am; then
5097 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
5098 sourcebase_base=`basename "$sourcebase"`
5099 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
5101 if test -n "$pobase"; then
5102 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
5103 pobase_base=`basename "$pobase"`
5104 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
5107 if test "$makefile_am" = Makefile.am; then
5108 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
5109 testsbase_base=`basename "$testsbase"`
5110 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
5113 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
5115 # Find the first parent directory of $m4base that contains or will contain
5117 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
5119 sed_butlast='s,[^/][^/]*//*$,,'
5120 dir1="${m4base}/"; dir2=""
5121 while test -n "$dir1" \
5122 && ! { test -f "${destdir}/${dir1}Makefile.am" \
5123 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
5124 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
5126 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
5127 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
5128 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
5129 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
5131 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
5134 # Create library makefile.
5135 func_dest_tmpfilename $sourcebase/$makefile_am
5136 destfile="$sourcebase/$makefile_am"
5137 modules="$main_modules"
5138 func_emit_lib_Makefile_am > "$tmpfile"
5139 if test -f "$destdir"/$sourcebase/$makefile_am; then
5140 if cmp -s "$destdir"/$sourcebase/$makefile_am "$tmpfile"; then
5144 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
5145 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
5146 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
5148 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
5154 echo "Creating $sourcebase/$makefile_am"
5155 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
5157 echo "Create $sourcebase/$makefile_am"
5160 func_append added_files "$sourcebase/$makefile_am$nl"
5163 # Create po/ directory.
5164 if test -n "$pobase"; then
5165 # Create po makefile and auxiliary files.
5166 for file in Makefile.in.in remove-potcdate.sin; do
5167 func_dest_tmpfilename $pobase/$file
5168 func_lookup_file build-aux/po/$file
5169 cat "$lookedup_file" > "$tmpfile"
5170 if test -f "$destdir"/$pobase/$file; then
5171 if cmp -s "$destdir"/$pobase/$file "$tmpfile"; then
5175 echo "Updating $pobase/$file (backup in $pobase/$file~)"
5176 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
5177 mv -f "$tmpfile" "$destdir"/$pobase/$file
5179 echo "Update $pobase/$file (backup in $pobase/$file~)"
5185 echo "Creating $pobase/$file"
5186 mv -f "$tmpfile" "$destdir"/$pobase/$file
5188 echo "Create $pobase/$file"
5191 func_append added_files "$pobase/$file$nl"
5194 # Create po makefile parameterization, part 1.
5195 func_dest_tmpfilename $pobase/Makevars
5196 func_emit_po_Makevars > "$tmpfile"
5197 if test -f "$destdir"/$pobase/Makevars; then
5198 if cmp -s "$destdir"/$pobase/Makevars "$tmpfile"; then
5202 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
5203 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
5204 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5206 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
5212 echo "Creating $pobase/Makevars"
5213 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
5215 echo "Create $pobase/Makevars"
5218 func_append added_files "$pobase/Makevars$nl"
5220 # Create po makefile parameterization, part 2.
5221 func_dest_tmpfilename $pobase/POTFILES.in
5222 func_emit_po_POTFILES_in > "$tmpfile"
5223 if test -f "$destdir"/$pobase/POTFILES.in; then
5224 if cmp -s "$destdir"/$pobase/POTFILES.in "$tmpfile"; then
5228 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5229 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
5230 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5232 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
5238 echo "Creating $pobase/POTFILES.in"
5239 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5241 echo "Create $pobase/POTFILES.in"
5244 func_append added_files "$pobase/POTFILES.in$nl"
5247 TP_URL="http://translationproject.org/latest/"
5248 TP_RSYNC_URI="translationproject.org::tp/latest/"
5250 echo "Fetching gnulib PO files from $TP_URL"
5251 (cd "$destdir"/$pobase \
5252 && { # Prefer rsync over wget if it is available, since it consumes
5253 # less network bandwidth, due to compression.
5254 if type rsync 2>/dev/null | grep / > /dev/null; then
5255 rsync --delete --exclude "*.s1" -Lrtz "${TP_RSYNC_URI}gnulib/" . && return
5258 wget --no-verbose --mirror -nd -np -A.po -P . "${TP_URL}gnulib/"
5262 echo "Fetch gnulib PO files from $TP_URL"
5264 # Create po/LINGUAS.
5266 func_dest_tmpfilename $pobase/LINGUAS
5267 (cd "$destdir"/$pobase \
5268 && { echo '# Set of available languages.'
5269 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
5272 if test -f "$destdir"/$pobase/LINGUAS; then
5273 if cmp -s "$destdir"/$pobase/LINGUAS "$tmpfile"; then
5276 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5277 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
5278 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5281 echo "Creating $pobase/LINGUAS"
5282 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5283 func_append added_files "$pobase/LINGUAS$nl"
5286 if test -f "$destdir"/$pobase/LINGUAS; then
5287 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5289 echo "Create $pobase/LINGUAS"
5294 # func_count_relative_local_gnulib_path
5295 # gl_LOCAL_DIR requires local_gnulib_path to be set relatively to destdir
5297 # - local_gnulib_path from --local-dir
5298 # - destdir from --dir
5300 # - relative_local_dir path to be stored into gl_LOCAL_DIR
5301 func_count_relative_local_gnulib_path ()
5305 relative_local_gnulib_path=
5306 for local_dir in $local_gnulib_path
5308 # Store the local_dir relative to destdir.
5309 case "$local_dir" in
5311 relative_local_dir="$local_dir" ;;
5314 /*) relative_local_dir="$local_dir" ;;
5316 # destdir, local_dir are both relative.
5317 func_relativize "$destdir" "$local_dir"
5318 relative_local_dir="$reldir" ;;
5321 func_path_append relative_local_gnulib_path "$relative_local_dir"
5326 # Create m4/gnulib-cache.m4.
5327 func_dest_tmpfilename $m4base/gnulib-cache.m4
5329 func_emit_copyright_notice
5331 echo "# This file represents the specification of how gnulib-tool is used."
5332 echo "# It acts as a cache: It is written and read by gnulib-tool."
5333 echo "# In projects that use version control, this file is meant to be put under"
5334 echo "# version control, like the configure.ac and various Makefile.am files."
5337 echo "# Specification in the form of a command-line invocation:"
5340 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
5341 func_count_relative_local_gnulib_path
5342 echo "gl_LOCAL_DIR([$relative_local_gnulib_path])"
5344 echo "$specified_modules" | sed -e 's/^/ /g'
5346 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
5347 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
5348 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
5349 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
5350 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
5351 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
5352 echo "gl_AVOID([$avoidlist])"
5353 echo "gl_SOURCE_BASE([$sourcebase])"
5354 echo "gl_M4_BASE([$m4base])"
5355 echo "gl_PO_BASE([$pobase])"
5356 echo "gl_DOC_BASE([$docbase])"
5357 echo "gl_TESTS_BASE([$testsbase])"
5359 echo "gl_WITH_TESTS"
5361 echo "gl_LIB([$libname])"
5362 if test -n "$lgpl"; then
5363 if test "$lgpl" = yes; then
5366 echo "gl_LGPL([$lgpl])"
5369 echo "gl_MAKEFILE_NAME([$makefile_name])"
5370 if test "$cond_dependencies" = true; then
5371 echo "gl_CONDITIONAL_DEPENDENCIES"
5373 if test "$libtool" = true; then
5376 echo "gl_MACRO_PREFIX([$macro_prefix])"
5377 echo "gl_PO_DOMAIN([$po_domain])"
5378 echo "gl_WITNESS_C_MACRO([$witness_c_macro])"
5379 if test -n "$vc_files"; then
5380 echo "gl_VC_FILES([$vc_files])"
5383 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
5384 if cmp -s "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile"; then
5388 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5389 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
5390 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5392 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5396 echo "# gnulib-cache.m4 ends here"
5403 echo "Creating $m4base/gnulib-cache.m4"
5404 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5406 echo "Create $m4base/gnulib-cache.m4"
5412 # Create m4/gnulib-comp.m4.
5413 func_dest_tmpfilename $m4base/gnulib-comp.m4
5415 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
5416 func_emit_copyright_notice
5418 echo "# This file represents the compiled summary of the specification in"
5419 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
5420 echo "# to be invoked from configure.ac."
5421 echo "# In projects that use version control, this file can be treated like"
5422 echo "# other built files."
5425 echo "# This macro should be invoked from $configure_ac, in the section"
5426 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
5427 echo "# any checks for libraries, header files, types and library functions."
5428 echo "AC_DEFUN([${macro_prefix}_EARLY],"
5430 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5431 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5432 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5433 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5435 func_emit_pre_early_macros : ' ' "$final_modules"
5437 if test -n "$uses_subdirs"; then
5438 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
5440 for module in $final_modules; do
5442 if test -n "$module"; then
5443 echo "# Code from module $module:"
5444 func_get_autoconf_early_snippet "$module"
5447 | sed -e '/^$/d;' -e 's/^/ /'
5450 echo "# This macro should be invoked from $configure_ac, in the section"
5451 echo "# \"Check for header files, types and library functions\"."
5452 echo "AC_DEFUN([${macro_prefix}_INIT],"
5454 if test "$libtool" = true; then
5455 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5456 echo " gl_cond_libtool=true"
5458 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5459 echo " gl_cond_libtool=false"
5461 echo " gl_ltlibdeps="
5463 if test "$auxdir" != "build-aux"; then
5464 sed_replace_build_aux='
5466 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5467 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5471 sed_replace_build_aux="$sed_noop"
5473 echo " gl_m4_base='$m4base'"
5474 func_emit_initmacro_start $macro_prefix
5475 echo " gl_source_base='$sourcebase'"
5476 if test -n "$witness_c_macro"; then
5477 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
5479 func_emit_autoconf_snippets "$main_modules" func_verify_module true false true
5480 if test -n "$witness_c_macro"; then
5481 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5483 echo " # End of code from modules"
5484 func_emit_initmacro_end $macro_prefix
5485 echo " gltests_libdeps="
5486 echo " gltests_ltlibdeps="
5487 func_emit_initmacro_start ${macro_prefix}tests
5488 echo " gl_source_base='$testsbase'"
5489 # Define a tests witness macro that depends on the package.
5490 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
5491 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
5492 echo "changequote(,)dnl"
5493 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"
5494 echo "changequote([, ])dnl"
5495 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5496 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5497 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5498 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true true true
5499 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5500 func_emit_initmacro_end ${macro_prefix}tests
5501 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5502 # created using libtool, because libtool already handles the dependencies.
5503 if test "$libtool" != true; then
5504 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5505 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5506 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5507 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5508 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5510 if $use_libtests; then
5511 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5512 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5515 func_emit_initmacro_done $macro_prefix $sourcebase
5516 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5518 echo "# This macro records the list of files which have been installed by"
5519 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
5520 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
5521 echo "$files" | sed -e 's,^, ,'
5524 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
5525 if cmp -s "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile"; then
5529 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5530 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
5531 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5533 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5537 echo "# gnulib-comp.m4 ends here"
5544 echo "Creating $m4base/gnulib-comp.m4"
5545 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5547 echo "Create $m4base/gnulib-comp.m4"
5554 # Create tests makefile.
5555 func_dest_tmpfilename $testsbase/$makefile_am
5556 destfile="$testsbase/$makefile_am"
5557 modules="$testsrelated_modules"
5558 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
5559 if test -f "$destdir"/$testsbase/$makefile_am; then
5560 if cmp -s "$destdir"/$testsbase/$makefile_am "$tmpfile"; then
5564 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5565 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
5566 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5568 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5574 echo "Creating $testsbase/$makefile_am"
5575 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5577 echo "Create $testsbase/$makefile_am"
5580 func_append added_files "$testsbase/$makefile_am$nl"
5584 if test "$vc_files" != false; then
5585 # Update the .cvsignore and .gitignore files.
5586 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
5587 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
5588 # Treat gnulib-comp.m4 like an added file, even if it already existed.
5589 echo "$m4base/|A|gnulib-comp.m4"
5590 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
5591 { # Rearrange file descriptors. Needed because "while ... done < ..."
5592 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5593 exec 5<&0 < "$tmp"/fileset-changes
5594 func_update_ignorelist ()
5597 if test "$ignore" = .gitignore; then
5598 # In a .gitignore file, "foo" applies to the current directory and all
5599 # subdirectories, whereas "/foo" applies to the current directory only.
5602 doubly_escaped_anchor='\\/'
5606 doubly_escaped_anchor=''
5608 if test -f "$destdir/$dir$ignore"; then
5609 if test -n "$dir_added" || test -n "$dir_removed"; then
5610 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
5611 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
5612 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
5613 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
5614 > "$tmp"/ignore-removed
5616 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
5618 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5619 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
5620 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
5621 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
5622 } > "$tmp"/sed-ignore-removed
5623 { cat "$destdir/$dir$ignore"~
5624 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
5625 } | sed -f "$tmp"/sed-ignore-removed \
5626 > "$destdir/$dir$ignore"
5628 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5633 if test -n "$dir_added"; then
5635 echo "Creating $destdir/$dir$ignore"
5637 if test "$ignore" = .cvsignore; then
5639 # Automake generates Makefile rules that create .dirstamp files.
5642 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
5643 } > "$destdir/$dir$ignore"
5645 echo "Create $destdir/$dir$ignore"
5655 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
5656 func_update_ignorelist .cvsignore
5658 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
5659 func_update_ignorelist .gitignore
5666 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
5667 next_dir=`echo "$line" | sed -e 's,|.*,,'`
5668 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
5669 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
5670 if test "$next_dir" != "$last_dir"; then
5671 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5672 last_dir="$next_dir"
5677 A) func_append last_dir_added "$file$nl";;
5678 R) func_append last_dir_removed "$file$nl";;
5681 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5688 echo "You may need to add #include directives for the following .h files."
5689 # Intersect $specified_modules and $main_modules
5690 # (since $specified_modules is not necessarily of subset of $main_modules
5691 # - some may have been skipped through --avoid, and since the elements of
5692 # $main_modules but not in $specified_modules can go away without explicit
5693 # notice - through changes in the module dependencies).
5694 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
5695 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
5696 # First the #include <...> directives without #ifs, sorted for convenience,
5697 # then the #include "..." directives without #ifs, sorted for convenience,
5698 # then the #include directives that are surrounded by #ifs. Not sorted.
5699 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
5700 include_directive=`func_get_include_directive "$module"`
5701 case "$nl$include_directive" in
5703 echo "$include_directive" 1>&5
5706 echo "$include_directive" | grep -v 'include "' 1>&6
5707 echo "$include_directive" | grep 'include "' 1>&7
5710 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
5712 LC_ALL=C sort -u "$tmp"/include-angles
5713 LC_ALL=C sort -u "$tmp"/include-quotes
5714 cat "$tmp"/include-if
5715 ) | sed -e '/^$/d' -e 's/^/ /'
5716 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
5718 for module in $main_modules; do
5719 func_get_link_directive "$module"
5721 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
5722 if test `wc -l < "$tmp"/link` != 0; then
5724 echo "You may need to use the following Makefile variables when linking."
5725 echo "Use them in <program>_LDADD when linking a program, or"
5726 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
5732 echo "Don't forget to"
5733 if test "$makefile_am" = Makefile.am; then
5734 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5736 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
5738 if test -n "$pobase"; then
5739 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
5742 if test "$makefile_am" = Makefile.am; then
5743 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5745 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
5749 while test $edit != $makefile_am_edits; do
5750 edit=`expr $edit + 1`
5751 eval dir=\"\$makefile_am_edit${edit}_dir\"
5752 eval var=\"\$makefile_am_edit${edit}_var\"
5753 eval val=\"\$makefile_am_edit${edit}_val\"
5754 if test -n "$var"; then
5755 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
5758 if grep '^ *AC_PROG_CC_STDC' "$configure_ac" > /dev/null; then
5759 position_early_after=AC_PROG_CC_STDC
5761 if grep '^ *AC_PROG_CC_C99' "$configure_ac" > /dev/null; then
5762 position_early_after=AC_PROG_CC_C99
5764 position_early_after=AC_PROG_CC
5767 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after $position_early_after,"
5768 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
5771 # func_create_testdir testdir modules
5773 # - local_gnulib_path from --local-dir
5774 # - modcache true or false, from --cache-modules/--no-cache-modules
5775 # - auxdir directory relative to destdir where to place build aux files
5776 # - inctests true if tests should be included, false otherwise
5777 # - incobsolete true if obsolete modules among dependencies should be
5778 # included, blank otherwise
5779 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
5781 # - excl_longrunning_tests true if long-runnings tests should be excluded,
5783 # - excl_privileged_tests true if tests that require root privileges should be
5784 # excluded, blank otherwise
5785 # - excl_unportable_tests true if tests that fail on some platforms should be
5786 # excluded, blank otherwise
5787 # - single_configure true if a single configure file should be generated,
5788 # false for a separate configure file for the tests
5789 # - avoidlist list of modules to avoid
5790 # - cond_dependencies true if --conditional-dependencies was given, false if
5791 # --no-conditional-dependencies was given, blank otherwise
5792 # - libtool true if --libtool was given, false if --no-libtool was
5793 # given, blank otherwise
5794 # - symbolic true if files should be symlinked, copied otherwise
5795 # - lsymbolic true if files from local_gnulib_path should be symlinked,
5797 func_create_testdir ()
5801 if test -z "$modules"; then
5802 # All modules together.
5803 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5804 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
5805 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
5806 modules=`func_all_modules`
5807 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
5809 specified_modules="$modules"
5811 # Canonicalize the list of specified modules.
5812 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
5814 # Unlike in func_import, here we want to include all kinds of tests for the
5815 # directly specified modules, but not for dependencies.
5816 inc_all_direct_tests=true
5817 inc_all_indirect_tests="$inc_all_tests"
5819 # Check that the license of every module is consistent with the license of
5821 saved_inctests="$inctests"
5822 # When computing transitive closures, don't consider $module to depend on
5823 # $module-tests. Need this because tests are implicitly GPL and may depend
5824 # on GPL modules - therefore we don't want a warning in this case.
5826 for requested_module in $specified_modules; do
5827 requested_license=`func_get_license "$requested_module"`
5828 if test "$requested_license" != GPL; then
5829 # Here we use func_modules_transitive_closure, not just
5830 # func_get_dependencies, so that we also detect weird situations like
5831 # an LGPL module which depends on a GPLed build tool module which depends
5833 modules="$requested_module"
5834 func_modules_transitive_closure
5835 for module in $modules; do
5836 license=`func_get_license "$module"`
5838 'GPLed build tool') ;;
5839 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
5841 case "$requested_license" in
5844 GPLv2+ | LGPLv2+) ;;
5845 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5851 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5857 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5866 inctests="$saved_inctests"
5868 # Subdirectory names.
5879 # Determine final module list.
5880 modules="$specified_modules"
5881 func_modules_transitive_closure
5882 if test $verbose -ge 0; then
5883 func_show_module_list
5885 final_modules="$modules"
5887 if $single_configure; then
5888 # Determine main module list and tests-related module list separately.
5889 func_modules_transitive_closure_separately
5892 if $single_configure; then
5893 # Determine whether a $testsbase/libtests.a is needed.
5894 func_determine_use_libtests
5897 # Add the dummy module if needed.
5898 if $single_configure; then
5899 func_modules_add_dummy_separately
5901 func_modules_add_dummy
5904 # Show banner notice of every module.
5905 if $single_configure; then
5906 modules="$main_modules"
5912 # Determine final file list.
5913 if $single_configure; then
5914 func_modules_to_filelist_separately
5916 func_modules_to_filelist
5917 if test $verbose -ge 0; then
5919 echo "$files" | sed -e 's/^/ /'
5922 # Add files for which the copy in gnulib is newer than the one that
5923 # "automake --add-missing --copy" would provide.
5924 files="$files build-aux/config.guess"
5925 files="$files build-aux/config.sub"
5926 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
5928 rewritten='%REWRITTEN%'
5929 sed_rewrite_files="\
5930 s,^build-aux/,$rewritten$auxdir/,
5931 s,^doc/,$rewritten$docbase/,
5932 s,^lib/,$rewritten$sourcebase/,
5933 s,^m4/,$rewritten$m4base/,
5934 s,^tests/,$rewritten$testsbase/,
5935 s,^tests=lib/,$rewritten$testsbase/,
5939 # Create directories.
5940 for f in $files; do echo $f; done \
5941 | sed -e "$sed_rewrite_files" \
5942 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5943 | LC_ALL=C sort -u \
5945 { # Rearrange file descriptors. Needed because "while ... done < ..."
5946 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5947 exec 5<&0 < "$tmp"/dirs
5949 mkdir -p "$testdir/$d"
5954 # Copy files or make symbolic links.
5956 for f in $files; do echo $f; done \
5957 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
5960 { # Rearrange file descriptors. Needed because "while ... done < ..."
5961 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5962 exec 5<&0 < "$tmp"/files
5965 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
5967 func_lookup_file "$f"
5968 if test -n "$lookedup_tmp"; then
5969 cp -p "$lookedup_file" "$testdir/$g"
5971 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
5972 if func_should_symlink; then
5973 func_ln "$lookedup_file" "$testdir/$g"
5975 cp -p "$lookedup_file" "$testdir/$g"
5982 # Determine include_guard_prefix.
5983 func_compute_include_guard_prefix
5985 # Create Makefile.ams that are for testing.
5988 # No special edits are needed.
5991 # Create $sourcebase/Makefile.am.
5992 mkdir -p "$testdir/$sourcebase"
5993 destfile="$sourcebase/Makefile.am"
5994 if $single_configure; then
5995 modules="$main_modules"
5997 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
5998 any_uses_subdirs="$uses_subdirs"
6000 # Create $m4base/Makefile.am.
6001 mkdir -p "$testdir/$m4base"
6002 (echo "## Process this file with automake to produce Makefile.in."
6008 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
6011 ) > "$testdir/$m4base/Makefile.am"
6013 subdirs="$sourcebase $m4base"
6014 subdirs_with_configure_ac=""
6016 if false && test -f "$testdir"/$m4base/gettext.m4; then
6017 # Avoid stupid error message from automake:
6018 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
6019 mkdir -p "$testdir/po"
6020 (echo "## Process this file with automake to produce Makefile.in."
6021 ) > "$testdir/po/Makefile.am"
6022 func_append subdirs " po"
6026 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
6027 if $single_configure; then
6028 # Create $testsbase/Makefile.am.
6029 destfile="$testsbase/Makefile.am"
6030 modules="$testsrelated_modules"
6031 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$testdir/$testsbase/Makefile.am"
6033 # Viewed from the $testsbase subdirectory, $auxdir is different.
6034 saved_auxdir="$auxdir"
6035 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
6036 # Create $testsbase/Makefile.am.
6038 destfile="$testsbase/Makefile.am"
6039 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
6040 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
6041 # Create $testsbase/configure.ac.
6042 (echo "# Process this file with autoconf to produce a configure script."
6043 echo "AC_INIT([dummy], [0])"
6044 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6045 echo "AM_INIT_AUTOMAKE"
6047 echo "AC_CONFIG_HEADERS([config.h])"
6050 echo "AC_PROG_INSTALL"
6051 echo "AC_PROG_MAKE_SET"
6053 func_emit_pre_early_macros false '' "$modules"
6055 if test -n "$uses_subdirs"; then
6056 echo "AM_PROG_CC_C_O"
6059 for module in $modules; do
6061 if test -n "$module"; then
6063 gnumakefile | maintainer-makefile)
6064 # These modules are meant to be used only in the top-level directory.
6067 func_get_autoconf_early_snippet "$module"
6072 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
6073 if test "$libtool" = true; then
6074 echo "LT_INIT([win32-dll])"
6075 echo "LT_LANG([C++])"
6076 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6077 echo "gl_cond_libtool=true"
6079 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6080 echo "gl_cond_libtool=false"
6082 echo "gl_ltlibdeps="
6084 # Wrap the set of autoconf snippets into an autoconf macro that is then
6085 # invoked. This is needed because autoconf does not support AC_REQUIRE
6087 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6088 # but we want the AC_REQUIRE to have its normal meaning (provide one
6089 # expansion of the required macro before the current point, and only one
6091 echo "AC_DEFUN([gl_INIT], ["
6092 sed_replace_build_aux='
6094 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6095 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6098 echo "gl_m4_base='../$m4base'"
6099 func_emit_initmacro_start $macro_prefix
6100 # We don't have explicit ordering constraints between the various
6101 # autoconf snippets. It's cleanest to put those of the library before
6102 # those of the tests.
6103 echo "gl_source_base='../$sourcebase'"
6104 func_emit_autoconf_snippets "$modules" func_verify_nontests_module false false false
6105 echo "gl_source_base='.'"
6106 func_emit_autoconf_snippets "$modules" func_verify_tests_module false false false
6107 func_emit_initmacro_end $macro_prefix
6108 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6109 # created using libtool, because libtool already handles the dependencies.
6110 if test "$libtool" != true; then
6111 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6112 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6113 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6114 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6115 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6118 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
6122 # Usually $testsbase/config.h will be a superset of config.h. Verify this
6123 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
6124 echo "AH_TOP([#include \"../config.h\"])"
6126 echo "AC_CONFIG_FILES([Makefile])"
6128 ) > "$testdir/$testsbase/configure.ac"
6129 auxdir="$saved_auxdir"
6130 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
6132 func_append subdirs " $testsbase"
6135 # Create Makefile.am.
6136 (echo "## Process this file with automake to produce Makefile.in."
6138 echo "AUTOMAKE_OPTIONS = 1.9.6 foreign"
6140 echo "SUBDIRS = $subdirs"
6142 echo "ACLOCAL_AMFLAGS = -I $m4base"
6143 ) > "$testdir/Makefile.am"
6145 # Create configure.ac.
6146 (echo "# Process this file with autoconf to produce a configure script."
6147 echo "AC_INIT([dummy], [0])"
6148 if test "$auxdir" != "."; then
6149 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6151 echo "AM_INIT_AUTOMAKE"
6153 echo "AC_CONFIG_HEADERS([config.h])"
6156 echo "AC_PROG_INSTALL"
6157 echo "AC_PROG_MAKE_SET"
6159 echo "# For autobuild."
6160 echo "AC_CANONICAL_BUILD"
6161 echo "AC_CANONICAL_HOST"
6163 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
6164 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
6165 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
6166 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
6168 func_emit_pre_early_macros false '' "$final_modules"
6170 if test -n "$any_uses_subdirs"; then
6171 echo "AM_PROG_CC_C_O"
6174 for module in $final_modules; do
6175 if $single_configure; then
6178 func_verify_nontests_module
6180 if test -n "$module"; then
6181 func_get_autoconf_early_snippet "$module"
6184 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
6185 if test "$libtool" = true; then
6186 echo "LT_INIT([win32-dll])"
6187 echo "LT_LANG([C++])"
6188 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
6189 echo "gl_cond_libtool=true"
6191 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
6192 echo "gl_cond_libtool=false"
6194 echo "gl_ltlibdeps="
6196 # Wrap the set of autoconf snippets into an autoconf macro that is then
6197 # invoked. This is needed because autoconf does not support AC_REQUIRE
6199 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
6200 # but we want the AC_REQUIRE to have its normal meaning (provide one
6201 # expansion of the required macro before the current point, and only one
6203 echo "AC_DEFUN([gl_INIT], ["
6204 if test "$auxdir" != "build-aux"; then
6205 sed_replace_build_aux='
6207 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
6208 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
6212 sed_replace_build_aux="$sed_noop"
6214 echo "gl_m4_base='$m4base'"
6215 func_emit_initmacro_start $macro_prefix
6216 echo "gl_source_base='$sourcebase'"
6217 if $single_configure; then
6218 func_emit_autoconf_snippets "$main_modules" func_verify_module true false false
6220 func_emit_autoconf_snippets "$modules" func_verify_nontests_module true false false
6222 func_emit_initmacro_end $macro_prefix
6223 if $single_configure; then
6224 echo " gltests_libdeps="
6225 echo " gltests_ltlibdeps="
6226 func_emit_initmacro_start ${macro_prefix}tests
6227 echo " gl_source_base='$testsbase'"
6228 # Define a tests witness macro.
6229 echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
6230 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
6231 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
6232 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
6233 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true false false
6234 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
6235 func_emit_initmacro_end ${macro_prefix}tests
6237 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
6238 # created using libtool, because libtool already handles the dependencies.
6239 if test "$libtool" != true; then
6240 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
6241 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
6242 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
6243 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
6244 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
6246 if $single_configure; then
6247 if $use_libtests; then
6248 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
6249 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
6253 func_emit_initmacro_done $macro_prefix $sourcebase
6254 if $single_configure; then
6255 func_emit_initmacro_done ${macro_prefix}tests $testsbase
6260 if test -n "$subdirs_with_configure_ac"; then
6261 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
6263 makefiles="Makefile"
6264 for d in $subdirs; do
6265 # For subdirs that have a configure.ac by their own, it's the subdir's
6266 # configure.ac which creates the subdir's Makefile.am, not this one.
6267 case " $subdirs_with_configure_ac " in
6269 *) func_append makefiles " $d/Makefile" ;;
6272 echo "AC_CONFIG_FILES([$makefiles])"
6274 ) > "$testdir/configure.ac"
6276 # Create autogenerated files.
6278 # Do not use "${AUTORECONF} --force --install", because it may invoke
6279 # autopoint, which brings in older versions of some of our .m4 files.
6280 if test -f $m4base/gettext.m4; then
6281 func_execute_command ${AUTOPOINT} --force || func_exit 1
6282 for f in $m4base/*.m4~; do
6284 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6288 if test "$libtool" = true; then
6289 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
6291 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
6292 if ! test -d build-aux; then
6293 func_execute_command mkdir build-aux || func_exit 1
6295 func_execute_command ${AUTOCONF} || func_exit 1
6296 func_execute_command ${AUTOHEADER} || func_exit 1
6297 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6299 if $inctests && ! $single_configure; then
6300 # Create autogenerated files.
6301 (cd "$testdir/$testsbase" || func_exit 1
6302 # Do not use "${AUTORECONF} --force --install", because it may invoke
6303 # autopoint, which brings in older versions of some of our .m4 files.
6304 if test -f ../$m4base/gettext.m4; then
6305 func_execute_command ${AUTOPOINT} --force || func_exit 1
6306 for f in ../$m4base/*.m4~; do
6308 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6312 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
6313 if ! test -d ../build-aux; then
6314 func_execute_command mkdir ../build-aux
6316 func_execute_command ${AUTOCONF} || func_exit 1
6317 func_execute_command ${AUTOHEADER} || func_exit 1
6318 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6321 # Need to run configure and make once, to create built files that are to be
6322 # distributed (such as parse-datetime.c).
6323 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
6324 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
6325 cleaned_files=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
6326 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6327 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
6328 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
6329 # such $(FOO_H) because they don't refer to distributed files.
6330 built_sources=`combine_lines < "$testdir/$sourcebase/Makefile.am" \
6331 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6332 | sed -e "$sed_remove_make_variables"`
6333 distributed_built_sources=`for file in $built_sources; do
6334 case "$cleaned_files" in
6339 tests_distributed_built_sources=
6341 # Likewise for built files in the $testsbase directory.
6342 tests_cleaned_files=`combine_lines < "$testdir/$testsbase/Makefile.am" \
6343 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6344 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
6345 tests_built_sources=`combine_lines < "$testdir/$testsbase/Makefile.am" \
6346 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6347 | sed -e "$sed_remove_make_variables"`
6348 tests_distributed_built_sources=`for file in $tests_built_sources; do
6349 case "$tests_cleaned_files" in
6355 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
6357 ./configure || func_exit 1
6358 if test -n "$distributed_built_sources"; then
6360 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6361 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6366 if test -n "$tests_distributed_built_sources"; then
6368 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6369 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6374 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6381 # func_create_megatestdir megatestdir allmodules
6383 # - local_gnulib_path from --local-dir
6384 # - modcache true or false, from --cache-modules/--no-cache-modules
6385 # - auxdir directory relative to destdir where to place build aux files
6386 func_create_megatestdir ()
6390 if test -z "$allmodules"; then
6391 allmodules=`func_all_modules`
6395 # First, all modules one by one.
6396 for onemodule in $allmodules; do
6397 func_create_testdir "$megatestdir/$onemodule" $onemodule
6398 func_append megasubdirs "$onemodule "
6400 # Then, all modules all together.
6401 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6402 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
6403 func_create_testdir "$megatestdir/ALL" "$allmodules"
6404 func_append megasubdirs "ALL"
6407 cvsdate=`vc_witness="$gnulib_dir/.git/refs/heads/master"; \
6408 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
6409 | sed -e 's,January,01,' -e 's,Jan,01,' \
6410 -e 's,February,02,' -e 's,Feb,02,' \
6411 -e 's,March,03,' -e 's,Mar,03,' \
6412 -e 's,April,04,' -e 's,Apr,04,' \
6414 -e 's,June,06,' -e 's,Jun,06,' \
6415 -e 's,July,07,' -e 's,Jul,07,' \
6416 -e 's,August,08,' -e 's,Aug,08,' \
6417 -e 's,September,09,' -e 's,Sep,09,' \
6418 -e 's,October,10,' -e 's,Oct,10,' \
6419 -e 's,November,11,' -e 's,Nov,11,' \
6420 -e 's,December,12,' -e 's,Dec,12,' \
6421 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
6422 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
6424 echo "CVSDATE=$cvsdate"
6425 echo ": \${MAKE=make}"
6426 echo "test -d logs || mkdir logs"
6427 echo "for module in $megasubdirs; do"
6428 echo " echo \"Working on module \$module...\""
6429 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
6430 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
6433 echo " : autobuild project... \$module"
6434 echo " : autobuild revision... cvs-\$CVSDATE-000000"
6435 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
6436 echo " : autobuild hostname... \`hostname\`"
6437 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
6439 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
6441 ) > "$megatestdir/do-autobuild"
6442 chmod a+x "$megatestdir/do-autobuild"
6444 # Create Makefile.am.
6445 (echo "## Process this file with automake to produce Makefile.in."
6447 echo "AUTOMAKE_OPTIONS = 1.9.6 foreign"
6449 echo "SUBDIRS = $megasubdirs"
6451 echo "EXTRA_DIST = do-autobuild"
6452 ) > "$megatestdir/Makefile.am"
6454 # Create configure.ac.
6455 (echo "# Process this file with autoconf to produce a configure script."
6456 echo "AC_INIT([dummy], [0])"
6457 if test "$auxdir" != "."; then
6458 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6460 echo "AM_INIT_AUTOMAKE"
6462 echo "AC_PROG_MAKE_SET"
6464 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
6465 echo "AC_CONFIG_FILES([Makefile])"
6467 ) > "$megatestdir/configure.ac"
6469 # Create autogenerated files.
6471 # Do not use "${AUTORECONF} --install", because autoreconf operates
6472 # recursively, but the subdirectories are already finished, therefore
6473 # calling autoreconf here would only waste lots of CPU time.
6474 func_execute_command ${ACLOCAL} || func_exit 1
6475 func_execute_command mkdir build-aux
6476 func_execute_command ${AUTOCONF} || func_exit 1
6477 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6483 func_fatal_error "no mode specified" ;;
6490 # sed expression that converts a literal to a basic regular expression.
6491 # Needs to handle . [ \ * ^ $.
6492 sed_literal_to_basic_regex='s/\\/\\\\/g
6498 if test -f "$gnulib_dir/$filename" \
6499 || func_lookup_local_file "$filename"; then
6500 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
6501 filename_line_regex='^'"$filename_anywhere_regex"'$'
6504 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
6505 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$,,'
6507 | func_sanitize_modulelist \
6510 for module in $module_candidates; do
6511 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
6516 func_warning "file $filename does not exist"
6521 import | add-import | remove-import | update )
6524 if test -z "$destdir"; then
6527 test -d "$destdir" \
6528 || func_fatal_error "destination directory does not exist: $destdir"
6530 # Prefer configure.ac to configure.in.
6531 if test -f "$destdir"/configure.ac; then
6532 configure_ac="$destdir/configure.ac"
6534 if test -f "$destdir"/configure.in; then
6535 configure_ac="$destdir/configure.in"
6537 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
6541 # Analyze configure.ac.
6543 guessed_libtool=false
6548 /AC_CONFIG_AUX_DIR/ {
6549 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
6551 /A[CM]_PROG_LIBTOOL/ {
6552 s,^.*$,guessed_libtool=true,p
6554 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
6556 if test -z "$auxdir"; then
6557 auxdir="$guessed_auxdir"
6560 # Determine where to apply func_import.
6561 if test "$mode" = import; then
6562 # Apply func_import to a particular gnulib directory.
6563 # The command line contains the complete specification; don't look at
6564 # the contents of gnulib-cache.m4.
6565 test -n "$supplied_libname" || supplied_libname=true
6566 test -n "$sourcebase" || sourcebase="lib"
6567 test -n "$m4base" || m4base="m4"
6568 test -n "$docbase" || docbase="doc"
6569 test -n "$testsbase" || testsbase="tests"
6570 test -n "$macro_prefix" || macro_prefix="gl"
6573 if test -n "$m4base"; then
6574 # Apply func_import to a particular gnulib directory.
6575 # Any number of additional modules can be given.
6576 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
6577 # First use of gnulib in the given m4base.
6578 test -n "$supplied_libname" || supplied_libname=true
6579 test -n "$sourcebase" || sourcebase="lib"
6580 test -n "$docbase" || docbase="doc"
6581 test -n "$testsbase" || testsbase="tests"
6582 test -n "$macro_prefix" || macro_prefix="gl"
6586 # Apply func_import to all gnulib directories.
6587 # To get this list of directories, look at Makefile.am. (Not at
6588 # configure, because it may be omitted from version control. Also,
6589 # don't run "find $destdir -name gnulib-cache.m4", as it might be
6593 if test -f "$destdir"/Makefile.am; then
6594 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
6596 for arg in $aclocal_amflags; do
6597 if test -n "$m4dir_is_next"; then
6598 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
6602 if test -f "$destdir/$arg"/gnulib-cache.m4; then
6603 func_append m4dirs " $arg"
6604 m4dirs_count=`expr $m4dirs_count + 1`
6610 if test "X$arg" = "X-I"; then
6618 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
6619 if test -f "$destdir"/aclocal.m4; then
6620 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
6621 sedexpr2='s,^[^/]*$,.,'
6622 sedexpr3='s,/[^/]*$,,'
6623 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
6624 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
6625 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
6628 if test $m4dirs_count = 0; then
6629 # First use of gnulib in a package.
6630 # Any number of additional modules can be given.
6631 test -n "$supplied_libname" || supplied_libname=true
6632 test -n "$sourcebase" || sourcebase="lib"
6634 test -n "$docbase" || docbase="doc"
6635 test -n "$testsbase" || testsbase="tests"
6636 test -n "$macro_prefix" || macro_prefix="gl"
6639 if test $m4dirs_count = 1; then
6640 # There's only one use of gnulib here. Assume the user means it.
6641 # Any number of additional modules can be given.
6642 for m4base in $m4dirs; do
6646 # Ambiguous - guess what the user meant.
6647 if test $# = 0; then
6648 # No further arguments. Guess the user wants to update all of them.
6649 for m4base in $m4dirs; do
6650 # Perform func_import in a subshell, so that variable values
6652 # local_gnulib_path, incobsolete, inc_cxx_tests,
6653 # inc_longrunning_tests, inc_privileged_tests,
6654 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
6655 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
6656 # makefile_name, libtool, macro_prefix, po_domain,
6657 # witness_c_macro, vc_files
6658 # don't propagate from one directory to another.
6659 (func_import) || func_exit 1
6663 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
6672 if test -z "$destdir"; then
6673 func_fatal_error "please specify --dir option"
6676 test -d "$destdir" \
6677 || func_fatal_error "could not create destination directory"
6678 test -n "$auxdir" || auxdir="build-aux"
6679 func_create_testdir "$destdir" "$*"
6682 create-megatestdir )
6683 if test -z "$destdir"; then
6684 func_fatal_error "please specify --dir option"
6686 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6687 test -n "$auxdir" || auxdir="build-aux"
6688 func_create_megatestdir "$destdir" "$*"
6692 test -n "$destdir" || destdir=testdir$$
6693 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6694 test -n "$auxdir" || auxdir="build-aux"
6695 func_create_testdir "$destdir" "$*"
6699 ../configure || func_exit 1
6700 $MAKE || func_exit 1
6701 $MAKE check || func_exit 1
6702 $MAKE distclean || func_exit 1
6703 remaining=`find . -type f -print`
6704 if test -n "$remaining"; then
6705 echo "Remaining files:" $remaining 1>&2
6706 echo "gnulib-tool: *** Stop." 1>&2
6715 test -n "$destdir" || destdir=testdir$$
6716 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6717 test -n "$auxdir" || auxdir="build-aux"
6718 func_create_megatestdir "$destdir" "$*"
6726 remaining=`find . -type f -print`
6727 if test -n "$remaining"; then
6728 echo "Remaining files:" $remaining 1>&2
6729 echo "gnulib-tool: *** Stop." 1>&2
6737 extract-description )
6741 if test -n "$module"; then
6742 func_get_description "$module"
6751 if test -n "$module"; then
6752 func_get_comment "$module"
6761 if test -n "$module"; then
6762 func_get_status "$module"
6771 if test -n "$module"; then
6772 func_get_notice "$module"
6777 extract-applicability )
6781 if test -n "$module"; then
6782 func_get_applicability "$module"
6791 if test -n "$module"; then
6792 func_get_filelist "$module"
6797 extract-dependencies )
6798 if test -n "$avoidlist"; then
6799 func_fatal_error "cannot combine --avoid and --extract-dependencies"
6804 if test -n "$module"; then
6805 func_get_dependencies "$module"
6810 extract-autoconf-snippet )
6814 if test -n "$module"; then
6815 func_get_autoconf_snippet "$module"
6820 extract-automake-snippet )
6824 if test -n "$module"; then
6825 func_get_automake_snippet "$module"
6830 extract-include-directive )
6834 if test -n "$module"; then
6835 func_get_include_directive "$module"
6840 extract-link-directive )
6844 if test -n "$module"; then
6845 func_get_link_directive "$module"
6854 if test -n "$module"; then
6855 func_get_license "$module"
6860 extract-maintainer )
6864 if test -n "$module"; then
6865 func_get_maintainer "$module"
6870 extract-tests-module )
6874 if test -n "$module"; then
6875 func_get_tests_module "$module"
6881 # Verify the number of arguments.
6882 if test $# -lt 1 || test $# -gt 2; then
6883 func_fatal_error "invalid number of arguments for --$mode"
6886 # The first argument is the file to be copied.
6888 # Verify the file exists.
6889 func_lookup_file "$f"
6891 # The second argument is the destination; either a directory ot a file.
6892 # It defaults to the current directory.
6894 test -n "$dest" || dest='.'
6895 test -n "$sourcebase" || sourcebase="lib"
6896 test -n "$m4base" || m4base="m4"
6897 test -n "$docbase" || docbase="doc"
6898 test -n "$testsbase" || testsbase="tests"
6899 test -n "$auxdir" || auxdir="build-aux"
6900 rewritten='%REWRITTEN%'
6901 sed_rewrite_files="\
6902 s,^build-aux/,$rewritten$auxdir/,
6903 s,^doc/,$rewritten$docbase/,
6904 s,^lib/,$rewritten$sourcebase/,
6905 s,^m4/,$rewritten$m4base/,
6906 s,^tests/,$rewritten$testsbase/,
6909 if test -d "$dest"; then
6911 g=`echo "$f" | sed -e "$sed_rewrite_files"`
6913 destdir=`dirname "$dest"`
6914 g=`basename "$dest"`
6917 # Create the directory for destfile.
6918 d=`dirname "$destdir/$g"`
6920 if test -n "$d" && test ! -d "$d"; then
6921 mkdir -p "$d" || func_fatal_error "failed"
6925 func_dest_tmpfilename "$g"
6926 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
6927 already_present=true
6928 if test -f "$destdir/$g"; then
6929 # The file already exists.
6933 # Don't protest if the file should be there but isn't: it happens
6934 # frequently that developers don't put autogenerated files under version
6942 func_fatal_error "unknown operation mode --$mode" ;;
6946 # Undo the effect of the previous 'trap' command. Some shellology:
6947 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
6948 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
6949 # exit); for the others we need to call 'exit' explicitly. The value of $? is
6950 # 128 + signal number and is set before the trap-registered command is run.
6952 trap 'func_exit $?' 1 2 3 13 15
6957 # indent-tabs-mode: nil
6958 # whitespace-check-buffer-indent: nil