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-filelist extract the list of files
169 --extract-dependencies extract the dependencies
170 --extract-autoconf-snippet extract the snippet for configure.ac
171 --extract-automake-snippet extract the snippet for library makefile
172 --extract-include-directive extract the #include directive
173 --extract-link-directive extract the linker directive
174 --extract-license report the license terms of the source files
176 --extract-maintainer report the maintainer(s) inside gnulib
177 --extract-tests-module report the unit test module, if it exists
178 --copy-file copy a file that is not part of any module
181 --dir=DIRECTORY Specify the target directory.
182 For --import, this specifies where your
183 configure.ac can be found. Defaults to current
185 --local-dir=DIRECTORY Specify a local override directory where to look
186 up files before looking in gnulib's directory.
187 --cache-modules Enable module caching optimization.
188 --no-cache-modules Disable module caching optimization.
189 --verbose Increase verbosity. May be repeated.
190 --quiet Decrease verbosity. May be repeated.
192 Options for --import, --update:
193 --dry-run Only print what would have been done.
195 Options for --import, --create-[mega]testdir, --[mega]test:
196 --with-tests Include unit tests for the included modules.
197 --with-obsolete Include obsolete modules when they occur among the
198 dependencies. By default, dependencies to obsolete
200 --avoid=MODULE Avoid including the given MODULE. Useful if you
201 have code that provides equivalent functionality.
202 This option can be repeated.
203 --libtool Use libtool rules.
204 --no-libtool Don't use libtool rules.
206 Options for --import:
207 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
208 --source-base=DIRECTORY
209 Directory relative to --dir where source code is
210 placed (default \"lib\").
211 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
212 placed (default \"m4\").
213 --po-base=DIRECTORY Directory relative to --dir where *.po files are
214 placed (default \"po\").
215 --doc-base=DIRECTORY Directory relative to --dir where doc files are
216 placed (default \"doc\").
217 --tests-base=DIRECTORY
218 Directory relative to --dir where unit tests are
219 placed (default \"tests\").
220 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
221 tools are placed (default \"build-aux\").
222 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
223 Also modify license template from GPL to LGPL.
224 The version number of the LGPL can be specified;
225 the default is currently LGPLv3.
226 --makefile-name=NAME Name of makefile in automake syntax in the
227 source-base and tests-base directories
228 (default \"Makefile.am\").
229 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
230 'gl_INIT'. Default is 'gl'.
231 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
232 the package name. A suffix '-gnulib' is appended.
233 --vc-files Update version control related files.
234 --no-vc-files Don't update version control related files
235 (.gitignore and/or .cvsignore).
236 --no-changelog Don't update or create ChangeLog files.
238 Options for --import, --update, --create-[mega]testdir, --[mega]test:
239 -s, --symbolic, --symlink Make symbolic links instead of copying files.
240 --local-symlink Make symbolic links instead of copying files, only
241 for files from the local override directory.
243 Options for --import, --update:
244 -S, --more-symlinks Make symbolic links instead of copying files, and
245 don't replace copyright notices.
247 Report bugs to <bug-gnulib@gnu.org>."
251 # outputs to stdout the --version message.
255 if test -d "$gnulib_dir"/.git \
256 && (git --version) >/dev/null 2>/dev/null \
257 && (date --version) >/dev/null 2>/dev/null; then
258 # gnulib checked out from git.
259 sed_extract_first_date='/^Date/{
263 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
264 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
265 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
266 date=`echo "$date" | sed -e "$sed_year_before_time"`
267 # Use GNU date to compute the time in GMT.
268 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
269 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
271 if test -d "$gnulib_dir"/CVS \
272 && (cvs --version) >/dev/null 2>/dev/null; then
273 # gnulib checked out from CVS.
274 sed_extract_first_date='/^date: /{
275 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
278 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
280 # gnulib copy without versioning information.
281 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
285 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
287 gnulib-tool (GNU $package $date)$version
288 Copyright (C) $year Free Software Foundation, Inc.
289 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
290 This is free software: you are free to change and redistribute it.
291 There is NO WARRANTY, to the extent permitted by law.
293 Written by" "Bruno Haible" "and" "Simon Josefsson"
296 # func_emit_copyright_notice
297 # outputs to stdout a header for a generated file.
298 func_emit_copyright_notice ()
300 sed -n -e '/Copyright/ {
303 }' < "$self_abspathname"
305 echo "# This file is free software, distributed under the terms of the GNU"
306 echo "# General Public License. As a special exception to the GNU General"
307 echo "# Public License, this file may be distributed as part of a program"
308 echo "# that contains a configuration script generated by Autoconf, under"
309 echo "# the same distribution terms as the rest of that program."
311 echo "# Generated by gnulib-tool."
315 # exits with a given status.
316 # This function needs to be used, rather than 'exit', when a 'trap' handler is
317 # in effect that refers to $?.
324 # locates the directory where the gnulib repository lives
326 # - progname name of this program
328 # - self_abspathname absolute pathname of gnulib-tool
329 # - gnulib_dir absolute pathname of gnulib repository
333 /*) self_abspathname="$progname" ;;
334 */*) self_abspathname=`pwd`/"$progname" ;;
337 # Iterate through the elements of $PATH.
338 # We use IFS=: instead of
339 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
340 # because the latter does not work when some PATH element contains spaces.
341 # We use a canonicalized $pathx instead of $PATH, because empty PATH
342 # elements are by definition equivalent to '.', however field splitting
343 # according to IFS=: loses empty fields in many shells:
344 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
345 # beginning, at the end, and in the middle),
346 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
347 # at the beginning and at the end,
348 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
349 # Solaris lose empty fields at the end.
350 # The 'case' statement is an optimization, to avoid evaluating the
351 # explicit canonicalization command when $PATH contains no empty fields.
353 if test "${PATH_SEPARATOR+set}" != set; then
355 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
356 chmod +x "$tmp"/conf.sh
357 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
364 if test "$PATH_SEPARATOR" = ";"; then
365 # On Windows, programs are searched in "." before $PATH.
368 # On Unix, we have to convert empty PATH elements to ".".
372 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
377 IFS="$PATH_SEPARATOR"
381 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
382 self_abspathname="$d/$progname"
387 if test -z "$self_abspathname"; then
388 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
392 while test -h "$self_abspathname"; do
393 # Resolve symbolic link.
394 linkval=`func_readlink "$self_abspathname"`
395 test -n "$linkval" || break
397 /* ) self_abspathname="$linkval" ;;
398 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
401 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
405 # creates a temporary directory.
407 # - progname name of this program
409 # - tmp pathname of freshly created temporary directory
412 # Use the environment variable TMPDIR, falling back to /tmp. This allows
413 # users to specify a different temporary directory, for example, if their
414 # /tmp is filled up or too small.
417 # Use the mktemp program if available. If not available, hide the error
419 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
420 test -n "$tmp" && test -d "$tmp"
423 # Use a simple mkdir command. It is guaranteed to fail if the directory
424 # already exists. $RANDOM is bash specific and expands to empty in shells
425 # other than bash, ksh and zsh. Its use does not increase security;
426 # rather, it minimizes the probability of failure in a very cluttered /tmp
428 tmp=$TMPDIR/gl$$-$RANDOM
429 (umask 077 && mkdir "$tmp")
432 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
437 # func_append var value
438 # appends the given value to the shell variable var.
439 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
440 # Use bash's += operator. It reduces complexity of appending repeatedly to
441 # a single variable from O(n^2) to O(n).
446 fast_func_append=true
450 eval "$1=\"\$$1\$2\""
452 fast_func_append=false
455 # func_remove_prefix var prefix
456 # removes the given prefix from the value of the shell variable var.
457 # var should be the name of a shell variable.
458 # Its value should not contain a newline and not start or end with whitespace.
459 # prefix should not contain the characters "$`\{}[]^|.
460 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
461 func_remove_prefix ()
465 fast_func_remove_prefix=true
467 func_remove_prefix ()
469 eval "value=\"\$$1\""
473 sed_escape_dots='s/\([.]\)/\\\1/g'
474 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
477 value=`echo "$value" | sed -e "s|^${prefix}||"`
478 eval "$1=\"\$value\""
480 fast_func_remove_prefix=false
483 # func_remove_suffix var suffix
484 # removes the given suffix from the value of the shell variable var.
485 # var should be the name of a shell variable.
486 # Its value should not contain a newline and not start or end with whitespace.
487 # suffix should not contain the characters "$`\{}[]^|.
488 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
489 func_remove_suffix ()
493 fast_func_remove_suffix=true
495 func_remove_suffix ()
497 eval "value=\"\$$1\""
501 sed_escape_dots='s/\([.]\)/\\\1/g'
502 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
505 value=`echo "$value" | sed -e "s|${suffix}\$||"`
506 eval "$1=\"\$value\""
508 fast_func_remove_suffix=false
511 # func_fatal_error message
512 # outputs to stderr a fatal error message, and terminates the program.
514 # - progname name of this program
517 echo "$progname: *** $1" 1>&2
518 echo "$progname: *** Stop." 1>&2
522 # func_warning message
523 # Outputs to stderr a warning message,
526 echo "gnulib-tool: warning: $1" 1>&2
529 # func_readlink SYMLINK
530 # outputs the target of the given symlink.
531 if (type -p readlink) > /dev/null 2>&1; then
534 # Use the readlink program from GNU coreutils.
540 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
541 # would do the wrong thing if the link target contains " -> ".
542 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
546 # func_relativize DIR1 DIR2
547 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
549 # - DIR1 relative pathname, relative to the current directory
550 # - DIR2 relative pathname, relative to the current directory
552 # - reldir relative pathname of DIR2, relative to DIR1
558 sed_first='s,^\([^/]*\)/.*$,\1,'
559 sed_rest='s,^[^/]*/*,,'
560 sed_last='s,^.*/\([^/]*\)$,\1,'
561 sed_butlast='s,/*[^/]*$,,'
562 while test -n "$dir1"; do
563 first=`echo "$dir1" | sed -e "$sed_first"`
564 if test "$first" != "."; then
565 if test "$first" = ".."; then
566 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
567 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
569 first2=`echo "$dir2" | sed -e "$sed_first"`
570 if test "$first2" = "$first"; then
571 dir2=`echo "$dir2" | sed -e "$sed_rest"`
575 dir0="$dir0"/"$first"
578 dir1=`echo "$dir1" | sed -e "$sed_rest"`
583 # func_relconcat DIR1 DIR2
584 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
586 # - DIR1 relative pathname, relative to the current directory
587 # - DIR2 relative pathname, relative to DIR1
589 # - relconcat DIR1/DIR2, relative to the current directory
594 sed_first='s,^\([^/]*\)/.*$,\1,'
595 sed_rest='s,^[^/]*/*,,'
596 sed_last='s,^.*/\([^/]*\)$,\1,'
597 sed_butlast='s,/*[^/]*$,,'
599 first=`echo "$dir2" | sed -e "$sed_first"`
600 if test "$first" = "."; then
601 dir2=`echo "$dir2" | sed -e "$sed_rest"`
602 if test -z "$dir2"; then
607 last=`echo "$dir1" | sed -e "$sed_last"`
608 while test "$last" = "."; do
609 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
610 last=`echo "$dir1" | sed -e "$sed_last"`
612 if test -z "$dir1"; then
616 if test "$first" = ".."; then
617 if test "$last" = ".."; then
618 relconcat="$dir1/$dir2"
621 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
622 dir2=`echo "$dir2" | sed -e "$sed_rest"`
623 if test -z "$dir1"; then
627 if test -z "$dir2"; then
632 relconcat="$dir1/$dir2"
640 # Like ln -s, except that SRC is given relative to the current directory (or
641 # absolute), not given relative to the directory of DEST.
647 *) # SRC is relative.
650 ln -s "`pwd`/$1" "$2" ;;
651 *) # DEST is relative too.
652 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
653 test -n "$ln_destdir" || ln_destdir="."
654 func_relativize "$ln_destdir" "$1"
662 # func_ln_if_changed SRC DEST
663 # Like func_ln, but avoids munging timestamps if the link is correct.
664 func_ln_if_changed ()
666 if test $# -ne 2; then
667 echo "usage: func_ln_if_changed SRC DEST" >&2
669 ln_target=`func_readlink "$2"`
670 if test -h "$2" && test "$1" = "$ln_target"; then
678 # Ensure an 'echo' command that
679 # 1. does not interpret backslashes and
680 # 2. does not print an error message "broken pipe" when writing into a pipe
683 # Test cases for problem 1:
684 # echo '\n' | wc -l prints 1 when OK, 2 when KO
685 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
686 # Test cases for problem 2:
687 # echo hi | true frequently prints
688 # "bash: echo: write error: Broken pipe"
689 # to standard error in bash 3.2.
691 # Problem 1 is a weird heritage from SVR4. BSD got it right (except that
692 # BSD echo interprets '-n' as an option, which is also not desirable).
693 # Nowadays the problem occurs in 4 situations:
694 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
695 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
696 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
697 # - in zsh, when sh-emulation is not set,
698 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
699 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
700 # - in Solaris /bin/sh and OSF/1 /bin/sh.
701 # We try the following workarounds:
702 # - for all: respawn using $CONFIG_SHELL if that is set and works.
703 # - for bash >= 2.04: unset the shell option xpg_echo.
704 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
705 # - for bash < 2.0: define echo to a function that uses cat of a here document.
706 # - for zsh: turn sh-emulation on.
707 # - for ksh: alias echo to 'print -r'.
708 # - for ksh: alias echo to a function that uses cat of a here document.
709 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
710 # the ksh workaround.
711 # - otherwise: respawn using /bin/sh and rely on the workarounds.
712 # When respawning, we pass --no-reexec as first argument, so as to avoid
713 # turning this script into a fork bomb in unlucky situations.
715 # Problem 2 is specific to bash 3.2 and affects the 'echo' built-in, but not
716 # the 'printf' built-in. See
717 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>
718 # <http://lists.gnu.org/archive/html/bug-gnulib/2010-02/msg00154.html>
719 # The workaround is: define echo to a function that uses the printf built-in.
721 if echo '\t' | grep t > /dev/null; then
722 have_echo=yes # Lucky!
724 # Try the workarounds.
725 # Respawn using $CONFIG_SHELL if that is set and works.
726 if test -z "$have_echo" \
727 && test "X$1" != "X--no-reexec" \
728 && test -n "$CONFIG_SHELL" \
729 && test -f "$CONFIG_SHELL" \
730 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
731 exec $CONFIG_SHELL "$0" --no-reexec "$@"
734 # For bash >= 2.04: unset the shell option xpg_echo.
735 if test -z "$have_echo" \
736 && test -n "$BASH_VERSION" \
737 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
741 # For bash >= 2.0: define echo to a function that uses the printf built-in.
742 # For bash < 2.0: define echo to a function that uses cat of a here document.
743 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
744 # Also handle problem 2, specific to bash 3.2, here.
745 if { test -z "$have_echo" \
746 || case "$BASH_VERSION" in 3.2*) true;; *) false;; esac; \
748 && test -n "$BASH_VERSION"; then \
749 if type printf 2>/dev/null | grep / > /dev/null; then
750 # 'printf' is not a shell built-in.
758 # 'printf' is a shell built-in.
764 if echo '\t' | grep t > /dev/null; then
768 # For zsh: turn sh-emulation on.
769 if test -z "$have_echo" \
770 && test -n "$ZSH_VERSION" \
771 && (emulate sh) >/dev/null 2>&1; then
774 # For ksh: alias echo to 'print -r'.
775 if test -z "$have_echo" \
776 && (type print) >/dev/null 2>&1; then
777 # A 'print' command exists.
778 if type print 2>/dev/null | grep / > /dev/null; then
781 # 'print' is a shell built-in.
782 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
783 # 'print' is the ksh shell built-in.
784 alias echo='print -r'
788 if test -z "$have_echo" \
789 && echo '\t' | grep t > /dev/null; then
792 # For ksh: alias echo to a function that uses cat of a here document.
793 # The ksh manual page says:
794 # "Aliasing is performed when scripts are read, not while they are executed.
795 # Therefore, for an alias to take effect, the alias definition command has
796 # to be executed before the command which references the alias is read."
797 # Because of this, we have to play strange tricks with have_echo, to ensure
798 # that the top-level statement containing the test starts after the 'alias'
800 if test -z "$have_echo"; then
807 alias echo=bsd_echo 2>/dev/null
809 if test -z "$have_echo" \
810 && echo '\t' | grep t > /dev/null; then
813 if test -z "$have_echo"; then
814 unalias echo 2>/dev/null
816 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
817 if test -z "$have_echo" \
818 && test "X$1" != "X--no-reexec" \
819 && test -f /bin/ksh; then
820 exec /bin/ksh "$0" --no-reexec "$@"
823 # Otherwise: respawn using /bin/sh.
824 if test -z "$have_echo" \
825 && test "X$1" != "X--no-reexec" \
826 && test -f /bin/sh; then
827 exec /bin/sh "$0" --no-reexec "$@"
830 if test -z "$have_echo"; then
831 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
833 if echo '\t' | grep t > /dev/null; then
836 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
838 if test "X$1" = "X--no-reexec"; then
842 # Command-line option processing.
843 # Removes the OPTIONS from the arguments. Sets the variables:
844 # - mode list or import or create-testdir or create-megatestdir
845 # - destdir from --dir
846 # - local_gnulib_dir from --local-dir
847 # - modcache true or false, from --cache-modules/--no-cache-modules
848 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
849 # - libname, supplied_libname from --lib
850 # - sourcebase from --source-base
851 # - m4base from --m4-base
852 # - pobase from --po-base
853 # - docbase from --doc-base
854 # - testsbase from --tests-base
855 # - auxdir from --aux-dir
856 # - inctests true if --with-tests was given, blank otherwise
857 # - incobsolete true if --with-obsolete was given, blank otherwise
858 # - avoidlist list of modules to avoid, from --avoid
859 # - lgpl yes or a number if --lgpl was given, blank otherwise
860 # - makefile_name from --makefile-name
861 # - libtool true if --libtool was given, false if --no-libtool was
862 # given, blank otherwise
863 # - macro_prefix from --macro-prefix
864 # - po_domain from --po-domain
865 # - vc_files true if --vc-files was given, false if --no-vc-files was
866 # given, blank otherwise
867 # - autoconf_minversion minimum supported autoconf version
868 # - do_changelog false if --no-changelog was given, : otherwise
869 # - doit : if actions shall be executed, false if only to be printed
870 # - symbolic true if --symlink or --more-symlinks was given, blank
872 # - lsymbolic true if --local-symlink was given, blank otherwise
873 # - do_copyrights blank if --more-symlinks was given, true otherwise
905 while test $# -gt 0; do
910 --find | --fin | --fi | --f )
913 --import | --impor | --impo | --imp | --im | --i )
916 --update | --updat | --upda | --upd | --up | --u )
919 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
922 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
923 mode=create-megatestdir
925 --test | --tes | --te | --t )
928 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
932 mode=`echo "X$1" | sed -e 's/^X--//'`
934 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop | --co )
940 func_fatal_error "missing argument for --dir"
945 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
950 func_fatal_error "missing argument for --local-dir"
955 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
957 --cache-modules | --cache-module | --cache-modul | --cache-modu | --cache-mod | --cache-mo | --cache-m | --cache- | --cache | --cach | --cac | --ca )
960 --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 )
963 --verbose | --verbos | --verbo | --verb )
964 verbose=`expr $verbose + 1`
966 --quiet | --quie | --qui | --qu | --q )
967 verbose=`expr $verbose - 1`
972 func_fatal_error "missing argument for --lib"
975 supplied_libname=true
978 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
979 supplied_libname=true
984 func_fatal_error "missing argument for --source-base"
989 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
994 func_fatal_error "missing argument for --m4-base"
999 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
1003 if test $# = 0; then
1004 func_fatal_error "missing argument for --po-base"
1009 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
1013 if test $# = 0; then
1014 func_fatal_error "missing argument for --doc-base"
1019 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
1023 if test $# = 0; then
1024 func_fatal_error "missing argument for --tests-base"
1029 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1033 if test $# = 0; then
1034 func_fatal_error "missing argument for --aux-dir"
1039 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1049 if test $# = 0; then
1050 func_fatal_error "missing argument for --avoid"
1052 func_append avoidlist " $1"
1055 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1056 func_append avoidlist " $arg"
1062 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1065 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1071 if test $# = 0; then
1072 func_fatal_error "missing argument for --makefile-name"
1077 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1087 if test $# = 0; then
1088 func_fatal_error "missing argument for --macro-prefix"
1093 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1097 if test $# = 0; then
1098 func_fatal_error "missing argument for --po-domain"
1103 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1111 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1117 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1120 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1123 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1127 --help | --hel | --he | --h )
1130 --version | --versio | --versi | --vers )
1134 # Stop option processing
1138 echo "gnulib-tool: unknown option $1" 1>&2
1139 echo "Try 'gnulib-tool --help' for more information." 1>&2
1146 if test "$mode" = update; then
1147 if test $# != 0; then
1148 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1149 echo "Try 'gnulib-tool --help' for more information." 1>&2
1150 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1151 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1154 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1155 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1156 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1157 || test -n "$inctests" || test -n "$incobsolete" \
1158 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1159 || test -n "$macro_prefix" || test -n "$po_domain" \
1160 || test -n "$vc_files"; then
1161 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1162 echo "Try 'gnulib-tool --help' for more information." 1>&2
1163 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1164 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1169 if test -n "$pobase" && test -z "$po_domain"; then
1170 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1171 echo "Try 'gnulib-tool --help' for more information." 1>&2
1174 if test -z "$pobase" && test -n "$po_domain"; then
1175 func_warning "--po-domain has no effect without a --po-base option"
1178 # Determine the minimum supported autoconf version from the project's
1180 DEFAULT_AUTOCONF_MINVERSION="2.59"
1181 autoconf_minversion=
1183 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1184 if test -f "$destdir"/configure.ac; then
1185 configure_ac="$destdir/configure.ac"
1187 if test -f "$destdir"/configure.in; then
1188 configure_ac="$destdir/configure.in"
1192 if test -f configure.ac; then
1193 configure_ac="configure.ac"
1195 if test -f configure.in; then
1196 configure_ac="configure.in"
1200 if test -n "$configure_ac"; then
1201 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1202 # because when some m4 files are omitted from a CVS repository,
1203 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1204 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1205 # autom4te: m4 failed with exit status: 1
1212 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1214 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1215 if test -n "$prereqs"; then
1216 autoconf_minversion=`
1217 for version in $prereqs; do echo $version; done |
1218 LC_ALL=C sort -nru | sed -e 1q
1222 if test -z "$autoconf_minversion"; then
1223 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1225 case "$autoconf_minversion" in
1226 1.* | 2.[0-4]* | 2.5[0-8]*)
1227 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1230 # Remove trailing slashes from the directory names. This is necessary for
1231 # m4base (to avoid an error in func_import) and optional for the others.
1232 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1233 case "$local_gnulib_dir" in
1234 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1236 case "$sourcebase" in
1237 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1240 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1243 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1246 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1248 case "$testsbase" in
1249 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1252 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1258 trap 'exit_status=$?
1259 if test "$signal" != 0; then
1260 echo "caught signal $signal" >&2
1263 exit $exit_status' 0
1264 for signal in 1 2 3 13 15; do
1265 trap '{ signal='$signal'; func_exit 1; }' $signal
1269 # func_lookup_file file
1270 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1273 # - local_gnulib_dir from --local-dir
1275 # - lookedup_file name of the merged (combined) file
1276 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1280 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1281 lookedup_file="$local_gnulib_dir/$lkfile"
1284 if test -f "$gnulib_dir/$lkfile"; then
1285 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1286 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1287 rm -f "$tmp/$lkbase"
1288 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1289 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1290 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1291 lookedup_file="$tmp/$lkbase"
1294 lookedup_file="$gnulib_dir/$lkfile"
1298 func_fatal_error "file $gnulib_dir/$lkfile not found"
1303 # func_sanitize_modulelist
1304 # receives a list of possible module names on standard input, one per line.
1305 # It removes those which are just file names unrelated to modules, and outputs
1306 # the resulting list to standard output, one per line.
1307 func_sanitize_modulelist ()
1309 sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1310 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1311 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1312 -e '/^README$/d' -e '/\/README$/d' \
1313 -e '/^TEMPLATE$/d' \
1314 -e '/^TEMPLATE-EXTENDED$/d' \
1315 -e '/^TEMPLATE-TESTS$/d' \
1322 # - local_gnulib_dir from --local-dir
1325 # Filter out metainformation files like README, which are not modules.
1326 # Filter out unit test modules; they can be retrieved through
1327 # --extract-tests-module if desired.
1329 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1330 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1331 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1334 | func_sanitize_modulelist \
1335 | sed -e '/-tests$/d' \
1339 # func_verify_module
1340 # verifies a module name
1342 # - local_gnulib_dir from --local-dir
1343 # - module module name argument
1344 func_verify_module ()
1346 if { test -f "$gnulib_dir/modules/$module" \
1347 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1348 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1349 && test "CVS" != "$module" \
1350 && test "ChangeLog" != "$module" \
1351 && test "COPYING" != "$module" \
1352 && test "README" != "$module" \
1353 && test "TEMPLATE" != "$module" \
1354 && test "TEMPLATE-EXTENDED" != "$module" \
1355 && test "TEMPLATE-TESTS" != "$module"; then
1356 # OK, $module is a correct module name.
1357 # Verify that building the module description with 'patch' succeeds.
1358 func_lookup_file "modules/$module"
1360 func_warning "module $module doesn't exist"
1365 # func_verify_nontests_module
1366 # verifies a module name, excluding tests modules
1368 # - local_gnulib_dir from --local-dir
1369 # - module module name argument
1370 func_verify_nontests_module ()
1373 *-tests ) module= ;;
1374 * ) func_verify_module ;;
1378 # func_verify_tests_module
1379 # verifies a module name, considering only tests modules
1381 # - local_gnulib_dir from --local-dir
1382 # - module module name argument
1383 func_verify_tests_module ()
1386 *-tests ) func_verify_module ;;
1391 # Suffix of a sed expression that extracts a particular field from a
1392 # module description.
1393 # A field starts with a line that contains a keyword, such as 'Description',
1394 # followed by a colon and optional whitespace. All following lines, up to
1395 # the next field (or end of file if there is none) form the contents of the
1397 # An absent field is equivalent to a field with empty contents.
1398 # NOTE: Keep this in sync with sed_extract_cache_prog below!
1399 sed_extract_prog=':[ ]*$/ {
1402 s/^Description:[ ]*$//
1405 s/^Applicability:[ ]*$//
1407 s/^Depends-on:[ ]*$//
1408 s/^configure\.ac-early:[ ]*$//
1409 s/^configure\.ac:[ ]*$//
1410 s/^Makefile\.am:[ ]*$//
1414 s/^Maintainer:[ ]*$//
1421 # Piece of a sed expression that converts a field header line to a shell
1423 # NOTE: Keep this in sync with sed_extract_prog above!
1424 sed_extract_field_header='
1425 s/^Description:[ ]*$/description/
1426 s/^Status:[ ]*$/status/
1427 s/^Notice:[ ]*$/notice/
1428 s/^Applicability:[ ]*$/applicability/
1429 s/^Files:[ ]*$/files/
1430 s/^Depends-on:[ ]*$/dependson/
1431 s/^configure\.ac-early:[ ]*$/configureac_early/
1432 s/^configure\.ac:[ ]*$/configureac/
1433 s/^Makefile\.am:[ ]*$/makefile/
1434 s/^Include:[ ]*$/include/
1436 s/^License:[ ]*$/license/
1437 s/^Maintainer:[ ]*$/maintainer/'
1441 # Note: The 'eval' silences stderr output in dash.
1442 if declare -A x 2>/dev/null && { x[f/2]='foo'; x[f/3]='bar'; eval test '${x[f/2]}' = foo; }; then
1443 # Zsh 4 and Bash 4 have associative arrays.
1444 have_associative=true
1446 # For other shells, use 'eval' with computed shell variable names.
1447 have_associative=false
1450 if $have_associative; then
1452 # Declare the associative arrays.
1453 declare -A modcache_cached
1454 sed_to_declare_statement='s|^.*/\([a-zA-Z0-9_]*\)/$|declare -A modcache_\1|p'
1455 declare_script=`echo "$sed_extract_field_header" | sed -n -e "$sed_to_declare_statement"`
1456 eval "$declare_script"
1460 # func_cache_var module
1461 # computes the cache variable name corresponding to $module.
1462 # Note: This computation can map different module names to the same
1463 # cachevar (such as 'foo-bar', 'foo_bar', or 'foo/bar'); the caller has
1464 # to protect against this case.
1466 # - cachevar a shell variable name
1467 if (f=foo; eval echo '${f//o/e}') < /dev/null 2>/dev/null | grep fee >/dev/null; then
1468 # Bash 2.0 and newer, ksh, and zsh support the syntax
1469 # ${param//pattern/replacement}
1470 # as a shorthand for
1471 # `echo "$param" | sed -e "s/pattern/replacement/g"`.
1472 # Note: The 'eval' above silences stderr output in dash.
1475 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1482 cachevar=c_`echo "$1" | LC_ALL=C sed -e 's/[^a-zA-Z0-9_]/_/g'` ;;
1491 # func_init_sed_convert_to_cache_statements
1493 # - modcachevar_assignment
1495 # - sed_convert_to_cache_statements
1496 func_init_sed_convert_to_cache_statements ()
1498 # 'sed' script that turns a module description into shell script
1499 # assignments, suitable to be eval'ed. All active characters are escaped.
1502 # Some module's description
1507 # modcache_description[$1]=\
1508 # 'Some module'"'"'s description
1510 # modcache_files[$1]=\
1513 # c_MODULE_description_set=set; c_MODULE_description=\
1514 # 'Some module'"'"'s description
1516 # c_MODULE_files_set=set; c_MODULE_files=\
1518 # The script consists of two parts:
1519 # 1) Ignore the lines before the first field header.
1520 # 2) A loop, treating non-field-header lines by escaping single quotes
1521 # and adding a closing quote in the last line,
1522 sed_convert_to_cache_statements="
1524 # Here we have not yet seen a field header.
1526 # See if the current line contains a field header.
1529 ${sed_extract_field_header}
1532 # No field header. Ignore the line.
1534 # Read the next line. Upon EOF, just exit.
1539 # The current line contains a field header.
1541 # Turn it into the beginning of an assignment.
1542 s/^\\(.*\\)\$/${modcachevar_assignment}\\\\/
1544 # Move it to the hold space. Don't print it yet,
1545 # because we want no assignment if the field is empty.
1548 # Read the next line.
1549 # Upon EOF, the field was empty. Print no assignment. Just exit.
1552 # See if the current line contains a field header.
1555 ${sed_extract_field_header}
1556 # If it is, the previous field was empty. Print no assignment.
1559 # Not a field header.
1561 # Print the previous line, held in the hold space.
1566 # Transform single quotes.
1569 # Prepend a single quote.
1574 # Move it to the hold space.
1577 # Read the next line.
1584 # See if the current line contains a field header.
1587 ${sed_extract_field_header}
1590 # Print the previous line, held in the hold space.
1595 # Transform single quotes.
1602 # Print the previous line, held in the hold space, with a single quote
1603 # to end the assignment.
1613 # Print the previous line, held in the hold space, with a single quote
1614 # to end the assignment.
1621 if ! $sed_comments; then
1623 sed_convert_to_cache_statements=`echo "$sed_convert_to_cache_statements" \
1624 | sed -e 's/^ *//' -e 's/^#.*//'`
1628 if $have_associative; then
1629 # sed_convert_to_cache_statements does not depend on the module.
1630 modcachevar_assignment='modcache_\1[$1]='
1631 func_init_sed_convert_to_cache_statements
1634 # func_cache_lookup_module module
1636 # looks up a module, like 'func_lookup_file modules/$module', and stores all
1637 # of its relevant data in a cache in the memory of the processing shell. If
1638 # already cached, it does not look it up again, thus saving file access time.
1640 # - module non-empty string
1641 # Output if $have_associative:
1642 # - modcache_cached[$module] set to yes
1643 # - modcache_description[$module] ==
1644 # - modcache_status[$module] \ set to the field's value, minus the
1645 # - ... / final newline,
1646 # - modcache_maintainer[$module] == or unset if the field's value is empty
1647 # Output if ! $have_associative:
1648 # - cachevar a shell variable name
1649 # - ${cachevar}_cached set to $module
1650 # - ${cachevar}_description ==
1651 # - ${cachevar}_status \ set to the field's value, minus the
1652 # - ... / final newline,
1653 # - ${cachevar}_maintainer == or unset if the field's value is empty
1654 # - ${cachevar}_description_set ==
1655 # - ${cachevar}_status_set \ set to non-empty if the field's value
1656 # - ... / is non-empty,
1657 # - ${cachevar}_maintainer_set == or unset if the field's value is empty
1658 func_cache_lookup_module ()
1660 if $have_associative; then
1661 cached=${modcache_cached[$1]}
1664 eval "cached=\"\$${cachevar}_cached\""
1666 if test -z "$cached"; then
1667 # Not found in cache. Look it up on the file system.
1668 func_lookup_file "modules/$1"
1669 if $have_associative; then
1670 modcache_cached[$1]=yes
1672 eval "${cachevar}_cached=\"\$1\""
1674 if ! $have_associative; then
1675 # sed_convert_to_cache_statements depends on the module.
1676 modcachevar_assignment="${cachevar}"'_\1_set=set; '"${cachevar}"'_\1='
1677 func_init_sed_convert_to_cache_statements
1679 cache_statements=`LC_ALL=C sed -n -e "$sed_convert_to_cache_statements" < "$lookedup_file"`
1680 eval "$cache_statements"
1682 if ! $have_associative; then
1683 if test "$1" != "$cached"; then
1684 func_fatal_error "cache variable collision between $1 and $cached"
1692 # func_get_description module
1694 # - local_gnulib_dir from --local-dir
1695 # - modcache true or false, from --cache-modules/--no-cache-modules
1696 func_get_description ()
1698 if ! $modcache; then
1699 func_lookup_file "modules/$1"
1700 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1702 func_cache_lookup_module "$1"
1703 # Output the field's value, including the final newline (if any).
1704 if $have_associative; then
1705 if test -n "${modcache_description[$1]+set}"; then
1706 echo "${modcache_description[$1]}"
1709 eval "field_set=\"\$${cachevar}_description_set\""
1710 if test -n "$field_set"; then
1711 eval "field_value=\"\$${cachevar}_description\""
1712 echo "${field_value}"
1718 # func_get_status module
1720 # - local_gnulib_dir from --local-dir
1721 # - modcache true or false, from --cache-modules/--no-cache-modules
1724 if ! $modcache; then
1725 func_lookup_file "modules/$1"
1726 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1728 func_cache_lookup_module "$1"
1729 # Output the field's value, including the final newline (if any).
1730 if $have_associative; then
1731 if test -n "${modcache_status[$1]+set}"; then
1732 echo "${modcache_status[$1]}"
1735 eval "field_set=\"\$${cachevar}_status_set\""
1736 if test -n "$field_set"; then
1737 eval "field_value=\"\$${cachevar}_status\""
1738 echo "${field_value}"
1744 # func_get_notice module
1746 # - local_gnulib_dir from --local-dir
1747 # - modcache true or false, from --cache-modules/--no-cache-modules
1750 if ! $modcache; then
1751 func_lookup_file "modules/$1"
1752 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1754 func_cache_lookup_module "$1"
1755 # Output the field's value, including the final newline (if any).
1756 if $have_associative; then
1757 if test -n "${modcache_notice[$1]+set}"; then
1758 echo "${modcache_notice[$1]}"
1761 eval "field_set=\"\$${cachevar}_notice_set\""
1762 if test -n "$field_set"; then
1763 eval "field_value=\"\$${cachevar}_notice\""
1764 echo "${field_value}"
1770 # func_get_applicability module
1772 # - local_gnulib_dir from --local-dir
1773 # - modcache true or false, from --cache-modules/--no-cache-modules
1774 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1775 func_get_applicability ()
1777 if ! $modcache; then
1778 func_lookup_file "modules/$1"
1779 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1781 func_cache_lookup_module "$1"
1782 # Get the field's value, without the final newline.
1783 if $have_associative; then
1784 my_applicability="${modcache_applicability[$1]}"
1786 eval "my_applicability=\"\$${cachevar}_applicability\""
1789 if test -n "$my_applicability"; then
1790 echo $my_applicability
1792 # The default is 'main' or 'tests', depending on the module's name.
1794 *-tests) echo "tests";;
1800 # func_get_filelist module
1802 # - local_gnulib_dir from --local-dir
1803 # - modcache true or false, from --cache-modules/--no-cache-modules
1804 func_get_filelist ()
1806 if ! $modcache; then
1807 func_lookup_file "modules/$1"
1808 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1810 func_cache_lookup_module "$1"
1811 # Output the field's value, including the final newline (if any).
1812 if $have_associative; then
1813 if test -n "${modcache_files[$1]+set}"; then
1814 echo "${modcache_files[$1]}"
1817 eval "field_set=\"\$${cachevar}_files_set\""
1818 if test -n "$field_set"; then
1819 eval "field_value=\"\$${cachevar}_files\""
1820 echo "${field_value}"
1825 echo m4/gnulib-common.m4
1826 case "$autoconf_minversion" in
1833 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
1834 # stores in outputvar the filtered and processed filelist. Filtering: Only the
1835 # elements starting with prefix and ending with suffix are considered.
1836 # Processing: removed_prefix and removed_suffix are removed from each element,
1837 # added_prefix and added_suffix are added to each element.
1838 # prefix, suffix should not contain shell-special characters.
1839 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
1840 # added_prefix, added_suffix should not contain the characters \|&.
1841 func_filter_filelist ()
1843 if test "$2" != "$nl" \
1844 || { $fast_func_append \
1845 && { test -z "$6" || $fast_func_remove_prefix; } \
1846 && { test -z "$7" || $fast_func_remove_suffix; }; \
1850 # Do not quote possibly-empty parameters in case patterns,
1851 # AIX and HP-UX ksh won't match them if they are empty.
1854 if test -n "$6"; then
1855 func_remove_prefix fff "$6"
1857 if test -n "$7"; then
1858 func_remove_suffix fff "$7"
1861 if test -z "$ffflist"; then
1864 func_append ffflist "$2${fff}"
1870 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
1871 ffflist=`for fff in $3; do
1873 $4*$5) echo "$fff" ;;
1875 done | sed -e "$sed_fff_filter"`
1877 eval "$1=\"\$ffflist\""
1880 # func_get_dependencies module
1882 # - local_gnulib_dir from --local-dir
1883 # - modcache true or false, from --cache-modules/--no-cache-modules
1884 func_get_dependencies ()
1886 # ${module}-tests always implicitly depends on ${module}.
1890 func_remove_suffix fgd1 '-tests'
1894 # Then the explicit dependencies listed in the module description.
1895 if ! $modcache; then
1896 func_lookup_file "modules/$1"
1897 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1899 func_cache_lookup_module "$1"
1900 # Output the field's value, including the final newline (if any).
1901 if $have_associative; then
1902 if test -n "${modcache_dependson[$1]+set}"; then
1903 echo "${modcache_dependson[$1]}"
1906 eval "field_set=\"\$${cachevar}_dependson_set\""
1907 if test -n "$field_set"; then
1908 eval "field_value=\"\$${cachevar}_dependson\""
1909 echo "${field_value}"
1915 # func_get_autoconf_early_snippet module
1917 # - local_gnulib_dir from --local-dir
1918 # - modcache true or false, from --cache-modules/--no-cache-modules
1919 func_get_autoconf_early_snippet ()
1921 if ! $modcache; then
1922 func_lookup_file "modules/$1"
1923 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1925 func_cache_lookup_module "$1"
1926 # Output the field's value, including the final newline (if any).
1927 if $have_associative; then
1928 if test -n "${modcache_configureac_early[$1]+set}"; then
1929 echo "${modcache_configureac_early[$1]}"
1932 eval "field_set=\"\$${cachevar}_configureac_early_set\""
1933 if test -n "$field_set"; then
1934 eval "field_value=\"\$${cachevar}_configureac_early\""
1935 echo "${field_value}"
1941 # func_get_autoconf_snippet module
1943 # - local_gnulib_dir from --local-dir
1944 # - modcache true or false, from --cache-modules/--no-cache-modules
1945 func_get_autoconf_snippet ()
1947 if ! $modcache; then
1948 func_lookup_file "modules/$1"
1949 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1951 func_cache_lookup_module "$1"
1952 # Output the field's value, including the final newline (if any).
1953 if $have_associative; then
1954 if test -n "${modcache_configureac[$1]+set}"; then
1955 echo "${modcache_configureac[$1]}"
1958 eval "field_set=\"\$${cachevar}_configureac_set\""
1959 if test -n "$field_set"; then
1960 eval "field_value=\"\$${cachevar}_configureac\""
1961 echo "${field_value}"
1967 # func_get_automake_snippet module
1969 # - local_gnulib_dir from --local-dir
1970 # - modcache true or false, from --cache-modules/--no-cache-modules
1971 func_get_automake_snippet ()
1973 if ! $modcache; then
1974 func_lookup_file "modules/$1"
1975 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1977 func_cache_lookup_module "$1"
1978 # Output the field's value, including the final newline (if any).
1979 if $have_associative; then
1980 if test -n "${modcache_makefile[$1]+set}"; then
1981 echo "${modcache_makefile[$1]}"
1984 eval "field_set=\"\$${cachevar}_makefile_set\""
1985 if test -n "$field_set"; then
1986 eval "field_value=\"\$${cachevar}_makefile\""
1987 echo "${field_value}"
1993 # *-tests module live in tests/, not lib/.
1994 # Synthesize an EXTRA_DIST augmentation.
1995 all_files=`func_get_filelist $1`
1996 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
1997 extra_files="$tests_files"
1998 if test -n "$extra_files"; then
1999 echo "EXTRA_DIST +=" $extra_files
2004 # Synthesize an EXTRA_DIST augmentation.
2005 sed_combine_lines='/\\$/{
2012 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
2013 already_mentioned_files=` \
2014 { if ! $modcache; then
2015 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
2017 if $have_associative; then
2018 if test -n "${modcache_makefile[$1]+set}"; then
2019 echo "${modcache_makefile[$1]}"
2022 eval 'field_set="$'"${cachevar}"'_makefile_set"'
2023 if test -n "$field_set"; then
2024 eval 'field_value="$'"${cachevar}"'_makefile"'
2025 echo "${field_value}"
2030 | sed -e "$sed_combine_lines" \
2031 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
2032 all_files=`func_get_filelist $1`
2033 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
2034 # Remove $already_mentioned_files from $lib_files.
2035 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
2036 extra_files=`for f in $already_mentioned_files; do echo $f; done \
2037 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
2038 if test -n "$extra_files"; then
2039 echo "EXTRA_DIST +=" $extra_files
2042 # Synthesize also an EXTRA_lib_SOURCES augmentation.
2043 # This is necessary so that automake can generate the right list of
2045 # A possible approach would be to use autom4te --trace of the redefined
2046 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
2047 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
2048 # inside autoconf's built-in macros are not missed).
2049 # But it's simpler and more robust to do it here, based on the file list.
2050 # If some .c file exists and is not used with AC_LIBOBJ - for example,
2051 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
2052 # automake will generate a useless dependency; this is harmless.
2054 relocatable-prog-wrapper) ;;
2056 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
2057 if test -n "$extra_files"; then
2058 echo "EXTRA_lib_SOURCES +=" $extra_files
2063 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
2064 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
2065 if test -n "$buildaux_files"; then
2066 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
2067 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
2070 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
2071 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
2072 if test -n "$top_files"; then
2073 sed_prepend_topdir='s,^,$(top_srcdir)/,'
2074 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
2081 # func_get_include_directive module
2083 # - local_gnulib_dir from --local-dir
2084 # - modcache true or false, from --cache-modules/--no-cache-modules
2085 func_get_include_directive ()
2088 if ! $modcache; then
2089 func_lookup_file "modules/$1"
2090 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file"
2092 func_cache_lookup_module "$1"
2093 # Output the field's value, including the final newline (if any).
2094 if $have_associative; then
2095 if test -n "${modcache_include[$1]+set}"; then
2096 echo "${modcache_include[$1]}"
2099 eval "field_set=\"\$${cachevar}_include_set\""
2100 if test -n "$field_set"; then
2101 eval "field_value=\"\$${cachevar}_include\""
2102 echo "${field_value}"
2106 } | sed -e 's/^\(["<]\)/#include \1/'
2109 # func_get_link_directive module
2111 # - local_gnulib_dir from --local-dir
2112 # - modcache true or false, from --cache-modules/--no-cache-modules
2113 func_get_link_directive ()
2115 if ! $modcache; then
2116 func_lookup_file "modules/$1"
2117 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
2119 func_cache_lookup_module "$1"
2120 # Output the field's value, including the final newline (if any).
2121 if $have_associative; then
2122 if test -n "${modcache_link[$1]+set}"; then
2123 echo "${modcache_link[$1]}"
2126 eval "field_set=\"\$${cachevar}_link_set\""
2127 if test -n "$field_set"; then
2128 eval "field_value=\"\$${cachevar}_link\""
2129 echo "${field_value}"
2135 # func_get_license module
2137 # - local_gnulib_dir from --local-dir
2138 # - modcache true or false, from --cache-modules/--no-cache-modules
2142 if ! $modcache; then
2143 func_lookup_file "modules/$1"
2144 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
2146 func_cache_lookup_module "$1"
2147 # Output the field's value, including the final newline (if any).
2148 if $have_associative; then
2149 if test -n "${modcache_license[$1]+set}"; then
2150 echo "${modcache_license[$1]}"
2153 eval "field_set=\"\$${cachevar}_license_set\""
2154 if test -n "$field_set"; then
2155 eval "field_value=\"\$${cachevar}_license\""
2156 echo "${field_value}"
2160 # The default is GPL.
2162 } | sed -e 's,^ *$,,' | sed -e 1q
2165 # func_get_maintainer module
2167 # - local_gnulib_dir from --local-dir
2168 # - modcache true or false, from --cache-modules/--no-cache-modules
2169 func_get_maintainer ()
2171 if ! $modcache; then
2172 func_lookup_file "modules/$1"
2173 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
2175 func_cache_lookup_module "$1"
2176 # Output the field's value, including the final newline (if any).
2177 if $have_associative; then
2178 if test -n "${modcache_maintainer[$1]+set}"; then
2179 echo "${modcache_maintainer[$1]}"
2182 eval "field_set=\"\$${cachevar}_maintainer_set\""
2183 if test -n "$field_set"; then
2184 eval "field_value=\"\$${cachevar}_maintainer\""
2185 echo "${field_value}"
2191 # func_get_tests_module module
2193 # - local_gnulib_dir from --local-dir
2194 func_get_tests_module ()
2196 # The naming convention for tests modules is hardwired: ${module}-tests.
2197 if test -f "$gnulib_dir/modules/$1"-tests \
2198 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
2199 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
2204 # func_acceptable module
2205 # tests whether a module is acceptable.
2207 # - avoidlist list of modules to avoid
2210 for avoid in $avoidlist; do
2211 if test "$avoid" = "$1"; then
2218 # func_modules_transitive_closure
2220 # - local_gnulib_dir from --local-dir
2221 # - modcache true or false, from --cache-modules/--no-cache-modules
2222 # - modules list of specified modules
2223 # - inctests true if tests should be included, blank otherwise
2224 # - incobsolete true if obsolete modules among dependencies should be
2225 # included, blank otherwise
2226 # - avoidlist list of modules to avoid
2227 # - tmp pathname of a temporary directory
2229 # - modules list of modules, including dependencies
2230 func_modules_transitive_closure ()
2232 # In order to process every module only once (for speed), process an "input
2233 # list" of modules, producing an "output list" of modules. During each round,
2234 # more modules can be queued in the input list. Once a module on the input
2235 # list has been processed, it is added to the "handled list", so we can avoid
2236 # to process it again.
2238 inmodules="$modules"
2240 while test -n "$inmodules"; do
2241 inmodules_this_round="$inmodules"
2242 inmodules= # Accumulator, queue for next round
2243 for module in $inmodules_this_round; do
2245 if test -n "$module"; then
2246 if func_acceptable $module; then
2247 func_append outmodules " $module"
2248 deps=`func_get_dependencies $module`
2249 # Duplicate dependencies are harmless, but Jim wants a warning.
2250 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
2251 if test -n "$duplicated_deps"; then
2252 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
2254 for dep in $deps; do
2255 if test -n "$incobsolete" \
2256 || { status=`func_get_status $dep`; test "$status" != obsolete; }; then
2257 func_append inmodules " $dep"
2260 if test -n "$inctests"; then
2261 testsmodule=`func_get_tests_module $module`
2262 if test -n "$testsmodule"; then
2263 func_append inmodules " $testsmodule"
2269 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
2270 # Remove $handledmodules from $inmodules.
2271 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
2272 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
2274 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
2275 rm -f "$tmp"/queued-modules
2278 # func_modules_add_dummy
2280 # - local_gnulib_dir from --local-dir
2281 # - modcache true or false, from --cache-modules/--no-cache-modules
2282 # - modules list of modules, including dependencies
2284 # - modules list of modules, including 'dummy' if needed
2285 func_modules_add_dummy ()
2287 # Determine whether any module provides a lib_SOURCES augmentation.
2289 sed_remove_backslash_newline=':a
2296 for module in $modules; do
2297 func_verify_nontests_module
2298 if test -n "$module"; then
2299 # Extract the value of "lib_SOURCES += ...".
2300 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
2301 # Ignore .h files since they are not compiled.
2305 have_lib_SOURCES=yes
2312 # Add the dummy module, to make sure the library will be non-empty.
2313 if test -z "$have_lib_SOURCES"; then
2314 if func_acceptable "dummy"; then
2315 func_append modules " dummy"
2320 # func_modules_notice
2322 # - local_gnulib_dir from --local-dir
2323 # - modcache true or false, from --cache-modules/--no-cache-modules
2324 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2325 # - modules list of modules, including dependencies
2326 func_modules_notice ()
2328 if test $verbose -ge -1; then
2329 for module in $modules; do
2331 if test -n "$module"; then
2332 msg=`func_get_notice $module`
2333 if test -n "$msg"; then
2334 echo "Notice from module $module:"
2335 echo "$msg" | sed -e 's/^/ /'
2342 # func_modules_to_filelist
2344 # - local_gnulib_dir from --local-dir
2345 # - modcache true or false, from --cache-modules/--no-cache-modules
2346 # - modules list of modules, including dependencies
2348 # - files list of files
2349 func_modules_to_filelist ()
2352 for module in $modules; do
2354 if test -n "$module"; then
2355 fs=`func_get_filelist $module`
2356 func_append files " $fs"
2359 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2362 # func_execute_command command [args...]
2363 # Executes a command.
2364 # Uses also the variables
2365 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2366 func_execute_command ()
2368 if test $verbose -ge 0; then
2372 # Commands like automake produce output to stderr even when they succeed.
2373 # Turn this output off if the command succeeds.
2374 "$@" > "$tmp"/cmdout 2>&1
2376 if test $cmdret = 0; then
2380 cat "$tmp"/cmdout 1>&2
2387 # func_dest_tmpfilename file
2388 # determines the name of a temporary file (file is relative to destdir).
2390 # - destdir target directory
2391 # - doit : if actions shall be executed, false if only to be printed
2392 # - tmp pathname of a temporary directory
2394 # - tmpfile absolute filename of the temporary file
2395 func_dest_tmpfilename ()
2398 # Put the new contents of $file in a file in the same directory (needed
2399 # to guarantee that an 'mv' to "$destdir/$file" works).
2400 tmpfile="$destdir/$1.tmp"
2402 # Put the new contents of $file in a file in a temporary directory
2403 # (because the directory of "$file" might not exist).
2404 tmpfile="$tmp"/`basename "$1"`.tmp
2409 # copies a file from gnulib into the destination directory. The destination
2410 # is known to not exist.
2412 # - destdir target directory
2413 # - local_gnulib_dir from --local-dir
2414 # - modcache true or false, from --cache-modules/--no-cache-modules
2415 # - f the original file name
2416 # - lookedup_file name of the merged (combined) file
2417 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2418 # - g the rewritten file name
2419 # - tmpfile absolute filename of the temporary file
2420 # - doit : if actions shall be executed, false if only to be printed
2421 # - symbolic true if files should be symlinked, copied otherwise
2422 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2427 echo "Copying file $g"
2428 if { test -n "$symbolic" \
2429 || { test -n "$lsymbolic" \
2430 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2431 && test -z "$lookedup_tmp" \
2432 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2433 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2435 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2443 # copies a file from gnulib into the destination directory. The destination
2444 # is known to exist.
2446 # - destdir target directory
2447 # - local_gnulib_dir from --local-dir
2448 # - modcache true or false, from --cache-modules/--no-cache-modules
2449 # - f the original file name
2450 # - lookedup_file name of the merged (combined) file
2451 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2452 # - g the rewritten file name
2453 # - tmpfile absolute filename of the temporary file
2454 # - doit : if actions shall be executed, false if only to be printed
2455 # - symbolic true if files should be symlinked, copied otherwise
2456 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2458 # - already_present nonempty if the file should already exist, empty otherwise
2461 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2462 : # The file has not changed.
2466 if test -n "$already_present"; then
2467 echo "Updating file $g (backup in ${g}~)"
2469 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2471 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2472 if { test -n "$symbolic" \
2473 || { test -n "$lsymbolic" \
2474 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2475 && test -z "$lookedup_tmp" \
2476 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2477 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2479 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2482 if test -n "$already_present"; then
2483 echo "Update file $g (backup in ${g}~)"
2485 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2491 # func_emit_lib_Makefile_am
2492 # emits the contents of library makefile to standard output.
2494 # - local_gnulib_dir from --local-dir
2495 # - modcache true or false, from --cache-modules/--no-cache-modules
2496 # - modules list of modules, including dependencies
2497 # - libname library name
2498 # - pobase directory relative to destdir where to place *.po files
2499 # - auxdir directory relative to destdir where to place build aux files
2500 # - makefile_name from --makefile-name
2501 # - libtool true if libtool will be used, false or blank otherwise
2502 # - macro_prefix prefix of gl_LIBOBJS macros to use
2503 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2504 # - actioncmd (optional) command that will reproduce this invocation
2505 # - for_test true if creating a package for testing, false otherwise
2506 # - destfile filename relative to destdir of makefile being generated
2508 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2509 # list of edits to be done to Makefile.am variables
2511 # - uses_subdirs nonempty if object files in subdirs exist
2512 func_emit_lib_Makefile_am ()
2514 # When creating an includable Makefile.am snippet, augment variables with
2515 # += instead of assigning them.
2516 if test -n "$makefile_name"; then
2521 if test "$libtool" = true; then
2524 sed_eliminate_LDFLAGS="$sed_noop"
2528 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2531 # When creating a package for testing: Attempt to provoke failures,
2532 # especially link errors, already during "make" rather than during
2533 # "make check", because "make check" is not possible in a cross-compiling
2534 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2535 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2537 sed_transform_check_PROGRAMS="$sed_noop"
2539 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2540 echo "## Process this file with automake to produce Makefile.in."
2541 func_emit_copyright_notice
2542 if test -n "$actioncmd"; then
2543 # The maximum line length (excluding the terminating newline) of any file
2544 # that is to be preprocessed by config.status is 3070. config.status uses
2545 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
2546 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
2547 len=`echo "$actioncmd" | wc -c`
2548 if test -n "$len" && test "$len" -le 3000; then
2549 echo "# Reproduce by: $actioncmd"
2555 for module in $modules; do
2556 func_verify_nontests_module
2557 if test -n "$module"; then
2559 func_get_automake_snippet "$module" |
2561 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2562 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2563 -e "$sed_eliminate_LDFLAGS" \
2564 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
2565 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2566 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2567 -e "$sed_transform_check_PROGRAMS"
2568 if test "$module" = 'alloca'; then
2569 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2570 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2572 } > "$tmp"/amsnippet
2573 # Skip the contents if it's entirely empty.
2574 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2575 echo "## begin gnulib module $module"
2577 cat "$tmp"/amsnippet
2578 echo "## end gnulib module $module"
2581 rm -f "$tmp"/amsnippet
2582 # Test whether there are some source files in subdirectories.
2583 for f in `func_get_filelist "$module"`; do
2593 } > "$tmp"/allsnippets
2594 if test -z "$makefile_name"; then
2595 # If there are source files in subdirectories, prevent collision of the
2596 # object files (example: hash.c and libxml/hash.c).
2598 if test -n "$uses_subdirs"; then
2599 subdir_options=' subdir-objects'
2601 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2604 if test -z "$makefile_name"; then
2606 echo "noinst_HEADERS ="
2607 echo "noinst_LIBRARIES ="
2608 echo "noinst_LTLIBRARIES ="
2609 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2610 # if you specify pkgdata_DATA to empty. This is a workaround.
2611 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2612 echo "pkgdata_DATA ="
2615 echo "BUILT_SOURCES ="
2618 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2619 if test -z "$makefile_name"; then
2620 echo "MOSTLYCLEANDIRS ="
2622 echo "DISTCLEANFILES ="
2623 echo "MAINTAINERCLEANFILES ="
2625 # Execute edits that apply to the Makefile.am being generated.
2627 while test $edit != $makefile_am_edits; do
2628 edit=`expr $edit + 1`
2629 eval dir=\"\$makefile_am_edit${edit}_dir\"
2630 eval var=\"\$makefile_am_edit${edit}_var\"
2631 eval val=\"\$makefile_am_edit${edit}_val\"
2632 if test -n "$var"; then
2633 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2634 echo "${var} += ${val}"
2635 eval "makefile_am_edit${edit}_var="
2639 if test -z "$makefile_name"; then
2641 echo "AM_CPPFLAGS ="
2645 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
2646 || { test -n "$makefile_name" \
2647 && test -f "$sourcebase/Makefile.am" \
2648 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2650 # One of the snippets or the user's Makefile.am already specifies an
2651 # installation location for the library. Don't confuse automake by saying
2652 # it should not be installed.
2655 # By default, the generated library should not be installed.
2656 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2659 echo "${libname}_${libext}_SOURCES ="
2660 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2661 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2662 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2663 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2664 echo "EXTRA_${libname}_${libext}_SOURCES ="
2665 if test "$libtool" = true; then
2666 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2669 if test -n "$pobase"; then
2670 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2673 cat "$tmp"/allsnippets \
2674 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2676 echo "mostlyclean-local: mostlyclean-generic"
2677 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2678 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2679 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2683 rm -f "$tmp"/allsnippets
2686 # func_emit_po_Makevars
2687 # emits the contents of po/ makefile parameterization to standard output.
2689 # - local_gnulib_dir from --local-dir
2690 # - modcache true or false, from --cache-modules/--no-cache-modules
2691 # - sourcebase directory relative to destdir where to place source code
2692 # - pobase directory relative to destdir where to place *.po files
2693 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2694 func_emit_po_Makevars ()
2696 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2697 func_emit_copyright_notice
2699 echo "# Usually the message domain is the same as the package name."
2700 echo "# But here it has a '-gnulib' suffix."
2701 echo "DOMAIN = ${po_domain}-gnulib"
2703 echo "# These two variables depend on the location of this directory."
2704 echo "subdir = ${pobase}"
2705 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2708 # These options get passed to xgettext.
2709 XGETTEXT_OPTIONS = \
2710 --keyword=_ --flag=_:1:pass-c-format \
2711 --keyword=N_ --flag=N_:1:pass-c-format \
2712 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2713 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2714 --flag=error:3:c-format --flag=error_at_line:5:c-format
2716 # This is the copyright holder that gets inserted into the header of the
2717 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2718 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2720 # This is the email address or URL to which the translators shall report
2721 # bugs in the untranslated strings:
2722 # - Strings which are not entire sentences, see the maintainer guidelines
2723 # in the GNU gettext documentation, section 'Preparing Strings'.
2724 # - Strings which use unclear terms or require additional context to be
2726 # - Strings which make invalid assumptions about notation of date, time or
2728 # - Pluralisation problems.
2729 # - Incorrect English spelling.
2730 # - Incorrect formatting.
2731 # It can be your email address, or a mailing list address where translators
2732 # can write to without being subscribed, or the URL of a web page through
2733 # which the translators can contact you.
2734 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2736 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2737 # message catalogs shall be used. It is usually empty.
2738 EXTRA_LOCALE_CATEGORIES =
2740 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2741 # context. Possible values are "yes" and "no". Set this to yes if the
2742 # package uses functions taking also a message context, like pgettext(), or
2743 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
2748 # func_emit_po_POTFILES_in
2749 # emits the file list to be passed to xgettext to standard output.
2751 # - local_gnulib_dir from --local-dir
2752 # - modcache true or false, from --cache-modules/--no-cache-modules
2753 # - sourcebase directory relative to destdir where to place source code
2754 # - files list of new files
2755 func_emit_po_POTFILES_in ()
2757 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2758 func_emit_copyright_notice
2760 echo "# List of files which contain translatable strings."
2761 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
2764 # func_emit_tests_Makefile_am witness_macro
2765 # emits the contents of tests makefile to standard output.
2767 # - local_gnulib_dir from --local-dir
2768 # - modcache true or false, from --cache-modules/--no-cache-modules
2769 # - modules list of modules, including dependencies
2770 # - libname library name
2771 # - auxdir directory relative to destdir where to place build aux files
2772 # - makefile_name from --makefile-name
2773 # - libtool true if libtool will be used, false or blank otherwise
2774 # - sourcebase relative directory containing lib source code
2775 # - m4base relative directory containing autoconf macros
2776 # - testsbase relative directory containing unit test code
2777 # - macro_prefix prefix of gl_LIBOBJS macros to use
2778 # - for_test true if creating a package for testing, false otherwise
2779 # - use_libtests true if a libtests.a should be built, false otherwise
2780 # - destfile filename relative to destdir of makefile being generated
2782 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2783 # list of edits to be done to Makefile.am variables
2785 # - uses_subdirs nonempty if object files in subdirs exist
2786 func_emit_tests_Makefile_am ()
2789 if test "$libtool" = true; then
2791 sed_eliminate_LDFLAGS="$sed_noop"
2794 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2797 # When creating a package for testing: Attempt to provoke failures,
2798 # especially link errors, already during "make" rather than during
2799 # "make check", because "make check" is not possible in a cross-compiling
2800 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2801 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2803 sed_transform_check_PROGRAMS="$sed_noop"
2805 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
2806 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2807 echo "## Process this file with automake to produce Makefile.in."
2808 func_emit_copyright_notice
2812 for module in $modules; do
2814 func_verify_tests_module
2818 if test -n "$module"; then
2820 func_get_automake_snippet "$module" |
2822 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2823 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2824 -e "$sed_eliminate_LDFLAGS" \
2825 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
2826 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2827 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2828 -e "$sed_transform_check_PROGRAMS"
2829 if $use_libtests && test "$module" = 'alloca'; then
2830 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
2831 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2833 } > "$tmp"/amsnippet
2834 # Skip the contents if it's entirely empty.
2835 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2836 echo "## begin gnulib module $module"
2838 cat "$tmp"/amsnippet
2839 echo "## end gnulib module $module"
2842 rm -f "$tmp"/amsnippet
2843 # Test whether there are some source files in subdirectories.
2844 for f in `func_get_filelist "$module"`; do
2846 lib/*/*.c | tests/*/*.c)
2854 } > "$tmp"/allsnippets
2855 # Generate dependencies here, since it eases the debugging of test failures.
2856 # If there are source files in subdirectories, prevent collision of the
2857 # object files (example: hash.c and libxml/hash.c).
2859 if test -n "$uses_subdirs"; then
2860 subdir_options=' subdir-objects'
2862 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
2865 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
2868 # Nothing is being added to SUBDIRS; nevertheless the existence of this
2869 # variable is needed to avoid an error from automake:
2870 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
2873 echo "XFAIL_TESTS ="
2874 echo "TESTS_ENVIRONMENT ="
2875 echo "noinst_PROGRAMS ="
2876 if ! $for_test; then
2877 echo "check_PROGRAMS ="
2879 echo "noinst_HEADERS ="
2880 echo "noinst_LIBRARIES ="
2881 if $use_libtests; then
2883 echo "noinst_LIBRARIES += libtests.a"
2885 echo "check_LIBRARIES = libtests.a"
2888 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2889 # if you specify pkgdata_DATA to empty. This is a workaround.
2890 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2891 echo "pkgdata_DATA ="
2894 echo "BUILT_SOURCES ="
2896 echo "MOSTLYCLEANFILES = core *.stackdump"
2897 echo "MOSTLYCLEANDIRS ="
2899 echo "DISTCLEANFILES ="
2900 echo "MAINTAINERCLEANFILES ="
2901 # Execute edits that apply to the Makefile.am being generated.
2903 while test $edit != $makefile_am_edits; do
2904 edit=`expr $edit + 1`
2905 eval dir=\"\$makefile_am_edit${edit}_dir\"
2906 eval var=\"\$makefile_am_edit${edit}_var\"
2907 eval val=\"\$makefile_am_edit${edit}_val\"
2908 if test -n "$var"; then
2909 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2910 echo "${var} += ${val}"
2911 eval "makefile_am_edit${edit}_var="
2916 echo "AM_CPPFLAGS = \\"
2917 if test -n "${witness_macro}"; then
2918 echo " -D@${witness_macro}@=1 \\"
2920 echo " -I. -I\$(srcdir) \\"
2921 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
2922 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
2924 local_ldadd_before=''
2925 local_ldadd_after=''
2926 if $use_libtests; then
2927 # All test programs need to be linked with libtests.a.
2928 # It needs to be passed to the linker before ${libname}.${libext}, since
2929 # the tests-related modules depend on the main modules.
2930 # It also needs to be passed to the linker after ${libname}.${libext}
2931 # because the latter might contain incomplete modules (such as the 'error'
2932 # module whose dependency to 'progname' is voluntarily omitted).
2933 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
2935 local_ldadd_before=' libtests.a'
2936 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
2938 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
2940 if $use_libtests; then
2941 echo "libtests_a_SOURCES ="
2942 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2943 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2944 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
2945 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
2946 echo "EXTRA_libtests_a_SOURCES ="
2947 # The circular dependency in LDADD requires this.
2948 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
2951 # Many test scripts use ${EXEEXT} or ${srcdir}.
2952 # EXEEXT is defined by AC_PROG_CC through autoconf.
2953 # srcdir is defined by autoconf and automake.
2954 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
2956 cat "$tmp"/allsnippets \
2957 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2958 echo "# Clean up after Solaris cc."
2960 echo " rm -rf SunWS_cache"
2962 echo "mostlyclean-local: mostlyclean-generic"
2963 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2964 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2965 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2969 rm -f "$tmp"/allsnippets
2972 # func_emit_initmacro_start macro_prefix
2973 # emits the first few statements of the gl_INIT macro to standard output.
2974 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2975 func_emit_initmacro_start ()
2977 macro_prefix_arg="$1"
2978 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
2979 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
2980 # LIBOBJS. The purpose is to allow several gnulib instantiations under
2981 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
2983 # Furthermore it avoids an automake error like this when a Makefile.am
2984 # that uses pieces of gnulib also uses $(LIBOBJ):
2985 # automatically discovered file `error.c' should not be explicitly mentioned
2986 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
2987 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
2988 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
2989 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
2990 # automatically discovered file `error.c' should not be explicitly mentioned
2991 # We let automake know about the files to be distributed through the
2992 # EXTRA_lib_SOURCES variable.
2993 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
2994 # Create data variables for checking the presence of files that are mentioned
2995 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
2996 # because we want the check to happen when the configure file is created,
2997 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
2998 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
2999 # in which to expect them.
3000 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
3001 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
3005 # func_emit_initmacro_end macro_prefix
3006 # emits the last few statements of the gl_INIT macro to standard output.
3007 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3008 func_emit_initmacro_end ()
3010 macro_prefix_arg="$1"
3011 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
3012 # The check is performed only when autoconf is run from the directory where
3013 # the configure.ac resides; if it is run from a different directory, the
3015 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
3016 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
3017 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
3018 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
3019 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
3023 echo " m4_if(m4_sysval, [0], [],"
3024 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
3026 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
3027 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
3028 echo " m4_popdef([AC_LIBSOURCES])"
3029 echo " m4_popdef([AC_REPLACE_FUNCS])"
3030 echo " m4_popdef([AC_LIBOBJ])"
3031 echo " AC_CONFIG_COMMANDS_PRE(["
3032 echo " ${macro_prefix_arg}_libobjs="
3033 echo " ${macro_prefix_arg}_ltlibobjs="
3034 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
3035 echo " # Remove the extension."
3036 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
3037 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
3038 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
3039 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
3042 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
3043 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
3047 # func_emit_initmacro_done macro_prefix sourcebase
3048 # emits a few statements after the gl_INIT macro to standard output.
3049 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3050 # - sourcebase directory relative to destdir where to place source code
3051 func_emit_initmacro_done ()
3053 macro_prefix_arg="$1"
3056 echo "# Like AC_LIBOBJ, except that the module name goes"
3057 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3058 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
3059 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
3060 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
3063 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
3064 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
3065 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
3066 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
3067 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
3070 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
3071 echo "# expected is derived from the gnulib-tool parameterization,"
3072 echo "# and alloca is special cased (for the alloca-opt module)."
3073 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
3074 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
3075 echo " m4_foreach([_gl_NAME], [\$1], ["
3076 echo " m4_if(_gl_NAME, [alloca.c], [], ["
3077 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
3078 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
3084 # func_import modules
3085 # Uses also the variables
3086 # - destdir target directory
3087 # - local_gnulib_dir from --local-dir
3088 # - modcache true or false, from --cache-modules/--no-cache-modules
3089 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
3090 # - libname library name
3091 # - sourcebase directory relative to destdir where to place source code
3092 # - m4base directory relative to destdir where to place *.m4 macros
3093 # - pobase directory relative to destdir where to place *.po files
3094 # - docbase directory relative to destdir where to place doc files
3095 # - testsbase directory relative to destdir where to place unit test code
3096 # - auxdir directory relative to destdir where to place build aux files
3097 # - inctests true if --with-tests was given, blank otherwise
3098 # - incobsolete true if --with-obsolete was given, blank otherwise
3099 # - avoidlist list of modules to avoid, from --avoid
3100 # - lgpl yes or a number if library's license shall be LGPL,
3102 # - makefile_name from --makefile-name
3103 # - libtool true if --libtool was given, false if --no-libtool was
3104 # given, blank otherwise
3105 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
3106 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
3107 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
3108 # - vc_files true if --vc-files was given, false if --no-vc-files was
3109 # given, blank otherwise
3110 # - autoconf_minversion minimum supported autoconf version
3111 # - doit : if actions shall be executed, false if only to be printed
3112 # - symbolic true if files should be symlinked, copied otherwise
3113 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
3115 # - do_copyrights true if copyright notices in files should be replaced,
3119 # Get the cached settings.
3120 cached_local_gnulib_dir=
3121 cached_specified_modules=
3132 cached_makefile_name=
3134 cached_macro_prefix=
3138 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3139 cached_libtool=false
3145 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
3155 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
3157 /gl_WITH_OBSOLETE/ {
3158 s,^.*$,cached_incobsolete=true,p
3161 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
3164 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
3167 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
3170 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
3173 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
3176 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
3179 s,^.*$,cached_inctests=true,p
3182 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
3185 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
3188 s,^.*$,cached_lgpl=yes,p
3190 /gl_MAKEFILE_NAME(/ {
3191 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
3194 s,^.*$,cached_libtool=true,p
3196 /gl_MACRO_PREFIX(/ {
3197 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
3200 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
3203 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
3205 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
3206 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3211 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
3212 s,^.*$,cached_files=",p
3225 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
3229 # Merge the cached settings with the specified ones.
3230 # The m4base must be the same as expected from the pathname.
3231 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
3232 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
3234 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
3235 # is relative to $destdir, whereas the one we use is relative to . or absolute.
3236 if test -z "$local_gnulib_dir"; then
3237 if test -n "$cached_local_gnulib_dir"; then
3240 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3242 case "$cached_local_gnulib_dir" in
3244 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
3246 func_relconcat "$destdir" "$cached_local_gnulib_dir"
3247 local_gnulib_dir="$relconcat" ;;
3252 # Append the cached and the specified module names. So that
3253 # "gnulib-tool --import foo" means to add the module foo.
3254 specified_modules="$cached_specified_modules $1"
3255 # Included obsolete modules among the dependencies if specified either way.
3256 if test -z "$incobsolete"; then
3257 incobsolete="$cached_incobsolete"
3259 # Append the cached and the specified avoidlist. This is probably better
3260 # than dropping the cached one when --avoid is specified at least once.
3261 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
3262 avoidlist=`echo $avoidlist`
3264 # The sourcebase defaults to the cached one.
3265 if test -z "$sourcebase"; then
3266 sourcebase="$cached_sourcebase"
3267 if test -z "$sourcebase"; then
3268 func_fatal_error "missing --source-base option"
3271 # The pobase defaults to the cached one.
3272 if test -z "$pobase"; then
3273 pobase="$cached_pobase"
3275 # The docbase defaults to the cached one.
3276 if test -z "$docbase"; then
3277 docbase="$cached_docbase"
3278 if test -z "$docbase"; then
3279 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."
3282 # The testsbase defaults to the cached one.
3283 if test -z "$testsbase"; then
3284 testsbase="$cached_testsbase"
3285 if test -z "$testsbase"; then
3286 func_fatal_error "missing --tests-base option"
3289 # Require the tests if specified either way.
3290 if test -z "$inctests"; then
3291 inctests="$cached_inctests"
3293 # The libname defaults to the cached one.
3294 if test -z "$supplied_libname"; then
3295 libname="$cached_libname"
3296 if test -z "$libname"; then
3297 func_fatal_error "missing --lib option"
3300 # Require LGPL if specified either way.
3301 if test -z "$lgpl"; then
3304 # The makefile_name defaults to the cached one.
3305 if test -z "$makefile_name"; then
3306 makefile_name="$cached_makefile_name"
3308 # Use libtool if specified either way, or if guessed.
3309 if test -z "$libtool"; then
3310 if test -n "$cached_m4base"; then
3311 libtool="$cached_libtool"
3313 libtool="$guessed_libtool"
3316 # The macro_prefix defaults to the cached one.
3317 if test -z "$macro_prefix"; then
3318 macro_prefix="$cached_macro_prefix"
3319 if test -z "$macro_prefix"; then
3320 func_fatal_error "missing --macro-prefix option"
3323 # The po_domain defaults to the cached one.
3324 if test -z "$po_domain"; then
3325 po_domain="$cached_po_domain"
3327 # The vc_files defaults to the cached one.
3328 if test -z "$vc_files"; then
3329 vc_files="$cached_vc_files"
3332 # Canonicalize the list of specified modules.
3333 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
3335 # Determine final module list.
3336 modules="$specified_modules"
3337 func_modules_transitive_closure
3338 if test $verbose -ge 0; then
3339 echo "Module list with included dependencies:"
3340 echo "$modules" | sed -e 's/^/ /'
3342 final_modules="$modules"
3344 # Determine main module list and tests-related module list separately.
3345 # The main module list is the transitive closure of the specified modules,
3346 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
3347 # is specified, it will consist only of LGPLed source.
3348 # The tests-related module list is the transitive closure of the specified
3349 # modules, including tests modules, minus the main module list excluding
3350 # modules of applicability 'all'. Its lib/* sources (brought in through
3351 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3352 # source, even if --lgpl is specified.
3353 # Determine main module list.
3354 saved_inctests="$inctests"
3356 modules="$specified_modules"
3357 func_modules_transitive_closure
3358 main_modules="$modules"
3359 inctests="$saved_inctests"
3360 if test $verbose -ge 1; then
3361 echo "Main module list:"
3362 echo "$main_modules" | sed -e 's/^/ /'
3364 # Determine tests-related module list.
3365 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3366 testsrelated_modules=`for module in $main_modules; do
3367 if test \`func_get_applicability $module\` = main; then
3371 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3372 if test $verbose -ge 1; then
3373 echo "Tests-related module list:"
3374 echo "$testsrelated_modules" | sed -e 's/^/ /'
3377 # Add the dummy module to the main module list if needed.
3378 modules="$main_modules"
3379 func_modules_add_dummy
3380 main_modules="$modules"
3382 # Determine whether a $testsbase/libtests.a is needed.
3384 for module in $testsrelated_modules; do
3385 func_verify_nontests_module
3386 if test -n "$module"; then
3387 all_files=`func_get_filelist $module`
3388 # Test whether some file in $all_files lies in lib/.
3389 for f in $all_files; do
3400 # Add the dummy module to the tests-related module list if needed.
3401 if $use_libtests; then
3402 modules="$testsrelated_modules"
3403 func_modules_add_dummy
3404 testsrelated_modules="$modules"
3407 # If --lgpl, verify that the licenses of modules are compatible.
3408 if test -n "$lgpl"; then
3409 license_incompatibilities=
3410 for module in $main_modules; do
3411 license=`func_get_license $module`
3413 'GPLed build tool') ;;
3414 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3419 LGPL | LGPLv2+ | LGPLv3+) ;;
3420 *) func_append license_incompatibilities "$module $license$nl" ;;
3426 *) func_append license_incompatibilities "$module $license$nl" ;;
3429 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3434 if test -n "$license_incompatibilities"; then
3435 # Format the license incompatibilities as a table.
3436 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
3437 s,^\(.................................................[^ ]*\) *, \1 ,'
3438 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
3439 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
3443 # Show banner notice of every module.
3444 modules="$main_modules"
3447 # Determine script to apply to imported library files.
3448 sed_transform_lib_file=
3449 for module in $main_modules; do
3450 if test $module = config-h; then
3451 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
3452 sed_transform_lib_file=$sed_transform_lib_file'
3453 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
3458 sed_transform_main_lib_file="$sed_transform_lib_file"
3459 if test -n "$do_copyrights"; then
3460 if test -n "$lgpl"; then
3464 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3465 s/GNU General/GNU Lesser General/g
3469 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3470 s/GNU General/GNU Lesser General/g
3471 s/version [23]\([ ,]\)/version 2.1\1/g
3474 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3478 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3479 s/GNU Lesser General/GNU General/g
3480 s/GNU Library General/GNU General/g
3481 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3486 # Determine script to apply to auxiliary files that go into $auxdir/.
3487 sed_transform_build_aux_file=
3488 if test -n "$do_copyrights"; then
3490 sed_transform_build_aux_file=$sed_transform_build_aux_file'
3491 s/GNU Lesser General/GNU General/g
3492 s/GNU Library General/GNU General/g
3493 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3497 # Determine script to apply to library files that go into $testsbase/.
3498 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
3499 if test -n "$do_copyrights"; then
3501 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
3502 s/GNU Lesser General/GNU General/g
3503 s/GNU Library General/GNU General/g
3504 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3508 # Determine the final file lists.
3509 # They must be computed separately, because files in lib/* go into
3510 # $sourcebase/ if they are in the main file list but into $testsbase/
3511 # if they are in the tests-related file list. Furthermore lib/dummy.c
3513 # Determine final main file list.
3514 modules="$main_modules"
3515 func_modules_to_filelist
3517 # Determine final tests-related file list.
3518 modules="$testsrelated_modules"
3519 func_modules_to_filelist
3520 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3521 # Merge both file lists.
3522 sed_remove_empty_lines='/^$/d'
3523 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3524 if test $verbose -ge 0; then
3526 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3527 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3531 || func_fatal_error "refusing to do nothing"
3533 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
3534 new_files="$files m4/gnulib-tool.m4"
3535 old_files="$cached_files"
3536 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
3537 func_append old_files " m4/gnulib-tool.m4"
3540 rewritten='%REWRITTEN%'
3541 sed_rewrite_old_files="\
3542 s,^build-aux/,$rewritten$auxdir/,
3543 s,^doc/,$rewritten$cached_docbase/,
3544 s,^lib/,$rewritten$cached_sourcebase/,
3545 s,^m4/,$rewritten$cached_m4base/,
3546 s,^tests/,$rewritten$cached_testsbase/,
3547 s,^tests=lib/,$rewritten$cached_testsbase/,
3550 sed_rewrite_new_files="\
3551 s,^build-aux/,$rewritten$auxdir/,
3552 s,^doc/,$rewritten$docbase/,
3553 s,^lib/,$rewritten$sourcebase/,
3554 s,^m4/,$rewritten$m4base/,
3555 s,^tests/,$rewritten$testsbase/,
3556 s,^tests=lib/,$rewritten$testsbase/,
3560 # Create directories.
3561 { echo "$sourcebase"
3563 if test -n "$pobase"; then
3566 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
3567 if test -n "$docfiles"; then
3570 if test -n "$inctests"; then
3574 for f in $files; do echo $f; done \
3575 | sed -e "$sed_rewrite_new_files" \
3576 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3579 { # Rearrange file descriptors. Needed because "while ... done < ..."
3580 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3581 exec 5<&0 < "$tmp"/dirs
3583 if test ! -d "$destdir/$d"; then
3585 echo "Creating directory $destdir/$d"
3586 mkdir -p "$destdir/$d" || func_fatal_error "failed"
3588 echo "Create directory $destdir/$d"
3595 # Copy files or make symbolic links. Remove obsolete files.
3599 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3600 # representing the files according to the last gnulib-tool invocation.
3601 for f in $old_files; do echo $f; done \
3602 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
3605 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3606 # representing the files after this gnulib-tool invocation.
3607 for f in $new_files; do echo $f; done \
3608 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
3611 # First the files that are in old-files, but not in new-files:
3612 sed_take_first_column='s,'"$delimiter"'.*,,'
3613 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
3614 # Remove the file. Do nothing if the user already removed it.
3615 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
3617 echo "Removing file $g (backup in ${g}~)"
3618 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3620 echo "Remove file $g (backup in ${g}~)"
3622 func_append removed_files "$g$nl"
3625 # func_add_or_update handles a file that ought to be present afterwards.
3627 # - f the original file name
3628 # - g the rewritten file name
3629 # - already_present nonempty if the file should already exist, empty
3631 func_add_or_update ()
3635 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
3637 func_dest_tmpfilename "$g"
3638 func_lookup_file "$f"
3639 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
3640 if test -n "$sed_transform_main_lib_file"; then
3643 sed -e "$sed_transform_main_lib_file" \
3644 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3648 if test -n "$sed_transform_build_aux_file"; then
3651 sed -e "$sed_transform_build_aux_file" \
3652 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3656 if test -n "$sed_transform_testsrelated_lib_file"; then
3659 sed -e "$sed_transform_testsrelated_lib_file" \
3660 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3664 if test -f "$destdir/$g"; then
3665 # The file already exists.
3669 # Don't protest if the file should be there but isn't: it happens
3670 # frequently that developers don't put autogenerated files into CVS.
3672 func_append added_files "$g$nl"
3676 # Then the files that are in new-files, but not in old-files:
3677 sed_take_last_column='s,^.*'"$delimiter"',,'
3679 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
3680 | sed -e "$sed_take_last_column" \
3681 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
3682 { # Rearrange file descriptors. Needed because "while ... done < ..."
3683 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3684 exec 5<&0 < "$tmp"/added-files
3690 # Then the files that are in new-files and in old-files:
3691 already_present=true
3692 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
3693 | sed -e "$sed_take_last_column" \
3694 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
3695 { # Rearrange file descriptors. Needed because "while ... done < ..."
3696 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3697 exec 5<&0 < "$tmp"/kept-files
3704 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
3705 actioncmd="gnulib-tool --import"
3706 func_append actioncmd " --dir=$destdir"
3707 if test -n "$local_gnulib_dir"; then
3708 func_append actioncmd " --local-dir=$local_gnulib_dir"
3710 func_append actioncmd " --lib=$libname"
3711 func_append actioncmd " --source-base=$sourcebase"
3712 func_append actioncmd " --m4-base=$m4base"
3713 if test -n "$pobase"; then
3714 func_append actioncmd " --po-base=$pobase"
3716 func_append actioncmd " --doc-base=$docbase"
3717 func_append actioncmd " --tests-base=$testsbase"
3718 func_append actioncmd " --aux-dir=$auxdir"
3719 if test -n "$inctests"; then
3720 func_append actioncmd " --with-tests"
3722 if test -n "$incobsolete"; then
3723 func_append actioncmd " --with-obsolete"
3725 for module in $avoidlist; do
3726 func_append actioncmd " --avoid=$module"
3728 if test -n "$lgpl"; then
3729 if test "$lgpl" = yes; then
3730 func_append actioncmd " --lgpl"
3732 func_append actioncmd " --lgpl=$lgpl"
3735 if test -n "$makefile_name"; then
3736 func_append actioncmd " --makefile-name=$makefile_name"
3738 if test "$libtool" = true; then
3739 func_append actioncmd " --libtool"
3741 func_append actioncmd " --no-libtool"
3743 func_append actioncmd " --macro-prefix=$macro_prefix"
3744 if test -n "$po_domain"; then
3745 func_append actioncmd " --po-domain=$po_domain"
3747 if test -n "$vc_files"; then
3748 if test "$vc_files" = true; then
3749 func_append actioncmd " --vc-files"
3751 func_append actioncmd " --no-vc-files"
3754 func_append actioncmd " `echo $specified_modules`"
3756 # Default the makefile name to Makefile.am.
3757 if test -n "$makefile_name"; then
3758 makefile_am=$makefile_name
3760 makefile_am=Makefile.am
3763 # Create normal Makefile.ams.
3766 # Setup list of Makefile.am edits that are to be performed afterwards.
3767 # Some of these edits apply to files that we will generate; others are
3768 # under the responsibility of the developer.
3770 # func_note_Makefile_am_edit dir var value
3771 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
3773 func_note_Makefile_am_edit ()
3775 makefile_am_edits=`expr $makefile_am_edits + 1`
3776 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
3777 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
3778 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
3780 if test "$makefile_am" = Makefile.am; then
3781 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3782 sourcebase_base=`basename "$sourcebase"`
3783 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
3785 if test -n "$pobase"; then
3786 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3787 pobase_base=`basename "$pobase"`
3788 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
3790 if test -n "$inctests"; then
3791 if test "$makefile_am" = Makefile.am; then
3792 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3793 testsbase_base=`basename "$testsbase"`
3794 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
3797 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
3799 # Find the first parent directory of $m4base that contains or will contain
3801 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
3803 sed_butlast='s,[^/][^/]*//*$,,'
3804 dir1="${m4base}/"; dir2=""
3805 while test -n "$dir1" \
3806 && ! { test -f "${destdir}/${dir1}Makefile.am" \
3807 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3808 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3809 || { test -n "$inctests" \
3810 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
3811 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
3812 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
3813 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
3815 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
3818 # Create library makefile.
3819 func_dest_tmpfilename $sourcebase/$makefile_am
3820 destfile="$sourcebase/$makefile_am"
3821 modules="$main_modules"
3822 func_emit_lib_Makefile_am > "$tmpfile"
3823 if test -f "$destdir"/$sourcebase/$makefile_am; then
3824 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
3828 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3829 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
3830 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3832 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3838 echo "Creating $sourcebase/$makefile_am"
3839 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3841 echo "Create $sourcebase/$makefile_am"
3844 func_append added_files "$sourcebase/$makefile_am$nl"
3847 # Create po/ directory.
3848 if test -n "$pobase"; then
3849 # Create po makefile and auxiliary files.
3850 for file in Makefile.in.in remove-potcdate.sin; do
3851 func_dest_tmpfilename $pobase/$file
3852 func_lookup_file build-aux/po/$file
3853 cat "$lookedup_file" > "$tmpfile"
3854 if test -f "$destdir"/$pobase/$file; then
3855 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
3859 echo "Updating $pobase/$file (backup in $pobase/$file~)"
3860 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
3861 mv -f "$tmpfile" "$destdir"/$pobase/$file
3863 echo "Update $pobase/$file (backup in $pobase/$file~)"
3869 echo "Creating $pobase/$file"
3870 mv -f "$tmpfile" "$destdir"/$pobase/$file
3872 echo "Create $pobase/$file"
3875 func_append added_files "$pobase/$file$nl"
3878 # Create po makefile parameterization, part 1.
3879 func_dest_tmpfilename $pobase/Makevars
3880 func_emit_po_Makevars > "$tmpfile"
3881 if test -f "$destdir"/$pobase/Makevars; then
3882 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
3886 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
3887 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
3888 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3890 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
3896 echo "Creating $pobase/Makevars"
3897 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3899 echo "Create $pobase/Makevars"
3902 func_append added_files "$pobase/Makevars$nl"
3904 # Create po makefile parameterization, part 2.
3905 func_dest_tmpfilename $pobase/POTFILES.in
3906 func_emit_po_POTFILES_in > "$tmpfile"
3907 if test -f "$destdir"/$pobase/POTFILES.in; then
3908 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
3912 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3913 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
3914 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3916 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3922 echo "Creating $pobase/POTFILES.in"
3923 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3925 echo "Create $pobase/POTFILES.in"
3928 func_append added_files "$pobase/POTFILES.in$nl"
3931 TP_URL="http://translationproject.org/latest/"
3932 TP_RSYNC_URI="translationproject.org::tp/latest/"
3934 echo "Fetching gnulib PO files from $TP_URL"
3935 (cd "$destdir"/$pobase \
3936 && { # Prefer rsync over wget if it is available, since it consumes
3937 # less network bandwidth, due to compression.
3938 if type rsync 2>/dev/null | grep / > /dev/null; then
3939 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
3941 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
3946 echo "Fetch gnulib PO files from $TP_URL"
3948 # Create po/LINGUAS.
3950 func_dest_tmpfilename $pobase/LINGUAS
3951 (cd "$destdir"/$pobase \
3952 && { echo '# Set of available languages.'
3953 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
3956 if test -f "$destdir"/$pobase/LINGUAS; then
3957 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
3960 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3961 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
3962 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3965 echo "Creating $pobase/LINGUAS"
3966 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3967 func_append added_files "$pobase/LINGUAS$nl"
3970 if test -f "$destdir"/$pobase/LINGUAS; then
3971 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3973 echo "Create $pobase/LINGUAS"
3978 # Create m4/gnulib-cache.m4.
3979 func_dest_tmpfilename $m4base/gnulib-cache.m4
3981 func_emit_copyright_notice
3983 echo "# This file represents the specification of how gnulib-tool is used."
3984 echo "# It acts as a cache: It is written and read by gnulib-tool."
3985 echo "# In projects using CVS, this file is meant to be stored in CVS,"
3986 echo "# like the configure.ac and various Makefile.am files."
3989 echo "# Specification in the form of a command-line invocation:"
3992 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
3993 # Store the local_gnulib_dir relative to destdir.
3994 case "$local_gnulib_dir" in
3996 relative_local_gnulib_dir="$local_gnulib_dir" ;;
3999 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
4001 # destdir, local_gnulib_dir are both relative.
4002 func_relativize "$destdir" "$local_gnulib_dir"
4003 relative_local_gnulib_dir="$reldir" ;;
4006 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
4008 echo "$specified_modules" | sed -e 's/^/ /g'
4010 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
4011 echo "gl_AVOID([$avoidlist])"
4012 echo "gl_SOURCE_BASE([$sourcebase])"
4013 echo "gl_M4_BASE([$m4base])"
4014 echo "gl_PO_BASE([$pobase])"
4015 echo "gl_DOC_BASE([$docbase])"
4016 echo "gl_TESTS_BASE([$testsbase])"
4017 test -z "$inctests" || echo "gl_WITH_TESTS"
4018 echo "gl_LIB([$libname])"
4019 if test -n "$lgpl"; then
4020 if test "$lgpl" = yes; then
4023 echo "gl_LGPL([$lgpl])"
4026 echo "gl_MAKEFILE_NAME([$makefile_name])"
4027 if test "$libtool" = true; then
4030 echo "gl_MACRO_PREFIX([$macro_prefix])"
4031 echo "gl_PO_DOMAIN([$po_domain])"
4032 if test -n "$vc_files"; then
4033 echo "gl_VC_FILES([$vc_files])"
4036 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
4037 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
4041 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4042 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
4043 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4045 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
4049 echo "# gnulib-cache.m4 ends here"
4056 echo "Creating $m4base/gnulib-cache.m4"
4057 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
4059 echo "Create $m4base/gnulib-cache.m4"
4065 # Create m4/gnulib-comp.m4.
4066 func_dest_tmpfilename $m4base/gnulib-comp.m4
4068 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
4069 func_emit_copyright_notice
4071 echo "# This file represents the compiled summary of the specification in"
4072 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
4073 echo "# to be invoked from configure.ac."
4074 echo "# In projects using CVS, this file can be treated like other built files."
4077 echo "# This macro should be invoked from $configure_ac, in the section"
4078 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
4079 echo "# any checks for libraries, header files, types and library functions."
4080 echo "AC_DEFUN([${macro_prefix}_EARLY],"
4082 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4083 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4084 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4085 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4086 echo " AC_REQUIRE([AC_PROG_RANLIB])"
4087 if test -n "$uses_subdirs"; then
4088 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
4090 for module in $final_modules; do
4092 if test -n "$module"; then
4093 echo "# Code from module $module:"
4094 func_get_autoconf_early_snippet "$module"
4097 | sed -e '/^$/d;' -e 's/^/ /'
4100 echo "# This macro should be invoked from $configure_ac, in the section"
4101 echo "# \"Check for header files, types and library functions\"."
4102 echo "AC_DEFUN([${macro_prefix}_INIT],"
4104 if test "$libtool" = true; then
4105 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4106 echo " gl_cond_libtool=true"
4108 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4109 echo " gl_cond_libtool=false"
4111 echo " gl_ltlibdeps="
4113 if test "$auxdir" != "build-aux"; then
4114 sed_replace_build_aux='
4116 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4117 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4121 sed_replace_build_aux="$sed_noop"
4123 func_emit_initmacro_start $macro_prefix
4124 echo " gl_source_base='$sourcebase'"
4125 for module in $main_modules; do
4127 if test -n "$module"; then
4128 echo " # Code from module $module:"
4129 func_get_autoconf_snippet "$module" \
4130 | sed -e '/^$/d;' -e 's/^/ /' \
4131 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4132 -e "$sed_replace_build_aux"
4133 if test "$module" = 'alloca' && test "$libtool" = true; then
4134 echo 'changequote(,)dnl'
4135 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
4136 echo 'changequote([, ])dnl'
4137 echo 'AC_SUBST([LTALLOCA])'
4141 echo " # End of code from modules"
4142 func_emit_initmacro_end $macro_prefix
4143 echo " gltests_libdeps="
4144 echo " gltests_ltlibdeps="
4145 func_emit_initmacro_start ${macro_prefix}tests
4146 echo " gl_source_base='$testsbase'"
4147 # Define a tests witness macro that depends on the package.
4148 # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
4149 # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
4150 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"
4151 echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
4152 echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
4153 echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
4154 for module in $testsrelated_modules; do
4156 if test -n "$module"; then
4157 func_get_autoconf_snippet "$module" \
4158 | sed -e '/^$/d;' -e 's/^/ /' \
4159 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
4160 -e "$sed_replace_build_aux" \
4161 -e 's/\$gl_cond_libtool/false/g' \
4162 -e 's/gl_libdeps/gltests_libdeps/g' \
4163 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
4166 echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
4167 func_emit_initmacro_end ${macro_prefix}tests
4168 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4169 # created using libtool, because libtool already handles the dependencies.
4170 if test "$libtool" != true; then
4171 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4172 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4173 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4174 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4175 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4177 if $use_libtests; then
4178 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
4179 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
4182 func_emit_initmacro_done $macro_prefix $sourcebase
4183 func_emit_initmacro_done ${macro_prefix}tests $testsbase
4185 echo "# This macro records the list of files which have been installed by"
4186 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
4187 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
4188 echo "$files" | sed -e 's,^, ,'
4191 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
4192 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
4196 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4197 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
4198 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4200 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
4204 echo "# gnulib-comp.m4 ends here"
4211 echo "Creating $m4base/gnulib-comp.m4"
4212 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
4214 echo "Create $m4base/gnulib-comp.m4"
4220 if test -n "$inctests"; then
4221 # Create tests makefile.
4222 func_dest_tmpfilename $testsbase/$makefile_am
4223 destfile="$testsbase/$makefile_am"
4224 modules="$testsrelated_modules"
4225 func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
4226 if test -f "$destdir"/$testsbase/$makefile_am; then
4227 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
4231 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4232 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
4233 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4235 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
4241 echo "Creating $testsbase/$makefile_am"
4242 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
4244 echo "Create $testsbase/$makefile_am"
4247 func_append added_files "$testsbase/$makefile_am$nl"
4251 if test "$vc_files" != false; then
4252 # Update the .cvsignore and .gitignore files.
4253 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
4254 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
4255 # Treat gnulib-comp.m4 like an added file, even if it already existed.
4256 echo "$m4base/|A|gnulib-comp.m4"
4257 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
4258 { # Rearrange file descriptors. Needed because "while ... done < ..."
4259 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4260 exec 5<&0 < "$tmp"/fileset-changes
4261 func_update_ignorelist ()
4264 if test "$ignore" = .gitignore; then
4265 # In a .gitignore file, "foo" applies to the current directory and all
4266 # subdirectories, whereas "/foo" applies to the current directory only.
4269 doubly_escaped_anchor='\\/'
4273 doubly_escaped_anchor=''
4275 if test -f "$destdir/$dir$ignore"; then
4276 if test -n "$dir_added" || test -n "$dir_removed"; then
4277 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
4278 (echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
4279 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
4280 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
4281 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
4283 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
4285 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4286 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
4287 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
4288 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
4289 } > "$tmp"/sed-ignore-removed
4290 { cat "$destdir/$dir$ignore"~
4291 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
4292 } | sed -f "$tmp"/sed-ignore-removed \
4293 > "$destdir/$dir$ignore"
4295 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
4300 if test -n "$dir_added"; then
4302 echo "Creating $destdir/$dir$ignore"
4304 if test "$ignore" = .cvsignore; then
4306 # Automake generates Makefile rules that create .dirstamp files.
4309 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
4310 } > "$destdir/$dir$ignore"
4312 echo "Create $destdir/$dir$ignore"
4322 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
4323 func_update_ignorelist .cvsignore
4325 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
4326 func_update_ignorelist .gitignore
4333 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
4334 next_dir=`echo "$line" | sed -e 's,|.*,,'`
4335 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
4336 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
4337 if test "$next_dir" != "$last_dir"; then
4338 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4339 last_dir="$next_dir"
4344 A) func_append last_dir_added "$file$nl";;
4345 R) func_append last_dir_removed "$file$nl";;
4348 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
4355 echo "You may need to add #include directives for the following .h files."
4356 # Intersect $specified_modules and $main_modules
4357 # (since $specified_modules is not necessarily of subset of $main_modules
4358 # - some may have been skipped through --avoid, and since the elements of
4359 # $main_modules but not in $specified_modules can go away without explicit
4360 # notice - through changes in the module dependencies).
4361 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
4362 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
4363 # First the #include <...> directives without #ifs, sorted for convenience,
4364 # then the #include "..." directives without #ifs, sorted for convenience,
4365 # then the #include directives that are surrounded by #ifs. Not sorted.
4366 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
4367 include_directive=`func_get_include_directive "$module"`
4368 case "$nl$include_directive" in
4370 echo "$include_directive" 1>&5
4373 echo "$include_directive" | grep -v 'include "' 1>&6
4374 echo "$include_directive" | grep 'include "' 1>&7
4377 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
4379 LC_ALL=C sort -u "$tmp"/include-angles
4380 LC_ALL=C sort -u "$tmp"/include-quotes
4381 cat "$tmp"/include-if
4382 ) | sed -e '/^$/d' -e 's/^/ /'
4383 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
4385 for module in $main_modules; do
4386 func_get_link_directive "$module"
4388 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
4389 if test `wc -l < "$tmp"/link` != 0; then
4391 echo "You may need to use the following Makefile variables when linking."
4392 echo "Use them in <program>_LDADD when linking a program, or"
4393 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
4399 echo "Don't forget to"
4400 if test "$makefile_am" = Makefile.am; then
4401 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4403 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
4405 if test -n "$pobase"; then
4406 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
4408 if test -n "$inctests"; then
4409 if test "$makefile_am" = Makefile.am; then
4410 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4412 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
4416 while test $edit != $makefile_am_edits; do
4417 edit=`expr $edit + 1`
4418 eval dir=\"\$makefile_am_edit${edit}_dir\"
4419 eval var=\"\$makefile_am_edit${edit}_var\"
4420 eval val=\"\$makefile_am_edit${edit}_val\"
4421 if test -n "$var"; then
4422 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
4425 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
4426 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
4429 # func_create_testdir testdir modules
4431 # - local_gnulib_dir from --local-dir
4432 # - modcache true or false, from --cache-modules/--no-cache-modules
4433 # - auxdir directory relative to destdir where to place build aux files
4434 # - inctests true if tests should be included, blank otherwise
4435 # - incobsolete true if obsolete modules among dependencies should be
4436 # included, blank otherwise
4437 # - avoidlist list of modules to avoid
4438 # - libtool true if --libtool was given, false if --no-libtool was
4439 # given, blank otherwise
4440 # - symbolic true if files should be symlinked, copied otherwise
4441 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
4443 func_create_testdir ()
4447 if test -z "$modules"; then
4448 # All modules together.
4449 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4450 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
4451 # Except lib-ignore, which leads to link errors when Sun C++ is used. FIXME.
4452 modules=`func_all_modules`
4453 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist | lib-ignore) ;; *) echo $m;; esac; done`
4455 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
4457 # Check that the license of every module is consistent with the license of
4459 saved_modules="$modules"
4460 saved_inctests="$inctests"
4461 # When computing transitive closures, don't consider $module to depend on
4462 # $module-tests. Need this becauses tests are implicitly GPL and may depend
4463 # on GPL modules - therefore we don't want a warning in this case.
4465 for requested_module in $saved_modules; do
4466 requested_license=`func_get_license "$requested_module"`
4467 if test "$requested_license" != GPL; then
4468 # Here we use func_modules_transitive_closure, not just
4469 # func_get_dependencies, so that we also detect weird situations like
4470 # an LGPL module which depends on a GPLed build tool module which depends
4472 modules="$requested_module"
4473 func_modules_transitive_closure
4474 for module in $modules; do
4475 license=`func_get_license "$module"`
4477 'GPLed build tool') ;;
4478 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4480 case "$requested_license" in
4483 GPLv2+ | LGPLv2+) ;;
4484 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4490 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4496 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4505 modules="$saved_modules"
4506 inctests="$saved_inctests"
4508 # Subdirectory names.
4518 # Determine final module list.
4519 func_modules_transitive_closure
4520 if test $verbose -ge 0; then
4521 echo "Module list with included dependencies:"
4522 echo "$modules" | sed -e 's/^/ /'
4525 # Add the dummy module if needed.
4526 func_modules_add_dummy
4528 # Show banner notice of every module.
4531 # Determine final file list.
4532 func_modules_to_filelist
4533 if test $verbose -ge 0; then
4535 echo "$files" | sed -e 's/^/ /'
4538 rewritten='%REWRITTEN%'
4539 sed_rewrite_files="\
4540 s,^build-aux/,$rewritten$auxdir/,
4541 s,^doc/,$rewritten$docbase/,
4542 s,^lib/,$rewritten$sourcebase/,
4543 s,^m4/,$rewritten$m4base/,
4544 s,^tests/,$rewritten$testsbase/,
4548 # Create directories.
4549 for f in $files; do echo $f; done \
4550 | sed -e "$sed_rewrite_files" \
4551 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4552 | LC_ALL=C sort -u \
4554 { # Rearrange file descriptors. Needed because "while ... done < ..."
4555 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4556 exec 5<&0 < "$tmp"/dirs
4558 mkdir -p "$testdir/$d"
4563 # Copy files or make symbolic links.
4565 for f in $files; do echo $f; done \
4566 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
4569 { # Rearrange file descriptors. Needed because "while ... done < ..."
4570 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4571 exec 5<&0 < "$tmp"/files
4573 func_lookup_file "$f"
4574 if test -n "$lookedup_tmp"; then
4575 cp -p "$lookedup_file" "$testdir/$g"
4577 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
4578 if { test -n "$symbolic" \
4579 || { test -n "$lsymbolic" \
4580 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
4581 func_ln "$lookedup_file" "$testdir/$g"
4583 cp -p "$lookedup_file" "$testdir/$g"
4590 # Create Makefile.ams that are for testing.
4593 # No special edits are needed.
4596 # Create $sourcebase/Makefile.am.
4597 mkdir -p "$testdir/$sourcebase"
4598 destfile="$sourcebase/Makefile.am"
4599 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
4600 any_uses_subdirs="$uses_subdirs"
4602 # Create $m4base/Makefile.am.
4603 mkdir -p "$testdir/$m4base"
4604 (echo "## Process this file with automake to produce Makefile.in."
4610 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
4613 ) > "$testdir/$m4base/Makefile.am"
4615 subdirs="$sourcebase $m4base"
4616 subdirs_with_configure_ac=""
4618 if false && test -f "$testdir"/$m4base/gettext.m4; then
4619 # Avoid stupid error message from automake:
4620 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
4621 mkdir -p "$testdir/po"
4622 (echo "## Process this file with automake to produce Makefile.in."
4623 ) > "$testdir/po/Makefile.am"
4624 func_append subdirs " po"
4627 if test -n "$inctests"; then
4628 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
4629 # Viewed from the $testsbase subdirectory, $auxdir is different.
4630 saved_auxdir="$auxdir"
4631 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
4632 # Create $testsbase/Makefile.am.
4634 destfile="$testsbase/Makefile.am"
4635 func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
4636 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
4637 # Create $testsbase/configure.ac.
4638 (echo "# Process this file with autoconf to produce a configure script."
4639 echo "AC_INIT([dummy], [0])"
4640 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4641 echo "AM_INIT_AUTOMAKE"
4643 echo "AC_CONFIG_HEADERS([config.h])"
4646 echo "AC_PROG_INSTALL"
4647 echo "AC_PROG_MAKE_SET"
4648 echo "AC_PROG_RANLIB"
4650 if test -n "$uses_subdirs"; then
4651 echo "AM_PROG_CC_C_O"
4654 for module in $modules; do
4656 if test -n "$module"; then
4658 gnumakefile | maintainer-makefile)
4659 # These modules are meant to be used only in the top-level directory.
4662 func_get_autoconf_early_snippet "$module"
4667 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4668 if test "$libtool" = true; then
4669 echo "LT_INIT([win32-dll])"
4670 echo "LT_LANG([C++])"
4671 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4672 echo "gl_cond_libtool=true"
4674 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4675 echo "gl_cond_libtool=false"
4677 echo "gl_ltlibdeps="
4679 # Wrap the set of autoconf snippets into an autoconf macro that is then
4680 # invoked. This is needed because autoconf does not support AC_REQUIRE
4682 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4683 # but we want the AC_REQUIRE to have its normal meaning (provide one
4684 # expansion of the required macro before the current point, and only one
4686 echo "AC_DEFUN([gl_INIT], ["
4687 sed_replace_build_aux='
4689 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4690 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4693 func_emit_initmacro_start $macro_prefix
4694 # We don't have explicit ordering constraints between the various
4695 # autoconf snippets. It's cleanest to put those of the library before
4696 # those of the tests.
4697 echo "gl_source_base='../$sourcebase'"
4698 for module in $modules; do
4699 func_verify_nontests_module
4700 if test -n "$module"; then
4702 gnumakefile | maintainer-makefile)
4703 # These modules are meant to be used only in the top-level directory.
4706 func_get_autoconf_snippet "$module" \
4707 | sed -e "$sed_replace_build_aux"
4712 echo "gl_source_base='.'"
4713 for module in $modules; do
4714 func_verify_tests_module
4715 if test -n "$module"; then
4716 func_get_autoconf_snippet "$module" \
4717 | sed -e "$sed_replace_build_aux"
4720 func_emit_initmacro_end $macro_prefix
4721 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4722 # created using libtool, because libtool already handles the dependencies.
4723 if test "$libtool" != true; then
4724 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4725 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4726 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4727 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4728 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4731 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
4735 # Usually $testsbase/config.h will be a superset of config.h. Verify this
4736 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
4737 echo "AH_TOP([#include \"../config.h\"])"
4739 echo "AC_CONFIG_FILES([Makefile])"
4741 ) > "$testdir/$testsbase/configure.ac"
4742 auxdir="$saved_auxdir"
4743 func_append subdirs " $testsbase"
4744 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
4747 # Create Makefile.am.
4748 (echo "## Process this file with automake to produce Makefile.in."
4750 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4752 echo "SUBDIRS = $subdirs"
4754 echo "ACLOCAL_AMFLAGS = -I $m4base"
4755 ) > "$testdir/Makefile.am"
4757 # Create configure.ac.
4758 (echo "# Process this file with autoconf to produce a configure script."
4759 echo "AC_INIT([dummy], [0])"
4760 if test "$auxdir" != "."; then
4761 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4763 echo "AM_INIT_AUTOMAKE"
4765 echo "AC_CONFIG_HEADERS([config.h])"
4768 echo "AC_PROG_INSTALL"
4769 echo "AC_PROG_MAKE_SET"
4771 echo "# For autobuild."
4772 echo "AC_CANONICAL_BUILD"
4773 echo "AC_CANONICAL_HOST"
4775 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4776 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4777 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4778 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4780 echo "AC_PROG_RANLIB"
4782 if test -n "$any_uses_subdirs"; then
4783 echo "AM_PROG_CC_C_O"
4786 for module in $modules; do
4787 func_verify_nontests_module
4788 if test -n "$module"; then
4789 func_get_autoconf_early_snippet "$module"
4792 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4793 if test "$libtool" = true; then
4794 echo "LT_INIT([win32-dll])"
4795 echo "LT_LANG([C++])"
4796 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4797 echo "gl_cond_libtool=true"
4799 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4800 echo "gl_cond_libtool=false"
4802 echo "gl_ltlibdeps="
4804 # Wrap the set of autoconf snippets into an autoconf macro that is then
4805 # invoked. This is needed because autoconf does not support AC_REQUIRE
4807 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4808 # but we want the AC_REQUIRE to have its normal meaning (provide one
4809 # expansion of the required macro before the current point, and only one
4811 echo "AC_DEFUN([gl_INIT], ["
4812 if test "$auxdir" != "build-aux"; then
4813 sed_replace_build_aux='
4815 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4816 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4820 sed_replace_build_aux="$sed_noop"
4822 func_emit_initmacro_start $macro_prefix
4823 echo "gl_source_base='$sourcebase'"
4824 for module in $modules; do
4825 func_verify_nontests_module
4826 if test -n "$module"; then
4827 func_get_autoconf_snippet "$module" \
4828 | sed -e "$sed_replace_build_aux"
4831 func_emit_initmacro_end $macro_prefix
4832 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4833 # created using libtool, because libtool already handles the dependencies.
4834 if test "$libtool" != true; then
4835 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4836 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4837 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4838 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4839 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4842 func_emit_initmacro_done $macro_prefix $sourcebase
4846 if test -n "$subdirs_with_configure_ac"; then
4847 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
4849 makefiles="Makefile"
4850 for d in $subdirs; do
4851 # For subdirs that have a configure.ac by their own, it's the subdir's
4852 # configure.ac which creates the subdir's Makefile.am, not this one.
4853 case " $subdirs_with_configure_ac " in
4855 *) func_append makefiles " $d/Makefile" ;;
4858 echo "AC_CONFIG_FILES([$makefiles])"
4860 ) > "$testdir/configure.ac"
4862 # Create autogenerated files.
4864 # Do not use "${AUTORECONF} --force --install", because it may invoke
4865 # autopoint, which brings in older versions of some of our .m4 files.
4866 if test -f $m4base/gettext.m4; then
4867 func_execute_command ${AUTOPOINT} --force || func_exit 1
4868 for f in $m4base/*.m4~; do
4870 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4874 if test "$libtool" = true; then
4875 func_execute_command ${LIBTOOLIZE} --copy || func_exit 1
4877 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
4878 if ! test -d build-aux; then
4879 func_execute_command mkdir build-aux || func_exit 1
4881 func_execute_command ${AUTOCONF} || func_exit 1
4882 func_execute_command ${AUTOHEADER} || func_exit 1
4883 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4885 if test -n "$inctests"; then
4886 # Create autogenerated files.
4887 (cd "$testdir/$testsbase" || func_exit 1
4888 # Do not use "${AUTORECONF} --force --install", because it may invoke
4889 # autopoint, which brings in older versions of some of our .m4 files.
4890 if test -f ../$m4base/gettext.m4; then
4891 func_execute_command ${AUTOPOINT} --force || func_exit 1
4892 for f in ../$m4base/*.m4~; do
4894 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4898 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
4899 if ! test -d ../build-aux; then
4900 func_execute_command mkdir ../build-aux
4902 func_execute_command ${AUTOCONF} || func_exit 1
4903 func_execute_command ${AUTOHEADER} || func_exit 1
4904 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4907 # Need to run configure and make once, to create built files that are to be
4908 # distributed (such as getdate.c).
4909 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
4910 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4911 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
4912 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
4913 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
4914 # such $(FOO_H) because they don't refer to distributed files.
4915 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
4916 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4917 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
4918 | sed -e "$sed_remove_make_variables"`
4919 distributed_built_sources=`for file in $built_sources; do
4920 case "$cleaned_files" in
4925 if test -n "$distributed_built_sources"; then
4927 ./configure || func_exit 1
4929 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
4930 $MAKE built_sources || func_exit 1
4932 $MAKE distclean || func_exit 1
4937 # func_create_megatestdir megatestdir allmodules
4939 # - local_gnulib_dir from --local-dir
4940 # - modcache true or false, from --cache-modules/--no-cache-modules
4941 # - auxdir directory relative to destdir where to place build aux files
4942 func_create_megatestdir ()
4946 if test -z "$allmodules"; then
4947 allmodules=`func_all_modules`
4951 # First, all modules one by one.
4952 for onemodule in $allmodules; do
4953 func_create_testdir "$megatestdir/$onemodule" $onemodule
4954 func_append megasubdirs "$onemodule "
4956 # Then, all modules all together.
4957 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4958 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
4959 func_create_testdir "$megatestdir/ALL" "$allmodules"
4960 func_append megasubdirs "ALL"
4963 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
4964 vc_witness="$gnulib_dir/CVS/Entries"; \
4966 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
4968 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
4969 | sed -e 's,January,01,' -e 's,Jan,01,' \
4970 -e 's,February,02,' -e 's,Feb,02,' \
4971 -e 's,March,03,' -e 's,Mar,03,' \
4972 -e 's,April,04,' -e 's,Apr,04,' \
4974 -e 's,June,06,' -e 's,Jun,06,' \
4975 -e 's,July,07,' -e 's,Jul,07,' \
4976 -e 's,August,08,' -e 's,Aug,08,' \
4977 -e 's,September,09,' -e 's,Sep,09,' \
4978 -e 's,October,10,' -e 's,Oct,10,' \
4979 -e 's,November,11,' -e 's,Nov,11,' \
4980 -e 's,December,12,' -e 's,Dec,12,' \
4981 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
4982 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
4984 echo "CVSDATE=$cvsdate"
4985 echo ": \${MAKE=make}"
4986 echo "test -d logs || mkdir logs"
4987 echo "for module in $megasubdirs; do"
4988 echo " echo \"Working on module \$module...\""
4989 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
4990 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
4993 echo " : autobuild project... \$module"
4994 echo " : autobuild revision... cvs-\$CVSDATE-000000"
4995 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
4996 echo " : autobuild hostname... \`hostname\`"
4997 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
4999 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
5001 ) > "$megatestdir/do-autobuild"
5002 chmod a+x "$megatestdir/do-autobuild"
5004 # Create Makefile.am.
5005 (echo "## Process this file with automake to produce Makefile.in."
5007 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
5009 echo "SUBDIRS = $megasubdirs"
5011 echo "EXTRA_DIST = do-autobuild"
5012 ) > "$megatestdir/Makefile.am"
5014 # Create configure.ac.
5015 (echo "# Process this file with autoconf to produce a configure script."
5016 echo "AC_INIT([dummy], [0])"
5017 if test "$auxdir" != "."; then
5018 echo "AC_CONFIG_AUX_DIR([$auxdir])"
5020 echo "AM_INIT_AUTOMAKE"
5022 echo "AC_PROG_MAKE_SET"
5024 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
5025 echo "AC_CONFIG_FILES([Makefile])"
5027 ) > "$megatestdir/configure.ac"
5029 # Create autogenerated files.
5031 # Do not use "${AUTORECONF} --install", because autoreconf operates
5032 # recursively, but the subdirectories are already finished, therefore
5033 # calling autoreconf here would only waste lots of CPU time.
5034 func_execute_command ${ACLOCAL} || func_exit 1
5035 func_execute_command mkdir build-aux
5036 func_execute_command ${AUTOCONF} || func_exit 1
5037 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
5043 func_fatal_error "no mode specified" ;;
5050 # sed expression that converts a literal to a basic regular expression.
5051 # Needs to handle . [ \ * ^ $.
5052 sed_literal_to_basic_regex='s/\\/\\\\/g
5058 if test -f "$gnulib_dir/$filename" \
5059 || { test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$filename"; }; then
5060 filename_anywhere_regex=`echo "$filename" | sed -e "$sed_literal_to_basic_regex"`
5061 filename_line_regex='^'"$filename_anywhere_regex"'$'
5064 (cd "$gnulib_dir" && find modules -type f -print | xargs -n 100 grep -l "$filename_line_regex" /dev/null | sed -e 's,^modules/,,')
5065 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
5066 (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$,,')
5069 | func_sanitize_modulelist \
5072 for module in $module_candidates; do
5073 if func_get_filelist $module | grep "$filename_line_regex" > /dev/null; then
5078 func_warning "file $filename does not exist"
5086 if test -z "$destdir"; then
5089 test -d "$destdir" \
5090 || func_fatal_error "destination directory does not exist: $destdir"
5092 # Prefer configure.ac to configure.in.
5093 if test -f "$destdir"/configure.ac; then
5094 configure_ac="$destdir/configure.ac"
5096 if test -f "$destdir"/configure.in; then
5097 configure_ac="$destdir/configure.in"
5099 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
5103 # Analyze configure.ac.
5105 guessed_libtool=false
5110 /AC_CONFIG_AUX_DIR/ {
5111 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
5113 /A[CM]_PROG_LIBTOOL/ {
5114 s,^.*$,guessed_libtool=true,p
5116 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
5118 if test -z "$auxdir"; then
5119 auxdir="$guessed_auxdir"
5122 # Determine where to apply func_import.
5123 if test -n "$m4base"; then
5124 # Apply func_import to a particular gnulib directory.
5125 # Any number of additional modules can be given.
5126 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
5127 # First use of gnulib in the given m4base.
5128 test -n "$supplied_libname" || supplied_libname=true
5129 test -n "$sourcebase" || sourcebase="lib"
5130 test -n "$docbase" || docbase="doc"
5131 test -n "$testsbase" || testsbase="tests"
5132 test -n "$macro_prefix" || macro_prefix="gl"
5136 # Apply func_import to all gnulib directories.
5137 # To get this list of directories, look at Makefile.am. (Not at
5138 # configure, because it may be omitted from CVS. Also, don't run
5139 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
5142 if test -f "$destdir"/Makefile.am; then
5143 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
5145 for arg in $aclocal_amflags; do
5146 if test -n "$m4dir_is_next"; then
5147 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
5151 if test -f "$destdir/$arg"/gnulib-cache.m4; then
5152 func_append m4dirs " $arg"
5153 m4dirs_count=`expr $m4dirs_count + 1`
5159 if test "X$arg" = "X-I"; then
5167 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
5168 if test -f "$destdir"/aclocal.m4; then
5169 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
5170 sedexpr2='s,^[^/]*$,.,'
5171 sedexpr3='s,/[^/]*$,,'
5172 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
5173 m4dirs_count=`printf %s "$m4dirs" | wc -l`
5176 if test $m4dirs_count = 0; then
5177 # First use of gnulib in a package.
5178 # Any number of additional modules can be given.
5179 test -n "$supplied_libname" || supplied_libname=true
5180 test -n "$sourcebase" || sourcebase="lib"
5182 test -n "$docbase" || docbase="doc"
5183 test -n "$testsbase" || testsbase="tests"
5184 test -n "$macro_prefix" || macro_prefix="gl"
5187 if test $m4dirs_count = 1; then
5188 # There's only one use of gnulib here. Assume the user means it.
5189 # Any number of additional modules can be given.
5190 for m4base in $m4dirs; do
5194 # Ambiguous - guess what the user meant.
5195 if test $# = 0; then
5196 # No further arguments. Guess the user wants to update all of them.
5197 for m4base in $m4dirs; do
5198 # Perform func_import in a subshell, so that variable values
5200 # local_gnulib_dir, incobsolete, avoidlist, sourcebase, m4base,
5201 # pobase, docbase, testsbase, inctests, libname, lgpl,
5202 # makefile_name, libtool, macro_prefix, po_domain, vc_files
5203 # don't propagate from one directory to another.
5204 (func_import) || func_exit 1
5208 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
5216 if test -z "$destdir"; then
5217 func_fatal_error "please specify --dir option"
5220 test -d "$destdir" \
5221 || func_fatal_error "could not create destination directory"
5222 test -n "$auxdir" || auxdir="build-aux"
5223 func_create_testdir "$destdir" "$*"
5226 create-megatestdir )
5227 if test -z "$destdir"; then
5228 func_fatal_error "please specify --dir option"
5230 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5231 test -n "$auxdir" || auxdir="build-aux"
5232 func_create_megatestdir "$destdir" "$*"
5236 test -n "$destdir" || destdir=testdir$$
5237 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5238 test -n "$auxdir" || auxdir="build-aux"
5239 func_create_testdir "$destdir" "$*"
5243 ../configure || func_exit 1
5244 $MAKE || func_exit 1
5245 $MAKE check || func_exit 1
5246 $MAKE distclean || func_exit 1
5247 remaining=`find . -type f -print`
5248 if test -n "$remaining"; then
5249 echo "Remaining files:" $remaining 1>&2
5250 echo "gnulib-tool: *** Stop." 1>&2
5259 test -n "$destdir" || destdir=testdir$$
5260 mkdir "$destdir" || func_fatal_error "could not create destination directory"
5261 test -n "$auxdir" || auxdir="build-aux"
5262 func_create_megatestdir "$destdir" "$*"
5270 remaining=`find . -type f -print`
5271 if test -n "$remaining"; then
5272 echo "Remaining files:" $remaining 1>&2
5273 echo "gnulib-tool: *** Stop." 1>&2
5281 extract-description )
5285 if test -n "$module"; then
5286 func_get_description "$module"
5295 if test -n "$module"; then
5296 func_get_status "$module"
5305 if test -n "$module"; then
5306 func_get_notice "$module"
5311 extract-applicability )
5315 if test -n "$module"; then
5316 func_get_applicability "$module"
5325 if test -n "$module"; then
5326 func_get_filelist "$module"
5331 extract-dependencies )
5335 if test -n "$module"; then
5336 func_get_dependencies "$module"
5341 extract-autoconf-snippet )
5345 if test -n "$module"; then
5346 func_get_autoconf_snippet "$module"
5351 extract-automake-snippet )
5355 if test -n "$module"; then
5356 func_get_automake_snippet "$module"
5361 extract-include-directive )
5365 if test -n "$module"; then
5366 func_get_include_directive "$module"
5371 extract-link-directive )
5375 if test -n "$module"; then
5376 func_get_link_directive "$module"
5385 if test -n "$module"; then
5386 func_get_license "$module"
5391 extract-maintainer )
5395 if test -n "$module"; then
5396 func_get_maintainer "$module"
5401 extract-tests-module )
5405 if test -n "$module"; then
5406 func_get_tests_module "$module"
5412 # Verify the number of arguments.
5413 if test $# -lt 1 || test $# -gt 2; then
5414 func_fatal_error "invalid number of arguments for --$mode"
5417 # The first argument is the file to be copied.
5419 # Verify the file exists.
5420 func_lookup_file "$f"
5422 # The second argument is the destination; either a directory ot a file.
5423 # It defaults to the current directory.
5425 test -n "$dest" || dest='.'
5426 test -n "$sourcebase" || sourcebase="lib"
5427 test -n "$m4base" || m4base="m4"
5428 test -n "$docbase" || docbase="doc"
5429 test -n "$testsbase" || testsbase="tests"
5430 test -n "$auxdir" || auxdir="build-aux"
5431 rewritten='%REWRITTEN%'
5432 sed_rewrite_files="\
5433 s,^build-aux/,$rewritten$auxdir/,
5434 s,^doc/,$rewritten$docbase/,
5435 s,^lib/,$rewritten$sourcebase/,
5436 s,^m4/,$rewritten$m4base/,
5437 s,^tests/,$rewritten$testsbase/,
5440 if test -d "$dest"; then
5442 g=`echo "$f" | sed -e "$sed_rewrite_files"`
5444 destdir=`dirname "$dest"`
5445 g=`basename "$dest"`
5448 # Create the directory for destfile.
5449 d=`dirname "$destdir/$g"`
5451 if test -n "$d" && test ! -d "$d"; then
5452 mkdir -p "$d" || func_fatal_error "failed"
5456 func_dest_tmpfilename "$g"
5457 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5458 already_present=true
5459 if test -f "$destdir/$g"; then
5460 # The file already exists.
5464 # Don't protest if the file should be there but isn't: it happens
5465 # frequently that developers don't put autogenerated files into CVS.
5472 func_fatal_error "unknown operation mode --$mode" ;;
5476 # Undo the effect of the previous 'trap' command. Some shellology:
5477 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
5478 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
5479 # exit); for the others we need to call 'exit' explicitly. The value of $? is
5480 # 128 + signal number and is set before the trap-registered command is run.
5482 trap 'func_exit $?' 1 2 3 13 15
5487 # indent-tabs-mode: nil
5488 # whitespace-check-buffer-indent: nil