3b57fe504fe628eaa926967b7531895e980c9baf
[platform/upstream/syncevolution.git] / configure-pre.in
1 dnl Invoke autogen.sh to produce a configure script.
2
3 AC_INIT(src/syncevolution.cpp)
4 AM_INIT_AUTOMAKE(syncevolution, 0.8-beta3)
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(funambol,
15             AS_HELP_STRING([--with-funambol=<base directory>],
16                            [specifies location of Funambol client library]),
17             [FUNAMBOL="$withval"])
18
19 AC_ARG_WITH(sync4j,
20             AS_HELP_STRING([--with-funambol=<base directory>],
21                            [alias for --with-funambol]),
22             [FUNAMBOL="$withval"])
23
24 AC_ARG_WITH(funambol-src,
25             AS_HELP_STRING([--with-funambol-src=<base directory>],
26                            [specifies location of the Funambol '3x/client-api/native' source code]),
27             [FUNAMBOLSRC="$withval"])
28
29 AC_ARG_WITH(sync4j-src,
30             AS_HELP_STRING([--with-sync4j-src=<base directory>],
31                            [alias for --with-funambol-src]),
32             [FUNAMBOLSRC="$withval"])
33
34 AC_ARG_ENABLE(shared,
35               AS_HELP_STRING([--enable-shared],
36                              [build backends as dynamically loadable modules]),
37               enable_shared="$enableval", enable_shared="no")
38
39 AC_ARG_ENABLE(static,
40               AS_HELP_STRING([--enable-static],
41                              [build backends also as static libraries]),
42               enable_static="$enableval", enable_static="no")
43
44 AC_ARG_ENABLE(unit-tests,
45               AS_HELP_STRING([--enable-unit-tests],
46                              [enables tests embedded in the source code of the library (changes content of executable)]),
47               enable_unit_tests="$enableval", enable_unit_tests="no")
48 AC_ARG_ENABLE(integration-tests,
49               AS_HELP_STRING([--enable-integration-tests],
50                              [enables tests outside of the library (can be used together with normal builds of the library)]),
51               enable_integration_tests="$enableval", enable_integration_tests="no")
52
53 AC_ARG_ENABLE(static-cxx,
54               AS_HELP_STRING([--enable-static-cxx],
55                              [build executables which contain libstdc++ instead of requiring suitable libstdc++.so to run]),
56               enable_static_cxx="$enableval", enable_static_cxx="no")
57
58 # Maemo hacks:
59 # - set the (non-standard!) DBUS_DEFAULT_TIMEOUT
60 # - wrap e_book_from_string() to fix invalid parameter
61 # - don't use UTF-8 encoding in Perl script
62 AC_ARG_ENABLE(maemo,
63               AS_HELP_STRING([--enable-maemo],
64                              [enables some hacks which work around problems with the Maemo 2.0 until at least 3.0 EDS-Dbus]),
65               [AC_DEFINE(ENABLE_MAEMO, 1, [enable Maemo hacks])
66                DEVICE_TYPE=Maemo
67                MODIFY_SYNCCOMPARE='-e "s/use encoding/#use encoding/;" -e "s/:utf8//;"'])
68 AC_SUBST(MODIFY_SYNCCOMPARE)
69
70 AC_CHECK_HEADERS(signal.h dlfcn.h)
71
72 # cppunit needed?
73 if test $enable_unit_tests == "yes" || test $enable_integration_tests == yes; then
74         CPPUNIT_CXXFLAGS=`cppunit-config --cflags` || AC_MSG_ERROR("cppunit-config --cflags failed - is it installed?")
75         CPPUNIT_LDFLAGS=`cppunit-config --libs` || AC_MSG_ERROR("cppunit-config --libs failed - is it installed?")
76         CPPUNIT_TESTS=client-test
77 fi
78 AC_SUBST(CPPUNIT_CXXFLAGS)
79 AC_SUBST(CPPUNIT_LDFLAGS)
80 AC_SUBST(CPPUNIT_TESTS)
81
82 if test $enable_unit_tests == "yes"; then
83         CLIENT_CONFIGURE="$CLIENT_CONFIGURE --enable-unit-tests"
84         AC_DEFINE(ENABLE_UNIT_TESTS, 1, [enable unit tests inside the library's source code])
85 fi
86 if test $enable_integration_tests == "yes"; then
87         CLIENT_CONFIGURE="$CLIENT_CONFIGURE --enable-integration-tests"
88         AC_DEFINE(ENABLE_INTEGRATION_TESTS, 1, [enable unit tests outside of the library's source code])
89 fi
90
91 if test $enable_static_cxx == "yes"; then
92         LIBS="$LIBS -L."
93         CORE_LDADD_DEP=libstdc++.a
94 fi
95 AC_SUBST(CORE_LDADD_DEP)
96
97 # preserve src/client-api by default
98 CLEAN_CLIENT_SRC=
99 FUNAMBOL_LIB=$PWD/src/client-api.build/src/libfunambol.la
100
101 AC_SUBST(CLEAN_CLIENT_SRC)
102
103 case $target in
104 *apple-darwin*)  use_mac_ta="yes" ;;
105 *) use_libcurl="yes" ;;
106 esac
107
108 # Check for libcurl now instead of during make.
109 # Strictly speaking, building libfunambol takes
110 # care of that, but because we build it in a
111 # slightly unusual way (build libfunambol.a with
112 # -fPIC, include just the required object files
113 # in libsyncevolution) libtool doesn't pick up
114 # that dependency and we have to add libcurl to
115 # out link flags ourselves.
116 AC_MSG_CHECKING([for libcurl])
117 if TRANSPORT_LDFLAGS=`sh -c 'curl-config --libs' 2>&AS_MESSAGE_LOG_FD` && \
118     TRANSPORT_CFLAGS=`sh -c 'curl-config --cflags' 2>&AS_MESSAGE_LOG_FD`; then
119     AC_MSG_RESULT([found])
120 else
121     AC_MSG_RESULT([missing])
122     # FIXME: hard-coded check for Mac (same as in libfunambol)
123     case $target in
124         *apple-darwin*) TRANSPORT_LDFLAGS="-framework CoreServices" ;;
125         *) AC_MSG_ERROR([libcurl is required, check that its development package is installed and curl-config is in your PATH]) ;;
126     esac
127 fi
128 AC_SUBST(TRANSPORT_LDFLAGS)
129 AC_SUBST(TRANSPORT_CFLAGS)
130
131 if test "x$use_mac_ta" = "xyes"; then
132     CURL_LDFLAGS="-framework CoreServices"
133     AC_SUBST(CURL_LDFLAGS)
134 fi
135
136
137 if test ! "$FUNAMBOL"; then
138     if test "$FUNAMBOLSRC"; then
139         # make a copy of the sources, remove it during maintainer-clean and distclean
140         CLEAN_CLIENT_SRC=client-api
141
142         AC_MSG_NOTICE( [updating the content of src/client-api from $FUNAMBOLSRC] )
143         mkdir -p src/client-api
144         if cp --help 2>/dev/null | grep >/dev/null -e "--update"; then
145             # GNU cp
146             cp_opts="--update --archive"
147         else
148             cp_opts="-r"
149         fi
150
151         if cp $cp_opts $FUNAMBOLSRC/* src/client-api; then
152             ( cd src/client-api/build/autotools && ( test -f configure || sh autogen.sh ) )
153         else
154             AC_MSG_ERROR( [copying $FUNAMBOLSRC into src/client-api failed] )
155         fi
156         find src/client-api/build/autotools/win* -name output | xargs rm -rf
157         find src/client-api/build/autotools/include/* src/client-api/build/autotools/src/* -type d | xargs rm -rf
158         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
159     else
160         if test ! -d src/client-api; then
161             if test -d $srcdir/src/client-api; then
162                 mkdir -p src
163                 case $srcdir in
164                         /*) ln -s $srcdir/src/client-api src/client-api;;
165                         *) ln -s $PWD/$srcdir/src/client-api src/client-api;;
166                 esac
167             fi
168         fi
169     fi
170
171     if test -f src/client-api/build/autotools/configure; then
172         chmod u+x src/client-api/build/autotools/configure src/client-api/build/autotools/config.sub src/client-api/build/autotools/config.guess
173
174         # use local copy of the sources, with dependencies
175         # to trigger building the client library
176         FUNAMBOL_SUBDIR=$PWD/src/client-api.build
177         FUNAMBOL_DEP=$PWD/src/client-api.build/src/libfunambol.la
178
179         FUNAMBOL_CFLAGS="-I$FUNAMBOL_SUBDIR/include/posix -I$FUNAMBOL_SUBDIR/include/common -I$FUNAMBOL_SUBDIR/include -I$FUNAMBOL_SUBDIR/test"
180         FUNAMBOL_LIBS="-L$FUNAMBOL_SUBDIR/src -lfunambol"
181
182         AC_MSG_NOTICE( [configuring the client library] )
183         # Passing some specific configure arguments to the client library's
184         # configure makes sense (e.g., --enable-unit-tests) or is
185         # required (--disable-dependency-tracking when compiling for
186         # multiple architectures on Mac OS X).
187         cxx_lib_args=`for i in --disable-dependency-tracking --enable-unit-tests; do
188            if echo $ac_configure_args | grep -e $i >/dev/null; then
189               echo $i;
190            fi;
191           done`
192         if test "$enable_shared" == "yes"; then
193             # Okay, this is a shortcut: strictly speaking we would have
194             # to check with autoconf for the right flags...
195             FUNAMBOL_LIB_SHARED_FLAGS="-DPIC -fPIC"
196         fi
197         if (set -x; mkdir -p $FUNAMBOL_SUBDIR && cd $FUNAMBOL_SUBDIR && $CLIENT_CONFIGURE --build=$build_alias --host=$host_alias --target=$target_alias --disable-shared CFLAGS="$CFLAGS $FUNAMBOL_LIB_SHARED_FLAGS" CXXFLAGS="$CXXFLAGS $FUNAMBOL_LIB_SHARED_FLAGS" $cxx_lib_args); then true; else
198             AC_MSG_ERROR( [configuring client library failed] )
199         fi
200     else
201         AC_MSG_ERROR( [either --with-funambol or --with-funambol-src have to be used] )
202     fi
203 else
204     if test -f $FUNAMBOL/include/funambol/common/spds/SyncItem.h; then
205         FUNAMBOL_CFLAGS="-I$FUNAMBOL/include/funambol/posix -I$FUNAMBOL/include/funambol/common -I$FUNAMBOL/include/funambol"
206         FUNAMBOL_LIBS="-L$FUNAMBOL/lib -lfunambol"
207     else
208         AC_MSG_ERROR( [$FUNAMBOL does seem to be valid (e.g. include/funambol/spds/common/SyncItem.h is missing)] )
209     fi
210 fi
211
212 AC_SUBST(FUNAMBOL_CFLAGS)
213 AC_SUBST(FUNAMBOL_LIBS)
214 AC_SUBST(FUNAMBOL)
215 AC_SUBST(FUNAMBOL_SUBDIR)
216 AC_SUBST(FUNAMBOL_DEP)
217 AC_SUBST(FUNAMBOL_LIB)
218 AC_SUBST(FUNAMBOLSRC)
219
220 dnl select backends
221 BACKENDS=""
222
223 # AC_ARG_ENABLE_BACKEND(BACKEND, DIR, HELP-STRING, [ACTION-IF-GIVEN],
224 #                       [ACTION-IF-NOT-GIVEN])
225 #
226 # Same as AC_ARG_ENABLE(), but also tells configure that the
227 # backend exists.
228 #
229 # BACKEND = name of modules built in that dir as .la files without the
230 #           obligatory sync prefix, e.g. "ebook"
231 # DIR = name of the directory inside src/backends, e.g., "evolution"
232 AC_DEFUN([AC_ARG_ENABLE_BACKEND],
233 [
234         AC_ARG_ENABLE($1, $3, $4, $5)
235         BACKENDS="$BACKENDS $1"
236         BACKEND_DEFINES="$BACKEND_DEFINES ENABLE_`echo $1 | tr a-z A-Z`"
237         for source in $2; do
238             SYNCSOURCES="$SYNCSOURCES backends/$2/sync$1.la"
239         done
240 ])
241 AC_SUBST(SYNCSOURCES)
242 AC_SUBST(BACKEND_DEFINES)
243
244 dnl src/backends/*/configure-sub.in and configure-post.in follow