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-29 20:03:02 $'
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
59 gnulib-tool --extract-tests-module module
62 --list print the available module names
63 --import import the given modules into the current package
64 --create-testdir create a scratch package with the given modules
65 --create-megatestdir create a mega scratch package with the given modules
66 one by one and all together
67 --test test the combination of the given modules
68 (recommended to use CC=\"gcc -Wall\" here)
69 --megatest test the given modules one by one and all together
70 (recommended to use CC=\"gcc -Wall\" here)
71 --extract-description extract the description
72 --extract-filelist extract the list of files
73 --extract-dependencies extract the dependencies
74 --extract-autoconf-snippet extract the snippet for configure.ac
75 --extract-automake-snippet extract the snippet for lib/Makefile.am
76 --extract-include-directive extract the #include directive
77 --extract-license report the license terms of the source files
79 --extract-maintainer report the maintainer(s) inside gnulib
80 --extract-tests-module report the unit test module, if it exists
83 --dir=DIRECTORY specify the target directory
84 For --import, this specifies where your
85 configure.ac can be found. Defaults to current
87 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
88 --source-base=DIRECTORY
89 Directory relative --dir where source code is
90 placed (default \"lib\"), for --import.
91 --m4-base=DIRECTORY Directory relative --dir where *.m4 macros are
92 placed (default \"m4\"), for --import.
93 --tests-base=DIRECTORY
94 Directory relative --dir where unit tests are
95 placed (default \"tests\"), for --import.
96 --aux-dir=DIRECTORY Directory relative --dir where auxiliary build
97 tools are placed (default \"build-aux\").
98 --with-tests Include unit tests for the included modules.
99 --avoid=MODULE Avoid including the given MODULE. Useful if you
100 have code that provides equivalent functionality.
101 This option can be repeated.
102 --lgpl Abort if modules aren't available under the LGPL.
103 Also modify license template from GPL to LGPL.
104 --libtool Use libtool rules, for --import.
105 --no-changelog don't update or create ChangeLog files
106 --dry-run For --import, only print what would have been done.
107 -s, --symbolic, --symlink Make symbolic links instead of copying files.
109 Report bugs to <bug-gnulib@gnu.org>."
113 # outputs to stdout the --version message.
116 echo "$progname (GNU $package) $version"
117 echo "Copyright (C) 2002-2005 Free Software Foundation, Inc.
118 This is free software; see the source for copying conditions. There is NO
119 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
120 echo "Written by" "Bruno Haible" "and" "Simon Josefsson"
123 # func_fatal_error message
124 # outputs to stderr a fatal error message, and terminates the program.
127 echo "gnulib-tool: *** $1" 1>&2
128 echo "gnulib-tool: *** Stop." 1>&2
132 # func_cp_if_changed SRC DEST
133 # Like cp, but avoids munging timestamps if the file hasn't changed.
134 # Uses also the variables
135 # - dry_run true if actions shall only be printed, blank otherwise
136 func_cp_if_changed ()
138 if test $# -ne 2; then
139 echo "usage: func_cp_if_changed SRC DEST" >&2
141 test -n "$dry_run" && dry=echo
142 if cmp "$1" "$2" >/dev/null 2>&1; then
149 # func_mv_if_changed SRC DEST
150 # Like mv, but avoids munging timestamps if the file hasn't changed.
151 # Removes SRC if it is not renamed.
152 # Uses also the variables
153 # - dry_run true if actions shall only be printed, blank otherwise
154 func_mv_if_changed ()
156 if test $# -ne 2; then
157 echo "usage: func_mv_if_changed SRC DEST" >&2
159 test -n "$dry_run" && dry=echo
160 if cmp "$1" "$2" >/dev/null 2>&1; then
167 # func_ln_if_changed SRC DEST
168 # Like ln -s, but avoids munging timestamps if the link is correct.
169 # Uses also the variables
170 # - dry_run true if actions shall only be printed, blank otherwise
171 func_ln_if_changed ()
173 if test $# -ne 2; then
174 echo "usage: func_ln_if_changed SRC DEST" >&2
176 test -n "$dry_run" && dry=echo
177 if test -L "$2" -a "$1" = "`readlink "$2"`"; then
185 # Command-line option processing.
186 # Removes the OPTIONS from the arguments. Sets the variables:
187 # - mode list or import or create-testdir or create-megatestdir
188 # - destdir from --dir
189 # - libname, supplied_libname from --lib
190 # - sourcebase from --source-base
191 # - m4base from --m4-base
192 # - testsbase from --tests-base
193 # - auxdir from --aux-dir
194 # - inctests true if --with-tests was given, blank otherwise
195 # - avoidlist list of modules to avoid, from --avoid
196 # - lgpl true if --lgpl was given, blank otherwise
197 # - libtool true if --libtool was given, blank otherwise
198 # - do_changelog false if --no-changelog was given, : otherwise
199 # - dry_run true if --dry-run was given, blank otherwise
219 while test $# -gt 0; do
224 --import | --impor | --impo | --imp | --im | --i )
227 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
230 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
231 mode=create-megatestdir
233 --test | --tes | --te | --t )
236 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
240 mode=`echo "X$1" | sed -e 's/^X--//'`
245 func_fatal_error "missing argument for --dir"
250 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
255 func_fatal_error "missing argument for --lib"
258 supplied_libname=true
261 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
262 supplied_libname=true
267 func_fatal_error "missing argument for --source-base"
272 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
277 func_fatal_error "missing argument for --m4-base"
282 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
287 func_fatal_error "missing argument for --tests-base"
292 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
297 func_fatal_error "missing argument for --aux-dir"
302 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
310 func_fatal_error "missing argument for --avoid"
312 avoidlist="$avoidlist $1"
315 avoidlist="$avoidlist "`echo "X$1" | sed -e 's/^X--avoid=//'`
323 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
329 -s | --symbolic | --symlink )
332 --help | --hel | --he | --h )
335 --version | --versio | --versi | --vers | --ver | --ve | --v )
339 # Stop option prcessing
343 echo "gnulib-tool: unknown option $1" 1>&2
344 echo "Try 'gnulib-tool --help' for more information." 1>&2
353 /*) self_abspathname="$0" ;;
354 */*) self_abspathname=`pwd`/"$0" ;;
355 *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
356 if test -x "$d/$0" && test ! -d "$d/$0"; then
357 self_abspathname="$d/$0"
361 if test -z "$self_abspathname"; then
362 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
366 while test -h "$self_abspathname"; do
367 # Resolve symbolic link.
368 sedexpr1='s, -> ,#%%#,'
369 sedexpr2='s,^.*#%%#\(.*\)$,\1,p'
370 linkval=`LC_ALL=C ls -l "$self_abspathname" | sed -e "$sedexpr1" | sed -n -e "$sedexpr2"`
371 test -n "$linkval" || break
373 /* ) self_abspathname="$linkval" ;;
374 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
377 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
382 # Filter out metainformation files like README, which are not modules.
383 # Filter out unit test modules; they can be retrieved through
384 # --extract-tests-module if desired.
385 (cd "$gnulib_dir/modules" && ls -1) \
386 | sed -e '/^CVS$/d' -e '/^ChangeLog$/d' -e '/^README$/d' -e '/^TEMPLATE$/d' -e '/^TEMPLATE-TESTS$/d' -e '/~$/d' \
387 | sed -e '/-tests$/d' \
392 # verifies a module name
393 func_verify_module ()
395 if test ! -f "$gnulib_dir/modules/$module" \
396 || test "CVS" = "$module" \
397 || test "ChangeLog" = "$module" \
398 || test "README" = "$module" \
399 || test "TEMPLATE" = "$module" \
400 || test "TEMPLATE-TESTS" = "$module"; then
401 echo "gnulib-tool: module $module doesn't exist" 1>&2
406 # func_verify_nontests_module
407 # verifies a module name, excluding tests modules
408 func_verify_nontests_module ()
412 * ) func_verify_module ;;
416 # func_verify_tests_module
417 # verifies a module name, considering only tests modules
418 func_verify_tests_module ()
421 *-tests ) func_verify_module ;;
426 sed_extract_prog=':[ ]*$/ {
429 s/^Description:[ ]*$//
431 s/^Depends-on:[ ]*$//
432 s/^configure\.ac:[ ]*$//
433 s/^Makefile\.am:[ ]*$//
436 s/^Maintainer:[ ]*$//
443 # func_get_description module
444 func_get_description ()
446 sed -n -e "/^Description$sed_extract_prog" < "$gnulib_dir/modules/$1"
449 # func_get_filelist module
452 sed -n -e "/^Files$sed_extract_prog" < "$gnulib_dir/modules/$1"
454 echo m4/onceonly_2_57.m4
457 # func_get_dependencies module
458 func_get_dependencies ()
460 # ${module}-tests always implicitly depends on ${module}.
461 echo "$1" | sed -n -e 's/-tests//p'
462 # Then the explicit dependencies listed in the module description.
463 sed -n -e "/^Depends-on$sed_extract_prog" < "$gnulib_dir/modules/$1"
466 # func_get_autoconf_snippet module
467 func_get_autoconf_snippet ()
469 sed -n -e "/^configure\.ac$sed_extract_prog" < "$gnulib_dir/modules/$1"
472 # func_get_automake_snippet module
473 func_get_automake_snippet ()
475 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$gnulib_dir/modules/$1"
478 # func_get_include_directive module
479 func_get_include_directive ()
481 sed -n -e "/^Include$sed_extract_prog" < "$gnulib_dir/modules/$1" | \
482 sed -e 's/^\(["<]\)/#include \1/'
485 # func_get_license module
488 sed -n -e "/^License$sed_extract_prog" < "$gnulib_dir/modules/$1"
491 # func_get_maintainer module
492 func_get_maintainer ()
494 sed -n -e "/^Maintainer$sed_extract_prog" < "$gnulib_dir/modules/$1"
497 # func_get_tests_module module
498 func_get_tests_module ()
500 # The naming convention for tests modules is hardwired: ${module}-tests.
501 if test -f modules/"$1"-tests; then
506 # func_acceptable module
507 # tests whether a module is acceptable.
509 # - avoidlist list of modules to avoid
512 for avoid in $avoidlist; do
513 if test "$avoid" = "$1"; then
520 # func_modules_transitive_closure
522 # - modules list of specified modules
523 # - inctests true if tests should be included, blank otherwise
524 # - avoidlist list of modules to avoid
526 # - modules list of modules, including dependencies
527 func_modules_transitive_closure ()
531 for module in $modules; do
533 if test -n "$module"; then
534 # Duplicate dependencies are harmless, but Jim wants a warning.
535 duplicated_deps=`func_get_dependencies $module | sort | uniq -d`
536 if test -n "$duplicated_deps"; then
537 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
539 if func_acceptable $module; then
540 xmodules="$xmodules $module"
541 for depmodule in `func_get_dependencies $module`; do
542 if func_acceptable $depmodule; then
543 xmodules="$xmodules $depmodule"
546 if test -n "$inctests"; then
547 testsmodule=`func_get_tests_module $module`
548 if test -n "$testsmodule"; then
549 if func_acceptable $testsmodule; then
550 xmodules="$xmodules $testsmodule"
551 for depmodule in `func_get_dependencies $testsmodule`; do
552 if func_acceptable $depmodule; then
553 xmodules="$xmodules $depmodule"
562 xmodules=`for m in $xmodules; do echo $m; done | sort | uniq`
563 if test "$xmodules" = "$modules"; then
570 # func_modules_to_filelist
572 # - modules list of modules, including dependencies
574 # - files list of files
575 func_modules_to_filelist ()
578 for module in $modules; do
580 if test -n "$module"; then
581 files="$files "`func_get_filelist $module`
584 files=`for f in $files; do echo $f; done | sort | uniq`
587 # func_emit_lib_Makefile_am
588 # emits the contents of lib/Makefile.am to standard output.
590 # - modules list of modules, including dependencies
591 # - libname library name
592 # - libtool true if libtool will be used, blank otherwise
593 # - cmd (optional) command that led to this invocation
594 # - actioncmd (optional) command that will reproduce this invocation
595 func_emit_lib_Makefile_am ()
597 if test -n "$libtool"; then
604 echo "## Process this file with automake to produce Makefile.in."
605 echo "# Copyright (C) 2004 Free Software Foundation, Inc."
607 echo "# This file is free software, distributed under the terms of the GNU"
608 echo "# General Public License. As a special exception to the GNU General"
609 echo "# Public License, this file may be distributed as part of a program"
610 echo "# that contains a configuration script generated by Automake, under"
611 echo "# the same distribution terms as the rest of that program."
613 echo "# Generated by gnulib-tool."
614 if test -n "$cmd"; then
615 echo "# Invoked as: $cmd"
617 if test -n "$actioncmd"; then
618 echo "# Reproduce by: $actioncmd"
621 # No need to generate dependencies since the sources are in gnulib, not here.
622 echo "AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies"
624 echo "noinst_${perhapsLT}LIBRARIES = $libname.$libext"
626 echo "${libname}_${libext}_SOURCES ="
627 echo "${libname}_${libext}_LIBADD = @${perhapsLT}LIBOBJS@"
629 echo "BUILT_SOURCES ="
631 echo "MOSTLYCLEANFILES ="
633 echo "DISTCLEANFILES ="
634 echo "MAINTAINERCLEANFILES ="
636 for module in $modules; do
637 func_verify_nontests_module
638 if test -n "$module"; then
640 func_get_automake_snippet "$module" |
641 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
642 if test "$module" = 'alloca'; then
643 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
646 # Skip the contents if its entirely empty.
647 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
648 echo "## begin gnulib module $module"
651 echo "## end gnulib module $module"
658 echo "# Makefile.am ends here"
661 # func_emit_tests_Makefile_am
662 # emits the contents of tests/Makefile.am to standard output.
664 # - modules list of modules, including dependencies
665 # - libname library name
666 # - libtool true if libtool will be used, blank otherwise
667 # - sourcebase relative directory containing lib source code
668 func_emit_tests_Makefile_am ()
670 if test -n "$libtool"; then
675 echo "## Process this file with automake to produce Makefile.in."
676 echo "# Copyright (C) 2004-2005 Free Software Foundation, Inc."
678 echo "# This file is free software, distributed under the terms of the GNU"
679 echo "# General Public License. As a special exception to the GNU General"
680 echo "# Public License, this file may be distributed as part of a program"
681 echo "# that contains a configuration script generated by Automake, under"
682 echo "# the same distribution terms as the rest of that program."
684 echo "# Generated by gnulib-tool."
686 # Generate dependencies here, since it eases the debugging of test failures.
687 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
689 echo "ACLOCAL_AMFLAGS = -I ../m4"
692 echo "noinst_PROGRAMS ="
694 echo "BUILT_SOURCES ="
696 echo "MOSTLYCLEANFILES ="
698 echo "DISTCLEANFILES ="
699 echo "MAINTAINERCLEANFILES ="
701 echo "AM_CPPFLAGS = \\"
702 echo " -I. -I\$(srcdir) \\"
703 echo " -I.. -I\$(srcdir)/.. \\"
704 echo " -I../${sourcebase-lib} -I\$(srcdir)/../${sourcebase-lib}"
706 echo "LDADD = ../${sourcebase-lib}/${libname}.${libext}"
708 for module in $modules; do
709 func_verify_tests_module
710 if test -n "$module"; then
711 func_get_automake_snippet "$module" > amsnippet.tmp
712 # Skip the contents if its entirely empty.
713 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
714 echo "## begin gnulib module $module"
717 echo "## end gnulib module $module"
723 echo "# Clean up after Solaris cc."
725 echo " rm -rf SunWS_cache"
727 echo "# Makefile.am ends here"
730 # func_import modules
731 # Uses also the variables
732 # - destdir target directory
733 # - libname library name
734 # - sourcebase directory relative to destdir where to place source code
735 # - m4base directory relative to destdir where to place *.m4 macros
736 # - auxdir directory relative to destdir where to place build aux files
737 # - avoidlist list of modules to avoid, from --avoid
738 # - lgpl true if library's license shall be LGPL, blank otherwise
739 # - libtool true if libtool will be used, blank otherwise
740 # - dry_run true if actions shall only be printed, blank otherwise
741 # - symbolic true if files should be symlinked, copied otherwise
742 # - supplied_opts all options passed to gnulib-tool
746 modules=`for m in $modules; do echo $m; done | sort | uniq`
748 # Determine final module list.
749 func_modules_transitive_closure
750 echo "Module list with included dependencies:"
751 echo "$modules" | sed -e 's/^/ /'
753 # If --lgpl, check the license of modules are compatible.
754 if test -n "$lgpl"; then
755 for module in $modules; do
756 license=`func_get_license $module`
758 LGPL | 'public domain' | 'unlimited') ;;
761 "incompatible license on module \`$module\`: $license" ;;
766 # Determine final file list.
767 func_modules_to_filelist
769 echo "$files" | sed -e 's/^/ /'
772 || func_fatal_error "refusing to do nothing"
774 # Copy files or make symbolic links.
778 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
779 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"`; source=true ;;
780 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
783 if test -z "$symbolic"; then
784 func_cp_if_changed "$gnulib_dir/$f" "$destdir/$g"
786 func_ln_if_changed "$gnulib_dir/$f" "$destdir/$g"
789 if test -z "$dry_run" && test -n "$lgpl" && test -n "$source"; then
790 perl -pi -e 's/GNU General/GNU Lesser General/g;' \
791 -e 's/version 2([ ,])/version 2.1\1/g' \
796 # Commands printed in a comment in generated files.
797 cmd="gnulib-tool $supplied_opts"
799 if test -n "$libtool"; then
800 opt_libtool="--libtool"
803 if test -n "$lgpl"; then
806 actioncmd="gnulib-tool --import --dir=$destdir --lib=$libname --source-base=$sourcebase --m4-base=$m4base --aux-dir=$auxdir $opt_libtool $opt_lgpl `echo $modules`"
808 # Create lib/Makefile.am.
809 echo "Creating $destdir/$sourcebase/Makefile.am..."
810 if test -z "$dry_run"; then
811 func_emit_lib_Makefile_am > "$destdir"/$sourcebase/Makefile.am.new
813 func_emit_lib_Makefile_am
815 func_mv_if_changed "$destdir"/$sourcebase/Makefile.am.new \
816 "$destdir"/$sourcebase/Makefile.am
819 echo "Creating $destdir/$m4base/gnulib.m4..."
821 if test -z "$dry_run"; then
822 exec > "$destdir"/$m4base/gnulib.m4.new
824 echo "# $destdir/$m4base/gnulib.m4"
826 echo "# Copyright (C) 2004 Free Software Foundation, Inc."
827 echo "# This file is free software, distributed under the terms of the GNU"
828 echo "# General Public License. As a special exception to the GNU General"
829 echo "# Public License, this file may be distributed as part of a program"
830 echo "# that contains a configuration script generated by Autoconf, under"
831 echo "# the same distribution terms as the rest of that program."
833 echo "# Generated by gnulib-tool."
835 echo "# Invoked as: $cmd"
836 echo "# Reproduce by: $actioncmd"
838 echo "# This macro should be invoked from $configure_ac, in the section"
839 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
840 echo "# any checks for libraries, header files, types and library functions."
841 echo "AC_DEFUN([gl_EARLY],"
843 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 > /dev/null; then
844 echo " AC_GNU_SOURCE"
846 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 > /dev/null; then
847 echo " gl_USE_SYSTEM_EXTENSIONS"
851 echo "# This macro should be invoked from $configure_ac, in the section"
852 echo "# \"Check for header files, types and library functions\"."
853 echo "AC_DEFUN([gl_INIT],"
855 for module in $modules; do
857 if test -n "$module"; then
858 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./'
859 if test "$module" = 'alloca' && test -n "$libtool"; then
860 echo 'changequote(,)dnl'
861 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
862 echo 'changequote([, ])dnl'
863 echo 'AC_SUBST([LTALLOCA])'
869 echo "dnl Usage: gl_MODULES([module1 module2 ...])"
870 echo "AC_DEFUN([gl_MODULES], [])"
872 echo "dnl Usage: gl_AVOID([module1 module2 ...])"
873 echo "AC_DEFUN([gl_AVOID], [])"
875 echo "dnl Usage: gl_SOURCE_BASE([DIR])"
876 echo "AC_DEFUN([gl_SOURCE_BASE], [])"
878 echo "dnl Usage: gl_M4_BASE([DIR])"
879 echo "AC_DEFUN([gl_M4_BASE], [])"
881 echo "dnl Usage: gl_LIB([LIBNAME])"
882 echo "AC_DEFUN([gl_LIB], [])"
884 echo "dnl Usage: gl_LGPL"
885 echo "AC_DEFUN([gl_LGPL], [])"
887 echo "# gnulib.m4 ends here"
889 func_mv_if_changed "$destdir"/$m4base/gnulib.m4.new "$destdir"/$m4base/gnulib.m4
892 echo "You may need to add #include directives for the following .h files."
893 for module in $modules; do
894 func_get_include_directive "$module"
895 done | LC_ALL=C sort -u | sed -e '/^$/d;' -e 's/^/ /'
897 echo "Don't forget to"
898 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
899 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
900 sourcebase_base=`basename "$sourcebase"`
901 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
902 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
903 echo " - invoke gl_EARLY in $configure_ac, right after AC_PROG_CC,"
904 echo " - invoke gl_INIT in $configure_ac."
907 # func_create_testdir testdir modules
909 # - auxdir directory relative to destdir where to place build aux files
910 func_create_testdir ()
914 modules=`for m in $modules; do echo $m; done | sort | uniq`
916 # Determine final module list.
917 func_modules_transitive_closure
918 echo "Module list with included dependencies:"
919 echo "$modules" | sed -e 's/^/ /'
921 # Determine final file list.
922 func_modules_to_filelist
924 echo "$files" | sed -e 's/^/ /'
926 # Create directories.
927 for d in `echo "$files" | sed -n -e 's,^\(.*\)/[^/]*,\1,p'`; do
928 if test "$d" = build-aux; then
929 mkdir -p "$testdir/$auxdir"
931 mkdir -p "$testdir/$d"
935 # Copy files or make symbolic links.
938 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
941 ln "$gnulib_dir/$f" "$testdir/$g" 2>/dev/null ||
942 if test -z "$symbolic"; then
943 cp -p "$gnulib_dir/$f" "$testdir/$g"
945 ln -s "$gnulib_dir/$f" "$testdir/$g"
949 # Create lib/Makefile.am.
950 mkdir -p "$testdir/lib"
951 func_emit_lib_Makefile_am > "$testdir/lib/Makefile.am"
953 # Create m4/Makefile.am.
954 mkdir -p "$testdir/m4"
955 (echo "## Process this file with automake to produce Makefile.in."
961 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
964 ) > "$testdir/m4/Makefile.am"
967 subdirs_with_configure_ac=""
969 if test -f "$testdir"/m4/gettext.m4; then
970 # Avoid stupid error message from automake:
971 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
972 mkdir -p "$testdir/po"
973 (echo "## Process this file with automake to produce Makefile.in."
974 ) > "$testdir/po/Makefile.am"
975 subdirs="$subdirs po"
978 if test -n "$inctests"; then
979 test -d "$testdir/tests" || mkdir "$testdir/tests"
980 # Create tests/Makefile.am.
982 func_emit_tests_Makefile_am > "$testdir/tests/Makefile.am"
983 # Create tests/configure.ac.
984 (echo "# Process this file with autoconf to produce a configure script."
985 echo "AC_INIT([dummy], [0])"
986 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
987 echo "AM_INIT_AUTOMAKE"
989 echo "AM_CONFIG_HEADER([config.h])"
992 echo "AC_PROG_INSTALL"
993 echo "AC_PROG_MAKE_SET"
994 echo "AC_PROG_RANLIB"
996 if grep AC_GNU_SOURCE "$testdir"/m4/*.m4 > /dev/null; then
1000 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir"/m4/*.m4 > /dev/null; then
1001 echo "gl_USE_SYSTEM_EXTENSIONS"
1004 # We don't have explicit ordering constraints between the various
1005 # autoconf snippets. It's cleanest to put those of the library before
1006 # those of the tests.
1007 for module in $modules; do
1008 func_verify_nontests_module
1009 if test -n "$module"; then
1010 func_get_autoconf_snippet "$module"
1013 for module in $modules; do
1014 func_verify_tests_module
1015 if test -n "$module"; then
1016 func_get_autoconf_snippet "$module"
1020 # Usually tests/config.h will be a superset of config.h. Verify this by
1021 # "merging" config.h into tests/config.h; look out for gcc warnings.
1022 echo "AH_TOP([#include \"../config.h\"])"
1024 echo "AC_OUTPUT([Makefile])"
1025 ) > "$testdir/tests/configure.ac"
1026 subdirs="$subdirs tests"
1027 subdirs_with_configure_ac="$subdirs_with_configure_ac tests"
1030 # Create Makefile.am.
1031 (echo "## Process this file with automake to produce Makefile.in."
1033 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1035 echo "SUBDIRS = $subdirs"
1037 echo "ACLOCAL_AMFLAGS = -I m4"
1038 ) > "$testdir/Makefile.am"
1040 # Create configure.ac.
1041 (echo "# Process this file with autoconf to produce a configure script."
1042 echo "AC_INIT([dummy], [0])"
1043 if test "$auxdir" != "."; then
1044 echo "AC_CONFIG_AUX_DIR([$auxdir])"
1046 echo "AM_INIT_AUTOMAKE"
1048 echo "AM_CONFIG_HEADER([config.h])"
1051 echo "AC_PROG_INSTALL"
1052 echo "AC_PROG_MAKE_SET"
1053 echo "AC_PROG_RANLIB"
1055 if grep AC_GNU_SOURCE "$testdir"/m4/*.m4 > /dev/null; then
1056 echo "AC_GNU_SOURCE"
1059 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir"/m4/*.m4 > /dev/null; then
1060 echo "gl_USE_SYSTEM_EXTENSIONS"
1063 for module in $modules; do
1064 func_verify_nontests_module
1065 if test -n "$module"; then
1066 func_get_autoconf_snippet "$module"
1070 if test -n "$subdirs_with_configure_ac"; then
1071 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
1073 makefiles="Makefile"
1074 for d in $subdirs; do
1075 # For subdirs that have a configure.ac by their own, it's the subdir's
1076 # configure.ac which creates the subdir's Makefile.am, not this one.
1077 case " $subdirs_with_configure_ac " in
1079 *) makefiles="$makefiles $d/Makefile" ;;
1082 echo "AC_OUTPUT([$makefiles])"
1083 ) > "$testdir/configure.ac"
1085 # Create autogenerated files.
1087 echo "executing ${AUTORECONF} --force --install"
1088 ${AUTORECONF} --force --install
1090 if grep '^BUILT_SOURCES *+=' "$testdir/lib/Makefile.am" > /dev/null; then
1094 built_sources=`grep '^BUILT_SOURCES *=' Makefile.in | sed -e 's/^BUILT_SOURCES *=//'`
1095 if test -n "$built_sources"; then
1104 # func_create_megatestdir megatestdir allmodules
1106 # - auxdir directory relative to destdir where to place build aux files
1107 func_create_megatestdir ()
1111 if test -z "$allmodules"; then
1112 allmodules=`func_all_modules`
1116 # First, all modules one by one.
1117 for onemodule in $allmodules; do
1118 func_create_testdir "$megatestdir/$onemodule" $onemodule
1119 megasubdirs="${megasubdirs}$onemodule "
1121 # Then, all modules all together.
1122 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
1123 allmodules=`for m in $allmodules; do if test $m != fnmatch-posix; then echo $m; fi; done`
1124 func_create_testdir "$megatestdir/ALL" "$allmodules"
1125 megasubdirs="${megasubdirs}ALL"
1127 # Create Makefile.am.
1128 (echo "## Process this file with automake to produce Makefile.in."
1130 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1132 echo "SUBDIRS = $megasubdirs"
1133 ) > "$megatestdir/Makefile.am"
1135 # Create configure.ac.
1136 (echo "# Process this file with autoconf to produce a configure script."
1137 echo "AC_INIT([dummy], [0])"
1138 if test "$auxdir" != "."; then
1139 echo "AC_CONFIG_AUX_DIR([$auxdir])"
1141 echo "AM_INIT_AUTOMAKE"
1143 echo "AC_PROG_MAKE_SET"
1145 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
1146 echo "AC_OUTPUT([Makefile])"
1147 ) > "$megatestdir/configure.ac"
1149 # Create autogenerated files.
1151 echo "executing ${AUTORECONF} --install"
1152 ${AUTORECONF} --install
1158 func_fatal_error "no mode specified" ;;
1166 if test -z "$destdir"; then
1169 test -d "$destdir" \
1170 || func_fatal_error "destination directory does not exist: $destdir"
1172 # Prefer configure.ac to configure.in
1173 test -f "$destdir"/configure.in && configure_ac="$destdir/configure.in"
1174 test -f "$destdir"/configure.ac && configure_ac="$destdir/configure.ac"
1175 test -f "$configure_ac" \
1176 || func_fatal_error "cannot find $destdir/configure.ac"
1179 my_sed_traces='s,#.*$,,; s,^dnl .*$,,; s, dnl .*$,,;
1181 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,ac_modules="\1",; p;
1184 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,ac_avoidlist="\1",; p;
1187 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,ac_sourcebase="\1",; p;
1190 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,ac_m4base="\1",; p;
1193 s,^.*gl_LIB([[ ]*\([^])]*\).*$,ac_libname="\1",; p;
1195 /AC_CONFIG_AUX_DIR/ {
1196 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,ac_auxdir="\1",; p;
1198 /A[CM]_PROG_LIBTOOL/ { s,^.*$,seen_libtool=:,; p; };
1199 /LT_INIT/ { s,^.*$,seen_libtool=:,; p; };
1200 /gl_LGPL/ { s,^.*$,lgpl=true,; p; };
1202 eval `cat $configure_ac | sed "$my_sed_traces"`
1205 if test -z "$supplied_libname" && test -n "$ac_libname"; then
1206 libname="$ac_libname"
1209 # Set up source base.
1210 test -z "$sourcebase" && sourcebase="$ac_sourcebase"
1211 test -z "$sourcebase" && sourcebase="lib"
1212 test -d "$destdir/$sourcebase" \
1213 || { test -z "$dry_run" && mkdir "$destdir/$sourcebase"; } \
1214 || func_fatal_error "source base $destdir/$sourcebase doesn't exist"
1217 test -z "$m4base" && m4base="$ac_m4base"
1218 test -z "$m4base" && m4base="m4"
1219 test -d "$destdir/$m4base" \
1220 || { test -z "$dry_run" && mkdir "$destdir/$m4base"; } \
1221 || func_fatal_error "m4 base $destdir/$m4base doesn't exist"
1223 # Set up auxiliary directory.
1224 test -z "$auxdir" && auxdir="$ac_auxdir"
1225 test -z "$auxdir" && auxdir="build-aux"
1226 test -d "$destdir/$auxdir" \
1227 || { test -z "$dry_run" && mkdir "$destdir/$auxdir"; } \
1228 || func_fatal_error "aux directory $destdir/$auxdir doesn't exist"
1231 if test -n "$seen_libtool"; then
1235 # What modules to extract.
1236 if test $# = 0; then
1237 modules="$ac_modules"
1242 # Which modules to avoid?
1243 avoidlist=`echo $avoidlist $ac_avoidlist`
1245 func_import "$modules"
1249 if test -z "$destdir"; then
1250 func_fatal_error "please specify --dir option"
1253 test -d "$destdir" \
1254 || func_fatal_error "could not create destination directory"
1255 test -n "$auxdir" || auxdir="build-aux"
1256 func_create_testdir "$destdir" "$*"
1259 create-megatestdir )
1260 if test -z "$destdir"; then
1261 func_fatal_error "please specify --dir option"
1263 mkdir "$destdir" || func_fatal_error "could not create destination directory"
1264 test -n "$auxdir" || auxdir="build-aux"
1265 func_create_megatestdir "$destdir" "$*"
1269 test -n "$destdir" || destdir=testdir$$
1270 mkdir "$destdir" || func_fatal_error "could not create destination directory"
1271 test -n "$auxdir" || auxdir="build-aux"
1272 func_create_testdir "$destdir" "$*"
1280 remaining=`find . -type f -print`
1281 if test -n "$remaining"; then
1282 echo "Remaining files:" $remaining 1>&2
1283 echo "gnulib-tool: *** Stop." 1>&2
1292 test -n "$destdir" || destdir=testdir$$
1293 mkdir "$destdir" || func_fatal_error "could not create destination directory"
1294 test -n "$auxdir" || auxdir="build-aux"
1295 func_create_megatestdir "$destdir" "$*"
1303 remaining=`find . -type f -print`
1304 if test -n "$remaining"; then
1305 echo "Remaining files:" $remaining 1>&2
1306 echo "gnulib-tool: *** Stop." 1>&2
1314 extract-description )
1318 if test -n "$module"; then
1319 func_get_description "$module"
1328 if test -n "$module"; then
1329 func_get_filelist "$module"
1334 extract-dependencies )
1338 if test -n "$module"; then
1339 func_get_dependencies "$module"
1344 extract-autoconf-snippet )
1348 if test -n "$module"; then
1349 func_get_autoconf_snippet "$module"
1354 extract-automake-snippet )
1358 if test -n "$module"; then
1359 func_get_automake_snippet "$module"
1364 extract-include-directive )
1368 if test -n "$module"; then
1369 func_get_include_directive "$module"
1378 if test -n "$module"; then
1379 func_get_license "$module"
1384 extract-maintainer )
1388 if test -n "$module"; then
1389 func_get_maintainer "$module"
1394 extract-tests-module )
1398 if test -n "$module"; then
1399 func_get_tests_module "$module"
1405 func_fatal_error "unknown operation mode --$mode" ;;