1#
2# Copyright (C) Mellanox Technologies Ltd. 2019.  ALL RIGHTS RESERVED.
3# See file LICENSE for terms.
4#
5
6if HAVE_JAVA
7
8jardir         = $(libdir)
9topdir         = $(abs_top_builddir)
10java_build_dir = $(builddir)/build-java
11jarfile        = $(java_build_dir)/jucx-@VERSION@.jar
12javadir        = $(top_srcdir)/bindings/java
13
14MVNCMD = $(MVN) -B -T 1C -f \
15         $(topdir)/bindings/java/pom.xml \
16         -Dmaven.repo.local=$(java_build_dir)/.deps \
17         -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn
18
19JUCX_GENERATED_H_FILES = org_openucx_jucx_ucp_UcpConstants.h             \
20                         org_openucx_jucx_ucp_UcpContext.h               \
21                         org_openucx_jucx_ucp_UcpEndpoint.h              \
22                         org_openucx_jucx_ucp_UcpListener.h              \
23                         org_openucx_jucx_ucp_UcpMemory.h                \
24                         org_openucx_jucx_ucp_UcpRequest.h               \
25                         org_openucx_jucx_ucp_UcpRemoteKey.h             \
26                         org_openucx_jucx_ucp_UcpWorker.h                \
27                         org_openucx_jucx_ucs_UcsConstants_ThreadMode.h  \
28                         org_openucx_jucx_ucs_UcsConstants.h
29
30BUILT_SOURCES = $(JUCX_GENERATED_H_FILES)
31
32STAMP_FILE = native_headers.stamp
33
34MOSTLYCLEANFILES = $(JUCX_GENERATED_H_FILES) $(STAMP_FILE)
35
36#
37# Create a timestamp file to avoid regenerating header files every time
38# See https://www.gnu.org/software/automake/manual/html_node/Multiple-Outputs.html
39#
40$(STAMP_FILE): \
41		$(javadir)/src/main/java/org/openucx/jucx/ucs/*.java \
42		$(javadir)/src/main/java/org/openucx/jucx/ucp/*.java
43	$(MVNCMD) compile
44	touch $(STAMP_FILE)
45
46$(JUCX_GENERATED_H_FILES): $(STAMP_FILE)
47
48lib_LTLIBRARIES = libjucx.la
49
50libjucx_la_CPPFLAGS = -I$(JDK)/include -I$(JDK)/include/linux \
51                      -I$(topdir)/src -I$(top_srcdir)/src
52
53noinst_HEADERS = jucx_common_def.h
54
55libjucx_la_SOURCES = context.cc \
56                     endpoint.cc \
57                     jucx_common_def.cc \
58                     listener.cc \
59                     memory.cc \
60                     request.cc \
61                     ucp_constants.cc \
62                     ucs_constants.cc \
63                     worker.cc
64
65libjucx_la_CXXFLAGS = -fPIC -DPIC -Werror -std=gnu++98
66
67libjucx_la_LIBADD = $(topdir)/src/ucs/libucs.la \
68                    $(topdir)/src/uct/libuct.la \
69                    $(topdir)/src/ucm/libucm.la \
70                    $(topdir)/src/ucp/libucp.la
71
72libjucx_la_DEPENDENCIES = Makefile.am Makefile.in Makefile
73
74# Compile Java source code and pack to jar
75$(jarfile):
76	$(MVNCMD) package -DskipTests
77
78package : $(jarfile)
79
80.PHONY: package
81
82# Maven install phase
83jar_DATA = $(jarfile)
84
85# Remove all compiled Java files
86clean-local:
87	-rm -rf $(java_build_dir)
88
89set-version:
90	$(MVNCMD) versions:set -DnewVersion=${JUCX_VERSION}
91
92# Publish JUCX jar to maven central
93publish-snapshot:
94	@make set-version JUCX_VERSION=@VERSION@-SNAPSHOT
95	@make publish
96
97publish-release:
98	@make set-version JUCX_VERSION=${JUCX_VERSION}
99	@make publish
100
101publish:
102	$(MVNCMD) deploy -DskipTests ${ARGS}
103
104test:
105	$(MVNCMD) test -DargLine="-XX:OnError='cat hs_err_pid%p.log'"
106docs:
107	$(MVNCMD) javadoc:javadoc
108
109endif
110