[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: java Makefile



"Matt Fair" <matt@netasol.com> writes:

> Is there a good way to create a good Makefile for JAVA projects?
> Right now all I am doing is in my Makefile I have:
> javac $(find . -name \*.java)
> 
> This does the trick, but all it does is when I call Makefile is go
> through all my java files and compiles them.
> Is there a way to check dependencies and compile only the files that
> need compiling?

In Kawa I do:

java-classes.stamp: $(java_Java)
	$(CLASSPATH_ENV) $(JAVAC) -d $(JAVAROOT) $(JAVACFLAGS) $?
	echo timestamp > java-classes.stamp

where java_Java is the sources files in the current directory
and JAVAROOT is to ../.. to get to the root. This recompiles just
the java files that are out of date.

To compile to native code using GCJ (and libtool for shared
libraries) I do:

$(OFILES_DIR)/$(PACKAGE_FNAME).lo:  $(GCJ_DEPS)
	$(LIBTOOL) --tag=GCJ --mode=compile $(GCJ) $(GCJFLAGS) \
	  --CLASSPATH=$(JAVAROOT):$(srcdir)/$(JAVAROOT) -c \
	  $^ $(EXTRA_GCJ_INPUTS) -o $(OFILES_DIR)/$(PACKAGE_FNAME).lo

The sourcesa are on ftp://ftp.gnu.org/pub/gnu/kawa/kawa-newest.tar.gz .
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/per/



Reply to: