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