From 336cc8436b738d03f99beac2c2bd42c080ac668b Mon Sep 17 00:00:00 2001 From: Tor Lillqvist Date: Mon, 21 Apr 2008 08:38:36 +0000 Subject: [PATCH] configure.in More work on enabling static building on Windows. When 2008-04-21 Tor Lillqvist * configure.in * */Makefile.am: More work on enabling static building on Windows. When building statically: Also define GOBJECT_STATIC_COMPILATION in glibconfig.h so that also the variables in gparamspecs.h get declared without any dllimport/dllexport decorations. Don't install .def files which obviously have no meaning for static libraries. Don't create MS import libraries. Don't do any resource object files. svn path=/trunk/; revision=6866 --- ChangeLog | 11 +++++++++++ configure.in | 7 +++++-- gio/Makefile.am | 16 +++++++++------- glib/Makefile.am | 27 ++++++++++++++------------- gmodule/Makefile.am | 26 ++++++++++++-------------- gobject/Makefile.am | 27 ++++++++++++--------------- gthread/Makefile.am | 20 ++++++++++---------- 7 files changed, 73 insertions(+), 61 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3eeef906e..3213cef58 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2008-04-21 Tor Lillqvist + + * configure.in + * */Makefile.am: More work on enabling static building on + Windows. When building statically: Also define + GOBJECT_STATIC_COMPILATION in glibconfig.h so that also the + variables in gparamspecs.h get declared without any + dllimport/dllexport decorations. Don't install .def files which + obviously have no meaning for static libraries. Don't create MS + import libraries. Don't do any resource object files. + 2008-04-18 17:40:58 Tim Janik * tests/testglib.c: fixed gstdio.h include. diff --git a/configure.in b/configure.in index c12b0382f..37d67a343 100644 --- a/configure.in +++ b/configure.in @@ -491,10 +491,12 @@ if test "$glib_native_win32" = "yes"; then fi if test x$enable_static = xyes; then glib_win32_static_compilation=yes - GLIB_WIN32_STATIC_COMPILATION_DEFINE="#define GLIB_STATIC_COMPILATION 1" + GLIB_WIN32_STATIC_COMPILATION_DEFINE="#define GLIB_STATIC_COMPILATION 1 +#define GOBJECT_STATIC_COMPILATION 1" AC_SUBST(GLIB_WIN32_STATIC_COMPILATION_DEFINE) fi fi +AM_CONDITIONAL(OS_WIN32_AND_DLL_COMPILATION, [test x$glib_native_win32 = xyes -a x$glib_win32_static_compilation != xyes]) dnl dnl DU4 native cc currently needs -std1 for ANSI mode (instead of K&R) @@ -3203,7 +3205,8 @@ case $host in esac glib_static_compilation="" if test x$glib_win32_static_compilation = xyes; then - glib_static_compilation="#define GLIB_STATIC_COMPILATION 1" + glib_static_compilation="#define GLIB_STATIC_COMPILATION 1 +#define GOBJECT_STATIC_COMPILATION 1" fi ]) diff --git a/gio/Makefile.am b/gio/Makefile.am index b22a5ec9d..f5bb994e3 100644 --- a/gio/Makefile.am +++ b/gio/Makefile.am @@ -8,18 +8,20 @@ if OS_UNIX SUBDIRS += xdgmime endif +if OS_WIN32_AND_DLL_COMPILATION if MS_LIB_AVAILABLE noinst_DATA = gio-2.0.lib +install_ms_lib_cmd = $(INSTALL) gio-2.0.lib $(DESTDIR)$(libdir) +uninstall_ms_lib_cmd = -rm $(DESTDIR)$(libdir)/gio-2.0.lib +endif +endif + install-ms-lib: - $(INSTALL) gio-2.0.lib $(DESTDIR)$(libdir) + $(install_ms_lib_cmd) uninstall-ms-lib: - -rm $(DESTDIR)$(libdir)/gio-2.0.lib -else -install-ms-lib: -uninstall-ms-lib: -endif + $(uninstall_ms_lib_cmd) gio.def: gio.symbols (echo -e EXPORTS; $(CPP) -P -DINCLUDE_VARIABLES -DINCLUDE_INTERNAL_SYMBOLS -DG_OS_WIN32 -DALL_FILES - <$(srcdir)/gio.symbols | sed -e '/^$$/d' -e 's/^/ /' -e 's/G_GNUC_[^ ]*//g' | sort) > gio.def.tmp && \ @@ -228,7 +230,7 @@ if PLATFORM_WIN32 no_undefined = -no-undefined endif -if OS_WIN32 +if OS_WIN32_AND_DLL_COMPILATION export_symbols = -export-symbols gio.def gio_def = gio.def diff --git a/glib/Makefile.am b/glib/Makefile.am index 4093cac9a..b92777b77 100644 --- a/glib/Makefile.am +++ b/glib/Makefile.am @@ -81,18 +81,20 @@ BUILT_EXTRA_DIST = \ lib_LTLIBRARIES = libglib-2.0.la +if OS_WIN32_AND_DLL_COMPILATION if MS_LIB_AVAILABLE noinst_DATA = glib-2.0.lib +install_ms_lib_cmd = $(INSTALL) glib-2.0.lib $(DESTDIR)$(libdir) +uninstall_ms_lib_cmd = -rm $(DESTDIR)$(libdir)/glib-2.0.lib +endif +endif + install-ms-lib: - $(INSTALL) glib-2.0.lib $(DESTDIR)$(libdir) + $(install_ms_lib_cmd) uninstall-ms-lib: - -rm $(DESTDIR)$(libdir)/glib-2.0.lib -else -install-ms-lib: -uninstall-ms-lib: -endif + $(uninstall_ms_lib_cmd) libglib_2_0_la_SOURCES = \ garray.c \ @@ -251,8 +253,12 @@ if PLATFORM_WIN32 no_undefined = -no-undefined endif -if OS_WIN32 +if OS_WIN32_AND_DLL_COMPILATION export_symbols = -export-symbols glib.def + +glib_win32_res = glib-win32-res.o +glib_win32_res_ldflag = -Wl,$(glib_win32_res) + glib_def = glib.def install-def-file: @@ -267,11 +273,6 @@ uninstall-def-file: export_symbols = $(LIBTOOL_EXPORT_OPTIONS) endif -if OS_WIN32 -glib_win32_res = glib-win32-res.o -glib_win32_res_ldflag = -Wl,$(glib_win32_res) -endif - if ENABLE_REGEX if USE_SYSTEM_PCRE pcre_lib = $(PCRE_LIBS) @@ -303,10 +304,10 @@ INSTALL_PROGS += gspawn-win32-helper gspawn-win32-helper-console gspawn_win32_helper_LDADD = libglib-2.0.la gspawn_win32_helper_LDFLAGS = -mwindows gspawn_win32_helper_console_LDADD = libglib-2.0.la +endif glib-win32-res.o: glib.rc $(WINDRES) glib.rc $@ -endif bin_PROGRAMS = ${INSTALL_PROGS} diff --git a/gmodule/Makefile.am b/gmodule/Makefile.am index c238110ff..852aabbad 100644 --- a/gmodule/Makefile.am +++ b/gmodule/Makefile.am @@ -40,27 +40,32 @@ top_builddir_full=`cd \$(top_builddir); pwd` lib_LTLIBRARIES = libgmodule-2.0.la +if OS_WIN32_AND_DLL_COMPILATION if MS_LIB_AVAILABLE noinst_DATA = gmodule-2.0.lib +install_ms_lib_cmd = $(INSTALL) gmodule-2.0.lib $(DESTDIR)$(libdir) +uninstall_ms_lib_cmd = -rm $(DESTDIR)$(libdir)/gmodule-2.0.lib +endif +endif + install-ms-lib: - $(INSTALL) gmodule-2.0.lib $(DESTDIR)$(libdir) + $(install_ms_lib_cmd) uninstall-ms-lib: - -rm $(DESTDIR)$(libdir)/gmodule-2.0.lib -else -install-ms-lib: -uninstall-ms-lib: -endif + $(uninstall_ms_lib_cmd) if PLATFORM_WIN32 no_undefined = -no-undefined endif -if OS_WIN32 +if OS_WIN32_AND_DLL_COMPILATION export_symbols = -export-symbols $(srcdir)/gmodule.def gmodule_def = gmodule.def +gmodule_win32_res = gmodule-win32-res.o +gmodule_win32_res_ldflag = -Wl,$(gmodule_win32_res) + install-def-file: $(INSTALL) $(srcdir)/gmodule.def $(DESTDIR)$(libdir)/gmodule-2.0.def @@ -71,11 +76,6 @@ install-def-file: uninstall-def-file: endif -if OS_WIN32 -gmodule_win32_res = gmodule-win32-res.o -gmodule_win32_res_ldflag = -Wl,$(gmodule_win32_res) -endif - libgmodule_2_0_la_SOURCES = gmodule.c libgmodule_2_0_la_LDFLAGS = \ $(gmodule_win32_res_ldflag) \ @@ -87,10 +87,8 @@ libgmodule_2_0_la_LIBADD = $(G_MODULE_LIBS_EXTRA) $(G_MODULE_LIBS) $(libglib) libgmodule_2_0_la_DEPENDENCIES = $(gmodule_win32_res) $(gmodule_def) -if OS_WIN32 gmodule-win32-res.o: gmodule.rc $(WINDRES) gmodule.rc $@ -endif gmodule-2.0.lib: libgmodule-2.0.la gmodule.def lib -name:libgmodule-2.0-$(LT_CURRENT_MINUS_AGE).dll -def:$(srcdir)/gmodule.def -out:$@ diff --git a/gobject/Makefile.am b/gobject/Makefile.am index c348b6762..4d59fc035 100644 --- a/gobject/Makefile.am +++ b/gobject/Makefile.am @@ -36,27 +36,32 @@ libglib = $(top_builddir)/glib/libglib-2.0.la # libraries to compile and install lib_LTLIBRARIES = libgobject-2.0.la +if OS_WIN32_AND_DLL_COMPILATION if MS_LIB_AVAILABLE noinst_DATA = gobject-2.0.lib +install_ms_lib_cmd = $(INSTALL) gobject-2.0.lib $(DESTDIR)$(libdir) +uninstall_ms_lib_cmd = -rm $(DESTDIR)$(libdir)/gobject-2.0.lib +endif +endif + install-ms-lib: - $(INSTALL) gobject-2.0.lib $(DESTDIR)$(libdir) + $(install_ms_lib_cmd) uninstall-ms-lib: - -rm $(DESTDIR)$(libdir)/gobject-2.0.lib -else -install-ms-lib: -uninstall-ms-lib: -endif + $(uninstall_ms_lib_cmd) if PLATFORM_WIN32 no_undefined = -no-undefined endif -if OS_WIN32 +if OS_WIN32_AND_DLL_COMPILATION export_symbols = -export-symbols gobject.def gobject_def = gobject.def +gobject_win32_res = gobject-win32-res.o +gobject_win32_res_ldflag = -Wl,$(gobject_win32_res) + install-def-file: $(INSTALL) gobject.def $(DESTDIR)$(libdir)/gobject-2.0.def @@ -69,11 +74,6 @@ uninstall-def-file: export_symbols = $(LIBTOOL_EXPORT_OPTIONS) endif -if OS_WIN32 -gobject_win32_res = gobject-win32-res.o -gobject_win32_res_ldflag = -Wl,$(gobject_win32_res) -endif - # libtool stuff: set version and export symbols for resolving libgobjectincludedir = $(includedir)/glib-2.0/gobject libgobject_2_0_la_LDFLAGS = \ @@ -240,11 +240,8 @@ BUILT_EXTRA_DIST = \ gobjectalias.h \ gobjectaliasdef.c - -if OS_WIN32 gobject-win32-res.o: gobject.rc $(WINDRES) gobject.rc $@ -endif gobject-2.0.lib: libgobject-2.0.la gobject.def lib -name:libgobject-2.0-$(LT_CURRENT_MINUS_AGE).dll -def:gobject.def -out:$@ diff --git a/gthread/Makefile.am b/gthread/Makefile.am index 07dc0a20d..ab7dd2aa8 100644 --- a/gthread/Makefile.am +++ b/gthread/Makefile.am @@ -28,24 +28,26 @@ top_builddir_full=`cd \$(top_builddir); pwd` lib_LTLIBRARIES = libgthread-2.0.la +if OS_WIN32_AND_DLL_COMPILATION if MS_LIB_AVAILABLE noinst_DATA = gthread-2.0.lib +install_ms_lib_cmd = $(INSTALL) gthread-2.0.lib $(DESTDIR)$(libdir) +uninstall_ms_lib_cmd = -rm $(DESTDIR)$(libdir)/gthread-2.0.lib +endif +endif + install-ms-lib: - $(INSTALL) gthread-2.0.lib $(DESTDIR)$(libdir) + $(install_ms_lib_cmd) uninstall-ms-lib: - -rm $(DESTDIR)$(libdir)/gthread-2.0.lib -else -install-ms-lib: -uninstall-ms-lib: -endif + $(uninstall_ms_lib_cmd) if PLATFORM_WIN32 no_undefined = -no-undefined endif -if OS_WIN32 +if OS_WIN32_AND_DLL_COMPILATION export_symbols = -export-symbols $(srcdir)/gthread.def gthread_def = gthread.def @@ -59,7 +61,7 @@ install-def-file: uninstall-def-file: endif -if OS_WIN32 +if OS_WIN32_AND_DLL_COMPILATION gthread_win32_res = gthread-win32-res.o gthread_win32_res_ldflag = -Wl,$(gthread_win32_res) endif @@ -74,10 +76,8 @@ libgthread_2_0_la_LIBADD = $(G_THREAD_LIBS_EXTRA) $(G_THREAD_LIBS_FOR_GTHREAD) $ libgthread_2_0_la_DEPENDENCIES = $(gthread_win32_res) $(gthread_def) -if OS_WIN32 gthread-win32-res.o: gthread.rc $(WINDRES) gthread.rc $@ -endif gthread-2.0.lib: libgthread-2.0.la gthread.def lib -name:libgthread-2.0-$(LT_CURRENT_MINUS_AGE).dll -def:$(srcdir)/gthread.def -out:$@