summaryrefslogtreecommitdiff
path: root/backends/backend-library.mk
blob: 2994fae902f2064bbbdfad130a71a731b1359f98 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
#
# Common build variable values for folks backend libraries.
#
# Required variables:
#  - BACKEND_NAME = name-of-backend
#    (this must be the same as the source directory and the backend's type ID)
#  - BACKEND_NAME_C = NameOfBackend
#    (BACKEND_NAME in CamelCase for the GIR filename)
#  - BACKEND_API_VERSION = $(FOLKS_something_API_VERSION)
#  - BACKEND_LT_VERSION = $(FOLKS_something_LT_VERSION)
#    (from configure.ac)
#  - BACKEND_SYMBOLS_REGEX = something
#    (regex to pass to -export-symbols-regex to determine the backend’s public
#     symbols)
#  - BACKEND_NAMESPACE = Something
#    (Vala namespace used in the backend code)
# Required targets:
#  - libfolks-$(BACKEND_NAME).la
# Derived helper variables (these may be overridden for weird backends):
#  - BACKEND_LIBRARY_NAME
#  - BACKEND_LA_FILE
#  - BACKEND_PC_FILE
#  - BACKEND_GIR_FILE
#  - BACKEND_VAPI_FILE
#  - BACKEND_DEPS_FILE
#  - BACKEND_HEADER_FILE
# Defined backend library variables (these must be included in the
# backend-specific variables):
#  - backend_library_sources
#  - backend_library_valaflags
#  - backend_library_cppflags
#  - backend_library_cflags
#  - backend_library_libadd
#  - backend_library_ldflags
# in addition, most of these have *_generic variants which don’t include
# backend-specific flags (for use in helper and utility libraries).
# The defined variables include flags for the standard dependencies:
#  - folks
#  - GIO
#  - GLib
#  - libgee
# and also include the relevant $(AM_*) variables.
#
# Additional rules are included for generating and installing the following:
#  - pkg-config
#  - VAPI and deps files
#  - C header file
#  - GIR and typelib files

# Derived (but still overrideable) variables
BACKEND_LIBRARY_NAME = folks-$(BACKEND_NAME)
BACKEND_LA_FILE = lib$(BACKEND_LIBRARY_NAME).la
BACKEND_PC_FILE = $(BACKEND_LIBRARY_NAME).pc.in
BACKEND_GIR_FILE = Folks$(BACKEND_NAME_C)-$(BACKEND_API_VERSION).gir
BACKEND_VAPI_FILE = $(BACKEND_LIBRARY_NAME).vapi
BACKEND_DEPS_FILE = $(BACKEND_LIBRARY_NAME).deps
BACKEND_HEADER_FILE = folks/$(BACKEND_LIBRARY_NAME).h


# Added in case it's needed in the future.
backend_library_sources = \
	namespace.vala \
	$(NULL)

backend_library_cppflags_generic = \
	$(AM_CPPFLAGS) \
	-I$(top_srcdir) \
	-I$(top_srcdir)/folks \
	-include $(CONFIG_HEADER) \
	-include $(top_srcdir)/folks/warnings.h \
	-DPACKAGE_DATADIR=\"$(pkgdatadir)\" \
	$(NULL)
backend_library_cppflags = \
	$(backend_library_cppflags_generic) \
	-DBACKEND_NAME=\"$(BACKEND_NAME)\" \
	-DG_LOG_DOMAIN=\"$(BACKEND_NAME)\" \
	$(NULL)

backend_library_valaflags_generic = \
	$(AM_VALAFLAGS) \
	$(TARGET_VALAFLAGS) \
	$(ERROR_VALAFLAGS) \
	--vapidir=. \
	--vapidir=$(top_srcdir)/folks \
	--vapidir=$(top_builddir)/folks \
	--pkg build-conf \
	--pkg folks \
	--pkg folks-internal \
	--pkg folks-generics \
	--pkg gee-0.8 \
	--pkg gio-2.0 \
	--pkg gobject-2.0 \
	$(NULL)
