[PATCH]: build problems with command line length (ksh93)

Jeff Sturm jsturm@one-point.com
Sun Jul 1 22:45:00 GMT 2001


I've done some work on Makefile.am to avoid command line length
problems once and for all.  (I'm testing this on my alpha-linux
machine with ksh93, which runs configure and libtool considerably
faster than bash, but is less tolerant of long command lines.)

Despite Alexandre Oliva's earlier attempt, we still had statements
like
	for f in `cat $$dir/tmp-list`; do \
  
which expand to a long command.  This patch corrects these along with
some other cleanup (note that libtool still needs a similar fix).

Some comments I removed:

-## JAVAC is set to `$(GCJ) -C'.  However, JAVAC is run from the srcdir
-## (due to problems running it in builddir).  In this case the obvious
-## definition of GCJ won't work; instead we resort to this ugly
-## definition that gives us absolute paths.

I can't tell what this refers to exactly, nor can I figure out why
gcj -C should have any problem running in builddir.

-## FIXME: this ought to depend on built_java_source_files, but right
-## now it can't.  Ugly.

No real explanation, again, so I tried a straightforward dependency.
It worked, and so I removed the comment.

 ## This little nastiness is here so that the backquoted stuff in the
 ## GCJ definition can be correctly expanded, if required.

I assume this refers to the definition of $(JAVAC).  I'm not aware of
any such use of backquotes, but I left this just in case.

Later I'll investigate why ksh93 doesn't like autoconf 2.50 :(

Tested on trunk with alphapca56-unknown-linux-gnu.  OK to commit?


2001-07-01  Jeff Sturm  <jsturm@one-point.com
	
	* Makefile.am (libgcj.jar): Don't recursively make
	built_java_source_files.  Avoid long command lines.
	Don't change to $(srcdir) to invoke javac.
	(libgcj.la, libgcjx.la); Avoid long command lines.
	($(nat_headers),$(x_nat_headers)): Depend on libgcj.jar.

	* Makefile.in: Rebuilt.

Index: Makefile.am
===================================================================
RCS file: /cvs/gcc/gcc/libjava/Makefile.am,v
retrieving revision 1.153
diff -u -r1.153 Makefile.am
--- Makefile.am	2001/06/08 19:09:04	1.153
+++ Makefile.am	2001/07/02 05:15:37
@@ -58,10 +58,6 @@
 endif
 GCJH = gcjh
 else # CANADIAN
-## JAVAC is set to `$(GCJ) -C'.  However, JAVAC is run from the srcdir
-## (due to problems running it in builddir).  In this case the obvious
-## definition of GCJ won't work; instead we resort to this ugly
-## definition that gives us absolute paths.
 GCJH = $(MULTIBUILDTOP)../$(COMPPATH)/gcc/gcjh$(EXEEXT)
 ZIP = $(MULTIBUILDTOP)../$(COMPPATH)/fastjar/jar$(EXEEXT)
 endif # CANADIAN
@@ -165,6 +161,7 @@
 ## a .java file with some other class which is caught.  Note that we
 ## only want to create headers for those files which do not have
 ## hand-maintained headers.
+$(built_java_source_files:.java=.class): libgcj.jar
 $(java_source_files:.java=.class): libgcj.jar
 
 ## The .class files for X will not be included in libgcj.jar, but the
@@ -172,36 +169,22 @@
 ## built. We need this to generate headers for the nat-files.
 $(x_java_source_files:.java=.class): libgcj.jar
 
-## FIXME: this isn't really correct.
-$(built_java_source_files:.java=.class): $(built_java_source_files)
-## This little nastiness is here so that the backquoted stuff in the
-## GCJ definition can be correctly expanded, if required.
-	@javac="$(JAVAC)"; \
-	for f in $?; do \
-	  echo $$javac -L$(here) $(JCFLAGS) -classpath $(here):`cd $(srcdir) && /bin/pwd` -d $(here) $$f; \
-	  $$javac -L$(here) $(JCFLAGS) -classpath $(here):`cd $(srcdir) && /bin/pwd` \
-	  -d $(here) $$f; \
-	done
-
 ## We have the zip file depend on the java sources and not the class
 ## files, because we don't know the names of all the class files.
 ## FIXME: this method fails in a peculiar case: if libgcj.jar is
 ## up-to-date, and foo.class is removed, and bar.java is touched, then
 ## `make libgcj.jar' will not rebuilt foo.class.  That's because
 ## libgcj.jar is not out-of-date with respect to foo.java.
-libgcj.jar: $(java_source_files) $(x_java_source_files)
+libgcj.jar: $(built_java_source_files) $(java_source_files) $(x_java_source_files)
 ## Create a list of all Java sources, without exceeding any shell limits.
-	@: $(shell echo Creating list of files to compile...) $(shell rm -f tmp-list || :) $(shell touch tmp-list) $(foreach source,$(subst $(srcdir)/,,$?),$(shell echo $(source) >> tmp-list))
-## FIXME: this ought to depend on built_java_source_files, but right
-## now it can't.  Ugly.
-	$(MAKE) $(built_java_source_files:.java=.class)
+	@: $(shell echo Creating list of files to compile...) $(shell rm -f tmp-list || :) $(shell touch tmp-list) $(foreach source,$?,$(shell echo $(source) >> tmp-list))
 ## This little nastiness is here so that the backquoted stuff in the
 ## GCJ definition can be correctly expanded, if required.
 	@set fnord $(MAKEFLAGS); amf=$$2; fail=no; \
-	javac="$(JAVAC)"; dir=`/bin/pwd`; cd $(srcdir); \
-	for f in `cat $$dir/tmp-list`; do \
-	  echo $$javac $(JCFLAGS) -classpath $(here):`/bin/pwd` -d $(here) $$f; \
-	  $$javac $(JCFLAGS) -classpath $(here):`/bin/pwd` -d $(here) $$f \
+	javac="$(JAVAC)"; \
+	cat tmp-list | while read f; do \
+	  echo $$javac $(JCFLAGS) -classpath $(here):$(srcdir) -d $(here) $$f; \
+	  $$javac $(JCFLAGS) -classpath $(here):$(srcdir) -d $(here) $$f \
 	    || case "$$amf" in *=*) exit 1;; *k*) fail=yes ;; *) exit 1;; esac; \
 	done; \
 	test "$$fail" = no
