[folks] build: Factor common automakery out of backends ’ Makefile.ams



commit 1760767bfd73addf52b02063377ed921b52df09b
Author: Philip Withnall <philip withnall collabora co uk>
Date:   Mon Oct 28 10:15:56 2013 +0000

    build: Factor common automakery out of backends’ Makefile.ams
    
    This makes the backends’ build process so much more consistent, and reduces
    a huge amount of copy–paste automakery.

 backends/Makefile.am              |    2 +
 backends/backend.mk               |   80 +++++++++++++++++++++++++++++++++++++
 backends/eds/Makefile.am          |   43 ++++----------------
 backends/eds/backend.mk           |    1 -
 backends/key-file/Makefile.am     |   49 ++++++-----------------
 backends/libsocialweb/Makefile.am |   49 ++++++-----------------
 backends/ofono/Makefile.am        |   60 ++++++++--------------------
 backends/telepathy/Makefile.am    |   55 ++++++-------------------
 backends/tracker/Makefile.am      |   44 ++++----------------
 9 files changed, 154 insertions(+), 229 deletions(-)
---
diff --git a/backends/Makefile.am b/backends/Makefile.am
index fd51853..0da4773 100644
--- a/backends/Makefile.am
+++ b/backends/Makefile.am
@@ -31,4 +31,6 @@ DIST_SUBDIRS = \
        tracker \
        $(NULL)
 
+EXTRA_DIST = backend.mk
+
 -include $(top_srcdir)/git.mk
diff --git a/backends/backend.mk b/backends/backend.mk
new file mode 100644
index 0000000..32a7590
--- /dev/null
+++ b/backends/backend.mk
@@ -0,0 +1,80 @@
+#
+# Common build variable values for folks backends.
+#
+# Required variables:
+#  - BACKEND_NAME = "name-of-backend"
+#    (this must be the same as the source directory and the backend's type ID)
+# Required targets:
+#  - $(BACKEND_NAME).la
+# Defined variables (these must be included in the backend-specific variables):
+#  - backend_sources
+#  - backend_valaflags
+#  - backend_cppflags
+#  - backend_cflags
+#  - backend_libadd
+#  - backend_ldflags
+# The defined variables include flags for the standard dependencies:
+#  - folks
+#  - GIO
+#  - GLib
+#  - libgee
+# and also include the relevant $(AM_*) variables.
+#
+# Note: It is suggested that Makefile.ams include the flags
+# '-module -avoid-version' in their *_LDFLAGS variable, as well as in
+# $(backend_ldflags). This shuts up automake's warnings about the library name
+# not being prefixed by 'lib'.
+
+# Added in case it's needed in the future.
+backend_sources = \
+       $(NULL)
+
+backend_valaflags = \
+       $(AM_VALAFLAGS) \
+       $(ERROR_VALAFLAGS) \
+       --vapidir=. \
+       --vapidir=$(top_srcdir)/folks \
+       --vapidir=$(top_builddir)/folks \
+       --pkg folks \
+       --pkg folks-internal \
+       --pkg gee-0.8 \
+       --pkg gio-2.0 \
+       --pkg gobject-2.0 \
+       $(NULL)
+
+backend_cppflags = \
+       $(AM_CPPFLAGS) \
+       -I$(top_srcdir) \
+       -I$(top_srcdir)/folks \
+       -include $(CONFIG_HEADER) \
+       -include $(top_srcdir)/folks/warnings.h \
+       -DPACKAGE_DATADIR=\"$(pkgdatadir)\" \
+       -DBACKEND_NAME=\"$(BACKEND_NAME)\" \
+       -DG_LOG_DOMAIN=\"$(BACKEND_NAME)\" \
+       $(NULL)
+
+backend_cflags = \
+       $(AM_CFLAGS) \
+       $(ERROR_CFLAGS) \
+       $(CODE_COVERAGE_CFLAGS) \
+       $(GIO_CFLAGS) \
+       $(GLIB_CFLAGS) \
+       $(GEE_CFLAGS) \
+       $(NULL)
+
+backend_libadd = \
+       $(AM_LIBADD) \
+       $(top_builddir)/folks/libfolks.la \
+       $(GIO_LIBS) \
+       $(GLIB_LIBS) \
+       $(GEE_LIBS) \
+       $(NULL)
+
+backend_ldflags = \
+       $(AM_LDFLAGS) \
+       $(CODE_COVERAGE_LDFLAGS) \
+       -shared \
+       -fPIC \
+       -module \
+       -avoid-version \
+       $(NULL)
diff --git a/backends/eds/Makefile.am b/backends/eds/Makefile.am
index db576f4..ec9d86a 100644
--- a/backends/eds/Makefile.am
+++ b/backends/eds/Makefile.am
@@ -6,72 +6,45 @@ backenddir = $(BACKEND_DIR)/eds
 backend_LTLIBRARIES = eds.la
 
 eds_la_VALAFLAGS = \
