3 # $Id: java.mk,v 1.14 2007/11/22 08:16:25 sjg Exp $
5 # @(#) Copyright (c) 1998-2001, Simon J. Gerraty
7 # This file is provided in the hope that it will
8 # be of use. There is absolutely NO WARRANTY.
9 # Permission to copy, redistribute or otherwise
10 # use this file is hereby granted provided that
11 # the above copyright notice and this notice are
14 # Please send copies of changes and bug-fixes to:
18 .if !target(__${.PARSEFILE}__)
26 SRCS?= ${PROG:.class=.java}
28 .if !defined(SRCS) || empty(SRCS)
29 SRCS!=cd ${.CURDIR} && echo *.java
31 .SUFFIXES: .class .java
40 ${JAVADOC} ${JAVADOC_FLAGS} ${SRCS}
43 .if defined(JAVADESTDIR) && !empty(JAVADESTDIR)
44 JAVASRCDIR?=${JAVADESTDIR:H}/src
45 __classdest:=${JAVADESTDIR}${.CURDIR:S,${JAVASRCDIR},,}/
46 CLASSPATH:=${CLASSPATH}:${JAVADESTDIR}
47 JAVAC_FLAGS+= -d ${JAVADESTDIR}
52 JAVAC_FLAGS+= ${JAVAC_DBG}
54 .if defined(MAKE_VERSION) && !defined(NO_CLASSES_COOKIE)
55 # java works best by compiling a bunch of classes at once.
56 # this lot does that but needs a recent netbsd make or
57 # or its portable cousin bmake.
59 __c:= ${__classdest}${__s:.java=.class}
61 # We need to do something to force __c's parent to be made.
66 __classes:= ${__classes} ${__c}
68 __classes_cookie=${__classdest}.classes.done
69 CLEANFILES+= ${__classes} ${__classes_cookie}
71 ${__classes_cookie}: ${__classes}
72 CLASSPATH=${CLASSPATH} ${JAVAC} ${JAVAC_FLAGS} ${.OODATE:@c@${SRCS_$c}@}
75 all: ${__classes_cookie}
78 # this will work with other BSD make's
80 __c:= ${__classdest}${__s:.java=.class}
82 CLASSPATH=${CLASSPATH} ${JAVAC} ${JAVAC_FLAGS} ${.OODATE}
85 all: ${SRCS:%.java=${__classdest}%.class}
89 .if !target(cleanjava)
91 rm -f [Ee]rrs mklog core *.core ${PROG} ${CLEANFILES}