summaryrefslogtreecommitdiff
path: root/configure-pre.in
blob: 3b57fe504fe628eaa926967b7531895e980c9baf (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
dnl Invoke autogen.sh to produce a configure script.

AC_INIT(src/syncevolution.cpp)
AM_INIT_AUTOMAKE(syncevolution, 0.8-beta3)
AM_CONFIG_HEADER(config.h)
AC_LIBTOOL_DLOPEN

dnl default device type (see AC_DEFINE below)
DEVICE_TYPE=desktop

# command used to configure client library, including options
CLIENT_CONFIGURE=$PWD/src/client-api/build/autotools/configure

AC_ARG_WITH(funambol,
            AS_HELP_STRING([--with-funambol=<base directory>],
                           [specifies location of Funambol client library]),
            [FUNAMBOL="$withval"])

AC_ARG_WITH(sync4j,
            AS_HELP_STRING([--with-funambol=<base directory>],
                           [alias for --with-funambol]),
            [FUNAMBOL="$withval"])

AC_ARG_WITH(funambol-src,
            AS_HELP_STRING([--with-funambol-src=<base directory>],
                           [specifies location of the Funambol '3x/client-api/native' source code]),
            [FUNAMBOLSRC="$withval"])

AC_ARG_WITH(sync4j-src,
            AS_HELP_STRING([--with-sync4j-src=<base directory>],
                           [alias for --with-funambol-src]),
            [FUNAMBOLSRC="$withval"])

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")

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")

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")

# 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])
               DEVICE_TYPE=Maemo
               MODIFY_SYNCCOMPARE='-e "s/use encoding/#use encoding/;" -e "s/:utf8//;"'])
AC_SUBST(MODIFY_SYNCCOMPARE)

AC_CHECK_HEADERS(signal.h dlfcn.h)

# 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
        CLIENT_CONFIGURE="$CLIENT_CONFIGURE --enable-unit-tests"
        AC_DEFINE(ENABLE_UNIT_TESTS, 1, [enable unit tests inside the library's source code])
fi
if test $enable_integration_tests == "yes"; then
        CLIENT_CONFIGURE="$CLIENT_CONFIGURE --enable-integration-tests"
        AC_DEFINE(ENABLE_INTEGRATION_TESTS, 1, [enable unit tests outside of the library's source code])
fi

if test $enable_static_cxx == "yes"; then
        LIBS="$LIBS -L."
        CORE_LDADD_DEP=libstdc++.a
fi
AC_SUBST(CORE_LDADD_DEP)

# preserve src/client-api by default
CLEAN_CLIENT_SRC=
FUNAMBOL_LIB=$PWD/src/client-api.build/src/libfunambol.la

AC_SUBST(CLEAN_CLIENT_SRC)

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


if test ! "$FUNAMBOL"; then
    if test "$FUNAMBOLSRC"; then
        # make a copy of the sources, remove it during maintainer-clean and distclean
        CLEAN_CLIENT_SRC=client-api

        AC_MSG_NOTICE( [updating the content of src/client-api from $FUNAMBOLSRC] )
        mkdir -p src/client-api
        if cp --help 2>/dev/null | grep >/dev/null -e "--update"; then
            # GNU cp
            cp_opts="--update --archive"
        else
            cp_opts="-r"
        fi

        if cp $cp_opts $FUNAMBOLSRC/* src/client-api; then
            ( cd src/client-api/build/autotools && ( test -f configure || sh autogen.sh ) )
        else
            AC_MSG_ERROR( [copying $FUNAMBOLSRC into src/client-api failed] )
        fi
        find src/client-api/build/autotools/win* -name output | xargs rm -rf
        find src/client-api/build/autotools/include/* src/client-api/build/autotools/src/* -type d | xargs rm -rf
        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
    else
        if test ! -d src/client-api; then
            if test -d $srcdir/src/client-api; then
                mkdir -p src
                case $srcdir in
                        /*) ln -s $srcdir/src/client-api src/client-api;;
                        *) ln -s $PWD/$srcdir/src/client-api src/client-api;;
                esac
            fi
        fi
    fi

    if test -f src/client-api/build/autotools/configure; then
        chmod u+x src/client-api/build/autotools/configure src/client-api/build/autotools/config.sub src/client-api/build/autotools/config.guess

        # use local copy of the sources, with dependencies
        # to trigger building the client library
        FUNAMBOL_SUBDIR=$PWD/src/client-api.build
        FUNAMBOL_DEP=$PWD/src/client-api.build/src/libfunambol.la

        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"

        AC_MSG_NOTICE( [configuring the client library] )
        # 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`
        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
        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
            AC_MSG_ERROR( [configuring client library failed] )
        fi
    else
        AC_MSG_ERROR( [either --with-funambol or --with-funambol-src have to be used] )
    fi
else
    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"
    else
        AC_MSG_ERROR( [$FUNAMBOL does seem to be valid (e.g. include/funambol/spds/common/SyncItem.h is missing)] )
    fi
fi

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)

dnl select backends
BACKENDS=""

# AC_ARG_ENABLE_BACKEND(BACKEND, DIR, HELP-STRING, [ACTION-IF-GIVEN],
#                       [ACTION-IF-NOT-GIVEN])
#
# Same as AC_ARG_ENABLE(), but also tells configure that the
# backend exists.
#
# 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"
AC_DEFUN([AC_ARG_ENABLE_BACKEND],
[
        AC_ARG_ENABLE($1, $3, $4, $5)
        BACKENDS="$BACKENDS $1"
        BACKEND_DEFINES="$BACKEND_DEFINES ENABLE_`echo $1 | tr a-z A-Z`"
        for source in $2; do
            SYNCSOURCES="$SYNCSOURCES backends/$2/sync$1.la"
        done
])
AC_SUBST(SYNCSOURCES)
AC_SUBST(BACKEND_DEFINES)

dnl src/backends/*/configure-sub.in and configure-post.in follow