From 2eb14969258ff08b8bda74ab53cbe6b617086f55 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Fri, 13 Feb 1998 07:27:33 +0000 Subject: [PATCH] side-effect dependency tracking --- ChangeLog | 12 ++++++++++++ Makefile.in | 4 ++-- NEWS | 1 + automake.in | 22 ++++++++++++++-------- comp-vars.am | 2 +- compile.am | 4 ++-- depend.am | 21 --------------------- depend2.am | 20 ++++++++++++-------- lib/am/comp-vars.am | 2 +- lib/am/compile.am | 4 ++-- lib/am/depend.am | 21 --------------------- lib/am/depend2.am | 20 ++++++++++++-------- 12 files changed, 59 insertions(+), 74 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6e5ebc2e..b46c2904 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,17 @@ Thu Feb 12 22:27:05 1998 Tom Tromey + * automake.in (get_object_extension): Conditionally include .c.o + rule from compile.am. + (handle_dependencies): Generate correct code when including new + depend2.am. + (file_contents_with_transform): Better error reporting. + * depend.am (MKDEP): Removed. + (.deps/.P): Removed. Don't include .deps/.P. + * compile.am (.c.o): Now conditional on dependencies not being + generated by compiles. + * depend2.am (%.o): New rule. + (.deps/%.P): Removed. + * tags.am (TAGS): Uniquify list of files. From Harlan Stenn. * aclocal.in (scan_m4_files): Reverse-sort keys when constructing diff --git a/Makefile.in b/Makefile.in index c02a0111..1d42c66f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -362,8 +362,8 @@ TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP) done; \ list='$(SOURCES) $(HEADERS)'; \ unique=`for i in $$list; do echo $$i; done | \ - awk ' { files[$$i] = 1; } \ - END { for (i in files) print $$i; }'`; \ + awk ' { files[$$0] = 1; } \ + END { for (i in files) print i; }'`; \ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ || (cd $(srcdir) && etags $(ETAGS_ARGS) $$tags $$unique $(LISP) -o $$here/TAGS) diff --git a/NEWS b/NEWS index 662d7594..31a91b80 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,7 @@ New in 1.2d: * aclocal gives error if `AM_' macro not found * Passed YFLAGS, not YACCFLAGS, to yacc * AM_PROG_CC_STDC does not have to come before AC_PROG_CPP +* Dependencies computed as a side effect of compilation New in 1.2: * Bug fixes diff --git a/automake.in b/automake.in index 2f1b8d3a..16e2dcef 100755 --- a/automake.in +++ b/automake.in @@ -746,7 +746,11 @@ sub get_object_extension $xform = 's/\@CONFIG_INCLUDE_SPEC\@/' . $xform . '/go;'; $output_vars .= &file_contents_with_transform ($xform, 'comp-vars'); - $output_rules .= &file_contents ('compile'); + $output_rules .= + &file_contents_with_transform + ($use_dependencies ? 's/^NOTDEPEND.*$//;' : 's/^NOTDEPEND//;', + 'compile'); + &push_phony_cleaners ('compile'); # If using X, include some extra variable definitions. NOTE @@ -2761,19 +2765,21 @@ sub handle_dependencies $output_rules .= &file_contents ('depend'); push (@clean, 'depend'); &push_phony_cleaners ('depend'); + # FIXME: should use @EXT@ and @PFX@. I don't know why it + # didn't work. $output_rules .= - &file_contents_with_transform ('s/\@EXT\@/.c/g;' - . 's/\@MKDEP\@/MKDEP/g;' - . 's/^ONLYC//g;', + &file_contents_with_transform ('s/EXT/.c/g;' + . 's/PFX//g;', 'depend2'); local ($ext); local ($need_cxx) = 0; foreach $ext (sort keys %cxx_extensions) { + # FIXME: should use @EXT@ and @PFX@. I don't know why + # it didn't work. $output_rules .= - &file_contents_with_transform ('s/\@EXT\@/' . $ext .'/g;' - . 's/\@MKDEP\@/CXXMKDEP/g;' - . 's/^ONLYC.*$//;', + &file_contents_with_transform ('s/EXT/' . $ext .'/g;' + . 's/PFX/CXX/g;', 'depend2'); $need_cxx = 1; } @@ -5556,7 +5562,7 @@ sub file_contents_with_transform if ($command ne '' && substr ($command, -1) ne ';') { - die "automake: programming error in file_contents_with_transform\n"; + die "automake: programming error in file_contents_with_transform: $command\n"; } open (FC_FILE, $file) diff --git a/comp-vars.am b/comp-vars.am index 801b2351..c7d773bf 100644 --- a/comp-vars.am +++ b/comp-vars.am @@ -1,5 +1,5 @@ ## automake - create Makefile.in from Makefile.am -## Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. +## Copyright (C) 1994, 1995, 1996, 1998 Free Software Foundation, Inc. ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by diff --git a/compile.am b/compile.am index e673c94c..ece65594 100644 --- a/compile.am +++ b/compile.am @@ -15,8 +15,8 @@ ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. -.c.o: - $(COMPILE) -c $< +NOTDEPEND.c.o: +NOTDEPEND $(COMPILE) -c $< .s.o: $(COMPILE) -c $< diff --git a/depend.am b/depend.am index 3d19cb7a..4f20a473 100644 --- a/depend.am +++ b/depend.am @@ -20,31 +20,10 @@ ## on GNU make and gcc. It is only included in the generated ## Makefile.in if `automake' is not passed the `--include-deps' flag. -## We have to use $(CC), not `gcc', even though we do rely on gcc to -## do dependency tracking. We have to do this because `gcc' is not -## the real name of the compiler when cross-compiling. -MKDEP = $(CC) -M $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) - ## We must create the .deps directory if it doesn't exist. We do it ## in this strange way because of a buglet in make -- it won't try to ## create .deps/.P if the .deps directory doesn't exist. DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) -## 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 .deps/.P -## This depends on $(BUILT_SOURCES) because that lets us generate -## dependencies for files that don't exist at the start of a fresh -## build. -.deps/.P: $(BUILT_SOURCES) -## 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 -## manual, node Automatic Remaking: -## On some old BSD systems, `touch' or any command that results in an -## empty file does not update the timestamps, so use a command like -## `echo' as a workaround. - echo > $@ -include $(DEP_FILES) diff --git a/depend2.am b/depend2.am index 1eed7925..48cdd18e 100644 --- a/depend2.am +++ b/depend2.am @@ -1,5 +1,5 @@ ## automake - create Makefile.in from Makefile.am -## Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. +## Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -15,10 +15,14 @@ ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. -.deps/%.P: %@EXT@ - @echo "Computing dependencies for $<..." - @o='o'; \ -ONLYC test -n "$o" && o='$$o'; \ - $(@MKDEP@) $< >$@.tmp \ - && sed "s,^\(.*\)\.o:,\1.$$o \1.l$$o $@:," < $@.tmp > $@ \ - && rm -f $@.tmp +## FIXME: should use @EXT@, but that didn't work. +%.o: %EXT +## FIXME: should use @PFX@, but that didn't work. + @echo '$(PFXCOMPILE) -c $<'; \ + DEPENDENCIES_OUTPUT='.deps/$(*F).P'; \ + export DEPENDENCIES_OUTPUT; \ +## Note that using DEPENDENCIES_OUTPUT causes gcc to append to the +## named file. So we truncate it explicitly. + : > .deps/$(*F).P; \ +## FIXME: should use @PFX@, but that didn't work. + $(PFXCOMPILE) -c $< diff --git a/lib/am/comp-vars.am b/lib/am/comp-vars.am index 801b2351..c7d773bf 100644 --- a/lib/am/comp-vars.am +++ b/lib/am/comp-vars.am @@ -1,5 +1,5 @@ ## automake - create Makefile.in from Makefile.am -## Copyright (C) 1994, 1995, 1996 Free Software Foundation, Inc. +## Copyright (C) 1994, 1995, 1996, 1998 Free Software Foundation, Inc. ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by diff --git a/lib/am/compile.am b/lib/am/compile.am index e673c94c..ece65594 100644 --- a/lib/am/compile.am +++ b/lib/am/compile.am @@ -15,8 +15,8 @@ ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. -.c.o: - $(COMPILE) -c $< +NOTDEPEND.c.o: +NOTDEPEND $(COMPILE) -c $< .s.o: $(COMPILE) -c $< diff --git a/lib/am/depend.am b/lib/am/depend.am index 3d19cb7a..4f20a473 100644 --- a/lib/am/depend.am +++ b/lib/am/depend.am @@ -20,31 +20,10 @@ ## on GNU make and gcc. It is only included in the generated ## Makefile.in if `automake' is not passed the `--include-deps' flag. -## We have to use $(CC), not `gcc', even though we do rely on gcc to -## do dependency tracking. We have to do this because `gcc' is not -## the real name of the compiler when cross-compiling. -MKDEP = $(CC) -M $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) - ## We must create the .deps directory if it doesn't exist. We do it ## in this strange way because of a buglet in make -- it won't try to ## create .deps/.P if the .deps directory doesn't exist. DEPS_MAGIC := $(shell mkdir .deps > /dev/null 2>&1 || :) -## 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 .deps/.P -## This depends on $(BUILT_SOURCES) because that lets us generate -## dependencies for files that don't exist at the start of a fresh -## build. -.deps/.P: $(BUILT_SOURCES) -## 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 -## manual, node Automatic Remaking: -## On some old BSD systems, `touch' or any command that results in an -## empty file does not update the timestamps, so use a command like -## `echo' as a workaround. - echo > $@ -include $(DEP_FILES) diff --git a/lib/am/depend2.am b/lib/am/depend2.am index 1eed7925..48cdd18e 100644 --- a/lib/am/depend2.am +++ b/lib/am/depend2.am @@ -1,5 +1,5 @@ ## automake - create Makefile.in from Makefile.am -## Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc. +## Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc. ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by @@ -15,10 +15,14 @@ ## along with this program; if not, write to the Free Software ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ## 02111-1307, USA. -.deps/%.P: %@EXT@ - @echo "Computing dependencies for $<..." - @o='o'; \ -ONLYC test -n "$o" && o='$$o'; \ - $(@MKDEP@) $< >$@.tmp \ - && sed "s,^\(.*\)\.o:,\1.$$o \1.l$$o $@:," < $@.tmp > $@ \ - && rm -f $@.tmp +## FIXME: should use @EXT@, but that didn't work. +%.o: %EXT +## FIXME: should use @PFX@, but that didn't work. + @echo '$(PFXCOMPILE) -c $<'; \ + DEPENDENCIES_OUTPUT='.deps/$(*F).P'; \ + export DEPENDENCIES_OUTPUT; \ +## Note that using DEPENDENCIES_OUTPUT causes gcc to append to the +## named file. So we truncate it explicitly. + : > .deps/$(*F).P; \ +## FIXME: should use @PFX@, but that didn't work. + $(PFXCOMPILE) -c $< -- 2.43.5