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-08-28 15:12:52 $'
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"
56 # GNU sort is needed. Set SORT to its location (not needed if it's called
57 # 'sort' and already in the PATH).
58 if test -z "$SORT"; then
66 # outputs to stdout the --help usage message.
70 Usage: gnulib-tool --list
71 gnulib-tool --import [module1 ... moduleN]
73 gnulib-tool --create-testdir --dir=directory module1 ... moduleN
74 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
75 gnulib-tool --test --dir=directory module1 ... moduleN
76 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
77 gnulib-tool --extract-description module
78 gnulib-tool --extract-filelist module
79 gnulib-tool --extract-dependencies module
80 gnulib-tool --extract-autoconf-snippet module
81 gnulib-tool --extract-automake-snippet module
82 gnulib-tool --extract-include-directive module
83 gnulib-tool --extract-license module
84 gnulib-tool --extract-maintainer module
85 gnulib-tool --extract-tests-module module
88 --list print the available module names
89 --import import the given modules into the current package;
90 if no modules are specified, update the current
91 package from the current gnulib
92 --update update the current package, restore files omitted
94 --create-testdir create a scratch package with the given modules
95 --create-megatestdir create a mega scratch package with the given modules
96 one by one and all together
97 --test test the combination of the given modules
98 (recommended to use CC=\"gcc -Wall\" here)
99 --megatest test the given modules one by one and all together
100 (recommended to use CC=\"gcc -Wall\" here)
101 --extract-description extract the description
102 --extract-filelist extract the list of files
103 --extract-dependencies extract the dependencies
104 --extract-autoconf-snippet extract the snippet for configure.ac
105 --extract-automake-snippet extract the snippet for lib/Makefile.am
106 --extract-include-directive extract the #include directive
107 --extract-license report the license terms of the source files
109 --extract-maintainer report the maintainer(s) inside gnulib
110 --extract-tests-module report the unit test module, if it exists
113 --dir=DIRECTORY Specify the target directory.
114 For --import, this specifies where your
115 configure.ac can be found. Defaults to current
117 --local-dir=DIRECTORY Specify a local override directory where to look
118 up files before looking in gnulib's directory.
120 Options for --import:
121 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
122 --source-base=DIRECTORY
123 Directory relative to --dir where source code is
124 placed (default \"lib\").
125 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
126 placed (default \"m4\").
127 --doc-base=DIRECTORY Directory relative to --dir where doc files are
128 placed (default \"doc\").
129 --tests-base=DIRECTORY
130 Directory relative to --dir where unit tests are
131 placed (default \"tests\").
132 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
133 tools are placed (default \"build-aux\").
134 --with-tests Include unit tests for the included modules.
135 --avoid=MODULE Avoid including the given MODULE. Useful if you
136 have code that provides equivalent functionality.
137 This option can be repeated.
138 --lgpl Abort if modules aren't available under the LGPL.
139 Also modify license template from GPL to LGPL.
140 --libtool Use libtool rules.
141 --no-libtool Don't use libtool rules.
142 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
143 'gl_INIT'. Default is 'gl'.
144 --no-changelog don't update or create ChangeLog files
146 Options for --import and --update:
147 --dry-run For --import, only print what would have been done.
148 -s, --symbolic, --symlink Make symbolic links instead of copying files.
150 Report bugs to <bug-gnulib@gnu.org>."
154 # outputs to stdout the --version message.
157 year=`echo "$last_checkin_date" | sed -e 's,/.*$,,'`
158 echo "$progname (GNU $package) $version"
159 echo "Copyright (C) $year Free Software Foundation, Inc.
160 This is free software; see the source for copying conditions. There is NO
161 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
162 echo "Written by" "Bruno Haible" "and" "Simon Josefsson"
165 # func_emit_copyright_notice
166 # outputs to stdout a header for a generated file.
167 func_emit_copyright_notice ()
169 echo "# Copyright (C) 2004-2006 Free Software Foundation, Inc."
171 echo "# This file is free software, distributed under the terms of the GNU"
172 echo "# General Public License. As a special exception to the GNU General"
173 echo "# Public License, this file may be distributed as part of a program"
174 echo "# that contains a configuration script generated by Autoconf, under"
175 echo "# the same distribution terms as the rest of that program."
177 echo "# Generated by gnulib-tool."
181 # creates a temporary directory.
183 # - tmp pathname of freshly created temporary directory
186 # Use the environment variable TMPDIR, falling back to /tmp. This allows
187 # users to specify a different temporary directory, for example, if their
188 # /tmp is filled up or too small.
191 # Use the mktemp program if available. If not available, hide the error
193 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
194 test -n "$tmp" && test -d "$tmp"
197 # Use a simple mkdir command. It is guaranteed to fail if the directory
198 # already exists. $RANDOM is bash specific and expands to empty in shells
199 # other than bash, ksh and zsh. Its use does not increase security;
200 # rather, it minimizes the probability of failure in a very cluttered /tmp
202 tmp=$TMPDIR/gl$$-$RANDOM
203 (umask 077 && mkdir "$tmp")
206 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
207 { (exit 1); exit 1; }
211 # func_fatal_error message
212 # outputs to stderr a fatal error message, and terminates the program.
215 echo "gnulib-tool: *** $1" 1>&2
216 echo "gnulib-tool: *** Stop." 1>&2
220 # func_readlink SYMLINK
221 # outputs the target of the given symlink.
222 if (type -p readlink) > /dev/null 2>&1; then
225 # Use the readlink program from GNU coreutils.
231 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
232 # would do the wrong thing if the link target contains " -> ".
233 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
237 # func_ln_if_changed SRC DEST
238 # Like ln -s, but avoids munging timestamps if the link is correct.
239 func_ln_if_changed ()
241 if test $# -ne 2; then
242 echo "usage: func_ln_if_changed SRC DEST" >&2
244 if test -L "$2" && test "$1" = "`func_readlink "$2"`"; then
252 # Command-line option processing.
253 # Removes the OPTIONS from the arguments. Sets the variables:
254 # - mode list or import or create-testdir or create-megatestdir
255 # - destdir from --dir
256 # - libname, supplied_libname from --lib
257 # - sourcebase from --source-base
258 # - m4base from --m4-base
259 # - docbase from --doc-base
260 # - testsbase from --tests-base
261 # - auxdir from --aux-dir
262 # - inctests true if --with-tests was given, blank otherwise
263 # - avoidlist list of modules to avoid, from --avoid
264 # - lgpl true if --lgpl was given, blank otherwise
265 # - libtool true if --libtool was given, false if --no-libtool was
266 # given, blank otherwise
267 # - macro_prefix from --macro-prefix
268 # - autoconf_minversion minimum supported autoconf version
269 # - do_changelog false if --no-changelog was given, : otherwise
270 # - doit : if actions shall be executed, false if only to be printed
271 # - local_gnulib_dir from --local-dir
272 # - symbolic true if --symbolic was given, blank otherwise
295 while test $# -gt 0; do
300 --import | --impor | --impo | --imp | --im | --i )
303 --update | --updat | --upda | --upd | --up | --u )
306 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
309 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
310 mode=create-megatestdir
312 --test | --tes | --te | --t )
315 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
319 mode=`echo "X$1" | sed -e 's/^X--//'`
324 func_fatal_error "missing argument for --dir"
329 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
334 func_fatal_error "missing argument for --lib"
337 supplied_libname=true
340 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
341 supplied_libname=true
346 func_fatal_error "missing argument for --source-base"
351 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
356 func_fatal_error "missing argument for --m4-base"
361 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
366 func_fatal_error "missing argument for --doc-base"
371 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
376 func_fatal_error "missing argument for --tests-base"
381 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
386 func_fatal_error "missing argument for --aux-dir"
391 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
399 func_fatal_error "missing argument for --avoid"
401 avoidlist="$avoidlist $1"
404 avoidlist="$avoidlist "`echo "X$1" | sed -e 's/^X--avoid=//'`
418 func_fatal_error "missing argument for --macro-prefix"
423 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
425 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
434 func_fatal_error "missing argument for --local-dir"
439 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
441 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
444 --help | --hel | --he | --h )
447 --version | --versio | --versi | --vers | --ver | --ve | --v )
451 # Stop option processing
455 echo "gnulib-tool: unknown option $1" 1>&2
456 echo "Try 'gnulib-tool --help' for more information." 1>&2
463 if test "$mode" = update; then
464 if test $# != 0; then
465 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
466 echo "Try 'gnulib-tool --help' for more information." 1>&2
467 echo "If you really want to modify the gnulib configuration of your project," 1>&2
468 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
471 if test -n "$supplied_libname" || test -n "$sourcebase" || test -n "$m4base" \
472 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
473 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
474 || test -n "$macro_prefix"; then
475 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
476 echo "Try 'gnulib-tool --help' for more information." 1>&2
477 echo "If you really want to modify the gnulib configuration of your project," 1>&2
478 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
484 # Determine the minimum supported autoconf version from the project's
486 DEFAULT_AUTOCONF_MINVERSION="2.59"
489 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
490 if test -f "$destdir"/configure.ac; then
491 configure_ac="$destdir/configure.ac"
493 if test -f "$destdir"/configure.in; then
494 configure_ac="$destdir/configure.in"
498 if test -f configure.ac; then
499 configure_ac="configure.ac"
501 if test -f configure.in; then
502 configure_ac="configure.in"
506 if test -n "$configure_ac"; then
507 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
508 # because when some m4 files are omitted from a CVS repository,
509 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
510 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
511 # autom4te: m4 failed with exit status: 1
518 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,prereqs="$prereqs \1",p
520 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
521 if test -n "$prereqs"; then
522 autoconf_minversion=`for version in $prereqs; do echo $version; done | $SORT -g | uniq | tail -1`
525 if test -z "$autoconf_minversion"; then
526 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
528 case "$autoconf_minversion" in
529 1.* | 2.[0-4]* | 2.5[0-8]*)
530 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
533 # Remove trailing slashes from the directory names. This is necessary for
534 # m4base (to avoid an error in func_import) and optional for the others.
535 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
536 case "$sourcebase" in
537 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
540 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
543 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
546 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
549 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
554 /*) self_abspathname="$0" ;;
555 */*) self_abspathname=`pwd`/"$0" ;;
556 *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
557 if test -x "$d/$0" && test ! -d "$d/$0"; then
558 self_abspathname="$d/$0"
562 if test -z "$self_abspathname"; then
563 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
567 while test -h "$self_abspathname"; do
568 # Resolve symbolic link.
569 linkval=`func_readlink "$self_abspathname"`
570 test -n "$linkval" || break
572 /* ) self_abspathname="$linkval" ;;
573 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
576 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
579 trap 'rm -rf "$tmp"' 0 1 2 3 15
581 # func_lookup_file file
582 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
585 # - lookedup_file name of the merged (combined) file
586 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
590 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
591 lookedup_file="$local_gnulib_dir/$lkfile"
594 if test -f "$gnulib_dir/$lkfile"; then
595 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
596 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
598 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
599 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
600 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
601 lookedup_file="$tmp/$lkbase"
604 lookedup_file="$gnulib_dir/$lkfile"
608 func_fatal_error "file $gnulib_dir/$lkfile not found"
616 # Filter out metainformation files like README, which are not modules.
617 # Filter out unit test modules; they can be retrieved through
618 # --extract-tests-module if desired.
620 (cd "$gnulib_dir/modules" && ls -1)
621 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
622 (cd "$local_gnulib_dir/modules" && ls -1 | sed -e 's,\.diff$,,')
625 | sed -e '/^CVS$/d' -e '/^ChangeLog$/d' -e '/^COPYING$/d' -e '/^README$/d' -e '/^TEMPLATE$/d' -e '/^TEMPLATE-TESTS$/d' -e '/~$/d' \
626 | sed -e '/-tests$/d' \
632 # verifies a module name
633 func_verify_module ()
635 if { test -f "$gnulib_dir/modules/$module" \
636 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
637 && test -f "$local_gnulib_dir/modules/$module"; }; } \
638 && test "CVS" != "$module" \
639 && test "ChangeLog" != "$module" \
640 && test "COPYING" != "$module" \
641 && test "README" != "$module" \
642 && test "TEMPLATE" != "$module" \
643 && test "TEMPLATE-TESTS" != "$module"; then
644 # OK, $module is a correct module name.
645 # Verify that building the module description with 'patch' succeeds.
646 func_lookup_file "modules/$module"
648 echo "gnulib-tool: module $module doesn't exist" 1>&2
653 # func_verify_nontests_module
654 # verifies a module name, excluding tests modules
655 func_verify_nontests_module ()
659 * ) func_verify_module ;;
663 # func_verify_tests_module
664 # verifies a module name, considering only tests modules
665 func_verify_tests_module ()
668 *-tests ) func_verify_module ;;
673 sed_extract_prog=':[ ]*$/ {
676 s/^Description:[ ]*$//
678 s/^Depends-on:[ ]*$//
679 s/^configure\.ac:[ ]*$//
680 s/^Makefile\.am:[ ]*$//
683 s/^Maintainer:[ ]*$//
690 # func_get_description module
691 func_get_description ()
693 func_lookup_file "modules/$1"
694 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
697 # func_get_filelist module
700 func_lookup_file "modules/$1"
701 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
702 case "$autoconf_minversion" in
705 echo m4/onceonly_2_57.m4
710 # func_get_dependencies module
711 func_get_dependencies ()
713 # ${module}-tests always implicitly depends on ${module}.
714 echo "$1" | sed -n -e 's/-tests//p'
715 # Then the explicit dependencies listed in the module description.
716 func_lookup_file "modules/$1"
717 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
720 # func_get_autoconf_snippet module
721 func_get_autoconf_snippet ()
723 func_lookup_file "modules/$1"
724 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
727 # func_get_automake_snippet module
728 func_get_automake_snippet ()
730 func_lookup_file "modules/$1"
731 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
734 # func_get_include_directive module
735 func_get_include_directive ()
737 func_lookup_file "modules/$1"
738 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
739 sed -e 's/^\(["<]\)/#include \1/'
742 # func_get_license module
745 func_lookup_file "modules/$1"
746 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
749 # func_get_maintainer module
750 func_get_maintainer ()
752 func_lookup_file "modules/$1"
753 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
756 # func_get_tests_module module
757 func_get_tests_module ()
759 # The naming convention for tests modules is hardwired: ${module}-tests.
760 if test -f modules/"$1"-tests; then
765 # func_acceptable module
766 # tests whether a module is acceptable.
768 # - avoidlist list of modules to avoid
771 for avoid in $avoidlist; do
772 if test "$avoid" = "$1"; then
779 # func_modules_transitive_closure
781 # - modules list of specified modules
782 # - inctests true if tests should be included, blank otherwise
783 # - avoidlist list of modules to avoid
785 # - modules list of modules, including dependencies
786 func_modules_transitive_closure ()
790 for module in $modules; do
792 if test -n "$module"; then
793 # Duplicate dependencies are harmless, but Jim wants a warning.
794 duplicated_deps=`func_get_dependencies $module | LC_ALL=C sort | LC_ALL=C uniq -d`
795 if test -n "$duplicated_deps"; then
796 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
798 if func_acceptable $module; then
799 xmodules="$xmodules $module"
800 for depmodule in `func_get_dependencies $module`; do
801 if func_acceptable $depmodule; then
802 xmodules="$xmodules $depmodule"
805 if test -n "$inctests"; then
806 testsmodule=`func_get_tests_module $module`
807 if test -n "$testsmodule"; then
808 if func_acceptable $testsmodule; then
809 xmodules="$xmodules $testsmodule"
810 for depmodule in `func_get_dependencies $testsmodule`; do
811 if func_acceptable $depmodule; then
812 xmodules="$xmodules $depmodule"
821 xmodules=`for m in $xmodules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
822 if test "$xmodules" = "$modules"; then
829 # func_modules_add_dummy
831 # - modules list of modules, including dependencies
833 # - modules list of modules, including 'dummy' if needed
834 func_modules_add_dummy ()
837 sed_remove_backslash_newline=':a
844 for module in $modules; do
845 func_verify_nontests_module
846 if test -n "$module"; then
847 # Extract the value of "lib_SOURCES += ...".
848 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
849 # Ignore .h files since they are not compiled.
852 *) have_lib_SOURCES=yes ;;
857 # Add the dummy module, to make sure the library will be non-empty.
858 if test -z "$have_lib_SOURCES"; then
859 modules="$modules dummy"
863 # func_modules_to_filelist
865 # - modules list of modules, including dependencies
867 # - files list of files
868 func_modules_to_filelist ()
871 for module in $modules; do
873 if test -n "$module"; then
874 files="$files "`func_get_filelist $module`
877 files=`for f in $files; do echo $f; done | LC_ALL=C sort | LC_ALL=C uniq`
880 # func_emit_lib_Makefile_am
881 # emits the contents of lib/Makefile.am to standard output.
883 # - modules list of modules, including dependencies
884 # - libname library name
885 # - libtool true if libtool will be used, false or blank otherwise
886 # - actioncmd (optional) command that will reproduce this invocation
887 func_emit_lib_Makefile_am ()
889 if test "$libtool" = true; then
896 echo "## Process this file with automake to produce Makefile.in."
897 func_emit_copyright_notice
898 if test -n "$actioncmd"; then
899 echo "# Reproduce by: $actioncmd"
902 # No need to generate dependencies since the sources are in gnulib, not here.
903 echo "AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies"
906 for module in $modules; do
907 func_verify_nontests_module
908 if test -n "$module"; then
910 func_get_automake_snippet "$module" |
911 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
912 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
913 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
914 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
915 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
916 if test "$module" = 'alloca'; then
917 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
920 # Skip the contents if its entirely empty.
921 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
922 echo "## begin gnulib module $module"
925 echo "## end gnulib module $module"
932 if grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
933 # One of the snippets already specifies an installation location for the
934 # library. Don't confuse automake by saying it should not be installed.
937 # By default, the generated library should not be installed.
938 echo "noinst_${perhapsLT}LIBRARIES = $libname.$libext"
941 echo "${libname}_${libext}_SOURCES ="
942 echo "${libname}_${libext}_LIBADD = @${perhapsLT}LIBOBJS@"
943 echo "noinst_HEADERS ="
944 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
945 echo "pkgdata_DATA ="
948 echo "BUILT_SOURCES ="
950 echo "MOSTLYCLEANFILES = core *.stackdump"
951 echo "MOSTLYCLEANDIRS ="
953 echo "DISTCLEANFILES ="
954 echo "MAINTAINERCLEANFILES ="
960 echo "mostlyclean-local: mostlyclean-generic"
961 echo " @test -z \"\$(MOSTLYCLEANDIRS)\" || \\"
962 echo " for dir in \$(MOSTLYCLEANDIRS); do \\"
963 echo " if test -d \$\$dir; then \\"
964 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
968 echo "# Makefile.am ends here"
969 rm -f allsnippets.tmp
972 # func_emit_tests_Makefile_am
973 # emits the contents of tests/Makefile.am to standard output.
975 # - modules list of modules, including dependencies
976 # - libname library name
977 # - libtool true if libtool will be used, false or blank otherwise
978 # - sourcebase relative directory containing lib source code
979 # - m4base relative directory containing autoconf macros
980 # - testsbase relative directory containing unit test code
981 func_emit_tests_Makefile_am ()
983 if test "$libtool" = true; then
988 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
989 echo "## Process this file with automake to produce Makefile.in."
990 func_emit_copyright_notice
992 # Generate dependencies here, since it eases the debugging of test failures.
993 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
995 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
998 for module in $modules; do
999 func_verify_tests_module
1000 if test -n "$module"; then
1001 func_get_automake_snippet "$module" > amsnippet.tmp
1002 # Skip the contents if its entirely empty.
1003 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1004 echo "## begin gnulib module $module"
1007 echo "## end gnulib module $module"
1014 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1015 # variable is needed to avoid an error from automake:
1016 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1019 echo "TESTS_ENVIRONMENT ="
1020 echo "noinst_PROGRAMS ="
1021 echo "check_PROGRAMS ="
1022 echo "noinst_HEADERS ="
1023 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1024 echo "pkgdata_DATA ="
1027 echo "BUILT_SOURCES ="
1029 echo "MOSTLYCLEANFILES = core *.stackdump"
1030 echo "MOSTLYCLEANDIRS ="
1032 echo "DISTCLEANFILES ="
1033 echo "MAINTAINERCLEANFILES ="
1035 echo "AM_CPPFLAGS = \\"
1036 echo " -I. -I\$(srcdir) \\"
1037 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1038 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1040 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1043 echo "# Clean up after Solaris cc."
1045 echo " rm -rf SunWS_cache"
1047 echo "mostlyclean-local: mostlyclean-generic"
1048 echo " @test -z \"\$(MOSTLYCLEANDIRS)\" || \\"
1049 echo " for dir in \$(MOSTLYCLEANDIRS); do \\"
1050 echo " if test -d \$\$dir; then \\"
1051 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1055 echo "# Makefile.am ends here"
1056 rm -f allsnippets.tmp
1059 # func_import modules
1060 # Uses also the variables
1061 # - destdir target directory
1062 # - libname library name
1063 # - sourcebase directory relative to destdir where to place source code
1064 # - m4base directory relative to destdir where to place *.m4 macros
1065 # - docbase directory relative to destdir where to place doc files
1066 # - testsbase directory relative to destdir where to place unit test code
1067 # - auxdir directory relative to destdir where to place build aux files
1068 # - inctests true if --with-tests was given, blank otherwise
1069 # - avoidlist list of modules to avoid, from --avoid
1070 # - lgpl true if library's license shall be LGPL, blank otherwise
1071 # - libtool true if --libtool was given, false if --no-libtool was
1072 # given, blank otherwise
1073 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1074 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1075 # - autoconf_minversion minimum supported autoconf version
1076 # - doit : if actions shall be executed, false if only to be printed
1077 # - symbolic true if files should be symlinked, copied otherwise
1080 # Get the cached settings.
1081 cached_specified_modules=
1090 cached_macro_prefix=
1092 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1093 cached_libtool=false
1099 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1102 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1105 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1108 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1111 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1114 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1117 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1120 s,^.*$,cached_lgpl=true,p
1123 s,^.*$,cached_libtool=true,p
1125 /gl_MACRO_PREFIX(/ {
1126 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
1128 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
1129 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1134 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
1135 s,^.*$,cached_files=",p
1147 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1151 # Merge the cached settings with the specified ones.
1152 # The m4base must be the same as expected from the pathname.
1153 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1154 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1156 # Append the cached and the specified module names. So that
1157 # "gnulib-tool --import foo" means to add the module foo.
1158 specified_modules="$cached_specified_modules $1"
1159 # Append the cached and the specified avoidlist. This is probably better
1160 # than dropping the cached one when --avoid is specified at least once.
1161 avoidlist=`echo $cached_avoidlist $avoidlist`
1162 # The sourcebase defaults to the cached one.
1163 if test -z "$sourcebase"; then
1164 sourcebase="$cached_sourcebase"
1165 if test -z "$sourcebase"; then
1166 func_fatal_error "missing --source-base option"
1169 # The docbase defaults to the cached one.
1170 if test -z "$docbase"; then
1171 docbase="$cached_docbase"
1172 if test -z "$docbase"; then
1173 func_fatal_error "missing --doc-base option. --doc-base has been introduced on 2006-07-11; if your last invocation of 'gnulib-tool --import' is before that date, you need to run 'gnulib-tool --import' once, with a --doc-base option."
1176 # The testsbase defaults to the cached one.
1177 if test -z "$testsbase"; then
1178 testsbase="$cached_testsbase"
1179 if test -z "$testsbase"; then
1180 func_fatal_error "missing --tests-base option"
1183 # The libname defaults to the cached one.
1184 if test -z "$supplied_libname"; then
1185 libname="$cached_libname"
1186 if test -z "$libname"; then
1187 func_fatal_error "missing --lib option"
1190 # Require LGPL if specified either way.
1191 if test -z "$lgpl"; then
1194 # Use libtool if specified either way, or if guessed.
1195 if test -z "$libtool"; then
1196 if test -n "$cached_m4base"; then
1197 libtool="$cached_libtool"
1199 libtool="$guessed_libtool"
1202 # The macro_prefix defaults to the cached one.
1203 if test -z "$macro_prefix"; then
1204 macro_prefix="$cached_macro_prefix"
1205 if test -z "$macro_prefix"; then
1206 func_fatal_error "missing --macro-prefix option"
1210 # Canonicalize the list of specified modules.
1211 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
1213 # Determine final module list.
1214 modules="$specified_modules"
1215 func_modules_transitive_closure
1216 echo "Module list with included dependencies:"
1217 echo "$modules" | sed -e 's/^/ /'
1219 # Add the dummy module if needed.
1220 func_modules_add_dummy
1222 # If --lgpl, check the license of modules are compatible.
1223 if test -n "$lgpl"; then
1224 for module in $modules; do
1225 license=`func_get_license $module`
1227 LGPL | 'GPLed build tool' | 'public domain' | 'unlimited') ;;
1228 *) func_fatal_error "incompatible license on module $module: $license" ;;
1233 # Determine script to apply to imported library files.
1234 sed_transform_lib_file=
1235 case $nl$modules$nl in
1236 *"${nl}config-h$nl"*)
1237 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
1238 sed_transform_lib_file=$sed_transform_lib_file'
1239 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
1242 if test -n "$lgpl"; then
1244 sed_transform_lib_file=$sed_transform_lib_file'
1245 s/GNU General/GNU Lesser General/g
1246 s/version 2\([ ,]\)/version 2.1\1/g
1250 # Determine final file list.
1251 func_modules_to_filelist
1253 echo "$files" | sed -e 's/^/ /'
1256 || func_fatal_error "refusing to do nothing"
1258 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
1259 new_files="$files m4/gnulib-tool.m4"
1260 old_files="$cached_files"
1261 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
1262 old_files="$old_files m4/gnulib-tool.m4"
1265 # Create directories.
1266 if test ! -d "$destdir/$sourcebase"; then
1268 echo "Creating directory $destdir/$sourcebase"
1269 mkdir "$destdir/$sourcebase" || func_fatal_error "failed"
1271 echo "Create directory $destdir/$sourcebase"
1274 if test ! -d "$destdir/$m4base"; then
1276 echo "Creating directory $destdir/$m4base"
1277 mkdir "$destdir/$m4base" || func_fatal_error "failed"
1279 echo "Create directory $destdir/$m4base"
1282 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
1283 if test -n "$docfiles"; then
1284 if test ! -d "$destdir/$docbase"; then
1286 echo "Creating directory $destdir/$docbase"
1287 mkdir "$destdir/$docbase" || func_fatal_error "failed"
1289 echo "Create directory $destdir/$docbase"
1293 if test -n "$inctests"; then
1294 if test ! -d "$destdir/$testsbase"; then
1296 echo "Creating directory $destdir/$testsbase"
1297 mkdir "$destdir/$testsbase" || func_fatal_error "failed"
1299 echo "Create directory $destdir/$testsbase"
1303 if test ! -d "$destdir/$auxdir"; then
1305 echo "Creating directory $destdir/$auxdir"
1306 mkdir "$destdir/$auxdir" || func_fatal_error "failed"
1308 echo "Create directory $destdir/$auxdir"
1312 # func_dest_tmpfilename file
1313 # determines the name of a temporary file (file is relative to destdir).
1315 # - tmpfile absolute filename of the temporary file
1316 func_dest_tmpfilename ()
1319 # Put the new contents of $file in a file in the same directory (needed
1320 # to guarantee that an 'mv' to "$destdir/$file" works).
1321 tmpfile="$destdir/$1.tmp"
1323 # Put the new contents of $file in a file in a temporary directory
1324 # (because the directory of "$file" might not exist).
1325 tmpfile="$tmp"/`basename "$1"`.tmp
1329 # Copy files or make symbolic links. Remove obsolete files.
1331 for f in $old_files; do
1333 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1334 doc/*) g=`echo "$f" | sed -e "s,^doc/,$cached_docbase/,"` ;;
1335 lib/*) g=`echo "$f" | sed -e "s,^lib/,$cached_sourcebase/,"` ;;
1336 m4/*) g=`echo "$f" | sed -e "s,^m4/,$cached_m4base/,"` ;;
1337 tests/*) g=`echo "$f" | sed -e "s,^tests/,$cached_testsbase/,"` ;;
1340 echo "$g""$delimiter""$f"
1341 done | LC_ALL=C sort > "$tmp"/old-files
1342 for f in $new_files; do
1344 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1345 doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
1346 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1347 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1348 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1351 echo "$g""$delimiter""$f"
1352 done | LC_ALL=C sort > "$tmp"/new-files
1353 # First the files that are in old-files, but not in new-files:
1354 sed_take_first_column='s,'"$delimiter"'.*,,'
1355 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
1356 # Remove the file. Do nothing if the user already removed it.
1357 if test -f "$destdir/$g"; then
1359 echo "Removing file $g (backup in ${g}~)"
1360 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1362 echo "Remove file $g (backup in ${g}~)"
1366 # func_add_or_update handles a file that ought to be present afterwards.
1367 # Uses parameters f, g, already_present.
1368 func_add_or_update ()
1370 func_dest_tmpfilename "$g"
1371 func_lookup_file "$f"
1372 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
1373 if test -n "sed_transform_lib_file"; then
1376 sed -e "$sed_transform_lib_file" \
1377 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
1381 if test -f "$destdir/$g"; then
1382 # The file already exists.
1383 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1384 : # The file has not changed.
1388 if test -n "$already_present"; then
1389 echo "Updating file $g (backup in ${g}~)"
1391 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
1393 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1394 if test -n "$symbolic" && test -z "$lookedup_tmp" \
1395 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1396 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1398 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1401 if test -n "$already_present"; then
1402 echo "Update file $g (backup in ${g}~)"
1404 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
1410 # Don't protest if the file should be there but isn't: it happens
1411 # frequently that developers don't put autogenerated files into CVS.
1413 echo "Copying file $g"
1414 if test -n "$symbolic" && test -z "$lookedup_tmp" \
1415 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1416 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1418 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1426 # Then the files that are in new-files, but not in old-files:
1427 sed_take_last_column='s,^.*'"$delimiter"',,'
1429 for f in `LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_last_column"`; do
1431 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1432 doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
1433 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1434 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1435 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1440 # Then the files that are in new-files and in old-files:
1441 already_present=true
1442 for f in `LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_last_column"`; do
1444 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1445 doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
1446 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1447 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1448 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1454 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
1455 actioncmd="gnulib-tool --import"
1456 actioncmd="$actioncmd --dir=$destdir"
1457 actioncmd="$actioncmd --lib=$libname"
1458 actioncmd="$actioncmd --source-base=$sourcebase"
1459 actioncmd="$actioncmd --m4-base=$m4base"
1460 actioncmd="$actioncmd --doc-base=$docbase"
1461 actioncmd="$actioncmd --aux-dir=$auxdir"
1462 for module in $avoidlist; do
1463 actioncmd="$actioncmd --avoid=$module"
1465 if test -n "$lgpl"; then
1466 actioncmd="$actioncmd --lgpl"
1468 if test "$libtool" = true; then
1469 actioncmd="$actioncmd --libtool"
1471 actioncmd="$actioncmd --no-libtool"
1473 actioncmd="$actioncmd --macro-prefix=$macro_prefix"
1474 actioncmd="$actioncmd `echo $specified_modules`"
1476 # Create lib/Makefile.am.
1477 func_dest_tmpfilename $sourcebase/Makefile.am
1478 func_emit_lib_Makefile_am > "$tmpfile"
1479 if test -f "$destdir"/$sourcebase/Makefile.am; then
1480 if cmp "$destdir"/$sourcebase/Makefile.am "$tmpfile" > /dev/null; then
1484 echo "Updating $sourcebase/Makefile.am (backup in $sourcebase/Makefile.am~)"
1485 mv -f "$destdir"/$sourcebase/Makefile.am "$destdir"/$sourcebase/Makefile.am~
1486 mv -f "$tmpfile" "$destdir"/$sourcebase/Makefile.am
1488 echo "Update $sourcebase/Makefile.am (backup in $sourcebase/Makefile.am~)"
1494 echo "Creating $sourcebase/Makefile.am"
1495 mv -f "$tmpfile" "$destdir"/$sourcebase/Makefile.am
1497 echo "Create $sourcebase/Makefile.am"
1502 # Create m4/gnulib-cache.m4.
1503 func_dest_tmpfilename $m4base/gnulib-cache.m4
1505 func_emit_copyright_notice
1507 echo "# This file represents the specification of how gnulib-tool is used."
1508 echo "# It acts as a cache: It is written and read by gnulib-tool."
1509 echo "# In projects using CVS, this file is meant to be stored in CVS,"
1510 echo "# like the configure.ac and various Makefile.am files."
1513 echo "# Specification in the form of a command-line invocation:"
1516 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
1517 echo "gl_MODULES(["`echo $specified_modules`"])"
1518 echo "gl_AVOID([$avoidlist])"
1519 echo "gl_SOURCE_BASE([$sourcebase])"
1520 echo "gl_M4_BASE([$m4base])"
1521 echo "gl_DOC_BASE([$docbase])"
1522 echo "gl_TESTS_BASE([$testsbase])"
1523 echo "gl_LIB([$libname])"
1524 test -z "$lgpl" || echo "gl_LGPL"
1525 if test "$libtool" = true; then
1528 echo "gl_MACRO_PREFIX([$macro_prefix])"
1530 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1531 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
1535 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1536 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
1537 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
1539 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1543 echo "# gnulib-cache.m4 ends here"
1550 echo "Creating $m4base/gnulib-cache.m4"
1551 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
1553 echo "Create $m4base/gnulib-cache.m4"
1559 # Create m4/gnulib-comp.m4.
1560 func_dest_tmpfilename $m4base/gnulib-comp.m4
1562 func_emit_copyright_notice
1564 echo "# This file represents the compiled summary of the specification in"
1565 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
1566 echo "# to be invoked from configure.ac."
1567 echo "# In projects using CVS, this file can be treated like other built files."
1570 echo "# This macro should be invoked from $configure_ac, in the section"
1571 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
1572 echo "# any checks for libraries, header files, types and library functions."
1573 echo "AC_DEFUN([${macro_prefix}_EARLY],"
1575 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
1576 echo " m4_pattern_allow([^gl_ES$])dnl a valid locale name"
1577 echo " AC_REQUIRE([AC_PROG_RANLIB])"
1578 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1579 echo " AC_REQUIRE([AC_GNU_SOURCE])"
1581 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1582 echo " AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])"
1584 if grep gl_LOCK "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1585 echo " AC_REQUIRE([gl_LOCK_EARLY])"
1589 echo "# This macro should be invoked from $configure_ac, in the section"
1590 echo "# \"Check for header files, types and library functions\"."
1591 echo "AC_DEFUN([${macro_prefix}_INIT],"
1593 if test "$libtool" = true; then
1594 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1596 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1598 if test "$auxdir" != "build-aux"; then
1599 sed_replace_build_aux='
1601 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
1602 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
1605 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
1607 sed_replace_build_aux=
1609 for module in $modules; do
1611 if test -n "$module"; then
1612 func_get_autoconf_snippet "$module" \
1613 | sed -e '/^$/d;' -e 's/^/ /' \
1614 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
1615 -e "$sed_replace_build_aux"
1616 if test "$module" = 'alloca' && test "$libtool" = true; then
1617 echo 'changequote(,)dnl'
1618 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
1619 echo 'changequote([, ])dnl'
1620 echo 'AC_SUBST([LTALLOCA])'
1626 echo "# This macro records the list of files which have been installed by"
1627 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
1628 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
1629 echo "$files" | sed -e 's,^, ,'
1632 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1633 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
1637 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1638 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
1639 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
1641 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1645 echo "# gnulib-comp.m4 ends here"
1652 echo "Creating $m4base/gnulib-comp.m4"
1653 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
1655 echo "Create $m4base/gnulib-comp.m4"
1661 if test -n "$inctests"; then
1662 # Create tests/Makefile.am.
1663 func_dest_tmpfilename $testsbase/Makefile.am
1664 func_emit_tests_Makefile_am > "$tmpfile"
1665 if test -f "$destdir"/$testsbase/Makefile.am; then
1666 if cmp "$destdir"/$testsbase/Makefile.am "$tmpfile" > /dev/null; then
1670 echo "Updating $testsbase/Makefile.am (backup in $testsbase/Makefile.am~)"
1671 mv -f "$destdir"/$testsbase/Makefile.am "$destdir"/$testsbase/Makefile.am~
1672 mv -f "$tmpfile" "$destdir"/$testsbase/Makefile.am
1674 echo "Update $testsbase/Makefile.am (backup in $testsbase/Makefile.am~)"
1680 echo "Creating $testsbase/Makefile.am"
1681 mv -f "$tmpfile" "$destdir"/$testsbase/Makefile.am
1683 echo "Create $testsbase/Makefile.am"
1691 echo "You may need to add #include directives for the following .h files."
1693 # First the #include <...> directives without #ifs, sorted for convenience.
1694 for module in $modules; do
1695 if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
1698 func_get_include_directive "$module" | grep -v 'include "'
1700 done | LC_ALL=C sort -u
1701 # Then the #include "..." directives without #ifs, sorted for convenience.
1702 for module in $modules; do
1703 if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
1706 func_get_include_directive "$module" | grep 'include "'
1708 done | LC_ALL=C sort -u
1709 # Then the #include directives that are surrounded by #ifs. Not sorted.
1710 for module in $modules; do
1711 if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
1712 func_get_include_directive "$module"
1715 ) | sed -e '/^$/d;' -e 's/^/ /'
1717 echo "Don't forget to"
1718 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1719 if test -n "$inctests"; then
1720 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1722 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
1723 sourcebase_base=`basename "$sourcebase"`
1724 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
1725 if test -n "$inctests"; then
1726 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
1727 testsbase_base=`basename "$testsbase"`
1728 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
1730 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
1731 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
1732 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
1735 # func_create_testdir testdir modules
1737 # - auxdir directory relative to destdir where to place build aux files
1738 func_create_testdir ()
1742 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
1744 # Subdirectory names.
1749 # Determine final module list.
1750 func_modules_transitive_closure
1751 echo "Module list with included dependencies:"
1752 echo "$modules" | sed -e 's/^/ /'
1754 # Add the dummy module if needed.
1755 func_modules_add_dummy
1757 # Determine final file list.
1758 func_modules_to_filelist
1760 echo "$files" | sed -e 's/^/ /'
1762 # Create directories.
1763 for d in `echo "$files" | sed -n -e 's,^\(.*\)/[^/]*,\1,p'`; do
1765 build-aux) mkdir -p "$testdir/$auxdir" ;;
1766 lib) mkdir -p "$testdir/$sourcebase" ;;
1767 m4) mkdir -p "$testdir/$m4base" ;;
1768 tests) mkdir -p "$testdir/$testsbase" ;;
1769 *) mkdir -p "$testdir/$d" ;;
1773 # Copy files or make symbolic links.
1775 func_lookup_file "$f"
1777 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1778 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1779 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1780 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1783 if test -n "$lookedup_tmp"; then
1784 cp -p "$lookedup_file" "$testdir/$g"
1786 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
1787 if test -z "$symbolic"; then
1788 cp -p "$lookedup_file" "$testdir/$g"
1790 ln -s "$lookedup_file" "$testdir/$g"
1795 # Create $sourcebase/Makefile.am.
1796 mkdir -p "$testdir/$sourcebase"
1797 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
1799 # Create $m4base/Makefile.am.
1800 mkdir -p "$testdir/$m4base"
1801 (echo "## Process this file with automake to produce Makefile.in."
1807 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
1810 ) > "$testdir/$m4base/Makefile.am"
1812 subdirs="$sourcebase $m4base"
1813 subdirs_with_configure_ac=""
1815 if test -f "$testdir"/$m4base/gettext.m4; then
1816 # Avoid stupid error message from automake:
1817 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
1818 mkdir -p "$testdir/po"
1819 (echo "## Process this file with automake to produce Makefile.in."
1820 ) > "$testdir/po/Makefile.am"
1821 subdirs="$subdirs po"
1824 if test -n "$inctests"; then
1825 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
1826 # Create $testsbase/Makefile.am.
1827 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
1828 # Create $testsbase/configure.ac.
1829 (echo "# Process this file with autoconf to produce a configure script."
1830 echo "AC_INIT([dummy], [0])"
1831 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
1832 echo "AM_INIT_AUTOMAKE"
1834 echo "AM_CONFIG_HEADER([config.h])"
1837 echo "AC_PROG_INSTALL"
1838 echo "AC_PROG_MAKE_SET"
1839 echo "AC_PROG_RANLIB"
1841 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
1842 echo "AC_GNU_SOURCE"
1845 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
1846 echo "gl_USE_SYSTEM_EXTENSIONS"
1849 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
1850 echo "gl_LOCK_EARLY"
1853 if test "$libtool" = true; then
1854 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1856 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1858 # Wrap the set of autoconf snippets into an autoconf macro that is then
1859 # invoked. This is needed because autoconf does not support AC_REQUIRE
1861 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
1862 # but we want the AC_REQUIRE to have its normal meaning (provide one
1863 # expansion of the required macro before the current point, and only one
1865 echo "AC_DEFUN([gl_INIT], ["
1866 if test "$auxdir" != "build-aux"; then
1867 sed_replace_build_aux='
1869 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
1870 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
1873 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
1875 sed_replace_build_aux=
1877 # We don't have explicit ordering constraints between the various
1878 # autoconf snippets. It's cleanest to put those of the library before
1879 # those of the tests.
1880 for module in $modules; do
1881 func_verify_nontests_module
1882 if test -n "$module"; then
1883 func_get_autoconf_snippet "$module" \
1884 | sed -e "$sed_replace_build_aux"
1887 for module in $modules; do
1888 func_verify_tests_module
1889 if test -n "$module"; then
1890 func_get_autoconf_snippet "$module" \
1891 | sed -e "$sed_replace_build_aux"
1897 # Usually $testsbase/config.h will be a superset of config.h. Verify this
1898 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
1899 echo "AH_TOP([#include \"../config.h\"])"
1901 echo "AC_OUTPUT([Makefile])"
1902 ) > "$testdir/$testsbase/configure.ac"
1903 subdirs="$subdirs $testsbase"
1904 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
1907 # Create Makefile.am.
1908 (echo "## Process this file with automake to produce Makefile.in."
1910 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1912 echo "SUBDIRS = $subdirs"
1914 echo "ACLOCAL_AMFLAGS = -I $m4base"
1915 ) > "$testdir/Makefile.am"
1917 # Create configure.ac.
1918 (echo "# Process this file with autoconf to produce a configure script."
1919 echo "AC_INIT([dummy], [0])"
1920 if test "$auxdir" != "."; then
1921 echo "AC_CONFIG_AUX_DIR([$auxdir])"
1923 echo "AM_INIT_AUTOMAKE"
1925 echo "AM_CONFIG_HEADER([config.h])"
1928 echo "AC_PROG_INSTALL"
1929 echo "AC_PROG_MAKE_SET"
1931 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
1932 echo "m4_pattern_allow([^gl_ES$])dnl a valid locale name"
1934 echo "AC_PROG_RANLIB"
1936 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
1937 echo "AC_GNU_SOURCE"
1940 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
1941 echo "gl_USE_SYSTEM_EXTENSIONS"
1944 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
1945 echo "gl_LOCK_EARLY"
1948 if test "$libtool" = true; then
1949 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1951 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1953 # Wrap the set of autoconf snippets into an autoconf macro that is then
1954 # invoked. This is needed because autoconf does not support AC_REQUIRE
1956 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
1957 # but we want the AC_REQUIRE to have its normal meaning (provide one
1958 # expansion of the required macro before the current point, and only one
1960 echo "AC_DEFUN([gl_INIT], ["
1961 if test "$auxdir" != "build-aux"; then
1962 sed_replace_build_aux='
1964 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
1965 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
1968 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
1970 sed_replace_build_aux=
1972 for module in $modules; do
1973 func_verify_nontests_module
1974 if test -n "$module"; then
1975 func_get_autoconf_snippet "$module" \
1976 | sed -e "$sed_replace_build_aux"
1982 if test -n "$subdirs_with_configure_ac"; then
1983 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
1985 makefiles="Makefile"
1986 for d in $subdirs; do
1987 # For subdirs that have a configure.ac by their own, it's the subdir's
1988 # configure.ac which creates the subdir's Makefile.am, not this one.
1989 case " $subdirs_with_configure_ac " in
1991 *) makefiles="$makefiles $d/Makefile" ;;
1994 echo "AC_OUTPUT([$makefiles])"
1995 ) > "$testdir/configure.ac"
1997 # Create autogenerated files.
1999 echo "executing ${AUTORECONF} --force --install"
2000 ${AUTORECONF} --force --install
2002 if grep '^BUILT_SOURCES *+=' "$testdir/$sourcebase/Makefile.am" > /dev/null; then
2006 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
2014 # func_create_megatestdir megatestdir allmodules
2016 # - auxdir directory relative to destdir where to place build aux files
2017 func_create_megatestdir ()
2021 if test -z "$allmodules"; then
2022 allmodules=`func_all_modules`
2026 # First, all modules one by one.
2027 for onemodule in $allmodules; do
2028 func_create_testdir "$megatestdir/$onemodule" $onemodule
2029 megasubdirs="${megasubdirs}$onemodule "
2031 # Then, all modules all together.
2032 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2033 allmodules=`for m in $allmodules; do if test $m != fnmatch-posix; then echo $m; fi; done`
2034 func_create_testdir "$megatestdir/ALL" "$allmodules"
2035 megasubdirs="${megasubdirs}ALL"
2037 # Create Makefile.am.
2038 (echo "## Process this file with automake to produce Makefile.in."
2040 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2042 echo "SUBDIRS = $megasubdirs"
2043 ) > "$megatestdir/Makefile.am"
2045 # Create configure.ac.
2046 (echo "# Process this file with autoconf to produce a configure script."
2047 echo "AC_INIT([dummy], [0])"
2048 if test "$auxdir" != "."; then
2049 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2051 echo "AM_INIT_AUTOMAKE"
2053 echo "AC_PROG_MAKE_SET"
2055 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
2056 echo "AC_OUTPUT([Makefile])"
2057 ) > "$megatestdir/configure.ac"
2059 # Create autogenerated files.
2061 # Do not use "${AUTORECONF} --install", because autoreconf operates
2062 # recursively, but the subdirectories are already finished, therefore
2063 # calling autoreconf here would only waste lots of CPU time.
2064 echo "executing ${ACLOCAL}"
2066 echo "executing mkdir build-aux"
2068 echo "executing ${AUTOCONF}"
2070 echo "executing ${AUTOMAKE} --add-missing --copy"
2071 ${AUTOMAKE} --add-missing --copy
2077 func_fatal_error "no mode specified" ;;
2086 if test -z "$destdir"; then
2089 test -d "$destdir" \
2090 || func_fatal_error "destination directory does not exist: $destdir"
2092 # Prefer configure.ac to configure.in.
2093 if test -f "$destdir"/configure.ac; then
2094 configure_ac="$destdir/configure.ac"
2096 if test -f "$destdir"/configure.in; then
2097 configure_ac="$destdir/configure.in"
2099 func_fatal_error "cannot find $destdir/configure.ac"
2103 # Analyze configure.ac.
2105 guessed_libtool=false
2110 /AC_CONFIG_AUX_DIR/ {
2111 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
2113 /A[CM]_PROG_LIBTOOL/ {
2114 s,^.*$,guessed_libtool=true,p
2116 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
2118 if test -z "$auxdir"; then
2119 auxdir="$guessed_auxdir"
2122 # Determine where to apply func_import.
2123 if test -n "$m4base"; then
2124 # Apply func_import to a particular gnulib directory.
2125 # Any number of additional modules can be given.
2126 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
2127 # First use of gnulib in the given m4base.
2128 test -n "$supplied_libname" || supplied_libname=true
2129 test -n "$sourcebase" || sourcebase="lib"
2130 test -n "$docbase" || docbase="doc"
2131 test -n "$testsbase" || testsbase="tests"
2132 test -n "$macro_prefix" || macro_prefix="gl"
2136 # Apply func_import to all gnulib directories.
2137 # To get this list of directories, look at Makefile.am. (Not at
2138 # configure, because it may be omitted from CVS. Also, don't run
2139 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
2142 if test -f "$destdir"/Makefile.am; then
2143 aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$destdir"/Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'`
2145 for arg in $aclocal_amflags; do
2146 if test -n "$m4dir_is_next"; then
2147 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
2151 if test -f "$destdir/$arg"/gnulib-cache.m4; then
2152 m4dirs="$m4dirs $arg"
2153 m4dirs_count=`expr $m4dirs_count + 1`
2158 if test "X$arg" = "X-I"; then
2166 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
2167 if test -f "$destdir"/aclocal.m4; then
2168 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
2169 sedexpr2='s,^[^/]*$,.,'
2170 sedexpr3='s,/[^/]*$,,'
2171 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort | LC_ALL=C uniq`
2172 m4dirs_count=`echo "$m4dirs" | wc -l`
2175 if test $m4dirs_count = 0; then
2176 # First use of gnulib in a package.
2177 # Any number of additional modules can be given.
2178 test -n "$supplied_libname" || supplied_libname=true
2179 test -n "$sourcebase" || sourcebase="lib"
2181 test -n "$docbase" || docbase="doc"
2182 test -n "$testsbase" || testsbase="tests"
2183 test -n "$macro_prefix" || macro_prefix="gl"
2186 if test $m4dirs_count = 1; then
2187 # There's only one use of gnulib here. Assume the user means it.
2188 # Any number of additional modules can be given.
2189 for m4base in $m4dirs; do
2193 # Ambiguous - guess what the user meant.
2194 if test $# = 0; then
2195 # No further arguments. Guess the user wants to update all of them.
2196 for m4base in $m4dirs; do
2201 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
2209 if test -z "$destdir"; then
2210 func_fatal_error "please specify --dir option"
2213 test -d "$destdir" \
2214 || func_fatal_error "could not create destination directory"
2215 test -n "$auxdir" || auxdir="build-aux"
2216 func_create_testdir "$destdir" "$*"
2219 create-megatestdir )
2220 if test -z "$destdir"; then
2221 func_fatal_error "please specify --dir option"
2223 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2224 test -n "$auxdir" || auxdir="build-aux"
2225 func_create_megatestdir "$destdir" "$*"
2229 test -n "$destdir" || destdir=testdir$$
2230 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2231 test -n "$auxdir" || auxdir="build-aux"
2232 func_create_testdir "$destdir" "$*"
2240 remaining=`find . -type f -print`
2241 if test -n "$remaining"; then
2242 echo "Remaining files:" $remaining 1>&2
2243 echo "gnulib-tool: *** Stop." 1>&2
2252 test -n "$destdir" || destdir=testdir$$
2253 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2254 test -n "$auxdir" || auxdir="build-aux"
2255 func_create_megatestdir "$destdir" "$*"
2263 remaining=`find . -type f -print`
2264 if test -n "$remaining"; then
2265 echo "Remaining files:" $remaining 1>&2
2266 echo "gnulib-tool: *** Stop." 1>&2
2274 extract-description )
2278 if test -n "$module"; then
2279 func_get_description "$module"
2288 if test -n "$module"; then
2289 func_get_filelist "$module"
2294 extract-dependencies )
2298 if test -n "$module"; then
2299 func_get_dependencies "$module"
2304 extract-autoconf-snippet )
2308 if test -n "$module"; then
2309 func_get_autoconf_snippet "$module"
2314 extract-automake-snippet )
2318 if test -n "$module"; then
2319 func_get_automake_snippet "$module"
2324 extract-include-directive )
2328 if test -n "$module"; then
2329 func_get_include_directive "$module"
2338 if test -n "$module"; then
2339 func_get_license "$module"
2344 extract-maintainer )
2348 if test -n "$module"; then
2349 func_get_maintainer "$module"
2354 extract-tests-module )
2358 if test -n "$module"; then
2359 func_get_tests_module "$module"
2365 func_fatal_error "unknown operation mode --$mode" ;;
2369 # Undo the effect of the previous 'trap' command. Some shellology:
2370 # We cannot use "trap - 0 1 2 3 15", because Solaris sh would attempt to
2371 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
2372 # exit); for the others we need to call 'exit' explicitly. The value of $? is
2373 # 128 + signal number and is set before the trap-registered command is run.
2375 trap 'exit $?' 1 2 3 15