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 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
44 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
45 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
46 AUTOCONF="${AUTOCONFPATH}autoconf"
48 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
49 AUTOHEADER="${AUTOCONFPATH}autoheader"
51 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
52 ACLOCAL="${AUTOMAKEPATH}aclocal"
54 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
55 AUTOMAKE="${AUTOMAKEPATH}automake"
57 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
58 AUTORECONF="${AUTOCONFPATH}autoreconf"
61 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
62 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
63 AUTOPOINT="${GETTEXTPATH}autopoint"
67 if test -z "${MAKE}"; then
71 # When using GNU sed, turn off as many GNU extensions as possible,
72 # to minimize the risk of accidentally using non-portable features.
73 # However, do this only for gnulib-tool itself, not for the code that
74 # gnulib-tool generates, since we don't want "sed --posix" to leak
75 # into makefiles. And do it only for sed versions 4.2 or newer,
76 # because "sed --posix" is buggy in GNU sed 4.1.5, see
77 # <http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00225.html>.
78 if (alias) > /dev/null 2>&1 \
79 && echo | sed --posix -e d >/dev/null 2>&1 \
80 && case `sed --version | sed -e 's/^[^0-9]*//' -e 1q` in \
81 [1-3]* | 4.[01]*) false;; \
85 # Define sed as an alias.
86 # It is not always possible to use aliases. Aliases are guaranteed to work
87 # if the executing shell is bash and either it is invoked as /bin/sh or
88 # is a version >= 2.0, supporting shopt. This is the common case.
89 # Two other approaches (use of a variable $sed or of a function func_sed
90 # instead of an alias) require massive, fragile code changes.
91 # An other approach (use of function sed) requires `which sed` - but
92 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
93 if test -n "$BASH_VERSION"; then
94 shopt -s expand_aliases >/dev/null 2>&1
96 alias sed='sed --posix'
99 # sed_noop is a sed expression that does nothing.
100 # An empty expression does not work with the native 'sed' on AIX 6.1.
104 # outputs to stdout the --help usage message.
108 Usage: gnulib-tool --list
109 gnulib-tool --import [module1 ... moduleN]
111 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
112 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
113 gnulib-tool --test --dir=directory module1 ... moduleN
114 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
115 gnulib-tool --extract-description module
116 gnulib-tool --extract-status module
117 gnulib-tool --extract-notice module
118 gnulib-tool --extract-applicability module
119 gnulib-tool --extract-filelist module
120 gnulib-tool --extract-dependencies module
121 gnulib-tool --extract-autoconf-snippet module
122 gnulib-tool --extract-automake-snippet module
123 gnulib-tool --extract-include-directive module
124 gnulib-tool --extract-link-directive module
125 gnulib-tool --extract-license module
126 gnulib-tool --extract-maintainer module
127 gnulib-tool --extract-tests-module module
128 gnulib-tool --copy-file file [destination]
131 --list print the available module names
132 --import import the given modules into the current package;
133 if no modules are specified, update the current
134 package from the current gnulib
135 --update update the current package, restore files omitted
137 --create-testdir create a scratch package with the given modules
138 --create-megatestdir create a mega scratch package with the given modules
139 one by one and all together
140 --test test the combination of the given modules
141 (recommended to use CC=\"gcc -Wall\" here)
142 --megatest test the given modules one by one and all together
143 (recommended to use CC=\"gcc -Wall\" here)
144 --extract-description extract the description
145 --extract-status extract the status (obsolete or not)
146 --extract-notice extract the notice or banner
147 --extract-filelist extract the list of files
148 --extract-dependencies extract the dependencies
149 --extract-autoconf-snippet extract the snippet for configure.ac
150 --extract-automake-snippet extract the snippet for library makefile
151 --extract-include-directive extract the #include directive
152 --extract-link-directive extract the linker directive
153 --extract-license report the license terms of the source files
155 --extract-maintainer report the maintainer(s) inside gnulib
156 --extract-tests-module report the unit test module, if it exists
157 --copy-file copy a file that is not part of any module
160 --dir=DIRECTORY Specify the target directory.
161 For --import, this specifies where your
162 configure.ac can be found. Defaults to current
164 --local-dir=DIRECTORY Specify a local override directory where to look
165 up files before looking in gnulib's directory.
166 --verbose Increase verbosity. May be repeated.
167 --quiet Decrease verbosity. May be repeated.
168 --no-cache Disable module caching optimization.
170 Options for --import:
171 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
172 --source-base=DIRECTORY
173 Directory relative to --dir where source code is
174 placed (default \"lib\").
175 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
176 placed (default \"m4\").
177 --po-base=DIRECTORY Directory relative to --dir where *.po files are
178 placed (default \"po\").
179 --doc-base=DIRECTORY Directory relative to --dir where doc files are
180 placed (default \"doc\").
181 --tests-base=DIRECTORY
182 Directory relative to --dir where unit tests are
183 placed (default \"tests\").
184 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
185 tools are placed (default \"build-aux\").
186 --with-tests Include unit tests for the included modules.
187 --with-obsolete Include obsolete modules when they occur among the
188 dependencies. By default, dependencies to obsolete
190 --avoid=MODULE Avoid including the given MODULE. Useful if you
191 have code that provides equivalent functionality.
192 This option can be repeated.
193 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
194 Also modify license template from GPL to LGPL.
195 The version number of the LGPL can be specified;
196 the default is currently LGPLv3.
197 --makefile-name=NAME Name of makefile in automake syntax in the
198 source-base and tests-base directories
199 (default \"Makefile.am\").
200 --libtool Use libtool rules.
201 --no-libtool Don't use libtool rules.
202 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
203 'gl_INIT'. Default is 'gl'.
204 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
205 the package name. A suffix '-gnulib' is appended.
206 --vc-files Update version control related files.
207 --no-vc-files Don't update version control related files
208 (.gitignore and/or .cvsignore).
209 --no-changelog Don't update or create ChangeLog files.
211 Options for --import and --update:
212 --dry-run For --import, only print what would have been done.
213 -s, --symbolic, --symlink Make symbolic links instead of copying files.
214 --local-symlink Make symbolic links instead of copying files, only
215 for files from the local override directory.
216 -S, --more-symlinks Make symbolic links instead of copying files, and
217 don't replace copyright notices.
219 Report bugs to <bug-gnulib@gnu.org>."
223 # outputs to stdout the --version message.
227 if test -d "$gnulib_dir"/.git \
228 && (git --version) >/dev/null 2>/dev/null \
229 && (date --version) >/dev/null 2>/dev/null; then
230 # gnulib checked out from git.
231 sed_extract_first_date='/^Date/{
235 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
236 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
237 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
238 date=`echo "$date" | sed -e "$sed_year_before_time"`
239 # Use GNU date to compute the time in GMT.
240 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
241 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
243 if test -d "$gnulib_dir"/CVS \
244 && (cvs --version) >/dev/null 2>/dev/null; then
245 # gnulib checked out from CVS.
246 sed_extract_first_date='/^date: /{
247 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
250 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
252 # gnulib copy without versioning information.
253 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
257 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed -e 's,^.* ,,'`
259 gnulib-tool (GNU $package $date)$version
260 Copyright (C) $year Free Software Foundation, Inc.
261 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
262 This is free software: you are free to change and redistribute it.
263 There is NO WARRANTY, to the extent permitted by law.
265 Written by" "Bruno Haible" "and" "Simon Josefsson"
268 # func_emit_copyright_notice
269 # outputs to stdout a header for a generated file.
270 func_emit_copyright_notice ()
272 sed -n -e '/Copyright/ {
275 }' < "$self_abspathname"
277 echo "# This file is free software, distributed under the terms of the GNU"
278 echo "# General Public License. As a special exception to the GNU General"
279 echo "# Public License, this file may be distributed as part of a program"
280 echo "# that contains a configuration script generated by Autoconf, under"
281 echo "# the same distribution terms as the rest of that program."
283 echo "# Generated by gnulib-tool."
287 # exits with a given status.
288 # This function needs to be used, rather than 'exit', when a 'trap' handler is
289 # in effect that refers to $?.
296 # locates the directory where the gnulib repository lives
298 # - progname name of this program
300 # - self_abspathname absolute pathname of gnulib-tool
301 # - gnulib_dir absolute pathname of gnulib repository
305 /*) self_abspathname="$progname" ;;
306 */*) self_abspathname=`pwd`/"$progname" ;;
309 # Iterate through the elements of $PATH.
310 # We use IFS=: instead of
311 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
312 # because the latter does not work when some PATH element contains spaces.
313 # We use a canonicalized $pathx instead of $PATH, because empty PATH
314 # elements are by definition equivalent to '.', however field splitting
315 # according to IFS=: loses empty fields in many shells:
316 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
317 # beginning, at the end, and in the middle),
318 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
319 # at the beginning and at the end,
320 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
321 # Solaris lose empty fields at the end.
322 # The 'case' statement is an optimization, to avoid evaluating the
323 # explicit canonicalization command when $PATH contains no empty fields.
325 if test "${PATH_SEPARATOR+set}" != set; then
327 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
328 chmod +x "$tmp"/conf.sh
329 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
336 if test "$PATH_SEPARATOR" = ";"; then
337 # On Windows, programs are searched in "." before $PATH.
340 # On Unix, we have to convert empty PATH elements to ".".
344 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
349 IFS="$PATH_SEPARATOR"
353 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
354 self_abspathname="$d/$progname"
359 if test -z "$self_abspathname"; then
360 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
364 while test -h "$self_abspathname"; do
365 # Resolve symbolic link.
366 linkval=`func_readlink "$self_abspathname"`
367 test -n "$linkval" || break
369 /* ) self_abspathname="$linkval" ;;
370 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
373 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
377 # creates a temporary directory.
379 # - progname name of this program
381 # - tmp pathname of freshly created temporary directory
384 # Use the environment variable TMPDIR, falling back to /tmp. This allows
385 # users to specify a different temporary directory, for example, if their
386 # /tmp is filled up or too small.
389 # Use the mktemp program if available. If not available, hide the error
391 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
392 test -n "$tmp" && test -d "$tmp"
395 # Use a simple mkdir command. It is guaranteed to fail if the directory
396 # already exists. $RANDOM is bash specific and expands to empty in shells
397 # other than bash, ksh and zsh. Its use does not increase security;
398 # rather, it minimizes the probability of failure in a very cluttered /tmp
400 tmp=$TMPDIR/gl$$-$RANDOM
401 (umask 077 && mkdir "$tmp")
404 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
409 # func_append var value
410 # appends the given value to the shell variable var.
411 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
412 # Use bash's += operator. It reduces complexity of appending repeatedly to
413 # a single variable from O(n^2) to O(n).
418 fast_func_append=true
422 eval "$1=\"\$$1\$2\""
424 fast_func_append=false
427 # func_remove_prefix var prefix
428 # removes the given prefix from the value of the shell variable var.
429 # var should be the name of a shell variable.
430 # Its value should not contain a newline and not start or end with whitespace.
431 # prefix should not contain the characters "$`\{}[]^|.
432 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
433 func_remove_prefix ()
437 fast_func_remove_prefix=true
439 func_remove_prefix ()
441 eval "value=\"\$$1\""
445 sed_escape_dots='s/\([.]\)/\\\1/g'
446 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
449 value=`echo "$value" | sed -e "s|^${prefix}||"`
450 eval "$1=\"\$value\""
452 fast_func_remove_prefix=false
455 # func_remove_suffix var suffix
456 # removes the given suffix 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 # suffix should not contain the characters "$`\{}[]^|.
460 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
461 func_remove_suffix ()
465 fast_func_remove_suffix=true
467 func_remove_suffix ()
469 eval "value=\"\$$1\""
473 sed_escape_dots='s/\([.]\)/\\\1/g'
474 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
477 value=`echo "$value" | sed -e "s|${suffix}\$||"`
478 eval "$1=\"\$value\""
480 fast_func_remove_suffix=false
483 # func_fatal_error message
484 # outputs to stderr a fatal error message, and terminates the program.
486 # - progname name of this program
489 echo "$progname: *** $1" 1>&2
490 echo "$progname: *** Stop." 1>&2
494 # func_warning message
495 # Outputs to stderr a warning message,
498 echo "gnulib-tool: warning: $1" 1>&2
501 # func_readlink SYMLINK
502 # outputs the target of the given symlink.
503 if (type -p readlink) > /dev/null 2>&1; then
506 # Use the readlink program from GNU coreutils.
512 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
513 # would do the wrong thing if the link target contains " -> ".
514 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
518 # func_relativize DIR1 DIR2
519 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
521 # - DIR1 relative pathname, relative to the current directory
522 # - DIR2 relative pathname, relative to the current directory
524 # - reldir relative pathname of DIR2, relative to DIR1
530 sed_first='s,^\([^/]*\)/.*$,\1,'
531 sed_rest='s,^[^/]*/*,,'
532 sed_last='s,^.*/\([^/]*\)$,\1,'
533 sed_butlast='s,/*[^/]*$,,'
534 while test -n "$dir1"; do
535 first=`echo "$dir1" | sed -e "$sed_first"`
536 if test "$first" != "."; then
537 if test "$first" = ".."; then
538 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
539 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
541 first2=`echo "$dir2" | sed -e "$sed_first"`
542 if test "$first2" = "$first"; then
543 dir2=`echo "$dir2" | sed -e "$sed_rest"`
547 dir0="$dir0"/"$first"
550 dir1=`echo "$dir1" | sed -e "$sed_rest"`
555 # func_relconcat DIR1 DIR2
556 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
558 # - DIR1 relative pathname, relative to the current directory
559 # - DIR2 relative pathname, relative to DIR1
561 # - relconcat DIR1/DIR2, relative to the current directory
566 sed_first='s,^\([^/]*\)/.*$,\1,'
567 sed_rest='s,^[^/]*/*,,'
568 sed_last='s,^.*/\([^/]*\)$,\1,'
569 sed_butlast='s,/*[^/]*$,,'
571 first=`echo "$dir2" | sed -e "$sed_first"`
572 if test "$first" = "."; then
573 dir2=`echo "$dir2" | sed -e "$sed_rest"`
574 if test -z "$dir2"; then
579 last=`echo "$dir1" | sed -e "$sed_last"`
580 while test "$last" = "."; do
581 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
582 last=`echo "$dir1" | sed -e "$sed_last"`
584 if test -z "$dir1"; then
588 if test "$first" = ".."; then
589 if test "$last" = ".."; then
590 relconcat="$dir1/$dir2"
593 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
594 dir2=`echo "$dir2" | sed -e "$sed_rest"`
595 if test -z "$dir1"; then
599 if test -z "$dir2"; then
604 relconcat="$dir1/$dir2"
612 # Like ln -s, except that SRC is given relative to the current directory (or
613 # absolute), not given relative to the directory of DEST.
619 *) # SRC is relative.
622 ln -s "`pwd`/$1" "$2" ;;
623 *) # DEST is relative too.
624 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
625 test -n "$ln_destdir" || ln_destdir="."
626 func_relativize "$ln_destdir" "$1"
634 # func_ln_if_changed SRC DEST
635 # Like func_ln, but avoids munging timestamps if the link is correct.
636 func_ln_if_changed ()
638 if test $# -ne 2; then
639 echo "usage: func_ln_if_changed SRC DEST" >&2
641 ln_target=`func_readlink "$2"`
642 if test -h "$2" && test "$1" = "$ln_target"; then
651 # Resets SIGPIPE to its default behaviour. SIGPIPE is signalled when a process
652 # writes into a pipe with no readers, i.e. a pipe where all readers have
653 # already closed their file descriptor that read from it or exited entirely.
654 # The default behaviour is to terminate the current process without an error
656 # When "trap '' SIGPIPE" is in effect, the behaviour (at least with bash) is to
657 # terminate the current process with an error message.
658 # This function should be called at the beginning of a command that only
659 # produces output to stdout (i.e. no side effects!), when the command that
660 # will read from this pipe might prematurely exit or close its standard input
662 if test -n "$BASH_VERSION"; then
663 # The problem has only been reported with bash. Probably it occurs only with
664 # bash-3.2. For the reasons, see
665 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>.
666 # Note that Solaris sh does not understand "trap - SIGPIPE".
667 func_reset_sigpipe ()
672 func_reset_sigpipe ()
678 # Ensure an 'echo' command that does not interpret backslashes.
680 # echo '\n' | wc -l prints 1 when OK, 2 when KO
681 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
682 # This problem is a weird heritage from SVR4. BSD got it right (except that
683 # BSD echo interprets '-n' as an option, which is also not desirable).
684 # Nowadays the problem occurs in 4 situations:
685 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
686 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
687 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
688 # - in zsh, when sh-emulation is not set,
689 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
690 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
691 # - in Solaris /bin/sh and OSF/1 /bin/sh.
692 # We try the following workarounds:
693 # - for all: respawn using $CONFIG_SHELL if that is set and works.
694 # - for bash >= 2.04: unset the shell option xpg_echo.
695 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
696 # - for bash < 2.0: define echo to a function that uses cat of a here document.
697 # - for zsh: turn sh-emulation on.
698 # - for ksh: alias echo to 'print -r'.
699 # - for ksh: alias echo to a function that uses cat of a here document.
700 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
701 # the ksh workaround.
702 # - otherwise: respawn using /bin/sh and rely on the workarounds.
703 # When respawning, we pass --no-reexec as first argument, so as to avoid
704 # turning this script into a fork bomb in unlucky situations.
706 if echo '\t' | grep t > /dev/null; then
707 have_echo=yes # Lucky!
709 # Try the workarounds.
710 # Respawn using $CONFIG_SHELL if that is set and works.
711 if test -z "$have_echo" \
712 && test "X$1" != "X--no-reexec" \
713 && test -n "$CONFIG_SHELL" \
714 && test -f "$CONFIG_SHELL" \
715 && $CONFIG_SHELL -c "echo '\\t' | grep t > /dev/null"; then
716 exec $CONFIG_SHELL "$0" --no-reexec "$@"
719 # For bash >= 2.04: unset the shell option xpg_echo.
720 if test -z "$have_echo" \
721 && test -n "$BASH_VERSION" \
722 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
726 # For bash >= 2.0: define echo to a function that uses the printf built-in.
727 # For bash < 2.0: define echo to a function that uses cat of a here document.
728 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
729 if test -z "$have_echo" \
730 && test -n "$BASH_VERSION"; then \
731 if type printf 2>/dev/null | grep / > /dev/null; then
732 # 'printf' is not a shell built-in.
740 # 'printf' is a shell built-in.
746 if echo '\t' | grep t > /dev/null; then
750 # For zsh: turn sh-emulation on.
751 if test -z "$have_echo" \
752 && test -n "$ZSH_VERSION" \
753 && (emulate sh) >/dev/null 2>&1; then
756 # For ksh: alias echo to 'print -r'.
757 if test -z "$have_echo" \
758 && (type print) >/dev/null 2>&1; then
759 # A 'print' command exists.
760 if type print 2>/dev/null | grep / > /dev/null; then
763 # 'print' is a shell built-in.
764 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
765 # 'print' is the ksh shell built-in.
766 alias echo='print -r'
770 if test -z "$have_echo" \
771 && echo '\t' | grep t > /dev/null; then
774 # For ksh: alias echo to a function that uses cat of a here document.
775 # The ksh manual page says:
776 # "Aliasing is performed when scripts are read, not while they are executed.
777 # Therefore, for an alias to take effect, the alias definition command has
778 # to be executed before the command which references the alias is read."
779 # Because of this, we have to play strange tricks with have_echo, to ensure
780 # that the top-level statement containing the test starts after the 'alias'
782 if test -z "$have_echo"; then
789 alias echo=bsd_echo 2>/dev/null
791 if test -z "$have_echo" \
792 && echo '\t' | grep t > /dev/null; then
795 if test -z "$have_echo"; then
796 unalias echo 2>/dev/null
798 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
799 if test -z "$have_echo" \
800 && test "X$1" != "X--no-reexec" \
801 && test -f /bin/ksh; then
802 exec /bin/ksh "$0" --no-reexec "$@"
805 # Otherwise: respawn using /bin/sh.
806 if test -z "$have_echo" \
807 && test "X$1" != "X--no-reexec" \
808 && test -f /bin/sh; then
809 exec /bin/sh "$0" --no-reexec "$@"
812 if test -z "$have_echo"; then
813 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
815 if echo '\t' | grep t > /dev/null; then
818 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
820 if test "X$1" = "X--no-reexec"; then
824 # Command-line option processing.
825 # Removes the OPTIONS from the arguments. Sets the variables:
826 # - mode list or import or create-testdir or create-megatestdir
827 # - destdir from --dir
828 # - local_gnulib_dir from --local-dir
829 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
830 # - libname, supplied_libname from --lib
831 # - sourcebase from --source-base
832 # - m4base from --m4-base
833 # - pobase from --po-base
834 # - docbase from --doc-base
835 # - testsbase from --tests-base
836 # - auxdir from --aux-dir
837 # - inctests true if --with-tests was given, blank otherwise
838 # - incobsolete true if --with-obsolete was given, blank otherwise
839 # - avoidlist list of modules to avoid, from --avoid
840 # - lgpl yes or a number if --lgpl was given, blank otherwise
841 # - makefile_name from --makefile-name
842 # - libtool true if --libtool was given, false if --no-libtool was
843 # given, blank otherwise
844 # - macro_prefix from --macro-prefix
845 # - po_domain from --po-domain
846 # - vc_files true if --vc-files was given, false if --no-vc-files was
847 # given, blank otherwise
848 # - autoconf_minversion minimum supported autoconf version
849 # - do_changelog false if --no-changelog was given, : otherwise
850 # - doit : if actions shall be executed, false if only to be printed
851 # - symbolic true if --symlink or --more-symlinks was given, blank
853 # - lsymbolic true if --local-symlink was given, blank otherwise
854 # - do_copyrights blank if --more-symlinks was given, true otherwise
886 while test $# -gt 0; do
891 --import | --impor | --impo | --imp | --im | --i )
894 --update | --updat | --upda | --upd | --up | --u )
897 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
900 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
901 mode=create-megatestdir
903 --test | --tes | --te | --t )
906 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
910 mode=`echo "X$1" | sed -e 's/^X--//'`
912 --copy-file | --copy-fil | --copy-fi | --copy-f | --copy- | --copy | --cop | --co )
918 func_fatal_error "missing argument for --dir"
923 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
928 func_fatal_error "missing argument for --local-dir"
933 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
935 --verbose | --verbos | --verbo | --verb )
936 verbose=`expr $verbose + 1`
938 --quiet | --quie | --qui | --qu | --q )
939 verbose=`expr $verbose - 1`
941 --no-cache | --no-cach | --no-cac | --no-ca )
947 func_fatal_error "missing argument for --lib"
950 supplied_libname=true
953 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
954 supplied_libname=true
959 func_fatal_error "missing argument for --source-base"
964 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
969 func_fatal_error "missing argument for --m4-base"
974 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
979 func_fatal_error "missing argument for --po-base"
984 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
989 func_fatal_error "missing argument for --doc-base"
994 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
999 func_fatal_error "missing argument for --tests-base"
1004 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
1008 if test $# = 0; then
1009 func_fatal_error "missing argument for --aux-dir"
1014 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
1024 if test $# = 0; then
1025 func_fatal_error "missing argument for --avoid"
1027 func_append avoidlist " $1"
1030 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1031 func_append avoidlist " $arg"
1037 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1040 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1046 if test $# = 0; then
1047 func_fatal_error "missing argument for --makefile-name"
1052 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1062 if test $# = 0; then
1063 func_fatal_error "missing argument for --macro-prefix"
1068 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1072 if test $# = 0; then
1073 func_fatal_error "missing argument for --po-domain"
1078 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1086 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch )
1092 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1095 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1098 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1102 --help | --hel | --he | --h )
1105 --version | --versio | --versi | --vers )
1109 # Stop option processing
1113 echo "gnulib-tool: unknown option $1" 1>&2
1114 echo "Try 'gnulib-tool --help' for more information." 1>&2
1121 if test "$mode" = update; then
1122 if test $# != 0; then
1123 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1124 echo "Try 'gnulib-tool --help' for more information." 1>&2
1125 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1126 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1129 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1130 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1131 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1132 || test -n "$inctests" || test -n "$incobsolete" \
1133 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1134 || test -n "$macro_prefix" || test -n "$po_domain" \
1135 || test -n "$vc_files"; then
1136 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1137 echo "Try 'gnulib-tool --help' for more information." 1>&2
1138 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1139 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1144 if test -n "$pobase" && test -z "$po_domain"; then
1145 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1146 echo "Try 'gnulib-tool --help' for more information." 1>&2
1149 if test -z "$pobase" && test -n "$po_domain"; then
1150 func_warning "--po-domain has no effect without a --po-base option"
1153 # Determine the minimum supported autoconf version from the project's
1155 DEFAULT_AUTOCONF_MINVERSION="2.59"
1156 autoconf_minversion=
1158 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1159 if test -f "$destdir"/configure.ac; then
1160 configure_ac="$destdir/configure.ac"
1162 if test -f "$destdir"/configure.in; then
1163 configure_ac="$destdir/configure.in"
1167 if test -f configure.ac; then
1168 configure_ac="configure.ac"
1170 if test -f configure.in; then
1171 configure_ac="configure.in"
1175 if test -n "$configure_ac"; then
1176 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1177 # because when some m4 files are omitted from a CVS repository,
1178 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1179 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1180 # autom4te: m4 failed with exit status: 1
1187 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1189 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1190 if test -n "$prereqs"; then
1191 autoconf_minversion=`
1192 for version in $prereqs; do echo $version; done |
1193 LC_ALL=C sort -nru | sed -e 1q
1197 if test -z "$autoconf_minversion"; then
1198 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1200 case "$autoconf_minversion" in
1201 1.* | 2.[0-4]* | 2.5[0-8]*)
1202 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1205 # Remove trailing slashes from the directory names. This is necessary for
1206 # m4base (to avoid an error in func_import) and optional for the others.
1207 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1208 case "$local_gnulib_dir" in
1209 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1211 case "$sourcebase" in
1212 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1215 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1218 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1221 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1223 case "$testsbase" in
1224 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1227 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1233 trap 'exit_status=$?
1234 if test "$signal" != 0; then
1235 echo "caught signal $signal" >&2
1238 exit $exit_status' 0
1239 for signal in 1 2 3 13 15; do
1240 trap '{ signal='$signal'; func_exit 1; }' $signal
1244 # func_lookup_file file
1245 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1248 # - local_gnulib_dir from --local-dir
1250 # - lookedup_file name of the merged (combined) file
1251 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1255 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1256 lookedup_file="$local_gnulib_dir/$lkfile"
1259 if test -f "$gnulib_dir/$lkfile"; then
1260 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1261 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1262 rm -f "$tmp/$lkbase"
1263 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1264 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1265 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1266 lookedup_file="$tmp/$lkbase"
1269 lookedup_file="$gnulib_dir/$lkfile"
1273 func_fatal_error "file $gnulib_dir/$lkfile not found"
1280 # - local_gnulib_dir from --local-dir
1283 # Filter out metainformation files like README, which are not modules.
1284 # Filter out unit test modules; they can be retrieved through
1285 # --extract-tests-module if desired.
1287 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1288 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1289 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1292 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1293 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1294 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1295 -e '/^README$/d' -e '/\/README$/d' \
1296 -e '/^TEMPLATE$/d' \
1297 -e '/^TEMPLATE-EXTENDED$/d' \
1298 -e '/^TEMPLATE-TESTS$/d' \
1301 | sed -e '/-tests$/d' \
1305 # func_verify_module
1306 # verifies a module name
1308 # - local_gnulib_dir from --local-dir
1309 # - module module name argument
1310 func_verify_module ()
1312 if { test -f "$gnulib_dir/modules/$module" \
1313 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1314 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1315 && test "CVS" != "$module" \
1316 && test "ChangeLog" != "$module" \
1317 && test "COPYING" != "$module" \
1318 && test "README" != "$module" \
1319 && test "TEMPLATE" != "$module" \
1320 && test "TEMPLATE-EXTENDED" != "$module" \
1321 && test "TEMPLATE-TESTS" != "$module"; then
1322 # OK, $module is a correct module name.
1323 # Verify that building the module description with 'patch' succeeds.
1324 func_lookup_file "modules/$module"
1326 func_warning "module $module doesn't exist"
1331 # func_verify_nontests_module
1332 # verifies a module name, excluding tests modules
1334 # - local_gnulib_dir from --local-dir
1335 # - module module name argument
1336 func_verify_nontests_module ()
1339 *-tests ) module= ;;
1340 * ) func_verify_module ;;
1344 # func_verify_tests_module
1345 # verifies a module name, considering only tests modules
1347 # - local_gnulib_dir from --local-dir
1348 # - module module name argument
1349 func_verify_tests_module ()
1352 *-tests ) func_verify_module ;;
1357 # func_cache_var file
1359 # return the cache variable name corresponding to $file.
1362 if test -n "$BASH_VERSION"; then
1365 cachevar=c_${1//[!a-zA-Z0-9_]/_}
1372 cachevar=c_`echo "$1" | LC_ALL=C sed 's/[^a-zA-Z0-9_]/_/g'` ;;
1379 # Extract headers from module descriptions.
1380 # NOTE: Keep this in sync with sed_extract_prog below!
1381 sed_extract_cache_prog="
1382 s/^Description:[ ]*$/desc/
1383 s/^Status:[ ]*$/status/
1384 s/^Notice:[ ]*$/notice/
1385 s/^Applicability:[ ]*$/applicability/
1386 s/^Files:[ ]*$/files/
1387 s/^Depends-on:[ ]*$/deps/
1388 s/^configure\.ac-early:[ ]*$/config_early/
1389 s/^configure\.ac:[ ]*$/config/
1390 s/^Makefile\.am:[ ]*$/makefile/
1391 s/^Include:[ ]*$/include/
1393 s/^License:[ ]*$/license/
1394 s/^Maintainer:[ ]*$/maint/"
1396 # func_cache_lookup_module file
1398 # look up a module, like 'func_lookup_file modules/$file', and store all of its
1399 # relevant data in a cache. If already cached, do not look it up again.
1404 # - ${cachevar}_cached
1405 # - ${cachevar}_desc
1406 # - ${cachevar}_status
1408 func_cache_lookup_module ()
1411 if eval test -z \"\$${cachevar}_cached\"; then
1412 func_lookup_file "modules/$1"
1413 # Turn module descriptions into shell script assignments,
1414 # suitable to be eval'ed. All active characters are escaped.
1417 # Some module's description
1422 # c_MODULE_cached='yes
1425 # 'Some module'\''s description
1430 # The script consists of four parts:
1431 # 1) Insert the "c_MODULE_cached='yes" line,
1432 # 2) The 'match' loop, treating non-header lines by escaping single
1433 # quotes and adding a closing quote in the last line,
1434 # 3) The 'header' treatment, closing the last quote and inserting
1435 # the "c_MODULE_HEADER=" assignment line as well starting the
1436 # following line with an opening quote, if any.
1437 # 4) Special treatment if two headers are only separated by one newline.
1439 1i\'$nl$cachevar'_name='\'$1\'\\$nl$cachevar'_cached='\''yes\'$nl'
1443 '"$sed_extract_cache_prog"'
1452 s/\([a-zA-Z0-9_]\{1,\}\)[ ]*$/'\'\\$nl${cachevar}_'\1=/
1457 '"$sed_extract_cache_prog"'
1467 # Strip trailing newlines from quoted variable assignment strings.
1468 sed_strip_trailing_nl='
1478 s/\n\n*\('\''\)$/\1/
1480 cache_script=`sed "$sed_cache_module" < "$lookedup_file" \
1481 | sed "$sed_strip_trailing_nl"`
1482 eval "$cache_script"
1484 if eval test "$1" != \"\$${cachevar}_name\"; then
1485 eval 'func_fatal_error "cache variable collision: $1 and $'${cachevar}'_name"'
1490 # Extract headers from module descriptions, without caching.
1491 # NOTE: Keep this in sync with sed_extract_cache_prog above!
1492 sed_extract_prog=':[ ]*$/ {
1495 s/^Description:[ ]*$//
1498 s/^Applicability:[ ]*$//
1500 s/^Depends-on:[ ]*$//
1501 s/^configure\.ac-early:[ ]*$//
1502 s/^configure\.ac:[ ]*$//
1503 s/^Makefile\.am:[ ]*$//
1507 s/^Maintainer:[ ]*$//
1515 # func_get_description module
1517 # - local_gnulib_dir from --local-dir
1518 func_get_description ()
1521 func_cache_lookup_module "$1"
1522 eval "echo \"\$${cachevar}_desc\""
1524 func_lookup_file "modules/$1"
1525 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1529 # func_get_status module
1531 # - local_gnulib_dir from --local-dir
1535 func_cache_lookup_module "$1"
1536 eval "echo \"\$${cachevar}_status\""
1538 func_lookup_file "modules/$1"
1539 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1543 # func_get_notice module
1545 # - local_gnulib_dir from --local-dir
1549 func_cache_lookup_module "$1"
1550 eval "echo \"\$${cachevar}_notice\""
1552 func_lookup_file "modules/$1"
1553 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1557 # func_get_applicability module
1559 # - local_gnulib_dir from --local-dir
1560 # The expected result (on stdout) is either 'main', or 'tests', or 'all'.
1561 func_get_applicability ()
1564 func_cache_lookup_module "$1"
1565 eval my_applicability=\$${cachevar}_applicability
1567 func_lookup_file "modules/$1"
1568 my_applicability=`sed -n -e "/^Applicability$sed_extract_prog" < "$lookedup_file"`
1570 if test -n "$my_applicability"; then
1571 echo $my_applicability
1573 # The default is 'main' or 'tests', depending on the module's name.
1575 *-tests) echo tests;;
1581 # func_get_filelist module
1583 # - local_gnulib_dir from --local-dir
1584 func_get_filelist ()
1587 func_cache_lookup_module "$1"
1588 eval "echo \"\$${cachevar}_files\""
1590 func_lookup_file "modules/$1"
1591 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1594 echo m4/gnulib-common.m4
1595 case "$autoconf_minversion" in
1602 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
1603 # stores in outputvar the filtered and processed filelist. Filtering: Only the
1604 # elements starting with prefix and ending with suffix are considered.
1605 # Processing: removed_prefix and removed_suffix are removed from each element,
1606 # added_prefix and added_suffix are added to each element.
1607 # prefix, suffix should not contain shell-special characters.
1608 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
1609 # added_prefix, added_suffix should not contain the characters \|&.
1610 func_filter_filelist ()
1612 if test "$2" != "$nl" \
1613 || { $fast_func_append \
1614 && { test -z "$6" || $fast_func_remove_prefix; } \
1615 && { test -z "$7" || $fast_func_remove_suffix; }; \
1619 # Do not quote possibly-empty parameters in case patterns,
1620 # AIX and HP-UX ksh won't match them if they are empty.
1623 if test -n "$6"; then
1624 func_remove_prefix fff "$6"
1626 if test -n "$7"; then
1627 func_remove_suffix fff "$7"
1630 if test -z "$ffflist"; then
1633 func_append ffflist "$2${fff}"
1639 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
1640 ffflist=`for fff in $3; do
1642 $4*$5) echo "$fff" ;;
1644 done | sed -e "$sed_fff_filter"`
1646 eval "$1=\"\$ffflist\""
1649 # func_get_dependencies module
1651 # - local_gnulib_dir from --local-dir
1652 func_get_dependencies ()
1654 # ${module}-tests always implicitly depends on ${module}.
1658 func_remove_suffix fgd1 '-tests'
1662 # Then the explicit dependencies listed in the module description.
1664 func_cache_lookup_module "$1"
1665 eval "echo \"\$${cachevar}_deps\""
1667 func_lookup_file "modules/$1"
1668 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1672 # func_get_autoconf_early_snippet module
1674 # - local_gnulib_dir from --local-dir
1675 func_get_autoconf_early_snippet ()
1678 func_cache_lookup_module "$1"
1679 eval "echo \"\$${cachevar}_config_early\""
1681 func_lookup_file "modules/$1"
1682 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1686 # func_get_autoconf_snippet module
1688 # - local_gnulib_dir from --local-dir
1689 func_get_autoconf_snippet ()
1692 func_cache_lookup_module "$1"
1693 eval "echo \"\$${cachevar}_config\""
1695 func_lookup_file "modules/$1"
1696 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1700 # func_get_automake_snippet module
1702 # - local_gnulib_dir from --local-dir
1703 func_get_automake_snippet ()
1706 func_cache_lookup_module "$1"
1707 eval "echo \"\$${cachevar}_makefile\""
1709 func_lookup_file "modules/$1"
1710 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1714 # *-tests module live in tests/, not lib/.
1715 # Synthesize an EXTRA_DIST augmentation.
1716 all_files=`func_get_filelist $1`
1717 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
1718 extra_files="$tests_files"
1719 if test -n "$extra_files"; then
1720 echo "EXTRA_DIST +=" $extra_files
1725 # Synthesize an EXTRA_DIST augmentation.
1726 sed_combine_lines='/\\$/{
1733 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1735 already_mentioned_files=` \
1736 { eval 'echo "$'${cachevar}'_makefile"'; echo; } \
1737 | sed -e "$sed_combine_lines" \
1738 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1740 already_mentioned_files=` \
1741 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1742 | sed -e "$sed_combine_lines" \
1743 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1745 all_files=`func_get_filelist $1`
1746 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
1747 # Remove $already_mentioned_files from $lib_files.
1748 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1749 extra_files=`func_reset_sigpipe; \
1750 for f in $already_mentioned_files; do echo $f; done \
1751 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1752 if test -n "$extra_files"; then
1753 echo "EXTRA_DIST +=" $extra_files
1756 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1757 # This is necessary so that automake can generate the right list of
1759 # A possible approach would be to use autom4te --trace of the redefined
1760 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1761 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1762 # inside autoconf's built-in macros are not missed).
1763 # But it's simpler and more robust to do it here, based on the file list.
1764 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1765 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1766 # automake will generate a useless dependency; this is harmless.
1768 relocatable-prog-wrapper) ;;
1770 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
1771 if test -n "$extra_files"; then
1772 echo "EXTRA_lib_SOURCES +=" $extra_files
1777 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1778 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
1779 if test -n "$buildaux_files"; then
1780 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1781 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1784 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
1785 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
1786 if test -n "$top_files"; then
1787 sed_prepend_topdir='s,^,$(top_srcdir)/,'
1788 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
1795 # func_get_include_directive module
1797 # - local_gnulib_dir from --local-dir
1798 func_get_include_directive ()
1801 func_cache_lookup_module "$1"
1802 eval "echo \"\$${cachevar}_include\"" | \
1803 sed -e 's/^\(["<]\)/#include \1/'
1805 func_lookup_file "modules/$1"
1806 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1807 sed -e 's/^\(["<]\)/#include \1/'
1811 # func_get_link_directive module
1813 # - local_gnulib_dir from --local-dir
1814 func_get_link_directive ()
1817 func_cache_lookup_module "$1"
1818 eval "echo \"\$${cachevar}_link\""
1820 func_lookup_file "modules/$1"
1821 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1825 # func_get_license module
1827 # - local_gnulib_dir from --local-dir
1832 func_cache_lookup_module "$1"
1833 eval "echo \"\$${cachevar}_license\""
1835 func_lookup_file "modules/$1"
1836 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1838 # The default is GPL.
1840 } | sed -e 's,^ *$,,' | sed -e 1q
1843 # func_get_maintainer module
1845 # - local_gnulib_dir from --local-dir
1846 func_get_maintainer ()
1849 func_cache_lookup_module "$1"
1850 eval "echo \"\$${cachevar}_maint\""
1852 func_lookup_file "modules/$1"
1853 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1857 # func_get_tests_module module
1859 # - local_gnulib_dir from --local-dir
1860 func_get_tests_module ()
1862 # The naming convention for tests modules is hardwired: ${module}-tests.
1863 if test -f "$gnulib_dir/modules/$1"-tests \
1864 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1865 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1870 # func_acceptable module
1871 # tests whether a module is acceptable.
1873 # - avoidlist list of modules to avoid
1876 for avoid in $avoidlist; do
1877 if test "$avoid" = "$1"; then
1884 # func_modules_transitive_closure
1886 # - local_gnulib_dir from --local-dir
1887 # - modules list of specified modules
1888 # - inctests true if tests should be included, blank otherwise
1889 # - incobsolete true if obsolete modules among dependencies should be
1890 # included, blank otherwise
1891 # - avoidlist list of modules to avoid
1892 # - tmp pathname of a temporary directory
1894 # - modules list of modules, including dependencies
1895 func_modules_transitive_closure ()
1897 # In order to process every module only once (for speed), process an "input
1898 # list" of modules, producing an "output list" of modules. During each round,
1899 # more modules can be queued in the input list. Once a module on the input
1900 # list has been processed, it is added to the "handled list", so we can avoid
1901 # to process it again.
1903 inmodules="$modules"
1905 while test -n "$inmodules"; do
1906 inmodules_this_round="$inmodules"
1907 inmodules= # Accumulator, queue for next round
1908 for module in $inmodules_this_round; do
1910 if test -n "$module"; then
1911 if func_acceptable $module; then
1912 func_append outmodules " $module"
1913 deps=`func_get_dependencies $module`
1914 # Duplicate dependencies are harmless, but Jim wants a warning.
1915 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1916 if test -n "$duplicated_deps"; then
1917 func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
1919 for dep in $deps; do
1920 if test -n "$incobsolete" \
1921 || { status=`func_get_status $dep`; test "$status" != obsolete; }; then
1922 func_append inmodules " $dep"
1925 if test -n "$inctests"; then
1926 testsmodule=`func_get_tests_module $module`
1927 if test -n "$testsmodule"; then
1928 func_append inmodules " $testsmodule"
1934 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1935 # Remove $handledmodules from $inmodules.
1936 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1937 inmodules=`func_reset_sigpipe; echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1939 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1940 rm -f "$tmp"/queued-modules
1943 # func_modules_add_dummy
1945 # - local_gnulib_dir from --local-dir
1946 # - modules list of modules, including dependencies
1948 # - modules list of modules, including 'dummy' if needed
1949 func_modules_add_dummy ()
1951 # Determine whether any module provides a lib_SOURCES augmentation.
1953 sed_remove_backslash_newline=':a
1960 for module in $modules; do
1961 func_verify_nontests_module
1962 if test -n "$module"; then
1963 # Extract the value of "lib_SOURCES += ...".
1964 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1965 # Ignore .h files since they are not compiled.
1969 have_lib_SOURCES=yes
1976 # Add the dummy module, to make sure the library will be non-empty.
1977 if test -z "$have_lib_SOURCES"; then
1978 if func_acceptable "dummy"; then
1979 func_append modules " dummy"
1984 # func_modules_notice
1986 # - local_gnulib_dir from --local-dir
1987 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1988 # - modules list of modules, including dependencies
1989 func_modules_notice ()
1991 if test $verbose -ge -1; then
1992 for module in $modules; do
1994 if test -n "$module"; then
1995 msg=`func_get_notice $module`
1996 if test -n "$msg"; then
1997 echo "Notice from module $module:"
1998 echo "$msg" | sed -e 's/^/ /'
2005 # func_modules_to_filelist
2007 # - local_gnulib_dir from --local-dir
2008 # - modules list of modules, including dependencies
2010 # - files list of files
2011 func_modules_to_filelist ()
2014 for module in $modules; do
2016 if test -n "$module"; then
2017 fs=`func_get_filelist $module`
2018 func_append files " $fs"
2021 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
2024 # func_execute_command command [args...]
2025 # Executes a command.
2026 # Uses also the variables
2027 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2028 func_execute_command ()
2030 if test $verbose -ge 0; then
2034 # Commands like automake produce output to stderr even when they succeed.
2035 # Turn this output off if the command succeeds.
2036 "$@" > "$tmp"/cmdout 2>&1
2038 if test $cmdret = 0; then
2042 cat "$tmp"/cmdout 1>&2
2049 # func_dest_tmpfilename file
2050 # determines the name of a temporary file (file is relative to destdir).
2052 # - destdir target directory
2053 # - doit : if actions shall be executed, false if only to be printed
2054 # - tmp pathname of a temporary directory
2056 # - tmpfile absolute filename of the temporary file
2057 func_dest_tmpfilename ()
2060 # Put the new contents of $file in a file in the same directory (needed
2061 # to guarantee that an 'mv' to "$destdir/$file" works).
2062 tmpfile="$destdir/$1.tmp"
2064 # Put the new contents of $file in a file in a temporary directory
2065 # (because the directory of "$file" might not exist).
2066 tmpfile="$tmp"/`basename "$1"`.tmp
2071 # copies a file from gnulib into the destination directory. The destination
2072 # is known to not exist.
2074 # - destdir target directory
2075 # - local_gnulib_dir from --local-dir
2076 # - f the original file name
2077 # - lookedup_file name of the merged (combined) file
2078 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2079 # - g the rewritten file name
2080 # - tmpfile absolute filename of the temporary file
2081 # - doit : if actions shall be executed, false if only to be printed
2082 # - symbolic true if files should be symlinked, copied otherwise
2083 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2088 echo "Copying file $g"
2089 if { test -n "$symbolic" \
2090 || { test -n "$lsymbolic" \
2091 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2092 && test -z "$lookedup_tmp" \
2093 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2094 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2096 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2104 # copies a file from gnulib into the destination directory. The destination
2105 # is known to exist.
2107 # - destdir target directory
2108 # - local_gnulib_dir from --local-dir
2109 # - f the original file name
2110 # - lookedup_file name of the merged (combined) file
2111 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
2112 # - g the rewritten file name
2113 # - tmpfile absolute filename of the temporary file
2114 # - doit : if actions shall be executed, false if only to be printed
2115 # - symbolic true if files should be symlinked, copied otherwise
2116 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2118 # - already_present nonempty if the file should already exist, empty otherwise
2121 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2122 : # The file has not changed.
2126 if test -n "$already_present"; then
2127 echo "Updating file $g (backup in ${g}~)"
2129 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2131 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2132 if { test -n "$symbolic" \
2133 || { test -n "$lsymbolic" \
2134 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2135 && test -z "$lookedup_tmp" \
2136 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2137 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2139 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2142 if test -n "$already_present"; then
2143 echo "Update file $g (backup in ${g}~)"
2145 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2151 # func_emit_lib_Makefile_am
2152 # emits the contents of library makefile to standard output.
2154 # - local_gnulib_dir from --local-dir
2155 # - modules list of modules, including dependencies
2156 # - libname library name
2157 # - pobase directory relative to destdir where to place *.po files
2158 # - auxdir directory relative to destdir where to place build aux files
2159 # - makefile_name from --makefile-name
2160 # - libtool true if libtool will be used, false or blank otherwise
2161 # - macro_prefix prefix of gl_LIBOBJS macros to use
2162 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2163 # - actioncmd (optional) command that will reproduce this invocation
2164 # - for_test true if creating a package for testing, false otherwise
2165 # - destfile filename relative to destdir of makefile being generated
2167 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2168 # list of edits to be done to Makefile.am variables
2170 # - uses_subdirs nonempty if object files in subdirs exist
2171 func_emit_lib_Makefile_am ()
2173 # When creating an includable Makefile.am snippet, augment variables with
2174 # += instead of assigning them.
2175 if test -n "$makefile_name"; then
2180 if test "$libtool" = true; then
2183 sed_eliminate_LDFLAGS="$sed_noop"
2187 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2190 # When creating a package for testing: Attempt to provoke failures,
2191 # especially link errors, already during "make" rather than during
2192 # "make check", because "make check" is not possible in a cross-compiling
2193 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2194 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2196 sed_transform_check_PROGRAMS="$sed_noop"
2198 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2199 echo "## Process this file with automake to produce Makefile.in."
2200 func_emit_copyright_notice
2201 if test -n "$actioncmd"; then
2202 # The maximum line length (excluding the terminating newline) of any file
2203 # that is to be preprocessed by config.status is 3070. config.status uses
2204 # awk, and the HP-UX 11.00 awk fails if a line has length >= 3071;
2205 # similarly, the IRIX 6.5 awk fails if a line has length >= 3072.
2206 len=`echo "$actioncmd" | wc -c`
2207 if test -n "$len" && test "$len" -le 3000; then
2208 echo "# Reproduce by: $actioncmd"
2214 for module in $modules; do
2215 func_verify_nontests_module
2216 if test -n "$module"; then
2218 func_get_automake_snippet "$module" |
2219 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2220 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2221 -e "$sed_eliminate_LDFLAGS" \
2222 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
2223 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2224 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2225 -e "$sed_transform_check_PROGRAMS"
2226 if test "$module" = 'alloca'; then
2227 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
2228 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2230 } > "$tmp"/amsnippet
2231 # Skip the contents if it's entirely empty.
2232 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2233 echo "## begin gnulib module $module"
2235 cat "$tmp"/amsnippet
2236 echo "## end gnulib module $module"
2239 rm -f "$tmp"/amsnippet
2240 # Test whether there are some source files in subdirectories.
2241 for f in `func_get_filelist "$module"`; do
2251 } > "$tmp"/allsnippets
2252 if test -z "$makefile_name"; then
2253 # If there are source files in subdirectories, prevent collision of the
2254 # object files (example: hash.c and libxml/hash.c).
2256 if test -n "$uses_subdirs"; then
2257 subdir_options=' subdir-objects'
2259 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
2262 if test -z "$makefile_name"; then
2264 echo "noinst_HEADERS ="
2265 echo "noinst_LIBRARIES ="
2266 echo "noinst_LTLIBRARIES ="
2267 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2268 # if you specify pkgdata_DATA to empty. This is a workaround.
2269 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2270 echo "pkgdata_DATA ="
2273 echo "BUILT_SOURCES ="
2276 echo "MOSTLYCLEANFILES $assign core *.stackdump"
2277 if test -z "$makefile_name"; then
2278 echo "MOSTLYCLEANDIRS ="
2280 echo "DISTCLEANFILES ="
2281 echo "MAINTAINERCLEANFILES ="
2283 # Execute edits that apply to the Makefile.am being generated.
2285 while test $edit != $makefile_am_edits; do
2286 edit=`expr $edit + 1`
2287 eval dir=\"\$makefile_am_edit${edit}_dir\"
2288 eval var=\"\$makefile_am_edit${edit}_var\"
2289 eval val=\"\$makefile_am_edit${edit}_val\"
2290 if test -n "$var"; then
2291 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2292 echo "${var} += ${val}"
2293 eval "makefile_am_edit${edit}_var="
2297 if test -z "$makefile_name"; then
2299 echo "AM_CPPFLAGS ="
2303 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$tmp"/allsnippets > /dev/null \
2304 || { test -n "$makefile_name" \
2305 && test -f "$sourcebase/Makefile.am" \
2306 && LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" "$sourcebase/Makefile.am" > /dev/null; \
2308 # One of the snippets or the user's Makefile.am already specifies an
2309 # installation location for the library. Don't confuse automake by saying
2310 # it should not be installed.
2313 # By default, the generated library should not be installed.
2314 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
2317 echo "${libname}_${libext}_SOURCES ="
2318 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2319 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2320 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2321 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
2322 echo "EXTRA_${libname}_${libext}_SOURCES ="
2323 if test "$libtool" = true; then
2324 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
2327 if test -n "$pobase"; then
2328 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
2331 cat "$tmp"/allsnippets \
2332 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2334 echo "mostlyclean-local: mostlyclean-generic"
2335 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2336 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2337 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2341 rm -f "$tmp"/allsnippets
2344 # func_emit_po_Makevars
2345 # emits the contents of po/ makefile parameterization to standard output.
2347 # - local_gnulib_dir from --local-dir
2348 # - sourcebase directory relative to destdir where to place source code
2349 # - pobase directory relative to destdir where to place *.po files
2350 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2351 func_emit_po_Makevars ()
2353 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2354 func_emit_copyright_notice
2356 echo "# Usually the message domain is the same as the package name."
2357 echo "# But here it has a '-gnulib' suffix."
2358 echo "DOMAIN = ${po_domain}-gnulib"
2360 echo "# These two variables depend on the location of this directory."
2361 echo "subdir = ${pobase}"
2362 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
2365 # These options get passed to xgettext.
2366 XGETTEXT_OPTIONS = \
2367 --keyword=_ --flag=_:1:pass-c-format \
2368 --keyword=N_ --flag=N_:1:pass-c-format \
2369 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
2370 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
2371 --flag=error:3:c-format --flag=error_at_line:5:c-format
2373 # This is the copyright holder that gets inserted into the header of the
2374 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2375 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2377 # This is the email address or URL to which the translators shall report
2378 # bugs in the untranslated strings:
2379 # - Strings which are not entire sentences, see the maintainer guidelines
2380 # in the GNU gettext documentation, section 'Preparing Strings'.
2381 # - Strings which use unclear terms or require additional context to be
2383 # - Strings which make invalid assumptions about notation of date, time or
2385 # - Pluralisation problems.
2386 # - Incorrect English spelling.
2387 # - Incorrect formatting.
2388 # It can be your email address, or a mailing list address where translators
2389 # can write to without being subscribed, or the URL of a web page through
2390 # which the translators can contact you.
2391 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2393 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2394 # message catalogs shall be used. It is usually empty.
2395 EXTRA_LOCALE_CATEGORIES =
2397 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2398 # context. Possible values are "yes" and "no". Set this to yes if the
2399 # package uses functions taking also a message context, like pgettext(), or
2400 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
2405 # func_emit_po_POTFILES_in
2406 # emits the file list to be passed to xgettext to standard output.
2408 # - local_gnulib_dir from --local-dir
2409 # - sourcebase directory relative to destdir where to place source code
2410 # - files list of new files
2411 func_emit_po_POTFILES_in ()
2413 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2414 func_emit_copyright_notice
2416 echo "# List of files which contain translatable strings."
2417 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
2420 # func_emit_tests_Makefile_am
2421 # emits the contents of tests makefile to standard output.
2423 # - local_gnulib_dir from --local-dir
2424 # - modules list of modules, including dependencies
2425 # - libname library name
2426 # - auxdir directory relative to destdir where to place build aux files
2427 # - makefile_name from --makefile-name
2428 # - libtool true if libtool will be used, false or blank otherwise
2429 # - sourcebase relative directory containing lib source code
2430 # - m4base relative directory containing autoconf macros
2431 # - testsbase relative directory containing unit test code
2432 # - macro_prefix prefix of gl_LIBOBJS macros to use
2433 # - for_test true if creating a package for testing, false otherwise
2434 # - use_libtests true if a libtests.a should be built, false otherwise
2435 # - destfile filename relative to destdir of makefile being generated
2437 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2438 # list of edits to be done to Makefile.am variables
2440 # - uses_subdirs nonempty if object files in subdirs exist
2441 func_emit_tests_Makefile_am ()
2443 if test "$libtool" = true; then
2445 sed_eliminate_LDFLAGS="$sed_noop"
2448 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2451 # When creating a package for testing: Attempt to provoke failures,
2452 # especially link errors, already during "make" rather than during
2453 # "make check", because "make check" is not possible in a cross-compiling
2454 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2455 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2457 sed_transform_check_PROGRAMS="$sed_noop"
2459 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
2460 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2461 echo "## Process this file with automake to produce Makefile.in."
2462 func_emit_copyright_notice
2466 for module in $modules; do
2468 func_verify_tests_module
2472 if test -n "$module"; then
2474 func_get_automake_snippet "$module" |
2475 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2476 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2477 -e "$sed_eliminate_LDFLAGS" \
2478 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
2479 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2480 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2481 -e "$sed_transform_check_PROGRAMS"
2482 if $use_libtests && test "$module" = 'alloca'; then
2483 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
2484 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2486 } > "$tmp"/amsnippet
2487 # Skip the contents if it's entirely empty.
2488 if grep '[^ ]' "$tmp"/amsnippet > /dev/null ; then
2489 echo "## begin gnulib module $module"
2491 cat "$tmp"/amsnippet
2492 echo "## end gnulib module $module"
2495 rm -f "$tmp"/amsnippet
2496 # Test whether there are some source files in subdirectories.
2497 for f in `func_get_filelist "$module"`; do
2499 lib/*/*.c | tests/*/*.c)
2507 } > "$tmp"/allsnippets
2508 # Generate dependencies here, since it eases the debugging of test failures.
2509 # If there are source files in subdirectories, prevent collision of the
2510 # object files (example: hash.c and libxml/hash.c).
2512 if test -n "$uses_subdirs"; then
2513 subdir_options=' subdir-objects'
2515 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
2518 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
2521 # Nothing is being added to SUBDIRS; nevertheless the existence of this
2522 # variable is needed to avoid an error from automake:
2523 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
2526 echo "XFAIL_TESTS ="
2527 echo "TESTS_ENVIRONMENT ="
2528 echo "noinst_PROGRAMS ="
2529 if ! $for_test; then
2530 echo "check_PROGRAMS ="
2532 echo "noinst_HEADERS ="
2533 echo "noinst_LIBRARIES ="
2534 if $use_libtests; then
2536 echo "noinst_LIBRARIES += libtests.a"
2538 echo "check_LIBRARIES = libtests.a"
2541 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2542 # if you specify pkgdata_DATA to empty. This is a workaround.
2543 if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
2544 echo "pkgdata_DATA ="
2547 echo "BUILT_SOURCES ="
2549 echo "MOSTLYCLEANFILES = core *.stackdump"
2550 echo "MOSTLYCLEANDIRS ="
2552 echo "DISTCLEANFILES ="
2553 echo "MAINTAINERCLEANFILES ="
2554 # Execute edits that apply to the Makefile.am being generated.
2556 while test $edit != $makefile_am_edits; do
2557 edit=`expr $edit + 1`
2558 eval dir=\"\$makefile_am_edit${edit}_dir\"
2559 eval var=\"\$makefile_am_edit${edit}_var\"
2560 eval val=\"\$makefile_am_edit${edit}_val\"
2561 if test -n "$var"; then
2562 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2563 echo "${var} += ${val}"
2564 eval "makefile_am_edit${edit}_var="
2569 echo "AM_CPPFLAGS = \\"
2570 echo " -I. -I\$(srcdir) \\"
2571 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
2572 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
2574 local_ldadd_before=''
2575 local_ldadd_after=''
2576 if $use_libtests; then
2577 # All test programs need to be linked with libtests.a.
2578 # It needs to be passed to the linker before ${libname}.${libext}, since
2579 # the tests-related modules depend on the main modules.
2580 # It also needs to be passed to the linker after ${libname}.${libext}
2581 # because the latter might contain incomplete modules (such as the 'error'
2582 # module whose dependency to 'progname' is voluntarily omitted).
2583 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
2585 local_ldadd_before=' libtests.a'
2586 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
2588 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
2590 if $use_libtests; then
2591 echo "libtests_a_SOURCES ="
2592 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2593 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2594 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
2595 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
2596 echo "EXTRA_libtests_a_SOURCES ="
2597 # The circular dependency in LDADD requires this.
2598 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
2601 # Many test scripts use ${EXEEXT} or ${srcdir}.
2602 # EXEEXT is defined by AC_PROG_CC through autoconf.
2603 # srcdir is defined by autoconf and automake.
2604 echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
2606 cat "$tmp"/allsnippets \
2607 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2608 echo "# Clean up after Solaris cc."
2610 echo " rm -rf SunWS_cache"
2612 echo "mostlyclean-local: mostlyclean-generic"
2613 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2614 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2615 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2619 rm -f "$tmp"/allsnippets
2622 # func_emit_initmacro_start macro_prefix
2623 # emits the first few statements of the gl_INIT macro to standard output.
2624 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2625 func_emit_initmacro_start ()
2627 macro_prefix_arg="$1"
2628 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
2629 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
2630 # LIBOBJS. The purpose is to allow several gnulib instantiations under
2631 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
2633 # Furthermore it avoids an automake error like this when a Makefile.am
2634 # that uses pieces of gnulib also uses $(LIBOBJ):
2635 # automatically discovered file `error.c' should not be explicitly mentioned
2636 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
2637 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
2638 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
2639 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
2640 # automatically discovered file `error.c' should not be explicitly mentioned
2641 # We let automake know about the files to be distributed through the
2642 # EXTRA_lib_SOURCES variable.
2643 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
2644 # Create data variables for checking the presence of files that are mentioned
2645 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
2646 # because we want the check to happen when the configure file is created,
2647 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
2648 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
2649 # in which to expect them.
2650 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
2651 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
2655 # func_emit_initmacro_end macro_prefix
2656 # emits the last few statements of the gl_INIT macro to standard output.
2657 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2658 func_emit_initmacro_end ()
2660 macro_prefix_arg="$1"
2661 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
2662 # The check is performed only when autoconf is run from the directory where
2663 # the configure.ac resides; if it is run from a different directory, the
2665 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
2666 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
2667 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
2668 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
2669 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
2673 echo " m4_if(m4_sysval, [0], [],"
2674 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
2676 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
2677 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
2678 echo " m4_popdef([AC_LIBSOURCES])"
2679 echo " m4_popdef([AC_REPLACE_FUNCS])"
2680 echo " m4_popdef([AC_LIBOBJ])"
2681 echo " AC_CONFIG_COMMANDS_PRE(["
2682 echo " ${macro_prefix_arg}_libobjs="
2683 echo " ${macro_prefix_arg}_ltlibobjs="
2684 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
2685 echo " # Remove the extension."
2686 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
2687 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed -e \"\$sed_drop_objext\" | sort | uniq\`; do"
2688 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
2689 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
2692 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
2693 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
2697 # func_emit_initmacro_done macro_prefix sourcebase
2698 # emits a few statements after the gl_INIT macro to standard output.
2699 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2700 # - sourcebase directory relative to destdir where to place source code
2701 func_emit_initmacro_done ()
2703 macro_prefix_arg="$1"
2706 echo "# Like AC_LIBOBJ, except that the module name goes"
2707 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2708 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
2709 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
2710 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
2713 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
2714 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2715 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
2716 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
2717 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
2720 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
2721 echo "# expected is derived from the gnulib-tool parameterization,"
2722 echo "# and alloca is special cased (for the alloca-opt module)."
2723 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
2724 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
2725 echo " m4_foreach([_gl_NAME], [\$1], ["
2726 echo " m4_if(_gl_NAME, [alloca.c], [], ["
2727 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
2728 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
2734 # func_import modules
2735 # Uses also the variables
2736 # - destdir target directory
2737 # - local_gnulib_dir from --local-dir
2738 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2739 # - libname library name
2740 # - sourcebase directory relative to destdir where to place source code
2741 # - m4base directory relative to destdir where to place *.m4 macros
2742 # - pobase directory relative to destdir where to place *.po files
2743 # - docbase directory relative to destdir where to place doc files
2744 # - testsbase directory relative to destdir where to place unit test code
2745 # - auxdir directory relative to destdir where to place build aux files
2746 # - inctests true if --with-tests was given, blank otherwise
2747 # - incobsolete true if --with-obsolete was given, blank otherwise
2748 # - avoidlist list of modules to avoid, from --avoid
2749 # - lgpl yes or a number if library's license shall be LGPL,
2751 # - makefile_name from --makefile-name
2752 # - libtool true if --libtool was given, false if --no-libtool was
2753 # given, blank otherwise
2754 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
2755 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2756 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2757 # - vc_files true if --vc-files was given, false if --no-vc-files was
2758 # given, blank otherwise
2759 # - autoconf_minversion minimum supported autoconf version
2760 # - doit : if actions shall be executed, false if only to be printed
2761 # - symbolic true if files should be symlinked, copied otherwise
2762 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2764 # - do_copyrights true if copyright notices in files should be replaced,
2768 # Get the cached settings.
2769 cached_local_gnulib_dir=
2770 cached_specified_modules=
2781 cached_makefile_name=
2783 cached_macro_prefix=
2787 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2788 cached_libtool=false
2794 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
2804 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
2806 /gl_WITH_OBSOLETE/ {
2807 s,^.*$,cached_incobsolete=true,p
2810 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
2813 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
2816 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
2819 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
2822 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
2825 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
2828 s,^.*$,cached_inctests=true,p
2831 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
2834 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
2837 s,^.*$,cached_lgpl=yes,p
2839 /gl_MAKEFILE_NAME(/ {
2840 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
2843 s,^.*$,cached_libtool=true,p
2845 /gl_MACRO_PREFIX(/ {
2846 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
2849 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
2852 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
2854 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2855 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2860 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2861 s,^.*$,cached_files=",p
2874 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2878 # Merge the cached settings with the specified ones.
2879 # The m4base must be the same as expected from the pathname.
2880 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2881 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2883 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2884 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2885 if test -z "$local_gnulib_dir"; then
2886 if test -n "$cached_local_gnulib_dir"; then
2889 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2891 case "$cached_local_gnulib_dir" in
2893 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2895 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2896 local_gnulib_dir="$relconcat" ;;
2901 # Append the cached and the specified module names. So that
2902 # "gnulib-tool --import foo" means to add the module foo.
2903 specified_modules="$cached_specified_modules $1"
2904 # Included obsolete modules among the dependencies if specified either way.
2905 if test -z "$incobsolete"; then
2906 incobsolete="$cached_incobsolete"
2908 # Append the cached and the specified avoidlist. This is probably better
2909 # than dropping the cached one when --avoid is specified at least once.
2910 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2911 avoidlist=`echo $avoidlist`
2913 # The sourcebase defaults to the cached one.
2914 if test -z "$sourcebase"; then
2915 sourcebase="$cached_sourcebase"
2916 if test -z "$sourcebase"; then
2917 func_fatal_error "missing --source-base option"
2920 # The pobase defaults to the cached one.
2921 if test -z "$pobase"; then
2922 pobase="$cached_pobase"
2924 # The docbase defaults to the cached one.
2925 if test -z "$docbase"; then
2926 docbase="$cached_docbase"
2927 if test -z "$docbase"; then
2928 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."
2931 # The testsbase defaults to the cached one.
2932 if test -z "$testsbase"; then
2933 testsbase="$cached_testsbase"
2934 if test -z "$testsbase"; then
2935 func_fatal_error "missing --tests-base option"
2938 # Require the tests if specified either way.
2939 if test -z "$inctests"; then
2940 inctests="$cached_inctests"
2942 # The libname defaults to the cached one.
2943 if test -z "$supplied_libname"; then
2944 libname="$cached_libname"
2945 if test -z "$libname"; then
2946 func_fatal_error "missing --lib option"
2949 # Require LGPL if specified either way.
2950 if test -z "$lgpl"; then
2953 # The makefile_name defaults to the cached one.
2954 if test -z "$makefile_name"; then
2955 makefile_name="$cached_makefile_name"
2957 # Use libtool if specified either way, or if guessed.
2958 if test -z "$libtool"; then
2959 if test -n "$cached_m4base"; then
2960 libtool="$cached_libtool"
2962 libtool="$guessed_libtool"
2965 # The macro_prefix defaults to the cached one.
2966 if test -z "$macro_prefix"; then
2967 macro_prefix="$cached_macro_prefix"
2968 if test -z "$macro_prefix"; then
2969 func_fatal_error "missing --macro-prefix option"
2972 # The po_domain defaults to the cached one.
2973 if test -z "$po_domain"; then
2974 po_domain="$cached_po_domain"
2976 # The vc_files defaults to the cached one.
2977 if test -z "$vc_files"; then
2978 vc_files="$cached_vc_files"
2981 # Canonicalize the list of specified modules.
2982 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2984 # Determine final module list.
2985 modules="$specified_modules"
2986 func_modules_transitive_closure
2987 if test $verbose -ge 0; then
2988 echo "Module list with included dependencies:"
2989 echo "$modules" | sed -e 's/^/ /'
2991 final_modules="$modules"
2993 # Determine main module list and tests-related module list separately.
2994 # The main module list is the transitive closure of the specified modules,
2995 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2996 # is specified, it will consist only of LGPLed source.
2997 # The tests-related module list is the transitive closure of the specified
2998 # modules, including tests modules, minus the main module list excluding
2999 # modules of applicability 'all'. Its lib/* sources (brought in through
3000 # dependencies of *-tests modules) go into $testsbase/. It may contain GPLed
3001 # source, even if --lgpl is specified.
3002 # Determine main module list.
3003 saved_inctests="$inctests"
3005 modules="$specified_modules"
3006 func_modules_transitive_closure
3007 main_modules="$modules"
3008 inctests="$saved_inctests"
3009 if test $verbose -ge 1; then
3010 echo "Main module list:"
3011 echo "$main_modules" | sed -e 's/^/ /'
3013 # Determine tests-related module list.
3014 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
3015 testsrelated_modules=`func_reset_sigpipe
3016 for module in $main_modules; do
3017 if test \`func_get_applicability $module\` = main; then
3021 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
3022 if test $verbose -ge 1; then
3023 echo "Tests-related module list:"
3024 echo "$testsrelated_modules" | sed -e 's/^/ /'
3027 # Add the dummy module to the main module list if needed.
3028 modules="$main_modules"
3029 func_modules_add_dummy
3030 main_modules="$modules"
3032 # Determine whether a $testsbase/libtests.a is needed.
3034 for module in $testsrelated_modules; do
3035 func_verify_nontests_module
3036 if test -n "$module"; then
3037 all_files=`func_get_filelist $module`
3038 # Test whether some file in $all_files lies in lib/.
3039 for f in $all_files; do
3050 # Add the dummy module to the tests-related module list if needed.
3051 if $use_libtests; then
3052 modules="$testsrelated_modules"
3053 func_modules_add_dummy
3054 testsrelated_modules="$modules"
3057 # If --lgpl, verify that the licenses of modules are compatible.
3058 if test -n "$lgpl"; then
3059 license_incompatibilities=
3060 for module in $main_modules; do
3061 license=`func_get_license $module`
3063 'GPLed build tool') ;;
3064 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3069 LGPL | LGPLv2+ | LGPLv3+) ;;
3070 *) func_append license_incompatibilities "$module $license$nl" ;;
3076 *) func_append license_incompatibilities "$module $license$nl" ;;
3079 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3084 if test -n "$license_incompatibilities"; then
3085 # Format the license incompatibilities as a table.
3086 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
3087 s,^\(.................................................[^ ]*\) *, \1 ,'
3088 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
3089 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
3093 # Show banner notice of every module.
3094 modules="$main_modules"
3097 # Determine script to apply to imported library files.
3098 sed_transform_lib_file=
3099 for module in $main_modules; do
3100 if test $module = config-h; then
3101 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
3102 sed_transform_lib_file=$sed_transform_lib_file'
3103 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
3108 sed_transform_main_lib_file="$sed_transform_lib_file"
3109 if test -n "$do_copyrights"; then
3110 if test -n "$lgpl"; then
3114 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3115 s/GNU General/GNU Lesser General/g
3119 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3120 s/GNU General/GNU Lesser General/g
3121 s/version [23]\([ ,]\)/version 2.1\1/g
3124 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
3128 sed_transform_main_lib_file=$sed_transform_main_lib_file'
3129 s/GNU Lesser General/GNU General/g
3130 s/GNU Library General/GNU General/g
3131 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3136 # Determine script to apply to auxiliary files that go into $auxdir/.
3137 sed_transform_build_aux_file=
3138 if test -n "$do_copyrights"; then
3140 sed_transform_build_aux_file=$sed_transform_build_aux_file'
3141 s/GNU Lesser General/GNU General/g
3142 s/GNU Library General/GNU General/g
3143 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3147 # Determine script to apply to library files that go into $testsbase/.
3148 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
3149 if test -n "$do_copyrights"; then
3151 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
3152 s/GNU Lesser General/GNU General/g
3153 s/GNU Library General/GNU General/g
3154 s/version 2\(.1\)\{0,1\}\([ ,]\)/version 3\2/g
3158 # Determine the final file lists.
3159 # They must be computed separately, because files in lib/* go into
3160 # $sourcebase/ if they are in the main file list but into $testsbase/
3161 # if they are in the tests-related file list. Furthermore lib/dummy.c
3163 # Determine final main file list.
3164 modules="$main_modules"
3165 func_modules_to_filelist
3167 # Determine final tests-related file list.
3168 modules="$testsrelated_modules"
3169 func_modules_to_filelist
3170 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
3171 # Merge both file lists.
3172 sed_remove_empty_lines='/^$/d'
3173 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
3174 if test $verbose -ge 0; then
3176 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
3177 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
3181 || func_fatal_error "refusing to do nothing"
3183 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
3184 new_files="$files m4/gnulib-tool.m4"
3185 old_files="$cached_files"
3186 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
3187 func_append old_files " m4/gnulib-tool.m4"
3190 rewritten='%REWRITTEN%'
3191 sed_rewrite_old_files="\
3192 s,^build-aux/,$rewritten$auxdir/,
3193 s,^doc/,$rewritten$cached_docbase/,
3194 s,^lib/,$rewritten$cached_sourcebase/,
3195 s,^m4/,$rewritten$cached_m4base/,
3196 s,^tests/,$rewritten$cached_testsbase/,
3197 s,^tests=lib/,$rewritten$cached_testsbase/,
3200 sed_rewrite_new_files="\
3201 s,^build-aux/,$rewritten$auxdir/,
3202 s,^doc/,$rewritten$docbase/,
3203 s,^lib/,$rewritten$sourcebase/,
3204 s,^m4/,$rewritten$m4base/,
3205 s,^tests/,$rewritten$testsbase/,
3206 s,^tests=lib/,$rewritten$testsbase/,
3210 # Create directories.
3211 { echo "$sourcebase"
3213 if test -n "$pobase"; then
3216 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
3217 if test -n "$docfiles"; then
3220 if test -n "$inctests"; then
3224 for f in $files; do echo $f; done \
3225 | sed -e "$sed_rewrite_new_files" \
3226 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3229 { # Rearrange file descriptors. Needed because "while ... done < ..."
3230 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3231 exec 5<&0 < "$tmp"/dirs
3233 if test ! -d "$destdir/$d"; then
3235 echo "Creating directory $destdir/$d"
3236 mkdir -p "$destdir/$d" || func_fatal_error "failed"
3238 echo "Create directory $destdir/$d"
3245 # Copy files or make symbolic links. Remove obsolete files.
3249 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3250 # representing the files according to the last gnulib-tool invocation.
3251 for f in $old_files; do echo $f; done \
3252 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
3255 # Construct a table with 2 columns: rewritten-file-name original-file-name,
3256 # representing the files after this gnulib-tool invocation.
3257 for f in $new_files; do echo $f; done \
3258 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
3261 # First the files that are in old-files, but not in new-files:
3262 sed_take_first_column='s,'"$delimiter"'.*,,'
3263 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
3264 # Remove the file. Do nothing if the user already removed it.
3265 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
3267 echo "Removing file $g (backup in ${g}~)"
3268 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
3270 echo "Remove file $g (backup in ${g}~)"
3272 func_append removed_files "$g$nl"
3275 # func_add_or_update handles a file that ought to be present afterwards.
3277 # - f the original file name
3278 # - g the rewritten file name
3279 # - already_present nonempty if the file should already exist, empty
3281 func_add_or_update ()
3285 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
3287 func_dest_tmpfilename "$g"
3288 func_lookup_file "$f"
3289 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
3290 if test -n "$sed_transform_main_lib_file"; then
3293 sed -e "$sed_transform_main_lib_file" \
3294 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3298 if test -n "$sed_transform_build_aux_file"; then
3301 sed -e "$sed_transform_build_aux_file" \
3302 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3306 if test -n "$sed_transform_testsrelated_lib_file"; then
3309 sed -e "$sed_transform_testsrelated_lib_file" \
3310 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
3314 if test -f "$destdir/$g"; then
3315 # The file already exists.
3319 # Don't protest if the file should be there but isn't: it happens
3320 # frequently that developers don't put autogenerated files into CVS.
3322 func_append added_files "$g$nl"
3326 # Then the files that are in new-files, but not in old-files:
3327 sed_take_last_column='s,^.*'"$delimiter"',,'
3329 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
3330 | sed -e "$sed_take_last_column" \
3331 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
3332 { # Rearrange file descriptors. Needed because "while ... done < ..."
3333 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3334 exec 5<&0 < "$tmp"/added-files
3340 # Then the files that are in new-files and in old-files:
3341 already_present=true
3342 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
3343 | sed -e "$sed_take_last_column" \
3344 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
3345 { # Rearrange file descriptors. Needed because "while ... done < ..."
3346 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3347 exec 5<&0 < "$tmp"/kept-files
3354 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
3355 actioncmd="gnulib-tool --import"
3356 func_append actioncmd " --dir=$destdir"
3357 if test -n "$local_gnulib_dir"; then
3358 func_append actioncmd " --local-dir=$local_gnulib_dir"
3360 func_append actioncmd " --lib=$libname"
3361 func_append actioncmd " --source-base=$sourcebase"
3362 func_append actioncmd " --m4-base=$m4base"
3363 if test -n "$pobase"; then
3364 func_append actioncmd " --po-base=$pobase"
3366 func_append actioncmd " --doc-base=$docbase"
3367 func_append actioncmd " --tests-base=$testsbase"
3368 func_append actioncmd " --aux-dir=$auxdir"
3369 if test -n "$inctests"; then
3370 func_append actioncmd " --with-tests"
3372 if test -n "$incobsolete"; then
3373 func_append actioncmd " --with-obsolete"
3375 for module in $avoidlist; do
3376 func_append actioncmd " --avoid=$module"
3378 if test -n "$lgpl"; then
3379 if test "$lgpl" = yes; then
3380 func_append actioncmd " --lgpl"
3382 func_append actioncmd " --lgpl=$lgpl"
3385 if test -n "$makefile_name"; then
3386 func_append actioncmd " --makefile-name=$makefile_name"
3388 if test "$libtool" = true; then
3389 func_append actioncmd " --libtool"
3391 func_append actioncmd " --no-libtool"
3393 func_append actioncmd " --macro-prefix=$macro_prefix"
3394 if test -n "$po_domain"; then
3395 func_append actioncmd " --po-domain=$po_domain"
3397 if test -n "$vc_files"; then
3398 if test "$vc_files" = true; then
3399 func_append actioncmd " --vc-files"
3401 func_append actioncmd " --no-vc-files"
3404 func_append actioncmd " `echo $specified_modules`"
3406 # Default the makefile name to Makefile.am.
3407 if test -n "$makefile_name"; then
3408 makefile_am=$makefile_name
3410 makefile_am=Makefile.am
3413 # Create normal Makefile.ams.
3416 # Setup list of Makefile.am edits that are to be performed afterwards.
3417 # Some of these edits apply to files that we will generate; others are
3418 # under the responsibility of the developer.
3420 # func_note_Makefile_am_edit dir var value
3421 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
3423 func_note_Makefile_am_edit ()
3425 makefile_am_edits=`expr $makefile_am_edits + 1`
3426 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
3427 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
3428 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
3430 if test "$makefile_am" = Makefile.am; then
3431 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3432 sourcebase_base=`basename "$sourcebase"`
3433 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
3435 if test -n "$pobase"; then
3436 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3437 pobase_base=`basename "$pobase"`
3438 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
3440 if test -n "$inctests"; then
3441 if test "$makefile_am" = Makefile.am; then
3442 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3443 testsbase_base=`basename "$testsbase"`
3444 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
3447 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
3449 # Find the first parent directory of $m4base that contains or will contain
3451 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
3453 sed_butlast='s,[^/][^/]*//*$,,'
3454 dir1="${m4base}/"; dir2=""
3455 while test -n "$dir1" \
3456 && ! { test -f "${destdir}/${dir1}Makefile.am" \
3457 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3458 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3459 || { test -n "$inctests" \
3460 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
3461 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
3462 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
3463 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
3465 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
3468 # Create library makefile.
3469 func_dest_tmpfilename $sourcebase/$makefile_am
3470 destfile="$sourcebase/$makefile_am"
3471 modules="$main_modules"
3472 func_emit_lib_Makefile_am > "$tmpfile"
3473 if test -f "$destdir"/$sourcebase/$makefile_am; then
3474 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
3478 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3479 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
3480 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3482 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3488 echo "Creating $sourcebase/$makefile_am"
3489 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3491 echo "Create $sourcebase/$makefile_am"
3494 func_append added_files "$sourcebase/$makefile_am$nl"
3497 # Create po/ directory.
3498 if test -n "$pobase"; then
3499 # Create po makefile and auxiliary files.
3500 for file in Makefile.in.in remove-potcdate.sin; do
3501 func_dest_tmpfilename $pobase/$file
3502 func_lookup_file build-aux/po/$file
3503 cat "$lookedup_file" > "$tmpfile"
3504 if test -f "$destdir"/$pobase/$file; then
3505 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
3509 echo "Updating $pobase/$file (backup in $pobase/$file~)"
3510 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
3511 mv -f "$tmpfile" "$destdir"/$pobase/$file
3513 echo "Update $pobase/$file (backup in $pobase/$file~)"
3519 echo "Creating $pobase/$file"
3520 mv -f "$tmpfile" "$destdir"/$pobase/$file
3522 echo "Create $pobase/$file"
3525 func_append added_files "$pobase/$file$nl"
3528 # Create po makefile parameterization, part 1.
3529 func_dest_tmpfilename $pobase/Makevars
3530 func_emit_po_Makevars > "$tmpfile"
3531 if test -f "$destdir"/$pobase/Makevars; then
3532 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
3536 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
3537 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
3538 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3540 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
3546 echo "Creating $pobase/Makevars"
3547 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3549 echo "Create $pobase/Makevars"
3552 func_append added_files "$pobase/Makevars$nl"
3554 # Create po makefile parameterization, part 2.
3555 func_dest_tmpfilename $pobase/POTFILES.in
3556 func_emit_po_POTFILES_in > "$tmpfile"
3557 if test -f "$destdir"/$pobase/POTFILES.in; then
3558 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
3562 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3563 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
3564 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3566 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3572 echo "Creating $pobase/POTFILES.in"
3573 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3575 echo "Create $pobase/POTFILES.in"
3578 func_append added_files "$pobase/POTFILES.in$nl"
3581 TP_URL="http://translationproject.org/latest/"
3582 TP_RSYNC_URI="translationproject.org::tp/latest/"
3584 echo "Fetching gnulib PO files from $TP_URL"
3585 (cd "$destdir"/$pobase \
3586 && { # Prefer rsync over wget if it is available, since it consumes
3587 # less network bandwidth, due to compression.
3588 if type rsync 2>/dev/null | grep / > /dev/null; then
3589 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
3591 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
3596 echo "Fetch gnulib PO files from $TP_URL"
3598 # Create po/LINGUAS.
3600 func_dest_tmpfilename $pobase/LINGUAS
3601 (cd "$destdir"/$pobase \
3602 && { echo '# Set of available languages.'
3603 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
3606 if test -f "$destdir"/$pobase/LINGUAS; then
3607 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
3610 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3611 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
3612 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3615 echo "Creating $pobase/LINGUAS"
3616 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3617 func_append added_files "$pobase/LINGUAS$nl"
3620 if test -f "$destdir"/$pobase/LINGUAS; then
3621 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3623 echo "Create $pobase/LINGUAS"
3628 # Create m4/gnulib-cache.m4.
3629 func_dest_tmpfilename $m4base/gnulib-cache.m4
3631 func_emit_copyright_notice
3633 echo "# This file represents the specification of how gnulib-tool is used."
3634 echo "# It acts as a cache: It is written and read by gnulib-tool."
3635 echo "# In projects using CVS, this file is meant to be stored in CVS,"
3636 echo "# like the configure.ac and various Makefile.am files."
3639 echo "# Specification in the form of a command-line invocation:"
3642 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
3643 # Store the local_gnulib_dir relative to destdir.
3644 case "$local_gnulib_dir" in
3646 relative_local_gnulib_dir="$local_gnulib_dir" ;;
3649 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
3651 # destdir, local_gnulib_dir are both relative.
3652 func_relativize "$destdir" "$local_gnulib_dir"
3653 relative_local_gnulib_dir="$reldir" ;;
3656 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
3658 echo "$specified_modules" | sed -e 's/^/ /g'
3660 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
3661 echo "gl_AVOID([$avoidlist])"
3662 echo "gl_SOURCE_BASE([$sourcebase])"
3663 echo "gl_M4_BASE([$m4base])"
3664 echo "gl_PO_BASE([$pobase])"
3665 echo "gl_DOC_BASE([$docbase])"
3666 echo "gl_TESTS_BASE([$testsbase])"
3667 test -z "$inctests" || echo "gl_WITH_TESTS"
3668 echo "gl_LIB([$libname])"
3669 if test -n "$lgpl"; then
3670 if test "$lgpl" = yes; then
3673 echo "gl_LGPL([$lgpl])"
3676 echo "gl_MAKEFILE_NAME([$makefile_name])"
3677 if test "$libtool" = true; then
3680 echo "gl_MACRO_PREFIX([$macro_prefix])"
3681 echo "gl_PO_DOMAIN([$po_domain])"
3682 if test -n "$vc_files"; then
3683 echo "gl_VC_FILES([$vc_files])"
3686 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3687 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
3691 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3692 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
3693 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3695 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3699 echo "# gnulib-cache.m4 ends here"
3706 echo "Creating $m4base/gnulib-cache.m4"
3707 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3709 echo "Create $m4base/gnulib-cache.m4"
3715 # Create m4/gnulib-comp.m4.
3716 func_dest_tmpfilename $m4base/gnulib-comp.m4
3718 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
3719 func_emit_copyright_notice
3721 echo "# This file represents the compiled summary of the specification in"
3722 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
3723 echo "# to be invoked from configure.ac."
3724 echo "# In projects using CVS, this file can be treated like other built files."
3727 echo "# This macro should be invoked from $configure_ac, in the section"
3728 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
3729 echo "# any checks for libraries, header files, types and library functions."
3730 echo "AC_DEFUN([${macro_prefix}_EARLY],"
3732 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3733 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3734 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3735 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3736 echo " AC_REQUIRE([AC_PROG_RANLIB])"
3737 if test -n "$uses_subdirs"; then
3738 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
3740 for module in $final_modules; do
3742 if test -n "$module"; then
3743 func_get_autoconf_early_snippet "$module"
3746 | sed -e '/^$/d;' -e 's/^/ /'
3749 echo "# This macro should be invoked from $configure_ac, in the section"
3750 echo "# \"Check for header files, types and library functions\"."
3751 echo "AC_DEFUN([${macro_prefix}_INIT],"
3753 if test "$libtool" = true; then
3754 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3755 echo " gl_cond_libtool=true"
3757 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3758 echo " gl_cond_libtool=false"
3760 echo " gl_ltlibdeps="
3762 if test "$auxdir" != "build-aux"; then
3763 sed_replace_build_aux='
3765 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3766 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3770 sed_replace_build_aux="$sed_noop"
3772 func_emit_initmacro_start $macro_prefix
3773 echo " gl_source_base='$sourcebase'"
3774 for module in $main_modules; do
3776 if test -n "$module"; then
3777 func_get_autoconf_snippet "$module" \
3778 | sed -e '/^$/d;' -e 's/^/ /' \
3779 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3780 -e "$sed_replace_build_aux"
3781 if test "$module" = 'alloca' && test "$libtool" = true; then
3782 echo 'changequote(,)dnl'
3783 echo 'LTALLOCA=`echo "$ALLOCA" | sed -e '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3784 echo 'changequote([, ])dnl'
3785 echo 'AC_SUBST([LTALLOCA])'
3789 func_emit_initmacro_end $macro_prefix
3790 echo " gltests_libdeps="
3791 echo " gltests_ltlibdeps="
3792 func_emit_initmacro_start ${macro_prefix}tests
3793 echo " gl_source_base='$testsbase'"
3794 for module in $testsrelated_modules; do
3796 if test -n "$module"; then
3797 func_get_autoconf_snippet "$module" \
3798 | sed -e '/^$/d;' -e 's/^/ /' \
3799 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3800 -e "$sed_replace_build_aux" \
3801 -e 's/\$gl_cond_libtool/false/g' \
3802 -e 's/gl_libdeps/gltests_libdeps/g' \
3803 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3806 func_emit_initmacro_end ${macro_prefix}tests
3807 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3808 # created using libtool, because libtool already handles the dependencies.
3809 if test "$libtool" != true; then
3810 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3811 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3812 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3813 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3814 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3816 if $use_libtests; then
3817 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
3818 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
3821 func_emit_initmacro_done $macro_prefix $sourcebase
3822 func_emit_initmacro_done ${macro_prefix}tests $testsbase
3824 echo "# This macro records the list of files which have been installed by"
3825 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
3826 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
3827 echo "$files" | sed -e 's,^, ,'
3830 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3831 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
3835 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3836 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
3837 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3839 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3843 echo "# gnulib-comp.m4 ends here"
3850 echo "Creating $m4base/gnulib-comp.m4"
3851 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3853 echo "Create $m4base/gnulib-comp.m4"
3859 if test -n "$inctests"; then
3860 # Create tests makefile.
3861 func_dest_tmpfilename $testsbase/$makefile_am
3862 destfile="$testsbase/$makefile_am"
3863 modules="$testsrelated_modules"
3864 func_emit_tests_Makefile_am > "$tmpfile"
3865 if test -f "$destdir"/$testsbase/$makefile_am; then
3866 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
3870 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3871 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
3872 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3874 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3880 echo "Creating $testsbase/$makefile_am"
3881 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3883 echo "Create $testsbase/$makefile_am"
3886 func_append added_files "$testsbase/$makefile_am$nl"
3890 if test "$vc_files" != false; then
3891 # Update the .cvsignore and .gitignore files.
3892 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
3893 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
3894 # Treat gnulib-comp.m4 like an added file, even if it already existed.
3895 echo "$m4base/|A|gnulib-comp.m4"
3896 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
3897 { # Rearrange file descriptors. Needed because "while ... done < ..."
3898 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3899 exec 5<&0 < "$tmp"/fileset-changes
3900 func_update_ignorelist ()
3903 if test "$ignore" = .gitignore; then
3904 # In a .gitignore file, "foo" applies to the current directory and all
3905 # subdirectories, whereas "/foo" applies to the current directory only.
3908 doubly_escaped_anchor='\\/'
3912 doubly_escaped_anchor=''
3914 if test -f "$destdir/$dir$ignore"; then
3915 if test -n "$dir_added" || test -n "$dir_removed"; then
3916 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
3918 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
3919 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
3920 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
3921 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
3923 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
3925 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3926 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
3927 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
3928 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
3929 } > "$tmp"/sed-ignore-removed
3930 { cat "$destdir/$dir$ignore"~
3931 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
3932 } | sed -f "$tmp"/sed-ignore-removed \
3933 > "$destdir/$dir$ignore"
3935 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3940 if test -n "$dir_added"; then
3942 echo "Creating $destdir/$dir$ignore"
3944 if test "$ignore" = .cvsignore; then
3946 # Automake generates Makefile rules that create .dirstamp files.
3949 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
3950 } > "$destdir/$dir$ignore"
3952 echo "Create $destdir/$dir$ignore"
3962 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
3963 func_update_ignorelist .cvsignore
3965 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
3966 func_update_ignorelist .gitignore
3973 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
3974 next_dir=`echo "$line" | sed -e 's,|.*,,'`
3975 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
3976 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
3977 if test "$next_dir" != "$last_dir"; then
3978 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3979 last_dir="$next_dir"
3984 A) func_append last_dir_added "$file$nl";;
3985 R) func_append last_dir_removed "$file$nl";;
3988 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3995 echo "You may need to add #include directives for the following .h files."
3996 # Intersect $specified_modules and $main_modules
3997 # (since $specified_modules is not necessarily of subset of $main_modules
3998 # - some may have been skipped through --avoid, and since the elements of
3999 # $main_modules but not in $specified_modules can go away without explicit
4000 # notice - through changes in the module dependencies).
4001 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
4002 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
4003 # First the #include <...> directives without #ifs, sorted for convenience,
4004 # then the #include "..." directives without #ifs, sorted for convenience,
4005 # then the #include directives that are surrounded by #ifs. Not sorted.
4006 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
4007 include_directive=`func_get_include_directive "$module"`
4008 case "$nl$include_directive" in
4010 echo "$include_directive" 1>&5
4013 echo "$include_directive" | grep -v 'include "' 1>&6
4014 echo "$include_directive" | grep 'include "' 1>&7
4017 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
4019 LC_ALL=C sort -u "$tmp"/include-angles
4020 LC_ALL=C sort -u "$tmp"/include-quotes
4021 cat "$tmp"/include-if
4022 ) | sed -e '/^$/d' -e 's/^/ /'
4023 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
4025 for module in $main_modules; do
4026 func_get_link_directive "$module"
4028 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
4029 if test `wc -l < "$tmp"/link` != 0; then
4031 echo "You may need to use the following Makefile variables when linking."
4032 echo "Use them in <program>_LDADD when linking a program, or"
4033 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
4039 echo "Don't forget to"
4040 if test "$makefile_am" = Makefile.am; then
4041 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4043 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
4045 if test -n "$pobase"; then
4046 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
4048 if test -n "$inctests"; then
4049 if test "$makefile_am" = Makefile.am; then
4050 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
4052 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
4056 while test $edit != $makefile_am_edits; do
4057 edit=`expr $edit + 1`
4058 eval dir=\"\$makefile_am_edit${edit}_dir\"
4059 eval var=\"\$makefile_am_edit${edit}_var\"
4060 eval val=\"\$makefile_am_edit${edit}_val\"
4061 if test -n "$var"; then
4062 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
4065 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
4066 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
4069 # func_create_testdir testdir modules
4071 # - local_gnulib_dir from --local-dir
4072 # - auxdir directory relative to destdir where to place build aux files
4073 func_create_testdir ()
4077 if test -z "$modules"; then
4078 # All modules together.
4079 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4080 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
4081 modules=`func_all_modules`
4082 modules=`for m in $modules; do case $m in config-h | ftruncate | mountlist) ;; *) echo $m;; esac; done`
4084 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
4086 # Check that the license of every module is consistent with the license of
4088 saved_modules="$modules"
4089 saved_inctests="$inctests"
4090 # When computing transitive closures, don't consider $module to depend on
4091 # $module-tests. Need this becauses tests are implicitly GPL and may depend
4092 # on GPL modules - therefore we don't want a warning in this case.
4094 for requested_module in $saved_modules; do
4095 requested_license=`func_get_license "$requested_module"`
4096 if test "$requested_license" != GPL; then
4097 # Here we use func_modules_transitive_closure, not just
4098 # func_get_dependencies, so that we also detect weird situations like
4099 # an LGPL module which depends on a GPLed build tool module which depends
4101 modules="$requested_module"
4102 func_modules_transitive_closure
4103 for module in $modules; do
4104 license=`func_get_license "$module"`
4106 'GPLed build tool') ;;
4107 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
4109 case "$requested_license" in
4112 GPLv2+ | LGPLv2+) ;;
4113 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4119 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4125 *) func_warning "module $requested_module depends on a module with an incompatible license: $module" ;;
4134 modules="$saved_modules"
4135 inctests="$saved_inctests"
4137 # Subdirectory names.
4147 # Determine final module list.
4148 func_modules_transitive_closure
4149 if test $verbose -ge 0; then
4150 echo "Module list with included dependencies:"
4151 echo "$modules" | sed -e 's/^/ /'
4154 # Add the dummy module if needed.
4155 func_modules_add_dummy
4157 # Show banner notice of every module.
4160 # Determine final file list.
4161 func_modules_to_filelist
4162 if test $verbose -ge 0; then
4164 echo "$files" | sed -e 's/^/ /'
4167 rewritten='%REWRITTEN%'
4168 sed_rewrite_files="\
4169 s,^build-aux/,$rewritten$auxdir/,
4170 s,^doc/,$rewritten$docbase/,
4171 s,^lib/,$rewritten$sourcebase/,
4172 s,^m4/,$rewritten$m4base/,
4173 s,^tests/,$rewritten$testsbase/,
4177 # Create directories.
4178 for f in $files; do echo $f; done \
4179 | sed -e "$sed_rewrite_files" \
4180 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
4181 | LC_ALL=C sort -u \
4183 { # Rearrange file descriptors. Needed because "while ... done < ..."
4184 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4185 exec 5<&0 < "$tmp"/dirs
4187 mkdir -p "$testdir/$d"
4192 # Copy files or make symbolic links.
4194 for f in $files; do echo $f; done \
4195 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
4198 { # Rearrange file descriptors. Needed because "while ... done < ..."
4199 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
4200 exec 5<&0 < "$tmp"/files
4202 func_lookup_file "$f"
4203 if test -n "$lookedup_tmp"; then
4204 cp -p "$lookedup_file" "$testdir/$g"
4206 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
4207 if { test -n "$symbolic" \
4208 || { test -n "$lsymbolic" \
4209 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
4210 func_ln "$lookedup_file" "$testdir/$g"
4212 cp -p "$lookedup_file" "$testdir/$g"
4219 # Create Makefile.ams that are for testing.
4222 # No special edits are needed.
4225 # Create $sourcebase/Makefile.am.
4226 mkdir -p "$testdir/$sourcebase"
4227 destfile="$sourcebase/Makefile.am"
4228 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
4229 any_uses_subdirs="$uses_subdirs"
4231 # Create $m4base/Makefile.am.
4232 mkdir -p "$testdir/$m4base"
4233 (echo "## Process this file with automake to produce Makefile.in."
4239 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
4242 ) > "$testdir/$m4base/Makefile.am"
4244 subdirs="$sourcebase $m4base"
4245 subdirs_with_configure_ac=""
4247 if false && test -f "$testdir"/$m4base/gettext.m4; then
4248 # Avoid stupid error message from automake:
4249 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
4250 mkdir -p "$testdir/po"
4251 (echo "## Process this file with automake to produce Makefile.in."
4252 ) > "$testdir/po/Makefile.am"
4253 func_append subdirs " po"
4256 if test -n "$inctests"; then
4257 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
4258 # Viewed from the $testsbase subdirectory, $auxdir is different.
4259 saved_auxdir="$auxdir"
4260 auxdir=`echo "$testsbase/" | sed -e 's%[^/][^/]*//*%../%g'`"$auxdir"
4261 # Create $testsbase/Makefile.am.
4263 destfile="$testsbase/Makefile.am"
4264 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
4265 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
4266 # Create $testsbase/configure.ac.
4267 (echo "# Process this file with autoconf to produce a configure script."
4268 echo "AC_INIT([dummy], [0])"
4269 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4270 echo "AM_INIT_AUTOMAKE"
4272 echo "AC_CONFIG_HEADERS([config.h])"
4275 echo "AC_PROG_INSTALL"
4276 echo "AC_PROG_MAKE_SET"
4277 echo "AC_PROG_RANLIB"
4279 if test -n "$uses_subdirs"; then
4280 echo "AM_PROG_CC_C_O"
4283 for module in $modules; do
4285 if test -n "$module"; then
4287 gnumakefile | maintainer-makefile)
4288 # These modules are meant to be used only in the top-level directory.
4291 func_get_autoconf_early_snippet "$module"
4296 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4297 if test "$libtool" = true; then
4298 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4299 echo "gl_cond_libtool=true"
4301 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4302 echo "gl_cond_libtool=false"
4304 echo "gl_ltlibdeps="
4306 # Wrap the set of autoconf snippets into an autoconf macro that is then
4307 # invoked. This is needed because autoconf does not support AC_REQUIRE
4309 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4310 # but we want the AC_REQUIRE to have its normal meaning (provide one
4311 # expansion of the required macro before the current point, and only one
4313 echo "AC_DEFUN([gl_INIT], ["
4314 sed_replace_build_aux='
4316 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4317 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4320 func_emit_initmacro_start $macro_prefix
4321 # We don't have explicit ordering constraints between the various
4322 # autoconf snippets. It's cleanest to put those of the library before
4323 # those of the tests.
4324 echo "gl_source_base='../$sourcebase'"
4325 for module in $modules; do
4326 func_verify_nontests_module
4327 if test -n "$module"; then
4329 gnumakefile | maintainer-makefile)
4330 # These modules are meant to be used only in the top-level directory.
4333 func_get_autoconf_snippet "$module" \
4334 | sed -e "$sed_replace_build_aux"
4339 echo "gl_source_base='.'"
4340 for module in $modules; do
4341 func_verify_tests_module
4342 if test -n "$module"; then
4343 func_get_autoconf_snippet "$module" \
4344 | sed -e "$sed_replace_build_aux"
4347 func_emit_initmacro_end $macro_prefix
4348 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4349 # created using libtool, because libtool already handles the dependencies.
4350 if test "$libtool" != true; then
4351 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4352 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4353 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4354 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4355 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4358 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
4362 # Usually $testsbase/config.h will be a superset of config.h. Verify this
4363 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
4364 echo "AH_TOP([#include \"../config.h\"])"
4366 echo "AC_CONFIG_FILES([Makefile])"
4368 ) > "$testdir/$testsbase/configure.ac"
4369 auxdir="$saved_auxdir"
4370 func_append subdirs " $testsbase"
4371 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
4374 # Create Makefile.am.
4375 (echo "## Process this file with automake to produce Makefile.in."
4377 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4379 echo "SUBDIRS = $subdirs"
4381 echo "ACLOCAL_AMFLAGS = -I $m4base"
4382 ) > "$testdir/Makefile.am"
4384 # Create configure.ac.
4385 (echo "# Process this file with autoconf to produce a configure script."
4386 echo "AC_INIT([dummy], [0])"
4387 if test "$auxdir" != "."; then
4388 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4390 echo "AM_INIT_AUTOMAKE"
4392 echo "AC_CONFIG_HEADERS([config.h])"
4395 echo "AC_PROG_INSTALL"
4396 echo "AC_PROG_MAKE_SET"
4398 echo "# For autobuild."
4399 echo "AC_CANONICAL_BUILD"
4400 echo "AC_CANONICAL_HOST"
4402 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4403 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4404 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4405 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4407 echo "AC_PROG_RANLIB"
4409 if test -n "$any_uses_subdirs"; then
4410 echo "AM_PROG_CC_C_O"
4413 for module in $modules; do
4414 func_verify_nontests_module
4415 if test -n "$module"; then
4416 func_get_autoconf_early_snippet "$module"
4419 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4420 if test "$libtool" = true; then
4421 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4422 echo "gl_cond_libtool=true"
4424 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4425 echo "gl_cond_libtool=false"
4427 echo "gl_ltlibdeps="
4429 # Wrap the set of autoconf snippets into an autoconf macro that is then
4430 # invoked. This is needed because autoconf does not support AC_REQUIRE
4432 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4433 # but we want the AC_REQUIRE to have its normal meaning (provide one
4434 # expansion of the required macro before the current point, and only one
4436 echo "AC_DEFUN([gl_INIT], ["
4437 if test "$auxdir" != "build-aux"; then
4438 sed_replace_build_aux='
4440 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4441 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4445 sed_replace_build_aux="$sed_noop"
4447 func_emit_initmacro_start $macro_prefix
4448 echo "gl_source_base='$sourcebase'"
4449 for module in $modules; do
4450 func_verify_nontests_module
4451 if test -n "$module"; then
4452 func_get_autoconf_snippet "$module" \
4453 | sed -e "$sed_replace_build_aux"
4456 func_emit_initmacro_end $macro_prefix
4457 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4458 # created using libtool, because libtool already handles the dependencies.
4459 if test "$libtool" != true; then
4460 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4461 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4462 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4463 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4464 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4467 func_emit_initmacro_done $macro_prefix $sourcebase
4471 if test -n "$subdirs_with_configure_ac"; then
4472 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
4474 makefiles="Makefile"
4475 for d in $subdirs; do
4476 # For subdirs that have a configure.ac by their own, it's the subdir's
4477 # configure.ac which creates the subdir's Makefile.am, not this one.
4478 case " $subdirs_with_configure_ac " in
4480 *) func_append makefiles " $d/Makefile" ;;
4483 echo "AC_CONFIG_FILES([$makefiles])"
4485 ) > "$testdir/configure.ac"
4487 # Create autogenerated files.
4489 # Do not use "${AUTORECONF} --force --install", because it may invoke
4490 # autopoint, which brings in older versions of some of our .m4 files.
4491 if test -f $m4base/gettext.m4; then
4492 func_execute_command ${AUTOPOINT} --force || func_exit 1
4493 for f in $m4base/*.m4~; do
4495 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4499 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
4500 if ! test -d build-aux; then
4501 func_execute_command mkdir build-aux || func_exit 1
4503 func_execute_command ${AUTOCONF} || func_exit 1
4504 func_execute_command ${AUTOHEADER} || func_exit 1
4505 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4507 if test -n "$inctests"; then
4508 # Create autogenerated files.
4509 (cd "$testdir/$testsbase" || func_exit 1
4510 # Do not use "${AUTORECONF} --force --install", because it may invoke
4511 # autopoint, which brings in older versions of some of our .m4 files.
4512 if test -f ../$m4base/gettext.m4; then
4513 func_execute_command ${AUTOPOINT} --force || func_exit 1
4514 for f in ../$m4base/*.m4~; do
4516 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4520 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
4521 if ! test -d ../build-aux; then
4522 func_execute_command mkdir ../build-aux
4524 func_execute_command ${AUTOCONF} || func_exit 1
4525 func_execute_command ${AUTOHEADER} || func_exit 1
4526 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4529 # Need to run configure and make once, to create built files that are to be
4530 # distributed (such as getdate.c).
4531 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
4532 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4533 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
4534 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
4535 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
4536 # such $(FOO_H) because they don't refer to distributed files.
4537 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
4538 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4539 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
4540 | sed -e "$sed_remove_make_variables"`
4541 distributed_built_sources=`for file in $built_sources; do
4542 case "$cleaned_files" in
4547 if test -n "$distributed_built_sources"; then
4549 ./configure || func_exit 1
4551 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
4552 $MAKE built_sources || func_exit 1
4554 $MAKE distclean || func_exit 1
4559 # func_create_megatestdir megatestdir allmodules
4561 # - local_gnulib_dir from --local-dir
4562 # - auxdir directory relative to destdir where to place build aux files
4563 func_create_megatestdir ()
4567 if test -z "$allmodules"; then
4568 allmodules=`func_all_modules`
4572 # First, all modules one by one.
4573 for onemodule in $allmodules; do
4574 func_create_testdir "$megatestdir/$onemodule" $onemodule
4575 func_append megasubdirs "$onemodule "
4577 # Then, all modules all together.
4578 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4579 allmodules=`for m in $allmodules; do if test $m != config-h; then echo $m; fi; done`
4580 func_create_testdir "$megatestdir/ALL" "$allmodules"
4581 func_append megasubdirs "ALL"
4584 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
4585 vc_witness="$gnulib_dir/CVS/Entries"; \
4587 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
4589 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
4590 | sed -e 's,January,01,' -e 's,Jan,01,' \
4591 -e 's,February,02,' -e 's,Feb,02,' \
4592 -e 's,March,03,' -e 's,Mar,03,' \
4593 -e 's,April,04,' -e 's,Apr,04,' \
4595 -e 's,June,06,' -e 's,Jun,06,' \
4596 -e 's,July,07,' -e 's,Jul,07,' \
4597 -e 's,August,08,' -e 's,Aug,08,' \
4598 -e 's,September,09,' -e 's,Sep,09,' \
4599 -e 's,October,10,' -e 's,Oct,10,' \
4600 -e 's,November,11,' -e 's,Nov,11,' \
4601 -e 's,December,12,' -e 's,Dec,12,' \
4602 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
4603 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
4605 echo "CVSDATE=$cvsdate"
4606 echo ": \${MAKE=make}"
4607 echo "test -d logs || mkdir logs"
4608 echo "for module in $megasubdirs; do"
4609 echo " echo \"Working on module \$module...\""
4610 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
4611 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
4614 echo " : autobuild project... \$module"
4615 echo " : autobuild revision... cvs-\$CVSDATE-000000"
4616 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
4617 echo " : autobuild hostname... \`hostname\`"
4618 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && \$MAKE && \$MAKE check && \$MAKE distclean"
4620 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
4622 ) > "$megatestdir/do-autobuild"
4623 chmod a+x "$megatestdir/do-autobuild"
4625 # Create Makefile.am.
4626 (echo "## Process this file with automake to produce Makefile.in."
4628 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4630 echo "SUBDIRS = $megasubdirs"
4632 echo "EXTRA_DIST = do-autobuild"
4633 ) > "$megatestdir/Makefile.am"
4635 # Create configure.ac.
4636 (echo "# Process this file with autoconf to produce a configure script."
4637 echo "AC_INIT([dummy], [0])"
4638 if test "$auxdir" != "."; then
4639 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4641 echo "AM_INIT_AUTOMAKE"
4643 echo "AC_PROG_MAKE_SET"
4645 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
4646 echo "AC_CONFIG_FILES([Makefile])"
4648 ) > "$megatestdir/configure.ac"
4650 # Create autogenerated files.
4652 # Do not use "${AUTORECONF} --install", because autoreconf operates
4653 # recursively, but the subdirectories are already finished, therefore
4654 # calling autoreconf here would only waste lots of CPU time.
4655 func_execute_command ${ACLOCAL} || func_exit 1
4656 func_execute_command mkdir build-aux
4657 func_execute_command ${AUTOCONF} || func_exit 1
4658 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4664 func_fatal_error "no mode specified" ;;
4673 if test -z "$destdir"; then
4676 test -d "$destdir" \
4677 || func_fatal_error "destination directory does not exist: $destdir"
4679 # Prefer configure.ac to configure.in.
4680 if test -f "$destdir"/configure.ac; then
4681 configure_ac="$destdir/configure.ac"
4683 if test -f "$destdir"/configure.in; then
4684 configure_ac="$destdir/configure.in"
4686 func_fatal_error "cannot find $destdir/configure.ac - make sure you run gnulib-tool from within your package's directory"
4690 # Analyze configure.ac.
4692 guessed_libtool=false
4697 /AC_CONFIG_AUX_DIR/ {
4698 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
4700 /A[CM]_PROG_LIBTOOL/ {
4701 s,^.*$,guessed_libtool=true,p
4703 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
4705 if test -z "$auxdir"; then
4706 auxdir="$guessed_auxdir"
4709 # Determine where to apply func_import.
4710 if test -n "$m4base"; then
4711 # Apply func_import to a particular gnulib directory.
4712 # Any number of additional modules can be given.
4713 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
4714 # First use of gnulib in the given m4base.
4715 test -n "$supplied_libname" || supplied_libname=true
4716 test -n "$sourcebase" || sourcebase="lib"
4717 test -n "$docbase" || docbase="doc"
4718 test -n "$testsbase" || testsbase="tests"
4719 test -n "$macro_prefix" || macro_prefix="gl"
4723 # Apply func_import to all gnulib directories.
4724 # To get this list of directories, look at Makefile.am. (Not at
4725 # configure, because it may be omitted from CVS. Also, don't run
4726 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
4729 if test -f "$destdir"/Makefile.am; then
4730 aclocal_amflags=`sed -n -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
4732 for arg in $aclocal_amflags; do
4733 if test -n "$m4dir_is_next"; then
4734 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
4738 if test -f "$destdir/$arg"/gnulib-cache.m4; then
4739 func_append m4dirs " $arg"
4740 m4dirs_count=`expr $m4dirs_count + 1`
4746 if test "X$arg" = "X-I"; then
4754 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
4755 if test -f "$destdir"/aclocal.m4; then
4756 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
4757 sedexpr2='s,^[^/]*$,.,'
4758 sedexpr3='s,/[^/]*$,,'
4759 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
4760 m4dirs_count=`printf %s "$m4dirs" | wc -l`
4763 if test $m4dirs_count = 0; then
4764 # First use of gnulib in a package.
4765 # Any number of additional modules can be given.
4766 test -n "$supplied_libname" || supplied_libname=true
4767 test -n "$sourcebase" || sourcebase="lib"
4769 test -n "$docbase" || docbase="doc"
4770 test -n "$testsbase" || testsbase="tests"
4771 test -n "$macro_prefix" || macro_prefix="gl"
4774 if test $m4dirs_count = 1; then
4775 # There's only one use of gnulib here. Assume the user means it.
4776 # Any number of additional modules can be given.
4777 for m4base in $m4dirs; do
4781 # Ambiguous - guess what the user meant.
4782 if test $# = 0; then
4783 # No further arguments. Guess the user wants to update all of them.
4784 for m4base in $m4dirs; do
4785 # Perform func_import in a subshell, so that variable values
4787 # local_gnulib_dir, incobsolete, avoidlist, sourcebase, m4base,
4788 # pobase, docbase, testsbase, inctests, libname, lgpl,
4789 # makefile_name, libtool, macro_prefix, po_domain, vc_files
4790 # don't propagate from one directory to another.
4791 (func_import) || func_exit 1
4795 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
4803 if test -z "$destdir"; then
4804 func_fatal_error "please specify --dir option"
4807 test -d "$destdir" \
4808 || func_fatal_error "could not create destination directory"
4809 test -n "$auxdir" || auxdir="build-aux"
4810 func_create_testdir "$destdir" "$*"
4813 create-megatestdir )
4814 if test -z "$destdir"; then
4815 func_fatal_error "please specify --dir option"
4817 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4818 test -n "$auxdir" || auxdir="build-aux"
4819 func_create_megatestdir "$destdir" "$*"
4823 test -n "$destdir" || destdir=testdir$$
4824 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4825 test -n "$auxdir" || auxdir="build-aux"
4826 func_create_testdir "$destdir" "$*"
4830 ../configure || func_exit 1
4831 $MAKE || func_exit 1
4832 $MAKE check || func_exit 1
4833 $MAKE distclean || func_exit 1
4834 remaining=`find . -type f -print`
4835 if test -n "$remaining"; then
4836 echo "Remaining files:" $remaining 1>&2
4837 echo "gnulib-tool: *** Stop." 1>&2
4846 test -n "$destdir" || destdir=testdir$$
4847 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4848 test -n "$auxdir" || auxdir="build-aux"
4849 func_create_megatestdir "$destdir" "$*"
4857 remaining=`find . -type f -print`
4858 if test -n "$remaining"; then
4859 echo "Remaining files:" $remaining 1>&2
4860 echo "gnulib-tool: *** Stop." 1>&2
4868 extract-description )
4872 if test -n "$module"; then
4873 func_get_description "$module"
4882 if test -n "$module"; then
4883 func_get_status "$module"
4892 if test -n "$module"; then
4893 func_get_notice "$module"
4898 extract-applicability )
4902 if test -n "$module"; then
4903 func_get_applicability "$module"
4912 if test -n "$module"; then
4913 func_get_filelist "$module"
4918 extract-dependencies )
4922 if test -n "$module"; then
4923 func_get_dependencies "$module"
4928 extract-autoconf-snippet )
4932 if test -n "$module"; then
4933 func_get_autoconf_snippet "$module"
4938 extract-automake-snippet )
4942 if test -n "$module"; then
4943 func_get_automake_snippet "$module"
4948 extract-include-directive )
4952 if test -n "$module"; then
4953 func_get_include_directive "$module"
4958 extract-link-directive )
4962 if test -n "$module"; then
4963 func_get_link_directive "$module"
4972 if test -n "$module"; then
4973 func_get_license "$module"
4978 extract-maintainer )
4982 if test -n "$module"; then
4983 func_get_maintainer "$module"
4988 extract-tests-module )
4992 if test -n "$module"; then
4993 func_get_tests_module "$module"
4999 # Verify the number of arguments.
5000 if test $# -lt 1 || test $# -gt 2; then
5001 func_fatal_error "invalid number of arguments for --$mode"
5004 # The first argument is the file to be copied.
5006 # Verify the file exists.
5007 func_lookup_file "$f"
5009 # The second argument is the destination; either a directory ot a file.
5010 # It defaults to the current directory.
5012 test -n "$dest" || dest='.'
5013 test -n "$sourcebase" || sourcebase="lib"
5014 test -n "$m4base" || m4base="m4"
5015 test -n "$docbase" || docbase="doc"
5016 test -n "$testsbase" || testsbase="tests"
5017 test -n "$auxdir" || auxdir="build-aux"
5018 rewritten='%REWRITTEN%'
5019 sed_rewrite_files="\
5020 s,^build-aux/,$rewritten$auxdir/,
5021 s,^doc/,$rewritten$docbase/,
5022 s,^lib/,$rewritten$sourcebase/,
5023 s,^m4/,$rewritten$m4base/,
5024 s,^tests/,$rewritten$testsbase/,
5027 if test -d "$dest"; then
5029 g=`echo "$f" | sed -e "$sed_rewrite_files"`
5031 destdir=`dirname "$dest"`
5032 g=`basename "$dest"`
5035 # Create the directory for destfile.
5036 d=`dirname "$destdir/$g"`
5038 if test -n "$d" && test ! -d "$d"; then
5039 mkdir -p "$d" || func_fatal_error "failed"
5043 func_dest_tmpfilename "$g"
5044 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
5045 already_present=true
5046 if test -f "$destdir/$g"; then
5047 # The file already exists.
5051 # Don't protest if the file should be there but isn't: it happens
5052 # frequently that developers don't put autogenerated files into CVS.
5059 func_fatal_error "unknown operation mode --$mode" ;;
5063 # Undo the effect of the previous 'trap' command. Some shellology:
5064 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
5065 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
5066 # exit); for the others we need to call 'exit' explicitly. The value of $? is
5067 # 128 + signal number and is set before the trap-registered command is run.
5069 trap 'func_exit $?' 1 2 3 13 15
5074 # indent-tabs-mode: nil
5075 # whitespace-check-buffer-indent: nil