xref: /unit/auto/modules/java (revision 1340:518b528dc67e)
1
2# Copyright (C) NGINX, Inc.
3
4
5shift
6
7NXT_JAVA_HOME=${JAVA_HOME-}
8NXT_JAR_REPO=https://repo1.maven.org/maven2/
9NXT_JAR_LOCAL_REPO=$HOME/.m2/repository/
10
11for nxt_option; do
12
13    case "$nxt_option" in
14        -*=*) value=`echo "$nxt_option" | sed -e 's/[-_a-zA-Z0-9]*=//'`     ;;
15           *) value="" ;;
16    esac
17
18    case "$nxt_option" in
19
20        --module=*)     NXT_JAVA_MODULE="$value"                              ;;
21        --home=*)       NXT_JAVA_HOME="$value"                                ;;
22        --lib-path=*)   NXT_JAVA_LIB_PATH="$value"                            ;;
23        --repo=*)       NXT_JAR_REPO="$value"                                 ;;
24        --local-repo=*) NXT_JAR_LOCAL_REPO="$value"                           ;;
25        --sha512=*)     NXT_SHA512_TOOL="$value"                              ;;
26        --jars=*)       NXT_JARS="$value"                                     ;;
27
28        --help)
29            cat << END
30
31    --module=NAME         set unit Java module name
32    --home=DIR            set Java home directory
33    --lib-path=DIRECTORY  set directory path to libjvm.so library
34    --repo=URL            set Maven remote repository URL
35                          default: "$NXT_JAR_REPO"
36    --local-repo=DIR      set local repository directory
37                          default: "$NXT_JAR_LOCAL_REPO"
38    --sha512=SHA512       set command for SHA512 check
39    --jars=DIR            set jars install/search directory
40
41END
42            exit 0
43        ;;
44
45        *)
46            echo
47            echo $0: error: invalid Java option \"$nxt_option\"
48            echo
49            exit 1
50        ;;
51    esac
52
53done
54
55
56if [ ! -f $NXT_AUTOCONF_DATA ]; then
57   echo
58   echo Please run common $0 before configuring module \"$nxt_module\".
59   echo
60   exit 1
61fi
62
63. $NXT_AUTOCONF_DATA
64
65
66NXT_JARS=${NXT_JARS=$NXT_MODULES}
67NXT_JAVA_MODULE=${NXT_JAVA_MODULE=java}
68NXT_JAVA_LIB_PATH=${NXT_JAVA_LIB_PATH=}
69
70$echo "configuring Java module"
71$echo "configuring Java module ..." >> $NXT_AUTOCONF_ERR
72
73if [ -n "${NXT_JAVA_HOME}" ]; then
74    $echo "using java.home ${NXT_JAVA_HOME}"
75    $echo "using java.home ${NXT_JAVA_HOME}" >> $NXT_AUTOCONF_ERR
76
77    if [ ! -d "${NXT_JAVA_HOME}" ]; then
78        $echo
79        $echo $0: error: Java home directory not found.
80        $echo
81        exit 1
82    fi
83
84    NXT_JAVA="${NXT_JAVA_HOME}/bin/java"
85
86else
87    $echo -n "checking for java executable"
88    $echo "checking for java executable ..." >> $NXT_AUTOCONF_ERR
89
90    NXT_JAVA=`which java || :`
91    if [ -z "$NXT_JAVA" -o ! -x "$NXT_JAVA" ]; then
92        $echo
93        $echo $0: error: java executable not found.
94        $echo
95        exit 1
96    fi
97
98    $echo " found $NXT_JAVA"
99    $echo "found $NXT_JAVA" >> $NXT_AUTOCONF_ERR
100
101    "$NXT_JAVA" -version
102
103    $echo -n "checking java.home"
104    $echo "checking java.home ..." >> $NXT_AUTOCONF_ERR
105
106    NXT_JAVA_HOME=`$NXT_JAVA -XshowSettings 2>&1 | grep -F -e java.home | sed -e 's/^.*= //'`
107    if [ -z "$NXT_JAVA_HOME" ]; then
108        $echo
109        $echo $0: error: java.home not found.
110        $echo
111        exit 1
112    fi
113
114    $echo " $NXT_JAVA_HOME"
115    $echo "got java.home $NXT_JAVA_HOME" >> $NXT_AUTOCONF_ERR
116
117    if [ ! -x "${NXT_JAVA_HOME}/bin/javac" ]; then
118        NXT_JAVA_HOME_=${NXT_JAVA_HOME%/jre}
119        if [ -x "${NXT_JAVA_HOME_}/bin/javac" ]; then
120            $echo "adjust java.home $NXT_JAVA_HOME_"
121            $echo "adjust java.home $NXT_JAVA_HOME_" >> $NXT_AUTOCONF_ERR
122
123            NXT_JAVA_HOME="$NXT_JAVA_HOME_"
124        fi
125    fi
126fi
127
128NXT_JAVAC="${NXT_JAVA_HOME}/bin/javac"
129
130if [ ! -x "$NXT_JAVAC" ]; then
131    $echo
132    $echo $0: error: javac not found.
133    $echo
134    exit 1
135fi
136
137NXT_JAVA_INCLUDE="-I${NXT_JAVA_HOME}/include"
138
139case "$NXT_SYSTEM" in
140    Linux)
141        NXT_JAVA_INCLUDE="${NXT_JAVA_INCLUDE} -I${NXT_JAVA_HOME}/include/linux"
142        ;;
143    Darwin)
144        NXT_JAVA_INCLUDE="${NXT_JAVA_INCLUDE} -I${NXT_JAVA_HOME}/include/darwin"
145        ;;
146    FreeBSD)
147        NXT_JAVA_INCLUDE="${NXT_JAVA_INCLUDE} -I${NXT_JAVA_HOME}/include/freebsd"
148        ;;
149esac
150
151if [ -z "$NXT_JAVA_LIB_PATH" ]; then
152    $echo -n "checking library path"
153    $echo "checking library path ..." >> $NXT_AUTOCONF_ERR
154
155    if [ ! -x "$NXT_JAVA" ]; then
156        $echo
157        $echo $0: error: java executable not found.
158        $echo
159        exit 1
160    fi
161
162    NXT_JAVA_LIB_PATH=`$NXT_JAVA -XshowSettings 2>&1 | grep -F -e sun.boot.library.path | sed -e 's/^.*= //'`
163
164    if [ -z "$NXT_JAVA_LIB_PATH" ]; then
165        $echo
166        $echo $0: error: library path not found.
167        $echo
168        exit 1
169    fi
170
171    NXT_JAVA_LIB_PATH="${NXT_JAVA_LIB_PATH}/server"
172
173    $echo " $NXT_JAVA_LIB_PATH"
174    $echo "got library path $NXT_JAVA_LIB_PATH" >> $NXT_AUTOCONF_ERR
175fi
176
177NXT_JAVA_LDFLAGS="-L${NXT_JAVA_LIB_PATH} -Wl,-rpath ${NXT_JAVA_LIB_PATH} -ljvm"
178
179
180nxt_found=no
181
182nxt_feature="JNI"
183nxt_feature_name=""
184nxt_feature_run=no
185nxt_feature_incs="${NXT_JAVA_INCLUDE}"
186nxt_feature_libs="${NXT_JAVA_LDFLAGS}"
187nxt_feature_test="
188    #include <jni.h>
189
190    int main() {
191        JNI_CreateJavaVM(NULL, NULL, NULL);
192        return 0;
193    }"
194
195. auto/feature
196
197
198if [ $nxt_found = no ]; then
199    $echo
200    $echo $0: error: no JNI found.
201    $echo
202    exit 1;
203fi
204
205NXT_JAVA_VERSION=`$NXT_JAVAC -version 2>&1`
206NXT_JAVA_VERSION=${NXT_JAVA_VERSION#javac }
207NXT_JAVA_INCLUDE="$NXT_JAVA_INCLUDE -I$NXT_BUILD_DIR/$NXT_JAVA_MODULE -DNXT_JAVA_VERSION=$NXT_JAVA_VERSION"
208
209if grep ^$NXT_JAVA_MODULE: $NXT_MAKEFILE 2>&1 > /dev/null; then
210    $echo
211    $echo $0: error: duplicate \"$NXT_JAVA_MODULE\" module configured.
212    $echo
213    exit 1;
214fi
215
216. ./version
217
218NXT_UNIT_JAR=nginx-unit-jsc-${NXT_JAVA_MODULE}-$NXT_VERSION.jar
219NXT_WS_API_JAR=websocket-api-${NXT_JAVA_MODULE}-$NXT_VERSION.jar
220
221NXT_JAVA_BUILD_CP=$NXT_BUILD_DIR/$NXT_JAVA_MODULE
222NXT_JAVA_INSTALL_JARS=
223NXT_JAVA_UNINSTALL_JARS=
224
225NXT_JAVA_JARS=$NXT_BUILD_DIR/$NXT_JAVA_MODULE/nxt_jars.h
226mkdir -p $NXT_BUILD_DIR/$NXT_JAVA_MODULE
227
228cat << END > $NXT_JAVA_JARS
229#ifndef _NXT_JAVA_JARS_INCLUDED_
230#define _NXT_JAVA_JARS_INCLUDED_
231
232#define NXT_JARS "$NXT_JARS"
233
234static const char *nxt_java_system_jars[] = {
235END
236
237NXT_TOMCAT_VERSION=9.0.13
238
239NXT_JAR_VERSION=$NXT_TOMCAT_VERSION
240
241NXT_JAR_NAME=tomcat-servlet-api
242NXT_JAR_NAMESPACE=org/apache/tomcat/
243. auto/modules/java_get_jar
244
245NXT_JAR_NAME=tomcat-el-api
246. auto/modules/java_get_jar
247
248NXT_JAR_NAME=tomcat-jsp-api
249. auto/modules/java_get_jar
250
251NXT_JAR_NAME=tomcat-jasper
252. auto/modules/java_get_jar
253
254NXT_JAR_NAME=tomcat-jasper-el
255. auto/modules/java_get_jar
256
257NXT_JAR_NAME=tomcat-juli
258. auto/modules/java_get_jar
259
260NXT_JAR_NAME=tomcat-api
261. auto/modules/java_get_jar
262
263NXT_JAR_NAME=tomcat-util-scan
264. auto/modules/java_get_jar
265
266NXT_JAR_NAME=tomcat-util
267. auto/modules/java_get_jar
268
269NXT_JAR_NAME=ecj
270NXT_JAR_VERSION=3.13.102
271NXT_JAR_NAMESPACE=org/eclipse/jdt/
272. auto/modules/java_get_jar
273
274cat << END >> $NXT_JAVA_JARS
275    "$NXT_WS_API_JAR",
276    NULL
277};
278
279static const char *nxt_java_unit_jars[] = {
280    "$NXT_UNIT_JAR",
281END
282
283NXT_JAR_VERSION=9.4.12.v20180830
284NXT_JAR_NAMESPACE=org/eclipse/jetty/
285
286NXT_JAR_NAME=jetty-util
287. auto/modules/java_get_jar
288
289NXT_JAR_NAME=jetty-server
290. auto/modules/java_get_jar
291
292NXT_JAR_NAME=jetty-http
293. auto/modules/java_get_jar
294
295NXT_JAR_NAME=classgraph
296NXT_JAR_VERSION=4.4.11
297NXT_JAR_NAMESPACE=io/github/classgraph/
298. auto/modules/java_get_jar
299
300cat << END >> $NXT_JAVA_JARS
301    NULL
302};
303
304#endif /* _NXT_JAVA_JARS_INCLUDED_ */
305END
306
307$echo " + Java module: ${NXT_JAVA_MODULE}.unit.so"
308
309. auto/cc/deps
310
311$echo >> $NXT_MAKEFILE
312
313NXT_JAVA_MODULE_SRCS=" \
314    src/nxt_java.c \
315    src/java/nxt_jni.c \
316    src/java/nxt_jni_Context.c \
317    src/java/nxt_jni_HeaderNamesEnumeration.c \
318    src/java/nxt_jni_HeadersEnumeration.c \
319    src/java/nxt_jni_InputStream.c \
320    src/java/nxt_jni_OutputStream.c \
321    src/java/nxt_jni_Request.c \
322    src/java/nxt_jni_Response.c \
323    src/java/nxt_jni_Thread.c \
324    src/java/nxt_jni_URLClassLoader.c \
325"
326
327# The Java module object files.
328
329nxt_objs=$NXT_BUILD_DIR/src/nxt_unit.o
330
331for nxt_src in $NXT_JAVA_MODULE_SRCS; do
332
333    nxt_obj=${nxt_src%.c}-$NXT_JAVA_MODULE.o
334    nxt_dep=${nxt_src%.c}-$NXT_JAVA_MODULE.dep
335    nxt_dep_flags=`nxt_gen_dep_flags`
336    nxt_dep_post=`nxt_gen_dep_post`
337    nxt_objs="$nxt_objs $NXT_BUILD_DIR/$nxt_obj"
338
339    cat << END >> $NXT_MAKEFILE
340
341$NXT_BUILD_DIR/$nxt_obj: $nxt_src $NXT_VERSION_H
342	mkdir -p $NXT_BUILD_DIR/src/java
343	\$(CC) -c \$(CFLAGS) \$(NXT_INCS) $NXT_JAVA_INCLUDE \\
344	$nxt_dep_flags \\
345	-o $NXT_BUILD_DIR/$nxt_obj $nxt_src
346	$nxt_dep_post
347
348-include $NXT_BUILD_DIR/$nxt_dep
349
350END
351
352done
353
354NXT_JAVA_SRCS=" \
355    src/java/nginx/unit/Context.java \
356    src/java/nginx/unit/DynamicDispatcherRequest.java \
357    src/java/nginx/unit/DynamicPathRequest.java \
358    src/java/nginx/unit/ForwardRequestWrapper.java \
359    src/java/nginx/unit/HeaderNamesEnumeration.java \
360    src/java/nginx/unit/HeadersEnumeration.java \
361    src/java/nginx/unit/IncludeRequestWrapper.java \
362    src/java/nginx/unit/IncludeResponseWrapper.java \
363    src/java/nginx/unit/InitParams.java \
364    src/java/nginx/unit/InputStream.java \
365    src/java/nginx/unit/JspPropertyGroup.java \
366    src/java/nginx/unit/OutputStream.java \
367    src/java/nginx/unit/Request.java \
368    src/java/nginx/unit/RequestAttrProxy.java \
369    src/java/nginx/unit/Response.java \
370    src/java/nginx/unit/Session.java \
371    src/java/nginx/unit/SessionAttrProxy.java \
372    src/java/nginx/unit/Taglib.java \
373    src/java/nginx/unit/UnitSessionCookieConfig.java \
374    src/java/nginx/unit/websocket/AsyncChannelGroupUtil.java \
375    src/java/nginx/unit/websocket/AsyncChannelWrapper.java \
376    src/java/nginx/unit/websocket/AsyncChannelWrapperNonSecure.java \
377    src/java/nginx/unit/websocket/AsyncChannelWrapperSecure.java \
378    src/java/nginx/unit/websocket/AuthenticationException.java \
379    src/java/nginx/unit/websocket/Authenticator.java \
380    src/java/nginx/unit/websocket/AuthenticatorFactory.java \
381    src/java/nginx/unit/websocket/BackgroundProcess.java \
382    src/java/nginx/unit/websocket/BackgroundProcessManager.java \
383    src/java/nginx/unit/websocket/BasicAuthenticator.java \
384    src/java/nginx/unit/websocket/Constants.java \
385    src/java/nginx/unit/websocket/DecoderEntry.java \
386    src/java/nginx/unit/websocket/DigestAuthenticator.java \
387    src/java/nginx/unit/websocket/FutureToSendHandler.java \
388    src/java/nginx/unit/websocket/MessageHandlerResult.java \
389    src/java/nginx/unit/websocket/MessageHandlerResultType.java \
390    src/java/nginx/unit/websocket/MessagePart.java \
391    src/java/nginx/unit/websocket/PerMessageDeflate.java \
392    src/java/nginx/unit/websocket/ReadBufferOverflowException.java \
393    src/java/nginx/unit/websocket/Transformation.java \
394    src/java/nginx/unit/websocket/TransformationFactory.java \
395    src/java/nginx/unit/websocket/TransformationResult.java \
396    src/java/nginx/unit/websocket/Util.java \
397    src/java/nginx/unit/websocket/WrappedMessageHandler.java \
398    src/java/nginx/unit/websocket/WsContainerProvider.java \
399    src/java/nginx/unit/websocket/WsExtension.java \
400    src/java/nginx/unit/websocket/WsExtensionParameter.java \
401    src/java/nginx/unit/websocket/WsFrameBase.java \
402    src/java/nginx/unit/websocket/WsFrameClient.java \
403    src/java/nginx/unit/websocket/WsHandshakeResponse.java \
404    src/java/nginx/unit/websocket/WsIOException.java \
405    src/java/nginx/unit/websocket/WsPongMessage.java \
406    src/java/nginx/unit/websocket/WsRemoteEndpointAsync.java \
407    src/java/nginx/unit/websocket/WsRemoteEndpointBase.java \
408    src/java/nginx/unit/websocket/WsRemoteEndpointBasic.java \
409    src/java/nginx/unit/websocket/WsRemoteEndpointImplBase.java \
410    src/java/nginx/unit/websocket/WsRemoteEndpointImplClient.java \
411    src/java/nginx/unit/websocket/WsSession.java \
412    src/java/nginx/unit/websocket/WsWebSocketContainer.java \
413    src/java/nginx/unit/websocket/pojo/Constants.java \
414    src/java/nginx/unit/websocket/pojo/PojoEndpointBase.java \
415    src/java/nginx/unit/websocket/pojo/PojoEndpointClient.java \
416    src/java/nginx/unit/websocket/pojo/PojoEndpointServer.java \
417    src/java/nginx/unit/websocket/pojo/PojoMessageHandlerBase.java \
418    src/java/nginx/unit/websocket/pojo/PojoMessageHandlerPartialBase.java \
419    src/java/nginx/unit/websocket/pojo/PojoMessageHandlerPartialBinary.java \
420    src/java/nginx/unit/websocket/pojo/PojoMessageHandlerPartialText.java \
421    src/java/nginx/unit/websocket/pojo/PojoMessageHandlerWholeBase.java \
422    src/java/nginx/unit/websocket/pojo/PojoMessageHandlerWholeBinary.java \
423    src/java/nginx/unit/websocket/pojo/PojoMessageHandlerWholePong.java \
424    src/java/nginx/unit/websocket/pojo/PojoMessageHandlerWholeText.java \
425    src/java/nginx/unit/websocket/pojo/PojoMethodMapping.java \
426    src/java/nginx/unit/websocket/pojo/PojoPathParam.java \
427    src/java/nginx/unit/websocket/pojo/package-info.java \
428    src/java/nginx/unit/websocket/server/Constants.java \
429    src/java/nginx/unit/websocket/server/DefaultServerEndpointConfigurator.java \
430    src/java/nginx/unit/websocket/server/UpgradeUtil.java \
431    src/java/nginx/unit/websocket/server/UriTemplate.java \
432    src/java/nginx/unit/websocket/server/WsContextListener.java \
433    src/java/nginx/unit/websocket/server/WsFilter.java \
434    src/java/nginx/unit/websocket/server/WsHandshakeRequest.java \
435    src/java/nginx/unit/websocket/server/WsHttpUpgradeHandler.java \
436    src/java/nginx/unit/websocket/server/WsMappingResult.java \
437    src/java/nginx/unit/websocket/server/WsPerSessionServerEndpointConfig.java \
438    src/java/nginx/unit/websocket/server/WsRemoteEndpointImplServer.java \
439    src/java/nginx/unit/websocket/server/WsSci.java \
440    src/java/nginx/unit/websocket/server/WsServerContainer.java \
441    src/java/nginx/unit/websocket/server/WsSessionListener.java \
442    src/java/nginx/unit/websocket/server/WsWriteTimeout.java \
443    src/java/nginx/unit/websocket/server/package-info.java \
444"
445
446NXT_JAVA_WS_API_SRCS=" \
447    src/java/javax/websocket/ClientEndpoint.java \
448    src/java/javax/websocket/ClientEndpointConfig.java \
449    src/java/javax/websocket/CloseReason.java \
450    src/java/javax/websocket/ContainerProvider.java \
451    src/java/javax/websocket/DecodeException.java \
452    src/java/javax/websocket/Decoder.java \
453    src/java/javax/websocket/DefaultClientEndpointConfig.java \
454    src/java/javax/websocket/DeploymentException.java \
455    src/java/javax/websocket/EncodeException.java \
456    src/java/javax/websocket/Encoder.java \
457    src/java/javax/websocket/Endpoint.java \
458    src/java/javax/websocket/EndpointConfig.java \
459    src/java/javax/websocket/Extension.java \
460    src/java/javax/websocket/HandshakeResponse.java \
461    src/java/javax/websocket/MessageHandler.java \
462    src/java/javax/websocket/OnClose.java \
463    src/java/javax/websocket/OnError.java \
464    src/java/javax/websocket/OnMessage.java \
465    src/java/javax/websocket/OnOpen.java \
466    src/java/javax/websocket/PongMessage.java \
467    src/java/javax/websocket/RemoteEndpoint.java \
468    src/java/javax/websocket/SendHandler.java \
469    src/java/javax/websocket/SendResult.java \
470    src/java/javax/websocket/Session.java \
471    src/java/javax/websocket/SessionException.java \
472    src/java/javax/websocket/WebSocketContainer.java \
473    src/java/javax/websocket/server/DefaultServerEndpointConfig.java \
474    src/java/javax/websocket/server/HandshakeRequest.java \
475    src/java/javax/websocket/server/PathParam.java \
476    src/java/javax/websocket/server/ServerApplicationConfig.java \
477    src/java/javax/websocket/server/ServerContainer.java \
478    src/java/javax/websocket/server/ServerEndpoint.java \
479    src/java/javax/websocket/server/ServerEndpointConfig.java \
480"
481
482cat << END >> $NXT_MAKEFILE
483
484.PHONY: ${NXT_JAVA_MODULE}
485.PHONY: ${NXT_JAVA_MODULE}-install
486.PHONY: ${NXT_JAVA_MODULE}-uninstall
487
488all: ${NXT_JAVA_MODULE}
489
490${NXT_JAVA_MODULE}: $NXT_BUILD_DIR/${NXT_JAVA_MODULE}.unit.so \
491    $NXT_BUILD_DIR/$NXT_UNIT_JAR \
492    $NXT_BUILD_DIR/$NXT_WS_API_JAR
493
494$NXT_BUILD_DIR/${NXT_JAVA_MODULE}.unit.so: $nxt_objs
495	\$(NXT_MODULE_LINK) -o $NXT_BUILD_DIR/${NXT_JAVA_MODULE}.unit.so \\
496	$nxt_objs $NXT_JAVA_LDFLAGS $NXT_LD_OPT
497
498
499install: ${NXT_JAVA_MODULE}-install
500
501${NXT_JAVA_MODULE}-install: $NXT_BUILD_DIR/${NXT_JAVA_MODULE}.unit.so \\
502    $NXT_BUILD_DIR/$NXT_UNIT_JAR \\
503    $NXT_BUILD_DIR/$NXT_WS_API_JAR \\
504    java-shared-install
505	install -d \$(DESTDIR)$NXT_MODULES
506	install -p $NXT_BUILD_DIR/${NXT_JAVA_MODULE}.unit.so \\
507		\$(DESTDIR)$NXT_MODULES/
508	install -d \$(DESTDIR)$NXT_JARS
509	install -p -m 0644 $NXT_BUILD_DIR/$NXT_UNIT_JAR \$(DESTDIR)$NXT_JARS/
510	install -p -m 0644 $NXT_BUILD_DIR/$NXT_WS_API_JAR \$(DESTDIR)$NXT_JARS/
511
512
513uninstall: ${NXT_JAVA_MODULE}-uninstall
514
515${NXT_JAVA_MODULE}-uninstall: java-shared-uninstall
516	rm -f \$(DESTDIR)$NXT_MODULES/${NXT_JAVA_MODULE}.unit.so
517	@rmdir -p \$(DESTDIR)$NXT_MODULES 2>/dev/null || true
518	rm -f \$(DESTDIR)$NXT_JARS/$NXT_UNIT_JAR
519	rm -f \$(DESTDIR)$NXT_JARS/$NXT_WS_API_JAR
520	@rmdir -p \$(DESTDIR)$NXT_JARS 2>/dev/null || true
521
522END
523
524if ! grep ^$NXT_BUILD_DIR/$NXT_UNIT_JAR: $NXT_MAKEFILE 2>&1 > /dev/null; then
525
526    cat << END >> $NXT_MAKEFILE
527
528NXT_JAVA_SRCS = $NXT_JAVA_SRCS
529
530$NXT_BUILD_DIR/$NXT_JAVA_MODULE/.nginx.unit.classes: \$(NXT_JAVA_SRCS) \\
531    $NXT_BUILD_DIR/$NXT_WS_API_JAR
532	rm -rf $NXT_BUILD_DIR/$NXT_JAVA_MODULE/nginx/unit
533	$NXT_JAVAC -d $NXT_BUILD_DIR/$NXT_JAVA_MODULE \\
534		-cp $NXT_JAVA_BUILD_CP:$NXT_BUILD_DIR/$NXT_WS_API_JAR \\
535		\$(NXT_JAVA_SRCS)
536	touch \$@
537
538$NXT_BUILD_DIR/$NXT_JAVA_MODULE/META-INF/LICENSE: LICENSE
539	mkdir -p $NXT_BUILD_DIR/$NXT_JAVA_MODULE/META-INF
540	cp -p LICENSE \$@
541
542$NXT_BUILD_DIR/$NXT_JAVA_MODULE/META-INF/NOTICE: NOTICE
543	mkdir -p $NXT_BUILD_DIR/$NXT_JAVA_MODULE/META-INF
544	cp -p NOTICE \$@
545
546$NXT_BUILD_DIR/$NXT_UNIT_JAR: \\
547    $NXT_BUILD_DIR/$NXT_JAVA_MODULE/.nginx.unit.classes \\
548    $NXT_BUILD_DIR/$NXT_JAVA_MODULE/META-INF/LICENSE \\
549    $NXT_BUILD_DIR/$NXT_JAVA_MODULE/META-INF/NOTICE
550	$NXT_JAVA_HOME/bin/jar c -C $NXT_BUILD_DIR/$NXT_JAVA_MODULE META-INF \\
551		-C $NXT_BUILD_DIR/$NXT_JAVA_MODULE nginx/unit > \$@
552
553NXT_JAVA_WS_API_SRCS = $NXT_JAVA_WS_API_SRCS
554
555$NXT_BUILD_DIR/$NXT_JAVA_MODULE/.javax.websocket.classes: \$(NXT_JAVA_WS_API_SRCS)
556	rm -rf $NXT_BUILD_DIR/$NXT_JAVA_MODULE/javax/websocket
557	$NXT_JAVAC -d $NXT_BUILD_DIR/$NXT_JAVA_MODULE -cp $NXT_JAVA_BUILD_CP \\
558		\$(NXT_JAVA_WS_API_SRCS)
559	touch \$@
560
561$NXT_BUILD_DIR/$NXT_WS_API_JAR: \\
562    $NXT_BUILD_DIR/$NXT_JAVA_MODULE/.javax.websocket.classes \\
563    $NXT_BUILD_DIR/$NXT_JAVA_MODULE/META-INF/LICENSE \\
564    $NXT_BUILD_DIR/$NXT_JAVA_MODULE/META-INF/NOTICE
565	$NXT_JAVA_HOME/bin/jar c -C $NXT_BUILD_DIR/$NXT_JAVA_MODULE META-INF \\
566		-C $NXT_BUILD_DIR/$NXT_JAVA_MODULE javax/websocket > \$@
567
568END
569
570NXT_PROPS="\
571    nginx/unit/websocket/LocalStrings.properties \
572    nginx/unit/websocket/pojo/LocalStrings.properties \
573    nginx/unit/websocket/server/LocalStrings.properties \
574"
575
576for nxt_prop in $NXT_PROPS ; do
577
578    cat << END >> $NXT_MAKEFILE
579$NXT_BUILD_DIR/$NXT_JAVA_MODULE/$nxt_prop: src/java/$nxt_prop \\
580    $NXT_BUILD_DIR/$NXT_JAVA_MODULE/.nginx.unit.classes
581	cp src/java/$nxt_prop \$@
582
583$NXT_BUILD_DIR/$NXT_UNIT_JAR: $NXT_BUILD_DIR/$NXT_JAVA_MODULE/$nxt_prop
584
585END
586
587done
588
589fi
590
591if ! grep ^java-shared-install: $NXT_MAKEFILE 2>&1 > /dev/null; then
592
593    cat << END >> $NXT_MAKEFILE
594
595.PHONY: java-shared-install
596.PHONY: java-shared-uninstall
597
598java-shared-install: $NXT_JAVA_INSTALL_JARS
599	install -d \$(DESTDIR)$NXT_JARS
600	install -p -m 0644 $NXT_JAVA_INSTALL_JARS \$(DESTDIR)$NXT_JARS/
601
602java-shared-uninstall:
603	rm -f $NXT_JAVA_UNINSTALL_JARS
604	@rmdir -p \$(DESTDIR)$NXT_JARS 2>/dev/null || true
605
606END
607
608fi
609