3 # Copyright (C) 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # This program is meant for authors or maintainers which want to import
21 # modules from gnulib into their packages.
25 cvsdatestamp='$Date: 2005-07-05 07:14:00 $'
26 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
27 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
29 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
33 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
34 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
38 AUTORECONF="${AUTOCONFPATH}autoreconf"
41 # outputs to stdout the --help usage message.
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
61 --list print the available module names
62 --import import the given modules into the current package
63 --create-testdir create a scratch package with the given modules
64 --create-megatestdir create a mega scratch package with the given modules
65 one by one and all together
66 --test test the combination of the given modules
67 (recommended to use CC=\"gcc -Wall\" here)
68 --megatest test the given modules one by one and all together
69 (recommended to use CC=\"gcc -Wall\" here)
70 --extract-description extract the description
71 --extract-filelist extract the list of files
72 --extract-dependencies extract the dependencies
73 --extract-autoconf-snippet extract the snippet for configure.ac
74 --extract-automake-snippet extract the snippet for lib/Makefile.am
75 --extract-include-directive extract the #include directive
76 --extract-license report the license terms of the source files
78 --extract-maintainer report the maintainer(s) inside gnulib
81 --dir=DIRECTORY specify the target directory
82 For --import, this specifies where your
83 configure.ac can be found. Defaults to current
85 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
86 --source-base=DIRECTORY
87 Directory relative --dir where source code is
88 placed (default \"lib\"), for --import.
89 --m4-base=DIRECTORY Directory relative --dir where *.m4 macros are
90 placed (default \"m4\"), for --import.
91 --aux-dir=DIRECTORY Directory relative --dir where auxiliary build
92 tools are placed (default \".\"), for --import.
93 --lgpl Abort if modules aren't available under the LGPL.
94 Also modify license template from GPL to LGPL.
95 --libtool Use libtool rules, for --import.
96 --no-changelog don't update or create ChangeLog files
97 --dry-run For --import, only print what would have been done.
98 -s, --symbolic, --symlink Make symbolic links instead of copying files.
100 Report bugs to <bug-gnulib@gnu.org>."
104 # outputs to stdout the --version message.
107 echo "$progname (GNU $package) $version"
108 echo "Copyright (C) 2002 Free Software Foundation, Inc.
109 This is free software; see the source for copying conditions. There is NO
110 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
111 echo "Written by" "Bruno Haible"
114 # func_fatal_error message
115 # outputs to stderr a fatal error message, and terminates the program.
118 echo "gnulib-tool: *** $1" 1>&2
119 echo "gnulib-tool: *** Stop." 1>&2
123 # func_cp_if_changed SRC DEST
124 # Like cp, but avoids munging timestamps if the file hasn't changed.
125 # Uses also the variables
126 # - dry_run true if actions shall only be printed, blank otherwise
127 func_cp_if_changed ()
129 if test $# -ne 2; then
130 echo "usage: func_cp_if_changed SRC DEST" >&2
132 test -n "$dry_run" && dry=echo
133 if cmp "$1" "$2" >/dev/null 2>&1; then
140 # func_mv_if_changed SRC DEST
141 # Like mv, but avoids munging timestamps if the file hasn't changed.
142 # Removes SRC if it is not renamed.
143 # Uses also the variables
144 # - dry_run true if actions shall only be printed, blank otherwise
145 func_mv_if_changed ()
147 if test $# -ne 2; then
148 echo "usage: func_mv_if_changed SRC DEST" >&2
150 test -n "$dry_run" && dry=echo
151 if cmp "$1" "$2" >/dev/null 2>&1; then
158 # func_ln_if_changed SRC DEST
159 # Like ln -s, but avoids munging timestamps if the link is correct.
160 # Uses also the variables
161 # - dry_run true if actions shall only be printed, blank otherwise
162 func_ln_if_changed ()
164 if test $# -ne 2; then
165 echo "usage: func_ln_if_changed SRC DEST" >&2
167 test -n "$dry_run" && dry=echo
168 if test -L "$2" -a "$1" = "`readlink "$2"`"; then
176 # Command-line option processing.
177 # Removes the OPTIONS from the arguments. Sets the variables:
178 # - mode list or import or create-testdir or create-megatestdir
179 # - destdir from --dir
180 # - libname, supplied_libname from --lib
181 # - sourcebase from --source-base
182 # - m4base from --m4-base
183 # - auxdir from --aux-dir
184 # - libtool true if --libtool was given, blank otherwise
185 # - lgpl true if --lgpl was given, blank otherwise
186 # - do_changelog false if --no-changelog was given, : otherwise
187 # - dry_run true if --dry-run was given, blank otherwise
205 while test $# -gt 0; do
210 --import | --impor | --impo | --imp | --im | --i )
213 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
216 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
217 mode=create-megatestdir
219 --test | --tes | --te | --t )
222 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
226 mode=`echo "X$1" | sed -e 's/^X--//'`
231 func_fatal_error "missing argument for --dir"
236 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
241 func_fatal_error "missing argument for --lib"
244 supplied_libname=true
247 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
248 supplied_libname=true
253 func_fatal_error "missing argument for --source-base"
258 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
263 func_fatal_error "missing argument for --m4-base"
268 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
273 func_fatal_error "missing argument for --aux-dir"
278 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
286 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
292 -s | --symbolic | --symlink )
295 --help | --hel | --he | --h )
298 --version | --versio | --versi | --vers | --ver | --ve | --v )
302 # Stop option prcessing
306 echo "gnulib-tool: unknown option $1" 1>&2
307 echo "Try 'gnulib-tool --help' for more information." 1>&2
316 /*) self_abspathname="$0" ;;
317 */*) self_abspathname=`pwd`/"$0" ;;
318 *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
319 if test -x "$d/$0" && test ! -d "$d/$0"; then
320 self_abspathname="$d/$0"
324 if test -z "$self_abspathname"; then
325 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
329 while test -h "$self_abspathname"; do
330 # Resolve symbolic link.
331 sedexpr1='s, -> ,#%%#,'
332 sedexpr2='s,^.*#%%#\(.*\)$,\1,p'
333 linkval=`LC_ALL=C ls -l "$self_abspathname" | sed -e "$sedexpr1" | sed -n -e "$sedexpr2"`
334 test -n "$linkval" || break
336 /* ) self_abspathname="$linkval" ;;
337 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
340 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
345 (cd "$gnulib_dir/modules" && ls -1) \
346 | sed -e '/^CVS$/d' -e '/^ChangeLog$/d' -e '/^README$/d' -e '/^TEMPLATE$/d' -e '/~$/d' \
351 # verifies a module name
352 func_verify_module ()
354 if test ! -f "$gnulib_dir/modules/$module" \
355 || test "CVS" = "$module" \
356 || test "ChangeLog" = "$module" \
357 || test "README" = "$module" \
358 || test "TEMPLATE" = "$module"; then
359 echo "gnulib-tool: module $module doesn't exist" 1>&2
364 sed_extract_prog=':[ ]*$/ {
367 s/^Description:[ ]*$//
369 s/^Depends-on:[ ]*$//
370 s/^configure\.ac:[ ]*$//
371 s/^Makefile\.am:[ ]*$//
374 s/^Maintainer:[ ]*$//
381 # func_get_description module
382 func_get_description ()
384 sed -n -e "/^Description$sed_extract_prog" < "$gnulib_dir/modules/$1"
387 # func_get_filelist module
390 sed -n -e "/^Files$sed_extract_prog" < "$gnulib_dir/modules/$1"
392 echo m4/onceonly_2_57.m4
395 # func_get_dependencies module
396 func_get_dependencies ()
398 sed -n -e "/^Depends-on$sed_extract_prog" < "$gnulib_dir/modules/$1"
401 # func_get_autoconf_snippet module
402 func_get_autoconf_snippet ()
404 sed -n -e "/^configure\.ac$sed_extract_prog" < "$gnulib_dir/modules/$1"
407 # func_get_automake_snippet module
408 func_get_automake_snippet ()
410 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$gnulib_dir/modules/$1"
413 # func_get_include_directive module
414 func_get_include_directive ()
416 sed -n -e "/^Include$sed_extract_prog" < "$gnulib_dir/modules/$1" | \
417 sed -e 's/^\(["<]\)/#include \1/'
420 # func_get_license module
423 sed -n -e "/^License$sed_extract_prog" < "$gnulib_dir/modules/$1"
426 # func_get_maintainer module
427 func_get_maintainer ()
429 sed -n -e "/^Maintainer$sed_extract_prog" < "$gnulib_dir/modules/$1"
432 # func_modules_transitive_closure
434 # - modules list of specified modules
436 # - modules list of modules, including dependencies
437 func_modules_transitive_closure ()
441 for module in $modules; do
443 if test -n "$module"; then
444 # Duplicate dependenies are harmless, but Jim wants a warning.
445 duplicated_deps=`func_get_dependencies $module | sort | uniq -d`
446 if test -n "$duplicated_deps"; then
447 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
449 xmodules="$xmodules $module "`func_get_dependencies $module`
452 xmodules=`for m in $xmodules; do echo $m; done | sort | uniq`
453 if test "$xmodules" = "$modules"; then
460 # func_modules_to_filelist
462 # - modules list of modules, including dependencies
464 # - files list of files
465 func_modules_to_filelist ()
468 for module in $modules; do
470 if test -n "$module"; then
471 files="$files "`func_get_filelist $module`
474 files=`for f in $files; do echo $f; done | sort | uniq`
477 # func_emit_lib_Makefile_am
478 # emits the contents of lib/Makefile.am to standard output.
480 # - modules list of modules, including dependencies
481 # - libname library name
482 # - libtool true if libtool will be used, blank otherwise
483 # - cmd (optional) command that led to this invocation
484 # - actioncmd (optional) command that will reproduce this invocation
485 func_emit_lib_Makefile_am ()
487 if test -n "$libtool"; then
494 echo "## Process this file with automake to produce Makefile.in."
495 echo "# Copyright (C) 2004 Free Software Foundation, Inc."
497 echo "# This file is free software, distributed under the terms of the GNU"
498 echo "# General Public License. As a special exception to the GNU General"
499 echo "# Public License, this file may be distributed as part of a program"
500 echo "# that contains a configuration script generated by Automake, under"
501 echo "# the same distribution terms as the rest of that program."
503 echo "# Generated by gnulib-tool."
504 if test -n "$cmd"; then
505 echo "# Invoked as: $cmd"
507 if test -n "$actioncmd"; then
508 echo "# Reproduce by: $actioncmd"
511 # No need to generate dependencies since the sources are in gnulib, not here.
512 echo "AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies"
514 echo "noinst_${perhapsLT}LIBRARIES = $libname.$libext"
516 echo "${libname}_${libext}_SOURCES ="
517 echo "${libname}_${libext}_LIBADD = @${perhapsLT}LIBOBJS@"
519 echo "BUILT_SOURCES ="
521 echo "MOSTLYCLEANFILES ="
523 echo "DISTCLEANFILES ="
524 echo "MAINTAINERCLEANFILES ="
526 for module in $modules; do
528 if test -n "$module"; then
530 func_get_automake_snippet "$module" |
531 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
532 if test "$module" = 'alloca'; then
533 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
536 # Skip the contents if its entirely empty.
537 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
538 echo "## begin gnulib module $module"
541 echo "## end gnulib module $module"
548 echo "# Makefile.am ends here"
551 # func_import modules
552 # Uses also the variables
553 # - destdir target directory
554 # - libname library name
555 # - sourcebase directory relative to destdir where to place source code
556 # - m4base directory relative to destdir where to place *.m4 macros
557 # - libtool true if libtool will be used, blank otherwise
558 # - lgpl true if library's license shall be LGPL, blank otherwise
559 # - dry_run true if actions shall only be printed, blank otherwise
560 # - symbolic true if files should be symlinked, copied otherwise
561 # - supplied_opts all options passed to gnulib-tool
565 modules=`for m in $modules; do echo $m; done | sort | uniq`
567 # Determine final module list.
568 func_modules_transitive_closure
569 echo "Module list with included dependencies:"
570 echo "$modules" | sed -e 's/^/ /'
572 # If --lgpl, check the license of modules are compatible.
573 if test -n "$lgpl"; then
574 for module in $modules; do
575 license=`func_get_license $module`
577 LGPL | 'public domain') ;;
580 "incompatible license on module \`$module\`: $license" ;;
585 # Determine final file list.
586 func_modules_to_filelist
588 echo "$files" | sed -e 's/^/ /'
591 || func_fatal_error "refusing to do nothing"
593 # Copy files or make symbolic links.
597 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
598 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"`; source=true ;;
599 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
602 if test -z "$symbolic"; then
603 func_cp_if_changed "$gnulib_dir/$f" "$destdir/$g"
605 func_ln_if_changed "$gnulib_dir/$f" "$destdir/$g"
608 if test -z "$dry_run" && test -n "$lgpl" && test -n "$source"; then
609 perl -pi -e 's/GNU General/GNU Lesser General/g;' \
610 -e 's/version 2([ ,])/version 2.1\1/g' \
615 # Commands printed in a comment in generated files.
616 cmd="gnulib-tool $supplied_opts"
618 if test -n "$libtool"; then
619 opt_libtool="--libtool"
622 if test -n "$lgpl"; then
625 actioncmd="gnulib-tool --import --dir=$destdir --lib=$libname --source-base=$sourcebase --m4-base=$m4base --aux-dir=$auxdir $opt_libtool $opt_lgpl `echo $modules`"
627 # Create lib/Makefile.am.
628 echo "Creating $destdir/$sourcebase/Makefile.am..."
629 if test -z "$dry_run"; then
630 func_emit_lib_Makefile_am > $destdir/$sourcebase/Makefile.am.new
632 func_emit_lib_Makefile_am
634 func_mv_if_changed $destdir/$sourcebase/Makefile.am.new \
635 $destdir/$sourcebase/Makefile.am
638 echo "Creating $destdir/$m4base/gnulib.m4..."
640 if test -z "$dry_run"; then
641 exec > $destdir/$m4base/gnulib.m4.new
643 echo "# $destdir/$m4base/gnulib.m4"
645 echo "# Copyright (C) 2004 Free Software Foundation, Inc."
646 echo "# This file is free software, distributed under the terms of the GNU"
647 echo "# General Public License. As a special exception to the GNU General"
648 echo "# Public License, this file may be distributed as part of a program"
649 echo "# that contains a configuration script generated by Autoconf, under"
650 echo "# the same distribution terms as the rest of that program."
652 echo "# Generated by gnulib-tool."
654 echo "# Invoked as: $cmd"
655 echo "# Reproduce by: $actioncmd"
657 echo "AC_DEFUN([gl_EARLY],"
659 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 > /dev/null; then
660 echo " AC_GNU_SOURCE"
662 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 > /dev/null; then
663 echo " gl_USE_SYSTEM_EXTENSIONS"
667 echo "AC_DEFUN([gl_INIT],"
669 for module in $modules; do
671 if test -n "$module"; then
672 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./'
673 if test "$module" = 'alloca' && test -n "$libtool"; then
674 echo 'changequote(,)dnl'
675 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
676 echo 'changequote([, ])dnl'
677 echo 'AC_SUBST(LTALLOCA)'
683 echo "dnl Usage: gl_MODULES(module1 module2 ...)"
684 echo "AC_DEFUN([gl_MODULES], [])"
686 echo "dnl Usage: gl_SOURCE_BASE(DIR)"
687 echo "AC_DEFUN([gl_SOURCE_BASE], [])"
689 echo "dnl Usage: gl_M4_BASE(DIR)"
690 echo "AC_DEFUN([gl_M4_BASE], [])"
692 echo "dnl Usage: gl_LIB(LIBNAME)"
693 echo "AC_DEFUN([gl_LIB], [])"
695 echo "dnl Usage: gl_LGPL"
696 echo "AC_DEFUN([gl_LGPL], [])"
698 echo "# gnulib.m4 ends here"
700 func_mv_if_changed $destdir/$m4base/gnulib.m4.new $destdir/$m4base/gnulib.m4
703 echo "You may need to add #include directives for the following .h files."
704 for module in $modules; do
705 func_get_include_directive "$module"
706 done | LC_ALL=C sort -u | sed -e '/^$/d;' -e 's/^/ /'
708 echo "Don't forget to add \"$sourcebase/Makefile\""
709 echo "to AC_CONFIG_FILES in \"$configure_ac\" and to mention"
710 echo "\"`basename $sourcebase`\" in SUBDIRS in some Makefile.am."
713 # func_create_testdir testdir modules
714 func_create_testdir ()
718 modules=`for m in $modules; do echo $m; done | sort | uniq`
720 # Determine final module list.
721 func_modules_transitive_closure
722 echo "Module list with included dependencies:"
723 echo "$modules" | sed -e 's/^/ /'
725 # Determine final file list.
726 func_modules_to_filelist
728 echo "$files" | sed -e 's/^/ /'
730 # Create directories.
731 for d in `echo "$files" | sed -n -e 's,^\(.*\)/[^/]*,\1,p'`; do
732 if test "$d" = build-aux; then
733 mkdir -p "$testdir/$auxdir"
735 mkdir -p "$testdir/$d"
739 # Copy files or make symbolic links.
742 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
745 ln "$gnulib_dir/$f" "$testdir/$g" 2>/dev/null ||
746 if test -z "$symbolic"; then
747 cp -p "$gnulib_dir/$f" "$testdir/$g"
749 ln -s "$gnulib_dir/$f" "$testdir/$g"
753 # Create lib/Makefile.am.
754 mkdir -p "$testdir/lib"
755 func_emit_lib_Makefile_am > "$testdir/lib/Makefile.am"
757 # Create m4/Makefile.am.
758 mkdir -p "$testdir/m4"
759 (echo "## Process this file with automake to produce Makefile.in."
765 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
768 ) > "$testdir/m4/Makefile.am"
772 if test -f "$testdir"/m4/gettext.m4; then
773 # Avoid stupid error message from automake:
774 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
775 mkdir -p "$testdir/po"
776 (echo "## Process this file with automake to produce Makefile.in."
777 ) > "$testdir/po/Makefile.am"
778 subdirs="$subdirs po"
781 # Create Makefile.am.
782 (echo "## Process this file with automake to produce Makefile.in."
784 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
786 echo "SUBDIRS = $subdirs"
788 echo "ACLOCAL_AMFLAGS = -I m4"
789 ) > "$testdir/Makefile.am"
791 # Create configure.ac.
792 (echo "# Process this file with autoconf to produce a configure script."
793 echo "AC_INIT(dummy,0)"
794 echo "AM_INIT_AUTOMAKE"
796 echo "AM_CONFIG_HEADER(config.h)"
799 echo "AC_PROG_INSTALL"
800 echo "AC_PROG_MAKE_SET"
801 echo "AC_PROG_RANLIB"
803 if grep AC_GNU_SOURCE "$testdir"/m4/*.m4 > /dev/null; then
807 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir"/m4/*.m4 > /dev/null; then
808 echo "gl_USE_SYSTEM_EXTENSIONS"
811 for module in $modules; do
813 if test -n "$module"; then
814 func_get_autoconf_snippet "$module"
819 for d in $subdirs; do
820 makefiles="$makefiles $d/Makefile"
822 echo "AC_OUTPUT([$makefiles])"
823 ) > "$testdir/configure.ac"
825 # Create autogenerated files.
827 echo "executing ${AUTORECONF} --force --install"
828 ${AUTORECONF} --force --install
830 if grep '^BUILT_SOURCES *+=' "$testdir/lib/Makefile.am" > /dev/null; then
834 built_sources=`grep '^BUILT_SOURCES *=' Makefile.in | sed -e 's/^BUILT_SOURCES *=//'`
835 if test -n "$built_sources"; then
844 # func_create_megatestdir megatestdir allmodules
845 func_create_megatestdir ()
849 if test -z "$allmodules"; then
850 allmodules=`func_all_modules`
854 # First, all modules one by one.
855 for onemodule in $allmodules; do
856 func_create_testdir "$megatestdir/$onemodule" $onemodule
857 megasubdirs="${megasubdirs}$onemodule "
859 # Then, all modules all together.
860 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
861 allmodules=`for m in $allmodules; do if test $m != fnmatch-posix; then echo $m; fi; done`
862 func_create_testdir "$megatestdir/ALL" "$allmodules"
863 megasubdirs="${megasubdirs}ALL"
865 # Create Makefile.am.
866 (echo "## Process this file with automake to produce Makefile.in."
868 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
870 echo "SUBDIRS = $megasubdirs"
871 ) > "$megatestdir/Makefile.am"
873 # Create configure.ac.
874 (echo "# Process this file with autoconf to produce a configure script."
875 echo "AC_INIT(dummy,0)"
876 echo "AM_INIT_AUTOMAKE"
878 echo "AC_PROG_MAKE_SET"
880 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
881 echo "AC_OUTPUT([Makefile])"
882 ) > "$megatestdir/configure.ac"
884 # Create autogenerated files.
886 echo "executing ${AUTORECONF} --force --install"
887 ${AUTORECONF} --force --install
893 func_fatal_error "no mode specified" ;;
901 if test -z "$destdir"; then
905 || func_fatal_error "destination directory does not exist: $destdir"
907 # Prefer configure.ac to configure.in
908 test -f $destdir/configure.in && configure_ac=$destdir/configure.in
909 test -f $destdir/configure.ac && configure_ac=$destdir/configure.ac
910 test -f "$configure_ac" \
911 || func_fatal_error "cannot find $destdir/configure.ac"
914 my_sed_traces='s,#.*$,,; s,^dnl .*$,,; s, dnl .*$,,;
916 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,ac_modules="\1",; p;
919 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,ac_sourcebase="\1",; p;
922 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,ac_m4base="\1",; p;
925 s,^.*gl_LIB([[ ]*\([^])]*\).*$,ac_libname="\1",; p;
927 /AC_CONFIG_AUX_DIR/ {
928 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,ac_auxdir="\1",; p;
930 /A[CM]_PROG_LIBTOOL/ { s,^.*$,seen_libtool=:,; p; };
931 /LT_INIT/ { s,^.*$,seen_libtool=:,; p; };
932 /gl_LGPL/ { s,^.*$,lgpl=true,; p; };
934 eval `cat $configure_ac | sed "$my_sed_traces"`
937 if test -z "$supplied_libname" && test -n "$ac_libname"; then
938 libname="$ac_libname"
941 # Set up source base.
942 test -z "$sourcebase" && sourcebase="$ac_sourcebase"
943 test -z "$sourcebase" && sourcebase="lib"
944 test -d "$destdir/$sourcebase" \
945 || (test -z "$dry_run" && mkdir "$destdir/$sourcebase") \
946 || func_fatal_error "source base $destdir/$sourcebase doesn't exist"
949 test -z "$m4base" && m4base="$ac_m4base"
950 test -z "$m4base" && m4base="m4"
951 test -d "$destdir/$m4base" \
952 || (test -z "$dry_run" && mkdir "$destdir/$m4base") \
953 || func_fatal_error "m4 base $destdir/$m4base doesn't exist"
955 # Set up auxiliary directory.
956 test -z "$auxdir" && auxdir="$ac_auxdir"
957 test -z "$auxdir" && auxdir="."
958 test -d "$destdir/$auxdir" \
959 || (test -z "$dry_run" && mkdir "$destdir/$auxdir") \
960 || func_fatal_error "aux directory $destdir/$auxdir doesn't exist"
963 if test -n "$seen_libtool"; then
967 # What modules to extract.
969 modules="$ac_modules"
974 func_import "$modules"
978 if test -z "$destdir"; then
979 func_fatal_error "please specify --dir option"
983 || func_fatal_error "could not create destination directory"
984 func_create_testdir "$destdir" "$*"
988 if test -z "$destdir"; then
989 func_fatal_error "please specify --dir option"
991 mkdir "$destdir" || func_fatal_error "could not create destination directory"
992 func_create_megatestdir "$destdir" "$*"
996 test -n "$destdir" || destdir=testdir$$
997 mkdir "$destdir" || func_fatal_error "could not create destination directory"
998 func_create_testdir "$destdir" "$*"
1006 remaining=`find . -type f -print`
1007 if test -n "$remaining"; then
1008 echo "Remaining files:" $remaining 1>&2
1009 echo "gnulib-tool: *** Stop." 1>&2
1018 test -n "$destdir" || destdir=testdir$$
1019 mkdir "$destdir" || func_fatal_error "could not create destination directory"
1020 func_create_megatestdir "$destdir" "$*"
1028 remaining=`find . -type f -print`
1029 if test -n "$remaining"; then
1030 echo "Remaining files:" $remaining 1>&2
1031 echo "gnulib-tool: *** Stop." 1>&2
1039 extract-description )
1043 if test -n "$module"; then
1044 func_get_description "$module"
1053 if test -n "$module"; then
1054 func_get_filelist "$module"
1059 extract-dependencies )
1063 if test -n "$module"; then
1064 func_get_dependencies "$module"
1069 extract-autoconf-snippet )
1073 if test -n "$module"; then
1074 func_get_autoconf_snippet "$module"
1079 extract-automake-snippet )
1083 if test -n "$module"; then
1084 func_get_automake_snippet "$module"
1089 extract-include-directive )
1093 if test -n "$module"; then
1094 func_get_include_directive "$module"
1103 if test -n "$module"; then
1104 func_get_license "$module"
1109 extract-maintainer )
1113 if test -n "$module"; then
1114 func_get_maintainer "$module"
1120 func_fatal_error "unknown operation mode --$mode" ;;