2008-10-08 23:30:06 +02:00
dnl -*- mode: Autoconf; -*-
2008-07-29 23:06:11 +02:00
dnl Invoke autogen.sh to produce a configure script.
2005-10-08 14:03:24 +02:00
2006-03-11 20:23:43 +01:00
AC_INIT(src/syncevolution.cpp)
2008-10-11 11:50:41 +02:00
AM_INIT_AUTOMAKE(syncevolution, 0.8.1)
2008-10-09 10:46:28 +02:00
define([FUNAMBOLSRC_REPO], [git://github.com/pohly/funambol-cpp-client-api.git])
2008-10-11 10:25:45 +02:00
dnl Specify git revisions/branches without prefix, i.e., without 'origin'.
dnl We'll sort that out below.
2008-12-15 23:18:48 +01:00
define([FUNAMBOLSRC_REVISION], [syncevolution-0.8.1a])
2005-10-08 14:03:24 +02:00
AM_CONFIG_HEADER(config.h)
2007-03-11 23:13:13 +01:00
AC_LIBTOOL_DLOPEN
2005-10-08 14:03:24 +02:00
2008-03-08 11:02:33 +01:00
dnl default device type (see AC_DEFINE below)
DEVICE_TYPE=desktop
2008-09-14 19:52:08 +02:00
# options to be used when configuring client library
CLIENT_CONFIGURE_OPTIONS=
2006-12-01 23:50:17 +01:00
2008-07-21 21:12:32 +02:00
AC_ARG_WITH(funambol,
AS_HELP_STRING([--with-funambol=<base directory>],
[specifies location of Funambol client library]),
[FUNAMBOL="$withval"])
2005-10-08 14:03:24 +02:00
AC_ARG_WITH(sync4j,
2008-07-21 21:12:32 +02:00
AS_HELP_STRING([--with-funambol=<base directory>],
[alias for --with-funambol]),
[FUNAMBOL="$withval"])
2008-09-14 19:52:08 +02:00
if test -e "$srcdir/src/client-api"; then
FUNAMBOLSRC_DEF="$srcdir/src/client-api"
else
FUNAMBOLSRC_DEF="FUNAMBOLSRC_REPO"
fi
2008-07-21 21:12:32 +02:00
AC_ARG_WITH(funambol-src,
2008-09-14 19:52:08 +02:00
AS_HELP_STRING([--with-funambol-src=<base directory|svn URL|git URL>],
[Specifies location of the Funambol 'client-api/native' source code.
Use this instead of --with-funambol when the client library is to
be compiled as part of the SyncEvolution compilation. In release
versions of SyncEvolution, a copy of the client library is bundled
under 'src/client-api' and compiled unless something else is
specified. --with-funambol-src can be given a path to sources
checked out already, a Subversion repository URL or a git repository
URL. When given a repository URL, then the configure script
will checkout the sources into 'src/client-api-copy' or
update that working copy if the directory already exists.
Default: bundled source in src/client-api (in released SyncEvolution sources),
FUNAMBOLSRC_REPO otherwise.]),
2008-09-20 10:25:39 +02:00
[FUNAMBOLSRC="$withval"], [FUNAMBOLSRC="$FUNAMBOLSRC_DEF"; REVISION="FUNAMBOLSRC_REVISION"])
2006-03-12 10:48:59 +01:00
AC_ARG_WITH(sync4j-src,
AS_HELP_STRING([--with-sync4j-src=<base directory>],
2008-07-21 21:12:32 +02:00
[alias for --with-funambol-src]),
[FUNAMBOLSRC="$withval"])
2006-03-12 10:48:59 +01:00
2008-09-14 19:52:08 +02:00
AC_ARG_WITH(funambol-username,
AS_HELP_STRING([--with-funambol-username=<svn username>],
[username to use when checking out --with-funambol-src sources from Subversion, default 'guest']),
[USERNAME="$withval"], [USERNAME="guest"])
AC_ARG_WITH(funambol-revision,
AS_HELP_STRING([--with-funambol-revision=<git tag/branch/hash or Subversion revision>],
2008-09-20 10:25:39 +02:00
[Identifies which source revision to use from --with-funambol-src repository, empty string stands for latest. Default for default --funambol-src: FUNAMBOLSRC_REVISION]),
[REVISION="$withval"])
2008-09-14 19:52:08 +02:00
2007-03-11 23:13:13 +01:00
AC_ARG_ENABLE(shared,
AS_HELP_STRING([--enable-shared],
[build backends as dynamically loadable modules]),
enable_shared="$enableval", enable_shared="no")
AC_ARG_ENABLE(static,
AS_HELP_STRING([--enable-static],
[build backends also as static libraries]),
enable_static="$enableval", enable_static="no")
2006-12-01 23:50:17 +01:00
AC_ARG_ENABLE(unit-tests,
AS_HELP_STRING([--enable-unit-tests],
[enables tests embedded in the source code of the library (changes content of executable)]),
enable_unit_tests="$enableval", enable_unit_tests="no")
AC_ARG_ENABLE(integration-tests,
AS_HELP_STRING([--enable-integration-tests],
[enables tests outside of the library (can be used together with normal builds of the library)]),
enable_integration_tests="$enableval", enable_integration_tests="no")
2007-01-21 17:14:48 +01:00
AC_ARG_ENABLE(static-cxx,
AS_HELP_STRING([--enable-static-cxx],
[build executables which contain libstdc++ instead of requiring suitable libstdc++.so to run]),
enable_static_cxx="$enableval", enable_static_cxx="no")
2008-10-08 23:30:06 +02:00
AC_ARG_ENABLE(evolution-compatibility,
AS_HELP_STRING([--enable-evolution-compatibility],
[build executables which only call Evolution via dlopen/dlsym: this avoids all hard dependencies on EDS shared objects, but might lead to crashes when their ABI changes]),
enable_evolution_compatibility="$enableval", enable_evolution_compatibility="no")
2007-03-24 16:47:22 +01:00
# Maemo hacks:
# - set the (non-standard!) DBUS_DEFAULT_TIMEOUT
# - wrap e_book_from_string() to fix invalid parameter
# - don't use UTF-8 encoding in Perl script
AC_ARG_ENABLE(maemo,
AS_HELP_STRING([--enable-maemo],
[enables some hacks which work around problems with the Maemo 2.0 until at least 3.0 EDS-Dbus]),
[AC_DEFINE(ENABLE_MAEMO, 1, [enable Maemo hacks])
2008-03-08 11:02:33 +01:00
DEVICE_TYPE=Maemo
2007-03-25 22:19:42 +02:00
MODIFY_SYNCCOMPARE='-e "s/use encoding/#use encoding/;" -e "s/:utf8//;"'])
2007-03-24 16:47:22 +01:00
AC_SUBST(MODIFY_SYNCCOMPARE)
2009-01-18 22:14:24 +01:00
PKG_CHECK_MODULES(SYNTHESIS, "synthesis")
2008-05-02 21:05:37 +02:00
AC_CHECK_HEADERS(signal.h dlfcn.h)
2007-01-03 21:12:47 +01:00
2006-12-01 23:50:17 +01:00
# cppunit needed?
if test $enable_unit_tests == "yes" || test $enable_integration_tests == yes; then
CPPUNIT_CXXFLAGS=`cppunit-config --cflags` || AC_MSG_ERROR("cppunit-config --cflags failed - is it installed?")
CPPUNIT_LDFLAGS=`cppunit-config --libs` || AC_MSG_ERROR("cppunit-config --libs failed - is it installed?")
CPPUNIT_TESTS=client-test
fi
AC_SUBST(CPPUNIT_CXXFLAGS)
AC_SUBST(CPPUNIT_LDFLAGS)
AC_SUBST(CPPUNIT_TESTS)
if test $enable_unit_tests == "yes"; then
2008-09-14 19:52:08 +02:00
CLIENT_CONFIGURE_OPTIONS="$CLIENT_CONFIGURE_OPTIONS --enable-unit-tests"
2006-12-01 23:50:17 +01:00
AC_DEFINE(ENABLE_UNIT_TESTS, 1, [enable unit tests inside the library's source code])
fi
if test $enable_integration_tests == "yes"; then
2008-09-14 19:52:08 +02:00
CLIENT_CONFIGURE_OPTIONS="$CLIENT_CONFIGURE_OPTIONS --enable-integration-tests"
2006-12-01 23:50:17 +01:00
AC_DEFINE(ENABLE_INTEGRATION_TESTS, 1, [enable unit tests outside of the library's source code])
fi
2007-01-21 17:14:48 +01:00
if test $enable_static_cxx == "yes"; then
LIBS="$LIBS -L."
CORE_LDADD_DEP=libstdc++.a
fi
AC_SUBST(CORE_LDADD_DEP)
2008-09-14 19:52:08 +02:00
# preserve src/client-api by default,
# always
2007-03-26 21:09:12 +02:00
CLEAN_CLIENT_SRC=
2008-09-14 19:52:08 +02:00
FUNAMBOL_LIB=$PWD/src/build-client-api/src/libfunambol.la
2008-04-06 12:07:04 +02:00
2007-03-26 21:09:12 +02:00
AC_SUBST(CLEAN_CLIENT_SRC)
2008-08-17 11:26:34 +02:00
case $target in
*apple-darwin*) use_mac_ta="yes" ;;
*) use_libcurl="yes" ;;
esac
# Check for libcurl now instead of during make.
# Strictly speaking, building libfunambol takes
# care of that, but because we build it in a
# slightly unusual way (build libfunambol.a with
# -fPIC, include just the required object files
# in libsyncevolution) libtool doesn't pick up
# that dependency and we have to add libcurl to
# out link flags ourselves.
AC_MSG_CHECKING([for libcurl])
if TRANSPORT_LDFLAGS=`sh -c 'curl-config --libs' 2>&AS_MESSAGE_LOG_FD` && \
TRANSPORT_CFLAGS=`sh -c 'curl-config --cflags' 2>&AS_MESSAGE_LOG_FD`; then
AC_MSG_RESULT([found])
else
AC_MSG_RESULT([missing])
# FIXME: hard-coded check for Mac (same as in libfunambol)
case $target in
*apple-darwin*) TRANSPORT_LDFLAGS="-framework CoreServices" ;;
*) AC_MSG_ERROR([libcurl is required, check that its development package is installed and curl-config is in your PATH]) ;;
esac
fi
AC_SUBST(TRANSPORT_LDFLAGS)
AC_SUBST(TRANSPORT_CFLAGS)
if test "x$use_mac_ta" = "xyes"; then
CURL_LDFLAGS="-framework CoreServices"
AC_SUBST(CURL_LDFLAGS)
fi
2008-09-14 19:52:08 +02:00
# absolute patch to source of Funambol client library
CLIENT_API_SRC=no-client-api-source
AC_SUBST(CLIENT_API_SRC)
2008-07-21 21:12:32 +02:00
if test ! "$FUNAMBOL"; then
if test "$FUNAMBOLSRC"; then
2008-09-14 19:52:08 +02:00
# default: checkout a copy of the sources, remove it during maintainer-clean and distclean
CLEAN_CLIENT_SRC=client-api-copy
CLIENT_API_SRC=$PWD/src/client-api-copy
2007-08-19 21:11:20 +02:00
2008-09-14 19:52:08 +02:00
AC_MSG_NOTICE( [updating the content of $CLIENT_API_SRC from $FUNAMBOLSRC] )
case "$FUNAMBOLSRC" in
*://*) protocol="`echo $FUNAMBOLSRC | sed -e 's;://.*;;'`";;
*) protocol="file";;
esac
mkdir -p src
case $protocol in
file)
# use existing copy of the sources
CLEAN_CLIENT_SRC=
case "$FUNAMBOLSRC" in
/*) CLIENT_API_SRC="$FUNAMBOLSRC";;
*) CLIENT_API_SRC="$PWD/$FUNAMBOLSRC";;
2006-03-12 10:48:59 +01:00
esac
2008-09-14 19:52:08 +02:00
;;
*svn*|*http*)
2008-09-20 10:25:39 +02:00
FUNAMBOLSRCREV="$FUNAMBOLSRC"
if test "$REVISION"; then
revarg="-r $REVISION "
if `echo $FUNAMBOLSRC | grep '@[0123456789]*'` >/dev/null; then
:
else
FUNAMBOLSRCREV="$FUNAMBOLSRC@$REVISION"
fi
fi
2008-09-14 19:52:08 +02:00
if test -d $CLIENT_API_SRC ; then
2008-09-20 10:25:39 +02:00
( set -x; cd $CLIENT_API_SRC && svn --username=$USERNAME switch $revarg "$FUNAMBOLSRC" ) || AC_ERROR([updating from $FUNAMBOLSRC failed])
2008-09-14 19:52:08 +02:00
else
2008-09-20 10:25:39 +02:00
(set -x; svn --username=$USERNAME checkout $revarg "$FUNAMBOLSRCREV" $CLIENT_API_SRC ) || AC_ERROR([checking out $FUNAMBOLSRC failed])
2008-09-14 19:52:08 +02:00
fi
;;
*git*)
if test -d $CLIENT_API_SRC ; then
2008-10-09 17:55:11 +02:00
( set -x; cd $CLIENT_API_SRC && git fetch "$FUNAMBOLSRC" ) || AC_ERROR([updating from $FUNAMBOLSRC failed])
2008-09-14 19:52:08 +02:00
else
2008-10-10 20:51:40 +02:00
( set -x; git clone "$FUNAMBOLSRC" $CLIENT_API_SRC ) || AC_ERROR([cloning $FUNAMBOLSRC failed])
2008-09-14 19:52:08 +02:00
fi
if test "$REVISION"; then
2008-10-16 17:29:33 +02:00
# git 1.6 finds tags and branches without explicit prefix, 1.4.4.4 doesn't
( set -x; cd $CLIENT_API_SRC &&
(git checkout "$REVISION" ||
git checkout "tags/$REVISION" ||
git checkout "origin/$REVISION") ) || AC_ERROR([checking out $FUNAMBOLSRC failed])
2008-09-14 19:52:08 +02:00
fi
;;
esac
else
# use existing copy of the sources; beware of
# out-of-tree compilation
case $srcdir in
/*) CLIENT_API_SRC="$srcdir/src/client-api";;
*) CLIENT_API_SRC="$PWD/$srcdir/src/client-api";;
esac
2006-03-12 10:48:59 +01:00
fi
2008-09-14 19:52:08 +02:00
( cd $CLIENT_API_SRC/build/autotools && ( test -f configure || sh autogen.sh ) )
if test -f $CLIENT_API_SRC/build/autotools/configure; then
CLIENT_CONFIGURE="$CLIENT_API_SRC/build/autotools/configure"
chmod u+x $CLIENT_API_SRC/build/autotools/configure $CLIENT_API_SRC/build/autotools/config.sub $CLIENT_API_SRC/build/autotools/config.guess
2006-04-06 19:02:43 +02:00
2008-04-06 12:07:04 +02:00
# use local copy of the sources, with dependencies
# to trigger building the client library
2008-09-14 19:52:08 +02:00
FUNAMBOL_SUBDIR=$PWD/src/build-client-api
FUNAMBOL_DEP=$PWD/src/build-client-api/src/libfunambol.la
2006-03-12 10:48:59 +01:00
2008-07-21 21:12:32 +02:00
FUNAMBOL_CFLAGS="-I$FUNAMBOL_SUBDIR/include/posix -I$FUNAMBOL_SUBDIR/include/common -I$FUNAMBOL_SUBDIR/include -I$FUNAMBOL_SUBDIR/test"
FUNAMBOL_LIBS="-L$FUNAMBOL_SUBDIR/src -lfunambol"
2006-03-12 10:48:59 +01:00
AC_MSG_NOTICE( [configuring the client library] )
2008-07-12 20:44:15 +02:00
# Passing some specific configure arguments to the client library's
# configure makes sense (e.g., --enable-unit-tests) or is
# required (--disable-dependency-tracking when compiling for
# multiple architectures on Mac OS X).
cxx_lib_args=`for i in --disable-dependency-tracking --enable-unit-tests; do
if echo $ac_configure_args | grep -e $i >/dev/null; then
echo $i;
fi;
done`
2008-07-29 23:06:11 +02:00
if test "$enable_shared" == "yes"; then
# Okay, this is a shortcut: strictly speaking we would have
# to check with autoconf for the right flags...
FUNAMBOL_LIB_SHARED_FLAGS="-DPIC -fPIC"
fi
2008-09-14 19:52:08 +02:00
if (set -x; mkdir -p $FUNAMBOL_SUBDIR && cd $FUNAMBOL_SUBDIR && $CLIENT_CONFIGURE $CLIENT_CONFIGURE_OPTIONS --build=$build_alias --host=$host_alias --target=$target_alias --disable-shared --with-transport-agent=curl CFLAGS="$CFLAGS $FUNAMBOL_LIB_SHARED_FLAGS" CXXFLAGS="$CXXFLAGS $FUNAMBOL_LIB_SHARED_FLAGS" $cxx_lib_args); then true; else
2006-03-12 10:48:59 +01:00
AC_MSG_ERROR( [configuring client library failed] )
fi
else
2008-07-21 21:12:32 +02:00
AC_MSG_ERROR( [either --with-funambol or --with-funambol-src have to be used] )
2006-03-12 10:48:59 +01:00
fi
else
2008-07-21 21:12:32 +02:00
if test -f $FUNAMBOL/include/funambol/common/spds/SyncItem.h; then
FUNAMBOL_CFLAGS="-I$FUNAMBOL/include/funambol/posix -I$FUNAMBOL/include/funambol/common -I$FUNAMBOL/include/funambol"
FUNAMBOL_LIBS="-L$FUNAMBOL/lib -lfunambol"
2006-03-12 10:48:59 +01:00
else
2008-07-21 21:12:32 +02:00
AC_MSG_ERROR( [$FUNAMBOL does seem to be valid (e.g. include/funambol/spds/common/SyncItem.h is missing)] )
2006-03-12 10:48:59 +01:00
fi
fi
2009-02-06 17:52:18 +01:00
FUNAMBOL_CFLAGS="$FUNAMBOL_CFLAGS $SYNTHESIS_CFLAGS"
2008-07-21 21:12:32 +02:00
AC_SUBST(FUNAMBOL_CFLAGS)
AC_SUBST(FUNAMBOL_LIBS)
AC_SUBST(FUNAMBOL)
AC_SUBST(FUNAMBOL_SUBDIR)
AC_SUBST(FUNAMBOL_DEP)
AC_SUBST(FUNAMBOL_LIB)
AC_SUBST(FUNAMBOLSRC)
2005-10-08 14:03:24 +02:00
2007-08-13 22:46:49 +02:00
dnl select backends
2008-07-28 22:48:26 +02:00
BACKENDS=""
2008-07-29 23:06:11 +02:00
2008-07-30 19:30:10 +02:00
# AC_ARG_ENABLE_BACKEND(BACKEND, DIR, HELP-STRING, [ACTION-IF-GIVEN],
2008-07-28 22:48:26 +02:00
# [ACTION-IF-NOT-GIVEN])
#
# Same as AC_ARG_ENABLE(), but also tells configure that the
# backend exists.
2008-07-30 19:30:10 +02:00
#
# BACKEND = name of modules built in that dir as .la files without the
# obligatory sync prefix, e.g. "ebook"
# DIR = name of the directory inside src/backends, e.g., "evolution"
2008-07-28 22:48:26 +02:00
AC_DEFUN([AC_ARG_ENABLE_BACKEND],
[
2008-07-30 19:30:10 +02:00
AC_ARG_ENABLE($1, $3, $4, $5)
2008-07-28 22:48:26 +02:00
BACKENDS="$BACKENDS $1"
2008-07-30 22:11:12 +02:00
BACKEND_DEFINES="$BACKEND_DEFINES ENABLE_`echo $1 | tr a-z A-Z`"
2008-07-30 19:30:10 +02:00
for source in $2; do
SYNCSOURCES="$SYNCSOURCES backends/$2/sync$1.la"
done
2008-07-28 22:48:26 +02:00
])
2008-07-30 19:30:10 +02:00
AC_SUBST(SYNCSOURCES)
2008-07-30 22:11:12 +02:00
AC_SUBST(BACKEND_DEFINES)
2008-07-28 22:48:26 +02:00
2008-07-29 23:06:11 +02:00
dnl src/backends/*/configure-sub.in and configure-post.in follow