README-release: capitalize a word and split a line
[gnulib/ericb.git] / gnulib-tool
blob3c895ac6900399322f84eb1315aeb58a9d35fa1b
1 #! /bin/sh
3 # Copyright (C) 2002-2012 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # This program is meant for authors or maintainers which want to import
20 # modules from gnulib into their packages.
22 progname=$0
23 package=gnulib
24 nl='
26 IFS=" "" $nl"
28 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
29 AUTOCONFPATH=
30 #case $USER in
31 # bruno )
32 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
33 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
34 # ;;
35 #esac
37 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
38 AUTOMAKEPATH=
40 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
41 GETTEXTPATH=
43 # You can set LIBTOOLPATH to empty if libtoolize 2.x is already in your PATH.
44 LIBTOOLPATH=
46 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
47 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
48 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
49 AUTOCONF="${AUTOCONFPATH}autoconf"
51 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
52 AUTOHEADER="${AUTOCONFPATH}autoheader"
54 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
55 ACLOCAL="${AUTOMAKEPATH}aclocal"
57 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
58 AUTOMAKE="${AUTOMAKEPATH}automake"
60 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
61 AUTORECONF="${AUTOCONFPATH}autoreconf"
64 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
65 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
66 AUTOPOINT="${GETTEXTPATH}autopoint"
69 # If you didn't set LIBTOOLPATH, you can also set the variable LIBTOOLIZE.
70 if test -z "${LIBTOOLIZE}" || test -n "${LIBTOOLPATH}"; then
71 LIBTOOLIZE="${LIBTOOLPATH}libtoolize"
74 # You can set MAKE.
75 if test -z "${MAKE}"; then
76 MAKE=make
79 # When using GNU sed, turn off as many GNU extensions as possible,
80 # to minimize the risk of accidentally using non-portable features.
81 # However, do this only for gnulib-tool itself, not for the code that
82 # gnulib-tool generates, since we don't want "sed --posix" to leak
83 # into makefiles. And do it only for sed versions 4.2 or newer,
84 # because "sed --posix" is buggy in GNU sed 4.1.5, see
85 # <http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00225.html>.
86 if (alias) > /dev/null 2>&1 \
87 && echo | sed --posix -e d >/dev/null 2>&1 \
88 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
89 [1-3]* | 4.[01]*) false;; \
90 *) true;; \
91 esac \
92 ; then
93 # Define sed as an alias.
94 # It is not always possible to use aliases. Aliases are guaranteed to work
95 # if the executing shell is bash and either it is invoked as /bin/sh or
96 # is a version >= 2.0, supporting shopt. This is the common case.
97 # Two other approaches (use of a variable $sed or of a function func_sed
98 # instead of an alias) require massive, fragile code changes.
99 # An other approach (use of function sed) requires `which sed` - but
100 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
101 if test -n "$BASH_VERSION"; then
102 shopt -s expand_aliases >/dev/null 2>&1
104 alias sed='sed --posix'
107 # sed_noop is a sed expression that does nothing.
108 # An empty expression does not work with the native 'sed' on AIX 6.1.
109 sed_noop='s,x,x,'
111 # sed_comments is true or false, depending whether 'sed' supports comments.
112 # AIX 5.3 sed barfs over indented comments.
113 if echo fo | sed -e 's/f/g/
114 # s/o/u/
115 # indented comment
116 s/o/e/' 2>/dev/null | grep ge > /dev/null; then
117 sed_comments=true
118 else
119 sed_comments=false
122 # func_usage
123 # outputs to stdout the --help usage message.
124 func_usage ()
126 echo "\
127 Usage: gnulib-tool --list
128 gnulib-tool --find filename
129 gnulib-tool --import [module1 ... moduleN]
130 gnulib-tool --add-import [module1 ... moduleN]
131 gnulib-tool --remove-import [module1 ... moduleN]
132 gnulib-tool --update
133 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
134 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
135 gnulib-tool --test --dir=directory module1 ... moduleN
136 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
137 gnulib-tool --extract-description module
138 gnulib-tool --extract-comment module
139 gnulib-tool --extract-status module
140 gnulib-tool --extract-notice module
141 gnulib-tool --extract-applicability module
142 gnulib-tool --extract-filelist module
143 gnulib-tool --extract-dependencies module
144 gnulib-tool --extract-autoconf-snippet module
145 gnulib-tool --extract-automake-snippet module
146 gnulib-tool --extract-include-directive module
147 gnulib-tool --extract-link-directive module
148 gnulib-tool --extract-license module
149 gnulib-tool --extract-maintainer module
150 gnulib-tool --extract-tests-module module
151 gnulib-tool --copy-file file [destination]
153 Operation modes:
155 --list print the available module names
156 --find find the modules which contain the specified file
157 --import import the given modules into the current package
158 --add-import augment the list of imports from gnulib into the
159 current package, by adding the given modules;
160 if no modules are specified, update the current
161 package from the current gnulib
162 --remove-import reduce the list of imports from gnulib into the
163 current package, by removing the given modules
164 --update update the current package, restore files omitted
165 from version control
166 --create-testdir create a scratch package with the given modules
167 (pass --with-tests to include the unit tests)
168 --create-megatestdir create a mega scratch package with the given modules
169 one by one and all together
170 (pass --with-tests to include the unit tests)
171 --test test the combination of the given modules
172 (pass --with-tests to include the unit tests)
173 (recommended to use CC=\"gcc -Wall\" here)
174 --megatest test the given modules one by one and all together
175 (pass --with-tests to include the unit tests)
176 (recommended to use CC=\"gcc -Wall\" here)
177 --extract-description extract the description
178 --extract-comment extract the comment
179 --extract-status extract the status (obsolete etc.)
180 --extract-notice extract the notice or banner
181 --extract-applicability extract the applicability
182 --extract-filelist extract the list of files
183 --extract-dependencies extract the dependencies
184 --extract-autoconf-snippet extract the snippet for configure.ac
185 --extract-automake-snippet extract the snippet for library makefile
186 --extract-include-directive extract the #include directive
187 --extract-link-directive extract the linker directive
188 --extract-license report the license terms of the source files
189 under lib/
190 --extract-maintainer report the maintainer(s) inside gnulib
191 --extract-tests-module report the unit test module, if it exists
192 --copy-file copy a file that is not part of any module
194 General options:
196 --dir=DIRECTORY Specify the target directory.
197 For --import, this specifies where your
198 configure.ac can be found. Defaults to current
199 directory.
200 --local-dir=DIRECTORY Specify a local override directory where to look
201 up files before looking in gnulib's directory.
202 --cache-modules Enable module caching optimization.
203 --no-cache-modules Disable module caching optimization.
204 --verbose Increase verbosity. May be repeated.
205 --quiet Decrease verbosity. May be repeated.
207 Options for --import, --add/remove-import, --update:
209 --dry-run Only print what would have been done.
211 Options for --import, --add/remove-import,
212 --create-[mega]testdir, --[mega]test:
214 --with-tests Include unit tests for the included modules.
215 --with-obsolete Include obsolete modules when they occur among the
216 dependencies. By default, dependencies to obsolete
217 modules are ignored.
218 --with-c++-tests Include even unit tests for C++ interoperability.
219 --with-longrunning-tests
220 Include even unit tests that are long-runners.
221 --with-privileged-tests
222 Include even unit tests that require root
223 privileges.
224 --with-unportable-tests
225 Include even unit tests that fail on some platforms.
226 --with-all-tests Include all kinds of problematic unit tests.
227 --avoid=MODULE Avoid including the given MODULE. Useful if you
228 have code that provides equivalent functionality.
229 This option can be repeated.
230 --conditional-dependencies
231 Support conditional dependencies (may save configure
232 time and object code).
233 --no-conditional-dependencies
234 Don't use conditional dependencies.
235 --libtool Use libtool rules.
236 --no-libtool Don't use libtool rules.
238 Options for --import, --add/remove-import:
240 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
241 --source-base=DIRECTORY
242 Directory relative to --dir where source code is
243 placed (default \"lib\").
244 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
245 placed (default \"m4\").
246 --po-base=DIRECTORY Directory relative to --dir where *.po files are
247 placed (default \"po\").
248 --doc-base=DIRECTORY Directory relative to --dir where doc files are
249 placed (default \"doc\").
250 --tests-base=DIRECTORY
251 Directory relative to --dir where unit tests are
252 placed (default \"tests\").
253 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
254 tools are placed (default comes from configure.ac).
255 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
256 Also modify license template from GPL to LGPL.
257 The version number of the LGPL can be specified;
258 the default is currently LGPLv3.
259 --makefile-name=NAME Name of makefile in automake syntax in the
260 source-base and tests-base directories
261 (default \"Makefile.am\").
262 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
263 'gl_INIT'. Default is 'gl'.
264 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
265 the package name. A suffix '-gnulib' is appended.
266 --witness-c-macro=NAME Specify the C macro that is defined when the
267 sources in this directory are compiled or used.
268 --vc-files Update version control related files.
269 --no-vc-files Don't update version control related files
270 (.gitignore and/or .cvsignore).
271 --no-changelog Don't update or create ChangeLog files.
273 Options for --create-[mega]testdir, --[mega]test:
275 --without-c++-tests Exclude unit tests for C++ interoperability.
276 --without-longrunning-tests
277 Exclude unit tests that are long-runners.
278 --without-privileged-tests
279 Exclude unit tests that require root privileges.
280 --without-unportable-tests
281 Exclude unit tests that fail on some platforms.
282 --single-configure Generate a single configure file, not a separate
283 configure file for the tests directory.
285 Options for --import, --add/remove-import, --update,
286 --create-[mega]testdir, --[mega]test:
288 -s, --symbolic, --symlink Make symbolic links instead of copying files.
289 --local-symlink Make symbolic links instead of copying files, only
290 for files from the local override directory.
292 Options for --import, --add/remove-import, --update:
294 -S, --more-symlinks Make symbolic links instead of copying files, and
295 don't replace copyright notices.
297 Report bugs to <bug-gnulib@gnu.org>."
300 # func_version
301 # outputs to stdout the --version message.
302 func_version ()
304 func_gnulib_dir
305 if test -d "$gnulib_dir"/.git \
306 && (git --version) >/dev/null 2>/dev/null \
307 && (date --version) >/dev/null 2>/dev/null; then
308 # gnulib checked out from git.
309 sed_extract_first_date='/^Date/{
310 s/^Date:[ ]*//p
313 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
314 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
315 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
316 date=`echo "$date" | sed -e "$sed_year_before_time"`
317 # Use GNU date to compute the time in GMT.
318 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
319 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
320 else
321 if test -d "$gnulib_dir"/CVS \
322 && (cvs --version) >/dev/null 2>/dev/null; then
323 # gnulib checked out from CVS.
324 sed_extract_first_date='/^date: /{
325 s/^date: \([0-9][0-9][0-9][0-9]\).\([0-9][0-9]\).\([0-9][0-9]\) \([0-9][0-9]:[0-9][0-9]:[0-9][0-9]\).*/\1-\2-\3 \4/p
328 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
329 else
330 # gnulib copy without versioning information.
331 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
333 version=
335 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
336 echo "\
337 gnulib-tool (GNU $package $date)$version
338 Copyright (C) $year Free Software Foundation, Inc.
339 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
340 This is free software: you are free to change and redistribute it.
341 There is NO WARRANTY, to the extent permitted by law.
343 Written by" "Bruno Haible" "and" "Simon Josefsson"
346 # func_emit_copyright_notice
347 # outputs to stdout a header for a generated file.
348 func_emit_copyright_notice ()
350 sed -n -e '/Copyright/ {
353 }' < "$self_abspathname"
354 echo "#"
355 echo "# This file is free software; you can redistribute it and/or modify"
356 echo "# it under the terms of the GNU General Public License as published by"
357 echo "# the Free Software Foundation; either version 3 of the License, or"
358 echo "# (at your option) any later version."
359 echo "#"
360 echo "# This file is distributed in the hope that it will be useful,"
361 echo "# but WITHOUT ANY WARRANTY; without even the implied warranty of"
362 echo "# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"
363 echo "# GNU General Public License for more details."
364 echo "#"
365 echo "# You should have received a copy of the GNU General Public License"
366 echo "# along with this file. If not, see <http://www.gnu.org/licenses/>."
367 echo "#"
368 echo "# As a special exception to the GNU General Public License,"
369 echo "# this file may be distributed as part of a program that"
370 echo "# contains a configuration script generated by Autoconf, under"
371 echo "# the same distribution terms as the rest of that program."
372 echo "#"
373 echo "# Generated by gnulib-tool."
376 # func_exit STATUS
377 # exits with a given status.
378 # This function needs to be used, rather than 'exit', when a 'trap' handler is
379 # in effect that refers to $?.
380 func_exit ()
382 (exit $1); exit $1
385 # func_gnulib_dir
386 # locates the directory where the gnulib repository lives
387 # Input:
388 # - progname name of this program
389 # Sets variables
390 # - self_abspathname absolute pathname of gnulib-tool
391 # - gnulib_dir absolute pathname of gnulib repository
392 func_gnulib_dir ()
394 case "$progname" in
395 /*) self_abspathname="$progname" ;;
396 */*) self_abspathname=`pwd`/"$progname" ;;
398 # Look in $PATH.
399 # Iterate through the elements of $PATH.
400 # We use IFS=: instead of
401 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
402 # because the latter does not work when some PATH element contains spaces.
403 # We use a canonicalized $pathx instead of $PATH, because empty PATH
404 # elements are by definition equivalent to '.', however field splitting
405 # according to IFS=: loses empty fields in many shells:
406 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
407 # beginning, at the end, and in the middle),
408 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
409 # at the beginning and at the end,
410 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
411 # Solaris lose empty fields at the end.
412 # The 'case' statement is an optimization, to avoid evaluating the
413 # explicit canonicalization command when $PATH contains no empty fields.
414 self_abspathname=
415 if test "${PATH_SEPARATOR+set}" != set; then
416 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
417 # contains only /bin. Note that ksh looks also at the FPATH variable,
418 # so we have to set that as well for the test.
419 PATH_SEPARATOR=:
420 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
421 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
422 || PATH_SEPARATOR=';'
425 if test "$PATH_SEPARATOR" = ";"; then
426 # On Windows, programs are searched in "." before $PATH.
427 pathx=".;$PATH"
428 else
429 # On Unix, we have to convert empty PATH elements to ".".
430 pathx="$PATH"
431 case :$PATH: in
432 *::*)
433 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
435 esac
437 save_IFS="$IFS"
438 IFS="$PATH_SEPARATOR"
439 for d in $pathx; do
440 IFS="$save_IFS"
441 test -z "$d" && d=.
442 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
443 self_abspathname="$d/$progname"
444 break
446 done
447 IFS="$save_IFS"
448 if test -z "$self_abspathname"; then
449 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
452 esac
453 while test -h "$self_abspathname"; do
454 # Resolve symbolic link.
455 linkval=`func_readlink "$self_abspathname"`
456 test -n "$linkval" || break
457 case "$linkval" in
458 /* ) self_abspathname="$linkval" ;;
459 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
460 esac
461 done
462 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
465 # func_tmpdir
466 # creates a temporary directory.
467 # Input:
468 # - progname name of this program
469 # Sets variable
470 # - tmp pathname of freshly created temporary directory
471 func_tmpdir ()
473 # Use the environment variable TMPDIR, falling back to /tmp. This allows
474 # users to specify a different temporary directory, for example, if their
475 # /tmp is filled up or too small.
476 : ${TMPDIR=/tmp}
478 # Use the mktemp program if available. If not available, hide the error
479 # message.
480 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
481 test -n "$tmp" && test -d "$tmp"
482 } ||
484 # Use a simple mkdir command. It is guaranteed to fail if the directory
485 # already exists. $RANDOM is bash specific and expands to empty in shells
486 # other than bash, ksh and zsh. Its use does not increase security;
487 # rather, it minimizes the probability of failure in a very cluttered /tmp
488 # directory.
489 tmp=$TMPDIR/gl$$-$RANDOM
490 (umask 077 && mkdir "$tmp")
491 } ||
493 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
494 func_exit 1
498 # func_append var value
499 # appends the given value to the shell variable var.
500 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
501 # Use bash's += operator. It reduces complexity of appending repeatedly to
502 # a single variable from O(n^2) to O(n).
503 func_append ()
505 eval "$1+=\"\$2\""
507 fast_func_append=true
508 else
509 func_append ()
511 eval "$1=\"\$$1\$2\""
513 fast_func_append=false
516 # func_remove_prefix var prefix
517 # removes the given prefix from the value of the shell variable var.
518 # var should be the name of a shell variable.
519 # Its value should not contain a newline and not start or end with whitespace.
520 # prefix should not contain the characters "$`\{}[]^|.
521 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
522 func_remove_prefix ()
524 eval "$1=\${$1#\$2}"
526 fast_func_remove_prefix=true
527 else
528 func_remove_prefix ()
530 eval "value=\"\$$1\""
531 prefix="$2"
532 case "$prefix" in
533 *.*)
534 sed_escape_dots='s/\([.]\)/\\\1/g'
535 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
537 esac
538 value=`echo "$value" | sed -e "s|^${prefix}||"`
539 eval "$1=\"\$value\""
541 fast_func_remove_prefix=false
544 # func_remove_suffix var suffix
545 # removes the given suffix from the value of the shell variable var.
546 # var should be the name of a shell variable.
547 # Its value should not contain a newline and not start or end with whitespace.
548 # suffix should not contain the characters "$`\{}[]^|.
549 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
550 func_remove_suffix ()
552 eval "$1=\${$1%\$2}"
554 fast_func_remove_suffix=true
555 else
556 func_remove_suffix ()
558 eval "value=\"\$$1\""
559 suffix="$2"
560 case "$suffix" in
561 *.*)
562 sed_escape_dots='s/\([.]\)/\\\1/g'
563 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
565 esac
566 value=`echo "$value" | sed -e "s|${suffix}\$||"`
567 eval "$1=\"\$value\""
569 fast_func_remove_suffix=false
572 # func_fatal_error message
573 # outputs to stderr a fatal error message, and terminates the program.
574 # Input:
575 # - progname name of this program
576 func_fatal_error ()
578 echo "$progname: *** $1" 1>&2
579 echo "$progname: *** Stop." 1>&2
580 func_exit 1
583 # func_warning message
584 # Outputs to stderr a warning message,
585 func_warning ()
587 echo "gnulib-tool: warning: $1" 1>&2
590 # func_readlink SYMLINK
591 # outputs the target of the given symlink.
592 if (type -p readlink) > /dev/null 2>&1; then
593 func_readlink ()
595 # Use the readlink program from GNU coreutils.
596 readlink "$1"
598 else
599 func_readlink ()
601 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
602 # would do the wrong thing if the link target contains " -> ".
603 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
607 # func_relativize DIR1 DIR2
608 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
609 # Input:
610 # - DIR1 relative pathname, relative to the current directory
611 # - DIR2 relative pathname, relative to the current directory
612 # Output:
613 # - reldir relative pathname of DIR2, relative to DIR1
614 func_relativize ()
616 dir0=`pwd`
617 dir1="$1"
618 dir2="$2"
619 sed_first='s,^\([^/]*\)/.*$,\1,'
620 sed_rest='s,^[^/]*/*,,'
621 sed_last='s,^.*/\([^/]*\)$,\1,'
622 sed_butlast='s,/*[^/]*$,,'
623 while test -n "$dir1"; do
624 first=`echo "$dir1" | sed -e "$sed_first"`
625 if test "$first" != "."; then
626 if test "$first" = ".."; then
627 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
628 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
629 else
630 first2=`echo "$dir2" | sed -e "$sed_first"`
631 if test "$first2" = "$first"; then
632 dir2=`echo "$dir2" | sed -e "$sed_rest"`
633 else
634 dir2="../$dir2"
636 dir0="$dir0"/"$first"
639 dir1=`echo "$dir1" | sed -e "$sed_rest"`
640 done
641 reldir="$dir2"
644 # func_relconcat DIR1 DIR2
645 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
646 # Input:
647 # - DIR1 relative pathname, relative to the current directory
648 # - DIR2 relative pathname, relative to DIR1
649 # Output:
650 # - relconcat DIR1/DIR2, relative to the current directory
651 func_relconcat ()
653 dir1="$1"
654 dir2="$2"
655 sed_first='s,^\([^/]*\)/.*$,\1,'
656 sed_rest='s,^[^/]*/*,,'
657 sed_last='s,^.*/\([^/]*\)$,\1,'
658 sed_butlast='s,/*[^/]*$,,'
659 while true; do
660 first=`echo "$dir2" | sed -e "$sed_first"`
661 if test "$first" = "."; then
662 dir2=`echo "$dir2" | sed -e "$sed_rest"`
663 if test -z "$dir2"; then
664 relconcat="$dir1"
665 break
667 else
668 last=`echo "$dir1" | sed -e "$sed_last"`
669 while test "$last" = "."; do
670 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
671 last=`echo "$dir1" | sed -e "$sed_last"`
672 done
673 if test -z "$dir1"; then
674 relconcat="$dir2"
675 break
677 if test "$first" = ".."; then
678 if test "$last" = ".."; then
679 relconcat="$dir1/$dir2"
680 break
682 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
683 dir2=`echo "$dir2" | sed -e "$sed_rest"`
684 if test -z "$dir1"; then
685 relconcat="$dir2"
686 break
688 if test -z "$dir2"; then
689 relconcat="$dir1"
690 break
692 else
693 relconcat="$dir1/$dir2"
694 break
697 done
700 # func_ln SRC DEST
701 # Like ln -s, except that SRC is given relative to the current directory (or
702 # absolute), not given relative to the directory of DEST.
703 func_ln ()
705 case "$1" in
707 ln -s "$1" "$2" ;;
708 *) # SRC is relative.
709 case "$2" in
711 ln -s "`pwd`/$1" "$2" ;;
712 *) # DEST is relative too.
713 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
714 test -n "$ln_destdir" || ln_destdir="."
715 func_relativize "$ln_destdir" "$1"
716 ln -s "$reldir" "$2"
718 esac
720 esac
723 # func_ln_if_changed SRC DEST
724 # Like func_ln, but avoids munging timestamps if the link is correct.
725 func_ln_if_changed ()
727 if test $# -ne 2; then
728 echo "usage: func_ln_if_changed SRC DEST" >&2
730 ln_target=`func_readlink "$2"`
731 if test -h "$2" && test "$1" = "$ln_target"; then
733 else
734 rm -f "$2"
735 func_ln "$1" "$2"
739 # Ensure an 'echo' command that
740 # 1. does not interpret backslashes and
741 # 2. does not print an error message "broken pipe" when writing into a pipe
742 # with no writers.
744 # Test cases for problem 1:
745 # echo '\n' | wc -l prints 1 when OK, 2 when KO
746 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
747 # Test cases for problem 2:
748 # echo hi | true frequently prints
749 # "bash: echo: write error: Broken pipe"
750 # to standard error in bash 3.2.
752 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
753 # BSD echo interprets '-n' as an option, which is also not desirable).
754 # Nowadays the problem occurs in 4 situations:
755 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
756 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
757 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
758 # - in zsh, when sh-emulation is not set,
759 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
760 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
761 # - in Solaris /bin/sh and OSF/1 /bin/sh.
762 # We try the following workarounds:
763 # - for all: respawn using $CONFIG_SHELL if that is set and works.
764 # - for bash >= 2.04: unset the shell option xpg_echo.
765 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
766 # - for bash < 2.0: define echo to a function that uses cat of a here document.
767 # - for zsh: turn sh-emulation on.
768 # - for ksh: alias echo to 'print -r'.
769 # - for ksh: alias echo to a function that uses cat of a here document.
770 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
771 # the ksh workaround.
772 # - otherwise: respawn using /bin/sh and rely on the workarounds.
773 # When respawning, we pass --no-reexec as first argument, so as to avoid
774 # turning this script into a fork bomb in unlucky situations.
776 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
777 # the 'printf' built-in. See
778 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
779 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
780 # The workaround is: define echo to a function that uses the printf built-in.
781 have_echo=
782 if echo '\t' | grep t > /dev/null; then
783 have_echo=yes # Lucky!
785 # Try the workarounds.
786 # Respawn using $CONFIG_SHELL if that is set and works.
787 if test -z "$have_echo" \
788 && test "X$1" != "X--no-reexec" \
789 && test -n "$CONFIG_SHELL" \
790 && test -f "$CONFIG_SHELL" \
791 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
792 exec $CONFIG_SHELL "$0" --no-reexec "$@"
793 exit 127
795 # For bash >= 2.04: unset the shell option xpg_echo.
796 if test -z "$have_echo" \
797 && test -n "$BASH_VERSION" \
798 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
799 shopt -o xpg_echo
800 have_echo=yes
802 # For bash >= 2.0: define echo to a function that uses the printf built-in.
803 # For bash < 2.0: define echo to a function that uses cat of a here document.
804 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
805 # Also handle problem 2, specific to bash 3.2, here.
806 if { test -z "$have_echo" \
807 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
809 && test -n "$BASH_VERSION"; then \
810 if type printf 2>/dev/null | grep / > /dev/null; then
811 # 'printf' is not a shell built-in.
812 echo ()
814 cat <<EOF
818 else
819 # 'printf' is a shell built-in.
820 echo ()
822 printf '%s\n' "$*"
825 if echo '\t' | grep t > /dev/null; then
826 have_echo=yes
829 # For zsh: turn sh-emulation on.
830 if test -z "$have_echo" \
831 && test -n "$ZSH_VERSION" \
832 && (emulate sh) >/dev/null 2>&1; then
833 emulate sh
835 # For ksh: alias echo to 'print -r'.
836 if test -z "$have_echo" \
837 && (type print) >/dev/null 2>&1; then
838 # A 'print' command exists.
839 if type print 2>/dev/null | grep / > /dev/null; then
841 else
842 # 'print' is a shell built-in.
843 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
844 # 'print' is the ksh shell built-in.
845 alias echo='print -r'
849 if test -z "$have_echo" \
850 && echo '\t' | grep t > /dev/null; then
851 have_echo=yes
853 # For ksh: alias echo to a function that uses cat of a here document.
854 # The ksh manual page says:
855 # "Aliasing is performed when scripts are read, not while they are executed.
856 # Therefore, for an alias to take effect, the alias definition command has
857 # to be executed before the command which references the alias is read."
858 # Because of this, we have to play strange tricks with have_echo, to ensure
859 # that the top-level statement containing the test starts after the 'alias'
860 # command.
861 if test -z "$have_echo"; then
862 bsd_echo ()
864 cat <<EOF
868 if (alias echo=bsd_echo) 2>/dev/null; then
869 alias echo=bsd_echo 2>/dev/null
872 if test -z "$have_echo" \
873 && echo '\t' | grep t > /dev/null; then
874 have_echo=yes
876 if test -z "$have_echo"; then
877 if (alias echo=bsd_echo) 2>/dev/null; then
878 unalias echo 2>/dev/null
881 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
882 if test -z "$have_echo" \
883 && test "X$1" != "X--no-reexec" \
884 && test -f /bin/ksh; then
885 exec /bin/ksh "$0" --no-reexec "$@"
886 exit 127
888 # Otherwise: respawn using /bin/sh.
889 if test -z "$have_echo" \
890 && test "X$1" != "X--no-reexec" \
891 && test -f /bin/sh; then
892 exec /bin/sh "$0" --no-reexec "$@"
893 exit 127
895 if test -z "$have_echo"; then
896 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
898 if echo '\t' | grep t > /dev/null; then
899 : # Works fine now.
900 else
901 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
903 if test "X$1" = "X--no-reexec"; then
904 shift
907 # Command-line option processing.
908 # Removes the OPTIONS from the arguments. Sets the variables:
909 # - mode list or import or add-import or remove-import or update
910 # or create-testdir or create-megatestdir
911 # - destdir from --dir
912 # - local_gnulib_dir from --local-dir
913 # - modcache true or false, from --cache-modules/--no-cache-modules
914 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
915 # - libname, supplied_libname from --lib
916 # - sourcebase from --source-base
917 # - m4base from --m4-base
918 # - pobase from --po-base
919 # - docbase from --doc-base
920 # - testsbase from --tests-base
921 # - auxdir from --aux-dir
922 # - inctests true if --with-tests was given, blank otherwise
923 # - incobsolete true if --with-obsolete was given, blank otherwise
924 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
925 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
926 # otherwise
927 # - inc_privileged_tests true if --with-privileged-tests was given, blank
928 # otherwise
929 # - inc_unportable_tests true if --with-unportable-tests was given, blank
930 # otherwise
931 # - inc_all_tests true if --with-all-tests was given, blank otherwise
932 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
933 # - excl_longrunning_tests true if --without-longrunning-tests was given,
934 # blank otherwise
935 # - excl_privileged_tests true if --without-privileged-tests was given, blank
936 # otherwise
937 # - excl_unportable_tests true if --without-unportable-tests was given, blank
938 # otherwise
939 # - single_configure true if --single-configure was given, false otherwise
940 # - avoidlist list of modules to avoid, from --avoid
941 # - cond_dependencies true if --conditional-dependencies was given, false if
942 # --no-conditional-dependencies was given, blank otherwise
943 # - lgpl yes or a number if --lgpl was given, blank otherwise
944 # - makefile_name from --makefile-name
945 # - libtool true if --libtool was given, false if --no-libtool was
946 # given, blank otherwise
947 # - macro_prefix from --macro-prefix
948 # - po_domain from --po-domain
949 # - witness_c_macro from --witness-c-macro
950 # - vc_files true if --vc-files was given, false if --no-vc-files was
951 # given, blank otherwise
952 # - autoconf_minversion minimum supported autoconf version
953 # - do_changelog false if --no-changelog was given, : otherwise
954 # - doit : if actions shall be executed, false if only to be printed
955 # - symbolic true if --symlink or --more-symlinks was given, blank
956 # otherwise
957 # - lsymbolic true if --local-symlink was given, blank otherwise
958 # - do_copyrights blank if --more-symlinks was given, true otherwise
960 mode=
961 destdir=
962 local_gnulib_dir=
963 modcache=true
964 verbose=0
965 libname=libgnu
966 supplied_libname=
967 sourcebase=
968 m4base=
969 pobase=
970 docbase=
971 testsbase=
972 auxdir=
973 inctests=
974 incobsolete=
975 inc_cxx_tests=
976 inc_longrunning_tests=
977 inc_privileged_tests=
978 inc_unportable_tests=
979 inc_all_tests=
980 excl_cxx_tests=
981 excl_longrunning_tests=
982 excl_privileged_tests=
983 excl_unportable_tests=
984 single_configure=false
985 avoidlist=
986 cond_dependencies=
987 lgpl=
988 makefile_name=
989 libtool=
990 macro_prefix=
991 po_domain=
992 witness_c_macro=
993 vc_files=
994 do_changelog=:
995 doit=:
996 symbolic=
997 lsymbolic=
998 do_copyrights=true
1000 supplied_opts="$@"
1002 while test $# -gt 0; do
1003 case "$1" in
1004 --list | --lis )
1005 mode=list
1006 shift ;;
1007 --find | --fin | --fi | --f )
1008 mode=find
1009 shift ;;
1010 --import | --impor | --impo | --imp | --im | --i )
1011 mode=import
1012 shift ;;
1013 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
1014 mode=add-import
1015 shift ;;
1016 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
1017 mode=remove-import
1018 shift ;;
1019 --update | --updat | --upda | --upd | --up | --u )
1020 mode=update
1021 shift ;;
1022 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
1023 mode=create-testdir
1024 shift ;;
1025 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
1026 mode=create-megatestdir
1027 shift ;;
1028 --test | --tes | --te | --t )
1029 mode=test
1030 shift ;;
1031 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1032 mode=megatest
1033 shift ;;
1034 --extract-* )
1035 mode=`echo "X$1" | sed -e 's/^X--//'`
1036 shift ;;
1037 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop )
1038 mode=copy-file
1039 shift ;;
1040 --dir )
1041 shift
1042 if test $# = 0; then
1043 func_fatal_error "missing argument for --dir"
1045 destdir=$1
1046 shift ;;
1047 --dir=* )
1048 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1049 shift ;;
1050 --local-dir )
1051 shift
1052 if test $# = 0; then
1053 func_fatal_error "missing argument for --local-dir"
1055 local_gnulib_dir=$1
1056 shift ;;
1057 --local-dir=* )
1058 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1059 shift ;;
1060 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1061 modcache=true
1062 shift ;;
1063 --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 )
1064 modcache=false
1065 shift ;;
1066 --verbose | --verbos | --verbo | --verb )
1067 verbose=`expr $verbose + 1`
1068 shift ;;
1069 --quiet | --quie | --qui | --qu | --q )
1070 verbose=`expr $verbose - 1`
1071 shift ;;
1072 --lib )
1073 shift
1074 if test $# = 0; then
1075 func_fatal_error "missing argument for --lib"
1077 libname=$1
1078 supplied_libname=true
1079 shift ;;
1080 --lib=* )
1081 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1082 supplied_libname=true
1083 shift ;;
1084 --source-base )
1085 shift
1086 if test $# = 0; then
1087 func_fatal_error "missing argument for --source-base"
1089 sourcebase=$1
1090 shift ;;
1091 --source-base=* )
1092 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1093 shift ;;
1094 --m4-base )
1095 shift
1096 if test $# = 0; then
1097 func_fatal_error "missing argument for --m4-base"
1099 m4base=$1
1100 shift ;;
1101 --m4-base=* )
1102 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1103 shift ;;
1104 --po-base )
1105 shift
1106 if test $# = 0; then
1107 func_fatal_error "missing argument for --po-base"
1109 pobase=$1
1110 shift ;;
1111 --po-base=* )
1112 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1113 shift ;;
1114 --doc-base )
1115 shift
1116 if test $# = 0; then
1117 func_fatal_error "missing argument for --doc-base"
1119 docbase=$1
1120 shift ;;
1121 --doc-base=* )
1122 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1123 shift ;;
1124 --tests-base )
1125 shift
1126 if test $# = 0; then
1127 func_fatal_error "missing argument for --tests-base"
1129 testsbase=$1
1130 shift ;;
1131 --tests-base=* )
1132 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1133 shift ;;
1134 --aux-dir )
1135 shift
1136 if test $# = 0; then
1137 func_fatal_error "missing argument for --aux-dir"
1139 auxdir=$1
1140 shift ;;
1141 --aux-dir=* )
1142 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1143 shift ;;
1144 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1145 inctests=true
1146 shift ;;
1147 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1148 incobsolete=true
1149 shift ;;
1150 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1151 inc_cxx_tests=true
1152 shift ;;
1153 --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)
1154 inc_longrunning_tests=true
1155 shift ;;
1156 --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)
1157 inc_privileged_tests=true
1158 shift ;;
1159 --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)
1160 inc_unportable_tests=true
1161 shift ;;
1162 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1163 inc_all_tests=true
1164 shift ;;
1165 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1166 excl_cxx_tests=true
1167 shift ;;
1168 --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)
1169 excl_longrunning_tests=true
1170 shift ;;
1171 --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)
1172 excl_privileged_tests=true
1173 shift ;;
1174 --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)
1175 excl_unportable_tests=true
1176 shift ;;
1177 --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)
1178 single_configure=true
1179 shift ;;
1180 --avoid )
1181 shift
1182 if test $# = 0; then
1183 func_fatal_error "missing argument for --avoid"
1185 func_append avoidlist " $1"
1186 shift ;;
1187 --avoid=* )
1188 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1189 func_append avoidlist " $arg"
1190 shift ;;
1191 --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)
1192 cond_dependencies=true
1193 shift ;;
1194 --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)
1195 cond_dependencies=false
1196 shift ;;
1197 --lgpl )
1198 lgpl=yes
1199 shift ;;
1200 --lgpl=* )
1201 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1202 case "$arg" in
1203 2 | 3) ;;
1204 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1205 esac
1206 lgpl=$arg
1207 shift ;;
1208 --makefile-name )
1209 shift
1210 if test $# = 0; then
1211 func_fatal_error "missing argument for --makefile-name"
1213 makefile_name="$1"
1214 shift ;;
1215 --makefile-name=* )
1216 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1217 shift ;;
1218 --libtool )
1219 libtool=true
1220 shift ;;
1221 --no-libtool )
1222 libtool=false
1223 shift ;;
1224 --macro-prefix )
1225 shift
1226 if test $# = 0; then
1227 func_fatal_error "missing argument for --macro-prefix"
1229 macro_prefix="$1"
1230 shift ;;
1231 --macro-prefix=* )
1232 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1233 shift ;;
1234 --po-domain )
1235 shift
1236 if test $# = 0; then
1237 func_fatal_error "missing argument for --po-domain"
1239 po_domain="$1"
1240 shift ;;
1241 --po-domain=* )
1242 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1243 shift ;;
1244 --witness-c-macro )
1245 shift
1246 if test $# = 0; then
1247 func_fatal_error "missing argument for --witness-c-macro"
1249 witness_c_macro="$1"
1250 shift ;;
1251 --witness-c-macro=* )
1252 witness_c_macro=`echo "X$1" | sed -e 's/^X--witness-c-macro=//'`
1253 shift ;;
1254 --vc-files )
1255 vc_files=true
1256 shift ;;
1257 --no-vc-files )
1258 vc_files=false
1259 shift ;;
1260 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1261 do_changelog=false
1262 shift ;;
1263 --dry-run )
1264 doit=false
1265 shift ;;
1266 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1267 symbolic=true
1268 shift ;;
1269 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1270 lsymbolic=true
1271 shift ;;
1272 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1273 symbolic=true
1274 do_copyrights=
1275 shift ;;
1276 --help | --hel | --he | --h )
1277 func_usage
1278 func_exit $? ;;
1279 --version | --versio | --versi | --vers )
1280 func_version
1281 func_exit $? ;;
1282 -- )
1283 # Stop option processing
1284 shift
1285 break ;;
1286 -* )
1287 echo "gnulib-tool: unknown option $1" 1>&2
1288 echo "Try 'gnulib-tool --help' for more information." 1>&2
1289 func_exit 1 ;;
1291 break ;;
1292 esac
1293 done
1295 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1296 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1297 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1298 || test "$single_configure" != false; then
1299 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1300 echo "Try 'gnulib-tool --help' for more information." 1>&2
1301 func_exit 1
1304 # This code helps migrating from --import to --add-import or --update. It can
1305 # be removed on 2012-01-01.
1306 if test "$mode" = import && test $# = 0; then
1307 echo "gnulib-tool: cowardly refusing to erase the module list." 1>&2
1308 echo "The meaning of the option '--import' has changed." 1>&2
1309 echo "See the documentation at" 1>&2
1310 echo "<http://www.gnu.org/software/gnulib/manual/html_node/Modified-imports.html>." 1>&2
1311 echo "For updating to a newer version of gnulib, use" 1>&2
1312 echo " gnulib-tool --add-import" 1>&2
1313 echo "For restoring files that were omitted from version control, use" 1>&2
1314 echo " gnulib-tool --update" 1>&2
1315 func_exit 1
1317 if test "$mode" = update; then
1318 if test $# != 0; then
1319 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1320 echo "Try 'gnulib-tool --help' for more information." 1>&2
1321 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1322 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1323 func_exit 1
1325 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1326 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1327 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1328 || test -n "$inctests" || test -n "$incobsolete" \
1329 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1330 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1331 || test -n "$inc_all_tests" \
1332 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1333 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1334 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1335 || test -n "$macro_prefix" || test -n "$po_domain" \
1336 || test -n "$witness_c_macro" || test -n "$vc_files"; then
1337 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1338 echo "Try 'gnulib-tool --help' for more information." 1>&2
1339 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1340 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1341 func_exit 1
1343 do_changelog=false
1345 if test -n "$pobase" && test -z "$po_domain"; then
1346 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1347 echo "Try 'gnulib-tool --help' for more information." 1>&2
1348 func_exit 1
1350 if test -z "$pobase" && test -n "$po_domain"; then
1351 func_warning "--po-domain has no effect without a --po-base option"
1353 if test "$cond_dependencies" = true && test -n "$inctests"; then
1354 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
1355 func_exit 1
1358 # Determine the minimum supported autoconf version from the project's
1359 # configure.ac.
1360 DEFAULT_AUTOCONF_MINVERSION="2.59"
1361 autoconf_minversion=
1362 configure_ac=
1363 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1364 && test -n "$destdir"; then
1365 if test -f "$destdir"/configure.ac; then
1366 configure_ac="$destdir/configure.ac"
1367 else
1368 if test -f "$destdir"/configure.in; then
1369 configure_ac="$destdir/configure.in"
1372 else
1373 if test -f configure.ac; then
1374 configure_ac="configure.ac"
1375 else
1376 if test -f configure.in; then
1377 configure_ac="configure.in"
1381 if test -n "$configure_ac"; then
1382 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1383 # because when some m4 files are omitted from a version control repository,
1384 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1385 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1386 # autom4te: m4 failed with exit status: 1
1387 prereqs=
1388 my_sed_traces='
1389 s,#.*$,,
1390 s,^dnl .*$,,
1391 s, dnl .*$,,
1392 /AC_PREREQ/ {
1393 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1395 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1396 if test -n "$prereqs"; then
1397 autoconf_minversion=`
1398 for version in $prereqs; do echo $version; done |
1399 LC_ALL=C sort -nru | sed -e 1q
1403 if test -z "$autoconf_minversion"; then
1404 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1406 case "$autoconf_minversion" in
1407 1.* | 2.[0-4]* | 2.5[0-8]*)
1408 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1409 esac
1411 # Remove trailing slashes from the directory names. This is necessary for
1412 # m4base (to avoid an error in func_import) and optional for the others.
1413 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1414 case "$local_gnulib_dir" in
1415 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1416 esac
1417 case "$sourcebase" in
1418 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1419 esac
1420 case "$m4base" in
1421 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1422 esac
1423 case "$pobase" in
1424 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1425 esac
1426 case "$docbase" in
1427 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1428 esac
1429 case "$testsbase" in
1430 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1431 esac
1432 case "$auxdir" in
1433 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1434 esac
1437 func_gnulib_dir
1438 func_tmpdir
1439 trap 'exit_status=$?
1440 if test "$signal" != 0; then
1441 echo "caught signal $signal" >&2
1443 rm -rf "$tmp"
1444 exit $exit_status' 0
1445 for signal in 1 2 3 13 15; do
1446 trap '{ signal='$signal'; func_exit 1; }' $signal
1447 done
1448 signal=0
1450 # Note: The 'eval' silences stderr output in dash.
1451 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1452 # Zsh 4 and Bash 4 have associative arrays.
1453 have_associative=true
1454 else
1455 # For other shells, use 'eval' with computed shell variable names.
1456 have_associative=false
1459 # func_lookup_file file
1460 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1461 # 'patch'.
1462 # Input:
1463 # - local_gnulib_dir from --local-dir
1464 # Output:
1465 # - lookedup_file name of the merged (combined) file
1466 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1467 func_lookup_file ()
1469 lkfile="$1"
1470 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1471 lookedup_file="$local_gnulib_dir/$lkfile"
1472 lookedup_tmp=
1473 else
1474 if test -f "$gnulib_dir/$lkfile"; then
1475 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1476 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1477 rm -f "$tmp/$lkbase"
1478 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1479 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1480 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1481 lookedup_file="$tmp/$lkbase"
1482 lookedup_tmp=true
1483 else
1484 lookedup_file="$gnulib_dir/$lkfile"
1485 lookedup_tmp=
1487 else
1488 func_fatal_error "file $gnulib_dir/$lkfile not found"
1493 # func_sanitize_modulelist
1494 # receives a list of possible module names on standard input, one per line.
1495 # It removes those which are just file names unrelated to modules, and outputs
1496 # the resulting list to standard output, one per line.
1497 func_sanitize_modulelist ()
1499 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1500 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1501 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1502 -e '/^README$/d' -e '/\/README$/d' \
1503 -e '/^TEMPLATE$/d' \
1504 -e '/^TEMPLATE-EXTENDED$/d' \
1505 -e '/^TEMPLATE-TESTS$/d' \
1506 -e '/^\..*/d' \
1507 -e '/~$/d'
1510 # func_all_modules
1511 # Input:
1512 # - local_gnulib_dir from --local-dir
1513 func_all_modules ()
1515 # Filter out metainformation files like README, which are not modules.
1516 # Filter out unit test modules; they can be retrieved through
1517 # --extract-tests-module if desired.
1519 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1520 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1521 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1524 | func_sanitize_modulelist \
1525 | sed -e '/-tests$/d' \
1526 | LC_ALL=C sort -u
1529 # func_exists_module module
1530 # tests whether a module, given by name, exists
1531 # Input:
1532 # - local_gnulib_dir from --local-dir
1533 func_exists_module ()
1535 { test -f "$gnulib_dir/modules/$1" \
1536 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1537 && test -f "$local_gnulib_dir/modules/$1"; }; } \
1538 && test "CVS" != "$1" \
1539 && test "ChangeLog" != "$1" \
1540 && test "COPYING" != "$1" \
1541 && test "README" != "$1" \
1542 && test "TEMPLATE" != "$1" \
1543 && test "TEMPLATE-EXTENDED" != "$1" \
1544 && test "TEMPLATE-TESTS" != "$1"
1547 # func_verify_module
1548 # verifies a module name
1549 # Input:
1550 # - local_gnulib_dir from --local-dir
1551 # - module module name argument
1552 func_verify_module ()
1554 if func_exists_module "$module"; then
1555 # OK, $module is a correct module name.
1556 # Verify that building the module description with 'patch' succeeds.
1557 func_lookup_file "modules/$module"
1558 else
1559 func_warning "module $module doesn't exist"
1560 module=
1564 # func_verify_nontests_module
1565 # verifies a module name, excluding tests modules
1566 # Input:
1567 # - local_gnulib_dir from --local-dir
1568 # - module module name argument
1569 func_verify_nontests_module ()
1571 case "$module" in
1572 *-tests ) module= ;;
1573 * ) func_verify_module ;;
1574 esac
1577 # func_verify_tests_module
1578 # verifies a module name, considering only tests modules
1579 # Input:
1580 # - local_gnulib_dir from --local-dir
1581 # - module module name argument
1582 func_verify_tests_module ()
1584 case "$module" in
1585 *-tests ) func_verify_module ;;
1586 * ) module= ;;
1587 esac
1590 # Suffix of a sed expression that extracts a particular field from a
1591 # module description.
1592 # A field starts with a line that contains a keyword, such as 'Description',
1593 # followed by a colon and optional whitespace. All following lines, up to
1594 # the next field (or end of file if there is none) form the contents of the
1595 # field.
1596 # An absent field is equivalent to a field with empty contents.
1597 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1598 sed_extract_prog=':[ ]*$/ {
1601 s/^Description:[ ]*$//
1602 s/^Comment:[ ]*$//
1603 s/^Status:[ ]*$//
1604 s/^Notice:[ ]*$//
1605 s/^Applicability:[ ]*$//
1606 s/^Files:[ ]*$//
1607 s/^Depends-on:[ ]*$//
1608 s/^configure\.ac-early:[ ]*$//
1609 s/^configure\.ac:[ ]*$//
1610 s/^Makefile\.am:[ ]*$//
1611 s/^Include:[ ]*$//
1612 s/^Link:[ ]*$//
1613 s/^License:[ ]*$//
1614 s/^Maintainer:[ ]*$//
1621 # Piece of a sed expression that converts a field header line to a shell
1622 # variable name,
1623 # NOTE: Keep this in sync with sed_extract_prog above!
1624 sed_extract_field_header='
1625 s/^Description:[ ]*$/description/
1626 s/^Comment:[ ]*$/comment/
1627 s/^Status:[ ]*$/status/
1628 s/^Notice:[ ]*$/notice/
1629 s/^Applicability:[ ]*$/applicability/
1630 s/^Files:[ ]*$/files/
1631 s/^Depends-on:[ ]*$/dependson/
1632 s/^configure\.ac-early:[ ]*$/configureac_early/
1633 s/^configure\.ac:[ ]*$/configureac/
1634 s/^Makefile\.am:[ ]*$/makefile/
1635 s/^Include:[ ]*$/include/
1636 s/^Link:[ ]*$/link/
1637 s/^License:[ ]*$/license/
1638 s/^Maintainer:[ ]*$/maintainer/'
1640 if $modcache; then
1642 if $have_associative; then
1644 # Declare the associative arrays.
1645 declare -A modcache_cached
1646 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1647 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1648 eval "$declare_script"
1650 else
1652 # func_cache_var module
1653 # computes the cache variable name corresponding to $module.
1654 # Note: This computation can map different module names to the same
1655 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1656 # to protect against this case.
1657 # Output:
1658 # - cachevar a shell variable name
1659 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1660 # Bash 2.0 and newer, ksh, and zsh support the syntax
1661 # ${param//pattern/replacement}
1662 # as a shorthand for
1663 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1664 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1665 eval 'func_cache_var ()
1667 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1669 else
1670 func_cache_var ()
1672 case $1 in
1673 *[!a-zA-Z0-9_]*)
1674 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1676 cachevar=c_$1 ;;
1677 esac
1683 # func_init_sed_convert_to_cache_statements
1684 # Input:
1685 # - modcachevar_assignment
1686 # Output:
1687 # - sed_convert_to_cache_statements
1688 func_init_sed_convert_to_cache_statements ()
1690 # 'sed' script that turns a module description into shell script
1691 # assignments, suitable to be eval'ed. All active characters are escaped.
1692 # This script turns
1693 # Description:
1694 # Some module's description
1696 # Files:
1697 # lib/file.h
1698 # into:
1699 # modcache_description[$1]=\
1700 # 'Some module'"'"'s description
1702 # modcache_files[$1]=\
1703 # 'lib/file.h'
1704 # or:
1705 # c_MODULE_description_set=set; c_MODULE_description=\
1706 # 'Some module'"'"'s description
1708 # c_MODULE_files_set=set; c_MODULE_files=\
1709 # 'lib/file.h'
1710 # The script consists of two parts:
1711 # 1) Ignore the lines before the first field header.
1712 # 2) A loop, treating non-field-header lines by escaping single quotes
1713 # and adding a closing quote in the last line,
1714 sed_convert_to_cache_statements="
1715 :llla
1716 # Here we have not yet seen a field header.
1718 # See if the current line contains a field header.
1719 t llla1
1720 :llla1
1721 ${sed_extract_field_header}
1722 t lllb
1724 # No field header. Ignore the line.
1726 # Read the next line. Upon EOF, just exit.
1728 b llla
1730 :lllb
1731 # The current line contains a field header.
1733 # Turn it into the beginning of an assignment.
1734 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1736 # Move it to the hold space. Don't print it yet,
1737 # because we want no assignment if the field is empty.
1740 # Read the next line.
1741 # Upon EOF, the field was empty. Print no assignment. Just exit.
1744 # See if the current line contains a field header.
1745 t lllb1
1746 :lllb1
1747 ${sed_extract_field_header}
1748 # If it is, the previous field was empty. Print no assignment.
1749 t lllb
1751 # Not a field header.
1753 # Print the previous line, held in the hold space.
1758 # Transform single quotes.
1759 s/'/'\"'\"'/g
1761 # Prepend a single quote.
1762 s/^/'/
1764 :lllc
1766 # Move it to the hold space.
1769 # Read the next line.
1770 # Upon EOF, branch.
1772 b llle
1776 # See if the current line contains a field header.
1777 t lllc1
1778 :lllc1
1779 ${sed_extract_field_header}
1780 t llld
1782 # Print the previous line, held in the hold space.
1787 # Transform single quotes.
1788 s/'/'\"'\"'/g
1790 b lllc
1792 :llld
1793 # A field header.
1794 # Print the previous line, held in the hold space, with a single quote
1795 # to end the assignment.
1797 s/\$/'/
1801 b lllb
1803 :llle
1804 # EOF seen.
1805 # Print the previous line, held in the hold space, with a single quote
1806 # to end the assignment.
1808 s/\$/'/
1810 # Exit.
1813 if ! $sed_comments; then
1814 # Remove comments.
1815 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1816 | sed -e 's/^ *//' -e 's/^#.*//'`
1820 if $have_associative; then
1821 # sed_convert_to_cache_statements does not depend on the module.
1822 modcachevar_assignment='modcache_\1[$1]='
1823 func_init_sed_convert_to_cache_statements
1826 # func_cache_lookup_module module
1828 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1829 # of its relevant data in a cache in the memory of the processing shell. If
1830 # already cached, it does not look it up again, thus saving file access time.
1831 # Parameters:
1832 # - module non-empty string
1833 # Output if $have_associative:
1834 # - modcache_cached[$module] set to yes
1835 # - modcache_description[$module] ==
1836 # - modcache_status[$module] \ set to the field's value, minus the
1837 # - ... / final newline,
1838 # - modcache_maintainer[$module] == or unset if the field's value is empty
1839 # Output if ! $have_associative:
1840 # - cachevar a shell variable name
1841 # - ${cachevar}_cached set to $module
1842 # - ${cachevar}_description ==
1843 # - ${cachevar}_status \ set to the field's value, minus the
1844 # - ... / final newline,
1845 # - ${cachevar}_maintainer == or unset if the field's value is empty
1846 # - ${cachevar}_description_set ==
1847 # - ${cachevar}_status_set \ set to non-empty if the field's value
1848 # - ... / is non-empty,
1849 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1850 func_cache_lookup_module ()
1852 if $have_associative; then
1853 eval 'cached=${modcache_cached[$1]}'
1854 else
1855 func_cache_var "$1"
1856 eval "cached=\"\$${cachevar}_cached\""
1858 if test -z "$cached"; then
1859 # Not found in cache. Look it up on the file system.
1860 func_lookup_file "modules/$1"
1861 if $have_associative; then
1862 eval 'modcache_cached[$1]=yes'
1863 else
1864 eval "${cachevar}_cached=\"\$1\""
1866 if ! $have_associative; then
1867 # sed_convert_to_cache_statements depends on the module.
1868 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1869 func_init_sed_convert_to_cache_statements
1871 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1872 eval "$cache_statements"
1873 else
1874 if ! $have_associative; then
1875 if test "$1" != "$cached"; then
1876 func_fatal_error "cache variable collision between $1 and $cached"
1884 # func_get_description module
1885 # Input:
1886 # - local_gnulib_dir from --local-dir
1887 # - modcache true or false, from --cache-modules/--no-cache-modules
1888 func_get_description ()
1890 if ! $modcache; then
1891 func_lookup_file "modules/$1"
1892 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1893 else
1894 func_cache_lookup_module "$1"
1895 # Output the field's value, including the final newline (if any).
1896 if $have_associative; then
1897 if eval 'test -n "${modcache_description[$1]+set}"'; then
1898 eval 'echo "${modcache_description[$1]}"'
1900 else
1901 eval "field_set=\"\$${cachevar}_description_set\""
1902 if test -n "$field_set"; then
1903 eval "field_value=\"\$${cachevar}_description\""
1904 echo "${field_value}"
1910 # func_get_comment module
1911 # Input:
1912 # - local_gnulib_dir from --local-dir
1913 # - modcache true or false, from --cache-modules/--no-cache-modules
1914 func_get_comment ()
1916 if ! $modcache; then
1917 func_lookup_file "modules/$1"
1918 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
1919 else
1920 func_cache_lookup_module "$1"
1921 # Output the field's value, including the final newline (if any).
1922 if $have_associative; then
1923 if eval 'test -n "${modcache_comment[$1]+set}"'; then
1924 eval 'echo "${modcache_comment[$1]}"'
1926 else
1927 eval "field_set=\"\$${cachevar}_comment_set\""
1928 if test -n "$field_set"; then
1929 eval "field_value=\"\$${cachevar}_comment\""
1930 echo "${field_value}"
1936 # func_get_status module
1937 # Input:
1938 # - local_gnulib_dir from --local-dir
1939 # - modcache true or false, from --cache-modules/--no-cache-modules
1940 func_get_status ()
1942 if ! $modcache; then
1943 func_lookup_file "modules/$1"
1944 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1945 else
1946 func_cache_lookup_module "$1"
1947 # Output the field's value, including the final newline (if any).
1948 if $have_associative; then
1949 if eval 'test -n "${modcache_status[$1]+set}"'; then
1950 eval 'echo "${modcache_status[$1]}"'
1952 else
1953 eval "field_set=\"\$${cachevar}_status_set\""
1954 if test -n "$field_set"; then
1955 eval "field_value=\"\$${cachevar}_status\""
1956 echo "${field_value}"
1962 # func_get_notice module
1963 # Input:
1964 # - local_gnulib_dir from --local-dir
1965 # - modcache true or false, from --cache-modules/--no-cache-modules
1966 func_get_notice ()
1968 if ! $modcache; then
1969 func_lookup_file "modules/$1"
1970 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1971 else
1972 func_cache_lookup_module "$1"
1973 # Output the field's value, including the final newline (if any).
1974 if $have_associative; then
1975 if eval 'test -n "${modcache_notice[$1]+set}"'; then
1976 eval 'echo "${modcache_notice[$1]}"'
1978 else
1979 eval "field_set=\"\$${cachevar}_notice_set\""
1980 if test -n "$field_set"; then
1981 eval "field_value=\"\$${cachevar}_notice\""
1982 echo "${field_value}"
1988 # func_get_applicability module
1989 # Input:
1990 # - local_gnulib_dir from --local-dir
1991 # - modcache true or false, from --cache-modules/--no-cache-modules
1992 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1993 func_get_applicability ()
1995 if ! $modcache; then
1996 func_lookup_file "modules/$1"
1997 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1998 else
1999 func_cache_lookup_module "$1"
2000 # Get the field's value, without the final newline.
2001 if $have_associative; then
2002 eval 'my_applicability="${modcache_applicability[$1]}"'
2003 else
2004 eval "my_applicability=\"\$${cachevar}_applicability\""
2007 if test -n "$my_applicability"; then
2008 echo $my_applicability
2009 else
2010 # The default is 'main' or 'tests', depending on the module's name.
2011 case $1 in
2012 *-tests) echo "tests";;
2013 *) echo "main";;
2014 esac
2018 # func_get_filelist module
2019 # Input:
2020 # - local_gnulib_dir from --local-dir
2021 # - modcache true or false, from --cache-modules/--no-cache-modules
2022 func_get_filelist ()
2024 if ! $modcache; then
2025 func_lookup_file "modules/$1"
2026 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
2027 else
2028 func_cache_lookup_module "$1"
2029 # Output the field's value, including the final newline (if any).
2030 if $have_associative; then
2031 if eval 'test -n "${modcache_files[$1]+set}"'; then
2032 eval 'echo "${modcache_files[$1]}"'
2034 else
2035 eval "field_set=\"\$${cachevar}_files_set\""
2036 if test -n "$field_set"; then
2037 eval "field_value=\"\$${cachevar}_files\""
2038 echo "${field_value}"
2042 echo m4/00gnulib.m4
2043 echo m4/gnulib-common.m4
2044 case "$autoconf_minversion" in
2045 2.59)
2046 echo m4/onceonly.m4
2048 esac
2051 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2052 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2053 # elements starting with prefix and ending with suffix are considered.
2054 # Processing: removed_prefix and removed_suffix are removed from each element,
2055 # added_prefix and added_suffix are added to each element.
2056 # prefix, suffix should not contain shell-special characters.
2057 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2058 # added_prefix, added_suffix should not contain the characters \|&.
2059 func_filter_filelist ()
2061 if test "$2" != "$nl" \
2062 || { $fast_func_append \
2063 && { test -z "$6" || $fast_func_remove_prefix; } \
2064 && { test -z "$7" || $fast_func_remove_suffix; }; \
2065 }; then
2066 ffflist=
2067 for fff in $3; do
2068 # Do not quote possibly-empty parameters in case patterns,
2069 # AIX and HP-UX ksh won't match them if they are empty.
2070 case "$fff" in
2071 $4*$5)
2072 if test -n "$6"; then
2073 func_remove_prefix fff "$6"
2075 if test -n "$7"; then
2076 func_remove_suffix fff "$7"
2078 fff="$8${fff}$9"
2079 if test -z "$ffflist"; then
2080 ffflist="${fff}"
2081 else
2082 func_append ffflist "$2${fff}"
2085 esac
2086 done
2087 else
2088 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2089 ffflist=`for fff in $3; do
2090 case "$fff" in
2091 $4*$5) echo "$fff" ;;
2092 esac
2093 done | sed -e "$sed_fff_filter"`
2095 eval "$1=\"\$ffflist\""
2098 # func_get_dependencies module
2099 # Input:
2100 # - local_gnulib_dir from --local-dir
2101 # - modcache true or false, from --cache-modules/--no-cache-modules
2102 func_get_dependencies ()
2104 # ${module}-tests implicitly depends on ${module}, if that module exists.
2105 case "$1" in
2106 *-tests)
2107 fgd1="$1"
2108 func_remove_suffix fgd1 '-tests'
2109 if func_exists_module "$fgd1"; then
2110 echo "$fgd1"
2113 esac
2114 # Then the explicit dependencies listed in the module description.
2115 { if ! $modcache; then
2116 func_lookup_file "modules/$1"
2117 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2118 else
2119 func_cache_lookup_module "$1"
2120 # Output the field's value, including the final newline (if any).
2121 if $have_associative; then
2122 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2123 eval 'echo "${modcache_dependson[$1]}"'
2125 else
2126 eval "field_set=\"\$${cachevar}_dependson_set\""
2127 if test -n "$field_set"; then
2128 eval "field_value=\"\$${cachevar}_dependson\""
2129 echo "${field_value}"
2134 | sed -e '/^#/d'
2137 # func_get_autoconf_early_snippet module
2138 # Input:
2139 # - local_gnulib_dir from --local-dir
2140 # - modcache true or false, from --cache-modules/--no-cache-modules
2141 func_get_autoconf_early_snippet ()
2143 if ! $modcache; then
2144 func_lookup_file "modules/$1"
2145 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2146 else
2147 func_cache_lookup_module "$1"
2148 # Output the field's value, including the final newline (if any).
2149 if $have_associative; then
2150 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2151 eval 'echo "${modcache_configureac_early[$1]}"'
2153 else
2154 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2155 if test -n "$field_set"; then
2156 eval "field_value=\"\$${cachevar}_configureac_early\""
2157 echo "${field_value}"
2163 # func_get_autoconf_snippet module
2164 # Input:
2165 # - local_gnulib_dir from --local-dir
2166 # - modcache true or false, from --cache-modules/--no-cache-modules
2167 func_get_autoconf_snippet ()
2169 if ! $modcache; then
2170 func_lookup_file "modules/$1"
2171 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2172 else
2173 func_cache_lookup_module "$1"
2174 # Output the field's value, including the final newline (if any).
2175 if $have_associative; then
2176 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2177 eval 'echo "${modcache_configureac[$1]}"'
2179 else
2180 eval "field_set=\"\$${cachevar}_configureac_set\""
2181 if test -n "$field_set"; then
2182 eval "field_value=\"\$${cachevar}_configureac\""
2183 echo "${field_value}"
2189 # func_get_automake_snippet_conditional module
2190 # returns the part of the Makefile.am snippet that can be put inside Automake
2191 # conditionals.
2192 # Input:
2193 # - local_gnulib_dir from --local-dir
2194 # - modcache true or false, from --cache-modules/--no-cache-modules
2195 func_get_automake_snippet_conditional ()
2197 if ! $modcache; then
2198 func_lookup_file "modules/$1"
2199 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2200 else
2201 func_cache_lookup_module "$1"
2202 # Output the field's value, including the final newline (if any).
2203 if $have_associative; then
2204 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2205 eval 'echo "${modcache_makefile[$1]}"'
2207 else
2208 eval "field_set=\"\$${cachevar}_makefile_set\""
2209 if test -n "$field_set"; then
2210 eval "field_value=\"\$${cachevar}_makefile\""
2211 echo "${field_value}"
2217 # func_get_automake_snippet_unconditional module
2218 # returns the part of the Makefile.am snippet that must stay outside of
2219 # Automake conditionals.
2220 # Input:
2221 # - local_gnulib_dir from --local-dir
2222 # - modcache true or false, from --cache-modules/--no-cache-modules
2223 func_get_automake_snippet_unconditional ()
2225 case "$1" in
2226 *-tests)
2227 # *-tests module live in tests/, not lib/.
2228 # Synthesize an EXTRA_DIST augmentation.
2229 all_files=`func_get_filelist $1`
2230 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2231 extra_files="$tests_files"
2232 if test -n "$extra_files"; then
2233 echo "EXTRA_DIST +=" $extra_files
2234 echo
2238 # Synthesize an EXTRA_DIST augmentation.
2239 sed_combine_lines='/\\$/{
2242 s/\\\n/ /
2243 s/\\$/\\/
2246 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2247 already_mentioned_files=` \
2248 { if ! $modcache; then
2249 func_lookup_file "modules/$1"
2250 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2251 else
2252 func_cache_lookup_module "$1"
2253 if $have_associative; then
2254 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2255 eval 'echo "${modcache_makefile[$1]}"'
2257 else
2258 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2259 if test -n "$field_set"; then
2260 eval 'field_value="$'"${cachevar}"'_makefile"'
2261 echo "${field_value}"
2266 | sed -e "$sed_combine_lines" \
2267 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2268 all_files=`func_get_filelist $1`
2269 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2270 # Remove $already_mentioned_files from $lib_files.
2271 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2272 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2273 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2274 if test -n "$extra_files"; then
2275 echo "EXTRA_DIST +=" $extra_files
2276 echo
2278 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2279 # This is necessary so that automake can generate the right list of
2280 # dependency rules.
2281 # A possible approach would be to use autom4te --trace of the redefined
2282 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2283 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2284 # inside autoconf's built-in macros are not missed).
2285 # But it's simpler and more robust to do it here, based on the file list.
2286 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2287 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2288 # automake will generate a useless dependency; this is harmless.
2289 case "$1" in
2290 relocatable-prog-wrapper) ;;
2291 pt_chown) ;;
2293 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2294 if test -n "$extra_files"; then
2295 echo "EXTRA_lib_SOURCES +=" $extra_files
2296 echo
2299 esac
2300 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2301 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2302 if test -n "$buildaux_files"; then
2303 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2304 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2305 echo
2307 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2308 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2309 if test -n "$top_files"; then
2310 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2311 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2312 echo
2315 esac
2318 # func_get_automake_snippet module
2319 # Input:
2320 # - local_gnulib_dir from --local-dir
2321 # - modcache true or false, from --cache-modules/--no-cache-modules
2322 func_get_automake_snippet ()
2324 func_get_automake_snippet_conditional "$1"
2325 func_get_automake_snippet_unconditional "$1"
2328 # func_get_include_directive module
2329 # Input:
2330 # - local_gnulib_dir from --local-dir
2331 # - modcache true or false, from --cache-modules/--no-cache-modules
2332 func_get_include_directive ()
2335 if ! $modcache; then
2336 func_lookup_file "modules/$1"
2337 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2338 else
2339 func_cache_lookup_module "$1"
2340 # Output the field's value, including the final newline (if any).
2341 if $have_associative; then
2342 if eval 'test -n "${modcache_include[$1]+set}"'; then
2343 eval 'echo "${modcache_include[$1]}"'
2345 else
2346 eval "field_set=\"\$${cachevar}_include_set\""
2347 if test -n "$field_set"; then
2348 eval "field_value=\"\$${cachevar}_include\""
2349 echo "${field_value}"
2353 } | sed -e 's/^\(["<]\)/#include \1/'
2356 # func_get_link_directive module
2357 # Input:
2358 # - local_gnulib_dir from --local-dir
2359 # - modcache true or false, from --cache-modules/--no-cache-modules
2360 func_get_link_directive ()
2362 if ! $modcache; then
2363 func_lookup_file "modules/$1"
2364 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2365 else
2366 func_cache_lookup_module "$1"
2367 # Output the field's value, including the final newline (if any).
2368 if $have_associative; then
2369 if eval 'test -n "${modcache_link[$1]+set}"'; then
2370 eval 'echo "${modcache_link[$1]}"'
2372 else
2373 eval "field_set=\"\$${cachevar}_link_set\""
2374 if test -n "$field_set"; then
2375 eval "field_value=\"\$${cachevar}_link\""
2376 echo "${field_value}"
2382 # func_get_license_raw module
2383 # Input:
2384 # - local_gnulib_dir from --local-dir
2385 # - modcache true or false, from --cache-modules/--no-cache-modules
2386 func_get_license_raw ()
2388 if ! $modcache; then
2389 func_lookup_file "modules/$1"
2390 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2391 else
2392 func_cache_lookup_module "$1"
2393 # Output the field's value, including the final newline (if any).
2394 if $have_associative; then
2395 if eval 'test -n "${modcache_license[$1]+set}"'; then
2396 eval 'echo "${modcache_license[$1]}"'
2398 else
2399 eval "field_set=\"\$${cachevar}_license_set\""
2400 if test -n "$field_set"; then
2401 eval "field_value=\"\$${cachevar}_license\""
2402 echo "${field_value}"
2408 # func_get_license module
2409 # Input:
2410 # - local_gnulib_dir from --local-dir
2411 # - modcache true or false, from --cache-modules/--no-cache-modules
2412 func_get_license ()
2414 # Warn if the License field is missing.
2415 case "$1" in
2416 *-tests ) ;;
2418 license=`func_get_license_raw "$1"`
2419 if test -z "$license"; then
2420 func_warning "module $1 lacks a License"
2423 esac
2425 func_get_license_raw "$1"
2426 # The default is GPL.
2427 echo "GPL"
2428 } | sed -e 's,^ *$,,' | sed -e 1q
2431 # func_get_maintainer module
2432 # Input:
2433 # - local_gnulib_dir from --local-dir
2434 # - modcache true or false, from --cache-modules/--no-cache-modules
2435 func_get_maintainer ()
2437 if ! $modcache; then
2438 func_lookup_file "modules/$1"
2439 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2440 else
2441 func_cache_lookup_module "$1"
2442 # Output the field's value, including the final newline (if any).
2443 if $have_associative; then
2444 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2445 eval 'echo "${modcache_maintainer[$1]}"'
2447 else
2448 eval "field_set=\"\$${cachevar}_maintainer_set\""
2449 if test -n "$field_set"; then
2450 eval "field_value=\"\$${cachevar}_maintainer\""
2451 echo "${field_value}"
2457 # func_get_tests_module module
2458 # Input:
2459 # - local_gnulib_dir from --local-dir
2460 func_get_tests_module ()
2462 # The naming convention for tests modules is hardwired: ${module}-tests.
2463 if test -f "$gnulib_dir/modules/$1"-tests \
2464 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2465 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2466 echo "$1"-tests
2470 # func_acceptable module
2471 # tests whether a module is acceptable.
2472 # Input:
2473 # - avoidlist list of modules to avoid
2474 func_acceptable ()
2476 for avoid in $avoidlist; do
2477 if test "$avoid" = "$1"; then
2478 return 1
2480 done
2481 return 0
2484 # sed expression to keep the first 32 characters of each line.
2485 sed_first_32_chars='s/^\(................................\).*/\1/'
2487 # func_module_shellfunc_name module
2488 # computes the shell function name that will contain the m4 macros for the module.
2489 # Input:
2490 # - macro_prefix prefix to use
2491 # Output:
2492 # - shellfunc shell function name
2493 func_module_shellfunc_name ()
2495 case $1 in
2496 *[!a-zA-Z0-9_]*)
2497 shellfunc=func_${macro_prefix}_gnulib_m4code_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2499 shellfunc=func_${macro_prefix}_gnulib_m4code_$1 ;;
2500 esac
2503 # func_module_shellvar_name module
2504 # computes the shell variable name the will be set to true once the m4 macros
2505 # for the module have been executed.
2506 # Output:
2507 # - shellvar shell variable name
2508 func_module_shellvar_name ()
2510 case $1 in
2511 *[!a-zA-Z0-9_]*)
2512 shellvar=${macro_prefix}_gnulib_enabled_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2514 shellvar=${macro_prefix}_gnulib_enabled_$1 ;;
2515 esac
2518 # func_module_conditional_name module
2519 # computes the automake conditional name for the module.
2520 # Output:
2521 # - conditional name of automake conditional
2522 func_module_conditional_name ()
2524 case $1 in
2525 *[!a-zA-Z0-9_]*)
2526 conditional=${macro_prefix}_GNULIB_ENABLED_`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2528 conditional=${macro_prefix}_GNULIB_ENABLED_$1 ;;
2529 esac
2532 # func_uncond_add_module B
2533 # notes the presence of B as an unconditional module.
2535 # func_conddep_add_module A B cond
2536 # notes the presence of a conditional dependency from module A to module B,
2537 # subject to the condition that A is enabled and cond is true.
2539 # func_cond_module_p B
2540 # tests whether module B is conditional.
2542 # func_cond_module_condition A B
2543 # returns the condition when B should be enabled as a dependency of A, once the
2544 # m4 code for A has been executed.
2545 # Output: - condition
2547 if $have_associative; then
2548 declare -A conddep_isuncond
2549 declare -A conddep_dependers
2550 declare -A conddep_condition
2551 func_uncond_add_module ()
2553 eval 'conddep_isuncond[$1]=true'
2554 eval 'unset conddep_dependers[$1]'
2556 func_conddep_add_module ()
2558 eval 'isuncond="${conddep_isuncond[$2]}"'
2559 if test -z "$isuncond"; then
2560 # No unconditional dependency to B known at this point.
2561 eval 'conddep_dependers[$2]="${conddep_dependers[$2]} $1"'
2562 eval 'conddep_condition[$1---$2]="$3"'
2565 func_cond_module_p ()
2567 eval 'previous_dependers="${conddep_dependers[$1]}"'
2568 test -n "$previous_dependers"
2570 func_cond_module_condition ()
2572 eval 'condition="${conddep_condition[$1---$2]}"'
2574 else
2575 func_uncond_add_module ()
2577 case $1 in
2578 *[!a-zA-Z0-9_]*)
2579 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2581 suffix=$1 ;;
2582 esac
2583 eval 'conddep_isuncond_'"$suffix"'=true'
2584 eval 'unset conddep_dependers_'"$suffix"
2586 func_conddep_add_module ()
2588 case $2 in
2589 *[!a-zA-Z0-9_]*)
2590 suffix=`echo "$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2592 suffix=$2 ;;
2593 esac
2594 eval 'isuncond="${conddep_isuncond_'"$suffix"'}"'
2595 if test -z "$isuncond"; then
2596 eval 'conddep_dependers_'"$suffix"'="${conddep_dependers_'"$suffix"'} $1"'
2597 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2598 eval 'conddep_condition_'"$suffix"'="$3"'
2601 func_cond_module_p ()
2603 case $1 in
2604 *[!a-zA-Z0-9_]*)
2605 suffix=`echo "$1" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"` ;;
2607 suffix=$1 ;;
2608 esac
2609 eval 'previous_dependers="${conddep_dependers_'"$suffix"'}"'
2610 test -n "$previous_dependers"
2612 func_cond_module_condition ()
2614 suffix=`echo "$1---$2" | md5sum | LC_ALL=C sed -e "$sed_first_32_chars"`
2615 eval 'condition="${conddep_condition_'"$suffix"'}"'
2619 sed_dependencies_without_conditions='s/ *\[.*//'
2621 # func_modules_transitive_closure
2622 # Input:
2623 # - local_gnulib_dir from --local-dir
2624 # - modcache true or false, from --cache-modules/--no-cache-modules
2625 # - modules list of specified modules
2626 # - inctests true if tests should be included, blank otherwise
2627 # - incobsolete true if obsolete modules among dependencies should be
2628 # included, blank otherwise
2629 # - inc_cxx_tests true if C++ interoperability tests should be included,
2630 # blank otherwise
2631 # - inc_longrunning_tests true if long-runnings tests should be included,
2632 # blank otherwise
2633 # - inc_privileged_tests true if tests that require root privileges should be
2634 # included, blank otherwise
2635 # - inc_unportable_tests true if tests that fail on some platforms should be
2636 # included, blank otherwise
2637 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2638 # the unit tests of the specified modules should be
2639 # included, blank otherwise
2640 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2641 # the unit tests of the dependencies should be
2642 # included, blank otherwise
2643 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2644 # blank otherwise
2645 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2646 # blank otherwise
2647 # - excl_privileged_tests true if tests that require root privileges should be
2648 # excluded, blank otherwise
2649 # - excl_unportable_tests true if tests that fail on some platforms should be
2650 # excluded, blank otherwise
2651 # - avoidlist list of modules to avoid
2652 # - cond_dependencies true if conditional dependencies shall be supported,
2653 # blank otherwise
2654 # - tmp pathname of a temporary directory
2655 # Output:
2656 # - modules list of modules, including dependencies
2657 # - conddep_dependers, conddep_condition information about conditionally
2658 # enabled modules
2659 func_modules_transitive_closure ()
2661 sed_escape_dependency='s|\([/.]\)|\\\1|g'
2662 # In order to process every module only once (for speed), process an "input
2663 # list" of modules, producing an "output list" of modules. During each round,
2664 # more modules can be queued in the input list. Once a module on the input
2665 # list has been processed, it is added to the "handled list", so we can avoid
2666 # to process it again.
2667 handledmodules=
2668 inmodules="$modules"
2669 outmodules=
2670 fmtc_inc_all_tests="$inc_all_direct_tests"
2671 if test "$cond_dependencies" = true; then
2672 for module in $inmodules; do
2673 func_verify_module
2674 if test -n "$module"; then
2675 if func_acceptable $module; then
2676 func_uncond_add_module $module
2679 done
2681 while test -n "$inmodules"; do
2682 inmodules_this_round="$inmodules"
2683 inmodules= # Accumulator, queue for next round
2684 for module in $inmodules_this_round; do
2685 func_verify_module
2686 if test -n "$module"; then
2687 if func_acceptable $module; then
2688 func_append outmodules " $module"
2689 if test "$cond_dependencies" = true; then
2690 if func_get_automake_snippet_conditional $module | grep '^if ' > /dev/null; then
2691 # A module whose Makefile.am snippet contains a reference to an
2692 # automake conditional. If we were to use it conditionally, we
2693 # would get an error
2694 # configure: error: conditional "..." was never defined.
2695 # because automake 1.11.1 does not handle nested conditionals
2696 # correctly. As a workaround, make the module unconditional.
2697 func_uncond_add_module $module
2699 if func_cond_module_p $module; then
2700 conditional=true
2701 else
2702 conditional=false
2705 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
2706 # Duplicate dependencies are harmless, but Jim wants a warning.
2707 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2708 if test -n "$duplicated_deps"; then
2709 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2711 if test -n "$inctests"; then
2712 testsmodule=`func_get_tests_module $module`
2713 if test -n "$testsmodule"; then
2714 deps="$deps $testsmodule"
2717 for dep in $deps; do
2718 # Determine whether to include the dependency or tests module.
2719 inc=true
2720 for word in `func_get_status $dep`; do
2721 case "$word" in
2722 obsolete)
2723 test -n "$incobsolete" \
2724 || inc=false
2726 c++-test)
2727 test -z "$excl_cxx_tests" \
2728 || inc=false
2729 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2730 || inc=false
2732 longrunning-test)
2733 test -z "$excl_longrunning_tests" \
2734 || inc=false
2735 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2736 || inc=false
2738 privileged-test)
2739 test -z "$excl_privileged_tests" \
2740 || inc=false
2741 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2742 || inc=false
2744 unportable-test)
2745 test -z "$excl_unportable_tests" \
2746 || inc=false
2747 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2748 || inc=false
2750 *-test)
2751 test -n "$fmtc_inc_all_tests" \
2752 || inc=false
2754 esac
2755 done
2756 if $inc && func_acceptable "$dep"; then
2757 func_append inmodules " $dep"
2758 if test "$cond_dependencies" = true; then
2759 escaped_dep=`echo "$dep" | sed -e "$sed_escape_dependency"`
2760 sed_extract_condition1='/^ *'"$escaped_dep"' *$/{
2761 s/^.*$/true/p
2763 sed_extract_condition2='/^ *'"$escaped_dep"' *\[.*\] *$/{
2764 s/^ *'"$escaped_dep"' *\[\(.*\)\] *$/\1/p
2766 condition=`func_get_dependencies $module | sed -n -e "$sed_extract_condition1" -e "$sed_extract_condition2"`
2767 if test "$condition" = true; then
2768 condition=
2770 if test -n "$condition"; then
2771 func_conddep_add_module "$module" "$dep" "$condition"
2772 else
2773 if $conditional; then
2774 func_conddep_add_module "$module" "$dep" true
2775 else
2776 func_uncond_add_module "$dep"
2781 done
2784 done
2785 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2786 # Remove $handledmodules from $inmodules.
2787 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2788 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2789 fmtc_inc_all_tests="$inc_all_indirect_tests"
2790 done
2791 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2792 rm -f "$tmp"/queued-modules
2795 # func_show_module_list
2796 # Input:
2797 # - specified_modules list of specified modules (one per line, sorted)
2798 # - modules complete list of modules (one per line, sorted)
2799 # - tmp pathname of a temporary directory
2800 func_show_module_list ()
2802 if case "$TERM" in
2803 xterm*) test -t 1;;
2804 *) false;;
2805 esac; then
2806 # Assume xterm compatible escape sequences.
2807 bold_on=`printf '\x1b[1m'`
2808 bold_off=`printf '\x1b[0m'`
2809 else
2810 bold_on=
2811 bold_off=
2813 echo "Module list with included dependencies (indented):"
2814 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2815 echo "$modules" | sed -e '/^$/d' \
2816 | LC_ALL=C join -t '|' -a2 "$tmp"/specified-modules - \
2817 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2820 # func_modules_transitive_closure_separately
2821 # Determine main module list and tests-related module list separately.
2822 # The main module list is the transitive closure of the specified modules,
2823 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2824 # is specified, it will consist only of LGPLed source.
2825 # The tests-related module list is the transitive closure of the specified
2826 # modules, including tests modules, minus the main module list excluding
2827 # modules of applicability 'all'. Its lib/* sources (brought in through
2828 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
2829 # source, even if --lgpl is specified.
2830 # Input:
2831 # - local_gnulib_dir from --local-dir
2832 # - modcache true or false, from --cache-modules/--no-cache-modules
2833 # - specified_modules list of specified modules
2834 # - inctests true if tests should be included, blank otherwise
2835 # - incobsolete true if obsolete modules among dependencies should be
2836 # included, blank otherwise
2837 # - inc_cxx_tests true if C++ interoperability tests should be included,
2838 # blank otherwise
2839 # - inc_longrunning_tests true if long-runnings tests should be included,
2840 # blank otherwise
2841 # - inc_privileged_tests true if tests that require root privileges should be
2842 # included, blank otherwise
2843 # - inc_unportable_tests true if tests that fail on some platforms should be
2844 # included, blank otherwise
2845 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2846 # the unit tests of the specified modules should be
2847 # included, blank otherwise
2848 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2849 # the unit tests of the dependencies should be
2850 # included, blank otherwise
2851 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2852 # blank otherwise
2853 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2854 # blank otherwise
2855 # - excl_privileged_tests true if tests that require root privileges should be
2856 # excluded, blank otherwise
2857 # - excl_unportable_tests true if tests that fail on some platforms should be
2858 # excluded, blank otherwise
2859 # - avoidlist list of modules to avoid
2860 # - cond_dependencies true if conditional dependencies shall be supported,
2861 # blank otherwise
2862 # - tmp pathname of a temporary directory
2863 # Output:
2864 # - main_modules list of modules, including dependencies
2865 # - testsrelated_modules list of tests-related modules, including dependencies
2866 # - conddep_dependers, conddep_condition information about conditionally
2867 # enabled modules
2868 func_modules_transitive_closure_separately ()
2870 # Determine main module list.
2871 saved_inctests="$inctests"
2872 inctests=""
2873 modules="$specified_modules"
2874 func_modules_transitive_closure
2875 main_modules="$modules"
2876 inctests="$saved_inctests"
2877 if test $verbose -ge 1; then
2878 echo "Main module list:"
2879 echo "$main_modules" | sed -e 's/^/ /'
2881 # Determine tests-related module list.
2882 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2883 testsrelated_modules=`for module in $main_modules; do
2884 if test \`func_get_applicability $module\` = main; then
2885 echo $module
2887 done \
2888 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2889 if test $verbose -ge 1; then
2890 echo "Tests-related module list:"
2891 echo "$testsrelated_modules" | sed -e 's/^/ /'
2895 # func_determine_use_libtests
2896 # Determines whether a $testsbase/libtests.a is needed.
2897 # Input:
2898 # - local_gnulib_dir from --local-dir
2899 # - modcache true or false, from --cache-modules/--no-cache-modules
2900 # - testsrelated_modules list of tests-related modules, including dependencies
2901 # Output:
2902 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
2903 func_determine_use_libtests ()
2905 use_libtests=false
2906 for module in $testsrelated_modules; do
2907 func_verify_nontests_module
2908 if test -n "$module"; then
2909 all_files=`func_get_filelist $module`
2910 # Test whether some file in $all_files lies in lib/.
2911 for f in $all_files; do
2912 case $f in
2913 lib/*)
2914 use_libtests=true
2915 break 2
2917 esac
2918 done
2920 done
2923 # func_modules_add_dummy
2924 # Input:
2925 # - local_gnulib_dir from --local-dir
2926 # - modcache true or false, from --cache-modules/--no-cache-modules
2927 # - modules list of modules, including dependencies
2928 # Output:
2929 # - modules list of modules, including 'dummy' if needed
2930 func_modules_add_dummy ()
2932 # Determine whether any module provides a lib_SOURCES augmentation.
2933 have_lib_SOURCES=
2934 sed_remove_backslash_newline=':a
2935 /\\$/{
2936 s/\\$//
2938 s/\n//
2941 for module in $modules; do
2942 func_verify_nontests_module
2943 if test -n "$module"; then
2944 # Extract the value of "lib_SOURCES += ...".
2945 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2946 # Ignore .h files since they are not compiled.
2947 case "$file" in
2948 *.h) ;;
2950 have_lib_SOURCES=yes
2951 break 2
2953 esac
2954 done
2956 done
2957 # Add the dummy module, to make sure the library will be non-empty.
2958 if test -z "$have_lib_SOURCES"; then
2959 if func_acceptable "dummy"; then
2960 func_append modules " dummy"
2965 # func_modules_add_dummy_separately
2966 # Input:
2967 # - local_gnulib_dir from --local-dir
2968 # - modcache true or false, from --cache-modules/--no-cache-modules
2969 # - main_modules list of modules, including dependencies
2970 # - testsrelated_modules list of tests-related modules, including dependencies
2971 # - use_libtests true if a $testsbase/libtests.a is needed, false otherwise
2972 # Output:
2973 # - main_modules list of modules, including 'dummy' if needed
2974 # - testsrelated_modules list of tests-related modules, including 'dummy' if
2975 # needed
2976 func_modules_add_dummy_separately ()
2978 # Add the dummy module to the main module list if needed.
2979 modules="$main_modules"
2980 func_modules_add_dummy
2981 main_modules="$modules"
2983 # Add the dummy module to the tests-related module list if needed.
2984 if $use_libtests; then
2985 modules="$testsrelated_modules"
2986 func_modules_add_dummy
2987 testsrelated_modules="$modules"
2991 # func_modules_notice
2992 # Input:
2993 # - local_gnulib_dir from --local-dir
2994 # - modcache true or false, from --cache-modules/--no-cache-modules
2995 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2996 # - modules list of modules, including dependencies
2997 func_modules_notice ()
2999 if test $verbose -ge -1; then
3000 for module in $modules; do
3001 func_verify_module
3002 if test -n "$module"; then
3003 msg=`func_get_notice $module`
3004 if test -n "$msg"; then
3005 echo "Notice from module $module:"
3006 echo "$msg" | sed -e 's/^/ /'
3009 done
3013 # func_modules_to_filelist
3014 # Input:
3015 # - local_gnulib_dir from --local-dir
3016 # - modcache true or false, from --cache-modules/--no-cache-modules
3017 # - modules list of modules, including dependencies
3018 # Output:
3019 # - files list of files
3020 func_modules_to_filelist ()
3022 files=
3023 for module in $modules; do
3024 func_verify_module
3025 if test -n "$module"; then
3026 fs=`func_get_filelist $module`
3027 func_append files " $fs"
3029 done
3030 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
3033 # func_modules_to_filelist_separately
3034 # Determine the final file lists.
3035 # They must be computed separately, because files in lib/* go into
3036 # $sourcebase/ if they are in the main file list but into $testsbase/
3037 # if they are in the tests-related file list. Furthermore lib/dummy.c
3038 # can be in both.
3039 # Input:
3040 # - local_gnulib_dir from --local-dir
3041 # - modcache true or false, from --cache-modules/--no-cache-modules
3042 # - main_modules list of modules, including dependencies
3043 # - testsrelated_modules list of tests-related modules, including dependencies
3044 func_modules_to_filelist_separately ()
3046 # Determine final main file list.
3047 modules="$main_modules"
3048 func_modules_to_filelist
3049 main_files="$files"
3050 # Determine final tests-related file list.
3051 modules="$testsrelated_modules"
3052 func_modules_to_filelist
3053 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3054 # Merge both file lists.
3055 sed_remove_empty_lines='/^$/d'
3056 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3057 if test $verbose -ge 0; then
3058 echo "File list:"
3059 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3060 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3064 # func_compute_include_guard_prefix
3065 # Determine include_guard_prefix.
3066 # Input:
3067 # - macro_prefix prefix of gl_LIBOBJS macros to use
3068 # Output:
3069 # - include_guard_prefix replacement for ${gl_include_guard_prefix}
3070 # - sed_replace_include_guard_prefix
3071 # sed expression for resolving ${gl_include_guard_prefix}
3072 func_compute_include_guard_prefix ()
3074 if test "$macro_prefix" = gl; then
3075 include_guard_prefix='GL'
3076 else
3077 include_guard_prefix='GL_'`echo "$macro_prefix" | LC_ALL=C tr '[a-z]' '[A-Z]'`
3079 sed_replace_include_guard_prefix='s/\${gl_include_guard_prefix}/'"${include_guard_prefix}"'/g'
3082 # func_execute_command command [args...]
3083 # Executes a command.
3084 # Uses also the variables
3085 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3086 func_execute_command ()
3088 if test $verbose -ge 0; then
3089 echo "executing $*"
3090 "$@"
3091 else
3092 # Commands like automake produce output to stderr even when they succeed.
3093 # Turn this output off if the command succeeds.
3094 "$@" > "$tmp"/cmdout 2>&1
3095 cmdret=$?
3096 if test $cmdret = 0; then
3097 rm -f "$tmp"/cmdout
3098 else
3099 echo "executing $*"
3100 cat "$tmp"/cmdout 1>&2
3101 rm -f "$tmp"/cmdout
3102 (exit $cmdret)
3107 # func_dest_tmpfilename file
3108 # determines the name of a temporary file (file is relative to destdir).
3109 # Input:
3110 # - destdir target directory
3111 # - doit : if actions shall be executed, false if only to be printed
3112 # - tmp pathname of a temporary directory
3113 # Sets variable:
3114 # - tmpfile absolute filename of the temporary file
3115 func_dest_tmpfilename ()
3117 if $doit; then
3118 # Put the new contents of $file in a file in the same directory (needed
3119 # to guarantee that an 'mv' to "$destdir/$file" works).
3120 tmpfile="$destdir/$1.tmp"
3121 else
3122 # Put the new contents of $file in a file in a temporary directory
3123 # (because the directory of "$file" might not exist).
3124 tmpfile="$tmp"/`basename "$1"`.tmp
3128 # func_add_file
3129 # copies a file from gnulib into the destination directory. The destination
3130 # is known to not exist.
3131 # Input:
3132 # - destdir target directory
3133 # - local_gnulib_dir from --local-dir
3134 # - modcache true or false, from --cache-modules/--no-cache-modules
3135 # - f the original file name
3136 # - lookedup_file name of the merged (combined) file
3137 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3138 # - g the rewritten file name
3139 # - tmpfile absolute filename of the temporary file
3140 # - doit : if actions shall be executed, false if only to be printed
3141 # - symbolic true if files should be symlinked, copied otherwise
3142 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3143 # copied otherwise
3144 func_add_file ()
3146 if $doit; then
3147 echo "Copying file $g"
3148 if { test -n "$symbolic" \
3149 || { test -n "$lsymbolic" \
3150 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
3151 && test -z "$lookedup_tmp" \
3152 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
3153 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3154 else
3155 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3157 else
3158 echo "Copy file $g"
3162 # func_update_file
3163 # copies a file from gnulib into the destination directory. The destination
3164 # is known to exist.
3165 # Input:
3166 # - destdir target directory
3167 # - local_gnulib_dir from --local-dir
3168 # - modcache true or false, from --cache-modules/--no-cache-modules
3169 # - f the original file name
3170 # - lookedup_file name of the merged (combined) file
3171 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
3172 # - g the rewritten file name
3173 # - tmpfile absolute filename of the temporary file
3174 # - doit : if actions shall be executed, false if only to be printed
3175 # - symbolic true if files should be symlinked, copied otherwise
3176 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3177 # copied otherwise
3178 # - already_present nonempty if the file should already exist, empty otherwise
3179 func_update_file ()
3181 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
3182 : # The file has not changed.
3183 else
3184 # Replace the file.
3185 if $doit; then
3186 if test -n "$already_present"; then
3187 echo "Updating file $g (backup in ${g}~)"
3188 else
3189 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
3191 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3192 if { test -n "$symbolic" \
3193 || { test -n "$lsymbolic" \
3194 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
3195 && test -z "$lookedup_tmp" \
3196 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
3197 func_ln_if_changed "$lookedup_file" "$destdir/$g"
3198 else
3199 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
3201 else
3202 if test -n "$already_present"; then
3203 echo "Update file $g (backup in ${g}~)"
3204 else
3205 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
3211 # func_emit_lib_Makefile_am
3212 # emits the contents of library makefile to standard output.
3213 # Input:
3214 # - local_gnulib_dir from --local-dir
3215 # - modcache true or false, from --cache-modules/--no-cache-modules
3216 # - modules list of modules, including dependencies
3217 # - libname library name
3218 # - pobase directory relative to destdir where to place *.po files
3219 # - auxdir directory relative to destdir where to place build aux files
3220 # - makefile_name from --makefile-name
3221 # - libtool true if libtool will be used, false or blank otherwise
3222 # - macro_prefix prefix of gl_LIBOBJS macros to use
3223 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3224 # - witness_c_macro from --witness-c-macro
3225 # - actioncmd (optional) command that will reproduce this invocation
3226 # - for_test true if creating a package for testing, false otherwise
3227 # - sed_replace_include_guard_prefix
3228 # sed expression for resolving ${gl_include_guard_prefix}
3229 # - destfile filename relative to destdir of makefile being generated
3230 # Input/Output:
3231 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3232 # list of edits to be done to Makefile.am variables
3233 # Output:
3234 # - uses_subdirs nonempty if object files in subdirs exist
3235 func_emit_lib_Makefile_am ()
3237 # When creating an includable Makefile.am snippet, augment variables with
3238 # += instead of assigning them.
3239 if test -n "$makefile_name"; then
3240 assign='+='
3241 else
3242 assign='='
3244 if test "$libtool" = true; then
3245 libext=la
3246 perhapsLT=LT
3247 sed_eliminate_LDFLAGS="$sed_noop"
3248 else
3249 libext=a
3250 perhapsLT=
3251 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3253 if $for_test; then
3254 # When creating a package for testing: Attempt to provoke failures,
3255 # especially link errors, already during "make" rather than during
3256 # "make check", because "make check" is not possible in a cross-compiling
3257 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3258 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3259 else
3260 sed_transform_check_PROGRAMS="$sed_noop"
3262 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3263 echo "## Process this file with automake to produce Makefile.in."
3264 func_emit_copyright_notice
3265 if test -n "$actioncmd"; then
3266 # The maximum line length (excluding the terminating newline) of any file
3267 # that is to be preprocessed by config.status is 3070. config.status uses
3268 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
3269 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
3270 len=`echo "$actioncmd" | wc -c`
3271 if test -n "$len" && test "$len" -le 3000; then
3272 echo "# Reproduce by: $actioncmd"
3275 echo
3276 uses_subdirs=
3278 for module in $modules; do
3279 func_verify_nontests_module
3280 if test -n "$module"; then
3282 func_get_automake_snippet_conditional "$module" |
3283 LC_ALL=C \
3284 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3285 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3286 -e "$sed_eliminate_LDFLAGS" \
3287 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
3288 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3289 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3290 -e "$sed_transform_check_PROGRAMS" \
3291 -e "$sed_replace_include_guard_prefix"
3292 if test "$module" = 'alloca'; then
3293 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
3294 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3296 } > "$tmp"/amsnippet1
3298 func_get_automake_snippet_unconditional "$module" |
3299 LC_ALL=C sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
3300 } > "$tmp"/amsnippet2
3301 # Skip the contents if it's entirely empty.
3302 if grep '[^ ]' "$tmp"/amsnippet1 "$tmp"/amsnippet2 > /dev/null ; then
3303 echo "## begin gnulib module $module"
3304 echo
3305 if test "$cond_dependencies" = true; then
3306 if func_cond_module_p "$module"; then
3307 func_module_conditional_name "$module"
3308 echo "if $conditional"
3311 cat "$tmp"/amsnippet1
3312 if test "$cond_dependencies" = true; then
3313 if func_cond_module_p "$module"; then
3314 echo "endif"
3317 cat "$tmp"/amsnippet2
3318 echo "## end gnulib module $module"
3319 echo
3321 rm -f "$tmp"/amsnippet1 "$tmp"/amsnippet2
3322 # Test whether there are some source files in subdirectories.
3323 for f in `func_get_filelist "$module"`; do
3324 case $f in
3325 lib/*/*.c)
3326 uses_subdirs=yes
3327 break
3329 esac
3330 done
3332 done
3333 } > "$tmp"/allsnippets
3334 if test -z "$makefile_name"; then
3335 # If there are source files in subdirectories, prevent collision of the
3336 # object files (example: hash.c and libxml/hash.c).
3337 subdir_options=
3338 if test -n "$uses_subdirs"; then
3339 subdir_options=' subdir-objects'
3341 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
3343 echo
3344 if test -z "$makefile_name"; then
3345 echo "SUBDIRS ="
3346 echo "noinst_HEADERS ="
3347 echo "noinst_LIBRARIES ="
3348 echo "noinst_LTLIBRARIES ="
3349 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3350 # if you specify pkgdata_DATA to empty. This is a workaround.
3351 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
3352 echo "pkgdata_DATA ="
3354 echo "EXTRA_DIST ="
3355 echo "BUILT_SOURCES ="
3356 echo "SUFFIXES ="
3358 echo "MOSTLYCLEANFILES $assign core *.stackdump"
3359 if test -z "$makefile_name"; then
3360 echo "MOSTLYCLEANDIRS ="
3361 echo "CLEANFILES ="
3362 echo "DISTCLEANFILES ="
3363 echo "MAINTAINERCLEANFILES ="
3365 # Execute edits that apply to the Makefile.am being generated.
3366 edit=0
3367 while test $edit != $makefile_am_edits; do
3368 edit=`expr $edit + 1`
3369 eval dir=\"\$makefile_am_edit${edit}_dir\"
3370 eval var=\"\$makefile_am_edit${edit}_var\"
3371 eval val=\"\$makefile_am_edit${edit}_val\"
3372 if test -n "$var"; then
3373 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3374 echo "${var} += ${val}"
3375 eval "makefile_am_edit${edit}_var="
3378 done
3379 if test -n "$witness_c_macro"; then
3380 cppflags_part1=" -D$witness_c_macro=1"
3381 else
3382 cppflags_part1=
3384 if $for_test; then
3385 cppflags_part2=" -DGNULIB_STRICT_CHECKING=1"
3386 else
3387 cppflags_part2=
3389 if test -z "$makefile_name"; then
3390 echo
3391 echo "AM_CPPFLAGS =$cppflags_part1$cppflags_part2"
3392 echo "AM_CFLAGS ="
3393 else
3394 if test -n "$cppflags_part1$cppflags_part2"; then
3395 echo
3396 echo "AM_CPPFLAGS +=$cppflags_part1$cppflags_part2"
3399 echo
3400 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
3401 || { test -n "$makefile_name" \
3402 && test -f "$sourcebase/Makefile.am" \
3403 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
3404 }; then
3405 # One of the snippets or the user's Makefile.am already specifies an
3406 # installation location for the library. Don't confuse automake by saying
3407 # it should not be installed.
3409 else
3410 # By default, the generated library should not be installed.
3411 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
3413 echo
3414 echo "${libname}_${libext}_SOURCES ="
3415 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3416 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3417 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3418 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
3419 echo "EXTRA_${libname}_${libext}_SOURCES ="
3420 if test "$libtool" = true; then
3421 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
3422 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
3423 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
3424 # the link dependencies of all modules.
3425 for module in $modules; do
3426 func_verify_nontests_module
3427 if test -n "$module"; then
3428 func_get_link_directive "$module"
3430 done \
3431 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
3432 | LC_ALL=C sort -u \
3433 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
3435 echo
3436 if test -n "$pobase"; then
3437 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
3438 echo
3440 cat "$tmp"/allsnippets \
3441 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3442 echo
3443 echo "mostlyclean-local: mostlyclean-generic"
3444 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3445 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3446 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3447 echo " fi; \\"
3448 echo " done; \\"
3449 echo " :"
3450 rm -f "$tmp"/allsnippets
3453 # func_emit_po_Makevars
3454 # emits the contents of po/ makefile parameterization to standard output.
3455 # Input:
3456 # - local_gnulib_dir from --local-dir
3457 # - modcache true or false, from --cache-modules/--no-cache-modules
3458 # - sourcebase directory relative to destdir where to place source code
3459 # - pobase directory relative to destdir where to place *.po files
3460 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3461 func_emit_po_Makevars ()
3463 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3464 func_emit_copyright_notice
3465 echo
3466 echo "# Usually the message domain is the same as the package name."
3467 echo "# But here it has a '-gnulib' suffix."
3468 echo "DOMAIN = ${po_domain}-gnulib"
3469 echo
3470 echo "# These two variables depend on the location of this directory."
3471 echo "subdir = ${pobase}"
3472 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
3473 echo
3474 cat <<\EOF
3475 # These options get passed to xgettext.
3476 XGETTEXT_OPTIONS = \
3477 --keyword=_ --flag=_:1:pass-c-format \
3478 --keyword=N_ --flag=N_:1:pass-c-format \
3479 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
3480 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
3481 --flag=error:3:c-format --flag=error_at_line:5:c-format
3483 # This is the copyright holder that gets inserted into the header of the
3484 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
3485 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
3487 # This is the email address or URL to which the translators shall report
3488 # bugs in the untranslated strings:
3489 # - Strings which are not entire sentences, see the maintainer guidelines
3490 # in the GNU gettext documentation, section 'Preparing Strings'.
3491 # - Strings which use unclear terms or require additional context to be
3492 # understood.
3493 # - Strings which make invalid assumptions about notation of date, time or
3494 # money.
3495 # - Pluralisation problems.
3496 # - Incorrect English spelling.
3497 # - Incorrect formatting.
3498 # It can be your email address, or a mailing list address where translators
3499 # can write to without being subscribed, or the URL of a web page through
3500 # which the translators can contact you.
3501 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3503 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3504 # message catalogs shall be used. It is usually empty.
3505 EXTRA_LOCALE_CATEGORIES =
3507 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3508 # context. Possible values are "yes" and "no". Set this to yes if the
3509 # package uses functions taking also a message context, like pgettext(), or
3510 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3511 USE_MSGCTXT = no
3515 # func_emit_po_POTFILES_in
3516 # emits the file list to be passed to xgettext to standard output.
3517 # Input:
3518 # - local_gnulib_dir from --local-dir
3519 # - modcache true or false, from --cache-modules/--no-cache-modules
3520 # - sourcebase directory relative to destdir where to place source code
3521 # - files list of new files
3522 func_emit_po_POTFILES_in ()
3524 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3525 func_emit_copyright_notice
3526 echo
3527 echo "# List of files which contain translatable strings."
3528 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3531 # func_emit_tests_Makefile_am witness_macro
3532 # emits the contents of tests makefile to standard output.
3533 # Input:
3534 # - local_gnulib_dir from --local-dir
3535 # - modcache true or false, from --cache-modules/--no-cache-modules
3536 # - modules list of modules, including dependencies
3537 # - libname library name
3538 # - auxdir directory relative to destdir where to place build aux files
3539 # - makefile_name from --makefile-name
3540 # - libtool true if libtool will be used, false or blank otherwise
3541 # - sourcebase relative directory containing lib source code
3542 # - m4base relative directory containing autoconf macros
3543 # - testsbase relative directory containing unit test code
3544 # - macro_prefix prefix of gl_LIBOBJS macros to use
3545 # - witness_c_macro from --witness-c-macro
3546 # - for_test true if creating a package for testing, false otherwise
3547 # - single_configure true if a single configure file should be generated,
3548 # false for a separate configure file for the tests
3549 # - use_libtests true if a libtests.a should be built, false otherwise
3550 # - sed_replace_include_guard_prefix
3551 # sed expression for resolving ${gl_include_guard_prefix}
3552 # - destfile filename relative to destdir of makefile being generated
3553 # Input/Output:
3554 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3555 # list of edits to be done to Makefile.am variables
3556 # Output:
3557 # - uses_subdirs nonempty if object files in subdirs exist
3558 func_emit_tests_Makefile_am ()
3560 witness_macro="$1"
3561 if test "$libtool" = true; then
3562 libext=la
3563 sed_eliminate_LDFLAGS="$sed_noop"
3564 else
3565 libext=a
3566 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3568 if $for_test; then
3569 # When creating a package for testing: Attempt to provoke failures,
3570 # especially link errors, already during "make" rather than during
3571 # "make check", because "make check" is not possible in a cross-compiling
3572 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3573 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3574 else
3575 sed_transform_check_PROGRAMS="$sed_noop"
3577 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3578 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3579 echo "## Process this file with automake to produce Makefile.in."
3580 func_emit_copyright_notice
3581 echo
3582 uses_subdirs=
3584 for module in $modules; do
3585 if $for_test && ! $single_configure; then
3586 func_verify_tests_module
3587 else
3588 func_verify_module
3590 if test -n "$module"; then
3592 func_get_automake_snippet "$module" |
3593 LC_ALL=C \
3594 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3595 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3596 -e "$sed_eliminate_LDFLAGS" \
3597 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3598 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3599 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3600 -e "$sed_transform_check_PROGRAMS" \
3601 -e "$sed_replace_include_guard_prefix"
3602 if $use_libtests && test "$module" = 'alloca'; then
3603 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3604 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3606 } > "$tmp"/amsnippet
3607 # Skip the contents if it's entirely empty.
3608 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3609 # Mention long-running tests at the end.
3610 ofd=3
3611 for word in `func_get_status "$module"`; do
3612 if test "$word" = 'longrunning-test'; then
3613 ofd=4
3614 break
3616 done
3617 { echo "## begin gnulib module $module"
3618 echo
3619 cat "$tmp"/amsnippet
3620 echo "## end gnulib module $module"
3621 echo
3622 } >&$ofd
3624 rm -f "$tmp"/amsnippet
3625 # Test whether there are some source files in subdirectories.
3626 for f in `func_get_filelist "$module"`; do
3627 case $f in
3628 lib/*/*.c | tests/*/*.c)
3629 uses_subdirs=yes
3630 break
3632 esac
3633 done
3635 done
3636 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3637 # Generate dependencies here, since it eases the debugging of test failures.
3638 # If there are source files in subdirectories, prevent collision of the
3639 # object files (example: hash.c and libxml/hash.c).
3640 subdir_options=
3641 if test -n "$uses_subdirs"; then
3642 subdir_options=' subdir-objects'
3644 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
3645 echo
3646 if $for_test && ! $single_configure; then
3647 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3648 echo
3650 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3651 # variable is needed to avoid an error from automake:
3652 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3653 echo "SUBDIRS = ."
3654 echo "TESTS ="
3655 echo "XFAIL_TESTS ="
3656 echo "TESTS_ENVIRONMENT ="
3657 echo "noinst_PROGRAMS ="
3658 if ! $for_test; then
3659 echo "check_PROGRAMS ="
3661 echo "noinst_HEADERS ="
3662 echo "noinst_LIBRARIES ="
3663 if $use_libtests; then
3664 if $for_test; then
3665 echo "noinst_LIBRARIES += libtests.a"
3666 else
3667 echo "check_LIBRARIES = libtests.a"
3670 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3671 # if you specify pkgdata_DATA to empty. This is a workaround.
3672 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3673 echo "pkgdata_DATA ="
3675 echo "EXTRA_DIST ="
3676 echo "BUILT_SOURCES ="
3677 echo "SUFFIXES ="
3678 echo "MOSTLYCLEANFILES = core *.stackdump"
3679 echo "MOSTLYCLEANDIRS ="
3680 echo "CLEANFILES ="
3681 echo "DISTCLEANFILES ="
3682 echo "MAINTAINERCLEANFILES ="
3683 # Execute edits that apply to the Makefile.am being generated.
3684 edit=0
3685 while test $edit != $makefile_am_edits; do
3686 edit=`expr $edit + 1`
3687 eval dir=\"\$makefile_am_edit${edit}_dir\"
3688 eval var=\"\$makefile_am_edit${edit}_var\"
3689 eval val=\"\$makefile_am_edit${edit}_val\"
3690 if test -n "$var"; then
3691 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3692 echo "${var} += ${val}"
3693 eval "makefile_am_edit${edit}_var="
3696 done
3697 echo
3698 echo "AM_CPPFLAGS = \\"
3699 if $for_test; then
3700 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3702 if test -n "$witness_c_macro"; then
3703 echo " -D$witness_c_macro=1 \\"
3705 if test -n "${witness_macro}"; then
3706 echo " -D@${witness_macro}@=1 \\"
3708 echo " -I. -I\$(srcdir) \\"
3709 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3710 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3711 echo
3712 local_ldadd_before=''
3713 local_ldadd_after=''
3714 if $use_libtests; then
3715 # All test programs need to be linked with libtests.a.
3716 # It needs to be passed to the linker before ${libname}.${libext}, since
3717 # the tests-related modules depend on the main modules.
3718 # It also needs to be passed to the linker after ${libname}.${libext}
3719 # because the latter might contain incomplete modules (such as the 'error'
3720 # module whose dependency to 'progname' is voluntarily omitted).
3721 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3722 # not matter.
3723 local_ldadd_before=' libtests.a'
3724 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3726 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3727 echo
3728 if $use_libtests; then
3729 echo "libtests_a_SOURCES ="
3730 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3731 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3732 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3733 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3734 echo "EXTRA_libtests_a_SOURCES ="
3735 # The circular dependency in LDADD requires this.
3736 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3737 echo
3739 # Many test scripts use ${EXEEXT} or ${srcdir}.
3740 # EXEEXT is defined by AC_PROG_CC through autoconf.
3741 # srcdir is defined by autoconf and automake.
3742 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3743 echo
3744 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3745 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3746 echo "# Clean up after Solaris cc."
3747 echo "clean-local:"
3748 echo " rm -rf SunWS_cache"
3749 echo
3750 echo "mostlyclean-local: mostlyclean-generic"
3751 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3752 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3753 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3754 echo " fi; \\"
3755 echo " done; \\"
3756 echo " :"
3757 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3760 # func_emit_initmacro_start macro_prefix
3761 # emits the first few statements of the gl_INIT macro to standard output.
3762 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3763 func_emit_initmacro_start ()
3765 macro_prefix_arg="$1"
3766 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3767 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3768 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3769 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3770 # flexibility.)
3771 # Furthermore it avoids an automake error like this when a Makefile.am
3772 # that uses pieces of gnulib also uses $(LIBOBJ):
3773 # automatically discovered file `error.c' should not be explicitly mentioned
3774 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3775 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3776 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3777 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3778 # automatically discovered file `error.c' should not be explicitly mentioned
3779 # We let automake know about the files to be distributed through the
3780 # EXTRA_lib_SOURCES variable.
3781 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3782 # Create data variables for checking the presence of files that are mentioned
3783 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3784 # because we want the check to happen when the configure file is created,
3785 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3786 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3787 # in which to expect them.
3788 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3789 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3790 echo " gl_COMMON"
3793 # func_emit_initmacro_end macro_prefix
3794 # emits the last few statements of the gl_INIT macro to standard output.
3795 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3796 func_emit_initmacro_end ()
3798 macro_prefix_arg="$1"
3799 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3800 # The check is performed only when autoconf is run from the directory where
3801 # the configure.ac resides; if it is run from a different directory, the
3802 # check is skipped.
3803 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3804 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3805 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3806 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3807 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3808 echo " exit 1"
3809 echo " fi"
3810 echo " done])dnl"
3811 echo " m4_if(m4_sysval, [0], [],"
3812 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3813 echo " ])"
3814 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3815 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3816 echo " m4_popdef([AC_LIBSOURCES])"
3817 echo " m4_popdef([AC_REPLACE_FUNCS])"
3818 echo " m4_popdef([AC_LIBOBJ])"
3819 echo " AC_CONFIG_COMMANDS_PRE(["
3820 echo " ${macro_prefix_arg}_libobjs="
3821 echo " ${macro_prefix_arg}_ltlibobjs="
3822 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3823 echo " # Remove the extension."
3824 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3825 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3826 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3827 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3828 echo " done"
3829 echo " fi"
3830 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3831 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3832 echo " ])"
3835 # func_emit_initmacro_done macro_prefix sourcebase
3836 # emits a few statements after the gl_INIT macro to standard output.
3837 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3838 # - sourcebase directory relative to destdir where to place source code
3839 func_emit_initmacro_done ()
3841 macro_prefix_arg="$1"
3842 sourcebase_arg="$2"
3843 echo
3844 echo "# Like AC_LIBOBJ, except that the module name goes"
3845 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3846 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3847 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3848 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3849 echo "])"
3850 echo
3851 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3852 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3853 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3854 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3855 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3856 echo "])"
3857 echo
3858 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3859 echo "# expected is derived from the gnulib-tool parameterization,"
3860 echo "# and alloca is special cased (for the alloca-opt module)."
3861 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3862 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3863 echo " m4_foreach([_gl_NAME], [\$1], ["
3864 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3865 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3866 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3867 echo " ])"
3868 echo " ])"
3869 echo "])"
3872 # func_emit_autoconf_snippet indentation
3873 # emits the autoconf snippet of a module.
3874 # Input:
3875 # - local_gnulib_dir from --local-dir
3876 # - modcache true or false, from --cache-modules/--no-cache-modules
3877 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3878 # - sed_replace_include_guard_prefix
3879 # sed expression for resolving ${gl_include_guard_prefix}
3880 # - module the module name
3881 # - toplevel true or false. 'false' means a subordinate use of
3882 # gnulib-tool.
3883 # - disable_libtool true or false. It tells whether to disable libtool
3884 # handling even if it has been specified through the
3885 # command line options.
3886 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3887 # invocations.
3888 # - indentation spaces to prepend on each line
3889 func_emit_autoconf_snippet ()
3891 if { case $module in
3892 gnumakefile | maintainer-makefile)
3893 # These modules are meant to be used only in the top-level directory.
3894 $toplevel ;;
3896 true ;;
3897 esac
3898 }; then
3899 func_get_autoconf_snippet "$module" \
3900 | sed -e '/^$/d;' -e "s/^/$indentation/" \
3901 -e "$sed_replace_build_aux" \
3902 -e "$sed_replace_include_guard_prefix" \
3903 | { if $disable_libtool; then
3904 sed -e 's/\$gl_cond_libtool/false/g' \
3905 -e 's/gl_libdeps/gltests_libdeps/g' \
3906 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3907 else
3911 | { if $disable_gettext; then
3912 sed -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
3913 else
3917 if test "$module" = 'alloca' && test "$libtool" = true && ! $disable_libtool; then
3918 echo 'changequote(,)dnl'
3919 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3920 echo 'changequote([, ])dnl'
3921 echo 'AC_SUBST([LTALLOCA])'
3926 # func_emit_autoconf_snippets modules verifier toplevel disable_libtool disable_gettext
3927 # collects and emit the autoconf snippets of a set of modules.
3928 # Input:
3929 # - local_gnulib_dir from --local-dir
3930 # - modcache true or false, from --cache-modules/--no-cache-modules
3931 # - sed_replace_build_aux sed expression that replaces reference to build-aux
3932 # - sed_replace_include_guard_prefix
3933 # sed expression for resolving ${gl_include_guard_prefix}
3934 # - modules the list of modules.
3935 # - verifier one of func_verify_module, func_verify_nontests_module,
3936 # func_verify_tests_module. It selects the subset of
3937 # $modules to consider.
3938 # - toplevel true or false. 'false' means a subordinate use of
3939 # gnulib-tool.
3940 # - disable_libtool true or false. It tells whether to disable libtool
3941 # handling even if it has been specified through the
3942 # command line options.
3943 # - disable_gettext true or false. It tells whether to disable AM_GNU_GETTEXT
3944 # invocations.
3945 func_emit_autoconf_snippets ()
3947 verifier="$2"
3948 toplevel="$3"
3949 disable_libtool="$4"
3950 disable_gettext="$5"
3951 if test "$cond_dependencies" = true; then
3952 for m in $modules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/modules
3953 # Emit the autoconf code for the unconditional modules.
3954 for module in $1; do
3955 eval $verifier
3956 if test -n "$module"; then
3957 if func_cond_module_p "$module"; then
3959 else
3960 func_emit_autoconf_snippet " "
3963 done
3964 # Initialize the shell variables indicating that the modules are enabled.
3965 for module in $1; do
3966 eval $verifier
3967 if test -n "$module"; then
3968 if func_cond_module_p "$module"; then
3969 func_module_shellvar_name "$module"
3970 echo " $shellvar=false"
3973 done
3974 # Emit the autoconf code for the conditional modules, each in a separate
3975 # function. This makes it possible to support cycles among conditional
3976 # modules.
3977 for module in $1; do
3978 eval $verifier
3979 if test -n "$module"; then
3980 if func_cond_module_p "$module"; then
3981 func_module_shellfunc_name "$module"
3982 func_module_shellvar_name "$module"
3983 echo " $shellfunc ()"
3984 echo ' {'
3985 echo " if ! \$$shellvar; then"
3986 func_emit_autoconf_snippet " "
3987 echo " $shellvar=true"
3988 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
3989 # Intersect $deps with the modules list $1.
3990 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
3991 for dep in $deps; do
3992 if func_cond_module_p "$dep"; then
3993 func_module_shellfunc_name "$dep"
3994 func_cond_module_condition "$module" "$dep"
3995 if test "$condition" != true; then
3996 echo " if $condition; then"
3997 echo " $shellfunc"
3998 echo ' fi'
3999 else
4000 echo " $shellfunc"
4002 else
4003 # The autoconf code for $dep has already been emitted above and
4004 # therefore is already executed when this function is run.
4007 done
4008 echo ' fi'
4009 echo ' }'
4012 done
4013 # Emit the dependencies from the unconditional to the conditional modules.
4014 for module in $1; do
4015 eval $verifier
4016 if test -n "$module"; then
4017 if func_cond_module_p "$module"; then
4019 else
4020 deps=`func_get_dependencies $module | sed -e "$sed_dependencies_without_conditions"`
4021 # Intersect $deps with the modules list $1.
4022 deps=`for m in $deps; do echo $m; done | LC_ALL=C sort -u | LC_ALL=C join - "$tmp"/modules`
4023 for dep in $deps; do
4024 if func_cond_module_p "$dep"; then
4025 func_module_shellfunc_name "$dep"
4026 func_cond_module_condition "$module" "$dep"
4027 if test "$condition" != true; then
4028 echo " if $condition; then"
4029 echo " $shellfunc"
4030 echo ' fi'
4031 else
4032 echo " $shellfunc"
4034 else
4035 # The autoconf code for $dep has already been emitted above and
4036 # therefore is already executed when this code is run.
4039 done
4042 done
4043 # Define the Automake conditionals.
4044 echo " m4_pattern_allow([^${macro_prefix}_GNULIB_ENABLED_])"
4045 for module in $1; do
4046 eval $verifier
4047 if test -n "$module"; then
4048 if func_cond_module_p "$module"; then
4049 func_module_conditional_name "$module"
4050 func_module_shellvar_name "$module"
4051 echo " AM_CONDITIONAL([$conditional], [\$$shellvar])"
4054 done
4055 else
4056 # Ignore the conditions, and enable all modules unconditionally.
4057 for module in $1; do
4058 eval $verifier
4059 if test -n "$module"; then
4060 func_emit_autoconf_snippet " "
4062 done
4066 # func_import modules
4067 # Uses also the variables
4068 # - mode import or add-import or remove-import or update
4069 # - destdir target directory
4070 # - local_gnulib_dir from --local-dir
4071 # - modcache true or false, from --cache-modules/--no-cache-modules
4072 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
4073 # - libname library name
4074 # - supplied_libname true if --lib was given, blank otherwise
4075 # - sourcebase directory relative to destdir where to place source code
4076 # - m4base directory relative to destdir where to place *.m4 macros
4077 # - pobase directory relative to destdir where to place *.po files
4078 # - docbase directory relative to destdir where to place doc files
4079 # - testsbase directory relative to destdir where to place unit test code
4080 # - auxdir directory relative to destdir where to place build aux files
4081 # - inctests true if --with-tests was given, blank otherwise
4082 # - incobsolete true if --with-obsolete was given, blank otherwise
4083 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
4084 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
4085 # otherwise
4086 # - inc_privileged_tests true if --with-privileged-tests was given, blank
4087 # otherwise
4088 # - inc_unportable_tests true if --with-unportable-tests was given, blank
4089 # otherwise
4090 # - inc_all_tests true if --with-all-tests was given, blank otherwise
4091 # - avoidlist list of modules to avoid, from --avoid
4092 # - cond_dependencies true if --conditional-dependencies was given, false if
4093 # --no-conditional-dependencies was given, blank otherwise
4094 # - lgpl yes or a number if library's license shall be LGPL,
4095 # blank otherwise
4096 # - makefile_name from --makefile-name
4097 # - libtool true if --libtool was given, false if --no-libtool was
4098 # given, blank otherwise
4099 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
4100 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
4101 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
4102 # - witness_c_macro from --witness-c-macro
4103 # - vc_files true if --vc-files was given, false if --no-vc-files was
4104 # given, blank otherwise
4105 # - autoconf_minversion minimum supported autoconf version
4106 # - doit : if actions shall be executed, false if only to be printed
4107 # - symbolic true if files should be symlinked, copied otherwise
4108 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4109 # copied otherwise
4110 # - do_copyrights true if copyright notices in files should be replaced,
4111 # blank otherwise
4112 func_import ()
4114 # Get the cached settings.
4115 # In 'import' mode, we read them only for the purpose of knowing the old
4116 # installed file list, and don't use them as defaults.
4117 cached_local_gnulib_dir=
4118 cached_specified_modules=
4119 cached_incobsolete=
4120 cached_inc_cxx_tests=
4121 cached_inc_longrunning_tests=
4122 cached_inc_privileged_tests=
4123 cached_inc_unportable_tests=
4124 cached_inc_all_tests=
4125 cached_avoidlist=
4126 cached_sourcebase=
4127 cached_m4base=
4128 cached_pobase=
4129 cached_docbase=
4130 cached_testsbase=
4131 cached_inctests=
4132 cached_libname=
4133 cached_lgpl=
4134 cached_makefile_name=
4135 cached_cond_dependencies=
4136 cached_libtool=
4137 cached_macro_prefix=
4138 cached_po_domain=
4139 cached_witness_c_macro=
4140 cached_vc_files=
4141 cached_files=
4142 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4143 cached_libtool=false
4144 my_sed_traces='
4145 s,#.*$,,
4146 s,^dnl .*$,,
4147 s, dnl .*$,,
4148 /gl_LOCAL_DIR(/ {
4149 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
4151 /gl_MODULES(/ {
4154 s/)/)/
4159 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
4161 /gl_WITH_OBSOLETE/ {
4162 s,^.*$,cached_incobsolete=true,p
4164 /gl_WITH_CXX_TESTS/ {
4165 s,^.*$,cached_inc_cxx_tests=true,p
4167 /gl_WITH_LONGRUNNING_TESTS/ {
4168 s,^.*$,cached_inc_longrunning_tests=true,p
4170 /gl_WITH_PRIVILEGED_TESTS/ {
4171 s,^.*$,cached_inc_privileged_tests=true,p
4173 /gl_WITH_UNPORTABLE_TESTS/ {
4174 s,^.*$,cached_inc_unportable_tests=true,p
4176 /gl_WITH_ALL_TESTS/ {
4177 s,^.*$,cached_inc_all_tests=true,p
4179 /gl_AVOID(/ {
4180 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
4182 /gl_SOURCE_BASE(/ {
4183 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
4185 /gl_M4_BASE(/ {
4186 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
4188 /gl_PO_BASE(/ {
4189 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
4191 /gl_DOC_BASE(/ {
4192 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
4194 /gl_TESTS_BASE(/ {
4195 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
4197 /gl_WITH_TESTS/ {
4198 s,^.*$,cached_inctests=true,p
4200 /gl_LIB(/ {
4201 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
4203 /gl_LGPL(/ {
4204 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
4206 /gl_LGPL/ {
4207 s,^.*$,cached_lgpl=yes,p
4209 /gl_MAKEFILE_NAME(/ {
4210 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
4212 /gl_CONDITIONAL_DEPENDENCIES/ {
4213 s,^.*$,cached_cond_dependencies=true,p
4215 /gl_LIBTOOL/ {
4216 s,^.*$,cached_libtool=true,p
4218 /gl_MACRO_PREFIX(/ {
4219 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
4221 /gl_PO_DOMAIN(/ {
4222 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
4224 /gl_WITNESS_C_MACRO(/ {
4225 s,^.*gl_WITNESS_C_MACRO([[ ]*\([^]"$`\\)]*\).*$,cached_witness_c_macro="\1",p
4227 /gl_VC_FILES(/ {
4228 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
4230 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
4231 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4232 my_sed_traces='
4233 s,#.*$,,
4234 s,^dnl .*$,,
4235 s, dnl .*$,,
4236 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
4237 s,^.*$,cached_files=",p
4241 s,^\]).*$,",
4243 s,["$`\\],,g
4250 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
4254 if test "$mode" = import; then
4255 # In 'import' mode, the new set of specified modules overrides the cached
4256 # set of modules. Ignore the cached settings.
4257 specified_modules="$1"
4258 else
4259 # Merge the cached settings with the specified ones.
4260 # The m4base must be the same as expected from the pathname.
4261 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
4262 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
4264 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
4265 # is relative to $destdir, whereas the one we use is relative to . or absolute.
4266 if test -z "$local_gnulib_dir"; then
4267 if test -n "$cached_local_gnulib_dir"; then
4268 case "$destdir" in
4270 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
4272 case "$cached_local_gnulib_dir" in
4274 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
4276 func_relconcat "$destdir" "$cached_local_gnulib_dir"
4277 local_gnulib_dir="$relconcat" ;;
4278 esac ;;
4279 esac
4282 case $mode in
4283 add-import)
4284 # Append the cached and the specified module names. So that
4285 # "gnulib-tool --add-import foo" means to add the module foo.
4286 specified_modules="$cached_specified_modules $1"
4288 remove-import)
4289 # Take the cached module names, minus the specified module names.
4290 specified_modules=
4291 if $have_associative; then
4292 # Use an associative array, for O(N) worst-case run time.
4293 declare -A to_remove
4294 for m in $1; do
4295 eval 'to_remove[$m]=yes'
4296 done
4297 for module in $cached_specified_modules; do
4298 if eval 'test -z "${to_remove[$module]}"'; then
4299 func_append specified_modules "$module "
4301 done
4302 else
4303 # This loop has O(N²) worst-case run time.
4304 for module in $cached_specified_modules; do
4305 to_remove=
4306 for m in $1; do
4307 if test "$m" = "$module"; then
4308 to_remove=yes
4309 break
4311 done
4312 if test -z "$to_remove"; then
4313 func_append specified_modules "$module "
4315 done
4318 update)
4319 # Take the cached module names. There are no specified module names.
4320 specified_modules="$cached_specified_modules"
4322 esac
4323 # Included obsolete modules among the dependencies if specified either way.
4324 if test -z "$incobsolete"; then
4325 incobsolete="$cached_incobsolete"
4327 # Included special kinds of tests modules among the dependencies if specified
4328 # either way.
4329 if test -z "$inc_cxx_tests"; then
4330 inc_cxx_tests="$cached_inc_cxx_tests"
4332 if test -z "$inc_longrunning_tests"; then
4333 inc_longrunning_tests="$cached_inc_longrunning_tests"
4335 if test -z "$inc_privileged_tests"; then
4336 inc_privileged_tests="$cached_inc_privileged_tests"
4338 if test -z "$inc_unportable_tests"; then
4339 inc_unportable_tests="$cached_inc_unportable_tests"
4341 if test -z "$inc_all_tests"; then
4342 inc_all_tests="$cached_inc_all_tests"
4344 # Append the cached and the specified avoidlist. This is probably better
4345 # than dropping the cached one when --avoid is specified at least once.
4346 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
4347 avoidlist=`echo $avoidlist`
4349 # The sourcebase defaults to the cached one.
4350 if test -z "$sourcebase"; then
4351 sourcebase="$cached_sourcebase"
4352 if test -z "$sourcebase"; then
4353 func_fatal_error "missing --source-base option"
4356 # The pobase defaults to the cached one.
4357 if test -z "$pobase"; then
4358 pobase="$cached_pobase"
4360 # The docbase defaults to the cached one.
4361 if test -z "$docbase"; then
4362 docbase="$cached_docbase"
4363 if test -z "$docbase"; then
4364 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."
4367 # The testsbase defaults to the cached one.
4368 if test -z "$testsbase"; then
4369 testsbase="$cached_testsbase"
4370 if test -z "$testsbase"; then
4371 func_fatal_error "missing --tests-base option"
4374 # Require the tests if specified either way.
4375 if test -z "$inctests"; then
4376 inctests="$cached_inctests"
4378 # The libname defaults to the cached one.
4379 if test -z "$supplied_libname"; then
4380 libname="$cached_libname"
4381 if test -z "$libname"; then
4382 func_fatal_error "missing --lib option"
4385 # Require LGPL if specified either way.
4386 if test -z "$lgpl"; then
4387 lgpl="$cached_lgpl"
4389 # The makefile_name defaults to the cached one.
4390 if test -z "$makefile_name"; then
4391 makefile_name="$cached_makefile_name"
4393 # Use conditional dependencies if specified either way.
4394 if test -z "$cond_dependencies"; then
4395 cond_dependencies="$cached_cond_dependencies"
4397 # Use libtool if specified either way, or if guessed.
4398 if test -z "$libtool"; then
4399 if test -n "$cached_m4base"; then
4400 libtool="$cached_libtool"
4401 else
4402 libtool="$guessed_libtool"
4405 # The macro_prefix defaults to the cached one.
4406 if test -z "$macro_prefix"; then
4407 macro_prefix="$cached_macro_prefix"
4408 if test -z "$macro_prefix"; then
4409 func_fatal_error "missing --macro-prefix option"
4412 # The po_domain defaults to the cached one.
4413 if test -z "$po_domain"; then
4414 po_domain="$cached_po_domain"
4416 # The witness_c_macro defaults to the cached one.
4417 if test -z "$witness_c_macro"; then
4418 witness_c_macro="$cached_witness_c_macro"
4420 # The vc_files defaults to the cached one.
4421 if test -z "$vc_files"; then
4422 vc_files="$cached_vc_files"
4424 # Ensure constraints.
4425 if test "$cond_dependencies" = true && test -n "$inctests"; then
4426 echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
4427 func_exit 1
4430 # --without-*-tests options are not supported here.
4431 excl_cxx_tests=
4432 excl_longrunning_tests=
4433 excl_privileged_tests=
4434 excl_unportable_tests=
4436 # Canonicalize the list of specified modules.
4437 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4439 # Include all kinds of tests modules if --with-all-tests was specified.
4440 inc_all_direct_tests="$inc_all_tests"
4441 inc_all_indirect_tests="$inc_all_tests"
4443 # Determine final module list.
4444 modules="$specified_modules"
4445 func_modules_transitive_closure
4446 if test $verbose -ge 0; then
4447 func_show_module_list
4449 final_modules="$modules"
4451 # Determine main module list and tests-related module list separately.
4452 func_modules_transitive_closure_separately
4454 # Determine whether a $testsbase/libtests.a is needed.
4455 func_determine_use_libtests
4457 # Add the dummy module to the main module list or to the tests-related module
4458 # list if needed.
4459 func_modules_add_dummy_separately
4461 # If --lgpl, verify that the licenses of modules are compatible.
4462 if test -n "$lgpl"; then
4463 license_incompatibilities=
4464 for module in $main_modules; do
4465 license=`func_get_license $module`
4466 case $license in
4467 'GPLed build tool') ;;
4468 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4470 case "$lgpl" in
4471 yes | 3)
4472 case $license in
4473 LGPL | LGPLv2+ | LGPLv3+) ;;
4474 *) func_append license_incompatibilities "$module $license$nl" ;;
4475 esac
4478 case $license in
4479 LGPLv2+) ;;
4480 *) func_append license_incompatibilities "$module $license$nl" ;;
4481 esac
4483 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4484 esac
4486 esac
4487 done
4488 if test -n "$license_incompatibilities"; then
4489 # Format the license incompatibilities as a table.
4490 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
4491 s,^\(.................................................[^ ]*\) *, \1 ,'
4492 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
4493 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
4497 # Show banner notice of every module.
4498 modules="$main_modules"
4499 func_modules_notice
4501 # Determine script to apply to imported library files.
4502 sed_transform_lib_file=
4503 for module in $main_modules; do
4504 if test $module = config-h; then
4505 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
4506 sed_transform_lib_file=$sed_transform_lib_file'
4507 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
4509 break
4511 done
4512 sed_transform_main_lib_file="$sed_transform_lib_file"
4513 if test -n "$do_copyrights"; then
4514 if test -n "$lgpl"; then
4515 # Update license.
4516 case "$lgpl" in
4517 yes | 3)
4518 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4519 s/GNU General/GNU Lesser General/g
4520 s/General Public License/Lesser General Public License/g
4521 s/Lesser Lesser General Public License/Lesser General Public License/g
4525 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4526 s/GNU General/GNU Lesser General/g
4527 s/General Public License/Lesser General Public License/g
4528 s/Lesser Lesser General Public License/Lesser General Public License/g
4530 s/version [23]\([ ,]\)/version 2.1\1/g
4533 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
4534 esac
4535 else
4536 # Update license.
4537 sed_transform_main_lib_file=$sed_transform_main_lib_file'
4538 s/GNU Lesser General/GNU General/g
4539 s/Lesser General Public License/General Public License/g
4541 s/GNU Library General/GNU General/g
4542 s/Library General Public License/General Public License/g
4544 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4549 # Determine script to apply to auxiliary files that go into $auxdir/.
4550 sed_transform_build_aux_file=
4551 if test -n "$do_copyrights"; then
4552 # Update license.
4553 sed_transform_build_aux_file=$sed_transform_build_aux_file'
4554 s/GNU Lesser General/GNU General/g
4555 s/Lesser General Public License/General Public License/g
4557 s/GNU Library General/GNU General/g
4558 s/Library General Public License/General Public License/g
4560 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4564 # Determine script to apply to library files that go into $testsbase/.
4565 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
4566 if test -n "$do_copyrights"; then
4567 # Update license.
4568 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
4569 s/GNU Lesser General/GNU General/g
4570 s/Lesser General Public License/General Public License/g
4572 s/GNU Library General/GNU General/g
4573 s/Library General Public License/General Public License/g
4575 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
4579 # Determine the final file lists.
4580 func_modules_to_filelist_separately
4582 test -n "$files" \
4583 || func_fatal_error "refusing to do nothing"
4585 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
4586 new_files="$files m4/gnulib-tool.m4"
4587 old_files="$cached_files"
4588 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
4589 func_append old_files " m4/gnulib-tool.m4"
4592 rewritten='%REWRITTEN%'
4593 sed_rewrite_old_files="\
4594 s,^build-aux/,$rewritten$auxdir/,
4595 s,^doc/,$rewritten$cached_docbase/,
4596 s,^lib/,$rewritten$cached_sourcebase/,
4597 s,^m4/,$rewritten$cached_m4base/,
4598 s,^tests/,$rewritten$cached_testsbase/,
4599 s,^tests=lib/,$rewritten$cached_testsbase/,
4600 s,^top/,$rewritten,
4601 s,^$rewritten,,"
4602 sed_rewrite_new_files="\
4603 s,^build-aux/,$rewritten$auxdir/,
4604 s,^doc/,$rewritten$docbase/,
4605 s,^lib/,$rewritten$sourcebase/,
4606 s,^m4/,$rewritten$m4base/,
4607 s,^tests/,$rewritten$testsbase/,
4608 s,^tests=lib/,$rewritten$testsbase/,
4609 s,^top/,$rewritten,
4610 s,^$rewritten,,"
4612 # Create directories.
4613 { echo "$sourcebase"
4614 echo "$m4base"
4615 if test -n "$pobase"; then
4616 echo "$pobase"
4618 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
4619 if test -n "$docfiles"; then
4620 echo "$docbase"
4622 if test -n "$inctests"; then
4623 echo "$testsbase"
4625 echo "$auxdir"
4626 for f in $files; do echo $f; done \
4627 | sed -e "$sed_rewrite_new_files" \
4628 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4629 | LC_ALL=C sort -u
4630 } > "$tmp"/dirs
4631 { # Rearrange file descriptors. Needed because "while ... done < ..."
4632 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4633 exec 5<&0 < "$tmp"/dirs
4634 while read d; do
4635 if test ! -d "$destdir/$d"; then
4636 if $doit; then
4637 echo "Creating directory $destdir/$d"
4638 mkdir -p "$destdir/$d" || func_fatal_error "failed"
4639 else
4640 echo "Create directory $destdir/$d"
4643 done
4644 exec 0<&5 5<&-
4647 # Copy files or make symbolic links. Remove obsolete files.
4648 added_files=''
4649 removed_files=''
4650 delimiter=' '
4651 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4652 # representing the files according to the last gnulib-tool invocation.
4653 for f in $old_files; do echo $f; done \
4654 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
4655 | LC_ALL=C sort \
4656 > "$tmp"/old-files
4657 # Construct a table with 2 columns: rewritten-file-name original-file-name,
4658 # representing the files after this gnulib-tool invocation.
4659 for f in $new_files; do echo $f; done \
4660 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
4661 | LC_ALL=C sort \
4662 > "$tmp"/new-files
4663 # First the files that are in old-files, but not in new-files:
4664 sed_take_first_column='s,'"$delimiter"'.*,,'
4665 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
4666 # Remove the file. Do nothing if the user already removed it.
4667 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
4668 if $doit; then
4669 echo "Removing file $g (backup in ${g}~)"
4670 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
4671 else
4672 echo "Remove file $g (backup in ${g}~)"
4674 func_append removed_files "$g$nl"
4676 done
4677 # func_add_or_update handles a file that ought to be present afterwards.
4678 # Uses parameters
4679 # - f the original file name
4680 # - g the rewritten file name
4681 # - already_present nonempty if the file should already exist, empty
4682 # otherwise
4683 func_add_or_update ()
4685 of="$f"
4686 case "$f" in
4687 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
4688 esac
4689 func_dest_tmpfilename "$g"
4690 func_lookup_file "$f"
4691 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4692 if test -n "$sed_transform_main_lib_file"; then
4693 case "$of" in
4694 lib/*)
4695 sed -e "$sed_transform_main_lib_file" \
4696 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4698 esac
4700 if test -n "$sed_transform_build_aux_file"; then
4701 case "$of" in
4702 build-aux/*)
4703 sed -e "$sed_transform_build_aux_file" \
4704 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4706 esac
4708 if test -n "$sed_transform_testsrelated_lib_file"; then
4709 case "$of" in
4710 tests=lib/*)
4711 sed -e "$sed_transform_testsrelated_lib_file" \
4712 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4714 esac
4716 if test -f "$destdir/$g"; then
4717 # The file already exists.
4718 func_update_file
4719 else
4720 # Install the file.
4721 # Don't protest if the file should be there but isn't: it happens
4722 # frequently that developers don't put autogenerated files under version control.
4723 func_add_file
4724 func_append added_files "$g$nl"
4726 rm -f "$tmpfile"
4728 # Then the files that are in new-files, but not in old-files:
4729 sed_take_last_column='s,^.*'"$delimiter"',,'
4730 already_present=
4731 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
4732 | sed -e "$sed_take_last_column" \
4733 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
4734 { # Rearrange file descriptors. Needed because "while ... done < ..."
4735 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4736 exec 5<&0 < "$tmp"/added-files
4737 while read g f; do
4738 func_add_or_update
4739 done
4740 exec 0<&5 5<&-
4742 # Then the files that are in new-files and in old-files:
4743 already_present=true
4744 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
4745 | sed -e "$sed_take_last_column" \
4746 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
4747 { # Rearrange file descriptors. Needed because "while ... done < ..."
4748 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4749 exec 5<&0 < "$tmp"/kept-files
4750 while read g f; do
4751 func_add_or_update
4752 done
4753 exec 0<&5 5<&-
4756 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
4757 actioncmd="gnulib-tool --import"
4758 func_append actioncmd " --dir=$destdir"
4759 if test -n "$local_gnulib_dir"; then
4760 func_append actioncmd " --local-dir=$local_gnulib_dir"
4762 func_append actioncmd " --lib=$libname"
4763 func_append actioncmd " --source-base=$sourcebase"
4764 func_append actioncmd " --m4-base=$m4base"
4765 if test -n "$pobase"; then
4766 func_append actioncmd " --po-base=$pobase"
4768 func_append actioncmd " --doc-base=$docbase"
4769 func_append actioncmd " --tests-base=$testsbase"
4770 func_append actioncmd " --aux-dir=$auxdir"
4771 if test -n "$inctests"; then
4772 func_append actioncmd " --with-tests"
4774 if test -n "$incobsolete"; then
4775 func_append actioncmd " --with-obsolete"
4777 if test -n "$inc_cxx_tests"; then
4778 func_append actioncmd " --with-c++-tests"
4780 if test -n "$inc_longrunning_tests"; then
4781 func_append actioncmd " --with-longrunning-tests"
4783 if test -n "$inc_privileged_tests"; then
4784 func_append actioncmd " --with-privileged-tests"
4786 if test -n "$inc_unportable_tests"; then
4787 func_append actioncmd " --with-unportable-tests"
4789 if test -n "$inc_all_tests"; then
4790 func_append actioncmd " --with-all-tests"
4792 for module in $avoidlist; do
4793 func_append actioncmd " --avoid=$module"
4794 done
4795 if test -n "$lgpl"; then
4796 if test "$lgpl" = yes; then
4797 func_append actioncmd " --lgpl"
4798 else
4799 func_append actioncmd " --lgpl=$lgpl"
4802 if test -n "$makefile_name"; then
4803 func_append actioncmd " --makefile-name=$makefile_name"
4805 if test "$cond_dependencies" = true; then
4806 func_append actioncmd " --conditional-dependencies"
4807 else
4808 func_append actioncmd " --no-conditional-dependencies"
4810 if test "$libtool" = true; then
4811 func_append actioncmd " --libtool"
4812 else
4813 func_append actioncmd " --no-libtool"
4815 func_append actioncmd " --macro-prefix=$macro_prefix"
4816 if test -n "$po_domain"; then
4817 func_append actioncmd " --po-domain=$po_domain"
4819 if test -n "$witness_c_macro"; then
4820 func_append actioncmd " --witness-c-macro=$witness_c_macro"
4822 if test -n "$vc_files"; then
4823 if test "$vc_files" = true; then
4824 func_append actioncmd " --vc-files"
4825 else
4826 func_append actioncmd " --no-vc-files"
4829 func_append actioncmd " `echo $specified_modules`"
4831 # Determine include_guard_prefix.
4832 func_compute_include_guard_prefix
4834 # Default the makefile name to Makefile.am.
4835 if test -n "$makefile_name"; then
4836 makefile_am=$makefile_name
4837 else
4838 makefile_am=Makefile.am
4841 # Create normal Makefile.ams.
4842 for_test=false
4844 # Setup list of Makefile.am edits that are to be performed afterwards.
4845 # Some of these edits apply to files that we will generate; others are
4846 # under the responsibility of the developer.
4847 makefile_am_edits=0
4848 # func_note_Makefile_am_edit dir var value
4849 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
4850 # ${value}.
4851 func_note_Makefile_am_edit ()
4853 makefile_am_edits=`expr $makefile_am_edits + 1`
4854 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
4855 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
4856 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
4858 if test "$makefile_am" = Makefile.am; then
4859 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
4860 sourcebase_base=`basename "$sourcebase"`
4861 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
4863 if test -n "$pobase"; then
4864 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
4865 pobase_base=`basename "$pobase"`
4866 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4868 if test -n "$inctests"; then
4869 if test "$makefile_am" = Makefile.am; then
4870 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4871 testsbase_base=`basename "$testsbase"`
4872 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4875 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4877 # Find the first parent directory of $m4base that contains or will contain
4878 # a Makefile.am.
4879 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4880 s,//*$,/,'
4881 sed_butlast='s,[^/][^/]*//*$,,'
4882 dir1="${m4base}/"; dir2=""
4883 while test -n "$dir1" \
4884 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4885 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4886 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4887 || { test -n "$inctests" \
4888 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4889 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4890 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4891 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4892 done
4893 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4896 # Create library makefile.
4897 func_dest_tmpfilename $sourcebase/$makefile_am
4898 destfile="$sourcebase/$makefile_am"
4899 modules="$main_modules"
4900 func_emit_lib_Makefile_am > "$tmpfile"
4901 if test -f "$destdir"/$sourcebase/$makefile_am; then
4902 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
4903 rm -f "$tmpfile"
4904 else
4905 if $doit; then
4906 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4907 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4908 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4909 else
4910 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4911 rm -f "$tmpfile"
4914 else
4915 if $doit; then
4916 echo "Creating $sourcebase/$makefile_am"
4917 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4918 else
4919 echo "Create $sourcebase/$makefile_am"
4920 rm -f "$tmpfile"
4922 func_append added_files "$sourcebase/$makefile_am$nl"
4925 # Create po/ directory.
4926 if test -n "$pobase"; then
4927 # Create po makefile and auxiliary files.
4928 for file in Makefile.in.in remove-potcdate.sin; do
4929 func_dest_tmpfilename $pobase/$file
4930 func_lookup_file build-aux/po/$file
4931 cat "$lookedup_file" > "$tmpfile"
4932 if test -f "$destdir"/$pobase/$file; then
4933 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
4934 rm -f "$tmpfile"
4935 else
4936 if $doit; then
4937 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4938 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4939 mv -f "$tmpfile" "$destdir"/$pobase/$file
4940 else
4941 echo "Update $pobase/$file (backup in $pobase/$file~)"
4942 rm -f "$tmpfile"
4945 else
4946 if $doit; then
4947 echo "Creating $pobase/$file"
4948 mv -f "$tmpfile" "$destdir"/$pobase/$file
4949 else
4950 echo "Create $pobase/$file"
4951 rm -f "$tmpfile"
4953 func_append added_files "$pobase/$file$nl"
4955 done
4956 # Create po makefile parameterization, part 1.
4957 func_dest_tmpfilename $pobase/Makevars
4958 func_emit_po_Makevars > "$tmpfile"
4959 if test -f "$destdir"/$pobase/Makevars; then
4960 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
4961 rm -f "$tmpfile"
4962 else
4963 if $doit; then
4964 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4965 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4966 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4967 else
4968 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4969 rm -f "$tmpfile"
4972 else
4973 if $doit; then
4974 echo "Creating $pobase/Makevars"
4975 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4976 else
4977 echo "Create $pobase/Makevars"
4978 rm -f "$tmpfile"
4980 func_append added_files "$pobase/Makevars$nl"
4982 # Create po makefile parameterization, part 2.
4983 func_dest_tmpfilename $pobase/POTFILES.in
4984 func_emit_po_POTFILES_in > "$tmpfile"
4985 if test -f "$destdir"/$pobase/POTFILES.in; then
4986 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
4987 rm -f "$tmpfile"
4988 else
4989 if $doit; then
4990 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4991 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
4992 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4993 else
4994 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4995 rm -f "$tmpfile"
4998 else
4999 if $doit; then
5000 echo "Creating $pobase/POTFILES.in"
5001 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
5002 else
5003 echo "Create $pobase/POTFILES.in"
5004 rm -f "$tmpfile"
5006 func_append added_files "$pobase/POTFILES.in$nl"
5008 # Fetch PO files.
5009 TP_URL="http://translationproject.org/latest/"
5010 TP_RSYNC_URI="translationproject.org::tp/latest/"
5011 if $doit; then
5012 echo "Fetching gnulib PO files from $TP_URL"
5013 (cd "$destdir"/$pobase \
5014 && { # Prefer rsync over wget if it is available, since it consumes
5015 # less network bandwidth, due to compression.
5016 if type rsync 2>/dev/null | grep / > /dev/null; then
5017 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
5018 else
5019 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
5023 else
5024 echo "Fetch gnulib PO files from $TP_URL"
5026 # Create po/LINGUAS.
5027 if $doit; then
5028 func_dest_tmpfilename $pobase/LINGUAS
5029 (cd "$destdir"/$pobase \
5030 && { echo '# Set of available languages.'
5031 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
5033 ) > "$tmpfile"
5034 if test -f "$destdir"/$pobase/LINGUAS; then
5035 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
5036 rm -f "$tmpfile"
5037 else
5038 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5039 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
5040 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5042 else
5043 echo "Creating $pobase/LINGUAS"
5044 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
5045 func_append added_files "$pobase/LINGUAS$nl"
5047 else
5048 if test -f "$destdir"/$pobase/LINGUAS; then
5049 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
5050 else
5051 echo "Create $pobase/LINGUAS"
5056 # Create m4/gnulib-cache.m4.
5057 func_dest_tmpfilename $m4base/gnulib-cache.m4
5059 func_emit_copyright_notice
5060 echo "#"
5061 echo "# This file represents the specification of how gnulib-tool is used."
5062 echo "# It acts as a cache: It is written and read by gnulib-tool."
5063 echo "# In projects that use version control, this file is meant to be put under"
5064 echo "# version control, like the configure.ac and various Makefile.am files."
5065 echo
5066 echo
5067 echo "# Specification in the form of a command-line invocation:"
5068 echo "# $actioncmd"
5069 echo
5070 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
5071 # Store the local_gnulib_dir relative to destdir.
5072 case "$local_gnulib_dir" in
5073 "" | /*)
5074 relative_local_gnulib_dir="$local_gnulib_dir" ;;
5076 case "$destdir" in
5077 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
5079 # destdir, local_gnulib_dir are both relative.
5080 func_relativize "$destdir" "$local_gnulib_dir"
5081 relative_local_gnulib_dir="$reldir" ;;
5082 esac ;;
5083 esac
5084 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
5085 echo "gl_MODULES(["
5086 echo "$specified_modules" | sed -e 's/^/ /g'
5087 echo "])"
5088 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
5089 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
5090 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
5091 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
5092 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
5093 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
5094 echo "gl_AVOID([$avoidlist])"
5095 echo "gl_SOURCE_BASE([$sourcebase])"
5096 echo "gl_M4_BASE([$m4base])"
5097 echo "gl_PO_BASE([$pobase])"
5098 echo "gl_DOC_BASE([$docbase])"
5099 echo "gl_TESTS_BASE([$testsbase])"
5100 test -z "$inctests" || echo "gl_WITH_TESTS"
5101 echo "gl_LIB([$libname])"
5102 if test -n "$lgpl"; then
5103 if test "$lgpl" = yes; then
5104 echo "gl_LGPL"
5105 else
5106 echo "gl_LGPL([$lgpl])"
5109 echo "gl_MAKEFILE_NAME([$makefile_name])"
5110 if test "$cond_dependencies" = true; then
5111 echo "gl_CONDITIONAL_DEPENDENCIES"
5113 if test "$libtool" = true; then
5114 echo "gl_LIBTOOL"
5116 echo "gl_MACRO_PREFIX([$macro_prefix])"
5117 echo "gl_PO_DOMAIN([$po_domain])"
5118 echo "gl_WITNESS_C_DOMAIN([$witness_c_macro])"
5119 if test -n "$vc_files"; then
5120 echo "gl_VC_FILES([$vc_files])"
5122 ) > "$tmpfile"
5123 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
5124 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
5125 rm -f "$tmpfile"
5126 else
5127 if $doit; then
5128 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5129 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
5130 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5131 else
5132 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
5133 if false; then
5134 cat "$tmpfile"
5135 echo
5136 echo "# gnulib-cache.m4 ends here"
5138 rm -f "$tmpfile"
5141 else
5142 if $doit; then
5143 echo "Creating $m4base/gnulib-cache.m4"
5144 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
5145 else
5146 echo "Create $m4base/gnulib-cache.m4"
5147 cat "$tmpfile"
5148 rm -f "$tmpfile"
5152 # Create m4/gnulib-comp.m4.
5153 func_dest_tmpfilename $m4base/gnulib-comp.m4
5155 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
5156 func_emit_copyright_notice
5157 echo "#"
5158 echo "# This file represents the compiled summary of the specification in"
5159 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
5160 echo "# to be invoked from configure.ac."
5161 echo "# In projects that use version control, this file can be treated like"
5162 echo "# other built files."
5163 echo
5164 echo
5165 echo "# This macro should be invoked from $configure_ac, in the section"
5166 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
5167 echo "# any checks for libraries, header files, types and library functions."
5168 echo "AC_DEFUN([${macro_prefix}_EARLY],"
5169 echo "["
5170 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5171 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5172 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5173 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5174 echo " AC_REQUIRE([gl_PROG_AR_RANLIB])"
5175 if test -n "$uses_subdirs"; then
5176 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
5178 for module in $final_modules; do
5179 func_verify_module
5180 if test -n "$module"; then
5181 echo "# Code from module $module:"
5182 func_get_autoconf_early_snippet "$module"
5184 done \
5185 | sed -e '/^$/d;' -e 's/^/ /'
5186 echo "])"
5187 echo
5188 echo "# This macro should be invoked from $configure_ac, in the section"
5189 echo "# \"Check for header files, types and library functions\"."
5190 echo "AC_DEFUN([${macro_prefix}_INIT],"
5191 echo "["
5192 if test "$libtool" = true; then
5193 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5194 echo " gl_cond_libtool=true"
5195 else
5196 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5197 echo " gl_cond_libtool=false"
5198 echo " gl_libdeps="
5199 echo " gl_ltlibdeps="
5201 if test "$auxdir" != "build-aux"; then
5202 sed_replace_build_aux='
5204 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5205 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5208 else
5209 sed_replace_build_aux="$sed_noop"
5211 echo " gl_m4_base='$m4base'"
5212 func_emit_initmacro_start $macro_prefix
5213 echo " gl_source_base='$sourcebase'"
5214 if test -n "$witness_c_macro"; then
5215 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
5217 func_emit_autoconf_snippets "$main_modules" func_verify_module true false true
5218 if test -n "$witness_c_macro"; then
5219 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5221 echo " # End of code from modules"
5222 func_emit_initmacro_end $macro_prefix
5223 echo " gltests_libdeps="
5224 echo " gltests_ltlibdeps="
5225 func_emit_initmacro_start ${macro_prefix}tests
5226 echo " gl_source_base='$testsbase'"
5227 # Define a tests witness macro that depends on the package.
5228 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
5229 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
5230 echo "changequote(,)dnl"
5231 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"
5232 echo "changequote([, ])dnl"
5233 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5234 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5235 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5236 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true true true
5237 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5238 func_emit_initmacro_end ${macro_prefix}tests
5239 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5240 # created using libtool, because libtool already handles the dependencies.
5241 if test "$libtool" != true; then
5242 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5243 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5244 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5245 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5246 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5248 if $use_libtests; then
5249 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5250 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5252 echo "])"
5253 func_emit_initmacro_done $macro_prefix $sourcebase
5254 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5255 echo
5256 echo "# This macro records the list of files which have been installed by"
5257 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
5258 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
5259 echo "$files" | sed -e 's,^, ,'
5260 echo "])"
5261 ) > "$tmpfile"
5262 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
5263 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
5264 rm -f "$tmpfile"
5265 else
5266 if $doit; then
5267 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5268 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
5269 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5270 else
5271 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
5272 if false; then
5273 cat "$tmpfile"
5274 echo
5275 echo "# gnulib-comp.m4 ends here"
5277 rm -f "$tmpfile"
5280 else
5281 if $doit; then
5282 echo "Creating $m4base/gnulib-comp.m4"
5283 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
5284 else
5285 echo "Create $m4base/gnulib-comp.m4"
5286 cat "$tmpfile"
5287 rm -f "$tmpfile"
5291 if test -n "$inctests"; then
5292 # Create tests makefile.
5293 func_dest_tmpfilename $testsbase/$makefile_am
5294 destfile="$testsbase/$makefile_am"
5295 modules="$testsrelated_modules"
5296 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
5297 if test -f "$destdir"/$testsbase/$makefile_am; then
5298 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
5299 rm -f "$tmpfile"
5300 else
5301 if $doit; then
5302 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5303 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
5304 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5305 else
5306 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
5307 rm -f "$tmpfile"
5310 else
5311 if $doit; then
5312 echo "Creating $testsbase/$makefile_am"
5313 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
5314 else
5315 echo "Create $testsbase/$makefile_am"
5316 rm -f "$tmpfile"
5318 func_append added_files "$testsbase/$makefile_am$nl"
5322 if test "$vc_files" != false; then
5323 # Update the .cvsignore and .gitignore files.
5324 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
5325 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
5326 # Treat gnulib-comp.m4 like an added file, even if it already existed.
5327 echo "$m4base/|A|gnulib-comp.m4"
5328 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
5329 { # Rearrange file descriptors. Needed because "while ... done < ..."
5330 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5331 exec 5<&0 < "$tmp"/fileset-changes
5332 func_update_ignorelist ()
5334 ignore="$1"
5335 if test "$ignore" = .gitignore; then
5336 # In a .gitignore file, "foo" applies to the current directory and all
5337 # subdirectories, whereas "/foo" applies to the current directory only.
5338 anchor='/'
5339 escaped_anchor='\/'
5340 doubly_escaped_anchor='\\/'
5341 else
5342 anchor=''
5343 escaped_anchor=''
5344 doubly_escaped_anchor=''
5346 if test -f "$destdir/$dir$ignore"; then
5347 if test -n "$dir_added" || test -n "$dir_removed"; then
5348 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
5349 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
5350 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
5351 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
5352 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
5354 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
5355 if $doit; then
5356 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5357 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
5358 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
5359 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
5360 } > "$tmp"/sed-ignore-removed
5361 { cat "$destdir/$dir$ignore"~
5362 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
5363 } | sed -f "$tmp"/sed-ignore-removed \
5364 > "$destdir/$dir$ignore"
5365 else
5366 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
5370 else
5371 if test -n "$dir_added"; then
5372 if $doit; then
5373 echo "Creating $destdir/$dir$ignore"
5375 if test "$ignore" = .cvsignore; then
5376 echo ".deps"
5377 # Automake generates Makefile rules that create .dirstamp files.
5378 echo ".dirstamp"
5380 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
5381 } > "$destdir/$dir$ignore"
5382 else
5383 echo "Create $destdir/$dir$ignore"
5388 func_done_dir ()
5390 dir="$1"
5391 dir_added="$2"
5392 dir_removed="$3"
5393 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
5394 func_update_ignorelist .cvsignore
5396 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
5397 func_update_ignorelist .gitignore
5400 last_dir=
5401 last_dir_added=
5402 last_dir_removed=
5403 while read line; do
5404 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
5405 next_dir=`echo "$line" | sed -e 's,|.*,,'`
5406 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
5407 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
5408 if test "$next_dir" != "$last_dir"; then
5409 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5410 last_dir="$next_dir"
5411 last_dir_added=
5412 last_dir_removed=
5414 case $op in
5415 A) func_append last_dir_added "$file$nl";;
5416 R) func_append last_dir_removed "$file$nl";;
5417 esac
5418 done
5419 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
5420 exec 0<&5 5<&-
5424 echo "Finished."
5425 echo
5426 echo "You may need to add #include directives for the following .h files."
5427 # Intersect $specified_modules and $main_modules
5428 # (since $specified_modules is not necessarily of subset of $main_modules
5429 # - some may have been skipped through --avoid, and since the elements of
5430 # $main_modules but not in $specified_modules can go away without explicit
5431 # notice - through changes in the module dependencies).
5432 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
5433 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
5434 # First the #include <...> directives without #ifs, sorted for convenience,
5435 # then the #include "..." directives without #ifs, sorted for convenience,
5436 # then the #include directives that are surrounded by #ifs. Not sorted.
5437 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
5438 include_directive=`func_get_include_directive "$module"`
5439 case "$nl$include_directive" in
5440 *"$nl#if"*)
5441 echo "$include_directive" 1>&5
5444 echo "$include_directive" | grep -v 'include "' 1>&6
5445 echo "$include_directive" | grep 'include "' 1>&7
5447 esac
5448 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
5450 LC_ALL=C sort -u "$tmp"/include-angles
5451 LC_ALL=C sort -u "$tmp"/include-quotes
5452 cat "$tmp"/include-if
5453 ) | sed -e '/^$/d' -e 's/^/ /'
5454 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
5456 for module in $main_modules; do
5457 func_get_link_directive "$module"
5458 done \
5459 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
5460 if test `wc -l < "$tmp"/link` != 0; then
5461 echo
5462 echo "You may need to use the following Makefile variables when linking."
5463 echo "Use them in <program>_LDADD when linking a program, or"
5464 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
5465 cat "$tmp"/link
5467 rm -f "$tmp"/link
5469 echo
5470 echo "Don't forget to"
5471 if test "$makefile_am" = Makefile.am; then
5472 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5473 else
5474 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
5476 if test -n "$pobase"; then
5477 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
5479 if test -n "$inctests"; then
5480 if test "$makefile_am" = Makefile.am; then
5481 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
5482 else
5483 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
5486 edit=0
5487 while test $edit != $makefile_am_edits; do
5488 edit=`expr $edit + 1`
5489 eval dir=\"\$makefile_am_edit${edit}_dir\"
5490 eval var=\"\$makefile_am_edit${edit}_var\"
5491 eval val=\"\$makefile_am_edit${edit}_val\"
5492 if test -n "$var"; then
5493 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
5495 done
5496 if grep '^ *AC_PROG_CC_STDC' "$configure_ac" > /dev/null; then
5497 position_early_after=AC_PROG_CC_STDC
5498 else
5499 if grep '^ *AC_PROG_CC_C99' "$configure_ac" > /dev/null; then
5500 position_early_after=AC_PROG_CC_C99
5501 else
5502 position_early_after=AC_PROG_CC
5505 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after $position_early_after,"
5506 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
5509 # func_create_testdir testdir modules
5510 # Input:
5511 # - local_gnulib_dir from --local-dir
5512 # - modcache true or false, from --cache-modules/--no-cache-modules
5513 # - auxdir directory relative to destdir where to place build aux files
5514 # - inctests true if tests should be included, blank otherwise
5515 # - incobsolete true if obsolete modules among dependencies should be
5516 # included, blank otherwise
5517 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
5518 # blank otherwise
5519 # - excl_longrunning_tests true if long-runnings tests should be excluded,
5520 # blank otherwise
5521 # - excl_privileged_tests true if tests that require root privileges should be
5522 # excluded, blank otherwise
5523 # - excl_unportable_tests true if tests that fail on some platforms should be
5524 # excluded, blank otherwise
5525 # - single_configure true if a single configure file should be generated,
5526 # false for a separate configure file for the tests
5527 # - avoidlist list of modules to avoid
5528 # - cond_dependencies true if --conditional-dependencies was given, false if
5529 # --no-conditional-dependencies was given, blank otherwise
5530 # - libtool true if --libtool was given, false if --no-libtool was
5531 # given, blank otherwise
5532 # - symbolic true if files should be symlinked, copied otherwise
5533 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
5534 # copied otherwise
5535 func_create_testdir ()
5537 testdir="$1"
5538 modules="$2"
5539 if test -z "$modules"; then
5540 # All modules together.
5541 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5542 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
5543 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
5544 modules=`func_all_modules`
5545 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
5547 specified_modules="$modules"
5549 # Canonicalize the list of specified modules.
5550 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
5552 # Unlike in func_import, here we want to include all kinds of tests for the
5553 # directly specified modules, but not for dependencies.
5554 inc_all_direct_tests=true
5555 inc_all_indirect_tests="$inc_all_tests"
5557 # Check that the license of every module is consistent with the license of
5558 # its dependencies.
5559 saved_inctests="$inctests"
5560 # When computing transitive closures, don't consider $module to depend on
5561 # $module-tests. Need this because tests are implicitly GPL and may depend
5562 # on GPL modules - therefore we don't want a warning in this case.
5563 inctests=""
5564 for requested_module in $specified_modules; do
5565 requested_license=`func_get_license "$requested_module"`
5566 if test "$requested_license" != GPL; then
5567 # Here we use func_modules_transitive_closure, not just
5568 # func_get_dependencies, so that we also detect weird situations like
5569 # an LGPL module which depends on a GPLed build tool module which depends
5570 # on a GPL module.
5571 modules="$requested_module"
5572 func_modules_transitive_closure
5573 for module in $modules; do
5574 license=`func_get_license "$module"`
5575 case "$license" in
5576 'GPLed build tool') ;;
5577 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
5579 case "$requested_license" in
5580 GPLv2+)
5581 case "$license" in
5582 GPLv2+ | LGPLv2+) ;;
5583 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5584 esac
5586 LGPL)
5587 case "$license" in
5588 LGPL | LGPLv2+) ;;
5589 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5590 esac
5592 LGPLv2+)
5593 case "$license" in
5594 LGPLv2+) ;;
5595 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
5596 esac
5598 esac
5600 esac
5601 done
5603 done
5604 inctests="$saved_inctests"
5606 # Subdirectory names.
5607 sourcebase=gllib
5608 m4base=glm4
5609 pobase=
5610 docbase=gldoc
5611 testsbase=gltests
5612 macro_prefix=gl
5613 po_domain=
5614 witness_c_macro=
5615 vc_files=
5617 # Determine final module list.
5618 modules="$specified_modules"
5619 func_modules_transitive_closure
5620 if test $verbose -ge 0; then
5621 func_show_module_list
5623 final_modules="$modules"
5625 if $single_configure; then
5626 # Determine main module list and tests-related module list separately.
5627 func_modules_transitive_closure_separately
5630 if $single_configure; then
5631 # Determine whether a $testsbase/libtests.a is needed.
5632 func_determine_use_libtests
5635 # Add the dummy module if needed.
5636 if $single_configure; then
5637 func_modules_add_dummy_separately
5638 else
5639 func_modules_add_dummy
5642 # Show banner notice of every module.
5643 if $single_configure; then
5644 modules="$main_modules"
5645 func_modules_notice
5646 else
5647 func_modules_notice
5650 # Determine final file list.
5651 if $single_configure; then
5652 func_modules_to_filelist_separately
5653 else
5654 func_modules_to_filelist
5655 if test $verbose -ge 0; then
5656 echo "File list:"
5657 echo "$files" | sed -e 's/^/ /'
5660 # Add files for which the copy in gnulib is newer than the one that
5661 # "automake --add-missing --copy" would provide.
5662 files="$files build-aux/config.guess"
5663 files="$files build-aux/config.sub"
5664 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
5666 rewritten='%REWRITTEN%'
5667 sed_rewrite_files="\
5668 s,^build-aux/,$rewritten$auxdir/,
5669 s,^doc/,$rewritten$docbase/,
5670 s,^lib/,$rewritten$sourcebase/,
5671 s,^m4/,$rewritten$m4base/,
5672 s,^tests/,$rewritten$testsbase/,
5673 s,^tests=lib/,$rewritten$testsbase/,
5674 s,^top/,$rewritten,
5675 s,^$rewritten,,"
5677 # Create directories.
5678 for f in $files; do echo $f; done \
5679 | sed -e "$sed_rewrite_files" \
5680 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
5681 | LC_ALL=C sort -u \
5682 > "$tmp"/dirs
5683 { # Rearrange file descriptors. Needed because "while ... done < ..."
5684 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5685 exec 5<&0 < "$tmp"/dirs
5686 while read d; do
5687 mkdir -p "$testdir/$d"
5688 done
5689 exec 0<&5 5<&-
5692 # Copy files or make symbolic links.
5693 delimiter=' '
5694 for f in $files; do echo $f; done \
5695 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
5696 | LC_ALL=C sort \
5697 > "$tmp"/files
5698 { # Rearrange file descriptors. Needed because "while ... done < ..."
5699 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5700 exec 5<&0 < "$tmp"/files
5701 while read g f; do
5702 case "$f" in
5703 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
5704 esac
5705 func_lookup_file "$f"
5706 if test -n "$lookedup_tmp"; then
5707 cp -p "$lookedup_file" "$testdir/$g"
5708 else
5709 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
5710 if { test -n "$symbolic" \
5711 || { test -n "$lsymbolic" \
5712 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
5713 func_ln "$lookedup_file" "$testdir/$g"
5714 else
5715 cp -p "$lookedup_file" "$testdir/$g"
5718 done
5719 exec 0<&5 5<&-
5722 # Determine include_guard_prefix.
5723 func_compute_include_guard_prefix
5725 # Create Makefile.ams that are for testing.
5726 for_test=true
5728 # No special edits are needed.
5729 makefile_am_edits=0
5731 # Create $sourcebase/Makefile.am.
5732 mkdir -p "$testdir/$sourcebase"
5733 destfile="$sourcebase/Makefile.am"
5734 if $single_configure; then
5735 modules="$main_modules"
5737 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
5738 any_uses_subdirs="$uses_subdirs"
5740 # Create $m4base/Makefile.am.
5741 mkdir -p "$testdir/$m4base"
5742 (echo "## Process this file with automake to produce Makefile.in."
5743 echo
5744 echo "EXTRA_DIST ="
5745 for f in $files; do
5746 case "$f" in
5747 m4/* )
5748 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
5749 esac
5750 done
5751 ) > "$testdir/$m4base/Makefile.am"
5753 subdirs="$sourcebase $m4base"
5754 subdirs_with_configure_ac=""
5756 if false && test -f "$testdir"/$m4base/gettext.m4; then
5757 # Avoid stupid error message from automake:
5758 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
5759 mkdir -p "$testdir/po"
5760 (echo "## Process this file with automake to produce Makefile.in."
5761 ) > "$testdir/po/Makefile.am"
5762 func_append subdirs " po"
5765 if test -n "$inctests"; then
5766 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
5767 if $single_configure; then
5768 # Create $testsbase/Makefile.am.
5769 destfile="$testsbase/Makefile.am"
5770 modules="$testsrelated_modules"
5771 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$testdir/$testsbase/Makefile.am"
5772 else
5773 # Viewed from the $testsbase subdirectory, $auxdir is different.
5774 saved_auxdir="$auxdir"
5775 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
5776 # Create $testsbase/Makefile.am.
5777 use_libtests=false
5778 destfile="$testsbase/Makefile.am"
5779 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
5780 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
5781 # Create $testsbase/configure.ac.
5782 (echo "# Process this file with autoconf to produce a configure script."
5783 echo "AC_INIT([dummy], [0])"
5784 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5785 echo "AM_INIT_AUTOMAKE"
5786 echo
5787 echo "AC_CONFIG_HEADERS([config.h])"
5788 echo
5789 echo "AC_PROG_CC"
5790 echo "AC_PROG_INSTALL"
5791 echo "AC_PROG_MAKE_SET"
5792 echo "gl_PROG_AR_RANLIB"
5793 echo
5794 if test -n "$uses_subdirs"; then
5795 echo "AM_PROG_CC_C_O"
5796 echo
5798 for module in $modules; do
5799 func_verify_module
5800 if test -n "$module"; then
5801 case $module in
5802 gnumakefile | maintainer-makefile)
5803 # These modules are meant to be used only in the top-level directory.
5806 func_get_autoconf_early_snippet "$module"
5808 esac
5810 done \
5811 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5812 if test "$libtool" = true; then
5813 echo "LT_INIT([win32-dll])"
5814 echo "LT_LANG([C++])"
5815 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5816 echo "gl_cond_libtool=true"
5817 else
5818 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5819 echo "gl_cond_libtool=false"
5820 echo "gl_libdeps="
5821 echo "gl_ltlibdeps="
5823 # Wrap the set of autoconf snippets into an autoconf macro that is then
5824 # invoked. This is needed because autoconf does not support AC_REQUIRE
5825 # at the top level:
5826 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5827 # but we want the AC_REQUIRE to have its normal meaning (provide one
5828 # expansion of the required macro before the current point, and only one
5829 # expansion total).
5830 echo "AC_DEFUN([gl_INIT], ["
5831 sed_replace_build_aux='
5833 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5834 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5837 echo "gl_m4_base='../$m4base'"
5838 func_emit_initmacro_start $macro_prefix
5839 # We don't have explicit ordering constraints between the various
5840 # autoconf snippets. It's cleanest to put those of the library before
5841 # those of the tests.
5842 echo "gl_source_base='../$sourcebase'"
5843 func_emit_autoconf_snippets "$modules" func_verify_nontests_module false false false
5844 echo "gl_source_base='.'"
5845 func_emit_autoconf_snippets "$modules" func_verify_tests_module false false false
5846 func_emit_initmacro_end $macro_prefix
5847 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5848 # created using libtool, because libtool already handles the dependencies.
5849 if test "$libtool" != true; then
5850 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5851 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5852 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5853 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5854 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5856 echo "])"
5857 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
5858 echo
5859 echo "gl_INIT"
5860 echo
5861 # Usually $testsbase/config.h will be a superset of config.h. Verify this
5862 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
5863 echo "AH_TOP([#include \"../config.h\"])"
5864 echo
5865 echo "AC_CONFIG_FILES([Makefile])"
5866 echo "AC_OUTPUT"
5867 ) > "$testdir/$testsbase/configure.ac"
5868 auxdir="$saved_auxdir"
5869 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
5871 func_append subdirs " $testsbase"
5874 # Create Makefile.am.
5875 (echo "## Process this file with automake to produce Makefile.in."
5876 echo
5877 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5878 echo
5879 echo "SUBDIRS = $subdirs"
5880 echo
5881 echo "ACLOCAL_AMFLAGS = -I $m4base"
5882 ) > "$testdir/Makefile.am"
5884 # Create configure.ac.
5885 (echo "# Process this file with autoconf to produce a configure script."
5886 echo "AC_INIT([dummy], [0])"
5887 if test "$auxdir" != "."; then
5888 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5890 echo "AM_INIT_AUTOMAKE"
5891 echo
5892 echo "AC_CONFIG_HEADERS([config.h])"
5893 echo
5894 echo "AC_PROG_CC"
5895 echo "AC_PROG_INSTALL"
5896 echo "AC_PROG_MAKE_SET"
5897 echo
5898 echo "# For autobuild."
5899 echo "AC_CANONICAL_BUILD"
5900 echo "AC_CANONICAL_HOST"
5901 echo
5902 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5903 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5904 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5905 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5906 echo
5907 echo "gl_PROG_AR_RANLIB"
5908 echo
5909 if test -n "$any_uses_subdirs"; then
5910 echo "AM_PROG_CC_C_O"
5911 echo
5913 for module in $final_modules; do
5914 if $single_configure; then
5915 func_verify_module
5916 else
5917 func_verify_nontests_module
5919 if test -n "$module"; then
5920 func_get_autoconf_early_snippet "$module"
5922 done \
5923 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5924 if test "$libtool" = true; then
5925 echo "LT_INIT([win32-dll])"
5926 echo "LT_LANG([C++])"
5927 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5928 echo "gl_cond_libtool=true"
5929 else
5930 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5931 echo "gl_cond_libtool=false"
5932 echo "gl_libdeps="
5933 echo "gl_ltlibdeps="
5935 # Wrap the set of autoconf snippets into an autoconf macro that is then
5936 # invoked. This is needed because autoconf does not support AC_REQUIRE
5937 # at the top level:
5938 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5939 # but we want the AC_REQUIRE to have its normal meaning (provide one
5940 # expansion of the required macro before the current point, and only one
5941 # expansion total).
5942 echo "AC_DEFUN([gl_INIT], ["
5943 if test "$auxdir" != "build-aux"; then
5944 sed_replace_build_aux='
5946 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5947 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5950 else
5951 sed_replace_build_aux="$sed_noop"
5953 echo "gl_m4_base='$m4base'"
5954 func_emit_initmacro_start $macro_prefix
5955 echo "gl_source_base='$sourcebase'"
5956 if $single_configure; then
5957 func_emit_autoconf_snippets "$main_modules" func_verify_module true false false
5958 else
5959 func_emit_autoconf_snippets "$modules" func_verify_nontests_module true false false
5961 func_emit_initmacro_end $macro_prefix
5962 if $single_configure; then
5963 echo " gltests_libdeps="
5964 echo " gltests_ltlibdeps="
5965 func_emit_initmacro_start ${macro_prefix}tests
5966 echo " gl_source_base='$testsbase'"
5967 # Define a tests witness macro.
5968 echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
5969 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
5970 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
5971 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
5972 func_emit_autoconf_snippets "$testsrelated_modules" func_verify_module true false false
5973 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
5974 func_emit_initmacro_end ${macro_prefix}tests
5976 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5977 # created using libtool, because libtool already handles the dependencies.
5978 if test "$libtool" != true; then
5979 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5980 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5981 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5982 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5983 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5985 if $single_configure; then
5986 if $use_libtests; then
5987 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
5988 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
5991 echo "])"
5992 func_emit_initmacro_done $macro_prefix $sourcebase
5993 if $single_configure; then
5994 func_emit_initmacro_done ${macro_prefix}tests $testsbase
5996 echo
5997 echo "gl_INIT"
5998 echo
5999 if test -n "$subdirs_with_configure_ac"; then
6000 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
6002 makefiles="Makefile"
6003 for d in $subdirs; do
6004 # For subdirs that have a configure.ac by their own, it's the subdir's
6005 # configure.ac which creates the subdir's Makefile.am, not this one.
6006 case " $subdirs_with_configure_ac " in
6007 *" $d "*) ;;
6008 *) func_append makefiles " $d/Makefile" ;;
6009 esac
6010 done
6011 echo "AC_CONFIG_FILES([$makefiles])"
6012 echo "AC_OUTPUT"
6013 ) > "$testdir/configure.ac"
6015 # Create autogenerated files.
6016 (cd "$testdir"
6017 # Do not use "${AUTORECONF} --force --install", because it may invoke
6018 # autopoint, which brings in older versions of some of our .m4 files.
6019 if test -f $m4base/gettext.m4; then
6020 func_execute_command ${AUTOPOINT} --force || func_exit 1
6021 for f in $m4base/*.m4~; do
6022 if test -f $f; then
6023 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6025 done
6027 if test "$libtool" = true; then
6028 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
6030 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
6031 if ! test -d build-aux; then
6032 func_execute_command mkdir build-aux || func_exit 1
6034 func_execute_command ${AUTOCONF} || func_exit 1
6035 func_execute_command ${AUTOHEADER} || func_exit 1
6036 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6037 ) || func_exit 1
6038 if test -n "$inctests" && ! $single_configure; then
6039 # Create autogenerated files.
6040 (cd "$testdir/$testsbase" || func_exit 1
6041 # Do not use "${AUTORECONF} --force --install", because it may invoke
6042 # autopoint, which brings in older versions of some of our .m4 files.
6043 if test -f ../$m4base/gettext.m4; then
6044 func_execute_command ${AUTOPOINT} --force || func_exit 1
6045 for f in ../$m4base/*.m4~; do
6046 if test -f $f; then
6047 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
6049 done
6051 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
6052 if ! test -d ../build-aux; then
6053 func_execute_command mkdir ../build-aux
6055 func_execute_command ${AUTOCONF} || func_exit 1
6056 func_execute_command ${AUTOHEADER} || func_exit 1
6057 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6058 ) || func_exit 1
6060 # Need to run configure and make once, to create built files that are to be
6061 # distributed (such as parse-datetime.c).
6062 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
6063 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
6064 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
6065 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6066 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
6067 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
6068 # such $(FOO_H) because they don't refer to distributed files.
6069 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
6070 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6071 | sed -e "$sed_remove_make_variables"`
6072 distributed_built_sources=`for file in $built_sources; do
6073 case "$cleaned_files" in
6074 *" "$file" "*) ;;
6075 *) echo $file ;;
6076 esac;
6077 done`
6078 tests_distributed_built_sources=
6079 if test -n "$inctests"; then
6080 # Likewise for built files in the $testsbase directory.
6081 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
6082 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
6083 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
6084 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
6085 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
6086 | sed -e "$sed_remove_make_variables"`
6087 tests_distributed_built_sources=`for file in $tests_built_sources; do
6088 case "$tests_cleaned_files" in
6089 *" "$file" "*) ;;
6090 *) echo $file ;;
6091 esac;
6092 done`
6094 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
6095 (cd "$testdir"
6096 ./configure || func_exit 1
6097 if test -n "$distributed_built_sources"; then
6098 cd "$sourcebase"
6099 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6100 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6101 built_sources \
6102 || func_exit 1
6103 cd ..
6105 if test -n "$tests_distributed_built_sources"; then
6106 cd "$testsbase"
6107 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
6108 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6109 built_sources \
6110 || func_exit 1
6111 cd ..
6113 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
6114 distclean \
6115 || func_exit 1
6116 ) || func_exit 1
6120 # func_create_megatestdir megatestdir allmodules
6121 # Input:
6122 # - local_gnulib_dir from --local-dir
6123 # - modcache true or false, from --cache-modules/--no-cache-modules
6124 # - auxdir directory relative to destdir where to place build aux files
6125 func_create_megatestdir ()
6127 megatestdir="$1"
6128 allmodules="$2"
6129 if test -z "$allmodules"; then
6130 allmodules=`func_all_modules`
6133 megasubdirs=
6134 # First, all modules one by one.
6135 for onemodule in $allmodules; do
6136 func_create_testdir "$megatestdir/$onemodule" $onemodule
6137 func_append megasubdirs "$onemodule "
6138 done
6139 # Then, all modules all together.
6140 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
6141 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
6142 func_create_testdir "$megatestdir/ALL" "$allmodules"
6143 func_append megasubdirs "ALL"
6145 # Create autobuild.
6146 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
6147 vc_witness="$gnulib_dir/CVS/Entries"; \
6148 else \
6149 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
6150 fi; \
6151 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
6152 | sed -e 's,January,01,' -e 's,Jan,01,' \
6153 -e 's,February,02,' -e 's,Feb,02,' \
6154 -e 's,March,03,' -e 's,Mar,03,' \
6155 -e 's,April,04,' -e 's,Apr,04,' \
6156 -e 's,May,05,' \
6157 -e 's,June,06,' -e 's,Jun,06,' \
6158 -e 's,July,07,' -e 's,Jul,07,' \
6159 -e 's,August,08,' -e 's,Aug,08,' \
6160 -e 's,September,09,' -e 's,Sep,09,' \
6161 -e 's,October,10,' -e 's,Oct,10,' \
6162 -e 's,November,11,' -e 's,Nov,11,' \
6163 -e 's,December,12,' -e 's,Dec,12,' \
6164 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
6165 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
6166 (echo '#!/bin/sh'
6167 echo "CVSDATE=$cvsdate"
6168 echo ": \${MAKE=make}"
6169 echo "test -d logs || mkdir logs"
6170 echo "for module in $megasubdirs; do"
6171 echo " echo \"Working on module \$module...\""
6172 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
6173 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
6174 echo " echo"
6175 echo " set -x"
6176 echo " : autobuild project... \$module"
6177 echo " : autobuild revision... cvs-\$CVSDATE-000000"
6178 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
6179 echo " : autobuild hostname... \`hostname\`"
6180 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
6181 echo " echo rc=\$?"
6182 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
6183 echo "done"
6184 ) > "$megatestdir/do-autobuild"
6185 chmod a+x "$megatestdir/do-autobuild"
6187 # Create Makefile.am.
6188 (echo "## Process this file with automake to produce Makefile.in."
6189 echo
6190 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
6191 echo
6192 echo "SUBDIRS = $megasubdirs"
6193 echo
6194 echo "EXTRA_DIST = do-autobuild"
6195 ) > "$megatestdir/Makefile.am"
6197 # Create configure.ac.
6198 (echo "# Process this file with autoconf to produce a configure script."
6199 echo "AC_INIT([dummy], [0])"
6200 if test "$auxdir" != "."; then
6201 echo "AC_CONFIG_AUX_DIR([$auxdir])"
6203 echo "AM_INIT_AUTOMAKE"
6204 echo
6205 echo "AC_PROG_MAKE_SET"
6206 echo
6207 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
6208 echo "AC_CONFIG_FILES([Makefile])"
6209 echo "AC_OUTPUT"
6210 ) > "$megatestdir/configure.ac"
6212 # Create autogenerated files.
6213 (cd "$megatestdir"
6214 # Do not use "${AUTORECONF} --install", because autoreconf operates
6215 # recursively, but the subdirectories are already finished, therefore
6216 # calling autoreconf here would only waste lots of CPU time.
6217 func_execute_command ${ACLOCAL} || func_exit 1
6218 func_execute_command mkdir build-aux
6219 func_execute_command ${AUTOCONF} || func_exit 1
6220 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
6221 ) || func_exit 1
6224 case $mode in
6225 "" )
6226 func_fatal_error "no mode specified" ;;
6228 list )
6229 func_all_modules
6232 find )
6233 # sed expression that converts a literal to a basic regular expression.
6234 # Needs to handle . [ \ * ^ $.
6235 sed_literal_to_basic_regex='s/\\/\\\\/g
6236 s/\[/\\[/g
6237 s/\^/\\^/g
6238 s/\([.*$]\)/[\1]/g'
6239 for filename
6241 if test -f "$gnulib_dir/$filename" \
6242 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
6243 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
6244 filename_line_regex='^'"$filename_anywhere_regex"'$'
6245 module_candidates=`
6247 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
6248 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
6249 (cd "$local_gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_anywhere_regex" /dev/null | sed -e 's,^modules/,,' -e 's,\.diff$,,')
6252 | func_sanitize_modulelist \
6253 | LC_ALL=C sort -u
6255 for module in $module_candidates; do
6256 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
6257 echo $module
6259 done
6260 else
6261 func_warning "file $filename does not exist"
6263 done
6266 import | add-import | remove-import | update )
6268 # Where to import.
6269 if test -z "$destdir"; then
6270 destdir=.
6272 test -d "$destdir" \
6273 || func_fatal_error "destination directory does not exist: $destdir"
6275 # Prefer configure.ac to configure.in.
6276 if test -f "$destdir"/configure.ac; then
6277 configure_ac="$destdir/configure.ac"
6278 else
6279 if test -f "$destdir"/configure.in; then
6280 configure_ac="$destdir/configure.in"
6281 else
6282 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
6286 # Analyze configure.ac.
6287 guessed_auxdir="."
6288 guessed_libtool=false
6289 my_sed_traces='
6290 s,#.*$,,
6291 s,^dnl .*$,,
6292 s, dnl .*$,,
6293 /AC_CONFIG_AUX_DIR/ {
6294 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
6296 /A[CM]_PROG_LIBTOOL/ {
6297 s,^.*$,guessed_libtool=true,p
6299 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
6301 if test -z "$auxdir"; then
6302 auxdir="$guessed_auxdir"
6305 # Determine where to apply func_import.
6306 if test "$mode" = import; then
6307 # Apply func_import to a particular gnulib directory.
6308 # The command line contains the complete specification; don't look at
6309 # the contents of gnulib-cache.m4.
6310 test -n "$supplied_libname" || supplied_libname=true
6311 test -n "$sourcebase" || sourcebase="lib"
6312 test -n "$m4base" || m4base="m4"
6313 test -n "$docbase" || docbase="doc"
6314 test -n "$testsbase" || testsbase="tests"
6315 test -n "$macro_prefix" || macro_prefix="gl"
6316 func_import "$*"
6317 else
6318 if test -n "$m4base"; then
6319 # Apply func_import to a particular gnulib directory.
6320 # Any number of additional modules can be given.
6321 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
6322 # First use of gnulib in the given m4base.
6323 test -n "$supplied_libname" || supplied_libname=true
6324 test -n "$sourcebase" || sourcebase="lib"
6325 test -n "$docbase" || docbase="doc"
6326 test -n "$testsbase" || testsbase="tests"
6327 test -n "$macro_prefix" || macro_prefix="gl"
6329 func_import "$*"
6330 else
6331 # Apply func_import to all gnulib directories.
6332 # To get this list of directories, look at Makefile.am. (Not at
6333 # configure, because it may be omitted from version control. Also,
6334 # don't run "find $destdir -name gnulib-cache.m4", as it might be
6335 # too expensive.)
6336 m4dirs=
6337 m4dirs_count=0
6338 if test -f "$destdir"/Makefile.am; then
6339 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
6340 m4dir_is_next=
6341 for arg in $aclocal_amflags; do
6342 if test -n "$m4dir_is_next"; then
6343 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
6344 case "$arg" in
6345 /*) ;;
6347 if test -f "$destdir/$arg"/gnulib-cache.m4; then
6348 func_append m4dirs " $arg"
6349 m4dirs_count=`expr $m4dirs_count + 1`
6352 esac
6353 m4dir_is_next=
6354 else
6355 if test "X$arg" = "X-I"; then
6356 m4dir_is_next=yes
6357 else
6358 m4dir_is_next=
6361 done
6362 else
6363 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
6364 if test -f "$destdir"/aclocal.m4; then
6365 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
6366 sedexpr2='s,^[^/]*$,.,'
6367 sedexpr3='s,/[^/]*$,,'
6368 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
6369 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
6370 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
6373 if test $m4dirs_count = 0; then
6374 # First use of gnulib in a package.
6375 # Any number of additional modules can be given.
6376 test -n "$supplied_libname" || supplied_libname=true
6377 test -n "$sourcebase" || sourcebase="lib"
6378 m4base="m4"
6379 test -n "$docbase" || docbase="doc"
6380 test -n "$testsbase" || testsbase="tests"
6381 test -n "$macro_prefix" || macro_prefix="gl"
6382 func_import "$*"
6383 else
6384 if test $m4dirs_count = 1; then
6385 # There's only one use of gnulib here. Assume the user means it.
6386 # Any number of additional modules can be given.
6387 for m4base in $m4dirs; do
6388 func_import "$*"
6389 done
6390 else
6391 # Ambiguous - guess what the user meant.
6392 if test $# = 0; then
6393 # No further arguments. Guess the user wants to update all of them.
6394 for m4base in $m4dirs; do
6395 # Perform func_import in a subshell, so that variable values
6396 # such as
6397 # local_gnulib_dir, incobsolete, inc_cxx_tests,
6398 # inc_longrunning_tests, inc_privileged_tests,
6399 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
6400 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
6401 # makefile_name, libtool, macro_prefix, po_domain,
6402 # witness_c_macro, vc_files
6403 # don't propagate from one directory to another.
6404 (func_import) || func_exit 1
6405 done
6406 else
6407 # Really ambiguous.
6408 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
6416 create-testdir )
6417 if test -z "$destdir"; then
6418 func_fatal_error "please specify --dir option"
6420 mkdir "$destdir"
6421 test -d "$destdir" \
6422 || func_fatal_error "could not create destination directory"
6423 test -n "$auxdir" || auxdir="build-aux"
6424 func_create_testdir "$destdir" "$*"
6427 create-megatestdir )
6428 if test -z "$destdir"; then
6429 func_fatal_error "please specify --dir option"
6431 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6432 test -n "$auxdir" || auxdir="build-aux"
6433 func_create_megatestdir "$destdir" "$*"
6436 test )
6437 test -n "$destdir" || destdir=testdir$$
6438 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6439 test -n "$auxdir" || auxdir="build-aux"
6440 func_create_testdir "$destdir" "$*"
6441 cd "$destdir"
6442 mkdir build
6443 cd build
6444 ../configure || func_exit 1
6445 $MAKE || func_exit 1
6446 $MAKE check || func_exit 1
6447 $MAKE distclean || func_exit 1
6448 remaining=`find . -type f -print`
6449 if test -n "$remaining"; then
6450 echo "Remaining files:" $remaining 1>&2
6451 echo "gnulib-tool: *** Stop." 1>&2
6452 func_exit 1
6454 cd ..
6455 cd ..
6456 rm -rf "$destdir"
6459 megatest )
6460 test -n "$destdir" || destdir=testdir$$
6461 mkdir "$destdir" || func_fatal_error "could not create destination directory"
6462 test -n "$auxdir" || auxdir="build-aux"
6463 func_create_megatestdir "$destdir" "$*"
6464 cd "$destdir"
6465 mkdir build
6466 cd build
6467 ../configure
6468 $MAKE
6469 $MAKE check
6470 $MAKE distclean
6471 remaining=`find . -type f -print`
6472 if test -n "$remaining"; then
6473 echo "Remaining files:" $remaining 1>&2
6474 echo "gnulib-tool: *** Stop." 1>&2
6475 func_exit 1
6477 cd ..
6478 cd ..
6479 rm -rf "$destdir"
6482 extract-description )
6483 for module
6485 func_verify_module
6486 if test -n "$module"; then
6487 func_get_description "$module"
6489 done
6492 extract-comment )
6493 for module
6495 func_verify_module
6496 if test -n "$module"; then
6497 func_get_comment "$module"
6499 done
6502 extract-status )
6503 for module
6505 func_verify_module
6506 if test -n "$module"; then
6507 func_get_status "$module"
6509 done
6512 extract-notice )
6513 for module
6515 func_verify_module
6516 if test -n "$module"; then
6517 func_get_notice "$module"
6519 done
6522 extract-applicability )
6523 for module
6525 func_verify_module
6526 if test -n "$module"; then
6527 func_get_applicability "$module"
6529 done
6532 extract-filelist )
6533 for module
6535 func_verify_module
6536 if test -n "$module"; then
6537 func_get_filelist "$module"
6539 done
6542 extract-dependencies )
6543 if test -n "$avoidlist"; then
6544 func_fatal_error "cannot combine --avoid and --extract-dependencies"
6546 for module
6548 func_verify_module
6549 if test -n "$module"; then
6550 func_get_dependencies "$module"
6552 done
6555 extract-autoconf-snippet )
6556 for module
6558 func_verify_module
6559 if test -n "$module"; then
6560 func_get_autoconf_snippet "$module"
6562 done
6565 extract-automake-snippet )
6566 for module
6568 func_verify_module
6569 if test -n "$module"; then
6570 func_get_automake_snippet "$module"
6572 done
6575 extract-include-directive )
6576 for module
6578 func_verify_module
6579 if test -n "$module"; then
6580 func_get_include_directive "$module"
6582 done
6585 extract-link-directive )
6586 for module
6588 func_verify_module
6589 if test -n "$module"; then
6590 func_get_link_directive "$module"
6592 done
6595 extract-license )
6596 for module
6598 func_verify_module
6599 if test -n "$module"; then
6600 func_get_license "$module"
6602 done
6605 extract-maintainer )
6606 for module
6608 func_verify_module
6609 if test -n "$module"; then
6610 func_get_maintainer "$module"
6612 done
6615 extract-tests-module )
6616 for module
6618 func_verify_module
6619 if test -n "$module"; then
6620 func_get_tests_module "$module"
6622 done
6625 copy-file )
6626 # Verify the number of arguments.
6627 if test $# -lt 1 || test $# -gt 2; then
6628 func_fatal_error "invalid number of arguments for --$mode"
6631 # The first argument is the file to be copied.
6632 f="$1"
6633 # Verify the file exists.
6634 func_lookup_file "$f"
6636 # The second argument is the destination; either a directory ot a file.
6637 # It defaults to the current directory.
6638 dest="$2"
6639 test -n "$dest" || dest='.'
6640 test -n "$sourcebase" || sourcebase="lib"
6641 test -n "$m4base" || m4base="m4"
6642 test -n "$docbase" || docbase="doc"
6643 test -n "$testsbase" || testsbase="tests"
6644 test -n "$auxdir" || auxdir="build-aux"
6645 rewritten='%REWRITTEN%'
6646 sed_rewrite_files="\
6647 s,^build-aux/,$rewritten$auxdir/,
6648 s,^doc/,$rewritten$docbase/,
6649 s,^lib/,$rewritten$sourcebase/,
6650 s,^m4/,$rewritten$m4base/,
6651 s,^tests/,$rewritten$testsbase/,
6652 s,^top/,$rewritten,
6653 s,^$rewritten,,"
6654 if test -d "$dest"; then
6655 destdir="$dest"
6656 g=`echo "$f" | sed -e "$sed_rewrite_files"`
6657 else
6658 destdir=`dirname "$dest"`
6659 g=`basename "$dest"`
6662 # Create the directory for destfile.
6663 d=`dirname "$destdir/$g"`
6664 if $doit; then
6665 if test -n "$d" && test ! -d "$d"; then
6666 mkdir -p "$d" || func_fatal_error "failed"
6669 # Copy the file.
6670 func_dest_tmpfilename "$g"
6671 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
6672 already_present=true
6673 if test -f "$destdir/$g"; then
6674 # The file already exists.
6675 func_update_file
6676 else
6677 # Install the file.
6678 # Don't protest if the file should be there but isn't: it happens
6679 # frequently that developers don't put autogenerated files under version
6680 # control.
6681 func_add_file
6683 rm -f "$tmpfile"
6687 func_fatal_error "unknown operation mode --$mode" ;;
6688 esac
6690 rm -rf "$tmp"
6691 # Undo the effect of the previous 'trap' command. Some shellology:
6692 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
6693 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
6694 # exit); for the others we need to call 'exit' explicitly. The value of $? is
6695 # 128 + signal number and is set before the trap-registered command is run.
6696 trap '' 0
6697 trap 'func_exit $?' 1 2 3 13 15
6699 exit 0
6701 # Local Variables:
6702 # indent-tabs-mode: nil
6703 # whitespace-check-buffer-indent: nil
6704 # End: