summaryrefslogtreecommitdiff
path: root/src/Makefile-gen.am
blob: 132c5cc20d704d1ea3d2d852c3cdb52ea852696f (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
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
BACKENDS = @BACKENDS@

service_in_files = org.Moblin.SyncEvolution.service.in
if COND_DBUS
servicedir = $(DBUS_SERVICES_DIR)
service_DATA = $(service_in_files:.service.in=.service)
$(service_DATA): $(service_in_files) Makefile
	@sed -e "s|\@libexecdir\@|$(libexecdir)|" $< > $@

DBUS_DIR = dbus
else
if COND_GUI
# jump into interface directory directly instead of going through dbus
DBUS_DIR = dbus/interfaces
endif
endif

if COND_GUI
GUI_DIR = gtk-ui
endif

SUBDIRS = $(SYNTHESIS_SUBDIR) $(DBUS_DIR) core $(BACKENDS) $(GUI_DIR)
DIST_SUBDIRS = dbus core $(BACKENDS) gtk-ui
BUILT_SOURCES =

AM_CPPFLAGS = $(SUBDIRS:%=-I$(srcdir)/%) -I$(srcdir)/../test -I$(top_srcdir) $(BACKEND_CPPFLAGS) $(GLIB_CFLAGS)

EXTRA_PROGRAMS =
TESTS =
bin_PROGRAMS = syncevolution
if COND_DBUS
libexec_PROGRAMS = syncevo-dbus-server
endif

bin_SCRIPTS = synccompare
SYNCEVOLUTION_DEP =
if ENABLE_MODULES
else
SYNCEVOLUTION_LDADD += $(SYNCSOURCES)
SYNCEVOLUTION_DEP += $(SYNCSOURCES)
endif
EXTRA_DIST = shlibs.local Makefile-gen.am syncclient_sample_config.xml $(service_in_files)

TEMPLATE_FILES = @TEMPLATE_FILES@
nobase_dist_sysconf_DATA = $(TEMPLATE_FILES)

DISTCLEANFILES = synccompare
MAINTAINERCLEANFILES = Makefile.in
CLEANFILES = libstdc++.a client-test $(CLIENT_LIB_TEST_FILES)

# synccompare is created by replacing its 'import Algorithm::Diff;'
# with a simplified copy of Diff.pm.
synccompare : ../test/Algorithm/Diff.pm ../test/synccompare.pl
	perl -e '$$diff = shift; open(DIFF, "<$$diff"); ($$_) = split(/__END__/, join("", <DIFF>)); s/\*import.*//m; s/require +Exporter;//; s/^#.*\n//mg; s/ +#.*\n//mg; $$diff = $$_;' -e 'while(<>) {' @MODIFY_SYNCCOMPARE@ -e 's/use +Algorithm::Diff;/"# embedded version of Algorithm::Diff follows, copyright by the original authors\n" . $$diff . "# end of embedded Algorithm::Diff\n"/e; print;}' $+ >$@
	chmod u+x $@

CORE_SOURCES =

# The files which register backends have to be compiled into
# "client-test" and "syncevolution" in order to pull in the
# code from the libs which implement the backends.
#
# Unit testing also goes there.
#
# When using modules the registration is done inside the
# module and the register file is unnecessary. However, they
# still need to be included in "make dist".
BACKEND_REGISTRIES = @BACKEND_REGISTRIES@
if ENABLE_MODULES
EXTRA_DIST += $(BACKEND_REGISTRIES)
else
CORE_SOURCES += $(BACKEND_REGISTRIES)
endif

CORE_CXXFLAGS = $(SYNTHESIS_CFLAGS)
CORE_LDADD = $(SYNCEVOLUTION_LDADD) core/libsyncevolution.la $(GLIB_LIBS) $(LIBS)
CORE_DEP = $(SYNCEVOLUTION_DEP) core/libsyncevolution.la $(SYNTHESIS_DEP)
CORE_LD_FLAGS = -uSyncEvolution_Module_Version -Wl,--export-dynamic

# put link to static c++ library into current directory, needed if compiling with --enable-static-c++
libstdc++.a :
	path=`$(CXX) $(CORE_LDADD) $(LD_FLAGS) -print-file-name=libstdc++.a` && ln -s $$path .

syncevolution_SOURCES = \
	syncevolution.cpp \
	$(CORE_SOURCES)
nodist_syncevolution_SOURCES = ../test/test.cpp

# SYNCEVOLUTION_LDADD will be replaced with libsyncebook.la/libsyncecal.la/libsyncsqlite.la
# if linking statically against them, empty otherwise;
# either way this does not lead to a dependency on those libs - done explicitly
syncevolution_LDADD = $(CORE_LDADD)
syncevolution_LDFLAGS = $(CORE_LD_FLAGS)
syncevolution_CXXFLAGS = $(SYNCEVOLUTION_CXXFLAGS) $(CORE_CXXFLAGS)
syncevolution_DEPENDENCIES = $(EXTRA_LTLIBRARIES) $(CORE_DEP) # $(SYNTHESIS_DEP)

# rule which is only relevant when compiling Synthesis in subdirectory
#$(SYNTHESIS_LIB) : $(SYNTHESIS_SUBDIR)/all
#$(SYNTHESIS_SUBDIR)/% :
#	[ ! "$(SYNTHESIS_SUBDIR)" ] || ( cd ${@D} && $(MAKE) ${@F} )

# include Synthesis in distribution: package only files in git if using a git checkout
dist-hook:
	set -x; [ ! "$(SYNTHESIS_SUBDIR)" ] || \
	mkdir -p $(distdir)/synthesis && \
	if test -d "$(SYNTHESIS_SRC)/.git"; \
	then \
		( ( cd "$(SYNTHESIS_SRC)" && git archive HEAD ) | ( cd "$(distdir)/synthesis" && tar xf - && $$SHELL autogen.sh && rm -rf autom4te.cache ) ) && \
		( echo Creating ChangeLog && \
		  ( ( cd "$(SYNTHESIS_SRC)" && \
		      echo '# Generated by configure.  Do no edit.' && \
		      githash=`git show-ref --head --hash | head -1` && \
		      echo "# git revision $$githash"  && \
		      echo "# git tag `git describe --tags $$githash`" && \
		      echo && \
		      "$(top_srcdir)/missing" --run perl "$(top_srcdir)/build/gen-changelog.pl" ) > ChangeLog.tmp ) && \
		  mv -f ChangeLog.tmp "$(distdir)/synthesis/ChangeLog" || \
		  ( rm -f ChangeLog.tmp ; \
		     echo Failed to generate ChangeLog >&2 ) \
                ); \
	elif test $(SYNTHESIS_SRC) != "no-synthesis-source"; then \
		cp -a $(SYNTHESIS_SRC)/* $(distdir)/synthesis  && \
		for i in _build autom4te.cache; do [ ! -d "$(SYNTHESIS_SRC)/$$i" ] || chmod -R u+rwx "$(SYNTHESIS_SRC)/$$i"; done && \
		find "$(distdir)" -name .libs -o -name "*~" -o -name ".*" -o -name "*.o" -o -name "*.lo" -o -name CVS -o -name .svn -o -name .git -o -name autom4te.cache -print0 | xargs -0 rm -rf; \
	fi

clean-local: testclean
	rm -rf testcases

# files created during testing
testclean:
	rm -rf *.test.vcf *.log *.tests *.diff *.dat *Client_Sync_*client.*

distclean-local:
	rm -rf $(SYNTHESIS_SUBDIR)
	rm -rf $(CLEAN_CLIENT_SRC)

if COND_DBUS
syncevo_dbus_server_SOURCES = \
	syncevo-dbus-server.cpp syncevo-dbus-server.h \
	DBusSyncClient.cpp DBusSyncClient.h \
	$(CORE_SOURCES)
nodist_syncevo_dbus_server_SOURCES = \
	dbus/interfaces/syncevo-marshal.c \
	../test/test.cpp

syncevo_dbus_server_LDADD = $(DBUS_GLIB_LIBS) $(KEYRING_LIBS) $(CORE_LDADD)
syncevo_dbus_server_CPPFLAGS = -DHAVE_CONFIG_H -Idbus/interfaces $(DBUS_GLIB_CFLAGS) $(KEYRING_CFLAGS) $(AM_CPPFLAGS)
syncevo_dbus_server_CXXFLAGS = $(SYNCEVOLUTION_CXXFLAGS) $(CORE_CXXFLAGS)
syncevo_dbus_server_LDFLAGS = $(CORE_LD_FLAGS)
syncevo_dbus_server_DEPENDENCIES = $(EXTRA_LTLIBRARIES) $(CORE_DEP) $(SYNTHESIS_DEP)
endif

# With --disable-shared autotools links against libfunambol.a which does not
# pull any of the test suites into the test binary, so they would not be
# executed. The workaround is to explicitly set them as undefined on the
# link line.
client_test_SOURCES = \
	client-test-app.cpp \
	../test/ClientTest.cpp \
	../test/ClientTest.h \
	../test/client-test-main.cpp \
	$(CORE_SOURCES)
nodist_client_test_SOURCES = ../test/test.cpp

# Always compile the registry files into client-test because that is
# the only place where they are compiled with
# ENABLE_INTEGRATION_TESTS.  This works without undefined references
# because client-test is linked against all shared backend libraries
# (non-portable, but works).
if ENABLE_MODULES
client_test_SOURCES += $(BACKEND_REGISTRIES)
endif

# list of test file base files
#
# Generated files (testcases/ical20.ics.funambol.tem) are derived from
# the original base file ($(srcdir)/test/testcases/ical20.ics) by
# applying a patch ($(srcdir)/test/testcases/ical20.ics.funambol.tem.patch).
CLIENT_LIB_TEST_FILES = \
	testcases/vcard21.vcf \
	testcases/vcard30.vcf \
	testcases/ical20.ics \
	testcases/imemo20.ics \
	testcases/itodo20.ics

# all patch files
TEST_FILES_PATCHES = $(wildcard $(srcdir)/../test/testcases/*.patch)
# generated local files
TEST_FILES_GENERATED = $(subst .patch,,$(subst $(srcdir)/../test/,,$(TEST_FILES_PATCHES)))
# all patched files, regardless whether the patch already exists
TEST_FILES_PATCHED = $(wildcard testcases/*.tem)
# add files created via patches
CLIENT_LIB_TEST_FILES += $(TEST_FILES_GENERATED)

client_test_CPPFLAGS = -DHAVE_CONFIG_H -DENABLE_INTEGRATION_TESTS -DENABLE_UNIT_TESTS $(AM_CPPFLAGS)
client_test_CXXFLAGS = `cppunit-config --cflags` $(SYNCEVOLUTION_CXXFLAGS) $(CORE_CXXFLAGS)
client_test_LDFLAGS = `cppunit-config --libs` `nm core/.libs/libsyncevolution.a | grep funambolAutoRegisterRegistry | sed -e 's/.* /-u /'` $(CORE_LD_FLAGS)
client_test_LDADD = $(CORE_LDADD) $(SYNCSOURCES)
# These dependencies are intentionally a bit too broad:
# they ensure that all files are in place to *run* client-test.

# rule to generate patched files from patches:
# make cannot compute the dependencies completely, so run the commands
# on each make invocation and do the time stamp test ourselves
.PHONY: $(TEST_FILES_GENERATED)
$(TEST_FILES_GENERATED):
	@ mkdir -p src/testcases
	@ echo "checking whether server specific test cases $@ are up-to-date"
	set -e; \
	patchfile=$(srcdir)/../test/$@.patch; \
	basefile=$(srcdir)/../test/$(basename $(basename $@)); \
	[ ! $@ -ot $$patchfile ] && [ ! $@ -ot $$basefile ] || \
	(echo '*** foo'; echo '--- bar'; cat $$patchfile) | patch -o $@ $$basefile

# rule to regenerate patches:
# like generating the patched files, this is run every time.
# It must avoid making the patch file more recent than the
# patched file, otherwise the rule above would needlessly recreate
# it (not nice when having the file open in an editor).
#
# To avoid needlessly updating the content of the patch file,
# the first two lines with changing information (paths, file dates)
# are stripped from it.
.PHONY: testcase2patch
testcase2patch: $(TEST_FILES_GENERATED)
	@ echo "checking whether test case patch files are up-to-date"
	set -e; \
	for i in testcases/*.tem; do \
		patchfile=$(srcdir)/../test/$$i.patch; \
		basefile=$(srcdir)/../test/`echo $$i | cut -d . -f  -2`; \
		if [ $$patchfile -ot $$i ] || [ $$patchfile -ot $$basefile ]; then \
			diff -u $$basefile $$i | tail -n +3 > $$patchfile || true; \
			touch -r $$i $$patchfile; \
			echo "updated $$patchfile"; \
		fi; \
	done

# copy base test files
$(filter-out %.tem, $(filter testcases/%, $(subst $(srcdir)/../test/,,$(CLIENT_LIB_TEST_FILES)))) : % : $(srcdir)/../test/%
	mkdir -p testcases
	cp $< $@

# The binary does not really depend on the test cases, only running it does.
# Listing the dependencies here is done to ensure that one doesn't accidentally
# runs the binary with out-dated auxiliary files.
client_test_DEPENDENCIES = $(EXTRA_LTLIBRARIES) $(CORE_DEP) $(CLIENT_LIB_TEST_FILES) testcase2patch synccompare


# distribute test system?
if ENABLE_TESTING
# yes: install client-test in bindir, test files in datadir
TESTS += client-test
bin_PROGRAMS += client-test
nobase_dist_doc_DATA = $(CLIENT_LIB_TEST_FILES)
else
# The "all" dependency causes a rebuild even if the actual input files
# haven't changed. If client-test is part of the regular targets built
# by "all", then it must not depend on all!
EXTRA_PROGRAMS += client-test
nodist_client_test_SOURCES = $(CLIENT_LIB_TEST_FILES)
client_test_DEPENDENCIES += all
endif

# test program for output redirection, has to be built
# and run manually
EXTRA_PROGRAMS += abort-redirect
CLEANFILES += abort-redirect.log
abort_redirect_SOURCES = ../test/abort-redirect.cpp
abort_redirect_CPPFLAGS = -DHAVE_CONFIG_H $(AM_CPPFLAGS)
abort_redirect_CXXFLAGS = $(SYNCEVOLUTION_CXXFLAGS) $(CORE_CXXFLAGS)
abort_redirect_LDFLAGS = $(CORE_LD_FLAGS)
abort_redirect_LDADD = $(CORE_LDADD)
abort_redirect_DEPENDENCIES = all


# special target for testing with valgrind
valgrind : test
	valgrind --leak-check=yes --suppressions=valgrind.supp ./test

# Because backend-related variables need to be substituted in
# Makefile-gen.am we need an explicit rule to redo that work
# so that "make" rebuilds derived files correctly.
$(srcdir)/Makefile.am: Makefile-gen.am
	sed -e 's;[@]BACKEND_REGISTRIES[@];$(BACKEND_REGISTRIES);' \
	    -e 's;[@]BACKENDS[@];$(BACKENDS);' \
            -e 's;[@]TEMPLATE_FILES[@];$(TEMPLATE_FILES);' \
	    $< >$@

# old-style name for test program(s)
.PHONY: test
test: client-test