forked from Rblp/Rblpapi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·93 lines (86 loc) · 3.19 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
#!/bin/bash
## Emacs please make this -*- mode: shell-mode; -*-
##
## configure -- Unix build preparation system
##
## Copyright (C) 2015 Dirk Eddelbuettel and Jeroen Ooms.
##
## This file is part of Rblpapi
##
## Rblpapi is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 2 of the License, or
## (at your option) any later version.
##
## Rblpapi is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with Rblpapi. If not, see <http://www.gnu.org/licenses/>.
## Check that we are on Unix
uname=$(type -P uname)
if [ "${uname}" = "" ]; then
echo "You do not have uname so this is unlikely to be a Unix system. Exiting."
exit -1
fi
## Check for Linux or OSX
: ${R_HOME=$(R RHOME)}
sysname=$(${R_HOME}/bin/Rscript -e 'cat(Sys.info()["sysname"])')
if [ ${sysname} == "Linux" ]; then
platform="linux"
elif [ ${sysname} == "Darwin" ]; then
platform="osx"
else
echo "Unsupported platform: $sysname"
echo "Check https://www.bloomberg.com/professional/support/api-library/ for possible support first."
echo "Contributions welcome, see https://github.com/Rblp/blp for integration with Rblapi."
exit -1
fi
## Populate Makevars
rpath=$(${R_HOME}/bin/Rscript -e 'cat(file.path(.libPaths()[1], "Rblpapi", "blp"))')
arch=$(uname -m)
if [ "${arch}" = "x86_64" ]; then
echo "Setting up compilation for a ${platform} 64-bit system"
sed -e"s/@config@/blpapi3_64/" -e"s|@rpath@|"${rpath}"|" src/Makevars.in > src/Makevars
flavour="64"
elif [ "${arch}" = "i686" ]; then
echo "Setting up compilation for a ${platform} 32-bit system"
sed -e"s/@config@/blpapi3_32/" -e"s|@rpath@|"${rpath}"|" src/Makevars.in > src/Makevars
flavour="32"
else
echo "Unknown architecture: ${arch}. Exiting."
exit -1
fi
## helper function to not rely on curl which at least on OS X fails to follow redirects
download() {
url=${1}
## sadly, for Travis we cannot rely on R as it lacks libcurl
libcurl=$(${R_HOME}/bin/Rscript -e 'cat(capabilities()[["libcurl"]])')
## so when we have libcurl in R, use it -- else fall back to curl
if [ ${libcurl} == "TRUE" ]; then
file=$(basename ${url})
${R_HOME}/bin/Rscript -e "download.file(\"${url}\", \"${file}\", quiet=TRUE, method='libcurl')"
else
curl -s -k -L -O ${url}
fi
}
## Get and install header files
cwd=$(pwd)
mkdir -p blp/${platform}
cd blp/${platform}
if [ ! -f blpHeaders.tar.gz ]; then
download https://github.com/Rblp/blp/raw/master/headers/${platform}/blpHeaders.tar.gz
tar xfz blpHeaders.tar.gz -C ../../inst
fi
cd ${cwd}
## Get and install precompiled shared library
mkdir -p inst/blp
cd blp/${platform}
if [ ! -f blpLibrary.tar.gz ]; then
download https://github.com/Rblp/blp/raw/master/${platform}${flavour}/blpLibrary.tar.gz
tar xfz blpLibrary.tar.gz -C ../../inst/blp/ libblpapi3_${flavour}.so
fi
cd ${cwd}
exit 0