-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
configure
executable file
·122 lines (101 loc) · 3.87 KB
/
configure
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/sh
# Based on configure of Rblpapi
# https://github.com/Rblp/Rblpapi/blob/master/configure
## Check that we are on Unix
which uname
if [ $? -ne 0 ]; then
echo "You do not have 'uname' so this is unlikely to be a Unix system. Exiting."
exit 1
fi
# Library settings
PKG_TEST_HEADER="<kiwi/Kiwi.h>"
PKG_LIBS="-lkiwi"
PKG_CPPFLAGS=""
LIB_VER="0.11.2"
# Copy libcache for local development.
if [ -f "`pwd`/kiwilibtmp/libs/libkiwi.a" ]; then
echo "Found kiwilibtmp folder!"
mkdir -p kiwilibs
cp -rf kiwilibtmp/* kiwilibs/
fi
# Check for custom locations
if [ "$INCLUDE_DIR" ] || [ "$LIB_DIR" ]; then
echo "Found INCLUDE_DIR and/or LIB_DIR!"
PKG_CPPFLAGS="-I$INCLUDE_DIR $PKG_CPPFLAGS"
PKG_LIBS="-L$LIB_DIR $PKG_LIBS"
elif [ -d "`pwd`/kiwilibs/libs/" ]; then
echo "Found libkiwi on pwd installation..."
PKG_CPPFLAGS="-I`pwd`/kiwilibs/include $PKG_CPPFLAGS"
PKG_LIBS="-L`pwd`/kiwilibs/libs $PKG_LIBS"
else
echo "Prior system libkiwi installation not found"
echo "Preparing to download and build library from source..."
which git
if [ $? -ne 0 ]; then
echo "------------------------------[ ELBIRD ]------------------------------"
echo "Configuration failed because 'git' was not found."
echo "If you want to kiwi build from source in package installation prosess,"
echo "make sure git and cmake work in system."
echo "-------------------------------------------------------------------------"
exit 1
fi
which cmake
if [ $? -ne 0 ]; then
export PATH=$PATH:/Applications/CMake.app/Contents/bin
fi
which cmake
if [ $? -ne 0 ]; then
echo "------------------------------[ ELBIRD ]------------------------------"
echo "Configuration failed because 'libkiwi' and 'cmake' were not found."
echo "If 'libkiwi' is already installed but in a non-standard location, you"
echo "may set INCLUDE_DIR and LIB_DIR manually via:"
echo "R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'"
echo ""
echo "If you want to kiwi build from source in package installation prosess,"
echo "make sure cmake work."
echo "-------------------------------------------------------------------------"
exit 1
fi
git config --global advice.detachedHead false
git clone -b v$LIB_VER --depth 1 https://github.com/bab2min/Kiwi
cd Kiwi
git rm third_party/googletest
git rm third_party/cpuinfo
git submodule update --init --recursive
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DKIWI_BUILD_TEST=OFF -DKIWI_USE_CPUINFO=OFF -DCMAKE_POSITION_INDEPENDENT_CODE=ON --log-level=ERROR ..
echo "** make is running..."
make kiwi_static 1> makelog.txt
echo "** done!"
cd ../..
mkdir -p kiwilibs/libs
mv -f Kiwi/build/libkiwi_static.a kiwilibs/libs/libkiwi.a
mv -f Kiwi/include kiwilibs/include
rm -rf Kiwi
# Copy libcache for local development.
cp -rf kiwilibs/ kiwilibtmp/
PKG_CPPFLAGS="-I`pwd`/kiwilibs/include $PKG_CPPFLAGS"
PKG_LIBS="-L`pwd`/kiwilibs/libs $PKG_LIBS"
fi
# For debugging
echo "Using PKG_CPPFLAGS=$PKG_CPPFLAGS"
echo "Using PKG_LIBS=$PKG_LIBS"
# Find compiler
CXX11=`${R_HOME}/bin/R CMD config CXX11`
CXXFLAGS=`${R_HOME}/bin/R CMD config CXXFLAGS`
# Test for libkiwi
echo "#include $PKG_TEST_HEADER" | ${CXX11} ${PKG_CPPFLAGS} ${CXXFLAGS} -E -xc++ - >/dev/null 2>&1
if [ $? -ne 0 ]; then
echo "------------------------------[ ELBIRD ]------------------------------"
echo "Configuration failed because 'libkiwi' was not found."
echo "If 'libkiwi' is already installed but in a non-standard location, you"
echo "may set INCLUDE_DIR and LIB_DIR manually via:"
echo "R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'"
echo "-------------------------------------------------------------------------"
exit 1
fi
# Write to Makevars
sed -e "s|@cppflags@|$PKG_CPPFLAGS|" -e "s|@libs@|$PKG_LIBS|" -e "s|@cxxflags@|$CXXFLAGS|" src/Makevars.in > src/Makevars
# Success
exit 0