help-make
[Top][All Lists]
Advanced

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

adapting make for Java?


From: Martin Algesten
Subject: adapting make for Java?
Date: Tue, 24 Oct 2000 11:21:32 +0100

Hello!

Does anyone know if there has been any attempt to address the issues with
using GNU make and Java? I've recently looked into the problem of making
good makefiles for my projects, and found some obstacles. 

Consider this:

I have a layout like this:
projectroot/
projectroot/classes/
projectroot/src/com/my/package/
projectroot/src/com/my/package/MyClass1.java
projectroot/src/com/my/package/MyClass2.java
projectroot/src/com/my/package/MyClass3.java
projectroot/src/com/my/package/Makefile

Makefile (out of my head):
#######################

PROOT = $(HOME)/projectroot
OUTPUT = $(PROOT)/classes

TARGETS =    MyClass1.class MyClass2.class MyClass3.class

all : $(TARGETS)

PACKAGE = com/my/package

vpath %.class $(OUTPUT)/$(PACKAGE)

%.class : %.java
    javac -d $(OUTPUT) $<

##########################

Okay this works fine. A compilation will put the targets where I want them.
It will then only attempt to compile the files that has changed etc etc.
There are however a big issues with this.

The implicit rule will only compile one java file at a time.
This is not the way to compile java. The javac does a heck of a lot of
initialization on each invokation (remember that javac is written in java
itself). I made a quick test of this with compiling five empty classes using
sequential compilation, I did it in 6.7 seconds. If I did it all at once the
same compilation took me 1.4 seconds. I think we all agree that almost 5x
slower compilation is not acceptable. The problem as I see it is that what I
want make to do is something like:

(%.class)+ : (%.java)+
    javac -d $(OUTPUT) $<<

(I will not be held responsible for the bogus syntax). Where I would like
the implicit rule to match all targets needed to be recompiled in one big
blow and that the automatic variable $<< would mean "all .java files". Is
there perhaps already a way of doing this?

Martin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]