]> CyberLeo.Net >> Repos - FreeBSD/releng/10.2.git/blob - contrib/bmake/mk/java.mk
- Copy stable/10@285827 to releng/10.2 in preparation for 10.2-RC1
[FreeBSD/releng/10.2.git] / contrib / bmake / mk / java.mk
1 #
2 # RCSid:
3 #       $Id: java.mk,v 1.14 2007/11/22 08:16:25 sjg Exp $
4
5 #       @(#) Copyright (c) 1998-2001, Simon J. Gerraty
6 #
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. 
13 #      
14 #       Please send copies of changes and bug-fixes to:
15 #       sjg@crufty.net
16 #
17
18 .if !target(__${.PARSEFILE}__)
19 __${.PARSEFILE}__:
20
21 .include <init.mk>
22
23 CLASSPATH?=.
24
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
32
33 CLEANFILES+= *.class
34
35 JAVAC?=   javac
36 JAVADOC?= javadoc
37
38 .if !target(docs)
39 docs:
40         ${JAVADOC} ${JAVADOC_FLAGS} ${SRCS}
41 .endif
42
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
51
52 JAVAC_FLAGS+= ${JAVAC_DBG}
53
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}
70
71 ${__classes_cookie}:    ${__classes}
72         CLASSPATH=${CLASSPATH} ${JAVAC} ${JAVAC_FLAGS} ${.OODATE:@c@${SRCS_$c}@}
73         @touch ${.TARGET}
74
75 all:    ${__classes_cookie}
76
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
84
85 all:    ${SRCS:%.java=${__classdest}%.class}
86
87 .endif
88
89 .if !target(cleanjava)
90 cleanjava:
91         rm -f [Ee]rrs mklog core *.core ${PROG} ${CLEANFILES}
92
93 clean: cleanjava
94 cleandir: cleanjava
95 .endif
96
97 .endif