3 # Copyright (C) 2002-2006 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 Foundation,
17 # 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: 2006-07-20 16:53:35 $'
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 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
41 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
42 # variables AUTOCONF, ACLOCAL, AUTOMAKE, AUTORECONF individually.
43 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
44 AUTOCONF="${AUTOCONFPATH}autoconf"
46 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
47 ACLOCAL="${AUTOMAKEPATH}aclocal"
49 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
50 AUTOMAKE="${AUTOMAKEPATH}automake"
52 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
53 AUTORECONF="${AUTOCONFPATH}autoreconf"
57 # outputs to stdout the --help usage message.
61 Usage: gnulib-tool --list
62 gnulib-tool --import [module1 ... moduleN]
64 gnulib-tool --create-testdir --dir=directory module1 ... moduleN
65 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
66 gnulib-tool --test --dir=directory module1 ... moduleN
67 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
68 gnulib-tool --extract-description module
69 gnulib-tool --extract-filelist module
70 gnulib-tool --extract-dependencies module
71 gnulib-tool --extract-autoconf-snippet module
72 gnulib-tool --extract-automake-snippet module
73 gnulib-tool --extract-include-directive module
74 gnulib-tool --extract-license module
75 gnulib-tool --extract-maintainer module
76 gnulib-tool --extract-tests-module module
79 --list print the available module names
80 --import import the given modules into the current package;
81 if no modules are specified, update the current
82 package from the current gnulib
83 --update update the current package, restore files omitted
85 --create-testdir create a scratch package with the given modules
86 --create-megatestdir create a mega scratch package with the given modules
87 one by one and all together
88 --test test the combination of the given modules
89 (recommended to use CC=\"gcc -Wall\" here)
90 --megatest test the given modules one by one and all together
91 (recommended to use CC=\"gcc -Wall\" here)
92 --extract-description extract the description
93 --extract-filelist extract the list of files
94 --extract-dependencies extract the dependencies
95 --extract-autoconf-snippet extract the snippet for configure.ac
96 --extract-automake-snippet extract the snippet for lib/Makefile.am
97 --extract-include-directive extract the #include directive
98 --extract-license report the license terms of the source files
100 --extract-maintainer report the maintainer(s) inside gnulib
101 --extract-tests-module report the unit test module, if it exists
104 --assume-autoconf=VERSION
105 Assume a given autoconf version (or newer).
106 If VERSION is 'latest-stable', assume the latest
108 --avoid=MODULE Avoid including the given MODULE. Useful if you
109 have code that provides equivalent functionality.
110 This option can be repeated.
111 --dry-run For --import, only print what would have been done.
112 --lgpl Abort if modules aren't available under the LGPL.
113 Also modify license template from GPL to LGPL.
114 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
115 --libtool Use libtool rules, for --import.
116 --macro-prefix=PREFIX Specify the prefix of the macros gl_EARLY and
117 gl_INIT. Default is "gl".
118 --no-changelog don't update or create ChangeLog files
119 -s, --symbolic, --symlink Make symbolic links instead of copying files.
120 --with-tests Include unit tests for the included modules.
123 --dir=DIRECTORY specify the target directory
124 For --import, this specifies where your
125 configure.ac can be found. Defaults to current
127 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
128 tools are placed (default \"build-aux\").
129 --doc-base=DIRECTORY Directory relative to --dir where doc files are
130 placed (default \"doc\"), for --import.
131 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
132 placed (default \"m4\"), for --import.
133 --source-base=DIRECTORY Directory relative to --dir where source code is
134 placed (default \"lib\"), for --import.
135 --tests-base=DIRECTORY Directory relative to --dir where unit tests are
136 placed (default \"tests\"), for --import.
138 Report bugs to <bug-gnulib@gnu.org>."
142 # outputs to stdout the --version message.
145 year=`echo "$last_checkin_date" | sed -e 's,/.*$,,'`
146 echo "$progname (GNU $package) $version"
147 echo "Copyright (C) $year Free Software Foundation, Inc.
148 This is free software; see the source for copying conditions. There is NO
149 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
150 echo "Written by" "Bruno Haible" "and" "Simon Josefsson"
153 # func_emit_copyright_notice
154 # outputs to stdout a header for a generated file.
155 func_emit_copyright_notice ()
157 echo "# Copyright (C) 2004-2006 Free Software Foundation, Inc."
159 echo "# This file is free software, distributed under the terms of the GNU"
160 echo "# General Public License. As a special exception to the GNU General"
161 echo "# Public License, this file may be distributed as part of a program"
162 echo "# that contains a configuration script generated by Autoconf, under"
163 echo "# the same distribution terms as the rest of that program."
165 echo "# Generated by gnulib-tool."
169 # creates a temporary directory.
171 # - tmp pathname of freshly created temporary directory
174 # Use the environment variable TMPDIR, falling back to /tmp. This allows
175 # users to specify a different temporary directory, for example, if their
176 # /tmp is filled up or too small.
179 # Use the mktemp program if available. If not available, hide the error
181 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
182 test -n "$tmp" && test -d "$tmp"
185 # Use a simple mkdir command. It is guaranteed to fail if the directory
186 # already exists. $RANDOM is bash specific and expands to empty in shells
187 # other than bash, ksh and zsh. Its use does not increase security;
188 # rather, it minimizes the probability of failure in a very cluttered /tmp
190 tmp=$TMPDIR/gl$$-$RANDOM
191 (umask 077 && mkdir "$tmp")
194 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
195 { (exit 1); exit 1; }
199 # func_fatal_error message
200 # outputs to stderr a fatal error message, and terminates the program.
203 echo "gnulib-tool: *** $1" 1>&2
204 echo "gnulib-tool: *** Stop." 1>&2
208 # func_readlink SYMLINK
209 # outputs the target of the given symlink.
210 if (type -p readlink) > /dev/null 2>&1; then
213 # Use the readlink program from GNU coreutils.
219 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
220 # would do the wrong thing if the link target contains " -> ".
221 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
225 # func_ln_if_changed SRC DEST
226 # Like ln -s, but avoids munging timestamps if the link is correct.
227 func_ln_if_changed ()
229 if test $# -ne 2; then
230 echo "usage: func_ln_if_changed SRC DEST" >&2
232 if test -L "$2" && test "$1" = "`func_readlink "$2"`"; then
240 # Command-line option processing.
241 # Removes the OPTIONS from the arguments. Sets the variables:
242 # - mode list or import or create-testdir or create-megatestdir
243 # - destdir from --dir
244 # - libname, supplied_libname from --lib
245 # - sourcebase from --source-base
246 # - m4base from --m4-base
247 # - docbase from --doc-base
248 # - testsbase from --tests-base
249 # - auxdir from --aux-dir
250 # - inctests true if --with-tests was given, blank otherwise
251 # - avoidlist list of modules to avoid, from --avoid
252 # - lgpl true if --lgpl was given, blank otherwise
253 # - libtool true if --libtool was given, blank otherwise
254 # - macro_prefix from --macro-prefix
255 # - autoconf_minversion minimum supported autoconf version
256 # - do_changelog false if --no-changelog was given, : otherwise
257 # - doit : if actions shall be executed, false if only to be printed
280 while test $# -gt 0; do
285 --import | --impor | --impo | --imp | --im | --i )
288 --update | --updat | --upda | --upd | --up | --u )
291 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
294 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
295 mode=create-megatestdir
297 --test | --tes | --te | --t )
300 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
304 mode=`echo "X$1" | sed -e 's/^X--//'`
309 func_fatal_error "missing argument for --dir"
314 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
319 func_fatal_error "missing argument for --lib"
322 supplied_libname=true
325 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
326 supplied_libname=true
331 func_fatal_error "missing argument for --source-base"
336 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
341 func_fatal_error "missing argument for --m4-base"
346 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
351 func_fatal_error "missing argument for --doc-base"
356 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
361 func_fatal_error "missing argument for --tests-base"
366 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
371 func_fatal_error "missing argument for --aux-dir"
376 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
384 func_fatal_error "missing argument for --avoid"
386 avoidlist="$avoidlist $1"
389 avoidlist="$avoidlist "`echo "X$1" | sed -e 's/^X--avoid=//'`
400 func_fatal_error "missing argument for --macro-prefix"
405 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
410 func_fatal_error "missing argument for --assume-autoconf"
412 autoconf_minversion="$1"
414 --assume-autoconf=* )
415 autoconf_minversion=`echo "X$1" | sed -e 's/^X--assume-autoconf=//'`
417 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
423 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
426 --help | --hel | --he | --h )
429 --version | --versio | --versi | --vers | --ver | --ve | --v )
433 # Stop option processing
437 echo "gnulib-tool: unknown option $1" 1>&2
438 echo "Try 'gnulib-tool --help' for more information." 1>&2
445 if test "$mode" = update; then
446 if test $# != 0; then
447 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
448 echo "Try 'gnulib-tool --help' for more information." 1>&2
449 echo "If you really want to modify the gnulib configuration of your project," 1>&2
450 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
453 if test -n "$supplied_libname" || test -n "$sourcebase" || test -n "$m4base" \
454 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
455 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
456 || test -n "$macro_prefix" || test -n "$autoconf_minversion"; then
457 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
458 echo "Try 'gnulib-tool --help' for more information." 1>&2
459 echo "If you really want to modify the gnulib configuration of your project," 1>&2
460 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
466 DEFAULT_AUTOCONF_MINVERSION="2.59"
467 case "$autoconf_minversion" in
468 1.* | 2.[0-4]* | 2.5[0-8]*)
469 func_fatal_error "minimum supported autoconf version is 2.59" ;;
472 # Remove trailing slashes from the directory names. This is necessary for
473 # m4base (to avoid an error in func_import) and optional for the others.
474 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
475 case "$sourcebase" in
476 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
479 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
482 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
485 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
488 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
493 /*) self_abspathname="$0" ;;
494 */*) self_abspathname=`pwd`/"$0" ;;
495 *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
496 if test -x "$d/$0" && test ! -d "$d/$0"; then
497 self_abspathname="$d/$0"
501 if test -z "$self_abspathname"; then
502 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
506 while test -h "$self_abspathname"; do
507 # Resolve symbolic link.
508 linkval=`func_readlink "$self_abspathname"`
509 test -n "$linkval" || break
511 /* ) self_abspathname="$linkval" ;;
512 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
515 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
520 # Filter out metainformation files like README, which are not modules.
521 # Filter out unit test modules; they can be retrieved through
522 # --extract-tests-module if desired.
523 (cd "$gnulib_dir/modules" && ls -1) \
524 | sed -e '/^CVS$/d' -e '/^ChangeLog$/d' -e '/^README$/d' -e '/^TEMPLATE$/d' -e '/^TEMPLATE-TESTS$/d' -e '/~$/d' \
525 | sed -e '/-tests$/d' \
530 # verifies a module name
531 func_verify_module ()
533 if test ! -f "$gnulib_dir/modules/$module" \
534 || test "CVS" = "$module" \
535 || test "ChangeLog" = "$module" \
536 || test "README" = "$module" \
537 || test "TEMPLATE" = "$module" \
538 || test "TEMPLATE-TESTS" = "$module"; then
539 echo "gnulib-tool: module $module doesn't exist" 1>&2
544 # func_verify_nontests_module
545 # verifies a module name, excluding tests modules
546 func_verify_nontests_module ()
550 * ) func_verify_module ;;
554 # func_verify_tests_module
555 # verifies a module name, considering only tests modules
556 func_verify_tests_module ()
559 *-tests ) func_verify_module ;;
564 sed_extract_prog=':[ ]*$/ {
567 s/^Description:[ ]*$//
569 s/^Depends-on:[ ]*$//
570 s/^configure\.ac:[ ]*$//
571 s/^Makefile\.am:[ ]*$//
574 s/^Maintainer:[ ]*$//
581 # func_get_description module
582 func_get_description ()
584 sed -n -e "/^Description$sed_extract_prog" < "$gnulib_dir/modules/$1"
587 # func_get_filelist module
590 sed -n -e "/^Files$sed_extract_prog" < "$gnulib_dir/modules/$1"
591 case "$autoconf_minversion" in
594 echo m4/onceonly_2_57.m4
599 # func_get_dependencies module
600 func_get_dependencies ()
602 # ${module}-tests always implicitly depends on ${module}.
603 echo "$1" | sed -n -e 's/-tests//p'
604 # Then the explicit dependencies listed in the module description.
605 sed -n -e "/^Depends-on$sed_extract_prog" < "$gnulib_dir/modules/$1"
608 # func_get_autoconf_snippet module
609 func_get_autoconf_snippet ()
611 sed -n -e "/^configure\.ac$sed_extract_prog" < "$gnulib_dir/modules/$1"
614 # func_get_automake_snippet module
615 func_get_automake_snippet ()
617 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$gnulib_dir/modules/$1"
620 # func_get_include_directive module
621 func_get_include_directive ()
623 sed -n -e "/^Include$sed_extract_prog" < "$gnulib_dir/modules/$1" | \
624 sed -e 's/^\(["<]\)/#include \1/'
627 # func_get_license module
630 sed -n -e "/^License$sed_extract_prog" < "$gnulib_dir/modules/$1"
633 # func_get_maintainer module
634 func_get_maintainer ()
636 sed -n -e "/^Maintainer$sed_extract_prog" < "$gnulib_dir/modules/$1"
639 # func_get_tests_module module
640 func_get_tests_module ()
642 # The naming convention for tests modules is hardwired: ${module}-tests.
643 if test -f modules/"$1"-tests; then
648 # func_acceptable module
649 # tests whether a module is acceptable.
651 # - avoidlist list of modules to avoid
654 for avoid in $avoidlist; do
655 if test "$avoid" = "$1"; then
662 # func_modules_transitive_closure
664 # - modules list of specified modules
665 # - inctests true if tests should be included, blank otherwise
666 # - avoidlist list of modules to avoid
668 # - modules list of modules, including dependencies
669 func_modules_transitive_closure ()
673 for module in $modules; do
675 if test -n "$module"; then
676 # Duplicate dependencies are harmless, but Jim wants a warning.
677 duplicated_deps=`func_get_dependencies $module | LC_ALL=C sort | LC_ALL=C uniq -d`
678 if test -n "$duplicated_deps"; then
679 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
681 if func_acceptable $module; then
682 xmodules="$xmodules $module"
683 for depmodule in `func_get_dependencies $module`; do
684 if func_acceptable $depmodule; then
685 xmodules="$xmodules $depmodule"
688 if test -n "$inctests"; then
689 testsmodule=`func_get_tests_module $module`
690 if test -n "$testsmodule"; then
691 if func_acceptable $testsmodule; then
692 xmodules="$xmodules $testsmodule"
693 for depmodule in `func_get_dependencies $testsmodule`; do
694 if func_acceptable $depmodule; then
695 xmodules="$xmodules $depmodule"
704 xmodules=`for m in $xmodules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
705 if test "$xmodules" = "$modules"; then
712 # func_modules_add_dummy
714 # - modules list of modules, including dependencies
716 # - modules list of modules, including 'dummy' if needed
717 func_modules_add_dummy ()
720 sed_remove_backslash_newline=':a
727 for module in $modules; do
728 func_verify_nontests_module
729 if test -n "$module"; then
730 # Extract the value of "lib_SOURCES += ...".
731 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
732 # Ignore .h files since they are not compiled.
735 *) have_lib_SOURCES=yes ;;
740 # Add the dummy module, to make sure the library will be non-empty.
741 if test -z "$have_lib_SOURCES"; then
742 modules="$modules dummy"
746 # func_modules_to_filelist
748 # - modules list of modules, including dependencies
750 # - files list of files
751 func_modules_to_filelist ()
754 for module in $modules; do
756 if test -n "$module"; then
757 files="$files "`func_get_filelist $module`
760 files=`for f in $files; do echo $f; done | LC_ALL=C sort | LC_ALL=C uniq`
763 # func_emit_lib_Makefile_am
764 # emits the contents of lib/Makefile.am to standard output.
766 # - modules list of modules, including dependencies
767 # - libname library name
768 # - libtool true if libtool will be used, blank otherwise
769 # - actioncmd (optional) command that will reproduce this invocation
770 func_emit_lib_Makefile_am ()
772 if test -n "$libtool"; then
779 echo "## Process this file with automake to produce Makefile.in."
780 func_emit_copyright_notice
781 if test -n "$actioncmd"; then
782 echo "# Reproduce by: $actioncmd"
785 # No need to generate dependencies since the sources are in gnulib, not here.
786 echo "AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies"
788 echo "noinst_${perhapsLT}LIBRARIES = $libname.$libext"
790 echo "${libname}_${libext}_SOURCES ="
791 echo "${libname}_${libext}_LIBADD = @${perhapsLT}LIBOBJS@"
792 echo "noinst_HEADERS ="
794 echo "BUILT_SOURCES ="
796 echo "MOSTLYCLEANFILES ="
797 echo "MOSTLYCLEANDIRS ="
799 echo "DISTCLEANFILES ="
800 echo "MAINTAINERCLEANFILES ="
804 for module in $modules; do
805 func_verify_nontests_module
806 if test -n "$module"; then
808 func_get_automake_snippet "$module" |
809 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
810 if test "$module" = 'alloca'; then
811 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
814 # Skip the contents if its entirely empty.
815 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
816 echo "## begin gnulib module $module"
819 echo "## end gnulib module $module"
826 echo "mostlyclean-local:"
827 echo " @test -z \"\$(MOSTLYCLEANDIRS)\" || \\"
828 echo " for dir in \$(MOSTLYCLEANDIRS); do \\"
829 echo " if test -d \$\$dir; then \\"
830 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
834 echo "# Makefile.am ends here"
837 # func_emit_tests_Makefile_am
838 # emits the contents of tests/Makefile.am to standard output.
840 # - modules list of modules, including dependencies
841 # - libname library name
842 # - libtool true if libtool will be used, blank otherwise
843 # - sourcebase relative directory containing lib source code
844 # - m4base relative directory containing autoconf macros
845 # - testsbase relative directory containing unit test code
846 func_emit_tests_Makefile_am ()
848 if test -n "$libtool"; then
853 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
854 echo "## Process this file with automake to produce Makefile.in."
855 func_emit_copyright_notice
857 # Generate dependencies here, since it eases the debugging of test failures.
858 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
860 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
862 # Nothing is being added to SUBDIRS; nevertheless the existence of this
863 # variable is needed to avoid an error from automake:
864 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
867 echo "TESTS_ENVIRONMENT ="
868 echo "noinst_PROGRAMS ="
869 echo "check_PROGRAMS ="
870 echo "noinst_HEADERS ="
872 echo "BUILT_SOURCES ="
874 echo "MOSTLYCLEANFILES ="
875 echo "MOSTLYCLEANDIRS ="
877 echo "DISTCLEANFILES ="
878 echo "MAINTAINERCLEANFILES ="
880 echo "AM_CPPFLAGS = \\"
881 echo " -I. -I\$(srcdir) \\"
882 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
883 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
885 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
887 for module in $modules; do
888 func_verify_tests_module
889 if test -n "$module"; then
890 func_get_automake_snippet "$module" > amsnippet.tmp
891 # Skip the contents if its entirely empty.
892 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
893 echo "## begin gnulib module $module"
896 echo "## end gnulib module $module"
902 echo "# Clean up after Solaris cc."
904 echo " rm -rf SunWS_cache"
906 echo "mostlyclean-local:"
907 echo " @test -z \"\$(MOSTLYCLEANDIRS)\" || \\"
908 echo " for dir in \$(MOSTLYCLEANDIRS); do \\"
909 echo " if test -d \$\$dir; then \\"
910 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
914 echo "# Makefile.am ends here"
917 # func_import modules
918 # Uses also the variables
919 # - destdir target directory
920 # - libname library name
921 # - sourcebase directory relative to destdir where to place source code
922 # - m4base directory relative to destdir where to place *.m4 macros
923 # - docbase directory relative to destdir where to place doc files
924 # - testsbase directory relative to destdir where to place unit test code
925 # - auxdir directory relative to destdir where to place build aux files
926 # - inctests true if --with-tests was given, blank otherwise
927 # - avoidlist list of modules to avoid, from --avoid
928 # - lgpl true if library's license shall be LGPL, blank otherwise
929 # - libtool true if libtool will be used, blank otherwise
930 # - guessed_libtool true if the configure.ac file uses libtool, blank otherwise
931 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
932 # - autoconf_minversion minimum supported autoconf version
933 # - doit : if actions shall be executed, false if only to be printed
934 # - symbolic true if files should be symlinked, copied otherwise
937 # Get the cached settings.
938 cached_specified_modules=
948 cached_autoconf_minversion=
950 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
956 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
959 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
962 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
965 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
968 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
971 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
974 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
977 s,^.*$,cached_lgpl=true,p
980 s,^.*$,cached_libtool=true,p
983 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
985 /gl_AUTOCONF_MINVERSION(/ {
986 s,^.*gl_AUTOCONF_MINVERSION([[ ]*\([^])]*\).*$,cached_autoconf_minversion="\1",p
988 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
989 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
994 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
995 s,^.*$,cached_files=",p
1007 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1011 # Merge the cached settings with the specified ones.
1012 # The m4base must be the same as expected from the pathname.
1013 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1014 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1016 # Append the cached and the specified module names. So that
1017 # "gnulib-tool --import foo" means to add the module foo.
1018 specified_modules="$cached_specified_modules $1"
1019 # Append the cached and the specified avoidlist. This is probably better
1020 # than dropping the cached one when --avoid is specified at least once.
1021 avoidlist=`echo $cached_avoidlist $avoidlist`
1022 # The sourcebase defaults to the cached one.
1023 if test -z "$sourcebase"; then
1024 sourcebase="$cached_sourcebase"
1025 if test -z "$sourcebase"; then
1026 func_fatal_error "missing --source-base option"
1029 # The docbase defaults to the cached one.
1030 if test -z "$docbase"; then
1031 docbase="$cached_docbase"
1032 if test -z "$docbase"; then
1033 func_fatal_error "missing --doc-base option"
1036 # The testsbase defaults to the cached one.
1037 if test -z "$testsbase"; then
1038 testsbase="$cached_testsbase"
1039 if test -z "$testsbase"; then
1040 func_fatal_error "missing --tests-base option"
1043 # The libname defaults to the cached one.
1044 if test -z "$supplied_libname"; then
1045 libname="$cached_libname"
1046 if test -z "$libname"; then
1047 func_fatal_error "missing --lib option"
1050 # Require LGPL if specified either way.
1051 if test -z "$lgpl"; then
1054 # Use libtool if specified either way, or if guessed.
1055 if test -z "$libtool"; then
1056 if test -n "$cached_m4base"; then
1057 libtool="$cached_libtool"
1059 libtool="$guessed_libtool"
1062 # The macro_prefix defaults to the cached one.
1063 if test -z "$macro_prefix"; then
1064 macro_prefix="$cached_macro_prefix"
1065 if test -z "$macro_prefix"; then
1066 func_fatal_error "missing --macro-prefix option"
1069 # The autoconf_minversion defaults to the cached one.
1070 if test -z "$autoconf_minversion"; then
1071 autoconf_minversion="$cached_autoconf_minversion"
1072 if test -z "$autoconf_minversion"; then
1073 autoconf_minversion="$DEFAULT_AUTOCONF_MINVERSION"
1077 # Canonicalize the list of specified modules.
1078 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
1080 # Determine final module list.
1081 modules="$specified_modules"
1082 func_modules_transitive_closure
1083 echo "Module list with included dependencies:"
1084 echo "$modules" | sed -e 's/^/ /'
1086 # Add the dummy module if needed.
1087 func_modules_add_dummy
1089 # If --lgpl, check the license of modules are compatible.
1090 if test -n "$lgpl"; then
1091 for module in $modules; do
1092 license=`func_get_license $module`
1094 LGPL | 'GPLed build tool' | 'public domain' | 'unlimited') ;;
1095 *) func_fatal_error "incompatible license on module $module: $license" ;;
1100 # Determine final file list.
1101 func_modules_to_filelist
1103 echo "$files" | sed -e 's/^/ /'
1106 || func_fatal_error "refusing to do nothing"
1108 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
1109 new_files="$files m4/gnulib-tool.m4"
1110 old_files="$cached_files"
1111 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
1112 old_files="$old_files m4/gnulib-tool.m4"
1115 # Create directories.
1116 if test ! -d "$destdir/$sourcebase"; then
1118 echo "Creating directory $destdir/$sourcebase"
1119 mkdir "$destdir/$sourcebase" || func_fatal_error "failed"
1121 echo "Create directory $destdir/$sourcebase"
1124 if test ! -d "$destdir/$m4base"; then
1126 echo "Creating directory $destdir/$m4base"
1127 mkdir "$destdir/$m4base" || func_fatal_error "failed"
1129 echo "Create directory $destdir/$m4base"
1132 if test ! -d "$destdir/$docbase"; then
1134 echo "Creating directory $destdir/$docbase"
1135 mkdir "$destdir/$docbase" || func_fatal_error "failed"
1137 echo "Create directory $destdir/$docbase"
1140 if test -n "$inctests"; then
1141 if test ! -d "$destdir/$testsbase"; then
1143 echo "Creating directory $destdir/$testsbase"
1144 mkdir "$destdir/$testsbase" || func_fatal_error "failed"
1146 echo "Create directory $destdir/$testsbase"
1150 if test ! -d "$destdir/$auxdir"; then
1152 echo "Creating directory $destdir/$auxdir"
1153 mkdir "$destdir/$auxdir" || func_fatal_error "failed"
1155 echo "Create directory $destdir/$auxdir"
1160 trap 'rm -rf "$tmp"' 0 1 2 3 15
1161 # func_dest_tmpfilename file
1162 # determines the name of a temporary file (file is relative to destdir).
1164 # - tmpfile absolute filename of the temporary file
1165 func_dest_tmpfilename ()
1168 # Put the new contents of $file in a file in the same directory (needed
1169 # to guarantee that an 'mv' to "$destdir/$file" works).
1170 tmpfile="$destdir/$1.tmp"
1172 # Put the new contents of $file in a file in a temporary directory
1173 # (because the directory of "$file" might not exist).
1174 tmpfile="$tmp"/`basename "$1"`.tmp
1178 # Copy files or make symbolic links. Remove obsolete files.
1180 for f in $old_files; do
1182 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1183 doc/*) g=`echo "$f" | sed -e "s,^doc/,$cached_docbase/,"` ;;
1184 lib/*) g=`echo "$f" | sed -e "s,^lib/,$cached_sourcebase/,"` ;;
1185 m4/*) g=`echo "$f" | sed -e "s,^m4/,$cached_m4base/,"` ;;
1186 tests/*) g=`echo "$f" | sed -e "s,^tests/,$cached_testsbase/,"` ;;
1189 echo "$g""$delimiter""$f"
1190 done | LC_ALL=C sort > "$tmp"/old-files
1191 for f in $new_files; do
1193 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1194 doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
1195 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1196 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1197 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1200 echo "$g""$delimiter""$f"
1201 done | LC_ALL=C sort > "$tmp"/new-files
1202 # First the files that are in old-files, but not in new-files:
1203 sed_take_first_column='s,'"$delimiter"'.*,,'
1204 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
1205 # Remove the file. Do nothing if the user already removed it.
1206 if test -f "$destdir/$g"; then
1208 echo "Removing file $g (backup in ${g}~)"
1209 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1211 echo "Remove file $g (backup in ${g}~)"
1215 # func_add_or_update handles a file that ought to be present afterwards.
1216 # Uses parameters f, g, already_present.
1217 func_add_or_update ()
1219 func_dest_tmpfilename "$g"
1220 cp "$gnulib_dir/$f" "$tmpfile" || func_fatal_error "failed"
1221 if test -n "$lgpl"; then
1225 sed -e 's/GNU General/GNU Lesser General/g' \
1226 -e 's/version 2\([ ,]\)/version 2.1\1/g' \
1227 < "$gnulib_dir/$f" > "$tmpfile" || func_fatal_error "failed"
1231 if test -f "$destdir/$g"; then
1232 # The file already exists.
1233 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1234 : # The file has not changed.
1238 if test -n "$already_present"; then
1239 echo "Updating file $g (backup in ${g}~)"
1241 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
1243 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1244 if test -n "$symbolic" && cmp "$gnulib_dir/$f" "$tmpfile" > /dev/null; then
1245 func_ln_if_changed "$gnulib_dir/$f" "$destdir/$g"
1247 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1250 if test -n "$already_present"; then
1251 echo "Update file $g (backup in ${g}~)"
1253 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
1259 # Don't protest if the file should be there but isn't: it happens
1260 # frequently that developers don't put autogenerated files into CVS.
1262 echo "Copying file $g"
1263 if test -n "$symbolic" && cmp "$gnulib_dir/$f" "$tmpfile" > /dev/null; then
1264 func_ln_if_changed "$gnulib_dir/$f" "$destdir/$g"
1266 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1274 # Then the files that are in new-files, but not in old-files:
1275 sed_take_last_column='s,^.*'"$delimiter"',,'
1277 for f in `LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_last_column"`; do
1279 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1280 doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
1281 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1282 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1283 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1288 # Then the files that are in new-files and in old-files:
1289 already_present=true
1290 for f in `LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_last_column"`; do
1292 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1293 doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
1294 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1295 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1296 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1302 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
1303 actioncmd="gnulib-tool --import"
1304 actioncmd="$actioncmd --dir=$destdir"
1305 actioncmd="$actioncmd --lib=$libname"
1306 actioncmd="$actioncmd --source-base=$sourcebase"
1307 actioncmd="$actioncmd --m4-base=$m4base"
1308 actioncmd="$actioncmd --doc-base=$docbase"
1309 actioncmd="$actioncmd --aux-dir=$auxdir"
1310 for module in $avoidlist; do
1311 actioncmd="$actioncmd --avoid=$module"
1313 if test -n "$lgpl"; then
1314 actioncmd="$actioncmd --lgpl"
1316 if test -n "$libtool"; then
1317 actioncmd="$actioncmd --libtool"
1319 actioncmd="$actioncmd --macro-prefix=$macro_prefix"
1320 actioncmd="$actioncmd --assume-autoconf=$autoconf_minversion"
1321 actioncmd="$actioncmd `echo $specified_modules`"
1323 # Create lib/Makefile.am.
1324 func_dest_tmpfilename $sourcebase/Makefile.am
1325 func_emit_lib_Makefile_am > "$tmpfile"
1326 if test -f "$destdir"/$sourcebase/Makefile.am; then
1327 if cmp "$destdir"/$sourcebase/Makefile.am "$tmpfile" > /dev/null; then
1331 echo "Updating $sourcebase/Makefile.am (backup in $sourcebase/Makefile.am~)"
1332 mv -f "$destdir"/$sourcebase/Makefile.am "$destdir"/$sourcebase/Makefile.am~
1333 mv -f "$tmpfile" "$destdir"/$sourcebase/Makefile.am
1335 echo "Update $sourcebase/Makefile.am (backup in $sourcebase/Makefile.am~)"
1341 echo "Creating $sourcebase/Makefile.am"
1342 mv -f "$tmpfile" "$destdir"/$sourcebase/Makefile.am
1344 echo "Create $sourcebase/Makefile.am"
1349 # Create m4/gnulib-cache.m4.
1350 func_dest_tmpfilename $m4base/gnulib-cache.m4
1352 func_emit_copyright_notice
1354 echo "# This file represents the specification of how gnulib-tool is used."
1355 echo "# It acts as a cache: It is written and read by gnulib-tool."
1356 echo "# In projects using CVS, this file is meant to be stored in CVS,"
1357 echo "# like the configure.ac and various Makefile.am files."
1360 echo "# Specification in the form of a command-line invocation:"
1363 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
1364 echo "gl_MODULES(["`echo $specified_modules`"])"
1365 echo "gl_AVOID([$avoidlist])"
1366 echo "gl_SOURCE_BASE([$sourcebase])"
1367 echo "gl_M4_BASE([$m4base])"
1368 echo "gl_DOC_BASE([$docbase])"
1369 echo "gl_TESTS_BASE([$testsbase])"
1370 echo "gl_LIB([$libname])"
1371 test -z "$lgpl" || echo "gl_LGPL"
1372 test -z "$libtool" || echo "gl_LIBTOOL"
1373 echo "gl_MACRO_PREFIX([$macro_prefix])"
1374 echo "gl_AUTOCONF_MINVERSION([$autoconf_minversion])"
1376 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1377 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
1381 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1382 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
1383 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
1385 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1389 echo "# gnulib-cache.m4 ends here"
1396 echo "Creating $m4base/gnulib-cache.m4"
1397 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
1399 echo "Create $m4base/gnulib-cache.m4"
1405 # Create m4/gnulib-comp.m4.
1406 func_dest_tmpfilename $m4base/gnulib-comp.m4
1408 func_emit_copyright_notice
1410 echo "# This file represents the compiled summary of the specification in"
1411 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
1412 echo "# to be invoked from configure.ac."
1413 echo "# In projects using CVS, this file can be treated like other built files."
1416 echo "# This macro should be invoked from $configure_ac, in the section"
1417 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
1418 echo "# any checks for libraries, header files, types and library functions."
1419 echo "AC_DEFUN([${macro_prefix}_EARLY],"
1421 echo " AC_REQUIRE([AC_PROG_RANLIB])"
1422 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1423 echo " AC_REQUIRE([AC_GNU_SOURCE])"
1425 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1426 echo " AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])"
1428 if grep gl_LOCK "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1429 echo " AC_REQUIRE([gl_LOCK])"
1433 echo "# This macro should be invoked from $configure_ac, in the section"
1434 echo "# \"Check for header files, types and library functions\"."
1435 echo "AC_DEFUN([${macro_prefix}_INIT],"
1437 if test -z "$libtool"; then
1438 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1440 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1442 if test "$auxdir" != "build-aux"; then
1443 sed_replace_build_aux='
1445 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
1446 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
1449 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
1451 sed_replace_build_aux=
1453 for module in $modules; do
1455 if test -n "$module"; then
1456 func_get_autoconf_snippet "$module" \
1457 | sed -e '/^$/d;' -e 's/^/ /' \
1458 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
1459 -e "$sed_replace_build_aux"
1460 if test "$module" = 'alloca' && test -n "$libtool"; then
1461 echo 'changequote(,)dnl'
1462 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
1463 echo 'changequote([, ])dnl'
1464 echo 'AC_SUBST([LTALLOCA])'
1470 echo "# This macro records the list of files which have been installed by"
1471 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
1472 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
1473 echo "$files" | sed -e 's,^, ,'
1476 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1477 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
1481 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1482 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
1483 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
1485 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1489 echo "# gnulib-comp.m4 ends here"
1496 echo "Creating $m4base/gnulib-comp.m4"
1497 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
1499 echo "Create $m4base/gnulib-comp.m4"
1505 if test -n "$inctests"; then
1506 # Create tests/Makefile.am.
1507 func_dest_tmpfilename $testsbase/Makefile.am
1508 func_emit_tests_Makefile_am > "$tmpfile"
1509 if test -f "$destdir"/$testsbase/Makefile.am; then
1510 if cmp "$destdir"/$testsbase/Makefile.am "$tmpfile" > /dev/null; then
1514 echo "Updating $testsbase/Makefile.am (backup in $testsbase/Makefile.am~)"
1515 mv -f "$destdir"/$testsbase/Makefile.am "$destdir"/$testsbase/Makefile.am~
1516 mv -f "$tmpfile" "$destdir"/$testsbase/Makefile.am
1518 echo "Update $testsbase/Makefile.am (backup in $testsbase/Makefile.am~)"
1524 echo "Creating $testsbase/Makefile.am"
1525 mv -f "$tmpfile" "$destdir"/$testsbase/Makefile.am
1527 echo "Create $testsbase/Makefile.am"
1534 # Undo the effect of the previous 'trap' command. Some shellology:
1535 # We cannot use "trap - 0 1 2 3 15", because Solaris sh would attempt to
1536 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
1537 # exit); for the others we need to call 'exit' explicitly. The value of $? is
1538 # 128 + signal number and is set before the trap-registered command is run.
1540 trap 'exit $?' 1 2 3 15
1544 echo "You may need to add #include directives for the following .h files."
1546 # First the #include <...> directives without #ifs, sorted for convenience.
1547 for module in $modules; do
1548 if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
1551 func_get_include_directive "$module" | grep -v 'include "'
1553 done | LC_ALL=C sort -u
1554 # Then the #include "..." directives without #ifs, sorted for convenience.
1555 for module in $modules; do
1556 if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
1559 func_get_include_directive "$module" | grep 'include "'
1561 done | LC_ALL=C sort -u
1562 # Then the #include directives that are surrounded by #ifs. Not sorted.
1563 for module in $modules; do
1564 if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
1565 func_get_include_directive "$module"
1568 ) | sed -e '/^$/d;' -e 's/^/ /'
1570 echo "Don't forget to"
1571 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1572 if test -n "$inctests"; then
1573 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1575 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
1576 sourcebase_base=`basename "$sourcebase"`
1577 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
1578 if test -n "$inctests"; then
1579 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
1580 testsbase_base=`basename "$testsbase"`
1581 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
1583 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
1584 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
1585 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
1588 # func_create_testdir testdir modules
1590 # - auxdir directory relative to destdir where to place build aux files
1591 func_create_testdir ()
1595 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
1597 # Determine final module list.
1598 func_modules_transitive_closure
1599 echo "Module list with included dependencies:"
1600 echo "$modules" | sed -e 's/^/ /'
1602 # Add the dummy module if needed.
1603 func_modules_add_dummy
1605 # Determine final file list.
1606 func_modules_to_filelist
1608 echo "$files" | sed -e 's/^/ /'
1610 # Create directories.
1611 for d in `echo "$files" | sed -n -e 's,^\(.*\)/[^/]*,\1,p'`; do
1612 if test "$d" = build-aux; then
1613 mkdir -p "$testdir/$auxdir"
1615 mkdir -p "$testdir/$d"
1619 # Copy files or make symbolic links.
1622 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1625 ln "$gnulib_dir/$f" "$testdir/$g" 2>/dev/null ||
1626 if test -z "$symbolic"; then
1627 cp -p "$gnulib_dir/$f" "$testdir/$g"
1629 ln -s "$gnulib_dir/$f" "$testdir/$g"
1633 # Create lib/Makefile.am.
1634 mkdir -p "$testdir/lib"
1635 func_emit_lib_Makefile_am > "$testdir/lib/Makefile.am"
1637 # Create m4/Makefile.am.
1638 mkdir -p "$testdir/m4"
1639 (echo "## Process this file with automake to produce Makefile.in."
1645 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
1648 ) > "$testdir/m4/Makefile.am"
1651 subdirs_with_configure_ac=""
1653 if test -f "$testdir"/m4/gettext.m4; then
1654 # Avoid stupid error message from automake:
1655 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
1656 mkdir -p "$testdir/po"
1657 (echo "## Process this file with automake to produce Makefile.in."
1658 ) > "$testdir/po/Makefile.am"
1659 subdirs="$subdirs po"
1662 if test -n "$inctests"; then
1663 test -d "$testdir/tests" || mkdir "$testdir/tests"
1664 # Create tests/Makefile.am.
1668 func_emit_tests_Makefile_am > "$testdir/tests/Makefile.am"
1669 # Create tests/configure.ac.
1670 (echo "# Process this file with autoconf to produce a configure script."
1671 echo "AC_INIT([dummy], [0])"
1672 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
1673 echo "AM_INIT_AUTOMAKE"
1675 echo "AM_CONFIG_HEADER([config.h])"
1678 echo "AC_PROG_INSTALL"
1679 echo "AC_PROG_MAKE_SET"
1680 echo "AC_PROG_RANLIB"
1682 if grep AC_GNU_SOURCE "$testdir"/m4/*.m4 >/dev/null 2>/dev/null; then
1683 echo "AC_GNU_SOURCE"
1686 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir"/m4/*.m4 >/dev/null 2>/dev/null; then
1687 echo "gl_USE_SYSTEM_EXTENSIONS"
1690 if grep gl_LOCK "$testdir"/m4/*.m4 >/dev/null 2>/dev/null; then
1694 if test -z "$libtool"; then
1695 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1697 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1699 if test "$auxdir" != "build-aux"; then
1700 sed_replace_build_aux='
1702 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
1703 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
1706 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
1708 sed_replace_build_aux=
1710 # We don't have explicit ordering constraints between the various
1711 # autoconf snippets. It's cleanest to put those of the library before
1712 # those of the tests.
1713 for module in $modules; do
1714 func_verify_nontests_module
1715 if test -n "$module"; then
1716 func_get_autoconf_snippet "$module" \
1717 | sed -e "$sed_replace_build_aux"
1720 for module in $modules; do
1721 func_verify_tests_module
1722 if test -n "$module"; then
1723 func_get_autoconf_snippet "$module" \
1724 | sed -e "$sed_replace_build_aux"
1728 # Usually tests/config.h will be a superset of config.h. Verify this by
1729 # "merging" config.h into tests/config.h; look out for gcc warnings.
1730 echo "AH_TOP([#include \"../config.h\"])"
1732 echo "AC_OUTPUT([Makefile])"
1733 ) > "$testdir/tests/configure.ac"
1734 subdirs="$subdirs tests"
1735 subdirs_with_configure_ac="$subdirs_with_configure_ac tests"
1738 # Create Makefile.am.
1739 (echo "## Process this file with automake to produce Makefile.in."
1741 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1743 echo "SUBDIRS = $subdirs"
1745 echo "ACLOCAL_AMFLAGS = -I m4"
1746 ) > "$testdir/Makefile.am"
1748 # Create configure.ac.
1749 (echo "# Process this file with autoconf to produce a configure script."
1750 echo "AC_INIT([dummy], [0])"
1751 if test "$auxdir" != "."; then
1752 echo "AC_CONFIG_AUX_DIR([$auxdir])"
1754 echo "AM_INIT_AUTOMAKE"
1756 echo "AM_CONFIG_HEADER([config.h])"
1759 echo "AC_PROG_INSTALL"
1760 echo "AC_PROG_MAKE_SET"
1761 echo "AC_PROG_RANLIB"
1763 if grep AC_GNU_SOURCE "$testdir"/m4/*.m4 >/dev/null 2>/dev/null; then
1764 echo "AC_GNU_SOURCE"
1767 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir"/m4/*.m4 >/dev/null 2>/dev/null; then
1768 echo "gl_USE_SYSTEM_EXTENSIONS"
1771 if grep gl_LOCK "$testdir"/m4/*.m4 >/dev/null 2>/dev/null; then
1775 if test -z "$libtool"; then
1776 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1778 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1780 if test "$auxdir" != "build-aux"; then
1781 sed_replace_build_aux='
1783 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
1784 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
1787 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
1789 sed_replace_build_aux=
1791 for module in $modules; do
1792 func_verify_nontests_module
1793 if test -n "$module"; then
1794 func_get_autoconf_snippet "$module" \
1795 | sed -e "$sed_replace_build_aux"
1799 if test -n "$subdirs_with_configure_ac"; then
1800 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
1802 makefiles="Makefile"
1803 for d in $subdirs; do
1804 # For subdirs that have a configure.ac by their own, it's the subdir's
1805 # configure.ac which creates the subdir's Makefile.am, not this one.
1806 case " $subdirs_with_configure_ac " in
1808 *) makefiles="$makefiles $d/Makefile" ;;
1811 echo "AC_OUTPUT([$makefiles])"
1812 ) > "$testdir/configure.ac"
1814 # Create autogenerated files.
1816 echo "executing ${AUTORECONF} --force --install"
1817 ${AUTORECONF} --force --install
1819 if grep '^BUILT_SOURCES *+=' "$testdir/lib/Makefile.am" > /dev/null; then
1823 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
1831 # func_create_megatestdir megatestdir allmodules
1833 # - auxdir directory relative to destdir where to place build aux files
1834 func_create_megatestdir ()
1838 if test -z "$allmodules"; then
1839 allmodules=`func_all_modules`
1843 # First, all modules one by one.
1844 for onemodule in $allmodules; do
1845 func_create_testdir "$megatestdir/$onemodule" $onemodule
1846 megasubdirs="${megasubdirs}$onemodule "
1848 # Then, all modules all together.
1849 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
1850 allmodules=`for m in $allmodules; do if test $m != fnmatch-posix; then echo $m; fi; done`
1851 func_create_testdir "$megatestdir/ALL" "$allmodules"
1852 megasubdirs="${megasubdirs}ALL"
1854 # Create Makefile.am.
1855 (echo "## Process this file with automake to produce Makefile.in."
1857 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1859 echo "SUBDIRS = $megasubdirs"
1860 ) > "$megatestdir/Makefile.am"
1862 # Create configure.ac.
1863 (echo "# Process this file with autoconf to produce a configure script."
1864 echo "AC_INIT([dummy], [0])"
1865 if test "$auxdir" != "."; then
1866 echo "AC_CONFIG_AUX_DIR([$auxdir])"
1868 echo "AM_INIT_AUTOMAKE"
1870 echo "AC_PROG_MAKE_SET"
1872 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
1873 echo "AC_OUTPUT([Makefile])"
1874 ) > "$megatestdir/configure.ac"
1876 # Create autogenerated files.
1878 # Do not use "${AUTORECONF} --install", because autoreconf operates
1879 # recursively, but the subdirectories are already finished, therefore
1880 # calling autoreconf here would only waste lots of CPU time.
1881 echo "executing ${ACLOCAL}"
1883 echo "executing mkdir build-aux"
1885 echo "executing ${AUTOCONF}"
1887 echo "executing ${AUTOMAKE} --add-missing --copy"
1888 ${AUTOMAKE} --add-missing --copy
1894 func_fatal_error "no mode specified" ;;
1903 if test -z "$destdir"; then
1906 test -d "$destdir" \
1907 || func_fatal_error "destination directory does not exist: $destdir"
1909 # Prefer configure.ac to configure.in.
1910 if test -f "$destdir"/configure.ac; then
1911 configure_ac="$destdir/configure.ac"
1913 if test -f "$destdir"/configure.in; then
1914 configure_ac="$destdir/configure.in"
1916 func_fatal_error "cannot find $destdir/configure.ac"
1920 test -f "$destdir"/Makefile.am \
1921 || func_fatal_error "cannot find $destdir/Makefile.am"
1923 # Analyze configure.ac.
1930 /AC_CONFIG_AUX_DIR/ {
1931 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
1933 /A[CM]_PROG_LIBTOOL/ {
1934 s,^.*$,guessed_libtool=true,p
1936 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
1938 if test -z "$auxdir"; then
1939 auxdir="$guessed_auxdir"
1942 # Determine where to apply func_import.
1943 if test -n "$m4base"; then
1944 # Apply func_import to a particular gnulib directory.
1945 # Any number of additional modules can be given.
1946 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
1947 # First use of gnulib in the given m4base.
1948 test -n "$supplied_libname" || supplied_libname=true
1949 test -n "$sourcebase" || sourcebase="lib"
1950 test -n "$docbase" || docbase="doc"
1951 test -n "$testsbase" || testsbase="tests"
1952 test -n "$macro_prefix" || macro_prefix="gl"
1953 test -n "$autoconf_minversion" || autoconf_minversion="$DEFAULT_AUTOCONF_MINVERSION"
1957 # Apply func_import to all gnulib directories.
1958 # To get this list of directories, look at Makefile.am. (Not at
1959 # configure, because it may be omitted from CVS. Also, don't run
1960 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
1961 aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$destdir"/Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'`
1965 for arg in $aclocal_amflags; do
1966 if test -n "$m4dir_is_next"; then
1967 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
1971 if test -f "$destdir/$arg"/gnulib-cache.m4; then
1972 m4dirs="$m4dirs $arg"
1973 m4dirs_count=`expr $m4dirs_count + 1`
1978 if test "X$arg" = "X-I"; then
1985 if test $m4dirs_count = 0; then
1986 # First use of gnulib in a package.
1987 # Any number of additional modules can be given.
1988 test -n "$supplied_libname" || supplied_libname=true
1989 test -n "$sourcebase" || sourcebase="lib"
1991 test -n "$docbase" || docbase="doc"
1992 test -n "$testsbase" || testsbase="tests"
1993 test -n "$macro_prefix" || macro_prefix="gl"
1994 test -n "$autoconf_version" || autoconf_version="$DEFAULT_AUTOCONF_MINVERSION"
1997 if test $m4dirs_count = 1; then
1998 # There's only one use of gnulib here. Assume the user means it.
1999 # Any number of additional modules can be given.
2000 for m4base in $m4dirs; do
2004 # Ambiguous - guess what the user meant.
2005 if test $# = 0; then
2006 # No further arguments. Guess the user wants to update all of them.
2007 for m4base in $m4dirs; do
2012 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
2020 if test -z "$destdir"; then
2021 func_fatal_error "please specify --dir option"
2024 test -d "$destdir" \
2025 || func_fatal_error "could not create destination directory"
2026 test -n "$auxdir" || auxdir="build-aux"
2027 func_create_testdir "$destdir" "$*"
2030 create-megatestdir )
2031 if test -z "$destdir"; then
2032 func_fatal_error "please specify --dir option"
2034 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2035 test -n "$auxdir" || auxdir="build-aux"
2036 func_create_megatestdir "$destdir" "$*"
2040 test -n "$destdir" || destdir=testdir$$
2041 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2042 test -n "$auxdir" || auxdir="build-aux"
2043 func_create_testdir "$destdir" "$*"
2051 remaining=`find . -type f -print`
2052 if test -n "$remaining"; then
2053 echo "Remaining files:" $remaining 1>&2
2054 echo "gnulib-tool: *** Stop." 1>&2
2063 test -n "$destdir" || destdir=testdir$$
2064 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2065 test -n "$auxdir" || auxdir="build-aux"
2066 func_create_megatestdir "$destdir" "$*"
2074 remaining=`find . -type f -print`
2075 if test -n "$remaining"; then
2076 echo "Remaining files:" $remaining 1>&2
2077 echo "gnulib-tool: *** Stop." 1>&2
2085 extract-description )
2089 if test -n "$module"; then
2090 func_get_description "$module"
2099 if test -n "$module"; then
2100 func_get_filelist "$module"
2105 extract-dependencies )
2109 if test -n "$module"; then
2110 func_get_dependencies "$module"
2115 extract-autoconf-snippet )
2119 if test -n "$module"; then
2120 func_get_autoconf_snippet "$module"
2125 extract-automake-snippet )
2129 if test -n "$module"; then
2130 func_get_automake_snippet "$module"
2135 extract-include-directive )
2139 if test -n "$module"; then
2140 func_get_include_directive "$module"
2149 if test -n "$module"; then
2150 func_get_license "$module"
2155 extract-maintainer )
2159 if test -n "$module"; then
2160 func_get_maintainer "$module"
2165 extract-tests-module )
2169 if test -n "$module"; then
2170 func_get_tests_module "$module"
2176 func_fatal_error "unknown operation mode --$mode" ;;