* modules/gethrxtime (Depends-on): Add gettime.
[gnulib.git] / gnulib-tool
1 #! /bin/sh
2 #
3 # Copyright (C) 2002, 2003, 2004, 2005 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
17 # Foundation, 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: 2005-11-04 18:25:19 $'
26 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
27 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
28
29 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
30 AUTOCONFPATH=
31 #case $USER in
32 #  bruno )
33 #    AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
34 #    AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
35 #    ;;
36 #esac
37
38 AUTORECONF="${AUTOCONFPATH}autoreconf"
39
40 # func_usage
41 # outputs to stdout the --help usage message.
42 func_usage ()
43 {
44   echo "\
45 Usage: gnulib-tool --list
46        gnulib-tool --import [module1 ... moduleN]
47        gnulib-tool --update
48        gnulib-tool --create-testdir --dir=directory module1 ... moduleN
49        gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
50        gnulib-tool --test --dir=directory module1 ... moduleN
51        gnulib-tool --megatest --dir=directory [module1 ... moduleN]
52        gnulib-tool --extract-description module
53        gnulib-tool --extract-filelist module
54        gnulib-tool --extract-dependencies module
55        gnulib-tool --extract-autoconf-snippet module
56        gnulib-tool --extract-automake-snippet module
57        gnulib-tool --extract-include-directive module
58        gnulib-tool --extract-license module
59        gnulib-tool --extract-maintainer module
60        gnulib-tool --extract-tests-module module
61
62 Operation modes:
63       --list                print the available module names
64       --import              import the given modules into the current package
65       --create-testdir      create a scratch package with the given modules
66       --create-megatestdir  create a mega scratch package with the given modules
67                             one by one and all together
68       --test                test the combination of the given modules
69                             (recommended to use CC=\"gcc -Wall\" here)
70       --megatest            test the given modules one by one and all together
71                             (recommended to use CC=\"gcc -Wall\" here)
72       --extract-description        extract the description
73       --extract-filelist           extract the list of files
74       --extract-dependencies       extract the dependencies
75       --extract-autoconf-snippet   extract the snippet for configure.ac
76       --extract-automake-snippet   extract the snippet for lib/Makefile.am
77       --extract-include-directive  extract the #include directive
78       --extract-license            report the license terms of the source files
79                                    under lib/
80       --extract-maintainer         report the maintainer(s) inside gnulib
81       --extract-tests-module       report the unit test module, if it exists
82
83 Options:
84       --dir=DIRECTORY       specify the target directory
85                             For --import, this specifies where your
86                             configure.ac can be found.  Defaults to current
87                             directory.
88       --lib=LIBRARY         Specify the library name.  Defaults to 'libgnu'.
89       --source-base=DIRECTORY
90                             Directory relative --dir where source code is
91                             placed (default \"lib\"), for --import.
92       --m4-base=DIRECTORY   Directory relative --dir where *.m4 macros are
93                             placed (default \"m4\"), for --import.
94       --tests-base=DIRECTORY
95                             Directory relative --dir where unit tests are
96                             placed (default \"tests\"), for --import.
97       --aux-dir=DIRECTORY   Directory relative --dir where auxiliary build
98                             tools are placed (default \"build-aux\").
99       --with-tests          Include unit tests for the included modules.
100       --avoid=MODULE        Avoid including the given MODULE. Useful if you
101                             have code that provides equivalent functionality.
102                             This option can be repeated.
103       --lgpl                Abort if modules aren't available under the LGPL.
104                             Also modify license template from GPL to LGPL.
105       --libtool             Use libtool rules, for --import.
106       --macro-prefix=PREFIX  Specify the prefix of the macros 'gl_EARLY' and
107                             'gl_INIT'. Default is 'gl'.
108       --no-changelog        don't update or create ChangeLog files
109       --dry-run             For --import, only print what would have been done.
110   -s, --symbolic, --symlink Make symbolic links instead of copying files.
111
112 Report bugs to <bug-gnulib@gnu.org>."
113 }
114
115 # func_version
116 # outputs to stdout the --version message.
117 func_version ()
118 {
119   echo "$progname (GNU $package) $version"
120   echo "Copyright (C) 2002-2005 Free Software Foundation, Inc.
121 This is free software; see the source for copying conditions.  There is NO
122 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
123   echo "Written by" "Bruno Haible" "and" "Simon Josefsson"
124 }
125
126 # func_tmpdir
127 # creates a temporary directory.
128 # Sets variable
129 # - tmp             pathname of freshly created temporary directory
130 func_tmpdir ()
131 {
132   # Use the environment variable TMPDIR, falling back to /tmp. This allows
133   # users to specify a different temporary directory, for example, if their
134   # /tmp is filled up or too small.
135   : ${TMPDIR=/tmp}
136   {
137     # Use the mktemp program if available. If not available, hide the error
138     # message.
139     tmp=`(umask 077 && mktemp -d -q "$TMPDIR/glXXXXXX") 2>/dev/null` &&
140     test -n "$tmp" && test -d "$tmp"
141   } ||
142   {
143     # Use a simple mkdir command. It is guaranteed to fail if the directory
144     # already exists.  $RANDOM is bash specific and expands to empty in shells
145     # other than bash, ksh and zsh.  Its use does not increase security;
146     # rather, it minimizes the probability of failure in a very cluttered /tmp
147     # directory.
148     tmp=$TMPDIR/gl$$-$RANDOM
149     (umask 077 && mkdir "$tmp")
150   } ||
151   {
152     echo "$0: cannot create a temporary directory in $TMPDIR" >&2
153     { (exit 1); exit 1; }
154   }
155 }
156
157 # func_fatal_error message
158 # outputs to stderr a fatal error message, and terminates the program.
159 func_fatal_error ()
160 {
161   echo "gnulib-tool: *** $1" 1>&2
162   echo "gnulib-tool: *** Stop." 1>&2
163   exit 1
164 }
165
166 # func_readlink SYMLINK
167 # outputs the target of the given symlink.
168 if (type -p readlink) > /dev/null 2>&1; then
169   func_readlink ()
170   {
171     # Use the readlink program from GNU coreutils.
172     readlink "$1"
173   }
174 else
175   func_readlink ()
176   {
177     # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
178     # would do the wrong thing if the link target contains " -> ".
179     LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
180   }
181 fi
182
183 # func_ln_if_changed SRC DEST
184 # Like ln -s, but avoids munging timestamps if the link is correct.
185 func_ln_if_changed ()
186 {
187   if test $# -ne 2; then
188     echo "usage: func_ln_if_changed SRC DEST" >&2
189   fi
190   if test -L "$2" && test "$1" = "`func_readlink "$2"`"; then
191     :
192   else
193     rm -f "$2"
194     ln -s "$1" "$2"
195   fi
196 }
197
198 # Command-line option processing.
199 # Removes the OPTIONS from the arguments. Sets the variables:
200 # - mode            list or import or create-testdir or create-megatestdir
201 # - destdir         from --dir
202 # - libname, supplied_libname  from --lib
203 # - sourcebase      from --source-base
204 # - m4base          from --m4-base
205 # - testsbase       from --tests-base
206 # - auxdir          from --aux-dir
207 # - inctests        true if --with-tests was given, blank otherwise
208 # - avoidlist       list of modules to avoid, from --avoid
209 # - lgpl            true if --lgpl was given, blank otherwise
210 # - libtool         true if --libtool was given, blank otherwise
211 # - do_changelog    false if --no-changelog was given, : otherwise
212 # - doit            : if actions shall be executed, false if only to be printed
213 {
214   mode=
215   destdir=
216   libname=libgnu
217   supplied_libname=
218   sourcebase=
219   m4base=
220   testsbase=
221   auxdir=
222   inctests=
223   avoidlist=
224   lgpl=
225   libtool=
226   macro_prefix=
227   do_changelog=:
228   doit=:
229   symbolic=
230
231   supplied_opts="$@"
232
233   while test $# -gt 0; do
234     case "$1" in
235       --list | --lis )
236         mode=list
237         shift ;;
238       --import | --impor | --impo | --imp | --im | --i )
239         mode=import
240         shift ;;
241       --update | --updat | --upda | --upd | --up | --u )
242         mode=update
243         shift ;;
244       --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
245         mode=create-testdir
246         shift ;;
247       --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
248         mode=create-megatestdir
249         shift ;;
250       --test | --tes | --te | --t )
251         mode=test
252         shift ;;
253       --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
254         mode=megatest
255         shift ;;
256       --extract-* )
257         mode=`echo "X$1" | sed -e 's/^X--//'`
258         shift ;;
259       --dir )
260         shift
261         if test $# = 0; then
262           func_fatal_error "missing argument for --dir"
263         fi
264         destdir=$1
265         shift ;;
266       --dir=* )
267         destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
268         shift ;;
269       --lib )
270         shift
271         if test $# = 0; then
272           func_fatal_error "missing argument for --lib"
273         fi
274         libname=$1
275         supplied_libname=true
276         shift ;;
277       --lib=* )
278         libname=`echo "X$1" | sed -e 's/^X--lib=//'`
279         supplied_libname=true
280         shift ;;
281       --source-base )
282         shift
283         if test $# = 0; then
284           func_fatal_error "missing argument for --source-base"
285         fi
286         sourcebase=$1
287         shift ;;
288       --source-base=* )
289         sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
290         shift ;;
291       --m4-base )
292         shift
293         if test $# = 0; then
294           func_fatal_error "missing argument for --m4-base"
295         fi
296         m4base=$1
297         shift ;;
298       --m4-base=* )
299         m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
300         shift ;;
301       --tests-base )
302         shift
303         if test $# = 0; then
304           func_fatal_error "missing argument for --tests-base"
305         fi
306         testsbase=$1
307         shift ;;
308       --tests-base=* )
309         testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
310         shift ;;
311       --aux-dir )
312         shift
313         if test $# = 0; then
314           func_fatal_error "missing argument for --aux-dir"
315         fi
316         auxdir=$1
317         shift ;;
318       --aux-dir=* )
319         auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
320         shift ;;
321       --with-tests )
322         inctests=true
323         shift ;;
324       --avoid )
325         shift
326         if test $# = 0; then
327           func_fatal_error "missing argument for --avoid"
328         fi
329         avoidlist="$avoidlist $1"
330         shift ;;
331       --avoid=* )
332         avoidlist="$avoidlist "`echo "X$1" | sed -e 's/^X--avoid=//'`
333         shift ;;
334       --lgpl )
335         lgpl=true
336         shift ;;
337       --libtool )
338         libtool=true
339         shift ;;
340       --macro-prefix )
341         shift
342         if test $# = 0; then
343           func_fatal_error "missing argument for --macro-prefix"
344         fi
345         macro_prefix="$1"
346         shift ;;
347       --macro-prefix=* )
348         macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
349         shift ;;
350       --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
351         do_changelog=false
352         shift ;;
353       --dry-run )
354         doit=false
355         shift ;;
356       -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
357         symbolic=true
358         shift ;;
359       --help | --hel | --he | --h )
360         func_usage
361         exit 0 ;;
362       --version | --versio | --versi | --vers | --ver | --ve | --v )
363         func_version
364         exit 0 ;;
365       -- )
366         # Stop option processing
367         shift
368         break ;;
369       -* )
370         echo "gnulib-tool: unknown option $1" 1>&2
371         echo "Try 'gnulib-tool --help' for more information." 1>&2
372         exit 1 ;;
373       * )
374         break ;;
375     esac
376   done
377
378   if test "$mode" = update; then
379     if test $# != 0; then
380       echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
381       echo "Try 'gnulib-tool --help' for more information." 1>&2
382       echo "If you really want to modify the gnulib configuration of your project," 1>&2
383       echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
384       exit 1
385     fi
386     if test -n "$libname" || test -n "$sourcebase" || test -n "$m4base" \
387        || test -n "$testsbase" || test -n "$auxdir" || test -n "$inctests" \
388        || test -n "$avoidlist" || test -n "$lgpl" || test -n "$macro_prefix"; then
389       echo "gnulib-tool: invalid options for 'update' mode" 1>&2
390       echo "Try 'gnulib-tool --help' for more information." 1>&2
391       echo "If you really want to modify the gnulib configuration of your project," 1>&2
392       echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
393       exit 1
394     fi
395     do_changelog=false
396   fi
397
398   # Remove trailing slashes from the directory names. This is necessary for
399   # m4base (to avoid an error in func_import) and optional for the others.
400   sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
401   case "$sourcebase" in
402     */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
403   esac
404   case "$m4base" in
405     */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
406   esac
407   case "$testsbase" in
408     */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
409   esac
410   case "$auxdir" in
411     */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
412   esac
413 }
414
415 case "$0" in
416   /*) self_abspathname="$0" ;;
417   */*) self_abspathname=`pwd`/"$0" ;;
418   *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
419        if test -x "$d/$0" && test ! -d "$d/$0"; then
420          self_abspathname="$d/$0"
421          break
422        fi
423      done
424      if test -z "$self_abspathname"; then
425        func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
426      fi
427      ;;
428 esac
429 while test -h "$self_abspathname"; do
430   # Resolve symbolic link.
431   linkval=`func_readlink "$self_abspathname"`
432   test -n "$linkval" || break
433   case "$linkval" in
434     /* ) self_abspathname="$linkval" ;;
435     * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
436   esac
437 done
438 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
439
440 # func_all_modules
441 func_all_modules ()
442 {
443   # Filter out metainformation files like README, which are not modules.
444   # Filter out unit test modules; they can be retrieved through
445   # --extract-tests-module if desired.
446   (cd "$gnulib_dir/modules" && ls -1) \
447       | sed -e '/^CVS$/d' -e '/^ChangeLog$/d' -e '/^README$/d' -e '/^TEMPLATE$/d' -e '/^TEMPLATE-TESTS$/d' -e '/~$/d' \
448       | sed -e '/-tests$/d' \
449       | LC_ALL=C sort
450 }
451
452 # func_verify_module
453 # verifies a module name
454 func_verify_module ()
455 {
456   if test ! -f "$gnulib_dir/modules/$module" \
457      || test "CVS" = "$module" \
458      || test "ChangeLog" = "$module" \
459      || test "README" = "$module" \
460      || test "TEMPLATE" = "$module" \
461      || test "TEMPLATE-TESTS" = "$module"; then
462     echo "gnulib-tool: module $module doesn't exist" 1>&2
463     module=
464   fi
465 }
466
467 # func_verify_nontests_module
468 # verifies a module name, excluding tests modules
469 func_verify_nontests_module ()
470 {
471   case "$module" in
472     *-tests ) module= ;;
473     * ) func_verify_module ;;
474   esac
475 }
476
477 # func_verify_tests_module
478 # verifies a module name, considering only tests modules
479 func_verify_tests_module ()
480 {
481   case "$module" in
482     *-tests ) func_verify_module ;;
483     * ) module= ;;
484   esac
485 }
486
487 sed_extract_prog=':[    ]*$/ {
488   :a
489     n
490     s/^Description:[    ]*$//
491     s/^Files:[  ]*$//
492     s/^Depends-on:[     ]*$//
493     s/^configure\.ac:[  ]*$//
494     s/^Makefile\.am:[   ]*$//
495     s/^Include:[        ]*$//
496     s/^License:[        ]*$//
497     s/^Maintainer:[     ]*$//
498     tb
499     p
500     ba
501   :b
502 }'
503
504 # func_get_description module
505 func_get_description ()
506 {
507   sed -n -e "/^Description$sed_extract_prog" < "$gnulib_dir/modules/$1"
508 }
509
510 # func_get_filelist module
511 func_get_filelist ()
512 {
513   sed -n -e "/^Files$sed_extract_prog" < "$gnulib_dir/modules/$1"
514   #echo m4/onceonly.m4
515   echo m4/onceonly_2_57.m4
516 }
517
518 # func_get_dependencies module
519 func_get_dependencies ()
520 {
521   # ${module}-tests always implicitly depends on ${module}.
522   echo "$1" | sed -n -e 's/-tests//p'
523   # Then the explicit dependencies listed in the module description.
524   sed -n -e "/^Depends-on$sed_extract_prog" < "$gnulib_dir/modules/$1"
525 }
526
527 # func_get_autoconf_snippet module
528 func_get_autoconf_snippet ()
529 {
530   sed -n -e "/^configure\.ac$sed_extract_prog" < "$gnulib_dir/modules/$1"
531 }
532
533 # func_get_automake_snippet module
534 func_get_automake_snippet ()
535 {
536   sed -n -e "/^Makefile\.am$sed_extract_prog" < "$gnulib_dir/modules/$1"
537 }
538
539 # func_get_include_directive module
540 func_get_include_directive ()
541 {
542   sed -n -e "/^Include$sed_extract_prog" < "$gnulib_dir/modules/$1" | \
543   sed -e 's/^\(["<]\)/#include \1/'
544 }
545
546 # func_get_license module
547 func_get_license ()
548 {
549   sed -n -e "/^License$sed_extract_prog" < "$gnulib_dir/modules/$1"
550 }
551
552 # func_get_maintainer module
553 func_get_maintainer ()
554 {
555   sed -n -e "/^Maintainer$sed_extract_prog" < "$gnulib_dir/modules/$1"
556 }
557
558 # func_get_tests_module module
559 func_get_tests_module ()
560 {
561   # The naming convention for tests modules is hardwired: ${module}-tests.
562   if test -f modules/"$1"-tests; then
563     echo "$1"-tests
564   fi
565 }
566
567 # func_acceptable module
568 # tests whether a module is acceptable.
569 # Input:
570 # - avoidlist       list of modules to avoid
571 func_acceptable ()
572 {
573   for avoid in $avoidlist; do
574     if test "$avoid" = "$1"; then
575       return 1
576     fi
577   done
578   return 0
579 }
580
581 # func_modules_transitive_closure
582 # Input:
583 # - modules         list of specified modules
584 # - inctests        true if tests should be included, blank otherwise
585 # - avoidlist       list of modules to avoid
586 # Output:
587 # - modules         list of modules, including dependencies
588 func_modules_transitive_closure ()
589 {
590   while true; do
591     xmodules=
592     for module in $modules; do
593       func_verify_module
594       if test -n "$module"; then
595         # Duplicate dependencies are harmless, but Jim wants a warning.
596         duplicated_deps=`func_get_dependencies $module | LC_ALL=C sort | LC_ALL=C uniq -d`
597         if test -n "$duplicated_deps"; then
598           echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
599         fi
600         if func_acceptable $module; then
601           xmodules="$xmodules $module"
602           for depmodule in `func_get_dependencies $module`; do
603             if func_acceptable $depmodule; then
604               xmodules="$xmodules $depmodule"
605             fi
606           done
607           if test -n "$inctests"; then
608             testsmodule=`func_get_tests_module $module`
609             if test -n "$testsmodule"; then
610               if func_acceptable $testsmodule; then
611                 xmodules="$xmodules $testsmodule"
612                 for depmodule in `func_get_dependencies $testsmodule`; do
613                   if func_acceptable $depmodule; then
614                     xmodules="$xmodules $depmodule"
615                   fi
616                 done
617               fi
618             fi
619           fi
620         fi
621       fi
622     done
623     xmodules=`for m in $xmodules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
624     if test "$xmodules" = "$modules"; then
625       break
626     fi
627     modules="$xmodules"
628   done
629 }
630
631 # func_modules_to_filelist
632 # Input:
633 # - modules         list of modules, including dependencies
634 # Output:
635 # - files           list of files
636 func_modules_to_filelist ()
637 {
638   files=
639   for module in $modules; do
640     func_verify_module
641     if test -n "$module"; then
642       files="$files "`func_get_filelist $module`
643     fi
644   done
645   files=`for f in $files; do echo $f; done | LC_ALL=C sort | LC_ALL=C uniq`
646 }
647
648 # func_emit_lib_Makefile_am
649 # emits the contents of lib/Makefile.am to standard output.
650 # Input:
651 # - modules         list of modules, including dependencies
652 # - libname         library name
653 # - libtool         true if libtool will be used, blank otherwise
654 # - actioncmd       (optional) command that will reproduce this invocation
655 func_emit_lib_Makefile_am ()
656 {
657   if test -n "$libtool"; then
658     libext=la
659     perhapsLT=LT
660   else
661     libext=a
662     perhapsLT=
663   fi
664   echo "## Process this file with automake to produce Makefile.in."
665   echo "# Copyright (C) 2004 Free Software Foundation, Inc."
666   echo "#"
667   echo "# This file is free software, distributed under the terms of the GNU"
668   echo "# General Public License.  As a special exception to the GNU General"
669   echo "# Public License, this file may be distributed as part of a program"
670   echo "# that contains a configuration script generated by Automake, under"
671   echo "# the same distribution terms as the rest of that program."
672   echo "#"
673   echo "# Generated by gnulib-tool."
674   if test -n "$actioncmd"; then
675     echo "# Reproduce by: $actioncmd"
676   fi
677   echo
678   # No need to generate dependencies since the sources are in gnulib, not here.
679   echo "AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies"
680   echo
681   echo "noinst_${perhapsLT}LIBRARIES = $libname.$libext"
682   echo
683   echo "${libname}_${libext}_SOURCES ="
684   echo "${libname}_${libext}_LIBADD = @${perhapsLT}LIBOBJS@"
685   echo "EXTRA_DIST ="
686   echo "BUILT_SOURCES ="
687   echo "SUFFIXES ="
688   echo "MOSTLYCLEANFILES ="
689   echo "CLEANFILES ="
690   echo "DISTCLEANFILES ="
691   echo "MAINTAINERCLEANFILES ="
692   echo
693   for module in $modules; do
694     func_verify_nontests_module
695     if test -n "$module"; then
696       {
697         func_get_automake_snippet "$module" |
698           sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
699         if test "$module" = 'alloca'; then
700           echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
701         fi
702       } > amsnippet.tmp
703       # Skip the contents if its entirely empty.
704       if grep '[^       ]' amsnippet.tmp > /dev/null ; then
705         echo "## begin gnulib module $module"
706         echo
707         cat amsnippet.tmp
708         echo "## end   gnulib module $module"
709         echo
710       fi
711       rm -f amsnippet.tmp
712     fi
713   done
714   echo
715   echo "# Makefile.am ends here"
716 }
717
718 # func_emit_tests_Makefile_am
719 # emits the contents of tests/Makefile.am to standard output.
720 # Input:
721 # - modules         list of modules, including dependencies
722 # - libname         library name
723 # - libtool         true if libtool will be used, blank otherwise
724 # - sourcebase      relative directory containing lib source code
725 # - m4base          relative directory containing autoconf macros
726 # - testsbase       relative directory containing unit test code
727 func_emit_tests_Makefile_am ()
728 {
729   if test -n "$libtool"; then
730     libext=la
731   else
732     libext=a
733   fi
734   testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
735   echo "## Process this file with automake to produce Makefile.in."
736   echo "# Copyright (C) 2004-2005 Free Software Foundation, Inc."
737   echo "#"
738   echo "# This file is free software, distributed under the terms of the GNU"
739   echo "# General Public License.  As a special exception to the GNU General"
740   echo "# Public License, this file may be distributed as part of a program"
741   echo "# that contains a configuration script generated by Automake, under"
742   echo "# the same distribution terms as the rest of that program."
743   echo "#"
744   echo "# Generated by gnulib-tool."
745   echo
746   # Generate dependencies here, since it eases the debugging of test failures.
747   echo "AUTOMAKE_OPTIONS = 1.5 foreign"
748   echo
749   echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
750   echo
751   echo "TESTS ="
752   echo "TESTS_ENVIRONMENT ="
753   echo "noinst_PROGRAMS ="
754   echo "EXTRA_DIST ="
755   echo "BUILT_SOURCES ="
756   echo "SUFFIXES ="
757   echo "MOSTLYCLEANFILES ="
758   echo "CLEANFILES ="
759   echo "DISTCLEANFILES ="
760   echo "MAINTAINERCLEANFILES ="
761   echo
762   echo "AM_CPPFLAGS = \\"
763   echo "  -I. -I\$(srcdir) \\"
764   echo "  -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
765   echo "  -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
766   echo
767   echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
768   echo
769   for module in $modules; do
770     func_verify_tests_module
771     if test -n "$module"; then
772       func_get_automake_snippet "$module" > amsnippet.tmp
773       # Skip the contents if its entirely empty.
774       if grep '[^       ]' amsnippet.tmp > /dev/null ; then
775         echo "## begin gnulib module $module"
776         echo
777         cat amsnippet.tmp
778         echo "## end   gnulib module $module"
779         echo
780       fi
781       rm -f amsnippet.tmp
782     fi
783   done
784   echo "# Clean up after Solaris cc."
785   echo "clean-local:"
786   echo "        rm -rf SunWS_cache"
787   echo
788   echo "# Makefile.am ends here"
789 }
790
791 # func_import modules
792 # Uses also the variables
793 # - destdir         target directory
794 # - libname         library name
795 # - sourcebase      directory relative to destdir where to place source code
796 # - m4base          directory relative to destdir where to place *.m4 macros
797 # - testsbase       directory relative to destdir where to place unit test code
798 # - auxdir          directory relative to destdir where to place build aux files
799 # - inctests        true if --with-tests was given, blank otherwise
800 # - avoidlist       list of modules to avoid, from --avoid
801 # - lgpl            true if library's license shall be LGPL, blank otherwise
802 # - libtool         true if libtool will be used, blank otherwise
803 # - guessed_libtool true if the configure.ac file uses libtool, blank otherwise
804 # - macro_prefix    prefix of gl_EARLY, gl_INIT macros to use
805 # - doit            : if actions shall be executed, false if only to be printed
806 # - symbolic        true if files should be symlinked, copied otherwise
807 func_import ()
808 {
809   # Get the cached settings.
810   cached_specified_modules=
811   cached_avoidlist=
812   cached_sourcebase=
813   cached_m4base=
814   cached_testsbase=
815   cached_libname=
816   cached_lgpl=
817   cached_libtool=
818   cached_macro_prefix=
819   cached_files=
820   if test -f "$destdir"/$m4base/gnulib-cache.m4; then
821     my_sed_traces='
822       s,#.*$,,
823       s,^dnl .*$,,
824       s, dnl .*$,,
825       /gl_MODULES(/ {
826         s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
827       }
828       /gl_AVOID(/ {
829         s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
830       }
831       /gl_SOURCE_BASE(/ {
832         s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
833       }
834       /gl_M4_BASE(/ {
835         s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
836       }
837       /gl_TESTS_BASE(/ {
838         s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
839       }
840       /gl_LIB(/ {
841         s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
842       }
843       /gl_LGPL/ {
844         s,^.*$,cached_lgpl=true,p
845       }
846       /gl_LIBTOOL/ {
847         s,^.*$,cached_libtool=true,p
848       }
849       /gl_MACRO_PREFIX(/ {
850         s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
851       }'
852     eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
853     if test -f "$destdir"/$m4base/gnulib-comp.m4; then
854       my_sed_traces='
855         s,#.*$,,
856         s,^dnl .*$,,
857         s, dnl .*$,,
858         /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
859           s,^.*$,cached_files=",p
860           n
861           ta
862           :a
863           s,^\]).*$,",
864           tb
865           p
866           n
867           ba
868           :b
869           p
870         }'
871       eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
872     fi
873   fi
874
875   # Merge the cached settings with the specified ones.
876   # The m4base must be the same as expected from the pathname.
877   if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
878     func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
879   fi
880   # Append the cached and the specified module names. So that
881   # "gnulib-tool --import foo" means to add the module foo.
882   specified_modules="$cached_specified_modules $1"
883   # Append the cached and the specified avoidlist. This is probably better
884   # than dropping the cached one when --avoid is specified at least once.
885   avoidlist=`echo $cached_avoidlist $avoidlist`
886   # The sourcebase defaults to the cached one.
887   if test -z "$sourcebase"; then
888     sourcebase="$cached_sourcebase"
889     if test -z "$sourcebase"; then
890       func_fatal_error "missing --source-base option"
891     fi
892   fi
893   # The testsbase defaults to the cached one.
894   if test -z "$testsbase"; then
895     testsbase="$cached_testsbase"
896     if test -z "$testsbase"; then
897       func_fatal_error "missing --tests-base option"
898     fi
899   fi
900   # The libname defaults to the cached one.
901   if test -z "$supplied_libname"; then
902     libname="$cached_libname"
903     if test -z "$libname"; then
904       func_fatal_error "missing --lib option"
905     fi
906   fi
907   # Require LGPL if specified either way.
908   if test -z "$lgpl"; then
909     lgpl="$cached_lgpl"
910   fi
911   # Use libtool if specified either way, or if guessed.
912   if test -z "$libtool"; then
913     if test -n "$cached_m4base"; then
914       libtool="$cached_libtool"
915     else
916       libtool="$guessed_libtool"
917     fi
918   fi
919   # The macro_prefix defaults to the cached one.
920   if test -z "$macro_prefix"; then
921     macro_prefix="$cached_macro_prefix"
922     if test -z "$macro_prefix"; then
923       func_fatal_error "missing --macro-prefix option"
924     fi
925   fi
926
927   # Canonicalize the list of specified modules.
928   specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
929
930   # Determine final module list.
931   modules="$specified_modules"
932   func_modules_transitive_closure
933   echo "Module list with included dependencies:"
934   echo "$modules" | sed -e 's/^/  /'
935
936   # If --lgpl, check the license of modules are compatible.
937   if test -n "$lgpl"; then
938     for module in $modules; do
939       license=`func_get_license $module`
940       case $license in
941         LGPL | 'public domain' | 'unlimited') ;;
942         *) func_fatal_error "incompatible license on module $module: $license" ;;
943       esac
944     done
945   fi
946
947   # Determine final file list.
948   func_modules_to_filelist
949   echo "File list:"
950   echo "$files" | sed -e 's/^/  /'
951
952   test -n "$files" \
953     || func_fatal_error "refusing to do nothing"
954
955   # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
956   new_files="$files m4/gnulib-tool.m4"
957   old_files="$cached_files"
958   if test -f "$destdir"/$m4base/gnulib-tool.m4; then
959     old_files="$old_files m4/gnulib-tool.m4"
960   fi
961
962   # Create directories.
963   if test ! -d "$destdir/$sourcebase"; then
964     if $doit; then
965       echo "Creating directory $destdir/$sourcebase"
966       mkdir "$destdir/$sourcebase" || func_fatal_error "failed"
967     else
968       echo "Create directory $destdir/$sourcebase"
969     fi
970   fi
971   if test ! -d "$destdir/$m4base"; then
972     if $doit; then
973       echo "Creating directory $destdir/$m4base"
974       mkdir "$destdir/$m4base" || func_fatal_error "failed"
975     else
976       echo "Create directory $destdir/$m4base"
977     fi
978   fi
979   if test -n "$inctests"; then
980     if test ! -d "$destdir/$testsbase"; then
981       if $doit; then
982         echo "Creating directory $destdir/$testsbase"
983         mkdir "$destdir/$testsbase" || func_fatal_error "failed"
984       else
985         echo "Create directory $destdir/$testsbase"
986       fi
987     fi
988   fi
989   if test ! -d "$destdir/$auxdir"; then
990     if $doit; then
991       echo "Creating directory $destdir/$auxdir"
992       mkdir "$destdir/$auxdir" || func_fatal_error "failed"
993     else
994       echo "Create directory $destdir/$auxdir"
995     fi
996   fi
997
998   # Copy files or make symbolic links. Remove obsolete files.
999   func_tmpdir
1000   trap 'rm -rf "$tmp"' 0 1 2 3 15
1001   delimiter='   '
1002   for f in $old_files; do
1003     case "$f" in
1004       build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1005       lib/*) g=`echo "$f" | sed -e "s,^lib/,$cached_sourcebase/,"` ;;
1006       m4/*) g=`echo "$f" | sed -e "s,^m4/,$cached_m4base/,"` ;;
1007       tests/*) g=`echo "$f" | sed -e "s,^tests/,$cached_testsbase/,"` ;;
1008       *) g="$f" ;;
1009     esac
1010     echo "$g""$delimiter""$f"
1011   done | LC_ALL=C sort > "$tmp"/old-files
1012   for f in $new_files; do
1013     case "$f" in
1014       build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1015       lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1016       m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1017       tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1018       *) g="$f" ;;
1019     esac
1020     echo "$g""$delimiter""$f"
1021   done | LC_ALL=C sort > "$tmp"/new-files
1022   # First the files that are in old-files, but not in new-files:
1023   for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e 's,'"$delimiter"'.*,,'`; do
1024     # Remove the file. Do nothing if the user already removed it.
1025     if test -f "$destdir/$g"; then
1026       if $doit; then
1027         echo "Removing file $g (backup in ${g}~)"
1028         mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1029       else
1030         echo "Remove file $g (backup in ${g}~)"
1031       fi
1032     fi
1033   done
1034   # func_add_or_update handles a file that ought to be present afterwards.
1035   # Uses parameters f, g, already_present.
1036   func_add_or_update ()
1037   {
1038     cp "$gnulib_dir/$f" "$destdir/$g.tmp" || func_fatal_error "failed"
1039     if test -n "$lgpl"; then
1040       # Update license.
1041       case "$f" in
1042         lib/*)
1043           sed -e 's/GNU General/GNU Lesser General/g' \
1044               -e 's/version 2\([ ,]\)/version 2.1\1/g' \
1045             < "$gnulib_dir/$f" > "$destdir/$g.tmp" || func_fatal_error "failed"
1046           ;;
1047       esac
1048     fi
1049     if test -f "$destdir/$g"; then
1050       # The file already exists.
1051       if cmp "$destdir/$g" "$destdir/$g.tmp" > /dev/null; then
1052         : # The file has not changed.
1053       else
1054         # Replace the file.
1055         if $doit; then
1056           if test -n "$already_present"; then
1057             echo "Updating file $g (backup in ${g}~)"
1058           else
1059             echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
1060           fi
1061           mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1062           if test -n "$symbolic" && cmp "$gnulib_dir/$f" "$destdir/$g.tmp" > /dev/null; then
1063             func_ln_if_changed "$gnulib_dir/$f" "$destdir/$g"
1064           else
1065             mv -f "$destdir/$g.tmp" "$destdir/${g}" || func_fatal_error "failed"
1066           fi
1067         else
1068           if test -n "$already_present"; then
1069             echo "Update file $g (backup in ${g}~)"
1070           else
1071             echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
1072           fi
1073         fi
1074       fi
1075     else
1076       # Install the file.
1077       # Don't protest if the file should be there but isn't: it happens
1078       # frequently that developers don't put autogenerated files into CVS.
1079       if $doit; then
1080         echo "Copying file $g"
1081         if test -n "$symbolic" && cmp "$gnulib_dir/$f" "$destdir/$g.tmp" > /dev/null; then
1082           func_ln_if_changed "$gnulib_dir/$f" "$destdir/$g"
1083         else
1084           mv -f "$destdir/$g.tmp" "$destdir/${g}" || func_fatal_error "failed"
1085         fi
1086       else
1087         echo "Copy file $g"
1088       fi
1089     fi
1090     rm -f "$destdir/$g.tmp"
1091   }
1092   # Then the files that are in new-files, but not in old-files:
1093   already_present=
1094   for f in `LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files | sed -e 's,'^.*"$delimiter"',,'`; do
1095     case "$f" in
1096       build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1097       lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1098       m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1099       tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1100       *) g="$f" ;;
1101     esac
1102     func_add_or_update
1103   done
1104   # Then the files that are in new-files and in old-files:
1105   already_present=true
1106   for f in `LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files | sed -e 's,'^.*"$delimiter"',,'`; do
1107     case "$f" in
1108       build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1109       lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1110       m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1111       tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1112       *) g="$f" ;;
1113     esac
1114     func_add_or_update
1115   done
1116   rm -rf "$tmp"
1117   trap - 0 1 2 3 15
1118
1119   # Command-line invocation printed in a comment in generated gnulib-cache.m4.
1120   actioncmd="gnulib-tool --import"
1121   actioncmd="$actioncmd --dir=$destdir"
1122   actioncmd="$actioncmd --lib=$libname"
1123   actioncmd="$actioncmd --source-base=$sourcebase"
1124   actioncmd="$actioncmd --m4-base=$m4base"
1125   actioncmd="$actioncmd --aux-dir=$auxdir"
1126   for module in $avoidlist; do
1127     actioncmd="$actioncmd --avoid=$module"
1128   done
1129   if test -n "$lgpl"; then
1130     actioncmd="$actioncmd --lgpl"
1131   fi
1132   if test -n "$libtool"; then
1133     actioncmd="$actioncmd --libtool"
1134   fi
1135   actioncmd="$actioncmd --macro-prefix=$macro_prefix"
1136   actioncmd="$actioncmd `echo $specified_modules`"
1137
1138   # Create lib/Makefile.am.
1139   func_emit_lib_Makefile_am > "$destdir"/$sourcebase/Makefile.am.tmp
1140   if test -f "$destdir"/$sourcebase/Makefile.am; then
1141     if cmp "$destdir"/$sourcebase/Makefile.am "$destdir"/$sourcebase/Makefile.am.tmp > /dev/null; then
1142       rm -f "$destdir"/$sourcebase/Makefile.am.tmp
1143     else
1144       if $doit; then
1145         echo "Updating $sourcebase/Makefile.am (backup in $sourcebase/Makefile.am~)"
1146         mv -f "$destdir"/$sourcebase/Makefile.am "$destdir"/$sourcebase/Makefile.am~
1147         mv -f "$destdir"/$sourcebase/Makefile.am.tmp "$destdir"/$sourcebase/Makefile.am
1148       else
1149         echo "Update $sourcebase/Makefile.am (backup in $sourcebase/Makefile.am~)"
1150         rm -f "$destdir"/$sourcebase/Makefile.am.tmp
1151       fi
1152     fi
1153   else
1154     if $doit; then
1155       echo "Creating $sourcebase/Makefile.am"
1156       mv -f "$destdir"/$sourcebase/Makefile.am.tmp "$destdir"/$sourcebase/Makefile.am
1157     else
1158       echo "Create $sourcebase/Makefile.am"
1159       rm -f "$destdir"/$sourcebase/Makefile.am.tmp
1160     fi
1161   fi
1162
1163   # Create m4/gnulib-cache.m4.
1164   (
1165     echo "# Copyright (C) 2004 Free Software Foundation, Inc."
1166     echo "# This file is free software, distributed under the terms of the GNU"
1167     echo "# General Public License.  As a special exception to the GNU General"
1168     echo "# Public License, this file may be distributed as part of a program"
1169     echo "# that contains a configuration script generated by Autoconf, under"
1170     echo "# the same distribution terms as the rest of that program."
1171     echo "#"
1172     echo "# Generated by gnulib-tool."
1173     echo "#"
1174     echo "# This file represents the specification of how gnulib-tool is used."
1175     echo "# It acts as a cache: It is written and read by gnulib-tool."
1176     echo "# In projects using CVS, this file is meant to be stored in CVS,"
1177     echo "# like the configure.ac and various Makefile.am files."
1178     echo
1179     echo
1180     echo "# Specification in the form of a command-line invocation:"
1181     echo "#   $actioncmd"
1182     echo
1183     echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
1184     echo "gl_MODULES(["`echo $specified_modules`"])"
1185     echo "gl_AVOID([$avoidlist])"
1186     echo "gl_SOURCE_BASE([$sourcebase])"
1187     echo "gl_M4_BASE([$m4base])"
1188     echo "gl_TESTS_BASE([$testsbase])"
1189     echo "gl_LIB([$libname])"
1190     test -z "$lgpl" || echo "gl_LGPL"
1191     test -z "$libtool" || echo "gl_LIBTOOL"
1192     echo "gl_MACRO_PREFIX([$macro_prefix])"
1193   ) > "$destdir"/$m4base/gnulib-cache.m4.tmp
1194   if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1195     if cmp "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4.tmp > /dev/null; then
1196       rm -f "$destdir"/$m4base/gnulib-cache.m4.tmp
1197     else
1198       if $doit; then
1199         echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1200         mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
1201         mv -f "$destdir"/$m4base/gnulib-cache.m4.tmp "$destdir"/$m4base/gnulib-cache.m4
1202       else
1203         echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1204         if false; then
1205           cat "$destdir"/$m4base/gnulib-cache.m4.tmp
1206           echo
1207           echo "# gnulib-cache.m4 ends here"
1208         fi
1209         rm -f "$destdir"/$m4base/gnulib-cache.m4.tmp
1210       fi
1211     fi
1212   else
1213     if $doit; then
1214       echo "Creating $m4base/gnulib-cache.m4"
1215       mv -f "$destdir"/$m4base/gnulib-cache.m4.tmp "$destdir"/$m4base/gnulib-cache.m4
1216     else
1217       echo "Create $m4base/gnulib-cache.m4"
1218       cat "$destdir"/$m4base/gnulib-cache.m4.tmp
1219       rm -f "$destdir"/$m4base/gnulib-cache.m4.tmp
1220     fi
1221   fi
1222
1223   # Create m4/gnulib-comp.m4.
1224   (
1225     echo "# Copyright (C) 2004 Free Software Foundation, Inc."
1226     echo "# This file is free software, distributed under the terms of the GNU"
1227     echo "# General Public License.  As a special exception to the GNU General"
1228     echo "# Public License, this file may be distributed as part of a program"
1229     echo "# that contains a configuration script generated by Autoconf, under"
1230     echo "# the same distribution terms as the rest of that program."
1231     echo "#"
1232     echo "# Generated by gnulib-tool."
1233     echo "#"
1234     echo "# This file represents the compiled summary of the specification in"
1235     echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
1236     echo "# to be invoked from configure.ac."
1237     echo "# In projects using CVS, this file can be treated like other built files."
1238     echo
1239     echo
1240     echo "# This macro should be invoked from $configure_ac, in the section"
1241     echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
1242     echo "# any checks for libraries, header files, types and library functions."
1243     echo "AC_DEFUN([${macro_prefix}_EARLY],"
1244     echo "["
1245     if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 > /dev/null; then
1246       echo "  AC_REQUIRE([AC_GNU_SOURCE])"
1247     fi
1248     if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 > /dev/null; then
1249       echo "  AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])"
1250     fi
1251     echo "])"
1252     echo
1253     echo "# This macro should be invoked from $configure_ac, in the section"
1254     echo "# \"Check for header files, types and library functions\"."
1255     echo "AC_DEFUN([${macro_prefix}_INIT],"
1256     echo "["
1257     if test -z "$libtool"; then
1258       echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1259     else
1260       echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1261     fi
1262     for module in $modules; do
1263       func_verify_module
1264       if test -n "$module"; then
1265         func_get_autoconf_snippet "$module" | sed -e '/^$/d;' -e 's/^/  /' -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./'
1266         if test "$module" = 'alloca' && test -n "$libtool"; then
1267           echo 'changequote(,)dnl'
1268           echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
1269           echo 'changequote([, ])dnl'
1270           echo 'AC_SUBST([LTALLOCA])'
1271         fi
1272       fi
1273     done
1274     echo "])"
1275     echo
1276     echo "# This macro records the list of files which have been installed by"
1277     echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
1278     echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
1279     echo "$files" | sed -e 's,^,  ,'
1280     echo "])"
1281   ) > "$destdir"/$m4base/gnulib-comp.m4.tmp
1282   if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1283     if cmp "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4.tmp > /dev/null; then
1284       rm -f "$destdir"/$m4base/gnulib-comp.m4.tmp
1285     else
1286       if $doit; then
1287         echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1288         mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
1289         mv -f "$destdir"/$m4base/gnulib-comp.m4.tmp "$destdir"/$m4base/gnulib-comp.m4
1290       else
1291         echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1292         if false; then
1293           cat "$destdir"/$m4base/gnulib-comp.m4.tmp
1294           echo
1295           echo "# gnulib-comp.m4 ends here"
1296         fi
1297         rm -f "$destdir"/$m4base/gnulib-comp.m4.tmp
1298       fi
1299     fi
1300   else
1301     if $doit; then
1302       echo "Creating $m4base/gnulib-comp.m4"
1303       mv -f "$destdir"/$m4base/gnulib-comp.m4.tmp "$destdir"/$m4base/gnulib-comp.m4
1304     else
1305       echo "Create $m4base/gnulib-comp.m4"
1306       cat "$destdir"/$m4base/gnulib-comp.m4.tmp
1307       rm -f "$destdir"/$m4base/gnulib-comp.m4.tmp
1308     fi
1309   fi
1310
1311   if test -n "$inctests"; then
1312     # Create tests/Makefile.am.
1313     func_emit_tests_Makefile_am > "$destdir"/$testsbase/Makefile.am.tmp
1314     if test -f "$destdir"/$testsbase/Makefile.am; then
1315       if cmp "$destdir"/$testsbase/Makefile.am "$destdir"/$testsbase/Makefile.am.tmp > /dev/null; then
1316         rm -f "$destdir"/$testsbase/Makefile.am.tmp
1317       else
1318         if $doit; then
1319           echo "Updating $testsbase/Makefile.am (backup in $testsbase/Makefile.am~)"
1320           mv -f "$destdir"/$testsbase/Makefile.am "$destdir"/$testsbase/Makefile.am~
1321           mv -f "$destdir"/$testsbase/Makefile.am.tmp "$destdir"/$testsbase/Makefile.am
1322         else
1323           echo "Update $testsbase/Makefile.am (backup in $testsbase/Makefile.am~)"
1324           rm -f "$destdir"/$testsbase/Makefile.am.tmp
1325         fi
1326       fi
1327     else
1328       if $doit; then
1329         echo "Creating $testsbase/Makefile.am"
1330         mv -f "$destdir"/$testsbase/Makefile.am.tmp "$destdir"/$testsbase/Makefile.am
1331       else
1332         echo "Create $testsbase/Makefile.am"
1333         rm -f "$destdir"/$testsbase/Makefile.am.tmp
1334       fi
1335     fi
1336   fi
1337
1338   echo "Finished."
1339   echo
1340   echo "You may need to add #include directives for the following .h files."
1341   for module in $modules; do
1342     func_get_include_directive "$module"
1343   done | LC_ALL=C sort -u | sed -e '/^$/d;' -e 's/^/  /'
1344   echo
1345   echo "Don't forget to"
1346   echo "  - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1347   if test -n "$inctests"; then
1348     echo "  - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1349   fi
1350   sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
1351   sourcebase_base=`basename "$sourcebase"`
1352   echo "  - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
1353   if test -n "$inctests"; then
1354     testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
1355     testsbase_base=`basename "$testsbase"`
1356     echo "  - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
1357   fi
1358   echo "  - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
1359   echo "  - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
1360   echo "  - invoke ${macro_prefix}_INIT in $configure_ac."
1361 }
1362
1363 # func_create_testdir testdir modules
1364 # Input:
1365 # - auxdir          directory relative to destdir where to place build aux files
1366 func_create_testdir ()
1367 {
1368   testdir="$1"
1369   modules="$2"
1370   modules=`for m in $modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
1371
1372   # Determine final module list.
1373   func_modules_transitive_closure
1374   echo "Module list with included dependencies:"
1375   echo "$modules" | sed -e 's/^/  /'
1376
1377   # Determine final file list.
1378   func_modules_to_filelist
1379   echo "File list:"
1380   echo "$files" | sed -e 's/^/  /'
1381
1382   # Create directories.
1383   for d in `echo "$files" | sed -n -e 's,^\(.*\)/[^/]*,\1,p'`; do
1384     if test "$d" = build-aux; then
1385       mkdir -p "$testdir/$auxdir"
1386     else
1387       mkdir -p "$testdir/$d"
1388     fi
1389   done
1390
1391   # Copy files or make symbolic links.
1392   for f in $files; do
1393     case "$f" in
1394       build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1395       *) g="$f" ;;
1396     esac
1397     ln "$gnulib_dir/$f" "$testdir/$g" 2>/dev/null ||
1398     if test -z "$symbolic"; then
1399       cp -p "$gnulib_dir/$f" "$testdir/$g"
1400     else
1401       ln -s "$gnulib_dir/$f" "$testdir/$g"
1402     fi
1403   done
1404
1405   # Create lib/Makefile.am.
1406   mkdir -p "$testdir/lib"
1407   func_emit_lib_Makefile_am > "$testdir/lib/Makefile.am"
1408
1409   # Create m4/Makefile.am.
1410   mkdir -p "$testdir/m4"
1411   (echo "## Process this file with automake to produce Makefile.in."
1412    echo
1413    echo "EXTRA_DIST ="
1414    for f in $files; do
1415      case "$f" in
1416        m4/* )
1417          echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
1418      esac
1419    done
1420   ) > "$testdir/m4/Makefile.am"
1421
1422   subdirs="lib m4"
1423   subdirs_with_configure_ac=""
1424
1425   if test -f "$testdir"/m4/gettext.m4; then
1426     # Avoid stupid error message from automake:
1427     # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
1428     mkdir -p "$testdir/po"
1429     (echo "## Process this file with automake to produce Makefile.in."
1430     ) > "$testdir/po/Makefile.am"
1431     subdirs="$subdirs po"
1432   fi
1433
1434   if test -n "$inctests"; then
1435     test -d "$testdir/tests" || mkdir "$testdir/tests"
1436     # Create tests/Makefile.am.
1437     sourcebase=lib
1438     m4base=m4
1439     testsbase=tests
1440     func_emit_tests_Makefile_am > "$testdir/tests/Makefile.am"
1441     # Create tests/configure.ac.
1442     (echo "# Process this file with autoconf to produce a configure script."
1443      echo "AC_INIT([dummy], [0])"
1444      echo "AC_CONFIG_AUX_DIR([../$auxdir])"
1445      echo "AM_INIT_AUTOMAKE"
1446      echo
1447      echo "AM_CONFIG_HEADER([config.h])"
1448      echo
1449      echo "AC_PROG_CC"
1450      echo "AC_PROG_INSTALL"
1451      echo "AC_PROG_MAKE_SET"
1452      echo "AC_PROG_RANLIB"
1453      echo
1454      if grep AC_GNU_SOURCE "$testdir"/m4/*.m4 > /dev/null; then
1455        echo "AC_GNU_SOURCE"
1456        echo
1457      fi
1458      if grep gl_USE_SYSTEM_EXTENSIONS "$testdir"/m4/*.m4 > /dev/null; then
1459        echo "gl_USE_SYSTEM_EXTENSIONS"
1460        echo
1461      fi
1462      if test -z "$libtool"; then
1463        echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1464      else
1465        echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1466      fi
1467      # We don't have explicit ordering constraints between the various
1468      # autoconf snippets. It's cleanest to put those of the library before
1469      # those of the tests.
1470      for module in $modules; do
1471        func_verify_nontests_module
1472        if test -n "$module"; then
1473          func_get_autoconf_snippet "$module"
1474        fi
1475      done
1476      for module in $modules; do
1477        func_verify_tests_module
1478        if test -n "$module"; then
1479          func_get_autoconf_snippet "$module"
1480        fi
1481      done
1482      echo
1483      # Usually tests/config.h will be a superset of config.h. Verify this by
1484      # "merging" config.h into tests/config.h; look out for gcc warnings.
1485      echo "AH_TOP([#include \"../config.h\"])"
1486      echo
1487      echo "AC_OUTPUT([Makefile])"
1488     ) > "$testdir/tests/configure.ac"
1489     subdirs="$subdirs tests"
1490     subdirs_with_configure_ac="$subdirs_with_configure_ac tests"
1491   fi
1492
1493   # Create Makefile.am.
1494   (echo "## Process this file with automake to produce Makefile.in."
1495    echo
1496    echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1497    echo
1498    echo "SUBDIRS = $subdirs"
1499    echo
1500    echo "ACLOCAL_AMFLAGS = -I m4"
1501   ) > "$testdir/Makefile.am"
1502
1503   # Create configure.ac.
1504   (echo "# Process this file with autoconf to produce a configure script."
1505    echo "AC_INIT([dummy], [0])"
1506    if test "$auxdir" != "."; then
1507      echo "AC_CONFIG_AUX_DIR([$auxdir])"
1508    fi
1509    echo "AM_INIT_AUTOMAKE"
1510    echo
1511    echo "AM_CONFIG_HEADER([config.h])"
1512    echo
1513    echo "AC_PROG_CC"
1514    echo "AC_PROG_INSTALL"
1515    echo "AC_PROG_MAKE_SET"
1516    echo "AC_PROG_RANLIB"
1517    echo
1518    if grep AC_GNU_SOURCE "$testdir"/m4/*.m4 > /dev/null; then
1519      echo "AC_GNU_SOURCE"
1520      echo
1521    fi
1522    if grep gl_USE_SYSTEM_EXTENSIONS "$testdir"/m4/*.m4 > /dev/null; then
1523      echo "gl_USE_SYSTEM_EXTENSIONS"
1524      echo
1525    fi
1526    if test -z "$libtool"; then
1527      echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1528    else
1529      echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1530    fi
1531    for module in $modules; do
1532      func_verify_nontests_module
1533      if test -n "$module"; then
1534        func_get_autoconf_snippet "$module"
1535      fi
1536    done
1537    echo
1538    if test -n "$subdirs_with_configure_ac"; then
1539      echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
1540    fi
1541    makefiles="Makefile"
1542    for d in $subdirs; do
1543      # For subdirs that have a configure.ac by their own, it's the subdir's
1544      # configure.ac which creates the subdir's Makefile.am, not this one.
1545      case " $subdirs_with_configure_ac " in
1546        *" $d "*) ;;
1547        *) makefiles="$makefiles $d/Makefile" ;;
1548      esac
1549    done
1550    echo "AC_OUTPUT([$makefiles])"
1551   ) > "$testdir/configure.ac"
1552
1553   # Create autogenerated files.
1554   (cd "$testdir"
1555    echo "executing ${AUTORECONF} --force --install"
1556    ${AUTORECONF} --force --install
1557   )
1558   if grep '^BUILT_SOURCES *+=' "$testdir/lib/Makefile.am" > /dev/null; then
1559     (cd "$testdir"
1560      ./configure
1561        cd lib
1562        echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
1563        make built_sources
1564        cd ..
1565      make distclean
1566     )
1567   fi
1568 }
1569
1570 # func_create_megatestdir megatestdir allmodules
1571 # Input:
1572 # - auxdir          directory relative to destdir where to place build aux files
1573 func_create_megatestdir ()
1574 {
1575   megatestdir="$1"
1576   allmodules="$2"
1577   if test -z "$allmodules"; then
1578     allmodules=`func_all_modules`
1579   fi
1580
1581   megasubdirs=
1582   # First, all modules one by one.
1583   for onemodule in $allmodules; do
1584     func_create_testdir "$megatestdir/$onemodule" $onemodule
1585     megasubdirs="${megasubdirs}$onemodule "
1586   done
1587   # Then, all modules all together.
1588   # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
1589   allmodules=`for m in $allmodules; do if test $m != fnmatch-posix; then echo $m; fi; done`
1590   func_create_testdir "$megatestdir/ALL" "$allmodules"
1591   megasubdirs="${megasubdirs}ALL"
1592
1593   # Create Makefile.am.
1594   (echo "## Process this file with automake to produce Makefile.in."
1595    echo
1596    echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1597    echo
1598    echo "SUBDIRS = $megasubdirs"
1599   ) > "$megatestdir/Makefile.am"
1600
1601   # Create configure.ac.
1602   (echo "# Process this file with autoconf to produce a configure script."
1603    echo "AC_INIT([dummy], [0])"
1604    if test "$auxdir" != "."; then
1605      echo "AC_CONFIG_AUX_DIR([$auxdir])"
1606    fi
1607    echo "AM_INIT_AUTOMAKE"
1608    echo
1609    echo "AC_PROG_MAKE_SET"
1610    echo
1611    echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
1612    echo "AC_OUTPUT([Makefile])"
1613   ) > "$megatestdir/configure.ac"
1614
1615   # Create autogenerated files.
1616   (cd "$megatestdir"
1617    echo "executing ${AUTORECONF} --install"
1618    ${AUTORECONF} --install
1619   )
1620 }
1621
1622 case $mode in
1623   "" )
1624     func_fatal_error "no mode specified" ;;
1625
1626   list )
1627     func_all_modules
1628     ;;
1629
1630   import | update )
1631     
1632     # Where to import.
1633     if test -z "$destdir"; then
1634       destdir=.
1635     fi
1636     test -d "$destdir" \
1637       || func_fatal_error "destination directory does not exist: $destdir"
1638
1639     # Prefer configure.ac to configure.in.
1640     if test -f "$destdir"/configure.ac; then
1641       configure_ac="$destdir/configure.ac"
1642     else
1643       if test -f "$destdir"/configure.in; then
1644         configure_ac="$destdir/configure.in"
1645       else
1646         func_fatal_error "cannot find $destdir/configure.ac"
1647       fi
1648     fi
1649
1650     test -f "$destdir"/Makefile.am \
1651       || func_fatal_error "cannot find $destdir/Makefile.am"
1652
1653     # Analyze configure.ac.
1654     guessed_auxdir="."
1655     guessed_libtool=
1656     my_sed_traces='
1657       s,#.*$,,
1658       s,^dnl .*$,,
1659       s, dnl .*$,,
1660       /AC_CONFIG_AUX_DIR/ {
1661         s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
1662       }
1663       /A[CM]_PROG_LIBTOOL/ {
1664         s,^.*$,guessed_libtool=true,p
1665       }'
1666     eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
1667
1668     if test -z "$auxdir"; then
1669       auxdir="$guessed_auxdir"
1670     fi
1671
1672     # Determine where to apply func_import.
1673     if test -n "$m4base"; then
1674       # Apply func_import to a particular gnulib directory.
1675       # Any number of additional modules can be given.
1676       if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
1677         # First use of gnulib in the given m4base.
1678         test -n "$supplied_libname" || supplied_libname=true
1679         test -n "$sourcebase" || sourcebase="lib"
1680         test -n "$testsbase" || testsbase="tests"
1681         test -n "$macro_prefix" || macro_prefix="gl"
1682       fi
1683       func_import "$*"
1684     else
1685       # Apply func_import to all gnulib directories.
1686       # To get this list of directories, look at Makefile.am. (Not at
1687       # configure, because it may be omitted from CVS. Also, don't run
1688       # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
1689       aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[  ]*=' "$destdir"/Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[       ]*=\(.*\)$/\1/'`
1690       m4dirs=
1691       m4dirs_count=0
1692       m4dir_is_next=
1693       for arg in $aclocal_amflags; do
1694         if test -n "$m4dir_is_next"; then
1695           # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
1696           case "$arg" in
1697             /*) ;;
1698             *)
1699               if test -f "$destdir/$arg"/gnulib-cache.m4; then
1700                 m4dirs="$m4dirs $arg"
1701                 m4dirs_count=`expr $m4dirs_count + 1`
1702               fi
1703               ;;
1704           esac
1705         else
1706           if test "X$arg" = "X-I"; then
1707             m4dir_is_next=yes
1708           else
1709             m4dir_is_next=
1710           fi
1711         fi
1712       done
1713       if test $m4dirs_count = 0; then
1714         # First use of gnulib in a package.
1715         # Any number of additional modules can be given.
1716         test -n "$supplied_libname" || supplied_libname=true
1717         test -n "$sourcebase" || sourcebase="lib"
1718         m4base="m4"
1719         test -n "$testsbase" || testsbase="tests"
1720         test -n "$macro_prefix" || macro_prefix="gl"
1721         func_import "$*"
1722       else
1723         if test $m4dirs_count = 1; then
1724           # There's only one use of gnulib here. Assume the user means it.
1725           # Any number of additional modules can be given.
1726           for m4base in $m4dirs; do
1727             func_import "$*"
1728           done
1729         else
1730           # Ambiguous - guess what the user meant.
1731           if test $# = 0; then
1732             # No further arguments. Guess the user wants to update all of them.
1733             for m4base in $m4dirs; do
1734               func_import
1735             done
1736           else
1737             # Really ambiguous.
1738             func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
1739           fi
1740         fi
1741       fi
1742     fi
1743     ;;
1744
1745   create-testdir )
1746     if test -z "$destdir"; then
1747       func_fatal_error "please specify --dir option"
1748     fi
1749     mkdir "$destdir"
1750     test -d "$destdir" \
1751       || func_fatal_error "could not create destination directory"
1752     test -n "$auxdir" || auxdir="build-aux"
1753     func_create_testdir "$destdir" "$*"
1754     ;;
1755
1756   create-megatestdir )
1757     if test -z "$destdir"; then
1758       func_fatal_error "please specify --dir option"
1759     fi
1760     mkdir "$destdir" || func_fatal_error "could not create destination directory"
1761     test -n "$auxdir" || auxdir="build-aux"
1762     func_create_megatestdir "$destdir" "$*"
1763     ;;
1764
1765   test )
1766     test -n "$destdir" || destdir=testdir$$
1767     mkdir "$destdir" || func_fatal_error "could not create destination directory"
1768     test -n "$auxdir" || auxdir="build-aux"
1769     func_create_testdir "$destdir" "$*"
1770     cd "$destdir"
1771       mkdir build
1772       cd build
1773         ../configure
1774         make
1775         make check
1776         make distclean
1777         remaining=`find . -type f -print`
1778         if test -n "$remaining"; then
1779           echo "Remaining files:" $remaining 1>&2
1780           echo "gnulib-tool: *** Stop." 1>&2
1781           exit 1
1782         fi
1783       cd ..
1784     cd ..
1785     rm -rf "$destdir"
1786     ;;
1787
1788   megatest )
1789     test -n "$destdir" || destdir=testdir$$
1790     mkdir "$destdir" || func_fatal_error "could not create destination directory"
1791     test -n "$auxdir" || auxdir="build-aux"
1792     func_create_megatestdir "$destdir" "$*"
1793     cd "$destdir"
1794       mkdir build
1795       cd build
1796         ../configure
1797         make
1798         make check
1799         make distclean
1800         remaining=`find . -type f -print`
1801         if test -n "$remaining"; then
1802           echo "Remaining files:" $remaining 1>&2
1803           echo "gnulib-tool: *** Stop." 1>&2
1804           exit 1
1805         fi
1806       cd ..
1807     cd ..
1808     rm -rf "$destdir"
1809     ;;
1810
1811   extract-description )
1812     for module
1813     do
1814       func_verify_module
1815       if test -n "$module"; then
1816         func_get_description "$module"
1817       fi
1818     done
1819     ;;
1820
1821   extract-filelist )
1822     for module
1823     do
1824       func_verify_module
1825       if test -n "$module"; then
1826         func_get_filelist "$module"
1827       fi
1828     done
1829     ;;
1830
1831   extract-dependencies )
1832     for module
1833     do
1834       func_verify_module
1835       if test -n "$module"; then
1836         func_get_dependencies "$module"
1837       fi
1838     done
1839     ;;
1840
1841   extract-autoconf-snippet )
1842     for module
1843     do
1844       func_verify_module
1845       if test -n "$module"; then
1846         func_get_autoconf_snippet "$module"
1847       fi
1848     done
1849     ;;
1850
1851   extract-automake-snippet )
1852     for module
1853     do
1854       func_verify_module
1855       if test -n "$module"; then
1856         func_get_automake_snippet "$module"
1857       fi
1858     done
1859     ;;
1860
1861   extract-include-directive )
1862     for module
1863     do
1864       func_verify_module
1865       if test -n "$module"; then
1866         func_get_include_directive "$module"
1867       fi
1868     done
1869     ;;
1870
1871   extract-license )
1872     for module
1873     do
1874       func_verify_module
1875       if test -n "$module"; then
1876         func_get_license "$module"
1877       fi
1878     done
1879     ;;
1880
1881   extract-maintainer )
1882     for module
1883     do
1884       func_verify_module
1885       if test -n "$module"; then
1886         func_get_maintainer "$module"
1887       fi
1888     done
1889     ;;
1890
1891   extract-tests-module )
1892     for module
1893     do
1894       func_verify_module
1895       if test -n "$module"; then
1896         func_get_tests_module "$module"
1897       fi
1898     done
1899     ;;
1900
1901   * )
1902     func_fatal_error "unknown operation mode --$mode" ;;
1903 esac
1904
1905 exit 0