-
Notifications
You must be signed in to change notification settings - Fork 76
/
configure
executable file
·113 lines (105 loc) · 4.04 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
#!/bin/sh
## Emacs please make this -*- mode: shell-mode; -*-
##
## configure -- Unix build preparation system
##
## Copyright (C) 2015 - 2024 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
if ! [ -x $(command -v 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 2
fi
## Populate Makevars
arch=$(uname -m)
if [ "${arch}" = "x86_64" ]; then
echo "Setting up compilation for a ${platform} 64-bit system"
sed -e"s/@config@/blpapi3_64/" src/Makevars.in > src/Makevars
flavour="64"
if [ "${platform}" = "osx" ]; then
cpu="x86"
fi
elif [ "${arch}" = "arm64" ]; then
echo "Setting up compilation for a ${platform} 64-bit system"
sed -e"s/@config@/blpapi3_64/" src/Makevars.in > src/Makevars
flavour="64"
if [ "${platform}" = "osx" ]; then
cpu="arm"
fi
elif [ "${arch}" = "i686" ]; then
echo "Setting up compilation for a ${platform} 32-bit system"
sed -e"s/@config@/blpapi3_32/" src/Makevars.in > src/Makevars
flavour="32"
else
echo "Unknown architecture: ${arch}. Exiting."
exit 3
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
}
## default file names, can override with say 'blpHeaders="/opt/blp/blpHeaders_1.2.3.tar.gz"'
## respects enviroment variable so 'blpHeaders="/opt/blp/blpHeaders_1.2.3.tar.gz" ./configure' works
: ${blpHeaders="blpHeaders.tar.gz"}
: ${blpLibrary="blpLibrary.tar.gz"}
: ${blpBranch="master"}
## Check for header files and download if needed, this looks at repo blp in directory headers/
cwd=$(pwd)
mkdir -p blp/${platform}
cd blp/${platform}
if [ ! -f ${blpHeaders} ]; then
download https://github.com/Rblp/blp/raw/${blpBranch}/headers/${platform}/blpHeaders.tar.gz
else
echo "** using ${blpHeaders}"
fi
tar xfz ${blpHeaders} -C ../../inst
cd ${cwd}
## Get and install precompiled shared library, this looks at repo blp in directoris 'PlatformFlavourCpu'
## Here flavour is mostly redundant as of 2024 as 32 bit is no longer built at CRAN but we support user who may have it
## The Cpu tag is used only on macos and it used to distinguish between (old) x86_64 and newer arm64
mkdir -p inst/blp
cd blp/${platform}
if [ ! -f ${blpLibrary} ]; then
download https://github.com/Rblp/blp/raw/${blpBranch}/${platform}${flavour}${cpu}/blpLibrary.tar.gz
else
echo "** using ${blpLibrary}"
fi
tar xfz ${blpLibrary} -C ../../inst/blp/ libblpapi3_${flavour}.so
cd ${cwd}
exit 0