2013-01-31 16:44:23 +00:00
|
|
|
#
|
|
|
|
# RCSid:
|
2020-09-05 16:11:04 +00:00
|
|
|
# $Id: java.mk,v 1.15 2020/08/19 17:51:53 sjg Exp $
|
2013-01-31 16:44:23 +00:00
|
|
|
|
|
|
|
# @(#) Copyright (c) 1998-2001, Simon J. Gerraty
|
|
|
|
#
|
|
|
|
# This file is provided in the hope that it will
|
|
|
|
# be of use. There is absolutely NO WARRANTY.
|
|
|
|
# Permission to copy, redistribute or otherwise
|
2020-09-05 16:11:04 +00:00
|
|
|
# use this file is hereby granted provided that
|
2013-01-31 16:44:23 +00:00
|
|
|
# the above copyright notice and this notice are
|
2020-09-05 16:11:04 +00:00
|
|
|
# left intact.
|
|
|
|
#
|
2013-01-31 16:44:23 +00:00
|
|
|
# Please send copies of changes and bug-fixes to:
|
|
|
|
# sjg@crufty.net
|
|
|
|
#
|
|
|
|
|
|
|
|
.if !target(__${.PARSEFILE}__)
|
|
|
|
__${.PARSEFILE}__:
|
|
|
|
|
|
|
|
.include <init.mk>
|
|
|
|
|
|
|
|
CLASSPATH?=.
|
|
|
|
|
|
|
|
.if defined(PROG)
|
|
|
|
SRCS?= ${PROG:.class=.java}
|
|
|
|
.endif
|
|
|
|
.if !defined(SRCS) || empty(SRCS)
|
|
|
|
SRCS!=cd ${.CURDIR} && echo *.java
|
|
|
|
.endif
|
|
|
|
.SUFFIXES: .class .java
|
|
|
|
|
|
|
|
CLEANFILES+= *.class
|
|
|
|
|
|
|
|
JAVAC?= javac
|
|
|
|
JAVADOC?= javadoc
|
|
|
|
|
|
|
|
.if !target(docs)
|
|
|
|
docs:
|
|
|
|
${JAVADOC} ${JAVADOC_FLAGS} ${SRCS}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if defined(JAVADESTDIR) && !empty(JAVADESTDIR)
|
|
|
|
JAVASRCDIR?=${JAVADESTDIR:H}/src
|
|
|
|
__classdest:=${JAVADESTDIR}${.CURDIR:S,${JAVASRCDIR},,}/
|
|
|
|
CLASSPATH:=${CLASSPATH}:${JAVADESTDIR}
|
|
|
|
JAVAC_FLAGS+= -d ${JAVADESTDIR}
|
|
|
|
.else
|
|
|
|
__classdest=
|
|
|
|
.endif
|
|
|
|
|
|
|
|
JAVAC_FLAGS+= ${JAVAC_DBG}
|
|
|
|
|
|
|
|
.if defined(MAKE_VERSION) && !defined(NO_CLASSES_COOKIE)
|
|
|
|
# java works best by compiling a bunch of classes at once.
|
2020-09-05 16:11:04 +00:00
|
|
|
# this lot does that but needs a recent netbsd make or
|
2013-01-31 16:44:23 +00:00
|
|
|
# or its portable cousin bmake.
|
|
|
|
.for __s in ${SRCS}
|
|
|
|
__c:= ${__classdest}${__s:.java=.class}
|
|
|
|
.if !target(${__c})
|
|
|
|
# We need to do something to force __c's parent to be made.
|
|
|
|
${__c}: ${__s}
|
|
|
|
@rm -f ${.TARGET}
|
|
|
|
.endif
|
|
|
|
SRCS_${__c}=${__s}
|
|
|
|
__classes:= ${__classes} ${__c}
|
|
|
|
.endfor
|
|
|
|
__classes_cookie=${__classdest}.classes.done
|
|
|
|
CLEANFILES+= ${__classes} ${__classes_cookie}
|
|
|
|
|
|
|
|
${__classes_cookie}: ${__classes}
|
|
|
|
CLASSPATH=${CLASSPATH} ${JAVAC} ${JAVAC_FLAGS} ${.OODATE:@c@${SRCS_$c}@}
|
|
|
|
@touch ${.TARGET}
|
|
|
|
|
|
|
|
all: ${__classes_cookie}
|
|
|
|
|
|
|
|
.else
|
|
|
|
# this will work with other BSD make's
|
|
|
|
.for __s in ${SRCS}
|
|
|
|
__c:= ${__classdest}${__s:.java=.class}
|
|
|
|
${__c}: ${__s}
|
|
|
|
CLASSPATH=${CLASSPATH} ${JAVAC} ${JAVAC_FLAGS} ${.OODATE}
|
|
|
|
.endfor
|
|
|
|
|
|
|
|
all: ${SRCS:%.java=${__classdest}%.class}
|
|
|
|
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !target(cleanjava)
|
|
|
|
cleanjava:
|
|
|
|
rm -f [Ee]rrs mklog core *.core ${PROG} ${CLEANFILES}
|
|
|
|
|
|
|
|
clean: cleanjava
|
|
|
|
cleandir: cleanjava
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.endif
|