Fix some build problems on MacOS X.
- Linking shared libraries needs slightly different options. - We were trying to detect mach_time.h but needed to detect mach/mach_time.h instead. While we're here, add a --disable-shared option to ./configure, which is different from --enable-static. --disable-shared does not build *new* share libraries, but doesn't pass -static to the linker (apparently there is no static linking posible on MacOS).
This commit is contained in:
parent
017997c035
commit
328d4ead7a
7 changed files with 59 additions and 13 deletions
|
|
@ -10,7 +10,7 @@ rc_include \
|
||||||
rc/rt.autolib.rc \
|
rc/rt.autolib.rc \
|
||||||
rc/libpng.rc \
|
rc/libpng.rc \
|
||||||
rc/clock_gettime.rc \
|
rc/clock_gettime.rc \
|
||||||
rc/mach_time.h.rc \
|
rc/mach__mach_time.h.rc \
|
||||||
rc/windows.h.rc \
|
rc/windows.h.rc \
|
||||||
rc/posix.rc \
|
rc/posix.rc \
|
||||||
rc/printf_lld.rc \
|
rc/printf_lld.rc \
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ long long monotime(void) {
|
||||||
return !result ? 1 : result;
|
return !result ? 1 : result;
|
||||||
}
|
}
|
||||||
|
|
||||||
#elif HAVE_MACH_TIME_H
|
#elif HAVE_MACH__MACH_TIME_H
|
||||||
|
|
||||||
#include <mach/mach.h>
|
#include <mach/mach.h>
|
||||||
#include <mach/mach_time.h>
|
#include <mach/mach_time.h>
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,13 @@ struct timespec x;
|
||||||
'
|
'
|
||||||
|
|
||||||
x=
|
x=
|
||||||
rc_replaceln HAS_POSIX 1
|
rc_replaceln HAVE_POSIX 1
|
||||||
if ! rc_compile cc link "$prog"; then
|
if ! rc_compile cc link "$prog"; then
|
||||||
x="-D_XOPEN_SOURCE=500"
|
x="-D_XOPEN_SOURCE=500"
|
||||||
rc_appendln CPPFLAGS "$x"
|
rc_appendln CPPFLAGS "$x"
|
||||||
if ! rc_compile cc link "$prog"; then
|
if ! rc_compile cc link "$prog"; then
|
||||||
rc_undo
|
rc_undo
|
||||||
rc_replaceln HAS_POSIX ""
|
rc_replaceln HAVE_POSIX ""
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
rc_save
|
rc_save
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,8 @@ usage() {
|
||||||
|
|
||||||
--prefix= Change installation prefix (usually /usr/local)
|
--prefix= Change installation prefix (usually /usr/local)
|
||||||
--host= Architecture prefix for output (eg. i686-w64-mingw32-)
|
--host= Architecture prefix for output (eg. i686-w64-mingw32-)
|
||||||
--enable-static Link libraries and binaries statically
|
--enable-static Link binaries statically
|
||||||
|
--disable-shared Do not build shared libraries
|
||||||
--{dis,en}able-optimization Disable/enable optimization for C/C++
|
--{dis,en}able-optimization Disable/enable optimization for C/C++
|
||||||
--{dis,en}able-debug Disable/enable debugging flags for C/C++
|
--{dis,en}able-debug Disable/enable debugging flags for C/C++
|
||||||
-h, --help This help message
|
-h, --help This help message
|
||||||
|
|
@ -115,6 +116,9 @@ for d in "$@"; do
|
||||||
--enable-static)
|
--enable-static)
|
||||||
emit "STATIC" "1"
|
emit "STATIC" "1"
|
||||||
;;
|
;;
|
||||||
|
--disable-shared)
|
||||||
|
emit "NOSHARED" "1"
|
||||||
|
;;
|
||||||
--enable-optimization)
|
--enable-optimization)
|
||||||
emit_append OPTFLAGS "-O2"
|
emit_append OPTFLAGS "-O2"
|
||||||
;;
|
;;
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
rc_include _all.rc rc/shlib.rc
|
rc_include _all.rc rc/shlib.rc
|
||||||
|
|
||||||
# Tricky quoting: see _compile.od for details.
|
# Tricky quoting: see _compile.od for details.
|
||||||
if [ "$HAVE_SHLIB" = 1 ]; then
|
if [ "$HAVE_SHLIB" = UNIX ]; then
|
||||||
cat >$3 <<-EOF
|
cat >$3 <<-EOF
|
||||||
#!/bin/sh -e
|
#!/bin/sh -e
|
||||||
LINK=$(shquote "$LINK")
|
LINK=$(shquote "$LINK")
|
||||||
|
|
@ -20,6 +20,25 @@ if [ "$HAVE_SHLIB" = 1 ]; then
|
||||||
"\$@" \\
|
"\$@" \\
|
||||||
\$LIBS
|
\$LIBS
|
||||||
EOF
|
EOF
|
||||||
|
elif [ "$HAVE_SHLIB" = MACOS ]; then
|
||||||
|
cat >$3 <<-EOF
|
||||||
|
#!/bin/sh -e
|
||||||
|
LINK=$(shquote "$LINK")
|
||||||
|
LDFLAGS=$(shquote "$LDFLAGS")
|
||||||
|
OPTFLAGS=$(shquote "$OPTFLAGS")
|
||||||
|
LIBS=$(shquote "$LIBS")
|
||||||
|
LIBDIR=$(shquote "$LIBDIR")
|
||||||
|
o="\$1"
|
||||||
|
ob="\${o#*/}"
|
||||||
|
shift
|
||||||
|
IFS="$NL"
|
||||||
|
set -f
|
||||||
|
\$LINK -dynamiclib -o "\$o" \\
|
||||||
|
-install_name "\$ob" \\
|
||||||
|
\$LDFLAGS \$OPTFLAGS \\
|
||||||
|
"\$@" \\
|
||||||
|
\$LIBS
|
||||||
|
EOF
|
||||||
else
|
else
|
||||||
# If no shared library support and we try to build one,
|
# If no shared library support and we try to build one,
|
||||||
# compensate by building a static library instead in the
|
# compensate by building a static library instead in the
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,9 @@
|
||||||
rc_include rc/CC.rc
|
rc_include rc/CC.rc
|
||||||
|
|
||||||
base="${1#*/}"
|
base="${1#*/}"
|
||||||
h="${base%.rc}"
|
h1="${base%.rc}"
|
||||||
H=$(echo "$h" | tr 'a-z.' 'A-Z_')
|
h=$(echo "$h1" | sed -e 's,__,/,g') # x__y_z.h.rc.od -> <x/y_z.h>
|
||||||
|
H=$(echo "$h1" | tr 'a-z.' 'A-Z_')
|
||||||
|
|
||||||
if rc_compile cc nolink "#include <$h>"; then
|
if rc_compile cc nolink "#include <$h>"; then
|
||||||
rc_replaceln "HAVE_$H" 1
|
rc_replaceln "HAVE_$H" 1
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,43 @@
|
||||||
. ./redoconf.rc
|
. ./redoconf.rc
|
||||||
rc_include rc/CC.rc
|
rc_include rc/CC.rc
|
||||||
|
|
||||||
appendln CFLAGS "-fPIC"
|
|
||||||
appendln LDFLAGS "-shared"
|
|
||||||
|
|
||||||
prog='
|
prog='
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
void f() { atoi(""); }
|
void f() { atoi(""); }
|
||||||
'
|
'
|
||||||
|
|
||||||
|
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"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
if [ -n "$STATIC" ]; then
|
if [ -n "$STATIC" ]; then
|
||||||
echo "--enable-static specified; not building shared libraries." >&2
|
echo "--enable-static specified; not building shared libraries." >&2
|
||||||
rc_replaceln HAVE_SHLIB ""
|
rc_replaceln HAVE_SHLIB ""
|
||||||
elif RCC_NO_MAIN=1 rc_compile cc link "$prog"; then
|
elif [ -n "$NOSHARED" ]; then
|
||||||
rc_replaceln HAVE_SHLIB 1
|
echo "--disable-shared specified; not building shared libraries." >&2
|
||||||
|
rc_replaceln HAVE_SHLIB ""
|
||||||
|
elif try_unix_style; then
|
||||||
|
rc_replaceln HAVE_SHLIB UNIX
|
||||||
|
elif try_macos_style; then
|
||||||
|
rc_replaceln HAVE_SHLIB MACOS
|
||||||
else
|
else
|
||||||
echo "Not building shared libraries on this platform." >&2
|
echo "Not building shared libraries on this platform." >&2
|
||||||
|
rc_undo
|
||||||
rc_replaceln HAVE_SHLIB ""
|
rc_replaceln HAVE_SHLIB ""
|
||||||
fi
|
fi
|
||||||
rc_save
|
rc_save
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue