Yuta HIGUCHI | a7ec073 | 2014-03-10 16:01:06 -0700 | [diff] [blame] | 1 | #!/bin/bash |
Yuta HIGUCHI | 1c2c0db | 2014-03-13 16:20:35 -0700 | [diff] [blame] | 2 | |
Yuta HIGUCHI | c83a4fb | 2014-04-07 15:16:06 -0700 | [diff] [blame] | 3 | if [ -z "${JAVA_HOME}" ]; then |
| 4 | echo "JAVA_HOME not set" |
| 5 | OPENJDK=`java -version 2>&1 | grep OpenJDK` |
| 6 | if [ -z "${OPENJDK}" -a -d "/usr/lib/jvm/java-7-oracle" ]; then |
| 7 | JAVA_HOME=/usr/lib/jvm/java-7-oracle |
| 8 | else |
| 9 | JAVA_HOME=/usr/lib/jvm/default-java |
| 10 | fi |
| 11 | echo "Assuming JAVA_HOME=${JAVA_HOME}" |
| 12 | fi |
| 13 | |
Yuta HIGUCHI | 4d70a01 | 2014-03-26 17:56:40 -0700 | [diff] [blame] | 14 | # fail on command error |
| 15 | set -e |
| 16 | |
Yuta HIGUCHI | c83a4fb | 2014-04-07 15:16:06 -0700 | [diff] [blame] | 17 | # echo back each command |
| 18 | set -x |
| 19 | |
Yuta HIGUCHI | a7ec073 | 2014-03-10 16:01:06 -0700 | [diff] [blame] | 20 | JAVA_HOME=${JAVA_HOME:-/usr/lib/jvm/java-7-oracle} |
Yuta HIGUCHI | 318d9d1 | 2014-04-10 17:00:32 -0700 | [diff] [blame] | 21 | export ONOS_HOME=${ONOS_HOME:-$(cd `dirname $0`; cd ..; pwd)} |
| 22 | export RAMCLOUD_HOME=${RAMCLOUD_HOME:-~/ramcloud} |
Yuta HIGUCHI | a7ec073 | 2014-03-10 16:01:06 -0700 | [diff] [blame] | 23 | RAMCLOUD_BRANCH=${RAMCLOUD_BRANCH:-master} |
| 24 | |
Yuta HIGUCHI | d47eac3 | 2014-04-07 13:44:47 -0700 | [diff] [blame] | 25 | if [ ! -e ${ONOS_HOME}/target/classes/edu/stanford/ramcloud/JRamCloud.class ]; then |
| 26 | mvn -f ${ONOS_HOME}/pom.xml compile -T 1C |
| 27 | fi |
Yuta HIGUCHI | a7ec073 | 2014-03-10 16:01:06 -0700 | [diff] [blame] | 28 | |
| 29 | javah -cp ${ONOS_HOME}/target/classes -o ${ONOS_HOME}/src/main/cpp/edu_stanford_ramcloud_JRamCloud.h edu.stanford.ramcloud.JRamCloud |
| 30 | |
| 31 | g++ -g -Wall -O3 -shared -fPIC -std=c++0x -I${JAVA_HOME}/include/ -I${JAVA_HOME}/include/linux -I${RAMCLOUD_HOME}/src/ -I${RAMCLOUD_HOME}/obj.${RAMCLOUD_BRANCH}/ -I${RAMCLOUD_HOME}/logcabin/ -I${RAMCLOUD_HOME}/gtest/include/ -L${RAMCLOUD_HOME}/obj.${RAMCLOUD_BRANCH} -o ${ONOS_HOME}/lib/libedu_stanford_ramcloud_JRamCloud.so ${ONOS_HOME}/src/main/cpp/edu_stanford_ramcloud_JRamCloud.cc -lramcloud |
| 32 | |
Yuta HIGUCHI | a7ec073 | 2014-03-10 16:01:06 -0700 | [diff] [blame] | 33 | |