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:14:35 $'
26 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
27 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
29 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
33 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
34 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
38 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
41 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
42 # variables AUTOCONF, ACLOCAL, AUTOMAKE, AUTORECONF individually.
43 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
44 AUTOCONF="${AUTOCONFPATH}autoconf"
46 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
47 ACLOCAL="${AUTOMAKEPATH}aclocal"
49 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
50 AUTOMAKE="${AUTOMAKEPATH}automake"
52 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
53 AUTORECONF="${AUTOCONFPATH}autoreconf"
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 # func_relativize DIR1 DIR2
253 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
255 # - DIR1 relative pathname, relative to the current directory
256 # - DIR2 relative pathname, relative to the current directory
258 # - reldir relative pathname of DIR2, relative to DIR1
264 sed_first='s,^\([^/]*\)/.*$,\1,'
265 sed_rest='s,^[^/]*/*,,'
266 sed_last='s,^.*/\([^/]*\)$,\1,'
267 sed_butlast='s,/*[^/]*$,,'
268 while test -n "$dir1"; do
269 first=`echo "$dir1" | sed -e "$sed_first"`
270 if test "$first" != "."; then
271 if test "$first" = ".."; then
272 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
273 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
275 first2=`echo "$dir2" | sed -e "$sed_first"`
276 if test "$first2" = "$first"; then
277 dir2=`echo "$dir2" | sed -e "$sed_rest"`
281 dir0="$dir0"/"$first"
284 dir1=`echo "$dir1" | sed -e "$sed_rest"`
289 # func_relconcat DIR1 DIR2
290 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
292 # - DIR1 relative pathname, relative to the current directory
293 # - DIR2 relative pathname, relative to DIR1
295 # - relconcat DIR1/DIR2, relative to the current directory
300 sed_first='s,^\([^/]*\)/.*$,\1,'
301 sed_rest='s,^[^/]*/*,,'
302 sed_last='s,^.*/\([^/]*\)$,\1,'
303 sed_butlast='s,/*[^/]*$,,'
305 first=`echo "$dir2" | sed -e "$sed_first"`
306 if test "$first" = "."; then
307 dir2=`echo "$dir2" | sed -e "$sed_rest"`
308 if test -z "$dir2"; then
313 last=`echo "$dir1" | sed -e "$sed_last"`
314 while test "$last" = "."; do
315 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
316 last=`echo "$dir1" | sed -e "$sed_last"`
318 if test -z "$dir1"; then
322 if test "$first" = ".."; then
323 if test "$last" = ".."; then
324 relconcat="$dir1/$dir2"
327 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
328 dir2=`echo "$dir2" | sed -e "$sed_rest"`
329 if test -z "$dir1"; then
333 if test -z "$dir2"; then
338 relconcat="$dir1/$dir2"
345 # Command-line option processing.
346 # Removes the OPTIONS from the arguments. Sets the variables:
347 # - mode list or import or create-testdir or create-megatestdir
348 # - destdir from --dir
349 # - libname, supplied_libname from --lib
350 # - sourcebase from --source-base
351 # - m4base from --m4-base
352 # - docbase from --doc-base
353 # - testsbase from --tests-base
354 # - auxdir from --aux-dir
355 # - inctests true if --with-tests was given, blank otherwise
356 # - avoidlist list of modules to avoid, from --avoid
357 # - lgpl true if --lgpl was given, blank otherwise
358 # - libtool true if --libtool was given, false if --no-libtool was
359 # given, blank otherwise
360 # - macro_prefix from --macro-prefix
361 # - autoconf_minversion minimum supported autoconf version
362 # - do_changelog false if --no-changelog was given, : otherwise
363 # - doit : if actions shall be executed, false if only to be printed
364 # - local_gnulib_dir from --local-dir
365 # - symbolic true if --symbolic was given, blank otherwise
388 while test $# -gt 0; do
393 --import | --impor | --impo | --imp | --im | --i )
396 --update | --updat | --upda | --upd | --up | --u )
399 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
402 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
403 mode=create-megatestdir
405 --test | --tes | --te | --t )
408 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
412 mode=`echo "X$1" | sed -e 's/^X--//'`
417 func_fatal_error "missing argument for --dir"
422 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
427 func_fatal_error "missing argument for --lib"
430 supplied_libname=true
433 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
434 supplied_libname=true
439 func_fatal_error "missing argument for --source-base"
444 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
449 func_fatal_error "missing argument for --m4-base"
454 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
459 func_fatal_error "missing argument for --doc-base"
464 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
469 func_fatal_error "missing argument for --tests-base"
474 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
479 func_fatal_error "missing argument for --aux-dir"
484 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
492 func_fatal_error "missing argument for --avoid"
494 avoidlist="$avoidlist $1"
497 avoidlist="$avoidlist "`echo "X$1" | sed -e 's/^X--avoid=//'`
511 func_fatal_error "missing argument for --macro-prefix"
516 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
518 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
527 func_fatal_error "missing argument for --local-dir"
532 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
534 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
537 --help | --hel | --he | --h )
540 --version | --versio | --versi | --vers | --ver | --ve | --v )
544 # Stop option processing
548 echo "gnulib-tool: unknown option $1" 1>&2
549 echo "Try 'gnulib-tool --help' for more information." 1>&2
556 if test "$mode" = update; then
557 if test $# != 0; then
558 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
559 echo "Try 'gnulib-tool --help' for more information." 1>&2
560 echo "If you really want to modify the gnulib configuration of your project," 1>&2
561 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
564 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
565 || test -n "$sourcebase" || test -n "$m4base" \
566 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
567 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
568 || test -n "$macro_prefix"; then
569 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
570 echo "Try 'gnulib-tool --help' for more information." 1>&2
571 echo "If you really want to modify the gnulib configuration of your project," 1>&2
572 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
578 # Determine the minimum supported autoconf version from the project's
580 DEFAULT_AUTOCONF_MINVERSION="2.59"
583 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
584 if test -f "$destdir"/configure.ac; then
585 configure_ac="$destdir/configure.ac"
587 if test -f "$destdir"/configure.in; then
588 configure_ac="$destdir/configure.in"
592 if test -f configure.ac; then
593 configure_ac="configure.ac"
595 if test -f configure.in; then
596 configure_ac="configure.in"
600 if test -n "$configure_ac"; then
601 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
602 # because when some m4 files are omitted from a CVS repository,
603 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
604 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
605 # autom4te: m4 failed with exit status: 1
612 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,prereqs="$prereqs \1",p
614 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
615 if test -n "$prereqs"; then
616 autoconf_minversion=`for version in $prereqs; do echo $version; done | $SORT -g | uniq | tail -1`
619 if test -z "$autoconf_minversion"; then
620 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
622 case "$autoconf_minversion" in
623 1.* | 2.[0-4]* | 2.5[0-8]*)
624 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
627 # Remove trailing slashes from the directory names. This is necessary for
628 # m4base (to avoid an error in func_import) and optional for the others.
629 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
630 case "$local_gnulib_dir" in
631 */ ) sourcebase=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
633 case "$sourcebase" in
634 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
637 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
640 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
643 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
646 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
651 /*) self_abspathname="$0" ;;
652 */*) self_abspathname=`pwd`/"$0" ;;
653 *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
654 if test -x "$d/$0" && test ! -d "$d/$0"; then
655 self_abspathname="$d/$0"
659 if test -z "$self_abspathname"; then
660 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
664 while test -h "$self_abspathname"; do
665 # Resolve symbolic link.
666 linkval=`func_readlink "$self_abspathname"`
667 test -n "$linkval" || break
669 /* ) self_abspathname="$linkval" ;;
670 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
673 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
676 trap 'rm -rf "$tmp"' 0 1 2 3 15
678 # func_lookup_file file
679 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
682 # - lookedup_file name of the merged (combined) file
683 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
687 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
688 lookedup_file="$local_gnulib_dir/$lkfile"
691 if test -f "$gnulib_dir/$lkfile"; then
692 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
693 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
695 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
696 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
697 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
698 lookedup_file="$tmp/$lkbase"
701 lookedup_file="$gnulib_dir/$lkfile"
705 func_fatal_error "file $gnulib_dir/$lkfile not found"
713 # Filter out metainformation files like README, which are not modules.
714 # Filter out unit test modules; they can be retrieved through
715 # --extract-tests-module if desired.
717 (cd "$gnulib_dir/modules" && ls -1)
718 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
719 (cd "$local_gnulib_dir/modules" && ls -1 | sed -e 's,\.diff$,,')
722 | sed -e '/^CVS$/d' -e '/^ChangeLog$/d' -e '/^COPYING$/d' -e '/^README$/d' -e '/^TEMPLATE$/d' -e '/^TEMPLATE-TESTS$/d' -e '/~$/d' \
723 | sed -e '/-tests$/d' \
729 # verifies a module name
730 func_verify_module ()
732 if { test -f "$gnulib_dir/modules/$module" \
733 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
734 && test -f "$local_gnulib_dir/modules/$module"; }; } \
735 && test "CVS" != "$module" \
736 && test "ChangeLog" != "$module" \
737 && test "COPYING" != "$module" \
738 && test "README" != "$module" \
739 && test "TEMPLATE" != "$module" \
740 && test "TEMPLATE-TESTS" != "$module"; then
741 # OK, $module is a correct module name.
742 # Verify that building the module description with 'patch' succeeds.
743 func_lookup_file "modules/$module"
745 echo "gnulib-tool: module $module doesn't exist" 1>&2
750 # func_verify_nontests_module
751 # verifies a module name, excluding tests modules
752 func_verify_nontests_module ()
756 * ) func_verify_module ;;
760 # func_verify_tests_module
761 # verifies a module name, considering only tests modules
762 func_verify_tests_module ()
765 *-tests ) func_verify_module ;;
770 sed_extract_prog=':[ ]*$/ {
773 s/^Description:[ ]*$//
775 s/^Depends-on:[ ]*$//
776 s/^configure\.ac:[ ]*$//
777 s/^Makefile\.am:[ ]*$//
780 s/^Maintainer:[ ]*$//
787 # func_get_description module
788 func_get_description ()
790 func_lookup_file "modules/$1"
791 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
794 # func_get_filelist module
797 func_lookup_file "modules/$1"
798 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
799 case "$autoconf_minversion" in
802 echo m4/onceonly_2_57.m4
807 # func_get_dependencies module
808 func_get_dependencies ()
810 # ${module}-tests always implicitly depends on ${module}.
811 echo "$1" | sed -n -e 's/-tests//p'
812 # Then the explicit dependencies listed in the module description.
813 func_lookup_file "modules/$1"
814 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
817 # func_get_autoconf_snippet module
818 func_get_autoconf_snippet ()
820 func_lookup_file "modules/$1"
821 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
824 # func_get_automake_snippet module
825 func_get_automake_snippet ()
827 func_lookup_file "modules/$1"
828 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
831 # func_get_include_directive module
832 func_get_include_directive ()
834 func_lookup_file "modules/$1"
835 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
836 sed -e 's/^\(["<]\)/#include \1/'
839 # func_get_license module
842 func_lookup_file "modules/$1"
843 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
846 # func_get_maintainer module
847 func_get_maintainer ()
849 func_lookup_file "modules/$1"
850 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
853 # func_get_tests_module module
854 func_get_tests_module ()
856 # The naming convention for tests modules is hardwired: ${module}-tests.
857 if test -f modules/"$1"-tests; then
862 # func_acceptable module
863 # tests whether a module is acceptable.
865 # - avoidlist list of modules to avoid
868 for avoid in $avoidlist; do
869 if test "$avoid" = "$1"; then
876 # func_modules_transitive_closure
878 # - modules list of specified modules
879 # - inctests true if tests should be included, blank otherwise
880 # - avoidlist list of modules to avoid
882 # - modules list of modules, including dependencies
883 func_modules_transitive_closure ()
887 for module in $modules; do
889 if test -n "$module"; then
890 # Duplicate dependencies are harmless, but Jim wants a warning.
891 duplicated_deps=`func_get_dependencies $module | LC_ALL=C sort | LC_ALL=C uniq -d`
892 if test -n "$duplicated_deps"; then
893 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
895 if func_acceptable $module; then
896 xmodules="$xmodules $module"
897 for depmodule in `func_get_dependencies $module`; do
898 if func_acceptable $depmodule; then
899 xmodules="$xmodules $depmodule"
902 if test -n "$inctests"; then
903 testsmodule=`func_get_tests_module $module`
904 if test -n "$testsmodule"; then
905 if func_acceptable $testsmodule; then
906 xmodules="$xmodules $testsmodule"
907 for depmodule in `func_get_dependencies $testsmodule`; do
908 if func_acceptable $depmodule; then
909 xmodules="$xmodules $depmodule"
918 xmodules=`for m in $xmodules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
919 if test "$xmodules" = "$modules"; then
926 # func_modules_add_dummy
928 # - modules list of modules, including dependencies
930 # - modules list of modules, including 'dummy' if needed
931 func_modules_add_dummy ()
934 sed_remove_backslash_newline=':a
941 for module in $modules; do
942 func_verify_nontests_module
943 if test -n "$module"; then
944 # Extract the value of "lib_SOURCES += ...".
945 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
946 # Ignore .h files since they are not compiled.
949 *) have_lib_SOURCES=yes ;;
954 # Add the dummy module, to make sure the library will be non-empty.
955 if test -z "$have_lib_SOURCES"; then
956 modules="$modules dummy"
960 # func_modules_to_filelist
962 # - modules list of modules, including dependencies
964 # - files list of files
965 func_modules_to_filelist ()
968 for module in $modules; do
970 if test -n "$module"; then
971 files="$files "`func_get_filelist $module`
974 files=`for f in $files; do echo $f; done | LC_ALL=C sort | LC_ALL=C uniq`
977 # func_emit_lib_Makefile_am
978 # emits the contents of lib/Makefile.am to standard output.
980 # - modules list of modules, including dependencies
981 # - libname library name
982 # - libtool true if libtool will be used, false or blank otherwise
983 # - actioncmd (optional) command that will reproduce this invocation
984 func_emit_lib_Makefile_am ()
986 if test "$libtool" = true; then
993 echo "## Process this file with automake to produce Makefile.in."
994 func_emit_copyright_notice
995 if test -n "$actioncmd"; then
996 echo "# Reproduce by: $actioncmd"
999 # No need to generate dependencies since the sources are in gnulib, not here.
1000 echo "AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies"
1003 for module in $modules; do
1004 func_verify_nontests_module
1005 if test -n "$module"; then
1007 func_get_automake_snippet "$module" |
1008 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1009 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1010 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1011 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1012 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
1013 if test "$module" = 'alloca'; then
1014 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1017 # Skip the contents if its entirely empty.
1018 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1019 echo "## begin gnulib module $module"
1022 echo "## end gnulib module $module"
1029 if grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1030 # One of the snippets already specifies an installation location for the
1031 # library. Don't confuse automake by saying it should not be installed.
1034 # By default, the generated library should not be installed.
1035 echo "noinst_${perhapsLT}LIBRARIES = $libname.$libext"
1038 echo "${libname}_${libext}_SOURCES ="
1039 echo "${libname}_${libext}_LIBADD = @${perhapsLT}LIBOBJS@"
1040 echo "noinst_HEADERS ="
1041 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1042 echo "pkgdata_DATA ="
1045 echo "BUILT_SOURCES ="
1047 echo "MOSTLYCLEANFILES = core *.stackdump"
1048 echo "MOSTLYCLEANDIRS ="
1050 echo "DISTCLEANFILES ="
1051 echo "MAINTAINERCLEANFILES ="
1053 echo "AM_CPPFLAGS ="
1057 echo "mostlyclean-local: mostlyclean-generic"
1058 echo " @test -z \"\$(MOSTLYCLEANDIRS)\" || \\"
1059 echo " for dir in \$(MOSTLYCLEANDIRS); do \\"
1060 echo " if test -d \$\$dir; then \\"
1061 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1065 echo "# Makefile.am ends here"
1066 rm -f allsnippets.tmp
1069 # func_emit_tests_Makefile_am
1070 # emits the contents of tests/Makefile.am to standard output.
1072 # - modules list of modules, including dependencies
1073 # - libname library name
1074 # - libtool true if libtool will be used, false or blank otherwise
1075 # - sourcebase relative directory containing lib source code
1076 # - m4base relative directory containing autoconf macros
1077 # - testsbase relative directory containing unit test code
1078 func_emit_tests_Makefile_am ()
1080 if test "$libtool" = true; then
1085 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1086 echo "## Process this file with automake to produce Makefile.in."
1087 func_emit_copyright_notice
1089 # Generate dependencies here, since it eases the debugging of test failures.
1090 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1092 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1095 for module in $modules; do
1096 func_verify_tests_module
1097 if test -n "$module"; then
1098 func_get_automake_snippet "$module" > amsnippet.tmp
1099 # Skip the contents if its entirely empty.
1100 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1101 echo "## begin gnulib module $module"
1104 echo "## end gnulib module $module"
1111 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1112 # variable is needed to avoid an error from automake:
1113 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1116 echo "TESTS_ENVIRONMENT ="
1117 echo "noinst_PROGRAMS ="
1118 echo "check_PROGRAMS ="
1119 echo "noinst_HEADERS ="
1120 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1121 echo "pkgdata_DATA ="
1124 echo "BUILT_SOURCES ="
1126 echo "MOSTLYCLEANFILES = core *.stackdump"
1127 echo "MOSTLYCLEANDIRS ="
1129 echo "DISTCLEANFILES ="
1130 echo "MAINTAINERCLEANFILES ="
1132 echo "AM_CPPFLAGS = \\"
1133 echo " -I. -I\$(srcdir) \\"
1134 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1135 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1137 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1140 echo "# Clean up after Solaris cc."
1142 echo " rm -rf SunWS_cache"
1144 echo "mostlyclean-local: mostlyclean-generic"
1145 echo " @test -z \"\$(MOSTLYCLEANDIRS)\" || \\"
1146 echo " for dir in \$(MOSTLYCLEANDIRS); do \\"
1147 echo " if test -d \$\$dir; then \\"
1148 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1152 echo "# Makefile.am ends here"
1153 rm -f allsnippets.tmp
1156 # func_import modules
1157 # Uses also the variables
1158 # - destdir target directory
1159 # - libname library name
1160 # - sourcebase directory relative to destdir where to place source code
1161 # - m4base directory relative to destdir where to place *.m4 macros
1162 # - docbase directory relative to destdir where to place doc files
1163 # - testsbase directory relative to destdir where to place unit test code
1164 # - auxdir directory relative to destdir where to place build aux files
1165 # - inctests true if --with-tests was given, blank otherwise
1166 # - avoidlist list of modules to avoid, from --avoid
1167 # - lgpl true if library's license shall be LGPL, blank otherwise
1168 # - libtool true if --libtool was given, false if --no-libtool was
1169 # given, blank otherwise
1170 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1171 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1172 # - autoconf_minversion minimum supported autoconf version
1173 # - doit : if actions shall be executed, false if only to be printed
1174 # - symbolic true if files should be symlinked, copied otherwise
1177 # Get the cached settings.
1178 cached_local_gnulib_dir=
1179 cached_specified_modules=
1188 cached_macro_prefix=
1190 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1191 cached_libtool=false
1197 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
1200 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1203 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1206 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1209 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1212 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1215 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1218 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1221 s,^.*$,cached_lgpl=true,p
1224 s,^.*$,cached_libtool=true,p
1226 /gl_MACRO_PREFIX(/ {
1227 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
1229 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
1230 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1235 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
1236 s,^.*$,cached_files=",p
1248 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1252 # Merge the cached settings with the specified ones.
1253 # The m4base must be the same as expected from the pathname.
1254 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1255 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1257 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
1258 # is relative to $destdir, whereas the one we use is relative to . or absolute.
1259 if test -z "$local_gnulib_dir"; then
1260 if test -n "$cached_local_gnulib_dir"; then
1263 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1265 case "$cached_local_gnulib_dir" in
1267 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1269 func_relconcat "$destdir" "$cached_local_gnulib_dir"
1270 local_gnulib_dir="$relconcat" ;;
1275 # Append the cached and the specified module names. So that
1276 # "gnulib-tool --import foo" means to add the module foo.
1277 specified_modules="$cached_specified_modules $1"
1278 # Append the cached and the specified avoidlist. This is probably better
1279 # than dropping the cached one when --avoid is specified at least once.
1280 avoidlist=`echo $cached_avoidlist $avoidlist`
1281 # The sourcebase defaults to the cached one.
1282 if test -z "$sourcebase"; then
1283 sourcebase="$cached_sourcebase"
1284 if test -z "$sourcebase"; then
1285 func_fatal_error "missing --source-base option"
1288 # The docbase defaults to the cached one.
1289 if test -z "$docbase"; then
1290 docbase="$cached_docbase"
1291 if test -z "$docbase"; then
1292 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."
1295 # The testsbase defaults to the cached one.
1296 if test -z "$testsbase"; then
1297 testsbase="$cached_testsbase"
1298 if test -z "$testsbase"; then
1299 func_fatal_error "missing --tests-base option"
1302 # The libname defaults to the cached one.
1303 if test -z "$supplied_libname"; then
1304 libname="$cached_libname"
1305 if test -z "$libname"; then
1306 func_fatal_error "missing --lib option"
1309 # Require LGPL if specified either way.
1310 if test -z "$lgpl"; then
1313 # Use libtool if specified either way, or if guessed.
1314 if test -z "$libtool"; then
1315 if test -n "$cached_m4base"; then
1316 libtool="$cached_libtool"
1318 libtool="$guessed_libtool"
1321 # The macro_prefix defaults to the cached one.
1322 if test -z "$macro_prefix"; then
1323 macro_prefix="$cached_macro_prefix"
1324 if test -z "$macro_prefix"; then
1325 func_fatal_error "missing --macro-prefix option"
1329 # Canonicalize the list of specified modules.
1330 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
1332 # Determine final module list.
1333 modules="$specified_modules"
1334 func_modules_transitive_closure
1335 echo "Module list with included dependencies:"
1336 echo "$modules" | sed -e 's/^/ /'
1338 # Add the dummy module if needed.
1339 func_modules_add_dummy
1341 # If --lgpl, check the license of modules are compatible.
1342 if test -n "$lgpl"; then
1343 for module in $modules; do
1344 license=`func_get_license $module`
1346 LGPL | 'GPLed build tool' | 'public domain' | 'unlimited') ;;
1347 *) func_fatal_error "incompatible license on module $module: $license" ;;
1352 # Determine script to apply to imported library files.
1353 sed_transform_lib_file=
1354 case $nl$modules$nl in
1355 *"${nl}config-h$nl"*)
1356 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
1357 sed_transform_lib_file=$sed_transform_lib_file'
1358 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
1361 if test -n "$lgpl"; then
1363 sed_transform_lib_file=$sed_transform_lib_file'
1364 s/GNU General/GNU Lesser General/g
1365 s/version 2\([ ,]\)/version 2.1\1/g
1369 # Determine final file list.
1370 func_modules_to_filelist
1372 echo "$files" | sed -e 's/^/ /'
1375 || func_fatal_error "refusing to do nothing"
1377 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
1378 new_files="$files m4/gnulib-tool.m4"
1379 old_files="$cached_files"
1380 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
1381 old_files="$old_files m4/gnulib-tool.m4"
1384 # Create directories.
1385 if test ! -d "$destdir/$sourcebase"; then
1387 echo "Creating directory $destdir/$sourcebase"
1388 mkdir "$destdir/$sourcebase" || func_fatal_error "failed"
1390 echo "Create directory $destdir/$sourcebase"
1393 if test ! -d "$destdir/$m4base"; then
1395 echo "Creating directory $destdir/$m4base"
1396 mkdir "$destdir/$m4base" || func_fatal_error "failed"
1398 echo "Create directory $destdir/$m4base"
1401 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
1402 if test -n "$docfiles"; then
1403 if test ! -d "$destdir/$docbase"; then
1405 echo "Creating directory $destdir/$docbase"
1406 mkdir "$destdir/$docbase" || func_fatal_error "failed"
1408 echo "Create directory $destdir/$docbase"
1412 if test -n "$inctests"; then
1413 if test ! -d "$destdir/$testsbase"; then
1415 echo "Creating directory $destdir/$testsbase"
1416 mkdir "$destdir/$testsbase" || func_fatal_error "failed"
1418 echo "Create directory $destdir/$testsbase"
1422 if test ! -d "$destdir/$auxdir"; then
1424 echo "Creating directory $destdir/$auxdir"
1425 mkdir "$destdir/$auxdir" || func_fatal_error "failed"
1427 echo "Create directory $destdir/$auxdir"
1431 # func_dest_tmpfilename file
1432 # determines the name of a temporary file (file is relative to destdir).
1434 # - tmpfile absolute filename of the temporary file
1435 func_dest_tmpfilename ()
1438 # Put the new contents of $file in a file in the same directory (needed
1439 # to guarantee that an 'mv' to "$destdir/$file" works).
1440 tmpfile="$destdir/$1.tmp"
1442 # Put the new contents of $file in a file in a temporary directory
1443 # (because the directory of "$file" might not exist).
1444 tmpfile="$tmp"/`basename "$1"`.tmp
1448 # Copy files or make symbolic links. Remove obsolete files.
1450 for f in $old_files; do
1452 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1453 doc/*) g=`echo "$f" | sed -e "s,^doc/,$cached_docbase/,"` ;;
1454 lib/*) g=`echo "$f" | sed -e "s,^lib/,$cached_sourcebase/,"` ;;
1455 m4/*) g=`echo "$f" | sed -e "s,^m4/,$cached_m4base/,"` ;;
1456 tests/*) g=`echo "$f" | sed -e "s,^tests/,$cached_testsbase/,"` ;;
1459 echo "$g""$delimiter""$f"
1460 done | LC_ALL=C sort > "$tmp"/old-files
1461 for f in $new_files; do
1463 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1464 doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
1465 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1466 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1467 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1470 echo "$g""$delimiter""$f"
1471 done | LC_ALL=C sort > "$tmp"/new-files
1472 # First the files that are in old-files, but not in new-files:
1473 sed_take_first_column='s,'"$delimiter"'.*,,'
1474 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
1475 # Remove the file. Do nothing if the user already removed it.
1476 if test -f "$destdir/$g"; then
1478 echo "Removing file $g (backup in ${g}~)"
1479 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1481 echo "Remove file $g (backup in ${g}~)"
1485 # func_add_or_update handles a file that ought to be present afterwards.
1486 # Uses parameters f, g, already_present.
1487 func_add_or_update ()
1489 func_dest_tmpfilename "$g"
1490 func_lookup_file "$f"
1491 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
1492 if test -n "sed_transform_lib_file"; then
1495 sed -e "$sed_transform_lib_file" \
1496 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
1500 if test -f "$destdir/$g"; then
1501 # The file already exists.
1502 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1503 : # The file has not changed.
1507 if test -n "$already_present"; then
1508 echo "Updating file $g (backup in ${g}~)"
1510 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
1512 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1513 if test -n "$symbolic" && test -z "$lookedup_tmp" \
1514 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1515 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1517 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1520 if test -n "$already_present"; then
1521 echo "Update file $g (backup in ${g}~)"
1523 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
1529 # Don't protest if the file should be there but isn't: it happens
1530 # frequently that developers don't put autogenerated files into CVS.
1532 echo "Copying file $g"
1533 if test -n "$symbolic" && test -z "$lookedup_tmp" \
1534 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1535 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1537 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1545 # Then the files that are in new-files, but not in old-files:
1546 sed_take_last_column='s,^.*'"$delimiter"',,'
1548 for f in `LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_last_column"`; do
1550 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1551 doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
1552 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1553 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1554 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1559 # Then the files that are in new-files and in old-files:
1560 already_present=true
1561 for f in `LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_last_column"`; do
1563 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1564 doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
1565 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1566 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1567 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1573 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
1574 actioncmd="gnulib-tool --import"
1575 actioncmd="$actioncmd --dir=$destdir"
1576 if test -n "$local_gnulib_dir"; then
1577 actioncmd="$actioncmd --local-dir=$local_gnulib_dir"
1579 actioncmd="$actioncmd --lib=$libname"
1580 actioncmd="$actioncmd --source-base=$sourcebase"
1581 actioncmd="$actioncmd --m4-base=$m4base"
1582 actioncmd="$actioncmd --doc-base=$docbase"
1583 actioncmd="$actioncmd --aux-dir=$auxdir"
1584 for module in $avoidlist; do
1585 actioncmd="$actioncmd --avoid=$module"
1587 if test -n "$lgpl"; then
1588 actioncmd="$actioncmd --lgpl"
1590 if test "$libtool" = true; then
1591 actioncmd="$actioncmd --libtool"
1593 actioncmd="$actioncmd --no-libtool"
1595 actioncmd="$actioncmd --macro-prefix=$macro_prefix"
1596 actioncmd="$actioncmd `echo $specified_modules`"
1598 # Create lib/Makefile.am.
1599 func_dest_tmpfilename $sourcebase/Makefile.am
1600 func_emit_lib_Makefile_am > "$tmpfile"
1601 if test -f "$destdir"/$sourcebase/Makefile.am; then
1602 if cmp "$destdir"/$sourcebase/Makefile.am "$tmpfile" > /dev/null; then
1606 echo "Updating $sourcebase/Makefile.am (backup in $sourcebase/Makefile.am~)"
1607 mv -f "$destdir"/$sourcebase/Makefile.am "$destdir"/$sourcebase/Makefile.am~
1608 mv -f "$tmpfile" "$destdir"/$sourcebase/Makefile.am
1610 echo "Update $sourcebase/Makefile.am (backup in $sourcebase/Makefile.am~)"
1616 echo "Creating $sourcebase/Makefile.am"
1617 mv -f "$tmpfile" "$destdir"/$sourcebase/Makefile.am
1619 echo "Create $sourcebase/Makefile.am"
1624 # Create m4/gnulib-cache.m4.
1625 func_dest_tmpfilename $m4base/gnulib-cache.m4
1627 func_emit_copyright_notice
1629 echo "# This file represents the specification of how gnulib-tool is used."
1630 echo "# It acts as a cache: It is written and read by gnulib-tool."
1631 echo "# In projects using CVS, this file is meant to be stored in CVS,"
1632 echo "# like the configure.ac and various Makefile.am files."
1635 echo "# Specification in the form of a command-line invocation:"
1638 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
1639 # Store the local_gnulib_dir relative to destdir.
1640 case "$local_gnulib_dir" in
1642 relative_local_gnulib_dir="$local_gnulib_dir" ;;
1645 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
1647 # destdir, local_gnulib_dir are both relative.
1648 func_relativize "$destdir" "$local_gnulib_dir"
1649 relative_local_gnulib_dir="$reldir" ;;
1652 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
1653 echo "gl_MODULES(["`echo $specified_modules`"])"
1654 echo "gl_AVOID([$avoidlist])"
1655 echo "gl_SOURCE_BASE([$sourcebase])"
1656 echo "gl_M4_BASE([$m4base])"
1657 echo "gl_DOC_BASE([$docbase])"
1658 echo "gl_TESTS_BASE([$testsbase])"
1659 echo "gl_LIB([$libname])"
1660 test -z "$lgpl" || echo "gl_LGPL"
1661 if test "$libtool" = true; then
1664 echo "gl_MACRO_PREFIX([$macro_prefix])"
1666 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1667 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
1671 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1672 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
1673 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
1675 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1679 echo "# gnulib-cache.m4 ends here"
1686 echo "Creating $m4base/gnulib-cache.m4"
1687 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
1689 echo "Create $m4base/gnulib-cache.m4"
1695 # Create m4/gnulib-comp.m4.
1696 func_dest_tmpfilename $m4base/gnulib-comp.m4
1698 func_emit_copyright_notice
1700 echo "# This file represents the compiled summary of the specification in"
1701 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
1702 echo "# to be invoked from configure.ac."
1703 echo "# In projects using CVS, this file can be treated like other built files."
1706 echo "# This macro should be invoked from $configure_ac, in the section"
1707 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
1708 echo "# any checks for libraries, header files, types and library functions."
1709 echo "AC_DEFUN([${macro_prefix}_EARLY],"
1711 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
1712 echo " m4_pattern_allow([^gl_ES$])dnl a valid locale name"
1713 echo " AC_REQUIRE([AC_PROG_RANLIB])"
1714 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1715 echo " AC_REQUIRE([AC_GNU_SOURCE])"
1717 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1718 echo " AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])"
1720 if grep gl_LOCK "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1721 echo " AC_REQUIRE([gl_LOCK_EARLY])"
1725 echo "# This macro should be invoked from $configure_ac, in the section"
1726 echo "# \"Check for header files, types and library functions\"."
1727 echo "AC_DEFUN([${macro_prefix}_INIT],"
1729 if test "$libtool" = true; then
1730 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1732 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1734 if test "$auxdir" != "build-aux"; then
1735 sed_replace_build_aux='
1737 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
1738 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
1741 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
1743 sed_replace_build_aux=
1745 for module in $modules; do
1747 if test -n "$module"; then
1748 func_get_autoconf_snippet "$module" \
1749 | sed -e '/^$/d;' -e 's/^/ /' \
1750 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
1751 -e "$sed_replace_build_aux"
1752 if test "$module" = 'alloca' && test "$libtool" = true; then
1753 echo 'changequote(,)dnl'
1754 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
1755 echo 'changequote([, ])dnl'
1756 echo 'AC_SUBST([LTALLOCA])'
1762 echo "# This macro records the list of files which have been installed by"
1763 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
1764 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
1765 echo "$files" | sed -e 's,^, ,'
1768 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1769 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
1773 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1774 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
1775 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
1777 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1781 echo "# gnulib-comp.m4 ends here"
1788 echo "Creating $m4base/gnulib-comp.m4"
1789 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
1791 echo "Create $m4base/gnulib-comp.m4"
1797 if test -n "$inctests"; then
1798 # Create tests/Makefile.am.
1799 func_dest_tmpfilename $testsbase/Makefile.am
1800 func_emit_tests_Makefile_am > "$tmpfile"
1801 if test -f "$destdir"/$testsbase/Makefile.am; then
1802 if cmp "$destdir"/$testsbase/Makefile.am "$tmpfile" > /dev/null; then
1806 echo "Updating $testsbase/Makefile.am (backup in $testsbase/Makefile.am~)"
1807 mv -f "$destdir"/$testsbase/Makefile.am "$destdir"/$testsbase/Makefile.am~
1808 mv -f "$tmpfile" "$destdir"/$testsbase/Makefile.am
1810 echo "Update $testsbase/Makefile.am (backup in $testsbase/Makefile.am~)"
1816 echo "Creating $testsbase/Makefile.am"
1817 mv -f "$tmpfile" "$destdir"/$testsbase/Makefile.am
1819 echo "Create $testsbase/Makefile.am"
1827 echo "You may need to add #include directives for the following .h files."
1829 # First the #include <...> directives without #ifs, sorted for convenience.
1830 for module in $modules; do
1831 if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
1834 func_get_include_directive "$module" | grep -v 'include "'
1836 done | LC_ALL=C sort -u
1837 # Then the #include "..." directives without #ifs, sorted for convenience.
1838 for module in $modules; do
1839 if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
1842 func_get_include_directive "$module" | grep 'include "'
1844 done | LC_ALL=C sort -u
1845 # Then the #include directives that are surrounded by #ifs. Not sorted.
1846 for module in $modules; do
1847 if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
1848 func_get_include_directive "$module"
1851 ) | sed -e '/^$/d;' -e 's/^/ /'
1853 echo "Don't forget to"
1854 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1855 if test -n "$inctests"; then
1856 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1858 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
1859 sourcebase_base=`basename "$sourcebase"`
1860 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
1861 if test -n "$inctests"; then
1862 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
1863 testsbase_base=`basename "$testsbase"`
1864 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
1866 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
1867 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
1868 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
1871 # func_create_testdir testdir modules
1873 # - auxdir directory relative to destdir where to place build aux files
1874 func_create_testdir ()
1878 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
1880 # Subdirectory names.
1885 # Determine final module list.
1886 func_modules_transitive_closure
1887 echo "Module list with included dependencies:"
1888 echo "$modules" | sed -e 's/^/ /'
1890 # Add the dummy module if needed.
1891 func_modules_add_dummy
1893 # Determine final file list.
1894 func_modules_to_filelist
1896 echo "$files" | sed -e 's/^/ /'
1898 # Create directories.
1899 for d in `echo "$files" | sed -n -e 's,^\(.*\)/[^/]*,\1,p'`; do
1901 build-aux) mkdir -p "$testdir/$auxdir" ;;
1902 lib) mkdir -p "$testdir/$sourcebase" ;;
1903 m4) mkdir -p "$testdir/$m4base" ;;
1904 tests) mkdir -p "$testdir/$testsbase" ;;
1905 *) mkdir -p "$testdir/$d" ;;
1909 # Copy files or make symbolic links.
1911 func_lookup_file "$f"
1913 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1914 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1915 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1916 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1919 if test -n "$lookedup_tmp"; then
1920 cp -p "$lookedup_file" "$testdir/$g"
1922 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
1923 if test -z "$symbolic"; then
1924 cp -p "$lookedup_file" "$testdir/$g"
1926 ln -s "$lookedup_file" "$testdir/$g"
1931 # Create $sourcebase/Makefile.am.
1932 mkdir -p "$testdir/$sourcebase"
1933 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
1935 # Create $m4base/Makefile.am.
1936 mkdir -p "$testdir/$m4base"
1937 (echo "## Process this file with automake to produce Makefile.in."
1943 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
1946 ) > "$testdir/$m4base/Makefile.am"
1948 subdirs="$sourcebase $m4base"
1949 subdirs_with_configure_ac=""
1951 if test -f "$testdir"/$m4base/gettext.m4; then
1952 # Avoid stupid error message from automake:
1953 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
1954 mkdir -p "$testdir/po"
1955 (echo "## Process this file with automake to produce Makefile.in."
1956 ) > "$testdir/po/Makefile.am"
1957 subdirs="$subdirs po"
1960 if test -n "$inctests"; then
1961 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
1962 # Create $testsbase/Makefile.am.
1963 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
1964 # Create $testsbase/configure.ac.
1965 (echo "# Process this file with autoconf to produce a configure script."
1966 echo "AC_INIT([dummy], [0])"
1967 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
1968 echo "AM_INIT_AUTOMAKE"
1970 echo "AM_CONFIG_HEADER([config.h])"
1973 echo "AC_PROG_INSTALL"
1974 echo "AC_PROG_MAKE_SET"
1975 echo "AC_PROG_RANLIB"
1977 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
1978 echo "AC_GNU_SOURCE"
1981 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
1982 echo "gl_USE_SYSTEM_EXTENSIONS"
1985 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
1986 echo "gl_LOCK_EARLY"
1989 if test "$libtool" = true; then
1990 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1992 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1994 # Wrap the set of autoconf snippets into an autoconf macro that is then
1995 # invoked. This is needed because autoconf does not support AC_REQUIRE
1997 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
1998 # but we want the AC_REQUIRE to have its normal meaning (provide one
1999 # expansion of the required macro before the current point, and only one
2001 echo "AC_DEFUN([gl_INIT], ["
2002 if test "$auxdir" != "build-aux"; then
2003 sed_replace_build_aux='
2005 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2006 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
2009 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2011 sed_replace_build_aux=
2013 # We don't have explicit ordering constraints between the various
2014 # autoconf snippets. It's cleanest to put those of the library before
2015 # those of the tests.
2016 for module in $modules; do
2017 func_verify_nontests_module
2018 if test -n "$module"; then
2019 func_get_autoconf_snippet "$module" \
2020 | sed -e "$sed_replace_build_aux"
2023 for module in $modules; do
2024 func_verify_tests_module
2025 if test -n "$module"; then
2026 func_get_autoconf_snippet "$module" \
2027 | sed -e "$sed_replace_build_aux"
2033 # Usually $testsbase/config.h will be a superset of config.h. Verify this
2034 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
2035 echo "AH_TOP([#include \"../config.h\"])"
2037 echo "AC_OUTPUT([Makefile])"
2038 ) > "$testdir/$testsbase/configure.ac"
2039 subdirs="$subdirs $testsbase"
2040 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
2043 # Create Makefile.am.
2044 (echo "## Process this file with automake to produce Makefile.in."
2046 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2048 echo "SUBDIRS = $subdirs"
2050 echo "ACLOCAL_AMFLAGS = -I $m4base"
2051 ) > "$testdir/Makefile.am"
2053 # Create configure.ac.
2054 (echo "# Process this file with autoconf to produce a configure script."
2055 echo "AC_INIT([dummy], [0])"
2056 if test "$auxdir" != "."; then
2057 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2059 echo "AM_INIT_AUTOMAKE"
2061 echo "AM_CONFIG_HEADER([config.h])"
2064 echo "AC_PROG_INSTALL"
2065 echo "AC_PROG_MAKE_SET"
2067 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2068 echo "m4_pattern_allow([^gl_ES$])dnl a valid locale name"
2070 echo "AC_PROG_RANLIB"
2072 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2073 echo "AC_GNU_SOURCE"
2076 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2077 echo "gl_USE_SYSTEM_EXTENSIONS"
2080 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2081 echo "gl_LOCK_EARLY"
2084 if test "$libtool" = true; then
2085 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2087 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2089 # Wrap the set of autoconf snippets into an autoconf macro that is then
2090 # invoked. This is needed because autoconf does not support AC_REQUIRE
2092 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2093 # but we want the AC_REQUIRE to have its normal meaning (provide one
2094 # expansion of the required macro before the current point, and only one
2096 echo "AC_DEFUN([gl_INIT], ["
2097 if test "$auxdir" != "build-aux"; then
2098 sed_replace_build_aux='
2100 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2101 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2104 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2106 sed_replace_build_aux=
2108 for module in $modules; do
2109 func_verify_nontests_module
2110 if test -n "$module"; then
2111 func_get_autoconf_snippet "$module" \
2112 | sed -e "$sed_replace_build_aux"
2118 if test -n "$subdirs_with_configure_ac"; then
2119 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
2121 makefiles="Makefile"
2122 for d in $subdirs; do
2123 # For subdirs that have a configure.ac by their own, it's the subdir's
2124 # configure.ac which creates the subdir's Makefile.am, not this one.
2125 case " $subdirs_with_configure_ac " in
2127 *) makefiles="$makefiles $d/Makefile" ;;
2130 echo "AC_OUTPUT([$makefiles])"
2131 ) > "$testdir/configure.ac"
2133 # Create autogenerated files.
2135 echo "executing ${AUTORECONF} --force --install"
2136 ${AUTORECONF} --force --install
2138 if grep '^BUILT_SOURCES *+=' "$testdir/$sourcebase/Makefile.am" > /dev/null; then
2142 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
2150 # func_create_megatestdir megatestdir allmodules
2152 # - auxdir directory relative to destdir where to place build aux files
2153 func_create_megatestdir ()
2157 if test -z "$allmodules"; then
2158 allmodules=`func_all_modules`
2162 # First, all modules one by one.
2163 for onemodule in $allmodules; do
2164 func_create_testdir "$megatestdir/$onemodule" $onemodule
2165 megasubdirs="${megasubdirs}$onemodule "
2167 # Then, all modules all together.
2168 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2169 allmodules=`for m in $allmodules; do if test $m != fnmatch-posix; then echo $m; fi; done`
2170 func_create_testdir "$megatestdir/ALL" "$allmodules"
2171 megasubdirs="${megasubdirs}ALL"
2173 # Create Makefile.am.
2174 (echo "## Process this file with automake to produce Makefile.in."
2176 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2178 echo "SUBDIRS = $megasubdirs"
2179 ) > "$megatestdir/Makefile.am"
2181 # Create configure.ac.
2182 (echo "# Process this file with autoconf to produce a configure script."
2183 echo "AC_INIT([dummy], [0])"
2184 if test "$auxdir" != "."; then
2185 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2187 echo "AM_INIT_AUTOMAKE"
2189 echo "AC_PROG_MAKE_SET"
2191 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
2192 echo "AC_OUTPUT([Makefile])"
2193 ) > "$megatestdir/configure.ac"
2195 # Create autogenerated files.
2197 # Do not use "${AUTORECONF} --install", because autoreconf operates
2198 # recursively, but the subdirectories are already finished, therefore
2199 # calling autoreconf here would only waste lots of CPU time.
2200 echo "executing ${ACLOCAL}"
2202 echo "executing mkdir build-aux"
2204 echo "executing ${AUTOCONF}"
2206 echo "executing ${AUTOMAKE} --add-missing --copy"
2207 ${AUTOMAKE} --add-missing --copy
2213 func_fatal_error "no mode specified" ;;
2222 if test -z "$destdir"; then
2225 test -d "$destdir" \
2226 || func_fatal_error "destination directory does not exist: $destdir"
2228 # Prefer configure.ac to configure.in.
2229 if test -f "$destdir"/configure.ac; then
2230 configure_ac="$destdir/configure.ac"
2232 if test -f "$destdir"/configure.in; then
2233 configure_ac="$destdir/configure.in"
2235 func_fatal_error "cannot find $destdir/configure.ac"
2239 # Analyze configure.ac.
2241 guessed_libtool=false
2246 /AC_CONFIG_AUX_DIR/ {
2247 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
2249 /A[CM]_PROG_LIBTOOL/ {
2250 s,^.*$,guessed_libtool=true,p
2252 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
2254 if test -z "$auxdir"; then
2255 auxdir="$guessed_auxdir"
2258 # Determine where to apply func_import.
2259 if test -n "$m4base"; then
2260 # Apply func_import to a particular gnulib directory.
2261 # Any number of additional modules can be given.
2262 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
2263 # First use of gnulib in the given m4base.
2264 test -n "$supplied_libname" || supplied_libname=true
2265 test -n "$sourcebase" || sourcebase="lib"
2266 test -n "$docbase" || docbase="doc"
2267 test -n "$testsbase" || testsbase="tests"
2268 test -n "$macro_prefix" || macro_prefix="gl"
2272 # Apply func_import to all gnulib directories.
2273 # To get this list of directories, look at Makefile.am. (Not at
2274 # configure, because it may be omitted from CVS. Also, don't run
2275 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
2278 if test -f "$destdir"/Makefile.am; then
2279 aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$destdir"/Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'`
2281 for arg in $aclocal_amflags; do
2282 if test -n "$m4dir_is_next"; then
2283 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
2287 if test -f "$destdir/$arg"/gnulib-cache.m4; then
2288 m4dirs="$m4dirs $arg"
2289 m4dirs_count=`expr $m4dirs_count + 1`
2294 if test "X$arg" = "X-I"; then
2302 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
2303 if test -f "$destdir"/aclocal.m4; then
2304 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
2305 sedexpr2='s,^[^/]*$,.,'
2306 sedexpr3='s,/[^/]*$,,'
2307 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort | LC_ALL=C uniq`
2308 m4dirs_count=`echo "$m4dirs" | wc -l`
2311 if test $m4dirs_count = 0; then
2312 # First use of gnulib in a package.
2313 # Any number of additional modules can be given.
2314 test -n "$supplied_libname" || supplied_libname=true
2315 test -n "$sourcebase" || sourcebase="lib"
2317 test -n "$docbase" || docbase="doc"
2318 test -n "$testsbase" || testsbase="tests"
2319 test -n "$macro_prefix" || macro_prefix="gl"
2322 if test $m4dirs_count = 1; then
2323 # There's only one use of gnulib here. Assume the user means it.
2324 # Any number of additional modules can be given.
2325 for m4base in $m4dirs; do
2329 # Ambiguous - guess what the user meant.
2330 if test $# = 0; then
2331 # No further arguments. Guess the user wants to update all of them.
2332 for m4base in $m4dirs; do
2337 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
2345 if test -z "$destdir"; then
2346 func_fatal_error "please specify --dir option"
2349 test -d "$destdir" \
2350 || func_fatal_error "could not create destination directory"
2351 test -n "$auxdir" || auxdir="build-aux"
2352 func_create_testdir "$destdir" "$*"
2355 create-megatestdir )
2356 if test -z "$destdir"; then
2357 func_fatal_error "please specify --dir option"
2359 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2360 test -n "$auxdir" || auxdir="build-aux"
2361 func_create_megatestdir "$destdir" "$*"
2365 test -n "$destdir" || destdir=testdir$$
2366 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2367 test -n "$auxdir" || auxdir="build-aux"
2368 func_create_testdir "$destdir" "$*"
2376 remaining=`find . -type f -print`
2377 if test -n "$remaining"; then
2378 echo "Remaining files:" $remaining 1>&2
2379 echo "gnulib-tool: *** Stop." 1>&2
2388 test -n "$destdir" || destdir=testdir$$
2389 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2390 test -n "$auxdir" || auxdir="build-aux"
2391 func_create_megatestdir "$destdir" "$*"
2399 remaining=`find . -type f -print`
2400 if test -n "$remaining"; then
2401 echo "Remaining files:" $remaining 1>&2
2402 echo "gnulib-tool: *** Stop." 1>&2
2410 extract-description )
2414 if test -n "$module"; then
2415 func_get_description "$module"
2424 if test -n "$module"; then
2425 func_get_filelist "$module"
2430 extract-dependencies )
2434 if test -n "$module"; then
2435 func_get_dependencies "$module"
2440 extract-autoconf-snippet )
2444 if test -n "$module"; then
2445 func_get_autoconf_snippet "$module"
2450 extract-automake-snippet )
2454 if test -n "$module"; then
2455 func_get_automake_snippet "$module"
2460 extract-include-directive )
2464 if test -n "$module"; then
2465 func_get_include_directive "$module"
2474 if test -n "$module"; then
2475 func_get_license "$module"
2480 extract-maintainer )
2484 if test -n "$module"; then
2485 func_get_maintainer "$module"
2490 extract-tests-module )
2494 if test -n "$module"; then
2495 func_get_tests_module "$module"
2501 func_fatal_error "unknown operation mode --$mode" ;;
2505 # Undo the effect of the previous 'trap' command. Some shellology:
2506 # We cannot use "trap - 0 1 2 3 15", because Solaris sh would attempt to
2507 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
2508 # exit); for the others we need to call 'exit' explicitly. The value of $? is
2509 # 128 + signal number and is set before the trap-registered command is run.
2511 trap 'exit $?' 1 2 3 15