[PATCH/RFC 5/6] buildsys: Add JNI to libopenconnect build

Kevin Cernekee cernekee at gmail.com
Mon Aug 5 01:25:58 EDT 2013


If the user runs "configure --with-jni", Java native interface stubs are
built into the library and it can be loaded with:

    System.loadLibrary("openconnect");

Signed-off-by: Kevin Cernekee <cernekee at gmail.com>
---
 Makefile.am           |    5 +++++
 configure.ac          |   25 +++++++++++++++++++++++++
 libopenconnect.map.in |    5 +++++
 3 files changed, 35 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index ef7a906..ea3d925 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -48,6 +48,11 @@ libopenconnect_la_LDFLAGS += -Wl, at VERSION_SCRIPT_ARG@,libopenconnect.map
 libopenconnect_la_DEPENDENCIES = libopenconnect.map
 endif
 
+if OPENCONNECT_JNI
+libopenconnect_la_SOURCES += jni.c
+libopenconnect_la_CFLAGS += $(JNI_CFLAGS)
+endif
+
 pkgconfig_DATA = openconnect.pc
 
 EXTRA_DIST = version.sh COPYING.LGPL $(lib_srcs_openssl) $(lib_srcs_gnutls)
diff --git a/configure.ac b/configure.ac
index 357b001..02f932f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -544,6 +544,31 @@ AS_IF([test "x$with_liboath" != "xno"], [
 		 liboath_pkg=no)
 ])
 
+AC_ARG_WITH([jni],
+	AS_HELP_STRING([--with-jni],
+	[Build JNI hooks into library [default=no]]))
+
+if test "$with_jni" = "yes"; then
+	AX_JNI_INCLUDE_DIR
+	for JNI_INCLUDE_DIR in $JNI_INCLUDE_DIRS; do
+		  JNI_CFLAGS="$JNI_CFLAGS -I$JNI_INCLUDE_DIR"
+	done
+
+	oldCFLAGS="$CFLAGS"
+	CFLAGS="$CFLAGS $JNI_CFLAGS"
+	AC_MSG_CHECKING([jni.h usability])
+	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <jni.h>],
+		[jint foo = 0; (void)foo;])],
+		AC_MSG_RESULT([yes]),
+		[AC_MSG_RESULT([no])
+		 AC_MSG_ERROR([unable to compile JNI test program])])
+	CFLAGS="$oldCFLAGS"
+
+	AC_SUBST(JNI_CFLAGS, [$JNI_CFLAGS])
+fi
+
+AM_CONDITIONAL(OPENCONNECT_JNI, [test "$JNI_CFLAGS" != ""])
+
 AC_CHECK_HEADER([if_tun.h],
     [AC_DEFINE([IF_TUN_HDR], ["if_tun.h"])],
     [AC_CHECK_HEADER([linux/if_tun.h],
diff --git a/libopenconnect.map.in b/libopenconnect.map.in
index 16d3380..7db094d 100644
--- a/libopenconnect.map.in
+++ b/libopenconnect.map.in
@@ -43,6 +43,11 @@ OPENCONNECT_2.2 {
 	openconnect_set_token_mode;
 } OPENCONNECT_2.1;
 
+OPENCONNECT_JNI {
+ global:
+	Java_*;
+};
+
 OPENCONNECT_PRIVATE {
  global: @SYMVER_TIME@ @SYMVER_ASPRINTF@ @SYMVER_GETLINE@ @SYMVER_PRINT_ERR@
 	openconnect_SSL_gets;
-- 
1.7.9.5




More information about the openconnect-devel mailing list