Imported Upstream version 1.2.99~20120606~SE~ff65aef~SYSYNC~2728cb4
[platform/upstream/syncevolution.git] / Makefile.am
1 include $(top_srcdir)/setup-variables.am
2 include $(top_srcdir)/autotroll.am
3 include $(top_srcdir)/build/build.am
4
5 AUTOMAKE_OPTIONS = subdir-objects
6
7 ## Process this file with automake to produce Makefile.in
8
9 ACLOCAL_AMFLAGS = -I m4 -I m4-repo ${ACLOCAL_FLAGS}
10
11 if COND_CORE
12 SUBDIRS += $(SYNTHESIS_SUBDIR)
13 else
14 SUBDIRS += $(SYNTHESIS_SUBDIR_INCLUDES)
15 endif
16
17 SUBDIRS += .
18
19 # choose D-Bus implementation
20 if COND_GIO_GDBUS
21 gdbus_dir = $(top_srcdir)/src/gdbusxx
22 gdbus_build_dir = src/gdbusxx
23 else
24 gdbus_dir = $(top_srcdir)/src/gdbus
25 gdbus_build_dir = src/gdbus
26 endif
27
28 disted_docs =
29 distbin_docs =
30
31 man_MANS =
32 include src/src.am
33 if COND_CORE
34 include test/test.am
35 SUBDIRS += po
36 disted_docs += README NEWS COPYING $(TEST_README_FILES) test/syncevo-http-server-logging.conf
37 distbin_docs += $(disted_docs)
38 dist_doc_DATA += $(disted_docs)
39 if COND_HTML_README
40 distbin_docs += README.html
41 # do not distribute in tarball.
42 doc_DATA += README.html
43 endif
44 if COND_MAN_PAGES
45 man_MANS += syncevolution.1
46 endif
47 endif
48 DIST_SUBDIRS += po
49
50 dist_noinst_DATA += \
51   HACKING \
52   LICENSE.txt \
53   LICENSE.LGPL-21 \
54   README.rst \
55   description \
56   autogen.sh \
57   Doxyfile \
58   po/LINGUAS.README
59
60 MAINTAINERCLEANFILES += Makefile.in config.h.in config.guess config.sub configure depcomp install-sh ltmain.sh missing mkinstalldirs
61
62 TEST_README_FILES = $(wildcard $(top_srcdir)/test/README.*)
63
64 DEV_FILE_PATTERN = $(1)$(2)/include $(1)$(2)/lib/*.so $(1)$(2)/lib/*.a $(1)$(2)/lib/*.la $(1)$(2)/lib/*/*.la $(1)$(2)/lib/pkgconfig
65
66 # binary distribution as .tar.gz
67 if COND_DBUS
68 # when building with D-Bus, we have no choice: the service has to go into /usr
69 # in order to be found
70 distbin : $(distbin_docs) INSTALL-tar-gz all
71         @ [ "$(BINSUFFIX)" ] || (echo "please invoke with e.g. 'make distbin BINSUFFIX=debian-3.1'"; exit 1 )
72         @ [ "$(prefix)" = "/usr" ] || (echo "please reconfigure with --prefix=/usr"; exit 1 )
73         rm -rf $(distdir)
74         $(MAKE) DESTDIR=`pwd`/$(distdir) install
75         $(MAKE) DESTDIR=`pwd`/$(distdir) installcheck
76         rm -rf $(call DEV_FILE_PATTERN,$(distdir),/usr)
77         for i in `find $(distdir) -type d | sort -r`; do rmdir $$i 2>/dev/null || true; done
78         mkdir -p $(distdir)/usr/share/doc/syncevolution
79         cp $(srcdir)/INSTALL-tar-gz $(distdir)/INSTALL
80         cp $(filter-out all, $+) $(distdir)/usr/share/doc/syncevolution
81         tar zcf $(distdir)-$(BINSUFFIX).tar.gz $(distdir)
82         rm -rf $(distdir)
83 else
84 # without D-Bus, we can simply create an archive with a bin directory
85 # and everything works
86 distbin : $(distbin_docs) all
87         @ [ "$(BINSUFFIX)" ] || (echo "please invoke with e.g. 'make distbin BINSUFFIX=debian-3.1'"; exit 1 ) 
88         rm -rf $(distdir)
89         $(MAKE) prefix=`pwd`/$(distdir) install
90         @echo removing developer files and empty directories
91         rm -rf $(call DEV_FILE_PATTERN,$(distdir),/)
92         for i in `find $(distdir) -type d | sort -r`; do rmdir $$i 2>/dev/null || true; done
93         cp $(filter-out all, $+) $(distdir)
94         tar zcf $(distdir)-$(BINSUFFIX).tar.gz $(distdir)
95         rm -rf $(distdir)
96 endif
97
98 iphone : SyncEvolution.plist
99
100 IPHONE_FILENAME = syncevolution-$(VERSION)-iphone.zip
101
102 SyncEvolution.plist : SyncEvolution.plist.in $(IPHONE_FILENAME)
103         $(AM_V_GEN)sed -e 's/__FILENAME__/$(IPHONE_FILENAME)/' \
104                        -e 's/__VERSION__/$(VERSION)/' \
105                        -e 's/__SIZE__/$(shell ls -l $(IPHONE_FILENAME) | sed -e 's/  */ /g' | cut -d ' ' -f 5)/' \
106                        $< >$@
107
108 $(IPHONE_FILENAME) : all
109         rm -rf syncevolution-iphone $@
110         $(MAKE) DESTDIR=`pwd`/syncevolution-iphone install
111         rm -rf `ls -1 -d syncevolution-iphone/usr/share/doc/syncevolution/*/spds/sources/* | grep -v addressbook`
112         perl -pi -e 's;SyncEvolution test #1;;;' \
113                  -e 's;^type = text/(x-)?vcard;type = addressbook;m;' \
114                  syncevolution-iphone/usr/share/doc/syncevolution/*/spds/sources/addressbook/config.txt
115         cd syncevolution-iphone && zip -r ../$(IPHONE_FILENAME) .
116
117 TYPE_deb = -D
118 TYPE_rpm = -R
119 # Dependency calculation is intentionally incomplete:
120 # - don't force dependency on specific EDS libs via backends, their versions change too much (handled via --enable-evolution-compatibility and dynamic loading of the backends)
121 # - ignore client-test dependencies (because users typically don't run it)
122 # - ignore backend dependencies (should never prevent installing the bundle)
123 # - be more flexible about kdelibs5 than dpkg-shlibdeps: it is found as package
124 #   for libkdeui.so.5 and libkdecore.so.5 on Ubuntu Lucid, but after Debian
125 #   Squeeze the package was replaced by individual library packages. On such
126 #   distros, libkdeui5 is what we need.
127 # - same for kdepimlibs5 -> libakonadi-kde4
128 REQUIRES_SED_KDE = -e 's/kdelibs5 ([^,]*),/kdelibs5 | libkdeui5,/g' -e 's/kdepimlibs5 ([^,]*),/kdepimlibs5 | libakonadi-kde4,/g'
129 REQUIRES_deb = --requires="'$(shell set -x; cd dist; LD_LIBRARY_PATH=$(distdir)/usr/lib:$(distdir)/usr/lib/syncevolution dpkg-shlibdeps -L$(srcdir)/src/shlibs.local --ignore-missing-info -O $$(for i in $$(find $(distdir) -type f -perm /u+x | grep -v -e client-test -e lib/syncevolution/backends/); do if file $$i | grep ELF >/dev/null; then echo $$i; fi; done) | sed $(REQUIRES_SED_KDE) -e 's/[^=]*=//')$(REQUIRES_deb_neon)'"
130 if NEON_COMPATIBILITY
131 # --enable-neon-compatibility in src/backends/webdav:
132 # replace dependencies from linking with hard-coded dlopen() dependencies
133 REQUIRES_deb_neon = , libneon27 (>= 0.29.0) | libneon27-gnutls (>= 0.29.0)
134 else
135 REQUIRES_deb_neon =
136 endif
137 VERSION_deb = 1:$(STABLE_VERSION)$(VERSION)
138 VERSION_rpm = `echo $(VERSION) | sed -e s/-/_/g`
139 RELEASE = 2
140
141 # The package name: BINSUFFIX is used to distinguish binaries
142 # for different Evolution releases.
143 PKGNAME=syncevolution$(patsubst %,-%,$(BINSUFFIX))
144
145 # This is a list of packages (potentially) provided on estamos.de.
146 # The current package conflicts with any of them, but not itself.
147 PKGS = $(addprefix syncevolution-evolution-, 2.6 2.8 2.12)
148
149 # When calling checkinstall we cannot install into /tmp
150 # because any file created there will be excluded: that makes
151 # sense, because "make install" might create temporary files
152 # there. The current directory might be in /tmp, so use $HOME.
153 #
154 # --replaces is necessary for migrating from syncevolution-evolution-<evover>
155 # to syncevolution-evolution (as per http://wiki.debian.org/Renaming_a_Package)
156 #
157 # When we build shared objects, then conflict with the corresponding
158 # system libs. The assumption is that the system library is named
159 # after the lib and its major version, which holds for libsmltk and
160 # libsynthesis in Debian.
161 deb rpm : dist/$(distdir) dist/debian/control
162         (echo "SyncEvolution - synchronizing personal information management data" && cat $(srcdir)/description) >description-pak
163         conflicts=`ls -1 dist/$(distdir)/usr/lib/*.so.[0123456789] | sed -e 's;.*/;;' -e 's/\.so\.//' -e 's/$$/, /'` && \
164         tmpdir=`mktemp -d $$HOME/syncevolution.XXXXXXXXXX` && \
165         trap "rm -rf $$tmpdir" EXIT && \
166         fakeroot checkinstall </dev/null \
167                 $(TYPE_$@) \
168                 $(REQUIRES_$@) \
169                 --fstrans=yes \
170                 --strip=no \
171                 --pkgversion=$(VERSION_$@) \
172                 --pkgrelease=$(RELEASE) \
173                 --pkgname=$(PKGNAME) \
174                 --pkgarch=$(PKGARCH) \
175                 --provides=syncevolution \
176                 --replaces="'syncevolution, `echo $(filter-out $(PKGNAME), $(PKGS)) | sed -e 's/  */ (<< 1:0.8.1-2), /g'` (<< 1:0.8.1-2)'" \
177                 --conflicts="'$${conflicts}syncevolution, `echo $(filter-out $(PKGNAME), $(PKGS)) | sed -e 's/  */ (<< 1:0.8.1-2), /g'` (<< 1:0.8.1-2)', libsmltk0, libsyncevolution0, libsynthesis0, syncevolution-common, syncevolution-libs" \
178                 --maintainer="'Patrick Ohly <patrick.ohly@gmx.de>'" \
179                 --pkgsource='http://syncevolution.org' \
180                 --pkggroup='$*' \
181                 --pkggroup='comm' \
182                 cp -r `pwd`/$</* /
183         if [ $@ = "rpm" ]; then cp /usr/src/rpm/RPMS/*/${PKGNAME}-${VERSION}-2.*.rpm .; fi
184
185 # Pseudo platform .deb packages:
186 # only depend on PKGNAME = syncevolution-$(BINSUFFIX) (usually syncevolution-bundle).
187 # Version number is only bumped when changing the packaging rules here.
188 PLATFORM_DEB_VERSION = $(VERSION_deb)
189 PLATFORM_DEB_RELEASE = 1
190 if ENABLE_MODULES
191 deb : syncevolution-kde-deb
192 deb : syncevolution-evolution-deb
193 endif
194
195 # define which files are relevant for each platform
196 PLATFORM_FILES_evolution = platformgnome syncecal syncebook
197 PLATFORM_FILES_kde = platformkde syncakonadi
198
199 # Fake conflicts/replaces works around a bug in CheckInstall,
200 # which creates empty, invalid entries for those unless
201 # something is given.
202 syncevolution-%-deb: dist/$(distdir) dist/debian/control
203         (echo "SyncEvolution - meta package for $*" && cat $(srcdir)/description) >description-pak
204         tmpdir=`mktemp -d $$HOME/syncevolution.XXXXXXXXXX` && \
205         trap "rm -rf $$tmpdir" EXIT && \
206         fakeroot checkinstall </dev/null \
207                 $(TYPE_deb) \
208                 --fstrans=yes \
209                 --strip=no \
210                 --nodoc \
211                 --pkgversion=$(PLATFORM_DEB_VERSION) \
212                 --pkgrelease=$(PLATFORM_DEB_RELEASE) \
213                 --pkgname=syncevolution-$* \
214                 --pkgarch=all \
215                 --requires="'$(shell set -x; cd dist; LD_LIBRARY_PATH=$(distdir)/usr/lib:$(distdir)/usr/lib/syncevolution dpkg-shlibdeps -L$(srcdir)/src/shlibs.local --ignore-missing-info -O $$(for i in $(patsubst %,$(distdir)/usr/lib/syncevolution/backends/%.so,$(PLATFORM_FILES_$*)); do if file $$i | grep ELF >/dev/null; then echo $$i; fi; done) | sed $(REQUIRES_SED_KDE) -e 's/[^=]*=//'), $(PKGNAME) (= $(VERSION_deb)-$(RELEASE))'" \
216                 --conflicts=syncevolution-foobar \
217                 --replaces=syncevolution-foobar \
218                 --maintainer="'Patrick Ohly <patrick.ohly@gmx.de>'" \
219                 --pkgsource='http://syncevolution.org' \
220                 --pkggroup='$*' \
221                 sh -c 'mkdir -p touch /usr/share/doc/syncevolution-$* && echo "SyncEvolution platform pseudo-package for $*" >/usr/share/doc/syncevolution-$*/README'
222
223 all_phonies += dist/$(distdir) clean_dist
224 dist/$(distdir): all
225         rm -rf $@
226         $(MAKE) install DESTDIR=`pwd`/$@
227         $(MAKE) installcheck DESTDIR=`pwd`/$@
228         rm -rf $(call DEV_FILE_PATTERN,$@,/usr)
229 clean-local: clean_dist
230 clean_dist:
231         rm -rf dist description-pak
232
233 # required by dpkg-shlibdeps
234 dist/debian/control:
235         mkdir -p ${dir $@}
236         touch $@
237
238 # Build "html" inside the build dir, using source files
239 # from the SyncEvolution source directory and (if built)
240 # the installed client-api.build directory.
241 all_phonies += doc clean-html
242 doc:
243         rm -rf html
244         export VERSION="SyncEvolution $(VERSION)"; \
245         export OUTPUT_DIRECTORY="`pwd`"; \
246         export PREDEFINED="@BACKEND_DEFINES@ ENABLE_UNIT_TESTS ENABLE_INTEGRATION_TESTS"; \
247         export CLIENT_LIBRARY="@FUNAMBOL_SUBDIR@/test @FUNAMBOL_SUBDIR@/include "; \
248         export STRIP_FROM_PATH="$(srcdir) `dirname @FUNAMBOL_SUBDIR@`"; \
249         cd $(srcdir); doxygen
250 clean-local: clean-html
251 clean-html:
252         rm -rf html
253
254 all_dist_hooks += dot_dist_hook
255 dot_dist_hook:
256         @if test -d "$(srcdir)/.git"; \
257         then \
258           printf '%s' 'Creating ChangeLog...' && \
259           ( cd "$(top_srcdir)" && \
260             printf '%s\n\n' '# Generated by configure.  Do not edit.'; \
261             $(top_srcdir)/missing --run perl $(top_srcdir)/build/gen-changelog.pl ) > ChangeLog.tmp && \
262           ( mv -f ChangeLog.tmp $(top_distdir)/ChangeLog && \
263             printf '%s\n' ' done.' ) || \
264           ( rm -f ChangeLog.tmp ; \
265             printf '%s\n' ' failed.'; \
266             echo Failed to generate ChangeLog >&2 ); \
267         else \
268           echo 'A git checkout is required to generate a ChangeLog.' >&2; \
269         fi
270
271 if ENABLE_EVOLUTION_COMPATIBILITY
272 # check .so (relevant for modular builds) and main syncevolution binary
273 # (relevant in that case and for static builds) for dependencies on
274 # problematic libraries and symbols
275 #
276 # ical_strdup is an exception because it is in SyncEvolution.
277 all_local_installchecks += toplevel_so_check
278 toplevel_so_check:
279         for i in `find $(DESTDIR)/$(libdir)/syncevolution $(DESTDIR)/$(libdir)/libsyncevo* $(DESTDIR)/$(libdir)/libsynthesis* -name *.so` $(DESTDIR)/$(bindir)/syncevolution; \
280         do \
281           if objdump -T -C $$i | grep -v :: | grep '\*UND\*' | sort | grep -v -w ical_strdup | grep -e ical -e " e_"; then \
282             echo "$$i should not depend on EDS, libical or libbluetooth"; \
283            exit 1; \
284           fi; \
285           if ldd $$i | grep -e libecal -e libebook -e libedata -e libical -e libbluetooth; then \
286             echo "$$i should not be linked against EDS, libical or libbluetooth"; \
287             exit 1; \
288           fi; \
289         done
290 endif
291
292 # Be strict about running 'syncevolution' only when not doing
293 # cross-compilation: in that case, if running 'syncevolution' fails,
294 # abort the build process. Otherwise proceed with the fallback below,
295 # which is to keep the "see --sync/source-property ?" placeholders in
296 # the README.
297 if COND_CROSS_COMPILING
298 RUN_SYNCEVOLUTION_CHECK=if ($$?) { return ""; } else { return $$buffer; }
299 else
300 RUN_SYNCEVOLUTION_CHECK=die if $$?; return $$buffer;
301 endif
302
303 # patch README.rst properties on-the-fly
304 README.patched.rst: README.rst src/syncevolution
305         $(AM_V_GEN)perl -e '$$syncfound=0; $$sourcefound=0; $$res=0;' \
306                         -e 'sub run { $$cmd = shift; $$buffer = `env LD_LIBRARY_PATH=src/syncevo/.libs:src/gdbus/.libs:src/gdbusxx/.libs:src/build-synthesis/src/.libs:$$ENV{LD_LIBRARY_PATH} $$cmd`; $(RUN_SYNCEVOLUTION_CHECK) }' \
307                         -e 'while (<>) {' \
308                         -e 's/^:Version: .*/:Version: $(VERSION)/;' \
309                         -e 's/:Date: .*/":Date: " . `date +%Y-%m-%d`/e;' \
310                         -e 'if (s;(<< see "syncevolution --sync-property ." >>\n);run("src/syncevolution --daemon=no --sync-property ?") || $$1;e) { $$syncfound=1; }' \
311                         -e 'if (s;(<< see "syncevolution --source-property ." >>\n);run("src/syncevolution --daemon=no --source-property ?") || $$1;e) { $$sourcefound=1; }' \
312                         -e 'print;' \
313                         -e '}' \
314                         -e 'die "<<sync-property>> tag not in README.rst?!" unless $$syncfound;' \
315                         -e 'die "<<source-property>> tag not in README.rst?!" unless $$sourcefound;' \
316                         -e 'exit $$res;' \
317                         $< >$@
318 CLEANFILES += README.patched.rst
319
320 # produce man pages
321 syncevolution.1: README.patched.rst
322         $(AM_V_GEN)$(RST2MAN) --exit-status=3 $< >$@
323 CLEANFILES += syncevolution.1
324
325 # README is the traditional name in the distribution,
326 # continue using it instead of README.rst.
327 # TODO: replace some of the RST syntax
328 README: README.patched.rst
329         $(AM_V_GEN)cp $< $@
330 CLEANFILES += README
331
332 # The README.html is also used on syncevolution.org as "Usage" page,
333 # therefore we must use <h3> headers and lower to fit into the page.
334 README.html: README.patched.rst
335         $(AM_V_GEN)$(RST2HTML) --initial-header-level=3 --exit-status=3 $< >$@
336 CLEANFILES += README.html
337
338 .PHONY: $(all_phonies) ;
339
340 installcheck-local: $(all_local_installchecks) ;
341
342 dist-hook: $(all_dist_hooks)
343
344 # Force sequential installation. This is a workaround for relinking failures
345 # during concurrent distcheck (a backend was relinked against not yet installed
346 # libsyncevolution.la).
347 install-am: all-am
348         @$(MAKE) $(AM_MAKEFLAGS) install-exec-am
349         @$(MAKE) $(AM_MAKEFLAGS) install-data-am
350
351 .DELETE_ON_ERROR: