Wed Sep 4 11:36:06 1996 Tom Tromey <tromey@creche.cygnus.com>
+ * automake.in (handle_source_transform): .deps no longer in
+ srcdir.
+ (handle_lib_objects): Ditto.
+ (handle_dist_worker): Pass --build-dir to automake.
+ ($build_directory): New global.
+ (parse_arguments): Handle --build-dir.
+ (initialize_global_constants): Include --build-dir in help.
+ (scan_dependency_file): New sub.
+ (handle_dependencies): Use it. Also, use $build_directory.
+ (initialize_global_constants): Added --srcdir-name.
+ (parse_arguments): Ditto.
+ (handle_dist_worker): Ditto.
+ ($srcdir_name): New global.
+ ($srcdir_rx): New global.
+ (parse_arguments): Set it.
+
+ * depend2.am: Removed all mention of $(srcdir).
+
+ * depend.am (MKDEP): Use gcc -M, not gcc -MM.
+ Removed all mention of $(srcdir); dependencies now put into build
+ dir.
+
+ * depend2.am ($(srcdir)/.deps/%.P): Fixed computation of `top'.
+ Don't do work silently.
+
* automake.in (handle_merge_targets): Error if invalid uninstall
targets are given.
+ (read_am_file): Fix for test block.test.
Tue Sep 3 18:50:32 1996 Tom Tromey <tromey@creche.cygnus.com>
* Random files listed in AC_OUTPUT now removed by "make clean"
* Will compute _DEPENDENCIES variables automatically if not supplied
* Will interpolate $(...) and ${...} when examining contents of a variable
+* .deps files now in build directory, not source directory; dependency
+ handling generally rewritten
\f
New in 1.0:
* Bug fixes
document variable scanning: $() and ${} interpolation
+document --build-dir
================================================================
# Relative location of top build directory.
$top_builddir = '';
+# Absolute location of top build directory.
+$build_directory = '';
+
+# Name of srcdir as given in build directory's Makefile. For
+# dependencies only.
+$srcdir_name = '';
+
+# Regular expression derived from srcdir_name.
+$srcdir_rx = '';
+
# List of Makefile.am's to process.
@input_files = ();
shift (@arglist);
$am_dir = $arglist[0];
}
+ elsif ($arglist[0] =~ /^--build-dir=(.+)$/)
+ {
+ # Must end in /.
+ $build_directory = $1 . '/';
+ }
+ elsif ($arglist[0] eq '--build-dir')
+ {
+ &require_argument (@arglist);
+ shift (@arglist);
+ # Must end in /.
+ $build_directory = $arglist[0] . '/';
+ }
+ elsif ($arglist[0] =~ /^--srcdir-name=(.+)$/)
+ {
+ $srcdir_name = $1;
+ ($srcdir_rx = $srcdir_name) =~ s/(\W)/\\$1/g;
+ }
+ elsif ($arglist[0] eq '--srcdir-name')
+ {
+ &require_argument (@arglist);
+ shift (@arglist);
+ $srcdir_name = $arglist[0];
+ ($srcdir_rx = $srcdir_name) =~ s/(\W)/\\$1/g;
+ }
elsif ($arglist[0] =~ /^--strictness=(.+)$/)
{
&set_strictness ($1);
# Transform .o or $o file into .P file (for automatic
# dependency code).
s/$objpat$/.P/g;
- $dep_files{'$(srcdir)/.deps/' . $_} = 1;
+ $dep_files{'.deps/' . $_} = 1;
}
&pretty_print ($one_file . "_OBJECTS =", "", @result)
if ($iter ne 'alloca.c')
{
($rewrite = $iter) =~ s/\.c$/.P/;
- $dep_files{'$(srcdir)/.deps/' . $rewrite} = 1;
+ $dep_files{'.deps/' . $rewrite} = 1;
&require_file_with_line ($var, $FOREIGN, $iter);
}
}
&am_line_error ($var,
"\@ALLOCA\@ seen but \`AC_FUNC_ALLOCA' not in \`configure.in'")
if ! defined $libsources{'alloca.c'};
- $dep_files{'$(srcdir)/.deps/alloca.P'} = 1;
+ $dep_files{'.deps/alloca.P'} = 1;
&require_file_with_line ($var, $FOREIGN, 'alloca.c');
}
}
(
# We need an absolute path for --output-dir. Thus the
# weirdness.
- ' distdir=`cd $(distdir) && pwd` \\
+ ' here=`pwd`; distdir=`cd $(distdir) && pwd` \\
&& cd $(srcdir) \\
- && automake --include-deps --output-dir=$$distdir --strictness='
+ && automake --include-deps --build-dir=$$here --srcdir-name=$(srcdir) --output-dir=$$distdir --strictness='
# Set strictness of output.
. $strictness_name . "\n"
);
&handle_dist_worker;
}
+# Scan a single dependency file and rewrite the dependencies as
+# appropriate. Essentially this means:
+# * Clean out absolute dependencies which are not desirable.
+# * Rewrite other dependencies to be relative to $(top_srcdir).
+sub scan_dependency_file
+{
+ local ($depfile) = @_;
+
+ if (! open (DEP_FILE, $depfile))
+ {
+ &am_error ("couldn't open \`$depfile': $!");
+ return;
+ }
+ print "automake: reading $depfile\n" if $verbose;
+
+ local ($first_line) = 1;
+ local ($target, @dependencies);
+ local ($one_dep, $xform);
+
+ while (<DEP_FILE>)
+ {
+ next if (/$WHITE_PATTERN/o);
+ chop;
+ s/\\$//;
+
+ if ($first_line)
+ {
+ if (! /([^:]+):(.+)$/)
+ {
+ &am_error ("\`$depfile' has incorrect format");
+ close (DEP_FILE);
+ return;
+ }
+
+ $target = $1;
+ $_ = $2;
+
+ $first_line = 0;
+ }
+
+ foreach $one_dep (split (' ', $_))
+ {
+ if ($one_dep =~ /^$srcdir_rx\//o)
+ {
+ ($xform = $one_dep) =~ s/^$srcdir_rx/\$(top_srcdir)/o;
+ push (@dependencies, $xform);
+ }
+ elsif ($one_dep =~ /^\//)
+ {
+ # Absolute path; ignore.
+ }
+ else
+ {
+ # Anything else is assumed to be correct.
+ push (@dependencies, $one_dep);
+ }
+ }
+ }
+
+ &pretty_print_rule ($target, "\t", @dependencies);
+
+ close (DEP_FILE);
+}
+
# Handle auto-dependency code.
sub handle_dependencies
{
}
else
{
- # Include any auto-generated deps that are present.
- if (-d ($relative_dir . "/.deps") && -f ($relative_dir . "/.deps/.P"))
+ # FIXME consider requiring --build-dir here. What about case
+ # where this is done via an option?
+
+ # Include any auto-generated deps that are present. Note that
+ # $build_directory ends in a "/".
+ if (-d ($build_directory . $relative_dir . "/.deps")
+ && -f ($build_directory . $relative_dir . "/.deps/.P"))
{
local ($depfile);
- local ($gpat) = $relative_dir . "/.deps/*.P";
+ local ($gpat) = $build_directory . $relative_dir . "/.deps/*.P";
foreach $depfile (<${gpat}>)
{
- if (! open (DEP_FILE, $depfile))
- {
- &am_error ("couldn't open \`$depfile': $!");
- next;
- }
- print "automake: reading $depfile\n" if $verbose;
-
- # Slurp entire file.
- $output_rules .= join ('', <DEP_FILE>);
-
- close (DEP_FILE);
+ &scan_dependency_file ($depfile);
}
$output_rules .= "\n";
elsif (/$COMMENT_PATTERN/o)
{
# Stick comments before the incoming macro or rule. Make
- # sure a blank line preceeds comments.
+ # sure a blank line preceeds first block of comments.
$spacing = "\n" unless $blank;
+ $blank = 1;
$comment .= $spacing . $_;
$spacing = '';
}
$USAGE = "\
--amdir=DIR directory storing config files
+ --build-dir=DIR directory where build being done (for dependencies)
--foreign same as --strictness=foreign
--gnits same as --strictness=gnits
--gnu same as --strictness=gnu
put generated Makefile.in's into DIR
-s LEVEL, --strictness=LEVEL
set strictness level. LEVEL is foreign, gnu, gnits
+ --srcdir-name=DIR name used for srcdir (for dependencies)
-v, --verbose verbosely list files processed
--version print version number, then exit\n";
## on GNU make and gcc. It is only included in the generated
## Makefile.in if `automake' is not passed the `--include-deps' flag.
-MKDEP = gcc -MM $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
+MKDEP = gcc -M $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
## We use ".P" as the name of our placeholder because it can't be
## duplicated by any C source file. (Well, there could be ".c", but
## no one does that in practice)
--include $(srcdir)/.deps/.P
-$(srcdir)/.deps/.P: $(BUILT_SOURCES)
- cd $(srcdir) && test -d .deps || mkdir .deps
+-include .deps/.P
+.deps/.P: $(BUILT_SOURCES)
+ test -d .deps || mkdir .deps
## Use ":" here and not "echo timestamp". Otherwise GNU Make barfs:
## .deps/.P:1: *** missing separator. Stop.
## Actually, use a plain "echo" and not ":". Why? From the Autoconf
echo > $@
-include $(DEP_FILES)
-$(DEP_FILES): $(srcdir)/.deps/.P
+$(DEP_FILES): .deps/.P
mostlyclean-depend:
distclean-depend:
maintainer-clean-depend:
- rm -rf $(srcdir)/.deps
+ rm -rf .deps
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
## 02111-1307, USA.
-$(srcdir)/.deps/%.P: $(srcdir)/%@EXT@
- @echo "mkdeps $< > $@"
-## Use funny regexp because otherwise too much can be matched when
-## srcdir begins with ".". Can't use \< since sed doesn't recognize
-## "." as a word start. Regexp-quote srcdir because "." is a matching
-## operator which commonly appears in filenames. Need "//*" in
-## regexps because otherwise the regexp will fail when srcdir=. and
-## the path to the file is relative (eg ../lib/error.c matches "./*").
- @top=`echo $(srcdir) | sed 's,^$(top_srcdir),,;s,[^/],,g;s,/,../,g'` ; \
- re=`echo "s,^$(srcdir)//*,,g;s, $(srcdir)//*, ,g;s,$(top_srcdir)//*,$$top,g" | sed 's,\.,\\\\.,g'`; \
- $(@MKDEP@) $< | sed "$$re" > $@-tmp
- @if test -n "$o"; then \
+.deps/%.P: $(srcdir)/%@EXT@
+ $(@MKDEP@) $< > $@-tmp
+## FIXME shouldn't do this for languages other than C.
+ if test -n "$o"; then \
sed 's/\.o:/$$o:/' $@-tmp > $@; \
rm $@-tmp; \
else \
## on GNU make and gcc. It is only included in the generated
## Makefile.in if `automake' is not passed the `--include-deps' flag.
-MKDEP = gcc -MM $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
+MKDEP = gcc -M $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
## We use ".P" as the name of our placeholder because it can't be
## duplicated by any C source file. (Well, there could be ".c", but
## no one does that in practice)
--include $(srcdir)/.deps/.P
-$(srcdir)/.deps/.P: $(BUILT_SOURCES)
- cd $(srcdir) && test -d .deps || mkdir .deps
+-include .deps/.P
+.deps/.P: $(BUILT_SOURCES)
+ test -d .deps || mkdir .deps
## Use ":" here and not "echo timestamp". Otherwise GNU Make barfs:
## .deps/.P:1: *** missing separator. Stop.
## Actually, use a plain "echo" and not ":". Why? From the Autoconf
echo > $@
-include $(DEP_FILES)
-$(DEP_FILES): $(srcdir)/.deps/.P
+$(DEP_FILES): .deps/.P
mostlyclean-depend:
distclean-depend:
maintainer-clean-depend:
- rm -rf $(srcdir)/.deps
+ rm -rf .deps
## along with this program; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
## 02111-1307, USA.
-$(srcdir)/.deps/%.P: $(srcdir)/%@EXT@
- @echo "mkdeps $< > $@"
-## Use funny regexp because otherwise too much can be matched when
-## srcdir begins with ".". Can't use \< since sed doesn't recognize
-## "." as a word start. Regexp-quote srcdir because "." is a matching
-## operator which commonly appears in filenames. Need "//*" in
-## regexps because otherwise the regexp will fail when srcdir=. and
-## the path to the file is relative (eg ../lib/error.c matches "./*").
- @top=`echo $(srcdir) | sed 's,^$(top_srcdir),,;s,[^/],,g;s,/,../,g'` ; \
- re=`echo "s,^$(srcdir)//*,,g;s, $(srcdir)//*, ,g;s,$(top_srcdir)//*,$$top,g" | sed 's,\.,\\\\.,g'`; \
- $(@MKDEP@) $< | sed "$$re" > $@-tmp
- @if test -n "$o"; then \
+.deps/%.P: $(srcdir)/%@EXT@
+ $(@MKDEP@) $< > $@-tmp
+## FIXME shouldn't do this for languages other than C.
+ if test -n "$o"; then \
sed 's/\.o:/$$o:/' $@-tmp > $@; \
rm $@-tmp; \
else \
#! /bin/sh
# Make sure block comments are not double-spaced.
+# Report from François Pinard.
. $srcdir/defs || exit 1