-       $(AM_VALAFLAGS) \
-       $(ERROR_VALAFLAGS) \
-       --vapidir=. \
+       $(backend_valaflags) \
        --vapidir=$(top_builddir)/backends/eds/lib \
-       --vapidir=$(top_srcdir)/folks \
-       --vapidir=$(top_builddir)/folks \
-       --pkg folks \
-       --pkg folks-internal \
        --pkg folks-eds \
-       --pkg gee-0.8 \
-       --pkg gio-2.0 \
-       --pkg gobject-2.0 \
        --pkg libebook-1.2 \
        --pkg libedataserver-1.2 \
        --pkg libxml-2.0 \
        $(NULL)
 
 eds_la_SOURCES = \
+       $(backend_sources) \
        eds-backend.vala \
        eds-backend-factory.vala \
        $(NULL)
 
 eds_la_CPPFLAGS = \
-       -I$(top_srcdir) \
-       -I$(top_srcdir)/folks \
+       $(backend_cppflags) \
        -I$(top_srcdir)/backends/eds/lib \
        -I$(top_srcdir)/backends/eds/lib/folks \
-       -include $(CONFIG_HEADER) \
-       -include $(top_srcdir)/folks/warnings.h \
-       -DPACKAGE_DATADIR=\"$(pkgdatadir)\" \
-       -DBACKEND_NAME=\"$(BACKEND_NAME)\" \
-       -DG_LOG_DOMAIN=\"$(BACKEND_NAME)\" \
        $(NULL)
 
 eds_la_CFLAGS = \
-       $(AM_CFLAGS) \
-       $(ERROR_CFLAGS) \
-       $(CODE_COVERAGE_CFLAGS) \
-       $(GIO_CFLAGS) \
-       $(GLIB_CFLAGS) \
-       $(GEE_CFLAGS) \
+       $(backend_cflags) \
        $(EBOOK_CFLAGS) \
        $(EDATASERVER_CFLAGS) \
        $(LIBXML_CFLAGS) \
        $(NULL)
 
 eds_la_LIBADD = \
-       $(AM_LIBADD) \
+       $(backend_libadd) \
        $(top_builddir)/backends/eds/lib/libfolks-eds.la \
-       $(top_builddir)/folks/libfolks.la \
-       $(GIO_LIBS) \
-       $(GLIB_LIBS) \
-       $(GEE_LIBS) \
        $(EBOOK_LIBS) \
        $(EDATASERVER_LIBS) \
        $(LIBXML_LIBS) \
        $(NULL)
 
 eds_la_LDFLAGS = \
-       $(AM_LDFLAGS) \
-       $(CODE_COVERAGE_LDFLAGS) \
-       -shared \
-       -fPIC \
-       -module \
-       -avoid-version \
+       -module -avoid-version \
+       $(backend_ldflags) \
        $(NULL)
 
--include backend.mk
+-include $(top_srcdir)/backends/backend.mk
 -include $(top_srcdir)/git.mk
diff --git a/backends/key-file/Makefile.am b/backends/key-file/Makefile.am
index 6fc2150..348f8a1 100644
--- a/backends/key-file/Makefile.am
+++ b/backends/key-file/Makefile.am
@@ -3,60 +3,35 @@ BACKEND_NAME = "key-file"
 backenddir = $(BACKEND_DIR)/key-file
 backend_LTLIBRARIES = key-file.la
 
