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-05-14 06:03:57 $'
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`
576 if test $license != LGPL; then
577 func_fatal_error "incompatible license on module \`$module\`: $license"
582 # Determine final file list.
583 func_modules_to_filelist
585 echo "$files" | sed -e 's/^/ /'
588 || func_fatal_error "refusing to do nothing"
590 # Copy files or make symbolic links.
594 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
595 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"`; source=true ;;
596 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
599 if test -z "$symbolic"; then
600 func_cp_if_changed "$gnulib_dir/$f" "$destdir/$g"
602 func_ln_if_changed "$gnulib_dir/$f" "$destdir/$g"
605 if test -z "$dry_run" && test -n "$lgpl" && test -n "$source"; then
606 perl -pi -e 's/GNU General/GNU Lesser General/g;' \
607 -e 's/version 2([ ,])/version 2.1\1/g' \
612 # Commands printed in a comment in generated files.
613 cmd="gnulib-tool $supplied_opts"
615 if test -n "$libtool"; then
616 opt_libtool="--libtool"
619 if test -n "$lgpl"; then
622 actioncmd="gnulib-tool --import --dir=$destdir --lib=$libname --source-base=$sourcebase --m4-base=$m4base --aux-dir=$auxdir $opt_libtool $opt_lgpl `echo $modules`"
624 # Create lib/Makefile.am.
625 echo "Creating $destdir/$sourcebase/Makefile.am..."
626 if test -z "$dry_run"; then
627 func_emit_lib_Makefile_am > $destdir/$sourcebase/Makefile.am.new
629 func_emit_lib_Makefile_am
631 func_mv_if_changed $destdir/$sourcebase/Makefile.am.new \
632 $destdir/$sourcebase/Makefile.am
635 echo "Creating $destdir/$m4base/gnulib.m4..."
637 if test -z "$dry_run"; then
638 exec > $destdir/$m4base/gnulib.m4.new
640 echo "# $destdir/$m4base/gnulib.m4"
642 echo "# Copyright (C) 2004 Free Software Foundation, Inc."
643 echo "# This file is free software, distributed under the terms of the GNU"
644 echo "# General Public License. As a special exception to the GNU General"
645 echo "# Public License, this file may be distributed as part of a program"
646 echo "# that contains a configuration script generated by Autoconf, under"
647 echo "# the same distribution terms as the rest of that program."
649 echo "# Generated by gnulib-tool."
651 echo "# Invoked as: $cmd"
652 echo "# Reproduce by: $actioncmd"
654 echo "AC_DEFUN([gl_EARLY],"
656 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 > /dev/null; then
657 echo " AC_GNU_SOURCE"
659 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 > /dev/null; then
660 echo " gl_USE_SYSTEM_EXTENSIONS"
664 echo "AC_DEFUN([gl_INIT],"
666 for module in $modules; do
668 if test -n "$module"; then
669 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./'
670 if test "$module" = 'alloca' && test -n "$libtool"; then
671 echo 'changequote(,)dnl'
672 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
673 echo 'changequote([, ])dnl'
674 echo 'AC_SUBST(LTALLOCA)'
680 echo "dnl Usage: gl_MODULES(module1 module2 ...)"
681 echo "AC_DEFUN([gl_MODULES], [])"
683 echo "dnl Usage: gl_SOURCE_BASE(DIR)"
684 echo "AC_DEFUN([gl_SOURCE_BASE], [])"
686 echo "dnl Usage: gl_M4_BASE(DIR)"
687 echo "AC_DEFUN([gl_M4_BASE], [])"
689 echo "dnl Usage: gl_LIB(LIBNAME)"
690 echo "AC_DEFUN([gl_LIB], [])"
692 echo "dnl Usage: gl_LGPL"
693 echo "AC_DEFUN([gl_LGPL], [])"
695 echo "# gnulib.m4 ends here"
697 func_mv_if_changed $destdir/$m4base/gnulib.m4.new $destdir/$m4base/gnulib.m4
700 echo "You may need to add #include directives for the following .h files."
701 for module in $modules; do
702 func_get_include_directive "$module"
703 done | LC_ALL=C sort -u | sed -e '/^$/d;' -e 's/^/ /'
705 echo "Don't forget to add \"$sourcebase/Makefile\""
706 echo "to AC_CONFIG_FILES in \"$configure_ac\" and to mention"
707 echo "\"`basename $sourcebase`\" in SUBDIRS in some Makefile.am."
710 # func_create_testdir testdir modules
711 func_create_testdir ()
715 modules=`for m in $modules; do echo $m; done | sort | uniq`
717 # Determine final module list.
718 func_modules_transitive_closure
719 echo "Module list with included dependencies:"
720 echo "$modules" | sed -e 's/^/ /'
722 # Determine final file list.
723 func_modules_to_filelist
725 echo "$files" | sed -e 's/^/ /'
727 # Create directories.
728 for d in `echo "$files" | sed -n -e 's,^\(.*\)/[^/]*,\1,p'`; do
729 if test "$d" = build-aux; then
730 mkdir -p "$testdir/$auxdir"
732 mkdir -p "$testdir/$d"
736 # Copy files or make symbolic links.
739 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
742 ln "$gnulib_dir/$f" "$testdir/$g" 2>/dev/null ||
743 if test -z "$symbolic"; then
744 cp -p "$gnulib_dir/$f" "$testdir/$g"
746 ln -s "$gnulib_dir/$f" "$testdir/$g"
750 # Create lib/Makefile.am.
751 mkdir -p "$testdir/lib"
752 func_emit_lib_Makefile_am > "$testdir/lib/Makefile.am"
754 # Create m4/Makefile.am.
755 mkdir -p "$testdir/m4"
756 (echo "## Process this file with automake to produce Makefile.in."
762 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
765 ) > "$testdir/m4/Makefile.am"
769 if test -f "$testdir"/m4/gettext.m4; then
770 # Avoid stupid error message from automake:
771 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
772 mkdir -p "$testdir/po"
773 (echo "## Process this file with automake to produce Makefile.in."
774 ) > "$testdir/po/Makefile.am"
775 subdirs="$subdirs po"
778 # Create Makefile.am.
779 (echo "## Process this file with automake to produce Makefile.in."
781 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
783 echo "SUBDIRS = $subdirs"
785 echo "ACLOCAL_AMFLAGS = -I m4"
786 ) > "$testdir/Makefile.am"
788 # Create configure.ac.
789 (echo "# Process this file with autoconf to produce a configure script."
790 echo "AC_INIT(dummy,0)"
791 echo "AM_INIT_AUTOMAKE"
793 echo "AM_CONFIG_HEADER(config.h)"
796 echo "AC_PROG_INSTALL"
797 echo "AC_PROG_MAKE_SET"
798 echo "AC_PROG_RANLIB"
800 if grep AC_GNU_SOURCE "$testdir"/m4/*.m4 > /dev/null; then
804 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir"/m4/*.m4 > /dev/null; then
805 echo "gl_USE_SYSTEM_EXTENSIONS"
808 for module in $modules; do
810 if test -n "$module"; then
811 func_get_autoconf_snippet "$module"
816 for d in $subdirs; do
817 makefiles="$makefiles $d/Makefile"
819 echo "AC_OUTPUT([$makefiles])"
820 ) > "$testdir/configure.ac"
822 # Create autogenerated files.
824 echo "executing ${AUTORECONF} --force --install"
825 ${AUTORECONF} --force --install
827 if grep '^BUILT_SOURCES *+=' "$testdir/lib/Makefile.am" > /dev/null; then
831 built_sources=`grep '^BUILT_SOURCES *=' Makefile.in | sed -e 's/^BUILT_SOURCES *=//'`
832 if test -n "$built_sources"; then
841 # func_create_megatestdir megatestdir allmodules
842 func_create_megatestdir ()
846 if test -z "$allmodules"; then
847 allmodules=`func_all_modules`
851 # First, all modules one by one.
852 for onemodule in $allmodules; do
853 func_create_testdir "$megatestdir/$onemodule" $onemodule
854 megasubdirs="${megasubdirs}$onemodule "
856 # Then, all modules all together.
857 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
858 allmodules=`for m in $allmodules; do if test $m != fnmatch-posix; then echo $m; fi; done`
859 func_create_testdir "$megatestdir/ALL" "$allmodules"
860 megasubdirs="${megasubdirs}ALL"
862 # Create Makefile.am.
863 (echo "## Process this file with automake to produce Makefile.in."
865 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
867 echo "SUBDIRS = $megasubdirs"
868 ) > "$megatestdir/Makefile.am"
870 # Create configure.ac.
871 (echo "# Process this file with autoconf to produce a configure script."
872 echo "AC_INIT(dummy,0)"
873 echo "AM_INIT_AUTOMAKE"
875 echo "AC_PROG_MAKE_SET"
877 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
878 echo "AC_OUTPUT([Makefile])"
879 ) > "$megatestdir/configure.ac"
881 # Create autogenerated files.
883 echo "executing ${AUTORECONF} --force --install"
884 ${AUTORECONF} --force --install
890 func_fatal_error "no mode specified" ;;
898 if test -z "$destdir"; then
902 || func_fatal_error "destination directory does not exist: $destdir"
904 # Prefer configure.ac to configure.in
905 test -f $destdir/configure.in && configure_ac=$destdir/configure.in
906 test -f $destdir/configure.ac && configure_ac=$destdir/configure.ac
907 test -f "$configure_ac" \
908 || func_fatal_error "cannot find $destdir/configure.ac"
911 my_sed_traces='s,#.*$,,; s,^dnl .*$,,; s, dnl .*$,,;
913 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,ac_modules="\1",; p;
916 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,ac_sourcebase="\1",; p;
919 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,ac_m4base="\1",; p;
922 s,^.*gl_LIB([[ ]*\([^])]*\).*$,ac_libname="\1",; p;
924 /AC_CONFIG_AUX_DIR/ {
925 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,ac_auxdir="\1",; p;
927 /A[CM]_PROG_LIBTOOL/ { s,^.*$,seen_libtool=:,; p; };
928 /LT_INIT/ { s,^.*$,seen_libtool=:,; p; };
929 /gl_LGPL/ { s,^.*$,lgpl=true,; p; };
931 eval `cat $configure_ac | sed "$my_sed_traces"`
934 if test -z "$supplied_libname" && test -n "$ac_libname"; then
935 libname="$ac_libname"
938 # Set up source base.
939 test -z "$sourcebase" && sourcebase="$ac_sourcebase"
940 test -z "$sourcebase" && sourcebase="lib"
941 test -d "$destdir/$sourcebase" \
942 || (test -z "$dry_run" && mkdir "$destdir/$sourcebase") \
943 || func_fatal_error "source base $destdir/$sourcebase doesn't exist"
946 test -z "$m4base" && m4base="$ac_m4base"
947 test -z "$m4base" && m4base="m4"
948 test -d "$destdir/$m4base" \
949 || (test -z "$dry_run" && mkdir "$destdir/$m4base") \
950 || func_fatal_error "m4 base $destdir/$m4base doesn't exist"
952 # Set up auxiliary directory.
953 test -z "$auxdir" && auxdir="$ac_auxdir"
954 test -z "$auxdir" && auxdir="."
955 test -d "$destdir/$auxdir" \
956 || (test -z "$dry_run" && mkdir "$destdir/$auxdir") \
957 || func_fatal_error "aux directory $destdir/$auxdir doesn't exist"
960 if test -n "$seen_libtool"; then
964 # What modules to extract.
966 modules="$ac_modules"
971 func_import "$modules"
975 if test -z "$destdir"; then
976 func_fatal_error "please specify --dir option"
980 || func_fatal_error "could not create destination directory"
981 func_create_testdir "$destdir" "$*"
985 if test -z "$destdir"; then
986 func_fatal_error "please specify --dir option"
988 mkdir "$destdir" || func_fatal_error "could not create destination directory"
989 func_create_megatestdir "$destdir" "$*"
993 test -n "$destdir" || destdir=testdir$$
994 mkdir "$destdir" || func_fatal_error "could not create destination directory"
995 func_create_testdir "$destdir" "$*"
1003 remaining=`find . -type f -print`
1004 if test -n "$remaining"; then
1005 echo "Remaining files:" $remaining 1>&2
1006 echo "gnulib-tool: *** Stop." 1>&2
1015 test -n "$destdir" || destdir=testdir$$
1016 mkdir "$destdir" || func_fatal_error "could not create destination directory"
1017 func_create_megatestdir "$destdir" "$*"
1025 remaining=`find . -type f -print`
1026 if test -n "$remaining"; then
1027 echo "Remaining files:" $remaining 1>&2
1028 echo "gnulib-tool: *** Stop." 1>&2
1036 extract-description )
1040 if test -n "$module"; then
1041 func_get_description "$module"
1050 if test -n "$module"; then
1051 func_get_filelist "$module"
1056 extract-dependencies )
1060 if test -n "$module"; then
1061 func_get_dependencies "$module"
1066 extract-autoconf-snippet )
1070 if test -n "$module"; then
1071 func_get_autoconf_snippet "$module"
1076 extract-automake-snippet )
1080 if test -n "$module"; then
1081 func_get_automake_snippet "$module"
1086 extract-include-directive )
1090 if test -n "$module"; then
1091 func_get_include_directive "$module"
1100 if test -n "$module"; then
1101 func_get_license "$module"
1106 extract-maintainer )
1110 if test -n "$module"; then
1111 func_get_maintainer "$module"
1117 func_fatal_error "unknown operation mode --$mode" ;;