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 14:51:57 $'
26 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
27 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
29 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
33 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
34 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
38 # 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 --avoid=MODULE Avoid including the given MODULE. Useful if you
107 have code that provides equivalent functionality.
108 This option can be repeated.
109 --dry-run For --import, only print what would have been done.
110 --lgpl Abort if modules aren't available under the LGPL.
111 Also modify license template from GPL to LGPL.
112 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
113 --libtool Use libtool rules, for --import.
114 --macro-prefix=PREFIX Specify the prefix of the macros gl_EARLY and
115 gl_INIT. Default is "gl".
116 --no-changelog don't update or create ChangeLog files
117 -s, --symbolic, --symlink Make symbolic links instead of copying files.
118 --with-tests Include unit tests for the included modules.
121 --dir=DIRECTORY specify the target directory
122 For --import, this specifies where your
123 configure.ac can be found. Defaults to current
125 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
126 tools are placed (default \"build-aux\").
127 --doc-base=DIRECTORY Directory relative to --dir where doc files are
128 placed (default \"doc\"), for --import.
129 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
130 placed (default \"m4\"), for --import.
131 --source-base=DIRECTORY Directory relative to --dir where source code is
132 placed (default \"lib\"), for --import.
133 --tests-base=DIRECTORY Directory relative to --dir where unit tests are
134 placed (default \"tests\"), for --import.
136 Report bugs to <bug-gnulib@gnu.org>."
140 # outputs to stdout the --version message.
143 year=`echo "$last_checkin_date" | sed -e 's,/.*$,,'`
144 echo "$progname (GNU $package) $version"
145 echo "Copyright (C) $year Free Software Foundation, Inc.
146 This is free software; see the source for copying conditions. There is NO
147 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
148 echo "Written by" "Bruno Haible" "and" "Simon Josefsson"
151 # func_emit_copyright_notice
152 # outputs to stdout a header for a generated file.
153 func_emit_copyright_notice ()
155 echo "# Copyright (C) 2004-2006 Free Software Foundation, Inc."
157 echo "# This file is free software, distributed under the terms of the GNU"
158 echo "# General Public License. As a special exception to the GNU General"
159 echo "# Public License, this file may be distributed as part of a program"
160 echo "# that contains a configuration script generated by Autoconf, under"
161 echo "# the same distribution terms as the rest of that program."
163 echo "# Generated by gnulib-tool."
167 # creates a temporary directory.
169 # - tmp pathname of freshly created temporary directory
172 # Use the environment variable TMPDIR, falling back to /tmp. This allows
173 # users to specify a different temporary directory, for example, if their
174 # /tmp is filled up or too small.
177 # Use the mktemp program if available. If not available, hide the error
179 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
180 test -n "$tmp" && test -d "$tmp"
183 # Use a simple mkdir command. It is guaranteed to fail if the directory
184 # already exists. $RANDOM is bash specific and expands to empty in shells
185 # other than bash, ksh and zsh. Its use does not increase security;
186 # rather, it minimizes the probability of failure in a very cluttered /tmp
188 tmp=$TMPDIR/gl$$-$RANDOM
189 (umask 077 && mkdir "$tmp")
192 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
193 { (exit 1); exit 1; }
197 # func_fatal_error message
198 # outputs to stderr a fatal error message, and terminates the program.
201 echo "gnulib-tool: *** $1" 1>&2
202 echo "gnulib-tool: *** Stop." 1>&2
206 # func_readlink SYMLINK
207 # outputs the target of the given symlink.
208 if (type -p readlink) > /dev/null 2>&1; then
211 # Use the readlink program from GNU coreutils.
217 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
218 # would do the wrong thing if the link target contains " -> ".
219 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
223 # func_ln_if_changed SRC DEST
224 # Like ln -s, but avoids munging timestamps if the link is correct.
225 func_ln_if_changed ()
227 if test $# -ne 2; then
228 echo "usage: func_ln_if_changed SRC DEST" >&2
230 if test -L "$2" && test "$1" = "`func_readlink "$2"`"; then
238 # Command-line option processing.
239 # Removes the OPTIONS from the arguments. Sets the variables:
240 # - mode list or import or create-testdir or create-megatestdir
241 # - destdir from --dir
242 # - libname, supplied_libname from --lib
243 # - sourcebase from --source-base
244 # - m4base from --m4-base
245 # - docbase from --doc-base
246 # - testsbase from --tests-base
247 # - auxdir from --aux-dir
248 # - inctests true if --with-tests was given, blank otherwise
249 # - avoidlist list of modules to avoid, from --avoid
250 # - lgpl true if --lgpl was given, blank otherwise
251 # - libtool true if --libtool was given, blank otherwise
252 # - macro_prefix from --macro-prefix
253 # - autoconf_minversion minimum supported autoconf version
254 # - do_changelog false if --no-changelog was given, : otherwise
255 # - doit : if actions shall be executed, false if only to be printed
278 while test $# -gt 0; do
283 --import | --impor | --impo | --imp | --im | --i )
286 --update | --updat | --upda | --upd | --up | --u )
289 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
292 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
293 mode=create-megatestdir
295 --test | --tes | --te | --t )
298 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
302 mode=`echo "X$1" | sed -e 's/^X--//'`
307 func_fatal_error "missing argument for --dir"
312 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
317 func_fatal_error "missing argument for --lib"
320 supplied_libname=true
323 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
324 supplied_libname=true
329 func_fatal_error "missing argument for --source-base"
334 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
339 func_fatal_error "missing argument for --m4-base"
344 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
349 func_fatal_error "missing argument for --doc-base"
354 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
359 func_fatal_error "missing argument for --tests-base"
364 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
369 func_fatal_error "missing argument for --aux-dir"
374 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
382 func_fatal_error "missing argument for --avoid"
384 avoidlist="$avoidlist $1"
387 avoidlist="$avoidlist "`echo "X$1" | sed -e 's/^X--avoid=//'`
398 func_fatal_error "missing argument for --macro-prefix"
403 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
408 func_fatal_error "missing argument for --assume-autoconf"
410 autoconf_minversion="$1"
412 --assume-autoconf=* )
413 autoconf_minversion=`echo "X$1" | sed -e 's/^X--assume-autoconf=//'`
415 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
421 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
424 --help | --hel | --he | --h )
427 --version | --versio | --versi | --vers | --ver | --ve | --v )
431 # Stop option processing
435 echo "gnulib-tool: unknown option $1" 1>&2
436 echo "Try 'gnulib-tool --help' for more information." 1>&2
443 if test "$mode" = update; then
444 if test $# != 0; then
445 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
446 echo "Try 'gnulib-tool --help' for more information." 1>&2
447 echo "If you really want to modify the gnulib configuration of your project," 1>&2
448 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
451 if test -n "$supplied_libname" || test -n "$sourcebase" || test -n "$m4base" \
452 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
453 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
454 || test -n "$macro_prefix" || test -n "$autoconf_minversion"; then
455 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
456 echo "Try 'gnulib-tool --help' for more information." 1>&2
457 echo "If you really want to modify the gnulib configuration of your project," 1>&2
458 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
464 DEFAULT_AUTOCONF_MINVERSION="2.59"
465 case "$autoconf_minversion" in
466 1.* | 2.[0-4]* | 2.5[0-8]*)
467 func_fatal_error "minimum supported autoconf version is 2.59" ;;
470 # Remove trailing slashes from the directory names. This is necessary for
471 # m4base (to avoid an error in func_import) and optional for the others.
472 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
473 case "$sourcebase" in
474 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
477 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
480 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
483 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
486 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
491 /*) self_abspathname="$0" ;;
492 */*) self_abspathname=`pwd`/"$0" ;;
493 *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
494 if test -x "$d/$0" && test ! -d "$d/$0"; then
495 self_abspathname="$d/$0"
499 if test -z "$self_abspathname"; then
500 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
504 while test -h "$self_abspathname"; do
505 # Resolve symbolic link.
506 linkval=`func_readlink "$self_abspathname"`
507 test -n "$linkval" || break
509 /* ) self_abspathname="$linkval" ;;
510 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
513 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
518 # Filter out metainformation files like README, which are not modules.
519 # Filter out unit test modules; they can be retrieved through
520 # --extract-tests-module if desired.
521 (cd "$gnulib_dir/modules" && ls -1) \
522 | sed -e '/^CVS$/d' -e '/^ChangeLog$/d' -e '/^README$/d' -e '/^TEMPLATE$/d' -e '/^TEMPLATE-TESTS$/d' -e '/~$/d' \
523 | sed -e '/-tests$/d' \
528 # verifies a module name
529 func_verify_module ()
531 if test ! -f "$gnulib_dir/modules/$module" \
532 || test "CVS" = "$module" \
533 || test "ChangeLog" = "$module" \
534 || test "README" = "$module" \
535 || test "TEMPLATE" = "$module" \
536 || test "TEMPLATE-TESTS" = "$module"; then
537 echo "gnulib-tool: module $module doesn't exist" 1>&2
542 # func_verify_nontests_module
543 # verifies a module name, excluding tests modules
544 func_verify_nontests_module ()
548 * ) func_verify_module ;;
552 # func_verify_tests_module
553 # verifies a module name, considering only tests modules
554 func_verify_tests_module ()
557 *-tests ) func_verify_module ;;
562 sed_extract_prog=':[ ]*$/ {
565 s/^Description:[ ]*$//
567 s/^Depends-on:[ ]*$//
568 s/^configure\.ac:[ ]*$//
569 s/^Makefile\.am:[ ]*$//
572 s/^Maintainer:[ ]*$//
579 # func_get_description module
580 func_get_description ()
582 sed -n -e "/^Description$sed_extract_prog" < "$gnulib_dir/modules/$1"
585 # func_get_filelist module
588 sed -n -e "/^Files$sed_extract_prog" < "$gnulib_dir/modules/$1"
589 case "$autoconf_minversion" in
592 echo m4/onceonly_2_57.m4
597 # func_get_dependencies module
598 func_get_dependencies ()
600 # ${module}-tests always implicitly depends on ${module}.
601 echo "$1" | sed -n -e 's/-tests//p'
602 # Then the explicit dependencies listed in the module description.
603 sed -n -e "/^Depends-on$sed_extract_prog" < "$gnulib_dir/modules/$1"
606 # func_get_autoconf_snippet module
607 func_get_autoconf_snippet ()
609 sed -n -e "/^configure\.ac$sed_extract_prog" < "$gnulib_dir/modules/$1"
612 # func_get_automake_snippet module
613 func_get_automake_snippet ()
615 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$gnulib_dir/modules/$1"
618 # func_get_include_directive module
619 func_get_include_directive ()
621 sed -n -e "/^Include$sed_extract_prog" < "$gnulib_dir/modules/$1" | \
622 sed -e 's/^\(["<]\)/#include \1/'
625 # func_get_license module
628 sed -n -e "/^License$sed_extract_prog" < "$gnulib_dir/modules/$1"
631 # func_get_maintainer module
632 func_get_maintainer ()
634 sed -n -e "/^Maintainer$sed_extract_prog" < "$gnulib_dir/modules/$1"
637 # func_get_tests_module module
638 func_get_tests_module ()
640 # The naming convention for tests modules is hardwired: ${module}-tests.
641 if test -f modules/"$1"-tests; then
646 # func_acceptable module
647 # tests whether a module is acceptable.
649 # - avoidlist list of modules to avoid
652 for avoid in $avoidlist; do
653 if test "$avoid" = "$1"; then
660 # func_modules_transitive_closure
662 # - modules list of specified modules
663 # - inctests true if tests should be included, blank otherwise
664 # - avoidlist list of modules to avoid
666 # - modules list of modules, including dependencies
667 func_modules_transitive_closure ()
671 for module in $modules; do
673 if test -n "$module"; then
674 # Duplicate dependencies are harmless, but Jim wants a warning.
675 duplicated_deps=`func_get_dependencies $module | LC_ALL=C sort | LC_ALL=C uniq -d`
676 if test -n "$duplicated_deps"; then
677 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
679 if func_acceptable $module; then
680 xmodules="$xmodules $module"
681 for depmodule in `func_get_dependencies $module`; do
682 if func_acceptable $depmodule; then
683 xmodules="$xmodules $depmodule"
686 if test -n "$inctests"; then
687 testsmodule=`func_get_tests_module $module`
688 if test -n "$testsmodule"; then
689 if func_acceptable $testsmodule; then
690 xmodules="$xmodules $testsmodule"
691 for depmodule in `func_get_dependencies $testsmodule`; do
692 if func_acceptable $depmodule; then
693 xmodules="$xmodules $depmodule"
702 xmodules=`for m in $xmodules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
703 if test "$xmodules" = "$modules"; then
710 # func_modules_add_dummy
712 # - modules list of modules, including dependencies
714 # - modules list of modules, including 'dummy' if needed
715 func_modules_add_dummy ()
718 sed_remove_backslash_newline=':a
725 for module in $modules; do
726 func_verify_nontests_module
727 if test -n "$module"; then
728 # Extract the value of "lib_SOURCES += ...".
729 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
730 # Ignore .h files since they are not compiled.
733 *) have_lib_SOURCES=yes ;;
738 # Add the dummy module, to make sure the library will be non-empty.
739 if test -z "$have_lib_SOURCES"; then
740 modules="$modules dummy"
744 # func_modules_to_filelist
746 # - modules list of modules, including dependencies
748 # - files list of files
749 func_modules_to_filelist ()
752 for module in $modules; do
754 if test -n "$module"; then
755 files="$files "`func_get_filelist $module`
758 files=`for f in $files; do echo $f; done | LC_ALL=C sort | LC_ALL=C uniq`
761 # func_emit_lib_Makefile_am
762 # emits the contents of lib/Makefile.am to standard output.
764 # - modules list of modules, including dependencies
765 # - libname library name
766 # - libtool true if libtool will be used, blank otherwise
767 # - actioncmd (optional) command that will reproduce this invocation
768 func_emit_lib_Makefile_am ()
770 if test -n "$libtool"; then
777 echo "## Process this file with automake to produce Makefile.in."
778 func_emit_copyright_notice
779 if test -n "$actioncmd"; then
780 echo "# Reproduce by: $actioncmd"
783 # No need to generate dependencies since the sources are in gnulib, not here.
784 echo "AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies"
786 echo "noinst_${perhapsLT}LIBRARIES = $libname.$libext"
788 echo "${libname}_${libext}_SOURCES ="
789 echo "${libname}_${libext}_LIBADD = @${perhapsLT}LIBOBJS@"
790 echo "noinst_HEADERS ="
792 echo "BUILT_SOURCES ="
794 echo "MOSTLYCLEANFILES ="
795 echo "MOSTLYCLEANDIRS ="
797 echo "DISTCLEANFILES ="
798 echo "MAINTAINERCLEANFILES ="
802 for module in $modules; do
803 func_verify_nontests_module
804 if test -n "$module"; then
806 func_get_automake_snippet "$module" |
807 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g'
808 if test "$module" = 'alloca'; then
809 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
812 # Skip the contents if its entirely empty.
813 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
814 echo "## begin gnulib module $module"
817 echo "## end gnulib module $module"
824 echo "mostlyclean-local:"
825 echo " @test -z \"\$(MOSTLYCLEANDIRS)\" || \\"
826 echo " for dir in \$(MOSTLYCLEANDIRS); do \\"
827 echo " if test -d \$\$dir; then \\"
828 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
832 echo "# Makefile.am ends here"
835 # func_emit_tests_Makefile_am
836 # emits the contents of tests/Makefile.am to standard output.
838 # - modules list of modules, including dependencies
839 # - libname library name
840 # - libtool true if libtool will be used, blank otherwise
841 # - sourcebase relative directory containing lib source code
842 # - m4base relative directory containing autoconf macros
843 # - testsbase relative directory containing unit test code
844 func_emit_tests_Makefile_am ()
846 if test -n "$libtool"; then
851 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
852 echo "## Process this file with automake to produce Makefile.in."
853 func_emit_copyright_notice
855 # Generate dependencies here, since it eases the debugging of test failures.
856 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
858 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
860 # Nothing is being added to SUBDIRS; nevertheless the existence of this
861 # variable is needed to avoid an error from automake:
862 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
865 echo "TESTS_ENVIRONMENT ="
866 echo "noinst_PROGRAMS ="
867 echo "check_PROGRAMS ="
868 echo "noinst_HEADERS ="
870 echo "BUILT_SOURCES ="
872 echo "MOSTLYCLEANFILES ="
873 echo "MOSTLYCLEANDIRS ="
875 echo "DISTCLEANFILES ="
876 echo "MAINTAINERCLEANFILES ="
878 echo "AM_CPPFLAGS = \\"
879 echo " -I. -I\$(srcdir) \\"
880 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
881 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
883 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
885 for module in $modules; do
886 func_verify_tests_module
887 if test -n "$module"; then
888 func_get_automake_snippet "$module" > amsnippet.tmp
889 # Skip the contents if its entirely empty.
890 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
891 echo "## begin gnulib module $module"
894 echo "## end gnulib module $module"
900 echo "# Clean up after Solaris cc."
902 echo " rm -rf SunWS_cache"
904 echo "mostlyclean-local:"
905 echo " @test -z \"\$(MOSTLYCLEANDIRS)\" || \\"
906 echo " for dir in \$(MOSTLYCLEANDIRS); do \\"
907 echo " if test -d \$\$dir; then \\"
908 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
912 echo "# Makefile.am ends here"
915 # func_import modules
916 # Uses also the variables
917 # - destdir target directory
918 # - libname library name
919 # - sourcebase directory relative to destdir where to place source code
920 # - m4base directory relative to destdir where to place *.m4 macros
921 # - docbase directory relative to destdir where to place doc files
922 # - testsbase directory relative to destdir where to place unit test code
923 # - auxdir directory relative to destdir where to place build aux files
924 # - inctests true if --with-tests was given, blank otherwise
925 # - avoidlist list of modules to avoid, from --avoid
926 # - lgpl true if library's license shall be LGPL, blank otherwise
927 # - libtool true if libtool will be used, blank otherwise
928 # - guessed_libtool true if the configure.ac file uses libtool, blank otherwise
929 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
930 # - autoconf_minversion minimum supported autoconf version
931 # - doit : if actions shall be executed, false if only to be printed
932 # - symbolic true if files should be symlinked, copied otherwise
935 # Get the cached settings.
936 cached_specified_modules=
946 cached_autoconf_minversion=
948 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
954 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
957 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
960 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
963 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
966 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
969 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
972 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
975 s,^.*$,cached_lgpl=true,p
978 s,^.*$,cached_libtool=true,p
981 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
983 /gl_AUTOCONF_MINVERSION(/ {
984 s,^.*gl_AUTOCONF_MINVERSION([[ ]*\([^])]*\).*$,cached_autoconf_minversion="\1",p
986 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
987 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
992 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
993 s,^.*$,cached_files=",p
1005 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1009 # Merge the cached settings with the specified ones.
1010 # The m4base must be the same as expected from the pathname.
1011 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1012 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1014 # Append the cached and the specified module names. So that
1015 # "gnulib-tool --import foo" means to add the module foo.
1016 specified_modules="$cached_specified_modules $1"
1017 # Append the cached and the specified avoidlist. This is probably better
1018 # than dropping the cached one when --avoid is specified at least once.
1019 avoidlist=`echo $cached_avoidlist $avoidlist`
1020 # The sourcebase defaults to the cached one.
1021 if test -z "$sourcebase"; then
1022 sourcebase="$cached_sourcebase"
1023 if test -z "$sourcebase"; then
1024 func_fatal_error "missing --source-base option"
1027 # The docbase defaults to the cached one.
1028 if test -z "$docbase"; then
1029 docbase="$cached_docbase"
1030 if test -z "$docbase"; then
1031 func_fatal_error "missing --doc-base option"
1034 # The testsbase defaults to the cached one.
1035 if test -z "$testsbase"; then
1036 testsbase="$cached_testsbase"
1037 if test -z "$testsbase"; then
1038 func_fatal_error "missing --tests-base option"
1041 # The libname defaults to the cached one.
1042 if test -z "$supplied_libname"; then
1043 libname="$cached_libname"
1044 if test -z "$libname"; then
1045 func_fatal_error "missing --lib option"
1048 # Require LGPL if specified either way.
1049 if test -z "$lgpl"; then
1052 # Use libtool if specified either way, or if guessed.
1053 if test -z "$libtool"; then
1054 if test -n "$cached_m4base"; then
1055 libtool="$cached_libtool"
1057 libtool="$guessed_libtool"
1060 # The macro_prefix defaults to the cached one.
1061 if test -z "$macro_prefix"; then
1062 macro_prefix="$cached_macro_prefix"
1063 if test -z "$macro_prefix"; then
1064 func_fatal_error "missing --macro-prefix option"
1067 # The autoconf_minversion defaults to the cached one.
1068 if test -z "$autoconf_minversion"; then
1069 autoconf_minversion="$cached_autoconf_minversion"
1070 if test -z "$autoconf_minversion"; then
1071 autoconf_minversion="$DEFAULT_AUTOCONF_MINVERSION"
1075 # Canonicalize the list of specified modules.
1076 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
1078 # Determine final module list.
1079 modules="$specified_modules"
1080 func_modules_transitive_closure
1081 echo "Module list with included dependencies:"
1082 echo "$modules" | sed -e 's/^/ /'
1084 # Add the dummy module if needed.
1085 func_modules_add_dummy
1087 # If --lgpl, check the license of modules are compatible.
1088 if test -n "$lgpl"; then
1089 for module in $modules; do
1090 license=`func_get_license $module`
1092 LGPL | 'GPLed build tool' | 'public domain' | 'unlimited') ;;
1093 *) func_fatal_error "incompatible license on module $module: $license" ;;
1098 # Determine final file list.
1099 func_modules_to_filelist
1101 echo "$files" | sed -e 's/^/ /'
1104 || func_fatal_error "refusing to do nothing"
1106 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
1107 new_files="$files m4/gnulib-tool.m4"
1108 old_files="$cached_files"
1109 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
1110 old_files="$old_files m4/gnulib-tool.m4"
1113 # Create directories.
1114 if test ! -d "$destdir/$sourcebase"; then
1116 echo "Creating directory $destdir/$sourcebase"
1117 mkdir "$destdir/$sourcebase" || func_fatal_error "failed"
1119 echo "Create directory $destdir/$sourcebase"
1122 if test ! -d "$destdir/$m4base"; then
1124 echo "Creating directory $destdir/$m4base"
1125 mkdir "$destdir/$m4base" || func_fatal_error "failed"
1127 echo "Create directory $destdir/$m4base"
1130 if test ! -d "$destdir/$docbase"; then
1132 echo "Creating directory $destdir/$docbase"
1133 mkdir "$destdir/$docbase" || func_fatal_error "failed"
1135 echo "Create directory $destdir/$docbase"
1138 if test -n "$inctests"; then
1139 if test ! -d "$destdir/$testsbase"; then
1141 echo "Creating directory $destdir/$testsbase"
1142 mkdir "$destdir/$testsbase" || func_fatal_error "failed"
1144 echo "Create directory $destdir/$testsbase"
1148 if test ! -d "$destdir/$auxdir"; then
1150 echo "Creating directory $destdir/$auxdir"
1151 mkdir "$destdir/$auxdir" || func_fatal_error "failed"
1153 echo "Create directory $destdir/$auxdir"
1158 trap 'rm -rf "$tmp"' 0 1 2 3 15
1159 # func_dest_tmpfilename file
1160 # determines the name of a temporary file (file is relative to destdir).
1162 # - tmpfile absolute filename of the temporary file
1163 func_dest_tmpfilename ()
1166 # Put the new contents of $file in a file in the same directory (needed
1167 # to guarantee that an 'mv' to "$destdir/$file" works).
1168 tmpfile="$destdir/$1.tmp"
1170 # Put the new contents of $file in a file in a temporary directory
1171 # (because the directory of "$file" might not exist).
1172 tmpfile="$tmp"/`basename "$1"`.tmp
1176 # Copy files or make symbolic links. Remove obsolete files.
1178 for f in $old_files; do
1180 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1181 doc/*) g=`echo "$f" | sed -e "s,^doc/,$cached_docbase/,"` ;;
1182 lib/*) g=`echo "$f" | sed -e "s,^lib/,$cached_sourcebase/,"` ;;
1183 m4/*) g=`echo "$f" | sed -e "s,^m4/,$cached_m4base/,"` ;;
1184 tests/*) g=`echo "$f" | sed -e "s,^tests/,$cached_testsbase/,"` ;;
1187 echo "$g""$delimiter""$f"
1188 done | LC_ALL=C sort > "$tmp"/old-files
1189 for f in $new_files; do
1191 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1192 doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
1193 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1194 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1195 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1198 echo "$g""$delimiter""$f"
1199 done | LC_ALL=C sort > "$tmp"/new-files
1200 # First the files that are in old-files, but not in new-files:
1201 sed_take_first_column='s,'"$delimiter"'.*,,'
1202 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
1203 # Remove the file. Do nothing if the user already removed it.
1204 if test -f "$destdir/$g"; then
1206 echo "Removing file $g (backup in ${g}~)"
1207 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1209 echo "Remove file $g (backup in ${g}~)"
1213 # func_add_or_update handles a file that ought to be present afterwards.
1214 # Uses parameters f, g, already_present.
1215 func_add_or_update ()
1217 func_dest_tmpfilename "$g"
1218 cp "$gnulib_dir/$f" "$tmpfile" || func_fatal_error "failed"
1219 if test -n "$lgpl"; then
1223 sed -e 's/GNU General/GNU Lesser General/g' \
1224 -e 's/version 2\([ ,]\)/version 2.1\1/g' \
1225 < "$gnulib_dir/$f" > "$tmpfile" || func_fatal_error "failed"
1229 if test -f "$destdir/$g"; then
1230 # The file already exists.
1231 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1232 : # The file has not changed.
1236 if test -n "$already_present"; then
1237 echo "Updating file $g (backup in ${g}~)"
1239 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
1241 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1242 if test -n "$symbolic" && cmp "$gnulib_dir/$f" "$tmpfile" > /dev/null; then
1243 func_ln_if_changed "$gnulib_dir/$f" "$destdir/$g"
1245 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1248 if test -n "$already_present"; then
1249 echo "Update file $g (backup in ${g}~)"
1251 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
1257 # Don't protest if the file should be there but isn't: it happens
1258 # frequently that developers don't put autogenerated files into CVS.
1260 echo "Copying file $g"
1261 if test -n "$symbolic" && cmp "$gnulib_dir/$f" "$tmpfile" > /dev/null; then
1262 func_ln_if_changed "$gnulib_dir/$f" "$destdir/$g"
1264 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1272 # Then the files that are in new-files, but not in old-files:
1273 sed_take_last_column='s,^.*'"$delimiter"',,'
1275 for f in `LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_last_column"`; do
1277 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1278 doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
1279 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1280 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1281 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1286 # Then the files that are in new-files and in old-files:
1287 already_present=true
1288 for f in `LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_last_column"`; do
1290 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1291 doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
1292 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1293 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1294 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1300 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
1301 actioncmd="gnulib-tool --import"
1302 actioncmd="$actioncmd --dir=$destdir"
1303 actioncmd="$actioncmd --lib=$libname"
1304 actioncmd="$actioncmd --source-base=$sourcebase"
1305 actioncmd="$actioncmd --m4-base=$m4base"
1306 actioncmd="$actioncmd --doc-base=$docbase"
1307 actioncmd="$actioncmd --aux-dir=$auxdir"
1308 for module in $avoidlist; do
1309 actioncmd="$actioncmd --avoid=$module"
1311 if test -n "$lgpl"; then
1312 actioncmd="$actioncmd --lgpl"
1314 if test -n "$libtool"; then
1315 actioncmd="$actioncmd --libtool"
1317 actioncmd="$actioncmd --macro-prefix=$macro_prefix"
1318 actioncmd="$actioncmd --assume-autoconf=$autoconf_minversion"
1319 actioncmd="$actioncmd `echo $specified_modules`"
1321 # Create lib/Makefile.am.
1322 func_dest_tmpfilename $sourcebase/Makefile.am
1323 func_emit_lib_Makefile_am > "$tmpfile"
1324 if test -f "$destdir"/$sourcebase/Makefile.am; then
1325 if cmp "$destdir"/$sourcebase/Makefile.am "$tmpfile" > /dev/null; then
1329 echo "Updating $sourcebase/Makefile.am (backup in $sourcebase/Makefile.am~)"
1330 mv -f "$destdir"/$sourcebase/Makefile.am "$destdir"/$sourcebase/Makefile.am~
1331 mv -f "$tmpfile" "$destdir"/$sourcebase/Makefile.am
1333 echo "Update $sourcebase/Makefile.am (backup in $sourcebase/Makefile.am~)"
1339 echo "Creating $sourcebase/Makefile.am"
1340 mv -f "$tmpfile" "$destdir"/$sourcebase/Makefile.am
1342 echo "Create $sourcebase/Makefile.am"
1347 # Create m4/gnulib-cache.m4.
1348 func_dest_tmpfilename $m4base/gnulib-cache.m4
1350 func_emit_copyright_notice
1352 echo "# This file represents the specification of how gnulib-tool is used."
1353 echo "# It acts as a cache: It is written and read by gnulib-tool."
1354 echo "# In projects using CVS, this file is meant to be stored in CVS,"
1355 echo "# like the configure.ac and various Makefile.am files."
1358 echo "# Specification in the form of a command-line invocation:"
1361 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
1362 echo "gl_MODULES(["`echo $specified_modules`"])"
1363 echo "gl_AVOID([$avoidlist])"
1364 echo "gl_SOURCE_BASE([$sourcebase])"
1365 echo "gl_M4_BASE([$m4base])"
1366 echo "gl_DOC_BASE([$docbase])"
1367 echo "gl_TESTS_BASE([$testsbase])"
1368 echo "gl_LIB([$libname])"
1369 test -z "$lgpl" || echo "gl_LGPL"
1370 test -z "$libtool" || echo "gl_LIBTOOL"
1371 echo "gl_MACRO_PREFIX([$macro_prefix])"
1372 echo "gl_AUTOCONF_MINVERSION([$autoconf_minversion])"
1374 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1375 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
1379 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1380 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
1381 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
1383 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1387 echo "# gnulib-cache.m4 ends here"
1394 echo "Creating $m4base/gnulib-cache.m4"
1395 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
1397 echo "Create $m4base/gnulib-cache.m4"
1403 # Create m4/gnulib-comp.m4.
1404 func_dest_tmpfilename $m4base/gnulib-comp.m4
1406 func_emit_copyright_notice
1408 echo "# This file represents the compiled summary of the specification in"
1409 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
1410 echo "# to be invoked from configure.ac."
1411 echo "# In projects using CVS, this file can be treated like other built files."
1414 echo "# This macro should be invoked from $configure_ac, in the section"
1415 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
1416 echo "# any checks for libraries, header files, types and library functions."
1417 echo "AC_DEFUN([${macro_prefix}_EARLY],"
1419 echo " AC_REQUIRE([AC_PROG_RANLIB])"
1420 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1421 echo " AC_REQUIRE([AC_GNU_SOURCE])"
1423 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1424 echo " AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])"
1426 if grep gl_LOCK "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1427 echo " AC_REQUIRE([gl_LOCK])"
1431 echo "# This macro should be invoked from $configure_ac, in the section"
1432 echo "# \"Check for header files, types and library functions\"."
1433 echo "AC_DEFUN([${macro_prefix}_INIT],"
1435 if test -z "$libtool"; then
1436 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1438 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1440 if test "$auxdir" != "build-aux"; then
1441 sed_replace_build_aux='
1443 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
1444 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
1447 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
1449 sed_replace_build_aux=
1451 for module in $modules; do
1453 if test -n "$module"; then
1454 func_get_autoconf_snippet "$module" \
1455 | sed -e '/^$/d;' -e 's/^/ /' \
1456 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
1457 -e "$sed_replace_build_aux"
1458 if test "$module" = 'alloca' && test -n "$libtool"; then
1459 echo 'changequote(,)dnl'
1460 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
1461 echo 'changequote([, ])dnl'
1462 echo 'AC_SUBST([LTALLOCA])'
1468 echo "# This macro records the list of files which have been installed by"
1469 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
1470 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
1471 echo "$files" | sed -e 's,^, ,'
1474 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1475 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
1479 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1480 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
1481 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
1483 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1487 echo "# gnulib-comp.m4 ends here"
1494 echo "Creating $m4base/gnulib-comp.m4"
1495 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
1497 echo "Create $m4base/gnulib-comp.m4"
1503 if test -n "$inctests"; then
1504 # Create tests/Makefile.am.
1505 func_dest_tmpfilename $testsbase/Makefile.am
1506 func_emit_tests_Makefile_am > "$tmpfile"
1507 if test -f "$destdir"/$testsbase/Makefile.am; then
1508 if cmp "$destdir"/$testsbase/Makefile.am "$tmpfile" > /dev/null; then
1512 echo "Updating $testsbase/Makefile.am (backup in $testsbase/Makefile.am~)"
1513 mv -f "$destdir"/$testsbase/Makefile.am "$destdir"/$testsbase/Makefile.am~
1514 mv -f "$tmpfile" "$destdir"/$testsbase/Makefile.am
1516 echo "Update $testsbase/Makefile.am (backup in $testsbase/Makefile.am~)"
1522 echo "Creating $testsbase/Makefile.am"
1523 mv -f "$tmpfile" "$destdir"/$testsbase/Makefile.am
1525 echo "Create $testsbase/Makefile.am"
1532 # Undo the effect of the previous 'trap' command. Some shellology:
1533 # We cannot use "trap - 0 1 2 3 15", because Solaris sh would attempt to
1534 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
1535 # exit); for the others we need to call 'exit' explicitly. The value of $? is
1536 # 128 + signal number and is set before the trap-registered command is run.
1538 trap 'exit $?' 1 2 3 15
1542 echo "You may need to add #include directives for the following .h files."
1544 # First the #include <...> directives without #ifs, sorted for convenience.
1545 for module in $modules; do
1546 if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
1549 func_get_include_directive "$module" | grep -v 'include "'
1551 done | LC_ALL=C sort -u
1552 # Then the #include "..." directives without #ifs, sorted for convenience.
1553 for module in $modules; do
1554 if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
1557 func_get_include_directive "$module" | grep 'include "'
1559 done | LC_ALL=C sort -u
1560 # Then the #include directives that are surrounded by #ifs. Not sorted.
1561 for module in $modules; do
1562 if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
1563 func_get_include_directive "$module"
1566 ) | sed -e '/^$/d;' -e 's/^/ /'
1568 echo "Don't forget to"
1569 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1570 if test -n "$inctests"; then
1571 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1573 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
1574 sourcebase_base=`basename "$sourcebase"`
1575 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
1576 if test -n "$inctests"; then
1577 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
1578 testsbase_base=`basename "$testsbase"`
1579 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
1581 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
1582 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
1583 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
1586 # func_create_testdir testdir modules
1588 # - auxdir directory relative to destdir where to place build aux files
1589 func_create_testdir ()
1593 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
1595 # Determine final module list.
1596 func_modules_transitive_closure
1597 echo "Module list with included dependencies:"
1598 echo "$modules" | sed -e 's/^/ /'
1600 # Add the dummy module if needed.
1601 func_modules_add_dummy
1603 # Determine final file list.
1604 func_modules_to_filelist
1606 echo "$files" | sed -e 's/^/ /'
1608 # Create directories.
1609 for d in `echo "$files" | sed -n -e 's,^\(.*\)/[^/]*,\1,p'`; do
1610 if test "$d" = build-aux; then
1611 mkdir -p "$testdir/$auxdir"
1613 mkdir -p "$testdir/$d"
1617 # Copy files or make symbolic links.
1620 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1623 ln "$gnulib_dir/$f" "$testdir/$g" 2>/dev/null ||
1624 if test -z "$symbolic"; then
1625 cp -p "$gnulib_dir/$f" "$testdir/$g"
1627 ln -s "$gnulib_dir/$f" "$testdir/$g"
1631 # Create lib/Makefile.am.
1632 mkdir -p "$testdir/lib"
1633 func_emit_lib_Makefile_am > "$testdir/lib/Makefile.am"
1635 # Create m4/Makefile.am.
1636 mkdir -p "$testdir/m4"
1637 (echo "## Process this file with automake to produce Makefile.in."
1643 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
1646 ) > "$testdir/m4/Makefile.am"
1649 subdirs_with_configure_ac=""
1651 if test -f "$testdir"/m4/gettext.m4; then
1652 # Avoid stupid error message from automake:
1653 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
1654 mkdir -p "$testdir/po"
1655 (echo "## Process this file with automake to produce Makefile.in."
1656 ) > "$testdir/po/Makefile.am"
1657 subdirs="$subdirs po"
1660 if test -n "$inctests"; then
1661 test -d "$testdir/tests" || mkdir "$testdir/tests"
1662 # Create tests/Makefile.am.
1666 func_emit_tests_Makefile_am > "$testdir/tests/Makefile.am"
1667 # Create tests/configure.ac.
1668 (echo "# Process this file with autoconf to produce a configure script."
1669 echo "AC_INIT([dummy], [0])"
1670 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
1671 echo "AM_INIT_AUTOMAKE"
1673 echo "AM_CONFIG_HEADER([config.h])"
1676 echo "AC_PROG_INSTALL"
1677 echo "AC_PROG_MAKE_SET"
1678 echo "AC_PROG_RANLIB"
1680 if grep AC_GNU_SOURCE "$testdir"/m4/*.m4 >/dev/null 2>/dev/null; then
1681 echo "AC_GNU_SOURCE"
1684 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir"/m4/*.m4 >/dev/null 2>/dev/null; then
1685 echo "gl_USE_SYSTEM_EXTENSIONS"
1688 if grep gl_LOCK "$testdir"/m4/*.m4 >/dev/null 2>/dev/null; then
1692 if test -z "$libtool"; then
1693 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1695 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1697 if test "$auxdir" != "build-aux"; then
1698 sed_replace_build_aux='
1700 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
1701 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
1704 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
1706 sed_replace_build_aux=
1708 # We don't have explicit ordering constraints between the various
1709 # autoconf snippets. It's cleanest to put those of the library before
1710 # those of the tests.
1711 for module in $modules; do
1712 func_verify_nontests_module
1713 if test -n "$module"; then
1714 func_get_autoconf_snippet "$module" \
1715 | sed -e "$sed_replace_build_aux"
1718 for module in $modules; do
1719 func_verify_tests_module
1720 if test -n "$module"; then
1721 func_get_autoconf_snippet "$module" \
1722 | sed -e "$sed_replace_build_aux"
1726 # Usually tests/config.h will be a superset of config.h. Verify this by
1727 # "merging" config.h into tests/config.h; look out for gcc warnings.
1728 echo "AH_TOP([#include \"../config.h\"])"
1730 echo "AC_OUTPUT([Makefile])"
1731 ) > "$testdir/tests/configure.ac"
1732 subdirs="$subdirs tests"
1733 subdirs_with_configure_ac="$subdirs_with_configure_ac tests"
1736 # Create Makefile.am.
1737 (echo "## Process this file with automake to produce Makefile.in."
1739 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1741 echo "SUBDIRS = $subdirs"
1743 echo "ACLOCAL_AMFLAGS = -I m4"
1744 ) > "$testdir/Makefile.am"
1746 # Create configure.ac.
1747 (echo "# Process this file with autoconf to produce a configure script."
1748 echo "AC_INIT([dummy], [0])"
1749 if test "$auxdir" != "."; then
1750 echo "AC_CONFIG_AUX_DIR([$auxdir])"
1752 echo "AM_INIT_AUTOMAKE"
1754 echo "AM_CONFIG_HEADER([config.h])"
1757 echo "AC_PROG_INSTALL"
1758 echo "AC_PROG_MAKE_SET"
1759 echo "AC_PROG_RANLIB"
1761 if grep AC_GNU_SOURCE "$testdir"/m4/*.m4 >/dev/null 2>/dev/null; then
1762 echo "AC_GNU_SOURCE"
1765 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir"/m4/*.m4 >/dev/null 2>/dev/null; then
1766 echo "gl_USE_SYSTEM_EXTENSIONS"
1769 if grep gl_LOCK "$testdir"/m4/*.m4 >/dev/null 2>/dev/null; then
1773 if test -z "$libtool"; then
1774 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1776 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1778 if test "$auxdir" != "build-aux"; then
1779 sed_replace_build_aux='
1781 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
1782 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
1785 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
1787 sed_replace_build_aux=
1789 for module in $modules; do
1790 func_verify_nontests_module
1791 if test -n "$module"; then
1792 func_get_autoconf_snippet "$module" \
1793 | sed -e "$sed_replace_build_aux"
1797 if test -n "$subdirs_with_configure_ac"; then
1798 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
1800 makefiles="Makefile"
1801 for d in $subdirs; do
1802 # For subdirs that have a configure.ac by their own, it's the subdir's
1803 # configure.ac which creates the subdir's Makefile.am, not this one.
1804 case " $subdirs_with_configure_ac " in
1806 *) makefiles="$makefiles $d/Makefile" ;;
1809 echo "AC_OUTPUT([$makefiles])"
1810 ) > "$testdir/configure.ac"
1812 # Create autogenerated files.
1814 echo "executing ${AUTORECONF} --force --install"
1815 ${AUTORECONF} --force --install
1817 if grep '^BUILT_SOURCES *+=' "$testdir/lib/Makefile.am" > /dev/null; then
1821 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
1829 # func_create_megatestdir megatestdir allmodules
1831 # - auxdir directory relative to destdir where to place build aux files
1832 func_create_megatestdir ()
1836 if test -z "$allmodules"; then
1837 allmodules=`func_all_modules`
1841 # First, all modules one by one.
1842 for onemodule in $allmodules; do
1843 func_create_testdir "$megatestdir/$onemodule" $onemodule
1844 megasubdirs="${megasubdirs}$onemodule "
1846 # Then, all modules all together.
1847 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
1848 allmodules=`for m in $allmodules; do if test $m != fnmatch-posix; then echo $m; fi; done`
1849 func_create_testdir "$megatestdir/ALL" "$allmodules"
1850 megasubdirs="${megasubdirs}ALL"
1852 # Create Makefile.am.
1853 (echo "## Process this file with automake to produce Makefile.in."
1855 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1857 echo "SUBDIRS = $megasubdirs"
1858 ) > "$megatestdir/Makefile.am"
1860 # Create configure.ac.
1861 (echo "# Process this file with autoconf to produce a configure script."
1862 echo "AC_INIT([dummy], [0])"
1863 if test "$auxdir" != "."; then
1864 echo "AC_CONFIG_AUX_DIR([$auxdir])"
1866 echo "AM_INIT_AUTOMAKE"
1868 echo "AC_PROG_MAKE_SET"
1870 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
1871 echo "AC_OUTPUT([Makefile])"
1872 ) > "$megatestdir/configure.ac"
1874 # Create autogenerated files.
1876 # Do not use "${AUTORECONF} --install", because autoreconf operates
1877 # recursively, but the subdirectories are already finished, therefore
1878 # calling autoreconf here would only waste lots of CPU time.
1879 echo "executing ${ACLOCAL}"
1881 echo "executing mkdir build-aux"
1883 echo "executing ${AUTOCONF}"
1885 echo "executing ${AUTOMAKE} --add-missing --copy"
1886 ${AUTOMAKE} --add-missing --copy
1892 func_fatal_error "no mode specified" ;;
1901 if test -z "$destdir"; then
1904 test -d "$destdir" \
1905 || func_fatal_error "destination directory does not exist: $destdir"
1907 # Prefer configure.ac to configure.in.
1908 if test -f "$destdir"/configure.ac; then
1909 configure_ac="$destdir/configure.ac"
1911 if test -f "$destdir"/configure.in; then
1912 configure_ac="$destdir/configure.in"
1914 func_fatal_error "cannot find $destdir/configure.ac"
1918 test -f "$destdir"/Makefile.am \
1919 || func_fatal_error "cannot find $destdir/Makefile.am"
1921 # Analyze configure.ac.
1928 /AC_CONFIG_AUX_DIR/ {
1929 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
1931 /A[CM]_PROG_LIBTOOL/ {
1932 s,^.*$,guessed_libtool=true,p
1934 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
1936 if test -z "$auxdir"; then
1937 auxdir="$guessed_auxdir"
1940 # Determine where to apply func_import.
1941 if test -n "$m4base"; then
1942 # Apply func_import to a particular gnulib directory.
1943 # Any number of additional modules can be given.
1944 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
1945 # First use of gnulib in the given m4base.
1946 test -n "$supplied_libname" || supplied_libname=true
1947 test -n "$sourcebase" || sourcebase="lib"
1948 test -n "$docbase" || docbase="doc"
1949 test -n "$testsbase" || testsbase="tests"
1950 test -n "$macro_prefix" || macro_prefix="gl"
1951 test -n "$autoconf_minversion" || autoconf_minversion="$DEFAULT_AUTOCONF_MINVERSION"
1955 # Apply func_import to all gnulib directories.
1956 # To get this list of directories, look at Makefile.am. (Not at
1957 # configure, because it may be omitted from CVS. Also, don't run
1958 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
1959 aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$destdir"/Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'`
1963 for arg in $aclocal_amflags; do
1964 if test -n "$m4dir_is_next"; then
1965 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
1969 if test -f "$destdir/$arg"/gnulib-cache.m4; then
1970 m4dirs="$m4dirs $arg"
1971 m4dirs_count=`expr $m4dirs_count + 1`
1976 if test "X$arg" = "X-I"; then
1983 if test $m4dirs_count = 0; then
1984 # First use of gnulib in a package.
1985 # Any number of additional modules can be given.
1986 test -n "$supplied_libname" || supplied_libname=true
1987 test -n "$sourcebase" || sourcebase="lib"
1989 test -n "$docbase" || docbase="doc"
1990 test -n "$testsbase" || testsbase="tests"
1991 test -n "$macro_prefix" || macro_prefix="gl"
1992 test -n "$autoconf_version" || autoconf_version="$DEFAULT_AUTOCONF_MINVERSION"
1995 if test $m4dirs_count = 1; then
1996 # There's only one use of gnulib here. Assume the user means it.
1997 # Any number of additional modules can be given.
1998 for m4base in $m4dirs; do
2002 # Ambiguous - guess what the user meant.
2003 if test $# = 0; then
2004 # No further arguments. Guess the user wants to update all of them.
2005 for m4base in $m4dirs; do
2010 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
2018 if test -z "$destdir"; then
2019 func_fatal_error "please specify --dir option"
2022 test -d "$destdir" \
2023 || func_fatal_error "could not create destination directory"
2024 test -n "$auxdir" || auxdir="build-aux"
2025 func_create_testdir "$destdir" "$*"
2028 create-megatestdir )
2029 if test -z "$destdir"; then
2030 func_fatal_error "please specify --dir option"
2032 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2033 test -n "$auxdir" || auxdir="build-aux"
2034 func_create_megatestdir "$destdir" "$*"
2038 test -n "$destdir" || destdir=testdir$$
2039 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2040 test -n "$auxdir" || auxdir="build-aux"
2041 func_create_testdir "$destdir" "$*"
2049 remaining=`find . -type f -print`
2050 if test -n "$remaining"; then
2051 echo "Remaining files:" $remaining 1>&2
2052 echo "gnulib-tool: *** Stop." 1>&2
2061 test -n "$destdir" || destdir=testdir$$
2062 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2063 test -n "$auxdir" || auxdir="build-aux"
2064 func_create_megatestdir "$destdir" "$*"
2072 remaining=`find . -type f -print`
2073 if test -n "$remaining"; then
2074 echo "Remaining files:" $remaining 1>&2
2075 echo "gnulib-tool: *** Stop." 1>&2
2083 extract-description )
2087 if test -n "$module"; then
2088 func_get_description "$module"
2097 if test -n "$module"; then
2098 func_get_filelist "$module"
2103 extract-dependencies )
2107 if test -n "$module"; then
2108 func_get_dependencies "$module"
2113 extract-autoconf-snippet )
2117 if test -n "$module"; then
2118 func_get_autoconf_snippet "$module"
2123 extract-automake-snippet )
2127 if test -n "$module"; then
2128 func_get_automake_snippet "$module"
2133 extract-include-directive )
2137 if test -n "$module"; then
2138 func_get_include_directive "$module"
2147 if test -n "$module"; then
2148 func_get_license "$module"
2153 extract-maintainer )
2157 if test -n "$module"; then
2158 func_get_maintainer "$module"
2163 extract-tests-module )
2167 if test -n "$module"; then
2168 func_get_tests_module "$module"
2174 func_fatal_error "unknown operation mode --$mode" ;;