i have a small java project i want to build using a makefile, the code is in src/package... /*.java
, the bytecode should go to bin/package.../*.class
.
My current file looks like this (simplified):
JC = javac
SRCDIR = src
BINDIR = bin
JCFLAGS = -d $(BINDIR)/
CLASSES = $(SRCDIR)/package/class1.java $(SRCDIR)/package/class2.java $(SRCDIR)/package/class3.java
default:
$(JC) $(JCFLAGS) $(CLASSES)
It works and does what it should, but there has to be a more elegant way to do this.
For example, is there a way to apply the path ($(SRCDIR)
and the package name) as a prefix to all class filenames, so i do not have to put the path seperately in front of every class?
All classes have to be compiled in one javac-call, as there are circular dependencies in them, so using an own target for each class does not work:
default: $(CLASSES)
%.java:
$(JC) $(JCFLAGS) $(SRCDIR)/$@
Thanks for your help.