@@ -65,33 +65,65 @@ If building a wolfSSL FIPS or FIPS Ready release bundle, additional
6565configure options may be required. Reference the wolfSSL Manual and build
6666documentation for exact build instructions.
6767
68- ## Building with ant
68+ ## Building and testing with make/ ant
6969
7070wolfSSL JNI/JSSE's ant build is the most stable and well-tested. Newer support
7171for building with Maven has also been added. See section below for instructions
7272on building with Maven.
7373
74- *** Note 1)***
75- The ` java.sh ` script uses a common location for the Java install location. If
76- your Java install location is different, this could lead to an error when
77- running ` java.sh ` . In this case, you should modify ` java.sh ` to match your
78- environment.
79-
80- Build targets for ant are :
81- * ** ant build (ant)** (only builds the jar necessary for an app to use)
82- * ** ant test** (builds the jar and tests then runs the tests, requires JUNIT setup)
83- * ** ant examples** (builds the jar and example cases)
84- * ** ant clean** (cleans all Java artifacts)
85- * ** ant cleanjni** (cleans native artifacts)
74+ The ` Makefile ` compiles the native JNI shared library
75+ (` libwolfssljni.so ` /` libwolfssljni.dylib ` ) and invokes ` ant ` to build the Java
76+ sources. It will auto-detect ` JAVA_HOME ` if not already set. To explicitly
77+ specify a Java installation, set ` JAVA_HOME ` before running ` make ` .
78+
79+ Make targets:
80+ * ** make** / ** make build** - Compiles the native JNI library and Java sources (JAR)
81+ * ** make check** - Builds and runs JUnit tests (requires ` JUNIT_HOME ` )
82+ * ** make native** - Compiles only the native JNI shared library
83+ * ** make clean** - Cleans all Java and native artifacts
84+ * ** make clean-native** - Cleans only native artifacts (` .o ` , ` .d ` , shared lib)
85+ * ** make install** - Installs shared library and JARs
86+ * ** make uninstall** - Removes installed files
87+
88+ Ant-only targets are also available:
89+ * ** ant build (ant)** - Only builds the JAR
90+ * ** ant test** - Builds and runs tests (requires JUNIT setup)
91+ * ** ant examples** - Builds examples
92+ * ** ant clean** - Cleans Java artifacts
93+ * ** ant cleanjni** - Cleans native artifacts
8694
8795To build wolfJSSE:
8896
8997```
9098$ cd wolfssljni
91- $ ./java.sh
92- $ ant
9399$ export JUNIT_HOME=/path/to/junit/jars
94- $ ant test
100+ $ make build
101+ $ make check
102+ ```
103+
104+ Custom wolfSSL installation directories and library names can be passed to
105+ ` make ` :
106+
107+ ```
108+ $ make WOLFSSL_INSTALL_DIR=/path/to/wolfssl WOLFSSL_LIBNAME=wolfssljsse
109+ ```
110+
111+ Set ` V=1 ` to see the full compiler commands:
112+
113+ ```
114+ $ make V=1
115+ ```
116+
117+ Set ` ENABLE_PATCHES=1 ` to automatically detect and enable JNI code that
118+ depends on wolfSSL pull request patches (` WOLFSSL_PR*_PATCH_APPLIED ` defines).
119+ This enables functionality and test coverage for features added since the last
120+ official wolfSSL build.
121+
122+ ** Note:** this requires a recent build of wolfSSL with the PR included, often
123+ newer than the latest tagged release.
124+
125+ ```
126+ $ make ENABLE_PATCHES=1
95127```
96128
97129To compile and run the examples, use the ` ant examples ` target:
@@ -108,28 +140,20 @@ $ ./examples/provider/ServerJSSE.sh
108140$ ./examples/provider/ClientJSSE.sh
109141```
110142
111- ### java.sh Script Options
112-
113- The ` java.sh ` script compiles the native JNI sources into a shared library named
114- either ` libwolfssljni.so ` (Linux/Unix) or ` libwolfssljni.dylib ` (MacOS).
115- Compiling on Linux/Unix and Mac OSX are currently supported.
143+ ### java.sh Script
116144
117- This script will attempt to auto-detect the ` JAVA_HOME ` location if not set.
118- To explicitly use a Java home location, set the ` JAVA_HOME ` environment variable
119- prior to running this script.
145+ The ` java.sh ` script is a convenience wrapper around the Makefile that compiles
146+ the native JNI sources into a shared library named either ` libwolfssljni.so `
147+ (Linux/Unix) or ` libwolfssljni.dylib ` (MacOS). It invokes ` make clean-native `
148+ followed by ` make native ` , performing a clean rebuild of the native library each
149+ time.
120150
121- This script will try to link against a wolfSSL library installed to the
122- default location of ` /usr/local ` . This script accepts two arguments on the
123- command line. The first argument can point to a custom wolfSSL installation
124- location. A custom install location would match the directory set at wolfSSL
125- ` ./configure --prefix=<DIR> ` .
151+ The script accepts two optional arguments:
126152
127- The second argument represents the wolfSSL library name that should be
128- linked against. This is helpful if a non-standard library name has been
129- used with wolfSSL, for example the ` ./configure --with-libsuffix ` option
130- has been used to add a suffix to the wolfSSL library name. Note that to
131- use this argument, an installation location must be specified via the
132- first argument.
153+ 1 . ** wolfSSL installation directory** (default: ` /usr/local ` ) - should match
154+ the directory set at wolfSSL ` ./configure --prefix=<DIR> ` .
155+ 2 . ** wolfSSL library name** (default: ` wolfssl ` ) - useful if a non-standard
156+ library name has been used, for example via ` ./configure --with-libsuffix ` .
133157
134158For example, if wolfSSL was configured with ` --with-libsuffix=jsse ` , then
135159this script could be called like so using the default installation
@@ -139,8 +163,7 @@ path of `/usr/local`:
139163java.sh /usr/local wolfssljsse
140164```
141165
142- ` java.sh ` can use preset ` CFLAGS ` defines, if set in the environment variable
143- prior to running the script, for example:
166+ ` CFLAGS ` can be set in the environment prior to running the script:
144167
145168```
146169CFLAGS=-DWOLFJNI_USE_IO_SELECT java.sh
@@ -153,12 +176,11 @@ are already set up to use and consume Maven packages.
153176
154177wolfJSSE's Maven build configuration is defined in the included ` pom.xml ` .
155178
156- First, compile the native JNI shared library (libwolfssljni.so/dylib) same
157- as above. This will create the native JNI shared library under the ` ./lib `
158- directory:
179+ First, compile the native JNI shared library (libwolfssljni.so/dylib). This
180+ will create the native JNI shared library under the ` ./lib ` directory:
159181
160182```
161- $ ./java.sh
183+ $ make native
162184```
163185
164186Compile the Java sources, where Maven will place the compiled ` .class ` files
@@ -202,10 +224,10 @@ The local Maven repository installation location will be similar to:
202224~/.m2/repository/com/wolfssl/wolfssl-jsse/X.X.X-SNAPSHOT/wolfssl-jsse-X.X.X-SNAPSHOT.jar
203225```
204226
205- The wolfSSL JNI shared library (` libwolfssljni.so/dylib ` ) created with the
206- ` java.sh ` script will need to be "installed" by being placed on your native
227+ The wolfSSL JNI shared library (` libwolfssljni.so/dylib ` ) will need to be
228+ "installed" by being placed on your native
207229library search path. For example, copied into ` /usr/local/lib ` , ` /usr/lib ` ,
208- or other location. Alternatively, append the ` ./libs ` directory to your native
230+ or other location. Alternatively, append the ` ./lib ` directory to your native
209231library search path by exporting ` LD_LIBRARY_PATH ` (Linux) or
210232` DYLD_LIBRARY_PATH ` (OSX):
211233
@@ -261,15 +283,14 @@ Maven builds support automatic module-info compilation.
261283
262284```
263285$ export JAVA_HOME=/path/to/jdk11 # or any JDK 9+
264- $ ./java.sh
265- $ ant
286+ $ make build
266287```
267288
268289** Using Maven:**
269290
270291```
271292$ export JAVA_HOME=/path/to/jdk11 # or any JDK 9+
272- $ ./java.sh
293+ $ make native
273294$ mvn package
274295```
275296
@@ -494,7 +515,8 @@ file descriptors inside Java Socket objects. These native file descriptors
494515are watched for read and write events with either ` select() ` or ` poll() ` .
495516
496517By default ` poll() ` will be used, unless ` WOLFJNI_USE_IO_SELECT ` is defined
497- or added to CFLAGS when compiling the native JNI sources (see ` java.sh ` ).
518+ or added to CFLAGS when compiling the native JNI sources (e.g.
519+ ` make CFLAGS=-DWOLFJNI_USE_IO_SELECT ` ).
498520Windows builds will also default to using ` select() ` since ` poll() ` is not
499521available there.
500522
@@ -698,14 +720,14 @@ legacy behavior where SNI is automatically configured from hostname/peer informa
698720even without explicit SSLParameters configuration. Default value is "false", where
699721SNI is only set when explicitly configured through SSLParameters.
700722
701- ** wolfssl.skipLibraryLoad (boolean)** - When set to "true", ` WolfSSL .loadLibrary()`
723+ ** wolfssl.skipLibraryLoad (boolean)** - When set to "true", ` wolfSSL .loadLibrary()`
702724will skip the default ` System.loadLibrary() ` calls for native wolfSSL and
703725wolfSSL JNI libraries. This is useful when applications need to load the native
704726libraries themselves using custom logic, for example when bundling the native
705727library inside a JAR file and extracting it at runtime. The property must be set
706- before ` WolfSSL .loadLibrary()` is called, either directly or via
728+ before ` wolfSSL .loadLibrary()` is called, either directly or via
707729` WolfSSLProvider() ` constructor. Applications can check if library loading was
708- skipped by calling ` WolfSSL .isLibraryLoadSkipped()` .
730+ skipped by calling ` wolfSSL .isLibraryLoadSkipped()` .
709731
710732Setting via command line:
711733
@@ -722,8 +744,8 @@ System.setProperty("wolfssl.skipLibraryLoad", "true");
722744System . load(" /path/to/libwolfssl.so" );
723745System . load(" /path/to/libwolfssljni.so" );
724746
725- /* Then use WolfSSL as normal */
726- WolfSSL . loadLibrary();
747+ /* Then use wolfSSL as normal */
748+ wolfSSL . loadLibrary();
727749```
728750
729751If there are other System properties you would like to use with wolfJSSE,
0 commit comments