-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild_dep.common
More file actions
executable file
·126 lines (112 loc) · 3.01 KB
/
Copy pathbuild_dep.common
File metadata and controls
executable file
·126 lines (112 loc) · 3.01 KB
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
#!/bin/bash
# CDDL HEADER START
#
# This file and its contents are supplied under the terms of the
# Common Development and Distribution License ("CDDL"), version 1.0.
# You may only use this file in accordance with the terms of version
# 1.0 of the CDDL.
#
# A full copy of the text of the CDDL should have accompanied this
# source. A copy of the CDDL is also available via the Internet at
# http://www.illumos.org/license/CDDL.
#
# CDDL HEADER END
# Copyright 2017 Saso Kiselkov. All rights reserved.
function build_dep() {
PLATFORM="$1"
CONFOPTS="$2"
TARBALL="$3"
PRODNAME="$4"
PRODFILE="$5"
PATCHFILES="$6"
if [[ "$PLATFORM" == "win-64" ]] && [[ "$minimal" == 1 ]]; then
return
fi
if [[ "$SRCDIR" = "" ]]; then
SRCDIR="$(basename "${TARBALL/%.tar.*/}")"
SRCDIR="$(basename "${SRCDIR/%.zip/}")"
fi
if [[ "$BUILDDIR" = "" ]]; then
BUILDDIR="$PRODNAME-$PLATFORM"
fi
if [ -n "$do_clean" ]; then
echo rm -rf "$BUILDDIR" "$SRCDIR"
rm -rf "$BUILDDIR" "$SRCDIR"
SRCDIR=""
BUILDDIR=""
return
fi
case $(uname) in
Linux)
NCPUS=$(( $(grep 'processor[[:space:]]\+:' /proc/cpuinfo \
| wc -l) + 1 ))
;;
Darwin)
NCPUS=$(( $(sysctl -n hw.ncpu) + 1 ))
CFLAGS_ADDTL="-mmacosx-version-min=10.9\ -arch\ x86_64\ -arch\ arm64"
CXXFLAGS_ADDTL="-mmacosx-version-min=10.9\ -arch\ x86_64\ -arch\ arm64"
LDFLAGS_ADDTL="-mmacosx-version-min=10.9\ -arch\ x86_64\ -arch\ arm64"
;;
esac
if [ -n "$BUILD_SINGLE_THREADED" ]; then
NCPUS=1
fi
export PKG_CONFIG_PATH=$(echo "$PKG_CONFIG_PATH_IN" | \
sed "s/{PLATFORM}/$PLATFORM/g")
if ! [ -d "$SRCDIR" ]; then
case "${TARBALL##*.}" in
bz2) tar -xjf "$TARBALL" || exit 1 ;;
gz) tar -xzf "$TARBALL" || exit 1 ;;
xz) tar -xJf "$TARBALL" || exit 1 ;;
zip) unzip -o "$TARBALL" || exit 1 ;;
*)
echo "Unknown archive extension of $TARBALL" >&2
exit 1
;;
esac
if [ -n "$PATCHFILES" ]; then
for PATCHFILE in $PATCHFILES; do
( cd "$SRCDIR" && patch -p1 < "../$PATCHFILE" )
done
fi
fi
if [ -f "$BUILDDIR/$PRODFILE" ] && \
[ "$BUILDDIR/$PRODFILE" -nt "$TARBALL" ]; then
SRCDIR=""
BUILDDIR=""
return
fi
(
if [[ "$BUILDDIR" != "$SRCDIR" ]]; then
rm -rf "$BUILDDIR"
mkdir "$BUILDDIR"
fi
cd "$BUILDDIR"
if [ -n "$CUSTPREPCMD" ]; then
eval "$CUSTPREPCMD" || exit 1
fi
if [[ "$PLATFORM" = "linux-32" ]] || \
[[ "$PLATFORM" = "linux-64" ]]; then
FPIC="-fPIC"
fi
# Linux: for some reason, we need to specify an optimization
# level or we won't get lstat/fstat correctly defined. WTF...
eval CFLAGS="-fvisibility=hidden\\ -O2\\ $FPIC\\ ${CFLAGS}\\ \
${CFLAGS_ADDTL}" \
CXXFLAGS="-fvisibility=hidden\\ -O2\\ $FPIC\\ ${CXXFLAGS}\\ \
${CXXFLAGS_ADDTL}" \
LDFLAGS="-fvisibility=hidden\\ $FPIC\\ ${LDFLAGS}\\ \
${LDFLAGS_ADDTL}" \
"../$SRCDIR/configure" --prefix="$(pwd)/$INSTALL_DIR" \
${CONFOPTS} || exit 1
if [ -n "$CUSTPREMAKECMD" ]; then
eval "$CUSTPREMAKECMD" || exit 1
fi
make -j $NCPUS || exit 1
if [ -z "$NOINSTALL" ]; then
make install || exit 1
fi
)
SRCDIR=""
BUILDDIR=""
}