From 9bfce0f5e4b7b0f52889fdd993a98ab7ca3cb86a Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Mon, 12 Mar 2012 14:15:48 +0000 Subject: [PATCH] When not producing a dynamic library, define DBUS_STATIC_BUILD When targeting Windows, linking against the static library requires special effort to turn off DLL import/export processing. We normally link some things against the dynamic library, but if we're not building that, we'll have to link everything statically. Based on patches from 'william' on fd.o #46367. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=33973 --- configure.ac | 10 ++++++++++ dbus-1-uninstalled.pc.in | 2 +- dbus-1.pc.in | 2 +- test/Makefile.am | 3 +++ tools/Makefile.am | 1 + 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index f461b68..aed8654 100644 --- a/configure.ac +++ b/configure.ac @@ -123,6 +123,16 @@ AM_CONDITIONAL(DBUS_WINCE, test "$dbus_wince" = yes) AM_CONDITIONAL(DBUS_UNIX, test "$dbus_unix" = yes) AM_CONDITIONAL(DBUS_CYGWIN, test "$dbus_cygwin" = yes) +DBUS_STATIC_BUILD_CPPFLAGS= +if test "x$enable_shared" = xno; then + # On Windows, linking against the static library requires special effort + # to turn off DLL import/export processing. We normally link some things + # against the dynamic library, but if we're not building that, we'll + # have to link everything statically. + DBUS_STATIC_BUILD_CPPFLAGS=-DDBUS_STATIC_BUILD +fi +AC_SUBST([DBUS_STATIC_BUILD_CPPFLAGS]) + AC_ARG_ENABLE(ansi, AS_HELP_STRING([--enable-ansi],[enable -ansi -pedantic gcc flags]),enable_ansi=$enableval,enable_ansi=no) AC_ARG_ENABLE(verbose-mode, AS_HELP_STRING([--enable-verbose-mode],[support verbose debug mode]),enable_verbose_mode=$enableval,enable_verbose_mode=$USE_MAINTAINER_MODE) AC_ARG_ENABLE(asserts, AS_HELP_STRING([--enable-asserts],[include assertion checks]),enable_asserts=$enableval,enable_asserts=$USE_MAINTAINER_MODE) diff --git a/dbus-1-uninstalled.pc.in b/dbus-1-uninstalled.pc.in index f007232..038c83e 100644 --- a/dbus-1-uninstalled.pc.in +++ b/dbus-1-uninstalled.pc.in @@ -14,4 +14,4 @@ Description: Free desktop message bus (uninstalled copy) Version: @VERSION@ Libs: ${abs_top_builddir}/dbus/libdbus-1.la Libs.private: @LIBDBUS_LIBS@ -Cflags: -I${abs_top_srcdir} +Cflags: -I${abs_top_srcdir} @DBUS_STATIC_BUILD_CPPFLAGS@ diff --git a/dbus-1.pc.in b/dbus-1.pc.in index 7201e07..25f8bce 100644 --- a/dbus-1.pc.in +++ b/dbus-1.pc.in @@ -14,4 +14,4 @@ Description: Free desktop message bus Version: @VERSION@ Libs: -L${libdir} -ldbus-1 Libs.private: @LIBDBUS_LIBS@ -Cflags: -I${includedir}/dbus-1.0 -I${libdir}/dbus-1.0/include +Cflags: -I${includedir}/dbus-1.0 -I${libdir}/dbus-1.0/include @DBUS_STATIC_BUILD_CPPFLAGS@ diff --git a/test/Makefile.am b/test/Makefile.am index 88a0e8c..cd11eb4 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -4,8 +4,10 @@ SUBDIRS= . name-test DIST_SUBDIRS=name-test +# CPPFLAGS for binaries that are normally dynamic AM_CPPFLAGS = \ -I$(top_srcdir) \ + $(DBUS_STATIC_BUILD_CPPFLAGS) \ $(GLIB_CFLAGS) \ $(DBUS_GLIB_CFLAGS) \ $(NULL) @@ -13,6 +15,7 @@ AM_CPPFLAGS = \ # improve backtraces from test stuff AM_LDFLAGS = @R_DYNAMIC_LDFLAG@ +# CPPFLAGS for binaries that are always static static_cppflags = \ $(AM_CPPFLAGS) \ -DDBUS_STATIC_BUILD \ diff --git a/tools/Makefile.am b/tools/Makefile.am index 08b9023..c4632e3 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -2,6 +2,7 @@ configdir=$(sysconfdir)/dbus-1 AM_CPPFLAGS = \ -I$(top_srcdir) \ + $(DBUS_STATIC_BUILD_CPPFLAGS) \ $(DBUS_X_CFLAGS) \ -DDBUS_COMPILATION \ -DDBUS_MACHINE_UUID_FILE=\""$(localstatedir)/lib/dbus/machine-id"\" \ -- 1.7.9.1