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-10-12 11:43:46 $'
26 last_checkin_date=`echo "$cvsdatestamp" | sed -e 's,^\$[D]ate: ,,'`
27 version=`echo "$last_checkin_date" | sed -e 's/ .*$//' -e 's,/,-,g'`
31 # You can set AUTOCONFPATH to empty if autoconf 2.57 is already in your PATH.
35 # AUTOCONFBINDIR=/packages/gnu-inst-autoconf/2.57/bin
36 # AUTOCONFPATH="eval env PATH=${AUTOCONFBINDIR}:\$PATH "
40 # You can set AUTOMAKEPATH to empty if automake 1.9.x is already in your PATH.
43 # If you didn't set AUTOCONFPATH and AUTOMAKEPATH, you can also set the
44 # variables AUTOCONF, ACLOCAL, AUTOMAKE, AUTORECONF individually.
45 if test -z "${AUTOCONF}" || test -n "${AUTOCONFPATH}"; then
46 AUTOCONF="${AUTOCONFPATH}autoconf"
48 if test -z "${ACLOCAL}" || test -n "${AUTOMAKEPATH}"; then
49 ACLOCAL="${AUTOMAKEPATH}aclocal"
51 if test -z "${AUTOMAKE}" || test -n "${AUTOMAKEPATH}"; then
52 AUTOMAKE="${AUTOMAKEPATH}automake"
54 if test -z "${AUTORECONF}" || test -n "${AUTOCONFPATH}"; then
55 AUTORECONF="${AUTOCONFPATH}autoreconf"
58 # GNU sort is needed. Set SORT to its location (not needed if it's called
59 # 'sort' and already in the PATH).
60 if test -z "$SORT"; then
65 # outputs to stdout the --help usage message.
69 Usage: gnulib-tool --list
70 gnulib-tool --import [module1 ... moduleN]
72 gnulib-tool --create-testdir --dir=directory [module1 ... moduleN]
73 gnulib-tool --create-megatestdir --dir=directory [module1 ... moduleN]
74 gnulib-tool --test --dir=directory module1 ... moduleN
75 gnulib-tool --megatest --dir=directory [module1 ... moduleN]
76 gnulib-tool --extract-description module
77 gnulib-tool --extract-filelist module
78 gnulib-tool --extract-dependencies module
79 gnulib-tool --extract-autoconf-snippet module
80 gnulib-tool --extract-automake-snippet module
81 gnulib-tool --extract-include-directive module
82 gnulib-tool --extract-license module
83 gnulib-tool --extract-maintainer module
84 gnulib-tool --extract-tests-module module
87 --list print the available module names
88 --import import the given modules into the current package;
89 if no modules are specified, update the current
90 package from the current gnulib
91 --update update the current package, restore files omitted
93 --create-testdir create a scratch package with the given modules
94 --create-megatestdir create a mega scratch package with the given modules
95 one by one and all together
96 --test test the combination of the given modules
97 (recommended to use CC=\"gcc -Wall\" here)
98 --megatest test the given modules one by one and all together
99 (recommended to use CC=\"gcc -Wall\" here)
100 --extract-description extract the description
101 --extract-filelist extract the list of files
102 --extract-dependencies extract the dependencies
103 --extract-autoconf-snippet extract the snippet for configure.ac
104 --extract-automake-snippet extract the snippet for library makefile
105 --extract-include-directive extract the #include directive
106 --extract-license report the license terms of the source files
108 --extract-maintainer report the maintainer(s) inside gnulib
109 --extract-tests-module report the unit test module, if it exists
112 --dir=DIRECTORY Specify the target directory.
113 For --import, this specifies where your
114 configure.ac can be found. Defaults to current
116 --local-dir=DIRECTORY Specify a local override directory where to look
117 up files before looking in gnulib's directory.
119 Options for --import:
120 --lib=LIBRARY Specify the library name. Defaults to 'libgnu'.
121 --source-base=DIRECTORY
122 Directory relative to --dir where source code is
123 placed (default \"lib\").
124 --m4-base=DIRECTORY Directory relative to --dir where *.m4 macros are
125 placed (default \"m4\").
126 --doc-base=DIRECTORY Directory relative to --dir where doc files are
127 placed (default \"doc\").
128 --tests-base=DIRECTORY
129 Directory relative to --dir where unit tests are
130 placed (default \"tests\").
131 --aux-dir=DIRECTORY Directory relative to --dir where auxiliary build
132 tools are placed (default \"build-aux\").
133 --with-tests Include unit tests for the included modules.
134 --avoid=MODULE Avoid including the given MODULE. Useful if you
135 have code that provides equivalent functionality.
136 This option can be repeated.
137 --lgpl Abort if modules aren't available under the LGPL.
138 Also modify license template from GPL to LGPL.
139 --makefile-name=NAME Name of makefile in automake syntax in the
140 source-base and tests-base directories
141 (default \"Makefile.am\").
142 --libtool Use libtool rules.
143 --no-libtool Don't use libtool rules.
144 --macro-prefix=PREFIX Specify the prefix of the macros 'gl_EARLY' and
145 'gl_INIT'. Default is 'gl'.
146 --no-changelog don't update or create ChangeLog files
148 Options for --import and --update:
149 --dry-run For --import, only print what would have been done.
150 -s, --symbolic, --symlink Make symbolic links instead of copying files.
152 Report bugs to <bug-gnulib@gnu.org>."
156 # outputs to stdout the --version message.
159 year=`echo "$last_checkin_date" | sed -e 's,/.*$,,'`
161 $progname (GNU $package) $version
162 Copyright (C) $year Free Software Foundation, Inc.
163 This is free software; see the source for copying conditions. There is NO
164 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
165 Written by" "Bruno Haible" "and" "Simon Josefsson"
168 # func_emit_copyright_notice
169 # outputs to stdout a header for a generated file.
170 func_emit_copyright_notice ()
172 echo "# Copyright (C) 2004-2006 Free Software Foundation, Inc."
174 echo "# This file is free software, distributed under the terms of the GNU"
175 echo "# General Public License. As a special exception to the GNU General"
176 echo "# Public License, this file may be distributed as part of a program"
177 echo "# that contains a configuration script generated by Autoconf, under"
178 echo "# the same distribution terms as the rest of that program."
180 echo "# Generated by gnulib-tool."
191 # creates a temporary directory.
193 # - tmp pathname of freshly created temporary directory
196 # Use the environment variable TMPDIR, falling back to /tmp. This allows
197 # users to specify a different temporary directory, for example, if their
198 # /tmp is filled up or too small.
201 # Use the mktemp program if available. If not available, hide the error
203 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
204 test -n "$tmp" && test -d "$tmp"
207 # Use a simple mkdir command. It is guaranteed to fail if the directory
208 # already exists. $RANDOM is bash specific and expands to empty in shells
209 # other than bash, ksh and zsh. Its use does not increase security;
210 # rather, it minimizes the probability of failure in a very cluttered /tmp
212 tmp=$TMPDIR/gl$$-$RANDOM
213 (umask 077 && mkdir "$tmp")
216 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
221 # func_append var value
222 # appends the given value to the shell variable var.
223 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
224 # Use bash's += operator. It reduces complexity of appending repeatedly to
225 # a single variable from O(n^2) to O(n).
233 eval "$1=\"\$$1\$2\""
237 # func_fatal_error message
238 # outputs to stderr a fatal error message, and terminates the program.
241 echo "gnulib-tool: *** $1" 1>&2
242 echo "gnulib-tool: *** Stop." 1>&2
246 # func_readlink SYMLINK
247 # outputs the target of the given symlink.
248 if (type -p readlink) > /dev/null 2>&1; then
251 # Use the readlink program from GNU coreutils.
257 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
258 # would do the wrong thing if the link target contains " -> ".
259 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
263 # func_ln_if_changed SRC DEST
264 # Like ln -s, but avoids munging timestamps if the link is correct.
265 func_ln_if_changed ()
267 if test $# -ne 2; then
268 echo "usage: func_ln_if_changed SRC DEST" >&2
270 if test -L "$2" && test "$1" = "`func_readlink "$2"`"; then
278 # func_relativize DIR1 DIR2
279 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
281 # - DIR1 relative pathname, relative to the current directory
282 # - DIR2 relative pathname, relative to the current directory
284 # - reldir relative pathname of DIR2, relative to DIR1
290 sed_first='s,^\([^/]*\)/.*$,\1,'
291 sed_rest='s,^[^/]*/*,,'
292 sed_last='s,^.*/\([^/]*\)$,\1,'
293 sed_butlast='s,/*[^/]*$,,'
294 while test -n "$dir1"; do
295 first=`echo "$dir1" | sed -e "$sed_first"`
296 if test "$first" != "."; then
297 if test "$first" = ".."; then
298 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
299 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
301 first2=`echo "$dir2" | sed -e "$sed_first"`
302 if test "$first2" = "$first"; then
303 dir2=`echo "$dir2" | sed -e "$sed_rest"`
307 dir0="$dir0"/"$first"
310 dir1=`echo "$dir1" | sed -e "$sed_rest"`
315 # func_relconcat DIR1 DIR2
316 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
318 # - DIR1 relative pathname, relative to the current directory
319 # - DIR2 relative pathname, relative to DIR1
321 # - relconcat DIR1/DIR2, relative to the current directory
326 sed_first='s,^\([^/]*\)/.*$,\1,'
327 sed_rest='s,^[^/]*/*,,'
328 sed_last='s,^.*/\([^/]*\)$,\1,'
329 sed_butlast='s,/*[^/]*$,,'
331 first=`echo "$dir2" | sed -e "$sed_first"`
332 if test "$first" = "."; then
333 dir2=`echo "$dir2" | sed -e "$sed_rest"`
334 if test -z "$dir2"; then
339 last=`echo "$dir1" | sed -e "$sed_last"`
340 while test "$last" = "."; do
341 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
342 last=`echo "$dir1" | sed -e "$sed_last"`
344 if test -z "$dir1"; then
348 if test "$first" = ".."; then
349 if test "$last" = ".."; then
350 relconcat="$dir1/$dir2"
353 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
354 dir2=`echo "$dir2" | sed -e "$sed_rest"`
355 if test -z "$dir1"; then
359 if test -z "$dir2"; then
364 relconcat="$dir1/$dir2"
371 # Command-line option processing.
372 # Removes the OPTIONS from the arguments. Sets the variables:
373 # - mode list or import or create-testdir or create-megatestdir
374 # - destdir from --dir
375 # - local_gnulib_dir from --local-dir
376 # - libname, supplied_libname from --lib
377 # - sourcebase from --source-base
378 # - m4base from --m4-base
379 # - docbase from --doc-base
380 # - testsbase from --tests-base
381 # - auxdir from --aux-dir
382 # - inctests true if --with-tests was given, blank otherwise
383 # - avoidlist list of modules to avoid, from --avoid
384 # - lgpl true if --lgpl was given, blank otherwise
385 # - makefile_name from --makefile-name
386 # - libtool true if --libtool was given, false if --no-libtool was
387 # given, blank otherwise
388 # - macro_prefix from --macro-prefix
389 # - autoconf_minversion minimum supported autoconf version
390 # - do_changelog false if --no-changelog was given, : otherwise
391 # - doit : if actions shall be executed, false if only to be printed
392 # - symbolic true if --symbolic was given, blank otherwise
416 while test $# -gt 0; do
421 --import | --impor | --impo | --imp | --im | --i )
424 --update | --updat | --upda | --upd | --up | --u )
427 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
430 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
431 mode=create-megatestdir
433 --test | --tes | --te | --t )
436 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
440 mode=`echo "X$1" | sed -e 's/^X--//'`
445 func_fatal_error "missing argument for --dir"
450 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
455 func_fatal_error "missing argument for --local-dir"
460 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
465 func_fatal_error "missing argument for --lib"
468 supplied_libname=true
471 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
472 supplied_libname=true
477 func_fatal_error "missing argument for --source-base"
482 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
487 func_fatal_error "missing argument for --m4-base"
492 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
497 func_fatal_error "missing argument for --doc-base"
502 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
507 func_fatal_error "missing argument for --tests-base"
512 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
517 func_fatal_error "missing argument for --aux-dir"
522 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
530 func_fatal_error "missing argument for --avoid"
532 func_append avoidlist " $1"
535 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
536 func_append avoidlist " $arg"
544 func_fatal_error "missing argument for --makefile-name"
549 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
560 func_fatal_error "missing argument for --macro-prefix"
565 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
567 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
573 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
576 --help | --hel | --he | --h )
579 --version | --versio | --versi | --vers | --ver | --ve | --v )
583 # Stop option processing
587 echo "gnulib-tool: unknown option $1" 1>&2
588 echo "Try 'gnulib-tool --help' for more information." 1>&2
595 if test "$mode" = update; then
596 if test $# != 0; then
597 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
598 echo "Try 'gnulib-tool --help' for more information." 1>&2
599 echo "If you really want to modify the gnulib configuration of your project," 1>&2
600 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
603 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
604 || test -n "$sourcebase" || test -n "$m4base" \
605 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
606 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
607 || test -n "$makefile_name" || test -n "$macro_prefix"; then
608 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
609 echo "Try 'gnulib-tool --help' for more information." 1>&2
610 echo "If you really want to modify the gnulib configuration of your project," 1>&2
611 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
617 # Determine the minimum supported autoconf version from the project's
619 DEFAULT_AUTOCONF_MINVERSION="2.59"
622 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
623 if test -f "$destdir"/configure.ac; then
624 configure_ac="$destdir/configure.ac"
626 if test -f "$destdir"/configure.in; then
627 configure_ac="$destdir/configure.in"
631 if test -f configure.ac; then
632 configure_ac="configure.ac"
634 if test -f configure.in; then
635 configure_ac="configure.in"
639 if test -n "$configure_ac"; then
640 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
641 # because when some m4 files are omitted from a CVS repository,
642 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
643 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
644 # autom4te: m4 failed with exit status: 1
651 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,prereqs="$prereqs \1",p
653 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
654 if test -n "$prereqs"; then
655 autoconf_minversion=`for version in $prereqs; do echo $version; done | $SORT -g -u | tail -1`
658 if test -z "$autoconf_minversion"; then
659 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
661 case "$autoconf_minversion" in
662 1.* | 2.[0-4]* | 2.5[0-8]*)
663 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
666 # Remove trailing slashes from the directory names. This is necessary for
667 # m4base (to avoid an error in func_import) and optional for the others.
668 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
669 case "$local_gnulib_dir" in
670 */ ) sourcebase=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
672 case "$sourcebase" in
673 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
676 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
679 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
682 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
685 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
690 /*) self_abspathname="$0" ;;
691 */*) self_abspathname=`pwd`/"$0" ;;
692 *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
693 if test -x "$d/$0" && test ! -d "$d/$0"; then
694 self_abspathname="$d/$0"
698 if test -z "$self_abspathname"; then
699 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
703 while test -h "$self_abspathname"; do
704 # Resolve symbolic link.
705 linkval=`func_readlink "$self_abspathname"`
706 test -n "$linkval" || break
708 /* ) self_abspathname="$linkval" ;;
709 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
712 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
716 if test "$signal" != 0; then
717 echo "caught signal $signal" >&2
721 for signal in 1 2 3 13 15; do
722 trap '{ signal='$signal'; func_exit 1; }' $signal
726 # func_lookup_file file
727 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
730 # - local_gnulib_dir from --local-dir
732 # - lookedup_file name of the merged (combined) file
733 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
737 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
738 lookedup_file="$local_gnulib_dir/$lkfile"
741 if test -f "$gnulib_dir/$lkfile"; then
742 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
743 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
745 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
746 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
747 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
748 lookedup_file="$tmp/$lkbase"
751 lookedup_file="$gnulib_dir/$lkfile"
755 func_fatal_error "file $gnulib_dir/$lkfile not found"
762 # - local_gnulib_dir from --local-dir
765 # Filter out metainformation files like README, which are not modules.
766 # Filter out unit test modules; they can be retrieved through
767 # --extract-tests-module if desired.
769 (cd "$gnulib_dir/modules" && ls -1)
770 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
771 (cd "$local_gnulib_dir/modules" && ls -1 | sed -e 's,\.diff$,,')
774 | sed -e '/^CVS$/d' -e '/^ChangeLog$/d' -e '/^COPYING$/d' -e '/^README$/d' -e '/^TEMPLATE$/d' -e '/^TEMPLATE-TESTS$/d' -e '/~$/d' \
775 | sed -e '/-tests$/d' \
780 # verifies a module name
782 # - local_gnulib_dir from --local-dir
783 # - module module name argument
784 func_verify_module ()
786 if { test -f "$gnulib_dir/modules/$module" \
787 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
788 && test -f "$local_gnulib_dir/modules/$module"; }; } \
789 && test "CVS" != "$module" \
790 && test "ChangeLog" != "$module" \
791 && test "COPYING" != "$module" \
792 && test "README" != "$module" \
793 && test "TEMPLATE" != "$module" \
794 && test "TEMPLATE-TESTS" != "$module"; then
795 # OK, $module is a correct module name.
796 # Verify that building the module description with 'patch' succeeds.
797 func_lookup_file "modules/$module"
799 echo "gnulib-tool: module $module doesn't exist" 1>&2
804 # func_verify_nontests_module
805 # verifies a module name, excluding tests modules
807 # - local_gnulib_dir from --local-dir
808 # - module module name argument
809 func_verify_nontests_module ()
813 * ) func_verify_module ;;
817 # func_verify_tests_module
818 # verifies a module name, considering only tests modules
820 # - local_gnulib_dir from --local-dir
821 # - module module name argument
822 func_verify_tests_module ()
825 *-tests ) func_verify_module ;;
830 sed_extract_prog=':[ ]*$/ {
833 s/^Description:[ ]*$//
835 s/^Depends-on:[ ]*$//
836 s/^configure\.ac:[ ]*$//
837 s/^Makefile\.am:[ ]*$//
840 s/^Maintainer:[ ]*$//
847 # func_get_description module
849 # - local_gnulib_dir from --local-dir
850 func_get_description ()
852 func_lookup_file "modules/$1"
853 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
856 # func_get_filelist module
858 # - local_gnulib_dir from --local-dir
861 func_lookup_file "modules/$1"
862 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
863 case "$autoconf_minversion" in
866 echo m4/onceonly_2_57.m4
871 # func_get_dependencies module
873 # - local_gnulib_dir from --local-dir
874 func_get_dependencies ()
876 # ${module}-tests always implicitly depends on ${module}.
877 echo "$1" | sed -n -e 's/-tests//p'
878 # Then the explicit dependencies listed in the module description.
879 func_lookup_file "modules/$1"
880 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
883 # func_get_autoconf_snippet module
885 # - local_gnulib_dir from --local-dir
886 func_get_autoconf_snippet ()
888 func_lookup_file "modules/$1"
889 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
892 # func_get_automake_snippet module
894 # - local_gnulib_dir from --local-dir
895 func_get_automake_snippet ()
897 func_lookup_file "modules/$1"
898 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
901 # func_get_include_directive module
903 # - local_gnulib_dir from --local-dir
904 func_get_include_directive ()
906 func_lookup_file "modules/$1"
907 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
908 sed -e 's/^\(["<]\)/#include \1/'
911 # func_get_license module
913 # - local_gnulib_dir from --local-dir
916 func_lookup_file "modules/$1"
917 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
920 # func_get_maintainer module
922 # - local_gnulib_dir from --local-dir
923 func_get_maintainer ()
925 func_lookup_file "modules/$1"
926 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
929 # func_get_tests_module module
931 # - local_gnulib_dir from --local-dir
932 func_get_tests_module ()
934 # The naming convention for tests modules is hardwired: ${module}-tests.
935 if test -f "$gnulib_dir/modules/$1"-tests \
936 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
937 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
942 # func_acceptable module
943 # tests whether a module is acceptable.
945 # - avoidlist list of modules to avoid
948 for avoid in $avoidlist; do
949 if test "$avoid" = "$1"; then
956 # func_modules_transitive_closure
958 # - local_gnulib_dir from --local-dir
959 # - modules list of specified modules
960 # - inctests true if tests should be included, blank otherwise
961 # - avoidlist list of modules to avoid
962 # - tmp pathname of a temporary directory
964 # - modules list of modules, including dependencies
965 func_modules_transitive_closure ()
967 # In order to process every module only once (for speed), process an "input
968 # list" of modules, producing an "output list" of modules. During each round,
969 # more modules can be queued in the input list. Once a module on the input
970 # list has been processed, it is added to the "handled list", so we can avoid
971 # to process it again.
975 while test -n "$inmodules"; do
976 inmodules_this_round="$inmodules"
977 inmodules= # Accumulator, queue for next round
978 for module in $inmodules_this_round; do
980 if test -n "$module"; then
981 if func_acceptable $module; then
982 func_append outmodules " $module"
983 deps=`func_get_dependencies $module`
984 # Duplicate dependencies are harmless, but Jim wants a warning.
985 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
986 if test -n "$duplicated_deps"; then
987 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
989 func_append inmodules " $deps"
990 if test -n "$inctests"; then
991 testsmodule=`func_get_tests_module $module`
992 if test -n "$testsmodule"; then
993 func_append inmodules " $testsmodule"
999 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
1000 # Remove $handledmodules from $inmodules.
1001 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
1002 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
1004 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
1005 rm -f "$tmp"/queued-modules
1008 # func_modules_add_dummy
1010 # - local_gnulib_dir from --local-dir
1011 # - modules list of modules, including dependencies
1013 # - modules list of modules, including 'dummy' if needed
1014 func_modules_add_dummy ()
1017 sed_remove_backslash_newline=':a
1024 for module in $modules; do
1025 func_verify_nontests_module
1026 if test -n "$module"; then
1027 # Extract the value of "lib_SOURCES += ...".
1028 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1029 # Ignore .h files since they are not compiled.
1032 *) have_lib_SOURCES=yes ;;
1037 # Add the dummy module, to make sure the library will be non-empty.
1038 if test -z "$have_lib_SOURCES"; then
1039 func_append modules " dummy"
1043 # func_modules_to_filelist
1045 # - local_gnulib_dir from --local-dir
1046 # - modules list of modules, including dependencies
1048 # - files list of files
1049 func_modules_to_filelist ()
1052 for module in $modules; do
1054 if test -n "$module"; then
1055 fs=`func_get_filelist $module`
1056 func_append files " $fs"
1059 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1062 # func_emit_lib_Makefile_am
1063 # emits the contents of library makefile to standard output.
1065 # - local_gnulib_dir from --local-dir
1066 # - modules list of modules, including dependencies
1067 # - libname library name
1068 # - makefile_name from --makefile-name
1069 # - libtool true if libtool will be used, false or blank otherwise
1070 # - actioncmd (optional) command that will reproduce this invocation
1071 func_emit_lib_Makefile_am ()
1073 # When creating an includable Makefile.am snippet, augment variables with
1074 # += instead of assigning them.
1075 if test -n "$makefile_name"; then
1080 if test "$libtool" = true; then
1083 sed_eliminate_LDFLAGS=
1087 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1089 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1090 echo "## Process this file with automake to produce Makefile.in."
1091 func_emit_copyright_notice
1092 if test -n "$actioncmd"; then
1093 echo "# Reproduce by: $actioncmd"
1096 if test -z "$makefile_name"; then
1097 echo "AUTOMAKE_OPTIONS = 1.5 gnits"
1101 for module in $modules; do
1102 func_verify_nontests_module
1103 if test -n "$module"; then
1105 func_get_automake_snippet "$module" |
1106 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1107 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1108 sed -e "$sed_eliminate_LDFLAGS" |
1109 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1110 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1111 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
1112 if test "$module" = 'alloca'; then
1113 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1116 # Skip the contents if its entirely empty.
1117 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1118 echo "## begin gnulib module $module"
1121 echo "## end gnulib module $module"
1128 if grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1129 # One of the snippets already specifies an installation location for the
1130 # library. Don't confuse automake by saying it should not be installed.
1133 # By default, the generated library should not be installed.
1134 echo "noinst_${perhapsLT}LIBRARIES $assign $libname.$libext"
1137 echo "${libname}_${libext}_SOURCES ="
1138 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1139 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1140 echo "${libname}_${libext}_LIBADD = \$(${perhapsLT}LIBOBJS)"
1141 if test "$libtool" = true; then
1142 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1144 if test -z "$makefile_name"; then
1145 echo "noinst_HEADERS ="
1146 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1147 # if you specify pkgdata_DATA to empty. This is a workaround.
1148 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1149 echo "pkgdata_DATA ="
1152 echo "BUILT_SOURCES ="
1155 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1156 if test -z "$makefile_name"; then
1157 echo "MOSTLYCLEANDIRS ="
1159 echo "DISTCLEANFILES ="
1160 echo "MAINTAINERCLEANFILES ="
1162 echo "AM_CPPFLAGS ="
1167 echo "mostlyclean-local: mostlyclean-generic"
1168 echo " @test -z \"\$(MOSTLYCLEANDIRS)\" || \\"
1169 echo " for dir in \$(MOSTLYCLEANDIRS); do \\"
1170 echo " if test -d \$\$dir; then \\"
1171 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1174 rm -f allsnippets.tmp
1177 # func_emit_tests_Makefile_am
1178 # emits the contents of tests makefile to standard output.
1180 # - local_gnulib_dir from --local-dir
1181 # - modules list of modules, including dependencies
1182 # - libname library name
1183 # - makefile_name from --makefile-name
1184 # - libtool true if libtool will be used, false or blank otherwise
1185 # - sourcebase relative directory containing lib source code
1186 # - m4base relative directory containing autoconf macros
1187 # - testsbase relative directory containing unit test code
1188 func_emit_tests_Makefile_am ()
1190 if test "$libtool" = true; then
1195 if test "$libtool" = true; then
1197 sed_eliminate_LDFLAGS=
1200 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1202 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1203 echo "## DO NOT EDIT! GENERATED AUTOMATICALLY!"
1204 echo "## Process this file with automake to produce Makefile.in."
1205 func_emit_copyright_notice
1207 # Generate dependencies here, since it eases the debugging of test failures.
1208 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1210 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1213 for module in $modules; do
1214 func_verify_tests_module
1215 if test -n "$module"; then
1217 func_get_automake_snippet "$module" |
1218 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1219 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1220 sed -e "$sed_eliminate_LDFLAGS" |
1221 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1222 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1223 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
1225 # Skip the contents if its entirely empty.
1226 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1227 echo "## begin gnulib module $module"
1230 echo "## end gnulib module $module"
1237 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1238 # variable is needed to avoid an error from automake:
1239 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1242 echo "TESTS_ENVIRONMENT ="
1243 echo "noinst_PROGRAMS ="
1244 echo "check_PROGRAMS ="
1245 echo "noinst_HEADERS ="
1246 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1247 echo "pkgdata_DATA ="
1250 echo "BUILT_SOURCES ="
1252 echo "MOSTLYCLEANFILES = core *.stackdump"
1253 echo "MOSTLYCLEANDIRS ="
1255 echo "DISTCLEANFILES ="
1256 echo "MAINTAINERCLEANFILES ="
1258 echo "AM_CPPFLAGS = \\"
1259 echo " -I. -I\$(srcdir) \\"
1260 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1261 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1263 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1266 echo "# Clean up after Solaris cc."
1268 echo " rm -rf SunWS_cache"
1270 echo "mostlyclean-local: mostlyclean-generic"
1271 echo " @test -z \"\$(MOSTLYCLEANDIRS)\" || \\"
1272 echo " for dir in \$(MOSTLYCLEANDIRS); do \\"
1273 echo " if test -d \$\$dir; then \\"
1274 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1277 rm -f allsnippets.tmp
1280 # func_import modules
1281 # Uses also the variables
1282 # - destdir target directory
1283 # - local_gnulib_dir from --local-dir
1284 # - libname library name
1285 # - sourcebase directory relative to destdir where to place source code
1286 # - m4base directory relative to destdir where to place *.m4 macros
1287 # - docbase directory relative to destdir where to place doc files
1288 # - testsbase directory relative to destdir where to place unit test code
1289 # - auxdir directory relative to destdir where to place build aux files
1290 # - inctests true if --with-tests was given, blank otherwise
1291 # - avoidlist list of modules to avoid, from --avoid
1292 # - lgpl true if library's license shall be LGPL, blank otherwise
1293 # - makefile_name from --makefile-name
1294 # - libtool true if --libtool was given, false if --no-libtool was
1295 # given, blank otherwise
1296 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1297 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1298 # - autoconf_minversion minimum supported autoconf version
1299 # - doit : if actions shall be executed, false if only to be printed
1300 # - symbolic true if files should be symlinked, copied otherwise
1303 # Get the cached settings.
1304 cached_local_gnulib_dir=
1305 cached_specified_modules=
1313 cached_makefile_name=
1315 cached_macro_prefix=
1317 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1318 cached_libtool=false
1324 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
1327 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1330 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1333 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1336 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1339 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1342 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1345 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1348 s,^.*$,cached_lgpl=true,p
1350 /gl_MAKEFILE_NAME(/ {
1351 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
1354 s,^.*$,cached_libtool=true,p
1356 /gl_MACRO_PREFIX(/ {
1357 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
1359 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
1360 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1365 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
1366 s,^.*$,cached_files=",p
1378 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1382 # Merge the cached settings with the specified ones.
1383 # The m4base must be the same as expected from the pathname.
1384 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1385 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1387 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
1388 # is relative to $destdir, whereas the one we use is relative to . or absolute.
1389 if test -z "$local_gnulib_dir"; then
1390 if test -n "$cached_local_gnulib_dir"; then
1393 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1395 case "$cached_local_gnulib_dir" in
1397 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1399 func_relconcat "$destdir" "$cached_local_gnulib_dir"
1400 local_gnulib_dir="$relconcat" ;;
1405 # Append the cached and the specified module names. So that
1406 # "gnulib-tool --import foo" means to add the module foo.
1407 specified_modules="$cached_specified_modules $1"
1408 # Append the cached and the specified avoidlist. This is probably better
1409 # than dropping the cached one when --avoid is specified at least once.
1410 avoidlist=`echo $cached_avoidlist $avoidlist`
1411 # The sourcebase defaults to the cached one.
1412 if test -z "$sourcebase"; then
1413 sourcebase="$cached_sourcebase"
1414 if test -z "$sourcebase"; then
1415 func_fatal_error "missing --source-base option"
1418 # The docbase defaults to the cached one.
1419 if test -z "$docbase"; then
1420 docbase="$cached_docbase"
1421 if test -z "$docbase"; then
1422 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."
1425 # The testsbase defaults to the cached one.
1426 if test -z "$testsbase"; then
1427 testsbase="$cached_testsbase"
1428 if test -z "$testsbase"; then
1429 func_fatal_error "missing --tests-base option"
1432 # The libname defaults to the cached one.
1433 if test -z "$supplied_libname"; then
1434 libname="$cached_libname"
1435 if test -z "$libname"; then
1436 func_fatal_error "missing --lib option"
1439 # Require LGPL if specified either way.
1440 if test -z "$lgpl"; then
1443 # The makefile_name defaults to the cached one.
1444 if test -z "$makefile_name"; then
1445 makefile_name="$cached_makefile_name"
1447 # Use libtool if specified either way, or if guessed.
1448 if test -z "$libtool"; then
1449 if test -n "$cached_m4base"; then
1450 libtool="$cached_libtool"
1452 libtool="$guessed_libtool"
1455 # The macro_prefix defaults to the cached one.
1456 if test -z "$macro_prefix"; then
1457 macro_prefix="$cached_macro_prefix"
1458 if test -z "$macro_prefix"; then
1459 func_fatal_error "missing --macro-prefix option"
1463 # Canonicalize the list of specified modules.
1464 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
1466 # Determine final module list.
1467 modules="$specified_modules"
1468 func_modules_transitive_closure
1469 echo "Module list with included dependencies:"
1470 echo "$modules" | sed -e 's/^/ /'
1472 # Add the dummy module if needed.
1473 func_modules_add_dummy
1475 # If --lgpl, verify that the licenses of modules are compatible.
1476 if test -n "$lgpl"; then
1477 for module in $modules; do
1478 license=`func_get_license $module`
1480 LGPL | 'GPLed build tool') ;;
1481 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
1482 *) func_fatal_error "incompatible license on module $module: $license" ;;
1487 # Determine script to apply to imported library files.
1488 sed_transform_lib_file=
1489 for module in $modules; do
1490 if test $module = config-h; then
1491 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
1492 sed_transform_lib_file=$sed_transform_lib_file'
1493 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
1498 if test -n "$lgpl"; then
1500 sed_transform_lib_file=$sed_transform_lib_file'
1501 s/GNU General/GNU Lesser General/g
1502 s/version 2\([ ,]\)/version 2.1\1/g
1506 # Determine final file list.
1507 func_modules_to_filelist
1509 echo "$files" | sed -e 's/^/ /'
1512 || func_fatal_error "refusing to do nothing"
1514 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
1515 new_files="$files m4/gnulib-tool.m4"
1516 old_files="$cached_files"
1517 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
1518 func_append old_files " m4/gnulib-tool.m4"
1521 # Create directories.
1522 if test ! -d "$destdir/$sourcebase"; then
1524 echo "Creating directory $destdir/$sourcebase"
1525 mkdir "$destdir/$sourcebase" || func_fatal_error "failed"
1527 echo "Create directory $destdir/$sourcebase"
1530 if test ! -d "$destdir/$m4base"; then
1532 echo "Creating directory $destdir/$m4base"
1533 mkdir "$destdir/$m4base" || func_fatal_error "failed"
1535 echo "Create directory $destdir/$m4base"
1538 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
1539 if test -n "$docfiles"; then
1540 if test ! -d "$destdir/$docbase"; then
1542 echo "Creating directory $destdir/$docbase"
1543 mkdir "$destdir/$docbase" || func_fatal_error "failed"
1545 echo "Create directory $destdir/$docbase"
1549 if test -n "$inctests"; then
1550 if test ! -d "$destdir/$testsbase"; then
1552 echo "Creating directory $destdir/$testsbase"
1553 mkdir "$destdir/$testsbase" || func_fatal_error "failed"
1555 echo "Create directory $destdir/$testsbase"
1559 if test ! -d "$destdir/$auxdir"; then
1561 echo "Creating directory $destdir/$auxdir"
1562 mkdir "$destdir/$auxdir" || func_fatal_error "failed"
1564 echo "Create directory $destdir/$auxdir"
1568 # func_dest_tmpfilename file
1569 # determines the name of a temporary file (file is relative to destdir).
1571 # - tmpfile absolute filename of the temporary file
1572 func_dest_tmpfilename ()
1575 # Put the new contents of $file in a file in the same directory (needed
1576 # to guarantee that an 'mv' to "$destdir/$file" works).
1577 tmpfile="$destdir/$1.tmp"
1579 # Put the new contents of $file in a file in a temporary directory
1580 # (because the directory of "$file" might not exist).
1581 tmpfile="$tmp"/`basename "$1"`.tmp
1585 # Copy files or make symbolic links. Remove obsolete files.
1587 sed_rewrite_old_files="\
1588 s,^build-aux/,$auxdir/,
1589 s,^doc/,$cached_docbase/,
1590 s,^lib/,$cached_sourcebase/,
1591 s,^m4/,$cached_m4base/,
1592 s,^tests/,$cached_testsbase/,"
1593 sed_rewrite_new_files="\
1594 s,^build-aux/,$auxdir/,
1596 s,^lib/,$sourcebase/,
1598 s,^tests/,$testsbase/,"
1599 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1600 # representing the files according to the last gnulib-tool invocation.
1601 for f in $old_files; do echo $f; done \
1602 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
1605 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1606 # representing the files after this gnulib-tool invocation.
1607 for f in $new_files; do echo $f; done \
1608 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
1611 # First the files that are in old-files, but not in new-files:
1612 sed_take_first_column='s,'"$delimiter"'.*,,'
1613 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
1614 # Remove the file. Do nothing if the user already removed it.
1615 if test -f "$destdir/$g"; then
1617 echo "Removing file $g (backup in ${g}~)"
1618 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1620 echo "Remove file $g (backup in ${g}~)"
1624 # func_add_or_update handles a file that ought to be present afterwards.
1626 # - f the original file name
1627 # - g the rewritten file name
1628 # - already_present nonempty if the file already exists, empty otherwise
1629 func_add_or_update ()
1631 func_dest_tmpfilename "$g"
1632 func_lookup_file "$f"
1633 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
1634 if test -n "$sed_transform_lib_file"; then
1637 sed -e "$sed_transform_lib_file" \
1638 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
1642 if test -f "$destdir/$g"; then
1643 # The file already exists.
1644 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1645 : # The file has not changed.
1649 if test -n "$already_present"; then
1650 echo "Updating file $g (backup in ${g}~)"
1652 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
1654 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1655 if test -n "$symbolic" && test -z "$lookedup_tmp" \
1656 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1657 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1659 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1662 if test -n "$already_present"; then
1663 echo "Update file $g (backup in ${g}~)"
1665 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
1671 # Don't protest if the file should be there but isn't: it happens
1672 # frequently that developers don't put autogenerated files into CVS.
1674 echo "Copying file $g"
1675 if test -n "$symbolic" && test -z "$lookedup_tmp" \
1676 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1677 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1679 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1687 # Then the files that are in new-files, but not in old-files:
1688 sed_take_last_column='s,^.*'"$delimiter"',,'
1690 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
1691 | sed -e "$sed_take_last_column" \
1692 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
1693 { # Rearrange file descriptors. Needed because "while ... done < ..."
1694 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1695 exec 5<&0 < "$tmp"/added-files
1701 # Then the files that are in new-files and in old-files:
1702 already_present=true
1703 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
1704 | sed -e "$sed_take_last_column" \
1705 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
1706 { # Rearrange file descriptors. Needed because "while ... done < ..."
1707 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
1708 exec 5<&0 < "$tmp"/kept-files
1715 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
1716 actioncmd="gnulib-tool --import"
1717 func_append actioncmd " --dir=$destdir"
1718 if test -n "$local_gnulib_dir"; then
1719 func_append actioncmd " --local-dir=$local_gnulib_dir"
1721 func_append actioncmd " --lib=$libname"
1722 func_append actioncmd " --source-base=$sourcebase"
1723 func_append actioncmd " --m4-base=$m4base"
1724 func_append actioncmd " --doc-base=$docbase"
1725 func_append actioncmd " --aux-dir=$auxdir"
1726 for module in $avoidlist; do
1727 func_append actioncmd " --avoid=$module"
1729 if test -n "$lgpl"; then
1730 func_append actioncmd " --lgpl"
1732 if test -n "$makefile_name"; then
1733 func_append actioncmd " --makefile_name=$makefile_name"
1735 if test "$libtool" = true; then
1736 func_append actioncmd " --libtool"
1738 func_append actioncmd " --no-libtool"
1740 func_append actioncmd " --macro-prefix=$macro_prefix"
1741 func_append actioncmd " `echo $specified_modules`"
1743 # Default the makefile name to Makefile.am.
1744 if test -n "$makefile_name"; then
1745 makefile_am=$makefile_name
1747 makefile_am=Makefile.am
1750 # Create library makefile.
1751 func_dest_tmpfilename $sourcebase/$makefile_am
1752 func_emit_lib_Makefile_am > "$tmpfile"
1753 if test -f "$destdir"/$sourcebase/$makefile_am; then
1754 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
1758 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
1759 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
1760 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
1762 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
1768 echo "Creating $sourcebase/$makefile_am"
1769 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
1771 echo "Create $sourcebase/$makefile_am"
1776 # Create m4/gnulib-cache.m4.
1777 func_dest_tmpfilename $m4base/gnulib-cache.m4
1779 func_emit_copyright_notice
1781 echo "# This file represents the specification of how gnulib-tool is used."
1782 echo "# It acts as a cache: It is written and read by gnulib-tool."
1783 echo "# In projects using CVS, this file is meant to be stored in CVS,"
1784 echo "# like the configure.ac and various Makefile.am files."
1787 echo "# Specification in the form of a command-line invocation:"
1790 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
1791 # Store the local_gnulib_dir relative to destdir.
1792 case "$local_gnulib_dir" in
1794 relative_local_gnulib_dir="$local_gnulib_dir" ;;
1797 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
1799 # destdir, local_gnulib_dir are both relative.
1800 func_relativize "$destdir" "$local_gnulib_dir"
1801 relative_local_gnulib_dir="$reldir" ;;
1804 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
1805 echo "gl_MODULES(["`echo $specified_modules`"])"
1806 echo "gl_AVOID([$avoidlist])"
1807 echo "gl_SOURCE_BASE([$sourcebase])"
1808 echo "gl_M4_BASE([$m4base])"
1809 echo "gl_DOC_BASE([$docbase])"
1810 echo "gl_TESTS_BASE([$testsbase])"
1811 echo "gl_LIB([$libname])"
1812 test -z "$lgpl" || echo "gl_LGPL"
1813 echo "gl_MAKEFILE_NAME([$makefile_name])"
1814 if test "$libtool" = true; then
1817 echo "gl_MACRO_PREFIX([$macro_prefix])"
1819 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1820 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
1824 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1825 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
1826 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
1828 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1832 echo "# gnulib-cache.m4 ends here"
1839 echo "Creating $m4base/gnulib-cache.m4"
1840 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
1842 echo "Create $m4base/gnulib-cache.m4"
1848 # Create m4/gnulib-comp.m4.
1849 func_dest_tmpfilename $m4base/gnulib-comp.m4
1851 echo "# DO NOT EDIT! GENERATED AUTOMATICALLY!"
1852 func_emit_copyright_notice
1854 echo "# This file represents the compiled summary of the specification in"
1855 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
1856 echo "# to be invoked from configure.ac."
1857 echo "# In projects using CVS, this file can be treated like other built files."
1860 echo "# This macro should be invoked from $configure_ac, in the section"
1861 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
1862 echo "# any checks for libraries, header files, types and library functions."
1863 echo "AC_DEFUN([${macro_prefix}_EARLY],"
1865 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
1866 echo " m4_pattern_allow([^gl_ES$])dnl a valid locale name"
1867 echo " AC_REQUIRE([AC_PROG_RANLIB])"
1868 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1869 echo " AC_REQUIRE([AC_GNU_SOURCE])"
1871 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1872 echo " AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])"
1874 if grep gl_LOCK "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1875 echo " AC_REQUIRE([gl_LOCK_EARLY])"
1879 echo "# This macro should be invoked from $configure_ac, in the section"
1880 echo "# \"Check for header files, types and library functions\"."
1881 echo "AC_DEFUN([${macro_prefix}_INIT],"
1883 if test "$libtool" = true; then
1884 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1885 echo " gl_cond_libtool=true"
1887 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1888 echo " gl_cond_libtool=false"
1890 echo " gl_ltlibdeps="
1892 echo " gl_source_base='$sourcebase'"
1893 if test "$auxdir" != "build-aux"; then
1894 sed_replace_build_aux='
1896 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
1897 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
1900 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
1902 sed_replace_build_aux=
1904 for module in $modules; do
1906 if test -n "$module"; then
1907 func_get_autoconf_snippet "$module" \
1908 | sed -e '/^$/d;' -e 's/^/ /' \
1909 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
1910 -e "$sed_replace_build_aux"
1911 if test "$module" = 'alloca' && test "$libtool" = true; then
1912 echo 'changequote(,)dnl'
1913 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
1914 echo 'changequote([, ])dnl'
1915 echo 'AC_SUBST([LTALLOCA])'
1919 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
1920 # created using libtool, because libtool already handles the dependencies.
1921 if test "$libtool" != true; then
1922 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
1923 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
1924 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
1925 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
1926 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
1930 echo "# This macro records the list of files which have been installed by"
1931 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
1932 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
1933 echo "$files" | sed -e 's,^, ,'
1936 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1937 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
1941 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1942 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
1943 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
1945 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1949 echo "# gnulib-comp.m4 ends here"
1956 echo "Creating $m4base/gnulib-comp.m4"
1957 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
1959 echo "Create $m4base/gnulib-comp.m4"
1965 if test -n "$inctests"; then
1966 # Create tests makefile.
1967 func_dest_tmpfilename $testsbase/$makefile_am
1968 func_emit_tests_Makefile_am > "$tmpfile"
1969 if test -f "$destdir"/$testsbase/$makefile_am; then
1970 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
1974 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
1975 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
1976 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
1978 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
1984 echo "Creating $testsbase/$makefile_am"
1985 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
1987 echo "Create $testsbase/$makefile_am"
1995 echo "You may need to add #include directives for the following .h files."
1996 # First the #include <...> directives without #ifs, sorted for convenience,
1997 # then the #include "..." directives without #ifs, sorted for convenience,
1998 # then the #include directives that are surrounded by #ifs. Not sorted.
1999 for module in $modules; do
2000 include_directive=`func_get_include_directive "$module"`
2001 case "$nl$include_directive" in
2003 echo "$include_directive" 1>&5
2006 echo "$include_directive" | grep -v 'include "' 1>&6
2007 echo "$include_directive" | grep 'include "' 1>&7
2010 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
2012 LC_ALL=C sort -u "$tmp"/include-angles
2013 LC_ALL=C sort -u "$tmp"/include-quotes
2014 cat "$tmp"/include-if
2015 ) | sed -e '/^$/d' -e 's/^/ /'
2016 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
2019 echo "Don't forget to"
2020 if test "$makefile_am" = Makefile.am; then
2021 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2023 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
2025 if test -n "$inctests"; then
2026 if test "$makefile_am" = Makefile.am; then
2027 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
2029 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
2032 if test "$makefile_am" = Makefile.am; then
2033 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
2034 sourcebase_base=`basename "$sourcebase"`
2035 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
2037 if test -n "$inctests"; then
2038 if test "$makefile_am" = Makefile.am; then
2039 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
2040 testsbase_base=`basename "$testsbase"`
2041 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
2044 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
2045 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
2046 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
2049 # func_create_testdir testdir modules
2051 # - local_gnulib_dir from --local-dir
2052 # - auxdir directory relative to destdir where to place build aux files
2053 func_create_testdir ()
2057 if test -z "$modules"; then
2058 # All modules together.
2059 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2060 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2061 modules=`func_all_modules`
2062 modules=`for m in $modules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
2064 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
2066 # Subdirectory names.
2072 # Determine final module list.
2073 func_modules_transitive_closure
2074 echo "Module list with included dependencies:"
2075 echo "$modules" | sed -e 's/^/ /'
2077 # Add the dummy module if needed.
2078 func_modules_add_dummy
2080 # Determine final file list.
2081 func_modules_to_filelist
2083 echo "$files" | sed -e 's/^/ /'
2085 # Create directories.
2086 for d in `echo "$files" | sed -n -e 's,^\(.*\)/[^/]*,\1,p'`; do
2088 build-aux) mkdir -p "$testdir/$auxdir" ;;
2089 doc) mkdir -p "$testdir/$docbase" ;;
2090 lib) mkdir -p "$testdir/$sourcebase" ;;
2091 m4) mkdir -p "$testdir/$m4base" ;;
2092 tests) mkdir -p "$testdir/$testsbase" ;;
2093 *) mkdir -p "$testdir/$d" ;;
2097 # Copy files or make symbolic links.
2099 sed_rewrite_files="\
2100 s,^build-aux/,$auxdir/,
2102 s,^lib/,$sourcebase/,
2104 s,^tests/,$testsbase/,"
2105 for f in $files; do echo $f; done \
2106 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
2109 { # Rearrange file descriptors. Needed because "while ... done < ..."
2110 # constructs are executed in a subshell e.g. by Solaris 10 /bin/sh.
2111 exec 5<&0 < "$tmp"/files
2113 func_lookup_file "$f"
2114 if test -n "$lookedup_tmp"; then
2115 cp -p "$lookedup_file" "$testdir/$g"
2117 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
2118 if test -z "$symbolic"; then
2119 cp -p "$lookedup_file" "$testdir/$g"
2121 ln -s "$lookedup_file" "$testdir/$g"
2128 # Create $sourcebase/Makefile.am.
2129 mkdir -p "$testdir/$sourcebase"
2130 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
2132 # Create $m4base/Makefile.am.
2133 mkdir -p "$testdir/$m4base"
2134 (echo "## Process this file with automake to produce Makefile.in."
2140 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
2143 ) > "$testdir/$m4base/Makefile.am"
2145 subdirs="$sourcebase $m4base"
2146 subdirs_with_configure_ac=""
2148 if test -f "$testdir"/$m4base/gettext.m4; then
2149 # Avoid stupid error message from automake:
2150 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
2151 mkdir -p "$testdir/po"
2152 (echo "## Process this file with automake to produce Makefile.in."
2153 ) > "$testdir/po/Makefile.am"
2154 func_append subdirs " po"
2157 if test -n "$inctests"; then
2158 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
2159 # Create $testsbase/Makefile.am.
2160 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
2161 # Create $testsbase/configure.ac.
2162 (echo "# Process this file with autoconf to produce a configure script."
2163 echo "AC_INIT([dummy], [0])"
2164 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
2165 echo "AM_INIT_AUTOMAKE"
2167 echo "AM_CONFIG_HEADER([config.h])"
2170 echo "AC_PROG_INSTALL"
2171 echo "AC_PROG_MAKE_SET"
2172 echo "AC_PROG_RANLIB"
2174 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2175 echo "AC_GNU_SOURCE"
2178 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2179 echo "gl_USE_SYSTEM_EXTENSIONS"
2182 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2183 echo "gl_LOCK_EARLY"
2186 if test "$libtool" = true; then
2187 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2188 echo "gl_cond_libtool=true"
2190 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2191 echo "gl_cond_libtool=false"
2193 echo "gl_ltlibdeps="
2195 echo "gl_source_base='$testsbase'"
2196 # Wrap the set of autoconf snippets into an autoconf macro that is then
2197 # invoked. This is needed because autoconf does not support AC_REQUIRE
2199 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2200 # but we want the AC_REQUIRE to have its normal meaning (provide one
2201 # expansion of the required macro before the current point, and only one
2203 echo "AC_DEFUN([gl_INIT], ["
2204 if test "$auxdir" != "build-aux"; then
2205 sed_replace_build_aux='
2207 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2208 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
2211 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2213 sed_replace_build_aux=
2215 # We don't have explicit ordering constraints between the various
2216 # autoconf snippets. It's cleanest to put those of the library before
2217 # those of the tests.
2218 for module in $modules; do
2219 func_verify_nontests_module
2220 if test -n "$module"; then
2221 func_get_autoconf_snippet "$module" \
2222 | sed -e "$sed_replace_build_aux"
2225 for module in $modules; do
2226 func_verify_tests_module
2227 if test -n "$module"; then
2228 func_get_autoconf_snippet "$module" \
2229 | sed -e "$sed_replace_build_aux"
2232 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2233 # created using libtool, because libtool already handles the dependencies.
2234 if test "$libtool" != true; then
2235 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2236 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2237 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2238 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2239 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2244 # Usually $testsbase/config.h will be a superset of config.h. Verify this
2245 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
2246 echo "AH_TOP([#include \"../config.h\"])"
2248 echo "AC_OUTPUT([Makefile])"
2249 ) > "$testdir/$testsbase/configure.ac"
2250 func_append subdirs " $testsbase"
2251 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
2254 # Create Makefile.am.
2255 (echo "## Process this file with automake to produce Makefile.in."
2257 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2259 echo "SUBDIRS = $subdirs"
2261 echo "ACLOCAL_AMFLAGS = -I $m4base"
2262 ) > "$testdir/Makefile.am"
2264 # Create configure.ac.
2265 (echo "# Process this file with autoconf to produce a configure script."
2266 echo "AC_INIT([dummy], [0])"
2267 if test "$auxdir" != "."; then
2268 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2270 echo "AM_INIT_AUTOMAKE"
2272 echo "AM_CONFIG_HEADER([config.h])"
2275 echo "AC_PROG_INSTALL"
2276 echo "AC_PROG_MAKE_SET"
2278 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2279 echo "m4_pattern_allow([^gl_ES$])dnl a valid locale name"
2281 echo "AC_PROG_RANLIB"
2283 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2284 echo "AC_GNU_SOURCE"
2287 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2288 echo "gl_USE_SYSTEM_EXTENSIONS"
2291 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2292 echo "gl_LOCK_EARLY"
2295 if test "$libtool" = true; then
2296 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2297 echo "gl_cond_libtool=true"
2299 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2300 echo "gl_cond_libtool=false"
2302 echo "gl_ltlibdeps="
2304 echo "gl_source_base='$sourcebase'"
2305 # Wrap the set of autoconf snippets into an autoconf macro that is then
2306 # invoked. This is needed because autoconf does not support AC_REQUIRE
2308 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2309 # but we want the AC_REQUIRE to have its normal meaning (provide one
2310 # expansion of the required macro before the current point, and only one
2312 echo "AC_DEFUN([gl_INIT], ["
2313 if test "$auxdir" != "build-aux"; then
2314 sed_replace_build_aux='
2316 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2317 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2320 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2322 sed_replace_build_aux=
2324 for module in $modules; do
2325 func_verify_nontests_module
2326 if test -n "$module"; then
2327 func_get_autoconf_snippet "$module" \
2328 | sed -e "$sed_replace_build_aux"
2331 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2332 # created using libtool, because libtool already handles the dependencies.
2333 if test "$libtool" != true; then
2334 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2335 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2336 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2337 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2338 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2343 if test -n "$subdirs_with_configure_ac"; then
2344 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
2346 makefiles="Makefile"
2347 for d in $subdirs; do
2348 # For subdirs that have a configure.ac by their own, it's the subdir's
2349 # configure.ac which creates the subdir's Makefile.am, not this one.
2350 case " $subdirs_with_configure_ac " in
2352 *) func_append makefiles " $d/Makefile" ;;
2355 echo "AC_OUTPUT([$makefiles])"
2356 ) > "$testdir/configure.ac"
2358 # Create autogenerated files.
2360 echo "executing ${AUTORECONF} --force --install"
2361 ${AUTORECONF} --force --install
2363 if grep '^BUILT_SOURCES *+=' "$testdir/$sourcebase/Makefile.am" > /dev/null; then
2367 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
2375 # func_create_megatestdir megatestdir allmodules
2377 # - local_gnulib_dir from --local-dir
2378 # - auxdir directory relative to destdir where to place build aux files
2379 func_create_megatestdir ()
2383 if test -z "$allmodules"; then
2384 allmodules=`func_all_modules`
2388 # First, all modules one by one.
2389 for onemodule in $allmodules; do
2390 func_create_testdir "$megatestdir/$onemodule" $onemodule
2391 func_append megasubdirs "$onemodule "
2393 # Then, all modules all together.
2394 # Except config-h, which breaks all modules which use HAVE_CONFIG_H.
2395 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2396 allmodules=`for m in $allmodules; do if test $m != config-h && test $m != fnmatch-posix; then echo $m; fi; done`
2397 func_create_testdir "$megatestdir/ALL" "$allmodules"
2398 func_append megasubdirs "ALL"
2400 # Create Makefile.am.
2401 (echo "## Process this file with automake to produce Makefile.in."
2403 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2405 echo "SUBDIRS = $megasubdirs"
2406 ) > "$megatestdir/Makefile.am"
2408 # Create configure.ac.
2409 (echo "# Process this file with autoconf to produce a configure script."
2410 echo "AC_INIT([dummy], [0])"
2411 if test "$auxdir" != "."; then
2412 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2414 echo "AM_INIT_AUTOMAKE"
2416 echo "AC_PROG_MAKE_SET"
2418 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
2419 echo "AC_OUTPUT([Makefile])"
2420 ) > "$megatestdir/configure.ac"
2422 # Create autogenerated files.
2424 # Do not use "${AUTORECONF} --install", because autoreconf operates
2425 # recursively, but the subdirectories are already finished, therefore
2426 # calling autoreconf here would only waste lots of CPU time.
2427 echo "executing ${ACLOCAL}"
2429 echo "executing mkdir build-aux"
2431 echo "executing ${AUTOCONF}"
2433 echo "executing ${AUTOMAKE} --add-missing --copy"
2434 ${AUTOMAKE} --add-missing --copy
2440 func_fatal_error "no mode specified" ;;
2449 if test -z "$destdir"; then
2452 test -d "$destdir" \
2453 || func_fatal_error "destination directory does not exist: $destdir"
2455 # Prefer configure.ac to configure.in.
2456 if test -f "$destdir"/configure.ac; then
2457 configure_ac="$destdir/configure.ac"
2459 if test -f "$destdir"/configure.in; then
2460 configure_ac="$destdir/configure.in"
2462 func_fatal_error "cannot find $destdir/configure.ac"
2466 # Analyze configure.ac.
2468 guessed_libtool=false
2473 /AC_CONFIG_AUX_DIR/ {
2474 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
2476 /A[CM]_PROG_LIBTOOL/ {
2477 s,^.*$,guessed_libtool=true,p
2479 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
2481 if test -z "$auxdir"; then
2482 auxdir="$guessed_auxdir"
2485 # Determine where to apply func_import.
2486 if test -n "$m4base"; then
2487 # Apply func_import to a particular gnulib directory.
2488 # Any number of additional modules can be given.
2489 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
2490 # First use of gnulib in the given m4base.
2491 test -n "$supplied_libname" || supplied_libname=true
2492 test -n "$sourcebase" || sourcebase="lib"
2493 test -n "$docbase" || docbase="doc"
2494 test -n "$testsbase" || testsbase="tests"
2495 test -n "$macro_prefix" || macro_prefix="gl"
2499 # Apply func_import to all gnulib directories.
2500 # To get this list of directories, look at Makefile.am. (Not at
2501 # configure, because it may be omitted from CVS. Also, don't run
2502 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
2505 if test -f "$destdir"/Makefile.am; then
2506 aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$destdir"/Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'`
2508 for arg in $aclocal_amflags; do
2509 if test -n "$m4dir_is_next"; then
2510 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
2514 if test -f "$destdir/$arg"/gnulib-cache.m4; then
2515 func_append m4dirs " $arg"
2516 m4dirs_count=`expr $m4dirs_count + 1`
2521 if test "X$arg" = "X-I"; then
2529 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
2530 if test -f "$destdir"/aclocal.m4; then
2531 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
2532 sedexpr2='s,^[^/]*$,.,'
2533 sedexpr3='s,/[^/]*$,,'
2534 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
2535 m4dirs_count=`echo "$m4dirs" | wc -l`
2538 if test $m4dirs_count = 0; then
2539 # First use of gnulib in a package.
2540 # Any number of additional modules can be given.
2541 test -n "$supplied_libname" || supplied_libname=true
2542 test -n "$sourcebase" || sourcebase="lib"
2544 test -n "$docbase" || docbase="doc"
2545 test -n "$testsbase" || testsbase="tests"
2546 test -n "$macro_prefix" || macro_prefix="gl"
2549 if test $m4dirs_count = 1; then
2550 # There's only one use of gnulib here. Assume the user means it.
2551 # Any number of additional modules can be given.
2552 for m4base in $m4dirs; do
2556 # Ambiguous - guess what the user meant.
2557 if test $# = 0; then
2558 # No further arguments. Guess the user wants to update all of them.
2559 for m4base in $m4dirs; do
2560 # Perform func_import in a subshell, so that variable values
2562 # local_gnulib_dir, avoidlist, sourcebase, m4base, docbase,
2563 # testsbase, libname, lgpl, makefile_name, libtool, macro_prefix
2564 # don't propagate from one directory to another.
2565 (func_import) || func_exit 1
2569 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
2577 if test -z "$destdir"; then
2578 func_fatal_error "please specify --dir option"
2581 test -d "$destdir" \
2582 || func_fatal_error "could not create destination directory"
2583 test -n "$auxdir" || auxdir="build-aux"
2584 func_create_testdir "$destdir" "$*"
2587 create-megatestdir )
2588 if test -z "$destdir"; then
2589 func_fatal_error "please specify --dir option"
2591 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2592 test -n "$auxdir" || auxdir="build-aux"
2593 func_create_megatestdir "$destdir" "$*"
2597 test -n "$destdir" || destdir=testdir$$
2598 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2599 test -n "$auxdir" || auxdir="build-aux"
2600 func_create_testdir "$destdir" "$*"
2608 remaining=`find . -type f -print`
2609 if test -n "$remaining"; then
2610 echo "Remaining files:" $remaining 1>&2
2611 echo "gnulib-tool: *** Stop." 1>&2
2620 test -n "$destdir" || destdir=testdir$$
2621 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2622 test -n "$auxdir" || auxdir="build-aux"
2623 func_create_megatestdir "$destdir" "$*"
2631 remaining=`find . -type f -print`
2632 if test -n "$remaining"; then
2633 echo "Remaining files:" $remaining 1>&2
2634 echo "gnulib-tool: *** Stop." 1>&2
2642 extract-description )
2646 if test -n "$module"; then
2647 func_get_description "$module"
2656 if test -n "$module"; then
2657 func_get_filelist "$module"
2662 extract-dependencies )
2666 if test -n "$module"; then
2667 func_get_dependencies "$module"
2672 extract-autoconf-snippet )
2676 if test -n "$module"; then
2677 func_get_autoconf_snippet "$module"
2682 extract-automake-snippet )
2686 if test -n "$module"; then
2687 func_get_automake_snippet "$module"
2692 extract-include-directive )
2696 if test -n "$module"; then
2697 func_get_include_directive "$module"
2706 if test -n "$module"; then
2707 func_get_license "$module"
2712 extract-maintainer )
2716 if test -n "$module"; then
2717 func_get_maintainer "$module"
2722 extract-tests-module )
2726 if test -n "$module"; then
2727 func_get_tests_module "$module"
2733 func_fatal_error "unknown operation mode --$mode" ;;
2737 # Undo the effect of the previous 'trap' command. Some shellology:
2738 # We cannot use "trap - 0 1 2 3 13 15", because Solaris sh would attempt to
2739 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
2740 # exit); for the others we need to call 'exit' explicitly. The value of $? is
2741 # 128 + signal number and is set before the trap-registered command is run.
2743 trap 'func_exit $?' 1 2 3 13 15
2748 # indent-tabs-mode: nil
2749 # whitespace-check-buffer-indent: nil