45601d99546c5bc1db98b31130816b8e513c1c96
[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-08-29 19:59:56 $'
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 --create-testdir --dir=directory module1 ... moduleN
48        gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
49        gnulib-tool --test --dir=directory module1 ... moduleN
50        gnulib-tool --megatest --dir=directory [module1 ... moduleN]
51        gnulib-tool --extract-description module
52        gnulib-tool --extract-filelist module
53        gnulib-tool --extract-dependencies module
54        gnulib-tool --extract-autoconf-snippet module
55        gnulib-tool --extract-automake-snippet module
56        gnulib-tool --extract-include-directive module
57        gnulib-tool --extract-license module
58        gnulib-tool --extract-maintainer module
59        gnulib-tool --extract-tests-module module
60
61 Operation modes:
62       --list                print the available module names
63       --import              import the given modules into the current package
64       --create-testdir      create a scratch package with the given modules
65       --create-megatestdir  create a mega scratch package with the given modules
66                             one by one and all together
67       --test                test the combination of the given modules
68                             (recommended to use CC=\"gcc -Wall\" here)
69       --megatest            test the given modules one by one and all together
70                             (recommended to use CC=\"gcc -Wall\" here)
71       --extract-description        extract the description
72       --extract-filelist           extract the list of files
73       --extract-dependencies       extract the dependencies
74       --extract-autoconf-snippet   extract the snippet for configure.ac
75       --extract-automake-snippet   extract the snippet for lib/Makefile.am
76       --extract-include-directive  extract the #include directive
77       --extract-license            report the license terms of the source files
78                                    under lib/
79       --extract-maintainer         report the maintainer(s) inside gnulib
80       --extract-tests-module       report the unit test module, if it exists
81
82 Options:
83       --dir=DIRECTORY       specify the target directory
84                             For --import, this specifies where your
85                             configure.ac can be found.  Defaults to current
86                             directory.
87       --lib=LIBRARY         Specify the library name.  Defaults to 'libgnu'.
88       --source-base=DIRECTORY
89                             Directory relative --dir where source code is
90                             placed (default \"lib\"), for --import.
91       --m4-base=DIRECTORY   Directory relative --dir where *.m4 macros are
92                             placed (default \"m4\"), for --import.
93       --tests-base=DIRECTORY
94                             Directory relative --dir where unit tests are
95                             placed (default \"tests\"), for --import.
96       --aux-dir=DIRECTORY   Directory relative --dir where auxiliary build
97                             tools are placed (default \"build-aux\").
98       --with-tests          Include unit tests for the included modules.
99       --avoid=MODULE        Avoid including the given MODULE. Useful if you
100                             have code that provides equivalent functionality.
101                             This option can be repeated.
102       --lgpl                Abort if modules aren't available under the LGPL.
103                             Also modify license template from GPL to LGPL.
104       --libtool             Use libtool rules, for --import.
105       --no-changelog        don't update or create ChangeLog files
106       --dry-run             For --import, only print what would have been done.
107   -s, --symbolic, --symlink Make symbolic links instead of copying files.
108
109 Report bugs to <bug-gnulib@gnu.org>."
110 }
111
112 # func_version
113 # outputs to stdout the --version message.
114 func_version ()
115 {
116   echo "$progname (GNU $package) $version"
117   echo "Copyright (C) 2002-2005 Free Software Foundation, Inc.
118 This is free software; see the source for copying conditions.  There is NO
119 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
120   echo "Written by" "Bruno Haible" "and" "Simon Josefsson"
121 }
122
123 # func_fatal_error message
124 # outputs to stderr a fatal error message, and terminates the program.
125 func_fatal_error ()
126 {
127   echo "gnulib-tool: *** $1" 1>&2
128   echo "gnulib-tool: *** Stop." 1>&2
129   exit 1
130 }
131
132 # func_cp_if_changed SRC DEST
133 # Like cp, but avoids munging timestamps if the file hasn't changed.
134 # Uses also the variables
135 # - dry_run         true if actions shall only be printed, blank otherwise
136 func_cp_if_changed ()
137 {
138   if test $# -ne 2; then
139     echo "usage: func_cp_if_changed SRC DEST" >&2
140   fi
141   test -n "$dry_run" && dry=echo
142   if cmp "$1" "$2" >/dev/null 2>&1; then
143     :
144   else
145     $dry cp -p "$1" "$2"
146   fi
147 }
148
149 # func_mv_if_changed SRC DEST
150 # Like mv, but avoids munging timestamps if the file hasn't changed.
151 # Removes SRC if it is not renamed.
152 # Uses also the variables
153 # - dry_run         true if actions shall only be printed, blank otherwise
154 func_mv_if_changed ()
155 {
156   if test $# -ne 2; then
157     echo "usage: func_mv_if_changed SRC DEST" >&2
158   fi
159   test -n "$dry_run" && dry=echo
160   if cmp "$1" "$2" >/dev/null 2>&1; then
161     $dry rm "$1"
162   else
163     $dry mv "$1" "$2"
164   fi
165 }
166
167 # func_ln_if_changed SRC DEST
168 # Like ln -s, but avoids munging timestamps if the link is correct.
169 # Uses also the variables
170 # - dry_run         true if actions shall only be printed, blank otherwise
171 func_ln_if_changed ()
172 {
173   if test $# -ne 2; then
174     echo "usage: func_ln_if_changed SRC DEST" >&2
175   fi
176   test -n "$dry_run" && dry=echo
177   if test -L "$2" -a "$1" = "`readlink "$2"`"; then
178     :
179   else
180     $dry rm -f "$2"
181     $dry ln -s "$1" "$2"
182   fi
183 }
184
185 # Command-line option processing.
186 # Removes the OPTIONS from the arguments. Sets the variables:
187 # - mode            list or import or create-testdir or create-megatestdir
188 # - destdir         from --dir
189 # - libname, supplied_libname  from --lib
190 # - sourcebase      from --source-base
191 # - m4base          from --m4-base
192 # - testsbase       from --tests-base
193 # - auxdir          from --aux-dir
194 # - inctests        true if --with-tests was given, blank otherwise
195 # - avoidlist       list of modules to avoid, from --avoid
196 # - lgpl            true if --lgpl was given, blank otherwise
197 # - libtool         true if --libtool was given, blank otherwise
198 # - do_changelog    false if --no-changelog was given, : otherwise
199 # - dry_run         true if --dry-run was given, blank otherwise
200 {
201   mode=
202   destdir=
203   libname=libgnu
204   supplied_libname=
205   sourcebase=
206   m4base=
207   testsbase=
208   auxdir=
209   inctests=
210   avoidlist=
211   lgpl=
212   libtool=
213   do_changelog=:
214   dry_run=
215   symbolic=
216
217   supplied_opts="$@"
218
219   while test $# -gt 0; do
220     case "$1" in
221       --list | --lis )
222         mode=list
223         shift ;;
224       --import | --impor | --impo | --imp | --im | --i )
225         mode=import
226         shift ;;
227       --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
228         mode=create-testdir
229         shift ;;
230       --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
231         mode=create-megatestdir
232         shift ;;
233       --test | --tes | --te | --t )
234         mode=test
235         shift ;;
236       --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
237         mode=megatest
238         shift ;;
239       --extract-* )
240         mode=`echo "X$1" | sed -e 's/^X--//'`
241         shift ;;
242       --dir )
243         shift
244         if test $# = 0; then
245           func_fatal_error "missing argument for --dir"
246         fi
247         destdir=$1
248         shift ;;
249       --dir=* )
250         destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
251         shift ;;
252       --lib )
253         shift
254         if test $# = 0; then
255           func_fatal_error "missing argument for --lib"
256         fi
257         libname=$1
258         supplied_libname=true
259         shift ;;
260       --lib=* )
261         libname=`echo "X$1" | sed -e 's/^X--lib=//'`
262         supplied_libname=true
263         shift ;;
264       --source-base )
265         shift
266         if test $# = 0; then
267           func_fatal_error "missing argument for --source-base"
268         fi
269         sourcebase=$1
270         shift ;;
271       --source-base=* )
272         sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
273         shift ;;
274       --m4-base )
275         shift
276         if test $# = 0; then
277           func_fatal_error "missing argument for --m4-base"
278         fi
279         m4base=$1
280         shift ;;
281       --m4-base=* )
282         m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
283         shift ;;
284       --tests-base )
285         shift
286         if test $# = 0; then
287           func_fatal_error "missing argument for --tests-base"
288         fi
289         testsbase=$1
290         shift ;;
291       --tests-base=* )
292         testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
293         shift ;;
294       --aux-dir )
295         shift
296         if test $# = 0; then
297           func_fatal_error "missing argument for --aux-dir"
298         fi
299         auxdir=$1
300         shift ;;
301       --aux-dir=* )
302         auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
303         shift ;;
304       --with-tests )
305         inctests=true
306         shift ;;
307       --avoid )
308         shift
309         if test $# = 0; then
310           func_fatal_error "missing argument for --avoid"
311         fi
312         avoidlist="$avoidlist $1"
313         shift ;;
314       --avoid=* )
315         avoidlist="$avoidlist "`echo "X$1" | sed -e 's/^X--avoid=//'`
316         shift ;;
317       --lgpl )
318         lgpl=true
319         shift ;;
320       --libtool )
321         libtool=true
322         shift ;;
323       --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
324         do_changelog=false
325         shift ;;
326       --dry-run )
327         dry_run=true
328         shift ;;
329       -s | --symbolic | --symlink )
330         symbolic=true
331         shift ;;
332       --help | --hel | --he | --h )
333         func_usage
334         exit 0 ;;
335       --version | --versio | --versi | --vers | --ver | --ve | --v )
336         func_version
337         exit 0 ;;
338       -- )
339         # Stop option prcessing
340         shift
341         break ;;
342       -* )
343         echo "gnulib-tool: unknown option $1" 1>&2
344         echo "Try 'gnulib-tool --help' for more information." 1>&2
345         exit 1 ;;
346       * )
347         break ;;
348     esac
349   done
350 }
351
352 case "$0" in
353   /*) self_abspathname="$0" ;;
354   */*) self_abspathname=`pwd`/"$0" ;;
355   *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
356        if test -x "$d/$0" && test ! -d "$d/$0"; then
357          self_abspathname="$d/$0"
358          break
359        fi
360      done
361      if test -z "$self_abspathname"; then
362        func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
363      fi
364      ;;
365 esac
366 while test -h "$self_abspathname"; do
367   # Resolve symbolic link.
368   sedexpr1='s, -> ,#%%#,'
369   sedexpr2='s,^.*#%%#\(.*\)$,\1,p'
370   linkval=`LC_ALL=C ls -l "$self_abspathname" | sed -e "$sedexpr1" | sed -n -e "$sedexpr2"`
371   test -n "$linkval" || break
372   case "$linkval" in
373     /* ) self_abspathname="$linkval" ;;
374     * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
375   esac
376 done
377 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
378
379 # func_all_modules
380 func_all_modules ()
381 {
382   # Filter out metainformation files like README, which are not modules.
383   # Filter out unit test modules; they can be retrieved through
384   # --extract-tests-module if desired.
385   (cd "$gnulib_dir/modules" && ls -1) \
386       | sed -e '/^CVS$/d' -e '/^ChangeLog$/d' -e '/^README$/d' -e '/^TEMPLATE$/d' -e '/^TEMPLATE-TESTS$/d' -e '/~$/d' \
387       | sed -e '/-tests$/d' \
388       | sort
389 }
390
391 # func_verify_module
392 # verifies a module name
393 func_verify_module ()
394 {
395   if test ! -f "$gnulib_dir/modules/$module" \
396      || test "CVS" = "$module" \
397      || test "ChangeLog" = "$module" \
398      || test "README" = "$module" \
399      || test "TEMPLATE" = "$module" \
400      || test "TEMPLATE-TESTS" = "$module"; then
401     echo "gnulib-tool: module $module doesn't exist" 1>&2
402     module=
403   fi
404 }
405
406 # func_verify_nontests_module
407 # verifies a module name, excluding tests modules
408 func_verify_nontests_module ()
409 {
410   case "$module" in
411     *-tests ) module= ;;
412     * ) func_verify_module ;;
413   esac
414 }
415
416 # func_verify_tests_module
417 # verifies a module name, considering only tests modules
418 func_verify_tests_module ()
419 {
420   case "$module" in
421     *-tests ) func_verify_module ;;
422     * ) module= ;;
423   esac
424 }
425
426 sed_extract_prog=':[    ]*$/ {
427   :a
428     n
429     s/^Description:[    ]*$//
430     s/^Files:[  ]*$//
431     s/^Depends-on:[     ]*$//
432     s/^configure\.ac:[  ]*$//
433     s/^Makefile\.am:[   ]*$//
434     s/^Include:[        ]*$//
435     s/^License:[        ]*$//
436     s/^Maintainer:[     ]*$//
437     tb
438     p
439     ba
440   :b
441 }'
442
443 # func_get_description module
444 func_get_description ()
445 {
446   sed -n -e "/^Description$sed_extract_prog" < "$gnulib_dir/modules/$1"
447 }
448
449 # func_get_filelist module
450 func_get_filelist ()
451 {
452   sed -n -e "/^Files$sed_extract_prog" < "$gnulib_dir/modules/$1"
453   #echo m4/onceonly.m4
454   echo m4/onceonly_2_57.m4
455 }
456
457 # func_get_dependencies module
458 func_get_dependencies ()
459 {
460   # ${module}-tests always implicitly depends on ${module}.
461   echo "$1" | sed -n -e 's/-tests//p'
462   # Then the explicit dependencies listed in the module description.
463   sed -n -e "/^Depends-on$sed_extract_prog" < "$gnulib_dir/modules/$1"
464 }
465
466 # func_get_autoconf_snippet module
467 func_get_autoconf_snippet ()
468 {
469   sed -n -e "/^configure\.ac$sed_extract_prog" < "$gnulib_dir/modules/$1"
470 }
471
472 # func_get_automake_snippet module
473 func_get_automake_snippet ()
474 {
475   sed -n -e "/^Makefile\.am$sed_extract_prog" < "$gnulib_dir/modules/$1"
476 }
477
478 # func_get_include_directive module
479 func_get_include_directive ()
480 {
481   sed -n -e "/^Include$sed_extract_prog" < "$gnulib_dir/modules/$1" | \
482   sed -e 's/^\(["<]\)/#include \1/'
483 }
484
485 # func_get_license module
486 func_get_license ()
487 {
488   sed -n -e "/^License$sed_extract_prog" < "$gnulib_dir/modules/$1"
489 }
490
491 # func_get_maintainer module
492 func_get_maintainer ()
493 {
494   sed -n -e "/^Maintainer$sed_extract_prog" < "$gnulib_dir/modules/$1"
495 }
496
497 # func_get_tests_module module
498 func_get_tests_module ()
499 {
500   # The naming convention for tests modules is hardwired: ${module}-tests.
501   if test -f modules/"$1"-tests; then
502     echo "$1"-tests
503   fi
504 }
505
506 # func_acceptable module
507 # tests whether a module is acceptable.
508 # Input:
509 # - avoidlist       list of modules to avoid
510 func_acceptable ()
511 {
512   for avoid in $avoidlist; do
513     if test "$avoid" = "$1"; then
514       return 1
515     fi
516   done
517   return 0
518 }
519
520 # func_modules_transitive_closure
521 # Input:
522 # - modules         list of specified modules
523 # - inctests        true if tests should be included, blank otherwise
524 # - avoidlist       list of modules to avoid
525 # Output:
526 # - modules         list of modules, including dependencies
527 func_modules_transitive_closure ()
528 {
529   while true; do
530     xmodules=
531     for module in $modules; do
532       func_verify_module
533       if test -n "$module"; then
534         # Duplicate dependencies are harmless, but Jim wants a warning.
535         duplicated_deps=`func_get_dependencies $module | sort | uniq -d`
536         if test -n "$duplicated_deps"; then
537           echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
538         fi
539         if func_acceptable $module; then
540           xmodules="$xmodules $module"
541           for depmodule in `func_get_dependencies $module`; do
542             if func_acceptable $depmodule; then
543               xmodules="$xmodules $depmodule"
544             fi
545           done
546           if test -n "$inctests"; then
547             testsmodule=`func_get_tests_module $module`
548             if test -n "$testsmodule"; then
549               if func_acceptable $testsmodule; then
550                 xmodules="$xmodules $testsmodule"
551                 for depmodule in `func_get_dependencies $testsmodule`; do
552                   if func_acceptable $depmodule; then
553                     xmodules="$xmodules $depmodule"
554                   fi
555                 done
556               fi
557             fi
558           fi
559         fi
560       fi
561     done
562     xmodules=`for m in $xmodules; do echo $m; done | sort | uniq`
563     if test "$xmodules" = "$modules"; then
564       break
565     fi
566     modules="$xmodules"
567   done
568 }
569
570 # func_modules_to_filelist
571 # Input:
572 # - modules         list of modules, including dependencies
573 # Output:
574 # - files           list of files
575 func_modules_to_filelist ()
576 {
577   files=
578   for module in $modules; do
579     func_verify_module
580     if test -n "$module"; then
581       files="$files "`func_get_filelist $module`
582     fi
583   done
584   files=`for f in $files; do echo $f; done | sort | uniq`
585 }
586
587 # func_emit_lib_Makefile_am
588 # emits the contents of lib/Makefile.am to standard output.
589 # Input:
590 # - modules         list of modules, including dependencies
591 # - libname         library name
592 # - libtool         true if libtool will be used, blank otherwise
593 # - cmd             (optional) command that led to this invocation
594 # - actioncmd       (optional) command that will reproduce this invocation
595 func_emit_lib_Makefile_am ()
596 {
597   if test -n "$libtool"; then
598     libext=la
599     perhapsLT=LT
600   else
601     libext=a
602     perhapsLT=
603   fi
604   echo "## Process this file with automake to produce Makefile.in."
605   echo "# Copyright (C) 2004 Free Software Foundation, Inc."
606   echo "#"
607   echo "# This file is free software, distributed under the terms of the GNU"
608   echo "# General Public License.  As a special exception to the GNU General"
609   echo "# Public License, this file may be distributed as part of a program"
610   echo "# that contains a configuration script generated by Automake, under"
611   echo "# the same distribution terms as the rest of that program."
612   echo "#"
613   echo "# Generated by gnulib-tool."
614   if test -n "$cmd"; then
615     echo "# Invoked as: $cmd"
616   fi
617   if test -n "$actioncmd"; then
618     echo "# Reproduce by: $actioncmd"
619   fi
620   echo
621   # No need to generate dependencies since the sources are in gnulib, not here.
622   echo "AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies"
623   echo
624   echo "noinst_${perhapsLT}LIBRARIES = $libname.$libext"
625   echo
626   echo "${libname}_${libext}_SOURCES ="
627   echo "${libname}_${libext}_LIBADD = @${perhapsLT}LIBOBJS@"
628   echo "EXTRA_DIST ="
629   echo "BUILT_SOURCES ="
630   echo "SUFFIXES ="
631   echo "MOSTLYCLEANFILES ="
632   echo "CLEANFILES ="
633   echo "DISTCLEANFILES ="
634   echo "MAINTAINERCLEANFILES ="
635   echo
636   for module in $modules; do
637     func_verify_nontests_module
638     if test -n "$module"; then
639       {
640         func_get_automake_snippet "$module" |
641           sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
642         if test "$module" = 'alloca'; then
643           echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
644         fi
645       } > amsnippet.tmp
646       # Skip the contents if its entirely empty.
647       if grep '[^       ]' amsnippet.tmp > /dev/null ; then
648         echo "## begin gnulib module $module"
649         echo
650         cat amsnippet.tmp
651         echo "## end   gnulib module $module"
652         echo
653       fi
654       rm -f amsnippet.tmp
655     fi
656   done
657   echo
658   echo "# Makefile.am ends here"
659 }
660
661 # func_emit_tests_Makefile_am
662 # emits the contents of tests/Makefile.am to standard output.
663 # Input:
664 # - modules         list of modules, including dependencies
665 # - libname         library name
666 # - libtool         true if libtool will be used, blank otherwise
667 # - sourcebase      relative directory containing lib source code
668 func_emit_tests_Makefile_am ()
669 {
670   if test -n "$libtool"; then
671     libext=la
672   else
673     libext=a
674   fi
675   echo "## Process this file with automake to produce Makefile.in."
676   echo "# Copyright (C) 2004-2005 Free Software Foundation, Inc."
677   echo "#"
678   echo "# This file is free software, distributed under the terms of the GNU"
679   echo "# General Public License.  As a special exception to the GNU General"
680   echo "# Public License, this file may be distributed as part of a program"
681   echo "# that contains a configuration script generated by Automake, under"
682   echo "# the same distribution terms as the rest of that program."
683   echo "#"
684   echo "# Generated by gnulib-tool."
685   echo
686   # Generate dependencies here, since it eases the debugging of test failures.
687   echo "AUTOMAKE_OPTIONS = 1.5 foreign"
688   echo
689   echo "ACLOCAL_AMFLAGS = -I ../m4"
690   echo
691   echo "TESTS ="
692   echo "noinst_PROGRAMS ="
693   echo "EXTRA_DIST ="
694   echo "BUILT_SOURCES ="
695   echo "SUFFIXES ="
696   echo "MOSTLYCLEANFILES ="
697   echo "CLEANFILES ="
698   echo "DISTCLEANFILES ="
699   echo "MAINTAINERCLEANFILES ="
700   echo
701   echo "AM_CPPFLAGS = \\"
702   echo "  -I. -I\$(srcdir) \\"
703   echo "  -I.. -I\$(srcdir)/.. \\"
704   echo "  -I../${sourcebase-lib} -I\$(srcdir)/../${sourcebase-lib}"
705   echo
706   echo "LDADD = ../${sourcebase-lib}/${libname}.${libext}"
707   echo
708   for module in $modules; do
709     func_verify_tests_module
710     if test -n "$module"; then
711       func_get_automake_snippet "$module" > amsnippet.tmp
712       # Skip the contents if its entirely empty.
713       if grep '[^       ]' amsnippet.tmp > /dev/null ; then
714         echo "## begin gnulib module $module"
715         echo
716         cat amsnippet.tmp
717         echo "## end   gnulib module $module"
718         echo
719       fi
720       rm -f amsnippet.tmp
721     fi
722   done
723   echo "# Clean up after Solaris cc."
724   echo "clean-local:"
725   echo "        rm -rf SunWS_cache"
726   echo
727   echo "# Makefile.am ends here"
728 }
729
730 # func_import modules
731 # Uses also the variables
732 # - destdir         target directory
733 # - libname         library name
734 # - sourcebase      directory relative to destdir where to place source code
735 # - m4base          directory relative to destdir where to place *.m4 macros
736 # - auxdir          directory relative to destdir where to place build aux files
737 # - avoidlist       list of modules to avoid, from --avoid
738 # - lgpl            true if library's license shall be LGPL, blank otherwise
739 # - libtool         true if libtool will be used, blank otherwise
740 # - dry_run         true if actions shall only be printed, blank otherwise
741 # - symbolic        true if files should be symlinked, copied otherwise
742 # - supplied_opts   all options passed to gnulib-tool
743 func_import ()
744 {
745   modules="$1"
746   modules=`for m in $modules; do echo $m; done | sort | uniq`
747
748   # Determine final module list.
749   func_modules_transitive_closure
750   echo "Module list with included dependencies:"
751   echo "$modules" | sed -e 's/^/  /'
752
753   # If --lgpl, check the license of modules are compatible.
754   if test -n "$lgpl"; then
755     for module in $modules; do
756       license=`func_get_license $module`
757       case $license in
758         LGPL | 'public domain' | 'unlimited') ;;
759         *)
760           func_fatal_error \
761             "incompatible license on module \`$module\`: $license" ;;
762       esac
763     done
764   fi
765
766   # Determine final file list.
767   func_modules_to_filelist
768   echo "File list:"
769   echo "$files" | sed -e 's/^/  /'
770
771   test -n "$files" \
772     || func_fatal_error "refusing to do nothing"
773
774   # Copy files or make symbolic links.
775   for f in $files; do
776     source=
777     case "$f" in
778       build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
779       lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"`; source=true ;;
780       m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
781       *) g="$f" ;;
782     esac
783     if test -z "$symbolic"; then
784       func_cp_if_changed "$gnulib_dir/$f" "$destdir/$g"
785     else
786       func_ln_if_changed "$gnulib_dir/$f" "$destdir/$g"
787     fi
788     # Update license.
789     if test -z "$dry_run" && test -n "$lgpl" && test -n "$source"; then
790       perl -pi -e 's/GNU General/GNU Lesser General/g;' \
791                -e 's/version 2([ ,])/version 2.1\1/g' \
792                "$destdir/$g"
793     fi
794   done
795
796   # Commands printed in a comment in generated files.
797   cmd="gnulib-tool $supplied_opts"
798   opt_libtool=
799   if test -n "$libtool"; then
800     opt_libtool="--libtool"
801   fi
802   opt_lgpl=
803   if test -n "$lgpl"; then
804     opt_lgpl="--lgpl"
805   fi
806   actioncmd="gnulib-tool --import --dir=$destdir --lib=$libname --source-base=$sourcebase --m4-base=$m4base --aux-dir=$auxdir $opt_libtool $opt_lgpl `echo $modules`"
807
808   # Create lib/Makefile.am.
809   echo "Creating $destdir/$sourcebase/Makefile.am..."
810   if test -z "$dry_run"; then
811     func_emit_lib_Makefile_am > "$destdir"/$sourcebase/Makefile.am.new
812   else
813     func_emit_lib_Makefile_am
814   fi
815   func_mv_if_changed "$destdir"/$sourcebase/Makefile.am.new \
816                      "$destdir"/$sourcebase/Makefile.am
817
818   # Create gnulib.m4.
819   echo "Creating $destdir/$m4base/gnulib.m4..."
820   (
821     if test -z "$dry_run"; then
822       exec > "$destdir"/$m4base/gnulib.m4.new
823     else
824       echo "# $destdir/$m4base/gnulib.m4"
825     fi
826     echo "# Copyright (C) 2004 Free Software Foundation, Inc."
827     echo "# This file is free software, distributed under the terms of the GNU"
828     echo "# General Public License.  As a special exception to the GNU General"
829     echo "# Public License, this file may be distributed as part of a program"
830     echo "# that contains a configuration script generated by Autoconf, under"
831     echo "# the same distribution terms as the rest of that program."
832     echo "#"
833     echo "# Generated by gnulib-tool."
834     echo "#"
835     echo "# Invoked as: $cmd"
836     echo "# Reproduce by: $actioncmd"
837     echo
838     echo "AC_DEFUN([gl_EARLY],"
839     echo "["
840     if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 > /dev/null; then
841       echo "  AC_GNU_SOURCE"
842     fi
843     if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 > /dev/null; then
844       echo "  gl_USE_SYSTEM_EXTENSIONS"
845     fi
846     echo "])"
847     echo
848     echo "AC_DEFUN([gl_INIT],"
849     echo "["
850     for module in $modules; do
851       func_verify_module
852       if test -n "$module"; then
853         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./'
854         if test "$module" = 'alloca' && test -n "$libtool"; then
855           echo 'changequote(,)dnl'
856           echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
857           echo 'changequote([, ])dnl'
858           echo 'AC_SUBST([LTALLOCA])'
859         fi
860       fi
861     done
862     echo "])"
863     echo
864     echo "dnl Usage: gl_MODULES([module1 module2 ...])"
865     echo "AC_DEFUN([gl_MODULES], [])"
866     echo
867     echo "dnl Usage: gl_AVOID([module1 module2 ...])"
868     echo "AC_DEFUN([gl_AVOID], [])"
869     echo
870     echo "dnl Usage: gl_SOURCE_BASE([DIR])"
871     echo "AC_DEFUN([gl_SOURCE_BASE], [])"
872     echo
873     echo "dnl Usage: gl_M4_BASE([DIR])"
874     echo "AC_DEFUN([gl_M4_BASE], [])"
875     echo
876     echo "dnl Usage: gl_LIB([LIBNAME])"
877     echo "AC_DEFUN([gl_LIB], [])"
878     echo
879     echo "dnl Usage: gl_LGPL"
880     echo "AC_DEFUN([gl_LGPL], [])"
881     echo
882     echo "# gnulib.m4 ends here"
883   )
884   func_mv_if_changed "$destdir"/$m4base/gnulib.m4.new "$destdir"/$m4base/gnulib.m4
885   echo "Finished."
886   echo
887   echo "You may need to add #include directives for the following .h files."
888   for module in $modules; do
889     func_get_include_directive "$module"
890   done | LC_ALL=C sort -u | sed -e '/^$/d;' -e 's/^/  /'
891   echo
892   echo "Don't forget to add \"$sourcebase/Makefile\""
893   echo "to AC_CONFIG_FILES in \"$configure_ac\" and to mention"
894   echo "\"`basename $sourcebase`\" in SUBDIRS in some Makefile.am."
895 }
896
897 # func_create_testdir testdir modules
898 # Input:
899 # - auxdir          directory relative to destdir where to place build aux files
900 func_create_testdir ()
901 {
902   testdir="$1"
903   modules="$2"
904   modules=`for m in $modules; do echo $m; done | sort | uniq`
905
906   # Determine final module list.
907   func_modules_transitive_closure
908   echo "Module list with included dependencies:"
909   echo "$modules" | sed -e 's/^/  /'
910
911   # Determine final file list.
912   func_modules_to_filelist
913   echo "File list:"
914   echo "$files" | sed -e 's/^/  /'
915
916   # Create directories.
917   for d in `echo "$files" | sed -n -e 's,^\(.*\)/[^/]*,\1,p'`; do
918     if test "$d" = build-aux; then
919       mkdir -p "$testdir/$auxdir"
920     else
921       mkdir -p "$testdir/$d"
922     fi
923   done
924
925   # Copy files or make symbolic links.
926   for f in $files; do
927     case "$f" in
928       build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
929       *) g="$f" ;;
930     esac
931     ln "$gnulib_dir/$f" "$testdir/$g" 2>/dev/null ||
932     if test -z "$symbolic"; then
933       cp -p "$gnulib_dir/$f" "$testdir/$g"
934     else
935       ln -s "$gnulib_dir/$f" "$testdir/$g"
936     fi
937   done
938
939   # Create lib/Makefile.am.
940   mkdir -p "$testdir/lib"
941   func_emit_lib_Makefile_am > "$testdir/lib/Makefile.am"
942
943   # Create m4/Makefile.am.
944   mkdir -p "$testdir/m4"
945   (echo "## Process this file with automake to produce Makefile.in."
946    echo
947    echo "EXTRA_DIST ="
948    for f in $files; do
949      case "$f" in
950        m4/* )
951          echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
952      esac
953    done
954   ) > "$testdir/m4/Makefile.am"
955
956   subdirs="lib m4"
957   subdirs_with_configure_ac=""
958
959   if test -f "$testdir"/m4/gettext.m4; then
960     # Avoid stupid error message from automake:
961     # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
962     mkdir -p "$testdir/po"
963     (echo "## Process this file with automake to produce Makefile.in."
964     ) > "$testdir/po/Makefile.am"
965     subdirs="$subdirs po"
966   fi
967
968   if test -n "$inctests"; then
969     test -d "$testdir/tests" || mkdir "$testdir/tests"
970     # Create tests/Makefile.am.
971     sourcebase=lib
972     func_emit_tests_Makefile_am > "$testdir/tests/Makefile.am"
973     # Create tests/configure.ac.
974     (echo "# Process this file with autoconf to produce a configure script."
975      echo "AC_INIT([dummy], [0])"
976      echo "AC_CONFIG_AUX_DIR([../$auxdir])"
977      echo "AM_INIT_AUTOMAKE"
978      echo
979      echo "AM_CONFIG_HEADER([config.h])"
980      echo
981      echo "AC_PROG_CC"
982      echo "AC_PROG_INSTALL"
983      echo "AC_PROG_MAKE_SET"
984      echo "AC_PROG_RANLIB"
985      echo
986      if grep AC_GNU_SOURCE "$testdir"/m4/*.m4 > /dev/null; then
987        echo "AC_GNU_SOURCE"
988        echo
989      fi
990      if grep gl_USE_SYSTEM_EXTENSIONS "$testdir"/m4/*.m4 > /dev/null; then
991        echo "gl_USE_SYSTEM_EXTENSIONS"
992        echo
993      fi
994      # We don't have explicit ordering constraints between the various
995      # autoconf snippets. It's cleanest to put those of the library before
996      # those of the tests.
997      for module in $modules; do
998        func_verify_nontests_module
999        if test -n "$module"; then
1000          func_get_autoconf_snippet "$module"
1001        fi
1002      done
1003      for module in $modules; do
1004        func_verify_tests_module
1005        if test -n "$module"; then
1006          func_get_autoconf_snippet "$module"
1007        fi
1008      done
1009      echo
1010      # Usually tests/config.h will be a superset of config.h. Verify this by
1011      # "merging" config.h into tests/config.h; look out for gcc warnings.
1012      echo "AH_TOP([#include \"../config.h\"])"
1013      echo
1014      echo "AC_OUTPUT([Makefile])"
1015     ) > "$testdir/tests/configure.ac"
1016     subdirs="$subdirs tests"
1017     subdirs_with_configure_ac="$subdirs_with_configure_ac tests"
1018   fi
1019
1020   # Create Makefile.am.
1021   (echo "## Process this file with automake to produce Makefile.in."
1022    echo
1023    echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1024    echo
1025    echo "SUBDIRS = $subdirs"
1026    echo
1027    echo "ACLOCAL_AMFLAGS = -I m4"
1028   ) > "$testdir/Makefile.am"
1029
1030   # Create configure.ac.
1031   (echo "# Process this file with autoconf to produce a configure script."
1032    echo "AC_INIT([dummy], [0])"
1033    if test "$auxdir" != "."; then
1034      echo "AC_CONFIG_AUX_DIR([$auxdir])"
1035    fi
1036    echo "AM_INIT_AUTOMAKE"
1037    echo
1038    echo "AM_CONFIG_HEADER([config.h])"
1039    echo
1040    echo "AC_PROG_CC"
1041    echo "AC_PROG_INSTALL"
1042    echo "AC_PROG_MAKE_SET"
1043    echo "AC_PROG_RANLIB"
1044    echo
1045    if grep AC_GNU_SOURCE "$testdir"/m4/*.m4 > /dev/null; then
1046      echo "AC_GNU_SOURCE"
1047      echo
1048    fi
1049    if grep gl_USE_SYSTEM_EXTENSIONS "$testdir"/m4/*.m4 > /dev/null; then
1050      echo "gl_USE_SYSTEM_EXTENSIONS"
1051      echo
1052    fi
1053    for module in $modules; do
1054      func_verify_nontests_module
1055      if test -n "$module"; then
1056        func_get_autoconf_snippet "$module"
1057      fi
1058    done
1059    echo
1060    if test -n "$subdirs_with_configure_ac"; then
1061      echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
1062    fi
1063    makefiles="Makefile"
1064    for d in $subdirs; do
1065      # For subdirs that have a configure.ac by their own, it's the subdir's
1066      # configure.ac which creates the subdir's Makefile.am, not this one.
1067      case " $subdirs_with_configure_ac " in
1068        *" $d "*) ;;
1069        *) makefiles="$makefiles $d/Makefile" ;;
1070      esac
1071    done
1072    echo "AC_OUTPUT([$makefiles])"
1073   ) > "$testdir/configure.ac"
1074
1075   # Create autogenerated files.
1076   (cd "$testdir"
1077    echo "executing ${AUTORECONF} --force --install"
1078    ${AUTORECONF} --force --install
1079   )
1080   if grep '^BUILT_SOURCES *+=' "$testdir/lib/Makefile.am" > /dev/null; then
1081     (cd "$testdir"
1082      ./configure
1083        cd lib
1084        built_sources=`grep '^BUILT_SOURCES *=' Makefile.in | sed -e 's/^BUILT_SOURCES *=//'`
1085        if test -n "$built_sources"; then
1086          make $built_sources
1087        fi
1088        cd ..
1089      make distclean
1090     )
1091   fi
1092 }
1093
1094 # func_create_megatestdir megatestdir allmodules
1095 # Input:
1096 # - auxdir          directory relative to destdir where to place build aux files
1097 func_create_megatestdir ()
1098 {
1099   megatestdir="$1"
1100   allmodules="$2"
1101   if test -z "$allmodules"; then
1102     allmodules=`func_all_modules`
1103   fi
1104
1105   megasubdirs=
1106   # First, all modules one by one.
1107   for onemodule in $allmodules; do
1108     func_create_testdir "$megatestdir/$onemodule" $onemodule
1109     megasubdirs="${megasubdirs}$onemodule "
1110   done
1111   # Then, all modules all together.
1112   # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
1113   allmodules=`for m in $allmodules; do if test $m != fnmatch-posix; then echo $m; fi; done`
1114   func_create_testdir "$megatestdir/ALL" "$allmodules"
1115   megasubdirs="${megasubdirs}ALL"
1116
1117   # Create Makefile.am.
1118   (echo "## Process this file with automake to produce Makefile.in."
1119    echo
1120    echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1121    echo
1122    echo "SUBDIRS = $megasubdirs"
1123   ) > "$megatestdir/Makefile.am"
1124
1125   # Create configure.ac.
1126   (echo "# Process this file with autoconf to produce a configure script."
1127    echo "AC_INIT([dummy], [0])"
1128    if test "$auxdir" != "."; then
1129      echo "AC_CONFIG_AUX_DIR([$auxdir])"
1130    fi
1131    echo "AM_INIT_AUTOMAKE"
1132    echo
1133    echo "AC_PROG_MAKE_SET"
1134    echo
1135    echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
1136    echo "AC_OUTPUT([Makefile])"
1137   ) > "$megatestdir/configure.ac"
1138
1139   # Create autogenerated files.
1140   (cd "$megatestdir"
1141    echo "executing ${AUTORECONF} --install"
1142    ${AUTORECONF} --install
1143   )
1144 }
1145
1146 case $mode in
1147   "" )
1148     func_fatal_error "no mode specified" ;;
1149
1150   list )
1151     func_all_modules
1152     ;;
1153
1154   import )
1155     # Where to import.
1156     if test -z "$destdir"; then
1157       destdir=.
1158     fi
1159     test -d "$destdir" \
1160       || func_fatal_error "destination directory does not exist: $destdir"
1161
1162     # Prefer configure.ac to configure.in
1163     test -f "$destdir"/configure.in && configure_ac="$destdir/configure.in"
1164     test -f "$destdir"/configure.ac && configure_ac="$destdir/configure.ac"
1165     test -f "$configure_ac" \
1166       || func_fatal_error "cannot find $destdir/configure.ac"
1167
1168     # Get settings.
1169     my_sed_traces='s,#.*$,,; s,^dnl .*$,,; s, dnl .*$,,;
1170       /gl_MODULES[^_]/  {
1171         s,^.*gl_MODULES([[   ]*\([^])]*\).*$,ac_modules="\1",; p;
1172       };
1173       /gl_AVOID[^_]/  {
1174         s,^.*gl_AVOID([[   ]*\([^])]*\).*$,ac_avoidlist="\1",; p;
1175       };
1176       /gl_SOURCE_BASE/   {
1177         s,^.*gl_SOURCE_BASE([[         ]*\([^])]*\).*$,ac_sourcebase="\1",; p;
1178       };
1179       /gl_M4_BASE/   {
1180         s,^.*gl_M4_BASE([[         ]*\([^])]*\).*$,ac_m4base="\1",; p;
1181       };
1182       /gl_LIB/   {
1183         s,^.*gl_LIB([[         ]*\([^])]*\).*$,ac_libname="\1",; p;
1184       };
1185       /AC_CONFIG_AUX_DIR/  {
1186         s,^.*AC_CONFIG_AUX_DIR([[         ]*\([^])]*\).*$,ac_auxdir="\1",; p;
1187       }
1188       /A[CM]_PROG_LIBTOOL/ { s,^.*$,seen_libtool=:,; p; };
1189       /LT_INIT/            { s,^.*$,seen_libtool=:,; p; };
1190       /gl_LGPL/            { s,^.*$,lgpl=true,; p; };
1191       d;'
1192     eval `cat $configure_ac | sed "$my_sed_traces"`
1193
1194     # Override libname?
1195     if test -z "$supplied_libname" && test -n "$ac_libname"; then
1196       libname="$ac_libname"
1197     fi
1198
1199     # Set up source base.
1200     test -z "$sourcebase" && sourcebase="$ac_sourcebase"
1201     test -z "$sourcebase" && sourcebase="lib"
1202     test -d "$destdir/$sourcebase" \
1203       || { test -z "$dry_run" && mkdir "$destdir/$sourcebase"; } \
1204       || func_fatal_error "source base $destdir/$sourcebase doesn't exist"
1205
1206     # Set up m4 base.
1207     test -z "$m4base" && m4base="$ac_m4base"
1208     test -z "$m4base" && m4base="m4"
1209     test -d "$destdir/$m4base" \
1210       || { test -z "$dry_run" && mkdir "$destdir/$m4base"; } \
1211       || func_fatal_error "m4 base $destdir/$m4base doesn't exist"
1212
1213     # Set up auxiliary directory.
1214     test -z "$auxdir" && auxdir="$ac_auxdir"
1215     test -z "$auxdir" && auxdir="build-aux"
1216     test -d "$destdir/$auxdir" \
1217       || { test -z "$dry_run" && mkdir "$destdir/$auxdir"; } \
1218       || func_fatal_error "aux directory $destdir/$auxdir doesn't exist"
1219
1220     # Using libtool?
1221     if test -n "$seen_libtool"; then
1222       libtool=true
1223     fi
1224
1225     # What modules to extract.
1226     if test $# = 0; then
1227       modules="$ac_modules"
1228     else
1229       modules="$*"
1230     fi
1231
1232     # Which modules to avoid?
1233     avoidlist="$avoidlist $ac_avoidlist"
1234
1235     func_import "$modules"
1236     ;;
1237
1238   create-testdir )
1239     if test -z "$destdir"; then
1240       func_fatal_error "please specify --dir option"
1241     fi
1242     mkdir "$destdir"
1243     test -d "$destdir" \
1244       || func_fatal_error "could not create destination directory"
1245     test -n "$auxdir" || auxdir="build-aux"
1246     func_create_testdir "$destdir" "$*"
1247     ;;
1248
1249   create-megatestdir )
1250     if test -z "$destdir"; then
1251       func_fatal_error "please specify --dir option"
1252     fi
1253     mkdir "$destdir" || func_fatal_error "could not create destination directory"
1254     test -n "$auxdir" || auxdir="build-aux"
1255     func_create_megatestdir "$destdir" "$*"
1256     ;;
1257
1258   test )
1259     test -n "$destdir" || destdir=testdir$$
1260     mkdir "$destdir" || func_fatal_error "could not create destination directory"
1261     test -n "$auxdir" || auxdir="build-aux"
1262     func_create_testdir "$destdir" "$*"
1263     cd "$destdir"
1264       mkdir build
1265       cd build
1266         ../configure
1267         make
1268         make check
1269         make distclean
1270         remaining=`find . -type f -print`
1271         if test -n "$remaining"; then
1272           echo "Remaining files:" $remaining 1>&2
1273           echo "gnulib-tool: *** Stop." 1>&2
1274           exit 1
1275         fi
1276       cd ..
1277     cd ..
1278     rm -rf "$destdir"
1279     ;;
1280
1281   megatest )
1282     test -n "$destdir" || destdir=testdir$$
1283     mkdir "$destdir" || func_fatal_error "could not create destination directory"
1284     test -n "$auxdir" || auxdir="build-aux"
1285     func_create_megatestdir "$destdir" "$*"
1286     cd "$destdir"
1287       mkdir build
1288       cd build
1289         ../configure
1290         make
1291         make check
1292         make distclean
1293         remaining=`find . -type f -print`
1294         if test -n "$remaining"; then
1295           echo "Remaining files:" $remaining 1>&2
1296           echo "gnulib-tool: *** Stop." 1>&2
1297           exit 1
1298         fi
1299       cd ..
1300     cd ..
1301     rm -rf "$destdir"
1302     ;;
1303
1304   extract-description )
1305     for module
1306     do
1307       func_verify_module
1308       if test -n "$module"; then
1309         func_get_description "$module"
1310       fi
1311     done
1312     ;;
1313
1314   extract-filelist )
1315     for module
1316     do
1317       func_verify_module
1318       if test -n "$module"; then
1319         func_get_filelist "$module"
1320       fi
1321     done
1322     ;;
1323
1324   extract-dependencies )
1325     for module
1326     do
1327       func_verify_module
1328       if test -n "$module"; then
1329         func_get_dependencies "$module"
1330       fi
1331     done
1332     ;;
1333
1334   extract-autoconf-snippet )
1335     for module
1336     do
1337       func_verify_module
1338       if test -n "$module"; then
1339         func_get_autoconf_snippet "$module"
1340       fi
1341     done
1342     ;;
1343
1344   extract-automake-snippet )
1345     for module
1346     do
1347       func_verify_module
1348       if test -n "$module"; then
1349         func_get_automake_snippet "$module"
1350       fi
1351     done
1352     ;;
1353
1354   extract-include-directive )
1355     for module
1356     do
1357       func_verify_module
1358       if test -n "$module"; then
1359         func_get_include_directive "$module"
1360       fi
1361     done
1362     ;;
1363
1364   extract-license )
1365     for module
1366     do
1367       func_verify_module
1368       if test -n "$module"; then
1369         func_get_license "$module"
1370       fi
1371     done
1372     ;;
1373
1374   extract-maintainer )
1375     for module
1376     do
1377       func_verify_module
1378       if test -n "$module"; then
1379         func_get_maintainer "$module"
1380       fi
1381     done
1382     ;;
1383
1384   extract-tests-module )
1385     for module
1386     do
1387       func_verify_module
1388       if test -n "$module"; then
1389         func_get_tests_module "$module"
1390       fi
1391     done
1392     ;;
1393
1394   * )
1395     func_fatal_error "unknown operation mode --$mode" ;;
1396 esac
1397
1398 exit 0