Skip to content

Commit 284f20d

Browse files
Update readme
1 parent e398bb2 commit 284f20d

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

README.markdown

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,43 @@ Syntax
2929
--cflags CFLAGS to use when compiling a JNI library
3030
--ldflags LDFLAGS to use when linking to the jvm
3131
32+
Example Usage
33+
-------------
34+
I wrote this tool primarily to aid in building JNI libraries. All of the other options are present because they are easy to get at and I was forever writing little one liner java programs to pull them out of the system properties.
35+
36+
Here is an example Linux makefile for building a shared library:
37+
38+
JAVA_CMD ?= java
39+
CFLAGS ?= -O3
40+
FREETYPE_CFLAGS ?= $(shell freetype-config --cflags)
41+
JAVA_CFLAGS ?= $(shell $(JAVA_CMD) -jar java-config.jar --cflags)
42+
43+
44+
libmapnik-jni.so: mapnikjni.cpp mapnikjni.h
45+
g++ -o libmapnik-jni.so \
46+
-fPIC -shared \
47+
$(CFLAGS) \
48+
$(FREETYPE_CFLAGS) \
49+
$(JAVA_CFLAGS) \
50+
mapnikjni.cpp \
51+
$(LDFLAGS) \
52+
-lmapnik2
53+
54+
And here is an example OSX makefile for building a jnilib:
55+
JAVA_CMD ?= java
56+
CFLAGS ?= -O3
57+
FREETYPE_CFLAGS ?= $(shell freetype-config --cflags)
58+
JAVA_CFLAGS ?= $(shell $(JAVA_CMD) -jar java-config.jar --cflags)
59+
60+
61+
libmapnik-jni.jnilib: mapnikjni.cpp mapnikjni.h
62+
g++ -dynamiclib -o libmapnik-jni.jnilib \
63+
$(CFLAGS) \
64+
$(FREETYPE_CFLAGS) \
65+
$(JAVA_CFLAGS) \
66+
mapnikjni.cpp \
67+
$(LDFLAGS) \
68+
-lmapnik2 -framework JavaVM
69+
70+
I used to use autoconf or other such craziness for this stuff, but JNI libraries are usually simple enough to require just quick incantations like the above. Bundling the java-config.jar with your source and using it to discover compilation options on the fly makes it all self-configuring.
71+

0 commit comments

Comments
 (0)