2019-02-03 01:14:51 -05:00
|
|
|
. ./redoconf.rc
|
|
|
|
|
rc_include rc/CC.rc
|
|
|
|
|
|
|
|
|
|
prog='
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
void f() { atoi(""); }
|
|
|
|
|
'
|
|
|
|
|
|
2019-02-24 22:29:19 -05:00
|
|
|
try_unix_style() {
|
|
|
|
|
(
|
|
|
|
|
appendln CFLAGS "-fPIC"
|
|
|
|
|
appendln LDFLAGS "-shared"
|
|
|
|
|
appendln LDFLAGS "-Wl,-soname,x.so"
|
|
|
|
|
RCC_NO_MAIN=1 rc_compile cc link "$prog"
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try_macos_style() {
|
|
|
|
|
(
|
|
|
|
|
appendln CFLAGS "-fPIC"
|
|
|
|
|
appendln LDFLAGS "-dynamiclib"
|
|
|
|
|
appendln LDFLAGS "-current_version"
|
|
|
|
|
appendln LDFLAGS "1.0"
|
|
|
|
|
RCC_NO_MAIN=1 rc_compile cc link "$prog"
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2019-02-03 01:14:51 -05:00
|
|
|
if [ -n "$STATIC" ]; then
|
|
|
|
|
echo "--enable-static specified; not building shared libraries." >&2
|
2019-03-01 13:38:25 -05:00
|
|
|
rc_replaceln HAVE_SHLIB "STATIC"
|
2019-02-24 22:29:19 -05:00
|
|
|
elif [ -n "$NOSHARED" ]; then
|
|
|
|
|
echo "--disable-shared specified; not building shared libraries." >&2
|
2019-03-01 13:38:25 -05:00
|
|
|
rc_replaceln HAVE_SHLIB "STATIC"
|
2019-02-24 22:29:19 -05:00
|
|
|
elif try_unix_style; then
|
|
|
|
|
rc_replaceln HAVE_SHLIB UNIX
|
|
|
|
|
elif try_macos_style; then
|
|
|
|
|
rc_replaceln HAVE_SHLIB MACOS
|
2019-02-03 01:14:51 -05:00
|
|
|
else
|
|
|
|
|
echo "Not building shared libraries on this platform." >&2
|
2019-03-01 13:38:25 -05:00
|
|
|
rc_replaceln HAVE_SHLIB "STATIC"
|
2019-02-03 01:14:51 -05:00
|
|
|
fi
|
2019-03-01 13:38:25 -05:00
|
|
|
|
|
|
|
|
if [ "$HAVE_SHLIB" != "STATIC" ]; then
|
|
|
|
|
x='-Wl,-z,origin'
|
|
|
|
|
if (appendln LDFLAGS "$x" && rc_compile cc link); then
|
|
|
|
|
rc_appendln LDFLAGS "$x"
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
x='-Wl,-rpath,$ORIGIN'
|
|
|
|
|
if (appendln LDFLAGS "$x" && rc_compile cc link); then
|
|
|
|
|
rc_appendln LDFLAGS "$x"
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2019-02-03 01:14:51 -05:00
|
|
|
rc_save
|