From: Adam Dickmeiss Date: Tue, 22 Sep 2009 08:48:31 +0000 (+0200) Subject: Maven calls make for native code. X-Git-Tag: v1.0~11 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=aec620258c1110cf27ae097c1e1a1303aff21d6c;p=yaz4j-moved-to-github.git Maven calls make for native code. The maven-antrun-plugin is used to invoke make from Maven. The shell scripts is replaced by a regular Makefile. --- diff --git a/README b/README index e4b4b2d..00262cd 100644 --- a/README +++ b/README @@ -13,16 +13,12 @@ The exact process varies from platform to platform. For example, on Ubuntu/Debian the following installs the components: apt-get install sun-java6-jdk maven2 libyaz3-dev swig -The compilation is a two-step process. The environment variable JAVA_HOME -should point to the Java JDK of your preference. For example, - export JAVA_HOME=/usr/lib/jvm/java-6-sun +The compilation for native code (JNI) is performed by good old make. +Adjust libyaz4j/Makefile as necessary. Tune JAVA_HOME and perhaps path to +yaz-config in the Makefile. -Build the shared libary (.so) with: - cd libyaz4j - ./build.sh - -Rest is built by maven which reads pom.xml: - cd .. +The Maven pom.xml will automatically invoke libyaz4j/Makefile , so +this is what it takes: mvn compile If you network-connected you should be able to run tests with: diff --git a/libyaz4j/Makefile b/libyaz4j/Makefile new file mode 100644 index 0000000..d151414 --- /dev/null +++ b/libyaz4j/Makefile @@ -0,0 +1,22 @@ +JNI_DIR=/usr/lib/jvm/java-6-sun/include +YAZ_CONFIG=yaz-config +YAZ_PREFIX=`${YAZ_CONFIG} --prefix` +YAZ_CFLAGS=`${YAZ_CONFIG} --cflags` +YAZ_LIBS=`${YAZ_CONFIG} --libs` + +all: lib/libyaz4j.so + +src/libyaz4j.cpp: libyaz4j.i + swig -I"include" -I"$(YAZ_PREFIX)/include" -outdir ../src/main/java/org/yaz4j/jni -package org.yaz4j.jni -o src/libyaz4j.cpp -c++ -java libyaz4j.i + +obj/libyaz4j.o: src/libyaz4j.cpp + g++ -fPIC -I"include" -I"$(JNI_DIR)" -I"$(JNI_DIR)/linux" $(YAZ_CFLAGS) -c -Wall -o obj/libyaz4j.o src/libyaz4j.cpp + +obj/zoom-extra.o: src/zoom-extra.cpp + g++ -fPIC -I"include" -I"$(JNI_DIR)" -I"$(JNI_DIR)/linux" $(YAZ_CFLAGS) -c -Wall -o obj/zoom-extra.o src/zoom-extra.cpp + +lib/libyaz4j.so: obj/zoom-extra.o obj/libyaz4j.o + g++ -shared obj/libyaz4j.o obj/zoom-extra.o -o lib/libyaz4j.so $(YAZ_LIBS) + +clean: + rm -f obj/*.o lib/libyaz4j.* src/libyaz4j.cpp ../src/main/java/org/jni/*.java diff --git a/libyaz4j/build-osx.sh b/libyaz4j/build-osx.sh deleted file mode 100755 index 00bb8a2..0000000 --- a/libyaz4j/build-osx.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -echo Swigging the Zoom Headers -swig -I"include" -I"../dependencies/yaz-2.1.28/include/yaz" -I"../dependencies/yaz-2.1.28/include" -outdir ../src/org/yaz4j/jni -package org.yaz4j.jni -o src/libyaz4j.cpp -c++ -java libyaz4j.i - -echo Compiling... -g++ -I"include" -I"/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Headers" -I"../dependencies/yaz-2.1.28/include/yaz" -I"../dependencies/yaz-2.1.28/include" -Wall -c -o obj/libyaz4j.o src/libyaz4j.cpp - -g++ -I"include" -I"/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Headers" -I"../dependencies/yaz-2.1.28/include/yaz" -I"../dependencies/yaz-2.1.28/include" -Wall -c -o obj/zoom-extra.o src/zoom-extra.c - -echo Linking... -g++ -L"../dependencies/yaz-2.1.28/lib" obj/zoom-extra.o obj/libyaz4j.o -lyaz -bundle -o lib/libyaz4j.so - diff --git a/libyaz4j/build.sh b/libyaz4j/build.sh deleted file mode 100755 index d4687ad..0000000 --- a/libyaz4j/build.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -JNI_DIR=${JAVA_HOME:-/usr/lib/jvm/java-6-sun}/include -set -x -YAZ_CONFIG=yaz-config -YAZ_PREFIX=`${YAZ_CONFIG} --prefix` -YAZ_CFLAGS=`${YAZ_CONFIG} --cflags` -YAZ_LIBS=`${YAZ_CONFIG} --libs` - -swig -I"include" -I"${YAZ_PREFIX}/include" -outdir ../src/main/java/org/yaz4j/jni -package org.yaz4j.jni -o src/libyaz4j.cpp -c++ -java libyaz4j.i - -g++ -fPIC -I"include" -I"$JNI_DIR" -I"$JNI_DIR/linux" ${YAZ_CFLAGS} -c -Wall -o obj/libyaz4j.o src/libyaz4j.cpp - -g++ -fPIC -I"include" -I"$JNI_DIR" -I"$JNI_DIR/linux" ${YAZ_CFLAGS} -c -Wall -o obj/zoom-extra.o src/zoom-extra.cpp - -g++ -shared obj/libyaz4j.o obj/zoom-extra.o -o lib/libyaz4j.so ${YAZ_LIBS} - - diff --git a/pom.xml b/pom.xml index 539d4bd..92a7226 100644 --- a/pom.xml +++ b/pom.xml @@ -95,6 +95,42 @@ -Djava.library.path=${basedir}/libyaz4j/lib + + + maven-antrun-plugin + + + build-native + compile + + run + + + + + + + + + + + + clean-native + clean + + run + + + + + + + + + + + +