+key_file_la_VALAFLAGS = \
+       $(backend_valaflags) \
+       --pkg folks-generics \
+       $(NULL)
+
 key_file_la_SOURCES = \
+       $(backend_sources) \
        kf-backend.vala \
        kf-backend-factory.vala \
        kf-persona.vala \
        kf-persona-store.vala \
        $(NULL)
 
-key_file_la_VALAFLAGS = \
-       $(AM_VALAFLAGS) \
-       $(ERROR_VALAFLAGS) \
-       --vapidir=. \
-       --vapidir=$(top_srcdir)/folks \
-       --pkg folks \
-       --pkg folks-generics \
-       --pkg folks-internal \
-       --pkg gee-0.8 \
-       --pkg gio-2.0 \
-       --pkg gobject-2.0 \
-       $(NULL)
-
 key_file_la_CPPFLAGS = \
-       -I$(top_srcdir) \
-       -I$(top_srcdir)/folks \
-       -include $(CONFIG_HEADER) \
-       -include $(top_srcdir)/folks/warnings.h \
-       -DPACKAGE_DATADIR=\"$(pkgdatadir)\" \
-       -DBACKEND_NAME=\"$(BACKEND_NAME)\" \
-       -DG_LOG_DOMAIN=\"$(BACKEND_NAME)\" \
+       $(backend_cppflags) \
        $(NULL)
 
 key_file_la_CFLAGS = \
-       $(AM_CFLAGS) \
-       $(ERROR_CFLAGS) \
-       $(CODE_COVERAGE_CFLAGS) \
-       $(GIO_CFLAGS) \
-       $(GLIB_CFLAGS) \
-       $(GEE_CFLAGS) \
+       $(backend_cflags) \
        $(NULL)
 
 key_file_la_LIBADD = \
-       $(AM_LIBADD) \
-       $(GIO_LIBS) \
-       $(GLIB_LIBS) \
-       $(GEE_LIBS) \
-       $(top_builddir)/folks/libfolks.la \
+       $(backend_libadd) \
        $(NULL)
 
 key_file_la_LDFLAGS = \
-       $(AM_LDFLAGS) \
-       $(CODE_COVERAGE_LDFLAGS) \
-       -shared \
-       -fPIC \
-       -module \
-       -avoid-version \
+       -module -avoid-version \
+       $(backend_ldflags) \
        $(NULL)
 
+-include $(top_srcdir)/backends/backend.mk
 -include $(top_srcdir)/git.mk
diff --git a/backends/libsocialweb/Makefile.am b/backends/libsocialweb/Makefile.am
index b33b425..67290e8 100644
--- a/backends/libsocialweb/Makefile.am
+++ b/backends/libsocialweb/Makefile.am
@@ -2,68 +2,43 @@ SUBDIRS = lib
 
 BACKEND_NAME = "libsocialweb"
 
+backenddir = $(BACKEND_DIR)/libsocialweb
+backend_LTLIBRARIES = libsocialweb.la
+
 libsocialweb_la_VALAFLAGS = \
-       $(AM_VALAFLAGS) \
-       $(ERROR_VALAFLAGS) \
-       --vapidir=. \
+       $(backend_valaflags) \
        --vapidir=$(top_builddir)/backends/libsocialweb/lib \
-       --vapidir=$(top_srcdir)/folks \
-       --pkg folks \
-       --pkg folks-internal \
        --pkg folks-libsocialweb \
-       --pkg gee-0.8 \
-       --pkg gio-2.0 \
-       --pkg gobject-2.0 \
        --pkg libsocialweb-client \
        $(NULL)
 
-backenddir = $(BACKEND_DIR)/libsocialweb
-backend_LTLIBRARIES = libsocialweb.la
-
 libsocialweb_la_SOURCES = \
+       $(backend_sources) \
        sw-backend.vala \
        sw-backend-factory.vala \
        $(NULL)
 
 libsocialweb_la_CPPFLAGS = \
-       -I$(top_srcdir) \
-       -I$(top_srcdir)/folks \
+       $(backend_cppflags) \
        -I$(top_srcdir)/backends/libsocialweb/lib \
        -I$(top_srcdir)/backends/libsocialweb/lib/folks \
