forked from skiselkov/BetterPushbackC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_dep.common
executable file
·62 lines (55 loc) · 1.53 KB
/
build_dep.common
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
#!/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"
SRCDIR="${TARBALL/%.tar.*/}"
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 ;;
*)
echo "Unknown archive extension of $TARBALL" >&2
exit 1
;;
esac
fi
if [ -f "$PRODNAME-$PLATFORM/$PRODFILE" ] && \
[ "$PRODNAME-$PLATFORM/$PRODFILE" -nt "$TARBALL" ]; then
return
fi
(
rm -rf "$PRODNAME-$PLATFORM"
mkdir "$PRODNAME-$PLATFORM"
cd "$PRODNAME-$PLATFORM"
if [ -n "$CUSTPREPCMD" ]; then
eval "$CUSTPREPCMD" || exit 1
fi
# Linux: for some reason, we need to specify an optimization
# level or we won't get lstat/fstat correctly defined. WTF...
CFLAGS="${CFLAGS} -fvisibility=hidden -O2" \
LDFLAGS="${LDFLAGS} -fvisibility=hidden" \
"../$SRCDIR/configure" --prefix="$(pwd)" \
$CONFOPTS || exit 1
make -j $NCPUS || exit 1
if [ -z "$NOINSTALL" ]; then
make install || exit 1
fi
)
}