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-09-07 13:00:56 $'
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
63 # outputs to stdout the --help usage message.
67 Usage: gnulib-tool --list
68 gnulib-tool --import [module1 ... moduleN]
70 gnulib-tool --create-testdir --dir=directory module1 ... moduleN
71 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
72 gnulib-tool --test --dir=directory module1 ... moduleN
73 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
74 gnulib-tool --extract-description module
75 gnulib-tool --extract-filelist module
76 gnulib-tool --extract-dependencies module
77 gnulib-tool --extract-autoconf-snippet module
78 gnulib-tool --extract-automake-snippet module
79 gnulib-tool --extract-include-directive module
80 gnulib-tool --extract-license module
81 gnulib-tool --extract-maintainer module
82 gnulib-tool --extract-tests-module module
85 --list print the available module names
86 --import import the given modules into the current package;
87 if no modules are specified, update the current
88 package from the current gnulib
89 --update update the current package, restore files omitted
91 --create-testdir create a scratch package with the given modules
92 --create-megatestdir create a mega scratch package with the given modules
93 one by one and all together
94 --test test the combination of the given modules
95 (recommended to use CC=\"gcc -Wall\" here)
96 --megatest test the given modules one by one and all together
97 (recommended to use CC=\"gcc -Wall\" here)
98 --extract-description extract the description
99 --extract-filelist extract the list of files
100 --extract-dependencies extract the dependencies
101 --extract-autoconf-snippet extract the snippet for configure.ac
102 --extract-automake-snippet extract the snippet for library makefile
103 --extract-include-directive extract the #include directive
104 --extract-license report the license terms of the source files
106 --extract-maintainer report the maintainer(s) inside gnulib
107 --extract-tests-module report the unit test module, if it exists
110 --dir=DIRECTORY Specify the target directory.
111 For --import, this specifies where your
112 configure.ac can be found. Defaults to current
114 --local-dir=DIRECTORY Specify a local override directory where to look
115 up files before looking in gnulib's directory.
117 Options for --import:
118 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
119 --source-base=DIRECTORY
120 Directory relative to --dir where source code is
121 placed (default \"lib\").
122 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
123 placed (default \"m4\").
124 --doc-base=DIRECTORY Directory relative to --dir where doc files are
125 placed (default \"doc\").
126 --tests-base=DIRECTORY
127 Directory relative to --dir where unit tests are
128 placed (default \"tests\").
129 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
130 tools are placed (default \"build-aux\").
131 --with-tests Include unit tests for the included modules.
132 --avoid=MODULE Avoid including the given MODULE. Useful if you
133 have code that provides equivalent functionality.
134 This option can be repeated.
135 --lgpl Abort if modules aren't available under the LGPL.
136 Also modify license template from GPL to LGPL.
137 --makefile-name=NAME Name of makefile in automake syntax in the
138 source-base and tests-base directories
139 (default \"Makefile.am\").
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 # - local_gnulib_dir from --local-dir
350 # - libname, supplied_libname from --lib
351 # - sourcebase from --source-base
352 # - m4base from --m4-base
353 # - docbase from --doc-base
354 # - testsbase from --tests-base
355 # - auxdir from --aux-dir
356 # - inctests true if --with-tests was given, blank otherwise
357 # - avoidlist list of modules to avoid, from --avoid
358 # - lgpl true if --lgpl was given, blank otherwise
359 # - makefile_name from --makefile-name
360 # - libtool true if --libtool was given, false if --no-libtool was
361 # given, blank otherwise
362 # - macro_prefix from --macro-prefix
363 # - autoconf_minversion minimum supported autoconf version
364 # - do_changelog false if --no-changelog was given, : otherwise
365 # - doit : if actions shall be executed, false if only to be printed
366 # - symbolic true if --symbolic was given, blank otherwise
390 while test $# -gt 0; do
395 --import | --impor | --impo | --imp | --im | --i )
398 --update | --updat | --upda | --upd | --up | --u )
401 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
404 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
405 mode=create-megatestdir
407 --test | --tes | --te | --t )
410 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
414 mode=`echo "X$1" | sed -e 's/^X--//'`
419 func_fatal_error "missing argument for --dir"
424 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
429 func_fatal_error "missing argument for --local-dir"
434 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
439 func_fatal_error "missing argument for --lib"
442 supplied_libname=true
445 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
446 supplied_libname=true
451 func_fatal_error "missing argument for --source-base"
456 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
461 func_fatal_error "missing argument for --m4-base"
466 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
471 func_fatal_error "missing argument for --doc-base"
476 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
481 func_fatal_error "missing argument for --tests-base"
486 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
491 func_fatal_error "missing argument for --aux-dir"
496 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
504 func_fatal_error "missing argument for --avoid"
506 avoidlist="$avoidlist $1"
509 avoidlist="$avoidlist "`echo "X$1" | sed -e 's/^X--avoid=//'`
517 func_fatal_error "missing argument for --makefile-name"
522 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
533 func_fatal_error "missing argument for --macro-prefix"
538 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
540 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
546 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
549 --help | --hel | --he | --h )
552 --version | --versio | --versi | --vers | --ver | --ve | --v )
556 # Stop option processing
560 echo "gnulib-tool: unknown option $1" 1>&2
561 echo "Try 'gnulib-tool --help' for more information." 1>&2
568 if test "$mode" = update; then
569 if test $# != 0; then
570 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
571 echo "Try 'gnulib-tool --help' for more information." 1>&2
572 echo "If you really want to modify the gnulib configuration of your project," 1>&2
573 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
576 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
577 || test -n "$sourcebase" || test -n "$m4base" \
578 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
579 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
580 || test -n "$makefile_name" || test -n "$macro_prefix"; then
581 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
582 echo "Try 'gnulib-tool --help' for more information." 1>&2
583 echo "If you really want to modify the gnulib configuration of your project," 1>&2
584 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
590 # Determine the minimum supported autoconf version from the project's
592 DEFAULT_AUTOCONF_MINVERSION="2.59"
595 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
596 if test -f "$destdir"/configure.ac; then
597 configure_ac="$destdir/configure.ac"
599 if test -f "$destdir"/configure.in; then
600 configure_ac="$destdir/configure.in"
604 if test -f configure.ac; then
605 configure_ac="configure.ac"
607 if test -f configure.in; then
608 configure_ac="configure.in"
612 if test -n "$configure_ac"; then
613 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
614 # because when some m4 files are omitted from a CVS repository,
615 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
616 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
617 # autom4te: m4 failed with exit status: 1
624 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,prereqs="$prereqs \1",p
626 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
627 if test -n "$prereqs"; then
628 autoconf_minversion=`for version in $prereqs; do echo $version; done | $SORT -g | uniq | tail -1`
631 if test -z "$autoconf_minversion"; then
632 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
634 case "$autoconf_minversion" in
635 1.* | 2.[0-4]* | 2.5[0-8]*)
636 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
639 # Remove trailing slashes from the directory names. This is necessary for
640 # m4base (to avoid an error in func_import) and optional for the others.
641 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
642 case "$local_gnulib_dir" in
643 */ ) sourcebase=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
645 case "$sourcebase" in
646 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
649 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
652 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
655 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
658 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
663 /*) self_abspathname="$0" ;;
664 */*) self_abspathname=`pwd`/"$0" ;;
665 *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
666 if test -x "$d/$0" && test ! -d "$d/$0"; then
667 self_abspathname="$d/$0"
671 if test -z "$self_abspathname"; then
672 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
676 while test -h "$self_abspathname"; do
677 # Resolve symbolic link.
678 linkval=`func_readlink "$self_abspathname"`
679 test -n "$linkval" || break
681 /* ) self_abspathname="$linkval" ;;
682 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
685 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
688 trap 'rm -rf "$tmp"' 0 1 2 3 15
690 # func_lookup_file file
691 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
694 # - local_gnulib_dir from --local-dir
696 # - lookedup_file name of the merged (combined) file
697 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
701 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
702 lookedup_file="$local_gnulib_dir/$lkfile"
705 if test -f "$gnulib_dir/$lkfile"; then
706 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
707 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
709 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
710 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
711 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
712 lookedup_file="$tmp/$lkbase"
715 lookedup_file="$gnulib_dir/$lkfile"
719 func_fatal_error "file $gnulib_dir/$lkfile not found"
726 # - local_gnulib_dir from --local-dir
729 # Filter out metainformation files like README, which are not modules.
730 # Filter out unit test modules; they can be retrieved through
731 # --extract-tests-module if desired.
733 (cd "$gnulib_dir/modules" && ls -1)
734 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
735 (cd "$local_gnulib_dir/modules" && ls -1 | sed -e 's,\.diff$,,')
738 | sed -e '/^CVS$/d' -e '/^ChangeLog$/d' -e '/^COPYING$/d' -e '/^README$/d' -e '/^TEMPLATE$/d' -e '/^TEMPLATE-TESTS$/d' -e '/~$/d' \
739 | sed -e '/-tests$/d' \
745 # verifies a module name
747 # - local_gnulib_dir from --local-dir
748 # - module module name argument
749 func_verify_module ()
751 if { test -f "$gnulib_dir/modules/$module" \
752 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
753 && test -f "$local_gnulib_dir/modules/$module"; }; } \
754 && test "CVS" != "$module" \
755 && test "ChangeLog" != "$module" \
756 && test "COPYING" != "$module" \
757 && test "README" != "$module" \
758 && test "TEMPLATE" != "$module" \
759 && test "TEMPLATE-TESTS" != "$module"; then
760 # OK, $module is a correct module name.
761 # Verify that building the module description with 'patch' succeeds.
762 func_lookup_file "modules/$module"
764 echo "gnulib-tool: module $module doesn't exist" 1>&2
769 # func_verify_nontests_module
770 # verifies a module name, excluding tests modules
772 # - local_gnulib_dir from --local-dir
773 # - module module name argument
774 func_verify_nontests_module ()
778 * ) func_verify_module ;;
782 # func_verify_tests_module
783 # verifies a module name, considering only tests modules
785 # - local_gnulib_dir from --local-dir
786 # - module module name argument
787 func_verify_tests_module ()
790 *-tests ) func_verify_module ;;
795 sed_extract_prog=':[ ]*$/ {
798 s/^Description:[ ]*$//
800 s/^Depends-on:[ ]*$//
801 s/^configure\.ac:[ ]*$//
802 s/^Makefile\.am:[ ]*$//
805 s/^Maintainer:[ ]*$//
812 # func_get_description module
814 # - local_gnulib_dir from --local-dir
815 func_get_description ()
817 func_lookup_file "modules/$1"
818 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
821 # func_get_filelist module
823 # - local_gnulib_dir from --local-dir
826 func_lookup_file "modules/$1"
827 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
828 case "$autoconf_minversion" in
831 echo m4/onceonly_2_57.m4
836 # func_get_dependencies module
838 # - local_gnulib_dir from --local-dir
839 func_get_dependencies ()
841 # ${module}-tests always implicitly depends on ${module}.
842 echo "$1" | sed -n -e 's/-tests//p'
843 # Then the explicit dependencies listed in the module description.
844 func_lookup_file "modules/$1"
845 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
848 # func_get_autoconf_snippet module
850 # - local_gnulib_dir from --local-dir
851 func_get_autoconf_snippet ()
853 func_lookup_file "modules/$1"
854 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
857 # func_get_automake_snippet module
859 # - local_gnulib_dir from --local-dir
860 func_get_automake_snippet ()
862 func_lookup_file "modules/$1"
863 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
866 # func_get_include_directive module
868 # - local_gnulib_dir from --local-dir
869 func_get_include_directive ()
871 func_lookup_file "modules/$1"
872 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
873 sed -e 's/^\(["<]\)/#include \1/'
876 # func_get_license module
878 # - local_gnulib_dir from --local-dir
881 func_lookup_file "modules/$1"
882 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
885 # func_get_maintainer module
887 # - local_gnulib_dir from --local-dir
888 func_get_maintainer ()
890 func_lookup_file "modules/$1"
891 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
894 # func_get_tests_module module
896 # - local_gnulib_dir from --local-dir
897 func_get_tests_module ()
899 # The naming convention for tests modules is hardwired: ${module}-tests.
900 if test -f "$gnulib_dir/modules/$1"-tests \
901 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
902 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
907 # func_acceptable module
908 # tests whether a module is acceptable.
910 # - avoidlist list of modules to avoid
913 for avoid in $avoidlist; do
914 if test "$avoid" = "$1"; then
921 # func_modules_transitive_closure
923 # - local_gnulib_dir from --local-dir
924 # - modules list of specified modules
925 # - inctests true if tests should be included, blank otherwise
926 # - avoidlist list of modules to avoid
928 # - modules list of modules, including dependencies
929 func_modules_transitive_closure ()
933 for module in $modules; do
935 if test -n "$module"; then
936 # Duplicate dependencies are harmless, but Jim wants a warning.
937 duplicated_deps=`func_get_dependencies $module | LC_ALL=C sort | LC_ALL=C uniq -d`
938 if test -n "$duplicated_deps"; then
939 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
941 if func_acceptable $module; then
942 xmodules="$xmodules $module"
943 for depmodule in `func_get_dependencies $module`; do
944 if func_acceptable $depmodule; then
945 xmodules="$xmodules $depmodule"
948 if test -n "$inctests"; then
949 testsmodule=`func_get_tests_module $module`
950 if test -n "$testsmodule"; then
951 if func_acceptable $testsmodule; then
952 xmodules="$xmodules $testsmodule"
953 for depmodule in `func_get_dependencies $testsmodule`; do
954 if func_acceptable $depmodule; then
955 xmodules="$xmodules $depmodule"
964 xmodules=`for m in $xmodules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
965 if test "$xmodules" = "$modules"; then
972 # func_modules_add_dummy
974 # - local_gnulib_dir from --local-dir
975 # - modules list of modules, including dependencies
977 # - modules list of modules, including 'dummy' if needed
978 func_modules_add_dummy ()
981 sed_remove_backslash_newline=':a
988 for module in $modules; do
989 func_verify_nontests_module
990 if test -n "$module"; then
991 # Extract the value of "lib_SOURCES += ...".
992 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
993 # Ignore .h files since they are not compiled.
996 *) have_lib_SOURCES=yes ;;
1001 # Add the dummy module, to make sure the library will be non-empty.
1002 if test -z "$have_lib_SOURCES"; then
1003 modules="$modules dummy"
1007 # func_modules_to_filelist
1009 # - local_gnulib_dir from --local-dir
1010 # - modules list of modules, including dependencies
1012 # - files list of files
1013 func_modules_to_filelist ()
1016 for module in $modules; do
1018 if test -n "$module"; then
1019 files="$files "`func_get_filelist $module`
1022 files=`for f in $files; do echo $f; done | LC_ALL=C sort | LC_ALL=C uniq`
1025 # func_emit_lib_Makefile_am
1026 # emits the contents of library makefile to standard output.
1028 # - local_gnulib_dir from --local-dir
1029 # - modules list of modules, including dependencies
1030 # - libname library name
1031 # - makefile_name from --makefile-name
1032 # - libtool true if libtool will be used, false or blank otherwise
1033 # - actioncmd (optional) command that will reproduce this invocation
1034 func_emit_lib_Makefile_am ()
1036 # When creating an includable Makefile.am snippet, augment variables with
1037 # += instead of assigning them.
1038 if test -n "$makefile_name"; then
1043 if test "$libtool" = true; then
1050 echo "## Process this file with automake to produce Makefile.in."
1051 func_emit_copyright_notice
1052 if test -n "$actioncmd"; then
1053 echo "# Reproduce by: $actioncmd"
1056 if test -z "$makefile_name"; then
1057 # No need to generate dependencies since the sources are in gnulib, not here.
1058 echo "AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies"
1062 for module in $modules; do
1063 func_verify_nontests_module
1064 if test -n "$module"; then
1066 func_get_automake_snippet "$module" |
1067 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1068 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1069 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1070 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1071 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
1072 if test "$module" = 'alloca'; then
1073 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1076 # Skip the contents if its entirely empty.
1077 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1078 echo "## begin gnulib module $module"
1081 echo "## end gnulib module $module"
1088 if grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1089 # One of the snippets already specifies an installation location for the
1090 # library. Don't confuse automake by saying it should not be installed.
1093 # By default, the generated library should not be installed.
1094 echo "noinst_${perhapsLT}LIBRARIES $assign $libname.$libext"
1097 echo "${libname}_${libext}_SOURCES ="
1098 echo "${libname}_${libext}_LIBADD = @${perhapsLT}LIBOBJS@"
1099 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1100 if test -z "$makefile_name"; then
1101 echo "noinst_HEADERS ="
1102 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1103 # if you specify pkgdata_DATA to empty. This is a workaround.
1104 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1105 echo "pkgdata_DATA ="
1108 echo "BUILT_SOURCES ="
1111 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1112 if test -z "$makefile_name"; then
1113 echo "MOSTLYCLEANDIRS ="
1115 echo "DISTCLEANFILES ="
1116 echo "MAINTAINERCLEANFILES ="
1118 echo "AM_CPPFLAGS ="
1123 echo "mostlyclean-local: mostlyclean-generic"
1124 echo " @test -z \"\$(MOSTLYCLEANDIRS)\" || \\"
1125 echo " for dir in \$(MOSTLYCLEANDIRS); do \\"
1126 echo " if test -d \$\$dir; then \\"
1127 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1130 rm -f allsnippets.tmp
1133 # func_emit_tests_Makefile_am
1134 # emits the contents of tests makefile to standard output.
1136 # - local_gnulib_dir from --local-dir
1137 # - modules list of modules, including dependencies
1138 # - libname library name
1139 # - makefile_name from --makefile-name
1140 # - libtool true if libtool will be used, false or blank otherwise
1141 # - sourcebase relative directory containing lib source code
1142 # - m4base relative directory containing autoconf macros
1143 # - testsbase relative directory containing unit test code
1144 func_emit_tests_Makefile_am ()
1146 if test "$libtool" = true; then
1151 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1152 echo "## Process this file with automake to produce Makefile.in."
1153 func_emit_copyright_notice
1155 # Generate dependencies here, since it eases the debugging of test failures.
1156 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1158 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1161 for module in $modules; do
1162 func_verify_tests_module
1163 if test -n "$module"; then
1164 func_get_automake_snippet "$module" > amsnippet.tmp
1165 # Skip the contents if its entirely empty.
1166 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1167 echo "## begin gnulib module $module"
1170 echo "## end gnulib module $module"
1177 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1178 # variable is needed to avoid an error from automake:
1179 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1182 echo "TESTS_ENVIRONMENT ="
1183 echo "noinst_PROGRAMS ="
1184 echo "check_PROGRAMS ="
1185 echo "noinst_HEADERS ="
1186 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1187 echo "pkgdata_DATA ="
1190 echo "BUILT_SOURCES ="
1192 echo "MOSTLYCLEANFILES = core *.stackdump"
1193 echo "MOSTLYCLEANDIRS ="
1195 echo "DISTCLEANFILES ="
1196 echo "MAINTAINERCLEANFILES ="
1198 echo "AM_CPPFLAGS = \\"
1199 echo " -I. -I\$(srcdir) \\"
1200 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1201 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1203 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1206 echo "# Clean up after Solaris cc."
1208 echo " rm -rf SunWS_cache"
1210 echo "mostlyclean-local: mostlyclean-generic"
1211 echo " @test -z \"\$(MOSTLYCLEANDIRS)\" || \\"
1212 echo " for dir in \$(MOSTLYCLEANDIRS); do \\"
1213 echo " if test -d \$\$dir; then \\"
1214 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1217 rm -f allsnippets.tmp
1220 # func_import modules
1221 # Uses also the variables
1222 # - destdir target directory
1223 # - local_gnulib_dir from --local-dir
1224 # - libname library name
1225 # - sourcebase directory relative to destdir where to place source code
1226 # - m4base directory relative to destdir where to place *.m4 macros
1227 # - docbase directory relative to destdir where to place doc files
1228 # - testsbase directory relative to destdir where to place unit test code
1229 # - auxdir directory relative to destdir where to place build aux files
1230 # - inctests true if --with-tests was given, blank otherwise
1231 # - avoidlist list of modules to avoid, from --avoid
1232 # - lgpl true if library's license shall be LGPL, blank otherwise
1233 # - makefile_name from --makefile-name
1234 # - libtool true if --libtool was given, false if --no-libtool was
1235 # given, blank otherwise
1236 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1237 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1238 # - autoconf_minversion minimum supported autoconf version
1239 # - doit : if actions shall be executed, false if only to be printed
1240 # - symbolic true if files should be symlinked, copied otherwise
1243 # Get the cached settings.
1244 cached_local_gnulib_dir=
1245 cached_specified_modules=
1253 cached_makefile_name=
1255 cached_macro_prefix=
1257 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1258 cached_libtool=false
1264 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
1267 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1270 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1273 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1276 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1279 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1282 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1285 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1288 s,^.*$,cached_lgpl=true,p
1290 /gl_MAKEFILE_NAME(/ {
1291 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
1294 s,^.*$,cached_libtool=true,p
1296 /gl_MACRO_PREFIX(/ {
1297 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
1299 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
1300 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1305 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
1306 s,^.*$,cached_files=",p
1318 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1322 # Merge the cached settings with the specified ones.
1323 # The m4base must be the same as expected from the pathname.
1324 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1325 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1327 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
1328 # is relative to $destdir, whereas the one we use is relative to . or absolute.
1329 if test -z "$local_gnulib_dir"; then
1330 if test -n "$cached_local_gnulib_dir"; then
1333 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1335 case "$cached_local_gnulib_dir" in
1337 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1339 func_relconcat "$destdir" "$cached_local_gnulib_dir"
1340 local_gnulib_dir="$relconcat" ;;
1345 # Append the cached and the specified module names. So that
1346 # "gnulib-tool --import foo" means to add the module foo.
1347 specified_modules="$cached_specified_modules $1"
1348 # Append the cached and the specified avoidlist. This is probably better
1349 # than dropping the cached one when --avoid is specified at least once.
1350 avoidlist=`echo $cached_avoidlist $avoidlist`
1351 # The sourcebase defaults to the cached one.
1352 if test -z "$sourcebase"; then
1353 sourcebase="$cached_sourcebase"
1354 if test -z "$sourcebase"; then
1355 func_fatal_error "missing --source-base option"
1358 # The docbase defaults to the cached one.
1359 if test -z "$docbase"; then
1360 docbase="$cached_docbase"
1361 if test -z "$docbase"; then
1362 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."
1365 # The testsbase defaults to the cached one.
1366 if test -z "$testsbase"; then
1367 testsbase="$cached_testsbase"
1368 if test -z "$testsbase"; then
1369 func_fatal_error "missing --tests-base option"
1372 # The libname defaults to the cached one.
1373 if test -z "$supplied_libname"; then
1374 libname="$cached_libname"
1375 if test -z "$libname"; then
1376 func_fatal_error "missing --lib option"
1379 # Require LGPL if specified either way.
1380 if test -z "$lgpl"; then
1383 # The makefile_name defaults to the cached one.
1384 if test -z "$makefile_name"; then
1385 makefile_name="$cached_makefile_name"
1387 # Use libtool if specified either way, or if guessed.
1388 if test -z "$libtool"; then
1389 if test -n "$cached_m4base"; then
1390 libtool="$cached_libtool"
1392 libtool="$guessed_libtool"
1395 # The macro_prefix defaults to the cached one.
1396 if test -z "$macro_prefix"; then
1397 macro_prefix="$cached_macro_prefix"
1398 if test -z "$macro_prefix"; then
1399 func_fatal_error "missing --macro-prefix option"
1403 # Canonicalize the list of specified modules.
1404 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
1406 # Determine final module list.
1407 modules="$specified_modules"
1408 func_modules_transitive_closure
1409 echo "Module list with included dependencies:"
1410 echo "$modules" | sed -e 's/^/ /'
1412 # Add the dummy module if needed.
1413 func_modules_add_dummy
1415 # If --lgpl, verify that the licenses of modules are compatible.
1416 if test -n "$lgpl"; then
1417 for module in $modules; do
1418 license=`func_get_license $module`
1420 LGPL | 'GPLed build tool') ;;
1421 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
1422 *) func_fatal_error "incompatible license on module $module: $license" ;;
1427 # Determine script to apply to imported library files.
1428 sed_transform_lib_file=
1429 for module in $modules; do
1430 if test $module = config-h; then
1431 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
1432 sed_transform_lib_file=$sed_transform_lib_file'
1433 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
1438 if test -n "$lgpl"; then
1440 sed_transform_lib_file=$sed_transform_lib_file'
1441 s/GNU General/GNU Lesser General/g
1442 s/version 2\([ ,]\)/version 2.1\1/g
1446 # Determine final file list.
1447 func_modules_to_filelist
1449 echo "$files" | sed -e 's/^/ /'
1452 || func_fatal_error "refusing to do nothing"
1454 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
1455 new_files="$files m4/gnulib-tool.m4"
1456 old_files="$cached_files"
1457 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
1458 old_files="$old_files m4/gnulib-tool.m4"
1461 # Create directories.
1462 if test ! -d "$destdir/$sourcebase"; then
1464 echo "Creating directory $destdir/$sourcebase"
1465 mkdir "$destdir/$sourcebase" || func_fatal_error "failed"
1467 echo "Create directory $destdir/$sourcebase"
1470 if test ! -d "$destdir/$m4base"; then
1472 echo "Creating directory $destdir/$m4base"
1473 mkdir "$destdir/$m4base" || func_fatal_error "failed"
1475 echo "Create directory $destdir/$m4base"
1478 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
1479 if test -n "$docfiles"; then
1480 if test ! -d "$destdir/$docbase"; then
1482 echo "Creating directory $destdir/$docbase"
1483 mkdir "$destdir/$docbase" || func_fatal_error "failed"
1485 echo "Create directory $destdir/$docbase"
1489 if test -n "$inctests"; then
1490 if test ! -d "$destdir/$testsbase"; then
1492 echo "Creating directory $destdir/$testsbase"
1493 mkdir "$destdir/$testsbase" || func_fatal_error "failed"
1495 echo "Create directory $destdir/$testsbase"
1499 if test ! -d "$destdir/$auxdir"; then
1501 echo "Creating directory $destdir/$auxdir"
1502 mkdir "$destdir/$auxdir" || func_fatal_error "failed"
1504 echo "Create directory $destdir/$auxdir"
1508 # func_dest_tmpfilename file
1509 # determines the name of a temporary file (file is relative to destdir).
1511 # - tmpfile absolute filename of the temporary file
1512 func_dest_tmpfilename ()
1515 # Put the new contents of $file in a file in the same directory (needed
1516 # to guarantee that an 'mv' to "$destdir/$file" works).
1517 tmpfile="$destdir/$1.tmp"
1519 # Put the new contents of $file in a file in a temporary directory
1520 # (because the directory of "$file" might not exist).
1521 tmpfile="$tmp"/`basename "$1"`.tmp
1525 # Copy files or make symbolic links. Remove obsolete files.
1527 for f in $old_files; do
1529 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1530 doc/*) g=`echo "$f" | sed -e "s,^doc/,$cached_docbase/,"` ;;
1531 lib/*) g=`echo "$f" | sed -e "s,^lib/,$cached_sourcebase/,"` ;;
1532 m4/*) g=`echo "$f" | sed -e "s,^m4/,$cached_m4base/,"` ;;
1533 tests/*) g=`echo "$f" | sed -e "s,^tests/,$cached_testsbase/,"` ;;
1536 echo "$g""$delimiter""$f"
1537 done | LC_ALL=C sort > "$tmp"/old-files
1538 for f in $new_files; do
1540 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1541 doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
1542 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1543 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1544 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1547 echo "$g""$delimiter""$f"
1548 done | LC_ALL=C sort > "$tmp"/new-files
1549 # First the files that are in old-files, but not in new-files:
1550 sed_take_first_column='s,'"$delimiter"'.*,,'
1551 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
1552 # Remove the file. Do nothing if the user already removed it.
1553 if test -f "$destdir/$g"; then
1555 echo "Removing file $g (backup in ${g}~)"
1556 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1558 echo "Remove file $g (backup in ${g}~)"
1562 # func_add_or_update handles a file that ought to be present afterwards.
1563 # Uses parameters f, g, already_present.
1564 func_add_or_update ()
1566 func_dest_tmpfilename "$g"
1567 func_lookup_file "$f"
1568 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
1569 if test -n "$sed_transform_lib_file"; then
1572 sed -e "$sed_transform_lib_file" \
1573 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
1577 if test -f "$destdir/$g"; then
1578 # The file already exists.
1579 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1580 : # The file has not changed.
1584 if test -n "$already_present"; then
1585 echo "Updating file $g (backup in ${g}~)"
1587 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
1589 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1590 if test -n "$symbolic" && test -z "$lookedup_tmp" \
1591 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1592 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1594 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1597 if test -n "$already_present"; then
1598 echo "Update file $g (backup in ${g}~)"
1600 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
1606 # Don't protest if the file should be there but isn't: it happens
1607 # frequently that developers don't put autogenerated files into CVS.
1609 echo "Copying file $g"
1610 if test -n "$symbolic" && test -z "$lookedup_tmp" \
1611 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1612 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1614 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1622 # Then the files that are in new-files, but not in old-files:
1623 sed_take_last_column='s,^.*'"$delimiter"',,'
1625 for f in `LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_last_column"`; do
1627 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1628 doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
1629 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1630 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1631 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1636 # Then the files that are in new-files and in old-files:
1637 already_present=true
1638 for f in `LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_last_column"`; do
1640 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
1641 doc/*) g=`echo "$f" | sed -e "s,^doc/,$docbase/,"` ;;
1642 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
1643 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
1644 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
1650 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
1651 actioncmd="gnulib-tool --import"
1652 actioncmd="$actioncmd --dir=$destdir"
1653 if test -n "$local_gnulib_dir"; then
1654 actioncmd="$actioncmd --local-dir=$local_gnulib_dir"
1656 actioncmd="$actioncmd --lib=$libname"
1657 actioncmd="$actioncmd --source-base=$sourcebase"
1658 actioncmd="$actioncmd --m4-base=$m4base"
1659 actioncmd="$actioncmd --doc-base=$docbase"
1660 actioncmd="$actioncmd --aux-dir=$auxdir"
1661 for module in $avoidlist; do
1662 actioncmd="$actioncmd --avoid=$module"
1664 if test -n "$lgpl"; then
1665 actioncmd="$actioncmd --lgpl"
1667 if test -n "$makefile_name"; then
1668 actioncmd="$actioncmd --makefile_name=$makefile_name"
1670 if test "$libtool" = true; then
1671 actioncmd="$actioncmd --libtool"
1673 actioncmd="$actioncmd --no-libtool"
1675 actioncmd="$actioncmd --macro-prefix=$macro_prefix"
1676 actioncmd="$actioncmd `echo $specified_modules`"
1678 # Default the makefile name to Makefile.am.
1679 if test -n "$makefile_name"; then
1680 makefile_am=$makefile_name
1682 makefile_am=Makefile.am
1685 # Create library makefile.
1686 func_dest_tmpfilename $sourcebase/$makefile_am
1687 func_emit_lib_Makefile_am > "$tmpfile"
1688 if test -f "$destdir"/$sourcebase/$makefile_am; then
1689 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
1693 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
1694 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
1695 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
1697 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
1703 echo "Creating $sourcebase/$makefile_am"
1704 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
1706 echo "Create $sourcebase/$makefile_am"
1711 # Create m4/gnulib-cache.m4.
1712 func_dest_tmpfilename $m4base/gnulib-cache.m4
1714 func_emit_copyright_notice
1716 echo "# This file represents the specification of how gnulib-tool is used."
1717 echo "# It acts as a cache: It is written and read by gnulib-tool."
1718 echo "# In projects using CVS, this file is meant to be stored in CVS,"
1719 echo "# like the configure.ac and various Makefile.am files."
1722 echo "# Specification in the form of a command-line invocation:"
1725 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
1726 # Store the local_gnulib_dir relative to destdir.
1727 case "$local_gnulib_dir" in
1729 relative_local_gnulib_dir="$local_gnulib_dir" ;;
1732 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
1734 # destdir, local_gnulib_dir are both relative.
1735 func_relativize "$destdir" "$local_gnulib_dir"
1736 relative_local_gnulib_dir="$reldir" ;;
1739 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
1740 echo "gl_MODULES(["`echo $specified_modules`"])"
1741 echo "gl_AVOID([$avoidlist])"
1742 echo "gl_SOURCE_BASE([$sourcebase])"
1743 echo "gl_M4_BASE([$m4base])"
1744 echo "gl_DOC_BASE([$docbase])"
1745 echo "gl_TESTS_BASE([$testsbase])"
1746 echo "gl_LIB([$libname])"
1747 test -z "$lgpl" || echo "gl_LGPL"
1748 echo "gl_MAKEFILE_NAME([$makefile_name])"
1749 if test "$libtool" = true; then
1752 echo "gl_MACRO_PREFIX([$macro_prefix])"
1754 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1755 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
1759 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1760 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
1761 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
1763 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1767 echo "# gnulib-cache.m4 ends here"
1774 echo "Creating $m4base/gnulib-cache.m4"
1775 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
1777 echo "Create $m4base/gnulib-cache.m4"
1783 # Create m4/gnulib-comp.m4.
1784 func_dest_tmpfilename $m4base/gnulib-comp.m4
1786 func_emit_copyright_notice
1788 echo "# This file represents the compiled summary of the specification in"
1789 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
1790 echo "# to be invoked from configure.ac."
1791 echo "# In projects using CVS, this file can be treated like other built files."
1794 echo "# This macro should be invoked from $configure_ac, in the section"
1795 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
1796 echo "# any checks for libraries, header files, types and library functions."
1797 echo "AC_DEFUN([${macro_prefix}_EARLY],"
1799 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
1800 echo " m4_pattern_allow([^gl_ES$])dnl a valid locale name"
1801 echo " AC_REQUIRE([AC_PROG_RANLIB])"
1802 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1803 echo " AC_REQUIRE([AC_GNU_SOURCE])"
1805 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1806 echo " AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])"
1808 if grep gl_LOCK "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1809 echo " AC_REQUIRE([gl_LOCK_EARLY])"
1813 echo "# This macro should be invoked from $configure_ac, in the section"
1814 echo "# \"Check for header files, types and library functions\"."
1815 echo "AC_DEFUN([${macro_prefix}_INIT],"
1817 if test "$libtool" = true; then
1818 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1820 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1822 if test "$auxdir" != "build-aux"; then
1823 sed_replace_build_aux='
1825 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
1826 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
1829 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
1831 sed_replace_build_aux=
1833 for module in $modules; do
1835 if test -n "$module"; then
1836 func_get_autoconf_snippet "$module" \
1837 | sed -e '/^$/d;' -e 's/^/ /' \
1838 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
1839 -e "$sed_replace_build_aux"
1840 if test "$module" = 'alloca' && test "$libtool" = true; then
1841 echo 'changequote(,)dnl'
1842 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
1843 echo 'changequote([, ])dnl'
1844 echo 'AC_SUBST([LTALLOCA])'
1850 echo "# This macro records the list of files which have been installed by"
1851 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
1852 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
1853 echo "$files" | sed -e 's,^, ,'
1856 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1857 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
1861 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1862 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
1863 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
1865 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1869 echo "# gnulib-comp.m4 ends here"
1876 echo "Creating $m4base/gnulib-comp.m4"
1877 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
1879 echo "Create $m4base/gnulib-comp.m4"
1885 if test -n "$inctests"; then
1886 # Create tests makefile.
1887 func_dest_tmpfilename $testsbase/$makefile_am
1888 func_emit_tests_Makefile_am > "$tmpfile"
1889 if test -f "$destdir"/$testsbase/$makefile_am; then
1890 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
1894 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
1895 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
1896 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
1898 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
1904 echo "Creating $testsbase/$makefile_am"
1905 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
1907 echo "Create $testsbase/$makefile_am"
1915 echo "You may need to add #include directives for the following .h files."
1917 # First the #include <...> directives without #ifs, sorted for convenience.
1918 for module in $modules; do
1919 if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
1922 func_get_include_directive "$module" | grep -v 'include "'
1924 done | LC_ALL=C sort -u
1925 # Then the #include "..." directives without #ifs, sorted for convenience.
1926 for module in $modules; do
1927 if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
1930 func_get_include_directive "$module" | grep 'include "'
1932 done | LC_ALL=C sort -u
1933 # Then the #include directives that are surrounded by #ifs. Not sorted.
1934 for module in $modules; do
1935 if func_get_include_directive "$module" | grep '^#if' >/dev/null; then
1936 func_get_include_directive "$module"
1939 ) | sed -e '/^$/d;' -e 's/^/ /'
1941 echo "Don't forget to"
1942 if test "$makefile_am" = Makefile.am; then
1943 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1945 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
1947 if test -n "$inctests"; then
1948 if test "$makefile_am" = Makefile.am; then
1949 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1951 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
1954 if test "$makefile_am" = Makefile.am; then
1955 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
1956 sourcebase_base=`basename "$sourcebase"`
1957 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
1959 if test -n "$inctests"; then
1960 if test "$makefile_am" = Makefile.am; then
1961 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
1962 testsbase_base=`basename "$testsbase"`
1963 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
1966 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
1967 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
1968 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
1971 # func_create_testdir testdir modules
1973 # - local_gnulib_dir from --local-dir
1974 # - auxdir directory relative to destdir where to place build aux files
1975 func_create_testdir ()
1979 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort | LC_ALL=C uniq`
1981 # Subdirectory names.
1986 # Determine final module list.
1987 func_modules_transitive_closure
1988 echo "Module list with included dependencies:"
1989 echo "$modules" | sed -e 's/^/ /'
1991 # Add the dummy module if needed.
1992 func_modules_add_dummy
1994 # Determine final file list.
1995 func_modules_to_filelist
1997 echo "$files" | sed -e 's/^/ /'
1999 # Create directories.
2000 for d in `echo "$files" | sed -n -e 's,^\(.*\)/[^/]*,\1,p'`; do
2002 build-aux) mkdir -p "$testdir/$auxdir" ;;
2003 lib) mkdir -p "$testdir/$sourcebase" ;;
2004 m4) mkdir -p "$testdir/$m4base" ;;
2005 tests) mkdir -p "$testdir/$testsbase" ;;
2006 *) mkdir -p "$testdir/$d" ;;
2010 # Copy files or make symbolic links.
2012 func_lookup_file "$f"
2014 build-aux/*) g=`echo "$f" | sed -e "s,^build-aux/,$auxdir/,"` ;;
2015 lib/*) g=`echo "$f" | sed -e "s,^lib/,$sourcebase/,"` ;;
2016 m4/*) g=`echo "$f" | sed -e "s,^m4/,$m4base/,"` ;;
2017 tests/*) g=`echo "$f" | sed -e "s,^tests/,$testsbase/,"` ;;
2020 if test -n "$lookedup_tmp"; then
2021 cp -p "$lookedup_file" "$testdir/$g"
2023 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
2024 if test -z "$symbolic"; then
2025 cp -p "$lookedup_file" "$testdir/$g"
2027 ln -s "$lookedup_file" "$testdir/$g"
2032 # Create $sourcebase/Makefile.am.
2033 mkdir -p "$testdir/$sourcebase"
2034 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
2036 # Create $m4base/Makefile.am.
2037 mkdir -p "$testdir/$m4base"
2038 (echo "## Process this file with automake to produce Makefile.in."
2044 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
2047 ) > "$testdir/$m4base/Makefile.am"
2049 subdirs="$sourcebase $m4base"
2050 subdirs_with_configure_ac=""
2052 if test -f "$testdir"/$m4base/gettext.m4; then
2053 # Avoid stupid error message from automake:
2054 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
2055 mkdir -p "$testdir/po"
2056 (echo "## Process this file with automake to produce Makefile.in."
2057 ) > "$testdir/po/Makefile.am"
2058 subdirs="$subdirs po"
2061 if test -n "$inctests"; then
2062 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
2063 # Create $testsbase/Makefile.am.
2064 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
2065 # Create $testsbase/configure.ac.
2066 (echo "# Process this file with autoconf to produce a configure script."
2067 echo "AC_INIT([dummy], [0])"
2068 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
2069 echo "AM_INIT_AUTOMAKE"
2071 echo "AM_CONFIG_HEADER([config.h])"
2074 echo "AC_PROG_INSTALL"
2075 echo "AC_PROG_MAKE_SET"
2076 echo "AC_PROG_RANLIB"
2078 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2079 echo "AC_GNU_SOURCE"
2082 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2083 echo "gl_USE_SYSTEM_EXTENSIONS"
2086 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2087 echo "gl_LOCK_EARLY"
2090 if test "$libtool" = true; then
2091 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2093 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2095 # Wrap the set of autoconf snippets into an autoconf macro that is then
2096 # invoked. This is needed because autoconf does not support AC_REQUIRE
2098 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2099 # but we want the AC_REQUIRE to have its normal meaning (provide one
2100 # expansion of the required macro before the current point, and only one
2102 echo "AC_DEFUN([gl_INIT], ["
2103 if test "$auxdir" != "build-aux"; then
2104 sed_replace_build_aux='
2106 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2107 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
2110 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2112 sed_replace_build_aux=
2114 # We don't have explicit ordering constraints between the various
2115 # autoconf snippets. It's cleanest to put those of the library before
2116 # those of the tests.
2117 for module in $modules; do
2118 func_verify_nontests_module
2119 if test -n "$module"; then
2120 func_get_autoconf_snippet "$module" \
2121 | sed -e "$sed_replace_build_aux"
2124 for module in $modules; do
2125 func_verify_tests_module
2126 if test -n "$module"; then
2127 func_get_autoconf_snippet "$module" \
2128 | sed -e "$sed_replace_build_aux"
2134 # Usually $testsbase/config.h will be a superset of config.h. Verify this
2135 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
2136 echo "AH_TOP([#include \"../config.h\"])"
2138 echo "AC_OUTPUT([Makefile])"
2139 ) > "$testdir/$testsbase/configure.ac"
2140 subdirs="$subdirs $testsbase"
2141 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
2144 # Create Makefile.am.
2145 (echo "## Process this file with automake to produce Makefile.in."
2147 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2149 echo "SUBDIRS = $subdirs"
2151 echo "ACLOCAL_AMFLAGS = -I $m4base"
2152 ) > "$testdir/Makefile.am"
2154 # Create configure.ac.
2155 (echo "# Process this file with autoconf to produce a configure script."
2156 echo "AC_INIT([dummy], [0])"
2157 if test "$auxdir" != "."; then
2158 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2160 echo "AM_INIT_AUTOMAKE"
2162 echo "AM_CONFIG_HEADER([config.h])"
2165 echo "AC_PROG_INSTALL"
2166 echo "AC_PROG_MAKE_SET"
2168 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2169 echo "m4_pattern_allow([^gl_ES$])dnl a valid locale name"
2171 echo "AC_PROG_RANLIB"
2173 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2174 echo "AC_GNU_SOURCE"
2177 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2178 echo "gl_USE_SYSTEM_EXTENSIONS"
2181 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2182 echo "gl_LOCK_EARLY"
2185 if test "$libtool" = true; then
2186 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2188 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2190 # Wrap the set of autoconf snippets into an autoconf macro that is then
2191 # invoked. This is needed because autoconf does not support AC_REQUIRE
2193 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2194 # but we want the AC_REQUIRE to have its normal meaning (provide one
2195 # expansion of the required macro before the current point, and only one
2197 echo "AC_DEFUN([gl_INIT], ["
2198 if test "$auxdir" != "build-aux"; then
2199 sed_replace_build_aux='
2201 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2202 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2205 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2207 sed_replace_build_aux=
2209 for module in $modules; do
2210 func_verify_nontests_module
2211 if test -n "$module"; then
2212 func_get_autoconf_snippet "$module" \
2213 | sed -e "$sed_replace_build_aux"
2219 if test -n "$subdirs_with_configure_ac"; then
2220 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
2222 makefiles="Makefile"
2223 for d in $subdirs; do
2224 # For subdirs that have a configure.ac by their own, it's the subdir's
2225 # configure.ac which creates the subdir's Makefile.am, not this one.
2226 case " $subdirs_with_configure_ac " in
2228 *) makefiles="$makefiles $d/Makefile" ;;
2231 echo "AC_OUTPUT([$makefiles])"
2232 ) > "$testdir/configure.ac"
2234 # Create autogenerated files.
2236 echo "executing ${AUTORECONF} --force --install"
2237 ${AUTORECONF} --force --install
2239 if grep '^BUILT_SOURCES *+=' "$testdir/$sourcebase/Makefile.am" > /dev/null; then
2243 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
2251 # func_create_megatestdir megatestdir allmodules
2253 # - local_gnulib_dir from --local-dir
2254 # - auxdir directory relative to destdir where to place build aux files
2255 func_create_megatestdir ()
2259 if test -z "$allmodules"; then
2260 allmodules=`func_all_modules`
2264 # First, all modules one by one.
2265 for onemodule in $allmodules; do
2266 func_create_testdir "$megatestdir/$onemodule" $onemodule
2267 megasubdirs="${megasubdirs}$onemodule "
2269 # Then, all modules all together.
2270 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2271 allmodules=`for m in $allmodules; do if test $m != fnmatch-posix; then echo $m; fi; done`
2272 func_create_testdir "$megatestdir/ALL" "$allmodules"
2273 megasubdirs="${megasubdirs}ALL"
2275 # Create Makefile.am.
2276 (echo "## Process this file with automake to produce Makefile.in."
2278 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2280 echo "SUBDIRS = $megasubdirs"
2281 ) > "$megatestdir/Makefile.am"
2283 # Create configure.ac.
2284 (echo "# Process this file with autoconf to produce a configure script."
2285 echo "AC_INIT([dummy], [0])"
2286 if test "$auxdir" != "."; then
2287 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2289 echo "AM_INIT_AUTOMAKE"
2291 echo "AC_PROG_MAKE_SET"
2293 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
2294 echo "AC_OUTPUT([Makefile])"
2295 ) > "$megatestdir/configure.ac"
2297 # Create autogenerated files.
2299 # Do not use "${AUTORECONF} --install", because autoreconf operates
2300 # recursively, but the subdirectories are already finished, therefore
2301 # calling autoreconf here would only waste lots of CPU time.
2302 echo "executing ${ACLOCAL}"
2304 echo "executing mkdir build-aux"
2306 echo "executing ${AUTOCONF}"
2308 echo "executing ${AUTOMAKE} --add-missing --copy"
2309 ${AUTOMAKE} --add-missing --copy
2315 func_fatal_error "no mode specified" ;;
2324 if test -z "$destdir"; then
2327 test -d "$destdir" \
2328 || func_fatal_error "destination directory does not exist: $destdir"
2330 # Prefer configure.ac to configure.in.
2331 if test -f "$destdir"/configure.ac; then
2332 configure_ac="$destdir/configure.ac"
2334 if test -f "$destdir"/configure.in; then
2335 configure_ac="$destdir/configure.in"
2337 func_fatal_error "cannot find $destdir/configure.ac"
2341 # Analyze configure.ac.
2343 guessed_libtool=false
2348 /AC_CONFIG_AUX_DIR/ {
2349 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
2351 /A[CM]_PROG_LIBTOOL/ {
2352 s,^.*$,guessed_libtool=true,p
2354 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
2356 if test -z "$auxdir"; then
2357 auxdir="$guessed_auxdir"
2360 # Determine where to apply func_import.
2361 if test -n "$m4base"; then
2362 # Apply func_import to a particular gnulib directory.
2363 # Any number of additional modules can be given.
2364 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
2365 # First use of gnulib in the given m4base.
2366 test -n "$supplied_libname" || supplied_libname=true
2367 test -n "$sourcebase" || sourcebase="lib"
2368 test -n "$docbase" || docbase="doc"
2369 test -n "$testsbase" || testsbase="tests"
2370 test -n "$macro_prefix" || macro_prefix="gl"
2374 # Apply func_import to all gnulib directories.
2375 # To get this list of directories, look at Makefile.am. (Not at
2376 # configure, because it may be omitted from CVS. Also, don't run
2377 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
2380 if test -f "$destdir"/Makefile.am; then
2381 aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$destdir"/Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'`
2383 for arg in $aclocal_amflags; do
2384 if test -n "$m4dir_is_next"; then
2385 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
2389 if test -f "$destdir/$arg"/gnulib-cache.m4; then
2390 m4dirs="$m4dirs $arg"
2391 m4dirs_count=`expr $m4dirs_count + 1`
2396 if test "X$arg" = "X-I"; then
2404 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
2405 if test -f "$destdir"/aclocal.m4; then
2406 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
2407 sedexpr2='s,^[^/]*$,.,'
2408 sedexpr3='s,/[^/]*$,,'
2409 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort | LC_ALL=C uniq`
2410 m4dirs_count=`echo "$m4dirs" | wc -l`
2413 if test $m4dirs_count = 0; then
2414 # First use of gnulib in a package.
2415 # Any number of additional modules can be given.
2416 test -n "$supplied_libname" || supplied_libname=true
2417 test -n "$sourcebase" || sourcebase="lib"
2419 test -n "$docbase" || docbase="doc"
2420 test -n "$testsbase" || testsbase="tests"
2421 test -n "$macro_prefix" || macro_prefix="gl"
2424 if test $m4dirs_count = 1; then
2425 # There's only one use of gnulib here. Assume the user means it.
2426 # Any number of additional modules can be given.
2427 for m4base in $m4dirs; do
2431 # Ambiguous - guess what the user meant.
2432 if test $# = 0; then
2433 # No further arguments. Guess the user wants to update all of them.
2434 for m4base in $m4dirs; do
2435 # Perform func_import in a subshell, so that variable values
2437 # local_gnulib_dir, avoidlist, sourcebase, m4base, docbase,
2438 # testsbase, libname, lgpl, makefile_name, libtool, macro_prefix
2439 # don't propagate from one directory to another.
2440 (func_import) || exit 1
2444 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
2452 if test -z "$destdir"; then
2453 func_fatal_error "please specify --dir option"
2456 test -d "$destdir" \
2457 || func_fatal_error "could not create destination directory"
2458 test -n "$auxdir" || auxdir="build-aux"
2459 func_create_testdir "$destdir" "$*"
2462 create-megatestdir )
2463 if test -z "$destdir"; then
2464 func_fatal_error "please specify --dir option"
2466 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2467 test -n "$auxdir" || auxdir="build-aux"
2468 func_create_megatestdir "$destdir" "$*"
2472 test -n "$destdir" || destdir=testdir$$
2473 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2474 test -n "$auxdir" || auxdir="build-aux"
2475 func_create_testdir "$destdir" "$*"
2483 remaining=`find . -type f -print`
2484 if test -n "$remaining"; then
2485 echo "Remaining files:" $remaining 1>&2
2486 echo "gnulib-tool: *** Stop." 1>&2
2495 test -n "$destdir" || destdir=testdir$$
2496 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2497 test -n "$auxdir" || auxdir="build-aux"
2498 func_create_megatestdir "$destdir" "$*"
2506 remaining=`find . -type f -print`
2507 if test -n "$remaining"; then
2508 echo "Remaining files:" $remaining 1>&2
2509 echo "gnulib-tool: *** Stop." 1>&2
2517 extract-description )
2521 if test -n "$module"; then
2522 func_get_description "$module"
2531 if test -n "$module"; then
2532 func_get_filelist "$module"
2537 extract-dependencies )
2541 if test -n "$module"; then
2542 func_get_dependencies "$module"
2547 extract-autoconf-snippet )
2551 if test -n "$module"; then
2552 func_get_autoconf_snippet "$module"
2557 extract-automake-snippet )
2561 if test -n "$module"; then
2562 func_get_automake_snippet "$module"
2567 extract-include-directive )
2571 if test -n "$module"; then
2572 func_get_include_directive "$module"
2581 if test -n "$module"; then
2582 func_get_license "$module"
2587 extract-maintainer )
2591 if test -n "$module"; then
2592 func_get_maintainer "$module"
2597 extract-tests-module )
2601 if test -n "$module"; then
2602 func_get_tests_module "$module"
2608 func_fatal_error "unknown operation mode --$mode" ;;
2612 # Undo the effect of the previous 'trap' command. Some shellology:
2613 # We cannot use "trap - 0 1 2 3 15", because Solaris sh would attempt to
2614 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
2615 # exit); for the others we need to call 'exit' explicitly. The value of $? is
2616 # 128 + signal number and is set before the trap-registered command is run.
2618 trap 'exit $?' 1 2 3 15
2623 # indent-tabs-mode: nil
2624 # whitespace-check-buffer-indent: nil