-       -include $(CONFIG_HEADER) \
-       -include $(top_srcdir)/folks/warnings.h \
-       -DPACKAGE_DATADIR=\"$(pkgdatadir)\" \
-       -DBACKEND_NAME=\"$(BACKEND_NAME)\" \
-       -DG_LOG_DOMAIN=\"$(BACKEND_NAME)\" \
        $(NULL)
 
 libsocialweb_la_CFLAGS = \
-       $(AM_CFLAGS) \
-       $(ERROR_CFLAGS) \
-       $(CODE_COVERAGE_CFLAGS) \
-       $(GIO_CFLAGS) \
-       $(GLIB_CFLAGS) \
-       $(GEE_CFLAGS) \
+       $(backend_cflags) \
        $(SW_CLIENT_CFLAGS) \
        $(NULL)
 
 libsocialweb_la_LIBADD = \
-       $(AM_LIBADD) \
-       $(GIO_LIBS) \
-       $(GLIB_LIBS) \
-       $(GEE_LIBS) \
-       $(top_builddir)/folks/libfolks.la \
+       $(backend_libadd) \
+       $(top_builddir)/backends/libsocialweb/lib/libfolks-libsocialweb.la \
        $(SW_CLIENT_LIBS) \
-       lib/libfolks-libsocialweb.la \
        $(NULL)
 
 libsocialweb_la_LDFLAGS = \
-       $(AM_LDFLAGS) \
-       $(CODE_COVERAGE_LDFLAGS) \
-       -shared \
-       -fPIC \
-       -module \
-       -avoid-version \
+       -module -avoid-version \
+       $(backend_ldflags) \
        $(NULL)
 
+-include $(top_srcdir)/backends/backend.mk
 -include $(top_srcdir)/git.mk
diff --git a/backends/ofono/Makefile.am b/backends/ofono/Makefile.am
index 2f307bf..1c9bb15 100644
--- a/backends/ofono/Makefile.am
+++ b/backends/ofono/Makefile.am
@@ -3,7 +3,18 @@ BACKEND_NAME = "ofono"
 backenddir = $(BACKEND_DIR)/ofono
 backend_LTLIBRARIES = ofono.la
 
+# FIXME: libedataserver-1.2 doesn't need to be explicitly mentioned
+# once we depend on a libebook version that includes libedataserver-1.2
+# in libebook-1.2.deps.
+ofono_la_VALAFLAGS = \
+       $(backend_valaflags) \
+       --pkg folks-generics \
+       --pkg libebook-1.2 \
+       --pkg libedataserver-1.2 \
+       $(NULL)
+
 ofono_la_SOURCES = \
+       $(backend_sources) \
        ofono-backend.vala \
        ofono-backend-factory.vala \
        ofono-persona.vala \
@@ -11,61 +22,24 @@ ofono_la_SOURCES = \
        org-ofono.vala \
        $(NULL)
 
-ofono_la_VALAFLAGS = \
-       $(AM_VALAFLAGS) \
-       $(ERROR_VALAFLAGS) \
-       --vapidir=. \
-       --vapidir=$(top_srcdir)/folks \
-       --pkg folks \
-       --pkg folks-generics \
-       --pkg folks-internal \
-       --pkg gee-0.8 \
-       --pkg gio-2.0 \
-       --pkg gobject-2.0 \
-       --pkg libebook-1.2 \
-       --pkg libedataserver-1.2 \
-       $(NULL)
-
-# FIXME: libedataserver-1.2 doesn't need to be explicitly mentioned
-# once we depend on libebook version that includes libedataserver-1.2
-# in libebook-1.2.deps.
-
 ofono_la_CPPFLAGS = \
-       -I$(top_srcdir) \
-       -I$(top_srcdir)/folks \
-       -include $(CONFIG_HEADER) \
-       -include $(top_srcdir)/folks/warnings.h \
-       -DPACKAGE_DATADIR=\"$(pkgdatadir)\" \
-       -DBACKEND_NAME=\"$(BACKEND_NAME)\" \
-       -DG_LOG_DOMAIN=\"$(BACKEND_NAME)\" \
+       $(backend_cppflags) \
        $(NULL)
 
 ofono_la_CFLAGS = \
