diff --git a/docs/cookbook/c/all.rc.od b/docs/cookbook/c/all.rc.od index 1ff6a57..22b35b0 100644 --- a/docs/cookbook/c/all.rc.od +++ b/docs/cookbook/c/all.rc.od @@ -10,7 +10,7 @@ rc_include \ rc/rt.autolib.rc \ rc/libpng.rc \ rc/clock_gettime.rc \ - rc/mach_time.h.rc \ + rc/mach__mach_time.h.rc \ rc/windows.h.rc \ rc/posix.rc \ rc/printf_lld.rc \ diff --git a/docs/cookbook/c/monotime.c b/docs/cookbook/c/monotime.c index 784f577..98602ba 100644 --- a/docs/cookbook/c/monotime.c +++ b/docs/cookbook/c/monotime.c @@ -23,7 +23,7 @@ long long monotime(void) { return !result ? 1 : result; } -#elif HAVE_MACH_TIME_H +#elif HAVE_MACH__MACH_TIME_H #include #include diff --git a/docs/cookbook/c/rc/posix.rc.od b/docs/cookbook/c/rc/posix.rc.od index 4a6b172..b33cb21 100644 --- a/docs/cookbook/c/rc/posix.rc.od +++ b/docs/cookbook/c/rc/posix.rc.od @@ -8,13 +8,13 @@ struct timespec x; ' x= -rc_replaceln HAS_POSIX 1 +rc_replaceln HAVE_POSIX 1 if ! rc_compile cc link "$prog"; then x="-D_XOPEN_SOURCE=500" rc_appendln CPPFLAGS "$x" if ! rc_compile cc link "$prog"; then rc_undo - rc_replaceln HAS_POSIX "" + rc_replaceln HAVE_POSIX "" fi fi rc_save diff --git a/redoconf/configure.sh b/redoconf/configure.sh index 83d77a1..38986e9 100644 --- a/redoconf/configure.sh +++ b/redoconf/configure.sh @@ -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" ;; diff --git a/redoconf/link-shlib.od b/redoconf/link-shlib.od index e3cb976..aa632f0 100644 --- a/redoconf/link-shlib.od +++ b/redoconf/link-shlib.od @@ -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 diff --git a/redoconf/rc/default.h.rc.od b/redoconf/rc/default.h.rc.od index 0057d77..6df73cb 100644 --- a/redoconf/rc/default.h.rc.od +++ b/redoconf/rc/default.h.rc.od @@ -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 -> +H=$(echo "$h1" | tr 'a-z.' 'A-Z_') if rc_compile cc nolink "#include <$h>"; then rc_replaceln "HAVE_$H" 1 diff --git a/redoconf/rc/shlib.rc.od b/redoconf/rc/shlib.rc.od index 35c938f..20211b4 100644 --- a/redoconf/rc/shlib.rc.od +++ b/redoconf/rc/shlib.rc.od @@ -1,21 +1,43 @@ . ./redoconf.rc rc_include rc/CC.rc -appendln CFLAGS "-fPIC" -appendln LDFLAGS "-shared" - prog=' #include 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