3 # Copyright (C) 2002-2010 Free Software Foundation, Inc.
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 # This program is meant for authors or maintainers which want to import
20 # modules from gnulib into their packages.
28 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
32 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
33 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
37 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
40 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
43 # You can set LIBTOOLPATH to empty if libtoolize 2.x is already in your PATH.
46 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
47 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
48 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
49 AUTOCONF="${AUTOCONFPATH}autoconf"
51 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
52 AUTOHEADER="${AUTOCONFPATH}autoheader"
54 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
55 ACLOCAL="${AUTOMAKEPATH}aclocal"
57 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
58 AUTOMAKE="${AUTOMAKEPATH}automake"
60 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
61 AUTORECONF="${AUTOCONFPATH}autoreconf"
64 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
65 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
66 AUTOPOINT="${GETTEXTPATH}autopoint"
69 # If you didn't set LIBTOOLPATH, you can also set the variable LIBTOOLIZE.
70 if test -z "${LIBTOOLIZE}" || test -n "${LIBTOOLPATH}"; then
71 LIBTOOLIZE="${LIBTOOLPATH}libtoolize"
75 if test -z "${MAKE}"; then
79 # When using GNU sed, turn off as many GNU extensions as possible,
80 # to minimize the risk of accidentally using non-portable features.
81 # However, do this only for gnulib-tool itself, not for the code that
82 # gnulib-tool generates, since we don't want "sed --posix" to leak
83 # into makefiles. And do it only for sed versions 4.2 or newer,
84 # because "sed --posix" is buggy in GNU sed 4.1.5, see
85 # <http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00225.html>.
86 if (alias) > /dev/null 2>&1 \
87 && echo | sed --posix -e d >/dev/null 2>&1 \
88 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
89 [1-3]* | 4.[01]*) false;; \
93 # Define sed as an alias.
94 # It is not always possible to use aliases. Aliases are guaranteed to work
95 # if the executing shell is bash and either it is invoked as /bin/sh or
96 # is a version >= 2.0, supporting shopt. This is the common case.
97 # Two other approaches (use of a variable $sed or of a function func_sed
98 # instead of an alias) require massive, fragile code changes.
99 # An other approach (use of function sed) requires `which sed` - but
100 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
101 if test -n "$BASH_VERSION"; then
102 shopt -s expand_aliases >/dev/null 2>&1
104 alias sed='sed --posix'
107 # sed_noop is a sed expression that does nothing.
108 # An empty expression does not work with the native 'sed' on AIX 6.1.
111 # sed_comments is true or false, depending whether 'sed' supports comments.
112 # (The GNU autoconf doc says that sed comments are not portable, but does
113 # not say which 'sed' versions are affected.)
114 if echo fo | sed -e 's/f/g/
116 s/o/e/' 2>/dev/null | grep ge > /dev/null; then
123 # outputs to stdout the --help usage message.
127 Usage: gnulib-tool --list
128 gnulib-tool --find filename
129 gnulib-tool --import [module1 ... moduleN]
131 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
132 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
133 gnulib-tool --test --dir=directory module1 ... moduleN
134 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
135 gnulib-tool --extract-description module
136 gnulib-tool --extract-status module
137 gnulib-tool --extract-notice module
138 gnulib-tool --extract-applicability module
139 gnulib-tool --extract-filelist module
140 gnulib-tool --extract-dependencies module
141 gnulib-tool --extract-autoconf-snippet module
142 gnulib-tool --extract-automake-snippet module
143 gnulib-tool --extract-include-directive module
144 gnulib-tool --extract-link-directive module
145 gnulib-tool --extract-license module
146 gnulib-tool --extract-maintainer module
147 gnulib-tool --extract-tests-module module
148 gnulib-tool --copy-file file [destination]
151 --list print the available module names
152 --find find the modules which contain the specified file
153 --import import the given modules into the current package;
154 if no modules are specified, update the current
155 package from the current gnulib
156 --update update the current package, restore files omitted
158 --create-testdir create a scratch package with the given modules
159 --create-megatestdir create a mega scratch package with the given modules
160 one by one and all together
161 --test test the combination of the given modules
162 (recommended to use CC=\"gcc -Wall\" here)
163 --megatest test the given modules one by one and all together
164 (recommended to use CC=\"gcc -Wall\" here)
165 --extract-description extract the description
166 --extract-status extract the status (obsolete or not)
167 --extract-notice extract the notice or banner
168 --extract-applicability extract the applicability
169 --extract-filelist extract the list of files
170 --extract-dependencies extract the dependencies
171 --extract-autoconf-snippet extract the snippet for configure.ac
172 --extract-automake-snippet extract the snippet for library makefile
173 --extract-include-directive extract the #include directive
174 --extract-link-directive extract the linker directive
175 --extract-license report the license terms of the source files
177 --extract-maintainer report the maintainer(s) inside gnulib
178 --extract-tests-module report the unit test module, if it exists
179 --copy-file copy a file that is not part of any module
182 --dir=DIRECTORY Specify the target directory.
183 For --import, this specifies where your
184 configure.ac can be found. Defaults to current
186 --local-dir=DIRECTORY Specify a local override directory where to look
187 up files before looking in gnulib's directory.
188 --cache-modules Enable module caching optimization.
189 --no-cache-modules Disable module caching optimization.
190 --verbose Increase verbosity. May be repeated.
191 --quiet Decrease verbosity. May be repeated.
193 Options for --import, --update:
194 --dry-run Only print what would have been done.
196 Options for --import, --create-[mega]testdir, --[mega]test:
197 --with-tests Include unit tests for the included modules.
198 --with-obsolete Include obsolete modules when they occur among the
199 dependencies. By default, dependencies to obsolete
201 --avoid=MODULE Avoid including the given MODULE. Useful if you
202 have code that provides equivalent functionality.
203 This option can be repeated.
204 --libtool Use libtool rules.
205 --no-libtool Don't use libtool rules.
207 Options for --import:
208 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
209 --source-base=DIRECTORY
210 Directory relative to --dir where source code is
211 placed (default \"lib\").
212 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
213 placed (default \"m4\").
214 --po-base=DIRECTORY Directory relative to --dir where *.po files are
215 placed (default \"po\").
216 --doc-base=DIRECTORY Directory relative to --dir where doc files are
217 placed (default \"doc\").
218 --tests-base=DIRECTORY
219 Directory relative to --dir where unit tests are
220 placed (default \"tests\").
221 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
222 tools are placed (default \"build-aux\").
223 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
224 Also modify license template from GPL to LGPL.
225 The version number of the LGPL can be specified;
226 the default is currently LGPLv3.
227 --makefile-name=NAME Name of makefile in automake syntax in the
228 source-base and tests-base directories
229 (default \"Makefile.am\").
230 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
231 'gl_INIT'. Default is 'gl'.
232 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
233 the package name. A suffix '-gnulib' is appended.
234 --vc-files Update version control related files.
235 --no-vc-files Don't update version control related files
236 (.gitignore and/or .cvsignore).
237 --no-changelog Don't update or create ChangeLog files.
239 Options for --import, --update, --create-[mega]testdir, --[mega]test:
240 -s, --symbolic, --symlink Make symbolic links instead of copying files.
241 --local-symlink Make symbolic links instead of copying files, only
242 for files from the local override directory.
244 Options for --import, --update:
245 -S, --more-symlinks Make symbolic links instead of copying files, and
246 don't replace copyright notices.
248 Report bugs to <bug-gnulib@gnu.org>."
252 # outputs to stdout the --version message.
256 if test -d "$gnulib_dir"/.git \
257 && (git --version) >/dev/null 2>/dev/null \
258 && (date --version) >/dev/null 2>/dev/null; then
259 # gnulib checked out from git.
260 sed_extract_first_date='/^Date/{
264 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
265 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
266 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
267 date=`echo "$date" | sed -e "$sed_year_before_time"`
268 # Use GNU date to compute the time in GMT.
269 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
270 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
272 if test -d "$gnulib_dir"/CVS \
273 && (cvs --version) >/dev/null 2>/dev/null; then
274 # gnulib checked out from CVS.
275 sed_extract_first_date='/^date: /{
276 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
279 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
281 # gnulib copy without versioning information.
282 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
286 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
288 gnulib-tool (GNU $package $date)$version
289 Copyright (C) $year Free Software Foundation, Inc.
290 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
291 This is free software: you are free to change and redistribute it.
292 There is NO WARRANTY, to the extent permitted by law.
294 Written by" "Bruno Haible" "and" "Simon Josefsson"
297 # func_emit_copyright_notice
298 # outputs to stdout a header for a generated file.
299 func_emit_copyright_notice ()
301 sed -n -e '/Copyright/ {
304 }' < "$self_abspathname"
306 echo "# This file is free software, distributed under the terms of the GNU"
307 echo "# General Public License. As a special exception to the GNU General"
308 echo "# Public License, this file may be distributed as part of a program"
309 echo "# that contains a configuration script generated by Autoconf, under"
310 echo "# the same distribution terms as the rest of that program."
312 echo "# Generated by gnulib-tool."
316 # exits with a given status.
317 # This function needs to be used, rather than 'exit', when a 'trap' handler is
318 # in effect that refers to $?.
325 # locates the directory where the gnulib repository lives
327 # - progname name of this program
329 # - self_abspathname absolute pathname of gnulib-tool
330 # - gnulib_dir absolute pathname of gnulib repository
334 /*) self_abspathname="$progname" ;;
335 */*) self_abspathname=`pwd`/"$progname" ;;
338 # Iterate through the elements of $PATH.
339 # We use IFS=: instead of
340 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
341 # because the latter does not work when some PATH element contains spaces.
342 # We use a canonicalized $pathx instead of $PATH, because empty PATH
343 # elements are by definition equivalent to '.', however field splitting
344 # according to IFS=: loses empty fields in many shells:
345 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
346 # beginning, at the end, and in the middle),
347 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
348 # at the beginning and at the end,
349 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
350 # Solaris lose empty fields at the end.
351 # The 'case' statement is an optimization, to avoid evaluating the
352 # explicit canonicalization command when $PATH contains no empty fields.
354 if test "${PATH_SEPARATOR+set}" != set; then
356 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
357 chmod +x "$tmp"/conf.sh
358 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
365 if test "$PATH_SEPARATOR" = ";"; then
366 # On Windows, programs are searched in "." before $PATH.
369 # On Unix, we have to convert empty PATH elements to ".".
373 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
378 IFS="$PATH_SEPARATOR"
382 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
383 self_abspathname="$d/$progname"
388 if test -z "$self_abspathname"; then
389 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
393 while test -h "$self_abspathname"; do
394 # Resolve symbolic link.
395 linkval=`func_readlink "$self_abspathname"`
396 test -n "$linkval" || break
398 /* ) self_abspathname="$linkval" ;;
399 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
402 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
406 # creates a temporary directory.
408 # - progname name of this program
410 # - tmp pathname of freshly created temporary directory
413 # Use the environment variable TMPDIR, falling back to /tmp. This allows
414 # users to specify a different temporary directory, for example, if their
415 # /tmp is filled up or too small.
418 # Use the mktemp program if available. If not available, hide the error
420 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
421 test -n "$tmp" && test -d "$tmp"
424 # Use a simple mkdir command. It is guaranteed to fail if the directory
425 # already exists. $RANDOM is bash specific and expands to empty in shells
426 # other than bash, ksh and zsh. Its use does not increase security;
427 # rather, it minimizes the probability of failure in a very cluttered /tmp
429 tmp=$TMPDIR/gl$$-$RANDOM
430 (umask 077 && mkdir "$tmp")
433 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
438 # func_append var value
439 # appends the given value to the shell variable var.
440 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
441 # Use bash's += operator. It reduces complexity of appending repeatedly to
442 # a single variable from O(n^2) to O(n).
447 fast_func_append=true
451 eval "$1=\"\$$1\$2\""
453 fast_func_append=false
456 # func_remove_prefix var prefix
457 # removes the given prefix from the value of the shell variable var.
458 # var should be the name of a shell variable.
459 # Its value should not contain a newline and not start or end with whitespace.
460 # prefix should not contain the characters "$`\{}[]^|.
461 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
462 func_remove_prefix ()
466 fast_func_remove_prefix=true
468 func_remove_prefix ()
470 eval "value=\"\$$1\""
474 sed_escape_dots='s/\([.]\)/\\\1/g'
475 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
478 value=`echo "$value" | sed -e "s|^${prefix}||"`
479 eval "$1=\"\$value\""
481 fast_func_remove_prefix=false
484 # func_remove_suffix var suffix
485 # removes the given suffix from the value of the shell variable var.
486 # var should be the name of a shell variable.
487 # Its value should not contain a newline and not start or end with whitespace.
488 # suffix should not contain the characters "$`\{}[]^|.
489 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
490 func_remove_suffix ()
494 fast_func_remove_suffix=true
496 func_remove_suffix ()
498 eval "value=\"\$$1\""
502 sed_escape_dots='s/\([.]\)/\\\1/g'
503 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
506 value=`echo "$value" | sed -e "s|${suffix}\$||"`
507 eval "$1=\"\$value\""
509 fast_func_remove_suffix=false
512 # func_fatal_error message
513 # outputs to stderr a fatal error message, and terminates the program.
515 # - progname name of this program
518 echo "$progname: *** $1" 1>&2
519 echo "$progname: *** Stop." 1>&2
523 # func_warning message
524 # Outputs to stderr a warning message,
527 echo "gnulib-tool: warning: $1" 1>&2
530 # func_readlink SYMLINK
531 # outputs the target of the given symlink.
532 if (type -p readlink) > /dev/null 2>&1; then
535 # Use the readlink program from GNU coreutils.
541 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
542 # would do the wrong thing if the link target contains " -> ".
543 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
547 # func_relativize DIR1 DIR2
548 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
550 # - DIR1 relative pathname, relative to the current directory
551 # - DIR2 relative pathname, relative to the current directory
553 # - reldir relative pathname of DIR2, relative to DIR1
559 sed_first='s,^\([^/]*\)/.*$,\1,'
560 sed_rest='s,^[^/]*/*,,'
561 sed_last='s,^.*/\([^/]*\)$,\1,'
562 sed_butlast='s,/*[^/]*$,,'
563 while test -n "$dir1"; do
564 first=`echo "$dir1" | sed -e "$sed_first"`
565 if test "$first" != "."; then
566 if test "$first" = ".."; then
567 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
568 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
570 first2=`echo "$dir2" | sed -e "$sed_first"`
571 if test "$first2" = "$first"; then
572 dir2=`echo "$dir2" | sed -e "$sed_rest"`
576 dir0="$dir0"/"$first"
579 dir1=`echo "$dir1" | sed -e "$sed_rest"`
584 # func_relconcat DIR1 DIR2
585 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
587 # - DIR1 relative pathname, relative to the current directory
588 # - DIR2 relative pathname, relative to DIR1
590 # - relconcat DIR1/DIR2, relative to the current directory
595 sed_first='s,^\([^/]*\)/.*$,\1,'
596 sed_rest='s,^[^/]*/*,,'
597 sed_last='s,^.*/\([^/]*\)$,\1,'
598 sed_butlast='s,/*[^/]*$,,'
600 first=`echo "$dir2" | sed -e "$sed_first"`
601 if test "$first" = "."; then
602 dir2=`echo "$dir2" | sed -e "$sed_rest"`
603 if test -z "$dir2"; then
608 last=`echo "$dir1" | sed -e "$sed_last"`
609 while test "$last" = "."; do
610 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
611 last=`echo "$dir1" | sed -e "$sed_last"`
613 if test -z "$dir1"; then
617 if test "$first" = ".."; then
618 if test "$last" = ".."; then
619 relconcat="$dir1/$dir2"
622 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
623 dir2=`echo "$dir2" | sed -e "$sed_rest"`
624 if test -z "$dir1"; then
628 if test -z "$dir2"; then
633 relconcat="$dir1/$dir2"
641 # Like ln -s, except that SRC is given relative to the current directory (or
642 # absolute), not given relative to the directory of DEST.
648 *) # SRC is relative.
651 ln -s "`pwd`/$1" "$2" ;;
652 *) # DEST is relative too.
653 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
654 test -n "$ln_destdir" || ln_destdir="."
655 func_relativize "$ln_destdir" "$1"
663 # func_ln_if_changed SRC DEST
664 # Like func_ln, but avoids munging timestamps if the link is correct.
665 func_ln_if_changed ()
667 if test $# -ne 2; then
668 echo "usage: func_ln_if_changed SRC DEST" >&2
670 ln_target=`func_readlink "$2"`
671 if test -h "$2" && test "$1" = "$ln_target"; then
679 # Ensure an 'echo' command that
680 # 1. does not interpret backslashes and
681 # 2. does not print an error message "broken pipe" when writing into a pipe
684 # Test cases for problem 1:
685 # echo '\n' | wc -l prints 1 when OK, 2 when KO
686 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
687 # Test cases for problem 2:
688 # echo hi | true frequently prints
689 # "bash: echo: write error: Broken pipe"
690 # to standard error in bash 3.2.
692 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
693 # BSD echo interprets '-n' as an option, which is also not desirable).
694 # Nowadays the problem occurs in 4 situations:
695 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
696 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
697 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
698 # - in zsh, when sh-emulation is not set,
699 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
700 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
701 # - in Solaris /bin/sh and OSF/1 /bin/sh.
702 # We try the following workarounds:
703 # - for all: respawn using $CONFIG_SHELL if that is set and works.
704 # - for bash >= 2.04: unset the shell option xpg_echo.
705 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
706 # - for bash < 2.0: define echo to a function that uses cat of a here document.
707 # - for zsh: turn sh-emulation on.
708 # - for ksh: alias echo to 'print -r'.
709 # - for ksh: alias echo to a function that uses cat of a here document.
710 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
711 # the ksh workaround.
712 # - otherwise: respawn using /bin/sh and rely on the workarounds.
713 # When respawning, we pass --no-reexec as first argument, so as to avoid
714 # turning this script into a fork bomb in unlucky situations.
716 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
717 # the 'printf' built-in. See
718 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
719 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
720 # The workaround is: define echo to a function that uses the printf built-in.
722 if echo '\t' | grep t > /dev/null; then
723 have_echo=yes # Lucky!
725 # Try the workarounds.
726 # Respawn using $CONFIG_SHELL if that is set and works.
727 if test -z "$have_echo" \
728 && test "X$1" != "X--no-reexec" \
729 && test -n "$CONFIG_SHELL" \
730 && test -f "$CONFIG_SHELL" \
731 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
732 exec $CONFIG_SHELL "$0" --no-reexec "$@"
735 # For bash >= 2.04: unset the shell option xpg_echo.
736 if test -z "$have_echo" \
737 && test -n "$BASH_VERSION" \
738 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
742 # For bash >= 2.0: define echo to a function that uses the printf built-in.
743 # For bash < 2.0: define echo to a function that uses cat of a here document.
744 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
745 # Also handle problem 2, specific to bash 3.2, here.
746 if { test -z "$have_echo" \
747 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
749 && test -n "$BASH_VERSION"; then \
750 if type printf 2>/dev/null | grep / > /dev/null; then
751 # 'printf' is not a shell built-in.
759 # 'printf' is a shell built-in.
765 if echo '\t' | grep t > /dev/null; then
769 # For zsh: turn sh-emulation on.
770 if test -z "$have_echo" \
771 && test -n "$ZSH_VERSION" \
772 && (emulate sh) >/dev/null 2>&1; then
775 # For ksh: alias echo to 'print -r'.
776 if test -z "$have_echo" \
777 && (type print) >/dev/null 2>&1; then
778 # A 'print' command exists.
779 if type print 2>/dev/null | grep / > /dev/null; then
782 # 'print' is a shell built-in.
783 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
784 # 'print' is the ksh shell built-in.
785 alias echo='print -r'
789 if test -z "$have_echo" \
790 && echo '\t' | grep t > /dev/null; then
793 # For ksh: alias echo to a function that uses cat of a here document.
794 # The ksh manual page says:
795 # "Aliasing is performed when scripts are read, not while they are executed.
796 # Therefore, for an alias to take effect, the alias definition command has
797 # to be executed before the command which references the alias is read."
798 # Because of this, we have to play strange tricks with have_echo, to ensure
799 # that the top-level statement containing the test starts after the 'alias'
801 if test -z "$have_echo"; then
808 alias echo=bsd_echo 2>/dev/null
810 if test -z "$have_echo" \
811 && echo '\t' | grep t > /dev/null; then
814 if test -z "$have_echo"; then
815 unalias echo 2>/dev/null
817 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
818 if test -z "$have_echo" \
819 && test "X$1" != "X--no-reexec" \
820 && test -f /bin/ksh; then
821 exec /bin/ksh "$0" --no-reexec "$@"
824 # Otherwise: respawn using /bin/sh.
825 if test -z "$have_echo" \
826 && test "X$1" != "X--no-reexec" \
827 && test -f /bin/sh; then
828 exec /bin/sh "$0" --no-reexec "$@"
831 if test -z "$have_echo"; then
832 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
834 if echo '\t' | grep t > /dev/null; then
837 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
839 if test "X$1" = "X--no-reexec"; then
843 # Command-line option processing.
844 # Removes the OPTIONS from the arguments. Sets the variables:
845 # - mode list or import or create-testdir or create-megatestdir
846 # - destdir from --dir
847 # - local_gnulib_dir from --local-dir
848 # - modcache true or false, from --cache-modules/--no-cache-modules
849 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
850 # - libname, supplied_libname from --lib
851 # - sourcebase from --source-base
852 # - m4base from --m4-base
853 # - pobase from --po-base
854 # - docbase from --doc-base
855 # - testsbase from --tests-base
856 # - auxdir from --aux-dir
857 # - inctests true if --with-tests was given, blank otherwise
858 # - incobsolete true if --with-obsolete was given, blank otherwise
859 # - avoidlist list of modules to avoid, from --avoid
860 # - lgpl yes or a number if --lgpl was given, blank otherwise
861 # - makefile_name from --makefile-name
862 # - libtool true if --libtool was given, false if --no-libtool was
863 # given, blank otherwise
864 # - macro_prefix from --macro-prefix
865 # - po_domain from --po-domain
866 # - vc_files true if --vc-files was given, false if --no-vc-files was
867 # given, blank otherwise
868 # - autoconf_minversion minimum supported autoconf version
869 # - do_changelog false if --no-changelog was given, : otherwise
870 # - doit : if actions shall be executed, false if only to be printed
871 # - symbolic true if --symlink or --more-symlinks was given, blank
873 # - lsymbolic true if --local-symlink was given, blank otherwise
874 # - do_copyrights blank if --more-symlinks was given, true otherwise
906 while test $# -gt 0; do
911 --find | --fin | --fi | --f )
914 --import | --impor | --impo | --imp | --im | --i )
917 --update | --updat | --upda | --upd | --up | --u )
920 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
923 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
924 mode=create-megatestdir
926 --test | --tes | --te | --t )
929 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
933 mode=`echo "X$1" | sed -e 's/^X--//'`
935 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop | --co )
941 func_fatal_error "missing argument for --dir"
946 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
951 func_fatal_error "missing argument for --local-dir"
956 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
958 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
961 --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 )
964 --verbose | --verbos | --verbo | --verb )
965 verbose=`expr $verbose + 1`
967 --quiet | --quie | --qui | --qu | --q )
968 verbose=`expr $verbose - 1`
973 func_fatal_error "missing argument for --lib"
976 supplied_libname=true
979 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
980 supplied_libname=true
985 func_fatal_error "missing argument for --source-base"
990 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
995 func_fatal_error "missing argument for --m4-base"
1000 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1004 if test $# = 0; then
1005 func_fatal_error "missing argument for --po-base"
1010 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1014 if test $# = 0; then
1015 func_fatal_error "missing argument for --doc-base"
1020 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1024 if test $# = 0; then
1025 func_fatal_error "missing argument for --tests-base"
1030 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1034 if test $# = 0; then
1035 func_fatal_error "missing argument for --aux-dir"
1040 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1050 if test $# = 0; then
1051 func_fatal_error "missing argument for --avoid"
1053 func_append avoidlist " $1"
1056 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1057 func_append avoidlist " $arg"
1063 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1066 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1072 if test $# = 0; then
1073 func_fatal_error "missing argument for --makefile-name"
1078 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1088 if test $# = 0; then
1089 func_fatal_error "missing argument for --macro-prefix"
1094 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1098 if test $# = 0; then
1099 func_fatal_error "missing argument for --po-domain"
1104 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1112 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1118 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1121 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1124 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1128 --help | --hel | --he | --h )
1131 --version | --versio | --versi | --vers )
1135 # Stop option processing
1139 echo "gnulib-tool: unknown option $1" 1>&2
1140 echo "Try 'gnulib-tool --help' for more information." 1>&2
1147 if test "$mode" = update; then
1148 if test $# != 0; then
1149 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1150 echo "Try 'gnulib-tool --help' for more information." 1>&2
1151 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1152 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1155 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1156 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1157 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1158 || test -n "$inctests" || test -n "$incobsolete" \
1159 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1160 || test -n "$macro_prefix" || test -n "$po_domain" \
1161 || test -n "$vc_files"; then
1162 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1163 echo "Try 'gnulib-tool --help' for more information." 1>&2
1164 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1165 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1170 if test -n "$pobase" && test -z "$po_domain"; then
1171 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1172 echo "Try 'gnulib-tool --help' for more information." 1>&2
1175 if test -z "$pobase" && test -n "$po_domain"; then
1176 func_warning "--po-domain has no effect without a --po-base option"
1179 # Determine the minimum supported autoconf version from the project's
1181 DEFAULT_AUTOCONF_MINVERSION="2.59"
1182 autoconf_minversion=
1184 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1185 if test -f "$destdir"/configure.ac; then
1186 configure_ac="$destdir/configure.ac"
1188 if test -f "$destdir"/configure.in; then
1189 configure_ac="$destdir/configure.in"
1193 if test -f configure.ac; then
1194 configure_ac="configure.ac"
1196 if test -f configure.in; then
1197 configure_ac="configure.in"
1201 if test -n "$configure_ac"; then
1202 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1203 # because when some m4 files are omitted from a CVS repository,
1204 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1205 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1206 # autom4te: m4 failed with exit status: 1
1213 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1215 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1216 if test -n "$prereqs"; then
1217 autoconf_minversion=`
1218 for version in $prereqs; do echo $version; done |
1219 LC_ALL=C sort -nru | sed -e 1q
1223 if test -z "$autoconf_minversion"; then
1224 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1226 case "$autoconf_minversion" in
1227 1.* | 2.[0-4]* | 2.5[0-8]*)
1228 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1231 # Remove trailing slashes from the directory names. This is necessary for
1232 # m4base (to avoid an error in func_import) and optional for the others.
1233 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1234 case "$local_gnulib_dir" in
1235 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1237 case "$sourcebase" in
1238 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1241 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1244 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1247 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1249 case "$testsbase" in
1250 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1253 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1259 trap 'exit_status=$?
1260 if test "$signal" != 0; then
1261 echo "caught signal $signal" >&2
1264 exit $exit_status' 0
1265 for signal in 1 2 3 13 15; do
1266 trap '{ signal='$signal'; func_exit 1; }' $signal
1270 # func_lookup_file file
1271 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1274 # - local_gnulib_dir from --local-dir
1276 # - lookedup_file name of the merged (combined) file
1277 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1281 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1282 lookedup_file="$local_gnulib_dir/$lkfile"
1285 if test -f "$gnulib_dir/$lkfile"; then
1286 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1287 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1288 rm -f "$tmp/$lkbase"
1289 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1290 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1291 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1292 lookedup_file="$tmp/$lkbase"
1295 lookedup_file="$gnulib_dir/$lkfile"
1299 func_fatal_error "file $gnulib_dir/$lkfile not found"
1304 # func_sanitize_modulelist
1305 # receives a list of possible module names on standard input, one per line.
1306 # It removes those which are just file names unrelated to modules, and outputs
1307 # the resulting list to standard output, one per line.
1308 func_sanitize_modulelist ()
1310 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1311 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1312 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1313 -e '/^README$/d' -e '/\/README$/d' \
1314 -e '/^TEMPLATE$/d' \
1315 -e '/^TEMPLATE-EXTENDED$/d' \
1316 -e '/^TEMPLATE-TESTS$/d' \
1323 # - local_gnulib_dir from --local-dir
1326 # Filter out metainformation files like README, which are not modules.
1327 # Filter out unit test modules; they can be retrieved through
1328 # --extract-tests-module if desired.
1330 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1331 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1332 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1335 | func_sanitize_modulelist \
1336 | sed -e '/-tests$/d' \
1340 # func_verify_module
1341 # verifies a module name
1343 # - local_gnulib_dir from --local-dir
1344 # - module module name argument
1345 func_verify_module ()
1347 if { test -f "$gnulib_dir/modules/$module" \
1348 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1349 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1350 && test "CVS" != "$module" \
1351 && test "ChangeLog" != "$module" \
1352 && test "COPYING" != "$module" \
1353 && test "README" != "$module" \
1354 && test "TEMPLATE" != "$module" \
1355 && test "TEMPLATE-EXTENDED" != "$module" \
1356 && test "TEMPLATE-TESTS" != "$module"; then
1357 # OK, $module is a correct module name.
1358 # Verify that building the module description with 'patch' succeeds.
1359 func_lookup_file "modules/$module"
1361 func_warning "module $module doesn't exist"
1366 # func_verify_nontests_module
1367 # verifies a module name, excluding tests modules
1369 # - local_gnulib_dir from --local-dir
1370 # - module module name argument
1371 func_verify_nontests_module ()
1374 *-tests ) module= ;;
1375 * ) func_verify_module ;;
1379 # func_verify_tests_module
1380 # verifies a module name, considering only tests modules
1382 # - local_gnulib_dir from --local-dir
1383 # - module module name argument
1384 func_verify_tests_module ()
1387 *-tests ) func_verify_module ;;
1392 # Suffix of a sed expression that extracts a particular field from a
1393 # module description.
1394 # A field starts with a line that contains a keyword, such as 'Description',
1395 # followed by a colon and optional whitespace. All following lines, up to
1396 # the next field (or end of file if there is none) form the contents of the
1398 # An absent field is equivalent to a field with empty contents.
1399 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1400 sed_extract_prog=':[ ]*$/ {
1403 s/^Description:[ ]*$//
1406 s/^Applicability:[ ]*$//
1408 s/^Depends-on:[ ]*$//
1409 s/^configure\.ac-early:[ ]*$//
1410 s/^configure\.ac:[ ]*$//
1411 s/^Makefile\.am:[ ]*$//
1415 s/^Maintainer:[ ]*$//
1422 # Piece of a sed expression that converts a field header line to a shell
1424 # NOTE: Keep this in sync with sed_extract_prog above!
1425 sed_extract_field_header='
1426 s/^Description:[ ]*$/description/
1427 s/^Status:[ ]*$/status/
1428 s/^Notice:[ ]*$/notice/
1429 s/^Applicability:[ ]*$/applicability/
1430 s/^Files:[ ]*$/files/
1431 s/^Depends-on:[ ]*$/dependson/
1432 s/^configure\.ac-early:[ ]*$/configureac_early/
1433 s/^configure\.ac:[ ]*$/configureac/
1434 s/^Makefile\.am:[ ]*$/makefile/
1435 s/^Include:[ ]*$/include/
1437 s/^License:[ ]*$/license/
1438 s/^Maintainer:[ ]*$/maintainer/'
1442 # Note: The 'eval' silences stderr output in dash.
1443 if declare -A x 2>/dev/null && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }; then
1444 # Zsh 4 and Bash 4 have associative arrays.
1445 have_associative=true
1447 # For other shells, use 'eval' with computed shell variable names.
1448 have_associative=false
1451 if $have_associative; then
1453 # Declare the associative arrays.
1454 declare -A modcache_cached
1455 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1456 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1457 eval "$declare_script"
1461 # func_cache_var module
1462 # computes the cache variable name corresponding to $module.
1463 # Note: This computation can map different module names to the same
1464 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1465 # to protect against this case.
1467 # - cachevar a shell variable name
1468 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1469 # Bash 2.0 and newer, ksh, and zsh support the syntax
1470 # ${param//pattern/replacement}
1471 # as a shorthand for
1472 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1473 # Note: The 'eval' above silences stderr output in dash.
1476 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1483 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1492 # func_init_sed_convert_to_cache_statements
1494 # - modcachevar_assignment
1496 # - sed_convert_to_cache_statements
1497 func_init_sed_convert_to_cache_statements ()
1499 # 'sed' script that turns a module description into shell script
1500 # assignments, suitable to be eval'ed. All active characters are escaped.
1503 # Some module's description
1508 # modcache_description[$1]=\
1509 # 'Some module'"'"'s description
1511 # modcache_files[$1]=\
1514 # c_MODULE_description_set=set; c_MODULE_description=\
1515 # 'Some module'"'"'s description
1517 # c_MODULE_files_set=set; c_MODULE_files=\
1519 # The script consists of two parts:
1520 # 1) Ignore the lines before the first field header.
1521 # 2) A loop, treating non-field-header lines by escaping single quotes
1522 # and adding a closing quote in the last line,
1523 sed_convert_to_cache_statements="
1525 # Here we have not yet seen a field header.
1527 # See if the current line contains a field header.
1530 ${sed_extract_field_header}
1533 # No field header. Ignore the line.
1535 # Read the next line. Upon EOF, just exit.
1540 # The current line contains a field header.
1542 # Turn it into the beginning of an assignment.
1543 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1545 # Move it to the hold space. Don't print it yet,
1546 # because we want no assignment if the field is empty.
1549 # Read the next line.
1550 # Upon EOF, the field was empty. Print no assignment. Just exit.
1553 # See if the current line contains a field header.
1556 ${sed_extract_field_header}
1557 # If it is, the previous field was empty. Print no assignment.
1560 # Not a field header.
1562 # Print the previous line, held in the hold space.
1567 # Transform single quotes.
1570 # Prepend a single quote.
1575 # Move it to the hold space.
1578 # Read the next line.
1585 # See if the current line contains a field header.
1588 ${sed_extract_field_header}
1591 # Print the previous line, held in the hold space.
1596 # Transform single quotes.
1603 # Print the previous line, held in the hold space, with a single quote
1604 # to end the assignment.
1614 # Print the previous line, held in the hold space, with a single quote
1615 # to end the assignment.
1622 if ! $sed_comments; then
1624 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1625 | sed -e 's/^ *//' -e 's/^#.*//'`
1629 if $have_associative; then
1630 # sed_convert_to_cache_statements does not depend on the module.
1631 modcachevar_assignment='modcache_\1[$1]='
1632 func_init_sed_convert_to_cache_statements
1635 # func_cache_lookup_module module
1637 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1638 # of its relevant data in a cache in the memory of the processing shell. If
1639 # already cached, it does not look it up again, thus saving file access time.
1641 # - module non-empty string
1642 # Output if $have_associative:
1643 # - modcache_cached[$module] set to yes
1644 # - modcache_description[$module] ==
1645 # - modcache_status[$module] \ set to the field's value, minus the
1646 # - ... / final newline,
1647 # - modcache_maintainer[$module] == or unset if the field's value is empty
1648 # Output if ! $have_associative:
1649 # - cachevar a shell variable name
1650 # - ${cachevar}_cached set to $module
1651 # - ${cachevar}_description ==
1652 # - ${cachevar}_status \ set to the field's value, minus the
1653 # - ... / final newline,
1654 # - ${cachevar}_maintainer == or unset if the field's value is empty
1655 # - ${cachevar}_description_set ==
1656 # - ${cachevar}_status_set \ set to non-empty if the field's value
1657 # - ... / is non-empty,
1658 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1659 func_cache_lookup_module ()
1661 if $have_associative; then
1662 cached=${modcache_cached[$1]}
1665 eval "cached=\"\$${cachevar}_cached\""
1667 if test -z "$cached"; then
1668 # Not found in cache. Look it up on the file system.
1669 func_lookup_file "modules/$1"
1670 if $have_associative; then
1671 modcache_cached[$1]=yes
1673 eval "${cachevar}_cached=\"\$1\""
1675 if ! $have_associative; then
1676 # sed_convert_to_cache_statements depends on the module.
1677 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1678 func_init_sed_convert_to_cache_statements
1680 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1681 eval "$cache_statements"
1683 if ! $have_associative; then
1684 if test "$1" != "$cached"; then
1685 func_fatal_error "cache variable collision between $1 and $cached"
1693 # func_get_description module
1695 # - local_gnulib_dir from --local-dir
1696 # - modcache true or false, from --cache-modules/--no-cache-modules
1697 func_get_description ()
1699 if ! $modcache; then
1700 func_lookup_file "modules/$1"
1701 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1703 func_cache_lookup_module "$1"
1704 # Output the field's value, including the final newline (if any).
1705 if $have_associative; then
1706 if test -n "${modcache_description[$1]+set}"; then
1707 echo "${modcache_description[$1]}"
1710 eval "field_set=\"\$${cachevar}_description_set\""
1711 if test -n "$field_set"; then
1712 eval "field_value=\"\$${cachevar}_description\""
1713 echo "${field_value}"
1719 # func_get_status module
1721 # - local_gnulib_dir from --local-dir
1722 # - modcache true or false, from --cache-modules/--no-cache-modules
1725 if ! $modcache; then
1726 func_lookup_file "modules/$1"
1727 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1729 func_cache_lookup_module "$1"
1730 # Output the field's value, including the final newline (if any).
1731 if $have_associative; then
1732 if test -n "${modcache_status[$1]+set}"; then
1733 echo "${modcache_status[$1]}"
1736 eval "field_set=\"\$${cachevar}_status_set\""
1737 if test -n "$field_set"; then
1738 eval "field_value=\"\$${cachevar}_status\""
1739 echo "${field_value}"
1745 # func_get_notice module
1747 # - local_gnulib_dir from --local-dir
1748 # - modcache true or false, from --cache-modules/--no-cache-modules
1751 if ! $modcache; then
1752 func_lookup_file "modules/$1"
1753 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1755 func_cache_lookup_module "$1"
1756 # Output the field's value, including the final newline (if any).
1757 if $have_associative; then
1758 if test -n "${modcache_notice[$1]+set}"; then
1759 echo "${modcache_notice[$1]}"
1762 eval "field_set=\"\$${cachevar}_notice_set\""
1763 if test -n "$field_set"; then
1764 eval "field_value=\"\$${cachevar}_notice\""
1765 echo "${field_value}"
1771 # func_get_applicability module
1773 # - local_gnulib_dir from --local-dir
1774 # - modcache true or false, from --cache-modules/--no-cache-modules
1775 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1776 func_get_applicability ()
1778 if ! $modcache; then
1779 func_lookup_file "modules/$1"
1780 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1782 func_cache_lookup_module "$1"
1783 # Get the field's value, without the final newline.
1784 if $have_associative; then
1785 my_applicability="${modcache_applicability[$1]}"
1787 eval "my_applicability=\"\$${cachevar}_applicability\""
1790 if test -n "$my_applicability"; then
1791 echo $my_applicability
1793 # The default is 'main' or 'tests', depending on the module's name.
1795 *-tests) echo "tests";;
1801 # func_get_filelist module
1803 # - local_gnulib_dir from --local-dir
1804 # - modcache true or false, from --cache-modules/--no-cache-modules
1805 func_get_filelist ()
1807 if ! $modcache; then
1808 func_lookup_file "modules/$1"
1809 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1811 func_cache_lookup_module "$1"
1812 # Output the field's value, including the final newline (if any).
1813 if $have_associative; then
1814 if test -n "${modcache_files[$1]+set}"; then
1815 echo "${modcache_files[$1]}"
1818 eval "field_set=\"\$${cachevar}_files_set\""
1819 if test -n "$field_set"; then
1820 eval "field_value=\"\$${cachevar}_files\""
1821 echo "${field_value}"
1826 echo m4/gnulib-common.m4
1827 case "$autoconf_minversion" in
1834 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
1835 # stores in outputvar the filtered and processed filelist. Filtering: Only the
1836 # elements starting with prefix and ending with suffix are considered.
1837 # Processing: removed_prefix and removed_suffix are removed from each element,
1838 # added_prefix and added_suffix are added to each element.
1839 # prefix, suffix should not contain shell-special characters.
1840 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
1841 # added_prefix, added_suffix should not contain the characters \|&.
1842 func_filter_filelist ()
1844 if test "$2" != "$nl" \
1845 || { $fast_func_append \
1846 && { test -z "$6" || $fast_func_remove_prefix; } \
1847 && { test -z "$7" || $fast_func_remove_suffix; }; \
1851 # Do not quote possibly-empty parameters in case patterns,
1852 # AIX and HP-UX ksh won't match them if they are empty.
1855 if test -n "$6"; then
1856 func_remove_prefix fff "$6"
1858 if test -n "$7"; then
1859 func_remove_suffix fff "$7"
1862 if test -z "$ffflist"; then
1865 func_append ffflist "$2${fff}"
1871 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
1872 ffflist=`for fff in $3; do
1874 $4*$5) echo "$fff" ;;
1876 done | sed -e "$sed_fff_filter"`
1878 eval "$1=\"\$ffflist\""
1881 # func_get_dependencies module
1883 # - local_gnulib_dir from --local-dir
1884 # - modcache true or false, from --cache-modules/--no-cache-modules
1885 func_get_dependencies ()
1887 # ${module}-tests always implicitly depends on ${module}.
1891 func_remove_suffix fgd1 '-tests'
1895 # Then the explicit dependencies listed in the module description.
1896 if ! $modcache; then
1897 func_lookup_file "modules/$1"
1898 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1900 func_cache_lookup_module "$1"
1901 # Output the field's value, including the final newline (if any).
1902 if $have_associative; then
1903 if test -n "${modcache_dependson[$1]+set}"; then
1904 echo "${modcache_dependson[$1]}"
1907 eval "field_set=\"\$${cachevar}_dependson_set\""
1908 if test -n "$field_set"; then
1909 eval "field_value=\"\$${cachevar}_dependson\""
1910 echo "${field_value}"
1916 # func_get_autoconf_early_snippet module
1918 # - local_gnulib_dir from --local-dir
1919 # - modcache true or false, from --cache-modules/--no-cache-modules
1920 func_get_autoconf_early_snippet ()
1922 if ! $modcache; then
1923 func_lookup_file "modules/$1"
1924 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1926 func_cache_lookup_module "$1"
1927 # Output the field's value, including the final newline (if any).
1928 if $have_associative; then
1929 if test -n "${modcache_configureac_early[$1]+set}"; then
1930 echo "${modcache_configureac_early[$1]}"
1933 eval "field_set=\"\$${cachevar}_configureac_early_set\""
1934 if test -n "$field_set"; then
1935 eval "field_value=\"\$${cachevar}_configureac_early\""
1936 echo "${field_value}"
1942 # func_get_autoconf_snippet module
1944 # - local_gnulib_dir from --local-dir
1945 # - modcache true or false, from --cache-modules/--no-cache-modules
1946 func_get_autoconf_snippet ()
1948 if ! $modcache; then
1949 func_lookup_file "modules/$1"
1950 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1952 func_cache_lookup_module "$1"
1953 # Output the field's value, including the final newline (if any).
1954 if $have_associative; then
1955 if test -n "${modcache_configureac[$1]+set}"; then
1956 echo "${modcache_configureac[$1]}"
1959 eval "field_set=\"\$${cachevar}_configureac_set\""
1960 if test -n "$field_set"; then
1961 eval "field_value=\"\$${cachevar}_configureac\""
1962 echo "${field_value}"
1968 # func_get_automake_snippet module
1970 # - local_gnulib_dir from --local-dir
1971 # - modcache true or false, from --cache-modules/--no-cache-modules
1972 func_get_automake_snippet ()
1974 if ! $modcache; then
1975 func_lookup_file "modules/$1"
1976 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1978 func_cache_lookup_module "$1"
1979 # Output the field's value, including the final newline (if any).
1980 if $have_associative; then
1981 if test -n "${modcache_makefile[$1]+set}"; then
1982 echo "${modcache_makefile[$1]}"
1985 eval "field_set=\"\$${cachevar}_makefile_set\""
1986 if test -n "$field_set"; then
1987 eval "field_value=\"\$${cachevar}_makefile\""
1988 echo "${field_value}"
1994 # *-tests module live in tests/, not lib/.
1995 # Synthesize an EXTRA_DIST augmentation.
1996 all_files=`func_get_filelist $1`
1997 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
1998 extra_files="$tests_files"
1999 if test -n "$extra_files"; then
2000 echo "EXTRA_DIST +=" $extra_files
2005 # Synthesize an EXTRA_DIST augmentation.
2006 sed_combine_lines='/\\$/{
2013 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2014 already_mentioned_files=` \
2015 { if ! $modcache; then
2016 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2018 if $have_associative; then
2019 if test -n "${modcache_makefile[$1]+set}"; then
2020 echo "${modcache_makefile[$1]}"
2023 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2024 if test -n "$field_set"; then
2025 eval 'field_value="$'"${cachevar}"'_makefile"'
2026 echo "${field_value}"
2031 | sed -e "$sed_combine_lines" \
2032 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2033 all_files=`func_get_filelist $1`
2034 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2035 # Remove $already_mentioned_files from $lib_files.
2036 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2037 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2038 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2039 if test -n "$extra_files"; then
2040 echo "EXTRA_DIST +=" $extra_files
2043 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2044 # This is necessary so that automake can generate the right list of
2046 # A possible approach would be to use autom4te --trace of the redefined
2047 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2048 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2049 # inside autoconf's built-in macros are not missed).
2050 # But it's simpler and more robust to do it here, based on the file list.
2051 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2052 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2053 # automake will generate a useless dependency; this is harmless.
2055 relocatable-prog-wrapper) ;;
2057 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2058 if test -n "$extra_files"; then
2059 echo "EXTRA_lib_SOURCES +=" $extra_files
2064 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2065 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2066 if test -n "$buildaux_files"; then
2067 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2068 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2071 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2072 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2073 if test -n "$top_files"; then
2074 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2075 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2082 # func_get_include_directive module
2084 # - local_gnulib_dir from --local-dir
2085 # - modcache true or false, from --cache-modules/--no-cache-modules
2086 func_get_include_directive ()
2089 if ! $modcache; then
2090 func_lookup_file "modules/$1"
2091 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2093 func_cache_lookup_module "$1"
2094 # Output the field's value, including the final newline (if any).
2095 if $have_associative; then
2096 if test -n "${modcache_include[$1]+set}"; then
2097 echo "${modcache_include[$1]}"
2100 eval "field_set=\"\$${cachevar}_include_set\""
2101 if test -n "$field_set"; then
2102 eval "field_value=\"\$${cachevar}_include\""
2103 echo "${field_value}"
2107 } | sed -e 's/^\(["<]\)/#include \1/'
2110 # func_get_link_directive module
2112 # - local_gnulib_dir from --local-dir
2113 # - modcache true or false, from --cache-modules/--no-cache-modules
2114 func_get_link_directive ()
2116 if ! $modcache; then
2117 func_lookup_file "modules/$1"
2118 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2120 func_cache_lookup_module "$1"
2121 # Output the field's value, including the final newline (if any).
2122 if $have_associative; then
2123 if test -n "${modcache_link[$1]+set}"; then
2124 echo "${modcache_link[$1]}"
2127 eval "field_set=\"\$${cachevar}_link_set\""
2128 if test -n "$field_set"; then
2129 eval "field_value=\"\$${cachevar}_link\""
2130 echo "${field_value}"
2136 # func_get_license module
2138 # - local_gnulib_dir from --local-dir
2139 # - modcache true or false, from --cache-modules/--no-cache-modules
2143 if ! $modcache; then
2144 func_lookup_file "modules/$1"
2145 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2147 func_cache_lookup_module "$1"
2148 # Output the field's value, including the final newline (if any).
2149 if $have_associative; then
2150 if test -n "${modcache_license[$1]+set}"; then
2151 echo "${modcache_license[$1]}"
2154 eval "field_set=\"\$${cachevar}_license_set\""
2155 if test -n "$field_set"; then
2156 eval "field_value=\"\$${cachevar}_license\""
2157 echo "${field_value}"
2161 # The default is GPL.
2163 } | sed -e 's,^ *$,,' | sed -e 1q
2166 # func_get_maintainer module
2168 # - local_gnulib_dir from --local-dir
2169 # - modcache true or false, from --cache-modules/--no-cache-modules
2170 func_get_maintainer ()
2172 if ! $modcache; then
2173 func_lookup_file "modules/$1"
2174 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2176 func_cache_lookup_module "$1"
2177 # Output the field's value, including the final newline (if any).
2178 if $have_associative; then
2179 if test -n "${modcache_maintainer[$1]+set}"; then
2180 echo "${modcache_maintainer[$1]}"
2183 eval "field_set=\"\$${cachevar}_maintainer_set\""
2184 if test -n "$field_set"; then
2185 eval "field_value=\"\$${cachevar}_maintainer\""
2186 echo "${field_value}"
2192 # func_get_tests_module module
2194 # - local_gnulib_dir from --local-dir
2195 func_get_tests_module ()
2197 # The naming convention for tests modules is hardwired: ${module}-tests.
2198 if test -f "$gnulib_dir/modules/$1"-tests \
2199 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2200 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2205 # func_acceptable module
2206 # tests whether a module is acceptable.
2208 # - avoidlist list of modules to avoid
2211 for avoid in $avoidlist; do
2212 if test "$avoid" = "$1"; then
2219 # func_modules_transitive_closure
2221 # - local_gnulib_dir from --local-dir
2222 # - modcache true or false, from --cache-modules/--no-cache-modules
2223 # - modules list of specified modules
2224 # - inctests true if tests should be included, blank otherwise
2225 # - incobsolete true if obsolete modules among dependencies should be
2226 # included, blank otherwise
2227 # - avoidlist list of modules to avoid
2228 # - tmp pathname of a temporary directory
2230 # - modules list of modules, including dependencies
2231 func_modules_transitive_closure ()
2233 # In order to process every module only once (for speed), process an "input
2234 # list" of modules, producing an "output list" of modules. During each round,
2235 # more modules can be queued in the input list. Once a module on the input
2236 # list has been processed, it is added to the "handled list", so we can avoid
2237 # to process it again.
2239 inmodules="$modules"
2241 while test -n "$inmodules"; do
2242 inmodules_this_round="$inmodules"
2243 inmodules= # Accumulator, queue for next round
2244 for module in $inmodules_this_round; do
2246 if test -n "$module"; then
2247 if func_acceptable $module; then
2248 func_append outmodules " $module"
2249 deps=`func_get_dependencies $module`
2250 # Duplicate dependencies are harmless, but Jim wants a warning.
2251 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2252 if test -n "$duplicated_deps"; then
2253 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2255 for dep in $deps; do
2256 if test -n "$incobsolete" \
2257 || { status=`func_get_status $dep`; test "$status" != obsolete; }; then
2258 func_append inmodules " $dep"
2261 if test -n "$inctests"; then
2262 testsmodule=`func_get_tests_module $module`
2263 if test -n "$testsmodule"; then
2264 func_append inmodules " $testsmodule"
2270 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2271 # Remove $handledmodules from $inmodules.
2272 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2273 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2275 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2276 rm -f "$tmp"/queued-modules
2279 # func_modules_add_dummy
2281 # - local_gnulib_dir from --local-dir
2282 # - modcache true or false, from --cache-modules/--no-cache-modules
2283 # - modules list of modules, including dependencies
2285 # - modules list of modules, including 'dummy' if needed
2286 func_modules_add_dummy ()
2288 # Determine whether any module provides a lib_SOURCES augmentation.
2290 sed_remove_backslash_newline=':a
2297 for module in $modules; do
2298 func_verify_nontests_module
2299 if test -n "$module"; then
2300 # Extract the value of "lib_SOURCES += ...".
2301 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2302 # Ignore .h files since they are not compiled.
2306 have_lib_SOURCES=yes
2313 # Add the dummy module, to make sure the library will be non-empty.
2314 if test -z "$have_lib_SOURCES"; then
2315 if func_acceptable "dummy"; then
2316 func_append modules " dummy"
2321 # func_modules_notice
2323 # - local_gnulib_dir from --local-dir
2324 # - modcache true or false, from --cache-modules/--no-cache-modules
2325 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2326 # - modules list of modules, including dependencies
2327 func_modules_notice ()
2329 if test $verbose -ge -1; then
2330 for module in $modules; do
2332 if test -n "$module"; then
2333 msg=`func_get_notice $module`
2334 if test -n "$msg"; then
2335 echo "Notice from module $module:"
2336 echo "$msg" | sed -e 's/^/ /'
2343 # func_modules_to_filelist
2345 # - local_gnulib_dir from --local-dir
2346 # - modcache true or false, from --cache-modules/--no-cache-modules
2347 # - modules list of modules, including dependencies
2349 # - files list of files
2350 func_modules_to_filelist ()
2353 for module in $modules; do
2355 if test -n "$module"; then
2356 fs=`func_get_filelist $module`
2357 func_append files " $fs"
2360 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2363 # func_execute_command command [args...]
2364 # Executes a command.
2365 # Uses also the variables
2366 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2367 func_execute_command ()
2369 if test $verbose -ge 0; then
2373 # Commands like automake produce output to stderr even when they succeed.
2374 # Turn this output off if the command succeeds.
2375 "$@" > "$tmp"/cmdout 2>&1
2377 if test $cmdret = 0; then
2381 cat "$tmp"/cmdout 1>&2
2388 # func_dest_tmpfilename file
2389 # determines the name of a temporary file (file is relative to destdir).
2391 # - destdir target directory
2392 # - doit : if actions shall be executed, false if only to be printed
2393 # - tmp pathname of a temporary directory
2395 # - tmpfile absolute filename of the temporary file
2396 func_dest_tmpfilename ()
2399 # Put the new contents of $file in a file in the same directory (needed
2400 # to guarantee that an 'mv' to "$destdir/$file" works).
2401 tmpfile="$destdir/$1.tmp"
2403 # Put the new contents of $file in a file in a temporary directory
2404 # (because the directory of "$file" might not exist).
2405 tmpfile="$tmp"/`basename "$1"`.tmp
2410 # copies a file from gnulib into the destination directory. The destination
2411 # is known to not exist.
2413 # - destdir target directory
2414 # - local_gnulib_dir from --local-dir
2415 # - modcache true or false, from --cache-modules/--no-cache-modules
2416 # - f the original file name
2417 # - lookedup_file name of the merged (combined) file
2418 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2419 # - g the rewritten file name
2420 # - tmpfile absolute filename of the temporary file
2421 # - doit : if actions shall be executed, false if only to be printed
2422 # - symbolic true if files should be symlinked, copied otherwise
2423 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2428 echo "Copying file $g"
2429 if { test -n "$symbolic" \
2430 || { test -n "$lsymbolic" \
2431 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2432 && test -z "$lookedup_tmp" \
2433 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2434 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2436 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2444 # copies a file from gnulib into the destination directory. The destination
2445 # is known to exist.
2447 # - destdir target directory
2448 # - local_gnulib_dir from --local-dir
2449 # - modcache true or false, from --cache-modules/--no-cache-modules
2450 # - f the original file name
2451 # - lookedup_file name of the merged (combined) file
2452 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2453 # - g the rewritten file name
2454 # - tmpfile absolute filename of the temporary file
2455 # - doit : if actions shall be executed, false if only to be printed
2456 # - symbolic true if files should be symlinked, copied otherwise
2457 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2459 # - already_present nonempty if the file should already exist, empty otherwise
2462 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2463 : # The file has not changed.
2467 if test -n "$already_present"; then
2468 echo "Updating file $g (backup in ${g}~)"
2470 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2472 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2473 if { test -n "$symbolic" \
2474 || { test -n "$lsymbolic" \
2475 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2476 && test -z "$lookedup_tmp" \
2477 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2478 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2480 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2483 if test -n "$already_present"; then
2484 echo "Update file $g (backup in ${g}~)"
2486 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2492 # func_emit_lib_Makefile_am
2493 # emits the contents of library makefile to standard output.
2495 # - local_gnulib_dir from --local-dir
2496 # - modcache true or false, from --cache-modules/--no-cache-modules
2497 # - modules list of modules, including dependencies
2498 # - libname library name
2499 # - pobase directory relative to destdir where to place *.po files
2500 # - auxdir directory relative to destdir where to place build aux files
2501 # - makefile_name from --makefile-name
2502 # - libtool true if libtool will be used, false or blank otherwise
2503 # - macro_prefix prefix of gl_LIBOBJS macros to use
2504 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2505 # - actioncmd (optional) command that will reproduce this invocation
2506 # - for_test true if creating a package for testing, false otherwise
2507 # - destfile filename relative to destdir of makefile being generated
2509 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2510 # list of edits to be done to Makefile.am variables
2512 # - uses_subdirs nonempty if object files in subdirs exist
2513 func_emit_lib_Makefile_am ()
2515 # When creating an includable Makefile.am snippet, augment variables with
2516 # += instead of assigning them.
2517 if test -n "$makefile_name"; then
2522 if test "$libtool" = true; then
2525 sed_eliminate_LDFLAGS="$sed_noop"
2529 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2532 # When creating a package for testing: Attempt to provoke failures,
2533 # especially link errors, already during "make" rather than during
2534 # "make check", because "make check" is not possible in a cross-compiling
2535 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2536 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2538 sed_transform_check_PROGRAMS="$sed_noop"
2540 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2541 echo "## Process this file with automake to produce Makefile.in."
2542 func_emit_copyright_notice
2543 if test -n "$actioncmd"; then
2544 # The maximum line length (excluding the terminating newline) of any file
2545 # that is to be preprocessed by config.status is 3070. config.status uses
2546 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
2547 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
2548 len=`echo "$actioncmd" | wc -c`
2549 if test -n "$len" && test "$len" -le 3000; then
2550 echo "# Reproduce by: $actioncmd"
2556 for module in $modules; do
2557 func_verify_nontests_module
2558 if test -n "$module"; then
2560 func_get_automake_snippet "$module" |
2562 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2563 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2564 -e "$sed_eliminate_LDFLAGS" \
2565 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
2566 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2567 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2568 -e "$sed_transform_check_PROGRAMS"
2569 if test "$module" = 'alloca'; then
2570 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2571 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2573 } > "$tmp"/amsnippet
2574 # Skip the contents if it's entirely empty.
2575 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2576 echo "## begin gnulib module $module"
2578 cat "$tmp"/amsnippet
2579 echo "## end gnulib module $module"
2582 rm -f "$tmp"/amsnippet
2583 # Test whether there are some source files in subdirectories.
2584 for f in `func_get_filelist "$module"`; do
2594 } > "$tmp"/allsnippets
2595 if test -z "$makefile_name"; then
2596 # If there are source files in subdirectories, prevent collision of the
2597 # object files (example: hash.c and libxml/hash.c).
2599 if test -n "$uses_subdirs"; then
2600 subdir_options=' subdir-objects'
2602 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2605 if test -z "$makefile_name"; then
2607 echo "noinst_HEADERS ="
2608 echo "noinst_LIBRARIES ="
2609 echo "noinst_LTLIBRARIES ="
2610 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2611 # if you specify pkgdata_DATA to empty. This is a workaround.
2612 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2613 echo "pkgdata_DATA ="
2616 echo "BUILT_SOURCES ="
2619 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2620 if test -z "$makefile_name"; then
2621 echo "MOSTLYCLEANDIRS ="
2623 echo "DISTCLEANFILES ="
2624 echo "MAINTAINERCLEANFILES ="
2626 # Execute edits that apply to the Makefile.am being generated.
2628 while test $edit != $makefile_am_edits; do
2629 edit=`expr $edit + 1`
2630 eval dir=\"\$makefile_am_edit${edit}_dir\"
2631 eval var=\"\$makefile_am_edit${edit}_var\"
2632 eval val=\"\$makefile_am_edit${edit}_val\"
2633 if test -n "$var"; then
2634 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2635 echo "${var} += ${val}"
2636 eval "makefile_am_edit${edit}_var="
2640 if test -z "$makefile_name"; then
2642 echo "AM_CPPFLAGS ="
2646 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
2647 || { test -n "$makefile_name" \
2648 && test -f "$sourcebase/Makefile.am" \
2649 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2651 # One of the snippets or the user's Makefile.am already specifies an
2652 # installation location for the library. Don't confuse automake by saying
2653 # it should not be installed.
2656 # By default, the generated library should not be installed.
2657 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2660 echo "${libname}_${libext}_SOURCES ="
2661 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2662 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2663 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2664 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2665 echo "EXTRA_${libname}_${libext}_SOURCES ="
2666 if test "$libtool" = true; then
2667 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2670 if test -n "$pobase"; then
2671 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2674 cat "$tmp"/allsnippets \
2675 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2677 echo "mostlyclean-local: mostlyclean-generic"
2678 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2679 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2680 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2684 rm -f "$tmp"/allsnippets
2687 # func_emit_po_Makevars
2688 # emits the contents of po/ makefile parameterization to standard output.
2690 # - local_gnulib_dir from --local-dir
2691 # - modcache true or false, from --cache-modules/--no-cache-modules
2692 # - sourcebase directory relative to destdir where to place source code
2693 # - pobase directory relative to destdir where to place *.po files
2694 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2695 func_emit_po_Makevars ()
2697 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2698 func_emit_copyright_notice
2700 echo "# Usually the message domain is the same as the package name."
2701 echo "# But here it has a '-gnulib' suffix."
2702 echo "DOMAIN = ${po_domain}-gnulib"
2704 echo "# These two variables depend on the location of this directory."
2705 echo "subdir = ${pobase}"
2706 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2709 # These options get passed to xgettext.
2710 XGETTEXT_OPTIONS = \
2711 --keyword=_ --flag=_:1:pass-c-format \
2712 --keyword=N_ --flag=N_:1:pass-c-format \
2713 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2714 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2715 --flag=error:3:c-format --flag=error_at_line:5:c-format
2717 # This is the copyright holder that gets inserted into the header of the
2718 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2719 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2721 # This is the email address or URL to which the translators shall report
2722 # bugs in the untranslated strings:
2723 # - Strings which are not entire sentences, see the maintainer guidelines
2724 # in the GNU gettext documentation, section 'Preparing Strings'.
2725 # - Strings which use unclear terms or require additional context to be
2727 # - Strings which make invalid assumptions about notation of date, time or
2729 # - Pluralisation problems.
2730 # - Incorrect English spelling.
2731 # - Incorrect formatting.
2732 # It can be your email address, or a mailing list address where translators
2733 # can write to without being subscribed, or the URL of a web page through
2734 # which the translators can contact you.
2735 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2737 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2738 # message catalogs shall be used. It is usually empty.
2739 EXTRA_LOCALE_CATEGORIES =
2741 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2742 # context. Possible values are "yes" and "no". Set this to yes if the
2743 # package uses functions taking also a message context, like pgettext(), or
2744 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
2749 # func_emit_po_POTFILES_in
2750 # emits the file list to be passed to xgettext to standard output.
2752 # - local_gnulib_dir from --local-dir
2753 # - modcache true or false, from --cache-modules/--no-cache-modules
2754 # - sourcebase directory relative to destdir where to place source code
2755 # - files list of new files
2756 func_emit_po_POTFILES_in ()
2758 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2759 func_emit_copyright_notice
2761 echo "# List of files which contain translatable strings."
2762 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
2765 # func_emit_tests_Makefile_am witness_macro
2766 # emits the contents of tests makefile to standard output.
2768 # - local_gnulib_dir from --local-dir
2769 # - modcache true or false, from --cache-modules/--no-cache-modules
2770 # - modules list of modules, including dependencies
2771 # - libname library name
2772 # - auxdir directory relative to destdir where to place build aux files
2773 # - makefile_name from --makefile-name
2774 # - libtool true if libtool will be used, false or blank otherwise
2775 # - sourcebase relative directory containing lib source code
2776 # - m4base relative directory containing autoconf macros
2777 # - testsbase relative directory containing unit test code
2778 # - macro_prefix prefix of gl_LIBOBJS macros to use
2779 # - for_test true if creating a package for testing, false otherwise
2780 # - use_libtests true if a libtests.a should be built, false otherwise
2781 # - destfile filename relative to destdir of makefile being generated
2783 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2784 # list of edits to be done to Makefile.am variables
2786 # - uses_subdirs nonempty if object files in subdirs exist
2787 func_emit_tests_Makefile_am ()
2790 if test "$libtool" = true; then
2792 sed_eliminate_LDFLAGS="$sed_noop"
2795 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2798 # When creating a package for testing: Attempt to provoke failures,
2799 # especially link errors, already during "make" rather than during
2800 # "make check", because "make check" is not possible in a cross-compiling
2801 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2802 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2804 sed_transform_check_PROGRAMS="$sed_noop"
2806 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
2807 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2808 echo "## Process this file with automake to produce Makefile.in."
2809 func_emit_copyright_notice
2813 for module in $modules; do
2815 func_verify_tests_module
2819 if test -n "$module"; then
2821 func_get_automake_snippet "$module" |
2823 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2824 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2825 -e "$sed_eliminate_LDFLAGS" \
2826 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
2827 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2828 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2829 -e "$sed_transform_check_PROGRAMS"
2830 if $use_libtests && test "$module" = 'alloca'; then
2831 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
2832 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2834 } > "$tmp"/amsnippet
2835 # Skip the contents if it's entirely empty.
2836 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2837 echo "## begin gnulib module $module"
2839 cat "$tmp"/amsnippet
2840 echo "## end gnulib module $module"
2843 rm -f "$tmp"/amsnippet
2844 # Test whether there are some source files in subdirectories.
2845 for f in `func_get_filelist "$module"`; do
2847 lib/*/*.c | tests/*/*.c)
2855 } > "$tmp"/allsnippets
2856 # Generate dependencies here, since it eases the debugging of test failures.
2857 # If there are source files in subdirectories, prevent collision of the
2858 # object files (example: hash.c and libxml/hash.c).
2860 if test -n "$uses_subdirs"; then
2861 subdir_options=' subdir-objects'
2863 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
2866 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
2869 # Nothing is being added to SUBDIRS; nevertheless the existence of this
2870 # variable is needed to avoid an error from automake:
2871 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
2874 echo "XFAIL_TESTS ="
2875 echo "TESTS_ENVIRONMENT ="
2876 echo "noinst_PROGRAMS ="
2877 if ! $for_test; then
2878 echo "check_PROGRAMS ="
2880 echo "noinst_HEADERS ="
2881 echo "noinst_LIBRARIES ="
2882 if $use_libtests; then
2884 echo "noinst_LIBRARIES += libtests.a"
2886 echo "check_LIBRARIES = libtests.a"
2889 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2890 # if you specify pkgdata_DATA to empty. This is a workaround.
2891 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2892 echo "pkgdata_DATA ="
2895 echo "BUILT_SOURCES ="
2897 echo "MOSTLYCLEANFILES = core *.stackdump"
2898 echo "MOSTLYCLEANDIRS ="
2900 echo "DISTCLEANFILES ="
2901 echo "MAINTAINERCLEANFILES ="
2902 # Execute edits that apply to the Makefile.am being generated.
2904 while test $edit != $makefile_am_edits; do
2905 edit=`expr $edit + 1`
2906 eval dir=\"\$makefile_am_edit${edit}_dir\"
2907 eval var=\"\$makefile_am_edit${edit}_var\"
2908 eval val=\"\$makefile_am_edit${edit}_val\"
2909 if test -n "$var"; then
2910 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2911 echo "${var} += ${val}"
2912 eval "makefile_am_edit${edit}_var="
2917 echo "AM_CPPFLAGS = \\"
2918 if test -n "${witness_macro}"; then
2919 echo " -D@${witness_macro}@=1 \\"
2921 echo " -I. -I\$(srcdir) \\"
2922 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
2923 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
2925 local_ldadd_before=''
2926 local_ldadd_after=''
2927 if $use_libtests; then
2928 # All test programs need to be linked with libtests.a.
2929 # It needs to be passed to the linker before ${libname}.${libext}, since
2930 # the tests-related modules depend on the main modules.
2931 # It also needs to be passed to the linker after ${libname}.${libext}
2932 # because the latter might contain incomplete modules (such as the 'error'
2933 # module whose dependency to 'progname' is voluntarily omitted).
2934 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
2936 local_ldadd_before=' libtests.a'
2937 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
2939 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
2941 if $use_libtests; then
2942 echo "libtests_a_SOURCES ="
2943 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2944 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2945 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
2946 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
2947 echo "EXTRA_libtests_a_SOURCES ="
2948 # The circular dependency in LDADD requires this.
2949 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
2952 # Many test scripts use ${EXEEXT} or ${srcdir}.
2953 # EXEEXT is defined by AC_PROG_CC through autoconf.
2954 # srcdir is defined by autoconf and automake.
2955 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
2957 cat "$tmp"/allsnippets \
2958 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2959 echo "# Clean up after Solaris cc."
2961 echo " rm -rf SunWS_cache"
2963 echo "mostlyclean-local: mostlyclean-generic"
2964 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2965 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2966 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2970 rm -f "$tmp"/allsnippets
2973 # func_emit_initmacro_start macro_prefix
2974 # emits the first few statements of the gl_INIT macro to standard output.
2975 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2976 func_emit_initmacro_start ()
2978 macro_prefix_arg="$1"
2979 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
2980 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
2981 # LIBOBJS. The purpose is to allow several gnulib instantiations under
2982 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
2984 # Furthermore it avoids an automake error like this when a Makefile.am
2985 # that uses pieces of gnulib also uses $(LIBOBJ):
2986 # automatically discovered file `error.c' should not be explicitly mentioned
2987 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
2988 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
2989 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
2990 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
2991 # automatically discovered file `error.c' should not be explicitly mentioned
2992 # We let automake know about the files to be distributed through the
2993 # EXTRA_lib_SOURCES variable.
2994 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
2995 # Create data variables for checking the presence of files that are mentioned
2996 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
2997 # because we want the check to happen when the configure file is created,
2998 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
2999 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
3000 # in which to expect them.
3001 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3002 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3006 # func_emit_initmacro_end macro_prefix
3007 # emits the last few statements of the gl_INIT macro to standard output.
3008 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3009 func_emit_initmacro_end ()
3011 macro_prefix_arg="$1"
3012 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3013 # The check is performed only when autoconf is run from the directory where
3014 # the configure.ac resides; if it is run from a different directory, the
3016 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3017 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3018 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3019 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3020 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3024 echo " m4_if(m4_sysval, [0], [],"
3025 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3027 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3028 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3029 echo " m4_popdef([AC_LIBSOURCES])"
3030 echo " m4_popdef([AC_REPLACE_FUNCS])"
3031 echo " m4_popdef([AC_LIBOBJ])"
3032 echo " AC_CONFIG_COMMANDS_PRE(["
3033 echo " ${macro_prefix_arg}_libobjs="
3034 echo " ${macro_prefix_arg}_ltlibobjs="
3035 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3036 echo " # Remove the extension."
3037 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3038 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3039 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3040 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3043 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3044 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3048 # func_emit_initmacro_done macro_prefix sourcebase
3049 # emits a few statements after the gl_INIT macro to standard output.
3050 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3051 # - sourcebase directory relative to destdir where to place source code
3052 func_emit_initmacro_done ()
3054 macro_prefix_arg="$1"
3057 echo "# Like AC_LIBOBJ, except that the module name goes"
3058 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3059 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3060 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3061 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3064 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3065 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3066 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3067 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3068 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3071 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3072 echo "# expected is derived from the gnulib-tool parameterization,"
3073 echo "# and alloca is special cased (for the alloca-opt module)."
3074 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3075 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3076 echo " m4_foreach([_gl_NAME], [\$1], ["
3077 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3078 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3079 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3085 # func_import modules
3086 # Uses also the variables
3087 # - destdir target directory
3088 # - local_gnulib_dir from --local-dir
3089 # - modcache true or false, from --cache-modules/--no-cache-modules
3090 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3091 # - libname library name
3092 # - sourcebase directory relative to destdir where to place source code
3093 # - m4base directory relative to destdir where to place *.m4 macros
3094 # - pobase directory relative to destdir where to place *.po files
3095 # - docbase directory relative to destdir where to place doc files
3096 # - testsbase directory relative to destdir where to place unit test code
3097 # - auxdir directory relative to destdir where to place build aux files
3098 # - inctests true if --with-tests was given, blank otherwise
3099 # - incobsolete true if --with-obsolete was given, blank otherwise
3100 # - avoidlist list of modules to avoid, from --avoid
3101 # - lgpl yes or a number if library's license shall be LGPL,
3103 # - makefile_name from --makefile-name
3104 # - libtool true if --libtool was given, false if --no-libtool was
3105 # given, blank otherwise
3106 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
3107 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3108 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3109 # - vc_files true if --vc-files was given, false if --no-vc-files was
3110 # given, blank otherwise
3111 # - autoconf_minversion minimum supported autoconf version
3112 # - doit : if actions shall be executed, false if only to be printed
3113 # - symbolic true if files should be symlinked, copied otherwise
3114 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3116 # - do_copyrights true if copyright notices in files should be replaced,
3120 # Get the cached settings.
3121 cached_local_gnulib_dir=
3122 cached_specified_modules=
3133 cached_makefile_name=
3135 cached_macro_prefix=
3139 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3140 cached_libtool=false
3146 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
3156 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
3158 /gl_WITH_OBSOLETE/ {
3159 s,^.*$,cached_incobsolete=true,p
3162 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
3165 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
3168 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
3171 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
3174 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
3177 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
3180 s,^.*$,cached_inctests=true,p
3183 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
3186 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
3189 s,^.*$,cached_lgpl=yes,p
3191 /gl_MAKEFILE_NAME(/ {
3192 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
3195 s,^.*$,cached_libtool=true,p
3197 /gl_MACRO_PREFIX(/ {
3198 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
3201 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
3204 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
3206 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
3207 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3212 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
3213 s,^.*$,cached_files=",p
3226 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
3230 # Merge the cached settings with the specified ones.
3231 # The m4base must be the same as expected from the pathname.
3232 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
3233 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
3235 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
3236 # is relative to $destdir, whereas the one we use is relative to . or absolute.
3237 if test -z "$local_gnulib_dir"; then
3238 if test -n "$cached_local_gnulib_dir"; then
3241 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3243 case "$cached_local_gnulib_dir" in
3245 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3247 func_relconcat "$destdir" "$cached_local_gnulib_dir"
3248 local_gnulib_dir="$relconcat" ;;
3253 # Append the cached and the specified module names. So that
3254 # "gnulib-tool --import foo" means to add the module foo.
3255 specified_modules="$cached_specified_modules $1"
3256 # Included obsolete modules among the dependencies if specified either way.
3257 if test -z "$incobsolete"; then
3258 incobsolete="$cached_incobsolete"
3260 # Append the cached and the specified avoidlist. This is probably better
3261 # than dropping the cached one when --avoid is specified at least once.
3262 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
3263 avoidlist=`echo $avoidlist`
3265 # The sourcebase defaults to the cached one.
3266 if test -z "$sourcebase"; then
3267 sourcebase="$cached_sourcebase"
3268 if test -z "$sourcebase"; then
3269 func_fatal_error "missing --source-base option"
3272 # The pobase defaults to the cached one.
3273 if test -z "$pobase"; then
3274 pobase="$cached_pobase"
3276 # The docbase defaults to the cached one.
3277 if test -z "$docbase"; then
3278 docbase="$cached_docbase"
3279 if test -z "$docbase"; then
3280 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."
3283 # The testsbase defaults to the cached one.
3284 if test -z "$testsbase"; then
3285 testsbase="$cached_testsbase"
3286 if test -z "$testsbase"; then
3287 func_fatal_error "missing --tests-base option"
3290 # Require the tests if specified either way.
3291 if test -z "$inctests"; then
3292 inctests="$cached_inctests"
3294 # The libname defaults to the cached one.
3295 if test -z "$supplied_libname"; then
3296 libname="$cached_libname"
3297 if test -z "$libname"; then
3298 func_fatal_error "missing --lib option"
3301 # Require LGPL if specified either way.
3302 if test -z "$lgpl"; then
3305 # The makefile_name defaults to the cached one.
3306 if test -z "$makefile_name"; then
3307 makefile_name="$cached_makefile_name"
3309 # Use libtool if specified either way, or if guessed.
3310 if test -z "$libtool"; then
3311 if test -n "$cached_m4base"; then
3312 libtool="$cached_libtool"
3314 libtool="$guessed_libtool"
3317 # The macro_prefix defaults to the cached one.
3318 if test -z "$macro_prefix"; then
3319 macro_prefix="$cached_macro_prefix"
3320 if test -z "$macro_prefix"; then
3321 func_fatal_error "missing --macro-prefix option"
3324 # The po_domain defaults to the cached one.
3325 if test -z "$po_domain"; then
3326 po_domain="$cached_po_domain"
3328 # The vc_files defaults to the cached one.
3329 if test -z "$vc_files"; then
3330 vc_files="$cached_vc_files"
3333 # Canonicalize the list of specified modules.
3334 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
3336 # Determine final module list.
3337 modules="$specified_modules"
3338 func_modules_transitive_closure
3339 if test $verbose -ge 0; then
3340 echo "Module list with included dependencies:"
3341 echo "$modules" | sed -e 's/^/ /'
3343 final_modules="$modules"
3345 # Determine main module list and tests-related module list separately.
3346 # The main module list is the transitive closure of the specified modules,
3347 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3348 # is specified, it will consist only of LGPLed source.
3349 # The tests-related module list is the transitive closure of the specified
3350 # modules, including tests modules, minus the main module list excluding
3351 # modules of applicability 'all'. Its lib/* sources (brought in through
3352 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3353 # source, even if --lgpl is specified.
3354 # Determine main module list.
3355 saved_inctests="$inctests"
3357 modules="$specified_modules"
3358 func_modules_transitive_closure
3359 main_modules="$modules"
3360 inctests="$saved_inctests"
3361 if test $verbose -ge 1; then
3362 echo "Main module list:"
3363 echo "$main_modules" | sed -e 's/^/ /'
3365 # Determine tests-related module list.
3366 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3367 testsrelated_modules=`for module in $main_modules; do
3368 if test \`func_get_applicability $module\` = main; then
3372 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3373 if test $verbose -ge 1; then
3374 echo "Tests-related module list:"
3375 echo "$testsrelated_modules" | sed -e 's/^/ /'
3378 # Add the dummy module to the main module list if needed.
3379 modules="$main_modules"
3380 func_modules_add_dummy
3381 main_modules="$modules"
3383 # Determine whether a $testsbase/libtests.a is needed.
3385 for module in $testsrelated_modules; do
3386 func_verify_nontests_module
3387 if test -n "$module"; then
3388 all_files=`func_get_filelist $module`
3389 # Test whether some file in $all_files lies in lib/.
3390 for f in $all_files; do
3401 # Add the dummy module to the tests-related module list if needed.
3402 if $use_libtests; then
3403 modules="$testsrelated_modules"
3404 func_modules_add_dummy
3405 testsrelated_modules="$modules"
3408 # If --lgpl, verify that the licenses of modules are compatible.
3409 if test -n "$lgpl"; then
3410 license_incompatibilities=
3411 for module in $main_modules; do
3412 license=`func_get_license $module`
3414 'GPLed build tool') ;;
3415 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3420 LGPL | LGPLv2+ | LGPLv3+) ;;
3421 *) func_append license_incompatibilities "$module $license$nl" ;;
3427 *) func_append license_incompatibilities "$module $license$nl" ;;
3430 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3435 if test -n "$license_incompatibilities"; then
3436 # Format the license incompatibilities as a table.
3437 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
3438 s,^\(.................................................[^ ]*\) *, \1 ,'
3439 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
3440 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
3444 # Show banner notice of every module.
3445 modules="$main_modules"
3448 # Determine script to apply to imported library files.
3449 sed_transform_lib_file=
3450 for module in $main_modules; do
3451 if test $module = config-h; then
3452 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
3453 sed_transform_lib_file=$sed_transform_lib_file'
3454 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
3459 sed_transform_main_lib_file="$sed_transform_lib_file"
3460 if test -n "$do_copyrights"; then
3461 if test -n "$lgpl"; then
3465 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3466 s/GNU General/GNU Lesser General/g
3470 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3471 s/GNU General/GNU Lesser General/g
3472 s/version [23]\([ ,]\)/version 2.1\1/g
3475 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3479 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3480 s/GNU Lesser General/GNU General/g
3481 s/GNU Library General/GNU General/g
3482 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3487 # Determine script to apply to auxiliary files that go into $auxdir/.
3488 sed_transform_build_aux_file=
3489 if test -n "$do_copyrights"; then
3491 sed_transform_build_aux_file=$sed_transform_build_aux_file'
3492 s/GNU Lesser General/GNU General/g
3493 s/GNU Library General/GNU General/g
3494 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3498 # Determine script to apply to library files that go into $testsbase/.
3499 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
3500 if test -n "$do_copyrights"; then
3502 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
3503 s/GNU Lesser General/GNU General/g
3504 s/GNU Library General/GNU General/g
3505 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3509 # Determine the final file lists.
3510 # They must be computed separately, because files in lib/* go into
3511 # $sourcebase/ if they are in the main file list but into $testsbase/
3512 # if they are in the tests-related file list. Furthermore lib/dummy.c
3514 # Determine final main file list.
3515 modules="$main_modules"
3516 func_modules_to_filelist
3518 # Determine final tests-related file list.
3519 modules="$testsrelated_modules"
3520 func_modules_to_filelist
3521 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3522 # Merge both file lists.
3523 sed_remove_empty_lines='/^$/d'
3524 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3525 if test $verbose -ge 0; then
3527 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3528 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3532 || func_fatal_error "refusing to do nothing"
3534 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
3535 new_files="$files m4/gnulib-tool.m4"
3536 old_files="$cached_files"
3537 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
3538 func_append old_files " m4/gnulib-tool.m4"
3541 rewritten='%REWRITTEN%'
3542 sed_rewrite_old_files="\
3543 s,^build-aux/,$rewritten$auxdir/,
3544 s,^doc/,$rewritten$cached_docbase/,
3545 s,^lib/,$rewritten$cached_sourcebase/,
3546 s,^m4/,$rewritten$cached_m4base/,
3547 s,^tests/,$rewritten$cached_testsbase/,
3548 s,^tests=lib/,$rewritten$cached_testsbase/,
3551 sed_rewrite_new_files="\
3552 s,^build-aux/,$rewritten$auxdir/,
3553 s,^doc/,$rewritten$docbase/,
3554 s,^lib/,$rewritten$sourcebase/,
3555 s,^m4/,$rewritten$m4base/,
3556 s,^tests/,$rewritten$testsbase/,
3557 s,^tests=lib/,$rewritten$testsbase/,
3561 # Create directories.
3562 { echo "$sourcebase"
3564 if test -n "$pobase"; then
3567 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
3568 if test -n "$docfiles"; then
3571 if test -n "$inctests"; then
3575 for f in $files; do echo $f; done \
3576 | sed -e "$sed_rewrite_new_files" \
3577 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3580 { # Rearrange file descriptors. Needed because "while ... done < ..."
3581 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3582 exec 5<&0 < "$tmp"/dirs
3584 if test ! -d "$destdir/$d"; then
3586 echo "Creating directory $destdir/$d"
3587 mkdir -p "$destdir/$d" || func_fatal_error "failed"
3589 echo "Create directory $destdir/$d"
3596 # Copy files or make symbolic links. Remove obsolete files.
3600 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3601 # representing the files according to the last gnulib-tool invocation.
3602 for f in $old_files; do echo $f; done \
3603 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
3606 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3607 # representing the files after this gnulib-tool invocation.
3608 for f in $new_files; do echo $f; done \
3609 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
3612 # First the files that are in old-files, but not in new-files:
3613 sed_take_first_column='s,'"$delimiter"'.*,,'
3614 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
3615 # Remove the file. Do nothing if the user already removed it.
3616 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
3618 echo "Removing file $g (backup in ${g}~)"
3619 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3621 echo "Remove file $g (backup in ${g}~)"
3623 func_append removed_files "$g$nl"
3626 # func_add_or_update handles a file that ought to be present afterwards.
3628 # - f the original file name
3629 # - g the rewritten file name
3630 # - already_present nonempty if the file should already exist, empty
3632 func_add_or_update ()
3636 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
3638 func_dest_tmpfilename "$g"
3639 func_lookup_file "$f"
3640 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
3641 if test -n "$sed_transform_main_lib_file"; then
3644 sed -e "$sed_transform_main_lib_file" \
3645 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3649 if test -n "$sed_transform_build_aux_file"; then
3652 sed -e "$sed_transform_build_aux_file" \
3653 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3657 if test -n "$sed_transform_testsrelated_lib_file"; then
3660 sed -e "$sed_transform_testsrelated_lib_file" \
3661 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3665 if test -f "$destdir/$g"; then
3666 # The file already exists.
3670 # Don't protest if the file should be there but isn't: it happens
3671 # frequently that developers don't put autogenerated files into CVS.
3673 func_append added_files "$g$nl"
3677 # Then the files that are in new-files, but not in old-files:
3678 sed_take_last_column='s,^.*'"$delimiter"',,'
3680 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
3681 | sed -e "$sed_take_last_column" \
3682 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
3683 { # Rearrange file descriptors. Needed because "while ... done < ..."
3684 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3685 exec 5<&0 < "$tmp"/added-files
3691 # Then the files that are in new-files and in old-files:
3692 already_present=true
3693 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
3694 | sed -e "$sed_take_last_column" \
3695 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
3696 { # Rearrange file descriptors. Needed because "while ... done < ..."
3697 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3698 exec 5<&0 < "$tmp"/kept-files
3705 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
3706 actioncmd="gnulib-tool --import"
3707 func_append actioncmd " --dir=$destdir"
3708 if test -n "$local_gnulib_dir"; then
3709 func_append actioncmd " --local-dir=$local_gnulib_dir"
3711 func_append actioncmd " --lib=$libname"
3712 func_append actioncmd " --source-base=$sourcebase"
3713 func_append actioncmd " --m4-base=$m4base"
3714 if test -n "$pobase"; then
3715 func_append actioncmd " --po-base=$pobase"
3717 func_append actioncmd " --doc-base=$docbase"
3718 func_append actioncmd " --tests-base=$testsbase"
3719 func_append actioncmd " --aux-dir=$auxdir"
3720 if test -n "$inctests"; then
3721 func_append actioncmd " --with-tests"
3723 if test -n "$incobsolete"; then
3724 func_append actioncmd " --with-obsolete"
3726 for module in $avoidlist; do
3727 func_append actioncmd " --avoid=$module"
3729 if test -n "$lgpl"; then
3730 if test "$lgpl" = yes; then
3731 func_append actioncmd " --lgpl"
3733 func_append actioncmd " --lgpl=$lgpl"
3736 if test -n "$makefile_name"; then
3737 func_append actioncmd " --makefile-name=$makefile_name"
3739 if test "$libtool" = true; then
3740 func_append actioncmd " --libtool"
3742 func_append actioncmd " --no-libtool"
3744 func_append actioncmd " --macro-prefix=$macro_prefix"
3745 if test -n "$po_domain"; then
3746 func_append actioncmd " --po-domain=$po_domain"
3748 if test -n "$vc_files"; then
3749 if test "$vc_files" = true; then
3750 func_append actioncmd " --vc-files"
3752 func_append actioncmd " --no-vc-files"
3755 func_append actioncmd " `echo $specified_modules`"
3757 # Default the makefile name to Makefile.am.
3758 if test -n "$makefile_name"; then
3759 makefile_am=$makefile_name
3761 makefile_am=Makefile.am
3764 # Create normal Makefile.ams.
3767 # Setup list of Makefile.am edits that are to be performed afterwards.
3768 # Some of these edits apply to files that we will generate; others are
3769 # under the responsibility of the developer.
3771 # func_note_Makefile_am_edit dir var value
3772 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
3774 func_note_Makefile_am_edit ()
3776 makefile_am_edits=`expr $makefile_am_edits + 1`
3777 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
3778 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
3779 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
3781 if test "$makefile_am" = Makefile.am; then
3782 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3783 sourcebase_base=`basename "$sourcebase"`
3784 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
3786 if test -n "$pobase"; then
3787 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3788 pobase_base=`basename "$pobase"`
3789 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
3791 if test -n "$inctests"; then
3792 if test "$makefile_am" = Makefile.am; then
3793 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3794 testsbase_base=`basename "$testsbase"`
3795 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
3798 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
3800 # Find the first parent directory of $m4base that contains or will contain
3802 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
3804 sed_butlast='s,[^/][^/]*//*$,,'
3805 dir1="${m4base}/"; dir2=""
3806 while test -n "$dir1" \
3807 && ! { test -f "${destdir}/${dir1}Makefile.am" \
3808 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3809 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3810 || { test -n "$inctests" \
3811 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
3812 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
3813 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
3814 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
3816 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
3819 # Create library makefile.
3820 func_dest_tmpfilename $sourcebase/$makefile_am
3821 destfile="$sourcebase/$makefile_am"
3822 modules="$main_modules"
3823 func_emit_lib_Makefile_am > "$tmpfile"
3824 if test -f "$destdir"/$sourcebase/$makefile_am; then
3825 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
3829 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3830 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
3831 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3833 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3839 echo "Creating $sourcebase/$makefile_am"
3840 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3842 echo "Create $sourcebase/$makefile_am"
3845 func_append added_files "$sourcebase/$makefile_am$nl"
3848 # Create po/ directory.
3849 if test -n "$pobase"; then
3850 # Create po makefile and auxiliary files.
3851 for file in Makefile.in.in remove-potcdate.sin; do
3852 func_dest_tmpfilename $pobase/$file
3853 func_lookup_file build-aux/po/$file
3854 cat "$lookedup_file" > "$tmpfile"
3855 if test -f "$destdir"/$pobase/$file; then
3856 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
3860 echo "Updating $pobase/$file (backup in $pobase/$file~)"
3861 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
3862 mv -f "$tmpfile" "$destdir"/$pobase/$file
3864 echo "Update $pobase/$file (backup in $pobase/$file~)"
3870 echo "Creating $pobase/$file"
3871 mv -f "$tmpfile" "$destdir"/$pobase/$file
3873 echo "Create $pobase/$file"
3876 func_append added_files "$pobase/$file$nl"
3879 # Create po makefile parameterization, part 1.
3880 func_dest_tmpfilename $pobase/Makevars
3881 func_emit_po_Makevars > "$tmpfile"
3882 if test -f "$destdir"/$pobase/Makevars; then
3883 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
3887 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
3888 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
3889 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3891 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
3897 echo "Creating $pobase/Makevars"
3898 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3900 echo "Create $pobase/Makevars"
3903 func_append added_files "$pobase/Makevars$nl"
3905 # Create po makefile parameterization, part 2.
3906 func_dest_tmpfilename $pobase/POTFILES.in
3907 func_emit_po_POTFILES_in > "$tmpfile"
3908 if test -f "$destdir"/$pobase/POTFILES.in; then
3909 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
3913 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3914 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
3915 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3917 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3923 echo "Creating $pobase/POTFILES.in"
3924 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3926 echo "Create $pobase/POTFILES.in"
3929 func_append added_files "$pobase/POTFILES.in$nl"
3932 TP_URL="http://translationproject.org/latest/"
3933 TP_RSYNC_URI="translationproject.org::tp/latest/"
3935 echo "Fetching gnulib PO files from $TP_URL"
3936 (cd "$destdir"/$pobase \
3937 && { # Prefer rsync over wget if it is available, since it consumes
3938 # less network bandwidth, due to compression.
3939 if type rsync 2>/dev/null | grep / > /dev/null; then
3940 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
3942 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
3947 echo "Fetch gnulib PO files from $TP_URL"
3949 # Create po/LINGUAS.
3951 func_dest_tmpfilename $pobase/LINGUAS
3952 (cd "$destdir"/$pobase \
3953 && { echo '# Set of available languages.'
3954 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
3957 if test -f "$destdir"/$pobase/LINGUAS; then
3958 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
3961 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3962 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
3963 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3966 echo "Creating $pobase/LINGUAS"
3967 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3968 func_append added_files "$pobase/LINGUAS$nl"
3971 if test -f "$destdir"/$pobase/LINGUAS; then
3972 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3974 echo "Create $pobase/LINGUAS"
3979 # Create m4/gnulib-cache.m4.
3980 func_dest_tmpfilename $m4base/gnulib-cache.m4
3982 func_emit_copyright_notice
3984 echo "# This file represents the specification of how gnulib-tool is used."
3985 echo "# It acts as a cache: It is written and read by gnulib-tool."
3986 echo "# In projects using CVS, this file is meant to be stored in CVS,"
3987 echo "# like the configure.ac and various Makefile.am files."
3990 echo "# Specification in the form of a command-line invocation:"
3993 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
3994 # Store the local_gnulib_dir relative to destdir.
3995 case "$local_gnulib_dir" in
3997 relative_local_gnulib_dir="$local_gnulib_dir" ;;
4000 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
4002 # destdir, local_gnulib_dir are both relative.
4003 func_relativize "$destdir" "$local_gnulib_dir"
4004 relative_local_gnulib_dir="$reldir" ;;
4007 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
4009 echo "$specified_modules" | sed -e 's/^/ /g'
4011 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
4012 echo "gl_AVOID([$avoidlist])"
4013 echo "gl_SOURCE_BASE([$sourcebase])"
4014 echo "gl_M4_BASE([$m4base])"
4015 echo "gl_PO_BASE([$pobase])"
4016 echo "gl_DOC_BASE([$docbase])"
4017 echo "gl_TESTS_BASE([$testsbase])"
4018 test -z "$inctests" || echo "gl_WITH_TESTS"
4019 echo "gl_LIB([$libname])"
4020 if test -n "$lgpl"; then
4021 if test "$lgpl" = yes; then
4024 echo "gl_LGPL([$lgpl])"
4027 echo "gl_MAKEFILE_NAME([$makefile_name])"
4028 if test "$libtool" = true; then
4031 echo "gl_MACRO_PREFIX([$macro_prefix])"
4032 echo "gl_PO_DOMAIN([$po_domain])"
4033 if test -n "$vc_files"; then
4034 echo "gl_VC_FILES([$vc_files])"
4037 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4038 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
4042 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4043 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
4044 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4046 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4050 echo "# gnulib-cache.m4 ends here"
4057 echo "Creating $m4base/gnulib-cache.m4"
4058 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4060 echo "Create $m4base/gnulib-cache.m4"
4066 # Create m4/gnulib-comp.m4.
4067 func_dest_tmpfilename $m4base/gnulib-comp.m4
4069 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
4070 func_emit_copyright_notice
4072 echo "# This file represents the compiled summary of the specification in"
4073 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
4074 echo "# to be invoked from configure.ac."
4075 echo "# In projects using CVS, this file can be treated like other built files."
4078 echo "# This macro should be invoked from $configure_ac, in the section"
4079 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
4080 echo "# any checks for libraries, header files, types and library functions."
4081 echo "AC_DEFUN([${macro_prefix}_EARLY],"
4083 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4084 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4085 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4086 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4087 echo " AC_REQUIRE([AC_PROG_RANLIB])"
4088 if test -n "$uses_subdirs"; then
4089 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
4091 for module in $final_modules; do
4093 if test -n "$module"; then
4094 echo "# Code from module $module:"
4095 func_get_autoconf_early_snippet "$module"
4098 | sed -e '/^$/d;' -e 's/^/ /'
4101 echo "# This macro should be invoked from $configure_ac, in the section"
4102 echo "# \"Check for header files, types and library functions\"."
4103 echo "AC_DEFUN([${macro_prefix}_INIT],"
4105 if test "$libtool" = true; then
4106 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4107 echo " gl_cond_libtool=true"
4109 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4110 echo " gl_cond_libtool=false"
4112 echo " gl_ltlibdeps="
4114 if test "$auxdir" != "build-aux"; then
4115 sed_replace_build_aux='
4117 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4118 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4122 sed_replace_build_aux="$sed_noop"
4124 func_emit_initmacro_start $macro_prefix
4125 echo " gl_source_base='$sourcebase'"
4126 for module in $main_modules; do
4128 if test -n "$module"; then
4129 echo " # Code from module $module:"
4130 func_get_autoconf_snippet "$module" \
4131 | sed -e '/^$/d;' -e 's/^/ /' \
4132 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4133 -e "$sed_replace_build_aux"
4134 if test "$module" = 'alloca' && test "$libtool" = true; then
4135 echo 'changequote(,)dnl'
4136 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4137 echo 'changequote([, ])dnl'
4138 echo 'AC_SUBST([LTALLOCA])'
4142 echo " # End of code from modules"
4143 func_emit_initmacro_end $macro_prefix
4144 echo " gltests_libdeps="
4145 echo " gltests_ltlibdeps="
4146 func_emit_initmacro_start ${macro_prefix}tests
4147 echo " gl_source_base='$testsbase'"
4148 # Define a tests witness macro that depends on the package.
4149 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
4150 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
4151 echo " ${macro_prefix}tests_WITNESS=IN_\`echo \"\${PACKAGE-\$PACKAGE_TARNAME}\" | LC_ALL=C tr 'a-z' 'A-Z' | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'\`_GNULIB_TESTS"
4152 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
4153 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
4154 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
4155 for module in $testsrelated_modules; do
4157 if test -n "$module"; then
4158 func_get_autoconf_snippet "$module" \
4159 | sed -e '/^$/d;' -e 's/^/ /' \
4160 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4161 -e "$sed_replace_build_aux" \
4162 -e 's/\$gl_cond_libtool/false/g' \
4163 -e 's/gl_libdeps/gltests_libdeps/g' \
4164 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4167 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
4168 func_emit_initmacro_end ${macro_prefix}tests
4169 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4170 # created using libtool, because libtool already handles the dependencies.
4171 if test "$libtool" != true; then
4172 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4173 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4174 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4175 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4176 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4178 if $use_libtests; then
4179 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
4180 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
4183 func_emit_initmacro_done $macro_prefix $sourcebase
4184 func_emit_initmacro_done ${macro_prefix}tests $testsbase
4186 echo "# This macro records the list of files which have been installed by"
4187 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
4188 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
4189 echo "$files" | sed -e 's,^, ,'
4192 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4193 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
4197 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4198 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
4199 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4201 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4205 echo "# gnulib-comp.m4 ends here"
4212 echo "Creating $m4base/gnulib-comp.m4"
4213 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4215 echo "Create $m4base/gnulib-comp.m4"
4221 if test -n "$inctests"; then
4222 # Create tests makefile.
4223 func_dest_tmpfilename $testsbase/$makefile_am
4224 destfile="$testsbase/$makefile_am"
4225 modules="$testsrelated_modules"
4226 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
4227 if test -f "$destdir"/$testsbase/$makefile_am; then
4228 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
4232 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4233 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
4234 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4236 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4242 echo "Creating $testsbase/$makefile_am"
4243 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4245 echo "Create $testsbase/$makefile_am"
4248 func_append added_files "$testsbase/$makefile_am$nl"
4252 if test "$vc_files" != false; then
4253 # Update the .cvsignore and .gitignore files.
4254 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
4255 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
4256 # Treat gnulib-comp.m4 like an added file, even if it already existed.
4257 echo "$m4base/|A|gnulib-comp.m4"
4258 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
4259 { # Rearrange file descriptors. Needed because "while ... done < ..."
4260 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4261 exec 5<&0 < "$tmp"/fileset-changes
4262 func_update_ignorelist ()
4265 if test "$ignore" = .gitignore; then
4266 # In a .gitignore file, "foo" applies to the current directory and all
4267 # subdirectories, whereas "/foo" applies to the current directory only.
4270 doubly_escaped_anchor='\\/'
4274 doubly_escaped_anchor=''
4276 if test -f "$destdir/$dir$ignore"; then
4277 if test -n "$dir_added" || test -n "$dir_removed"; then
4278 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
4279 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
4280 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
4281 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
4282 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
4284 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
4286 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4287 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
4288 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
4289 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
4290 } > "$tmp"/sed-ignore-removed
4291 { cat "$destdir/$dir$ignore"~
4292 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
4293 } | sed -f "$tmp"/sed-ignore-removed \
4294 > "$destdir/$dir$ignore"
4296 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4301 if test -n "$dir_added"; then
4303 echo "Creating $destdir/$dir$ignore"
4305 if test "$ignore" = .cvsignore; then
4307 # Automake generates Makefile rules that create .dirstamp files.
4310 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
4311 } > "$destdir/$dir$ignore"
4313 echo "Create $destdir/$dir$ignore"
4323 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
4324 func_update_ignorelist .cvsignore
4326 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
4327 func_update_ignorelist .gitignore
4334 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
4335 next_dir=`echo "$line" | sed -e 's,|.*,,'`
4336 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
4337 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
4338 if test "$next_dir" != "$last_dir"; then
4339 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4340 last_dir="$next_dir"
4345 A) func_append last_dir_added "$file$nl";;
4346 R) func_append last_dir_removed "$file$nl";;
4349 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4356 echo "You may need to add #include directives for the following .h files."
4357 # Intersect $specified_modules and $main_modules
4358 # (since $specified_modules is not necessarily of subset of $main_modules
4359 # - some may have been skipped through --avoid, and since the elements of
4360 # $main_modules but not in $specified_modules can go away without explicit
4361 # notice - through changes in the module dependencies).
4362 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
4363 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
4364 # First the #include <...> directives without #ifs, sorted for convenience,
4365 # then the #include "..." directives without #ifs, sorted for convenience,
4366 # then the #include directives that are surrounded by #ifs. Not sorted.
4367 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
4368 include_directive=`func_get_include_directive "$module"`
4369 case "$nl$include_directive" in
4371 echo "$include_directive" 1>&5
4374 echo "$include_directive" | grep -v 'include "' 1>&6
4375 echo "$include_directive" | grep 'include "' 1>&7
4378 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
4380 LC_ALL=C sort -u "$tmp"/include-angles
4381 LC_ALL=C sort -u "$tmp"/include-quotes
4382 cat "$tmp"/include-if
4383 ) | sed -e '/^$/d' -e 's/^/ /'
4384 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
4386 for module in $main_modules; do
4387 func_get_link_directive "$module"
4389 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
4390 if test `wc -l < "$tmp"/link` != 0; then
4392 echo "You may need to use the following Makefile variables when linking."
4393 echo "Use them in <program>_LDADD when linking a program, or"
4394 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
4400 echo "Don't forget to"
4401 if test "$makefile_am" = Makefile.am; then
4402 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4404 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
4406 if test -n "$pobase"; then
4407 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
4409 if test -n "$inctests"; then
4410 if test "$makefile_am" = Makefile.am; then
4411 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4413 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
4417 while test $edit != $makefile_am_edits; do
4418 edit=`expr $edit + 1`
4419 eval dir=\"\$makefile_am_edit${edit}_dir\"
4420 eval var=\"\$makefile_am_edit${edit}_var\"
4421 eval val=\"\$makefile_am_edit${edit}_val\"
4422 if test -n "$var"; then
4423 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
4426 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
4427 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
4430 # func_create_testdir testdir modules
4432 # - local_gnulib_dir from --local-dir
4433 # - modcache true or false, from --cache-modules/--no-cache-modules
4434 # - auxdir directory relative to destdir where to place build aux files
4435 # - inctests true if tests should be included, blank otherwise
4436 # - incobsolete true if obsolete modules among dependencies should be
4437 # included, blank otherwise
4438 # - avoidlist list of modules to avoid
4439 # - libtool true if --libtool was given, false if --no-libtool was
4440 # given, blank otherwise
4441 # - symbolic true if files should be symlinked, copied otherwise
4442 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4444 func_create_testdir ()
4448 if test -z "$modules"; then
4449 # All modules together.
4450 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4451 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
4452 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
4453 modules=`func_all_modules`
4454 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
4456 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
4458 # Check that the license of every module is consistent with the license of
4460 saved_modules="$modules"
4461 saved_inctests="$inctests"
4462 # When computing transitive closures, don't consider $module to depend on
4463 # $module-tests. Need this becauses tests are implicitly GPL and may depend
4464 # on GPL modules - therefore we don't want a warning in this case.
4466 for requested_module in $saved_modules; do
4467 requested_license=`func_get_license "$requested_module"`
4468 if test "$requested_license" != GPL; then
4469 # Here we use func_modules_transitive_closure, not just
4470 # func_get_dependencies, so that we also detect weird situations like
4471 # an LGPL module which depends on a GPLed build tool module which depends
4473 modules="$requested_module"
4474 func_modules_transitive_closure
4475 for module in $modules; do
4476 license=`func_get_license "$module"`
4478 'GPLed build tool') ;;
4479 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4481 case "$requested_license" in
4484 GPLv2+ | LGPLv2+) ;;
4485 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4491 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4497 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4506 modules="$saved_modules"
4507 inctests="$saved_inctests"
4509 # Subdirectory names.
4519 # Determine final module list.
4520 func_modules_transitive_closure
4521 if test $verbose -ge 0; then
4522 echo "Module list with included dependencies:"
4523 echo "$modules" | sed -e 's/^/ /'
4526 # Add the dummy module if needed.
4527 func_modules_add_dummy
4529 # Show banner notice of every module.
4532 # Determine final file list.
4533 func_modules_to_filelist
4534 if test $verbose -ge 0; then
4536 echo "$files" | sed -e 's/^/ /'
4539 rewritten='%REWRITTEN%'
4540 sed_rewrite_files="\
4541 s,^build-aux/,$rewritten$auxdir/,
4542 s,^doc/,$rewritten$docbase/,
4543 s,^lib/,$rewritten$sourcebase/,
4544 s,^m4/,$rewritten$m4base/,
4545 s,^tests/,$rewritten$testsbase/,
4549 # Create directories.
4550 for f in $files; do echo $f; done \
4551 | sed -e "$sed_rewrite_files" \
4552 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4553 | LC_ALL=C sort -u \
4555 { # Rearrange file descriptors. Needed because "while ... done < ..."
4556 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4557 exec 5<&0 < "$tmp"/dirs
4559 mkdir -p "$testdir/$d"
4564 # Copy files or make symbolic links.
4566 for f in $files; do echo $f; done \
4567 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
4570 { # Rearrange file descriptors. Needed because "while ... done < ..."
4571 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4572 exec 5<&0 < "$tmp"/files
4574 func_lookup_file "$f"
4575 if test -n "$lookedup_tmp"; then
4576 cp -p "$lookedup_file" "$testdir/$g"
4578 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
4579 if { test -n "$symbolic" \
4580 || { test -n "$lsymbolic" \
4581 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
4582 func_ln "$lookedup_file" "$testdir/$g"
4584 cp -p "$lookedup_file" "$testdir/$g"
4591 # Create Makefile.ams that are for testing.
4594 # No special edits are needed.
4597 # Create $sourcebase/Makefile.am.
4598 mkdir -p "$testdir/$sourcebase"
4599 destfile="$sourcebase/Makefile.am"
4600 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
4601 any_uses_subdirs="$uses_subdirs"
4603 # Create $m4base/Makefile.am.
4604 mkdir -p "$testdir/$m4base"
4605 (echo "## Process this file with automake to produce Makefile.in."
4611 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
4614 ) > "$testdir/$m4base/Makefile.am"
4616 subdirs="$sourcebase $m4base"
4617 subdirs_with_configure_ac=""
4619 if false && test -f "$testdir"/$m4base/gettext.m4; then
4620 # Avoid stupid error message from automake:
4621 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
4622 mkdir -p "$testdir/po"
4623 (echo "## Process this file with automake to produce Makefile.in."
4624 ) > "$testdir/po/Makefile.am"
4625 func_append subdirs " po"
4628 if test -n "$inctests"; then
4629 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
4630 # Viewed from the $testsbase subdirectory, $auxdir is different.
4631 saved_auxdir="$auxdir"
4632 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
4633 # Create $testsbase/Makefile.am.
4635 destfile="$testsbase/Makefile.am"
4636 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
4637 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
4638 # Create $testsbase/configure.ac.
4639 (echo "# Process this file with autoconf to produce a configure script."
4640 echo "AC_INIT([dummy], [0])"
4641 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4642 echo "AM_INIT_AUTOMAKE"
4644 echo "AC_CONFIG_HEADERS([config.h])"
4647 echo "AC_PROG_INSTALL"
4648 echo "AC_PROG_MAKE_SET"
4649 echo "AC_PROG_RANLIB"
4651 if test -n "$uses_subdirs"; then
4652 echo "AM_PROG_CC_C_O"
4655 for module in $modules; do
4657 if test -n "$module"; then
4659 gnumakefile | maintainer-makefile)
4660 # These modules are meant to be used only in the top-level directory.
4663 func_get_autoconf_early_snippet "$module"
4668 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4669 if test "$libtool" = true; then
4670 echo "LT_INIT([win32-dll])"
4671 echo "LT_LANG([C++])"
4672 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4673 echo "gl_cond_libtool=true"
4675 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4676 echo "gl_cond_libtool=false"
4678 echo "gl_ltlibdeps="
4680 # Wrap the set of autoconf snippets into an autoconf macro that is then
4681 # invoked. This is needed because autoconf does not support AC_REQUIRE
4683 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4684 # but we want the AC_REQUIRE to have its normal meaning (provide one
4685 # expansion of the required macro before the current point, and only one
4687 echo "AC_DEFUN([gl_INIT], ["
4688 sed_replace_build_aux='
4690 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4691 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4694 func_emit_initmacro_start $macro_prefix
4695 # We don't have explicit ordering constraints between the various
4696 # autoconf snippets. It's cleanest to put those of the library before
4697 # those of the tests.
4698 echo "gl_source_base='../$sourcebase'"
4699 for module in $modules; do
4700 func_verify_nontests_module
4701 if test -n "$module"; then
4703 gnumakefile | maintainer-makefile)
4704 # These modules are meant to be used only in the top-level directory.
4707 func_get_autoconf_snippet "$module" \
4708 | sed -e "$sed_replace_build_aux"
4713 echo "gl_source_base='.'"
4714 for module in $modules; do
4715 func_verify_tests_module
4716 if test -n "$module"; then
4717 func_get_autoconf_snippet "$module" \
4718 | sed -e "$sed_replace_build_aux"
4721 func_emit_initmacro_end $macro_prefix
4722 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4723 # created using libtool, because libtool already handles the dependencies.
4724 if test "$libtool" != true; then
4725 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4726 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4727 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4728 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4729 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4732 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
4736 # Usually $testsbase/config.h will be a superset of config.h. Verify this
4737 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
4738 echo "AH_TOP([#include \"../config.h\"])"
4740 echo "AC_CONFIG_FILES([Makefile])"
4742 ) > "$testdir/$testsbase/configure.ac"
4743 auxdir="$saved_auxdir"
4744 func_append subdirs " $testsbase"
4745 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
4748 # Create Makefile.am.
4749 (echo "## Process this file with automake to produce Makefile.in."
4751 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4753 echo "SUBDIRS = $subdirs"
4755 echo "ACLOCAL_AMFLAGS = -I $m4base"
4756 ) > "$testdir/Makefile.am"
4758 # Create configure.ac.
4759 (echo "# Process this file with autoconf to produce a configure script."
4760 echo "AC_INIT([dummy], [0])"
4761 if test "$auxdir" != "."; then
4762 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4764 echo "AM_INIT_AUTOMAKE"
4766 echo "AC_CONFIG_HEADERS([config.h])"
4769 echo "AC_PROG_INSTALL"
4770 echo "AC_PROG_MAKE_SET"
4772 echo "# For autobuild."
4773 echo "AC_CANONICAL_BUILD"
4774 echo "AC_CANONICAL_HOST"
4776 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4777 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4778 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4779 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4781 echo "AC_PROG_RANLIB"
4783 if test -n "$any_uses_subdirs"; then
4784 echo "AM_PROG_CC_C_O"
4787 for module in $modules; do
4788 func_verify_nontests_module
4789 if test -n "$module"; then
4790 func_get_autoconf_early_snippet "$module"
4793 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4794 if test "$libtool" = true; then
4795 echo "LT_INIT([win32-dll])"
4796 echo "LT_LANG([C++])"
4797 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4798 echo "gl_cond_libtool=true"
4800 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4801 echo "gl_cond_libtool=false"
4803 echo "gl_ltlibdeps="
4805 # Wrap the set of autoconf snippets into an autoconf macro that is then
4806 # invoked. This is needed because autoconf does not support AC_REQUIRE
4808 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4809 # but we want the AC_REQUIRE to have its normal meaning (provide one
4810 # expansion of the required macro before the current point, and only one
4812 echo "AC_DEFUN([gl_INIT], ["
4813 if test "$auxdir" != "build-aux"; then
4814 sed_replace_build_aux='
4816 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4817 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4821 sed_replace_build_aux="$sed_noop"
4823 func_emit_initmacro_start $macro_prefix
4824 echo "gl_source_base='$sourcebase'"
4825 for module in $modules; do
4826 func_verify_nontests_module
4827 if test -n "$module"; then
4828 func_get_autoconf_snippet "$module" \
4829 | sed -e "$sed_replace_build_aux"
4832 func_emit_initmacro_end $macro_prefix
4833 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4834 # created using libtool, because libtool already handles the dependencies.
4835 if test "$libtool" != true; then
4836 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4837 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4838 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4839 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4840 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4843 func_emit_initmacro_done $macro_prefix $sourcebase
4847 if test -n "$subdirs_with_configure_ac"; then
4848 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
4850 makefiles="Makefile"
4851 for d in $subdirs; do
4852 # For subdirs that have a configure.ac by their own, it's the subdir's
4853 # configure.ac which creates the subdir's Makefile.am, not this one.
4854 case " $subdirs_with_configure_ac " in
4856 *) func_append makefiles " $d/Makefile" ;;
4859 echo "AC_CONFIG_FILES([$makefiles])"
4861 ) > "$testdir/configure.ac"
4863 # Create autogenerated files.
4865 # Do not use "${AUTORECONF} --force --install", because it may invoke
4866 # autopoint, which brings in older versions of some of our .m4 files.
4867 if test -f $m4base/gettext.m4; then
4868 func_execute_command ${AUTOPOINT} --force || func_exit 1
4869 for f in $m4base/*.m4~; do
4871 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4875 if test "$libtool" = true; then
4876 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
4878 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
4879 if ! test -d build-aux; then
4880 func_execute_command mkdir build-aux || func_exit 1
4882 func_execute_command ${AUTOCONF} || func_exit 1
4883 func_execute_command ${AUTOHEADER} || func_exit 1
4884 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4886 if test -n "$inctests"; then
4887 # Create autogenerated files.
4888 (cd "$testdir/$testsbase" || func_exit 1
4889 # Do not use "${AUTORECONF} --force --install", because it may invoke
4890 # autopoint, which brings in older versions of some of our .m4 files.
4891 if test -f ../$m4base/gettext.m4; then
4892 func_execute_command ${AUTOPOINT} --force || func_exit 1
4893 for f in ../$m4base/*.m4~; do
4895 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4899 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
4900 if ! test -d ../build-aux; then
4901 func_execute_command mkdir ../build-aux
4903 func_execute_command ${AUTOCONF} || func_exit 1
4904 func_execute_command ${AUTOHEADER} || func_exit 1
4905 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4908 # Need to run configure and make once, to create built files that are to be
4909 # distributed (such as getdate.c).
4910 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
4911 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4912 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
4913 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
4914 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
4915 # such $(FOO_H) because they don't refer to distributed files.
4916 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
4917 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4918 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
4919 | sed -e "$sed_remove_make_variables"`
4920 distributed_built_sources=`for file in $built_sources; do
4921 case "$cleaned_files" in
4926 if test -n "$distributed_built_sources"; then
4928 ./configure || func_exit 1
4930 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
4931 $MAKE built_sources || func_exit 1
4933 $MAKE distclean || func_exit 1
4938 # func_create_megatestdir megatestdir allmodules
4940 # - local_gnulib_dir from --local-dir
4941 # - modcache true or false, from --cache-modules/--no-cache-modules
4942 # - auxdir directory relative to destdir where to place build aux files
4943 func_create_megatestdir ()
4947 if test -z "$allmodules"; then
4948 allmodules=`func_all_modules`
4952 # First, all modules one by one.
4953 for onemodule in $allmodules; do
4954 func_create_testdir "$megatestdir/$onemodule" $onemodule
4955 func_append megasubdirs "$onemodule "
4957 # Then, all modules all together.
4958 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4959 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
4960 func_create_testdir "$megatestdir/ALL" "$allmodules"
4961 func_append megasubdirs "ALL"
4964 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
4965 vc_witness="$gnulib_dir/CVS/Entries"; \
4967 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
4969 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
4970 | sed -e 's,January,01,' -e 's,Jan,01,' \
4971 -e 's,February,02,' -e 's,Feb,02,' \
4972 -e 's,March,03,' -e 's,Mar,03,' \
4973 -e 's,April,04,' -e 's,Apr,04,' \
4975 -e 's,June,06,' -e 's,Jun,06,' \
4976 -e 's,July,07,' -e 's,Jul,07,' \
4977 -e 's,August,08,' -e 's,Aug,08,' \
4978 -e 's,September,09,' -e 's,Sep,09,' \
4979 -e 's,October,10,' -e 's,Oct,10,' \
4980 -e 's,November,11,' -e 's,Nov,11,' \
4981 -e 's,December,12,' -e 's,Dec,12,' \
4982 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
4983 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
4985 echo "CVSDATE=$cvsdate"
4986 echo ": \${MAKE=make}"
4987 echo "test -d logs || mkdir logs"
4988 echo "for module in $megasubdirs; do"
4989 echo " echo \"Working on module \$module...\""
4990 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
4991 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
4994 echo " : autobuild project... \$module"
4995 echo " : autobuild revision... cvs-\$CVSDATE-000000"
4996 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
4997 echo " : autobuild hostname... \`hostname\`"
4998 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
5000 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
5002 ) > "$megatestdir/do-autobuild"
5003 chmod a+x "$megatestdir/do-autobuild"
5005 # Create Makefile.am.
5006 (echo "## Process this file with automake to produce Makefile.in."
5008 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5010 echo "SUBDIRS = $megasubdirs"
5012 echo "EXTRA_DIST = do-autobuild"
5013 ) > "$megatestdir/Makefile.am"
5015 # Create configure.ac.
5016 (echo "# Process this file with autoconf to produce a configure script."
5017 echo "AC_INIT([dummy], [0])"
5018 if test "$auxdir" != "."; then
5019 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5021 echo "AM_INIT_AUTOMAKE"
5023 echo "AC_PROG_MAKE_SET"
5025 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
5026 echo "AC_CONFIG_FILES([Makefile])"
5028 ) > "$megatestdir/configure.ac"
5030 # Create autogenerated files.
5032 # Do not use "${AUTORECONF} --install", because autoreconf operates
5033 # recursively, but the subdirectories are already finished, therefore
5034 # calling autoreconf here would only waste lots of CPU time.
5035 func_execute_command ${ACLOCAL} || func_exit 1
5036 func_execute_command mkdir build-aux
5037 func_execute_command ${AUTOCONF} || func_exit 1
5038 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5044 func_fatal_error "no mode specified" ;;
5051 # sed expression that converts a literal to a basic regular expression.
5052 # Needs to handle . [ \ * ^ $.
5053 sed_literal_to_basic_regex='s/\\/\\\\/g
5059 if test -f "$gnulib_dir/$filename" \
5060 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
5061 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
5062 filename_line_regex='^'"$filename_anywhere_regex"'$'
5065 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
5066 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
5067 (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$,,')
5070 | func_sanitize_modulelist \
5073 for module in $module_candidates; do
5074 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
5079 func_warning "file $filename does not exist"
5087 if test -z "$destdir"; then
5090 test -d "$destdir" \
5091 || func_fatal_error "destination directory does not exist: $destdir"
5093 # Prefer configure.ac to configure.in.
5094 if test -f "$destdir"/configure.ac; then
5095 configure_ac="$destdir/configure.ac"
5097 if test -f "$destdir"/configure.in; then
5098 configure_ac="$destdir/configure.in"
5100 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
5104 # Analyze configure.ac.
5106 guessed_libtool=false
5111 /AC_CONFIG_AUX_DIR/ {
5112 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
5114 /A[CM]_PROG_LIBTOOL/ {
5115 s,^.*$,guessed_libtool=true,p
5117 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
5119 if test -z "$auxdir"; then
5120 auxdir="$guessed_auxdir"
5123 # Determine where to apply func_import.
5124 if test -n "$m4base"; then
5125 # Apply func_import to a particular gnulib directory.
5126 # Any number of additional modules can be given.
5127 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
5128 # First use of gnulib in the given m4base.
5129 test -n "$supplied_libname" || supplied_libname=true
5130 test -n "$sourcebase" || sourcebase="lib"
5131 test -n "$docbase" || docbase="doc"
5132 test -n "$testsbase" || testsbase="tests"
5133 test -n "$macro_prefix" || macro_prefix="gl"
5137 # Apply func_import to all gnulib directories.
5138 # To get this list of directories, look at Makefile.am. (Not at
5139 # configure, because it may be omitted from CVS. Also, don't run
5140 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
5143 if test -f "$destdir"/Makefile.am; then
5144 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
5146 for arg in $aclocal_amflags; do
5147 if test -n "$m4dir_is_next"; then
5148 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
5152 if test -f "$destdir/$arg"/gnulib-cache.m4; then
5153 func_append m4dirs " $arg"
5154 m4dirs_count=`expr $m4dirs_count + 1`
5160 if test "X$arg" = "X-I"; then
5168 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
5169 if test -f "$destdir"/aclocal.m4; then
5170 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
5171 sedexpr2='s,^[^/]*$,.,'
5172 sedexpr3='s,/[^/]*$,,'
5173 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
5174 m4dirs_count=`printf %s "$m4dirs" | wc -l`
5177 if test $m4dirs_count = 0; then
5178 # First use of gnulib in a package.
5179 # Any number of additional modules can be given.
5180 test -n "$supplied_libname" || supplied_libname=true
5181 test -n "$sourcebase" || sourcebase="lib"
5183 test -n "$docbase" || docbase="doc"
5184 test -n "$testsbase" || testsbase="tests"
5185 test -n "$macro_prefix" || macro_prefix="gl"
5188 if test $m4dirs_count = 1; then
5189 # There's only one use of gnulib here. Assume the user means it.
5190 # Any number of additional modules can be given.
5191 for m4base in $m4dirs; do
5195 # Ambiguous - guess what the user meant.
5196 if test $# = 0; then
5197 # No further arguments. Guess the user wants to update all of them.
5198 for m4base in $m4dirs; do
5199 # Perform func_import in a subshell, so that variable values
5201 # local_gnulib_dir, incobsolete, avoidlist, sourcebase, m4base,
5202 # pobase, docbase, testsbase, inctests, libname, lgpl,
5203 # makefile_name, libtool, macro_prefix, po_domain, vc_files
5204 # don't propagate from one directory to another.
5205 (func_import) || func_exit 1
5209 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
5217 if test -z "$destdir"; then
5218 func_fatal_error "please specify --dir option"
5221 test -d "$destdir" \
5222 || func_fatal_error "could not create destination directory"
5223 test -n "$auxdir" || auxdir="build-aux"
5224 func_create_testdir "$destdir" "$*"
5227 create-megatestdir )
5228 if test -z "$destdir"; then
5229 func_fatal_error "please specify --dir option"
5231 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5232 test -n "$auxdir" || auxdir="build-aux"
5233 func_create_megatestdir "$destdir" "$*"
5237 test -n "$destdir" || destdir=testdir$$
5238 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5239 test -n "$auxdir" || auxdir="build-aux"
5240 func_create_testdir "$destdir" "$*"
5244 ../configure || func_exit 1
5245 $MAKE || func_exit 1
5246 $MAKE check || func_exit 1
5247 $MAKE distclean || func_exit 1
5248 remaining=`find . -type f -print`
5249 if test -n "$remaining"; then
5250 echo "Remaining files:" $remaining 1>&2
5251 echo "gnulib-tool: *** Stop." 1>&2
5260 test -n "$destdir" || destdir=testdir$$
5261 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5262 test -n "$auxdir" || auxdir="build-aux"
5263 func_create_megatestdir "$destdir" "$*"
5271 remaining=`find . -type f -print`
5272 if test -n "$remaining"; then
5273 echo "Remaining files:" $remaining 1>&2
5274 echo "gnulib-tool: *** Stop." 1>&2
5282 extract-description )
5286 if test -n "$module"; then
5287 func_get_description "$module"
5296 if test -n "$module"; then
5297 func_get_status "$module"
5306 if test -n "$module"; then
5307 func_get_notice "$module"
5312 extract-applicability )
5316 if test -n "$module"; then
5317 func_get_applicability "$module"
5326 if test -n "$module"; then
5327 func_get_filelist "$module"
5332 extract-dependencies )
5336 if test -n "$module"; then
5337 func_get_dependencies "$module"
5342 extract-autoconf-snippet )
5346 if test -n "$module"; then
5347 func_get_autoconf_snippet "$module"
5352 extract-automake-snippet )
5356 if test -n "$module"; then
5357 func_get_automake_snippet "$module"
5362 extract-include-directive )
5366 if test -n "$module"; then
5367 func_get_include_directive "$module"
5372 extract-link-directive )
5376 if test -n "$module"; then
5377 func_get_link_directive "$module"
5386 if test -n "$module"; then
5387 func_get_license "$module"
5392 extract-maintainer )
5396 if test -n "$module"; then
5397 func_get_maintainer "$module"
5402 extract-tests-module )
5406 if test -n "$module"; then
5407 func_get_tests_module "$module"
5413 # Verify the number of arguments.
5414 if test $# -lt 1 || test $# -gt 2; then
5415 func_fatal_error "invalid number of arguments for --$mode"
5418 # The first argument is the file to be copied.
5420 # Verify the file exists.
5421 func_lookup_file "$f"
5423 # The second argument is the destination; either a directory ot a file.
5424 # It defaults to the current directory.
5426 test -n "$dest" || dest='.'
5427 test -n "$sourcebase" || sourcebase="lib"
5428 test -n "$m4base" || m4base="m4"
5429 test -n "$docbase" || docbase="doc"
5430 test -n "$testsbase" || testsbase="tests"
5431 test -n "$auxdir" || auxdir="build-aux"
5432 rewritten='%REWRITTEN%'
5433 sed_rewrite_files="\
5434 s,^build-aux/,$rewritten$auxdir/,
5435 s,^doc/,$rewritten$docbase/,
5436 s,^lib/,$rewritten$sourcebase/,
5437 s,^m4/,$rewritten$m4base/,
5438 s,^tests/,$rewritten$testsbase/,
5441 if test -d "$dest"; then
5443 g=`echo "$f" | sed -e "$sed_rewrite_files"`
5445 destdir=`dirname "$dest"`
5446 g=`basename "$dest"`
5449 # Create the directory for destfile.
5450 d=`dirname "$destdir/$g"`
5452 if test -n "$d" && test ! -d "$d"; then
5453 mkdir -p "$d" || func_fatal_error "failed"
5457 func_dest_tmpfilename "$g"
5458 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5459 already_present=true
5460 if test -f "$destdir/$g"; then
5461 # The file already exists.
5465 # Don't protest if the file should be there but isn't: it happens
5466 # frequently that developers don't put autogenerated files into CVS.
5473 func_fatal_error "unknown operation mode --$mode" ;;
5477 # Undo the effect of the previous 'trap' command. Some shellology:
5478 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
5479 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
5480 # exit); for the others we need to call 'exit' explicitly. The value of $? is
5481 # 128 + signal number and is set before the trap-registered command is run.
5483 trap 'func_exit $?' 1 2 3 13 15
5488 # indent-tabs-mode: nil
5489 # whitespace-check-buffer-indent: nil