-       $(AM_CFLAGS) \
-       $(ERROR_CFLAGS) \
-       $(CODE_COVERAGE_CFLAGS) \
-       $(GIO_CFLAGS) \
-       $(GLIB_CFLAGS) \
-       $(GEE_CFLAGS) \
+       $(backend_cflags) \
        $(EBOOK_CFLAGS) \
        $(NULL)
 
 ofono_la_LIBADD = \
-       $(AM_LIBADD) \
-       $(GIO_LIBS) \
-       $(GLIB_LIBS) \
-       $(GEE_LIBS) \
+       $(backend_libadd) \
        $(EBOOK_LIBS) \
-       $(top_builddir)/folks/libfolks.la \
        $(NULL)
 
 ofono_la_LDFLAGS = \
-       $(AM_LDFLAGS) \
-       $(CODE_COVERAGE_LDFLAGS) \
-       -shared \
-       -fPIC \
-       -module \
-       -avoid-version \
+       -module -avoid-version \
+       $(backend_ldflags) \
        $(NULL)
 
+-include $(top_srcdir)/backends/backend.mk
 -include $(top_srcdir)/git.mk
diff --git a/backends/telepathy/Makefile.am b/backends/telepathy/Makefile.am
index 44094ae..e1e918e 100644
--- a/backends/telepathy/Makefile.am
+++ b/backends/telepathy/Makefile.am
@@ -2,71 +2,44 @@ SUBDIRS = lib
 
 BACKEND_NAME = "telepathy"
 
+backenddir = $(BACKEND_DIR)/telepathy
+backend_LTLIBRARIES = telepathy.la
+
 telepathy_la_VALAFLAGS = \
-       $(AM_VALAFLAGS) \
-       $(ERROR_VALAFLAGS) \
-       --vapidir=$(abs_srcdir) \
-       --vapidir=$(abs_builddir) \
-       --vapidir=$(abs_top_srcdir)/backends/telepathy/lib \
-       --vapidir=$(abs_top_builddir)/backends/telepathy/lib \
-       --vapidir=$(abs_top_srcdir)/folks \
-       --vapidir=$(abs_top_builddir)/folks \
-       --pkg folks \
-       --pkg folks-internal \
+       $(backend_valaflags) \
+       --vapidir=$(top_srcdir)/backends/telepathy/lib \
+       --vapidir=$(top_builddir)/backends/telepathy/lib \
        --pkg folks-telepathy \
-       --pkg gee-0.8 \
-       --pkg gio-2.0 \
-       --pkg gobject-2.0 \
        --pkg telepathy-glib \
        $(NULL)
 
-backenddir = $(BACKEND_DIR)/telepathy
-backend_LTLIBRARIES = telepathy.la
-
 telepathy_la_SOURCES = \
+       $(backend_sources) \
        tp-backend.vala \
        tp-backend-factory.vala \
        $(NULL)
 
 telepathy_la_CPPFLAGS = \
-       -I$(top_srcdir) \
-       -I$(top_srcdir)/folks \
+       $(backend_cppflags) \
        -I$(top_srcdir)/backends/telepathy/lib \
        -I$(top_srcdir)/backends/telepathy/lib/folks \
-       -include $(CONFIG_HEADER) \
-       -include $(top_srcdir)/folks/warnings.h \
-       -DPACKAGE_DATADIR=\"$(pkgdatadir)\" \
-       -DBACKEND_NAME=\"$(BACKEND_NAME)\" \
-       -DG_LOG_DOMAIN=\"$(BACKEND_NAME)\" \
        $(NULL)
 
 telepathy_la_CFLAGS = \
-       $(AM_CFLAGS) \
-       $(ERROR_CFLAGS) \
-       $(CODE_COVERAGE_CFLAGS) \
-       $(GIO_CFLAGS) \
-       $(GLIB_CFLAGS) \
-       $(GEE_CFLAGS) \
+       $(backend_cflags) \
        $(TP_GLIB_CFLAGS) \
        $(NULL)
 
 telepathy_la_LIBADD = \
