-
Notifications
You must be signed in to change notification settings - Fork 5
/
compile_java_lib.sh
executable file
·67 lines (53 loc) · 1.84 KB
/
compile_java_lib.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
SCRIPT_DIR=$(cd $(dirname $0);echo $PWD)
ROOT_DIR=${SCRIPT_DIR}
# local c++ lib env
export INCLUDES=/usr/local/include
export BOOST_LIBS_DIR=/usr/local/lib
export CPLUS_INCLUDE_PATH=${CPLUS_INCLUDE_PATH}:${INCLUDES}
export C_INCLUDE_PATH=${C_INCLUDE_PATH}:${INCLUDES}
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${BOOST_LIBS_DIR}
export LIBRARY_PATH=${LIBRARY_PATH}:${BOOST_LIBS_DIR}
BHROOT=${ROOT_DIR}/src/storage/brighthouse
LIBDIR=${ROOT_DIR}/java_lib
mkdir -p ${LIBDIR}
CPP_OUT_DIR=${ROOT_DIR}/cpp-out
#######################
# Compile compress lib
if [ ! -f "${BOOST_LIBS_DIR}/libboost_system.a" ]; then
echo "lib not found: ${BOOST_LIBS_DIR}/libboost_system.a"
exit 1
fi
mkdir -p ${CPP_OUT_DIR}
echo "cd ${CPP_OUT_DIR}"
cd ${CPP_OUT_DIR}
if [[ "${OSTYPE}" == "linux"* ]] || [[ "${OSTYPE}" == "cygwin"* ]]; then
BHLIB=libbhcompress.so
BOOST_SYSTEM_LIB=libboost_system.so
elif [[ "${OSTYPE}" == "darwin"* ]]; then
BHLIB=libbhcompress.dylib
BOOST_SYSTEM_LIB=libboost_system.dylib
else
echo "Platform ${OSTYPE} not supported!"
exit 1
fi
rm -f ${LIBDIR}/${BHLIB}
rm -f ${LIBDIR}/${BOOST_SYSTEM_LIB}
if [[ "x$1" == "x-j" ]]; then
echo "Compiling ${BHROOT}/compress/JavaCompress.cpp"
rm -f ${CPP_OUT_DIR}/JavaCompress.o
g++ -O3 -c -fPIC -I"${BHROOT}" -I"${BHROOT}/community" ${BHROOT}/compress/JavaCompress.cpp
else
echo "Compiling ${BHROOT}/compress/*.cpp"
rm -f ${CPP_OUT_DIR}/*.o
g++ -O3 -c -fPIC -I"${BHROOT}" -I"${BHROOT}/community" ${BHROOT}/compress/*.cpp
fi
rm -f ${LIBDIR}/libbhcompress.*
#g++ -shared -fPIC -O3 -o ${LIBDIR}/${BHLIB} ${CPP_OUT_DIR}/*.o ${BOOST_LIBS_DIR}/libboost_system.a
g++ -shared -fPIC -O3 -o ${LIBDIR}/${BHLIB} ${CPP_OUT_DIR}/*.o -lboost_system
if [ ! "x$?" = "x0" ]; then
exit $?
fi
echo "Generated ${LIBDIR}/${BHLIB}"
# Compilation done.
#######################
rm -rf ${CPP_OUT_DIR}