diff --git a/README.md b/README.md index da2785a..2bb163e 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ The implementation is written in C99 and is distributed under the 2-clause BSD license. Additionally, bindings are available for **Lua** and **Java**. -There is a specification to build an RPM package. +Specifications to build RPM and DEB packages are also provided. ## API @@ -49,7 +49,9 @@ There is a specification to build an RPM package. provide at least 4 or 16 bytes (depending on the address family). Returns zero on success and -1 on failure. -## Lua example +## Examples + +### Lua ```lua local lpm = require("lpm") @@ -67,6 +69,12 @@ local ret = acl:lookup(lpm.tobin("10.0.0.100")) print(ret.val) ``` +### Java + +See [README](src/jni) how to build the JAR and the +[test case](src/jni/org/netbsd/liblpm/LPMTest.java) as example +how to use the Java API + ## Packages Just build the package, install it and link the library using the diff --git a/src/jni/Makefile b/src/jni/Makefile index 61341c2..9780c3f 100644 --- a/src/jni/Makefile +++ b/src/jni/Makefile @@ -2,9 +2,11 @@ # This file is in the Public Domain. # -CFLAGS= -std=gnu99 -O2 -g -W -Wextra -Werror -D_BSD_SOURCE -CFLAGS+= -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -CFLAGS+= -Wshadow -Wcast-qual -Wwrite-strings +CFLAGS+= -std=c99 -O2 -g -Wall -Wextra -Werror +CFLAGS+= -D_POSIX_C_SOURCE=200809L +CFLAGS+= -D_GNU_SOURCE -D_DEFAULT_SOURCE + +CFLAGS+= -Wno-unused-parameter ifeq ($(MAKECMDGOALS),tests) DEBUG= 1 diff --git a/src/jni/README.md b/src/jni/README.md new file mode 100644 index 0000000..0337475 --- /dev/null +++ b/src/jni/README.md @@ -0,0 +1,17 @@ +# LPM library Java bindings + +## Building + +The below is an example of building on Debian 10. Set the `JAVA_HOME` +according to your JDK version and system. + +```shell +$ uname -srv +Linux 4.9.0-9-amd64 #1 SMP Debian 4.9.168-1 (2019-04-12) +$ sudo apt-get install openjdk-8-jre-headless openjdk-8-jdk-headless +... +$ cd liblpm/src/jni +$ JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 make test +``` + +This will produce the `liblpm.jar` file. Use it in your project.