Correct math and limerick.
[dragonfly.git] / contrib / bmake / mk / java.mk
blobef4a5ea0ba1000fbe85e1e779b36e280c67d8504
2 # RCSid:
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
12 # left intact.
14 # Please send copies of changes and bug-fixes to:
15 # sjg@crufty.net
18 .if !target(__${.PARSEFILE}__)
19 __${.PARSEFILE}__:
21 .include <init.mk>
23 CLASSPATH?=.
25 .if defined(PROG)
26 SRCS?= ${PROG:.class=.java}
27 .endif
28 .if !defined(SRCS) || empty(SRCS)
29 SRCS!=cd ${.CURDIR} && echo *.java
30 .endif
31 .SUFFIXES: .class .java
33 CLEANFILES+= *.class
35 JAVAC?= javac
36 JAVADOC?= javadoc
38 .if !target(docs)
39 docs:
40 ${JAVADOC} ${JAVADOC_FLAGS} ${SRCS}
41 .endif
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}
48 .else
49 __classdest=
50 .endif
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.
58 .for __s in ${SRCS}
59 __c:= ${__classdest}${__s:.java=.class}
60 .if !target(${__c})
61 # We need to do something to force __c's parent to be made.
62 ${__c}: ${__s}
63 @rm -f ${.TARGET}
64 .endif
65 SRCS_${__c}=${__s}
66 __classes:= ${__classes} ${__c}
67 .endfor
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}@}
73 @touch ${.TARGET}
75 all: ${__classes_cookie}
77 .else
78 # this will work with other BSD make's
79 .for __s in ${SRCS}
80 __c:= ${__classdest}${__s:.java=.class}
81 ${__c}: ${__s}
82 CLASSPATH=${CLASSPATH} ${JAVAC} ${JAVAC_FLAGS} ${.OODATE}
83 .endfor
85 all: ${SRCS:%.java=${__classdest}%.class}
87 .endif
89 .if !target(cleanjava)
90 cleanjava:
91 rm -f [Ee]rrs mklog core *.core ${PROG} ${CLEANFILES}
93 clean: cleanjava
94 cleandir: cleanjava
95 .endif
97 .endif