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-08-11 10:08: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 --avoid=MODULE Avoid including the given MODULE. Useful if you
94 have code that provides equivalent functionality.
95 This option can be repeated.
96 --lgpl Abort if modules aren't available under the LGPL.
97 Also modify license template from GPL to LGPL.
98 --libtool Use libtool rules, for --import.
99 --no-changelog don't update or create ChangeLog files
100 --dry-run For --import, only print what would have been done.
101 -s, --symbolic, --symlink Make symbolic links instead of copying files.
103 Report bugs to <bug-gnulib@gnu.org>."
107 # outputs to stdout the --version message.
110 echo "$progname (GNU $package) $version"
111 echo "Copyright (C) 2002 Free Software Foundation, Inc.
112 This is free software; see the source for copying conditions. There is NO
113 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
114 echo "Written by" "Bruno Haible"
117 # func_fatal_error message
118 # outputs to stderr a fatal error message, and terminates the program.
121 echo "gnulib-tool: *** $1" 1>&2
122 echo "gnulib-tool: *** Stop." 1>&2
126 # func_cp_if_changed SRC DEST
127 # Like cp, but avoids munging timestamps if the file hasn't changed.
128 # Uses also the variables
129 # - dry_run true if actions shall only be printed, blank otherwise
130 func_cp_if_changed ()
132 if test $# -ne 2; then
133 echo "usage: func_cp_if_changed SRC DEST" >&2
135 test -n "$dry_run" && dry=echo
136 if cmp "$1" "$2" >/dev/null 2>&1; then
143 # func_mv_if_changed SRC DEST
144 # Like mv, but avoids munging timestamps if the file hasn't changed.
145 # Removes SRC if it is not renamed.
146 # Uses also the variables
147 # - dry_run true if actions shall only be printed, blank otherwise
148 func_mv_if_changed ()
150 if test $# -ne 2; then
151 echo "usage: func_mv_if_changed SRC DEST" >&2
153 test -n "$dry_run" && dry=echo
154 if cmp "$1" "$2" >/dev/null 2>&1; then
161 # func_ln_if_changed SRC DEST
162 # Like ln -s, but avoids munging timestamps if the link is correct.
163 # Uses also the variables
164 # - dry_run true if actions shall only be printed, blank otherwise
165 func_ln_if_changed ()
167 if test $# -ne 2; then
168 echo "usage: func_ln_if_changed SRC DEST" >&2
170 test -n "$dry_run" && dry=echo
171 if test -L "$2" -a "$1" = "`readlink "$2"`"; then
179 # Command-line option processing.
180 # Removes the OPTIONS from the arguments. Sets the variables:
181 # - mode list or import or create-testdir or create-megatestdir
182 # - destdir from --dir
183 # - libname, supplied_libname from --lib
184 # - sourcebase from --source-base
185 # - m4base from --m4-base
186 # - auxdir from --aux-dir
187 # - avoidlist list of modules to avoid, from --avoid
188 # - lgpl true if --lgpl was given, blank otherwise
189 # - libtool true if --libtool was given, blank otherwise
190 # - do_changelog false if --no-changelog was given, : otherwise
191 # - dry_run true if --dry-run was given, blank otherwise
209 while test $# -gt 0; do
214 --import | --impor | --impo | --imp | --im | --i )
217 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
220 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
221 mode=create-megatestdir
223 --test | --tes | --te | --t )
226 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
230 mode=`echo "X$1" | sed -e 's/^X--//'`
235 func_fatal_error "missing argument for --dir"
240 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
245 func_fatal_error "missing argument for --lib"
248 supplied_libname=true
251 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
252 supplied_libname=true
257 func_fatal_error "missing argument for --source-base"
262 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
267 func_fatal_error "missing argument for --m4-base"
272 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
277 func_fatal_error "missing argument for --aux-dir"
282 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
287 func_fatal_error "missing argument for --avoid"
289 avoidlist="$avoidlist $1"
292 avoidlist="$avoidlist "`echo "X$1" | sed -e 's/^X--avoid=//'`
300 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
306 -s | --symbolic | --symlink )
309 --help | --hel | --he | --h )
312 --version | --versio | --versi | --vers | --ver | --ve | --v )
316 # Stop option prcessing
320 echo "gnulib-tool: unknown option $1" 1>&2
321 echo "Try 'gnulib-tool --help' for more information." 1>&2
330 /*) self_abspathname="$0" ;;
331 */*) self_abspathname=`pwd`/"$0" ;;
332 *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
333 if test -x "$d/$0" && test ! -d "$d/$0"; then
334 self_abspathname="$d/$0"
338 if test -z "$self_abspathname"; then
339 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
343 while test -h "$self_abspathname"; do
344 # Resolve symbolic link.
345 sedexpr1='s, -> ,#%%#,'
346 sedexpr2='s,^.*#%%#\(.*\)$,\1,p'
347 linkval=`LC_ALL=C ls -l "$self_abspathname" | sed -e "$sedexpr1" | sed -n -e "$sedexpr2"`
348 test -n "$linkval" || break
350 /* ) self_abspathname="$linkval" ;;
351 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
354 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
359 (cd "$gnulib_dir/modules" && ls -1) \
360 | sed -e '/^CVS$/d' -e '/^ChangeLog$/d' -e '/^README$/d' -e '/^TEMPLATE$/d' -e '/~$/d' \
365 # verifies a module name
366 func_verify_module ()
368 if test ! -f "$gnulib_dir/modules/$module" \
369 || test "CVS" = "$module" \
370 || test "ChangeLog" = "$module" \
371 || test "README" = "$module" \
372 || test "TEMPLATE" = "$module"; then
373 echo "gnulib-tool: module $module doesn't exist" 1>&2
378 sed_extract_prog=':[ ]*$/ {
381 s/^Description:[ ]*$//
383 s/^Depends-on:[ ]*$//
384 s/^configure\.ac:[ ]*$//
385 s/^Makefile\.am:[ ]*$//
388 s/^Maintainer:[ ]*$//
395 # func_get_description module
396 func_get_description ()
398 sed -n -e "/^Description$sed_extract_prog" < "$gnulib_dir/modules/$1"
401 # func_get_filelist module
404 sed -n -e "/^Files$sed_extract_prog" < "$gnulib_dir/modules/$1"
406 echo m4/onceonly_2_57.m4
409 # func_get_dependencies module
410 func_get_dependencies ()
412 sed -n -e "/^Depends-on$sed_extract_prog" < "$gnulib_dir/modules/$1"
415 # func_get_autoconf_snippet module
416 func_get_autoconf_snippet ()
418 sed -n -e "/^configure\.ac$sed_extract_prog" < "$gnulib_dir/modules/$1"
421 # func_get_automake_snippet module
422 func_get_automake_snippet ()
424 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$gnulib_dir/modules/$1"
427 # func_get_include_directive module
428 func_get_include_directive ()
430 sed -n -e "/^Include$sed_extract_prog" < "$gnulib_dir/modules/$1" | \
431 sed -e 's/^\(["<]\)/#include \1/'
434 # func_get_license module
437 sed -n -e "/^License$sed_extract_prog" < "$gnulib_dir/modules/$1"
440 # func_get_maintainer module
441 func_get_maintainer ()
443 sed -n -e "/^Maintainer$sed_extract_prog" < "$gnulib_dir/modules/$1"
446 # func_acceptable module
447 # tests whether a module is acceptable.
449 # - avoidlist list of modules to avoid
452 for avoid in $avoidlist; do
453 if test "$avoid" = "$1"; then
460 # func_modules_transitive_closure
462 # - modules list of specified modules
463 # - avoidlist list of modules to avoid
465 # - modules list of modules, including dependencies
466 func_modules_transitive_closure ()
470 for module in $modules; do
472 if test -n "$module"; then
473 # Duplicate dependencies are harmless, but Jim wants a warning.
474 duplicated_deps=`func_get_dependencies $module | sort | uniq -d`
475 if test -n "$duplicated_deps"; then
476 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
478 if func_acceptable $module; then
479 xmodules="$xmodules $module"
480 for depmodule in `func_get_dependencies $module`; do
481 if func_acceptable $depmodule; then
482 xmodules="$xmodules $depmodule"
488 xmodules=`for m in $xmodules; do echo $m; done | sort | uniq`
489 if test "$xmodules" = "$modules"; then
496 # func_modules_to_filelist
498 # - modules list of modules, including dependencies
500 # - files list of files
501 func_modules_to_filelist ()
504 for module in $modules; do
506 if test -n "$module"; then
507 files="$files "`func_get_filelist $module`
510 files=`for f in $files; do echo $f; done | sort | uniq`
513 # func_emit_lib_Makefile_am
514 # emits the contents of lib/Makefile.am to standard output.
516 # - modules list of modules, including dependencies
517 # - libname library name
518 # - libtool true if libtool will be used, blank otherwise
519 # - cmd (optional) command that led to this invocation
520 # - actioncmd (optional) command that will reproduce this invocation
521 func_emit_lib_Makefile_am ()
523 if test -n "$libtool"; then
530 echo "## Process this file with automake to produce Makefile.in."
531 echo "# Copyright (C) 2004 Free Software Foundation, Inc."
533 echo "# This file is free software, distributed under the terms of the GNU"
534 echo "# General Public License. As a special exception to the GNU General"
535 echo "# Public License, this file may be distributed as part of a program"
536 echo "# that contains a configuration script generated by Automake, under"
537 echo "# the same distribution terms as the rest of that program."
539 echo "# Generated by gnulib-tool."
540 if test -n "$cmd"; then
541 echo "# Invoked as: $cmd"
543 if test -n "$actioncmd"; then
544 echo "# Reproduce by: $actioncmd"
547 # No need to generate dependencies since the sources are in gnulib, not here.
548 echo "AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies"
550 echo "noinst_${perhapsLT}LIBRARIES = $libname.$libext"
552 echo "${libname}_${libext}_SOURCES ="
553 echo "${libname}_${libext}_LIBADD = @${perhapsLT}LIBOBJS@"
555 echo "BUILT_SOURCES ="
557 echo "MOSTLYCLEANFILES ="
559 echo "DISTCLEANFILES ="
560 echo "MAINTAINERCLEANFILES ="
562 for module in $modules; do
564 if test -n "$module"; then
566 func_get_automake_snippet "$module" |
567 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
568 if test "$module" = 'alloca'; then
569 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
572 # Skip the contents if its entirely empty.
573 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
574 echo "## begin gnulib module $module"
577 echo "## end gnulib module $module"
584 echo "# Makefile.am ends here"
587 # func_import modules
588 # Uses also the variables
589 # - destdir target directory
590 # - libname library name
591 # - sourcebase directory relative to destdir where to place source code
592 # - m4base directory relative to destdir where to place *.m4 macros
593 # - avoidlist list of modules to avoid, from --avoid
594 # - lgpl true if library's license shall be LGPL, blank otherwise
595 # - libtool true if libtool will be used, blank otherwise
596 # - dry_run true if actions shall only be printed, blank otherwise
597 # - symbolic true if files should be symlinked, copied otherwise
598 # - supplied_opts all options passed to gnulib-tool
602 modules=`for m in $modules; do echo $m; done | sort | uniq`
604 # Determine final module list.
605 func_modules_transitive_closure
606 echo "Module list with included dependencies:"
607 echo "$modules" | sed -e 's/^/ /'
609 # If --lgpl, check the license of modules are compatible.
610 if test -n "$lgpl"; then
611 for module in $modules; do
612 license=`func_get_license $module`
614 LGPL | 'public domain') ;;
617 "incompatible license on module \`$module\`: $license" ;;
622 # Determine final file list.
623 func_modules_to_filelist
625 echo "$files" | sed -e 's/^/ /'
628 || func_fatal_error "refusing to do nothing"
630 # Copy files or make symbolic links.
634 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
635 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"`; source=true ;;
636 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
639 if test -z "$symbolic"; then
640 func_cp_if_changed "$gnulib_dir/$f" "$destdir/$g"
642 func_ln_if_changed "$gnulib_dir/$f" "$destdir/$g"
645 if test -z "$dry_run" && test -n "$lgpl" && test -n "$source"; then
646 perl -pi -e 's/GNU General/GNU Lesser General/g;' \
647 -e 's/version 2([ ,])/version 2.1\1/g' \
652 # Commands printed in a comment in generated files.
653 cmd="gnulib-tool $supplied_opts"
655 if test -n "$libtool"; then
656 opt_libtool="--libtool"
659 if test -n "$lgpl"; then
662 actioncmd="gnulib-tool --import --dir=$destdir --lib=$libname --source-base=$sourcebase --m4-base=$m4base --aux-dir=$auxdir $opt_libtool $opt_lgpl `echo $modules`"
664 # Create lib/Makefile.am.
665 echo "Creating $destdir/$sourcebase/Makefile.am..."
666 if test -z "$dry_run"; then
667 func_emit_lib_Makefile_am > $destdir/$sourcebase/Makefile.am.new
669 func_emit_lib_Makefile_am
671 func_mv_if_changed $destdir/$sourcebase/Makefile.am.new \
672 $destdir/$sourcebase/Makefile.am
675 echo "Creating $destdir/$m4base/gnulib.m4..."
677 if test -z "$dry_run"; then
678 exec > $destdir/$m4base/gnulib.m4.new
680 echo "# $destdir/$m4base/gnulib.m4"
682 echo "# Copyright (C) 2004 Free Software Foundation, Inc."
683 echo "# This file is free software, distributed under the terms of the GNU"
684 echo "# General Public License. As a special exception to the GNU General"
685 echo "# Public License, this file may be distributed as part of a program"
686 echo "# that contains a configuration script generated by Autoconf, under"
687 echo "# the same distribution terms as the rest of that program."
689 echo "# Generated by gnulib-tool."
691 echo "# Invoked as: $cmd"
692 echo "# Reproduce by: $actioncmd"
694 echo "AC_DEFUN([gl_EARLY],"
696 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 > /dev/null; then
697 echo " AC_GNU_SOURCE"
699 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 > /dev/null; then
700 echo " gl_USE_SYSTEM_EXTENSIONS"
704 echo "AC_DEFUN([gl_INIT],"
706 for module in $modules; do
708 if test -n "$module"; then
709 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./'
710 if test "$module" = 'alloca' && test -n "$libtool"; then
711 echo 'changequote(,)dnl'
712 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
713 echo 'changequote([, ])dnl'
714 echo 'AC_SUBST(LTALLOCA)'
720 echo "dnl Usage: gl_MODULES(module1 module2 ...)"
721 echo "AC_DEFUN([gl_MODULES], [])"
723 echo "dnl Usage: gl_AVOID(module1 module2 ...)"
724 echo "AC_DEFUN([gl_AVOID], [])"
726 echo "dnl Usage: gl_SOURCE_BASE(DIR)"
727 echo "AC_DEFUN([gl_SOURCE_BASE], [])"
729 echo "dnl Usage: gl_M4_BASE(DIR)"
730 echo "AC_DEFUN([gl_M4_BASE], [])"
732 echo "dnl Usage: gl_LIB(LIBNAME)"
733 echo "AC_DEFUN([gl_LIB], [])"
735 echo "dnl Usage: gl_LGPL"
736 echo "AC_DEFUN([gl_LGPL], [])"
738 echo "# gnulib.m4 ends here"
740 func_mv_if_changed $destdir/$m4base/gnulib.m4.new $destdir/$m4base/gnulib.m4
743 echo "You may need to add #include directives for the following .h files."
744 for module in $modules; do
745 func_get_include_directive "$module"
746 done | LC_ALL=C sort -u | sed -e '/^$/d;' -e 's/^/ /'
748 echo "Don't forget to add \"$sourcebase/Makefile\""
749 echo "to AC_CONFIG_FILES in \"$configure_ac\" and to mention"
750 echo "\"`basename $sourcebase`\" in SUBDIRS in some Makefile.am."
753 # func_create_testdir testdir modules
754 func_create_testdir ()
758 modules=`for m in $modules; do echo $m; done | sort | uniq`
760 # Determine final module list.
761 func_modules_transitive_closure
762 echo "Module list with included dependencies:"
763 echo "$modules" | sed -e 's/^/ /'
765 # Determine final file list.
766 func_modules_to_filelist
768 echo "$files" | sed -e 's/^/ /'
770 # Create directories.
771 for d in `echo "$files" | sed -n -e 's,^\(.*\)/[^/]*,\1,p'`; do
772 if test "$d" = build-aux; then
773 mkdir -p "$testdir/$auxdir"
775 mkdir -p "$testdir/$d"
779 # Copy files or make symbolic links.
782 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
785 ln "$gnulib_dir/$f" "$testdir/$g" 2>/dev/null ||
786 if test -z "$symbolic"; then
787 cp -p "$gnulib_dir/$f" "$testdir/$g"
789 ln -s "$gnulib_dir/$f" "$testdir/$g"
793 # Create lib/Makefile.am.
794 mkdir -p "$testdir/lib"
795 func_emit_lib_Makefile_am > "$testdir/lib/Makefile.am"
797 # Create m4/Makefile.am.
798 mkdir -p "$testdir/m4"
799 (echo "## Process this file with automake to produce Makefile.in."
805 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
808 ) > "$testdir/m4/Makefile.am"
812 if test -f "$testdir"/m4/gettext.m4; then
813 # Avoid stupid error message from automake:
814 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
815 mkdir -p "$testdir/po"
816 (echo "## Process this file with automake to produce Makefile.in."
817 ) > "$testdir/po/Makefile.am"
818 subdirs="$subdirs po"
821 # Create Makefile.am.
822 (echo "## Process this file with automake to produce Makefile.in."
824 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
826 echo "SUBDIRS = $subdirs"
828 echo "ACLOCAL_AMFLAGS = -I m4"
829 ) > "$testdir/Makefile.am"
831 # Create configure.ac.
832 (echo "# Process this file with autoconf to produce a configure script."
833 echo "AC_INIT(dummy,0)"
834 echo "AM_INIT_AUTOMAKE"
836 echo "AM_CONFIG_HEADER(config.h)"
839 echo "AC_PROG_INSTALL"
840 echo "AC_PROG_MAKE_SET"
841 echo "AC_PROG_RANLIB"
843 if grep AC_GNU_SOURCE "$testdir"/m4/*.m4 > /dev/null; then
847 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir"/m4/*.m4 > /dev/null; then
848 echo "gl_USE_SYSTEM_EXTENSIONS"
851 for module in $modules; do
853 if test -n "$module"; then
854 func_get_autoconf_snippet "$module"
859 for d in $subdirs; do
860 makefiles="$makefiles $d/Makefile"
862 echo "AC_OUTPUT([$makefiles])"
863 ) > "$testdir/configure.ac"
865 # Create autogenerated files.
867 echo "executing ${AUTORECONF} --force --install"
868 ${AUTORECONF} --force --install
870 if grep '^BUILT_SOURCES *+=' "$testdir/lib/Makefile.am" > /dev/null; then
874 built_sources=`grep '^BUILT_SOURCES *=' Makefile.in | sed -e 's/^BUILT_SOURCES *=//'`
875 if test -n "$built_sources"; then
884 # func_create_megatestdir megatestdir allmodules
885 func_create_megatestdir ()
889 if test -z "$allmodules"; then
890 allmodules=`func_all_modules`
894 # First, all modules one by one.
895 for onemodule in $allmodules; do
896 func_create_testdir "$megatestdir/$onemodule" $onemodule
897 megasubdirs="${megasubdirs}$onemodule "
899 # Then, all modules all together.
900 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
901 allmodules=`for m in $allmodules; do if test $m != fnmatch-posix; then echo $m; fi; done`
902 func_create_testdir "$megatestdir/ALL" "$allmodules"
903 megasubdirs="${megasubdirs}ALL"
905 # Create Makefile.am.
906 (echo "## Process this file with automake to produce Makefile.in."
908 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
910 echo "SUBDIRS = $megasubdirs"
911 ) > "$megatestdir/Makefile.am"
913 # Create configure.ac.
914 (echo "# Process this file with autoconf to produce a configure script."
915 echo "AC_INIT(dummy,0)"
916 echo "AM_INIT_AUTOMAKE"
918 echo "AC_PROG_MAKE_SET"
920 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
921 echo "AC_OUTPUT([Makefile])"
922 ) > "$megatestdir/configure.ac"
924 # Create autogenerated files.
926 echo "executing ${AUTORECONF} --force --install"
927 ${AUTORECONF} --force --install
933 func_fatal_error "no mode specified" ;;
941 if test -z "$destdir"; then
945 || func_fatal_error "destination directory does not exist: $destdir"
947 # Prefer configure.ac to configure.in
948 test -f $destdir/configure.in && configure_ac=$destdir/configure.in
949 test -f $destdir/configure.ac && configure_ac=$destdir/configure.ac
950 test -f "$configure_ac" \
951 || func_fatal_error "cannot find $destdir/configure.ac"
954 my_sed_traces='s,#.*$,,; s,^dnl .*$,,; s, dnl .*$,,;
956 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,ac_modules="\1",; p;
959 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,ac_avoidlist="\1",; p;
962 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,ac_sourcebase="\1",; p;
965 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,ac_m4base="\1",; p;
968 s,^.*gl_LIB([[ ]*\([^])]*\).*$,ac_libname="\1",; p;
970 /AC_CONFIG_AUX_DIR/ {
971 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,ac_auxdir="\1",; p;
973 /A[CM]_PROG_LIBTOOL/ { s,^.*$,seen_libtool=:,; p; };
974 /LT_INIT/ { s,^.*$,seen_libtool=:,; p; };
975 /gl_LGPL/ { s,^.*$,lgpl=true,; p; };
977 eval `cat $configure_ac | sed "$my_sed_traces"`
980 if test -z "$supplied_libname" && test -n "$ac_libname"; then
981 libname="$ac_libname"
984 # Set up source base.
985 test -z "$sourcebase" && sourcebase="$ac_sourcebase"
986 test -z "$sourcebase" && sourcebase="lib"
987 test -d "$destdir/$sourcebase" \
988 || (test -z "$dry_run" && mkdir "$destdir/$sourcebase") \
989 || func_fatal_error "source base $destdir/$sourcebase doesn't exist"
992 test -z "$m4base" && m4base="$ac_m4base"
993 test -z "$m4base" && m4base="m4"
994 test -d "$destdir/$m4base" \
995 || (test -z "$dry_run" && mkdir "$destdir/$m4base") \
996 || func_fatal_error "m4 base $destdir/$m4base doesn't exist"
998 # Set up auxiliary directory.
999 test -z "$auxdir" && auxdir="$ac_auxdir"
1000 test -z "$auxdir" && auxdir="."
1001 test -d "$destdir/$auxdir" \
1002 || (test -z "$dry_run" && mkdir "$destdir/$auxdir") \
1003 || func_fatal_error "aux directory $destdir/$auxdir doesn't exist"
1006 if test -n "$seen_libtool"; then
1010 # What modules to extract.
1011 if test $# = 0; then
1012 modules="$ac_modules"
1017 # Which modules to avoid?
1018 avoidlist="$avoidlist $ac_avoidlist"
1020 func_import "$modules"
1024 if test -z "$destdir"; then
1025 func_fatal_error "please specify --dir option"
1028 test -d "$destdir" \
1029 || func_fatal_error "could not create destination directory"
1030 func_create_testdir "$destdir" "$*"
1033 create-megatestdir )
1034 if test -z "$destdir"; then
1035 func_fatal_error "please specify --dir option"
1037 mkdir "$destdir" || func_fatal_error "could not create destination directory"
1038 func_create_megatestdir "$destdir" "$*"
1042 test -n "$destdir" || destdir=testdir$$
1043 mkdir "$destdir" || func_fatal_error "could not create destination directory"
1044 func_create_testdir "$destdir" "$*"
1052 remaining=`find . -type f -print`
1053 if test -n "$remaining"; then
1054 echo "Remaining files:" $remaining 1>&2
1055 echo "gnulib-tool: *** Stop." 1>&2
1064 test -n "$destdir" || destdir=testdir$$
1065 mkdir "$destdir" || func_fatal_error "could not create destination directory"
1066 func_create_megatestdir "$destdir" "$*"
1074 remaining=`find . -type f -print`
1075 if test -n "$remaining"; then
1076 echo "Remaining files:" $remaining 1>&2
1077 echo "gnulib-tool: *** Stop." 1>&2
1085 extract-description )
1089 if test -n "$module"; then
1090 func_get_description "$module"
1099 if test -n "$module"; then
1100 func_get_filelist "$module"
1105 extract-dependencies )
1109 if test -n "$module"; then
1110 func_get_dependencies "$module"
1115 extract-autoconf-snippet )
1119 if test -n "$module"; then
1120 func_get_autoconf_snippet "$module"
1125 extract-automake-snippet )
1129 if test -n "$module"; then
1130 func_get_automake_snippet "$module"
1135 extract-include-directive )
1139 if test -n "$module"; then
1140 func_get_include_directive "$module"
1149 if test -n "$module"; then
1150 func_get_license "$module"
1155 extract-maintainer )
1159 if test -n "$module"; then
1160 func_get_maintainer "$module"
1166 func_fatal_error "unknown operation mode --$mode" ;;