-
Notifications
You must be signed in to change notification settings - Fork 87
/
Copy pathconfigure_build.sh
83 lines (75 loc) · 2.83 KB
/
configure_build.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# Find, load common utilities
# Defines IS_MACOS, fetch_unpack
MULTIBUILD_DIR=$(dirname "${BASH_SOURCE[0]}")
source $MULTIBUILD_DIR/common_utils.sh
# Only source configure_build once
if [ -n "$CONFIGURE_BUILD_SOURCED" ]; then
return
fi
CONFIGURE_BUILD_SOURCED=1
BUILD_PREFIX="${BUILD_PREFIX:-/usr/local}"
# IS_MACOS is defined in common_utils.sh
if [ -n "$IS_MACOS" ]; then
# Default compilation flags for OSX
source $MULTIBUILD_DIR/osx_utils.sh
PLAT=${PLAT:-$(macpython_arch_for_version $MB_PYTHON_VERSION)}
if [[ $PLAT == intel ]]; then
ARCH_FLAGS=${ARCH_FLAGS:-"-arch i386 -arch x86_64"}
elif [[ $PLAT == x86_64 ]]; then
ARCH_FLAGS=${ARCH_FLAGS:-"-arch x86_64"}
elif [[ $PLAT == arm64 ]]; then
ARCH_FLAGS=${ARCH_FLAGS:-"-arch arm64"}
elif [[ $PLAT == universal2 ]]; then
# Do nothing as we are going with fusing wheels
ARCH_FLAGS=${ARCH_FLAGS:-}
else
echo "Invalid platform = '$PLAT'. Supported values are 'intel', 'x86_64', 'arm64' or 'universal2'"
exit 1
fi
# Only set CFLAGS, FFLAGS if they are not already defined. Build functions
# can override the arch flags by setting CFLAGS, FFLAGS
export CFLAGS="${CFLAGS:-$ARCH_FLAGS}"
export CXXFLAGS="${CXXFLAGS:-$ARCH_FLAGS}"
export FFLAGS="${FFLAGS:-$ARCH_FLAGS}"
# Disable homebrew auto-update
export HOMEBREW_NO_AUTO_UPDATE=1
else
# default compilation flags for linux
PLAT="${PLAT:-x86_64}"
# Strip all binaries after compilation.
STRIP_FLAGS=${STRIP_FLAGS:-"-Wl,-strip-all"}
export CFLAGS="${CFLAGS:-$STRIP_FLAGS}"
export CXXFLAGS="${CXXFLAGS:-$STRIP_FLAGS}"
export FFLAGS="${FFLAGS:-$STRIP_FLAGS}"
if [[ $MB_ML_VER == "_2_24" ]]; then
# This is the first opportunity to distinguish between manylinuxes
apt update
if [ "${MB_PYTHON_VERSION:0:4}" == "pypy" ]; then
# debian:9 based distro
apt install -y wget
fi
elif [[ $MB_ML_VER == "1" ]]; then
# Need libtool, and for pypy need wget
# centos based distro
yum install -y libtool wget
elif [ "${MB_PYTHON_VERSION:0:4}" == "pypy" ]; then
if [ -n "$IS_ALPINE" ]; then
apk add wget
else
# centos based distro
yum install -y wget
fi
fi
fi
export CPPFLAGS_BACKUP="$CPPFLAGS"
export LIBRARY_PATH_BACKUP="$LIBRARY_PATH"
export PKG_CONFIG_PATH_BACKUP="$PKG_CONFIG_PATH"
function update_env_for_build_prefix {
# Promote BUILD_PREFIX on search path to any newly built libs
export CPPFLAGS="-I$BUILD_PREFIX/include $CPPFLAGS_BACKUP"
export LIBRARY_PATH="$BUILD_PREFIX/lib:$LIBRARY_PATH_BACKUP"
export PKG_CONFIG_PATH="$BUILD_PREFIX/lib/pkgconfig/:$PKG_CONFIG_PATH_BACKUP"
# Add binary path for configure utils etc
export PATH="$BUILD_PREFIX/bin:$PATH"
}
update_env_for_build_prefix