-       $(AM_LIBADD) \
-       $(GIO_LIBS) \
-       $(GLIB_LIBS) \
-       $(GEE_LIBS) \
-       $(top_builddir)/folks/libfolks.la \
+       $(backend_libadd) \
+       $(top_builddir)/backends/telepathy/lib/libfolks-telepathy.la \
        $(TP_GLIB_LIBS) \
-       lib/libfolks-telepathy.la \
        $(NULL)
 
 telepathy_la_LDFLAGS = \
-       $(AM_LDFLAGS) \
-       $(CODE_COVERAGE_LDFLAGS) \
-       -shared \
-       -fPIC \
-       -module \
-       -avoid-version \
+       -module -avoid-version \
+       $(backend_ldflags) \
        $(NULL)
 
+-include $(top_srcdir)/backends/backend.mk
 -include $(top_srcdir)/git.mk
diff --git a/backends/tracker/Makefile.am b/backends/tracker/Makefile.am
index b8f399a..f47218e 100644
--- a/backends/tracker/Makefile.am
+++ b/backends/tracker/Makefile.am
@@ -6,65 +6,39 @@ backenddir = $(BACKEND_DIR)/tracker
 backend_LTLIBRARIES = tracker.la
 
 tracker_la_VALAFLAGS = \
-       $(AM_VALAFLAGS) \
-       $(ERROR_VALAFLAGS) \
-       --vapidir=. \
-       --vapidir=vapi \
+       $(backend_valaflags) \
        --vapidir=$(top_builddir)/backends/tracker/lib \
-       --vapidir=$(top_srcdir)/folks \
-       --pkg folks \
-       --pkg folks-internal \
        --pkg folks-tracker \
-       --pkg gee-0.8 \
-       --pkg gio-2.0 \
-       --pkg gobject-2.0 \
        --pkg tracker-sparql-$(TRACKER_SPARQL_MAJOR) \
        $(NULL)
 
 tracker_la_SOURCES = \
+       $(backend_sources) \
        tr-backend.vala \
        tr-backend-factory.vala \
        $(NULL)
 
 tracker_la_CPPFLAGS = \
-       -I$(top_srcdir) \
-       -I$(top_srcdir)/folks \
+       $(backend_cppflags) \
        -I$(top_srcdir)/backends/tracker/lib \
        -I$(top_srcdir)/backends/tracker/lib/folks \
-       -include $(CONFIG_HEADER) \
-       -include $(top_srcdir)/folks/warnings.h \
-       -DPACKAGE_DATADIR=\"$(pkgdatadir)\" \
-       -DBACKEND_NAME=\"$(BACKEND_NAME)\" \
-       -DG_LOG_DOMAIN=\"$(BACKEND_NAME)\" \
        $(NULL)
 
 tracker_la_CFLAGS = \
-       $(AM_CFLAGS) \
-       $(ERROR_CFLAGS) \
-       $(CODE_COVERAGE_CFLAGS) \
-       $(GIO_CFLAGS) \
-       $(GLIB_CFLAGS) \
-       $(GEE_CFLAGS) \
+       $(backend_cflags) \
        $(TRACKER_SPARQL_CFLAGS) \
        $(NULL)
 
 tracker_la_LIBADD = \
-       $(AM_LIBADD) \
-       $(GIO_LIBS) \
-       $(GLIB_LIBS) \
-       $(GEE_LIBS) \
-       $(top_builddir)/folks/libfolks.la \
-       $(TRACKER_SPARQL_LIBS) \
+       $(backend_libadd) \
        $(top_builddir)/backends/tracker/lib/libfolks-tracker.la \
+       $(TRACKER_SPARQL_LIBS) \
        $(NULL)
 
 tracker_la_LDFLAGS = \
-       $(AM_LDFLAGS) \
-       $(CODE_COVERAGE_LDFLAGS) \
-       -shared \
-       -fPIC \
-       -module \
-       -avoid-version \
+       -module -avoid-version \
+       $(backend_ldflags) \
        $(NULL)
 
+-include $(top_srcdir)/backends/backend.mk
 -include $(top_srcdir)/git.mk


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]