backend_library_valaflags = \
	$(backend_library_valaflags_generic) \
	--includedir folks \
	--gir $(BACKEND_GIR_FILE) \
	--library $(BACKEND_LIBRARY_NAME) \
	--vapi $(BACKEND_VAPI_FILE) \
	-H $(BACKEND_HEADER_FILE) \
	$(NULL)

backend_library_cflags_generic = \
	$(AM_CFLAGS) \
	$(ERROR_CFLAGS) \
	$(CODE_COVERAGE_CFLAGS) \
	$(GIO_CFLAGS) \
	$(GLIB_CFLAGS) \
	$(GEE_CFLAGS) \
	$(NULL)
backend_library_cflags = $(backend_library_cflags_generic)

backend_library_libadd_generic = \
	$(AM_LIBADD) \
	$(top_builddir)/folks/libfolks.la \
	$(GIO_LIBS) \
	$(GLIB_LIBS) \
	$(GEE_LIBS) \
	$(NULL)
backend_library_libadd = \
	$(backend_library_libadd_generic) \
	$(NULL)

backend_library_ldflags_generic = \
	$(AM_LDFLAGS) \
	$(CODE_COVERAGE_LDFLAGS) \
	$(NULL)
backend_library_ldflags = \
	$(backend_library_ldflags_generic) \
	-version-info $(BACKEND_LT_VERSION) \
	-export-symbols-regex $(BACKEND_SYMBOLS_REGEX) \
	$(NULL)


# Namespace Vala file
#
# FIXME: This can be removed once the backend namespaces have been sanitised.
# https://bugzilla.gnome.org/show_bug.cgi?id=711544
#
# This file sets namespace and version attributes for GIR.
namespace.vala:
	$(AM_V_GEN)echo -e "[CCode (gir_namespace = \"Folks$(BACKEND_NAME_C)\", gir_version = \"$(BACKEND_API_VERSION)\")]\nnamespace $(BACKEND_NAMESPACE) {}" > $@

MAINTAINERCLEANFILES += namespace.vala

# Installed headers
folks_includedir = $(includedir)/folks
folks_include_HEADERS = $(BACKEND_HEADER_FILE)

vapidir = $(datadir)/vala/vapi
dist_vapi_DATA = \
	$(BACKEND_VAPI_FILE) \
	$(BACKEND_DEPS_FILE) \
	$(NULL)


# pkg-config
pkgconfig_in = $(BACKEND_PC_FILE)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = $(pkgconfig_in:.in=)
EXTRA_DIST += $(pkgconfig_in)


# Introspection
-include $(INTROSPECTION_MAKEFILE)
INTROSPECTION_SCANNER_ARGS = \
	$(ERROR_INTROSPECTION_SCANNER_ARGS) \
	--add-include-path=$(srcdir) \
	--add-include-path=$(abs_top_builddir)/folks \
	--warn-all \
	$(NULL)

# Set PKG_CONFIG_PATH so we can find the backend's uninstalled pkg-config file.
INTROSPECTION_SCANNER_ENV = \
	PKG_CONFIG_PATH=$(top_builddir)/folks:$${PKG_CONFIG_PATH}

INTROSPECTION_COMPILER_ARGS = \
	--includedir=$(srcdir) \
	--includedir=$(abs_top_builddir)/folks \
	$(NULL)

if HAVE_INTROSPECTION
$(BACKEND_GIR_FILE): $(BACKEND_LA_FILE)
GIRS = $(BACKEND_GIR_FILE)

girdir = $(datadir)/gir-1.0
dist_gir_DATA = $(GIRS)

MAINTAINERCLEANFILES += $(dist_gir_DATA)

typelibdir = $(libdir)/girepository-1.0
nodist_typelib_DATA = $(GIRS:.gir=.typelib)

CLEANFILES += $(nodist_typelib_DATA)
endif