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'
87 # outputs to stdout the --help usage message.
91 Usage: gnulib-tool --list
92 gnulib-tool --import [module1 ... moduleN]
94 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
95 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
96 gnulib-tool --test --dir=directory module1 ... moduleN
97 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
98 gnulib-tool --extract-description module
99 gnulib-tool --extract-notice module
100 gnulib-tool --extract-filelist module
101 gnulib-tool --extract-dependencies module
102 gnulib-tool --extract-autoconf-snippet module
103 gnulib-tool --extract-automake-snippet module
104 gnulib-tool --extract-include-directive module
105 gnulib-tool --extract-link-directive module
106 gnulib-tool --extract-license module
107 gnulib-tool --extract-maintainer module
108 gnulib-tool --extract-tests-module module
111 --list print the available module names
112 --import import the given modules into the current package;
113 if no modules are specified, update the current
114 package from the current gnulib
115 --update update the current package, restore files omitted
117 --create-testdir create a scratch package with the given modules
118 --create-megatestdir create a mega scratch package with the given modules
119 one by one and all together
120 --test test the combination of the given modules
121 (recommended to use CC=\"gcc -Wall\" here)
122 --megatest test the given modules one by one and all together
123 (recommended to use CC=\"gcc -Wall\" here)
124 --extract-description extract the description
125 --extract-notice extract the notice or banner
126 --extract-filelist extract the list of files
127 --extract-dependencies extract the dependencies
128 --extract-autoconf-snippet extract the snippet for configure.ac
129 --extract-automake-snippet extract the snippet for library makefile
130 --extract-include-directive extract the #include directive
131 --extract-link-directive extract the linker directive
132 --extract-license report the license terms of the source files
134 --extract-maintainer report the maintainer(s) inside gnulib
135 --extract-tests-module report the unit test module, if it exists
138 --dir=DIRECTORY Specify the target directory.
139 For --import, this specifies where your
140 configure.ac can be found. Defaults to current
142 --local-dir=DIRECTORY Specify a local override directory where to look
143 up files before looking in gnulib's directory.
144 --verbose Increase verbosity. May be repeated.
145 --quiet Decrease verbosity. May be repeated.
147 Options for --import:
148 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
149 --source-base=DIRECTORY
150 Directory relative to --dir where source code is
151 placed (default \"lib\").
152 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
153 placed (default \"m4\").
154 --po-base=DIRECTORY Directory relative to --dir where *.po files are
155 placed (default \"po\").
156 --doc-base=DIRECTORY Directory relative to --dir where doc files are
157 placed (default \"doc\").
158 --tests-base=DIRECTORY
159 Directory relative to --dir where unit tests are
160 placed (default \"tests\").
161 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
162 tools are placed (default \"build-aux\").
163 --with-tests Include unit tests for the included modules.
164 --avoid=MODULE Avoid including the given MODULE. Useful if you
165 have code that provides equivalent functionality.
166 This option can be repeated.
167 --lgpl[=2|=3] Abort if modules aren't available under the LGPL.
168 Also modify license template from GPL to LGPL.
169 The version number of the LGPL can be specified;
170 the default is currently LGPLv3.
171 --makefile-name=NAME Name of makefile in automake syntax in the
172 source-base and tests-base directories
173 (default \"Makefile.am\").
174 --libtool Use libtool rules.
175 --no-libtool Don't use libtool rules.
176 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
177 'gl_INIT'. Default is 'gl'.
178 --po-domain=NAME Specify the prefix of the i18n domain. Usually use
179 the package name. A suffix '-gnulib' is appended.
180 --no-changelog don't update or create ChangeLog files
182 Options for --import and --update:
183 --dry-run For --import, only print what would have been done.
184 -s, --symbolic, --symlink Make symbolic links instead of copying files.
185 --local-symlink Make symbolic links instead of copying files, only
186 for files from the local override directory.
187 -S, --more-symlinks Make symbolic links instead of copying files, and
188 don't replace copyright notices.
190 Report bugs to <bug-gnulib@gnu.org>."
194 # outputs to stdout the --version message.
198 if test -d "$gnulib_dir"/.git \
199 && (git --version) >/dev/null 2>/dev/null \
200 && (date --version) >/dev/null 2>/dev/null; then
201 # gnulib checked out from git.
202 sed_extract_first_date='/^Date/{
206 date=`cd "$gnulib_dir" && git log ChangeLog | sed -n -e "$sed_extract_first_date"`
207 # Turn "Fri Mar 21 07:16:51 2008 -0600" into "Mar 21 2008 07:16:51 -0600".
208 sed_year_before_time='s/^[^ ]* \([^ ]*\) \([0-9]*\) \([0-9:]*\) \([0-9]*\) /\1 \2 \4 \3 /'
209 date=`echo "$date" | sed -e "$sed_year_before_time"`
210 # Use GNU date to compute the time in GMT.
211 date=`date -d "$date" -u +"%Y-%m-%d %H:%M:%S"`
212 version=' '`"$gnulib_dir"/build-aux/git-version-gen /dev/null | sed -e 's/-dirty/-modified/'`
214 if test -d "$gnulib_dir"/CVS \
215 && (cvs --version) >/dev/null 2>/dev/null; then
216 # gnulib checked out from CVS.
217 sed_extract_first_date='/^date: /{
218 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
221 date=`cd "$gnulib_dir" && cvs log -N ChangeLog 2>/dev/null | sed -n -e "$sed_extract_first_date"`
223 # gnulib copy without versioning information.
224 date=`sed -e 's/ .*//;q' "$gnulib_dir"/ChangeLog`
228 year=`"$gnulib_dir"/build-aux/mdate-sh "$self_abspathname" | sed 's,^.* ,,'`
230 gnulib-tool (GNU $package $date)$version
231 Copyright (C) $year Free Software Foundation, Inc.
232 License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
233 This is free software: you are free to change and redistribute it.
234 There is NO WARRANTY, to the extent permitted by law.
236 Written by" "Bruno Haible" "and" "Simon Josefsson"
239 # func_emit_copyright_notice
240 # outputs to stdout a header for a generated file.
241 func_emit_copyright_notice ()
243 sed -n '/Copyright/ {
246 }' < "$self_abspathname"
248 echo "# This file is free software, distributed under the terms of the GNU"
249 echo "# General Public License. As a special exception to the GNU General"
250 echo "# Public License, this file may be distributed as part of a program"
251 echo "# that contains a configuration script generated by Autoconf, under"
252 echo "# the same distribution terms as the rest of that program."
254 echo "# Generated by gnulib-tool."
265 # locates the directory where the gnulib repository lives
267 # - self_abspathname absolute pathname of gnulib-tool
268 # - gnulib_dir absolute pathname of gnulib repository
272 /*) self_abspathname="$0" ;;
273 */*) self_abspathname=`pwd`/"$0" ;;
276 # Iterate through the elements of $PATH.
277 # We use IFS=: instead of
278 # for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`
279 # because the latter does not work when some PATH element contains spaces.
280 # We use a canonicalized $pathx instead of $PATH, because empty PATH
281 # elements are by definition equivalent to '.', however field splitting
282 # according to IFS=: loses empty fields in many shells:
283 # - /bin/sh on OSF/1 and Solaris loses all empty fields (at the
284 # beginning, at the end, and in the middle),
285 # - /bin/sh on IRIX and /bin/ksh on IRIX and OSF/1 lose empty fields
286 # at the beginning and at the end,
287 # - GNU bash, /bin/sh on AIX and HP-UX, and /bin/ksh on AIX, HP-UX,
288 # Solaris lose empty fields at the end.
289 # The 'case' statement is an optimization, to avoid evaluating the
290 # explicit canonicalization command when $PATH contains no empty fields.
292 if test "${PATH_SEPARATOR+set}" != set; then
294 { echo "#! /bin/sh"; echo "exit 0"; } > "$tmp"/conf.sh
295 chmod +x "$tmp"/conf.sh
296 if (PATH="/nonexistent;$tmp"; conf.sh) >/dev/null 2>&1; then
303 if test "$PATH_SEPARATOR" = ";"; then
304 # On Windows, programs are searched in "." before $PATH.
307 # On Unix, we have to convert empty PATH elements to ".".
311 pathx=`echo ":$PATH:" | sed -e 's/:::*/:.:/g' -e 's/^://' -e 's/:\$//'`
316 IFS="$PATH_SEPARATOR"
320 if test -x "$d/$0" && test ! -d "$d/$0"; then
321 self_abspathname="$d/$0"
326 if test -z "$self_abspathname"; then
327 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
331 while test -h "$self_abspathname"; do
332 # Resolve symbolic link.
333 linkval=`func_readlink "$self_abspathname"`
334 test -n "$linkval" || break
336 /* ) self_abspathname="$linkval" ;;
337 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
340 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
344 # creates a temporary directory.
346 # - tmp pathname of freshly created temporary directory
349 # Use the environment variable TMPDIR, falling back to /tmp. This allows
350 # users to specify a different temporary directory, for example, if their
351 # /tmp is filled up or too small.
354 # Use the mktemp program if available. If not available, hide the error
356 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
357 test -n "$tmp" && test -d "$tmp"
360 # Use a simple mkdir command. It is guaranteed to fail if the directory
361 # already exists. $RANDOM is bash specific and expands to empty in shells
362 # other than bash, ksh and zsh. Its use does not increase security;
363 # rather, it minimizes the probability of failure in a very cluttered /tmp
365 tmp=$TMPDIR/gl$$-$RANDOM
366 (umask 077 && mkdir "$tmp")
369 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
374 # func_append var value
375 # appends the given value to the shell variable var.
376 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
377 # Use bash's += operator. It reduces complexity of appending repeatedly to
378 # a single variable from O(n^2) to O(n).
386 eval "$1=\"\$$1\$2\""
390 # func_fatal_error message
391 # outputs to stderr a fatal error message, and terminates the program.
394 echo "gnulib-tool: *** $1" 1>&2
395 echo "gnulib-tool: *** Stop." 1>&2
399 # func_readlink SYMLINK
400 # outputs the target of the given symlink.
401 if (type -p readlink) > /dev/null 2>&1; then
404 # Use the readlink program from GNU coreutils.
410 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
411 # would do the wrong thing if the link target contains " -> ".
412 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
416 # func_relativize DIR1 DIR2
417 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
419 # - DIR1 relative pathname, relative to the current directory
420 # - DIR2 relative pathname, relative to the current directory
422 # - reldir relative pathname of DIR2, relative to DIR1
428 sed_first='s,^\([^/]*\)/.*$,\1,'
429 sed_rest='s,^[^/]*/*,,'
430 sed_last='s,^.*/\([^/]*\)$,\1,'
431 sed_butlast='s,/*[^/]*$,,'
432 while test -n "$dir1"; do
433 first=`echo "$dir1" | sed -e "$sed_first"`
434 if test "$first" != "."; then
435 if test "$first" = ".."; then
436 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
437 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
439 first2=`echo "$dir2" | sed -e "$sed_first"`
440 if test "$first2" = "$first"; then
441 dir2=`echo "$dir2" | sed -e "$sed_rest"`
445 dir0="$dir0"/"$first"
448 dir1=`echo "$dir1" | sed -e "$sed_rest"`
453 # func_relconcat DIR1 DIR2
454 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
456 # - DIR1 relative pathname, relative to the current directory
457 # - DIR2 relative pathname, relative to DIR1
459 # - relconcat DIR1/DIR2, relative to the current directory
464 sed_first='s,^\([^/]*\)/.*$,\1,'
465 sed_rest='s,^[^/]*/*,,'
466 sed_last='s,^.*/\([^/]*\)$,\1,'
467 sed_butlast='s,/*[^/]*$,,'
469 first=`echo "$dir2" | sed -e "$sed_first"`
470 if test "$first" = "."; then
471 dir2=`echo "$dir2" | sed -e "$sed_rest"`
472 if test -z "$dir2"; then
477 last=`echo "$dir1" | sed -e "$sed_last"`
478 while test "$last" = "."; do
479 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
480 last=`echo "$dir1" | sed -e "$sed_last"`
482 if test -z "$dir1"; then
486 if test "$first" = ".."; then
487 if test "$last" = ".."; then
488 relconcat="$dir1/$dir2"
491 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
492 dir2=`echo "$dir2" | sed -e "$sed_rest"`
493 if test -z "$dir1"; then
497 if test -z "$dir2"; then
502 relconcat="$dir1/$dir2"
510 # Like ln -s, except that SRC is given relative to the current directory (or
511 # absolute), not given relative to the directory of DEST.
517 *) # SRC is relative.
520 ln -s "`pwd`/$1" "$2" ;;
521 *) # DEST is relative too.
522 ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
523 test -n "$ln_destdir" || ln_destdir="."
524 func_relativize "$ln_destdir" "$1"
532 # func_ln_if_changed SRC DEST
533 # Like func_ln, but avoids munging timestamps if the link is correct.
534 func_ln_if_changed ()
536 if test $# -ne 2; then
537 echo "usage: func_ln_if_changed SRC DEST" >&2
539 ln_target=`func_readlink "$2"`
540 if test -h "$2" && test "$1" = "$ln_target"; then
548 # Ensure an 'echo' command that does not interpret backslashes.
550 # echo '\n' | wc -l prints 1 when OK, 2 when KO
551 # echo '\t' | grep t > /dev/null has return code 0 when OK, 1 when KO
552 # This problem is a weird heritage from SVR4. BSD got it right (except that
553 # BSD echo interprets '-n' as an option, which is also not desirable).
554 # Nowadays the problem occurs in 4 situations:
555 # - in bash, when the shell option xpg_echo is set (bash >= 2.04)
556 # or when it was built with --enable-usg-echo-default (bash >= 2.0)
557 # or when it was built with DEFAULT_ECHO_TO_USG (bash < 2.0),
558 # - in zsh, when sh-emulation is not set,
559 # - in ksh (e.g. AIX /bin/sh and Solaris /usr/xpg4/bin/sh are ksh instances,
560 # and HP-UX /bin/sh and IRIX /bin/sh behave similarly),
561 # - in Solaris /bin/sh and OSF/1 /bin/sh.
562 # We try the following workarounds:
563 # - for all: respawn using $CONFIG_SHELL if that is set and works.
564 # - for bash >= 2.04: unset the shell option xpg_echo.
565 # - for bash >= 2.0: define echo to a function that uses the printf built-in.
566 # - for bash < 2.0: define echo to a function that uses cat of a here document.
567 # - for zsh: turn sh-emulation on.
568 # - for ksh: alias echo to 'print -r'.
569 # - for ksh: alias echo to a function that uses cat of a here document.
570 # - for Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh and rely on
571 # the ksh workaround.
572 # - otherwise: respawn using /bin/sh and rely on the workarounds.
573 # When respawning, we pass --no-reexec as first argument, so as to avoid
574 # turning this script into a fork bomb in unlucky situations.
576 if echo '\t' | grep t > /dev/null; then
577 have_echo=yes # Lucky!
579 # Try the workarounds.
580 # Respawn using $CONFIG_SHELL if that is set and works.
581 if test -z "$have_echo" \
582 && test "X$1" != "X--no-reexec" \
583 && test -n "$CONFIG_SHELL" \
584 && test -f "$CONFIG_SHELL" \
585 && $CONFIG_SHELL -c 'echo '\t' | grep t > /dev/null'; then
586 exec $CONFIG_SHELL "$0" --no-reexec "$@"
589 # For bash >= 2.04: unset the shell option xpg_echo.
590 if test -z "$have_echo" \
591 && test -n "$BASH_VERSION" \
592 && (shopt -o xpg_echo; echo '\t' | grep t > /dev/null) 2>/dev/null; then
596 # For bash >= 2.0: define echo to a function that uses the printf built-in.
597 # For bash < 2.0: define echo to a function that uses cat of a here document.
598 # (There is no win in using 'printf' over 'cat' if it is not a shell built-in.)
599 if test -z "$have_echo" \
600 && test -n "$BASH_VERSION"; then \
601 if type printf 2>/dev/null | grep / > /dev/null; then
602 # 'printf' is not a shell built-in.
610 # 'printf' is a shell built-in.
616 if echo '\t' | grep t > /dev/null; then
620 # For zsh: turn sh-emulation on.
621 if test -z "$have_echo" \
622 && test -n "$ZSH_VERSION" \
623 && (emulate sh) >/dev/null 2>&1; then
626 # For ksh: alias echo to 'print -r'.
627 if test -z "$have_echo" \
628 && (type print) >/dev/null 2>&1; then
629 # A 'print' command exists.
630 if type print 2>/dev/null | grep / > /dev/null; then
633 # 'print' is a shell built-in.
634 if (print -r '\told' | grep told > /dev/null) 2>/dev/null; then
635 # 'print' is the ksh shell built-in.
636 alias echo='print -r'
640 if test -z "$have_echo" \
641 && echo '\t' | grep t > /dev/null; then
644 # For ksh: alias echo to a function that uses cat of a here document.
645 # The ksh manual page says:
646 # "Aliasing is performed when scripts are read, not while they are executed.
647 # Therefore, for an alias to take effect, the alias definition command has
648 # to be executed before the command which references the alias is read."
649 # Because of this, we have to play strange tricks with have_echo, to ensure
650 # that the top-level statement containing the test starts after the 'alias'
652 if test -z "$have_echo"; then
659 alias echo=bsd_echo 2>/dev/null
661 if test -z "$have_echo" \
662 && echo '\t' | grep t > /dev/null; then
665 if test -z "$have_echo"; then
666 unalias echo 2>/dev/null
668 # For Solaris /bin/sh and OSF/1 /bin/sh: respawn using /bin/ksh.
669 if test -z "$have_echo" \
670 && test "X$1" != "X--no-reexec" \
671 && test -f /bin/ksh; then
672 exec /bin/ksh "$0" --no-reexec "$@"
675 # Otherwise: respawn using /bin/sh.
676 if test -z "$have_echo" \
677 && test "X$1" != "X--no-reexec" \
678 && test -f /bin/sh; then
679 exec /bin/sh "$0" --no-reexec "$@"
682 if test -z "$have_echo"; then
683 func_fatal_error "Shell does not support 'echo' correctly. Please install GNU bash and set the environment variable CONFIG_SHELL to point to it."
685 if echo '\t' | grep t > /dev/null; then
688 func_fatal_error "Shell does not support 'echo' correctly. Workaround does not work. Please report this as a bug to bug-gnulib@gnu.org."
690 if test "X$1" = "X--no-reexec"; then
694 # Command-line option processing.
695 # Removes the OPTIONS from the arguments. Sets the variables:
696 # - mode list or import or create-testdir or create-megatestdir
697 # - destdir from --dir
698 # - local_gnulib_dir from --local-dir
699 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
700 # - libname, supplied_libname from --lib
701 # - sourcebase from --source-base
702 # - m4base from --m4-base
703 # - pobase from --po-base
704 # - docbase from --doc-base
705 # - testsbase from --tests-base
706 # - auxdir from --aux-dir
707 # - inctests true if --with-tests was given, blank otherwise
708 # - avoidlist list of modules to avoid, from --avoid
709 # - lgpl yes or a number if --lgpl was given, blank otherwise
710 # - makefile_name from --makefile-name
711 # - libtool true if --libtool was given, false if --no-libtool was
712 # given, blank otherwise
713 # - macro_prefix from --macro-prefix
714 # - po_domain from --po-domain
715 # - autoconf_minversion minimum supported autoconf version
716 # - do_changelog false if --no-changelog was given, : otherwise
717 # - doit : if actions shall be executed, false if only to be printed
718 # - symbolic true if --symlink or --more-symlinks was given, blank
720 # - lsymbolic true if --local-symlink was given, blank otherwise
721 # - do_copyrights blank if --more-symlinks was given, true otherwise
750 while test $# -gt 0; do
755 --import | --impor | --impo | --imp | --im | --i )
758 --update | --updat | --upda | --upd | --up | --u )
761 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
764 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
765 mode=create-megatestdir
767 --test | --tes | --te | --t )
770 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
774 mode=`echo "X$1" | sed -e 's/^X--//'`
779 func_fatal_error "missing argument for --dir"
784 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
789 func_fatal_error "missing argument for --local-dir"
794 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
796 --verbose | --verbos | --verbo | --verb )
797 verbose=`expr $verbose + 1`
799 --quiet | --quie | --qui | --qu | --q )
800 verbose=`expr $verbose - 1`
805 func_fatal_error "missing argument for --lib"
808 supplied_libname=true
811 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
812 supplied_libname=true
817 func_fatal_error "missing argument for --source-base"
822 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
827 func_fatal_error "missing argument for --m4-base"
832 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
837 func_fatal_error "missing argument for --po-base"
842 pobase=`echo "X$1" | sed -e 's/^X--po-base=//'`
847 func_fatal_error "missing argument for --doc-base"
852 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
857 func_fatal_error "missing argument for --tests-base"
862 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
867 func_fatal_error "missing argument for --aux-dir"
872 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
880 func_fatal_error "missing argument for --avoid"
882 func_append avoidlist " $1"
885 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
886 func_append avoidlist " $arg"
892 arg=`echo "X$1" | sed -e 's/^X--lgpl=//'`
895 *) func_fatal_error "invalid LGPL version number for --lgpl" ;;
902 func_fatal_error "missing argument for --makefile-name"
907 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
918 func_fatal_error "missing argument for --macro-prefix"
923 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
928 func_fatal_error "missing argument for --po-domain"
933 po_domain=`echo "X$1" | sed -e 's/^X--po-domain=//'`
935 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
941 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
944 --local-symlink | --local-symlin | --local-symli | --local-syml | --local-sym | --local-sy | --local-s )
947 -S | --more-symlinks | --more-symlink | --more-symlin | --more-symli | --more-syml | --more-sym | --more-sy | --more-s | --more- | --more | --mor | --mo )
951 --help | --hel | --he | --h )
954 --version | --versio | --versi | --vers )
958 # Stop option processing
962 echo "gnulib-tool: unknown option $1" 1>&2
963 echo "Try 'gnulib-tool --help' for more information." 1>&2
970 if test "$mode" = update; then
971 if test $# != 0; then
972 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
973 echo "Try 'gnulib-tool --help' for more information." 1>&2
974 echo "If you really want to modify the gnulib configuration of your project," 1>&2
975 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
978 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
979 || test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
980 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
981 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
982 || test -n "$makefile_name" || test -n "$macro_prefix" \
983 || test -n "$po_domain"; then
984 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
985 echo "Try 'gnulib-tool --help' for more information." 1>&2
986 echo "If you really want to modify the gnulib configuration of your project," 1>&2
987 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
992 if test -n "$pobase" && test -z "$po_domain"; then
993 echo "gnulib-tool: together with --po-base, you need to specify --po-domain" 1>&2
994 echo "Try 'gnulib-tool --help' for more information." 1>&2
997 if test -z "$pobase" && test -n "$po_domain"; then
998 echo "gnulib-tool: warning: --po-domain has no effect without a --po-base option" 1>&2
1001 # Determine the minimum supported autoconf version from the project's
1003 DEFAULT_AUTOCONF_MINVERSION="2.59"
1004 autoconf_minversion=
1006 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
1007 if test -f "$destdir"/configure.ac; then
1008 configure_ac="$destdir/configure.ac"
1010 if test -f "$destdir"/configure.in; then
1011 configure_ac="$destdir/configure.in"
1015 if test -f configure.ac; then
1016 configure_ac="configure.ac"
1018 if test -f configure.in; then
1019 configure_ac="configure.in"
1023 if test -n "$configure_ac"; then
1024 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
1025 # because when some m4 files are omitted from a CVS repository,
1026 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
1027 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
1028 # autom4te: m4 failed with exit status: 1
1035 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,\1,p
1037 prereqs=`sed -n -e "$my_sed_traces" < "$configure_ac"`
1038 if test -n "$prereqs"; then
1039 autoconf_minversion=`
1040 for version in $prereqs; do echo $version; done |
1041 LC_ALL=C sort -nru | sed 1q
1045 if test -z "$autoconf_minversion"; then
1046 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
1048 case "$autoconf_minversion" in
1049 1.* | 2.[0-4]* | 2.5[0-8]*)
1050 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
1053 # Remove trailing slashes from the directory names. This is necessary for
1054 # m4base (to avoid an error in func_import) and optional for the others.
1055 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
1056 case "$local_gnulib_dir" in
1057 */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
1059 case "$sourcebase" in
1060 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
1063 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
1066 */ ) pobase=`echo "$pobase" | sed -e "$sed_trimtrailingslashes"` ;;
1069 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
1071 case "$testsbase" in
1072 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
1075 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
1081 trap 'exit_status=$?
1082 if test "$signal" != 0; then
1083 echo "caught signal $signal" >&2
1086 exit $exit_status' 0
1087 for signal in 1 2 3 13 15; do
1088 trap '{ signal='$signal'; func_exit 1; }' $signal
1092 # func_lookup_file file
1093 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
1096 # - local_gnulib_dir from --local-dir
1098 # - lookedup_file name of the merged (combined) file
1099 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
1103 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
1104 lookedup_file="$local_gnulib_dir/$lkfile"
1107 if test -f "$gnulib_dir/$lkfile"; then
1108 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
1109 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
1110 rm -f "$tmp/$lkbase"
1111 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
1112 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
1113 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
1114 lookedup_file="$tmp/$lkbase"
1117 lookedup_file="$gnulib_dir/$lkfile"
1121 func_fatal_error "file $gnulib_dir/$lkfile not found"
1128 # - local_gnulib_dir from --local-dir
1131 # Filter out metainformation files like README, which are not modules.
1132 # Filter out unit test modules; they can be retrieved through
1133 # --extract-tests-module if desired.
1135 (cd "$gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,')
1136 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
1137 (cd "$local_gnulib_dir" && find modules -type f -print | sed -e 's,^modules/,,' -e 's,\.diff$,,')
1140 | sed -e '/^CVS\//d' -e '/\/CVS\//d' \
1141 -e '/^ChangeLog$/d' -e '/\/ChangeLog$/d' \
1142 -e '/^COPYING$/d' -e '/\/COPYING$/d' \
1143 -e '/^README$/d' -e '/\/README$/d' \
1144 -e '/^TEMPLATE$/d' \
1145 -e '/^TEMPLATE-EXTENDED$/d' \
1146 -e '/^TEMPLATE-TESTS$/d' \
1149 | sed -e '/-tests$/d' \
1153 # func_verify_module
1154 # verifies a module name
1156 # - local_gnulib_dir from --local-dir
1157 # - module module name argument
1158 func_verify_module ()
1160 if { test -f "$gnulib_dir/modules/$module" \
1161 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1162 && test -f "$local_gnulib_dir/modules/$module"; }; } \
1163 && test "CVS" != "$module" \
1164 && test "ChangeLog" != "$module" \
1165 && test "COPYING" != "$module" \
1166 && test "README" != "$module" \
1167 && test "TEMPLATE" != "$module" \
1168 && test "TEMPLATE-EXTENDED" != "$module" \
1169 && test "TEMPLATE-TESTS" != "$module"; then
1170 # OK, $module is a correct module name.
1171 # Verify that building the module description with 'patch' succeeds.
1172 func_lookup_file "modules/$module"
1174 echo "gnulib-tool: module $module doesn't exist" 1>&2
1179 # func_verify_nontests_module
1180 # verifies a module name, excluding tests modules
1182 # - local_gnulib_dir from --local-dir
1183 # - module module name argument
1184 func_verify_nontests_module ()
1187 *-tests ) module= ;;
1188 * ) func_verify_module ;;
1192 # func_verify_tests_module
1193 # verifies a module name, considering only tests modules
1195 # - local_gnulib_dir from --local-dir
1196 # - module module name argument
1197 func_verify_tests_module ()
1200 *-tests ) func_verify_module ;;
1205 sed_extract_prog=':[ ]*$/ {
1208 s/^Description:[ ]*$//
1211 s/^Depends-on:[ ]*$//
1212 s/^configure\.ac-early:[ ]*$//
1213 s/^configure\.ac:[ ]*$//
1214 s/^Makefile\.am:[ ]*$//
1218 s/^Maintainer:[ ]*$//
1225 # func_get_description module
1227 # - local_gnulib_dir from --local-dir
1228 func_get_description ()
1230 func_lookup_file "modules/$1"
1231 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
1234 # func_get_notice module
1236 # - local_gnulib_dir from --local-dir
1239 func_lookup_file "modules/$1"
1240 sed -n -e "/^Notice$sed_extract_prog" < "$lookedup_file"
1243 # func_get_filelist module
1245 # - local_gnulib_dir from --local-dir
1246 func_get_filelist ()
1248 func_lookup_file "modules/$1"
1249 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
1250 echo m4/gnulib-common.m4
1251 case "$autoconf_minversion" in
1253 #echo m4/onceonly.m4
1254 echo m4/onceonly_2_57.m4
1259 # func_get_dependencies module
1261 # - local_gnulib_dir from --local-dir
1262 func_get_dependencies ()
1264 # ${module}-tests always implicitly depends on ${module}.
1265 echo "$1" | sed -n -e 's/-tests$//p'
1266 # Then the explicit dependencies listed in the module description.
1267 func_lookup_file "modules/$1"
1268 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
1271 # func_get_autoconf_early_snippet module
1273 # - local_gnulib_dir from --local-dir
1274 func_get_autoconf_early_snippet ()
1276 func_lookup_file "modules/$1"
1277 sed -n -e "/^configure\.ac-early$sed_extract_prog" < "$lookedup_file"
1280 # func_get_autoconf_snippet module
1282 # - local_gnulib_dir from --local-dir
1283 func_get_autoconf_snippet ()
1285 func_lookup_file "modules/$1"
1286 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
1289 # func_get_automake_snippet module
1291 # - local_gnulib_dir from --local-dir
1292 func_get_automake_snippet ()
1294 func_lookup_file "modules/$1"
1295 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
1298 # *-tests module live in tests/, not lib/.
1299 # Synthesize an EXTRA_DIST augmentation.
1300 all_files=`func_get_filelist $1`
1301 tests_files=`for f in $all_files; do \
1303 tests/*) echo $f ;; \
1305 done | sed -e 's,^tests/,,'`
1306 extra_files="$tests_files"
1307 if test -n "$extra_files"; then
1308 echo "EXTRA_DIST +=" $extra_files
1313 # Synthesize an EXTRA_DIST augmentation.
1314 sed_combine_lines='/\\$/{
1321 sed_extract_mentioned_files='s/^lib_SOURCES[ ]*+=[ ]*//p'
1322 already_mentioned_files=` \
1323 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
1324 | sed -e "$sed_combine_lines" \
1325 | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
1326 all_files=`func_get_filelist $1`
1327 lib_files=`for f in $all_files; do \
1331 done | sed -e 's,^lib/,,'`
1332 # Remove $already_mentioned_files from $lib_files.
1333 echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
1334 extra_files=`for f in $already_mentioned_files; do echo $f; done \
1335 | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
1336 if test -n "$extra_files"; then
1337 echo "EXTRA_DIST +=" $extra_files
1340 # Synthesize also an EXTRA_lib_SOURCES augmentation.
1341 # This is necessary so that automake can generate the right list of
1343 # A possible approach would be to use autom4te --trace of the redefined
1344 # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
1345 # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
1346 # inside autoconf's built-in macros are not missed).
1347 # But it's simpler and more robust to do it here, based on the file list.
1348 # If some .c file exists and is not used with AC_LIBOBJ - for example,
1349 # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
1350 # automake will generate a useless dependency; this is harmless.
1352 relocatable-prog-wrapper) ;;
1354 sed_extract_c_files='/\.c$/p'
1355 extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
1356 if test -n "$extra_files"; then
1357 echo "EXTRA_lib_SOURCES +=" $extra_files
1362 # Synthesize an EXTRA_DIST augmentation also for the files in build-aux/.
1363 buildaux_files=`for f in $all_files; do \
1365 build-aux/*) echo $f ;; \
1367 done | sed -e 's,^build-aux/,,'`
1368 if test -n "$buildaux_files"; then
1369 sed_prepend_auxdir='s,^,$(top_srcdir)/'"$auxdir"'/,'
1370 echo "EXTRA_DIST += "`echo "$buildaux_files" | sed -e "$sed_prepend_auxdir"`
1377 # func_get_include_directive module
1379 # - local_gnulib_dir from --local-dir
1380 func_get_include_directive ()
1382 func_lookup_file "modules/$1"
1383 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
1384 sed -e 's/^\(["<]\)/#include \1/'
1387 # func_get_link_directive module
1389 # - local_gnulib_dir from --local-dir
1390 func_get_link_directive ()
1392 func_lookup_file "modules/$1"
1393 sed -n -e "/^Link$sed_extract_prog" < "$lookedup_file"
1396 # func_get_license module
1398 # - local_gnulib_dir from --local-dir
1401 func_lookup_file "modules/$1"
1402 { sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1403 # The default is GPL.
1405 } | sed -e 's,^ *$,,' | sed -e 1q
1408 # func_get_maintainer module
1410 # - local_gnulib_dir from --local-dir
1411 func_get_maintainer ()
1413 func_lookup_file "modules/$1"
1414 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1417 # func_get_tests_module module
1419 # - local_gnulib_dir from --local-dir
1420 func_get_tests_module ()
1422 # The naming convention for tests modules is hardwired: ${module}-tests.
1423 if test -f "$gnulib_dir/modules/$1"-tests \
1424 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1425 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1430 # func_acceptable module
1431 # tests whether a module is acceptable.
1433 # - avoidlist list of modules to avoid
1436 for avoid in $avoidlist; do
1437 if test "$avoid" = "$1"; then
1444 # func_modules_transitive_closure
1446 # - local_gnulib_dir from --local-dir
1447 # - modules list of specified modules
1448 # - inctests true if tests should be included, blank otherwise
1449 # - avoidlist list of modules to avoid
1450 # - tmp pathname of a temporary directory
1452 # - modules list of modules, including dependencies
1453 func_modules_transitive_closure ()
1455 # In order to process every module only once (for speed), process an "input
1456 # list" of modules, producing an "output list" of modules. During each round,
1457 # more modules can be queued in the input list. Once a module on the input
1458 # list has been processed, it is added to the "handled list", so we can avoid
1459 # to process it again.
1461 inmodules="$modules"
1463 while test -n "$inmodules"; do
1464 inmodules_this_round="$inmodules"
1465 inmodules= # Accumulator, queue for next round
1466 for module in $inmodules_this_round; do
1468 if test -n "$module"; then
1469 if func_acceptable $module; then
1470 func_append outmodules " $module"
1471 deps=`func_get_dependencies $module`
1472 # Duplicate dependencies are harmless, but Jim wants a warning.
1473 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1474 if test -n "$duplicated_deps"; then
1475 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1477 func_append inmodules " $deps"
1478 if test -n "$inctests"; then
1479 testsmodule=`func_get_tests_module $module`
1480 if test -n "$testsmodule"; then
1481 func_append inmodules " $testsmodule"
1487 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1488 # Remove $handledmodules from $inmodules.
1489 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1490 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1492 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1493 rm -f "$tmp"/queued-modules
1496 # func_modules_add_dummy
1498 # - local_gnulib_dir from --local-dir
1499 # - modules list of modules, including dependencies
1501 # - modules list of modules, including 'dummy' if needed
1502 func_modules_add_dummy ()
1505 sed_remove_backslash_newline=':a
1512 for module in $modules; do
1513 func_verify_nontests_module
1514 if test -n "$module"; then
1515 # Extract the value of "lib_SOURCES += ...".
1516 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1517 # Ignore .h files since they are not compiled.
1520 *) have_lib_SOURCES=yes ;;
1525 # Add the dummy module, to make sure the library will be non-empty.
1526 if test -z "$have_lib_SOURCES"; then
1527 if func_acceptable "dummy"; then
1528 func_append modules " dummy"
1533 # func_modules_notice
1535 # - local_gnulib_dir from --local-dir
1536 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1537 # - modules list of modules, including dependencies
1538 func_modules_notice ()
1540 if test $verbose -ge -1; then
1541 for module in $modules; do
1543 if test -n "$module"; then
1544 msg=`func_get_notice $module`
1545 if test -n "$msg"; then
1546 echo "Notice from module $module:"
1547 echo "$msg" | sed -e 's/^/ /'
1554 # func_modules_to_filelist
1556 # - local_gnulib_dir from --local-dir
1557 # - modules list of modules, including dependencies
1559 # - files list of files
1560 func_modules_to_filelist ()
1563 for module in $modules; do
1565 if test -n "$module"; then
1566 fs=`func_get_filelist $module`
1567 func_append files " $fs"
1570 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1573 # func_execute_command command [args...]
1574 # Executes a command.
1575 # Uses also the variables
1576 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
1577 func_execute_command ()
1579 if test $verbose -ge 0; then
1583 # Commands like automake produce output to stderr even when the succeed.
1584 # Turn this output off if the command succeeds.
1585 "$@" > "$tmp"/cmdout 2>&1
1587 if test $cmdret = 0; then
1591 cat "$tmp"/cmdout 1>&2
1598 # func_emit_lib_Makefile_am
1599 # emits the contents of library makefile to standard output.
1601 # - local_gnulib_dir from --local-dir
1602 # - modules list of modules, including dependencies
1603 # - libname library name
1604 # - pobase directory relative to destdir where to place *.po files
1605 # - auxdir directory relative to destdir where to place build aux files
1606 # - makefile_name from --makefile-name
1607 # - libtool true if libtool will be used, false or blank otherwise
1608 # - macro_prefix prefix of gl_LIBOBJS macros to use
1609 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1610 # - actioncmd (optional) command that will reproduce this invocation
1611 # - for_test true if creating a package for testing, false otherwise
1613 # - uses_subdirs nonempty if object files in subdirs exist
1614 func_emit_lib_Makefile_am ()
1616 # When creating an includable Makefile.am snippet, augment variables with
1617 # += instead of assigning them.
1618 if test -n "$makefile_name"; then
1623 if test "$libtool" = true; then
1626 sed_eliminate_LDFLAGS=
1630 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1633 # When creating a package for testing: Attempt to provoke failures,
1634 # especially link errors, already during "make" rather than during
1635 # "make check", because "make check" is not possible in a cross-compiling
1636 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1637 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1639 sed_transform_check_PROGRAMS=
1641 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1642 echo "## Process this file with automake to produce Makefile.in."
1643 func_emit_copyright_notice
1644 if test -n "$actioncmd"; then
1645 echo "# Reproduce by: $actioncmd"
1650 for module in $modules; do
1651 func_verify_nontests_module
1652 if test -n "$module"; then
1654 func_get_automake_snippet "$module" |
1655 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1656 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1657 -e "$sed_eliminate_LDFLAGS" \
1658 -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' \
1659 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1660 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1661 -e "$sed_transform_check_PROGRAMS"
1662 if test "$module" = 'alloca'; then
1663 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1664 echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1667 # Skip the contents if its entirely empty.
1668 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1669 echo "## begin gnulib module $module"
1672 echo "## end gnulib module $module"
1676 # Test whether there are some source files in subdirectories.
1677 for f in `func_get_filelist "$module"`; do
1679 lib/*/*.c) uses_subdirs=yes ;;
1685 if test -z "$makefile_name"; then
1686 # If there are source files in subdirectories, prevent collision of the
1687 # object files (example: hash.c and libxml/hash.c).
1689 if test -n "$uses_subdirs"; then
1690 subdir_options=' subdir-objects'
1692 echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1695 if test -z "$makefile_name"; then
1696 echo "noinst_HEADERS ="
1697 echo "noinst_LIBRARIES ="
1698 echo "noinst_LTLIBRARIES ="
1699 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1700 # if you specify pkgdata_DATA to empty. This is a workaround.
1701 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1702 echo "pkgdata_DATA ="
1705 echo "BUILT_SOURCES ="
1708 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1709 if test -z "$makefile_name"; then
1710 echo "MOSTLYCLEANDIRS ="
1712 echo "DISTCLEANFILES ="
1713 echo "MAINTAINERCLEANFILES ="
1715 echo "AM_CPPFLAGS ="
1718 if LC_ALL=C grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1719 # One of the snippets already specifies an installation location for the
1720 # library. Don't confuse automake by saying it should not be installed.
1723 # By default, the generated library should not be installed.
1724 echo "noinst_${perhapsLT}LIBRARIES += $libname.$libext"
1727 echo "${libname}_${libext}_SOURCES ="
1728 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1729 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1730 echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1731 echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1732 echo "EXTRA_${libname}_${libext}_SOURCES ="
1733 if test "$libtool" = true; then
1734 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1737 if test -n "$pobase"; then
1738 echo "AM_CPPFLAGS += -DDEFAULT_TEXT_DOMAIN=\\\"${po_domain}-gnulib\\\""
1741 cat allsnippets.tmp \
1742 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1744 echo "mostlyclean-local: mostlyclean-generic"
1745 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1746 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1747 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1751 rm -f allsnippets.tmp
1754 # func_emit_po_Makevars
1755 # emits the contents of po/ makefile parametrization to standard output.
1757 # - local_gnulib_dir from --local-dir
1758 # - sourcebase directory relative to destdir where to place source code
1759 # - pobase directory relative to destdir where to place *.po files
1760 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
1761 func_emit_po_Makevars ()
1763 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1764 func_emit_copyright_notice
1766 echo "# Usually the message domain is the same as the package name."
1767 echo "# But here it has a '-gnulib' suffix."
1768 echo "DOMAIN = ${po_domain}-gnulib"
1770 echo "# These two variables depend on the location of this directory."
1771 echo "subdir = ${pobase}"
1772 echo "top_builddir = "`echo "$pobase" | sed -e 's,//*,/,g' -e 's,[^/][^/]*,..,g'`
1775 # These options get passed to xgettext.
1776 XGETTEXT_OPTIONS = \
1777 --keyword=_ --flag=_:1:pass-c-format \
1778 --keyword=N_ --flag=N_:1:pass-c-format \
1779 --keyword='proper_name:1,"This is a proper name. See the gettext manual, section Names."' \
1780 --keyword='proper_name_utf8:1,"This is a proper name. See the gettext manual, section Names."' \
1781 --flag=error:3:c-format --flag=error_at_line:5:c-format
1783 # This is the copyright holder that gets inserted into the header of the
1784 # $(DOMAIN).pot file. gnulib is copyrighted by the FSF.
1785 COPYRIGHT_HOLDER = Free Software Foundation, Inc.
1787 # This is the email address or URL to which the translators shall report
1788 # bugs in the untranslated strings:
1789 # - Strings which are not entire sentences, see the maintainer guidelines
1790 # in the GNU gettext documentation, section 'Preparing Strings'.
1791 # - Strings which use unclear terms or require additional context to be
1793 # - Strings which make invalid assumptions about notation of date, time or
1795 # - Pluralisation problems.
1796 # - Incorrect English spelling.
1797 # - Incorrect formatting.
1798 # It can be your email address, or a mailing list address where translators
1799 # can write to without being subscribed, or the URL of a web page through
1800 # which the translators can contact you.
1801 MSGID_BUGS_ADDRESS = bug-gnulib@gnu.org
1803 # This is the list of locale categories, beyond LC_MESSAGES, for which the
1804 # message catalogs shall be used. It is usually empty.
1805 EXTRA_LOCALE_CATEGORIES =
1807 # This tells whether the $(DOMAIN).pot file contains messages with an 'msgctxt'
1808 # context. Possible values are "yes" and "no". Set this to yes if the
1809 # package uses functions taking also a message context, like pgettext(), or
1810 # if in $(XGETTEXT_OPTIONS) you define keywords with a context argument.
1815 # func_emit_po_POTFILES_in
1816 # emits the file list to be passed to xgettext to standard output.
1818 # - local_gnulib_dir from --local-dir
1819 # - sourcebase directory relative to destdir where to place source code
1820 # - files list of new files
1821 func_emit_po_POTFILES_in ()
1823 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1824 func_emit_copyright_notice
1826 echo "# List of files which contain translatable strings."
1827 echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
1830 # func_emit_tests_Makefile_am
1831 # emits the contents of tests makefile to standard output.
1833 # - local_gnulib_dir from --local-dir
1834 # - modules list of modules, including dependencies
1835 # - libname library name
1836 # - auxdir directory relative to destdir where to place build aux files
1837 # - makefile_name from --makefile-name
1838 # - libtool true if libtool will be used, false or blank otherwise
1839 # - sourcebase relative directory containing lib source code
1840 # - m4base relative directory containing autoconf macros
1841 # - testsbase relative directory containing unit test code
1842 # - macro_prefix prefix of gl_LIBOBJS macros to use
1843 # - for_test true if creating a package for testing, false otherwise
1844 # - use_libtests true if a libtests.a should be built, false otherwise
1846 # - uses_subdirs nonempty if object files in subdirs exist
1847 func_emit_tests_Makefile_am ()
1849 if test "$libtool" = true; then
1851 sed_eliminate_LDFLAGS=
1854 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1857 # When creating a package for testing: Attempt to provoke failures,
1858 # especially link errors, already during "make" rather than during
1859 # "make check", because "make check" is not possible in a cross-compiling
1860 # situation. Turn check_PROGRAMS into noinst_PROGRAMS.
1861 sed_transform_check_PROGRAMS='s,check_PROGRAMS,noinst_PROGRAMS,g'
1863 sed_transform_check_PROGRAMS=
1865 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1866 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1867 echo "## Process this file with automake to produce Makefile.in."
1868 func_emit_copyright_notice
1872 for module in $modules; do
1874 func_verify_tests_module
1878 if test -n "$module"; then
1880 func_get_automake_snippet "$module" |
1881 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1882 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' \
1883 -e "$sed_eliminate_LDFLAGS" \
1884 -e 's,lib_\([A-Z][A-Z]*\),libtests_a_\1,g' \
1885 -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1886 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g' \
1887 -e "$sed_transform_check_PROGRAMS"
1888 if $use_libtests && test "$module" = 'alloca'; then
1889 echo "libtests_a_LIBADD += @${perhapsLT}ALLOCA@"
1890 echo "libtests_a_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1893 # Skip the contents if its entirely empty.
1894 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1895 echo "## begin gnulib module $module"
1898 echo "## end gnulib module $module"
1902 # Test whether there are some source files in subdirectories.
1903 for f in `func_get_filelist "$module"`; do
1905 lib/*/*.c | tests/*/*.c) uses_subdirs=yes ;;
1911 # Generate dependencies here, since it eases the debugging of test failures.
1912 # If there are source files in subdirectories, prevent collision of the
1913 # object files (example: hash.c and libxml/hash.c).
1915 if test -n "$uses_subdirs"; then
1916 subdir_options=' subdir-objects'
1918 echo "AUTOMAKE_OPTIONS = 1.5 foreign${subdir_options}"
1921 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1924 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1925 # variable is needed to avoid an error from automake:
1926 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1929 echo "TESTS_ENVIRONMENT ="
1930 echo "noinst_PROGRAMS ="
1931 if ! $for_test; then
1932 echo "check_PROGRAMS ="
1934 echo "noinst_HEADERS ="
1935 echo "noinst_LIBRARIES ="
1936 if $use_libtests; then
1938 echo "noinst_LIBRARIES += libtests.a"
1940 echo "check_LIBRARIES = libtests.a"
1943 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1944 # if you specify pkgdata_DATA to empty. This is a workaround.
1945 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1946 echo "pkgdata_DATA ="
1949 echo "BUILT_SOURCES ="
1951 echo "MOSTLYCLEANFILES = core *.stackdump"
1952 echo "MOSTLYCLEANDIRS ="
1954 echo "DISTCLEANFILES ="
1955 echo "MAINTAINERCLEANFILES ="
1957 echo "AM_CPPFLAGS = \\"
1958 echo " -I. -I\$(srcdir) \\"
1959 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1960 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1962 local_ldadd_before=''
1963 local_ldadd_after=''
1964 if $use_libtests; then
1965 # All test programs need to be linked with libtests.a.
1966 # It needs to be passed to the linker before ${libname}.${libext}, since
1967 # the tests-related modules depend on the main modules.
1968 # It also needs to be passed to the linker after ${libname}.${libext}
1969 # because the latter might contain incomplete modules (such as the 'error'
1970 # module whose dependency to 'progname' is voluntarily omitted).
1971 # The LIBTESTS_LIBDEPS can be passed to the linker once or twice, it does
1973 local_ldadd_before=' libtests.a'
1974 local_ldadd_after=' libtests.a $(LIBTESTS_LIBDEPS)'
1976 echo "LDADD =${local_ldadd_before} ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}${local_ldadd_after}"
1978 if $use_libtests; then
1979 echo "libtests_a_SOURCES ="
1980 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1981 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1982 echo "libtests_a_LIBADD = \$(${macro_prefix}tests_LIBOBJS)"
1983 echo "libtests_a_DEPENDENCIES = \$(${macro_prefix}tests_LIBOBJS)"
1984 echo "EXTRA_libtests_a_SOURCES ="
1985 # The circular dependency in LDADD requires this.
1986 echo "AM_LIBTOOLFLAGS = --preserve-dup-deps"
1989 cat allsnippets.tmp \
1990 | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
1991 echo "# Clean up after Solaris cc."
1993 echo " rm -rf SunWS_cache"
1995 echo "mostlyclean-local: mostlyclean-generic"
1996 echo " @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1997 echo " if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1998 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
2002 rm -f allsnippets.tmp
2005 # func_emit_initmacro_start macro_prefix
2006 # emits the first few statements of the gl_INIT macro to standard output.
2007 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2008 func_emit_initmacro_start ()
2010 macro_prefix_arg="$1"
2011 # Overriding AC_LIBOBJ and AC_REPLACE_FUNCS has the effect of storing
2012 # platform-dependent object files in ${macro_prefix_arg}_LIBOBJS instead of
2013 # LIBOBJS. The purpose is to allow several gnulib instantiations under
2014 # a single configure.ac file. (AC_CONFIG_LIBOBJ_DIR does not allow this
2016 # Furthermore it avoids an automake error like this when a Makefile.am
2017 # that uses pieces of gnulib also uses $(LIBOBJ):
2018 # automatically discovered file `error.c' should not be explicitly mentioned
2019 echo " m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix_arg}_LIBOBJ]))"
2020 echo " m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix_arg}_REPLACE_FUNCS]))"
2021 # Overriding AC_LIBSOURCES has the same purpose of avoiding the automake
2022 # error when a Makefile.am that uses pieces of gnulib also uses $(LIBOBJ):
2023 # automatically discovered file `error.c' should not be explicitly mentioned
2024 # We let automake know about the files to be distributed through the
2025 # EXTRA_lib_SOURCES variable.
2026 echo " m4_pushdef([AC_LIBSOURCES], m4_defn([${macro_prefix_arg}_LIBSOURCES]))"
2029 # func_emit_initmacro_end macro_prefix
2030 # emits the last few statements of the gl_INIT macro to standard output.
2031 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2032 func_emit_initmacro_end ()
2034 macro_prefix_arg="$1"
2035 echo " m4_popdef([AC_LIBSOURCES])"
2036 echo " m4_popdef([AC_REPLACE_FUNCS])"
2037 echo " m4_popdef([AC_LIBOBJ])"
2038 echo " AC_CONFIG_COMMANDS_PRE(["
2039 echo " ${macro_prefix_arg}_libobjs="
2040 echo " ${macro_prefix_arg}_ltlibobjs="
2041 echo " if test -n \"\$${macro_prefix_arg}_LIBOBJS\"; then"
2042 echo " # Remove the extension."
2043 echo " sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
2044 echo " for i in \`for i in \$${macro_prefix_arg}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
2045 echo " ${macro_prefix_arg}_libobjs=\"\$${macro_prefix_arg}_libobjs \$i.\$ac_objext\""
2046 echo " ${macro_prefix_arg}_ltlibobjs=\"\$${macro_prefix_arg}_ltlibobjs \$i.lo\""
2049 echo " AC_SUBST([${macro_prefix_arg}_LIBOBJS], [\$${macro_prefix_arg}_libobjs])"
2050 echo " AC_SUBST([${macro_prefix_arg}_LTLIBOBJS], [\$${macro_prefix_arg}_ltlibobjs])"
2054 # func_emit_initmacro_done macro_prefix sourcebase
2055 # emits a few statements after the gl_INIT macro to standard output.
2056 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2057 # - sourcebase directory relative to destdir where to place source code
2058 func_emit_initmacro_done ()
2060 macro_prefix_arg="$1"
2063 echo "# Like AC_LIBOBJ, except that the module name goes"
2064 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2065 echo "AC_DEFUN([${macro_prefix_arg}_LIBOBJ], ["
2066 echo " AS_LITERAL_IF([\$1], [${macro_prefix_arg}_LIBSOURCES([\$1.c])])dnl"
2067 echo " ${macro_prefix_arg}_LIBOBJS=\"\$${macro_prefix_arg}_LIBOBJS \$1.\$ac_objext\""
2070 echo "# m4_foreach_w is provided by autoconf-2.59c and later."
2071 echo "# This definition is to accommodate developers using versions"
2072 echo "# of autoconf older than that."
2073 echo "m4_ifndef([m4_foreach_w],"
2074 echo " [m4_define([m4_foreach_w],"
2075 echo " [m4_foreach([\$1], m4_split(m4_normalize([\$2]), [ ]), [\$3])])])"
2077 echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
2078 echo "# into ${macro_prefix_arg}_LIBOBJS instead of into LIBOBJS."
2079 echo "AC_DEFUN([${macro_prefix_arg}_REPLACE_FUNCS], ["
2080 echo " m4_foreach_w([gl_NAME], [\$1], [AC_LIBSOURCES(gl_NAME[.c])])dnl"
2081 echo " AC_CHECK_FUNCS([\$1], , [${macro_prefix_arg}_LIBOBJ(\$ac_func)])"
2084 echo "# Like AC_LIBSOURCES, except the directory where the source file is"
2085 echo "# expected is derived from the gnulib-tool parametrization,"
2086 echo "# and alloca is special cased (for the alloca-opt module)."
2087 echo "# We could also entirely rely on EXTRA_lib..._SOURCES."
2088 echo "AC_DEFUN([${macro_prefix_arg}_LIBSOURCES], ["
2089 echo " m4_foreach([_gl_NAME], [\$1], ["
2090 echo " m4_if(_gl_NAME, [alloca.c], [], ["
2091 echo " m4_syscmd([test -r $sourcebase_arg/]_gl_NAME[ || test ! -d $sourcebase_arg])dnl"
2092 echo " m4_if(m4_sysval, [0], [],"
2093 echo " [AC_FATAL([missing $sourcebase_arg/]_gl_NAME)])"
2099 # func_import modules
2100 # Uses also the variables
2101 # - destdir target directory
2102 # - local_gnulib_dir from --local-dir
2103 # - verbose integer, default 0, inc/decremented by --verbose/--quiet
2104 # - libname library name
2105 # - sourcebase directory relative to destdir where to place source code
2106 # - m4base directory relative to destdir where to place *.m4 macros
2107 # - pobase directory relative to destdir where to place *.po files
2108 # - docbase directory relative to destdir where to place doc files
2109 # - testsbase directory relative to destdir where to place unit test code
2110 # - auxdir directory relative to destdir where to place build aux files
2111 # - inctests true if --with-tests was given, blank otherwise
2112 # - avoidlist list of modules to avoid, from --avoid
2113 # - lgpl yes or a number if library's license shall be LGPL,
2115 # - makefile_name from --makefile-name
2116 # - libtool true if --libtool was given, false if --no-libtool was
2117 # given, blank otherwise
2118 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
2119 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
2120 # - po_domain prefix of i18n domain to use (without -gnulib suffix)
2121 # - autoconf_minversion minimum supported autoconf version
2122 # - doit : if actions shall be executed, false if only to be printed
2123 # - symbolic true if files should be symlinked, copied otherwise
2124 # - lsymbolic true if files from local_gnulib_dir should be symlinked,
2126 # - do_copyrights true if copyright notices in files should be replaced,
2130 # Get the cached settings.
2131 cached_local_gnulib_dir=
2132 cached_specified_modules=
2142 cached_makefile_name=
2144 cached_macro_prefix=
2147 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2148 cached_libtool=false
2154 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
2157 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
2160 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
2163 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
2166 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
2169 s,^.*gl_PO_BASE([[ ]*\([^])]*\).*$,cached_pobase="\1",p
2172 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
2175 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
2178 s,^.*$,cached_inctests=true,p
2181 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
2184 s,^.*gl_LGPL([[ ]*\([^])]*\).*$,cached_lgpl="\1",p
2187 s,^.*$,cached_lgpl=yes,p
2189 /gl_MAKEFILE_NAME(/ {
2190 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
2193 s,^.*$,cached_libtool=true,p
2195 /gl_MACRO_PREFIX(/ {
2196 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
2199 s,^.*gl_PO_DOMAIN([[ ]*\([^])]*\).*$,cached_po_domain="\1",p
2201 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
2202 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2207 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
2208 s,^.*$,cached_files=",p
2220 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
2224 # Merge the cached settings with the specified ones.
2225 # The m4base must be the same as expected from the pathname.
2226 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
2227 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
2229 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
2230 # is relative to $destdir, whereas the one we use is relative to . or absolute.
2231 if test -z "$local_gnulib_dir"; then
2232 if test -n "$cached_local_gnulib_dir"; then
2235 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2237 case "$cached_local_gnulib_dir" in
2239 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
2241 func_relconcat "$destdir" "$cached_local_gnulib_dir"
2242 local_gnulib_dir="$relconcat" ;;
2247 # Append the cached and the specified module names. So that
2248 # "gnulib-tool --import foo" means to add the module foo.
2249 specified_modules="$cached_specified_modules $1"
2250 # Append the cached and the specified avoidlist. This is probably better
2251 # than dropping the cached one when --avoid is specified at least once.
2252 avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
2253 avoidlist=`echo $avoidlist`
2255 # The sourcebase defaults to the cached one.
2256 if test -z "$sourcebase"; then
2257 sourcebase="$cached_sourcebase"
2258 if test -z "$sourcebase"; then
2259 func_fatal_error "missing --source-base option"
2262 # The pobase defaults to the cached one.
2263 if test -z "$pobase"; then
2264 pobase="$cached_pobase"
2266 # The docbase defaults to the cached one.
2267 if test -z "$docbase"; then
2268 docbase="$cached_docbase"
2269 if test -z "$docbase"; then
2270 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."
2273 # The testsbase defaults to the cached one.
2274 if test -z "$testsbase"; then
2275 testsbase="$cached_testsbase"
2276 if test -z "$testsbase"; then
2277 func_fatal_error "missing --tests-base option"
2280 # Require the tests if specified either way.
2281 if test -z "$inctests"; then
2282 inctests="$cached_inctests"
2284 # The libname defaults to the cached one.
2285 if test -z "$supplied_libname"; then
2286 libname="$cached_libname"
2287 if test -z "$libname"; then
2288 func_fatal_error "missing --lib option"
2291 # Require LGPL if specified either way.
2292 if test -z "$lgpl"; then
2295 # The makefile_name defaults to the cached one.
2296 if test -z "$makefile_name"; then
2297 makefile_name="$cached_makefile_name"
2299 # Use libtool if specified either way, or if guessed.
2300 if test -z "$libtool"; then
2301 if test -n "$cached_m4base"; then
2302 libtool="$cached_libtool"
2304 libtool="$guessed_libtool"
2307 # The macro_prefix defaults to the cached one.
2308 if test -z "$macro_prefix"; then
2309 macro_prefix="$cached_macro_prefix"
2310 if test -z "$macro_prefix"; then
2311 func_fatal_error "missing --macro-prefix option"
2314 # The po_domain defaults to the cached one.
2315 if test -z "$po_domain"; then
2316 po_domain="$cached_po_domain"
2319 # Canonicalize the list of specified modules.
2320 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
2322 # Determine final module list.
2323 modules="$specified_modules"
2324 func_modules_transitive_closure
2325 if test $verbose -ge 0; then
2326 echo "Module list with included dependencies:"
2327 echo "$modules" | sed -e 's/^/ /'
2329 final_modules="$modules"
2331 # Determine main module list and tests-related module list separately.
2332 # The main module list is the transitive closure of the specified modules,
2333 # ignoring tests modules. Its lib/* sources go into $sourcebase/. If --lgpl
2334 # is specified, it will consist only of LGPLed source.
2335 # The tests-related module list is the transitive closure of the specified
2336 # modules, including tests modules, minus the main module list. Its lib/*
2337 # sources (brought in through dependencies of *-tests modules) go into
2338 # $testsbase/. It may contain GPLed source, even if --lgpl is specified.
2339 # Determine main module list.
2340 saved_inctests="$inctests"
2342 modules="$specified_modules"
2343 func_modules_transitive_closure
2344 main_modules="$modules"
2345 inctests="$saved_inctests"
2346 if test $verbose -ge 1; then
2347 echo "Main module list:"
2348 echo "$main_modules" | sed -e 's/^/ /'
2350 # Determine tests-related module list.
2351 echo "$final_modules" | LC_ALL=C sort -u > "$tmp"/final-modules
2352 testsrelated_modules=`echo "$main_modules" | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/final-modules`
2353 if test $verbose -ge 1; then
2354 echo "Tests-related module list:"
2355 echo "$testsrelated_modules" | sed -e 's/^/ /'
2358 # Add the dummy module to the main module list if needed.
2359 modules="$main_modules"
2360 func_modules_add_dummy
2361 main_modules="$modules"
2363 # Determine whether a $testsbase/libtests.a is needed.
2365 for module in $testsrelated_modules; do
2366 func_verify_nontests_module
2367 if test -n "$module"; then
2368 all_files=`func_get_filelist $module`
2369 lib_files=`for f in $all_files; do \
2373 done | sed -e 's,^lib/,,'`
2374 if test -n "$lib_files"; then
2381 # Add the dummy module to the tests-related module list if needed.
2382 if $use_libtests; then
2383 modules="$testsrelated_modules"
2384 func_modules_add_dummy
2385 testsrelated_modules="$modules"
2388 # If --lgpl, verify that the licenses of modules are compatible.
2389 if test -n "$lgpl"; then
2390 for module in $main_modules; do
2391 license=`func_get_license $module`
2393 'GPLed build tool') ;;
2394 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
2400 *) func_fatal_error "incompatible license on module $module: $license" ;;
2406 *) func_fatal_error "incompatible license on module $module: $license" ;;
2409 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2416 # Show banner notice of every module.
2417 modules="$main_modules"
2420 # Determine script to apply to imported library files.
2421 sed_transform_lib_file=
2422 for module in $main_modules; do
2423 if test $module = config-h; then
2424 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
2425 sed_transform_lib_file=$sed_transform_lib_file'
2426 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
2431 sed_transform_main_lib_file="$sed_transform_lib_file"
2432 if test -n "$do_copyrights"; then
2433 if test -n "$lgpl"; then
2437 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2438 s/GNU General/GNU Lesser General/g
2442 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2443 s/GNU General/GNU Lesser General/g
2444 s/version [23]\([ ,]\)/version 2.1\1/g
2447 *) func_fatal_error "invalid value lgpl=$lgpl" ;;
2451 sed_transform_main_lib_file=$sed_transform_main_lib_file'
2452 s/GNU Lesser General/GNU General/g
2453 s/GNU Library General/GNU General/g
2454 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2459 # Determine script to apply to library files that go into $testsbase/.
2460 sed_transform_testsrelated_lib_file="$sed_transform_lib_file"
2461 if test -n "$do_copyrights"; then
2463 sed_transform_testsrelated_lib_file=$sed_transform_testsrelated_lib_file'
2464 s/GNU Lesser General/GNU General/g
2465 s/GNU Library General/GNU General/g
2466 s/version \(2\|2\.1\)\([ ,]\)/version 3\2/g
2470 # Determine the final file lists.
2471 # They must be computed separately, because files in lib/* go into
2472 # $sourcebase/ if they are in the main file list but into $testsbase/
2473 # if they are in the tests-related file list. Furthermore lib/dummy.c
2475 # Determine final main file list.
2476 modules="$main_modules"
2477 func_modules_to_filelist
2479 # Determine final tests-related file list.
2480 modules="$testsrelated_modules"
2481 func_modules_to_filelist
2482 testsrelated_files=`echo "$files" | sed -e 's,^lib/,tests=lib/,'`
2483 # Merge both file lists.
2484 sed_remove_empty_lines='/^$/d'
2485 files=`{ echo "$main_files"; echo "$testsrelated_files"; } | sed -e "$sed_remove_empty_lines" | LC_ALL=C sort -u`
2486 if test $verbose -ge 0; then
2488 sed_prettyprint_files='s,^tests=lib/\(.*\)$,lib/\1 -> tests/\1,'
2489 echo "$files" | sed -e "$sed_prettyprint_files" -e 's/^/ /'
2493 || func_fatal_error "refusing to do nothing"
2495 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
2496 new_files="$files m4/gnulib-tool.m4"
2497 old_files="$cached_files"
2498 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
2499 func_append old_files " m4/gnulib-tool.m4"
2502 sed_rewrite_old_files="\
2503 s,^build-aux/,$auxdir/,
2504 s,^doc/,$cached_docbase/,
2505 s,^lib/,$cached_sourcebase/,
2506 s,^m4/,$cached_m4base/,
2507 s,^tests/,$cached_testsbase/,
2508 s,^tests=lib/,$cached_testsbase/,"
2509 sed_rewrite_new_files="\
2510 s,^build-aux/,$auxdir/,
2512 s,^lib/,$sourcebase/,
2514 s,^tests/,$testsbase/,
2515 s,^tests=lib/,$testsbase/,"
2517 # Create directories.
2518 { echo "$sourcebase"
2520 if test -n "$pobase"; then
2523 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
2524 if test -n "$docfiles"; then
2527 if test -n "$inctests"; then
2531 for f in $files; do echo $f; done \
2532 | sed -e "$sed_rewrite_new_files" \
2533 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2536 { # Rearrange file descriptors. Needed because "while ... done < ..."
2537 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2538 exec 5<&0 < "$tmp"/dirs
2540 if test ! -d "$destdir/$d"; then
2542 echo "Creating directory $destdir/$d"
2543 mkdir -p "$destdir/$d" || func_fatal_error "failed"
2545 echo "Create directory $destdir/$d"
2552 # func_dest_tmpfilename file
2553 # determines the name of a temporary file (file is relative to destdir).
2555 # - tmpfile absolute filename of the temporary file
2556 func_dest_tmpfilename ()
2559 # Put the new contents of $file in a file in the same directory (needed
2560 # to guarantee that an 'mv' to "$destdir/$file" works).
2561 tmpfile="$destdir/$1.tmp"
2563 # Put the new contents of $file in a file in a temporary directory
2564 # (because the directory of "$file" might not exist).
2565 tmpfile="$tmp"/`basename "$1"`.tmp
2569 # Copy files or make symbolic links. Remove obsolete files.
2573 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2574 # representing the files according to the last gnulib-tool invocation.
2575 for f in $old_files; do echo $f; done \
2576 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
2579 # Construct a table with 2 columns: rewritten-file-name original-file-name,
2580 # representing the files after this gnulib-tool invocation.
2581 for f in $new_files; do echo $f; done \
2582 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
2585 # First the files that are in old-files, but not in new-files:
2586 sed_take_first_column='s,'"$delimiter"'.*,,'
2587 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
2588 # Remove the file. Do nothing if the user already removed it.
2589 if test -f "$destdir/$g" || test -h "$destdir/$g"; then
2591 echo "Removing file $g (backup in ${g}~)"
2592 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2594 echo "Remove file $g (backup in ${g}~)"
2596 func_append removed_files "$g$nl"
2599 # func_add_or_update handles a file that ought to be present afterwards.
2601 # - f the original file name
2602 # - g the rewritten file name
2603 # - already_present nonempty if the file already exists, empty otherwise
2604 func_add_or_update ()
2608 tests=lib/*) f=`echo "$f" | sed -e 's,^tests=lib/,lib/,'` ;;
2610 func_dest_tmpfilename "$g"
2611 func_lookup_file "$f"
2612 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
2613 if test -n "$sed_transform_main_lib_file"; then
2616 sed -e "$sed_transform_main_lib_file" \
2617 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2621 if test -n "$sed_transform_testsrelated_lib_file"; then
2624 sed -e "$sed_transform_testsrelated_lib_file" \
2625 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
2629 if test -f "$destdir/$g"; then
2630 # The file already exists.
2631 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
2632 : # The file has not changed.
2636 if test -n "$already_present"; then
2637 echo "Updating file $g (backup in ${g}~)"
2639 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
2641 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
2642 if { test -n "$symbolic" \
2643 || { test -n "$lsymbolic" \
2644 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2645 && test -z "$lookedup_tmp" \
2646 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2647 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2649 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2652 if test -n "$already_present"; then
2653 echo "Update file $g (backup in ${g}~)"
2655 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
2661 # Don't protest if the file should be there but isn't: it happens
2662 # frequently that developers don't put autogenerated files into CVS.
2664 echo "Copying file $g"
2665 if { test -n "$symbolic" \
2666 || { test -n "$lsymbolic" \
2667 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; } \
2668 && test -z "$lookedup_tmp" \
2669 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
2670 func_ln_if_changed "$lookedup_file" "$destdir/$g"
2672 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
2677 func_append added_files "$g$nl"
2681 # Then the files that are in new-files, but not in old-files:
2682 sed_take_last_column='s,^.*'"$delimiter"',,'
2684 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
2685 | sed -e "$sed_take_last_column" \
2686 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
2687 { # Rearrange file descriptors. Needed because "while ... done < ..."
2688 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2689 exec 5<&0 < "$tmp"/added-files
2695 # Then the files that are in new-files and in old-files:
2696 already_present=true
2697 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
2698 | sed -e "$sed_take_last_column" \
2699 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
2700 { # Rearrange file descriptors. Needed because "while ... done < ..."
2701 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2702 exec 5<&0 < "$tmp"/kept-files
2709 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
2710 actioncmd="gnulib-tool --import"
2711 func_append actioncmd " --dir=$destdir"
2712 if test -n "$local_gnulib_dir"; then
2713 func_append actioncmd " --local-dir=$local_gnulib_dir"
2715 func_append actioncmd " --lib=$libname"
2716 func_append actioncmd " --source-base=$sourcebase"
2717 func_append actioncmd " --m4-base=$m4base"
2718 if test -n "$pobase"; then
2719 func_append actioncmd " --po-base=$pobase"
2721 func_append actioncmd " --doc-base=$docbase"
2722 func_append actioncmd " --aux-dir=$auxdir"
2723 if test -n "$inctests"; then
2724 func_append actioncmd " --with-tests"
2726 for module in $avoidlist; do
2727 func_append actioncmd " --avoid=$module"
2729 if test -n "$lgpl"; then
2730 if test "$lgpl" = yes; then
2731 func_append actioncmd " --lgpl"
2733 func_append actioncmd " --lgpl=$lgpl"
2736 if test -n "$makefile_name"; then
2737 func_append actioncmd " --makefile-name=$makefile_name"
2739 if test "$libtool" = true; then
2740 func_append actioncmd " --libtool"
2742 func_append actioncmd " --no-libtool"
2744 func_append actioncmd " --macro-prefix=$macro_prefix"
2745 if test -n "$po_domain"; then
2746 func_append actioncmd " --po-domain=$po_domain"
2748 func_append actioncmd " `echo $specified_modules`"
2750 # Default the makefile name to Makefile.am.
2751 if test -n "$makefile_name"; then
2752 makefile_am=$makefile_name
2754 makefile_am=Makefile.am
2757 # Create normal Makefile.ams.
2760 # Create library makefile.
2761 func_dest_tmpfilename $sourcebase/$makefile_am
2762 modules="$main_modules"
2763 func_emit_lib_Makefile_am > "$tmpfile"
2764 if test -f "$destdir"/$sourcebase/$makefile_am; then
2765 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
2769 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2770 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
2771 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2773 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
2779 echo "Creating $sourcebase/$makefile_am"
2780 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
2782 echo "Create $sourcebase/$makefile_am"
2785 func_append added_files "$sourcebase/$makefile_am$nl"
2788 # Create po/ directory.
2789 if test -n "$pobase"; then
2790 # Create po makefile and auxiliary files.
2791 for file in Makefile.in.in remove-potcdate.sin; do
2792 func_dest_tmpfilename $pobase/$file
2793 func_lookup_file build-aux/po/$file
2794 cat "$lookedup_file" > "$tmpfile"
2795 if test -f "$destdir"/$pobase/$file; then
2796 if cmp "$destdir"/$pobase/$file "$tmpfile" > /dev/null; then
2800 echo "Updating $pobase/$file (backup in $pobase/$file~)"
2801 mv -f "$destdir"/$pobase/$file "$destdir"/$pobase/$file~
2802 mv -f "$tmpfile" "$destdir"/$pobase/$file
2804 echo "Update $pobase/$file (backup in $pobase/$file~)"
2810 echo "Creating $pobase/$file"
2811 mv -f "$tmpfile" "$destdir"/$pobase/$file
2813 echo "Create $pobase/$file"
2816 func_append added_files "$pobase/$file$nl"
2819 # Create po makefile parametrization, part 1.
2820 func_dest_tmpfilename $pobase/Makevars
2821 func_emit_po_Makevars > "$tmpfile"
2822 if test -f "$destdir"/$pobase/Makevars; then
2823 if cmp "$destdir"/$pobase/Makevars "$tmpfile" > /dev/null; then
2827 echo "Updating $pobase/Makevars (backup in $pobase/Makevars~)"
2828 mv -f "$destdir"/$pobase/Makevars "$destdir"/$pobase/Makevars~
2829 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2831 echo "Update $pobase/Makevars (backup in $pobase/Makevars~)"
2837 echo "Creating $pobase/Makevars"
2838 mv -f "$tmpfile" "$destdir"/$pobase/Makevars
2840 echo "Create $pobase/Makevars"
2843 func_append added_files "$pobase/Makevars$nl"
2845 # Create po makefile parametrization, part 2.
2846 func_dest_tmpfilename $pobase/POTFILES.in
2847 func_emit_po_POTFILES_in > "$tmpfile"
2848 if test -f "$destdir"/$pobase/POTFILES.in; then
2849 if cmp "$destdir"/$pobase/POTFILES.in "$tmpfile" > /dev/null; then
2853 echo "Updating $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2854 mv -f "$destdir"/$pobase/POTFILES.in "$destdir"/$pobase/POTFILES.in~
2855 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2857 echo "Update $pobase/POTFILES.in (backup in $pobase/POTFILES.in~)"
2863 echo "Creating $pobase/POTFILES.in"
2864 mv -f "$tmpfile" "$destdir"/$pobase/POTFILES.in
2866 echo "Create $pobase/POTFILES.in"
2869 func_append added_files "$pobase/POTFILES.in$nl"
2872 TP_URL="http://translationproject.org/latest/"
2873 TP_RSYNC_URI="translationproject.org::tp/latest/"
2875 echo "Fetching gnulib PO files from $TP_URL"
2876 (cd "$destdir"/$pobase \
2877 && { # Prefer rsync over wget if it is available, since it consumes
2878 # less network bandwidth, due to compression.
2879 if type rsync 2>/dev/null | grep / > /dev/null; then
2880 rsync -Lrtz "${TP_RSYNC_URI}gnulib/" .
2882 wget --quiet -r -l1 -nd -np -A.po "${TP_URL}gnulib"
2887 echo "Fetch gnulib PO files from $TP_URL"
2889 # Create po/LINGUAS.
2891 func_dest_tmpfilename $pobase/LINGUAS
2892 (cd "$destdir"/$pobase \
2893 && { echo '# Set of available languages.'
2894 LC_ALL=C ls -1 *.po | sed -e 's,\.po$,,'
2897 if test -f "$destdir"/$pobase/LINGUAS; then
2898 if cmp "$destdir"/$pobase/LINGUAS "$tmpfile" > /dev/null; then
2901 echo "Updating $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2902 mv -f "$destdir"/$pobase/LINGUAS "$destdir"/$pobase/LINGUAS~
2903 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2906 echo "Creating $pobase/LINGUAS"
2907 mv -f "$tmpfile" "$destdir"/$pobase/LINGUAS
2908 func_append added_files "$pobase/LINGUAS$nl"
2911 if test -f "$destdir"/$pobase/LINGUAS; then
2912 echo "Update $pobase/LINGUAS (backup in $pobase/LINGUAS~)"
2914 echo "Create $pobase/LINGUAS"
2919 # Create m4/gnulib-cache.m4.
2920 func_dest_tmpfilename $m4base/gnulib-cache.m4
2922 func_emit_copyright_notice
2924 echo "# This file represents the specification of how gnulib-tool is used."
2925 echo "# It acts as a cache: It is written and read by gnulib-tool."
2926 echo "# In projects using CVS, this file is meant to be stored in CVS,"
2927 echo "# like the configure.ac and various Makefile.am files."
2930 echo "# Specification in the form of a command-line invocation:"
2933 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
2934 # Store the local_gnulib_dir relative to destdir.
2935 case "$local_gnulib_dir" in
2937 relative_local_gnulib_dir="$local_gnulib_dir" ;;
2940 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
2942 # destdir, local_gnulib_dir are both relative.
2943 func_relativize "$destdir" "$local_gnulib_dir"
2944 relative_local_gnulib_dir="$reldir" ;;
2947 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
2948 echo "gl_MODULES(["`echo $specified_modules`"])"
2949 echo "gl_AVOID([$avoidlist])"
2950 echo "gl_SOURCE_BASE([$sourcebase])"
2951 echo "gl_M4_BASE([$m4base])"
2952 echo "gl_PO_BASE([$pobase])"
2953 echo "gl_DOC_BASE([$docbase])"
2954 echo "gl_TESTS_BASE([$testsbase])"
2955 test -z "$inctests" || echo "gl_WITH_TESTS"
2956 echo "gl_LIB([$libname])"
2957 if test -n "$lgpl"; then
2958 if test "$lgpl" = yes; then
2961 echo "gl_LGPL([$lgpl])"
2964 echo "gl_MAKEFILE_NAME([$makefile_name])"
2965 if test "$libtool" = true; then
2968 echo "gl_MACRO_PREFIX([$macro_prefix])"
2969 echo "gl_PO_DOMAIN([$po_domain])"
2971 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
2972 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
2976 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2977 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
2978 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2980 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
2984 echo "# gnulib-cache.m4 ends here"
2991 echo "Creating $m4base/gnulib-cache.m4"
2992 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
2994 echo "Create $m4base/gnulib-cache.m4"
3000 # Create m4/gnulib-comp.m4.
3001 func_dest_tmpfilename $m4base/gnulib-comp.m4
3003 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
3004 func_emit_copyright_notice
3006 echo "# This file represents the compiled summary of the specification in"
3007 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
3008 echo "# to be invoked from configure.ac."
3009 echo "# In projects using CVS, this file can be treated like other built files."
3012 echo "# This macro should be invoked from $configure_ac, in the section"
3013 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
3014 echo "# any checks for libraries, header files, types and library functions."
3015 echo "AC_DEFUN([${macro_prefix}_EARLY],"
3017 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3018 echo " m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3019 echo " m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3020 echo " m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3021 echo " AC_REQUIRE([AC_PROG_RANLIB])"
3022 if test -n "$uses_subdirs"; then
3023 echo " AC_REQUIRE([AM_PROG_CC_C_O])"
3025 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
3026 echo " AC_REQUIRE([AC_GNU_SOURCE])"
3028 for module in $final_modules; do
3030 if test -n "$module"; then
3031 func_get_autoconf_early_snippet "$module"
3034 | sed -e '/^$/d;' -e 's/^/ /'
3037 echo "# This macro should be invoked from $configure_ac, in the section"
3038 echo "# \"Check for header files, types and library functions\"."
3039 echo "AC_DEFUN([${macro_prefix}_INIT],"
3041 if test "$libtool" = true; then
3042 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3043 echo " gl_cond_libtool=true"
3045 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3046 echo " gl_cond_libtool=false"
3048 echo " gl_ltlibdeps="
3050 if test "$auxdir" != "build-aux"; then
3051 sed_replace_build_aux='
3053 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3054 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3058 sed_replace_build_aux=
3060 func_emit_initmacro_start $macro_prefix
3061 echo " gl_source_base='$sourcebase'"
3062 for module in $main_modules; do
3064 if test -n "$module"; then
3065 func_get_autoconf_snippet "$module" \
3066 | sed -e '/^$/d;' -e 's/^/ /' \
3067 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3068 -e "$sed_replace_build_aux"
3069 if test "$module" = 'alloca' && test "$libtool" = true; then
3070 echo 'changequote(,)dnl'
3071 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
3072 echo 'changequote([, ])dnl'
3073 echo 'AC_SUBST([LTALLOCA])'
3077 func_emit_initmacro_end $macro_prefix
3078 echo " gltests_libdeps="
3079 echo " gltests_ltlibdeps="
3080 func_emit_initmacro_start ${macro_prefix}tests
3081 echo " gl_source_base='$testsbase'"
3082 for module in $testsrelated_modules; do
3084 if test -n "$module"; then
3085 func_get_autoconf_snippet "$module" \
3086 | sed -e '/^$/d;' -e 's/^/ /' \
3087 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
3088 -e "$sed_replace_build_aux" \
3089 -e 's/\$gl_cond_libtool/false/g' \
3090 -e 's/gl_libdeps/gltests_libdeps/g' \
3091 -e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
3094 func_emit_initmacro_end ${macro_prefix}tests
3095 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3096 # created using libtool, because libtool already handles the dependencies.
3097 if test "$libtool" != true; then
3098 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3099 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3100 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3101 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3102 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3104 if $use_libtests; then
3105 echo " LIBTESTS_LIBDEPS=\"\$gltests_libdeps\""
3106 echo " AC_SUBST([LIBTESTS_LIBDEPS])"
3109 func_emit_initmacro_done $macro_prefix $sourcebase
3110 func_emit_initmacro_done ${macro_prefix}tests $testsbase
3112 echo "# This macro records the list of files which have been installed by"
3113 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
3114 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
3115 echo "$files" | sed -e 's,^, ,'
3118 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
3119 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
3123 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3124 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
3125 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3127 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
3131 echo "# gnulib-comp.m4 ends here"
3138 echo "Creating $m4base/gnulib-comp.m4"
3139 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
3141 echo "Create $m4base/gnulib-comp.m4"
3147 if test -n "$inctests"; then
3148 # Create tests makefile.
3149 func_dest_tmpfilename $testsbase/$makefile_am
3150 modules="$testsrelated_modules"
3151 func_emit_tests_Makefile_am > "$tmpfile"
3152 if test -f "$destdir"/$testsbase/$makefile_am; then
3153 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
3157 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3158 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
3159 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3161 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
3167 echo "Creating $testsbase/$makefile_am"
3168 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
3170 echo "Create $testsbase/$makefile_am"
3173 func_append added_files "$testsbase/$makefile_am$nl"
3177 # Update the .cvsignore and .gitignore files.
3178 { echo "$added_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|A|\1,'
3179 echo "$removed_files" | sed -e '/^$/d' -e 's,\([^/]*\)$,|R|\1,'
3180 } | LC_ALL=C sort -t'|' -k1,1 > "$tmp"/fileset-changes
3181 { # Rearrange file descriptors. Needed because "while ... done < ..."
3182 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3183 exec 5<&0 < "$tmp"/fileset-changes
3184 func_update_ignorelist ()
3187 if test -f "$destdir/$dir$ignore"; then
3188 if test -n "$dir_added" || test -n "$dir_removed"; then
3189 LC_ALL=C sort "$destdir/$dir$ignore" > "$tmp"/ignore
3190 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u \
3191 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-added
3192 echo "$dir_removed" | sed -e '/^$/d' | LC_ALL=C sort -u \
3193 | LC_ALL=C join -v 2 "$tmp"/ignore - > "$tmp"/ignore-removed
3194 if test -s "$tmp"/ignore-added || test -s "$tmp"/ignore-removed; then
3196 echo "Updating $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3197 mv -f "$destdir/$dir$ignore" "$destdir/$dir$ignore"~
3198 sed -e 's,^,/^,' -e 's,$,\$/d,' < "$tmp"/ignore-removed > "$tmp"/sed-ignore-removed
3199 cat "$destdir/$dir$ignore"~ "$tmp"/ignore-added \
3200 | sed -f "$tmp"/sed-ignore-removed \
3201 > "$destdir/$dir$ignore"
3203 echo "Update $destdir/$dir$ignore (backup in $destdir/$dir${ignore}~)"
3208 if test -n "$dir_added"; then
3210 echo "Creating $destdir/$dir$ignore"
3212 if test "$ignore" = .cvsignore; then
3214 # Automake generates Makefile rules that create .dirstamp files.
3217 echo "$dir_added" | sed -e '/^$/d' | LC_ALL=C sort -u
3218 } > "$destdir/$dir$ignore"
3220 echo "Create $destdir/$dir$ignore"
3230 if test -d "$destdir/CVS" || test -d "$destdir/${dir}CVS" || test -f "$destdir/${dir}.cvsignore"; then
3231 func_update_ignorelist .cvsignore
3233 if test -d "$destdir/.git" || test -f "$destdir/${dir}.gitignore"; then
3234 func_update_ignorelist .gitignore
3241 # Why not ''read next_dir op file'' ? Because the dir column can be empty.
3242 next_dir=`echo "$line" | sed -e 's,|.*,,'`
3243 op=`echo "$line" | sed -e 's,^[^|]*|\([^|]*\)|.*$,\1,'`
3244 file=`echo "$line" | sed -e 's,^[^|]*|[^|]*|,,'`
3245 if test "$next_dir" != "$last_dir"; then
3246 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3247 last_dir="$next_dir"
3252 A) func_append last_dir_added "$file$nl";;
3253 R) func_append last_dir_removed "$file$nl";;
3256 func_done_dir "$last_dir" "$last_dir_added" "$last_dir_removed"
3262 echo "You may need to add #include directives for the following .h files."
3263 # Intersect $specified_modules and $main_modules
3264 # (since $specified_modules is not necessarily of subset of $main_modules
3265 # - some may have been skipped through --avoid, and since the elements of
3266 # $main_modules but not in $specified_modules can go away without explicit
3267 # notice - through changes in the module dependencies).
3268 echo "$specified_modules" > "$tmp"/modules1 # a sorted list, one module per line
3269 echo "$main_modules" > "$tmp"/modules2 # also a sorted list, one module per line
3270 # First the #include <...> directives without #ifs, sorted for convenience,
3271 # then the #include "..." directives without #ifs, sorted for convenience,
3272 # then the #include directives that are surrounded by #ifs. Not sorted.
3273 for module in `LC_ALL=C join "$tmp"/modules1 "$tmp"/modules2`; do
3274 include_directive=`func_get_include_directive "$module"`
3275 case "$nl$include_directive" in
3277 echo "$include_directive" 1>&5
3280 echo "$include_directive" | grep -v 'include "' 1>&6
3281 echo "$include_directive" | grep 'include "' 1>&7
3284 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
3286 LC_ALL=C sort -u "$tmp"/include-angles
3287 LC_ALL=C sort -u "$tmp"/include-quotes
3288 cat "$tmp"/include-if
3289 ) | sed -e '/^$/d' -e 's/^/ /'
3290 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
3292 for module in $main_modules; do
3293 func_get_link_directive "$module"
3295 | LC_ALL=C sort -u | sed -e '/^$/d' -e 's/^/ /' > "$tmp"/link
3296 if test `wc -l < "$tmp"/link` != 0; then
3298 echo "You may need to use the following Makefile variables when linking."
3299 echo "Use them in <program>_LDADD when linking a program, or"
3300 echo "in <library>_a_LDFLAGS or <library>_la_LDFLAGS when linking a library."
3306 echo "Don't forget to"
3307 if test "$makefile_am" = Makefile.am; then
3308 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3310 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
3312 if test -n "$pobase"; then
3313 echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
3315 if test -n "$inctests"; then
3316 if test "$makefile_am" = Makefile.am; then
3317 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
3319 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
3322 if test "$makefile_am" = Makefile.am; then
3323 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
3324 sourcebase_base=`basename "$sourcebase"`
3325 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
3327 if test -n "$pobase"; then
3328 pobase_dir=`echo "$pobase" | sed -n -e 's,/[^/]*$,/,p'`
3329 pobase_base=`basename "$pobase"`
3330 echo " - mention \"${pobase_base}\" in SUBDIRS in ${pobase_dir}Makefile.am,"
3332 if test -n "$inctests"; then
3333 if test "$makefile_am" = Makefile.am; then
3334 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
3335 testsbase_base=`basename "$testsbase"`
3336 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
3339 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
3340 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
3341 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
3344 # func_create_testdir testdir modules
3346 # - local_gnulib_dir from --local-dir
3347 # - auxdir directory relative to destdir where to place build aux files
3348 func_create_testdir ()
3352 if test -z "$modules"; then
3353 # All modules together.
3354 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3355 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3356 # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
3357 modules=`func_all_modules`
3358 modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
3360 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
3362 # Check that the license of every module is consistent with the license of
3364 saved_modules="$modules"
3365 saved_inctests="$inctests"
3366 # When computing transitive closures, don't consider $module to depend on
3367 # $module-tests. Need this becauses tests are implicitly GPL and may depend
3368 # on GPL modules - therefore we don't want a warning in this case.
3370 for requested_module in $saved_modules; do
3371 requested_license=`func_get_license "$requested_module"`
3372 if test "$requested_license" != GPL; then
3373 # Here we use func_modules_transitive_closure, not just
3374 # func_get_dependencies, so that we also detect weird situations like
3375 # an LGPL module which depends on a GPLed build tool module which depends
3377 modules="$requested_module"
3378 func_modules_transitive_closure
3379 for module in $modules; do
3380 license=`func_get_license "$module"`
3382 'GPLed build tool') ;;
3383 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
3385 case "$requested_license" in
3388 GPLv2+ | LGPLv2+) ;;
3389 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3395 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3401 *) echo "warning: module $requested_module depends on a module with an incompatible license: $module" 1>&2 ;;
3410 modules="$saved_modules"
3411 inctests="$saved_inctests"
3413 # Subdirectory names.
3422 # Determine final module list.
3423 func_modules_transitive_closure
3424 if test $verbose -ge 0; then
3425 echo "Module list with included dependencies:"
3426 echo "$modules" | sed -e 's/^/ /'
3429 # Add the dummy module if needed.
3430 func_modules_add_dummy
3432 # Show banner notice of every module.
3435 # Determine final file list.
3436 func_modules_to_filelist
3437 if test $verbose -ge 0; then
3439 echo "$files" | sed -e 's/^/ /'
3442 sed_rewrite_files="\
3443 s,^build-aux/,$auxdir/,
3445 s,^lib/,$sourcebase/,
3447 s,^tests/,$testsbase/,"
3449 # Create directories.
3450 for f in $files; do echo $f; done \
3451 | sed -e "$sed_rewrite_files" \
3452 | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
3453 | LC_ALL=C sort -u \
3455 { # Rearrange file descriptors. Needed because "while ... done < ..."
3456 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3457 exec 5<&0 < "$tmp"/dirs
3459 mkdir -p "$testdir/$d"
3464 # Copy files or make symbolic links.
3466 for f in $files; do echo $f; done \
3467 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
3470 { # Rearrange file descriptors. Needed because "while ... done < ..."
3471 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
3472 exec 5<&0 < "$tmp"/files
3474 func_lookup_file "$f"
3475 if test -n "$lookedup_tmp"; then
3476 cp -p "$lookedup_file" "$testdir/$g"
3478 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
3479 if { test -n "$symbolic" \
3480 || { test -n "$lsymbolic" \
3481 && test "$lookedup_file" = "$local_gnulib_dir/$f"; }; }; then
3482 func_ln "$lookedup_file" "$testdir/$g"
3484 cp -p "$lookedup_file" "$testdir/$g"
3491 # Create Makefile.ams that are for testing.
3494 # Create $sourcebase/Makefile.am.
3495 mkdir -p "$testdir/$sourcebase"
3496 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
3497 any_uses_subdirs="$uses_subdirs"
3499 # Create $m4base/Makefile.am.
3500 mkdir -p "$testdir/$m4base"
3501 (echo "## Process this file with automake to produce Makefile.in."
3507 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
3510 ) > "$testdir/$m4base/Makefile.am"
3512 subdirs="$sourcebase $m4base"
3513 subdirs_with_configure_ac=""
3515 if false && test -f "$testdir"/$m4base/gettext.m4; then
3516 # Avoid stupid error message from automake:
3517 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
3518 mkdir -p "$testdir/po"
3519 (echo "## Process this file with automake to produce Makefile.in."
3520 ) > "$testdir/po/Makefile.am"
3521 func_append subdirs " po"
3524 if test -n "$inctests"; then
3525 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
3526 # Viewed from the $testsbase subdirectory, $auxdir is different.
3527 saved_auxdir="$auxdir"
3528 auxdir=`echo "$testsbase/"|sed 's%[^/][^/]*//*%../%g'`"$auxdir"
3529 # Create $testsbase/Makefile.am.
3531 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
3532 any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
3533 # Create $testsbase/configure.ac.
3534 (echo "# Process this file with autoconf to produce a configure script."
3535 echo "AC_INIT([dummy], [0])"
3536 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3537 echo "AM_INIT_AUTOMAKE"
3539 echo "AM_CONFIG_HEADER([config.h])"
3542 echo "AC_PROG_INSTALL"
3543 echo "AC_PROG_MAKE_SET"
3544 echo "AC_PROG_RANLIB"
3546 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3547 echo "AC_GNU_SOURCE"
3550 for module in $modules; do
3552 if test -n "$module"; then
3553 func_get_autoconf_early_snippet "$module"
3556 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3557 if test "$libtool" = true; then
3558 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3559 echo "gl_cond_libtool=true"
3561 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3562 echo "gl_cond_libtool=false"
3564 echo "gl_ltlibdeps="
3566 # Wrap the set of autoconf snippets into an autoconf macro that is then
3567 # invoked. This is needed because autoconf does not support AC_REQUIRE
3569 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3570 # but we want the AC_REQUIRE to have its normal meaning (provide one
3571 # expansion of the required macro before the current point, and only one
3573 echo "AC_DEFUN([gl_INIT], ["
3574 sed_replace_build_aux='
3576 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3577 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3580 func_emit_initmacro_start $macro_prefix
3581 # We don't have explicit ordering constraints between the various
3582 # autoconf snippets. It's cleanest to put those of the library before
3583 # those of the tests.
3584 echo "gl_source_base='../$sourcebase'"
3585 for module in $modules; do
3586 func_verify_nontests_module
3587 if test -n "$module"; then
3588 func_get_autoconf_snippet "$module" \
3589 | sed -e "$sed_replace_build_aux"
3592 echo "gl_source_base='.'"
3593 for module in $modules; do
3594 func_verify_tests_module
3595 if test -n "$module"; then
3596 func_get_autoconf_snippet "$module" \
3597 | sed -e "$sed_replace_build_aux"
3600 func_emit_initmacro_end $macro_prefix
3601 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3602 # created using libtool, because libtool already handles the dependencies.
3603 if test "$libtool" != true; then
3604 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3605 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3606 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3607 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3608 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3611 func_emit_initmacro_done $macro_prefix $sourcebase # FIXME use $sourcebase or $testsbase?
3615 # Usually $testsbase/config.h will be a superset of config.h. Verify this
3616 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
3617 echo "AH_TOP([#include \"../config.h\"])"
3619 echo "AC_OUTPUT([Makefile])"
3620 ) > "$testdir/$testsbase/configure.ac"
3621 auxdir="$saved_auxdir"
3622 func_append subdirs " $testsbase"
3623 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
3626 # Create Makefile.am.
3627 (echo "## Process this file with automake to produce Makefile.in."
3629 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3631 echo "SUBDIRS = $subdirs"
3633 echo "ACLOCAL_AMFLAGS = -I $m4base"
3634 ) > "$testdir/Makefile.am"
3636 # Create configure.ac.
3637 (echo "# Process this file with autoconf to produce a configure script."
3638 echo "AC_INIT([dummy], [0])"
3639 if test "$auxdir" != "."; then
3640 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3642 echo "AM_INIT_AUTOMAKE"
3644 echo "AM_CONFIG_HEADER([config.h])"
3647 echo "AC_PROG_INSTALL"
3648 echo "AC_PROG_MAKE_SET"
3650 echo "# For autobuild."
3651 echo "AC_CANONICAL_BUILD"
3652 echo "AC_CANONICAL_HOST"
3654 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
3655 echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
3656 echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
3657 echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
3659 echo "AC_PROG_RANLIB"
3661 if test -n "$any_uses_subdirs"; then
3662 echo "AM_PROG_CC_C_O"
3665 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
3666 echo "AC_GNU_SOURCE"
3669 for module in $modules; do
3670 func_verify_nontests_module
3671 if test -n "$module"; then
3672 func_get_autoconf_early_snippet "$module"
3675 | sed -e '/^$/d;' -e 's/AC_REQUIRE(\[\([^()]*\)\])/\1/'
3676 if test "$libtool" = true; then
3677 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
3678 echo "gl_cond_libtool=true"
3680 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
3681 echo "gl_cond_libtool=false"
3683 echo "gl_ltlibdeps="
3685 # Wrap the set of autoconf snippets into an autoconf macro that is then
3686 # invoked. This is needed because autoconf does not support AC_REQUIRE
3688 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
3689 # but we want the AC_REQUIRE to have its normal meaning (provide one
3690 # expansion of the required macro before the current point, and only one
3692 echo "AC_DEFUN([gl_INIT], ["
3693 if test "$auxdir" != "build-aux"; then
3694 sed_replace_build_aux='
3696 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
3697 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
3701 sed_replace_build_aux=
3703 func_emit_initmacro_start $macro_prefix
3704 echo "gl_source_base='$sourcebase'"
3705 for module in $modules; do
3706 func_verify_nontests_module
3707 if test -n "$module"; then
3708 func_get_autoconf_snippet "$module" \
3709 | sed -e "$sed_replace_build_aux"
3712 func_emit_initmacro_end $macro_prefix
3713 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
3714 # created using libtool, because libtool already handles the dependencies.
3715 if test "$libtool" != true; then
3716 libname_upper=`echo "$libname" | LC_ALL=C tr 'a-z-' 'A-Z_'`
3717 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
3718 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
3719 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
3720 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
3723 func_emit_initmacro_done $macro_prefix $sourcebase
3727 if test -n "$subdirs_with_configure_ac"; then
3728 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
3730 makefiles="Makefile"
3731 for d in $subdirs; do
3732 # For subdirs that have a configure.ac by their own, it's the subdir's
3733 # configure.ac which creates the subdir's Makefile.am, not this one.
3734 case " $subdirs_with_configure_ac " in
3736 *) func_append makefiles " $d/Makefile" ;;
3739 echo "AC_OUTPUT([$makefiles])"
3740 ) > "$testdir/configure.ac"
3742 # Create autogenerated files.
3744 # Do not use "${AUTORECONF} --force --install", because it may invoke
3745 # autopoint, which brings in older versions of some of our .m4 files.
3746 if test -f $m4base/gettext.m4; then
3747 func_execute_command ${AUTOPOINT} --force || func_exit 1
3748 for f in $m4base/*.m4~; do
3749 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3752 func_execute_command ${ACLOCAL} -I $m4base || func_exit 1
3753 if ! test -d build-aux; then
3754 func_execute_command mkdir build-aux || func_exit 1
3756 func_execute_command ${AUTOCONF} || func_exit 1
3757 func_execute_command ${AUTOHEADER} || func_exit 1
3758 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3760 if test -n "$inctests"; then
3761 # Create autogenerated files.
3762 (cd "$testdir/$testsbase" || func_exit 1
3763 # Do not use "${AUTORECONF} --force --install", because it may invoke
3764 # autopoint, which brings in older versions of some of our .m4 files.
3765 if test -f ../$m4base/gettext.m4; then
3766 func_execute_command ${AUTOPOINT} --force || func_exit 1
3767 for f in ../$m4base/*.m4~; do
3768 mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
3771 func_execute_command ${ACLOCAL} -I ../$m4base || func_exit 1
3772 if ! test -d ../build-aux; then
3773 func_execute_command mkdir ../build-aux
3775 func_execute_command ${AUTOCONF} || func_exit 1
3776 func_execute_command ${AUTOHEADER} || func_exit 1
3777 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3780 # Need to run configure and make once, to create built files that are to be
3781 # distributed (such as getdate.c).
3782 # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
3783 cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3784 | sed -n -e 's,^CLEANFILES[ ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[ ]*+=\([^#]*\).*$,\1,p'`
3785 cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
3786 # Extract the value of "BUILT_SOURCES += ...". Remove variable references
3787 # such $(FOO_H) because they don't refer to distributed files.
3788 sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
3789 built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
3790 | sed -n -e 's,^BUILT_SOURCES[ ]*+=\([^#]*\).*$,\1,p' \
3791 | sed -e "$sed_remove_make_variables"`
3792 distributed_built_sources=`for file in $built_sources; do
3793 case "$cleaned_files" in
3798 if test -n "$distributed_built_sources"; then
3800 ./configure || func_exit 1
3802 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
3803 make built_sources || func_exit 1
3805 make distclean || func_exit 1
3810 # func_create_megatestdir megatestdir allmodules
3812 # - local_gnulib_dir from --local-dir
3813 # - auxdir directory relative to destdir where to place build aux files
3814 func_create_megatestdir ()
3818 if test -z "$allmodules"; then
3819 allmodules=`func_all_modules`
3823 # First, all modules one by one.
3824 for onemodule in $allmodules; do
3825 func_create_testdir "$megatestdir/$onemodule" $onemodule
3826 func_append megasubdirs "$onemodule "
3828 # Then, all modules all together.
3829 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
3830 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
3831 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
3832 func_create_testdir "$megatestdir/ALL" "$allmodules"
3833 func_append megasubdirs "ALL"
3836 cvsdate=`if test -f "$gnulib_dir/CVS/Entries"; then \
3837 vc_witness="$gnulib_dir/CVS/Entries"; \
3839 vc_witness="$gnulib_dir/.git/refs/heads/master"; \
3841 sh "$gnulib_dir/build-aux/mdate-sh" "$vc_witness" \
3842 | sed -e 's,January,01,' -e 's,Jan,01,' \
3843 -e 's,February,02,' -e 's,Feb,02,' \
3844 -e 's,March,03,' -e 's,Mar,03,' \
3845 -e 's,April,04,' -e 's,Apr,04,' \
3847 -e 's,June,06,' -e 's,Jun,06,' \
3848 -e 's,July,07,' -e 's,Jul,07,' \
3849 -e 's,August,08,' -e 's,Aug,08,' \
3850 -e 's,September,09,' -e 's,Sep,09,' \
3851 -e 's,October,10,' -e 's,Oct,10,' \
3852 -e 's,November,11,' -e 's,Nov,11,' \
3853 -e 's,December,12,' -e 's,Dec,12,' \
3854 -e 's,^,00,' -e 's,^[0-9]*\([0-9][0-9] \),\1,' \
3855 -e 's,^\([0-9]*\) \([0-9]*\) \([0-9]*\),\3\2\1,'`
3857 echo "CVSDATE=$cvsdate"
3858 echo "test -d logs || mkdir logs"
3859 echo "for module in $megasubdirs; do"
3860 echo " echo \"Working on module \$module...\""
3861 echo " safemodule=\`echo \$module | sed -e 's|/|-|g'\`"
3862 echo " (echo \"To: gnulib@autobuild.josefsson.org\""
3865 echo " : autobuild project... \$module"
3866 echo " : autobuild revision... cvs-\$CVSDATE-000000"
3867 echo " : autobuild timestamp... \`date \"+%Y%m%d-%H%M%S\"\`"
3868 echo " : autobuild hostname... \`hostname\`"
3869 echo " cd \$module && ./configure \$CONFIGURE_OPTIONS && make && make check && make distclean"
3871 echo " ) 2>&1 | { if test -n \"\$AUTOBUILD_SUBST\"; then sed -e \"\$AUTOBUILD_SUBST\"; else cat; fi; } > logs/\$safemodule"
3873 ) > "$megatestdir/do-autobuild"
3874 chmod a+x "$megatestdir/do-autobuild"
3876 # Create Makefile.am.
3877 (echo "## Process this file with automake to produce Makefile.in."
3879 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
3881 echo "SUBDIRS = $megasubdirs"
3883 echo "EXTRA_DIST = do-autobuild"
3884 ) > "$megatestdir/Makefile.am"
3886 # Create configure.ac.
3887 (echo "# Process this file with autoconf to produce a configure script."
3888 echo "AC_INIT([dummy], [0])"
3889 if test "$auxdir" != "."; then
3890 echo "AC_CONFIG_AUX_DIR([$auxdir])"
3892 echo "AM_INIT_AUTOMAKE"
3894 echo "AC_PROG_MAKE_SET"
3896 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
3897 echo "AC_OUTPUT([Makefile])"
3898 ) > "$megatestdir/configure.ac"
3900 # Create autogenerated files.
3902 # Do not use "${AUTORECONF} --install", because autoreconf operates
3903 # recursively, but the subdirectories are already finished, therefore
3904 # calling autoreconf here would only waste lots of CPU time.
3905 func_execute_command ${ACLOCAL} || func_exit 1
3906 func_execute_command mkdir build-aux
3907 func_execute_command ${AUTOCONF} || func_exit 1
3908 func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
3914 func_fatal_error "no mode specified" ;;
3923 if test -z "$destdir"; then
3926 test -d "$destdir" \
3927 || func_fatal_error "destination directory does not exist: $destdir"
3929 # Prefer configure.ac to configure.in.
3930 if test -f "$destdir"/configure.ac; then
3931 configure_ac="$destdir/configure.ac"
3933 if test -f "$destdir"/configure.in; then
3934 configure_ac="$destdir/configure.in"
3936 func_fatal_error "cannot find $destdir/configure.ac"
3940 # Analyze configure.ac.
3942 guessed_libtool=false
3947 /AC_CONFIG_AUX_DIR/ {
3948 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
3950 /A[CM]_PROG_LIBTOOL/ {
3951 s,^.*$,guessed_libtool=true,p
3953 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
3955 if test -z "$auxdir"; then
3956 auxdir="$guessed_auxdir"
3959 # Determine where to apply func_import.
3960 if test -n "$m4base"; then
3961 # Apply func_import to a particular gnulib directory.
3962 # Any number of additional modules can be given.
3963 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
3964 # First use of gnulib in the given m4base.
3965 test -n "$supplied_libname" || supplied_libname=true
3966 test -n "$sourcebase" || sourcebase="lib"
3967 test -n "$docbase" || docbase="doc"
3968 test -n "$testsbase" || testsbase="tests"
3969 test -n "$macro_prefix" || macro_prefix="gl"
3973 # Apply func_import to all gnulib directories.
3974 # To get this list of directories, look at Makefile.am. (Not at
3975 # configure, because it may be omitted from CVS. Also, don't run
3976 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
3979 if test -f "$destdir"/Makefile.am; then
3980 aclocal_amflags=`sed -n 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/p' "$destdir"/Makefile.am`
3982 for arg in $aclocal_amflags; do
3983 if test -n "$m4dir_is_next"; then
3984 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
3988 if test -f "$destdir/$arg"/gnulib-cache.m4; then
3989 func_append m4dirs " $arg"
3990 m4dirs_count=`expr $m4dirs_count + 1`
3996 if test "X$arg" = "X-I"; then
4004 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
4005 if test -f "$destdir"/aclocal.m4; then
4006 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
4007 sedexpr2='s,^[^/]*$,.,'
4008 sedexpr3='s,/[^/]*$,,'
4009 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
4010 m4dirs_count=`echo "$m4dirs" | wc -l`
4013 if test $m4dirs_count = 0; then
4014 # First use of gnulib in a package.
4015 # Any number of additional modules can be given.
4016 test -n "$supplied_libname" || supplied_libname=true
4017 test -n "$sourcebase" || sourcebase="lib"
4019 test -n "$docbase" || docbase="doc"
4020 test -n "$testsbase" || testsbase="tests"
4021 test -n "$macro_prefix" || macro_prefix="gl"
4024 if test $m4dirs_count = 1; then
4025 # There's only one use of gnulib here. Assume the user means it.
4026 # Any number of additional modules can be given.
4027 for m4base in $m4dirs; do
4031 # Ambiguous - guess what the user meant.
4032 if test $# = 0; then
4033 # No further arguments. Guess the user wants to update all of them.
4034 for m4base in $m4dirs; do
4035 # Perform func_import in a subshell, so that variable values
4037 # local_gnulib_dir, avoidlist, sourcebase, m4base, pobase,
4038 # docbase, testsbase, inctests, libname, lgpl, makefile_name,
4039 # libtool, macro_prefix, po_domain
4040 # don't propagate from one directory to another.
4041 (func_import) || func_exit 1
4045 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
4053 if test -z "$destdir"; then
4054 func_fatal_error "please specify --dir option"
4057 test -d "$destdir" \
4058 || func_fatal_error "could not create destination directory"
4059 test -n "$auxdir" || auxdir="build-aux"
4060 func_create_testdir "$destdir" "$*"
4063 create-megatestdir )
4064 if test -z "$destdir"; then
4065 func_fatal_error "please specify --dir option"
4067 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4068 test -n "$auxdir" || auxdir="build-aux"
4069 func_create_megatestdir "$destdir" "$*"
4073 test -n "$destdir" || destdir=testdir$$
4074 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4075 test -n "$auxdir" || auxdir="build-aux"
4076 func_create_testdir "$destdir" "$*"
4080 ../configure || func_exit 1
4082 make check || func_exit 1
4083 make distclean || func_exit 1
4084 remaining=`find . -type f -print`
4085 if test -n "$remaining"; then
4086 echo "Remaining files:" $remaining 1>&2
4087 echo "gnulib-tool: *** Stop." 1>&2
4096 test -n "$destdir" || destdir=testdir$$
4097 mkdir "$destdir" || func_fatal_error "could not create destination directory"
4098 test -n "$auxdir" || auxdir="build-aux"
4099 func_create_megatestdir "$destdir" "$*"
4107 remaining=`find . -type f -print`
4108 if test -n "$remaining"; then
4109 echo "Remaining files:" $remaining 1>&2
4110 echo "gnulib-tool: *** Stop." 1>&2
4118 extract-description )
4122 if test -n "$module"; then
4123 func_get_description "$module"
4132 if test -n "$module"; then
4133 func_get_notice "$module"
4142 if test -n "$module"; then
4143 func_get_filelist "$module"
4148 extract-dependencies )
4152 if test -n "$module"; then
4153 func_get_dependencies "$module"
4158 extract-autoconf-snippet )
4162 if test -n "$module"; then
4163 func_get_autoconf_snippet "$module"
4168 extract-automake-snippet )
4172 if test -n "$module"; then
4173 func_get_automake_snippet "$module"
4178 extract-include-directive )
4182 if test -n "$module"; then
4183 func_get_include_directive "$module"
4188 extract-link-directive )
4192 if test -n "$module"; then
4193 func_get_link_directive "$module"
4202 if test -n "$module"; then
4203 func_get_license "$module"
4208 extract-maintainer )
4212 if test -n "$module"; then
4213 func_get_maintainer "$module"
4218 extract-tests-module )
4222 if test -n "$module"; then
4223 func_get_tests_module "$module"
4229 func_fatal_error "unknown operation mode --$mode" ;;
4233 # Undo the effect of the previous 'trap' command. Some shellology:
4234 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
4235 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
4236 # exit); for the others we need to call 'exit' explicitly. The value of $? is
4237 # 128 + signal number and is set before the trap-registered command is run.
4239 trap 'func_exit $?' 1 2 3 13 15
4244 # indent-tabs-mode: nil
4245 # whitespace-check-buffer-indent: nil