This is the mail archive of the java-patches@gcc.gnu.org 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]
Other format: [Raw text]

Patch for Review: Build all libjava .class files at once (Updated Again)


Hi Tom,

>Now we just have to tackle the other half of the equation :-)
>
>Mohan> +	@: $(shell echo $? | tr ' ' '\n' > libgcj.sourcelist)
>
>Like Alexandre says, you have to use the GNU make trick here to work
>around systems with command line length limitations.  With that change
>this patch is ok.

Since we can assume GNU make (and since you know how I feel about
duplicated code), I splurged and wrote a parameterized
function to do this and also refactored the libgcj.la,
lib-gnu-awt-xlib.la, install-data-local targets to use this.
Is this okay? In my opinion, these read really nicely now.

(And what if some utopic day in the future, we varied write_entries_to_file
by host via write_entries_to_file = @WRITE_ENTRIES_TO_FILE_IMPL@? Could
GNU make, automake and parameterized functions usher in a new era of makefile
optimization?)

Tested on (i686-pc-linux-gnu,i686-pc-linux-gnu,i686-pc-linux-gnu) and
(i686-pc-linux-gnu,i686-pc-linux-gnu,i686-pc-mingw32).

ChangeLog
2003-08-18  Mohan Embar  <gnustuff@thisiscool.com>

	* Makefile.am: (write_entries_to_file) New parameterized
	function for writing entries to a file one line at a time.
	(all_java_class_files): Removed definition.
	(.java.class) Removed.target.
	(libgcj-@gcc_version@.jar): Changed dependency to
	$(all_java_source_files); added compilation step which compiles
	all changed source files in one pass.
	(libgcj.la) Refactored to use write_entries_to_file.
	(lib-gnu-awt-xlib.la) Likewise.
	(install-data-local) Likewise.
	(write-entries-to-file-check) New target which tests write_entries_to_file.
	(all-recursive): Changed dependency from $(all_java_class_files)
	to libgcj-@gcc_version@.jar
	* Makefile.in: Rebuilt.

Index: Makefile.am
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/Makefile.am,v
retrieving revision 1.313
diff -u -2 -r1.313 Makefile.am
--- Makefile.am	8 Aug 2003 16:25:57 -0000	1.313
+++ Makefile.am	18 Aug 2003 10:53:34 -0000
@@ -11,4 +11,13 @@
 endif
 
+# write_entries_to_file - writes each entry in a list
+# to the specified file. Each entry is written individually
+# to accomodate systems with severe command-line-length
+# limitations.
+# Parameters:
+# $(1): variable containing entries to iterate over
+# $(2): output file
+write_entries_to_file = $(shell rm -f $(2) || :) $(shell touch $(2)) $(foreach object,$(1),$(shell echo $(object) >> $(2)))
+
 ## ################################################################
 
@@ -331,12 +340,9 @@
     $(x_java_source_files)
 
-all_java_class_files = $(all_java_source_files:.java=.class)
-
-.java.class:
-	$(JAVAC) $(JCFLAGS) -classpath '' -bootclasspath $(here):$(srcdir) \
-             -d $(here) $<
-
-libgcj-@gcc_version@.jar: $(all_java_class_files)
+libgcj-@gcc_version@.jar: $(all_java_source_files)
 	-@rm -f libgcj-@gcc_version@.jar
+	@echo Compiling Java sourcefiles...
+	@: $(call write_entries_to_file,$?,libgcj.sourcelist)
+	$(JAVAC) $(JCFLAGS) -classpath '' -bootclasspath $(here):$(srcdir) -d $(here) @libgcj.sourcelist
 ## Note that we explicitly want to include directory information.
 	find java gnu javax org -type d -o -type f -name '*.class' | \
@@ -394,5 +400,6 @@
 ## avoid tripping platform command line length limits.
 libgcj.la: $(libgcj_la_OBJECTS) $(libgcj_la_DEPENDENCIES)
-	@: $(shell echo Creating list of files to link...) $(shell rm -f libgcj.objectlist || :) $(shell touch libgcj.objectlist) $(foreach object,$(libgcj_la_OBJECTS) $(libgcj_la_LIBADD),$(shell echo 
$(object) >> libgcj.objectlist))
+	@echo Creating list of files to link...
+	@: $(call write_entries_to_file,$(libgcj_la_OBJECTS) $(libgcj_la_LIBADD),libgcj.objectlist)
 	$(libgcj_la_LINK) -objectlist libgcj.objectlist \
 	@GCLIBS@ @LIBFFI@ @ZLIBS@ \
@@ -400,5 +407,6 @@
 
 lib-gnu-awt-xlib.la: $(lib_gnu_awt_xlib_la_OBJECTS) $(lib_gnu_awt_xlib_la_DEPENDENCIES)
-	@: $(shell echo Creating list of files to link...) $(shell rm -f lib_gnu_awt_xlib.objectlist || :) $(shell touch lib_gnu_awt_xlib.objectlist) $(foreach object,$(lib_gnu_awt_xlib_la_OBJECTS) 
$(lib_gnu_awt_xlib_la_LIBADD),$(shell echo $(object) >> lib_gnu_awt_xlib.objectlist))
+	@echo Creating list of files to link...
+	@: $(call write_entries_to_file,$(lib_gnu_awt_xlib_la_OBJECTS) $(lib_gnu_awt_xlib_la_LIBADD),lib_gnu_awt_xlib.objectlist)
 	$(lib_gnu_awt_xlib_la_LINK) -objectlist lib_gnu_awt_xlib.objectlist \
 	-rpath $(toolexeclibdir) $(lib_gnu_awt_xlib_la_LDFLAGS) $(LIBS)
@@ -518,5 +526,6 @@
 ## We use a GNU make trick here so that we don't go over the command
 ## length limit of some shells.
-	@: $(shell echo Creating list of headers to install...) $(shell rm -f tmp-ilist || :) $(shell touch tmp-ilist) $(foreach hdr,$(nat_headers) $(extra_headers),$(shell echo $(hdr) >> tmp-ilist))
+	@echo Creating list of headers to install...
+	@: $(call write_entries_to_file,$(nat_headers) $(extra_headers),tmp-ilist)
 	@cat tmp-ilist | while read f; do \
 	  d="`echo $$f | sed -e 's,/[^/]*$$,,'`"; \
@@ -574,4 +583,9 @@
 	done; exit $$ok
 
+## This rule checks whether write_entries_to_file works properly.
+write-entries-to-file-check:
+	@echo Creating list of files to link...
+	@: $(call write_entries_to_file,$(libgcj_la_OBJECTS) $(libgcj_la_LIBADD),libgcj.objectlist)
+
 ## ################################################################
 
@@ -2731,5 +2745,5 @@
 ## Also force all the class files to build first. This makes them build in
 ## the right order to improve performance.
-all-recursive: $(all_java_class_files) $(nat_headers) $(x_nat_headers)
+all-recursive: libgcj-@gcc_version@.jar $(nat_headers) $(x_nat_headers)
 
 ## ################################################################





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