My Java build system on NetBSD/i386 consists of a /usr/java
sub-tree (actually a link from the JDK home dir in use
to /usr/java ) and a 4.4BSD style make
include file .
A good starting point for the exploration of make (besides 'man make')
is the make tutorial in /usr/share/doc/psd/12.make/ .
In analogy to the Un*x-derived directory structure, all the Java
libraries (*.jar, *.zip) are located in /usr/java/lib :
[hf@scree] ~ > l /usr/java/lib/*.{jar,zip}
-r--r--r-- 1 root wheel 200486 Mar 16 17:17 /usr/java/lib/Broker.zip
-r--r--r-- 1 root wheel 68926 Mar 16 17:17 /usr/java/lib/WARREN.2.4.3.zip
-r--r--r-- 1 root wheel 64965 Mar 16 17:28 /usr/java/lib/WARREN.zip
-r--r--r-- 1 root wheel 8876583 Mar 13 15:47 /usr/java/lib/classes.zip
-r--r--r-- 1 root wheel 217529 May 25 12:18 /usr/java/lib/collections.jar
-r--r--r-- 1 root wheel 128722 May 15 12:40 /usr/java/lib/interclient.jar
-r--r--r-- 1 root wheel 200265 Mar 16 17:17 /usr/java/lib/jd.zip
-r--r--r-- 1 root wheel 1045782 Mar 16 17:28 /usr/java/lib/jgl.3.0.jar
-r--r--r-- 1 root wheel 963513 Mar 16 17:16 /usr/java/lib/jgl.3.1.jar
-r--r--r-- 1 root wheel 2001666 May 14 17:15 /usr/java/lib/swingall.1.0.2.jar
-r--r--r-- 1 root wheel 1907130 Mar 16 17:16 /usr/java/lib/swingall.1.0.jar
[hf@scree] ~ >
The Java home environment variable of the week (try JAVA_HOME,
JAVAHOME, JDK_HOME, JDKHOME) points to
/usr/java. The CLASSPATH variable
remains unset, saving you a lot of trouble; the Makefiles
do the dirty work for you. PATH contains
/usr/java/bin.
The library filenames are mapped to symbolic names (like
LIBJXXX) in the Java make include file.
The 4.4BSD Java make include file offers a variety of variables that control the build system. They are set to default values and can be overridden in local Makefiles.
A typical Makefile shows the most important variables:
CLPATH lists the libraries to be included in the
classpath
BASEDIR denotes the relative path to the root of
the Java class hierarchy
PACKDIR denotes the relative path from the root
of the Java class hierarchy to the current directory
SRCS lists the source files
PROG takes the fully qualified name of
the class containing main().
CLEANFILES takes additional product files
that are not cleaned up by the default rule.
JCFLAGS takes options for the Java compiler
JIFLAGS takes options for the Java interpreter
(Don't forget to .include <bsd.java.mk> at the
end of your Makefile.)
The following targets are defined:
all: builds the classes from the source files.
jar: archives a subtree from ${BASEDIR}
downwards.
depend: creates dependency files for the
Java source files.
doc: creates JavaDoc files.
checksourcelist: checks if all the *.java
files in the subtree are listed in a Makefile.
clean: - well, what did you expect?
cleandir: removes dependency files, orphaned
*.class files and *.html files, too.
run: starts ${PROG} , if it is
defined, with the correct classpath.
debug: starts ${PROG} with the
Jikes debugger.
NetBSD's make compiles with minor tweaks on Windows NT under the
Cygnus GNU-Win32
package (see
NetBSD PR bin/4905 & 4908). Add _PS= ;
to /etc/mk.conf to use the Win32 specific path
separator. Fortunately, Sun's JDK-Win32 accepts slashes as
file separator.
'make all' works fine that way; currently, 'make depend' chokes on what I think is a bash/GNU-Win32 deficiency.
The described system works reliably in a project with ~150 files. Compile times are much larger than with JBuilder 1.0.1 on NT 4, but we spend a lot of time on searching errors and rebuilds from scratch because of JBuilder's insufficient dependency checking (AFAICS, this applies to the JDK javac's dependency checking as well).