22fe4f799b5b83c1954d13959703521c75aed01c
[gnulib.git] / gnulib-tool
1 #! /bin/sh
2 #
3 # Copyright (C) 2002-2006 Free Software Foundation, Inc.
4 #
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 2, or (at your option)
8 # any later version.
9 #
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.
14 #
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software Foundation,
17 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 #
19
20 # This program is meant for authors or maintainers which want to import
21 # modules from gnulib into their packages.
22
23 progname=$0
24 package=gnulib
25 cvsdatestamp='$Date: 2006-11-13 12:34:33 $'
26 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
27 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
28 nl='
29 '
30
31 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
32 AUTOCONFPATH=
33 #case $USER in
34 #  bruno )
35 #    AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
36 #    AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
37 #    ;;
38 #esac
39
40 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
41 AUTOMAKEPATH=
42
43 # You can set GETTEXTPATH to empty if autopoint 0.15 is already in your PATH.
44 GETTEXTPATH=
45
46 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
47 # variables AUTOCONF, AUTOHEADER, ACLOCAL, AUTOMAKE, AUTORECONF individually.
48 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
49   AUTOCONF="${AUTOCONFPATH}autoconf"
50 fi
51 if test -z "${AUTOHEADER}" || test -n "${AUTOCONFPATH}"; then
52   AUTOHEADER="${AUTOCONFPATH}autoheader"
53 fi
54 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
55   ACLOCAL="${AUTOMAKEPATH}aclocal"
56 fi
57 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
58   AUTOMAKE="${AUTOMAKEPATH}automake"
59 fi
60 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
61   AUTORECONF="${AUTOCONFPATH}autoreconf"
62 fi
63
64 # If you didn't set GETTEXTPATH, you can also set the variable AUTOPOINT.
65 if test -z "${AUTOPOINT}" || test -n "${GETTEXTPATH}"; then
66   AUTOPOINT="${GETTEXTPATH}autopoint"
67 fi
68
69 # GNU sort is needed. Set SORT to its location (not needed if it's called
70 # 'sort' and already in the PATH).
71 if test -z "$SORT"; then
72   SORT=sort
73 fi
74
75 # func_usage
76 # outputs to stdout the --help usage message.
77 func_usage ()
78 {
79   echo "\
80 Usage: gnulib-tool --list
81        gnulib-tool --import [module1 ... moduleN]
82        gnulib-tool --update
83        gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
84        gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
85        gnulib-tool --test --dir=directory module1 ... moduleN
86        gnulib-tool --megatest --dir=directory [module1 ... moduleN]
87        gnulib-tool --extract-description module
88        gnulib-tool --extract-filelist module
89        gnulib-tool --extract-dependencies module
90        gnulib-tool --extract-autoconf-snippet module
91        gnulib-tool --extract-automake-snippet module
92        gnulib-tool --extract-include-directive module
93        gnulib-tool --extract-license module
94        gnulib-tool --extract-maintainer module
95        gnulib-tool --extract-tests-module module
96
97 Operation modes:
98       --list                print the available module names
99       --import              import the given modules into the current package;
100                             if no modules are specified, update the current
101                             package from the current gnulib
102       --update              update the current package, restore files omitted
103                             from CVS
104       --create-testdir      create a scratch package with the given modules
105       --create-megatestdir  create a mega scratch package with the given modules
106                             one by one and all together
107       --test                test the combination of the given modules
108                             (recommended to use CC=\"gcc -Wall\" here)
109       --megatest            test the given modules one by one and all together
110                             (recommended to use CC=\"gcc -Wall\" here)
111       --extract-description        extract the description
112       --extract-filelist           extract the list of files
113       --extract-dependencies       extract the dependencies
114       --extract-autoconf-snippet   extract the snippet for configure.ac
115       --extract-automake-snippet   extract the snippet for library makefile
116       --extract-include-directive  extract the #include directive
117       --extract-license            report the license terms of the source files
118                                    under lib/
119       --extract-maintainer         report the maintainer(s) inside gnulib
120       --extract-tests-module       report the unit test module, if it exists
121
122 General options:
123       --dir=DIRECTORY       Specify the target directory.
124                             For --import, this specifies where your
125                             configure.ac can be found.  Defaults to current
126                             directory.
127       --local-dir=DIRECTORY  Specify a local override directory where to look
128                             up files before looking in gnulib's directory.
129
130 Options for --import:
131       --lib=LIBRARY         Specify the library name.  Defaults to 'libgnu'.
132       --source-base=DIRECTORY
133                             Directory relative to --dir where source code is
134                             placed (default \"lib\").
135       --m4-base=DIRECTORY   Directory relative to --dir where *.m4 macros are
136                             placed (default \"m4\").
137       --doc-base=DIRECTORY  Directory relative to --dir where doc files are
138                             placed (default \"doc\").
139       --tests-base=DIRECTORY
140                             Directory relative to --dir where unit tests are
141                             placed (default \"tests\").
142       --aux-dir=DIRECTORY   Directory relative to --dir where auxiliary build
143                             tools are placed (default \"build-aux\").
144       --with-tests          Include unit tests for the included modules.
145       --avoid=MODULE        Avoid including the given MODULE. Useful if you
146                             have code that provides equivalent functionality.
147                             This option can be repeated.
148       --lgpl                Abort if modules aren't available under the LGPL.
149                             Also modify license template from GPL to LGPL.
150       --makefile-name=NAME  Name of makefile in automake syntax in the
151                             source-base and tests-base directories
152                             (default \"Makefile.am\").
153       --libtool             Use libtool rules.
154       --no-libtool          Don't use libtool rules.
155       --macro-prefix=PREFIX  Specify the prefix of the macros 'gl_EARLY' and
156                             'gl_INIT'. Default is 'gl'.
157       --no-changelog        don't update or create ChangeLog files
158
159 Options for --import and --update:
160       --dry-run             For --import, only print what would have been done.
161   -s, --symbolic, --symlink Make symbolic links instead of copying files.
162
163 Report bugs to <bug-gnulib@gnu.org>."
164 }
165
166 # func_version
167 # outputs to stdout the --version message.
168 func_version ()
169 {
170   year=`echo "$last_checkin_date" | sed -e 's,/.*$,,'`
171   echo "\
172 $progname (GNU $package) $version
173 Copyright (C) $year Free Software Foundation, Inc.
174 This is free software; see the source for copying conditions.  There is NO
175 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
176 Written by" "Bruno Haible" "and" "Simon Josefsson"
177 }
178
179 # func_emit_copyright_notice
180 # outputs to stdout a header for a generated file.
181 func_emit_copyright_notice ()
182 {
183   echo "# Copyright (C) 2004-2006 Free Software Foundation, Inc."
184   echo "#"
185   echo "# This file is free software, distributed under the terms of the GNU"
186   echo "# General Public License.  As a special exception to the GNU General"
187   echo "# Public License, this file may be distributed as part of a program"
188   echo "# that contains a configuration script generated by Autoconf, under"
189   echo "# the same distribution terms as the rest of that program."
190   echo "#"
191   echo "# Generated by gnulib-tool."
192 }
193
194 # func_exit STATUS
195 # exit with status
196 func_exit ()
197 {
198   (exit $1); exit $1
199 }
200
201 # func_tmpdir
202 # creates a temporary directory.
203 # Sets variable
204 # - tmp             pathname of freshly created temporary directory
205 func_tmpdir ()
206 {
207   # Use the environment variable TMPDIR, falling back to /tmp. This allows
208   # users to specify a different temporary directory, for example, if their
209   # /tmp is filled up or too small.
210   : ${TMPDIR=/tmp}
211   {
212     # Use the mktemp program if available. If not available, hide the error
213     # message.
214     tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
215     test -n "$tmp" && test -d "$tmp"
216   } ||
217   {
218     # Use a simple mkdir command. It is guaranteed to fail if the directory
219     # already exists.  $RANDOM is bash specific and expands to empty in shells
220     # other than bash, ksh and zsh.  Its use does not increase security;
221     # rather, it minimizes the probability of failure in a very cluttered /tmp
222     # directory.
223     tmp=$TMPDIR/gl$$-$RANDOM
224     (umask 077 && mkdir "$tmp")
225   } ||
226   {
227     echo "$0: cannot create a temporary directory in $TMPDIR" >&2
228     func_exit 1
229   }
230 }
231
232 # func_append var value
233 # appends the given value to the shell variable var.
234 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
235   # Use bash's += operator. It reduces complexity of appending repeatedly to
236   # a single variable from O(n^2) to O(n).
237   func_append ()
238   {
239     eval "$1+=\"\$2\""
240   }
241 else
242   func_append ()
243   {
244     eval "$1=\"\$$1\$2\""
245   }
246 fi
247
248 # func_fatal_error message
249 # outputs to stderr a fatal error message, and terminates the program.
250 func_fatal_error ()
251 {
252   echo "gnulib-tool: *** $1" 1>&2
253   echo "gnulib-tool: *** Stop." 1>&2
254   func_exit 1
255 }
256
257 # func_readlink SYMLINK
258 # outputs the target of the given symlink.
259 if (type -p readlink) > /dev/null 2>&1; then
260   func_readlink ()
261   {
262     # Use the readlink program from GNU coreutils.
263     readlink "$1"
264   }
265 else
266   func_readlink ()
267   {
268     # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
269     # would do the wrong thing if the link target contains " -> ".
270     LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
271   }
272 fi
273
274 # func_relativize DIR1 DIR2
275 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
276 # Input:
277 # - DIR1            relative pathname, relative to the current directory
278 # - DIR2            relative pathname, relative to the current directory
279 # Output:
280 # - reldir          relative pathname of DIR2, relative to DIR1
281 func_relativize ()
282 {
283   dir0=`pwd`
284   dir1="$1"
285   dir2="$2"
286   sed_first='s,^\([^/]*\)/.*$,\1,'
287   sed_rest='s,^[^/]*/*,,'
288   sed_last='s,^.*/\([^/]*\)$,\1,'
289   sed_butlast='s,/*[^/]*$,,'
290   while test -n "$dir1"; do
291     first=`echo "$dir1" | sed -e "$sed_first"`
292     if test "$first" != "."; then
293       if test "$first" = ".."; then
294         dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
295         dir0=`echo "$dir0" | sed -e "$sed_butlast"`
296       else
297         first2=`echo "$dir2" | sed -e "$sed_first"`
298         if test "$first2" = "$first"; then
299           dir2=`echo "$dir2" | sed -e "$sed_rest"`
300         else
301           dir2="../$dir2"
302         fi
303         dir0="$dir0"/"$first"
304       fi
305     fi
306     dir1=`echo "$dir1" | sed -e "$sed_rest"`
307   done
308   reldir="$dir2"
309 }
310
311 # func_relconcat DIR1 DIR2
312 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
313 # Input:
314 # - DIR1            relative pathname, relative to the current directory
315 # - DIR2            relative pathname, relative to DIR1
316 # Output:
317 # - relconcat       DIR1/DIR2, relative to the current directory
318 func_relconcat ()
319 {
320   dir1="$1"
321   dir2="$2"
322   sed_first='s,^\([^/]*\)/.*$,\1,'
323   sed_rest='s,^[^/]*/*,,'
324   sed_last='s,^.*/\([^/]*\)$,\1,'
325   sed_butlast='s,/*[^/]*$,,'
326   while true; do
327     first=`echo "$dir2" | sed -e "$sed_first"`
328     if test "$first" = "."; then
329       dir2=`echo "$dir2" | sed -e "$sed_rest"`
330       if test -z "$dir2"; then
331         relconcat="$dir1"
332         break
333       fi
334     else
335       last=`echo "$dir1" | sed -e "$sed_last"`
336       while test "$last" = "."; do
337         dir1=`echo "$dir1" | sed -e "$sed_butlast"`
338         last=`echo "$dir1" | sed -e "$sed_last"`
339       done
340       if test -z "$dir1"; then
341         relconcat="$dir2"
342         break
343       fi
344       if test "$first" = ".."; then
345         if test "$last" = ".."; then
346           relconcat="$dir1/$dir2"
347           break
348         fi
349         dir1=`echo "$dir1" | sed -e "$sed_butlast"`
350         dir2=`echo "$dir2" | sed -e "$sed_rest"`
351         if test -z "$dir1"; then
352           relconcat="$dir2"
353           break
354         fi
355         if test -z "$dir2"; then
356           relconcat="$dir1"
357           break
358         fi
359       else
360         relconcat="$dir1/$dir2"
361         break
362       fi
363     fi
364   done
365 }
366
367 # func_ln SRC DEST
368 # Like ln -s, except that SRC is given relative to the current directory (or
369 # absolute), not given relative to the directory of DEST.
370 func_ln ()
371 {
372   case "$1" in
373     /*)
374       ln -s "$1" "$2" ;;
375     *) # SRC is relative.
376       case "$2" in
377         /*)
378           ln -s "`pwd`/$1" "$2" ;;
379         *) # DEST is relative too.
380           ln_destdir=`echo "$2" | sed -e 's,[^/]*$,,'`
381           test -n "$ln_destdir" || ln_destdir="."
382           func_relativize "$ln_destdir" "$1"
383           ln -s "$reldir" "$2"
384           ;;
385       esac
386       ;;
387   esac
388 }
389
390 # func_ln_if_changed SRC DEST
391 # Like func_ln, but avoids munging timestamps if the link is correct.
392 func_ln_if_changed ()
393 {
394   if test $# -ne 2; then
395     echo "usage: func_ln_if_changed SRC DEST" >&2
396   fi
397   ln_target=`func_readlink "$2"`
398   if test -L "$2" && test "$1" = "$ln_target"; then
399     :
400   else
401     rm -f "$2"
402     func_ln "$1" "$2"
403   fi
404 }
405
406 # Command-line option processing.
407 # Removes the OPTIONS from the arguments. Sets the variables:
408 # - mode            list or import or create-testdir or create-megatestdir
409 # - destdir         from --dir
410 # - local_gnulib_dir  from --local-dir
411 # - libname, supplied_libname  from --lib
412 # - sourcebase      from --source-base
413 # - m4base          from --m4-base
414 # - docbase         from --doc-base
415 # - testsbase       from --tests-base
416 # - auxdir          from --aux-dir
417 # - inctests        true if --with-tests was given, blank otherwise
418 # - avoidlist       list of modules to avoid, from --avoid
419 # - lgpl            true if --lgpl was given, blank otherwise
420 # - makefile_name   from --makefile-name
421 # - libtool         true if --libtool was given, false if --no-libtool was
422 #                   given, blank otherwise
423 # - macro_prefix    from --macro-prefix
424 # - autoconf_minversion  minimum supported autoconf version
425 # - do_changelog    false if --no-changelog was given, : otherwise
426 # - doit            : if actions shall be executed, false if only to be printed
427 # - symbolic        true if --symbolic was given, blank otherwise
428 {
429   mode=
430   destdir=
431   local_gnulib_dir=
432   libname=libgnu
433   supplied_libname=
434   sourcebase=
435   m4base=
436   docbase=
437   testsbase=
438   auxdir=
439   inctests=
440   avoidlist=
441   lgpl=
442   makefile_name=
443   libtool=
444   macro_prefix=
445   do_changelog=:
446   doit=:
447   symbolic=
448
449   supplied_opts="$@"
450
451   while test $# -gt 0; do
452     case "$1" in
453       --list | --lis )
454         mode=list
455         shift ;;
456       --import | --impor | --impo | --imp | --im | --i )
457         mode=import
458         shift ;;
459       --update | --updat | --upda | --upd | --up | --u )
460         mode=update
461         shift ;;
462       --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
463         mode=create-testdir
464         shift ;;
465       --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
466         mode=create-megatestdir
467         shift ;;
468       --test | --tes | --te | --t )
469         mode=test
470         shift ;;
471       --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
472         mode=megatest
473         shift ;;
474       --extract-* )
475         mode=`echo "X$1" | sed -e 's/^X--//'`
476         shift ;;
477       --dir )
478         shift
479         if test $# = 0; then
480           func_fatal_error "missing argument for --dir"
481         fi
482         destdir=$1
483         shift ;;
484       --dir=* )
485         destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
486         shift ;;
487       --local-dir )
488         shift
489         if test $# = 0; then
490           func_fatal_error "missing argument for --local-dir"
491         fi
492         local_gnulib_dir=$1
493         shift ;;
494       --local-dir=* )
495         local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
496         shift ;;
497       --lib )
498         shift
499         if test $# = 0; then
500           func_fatal_error "missing argument for --lib"
501         fi
502         libname=$1
503         supplied_libname=true
504         shift ;;
505       --lib=* )
506         libname=`echo "X$1" | sed -e 's/^X--lib=//'`
507         supplied_libname=true
508         shift ;;
509       --source-base )
510         shift
511         if test $# = 0; then
512           func_fatal_error "missing argument for --source-base"
513         fi
514         sourcebase=$1
515         shift ;;
516       --source-base=* )
517         sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
518         shift ;;
519       --m4-base )
520         shift
521         if test $# = 0; then
522           func_fatal_error "missing argument for --m4-base"
523         fi
524         m4base=$1
525         shift ;;
526       --m4-base=* )
527         m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
528         shift ;;
529       --doc-base )
530         shift
531         if test $# = 0; then
532           func_fatal_error "missing argument for --doc-base"
533         fi
534         docbase=$1
535         shift ;;
536       --doc-base=* )
537         docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
538         shift ;;
539       --tests-base )
540         shift
541         if test $# = 0; then
542           func_fatal_error "missing argument for --tests-base"
543         fi
544         testsbase=$1
545         shift ;;
546       --tests-base=* )
547         testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
548         shift ;;
549       --aux-dir )
550         shift
551         if test $# = 0; then
552           func_fatal_error "missing argument for --aux-dir"
553         fi
554         auxdir=$1
555         shift ;;
556       --aux-dir=* )
557         auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
558         shift ;;
559       --with-tests )
560         inctests=true
561         shift ;;
562       --avoid )
563         shift
564         if test $# = 0; then
565           func_fatal_error "missing argument for --avoid"
566         fi
567         func_append avoidlist " $1"
568         shift ;;
569       --avoid=* )
570         arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
571         func_append avoidlist " $arg"
572         shift ;;
573       --lgpl )
574         lgpl=true
575         shift ;;
576       --makefile-name )
577         shift
578         if test $# = 0; then
579           func_fatal_error "missing argument for --makefile-name"
580         fi
581         makefile_name="$1"
582         shift ;;
583       --makefile-name=* )
584         makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
585         shift ;;
586       --libtool )
587         libtool=true
588         shift ;;
589       --no-libtool )
590         libtool=false
591         shift ;;
592       --macro-prefix )
593         shift
594         if test $# = 0; then
595           func_fatal_error "missing argument for --macro-prefix"
596         fi
597         macro_prefix="$1"
598         shift ;;
599       --macro-prefix=* )
600         macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
601         shift ;;
602       --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
603         do_changelog=false
604         shift ;;
605       --dry-run )
606         doit=false
607         shift ;;
608       -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
609         symbolic=true
610         shift ;;
611       --help | --hel | --he | --h )
612         func_usage
613         func_exit $? ;;
614       --version | --versio | --versi | --vers | --ver | --ve | --v )
615         func_version
616         func_exit $? ;;
617       -- )
618         # Stop option processing
619         shift
620         break ;;
621       -* )
622         echo "gnulib-tool: unknown option $1" 1>&2
623         echo "Try 'gnulib-tool --help' for more information." 1>&2
624         func_exit 1 ;;
625       * )
626         break ;;
627     esac
628   done
629
630   if test "$mode" = update; then
631     if test $# != 0; then
632       echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
633       echo "Try 'gnulib-tool --help' for more information." 1>&2
634       echo "If you really want to modify the gnulib configuration of your project," 1>&2
635       echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
636       func_exit 1
637     fi
638     if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
639        || test -n "$sourcebase" || test -n "$m4base" \
640        || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
641        || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
642        || test -n "$makefile_name" || test -n "$macro_prefix"; then
643       echo "gnulib-tool: invalid options for 'update' mode" 1>&2
644       echo "Try 'gnulib-tool --help' for more information." 1>&2
645       echo "If you really want to modify the gnulib configuration of your project," 1>&2
646       echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
647       func_exit 1
648     fi
649     do_changelog=false
650   fi
651
652   # Determine the minimum supported autoconf version from the project's
653   # configure.ac.
654   DEFAULT_AUTOCONF_MINVERSION="2.59"
655   autoconf_minversion=
656   configure_ac=
657   if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
658     if test -f "$destdir"/configure.ac; then
659       configure_ac="$destdir/configure.ac"
660     else
661       if test -f "$destdir"/configure.in; then
662         configure_ac="$destdir/configure.in"
663       fi
664     fi
665   else
666     if test -f configure.ac; then
667       configure_ac="configure.ac"
668     else
669       if test -f configure.in; then
670         configure_ac="configure.in"
671       fi
672     fi
673   fi
674   if test -n "$configure_ac"; then
675     # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
676     # because when some m4 files are omitted from a CVS repository,
677     # "autoconf --trace=AC_PREREQ" fails with an error message like this:
678     #   m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
679     #   autom4te: m4 failed with exit status: 1
680     prereqs=
681     my_sed_traces='
682       s,#.*$,,
683       s,^dnl .*$,,
684       s, dnl .*$,,
685       /AC_PREREQ/ {
686         s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,prereqs="$prereqs \1",p
687       }'
688     eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
689     if test -n "$prereqs"; then
690       autoconf_minversion=`for version in $prereqs; do echo $version; done | $SORT -g -u | tail -1`
691     fi
692   fi
693   if test -z "$autoconf_minversion"; then
694     autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
695   fi
696   case "$autoconf_minversion" in
697     1.* | 2.[0-4]* | 2.5[0-8]*)
698       func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
699   esac
700
701   # Remove trailing slashes from the directory names. This is necessary for
702   # m4base (to avoid an error in func_import) and optional for the others.
703   sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
704   case "$local_gnulib_dir" in
705     */ ) local_gnulib_dir=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
706   esac
707   case "$sourcebase" in
708     */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
709   esac
710   case "$m4base" in
711     */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
712   esac
713   case "$docbase" in
714     */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
715   esac
716   case "$testsbase" in
717     */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
718   esac
719   case "$auxdir" in
720     */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
721   esac
722 }
723
724 case "$0" in
725   /*) self_abspathname="$0" ;;
726   */*) self_abspathname=`pwd`/"$0" ;;
727   *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
728        if test -x "$d/$0" && test ! -d "$d/$0"; then
729          self_abspathname="$d/$0"
730          break
731        fi
732      done
733      if test -z "$self_abspathname"; then
734        func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
735      fi
736      ;;
737 esac
738 while test -h "$self_abspathname"; do
739   # Resolve symbolic link.
740   linkval=`func_readlink "$self_abspathname"`
741   test -n "$linkval" || break
742   case "$linkval" in
743     /* ) self_abspathname="$linkval" ;;
744     * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
745   esac
746 done
747 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
748
749 func_tmpdir
750 trap 'exit_status=$?
751       if test "$signal" != 0; then
752         echo "caught signal $signal" >&2
753       fi
754       rm -rf "$tmp"
755       exit $exit_status' 0
756 for signal in 1 2 3 13 15; do
757   trap '{ signal='$signal'; func_exit 1; }' $signal
758 done
759 signal=0
760
761 # func_lookup_file file
762 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
763 # 'patch'.
764 # Input:
765 # - local_gnulib_dir  from --local-dir
766 # Output:
767 # - lookedup_file   name of the merged (combined) file
768 # - lookedup_tmp    true if it is located in the tmp directory, blank otherwise
769 func_lookup_file ()
770 {
771   lkfile="$1"
772   if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
773     lookedup_file="$local_gnulib_dir/$lkfile"
774     lookedup_tmp=
775   else
776     if test -f "$gnulib_dir/$lkfile"; then
777       if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
778         lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
779         rm -f "$tmp/$lkbase"
780         cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
781         patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
782           || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
783         lookedup_file="$tmp/$lkbase"
784         lookedup_tmp=true
785       else
786         lookedup_file="$gnulib_dir/$lkfile"
787         lookedup_tmp=
788       fi
789     else
790       func_fatal_error "file $gnulib_dir/$lkfile not found"
791     fi
792   fi
793 }
794
795 # func_all_modules
796 # Input:
797 # - local_gnulib_dir  from --local-dir
798 func_all_modules ()
799 {
800   # Filter out metainformation files like README, which are not modules.
801   # Filter out unit test modules; they can be retrieved through
802   # --extract-tests-module if desired.
803   {
804     (cd "$gnulib_dir/modules" && ls -1)
805     if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
806       (cd "$local_gnulib_dir/modules" && ls -1 | sed -e 's,\.diff$,,')
807     fi
808   } \
809       | sed -e '/^CVS$/d' -e '/^ChangeLog$/d' -e '/^COPYING$/d' -e '/^README$/d' -e '/^TEMPLATE$/d' -e '/^TEMPLATE-TESTS$/d' -e '/~$/d' \
810       | sed -e '/-tests$/d' \
811       | LC_ALL=C sort -u
812 }
813
814 # func_verify_module
815 # verifies a module name
816 # Input:
817 # - local_gnulib_dir  from --local-dir
818 # - module          module name argument
819 func_verify_module ()
820 {
821   if { test -f "$gnulib_dir/modules/$module" \
822        || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
823             && test -f "$local_gnulib_dir/modules/$module"; }; } \
824      && test "CVS" != "$module" \
825      && test "ChangeLog" != "$module" \
826      && test "COPYING" != "$module" \
827      && test "README" != "$module" \
828      && test "TEMPLATE" != "$module" \
829      && test "TEMPLATE-TESTS" != "$module"; then
830     # OK, $module is a correct module name.
831     # Verify that building the module description with 'patch' succeeds.
832     func_lookup_file "modules/$module"
833   else
834     echo "gnulib-tool: module $module doesn't exist" 1>&2
835     module=
836   fi
837 }
838
839 # func_verify_nontests_module
840 # verifies a module name, excluding tests modules
841 # Input:
842 # - local_gnulib_dir  from --local-dir
843 # - module          module name argument
844 func_verify_nontests_module ()
845 {
846   case "$module" in
847     *-tests ) module= ;;
848     * ) func_verify_module ;;
849   esac
850 }
851
852 # func_verify_tests_module
853 # verifies a module name, considering only tests modules
854 # Input:
855 # - local_gnulib_dir  from --local-dir
856 # - module          module name argument
857 func_verify_tests_module ()
858 {
859   case "$module" in
860     *-tests ) func_verify_module ;;
861     * ) module= ;;
862   esac
863 }
864
865 sed_extract_prog=':[     ]*$/ {
866   :a
867     n
868     s/^Description:[     ]*$//
869     s/^Files:[   ]*$//
870     s/^Depends-on:[      ]*$//
871     s/^configure\.ac:[   ]*$//
872     s/^Makefile\.am:[    ]*$//
873     s/^Include:[         ]*$//
874     s/^License:[         ]*$//
875     s/^Maintainer:[      ]*$//
876     tb
877     p
878     ba
879   :b
880 }'
881
882 # func_get_description module
883 # Input:
884 # - local_gnulib_dir  from --local-dir
885 func_get_description ()
886 {
887   func_lookup_file "modules/$1"
888   sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
889 }
890
891 # func_get_filelist module
892 # Input:
893 # - local_gnulib_dir  from --local-dir
894 func_get_filelist ()
895 {
896   func_lookup_file "modules/$1"
897   sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
898   case "$autoconf_minversion" in
899     2.59)
900       #echo m4/onceonly.m4
901       echo m4/onceonly_2_57.m4
902       ;;
903   esac
904 }
905
906 # func_get_dependencies module
907 # Input:
908 # - local_gnulib_dir  from --local-dir
909 func_get_dependencies ()
910 {
911   # ${module}-tests always implicitly depends on ${module}.
912   echo "$1" | sed -n -e 's/-tests//p'
913   # Then the explicit dependencies listed in the module description.
914   func_lookup_file "modules/$1"
915   sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
916 }
917
918 # func_get_autoconf_snippet module
919 # Input:
920 # - local_gnulib_dir  from --local-dir
921 func_get_autoconf_snippet ()
922 {
923   func_lookup_file "modules/$1"
924   sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
925 }
926
927 # func_get_automake_snippet module
928 # Input:
929 # - local_gnulib_dir  from --local-dir
930 func_get_automake_snippet ()
931 {
932   func_lookup_file "modules/$1"
933   sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
934   case "$1" in
935     *-tests)
936       # *-tests module live in tests/, not lib/.
937       ;;
938     *)
939       # Synthesize an EXTRA_DIST augmentation.
940       sed_combine_lines='/\\$/{
941         :a
942         N
943         s/\\\n/ /
944         s/\\$/\\/
945         ta
946       }'
947       sed_extract_mentioned_files='s/^lib_SOURCES[      ]*+=[   ]*//p'
948       already_mentioned_files=` \
949         sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file" \
950         | sed -e "$sed_combine_lines" \
951         | sed -n -e "$sed_extract_mentioned_files" | sed -e 's/#.*//'`
952       all_files=`func_get_filelist $1`
953       lib_files=`for f in $all_files; do \
954                    case $f in \
955                      lib/*) echo $f ;; \
956                    esac; \
957                  done | sed -e 's,^lib/,,'`
958       # Remove $already_mentioned_files from $lib_files.
959       echo "$lib_files" | LC_ALL=C sort -u > "$tmp"/lib-files
960       extra_files=`for f in $already_mentioned_files; do echo $f; done \
961                    | LC_ALL=C sort -u | LC_ALL=C join -v 2 - "$tmp"/lib-files`
962       if test -n "$extra_files"; then
963         echo "EXTRA_DIST +=" $extra_files
964         echo
965       fi
966       # Synthesize also an EXTRA_lib_SOURCES augmentation.
967       # This is necessary so that automake can generate the right list of
968       # dependency rules.
969       # A possible approach would be to use autom4te --trace of the redefined
970       # AC_LIBOBJ and AC_REPLACE_FUNCS macros when creating the Makefile.am
971       # (use autom4te --trace, not just grep, so that AC_LIBOBJ invocations
972       # inside autoconf's built-in macros are not missed).
973       # But it's simpler and more robust to do it here, based on the file list.
974       # If some .c file exists and is not used with AC_LIBOBJ - for example,
975       # a .c file is preprocessed into another .c file for BUILT_SOURCES -,
976       # automake will generate a useless dependency; this is harmless.
977       sed_extract_c_files='/\.c$/p'
978       extra_files=`echo "$extra_files" | sed -n -e "$sed_extract_c_files"`
979       if test -n "$extra_files"; then
980         echo "EXTRA_lib_SOURCES +=" $extra_files
981         echo
982       fi
983       ;;
984   esac
985 }
986
987 # func_get_include_directive module
988 # Input:
989 # - local_gnulib_dir  from --local-dir
990 func_get_include_directive ()
991 {
992   func_lookup_file "modules/$1"
993   sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
994   sed -e 's/^\(["<]\)/#include \1/'
995 }
996
997 # func_get_license module
998 # Input:
999 # - local_gnulib_dir  from --local-dir
1000 func_get_license ()
1001 {
1002   func_lookup_file "modules/$1"
1003   sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
1004 }
1005
1006 # func_get_maintainer module
1007 # Input:
1008 # - local_gnulib_dir  from --local-dir
1009 func_get_maintainer ()
1010 {
1011   func_lookup_file "modules/$1"
1012   sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
1013 }
1014
1015 # func_get_tests_module module
1016 # Input:
1017 # - local_gnulib_dir  from --local-dir
1018 func_get_tests_module ()
1019 {
1020   # The naming convention for tests modules is hardwired: ${module}-tests.
1021   if test -f "$gnulib_dir/modules/$1"-tests \
1022      || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
1023           && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
1024     echo "$1"-tests
1025   fi
1026 }
1027
1028 # func_acceptable module
1029 # tests whether a module is acceptable.
1030 # Input:
1031 # - avoidlist       list of modules to avoid
1032 func_acceptable ()
1033 {
1034   for avoid in $avoidlist; do
1035     if test "$avoid" = "$1"; then
1036       return 1
1037     fi
1038   done
1039   return 0
1040 }
1041
1042 # func_modules_transitive_closure
1043 # Input:
1044 # - local_gnulib_dir  from --local-dir
1045 # - modules         list of specified modules
1046 # - inctests        true if tests should be included, blank otherwise
1047 # - avoidlist       list of modules to avoid
1048 # - tmp             pathname of a temporary directory
1049 # Output:
1050 # - modules         list of modules, including dependencies
1051 func_modules_transitive_closure ()
1052 {
1053   # In order to process every module only once (for speed), process an "input
1054   # list" of modules, producing an "output list" of modules. During each round,
1055   # more modules can be queued in the input list. Once a module on the input
1056   # list has been processed, it is added to the "handled list", so we can avoid
1057   # to process it again.
1058   handledmodules=
1059   inmodules="$modules"
1060   outmodules=
1061   while test -n "$inmodules"; do
1062     inmodules_this_round="$inmodules"
1063     inmodules=                    # Accumulator, queue for next round
1064     for module in $inmodules_this_round; do
1065       func_verify_module
1066       if test -n "$module"; then
1067         if func_acceptable $module; then
1068           func_append outmodules " $module"
1069           deps=`func_get_dependencies $module`
1070           # Duplicate dependencies are harmless, but Jim wants a warning.
1071           duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
1072           if test -n "$duplicated_deps"; then
1073             echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
1074           fi
1075           func_append inmodules " $deps"
1076           if test -n "$inctests"; then
1077             testsmodule=`func_get_tests_module $module`
1078             if test -n "$testsmodule"; then
1079               func_append inmodules " $testsmodule"
1080             fi
1081           fi
1082         fi
1083       fi
1084     done
1085     handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1086     # Remove $handledmodules from $inmodules.
1087     for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1088     inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1089   done
1090   modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1091   rm -f "$tmp"/queued-modules
1092 }
1093
1094 # func_modules_add_dummy
1095 # Input:
1096 # - local_gnulib_dir  from --local-dir
1097 # - modules         list of modules, including dependencies
1098 # Output:
1099 # - modules         list of modules, including 'dummy' if needed
1100 func_modules_add_dummy ()
1101 {
1102   have_lib_SOURCES=
1103   sed_remove_backslash_newline=':a
1104 /\\$/{
1105 s/\\$//
1106 N
1107 s/\n//
1108 ba
1109 }'
1110   for module in $modules; do
1111     func_verify_nontests_module
1112     if test -n "$module"; then
1113       # Extract the value of "lib_SOURCES += ...".
1114       for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[     ]*+=\([^#]*\).*$,\1,p'`; do
1115         # Ignore .h files since they are not compiled.
1116         case "$file" in
1117           *.h) ;;
1118           *) have_lib_SOURCES=yes ;;
1119         esac
1120       done
1121     fi
1122   done
1123   # Add the dummy module, to make sure the library will be non-empty.
1124   if test -z "$have_lib_SOURCES"; then
1125     func_append modules " dummy"
1126   fi
1127 }
1128
1129 # func_modules_to_filelist
1130 # Input:
1131 # - local_gnulib_dir  from --local-dir
1132 # - modules         list of modules, including dependencies
1133 # Output:
1134 # - files           list of files
1135 func_modules_to_filelist ()
1136 {
1137   files=
1138   for module in $modules; do
1139     func_verify_module
1140     if test -n "$module"; then
1141       fs=`func_get_filelist $module`
1142       func_append files " $fs"
1143     fi
1144   done
1145   files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1146 }
1147
1148 # func_emit_lib_Makefile_am
1149 # emits the contents of library makefile to standard output.
1150 # Input:
1151 # - local_gnulib_dir  from --local-dir
1152 # - modules         list of modules, including dependencies
1153 # - libname         library name
1154 # - makefile_name   from --makefile-name
1155 # - libtool         true if libtool will be used, false or blank otherwise
1156 # - macro_prefix    prefix of gl_LIBOBJS macros to use
1157 # - actioncmd       (optional) command that will reproduce this invocation
1158 # Output:
1159 # - uses_subdirs    nonempty if object files in subdirs exist
1160 func_emit_lib_Makefile_am ()
1161 {
1162   # When creating an includable Makefile.am snippet, augment variables with
1163   # += instead of assigning them.
1164   if test -n "$makefile_name"; then
1165     assign='+='
1166   else
1167     assign='='
1168   fi
1169   if test "$libtool" = true; then
1170     libext=la
1171     perhapsLT=LT
1172     sed_eliminate_LDFLAGS=
1173   else
1174     libext=a
1175     perhapsLT=
1176     sed_eliminate_LDFLAGS='/^lib_LDFLAGS[        ]*+=/d'
1177   fi
1178   echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1179   echo "## Process this file with automake to produce Makefile.in."
1180   func_emit_copyright_notice
1181   if test -n "$actioncmd"; then
1182     echo "# Reproduce by: $actioncmd"
1183   fi
1184   echo
1185   uses_subdirs=
1186   {
1187     for module in $modules; do
1188       func_verify_nontests_module
1189       if test -n "$module"; then
1190         {
1191           func_get_automake_snippet "$module" |
1192             sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1193                 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1194             sed -e "$sed_eliminate_LDFLAGS" |
1195             sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1196             sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1197                 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
1198           if test "$module" = 'alloca'; then
1199             echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1200             echo "${libname}_${libext}_DEPENDENCIES += @${perhapsLT}ALLOCA@"
1201           fi
1202         } > amsnippet.tmp
1203         # Skip the contents if its entirely empty.
1204         if grep '[^      ]' amsnippet.tmp > /dev/null ; then
1205           echo "## begin gnulib module $module"
1206           echo
1207           cat amsnippet.tmp
1208           echo "## end   gnulib module $module"
1209           echo
1210         fi
1211         rm -f amsnippet.tmp
1212         # Test whether there are some source files in subdirectories.
1213         for f in `func_get_filelist "$module"`; do
1214           case $f in
1215             lib/*/*.c) uses_subdirs=yes ;;
1216           esac
1217         done
1218       fi
1219     done
1220   } > allsnippets.tmp
1221   if test -z "$makefile_name"; then
1222     # If there are source files in subdirectories, prevent collision of the
1223     # object files (example: hash.c and libxml/hash.c).
1224     subdir_options=
1225     if test -n "$uses_subdirs"; then
1226       subdir_options=' subdir-objects'
1227     fi
1228     echo "AUTOMAKE_OPTIONS = 1.5 gnits${subdir_options}"
1229   fi
1230   echo
1231   if grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1232     # One of the snippets already specifies an installation location for the
1233     # library. Don't confuse automake by saying it should not be installed.
1234     :
1235   else
1236     # By default, the generated library should not be installed.
1237     echo "noinst_${perhapsLT}LIBRARIES $assign $libname.$libext"
1238   fi
1239   echo
1240   echo "${libname}_${libext}_SOURCES ="
1241   # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1242   # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1243   echo "${libname}_${libext}_LIBADD = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1244   echo "${libname}_${libext}_DEPENDENCIES = \$(${macro_prefix}_${perhapsLT}LIBOBJS)"
1245   echo "EXTRA_${libname}_${libext}_SOURCES ="
1246   if test "$libtool" = true; then
1247     echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1248   fi
1249   if test -z "$makefile_name"; then
1250     echo "noinst_HEADERS ="
1251     # Automake versions < 1.9b create an empty pkgdatadir at installation time
1252     # if you specify pkgdata_DATA to empty. This is a workaround.
1253     if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1254       echo "pkgdata_DATA ="
1255     fi
1256     echo "EXTRA_DIST ="
1257     echo "BUILT_SOURCES ="
1258     echo "SUFFIXES ="
1259   fi
1260   echo "MOSTLYCLEANFILES $assign core *.stackdump"
1261   if test -z "$makefile_name"; then
1262     echo "MOSTLYCLEANDIRS ="
1263     echo "CLEANFILES ="
1264     echo "DISTCLEANFILES ="
1265     echo "MAINTAINERCLEANFILES ="
1266     echo
1267     echo "AM_CPPFLAGS ="
1268   fi
1269   echo
1270   cat allsnippets.tmp
1271   echo
1272   echo "mostlyclean-local: mostlyclean-generic"
1273   echo "        @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1274   echo "          if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1275   echo "            echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1276   echo "          fi; \\"
1277   echo "        done"
1278   rm -f allsnippets.tmp
1279 }
1280
1281 # func_emit_tests_Makefile_am
1282 # emits the contents of tests makefile to standard output.
1283 # Input:
1284 # - local_gnulib_dir  from --local-dir
1285 # - modules         list of modules, including dependencies
1286 # - libname         library name
1287 # - makefile_name   from --makefile-name
1288 # - libtool         true if libtool will be used, false or blank otherwise
1289 # - sourcebase      relative directory containing lib source code
1290 # - m4base          relative directory containing autoconf macros
1291 # - testsbase       relative directory containing unit test code
1292 func_emit_tests_Makefile_am ()
1293 {
1294   if test "$libtool" = true; then
1295     libext=la
1296   else
1297     libext=a
1298   fi
1299   if test "$libtool" = true; then
1300     libext=la
1301     sed_eliminate_LDFLAGS=
1302   else
1303     libext=a
1304     sed_eliminate_LDFLAGS='/^lib_LDFLAGS[        ]*+=/d'
1305   fi
1306   testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1307   echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1308   echo "## Process this file with automake to produce Makefile.in."
1309   func_emit_copyright_notice
1310   echo
1311   # Generate dependencies here, since it eases the debugging of test failures.
1312   echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1313   echo
1314   echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1315   echo
1316   (
1317     for module in $modules; do
1318       func_verify_tests_module
1319       if test -n "$module"; then
1320         {
1321           func_get_automake_snippet "$module" |
1322             sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1323                 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1324             sed -e "$sed_eliminate_LDFLAGS" |
1325             sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1326             sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1327                 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
1328         } > amsnippet.tmp
1329         # Skip the contents if its entirely empty.
1330         if grep '[^      ]' amsnippet.tmp > /dev/null ; then
1331           echo "## begin gnulib module $module"
1332           echo
1333           cat amsnippet.tmp
1334           echo "## end   gnulib module $module"
1335           echo
1336         fi
1337         rm -f amsnippet.tmp
1338       fi
1339     done
1340   ) > allsnippets.tmp
1341   # Nothing is being added to SUBDIRS; nevertheless the existence of this
1342   # variable is needed to avoid an error from automake:
1343   #   "AM_GNU_GETTEXT used but SUBDIRS not defined"
1344   echo "SUBDIRS ="
1345   echo "TESTS ="
1346   echo "TESTS_ENVIRONMENT ="
1347   echo "noinst_PROGRAMS ="
1348   echo "check_PROGRAMS ="
1349   echo "noinst_HEADERS ="
1350   if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1351     echo "pkgdata_DATA ="
1352   fi
1353   echo "EXTRA_DIST ="
1354   echo "BUILT_SOURCES ="
1355   echo "SUFFIXES ="
1356   echo "MOSTLYCLEANFILES = core *.stackdump"
1357   echo "MOSTLYCLEANDIRS ="
1358   echo "CLEANFILES ="
1359   echo "DISTCLEANFILES ="
1360   echo "MAINTAINERCLEANFILES ="
1361   echo
1362   echo "AM_CPPFLAGS = \\"
1363   echo "  -I. -I\$(srcdir) \\"
1364   echo "  -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1365   echo "  -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1366   echo
1367   echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1368   echo
1369   cat allsnippets.tmp
1370   echo "# Clean up after Solaris cc."
1371   echo "clean-local:"
1372   echo "        rm -rf SunWS_cache"
1373   echo
1374   echo "mostlyclean-local: mostlyclean-generic"
1375   echo "        @for dir in '' \$(MOSTLYCLEANDIRS); do \\"
1376   echo "          if test -n \"\$\$dir\" && test -d \$\$dir; then \\"
1377   echo "            echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1378   echo "          fi; \\"
1379   echo "        done"
1380   rm -f allsnippets.tmp
1381 }
1382
1383 # func_emit_initmacro_start
1384 # emits the first few statements of the gl_INIT macro to standard output.
1385 # - macro_prefix    prefix of gl_EARLY, gl_INIT macros to use
1386 func_emit_initmacro_start ()
1387 {
1388   echo "  m4_pushdef([AC_LIBOBJ], m4_defn([${macro_prefix}_LIBOBJ]))"
1389   echo "  m4_pushdef([AC_REPLACE_FUNCS], m4_defn([${macro_prefix}_REPLACE_FUNCS]))"
1390 }
1391
1392 # func_emit_initmacro_end
1393 # emits the last few statements of the gl_INIT macro to standard output.
1394 # - macro_prefix    prefix of gl_EARLY, gl_INIT macros to use
1395 func_emit_initmacro_end ()
1396 {
1397   echo "  m4_popdef([AC_REPLACE_FUNCS])"
1398   echo "  m4_popdef([AC_LIBOBJ])"
1399   echo "  AC_CONFIG_COMMANDS_PRE(["
1400   echo "    ${macro_prefix}_libobjs="
1401   echo "    ${macro_prefix}_ltlibobjs="
1402   echo "    if test -n \"\$${macro_prefix}_LIBOBJS\"; then"
1403   echo "      # Remove the extension."
1404   echo "      sed_drop_objext='s/\\.o\$//;s/\\.obj\$//'"
1405   echo "      for i in \`for i in \$${macro_prefix}_LIBOBJS; do echo \"\$i\"; done | sed \"\$sed_drop_objext\" | sort | uniq\`; do"
1406   echo "        ${macro_prefix}_libobjs=\"\$${macro_prefix}_libobjs \$i.\$ac_objext\""
1407   echo "        ${macro_prefix}_ltlibobjs=\"\$${macro_prefix}_ltlibobjs \$i.lo\""
1408   echo "      done"
1409   echo "    fi"
1410   echo "    AC_SUBST([${macro_prefix}_LIBOBJS], [\$${macro_prefix}_libobjs])"
1411   echo "    AC_SUBST([${macro_prefix}_LTLIBOBJS], [\$${macro_prefix}_ltlibobjs])"
1412   echo "  ])"
1413 }
1414
1415 # func_emit_initmacro_done
1416 # emits a few statements after the gl_INIT macro to standard output.
1417 # - macro_prefix    prefix of gl_EARLY, gl_INIT macros to use
1418 func_emit_initmacro_done ()
1419 {
1420   echo
1421   echo "# Like AC_LIBOBJ, except that the module name goes"
1422   echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1423   echo "AC_DEFUN([${macro_prefix}_LIBOBJ],"
1424   echo "  [${macro_prefix}_LIBOBJS=\"\$${macro_prefix}_LIBOBJS \$1.\$ac_objext\"])"
1425   echo
1426   echo "# Like AC_REPLACE_FUNCS, except that the module name goes"
1427   echo "# into ${macro_prefix}_LIBOBJS instead of into LIBOBJS."
1428   echo "AC_DEFUN([${macro_prefix}_REPLACE_FUNCS],"
1429   echo "  [AC_CHECK_FUNCS([\$1], , [${macro_prefix}_LIBOBJ(\$ac_func)])])"
1430 }
1431
1432 # func_import modules
1433 # Uses also the variables
1434 # - destdir         target directory
1435 # - local_gnulib_dir  from --local-dir
1436 # - libname         library name
1437 # - sourcebase      directory relative to destdir where to place source code
1438 # - m4base          directory relative to destdir where to place *.m4 macros
1439 # - docbase         directory relative to destdir where to place doc files
1440 # - testsbase       directory relative to destdir where to place unit test code
1441 # - auxdir          directory relative to destdir where to place build aux files
1442 # - inctests        true if --with-tests was given, blank otherwise
1443 # - avoidlist       list of modules to avoid, from --avoid
1444 # - lgpl            true if library's license shall be LGPL, blank otherwise
1445 # - makefile_name   from --makefile-name
1446 # - libtool         true if --libtool was given, false if --no-libtool was
1447 #                   given, blank otherwise
1448 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1449 # - macro_prefix    prefix of gl_EARLY, gl_INIT macros to use
1450 # - autoconf_minversion  minimum supported autoconf version
1451 # - doit            : if actions shall be executed, false if only to be printed
1452 # - symbolic        true if files should be symlinked, copied otherwise
1453 func_import ()
1454 {
1455   # Get the cached settings.
1456   cached_local_gnulib_dir=
1457   cached_specified_modules=
1458   cached_avoidlist=
1459   cached_sourcebase=
1460   cached_m4base=
1461   cached_docbase=
1462   cached_testsbase=
1463   cached_libname=
1464   cached_lgpl=
1465   cached_makefile_name=
1466   cached_libtool=
1467   cached_macro_prefix=
1468   cached_files=
1469   if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1470     cached_libtool=false
1471     my_sed_traces='
1472       s,#.*$,,
1473       s,^dnl .*$,,
1474       s, dnl .*$,,
1475       /gl_LOCAL_DIR(/ {
1476         s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
1477       }
1478       /gl_MODULES(/ {
1479         s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1480       }
1481       /gl_AVOID(/ {
1482         s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1483       }
1484       /gl_SOURCE_BASE(/ {
1485         s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1486       }
1487       /gl_M4_BASE(/ {
1488         s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1489       }
1490       /gl_DOC_BASE(/ {
1491         s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1492       }
1493       /gl_TESTS_BASE(/ {
1494         s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1495       }
1496       /gl_LIB(/ {
1497         s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1498       }
1499       /gl_LGPL/ {
1500         s,^.*$,cached_lgpl=true,p
1501       }
1502       /gl_MAKEFILE_NAME(/ {
1503         s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
1504       }
1505       /gl_LIBTOOL/ {
1506         s,^.*$,cached_libtool=true,p
1507       }
1508       /gl_MACRO_PREFIX(/ {
1509         s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
1510       }'
1511     eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
1512     if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1513       my_sed_traces='
1514         s,#.*$,,
1515         s,^dnl .*$,,
1516         s, dnl .*$,,
1517         /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
1518           s,^.*$,cached_files=",p
1519           n
1520           ta
1521           :a
1522           s,^\]).*$,",
1523           tb
1524           p
1525           n
1526           ba
1527           :b
1528           p
1529         }'
1530       eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1531     fi
1532   fi
1533
1534   # Merge the cached settings with the specified ones.
1535   # The m4base must be the same as expected from the pathname.
1536   if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1537     func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1538   fi
1539   # The local_gnulib_dir defaults to the cached one. Recall that the cached one
1540   # is relative to $destdir, whereas the one we use is relative to . or absolute.
1541   if test -z "$local_gnulib_dir"; then
1542     if test -n "$cached_local_gnulib_dir"; then
1543       case "$destdir" in
1544         /*)
1545           local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1546         *)
1547           case "$cached_local_gnulib_dir" in
1548             /*)
1549               local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1550             *)
1551               func_relconcat "$destdir" "$cached_local_gnulib_dir"
1552               local_gnulib_dir="$relconcat" ;;
1553           esac ;;
1554       esac
1555     fi
1556   fi
1557   # Append the cached and the specified module names. So that
1558   # "gnulib-tool --import foo" means to add the module foo.
1559   specified_modules="$cached_specified_modules $1"
1560   # Append the cached and the specified avoidlist. This is probably better
1561   # than dropping the cached one when --avoid is specified at least once.
1562   avoidlist=`echo $cached_avoidlist $avoidlist`
1563   # The sourcebase defaults to the cached one.
1564   if test -z "$sourcebase"; then
1565     sourcebase="$cached_sourcebase"
1566     if test -z "$sourcebase"; then
1567       func_fatal_error "missing --source-base option"
1568     fi
1569   fi
1570   # The docbase defaults to the cached one.
1571   if test -z "$docbase"; then
1572     docbase="$cached_docbase"
1573     if test -z "$docbase"; then
1574       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."
1575     fi
1576   fi
1577   # The testsbase defaults to the cached one.
1578   if test -z "$testsbase"; then
1579     testsbase="$cached_testsbase"
1580     if test -z "$testsbase"; then
1581       func_fatal_error "missing --tests-base option"
1582     fi
1583   fi
1584   # The libname defaults to the cached one.
1585   if test -z "$supplied_libname"; then
1586     libname="$cached_libname"
1587     if test -z "$libname"; then
1588       func_fatal_error "missing --lib option"
1589     fi
1590   fi
1591   # Require LGPL if specified either way.
1592   if test -z "$lgpl"; then
1593     lgpl="$cached_lgpl"
1594   fi
1595   # The makefile_name defaults to the cached one.
1596   if test -z "$makefile_name"; then
1597     makefile_name="$cached_makefile_name"
1598   fi
1599   # Use libtool if specified either way, or if guessed.
1600   if test -z "$libtool"; then
1601     if test -n "$cached_m4base"; then
1602       libtool="$cached_libtool"
1603     else
1604       libtool="$guessed_libtool"
1605     fi
1606   fi
1607   # The macro_prefix defaults to the cached one.
1608   if test -z "$macro_prefix"; then
1609     macro_prefix="$cached_macro_prefix"
1610     if test -z "$macro_prefix"; then
1611       func_fatal_error "missing --macro-prefix option"
1612     fi
1613   fi
1614
1615   # Canonicalize the list of specified modules.
1616   specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
1617
1618   # Determine final module list.
1619   modules="$specified_modules"
1620   func_modules_transitive_closure
1621   echo "Module list with included dependencies:"
1622   echo "$modules" | sed -e 's/^/  /'
1623
1624   # Add the dummy module if needed.
1625   func_modules_add_dummy
1626
1627   # If --lgpl, verify that the licenses of modules are compatible.
1628   if test -n "$lgpl"; then
1629     for module in $modules; do
1630       license=`func_get_license $module`
1631       case $license in
1632         LGPL | 'GPLed build tool') ;;
1633         'public domain' | 'unlimited' | 'unmodifiable license text') ;;
1634         *) func_fatal_error "incompatible license on module $module: $license" ;;
1635       esac
1636     done
1637   fi
1638
1639   # Determine script to apply to imported library files.
1640   sed_transform_lib_file=
1641   for module in $modules; do
1642     if test $module = config-h; then
1643       # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
1644       sed_transform_lib_file=$sed_transform_lib_file'
1645         s/^#ifdef[       ]*HAVE_CONFIG_H[        ]*$/#if 1/
1646       '
1647       break
1648     fi
1649   done
1650   if test -n "$lgpl"; then
1651     # Update license.
1652     sed_transform_lib_file=$sed_transform_lib_file'
1653       s/GNU General/GNU Lesser General/g
1654       s/version 2\([ ,]\)/version 2.1\1/g
1655     '
1656   fi
1657
1658   # Determine final file list.
1659   func_modules_to_filelist
1660   echo "File list:"
1661   echo "$files" | sed -e 's/^/  /'
1662
1663   test -n "$files" \
1664     || func_fatal_error "refusing to do nothing"
1665
1666   # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
1667   new_files="$files m4/gnulib-tool.m4"
1668   old_files="$cached_files"
1669   if test -f "$destdir"/$m4base/gnulib-tool.m4; then
1670     func_append old_files " m4/gnulib-tool.m4"
1671   fi
1672
1673   sed_rewrite_old_files="\
1674     s,^build-aux/,$auxdir/,
1675     s,^doc/,$cached_docbase/,
1676     s,^lib/,$cached_sourcebase/,
1677     s,^m4/,$cached_m4base/,
1678     s,^tests/,$cached_testsbase/,"
1679   sed_rewrite_new_files="\
1680     s,^build-aux/,$auxdir/,
1681     s,^doc/,$docbase/,
1682     s,^lib/,$sourcebase/,
1683     s,^m4/,$m4base/,
1684     s,^tests/,$testsbase/,"
1685
1686   # Create directories.
1687   { echo "$sourcebase"
1688     echo "$m4base"
1689     docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
1690     if test -n "$docfiles"; then
1691       echo "$docbase"
1692     fi
1693     if test -n "$inctests"; then
1694       echo "$testsbase"
1695     fi
1696     echo "$auxdir"
1697     for f in $files; do echo $f; done \
1698       | sed -e "$sed_rewrite_new_files" \
1699       | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
1700       | LC_ALL=C sort -u
1701   } > "$tmp"/dirs
1702   { # Rearrange file descriptors. Needed because "while ... done < ..."
1703     # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1704     exec 5<&0 < "$tmp"/dirs
1705     while read d; do
1706       if test ! -d "$destdir/$d"; then
1707         if $doit; then
1708           echo "Creating directory $destdir/$d"
1709           mkdir -p "$destdir/$d" || func_fatal_error "failed"
1710         else
1711           echo "Create directory $destdir/$d"
1712         fi
1713       fi
1714     done
1715     exec 0<&5 5<&-
1716   }
1717
1718   # func_dest_tmpfilename file
1719   # determines the name of a temporary file (file is relative to destdir).
1720   # Sets variable:
1721   #   - tmpfile       absolute filename of the temporary file
1722   func_dest_tmpfilename ()
1723   {
1724     if $doit; then
1725       # Put the new contents of $file in a file in the same directory (needed
1726       # to guarantee that an 'mv' to "$destdir/$file" works).
1727       tmpfile="$destdir/$1.tmp"
1728     else
1729       # Put the new contents of $file in a file in a temporary directory
1730       # (because the directory of "$file" might not exist).
1731       tmpfile="$tmp"/`basename "$1"`.tmp
1732     fi
1733   }
1734
1735   # Copy files or make symbolic links. Remove obsolete files.
1736   delimiter='   '
1737   # Construct a table with 2 columns: rewritten-file-name original-file-name,
1738   # representing the files according to the last gnulib-tool invocation.
1739   for f in $old_files; do echo $f; done \
1740     | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
1741     | LC_ALL=C sort \
1742     > "$tmp"/old-files
1743   # Construct a table with 2 columns: rewritten-file-name original-file-name,
1744   # representing the files after this gnulib-tool invocation.
1745   for f in $new_files; do echo $f; done \
1746     | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
1747     | LC_ALL=C sort \
1748     > "$tmp"/new-files
1749   # First the files that are in old-files, but not in new-files:
1750   sed_take_first_column='s,'"$delimiter"'.*,,'
1751   for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
1752     # Remove the file. Do nothing if the user already removed it.
1753     if test -f "$destdir/$g"; then
1754       if $doit; then
1755         echo "Removing file $g (backup in ${g}~)"
1756         mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1757       else
1758         echo "Remove file $g (backup in ${g}~)"
1759       fi
1760     fi
1761   done
1762   # func_add_or_update handles a file that ought to be present afterwards.
1763   # Uses parameters
1764   # - f             the original file name
1765   # - g             the rewritten file name
1766   # - already_present  nonempty if the file already exists, empty otherwise
1767   func_add_or_update ()
1768   {
1769     func_dest_tmpfilename "$g"
1770     func_lookup_file "$f"
1771     cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
1772     if test -n "$sed_transform_lib_file"; then
1773       case "$f" in
1774         lib/*)
1775           sed -e "$sed_transform_lib_file" \
1776             < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
1777           ;;
1778       esac
1779     fi
1780     if test -f "$destdir/$g"; then
1781       # The file already exists.
1782       if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1783         : # The file has not changed.
1784       else
1785         # Replace the file.
1786         if $doit; then
1787           if test -n "$already_present"; then
1788             echo "Updating file $g (backup in ${g}~)"
1789           else
1790             echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
1791           fi
1792           mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1793           if test -n "$symbolic" && test -z "$lookedup_tmp" \
1794              && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1795             func_ln_if_changed "$lookedup_file" "$destdir/$g"
1796           else
1797             mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1798           fi
1799         else
1800           if test -n "$already_present"; then
1801             echo "Update file $g (backup in ${g}~)"
1802           else
1803             echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
1804           fi
1805         fi
1806       fi
1807     else
1808       # Install the file.
1809       # Don't protest if the file should be there but isn't: it happens
1810       # frequently that developers don't put autogenerated files into CVS.
1811       if $doit; then
1812         echo "Copying file $g"
1813         if test -n "$symbolic" && test -z "$lookedup_tmp" \
1814            && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1815           func_ln_if_changed "$lookedup_file" "$destdir/$g"
1816         else
1817           mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1818         fi
1819       else
1820         echo "Copy file $g"
1821       fi
1822     fi
1823     rm -f "$tmpfile"
1824   }
1825   # Then the files that are in new-files, but not in old-files:
1826   sed_take_last_column='s,^.*'"$delimiter"',,'
1827   already_present=
1828   LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
1829     | sed -e "$sed_take_last_column" \
1830     | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
1831   { # Rearrange file descriptors. Needed because "while ... done < ..."
1832     # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1833     exec 5<&0 < "$tmp"/added-files
1834     while read g f; do
1835       func_add_or_update
1836     done
1837     exec 0<&5 5<&-
1838   }
1839   # Then the files that are in new-files and in old-files:
1840   already_present=true
1841   LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
1842     | sed -e "$sed_take_last_column" \
1843     | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
1844   { # Rearrange file descriptors. Needed because "while ... done < ..."
1845     # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1846     exec 5<&0 < "$tmp"/kept-files
1847     while read g f; do
1848       func_add_or_update
1849     done
1850     exec 0<&5 5<&-
1851   }
1852
1853   # Command-line invocation printed in a comment in generated gnulib-cache.m4.
1854   actioncmd="gnulib-tool --import"
1855   func_append actioncmd " --dir=$destdir"
1856   if test -n "$local_gnulib_dir"; then
1857     func_append actioncmd " --local-dir=$local_gnulib_dir"
1858   fi
1859   func_append actioncmd " --lib=$libname"
1860   func_append actioncmd " --source-base=$sourcebase"
1861   func_append actioncmd " --m4-base=$m4base"
1862   func_append actioncmd " --doc-base=$docbase"
1863   func_append actioncmd " --aux-dir=$auxdir"
1864   for module in $avoidlist; do
1865     func_append actioncmd " --avoid=$module"
1866   done
1867   if test -n "$lgpl"; then
1868     func_append actioncmd " --lgpl"
1869   fi
1870   if test -n "$makefile_name"; then
1871     func_append actioncmd " --makefile-name=$makefile_name"
1872   fi
1873   if test "$libtool" = true; then
1874     func_append actioncmd " --libtool"
1875   else
1876     func_append actioncmd " --no-libtool"
1877   fi
1878   func_append actioncmd " --macro-prefix=$macro_prefix"
1879   func_append actioncmd " `echo $specified_modules`"
1880
1881   # Default the makefile name to Makefile.am.
1882   if test -n "$makefile_name"; then
1883     makefile_am=$makefile_name
1884   else
1885     makefile_am=Makefile.am
1886   fi
1887
1888   # Create library makefile.
1889   func_dest_tmpfilename $sourcebase/$makefile_am
1890   func_emit_lib_Makefile_am > "$tmpfile"
1891   if test -f "$destdir"/$sourcebase/$makefile_am; then
1892     if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
1893       rm -f "$tmpfile"
1894     else
1895       if $doit; then
1896         echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
1897         mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
1898         mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
1899       else
1900         echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
1901         rm -f "$tmpfile"
1902       fi
1903     fi
1904   else
1905     if $doit; then
1906       echo "Creating $sourcebase/$makefile_am"
1907       mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
1908     else
1909       echo "Create $sourcebase/$makefile_am"
1910       rm -f "$tmpfile"
1911     fi
1912   fi
1913
1914   # Create m4/gnulib-cache.m4.
1915   func_dest_tmpfilename $m4base/gnulib-cache.m4
1916   (
1917     func_emit_copyright_notice
1918     echo "#"
1919     echo "# This file represents the specification of how gnulib-tool is used."
1920     echo "# It acts as a cache: It is written and read by gnulib-tool."
1921     echo "# In projects using CVS, this file is meant to be stored in CVS,"
1922     echo "# like the configure.ac and various Makefile.am files."
1923     echo
1924     echo
1925     echo "# Specification in the form of a command-line invocation:"
1926     echo "#   $actioncmd"
1927     echo
1928     echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
1929     # Store the local_gnulib_dir relative to destdir.
1930     case "$local_gnulib_dir" in
1931       "" | /*)
1932         relative_local_gnulib_dir="$local_gnulib_dir" ;;
1933       * )
1934         case "$destdir" in
1935           /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
1936           *)
1937             # destdir, local_gnulib_dir are both relative.
1938             func_relativize "$destdir" "$local_gnulib_dir"
1939             relative_local_gnulib_dir="$reldir" ;;
1940         esac ;;
1941     esac
1942     echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
1943     echo "gl_MODULES(["`echo $specified_modules`"])"
1944     echo "gl_AVOID([$avoidlist])"
1945     echo "gl_SOURCE_BASE([$sourcebase])"
1946     echo "gl_M4_BASE([$m4base])"
1947     echo "gl_DOC_BASE([$docbase])"
1948     echo "gl_TESTS_BASE([$testsbase])"
1949     echo "gl_LIB([$libname])"
1950     test -z "$lgpl" || echo "gl_LGPL"
1951     echo "gl_MAKEFILE_NAME([$makefile_name])"
1952     if test "$libtool" = true; then
1953       echo "gl_LIBTOOL"
1954     fi
1955     echo "gl_MACRO_PREFIX([$macro_prefix])"
1956   ) > "$tmpfile"
1957   if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1958     if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
1959       rm -f "$tmpfile"
1960     else
1961       if $doit; then
1962         echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1963         mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
1964         mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
1965       else
1966         echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1967         if false; then
1968           cat "$tmpfile"
1969           echo
1970           echo "# gnulib-cache.m4 ends here"
1971         fi
1972         rm -f "$tmpfile"
1973       fi
1974     fi
1975   else
1976     if $doit; then
1977       echo "Creating $m4base/gnulib-cache.m4"
1978       mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
1979     else
1980       echo "Create $m4base/gnulib-cache.m4"
1981       cat "$tmpfile"
1982       rm -f "$tmpfile"
1983     fi
1984   fi
1985
1986   # Create m4/gnulib-comp.m4.
1987   func_dest_tmpfilename $m4base/gnulib-comp.m4
1988   (
1989     echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
1990     func_emit_copyright_notice
1991     echo "#"
1992     echo "# This file represents the compiled summary of the specification in"
1993     echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
1994     echo "# to be invoked from configure.ac."
1995     echo "# In projects using CVS, this file can be treated like other built files."
1996     echo
1997     echo
1998     echo "# This macro should be invoked from $configure_ac, in the section"
1999     echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
2000     echo "# any checks for libraries, header files, types and library functions."
2001     echo "AC_DEFUN([${macro_prefix}_EARLY],"
2002     echo "["
2003     echo "  m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2004     echo "  m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2005     echo "  m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2006     echo "  m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2007     echo "  AC_REQUIRE([AC_PROG_RANLIB])"
2008     if test -n "$uses_subdirs"; then
2009       echo "  AC_REQUIRE([AM_PROG_CC_C_O])"
2010     fi
2011     if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2012       echo "  AC_REQUIRE([AC_GNU_SOURCE])"
2013     fi
2014     if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2015       echo "  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])"
2016     fi
2017     if grep gl_LOCK "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
2018       echo "  AC_REQUIRE([gl_LOCK_EARLY])"
2019     fi
2020     echo "])"
2021     echo
2022     echo "# This macro should be invoked from $configure_ac, in the section"
2023     echo "# \"Check for header files, types and library functions\"."
2024     echo "AC_DEFUN([${macro_prefix}_INIT],"
2025     echo "["
2026     func_emit_initmacro_start
2027     if test "$libtool" = true; then
2028       echo "  AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2029       echo "  gl_cond_libtool=true"
2030     else
2031       echo "  AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2032       echo "  gl_cond_libtool=false"
2033       echo "  gl_libdeps="
2034       echo "  gl_ltlibdeps="
2035     fi
2036     echo "  gl_source_base='$sourcebase'"
2037     if test "$auxdir" != "build-aux"; then
2038       sed_replace_build_aux='
2039         :a
2040         /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2041           s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2042           ba
2043         }'
2044       sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2045     else
2046       sed_replace_build_aux=
2047     fi
2048     for module in $modules; do
2049       func_verify_module
2050       if test -n "$module"; then
2051         func_get_autoconf_snippet "$module" \
2052           | sed -e '/^$/d;' -e 's/^/  /' \
2053                 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
2054                 -e "$sed_replace_build_aux"
2055         if test "$module" = 'alloca' && test "$libtool" = true; then
2056           echo 'changequote(,)dnl'
2057           echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
2058           echo 'changequote([, ])dnl'
2059           echo 'AC_SUBST([LTALLOCA])'
2060         fi
2061       fi
2062     done
2063     # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2064     # created using libtool, because libtool already handles the dependencies.
2065     if test "$libtool" != true; then
2066       libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2067       echo "  ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2068       echo "  AC_SUBST([${libname_upper}_LIBDEPS])"
2069       echo "  ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2070       echo "  AC_SUBST([${libname_upper}_LTLIBDEPS])"
2071     fi
2072     func_emit_initmacro_end
2073     echo "])"
2074     func_emit_initmacro_done
2075     echo
2076     echo "# This macro records the list of files which have been installed by"
2077     echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
2078     echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
2079     echo "$files" | sed -e 's,^,  ,'
2080     echo "])"
2081   ) > "$tmpfile"
2082   if test -f "$destdir"/$m4base/gnulib-comp.m4; then
2083     if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
2084       rm -f "$tmpfile"
2085     else
2086       if $doit; then
2087         echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2088         mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
2089         mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2090       else
2091         echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
2092         if false; then
2093           cat "$tmpfile"
2094           echo
2095           echo "# gnulib-comp.m4 ends here"
2096         fi
2097         rm -f "$tmpfile"
2098       fi
2099     fi
2100   else
2101     if $doit; then
2102       echo "Creating $m4base/gnulib-comp.m4"
2103       mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
2104     else
2105       echo "Create $m4base/gnulib-comp.m4"
2106       cat "$tmpfile"
2107       rm -f "$tmpfile"
2108     fi
2109   fi
2110
2111   if test -n "$inctests"; then
2112     # Create tests makefile.
2113     func_dest_tmpfilename $testsbase/$makefile_am
2114     func_emit_tests_Makefile_am > "$tmpfile"
2115     if test -f "$destdir"/$testsbase/$makefile_am; then
2116       if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
2117         rm -f "$tmpfile"
2118       else
2119         if $doit; then
2120           echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2121           mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
2122           mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2123         else
2124           echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
2125           rm -f "$tmpfile"
2126         fi
2127       fi
2128     else
2129       if $doit; then
2130         echo "Creating $testsbase/$makefile_am"
2131         mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
2132       else
2133         echo "Create $testsbase/$makefile_am"
2134         rm -f "$tmpfile"
2135       fi
2136     fi
2137   fi
2138
2139   echo "Finished."
2140   echo
2141   echo "You may need to add #include directives for the following .h files."
2142   # First the #include <...> directives without #ifs, sorted for convenience,
2143   # then the #include "..." directives without #ifs, sorted for convenience,
2144   # then the #include directives that are surrounded by #ifs. Not sorted.
2145   for module in $modules; do
2146     include_directive=`func_get_include_directive "$module"`
2147     case "$nl$include_directive" in
2148       *"$nl#if"*)
2149         echo "$include_directive" 1>&5
2150         ;;
2151       *)
2152         echo "$include_directive" | grep -v 'include "' 1>&6
2153         echo "$include_directive" | grep 'include "' 1>&7
2154         ;;
2155     esac
2156   done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
2157   (
2158    LC_ALL=C sort -u "$tmp"/include-angles
2159    LC_ALL=C sort -u "$tmp"/include-quotes
2160    cat "$tmp"/include-if
2161   ) | sed -e '/^$/d' -e 's/^/  /'
2162   rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
2163
2164   echo
2165   echo "Don't forget to"
2166   if test "$makefile_am" = Makefile.am; then
2167     echo "  - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2168   else
2169     echo "  - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
2170   fi
2171   if test -n "$inctests"; then
2172     if test "$makefile_am" = Makefile.am; then
2173       echo "  - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2174     else
2175       echo "  - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
2176     fi
2177   fi
2178   if test "$makefile_am" = Makefile.am; then
2179     sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
2180     sourcebase_base=`basename "$sourcebase"`
2181     echo "  - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
2182   fi
2183   if test -n "$inctests"; then
2184     if test "$makefile_am" = Makefile.am; then
2185       testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
2186       testsbase_base=`basename "$testsbase"`
2187       echo "  - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
2188     fi
2189   fi
2190   echo "  - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
2191   echo "  - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
2192   echo "  - invoke ${macro_prefix}_INIT in $configure_ac."
2193 }
2194
2195 # func_create_testdir testdir modules
2196 # Input:
2197 # - local_gnulib_dir  from --local-dir
2198 # - auxdir          directory relative to destdir where to place build aux files
2199 func_create_testdir ()
2200 {
2201   testdir="$1"
2202   modules="$2"
2203   if test -z "$modules"; then
2204     # All modules together.
2205     # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2206     # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2207     # Except ftruncate, mountlist, which abort the configuration on mingw. FIXME.
2208     modules=`func_all_modules`
2209     modules=`for m in $modules; do case $m in config-h | fnmatch-posix | ftruncate | mountlist) ;; *) echo $m;; esac; done`
2210   fi
2211   modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
2212
2213   # Subdirectory names.
2214   sourcebase=gllib
2215   m4base=glm4
2216   docbase=gldoc
2217   testsbase=gltests
2218   macro_prefix=gl
2219
2220   # Determine final module list.
2221   func_modules_transitive_closure
2222   echo "Module list with included dependencies:"
2223   echo "$modules" | sed -e 's/^/  /'
2224
2225   # Add the dummy module if needed.
2226   func_modules_add_dummy
2227
2228   # Determine final file list.
2229   func_modules_to_filelist
2230   echo "File list:"
2231   echo "$files" | sed -e 's/^/  /'
2232
2233   sed_rewrite_files="\
2234     s,^build-aux/,$auxdir/,
2235     s,^doc/,$docbase/,
2236     s,^lib/,$sourcebase/,
2237     s,^m4/,$m4base/,
2238     s,^tests/,$testsbase/,"
2239
2240   # Create directories.
2241   for f in $files; do echo $f; done \
2242     | sed -e "$sed_rewrite_files" \
2243     | sed -n -e 's,^\(.*\)/[^/]*,\1,p' \
2244     | LC_ALL=C sort -u \
2245     > "$tmp"/dirs
2246   { # Rearrange file descriptors. Needed because "while ... done < ..."
2247     # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2248     exec 5<&0 < "$tmp"/dirs
2249     while read d; do
2250       mkdir -p "$testdir/$d"
2251     done
2252     exec 0<&5 5<&-
2253   }
2254
2255   # Copy files or make symbolic links.
2256   delimiter='   '
2257   for f in $files; do echo $f; done \
2258     | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
2259     | LC_ALL=C sort \
2260     > "$tmp"/files
2261   { # Rearrange file descriptors. Needed because "while ... done < ..."
2262     # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2263     exec 5<&0 < "$tmp"/files
2264     while read g f; do
2265       func_lookup_file "$f"
2266       if test -n "$lookedup_tmp"; then
2267         cp -p "$lookedup_file" "$testdir/$g"
2268       else
2269         ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
2270         if test -z "$symbolic"; then
2271           cp -p "$lookedup_file" "$testdir/$g"
2272         else
2273           func_ln "$lookedup_file" "$testdir/$g"
2274         fi
2275       fi
2276     done
2277     exec 0<&5 5<&-
2278   }
2279
2280   # Create $sourcebase/Makefile.am.
2281   mkdir -p "$testdir/$sourcebase"
2282   func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
2283
2284   # Create $m4base/Makefile.am.
2285   mkdir -p "$testdir/$m4base"
2286   (echo "## Process this file with automake to produce Makefile.in."
2287    echo
2288    echo "EXTRA_DIST ="
2289    for f in $files; do
2290      case "$f" in
2291        m4/* )
2292          echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
2293      esac
2294    done
2295   ) > "$testdir/$m4base/Makefile.am"
2296
2297   subdirs="$sourcebase $m4base"
2298   subdirs_with_configure_ac=""
2299
2300   if false && test -f "$testdir"/$m4base/gettext.m4; then
2301     # Avoid stupid error message from automake:
2302     # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
2303     mkdir -p "$testdir/po"
2304     (echo "## Process this file with automake to produce Makefile.in."
2305     ) > "$testdir/po/Makefile.am"
2306     func_append subdirs " po"
2307   fi
2308
2309   if test -n "$inctests"; then
2310     test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
2311     # Create $testsbase/Makefile.am.
2312     func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
2313     # Create $testsbase/configure.ac.
2314     (echo "# Process this file with autoconf to produce a configure script."
2315      echo "AC_INIT([dummy], [0])"
2316      echo "AC_CONFIG_AUX_DIR([../$auxdir])"
2317      echo "AM_INIT_AUTOMAKE"
2318      echo
2319      echo "AM_CONFIG_HEADER([config.h])"
2320      echo
2321      echo "AC_PROG_CC"
2322      echo "AC_PROG_INSTALL"
2323      echo "AC_PROG_MAKE_SET"
2324      echo "AC_PROG_RANLIB"
2325      echo
2326      if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2327        echo "AC_GNU_SOURCE"
2328        echo
2329      fi
2330      if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2331        echo "gl_USE_SYSTEM_EXTENSIONS"
2332        echo
2333      fi
2334      if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2335        echo "gl_LOCK_EARLY"
2336        echo
2337      fi
2338      if test "$libtool" = true; then
2339        echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2340        echo "gl_cond_libtool=true"
2341      else
2342        echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2343        echo "gl_cond_libtool=false"
2344        echo "gl_libdeps="
2345        echo "gl_ltlibdeps="
2346      fi
2347      echo "gl_source_base='$testsbase'"
2348      # Wrap the set of autoconf snippets into an autoconf macro that is then
2349      # invoked. This is needed because autoconf does not support AC_REQUIRE
2350      # at the top level:
2351      #   error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2352      # but we want the AC_REQUIRE to have its normal meaning (provide one
2353      # expansion of the required macro before the current point, and only one
2354      # expansion total).
2355      echo "AC_DEFUN([gl_INIT], ["
2356      func_emit_initmacro_start
2357      sed_replace_build_aux='
2358        :a
2359        /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2360          s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
2361          ba
2362        }'
2363      sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2364      # We don't have explicit ordering constraints between the various
2365      # autoconf snippets. It's cleanest to put those of the library before
2366      # those of the tests.
2367      for module in $modules; do
2368        func_verify_nontests_module
2369        if test -n "$module"; then
2370          func_get_autoconf_snippet "$module" \
2371            | sed -e "$sed_replace_build_aux"
2372        fi
2373      done
2374      for module in $modules; do
2375        func_verify_tests_module
2376        if test -n "$module"; then
2377          func_get_autoconf_snippet "$module" \
2378            | sed -e "$sed_replace_build_aux"
2379        fi
2380      done
2381      # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2382      # created using libtool, because libtool already handles the dependencies.
2383      if test "$libtool" != true; then
2384        libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2385        echo "  ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2386        echo "  AC_SUBST([${libname_upper}_LIBDEPS])"
2387        echo "  ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2388        echo "  AC_SUBST([${libname_upper}_LTLIBDEPS])"
2389      fi
2390      func_emit_initmacro_end
2391      echo "])"
2392      func_emit_initmacro_done
2393      echo
2394      echo "gl_INIT"
2395      echo
2396      # Usually $testsbase/config.h will be a superset of config.h. Verify this
2397      # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
2398      echo "AH_TOP([#include \"../config.h\"])"
2399      echo
2400      echo "AC_OUTPUT([Makefile])"
2401     ) > "$testdir/$testsbase/configure.ac"
2402     func_append subdirs " $testsbase"
2403     subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
2404   fi
2405
2406   # Create Makefile.am.
2407   (echo "## Process this file with automake to produce Makefile.in."
2408    echo
2409    echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2410    echo
2411    echo "SUBDIRS = $subdirs"
2412    echo
2413    echo "ACLOCAL_AMFLAGS = -I $m4base"
2414   ) > "$testdir/Makefile.am"
2415
2416   # Create configure.ac.
2417   (echo "# Process this file with autoconf to produce a configure script."
2418    echo "AC_INIT([dummy], [0])"
2419    if test "$auxdir" != "."; then
2420      echo "AC_CONFIG_AUX_DIR([$auxdir])"
2421    fi
2422    echo "AM_INIT_AUTOMAKE"
2423    echo
2424    echo "AM_CONFIG_HEADER([config.h])"
2425    echo
2426    echo "AC_PROG_CC"
2427    echo "AC_PROG_INSTALL"
2428    echo "AC_PROG_MAKE_SET"
2429    echo
2430    echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2431    echo "m4_pattern_allow([^gl_ES\$])dnl a valid locale name"
2432    echo "m4_pattern_allow([^gl_LIBOBJS\$])dnl a variable"
2433    echo "m4_pattern_allow([^gl_LTLIBOBJS\$])dnl a variable"
2434    echo
2435    echo "AC_PROG_RANLIB"
2436    echo
2437    if test -n "$uses_subdirs"; then
2438      echo "AM_PROG_CC_C_O"
2439      echo
2440    fi
2441    if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2442      echo "AC_GNU_SOURCE"
2443      echo
2444    fi
2445    if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2446      echo "gl_USE_SYSTEM_EXTENSIONS"
2447      echo
2448    fi
2449    if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2450      echo "gl_LOCK_EARLY"
2451      echo
2452    fi
2453    if test "$libtool" = true; then
2454      echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2455      echo "gl_cond_libtool=true"
2456    else
2457      echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2458      echo "gl_cond_libtool=false"
2459      echo "gl_libdeps="
2460      echo "gl_ltlibdeps="
2461    fi
2462    echo "gl_source_base='$sourcebase'"
2463    # Wrap the set of autoconf snippets into an autoconf macro that is then
2464    # invoked. This is needed because autoconf does not support AC_REQUIRE
2465    # at the top level:
2466    #   error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2467    # but we want the AC_REQUIRE to have its normal meaning (provide one
2468    # expansion of the required macro before the current point, and only one
2469    # expansion total).
2470    echo "AC_DEFUN([gl_INIT], ["
2471    func_emit_initmacro_start
2472    if test "$auxdir" != "build-aux"; then
2473      sed_replace_build_aux='
2474        :a
2475        /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2476          s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2477          ba
2478        }'
2479      sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2480    else
2481      sed_replace_build_aux=
2482    fi
2483    for module in $modules; do
2484      func_verify_nontests_module
2485      if test -n "$module"; then
2486        func_get_autoconf_snippet "$module" \
2487          | sed -e "$sed_replace_build_aux"
2488      fi
2489    done
2490    # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2491    # created using libtool, because libtool already handles the dependencies.
2492    if test "$libtool" != true; then
2493      libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2494      echo "  ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2495      echo "  AC_SUBST([${libname_upper}_LIBDEPS])"
2496      echo "  ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2497      echo "  AC_SUBST([${libname_upper}_LTLIBDEPS])"
2498    fi
2499    func_emit_initmacro_end
2500    echo "])"
2501    func_emit_initmacro_done
2502    echo
2503    echo "gl_INIT"
2504    echo
2505    if test -n "$subdirs_with_configure_ac"; then
2506      echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
2507    fi
2508    makefiles="Makefile"
2509    for d in $subdirs; do
2510      # For subdirs that have a configure.ac by their own, it's the subdir's
2511      # configure.ac which creates the subdir's Makefile.am, not this one.
2512      case " $subdirs_with_configure_ac " in
2513        *" $d "*) ;;
2514        *) func_append makefiles " $d/Makefile" ;;
2515      esac
2516    done
2517    echo "AC_OUTPUT([$makefiles])"
2518   ) > "$testdir/configure.ac"
2519
2520   # Create autogenerated files.
2521   (cd "$testdir"
2522    # Do not use "${AUTORECONF} --force --install", because it may invoke
2523    # autopoint, which brings in older versions of some of our .m4 files.
2524    if test -f $m4base/gettext.m4; then
2525      echo "executing ${AUTOPOINT} --force"
2526      ${AUTOPOINT} --force || func_exit 1
2527      for f in $m4base/*.m4~; do
2528        mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2529      done
2530    fi
2531    echo "executing ${ACLOCAL} -I $m4base"
2532    ${ACLOCAL} -I $m4base || func_exit 1
2533    if ! test -d build-aux; then
2534      echo "executing mkdir build-aux"
2535      mkdir build-aux || func_exit 1
2536    fi
2537    echo "executing ${AUTOCONF}"
2538    ${AUTOCONF} || func_exit 1
2539    echo "executing ${AUTOHEADER}"
2540    ${AUTOHEADER} || func_exit 1
2541    echo "executing ${AUTOMAKE} --add-missing --copy"
2542    ${AUTOMAKE} --add-missing --copy || func_exit 1
2543   ) || func_exit 1
2544   if test -n "$inctests"; then
2545     # Create autogenerated files.
2546     (cd "$testdir/$testsbase" || func_exit 1
2547      # Do not use "${AUTORECONF} --force --install", because it may invoke
2548      # autopoint, which brings in older versions of some of our .m4 files.
2549      if test -f ../$m4base/gettext.m4; then
2550        echo "executing ${AUTOPOINT} --force"
2551        ${AUTOPOINT} --force || func_exit 1
2552        for f in ../$m4base/*.m4~; do
2553          mv -f $f `echo $f | sed -e 's,~$,,'` || func_exit 1
2554        done
2555      fi
2556      echo "executing ${ACLOCAL} -I ../$m4base"
2557      ${ACLOCAL} -I ../$m4base || func_exit 1
2558      if ! test -d ../build-aux; then
2559        echo "executing mkdir ../build-aux"
2560        mkdir ../build-aux
2561      fi
2562      echo "executing ${AUTOCONF}"
2563      ${AUTOCONF} || func_exit 1
2564      echo "executing ${AUTOHEADER}"
2565      ${AUTOHEADER} || func_exit 1
2566      echo "executing ${AUTOMAKE} --add-missing --copy"
2567      ${AUTOMAKE} --add-missing --copy || func_exit 1
2568     ) || func_exit 1
2569   fi
2570   if grep '^BUILT_SOURCES *+=' "$testdir/$sourcebase/Makefile.am" > /dev/null; then
2571     (cd "$testdir"
2572      ./configure || func_exit 1
2573        cd "$sourcebase"
2574        echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
2575        make built_sources || func_exit 1
2576        cd ..
2577      make distclean || func_exit 1
2578     ) || func_exit 1
2579   fi
2580 }
2581
2582 # func_create_megatestdir megatestdir allmodules
2583 # Input:
2584 # - local_gnulib_dir  from --local-dir
2585 # - auxdir          directory relative to destdir where to place build aux files
2586 func_create_megatestdir ()
2587 {
2588   megatestdir="$1"
2589   allmodules="$2"
2590   if test -z "$allmodules"; then
2591     allmodules=`func_all_modules`
2592   fi
2593
2594   megasubdirs=
2595   # First, all modules one by one.
2596   for onemodule in $allmodules; do
2597     func_create_testdir "$megatestdir/$onemodule" $onemodule
2598     func_append megasubdirs "$onemodule "
2599   done
2600   # Then, all modules all together.
2601   # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2602   # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2603   allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
2604   func_create_testdir "$megatestdir/ALL" "$allmodules"
2605   func_append megasubdirs "ALL"
2606
2607   # Create Makefile.am.
2608   (echo "## Process this file with automake to produce Makefile.in."
2609    echo
2610    echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2611    echo
2612    echo "SUBDIRS = $megasubdirs"
2613   ) > "$megatestdir/Makefile.am"
2614
2615   # Create configure.ac.
2616   (echo "# Process this file with autoconf to produce a configure script."
2617    echo "AC_INIT([dummy], [0])"
2618    if test "$auxdir" != "."; then
2619      echo "AC_CONFIG_AUX_DIR([$auxdir])"
2620    fi
2621    echo "AM_INIT_AUTOMAKE"
2622    echo
2623    echo "AC_PROG_MAKE_SET"
2624    echo
2625    echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
2626    echo "AC_OUTPUT([Makefile])"
2627   ) > "$megatestdir/configure.ac"
2628
2629   # Create autogenerated files.
2630   (cd "$megatestdir"
2631    # Do not use "${AUTORECONF} --install", because autoreconf operates
2632    # recursively, but the subdirectories are already finished, therefore
2633    # calling autoreconf here would only waste lots of CPU time.
2634    echo "executing ${ACLOCAL}"
2635    ${ACLOCAL} || func_exit 1
2636    echo "executing mkdir build-aux"
2637    mkdir build-aux
2638    echo "executing ${AUTOCONF}"
2639    ${AUTOCONF} || func_exit 1
2640    echo "executing ${AUTOMAKE} --add-missing --copy"
2641    ${AUTOMAKE} --add-missing --copy || func_exit 1
2642   ) || func_exit 1
2643 }
2644
2645 case $mode in
2646   "" )
2647     func_fatal_error "no mode specified" ;;
2648
2649   list )
2650     func_all_modules
2651     ;;
2652
2653   import | update )
2654
2655     # Where to import.
2656     if test -z "$destdir"; then
2657       destdir=.
2658     fi
2659     test -d "$destdir" \
2660       || func_fatal_error "destination directory does not exist: $destdir"
2661
2662     # Prefer configure.ac to configure.in.
2663     if test -f "$destdir"/configure.ac; then
2664       configure_ac="$destdir/configure.ac"
2665     else
2666       if test -f "$destdir"/configure.in; then
2667         configure_ac="$destdir/configure.in"
2668       else
2669         func_fatal_error "cannot find $destdir/configure.ac"
2670       fi
2671     fi
2672
2673     # Analyze configure.ac.
2674     guessed_auxdir="."
2675     guessed_libtool=false
2676     my_sed_traces='
2677       s,#.*$,,
2678       s,^dnl .*$,,
2679       s, dnl .*$,,
2680       /AC_CONFIG_AUX_DIR/ {
2681         s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
2682       }
2683       /A[CM]_PROG_LIBTOOL/ {
2684         s,^.*$,guessed_libtool=true,p
2685       }'
2686     eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
2687
2688     if test -z "$auxdir"; then
2689       auxdir="$guessed_auxdir"
2690     fi
2691
2692     # Determine where to apply func_import.
2693     if test -n "$m4base"; then
2694       # Apply func_import to a particular gnulib directory.
2695       # Any number of additional modules can be given.
2696       if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
2697         # First use of gnulib in the given m4base.
2698         test -n "$supplied_libname" || supplied_libname=true
2699         test -n "$sourcebase" || sourcebase="lib"
2700         test -n "$docbase" || docbase="doc"
2701         test -n "$testsbase" || testsbase="tests"
2702         test -n "$macro_prefix" || macro_prefix="gl"
2703       fi
2704       func_import "$*"
2705     else
2706       # Apply func_import to all gnulib directories.
2707       # To get this list of directories, look at Makefile.am. (Not at
2708       # configure, because it may be omitted from CVS. Also, don't run
2709       # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
2710       m4dirs=
2711       m4dirs_count=0
2712       if test -f "$destdir"/Makefile.am; then
2713         aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[         ]*=' "$destdir"/Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[       ]*=\(.*\)$/\1/'`
2714         m4dir_is_next=
2715         for arg in $aclocal_amflags; do
2716           if test -n "$m4dir_is_next"; then
2717             # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
2718             case "$arg" in
2719               /*) ;;
2720               *)
2721                 if test -f "$destdir/$arg"/gnulib-cache.m4; then
2722                   func_append m4dirs " $arg"
2723                   m4dirs_count=`expr $m4dirs_count + 1`
2724                 fi
2725                 ;;
2726             esac
2727           else
2728             if test "X$arg" = "X-I"; then
2729               m4dir_is_next=yes
2730             else
2731               m4dir_is_next=
2732             fi
2733           fi
2734         done
2735       else
2736         # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
2737         if test -f "$destdir"/aclocal.m4; then
2738           sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
2739           sedexpr2='s,^[^/]*$,.,'
2740           sedexpr3='s,/[^/]*$,,'
2741           m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
2742           m4dirs_count=`echo "$m4dirs" | wc -l`
2743         fi
2744       fi
2745       if test $m4dirs_count = 0; then
2746         # First use of gnulib in a package.
2747         # Any number of additional modules can be given.
2748         test -n "$supplied_libname" || supplied_libname=true
2749         test -n "$sourcebase" || sourcebase="lib"
2750         m4base="m4"
2751         test -n "$docbase" || docbase="doc"
2752         test -n "$testsbase" || testsbase="tests"
2753         test -n "$macro_prefix" || macro_prefix="gl"
2754         func_import "$*"
2755       else
2756         if test $m4dirs_count = 1; then
2757           # There's only one use of gnulib here. Assume the user means it.
2758           # Any number of additional modules can be given.
2759           for m4base in $m4dirs; do
2760             func_import "$*"
2761           done
2762         else
2763           # Ambiguous - guess what the user meant.
2764           if test $# = 0; then
2765             # No further arguments. Guess the user wants to update all of them.
2766             for m4base in $m4dirs; do
2767               # Perform func_import in a subshell, so that variable values
2768               # such as
2769               #   local_gnulib_dir, avoidlist, sourcebase, m4base, docbase,
2770               #   testsbase, libname, lgpl, makefile_name, libtool, macro_prefix
2771               # don't propagate from one directory to another.
2772               (func_import) || func_exit 1
2773             done
2774           else
2775             # Really ambiguous.
2776             func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
2777           fi
2778         fi
2779       fi
2780     fi
2781     ;;
2782
2783   create-testdir )
2784     if test -z "$destdir"; then
2785       func_fatal_error "please specify --dir option"
2786     fi
2787     mkdir "$destdir"
2788     test -d "$destdir" \
2789       || func_fatal_error "could not create destination directory"
2790     test -n "$auxdir" || auxdir="build-aux"
2791     func_create_testdir "$destdir" "$*"
2792     ;;
2793
2794   create-megatestdir )
2795     if test -z "$destdir"; then
2796       func_fatal_error "please specify --dir option"
2797     fi
2798     mkdir "$destdir" || func_fatal_error "could not create destination directory"
2799     test -n "$auxdir" || auxdir="build-aux"
2800     func_create_megatestdir "$destdir" "$*"
2801     ;;
2802
2803   test )
2804     test -n "$destdir" || destdir=testdir$$
2805     mkdir "$destdir" || func_fatal_error "could not create destination directory"
2806     test -n "$auxdir" || auxdir="build-aux"
2807     func_create_testdir "$destdir" "$*"
2808     cd "$destdir"
2809       mkdir build
2810       cd build
2811         ../configure || func_exit 1
2812         make || func_exit 1
2813         make check || func_exit 1
2814         make distclean || func_exit 1
2815         remaining=`find . -type f -print`
2816         if test -n "$remaining"; then
2817           echo "Remaining files:" $remaining 1>&2
2818           echo "gnulib-tool: *** Stop." 1>&2
2819           func_exit 1
2820         fi
2821       cd ..
2822     cd ..
2823     rm -rf "$destdir"
2824     ;;
2825
2826   megatest )
2827     test -n "$destdir" || destdir=testdir$$
2828     mkdir "$destdir" || func_fatal_error "could not create destination directory"
2829     test -n "$auxdir" || auxdir="build-aux"
2830     func_create_megatestdir "$destdir" "$*"
2831     cd "$destdir"
2832       mkdir build
2833       cd build
2834         ../configure
2835         make
2836         make check
2837         make distclean
2838         remaining=`find . -type f -print`
2839         if test -n "$remaining"; then
2840           echo "Remaining files:" $remaining 1>&2
2841           echo "gnulib-tool: *** Stop." 1>&2
2842           func_exit 1
2843         fi
2844       cd ..
2845     cd ..
2846     rm -rf "$destdir"
2847     ;;
2848
2849   extract-description )
2850     for module
2851     do
2852       func_verify_module
2853       if test -n "$module"; then
2854         func_get_description "$module"
2855       fi
2856     done
2857     ;;
2858
2859   extract-filelist )
2860     for module
2861     do
2862       func_verify_module
2863       if test -n "$module"; then
2864         func_get_filelist "$module"
2865       fi
2866     done
2867     ;;
2868
2869   extract-dependencies )
2870     for module
2871     do
2872       func_verify_module
2873       if test -n "$module"; then
2874         func_get_dependencies "$module"
2875       fi
2876     done
2877     ;;
2878
2879   extract-autoconf-snippet )
2880     for module
2881     do
2882       func_verify_module
2883       if test -n "$module"; then
2884         func_get_autoconf_snippet "$module"
2885       fi
2886     done
2887     ;;
2888
2889   extract-automake-snippet )
2890     for module
2891     do
2892       func_verify_module
2893       if test -n "$module"; then
2894         func_get_automake_snippet "$module"
2895       fi
2896     done
2897     ;;
2898
2899   extract-include-directive )
2900     for module
2901     do
2902       func_verify_module
2903       if test -n "$module"; then
2904         func_get_include_directive "$module"
2905       fi
2906     done
2907     ;;
2908
2909   extract-license )
2910     for module
2911     do
2912       func_verify_module
2913       if test -n "$module"; then
2914         func_get_license "$module"
2915       fi
2916     done
2917     ;;
2918
2919   extract-maintainer )
2920     for module
2921     do
2922       func_verify_module
2923       if test -n "$module"; then
2924         func_get_maintainer "$module"
2925       fi
2926     done
2927     ;;
2928
2929   extract-tests-module )
2930     for module
2931     do
2932       func_verify_module
2933       if test -n "$module"; then
2934         func_get_tests_module "$module"
2935       fi
2936     done
2937     ;;
2938
2939   * )
2940     func_fatal_error "unknown operation mode --$mode" ;;
2941 esac
2942
2943 rm -rf "$tmp"
2944 # Undo the effect of the previous 'trap' command. Some shellology:
2945 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
2946 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
2947 # exit); for the others we need to call 'exit' explicitly. The value of $? is
2948 # 128 + signal number and is set before the trap-registered command is run.
2949 trap '' 0
2950 trap 'func_exit $?' 1 2 3 13 15
2951
2952 exit 0
2953
2954 # Local Variables:
2955 # indent-tabs-mode: nil
2956 # whitespace-check-buffer-indent: nil
2957 # End: