summaryrefslogtreecommitdiff
path: root/devel/bmake/files/mk/java.mk
blob: 1a705d3d58874c90a4e0abf303cc37e34109906d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#
# RCSid:
#	$Id: java.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $

#	@(#) 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
#	use this file is hereby granted provided that 
#	the above copyright notice and this notice are
#	left intact. 
#      
#	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.
# this lot does that but needs a recent netbsd make or 
# 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