This is the mail archive of the java-patches@sources.redhat.com mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Patch: Smart dependency tracking


This patch implements smart dependency tracking for libgcj.  With this
patch, touching a .java file will result in a minimal rebuild rather
than a full rebuild.

I will check this in after the corresponding gcj/gcc patch is
approved.

2000-10-18  Tom Tromey  <tromey@cygnus.com>

	* Makefile.in: Rebuilt.
	* Makefile.am: Include deps.mk.
	(GCJCOMPILE): Added -MD, -MT, and -MF.
	($(javao_files)): Don't depend on libgcj.zip.
	(all-recursive): New target.
	(%.lo:%.cc): Do dependency tracking.
	($(nat_headers)): Don't depend on libgcj.zip.
	* configure: Rebuilt.
	* configure.in: Make .d files and deps.mk.

Tom

Index: configure.in
===================================================================
RCS file: /cvs/java/libgcj/libjava/configure.in,v
retrieving revision 1.63
diff -u -r1.63 configure.in
--- configure.in	2000/10/09 17:19:49	1.63
+++ configure.in	2000/10/19 00:43:08
@@ -765,10 +765,31 @@
 here=`pwd`
 AC_SUBST(here)
 
+
 AC_OUTPUT(Makefile libgcj.spec libgcj-test.spec gcj/Makefile include/Makefile testsuite/Makefile,
 [if test -n "$CONFIG_FILES"; then
   ac_file=Makefile . ${libgcj_basedir}/../config-ml.in
-fi],
+fi
+
+# Make subdirectories and `.d' files.  Look in both srcdir and
+# builddir for the .java files.
+h=`pwd`
+: > deps.mk
+( (cd $srcdir && find . -name '*.java' -print) ;
+  find . -name '*.java' -print) | \
+   fgrep -v testsuite | \
+   sed -e 's/\.java/.d/' | \
+   while read f; do
+      echo "include $f" >> deps.mk
+      test -f $f || {
+changequote(<<,>>)
+	 d=`echo $f | sed -e 's,/[^/]*$,,'`
+changequote([,])
+	 $srcdir/../mkinstalldirs $d
+	 : > $f
+      }
+   done
+],
 srcdir=${srcdir}
 host=${host}
 target=${target}
Index: Makefile.am
===================================================================
RCS file: /cvs/java/libgcj/libjava/Makefile.am,v
retrieving revision 1.91
diff -u -r1.91 Makefile.am
--- Makefile.am	2000/10/05 23:57:16	1.91
+++ Makefile.am	2000/10/19 00:43:09
@@ -65,7 +65,7 @@
 ZIP = $(MULTIBUILDTOP)../$(COMPPATH)/zip/zip$(EXEEXT)
 endif # CANADIAN
 
-GCJCOMPILE = $(LIBTOOL) --mode=compile $(GCJ) -fassume-compiled -fclasspath=$(here) -L$(here) $(JC1FLAGS) -c
+GCJCOMPILE = $(LIBTOOL) --mode=compile $(GCJ) -fassume-compiled -fclasspath=$(here) -L$(here) $(JC1FLAGS) -MD -MT $@ -MF $(@:.lo=.d) -c
 GCJLINK = $(LIBTOOL) --mode=link $(GCJ) -L$(here) $(JC1FLAGS) $(LDFLAGS) -o $@
 LIBLINK = $(LIBTOOL) --mode=link $(CC) -L$(here) $(JC1FLAGS) $(LDFLAGS) -o $@
 
@@ -117,12 +117,13 @@
 libffi_files = `$(AR) t ../libffi/.libs/libffi.a 2>/dev/null | sed 's/\.o/\.lo/g' | sed 's/^/..\/libffi\//g'`
 
 libgcj_la_SOURCES = prims.cc posix.cc jni.cc exception.cc \
-	resolve.cc defineclass.cc interpret.cc name-finder.cc
+	resolve.cc defineclass.cc interpret.cc name-finder.cc \
+	$(nat_source_files)
 EXTRA_libgcj_la_SOURCES = boehm.cc nogc.cc posix-threads.cc no-threads.cc \
 	$(c_source_files) $(java_source_files) $(built_java_source_files)
-libgcj_la_DEPENDENCIES = libgcj.zip $(javao_files) $(nat_files) \
+libgcj_la_DEPENDENCIES = libgcj.zip $(javao_files) \
 	$(c_files) $(GCOBJS) $(THREADOBJS) $(LIBLTDL)
-libgcj_la_LIBADD = $(javao_files) $(nat_files) $(c_files) $(GCOBJS) \
+libgcj_la_LIBADD = $(javao_files) $(c_files) $(GCOBJS) \
 	$(THREADOBJS) $(libffi_files) $(LIBLTDL)
 libgcj_la_LDFLAGS = -rpath $(toolexeclibdir) \
 ## The mysterious backslash is consumed by make.
@@ -192,11 +193,15 @@
 ## is a bug in automake), and it also won't put the .o files into
 ## subdirs.  FIXME.
 $(nat_files): %.lo: %.cc
-	$(LTCXXCOMPILE) -c -o $@ $<
+	@echo '$(LTCXXCOMPILE) -c -o $@ $<'; \
+	$(LTCXXCOMPILE) -Wp,-MD,.deps/$(*F).pp -c -o $@ $<
+	@-sed -e 's/^\([^:]*\)\.o[ 	]*:/\1.lo \1.o :/' \
+	  < .deps/$(*F).pp > .deps/$(*F).P; \
+	tr ' ' '\012' < .deps/$(*F).pp \
+	  | sed -e 's/^\\$$//' -e '/^$$/ d' -e '/:$$/ d' -e 's/$$/ :/' \
+	    >> .deps/$(*F).P; \
+	rm -f .deps/$(*F).pp
 
-$(nat_files) $(GCOBJS) $(THREADOBJS) $(libgcj_la_OBJECTS) $(gij_OBJECTS): \
-		include/config.h include/java-signal.h $(nat_headers)
-
 ## FIXME: GNU make.
 $(c_files): %.lo: %.c
 	$(LTCOMPILE) -c -o $@ $<
@@ -207,8 +212,6 @@
 $(javao_files): %.lo: %.java
 	$(GCJCOMPILE) -o $@ $<
 
-$(javao_files): libgcj.zip
-
 ## ################################################################
 
 ##
@@ -225,8 +228,6 @@
 	java/io/ObjectOutputStream$$PutField.h \
 	java/io/ObjectInputStream$$GetField.h
 
-$(nat_headers): libgcj.zip
-
 java/lang/ClassLoader.h: java/lang/ClassLoader.class libgcj.zip
 	$(GCJH) -classpath $(top_builddir) \
 		-friend 'jclass _Jv_FindClass (_Jv_Utf8Const *name, java::lang::ClassLoader *loader);' \
@@ -1166,6 +1167,22 @@
 java/util/natGregorianCalendar.cc \
 java/util/zip/natDeflater.cc \
 java/util/zip/natInflater.cc
+
+## ################################################################
+
+##
+## Dependency tracking madness.
+##
+
+## FIXME: depends on GNU make.
+-include deps.mk
+
+## This is an evil hack to work around an automake limitation.  We
+## need to ensure that the built headers are built before we try to
+## compile the C++ sources, but we can't make the .o files depend on
+## the headers, because in that case we'll force a complete rebuild of
+## the C++ code whenever any .java file is touched.
+all-recursive: $(nat_headers)
 
 ## ################################################################
 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]