-
Notifications
You must be signed in to change notification settings - Fork 24
/
installlib
executable file
·95 lines (88 loc) · 2.04 KB
/
installlib
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
#!/bin/sh
set -e
: "${prefix:=/usr/local}"
: "${includedir:=$prefix/include}"
: "${libdir:=$prefix/lib}"
: "${DESTDIR:=}"
HEADER=BlocksRuntime/Block.h
LIB=libBlocksRuntime.a
SHLIB=
docmd()
{
echo "$*"
if [ -z "$dryrun" ]; then eval "$*"; fi
}
if ! myid="$(id -u)"; then
echo "Cannot run id, aborting!"
exit 1
fi
if [ ! -r $HEADER ]; then
echo "Cannot find $HEADER, aborting!"
exit 1
fi
dryrun=
if [ "$1" = '-n' ] || [ "$1" = '--dry-run' ]; then
dryrun=1
shift
fi
static=1
shared=1
case "$1" in
"-static"|"--static")
shift
shared=
;;
"-shared"|"--shared")
shift
static=
;;
esac
if [ "$#" != 0 ]; then
echo "Usage: [prefix=prefixdir] $0 [-n | --dry-run] [-shared | -static]"
exit 1
fi
if [ -n "$shared" ]; then
UNAME_S="$(uname -s 2>/dev/null)" || :
case "$UNAME_S" in
Darwin)
SHLIB="${LIB%.a}.dylib"
SHLIBMODE=755
;;
*)
SHLIB="${LIB%.a}.so"
SHLIBMODE=644
;;
esac
if [ -n "$static" ]; then
# ignore a missing shared library
[ -e "$SHLIB" ] || SHLIB=
else
LIB=
fi
fi
if [ -n "$LIB" ] && [ ! -r "$LIB" ]; then
echo "Cannot find $LIB, did you run \`buildlib\` or \`buildlib-osx\`?"
exit 1
fi
if [ -n "$SHLIB" ] && [ ! -r "$SHLIB" ]; then
echo "Cannot find $SHLIB, did you run \`buildlib -shared\` or \`buildlib-osx -shared\`?"
exit 1
fi
[ -z "$DESTDIR" ] ||
echo "Destination Root(\$DESTDIR): $DESTDIR (default is \"\")"
echo "Install Prefix(\$prefix): $prefix (default is /usr/local)"
echo "Include Directory(\$includedir): $includedir (default is \$prefix/include)"
echo "Library Directory(\$libdir): $libdir (default is \$prefix/lib)"
echo "(use prefix=prefixdir $0 [or similar] to change)"
echo ''
if [ -z "$DESTDIR" -a -z "$dryrun" -a "$myid" != 0 ]; then
echo "Must be root to install, use sudo $0"
echo "(Or try using the --dry-run option)"
exit 1
fi
docmd "install -d "$DESTDIR"$includedir "$DESTDIR"$libdir"
docmd "install -m 644 $HEADER "$DESTDIR"$includedir/"
[ -z "$LIB" ] ||
docmd "install -m 644 $LIB "$DESTDIR"$libdir/"
[ -z "$SHLIB" ] ||
docmd "install -m $SHLIBMODE $SHLIB "$DESTDIR"$libdir/"