@@ -253,15 +236,13 @@
 ## Pass the list of object files to libtool in a temporary file to 
 ## avoid tripping platform command line length limits.
 libgcj.la: $(libgcj_la_OBJECTS) $(libgcj_la_DEPENDENCIES)
-	@echo $(libgcj_la_OBJECTS) > libgcj.objectlist;
-	@echo $(libgcj_la_LIBADD) >> libgcj.objectlist;
+	@: $(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))
 	$(libgcj_la_LINK) -objectlist libgcj.objectlist \
 	@LIBFFI@ \
 	-rpath $(toolexeclibdir) $(libgcj_la_LDFLAGS) $(LIBS)
 
 libgcjx.la: $(libgcjx_la_OBJECTS) $(libgcjx_la_DEPENDENCIES)
-	@echo $(libgcjx_la_OBJECTS) > libgcjx.objectlist;
-	@echo $(libgcjx_la_LIBADD) >> libgcjx.objectlist;
+	@: $(shell echo Creating list of files to link...) $(shell rm -f libgcjx.objectlist || :) $(shell touch libgcjx.objectlist) $(foreach object,$(libgcjx_la_OBJECTS) $(libgcjx_la_LIBADD),$(shell echo $(object) >> libgcjx.objectlist))
 	$(libgcjx_la_LINK) -objectlist libgcjx.objectlist \
 	-rpath $(toolexeclibdir) $(libgcjx_la_LDFLAGS) $(LIBS)
 
@@ -282,6 +263,8 @@
 	java/io/ObjectInputStream$$GetField.h
 
 x_nat_headers = $(x_java_source_files:.java=.h)
+
+$(nat_headers) $(x_nat_headers): libgcj.jar
 
 java/lang/ClassLoader.h: java/lang/ClassLoader.class libgcj.jar
 	$(GCJH) -classpath $(top_builddir) \



More information about the Java-patches mailing list