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
|
|
@ -50,7 +50,8 @@ usage() {
|
|||
|
||||
--prefix= Change installation prefix (usually /usr/local)
|
||||
--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-debug Disable/enable debugging flags for C/C++
|
||||
-h, --help This help message
|
||||
|
|
@ -115,6 +116,9 @@ for d in "$@"; do
|
|||
--enable-static)
|
||||
emit "STATIC" "1"
|
||||
;;
|
||||
--disable-shared)
|
||||
emit "NOSHARED" "1"
|
||||
;;
|
||||
--enable-optimization)
|
||||
emit_append OPTFLAGS "-O2"
|
||||
;;
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
rc_include _all.rc rc/shlib.rc
|
||||
|
||||
# Tricky quoting: see _compile.od for details.
|
||||
if [ "$HAVE_SHLIB" = 1 ]; then
|
||||
if [ "$HAVE_SHLIB" = UNIX ]; then
|
||||
cat >$3 <<-EOF
|
||||
#!/bin/sh -e
|
||||
LINK=$(shquote "$LINK")
|
||||
|
|
@ -20,6 +20,25 @@ if [ "$HAVE_SHLIB" = 1 ]; then
|
|||
"\$@" \\
|
||||
\$LIBS
|
||||
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
|
||||
# If no shared library support and we try to build one,
|
||||
# compensate by building a static library instead in the
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@
|
|||
rc_include rc/CC.rc
|
||||
|
||||
base="${1#*/}"
|
||||
h="${base%.rc}"
|
||||
H=$(echo "$h" | tr 'a-z.' 'A-Z_')
|
||||
h1="${base%.rc}"
|
||||
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
|
||||
rc_replaceln "HAVE_$H" 1
|
||||
|
|
|
|||
|
|
@ -1,21 +1,43 @@
|
|||
. ./redoconf.rc
|
||||
rc_include rc/CC.rc
|
||||
|
||||
appendln CFLAGS "-fPIC"
|
||||
appendln LDFLAGS "-shared"
|
||||
|
||||
prog='
|
||||
#include <stdlib.h>
|
||||
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
|
||||
echo "--enable-static specified; not building shared libraries." >&2
|
||||
rc_replaceln HAVE_SHLIB ""
|
||||
elif RCC_NO_MAIN=1 rc_compile cc link "$prog"; then
|
||||
rc_replaceln HAVE_SHLIB 1
|
||||
elif [ -n "$NOSHARED" ]; then
|
||||
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
|
||||
echo "Not building shared libraries on this platform." >&2
|
||||
rc_undo
|
||||
rc_replaceln HAVE_SHLIB ""
|
||||
fi
|
||||
rc_save
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue