#!/bin/bash

NAME=weights
    
# C:/Program Files (x86)/Java/jdk1.8.0_05
# C:/Program Files/Java/jdk1.7.0_40

java="C:/Program Files (x86)/Java/jdk1.8.0_05"
allInc="-I\"$java/include\" -I\"$java/include/win32\""

echo ${allInc}

adapter=libJavaGraderAdapter.so
stdcall=
fpic="-fPIC"
if [ "$OS" == "Windows_NT" ] ; then
    adapter=JavaGraderAdapter.dll
    stdcall=-Wl,--add-stdcall-alias
    fpic=
fi

javac grader.java || exit
bash -c "g++ -std=gnu++11 $allInc -shared -c $fpic -Wall -O2 JavaGraderAdapter.cpp" || exit
bash -c "g++ -std=gnu++11 $allInc $stdcall -o $adapter -shared JavaGraderAdapter.o" || exit
jar cfe $NAME.jar grader *.class || exit

