3 # Copyright (C) 2002-2009 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"
66 # Disabled because "sed --posix" is buggy in GNU sed 4.1.5, see
67 # <http://lists.gnu.org/archive/html/bug-gnulib/2009-02/msg00225.html>.
69 # When using GNU sed, turn off as many GNU extensions as possible,
70 # to minimize the risk of accidentally using non-portable features.
71 # However, do this only for gnulib-tool itself, not for the code that
72 # gnulib-tool generates, since we don't want "sed --posix" to leak
74 if (alias) > /dev/null 2>&1 && echo | sed --posix -e d >/dev/null 2>&1; then
75 # Define sed as an alias.
76 # It is not always possible to use aliases. Aliases are guaranteed to work
77 # if the executing shell is bash and either it is invoked as /bin/sh or
78 # is a version >= 2.0, supporting shopt. This is the common case.
79 # Two other approaches (use of a variable $sed or of a function func_sed
80 # instead of an alias) require massive, fragile code changes.
81 # An other approach (use of function sed) requires `which sed` - but
82 # 'which' is hard to emulate, due to missing "test -x" on some platforms.
83 if test -n "$BASH_VERSION"; then
84 shopt -s expand_aliases >/dev/null 2>&1
86 alias sed='sed --posix'
90 # sed_noop is a sed expression that does nothing.
91 # An empty expression does not work with the native 'sed' on AIX 6.1.
95 # outputs to stdout the --help usage message.
99 Usage: gnulib-tool --list
100 gnulib-tool --import [module1 ... moduleN]
102 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
103 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
104 gnulib-tool --test --dir=directory module1 ... moduleN
105 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
106 gnulib-tool --extract-description module
107 gnulib-tool --extract-status module
108 gnulib-tool --extract-notice module
109 gnulib-tool --extract-filelist module
110 gnulib-tool --extract-dependencies module
111 gnulib-tool --extract-autoconf-snippet module
112 gnulib-tool --extract-automake-snippet module
113 gnulib-tool --extract-include-directive module
114 gnulib-tool --extract-link-directive module
115 gnulib-tool --extract-license module
116 gnulib-tool --extract-maintainer module
117 gnulib-tool --extract-tests-module module
120 --list print the available module names
121 --import import the given modules into the current package;
122 if no modules are specified, update the current
123 package from the current gnulib
124 --update update the current package, restore files omitted
126 --create-testdir create a scratch package with the given modules
127 --create-megatestdir create a mega scratch package with the given modules
128 one by one and all together
129 --test test the combination of the given modules
130 (recommended to use CC=\"gcc -Wall\" here)
131 --megatest test the given modules one by one and all together
132 (recommended to use CC=\"gcc -Wall\" here)
133 --extract-description extract the description
134 --extract-status extract the status (obsolete or not)
135 --extract-notice extract the notice or banner
136 --extract-filelist extract the list of files
137 --extract-dependencies extract the dependencies
138 --extract-autoconf-snippet extract the snippet for configure.ac
139 --extract-automake-snippet extract the snippet for library makefile
140 --extract-include-directive extract the #include directive
141 --extract-link-directive extract the linker directive
142 --extract-license report the license terms of the source files
144 --extract-maintainer report the maintainer(s) inside gnulib
145 --extract-tests-module report the unit test module, if it exists
148 --dir=DIRECTORY Specify the target directory.
149 For --import, this specifies where your
150 configure.ac can be found. Defaults to current
152 --local-dir=DIRECTORY Specify a local override directory where to look
153 up files before looking in gnulib's directory.
154 --verbose Increase verbosity. May be repeated.
155 --quiet Decrease verbosity. May be repeated.
157 Options for --import:
158 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
159 --source-base=DIRECTORY
160 Directory relative to --dir where source code is
161 placed (default \"lib\").
162 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
163 placed (default \"m4\").
164 --po-base=DIRECTORY Directory relative to --dir where *.po files are
165 placed (default \"po\").
166 --doc-base=DIRECTORY Directory relative to --dir where doc files are
167 placed (default \"doc\").
168 --tests-base=DIRECTORY
169 Directory relative to --dir where unit tests are
170 placed (default \"tests\").
171 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
172 tools are placed (default \"build-aux\").
173 --with-tests Include unit tests for the included modules.
174 --with-obsolete Include obsolete modules when they occur among the
175 dependencies. By default, dependencies to obsolete
177 --avoid=MODULE Avoid including the given MODULE. Useful if you
178 have code that provides equivalent functionality.
179 This option can be repeated.
180 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
181 Also modify license template from GPL to LGPL.
182 The version number of the LGPL can be specified;
183 the default is currently LGPLv3.
184 --makefile-name=NAME Name of makefile in automake syntax in the
185 source-base and tests-base directories
186 (default \"Makefile.am\").
187 --libtool Use libtool rules.
188 --no-libtool Don't use libtool rules.
189 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
190 'gl_INIT'. Default is 'gl'.
191 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
192 the package name. A suffix '-gnulib' is appended.
193 --vc-files Update version control related files.
194 --no-vc-files Don't update version control related files
195 (.gitignore and/or .cvsignore).
196 --no-changelog Don't update or create ChangeLog files.
198 Options for --import and --update:
199 --dry-run For --import, only print what would have been done.
200 -s, --symbolic, --symlink Make symbolic links instead of copying files.
201 --local-symlink Make symbolic links instead of copying files, only
202 for files from the local override directory.
203 -S, --more-symlinks Make symbolic links instead of copying files, and
204 don't replace copyright notices.
206 Report bugs to <bug-gnulib@gnu.org>."
210 # outputs to stdout the --version message.
214 if test -d "$gnulib_dir"/.git \
215 && (git --version) >/dev/null 2>/dev/null \
216 && (date --version) >/dev/null 2>/dev/null; then
217 # gnulib checked out from git.
218 sed_extract_first_date='/^Date/{
222 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
223 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
224 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
225 date=`echo "$date" | sed -e "$sed_year_before_time"`
226 # Use GNU date to compute the time in GMT.
227 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
228 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
230 if test -d "$gnulib_dir"/CVS \
231 && (cvs --version) >/dev/null 2>/dev/null; then
232 # gnulib checked out from CVS.
233 sed_extract_first_date='/^date: /{
234 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
237 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
239 # gnulib copy without versioning information.
240 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
244 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed 's,^.* ,,'`
246 gnulib-tool (GNU $package $date)$version
247 Copyright (C) $year Free Software Foundation, Inc.
248 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
249 This is free software: you are free to change and redistribute it.
250 There is NO WARRANTY, to the extent permitted by law.
252 Written by" "Bruno Haible" "and" "Simon Josefsson"
255 # func_emit_copyright_notice
256 # outputs to stdout a header for a generated file.
257 func_emit_copyright_notice ()
259 sed -n '/Copyright/ {
262 }' < "$self_abspathname"
264 echo "# This file is free software, distributed under the terms of the GNU"
265 echo "# General Public License. As a special exception to the GNU General"
266 echo "# Public License, this file may be distributed as part of a program"
267 echo "# that contains a configuration script generated by Autoconf, under"
268 echo "# the same distribution terms as the rest of that program."
270 echo "# Generated by gnulib-tool."
274 # exits with a given status.
275 # This function needs to be used, rather than 'exit', when a 'trap' handler is
276 # in effect that refers to $?.
283 # locates the directory where the gnulib repository lives
285 # - progname name of this program
287 # - self_abspathname absolute pathname of gnulib-tool
288 # - gnulib_dir absolute pathname of gnulib repository
292 /*) self_abspathname="$progname" ;;
293 */*) self_abspathname=`pwd`/"$progname" ;;
296 # Iterate through the elements of $PATH.
297 # We use IFS=: instead of
298 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
299 # because the latter does not work when some PATH element contains spaces.
300 # We use a canonicalized $pathx instead of $PATH, because empty PATH
301 # elements are by definition equivalent to '.', however field splitting
302 # according to IFS=: loses empty fields in many shells:
303 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
304 # beginning, at the end, and in the middle),
305 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
306 # at the beginning and at the end,
307 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
308 # Solaris lose empty fields at the end.
309 # The 'case' statement is an optimization, to avoid evaluating the
310 # explicit canonicalization command when $PATH contains no empty fields.
312 if test "${PATH_SEPARATOR+set}" != set; then
314 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
315 chmod +x "$tmp"/conf.sh
316 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
323 if test "$PATH_SEPARATOR" = ";"; then
324 # On Windows, programs are searched in "." before $PATH.
327 # On Unix, we have to convert empty PATH elements to ".".
331 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
336 IFS="$PATH_SEPARATOR"
340 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
341 self_abspathname="$d/$progname"
346 if test -z "$self_abspathname"; then
347 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
351 while test -h "$self_abspathname"; do
352 # Resolve symbolic link.
353 linkval=`func_readlink "$self_abspathname"`
354 test -n "$linkval" || break
356 /* ) self_abspathname="$linkval" ;;
357 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
360 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
364 # creates a temporary directory.
366 # - progname name of this program
368 # - tmp pathname of freshly created temporary directory
371 # Use the environment variable TMPDIR, falling back to /tmp. This allows
372 # users to specify a different temporary directory, for example, if their
373 # /tmp is filled up or too small.
376 # Use the mktemp program if available. If not available, hide the error
378 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
379 test -n "$tmp" && test -d "$tmp"
382 # Use a simple mkdir command. It is guaranteed to fail if the directory
383 # already exists. $RANDOM is bash specific and expands to empty in shells
384 # other than bash, ksh and zsh. Its use does not increase security;
385 # rather, it minimizes the probability of failure in a very cluttered /tmp
387 tmp=$TMPDIR/gl$$-$RANDOM
388 (umask 077 && mkdir "$tmp")
391 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
396 # func_append var value
397 # appends the given value to the shell variable var.
398 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
399 # Use bash's += operator. It reduces complexity of appending repeatedly to
400 # a single variable from O(n^2) to O(n).
405 fast_func_append=true
409 eval "$1=\"\$$1\$2\""
411 fast_func_append=false
414 # func_remove_prefix var prefix
415 # removes the given prefix from the value of the shell variable var.
416 # var should be the name of a shell variable.
417 # Its value should not contain a newline and not start or end with whitespace.
418 # prefix should not contain the characters "$`\{}[]^|.
419 if ( foo=bar; eval 'test "${foo#b}" = ar' ) >/dev/null 2>&1; then
420 func_remove_prefix ()
424 fast_func_remove_prefix=true
426 func_remove_prefix ()
428 eval "value=\"\$$1\""
432 sed_escape_dots='s/\([.]\)/\\\1/g'
433 prefix=`echo "$prefix" | sed -e "$sed_escape_dots"`
436 value=`echo "$value" | sed -e "s|^${prefix}||"`
437 eval "$1=\"\$value\""
439 fast_func_remove_prefix=false
442 # func_remove_suffix var suffix
443 # removes the given suffix from the value of the shell variable var.
444 # var should be the name of a shell variable.
445 # Its value should not contain a newline and not start or end with whitespace.
446 # suffix should not contain the characters "$`\{}[]^|.
447 if ( foo=bar; eval 'test "${foo%r}" = ba' ) >/dev/null 2>&1; then
448 func_remove_suffix ()
452 fast_func_remove_suffix=true
454 func_remove_suffix ()
456 eval "value=\"\$$1\""
460 sed_escape_dots='s/\([.]\)/\\\1/g'
461 suffix=`echo "$suffix" | sed -e "$sed_escape_dots"`
464 value=`echo "$value" | sed -e "s|${suffix}\$||"`
465 eval "$1=\"\$value\""
467 fast_func_remove_suffix=false
470 # func_fatal_error message
471 # outputs to stderr a fatal error message, and terminates the program.
473 # - progname name of this program
476 echo "$progname: *** $1" 1>&2
477 echo "$progname: *** Stop." 1>&2
481 # func_readlink SYMLINK
482 # outputs the target of the given symlink.
483 if (type -p readlink) > /dev/null 2>&1; then
486 # Use the readlink program from GNU coreutils.
492 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
493 # would do the wrong thing if the link target contains " -> ".
494 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
498 # func_relativize DIR1 DIR2
499 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
501 # - DIR1 relative pathname, relative to the current directory
502 # - DIR2 relative pathname, relative to the current directory
504 # - reldir relative pathname of DIR2, relative to DIR1
510 sed_first='s,^\([^/]*\)/.*$,\1,'
511 sed_rest='s,^[^/]*/*,,'
512 sed_last='s,^.*/\([^/]*\)$,\1,'
513 sed_butlast='s,/*[^/]*$,,'
514 while test -n "$dir1"; do
515 first=`echo "$dir1" | sed -e "$sed_first"`
516 if test "$first" != "."; then
517 if test "$first" = ".."; then
518 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
519 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
521 first2=`echo "$dir2" | sed -e "$sed_first"`
522 if test "$first2" = "$first"; then
523 dir2=`echo "$dir2" | sed -e "$sed_rest"`
527 dir0="$dir0"/"$first"
530 dir1=`echo "$dir1" | sed -e "$sed_rest"`
535 # func_relconcat DIR1 DIR2
536 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
538 # - DIR1 relative pathname, relative to the current directory
539 # - DIR2 relative pathname, relative to DIR1
541 # - relconcat DIR1/DIR2, relative to the current directory
546 sed_first='s,^\([^/]*\)/.*$,\1,'
547 sed_rest='s,^[^/]*/*,,'
548 sed_last='s,^.*/\([^/]*\)$,\1,'
549 sed_butlast='s,/*[^/]*$,,'
551 first=`echo "$dir2" | sed -e "$sed_first"`
552 if test "$first" = "."; then
553 dir2=`echo "$dir2" | sed -e "$sed_rest"`
554 if test -z "$dir2"; then
559 last=`echo "$dir1" | sed -e "$sed_last"`
560 while test "$last" = "."; do
561 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
562 last=`echo "$dir1" | sed -e "$sed_last"`
564 if test -z "$dir1"; then
568 if test "$first" = ".."; then
569 if test "$last" = ".."; then
570 relconcat="$dir1/$dir2"
573 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
574 dir2=`echo "$dir2" | sed -e "$sed_rest"`
575 if test -z "$dir1"; then
579 if test -z "$dir2"; then
584 relconcat="$dir1/$dir2"
592 # Like ln -s, except that SRC is given relative to the current directory (or
593 # absolute), not given relative to the directory of DEST.
599 *) # SRC is relative.
602 ln -s "`pwd`/$1" "$2" ;;
603 *) # DEST is relative too.
604 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
605 test -n "$ln_destdir" || ln_destdir="."
606 func_relativize "$ln_destdir" "$1"
614 # func_ln_if_changed SRC DEST
615 # Like func_ln, but avoids munging timestamps if the link is correct.
616 func_ln_if_changed ()
618 if test $# -ne 2; then
619 echo "usage: func_ln_if_changed SRC DEST" >&2
621 ln_target=`func_readlink "$2"`
622 if test -h "$2" && test "$1" = "$ln_target"; then
631 # Resets SIGPIPE to its default behaviour. SIGPIPE is signalled when a process
632 # writes into a pipe with no readers, i.e. a pipe where all readers have
633 # already closed their file descriptor that read from it or exited entirely.
634 # The default behaviour is to terminate the current process without an error
636 # When "trap '' SIGPIPE" is in effect, the behaviour (at least with bash) is to
637 # terminate the current process with an error message.
638 # This function should be called at the beginning of a command that only
639 # produces output to stdout (i.e. no side effects!), when the command that
640 # will read from this pipe might prematurely exit or close its standard input
642 if test -n "$BASH_VERSION"; then
643 # The problem has only been reported with bash. Probably it occurs only with
644 # bash-3.2. For the reasons, see
645 # <http://lists.gnu.org/archive/html/bug-bash/2008-12/msg00050.html>.
646 # Note that Solaris sh does not understand "trap - SIGPIPE".
647 func_reset_sigpipe ()
652 func_reset_sigpipe ()
658 # Ensure an 'echo' command that does not interpret backslashes.
660 # echo '\n' | wc -l prints 1 when OK, 2 when KO
661 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
662 # This problem is a weird heritage from SVR4. BSD got it right (except that
663 # BSD echo interprets '-n' as an option, which is also not desirable).
664 # Nowadays the problem occurs in 4 situations:
665 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
666 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
667 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
668 # - in zsh, when sh-emulation is not set,
669 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
670 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
671 # - in Solaris /bin/sh and OSF/1 /bin/sh.
672 # We try the following workarounds:
673 # - for all: respawn using $CONFIG_SHELL if that is set and works.
674 # - for bash >= 2.04: unset the shell option xpg_echo.
675 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
676 # - for bash < 2.0: define echo to a function that uses cat of a here document.
677 # - for zsh: turn sh-emulation on.
678 # - for ksh: alias echo to 'print -r'.
679 # - for ksh: alias echo to a function that uses cat of a here document.
680 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
681 # the ksh workaround.
682 # - otherwise: respawn using /bin/sh and rely on the workarounds.
683 # When respawning, we pass --no-reexec as first argument, so as to avoid
684 # turning this script into a fork bomb in unlucky situations.
686 if echo '\t' | grep t > /dev/null; then
687 have_echo=yes # Lucky!
689 # Try the workarounds.
690 # Respawn using $CONFIG_SHELL if that is set and works.
691 if test -z "$have_echo" \
692 && test "X$1" != "X--no-reexec" \
693 && test -n "$CONFIG_SHELL" \
694 && test -f "$CONFIG_SHELL" \
695 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
696 exec $CONFIG_SHELL "$0" --no-reexec "$@"
699 # For bash >= 2.04: unset the shell option xpg_echo.
700 if test -z "$have_echo" \
701 && test -n "$BASH_VERSION" \
702 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
706 # For bash >= 2.0: define echo to a function that uses the printf built-in.
707 # For bash < 2.0: define echo to a function that uses cat of a here document.
708 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
709 if test -z "$have_echo" \
710 && test -n "$BASH_VERSION"; then \
711 if type printf 2>/dev/null | grep / > /dev/null; then
712 # 'printf' is not a shell built-in.
720 # 'printf' is a shell built-in.
726 if echo '\t' | grep t > /dev/null; then
730 # For zsh: turn sh-emulation on.
731 if test -z "$have_echo" \
732 && test -n "$ZSH_VERSION" \
733 && (emulate sh) >/dev/null 2>&1; then
736 # For ksh: alias echo to 'print -r'.
737 if test -z "$have_echo" \
738 && (type print) >/dev/null 2>&1; then
739 # A 'print' command exists.
740 if type print 2>/dev/null | grep / > /dev/null; then
743 # 'print' is a shell built-in.
744 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
745 # 'print' is the ksh shell built-in.
746 alias echo='print -r'
750 if test -z "$have_echo" \
751 && echo '\t' | grep t > /dev/null; then
754 # For ksh: alias echo to a function that uses cat of a here document.
755 # The ksh manual page says:
756 # "Aliasing is performed when scripts are read, not while they are executed.
757 # Therefore, for an alias to take effect, the alias definition command has
758 # to be executed before the command which references the alias is read."
759 # Because of this, we have to play strange tricks with have_echo, to ensure
760 # that the top-level statement containing the test starts after the 'alias'
762 if test -z "$have_echo"; then
769 alias echo=bsd_echo 2>/dev/null
771 if test -z "$have_echo" \
772 && echo '\t' | grep t > /dev/null; then
775 if test -z "$have_echo"; then
776 unalias echo 2>/dev/null
778 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
779 if test -z "$have_echo" \
780 && test "X$1" != "X--no-reexec" \
781 && test -f /bin/ksh; then
782 exec /bin/ksh "$0" --no-reexec "$@"
785 # Otherwise: respawn using /bin/sh.
786 if test -z "$have_echo" \
787 && test "X$1" != "X--no-reexec" \
788 && test -f /bin/sh; then
789 exec /bin/sh "$0" --no-reexec "$@"
792 if test -z "$have_echo"; then
793 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
795 if echo '\t' | grep t > /dev/null; then
798 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
800 if test "X$1" = "X--no-reexec"; then
804 # Command-line option processing.
805 # Removes the OPTIONS from the arguments. Sets the variables:
806 # - mode list or import or create-testdir or create-megatestdir
807 # - destdir from --dir
808 # - local_gnulib_dir from --local-dir
809 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
810 # - libname, supplied_libname from --lib
811 # - sourcebase from --source-base
812 # - m4base from --m4-base
813 # - pobase from --po-base
814 # - docbase from --doc-base
815 # - testsbase from --tests-base
816 # - auxdir from --aux-dir
817 # - inctests true if --with-tests was given, blank otherwise
818 # - incobsolete true if --with-obsolete was given, blank otherwise
819 # - avoidlist list of modules to avoid, from --avoid
820 # - lgpl yes or a number if --lgpl was given, blank otherwise
821 # - makefile_name from --makefile-name
822 # - libtool true if --libtool was given, false if --no-libtool was
823 # given, blank otherwise
824 # - macro_prefix from --macro-prefix
825 # - po_domain from --po-domain
826 # - vc_files true if --vc-files was given, false if --no-vc-files was
827 # given, blank otherwise
828 # - autoconf_minversion minimum supported autoconf version
829 # - do_changelog false if --no-changelog was given, : otherwise
830 # - doit : if actions shall be executed, false if only to be printed
831 # - symbolic true if --symlink or --more-symlinks was given, blank
833 # - lsymbolic true if --local-symlink was given, blank otherwise
834 # - do_copyrights blank if --more-symlinks was given, true otherwise
865 while test $# -gt 0; do
870 --import | --impor | --impo | --imp | --im | --i )
873 --update | --updat | --upda | --upd | --up | --u )
876 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
879 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
880 mode=create-megatestdir
882 --test | --tes | --te | --t )
885 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
889 mode=`echo "X$1" | sed -e 's/^X--//'`
894 func_fatal_error "missing argument for --dir"
899 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
904 func_fatal_error "missing argument for --local-dir"
909 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
911 --verbose | --verbos | --verbo | --verb )
912 verbose=`expr $verbose + 1`
914 --quiet | --quie | --qui | --qu | --q )
915 verbose=`expr $verbose - 1`
920 func_fatal_error "missing argument for --lib"
923 supplied_libname=true
926 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
927 supplied_libname=true
932 func_fatal_error "missing argument for --source-base"
937 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
942 func_fatal_error "missing argument for --m4-base"
947 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
952 func_fatal_error "missing argument for --po-base"
957 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
962 func_fatal_error "missing argument for --doc-base"
967 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
972 func_fatal_error "missing argument for --tests-base"
977 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
982 func_fatal_error "missing argument for --aux-dir"
987 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
998 func_fatal_error "missing argument for --avoid"
1000 func_append avoidlist " $1"
1003 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
1004 func_append avoidlist " $arg"
1010 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
1013 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
1019 if test $# = 0; then
1020 func_fatal_error "missing argument for --makefile-name"
1025 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
1035 if test $# = 0; then
1036 func_fatal_error "missing argument for --macro-prefix"
1041 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
1045 if test $# = 0; then
1046 func_fatal_error "missing argument for --po-domain"
1051 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
1059 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
1065 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
1068 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
1071 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1075 --help | --hel | --he | --h )
1078 --version | --versio | --versi | --vers )
1082 # Stop option processing
1086 echo "gnulib-tool: unknown option $1" 1>&2
1087 echo "Try 'gnulib-tool --help' for more information." 1>&2
1094 if test "$mode" = update; then
1095 if test $# != 0; then
1096 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1097 echo "Try 'gnulib-tool --help' for more information." 1>&2
1098 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1099 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1102 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1103 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1104 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1105 || test -n "$inctests" || test -n "$incobsolete" \
1106 || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
1107 || test -n "$macro_prefix" || test -n "$po_domain" \
1108 || test -n "$vc_files"; then
1109 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1110 echo "Try 'gnulib-tool --help' for more information." 1>&2
1111 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1112 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1117 if test -n "$pobase" && test -z "$po_domain"; then
1118 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1119 echo "Try 'gnulib-tool --help' for more information." 1>&2
1122 if test -z "$pobase" && test -n "$po_domain"; then
1123 echo "gnulib-tool: warning: --po-domain has no effect without a --po-base option" 1>&2
1126 # Determine the minimum supported autoconf version from the project's
1128 DEFAULT_AUTOCONF_MINVERSION="2.59"
1129 autoconf_minversion=
1131 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1132 if test -f "$destdir"/configure.ac; then
1133 configure_ac="$destdir/configure.ac"
1135 if test -f "$destdir"/configure.in; then
1136 configure_ac="$destdir/configure.in"
1140 if test -f configure.ac; then
1141 configure_ac="configure.ac"
1143 if test -f configure.in; then
1144 configure_ac="configure.in"
1148 if test -n "$configure_ac"; then
1149 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1150 # because when some m4 files are omitted from a CVS repository,
1151 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1152 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1153 # autom4te: m4 failed with exit status: 1
1160 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1162 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1163 if test -n "$prereqs"; then
1164 autoconf_minversion=`
1165 for version in $prereqs; do echo $version; done |
1166 LC_ALL=C sort -nru | sed 1q
1170 if test -z "$autoconf_minversion"; then
1171 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1173 case "$autoconf_minversion" in
1174 1.* | 2.[0-4]* | 2.5[0-8]*)
1175 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1178 # Remove trailing slashes from the directory names. This is necessary for
1179 # m4base (to avoid an error in func_import) and optional for the others.
1180 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1181 case "$local_gnulib_dir" in
1182 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1184 case "$sourcebase" in
1185 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1188 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1191 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1194 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1196 case "$testsbase" in
1197 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1200 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1206 trap 'exit_status=$?
1207 if test "$signal" != 0; then
1208 echo "caught signal $signal" >&2
1211 exit $exit_status' 0
1212 for signal in 1 2 3 13 15; do
1213 trap '{ signal='$signal'; func_exit 1; }' $signal
1217 # func_lookup_file file
1218 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1221 # - local_gnulib_dir from --local-dir
1223 # - lookedup_file name of the merged (combined) file
1224 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1228 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1229 lookedup_file="$local_gnulib_dir/$lkfile"
1232 if test -f "$gnulib_dir/$lkfile"; then
1233 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1234 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1235 rm -f "$tmp/$lkbase"
1236 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1237 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1238 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1239 lookedup_file="$tmp/$lkbase"
1242 lookedup_file="$gnulib_dir/$lkfile"
1246 func_fatal_error "file $gnulib_dir/$lkfile not found"
1253 # - local_gnulib_dir from --local-dir
1256 # Filter out metainformation files like README, which are not modules.
1257 # Filter out unit test modules; they can be retrieved through
1258 # --extract-tests-module if desired.
1260 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1261 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1262 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1265 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1266 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1267 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1268 -e '/^README$/d' -e '/\/README$/d' \
1269 -e '/^TEMPLATE$/d' \
1270 -e '/^TEMPLATE-EXTENDED$/d' \
1271 -e '/^TEMPLATE-TESTS$/d' \
1274 | sed -e '/-tests$/d' \
1278 # func_verify_module
1279 # verifies a module name
1281 # - local_gnulib_dir from --local-dir
1282 # - module module name argument
1283 func_verify_module ()
1285 if { test -f "$gnulib_dir/modules/$module" \
1286 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1287 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1288 && test "CVS" != "$module" \
1289 && test "ChangeLog" != "$module" \
1290 && test "COPYING" != "$module" \
1291 && test "README" != "$module" \
1292 && test "TEMPLATE" != "$module" \
1293 && test "TEMPLATE-EXTENDED" != "$module" \
1294 && test "TEMPLATE-TESTS" != "$module"; then
1295 # OK, $module is a correct module name.
1296 # Verify that building the module description with 'patch' succeeds.
1297 func_lookup_file "modules/$module"
1299 echo "gnulib-tool: module $module doesn't exist" 1>&2
1304 # func_verify_nontests_module
1305 # verifies a module name, excluding tests modules
1307 # - local_gnulib_dir from --local-dir
1308 # - module module name argument
1309 func_verify_nontests_module ()
1312 *-tests ) module= ;;
1313 * ) func_verify_module ;;
1317 # func_verify_tests_module
1318 # verifies a module name, considering only tests modules
1320 # - local_gnulib_dir from --local-dir
1321 # - module module name argument
1322 func_verify_tests_module ()
1325 *-tests ) func_verify_module ;;
1330 sed_extract_prog=':[ ]*$/ {
1333 s/^Description:[ ]*$//
1337 s/^Depends-on:[ ]*$//
1338 s/^configure\.ac-early:[ ]*$//
1339 s/^configure\.ac:[ ]*$//
1340 s/^Makefile\.am:[ ]*$//
1344 s/^Maintainer:[ ]*$//
1351 # func_get_description module
1353 # - local_gnulib_dir from --local-dir
1354 func_get_description ()
1356 func_lookup_file "modules/$1"
1357 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1360 # func_get_status module
1362 # - local_gnulib_dir from --local-dir
1365 func_lookup_file "modules/$1"
1366 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1369 # func_get_notice module
1371 # - local_gnulib_dir from --local-dir
1374 func_lookup_file "modules/$1"
1375 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1378 # func_get_filelist module
1380 # - local_gnulib_dir from --local-dir
1381 func_get_filelist ()
1383 func_lookup_file "modules/$1"
1384 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1386 echo m4/gnulib-common.m4
1387 case "$autoconf_minversion" in
1394 # func_filter_filelist outputvar separator filelist prefix suffix removed_prefix removed_suffix [added_prefix [added_suffix]]
1395 # stores in outputvar the filtered and processed filelist. Filtering: Only the
1396 # elements starting with prefix and ending with suffix are considered.
1397 # Processing: removed_prefix and removed_suffix are removed from each element,
1398 # added_prefix and added_suffix are added to each element.
1399 # removed_prefix, removed_suffix should not contain the characters "$`\{}[]^|.
1400 # added_prefix, added_suffix should not contain the characters \|.
1401 func_filter_filelist ()
1403 if test "$2" != "$nl" \
1404 || { $fast_func_append \
1405 && { test -z "$6" || $fast_func_remove_prefix; } \
1406 && { test -z "$7" || $fast_func_remove_suffix; }; \
1412 if test -n "$6"; then
1413 func_remove_prefix fff "$6"
1415 if test -n "$7"; then
1416 func_remove_suffix fff "$7"
1419 if test -z "$ffflist"; then
1422 func_append ffflist "$2${fff}"
1428 sed_fff_filter="s|^$6\(.*\)$7\$|$8\\1$9|"
1429 ffflist=`for fff in $3; do
1431 "$4"*"$5") echo "$fff" ;;
1433 done | sed -e "$sed_fff_filter"`
1435 eval "$1=\"\$ffflist\""
1438 # func_get_dependencies module
1440 # - local_gnulib_dir from --local-dir
1441 func_get_dependencies ()
1443 # ${module}-tests always implicitly depends on ${module}.
1447 func_remove_suffix fgd1 '-tests'
1451 # Then the explicit dependencies listed in the module description.
1452 func_lookup_file "modules/$1"
1453 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1456 # func_get_autoconf_early_snippet module
1458 # - local_gnulib_dir from --local-dir
1459 func_get_autoconf_early_snippet ()
1461 func_lookup_file "modules/$1"
1462 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1465 # func_get_autoconf_snippet module
1467 # - local_gnulib_dir from --local-dir
1468 func_get_autoconf_snippet ()
1470 func_lookup_file "modules/$1"
1471 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1474 # func_get_automake_snippet module
1476 # - local_gnulib_dir from --local-dir
1477 func_get_automake_snippet ()
1479 func_lookup_file "modules/$1"
1480 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1483 # *-tests module live in tests/, not lib/.
1484 # Synthesize an EXTRA_DIST augmentation.
1485 all_files=`func_get_filelist $1`
1486 func_filter_filelist tests_files " " "$all_files" 'tests/' '' 'tests/' ''
1487 extra_files="$tests_files"
1488 if test -n "$extra_files"; then
1489 echo "EXTRA_DIST +=" $extra_files
1494 # Synthesize an EXTRA_DIST augmentation.
1495 sed_combine_lines='/\\$/{
1502 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1503 already_mentioned_files=` \
1504 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1505 | sed -e "$sed_combine_lines" \
1506 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1507 all_files=`func_get_filelist $1`
1508 func_filter_filelist lib_files "$nl" "$all_files" 'lib/' '' 'lib/' ''
1509 # Remove $already_mentioned_files from $lib_files.
1510 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1511 extra_files=`func_reset_sigpipe; \
1512 for f in $already_mentioned_files; do echo $f; done \
1513 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1514 if test -n "$extra_files"; then
1515 echo "EXTRA_DIST +=" $extra_files
1518 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1519 # This is necessary so that automake can generate the right list of
1521 # A possible approach would be to use autom4te --trace of the redefined
1522 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1523 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1524 # inside autoconf's built-in macros are not missed).
1525 # But it's simpler and more robust to do it here, based on the file list.
1526 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1527 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1528 # automake will generate a useless dependency; this is harmless.
1530 relocatable-prog-wrapper) ;;
1532 func_filter_filelist extra_files "$nl" "$extra_files" '' '.c' '' ''
1533 if test -n "$extra_files"; then
1534 echo "EXTRA_lib_SOURCES +=" $extra_files
1539 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1540 func_filter_filelist buildaux_files "$nl" "$all_files" 'build-aux/' '' 'build-aux/' ''
1541 if test -n "$buildaux_files"; then
1542 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1543 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1546 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
1547 func_filter_filelist top_files "$nl" "$all_files" 'top/' '' 'top/' ''
1548 if test -n "$top_files"; then
1549 sed_prepend_topdir='s,^,$(top_srcdir)/,'
1550 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
1557 # func_get_include_directive module
1559 # - local_gnulib_dir from --local-dir
1560 func_get_include_directive ()
1562 func_lookup_file "modules/$1"
1563 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1564 sed -e 's/^\(["<]\)/#include \1/'
1567 # func_get_link_directive module
1569 # - local_gnulib_dir from --local-dir
1570 func_get_link_directive ()
1572 func_lookup_file "modules/$1"
1573 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1576 # func_get_license module
1578 # - local_gnulib_dir from --local-dir
1581 func_lookup_file "modules/$1"
1582 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1583 # The default is GPL.
1585 } | sed -e 's,^ *$,,' | sed -e 1q
1588 # func_get_maintainer module
1590 # - local_gnulib_dir from --local-dir
1591 func_get_maintainer ()
1593 func_lookup_file "modules/$1"
1594 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1597 # func_get_tests_module module
1599 # - local_gnulib_dir from --local-dir
1600 func_get_tests_module ()
1602 # The naming convention for tests modules is hardwired: ${module}-tests.
1603 if test -f "$gnulib_dir/modules/$1"-tests \
1604 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1605 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1610 # func_acceptable module
1611 # tests whether a module is acceptable.
1613 # - avoidlist list of modules to avoid
1616 for avoid in $avoidlist; do
1617 if test "$avoid" = "$1"; then
1624 # func_modules_transitive_closure
1626 # - local_gnulib_dir from --local-dir
1627 # - modules list of specified modules
1628 # - inctests true if tests should be included, blank otherwise
1629 # - incobsolete true if obsolete modules among dependencies should be
1630 # included, blank otherwise
1631 # - avoidlist list of modules to avoid
1632 # - tmp pathname of a temporary directory
1634 # - modules list of modules, including dependencies
1635 func_modules_transitive_closure ()
1637 # In order to process every module only once (for speed), process an "input
1638 # list" of modules, producing an "output list" of modules. During each round,
1639 # more modules can be queued in the input list. Once a module on the input
1640 # list has been processed, it is added to the "handled list", so we can avoid
1641 # to process it again.
1643 inmodules="$modules"
1645 while test -n "$inmodules"; do
1646 inmodules_this_round="$inmodules"
1647 inmodules= # Accumulator, queue for next round
1648 for module in $inmodules_this_round; do
1650 if test -n "$module"; then
1651 if func_acceptable $module; then
1652 func_append outmodules " $module"
1653 deps=`func_get_dependencies $module`
1654 # Duplicate dependencies are harmless, but Jim wants a warning.
1655 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1656 if test -n "$duplicated_deps"; then
1657 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1659 for dep in $deps; do
1660 if test -n "$incobsolete" \
1661 || { status=`func_get_status $dep`; test "$status" != obsolete; }; then
1662 func_append inmodules " $dep"
1665 if test -n "$inctests"; then
1666 testsmodule=`func_get_tests_module $module`
1667 if test -n "$testsmodule"; then
1668 func_append inmodules " $testsmodule"
1674 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1675 # Remove $handledmodules from $inmodules.
1676 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1677 inmodules=`func_reset_sigpipe; echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1679 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1680 rm -f "$tmp"/queued-modules
1683 # func_modules_add_dummy
1685 # - local_gnulib_dir from --local-dir
1686 # - modules list of modules, including dependencies
1688 # - modules list of modules, including 'dummy' if needed
1689 func_modules_add_dummy ()
1691 # Determine whether any module provides a lib_SOURCES augmentation.
1693 sed_remove_backslash_newline=':a
1700 for module in $modules; do
1701 func_verify_nontests_module
1702 if test -n "$module"; then
1703 # Extract the value of "lib_SOURCES += ...".
1704 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1705 # Ignore .h files since they are not compiled.
1709 have_lib_SOURCES=yes
1716 # Add the dummy module, to make sure the library will be non-empty.
1717 if test -z "$have_lib_SOURCES"; then
1718 if func_acceptable "dummy"; then
1719 func_append modules " dummy"
1724 # func_modules_notice
1726 # - local_gnulib_dir from --local-dir
1727 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1728 # - modules list of modules, including dependencies
1729 func_modules_notice ()
1731 if test $verbose -ge -1; then
1732 for module in $modules; do
1734 if test -n "$module"; then
1735 msg=`func_get_notice $module`
1736 if test -n "$msg"; then
1737 echo "Notice from module $module:"
1738 echo "$msg" | sed -e 's/^/ /'
1745 # func_modules_to_filelist
1747 # - local_gnulib_dir from --local-dir
1748 # - modules list of modules, including dependencies
1750 # - files list of files
1751 func_modules_to_filelist ()
1754 for module in $modules; do
1756 if test -n "$module"; then
1757 fs=`func_get_filelist $module`
1758 func_append files " $fs"
1761 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1764 # func_execute_command command [args...]
1765 # Executes a command.
1766 # Uses also the variables
1767 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1768 func_execute_command ()
1770 if test $verbose -ge 0; then
1774 # Commands like automake produce output to stderr even when they succeed.
1775 # Turn this output off if the command succeeds.
1776 "$@" > "$tmp"/cmdout 2>&1
1778 if test $cmdret = 0; then
1782 cat "$tmp"/cmdout 1>&2
1789 # func_emit_lib_Makefile_am
1790 # emits the contents of library makefile to standard output.
1792 # - local_gnulib_dir from --local-dir
1793 # - modules list of modules, including dependencies
1794 # - libname library name
1795 # - pobase directory relative to destdir where to place *.po files
1796 # - auxdir directory relative to destdir where to place build aux files
1797 # - makefile_name from --makefile-name
1798 # - libtool true if libtool will be used, false or blank otherwise
1799 # - macro_prefix prefix of gl_LIBOBJS macros to use
1800 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1801 # - actioncmd (optional) command that will reproduce this invocation
1802 # - for_test true if creating a package for testing, false otherwise
1803 # - destfile filename relative to destdir of makefile being generated
1805 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
1806 # list of edits to be done to Makefile.am variables
1808 # - uses_subdirs nonempty if object files in subdirs exist
1809 func_emit_lib_Makefile_am ()
1811 # When creating an includable Makefile.am snippet, augment variables with
1812 # += instead of assigning them.
1813 if test -n "$makefile_name"; then
1818 if test "$libtool" = true; then
1821 sed_eliminate_LDFLAGS="$sed_noop"
1825 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1828 # When creating a package for testing: Attempt to provoke failures,
1829 # especially link errors, already during "make" rather than during
1830 # "make check", because "make check" is not possible in a cross-compiling
1831 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1832 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1834 sed_transform_check_PROGRAMS="$sed_noop"
1836 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1837 echo "## Process this file with automake to produce Makefile.in."
1838 func_emit_copyright_notice
1839 if test -n "$actioncmd"; then
1840 echo "# Reproduce by: $actioncmd"
1845 for module in $modules; do
1846 func_verify_nontests_module
1847 if test -n "$module"; then
1849 func_get_automake_snippet "$module" |
1850 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1851 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1852 -e "$sed_eliminate_LDFLAGS" \
1853 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1854 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1855 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1856 -e "$sed_transform_check_PROGRAMS"
1857 if test "$module" = 'alloca'; then
1858 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1859 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1862 # Skip the contents if it's entirely empty.
1863 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1864 echo "## begin gnulib module $module"
1867 echo "## end gnulib module $module"
1871 # Test whether there are some source files in subdirectories.
1872 for f in `func_get_filelist "$module"`; do
1883 if test -z "$makefile_name"; then
1884 # If there are source files in subdirectories, prevent collision of the
1885 # object files (example: hash.c and libxml/hash.c).
1887 if test -n "$uses_subdirs"; then
1888 subdir_options=' subdir-objects'
1890 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1893 if test -z "$makefile_name"; then
1895 echo "noinst_HEADERS ="
1896 echo "noinst_LIBRARIES ="
1897 echo "noinst_LTLIBRARIES ="
1898 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1899 # if you specify pkgdata_DATA to empty. This is a workaround.
1900 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1901 echo "pkgdata_DATA ="
1904 echo "BUILT_SOURCES ="
1907 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1908 if test -z "$makefile_name"; then
1909 echo "MOSTLYCLEANDIRS ="
1911 echo "DISTCLEANFILES ="
1912 echo "MAINTAINERCLEANFILES ="
1914 # Execute edits that apply to the Makefile.am being generated.
1916 while test $edit != $makefile_am_edits; do
1917 edit=`expr $edit + 1`
1918 eval dir=\"\$makefile_am_edit${edit}_dir\"
1919 eval var=\"\$makefile_am_edit${edit}_var\"
1920 eval val=\"\$makefile_am_edit${edit}_val\"
1921 if test -n "$var"; then
1922 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
1923 echo "${var} += ${val}"
1924 eval "makefile_am_edit${edit}_var="
1928 if test -z "$makefile_name"; then
1930 echo "AM_CPPFLAGS ="
1933 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1934 # One of the snippets already specifies an installation location for the
1935 # library. Don't confuse automake by saying it should not be installed.
1938 # By default, the generated library should not be installed.
1939 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1942 echo "${libname}_${libext}_SOURCES ="
1943 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1944 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
1945 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1946 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1947 echo "EXTRA_${libname}_${libext}_SOURCES ="
1948 if test "$libtool" = true; then
1949 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1952 if test -n "$pobase"; then
1953 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
1956 cat allsnippets.tmp \
1957 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1959 echo "mostlyclean-local: mostlyclean-generic"
1960 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1961 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1962 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1966 rm -f allsnippets.tmp
1969 # func_emit_po_Makevars
1970 # emits the contents of po/ makefile parameterization to standard output.
1972 # - local_gnulib_dir from --local-dir
1973 # - sourcebase directory relative to destdir where to place source code
1974 # - pobase directory relative to destdir where to place *.po files
1975 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1976 func_emit_po_Makevars ()
1978 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1979 func_emit_copyright_notice
1981 echo "# Usually the message domain is the same as the package name."
1982 echo "# But here it has a '-gnulib' suffix."
1983 echo "DOMAIN = ${po_domain}-gnulib"
1985 echo "# These two variables depend on the location of this directory."
1986 echo "subdir = ${pobase}"
1987 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
1990 # These options get passed to xgettext.
1991 XGETTEXT_OPTIONS = \
1992 --keyword=_ --flag=_:1:pass-c-format \
1993 --keyword=N_ --flag=N_:1:pass-c-format \
1994 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
1995 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
1996 --flag=error:3:c-format --flag=error_at_line:5:c-format
1998 # This is the copyright holder that gets inserted into the header of the
1999 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
2000 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
2002 # This is the email address or URL to which the translators shall report
2003 # bugs in the untranslated strings:
2004 # - Strings which are not entire sentences, see the maintainer guidelines
2005 # in the GNU gettext documentation, section 'Preparing Strings'.
2006 # - Strings which use unclear terms or require additional context to be
2008 # - Strings which make invalid assumptions about notation of date, time or
2010 # - Pluralisation problems.
2011 # - Incorrect English spelling.
2012 # - Incorrect formatting.
2013 # It can be your email address, or a mailing list address where translators
2014 # can write to without being subscribed, or the URL of a web page through
2015 # which the translators can contact you.
2016 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
2018 # This is the list of locale categories, beyond LC_MESSAGES, for which the
2019 # message catalogs shall be used. It is usually empty.
2020 EXTRA_LOCALE_CATEGORIES =
2022 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
2023 # context. Possible values are "yes" and "no". Set this to yes if the
2024 # package uses functions taking also a message context, like pgettext(), or
2025 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
2030 # func_emit_po_POTFILES_in
2031 # emits the file list to be passed to xgettext to standard output.
2033 # - local_gnulib_dir from --local-dir
2034 # - sourcebase directory relative to destdir where to place source code
2035 # - files list of new files
2036 func_emit_po_POTFILES_in ()
2038 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2039 func_emit_copyright_notice
2041 echo "# List of files which contain translatable strings."
2042 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
2045 # func_emit_tests_Makefile_am
2046 # emits the contents of tests makefile to standard output.
2048 # - local_gnulib_dir from --local-dir
2049 # - modules list of modules, including dependencies
2050 # - libname library name
2051 # - auxdir directory relative to destdir where to place build aux files
2052 # - makefile_name from --makefile-name
2053 # - libtool true if libtool will be used, false or blank otherwise
2054 # - sourcebase relative directory containing lib source code
2055 # - m4base relative directory containing autoconf macros
2056 # - testsbase relative directory containing unit test code
2057 # - macro_prefix prefix of gl_LIBOBJS macros to use
2058 # - for_test true if creating a package for testing, false otherwise
2059 # - use_libtests true if a libtests.a should be built, false otherwise
2060 # - destfile filename relative to destdir of makefile being generated
2062 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
2063 # list of edits to be done to Makefile.am variables
2065 # - uses_subdirs nonempty if object files in subdirs exist
2066 func_emit_tests_Makefile_am ()
2068 if test "$libtool" = true; then
2070 sed_eliminate_LDFLAGS="$sed_noop"
2073 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
2076 # When creating a package for testing: Attempt to provoke failures,
2077 # especially link errors, already during "make" rather than during
2078 # "make check", because "make check" is not possible in a cross-compiling
2079 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
2080 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
2082 sed_transform_check_PROGRAMS="$sed_noop"
2084 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
2085 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
2086 echo "## Process this file with automake to produce Makefile.in."
2087 func_emit_copyright_notice
2091 for module in $modules; do
2093 func_verify_tests_module
2097 if test -n "$module"; then
2099 func_get_automake_snippet "$module" |
2100 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
2101 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
2102 -e "$sed_eliminate_LDFLAGS" \
2103 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
2104 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
2105 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
2106 -e "$sed_transform_check_PROGRAMS"
2107 if $use_libtests && test "$module" = 'alloca'; then
2108 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
2109 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
2112 # Skip the contents if it's entirely empty.
2113 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
2114 echo "## begin gnulib module $module"
2117 echo "## end gnulib module $module"
2121 # Test whether there are some source files in subdirectories.
2122 for f in `func_get_filelist "$module"`; do
2124 lib/*/*.c | tests/*/*.c)
2133 # Generate dependencies here, since it eases the debugging of test failures.
2134 # If there are source files in subdirectories, prevent collision of the
2135 # object files (example: hash.c and libxml/hash.c).
2137 if test -n "$uses_subdirs"; then
2138 subdir_options=' subdir-objects'
2140 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
2143 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
2146 # Nothing is being added to SUBDIRS; nevertheless the existence of this
2147 # variable is needed to avoid an error from automake:
2148 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
2151 echo "TESTS_ENVIRONMENT ="
2152 echo "noinst_PROGRAMS ="
2153 if ! $for_test; then
2154 echo "check_PROGRAMS ="
2156 echo "noinst_HEADERS ="
2157 echo "noinst_LIBRARIES ="
2158 if $use_libtests; then
2160 echo "noinst_LIBRARIES += libtests.a"
2162 echo "check_LIBRARIES = libtests.a"
2165 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2166 # if you specify pkgdata_DATA to empty. This is a workaround.
2167 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
2168 echo "pkgdata_DATA ="
2171 echo "BUILT_SOURCES ="
2173 echo "MOSTLYCLEANFILES = core *.stackdump"
2174 echo "MOSTLYCLEANDIRS ="
2176 echo "DISTCLEANFILES ="
2177 echo "MAINTAINERCLEANFILES ="
2178 # Execute edits that apply to the Makefile.am being generated.
2180 while test $edit != $makefile_am_edits; do
2181 edit=`expr $edit + 1`
2182 eval dir=\"\$makefile_am_edit${edit}_dir\"
2183 eval var=\"\$makefile_am_edit${edit}_var\"
2184 eval val=\"\$makefile_am_edit${edit}_val\"
2185 if test -n "$var"; then
2186 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2187 echo "${var} += ${val}"
2188 eval "makefile_am_edit${edit}_var="
2193 echo "AM_CPPFLAGS = \\"
2194 echo " -I. -I\$(srcdir) \\"
2195 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
2196 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
2198 local_ldadd_before=''
2199 local_ldadd_after=''
2200 if $use_libtests; then
2201 # All test programs need to be linked with libtests.a.
2202 # It needs to be passed to the linker before ${libname}.${libext}, since
2203 # the tests-related modules depend on the main modules.
2204 # It also needs to be passed to the linker after ${libname}.${libext}
2205 # because the latter might contain incomplete modules (such as the 'error'
2206 # module whose dependency to 'progname' is voluntarily omitted).
2207 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
2209 local_ldadd_before=' libtests.a'
2210 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
2212 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
2214 if $use_libtests; then
2215 echo "libtests_a_SOURCES ="
2216 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2217 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2218 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
2219 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
2220 echo "EXTRA_libtests_a_SOURCES ="
2221 # The circular dependency in LDADD requires this.
2222 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
2225 cat allsnippets.tmp \
2226 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2227 echo "# Clean up after Solaris cc."
2229 echo " rm -rf SunWS_cache"
2231 echo "mostlyclean-local: mostlyclean-generic"
2232 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2233 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2234 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2238 rm -f allsnippets.tmp
2241 # func_emit_initmacro_start macro_prefix
2242 # emits the first few statements of the gl_INIT macro to standard output.
2243 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2244 func_emit_initmacro_start ()
2246 macro_prefix_arg="$1"
2247 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
2248 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
2249 # LIBOBJS. The purpose is to allow several gnulib instantiations under
2250 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
2252 # Furthermore it avoids an automake error like this when a Makefile.am
2253 # that uses pieces of gnulib also uses $(LIBOBJ):
2254 # automatically discovered file `error.c' should not be explicitly mentioned
2255 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
2256 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
2257 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
2258 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
2259 # automatically discovered file `error.c' should not be explicitly mentioned
2260 # We let automake know about the files to be distributed through the
2261 # EXTRA_lib_SOURCES variable.
2262 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
2263 # Create data variables for checking the presence of files that are mentioned
2264 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
2265 # because we want the check to happen when the configure file is created,
2266 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
2267 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
2268 # in which to expect them.
2269 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
2270 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
2274 # func_emit_initmacro_end macro_prefix
2275 # emits the last few statements of the gl_INIT macro to standard output.
2276 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2277 func_emit_initmacro_end ()
2279 macro_prefix_arg="$1"
2280 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
2281 # The check is performed only when autoconf is run from the directory where
2282 # the configure.ac resides; if it is run from a different directory, the
2284 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
2285 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
2286 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
2287 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
2288 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
2292 echo " m4_if(m4_sysval, [0], [],"
2293 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
2295 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
2296 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
2297 echo " m4_popdef([AC_LIBSOURCES])"
2298 echo " m4_popdef([AC_REPLACE_FUNCS])"
2299 echo " m4_popdef([AC_LIBOBJ])"
2300 echo " AC_CONFIG_COMMANDS_PRE(["
2301 echo " ${macro_prefix_arg}_libobjs="
2302 echo " ${macro_prefix_arg}_ltlibobjs="
2303 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
2304 echo " # Remove the extension."
2305 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
2306 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
2307 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
2308 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
2311 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
2312 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
2316 # func_emit_initmacro_done macro_prefix sourcebase
2317 # emits a few statements after the gl_INIT macro to standard output.
2318 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2319 # - sourcebase directory relative to destdir where to place source code
2320 func_emit_initmacro_done ()
2322 macro_prefix_arg="$1"
2325 echo "# Like AC_LIBOBJ, except that the module name goes"
2326 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2327 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
2328 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
2329 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
2332 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
2333 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2334 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
2335 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
2336 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
2339 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
2340 echo "# expected is derived from the gnulib-tool parameterization,"
2341 echo "# and alloca is special cased (for the alloca-opt module)."
2342 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
2343 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
2344 echo " m4_foreach([_gl_NAME], [\$1], ["
2345 echo " m4_if(_gl_NAME, [alloca.c], [], ["
2346 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
2347 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
2353 # func_import modules
2354 # Uses also the variables
2355 # - destdir target directory
2356 # - local_gnulib_dir from --local-dir
2357 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2358 # - libname library name
2359 # - sourcebase directory relative to destdir where to place source code
2360 # - m4base directory relative to destdir where to place *.m4 macros
2361 # - pobase directory relative to destdir where to place *.po files
2362 # - docbase directory relative to destdir where to place doc files
2363 # - testsbase directory relative to destdir where to place unit test code
2364 # - auxdir directory relative to destdir where to place build aux files
2365 # - inctests true if --with-tests was given, blank otherwise
2366 # - incobsolete true if --with-obsolete was given, blank otherwise
2367 # - avoidlist list of modules to avoid, from --avoid
2368 # - lgpl yes or a number if library's license shall be LGPL,
2370 # - makefile_name from --makefile-name
2371 # - libtool true if --libtool was given, false if --no-libtool was
2372 # given, blank otherwise
2373 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
2374 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2375 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2376 # - vc_files true if --vc-files was given, false if --no-vc-files was
2377 # given, blank otherwise
2378 # - autoconf_minversion minimum supported autoconf version
2379 # - doit : if actions shall be executed, false if only to be printed
2380 # - symbolic true if files should be symlinked, copied otherwise
2381 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2383 # - do_copyrights true if copyright notices in files should be replaced,
2387 # Get the cached settings.
2388 cached_local_gnulib_dir=
2389 cached_specified_modules=
2400 cached_makefile_name=
2402 cached_macro_prefix=
2406 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2407 cached_libtool=false
2413 s,^.*gl_LOCAL_DIR([[ ]*\([^]"$`\\)]*\).*$,cached_local_gnulib_dir="\1",p
2423 s,^.*gl_MODULES([[ ]*\([^]"$`\\)]*\).*$,cached_specified_modules="\1",p
2425 /gl_WITH_OBSOLETE/ {
2426 s,^.*$,cached_incobsolete=true,p
2429 s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
2432 s,^.*gl_SOURCE_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_sourcebase="\1",p
2435 s,^.*gl_M4_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_m4base="\1",p
2438 s,^.*gl_PO_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_pobase="\1",p
2441 s,^.*gl_DOC_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_docbase="\1",p
2444 s,^.*gl_TESTS_BASE([[ ]*\([^]"$`\\)]*\).*$,cached_testsbase="\1",p
2447 s,^.*$,cached_inctests=true,p
2450 s,^.*gl_LIB([[ ]*\([^]"$`\\)]*\).*$,cached_libname="\1",p
2453 s,^.*gl_LGPL([[ ]*\([^]"$`\\)]*\).*$,cached_lgpl="\1",p
2456 s,^.*$,cached_lgpl=yes,p
2458 /gl_MAKEFILE_NAME(/ {
2459 s,^.*gl_MAKEFILE_NAME([[ ]*\([^]"$`\\)]*\).*$,cached_makefile_name="\1",p
2462 s,^.*$,cached_libtool=true,p
2464 /gl_MACRO_PREFIX(/ {
2465 s,^.*gl_MACRO_PREFIX([[ ]*\([^]"$`\\)]*\).*$,cached_macro_prefix="\1",p
2468 s,^.*gl_PO_DOMAIN([[ ]*\([^]"$`\\)]*\).*$,cached_po_domain="\1",p
2471 s,^.*gl_VC_FILES([[ ]*\([^]"$`\\)]*\).*$,cached_vc_files="\1",p
2473 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2474 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2479 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2480 s,^.*$,cached_files=",p
2493 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2497 # Merge the cached settings with the specified ones.
2498 # The m4base must be the same as expected from the pathname.
2499 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2500 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2502 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2503 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2504 if test -z "$local_gnulib_dir"; then
2505 if test -n "$cached_local_gnulib_dir"; then
2508 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2510 case "$cached_local_gnulib_dir" in
2512 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2514 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2515 local_gnulib_dir="$relconcat" ;;
2520 # Append the cached and the specified module names. So that
2521 # "gnulib-tool --import foo" means to add the module foo.
2522 specified_modules="$cached_specified_modules $1"
2523 # Included obsolete modules among the dependencies if specified either way.
2524 if test -z "$incobsolete"; then
2525 incobsolete="$cached_incobsolete"
2527 # Append the cached and the specified avoidlist. This is probably better
2528 # than dropping the cached one when --avoid is specified at least once.
2529 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2530 avoidlist=`echo $avoidlist`
2532 # The sourcebase defaults to the cached one.
2533 if test -z "$sourcebase"; then
2534 sourcebase="$cached_sourcebase"
2535 if test -z "$sourcebase"; then
2536 func_fatal_error "missing --source-base option"
2539 # The pobase defaults to the cached one.
2540 if test -z "$pobase"; then
2541 pobase="$cached_pobase"
2543 # The docbase defaults to the cached one.
2544 if test -z "$docbase"; then
2545 docbase="$cached_docbase"
2546 if test -z "$docbase"; then
2547 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."
2550 # The testsbase defaults to the cached one.
2551 if test -z "$testsbase"; then
2552 testsbase="$cached_testsbase"
2553 if test -z "$testsbase"; then
2554 func_fatal_error "missing --tests-base option"
2557 # Require the tests if specified either way.
2558 if test -z "$inctests"; then
2559 inctests="$cached_inctests"
2561 # The libname defaults to the cached one.
2562 if test -z "$supplied_libname"; then
2563 libname="$cached_libname"
2564 if test -z "$libname"; then
2565 func_fatal_error "missing --lib option"
2568 # Require LGPL if specified either way.
2569 if test -z "$lgpl"; then
2572 # The makefile_name defaults to the cached one.
2573 if test -z "$makefile_name"; then
2574 makefile_name="$cached_makefile_name"
2576 # Use libtool if specified either way, or if guessed.
2577 if test -z "$libtool"; then
2578 if test -n "$cached_m4base"; then
2579 libtool="$cached_libtool"
2581 libtool="$guessed_libtool"
2584 # The macro_prefix defaults to the cached one.
2585 if test -z "$macro_prefix"; then
2586 macro_prefix="$cached_macro_prefix"
2587 if test -z "$macro_prefix"; then
2588 func_fatal_error "missing --macro-prefix option"
2591 # The po_domain defaults to the cached one.
2592 if test -z "$po_domain"; then
2593 po_domain="$cached_po_domain"
2595 # The vc_files defaults to the cached one.
2596 if test -z "$vc_files"; then
2597 vc_files="$cached_vc_files"
2600 # Canonicalize the list of specified modules.
2601 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2603 # Determine final module list.
2604 modules="$specified_modules"
2605 func_modules_transitive_closure
2606 if test $verbose -ge 0; then
2607 echo "Module list with included dependencies:"
2608 echo "$modules" | sed -e 's/^/ /'
2610 final_modules="$modules"
2612 # Determine main module list and tests-related module list separately.
2613 # The main module list is the transitive closure of the specified modules,
2614 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2615 # is specified, it will consist only of LGPLed source.
2616 # The tests-related module list is the transitive closure of the specified
2617 # modules, including tests modules, minus the main module list. Its lib/*
2618 # sources (brought in through dependencies of *-tests modules) go into
2619 # $testsbase/. It may contain GPLed source, even if --lgpl is specified.
2620 # Determine main module list.
2621 saved_inctests="$inctests"
2623 modules="$specified_modules"
2624 func_modules_transitive_closure
2625 main_modules="$modules"
2626 inctests="$saved_inctests"
2627 if test $verbose -ge 1; then
2628 echo "Main module list:"
2629 echo "$main_modules" | sed -e 's/^/ /'
2631 # Determine tests-related module list.
2632 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2633 testsrelated_modules=`func_reset_sigpipe; echo "$main_modules" | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2634 if test $verbose -ge 1; then
2635 echo "Tests-related module list:"
2636 echo "$testsrelated_modules" | sed -e 's/^/ /'
2639 # Add the dummy module to the main module list if needed.
2640 modules="$main_modules"
2641 func_modules_add_dummy
2642 main_modules="$modules"
2644 # Determine whether a $testsbase/libtests.a is needed.
2646 for module in $testsrelated_modules; do
2647 func_verify_nontests_module
2648 if test -n "$module"; then
2649 all_files=`func_get_filelist $module`
2650 # Test whether some file in $all_files lies in lib/.
2651 for f in $all_files; do
2662 # Add the dummy module to the tests-related module list if needed.
2663 if $use_libtests; then
2664 modules="$testsrelated_modules"
2665 func_modules_add_dummy
2666 testsrelated_modules="$modules"
2669 # If --lgpl, verify that the licenses of modules are compatible.
2670 if test -n "$lgpl"; then
2671 license_incompatibilities=
2672 for module in $main_modules; do
2673 license=`func_get_license $module`
2675 'GPLed build tool') ;;
2676 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2682 *) func_append license_incompatibilities "$module $license$nl" ;;
2688 *) func_append license_incompatibilities "$module $license$nl" ;;
2691 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2696 if test -n "$license_incompatibilities"; then
2697 # Format the license incompatibilities as a table.
2698 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
2699 s,^\(.................................................[^ ]*\) *, \1 ,'
2700 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
2701 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
2705 # Show banner notice of every module.
2706 modules="$main_modules"
2709 # Determine script to apply to imported library files.
2710 sed_transform_lib_file=
2711 for module in $main_modules; do
2712 if test $module = config-h; then
2713 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2714 sed_transform_lib_file=$sed_transform_lib_file'
2715 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2720 sed_transform_main_lib_file="$sed_transform_lib_file"
2721 if test -n "$do_copyrights"; then
2722 if test -n "$lgpl"; then
2726 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2727 s/GNU General/GNU Lesser General/g
2731 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2732 s/GNU General/GNU Lesser General/g
2733 s/version [23]\([ ,]\)/version 2.1\1/g
2736 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2740 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2741 s/GNU Lesser General/GNU General/g
2742 s/GNU Library General/GNU General/g
2743 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2748 # Determine script to apply to library files that go into $testsbase/.
2749 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
2750 if test -n "$do_copyrights"; then
2752 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
2753 s/GNU Lesser General/GNU General/g
2754 s/GNU Library General/GNU General/g
2755 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2759 # Determine the final file lists.
2760 # They must be computed separately, because files in lib/* go into
2761 # $sourcebase/ if they are in the main file list but into $testsbase/
2762 # if they are in the tests-related file list. Furthermore lib/dummy.c
2764 # Determine final main file list.
2765 modules="$main_modules"
2766 func_modules_to_filelist
2768 # Determine final tests-related file list.
2769 modules="$testsrelated_modules"
2770 func_modules_to_filelist
2771 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
2772 # Merge both file lists.
2773 sed_remove_empty_lines='/^$/d'
2774 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
2775 if test $verbose -ge 0; then
2777 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
2778 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
2782 || func_fatal_error "refusing to do nothing"
2784 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2785 new_files="$files m4/gnulib-tool.m4"
2786 old_files="$cached_files"
2787 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2788 func_append old_files " m4/gnulib-tool.m4"
2791 sed_rewrite_old_files="\
2792 s,^build-aux/,$auxdir/,
2793 s,^doc/,$cached_docbase/,
2794 s,^lib/,$cached_sourcebase/,
2795 s,^m4/,$cached_m4base/,
2796 s,^tests/,$cached_testsbase/,
2797 s,^tests=lib/,$cached_testsbase/,
2799 sed_rewrite_new_files="\
2800 s,^build-aux/,$auxdir/,
2802 s,^lib/,$sourcebase/,
2804 s,^tests/,$testsbase/,
2805 s,^tests=lib/,$testsbase/,
2808 # Create directories.
2809 { echo "$sourcebase"
2811 if test -n "$pobase"; then
2814 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2815 if test -n "$docfiles"; then
2818 if test -n "$inctests"; then
2822 for f in $files; do echo $f; done \
2823 | sed -e "$sed_rewrite_new_files" \
2824 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2827 { # Rearrange file descriptors. Needed because "while ... done < ..."
2828 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2829 exec 5<&0 < "$tmp"/dirs
2831 if test ! -d "$destdir/$d"; then
2833 echo "Creating directory $destdir/$d"
2834 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2836 echo "Create directory $destdir/$d"
2843 # func_dest_tmpfilename file
2844 # determines the name of a temporary file (file is relative to destdir).
2846 # - tmpfile absolute filename of the temporary file
2847 func_dest_tmpfilename ()
2850 # Put the new contents of $file in a file in the same directory (needed
2851 # to guarantee that an 'mv' to "$destdir/$file" works).
2852 tmpfile="$destdir/$1.tmp"
2854 # Put the new contents of $file in a file in a temporary directory
2855 # (because the directory of "$file" might not exist).
2856 tmpfile="$tmp"/`basename "$1"`.tmp
2860 # Copy files or make symbolic links. Remove obsolete files.
2864 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2865 # representing the files according to the last gnulib-tool invocation.
2866 for f in $old_files; do echo $f; done \
2867 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2870 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2871 # representing the files after this gnulib-tool invocation.
2872 for f in $new_files; do echo $f; done \
2873 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2876 # First the files that are in old-files, but not in new-files:
2877 sed_take_first_column='s,'"$delimiter"'.*,,'
2878 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2879 # Remove the file. Do nothing if the user already removed it.
2880 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
2882 echo "Removing file $g (backup in ${g}~)"
2883 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2885 echo "Remove file $g (backup in ${g}~)"
2887 func_append removed_files "$g$nl"
2890 # func_add_or_update handles a file that ought to be present afterwards.
2892 # - f the original file name
2893 # - g the rewritten file name
2894 # - already_present nonempty if the file already exists, empty otherwise
2895 func_add_or_update ()
2899 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
2901 func_dest_tmpfilename "$g"
2902 func_lookup_file "$f"
2903 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2904 if test -n "$sed_transform_main_lib_file"; then
2907 sed -e "$sed_transform_main_lib_file" \
2908 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2912 if test -n "$sed_transform_testsrelated_lib_file"; then
2915 sed -e "$sed_transform_testsrelated_lib_file" \
2916 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2920 if test -f "$destdir/$g"; then
2921 # The file already exists.
2922 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2923 : # The file has not changed.
2927 if test -n "$already_present"; then
2928 echo "Updating file $g (backup in ${g}~)"
2930 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2932 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2933 if { test -n "$symbolic" \
2934 || { test -n "$lsymbolic" \
2935 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2936 && test -z "$lookedup_tmp" \
2937 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2938 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2940 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2943 if test -n "$already_present"; then
2944 echo "Update file $g (backup in ${g}~)"
2946 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2952 # Don't protest if the file should be there but isn't: it happens
2953 # frequently that developers don't put autogenerated files into CVS.
2955 echo "Copying file $g"
2956 if { test -n "$symbolic" \
2957 || { test -n "$lsymbolic" \
2958 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2959 && test -z "$lookedup_tmp" \
2960 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2961 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2963 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2968 func_append added_files "$g$nl"
2972 # Then the files that are in new-files, but not in old-files:
2973 sed_take_last_column='s,^.*'"$delimiter"',,'
2975 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2976 | sed -e "$sed_take_last_column" \
2977 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2978 { # Rearrange file descriptors. Needed because "while ... done < ..."
2979 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2980 exec 5<&0 < "$tmp"/added-files
2986 # Then the files that are in new-files and in old-files:
2987 already_present=true
2988 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2989 | sed -e "$sed_take_last_column" \
2990 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2991 { # Rearrange file descriptors. Needed because "while ... done < ..."
2992 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2993 exec 5<&0 < "$tmp"/kept-files
3000 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
3001 actioncmd="gnulib-tool --import"
3002 func_append actioncmd " --dir=$destdir"
3003 if test -n "$local_gnulib_dir"; then
3004 func_append actioncmd " --local-dir=$local_gnulib_dir"
3006 func_append actioncmd " --lib=$libname"
3007 func_append actioncmd " --source-base=$sourcebase"
3008 func_append actioncmd " --m4-base=$m4base"
3009 if test -n "$pobase"; then
3010 func_append actioncmd " --po-base=$pobase"
3012 func_append actioncmd " --doc-base=$docbase"
3013 func_append actioncmd " --tests-base=$testsbase"
3014 func_append actioncmd " --aux-dir=$auxdir"
3015 if test -n "$inctests"; then
3016 func_append actioncmd " --with-tests"
3018 if test -n "$incobsolete"; then
3019 func_append actioncmd " --with-obsolete"
3021 for module in $avoidlist; do
3022 func_append actioncmd " --avoid=$module"
3024 if test -n "$lgpl"; then
3025 if test "$lgpl" = yes; then
3026 func_append actioncmd " --lgpl"
3028 func_append actioncmd " --lgpl=$lgpl"
3031 if test -n "$makefile_name"; then
3032 func_append actioncmd " --makefile-name=$makefile_name"
3034 if test "$libtool" = true; then
3035 func_append actioncmd " --libtool"
3037 func_append actioncmd " --no-libtool"
3039 func_append actioncmd " --macro-prefix=$macro_prefix"
3040 if test -n "$po_domain"; then
3041 func_append actioncmd " --po-domain=$po_domain"
3043 if test -n "$vc_files"; then
3044 if test "$vc_files" = true; then
3045 func_append actioncmd " --vc-files"
3047 func_append actioncmd " --no-vc-files"
3050 func_append actioncmd " `echo $specified_modules`"
3052 # Default the makefile name to Makefile.am.
3053 if test -n "$makefile_name"; then
3054 makefile_am=$makefile_name
3056 makefile_am=Makefile.am
3059 # Create normal Makefile.ams.
3062 # Setup list of Makefile.am edits that are to be performed afterwards.
3063 # Some of these edits apply to files that we will generate; others are
3064 # under the responsibility of the developer.
3066 # func_note_Makefile_am_edit dir var value
3067 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
3069 func_note_Makefile_am_edit ()
3071 makefile_am_edits=`expr $makefile_am_edits + 1`
3072 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
3073 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
3074 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
3076 if test "$makefile_am" = Makefile.am; then
3077 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3078 sourcebase_base=`basename "$sourcebase"`
3079 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
3081 if test -n "$pobase"; then
3082 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3083 pobase_base=`basename "$pobase"`
3084 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
3086 if test -n "$inctests"; then
3087 if test "$makefile_am" = Makefile.am; then
3088 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3089 testsbase_base=`basename "$testsbase"`
3090 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
3093 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
3095 # Find the first parent directory of $m4base that contains or will contain
3097 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
3099 sed_butlast='s,[^/][^/]*//*$,,'
3100 dir1="${m4base}/"; dir2=""
3101 while test -n "$dir1" \
3102 && ! { test -f "${destdir}/${dir1}Makefile.am" \
3103 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3104 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
3105 || { test -n "$inctests" \
3106 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
3107 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
3108 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
3109 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
3111 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
3114 # Create library makefile.
3115 func_dest_tmpfilename $sourcebase/$makefile_am
3116 destfile="$sourcebase/$makefile_am"
3117 modules="$main_modules"
3118 func_emit_lib_Makefile_am > "$tmpfile"
3119 if test -f "$destdir"/$sourcebase/$makefile_am; then
3120 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
3124 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3125 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
3126 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3128 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
3134 echo "Creating $sourcebase/$makefile_am"
3135 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3137 echo "Create $sourcebase/$makefile_am"
3140 func_append added_files "$sourcebase/$makefile_am$nl"
3143 # Create po/ directory.
3144 if test -n "$pobase"; then
3145 # Create po makefile and auxiliary files.
3146 for file in Makefile.in.in remove-potcdate.sin; do
3147 func_dest_tmpfilename $pobase/$file
3148 func_lookup_file build-aux/po/$file
3149 cat "$lookedup_file" > "$tmpfile"
3150 if test -f "$destdir"/$pobase/$file; then
3151 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
3155 echo "Updating $pobase/$file (backup in $pobase/$file~)"
3156 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
3157 mv -f "$tmpfile" "$destdir"/$pobase/$file
3159 echo "Update $pobase/$file (backup in $pobase/$file~)"
3165 echo "Creating $pobase/$file"
3166 mv -f "$tmpfile" "$destdir"/$pobase/$file
3168 echo "Create $pobase/$file"
3171 func_append added_files "$pobase/$file$nl"
3174 # Create po makefile parameterization, part 1.
3175 func_dest_tmpfilename $pobase/Makevars
3176 func_emit_po_Makevars > "$tmpfile"
3177 if test -f "$destdir"/$pobase/Makevars; then
3178 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
3182 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
3183 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
3184 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3186 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
3192 echo "Creating $pobase/Makevars"
3193 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3195 echo "Create $pobase/Makevars"
3198 func_append added_files "$pobase/Makevars$nl"
3200 # Create po makefile parameterization, part 2.
3201 func_dest_tmpfilename $pobase/POTFILES.in
3202 func_emit_po_POTFILES_in > "$tmpfile"
3203 if test -f "$destdir"/$pobase/POTFILES.in; then
3204 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
3208 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3209 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
3210 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3212 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3218 echo "Creating $pobase/POTFILES.in"
3219 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3221 echo "Create $pobase/POTFILES.in"
3224 func_append added_files "$pobase/POTFILES.in$nl"
3227 TP_URL="http://translationproject.org/latest/"
3228 TP_RSYNC_URI="translationproject.org::tp/latest/"
3230 echo "Fetching gnulib PO files from $TP_URL"
3231 (cd "$destdir"/$pobase \
3232 && { # Prefer rsync over wget if it is available, since it consumes
3233 # less network bandwidth, due to compression.
3234 if type rsync 2>/dev/null | grep / > /dev/null; then
3235 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
3237 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
3242 echo "Fetch gnulib PO files from $TP_URL"
3244 # Create po/LINGUAS.
3246 func_dest_tmpfilename $pobase/LINGUAS
3247 (cd "$destdir"/$pobase \
3248 && { echo '# Set of available languages.'
3249 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
3252 if test -f "$destdir"/$pobase/LINGUAS; then
3253 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
3256 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3257 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
3258 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3261 echo "Creating $pobase/LINGUAS"
3262 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3263 func_append added_files "$pobase/LINGUAS$nl"
3266 if test -f "$destdir"/$pobase/LINGUAS; then
3267 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3269 echo "Create $pobase/LINGUAS"
3274 # Create m4/gnulib-cache.m4.
3275 func_dest_tmpfilename $m4base/gnulib-cache.m4
3277 func_emit_copyright_notice
3279 echo "# This file represents the specification of how gnulib-tool is used."
3280 echo "# It acts as a cache: It is written and read by gnulib-tool."
3281 echo "# In projects using CVS, this file is meant to be stored in CVS,"
3282 echo "# like the configure.ac and various Makefile.am files."
3285 echo "# Specification in the form of a command-line invocation:"
3288 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
3289 # Store the local_gnulib_dir relative to destdir.
3290 case "$local_gnulib_dir" in
3292 relative_local_gnulib_dir="$local_gnulib_dir" ;;
3295 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
3297 # destdir, local_gnulib_dir are both relative.
3298 func_relativize "$destdir" "$local_gnulib_dir"
3299 relative_local_gnulib_dir="$reldir" ;;
3302 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
3304 echo "$specified_modules" | sed 's/^/ /g'
3306 test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
3307 echo "gl_AVOID([$avoidlist])"
3308 echo "gl_SOURCE_BASE([$sourcebase])"
3309 echo "gl_M4_BASE([$m4base])"
3310 echo "gl_PO_BASE([$pobase])"
3311 echo "gl_DOC_BASE([$docbase])"
3312 echo "gl_TESTS_BASE([$testsbase])"
3313 test -z "$inctests" || echo "gl_WITH_TESTS"
3314 echo "gl_LIB([$libname])"
3315 if test -n "$lgpl"; then
3316 if test "$lgpl" = yes; then
3319 echo "gl_LGPL([$lgpl])"
3322 echo "gl_MAKEFILE_NAME([$makefile_name])"
3323 if test "$libtool" = true; then
3326 echo "gl_MACRO_PREFIX([$macro_prefix])"
3327 echo "gl_PO_DOMAIN([$po_domain])"
3328 if test -n "$vc_files"; then
3329 echo "gl_VC_FILES([$vc_files])"
3332 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3333 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
3337 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3338 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
3339 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3341 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3345 echo "# gnulib-cache.m4 ends here"
3352 echo "Creating $m4base/gnulib-cache.m4"
3353 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3355 echo "Create $m4base/gnulib-cache.m4"
3361 # Create m4/gnulib-comp.m4.
3362 func_dest_tmpfilename $m4base/gnulib-comp.m4
3364 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
3365 func_emit_copyright_notice
3367 echo "# This file represents the compiled summary of the specification in"
3368 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
3369 echo "# to be invoked from configure.ac."
3370 echo "# In projects using CVS, this file can be treated like other built files."
3373 echo "# This macro should be invoked from $configure_ac, in the section"
3374 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
3375 echo "# any checks for libraries, header files, types and library functions."
3376 echo "AC_DEFUN([${macro_prefix}_EARLY],"
3378 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3379 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3380 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3381 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3382 echo " AC_REQUIRE([AC_PROG_RANLIB])"
3383 if test -n "$uses_subdirs"; then
3384 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
3386 for module in $final_modules; do
3388 if test -n "$module"; then
3389 func_get_autoconf_early_snippet "$module"
3392 | sed -e '/^$/d;' -e 's/^/ /'
3395 echo "# This macro should be invoked from $configure_ac, in the section"
3396 echo "# \"Check for header files, types and library functions\"."
3397 echo "AC_DEFUN([${macro_prefix}_INIT],"
3399 if test "$libtool" = true; then
3400 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3401 echo " gl_cond_libtool=true"
3403 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3404 echo " gl_cond_libtool=false"
3406 echo " gl_ltlibdeps="
3408 if test "$auxdir" != "build-aux"; then
3409 sed_replace_build_aux='
3411 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3412 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3416 sed_replace_build_aux="$sed_noop"
3418 func_emit_initmacro_start $macro_prefix
3419 echo " gl_source_base='$sourcebase'"
3420 for module in $main_modules; do
3422 if test -n "$module"; then
3423 func_get_autoconf_snippet "$module" \
3424 | sed -e '/^$/d;' -e 's/^/ /' \
3425 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3426 -e "$sed_replace_build_aux"
3427 if test "$module" = 'alloca' && test "$libtool" = true; then
3428 echo 'changequote(,)dnl'
3429 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3430 echo 'changequote([, ])dnl'
3431 echo 'AC_SUBST([LTALLOCA])'
3435 func_emit_initmacro_end $macro_prefix
3436 echo " gltests_libdeps="
3437 echo " gltests_ltlibdeps="
3438 func_emit_initmacro_start ${macro_prefix}tests
3439 echo " gl_source_base='$testsbase'"
3440 for module in $testsrelated_modules; do
3442 if test -n "$module"; then
3443 func_get_autoconf_snippet "$module" \
3444 | sed -e '/^$/d;' -e 's/^/ /' \
3445 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3446 -e "$sed_replace_build_aux" \
3447 -e 's/\$gl_cond_libtool/false/g' \
3448 -e 's/gl_libdeps/gltests_libdeps/g' \
3449 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3452 func_emit_initmacro_end ${macro_prefix}tests
3453 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3454 # created using libtool, because libtool already handles the dependencies.
3455 if test "$libtool" != true; then
3456 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3457 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3458 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3459 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3460 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3462 if $use_libtests; then
3463 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
3464 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
3467 func_emit_initmacro_done $macro_prefix $sourcebase
3468 func_emit_initmacro_done ${macro_prefix}tests $testsbase
3470 echo "# This macro records the list of files which have been installed by"
3471 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
3472 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
3473 echo "$files" | sed -e 's,^, ,'
3476 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3477 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
3481 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3482 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
3483 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3485 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3489 echo "# gnulib-comp.m4 ends here"
3496 echo "Creating $m4base/gnulib-comp.m4"
3497 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3499 echo "Create $m4base/gnulib-comp.m4"
3505 if test -n "$inctests"; then
3506 # Create tests makefile.
3507 func_dest_tmpfilename $testsbase/$makefile_am
3508 destfile="$testsbase/$makefile_am"
3509 modules="$testsrelated_modules"
3510 func_emit_tests_Makefile_am > "$tmpfile"
3511 if test -f "$destdir"/$testsbase/$makefile_am; then
3512 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
3516 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3517 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
3518 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3520 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3526 echo "Creating $testsbase/$makefile_am"
3527 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3529 echo "Create $testsbase/$makefile_am"
3532 func_append added_files "$testsbase/$makefile_am$nl"
3536 if test "$vc_files" != false; then
3537 # Update the .cvsignore and .gitignore files.
3538 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
3539 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
3540 # Treat gnulib-comp.m4 like an added file, even if it already existed.
3541 echo "$m4base/|A|gnulib-comp.m4"
3542 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
3543 { # Rearrange file descriptors. Needed because "while ... done < ..."
3544 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3545 exec 5<&0 < "$tmp"/fileset-changes
3546 func_update_ignorelist ()
3549 if test "$ignore" = .gitignore; then
3550 # In a .gitignore file, "foo" applies to the current directory and all
3551 # subdirectories, whereas "/foo" applies to the current directory only.
3554 doubly_escaped_anchor='\\/'
3558 doubly_escaped_anchor=''
3560 if test -f "$destdir/$dir$ignore"; then
3561 if test -n "$dir_added" || test -n "$dir_removed"; then
3562 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
3564 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
3565 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-added
3566 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
3567 | LC_ALL=C join -v 1 - "$tmp"/ignore > "$tmp"/ignore-removed
3569 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
3571 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3572 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
3573 { sed -e 's,/,\\/,g' -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
3574 if test -n "$anchor"; then sed -e 's,/,\\/,g' -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,$/d,' < "$tmp"/ignore-removed; fi
3575 } > "$tmp"/sed-ignore-removed
3576 { cat "$destdir/$dir$ignore"~
3577 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
3578 } | sed -f "$tmp"/sed-ignore-removed \
3579 > "$destdir/$dir$ignore"
3581 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3586 if test -n "$dir_added"; then
3588 echo "Creating $destdir/$dir$ignore"
3590 if test "$ignore" = .cvsignore; then
3592 # Automake generates Makefile rules that create .dirstamp files.
3595 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
3596 } > "$destdir/$dir$ignore"
3598 echo "Create $destdir/$dir$ignore"
3608 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
3609 func_update_ignorelist .cvsignore
3611 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
3612 func_update_ignorelist .gitignore
3619 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
3620 next_dir=`echo "$line" | sed -e 's,|.*,,'`
3621 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
3622 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
3623 if test "$next_dir" != "$last_dir"; then
3624 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3625 last_dir="$next_dir"
3630 A) func_append last_dir_added "$file$nl";;
3631 R) func_append last_dir_removed "$file$nl";;
3634 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3641 echo "You may need to add #include directives for the following .h files."
3642 # Intersect $specified_modules and $main_modules
3643 # (since $specified_modules is not necessarily of subset of $main_modules
3644 # - some may have been skipped through --avoid, and since the elements of
3645 # $main_modules but not in $specified_modules can go away without explicit
3646 # notice - through changes in the module dependencies).
3647 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
3648 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
3649 # First the #include <...> directives without #ifs, sorted for convenience,
3650 # then the #include "..." directives without #ifs, sorted for convenience,
3651 # then the #include directives that are surrounded by #ifs. Not sorted.
3652 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
3653 include_directive=`func_get_include_directive "$module"`
3654 case "$nl$include_directive" in
3656 echo "$include_directive" 1>&5
3659 echo "$include_directive" | grep -v 'include "' 1>&6
3660 echo "$include_directive" | grep 'include "' 1>&7
3663 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
3665 LC_ALL=C sort -u "$tmp"/include-angles
3666 LC_ALL=C sort -u "$tmp"/include-quotes
3667 cat "$tmp"/include-if
3668 ) | sed -e '/^$/d' -e 's/^/ /'
3669 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
3671 for module in $main_modules; do
3672 func_get_link_directive "$module"
3674 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
3675 if test `wc -l < "$tmp"/link` != 0; then
3677 echo "You may need to use the following Makefile variables when linking."
3678 echo "Use them in <program>_LDADD when linking a program, or"
3679 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
3685 echo "Don't forget to"
3686 if test "$makefile_am" = Makefile.am; then
3687 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3689 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
3691 if test -n "$pobase"; then
3692 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
3694 if test -n "$inctests"; then
3695 if test "$makefile_am" = Makefile.am; then
3696 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3698 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
3702 while test $edit != $makefile_am_edits; do
3703 edit=`expr $edit + 1`
3704 eval dir=\"\$makefile_am_edit${edit}_dir\"
3705 eval var=\"\$makefile_am_edit${edit}_var\"
3706 eval val=\"\$makefile_am_edit${edit}_val\"
3707 if test -n "$var"; then
3708 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
3711 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
3712 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
3715 # func_create_testdir testdir modules
3717 # - local_gnulib_dir from --local-dir
3718 # - auxdir directory relative to destdir where to place build aux files
3719 func_create_testdir ()
3723 if test -z "$modules"; then
3724 # All modules together.
3725 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3726 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3727 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
3728 modules=`func_all_modules`
3729 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
3731 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
3733 # Check that the license of every module is consistent with the license of
3735 saved_modules="$modules"
3736 saved_inctests="$inctests"
3737 # When computing transitive closures, don't consider $module to depend on
3738 # $module-tests. Need this becauses tests are implicitly GPL and may depend
3739 # on GPL modules - therefore we don't want a warning in this case.
3741 for requested_module in $saved_modules; do
3742 requested_license=`func_get_license "$requested_module"`
3743 if test "$requested_license" != GPL; then
3744 # Here we use func_modules_transitive_closure, not just
3745 # func_get_dependencies, so that we also detect weird situations like
3746 # an LGPL module which depends on a GPLed build tool module which depends
3748 modules="$requested_module"
3749 func_modules_transitive_closure
3750 for module in $modules; do
3751 license=`func_get_license "$module"`
3753 'GPLed build tool') ;;
3754 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3756 case "$requested_license" in
3759 GPLv2+ | LGPLv2+) ;;
3760 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3766 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3772 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3781 modules="$saved_modules"
3782 inctests="$saved_inctests"
3784 # Subdirectory names.
3794 # Determine final module list.
3795 func_modules_transitive_closure
3796 if test $verbose -ge 0; then
3797 echo "Module list with included dependencies:"
3798 echo "$modules" | sed -e 's/^/ /'
3801 # Add the dummy module if needed.
3802 func_modules_add_dummy
3804 # Show banner notice of every module.
3807 # Determine final file list.
3808 func_modules_to_filelist
3809 if test $verbose -ge 0; then
3811 echo "$files" | sed -e 's/^/ /'
3814 sed_rewrite_files="\
3815 s,^build-aux/,$auxdir/,
3817 s,^lib/,$sourcebase/,
3819 s,^tests/,$testsbase/,
3822 # Create directories.
3823 for f in $files; do echo $f; done \
3824 | sed -e "$sed_rewrite_files" \
3825 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3826 | LC_ALL=C sort -u \
3828 { # Rearrange file descriptors. Needed because "while ... done < ..."
3829 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3830 exec 5<&0 < "$tmp"/dirs
3832 mkdir -p "$testdir/$d"
3837 # Copy files or make symbolic links.
3839 for f in $files; do echo $f; done \
3840 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3843 { # Rearrange file descriptors. Needed because "while ... done < ..."
3844 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3845 exec 5<&0 < "$tmp"/files
3847 func_lookup_file "$f"
3848 if test -n "$lookedup_tmp"; then
3849 cp -p "$lookedup_file" "$testdir/$g"
3851 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3852 if { test -n "$symbolic" \
3853 || { test -n "$lsymbolic" \
3854 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3855 func_ln "$lookedup_file" "$testdir/$g"
3857 cp -p "$lookedup_file" "$testdir/$g"
3864 # Create Makefile.ams that are for testing.
3867 # No special edits are needed.
3870 # Create $sourcebase/Makefile.am.
3871 mkdir -p "$testdir/$sourcebase"
3872 destfile="$sourcebase/Makefile.am"
3873 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3874 any_uses_subdirs="$uses_subdirs"
3876 # Create $m4base/Makefile.am.
3877 mkdir -p "$testdir/$m4base"
3878 (echo "## Process this file with automake to produce Makefile.in."
3884 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
3887 ) > "$testdir/$m4base/Makefile.am"
3889 subdirs="$sourcebase $m4base"
3890 subdirs_with_configure_ac=""
3892 if false && test -f "$testdir"/$m4base/gettext.m4; then
3893 # Avoid stupid error message from automake:
3894 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
3895 mkdir -p "$testdir/po"
3896 (echo "## Process this file with automake to produce Makefile.in."
3897 ) > "$testdir/po/Makefile.am"
3898 func_append subdirs " po"
3901 if test -n "$inctests"; then
3902 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
3903 # Viewed from the $testsbase subdirectory, $auxdir is different.
3904 saved_auxdir="$auxdir"
3905 auxdir=`echo "$testsbase/"|sed 's%[^/][^/]*//*%../%g'`"$auxdir"
3906 # Create $testsbase/Makefile.am.
3908 destfile="$testsbase/Makefile.am"
3909 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
3910 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
3911 # Create $testsbase/configure.ac.
3912 (echo "# Process this file with autoconf to produce a configure script."
3913 echo "AC_INIT([dummy], [0])"
3914 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3915 echo "AM_INIT_AUTOMAKE"
3917 echo "AM_CONFIG_HEADER([config.h])"
3920 echo "AC_PROG_INSTALL"
3921 echo "AC_PROG_MAKE_SET"
3922 echo "AC_PROG_RANLIB"
3924 for module in $modules; do
3926 if test -n "$module"; then
3928 gnumakefile | maintainer-makefile)
3929 # These modules are meant to be used only in the top-level directory.
3932 func_get_autoconf_early_snippet "$module"
3937 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3938 if test "$libtool" = true; then
3939 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3940 echo "gl_cond_libtool=true"
3942 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3943 echo "gl_cond_libtool=false"
3945 echo "gl_ltlibdeps="
3947 # Wrap the set of autoconf snippets into an autoconf macro that is then
3948 # invoked. This is needed because autoconf does not support AC_REQUIRE
3950 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3951 # but we want the AC_REQUIRE to have its normal meaning (provide one
3952 # expansion of the required macro before the current point, and only one
3954 echo "AC_DEFUN([gl_INIT], ["
3955 sed_replace_build_aux='
3957 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3958 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3961 func_emit_initmacro_start $macro_prefix
3962 # We don't have explicit ordering constraints between the various
3963 # autoconf snippets. It's cleanest to put those of the library before
3964 # those of the tests.
3965 echo "gl_source_base='../$sourcebase'"
3966 for module in $modules; do
3967 func_verify_nontests_module
3968 if test -n "$module"; then
3970 gnumakefile | maintainer-makefile)
3971 # These modules are meant to be used only in the top-level directory.
3974 func_get_autoconf_snippet "$module" \
3975 | sed -e "$sed_replace_build_aux"
3980 echo "gl_source_base='.'"
3981 for module in $modules; do
3982 func_verify_tests_module
3983 if test -n "$module"; then
3984 func_get_autoconf_snippet "$module" \
3985 | sed -e "$sed_replace_build_aux"
3988 func_emit_initmacro_end $macro_prefix
3989 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3990 # created using libtool, because libtool already handles the dependencies.
3991 if test "$libtool" != true; then
3992 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3993 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3994 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3995 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3996 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3999 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
4003 # Usually $testsbase/config.h will be a superset of config.h. Verify this
4004 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
4005 echo "AH_TOP([#include \"../config.h\"])"
4007 echo "AC_OUTPUT([Makefile])"
4008 ) > "$testdir/$testsbase/configure.ac"
4009 auxdir="$saved_auxdir"
4010 func_append subdirs " $testsbase"
4011 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
4014 # Create Makefile.am.
4015 (echo "## Process this file with automake to produce Makefile.in."
4017 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4019 echo "SUBDIRS = $subdirs"
4021 echo "ACLOCAL_AMFLAGS = -I $m4base"
4022 ) > "$testdir/Makefile.am"
4024 # Create configure.ac.
4025 (echo "# Process this file with autoconf to produce a configure script."
4026 echo "AC_INIT([dummy], [0])"
4027 if test "$auxdir" != "."; then
4028 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4030 echo "AM_INIT_AUTOMAKE"
4032 echo "AM_CONFIG_HEADER([config.h])"
4035 echo "AC_PROG_INSTALL"
4036 echo "AC_PROG_MAKE_SET"
4038 echo "# For autobuild."
4039 echo "AC_CANONICAL_BUILD"
4040 echo "AC_CANONICAL_HOST"
4042 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
4043 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
4044 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
4045 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
4047 echo "AC_PROG_RANLIB"
4049 if test -n "$any_uses_subdirs"; then
4050 echo "AM_PROG_CC_C_O"
4053 for module in $modules; do
4054 func_verify_nontests_module
4055 if test -n "$module"; then
4056 func_get_autoconf_early_snippet "$module"
4059 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
4060 if test "$libtool" = true; then
4061 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
4062 echo "gl_cond_libtool=true"
4064 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
4065 echo "gl_cond_libtool=false"
4067 echo "gl_ltlibdeps="
4069 # Wrap the set of autoconf snippets into an autoconf macro that is then
4070 # invoked. This is needed because autoconf does not support AC_REQUIRE
4072 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
4073 # but we want the AC_REQUIRE to have its normal meaning (provide one
4074 # expansion of the required macro before the current point, and only one
4076 echo "AC_DEFUN([gl_INIT], ["
4077 if test "$auxdir" != "build-aux"; then
4078 sed_replace_build_aux='
4080 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
4081 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
4085 sed_replace_build_aux="$sed_noop"
4087 func_emit_initmacro_start $macro_prefix
4088 echo "gl_source_base='$sourcebase'"
4089 for module in $modules; do
4090 func_verify_nontests_module
4091 if test -n "$module"; then
4092 func_get_autoconf_snippet "$module" \
4093 | sed -e "$sed_replace_build_aux"
4096 func_emit_initmacro_end $macro_prefix
4097 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
4098 # created using libtool, because libtool already handles the dependencies.
4099 if test "$libtool" != true; then
4100 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
4101 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
4102 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
4103 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
4104 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
4107 func_emit_initmacro_done $macro_prefix $sourcebase
4111 if test -n "$subdirs_with_configure_ac"; then
4112 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
4114 makefiles="Makefile"
4115 for d in $subdirs; do
4116 # For subdirs that have a configure.ac by their own, it's the subdir's
4117 # configure.ac which creates the subdir's Makefile.am, not this one.
4118 case " $subdirs_with_configure_ac " in
4120 *) func_append makefiles " $d/Makefile" ;;
4123 echo "AC_OUTPUT([$makefiles])"
4124 ) > "$testdir/configure.ac"
4126 # Create autogenerated files.
4128 # Do not use "${AUTORECONF} --force --install", because it may invoke
4129 # autopoint, which brings in older versions of some of our .m4 files.
4130 if test -f $m4base/gettext.m4; then
4131 func_execute_command ${AUTOPOINT} --force || func_exit 1
4132 for f in $m4base/*.m4~; do
4134 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4138 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
4139 if ! test -d build-aux; then
4140 func_execute_command mkdir build-aux || func_exit 1
4142 func_execute_command ${AUTOCONF} || func_exit 1
4143 func_execute_command ${AUTOHEADER} || func_exit 1
4144 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4146 if test -n "$inctests"; then
4147 # Create autogenerated files.
4148 (cd "$testdir/$testsbase" || func_exit 1
4149 # Do not use "${AUTORECONF} --force --install", because it may invoke
4150 # autopoint, which brings in older versions of some of our .m4 files.
4151 if test -f ../$m4base/gettext.m4; then
4152 func_execute_command ${AUTOPOINT} --force || func_exit 1
4153 for f in ../$m4base/*.m4~; do
4155 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4159 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
4160 if ! test -d ../build-aux; then
4161 func_execute_command mkdir ../build-aux
4163 func_execute_command ${AUTOCONF} || func_exit 1
4164 func_execute_command ${AUTOHEADER} || func_exit 1
4165 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4168 # Need to run configure and make once, to create built files that are to be
4169 # distributed (such as getdate.c).
4170 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
4171 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4172 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
4173 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
4174 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
4175 # such $(FOO_H) because they don't refer to distributed files.
4176 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
4177 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4178 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
4179 | sed -e "$sed_remove_make_variables"`
4180 distributed_built_sources=`for file in $built_sources; do
4181 case "$cleaned_files" in
4186 if test -n "$distributed_built_sources"; then
4188 ./configure || func_exit 1
4190 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
4191 make built_sources || func_exit 1
4193 make distclean || func_exit 1
4198 # func_create_megatestdir megatestdir allmodules
4200 # - local_gnulib_dir from --local-dir
4201 # - auxdir directory relative to destdir where to place build aux files
4202 func_create_megatestdir ()
4206 if test -z "$allmodules"; then
4207 allmodules=`func_all_modules`
4211 # First, all modules one by one.
4212 for onemodule in $allmodules; do
4213 func_create_testdir "$megatestdir/$onemodule" $onemodule
4214 func_append megasubdirs "$onemodule "
4216 # Then, all modules all together.
4217 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4218 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
4219 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
4220 func_create_testdir "$megatestdir/ALL" "$allmodules"
4221 func_append megasubdirs "ALL"
4224 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
4225 vc_witness="$gnulib_dir/CVS/Entries"; \
4227 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
4229 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
4230 | sed -e 's,January,01,' -e 's,Jan,01,' \
4231 -e 's,February,02,' -e 's,Feb,02,' \
4232 -e 's,March,03,' -e 's,Mar,03,' \
4233 -e 's,April,04,' -e 's,Apr,04,' \
4235 -e 's,June,06,' -e 's,Jun,06,' \
4236 -e 's,July,07,' -e 's,Jul,07,' \
4237 -e 's,August,08,' -e 's,Aug,08,' \
4238 -e 's,September,09,' -e 's,Sep,09,' \
4239 -e 's,October,10,' -e 's,Oct,10,' \
4240 -e 's,November,11,' -e 's,Nov,11,' \
4241 -e 's,December,12,' -e 's,Dec,12,' \
4242 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
4243 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
4245 echo "CVSDATE=$cvsdate"
4246 echo "test -d logs || mkdir logs"
4247 echo "for module in $megasubdirs; do"
4248 echo " echo \"Working on module \$module...\""
4249 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
4250 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
4253 echo " : autobuild project... \$module"
4254 echo " : autobuild revision... cvs-\$CVSDATE-000000"
4255 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
4256 echo " : autobuild hostname... \`hostname\`"
4257 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
4259 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
4261 ) > "$megatestdir/do-autobuild"
4262 chmod a+x "$megatestdir/do-autobuild"
4264 # Create Makefile.am.
4265 (echo "## Process this file with automake to produce Makefile.in."
4267 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4269 echo "SUBDIRS = $megasubdirs"
4271 echo "EXTRA_DIST = do-autobuild"
4272 ) > "$megatestdir/Makefile.am"
4274 # Create configure.ac.
4275 (echo "# Process this file with autoconf to produce a configure script."
4276 echo "AC_INIT([dummy], [0])"
4277 if test "$auxdir" != "."; then
4278 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4280 echo "AM_INIT_AUTOMAKE"
4282 echo "AC_PROG_MAKE_SET"
4284 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
4285 echo "AC_OUTPUT([Makefile])"
4286 ) > "$megatestdir/configure.ac"
4288 # Create autogenerated files.
4290 # Do not use "${AUTORECONF} --install", because autoreconf operates
4291 # recursively, but the subdirectories are already finished, therefore
4292 # calling autoreconf here would only waste lots of CPU time.
4293 func_execute_command ${ACLOCAL} || func_exit 1
4294 func_execute_command mkdir build-aux
4295 func_execute_command ${AUTOCONF} || func_exit 1
4296 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4302 func_fatal_error "no mode specified" ;;
4311 if test -z "$destdir"; then
4314 test -d "$destdir" \
4315 || func_fatal_error "destination directory does not exist: $destdir"
4317 # Prefer configure.ac to configure.in.
4318 if test -f "$destdir"/configure.ac; then
4319 configure_ac="$destdir/configure.ac"
4321 if test -f "$destdir"/configure.in; then
4322 configure_ac="$destdir/configure.in"
4324 func_fatal_error "cannot find $destdir/configure.ac"
4328 # Analyze configure.ac.
4330 guessed_libtool=false
4335 /AC_CONFIG_AUX_DIR/ {
4336 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^]"$`\\)]*\).*$,guessed_auxdir="\1",p
4338 /A[CM]_PROG_LIBTOOL/ {
4339 s,^.*$,guessed_libtool=true,p
4341 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
4343 if test -z "$auxdir"; then
4344 auxdir="$guessed_auxdir"
4347 # Determine where to apply func_import.
4348 if test -n "$m4base"; then
4349 # Apply func_import to a particular gnulib directory.
4350 # Any number of additional modules can be given.
4351 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
4352 # First use of gnulib in the given m4base.
4353 test -n "$supplied_libname" || supplied_libname=true
4354 test -n "$sourcebase" || sourcebase="lib"
4355 test -n "$docbase" || docbase="doc"
4356 test -n "$testsbase" || testsbase="tests"
4357 test -n "$macro_prefix" || macro_prefix="gl"
4361 # Apply func_import to all gnulib directories.
4362 # To get this list of directories, look at Makefile.am. (Not at
4363 # configure, because it may be omitted from CVS. Also, don't run
4364 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
4367 if test -f "$destdir"/Makefile.am; then
4368 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
4370 for arg in $aclocal_amflags; do
4371 if test -n "$m4dir_is_next"; then
4372 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
4376 if test -f "$destdir/$arg"/gnulib-cache.m4; then
4377 func_append m4dirs " $arg"
4378 m4dirs_count=`expr $m4dirs_count + 1`
4384 if test "X$arg" = "X-I"; then
4392 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
4393 if test -f "$destdir"/aclocal.m4; then
4394 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
4395 sedexpr2='s,^[^/]*$,.,'
4396 sedexpr3='s,/[^/]*$,,'
4397 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
4398 m4dirs_count=`echo "$m4dirs" | wc -l`
4401 if test $m4dirs_count = 0; then
4402 # First use of gnulib in a package.
4403 # Any number of additional modules can be given.
4404 test -n "$supplied_libname" || supplied_libname=true
4405 test -n "$sourcebase" || sourcebase="lib"
4407 test -n "$docbase" || docbase="doc"
4408 test -n "$testsbase" || testsbase="tests"
4409 test -n "$macro_prefix" || macro_prefix="gl"
4412 if test $m4dirs_count = 1; then
4413 # There's only one use of gnulib here. Assume the user means it.
4414 # Any number of additional modules can be given.
4415 for m4base in $m4dirs; do
4419 # Ambiguous - guess what the user meant.
4420 if test $# = 0; then
4421 # No further arguments. Guess the user wants to update all of them.
4422 for m4base in $m4dirs; do
4423 # Perform func_import in a subshell, so that variable values
4425 # local_gnulib_dir, incobsolete, avoidlist, sourcebase, m4base,
4426 # pobase, docbase, testsbase, inctests, libname, lgpl,
4427 # makefile_name, libtool, macro_prefix, po_domain, vc_files
4428 # don't propagate from one directory to another.
4429 (func_import) || func_exit 1
4433 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
4441 if test -z "$destdir"; then
4442 func_fatal_error "please specify --dir option"
4445 test -d "$destdir" \
4446 || func_fatal_error "could not create destination directory"
4447 test -n "$auxdir" || auxdir="build-aux"
4448 func_create_testdir "$destdir" "$*"
4451 create-megatestdir )
4452 if test -z "$destdir"; then
4453 func_fatal_error "please specify --dir option"
4455 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4456 test -n "$auxdir" || auxdir="build-aux"
4457 func_create_megatestdir "$destdir" "$*"
4461 test -n "$destdir" || destdir=testdir$$
4462 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4463 test -n "$auxdir" || auxdir="build-aux"
4464 func_create_testdir "$destdir" "$*"
4468 ../configure || func_exit 1
4470 make check || func_exit 1
4471 make distclean || func_exit 1
4472 remaining=`find . -type f -print`
4473 if test -n "$remaining"; then
4474 echo "Remaining files:" $remaining 1>&2
4475 echo "gnulib-tool: *** Stop." 1>&2
4484 test -n "$destdir" || destdir=testdir$$
4485 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4486 test -n "$auxdir" || auxdir="build-aux"
4487 func_create_megatestdir "$destdir" "$*"
4495 remaining=`find . -type f -print`
4496 if test -n "$remaining"; then
4497 echo "Remaining files:" $remaining 1>&2
4498 echo "gnulib-tool: *** Stop." 1>&2
4506 extract-description )
4510 if test -n "$module"; then
4511 func_get_description "$module"
4520 if test -n "$module"; then
4521 func_get_status "$module"
4530 if test -n "$module"; then
4531 func_get_notice "$module"
4540 if test -n "$module"; then
4541 func_get_filelist "$module"
4546 extract-dependencies )
4550 if test -n "$module"; then
4551 func_get_dependencies "$module"
4556 extract-autoconf-snippet )
4560 if test -n "$module"; then
4561 func_get_autoconf_snippet "$module"
4566 extract-automake-snippet )
4570 if test -n "$module"; then
4571 func_get_automake_snippet "$module"
4576 extract-include-directive )
4580 if test -n "$module"; then
4581 func_get_include_directive "$module"
4586 extract-link-directive )
4590 if test -n "$module"; then
4591 func_get_link_directive "$module"
4600 if test -n "$module"; then
4601 func_get_license "$module"
4606 extract-maintainer )
4610 if test -n "$module"; then
4611 func_get_maintainer "$module"
4616 extract-tests-module )
4620 if test -n "$module"; then
4621 func_get_tests_module "$module"
4627 func_fatal_error "unknown operation mode --$mode" ;;
4631 # Undo the effect of the previous 'trap' command. Some shellology:
4632 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
4633 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
4634 # exit); for the others we need to call 'exit' explicitly. The value of $? is
4635 # 128 + signal number and is set before the trap-registered command is run.
4637 trap 'func_exit $?' 1 2 3 13 15
4642 # indent-tabs-mode: nil
4643 # whitespace-check-buffer-indent: nil