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-18 13:07:37 $'
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,/.*$,,'`
160 echo "$progname (GNU $package) $version"
161 echo "Copyright (C) $year Free Software Foundation, Inc.
162 This is free software; see the source for copying conditions. There is NO
163 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
164 echo "Written by" "Bruno Haible" "and" "Simon Josefsson"
167 # func_emit_copyright_notice
168 # outputs to stdout a header for a generated file.
169 func_emit_copyright_notice ()
171 echo "# Copyright (C) 2004-2006 Free Software Foundation, Inc."
173 echo "# This file is free software, distributed under the terms of the GNU"
174 echo "# General Public License. As a special exception to the GNU General"
175 echo "# Public License, this file may be distributed as part of a program"
176 echo "# that contains a configuration script generated by Autoconf, under"
177 echo "# the same distribution terms as the rest of that program."
179 echo "# Generated by gnulib-tool."
183 # creates a temporary directory.
185 # - tmp pathname of freshly created temporary directory
188 # Use the environment variable TMPDIR, falling back to /tmp. This allows
189 # users to specify a different temporary directory, for example, if their
190 # /tmp is filled up or too small.
193 # Use the mktemp program if available. If not available, hide the error
195 tmp=`(umask 077 && mktemp -d "$TMPDIR/glXXXXXX") 2>/dev/null` &&
196 test -n "$tmp" && test -d "$tmp"
199 # Use a simple mkdir command. It is guaranteed to fail if the directory
200 # already exists. $RANDOM is bash specific and expands to empty in shells
201 # other than bash, ksh and zsh. Its use does not increase security;
202 # rather, it minimizes the probability of failure in a very cluttered /tmp
204 tmp=$TMPDIR/gl$$-$RANDOM
205 (umask 077 && mkdir "$tmp")
208 echo "$0: cannot create a temporary directory in $TMPDIR" >&2
209 { (exit 1); exit 1; }
213 # func_append var value
214 # appends the given value to the shell variable var.
215 if ( foo=bar; foo+=baz && test "$foo" = barbaz ) >/dev/null 2>&1; then
216 # Use bash's += operator. It reduces complexity of appending repeatedly to
217 # a single variable from O(n^2) to O(n).
225 eval "$1=\"\$$1\$2\""
229 # func_fatal_error message
230 # outputs to stderr a fatal error message, and terminates the program.
233 echo "gnulib-tool: *** $1" 1>&2
234 echo "gnulib-tool: *** Stop." 1>&2
238 # func_readlink SYMLINK
239 # outputs the target of the given symlink.
240 if (type -p readlink) > /dev/null 2>&1; then
243 # Use the readlink program from GNU coreutils.
249 # Use two sed invocations. A single sed -n -e 's,^.* -> \(.*\)$,\1,p'
250 # would do the wrong thing if the link target contains " -> ".
251 LC_ALL=C ls -l "$1" | sed -e 's, -> ,#%%#,' | sed -n -e 's,^.*#%%#\(.*\)$,\1,p'
255 # func_ln_if_changed SRC DEST
256 # Like ln -s, but avoids munging timestamps if the link is correct.
257 func_ln_if_changed ()
259 if test $# -ne 2; then
260 echo "usage: func_ln_if_changed SRC DEST" >&2
262 if test -L "$2" && test "$1" = "`func_readlink "$2"`"; then
270 # func_relativize DIR1 DIR2
271 # computes a relative pathname RELDIR such that DIR1/RELDIR = DIR2.
273 # - DIR1 relative pathname, relative to the current directory
274 # - DIR2 relative pathname, relative to the current directory
276 # - reldir relative pathname of DIR2, relative to DIR1
282 sed_first='s,^\([^/]*\)/.*$,\1,'
283 sed_rest='s,^[^/]*/*,,'
284 sed_last='s,^.*/\([^/]*\)$,\1,'
285 sed_butlast='s,/*[^/]*$,,'
286 while test -n "$dir1"; do
287 first=`echo "$dir1" | sed -e "$sed_first"`
288 if test "$first" != "."; then
289 if test "$first" = ".."; then
290 dir2=`echo "$dir0" | sed -e "$sed_last"`/"$dir2"
291 dir0=`echo "$dir0" | sed -e "$sed_butlast"`
293 first2=`echo "$dir2" | sed -e "$sed_first"`
294 if test "$first2" = "$first"; then
295 dir2=`echo "$dir2" | sed -e "$sed_rest"`
299 dir0="$dir0"/"$first"
302 dir1=`echo "$dir1" | sed -e "$sed_rest"`
307 # func_relconcat DIR1 DIR2
308 # computes a relative pathname DIR1/DIR2, with obvious simplifications.
310 # - DIR1 relative pathname, relative to the current directory
311 # - DIR2 relative pathname, relative to DIR1
313 # - relconcat DIR1/DIR2, relative to the current directory
318 sed_first='s,^\([^/]*\)/.*$,\1,'
319 sed_rest='s,^[^/]*/*,,'
320 sed_last='s,^.*/\([^/]*\)$,\1,'
321 sed_butlast='s,/*[^/]*$,,'
323 first=`echo "$dir2" | sed -e "$sed_first"`
324 if test "$first" = "."; then
325 dir2=`echo "$dir2" | sed -e "$sed_rest"`
326 if test -z "$dir2"; then
331 last=`echo "$dir1" | sed -e "$sed_last"`
332 while test "$last" = "."; do
333 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
334 last=`echo "$dir1" | sed -e "$sed_last"`
336 if test -z "$dir1"; then
340 if test "$first" = ".."; then
341 if test "$last" = ".."; then
342 relconcat="$dir1/$dir2"
345 dir1=`echo "$dir1" | sed -e "$sed_butlast"`
346 dir2=`echo "$dir2" | sed -e "$sed_rest"`
347 if test -z "$dir1"; then
351 if test -z "$dir2"; then
356 relconcat="$dir1/$dir2"
363 # Command-line option processing.
364 # Removes the OPTIONS from the arguments. Sets the variables:
365 # - mode list or import or create-testdir or create-megatestdir
366 # - destdir from --dir
367 # - local_gnulib_dir from --local-dir
368 # - libname, supplied_libname from --lib
369 # - sourcebase from --source-base
370 # - m4base from --m4-base
371 # - docbase from --doc-base
372 # - testsbase from --tests-base
373 # - auxdir from --aux-dir
374 # - inctests true if --with-tests was given, blank otherwise
375 # - avoidlist list of modules to avoid, from --avoid
376 # - lgpl true if --lgpl was given, blank otherwise
377 # - makefile_name from --makefile-name
378 # - libtool true if --libtool was given, false if --no-libtool was
379 # given, blank otherwise
380 # - macro_prefix from --macro-prefix
381 # - autoconf_minversion minimum supported autoconf version
382 # - do_changelog false if --no-changelog was given, : otherwise
383 # - doit : if actions shall be executed, false if only to be printed
384 # - symbolic true if --symbolic was given, blank otherwise
408 while test $# -gt 0; do
413 --import | --impor | --impo | --imp | --im | --i )
416 --update | --updat | --upda | --upd | --up | --u )
419 --create-testdir | --create-testdi | --create-testd | --create-test | --create-tes | --create-te | --create-t )
422 --create-megatestdir | --create-megatestdi | --create-megatestd | --create-megatest | --create-megates | --create-megate | --create-megat | --create-mega | --create-meg | --create-me | --create-m )
423 mode=create-megatestdir
425 --test | --tes | --te | --t )
428 --megatest | --megates | --megate | --megat | --mega | --meg | --me | --m )
432 mode=`echo "X$1" | sed -e 's/^X--//'`
437 func_fatal_error "missing argument for --dir"
442 destdir=`echo "X$1" | sed -e 's/^X--dir=//'`
447 func_fatal_error "missing argument for --local-dir"
452 local_gnulib_dir=`echo "X$1" | sed -e 's/^X--local-dir=//'`
457 func_fatal_error "missing argument for --lib"
460 supplied_libname=true
463 libname=`echo "X$1" | sed -e 's/^X--lib=//'`
464 supplied_libname=true
469 func_fatal_error "missing argument for --source-base"
474 sourcebase=`echo "X$1" | sed -e 's/^X--source-base=//'`
479 func_fatal_error "missing argument for --m4-base"
484 m4base=`echo "X$1" | sed -e 's/^X--m4-base=//'`
489 func_fatal_error "missing argument for --doc-base"
494 docbase=`echo "X$1" | sed -e 's/^X--doc-base=//'`
499 func_fatal_error "missing argument for --tests-base"
504 testsbase=`echo "X$1" | sed -e 's/^X--tests-base=//'`
509 func_fatal_error "missing argument for --aux-dir"
514 auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
522 func_fatal_error "missing argument for --avoid"
524 func_append avoidlist " $1"
527 arg=`echo "X$1" | sed -e 's/^X--avoid=//'`
536 func_fatal_error "missing argument for --makefile-name"
541 makefile_name=`echo "X$1" | sed -e 's/^X--makefile-name=//'`
552 func_fatal_error "missing argument for --macro-prefix"
557 macro_prefix=`echo "X$1" | sed -e 's/^X--macro-prefix=//'`
559 --no-changelog | --no-changelo | --no-changel | --no-change | --no-chang | --no-chan | --no-cha | --no-ch | --no-c )
565 -s | --symbolic | --symboli | --symbol | --symbo | --symb | --symlink | --symlin | --symli | --syml | --sym | --sy )
568 --help | --hel | --he | --h )
571 --version | --versio | --versi | --vers | --ver | --ve | --v )
575 # Stop option processing
579 echo "gnulib-tool: unknown option $1" 1>&2
580 echo "Try 'gnulib-tool --help' for more information." 1>&2
587 if test "$mode" = update; then
588 if test $# != 0; then
589 echo "gnulib-tool: too many arguments in 'update' mode" 1>&2
590 echo "Try 'gnulib-tool --help' for more information." 1>&2
591 echo "If you really want to modify the gnulib configuration of your project," 1>&2
592 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
595 if test -n "$local_gnulib_dir" || test -n "$supplied_libname" \
596 || test -n "$sourcebase" || test -n "$m4base" \
597 || test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
598 || test -n "$inctests" || test -n "$avoidlist" || test -n "$lgpl" \
599 || test -n "$makefile_name" || test -n "$macro_prefix"; then
600 echo "gnulib-tool: invalid options for 'update' mode" 1>&2
601 echo "Try 'gnulib-tool --help' for more information." 1>&2
602 echo "If you really want to modify the gnulib configuration of your project," 1>&2
603 echo "you need to use 'gnulib --import' - at your own risk!" 1>&2
609 # Determine the minimum supported autoconf version from the project's
611 DEFAULT_AUTOCONF_MINVERSION="2.59"
614 if { test "$mode" = import || test "$mode" = update; } && test -n "$destdir"; then
615 if test -f "$destdir"/configure.ac; then
616 configure_ac="$destdir/configure.ac"
618 if test -f "$destdir"/configure.in; then
619 configure_ac="$destdir/configure.in"
623 if test -f configure.ac; then
624 configure_ac="configure.ac"
626 if test -f configure.in; then
627 configure_ac="configure.in"
631 if test -n "$configure_ac"; then
632 # Use sed, not autoconf --trace, to look for the AC_PREREQ invocation,
633 # because when some m4 files are omitted from a CVS repository,
634 # "autoconf --trace=AC_PREREQ" fails with an error message like this:
635 # m4: aclocal.m4:851: Cannot open m4/absolute-header.m4: No such file or directory
636 # autom4te: m4 failed with exit status: 1
643 s,^.*AC_PREREQ([[ ]*\([^])]*\).*$,prereqs="$prereqs \1",p
645 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
646 if test -n "$prereqs"; then
647 autoconf_minversion=`for version in $prereqs; do echo $version; done | $SORT -g -u | tail -1`
650 if test -z "$autoconf_minversion"; then
651 autoconf_minversion=$DEFAULT_AUTOCONF_MINVERSION
653 case "$autoconf_minversion" in
654 1.* | 2.[0-4]* | 2.5[0-8]*)
655 func_fatal_error "minimum supported autoconf version is 2.59. Try adding AC_PREREQ([$DEFAULT_AUTOCONF_MINVERSION]) to your configure.ac." ;;
658 # Remove trailing slashes from the directory names. This is necessary for
659 # m4base (to avoid an error in func_import) and optional for the others.
660 sed_trimtrailingslashes='s,\([^/]\)//*$,\1,'
661 case "$local_gnulib_dir" in
662 */ ) sourcebase=`echo "$local_gnulib_dir" | sed -e "$sed_trimtrailingslashes"` ;;
664 case "$sourcebase" in
665 */ ) sourcebase=`echo "$sourcebase" | sed -e "$sed_trimtrailingslashes"` ;;
668 */ ) m4base=`echo "$m4base" | sed -e "$sed_trimtrailingslashes"` ;;
671 */ ) docbase=`echo "$docbase" | sed -e "$sed_trimtrailingslashes"` ;;
674 */ ) testsbase=`echo "$testsbase" | sed -e "$sed_trimtrailingslashes"` ;;
677 */ ) auxdir=`echo "$auxdir" | sed -e "$sed_trimtrailingslashes"` ;;
682 /*) self_abspathname="$0" ;;
683 */*) self_abspathname=`pwd`/"$0" ;;
684 *) for d in `echo ":$PATH:" | sed -e 's/:::*/:.:/g' | sed -e 's/:/ /g'`; do
685 if test -x "$d/$0" && test ! -d "$d/$0"; then
686 self_abspathname="$d/$0"
690 if test -z "$self_abspathname"; then
691 func_fatal_error "could not locate the gnulib-tool program - how did you invoke it?"
695 while test -h "$self_abspathname"; do
696 # Resolve symbolic link.
697 linkval=`func_readlink "$self_abspathname"`
698 test -n "$linkval" || break
700 /* ) self_abspathname="$linkval" ;;
701 * ) self_abspathname=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`/"$linkval" ;;
704 gnulib_dir=`echo "$self_abspathname" | sed -e 's,/[^/]*$,,'`
707 trap 'rm -rf "$tmp"' 0 1 2 3 15
709 # func_lookup_file file
710 # looks up a file in $local_gnulib_dir or $gnulib_dir, or combines it through
713 # - local_gnulib_dir from --local-dir
715 # - lookedup_file name of the merged (combined) file
716 # - lookedup_tmp true if it is located in the tmp directory, blank otherwise
720 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile"; then
721 lookedup_file="$local_gnulib_dir/$lkfile"
724 if test -f "$gnulib_dir/$lkfile"; then
725 if test -n "$local_gnulib_dir" && test -f "$local_gnulib_dir/$lkfile.diff"; then
726 lkbase=`echo "$lkfile" | sed -e 's,^.*/,,'`
728 cp "$gnulib_dir/$lkfile" "$tmp/$lkbase"
729 patch -s "$tmp/$lkbase" < "$local_gnulib_dir/$lkfile.diff" \
730 || func_fatal_error "patch file $local_gnulib_dir/$lkfile.diff didn't apply cleanly"
731 lookedup_file="$tmp/$lkbase"
734 lookedup_file="$gnulib_dir/$lkfile"
738 func_fatal_error "file $gnulib_dir/$lkfile not found"
745 # - local_gnulib_dir from --local-dir
748 # Filter out metainformation files like README, which are not modules.
749 # Filter out unit test modules; they can be retrieved through
750 # --extract-tests-module if desired.
752 (cd "$gnulib_dir/modules" && ls -1)
753 if test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules"; then
754 (cd "$local_gnulib_dir/modules" && ls -1 | sed -e 's,\.diff$,,')
757 | sed -e '/^CVS$/d' -e '/^ChangeLog$/d' -e '/^COPYING$/d' -e '/^README$/d' -e '/^TEMPLATE$/d' -e '/^TEMPLATE-TESTS$/d' -e '/~$/d' \
758 | sed -e '/-tests$/d' \
763 # verifies a module name
765 # - local_gnulib_dir from --local-dir
766 # - module module name argument
767 func_verify_module ()
769 if { test -f "$gnulib_dir/modules/$module" \
770 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
771 && test -f "$local_gnulib_dir/modules/$module"; }; } \
772 && test "CVS" != "$module" \
773 && test "ChangeLog" != "$module" \
774 && test "COPYING" != "$module" \
775 && test "README" != "$module" \
776 && test "TEMPLATE" != "$module" \
777 && test "TEMPLATE-TESTS" != "$module"; then
778 # OK, $module is a correct module name.
779 # Verify that building the module description with 'patch' succeeds.
780 func_lookup_file "modules/$module"
782 echo "gnulib-tool: module $module doesn't exist" 1>&2
787 # func_verify_nontests_module
788 # verifies a module name, excluding tests modules
790 # - local_gnulib_dir from --local-dir
791 # - module module name argument
792 func_verify_nontests_module ()
796 * ) func_verify_module ;;
800 # func_verify_tests_module
801 # verifies a module name, considering only tests modules
803 # - local_gnulib_dir from --local-dir
804 # - module module name argument
805 func_verify_tests_module ()
808 *-tests ) func_verify_module ;;
813 sed_extract_prog=':[ ]*$/ {
816 s/^Description:[ ]*$//
818 s/^Depends-on:[ ]*$//
819 s/^configure\.ac:[ ]*$//
820 s/^Makefile\.am:[ ]*$//
823 s/^Maintainer:[ ]*$//
830 # func_get_description module
832 # - local_gnulib_dir from --local-dir
833 func_get_description ()
835 func_lookup_file "modules/$1"
836 sed -n -e "/^Description$sed_extract_prog" < "$lookedup_file"
839 # func_get_filelist module
841 # - local_gnulib_dir from --local-dir
844 func_lookup_file "modules/$1"
845 sed -n -e "/^Files$sed_extract_prog" < "$lookedup_file"
846 case "$autoconf_minversion" in
849 echo m4/onceonly_2_57.m4
854 # func_get_dependencies module
856 # - local_gnulib_dir from --local-dir
857 func_get_dependencies ()
859 # ${module}-tests always implicitly depends on ${module}.
860 echo "$1" | sed -n -e 's/-tests//p'
861 # Then the explicit dependencies listed in the module description.
862 func_lookup_file "modules/$1"
863 sed -n -e "/^Depends-on$sed_extract_prog" < "$lookedup_file"
866 # func_get_autoconf_snippet module
868 # - local_gnulib_dir from --local-dir
869 func_get_autoconf_snippet ()
871 func_lookup_file "modules/$1"
872 sed -n -e "/^configure\.ac$sed_extract_prog" < "$lookedup_file"
875 # func_get_automake_snippet module
877 # - local_gnulib_dir from --local-dir
878 func_get_automake_snippet ()
880 func_lookup_file "modules/$1"
881 sed -n -e "/^Makefile\.am$sed_extract_prog" < "$lookedup_file"
884 # func_get_include_directive module
886 # - local_gnulib_dir from --local-dir
887 func_get_include_directive ()
889 func_lookup_file "modules/$1"
890 sed -n -e "/^Include$sed_extract_prog" < "$lookedup_file" | \
891 sed -e 's/^\(["<]\)/#include \1/'
894 # func_get_license module
896 # - local_gnulib_dir from --local-dir
899 func_lookup_file "modules/$1"
900 sed -n -e "/^License$sed_extract_prog" < "$lookedup_file"
903 # func_get_maintainer module
905 # - local_gnulib_dir from --local-dir
906 func_get_maintainer ()
908 func_lookup_file "modules/$1"
909 sed -n -e "/^Maintainer$sed_extract_prog" < "$lookedup_file"
912 # func_get_tests_module module
914 # - local_gnulib_dir from --local-dir
915 func_get_tests_module ()
917 # The naming convention for tests modules is hardwired: ${module}-tests.
918 if test -f "$gnulib_dir/modules/$1"-tests \
919 || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
920 && test -f "$local_gnulib_dir/modules/$1"-tests; }; then
925 # func_acceptable module
926 # tests whether a module is acceptable.
928 # - avoidlist list of modules to avoid
931 for avoid in $avoidlist; do
932 if test "$avoid" = "$1"; then
939 # func_modules_transitive_closure
941 # - local_gnulib_dir from --local-dir
942 # - modules list of specified modules
943 # - inctests true if tests should be included, blank otherwise
944 # - avoidlist list of modules to avoid
945 # - tmp pathname of a temporary directory
947 # - modules list of modules, including dependencies
948 func_modules_transitive_closure ()
950 # In order to process every module only once (for speed), process an "input
951 # list" of modules, producing an "output list" of modules. During each round,
952 # more modules can be queued in the input list. Once a module on the input
953 # list has been processed, it is added to the "handled list", so we can avoid
954 # to process it again.
958 while test -n "$inmodules"; do
959 inmodules_this_round="$inmodules"
960 inmodules= # Accumulator, queue for next round
961 for module in $inmodules_this_round; do
963 if test -n "$module"; then
964 if func_acceptable $module; then
965 func_append outmodules " $module"
966 deps=`func_get_dependencies $module`
967 # Duplicate dependencies are harmless, but Jim wants a warning.
968 duplicated_deps=`echo "$deps" | LC_ALL=C sort | LC_ALL=C uniq -d`
969 if test -n "$duplicated_deps"; then
970 echo "warning: module $module has duplicated dependencies: "`echo $duplicated_deps` 1>&2
972 func_append inmodules " $deps"
973 if test -n "$inctests"; then
974 testsmodule=`func_get_tests_module $module`
975 if test -n "$testsmodule"; then
976 func_append inmodules " $testsmodule"
982 handledmodules=`for m in $handledmodules $inmodules_this_round; do echo $m; done | LC_ALL=C sort -u`
983 # Remove $handledmodules from $inmodules.
984 for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules
985 inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules`
987 modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u`
988 rm -f "$tmp"/queued-modules
991 # func_modules_add_dummy
993 # - local_gnulib_dir from --local-dir
994 # - modules list of modules, including dependencies
996 # - modules list of modules, including 'dummy' if needed
997 func_modules_add_dummy ()
1000 sed_remove_backslash_newline=':a
1007 for module in $modules; do
1008 func_verify_nontests_module
1009 if test -n "$module"; then
1010 # Extract the value of "lib_SOURCES += ...".
1011 for file in `func_get_automake_snippet "$module" | sed -e "$sed_remove_backslash_newline" | sed -n -e 's,^lib_SOURCES[ ]*+=\([^#]*\).*$,\1,p'`; do
1012 # Ignore .h files since they are not compiled.
1015 *) have_lib_SOURCES=yes ;;
1020 # Add the dummy module, to make sure the library will be non-empty.
1021 if test -z "$have_lib_SOURCES"; then
1022 func_append modules " dummy"
1026 # func_modules_to_filelist
1028 # - local_gnulib_dir from --local-dir
1029 # - modules list of modules, including dependencies
1031 # - files list of files
1032 func_modules_to_filelist ()
1035 for module in $modules; do
1037 if test -n "$module"; then
1038 fs=`func_get_filelist $module`
1039 func_append files " $fs"
1042 files=`for f in $files; do echo $f; done | LC_ALL=C sort -u`
1045 # func_emit_lib_Makefile_am
1046 # emits the contents of library makefile to standard output.
1048 # - local_gnulib_dir from --local-dir
1049 # - modules list of modules, including dependencies
1050 # - libname library name
1051 # - makefile_name from --makefile-name
1052 # - libtool true if libtool will be used, false or blank otherwise
1053 # - actioncmd (optional) command that will reproduce this invocation
1054 func_emit_lib_Makefile_am ()
1056 # When creating an includable Makefile.am snippet, augment variables with
1057 # += instead of assigning them.
1058 if test -n "$makefile_name"; then
1063 if test "$libtool" = true; then
1066 sed_eliminate_LDFLAGS=
1070 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1072 echo "## Process this file with automake to produce Makefile.in."
1073 func_emit_copyright_notice
1074 if test -n "$actioncmd"; then
1075 echo "# Reproduce by: $actioncmd"
1078 if test -z "$makefile_name"; then
1079 # No need to generate dependencies since the sources are in gnulib, not here.
1080 echo "AUTOMAKE_OPTIONS = 1.5 gnits no-dependencies"
1084 for module in $modules; do
1085 func_verify_nontests_module
1086 if test -n "$module"; then
1088 func_get_automake_snippet "$module" |
1089 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1090 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1091 sed -e "$sed_eliminate_LDFLAGS" |
1092 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1093 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1094 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
1095 if test "$module" = 'alloca'; then
1096 echo "${libname}_${libext}_LIBADD += @${perhapsLT}ALLOCA@"
1099 # Skip the contents if its entirely empty.
1100 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1101 echo "## begin gnulib module $module"
1104 echo "## end gnulib module $module"
1111 if grep "^[a-zA-Z0-9_]*_${perhapsLT}LIBRARIES *= *$libname\\.$libext\$" allsnippets.tmp > /dev/null; then
1112 # One of the snippets already specifies an installation location for the
1113 # library. Don't confuse automake by saying it should not be installed.
1116 # By default, the generated library should not be installed.
1117 echo "noinst_${perhapsLT}LIBRARIES $assign $libname.$libext"
1120 echo "${libname}_${libext}_SOURCES ="
1121 # Here we use $(LIBOBJS), not @LIBOBJS@. The value is the same. However,
1122 # automake during its analyses looks for $(LIBOBJS), not for @LIBOBJS@.
1123 echo "${libname}_${libext}_LIBADD = \$(${perhapsLT}LIBOBJS)"
1124 if test "$libtool" = true; then
1125 echo "${libname}_${libext}_LDFLAGS = \$(AM_LDFLAGS)"
1127 if test -z "$makefile_name"; then
1128 echo "noinst_HEADERS ="
1129 # Automake versions < 1.9b create an empty pkgdatadir at installation time
1130 # if you specify pkgdata_DATA to empty. This is a workaround.
1131 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1132 echo "pkgdata_DATA ="
1135 echo "BUILT_SOURCES ="
1138 echo "MOSTLYCLEANFILES $assign core *.stackdump"
1139 if test -z "$makefile_name"; then
1140 echo "MOSTLYCLEANDIRS ="
1142 echo "DISTCLEANFILES ="
1143 echo "MAINTAINERCLEANFILES ="
1145 echo "AM_CPPFLAGS ="
1150 echo "mostlyclean-local: mostlyclean-generic"
1151 echo " @test -z \"\$(MOSTLYCLEANDIRS)\" || \\"
1152 echo " for dir in \$(MOSTLYCLEANDIRS); do \\"
1153 echo " if test -d \$\$dir; then \\"
1154 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1157 rm -f allsnippets.tmp
1160 # func_emit_tests_Makefile_am
1161 # emits the contents of tests makefile to standard output.
1163 # - local_gnulib_dir from --local-dir
1164 # - modules list of modules, including dependencies
1165 # - libname library name
1166 # - makefile_name from --makefile-name
1167 # - libtool true if libtool will be used, false or blank otherwise
1168 # - sourcebase relative directory containing lib source code
1169 # - m4base relative directory containing autoconf macros
1170 # - testsbase relative directory containing unit test code
1171 func_emit_tests_Makefile_am ()
1173 if test "$libtool" = true; then
1178 if test "$libtool" = true; then
1180 sed_eliminate_LDFLAGS=
1183 sed_eliminate_LDFLAGS='/^lib_LDFLAGS[ ]*+=/d'
1185 testsbase_inverse=`echo "$testsbase" | sed -e 's,/$,,' | sed -e 's,[^/][^/]*,..,g'`
1186 echo "## Process this file with automake to produce Makefile.in."
1187 func_emit_copyright_notice
1189 # Generate dependencies here, since it eases the debugging of test failures.
1190 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
1192 echo "ACLOCAL_AMFLAGS = -I ${testsbase_inverse}/${m4base}"
1195 for module in $modules; do
1196 func_verify_tests_module
1197 if test -n "$module"; then
1199 func_get_automake_snippet "$module" |
1200 sed -e 's,lib_LIBRARIES,lib%_LIBRARIES,g' \
1201 -e 's,lib_LTLIBRARIES,lib%_LTLIBRARIES,g' |
1202 sed -e "$sed_eliminate_LDFLAGS" |
1203 sed -e 's,lib_\([A-Z][A-Z]*\),'"${libname}_${libext}"'_\1,g' |
1204 sed -e 's,lib%_LIBRARIES,lib_LIBRARIES,g' \
1205 -e 's,lib%_LTLIBRARIES,lib_LTLIBRARIES,g'
1207 # Skip the contents if its entirely empty.
1208 if grep '[^ ]' amsnippet.tmp > /dev/null ; then
1209 echo "## begin gnulib module $module"
1212 echo "## end gnulib module $module"
1219 # Nothing is being added to SUBDIRS; nevertheless the existence of this
1220 # variable is needed to avoid an error from automake:
1221 # "AM_GNU_GETTEXT used but SUBDIRS not defined"
1224 echo "TESTS_ENVIRONMENT ="
1225 echo "noinst_PROGRAMS ="
1226 echo "check_PROGRAMS ="
1227 echo "noinst_HEADERS ="
1228 if grep '^pkgdata_DATA *+=' allsnippets.tmp > /dev/null; then
1229 echo "pkgdata_DATA ="
1232 echo "BUILT_SOURCES ="
1234 echo "MOSTLYCLEANFILES = core *.stackdump"
1235 echo "MOSTLYCLEANDIRS ="
1237 echo "DISTCLEANFILES ="
1238 echo "MAINTAINERCLEANFILES ="
1240 echo "AM_CPPFLAGS = \\"
1241 echo " -I. -I\$(srcdir) \\"
1242 echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
1243 echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
1245 echo "LDADD = ${testsbase_inverse}/${sourcebase-lib}/${libname}.${libext}"
1248 echo "# Clean up after Solaris cc."
1250 echo " rm -rf SunWS_cache"
1252 echo "mostlyclean-local: mostlyclean-generic"
1253 echo " @test -z \"\$(MOSTLYCLEANDIRS)\" || \\"
1254 echo " for dir in \$(MOSTLYCLEANDIRS); do \\"
1255 echo " if test -d \$\$dir; then \\"
1256 echo " echo \"rmdir \$\$dir\"; rmdir \$\$dir; \\"
1259 rm -f allsnippets.tmp
1262 # func_import modules
1263 # Uses also the variables
1264 # - destdir target directory
1265 # - local_gnulib_dir from --local-dir
1266 # - libname library name
1267 # - sourcebase directory relative to destdir where to place source code
1268 # - m4base directory relative to destdir where to place *.m4 macros
1269 # - docbase directory relative to destdir where to place doc files
1270 # - testsbase directory relative to destdir where to place unit test code
1271 # - auxdir directory relative to destdir where to place build aux files
1272 # - inctests true if --with-tests was given, blank otherwise
1273 # - avoidlist list of modules to avoid, from --avoid
1274 # - lgpl true if library's license shall be LGPL, blank otherwise
1275 # - makefile_name from --makefile-name
1276 # - libtool true if --libtool was given, false if --no-libtool was
1277 # given, blank otherwise
1278 # - guessed_libtool true if the configure.ac file uses libtool, false otherwise
1279 # - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
1280 # - autoconf_minversion minimum supported autoconf version
1281 # - doit : if actions shall be executed, false if only to be printed
1282 # - symbolic true if files should be symlinked, copied otherwise
1285 # Get the cached settings.
1286 cached_local_gnulib_dir=
1287 cached_specified_modules=
1295 cached_makefile_name=
1297 cached_macro_prefix=
1299 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1300 cached_libtool=false
1306 s,^.*gl_LOCAL_DIR([[ ]*\([^])]*\).*$,cached_local_gnulib_dir="\1",p
1309 s,^.*gl_MODULES([[ ]*\([^])]*\).*$,cached_specified_modules="\1",p
1312 s,^.*gl_AVOID([[ ]*\([^])]*\).*$,cached_avoidlist="\1",p
1315 s,^.*gl_SOURCE_BASE([[ ]*\([^])]*\).*$,cached_sourcebase="\1",p
1318 s,^.*gl_M4_BASE([[ ]*\([^])]*\).*$,cached_m4base="\1",p
1321 s,^.*gl_DOC_BASE([[ ]*\([^])]*\).*$,cached_docbase="\1",p
1324 s,^.*gl_TESTS_BASE([[ ]*\([^])]*\).*$,cached_testsbase="\1",p
1327 s,^.*gl_LIB([[ ]*\([^])]*\).*$,cached_libname="\1",p
1330 s,^.*$,cached_lgpl=true,p
1332 /gl_MAKEFILE_NAME(/ {
1333 s,^.*gl_MAKEFILE_NAME([[ ]*\([^])]*\).*$,cached_makefile_name="\1",p
1336 s,^.*$,cached_libtool=true,p
1338 /gl_MACRO_PREFIX(/ {
1339 s,^.*gl_MACRO_PREFIX([[ ]*\([^])]*\).*$,cached_macro_prefix="\1",p
1341 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-cache.m4`
1342 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1347 /AC_DEFUN(\['"${cached_macro_prefix}"'_FILE_LIST\], \[/ {
1348 s,^.*$,cached_files=",p
1360 eval `sed -n -e "$my_sed_traces" < "$destdir"/$m4base/gnulib-comp.m4`
1364 # Merge the cached settings with the specified ones.
1365 # The m4base must be the same as expected from the pathname.
1366 if test -n "$cached_m4base" && test "$cached_m4base" != "$m4base"; then
1367 func_fatal_error "$m4base/gnulib-cache.m4 is expected to contain gl_M4_BASE([$m4base])"
1369 # The local_gnulib_dir defaults to the cached one. Recall that the cached one
1370 # is relative to $destdir, whereas the one we use is relative to . or absolute.
1371 if test -z "$local_gnulib_dir"; then
1372 if test -n "$cached_local_gnulib_dir"; then
1375 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1377 case "$cached_local_gnulib_dir" in
1379 local_gnulib_dir="$destdir/$cached_local_gnulib_dir" ;;
1381 func_relconcat "$destdir" "$cached_local_gnulib_dir"
1382 local_gnulib_dir="$relconcat" ;;
1387 # Append the cached and the specified module names. So that
1388 # "gnulib-tool --import foo" means to add the module foo.
1389 specified_modules="$cached_specified_modules $1"
1390 # Append the cached and the specified avoidlist. This is probably better
1391 # than dropping the cached one when --avoid is specified at least once.
1392 avoidlist=`echo $cached_avoidlist $avoidlist`
1393 # The sourcebase defaults to the cached one.
1394 if test -z "$sourcebase"; then
1395 sourcebase="$cached_sourcebase"
1396 if test -z "$sourcebase"; then
1397 func_fatal_error "missing --source-base option"
1400 # The docbase defaults to the cached one.
1401 if test -z "$docbase"; then
1402 docbase="$cached_docbase"
1403 if test -z "$docbase"; then
1404 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."
1407 # The testsbase defaults to the cached one.
1408 if test -z "$testsbase"; then
1409 testsbase="$cached_testsbase"
1410 if test -z "$testsbase"; then
1411 func_fatal_error "missing --tests-base option"
1414 # The libname defaults to the cached one.
1415 if test -z "$supplied_libname"; then
1416 libname="$cached_libname"
1417 if test -z "$libname"; then
1418 func_fatal_error "missing --lib option"
1421 # Require LGPL if specified either way.
1422 if test -z "$lgpl"; then
1425 # The makefile_name defaults to the cached one.
1426 if test -z "$makefile_name"; then
1427 makefile_name="$cached_makefile_name"
1429 # Use libtool if specified either way, or if guessed.
1430 if test -z "$libtool"; then
1431 if test -n "$cached_m4base"; then
1432 libtool="$cached_libtool"
1434 libtool="$guessed_libtool"
1437 # The macro_prefix defaults to the cached one.
1438 if test -z "$macro_prefix"; then
1439 macro_prefix="$cached_macro_prefix"
1440 if test -z "$macro_prefix"; then
1441 func_fatal_error "missing --macro-prefix option"
1445 # Canonicalize the list of specified modules.
1446 specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u`
1448 # Determine final module list.
1449 modules="$specified_modules"
1450 func_modules_transitive_closure
1451 echo "Module list with included dependencies:"
1452 echo "$modules" | sed -e 's/^/ /'
1454 # Add the dummy module if needed.
1455 func_modules_add_dummy
1457 # If --lgpl, verify that the licenses of modules are compatible.
1458 if test -n "$lgpl"; then
1459 for module in $modules; do
1460 license=`func_get_license $module`
1462 LGPL | 'GPLed build tool') ;;
1463 'public domain' | 'unlimited' | 'unmodifiable license text') ;;
1464 *) func_fatal_error "incompatible license on module $module: $license" ;;
1469 # Determine script to apply to imported library files.
1470 sed_transform_lib_file=
1471 for module in $modules; do
1472 if test $module = config-h; then
1473 # Assume config.h exists, and that -DHAVE_CONFIG_H is omitted.
1474 sed_transform_lib_file=$sed_transform_lib_file'
1475 s/^#ifdef[ ]*HAVE_CONFIG_H[ ]*$/#if 1/
1480 if test -n "$lgpl"; then
1482 sed_transform_lib_file=$sed_transform_lib_file'
1483 s/GNU General/GNU Lesser General/g
1484 s/version 2\([ ,]\)/version 2.1\1/g
1488 # Determine final file list.
1489 func_modules_to_filelist
1491 echo "$files" | sed -e 's/^/ /'
1494 || func_fatal_error "refusing to do nothing"
1496 # Add m4/gnulib-tool.m4 to the file list. It is not part of any module.
1497 new_files="$files m4/gnulib-tool.m4"
1498 old_files="$cached_files"
1499 if test -f "$destdir"/$m4base/gnulib-tool.m4; then
1500 func_append old_files " m4/gnulib-tool.m4"
1503 # Create directories.
1504 if test ! -d "$destdir/$sourcebase"; then
1506 echo "Creating directory $destdir/$sourcebase"
1507 mkdir "$destdir/$sourcebase" || func_fatal_error "failed"
1509 echo "Create directory $destdir/$sourcebase"
1512 if test ! -d "$destdir/$m4base"; then
1514 echo "Creating directory $destdir/$m4base"
1515 mkdir "$destdir/$m4base" || func_fatal_error "failed"
1517 echo "Create directory $destdir/$m4base"
1520 docfiles=`echo "$files" | sed -n -e 's,^doc/,,p'`
1521 if test -n "$docfiles"; then
1522 if test ! -d "$destdir/$docbase"; then
1524 echo "Creating directory $destdir/$docbase"
1525 mkdir "$destdir/$docbase" || func_fatal_error "failed"
1527 echo "Create directory $destdir/$docbase"
1531 if test -n "$inctests"; then
1532 if test ! -d "$destdir/$testsbase"; then
1534 echo "Creating directory $destdir/$testsbase"
1535 mkdir "$destdir/$testsbase" || func_fatal_error "failed"
1537 echo "Create directory $destdir/$testsbase"
1541 if test ! -d "$destdir/$auxdir"; then
1543 echo "Creating directory $destdir/$auxdir"
1544 mkdir "$destdir/$auxdir" || func_fatal_error "failed"
1546 echo "Create directory $destdir/$auxdir"
1550 # func_dest_tmpfilename file
1551 # determines the name of a temporary file (file is relative to destdir).
1553 # - tmpfile absolute filename of the temporary file
1554 func_dest_tmpfilename ()
1557 # Put the new contents of $file in a file in the same directory (needed
1558 # to guarantee that an 'mv' to "$destdir/$file" works).
1559 tmpfile="$destdir/$1.tmp"
1561 # Put the new contents of $file in a file in a temporary directory
1562 # (because the directory of "$file" might not exist).
1563 tmpfile="$tmp"/`basename "$1"`.tmp
1567 # Copy files or make symbolic links. Remove obsolete files.
1569 sed_rewrite_old_files="\
1570 s,^build-aux/,$auxdir/,
1571 s,^doc/,$cached_docbase/,
1572 s,^lib/,$cached_sourcebase/,
1573 s,^m4/,$cached_m4base/,
1574 s,^tests/,$cached_testsbase/,"
1575 sed_rewrite_new_files="\
1576 s,^build-aux/,$auxdir/,
1578 s,^lib/,$sourcebase/,
1580 s,^tests/,$testsbase/,"
1581 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1582 # representing the files according to the last gnulib-tool invocation.
1583 for f in $old_files; do echo $f; done \
1584 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_old_files" \
1587 # Construct a table with 2 columns: rewritten-file-name original-file-name,
1588 # representing the files after this gnulib-tool invocation.
1589 for f in $new_files; do echo $f; done \
1590 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" \
1593 # First the files that are in old-files, but not in new-files:
1594 sed_take_first_column='s,'"$delimiter"'.*,,'
1595 for g in `LC_ALL=C join -t"$delimiter" -v1 "$tmp"/old-files "$tmp"/new-files | sed -e "$sed_take_first_column"`; do
1596 # Remove the file. Do nothing if the user already removed it.
1597 if test -f "$destdir/$g"; then
1599 echo "Removing file $g (backup in ${g}~)"
1600 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1602 echo "Remove file $g (backup in ${g}~)"
1606 # func_add_or_update handles a file that ought to be present afterwards.
1608 # - f the original file name
1609 # - g the rewritten file name
1610 # - already_present nonempty if the file already exists, empty otherwise
1611 func_add_or_update ()
1613 func_dest_tmpfilename "$g"
1614 func_lookup_file "$f"
1615 cp "$lookedup_file" "$tmpfile" || func_fatal_error "failed"
1616 if test -n "$sed_transform_lib_file"; then
1619 sed -e "$sed_transform_lib_file" \
1620 < "$lookedup_file" > "$tmpfile" || func_fatal_error "failed"
1624 if test -f "$destdir/$g"; then
1625 # The file already exists.
1626 if cmp "$destdir/$g" "$tmpfile" > /dev/null; then
1627 : # The file has not changed.
1631 if test -n "$already_present"; then
1632 echo "Updating file $g (backup in ${g}~)"
1634 echo "Replacing file $g (non-gnulib code backuped in ${g}~) !!"
1636 mv -f "$destdir/$g" "$destdir/${g}~" || func_fatal_error "failed"
1637 if test -n "$symbolic" && test -z "$lookedup_tmp" \
1638 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1639 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1641 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1644 if test -n "$already_present"; then
1645 echo "Update file $g (backup in ${g}~)"
1647 echo "Replace file $g (non-gnulib code backuped in ${g}~) !!"
1653 # Don't protest if the file should be there but isn't: it happens
1654 # frequently that developers don't put autogenerated files into CVS.
1656 echo "Copying file $g"
1657 if test -n "$symbolic" && test -z "$lookedup_tmp" \
1658 && cmp "$lookedup_file" "$tmpfile" > /dev/null; then
1659 func_ln_if_changed "$lookedup_file" "$destdir/$g"
1661 mv -f "$tmpfile" "$destdir/${g}" || func_fatal_error "failed"
1669 # Then the files that are in new-files, but not in old-files:
1670 sed_take_last_column='s,^.*'"$delimiter"',,'
1672 LC_ALL=C join -t"$delimiter" -v2 "$tmp"/old-files "$tmp"/new-files \
1673 | sed -e "$sed_take_last_column" \
1674 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/added-files
1677 done < "$tmp"/added-files
1678 # Then the files that are in new-files and in old-files:
1679 already_present=true
1680 LC_ALL=C join -t"$delimiter" "$tmp"/old-files "$tmp"/new-files \
1681 | sed -e "$sed_take_last_column" \
1682 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_new_files" > "$tmp"/kept-files
1685 done < "$tmp"/kept-files
1687 # Command-line invocation printed in a comment in generated gnulib-cache.m4.
1688 actioncmd="gnulib-tool --import"
1689 func_append actioncmd " --dir=$destdir"
1690 if test -n "$local_gnulib_dir"; then
1691 func_append actioncmd " --local-dir=$local_gnulib_dir"
1693 func_append actioncmd " --lib=$libname"
1694 func_append actioncmd " --source-base=$sourcebase"
1695 func_append actioncmd " --m4-base=$m4base"
1696 func_append actioncmd " --doc-base=$docbase"
1697 func_append actioncmd " --aux-dir=$auxdir"
1698 for module in $avoidlist; do
1699 func_append actioncmd " --avoid=$module"
1701 if test -n "$lgpl"; then
1702 func_append actioncmd " --lgpl"
1704 if test -n "$makefile_name"; then
1705 func_append actioncmd " --makefile_name=$makefile_name"
1707 if test "$libtool" = true; then
1708 func_append actioncmd " --libtool"
1710 func_append actioncmd " --no-libtool"
1712 func_append actioncmd " --macro-prefix=$macro_prefix"
1713 func_append actioncmd " `echo $specified_modules`"
1715 # Default the makefile name to Makefile.am.
1716 if test -n "$makefile_name"; then
1717 makefile_am=$makefile_name
1719 makefile_am=Makefile.am
1722 # Create library makefile.
1723 func_dest_tmpfilename $sourcebase/$makefile_am
1724 func_emit_lib_Makefile_am > "$tmpfile"
1725 if test -f "$destdir"/$sourcebase/$makefile_am; then
1726 if cmp "$destdir"/$sourcebase/$makefile_am "$tmpfile" > /dev/null; then
1730 echo "Updating $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
1731 mv -f "$destdir"/$sourcebase/$makefile_am "$destdir"/$sourcebase/$makefile_am~
1732 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
1734 echo "Update $sourcebase/$makefile_am (backup in $sourcebase/$makefile_am~)"
1740 echo "Creating $sourcebase/$makefile_am"
1741 mv -f "$tmpfile" "$destdir"/$sourcebase/$makefile_am
1743 echo "Create $sourcebase/$makefile_am"
1748 # Create m4/gnulib-cache.m4.
1749 func_dest_tmpfilename $m4base/gnulib-cache.m4
1751 func_emit_copyright_notice
1753 echo "# This file represents the specification of how gnulib-tool is used."
1754 echo "# It acts as a cache: It is written and read by gnulib-tool."
1755 echo "# In projects using CVS, this file is meant to be stored in CVS,"
1756 echo "# like the configure.ac and various Makefile.am files."
1759 echo "# Specification in the form of a command-line invocation:"
1762 echo "# Specification in the form of a few gnulib-tool.m4 macro invocations:"
1763 # Store the local_gnulib_dir relative to destdir.
1764 case "$local_gnulib_dir" in
1766 relative_local_gnulib_dir="$local_gnulib_dir" ;;
1769 /*) relative_local_gnulib_dir="$local_gnulib_dir" ;;
1771 # destdir, local_gnulib_dir are both relative.
1772 func_relativize "$destdir" "$local_gnulib_dir"
1773 relative_local_gnulib_dir="$reldir" ;;
1776 echo "gl_LOCAL_DIR([$relative_local_gnulib_dir])"
1777 echo "gl_MODULES(["`echo $specified_modules`"])"
1778 echo "gl_AVOID([$avoidlist])"
1779 echo "gl_SOURCE_BASE([$sourcebase])"
1780 echo "gl_M4_BASE([$m4base])"
1781 echo "gl_DOC_BASE([$docbase])"
1782 echo "gl_TESTS_BASE([$testsbase])"
1783 echo "gl_LIB([$libname])"
1784 test -z "$lgpl" || echo "gl_LGPL"
1785 echo "gl_MAKEFILE_NAME([$makefile_name])"
1786 if test "$libtool" = true; then
1789 echo "gl_MACRO_PREFIX([$macro_prefix])"
1791 if test -f "$destdir"/$m4base/gnulib-cache.m4; then
1792 if cmp "$destdir"/$m4base/gnulib-cache.m4 "$tmpfile" > /dev/null; then
1796 echo "Updating $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1797 mv -f "$destdir"/$m4base/gnulib-cache.m4 "$destdir"/$m4base/gnulib-cache.m4~
1798 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
1800 echo "Update $m4base/gnulib-cache.m4 (backup in $m4base/gnulib-cache.m4~)"
1804 echo "# gnulib-cache.m4 ends here"
1811 echo "Creating $m4base/gnulib-cache.m4"
1812 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-cache.m4
1814 echo "Create $m4base/gnulib-cache.m4"
1820 # Create m4/gnulib-comp.m4.
1821 func_dest_tmpfilename $m4base/gnulib-comp.m4
1823 func_emit_copyright_notice
1825 echo "# This file represents the compiled summary of the specification in"
1826 echo "# gnulib-cache.m4. It lists the computed macro invocations that need"
1827 echo "# to be invoked from configure.ac."
1828 echo "# In projects using CVS, this file can be treated like other built files."
1831 echo "# This macro should be invoked from $configure_ac, in the section"
1832 echo "# \"Checks for programs\", right after AC_PROG_CC, and certainly before"
1833 echo "# any checks for libraries, header files, types and library functions."
1834 echo "AC_DEFUN([${macro_prefix}_EARLY],"
1836 echo " m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
1837 echo " m4_pattern_allow([^gl_ES$])dnl a valid locale name"
1838 echo " AC_REQUIRE([AC_PROG_RANLIB])"
1839 if grep AC_GNU_SOURCE "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1840 echo " AC_REQUIRE([AC_GNU_SOURCE])"
1842 if grep gl_USE_SYSTEM_EXTENSIONS "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1843 echo " AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])"
1845 if grep gl_LOCK "$destdir"/$m4base/*.m4 >/dev/null 2>/dev/null; then
1846 echo " AC_REQUIRE([gl_LOCK_EARLY])"
1850 echo "# This macro should be invoked from $configure_ac, in the section"
1851 echo "# \"Check for header files, types and library functions\"."
1852 echo "AC_DEFUN([${macro_prefix}_INIT],"
1854 if test "$libtool" = true; then
1855 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
1856 echo " gl_cond_libtool=true"
1858 echo " AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
1859 echo " gl_cond_libtool=false"
1861 echo " gl_ltlibdeps="
1863 if test "$auxdir" != "build-aux"; then
1864 sed_replace_build_aux='
1866 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
1867 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
1870 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
1872 sed_replace_build_aux=
1874 for module in $modules; do
1876 if test -n "$module"; then
1877 func_get_autoconf_snippet "$module" \
1878 | sed -e '/^$/d;' -e 's/^/ /' \
1879 -e 's/AM_GNU_GETTEXT(\[external\])/dnl you must add AM_GNU_GETTEXT([external]) or similar to configure.ac./' \
1880 -e "$sed_replace_build_aux"
1881 if test "$module" = 'alloca' && test "$libtool" = true; then
1882 echo 'changequote(,)dnl'
1883 echo 'LTALLOCA=`echo "$ALLOCA" | sed '"'"'s/\.[^.]* /.lo /g;s/\.[^.]*$/.lo/'"'"'`'
1884 echo 'changequote([, ])dnl'
1885 echo 'AC_SUBST([LTALLOCA])'
1889 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
1890 # created using libtool, because libtool already handles the dependencies.
1891 if test "$libtool" != true; then
1892 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
1893 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
1894 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
1895 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
1896 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
1900 echo "# This macro records the list of files which have been installed by"
1901 echo "# gnulib-tool and may be removed by future gnulib-tool invocations."
1902 echo "AC_DEFUN([${macro_prefix}_FILE_LIST], ["
1903 echo "$files" | sed -e 's,^, ,'
1906 if test -f "$destdir"/$m4base/gnulib-comp.m4; then
1907 if cmp "$destdir"/$m4base/gnulib-comp.m4 "$tmpfile" > /dev/null; then
1911 echo "Updating $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1912 mv -f "$destdir"/$m4base/gnulib-comp.m4 "$destdir"/$m4base/gnulib-comp.m4~
1913 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
1915 echo "Update $m4base/gnulib-comp.m4 (backup in $m4base/gnulib-comp.m4~)"
1919 echo "# gnulib-comp.m4 ends here"
1926 echo "Creating $m4base/gnulib-comp.m4"
1927 mv -f "$tmpfile" "$destdir"/$m4base/gnulib-comp.m4
1929 echo "Create $m4base/gnulib-comp.m4"
1935 if test -n "$inctests"; then
1936 # Create tests makefile.
1937 func_dest_tmpfilename $testsbase/$makefile_am
1938 func_emit_tests_Makefile_am > "$tmpfile"
1939 if test -f "$destdir"/$testsbase/$makefile_am; then
1940 if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
1944 echo "Updating $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
1945 mv -f "$destdir"/$testsbase/$makefile_am "$destdir"/$testsbase/$makefile_am~
1946 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
1948 echo "Update $testsbase/$makefile_am (backup in $testsbase/$makefile_am~)"
1954 echo "Creating $testsbase/$makefile_am"
1955 mv -f "$tmpfile" "$destdir"/$testsbase/$makefile_am
1957 echo "Create $testsbase/$makefile_am"
1965 echo "You may need to add #include directives for the following .h files."
1966 # First the #include <...> directives without #ifs, sorted for convenience,
1967 # then the #include "..." directives without #ifs, sorted for convenience,
1968 # then the #include directives that are surrounded by #ifs. Not sorted.
1969 for module in $modules; do
1970 include_directive=`func_get_include_directive "$module"`
1971 case "$nl$include_directive" in
1973 echo "$include_directive" 1>&5
1976 echo "$include_directive" | grep -v 'include "' 1>&6
1977 echo "$include_directive" | grep 'include "' 1>&7
1980 done 5> "$tmp"/include-if 6> "$tmp"/include-angles 7> "$tmp"/include-quotes
1982 LC_ALL=C sort -u "$tmp"/include-angles
1983 LC_ALL=C sort -u "$tmp"/include-quotes
1984 cat "$tmp"/include-if
1985 ) | sed -e '/^$/d' -e 's/^/ /'
1986 rm -f "$tmp"/include-angles "$tmp"/include-quotes "$tmp"/include-if
1989 echo "Don't forget to"
1990 if test "$makefile_am" = Makefile.am; then
1991 echo " - add \"$sourcebase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1993 echo " - \"include $makefile_name\" from within \"$sourcebase/Makefile.am\","
1995 if test -n "$inctests"; then
1996 if test "$makefile_am" = Makefile.am; then
1997 echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
1999 echo " - \"include $makefile_name\" from within \"$testsbase/Makefile.am\","
2002 if test "$makefile_am" = Makefile.am; then
2003 sourcebase_dir=`echo "$sourcebase" | sed -n -e 's,/[^/]*$,/,p'`
2004 sourcebase_base=`basename "$sourcebase"`
2005 echo " - mention \"${sourcebase_base}\" in SUBDIRS in ${sourcebase_dir}Makefile.am,"
2007 if test -n "$inctests"; then
2008 if test "$makefile_am" = Makefile.am; then
2009 testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
2010 testsbase_base=`basename "$testsbase"`
2011 echo " - mention \"${testsbase_base}\" in SUBDIRS in ${testsbase_dir}Makefile.am,"
2014 echo " - mention \"-I ${m4base}\" in ACLOCAL_AMFLAGS in Makefile.am,"
2015 echo " - invoke ${macro_prefix}_EARLY in $configure_ac, right after AC_PROG_CC,"
2016 echo " - invoke ${macro_prefix}_INIT in $configure_ac."
2019 # func_create_testdir testdir modules
2021 # - local_gnulib_dir from --local-dir
2022 # - auxdir directory relative to destdir where to place build aux files
2023 func_create_testdir ()
2027 modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
2029 # Subdirectory names.
2035 # Determine final module list.
2036 func_modules_transitive_closure
2037 echo "Module list with included dependencies:"
2038 echo "$modules" | sed -e 's/^/ /'
2040 # Add the dummy module if needed.
2041 func_modules_add_dummy
2043 # Determine final file list.
2044 func_modules_to_filelist
2046 echo "$files" | sed -e 's/^/ /'
2048 # Create directories.
2049 for d in `echo "$files" | sed -n -e 's,^\(.*\)/[^/]*,\1,p'`; do
2051 build-aux) mkdir -p "$testdir/$auxdir" ;;
2052 doc) mkdir -p "$testdir/$docbase" ;;
2053 lib) mkdir -p "$testdir/$sourcebase" ;;
2054 m4) mkdir -p "$testdir/$m4base" ;;
2055 tests) mkdir -p "$testdir/$testsbase" ;;
2056 *) mkdir -p "$testdir/$d" ;;
2060 # Copy files or make symbolic links.
2062 sed_rewrite_files="\
2063 s,^build-aux/,$auxdir/,
2065 s,^lib/,$sourcebase/,
2067 s,^tests/,$testsbase/,"
2068 for f in $files; do echo $f; done \
2069 | sed -e "s,^.*\$,&$delimiter&," -e "$sed_rewrite_files" \
2073 func_lookup_file "$f"
2074 if test -n "$lookedup_tmp"; then
2075 cp -p "$lookedup_file" "$testdir/$g"
2077 ln "$lookedup_file" "$testdir/$g" 2>/dev/null ||
2078 if test -z "$symbolic"; then
2079 cp -p "$lookedup_file" "$testdir/$g"
2081 ln -s "$lookedup_file" "$testdir/$g"
2086 # Create $sourcebase/Makefile.am.
2087 mkdir -p "$testdir/$sourcebase"
2088 func_emit_lib_Makefile_am > "$testdir/$sourcebase/Makefile.am"
2090 # Create $m4base/Makefile.am.
2091 mkdir -p "$testdir/$m4base"
2092 (echo "## Process this file with automake to produce Makefile.in."
2098 echo "EXTRA_DIST += "`echo "$f" | sed -e 's,^m4/,,'` ;;
2101 ) > "$testdir/$m4base/Makefile.am"
2103 subdirs="$sourcebase $m4base"
2104 subdirs_with_configure_ac=""
2106 if test -f "$testdir"/$m4base/gettext.m4; then
2107 # Avoid stupid error message from automake:
2108 # "AM_GNU_GETTEXT used but `po' not in SUBDIRS"
2109 mkdir -p "$testdir/po"
2110 (echo "## Process this file with automake to produce Makefile.in."
2111 ) > "$testdir/po/Makefile.am"
2112 func_append subdirs " po"
2115 if test -n "$inctests"; then
2116 test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
2117 # Create $testsbase/Makefile.am.
2118 func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
2119 # Create $testsbase/configure.ac.
2120 (echo "# Process this file with autoconf to produce a configure script."
2121 echo "AC_INIT([dummy], [0])"
2122 echo "AC_CONFIG_AUX_DIR([../$auxdir])"
2123 echo "AM_INIT_AUTOMAKE"
2125 echo "AM_CONFIG_HEADER([config.h])"
2128 echo "AC_PROG_INSTALL"
2129 echo "AC_PROG_MAKE_SET"
2130 echo "AC_PROG_RANLIB"
2132 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2133 echo "AC_GNU_SOURCE"
2136 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2137 echo "gl_USE_SYSTEM_EXTENSIONS"
2140 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2141 echo "gl_LOCK_EARLY"
2144 if test "$libtool" = true; then
2145 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2146 echo "gl_cond_libtool=true"
2148 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2149 echo "gl_cond_libtool=false"
2151 echo "gl_ltlibdeps="
2153 # Wrap the set of autoconf snippets into an autoconf macro that is then
2154 # invoked. This is needed because autoconf does not support AC_REQUIRE
2156 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2157 # but we want the AC_REQUIRE to have its normal meaning (provide one
2158 # expansion of the required macro before the current point, and only one
2160 echo "AC_DEFUN([gl_INIT], ["
2161 if test "$auxdir" != "build-aux"; then
2162 sed_replace_build_aux='
2164 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2165 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:../'"$auxdir"'/\2)|
2168 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2170 sed_replace_build_aux=
2172 # We don't have explicit ordering constraints between the various
2173 # autoconf snippets. It's cleanest to put those of the library before
2174 # those of the tests.
2175 for module in $modules; do
2176 func_verify_nontests_module
2177 if test -n "$module"; then
2178 func_get_autoconf_snippet "$module" \
2179 | sed -e "$sed_replace_build_aux"
2182 for module in $modules; do
2183 func_verify_tests_module
2184 if test -n "$module"; then
2185 func_get_autoconf_snippet "$module" \
2186 | sed -e "$sed_replace_build_aux"
2189 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2190 # created using libtool, because libtool already handles the dependencies.
2191 if test "$libtool" != true; then
2192 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2193 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2194 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2195 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2196 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2201 # Usually $testsbase/config.h will be a superset of config.h. Verify this
2202 # by "merging" config.h into $testsbase/config.h; look out for gcc warnings.
2203 echo "AH_TOP([#include \"../config.h\"])"
2205 echo "AC_OUTPUT([Makefile])"
2206 ) > "$testdir/$testsbase/configure.ac"
2207 func_append subdirs " $testsbase"
2208 subdirs_with_configure_ac="$subdirs_with_configure_ac $testsbase"
2211 # Create Makefile.am.
2212 (echo "## Process this file with automake to produce Makefile.in."
2214 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2216 echo "SUBDIRS = $subdirs"
2218 echo "ACLOCAL_AMFLAGS = -I $m4base"
2219 ) > "$testdir/Makefile.am"
2221 # Create configure.ac.
2222 (echo "# Process this file with autoconf to produce a configure script."
2223 echo "AC_INIT([dummy], [0])"
2224 if test "$auxdir" != "."; then
2225 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2227 echo "AM_INIT_AUTOMAKE"
2229 echo "AM_CONFIG_HEADER([config.h])"
2232 echo "AC_PROG_INSTALL"
2233 echo "AC_PROG_MAKE_SET"
2235 echo "m4_pattern_forbid([^gl_[A-Z]])dnl the gnulib macro namespace"
2236 echo "m4_pattern_allow([^gl_ES$])dnl a valid locale name"
2238 echo "AC_PROG_RANLIB"
2240 if grep AC_GNU_SOURCE "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2241 echo "AC_GNU_SOURCE"
2244 if grep gl_USE_SYSTEM_EXTENSIONS "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2245 echo "gl_USE_SYSTEM_EXTENSIONS"
2248 if grep gl_LOCK "$testdir/$m4base"/*.m4 >/dev/null 2>/dev/null; then
2249 echo "gl_LOCK_EARLY"
2252 if test "$libtool" = true; then
2253 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [true])"
2254 echo "gl_cond_libtool=true"
2256 echo "AM_CONDITIONAL([GL_COND_LIBTOOL], [false])"
2257 echo "gl_cond_libtool=false"
2259 echo "gl_ltlibdeps="
2261 # Wrap the set of autoconf snippets into an autoconf macro that is then
2262 # invoked. This is needed because autoconf does not support AC_REQUIRE
2264 # error: AC_REQUIRE(gt_CSHARPCOMP): cannot be used outside of an AC_DEFUN'd macro
2265 # but we want the AC_REQUIRE to have its normal meaning (provide one
2266 # expansion of the required macro before the current point, and only one
2268 echo "AC_DEFUN([gl_INIT], ["
2269 if test "$auxdir" != "build-aux"; then
2270 sed_replace_build_aux='
2272 /AC_CONFIG_FILES(.*:build-aux\/.*)/{
2273 s|AC_CONFIG_FILES(\(.*\):build-aux/\(.*\))|AC_CONFIG_FILES(\1:'"$auxdir"'/\2)|
2276 sed_replace_build_aux=`echo "$sed_replace_build_aux" | sed -e 1d -e 's/^ *//'`
2278 sed_replace_build_aux=
2280 for module in $modules; do
2281 func_verify_nontests_module
2282 if test -n "$module"; then
2283 func_get_autoconf_snippet "$module" \
2284 | sed -e "$sed_replace_build_aux"
2287 # _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
2288 # created using libtool, because libtool already handles the dependencies.
2289 if test "$libtool" != true; then
2290 libname_upper=`echo "$libname" | tr 'a-z' 'A-Z'`
2291 echo " ${libname_upper}_LIBDEPS=\"\$gl_libdeps\""
2292 echo " AC_SUBST([${libname_upper}_LIBDEPS])"
2293 echo " ${libname_upper}_LTLIBDEPS=\"\$gl_ltlibdeps\""
2294 echo " AC_SUBST([${libname_upper}_LTLIBDEPS])"
2299 if test -n "$subdirs_with_configure_ac"; then
2300 echo "AC_CONFIG_SUBDIRS(["`echo $subdirs_with_configure_ac`"])"
2302 makefiles="Makefile"
2303 for d in $subdirs; do
2304 # For subdirs that have a configure.ac by their own, it's the subdir's
2305 # configure.ac which creates the subdir's Makefile.am, not this one.
2306 case " $subdirs_with_configure_ac " in
2308 *) func_append makefiles " $d/Makefile" ;;
2311 echo "AC_OUTPUT([$makefiles])"
2312 ) > "$testdir/configure.ac"
2314 # Create autogenerated files.
2316 echo "executing ${AUTORECONF} --force --install"
2317 ${AUTORECONF} --force --install
2319 if grep '^BUILT_SOURCES *+=' "$testdir/$sourcebase/Makefile.am" > /dev/null; then
2323 echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
2331 # func_create_megatestdir megatestdir allmodules
2333 # - local_gnulib_dir from --local-dir
2334 # - auxdir directory relative to destdir where to place build aux files
2335 func_create_megatestdir ()
2339 if test -z "$allmodules"; then
2340 allmodules=`func_all_modules`
2344 # First, all modules one by one.
2345 for onemodule in $allmodules; do
2346 func_create_testdir "$megatestdir/$onemodule" $onemodule
2347 func_append megasubdirs "$onemodule "
2349 # Then, all modules all together.
2350 # Except fnmatch-posix, which conflicts with fnmatch-gnu. FIXME.
2351 allmodules=`for m in $allmodules; do if test $m != fnmatch-posix; then echo $m; fi; done`
2352 func_create_testdir "$megatestdir/ALL" "$allmodules"
2353 func_append megasubdirs "ALL"
2355 # Create Makefile.am.
2356 (echo "## Process this file with automake to produce Makefile.in."
2358 echo "AUTOMAKE_OPTIONS = 1.5 foreign"
2360 echo "SUBDIRS = $megasubdirs"
2361 ) > "$megatestdir/Makefile.am"
2363 # Create configure.ac.
2364 (echo "# Process this file with autoconf to produce a configure script."
2365 echo "AC_INIT([dummy], [0])"
2366 if test "$auxdir" != "."; then
2367 echo "AC_CONFIG_AUX_DIR([$auxdir])"
2369 echo "AM_INIT_AUTOMAKE"
2371 echo "AC_PROG_MAKE_SET"
2373 echo "AC_CONFIG_SUBDIRS([$megasubdirs])"
2374 echo "AC_OUTPUT([Makefile])"
2375 ) > "$megatestdir/configure.ac"
2377 # Create autogenerated files.
2379 # Do not use "${AUTORECONF} --install", because autoreconf operates
2380 # recursively, but the subdirectories are already finished, therefore
2381 # calling autoreconf here would only waste lots of CPU time.
2382 echo "executing ${ACLOCAL}"
2384 echo "executing mkdir build-aux"
2386 echo "executing ${AUTOCONF}"
2388 echo "executing ${AUTOMAKE} --add-missing --copy"
2389 ${AUTOMAKE} --add-missing --copy
2395 func_fatal_error "no mode specified" ;;
2404 if test -z "$destdir"; then
2407 test -d "$destdir" \
2408 || func_fatal_error "destination directory does not exist: $destdir"
2410 # Prefer configure.ac to configure.in.
2411 if test -f "$destdir"/configure.ac; then
2412 configure_ac="$destdir/configure.ac"
2414 if test -f "$destdir"/configure.in; then
2415 configure_ac="$destdir/configure.in"
2417 func_fatal_error "cannot find $destdir/configure.ac"
2421 # Analyze configure.ac.
2423 guessed_libtool=false
2428 /AC_CONFIG_AUX_DIR/ {
2429 s,^.*AC_CONFIG_AUX_DIR([[ ]*\([^])]*\).*$,guessed_auxdir="\1",p
2431 /A[CM]_PROG_LIBTOOL/ {
2432 s,^.*$,guessed_libtool=true,p
2434 eval `sed -n -e "$my_sed_traces" < "$configure_ac"`
2436 if test -z "$auxdir"; then
2437 auxdir="$guessed_auxdir"
2440 # Determine where to apply func_import.
2441 if test -n "$m4base"; then
2442 # Apply func_import to a particular gnulib directory.
2443 # Any number of additional modules can be given.
2444 if test ! -f "$destdir/$m4base"/gnulib-cache.m4; then
2445 # First use of gnulib in the given m4base.
2446 test -n "$supplied_libname" || supplied_libname=true
2447 test -n "$sourcebase" || sourcebase="lib"
2448 test -n "$docbase" || docbase="doc"
2449 test -n "$testsbase" || testsbase="tests"
2450 test -n "$macro_prefix" || macro_prefix="gl"
2454 # Apply func_import to all gnulib directories.
2455 # To get this list of directories, look at Makefile.am. (Not at
2456 # configure, because it may be omitted from CVS. Also, don't run
2457 # "find $destdir -name gnulib-cache.m4", as it might be too expensive.)
2460 if test -f "$destdir"/Makefile.am; then
2461 aclocal_amflags=`grep '^ACLOCAL_AMFLAGS[ ]*=' "$destdir"/Makefile.am | sed -e 's/^ACLOCAL_AMFLAGS[ ]*=\(.*\)$/\1/'`
2463 for arg in $aclocal_amflags; do
2464 if test -n "$m4dir_is_next"; then
2465 # Ignore absolute directory pathnames, like /usr/local/share/aclocal.
2469 if test -f "$destdir/$arg"/gnulib-cache.m4; then
2470 func_append m4dirs " $arg"
2471 m4dirs_count=`expr $m4dirs_count + 1`
2476 if test "X$arg" = "X-I"; then
2484 # No Makefile.am! Oh well. Look at the last generated aclocal.m4.
2485 if test -f "$destdir"/aclocal.m4; then
2486 sedexpr1='s,^m4_include(\[\(.*\)])$,\1,p'
2487 sedexpr2='s,^[^/]*$,.,'
2488 sedexpr3='s,/[^/]*$,,'
2489 m4dirs=`sed -n -e "$sedexpr1" aclocal.m4 | sed -e "$sedexpr2" -e "$sedexpr3" | LC_ALL=C sort -u`
2490 m4dirs_count=`echo "$m4dirs" | wc -l`
2493 if test $m4dirs_count = 0; then
2494 # First use of gnulib in a package.
2495 # Any number of additional modules can be given.
2496 test -n "$supplied_libname" || supplied_libname=true
2497 test -n "$sourcebase" || sourcebase="lib"
2499 test -n "$docbase" || docbase="doc"
2500 test -n "$testsbase" || testsbase="tests"
2501 test -n "$macro_prefix" || macro_prefix="gl"
2504 if test $m4dirs_count = 1; then
2505 # There's only one use of gnulib here. Assume the user means it.
2506 # Any number of additional modules can be given.
2507 for m4base in $m4dirs; do
2511 # Ambiguous - guess what the user meant.
2512 if test $# = 0; then
2513 # No further arguments. Guess the user wants to update all of them.
2514 for m4base in $m4dirs; do
2515 # Perform func_import in a subshell, so that variable values
2517 # local_gnulib_dir, avoidlist, sourcebase, m4base, docbase,
2518 # testsbase, libname, lgpl, makefile_name, libtool, macro_prefix
2519 # don't propagate from one directory to another.
2520 (func_import) || exit 1
2524 func_fatal_error "Ambiguity: to which directory should the modules be added? Please specify at least --m4-base=..."
2532 if test -z "$destdir"; then
2533 func_fatal_error "please specify --dir option"
2536 test -d "$destdir" \
2537 || func_fatal_error "could not create destination directory"
2538 test -n "$auxdir" || auxdir="build-aux"
2539 func_create_testdir "$destdir" "$*"
2542 create-megatestdir )
2543 if test -z "$destdir"; then
2544 func_fatal_error "please specify --dir option"
2546 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2547 test -n "$auxdir" || auxdir="build-aux"
2548 func_create_megatestdir "$destdir" "$*"
2552 test -n "$destdir" || destdir=testdir$$
2553 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2554 test -n "$auxdir" || auxdir="build-aux"
2555 func_create_testdir "$destdir" "$*"
2563 remaining=`find . -type f -print`
2564 if test -n "$remaining"; then
2565 echo "Remaining files:" $remaining 1>&2
2566 echo "gnulib-tool: *** Stop." 1>&2
2575 test -n "$destdir" || destdir=testdir$$
2576 mkdir "$destdir" || func_fatal_error "could not create destination directory"
2577 test -n "$auxdir" || auxdir="build-aux"
2578 func_create_megatestdir "$destdir" "$*"
2586 remaining=`find . -type f -print`
2587 if test -n "$remaining"; then
2588 echo "Remaining files:" $remaining 1>&2
2589 echo "gnulib-tool: *** Stop." 1>&2
2597 extract-description )
2601 if test -n "$module"; then
2602 func_get_description "$module"
2611 if test -n "$module"; then
2612 func_get_filelist "$module"
2617 extract-dependencies )
2621 if test -n "$module"; then
2622 func_get_dependencies "$module"
2627 extract-autoconf-snippet )
2631 if test -n "$module"; then
2632 func_get_autoconf_snippet "$module"
2637 extract-automake-snippet )
2641 if test -n "$module"; then
2642 func_get_automake_snippet "$module"
2647 extract-include-directive )
2651 if test -n "$module"; then
2652 func_get_include_directive "$module"
2661 if test -n "$module"; then
2662 func_get_license "$module"
2667 extract-maintainer )
2671 if test -n "$module"; then
2672 func_get_maintainer "$module"
2677 extract-tests-module )
2681 if test -n "$module"; then
2682 func_get_tests_module "$module"
2688 func_fatal_error "unknown operation mode --$mode" ;;
2692 # Undo the effect of the previous 'trap' command. Some shellology:
2693 # We cannot use "trap - 0 1 2 3 15", because Solaris sh would attempt to
2694 # execute the command "-". "trap '' ..." is fine only for signal 0 (= normal
2695 # exit); for the others we need to call 'exit' explicitly. The value of $? is
2696 # 128 + signal number and is set before the trap-registered command is run.
2698 trap 'exit $?' 1 2 3 15
2703 # indent-tabs-mode: nil
2704 # whitespace-check-buffer-indent: nil