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-26 06:39:32 $'
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.
647 echo "gnulib-tool: module $module doesn't exist" 1>&2
652 # func_verify_nontests_module
653 # verifies a module name, excluding tests modules
654 func_verify_nontests_module ()
658 * ) func_verify_module ;;
662 # func_verify_tests_module
663 # verifies a module name, considering only tests modules
664 func_verify_tests_module ()
667 *-tests ) func_verify_module ;;
672 sed_extract_prog=':[ ]*$/ {
675 s/^Description:[ ]*$//
677 s/^Depends-on:[ ]*$//
678 s/^configure\.ac:[ ]*$//
679 s/^Makefile\.am:[ ]*$//
682 s/^Maintainer:[ ]*$//
689 # func_get_description module
690 func_get_description ()
692 func_lookup_file "modules/$1"
693 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
696 # func_get_filelist module
699 func_lookup_file "modules/$1"
700 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
701 case "$autoconf_minversion" in
704 echo m4/onceonly_2_57.m4
709 # func_get_dependencies module
710 func_get_dependencies ()
712 # ${module}-tests always implicitly depends on ${module}.
713 echo "$1" | sed -n -e 's/-tests//p'
714 # Then the explicit dependencies listed in the module description.
715 func_lookup_file "modules/$1"
716 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
719 # func_get_autoconf_snippet module
720 func_get_autoconf_snippet ()
722 func_lookup_file "modules/$1"
723 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
726 # func_get_automake_snippet module
727 func_get_automake_snippet ()
729 func_lookup_file "modules/$1"
730 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
733 # func_get_include_directive module
734 func_get_include_directive ()
736 func_lookup_file "modules/$1"
737 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
738 sed -e 's/^\(["<]\)/#include \1/'
741 # func_get_license module
744 func_lookup_file "modules/$1"
745 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
748 # func_get_maintainer module
749 func_get_maintainer ()
751 func_lookup_file "modules/$1"
752 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
755 # func_get_tests_module module
756 func_get_tests_module ()
758 # The naming convention for tests modules is hardwired: ${module}-tests.
759 if test -f modules/"$1"-tests; then
764 # func_acceptable module
765 # tests whether a module is acceptable.
767 # - avoidlist list of modules to avoid
770 for avoid in $avoidlist; do
771 if test "$avoid" = "$1"; then
778 # func_modules_transitive_closure
780 # - modules list of specified modules
781 # - inctests true if tests should be included, blank otherwise
782 # - avoidlist list of modules to avoid
784 # - modules list of modules, including dependencies
785 func_modules_transitive_closure ()
789 for module in $modules; do
791 if test -n "$module"; then
792 # Duplicate dependencies are harmless, but Jim wants a warning.
793 duplicated_deps=`func_get_dependencies $module | LC_ALL=C sort | LC_ALL=C uniq -d`
794 if test -n "$duplicated_deps"; then
795 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
797 if func_acceptable $module; then
798 xmodules="$xmodules $module"
799 for depmodule in `func_get_dependencies $module`; do
800 if func_acceptable $depmodule; then
801 xmodules="$xmodules $depmodule"
804 if test -n "$inctests"; then
805 testsmodule=`func_get_tests_module $module`
806 if test -n "$testsmodule"; then
807 if func_acceptable $testsmodule; then
808 xmodules="$xmodules $testsmodule"
809 for depmodule in `func_get_dependencies $testsmodule`; do
810 if func_acceptable $depmodule; then
811 xmodules="$xmodules $depmodule"
820 xmodules=`for m in $xmodules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
821 if test "$xmodules" = "$modules"; then
828 # func_modules_add_dummy
830 # - modules list of modules, including dependencies
832 # - modules list of modules, including 'dummy' if needed
833 func_modules_add_dummy ()
836 sed_remove_backslash_newline=':a
843 for module in $modules; do
844 func_verify_nontests_module
845 if test -n "$module"; then
846 # Extract the value of "lib_SOURCES += ...".
847 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
848 # Ignore .h files since they are not compiled.
851 *) have_lib_SOURCES=yes ;;
856 # Add the dummy module, to make sure the library will be non-empty.
857 if test -z "$have_lib_SOURCES"; then
858 modules="$modules dummy"
862 # func_modules_to_filelist
864 # - modules list of modules, including dependencies
866 # - files list of files
867 func_modules_to_filelist ()
870 for module in $modules; do
872 if test -n "$module"; then
873 files="$files "`func_get_filelist $module`
876 files=`for f in $files; do echo $f; done | LC_ALL=C sort | LC_ALL=C uniq`
879 # func_emit_lib_Makefile_am
880 # emits the contents of lib/Makefile.am to standard output.
882 # - modules list of modules, including dependencies
883 # - libname library name
884 # - libtool true if libtool will be used, false or blank otherwise
885 # - actioncmd (optional) command that will reproduce this invocation
886 func_emit_lib_Makefile_am ()
888 if test "$libtool" = true; then
895 echo "## Process this file with automake to produce Makefile.in."
896 func_emit_copyright_notice
897 if test -n "$actioncmd"; then
898 echo "# Reproduce by: $actioncmd"
901 # No need to generate dependencies since the sources are in gnulib, not here.
902 echo "AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies"
905 for module in $modules; do
906 func_verify_nontests_module
907 if test -n "$module"; then
909 func_get_automake_snippet "$module" |
910 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
911 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
912 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
913 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
914 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
915 if test "$module" = 'alloca'; then
916 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
919 # Skip the contents if its entirely empty.
920 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
921 echo "## begin gnulib module $module"
924 echo "## end gnulib module $module"
931 if grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
932 # One of the snippets already specifies an installation location for the
933 # library. Don't confuse automake by saying it should not be installed.
936 # By default, the generated library should not be installed.
937 echo "noinst_${perhapsLT}LIBRARIES = $libname.$libext"
940 echo "${libname}_${libext}_SOURCES ="
941 echo "${libname}_${libext}_LIBADD = @${perhapsLT}LIBOBJS@"
942 echo "noinst_HEADERS ="
943 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
944 echo "pkgdata_DATA ="
947 echo "BUILT_SOURCES ="
949 echo "MOSTLYCLEANFILES = core *.stackdump"
950 echo "MOSTLYCLEANDIRS ="
952 echo "DISTCLEANFILES ="
953 echo "MAINTAINERCLEANFILES ="
959 echo "mostlyclean-local: mostlyclean-generic"
960 echo " @test -z \"\$(MOSTLYCLEANDIRS)\" || \\"
961 echo " for dir in \$(MOSTLYCLEANDIRS); do \\"
962 echo " if test -d \$\$dir; then \\"
963 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
967 echo "# Makefile.am ends here"
968 rm -f allsnippets.tmp
971 # func_emit_tests_Makefile_am
972 # emits the contents of tests/Makefile.am to standard output.
974 # - modules list of modules, including dependencies
975 # - libname library name
976 # - libtool true if libtool will be used, false or blank otherwise
977 # - sourcebase relative directory containing lib source code
978 # - m4base relative directory containing autoconf macros
979 # - testsbase relative directory containing unit test code
980 func_emit_tests_Makefile_am ()
982 if test "$libtool" = true; then
987 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
988 echo "## Process this file with automake to produce Makefile.in."
989 func_emit_copyright_notice
991 # Generate dependencies here, since it eases the debugging of test failures.
992 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
994 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
997 for module in $modules; do
998 func_verify_tests_module
999 if test -n "$module"; then
1000 func_get_automake_snippet "$module" > amsnippet.tmp
1001 # Skip the contents if its entirely empty.
1002 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1003 echo "## begin gnulib module $module"
1006 echo "## end gnulib module $module"
1013 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1014 # variable is needed to avoid an error from automake:
1015 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1018 echo "TESTS_ENVIRONMENT ="
1019 echo "noinst_PROGRAMS ="
1020 echo "check_PROGRAMS ="
1021 echo "noinst_HEADERS ="
1022 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1023 echo "pkgdata_DATA ="
1026 echo "BUILT_SOURCES ="
1028 echo "MOSTLYCLEANFILES = core *.stackdump"
1029 echo "MOSTLYCLEANDIRS ="
1031 echo "DISTCLEANFILES ="
1032 echo "MAINTAINERCLEANFILES ="
1034 echo "AM_CPPFLAGS = \\"
1035 echo " -I. -I\$(srcdir) \\"
1036 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1037 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1039 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1042 echo "# Clean up after Solaris cc."
1044 echo " rm -rf SunWS_cache"
1046 echo "mostlyclean-local: mostlyclean-generic"
1047 echo " @test -z \"\$(MOSTLYCLEANDIRS)\" || \\"
1048 echo " for dir in \$(MOSTLYCLEANDIRS); do \\"
1049 echo " if test -d \$\$dir; then \\"
1050 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1054 echo "# Makefile.am ends here"
1055 rm -f allsnippets.tmp
1058 # func_import modules
1059 # Uses also the variables
1060 # - destdir target directory
1061 # - libname library name
1062 # - sourcebase directory relative to destdir where to place source code
1063 # - m4base directory relative to destdir where to place *.m4 macros
1064 # - docbase directory relative to destdir where to place doc files
1065 # - testsbase directory relative to destdir where to place unit test code
1066 # - auxdir directory relative to destdir where to place build aux files
1067 # - inctests true if --with-tests was given, blank otherwise
1068 # - avoidlist list of modules to avoid, from --avoid
1069 # - lgpl true if library's license shall be LGPL, blank otherwise
1070 # - libtool true if --libtool was given, false if --no-libtool was
1071 # given, blank otherwise
1072 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1073 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1074 # - autoconf_minversion minimum supported autoconf version
1075 # - doit : if actions shall be executed, false if only to be printed
1076 # - symbolic true if files should be symlinked, copied otherwise
1079 # Get the cached settings.
1080 cached_specified_modules=
1089 cached_macro_prefix=
1091 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1092 cached_libtool=false
1098 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1101 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1104 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1107 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1110 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1113 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1116 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1119 s,^.*$,cached_lgpl=true,p
1122 s,^.*$,cached_libtool=true,p
1124 /gl_MACRO_PREFIX(/ {
1125 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
1127 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
1128 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1133 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
1134 s,^.*$,cached_files=",p
1146 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1150 # Merge the cached settings with the specified ones.
1151 # The m4base must be the same as expected from the pathname.
1152 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1153 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1155 # Append the cached and the specified module names. So that
1156 # "gnulib-tool --import foo" means to add the module foo.
1157 specified_modules="$cached_specified_modules $1"
1158 # Append the cached and the specified avoidlist. This is probably better
1159 # than dropping the cached one when --avoid is specified at least once.
1160 avoidlist=`echo $cached_avoidlist $avoidlist`
1161 # The sourcebase defaults to the cached one.
1162 if test -z "$sourcebase"; then
1163 sourcebase="$cached_sourcebase"
1164 if test -z "$sourcebase"; then
1165 func_fatal_error "missing --source-base option"
1168 # The docbase defaults to the cached one.
1169 if test -z "$docbase"; then
1170 docbase="$cached_docbase"
1171 if test -z "$docbase"; then
1172 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."
1175 # The testsbase defaults to the cached one.
1176 if test -z "$testsbase"; then
1177 testsbase="$cached_testsbase"
1178 if test -z "$testsbase"; then
1179 func_fatal_error "missing --tests-base option"
1182 # The libname defaults to the cached one.
1183 if test -z "$supplied_libname"; then
1184 libname="$cached_libname"
1185 if test -z "$libname"; then
1186 func_fatal_error "missing --lib option"
1189 # Require LGPL if specified either way.
1190 if test -z "$lgpl"; then
1193 # Use libtool if specified either way, or if guessed.
1194 if test -z "$libtool"; then
1195 if test -n "$cached_m4base"; then
1196 libtool="$cached_libtool"
1198 libtool="$guessed_libtool"
1201 # The macro_prefix defaults to the cached one.
1202 if test -z "$macro_prefix"; then
1203 macro_prefix="$cached_macro_prefix"
1204 if test -z "$macro_prefix"; then
1205 func_fatal_error "missing --macro-prefix option"
1209 # Canonicalize the list of specified modules.
1210 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
1212 # Determine final module list.
1213 modules="$specified_modules"
1214 func_modules_transitive_closure
1215 echo "Module list with included dependencies:"
1216 echo "$modules" | sed -e 's/^/ /'
1218 # Add the dummy module if needed.
1219 func_modules_add_dummy
1221 # If --lgpl, check the license of modules are compatible.
1222 if test -n "$lgpl"; then
1223 for module in $modules; do
1224 license=`func_get_license $module`
1226 LGPL | 'GPLed build tool' | 'public domain' | 'unlimited') ;;
1227 *) func_fatal_error "incompatible license on module $module: $license" ;;
1232 # Determine script to apply to imported library files.
1233 sed_transform_lib_file=
1234 case $nl$modules$nl in
1235 *"${nl}config-h$nl"*)
1236 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
1237 sed_transform_lib_file=$sed_transform_lib_file'
1238 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
1241 if test -n "$lgpl"; then
1243 sed_transform_lib_file=$sed_transform_lib_file'
1244 s/GNU General/GNU Lesser General/g
1245 s/version 2\([ ,]\)/version 2.1\1/g
1249 # Determine final file list.
1250 func_modules_to_filelist
1252 echo "$files" | sed -e 's/^/ /'
1255 || func_fatal_error "refusing to do nothing"
1257 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
1258 new_files="$files m4/gnulib-tool.m4"
1259 old_files="$cached_files"
1260 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
1261 old_files="$old_files m4/gnulib-tool.m4"
1264 # Create directories.
1265 if test ! -d "$destdir/$sourcebase"; then
1267 echo "Creating directory $destdir/$sourcebase"
1268 mkdir "$destdir/$sourcebase" || func_fatal_error "failed"
1270 echo "Create directory $destdir/$sourcebase"
1273 if test ! -d "$destdir/$m4base"; then
1275 echo "Creating directory $destdir/$m4base"
1276 mkdir "$destdir/$m4base" || func_fatal_error "failed"
1278 echo "Create directory $destdir/$m4base"
1281 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
1282 if test -n "$docfiles"; then
1283 if test ! -d "$destdir/$docbase"; then
1285 echo "Creating directory $destdir/$docbase"
1286 mkdir "$destdir/$docbase" || func_fatal_error "failed"
1288 echo "Create directory $destdir/$docbase"
1292 if test -n "$inctests"; then
1293 if test ! -d "$destdir/$testsbase"; then
1295 echo "Creating directory $destdir/$testsbase"
1296 mkdir "$destdir/$testsbase" || func_fatal_error "failed"
1298 echo "Create directory $destdir/$testsbase"
1302 if test ! -d "$destdir/$auxdir"; then
1304 echo "Creating directory $destdir/$auxdir"
1305 mkdir "$destdir/$auxdir" || func_fatal_error "failed"
1307 echo "Create directory $destdir/$auxdir"
1311 # func_dest_tmpfilename file
1312 # determines the name of a temporary file (file is relative to destdir).
1314 # - tmpfile absolute filename of the temporary file
1315 func_dest_tmpfilename ()
1318 # Put the new contents of $file in a file in the same directory (needed
1319 # to guarantee that an 'mv' to "$destdir/$file" works).
1320 tmpfile="$destdir/$1.tmp"
1322 # Put the new contents of $file in a file in a temporary directory
1323 # (because the directory of "$file" might not exist).
1324 tmpfile="$tmp"/`basename "$1"`.tmp
1328 # Copy files or make symbolic links. Remove obsolete files.
1330 for f in $old_files; do
1332 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1333 doc/*) g=`echo "$f" | sed -e "s,^doc/,$cached_docbase/,"` ;;
1334 lib/*) g=`echo "$f" | sed -e "s,^lib/,$cached_sourcebase/,"` ;;
1335 m4/*) g=`echo "$f" | sed -e "s,^m4/,$cached_m4base/,"` ;;
1336 tests/*) g=`echo "$f" | sed -e "s,^tests/,$cached_testsbase/,"` ;;
1339 echo "$g""$delimiter""$f"
1340 done | LC_ALL=C sort > "$tmp"/old-files
1341 for f in $new_files; do
1343 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1344 doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
1345 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1346 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1347 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1350 echo "$g""$delimiter""$f"
1351 done | LC_ALL=C sort > "$tmp"/new-files
1352 # First the files that are in old-files, but not in new-files:
1353 sed_take_first_column='s,'"$delimiter"'.*,,'
1354 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
1355 # Remove the file. Do nothing if the user already removed it.
1356 if test -f "$destdir/$g"; then
1358 echo "Removing file $g (backup in ${g}~)"
1359 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1361 echo "Remove file $g (backup in ${g}~)"
1365 # func_add_or_update handles a file that ought to be present afterwards.
1366 # Uses parameters f, g, already_present.
1367 func_add_or_update ()
1369 func_dest_tmpfilename "$g"
1370 func_lookup_file "$f"
1371 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
1372 if test -n "sed_transform_lib_file"; then
1375 sed -e "$sed_transform_lib_file" \
1376 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
1380 if test -f "$destdir/$g"; then
1381 # The file already exists.
1382 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1383 : # The file has not changed.
1387 if test -n "$already_present"; then
1388 echo "Updating file $g (backup in ${g}~)"
1390 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
1392 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1393 if test -n "$symbolic" && test -z "$lookedup_tmp" \
1394 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1395 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1397 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1400 if test -n "$already_present"; then
1401 echo "Update file $g (backup in ${g}~)"
1403 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
1409 # Don't protest if the file should be there but isn't: it happens
1410 # frequently that developers don't put autogenerated files into CVS.
1412 echo "Copying file $g"
1413 if test -n "$symbolic" && test -z "$lookedup_tmp" \
1414 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1415 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1417 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1425 # Then the files that are in new-files, but not in old-files:
1426 sed_take_last_column='s,^.*'"$delimiter"',,'
1428 for f in `LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_last_column"`; do
1430 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1431 doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
1432 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1433 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1434 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1439 # Then the files that are in new-files and in old-files:
1440 already_present=true
1441 for f in `LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_last_column"`; do
1443 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1444 doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
1445 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1446 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1447 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1453 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
1454 actioncmd="gnulib-tool --import"
1455 actioncmd="$actioncmd --dir=$destdir"
1456 actioncmd="$actioncmd --lib=$libname"
1457 actioncmd="$actioncmd --source-base=$sourcebase"
1458 actioncmd="$actioncmd --m4-base=$m4base"
1459 actioncmd="$actioncmd --doc-base=$docbase"
1460 actioncmd="$actioncmd --aux-dir=$auxdir"
1461 for module in $avoidlist; do
1462 actioncmd="$actioncmd --avoid=$module"
1464 if test -n "$lgpl"; then
1465 actioncmd="$actioncmd --lgpl"
1467 if test "$libtool" = true; then
1468 actioncmd="$actioncmd --libtool"
1470 actioncmd="$actioncmd --no-libtool"
1472 actioncmd="$actioncmd --macro-prefix=$macro_prefix"
1473 actioncmd="$actioncmd `echo $specified_modules`"
1475 # Create lib/Makefile.am.
1476 func_dest_tmpfilename $sourcebase/Makefile.am
1477 func_emit_lib_Makefile_am > "$tmpfile"
1478 if test -f "$destdir"/$sourcebase/Makefile.am; then
1479 if cmp "$destdir"/$sourcebase/Makefile.am "$tmpfile" > /dev/null; then
1483 echo "Updating $sourcebase/Makefile.am (backup in $sourcebase/Makefile.am~)"
1484 mv -f "$destdir"/$sourcebase/Makefile.am "$destdir"/$sourcebase/Makefile.am~
1485 mv -f "$tmpfile" "$destdir"/$sourcebase/Makefile.am
1487 echo "Update $sourcebase/Makefile.am (backup in $sourcebase/Makefile.am~)"
1493 echo "Creating $sourcebase/Makefile.am"
1494 mv -f "$tmpfile" "$destdir"/$sourcebase/Makefile.am
1496 echo "Create $sourcebase/Makefile.am"
1501 # Create m4/gnulib-cache.m4.
1502 func_dest_tmpfilename $m4base/gnulib-cache.m4
1504 func_emit_copyright_notice
1506 echo "# This file represents the specification of how gnulib-tool is used."
1507 echo "# It acts as a cache: It is written and read by gnulib-tool."
1508 echo "# In projects using CVS, this file is meant to be stored in CVS,"
1509 echo "# like the configure.ac and various Makefile.am files."
1512 echo "# Specification in the form of a command-line invocation:"
1515 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
1516 echo "gl_MODULES(["`echo $specified_modules`"])"
1517 echo "gl_AVOID([$avoidlist])"
1518 echo "gl_SOURCE_BASE([$sourcebase])"
1519 echo "gl_M4_BASE([$m4base])"
1520 echo "gl_DOC_BASE([$docbase])"
1521 echo "gl_TESTS_BASE([$testsbase])"
1522 echo "gl_LIB([$libname])"
1523 test -z "$lgpl" || echo "gl_LGPL"
1524 if test "$libtool" = true; then
1527 echo "gl_MACRO_PREFIX([$macro_prefix])"
1529 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1530 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
1534 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1535 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
1536 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
1538 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1542 echo "# gnulib-cache.m4 ends here"
1549 echo "Creating $m4base/gnulib-cache.m4"
1550 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
1552 echo "Create $m4base/gnulib-cache.m4"
1558 # Create m4/gnulib-comp.m4.
1559 func_dest_tmpfilename $m4base/gnulib-comp.m4
1561 func_emit_copyright_notice
1563 echo "# This file represents the compiled summary of the specification in"
1564 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
1565 echo "# to be invoked from configure.ac."
1566 echo "# In projects using CVS, this file can be treated like other built files."
1569 echo "# This macro should be invoked from $configure_ac, in the section"
1570 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
1571 echo "# any checks for libraries, header files, types and library functions."
1572 echo "AC_DEFUN([${macro_prefix}_EARLY],"
1574 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
1575 echo " m4_pattern_allow([^gl_ES$])dnl a valid locale name"
1576 echo " AC_REQUIRE([AC_PROG_RANLIB])"
1577 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1578 echo " AC_REQUIRE([AC_GNU_SOURCE])"
1580 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1581 echo " AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])"
1583 if grep gl_LOCK "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1584 echo " AC_REQUIRE([gl_LOCK_EARLY])"
1588 echo "# This macro should be invoked from $configure_ac, in the section"
1589 echo "# \"Check for header files, types and library functions\"."
1590 echo "AC_DEFUN([${macro_prefix}_INIT],"
1592 if test "$libtool" = true; then
1593 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1595 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1597 if test "$auxdir" != "build-aux"; then
1598 sed_replace_build_aux='
1600 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
1601 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
1604 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
1606 sed_replace_build_aux=
1608 for module in $modules; do
1610 if test -n "$module"; then
1611 func_get_autoconf_snippet "$module" \
1612 | sed -e '/^$/d;' -e 's/^/ /' \
1613 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
1614 -e "$sed_replace_build_aux"
1615 if test "$module" = 'alloca' && test "$libtool" = true; then
1616 echo 'changequote(,)dnl'
1617 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
1618 echo 'changequote([, ])dnl'
1619 echo 'AC_SUBST([LTALLOCA])'
1625 echo "# This macro records the list of files which have been installed by"
1626 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
1627 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
1628 echo "$files" | sed -e 's,^, ,'
1631 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1632 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
1636 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1637 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
1638 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
1640 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1644 echo "# gnulib-comp.m4 ends here"
1651 echo "Creating $m4base/gnulib-comp.m4"
1652 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
1654 echo "Create $m4base/gnulib-comp.m4"
1660 if test -n "$inctests"; then
1661 # Create tests/Makefile.am.
1662 func_dest_tmpfilename $testsbase/Makefile.am
1663 func_emit_tests_Makefile_am > "$tmpfile"
1664 if test -f "$destdir"/$testsbase/Makefile.am; then
1665 if cmp "$destdir"/$testsbase/Makefile.am "$tmpfile" > /dev/null; then
1669 echo "Updating $testsbase/Makefile.am (backup in $testsbase/Makefile.am~)"
1670 mv -f "$destdir"/$testsbase/Makefile.am "$destdir"/$testsbase/Makefile.am~
1671 mv -f "$tmpfile" "$destdir"/$testsbase/Makefile.am
1673 echo "Update $testsbase/Makefile.am (backup in $testsbase/Makefile.am~)"
1679 echo "Creating $testsbase/Makefile.am"
1680 mv -f "$tmpfile" "$destdir"/$testsbase/Makefile.am
1682 echo "Create $testsbase/Makefile.am"
1690 echo "You may need to add #include directives for the following .h files."
1692 # First the #include <...> directives without #ifs, sorted for convenience.
1693 for module in $modules; do
1694 if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
1697 func_get_include_directive "$module" | grep -v 'include "'
1699 done | LC_ALL=C sort -u
1700 # Then the #include "..." directives without #ifs, sorted for convenience.
1701 for module in $modules; do
1702 if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
1705 func_get_include_directive "$module" | grep 'include "'
1707 done | LC_ALL=C sort -u
1708 # Then the #include directives that are surrounded by #ifs. Not sorted.
1709 for module in $modules; do
1710 if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
1711 func_get_include_directive "$module"
1714 ) | sed -e '/^$/d;' -e 's/^/ /'
1716 echo "Don't forget to"
1717 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1718 if test -n "$inctests"; then
1719 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1721 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
1722 sourcebase_base=`basename "$sourcebase"`
1723 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
1724 if test -n "$inctests"; then
1725 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
1726 testsbase_base=`basename "$testsbase"`
1727 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
1729 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
1730 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
1731 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
1734 # func_create_testdir testdir modules
1736 # - auxdir directory relative to destdir where to place build aux files
1737 func_create_testdir ()
1741 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
1743 # Subdirectory names.
1748 # Determine final module list.
1749 func_modules_transitive_closure
1750 echo "Module list with included dependencies:"
1751 echo "$modules" | sed -e 's/^/ /'
1753 # Add the dummy module if needed.
1754 func_modules_add_dummy
1756 # Determine final file list.
1757 func_modules_to_filelist
1759 echo "$files" | sed -e 's/^/ /'
1761 # Create directories.
1762 for d in `echo "$files" | sed -n -e 's,^\(.*\)/[^/]*,\1,p'`; do
1764 build-aux) mkdir -p "$testdir/$auxdir" ;;
1765 lib) mkdir -p "$testdir/$sourcebase" ;;
1766 m4) mkdir -p "$testdir/$m4base" ;;
1767 tests) mkdir -p "$testdir/$testsbase" ;;
1768 *) mkdir -p "$testdir/$d" ;;
1772 # Copy files or make symbolic links.
1774 func_lookup_file "$f"
1776 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1777 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1778 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1779 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1782 if test -n "$lookedup_tmp"; then
1783 cp -p "$lookedup_file" "$testdir/$g"
1785 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
1786 if test -z "$symbolic"; then
1787 cp -p "$lookedup_file" "$testdir/$g"
1789 ln -s "$lookedup_file" "$testdir/$g"
1794 # Create $sourcebase/Makefile.am.
1795 mkdir -p "$testdir/$sourcebase"
1796 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
1798 # Create $m4base/Makefile.am.
1799 mkdir -p "$testdir/$m4base"
1800 (echo "## Process this file with automake to produce Makefile.in."
1806 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
1809 ) > "$testdir/$m4base/Makefile.am"
1811 subdirs="$sourcebase $m4base"
1812 subdirs_with_configure_ac=""
1814 if test -f "$testdir"/$m4base/gettext.m4; then
1815 # Avoid stupid error message from automake:
1816 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
1817 mkdir -p "$testdir/po"
1818 (echo "## Process this file with automake to produce Makefile.in."
1819 ) > "$testdir/po/Makefile.am"
1820 subdirs="$subdirs po"
1823 if test -n "$inctests"; then
1824 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
1825 # Create $testsbase/Makefile.am.
1826 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
1827 # Create $testsbase/configure.ac.
1828 (echo "# Process this file with autoconf to produce a configure script."
1829 echo "AC_INIT([dummy], [0])"
1830 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
1831 echo "AM_INIT_AUTOMAKE"
1833 echo "AM_CONFIG_HEADER([config.h])"
1836 echo "AC_PROG_INSTALL"
1837 echo "AC_PROG_MAKE_SET"
1838 echo "AC_PROG_RANLIB"
1840 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
1841 echo "AC_GNU_SOURCE"
1844 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
1845 echo "gl_USE_SYSTEM_EXTENSIONS"
1848 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
1849 echo "gl_LOCK_EARLY"
1852 if test "$libtool" = true; then
1853 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1855 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1857 # Wrap the set of autoconf snippets into an autoconf macro that is then
1858 # invoked. This is needed because autoconf does not support AC_REQUIRE
1860 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
1861 # but we want the AC_REQUIRE to have its normal meaning (provide one
1862 # expansion of the required macro before the current point, and only one
1864 echo "AC_DEFUN([gl_INIT], ["
1865 if test "$auxdir" != "build-aux"; then
1866 sed_replace_build_aux='
1868 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
1869 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
1872 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
1874 sed_replace_build_aux=
1876 # We don't have explicit ordering constraints between the various
1877 # autoconf snippets. It's cleanest to put those of the library before
1878 # those of the tests.
1879 for module in $modules; do
1880 func_verify_nontests_module
1881 if test -n "$module"; then
1882 func_get_autoconf_snippet "$module" \
1883 | sed -e "$sed_replace_build_aux"
1886 for module in $modules; do
1887 func_verify_tests_module
1888 if test -n "$module"; then
1889 func_get_autoconf_snippet "$module" \
1890 | sed -e "$sed_replace_build_aux"
1896 # Usually $testsbase/config.h will be a superset of config.h. Verify this
1897 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
1898 echo "AH_TOP([#include \"../config.h\"])"
1900 echo "AC_OUTPUT([Makefile])"
1901 ) > "$testdir/$testsbase/configure.ac"
1902 subdirs="$subdirs $testsbase"
1903 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
1906 # Create Makefile.am.
1907 (echo "## Process this file with automake to produce Makefile.in."
1909 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1911 echo "SUBDIRS = $subdirs"
1913 echo "ACLOCAL_AMFLAGS = -I $m4base"
1914 ) > "$testdir/Makefile.am"
1916 # Create configure.ac.
1917 (echo "# Process this file with autoconf to produce a configure script."
1918 echo "AC_INIT([dummy], [0])"
1919 if test "$auxdir" != "."; then
1920 echo "AC_CONFIG_AUX_DIR([$auxdir])"
1922 echo "AM_INIT_AUTOMAKE"
1924 echo "AM_CONFIG_HEADER([config.h])"
1927 echo "AC_PROG_INSTALL"
1928 echo "AC_PROG_MAKE_SET"
1930 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
1931 echo "m4_pattern_allow([^gl_ES$])dnl a valid locale name"
1933 echo "AC_PROG_RANLIB"
1935 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
1936 echo "AC_GNU_SOURCE"
1939 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
1940 echo "gl_USE_SYSTEM_EXTENSIONS"
1943 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
1944 echo "gl_LOCK_EARLY"
1947 if test "$libtool" = true; then
1948 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1950 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1952 # Wrap the set of autoconf snippets into an autoconf macro that is then
1953 # invoked. This is needed because autoconf does not support AC_REQUIRE
1955 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
1956 # but we want the AC_REQUIRE to have its normal meaning (provide one
1957 # expansion of the required macro before the current point, and only one
1959 echo "AC_DEFUN([gl_INIT], ["
1960 if test "$auxdir" != "build-aux"; then
1961 sed_replace_build_aux='
1963 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
1964 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
1967 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
1969 sed_replace_build_aux=
1971 for module in $modules; do
1972 func_verify_nontests_module
1973 if test -n "$module"; then
1974 func_get_autoconf_snippet "$module" \
1975 | sed -e "$sed_replace_build_aux"
1981 if test -n "$subdirs_with_configure_ac"; then
1982 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
1984 makefiles="Makefile"
1985 for d in $subdirs; do
1986 # For subdirs that have a configure.ac by their own, it's the subdir's
1987 # configure.ac which creates the subdir's Makefile.am, not this one.
1988 case " $subdirs_with_configure_ac " in
1990 *) makefiles="$makefiles $d/Makefile" ;;
1993 echo "AC_OUTPUT([$makefiles])"
1994 ) > "$testdir/configure.ac"
1996 # Create autogenerated files.
1998 echo "executing ${AUTORECONF} --force --install"
1999 ${AUTORECONF} --force --install
2001 if grep '^BUILT_SOURCES *+=' "$testdir/$sourcebase/Makefile.am" > /dev/null; then
2005 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
2013 # func_create_megatestdir megatestdir allmodules
2015 # - auxdir directory relative to destdir where to place build aux files
2016 func_create_megatestdir ()
2020 if test -z "$allmodules"; then
2021 allmodules=`func_all_modules`
2025 # First, all modules one by one.
2026 for onemodule in $allmodules; do
2027 func_create_testdir "$megatestdir/$onemodule" $onemodule
2028 megasubdirs="${megasubdirs}$onemodule "
2030 # Then, all modules all together.
2031 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2032 allmodules=`for m in $allmodules; do if test $m != fnmatch-posix; then echo $m; fi; done`
2033 func_create_testdir "$megatestdir/ALL" "$allmodules"
2034 megasubdirs="${megasubdirs}ALL"
2036 # Create Makefile.am.
2037 (echo "## Process this file with automake to produce Makefile.in."
2039 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2041 echo "SUBDIRS = $megasubdirs"
2042 ) > "$megatestdir/Makefile.am"
2044 # Create configure.ac.
2045 (echo "# Process this file with autoconf to produce a configure script."
2046 echo "AC_INIT([dummy], [0])"
2047 if test "$auxdir" != "."; then
2048 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2050 echo "AM_INIT_AUTOMAKE"
2052 echo "AC_PROG_MAKE_SET"
2054 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
2055 echo "AC_OUTPUT([Makefile])"
2056 ) > "$megatestdir/configure.ac"
2058 # Create autogenerated files.
2060 # Do not use "${AUTORECONF} --install", because autoreconf operates
2061 # recursively, but the subdirectories are already finished, therefore
2062 # calling autoreconf here would only waste lots of CPU time.
2063 echo "executing ${ACLOCAL}"
2065 echo "executing mkdir build-aux"
2067 echo "executing ${AUTOCONF}"
2069 echo "executing ${AUTOMAKE} --add-missing --copy"
2070 ${AUTOMAKE} --add-missing --copy
2076 func_fatal_error "no mode specified" ;;
2085 if test -z "$destdir"; then
2088 test -d "$destdir" \
2089 || func_fatal_error "destination directory does not exist: $destdir"
2091 # Prefer configure.ac to configure.in.
2092 if test -f "$destdir"/configure.ac; then
2093 configure_ac="$destdir/configure.ac"
2095 if test -f "$destdir"/configure.in; then
2096 configure_ac="$destdir/configure.in"
2098 func_fatal_error "cannot find $destdir/configure.ac"
2102 # Analyze configure.ac.
2104 guessed_libtool=false
2109 /AC_CONFIG_AUX_DIR/ {
2110 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
2112 /A[CM]_PROG_LIBTOOL/ {
2113 s,^.*$,guessed_libtool=true,p
2115 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
2117 if test -z "$auxdir"; then
2118 auxdir="$guessed_auxdir"
2121 # Determine where to apply func_import.
2122 if test -n "$m4base"; then
2123 # Apply func_import to a particular gnulib directory.
2124 # Any number of additional modules can be given.
2125 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
2126 # First use of gnulib in the given m4base.
2127 test -n "$supplied_libname" || supplied_libname=true
2128 test -n "$sourcebase" || sourcebase="lib"
2129 test -n "$docbase" || docbase="doc"
2130 test -n "$testsbase" || testsbase="tests"
2131 test -n "$macro_prefix" || macro_prefix="gl"
2135 # Apply func_import to all gnulib directories.
2136 # To get this list of directories, look at Makefile.am. (Not at
2137 # configure, because it may be omitted from CVS. Also, don't run
2138 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
2141 if test -f "$destdir"/Makefile.am; then
2142 aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$destdir"/Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'`
2144 for arg in $aclocal_amflags; do
2145 if test -n "$m4dir_is_next"; then
2146 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
2150 if test -f "$destdir/$arg"/gnulib-cache.m4; then
2151 m4dirs="$m4dirs $arg"
2152 m4dirs_count=`expr $m4dirs_count + 1`
2157 if test "X$arg" = "X-I"; then
2165 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
2166 if test -f "$destdir"/aclocal.m4; then
2167 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
2168 sedexpr2='s,^[^/]*$,.,'
2169 sedexpr3='s,/[^/]*$,,'
2170 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort | LC_ALL=C uniq`
2171 m4dirs_count=`echo "$m4dirs" | wc -l`
2174 if test $m4dirs_count = 0; then
2175 # First use of gnulib in a package.
2176 # Any number of additional modules can be given.
2177 test -n "$supplied_libname" || supplied_libname=true
2178 test -n "$sourcebase" || sourcebase="lib"
2180 test -n "$docbase" || docbase="doc"
2181 test -n "$testsbase" || testsbase="tests"
2182 test -n "$macro_prefix" || macro_prefix="gl"
2185 if test $m4dirs_count = 1; then
2186 # There's only one use of gnulib here. Assume the user means it.
2187 # Any number of additional modules can be given.
2188 for m4base in $m4dirs; do
2192 # Ambiguous - guess what the user meant.
2193 if test $# = 0; then
2194 # No further arguments. Guess the user wants to update all of them.
2195 for m4base in $m4dirs; do
2200 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
2208 if test -z "$destdir"; then
2209 func_fatal_error "please specify --dir option"
2212 test -d "$destdir" \
2213 || func_fatal_error "could not create destination directory"
2214 test -n "$auxdir" || auxdir="build-aux"
2215 func_create_testdir "$destdir" "$*"
2218 create-megatestdir )
2219 if test -z "$destdir"; then
2220 func_fatal_error "please specify --dir option"
2222 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2223 test -n "$auxdir" || auxdir="build-aux"
2224 func_create_megatestdir "$destdir" "$*"
2228 test -n "$destdir" || destdir=testdir$$
2229 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2230 test -n "$auxdir" || auxdir="build-aux"
2231 func_create_testdir "$destdir" "$*"
2239 remaining=`find . -type f -print`
2240 if test -n "$remaining"; then
2241 echo "Remaining files:" $remaining 1>&2
2242 echo "gnulib-tool: *** Stop." 1>&2
2251 test -n "$destdir" || destdir=testdir$$
2252 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2253 test -n "$auxdir" || auxdir="build-aux"
2254 func_create_megatestdir "$destdir" "$*"
2262 remaining=`find . -type f -print`
2263 if test -n "$remaining"; then
2264 echo "Remaining files:" $remaining 1>&2
2265 echo "gnulib-tool: *** Stop." 1>&2
2273 extract-description )
2277 if test -n "$module"; then
2278 func_get_description "$module"
2287 if test -n "$module"; then
2288 func_get_filelist "$module"
2293 extract-dependencies )
2297 if test -n "$module"; then
2298 func_get_dependencies "$module"
2303 extract-autoconf-snippet )
2307 if test -n "$module"; then
2308 func_get_autoconf_snippet "$module"
2313 extract-automake-snippet )
2317 if test -n "$module"; then
2318 func_get_automake_snippet "$module"
2323 extract-include-directive )
2327 if test -n "$module"; then
2328 func_get_include_directive "$module"
2337 if test -n "$module"; then
2338 func_get_license "$module"
2343 extract-maintainer )
2347 if test -n "$module"; then
2348 func_get_maintainer "$module"
2353 extract-tests-module )
2357 if test -n "$module"; then
2358 func_get_tests_module "$module"
2364 func_fatal_error "unknown operation mode --$mode" ;;
2368 # Undo the effect of the previous 'trap' command. Some shellology:
2369 # We cannot use "trap - 0 1 2 3 15", because Solaris sh would attempt to
2370 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
2371 # exit); for the others we need to call 'exit' explicitly. The value of $? is
2372 # 128 + signal number and is set before the trap-registered command is run.
2374 trap 'exit $?' 1 2 3 15