3 # Copyright (C) 2002-2008 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 # When using GNU sed, turn off as many GNU extensions as possible,
67 # to minimize the risk of accidentally using non-portable features.
68 # However, do this only for gnulib-tool itself, not for the code that
69 # gnulib-tool generates, since we don't want "sed --posix" to leak
71 if (alias) > /dev/null 2>&1 && echo | sed --posix -e d >/dev/null 2>&1; then
72 # Define sed as an alias.
73 # It is not always possible to use aliases. Aliases are guaranteed to work
74 # if the executing shell is bash and either it is invoked as /bin/sh or
75 # is a version >= 2.0, supporting shopt. This is the common case.
76 # Two other approaches (use of a variable $sed or of a function func_sed
77 # instead of an alias) require massive, fragile code changes.
78 # An other approach (use of function sed) requires `which sed` - but 'which'
79 # is hard to emulate, due to missing "test -x" on some platforms.
80 if test -n "$BASH_VERSION"; then
81 shopt -s expand_aliases >/dev/null 2>&1
83 alias sed='sed --posix'
86 # sed_noop is a sed expression that does nothing.
87 # An empty expression does not work with the native 'sed' on AIX 6.1.
91 # outputs to stdout the --help usage message.
95 Usage: gnulib-tool --list
96 gnulib-tool --import [module1 ... moduleN]
98 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
99 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
100 gnulib-tool --test --dir=directory module1 ... moduleN
101 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
102 gnulib-tool --extract-description module
103 gnulib-tool --extract-status module
104 gnulib-tool --extract-notice module
105 gnulib-tool --extract-filelist module
106 gnulib-tool --extract-dependencies module
107 gnulib-tool --extract-autoconf-snippet module
108 gnulib-tool --extract-automake-snippet module
109 gnulib-tool --extract-include-directive module
110 gnulib-tool --extract-link-directive module
111 gnulib-tool --extract-license module
112 gnulib-tool --extract-maintainer module
113 gnulib-tool --extract-tests-module module
116 --list print the available module names
117 --import import the given modules into the current package;
118 if no modules are specified, update the current
119 package from the current gnulib
120 --update update the current package, restore files omitted
122 --create-testdir create a scratch package with the given modules
123 --create-megatestdir create a mega scratch package with the given modules
124 one by one and all together
125 --test test the combination of the given modules
126 (recommended to use CC=\"gcc -Wall\" here)
127 --megatest test the given modules one by one and all together
128 (recommended to use CC=\"gcc -Wall\" here)
129 --extract-description extract the description
130 --extract-status extract the status (obsolete or not)
131 --extract-notice extract the notice or banner
132 --extract-filelist extract the list of files
133 --extract-dependencies extract the dependencies
134 --extract-autoconf-snippet extract the snippet for configure.ac
135 --extract-automake-snippet extract the snippet for library makefile
136 --extract-include-directive extract the #include directive
137 --extract-link-directive extract the linker directive
138 --extract-license report the license terms of the source files
140 --extract-maintainer report the maintainer(s) inside gnulib
141 --extract-tests-module report the unit test module, if it exists
144 --dir=DIRECTORY Specify the target directory.
145 For --import, this specifies where your
146 configure.ac can be found. Defaults to current
148 --local-dir=DIRECTORY Specify a local override directory where to look
149 up files before looking in gnulib's directory.
150 --verbose Increase verbosity. May be repeated.
151 --quiet Decrease verbosity. May be repeated.
153 Options for --import:
154 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
155 --source-base=DIRECTORY
156 Directory relative to --dir where source code is
157 placed (default \"lib\").
158 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
159 placed (default \"m4\").
160 --po-base=DIRECTORY Directory relative to --dir where *.po files are
161 placed (default \"po\").
162 --doc-base=DIRECTORY Directory relative to --dir where doc files are
163 placed (default \"doc\").
164 --tests-base=DIRECTORY
165 Directory relative to --dir where unit tests are
166 placed (default \"tests\").
167 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
168 tools are placed (default \"build-aux\").
169 --with-tests Include unit tests for the included modules.
170 --avoid=MODULE Avoid including the given MODULE. Useful if you
171 have code that provides equivalent functionality.
172 This option can be repeated.
173 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
174 Also modify license template from GPL to LGPL.
175 The version number of the LGPL can be specified;
176 the default is currently LGPLv3.
177 --makefile-name=NAME Name of makefile in automake syntax in the
178 source-base and tests-base directories
179 (default \"Makefile.am\").
180 --libtool Use libtool rules.
181 --no-libtool Don't use libtool rules.
182 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
183 'gl_INIT'. Default is 'gl'.
184 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
185 the package name. A suffix '-gnulib' is appended.
186 --vc-files Update version control related files.
187 --no-vc-files Don't update version control related files
188 (.gitignore and/or .cvsignore).
189 --no-changelog Don't update or create ChangeLog files.
191 Options for --import and --update:
192 --dry-run For --import, only print what would have been done.
193 -s, --symbolic, --symlink Make symbolic links instead of copying files.
194 --local-symlink Make symbolic links instead of copying files, only
195 for files from the local override directory.
196 -S, --more-symlinks Make symbolic links instead of copying files, and
197 don't replace copyright notices.
199 Report bugs to <bug-gnulib@gnu.org>."
203 # outputs to stdout the --version message.
207 if test -d "$gnulib_dir"/.git \
208 && (git --version) >/dev/null 2>/dev/null \
209 && (date --version) >/dev/null 2>/dev/null; then
210 # gnulib checked out from git.
211 sed_extract_first_date='/^Date/{
215 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
216 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
217 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
218 date=`echo "$date" | sed -e "$sed_year_before_time"`
219 # Use GNU date to compute the time in GMT.
220 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
221 version=' '`cd "$gnulib_dir" && ./build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
223 if test -d "$gnulib_dir"/CVS \
224 && (cvs --version) >/dev/null 2>/dev/null; then
225 # gnulib checked out from CVS.
226 sed_extract_first_date='/^date: /{
227 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
230 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
232 # gnulib copy without versioning information.
233 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
237 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed 's,^.* ,,'`
239 gnulib-tool (GNU $package $date)$version
240 Copyright (C) $year Free Software Foundation, Inc.
241 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
242 This is free software: you are free to change and redistribute it.
243 There is NO WARRANTY, to the extent permitted by law.
245 Written by" "Bruno Haible" "and" "Simon Josefsson"
248 # func_emit_copyright_notice
249 # outputs to stdout a header for a generated file.
250 func_emit_copyright_notice ()
252 sed -n '/Copyright/ {
255 }' < "$self_abspathname"
257 echo "# This file is free software, distributed under the terms of the GNU"
258 echo "# General Public License. As a special exception to the GNU General"
259 echo "# Public License, this file may be distributed as part of a program"
260 echo "# that contains a configuration script generated by Autoconf, under"
261 echo "# the same distribution terms as the rest of that program."
263 echo "# Generated by gnulib-tool."
267 # exits with a given status.
268 # This function needs to be used, rather than 'exit', when a 'trap' handler is
269 # in effect that refers to $?.
276 # locates the directory where the gnulib repository lives
278 # - progname name of this program
280 # - self_abspathname absolute pathname of gnulib-tool
281 # - gnulib_dir absolute pathname of gnulib repository
285 /*) self_abspathname="$progname" ;;
286 */*) self_abspathname=`pwd`/"$progname" ;;
289 # Iterate through the elements of $PATH.
290 # We use IFS=: instead of
291 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
292 # because the latter does not work when some PATH element contains spaces.
293 # We use a canonicalized $pathx instead of $PATH, because empty PATH
294 # elements are by definition equivalent to '.', however field splitting
295 # according to IFS=: loses empty fields in many shells:
296 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
297 # beginning, at the end, and in the middle),
298 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
299 # at the beginning and at the end,
300 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
301 # Solaris lose empty fields at the end.
302 # The 'case' statement is an optimization, to avoid evaluating the
303 # explicit canonicalization command when $PATH contains no empty fields.
305 if test "${PATH_SEPARATOR+set}" != set; then
307 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
308 chmod +x "$tmp"/conf.sh
309 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
316 if test "$PATH_SEPARATOR" = ";"; then
317 # On Windows, programs are searched in "." before $PATH.
320 # On Unix, we have to convert empty PATH elements to ".".
324 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
329 IFS="$PATH_SEPARATOR"
333 if test -x "$d/$progname" && test ! -d "$d/$progname"; then
334 self_abspathname="$d/$progname"
339 if test -z "$self_abspathname"; then
340 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
344 while test -h "$self_abspathname"; do
345 # Resolve symbolic link.
346 linkval=`func_readlink "$self_abspathname"`
347 test -n "$linkval" || break
349 /* ) self_abspathname="$linkval" ;;
350 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
353 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
357 # creates a temporary directory.
359 # - progname name of this program
361 # - tmp pathname of freshly created temporary directory
364 # Use the environment variable TMPDIR, falling back to /tmp. This allows
365 # users to specify a different temporary directory, for example, if their
366 # /tmp is filled up or too small.
369 # Use the mktemp program if available. If not available, hide the error
371 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
372 test -n "$tmp" && test -d "$tmp"
375 # Use a simple mkdir command. It is guaranteed to fail if the directory
376 # already exists. $RANDOM is bash specific and expands to empty in shells
377 # other than bash, ksh and zsh. Its use does not increase security;
378 # rather, it minimizes the probability of failure in a very cluttered /tmp
380 tmp=$TMPDIR/gl$$-$RANDOM
381 (umask 077 && mkdir "$tmp")
384 echo "$progname: cannot create a temporary directory in $TMPDIR" >&2
389 # func_append var value
390 # appends the given value to the shell variable var.
391 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
392 # Use bash's += operator. It reduces complexity of appending repeatedly to
393 # a single variable from O(n^2) to O(n).
401 eval "$1=\"\$$1\$2\""
405 # func_fatal_error message
406 # outputs to stderr a fatal error message, and terminates the program.
408 # - progname name of this program
411 echo "$progname: *** $1" 1>&2
412 echo "$progname: *** Stop." 1>&2
416 # func_readlink SYMLINK
417 # outputs the target of the given symlink.
418 if (type -p readlink) > /dev/null 2>&1; then
421 # Use the readlink program from GNU coreutils.
427 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
428 # would do the wrong thing if the link target contains " -> ".
429 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
433 # func_relativize DIR1 DIR2
434 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
436 # - DIR1 relative pathname, relative to the current directory
437 # - DIR2 relative pathname, relative to the current directory
439 # - reldir relative pathname of DIR2, relative to DIR1
445 sed_first='s,^\([^/]*\)/.*$,\1,'
446 sed_rest='s,^[^/]*/*,,'
447 sed_last='s,^.*/\([^/]*\)$,\1,'
448 sed_butlast='s,/*[^/]*$,,'
449 while test -n "$dir1"; do
450 first=`echo "$dir1" | sed -e "$sed_first"`
451 if test "$first" != "."; then
452 if test "$first" = ".."; then
453 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
454 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
456 first2=`echo "$dir2" | sed -e "$sed_first"`
457 if test "$first2" = "$first"; then
458 dir2=`echo "$dir2" | sed -e "$sed_rest"`
462 dir0="$dir0"/"$first"
465 dir1=`echo "$dir1" | sed -e "$sed_rest"`
470 # func_relconcat DIR1 DIR2
471 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
473 # - DIR1 relative pathname, relative to the current directory
474 # - DIR2 relative pathname, relative to DIR1
476 # - relconcat DIR1/DIR2, relative to the current directory
481 sed_first='s,^\([^/]*\)/.*$,\1,'
482 sed_rest='s,^[^/]*/*,,'
483 sed_last='s,^.*/\([^/]*\)$,\1,'
484 sed_butlast='s,/*[^/]*$,,'
486 first=`echo "$dir2" | sed -e "$sed_first"`
487 if test "$first" = "."; then
488 dir2=`echo "$dir2" | sed -e "$sed_rest"`
489 if test -z "$dir2"; then
494 last=`echo "$dir1" | sed -e "$sed_last"`
495 while test "$last" = "."; do
496 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
497 last=`echo "$dir1" | sed -e "$sed_last"`
499 if test -z "$dir1"; then
503 if test "$first" = ".."; then
504 if test "$last" = ".."; then
505 relconcat="$dir1/$dir2"
508 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
509 dir2=`echo "$dir2" | sed -e "$sed_rest"`
510 if test -z "$dir1"; then
514 if test -z "$dir2"; then
519 relconcat="$dir1/$dir2"
527 # Like ln -s, except that SRC is given relative to the current directory (or
528 # absolute), not given relative to the directory of DEST.
534 *) # SRC is relative.
537 ln -s "`pwd`/$1" "$2" ;;
538 *) # DEST is relative too.
539 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
540 test -n "$ln_destdir" || ln_destdir="."
541 func_relativize "$ln_destdir" "$1"
549 # func_ln_if_changed SRC DEST
550 # Like func_ln, but avoids munging timestamps if the link is correct.
551 func_ln_if_changed ()
553 if test $# -ne 2; then
554 echo "usage: func_ln_if_changed SRC DEST" >&2
556 ln_target=`func_readlink "$2"`
557 if test -h "$2" && test "$1" = "$ln_target"; then
566 # Resets SIGPIPE to its default behaviour. SIGPIPE is signalled when a process
567 # writes into a pipe with no readers, i.e. a pipe where all readers have
568 # already closed their file descriptor that read from it or exited entirely.
569 # The default behaviour is to terminate the current process without an error
571 # When "trap '' SIGPIPE" is in effect, the behaviour (at least with bash) is to
572 # terminate the current process with an error message.
573 # This function should be called at the beginning of a command that only
574 # produces output to stdout (i.e. no side effects!), when the command that
575 # will read from this pipe might prematurely exit or close its standard input
577 if test -n "$BASH_VERSION"; then
578 # The problem has only been reported with bash.
579 # Note that Solaris sh does not understand "trap - SIGPIPE".
580 func_reset_sigpipe ()
585 func_reset_sigpipe ()
591 # Ensure an 'echo' command that does not interpret backslashes.
593 # echo '\n' | wc -l prints 1 when OK, 2 when KO
594 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
595 # This problem is a weird heritage from SVR4. BSD got it right (except that
596 # BSD echo interprets '-n' as an option, which is also not desirable).
597 # Nowadays the problem occurs in 4 situations:
598 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
599 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
600 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
601 # - in zsh, when sh-emulation is not set,
602 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
603 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
604 # - in Solaris /bin/sh and OSF/1 /bin/sh.
605 # We try the following workarounds:
606 # - for all: respawn using $CONFIG_SHELL if that is set and works.
607 # - for bash >= 2.04: unset the shell option xpg_echo.
608 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
609 # - for bash < 2.0: define echo to a function that uses cat of a here document.
610 # - for zsh: turn sh-emulation on.
611 # - for ksh: alias echo to 'print -r'.
612 # - for ksh: alias echo to a function that uses cat of a here document.
613 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
614 # the ksh workaround.
615 # - otherwise: respawn using /bin/sh and rely on the workarounds.
616 # When respawning, we pass --no-reexec as first argument, so as to avoid
617 # turning this script into a fork bomb in unlucky situations.
619 if echo '\t' | grep t > /dev/null; then
620 have_echo=yes # Lucky!
622 # Try the workarounds.
623 # Respawn using $CONFIG_SHELL if that is set and works.
624 if test -z "$have_echo" \
625 && test "X$1" != "X--no-reexec" \
626 && test -n "$CONFIG_SHELL" \
627 && test -f "$CONFIG_SHELL" \
628 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
629 exec $CONFIG_SHELL "$0" --no-reexec "$@"
632 # For bash >= 2.04: unset the shell option xpg_echo.
633 if test -z "$have_echo" \
634 && test -n "$BASH_VERSION" \
635 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
639 # For bash >= 2.0: define echo to a function that uses the printf built-in.
640 # For bash < 2.0: define echo to a function that uses cat of a here document.
641 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
642 if test -z "$have_echo" \
643 && test -n "$BASH_VERSION"; then \
644 if type printf 2>/dev/null | grep / > /dev/null; then
645 # 'printf' is not a shell built-in.
653 # 'printf' is a shell built-in.
659 if echo '\t' | grep t > /dev/null; then
663 # For zsh: turn sh-emulation on.
664 if test -z "$have_echo" \
665 && test -n "$ZSH_VERSION" \
666 && (emulate sh) >/dev/null 2>&1; then
669 # For ksh: alias echo to 'print -r'.
670 if test -z "$have_echo" \
671 && (type print) >/dev/null 2>&1; then
672 # A 'print' command exists.
673 if type print 2>/dev/null | grep / > /dev/null; then
676 # 'print' is a shell built-in.
677 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
678 # 'print' is the ksh shell built-in.
679 alias echo='print -r'
683 if test -z "$have_echo" \
684 && echo '\t' | grep t > /dev/null; then
687 # For ksh: alias echo to a function that uses cat of a here document.
688 # The ksh manual page says:
689 # "Aliasing is performed when scripts are read, not while they are executed.
690 # Therefore, for an alias to take effect, the alias definition command has
691 # to be executed before the command which references the alias is read."
692 # Because of this, we have to play strange tricks with have_echo, to ensure
693 # that the top-level statement containing the test starts after the 'alias'
695 if test -z "$have_echo"; then
702 alias echo=bsd_echo 2>/dev/null
704 if test -z "$have_echo" \
705 && echo '\t' | grep t > /dev/null; then
708 if test -z "$have_echo"; then
709 unalias echo 2>/dev/null
711 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
712 if test -z "$have_echo" \
713 && test "X$1" != "X--no-reexec" \
714 && test -f /bin/ksh; then
715 exec /bin/ksh "$0" --no-reexec "$@"
718 # Otherwise: respawn using /bin/sh.
719 if test -z "$have_echo" \
720 && test "X$1" != "X--no-reexec" \
721 && test -f /bin/sh; then
722 exec /bin/sh "$0" --no-reexec "$@"
725 if test -z "$have_echo"; then
726 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
728 if echo '\t' | grep t > /dev/null; then
731 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
733 if test "X$1" = "X--no-reexec"; then
737 # Command-line option processing.
738 # Removes the OPTIONS from the arguments. Sets the variables:
739 # - mode list or import or create-testdir or create-megatestdir
740 # - destdir from --dir
741 # - local_gnulib_dir from --local-dir
742 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
743 # - libname, supplied_libname from --lib
744 # - sourcebase from --source-base
745 # - m4base from --m4-base
746 # - pobase from --po-base
747 # - docbase from --doc-base
748 # - testsbase from --tests-base
749 # - auxdir from --aux-dir
750 # - inctests true if --with-tests was given, blank otherwise
751 # - avoidlist list of modules to avoid, from --avoid
752 # - lgpl yes or a number if --lgpl was given, blank otherwise
753 # - makefile_name from --makefile-name
754 # - libtool true if --libtool was given, false if --no-libtool was
755 # given, blank otherwise
756 # - macro_prefix from --macro-prefix
757 # - po_domain from --po-domain
758 # - vc_files true if --vc-files was given, false if --no-vc-files was
759 # given, blank otherwise
760 # - autoconf_minversion minimum supported autoconf version
761 # - do_changelog false if --no-changelog was given, : otherwise
762 # - doit : if actions shall be executed, false if only to be printed
763 # - symbolic true if --symlink or --more-symlinks was given, blank
765 # - lsymbolic true if --local-symlink was given, blank otherwise
766 # - do_copyrights blank if --more-symlinks was given, true otherwise
796 while test $# -gt 0; do
801 --import | --impor | --impo | --imp | --im | --i )
804 --update | --updat | --upda | --upd | --up | --u )
807 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
810 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
811 mode=create-megatestdir
813 --test | --tes | --te | --t )
816 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
820 mode=`echo "X$1" | sed -e 's/^X--//'`
825 func_fatal_error "missing argument for --dir"
830 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
835 func_fatal_error "missing argument for --local-dir"
840 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
842 --verbose | --verbos | --verbo | --verb )
843 verbose=`expr $verbose + 1`
845 --quiet | --quie | --qui | --qu | --q )
846 verbose=`expr $verbose - 1`
851 func_fatal_error "missing argument for --lib"
854 supplied_libname=true
857 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
858 supplied_libname=true
863 func_fatal_error "missing argument for --source-base"
868 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
873 func_fatal_error "missing argument for --m4-base"
878 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
883 func_fatal_error "missing argument for --po-base"
888 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
893 func_fatal_error "missing argument for --doc-base"
898 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
903 func_fatal_error "missing argument for --tests-base"
908 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
913 func_fatal_error "missing argument for --aux-dir"
918 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
926 func_fatal_error "missing argument for --avoid"
928 func_append avoidlist " $1"
931 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
932 func_append avoidlist " $arg"
938 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
941 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
948 func_fatal_error "missing argument for --makefile-name"
953 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
964 func_fatal_error "missing argument for --macro-prefix"
969 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
974 func_fatal_error "missing argument for --po-domain"
979 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
987 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
993 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
996 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
999 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
1003 --help | --hel | --he | --h )
1006 --version | --versio | --versi | --vers )
1010 # Stop option processing
1014 echo "gnulib-tool: unknown option $1" 1>&2
1015 echo "Try 'gnulib-tool --help' for more information." 1>&2
1022 if test "$mode" = update; then
1023 if test $# != 0; then
1024 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
1025 echo "Try 'gnulib-tool --help' for more information." 1>&2
1026 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1027 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1030 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
1031 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
1032 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
1033 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
1034 || test -n "$makefile_name" || test -n "$macro_prefix" \
1035 || test -n "$po_domain" || test -n "$vc_files"; then
1036 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
1037 echo "Try 'gnulib-tool --help' for more information." 1>&2
1038 echo "If you really want to modify the gnulib configuration of your project," 1>&2
1039 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
1044 if test -n "$pobase" && test -z "$po_domain"; then
1045 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
1046 echo "Try 'gnulib-tool --help' for more information." 1>&2
1049 if test -z "$pobase" && test -n "$po_domain"; then
1050 echo "gnulib-tool: warning: --po-domain has no effect without a --po-base option" 1>&2
1053 # Determine the minimum supported autoconf version from the project's
1055 DEFAULT_AUTOCONF_MINVERSION="2.59"
1056 autoconf_minversion=
1058 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1059 if test -f "$destdir"/configure.ac; then
1060 configure_ac="$destdir/configure.ac"
1062 if test -f "$destdir"/configure.in; then
1063 configure_ac="$destdir/configure.in"
1067 if test -f configure.ac; then
1068 configure_ac="configure.ac"
1070 if test -f configure.in; then
1071 configure_ac="configure.in"
1075 if test -n "$configure_ac"; then
1076 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1077 # because when some m4 files are omitted from a CVS repository,
1078 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1079 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1080 # autom4te: m4 failed with exit status: 1
1087 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1089 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1090 if test -n "$prereqs"; then
1091 autoconf_minversion=`
1092 for version in $prereqs; do echo $version; done |
1093 LC_ALL=C sort -nru | sed 1q
1097 if test -z "$autoconf_minversion"; then
1098 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1100 case "$autoconf_minversion" in
1101 1.* | 2.[0-4]* | 2.5[0-8]*)
1102 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1105 # Remove trailing slashes from the directory names. This is necessary for
1106 # m4base (to avoid an error in func_import) and optional for the others.
1107 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1108 case "$local_gnulib_dir" in
1109 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1111 case "$sourcebase" in
1112 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1115 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1118 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1121 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1123 case "$testsbase" in
1124 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1127 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1133 trap 'exit_status=$?
1134 if test "$signal" != 0; then
1135 echo "caught signal $signal" >&2
1138 exit $exit_status' 0
1139 for signal in 1 2 3 13 15; do
1140 trap '{ signal='$signal'; func_exit 1; }' $signal
1144 # func_lookup_file file
1145 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1148 # - local_gnulib_dir from --local-dir
1150 # - lookedup_file name of the merged (combined) file
1151 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1155 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1156 lookedup_file="$local_gnulib_dir/$lkfile"
1159 if test -f "$gnulib_dir/$lkfile"; then
1160 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1161 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1162 rm -f "$tmp/$lkbase"
1163 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1164 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1165 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1166 lookedup_file="$tmp/$lkbase"
1169 lookedup_file="$gnulib_dir/$lkfile"
1173 func_fatal_error "file $gnulib_dir/$lkfile not found"
1180 # - local_gnulib_dir from --local-dir
1183 # Filter out metainformation files like README, which are not modules.
1184 # Filter out unit test modules; they can be retrieved through
1185 # --extract-tests-module if desired.
1187 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1188 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1189 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1192 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1193 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1194 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1195 -e '/^README$/d' -e '/\/README$/d' \
1196 -e '/^TEMPLATE$/d' \
1197 -e '/^TEMPLATE-EXTENDED$/d' \
1198 -e '/^TEMPLATE-TESTS$/d' \
1201 | sed -e '/-tests$/d' \
1205 # func_verify_module
1206 # verifies a module name
1208 # - local_gnulib_dir from --local-dir
1209 # - module module name argument
1210 func_verify_module ()
1212 if { test -f "$gnulib_dir/modules/$module" \
1213 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1214 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1215 && test "CVS" != "$module" \
1216 && test "ChangeLog" != "$module" \
1217 && test "COPYING" != "$module" \
1218 && test "README" != "$module" \
1219 && test "TEMPLATE" != "$module" \
1220 && test "TEMPLATE-EXTENDED" != "$module" \
1221 && test "TEMPLATE-TESTS" != "$module"; then
1222 # OK, $module is a correct module name.
1223 # Verify that building the module description with 'patch' succeeds.
1224 func_lookup_file "modules/$module"
1226 echo "gnulib-tool: module $module doesn't exist" 1>&2
1231 # func_verify_nontests_module
1232 # verifies a module name, excluding tests modules
1234 # - local_gnulib_dir from --local-dir
1235 # - module module name argument
1236 func_verify_nontests_module ()
1239 *-tests ) module= ;;
1240 * ) func_verify_module ;;
1244 # func_verify_tests_module
1245 # verifies a module name, considering only tests modules
1247 # - local_gnulib_dir from --local-dir
1248 # - module module name argument
1249 func_verify_tests_module ()
1252 *-tests ) func_verify_module ;;
1257 sed_extract_prog=':[ ]*$/ {
1260 s/^Description:[ ]*$//
1264 s/^Depends-on:[ ]*$//
1265 s/^configure\.ac-early:[ ]*$//
1266 s/^configure\.ac:[ ]*$//
1267 s/^Makefile\.am:[ ]*$//
1271 s/^Maintainer:[ ]*$//
1278 # func_get_description module
1280 # - local_gnulib_dir from --local-dir
1281 func_get_description ()
1283 func_lookup_file "modules/$1"
1284 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1287 # func_get_status module
1289 # - local_gnulib_dir from --local-dir
1292 func_lookup_file "modules/$1"
1293 sed -n -e "/^Status$sed_extract_prog" < "$lookedup_file"
1296 # func_get_notice module
1298 # - local_gnulib_dir from --local-dir
1301 func_lookup_file "modules/$1"
1302 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1305 # func_get_filelist module
1307 # - local_gnulib_dir from --local-dir
1308 func_get_filelist ()
1310 func_lookup_file "modules/$1"
1311 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1312 echo m4/gnulib-common.m4
1313 case "$autoconf_minversion" in
1320 # func_get_dependencies module
1322 # - local_gnulib_dir from --local-dir
1323 func_get_dependencies ()
1325 # ${module}-tests always implicitly depends on ${module}.
1326 echo "$1" | sed -n -e 's/-tests$//p'
1327 # Then the explicit dependencies listed in the module description.
1328 func_lookup_file "modules/$1"
1329 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1332 # func_get_autoconf_early_snippet module
1334 # - local_gnulib_dir from --local-dir
1335 func_get_autoconf_early_snippet ()
1337 func_lookup_file "modules/$1"
1338 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1341 # func_get_autoconf_snippet module
1343 # - local_gnulib_dir from --local-dir
1344 func_get_autoconf_snippet ()
1346 func_lookup_file "modules/$1"
1347 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1350 # func_get_automake_snippet module
1352 # - local_gnulib_dir from --local-dir
1353 func_get_automake_snippet ()
1355 func_lookup_file "modules/$1"
1356 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1359 # *-tests module live in tests/, not lib/.
1360 # Synthesize an EXTRA_DIST augmentation.
1361 all_files=`func_get_filelist $1`
1362 tests_files=`for f in $all_files; do \
1364 tests/*) echo $f ;; \
1366 done | sed -e 's,^tests/,,'`
1367 extra_files="$tests_files"
1368 if test -n "$extra_files"; then
1369 echo "EXTRA_DIST +=" $extra_files
1374 # Synthesize an EXTRA_DIST augmentation.
1375 sed_combine_lines='/\\$/{
1382 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1383 already_mentioned_files=` \
1384 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1385 | sed -e "$sed_combine_lines" \
1386 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1387 all_files=`func_get_filelist $1`
1388 lib_files=`for f in $all_files; do \
1392 done | sed -e 's,^lib/,,'`
1393 # Remove $already_mentioned_files from $lib_files.
1394 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1395 extra_files=`func_reset_sigpipe; \
1396 for f in $already_mentioned_files; do echo $f; done \
1397 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1398 if test -n "$extra_files"; then
1399 echo "EXTRA_DIST +=" $extra_files
1402 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1403 # This is necessary so that automake can generate the right list of
1405 # A possible approach would be to use autom4te --trace of the redefined
1406 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1407 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1408 # inside autoconf's built-in macros are not missed).
1409 # But it's simpler and more robust to do it here, based on the file list.
1410 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1411 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1412 # automake will generate a useless dependency; this is harmless.
1414 relocatable-prog-wrapper) ;;
1416 sed_extract_c_files='/\.c$/p'
1417 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1418 if test -n "$extra_files"; then
1419 echo "EXTRA_lib_SOURCES +=" $extra_files
1424 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1425 buildaux_files=`for f in $all_files; do \
1427 build-aux/*) echo $f ;; \
1429 done | sed -e 's,^build-aux/,,'`
1430 if test -n "$buildaux_files"; then
1431 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1432 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1435 # Synthesize an EXTRA_DIST augmentation also for the files from top/.
1436 top_files=`for f in $all_files; do \
1440 done | sed -e 's,^top/,,'`
1441 if test -n "$top_files"; then
1442 sed_prepend_topdir='s,^,$(top_srcdir)/,'
1443 echo "EXTRA_DIST += "`echo "$top_files" | sed -e "$sed_prepend_topdir"`
1450 # func_get_include_directive module
1452 # - local_gnulib_dir from --local-dir
1453 func_get_include_directive ()
1455 func_lookup_file "modules/$1"
1456 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1457 sed -e 's/^\(["<]\)/#include \1/'
1460 # func_get_link_directive module
1462 # - local_gnulib_dir from --local-dir
1463 func_get_link_directive ()
1465 func_lookup_file "modules/$1"
1466 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1469 # func_get_license module
1471 # - local_gnulib_dir from --local-dir
1474 func_lookup_file "modules/$1"
1475 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1476 # The default is GPL.
1478 } | sed -e 's,^ *$,,' | sed -e 1q
1481 # func_get_maintainer module
1483 # - local_gnulib_dir from --local-dir
1484 func_get_maintainer ()
1486 func_lookup_file "modules/$1"
1487 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1490 # func_get_tests_module module
1492 # - local_gnulib_dir from --local-dir
1493 func_get_tests_module ()
1495 # The naming convention for tests modules is hardwired: ${module}-tests.
1496 if test -f "$gnulib_dir/modules/$1"-tests \
1497 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1498 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1503 # func_acceptable module
1504 # tests whether a module is acceptable.
1506 # - avoidlist list of modules to avoid
1509 for avoid in $avoidlist; do
1510 if test "$avoid" = "$1"; then
1517 # func_modules_transitive_closure
1519 # - local_gnulib_dir from --local-dir
1520 # - modules list of specified modules
1521 # - inctests true if tests should be included, blank otherwise
1522 # - avoidlist list of modules to avoid
1523 # - tmp pathname of a temporary directory
1525 # - modules list of modules, including dependencies
1526 func_modules_transitive_closure ()
1528 # In order to process every module only once (for speed), process an "input
1529 # list" of modules, producing an "output list" of modules. During each round,
1530 # more modules can be queued in the input list. Once a module on the input
1531 # list has been processed, it is added to the "handled list", so we can avoid
1532 # to process it again.
1534 inmodules="$modules"
1536 while test -n "$inmodules"; do
1537 inmodules_this_round="$inmodules"
1538 inmodules= # Accumulator, queue for next round
1539 for module in $inmodules_this_round; do
1541 if test -n "$module"; then
1542 if func_acceptable $module; then
1543 func_append outmodules " $module"
1544 deps=`func_get_dependencies $module`
1545 # Duplicate dependencies are harmless, but Jim wants a warning.
1546 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1547 if test -n "$duplicated_deps"; then
1548 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1550 func_append inmodules " $deps"
1551 if test -n "$inctests"; then
1552 testsmodule=`func_get_tests_module $module`
1553 if test -n "$testsmodule"; then
1554 func_append inmodules " $testsmodule"
1560 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1561 # Remove $handledmodules from $inmodules.
1562 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1563 inmodules=`func_reset_sigpipe; echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1565 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1566 rm -f "$tmp"/queued-modules
1569 # func_modules_add_dummy
1571 # - local_gnulib_dir from --local-dir
1572 # - modules list of modules, including dependencies
1574 # - modules list of modules, including 'dummy' if needed
1575 func_modules_add_dummy ()
1578 sed_remove_backslash_newline=':a
1585 for module in $modules; do
1586 func_verify_nontests_module
1587 if test -n "$module"; then
1588 # Extract the value of "lib_SOURCES += ...".
1589 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1590 # Ignore .h files since they are not compiled.
1593 *) have_lib_SOURCES=yes ;;
1598 # Add the dummy module, to make sure the library will be non-empty.
1599 if test -z "$have_lib_SOURCES"; then
1600 if func_acceptable "dummy"; then
1601 func_append modules " dummy"
1606 # func_modules_notice
1608 # - local_gnulib_dir from --local-dir
1609 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1610 # - modules list of modules, including dependencies
1611 func_modules_notice ()
1613 if test $verbose -ge -1; then
1614 for module in $modules; do
1616 if test -n "$module"; then
1617 msg=`func_get_notice $module`
1618 if test -n "$msg"; then
1619 echo "Notice from module $module:"
1620 echo "$msg" | sed -e 's/^/ /'
1627 # func_modules_to_filelist
1629 # - local_gnulib_dir from --local-dir
1630 # - modules list of modules, including dependencies
1632 # - files list of files
1633 func_modules_to_filelist ()
1636 for module in $modules; do
1638 if test -n "$module"; then
1639 fs=`func_get_filelist $module`
1640 func_append files " $fs"
1643 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1646 # func_execute_command command [args...]
1647 # Executes a command.
1648 # Uses also the variables
1649 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1650 func_execute_command ()
1652 if test $verbose -ge 0; then
1656 # Commands like automake produce output to stderr even when they succeed.
1657 # Turn this output off if the command succeeds.
1658 "$@" > "$tmp"/cmdout 2>&1
1660 if test $cmdret = 0; then
1664 cat "$tmp"/cmdout 1>&2
1671 # func_emit_lib_Makefile_am
1672 # emits the contents of library makefile to standard output.
1674 # - local_gnulib_dir from --local-dir
1675 # - modules list of modules, including dependencies
1676 # - libname library name
1677 # - pobase directory relative to destdir where to place *.po files
1678 # - auxdir directory relative to destdir where to place build aux files
1679 # - makefile_name from --makefile-name
1680 # - libtool true if libtool will be used, false or blank otherwise
1681 # - macro_prefix prefix of gl_LIBOBJS macros to use
1682 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1683 # - actioncmd (optional) command that will reproduce this invocation
1684 # - for_test true if creating a package for testing, false otherwise
1685 # - destfile filename relative to destdir of makefile being generated
1687 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
1688 # list of edits to be done to Makefile.am variables
1690 # - uses_subdirs nonempty if object files in subdirs exist
1691 func_emit_lib_Makefile_am ()
1693 # When creating an includable Makefile.am snippet, augment variables with
1694 # += instead of assigning them.
1695 if test -n "$makefile_name"; then
1700 if test "$libtool" = true; then
1703 sed_eliminate_LDFLAGS="$sed_noop"
1707 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1710 # When creating a package for testing: Attempt to provoke failures,
1711 # especially link errors, already during "make" rather than during
1712 # "make check", because "make check" is not possible in a cross-compiling
1713 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1714 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1716 sed_transform_check_PROGRAMS="$sed_noop"
1718 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1719 echo "## Process this file with automake to produce Makefile.in."
1720 func_emit_copyright_notice
1721 if test -n "$actioncmd"; then
1722 echo "# Reproduce by: $actioncmd"
1727 for module in $modules; do
1728 func_verify_nontests_module
1729 if test -n "$module"; then
1731 func_get_automake_snippet "$module" |
1732 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1733 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1734 -e "$sed_eliminate_LDFLAGS" \
1735 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1736 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1737 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1738 -e "$sed_transform_check_PROGRAMS"
1739 if test "$module" = 'alloca'; then
1740 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1741 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1744 # Skip the contents if it's entirely empty.
1745 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1746 echo "## begin gnulib module $module"
1749 echo "## end gnulib module $module"
1753 # Test whether there are some source files in subdirectories.
1754 for f in `func_get_filelist "$module"`; do
1756 lib/*/*.c) uses_subdirs=yes ;;
1762 if test -z "$makefile_name"; then
1763 # If there are source files in subdirectories, prevent collision of the
1764 # object files (example: hash.c and libxml/hash.c).
1766 if test -n "$uses_subdirs"; then
1767 subdir_options=' subdir-objects'
1769 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1772 if test -z "$makefile_name"; then
1774 echo "noinst_HEADERS ="
1775 echo "noinst_LIBRARIES ="
1776 echo "noinst_LTLIBRARIES ="
1777 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1778 # if you specify pkgdata_DATA to empty. This is a workaround.
1779 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1780 echo "pkgdata_DATA ="
1783 echo "BUILT_SOURCES ="
1786 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1787 if test -z "$makefile_name"; then
1788 echo "MOSTLYCLEANDIRS ="
1790 echo "DISTCLEANFILES ="
1791 echo "MAINTAINERCLEANFILES ="
1793 # Execute edits that apply to the Makefile.am being generated.
1795 while test $edit != $makefile_am_edits; do
1796 edit=`expr $edit + 1`
1797 eval dir=\"\$makefile_am_edit${edit}_dir\"
1798 eval var=\"\$makefile_am_edit${edit}_var\"
1799 eval val=\"\$makefile_am_edit${edit}_val\"
1800 if test -n "$var"; then
1801 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
1802 echo "${var} += ${val}"
1803 eval "makefile_am_edit${edit}_var="
1807 if test -z "$makefile_name"; then
1809 echo "AM_CPPFLAGS ="
1812 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *+\{0,1\}= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1813 # One of the snippets already specifies an installation location for the
1814 # library. Don't confuse automake by saying it should not be installed.
1817 # By default, the generated library should not be installed.
1818 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1821 echo "${libname}_${libext}_SOURCES ="
1822 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1823 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
1824 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1825 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1826 echo "EXTRA_${libname}_${libext}_SOURCES ="
1827 if test "$libtool" = true; then
1828 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1831 if test -n "$pobase"; then
1832 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
1835 cat allsnippets.tmp \
1836 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1838 echo "mostlyclean-local: mostlyclean-generic"
1839 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1840 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1841 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1845 rm -f allsnippets.tmp
1848 # func_emit_po_Makevars
1849 # emits the contents of po/ makefile parameterization to standard output.
1851 # - local_gnulib_dir from --local-dir
1852 # - sourcebase directory relative to destdir where to place source code
1853 # - pobase directory relative to destdir where to place *.po files
1854 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1855 func_emit_po_Makevars ()
1857 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1858 func_emit_copyright_notice
1860 echo "# Usually the message domain is the same as the package name."
1861 echo "# But here it has a '-gnulib' suffix."
1862 echo "DOMAIN = ${po_domain}-gnulib"
1864 echo "# These two variables depend on the location of this directory."
1865 echo "subdir = ${pobase}"
1866 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
1869 # These options get passed to xgettext.
1870 XGETTEXT_OPTIONS = \
1871 --keyword=_ --flag=_:1:pass-c-format \
1872 --keyword=N_ --flag=N_:1:pass-c-format \
1873 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
1874 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
1875 --flag=error:3:c-format --flag=error_at_line:5:c-format
1877 # This is the copyright holder that gets inserted into the header of the
1878 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
1879 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
1881 # This is the email address or URL to which the translators shall report
1882 # bugs in the untranslated strings:
1883 # - Strings which are not entire sentences, see the maintainer guidelines
1884 # in the GNU gettext documentation, section 'Preparing Strings'.
1885 # - Strings which use unclear terms or require additional context to be
1887 # - Strings which make invalid assumptions about notation of date, time or
1889 # - Pluralisation problems.
1890 # - Incorrect English spelling.
1891 # - Incorrect formatting.
1892 # It can be your email address, or a mailing list address where translators
1893 # can write to without being subscribed, or the URL of a web page through
1894 # which the translators can contact you.
1895 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
1897 # This is the list of locale categories, beyond LC_MESSAGES, for which the
1898 # message catalogs shall be used. It is usually empty.
1899 EXTRA_LOCALE_CATEGORIES =
1901 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
1902 # context. Possible values are "yes" and "no". Set this to yes if the
1903 # package uses functions taking also a message context, like pgettext(), or
1904 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
1909 # func_emit_po_POTFILES_in
1910 # emits the file list to be passed to xgettext to standard output.
1912 # - local_gnulib_dir from --local-dir
1913 # - sourcebase directory relative to destdir where to place source code
1914 # - files list of new files
1915 func_emit_po_POTFILES_in ()
1917 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1918 func_emit_copyright_notice
1920 echo "# List of files which contain translatable strings."
1921 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
1924 # func_emit_tests_Makefile_am
1925 # emits the contents of tests makefile to standard output.
1927 # - local_gnulib_dir from --local-dir
1928 # - modules list of modules, including dependencies
1929 # - libname library name
1930 # - auxdir directory relative to destdir where to place build aux files
1931 # - makefile_name from --makefile-name
1932 # - libtool true if libtool will be used, false or blank otherwise
1933 # - sourcebase relative directory containing lib source code
1934 # - m4base relative directory containing autoconf macros
1935 # - testsbase relative directory containing unit test code
1936 # - macro_prefix prefix of gl_LIBOBJS macros to use
1937 # - for_test true if creating a package for testing, false otherwise
1938 # - use_libtests true if a libtests.a should be built, false otherwise
1939 # - destfile filename relative to destdir of makefile being generated
1941 # - makefile_am_edits and makefile_am_edit${edit}_{dir,var,val}
1942 # list of edits to be done to Makefile.am variables
1944 # - uses_subdirs nonempty if object files in subdirs exist
1945 func_emit_tests_Makefile_am ()
1947 if test "$libtool" = true; then
1949 sed_eliminate_LDFLAGS="$sed_noop"
1952 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1955 # When creating a package for testing: Attempt to provoke failures,
1956 # especially link errors, already during "make" rather than during
1957 # "make check", because "make check" is not possible in a cross-compiling
1958 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1959 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1961 sed_transform_check_PROGRAMS="$sed_noop"
1963 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1964 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1965 echo "## Process this file with automake to produce Makefile.in."
1966 func_emit_copyright_notice
1970 for module in $modules; do
1972 func_verify_tests_module
1976 if test -n "$module"; then
1978 func_get_automake_snippet "$module" |
1979 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1980 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1981 -e "$sed_eliminate_LDFLAGS" \
1982 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
1983 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1984 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1985 -e "$sed_transform_check_PROGRAMS"
1986 if $use_libtests && test "$module" = 'alloca'; then
1987 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
1988 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1991 # Skip the contents if it's entirely empty.
1992 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1993 echo "## begin gnulib module $module"
1996 echo "## end gnulib module $module"
2000 # Test whether there are some source files in subdirectories.
2001 for f in `func_get_filelist "$module"`; do
2003 lib/*/*.c | tests/*/*.c) uses_subdirs=yes ;;
2009 # Generate dependencies here, since it eases the debugging of test failures.
2010 # If there are source files in subdirectories, prevent collision of the
2011 # object files (example: hash.c and libxml/hash.c).
2013 if test -n "$uses_subdirs"; then
2014 subdir_options=' subdir-objects'
2016 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
2019 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
2022 # Nothing is being added to SUBDIRS; nevertheless the existence of this
2023 # variable is needed to avoid an error from automake:
2024 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
2027 echo "TESTS_ENVIRONMENT ="
2028 echo "noinst_PROGRAMS ="
2029 if ! $for_test; then
2030 echo "check_PROGRAMS ="
2032 echo "noinst_HEADERS ="
2033 echo "noinst_LIBRARIES ="
2034 if $use_libtests; then
2036 echo "noinst_LIBRARIES += libtests.a"
2038 echo "check_LIBRARIES = libtests.a"
2041 # Automake versions < 1.9b create an empty pkgdatadir at installation time
2042 # if you specify pkgdata_DATA to empty. This is a workaround.
2043 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
2044 echo "pkgdata_DATA ="
2047 echo "BUILT_SOURCES ="
2049 echo "MOSTLYCLEANFILES = core *.stackdump"
2050 echo "MOSTLYCLEANDIRS ="
2052 echo "DISTCLEANFILES ="
2053 echo "MAINTAINERCLEANFILES ="
2054 # Execute edits that apply to the Makefile.am being generated.
2056 while test $edit != $makefile_am_edits; do
2057 edit=`expr $edit + 1`
2058 eval dir=\"\$makefile_am_edit${edit}_dir\"
2059 eval var=\"\$makefile_am_edit${edit}_var\"
2060 eval val=\"\$makefile_am_edit${edit}_val\"
2061 if test -n "$var"; then
2062 if test "${dir}Makefile.am" = "$destfile" || test "./${dir}Makefile.am" = "$destfile"; then
2063 echo "${var} += ${val}"
2064 eval "makefile_am_edit${edit}_var="
2069 echo "AM_CPPFLAGS = \\"
2070 echo " -I. -I\$(srcdir) \\"
2071 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
2072 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
2074 local_ldadd_before=''
2075 local_ldadd_after=''
2076 if $use_libtests; then
2077 # All test programs need to be linked with libtests.a.
2078 # It needs to be passed to the linker before ${libname}.${libext}, since
2079 # the tests-related modules depend on the main modules.
2080 # It also needs to be passed to the linker after ${libname}.${libext}
2081 # because the latter might contain incomplete modules (such as the 'error'
2082 # module whose dependency to 'progname' is voluntarily omitted).
2083 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
2085 local_ldadd_before=' libtests.a'
2086 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
2088 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
2090 if $use_libtests; then
2091 echo "libtests_a_SOURCES ="
2092 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
2093 # automake during its analysis looks for $(LIBOBJS), not for @LIBOBJS@.
2094 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
2095 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
2096 echo "EXTRA_libtests_a_SOURCES ="
2097 # The circular dependency in LDADD requires this.
2098 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
2101 cat allsnippets.tmp \
2102 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
2103 echo "# Clean up after Solaris cc."
2105 echo " rm -rf SunWS_cache"
2107 echo "mostlyclean-local: mostlyclean-generic"
2108 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
2109 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
2110 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2114 rm -f allsnippets.tmp
2117 # func_emit_initmacro_start macro_prefix
2118 # emits the first few statements of the gl_INIT macro to standard output.
2119 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2120 func_emit_initmacro_start ()
2122 macro_prefix_arg="$1"
2123 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
2124 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
2125 # LIBOBJS. The purpose is to allow several gnulib instantiations under
2126 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
2128 # Furthermore it avoids an automake error like this when a Makefile.am
2129 # that uses pieces of gnulib also uses $(LIBOBJ):
2130 # automatically discovered file `error.c' should not be explicitly mentioned
2131 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
2132 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
2133 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
2134 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
2135 # automatically discovered file `error.c' should not be explicitly mentioned
2136 # We let automake know about the files to be distributed through the
2137 # EXTRA_lib_SOURCES variable.
2138 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
2139 # Create data variables for checking the presence of files that are mentioned
2140 # as AC_LIBSOURCES arguments. These are m4 variables, not shell variables,
2141 # because we want the check to happen when the configure file is created,
2142 # not when it is run. ${macro_prefix_arg}_LIBSOURCES_LIST is the list of
2143 # files to check for. ${macro_prefix_arg}_LIBSOURCES_DIR is the subdirectory
2144 # in which to expect them.
2145 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_LIST], [])"
2146 echo " m4_pushdef([${macro_prefix_arg}_LIBSOURCES_DIR], [])"
2150 # func_emit_initmacro_end macro_prefix
2151 # emits the last few statements of the gl_INIT macro to standard output.
2152 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2153 func_emit_initmacro_end ()
2155 macro_prefix_arg="$1"
2156 # Check the presence of files that are mentioned as AC_LIBSOURCES arguments.
2157 # The check is performed only when autoconf is run from the directory where
2158 # the configure.ac resides; if it is run from a different directory, the
2160 echo " m4_ifval(${macro_prefix_arg}_LIBSOURCES_LIST, ["
2161 echo " m4_syscmd([test ! -d ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[ ||"
2162 echo " for gl_file in ]${macro_prefix_arg}_LIBSOURCES_LIST[ ; do"
2163 echo " if test ! -r ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file ; then"
2164 echo " echo \"missing file ]m4_defn([${macro_prefix_arg}_LIBSOURCES_DIR])[/\$gl_file\" >&2"
2168 echo " m4_if(m4_sysval, [0], [],"
2169 echo " [AC_FATAL([expected source file, required through AC_LIBSOURCES, not found])])"
2171 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_DIR])"
2172 echo " m4_popdef([${macro_prefix_arg}_LIBSOURCES_LIST])"
2173 echo " m4_popdef([AC_LIBSOURCES])"
2174 echo " m4_popdef([AC_REPLACE_FUNCS])"
2175 echo " m4_popdef([AC_LIBOBJ])"
2176 echo " AC_CONFIG_COMMANDS_PRE(["
2177 echo " ${macro_prefix_arg}_libobjs="
2178 echo " ${macro_prefix_arg}_ltlibobjs="
2179 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
2180 echo " # Remove the extension."
2181 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
2182 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
2183 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
2184 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
2187 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
2188 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
2192 # func_emit_initmacro_done macro_prefix sourcebase
2193 # emits a few statements after the gl_INIT macro to standard output.
2194 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2195 # - sourcebase directory relative to destdir where to place source code
2196 func_emit_initmacro_done ()
2198 macro_prefix_arg="$1"
2201 echo "# Like AC_LIBOBJ, except that the module name goes"
2202 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2203 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
2204 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
2205 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
2208 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
2209 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2210 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
2211 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
2212 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
2215 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
2216 echo "# expected is derived from the gnulib-tool parameterization,"
2217 echo "# and alloca is special cased (for the alloca-opt module)."
2218 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
2219 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
2220 echo " m4_foreach([_gl_NAME], [\$1], ["
2221 echo " m4_if(_gl_NAME, [alloca.c], [], ["
2222 echo " m4_define([${macro_prefix_arg}_LIBSOURCES_DIR], [$sourcebase_arg])"
2223 echo " m4_append([${macro_prefix_arg}_LIBSOURCES_LIST], _gl_NAME, [ ])"
2229 # func_import modules
2230 # Uses also the variables
2231 # - destdir target directory
2232 # - local_gnulib_dir from --local-dir
2233 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2234 # - libname library name
2235 # - sourcebase directory relative to destdir where to place source code
2236 # - m4base directory relative to destdir where to place *.m4 macros
2237 # - pobase directory relative to destdir where to place *.po files
2238 # - docbase directory relative to destdir where to place doc files
2239 # - testsbase directory relative to destdir where to place unit test code
2240 # - auxdir directory relative to destdir where to place build aux files
2241 # - inctests true if --with-tests was given, blank otherwise
2242 # - avoidlist list of modules to avoid, from --avoid
2243 # - lgpl yes or a number if library's license shall be LGPL,
2245 # - makefile_name from --makefile-name
2246 # - libtool true if --libtool was given, false if --no-libtool was
2247 # given, blank otherwise
2248 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
2249 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2250 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2251 # - vc_files true if --vc-files was given, false if --no-vc-files was
2252 # given, blank otherwise
2253 # - autoconf_minversion minimum supported autoconf version
2254 # - doit : if actions shall be executed, false if only to be printed
2255 # - symbolic true if files should be symlinked, copied otherwise
2256 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2258 # - do_copyrights true if copyright notices in files should be replaced,
2262 # Get the cached settings.
2263 cached_local_gnulib_dir=
2264 cached_specified_modules=
2274 cached_makefile_name=
2276 cached_macro_prefix=
2280 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2281 cached_libtool=false
2287 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
2297 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
2300 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
2303 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
2306 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
2309 s,^.*gl_PO_BASE([[ ]*\([^])]*\).*$,cached_pobase="\1",p
2312 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
2315 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
2318 s,^.*$,cached_inctests=true,p
2321 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
2324 s,^.*gl_LGPL([[ ]*\([^])]*\).*$,cached_lgpl="\1",p
2327 s,^.*$,cached_lgpl=yes,p
2329 /gl_MAKEFILE_NAME(/ {
2330 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
2333 s,^.*$,cached_libtool=true,p
2335 /gl_MACRO_PREFIX(/ {
2336 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
2339 s,^.*gl_PO_DOMAIN([[ ]*\([^])]*\).*$,cached_po_domain="\1",p
2342 s,^.*gl_VC_FILES([[ ]*\([^])]*\).*$,cached_vc_files="\1",p
2344 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2345 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2350 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2351 s,^.*$,cached_files=",p
2363 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2367 # Merge the cached settings with the specified ones.
2368 # The m4base must be the same as expected from the pathname.
2369 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2370 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2372 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2373 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2374 if test -z "$local_gnulib_dir"; then
2375 if test -n "$cached_local_gnulib_dir"; then
2378 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2380 case "$cached_local_gnulib_dir" in
2382 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2384 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2385 local_gnulib_dir="$relconcat" ;;
2390 # Append the cached and the specified module names. So that
2391 # "gnulib-tool --import foo" means to add the module foo.
2392 specified_modules="$cached_specified_modules $1"
2393 # Append the cached and the specified avoidlist. This is probably better
2394 # than dropping the cached one when --avoid is specified at least once.
2395 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2396 avoidlist=`echo $avoidlist`
2398 # The sourcebase defaults to the cached one.
2399 if test -z "$sourcebase"; then
2400 sourcebase="$cached_sourcebase"
2401 if test -z "$sourcebase"; then
2402 func_fatal_error "missing --source-base option"
2405 # The pobase defaults to the cached one.
2406 if test -z "$pobase"; then
2407 pobase="$cached_pobase"
2409 # The docbase defaults to the cached one.
2410 if test -z "$docbase"; then
2411 docbase="$cached_docbase"
2412 if test -z "$docbase"; then
2413 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."
2416 # The testsbase defaults to the cached one.
2417 if test -z "$testsbase"; then
2418 testsbase="$cached_testsbase"
2419 if test -z "$testsbase"; then
2420 func_fatal_error "missing --tests-base option"
2423 # Require the tests if specified either way.
2424 if test -z "$inctests"; then
2425 inctests="$cached_inctests"
2427 # The libname defaults to the cached one.
2428 if test -z "$supplied_libname"; then
2429 libname="$cached_libname"
2430 if test -z "$libname"; then
2431 func_fatal_error "missing --lib option"
2434 # Require LGPL if specified either way.
2435 if test -z "$lgpl"; then
2438 # The makefile_name defaults to the cached one.
2439 if test -z "$makefile_name"; then
2440 makefile_name="$cached_makefile_name"
2442 # Use libtool if specified either way, or if guessed.
2443 if test -z "$libtool"; then
2444 if test -n "$cached_m4base"; then
2445 libtool="$cached_libtool"
2447 libtool="$guessed_libtool"
2450 # The macro_prefix defaults to the cached one.
2451 if test -z "$macro_prefix"; then
2452 macro_prefix="$cached_macro_prefix"
2453 if test -z "$macro_prefix"; then
2454 func_fatal_error "missing --macro-prefix option"
2457 # The po_domain defaults to the cached one.
2458 if test -z "$po_domain"; then
2459 po_domain="$cached_po_domain"
2461 # The vc_files defaults to the cached one.
2462 if test -z "$vc_files"; then
2463 vc_files="$cached_vc_files"
2466 # Canonicalize the list of specified modules.
2467 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2469 # Determine final module list.
2470 modules="$specified_modules"
2471 func_modules_transitive_closure
2472 if test $verbose -ge 0; then
2473 echo "Module list with included dependencies:"
2474 echo "$modules" | sed -e 's/^/ /'
2476 final_modules="$modules"
2478 # Determine main module list and tests-related module list separately.
2479 # The main module list is the transitive closure of the specified modules,
2480 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2481 # is specified, it will consist only of LGPLed source.
2482 # The tests-related module list is the transitive closure of the specified
2483 # modules, including tests modules, minus the main module list. Its lib/*
2484 # sources (brought in through dependencies of *-tests modules) go into
2485 # $testsbase/. It may contain GPLed source, even if --lgpl is specified.
2486 # Determine main module list.
2487 saved_inctests="$inctests"
2489 modules="$specified_modules"
2490 func_modules_transitive_closure
2491 main_modules="$modules"
2492 inctests="$saved_inctests"
2493 if test $verbose -ge 1; then
2494 echo "Main module list:"
2495 echo "$main_modules" | sed -e 's/^/ /'
2497 # Determine tests-related module list.
2498 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2499 testsrelated_modules=`func_reset_sigpipe; echo "$main_modules" | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2500 if test $verbose -ge 1; then
2501 echo "Tests-related module list:"
2502 echo "$testsrelated_modules" | sed -e 's/^/ /'
2505 # Add the dummy module to the main module list if needed.
2506 modules="$main_modules"
2507 func_modules_add_dummy
2508 main_modules="$modules"
2510 # Determine whether a $testsbase/libtests.a is needed.
2512 for module in $testsrelated_modules; do
2513 func_verify_nontests_module
2514 if test -n "$module"; then
2515 all_files=`func_get_filelist $module`
2516 lib_files=`for f in $all_files; do \
2520 done | sed -e 's,^lib/,,'`
2521 if test -n "$lib_files"; then
2528 # Add the dummy module to the tests-related module list if needed.
2529 if $use_libtests; then
2530 modules="$testsrelated_modules"
2531 func_modules_add_dummy
2532 testsrelated_modules="$modules"
2535 # If --lgpl, verify that the licenses of modules are compatible.
2536 if test -n "$lgpl"; then
2537 license_incompatibilities=
2538 for module in $main_modules; do
2539 license=`func_get_license $module`
2541 'GPLed build tool') ;;
2542 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2548 *) func_append license_incompatibilities "$module $license$nl" ;;
2554 *) func_append license_incompatibilities "$module $license$nl" ;;
2557 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2562 if test -n "$license_incompatibilities"; then
2563 # Format the license incompatibilities as a table.
2564 sed_expand_column1_width50_indent17='s,^\([^ ]*\) ,\1 ,
2565 s,^\(.................................................[^ ]*\) *, \1 ,'
2566 license_incompatibilities=`echo "$license_incompatibilities" | sed -e "$sed_expand_column1_width50_indent17"`
2567 func_fatal_error "incompatible license on modules:$nl$license_incompatibilities"
2571 # Show banner notice of every module.
2572 modules="$main_modules"
2575 # Determine script to apply to imported library files.
2576 sed_transform_lib_file=
2577 for module in $main_modules; do
2578 if test $module = config-h; then
2579 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2580 sed_transform_lib_file=$sed_transform_lib_file'
2581 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2586 sed_transform_main_lib_file="$sed_transform_lib_file"
2587 if test -n "$do_copyrights"; then
2588 if test -n "$lgpl"; then
2592 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2593 s/GNU General/GNU Lesser General/g
2597 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2598 s/GNU General/GNU Lesser General/g
2599 s/version [23]\([ ,]\)/version 2.1\1/g
2602 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2606 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2607 s/GNU Lesser General/GNU General/g
2608 s/GNU Library General/GNU General/g
2609 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2614 # Determine script to apply to library files that go into $testsbase/.
2615 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
2616 if test -n "$do_copyrights"; then
2618 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
2619 s/GNU Lesser General/GNU General/g
2620 s/GNU Library General/GNU General/g
2621 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2625 # Determine the final file lists.
2626 # They must be computed separately, because files in lib/* go into
2627 # $sourcebase/ if they are in the main file list but into $testsbase/
2628 # if they are in the tests-related file list. Furthermore lib/dummy.c
2630 # Determine final main file list.
2631 modules="$main_modules"
2632 func_modules_to_filelist
2634 # Determine final tests-related file list.
2635 modules="$testsrelated_modules"
2636 func_modules_to_filelist
2637 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
2638 # Merge both file lists.
2639 sed_remove_empty_lines='/^$/d'
2640 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
2641 if test $verbose -ge 0; then
2643 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
2644 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
2648 || func_fatal_error "refusing to do nothing"
2650 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2651 new_files="$files m4/gnulib-tool.m4"
2652 old_files="$cached_files"
2653 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2654 func_append old_files " m4/gnulib-tool.m4"
2657 sed_rewrite_old_files="\
2658 s,^build-aux/,$auxdir/,
2659 s,^doc/,$cached_docbase/,
2660 s,^lib/,$cached_sourcebase/,
2661 s,^m4/,$cached_m4base/,
2662 s,^tests/,$cached_testsbase/,
2663 s,^tests=lib/,$cached_testsbase/,
2665 sed_rewrite_new_files="\
2666 s,^build-aux/,$auxdir/,
2668 s,^lib/,$sourcebase/,
2670 s,^tests/,$testsbase/,
2671 s,^tests=lib/,$testsbase/,
2674 # Create directories.
2675 { echo "$sourcebase"
2677 if test -n "$pobase"; then
2680 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2681 if test -n "$docfiles"; then
2684 if test -n "$inctests"; then
2688 for f in $files; do echo $f; done \
2689 | sed -e "$sed_rewrite_new_files" \
2690 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2693 { # Rearrange file descriptors. Needed because "while ... done < ..."
2694 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2695 exec 5<&0 < "$tmp"/dirs
2697 if test ! -d "$destdir/$d"; then
2699 echo "Creating directory $destdir/$d"
2700 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2702 echo "Create directory $destdir/$d"
2709 # func_dest_tmpfilename file
2710 # determines the name of a temporary file (file is relative to destdir).
2712 # - tmpfile absolute filename of the temporary file
2713 func_dest_tmpfilename ()
2716 # Put the new contents of $file in a file in the same directory (needed
2717 # to guarantee that an 'mv' to "$destdir/$file" works).
2718 tmpfile="$destdir/$1.tmp"
2720 # Put the new contents of $file in a file in a temporary directory
2721 # (because the directory of "$file" might not exist).
2722 tmpfile="$tmp"/`basename "$1"`.tmp
2726 # Copy files or make symbolic links. Remove obsolete files.
2730 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2731 # representing the files according to the last gnulib-tool invocation.
2732 for f in $old_files; do echo $f; done \
2733 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2736 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2737 # representing the files after this gnulib-tool invocation.
2738 for f in $new_files; do echo $f; done \
2739 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2742 # First the files that are in old-files, but not in new-files:
2743 sed_take_first_column='s,'"$delimiter"'.*,,'
2744 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2745 # Remove the file. Do nothing if the user already removed it.
2746 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
2748 echo "Removing file $g (backup in ${g}~)"
2749 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2751 echo "Remove file $g (backup in ${g}~)"
2753 func_append removed_files "$g$nl"
2756 # func_add_or_update handles a file that ought to be present afterwards.
2758 # - f the original file name
2759 # - g the rewritten file name
2760 # - already_present nonempty if the file already exists, empty otherwise
2761 func_add_or_update ()
2765 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
2767 func_dest_tmpfilename "$g"
2768 func_lookup_file "$f"
2769 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2770 if test -n "$sed_transform_main_lib_file"; then
2773 sed -e "$sed_transform_main_lib_file" \
2774 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2778 if test -n "$sed_transform_testsrelated_lib_file"; then
2781 sed -e "$sed_transform_testsrelated_lib_file" \
2782 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2786 if test -f "$destdir/$g"; then
2787 # The file already exists.
2788 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2789 : # The file has not changed.
2793 if test -n "$already_present"; then
2794 echo "Updating file $g (backup in ${g}~)"
2796 echo "Replacing file $g (non-gnulib code backed up in ${g}~) !!"
2798 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2799 if { test -n "$symbolic" \
2800 || { test -n "$lsymbolic" \
2801 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2802 && test -z "$lookedup_tmp" \
2803 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2804 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2806 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2809 if test -n "$already_present"; then
2810 echo "Update file $g (backup in ${g}~)"
2812 echo "Replace file $g (non-gnulib code backed up in ${g}~) !!"
2818 # Don't protest if the file should be there but isn't: it happens
2819 # frequently that developers don't put autogenerated files into CVS.
2821 echo "Copying file $g"
2822 if { test -n "$symbolic" \
2823 || { test -n "$lsymbolic" \
2824 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2825 && test -z "$lookedup_tmp" \
2826 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2827 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2829 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2834 func_append added_files "$g$nl"
2838 # Then the files that are in new-files, but not in old-files:
2839 sed_take_last_column='s,^.*'"$delimiter"',,'
2841 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2842 | sed -e "$sed_take_last_column" \
2843 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2844 { # Rearrange file descriptors. Needed because "while ... done < ..."
2845 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2846 exec 5<&0 < "$tmp"/added-files
2852 # Then the files that are in new-files and in old-files:
2853 already_present=true
2854 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2855 | sed -e "$sed_take_last_column" \
2856 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2857 { # Rearrange file descriptors. Needed because "while ... done < ..."
2858 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2859 exec 5<&0 < "$tmp"/kept-files
2866 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2867 actioncmd="gnulib-tool --import"
2868 func_append actioncmd " --dir=$destdir"
2869 if test -n "$local_gnulib_dir"; then
2870 func_append actioncmd " --local-dir=$local_gnulib_dir"
2872 func_append actioncmd " --lib=$libname"
2873 func_append actioncmd " --source-base=$sourcebase"
2874 func_append actioncmd " --m4-base=$m4base"
2875 if test -n "$pobase"; then
2876 func_append actioncmd " --po-base=$pobase"
2878 func_append actioncmd " --doc-base=$docbase"
2879 func_append actioncmd " --tests-base=$testsbase"
2880 func_append actioncmd " --aux-dir=$auxdir"
2881 if test -n "$inctests"; then
2882 func_append actioncmd " --with-tests"
2884 for module in $avoidlist; do
2885 func_append actioncmd " --avoid=$module"
2887 if test -n "$lgpl"; then
2888 if test "$lgpl" = yes; then
2889 func_append actioncmd " --lgpl"
2891 func_append actioncmd " --lgpl=$lgpl"
2894 if test -n "$makefile_name"; then
2895 func_append actioncmd " --makefile-name=$makefile_name"
2897 if test "$libtool" = true; then
2898 func_append actioncmd " --libtool"
2900 func_append actioncmd " --no-libtool"
2902 func_append actioncmd " --macro-prefix=$macro_prefix"
2903 if test -n "$po_domain"; then
2904 func_append actioncmd " --po-domain=$po_domain"
2906 if test -n "$vc_files"; then
2907 if test "$vc_files" = true; then
2908 func_append actioncmd " --vc-files"
2910 func_append actioncmd " --no-vc-files"
2913 func_append actioncmd " `echo $specified_modules`"
2915 # Default the makefile name to Makefile.am.
2916 if test -n "$makefile_name"; then
2917 makefile_am=$makefile_name
2919 makefile_am=Makefile.am
2922 # Create normal Makefile.ams.
2925 # Setup list of Makefile.am edits that are to be performed afterwards.
2926 # Some of these edits apply to files that we will generate; others are
2927 # under the responsibility of the developer.
2929 # func_note_Makefile_am_edit dir var value
2930 # remembers that ${dir}Makefile.am needs to be edited to that ${var} mentions
2932 func_note_Makefile_am_edit ()
2934 makefile_am_edits=`expr $makefile_am_edits + 1`
2935 eval makefile_am_edit${makefile_am_edits}_dir=\"\$1\"
2936 eval makefile_am_edit${makefile_am_edits}_var=\"\$2\"
2937 eval makefile_am_edit${makefile_am_edits}_val=\"\$3\"
2939 if test "$makefile_am" = Makefile.am; then
2940 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
2941 sourcebase_base=`basename "$sourcebase"`
2942 func_note_Makefile_am_edit "$sourcebase_dir" SUBDIRS "$sourcebase_base"
2944 if test -n "$pobase"; then
2945 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
2946 pobase_base=`basename "$pobase"`
2947 func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
2949 if test -n "$inctests"; then
2950 if test "$makefile_am" = Makefile.am; then
2951 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
2952 testsbase_base=`basename "$testsbase"`
2953 func_note_Makefile_am_edit "$testsbase_dir" SUBDIRS "$testsbase_base"
2956 func_note_Makefile_am_edit "" ACLOCAL_AMFLAGS "-I ${m4base}"
2958 # Find the first parent directory of $m4base that contains or will contain
2960 sed_last='s,^.*/\([^/][^/]*\)//*$,\1/,
2962 sed_butlast='s,[^/][^/]*//*$,,'
2963 dir1="${m4base}/"; dir2=""
2964 while test -n "$dir1" \
2965 && ! { test -f "${destdir}/${dir1}Makefile.am" \
2966 || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
2967 || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
2968 || { test -n "$inctests" \
2969 && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
2970 || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
2971 dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
2972 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
2974 func_note_Makefile_am_edit "$dir1" EXTRA_DIST "${dir2}gnulib-cache.m4"
2977 # Create library makefile.
2978 func_dest_tmpfilename $sourcebase/$makefile_am
2979 destfile="$sourcebase/$makefile_am"
2980 modules="$main_modules"
2981 func_emit_lib_Makefile_am > "$tmpfile"
2982 if test -f "$destdir"/$sourcebase/$makefile_am; then
2983 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
2987 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2988 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
2989 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2991 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2997 echo "Creating $sourcebase/$makefile_am"
2998 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
3000 echo "Create $sourcebase/$makefile_am"
3003 func_append added_files "$sourcebase/$makefile_am$nl"
3006 # Create po/ directory.
3007 if test -n "$pobase"; then
3008 # Create po makefile and auxiliary files.
3009 for file in Makefile.in.in remove-potcdate.sin; do
3010 func_dest_tmpfilename $pobase/$file
3011 func_lookup_file build-aux/po/$file
3012 cat "$lookedup_file" > "$tmpfile"
3013 if test -f "$destdir"/$pobase/$file; then
3014 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
3018 echo "Updating $pobase/$file (backup in $pobase/$file~)"
3019 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
3020 mv -f "$tmpfile" "$destdir"/$pobase/$file
3022 echo "Update $pobase/$file (backup in $pobase/$file~)"
3028 echo "Creating $pobase/$file"
3029 mv -f "$tmpfile" "$destdir"/$pobase/$file
3031 echo "Create $pobase/$file"
3034 func_append added_files "$pobase/$file$nl"
3037 # Create po makefile parameterization, part 1.
3038 func_dest_tmpfilename $pobase/Makevars
3039 func_emit_po_Makevars > "$tmpfile"
3040 if test -f "$destdir"/$pobase/Makevars; then
3041 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
3045 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
3046 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
3047 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3049 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
3055 echo "Creating $pobase/Makevars"
3056 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
3058 echo "Create $pobase/Makevars"
3061 func_append added_files "$pobase/Makevars$nl"
3063 # Create po makefile parameterization, part 2.
3064 func_dest_tmpfilename $pobase/POTFILES.in
3065 func_emit_po_POTFILES_in > "$tmpfile"
3066 if test -f "$destdir"/$pobase/POTFILES.in; then
3067 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
3071 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3072 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
3073 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3075 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
3081 echo "Creating $pobase/POTFILES.in"
3082 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
3084 echo "Create $pobase/POTFILES.in"
3087 func_append added_files "$pobase/POTFILES.in$nl"
3090 TP_URL="http://translationproject.org/latest/"
3091 TP_RSYNC_URI="translationproject.org::tp/latest/"
3093 echo "Fetching gnulib PO files from $TP_URL"
3094 (cd "$destdir"/$pobase \
3095 && { # Prefer rsync over wget if it is available, since it consumes
3096 # less network bandwidth, due to compression.
3097 if type rsync 2>/dev/null | grep / > /dev/null; then
3098 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
3100 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
3105 echo "Fetch gnulib PO files from $TP_URL"
3107 # Create po/LINGUAS.
3109 func_dest_tmpfilename $pobase/LINGUAS
3110 (cd "$destdir"/$pobase \
3111 && { echo '# Set of available languages.'
3112 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
3115 if test -f "$destdir"/$pobase/LINGUAS; then
3116 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
3119 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3120 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
3121 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3124 echo "Creating $pobase/LINGUAS"
3125 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
3126 func_append added_files "$pobase/LINGUAS$nl"
3129 if test -f "$destdir"/$pobase/LINGUAS; then
3130 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
3132 echo "Create $pobase/LINGUAS"
3137 # Create m4/gnulib-cache.m4.
3138 func_dest_tmpfilename $m4base/gnulib-cache.m4
3140 func_emit_copyright_notice
3142 echo "# This file represents the specification of how gnulib-tool is used."
3143 echo "# It acts as a cache: It is written and read by gnulib-tool."
3144 echo "# In projects using CVS, this file is meant to be stored in CVS,"
3145 echo "# like the configure.ac and various Makefile.am files."
3148 echo "# Specification in the form of a command-line invocation:"
3151 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
3152 # Store the local_gnulib_dir relative to destdir.
3153 case "$local_gnulib_dir" in
3155 relative_local_gnulib_dir="$local_gnulib_dir" ;;
3158 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
3160 # destdir, local_gnulib_dir are both relative.
3161 func_relativize "$destdir" "$local_gnulib_dir"
3162 relative_local_gnulib_dir="$reldir" ;;
3165 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
3167 echo "$specified_modules" | sed 's/^/ /g'
3169 echo "gl_AVOID([$avoidlist])"
3170 echo "gl_SOURCE_BASE([$sourcebase])"
3171 echo "gl_M4_BASE([$m4base])"
3172 echo "gl_PO_BASE([$pobase])"
3173 echo "gl_DOC_BASE([$docbase])"
3174 echo "gl_TESTS_BASE([$testsbase])"
3175 test -z "$inctests" || echo "gl_WITH_TESTS"
3176 echo "gl_LIB([$libname])"
3177 if test -n "$lgpl"; then
3178 if test "$lgpl" = yes; then
3181 echo "gl_LGPL([$lgpl])"
3184 echo "gl_MAKEFILE_NAME([$makefile_name])"
3185 if test "$libtool" = true; then
3188 echo "gl_MACRO_PREFIX([$macro_prefix])"
3189 echo "gl_PO_DOMAIN([$po_domain])"
3190 if test -n "$vc_files"; then
3191 echo "gl_VC_FILES([$vc_files])"
3194 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
3195 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
3199 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3200 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
3201 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3203 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
3207 echo "# gnulib-cache.m4 ends here"
3214 echo "Creating $m4base/gnulib-cache.m4"
3215 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
3217 echo "Create $m4base/gnulib-cache.m4"
3223 # Create m4/gnulib-comp.m4.
3224 func_dest_tmpfilename $m4base/gnulib-comp.m4
3226 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
3227 func_emit_copyright_notice
3229 echo "# This file represents the compiled summary of the specification in"
3230 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
3231 echo "# to be invoked from configure.ac."
3232 echo "# In projects using CVS, this file can be treated like other built files."
3235 echo "# This macro should be invoked from $configure_ac, in the section"
3236 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
3237 echo "# any checks for libraries, header files, types and library functions."
3238 echo "AC_DEFUN([${macro_prefix}_EARLY],"
3240 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3241 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3242 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3243 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3244 echo " AC_REQUIRE([AC_PROG_RANLIB])"
3245 if test -n "$uses_subdirs"; then
3246 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
3248 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
3249 echo " AC_REQUIRE([AC_GNU_SOURCE])"
3251 for module in $final_modules; do
3253 if test -n "$module"; then
3254 func_get_autoconf_early_snippet "$module"
3257 | sed -e '/^$/d;' -e 's/^/ /'
3260 echo "# This macro should be invoked from $configure_ac, in the section"
3261 echo "# \"Check for header files, types and library functions\"."
3262 echo "AC_DEFUN([${macro_prefix}_INIT],"
3264 if test "$libtool" = true; then
3265 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3266 echo " gl_cond_libtool=true"
3268 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3269 echo " gl_cond_libtool=false"
3271 echo " gl_ltlibdeps="
3273 if test "$auxdir" != "build-aux"; then
3274 sed_replace_build_aux='
3276 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3277 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3281 sed_replace_build_aux="$sed_noop"
3283 func_emit_initmacro_start $macro_prefix
3284 echo " gl_source_base='$sourcebase'"
3285 for module in $main_modules; do
3287 if test -n "$module"; then
3288 func_get_autoconf_snippet "$module" \
3289 | sed -e '/^$/d;' -e 's/^/ /' \
3290 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3291 -e "$sed_replace_build_aux"
3292 if test "$module" = 'alloca' && test "$libtool" = true; then
3293 echo 'changequote(,)dnl'
3294 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3295 echo 'changequote([, ])dnl'
3296 echo 'AC_SUBST([LTALLOCA])'
3300 func_emit_initmacro_end $macro_prefix
3301 echo " gltests_libdeps="
3302 echo " gltests_ltlibdeps="
3303 func_emit_initmacro_start ${macro_prefix}tests
3304 echo " gl_source_base='$testsbase'"
3305 for module in $testsrelated_modules; do
3307 if test -n "$module"; then
3308 func_get_autoconf_snippet "$module" \
3309 | sed -e '/^$/d;' -e 's/^/ /' \
3310 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3311 -e "$sed_replace_build_aux" \
3312 -e 's/\$gl_cond_libtool/false/g' \
3313 -e 's/gl_libdeps/gltests_libdeps/g' \
3314 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3317 func_emit_initmacro_end ${macro_prefix}tests
3318 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3319 # created using libtool, because libtool already handles the dependencies.
3320 if test "$libtool" != true; then
3321 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3322 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3323 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3324 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3325 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3327 if $use_libtests; then
3328 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
3329 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
3332 func_emit_initmacro_done $macro_prefix $sourcebase
3333 func_emit_initmacro_done ${macro_prefix}tests $testsbase
3335 echo "# This macro records the list of files which have been installed by"
3336 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
3337 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
3338 echo "$files" | sed -e 's,^, ,'
3341 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3342 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
3346 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3347 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
3348 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3350 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3354 echo "# gnulib-comp.m4 ends here"
3361 echo "Creating $m4base/gnulib-comp.m4"
3362 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3364 echo "Create $m4base/gnulib-comp.m4"
3370 if test -n "$inctests"; then
3371 # Create tests makefile.
3372 func_dest_tmpfilename $testsbase/$makefile_am
3373 destfile="$testsbase/$makefile_am"
3374 modules="$testsrelated_modules"
3375 func_emit_tests_Makefile_am > "$tmpfile"
3376 if test -f "$destdir"/$testsbase/$makefile_am; then
3377 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
3381 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3382 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
3383 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3385 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3391 echo "Creating $testsbase/$makefile_am"
3392 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3394 echo "Create $testsbase/$makefile_am"
3397 func_append added_files "$testsbase/$makefile_am$nl"
3401 if test "$vc_files" != false; then
3402 # Update the .cvsignore and .gitignore files.
3403 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
3404 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
3405 # Treat gnulib-comp.m4 like an added file, even if it already existed.
3406 echo "$m4base/|A|gnulib-comp.m4"
3407 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
3408 { # Rearrange file descriptors. Needed because "while ... done < ..."
3409 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3410 exec 5<&0 < "$tmp"/fileset-changes
3411 func_update_ignorelist ()
3414 if test "$ignore" = .gitignore; then
3415 # In a .gitignore file, "foo" applies to the current directory and all
3416 # subdirectories, whereas "/foo" applies to the current directory only.
3419 doubly_escaped_anchor='\\/'
3423 doubly_escaped_anchor=''
3425 if test -f "$destdir/$dir$ignore"; then
3426 if test -n "$dir_added" || test -n "$dir_removed"; then
3427 sed -e "s|^$anchor||" < "$destdir/$dir$ignore" | LC_ALL=C sort > "$tmp"/ignore
3429 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
3430 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-added
3431 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
3432 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-removed
3434 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
3436 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3437 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
3438 { sed -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed
3439 if test -n "$anchor"; then sed -e "s,^,/^${doubly_escaped_anchor}," -e 's,$,\$/d,' < "$tmp"/ignore-removed; fi
3440 } > "$tmp"/sed-ignore-removed
3441 { cat "$destdir/$dir$ignore"~
3442 sed -e "s|^|$anchor|" < "$tmp"/ignore-added
3443 } | sed -f "$tmp"/sed-ignore-removed \
3444 > "$destdir/$dir$ignore"
3446 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3451 if test -n "$dir_added"; then
3453 echo "Creating $destdir/$dir$ignore"
3455 if test "$ignore" = .cvsignore; then
3457 # Automake generates Makefile rules that create .dirstamp files.
3460 echo "$dir_added" | sed -e '/^$/d' -e "s|^|$anchor|" | LC_ALL=C sort -u
3461 } > "$destdir/$dir$ignore"
3463 echo "Create $destdir/$dir$ignore"
3473 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
3474 func_update_ignorelist .cvsignore
3476 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
3477 func_update_ignorelist .gitignore
3484 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
3485 next_dir=`echo "$line" | sed -e 's,|.*,,'`
3486 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
3487 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
3488 if test "$next_dir" != "$last_dir"; then
3489 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3490 last_dir="$next_dir"
3495 A) func_append last_dir_added "$file$nl";;
3496 R) func_append last_dir_removed "$file$nl";;
3499 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3506 echo "You may need to add #include directives for the following .h files."
3507 # Intersect $specified_modules and $main_modules
3508 # (since $specified_modules is not necessarily of subset of $main_modules
3509 # - some may have been skipped through --avoid, and since the elements of
3510 # $main_modules but not in $specified_modules can go away without explicit
3511 # notice - through changes in the module dependencies).
3512 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
3513 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
3514 # First the #include <...> directives without #ifs, sorted for convenience,
3515 # then the #include "..." directives without #ifs, sorted for convenience,
3516 # then the #include directives that are surrounded by #ifs. Not sorted.
3517 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
3518 include_directive=`func_get_include_directive "$module"`
3519 case "$nl$include_directive" in
3521 echo "$include_directive" 1>&5
3524 echo "$include_directive" | grep -v 'include "' 1>&6
3525 echo "$include_directive" | grep 'include "' 1>&7
3528 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
3530 LC_ALL=C sort -u "$tmp"/include-angles
3531 LC_ALL=C sort -u "$tmp"/include-quotes
3532 cat "$tmp"/include-if
3533 ) | sed -e '/^$/d' -e 's/^/ /'
3534 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
3536 for module in $main_modules; do
3537 func_get_link_directive "$module"
3539 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
3540 if test `wc -l < "$tmp"/link` != 0; then
3542 echo "You may need to use the following Makefile variables when linking."
3543 echo "Use them in <program>_LDADD when linking a program, or"
3544 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
3550 echo "Don't forget to"
3551 if test "$makefile_am" = Makefile.am; then
3552 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3554 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
3556 if test -n "$pobase"; then
3557 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
3559 if test -n "$inctests"; then
3560 if test "$makefile_am" = Makefile.am; then
3561 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3563 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
3567 while test $edit != $makefile_am_edits; do
3568 edit=`expr $edit + 1`
3569 eval dir=\"\$makefile_am_edit${edit}_dir\"
3570 eval var=\"\$makefile_am_edit${edit}_var\"
3571 eval val=\"\$makefile_am_edit${edit}_val\"
3572 if test -n "$var"; then
3573 echo " - mention \"${val}\" in ${var} in ${dir}Makefile.am,"
3576 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
3577 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
3580 # func_create_testdir testdir modules
3582 # - local_gnulib_dir from --local-dir
3583 # - auxdir directory relative to destdir where to place build aux files
3584 func_create_testdir ()
3588 if test -z "$modules"; then
3589 # All modules together.
3590 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3591 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3592 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
3593 modules=`func_all_modules`
3594 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
3596 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
3598 # Check that the license of every module is consistent with the license of
3600 saved_modules="$modules"
3601 saved_inctests="$inctests"
3602 # When computing transitive closures, don't consider $module to depend on
3603 # $module-tests. Need this becauses tests are implicitly GPL and may depend
3604 # on GPL modules - therefore we don't want a warning in this case.
3606 for requested_module in $saved_modules; do
3607 requested_license=`func_get_license "$requested_module"`
3608 if test "$requested_license" != GPL; then
3609 # Here we use func_modules_transitive_closure, not just
3610 # func_get_dependencies, so that we also detect weird situations like
3611 # an LGPL module which depends on a GPLed build tool module which depends
3613 modules="$requested_module"
3614 func_modules_transitive_closure
3615 for module in $modules; do
3616 license=`func_get_license "$module"`
3618 'GPLed build tool') ;;
3619 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3621 case "$requested_license" in
3624 GPLv2+ | LGPLv2+) ;;
3625 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3631 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3637 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3646 modules="$saved_modules"
3647 inctests="$saved_inctests"
3649 # Subdirectory names.
3659 # Determine final module list.
3660 func_modules_transitive_closure
3661 if test $verbose -ge 0; then
3662 echo "Module list with included dependencies:"
3663 echo "$modules" | sed -e 's/^/ /'
3666 # Add the dummy module if needed.
3667 func_modules_add_dummy
3669 # Show banner notice of every module.
3672 # Determine final file list.
3673 func_modules_to_filelist
3674 if test $verbose -ge 0; then
3676 echo "$files" | sed -e 's/^/ /'
3679 sed_rewrite_files="\
3680 s,^build-aux/,$auxdir/,
3682 s,^lib/,$sourcebase/,
3684 s,^tests/,$testsbase/,
3687 # Create directories.
3688 for f in $files; do echo $f; done \
3689 | sed -e "$sed_rewrite_files" \
3690 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3691 | LC_ALL=C sort -u \
3693 { # Rearrange file descriptors. Needed because "while ... done < ..."
3694 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3695 exec 5<&0 < "$tmp"/dirs
3697 mkdir -p "$testdir/$d"
3702 # Copy files or make symbolic links.
3704 for f in $files; do echo $f; done \
3705 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3708 { # Rearrange file descriptors. Needed because "while ... done < ..."
3709 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3710 exec 5<&0 < "$tmp"/files
3712 func_lookup_file "$f"
3713 if test -n "$lookedup_tmp"; then
3714 cp -p "$lookedup_file" "$testdir/$g"
3716 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3717 if { test -n "$symbolic" \
3718 || { test -n "$lsymbolic" \
3719 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3720 func_ln "$lookedup_file" "$testdir/$g"
3722 cp -p "$lookedup_file" "$testdir/$g"
3729 # Create Makefile.ams that are for testing.
3732 # No special edits are needed.
3735 # Create $sourcebase/Makefile.am.
3736 mkdir -p "$testdir/$sourcebase"
3737 destfile="$sourcebase/Makefile.am"
3738 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3739 any_uses_subdirs="$uses_subdirs"
3741 # Create $m4base/Makefile.am.
3742 mkdir -p "$testdir/$m4base"
3743 (echo "## Process this file with automake to produce Makefile.in."
3749 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
3752 ) > "$testdir/$m4base/Makefile.am"
3754 subdirs="$sourcebase $m4base"
3755 subdirs_with_configure_ac=""
3757 if false && test -f "$testdir"/$m4base/gettext.m4; then
3758 # Avoid stupid error message from automake:
3759 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
3760 mkdir -p "$testdir/po"
3761 (echo "## Process this file with automake to produce Makefile.in."
3762 ) > "$testdir/po/Makefile.am"
3763 func_append subdirs " po"
3766 if test -n "$inctests"; then
3767 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
3768 # Viewed from the $testsbase subdirectory, $auxdir is different.
3769 saved_auxdir="$auxdir"
3770 auxdir=`echo "$testsbase/"|sed 's%[^/][^/]*//*%../%g'`"$auxdir"
3771 # Create $testsbase/Makefile.am.
3773 destfile="$testsbase/Makefile.am"
3774 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
3775 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
3776 # Create $testsbase/configure.ac.
3777 (echo "# Process this file with autoconf to produce a configure script."
3778 echo "AC_INIT([dummy], [0])"
3779 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3780 echo "AM_INIT_AUTOMAKE"
3782 echo "AM_CONFIG_HEADER([config.h])"
3785 echo "AC_PROG_INSTALL"
3786 echo "AC_PROG_MAKE_SET"
3787 echo "AC_PROG_RANLIB"
3789 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3790 echo "AC_GNU_SOURCE"
3793 for module in $modules; do
3795 if test -n "$module"; then
3796 func_get_autoconf_early_snippet "$module"
3799 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3800 if test "$libtool" = true; then
3801 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3802 echo "gl_cond_libtool=true"
3804 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3805 echo "gl_cond_libtool=false"
3807 echo "gl_ltlibdeps="
3809 # Wrap the set of autoconf snippets into an autoconf macro that is then
3810 # invoked. This is needed because autoconf does not support AC_REQUIRE
3812 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3813 # but we want the AC_REQUIRE to have its normal meaning (provide one
3814 # expansion of the required macro before the current point, and only one
3816 echo "AC_DEFUN([gl_INIT], ["
3817 sed_replace_build_aux='
3819 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3820 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3823 func_emit_initmacro_start $macro_prefix
3824 # We don't have explicit ordering constraints between the various
3825 # autoconf snippets. It's cleanest to put those of the library before
3826 # those of the tests.
3827 echo "gl_source_base='../$sourcebase'"
3828 for module in $modules; do
3829 func_verify_nontests_module
3830 if test -n "$module"; then
3831 func_get_autoconf_snippet "$module" \
3832 | sed -e "$sed_replace_build_aux"
3835 echo "gl_source_base='.'"
3836 for module in $modules; do
3837 func_verify_tests_module
3838 if test -n "$module"; then
3839 func_get_autoconf_snippet "$module" \
3840 | sed -e "$sed_replace_build_aux"
3843 func_emit_initmacro_end $macro_prefix
3844 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3845 # created using libtool, because libtool already handles the dependencies.
3846 if test "$libtool" != true; then
3847 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3848 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3849 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3850 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3851 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3854 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
3858 # Usually $testsbase/config.h will be a superset of config.h. Verify this
3859 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
3860 echo "AH_TOP([#include \"../config.h\"])"
3862 echo "AC_OUTPUT([Makefile])"
3863 ) > "$testdir/$testsbase/configure.ac"
3864 auxdir="$saved_auxdir"
3865 func_append subdirs " $testsbase"
3866 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
3869 # Create Makefile.am.
3870 (echo "## Process this file with automake to produce Makefile.in."
3872 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3874 echo "SUBDIRS = $subdirs"
3876 echo "ACLOCAL_AMFLAGS = -I $m4base"
3877 ) > "$testdir/Makefile.am"
3879 # Create configure.ac.
3880 (echo "# Process this file with autoconf to produce a configure script."
3881 echo "AC_INIT([dummy], [0])"
3882 if test "$auxdir" != "."; then
3883 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3885 echo "AM_INIT_AUTOMAKE"
3887 echo "AM_CONFIG_HEADER([config.h])"
3890 echo "AC_PROG_INSTALL"
3891 echo "AC_PROG_MAKE_SET"
3893 echo "# For autobuild."
3894 echo "AC_CANONICAL_BUILD"
3895 echo "AC_CANONICAL_HOST"
3897 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3898 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3899 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3900 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3902 echo "AC_PROG_RANLIB"
3904 if test -n "$any_uses_subdirs"; then
3905 echo "AM_PROG_CC_C_O"
3908 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3909 echo "AC_GNU_SOURCE"
3912 for module in $modules; do
3913 func_verify_nontests_module
3914 if test -n "$module"; then
3915 func_get_autoconf_early_snippet "$module"
3918 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3919 if test "$libtool" = true; then
3920 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3921 echo "gl_cond_libtool=true"
3923 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3924 echo "gl_cond_libtool=false"
3926 echo "gl_ltlibdeps="
3928 # Wrap the set of autoconf snippets into an autoconf macro that is then
3929 # invoked. This is needed because autoconf does not support AC_REQUIRE
3931 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3932 # but we want the AC_REQUIRE to have its normal meaning (provide one
3933 # expansion of the required macro before the current point, and only one
3935 echo "AC_DEFUN([gl_INIT], ["
3936 if test "$auxdir" != "build-aux"; then
3937 sed_replace_build_aux='
3939 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3940 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3944 sed_replace_build_aux="$sed_noop"
3946 func_emit_initmacro_start $macro_prefix
3947 echo "gl_source_base='$sourcebase'"
3948 for module in $modules; do
3949 func_verify_nontests_module
3950 if test -n "$module"; then
3951 func_get_autoconf_snippet "$module" \
3952 | sed -e "$sed_replace_build_aux"
3955 func_emit_initmacro_end $macro_prefix
3956 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3957 # created using libtool, because libtool already handles the dependencies.
3958 if test "$libtool" != true; then
3959 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3960 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3961 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3962 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3963 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3966 func_emit_initmacro_done $macro_prefix $sourcebase
3970 if test -n "$subdirs_with_configure_ac"; then
3971 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
3973 makefiles="Makefile"
3974 for d in $subdirs; do
3975 # For subdirs that have a configure.ac by their own, it's the subdir's
3976 # configure.ac which creates the subdir's Makefile.am, not this one.
3977 case " $subdirs_with_configure_ac " in
3979 *) func_append makefiles " $d/Makefile" ;;
3982 echo "AC_OUTPUT([$makefiles])"
3983 ) > "$testdir/configure.ac"
3985 # Create autogenerated files.
3987 # Do not use "${AUTORECONF} --force --install", because it may invoke
3988 # autopoint, which brings in older versions of some of our .m4 files.
3989 if test -f $m4base/gettext.m4; then
3990 func_execute_command ${AUTOPOINT} --force || func_exit 1
3991 for f in $m4base/*.m4~; do
3992 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3995 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
3996 if ! test -d build-aux; then
3997 func_execute_command mkdir build-aux || func_exit 1
3999 func_execute_command ${AUTOCONF} || func_exit 1
4000 func_execute_command ${AUTOHEADER} || func_exit 1
4001 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4003 if test -n "$inctests"; then
4004 # Create autogenerated files.
4005 (cd "$testdir/$testsbase" || func_exit 1
4006 # Do not use "${AUTORECONF} --force --install", because it may invoke
4007 # autopoint, which brings in older versions of some of our .m4 files.
4008 if test -f ../$m4base/gettext.m4; then
4009 func_execute_command ${AUTOPOINT} --force || func_exit 1
4010 for f in ../$m4base/*.m4~; do
4011 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
4014 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
4015 if ! test -d ../build-aux; then
4016 func_execute_command mkdir ../build-aux
4018 func_execute_command ${AUTOCONF} || func_exit 1
4019 func_execute_command ${AUTOHEADER} || func_exit 1
4020 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4023 # Need to run configure and make once, to create built files that are to be
4024 # distributed (such as getdate.c).
4025 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
4026 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4027 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
4028 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
4029 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
4030 # such $(FOO_H) because they don't refer to distributed files.
4031 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
4032 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
4033 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
4034 | sed -e "$sed_remove_make_variables"`
4035 distributed_built_sources=`for file in $built_sources; do
4036 case "$cleaned_files" in
4041 if test -n "$distributed_built_sources"; then
4043 ./configure || func_exit 1
4045 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
4046 make built_sources || func_exit 1
4048 make distclean || func_exit 1
4053 # func_create_megatestdir megatestdir allmodules
4055 # - local_gnulib_dir from --local-dir
4056 # - auxdir directory relative to destdir where to place build aux files
4057 func_create_megatestdir ()
4061 if test -z "$allmodules"; then
4062 allmodules=`func_all_modules`
4066 # First, all modules one by one.
4067 for onemodule in $allmodules; do
4068 func_create_testdir "$megatestdir/$onemodule" $onemodule
4069 func_append megasubdirs "$onemodule "
4071 # Then, all modules all together.
4072 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
4073 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
4074 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
4075 func_create_testdir "$megatestdir/ALL" "$allmodules"
4076 func_append megasubdirs "ALL"
4079 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
4080 vc_witness="$gnulib_dir/CVS/Entries"; \
4082 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
4084 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
4085 | sed -e 's,January,01,' -e 's,Jan,01,' \
4086 -e 's,February,02,' -e 's,Feb,02,' \
4087 -e 's,March,03,' -e 's,Mar,03,' \
4088 -e 's,April,04,' -e 's,Apr,04,' \
4090 -e 's,June,06,' -e 's,Jun,06,' \
4091 -e 's,July,07,' -e 's,Jul,07,' \
4092 -e 's,August,08,' -e 's,Aug,08,' \
4093 -e 's,September,09,' -e 's,Sep,09,' \
4094 -e 's,October,10,' -e 's,Oct,10,' \
4095 -e 's,November,11,' -e 's,Nov,11,' \
4096 -e 's,December,12,' -e 's,Dec,12,' \
4097 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
4098 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
4100 echo "CVSDATE=$cvsdate"
4101 echo "test -d logs || mkdir logs"
4102 echo "for module in $megasubdirs; do"
4103 echo " echo \"Working on module \$module...\""
4104 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
4105 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
4108 echo " : autobuild project... \$module"
4109 echo " : autobuild revision... cvs-\$CVSDATE-000000"
4110 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
4111 echo " : autobuild hostname... \`hostname\`"
4112 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
4114 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
4116 ) > "$megatestdir/do-autobuild"
4117 chmod a+x "$megatestdir/do-autobuild"
4119 # Create Makefile.am.
4120 (echo "## Process this file with automake to produce Makefile.in."
4122 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
4124 echo "SUBDIRS = $megasubdirs"
4126 echo "EXTRA_DIST = do-autobuild"
4127 ) > "$megatestdir/Makefile.am"
4129 # Create configure.ac.
4130 (echo "# Process this file with autoconf to produce a configure script."
4131 echo "AC_INIT([dummy], [0])"
4132 if test "$auxdir" != "."; then
4133 echo "AC_CONFIG_AUX_DIR([$auxdir])"
4135 echo "AM_INIT_AUTOMAKE"
4137 echo "AC_PROG_MAKE_SET"
4139 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
4140 echo "AC_OUTPUT([Makefile])"
4141 ) > "$megatestdir/configure.ac"
4143 # Create autogenerated files.
4145 # Do not use "${AUTORECONF} --install", because autoreconf operates
4146 # recursively, but the subdirectories are already finished, therefore
4147 # calling autoreconf here would only waste lots of CPU time.
4148 func_execute_command ${ACLOCAL} || func_exit 1
4149 func_execute_command mkdir build-aux
4150 func_execute_command ${AUTOCONF} || func_exit 1
4151 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
4157 func_fatal_error "no mode specified" ;;
4166 if test -z "$destdir"; then
4169 test -d "$destdir" \
4170 || func_fatal_error "destination directory does not exist: $destdir"
4172 # Prefer configure.ac to configure.in.
4173 if test -f "$destdir"/configure.ac; then
4174 configure_ac="$destdir/configure.ac"
4176 if test -f "$destdir"/configure.in; then
4177 configure_ac="$destdir/configure.in"
4179 func_fatal_error "cannot find $destdir/configure.ac"
4183 # Analyze configure.ac.
4185 guessed_libtool=false
4190 /AC_CONFIG_AUX_DIR/ {
4191 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
4193 /A[CM]_PROG_LIBTOOL/ {
4194 s,^.*$,guessed_libtool=true,p
4196 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
4198 if test -z "$auxdir"; then
4199 auxdir="$guessed_auxdir"
4202 # Determine where to apply func_import.
4203 if test -n "$m4base"; then
4204 # Apply func_import to a particular gnulib directory.
4205 # Any number of additional modules can be given.
4206 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
4207 # First use of gnulib in the given m4base.
4208 test -n "$supplied_libname" || supplied_libname=true
4209 test -n "$sourcebase" || sourcebase="lib"
4210 test -n "$docbase" || docbase="doc"
4211 test -n "$testsbase" || testsbase="tests"
4212 test -n "$macro_prefix" || macro_prefix="gl"
4216 # Apply func_import to all gnulib directories.
4217 # To get this list of directories, look at Makefile.am. (Not at
4218 # configure, because it may be omitted from CVS. Also, don't run
4219 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
4222 if test -f "$destdir"/Makefile.am; then
4223 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
4225 for arg in $aclocal_amflags; do
4226 if test -n "$m4dir_is_next"; then
4227 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
4231 if test -f "$destdir/$arg"/gnulib-cache.m4; then
4232 func_append m4dirs " $arg"
4233 m4dirs_count=`expr $m4dirs_count + 1`
4239 if test "X$arg" = "X-I"; then
4247 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
4248 if test -f "$destdir"/aclocal.m4; then
4249 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
4250 sedexpr2='s,^[^/]*$,.,'
4251 sedexpr3='s,/[^/]*$,,'
4252 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
4253 m4dirs_count=`echo "$m4dirs" | wc -l`
4256 if test $m4dirs_count = 0; then
4257 # First use of gnulib in a package.
4258 # Any number of additional modules can be given.
4259 test -n "$supplied_libname" || supplied_libname=true
4260 test -n "$sourcebase" || sourcebase="lib"
4262 test -n "$docbase" || docbase="doc"
4263 test -n "$testsbase" || testsbase="tests"
4264 test -n "$macro_prefix" || macro_prefix="gl"
4267 if test $m4dirs_count = 1; then
4268 # There's only one use of gnulib here. Assume the user means it.
4269 # Any number of additional modules can be given.
4270 for m4base in $m4dirs; do
4274 # Ambiguous - guess what the user meant.
4275 if test $# = 0; then
4276 # No further arguments. Guess the user wants to update all of them.
4277 for m4base in $m4dirs; do
4278 # Perform func_import in a subshell, so that variable values
4280 # local_gnulib_dir, avoidlist, sourcebase, m4base, pobase,
4281 # docbase, testsbase, inctests, libname, lgpl, makefile_name,
4282 # libtool, macro_prefix, po_domain, vc_files
4283 # don't propagate from one directory to another.
4284 (func_import) || func_exit 1
4288 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
4296 if test -z "$destdir"; then
4297 func_fatal_error "please specify --dir option"
4300 test -d "$destdir" \
4301 || func_fatal_error "could not create destination directory"
4302 test -n "$auxdir" || auxdir="build-aux"
4303 func_create_testdir "$destdir" "$*"
4306 create-megatestdir )
4307 if test -z "$destdir"; then
4308 func_fatal_error "please specify --dir option"
4310 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4311 test -n "$auxdir" || auxdir="build-aux"
4312 func_create_megatestdir "$destdir" "$*"
4316 test -n "$destdir" || destdir=testdir$$
4317 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4318 test -n "$auxdir" || auxdir="build-aux"
4319 func_create_testdir "$destdir" "$*"
4323 ../configure || func_exit 1
4325 make check || func_exit 1
4326 make distclean || func_exit 1
4327 remaining=`find . -type f -print`
4328 if test -n "$remaining"; then
4329 echo "Remaining files:" $remaining 1>&2
4330 echo "gnulib-tool: *** Stop." 1>&2
4339 test -n "$destdir" || destdir=testdir$$
4340 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4341 test -n "$auxdir" || auxdir="build-aux"
4342 func_create_megatestdir "$destdir" "$*"
4350 remaining=`find . -type f -print`
4351 if test -n "$remaining"; then
4352 echo "Remaining files:" $remaining 1>&2
4353 echo "gnulib-tool: *** Stop." 1>&2
4361 extract-description )
4365 if test -n "$module"; then
4366 func_get_description "$module"
4375 if test -n "$module"; then
4376 func_get_status "$module"
4385 if test -n "$module"; then
4386 func_get_notice "$module"
4395 if test -n "$module"; then
4396 func_get_filelist "$module"
4401 extract-dependencies )
4405 if test -n "$module"; then
4406 func_get_dependencies "$module"
4411 extract-autoconf-snippet )
4415 if test -n "$module"; then
4416 func_get_autoconf_snippet "$module"
4421 extract-automake-snippet )
4425 if test -n "$module"; then
4426 func_get_automake_snippet "$module"
4431 extract-include-directive )
4435 if test -n "$module"; then
4436 func_get_include_directive "$module"
4441 extract-link-directive )
4445 if test -n "$module"; then
4446 func_get_link_directive "$module"
4455 if test -n "$module"; then
4456 func_get_license "$module"
4461 extract-maintainer )
4465 if test -n "$module"; then
4466 func_get_maintainer "$module"
4471 extract-tests-module )
4475 if test -n "$module"; then
4476 func_get_tests_module "$module"
4482 func_fatal_error "unknown operation mode --$mode" ;;
4486 # Undo the effect of the previous 'trap' command. Some shellology:
4487 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
4488 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
4489 # exit); for the others we need to call 'exit' explicitly. The value of $? is
4490 # 128 + signal number and is set before the trap-registered command is run.
4492 trap 'func_exit $?' 1 2 3 13 15
4497 # indent-tabs-mode: nil
4498 # whitespace-check-buffer-indent: nil