mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2026-01-03 02:20:16 +01:00
Fix compilation on MacOS X
Enable "ld_preload" (DYLD_INSERT_LIBRARIES + DYLD_FORCE_FLAT_NAMESPACE) and build cairo-trace as a library instead of a module to make it work also on MacOS X.
This commit is contained in:
parent
c181f9e9ae
commit
1ce096657b
4 changed files with 33 additions and 14 deletions
17
configure.ac
17
configure.ac
|
|
@ -651,12 +651,27 @@ AM_CONDITIONAL(BUILD_ANY2PPM,
|
|||
-o "x$any2ppm_ps" = "xyes" \
|
||||
-o "x$any2ppm_cs" = "xyes")
|
||||
|
||||
dnl ===========================================================================
|
||||
dnl Some utilities need to dlopen the shared libraries, so they need to
|
||||
dnl know how libtools will name them
|
||||
|
||||
case $host in
|
||||
*-*-darwin*)
|
||||
SHLIB_EXT="dylib"
|
||||
;;
|
||||
*)
|
||||
SHLIB_EXT="so"
|
||||
;;
|
||||
esac
|
||||
AC_DEFINE_UNQUOTED(SHARED_LIB_EXT, "${SHLIB_EXT}", [Shared library file extension])
|
||||
AC_SUBST(SHLIB_EXT)
|
||||
|
||||
dnl ===========================================================================
|
||||
dnl The tracing utility requires LD_PRELOAD, so only build it for systems
|
||||
dnl that are known to work.
|
||||
|
||||
case $host in
|
||||
*-linux*|*-*bsd*|*-solaris*)
|
||||
*-linux*|*-*bsd*|*-solaris*|*-*-darwin*)
|
||||
have_ld_preload="yes"
|
||||
;;
|
||||
*)
|
||||
|
|
|
|||
|
|
@ -2,37 +2,37 @@ cairolibdir = $(libdir)/cairo
|
|||
cairooutdir = $(localstatedir)/lib/cairo-trace
|
||||
|
||||
bin_SCRIPTS = cairo-trace
|
||||
cairolib_LTLIBRARIES = cairo-trace.la
|
||||
cairolib_LTLIBRARIES = libcairo-trace.la
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/src \
|
||||
-I$(top_builddir)/src
|
||||
|
||||
cairo_trace_la_SOURCES = trace.c
|
||||
cairo_trace_la_CPPFLAGS = -DCAIRO_TRACE_OUTDIR="\"$(cairooutdir)\"" \
|
||||
libcairo_trace_la_SOURCES = trace.c
|
||||
libcairo_trace_la_CPPFLAGS = -DCAIRO_TRACE_OUTDIR="\"$(cairooutdir)\"" \
|
||||
$(AM_CPPFLAGS)
|
||||
cairo_trace_la_CFLAGS = $(CAIRO_CFLAGS)
|
||||
cairo_trace_la_LDFLAGS = -module -no-undefined
|
||||
libcairo_trace_la_CFLAGS = $(CAIRO_CFLAGS)
|
||||
libcairo_trace_la_LDFLAGS = -no-undefined
|
||||
|
||||
cairo_trace_la_LIBADD = -lz $(pthread_LIBS)
|
||||
libcairo_trace_la_LIBADD = -lz $(pthread_LIBS)
|
||||
if CAIRO_HAS_DL
|
||||
cairo_trace_la_LIBADD += -ldl
|
||||
libcairo_trace_la_LIBADD += -ldl
|
||||
endif
|
||||
|
||||
if CAIRO_HAS_SYMBOL_LOOKUP
|
||||
cairo_trace_la_SOURCES += \
|
||||
libcairo_trace_la_SOURCES += \
|
||||
lookup-symbol.c \
|
||||
lookup-symbol.h
|
||||
cairo_trace_la_LIBADD += $(BFD_LIBS)
|
||||
libcairo_trace_la_LIBADD += $(BFD_LIBS)
|
||||
endif
|
||||
|
||||
|
||||
system-install: install
|
||||
-mkdir -p $(cairooutdir)
|
||||
-chmod 01777 $(cairooutdir)
|
||||
grep -sq $(cairolibdir)/cairo-trace.so /etc/ld.so.preload || echo $(cairolibdir)/cairo-trace.so >> /etc/ld.so.preload
|
||||
grep -sq $(cairolibdir)/libcairo-trace.so /etc/ld.so.preload || echo $(cairolibdir)/libcairo-trace.so >> /etc/ld.so.preload
|
||||
|
||||
system-uninstall: uninstall
|
||||
sed -e '/cairo-trace.so/d' < /etc/ld.so.preload > /tmp/ld.so.preload && mv /tmp/ld.so.preload /etc/ld.so.preload;
|
||||
sed -e '/libcairo-trace.so/d' < /etc/ld.so.preload > /tmp/ld.so.preload && mv /tmp/ld.so.preload /etc/ld.so.preload;
|
||||
|
||||
EXTRA_DIST = \
|
||||
COPYING \
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ export CAIRO_TRACE_PROG_NAME
|
|||
|
||||
if test "x$CAIRO_TRACE_SO" = "x"; then
|
||||
CAIRO_TRACE_SO=""
|
||||
for lib in @libdir@/cairo/cairo-trace.so @libdir@/cairo/cairo-trace.so*; do
|
||||
for lib in @libdir@/cairo/libcairo-trace.@SHLIB_EXT@ @libdir@/cairo/libcairo-trace.@SHLIB_EXT@* @libdir@/cairo/libcairo-trace.*.@SHLIB_EXT@ ; do
|
||||
if test -h "$lib" -o -f "$lib"; then
|
||||
CAIRO_TRACE_SO="$lib"
|
||||
break
|
||||
|
|
@ -104,7 +104,11 @@ if test "x$CAIRO_TRACE_SO" = "x"; then
|
|||
fi
|
||||
|
||||
LD_PRELOAD="$CAIRO_TRACE_SO"
|
||||
DYLD_INSERT_LIBRARIES="$CAIRO_TRACE_SO"
|
||||
DYLD_FORCE_FLAT_NAMESPACE=1
|
||||
export LD_PRELOAD
|
||||
export DYLD_INSERT_LIBRARIES
|
||||
export DYLD_FORCE_FLAT_NAMESPACE
|
||||
|
||||
if test -n "$nocallers"; then
|
||||
CAIRO_TRACE_LINE_INFO=0
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ static void *_dlhandle = RTLD_NEXT;
|
|||
if (name##_real == NULL) { \
|
||||
name##_real = (typeof (&name))(dlsym (_dlhandle, #name)); \
|
||||
if (name##_real == NULL && _dlhandle == RTLD_NEXT) { \
|
||||
_dlhandle = dlopen ("libcairo.so", RTLD_LAZY); \
|
||||
_dlhandle = dlopen ("libcairo." SHARED_LIB_EXT, RTLD_LAZY); \
|
||||
name##_real = (typeof (&name))(dlsym (_dlhandle, #name)); \
|
||||
assert (name##_real != NULL); \
|
||||
} \
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue