ignore-value: remove dependency on stdint
[gnulib.git] / gnulib-tool
blob9375f97d44781584dba38c585e55eeb9365f09f2
1 #! /bin/sh
3 # Copyright (C) 2002-2011 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 # This use of bold display can be removed on 2011-01-01.
127 if case "$TERM" in
128 xterm*) test -t 1;;
129 *) false;;
130 esac; then
131 # Assume xterm compatible escape sequences.
132 bold_on=`printf '\x1b[1m'`
133 bold_off=`printf '\x1b[0m'`
134 else
135 bold_on=
136 bold_off=
138 echo "\
139 Usage: gnulib-tool --list
140 gnulib-tool --find filename${bold_on}
141 gnulib-tool --import [module1 ... moduleN]
142 gnulib-tool --add-import [module1 ... moduleN]
143 gnulib-tool --remove-import [module1 ... moduleN]${bold_off}
144 gnulib-tool --update
145 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
146 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
147 gnulib-tool --test --dir=directory module1 ... moduleN
148 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
149 gnulib-tool --extract-description module
150 gnulib-tool --extract-comment module
151 gnulib-tool --extract-status module
152 gnulib-tool --extract-notice module
153 gnulib-tool --extract-applicability module
154 gnulib-tool --extract-filelist module
155 gnulib-tool --extract-dependencies module
156 gnulib-tool --extract-autoconf-snippet module
157 gnulib-tool --extract-automake-snippet module
158 gnulib-tool --extract-include-directive module
159 gnulib-tool --extract-link-directive module
160 gnulib-tool --extract-license module
161 gnulib-tool --extract-maintainer module
162 gnulib-tool --extract-tests-module module
163 gnulib-tool --copy-file file [destination]
165 Operation modes:
167 --list print the available module names
168 --find find the modules which contain the specified file${bold_on}
169 --import import the given modules into the current package
170 --add-import augment the list of imports from gnulib into the
171 current package, by adding the given modules;
172 if no modules are specified, update the current
173 package from the current gnulib
174 --remove-import reduce the list of imports from gnulib into the
175 current package, by removing the given modules${bold_off}
176 --update update the current package, restore files omitted
177 from version control
178 --create-testdir create a scratch package with the given modules
179 --create-megatestdir create a mega scratch package with the given modules
180 one by one and all together
181 --test test the combination of the given modules
182 (recommended to use CC=\"gcc -Wall\" here)
183 --megatest test the given modules one by one and all together
184 (recommended to use CC=\"gcc -Wall\" here)
185 --extract-description extract the description
186 --extract-comment extract the comment
187 --extract-status extract the status (obsolete etc.)
188 --extract-notice extract the notice or banner
189 --extract-applicability extract the applicability
190 --extract-filelist extract the list of files
191 --extract-dependencies extract the dependencies
192 --extract-autoconf-snippet extract the snippet for configure.ac
193 --extract-automake-snippet extract the snippet for library makefile
194 --extract-include-directive extract the #include directive
195 --extract-link-directive extract the linker directive
196 --extract-license report the license terms of the source files
197 under lib/
198 --extract-maintainer report the maintainer(s) inside gnulib
199 --extract-tests-module report the unit test module, if it exists
200 --copy-file copy a file that is not part of any module
202 General options:
204 --dir=DIRECTORY Specify the target directory.
205 For --import, this specifies where your
206 configure.ac can be found. Defaults to current
207 directory.
208 --local-dir=DIRECTORY Specify a local override directory where to look
209 up files before looking in gnulib's directory.
210 --cache-modules Enable module caching optimization.
211 --no-cache-modules Disable module caching optimization.
212 --verbose Increase verbosity. May be repeated.
213 --quiet Decrease verbosity. May be repeated.
215 Options for --import, --add/remove-import, --update:
217 --dry-run Only print what would have been done.
219 Options for --import, --add/remove-import,
220 --create-[mega]testdir, --[mega]test:
222 --with-tests Include unit tests for the included modules.
223 --with-obsolete Include obsolete modules when they occur among the
224 dependencies. By default, dependencies to obsolete
225 modules are ignored.
226 --with-c++-tests Include even unit tests for C++ interoperability.
227 --with-longrunning-tests
228 Include even unit tests that are long-runners.
229 --with-privileged-tests
230 Include even unit tests that require root
231 privileges.
232 --with-unportable-tests
233 Include even unit tests that fail on some platforms.
234 --with-all-tests Include all kinds of problematic unit tests.
235 --avoid=MODULE Avoid including the given MODULE. Useful if you
236 have code that provides equivalent functionality.
237 This option can be repeated.
238 --libtool Use libtool rules.
239 --no-libtool Don't use libtool rules.
241 Options for --import, --add/remove-import:
243 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
244 --source-base=DIRECTORY
245 Directory relative to --dir where source code is
246 placed (default \"lib\").
247 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
248 placed (default \"m4\").
249 --po-base=DIRECTORY Directory relative to --dir where *.po files are
250 placed (default \"po\").
251 --doc-base=DIRECTORY Directory relative to --dir where doc files are
252 placed (default \"doc\").
253 --tests-base=DIRECTORY
254 Directory relative to --dir where unit tests are
255 placed (default \"tests\").
256 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
257 tools are placed (default comes from configure.ac).
258 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
259 Also modify license template from GPL to LGPL.
260 The version number of the LGPL can be specified;
261 the default is currently LGPLv3.
262 --makefile-name=NAME Name of makefile in automake syntax in the
263 source-base and tests-base directories
264 (default \"Makefile.am\").
265 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
266 'gl_INIT'. Default is 'gl'.
267 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
268 the package name. A suffix '-gnulib' is appended.
269 --vc-files Update version control related files.
270 --no-vc-files Don't update version control related files
271 (.gitignore and/or .cvsignore).
272 --no-changelog Don't update or create ChangeLog files.
274 Options for --create-[mega]testdir, --[mega]test:
276 --without-c++-tests Exclude unit tests for C++ interoperability.
277 --without-longrunning-tests
278 Exclude unit tests that are long-runners.
279 --without-privileged-tests
280 Exclude unit tests that require root privileges.
281 --without-unportable-tests
282 Exclude unit tests that fail on some platforms.
284 Options for --import, --add/remove-import, --update,
285 --create-[mega]testdir, --[mega]test:
287 -s, --symbolic, --symlink Make symbolic links instead of copying files.
288 --local-symlink Make symbolic links instead of copying files, only
289 for files from the local override directory.
291 Options for --import, --add/remove-import, --update:
293 -S, --more-symlinks Make symbolic links instead of copying files, and
294 don't replace copyright notices.
296 Report bugs to <bug-gnulib@gnu.org>."
299 # func_version
300 # outputs to stdout the --version message.
301 func_version ()
303 func_gnulib_dir
304 if test -d "$gnulib_dir"/.git \
305 && (git --version) >/dev/null 2>/dev/null \
306 && (date --version) >/dev/null 2>/dev/null; then
307 # gnulib checked out from git.
308 sed_extract_first_date='/^Date/{
309 s/^Date:[ ]*//p
312 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
313 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
314 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
315 date=`echo "$date" | sed -e "$sed_year_before_time"`
316 # Use GNU date to compute the time in GMT.
317 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
318 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
319 else
320 if test -d "$gnulib_dir"/CVS \
321 && (cvs --version) >/dev/null 2>/dev/null; then
322 # gnulib checked out from CVS.
323 sed_extract_first_date='/^date: /{
324 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
327 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
328 else
329 # gnulib copy without versioning information.
330 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
332 version=
334 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
335 echo "\
336 gnulib-tool (GNU $package $date)$version
337 Copyright (C) $year Free Software Foundation, Inc.
338 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
339 This is free software: you are free to change and redistribute it.
340 There is NO WARRANTY, to the extent permitted by law.
342 Written by" "Bruno Haible" "and" "Simon Josefsson"
345 # func_emit_copyright_notice
346 # outputs to stdout a header for a generated file.
347 func_emit_copyright_notice ()
349 sed -n -e '/Copyright/ {
352 }' < "$self_abspathname"
353 echo "#"
354 echo "# This file is free software, distributed under the terms of the GNU"
355 echo "# General Public License. As a special exception to the GNU General"
356 echo "# Public License, this file may be distributed as part of a program"
357 echo "# that contains a configuration script generated by Autoconf, under"
358 echo "# the same distribution terms as the rest of that program."
359 echo "#"
360 echo "# Generated by gnulib-tool."
363 # func_exit STATUS
364 # exits with a given status.
365 # This function needs to be used, rather than 'exit', when a 'trap' handler is
366 # in effect that refers to $?.
367 func_exit ()
369 (exit $1); exit $1
372 # func_gnulib_dir
373 # locates the directory where the gnulib repository lives
374 # Input:
375 # - progname name of this program
376 # Sets variables
377 # - self_abspathname absolute pathname of gnulib-tool
378 # - gnulib_dir absolute pathname of gnulib repository
379 func_gnulib_dir ()
381 case "$progname" in
382 /*) self_abspathname="$progname" ;;
383 */*) self_abspathname=`pwd`/"$progname" ;;
385 # Look in $PATH.
386 # Iterate through the elements of $PATH.
387 # We use IFS=: instead of
388 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
389 # because the latter does not work when some PATH element contains spaces.
390 # We use a canonicalized $pathx instead of $PATH, because empty PATH
391 # elements are by definition equivalent to '.', however field splitting
392 # according to IFS=: loses empty fields in many shells:
393 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
394 # beginning, at the end, and in the middle),
395 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
396 # at the beginning and at the end,
397 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
398 # Solaris lose empty fields at the end.
399 # The 'case' statement is an optimization, to avoid evaluating the
400 # explicit canonicalization command when $PATH contains no empty fields.
401 self_abspathname=
402 if test "${PATH_SEPARATOR+set}" != set; then
403 # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which
404 # contains only /bin. Note that ksh looks also at the FPATH variable,
405 # so we have to set that as well for the test.
406 PATH_SEPARATOR=:
407 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
408 && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \
409 || PATH_SEPARATOR=';'
412 if test "$PATH_SEPARATOR" = ";"; then
413 # On Windows, programs are searched in "." before $PATH.
414 pathx=".;$PATH"
415 else
416 # On Unix, we have to convert empty PATH elements to ".".
417 pathx="$PATH"
418 case :$PATH: in
419 *::*)
420 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
422 esac
424 save_IFS="$IFS"
425 IFS="$PATH_SEPARATOR"
426 for d in $pathx; do
427 IFS="$save_IFS"
428 test -z "$d" && d=.
429 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
430 self_abspathname="$d/$progname"
431 break
433 done
434 IFS="$save_IFS"
435 if test -z "$self_abspathname"; then
436 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
439 esac
440 while test -h "$self_abspathname"; do
441 # Resolve symbolic link.
442 linkval=`func_readlink "$self_abspathname"`
443 test -n "$linkval" || break
444 case "$linkval" in
445 /* ) self_abspathname="$linkval" ;;
446 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
447 esac
448 done
449 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
452 # func_tmpdir
453 # creates a temporary directory.
454 # Input:
455 # - progname name of this program
456 # Sets variable
457 # - tmp pathname of freshly created temporary directory
458 func_tmpdir ()
460 # Use the environment variable TMPDIR, falling back to /tmp. This allows
461 # users to specify a different temporary directory, for example, if their
462 # /tmp is filled up or too small.
463 : ${TMPDIR=/tmp}
465 # Use the mktemp program if available. If not available, hide the error
466 # message.
467 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
468 test -n "$tmp" && test -d "$tmp"
469 } ||
471 # Use a simple mkdir command. It is guaranteed to fail if the directory
472 # already exists. $RANDOM is bash specific and expands to empty in shells
473 # other than bash, ksh and zsh. Its use does not increase security;
474 # rather, it minimizes the probability of failure in a very cluttered /tmp
475 # directory.
476 tmp=$TMPDIR/gl$$-$RANDOM
477 (umask 077 && mkdir "$tmp")
478 } ||
480 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
481 func_exit 1
485 # func_append var value
486 # appends the given value to the shell variable var.
487 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
488 # Use bash's += operator. It reduces complexity of appending repeatedly to
489 # a single variable from O(n^2) to O(n).
490 func_append ()
492 eval "$1+=\"\$2\""
494 fast_func_append=true
495 else
496 func_append ()
498 eval "$1=\"\$$1\$2\""
500 fast_func_append=false
503 # func_remove_prefix var prefix
504 # removes the given prefix from the value of the shell variable var.
505 # var should be the name of a shell variable.
506 # Its value should not contain a newline and not start or end with whitespace.
507 # prefix should not contain the characters "$`\{}[]^|.
508 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
509 func_remove_prefix ()
511 eval "$1=\${$1#\$2}"
513 fast_func_remove_prefix=true
514 else
515 func_remove_prefix ()
517 eval "value=\"\$$1\""
518 prefix="$2"
519 case "$prefix" in
520 *.*)
521 sed_escape_dots='s/\([.]\)/\\\1/g'
522 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
524 esac
525 value=`echo "$value" | sed -e "s|^${prefix}||"`
526 eval "$1=\"\$value\""
528 fast_func_remove_prefix=false
531 # func_remove_suffix var suffix
532 # removes the given suffix from the value of the shell variable var.
533 # var should be the name of a shell variable.
534 # Its value should not contain a newline and not start or end with whitespace.
535 # suffix should not contain the characters "$`\{}[]^|.
536 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
537 func_remove_suffix ()
539 eval "$1=\${$1%\$2}"
541 fast_func_remove_suffix=true
542 else
543 func_remove_suffix ()
545 eval "value=\"\$$1\""
546 suffix="$2"
547 case "$suffix" in
548 *.*)
549 sed_escape_dots='s/\([.]\)/\\\1/g'
550 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
552 esac
553 value=`echo "$value" | sed -e "s|${suffix}\$||"`
554 eval "$1=\"\$value\""
556 fast_func_remove_suffix=false
559 # func_fatal_error message
560 # outputs to stderr a fatal error message, and terminates the program.
561 # Input:
562 # - progname name of this program
563 func_fatal_error ()
565 echo "$progname: *** $1" 1>&2
566 echo "$progname: *** Stop." 1>&2
567 func_exit 1
570 # func_warning message
571 # Outputs to stderr a warning message,
572 func_warning ()
574 echo "gnulib-tool: warning: $1" 1>&2
577 # func_readlink SYMLINK
578 # outputs the target of the given symlink.
579 if (type -p readlink) > /dev/null 2>&1; then
580 func_readlink ()
582 # Use the readlink program from GNU coreutils.
583 readlink "$1"
585 else
586 func_readlink ()
588 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
589 # would do the wrong thing if the link target contains " -> ".
590 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
594 # func_relativize DIR1 DIR2
595 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
596 # Input:
597 # - DIR1 relative pathname, relative to the current directory
598 # - DIR2 relative pathname, relative to the current directory
599 # Output:
600 # - reldir relative pathname of DIR2, relative to DIR1
601 func_relativize ()
603 dir0=`pwd`
604 dir1="$1"
605 dir2="$2"
606 sed_first='s,^\([^/]*\)/.*$,\1,'
607 sed_rest='s,^[^/]*/*,,'
608 sed_last='s,^.*/\([^/]*\)$,\1,'
609 sed_butlast='s,/*[^/]*$,,'
610 while test -n "$dir1"; do
611 first=`echo "$dir1" | sed -e "$sed_first"`
612 if test "$first" != "."; then
613 if test "$first" = ".."; then
614 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
615 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
616 else
617 first2=`echo "$dir2" | sed -e "$sed_first"`
618 if test "$first2" = "$first"; then
619 dir2=`echo "$dir2" | sed -e "$sed_rest"`
620 else
621 dir2="../$dir2"
623 dir0="$dir0"/"$first"
626 dir1=`echo "$dir1" | sed -e "$sed_rest"`
627 done
628 reldir="$dir2"
631 # func_relconcat DIR1 DIR2
632 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
633 # Input:
634 # - DIR1 relative pathname, relative to the current directory
635 # - DIR2 relative pathname, relative to DIR1
636 # Output:
637 # - relconcat DIR1/DIR2, relative to the current directory
638 func_relconcat ()
640 dir1="$1"
641 dir2="$2"
642 sed_first='s,^\([^/]*\)/.*$,\1,'
643 sed_rest='s,^[^/]*/*,,'
644 sed_last='s,^.*/\([^/]*\)$,\1,'
645 sed_butlast='s,/*[^/]*$,,'
646 while true; do
647 first=`echo "$dir2" | sed -e "$sed_first"`
648 if test "$first" = "."; then
649 dir2=`echo "$dir2" | sed -e "$sed_rest"`
650 if test -z "$dir2"; then
651 relconcat="$dir1"
652 break
654 else
655 last=`echo "$dir1" | sed -e "$sed_last"`
656 while test "$last" = "."; do
657 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
658 last=`echo "$dir1" | sed -e "$sed_last"`
659 done
660 if test -z "$dir1"; then
661 relconcat="$dir2"
662 break
664 if test "$first" = ".."; then
665 if test "$last" = ".."; then
666 relconcat="$dir1/$dir2"
667 break
669 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
670 dir2=`echo "$dir2" | sed -e "$sed_rest"`
671 if test -z "$dir1"; then
672 relconcat="$dir2"
673 break
675 if test -z "$dir2"; then
676 relconcat="$dir1"
677 break
679 else
680 relconcat="$dir1/$dir2"
681 break
684 done
687 # func_ln SRC DEST
688 # Like ln -s, except that SRC is given relative to the current directory (or
689 # absolute), not given relative to the directory of DEST.
690 func_ln ()
692 case "$1" in
694 ln -s "$1" "$2" ;;
695 *) # SRC is relative.
696 case "$2" in
698 ln -s "`pwd`/$1" "$2" ;;
699 *) # DEST is relative too.
700 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
701 test -n "$ln_destdir" || ln_destdir="."
702 func_relativize "$ln_destdir" "$1"
703 ln -s "$reldir" "$2"
705 esac
707 esac
710 # func_ln_if_changed SRC DEST
711 # Like func_ln, but avoids munging timestamps if the link is correct.
712 func_ln_if_changed ()
714 if test $# -ne 2; then
715 echo "usage: func_ln_if_changed SRC DEST" >&2
717 ln_target=`func_readlink "$2"`
718 if test -h "$2" && test "$1" = "$ln_target"; then
720 else
721 rm -f "$2"
722 func_ln "$1" "$2"
726 # Ensure an 'echo' command that
727 # 1. does not interpret backslashes and
728 # 2. does not print an error message "broken pipe" when writing into a pipe
729 # with no writers.
731 # Test cases for problem 1:
732 # echo '\n' | wc -l prints 1 when OK, 2 when KO
733 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
734 # Test cases for problem 2:
735 # echo hi | true frequently prints
736 # "bash: echo: write error: Broken pipe"
737 # to standard error in bash 3.2.
739 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
740 # BSD echo interprets '-n' as an option, which is also not desirable).
741 # Nowadays the problem occurs in 4 situations:
742 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
743 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
744 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
745 # - in zsh, when sh-emulation is not set,
746 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
747 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
748 # - in Solaris /bin/sh and OSF/1 /bin/sh.
749 # We try the following workarounds:
750 # - for all: respawn using $CONFIG_SHELL if that is set and works.
751 # - for bash >= 2.04: unset the shell option xpg_echo.
752 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
753 # - for bash < 2.0: define echo to a function that uses cat of a here document.
754 # - for zsh: turn sh-emulation on.
755 # - for ksh: alias echo to 'print -r'.
756 # - for ksh: alias echo to a function that uses cat of a here document.
757 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
758 # the ksh workaround.
759 # - otherwise: respawn using /bin/sh and rely on the workarounds.
760 # When respawning, we pass --no-reexec as first argument, so as to avoid
761 # turning this script into a fork bomb in unlucky situations.
763 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
764 # the 'printf' built-in. See
765 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
766 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
767 # The workaround is: define echo to a function that uses the printf built-in.
768 have_echo=
769 if echo '\t' | grep t > /dev/null; then
770 have_echo=yes # Lucky!
772 # Try the workarounds.
773 # Respawn using $CONFIG_SHELL if that is set and works.
774 if test -z "$have_echo" \
775 && test "X$1" != "X--no-reexec" \
776 && test -n "$CONFIG_SHELL" \
777 && test -f "$CONFIG_SHELL" \
778 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
779 exec $CONFIG_SHELL "$0" --no-reexec "$@"
780 exit 127
782 # For bash >= 2.04: unset the shell option xpg_echo.
783 if test -z "$have_echo" \
784 && test -n "$BASH_VERSION" \
785 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
786 shopt -o xpg_echo
787 have_echo=yes
789 # For bash >= 2.0: define echo to a function that uses the printf built-in.
790 # For bash < 2.0: define echo to a function that uses cat of a here document.
791 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
792 # Also handle problem 2, specific to bash 3.2, here.
793 if { test -z "$have_echo" \
794 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
796 && test -n "$BASH_VERSION"; then \
797 if type printf 2>/dev/null | grep / > /dev/null; then
798 # 'printf' is not a shell built-in.
799 echo ()
801 cat <<EOF
805 else
806 # 'printf' is a shell built-in.
807 echo ()
809 printf '%s\n' "$*"
812 if echo '\t' | grep t > /dev/null; then
813 have_echo=yes
816 # For zsh: turn sh-emulation on.
817 if test -z "$have_echo" \
818 && test -n "$ZSH_VERSION" \
819 && (emulate sh) >/dev/null 2>&1; then
820 emulate sh
822 # For ksh: alias echo to 'print -r'.
823 if test -z "$have_echo" \
824 && (type print) >/dev/null 2>&1; then
825 # A 'print' command exists.
826 if type print 2>/dev/null | grep / > /dev/null; then
828 else
829 # 'print' is a shell built-in.
830 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
831 # 'print' is the ksh shell built-in.
832 alias echo='print -r'
836 if test -z "$have_echo" \
837 && echo '\t' | grep t > /dev/null; then
838 have_echo=yes
840 # For ksh: alias echo to a function that uses cat of a here document.
841 # The ksh manual page says:
842 # "Aliasing is performed when scripts are read, not while they are executed.
843 # Therefore, for an alias to take effect, the alias definition command has
844 # to be executed before the command which references the alias is read."
845 # Because of this, we have to play strange tricks with have_echo, to ensure
846 # that the top-level statement containing the test starts after the 'alias'
847 # command.
848 if test -z "$have_echo"; then
849 bsd_echo ()
851 cat <<EOF
855 if (alias echo=bsd_echo) 2>/dev/null; then
856 alias echo=bsd_echo 2>/dev/null
859 if test -z "$have_echo" \
860 && echo '\t' | grep t > /dev/null; then
861 have_echo=yes
863 if test -z "$have_echo"; then
864 if (alias echo=bsd_echo) 2>/dev/null; then
865 unalias echo 2>/dev/null
868 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
869 if test -z "$have_echo" \
870 && test "X$1" != "X--no-reexec" \
871 && test -f /bin/ksh; then
872 exec /bin/ksh "$0" --no-reexec "$@"
873 exit 127
875 # Otherwise: respawn using /bin/sh.
876 if test -z "$have_echo" \
877 && test "X$1" != "X--no-reexec" \
878 && test -f /bin/sh; then
879 exec /bin/sh "$0" --no-reexec "$@"
880 exit 127
882 if test -z "$have_echo"; then
883 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
885 if echo '\t' | grep t > /dev/null; then
886 : # Works fine now.
887 else
888 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
890 if test "X$1" = "X--no-reexec"; then
891 shift
894 # Command-line option processing.
895 # Removes the OPTIONS from the arguments. Sets the variables:
896 # - mode list or import or add-import or remove-import or update
897 # or create-testdir or create-megatestdir
898 # - destdir from --dir
899 # - local_gnulib_dir from --local-dir
900 # - modcache true or false, from --cache-modules/--no-cache-modules
901 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
902 # - libname, supplied_libname from --lib
903 # - sourcebase from --source-base
904 # - m4base from --m4-base
905 # - pobase from --po-base
906 # - docbase from --doc-base
907 # - testsbase from --tests-base
908 # - auxdir from --aux-dir
909 # - inctests true if --with-tests was given, blank otherwise
910 # - incobsolete true if --with-obsolete was given, blank otherwise
911 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
912 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
913 # otherwise
914 # - inc_privileged_tests true if --with-privileged-tests was given, blank
915 # otherwise
916 # - inc_unportable_tests true if --with-unportable-tests was given, blank
917 # otherwise
918 # - inc_all_tests true if --with-all-tests was given, blank otherwise
919 # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise
920 # - excl_longrunning_tests true if --without-longrunning-tests was given,
921 # blank otherwise
922 # - excl_privileged_tests true if --without-privileged-tests was given, blank
923 # otherwise
924 # - excl_unportable_tests true if --without-unportable-tests was given, blank
925 # otherwise
926 # - avoidlist list of modules to avoid, from --avoid
927 # - lgpl yes or a number if --lgpl was given, blank otherwise
928 # - makefile_name from --makefile-name
929 # - libtool true if --libtool was given, false if --no-libtool was
930 # given, blank otherwise
931 # - macro_prefix from --macro-prefix
932 # - po_domain from --po-domain
933 # - vc_files true if --vc-files was given, false if --no-vc-files was
934 # given, blank otherwise
935 # - autoconf_minversion minimum supported autoconf version
936 # - do_changelog false if --no-changelog was given, : otherwise
937 # - doit : if actions shall be executed, false if only to be printed
938 # - symbolic true if --symlink or --more-symlinks was given, blank
939 # otherwise
940 # - lsymbolic true if --local-symlink was given, blank otherwise
941 # - do_copyrights blank if --more-symlinks was given, true otherwise
943 mode=
944 destdir=
945 local_gnulib_dir=
946 modcache=true
947 verbose=0
948 libname=libgnu
949 supplied_libname=
950 sourcebase=
951 m4base=
952 pobase=
953 docbase=
954 testsbase=
955 auxdir=
956 inctests=
957 incobsolete=
958 inc_cxx_tests=
959 inc_longrunning_tests=
960 inc_privileged_tests=
961 inc_unportable_tests=
962 inc_all_tests=
963 excl_cxx_tests=
964 excl_longrunning_tests=
965 excl_privileged_tests=
966 excl_unportable_tests=
967 avoidlist=
968 lgpl=
969 makefile_name=
970 libtool=
971 macro_prefix=
972 po_domain=
973 vc_files=
974 do_changelog=:
975 doit=:
976 symbolic=
977 lsymbolic=
978 do_copyrights=true
980 supplied_opts="$@"
982 while test $# -gt 0; do
983 case "$1" in
984 --list | --lis )
985 mode=list
986 shift ;;
987 --find | --fin | --fi | --f )
988 mode=find
989 shift ;;
990 --import | --impor | --impo | --imp | --im | --i )
991 mode=import
992 shift ;;
993 --add-import | --add-impor | --add-impo | --add-imp | --add-im | --add-i | --add- | --add | --ad )
994 mode=add-import
995 shift ;;
996 --remove-import | --remove-impor | --remove-impo | --remove-imp | --remove-im | --remove-i | --remove- | --remove | --remov | --remo | --rem | --re | --r )
997 mode=remove-import
998 shift ;;
999 --update | --updat | --upda | --upd | --up | --u )
1000 mode=update
1001 shift ;;
1002 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
1003 mode=create-testdir
1004 shift ;;
1005 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
1006 mode=create-megatestdir
1007 shift ;;
1008 --test | --tes | --te | --t )
1009 mode=test
1010 shift ;;
1011 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
1012 mode=megatest
1013 shift ;;
1014 --extract-* )
1015 mode=`echo "X$1" | sed -e 's/^X--//'`
1016 shift ;;
1017 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop | --co )
1018 mode=copy-file
1019 shift ;;
1020 --dir )
1021 shift
1022 if test $# = 0; then
1023 func_fatal_error "missing argument for --dir"
1025 destdir=$1
1026 shift ;;
1027 --dir=* )
1028 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
1029 shift ;;
1030 --local-dir )
1031 shift
1032 if test $# = 0; then
1033 func_fatal_error "missing argument for --local-dir"
1035 local_gnulib_dir=$1
1036 shift ;;
1037 --local-dir=* )
1038 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
1039 shift ;;
1040 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
1041 modcache=true
1042 shift ;;
1043 --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 )
1044 modcache=false
1045 shift ;;
1046 --verbose | --verbos | --verbo | --verb )
1047 verbose=`expr $verbose + 1`
1048 shift ;;
1049 --quiet | --quie | --qui | --qu | --q )
1050 verbose=`expr $verbose - 1`
1051 shift ;;
1052 --lib )
1053 shift
1054 if test $# = 0; then
1055 func_fatal_error "missing argument for --lib"
1057 libname=$1
1058 supplied_libname=true
1059 shift ;;
1060 --lib=* )
1061 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
1062 supplied_libname=true
1063 shift ;;
1064 --source-base )
1065 shift
1066 if test $# = 0; then
1067 func_fatal_error "missing argument for --source-base"
1069 sourcebase=$1
1070 shift ;;
1071 --source-base=* )
1072 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
1073 shift ;;
1074 --m4-base )
1075 shift
1076 if test $# = 0; then
1077 func_fatal_error "missing argument for --m4-base"
1079 m4base=$1
1080 shift ;;
1081 --m4-base=* )
1082 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1083 shift ;;
1084 --po-base )
1085 shift
1086 if test $# = 0; then
1087 func_fatal_error "missing argument for --po-base"
1089 pobase=$1
1090 shift ;;
1091 --po-base=* )
1092 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1093 shift ;;
1094 --doc-base )
1095 shift
1096 if test $# = 0; then
1097 func_fatal_error "missing argument for --doc-base"
1099 docbase=$1
1100 shift ;;
1101 --doc-base=* )
1102 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1103 shift ;;
1104 --tests-base )
1105 shift
1106 if test $# = 0; then
1107 func_fatal_error "missing argument for --tests-base"
1109 testsbase=$1
1110 shift ;;
1111 --tests-base=* )
1112 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1113 shift ;;
1114 --aux-dir )
1115 shift
1116 if test $# = 0; then
1117 func_fatal_error "missing argument for --aux-dir"
1119 auxdir=$1
1120 shift ;;
1121 --aux-dir=* )
1122 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1123 shift ;;
1124 --with-tests | --with-test | --with-tes | --with-te | --with-t)
1125 inctests=true
1126 shift ;;
1127 --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
1128 incobsolete=true
1129 shift ;;
1130 --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
1131 inc_cxx_tests=true
1132 shift ;;
1133 --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)
1134 inc_longrunning_tests=true
1135 shift ;;
1136 --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)
1137 inc_privileged_tests=true
1138 shift ;;
1139 --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)
1140 inc_unportable_tests=true
1141 shift ;;
1142 --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
1143 inc_all_tests=true
1144 shift ;;
1145 --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c)
1146 excl_cxx_tests=true
1147 shift ;;
1148 --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)
1149 excl_longrunning_tests=true
1150 shift ;;
1151 --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)
1152 excl_privileged_tests=true
1153 shift ;;
1154 --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)
1155 excl_unportable_tests=true
1156 shift ;;
1157 --avoid )
1158 shift
1159 if test $# = 0; then
1160 func_fatal_error "missing argument for --avoid"
1162 func_append avoidlist " $1"
1163 shift ;;
1164 --avoid=* )
1165 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1166 func_append avoidlist " $arg"
1167 shift ;;
1168 --lgpl )
1169 lgpl=yes
1170 shift ;;
1171 --lgpl=* )
1172 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1173 case "$arg" in
1174 2 | 3) ;;
1175 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1176 esac
1177 lgpl=$arg
1178 shift ;;
1179 --makefile-name )
1180 shift
1181 if test $# = 0; then
1182 func_fatal_error "missing argument for --makefile-name"
1184 makefile_name="$1"
1185 shift ;;
1186 --makefile-name=* )
1187 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1188 shift ;;
1189 --libtool )
1190 libtool=true
1191 shift ;;
1192 --no-libtool )
1193 libtool=false
1194 shift ;;
1195 --macro-prefix )
1196 shift
1197 if test $# = 0; then
1198 func_fatal_error "missing argument for --macro-prefix"
1200 macro_prefix="$1"
1201 shift ;;
1202 --macro-prefix=* )
1203 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1204 shift ;;
1205 --po-domain )
1206 shift
1207 if test $# = 0; then
1208 func_fatal_error "missing argument for --po-domain"
1210 po_domain="$1"
1211 shift ;;
1212 --po-domain=* )
1213 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1214 shift ;;
1215 --vc-files )
1216 vc_files=true
1217 shift ;;
1218 --no-vc-files )
1219 vc_files=false
1220 shift ;;
1221 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1222 do_changelog=false
1223 shift ;;
1224 --dry-run )
1225 doit=false
1226 shift ;;
1227 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1228 symbolic=true
1229 shift ;;
1230 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1231 lsymbolic=true
1232 shift ;;
1233 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1234 symbolic=true
1235 do_copyrights=
1236 shift ;;
1237 --help | --hel | --he | --h )
1238 func_usage
1239 func_exit $? ;;
1240 --version | --versio | --versi | --vers )
1241 func_version
1242 func_exit $? ;;
1243 -- )
1244 # Stop option processing
1245 shift
1246 break ;;
1247 -* )
1248 echo "gnulib-tool: unknown option $1" 1>&2
1249 echo "Try 'gnulib-tool --help' for more information." 1>&2
1250 func_exit 1 ;;
1252 break ;;
1253 esac
1254 done
1256 if case "$mode" in import | add-import | remove-import) true;; *) false;; esac; then
1257 if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1258 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests"; then
1259 echo "gnulib-tool: invalid options for '$mode' mode" 1>&2
1260 echo "Try 'gnulib-tool --help' for more information." 1>&2
1261 func_exit 1
1264 # This code helps migrating from --import to --add-import or --update. It can
1265 # be removed on 2012-01-01.
1266 if test "$mode" = import && test $# = 0; then
1267 echo "gnulib-tool: cowardly refusing to erase the module list." 1>&2
1268 echo "The meaning of the option '--import' has changed." 1>&2
1269 echo "See the documentation at" 1>&2
1270 echo "<http://www.gnu.org/software/gnulib/manual/html_node/Modified-imports.html>." 1>&2
1271 echo "For updating to a newer version of gnulib, use" 1>&2
1272 echo " gnulib-tool --add-import" 1>&2
1273 echo "For restoring files that were omitted from version control, use" 1>&2
1274 echo " gnulib-tool --update" 1>&2
1275 func_exit 1
1277 if test "$mode" = update; then
1278 if test $# != 0; then
1279 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1280 echo "Try 'gnulib-tool --help' for more information." 1>&2
1281 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1282 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1283 func_exit 1
1285 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1286 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1287 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1288 || test -n "$inctests" || test -n "$incobsolete" \
1289 || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
1290 || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
1291 || test -n "$inc_all_tests" \
1292 || test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \
1293 || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \
1294 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1295 || test -n "$macro_prefix" || test -n "$po_domain" \
1296 || test -n "$vc_files"; then
1297 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1298 echo "Try 'gnulib-tool --help' for more information." 1>&2
1299 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1300 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1301 func_exit 1
1303 do_changelog=false
1305 if test -n "$pobase" && test -z "$po_domain"; then
1306 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1307 echo "Try 'gnulib-tool --help' for more information." 1>&2
1308 func_exit 1
1310 if test -z "$pobase" && test -n "$po_domain"; then
1311 func_warning "--po-domain has no effect without a --po-base option"
1314 # Determine the minimum supported autoconf version from the project's
1315 # configure.ac.
1316 DEFAULT_AUTOCONF_MINVERSION="2.59"
1317 autoconf_minversion=
1318 configure_ac=
1319 if case "$mode" in import | add-import | remove-import | update) true;; *) false;; esac \
1320 && test -n "$destdir"; then
1321 if test -f "$destdir"/configure.ac; then
1322 configure_ac="$destdir/configure.ac"
1323 else
1324 if test -f "$destdir"/configure.in; then
1325 configure_ac="$destdir/configure.in"
1328 else
1329 if test -f configure.ac; then
1330 configure_ac="configure.ac"
1331 else
1332 if test -f configure.in; then
1333 configure_ac="configure.in"
1337 if test -n "$configure_ac"; then
1338 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1339 # because when some m4 files are omitted from a version control repository,
1340 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1341 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1342 # autom4te: m4 failed with exit status: 1
1343 prereqs=
1344 my_sed_traces='
1345 s,#.*$,,
1346 s,^dnl .*$,,
1347 s, dnl .*$,,
1348 /AC_PREREQ/ {
1349 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1351 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1352 if test -n "$prereqs"; then
1353 autoconf_minversion=`
1354 for version in $prereqs; do echo $version; done |
1355 LC_ALL=C sort -nru | sed -e 1q
1359 if test -z "$autoconf_minversion"; then
1360 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1362 case "$autoconf_minversion" in
1363 1.* | 2.[0-4]* | 2.5[0-8]*)
1364 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1365 esac
1367 # Remove trailing slashes from the directory names. This is necessary for
1368 # m4base (to avoid an error in func_import) and optional for the others.
1369 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1370 case "$local_gnulib_dir" in
1371 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1372 esac
1373 case "$sourcebase" in
1374 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1375 esac
1376 case "$m4base" in
1377 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1378 esac
1379 case "$pobase" in
1380 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1381 esac
1382 case "$docbase" in
1383 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1384 esac
1385 case "$testsbase" in
1386 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1387 esac
1388 case "$auxdir" in
1389 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1390 esac
1393 func_gnulib_dir
1394 func_tmpdir
1395 trap 'exit_status=$?
1396 if test "$signal" != 0; then
1397 echo "caught signal $signal" >&2
1399 rm -rf "$tmp"
1400 exit $exit_status' 0
1401 for signal in 1 2 3 13 15; do
1402 trap '{ signal='$signal'; func_exit 1; }' $signal
1403 done
1404 signal=0
1406 # Note: The 'eval' silences stderr output in dash.
1407 if (declare -A x && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }) 2>/dev/null; then
1408 # Zsh 4 and Bash 4 have associative arrays.
1409 have_associative=true
1410 else
1411 # For other shells, use 'eval' with computed shell variable names.
1412 have_associative=false
1415 # func_lookup_file file
1416 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1417 # 'patch'.
1418 # Input:
1419 # - local_gnulib_dir from --local-dir
1420 # Output:
1421 # - lookedup_file name of the merged (combined) file
1422 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1423 func_lookup_file ()
1425 lkfile="$1"
1426 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1427 lookedup_file="$local_gnulib_dir/$lkfile"
1428 lookedup_tmp=
1429 else
1430 if test -f "$gnulib_dir/$lkfile"; then
1431 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1432 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1433 rm -f "$tmp/$lkbase"
1434 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1435 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1436 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1437 lookedup_file="$tmp/$lkbase"
1438 lookedup_tmp=true
1439 else
1440 lookedup_file="$gnulib_dir/$lkfile"
1441 lookedup_tmp=
1443 else
1444 func_fatal_error "file $gnulib_dir/$lkfile not found"
1449 # func_sanitize_modulelist
1450 # receives a list of possible module names on standard input, one per line.
1451 # It removes those which are just file names unrelated to modules, and outputs
1452 # the resulting list to standard output, one per line.
1453 func_sanitize_modulelist ()
1455 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1456 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1457 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1458 -e '/^README$/d' -e '/\/README$/d' \
1459 -e '/^TEMPLATE$/d' \
1460 -e '/^TEMPLATE-EXTENDED$/d' \
1461 -e '/^TEMPLATE-TESTS$/d' \
1462 -e '/^\..*/d' \
1463 -e '/~$/d'
1466 # func_all_modules
1467 # Input:
1468 # - local_gnulib_dir from --local-dir
1469 func_all_modules ()
1471 # Filter out metainformation files like README, which are not modules.
1472 # Filter out unit test modules; they can be retrieved through
1473 # --extract-tests-module if desired.
1475 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1476 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1477 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1480 | func_sanitize_modulelist \
1481 | sed -e '/-tests$/d' \
1482 | LC_ALL=C sort -u
1485 # func_exists_module module
1486 # tests whether a module, given by name, exists
1487 # Input:
1488 # - local_gnulib_dir from --local-dir
1489 func_exists_module ()
1491 { test -f "$gnulib_dir/modules/$1" \
1492 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1493 && test -f "$local_gnulib_dir/modules/$1"; }; } \
1494 && test "CVS" != "$1" \
1495 && test "ChangeLog" != "$1" \
1496 && test "COPYING" != "$1" \
1497 && test "README" != "$1" \
1498 && test "TEMPLATE" != "$1" \
1499 && test "TEMPLATE-EXTENDED" != "$1" \
1500 && test "TEMPLATE-TESTS" != "$1"
1503 # func_verify_module
1504 # verifies a module name
1505 # Input:
1506 # - local_gnulib_dir from --local-dir
1507 # - module module name argument
1508 func_verify_module ()
1510 if func_exists_module "$module"; then
1511 # OK, $module is a correct module name.
1512 # Verify that building the module description with 'patch' succeeds.
1513 func_lookup_file "modules/$module"
1514 else
1515 func_warning "module $module doesn't exist"
1516 module=
1520 # func_verify_nontests_module
1521 # verifies a module name, excluding tests modules
1522 # Input:
1523 # - local_gnulib_dir from --local-dir
1524 # - module module name argument
1525 func_verify_nontests_module ()
1527 case "$module" in
1528 *-tests ) module= ;;
1529 * ) func_verify_module ;;
1530 esac
1533 # func_verify_tests_module
1534 # verifies a module name, considering only tests modules
1535 # Input:
1536 # - local_gnulib_dir from --local-dir
1537 # - module module name argument
1538 func_verify_tests_module ()
1540 case "$module" in
1541 *-tests ) func_verify_module ;;
1542 * ) module= ;;
1543 esac
1546 # Suffix of a sed expression that extracts a particular field from a
1547 # module description.
1548 # A field starts with a line that contains a keyword, such as 'Description',
1549 # followed by a colon and optional whitespace. All following lines, up to
1550 # the next field (or end of file if there is none) form the contents of the
1551 # field.
1552 # An absent field is equivalent to a field with empty contents.
1553 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1554 sed_extract_prog=':[ ]*$/ {
1557 s/^Description:[ ]*$//
1558 s/^Comment:[ ]*$//
1559 s/^Status:[ ]*$//
1560 s/^Notice:[ ]*$//
1561 s/^Applicability:[ ]*$//
1562 s/^Files:[ ]*$//
1563 s/^Depends-on:[ ]*$//
1564 s/^configure\.ac-early:[ ]*$//
1565 s/^configure\.ac:[ ]*$//
1566 s/^Makefile\.am:[ ]*$//
1567 s/^Include:[ ]*$//
1568 s/^Link:[ ]*$//
1569 s/^License:[ ]*$//
1570 s/^Maintainer:[ ]*$//
1577 # Piece of a sed expression that converts a field header line to a shell
1578 # variable name,
1579 # NOTE: Keep this in sync with sed_extract_prog above!
1580 sed_extract_field_header='
1581 s/^Description:[ ]*$/description/
1582 s/^Comment:[ ]*$/comment/
1583 s/^Status:[ ]*$/status/
1584 s/^Notice:[ ]*$/notice/
1585 s/^Applicability:[ ]*$/applicability/
1586 s/^Files:[ ]*$/files/
1587 s/^Depends-on:[ ]*$/dependson/
1588 s/^configure\.ac-early:[ ]*$/configureac_early/
1589 s/^configure\.ac:[ ]*$/configureac/
1590 s/^Makefile\.am:[ ]*$/makefile/
1591 s/^Include:[ ]*$/include/
1592 s/^Link:[ ]*$/link/
1593 s/^License:[ ]*$/license/
1594 s/^Maintainer:[ ]*$/maintainer/'
1596 if $modcache; then
1598 if $have_associative; then
1600 # Declare the associative arrays.
1601 declare -A modcache_cached
1602 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1603 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1604 eval "$declare_script"
1606 else
1608 # func_cache_var module
1609 # computes the cache variable name corresponding to $module.
1610 # Note: This computation can map different module names to the same
1611 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1612 # to protect against this case.
1613 # Output:
1614 # - cachevar a shell variable name
1615 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1616 # Bash 2.0 and newer, ksh, and zsh support the syntax
1617 # ${param//pattern/replacement}
1618 # as a shorthand for
1619 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1620 # Note: The 'eval' is necessary for dash and NetBSD /bin/sh.
1621 eval 'func_cache_var ()
1623 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1625 else
1626 func_cache_var ()
1628 case $1 in
1629 *[!a-zA-Z0-9_]*)
1630 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1632 cachevar=c_$1 ;;
1633 esac
1639 # func_init_sed_convert_to_cache_statements
1640 # Input:
1641 # - modcachevar_assignment
1642 # Output:
1643 # - sed_convert_to_cache_statements
1644 func_init_sed_convert_to_cache_statements ()
1646 # 'sed' script that turns a module description into shell script
1647 # assignments, suitable to be eval'ed. All active characters are escaped.
1648 # This script turns
1649 # Description:
1650 # Some module's description
1652 # Files:
1653 # lib/file.h
1654 # into:
1655 # modcache_description[$1]=\
1656 # 'Some module'"'"'s description
1658 # modcache_files[$1]=\
1659 # 'lib/file.h'
1660 # or:
1661 # c_MODULE_description_set=set; c_MODULE_description=\
1662 # 'Some module'"'"'s description
1664 # c_MODULE_files_set=set; c_MODULE_files=\
1665 # 'lib/file.h'
1666 # The script consists of two parts:
1667 # 1) Ignore the lines before the first field header.
1668 # 2) A loop, treating non-field-header lines by escaping single quotes
1669 # and adding a closing quote in the last line,
1670 sed_convert_to_cache_statements="
1671 :llla
1672 # Here we have not yet seen a field header.
1674 # See if the current line contains a field header.
1675 t llla1
1676 :llla1
1677 ${sed_extract_field_header}
1678 t lllb
1680 # No field header. Ignore the line.
1682 # Read the next line. Upon EOF, just exit.
1684 b llla
1686 :lllb
1687 # The current line contains a field header.
1689 # Turn it into the beginning of an assignment.
1690 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1692 # Move it to the hold space. Don't print it yet,
1693 # because we want no assignment if the field is empty.
1696 # Read the next line.
1697 # Upon EOF, the field was empty. Print no assignment. Just exit.
1700 # See if the current line contains a field header.
1701 t lllb1
1702 :lllb1
1703 ${sed_extract_field_header}
1704 # If it is, the previous field was empty. Print no assignment.
1705 t lllb
1707 # Not a field header.
1709 # Print the previous line, held in the hold space.
1714 # Transform single quotes.
1715 s/'/'\"'\"'/g
1717 # Prepend a single quote.
1718 s/^/'/
1720 :lllc
1722 # Move it to the hold space.
1725 # Read the next line.
1726 # Upon EOF, branch.
1728 b llle
1732 # See if the current line contains a field header.
1733 t lllc1
1734 :lllc1
1735 ${sed_extract_field_header}
1736 t llld
1738 # Print the previous line, held in the hold space.
1743 # Transform single quotes.
1744 s/'/'\"'\"'/g
1746 b lllc
1748 :llld
1749 # A field header.
1750 # Print the previous line, held in the hold space, with a single quote
1751 # to end the assignment.
1753 s/\$/'/
1757 b lllb
1759 :llle
1760 # EOF seen.
1761 # Print the previous line, held in the hold space, with a single quote
1762 # to end the assignment.
1764 s/\$/'/
1766 # Exit.
1769 if ! $sed_comments; then
1770 # Remove comments.
1771 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1772 | sed -e 's/^ *//' -e 's/^#.*//'`
1776 if $have_associative; then
1777 # sed_convert_to_cache_statements does not depend on the module.
1778 modcachevar_assignment='modcache_\1[$1]='
1779 func_init_sed_convert_to_cache_statements
1782 # func_cache_lookup_module module
1784 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1785 # of its relevant data in a cache in the memory of the processing shell. If
1786 # already cached, it does not look it up again, thus saving file access time.
1787 # Parameters:
1788 # - module non-empty string
1789 # Output if $have_associative:
1790 # - modcache_cached[$module] set to yes
1791 # - modcache_description[$module] ==
1792 # - modcache_status[$module] \ set to the field's value, minus the
1793 # - ... / final newline,
1794 # - modcache_maintainer[$module] == or unset if the field's value is empty
1795 # Output if ! $have_associative:
1796 # - cachevar a shell variable name
1797 # - ${cachevar}_cached set to $module
1798 # - ${cachevar}_description ==
1799 # - ${cachevar}_status \ set to the field's value, minus the
1800 # - ... / final newline,
1801 # - ${cachevar}_maintainer == or unset if the field's value is empty
1802 # - ${cachevar}_description_set ==
1803 # - ${cachevar}_status_set \ set to non-empty if the field's value
1804 # - ... / is non-empty,
1805 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1806 func_cache_lookup_module ()
1808 if $have_associative; then
1809 eval 'cached=${modcache_cached[$1]}'
1810 else
1811 func_cache_var "$1"
1812 eval "cached=\"\$${cachevar}_cached\""
1814 if test -z "$cached"; then
1815 # Not found in cache. Look it up on the file system.
1816 func_lookup_file "modules/$1"
1817 if $have_associative; then
1818 eval 'modcache_cached[$1]=yes'
1819 else
1820 eval "${cachevar}_cached=\"\$1\""
1822 if ! $have_associative; then
1823 # sed_convert_to_cache_statements depends on the module.
1824 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1825 func_init_sed_convert_to_cache_statements
1827 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1828 eval "$cache_statements"
1829 else
1830 if ! $have_associative; then
1831 if test "$1" != "$cached"; then
1832 func_fatal_error "cache variable collision between $1 and $cached"
1840 # func_get_description module
1841 # Input:
1842 # - local_gnulib_dir from --local-dir
1843 # - modcache true or false, from --cache-modules/--no-cache-modules
1844 func_get_description ()
1846 if ! $modcache; then
1847 func_lookup_file "modules/$1"
1848 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1849 else
1850 func_cache_lookup_module "$1"
1851 # Output the field's value, including the final newline (if any).
1852 if $have_associative; then
1853 if eval 'test -n "${modcache_description[$1]+set}"'; then
1854 eval 'echo "${modcache_description[$1]}"'
1856 else
1857 eval "field_set=\"\$${cachevar}_description_set\""
1858 if test -n "$field_set"; then
1859 eval "field_value=\"\$${cachevar}_description\""
1860 echo "${field_value}"
1866 # func_get_comment module
1867 # Input:
1868 # - local_gnulib_dir from --local-dir
1869 # - modcache true or false, from --cache-modules/--no-cache-modules
1870 func_get_comment ()
1872 if ! $modcache; then
1873 func_lookup_file "modules/$1"
1874 sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
1875 else
1876 func_cache_lookup_module "$1"
1877 # Output the field's value, including the final newline (if any).
1878 if $have_associative; then
1879 if eval 'test -n "${modcache_comment[$1]+set}"'; then
1880 eval 'echo "${modcache_comment[$1]}"'
1882 else
1883 eval "field_set=\"\$${cachevar}_comment_set\""
1884 if test -n "$field_set"; then
1885 eval "field_value=\"\$${cachevar}_comment\""
1886 echo "${field_value}"
1892 # func_get_status module
1893 # Input:
1894 # - local_gnulib_dir from --local-dir
1895 # - modcache true or false, from --cache-modules/--no-cache-modules
1896 func_get_status ()
1898 if ! $modcache; then
1899 func_lookup_file "modules/$1"
1900 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1901 else
1902 func_cache_lookup_module "$1"
1903 # Output the field's value, including the final newline (if any).
1904 if $have_associative; then
1905 if eval 'test -n "${modcache_status[$1]+set}"'; then
1906 eval 'echo "${modcache_status[$1]}"'
1908 else
1909 eval "field_set=\"\$${cachevar}_status_set\""
1910 if test -n "$field_set"; then
1911 eval "field_value=\"\$${cachevar}_status\""
1912 echo "${field_value}"
1918 # func_get_notice module
1919 # Input:
1920 # - local_gnulib_dir from --local-dir
1921 # - modcache true or false, from --cache-modules/--no-cache-modules
1922 func_get_notice ()
1924 if ! $modcache; then
1925 func_lookup_file "modules/$1"
1926 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1927 else
1928 func_cache_lookup_module "$1"
1929 # Output the field's value, including the final newline (if any).
1930 if $have_associative; then
1931 if eval 'test -n "${modcache_notice[$1]+set}"'; then
1932 eval 'echo "${modcache_notice[$1]}"'
1934 else
1935 eval "field_set=\"\$${cachevar}_notice_set\""
1936 if test -n "$field_set"; then
1937 eval "field_value=\"\$${cachevar}_notice\""
1938 echo "${field_value}"
1944 # func_get_applicability module
1945 # Input:
1946 # - local_gnulib_dir from --local-dir
1947 # - modcache true or false, from --cache-modules/--no-cache-modules
1948 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1949 func_get_applicability ()
1951 if ! $modcache; then
1952 func_lookup_file "modules/$1"
1953 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1954 else
1955 func_cache_lookup_module "$1"
1956 # Get the field's value, without the final newline.
1957 if $have_associative; then
1958 eval 'my_applicability="${modcache_applicability[$1]}"'
1959 else
1960 eval "my_applicability=\"\$${cachevar}_applicability\""
1963 if test -n "$my_applicability"; then
1964 echo $my_applicability
1965 else
1966 # The default is 'main' or 'tests', depending on the module's name.
1967 case $1 in
1968 *-tests) echo "tests";;
1969 *) echo "main";;
1970 esac
1974 # func_get_filelist module
1975 # Input:
1976 # - local_gnulib_dir from --local-dir
1977 # - modcache true or false, from --cache-modules/--no-cache-modules
1978 func_get_filelist ()
1980 if ! $modcache; then
1981 func_lookup_file "modules/$1"
1982 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1983 else
1984 func_cache_lookup_module "$1"
1985 # Output the field's value, including the final newline (if any).
1986 if $have_associative; then
1987 if eval 'test -n "${modcache_files[$1]+set}"'; then
1988 eval 'echo "${modcache_files[$1]}"'
1990 else
1991 eval "field_set=\"\$${cachevar}_files_set\""
1992 if test -n "$field_set"; then
1993 eval "field_value=\"\$${cachevar}_files\""
1994 echo "${field_value}"
1998 echo m4/00gnulib.m4
1999 echo m4/gnulib-common.m4
2000 case "$autoconf_minversion" in
2001 2.59)
2002 echo m4/onceonly.m4
2004 esac
2007 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
2008 # stores in outputvar the filtered and processed filelist. Filtering: Only the
2009 # elements starting with prefix and ending with suffix are considered.
2010 # Processing: removed_prefix and removed_suffix are removed from each element,
2011 # added_prefix and added_suffix are added to each element.
2012 # prefix, suffix should not contain shell-special characters.
2013 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
2014 # added_prefix, added_suffix should not contain the characters \|&.
2015 func_filter_filelist ()
2017 if test "$2" != "$nl" \
2018 || { $fast_func_append \
2019 && { test -z "$6" || $fast_func_remove_prefix; } \
2020 && { test -z "$7" || $fast_func_remove_suffix; }; \
2021 }; then
2022 ffflist=
2023 for fff in $3; do
2024 # Do not quote possibly-empty parameters in case patterns,
2025 # AIX and HP-UX ksh won't match them if they are empty.
2026 case "$fff" in
2027 $4*$5)
2028 if test -n "$6"; then
2029 func_remove_prefix fff "$6"
2031 if test -n "$7"; then
2032 func_remove_suffix fff "$7"
2034 fff="$8${fff}$9"
2035 if test -z "$ffflist"; then
2036 ffflist="${fff}"
2037 else
2038 func_append ffflist "$2${fff}"
2041 esac
2042 done
2043 else
2044 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
2045 ffflist=`for fff in $3; do
2046 case "$fff" in
2047 $4*$5) echo "$fff" ;;
2048 esac
2049 done | sed -e "$sed_fff_filter"`
2051 eval "$1=\"\$ffflist\""
2054 # func_get_dependencies module
2055 # Input:
2056 # - local_gnulib_dir from --local-dir
2057 # - modcache true or false, from --cache-modules/--no-cache-modules
2058 func_get_dependencies ()
2060 # ${module}-tests implicitly depends on ${module}, if that module exists.
2061 case "$1" in
2062 *-tests)
2063 fgd1="$1"
2064 func_remove_suffix fgd1 '-tests'
2065 if func_exists_module "$fgd1"; then
2066 echo "$fgd1"
2069 esac
2070 # Then the explicit dependencies listed in the module description.
2071 if ! $modcache; then
2072 func_lookup_file "modules/$1"
2073 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
2074 else
2075 func_cache_lookup_module "$1"
2076 # Output the field's value, including the final newline (if any).
2077 if $have_associative; then
2078 if eval 'test -n "${modcache_dependson[$1]+set}"'; then
2079 eval 'echo "${modcache_dependson[$1]}"'
2081 else
2082 eval "field_set=\"\$${cachevar}_dependson_set\""
2083 if test -n "$field_set"; then
2084 eval "field_value=\"\$${cachevar}_dependson\""
2085 echo "${field_value}"
2091 # func_get_autoconf_early_snippet module
2092 # Input:
2093 # - local_gnulib_dir from --local-dir
2094 # - modcache true or false, from --cache-modules/--no-cache-modules
2095 func_get_autoconf_early_snippet ()
2097 if ! $modcache; then
2098 func_lookup_file "modules/$1"
2099 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
2100 else
2101 func_cache_lookup_module "$1"
2102 # Output the field's value, including the final newline (if any).
2103 if $have_associative; then
2104 if eval 'test -n "${modcache_configureac_early[$1]+set}"'; then
2105 eval 'echo "${modcache_configureac_early[$1]}"'
2107 else
2108 eval "field_set=\"\$${cachevar}_configureac_early_set\""
2109 if test -n "$field_set"; then
2110 eval "field_value=\"\$${cachevar}_configureac_early\""
2111 echo "${field_value}"
2117 # func_get_autoconf_snippet module
2118 # Input:
2119 # - local_gnulib_dir from --local-dir
2120 # - modcache true or false, from --cache-modules/--no-cache-modules
2121 func_get_autoconf_snippet ()
2123 if ! $modcache; then
2124 func_lookup_file "modules/$1"
2125 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
2126 else
2127 func_cache_lookup_module "$1"
2128 # Output the field's value, including the final newline (if any).
2129 if $have_associative; then
2130 if eval 'test -n "${modcache_configureac[$1]+set}"'; then
2131 eval 'echo "${modcache_configureac[$1]}"'
2133 else
2134 eval "field_set=\"\$${cachevar}_configureac_set\""
2135 if test -n "$field_set"; then
2136 eval "field_value=\"\$${cachevar}_configureac\""
2137 echo "${field_value}"
2143 # func_get_automake_snippet module
2144 # Input:
2145 # - local_gnulib_dir from --local-dir
2146 # - modcache true or false, from --cache-modules/--no-cache-modules
2147 func_get_automake_snippet ()
2149 if ! $modcache; then
2150 func_lookup_file "modules/$1"
2151 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2152 else
2153 func_cache_lookup_module "$1"
2154 # Output the field's value, including the final newline (if any).
2155 if $have_associative; then
2156 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2157 eval 'echo "${modcache_makefile[$1]}"'
2159 else
2160 eval "field_set=\"\$${cachevar}_makefile_set\""
2161 if test -n "$field_set"; then
2162 eval "field_value=\"\$${cachevar}_makefile\""
2163 echo "${field_value}"
2167 case "$1" in
2168 *-tests)
2169 # *-tests module live in tests/, not lib/.
2170 # Synthesize an EXTRA_DIST augmentation.
2171 all_files=`func_get_filelist $1`
2172 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
2173 extra_files="$tests_files"
2174 if test -n "$extra_files"; then
2175 echo "EXTRA_DIST +=" $extra_files
2176 echo
2180 # Synthesize an EXTRA_DIST augmentation.
2181 sed_combine_lines='/\\$/{
2184 s/\\\n/ /
2185 s/\\$/\\/
2188 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2189 already_mentioned_files=` \
2190 { if ! $modcache; then
2191 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2192 else
2193 if $have_associative; then
2194 if eval 'test -n "${modcache_makefile[$1]+set}"'; then
2195 eval 'echo "${modcache_makefile[$1]}"'
2197 else
2198 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2199 if test -n "$field_set"; then
2200 eval 'field_value="$'"${cachevar}"'_makefile"'
2201 echo "${field_value}"
2206 | sed -e "$sed_combine_lines" \
2207 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2208 all_files=`func_get_filelist $1`
2209 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2210 # Remove $already_mentioned_files from $lib_files.
2211 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2212 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2213 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2214 if test -n "$extra_files"; then
2215 echo "EXTRA_DIST +=" $extra_files
2216 echo
2218 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2219 # This is necessary so that automake can generate the right list of
2220 # dependency rules.
2221 # A possible approach would be to use autom4te --trace of the redefined
2222 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2223 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2224 # inside autoconf's built-in macros are not missed).
2225 # But it's simpler and more robust to do it here, based on the file list.
2226 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2227 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2228 # automake will generate a useless dependency; this is harmless.
2229 case "$1" in
2230 relocatable-prog-wrapper) ;;
2231 pt_chown) ;;
2233 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2234 if test -n "$extra_files"; then
2235 echo "EXTRA_lib_SOURCES +=" $extra_files
2236 echo
2239 esac
2240 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2241 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2242 if test -n "$buildaux_files"; then
2243 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2244 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2245 echo
2247 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2248 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2249 if test -n "$top_files"; then
2250 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2251 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2252 echo
2255 esac
2258 # func_get_include_directive module
2259 # Input:
2260 # - local_gnulib_dir from --local-dir
2261 # - modcache true or false, from --cache-modules/--no-cache-modules
2262 func_get_include_directive ()
2265 if ! $modcache; then
2266 func_lookup_file "modules/$1"
2267 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2268 else
2269 func_cache_lookup_module "$1"
2270 # Output the field's value, including the final newline (if any).
2271 if $have_associative; then
2272 if eval 'test -n "${modcache_include[$1]+set}"'; then
2273 eval 'echo "${modcache_include[$1]}"'
2275 else
2276 eval "field_set=\"\$${cachevar}_include_set\""
2277 if test -n "$field_set"; then
2278 eval "field_value=\"\$${cachevar}_include\""
2279 echo "${field_value}"
2283 } | sed -e 's/^\(["<]\)/#include \1/'
2286 # func_get_link_directive module
2287 # Input:
2288 # - local_gnulib_dir from --local-dir
2289 # - modcache true or false, from --cache-modules/--no-cache-modules
2290 func_get_link_directive ()
2292 if ! $modcache; then
2293 func_lookup_file "modules/$1"
2294 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2295 else
2296 func_cache_lookup_module "$1"
2297 # Output the field's value, including the final newline (if any).
2298 if $have_associative; then
2299 if eval 'test -n "${modcache_link[$1]+set}"'; then
2300 eval 'echo "${modcache_link[$1]}"'
2302 else
2303 eval "field_set=\"\$${cachevar}_link_set\""
2304 if test -n "$field_set"; then
2305 eval "field_value=\"\$${cachevar}_link\""
2306 echo "${field_value}"
2312 # func_get_license module
2313 # Input:
2314 # - local_gnulib_dir from --local-dir
2315 # - modcache true or false, from --cache-modules/--no-cache-modules
2316 func_get_license ()
2319 if ! $modcache; then
2320 func_lookup_file "modules/$1"
2321 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2322 else
2323 func_cache_lookup_module "$1"
2324 # Output the field's value, including the final newline (if any).
2325 if $have_associative; then
2326 if eval 'test -n "${modcache_license[$1]+set}"'; then
2327 eval 'echo "${modcache_license[$1]}"'
2329 else
2330 eval "field_set=\"\$${cachevar}_license_set\""
2331 if test -n "$field_set"; then
2332 eval "field_value=\"\$${cachevar}_license\""
2333 echo "${field_value}"
2337 # The default is GPL.
2338 echo "GPL"
2339 } | sed -e 's,^ *$,,' | sed -e 1q
2342 # func_get_maintainer module
2343 # Input:
2344 # - local_gnulib_dir from --local-dir
2345 # - modcache true or false, from --cache-modules/--no-cache-modules
2346 func_get_maintainer ()
2348 if ! $modcache; then
2349 func_lookup_file "modules/$1"
2350 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2351 else
2352 func_cache_lookup_module "$1"
2353 # Output the field's value, including the final newline (if any).
2354 if $have_associative; then
2355 if eval 'test -n "${modcache_maintainer[$1]+set}"'; then
2356 eval 'echo "${modcache_maintainer[$1]}"'
2358 else
2359 eval "field_set=\"\$${cachevar}_maintainer_set\""
2360 if test -n "$field_set"; then
2361 eval "field_value=\"\$${cachevar}_maintainer\""
2362 echo "${field_value}"
2368 # func_get_tests_module module
2369 # Input:
2370 # - local_gnulib_dir from --local-dir
2371 func_get_tests_module ()
2373 # The naming convention for tests modules is hardwired: ${module}-tests.
2374 if test -f "$gnulib_dir/modules/$1"-tests \
2375 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2376 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2377 echo "$1"-tests
2381 # func_acceptable module
2382 # tests whether a module is acceptable.
2383 # Input:
2384 # - avoidlist list of modules to avoid
2385 func_acceptable ()
2387 for avoid in $avoidlist; do
2388 if test "$avoid" = "$1"; then
2389 return 1
2391 done
2392 return 0
2395 # func_modules_transitive_closure
2396 # Input:
2397 # - local_gnulib_dir from --local-dir
2398 # - modcache true or false, from --cache-modules/--no-cache-modules
2399 # - modules list of specified modules
2400 # - inctests true if tests should be included, blank otherwise
2401 # - incobsolete true if obsolete modules among dependencies should be
2402 # included, blank otherwise
2403 # - inc_cxx_tests true if C++ interoperability tests should be included,
2404 # blank otherwise
2405 # - inc_longrunning_tests true if long-runnings tests should be included,
2406 # blank otherwise
2407 # - inc_privileged_tests true if tests that require root privileges should be
2408 # included, blank otherwise
2409 # - inc_unportable_tests true if tests that fail on some platforms should be
2410 # included, blank otherwise
2411 # - inc_all_direct_tests true if all kinds of problematic unit tests among
2412 # the unit tests of the specified modules should be
2413 # included, blank otherwise
2414 # - inc_all_indirect_tests true if all kinds of problematic unit tests among
2415 # the unit tests of the dependencies should be
2416 # included, blank otherwise
2417 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
2418 # blank otherwise
2419 # - excl_longrunning_tests true if long-runnings tests should be excluded,
2420 # blank otherwise
2421 # - excl_privileged_tests true if tests that require root privileges should be
2422 # excluded, blank otherwise
2423 # - excl_unportable_tests true if tests that fail on some platforms should be
2424 # excluded, blank otherwise
2425 # - avoidlist list of modules to avoid
2426 # - tmp pathname of a temporary directory
2427 # Output:
2428 # - modules list of modules, including dependencies
2429 func_modules_transitive_closure ()
2431 # In order to process every module only once (for speed), process an "input
2432 # list" of modules, producing an "output list" of modules. During each round,
2433 # more modules can be queued in the input list. Once a module on the input
2434 # list has been processed, it is added to the "handled list", so we can avoid
2435 # to process it again.
2436 handledmodules=
2437 inmodules="$modules"
2438 outmodules=
2439 fmtc_inc_all_tests="$inc_all_direct_tests"
2440 while test -n "$inmodules"; do
2441 inmodules_this_round="$inmodules"
2442 inmodules= # Accumulator, queue for next round
2443 for module in $inmodules_this_round; do
2444 func_verify_module
2445 if test -n "$module"; then
2446 if func_acceptable $module; then
2447 func_append outmodules " $module"
2448 deps=`func_get_dependencies $module`
2449 # Duplicate dependencies are harmless, but Jim wants a warning.
2450 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2451 if test -n "$duplicated_deps"; then
2452 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2454 if test -n "$inctests"; then
2455 testsmodule=`func_get_tests_module $module`
2456 if test -n "$testsmodule"; then
2457 deps="$deps $testsmodule"
2460 for dep in $deps; do
2461 # Determine whether to include the dependency or tests module.
2462 inc=true
2463 for word in `func_get_status $dep`; do
2464 case "$word" in
2465 obsolete)
2466 test -n "$incobsolete" \
2467 || inc=false
2469 c++-test)
2470 test -z "$excl_cxx_tests" \
2471 || inc=false
2472 test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \
2473 || inc=false
2475 longrunning-test)
2476 test -z "$excl_longrunning_tests" \
2477 || inc=false
2478 test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \
2479 || inc=false
2481 privileged-test)
2482 test -z "$excl_privileged_tests" \
2483 || inc=false
2484 test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \
2485 || inc=false
2487 unportable-test)
2488 test -z "$excl_unportable_tests" \
2489 || inc=false
2490 test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \
2491 || inc=false
2493 *-test)
2494 test -n "$fmtc_inc_all_tests" \
2495 || inc=false
2497 esac
2498 done
2499 if $inc; then
2500 func_append inmodules " $dep"
2502 done
2505 done
2506 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2507 # Remove $handledmodules from $inmodules.
2508 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2509 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2510 fmtc_inc_all_tests="$inc_all_indirect_tests"
2511 done
2512 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2513 rm -f "$tmp"/queued-modules
2516 # func_show_module_list
2517 # Input:
2518 # - specified_modules list of specified modules (one per line, sorted)
2519 # - modules complete list of modules (one per line, sorted)
2520 # - tmp pathname of a temporary directory
2521 func_show_module_list ()
2523 if case "$TERM" in
2524 xterm*) test -t 1;;
2525 *) false;;
2526 esac; then
2527 # Assume xterm compatible escape sequences.
2528 bold_on=`printf '\x1b[1m'`
2529 bold_off=`printf '\x1b[0m'`
2530 else
2531 bold_on=
2532 bold_off=
2534 echo "Module list with included dependencies (indented):"
2535 echo "$specified_modules" | sed -e '/^$/d' -e 's/$/| /' > "$tmp"/specified-modules
2536 echo "$modules" | sed -e '/^$/d' \
2537 | LC_ALL=C join -t '|' -a 2 "$tmp"/specified-modules - \
2538 | sed -e 's/^\(.*\)|.*/|\1/' -e 's/^/ /' -e 's/^ |\(.*\)$/ '"${bold_on}"'\1'"${bold_off}"'/'
2541 # func_modules_add_dummy
2542 # Input:
2543 # - local_gnulib_dir from --local-dir
2544 # - modcache true or false, from --cache-modules/--no-cache-modules
2545 # - modules list of modules, including dependencies
2546 # Output:
2547 # - modules list of modules, including 'dummy' if needed
2548 func_modules_add_dummy ()
2550 # Determine whether any module provides a lib_SOURCES augmentation.
2551 have_lib_SOURCES=
2552 sed_remove_backslash_newline=':a
2553 /\\$/{
2554 s/\\$//
2556 s/\n//
2559 for module in $modules; do
2560 func_verify_nontests_module
2561 if test -n "$module"; then
2562 # Extract the value of "lib_SOURCES += ...".
2563 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2564 # Ignore .h files since they are not compiled.
2565 case "$file" in
2566 *.h) ;;
2568 have_lib_SOURCES=yes
2569 break 2
2571 esac
2572 done
2574 done
2575 # Add the dummy module, to make sure the library will be non-empty.
2576 if test -z "$have_lib_SOURCES"; then
2577 if func_acceptable "dummy"; then
2578 func_append modules " dummy"
2583 # func_modules_notice
2584 # Input:
2585 # - local_gnulib_dir from --local-dir
2586 # - modcache true or false, from --cache-modules/--no-cache-modules
2587 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2588 # - modules list of modules, including dependencies
2589 func_modules_notice ()
2591 if test $verbose -ge -1; then
2592 for module in $modules; do
2593 func_verify_module
2594 if test -n "$module"; then
2595 msg=`func_get_notice $module`
2596 if test -n "$msg"; then
2597 echo "Notice from module $module:"
2598 echo "$msg" | sed -e 's/^/ /'
2601 done
2605 # func_modules_to_filelist
2606 # Input:
2607 # - local_gnulib_dir from --local-dir
2608 # - modcache true or false, from --cache-modules/--no-cache-modules
2609 # - modules list of modules, including dependencies
2610 # Output:
2611 # - files list of files
2612 func_modules_to_filelist ()
2614 files=
2615 for module in $modules; do
2616 func_verify_module
2617 if test -n "$module"; then
2618 fs=`func_get_filelist $module`
2619 func_append files " $fs"
2621 done
2622 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2625 # func_execute_command command [args...]
2626 # Executes a command.
2627 # Uses also the variables
2628 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2629 func_execute_command ()
2631 if test $verbose -ge 0; then
2632 echo "executing $*"
2633 "$@"
2634 else
2635 # Commands like automake produce output to stderr even when they succeed.
2636 # Turn this output off if the command succeeds.
2637 "$@" > "$tmp"/cmdout 2>&1
2638 cmdret=$?
2639 if test $cmdret = 0; then
2640 rm -f "$tmp"/cmdout
2641 else
2642 echo "executing $*"
2643 cat "$tmp"/cmdout 1>&2
2644 rm -f "$tmp"/cmdout
2645 (exit $cmdret)
2650 # func_dest_tmpfilename file
2651 # determines the name of a temporary file (file is relative to destdir).
2652 # Input:
2653 # - destdir target directory
2654 # - doit : if actions shall be executed, false if only to be printed
2655 # - tmp pathname of a temporary directory
2656 # Sets variable:
2657 # - tmpfile absolute filename of the temporary file
2658 func_dest_tmpfilename ()
2660 if $doit; then
2661 # Put the new contents of $file in a file in the same directory (needed
2662 # to guarantee that an 'mv' to "$destdir/$file" works).
2663 tmpfile="$destdir/$1.tmp"
2664 else
2665 # Put the new contents of $file in a file in a temporary directory
2666 # (because the directory of "$file" might not exist).
2667 tmpfile="$tmp"/`basename "$1"`.tmp
2671 # func_add_file
2672 # copies a file from gnulib into the destination directory. The destination
2673 # is known to not exist.
2674 # Input:
2675 # - destdir target directory
2676 # - local_gnulib_dir from --local-dir
2677 # - modcache true or false, from --cache-modules/--no-cache-modules
2678 # - f the original file name
2679 # - lookedup_file name of the merged (combined) file
2680 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2681 # - g the rewritten file name
2682 # - tmpfile absolute filename of the temporary file
2683 # - doit : if actions shall be executed, false if only to be printed
2684 # - symbolic true if files should be symlinked, copied otherwise
2685 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2686 # copied otherwise
2687 func_add_file ()
2689 if $doit; then
2690 echo "Copying file $g"
2691 if { test -n "$symbolic" \
2692 || { test -n "$lsymbolic" \
2693 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2694 && test -z "$lookedup_tmp" \
2695 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2696 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2697 else
2698 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2700 else
2701 echo "Copy file $g"
2705 # func_update_file
2706 # copies a file from gnulib into the destination directory. The destination
2707 # is known to exist.
2708 # Input:
2709 # - destdir target directory
2710 # - local_gnulib_dir from --local-dir
2711 # - modcache true or false, from --cache-modules/--no-cache-modules
2712 # - f the original file name
2713 # - lookedup_file name of the merged (combined) file
2714 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2715 # - g the rewritten file name
2716 # - tmpfile absolute filename of the temporary file
2717 # - doit : if actions shall be executed, false if only to be printed
2718 # - symbolic true if files should be symlinked, copied otherwise
2719 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2720 # copied otherwise
2721 # - already_present nonempty if the file should already exist, empty otherwise
2722 func_update_file ()
2724 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2725 : # The file has not changed.
2726 else
2727 # Replace the file.
2728 if $doit; then
2729 if test -n "$already_present"; then
2730 echo "Updating file $g (backup in ${g}~)"
2731 else
2732 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2734 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2735 if { test -n "$symbolic" \
2736 || { test -n "$lsymbolic" \
2737 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2738 && test -z "$lookedup_tmp" \
2739 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2740 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2741 else
2742 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2744 else
2745 if test -n "$already_present"; then
2746 echo "Update file $g (backup in ${g}~)"
2747 else
2748 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2754 # func_emit_lib_Makefile_am
2755 # emits the contents of library makefile to standard output.
2756 # Input:
2757 # - local_gnulib_dir from --local-dir
2758 # - modcache true or false, from --cache-modules/--no-cache-modules
2759 # - modules list of modules, including dependencies
2760 # - libname library name
2761 # - pobase directory relative to destdir where to place *.po files
2762 # - auxdir directory relative to destdir where to place build aux files
2763 # - makefile_name from --makefile-name
2764 # - libtool true if libtool will be used, false or blank otherwise
2765 # - macro_prefix prefix of gl_LIBOBJS macros to use
2766 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2767 # - actioncmd (optional) command that will reproduce this invocation
2768 # - for_test true if creating a package for testing, false otherwise
2769 # - destfile filename relative to destdir of makefile being generated
2770 # Input/Output:
2771 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2772 # list of edits to be done to Makefile.am variables
2773 # Output:
2774 # - uses_subdirs nonempty if object files in subdirs exist
2775 func_emit_lib_Makefile_am ()
2777 # When creating an includable Makefile.am snippet, augment variables with
2778 # += instead of assigning them.
2779 if test -n "$makefile_name"; then
2780 assign='+='
2781 else
2782 assign='='
2784 if test "$libtool" = true; then
2785 libext=la
2786 perhapsLT=LT
2787 sed_eliminate_LDFLAGS="$sed_noop"
2788 else
2789 libext=a
2790 perhapsLT=
2791 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2793 if $for_test; then
2794 # When creating a package for testing: Attempt to provoke failures,
2795 # especially link errors, already during "make" rather than during
2796 # "make check", because "make check" is not possible in a cross-compiling
2797 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2798 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2799 else
2800 sed_transform_check_PROGRAMS="$sed_noop"
2802 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2803 echo "## Process this file with automake to produce Makefile.in."
2804 func_emit_copyright_notice
2805 if test -n "$actioncmd"; then
2806 # The maximum line length (excluding the terminating newline) of any file
2807 # that is to be preprocessed by config.status is 3070. config.status uses
2808 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
2809 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
2810 len=`echo "$actioncmd" | wc -c`
2811 if test -n "$len" && test "$len" -le 3000; then
2812 echo "# Reproduce by: $actioncmd"
2815 echo
2816 uses_subdirs=
2818 for module in $modules; do
2819 func_verify_nontests_module
2820 if test -n "$module"; then
2822 func_get_automake_snippet "$module" |
2823 LC_ALL=C \
2824 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2825 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2826 -e "$sed_eliminate_LDFLAGS" \
2827 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
2828 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2829 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2830 -e "$sed_transform_check_PROGRAMS"
2831 if test "$module" = 'alloca'; then
2832 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2833 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2835 } > "$tmp"/amsnippet
2836 # Skip the contents if it's entirely empty.
2837 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2838 echo "## begin gnulib module $module"
2839 echo
2840 cat "$tmp"/amsnippet
2841 echo "## end gnulib module $module"
2842 echo
2844 rm -f "$tmp"/amsnippet
2845 # Test whether there are some source files in subdirectories.
2846 for f in `func_get_filelist "$module"`; do
2847 case $f in
2848 lib/*/*.c)
2849 uses_subdirs=yes
2850 break
2852 esac
2853 done
2855 done
2856 } > "$tmp"/allsnippets
2857 if test -z "$makefile_name"; then
2858 # If there are source files in subdirectories, prevent collision of the
2859 # object files (example: hash.c and libxml/hash.c).
2860 subdir_options=
2861 if test -n "$uses_subdirs"; then
2862 subdir_options=' subdir-objects'
2864 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2866 echo
2867 if test -z "$makefile_name"; then
2868 echo "SUBDIRS ="
2869 echo "noinst_HEADERS ="
2870 echo "noinst_LIBRARIES ="
2871 echo "noinst_LTLIBRARIES ="
2872 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2873 # if you specify pkgdata_DATA to empty. This is a workaround.
2874 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2875 echo "pkgdata_DATA ="
2877 echo "EXTRA_DIST ="
2878 echo "BUILT_SOURCES ="
2879 echo "SUFFIXES ="
2881 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2882 if test -z "$makefile_name"; then
2883 echo "MOSTLYCLEANDIRS ="
2884 echo "CLEANFILES ="
2885 echo "DISTCLEANFILES ="
2886 echo "MAINTAINERCLEANFILES ="
2888 # Execute edits that apply to the Makefile.am being generated.
2889 edit=0
2890 while test $edit != $makefile_am_edits; do
2891 edit=`expr $edit + 1`
2892 eval dir=\"\$makefile_am_edit${edit}_dir\"
2893 eval var=\"\$makefile_am_edit${edit}_var\"
2894 eval val=\"\$makefile_am_edit${edit}_val\"
2895 if test -n "$var"; then
2896 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2897 echo "${var} += ${val}"
2898 eval "makefile_am_edit${edit}_var="
2901 done
2902 if test -z "$makefile_name"; then
2903 echo
2904 if $for_test; then
2905 echo "AM_CPPFLAGS = -DGNULIB_STRICT_CHECKING=1"
2906 else
2907 echo "AM_CPPFLAGS ="
2909 echo "AM_CFLAGS ="
2911 echo
2912 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
2913 || { test -n "$makefile_name" \
2914 && test -f "$sourcebase/Makefile.am" \
2915 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2916 }; then
2917 # One of the snippets or the user's Makefile.am already specifies an
2918 # installation location for the library. Don't confuse automake by saying
2919 # it should not be installed.
2921 else
2922 # By default, the generated library should not be installed.
2923 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2925 echo
2926 echo "${libname}_${libext}_SOURCES ="
2927 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2928 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2929 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2930 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2931 echo "EXTRA_${libname}_${libext}_SOURCES ="
2932 if test "$libtool" = true; then
2933 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2934 echo "${libname}_${libext}_LDFLAGS += -no-undefined"
2935 # Synthesize an ${libname}_${libext}_LDFLAGS augmentation by combining
2936 # the link dependencies of all modules.
2937 for module in $modules; do
2938 func_verify_nontests_module
2939 if test -n "$module"; then
2940 func_get_link_directive "$module"
2942 done \
2943 | LC_ALL=C sed -e '/^$/d' -e 's/ when linking with libtool.*//' \
2944 | LC_ALL=C sort -u \
2945 | LC_ALL=C sed -e 's/^/'"${libname}_${libext}"'_LDFLAGS += /'
2947 echo
2948 if test -n "$pobase"; then
2949 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2950 echo
2952 cat "$tmp"/allsnippets \
2953 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2954 echo
2955 echo "mostlyclean-local: mostlyclean-generic"
2956 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2957 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2958 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2959 echo " fi; \\"
2960 echo " done; \\"
2961 echo " :"
2962 rm -f "$tmp"/allsnippets
2965 # func_emit_po_Makevars
2966 # emits the contents of po/ makefile parameterization to standard output.
2967 # Input:
2968 # - local_gnulib_dir from --local-dir
2969 # - modcache true or false, from --cache-modules/--no-cache-modules
2970 # - sourcebase directory relative to destdir where to place source code
2971 # - pobase directory relative to destdir where to place *.po files
2972 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2973 func_emit_po_Makevars ()
2975 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2976 func_emit_copyright_notice
2977 echo
2978 echo "# Usually the message domain is the same as the package name."
2979 echo "# But here it has a '-gnulib' suffix."
2980 echo "DOMAIN = ${po_domain}-gnulib"
2981 echo
2982 echo "# These two variables depend on the location of this directory."
2983 echo "subdir = ${pobase}"
2984 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2985 echo
2986 cat <<\EOF
2987 # These options get passed to xgettext.
2988 XGETTEXT_OPTIONS = \
2989 --keyword=_ --flag=_:1:pass-c-format \
2990 --keyword=N_ --flag=N_:1:pass-c-format \
2991 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2992 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2993 --flag=error:3:c-format --flag=error_at_line:5:c-format
2995 # This is the copyright holder that gets inserted into the header of the
2996 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2997 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2999 # This is the email address or URL to which the translators shall report
3000 # bugs in the untranslated strings:
3001 # - Strings which are not entire sentences, see the maintainer guidelines
3002 # in the GNU gettext documentation, section 'Preparing Strings'.
3003 # - Strings which use unclear terms or require additional context to be
3004 # understood.
3005 # - Strings which make invalid assumptions about notation of date, time or
3006 # money.
3007 # - Pluralisation problems.
3008 # - Incorrect English spelling.
3009 # - Incorrect formatting.
3010 # It can be your email address, or a mailing list address where translators
3011 # can write to without being subscribed, or the URL of a web page through
3012 # which the translators can contact you.
3013 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
3015 # This is the list of locale categories, beyond LC_MESSAGES, for which the
3016 # message catalogs shall be used. It is usually empty.
3017 EXTRA_LOCALE_CATEGORIES =
3019 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
3020 # context. Possible values are "yes" and "no". Set this to yes if the
3021 # package uses functions taking also a message context, like pgettext(), or
3022 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
3023 USE_MSGCTXT = no
3027 # func_emit_po_POTFILES_in
3028 # emits the file list to be passed to xgettext to standard output.
3029 # Input:
3030 # - local_gnulib_dir from --local-dir
3031 # - modcache true or false, from --cache-modules/--no-cache-modules
3032 # - sourcebase directory relative to destdir where to place source code
3033 # - files list of new files
3034 func_emit_po_POTFILES_in ()
3036 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3037 func_emit_copyright_notice
3038 echo
3039 echo "# List of files which contain translatable strings."
3040 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
3043 # func_emit_tests_Makefile_am witness_macro
3044 # emits the contents of tests makefile to standard output.
3045 # Input:
3046 # - local_gnulib_dir from --local-dir
3047 # - modcache true or false, from --cache-modules/--no-cache-modules
3048 # - modules list of modules, including dependencies
3049 # - libname library name
3050 # - auxdir directory relative to destdir where to place build aux files
3051 # - makefile_name from --makefile-name
3052 # - libtool true if libtool will be used, false or blank otherwise
3053 # - sourcebase relative directory containing lib source code
3054 # - m4base relative directory containing autoconf macros
3055 # - testsbase relative directory containing unit test code
3056 # - macro_prefix prefix of gl_LIBOBJS macros to use
3057 # - for_test true if creating a package for testing, false otherwise
3058 # - use_libtests true if a libtests.a should be built, false otherwise
3059 # - destfile filename relative to destdir of makefile being generated
3060 # Input/Output:
3061 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
3062 # list of edits to be done to Makefile.am variables
3063 # Output:
3064 # - uses_subdirs nonempty if object files in subdirs exist
3065 func_emit_tests_Makefile_am ()
3067 witness_macro="$1"
3068 if test "$libtool" = true; then
3069 libext=la
3070 sed_eliminate_LDFLAGS="$sed_noop"
3071 else
3072 libext=a
3073 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
3075 if $for_test; then
3076 # When creating a package for testing: Attempt to provoke failures,
3077 # especially link errors, already during "make" rather than during
3078 # "make check", because "make check" is not possible in a cross-compiling
3079 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
3080 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
3081 else
3082 sed_transform_check_PROGRAMS="$sed_noop"
3084 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
3085 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
3086 echo "## Process this file with automake to produce Makefile.in."
3087 func_emit_copyright_notice
3088 echo
3089 uses_subdirs=
3091 for module in $modules; do
3092 if $for_test; then
3093 func_verify_tests_module
3094 else
3095 func_verify_module
3097 if test -n "$module"; then
3099 func_get_automake_snippet "$module" |
3100 LC_ALL=C \
3101 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
3102 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
3103 -e "$sed_eliminate_LDFLAGS" \
3104 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
3105 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
3106 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
3107 -e "$sed_transform_check_PROGRAMS"
3108 if $use_libtests && test "$module" = 'alloca'; then
3109 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
3110 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
3112 } > "$tmp"/amsnippet
3113 # Skip the contents if it's entirely empty.
3114 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
3115 # Mention long-running tests at the end.
3116 ofd=3
3117 for word in `func_get_status "$module"`; do
3118 if test "$word" = 'longrunning-test'; then
3119 ofd=4
3120 break
3122 done
3123 { echo "## begin gnulib module $module"
3124 echo
3125 cat "$tmp"/amsnippet
3126 echo "## end gnulib module $module"
3127 echo
3128 } >&$ofd
3130 rm -f "$tmp"/amsnippet
3131 # Test whether there are some source files in subdirectories.
3132 for f in `func_get_filelist "$module"`; do
3133 case $f in
3134 lib/*/*.c | tests/*/*.c)
3135 uses_subdirs=yes
3136 break
3138 esac
3139 done
3141 done
3142 } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
3143 # Generate dependencies here, since it eases the debugging of test failures.
3144 # If there are source files in subdirectories, prevent collision of the
3145 # object files (example: hash.c and libxml/hash.c).
3146 subdir_options=
3147 if test -n "$uses_subdirs"; then
3148 subdir_options=' subdir-objects'
3150 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
3151 echo
3152 if $for_test; then
3153 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
3154 echo
3156 # Nothing is being added to SUBDIRS; nevertheless the existence of this
3157 # variable is needed to avoid an error from automake:
3158 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
3159 echo "SUBDIRS = ."
3160 echo "TESTS ="
3161 echo "XFAIL_TESTS ="
3162 echo "TESTS_ENVIRONMENT ="
3163 echo "noinst_PROGRAMS ="
3164 if ! $for_test; then
3165 echo "check_PROGRAMS ="
3167 echo "noinst_HEADERS ="
3168 echo "noinst_LIBRARIES ="
3169 if $use_libtests; then
3170 if $for_test; then
3171 echo "noinst_LIBRARIES += libtests.a"
3172 else
3173 echo "check_LIBRARIES = libtests.a"
3176 # Automake versions < 1.9b create an empty pkgdatadir at installation time
3177 # if you specify pkgdata_DATA to empty. This is a workaround.
3178 if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
3179 echo "pkgdata_DATA ="
3181 echo "EXTRA_DIST ="
3182 echo "BUILT_SOURCES ="
3183 echo "SUFFIXES ="
3184 echo "MOSTLYCLEANFILES = core *.stackdump"
3185 echo "MOSTLYCLEANDIRS ="
3186 echo "CLEANFILES ="
3187 echo "DISTCLEANFILES ="
3188 echo "MAINTAINERCLEANFILES ="
3189 # Execute edits that apply to the Makefile.am being generated.
3190 edit=0
3191 while test $edit != $makefile_am_edits; do
3192 edit=`expr $edit + 1`
3193 eval dir=\"\$makefile_am_edit${edit}_dir\"
3194 eval var=\"\$makefile_am_edit${edit}_var\"
3195 eval val=\"\$makefile_am_edit${edit}_val\"
3196 if test -n "$var"; then
3197 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
3198 echo "${var} += ${val}"
3199 eval "makefile_am_edit${edit}_var="
3202 done
3203 echo
3204 echo "AM_CPPFLAGS = \\"
3205 if $for_test; then
3206 echo " -DGNULIB_STRICT_CHECKING=1 \\"
3208 if test -n "${witness_macro}"; then
3209 echo " -D@${witness_macro}@=1 \\"
3211 echo " -I. -I\$(srcdir) \\"
3212 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
3213 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
3214 echo
3215 local_ldadd_before=''
3216 local_ldadd_after=''
3217 if $use_libtests; then
3218 # All test programs need to be linked with libtests.a.
3219 # It needs to be passed to the linker before ${libname}.${libext}, since
3220 # the tests-related modules depend on the main modules.
3221 # It also needs to be passed to the linker after ${libname}.${libext}
3222 # because the latter might contain incomplete modules (such as the 'error'
3223 # module whose dependency to 'progname' is voluntarily omitted).
3224 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
3225 # not matter.
3226 local_ldadd_before=' libtests.a'
3227 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
3229 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
3230 echo
3231 if $use_libtests; then
3232 echo "libtests_a_SOURCES ="
3233 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
3234 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
3235 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
3236 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
3237 echo "EXTRA_libtests_a_SOURCES ="
3238 # The circular dependency in LDADD requires this.
3239 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
3240 echo
3242 # Many test scripts use ${EXEEXT} or ${srcdir}.
3243 # EXEEXT is defined by AC_PROG_CC through autoconf.
3244 # srcdir is defined by autoconf and automake.
3245 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
3246 echo
3247 cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
3248 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
3249 echo "# Clean up after Solaris cc."
3250 echo "clean-local:"
3251 echo " rm -rf SunWS_cache"
3252 echo
3253 echo "mostlyclean-local: mostlyclean-generic"
3254 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
3255 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
3256 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
3257 echo " fi; \\"
3258 echo " done; \\"
3259 echo " :"
3260 rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
3263 # func_emit_initmacro_start macro_prefix
3264 # emits the first few statements of the gl_INIT macro to standard output.
3265 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3266 func_emit_initmacro_start ()
3268 macro_prefix_arg="$1"
3269 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
3270 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
3271 # LIBOBJS. The purpose is to allow several gnulib instantiations under
3272 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
3273 # flexibility.)
3274 # Furthermore it avoids an automake error like this when a Makefile.am
3275 # that uses pieces of gnulib also uses $(LIBOBJ):
3276 # automatically discovered file `error.c' should not be explicitly mentioned
3277 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
3278 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
3279 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
3280 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
3281 # automatically discovered file `error.c' should not be explicitly mentioned
3282 # We let automake know about the files to be distributed through the
3283 # EXTRA_lib_SOURCES variable.
3284 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
3285 # Create data variables for checking the presence of files that are mentioned
3286 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
3287 # because we want the check to happen when the configure file is created,
3288 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
3289 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3290 # in which to expect them.
3291 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3292 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3293 echo " gl_COMMON"
3296 # func_emit_initmacro_end macro_prefix
3297 # emits the last few statements of the gl_INIT macro to standard output.
3298 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3299 func_emit_initmacro_end ()
3301 macro_prefix_arg="$1"
3302 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3303 # The check is performed only when autoconf is run from the directory where
3304 # the configure.ac resides; if it is run from a different directory, the
3305 # check is skipped.
3306 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3307 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3308 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3309 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3310 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3311 echo " exit 1"
3312 echo " fi"
3313 echo " done])dnl"
3314 echo " m4_if(m4_sysval, [0], [],"
3315 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3316 echo " ])"
3317 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3318 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3319 echo " m4_popdef([AC_LIBSOURCES])"
3320 echo " m4_popdef([AC_REPLACE_FUNCS])"
3321 echo " m4_popdef([AC_LIBOBJ])"
3322 echo " AC_CONFIG_COMMANDS_PRE(["
3323 echo " ${macro_prefix_arg}_libobjs="
3324 echo " ${macro_prefix_arg}_ltlibobjs="
3325 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3326 echo " # Remove the extension."
3327 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3328 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3329 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3330 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3331 echo " done"
3332 echo " fi"
3333 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3334 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3335 echo " ])"
3338 # func_emit_initmacro_done macro_prefix sourcebase
3339 # emits a few statements after the gl_INIT macro to standard output.
3340 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3341 # - sourcebase directory relative to destdir where to place source code
3342 func_emit_initmacro_done ()
3344 macro_prefix_arg="$1"
3345 sourcebase_arg="$2"
3346 echo
3347 echo "# Like AC_LIBOBJ, except that the module name goes"
3348 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3349 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3350 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3351 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3352 echo "])"
3353 echo
3354 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3355 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3356 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3357 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3358 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3359 echo "])"
3360 echo
3361 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3362 echo "# expected is derived from the gnulib-tool parameterization,"
3363 echo "# and alloca is special cased (for the alloca-opt module)."
3364 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3365 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3366 echo " m4_foreach([_gl_NAME], [\$1], ["
3367 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3368 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3369 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3370 echo " ])"
3371 echo " ])"
3372 echo "])"
3375 # func_import modules
3376 # Uses also the variables
3377 # - mode import or add-import or remove-import or update
3378 # - destdir target directory
3379 # - local_gnulib_dir from --local-dir
3380 # - modcache true or false, from --cache-modules/--no-cache-modules
3381 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3382 # - libname library name
3383 # - supplied_libname true if --lib was given, blank otherwise
3384 # - sourcebase directory relative to destdir where to place source code
3385 # - m4base directory relative to destdir where to place *.m4 macros
3386 # - pobase directory relative to destdir where to place *.po files
3387 # - docbase directory relative to destdir where to place doc files
3388 # - testsbase directory relative to destdir where to place unit test code
3389 # - auxdir directory relative to destdir where to place build aux files
3390 # - inctests true if --with-tests was given, blank otherwise
3391 # - incobsolete true if --with-obsolete was given, blank otherwise
3392 # - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
3393 # - inc_longrunning_tests true if --with-longrunning-tests was given, blank
3394 # otherwise
3395 # - inc_privileged_tests true if --with-privileged-tests was given, blank
3396 # otherwise
3397 # - inc_unportable_tests true if --with-unportable-tests was given, blank
3398 # otherwise
3399 # - inc_all_tests true if --with-all-tests was given, blank otherwise
3400 # - avoidlist list of modules to avoid, from --avoid
3401 # - lgpl yes or a number if library's license shall be LGPL,
3402 # blank otherwise
3403 # - makefile_name from --makefile-name
3404 # - libtool true if --libtool was given, false if --no-libtool was
3405 # given, blank otherwise
3406 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
3407 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3408 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3409 # - vc_files true if --vc-files was given, false if --no-vc-files was
3410 # given, blank otherwise
3411 # - autoconf_minversion minimum supported autoconf version
3412 # - doit : if actions shall be executed, false if only to be printed
3413 # - symbolic true if files should be symlinked, copied otherwise
3414 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3415 # copied otherwise
3416 # - do_copyrights true if copyright notices in files should be replaced,
3417 # blank otherwise
3418 func_import ()
3420 # Get the cached settings.
3421 # In 'import' mode, we read them only for the purpose of knowing the old
3422 # installed file list, and don't use them as defaults.
3423 cached_local_gnulib_dir=
3424 cached_specified_modules=
3425 cached_incobsolete=
3426 cached_inc_cxx_tests=
3427 cached_inc_longrunning_tests=
3428 cached_inc_privileged_tests=
3429 cached_inc_unportable_tests=
3430 cached_inc_all_tests=
3431 cached_avoidlist=
3432 cached_sourcebase=
3433 cached_m4base=
3434 cached_pobase=
3435 cached_docbase=
3436 cached_testsbase=
3437 cached_inctests=
3438 cached_libname=
3439 cached_lgpl=
3440 cached_makefile_name=
3441 cached_libtool=
3442 cached_macro_prefix=
3443 cached_po_domain=
3444 cached_vc_files=
3445 cached_files=
3446 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3447 cached_libtool=false
3448 my_sed_traces='
3449 s,#.*$,,
3450 s,^dnl .*$,,
3451 s, dnl .*$,,
3452 /gl_LOCAL_DIR(/ {
3453 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
3455 /gl_MODULES(/ {
3458 s/)/)/
3463 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
3465 /gl_WITH_OBSOLETE/ {
3466 s,^.*$,cached_incobsolete=true,p
3468 /gl_WITH_CXX_TESTS/ {
3469 s,^.*$,cached_inc_cxx_tests=true,p
3471 /gl_WITH_LONGRUNNING_TESTS/ {
3472 s,^.*$,cached_inc_longrunning_tests=true,p
3474 /gl_WITH_PRIVILEGED_TESTS/ {
3475 s,^.*$,cached_inc_privileged_tests=true,p
3477 /gl_WITH_UNPORTABLE_TESTS/ {
3478 s,^.*$,cached_inc_unportable_tests=true,p
3480 /gl_WITH_ALL_TESTS/ {
3481 s,^.*$,cached_inc_all_tests=true,p
3483 /gl_AVOID(/ {
3484 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
3486 /gl_SOURCE_BASE(/ {
3487 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
3489 /gl_M4_BASE(/ {
3490 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
3492 /gl_PO_BASE(/ {
3493 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
3495 /gl_DOC_BASE(/ {
3496 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
3498 /gl_TESTS_BASE(/ {
3499 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
3501 /gl_WITH_TESTS/ {
3502 s,^.*$,cached_inctests=true,p
3504 /gl_LIB(/ {
3505 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
3507 /gl_LGPL(/ {
3508 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
3510 /gl_LGPL/ {
3511 s,^.*$,cached_lgpl=yes,p
3513 /gl_MAKEFILE_NAME(/ {
3514 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
3516 /gl_LIBTOOL/ {
3517 s,^.*$,cached_libtool=true,p
3519 /gl_MACRO_PREFIX(/ {
3520 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
3522 /gl_PO_DOMAIN(/ {
3523 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
3525 /gl_VC_FILES(/ {
3526 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
3528 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
3529 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3530 my_sed_traces='
3531 s,#.*$,,
3532 s,^dnl .*$,,
3533 s, dnl .*$,,
3534 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
3535 s,^.*$,cached_files=",p
3539 s,^\]).*$,",
3541 s,["$`\\],,g
3548 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
3552 if test "$mode" = import; then
3553 # In 'import' mode, the new set of specified modules overrides the cached
3554 # set of modules. Ignore the cached settings.
3555 specified_modules="$1"
3556 else
3557 # Merge the cached settings with the specified ones.
3558 # The m4base must be the same as expected from the pathname.
3559 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
3560 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
3562 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
3563 # is relative to $destdir, whereas the one we use is relative to . or absolute.
3564 if test -z "$local_gnulib_dir"; then
3565 if test -n "$cached_local_gnulib_dir"; then
3566 case "$destdir" in
3568 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3570 case "$cached_local_gnulib_dir" in
3572 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3574 func_relconcat "$destdir" "$cached_local_gnulib_dir"
3575 local_gnulib_dir="$relconcat" ;;
3576 esac ;;
3577 esac
3580 case $mode in
3581 add-import)
3582 # Append the cached and the specified module names. So that
3583 # "gnulib-tool --add-import foo" means to add the module foo.
3584 specified_modules="$cached_specified_modules $1"
3586 remove-import)
3587 # Take the cached module names, minus the specified module names.
3588 specified_modules=
3589 if $have_associative; then
3590 # Use an associative array, for O(N) worst-case run time.
3591 declare -A to_remove
3592 for m in $1; do
3593 eval 'to_remove[$m]=yes'
3594 done
3595 for module in $cached_specified_modules; do
3596 if eval 'test -z "${to_remove[$module]}"'; then
3597 func_append specified_modules "$module "
3599 done
3600 else
3601 # This loop has O(N²) worst-case run time.
3602 for module in $cached_specified_modules; do
3603 to_remove=
3604 for m in $1; do
3605 if test "$m" = "$module"; then
3606 to_remove=yes
3607 break
3609 done
3610 if test -z "$to_remove"; then
3611 func_append specified_modules "$module "
3613 done
3616 update)
3617 # Take the cached module names. There are no specified module names.
3618 specified_modules="$cached_specified_modules"
3620 esac
3621 # Included obsolete modules among the dependencies if specified either way.
3622 if test -z "$incobsolete"; then
3623 incobsolete="$cached_incobsolete"
3625 # Included special kinds of tests modules among the dependencies if specified
3626 # either way.
3627 if test -z "$inc_cxx_tests"; then
3628 inc_cxx_tests="$cached_inc_cxx_tests"
3630 if test -z "$inc_longrunning_tests"; then
3631 inc_longrunning_tests="$cached_inc_longrunning_tests"
3633 if test -z "$inc_privileged_tests"; then
3634 inc_privileged_tests="$cached_inc_privileged_tests"
3636 if test -z "$inc_unportable_tests"; then
3637 inc_unportable_tests="$cached_inc_unportable_tests"
3639 if test -z "$inc_all_tests"; then
3640 inc_all_tests="$cached_inc_all_tests"
3642 # Append the cached and the specified avoidlist. This is probably better
3643 # than dropping the cached one when --avoid is specified at least once.
3644 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
3645 avoidlist=`echo $avoidlist`
3647 # The sourcebase defaults to the cached one.
3648 if test -z "$sourcebase"; then
3649 sourcebase="$cached_sourcebase"
3650 if test -z "$sourcebase"; then
3651 func_fatal_error "missing --source-base option"
3654 # The pobase defaults to the cached one.
3655 if test -z "$pobase"; then
3656 pobase="$cached_pobase"
3658 # The docbase defaults to the cached one.
3659 if test -z "$docbase"; then
3660 docbase="$cached_docbase"
3661 if test -z "$docbase"; then
3662 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."
3665 # The testsbase defaults to the cached one.
3666 if test -z "$testsbase"; then
3667 testsbase="$cached_testsbase"
3668 if test -z "$testsbase"; then
3669 func_fatal_error "missing --tests-base option"
3672 # Require the tests if specified either way.
3673 if test -z "$inctests"; then
3674 inctests="$cached_inctests"
3676 # The libname defaults to the cached one.
3677 if test -z "$supplied_libname"; then
3678 libname="$cached_libname"
3679 if test -z "$libname"; then
3680 func_fatal_error "missing --lib option"
3683 # Require LGPL if specified either way.
3684 if test -z "$lgpl"; then
3685 lgpl="$cached_lgpl"
3687 # The makefile_name defaults to the cached one.
3688 if test -z "$makefile_name"; then
3689 makefile_name="$cached_makefile_name"
3691 # Use libtool if specified either way, or if guessed.
3692 if test -z "$libtool"; then
3693 if test -n "$cached_m4base"; then
3694 libtool="$cached_libtool"
3695 else
3696 libtool="$guessed_libtool"
3699 # The macro_prefix defaults to the cached one.
3700 if test -z "$macro_prefix"; then
3701 macro_prefix="$cached_macro_prefix"
3702 if test -z "$macro_prefix"; then
3703 func_fatal_error "missing --macro-prefix option"
3706 # The po_domain defaults to the cached one.
3707 if test -z "$po_domain"; then
3708 po_domain="$cached_po_domain"
3710 # The vc_files defaults to the cached one.
3711 if test -z "$vc_files"; then
3712 vc_files="$cached_vc_files"
3715 # --without-*-tests options are not supported here.
3716 excl_cxx_tests=
3717 excl_longrunning_tests=
3718 excl_privileged_tests=
3719 excl_unportable_tests=
3721 # Canonicalize the list of specified modules.
3722 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
3724 # Include all kinds of tests modules if --with-all-tests was specified.
3725 inc_all_direct_tests="$inc_all_tests"
3726 inc_all_indirect_tests="$inc_all_tests"
3728 # Determine final module list.
3729 modules="$specified_modules"
3730 func_modules_transitive_closure
3731 if test $verbose -ge 0; then
3732 func_show_module_list
3734 final_modules="$modules"
3736 # Determine main module list and tests-related module list separately.
3737 # The main module list is the transitive closure of the specified modules,
3738 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3739 # is specified, it will consist only of LGPLed source.
3740 # The tests-related module list is the transitive closure of the specified
3741 # modules, including tests modules, minus the main module list excluding
3742 # modules of applicability 'all'. Its lib/* sources (brought in through
3743 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3744 # source, even if --lgpl is specified.
3745 # Determine main module list.
3746 saved_inctests="$inctests"
3747 inctests=""
3748 modules="$specified_modules"
3749 func_modules_transitive_closure
3750 main_modules="$modules"
3751 inctests="$saved_inctests"
3752 if test $verbose -ge 1; then
3753 echo "Main module list:"
3754 echo "$main_modules" | sed -e 's/^/ /'
3756 # Determine tests-related module list.
3757 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3758 testsrelated_modules=`for module in $main_modules; do
3759 if test \`func_get_applicability $module\` = main; then
3760 echo $module
3762 done \
3763 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3764 if test $verbose -ge 1; then
3765 echo "Tests-related module list:"
3766 echo "$testsrelated_modules" | sed -e 's/^/ /'
3769 # Add the dummy module to the main module list if needed.
3770 modules="$main_modules"
3771 func_modules_add_dummy
3772 main_modules="$modules"
3774 # Determine whether a $testsbase/libtests.a is needed.
3775 use_libtests=false
3776 for module in $testsrelated_modules; do
3777 func_verify_nontests_module
3778 if test -n "$module"; then
3779 all_files=`func_get_filelist $module`
3780 # Test whether some file in $all_files lies in lib/.
3781 for f in $all_files; do
3782 case $f in
3783 lib/*)
3784 use_libtests=true
3785 break 2
3787 esac
3788 done
3790 done
3792 # Add the dummy module to the tests-related module list if needed.
3793 if $use_libtests; then
3794 modules="$testsrelated_modules"
3795 func_modules_add_dummy
3796 testsrelated_modules="$modules"
3799 # If --lgpl, verify that the licenses of modules are compatible.
3800 if test -n "$lgpl"; then
3801 license_incompatibilities=
3802 for module in $main_modules; do
3803 license=`func_get_license $module`
3804 case $license in
3805 'GPLed build tool') ;;
3806 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3808 case "$lgpl" in
3809 yes | 3)
3810 case $license in
3811 LGPL | LGPLv2+ | LGPLv3+) ;;
3812 *) func_append license_incompatibilities "$module $license$nl" ;;
3813 esac
3816 case $license in
3817 LGPLv2+) ;;
3818 *) func_append license_incompatibilities "$module $license$nl" ;;
3819 esac
3821 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3822 esac
3824 esac
3825 done
3826 if test -n "$license_incompatibilities"; then
3827 # Format the license incompatibilities as a table.
3828 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
3829 s,^\(.................................................[^ ]*\) *, \1 ,'
3830 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
3831 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
3835 # Show banner notice of every module.
3836 modules="$main_modules"
3837 func_modules_notice
3839 # Determine script to apply to imported library files.
3840 sed_transform_lib_file=
3841 for module in $main_modules; do
3842 if test $module = config-h; then
3843 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
3844 sed_transform_lib_file=$sed_transform_lib_file'
3845 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
3847 break
3849 done
3850 sed_transform_main_lib_file="$sed_transform_lib_file"
3851 if test -n "$do_copyrights"; then
3852 if test -n "$lgpl"; then
3853 # Update license.
3854 case "$lgpl" in
3855 yes | 3)
3856 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3857 s/GNU General/GNU Lesser General/g
3861 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3862 s/GNU General/GNU Lesser General/g
3863 s/version [23]\([ ,]\)/version 2.1\1/g
3866 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3867 esac
3868 else
3869 # Update license.
3870 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3871 s/GNU Lesser General/GNU General/g
3872 s/GNU Library General/GNU General/g
3873 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3878 # Determine script to apply to auxiliary files that go into $auxdir/.
3879 sed_transform_build_aux_file=
3880 if test -n "$do_copyrights"; then
3881 # Update license.
3882 sed_transform_build_aux_file=$sed_transform_build_aux_file'
3883 s/GNU Lesser General/GNU General/g
3884 s/GNU Library General/GNU General/g
3885 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3889 # Determine script to apply to library files that go into $testsbase/.
3890 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
3891 if test -n "$do_copyrights"; then
3892 # Update license.
3893 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
3894 s/GNU Lesser General/GNU General/g
3895 s/GNU Library General/GNU General/g
3896 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3900 # Determine the final file lists.
3901 # They must be computed separately, because files in lib/* go into
3902 # $sourcebase/ if they are in the main file list but into $testsbase/
3903 # if they are in the tests-related file list. Furthermore lib/dummy.c
3904 # can be in both.
3905 # Determine final main file list.
3906 modules="$main_modules"
3907 func_modules_to_filelist
3908 main_files="$files"
3909 # Determine final tests-related file list.
3910 modules="$testsrelated_modules"
3911 func_modules_to_filelist
3912 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3913 # Merge both file lists.
3914 sed_remove_empty_lines='/^$/d'
3915 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3916 if test $verbose -ge 0; then
3917 echo "File list:"
3918 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3919 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3922 test -n "$files" \
3923 || func_fatal_error "refusing to do nothing"
3925 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
3926 new_files="$files m4/gnulib-tool.m4"
3927 old_files="$cached_files"
3928 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
3929 func_append old_files " m4/gnulib-tool.m4"
3932 rewritten='%REWRITTEN%'
3933 sed_rewrite_old_files="\
3934 s,^build-aux/,$rewritten$auxdir/,
3935 s,^doc/,$rewritten$cached_docbase/,
3936 s,^lib/,$rewritten$cached_sourcebase/,
3937 s,^m4/,$rewritten$cached_m4base/,
3938 s,^tests/,$rewritten$cached_testsbase/,
3939 s,^tests=lib/,$rewritten$cached_testsbase/,
3940 s,^top/,$rewritten,
3941 s,^$rewritten,,"
3942 sed_rewrite_new_files="\
3943 s,^build-aux/,$rewritten$auxdir/,
3944 s,^doc/,$rewritten$docbase/,
3945 s,^lib/,$rewritten$sourcebase/,
3946 s,^m4/,$rewritten$m4base/,
3947 s,^tests/,$rewritten$testsbase/,
3948 s,^tests=lib/,$rewritten$testsbase/,
3949 s,^top/,$rewritten,
3950 s,^$rewritten,,"
3952 # Create directories.
3953 { echo "$sourcebase"
3954 echo "$m4base"
3955 if test -n "$pobase"; then
3956 echo "$pobase"
3958 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
3959 if test -n "$docfiles"; then
3960 echo "$docbase"
3962 if test -n "$inctests"; then
3963 echo "$testsbase"
3965 echo "$auxdir"
3966 for f in $files; do echo $f; done \
3967 | sed -e "$sed_rewrite_new_files" \
3968 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3969 | LC_ALL=C sort -u
3970 } > "$tmp"/dirs
3971 { # Rearrange file descriptors. Needed because "while ... done < ..."
3972 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3973 exec 5<&0 < "$tmp"/dirs
3974 while read d; do
3975 if test ! -d "$destdir/$d"; then
3976 if $doit; then
3977 echo "Creating directory $destdir/$d"
3978 mkdir -p "$destdir/$d" || func_fatal_error "failed"
3979 else
3980 echo "Create directory $destdir/$d"
3983 done
3984 exec 0<&5 5<&-
3987 # Copy files or make symbolic links. Remove obsolete files.
3988 added_files=''
3989 removed_files=''
3990 delimiter=' '
3991 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3992 # representing the files according to the last gnulib-tool invocation.
3993 for f in $old_files; do echo $f; done \
3994 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
3995 | LC_ALL=C sort \
3996 > "$tmp"/old-files
3997 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3998 # representing the files after this gnulib-tool invocation.
3999 for f in $new_files; do echo $f; done \
4000 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
4001 | LC_ALL=C sort \
4002 > "$tmp"/new-files
4003 # First the files that are in old-files, but not in new-files:
4004 sed_take_first_column='s,'"$delimiter"'.*,,'
4005 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
4006 # Remove the file. Do nothing if the user already removed it.
4007 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
4008 if $doit; then
4009 echo "Removing file $g (backup in ${g}~)"
4010 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
4011 else
4012 echo "Remove file $g (backup in ${g}~)"
4014 func_append removed_files "$g$nl"
4016 done
4017 # func_add_or_update handles a file that ought to be present afterwards.
4018 # Uses parameters
4019 # - f the original file name
4020 # - g the rewritten file name
4021 # - already_present nonempty if the file should already exist, empty
4022 # otherwise
4023 func_add_or_update ()
4025 of="$f"
4026 case "$f" in
4027 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
4028 esac
4029 func_dest_tmpfilename "$g"
4030 func_lookup_file "$f"
4031 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
4032 if test -n "$sed_transform_main_lib_file"; then
4033 case "$of" in
4034 lib/*)
4035 sed -e "$sed_transform_main_lib_file" \
4036 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4038 esac
4040 if test -n "$sed_transform_build_aux_file"; then
4041 case "$of" in
4042 build-aux/*)
4043 sed -e "$sed_transform_build_aux_file" \
4044 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4046 esac
4048 if test -n "$sed_transform_testsrelated_lib_file"; then
4049 case "$of" in
4050 tests=lib/*)
4051 sed -e "$sed_transform_testsrelated_lib_file" \
4052 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
4054 esac
4056 if test -f "$destdir/$g"; then
4057 # The file already exists.
4058 func_update_file
4059 else
4060 # Install the file.
4061 # Don't protest if the file should be there but isn't: it happens
4062 # frequently that developers don't put autogenerated files under version control.
4063 func_add_file
4064 func_append added_files "$g$nl"
4066 rm -f "$tmpfile"
4068 # Then the files that are in new-files, but not in old-files:
4069 sed_take_last_column='s,^.*'"$delimiter"',,'
4070 already_present=
4071 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
4072 | sed -e "$sed_take_last_column" \
4073 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
4074 { # Rearrange file descriptors. Needed because "while ... done < ..."
4075 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4076 exec 5<&0 < "$tmp"/added-files
4077 while read g f; do
4078 func_add_or_update
4079 done
4080 exec 0<&5 5<&-
4082 # Then the files that are in new-files and in old-files:
4083 already_present=true
4084 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
4085 | sed -e "$sed_take_last_column" \
4086 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
4087 { # Rearrange file descriptors. Needed because "while ... done < ..."
4088 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4089 exec 5<&0 < "$tmp"/kept-files
4090 while read g f; do
4091 func_add_or_update
4092 done
4093 exec 0<&5 5<&-
4096 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
4097 actioncmd="gnulib-tool --import"
4098 func_append actioncmd " --dir=$destdir"
4099 if test -n "$local_gnulib_dir"; then
4100 func_append actioncmd " --local-dir=$local_gnulib_dir"
4102 func_append actioncmd " --lib=$libname"
4103 func_append actioncmd " --source-base=$sourcebase"
4104 func_append actioncmd " --m4-base=$m4base"
4105 if test -n "$pobase"; then
4106 func_append actioncmd " --po-base=$pobase"
4108 func_append actioncmd " --doc-base=$docbase"
4109 func_append actioncmd " --tests-base=$testsbase"
4110 func_append actioncmd " --aux-dir=$auxdir"
4111 if test -n "$inctests"; then
4112 func_append actioncmd " --with-tests"
4114 if test -n "$incobsolete"; then
4115 func_append actioncmd " --with-obsolete"
4117 if test -n "$inc_cxx_tests"; then
4118 func_append actioncmd " --with-c++-tests"
4120 if test -n "$inc_longrunning_tests"; then
4121 func_append actioncmd " --with-longrunning-tests"
4123 if test -n "$inc_privileged_tests"; then
4124 func_append actioncmd " --with-privileged-tests"
4126 if test -n "$inc_unportable_tests"; then
4127 func_append actioncmd " --with-unportable-tests"
4129 if test -n "$inc_all_tests"; then
4130 func_append actioncmd " --with-all-tests"
4132 for module in $avoidlist; do
4133 func_append actioncmd " --avoid=$module"
4134 done
4135 if test -n "$lgpl"; then
4136 if test "$lgpl" = yes; then
4137 func_append actioncmd " --lgpl"
4138 else
4139 func_append actioncmd " --lgpl=$lgpl"
4142 if test -n "$makefile_name"; then
4143 func_append actioncmd " --makefile-name=$makefile_name"
4145 if test "$libtool" = true; then
4146 func_append actioncmd " --libtool"
4147 else
4148 func_append actioncmd " --no-libtool"
4150 func_append actioncmd " --macro-prefix=$macro_prefix"
4151 if test -n "$po_domain"; then
4152 func_append actioncmd " --po-domain=$po_domain"
4154 if test -n "$vc_files"; then
4155 if test "$vc_files" = true; then
4156 func_append actioncmd " --vc-files"
4157 else
4158 func_append actioncmd " --no-vc-files"
4161 func_append actioncmd " `echo $specified_modules`"
4163 # Default the makefile name to Makefile.am.
4164 if test -n "$makefile_name"; then
4165 makefile_am=$makefile_name
4166 else
4167 makefile_am=Makefile.am
4170 # Create normal Makefile.ams.
4171 for_test=false
4173 # Setup list of Makefile.am edits that are to be performed afterwards.
4174 # Some of these edits apply to files that we will generate; others are
4175 # under the responsibility of the developer.
4176 makefile_am_edits=0
4177 # func_note_Makefile_am_edit dir var value
4178 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
4179 # ${value}.
4180 func_note_Makefile_am_edit ()
4182 makefile_am_edits=`expr $makefile_am_edits + 1`
4183 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
4184 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
4185 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
4187 if test "$makefile_am" = Makefile.am; then
4188 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
4189 sourcebase_base=`basename "$sourcebase"`
4190 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
4192 if test -n "$pobase"; then
4193 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
4194 pobase_base=`basename "$pobase"`
4195 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
4197 if test -n "$inctests"; then
4198 if test "$makefile_am" = Makefile.am; then
4199 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
4200 testsbase_base=`basename "$testsbase"`
4201 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
4204 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
4206 # Find the first parent directory of $m4base that contains or will contain
4207 # a Makefile.am.
4208 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
4209 s,//*$,/,'
4210 sed_butlast='s,[^/][^/]*//*$,,'
4211 dir1="${m4base}/"; dir2=""
4212 while test -n "$dir1" \
4213 && ! { test -f "${destdir}/${dir1}Makefile.am" \
4214 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4215 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
4216 || { test -n "$inctests" \
4217 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
4218 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
4219 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
4220 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
4221 done
4222 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
4225 # Create library makefile.
4226 func_dest_tmpfilename $sourcebase/$makefile_am
4227 destfile="$sourcebase/$makefile_am"
4228 modules="$main_modules"
4229 func_emit_lib_Makefile_am > "$tmpfile"
4230 if test -f "$destdir"/$sourcebase/$makefile_am; then
4231 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
4232 rm -f "$tmpfile"
4233 else
4234 if $doit; then
4235 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4236 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
4237 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4238 else
4239 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
4240 rm -f "$tmpfile"
4243 else
4244 if $doit; then
4245 echo "Creating $sourcebase/$makefile_am"
4246 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
4247 else
4248 echo "Create $sourcebase/$makefile_am"
4249 rm -f "$tmpfile"
4251 func_append added_files "$sourcebase/$makefile_am$nl"
4254 # Create po/ directory.
4255 if test -n "$pobase"; then
4256 # Create po makefile and auxiliary files.
4257 for file in Makefile.in.in remove-potcdate.sin; do
4258 func_dest_tmpfilename $pobase/$file
4259 func_lookup_file build-aux/po/$file
4260 cat "$lookedup_file" > "$tmpfile"
4261 if test -f "$destdir"/$pobase/$file; then
4262 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
4263 rm -f "$tmpfile"
4264 else
4265 if $doit; then
4266 echo "Updating $pobase/$file (backup in $pobase/$file~)"
4267 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
4268 mv -f "$tmpfile" "$destdir"/$pobase/$file
4269 else
4270 echo "Update $pobase/$file (backup in $pobase/$file~)"
4271 rm -f "$tmpfile"
4274 else
4275 if $doit; then
4276 echo "Creating $pobase/$file"
4277 mv -f "$tmpfile" "$destdir"/$pobase/$file
4278 else
4279 echo "Create $pobase/$file"
4280 rm -f "$tmpfile"
4282 func_append added_files "$pobase/$file$nl"
4284 done
4285 # Create po makefile parameterization, part 1.
4286 func_dest_tmpfilename $pobase/Makevars
4287 func_emit_po_Makevars > "$tmpfile"
4288 if test -f "$destdir"/$pobase/Makevars; then
4289 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
4290 rm -f "$tmpfile"
4291 else
4292 if $doit; then
4293 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
4294 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
4295 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4296 else
4297 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
4298 rm -f "$tmpfile"
4301 else
4302 if $doit; then
4303 echo "Creating $pobase/Makevars"
4304 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
4305 else
4306 echo "Create $pobase/Makevars"
4307 rm -f "$tmpfile"
4309 func_append added_files "$pobase/Makevars$nl"
4311 # Create po makefile parameterization, part 2.
4312 func_dest_tmpfilename $pobase/POTFILES.in
4313 func_emit_po_POTFILES_in > "$tmpfile"
4314 if test -f "$destdir"/$pobase/POTFILES.in; then
4315 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
4316 rm -f "$tmpfile"
4317 else
4318 if $doit; then
4319 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4320 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
4321 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4322 else
4323 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
4324 rm -f "$tmpfile"
4327 else
4328 if $doit; then
4329 echo "Creating $pobase/POTFILES.in"
4330 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
4331 else
4332 echo "Create $pobase/POTFILES.in"
4333 rm -f "$tmpfile"
4335 func_append added_files "$pobase/POTFILES.in$nl"
4337 # Fetch PO files.
4338 TP_URL="http://translationproject.org/latest/"
4339 TP_RSYNC_URI="translationproject.org::tp/latest/"
4340 if $doit; then
4341 echo "Fetching gnulib PO files from $TP_URL"
4342 (cd "$destdir"/$pobase \
4343 && { # Prefer rsync over wget if it is available, since it consumes
4344 # less network bandwidth, due to compression.
4345 if type rsync 2>/dev/null | grep / > /dev/null; then
4346 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
4347 else
4348 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
4352 else
4353 echo "Fetch gnulib PO files from $TP_URL"
4355 # Create po/LINGUAS.
4356 if $doit; then
4357 func_dest_tmpfilename $pobase/LINGUAS
4358 (cd "$destdir"/$pobase \
4359 && { echo '# Set of available languages.'
4360 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
4362 ) > "$tmpfile"
4363 if test -f "$destdir"/$pobase/LINGUAS; then
4364 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
4365 rm -f "$tmpfile"
4366 else
4367 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4368 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
4369 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4371 else
4372 echo "Creating $pobase/LINGUAS"
4373 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
4374 func_append added_files "$pobase/LINGUAS$nl"
4376 else
4377 if test -f "$destdir"/$pobase/LINGUAS; then
4378 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
4379 else
4380 echo "Create $pobase/LINGUAS"
4385 # Create m4/gnulib-cache.m4.
4386 func_dest_tmpfilename $m4base/gnulib-cache.m4
4388 func_emit_copyright_notice
4389 echo "#"
4390 echo "# This file represents the specification of how gnulib-tool is used."
4391 echo "# It acts as a cache: It is written and read by gnulib-tool."
4392 echo "# In projects that use version control, this file is meant to be put under"
4393 echo "# version control, like the configure.ac and various Makefile.am files."
4394 echo
4395 echo
4396 echo "# Specification in the form of a command-line invocation:"
4397 echo "# $actioncmd"
4398 echo
4399 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
4400 # Store the local_gnulib_dir relative to destdir.
4401 case "$local_gnulib_dir" in
4402 "" | /*)
4403 relative_local_gnulib_dir="$local_gnulib_dir" ;;
4405 case "$destdir" in
4406 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
4408 # destdir, local_gnulib_dir are both relative.
4409 func_relativize "$destdir" "$local_gnulib_dir"
4410 relative_local_gnulib_dir="$reldir" ;;
4411 esac ;;
4412 esac
4413 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
4414 echo "gl_MODULES(["
4415 echo "$specified_modules" | sed -e 's/^/ /g'
4416 echo "])"
4417 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
4418 test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
4419 test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
4420 test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
4421 test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
4422 test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
4423 echo "gl_AVOID([$avoidlist])"
4424 echo "gl_SOURCE_BASE([$sourcebase])"
4425 echo "gl_M4_BASE([$m4base])"
4426 echo "gl_PO_BASE([$pobase])"
4427 echo "gl_DOC_BASE([$docbase])"
4428 echo "gl_TESTS_BASE([$testsbase])"
4429 test -z "$inctests" || echo "gl_WITH_TESTS"
4430 echo "gl_LIB([$libname])"
4431 if test -n "$lgpl"; then
4432 if test "$lgpl" = yes; then
4433 echo "gl_LGPL"
4434 else
4435 echo "gl_LGPL([$lgpl])"
4438 echo "gl_MAKEFILE_NAME([$makefile_name])"
4439 if test "$libtool" = true; then
4440 echo "gl_LIBTOOL"
4442 echo "gl_MACRO_PREFIX([$macro_prefix])"
4443 echo "gl_PO_DOMAIN([$po_domain])"
4444 if test -n "$vc_files"; then
4445 echo "gl_VC_FILES([$vc_files])"
4447 ) > "$tmpfile"
4448 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4449 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
4450 rm -f "$tmpfile"
4451 else
4452 if $doit; then
4453 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4454 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
4455 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4456 else
4457 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4458 if false; then
4459 cat "$tmpfile"
4460 echo
4461 echo "# gnulib-cache.m4 ends here"
4463 rm -f "$tmpfile"
4466 else
4467 if $doit; then
4468 echo "Creating $m4base/gnulib-cache.m4"
4469 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4470 else
4471 echo "Create $m4base/gnulib-cache.m4"
4472 cat "$tmpfile"
4473 rm -f "$tmpfile"
4477 # Create m4/gnulib-comp.m4.
4478 func_dest_tmpfilename $m4base/gnulib-comp.m4
4480 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
4481 func_emit_copyright_notice
4482 echo "#"
4483 echo "# This file represents the compiled summary of the specification in"
4484 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
4485 echo "# to be invoked from configure.ac."
4486 echo "# In projects that use version control, this file can be treated like"
4487 echo "# other built files."
4488 echo
4489 echo
4490 echo "# This macro should be invoked from $configure_ac, in the section"
4491 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
4492 echo "# any checks for libraries, header files, types and library functions."
4493 echo "AC_DEFUN([${macro_prefix}_EARLY],"
4494 echo "["
4495 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4496 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4497 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4498 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4499 echo " AC_REQUIRE([AC_PROG_RANLIB])"
4500 if test -n "$uses_subdirs"; then
4501 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
4503 for module in $final_modules; do
4504 func_verify_module
4505 if test -n "$module"; then
4506 echo "# Code from module $module:"
4507 func_get_autoconf_early_snippet "$module"
4509 done \
4510 | sed -e '/^$/d;' -e 's/^/ /'
4511 echo "])"
4512 echo
4513 echo "# This macro should be invoked from $configure_ac, in the section"
4514 echo "# \"Check for header files, types and library functions\"."
4515 echo "AC_DEFUN([${macro_prefix}_INIT],"
4516 echo "["
4517 if test "$libtool" = true; then
4518 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4519 echo " gl_cond_libtool=true"
4520 else
4521 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4522 echo " gl_cond_libtool=false"
4523 echo " gl_libdeps="
4524 echo " gl_ltlibdeps="
4526 if test "$auxdir" != "build-aux"; then
4527 sed_replace_build_aux='
4529 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4530 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4533 else
4534 sed_replace_build_aux="$sed_noop"
4536 echo " gl_m4_base='$m4base'"
4537 func_emit_initmacro_start $macro_prefix
4538 echo " gl_source_base='$sourcebase'"
4539 for module in $main_modules; do
4540 func_verify_module
4541 if test -n "$module"; then
4542 echo " # Code from module $module:"
4543 func_get_autoconf_snippet "$module" \
4544 | sed -e '/^$/d;' -e 's/^/ /' \
4545 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4546 -e "$sed_replace_build_aux"
4547 if test "$module" = 'alloca' && test "$libtool" = true; then
4548 echo 'changequote(,)dnl'
4549 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4550 echo 'changequote([, ])dnl'
4551 echo 'AC_SUBST([LTALLOCA])'
4554 done
4555 echo " # End of code from modules"
4556 func_emit_initmacro_end $macro_prefix
4557 echo " gltests_libdeps="
4558 echo " gltests_ltlibdeps="
4559 func_emit_initmacro_start ${macro_prefix}tests
4560 echo " gl_source_base='$testsbase'"
4561 # Define a tests witness macro that depends on the package.
4562 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
4563 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
4564 echo "changequote(,)dnl"
4565 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"
4566 echo "changequote([, ])dnl"
4567 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
4568 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
4569 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
4570 for module in $testsrelated_modules; do
4571 func_verify_module
4572 if test -n "$module"; then
4573 func_get_autoconf_snippet "$module" \
4574 | sed -e '/^$/d;' -e 's/^/ /' \
4575 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4576 -e "$sed_replace_build_aux" \
4577 -e 's/\$gl_cond_libtool/false/g' \
4578 -e 's/gl_libdeps/gltests_libdeps/g' \
4579 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4581 done
4582 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
4583 func_emit_initmacro_end ${macro_prefix}tests
4584 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4585 # created using libtool, because libtool already handles the dependencies.
4586 if test "$libtool" != true; then
4587 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
4588 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4589 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4590 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4591 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4593 if $use_libtests; then
4594 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
4595 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
4597 echo "])"
4598 func_emit_initmacro_done $macro_prefix $sourcebase
4599 func_emit_initmacro_done ${macro_prefix}tests $testsbase
4600 echo
4601 echo "# This macro records the list of files which have been installed by"
4602 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
4603 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
4604 echo "$files" | sed -e 's,^, ,'
4605 echo "])"
4606 ) > "$tmpfile"
4607 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4608 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
4609 rm -f "$tmpfile"
4610 else
4611 if $doit; then
4612 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4613 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
4614 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4615 else
4616 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4617 if false; then
4618 cat "$tmpfile"
4619 echo
4620 echo "# gnulib-comp.m4 ends here"
4622 rm -f "$tmpfile"
4625 else
4626 if $doit; then
4627 echo "Creating $m4base/gnulib-comp.m4"
4628 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4629 else
4630 echo "Create $m4base/gnulib-comp.m4"
4631 cat "$tmpfile"
4632 rm -f "$tmpfile"
4636 if test -n "$inctests"; then
4637 # Create tests makefile.
4638 func_dest_tmpfilename $testsbase/$makefile_am
4639 destfile="$testsbase/$makefile_am"
4640 modules="$testsrelated_modules"
4641 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
4642 if test -f "$destdir"/$testsbase/$makefile_am; then
4643 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
4644 rm -f "$tmpfile"
4645 else
4646 if $doit; then
4647 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4648 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
4649 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4650 else
4651 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4652 rm -f "$tmpfile"
4655 else
4656 if $doit; then
4657 echo "Creating $testsbase/$makefile_am"
4658 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4659 else
4660 echo "Create $testsbase/$makefile_am"
4661 rm -f "$tmpfile"
4663 func_append added_files "$testsbase/$makefile_am$nl"
4667 if test "$vc_files" != false; then
4668 # Update the .cvsignore and .gitignore files.
4669 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
4670 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
4671 # Treat gnulib-comp.m4 like an added file, even if it already existed.
4672 echo "$m4base/|A|gnulib-comp.m4"
4673 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
4674 { # Rearrange file descriptors. Needed because "while ... done < ..."
4675 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4676 exec 5<&0 < "$tmp"/fileset-changes
4677 func_update_ignorelist ()
4679 ignore="$1"
4680 if test "$ignore" = .gitignore; then
4681 # In a .gitignore file, "foo" applies to the current directory and all
4682 # subdirectories, whereas "/foo" applies to the current directory only.
4683 anchor='/'
4684 escaped_anchor='\/'
4685 doubly_escaped_anchor='\\/'
4686 else
4687 anchor=''
4688 escaped_anchor=''
4689 doubly_escaped_anchor=''
4691 if test -f "$destdir/$dir$ignore"; then
4692 if test -n "$dir_added" || test -n "$dir_removed"; then
4693 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
4694 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
4695 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
4696 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
4697 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
4699 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
4700 if $doit; then
4701 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4702 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
4703 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
4704 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
4705 } > "$tmp"/sed-ignore-removed
4706 { cat "$destdir/$dir$ignore"~
4707 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
4708 } | sed -f "$tmp"/sed-ignore-removed \
4709 > "$destdir/$dir$ignore"
4710 else
4711 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4715 else
4716 if test -n "$dir_added"; then
4717 if $doit; then
4718 echo "Creating $destdir/$dir$ignore"
4720 if test "$ignore" = .cvsignore; then
4721 echo ".deps"
4722 # Automake generates Makefile rules that create .dirstamp files.
4723 echo ".dirstamp"
4725 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
4726 } > "$destdir/$dir$ignore"
4727 else
4728 echo "Create $destdir/$dir$ignore"
4733 func_done_dir ()
4735 dir="$1"
4736 dir_added="$2"
4737 dir_removed="$3"
4738 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
4739 func_update_ignorelist .cvsignore
4741 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
4742 func_update_ignorelist .gitignore
4745 last_dir=
4746 last_dir_added=
4747 last_dir_removed=
4748 while read line; do
4749 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
4750 next_dir=`echo "$line" | sed -e 's,|.*,,'`
4751 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
4752 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
4753 if test "$next_dir" != "$last_dir"; then
4754 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4755 last_dir="$next_dir"
4756 last_dir_added=
4757 last_dir_removed=
4759 case $op in
4760 A) func_append last_dir_added "$file$nl";;
4761 R) func_append last_dir_removed "$file$nl";;
4762 esac
4763 done
4764 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4765 exec 0<&5 5<&-
4769 echo "Finished."
4770 echo
4771 echo "You may need to add #include directives for the following .h files."
4772 # Intersect $specified_modules and $main_modules
4773 # (since $specified_modules is not necessarily of subset of $main_modules
4774 # - some may have been skipped through --avoid, and since the elements of
4775 # $main_modules but not in $specified_modules can go away without explicit
4776 # notice - through changes in the module dependencies).
4777 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
4778 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
4779 # First the #include <...> directives without #ifs, sorted for convenience,
4780 # then the #include "..." directives without #ifs, sorted for convenience,
4781 # then the #include directives that are surrounded by #ifs. Not sorted.
4782 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
4783 include_directive=`func_get_include_directive "$module"`
4784 case "$nl$include_directive" in
4785 *"$nl#if"*)
4786 echo "$include_directive" 1>&5
4789 echo "$include_directive" | grep -v 'include "' 1>&6
4790 echo "$include_directive" | grep 'include "' 1>&7
4792 esac
4793 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
4795 LC_ALL=C sort -u "$tmp"/include-angles
4796 LC_ALL=C sort -u "$tmp"/include-quotes
4797 cat "$tmp"/include-if
4798 ) | sed -e '/^$/d' -e 's/^/ /'
4799 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
4801 for module in $main_modules; do
4802 func_get_link_directive "$module"
4803 done \
4804 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
4805 if test `wc -l < "$tmp"/link` != 0; then
4806 echo
4807 echo "You may need to use the following Makefile variables when linking."
4808 echo "Use them in <program>_LDADD when linking a program, or"
4809 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
4810 cat "$tmp"/link
4812 rm -f "$tmp"/link
4814 echo
4815 echo "Don't forget to"
4816 if test "$makefile_am" = Makefile.am; then
4817 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4818 else
4819 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
4821 if test -n "$pobase"; then
4822 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
4824 if test -n "$inctests"; then
4825 if test "$makefile_am" = Makefile.am; then
4826 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4827 else
4828 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
4831 edit=0
4832 while test $edit != $makefile_am_edits; do
4833 edit=`expr $edit + 1`
4834 eval dir=\"\$makefile_am_edit${edit}_dir\"
4835 eval var=\"\$makefile_am_edit${edit}_var\"
4836 eval val=\"\$makefile_am_edit${edit}_val\"
4837 if test -n "$var"; then
4838 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
4840 done
4841 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
4842 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
4845 # func_create_testdir testdir modules
4846 # Input:
4847 # - local_gnulib_dir from --local-dir
4848 # - modcache true or false, from --cache-modules/--no-cache-modules
4849 # - auxdir directory relative to destdir where to place build aux files
4850 # - inctests true if tests should be included, blank otherwise
4851 # - incobsolete true if obsolete modules among dependencies should be
4852 # included, blank otherwise
4853 # - excl_cxx_tests true if C++ interoperability tests should be excluded,
4854 # blank otherwise
4855 # - excl_longrunning_tests true if long-runnings tests should be excluded,
4856 # blank otherwise
4857 # - excl_privileged_tests true if tests that require root privileges should be
4858 # excluded, blank otherwise
4859 # - excl_unportable_tests true if tests that fail on some platforms should be
4860 # excluded, blank otherwise
4861 # - avoidlist list of modules to avoid
4862 # - libtool true if --libtool was given, false if --no-libtool was
4863 # given, blank otherwise
4864 # - symbolic true if files should be symlinked, copied otherwise
4865 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4866 # copied otherwise
4867 func_create_testdir ()
4869 testdir="$1"
4870 modules="$2"
4871 if test -z "$modules"; then
4872 # All modules together.
4873 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4874 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
4875 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
4876 modules=`func_all_modules`
4877 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
4879 specified_modules="$modules"
4881 # Canonicalize the list of specified modules.
4882 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
4884 # Unlike in func_import, here we want to include all kinds of tests for the
4885 # directly specified modules, but not for dependencies.
4886 inc_all_direct_tests=true
4887 inc_all_indirect_tests="$inc_all_tests"
4889 # Check that the license of every module is consistent with the license of
4890 # its dependencies.
4891 saved_inctests="$inctests"
4892 # When computing transitive closures, don't consider $module to depend on
4893 # $module-tests. Need this becauses tests are implicitly GPL and may depend
4894 # on GPL modules - therefore we don't want a warning in this case.
4895 inctests=""
4896 for requested_module in $specified_modules; do
4897 requested_license=`func_get_license "$requested_module"`
4898 if test "$requested_license" != GPL; then
4899 # Here we use func_modules_transitive_closure, not just
4900 # func_get_dependencies, so that we also detect weird situations like
4901 # an LGPL module which depends on a GPLed build tool module which depends
4902 # on a GPL module.
4903 modules="$requested_module"
4904 func_modules_transitive_closure
4905 for module in $modules; do
4906 license=`func_get_license "$module"`
4907 case "$license" in
4908 'GPLed build tool') ;;
4909 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4911 case "$requested_license" in
4912 GPLv2+)
4913 case "$license" in
4914 GPLv2+ | LGPLv2+) ;;
4915 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4916 esac
4918 LGPL)
4919 case "$license" in
4920 LGPL | LGPLv2+) ;;
4921 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4922 esac
4924 LGPLv2+)
4925 case "$license" in
4926 LGPLv2+) ;;
4927 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4928 esac
4930 esac
4932 esac
4933 done
4935 done
4936 inctests="$saved_inctests"
4938 # Subdirectory names.
4939 sourcebase=gllib
4940 m4base=glm4
4941 pobase=
4942 docbase=gldoc
4943 testsbase=gltests
4944 macro_prefix=gl
4945 po_domain=
4946 vc_files=
4948 # Determine final module list.
4949 modules="$specified_modules"
4950 func_modules_transitive_closure
4951 if test $verbose -ge 0; then
4952 func_show_module_list
4955 # Add the dummy module if needed.
4956 func_modules_add_dummy
4958 # Show banner notice of every module.
4959 func_modules_notice
4961 # Determine final file list.
4962 func_modules_to_filelist
4963 if test $verbose -ge 0; then
4964 echo "File list:"
4965 echo "$files" | sed -e 's/^/ /'
4967 # Add files for which the copy in gnulib is newer than the one that
4968 # "automake --add-missing --copy" would provide.
4969 files="$files build-aux/config.guess"
4970 files="$files build-aux/config.sub"
4971 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
4973 rewritten='%REWRITTEN%'
4974 sed_rewrite_files="\
4975 s,^build-aux/,$rewritten$auxdir/,
4976 s,^doc/,$rewritten$docbase/,
4977 s,^lib/,$rewritten$sourcebase/,
4978 s,^m4/,$rewritten$m4base/,
4979 s,^tests/,$rewritten$testsbase/,
4980 s,^top/,$rewritten,
4981 s,^$rewritten,,"
4983 # Create directories.
4984 for f in $files; do echo $f; done \
4985 | sed -e "$sed_rewrite_files" \
4986 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4987 | LC_ALL=C sort -u \
4988 > "$tmp"/dirs
4989 { # Rearrange file descriptors. Needed because "while ... done < ..."
4990 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4991 exec 5<&0 < "$tmp"/dirs
4992 while read d; do
4993 mkdir -p "$testdir/$d"
4994 done
4995 exec 0<&5 5<&-
4998 # Copy files or make symbolic links.
4999 delimiter=' '
5000 for f in $files; do echo $f; done \
5001 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
5002 | LC_ALL=C sort \
5003 > "$tmp"/files
5004 { # Rearrange file descriptors. Needed because "while ... done < ..."
5005 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
5006 exec 5<&0 < "$tmp"/files
5007 while read g f; do
5008 func_lookup_file "$f"
5009 if test -n "$lookedup_tmp"; then
5010 cp -p "$lookedup_file" "$testdir/$g"
5011 else
5012 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
5013 if { test -n "$symbolic" \
5014 || { test -n "$lsymbolic" \
5015 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
5016 func_ln "$lookedup_file" "$testdir/$g"
5017 else
5018 cp -p "$lookedup_file" "$testdir/$g"
5021 done
5022 exec 0<&5 5<&-
5025 # Create Makefile.ams that are for testing.
5026 for_test=true
5028 # No special edits are needed.
5029 makefile_am_edits=0
5031 # Create $sourcebase/Makefile.am.
5032 mkdir -p "$testdir/$sourcebase"
5033 destfile="$sourcebase/Makefile.am"
5034 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
5035 any_uses_subdirs="$uses_subdirs"
5037 # Create $m4base/Makefile.am.
5038 mkdir -p "$testdir/$m4base"
5039 (echo "## Process this file with automake to produce Makefile.in."
5040 echo
5041 echo "EXTRA_DIST ="
5042 for f in $files; do
5043 case "$f" in
5044 m4/* )
5045 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
5046 esac
5047 done
5048 ) > "$testdir/$m4base/Makefile.am"
5050 subdirs="$sourcebase $m4base"
5051 subdirs_with_configure_ac=""
5053 if false && test -f "$testdir"/$m4base/gettext.m4; then
5054 # Avoid stupid error message from automake:
5055 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
5056 mkdir -p "$testdir/po"
5057 (echo "## Process this file with automake to produce Makefile.in."
5058 ) > "$testdir/po/Makefile.am"
5059 func_append subdirs " po"
5062 if test -n "$inctests"; then
5063 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
5064 # Viewed from the $testsbase subdirectory, $auxdir is different.
5065 saved_auxdir="$auxdir"
5066 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
5067 # Create $testsbase/Makefile.am.
5068 use_libtests=false
5069 destfile="$testsbase/Makefile.am"
5070 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
5071 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
5072 # Create $testsbase/configure.ac.
5073 (echo "# Process this file with autoconf to produce a configure script."
5074 echo "AC_INIT([dummy], [0])"
5075 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5076 echo "AM_INIT_AUTOMAKE"
5077 echo
5078 echo "AC_CONFIG_HEADERS([config.h])"
5079 echo
5080 echo "AC_PROG_CC"
5081 echo "AC_PROG_INSTALL"
5082 echo "AC_PROG_MAKE_SET"
5083 echo "AC_PROG_RANLIB"
5084 echo
5085 if test -n "$uses_subdirs"; then
5086 echo "AM_PROG_CC_C_O"
5087 echo
5089 for module in $modules; do
5090 func_verify_module
5091 if test -n "$module"; then
5092 case $module in
5093 gnumakefile | maintainer-makefile)
5094 # These modules are meant to be used only in the top-level directory.
5097 func_get_autoconf_early_snippet "$module"
5099 esac
5101 done \
5102 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5103 if test "$libtool" = true; then
5104 echo "LT_INIT([win32-dll])"
5105 echo "LT_LANG([C++])"
5106 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5107 echo "gl_cond_libtool=true"
5108 else
5109 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5110 echo "gl_cond_libtool=false"
5111 echo "gl_libdeps="
5112 echo "gl_ltlibdeps="
5114 # Wrap the set of autoconf snippets into an autoconf macro that is then
5115 # invoked. This is needed because autoconf does not support AC_REQUIRE
5116 # at the top level:
5117 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5118 # but we want the AC_REQUIRE to have its normal meaning (provide one
5119 # expansion of the required macro before the current point, and only one
5120 # expansion total).
5121 echo "AC_DEFUN([gl_INIT], ["
5122 sed_replace_build_aux='
5124 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5125 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5128 echo "gl_m4_base='../$m4base'"
5129 func_emit_initmacro_start $macro_prefix
5130 # We don't have explicit ordering constraints between the various
5131 # autoconf snippets. It's cleanest to put those of the library before
5132 # those of the tests.
5133 echo "gl_source_base='../$sourcebase'"
5134 for module in $modules; do
5135 func_verify_nontests_module
5136 if test -n "$module"; then
5137 case $module in
5138 gnumakefile | maintainer-makefile)
5139 # These modules are meant to be used only in the top-level directory.
5142 func_get_autoconf_snippet "$module" \
5143 | sed -e "$sed_replace_build_aux"
5144 if test "$module" = 'alloca' && test "$libtool" = true; then
5145 echo 'changequote(,)dnl'
5146 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
5147 echo 'changequote([, ])dnl'
5148 echo 'AC_SUBST([LTALLOCA])'
5151 esac
5153 done
5154 echo "gl_source_base='.'"
5155 for module in $modules; do
5156 func_verify_tests_module
5157 if test -n "$module"; then
5158 func_get_autoconf_snippet "$module" \
5159 | sed -e "$sed_replace_build_aux"
5161 done
5162 func_emit_initmacro_end $macro_prefix
5163 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5164 # created using libtool, because libtool already handles the dependencies.
5165 if test "$libtool" != true; then
5166 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5167 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5168 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5169 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5170 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5172 echo "])"
5173 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
5174 echo
5175 echo "gl_INIT"
5176 echo
5177 # Usually $testsbase/config.h will be a superset of config.h. Verify this
5178 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
5179 echo "AH_TOP([#include \"../config.h\"])"
5180 echo
5181 echo "AC_CONFIG_FILES([Makefile])"
5182 echo "AC_OUTPUT"
5183 ) > "$testdir/$testsbase/configure.ac"
5184 auxdir="$saved_auxdir"
5185 func_append subdirs " $testsbase"
5186 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
5189 # Create Makefile.am.
5190 (echo "## Process this file with automake to produce Makefile.in."
5191 echo
5192 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5193 echo
5194 echo "SUBDIRS = $subdirs"
5195 echo
5196 echo "ACLOCAL_AMFLAGS = -I $m4base"
5197 ) > "$testdir/Makefile.am"
5199 # Create configure.ac.
5200 (echo "# Process this file with autoconf to produce a configure script."
5201 echo "AC_INIT([dummy], [0])"
5202 if test "$auxdir" != "."; then
5203 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5205 echo "AM_INIT_AUTOMAKE"
5206 echo
5207 echo "AC_CONFIG_HEADERS([config.h])"
5208 echo
5209 echo "AC_PROG_CC"
5210 echo "AC_PROG_INSTALL"
5211 echo "AC_PROG_MAKE_SET"
5212 echo
5213 echo "# For autobuild."
5214 echo "AC_CANONICAL_BUILD"
5215 echo "AC_CANONICAL_HOST"
5216 echo
5217 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
5218 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
5219 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
5220 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
5221 echo
5222 echo "AC_PROG_RANLIB"
5223 echo
5224 if test -n "$any_uses_subdirs"; then
5225 echo "AM_PROG_CC_C_O"
5226 echo
5228 for module in $modules; do
5229 func_verify_nontests_module
5230 if test -n "$module"; then
5231 func_get_autoconf_early_snippet "$module"
5233 done \
5234 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
5235 if test "$libtool" = true; then
5236 echo "LT_INIT([win32-dll])"
5237 echo "LT_LANG([C++])"
5238 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
5239 echo "gl_cond_libtool=true"
5240 else
5241 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
5242 echo "gl_cond_libtool=false"
5243 echo "gl_libdeps="
5244 echo "gl_ltlibdeps="
5246 # Wrap the set of autoconf snippets into an autoconf macro that is then
5247 # invoked. This is needed because autoconf does not support AC_REQUIRE
5248 # at the top level:
5249 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
5250 # but we want the AC_REQUIRE to have its normal meaning (provide one
5251 # expansion of the required macro before the current point, and only one
5252 # expansion total).
5253 echo "AC_DEFUN([gl_INIT], ["
5254 if test "$auxdir" != "build-aux"; then
5255 sed_replace_build_aux='
5257 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
5258 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
5261 else
5262 sed_replace_build_aux="$sed_noop"
5264 echo "gl_m4_base='$m4base'"
5265 func_emit_initmacro_start $macro_prefix
5266 echo "gl_source_base='$sourcebase'"
5267 for module in $modules; do
5268 func_verify_nontests_module
5269 if test -n "$module"; then
5270 func_get_autoconf_snippet "$module" \
5271 | sed -e "$sed_replace_build_aux"
5272 if test "$module" = 'alloca' && test "$libtool" = true; then
5273 echo 'changequote(,)dnl'
5274 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
5275 echo 'changequote([, ])dnl'
5276 echo 'AC_SUBST([LTALLOCA])'
5279 done
5280 func_emit_initmacro_end $macro_prefix
5281 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
5282 # created using libtool, because libtool already handles the dependencies.
5283 if test "$libtool" != true; then
5284 libname_upper=`echo "$libname" | LC_ALL=C tr '[a-z]-' '[A-Z]_'`
5285 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
5286 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
5287 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
5288 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
5290 echo "])"
5291 func_emit_initmacro_done $macro_prefix $sourcebase
5292 echo
5293 echo "gl_INIT"
5294 echo
5295 if test -n "$subdirs_with_configure_ac"; then
5296 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
5298 makefiles="Makefile"
5299 for d in $subdirs; do
5300 # For subdirs that have a configure.ac by their own, it's the subdir's
5301 # configure.ac which creates the subdir's Makefile.am, not this one.
5302 case " $subdirs_with_configure_ac " in
5303 *" $d "*) ;;
5304 *) func_append makefiles " $d/Makefile" ;;
5305 esac
5306 done
5307 echo "AC_CONFIG_FILES([$makefiles])"
5308 echo "AC_OUTPUT"
5309 ) > "$testdir/configure.ac"
5311 # Create autogenerated files.
5312 (cd "$testdir"
5313 # Do not use "${AUTORECONF} --force --install", because it may invoke
5314 # autopoint, which brings in older versions of some of our .m4 files.
5315 if test -f $m4base/gettext.m4; then
5316 func_execute_command ${AUTOPOINT} --force || func_exit 1
5317 for f in $m4base/*.m4~; do
5318 if test -f $f; then
5319 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5321 done
5323 if test "$libtool" = true; then
5324 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
5326 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
5327 if ! test -d build-aux; then
5328 func_execute_command mkdir build-aux || func_exit 1
5330 func_execute_command ${AUTOCONF} || func_exit 1
5331 func_execute_command ${AUTOHEADER} || func_exit 1
5332 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5333 ) || func_exit 1
5334 if test -n "$inctests"; then
5335 # Create autogenerated files.
5336 (cd "$testdir/$testsbase" || func_exit 1
5337 # Do not use "${AUTORECONF} --force --install", because it may invoke
5338 # autopoint, which brings in older versions of some of our .m4 files.
5339 if test -f ../$m4base/gettext.m4; then
5340 func_execute_command ${AUTOPOINT} --force || func_exit 1
5341 for f in ../$m4base/*.m4~; do
5342 if test -f $f; then
5343 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
5345 done
5347 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
5348 if ! test -d ../build-aux; then
5349 func_execute_command mkdir ../build-aux
5351 func_execute_command ${AUTOCONF} || func_exit 1
5352 func_execute_command ${AUTOHEADER} || func_exit 1
5353 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5354 ) || func_exit 1
5356 # Need to run configure and make once, to create built files that are to be
5357 # distributed (such as parse-datetime.c).
5358 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
5359 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
5360 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5361 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5362 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
5363 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
5364 # such $(FOO_H) because they don't refer to distributed files.
5365 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
5366 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5367 | sed -e "$sed_remove_make_variables"`
5368 distributed_built_sources=`for file in $built_sources; do
5369 case "$cleaned_files" in
5370 *" "$file" "*) ;;
5371 *) echo $file ;;
5372 esac;
5373 done`
5374 tests_distributed_built_sources=
5375 if test -n "$inctests"; then
5376 # Likewise for built files in the $testsbase directory.
5377 tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5378 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
5379 tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
5380 tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
5381 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
5382 | sed -e "$sed_remove_make_variables"`
5383 tests_distributed_built_sources=`for file in $tests_built_sources; do
5384 case "$tests_cleaned_files" in
5385 *" "$file" "*) ;;
5386 *) echo $file ;;
5387 esac;
5388 done`
5390 if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
5391 (cd "$testdir"
5392 ./configure || func_exit 1
5393 if test -n "$distributed_built_sources"; then
5394 cd "$sourcebase"
5395 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5396 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5397 built_sources \
5398 || func_exit 1
5399 cd ..
5401 if test -n "$tests_distributed_built_sources"; then
5402 cd "$testsbase"
5403 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
5404 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5405 built_sources \
5406 || func_exit 1
5407 cd ..
5409 $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
5410 distclean \
5411 || func_exit 1
5412 ) || func_exit 1
5416 # func_create_megatestdir megatestdir allmodules
5417 # Input:
5418 # - local_gnulib_dir from --local-dir
5419 # - modcache true or false, from --cache-modules/--no-cache-modules
5420 # - auxdir directory relative to destdir where to place build aux files
5421 func_create_megatestdir ()
5423 megatestdir="$1"
5424 allmodules="$2"
5425 if test -z "$allmodules"; then
5426 allmodules=`func_all_modules`
5429 megasubdirs=
5430 # First, all modules one by one.
5431 for onemodule in $allmodules; do
5432 func_create_testdir "$megatestdir/$onemodule" $onemodule
5433 func_append megasubdirs "$onemodule "
5434 done
5435 # Then, all modules all together.
5436 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
5437 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
5438 func_create_testdir "$megatestdir/ALL" "$allmodules"
5439 func_append megasubdirs "ALL"
5441 # Create autobuild.
5442 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
5443 vc_witness="$gnulib_dir/CVS/Entries"; \
5444 else \
5445 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
5446 fi; \
5447 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
5448 | sed -e 's,January,01,' -e 's,Jan,01,' \
5449 -e 's,February,02,' -e 's,Feb,02,' \
5450 -e 's,March,03,' -e 's,Mar,03,' \
5451 -e 's,April,04,' -e 's,Apr,04,' \
5452 -e 's,May,05,' \
5453 -e 's,June,06,' -e 's,Jun,06,' \
5454 -e 's,July,07,' -e 's,Jul,07,' \
5455 -e 's,August,08,' -e 's,Aug,08,' \
5456 -e 's,September,09,' -e 's,Sep,09,' \
5457 -e 's,October,10,' -e 's,Oct,10,' \
5458 -e 's,November,11,' -e 's,Nov,11,' \
5459 -e 's,December,12,' -e 's,Dec,12,' \
5460 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
5461 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
5462 (echo '#!/bin/sh'
5463 echo "CVSDATE=$cvsdate"
5464 echo ": \${MAKE=make}"
5465 echo "test -d logs || mkdir logs"
5466 echo "for module in $megasubdirs; do"
5467 echo " echo \"Working on module \$module...\""
5468 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
5469 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
5470 echo " echo"
5471 echo " set -x"
5472 echo " : autobuild project... \$module"
5473 echo " : autobuild revision... cvs-\$CVSDATE-000000"
5474 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
5475 echo " : autobuild hostname... \`hostname\`"
5476 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
5477 echo " echo rc=\$?"
5478 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
5479 echo "done"
5480 ) > "$megatestdir/do-autobuild"
5481 chmod a+x "$megatestdir/do-autobuild"
5483 # Create Makefile.am.
5484 (echo "## Process this file with automake to produce Makefile.in."
5485 echo
5486 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5487 echo
5488 echo "SUBDIRS = $megasubdirs"
5489 echo
5490 echo "EXTRA_DIST = do-autobuild"
5491 ) > "$megatestdir/Makefile.am"
5493 # Create configure.ac.
5494 (echo "# Process this file with autoconf to produce a configure script."
5495 echo "AC_INIT([dummy], [0])"
5496 if test "$auxdir" != "."; then
5497 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5499 echo "AM_INIT_AUTOMAKE"
5500 echo
5501 echo "AC_PROG_MAKE_SET"
5502 echo
5503 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
5504 echo "AC_CONFIG_FILES([Makefile])"
5505 echo "AC_OUTPUT"
5506 ) > "$megatestdir/configure.ac"
5508 # Create autogenerated files.
5509 (cd "$megatestdir"
5510 # Do not use "${AUTORECONF} --install", because autoreconf operates
5511 # recursively, but the subdirectories are already finished, therefore
5512 # calling autoreconf here would only waste lots of CPU time.
5513 func_execute_command ${ACLOCAL} || func_exit 1
5514 func_execute_command mkdir build-aux
5515 func_execute_command ${AUTOCONF} || func_exit 1
5516 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5517 ) || func_exit 1
5520 case $mode in
5521 "" )
5522 func_fatal_error "no mode specified" ;;
5524 list )
5525 func_all_modules
5528 find )
5529 # sed expression that converts a literal to a basic regular expression.
5530 # Needs to handle . [ \ * ^ $.
5531 sed_literal_to_basic_regex='s/\\/\\\\/g
5532 s/\[/\\[/g
5533 s/\^/\\^/g
5534 s/\([.*$]\)/[\1]/g'
5535 for filename
5537 if test -f "$gnulib_dir/$filename" \
5538 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
5539 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
5540 filename_line_regex='^'"$filename_anywhere_regex"'$'
5541 module_candidates=`
5543 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
5544 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
5545 (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$,,')
5548 | func_sanitize_modulelist \
5549 | LC_ALL=C sort -u
5551 for module in $module_candidates; do
5552 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
5553 echo $module
5555 done
5556 else
5557 func_warning "file $filename does not exist"
5559 done
5562 import | add-import | remove-import | update )
5564 # Where to import.
5565 if test -z "$destdir"; then
5566 destdir=.
5568 test -d "$destdir" \
5569 || func_fatal_error "destination directory does not exist: $destdir"
5571 # Prefer configure.ac to configure.in.
5572 if test -f "$destdir"/configure.ac; then
5573 configure_ac="$destdir/configure.ac"
5574 else
5575 if test -f "$destdir"/configure.in; then
5576 configure_ac="$destdir/configure.in"
5577 else
5578 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
5582 # Analyze configure.ac.
5583 guessed_auxdir="."
5584 guessed_libtool=false
5585 my_sed_traces='
5586 s,#.*$,,
5587 s,^dnl .*$,,
5588 s, dnl .*$,,
5589 /AC_CONFIG_AUX_DIR/ {
5590 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
5592 /A[CM]_PROG_LIBTOOL/ {
5593 s,^.*$,guessed_libtool=true,p
5595 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
5597 if test -z "$auxdir"; then
5598 auxdir="$guessed_auxdir"
5601 # Determine where to apply func_import.
5602 if test "$mode" = import; then
5603 # Apply func_import to a particular gnulib directory.
5604 # The command line contains the complete specification; don't look at
5605 # the contents of gnulib-cache.m4.
5606 test -n "$supplied_libname" || supplied_libname=true
5607 test -n "$sourcebase" || sourcebase="lib"
5608 test -n "$m4base" || m4base="m4"
5609 test -n "$docbase" || docbase="doc"
5610 test -n "$testsbase" || testsbase="tests"
5611 test -n "$macro_prefix" || macro_prefix="gl"
5612 func_import "$*"
5613 else
5614 if test -n "$m4base"; then
5615 # Apply func_import to a particular gnulib directory.
5616 # Any number of additional modules can be given.
5617 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
5618 # First use of gnulib in the given m4base.
5619 test -n "$supplied_libname" || supplied_libname=true
5620 test -n "$sourcebase" || sourcebase="lib"
5621 test -n "$docbase" || docbase="doc"
5622 test -n "$testsbase" || testsbase="tests"
5623 test -n "$macro_prefix" || macro_prefix="gl"
5625 func_import "$*"
5626 else
5627 # Apply func_import to all gnulib directories.
5628 # To get this list of directories, look at Makefile.am. (Not at
5629 # configure, because it may be omitted from version control. Also,
5630 # don't run "find $destdir -name gnulib-cache.m4", as it might be
5631 # too expensive.)
5632 m4dirs=
5633 m4dirs_count=0
5634 if test -f "$destdir"/Makefile.am; then
5635 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
5636 m4dir_is_next=
5637 for arg in $aclocal_amflags; do
5638 if test -n "$m4dir_is_next"; then
5639 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
5640 case "$arg" in
5641 /*) ;;
5643 if test -f "$destdir/$arg"/gnulib-cache.m4; then
5644 func_append m4dirs " $arg"
5645 m4dirs_count=`expr $m4dirs_count + 1`
5648 esac
5649 m4dir_is_next=
5650 else
5651 if test "X$arg" = "X-I"; then
5652 m4dir_is_next=yes
5653 else
5654 m4dir_is_next=
5657 done
5658 else
5659 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
5660 if test -f "$destdir"/aclocal.m4; then
5661 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
5662 sedexpr2='s,^[^/]*$,.,'
5663 sedexpr3='s,/[^/]*$,,'
5664 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
5665 m4dirs=`for arg in $m4dirs; do if test -f "$destdir/$arg"/gnulib-cache.m4; then echo $arg; fi; done`
5666 m4dirs_count=`for arg in $m4dirs; do echo "$arg"; done | wc -l`
5669 if test $m4dirs_count = 0; then
5670 # First use of gnulib in a package.
5671 # Any number of additional modules can be given.
5672 test -n "$supplied_libname" || supplied_libname=true
5673 test -n "$sourcebase" || sourcebase="lib"
5674 m4base="m4"
5675 test -n "$docbase" || docbase="doc"
5676 test -n "$testsbase" || testsbase="tests"
5677 test -n "$macro_prefix" || macro_prefix="gl"
5678 func_import "$*"
5679 else
5680 if test $m4dirs_count = 1; then
5681 # There's only one use of gnulib here. Assume the user means it.
5682 # Any number of additional modules can be given.
5683 for m4base in $m4dirs; do
5684 func_import "$*"
5685 done
5686 else
5687 # Ambiguous - guess what the user meant.
5688 if test $# = 0; then
5689 # No further arguments. Guess the user wants to update all of them.
5690 for m4base in $m4dirs; do
5691 # Perform func_import in a subshell, so that variable values
5692 # such as
5693 # local_gnulib_dir, incobsolete, inc_cxx_tests,
5694 # inc_longrunning_tests, inc_privileged_tests,
5695 # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
5696 # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
5697 # makefile_name, libtool, macro_prefix, po_domain, vc_files
5698 # don't propagate from one directory to another.
5699 (func_import) || func_exit 1
5700 done
5701 else
5702 # Really ambiguous.
5703 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
5711 create-testdir )
5712 if test -z "$destdir"; then
5713 func_fatal_error "please specify --dir option"
5715 mkdir "$destdir"
5716 test -d "$destdir" \
5717 || func_fatal_error "could not create destination directory"
5718 test -n "$auxdir" || auxdir="build-aux"
5719 func_create_testdir "$destdir" "$*"
5722 create-megatestdir )
5723 if test -z "$destdir"; then
5724 func_fatal_error "please specify --dir option"
5726 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5727 test -n "$auxdir" || auxdir="build-aux"
5728 func_create_megatestdir "$destdir" "$*"
5731 test )
5732 test -n "$destdir" || destdir=testdir$$
5733 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5734 test -n "$auxdir" || auxdir="build-aux"
5735 func_create_testdir "$destdir" "$*"
5736 cd "$destdir"
5737 mkdir build
5738 cd build
5739 ../configure || func_exit 1
5740 $MAKE || func_exit 1
5741 $MAKE check || func_exit 1
5742 $MAKE distclean || func_exit 1
5743 remaining=`find . -type f -print`
5744 if test -n "$remaining"; then
5745 echo "Remaining files:" $remaining 1>&2
5746 echo "gnulib-tool: *** Stop." 1>&2
5747 func_exit 1
5749 cd ..
5750 cd ..
5751 rm -rf "$destdir"
5754 megatest )
5755 test -n "$destdir" || destdir=testdir$$
5756 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5757 test -n "$auxdir" || auxdir="build-aux"
5758 func_create_megatestdir "$destdir" "$*"
5759 cd "$destdir"
5760 mkdir build
5761 cd build
5762 ../configure
5763 $MAKE
5764 $MAKE check
5765 $MAKE distclean
5766 remaining=`find . -type f -print`
5767 if test -n "$remaining"; then
5768 echo "Remaining files:" $remaining 1>&2
5769 echo "gnulib-tool: *** Stop." 1>&2
5770 func_exit 1
5772 cd ..
5773 cd ..
5774 rm -rf "$destdir"
5777 extract-description )
5778 for module
5780 func_verify_module
5781 if test -n "$module"; then
5782 func_get_description "$module"
5784 done
5787 extract-comment )
5788 for module
5790 func_verify_module
5791 if test -n "$module"; then
5792 func_get_comment "$module"
5794 done
5797 extract-status )
5798 for module
5800 func_verify_module
5801 if test -n "$module"; then
5802 func_get_status "$module"
5804 done
5807 extract-notice )
5808 for module
5810 func_verify_module
5811 if test -n "$module"; then
5812 func_get_notice "$module"
5814 done
5817 extract-applicability )
5818 for module
5820 func_verify_module
5821 if test -n "$module"; then
5822 func_get_applicability "$module"
5824 done
5827 extract-filelist )
5828 for module
5830 func_verify_module
5831 if test -n "$module"; then
5832 func_get_filelist "$module"
5834 done
5837 extract-dependencies )
5838 for module
5840 func_verify_module
5841 if test -n "$module"; then
5842 func_get_dependencies "$module"
5844 done
5847 extract-autoconf-snippet )
5848 for module
5850 func_verify_module
5851 if test -n "$module"; then
5852 func_get_autoconf_snippet "$module"
5854 done
5857 extract-automake-snippet )
5858 for module
5860 func_verify_module
5861 if test -n "$module"; then
5862 func_get_automake_snippet "$module"
5864 done
5867 extract-include-directive )
5868 for module
5870 func_verify_module
5871 if test -n "$module"; then
5872 func_get_include_directive "$module"
5874 done
5877 extract-link-directive )
5878 for module
5880 func_verify_module
5881 if test -n "$module"; then
5882 func_get_link_directive "$module"
5884 done
5887 extract-license )
5888 for module
5890 func_verify_module
5891 if test -n "$module"; then
5892 func_get_license "$module"
5894 done
5897 extract-maintainer )
5898 for module
5900 func_verify_module
5901 if test -n "$module"; then
5902 func_get_maintainer "$module"
5904 done
5907 extract-tests-module )
5908 for module
5910 func_verify_module
5911 if test -n "$module"; then
5912 func_get_tests_module "$module"
5914 done
5917 copy-file )
5918 # Verify the number of arguments.
5919 if test $# -lt 1 || test $# -gt 2; then
5920 func_fatal_error "invalid number of arguments for --$mode"
5923 # The first argument is the file to be copied.
5924 f="$1"
5925 # Verify the file exists.
5926 func_lookup_file "$f"
5928 # The second argument is the destination; either a directory ot a file.
5929 # It defaults to the current directory.
5930 dest="$2"
5931 test -n "$dest" || dest='.'
5932 test -n "$sourcebase" || sourcebase="lib"
5933 test -n "$m4base" || m4base="m4"
5934 test -n "$docbase" || docbase="doc"
5935 test -n "$testsbase" || testsbase="tests"
5936 test -n "$auxdir" || auxdir="build-aux"
5937 rewritten='%REWRITTEN%'
5938 sed_rewrite_files="\
5939 s,^build-aux/,$rewritten$auxdir/,
5940 s,^doc/,$rewritten$docbase/,
5941 s,^lib/,$rewritten$sourcebase/,
5942 s,^m4/,$rewritten$m4base/,
5943 s,^tests/,$rewritten$testsbase/,
5944 s,^top/,$rewritten,
5945 s,^$rewritten,,"
5946 if test -d "$dest"; then
5947 destdir="$dest"
5948 g=`echo "$f" | sed -e "$sed_rewrite_files"`
5949 else
5950 destdir=`dirname "$dest"`
5951 g=`basename "$dest"`
5954 # Create the directory for destfile.
5955 d=`dirname "$destdir/$g"`
5956 if $doit; then
5957 if test -n "$d" && test ! -d "$d"; then
5958 mkdir -p "$d" || func_fatal_error "failed"
5961 # Copy the file.
5962 func_dest_tmpfilename "$g"
5963 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5964 already_present=true
5965 if test -f "$destdir/$g"; then
5966 # The file already exists.
5967 func_update_file
5968 else
5969 # Install the file.
5970 # Don't protest if the file should be there but isn't: it happens
5971 # frequently that developers don't put autogenerated files under version
5972 # control.
5973 func_add_file
5975 rm -f "$tmpfile"
5979 func_fatal_error "unknown operation mode --$mode" ;;
5980 esac
5982 rm -rf "$tmp"
5983 # Undo the effect of the previous 'trap' command. Some shellology:
5984 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
5985 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
5986 # exit); for the others we need to call 'exit' explicitly. The value of $? is
5987 # 128 + signal number and is set before the trap-registered command is run.
5988 trap '' 0
5989 trap 'func_exit $?' 1 2 3 13 15
5991 exit 0
5993 # Local Variables:
5994 # indent-tabs-mode: nil
5995 # whitespace-check-buffer-indent: nil
5996 # End: