build: Use subdir-objects with Autotools

We're eventually going to drop Autotools, but in the meantime we should
probably use idiomatic options and reduce warnings.

GLib is pretty much already safe for subdir-objects to be enabled,
except in the GIO tests, where the build references files that are
generated in a different level. For that, we can use the same solution
employed by GTK+, and link the appropriate file in the right
sub-directory.

https://bugzilla.gnome.org/show_bug.cgi?id=788989
This commit is contained in:
Emmanuele Bassi 2017-10-14 15:42:31 +01:00
parent 3d4fb44653
commit 5c13bf9bcf
2 changed files with 23 additions and 5 deletions

View File

@ -63,7 +63,7 @@ AC_CONFIG_MACRO_DIR([m4macros])
# Save this value here, since automake will set cflags later
cflags_set=${CFLAGS:+set}
AM_INIT_AUTOMAKE([1.11 -Wno-portability no-define no-dist-gzip dist-xz tar-ustar])
AM_INIT_AUTOMAKE([1.14 -Wno-portability no-define no-dist-gzip dist-xz tar-ustar subdir-objects])
AM_MAINTAINER_MODE([enable])
# Support silent build rules. Disable

View File

@ -231,11 +231,29 @@ socket_client_SOURCES = \
EXTRA_DIST += socket-common.c
uninstalled_test_extra_programs += gdbus-daemon
gdbus_daemon_SOURCES = gdbus-daemon.c
nodist_gdbus_daemon_SOURCES = \
$(top_builddir)/gio/gdbus-daemon-generated.c
gdbus_daemon_SOURCES = \
gdbus-daemon.c \
$(top_srcdir)/gio/gdbusdaemon.c
gdbus-daemon-generated.c \
gdbus-daemon-impl.c
CLEANFILES += gdbus-daemon-impl.c gdbus-daemon-generated.c gdbus-daemon-generated.h
# With subdir-objects we need to create a link to the original
# file in the right directory, otherwise libtool will complain
# that it cannot find the wrapper file
gdbus-daemon-impl.c: $(top_srcdir)/gio/gdbusdaemon.c
$(AM_V_GEN) $(LN_S) $^ $@
# These files are only generated on Windows builds inside GIO,
# but we want them on non-Windows builds for the tests
gdbus-daemon-generated.h gdbus-daemon-generated.c: $(top_srcdir)/gio/dbus-daemon.xml $(GDBUS_PYTHON_DEPS)
$(AM_V_GEN) UNINSTALLED_GLIB_SRCDIR=$(top_srcdir) \
UNINSTALLED_GLIB_BUILDDIR=$(top_builddir) \
$(PYTHON) $(top_srcdir)/gio/gdbus-2.0/codegen/gdbus-codegen.in \
--interface-prefix org. \
--generate-c-code gdbus-daemon-generated \
--c-namespace _G \
$(top_srcdir)/gio/dbus-daemon.xml \
$(NULL)
# -----------------------------------------------------------------------------
# Test programs buildable on UNIX only