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-25 12:00:38 $'
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 \"build-aux\"),
94 --avoid=MODULE Avoid including the given MODULE. Useful if you
95 have code that provides equivalent functionality.
96 This option can be repeated.
97 --lgpl Abort if modules aren't available under the LGPL.
98 Also modify license template from GPL to LGPL.
99 --libtool Use libtool rules, for --import.
100 --no-changelog don't update or create ChangeLog files
101 --dry-run For --import, only print what would have been done.
102 -s, --symbolic, --symlink Make symbolic links instead of copying files.
104 Report bugs to <bug-gnulib@gnu.org>."
108 # outputs to stdout the --version message.
111 echo "$progname (GNU $package) $version"
112 echo "Copyright (C) 2002 Free Software Foundation, Inc.
113 This is free software; see the source for copying conditions. There is NO
114 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
115 echo "Written by" "Bruno Haible"
118 # func_fatal_error message
119 # outputs to stderr a fatal error message, and terminates the program.
122 echo "gnulib-tool: *** $1" 1>&2
123 echo "gnulib-tool: *** Stop." 1>&2
127 # func_cp_if_changed SRC DEST
128 # Like cp, but avoids munging timestamps if the file hasn't changed.
129 # Uses also the variables
130 # - dry_run true if actions shall only be printed, blank otherwise
131 func_cp_if_changed ()
133 if test $# -ne 2; then
134 echo "usage: func_cp_if_changed SRC DEST" >&2
136 test -n "$dry_run" && dry=echo
137 if cmp "$1" "$2" >/dev/null 2>&1; then
144 # func_mv_if_changed SRC DEST
145 # Like mv, but avoids munging timestamps if the file hasn't changed.
146 # Removes SRC if it is not renamed.
147 # Uses also the variables
148 # - dry_run true if actions shall only be printed, blank otherwise
149 func_mv_if_changed ()
151 if test $# -ne 2; then
152 echo "usage: func_mv_if_changed SRC DEST" >&2
154 test -n "$dry_run" && dry=echo
155 if cmp "$1" "$2" >/dev/null 2>&1; then
162 # func_ln_if_changed SRC DEST
163 # Like ln -s, but avoids munging timestamps if the link is correct.
164 # Uses also the variables
165 # - dry_run true if actions shall only be printed, blank otherwise
166 func_ln_if_changed ()
168 if test $# -ne 2; then
169 echo "usage: func_ln_if_changed SRC DEST" >&2
171 test -n "$dry_run" && dry=echo
172 if test -L "$2" -a "$1" = "`readlink "$2"`"; then
180 # Command-line option processing.
181 # Removes the OPTIONS from the arguments. Sets the variables:
182 # - mode list or import or create-testdir or create-megatestdir
183 # - destdir from --dir
184 # - libname, supplied_libname from --lib
185 # - sourcebase from --source-base
186 # - m4base from --m4-base
187 # - auxdir from --aux-dir
188 # - avoidlist list of modules to avoid, from --avoid
189 # - lgpl true if --lgpl was given, blank otherwise
190 # - libtool true if --libtool was given, blank otherwise
191 # - do_changelog false if --no-changelog was given, : otherwise
192 # - dry_run true if --dry-run was given, blank otherwise
210 while test $# -gt 0; do
215 --import | --impor | --impo | --imp | --im | --i )
218 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
221 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
222 mode=create-megatestdir
224 --test | --tes | --te | --t )
227 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
231 mode=`echo "X$1" | sed -e 's/^X--//'`
236 func_fatal_error "missing argument for --dir"
241 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
246 func_fatal_error "missing argument for --lib"
249 supplied_libname=true
252 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
253 supplied_libname=true
258 func_fatal_error "missing argument for --source-base"
263 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
268 func_fatal_error "missing argument for --m4-base"
273 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
278 func_fatal_error "missing argument for --aux-dir"
283 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
288 func_fatal_error "missing argument for --avoid"
290 avoidlist="$avoidlist $1"
293 avoidlist="$avoidlist "`echo "X$1" | sed -e 's/^X--avoid=//'`
301 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
307 -s | --symbolic | --symlink )
310 --help | --hel | --he | --h )
313 --version | --versio | --versi | --vers | --ver | --ve | --v )
317 # Stop option prcessing
321 echo "gnulib-tool: unknown option $1" 1>&2
322 echo "Try 'gnulib-tool --help' for more information." 1>&2
331 /*) self_abspathname="$0" ;;
332 */*) self_abspathname=`pwd`/"$0" ;;
333 *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
334 if test -x "$d/$0" && test ! -d "$d/$0"; then
335 self_abspathname="$d/$0"
339 if test -z "$self_abspathname"; then
340 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
344 while test -h "$self_abspathname"; do
345 # Resolve symbolic link.
346 sedexpr1='s, -> ,#%%#,'
347 sedexpr2='s,^.*#%%#\(.*\)$,\1,p'
348 linkval=`LC_ALL=C ls -l "$self_abspathname" | sed -e "$sedexpr1" | sed -n -e "$sedexpr2"`
349 test -n "$linkval" || break
351 /* ) self_abspathname="$linkval" ;;
352 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
355 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
360 (cd "$gnulib_dir/modules" && ls -1) \
361 | sed -e '/^CVS$/d' -e '/^ChangeLog$/d' -e '/^README$/d' -e '/^TEMPLATE$/d' -e '/~$/d' \
366 # verifies a module name
367 func_verify_module ()
369 if test ! -f "$gnulib_dir/modules/$module" \
370 || test "CVS" = "$module" \
371 || test "ChangeLog" = "$module" \
372 || test "README" = "$module" \
373 || test "TEMPLATE" = "$module"; then
374 echo "gnulib-tool: module $module doesn't exist" 1>&2
379 sed_extract_prog=':[ ]*$/ {
382 s/^Description:[ ]*$//
384 s/^Depends-on:[ ]*$//
385 s/^configure\.ac:[ ]*$//
386 s/^Makefile\.am:[ ]*$//
389 s/^Maintainer:[ ]*$//
396 # func_get_description module
397 func_get_description ()
399 sed -n -e "/^Description$sed_extract_prog" < "$gnulib_dir/modules/$1"
402 # func_get_filelist module
405 sed -n -e "/^Files$sed_extract_prog" < "$gnulib_dir/modules/$1"
407 echo m4/onceonly_2_57.m4
410 # func_get_dependencies module
411 func_get_dependencies ()
413 sed -n -e "/^Depends-on$sed_extract_prog" < "$gnulib_dir/modules/$1"
416 # func_get_autoconf_snippet module
417 func_get_autoconf_snippet ()
419 sed -n -e "/^configure\.ac$sed_extract_prog" < "$gnulib_dir/modules/$1"
422 # func_get_automake_snippet module
423 func_get_automake_snippet ()
425 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$gnulib_dir/modules/$1"
428 # func_get_include_directive module
429 func_get_include_directive ()
431 sed -n -e "/^Include$sed_extract_prog" < "$gnulib_dir/modules/$1" | \
432 sed -e 's/^\(["<]\)/#include \1/'
435 # func_get_license module
438 sed -n -e "/^License$sed_extract_prog" < "$gnulib_dir/modules/$1"
441 # func_get_maintainer module
442 func_get_maintainer ()
444 sed -n -e "/^Maintainer$sed_extract_prog" < "$gnulib_dir/modules/$1"
447 # func_acceptable module
448 # tests whether a module is acceptable.
450 # - avoidlist list of modules to avoid
453 for avoid in $avoidlist; do
454 if test "$avoid" = "$1"; then
461 # func_modules_transitive_closure
463 # - modules list of specified modules
464 # - avoidlist list of modules to avoid
466 # - modules list of modules, including dependencies
467 func_modules_transitive_closure ()
471 for module in $modules; do
473 if test -n "$module"; then
474 # Duplicate dependencies are harmless, but Jim wants a warning.
475 duplicated_deps=`func_get_dependencies $module | sort | uniq -d`
476 if test -n "$duplicated_deps"; then
477 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
479 if func_acceptable $module; then
480 xmodules="$xmodules $module"
481 for depmodule in `func_get_dependencies $module`; do
482 if func_acceptable $depmodule; then
483 xmodules="$xmodules $depmodule"
489 xmodules=`for m in $xmodules; do echo $m; done | sort | uniq`
490 if test "$xmodules" = "$modules"; then
497 # func_modules_to_filelist
499 # - modules list of modules, including dependencies
501 # - files list of files
502 func_modules_to_filelist ()
505 for module in $modules; do
507 if test -n "$module"; then
508 files="$files "`func_get_filelist $module`
511 files=`for f in $files; do echo $f; done | sort | uniq`
514 # func_emit_lib_Makefile_am
515 # emits the contents of lib/Makefile.am to standard output.
517 # - modules list of modules, including dependencies
518 # - libname library name
519 # - libtool true if libtool will be used, blank otherwise
520 # - cmd (optional) command that led to this invocation
521 # - actioncmd (optional) command that will reproduce this invocation
522 func_emit_lib_Makefile_am ()
524 if test -n "$libtool"; then
531 echo "## Process this file with automake to produce Makefile.in."
532 echo "# Copyright (C) 2004 Free Software Foundation, Inc."
534 echo "# This file is free software, distributed under the terms of the GNU"
535 echo "# General Public License. As a special exception to the GNU General"
536 echo "# Public License, this file may be distributed as part of a program"
537 echo "# that contains a configuration script generated by Automake, under"
538 echo "# the same distribution terms as the rest of that program."
540 echo "# Generated by gnulib-tool."
541 if test -n "$cmd"; then
542 echo "# Invoked as: $cmd"
544 if test -n "$actioncmd"; then
545 echo "# Reproduce by: $actioncmd"
548 # No need to generate dependencies since the sources are in gnulib, not here.
549 echo "AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies"
551 echo "noinst_${perhapsLT}LIBRARIES = $libname.$libext"
553 echo "${libname}_${libext}_SOURCES ="
554 echo "${libname}_${libext}_LIBADD = @${perhapsLT}LIBOBJS@"
556 echo "BUILT_SOURCES ="
558 echo "MOSTLYCLEANFILES ="
560 echo "DISTCLEANFILES ="
561 echo "MAINTAINERCLEANFILES ="
563 for module in $modules; do
565 if test -n "$module"; then
567 func_get_automake_snippet "$module" |
568 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
569 if test "$module" = 'alloca'; then
570 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
573 # Skip the contents if its entirely empty.
574 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
575 echo "## begin gnulib module $module"
578 echo "## end gnulib module $module"
585 echo "# Makefile.am ends here"
588 # func_import modules
589 # Uses also the variables
590 # - destdir target directory
591 # - libname library name
592 # - sourcebase directory relative to destdir where to place source code
593 # - m4base directory relative to destdir where to place *.m4 macros
594 # - avoidlist list of modules to avoid, from --avoid
595 # - lgpl true if library's license shall be LGPL, blank otherwise
596 # - libtool true if libtool will be used, blank otherwise
597 # - dry_run true if actions shall only be printed, blank otherwise
598 # - symbolic true if files should be symlinked, copied otherwise
599 # - supplied_opts all options passed to gnulib-tool
603 modules=`for m in $modules; do echo $m; done | sort | uniq`
605 # Determine final module list.
606 func_modules_transitive_closure
607 echo "Module list with included dependencies:"
608 echo "$modules" | sed -e 's/^/ /'
610 # If --lgpl, check the license of modules are compatible.
611 if test -n "$lgpl"; then
612 for module in $modules; do
613 license=`func_get_license $module`
615 LGPL | 'public domain' | 'unlimited') ;;
618 "incompatible license on module \`$module\`: $license" ;;
623 # Determine final file list.
624 func_modules_to_filelist
626 echo "$files" | sed -e 's/^/ /'
629 || func_fatal_error "refusing to do nothing"
631 # Copy files or make symbolic links.
635 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
636 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"`; source=true ;;
637 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
640 if test -z "$symbolic"; then
641 func_cp_if_changed "$gnulib_dir/$f" "$destdir/$g"
643 func_ln_if_changed "$gnulib_dir/$f" "$destdir/$g"
646 if test -z "$dry_run" && test -n "$lgpl" && test -n "$source"; then
647 perl -pi -e 's/GNU General/GNU Lesser General/g;' \
648 -e 's/version 2([ ,])/version 2.1\1/g' \
653 # Commands printed in a comment in generated files.
654 cmd="gnulib-tool $supplied_opts"
656 if test -n "$libtool"; then
657 opt_libtool="--libtool"
660 if test -n "$lgpl"; then
663 actioncmd="gnulib-tool --import --dir=$destdir --lib=$libname --source-base=$sourcebase --m4-base=$m4base --aux-dir=$auxdir $opt_libtool $opt_lgpl `echo $modules`"
665 # Create lib/Makefile.am.
666 echo "Creating $destdir/$sourcebase/Makefile.am..."
667 if test -z "$dry_run"; then
668 func_emit_lib_Makefile_am > $destdir/$sourcebase/Makefile.am.new
670 func_emit_lib_Makefile_am
672 func_mv_if_changed $destdir/$sourcebase/Makefile.am.new \
673 $destdir/$sourcebase/Makefile.am
676 echo "Creating $destdir/$m4base/gnulib.m4..."
678 if test -z "$dry_run"; then
679 exec > $destdir/$m4base/gnulib.m4.new
681 echo "# $destdir/$m4base/gnulib.m4"
683 echo "# Copyright (C) 2004 Free Software Foundation, Inc."
684 echo "# This file is free software, distributed under the terms of the GNU"
685 echo "# General Public License. As a special exception to the GNU General"
686 echo "# Public License, this file may be distributed as part of a program"
687 echo "# that contains a configuration script generated by Autoconf, under"
688 echo "# the same distribution terms as the rest of that program."
690 echo "# Generated by gnulib-tool."
692 echo "# Invoked as: $cmd"
693 echo "# Reproduce by: $actioncmd"
695 echo "AC_DEFUN([gl_EARLY],"
697 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 > /dev/null; then
698 echo " AC_GNU_SOURCE"
700 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 > /dev/null; then
701 echo " gl_USE_SYSTEM_EXTENSIONS"
705 echo "AC_DEFUN([gl_INIT],"
707 for module in $modules; do
709 if test -n "$module"; then
710 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./'
711 if test "$module" = 'alloca' && test -n "$libtool"; then
712 echo 'changequote(,)dnl'
713 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
714 echo 'changequote([, ])dnl'
715 echo 'AC_SUBST([LTALLOCA])'
721 echo "dnl Usage: gl_MODULES([module1 module2 ...])"
722 echo "AC_DEFUN([gl_MODULES], [])"
724 echo "dnl Usage: gl_AVOID([module1 module2 ...])"
725 echo "AC_DEFUN([gl_AVOID], [])"
727 echo "dnl Usage: gl_SOURCE_BASE([DIR])"
728 echo "AC_DEFUN([gl_SOURCE_BASE], [])"
730 echo "dnl Usage: gl_M4_BASE([DIR])"
731 echo "AC_DEFUN([gl_M4_BASE], [])"
733 echo "dnl Usage: gl_LIB([LIBNAME])"
734 echo "AC_DEFUN([gl_LIB], [])"
736 echo "dnl Usage: gl_LGPL"
737 echo "AC_DEFUN([gl_LGPL], [])"
739 echo "# gnulib.m4 ends here"
741 func_mv_if_changed $destdir/$m4base/gnulib.m4.new $destdir/$m4base/gnulib.m4
744 echo "You may need to add #include directives for the following .h files."
745 for module in $modules; do
746 func_get_include_directive "$module"
747 done | LC_ALL=C sort -u | sed -e '/^$/d;' -e 's/^/ /'
749 echo "Don't forget to add \"$sourcebase/Makefile\""
750 echo "to AC_CONFIG_FILES in \"$configure_ac\" and to mention"
751 echo "\"`basename $sourcebase`\" in SUBDIRS in some Makefile.am."
754 # func_create_testdir testdir modules
755 func_create_testdir ()
759 modules=`for m in $modules; do echo $m; done | sort | uniq`
761 # Determine final module list.
762 func_modules_transitive_closure
763 echo "Module list with included dependencies:"
764 echo "$modules" | sed -e 's/^/ /'
766 # Determine final file list.
767 func_modules_to_filelist
769 echo "$files" | sed -e 's/^/ /'
771 # Create directories.
772 for d in `echo "$files" | sed -n -e 's,^\(.*\)/[^/]*,\1,p'`; do
773 if test "$d" = build-aux; then
774 mkdir -p "$testdir/$auxdir"
776 mkdir -p "$testdir/$d"
780 # Copy files or make symbolic links.
783 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
786 ln "$gnulib_dir/$f" "$testdir/$g" 2>/dev/null ||
787 if test -z "$symbolic"; then
788 cp -p "$gnulib_dir/$f" "$testdir/$g"
790 ln -s "$gnulib_dir/$f" "$testdir/$g"
794 # Create lib/Makefile.am.
795 mkdir -p "$testdir/lib"
796 func_emit_lib_Makefile_am > "$testdir/lib/Makefile.am"
798 # Create m4/Makefile.am.
799 mkdir -p "$testdir/m4"
800 (echo "## Process this file with automake to produce Makefile.in."
806 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
809 ) > "$testdir/m4/Makefile.am"
813 if test -f "$testdir"/m4/gettext.m4; then
814 # Avoid stupid error message from automake:
815 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
816 mkdir -p "$testdir/po"
817 (echo "## Process this file with automake to produce Makefile.in."
818 ) > "$testdir/po/Makefile.am"
819 subdirs="$subdirs po"
822 # Create Makefile.am.
823 (echo "## Process this file with automake to produce Makefile.in."
825 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
827 echo "SUBDIRS = $subdirs"
829 echo "ACLOCAL_AMFLAGS = -I m4"
830 ) > "$testdir/Makefile.am"
832 # Create configure.ac.
833 (echo "# Process this file with autoconf to produce a configure script."
834 echo "AC_INIT([dummy], [0])"
835 echo "AM_INIT_AUTOMAKE"
837 echo "AM_CONFIG_HEADER([config.h])"
840 echo "AC_PROG_INSTALL"
841 echo "AC_PROG_MAKE_SET"
842 echo "AC_PROG_RANLIB"
844 if grep AC_GNU_SOURCE "$testdir"/m4/*.m4 > /dev/null; then
848 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir"/m4/*.m4 > /dev/null; then
849 echo "gl_USE_SYSTEM_EXTENSIONS"
852 for module in $modules; do
854 if test -n "$module"; then
855 func_get_autoconf_snippet "$module"
860 for d in $subdirs; do
861 makefiles="$makefiles $d/Makefile"
863 echo "AC_OUTPUT([$makefiles])"
864 ) > "$testdir/configure.ac"
866 # Create autogenerated files.
868 echo "executing ${AUTORECONF} --force --install"
869 ${AUTORECONF} --force --install
871 if grep '^BUILT_SOURCES *+=' "$testdir/lib/Makefile.am" > /dev/null; then
875 built_sources=`grep '^BUILT_SOURCES *=' Makefile.in | sed -e 's/^BUILT_SOURCES *=//'`
876 if test -n "$built_sources"; then
885 # func_create_megatestdir megatestdir allmodules
886 func_create_megatestdir ()
890 if test -z "$allmodules"; then
891 allmodules=`func_all_modules`
895 # First, all modules one by one.
896 for onemodule in $allmodules; do
897 func_create_testdir "$megatestdir/$onemodule" $onemodule
898 megasubdirs="${megasubdirs}$onemodule "
900 # Then, all modules all together.
901 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
902 allmodules=`for m in $allmodules; do if test $m != fnmatch-posix; then echo $m; fi; done`
903 func_create_testdir "$megatestdir/ALL" "$allmodules"
904 megasubdirs="${megasubdirs}ALL"
906 # Create Makefile.am.
907 (echo "## Process this file with automake to produce Makefile.in."
909 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
911 echo "SUBDIRS = $megasubdirs"
912 ) > "$megatestdir/Makefile.am"
914 # Create configure.ac.
915 (echo "# Process this file with autoconf to produce a configure script."
916 echo "AC_INIT([dummy], [0])"
917 echo "AM_INIT_AUTOMAKE"
919 echo "AC_PROG_MAKE_SET"
921 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
922 echo "AC_OUTPUT([Makefile])"
923 ) > "$megatestdir/configure.ac"
925 # Create autogenerated files.
927 echo "executing ${AUTORECONF} --force --install"
928 ${AUTORECONF} --force --install
934 func_fatal_error "no mode specified" ;;
942 if test -z "$destdir"; then
946 || func_fatal_error "destination directory does not exist: $destdir"
948 # Prefer configure.ac to configure.in
949 test -f $destdir/configure.in && configure_ac=$destdir/configure.in
950 test -f $destdir/configure.ac && configure_ac=$destdir/configure.ac
951 test -f "$configure_ac" \
952 || func_fatal_error "cannot find $destdir/configure.ac"
955 my_sed_traces='s,#.*$,,; s,^dnl .*$,,; s, dnl .*$,,;
957 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,ac_modules="\1",; p;
960 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,ac_avoidlist="\1",; p;
963 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,ac_sourcebase="\1",; p;
966 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,ac_m4base="\1",; p;
969 s,^.*gl_LIB([[ ]*\([^])]*\).*$,ac_libname="\1",; p;
971 /AC_CONFIG_AUX_DIR/ {
972 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,ac_auxdir="\1",; p;
974 /A[CM]_PROG_LIBTOOL/ { s,^.*$,seen_libtool=:,; p; };
975 /LT_INIT/ { s,^.*$,seen_libtool=:,; p; };
976 /gl_LGPL/ { s,^.*$,lgpl=true,; p; };
978 eval `cat $configure_ac | sed "$my_sed_traces"`
981 if test -z "$supplied_libname" && test -n "$ac_libname"; then
982 libname="$ac_libname"
985 # Set up source base.
986 test -z "$sourcebase" && sourcebase="$ac_sourcebase"
987 test -z "$sourcebase" && sourcebase="lib"
988 test -d "$destdir/$sourcebase" \
989 || (test -z "$dry_run" && mkdir "$destdir/$sourcebase") \
990 || func_fatal_error "source base $destdir/$sourcebase doesn't exist"
993 test -z "$m4base" && m4base="$ac_m4base"
994 test -z "$m4base" && m4base="m4"
995 test -d "$destdir/$m4base" \
996 || (test -z "$dry_run" && mkdir "$destdir/$m4base") \
997 || func_fatal_error "m4 base $destdir/$m4base doesn't exist"
999 # Set up auxiliary directory.
1000 test -z "$auxdir" && auxdir="$ac_auxdir"
1001 test -z "$auxdir" && auxdir="build-aux"
1002 test -d "$destdir/$auxdir" \
1003 || (test -z "$dry_run" && mkdir "$destdir/$auxdir") \
1004 || func_fatal_error "aux directory $destdir/$auxdir doesn't exist"
1007 if test -n "$seen_libtool"; then
1011 # What modules to extract.
1012 if test $# = 0; then
1013 modules="$ac_modules"
1018 # Which modules to avoid?
1019 avoidlist="$avoidlist $ac_avoidlist"
1021 func_import "$modules"
1025 if test -z "$destdir"; then
1026 func_fatal_error "please specify --dir option"
1029 test -d "$destdir" \
1030 || func_fatal_error "could not create destination directory"
1031 func_create_testdir "$destdir" "$*"
1034 create-megatestdir )
1035 if test -z "$destdir"; then
1036 func_fatal_error "please specify --dir option"
1038 mkdir "$destdir" || func_fatal_error "could not create destination directory"
1039 func_create_megatestdir "$destdir" "$*"
1043 test -n "$destdir" || destdir=testdir$$
1044 mkdir "$destdir" || func_fatal_error "could not create destination directory"
1045 func_create_testdir "$destdir" "$*"
1053 remaining=`find . -type f -print`
1054 if test -n "$remaining"; then
1055 echo "Remaining files:" $remaining 1>&2
1056 echo "gnulib-tool: *** Stop." 1>&2
1065 test -n "$destdir" || destdir=testdir$$
1066 mkdir "$destdir" || func_fatal_error "could not create destination directory"
1067 func_create_megatestdir "$destdir" "$*"
1075 remaining=`find . -type f -print`
1076 if test -n "$remaining"; then
1077 echo "Remaining files:" $remaining 1>&2
1078 echo "gnulib-tool: *** Stop." 1>&2
1086 extract-description )
1090 if test -n "$module"; then
1091 func_get_description "$module"
1100 if test -n "$module"; then
1101 func_get_filelist "$module"
1106 extract-dependencies )
1110 if test -n "$module"; then
1111 func_get_dependencies "$module"
1116 extract-autoconf-snippet )
1120 if test -n "$module"; then
1121 func_get_autoconf_snippet "$module"
1126 extract-automake-snippet )
1130 if test -n "$module"; then
1131 func_get_automake_snippet "$module"
1136 extract-include-directive )
1140 if test -n "$module"; then
1141 func_get_include_directive "$module"
1150 if test -n "$module"; then
1151 func_get_license "$module"
1156 extract-maintainer )
1160 if test -n "$module"; then
1161 func_get_maintainer "$module"
1167 func_fatal_error "unknown operation mode --$mode" ;;