Imported Upstream version 0.8~beta1
[platform/upstream/syncevolution.git] / configure.in
1 dnl Process this file with autoconf to produce a configure script.
2
3 AC_INIT(src/syncevolution.cpp)
4 AM_INIT_AUTOMAKE(syncevolution, 0.8-beta1)
5 AM_CONFIG_HEADER(config.h)
6 AC_LIBTOOL_DLOPEN
7
8 dnl default device type (see AC_DEFINE below)
9 DEVICE_TYPE=desktop
10
11 # command used to configure client library, including options
12 CLIENT_CONFIGURE=$PWD/src/client-api/build/autotools/configure
13
14 AC_ARG_WITH(sync4j,
15             AS_HELP_STRING([--with-sync4j=<base directory>],
16                            [specifies location of Sync4j client library]),
17             [SYNC4J="$withval"])
18
19 AC_ARG_WITH(sync4j-src,
20             AS_HELP_STRING([--with-sync4j-src=<base directory>],
21                            [specifies location of the Sync4j '3x/client-api/native' source code]),
22             [SYNC4JSRC="$withval"])
23
24 AC_ARG_ENABLE(shared,
25               AS_HELP_STRING([--enable-shared],
26                              [build backends as dynamically loadable modules]),
27               enable_shared="$enableval", enable_shared="no")
28
29 AC_ARG_ENABLE(static,
30               AS_HELP_STRING([--enable-static],
31                              [build backends also as static libraries]),
32               enable_static="$enableval", enable_static="no")
33
34 AC_ARG_ENABLE(unit-tests,
35               AS_HELP_STRING([--enable-unit-tests],
36                              [enables tests embedded in the source code of the library (changes content of executable)]),
37               enable_unit_tests="$enableval", enable_unit_tests="no")
38 AC_ARG_ENABLE(integration-tests,
39               AS_HELP_STRING([--enable-integration-tests],
40                              [enables tests outside of the library (can be used together with normal builds of the library)]),
41               enable_integration_tests="$enableval", enable_integration_tests="no")
42
43 AC_ARG_ENABLE(static-cxx,
44               AS_HELP_STRING([--enable-static-cxx],
45                              [build executables which contain libstdc++ instead of requiring suitable libstdc++.so to run]),
46               enable_static_cxx="$enableval", enable_static_cxx="no")
47
48 # Maemo hacks:
49 # - set the (non-standard!) DBUS_DEFAULT_TIMEOUT
50 # - wrap e_book_from_string() to fix invalid parameter
51 # - don't use UTF-8 encoding in Perl script
52 AC_ARG_ENABLE(maemo,
53               AS_HELP_STRING([--enable-maemo],
54                              [enables some hacks which work around problems with the Maemo 2.0 until at least 3.0 EDS-Dbus]),
55               [AC_DEFINE(ENABLE_MAEMO, 1, [enable Maemo hacks])
56                DEVICE_TYPE=Maemo
57                MODIFY_SYNCCOMPARE='-e "s/use encoding/#use encoding/;" -e "s/:utf8//;"'])
58 AC_SUBST(MODIFY_SYNCCOMPARE)
59
60 # Another Maemo hack:
61 # - link main binaries against precompiled, patched libdbus-1.a
62 AC_ARG_WITH(patched-libdbus,
63             AS_HELP_STRING([--with-patched-libdbus=<absolute path of directory with patched libdbus-1.a/so>],
64                            [link main executables against special libdbus-1.a, for example one which supports DBUS_DEFAULT_TIMEOUT (required for Maemo)]),
65             [LIBDBUS="-L$withval"])
66 AC_SUBST(LIBDBUS)
67
68 AC_CHECK_HEADERS(signal.h dlfcn.h)
69
70 # cppunit needed?
71 if test $enable_unit_tests == "yes" || test $enable_integration_tests == yes; then
72         CPPUNIT_CXXFLAGS=`cppunit-config --cflags` || AC_MSG_ERROR("cppunit-config --cflags failed - is it installed?")
73         CPPUNIT_LDFLAGS=`cppunit-config --libs` || AC_MSG_ERROR("cppunit-config --libs failed - is it installed?")
74         CPPUNIT_TESTS=client-test
75 fi
76 AC_SUBST(CPPUNIT_CXXFLAGS)
77 AC_SUBST(CPPUNIT_LDFLAGS)
78 AC_SUBST(CPPUNIT_TESTS)
79
80 if test $enable_unit_tests == "yes"; then
81         CLIENT_CONFIGURE="$CLIENT_CONFIGURE --enable-unit-tests"
82         AC_DEFINE(ENABLE_UNIT_TESTS, 1, [enable unit tests inside the library's source code])
83 fi
84 if test $enable_integration_tests == "yes"; then
85         CLIENT_CONFIGURE="$CLIENT_CONFIGURE --enable-integration-tests"
86         AC_DEFINE(ENABLE_INTEGRATION_TESTS, 1, [enable unit tests outside of the library's source code])
87 fi
88
89 if test $enable_static_cxx == "yes"; then
90         LIBS="$LIBS -L."
91         CORE_LDADD_DEP=libstdc++.a
92 fi
93 AC_SUBST(CORE_LDADD_DEP)
94
95 # preserve src/client-api by default
96 CLEAN_CLIENT_SRC=
97 SYNC4J_LIB=$PWD/src/client-api.build/src/libsync4j.la
98
99 AC_SUBST(CLEAN_CLIENT_SRC)
100
101 if test ! "$SYNC4J"; then
102     if test "$SYNC4JSRC"; then
103         # make a copy of the sources, remove it during maintainer-clean and distclean
104         CLEAN_CLIENT_SRC=client-api
105
106         AC_MSG_NOTICE( [updating the content of src/client-api from $SYNC4JSRC] )
107         mkdir -p src/client-api
108         if cp --help 2>/dev/null | grep >/dev/null -e "--update"; then
109             # GNU cp
110             cp_opts="--update --archive"
111         else
112             cp_opts="-r"
113         fi
114
115         if cp $cp_opts $SYNC4JSRC/* src/client-api; then
116             ( cd src/client-api/build/autotools && ( test -f configure || sh autogen.sh ) )
117         else
118             AC_MSG_ERROR( [copying $SYNC4JSRC into src/client-api failed] )
119         fi
120         find src/client-api/build/autotools/win* -name output | xargs rm -rf
121         find src/client-api/build/autotools/include/* src/client-api/build/autotools/src/* -type d | xargs rm -rf
122         find src/client-api -name "*~*" -o -name ".#*" -o -name "*.orig" -o -name "stamp-*" -o -name "*.o" -o -name "*.lo" -o -name .libs -o -name autom4te.cache -o -name config.status | xargs rm -rf
123     else
124         if test ! -d src/client-api; then
125             if test -d $srcdir/src/client-api; then
126                 mkdir -p src
127                 case $srcdir in
128                         /*) ln -s $srcdir/src/client-api src/client-api;;
129                         *) ln -s $PWD/$srcdir/src/client-api src/client-api;;
130                 esac
131             fi
132         fi
133     fi
134
135     if test -f src/client-api/build/autotools/configure; then
136         chmod u+x src/client-api/build/autotools/configure src/client-api/build/autotools/config.sub src/client-api/build/autotools/config.guess
137
138         # use local copy of the sources, with dependencies
139         # to trigger building the client library
140         SYNC4J_SUBDIR=$PWD/src/client-api.build
141         SYNC4J_DEP=$PWD/src/client-api.build/src/libsync4j.la
142
143         SYNC4J_CFLAGS="-I$SYNC4J_SUBDIR/include/posix -I$SYNC4J_SUBDIR/include/common -I$SYNC4J_SUBDIR/include -I$SYNC4J_SUBDIR/test"
144         SYNC4J_LIBS="-L$SYNC4J_SUBDIR/src -lsync4j"
145
146         AC_MSG_NOTICE( [configuring the client library] )
147         if (set -x; mkdir -p $SYNC4J_SUBDIR && cd $SYNC4J_SUBDIR && $CLIENT_CONFIGURE --build=$build_alias --host=$host_alias --target=$target_alias --disable-shared); then true; else
148             AC_MSG_ERROR( [configuring client library failed] )
149         fi
150     else
151         AC_MSG_ERROR( [either --with-sync4j or --with-sync4j-src have to be used] )
152     fi
153 else
154     if test -f $SYNC4J/include/sync4j/common/spds/SyncItem.h; then
155         SYNC4J_CFLAGS="-I$SYNC4J/include/sync4j/posix -I$SYNC4J/include/sync4j/common -I$SYNC4J/include/sync4j"
156         SYNC4J_LIBS="-L$SYNC4J/lib -lsync4j"
157     else
158         AC_MSG_ERROR( [$SYNC4J does seem to be valid (e.g. include/sync4j/spds/common/SyncItem.h is missing)] )
159     fi
160 fi
161
162 AC_SUBST(SYNC4J_CFLAGS)
163 AC_SUBST(SYNC4J_LIBS)
164 AC_SUBST(SYNC4J)
165 AC_SUBST(SYNC4J_SUBDIR)
166 AC_SUBST(SYNC4J_DEP)
167 AC_SUBST(SYNC4J_LIB)
168 AC_SUBST(SYNC4JSRC)
169
170 pkg_emodules_10="libedataserver-1.0"
171 pkg_emodules_11="libedataserver-1.1"
172 pkg_emodules_12="libedataserver-1.2"
173 pkg_ebook_10="libebook-1.0"
174 pkg_ebook_11="libebook-1.1"
175 pkg_ebook_12="libebook-1.2"
176 pkg_ecal_10="libecal-1.0"
177 pkg_ecal_11="libecal-1.1"
178 pkg_ecal_12="libecal-1.2"
179
180 export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/usr/lib/pkgconfig:$prefix/lib/pkgconfig:/usr/local/lib/pkgconfig
181
182 anymissing="
183 Please install the development packages of Evolution and/or
184 set the PKG_CONFIG_PATH variable so that it points towards
185 the .pc files of libedataserver, libecal and libebook (the
186 latter two are optional).
187
188 You can check that these packages are available by running
189 pkg-config --list-all."
190
191 evomissing="No compatible evolution-data-server was found.
192 $anymissing"
193
194 dnl check for Evolution core packages
195 PKG_CHECK_MODULES(EPACKAGE, [$pkg_emodules_12], EDSFOUND=yes, [EDSFOUND=no])
196 if test "x${EDSFOUND}" = "xno"; then
197       PKG_CHECK_MODULES(EPACKAGE, [$pkg_emodules_11], EDSFOUND=yes, [EDSFOUND=no])
198       if test "x${EDSFOUND}" = "xno"; then
199               PKG_CHECK_MODULES(EPACKAGE, [$pkg_emodules_10], EDSFOUND=yes, [EDSFOUND=no])
200       fi
201 fi
202 AC_SUBST(EPACKAGE_CFLAGS)
203 AC_SUBST(EPACKAGE_LIBS)
204
205 dnl check for Evolution calendar packages
206 PKG_CHECK_MODULES(ECAL, [$pkg_ecal_12], ECALFOUND=yes, [ECALFOUND=no])
207 if test "x${ECALFOUND}" = "xno"; then
208         PKG_CHECK_MODULES(ECAL, [$pkg_ecal_11], ECALFOUND=yes, [ECALFOUND=no])
209         if test "x${ECALFOUND}" = "xno"; then
210                 PKG_CHECK_MODULES(ECAL, [$pkg_ecal_10], ECALFOUND=yes, [ECALFOUND=no])
211         fi
212 fi
213 AC_SUBST(ECAL_CFLAGS)
214 AC_SUBST(ECAL_LIBS)
215
216 dnl check for Evolution contact packages
217 PKG_CHECK_MODULES(EBOOK, [$pkg_ebook_12], EBOOKFOUND=yes, [EBOOKFOUND=no])
218 if test "x${EBOOKFOUND}" = "xno"; then
219         PKG_CHECK_MODULES(EBOOK, [$pkg_ebook_11], EBOOKFOUND=yes, [EBOOKFOUND=no])
220         if test "x${EBOOKFOUND}" = "xno"; then
221                 PKG_CHECK_MODULES(EBOOK, [$pkg_ebook_10], EBOOKFOUND=yes, [EBOOKFOUND=no])
222         fi
223 fi
224 AC_SUBST(EBOOK_CFLAGS)
225 AC_SUBST(EBOOK_LIBS)
226
227
228 dnl check for sqlite
229 PKG_CHECK_MODULES(SQLITE, sqlite3, SQLITEFOUND=yes, [SQLITEFOUND=no])
230 AC_SUBST(SQLITE_CFLAGS)
231 AC_SUBST(SQLITE_LIBS)
232
233 dnl hard-coded settings for Mac OS X AddressBook
234 ADDRESSBOOK_CFLAGS=
235
236 ADDRESSBOOK_LIBS="-framework AddressBook -framework CoreFoundation"
237 AC_SUBST(ADDRESSBOOK_CFLAGS)
238 AC_SUBST(ADDRESSBOOK_LIBS)
239
240 dnl select backends
241 AC_ARG_ENABLE(ebook, AS_HELP_STRING([--disable-ebook], [disable access to addressbooks (default on if available)]),
242                      [enable_ebook="$enableval"], [enable_ebook=$EBOOKFOUND])
243 AC_ARG_ENABLE(ecal, AS_HELP_STRING([--disable-ecal], [disable access to calendars and tasks (default on if available)]),
244                      [enable_ecal="$enableval"], [enable_ecal=$ECALFOUND])
245 AC_ARG_ENABLE(sqlite, AS_HELP_STRING([--enable-sqlite], [enable access to PIM data stored in SQLite files (experimental, default off)]),
246                       [enable_sqlite="$enableval"], [enable_sqlite="no"])
247 AC_ARG_ENABLE(addressbook, AS_HELP_STRING([--enable-addressbook], [enable access to Mac OS X address book (default off)]),
248                       [enable_addressbook="$enableval"], [enable_addressbook="no"])
249
250 enable_evo="no"
251 enable_any="no"
252 if test "$enable_ebook" = "yes"; then
253         test "x${EBOOKFOUND}" == "xyes" || AC_MSG_ERROR([--enable-ebook requires pkg-config information for libebook, which was not found])
254         AC_DEFINE(ENABLE_EBOOK, 1, [libebook available])
255         enable_evo="yes"
256         enable_any="yes"
257 fi
258
259 AM_CONDITIONAL([ENABLE_ECAL], [test "$enable_ecal" == "yes"])
260 if test "$enable_ecal" = "yes"; then
261         test "x${ECALFOUND}" == "xyes" || AC_MSG_ERROR([--enable-ecal requires pkg-config information for libecal, which was not found"])
262         AC_DEFINE(ENABLE_ECAL, 1, [libecal available])
263         enable_evo="yes"
264         enable_any="yes"
265 fi
266
267 if test "$enable_sqlite" = "yes"; then
268         test "x${SQLITEFOUND}" == "xyes" || AC_MSG_ERROR([--enable-sqlite requires pkg-config information for sqlite3, which was not found])
269         AC_DEFINE(ENABLE_SQLITE, 1, [sqlite available])
270         enable_any="yes"
271 fi
272
273 if test "$enable_addressbook" = "yes"; then
274         AC_DEFINE(ENABLE_ADDRESSBOOK, 1, [addressbook available])
275         DEVICE_TYPE=MacOS_X
276         enable_any="yes"
277 else
278         ADDRESSBOOK_LIBS=
279 fi
280
281 if test "$enable_any" = "no"; then
282         AC_MSG_ERROR([no backend enabled - refusing to continue: $anymissing])
283 fi
284
285 if test "$enable_evo" = "yes"; then
286         if test "$EDSFOUND" = "yes"; then
287                 AC_DEFINE(HAVE_EDS, 1, [evolution-dataserver available])
288         else
289                 AC_MSG_ERROR($evomissing)
290         fi
291 else
292         EPACKAGE_CFLAGS=
293         EPACKAGE_LIBS=
294 fi
295
296 dnl check for glib - calling g_type_init() is expected on Maemo
297 PKG_CHECK_MODULES(GLIB, "glib-2.0", GLIBFOUND=yes, GLIBFOUND=no)
298 if test "x${GLIBFOUND}" = "xno"; then
299         PKG_CHECK_MODULES(GLIB, "glib", GLIBFOUND=yes, GLIBFOUND=no)
300 fi
301 AC_SUBST(GLIB_CFLAGS)
302 AC_SUBST(GLIB_LIBS)
303
304 dnl check for programs.
305 AC_PROG_CXX
306 AC_PROG_LIBTOOL
307 AC_PROG_MAKE_SET
308
309 if test "$enable_sqlite" == "yes"; then
310         SYNCEVOLUTION_MODULES="$SYNCEVOLUTION_MODULES syncsqlite.la"
311 fi
312 if test "$enable_addressbook" == "yes"; then
313         SYNCEVOLUTION_MODULES="$SYNCEVOLUTION_MODULES syncaddressbook.la"
314 fi
315
316 dnl glib initialization is done only for libebook and libecal, not needed
317 dnl otherwise even if found
318 if test "$enable_ebook" != "yes" && test "$enable_ecal" != "yes"; then
319         GLIB_CFLAGS=
320         GLIB_LIBS=
321 else
322         if  test "x${GLIBFOUND}" = "xyes"; then
323             AC_DEFINE(HAVE_GLIB, 1, [glib found])
324         fi
325 fi
326
327 dnl figure out whether we link all code statically or as modules
328 AM_CONDITIONAL([ENABLE_MODULES], [test "$enable_shared" == "yes"])
329 if test "$enable_shared" == "yes"; then
330         SYNCEVOLUTION_LDADD="-Wl,-export-dynamic -rpath '\$(pkglibdir)'"
331         AC_DEFINE(ENABLE_MODULES, 1, [enable dynamically opening sync source backends])
332 else
333         SYNCEVOLUTION_LDADD="\$(EXTRA_LTLIBRARIES)"
334 fi
335 AC_SUBST(SYNCEVOLUTION_LDADD)
336
337 dnl CXXFLAGS gets applied to SyncEvolution and the client library.
338 dnl For e.g. "-Wall -Werror" this might not be such a good idea;
339 dnl SYNCEVOLUTION_CXXFLAGS can be used instead. It applies only
340 dnl to the sources in the SyncEvolution repository.
341 AC_SUBST(SYNCEVOLUTION_CXXFLAGS)
342
343 dnl a quick-and-dirty way to detect compilation for the iPhone
344 if test "$host" == "arm-apple-darwin"; then
345    AC_DEFINE(IPHONE, 1, [compiling for iPhone])
346    DEVICE_TYPE=iPhone
347 fi
348
349 dnl This string is sent as part of the SyncML DevInf (device
350 dnl information) structure to the server. All SyncEvolution platforms
351 dnl use "SyncEvolution" as HTTP user agent and "Mod" (model), so the
352 dnl device type is the only way how different kinds of clients can be
353 dnl distinguished.
354 AC_DEFINE_UNQUOTED(DEVICE_TYPE, "$DEVICE_TYPE", "SyncML DevInf DevType")
355
356 AC_CHECK_HEADERS(stdarg.h valgrind/valgrind.h execinfo.h)
357
358 AC_OUTPUT([
359 Makefile
360 src/Makefile
361 test/Makefile
362 ])