3 case "$1" in -h|
-H|
-help|
--help)
5 Usage: ${0##*/} [-shared]
6 -shared also attempt to build a shared library
7 Env: CC explicit "cc" compiler to use
8 AR explicit "ar" to use
9 RANLIB explicit "ranlib" to use
10 CFLAGS explicit compiler options to use
11 FPIC explicit -fPIC/-fpic (or none) option to use
18 LIB
=libBlocksRuntime.a
22 [ z
"$1" != z
"-shared" -a z
"$1" != z
"--shared" ] || shared
=1
24 if [ -n "$shared" ]; then
25 UNAME_S
="$(uname -s 2>/dev/null)" ||
:
28 SHLIB
="${LIB%.a}.dylib"
29 SHOPT
="-dynamiclib -Wl,-all_load"
34 SHOPT
="-shared -Wl,-whole-archive"
35 SHOPT2
="-Wl,-no-whole-archive"
41 if command -v gcc
> /dev
/null
; then
43 elif command -v clang
> /dev
/null
; then
45 elif command -v cc
> /dev
/null
; then
48 echo "Could not guess name of compiler, please set CC" >&2
59 if [ "${CFLAGS+set}" != "set" ]; then
72 "$CC" "$1" -o /tmp
/cc.$$
-c -x c
/dev
/null
>/dev
/null
2>&1 &&
75 if [ "${FPIC+set}" != "set" ]; then
76 if has_cc_opt
"-fPIC"; then
78 elif has_cc_opt
"-fpic"; then
82 [ -z "$FPIC" ] ||
echo "FPIC=$FPIC"
87 [ -z "$shared" ] ||
echo "SHLIB=$SHLIB"
88 [ -z "$shared" ] ||
echo "SHOPT=$SHOPT"
89 [ -z "$shared" ] ||
[ -z "$SHOPT2" ] ||
echo "SHOPT2=$SHOPT2"
94 ! test -e $LIB ||
rm $LIB
99 ! test -e $SHLIB ||
rm $SHLIB
103 "$CC" -c $FPIC $CFLAGS -o $SRC/data.o
$SRC/data.c
&&
104 "$CC" -c $FPIC $CFLAGS -o $SRC/runtime.o
-I .
$SRC/runtime.c
&&
105 "$AR" cr
$LIB $SRC/data.o
$SRC/runtime.o
&&
111 "$CC" $FPIC $CFLAGS -o "$SHLIB" $SHOPT $LIB $SHOPT2