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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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-03-04 19:28:13 $'
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 --lgpl Abort if modules aren't available under the LGPL.
92 Also modify license template from GPL to LGPL.
93 --libtool Use libtool rules, for --import.
94 --no-changelog don't update or create ChangeLog files
95 --dry-run For --import, only print what would have been done.
97 Report bugs to <bug-gnulib@gnu.org>."
101 # outputs to stdout the --version message.
104 echo "$progname (GNU $package) $version"
105 echo "Copyright (C) 2002 Free Software Foundation, Inc.
106 This is free software; see the source for copying conditions. There is NO
107 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
108 echo "Written by" "Bruno Haible"
111 # func_fatal_error message
112 # outputs to stderr a fatal error message, and terminates the program.
115 echo "gnulib-tool: *** $1" 1>&2
116 echo "gnulib-tool: *** Stop." 1>&2
120 # func_cp_if_changed SRC DEST
122 # cp, but avoid munging timestamps if the file hasn't changed.
123 func_cp_if_changed ()
125 if test $# -ne 2; then
126 echo "usage: cp_if_changed SRC DEST" >&2
128 test -n "$dry_run" && dry=echo
129 if cmp "$1" "$2" >/dev/null 2>&1; then :; else
134 # func_mv_if_changed SRC DEST
136 # mv, but avoid munging timestamps if the file hasn't changed.
137 # Remove the source file if it is not renamed.
138 func_mv_if_changed ()
140 if test $# -ne 2; then
141 echo "usage: mv_if_changed SRC DEST" >&2
143 test -n "$dry_run" && dry=echo
144 if cmp "$1" "$2" >/dev/null 2>&1; then
151 # Command-line option processing.
152 # Removes the OPTIONS from the arguments. Sets the variables:
153 # - mode list or import or create-testdir or create-megatestdir
154 # - destdir from --dir
155 # - libname, supplied_libname from --lib
156 # - sourcebase from --source-base
157 # - m4base from --m4-base
158 # - libtool true if --libtool was given, blank otherwise
159 # - lgpl true if --lgpl was given, blank otherwise
160 # - do_changelog false if --no-changelog was given, : otherwise
161 # - dry_run true if --dry-run was given, blank otherwise
177 while test $# -gt 0; do
182 --import | --impor | --impo | --imp | --im | --i )
185 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
188 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
189 mode=create-megatestdir
191 --test | --tes | --te | --t )
194 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
198 mode=`echo "X$1" | sed -e 's/^X--//'`
203 func_fatal_error "missing argument for --dir"
208 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
213 func_fatal_error "missing argument for --lib"
216 supplied_libname=true
219 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
220 supplied_libname=true
225 func_fatal_error "missing argument for --source-base"
230 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
235 func_fatal_error "missing argument for --m4-base"
240 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
248 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
254 --help | --hel | --he | --h )
257 --version | --versio | --versi | --vers | --ver | --ve | --v )
261 # Stop option prcessing
265 echo "gnulib-tool: unknown option $1" 1>&2
266 echo "Try 'gnulib-tool --help' for more information." 1>&2
275 /*) self_abspathname="$0" ;;
276 */*) self_abspathname=`pwd`/"$0" ;;
277 *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
278 if test -x "$d/$0" && test ! -d "$d/$0"; then
279 self_abspathname="$d/$0"
283 if test -z "$self_abspathname"; then
284 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
288 while test -h "$self_abspathname"; do
289 # Resolve symbolic link.
290 sedexpr1='s, -> ,#%%#,'
291 sedexpr2='s,^.*#%%#\(.*\)$,\1,p'
292 linkval=`LC_ALL=C ls -l "$self_abspathname" | sed -e "$sedexpr1" | sed -n -e "$sedexpr2"`
293 test -n "$linkval" || break
295 /* ) self_abspathname="$linkval" ;;
296 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
299 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
304 (cd "$gnulib_dir/modules" && ls -1) \
305 | sed -e '/^CVS$/d' -e '/^ChangeLog$/d' -e '/^README$/d' -e '/^TEMPLATE$/d' -e '/~$/d' \
310 # verifies a module name
311 func_verify_module ()
313 if test ! -f "$gnulib_dir/modules/$module" \
314 || test "CVS" = "$module" \
315 || test "ChangeLog" = "$module" \
316 || test "README" = "$module" \
317 || test "TEMPLATE" = "$module"; then
318 echo "gnulib-tool: module $module doesn't exist" 1>&2
323 sed_extract_prog=':[ ]*$/ {
326 s/^Description:[ ]*$//
328 s/^Depends-on:[ ]*$//
329 s/^configure\.ac:[ ]*$//
330 s/^Makefile\.am:[ ]*$//
333 s/^Maintainer:[ ]*$//
340 # func_get_description module
341 func_get_description ()
343 sed -n -e "/^Description$sed_extract_prog" < "$gnulib_dir/modules/$1"
346 # func_get_filelist module
349 sed -n -e "/^Files$sed_extract_prog" < "$gnulib_dir/modules/$1"
351 echo m4/onceonly_2_57.m4
354 # func_get_dependencies module
355 func_get_dependencies ()
357 sed -n -e "/^Depends-on$sed_extract_prog" < "$gnulib_dir/modules/$1"
360 # func_get_autoconf_snippet module
361 func_get_autoconf_snippet ()
363 sed -n -e "/^configure\.ac$sed_extract_prog" < "$gnulib_dir/modules/$1"
366 # func_get_automake_snippet module
367 func_get_automake_snippet ()
369 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$gnulib_dir/modules/$1"
372 # func_get_include_directive module
373 func_get_include_directive ()
375 sed -n -e "/^Include$sed_extract_prog" < "$gnulib_dir/modules/$1" | \
376 sed -e 's/^\(["<]\)/#include \1/'
379 # func_get_license module
382 sed -n -e "/^License$sed_extract_prog" < "$gnulib_dir/modules/$1"
385 # func_get_maintainer module
386 func_get_maintainer ()
388 sed -n -e "/^Maintainer$sed_extract_prog" < "$gnulib_dir/modules/$1"
391 # func_modules_transitive_closure
393 # - modules list of specified modules
395 # - modules list of modules, including dependencies
396 func_modules_transitive_closure ()
400 for module in $modules; do
402 if test -n "$module"; then
403 # Duplicate dependenies are harmless, but Jim wants a warning.
404 duplicated_deps=`func_get_dependencies $module | sort | uniq -d`
405 if test -n "$duplicated_deps"; then
406 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
408 xmodules="$xmodules $module "`func_get_dependencies $module`
411 xmodules=`for m in $xmodules; do echo $m; done | sort | uniq`
412 if test "$xmodules" = "$modules"; then
419 # func_modules_to_filelist
421 # - modules list of modules, including dependencies
423 # - files list of files
424 func_modules_to_filelist ()
427 for module in $modules; do
429 if test -n "$module"; then
430 files="$files "`func_get_filelist $module`
433 files=`for f in $files; do echo $f; done | sort | uniq`
436 # func_emit_lib_Makefile_am
437 # emits the contents of lib/Makefile.am to standard output.
439 # - modules list of modules, including dependencies
440 # - libname library name
441 # - libtool true if libtool will be used, blank otherwise
442 # - cmd (optional) command that led to this invocation
443 # - actioncmd (optional) command that will reproduce this invocation
444 func_emit_lib_Makefile_am ()
446 if test -n "$libtool"; then
453 echo "## Process this file with automake to produce Makefile.in."
454 echo "# Copyright (C) 2004 Free Software Foundation, Inc."
456 echo "# This file is free software, distributed under the terms of the GNU"
457 echo "# General Public License. As a special exception to the GNU General"
458 echo "# Public License, this file may be distributed as part of a program"
459 echo "# that contains a configuration script generated by Automake, under"
460 echo "# the same distribution terms as the rest of that program."
462 echo "# Generated by gnulib-tool."
463 if test -n "$cmd"; then
464 echo "# Invoked as: $cmd"
466 if test -n "$actioncmd"; then
467 echo "# Reproduce by: $actioncmd"
470 # No need to generate dependencies since the sources are in gnulib, not here.
471 echo "AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies"
473 echo "noinst_${perhapsLT}LIBRARIES = $libname.$libext"
475 echo "${libname}_${libext}_SOURCES ="
476 echo "${libname}_${libext}_LIBADD = @${perhapsLT}LIBOBJS@"
478 echo "BUILT_SOURCES ="
480 echo "MOSTLYCLEANFILES ="
482 echo "DISTCLEANFILES ="
483 echo "MAINTAINERCLEANFILES ="
485 for module in $modules; do
487 if test -n "$module"; then
489 func_get_automake_snippet "$module" |
490 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
491 if test "$module" = 'alloca'; then
492 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
495 # Skip the contents if its entirely empty.
496 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
497 echo "## begin gnulib module $module"
500 echo "## end gnulib module $module"
507 echo "# Makefile.am ends here"
510 # func_import modules
511 # Uses also the variables
512 # - destdir target directory
513 # - libname library name
514 # - sourcebase directory relative to destdir where to place source code
515 # - m4base directory relative to destdir where to place *.m4 macros
516 # - libtool true if libtool will be used, blank otherwise
517 # - lgpl true if library's license shall be LGPL, blank otherwise
518 # - dry_run true if actions shall only be printed, blank otherwise
519 # - supplied_opts all options passed to gnulib-tool
523 modules=`for m in $modules; do echo $m; done | sort | uniq`
525 # Determine final module list.
526 func_modules_transitive_closure
527 echo "Module list with included dependencies:"
528 echo "$modules" | sed -e 's/^/ /'
530 # If --lgpl, check the license of modules are compatible.
531 if test -n "$lgpl"; then
532 for module in $modules; do
533 license=`func_get_license $module`
534 if test $license != LGPL; then
535 func_fatal_error "incompatible license on module \`$module\`: $license"
540 # Determine final file list.
541 func_modules_to_filelist
543 echo "$files" | sed -e 's/^/ /'
546 || func_fatal_error "refusing to do nothing"
552 config/*) g=`echo "$f" | sed -e 's,^config/,,'` ;;
553 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"`; source=true ;;
554 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
557 func_cp_if_changed "$gnulib_dir/$f" "$destdir/$g"
559 if test -z "$dry_run" && test -n "$lgpl" && test -n "$source"; then
560 perl -pi -e 's/GNU General/GNU Lesser General/g;' \
561 -e 's/version 2([ ,])/version 2.1\1/g' \
566 # Commands printed in a comment in generated files.
567 cmd="gnulib-tool $supplied_opts"
569 if test -n "$libtool"; then
570 opt_libtool="--libtool"
573 if test -n "$lgpl"; then
576 actioncmd="gnulib-tool --import --dir=$destdir --lib=$libname --source-base=$sourcebase --m4-base=$m4base $opt_libtool $opt_lgpl `echo $modules`"
578 # Create lib/Makefile.am.
579 echo "Creating $destdir/$sourcebase/Makefile.am..."
580 if test -z "$dry_run"; then
581 func_emit_lib_Makefile_am > $destdir/$sourcebase/Makefile.am.new
583 func_emit_lib_Makefile_am
585 func_mv_if_changed $destdir/$sourcebase/Makefile.am.new \
586 $destdir/$sourcebase/Makefile.am
589 echo "Creating $destdir/$m4base/gnulib.m4..."
591 if test -z "$dry_run"; then
592 exec > $destdir/$m4base/gnulib.m4.new
594 echo "# $destdir/$m4base/gnulib.m4"
596 echo "# Copyright (C) 2004 Free Software Foundation, Inc."
597 echo "# This file is free software, distributed under the terms of the GNU"
598 echo "# General Public License. As a special exception to the GNU General"
599 echo "# Public License, this file may be distributed as part of a program"
600 echo "# that contains a configuration script generated by Autoconf, under"
601 echo "# the same distribution terms as the rest of that program."
603 echo "# Generated by gnulib-tool."
605 echo "# Invoked as: $cmd"
606 echo "# Reproduce by: $actioncmd"
608 echo "AC_DEFUN([gl_EARLY],"
610 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 > /dev/null; then
611 echo " AC_GNU_SOURCE"
613 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 > /dev/null; then
614 echo " gl_USE_SYSTEM_EXTENSIONS"
618 echo "AC_DEFUN([gl_INIT],"
620 for module in $modules; do
622 if test -n "$module"; then
623 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./'
624 if test "$module" = 'alloca' && test -n "$libtool"; then
625 echo 'changequote(,)dnl'
626 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
627 echo 'changequote([, ])dnl'
628 echo 'AC_SUBST(LTALLOCA)'
634 echo "dnl Usage: gl_MODULES(module1 module2 ...)"
635 echo "AC_DEFUN([gl_MODULES], [])"
637 echo "dnl Usage: gl_SOURCE_BASE(DIR)"
638 echo "AC_DEFUN([gl_SOURCE_BASE], [])"
640 echo "dnl Usage: gl_M4_BASE(DIR)"
641 echo "AC_DEFUN([gl_M4_BASE], [])"
643 echo "dnl Usage: gl_LIB(LIBNAME)"
644 echo "AC_DEFUN([gl_LIB], [])"
646 echo "dnl Usage: gl_LGPL"
647 echo "AC_DEFUN([gl_LGPL], [])"
649 echo "# gnulib.m4 ends here"
651 func_mv_if_changed $destdir/$m4base/gnulib.m4.new $destdir/$m4base/gnulib.m4
654 echo "You may need to add #include directives for the following .h files."
655 for module in $modules; do
656 func_get_include_directive "$module" | sed -e '/^$/d;' -e 's/^/ /'
659 echo "Don't forget to add \"$sourcebase/Makefile\""
660 echo "to AC_CONFIG_FILES in \"$configure_ac\" and to mention"
661 echo "\"`basename $sourcebase`\" in SUBDIRS in some Makefile.am."
664 # func_create_testdir testdir modules
665 func_create_testdir ()
669 modules=`for m in $modules; do echo $m; done | sort | uniq`
671 # Determine final module list.
672 func_modules_transitive_closure
673 echo "Module list with included dependencies:"
674 echo "$modules" | sed -e 's/^/ /'
676 # Determine final file list.
677 func_modules_to_filelist
679 echo "$files" | sed -e 's/^/ /'
681 # Create directories.
682 for d in `echo "$files" | sed -n -e 's,^\(.*\)/[^/]*,\1,p'`; do
683 if test "$d" != config; then
684 mkdir -p "$testdir/$d"
691 config/*) g=`echo "$f" | sed -e 's,^config/,,'` ;;
694 ln "$gnulib_dir/$f" "$testdir/$g" 2>/dev/null ||
695 cp -p "$gnulib_dir/$f" "$testdir/$g"
698 # Create lib/Makefile.am.
699 mkdir -p "$testdir/lib"
700 func_emit_lib_Makefile_am > "$testdir/lib/Makefile.am"
702 # Create m4/Makefile.am.
703 mkdir -p "$testdir/m4"
704 (echo "## Process this file with automake to produce Makefile.in."
710 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
713 ) > "$testdir/m4/Makefile.am"
717 if test -f "$testdir"/m4/gettext.m4; then
718 # Avoid stupid error message from automake:
719 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
720 mkdir -p "$testdir/po"
721 (echo "## Process this file with automake to produce Makefile.in."
722 ) > "$testdir/po/Makefile.am"
723 subdirs="$subdirs po"
726 # Create Makefile.am.
727 (echo "## Process this file with automake to produce Makefile.in."
729 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
731 echo "SUBDIRS = $subdirs"
733 echo "ACLOCAL_AMFLAGS = -I m4"
734 ) > "$testdir/Makefile.am"
736 # Create configure.ac.
737 (echo "# Process this file with autoconf to produce a configure script."
738 echo "AC_INIT(dummy,0)"
739 echo "AM_INIT_AUTOMAKE"
741 echo "AM_CONFIG_HEADER(config.h)"
744 echo "AC_PROG_INSTALL"
745 echo "AC_PROG_MAKE_SET"
746 echo "AC_PROG_RANLIB"
748 if grep AC_GNU_SOURCE "$testdir"/m4/*.m4 > /dev/null; then
752 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir"/m4/*.m4 > /dev/null; then
753 echo "gl_USE_SYSTEM_EXTENSIONS"
756 for module in $modules; do
758 if test -n "$module"; then
759 func_get_autoconf_snippet "$module"
764 for d in $subdirs; do
765 makefiles="$makefiles $d/Makefile"
767 echo "AC_OUTPUT([$makefiles])"
768 ) > "$testdir/configure.ac"
770 # Create autogenerated files.
772 echo "executing ${AUTORECONF} --force --install"
773 ${AUTORECONF} --force --install
775 if grep '^BUILT_SOURCES *+=' "$testdir/lib/Makefile.am" > /dev/null; then
779 built_sources=`grep '^BUILT_SOURCES *=' Makefile.in | sed -e 's/^BUILT_SOURCES *=//'`
780 if test -n "$built_sources"; then
789 # func_create_megatestdir megatestdir allmodules
790 func_create_megatestdir ()
794 if test -z "$allmodules"; then
795 allmodules=`func_all_modules`
799 # First, all modules one by one.
800 for onemodule in $allmodules; do
801 func_create_testdir "$megatestdir/$onemodule" $onemodule
802 megasubdirs="${megasubdirs}$onemodule "
804 # Then, all modules all together.
805 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
806 allmodules=`for m in $allmodules; do if test $m != fnmatch-posix; then echo $m; fi; done`
807 func_create_testdir "$megatestdir/ALL" "$allmodules"
808 megasubdirs="${megasubdirs}ALL"
810 # Create Makefile.am.
811 (echo "## Process this file with automake to produce Makefile.in."
813 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
815 echo "SUBDIRS = $megasubdirs"
816 ) > "$megatestdir/Makefile.am"
818 # Create configure.ac.
819 (echo "# Process this file with autoconf to produce a configure script."
820 echo "AC_INIT(dummy,0)"
821 echo "AM_INIT_AUTOMAKE"
823 echo "AC_PROG_MAKE_SET"
825 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
826 echo "AC_OUTPUT([Makefile])"
827 ) > "$megatestdir/configure.ac"
829 # Create autogenerated files.
831 echo "executing ${AUTORECONF} --force --install"
832 ${AUTORECONF} --force --install
838 func_fatal_error "no mode specified" ;;
846 if test -z "$destdir"; then
850 || func_fatal_error "destination directory does not exist: $destdir"
852 # Prefer configure.ac to configure.in
853 test -f $destdir/configure.in && configure_ac=$destdir/configure.in
854 test -f $destdir/configure.ac && configure_ac=$destdir/configure.ac
855 test -f "$configure_ac" \
856 || func_fatal_error "cannot find $destdir/configure.ac"
859 my_sed_traces='s,#.*$,,; s,^dnl .*$,,; s, dnl .*$,,;
861 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,ac_modules="\1",; p;
864 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,ac_sourcebase="\1",; p;
867 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,ac_m4base="\1",; p;
870 s,^.*gl_LIB([[ ]*\([^])]*\).*$,ac_libname="\1",; p;
872 /A[CM]_PROG_LIBTOOL/ { s,^.*$,seen_libtool=:,; p; };
873 /LT_INIT/ { s,^.*$,seen_libtool=:,; p; };
874 /gl_LGPL/ { s,^.*$,lgpl=true,; p; };
876 eval `cat $configure_ac | sed "$my_sed_traces"`
879 if test -z "$supplied_libname" && test -n "$ac_libname"; then
880 libname="$ac_libname"
883 # Set up source base.
884 test -z "$sourcebase" && sourcebase="$ac_sourcebase"
885 test -z "$sourcebase" && sourcebase="lib"
886 test -d "$destdir/$sourcebase" \
887 || (test -z "$dry_run" && mkdir "$destdir/$sourcebase") \
888 || func_fatal_error "source base $destdir/$sourcebase doesn't exist"
891 test -z "$m4base" && m4base="$ac_m4base"
892 test -z "$m4base" && m4base="m4"
893 test -d "$destdir/$m4base" \
894 || (test -z "$dry_run" && mkdir "$destdir/$m4base") \
895 || func_fatal_error "m4 base $destdir/$m4base doesn't exist"
898 if test -n "$seen_libtool"; then
902 # What modules to extract.
904 modules="$ac_modules"
909 func_import "$modules"
913 if test -z "$destdir"; then
914 func_fatal_error "please specify --dir option"
918 || func_fatal_error "could not create destination directory"
919 func_create_testdir "$destdir" "$*"
923 if test -z "$destdir"; then
924 func_fatal_error "please specify --dir option"
926 mkdir "$destdir" || func_fatal_error "could not create destination directory"
927 func_create_megatestdir "$destdir" "$*"
931 test -n "$destdir" || destdir=testdir$$
932 mkdir "$destdir" || func_fatal_error "could not create destination directory"
933 func_create_testdir "$destdir" "$*"
941 remaining=`find . -type f -print`
942 if test -n "$remaining"; then
943 echo "Remaining files:" $remaining 1>&2
944 echo "gnulib-tool: *** Stop." 1>&2
953 test -n "$destdir" || destdir=testdir$$
954 mkdir "$destdir" || func_fatal_error "could not create destination directory"
955 func_create_megatestdir "$destdir" "$*"
963 remaining=`find . -type f -print`
964 if test -n "$remaining"; then
965 echo "Remaining files:" $remaining 1>&2
966 echo "gnulib-tool: *** Stop." 1>&2
974 extract-description )
978 if test -n "$module"; then
979 func_get_description "$module"
988 if test -n "$module"; then
989 func_get_filelist "$module"
994 extract-dependencies )
998 if test -n "$module"; then
999 func_get_dependencies "$module"
1004 extract-autoconf-snippet )
1008 if test -n "$module"; then
1009 func_get_autoconf_snippet "$module"
1014 extract-automake-snippet )
1018 if test -n "$module"; then
1019 func_get_automake_snippet "$module"
1024 extract-include-directive )
1028 if test -n "$module"; then
1029 func_get_include_directive "$module"
1038 if test -n "$module"; then
1039 func_get_license "$module"
1044 extract-maintainer )
1048 if test -n "$module"; then
1049 func_get_maintainer "$module"
1055 func_fatal_error "unknown operation mode --$mode" ;;