forked from apache/arrow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·219 lines (199 loc) · 8.4 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
#!/bin/sh
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# Anticonf (tm) script by Jeroen Ooms, Jim Hester (2017)
# License: MIT
#
# This script will query 'pkg-config' for the required cflags and ldflags.
# If pkg-config is unavailable or does not find the library, try setting
# INCLUDE_DIR and LIB_DIR manually via e.g:
# R CMD INSTALL --configure-vars='INCLUDE_DIR=/.../include LIB_DIR=/.../lib'
# Library settings
PKG_CONFIG_NAME="arrow parquet arrow-dataset"
PKG_DEB_NAME="(unsuppored)"
PKG_RPM_NAME="(unsuppored)"
PKG_BREW_NAME="apache-arrow"
PKG_TEST_HEADER="<arrow/api.h>"
# These must be the same order as $(pkg-config --libs arrow-dataset)
PKG_LIBS="-larrow_dataset -lparquet -larrow"
# Make some env vars case-insensitive
ARROW_R_DEV=`echo $ARROW_R_DEV | tr '[:upper:]' '[:lower:]'`
FORCE_AUTOBREW=`echo $FORCE_AUTOBREW | tr '[:upper:]' '[:lower:]'`
ARROW_USE_PKG_CONFIG=`echo $ARROW_USE_PKG_CONFIG | tr '[:upper:]' '[:lower:]'`
VERSION=`grep ^Version DESCRIPTION | sed s/Version:\ //`
UNAME=`uname -s`
# generate code
if [ "$ARROW_R_DEV" = "true" ] && [ -f "data-raw/codegen.R" ]; then
echo "*** Generating code with data-raw/codegen.R"
${R_HOME}/bin/Rscript data-raw/codegen.R
fi
if [ -f "tools/apache-arrow.rb" ]; then
# If you want to use a local apache-arrow.rb formula, do
# $ cp ../dev/tasks/homebrew-formulae/autobrew/apache-arrow.rb tools/apache-arrow.rb
# before R CMD build or INSTALL (assuming a local checkout of the apache/arrow repository)
cp tools/autobrew .
if [ "$FORCE_AUTOBREW" != "false" ]; then
# It is possible to turn off forced autobrew if the formula is included,
# but most likely you shouldn't because the included formula will reference
# the C++ library at the version that matches the R package.
FORCE_AUTOBREW="true"
fi
fi
if [ "$FORCE_AUTOBREW" = "true" ]; then
ARROW_USE_PKG_CONFIG="false"
fi
# Note that cflags may be empty in case of success
if [ "$INCLUDE_DIR" ] || [ "$LIB_DIR" ]; then
echo "*** Using INCLUDE_DIR/LIB_DIR"
PKG_CFLAGS="-I$INCLUDE_DIR $PKG_CFLAGS"
PKG_LIBS="-L$LIB_DIR $PKG_LIBS"
else
# Use pkg-config if available and allowed
pkg-config --version >/dev/null 2>&1
if [ "$ARROW_USE_PKG_CONFIG" != "false" ] && [ $? -eq 0 ]; then
PKGCONFIG_CFLAGS=`pkg-config --cflags --silence-errors ${PKG_CONFIG_NAME}`
PKGCONFIG_LIBS=`pkg-config --libs --silence-errors ${PKG_CONFIG_NAME}`
fi
if [ "$PKGCONFIG_CFLAGS" ] || [ "$PKGCONFIG_LIBS" ]; then
echo "*** Arrow C++ libraries found via pkg-config"
PKG_CFLAGS="$PKGCONFIG_CFLAGS"
PKG_LIBS=${PKGCONFIG_LIBS}
# Check for version mismatch
PC_LIB_VERSION=`pkg-config --modversion arrow`
echo $PC_LIB_VERSION | grep -e 'SNAPSHOT$' >/dev/null 2>&1
# If on a release (i.e. not SNAPSHOT) and version != R package version, warn
if [ $? -eq 1 ] && [ "$PC_LIB_VERSION" != "$VERSION" ]; then
echo "**** Warning: library version mismatch"
echo "**** C++ is $PC_LIB_VERSION but R is $VERSION"
echo "**** If installation fails, upgrade the C++ library to match"
echo "**** or retry with ARROW_USE_PKG_CONFIG=false"
fi
else
if [ "$UNAME" = "Darwin" ]; then
if [ "$FORCE_AUTOBREW" != "true" ] && [ "`command -v brew`" ] && [ "`brew ls --versions ${PKG_BREW_NAME}`" != "" ]; then
echo "*** Using Homebrew ${PKG_BREW_NAME}"
BREWDIR=`brew --prefix`
PKG_LIBS="-L$BREWDIR/opt/$PKG_BREW_NAME/lib $PKG_LIBS -larrow_bundled_dependencies"
PKG_CFLAGS="-I$BREWDIR/opt/$PKG_BREW_NAME/include"
else
echo "*** Downloading ${PKG_BREW_NAME}"
if [ -f "autobrew" ]; then
echo "**** Using local manifest for ${PKG_BREW_NAME}"
else
curl -sfL "https://autobrew.github.io/scripts/$PKG_BREW_NAME" > autobrew
if [ $? -ne 0 ]; then
echo "Failed to download manifest for ${PKG_BREW_NAME}"
fi
fi
. autobrew
if [ $? -ne 0 ]; then
echo "Failed to retrieve binary for ${PKG_BREW_NAME}"
fi
# autobrew sets `PKG_LIBS` and `PKG_CFLAGS`
fi
elif [ "$UNAME" = "Linux" ]; then
# Set some default values/backwards compatibility
if [ "${LIBARROW_DOWNLOAD}" = "" ] && [ "${NOT_CRAN}" != "" ]; then
LIBARROW_DOWNLOAD=$NOT_CRAN; export LIBARROW_DOWNLOAD
fi
if [ "${LIBARROW_BINARY}" = "" ] && [ "${LIBARROW_DOWNLOAD}" != "" ]; then
LIBARROW_BINARY=$LIBARROW_DOWNLOAD; export LIBARROW_BINARY
fi
if [ "${LIBARROW_MINIMAL}" = "" ] && [ "${LIBARROW_DOWNLOAD}" = "true" ]; then
LIBARROW_MINIMAL=false; export LIBARROW_MINIMAL
fi
if [ "${LIBARROW_MINIMAL}" = "" ] && [ "${NOT_CRAN}" = "true" ]; then
LIBARROW_MINIMAL=false; export LIBARROW_MINIMAL
fi
${R_HOME}/bin/Rscript tools/linuxlibs.R $VERSION
PKG_CFLAGS="-I$(pwd)/libarrow/arrow-${VERSION}/include $PKG_CFLAGS"
LIB_DIR="libarrow/arrow-${VERSION}/lib"
if [ -d "$LIB_DIR" ]; then
# Enumerate the static libs and add to PKG_LIBS
# (technically repeating arrow libs so they're in the right order)
#
# If tools/linuxlibs.R fails to produce libs, this dir won't exist
# so don't try (the error message from `ls` would be misleading)
# Assume linuxlibs.R has handled and messaged about its failure already
#
# TODO: what about non-bundled deps?
BUNDLED_LIBS=`cd $LIB_DIR && ls *.a`
BUNDLED_LIBS=`echo $BUNDLED_LIBS | sed -E "s/lib(.*)\.a/-l\1/" | sed -e "s/\\.a lib/ -l/g"`
PKG_LIBS="-L$(pwd)/$LIB_DIR $PKG_LIBS $BUNDLED_LIBS"
fi
fi
fi
fi
# Find compiler
CXXCPP="`${R_HOME}/bin/R CMD config CXX11` -E"
CXX11FLAGS=`"${R_HOME}"/bin/R CMD config CXX11FLAGS`
CXX11STD=`"${R_HOME}"/bin/R CMD config CXX11STD`
CPPFLAGS=`"${R_HOME}"/bin/R CMD config CPPFLAGS`
# If libarrow uses the old GLIBCXX ABI, so we have to use it too
if [ "$ARROW_USE_OLD_CXXABI" ]; then
PKG_CFLAGS="$PKG_CFLAGS -D_GLIBCXX_USE_CXX11_ABI=0"
fi
# Set any user-defined CXXFLAGS
if [ "$ARROW_R_CXXFLAGS" ]; then
PKG_CFLAGS="$PKG_CFLAGS $ARROW_R_CXXFLAGS"
fi
# Test configuration
TEST_CMD="${CXXCPP} ${CPPFLAGS} ${PKG_CFLAGS} ${CXX11FLAGS} ${CXX11STD} -xc++ -"
echo "#include $PKG_TEST_HEADER" | ${TEST_CMD} >/dev/null 2>&1
if [ $? -eq 0 ] || [ "$UNAME" = "Darwin" ]; then
# Always build with arrow on macOS
PKG_CFLAGS="$PKG_CFLAGS -DARROW_R_WITH_ARROW"
# Check for features
LIB_DIR=`echo $PKG_LIBS | sed -e 's/ -l.*//' | sed -e 's/^-L//'`
grep 'set(ARROW_S3 "ON")' $LIB_DIR/cmake/arrow/ArrowOptions.cmake >/dev/null 2>&1
if [ $? -eq 0 ]; then
PKG_CFLAGS="$PKG_CFLAGS -DARROW_R_WITH_S3"
if [ "$BUNDLED_LIBS" != "" ]; then
# We're depending on openssl/curl from the system, so they're not in the bundled deps
PKG_LIBS="$PKG_LIBS -lssl -lcrypto -lcurl"
fi
fi
echo "PKG_CFLAGS=$PKG_CFLAGS"
echo "PKG_LIBS=$PKG_LIBS"
else
if [ "$UNAME" = "Darwin" ]; then
# Just for debugging: is this possible?
echo "Test to load header failed. Command:"
echo "$TEST_CMD"
fi
echo "------------------------- NOTE ---------------------------"
echo "See https://arrow.apache.org/docs/r/articles/install.html"
echo "for help installing Arrow C++ libraries"
echo "---------------------------------------------------------"
PKG_LIBS=""
PKG_CFLAGS=""
fi
# Write to Makevars
sed -e "s|@cflags@|$PKG_CFLAGS|" -e "s|@libs@|$PKG_LIBS|" src/Makevars.in > src/Makevars
# This is removed because a (bad?) CRAN check fails when arrow.so is stripped
# # Add stripping
# if [ "$R_STRIP_SHARED_LIB" != "" ]; then
# # R_STRIP_SHARED_LIB is set in the global Renviron and should be available here
# echo "
# strip: \$(SHLIB)
# $R_STRIP_SHARED_LIB \$(SHLIB) >/dev/null 2>&1 || true
#
# .phony: strip
# " >> src/Makevars
# fi
# Success
exit 0