Add dummy file to make sure bin/ directory exists.
[jelmer/openchange.git] / configure.ac
1 # Simple configuration script for OpenChange
2 # Written by Jelmer Vernooij <jelmer@openchange.org>
3
4 AC_PREREQ(2.57)
5 AC_INIT(openchange, 1.0, [openchange@openchange.org])
6 AC_CONFIG_HEADER([config.h])
7 AM_INIT_AUTOMAKE
8 AC_DEFINE(_GNU_SOURCE, 1, [Use GNU extensions])
9
10 PKG_PROG_PKG_CONFIG([0.20])
11
12 if test -z "$CFLAGS";
13 then
14   CFLAGS="-g";
15 fi
16
17 CFLAGS="-I. $CFLAGS"
18
19 dnl #################################################################
20 dnl Check for OS dependent options
21 dnl #################################################################
22 AC_CANONICAL_HOST
23
24 case "${host}" in
25      *freebsd*) 
26                 BUILD_FOR_FREEBSD=yes
27                 AC_SUBST(BUILD_FOR_FREEBSD)
28                 MANUALLY_CREATE_SYMLINKS=yes
29                 ;;
30      *solaris*) 
31                 BUILD_FOR_SOLARIS=yes
32                 AC_SUBST(BUILD_FOR_SOLARIS)
33                 MANUALLY_CREATE_SYMLINKS=yes
34                 ;;
35 esac
36 AC_SUBST(MANUALLY_CREATE_SYMLINKS)
37
38 #
39 # OC_CHECK_SAMBA_PATH([PATH],[action-if-found],[action-if-not-found])
40 # -------------------------------------------------------------------
41 AC_DEFUN([OC_CHECK_SAMBA_PATH],
42 [
43         old_PKG_CONFIG_PATH="$PKG_CONFIG_PATH"
44         PKG_CONFIG_PATH="$1/lib64/pkgconfig:$1/lib/pkgconfig${PKG_CONFIG_PATH:+:$PKG_CONFIG_PATH}"
45         export PKG_CONFIG_PATH
46         PKG_CHECK_EXISTS([samba-hostconfig], [found=1], [found=0])
47         PKG_CONFIG_PATH="$old_PKG_CONFIG_PATH"
48         if test $found = 1; then
49                 ifelse([$2],[], [echo -n ], [$2])
50                 ifelse([$3],[],[],[else
51         [$3]])
52         fi
53 ])
54
55 AC_MSG_CHECKING([for samba 4])
56
57 AC_ARG_WITH(samba, 
58 [AC_HELP_STRING([--with-samba], [Override location Samba is installed])],
59
60  sambaprefix="$withval"
61 ],[
62  for p in "$prefix" /usr/local/samba /usr/local /usr
63  do
64         OC_CHECK_SAMBA_PATH($p, [sambaprefix="$p"])
65         if test -n "${sambaprefix:-}"; then
66         break
67         fi
68  done
69 ])
70 AC_SUBST(sambaprefix)
71 OC_CHECK_SAMBA_PATH($sambaprefix,[], AC_MSG_ERROR(Samba 4 not found))
72 AC_MSG_RESULT($sambaprefix)
73 PKG_CONFIG_PATH="$sambaprefix/lib/pkgconfig:$PKG_CONFIG_PATH"
74 PATH="$sambaprefix/bin:$PATH"
75
76 #
77 # OC_SETVAL([NAME])
78 # -----------------
79 AC_DEFUN([OC_SETVAL],
80 [
81 AC_ARG_VAR([NAME], [var name])
82 if test x"$enable_$1" = x""; then
83    enable_$1="no"
84 fi[]
85 ])
86
87 #
88 # OC_CHECK_SAMBA_VERSION([RELEASE],[VERSION], [action-if-found],[action-if-not-found],
89 #                                             [action-if-cross-compiling])
90 # ------------------------------------------------------------------------------------
91 AC_DEFUN([OC_CHECK_SAMBA_VERSION], [
92 AC_RUN_IFELSE([AC_LANG_SOURCE([[
93 #include <samba/version.h>
94 int main() { if (!strcmp(SAMBA_VERSION_STRING, "$1") || !strcmp(SAMBA_VERSION_STRING, "$2")) {return 0; } else { return -1;} }
95 ]])],[$3],[
96         ifelse([$4],[],[AC_MSG_WARN([The Samba4 version installed on your system doesn't meet OpenChange requirements ($1 or $2).])],[$4])],[$5])
97 ])
98
99 #
100 # OC_RULE_ADD([NAME], [TYPE])
101 # ---------------------------
102 AC_DEFUN([OC_RULE_ADD], 
103
104 AC_ARG_VAR([NAME], [rule name])
105 AC_ARG_VAR([TYPE], [rule type])
106 if test "x${$1}set" != "xset"; then
107    case "$2" in
108         LIBS)
109                 OC_$2="$OC_$2 $1"
110                 OC_$2_INSTALL="$OC_$2_INSTALL $1-install"
111                 OC_$2_UNINSTALL="$OC_$2_UNINSTALL $1-uninstall"
112                 OC_$2_INSTALLPC="$OC_$2_INSTALLPC $1-installpc"
113                 OC_$2_INSTALLHEADER="$OC_$2_INSTALLHEADER $1-installheader"
114                 OC_$2_INSTALLLIB="$OC_$2_INSTALLLIB $1-installlib"
115
116                 AC_SUBST(OC_$2_INSTALLPC)
117                 AC_SUBST(OC_$2_INSTALLHEADER)
118                 AC_SUBST(OC_$2_INSTALLLIB)
119         ;;
120         TOOLS)
121                 OC_$2="$OC_$2 $1"
122                 OC_$2_INSTALL="$OC_$2_INSTALL $1-install"
123                 OC_$2_UNINSTALL="$OC_$2_UNINSTALL $1-uninstall"
124         ;;
125         SERVER|MAPISTORE)
126                 OC_$2="$OC_$2 $1"
127                 OC_$2_CLEAN="$OC_$2_CLEAN $1-clean"
128                 OC_$2_INSTALL="$OC_$2_INSTALL $1-install"
129                 OC_$2_UNINSTALL="$OC_$2_UNINSTALL $1-uninstall"
130         ;;
131    esac
132
133    AC_SUBST(OC_$2)
134    AC_SUBST(OC_$2_CLEAN)
135    AC_SUBST(OC_$2_INSTALL)
136    AC_SUBST(OC_$2_UNINSTALL)
137
138    enable_$1="yes"
139
140 fi[]
141 ])
142
143 dnl ##################################################################
144 dnl Some general portability stuff
145 dnl ##################################################################
146 AC_CHECK_HEADERS( sys/cdefs.h string.h sys/sockio.h)
147 AC_CHECK_FUNCS(strcasestr)
148
149
150
151 dnl ###########################################################################
152 dnl _AC_LANG_COMPILER_ICC
153 dnl Check whether the compiler for the current language is really ICC.
154 dnl ###########################################################################
155 m4_define([AC_LANG_COMPILER_ICC],
156 [AC_CACHE_CHECK([whether we are really using the Intel _AC_LANG compiler],
157                 [ac_cv_[]_AC_LANG_ABBREV[]_compiler_icc],
158 [_AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[#ifndef __INTEL_COMPILER
159        choke me
160 #endif
161 ]])],
162                    [ac_compiler_icc=yes],
163                    [ac_compiler_icc=no])
164 ac_cv_[]_AC_LANG_ABBREV[]_compiler_icc=$ac_compiler_icc
165 ])])
166
167 dnl ###########################################################################
168 dnl _AC_LANG_COMPILER_SUNCC
169 dnl Check whether the compiler for the current language is really Sun compiler.
170 dnl ###########################################################################
171 m4_define([AC_LANG_COMPILER_SUNCC],
172 [AC_CACHE_CHECK([whether we are really using the Sun _AC_LANG compiler],
173                 [ac_cv_[]_AC_LANG_ABBREV[]_compiler_suncc],
174 [_AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[#ifndef __SUNPRO_C
175        choke me
176 #endif
177 ]])],
178                    [ac_compiler_suncc=yes],
179                    [ac_compiler_suncc=no])
180 ac_cv_[]_AC_LANG_ABBREV[]_compiler_suncc=$ac_compiler_suncc
181 ])])
182
183 dnl ###########################################################################
184 dnl FreeBSD installs some libraries such as libpopt in the non default
185 dnl search path /usr/local/{include,lib}. This nasty hack ensures
186 dnl configure.ac will find the library if available and additional
187 dnl flags be correctly added while compiling.
188 dnl ###########################################################################
189 if test x"$BUILD_FOR_FREEBSD" = x"yes"; then
190    CFLAGS="$CFLAGS -I/usr/local/include"
191    LDFLAGS="$LDFLAGS  -L/usr/local/lib"
192    CXXFLAGS="$CXXFLAGS -I/usr/local/include"
193 fi
194
195 dnl ----------------------------------------------------------------------------
196 dnl Check for comparison_fn_t
197 dnl ----------------------------------------------------------------------------
198 AC_CHECK_TYPE(comparison_fn_t, 
199 [AC_DEFINE(HAVE_COMPARISON_FN_T, 1,[Whether or not we have comparison_fn_t])],
200 [], [[#include <stdlib.h>]])
201
202
203 dnl ###########################################################################
204 dnl libmapi and required dependencies
205 dnl ###########################################################################
206
207 dnl ---------------------------------------------------------------------------
208 dnl Check for CC
209 dnl ---------------------------------------------------------------------------
210 AC_PROG_CC
211
212 dnl ---------------------------------------------------------------------------
213 dnl coverage testing
214 dnl ---------------------------------------------------------------------------
215 AC_ARG_ENABLE([coverage], AS_HELP_STRING([--enable-coverage],
216                                         [Compile the library with code coverage support (default is NO)]),
217                                         [use_cov=$enableval], [use_cov=no])
218
219
220 if test "x$use_cov" = x"yes"; then
221    COVERAGE_INIT="coverage-init"
222 fi
223 AC_SUBST(COVERAGE_INIT)
224
225 dnl ---------------------------------------------------------------------------
226 dnl Set up the right compiler options
227 dnl ---------------------------------------------------------------------------
228 AC_LANG_COMPILER_SUNCC 
229 AC_LANG_COMPILER_ICC
230
231 if test x"$ac_cv_c_compiler_suncc" = x"yes"; then
232 dnl Sun Studio Compiler
233     COMPILER_OPTIONS_SHARED="-D__FUNCTION__=__func__"
234     COMPILER_OPTIONS_C="$COMPILER_OPTIONS_SHARED"
235     COMPILER_OPTIONS_CXX="$COMPILER_OPTIONS_SHARED"
236     LDFLAGS="$LDFLAGS -z ignore -R '\$\$ORIGIN/../lib'"
237 elif test x"$ac_cv_c_compiler_icc" = x"yes"; then
238 dnl Intel Compiler
239     COMPILER_OPTIONS_SHARED="-Wall -fstrict-aliasing -Wmissing-prototypes -Wstrict-prototypes -wd2259,188,593,869,981,181,1419,2218"
240     COMPILER_OPTIONS_C="$COMPILER_OPTIONS_SHARED"
241     COMPILER_OPTIONS_CXX="$COMPILER_OPTIONS_SHARED"
242 else
243 dnl GNU Compiler
244     COMPILER_OPTIONS_SHARED="-Wall -fstrict-aliasing -Wp,-D_FORTIFY_SOURCE=2"
245     if test "x$use_cov" = "xyes"; then
246         COMPILER_OPTIONS_SHARED="-O0 $COMPILER_OPTIONS_SHARED"
247     else
248         COMPILER_OPTIONS_SHARED="$COMPILER_OPTIONS_SHARED"
249     fi
250     COMPILER_OPTIONS_C="$COMPILER_OPTIONS_SHARED -Wmissing-prototypes -Wstrict-prototypes"
251     if test "x$use_cov" = "xyes"; then
252         COMPILER_OPTIONS_C="$COMPILER_OPTIONS_C -fprofile-arcs -ftest-coverage"
253         LDFLAGS="$LDFLAGS -lgcov --coverage"
254     fi
255     COMPILER_OPTIONS_CXX="$COMPILER_OPTIONS_SHARED"
256     if test "x$use_cov" = "xyes"; then
257         COMPILER_OPTIONS_CXX="$COMPILER_OPTIONS_CXX -fprofile-arcs -ftest-coverage"
258         LDFLAGS="$LDFLAGS -lgcov --coverage"
259     fi
260 fi
261 AC_SUBST(COMPILER_OPTIONS_C)
262 AC_SUBST(COMPILER_OPTIONS_CXX)
263
264 dnl ---------------------------------------------------------------------------
265 dnl Define an assert macro if this is a development release
266 dnl ---------------------------------------------------------------------------
267 . `dirname $0`/VERSION
268 AC_SUBST(OPENCHANGE_VERSION_IS_SVN_SNAPSHOT)
269
270 if test x"$OPENCHANGE_VERSION_IS_SVN_SNAPSHOT" = x"yes"; then
271    ASSERT_DEFINITION="-DENABLE_ASSERTS"
272 fi
273 AC_SUBST(ASSERT_DEFINITION)
274
275 dnl ---------------------------------------------------------------------------
276 dnl Check for install
277 dnl ---------------------------------------------------------------------------
278 AC_PROG_INSTALL
279
280 dnl ---------------------------------------------------------------------------
281 dnl Check for Perl
282 dnl ---------------------------------------------------------------------------
283 AC_PATH_PROG(PERL, perl)
284
285 if test x"$PERL" = x""; then
286    AC_MSG_WARN([No version of perl was found!])
287    AC_MSG_ERROR([Please install perl http://www.perl.com])
288 fi
289 AC_SUBST(PERL)
290
291 dnl ---------------------------------------------------------------------------
292 dnl Check for Pidl
293 dnl ---------------------------------------------------------------------------
294 AC_PATH_PROG(PIDL, pidl)
295
296 if test x"$PIDL" = x""; then
297         AC_MSG_WARN([No version of pidl was found!])
298         AC_MSG_ERROR([Please install pidl])
299 fi
300 AC_SUBST(PIDL)
301
302 dnl ---------------------------------------------------------------------------
303 dnl Check for Python
304 dnl ---------------------------------------------------------------------------
305
306 AC_PATH_PROG(PYTHON, python)
307 if test x"$PYTHON" = x""; then
308         AC_MSG_WARN([No version of python was found!])
309         AC_MSG_ERROR([Please install python])
310 fi
311 AC_SUBST(PYTHON)
312
313 AC_PATH_PROG(PYTHON_CONFIG, python-config)
314 if test x"$PYTHON_CONFIG" = x""; then
315         AC_MSG_WARN([No version of python-config was found!])
316         AC_MSG_ERROR([Please install python-dev 2.7])
317 fi
318 AC_SUBST(PYTHON_CONFIG)
319
320 AC_MSG_CHECKING(python cflags)
321 PYTHON_CFLAGS=`$PYTHON_CONFIG --cflags`
322 AC_MSG_RESULT($PYTHON_CFLAGS)
323 AC_SUBST(PYTHON_CFLAGS)
324
325 AC_MSG_CHECKING(python libs)
326 PYTHON_LIBS=`$PYTHON_CONFIG --libs`
327 AC_MSG_RESULT($PYTHON_LIBS)
328 AC_SUBST(PYTHON_LIBS)
329
330 AC_MSG_CHECKING(python library directory)
331 pythondir=`$PYTHON -c "from distutils import sysconfig; print sysconfig.get_python_lib(1, 0, '\\${prefix}')"`
332 AC_MSG_RESULT($pythondir)
333 AC_SUBST(pythondir)
334
335 dnl ----------------------------------------------------------------------------
336 dnl Check for Flex
337 dnl Flex version < 2.5.35 is fine but 2.5.4 beta is not. This is the
338 dnl default version provided under FreeBSD or RHL5
339 dnl ----------------------------------------------------------------------------
340 if test x"$OPENCHANGE_VERSION_IS_SVN_SNAPSHOT" = x"yes"; then
341    AC_ARG_VAR([FLEX], [Location of the flex program.])
342    AC_CHECK_PROG([FLEX], [flex], [flex])
343
344    if test x"$FLEX" = x""; then
345         AC_MSG_WARN([No version of flex was found!])
346         AC_MSG_ERROR([Please install flex])
347    else
348         V=`$FLEX --version | awk '{print $NF}'`
349         W=`echo $V | awk -F. '{if (((($1*100 + $2)*100 + $3) > 20535) || $3 == 4) print "no"}'`
350         if test "x$W" != x ; then
351            AC_MSG_WARN([Adjust your FLEX environment variable])
352            AC_MSG_ERROR([Flex version 2.5.35 or below is needed. You have $V])
353         fi
354    fi
355
356    AC_SUBST(FLEX)
357 fi
358
359 dnl ---------------------------------------------------------------------------
360 dnl Samba4 modules
361 dnl ---------------------------------------------------------------------------
362 PKG_CHECK_MODULES(TALLOC, talloc)
363 PKG_CHECK_MODULES(SAMBA, dcerpc ndr samba-hostconfig samba-util tevent samba-credentials)
364 PKG_CHECK_MODULES(SAMBASERVER, dcerpc_server, [], [AC_MSG_WARN([No mapiproxy support])])
365 PKG_CHECK_MODULES(SAMDB, samdb, [], [AC_MSG_WARN([No mapiproxy support])])
366 PKG_CHECK_MODULES(TDB, tdb)
367 PKG_CHECK_MODULES(LDB, ldb)
368
369 dnl ---------------------------------------------------------------------------
370 dnl Check a particular Samba4 git revision
371 dnl ---------------------------------------------------------------------------
372
373 oc_save_CPPFLAGS="$CPPFLAGS"
374 CPPFLAGS="$CPPFLAGS `$PKG_CONFIG --cflags-only-I samba-hostconfig`"
375 AC_CHECK_HEADER([samba/version.h],, AC_MSG_ERROR([Could not find Samba4 headers. Re-run ./configure with --with-samba=XXX where
376  XXX is the prefix that Samba4 was installed to.]))
377
378 . `dirname $0`/script/samba4_ver.sh
379
380 OC_CHECK_SAMBA_VERSION([$SAMBA4_RELEASE],[$SAMBA4_GIT_VER-GIT-$SAMBA4_GIT_REV])
381 CPPFLAGS="$oc_save_CPPFLAGS"
382
383 AC_MSG_CHECKING([for DCE/RPC server modules directory])
384 DCERPC_SERVER_MODULESDIR=`$PKG_CONFIG --variable=modulesdir dcerpc_server`
385 AC_SUBST(DCERPC_SERVER_MODULESDIR)
386 AC_MSG_RESULT($DCERPC_SERVER_MODULESDIR)
387
388 dnl ---------------------------------------------------------------------------
389 dnl Finally add libmapi to the library list
390 dnl ---------------------------------------------------------------------------
391 if test "x$SAMBA_LIBS" != "x" ; then
392     libmapi=1
393 fi
394 OC_RULE_ADD(libmapi, LIBS)
395
396 dnl nasty hack: only compile IDL if we have a library
397 dnl libraries require libmapi and libmapi require IDL
398 OC_IDL="idl"
399 AC_SUBST(OC_IDL)
400
401 dnl ---------------------------------------------------------------------------
402 dnl Check for dl libs
403 dnl ---------------------------------------------------------------------------
404
405 AC_CHECK_LIB([dl], [dlopen],
406             [
407                         DL_LIBS="-ldl"
408                         AC_SUBST(DL_LIBS)
409                 ],
410                 [
411                         AC_CHECK_FUNCS(dlopen, [
412                                 DL_LIBS=""
413                                 AC_SUBST(DL_LIBS)
414                         ], [
415                                 AC_MSG_ERROR([unable to find dlopen])
416                         ])
417                 ])
418
419 dnl ---------------------------------------------------------------------------
420 dnl Check for pthread libs
421 dnl ---------------------------------------------------------------------------
422 enable_pthread=no
423 enable_thread_lib=""
424 AC_CHECK_LIB([pthread], [pthread_mutex_init],
425              [
426                 AC_DEFINE(HAVE_PTHREADS, 1, [Define if you want to use pthread for thread safety])
427                 THREAD_LIBS=-lpthread
428                 enable_pthread="yes"
429                 enable_thread_lib="(pthread)"
430              ],
431              [
432              AC_MSG_WARN([pthread is missing - library is not thread safe])
433              enable_pthread="no"
434              ])
435
436 if test x"$enable_pthread" = x"no"; then
437         dnl Check for gthread-2.0 / glib based implementation
438         PKG_CHECK_MODULES(GTHREAD, gthread-2.0, 
439                 [
440                         AC_DEFINE(HAVE_GTHREAD, 1, [Define if you want to use gthread for thread safety])
441                         THREAD_LIBS=$GTHREAD_LIBS
442                         THREAD_CFLAGS=$GTHREAD_CFLAGS
443                         enable_pthread=yes
444                         enable_thread_lib="(gthread)"
445                 ], 
446                 [
447                         enable_pthread=no
448                 ])
449 fi
450
451 AC_SUBST(THREAD_LIBS)
452 AC_SUBST(THREAD_CFLAGS)
453
454 dnl Additional thread library detection is required here:
455 dnl FreeBSD (pthreads), glib etc.
456
457 dnl ###########################################################################
458 dnl libmapi++ dependencies
459 dnl ###########################################################################
460
461 dnl ---------------------------------------------------------------------------
462 dnl Check for g++
463 dnl ---------------------------------------------------------------------------
464 AC_CACHE_CHECK([C++ compiler availability], [ac_cv_libmapixx_gxx_works],
465                [
466                 AC_LANG_PUSH([C++])
467                 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])], 
468                                   [ac_cv_libmapixx_gxx_works=yes],
469                                   [ac_cv_libmapixx_gxx_works=no])
470                 AC_LANG_POP([C++])
471                 ])
472
473 dnl ---------------------------------------------------------------------------
474 dnl Check for boost-thread
475 dnl ---------------------------------------------------------------------------
476
477 AC_ARG_VAR([BOOST_LIB_SUFFIX], [Boost library name suffix])
478
479 AC_CACHE_CHECK([for boost_thread$BOOST_LIB_SUFFIX library], [ov_cv_boost_thread],
480                [
481                 ov_cv_boost_thread=no
482                 ov_save_LIBS=$LIBS
483                 LIBS="-lboost_thread$BOOST_LIB_SUFFIX $LIBS"
484                 AC_LANG_PUSH([C++])
485                 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <boost/thread.hpp>]],
486                                                 [[boost::thread t]])],
487                                 [ov_cv_boost_thread=yes])
488                 AC_LANG_POP([C++])
489                 LIBS=$ov_save_LIBS
490                ])
491
492
493 if test x"$ac_cv_libmapixx_gxx_works" = "xyes"; then
494    if test x"$ov_cv_boost_thread" = "xyes"; then
495       AC_PROG_CXX 
496       libmapixx=1
497       OC_RULE_ADD(libmapixx, LIBS)
498    fi
499 fi
500
501
502 dnl ###########################################################################
503 dnl libocpf dependencies
504 dnl ###########################################################################
505
506 dnl ---------------------------------------------------------------------------
507 dnl Check for Bison
508 dnl ---------------------------------------------------------------------------
509 if test x"$OPENCHANGE_VERSION_IS_SVN_SNAPSHOT" = x"yes"; then
510    AC_ARG_VAR([BISON], [Location of the bison program.])
511    AC_PATH_PROG([BISON], [bison], [bison])
512
513    if test x"$BISON" != x""; then
514       libocpf=1
515       OC_RULE_ADD(libocpf, LIBS)
516       AC_SUBST(BISON)
517    fi
518 else
519    libocpf=1
520    OC_RULE_ADD(libocpf, LIBS)
521 fi
522
523
524
525 dnl ###########################################################################
526 dnl libmapiadmin dependencies
527 dnl ###########################################################################
528 PKG_CHECK_EXISTS([ dcerpc_samr ],
529                 [
530                         enable_libmapiadmin="yes"
531                 ], [
532                         enable_libmapiadmin="no"
533                 ])
534
535 if test x"$enable_libmapiadmin" = x"yes"; then
536         PKG_CHECK_MODULES(SAMR, dcerpc_samr ndr_standard)
537         libmapiadmin=1
538         OC_RULE_ADD(libmapiadmin, LIBS)
539 fi
540
541
542
543 dnl ##########################################################################
544 dnl tools dependencies
545 dnl ##########################################################################
546
547 dnl --------------------------------------------------------------------------
548 dnl Check for libical                                                        
549 dnl --------------------------------------------------------------------------
550 PKG_CHECK_MODULES([ICAL], [libical], [have_libical="yes"], [have_libical="no"])
551 AC_SUBST(ICAL_CFLAGS)
552 AC_SUBST(ICAL_LIBS)
553 PKG_CHECK_MODULES([ICAL_0_46], [libical >= 0.46], [have_libical_0_46="1"], [have_libical_0_46="0"])
554 AC_SUBST(have_libical_0_46)
555
556 dnl --------------------------------------------------------------------------
557 dnl Check for popt
558 dnl --------------------------------------------------------------------------
559
560 AC_CHECK_LIB([popt], [poptFreeContext], 
561              [
562                AC_DEFINE(HAVE_LIBPOPT, 1, [Define if you want to use libpopt])
563                enable_libpopt="yes"
564              ], 
565              [ 
566                AC_MSG_WARN([libpopt is missing - can't build openchange tools]) 
567                enable_libpopt="no"
568              ])
569
570 if test x"$enable_libpopt" = x"yes"; then
571         if test x"$enable_libmapiadmin" = x"yes"; then
572            openchangepfadmin=1
573            mapitest=1
574         fi
575
576         if test x"$enable_libocpf" = x"yes"; then
577            openchangeclient=1
578         fi
579
580         if test x"$have_libical" = x"yes"; then
581             exchange2ical=1
582         fi
583
584         MAPISTORE_TEST=mapistore_test
585         mapiprofile=1
586         openchangemapidump=1
587         schemaIDGUID=1
588         check_fasttransfer=1
589         test_asyncnotif=1
590 fi
591 AC_SUBST(MAPISTORE_TEST)
592 OC_RULE_ADD(openchangeclient, TOOLS)
593 #OC_RULE_ADD(mapistore_fsocpf, MAPISTORE)
594 OC_RULE_ADD(exchange2ical, TOOLS)
595 OC_RULE_ADD(openchangepfadmin, TOOLS)
596 OC_RULE_ADD(mapitest, TOOLS)
597 OC_RULE_ADD(mapiprofile, TOOLS)
598 OC_RULE_ADD(openchangemapidump, TOOLS)
599 OC_RULE_ADD(schemaIDGUID, TOOLS)
600
601 OC_RULE_ADD(check_fasttransfer, TOOLS)
602 OC_RULE_ADD(test_asyncnotif, TOOLS)
603
604 dnl --------------------------------------------------------------------------
605 dnl Check for libmagic
606 dnl --------------------------------------------------------------------------
607 AC_CHECK_LIB([magic], [magic_open],
608              [
609                AC_DEFINE(HAVE_LIBMAGIC, 1, [Define if you want to use libmagic])
610                MAGIC_LIBS="-lmagic -lz"
611                enable_libmagic="yes"
612              ],
613                AC_SUBST(MAGIC_LIBS)
614              [
615                AC_MSG_WARN([libmagic is missing - can't build exchange2mbox])
616                enable_libmagic="no"
617              ])
618
619 if test x"$enable_libmagic" = x"yes"; then
620         AC_CHECK_LIB([z], [gzopen], [], 
621                      [
622                        AC_MSG_ERROR([Z library not found, please install zlib-devel.], [1])
623                      ])
624         if test x"$enable_libpopt" = x"yes"; then
625                 exchange2mbox=1
626         fi
627 fi
628 OC_RULE_ADD(exchange2mbox, TOOLS)
629
630 dnl ##########################################################################
631 dnl libmapistore dependencies
632 dnl ##########################################################################
633
634 AC_CHECK_LIB([rt], [mq_open],
635             [
636                         RT_LIBS="-lrt"
637                         AC_SUBST(RT_LIBS)
638                 ],
639                 [
640                         AC_CHECK_FUNCS(mq_open, [
641                                 RT_LIBS=""
642                                 AC_SUBST(RT_LIBS)
643                         ], [
644                                 AC_MSG_ERROR([unable to find mq_open])
645                         ])
646                 ])
647
648 dnl ##########################################################################
649 dnl libmapistore backends dependencies
650 dnl ##########################################################################
651
652 OC_MAPISTORE=
653 OC_MAPISTORE_CLEAN=
654 OC_MAPISTORE_INSTALL=
655 OC_MAPISTORE_UNINSTALL=
656 AC_SUBST(OC_MAPISTORE)
657 AC_SUBST(OC_MAPISTORE_CLEAN)
658 AC_SUBST(OC_MAPISTORE_INSTALL)
659 AC_SUBST(OC_MAPISTORE_UNINSTALL)
660
661 dnl ##########################################################################
662 dnl mapiproxy server
663 dnl ##########################################################################
664 if test x$PYTHON != x; then
665         if test "x$SAMDB_LIBS" != x -a "x$SAMBASERVER_LIBS" != x ; then
666                 mapiproxy=1
667         fi
668 fi
669 OC_RULE_ADD(mapiproxy, SERVER)
670
671 AC_ARG_WITH(modulesdir, 
672 [AS_HELP_STRING([--with-modulesdir], [Modules path to use])],
673 [modulesdir="$withval"; ],
674 [modulesdir="\${prefix}/modules"; ])
675
676 AC_SUBST(modulesdir)
677
678 dnl ##########################################################################
679 dnl Python bindings dependencies
680 dnl ##########################################################################
681 AC_ARG_ENABLE(pymapi, AC_HELP_STRING([--enable-pymapi],
682                            [build Python bindings for libmapi]),
683                            enable_pymapi="$enableval",
684                            enable_pymapi=no)
685 PYCDIR=`$PYTHON -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(1, prefix='\\$(prefix)')"`
686 AC_SUBST(PYCDIR)
687
688 dnl Enable pyopenchange by default
689 PYMAPIALL="$PYMAPIALL pyopenchange"
690 PYMAPIINSTALL="$PYMAPIALLINSTALL pyopenchange-install"
691 PYMAPIUNINSTALL="$PYMAPIUNINSTALL pyopenchange-uninstall"
692
693 AC_SUBST(PYMAPIALL)
694 AC_SUBST(PYMAPIINSTALL)
695 AC_SUBST(PYMAPIUNINSTALL)
696
697
698 dnl ##########################################################################
699 dnl Documentation dependencies
700 dnl ##########################################################################
701 AC_PATH_PROG(DOXYGEN, doxygen)
702 if test x"$DOXYGEN" = x""; then
703         AC_MSG_WARN(doxygen)
704         enable_doxygen="no"
705 else
706         enable_doxygen="yes"
707         AC_SUBST(DOXYGEN)
708 fi
709
710 dnl ##########################################################################
711 dnl (Optional) subunit support in mapitest
712 dnl ##########################################################################
713 PKG_CHECK_MODULES(SUBUNIT, libsubunit, found_subunit=yes, found_subunit=no)
714 AC_SUBST(SUBUNIT_CFLAGS)
715 AC_SUBST(SUBUNIT_LIBS)
716
717 if test x"$found_subunit" = x"yes"; then
718         AC_DEFINE(HAVE_SUBUNIT, 1, [Define if you want to use subunit])
719         have_subunit="yes"
720 else
721         have_subunit="no"
722 fi
723
724 dnl ##########################################################################
725 dnl Qt4 support
726 dnl ##########################################################################
727 AC_ARG_ENABLE(openchange-qt4,
728               AC_HELP_STRING([--enable-openchange-qt4],
729                              [Compile OpenChange Qt4 wrapper.]),
730               enable_openchange_qt4=$enableval,
731               enable_openchange_qt4="no")
732 if test x$enable_openchange_qt4 = xyes; then
733   PKG_CHECK_MODULES(Qt4,
734                     QtCore >= 4.3.0 QtGui >= 4.3.0)
735   MOC=`$PKG_CONFIG --variable=moc_location QtCore`
736 elif test x$enable_openchange_qt4 = xtry; then
737   PKG_CHECK_MODULES(Qt4,
738                     QtCore >= 4.3.0 QtGui >= 4.3.0,
739                     [enable_openchange_qt4="yes"
740                      MOC=`$PKG_CONFIG --variable=moc_location QtCore`],
741                     [enable_openchange_qt4="no"])
742 fi
743
744 AC_SUBST(Qt4_CFLAGS)
745 AC_SUBST(Qt4_LIBS)
746 AC_SUBST(MOC)
747
748 if test "x$enable_openchange_qt4" = "xyes"; then
749    OPENCHANGE_QT4="openchange_qt4"
750 fi
751 AC_SUBST(OPENCHANGE_QT4)
752
753 dnl ***********************
754 dnl Makefiles 
755 dnl ***********************
756 AC_CONFIG_FILES([config.mk libmapi.pc libmapiadmin.pc libocpf.pc mapiproxy/libmapiproxy.pc
757                  mapiproxy/libmapiserver.pc mapiproxy/libmapistore.pc libmapi++.pc
758                  Doxyfile libmapi++/Doxyfile libocpf/Doxyfile libmapiadmin/Doxyfile
759                  libmapi/Doxyfile mapiproxy/Doxyfile utils/mapitest/Doxyfile
760                  mapiproxy/libmapistore/Doxyfile])
761 AC_OUTPUT
762
763
764 dnl ##########################################################################
765 dnl Print configuration info
766 dnl ##########################################################################
767
768 OC_SETVAL(libmapi)
769 OC_SETVAL(libmapiadmin)
770 OC_SETVAL(libocpf)
771 OC_SETVAL(libmapixx)
772
773 OC_SETVAL(openchangeclient)
774 OC_SETVAL(mapiprofile)
775 OC_SETVAL(openchangepfadmin)
776 OC_SETVAL(exchange2mbox)
777 OC_SETVAL(exchange2ical)
778 OC_SETVAL(mapitest)
779 OC_SETVAL(openchangemapidump)
780 OC_SETVAL(schemaIDGUID)
781 OC_SETVAL(mapiproxy)
782
783 OC_SETVAL(doxygen)
784
785 AC_MSG_RESULT([
786
787 ===============================================================
788 OpenChange Configuration (Please review)
789
790            * OpenChange Libraries:
791              - libmapi (C library):     $enable_libmapi
792                       Thread support:   $enable_pthread $enable_thread_lib
793              - libmapi++ (C++ library): $enable_libmapixx
794              - libmapiadmin:            $enable_libmapiadmin
795              - libocpf:                 $enable_libocpf
796
797            * OpenChange Server:
798              - mapiproxy:               $enable_mapiproxy
799
800            * OpenChange mapistore backends:
801              - backends dependencies goes here
802
803            * OpenChange Tools:
804              - openchangeclient:        $enable_openchangeclient
805              - mapiprofile:             $enable_mapiprofile
806              - openchangepfadmin:       $enable_openchangepfadmin
807              - exchange2mbox:           $enable_exchange2mbox
808              - exchange2ical:           $enable_exchange2ical
809              - mapitest:                $enable_mapitest
810              - openchangemapidump:      $enable_openchangemapidump
811              - schemaIDGUID:            $enable_schemaIDGUID
812
813            * subunit format (mapitest): $have_subunit
814
815            * OpenChange Documentation:  $enable_doxygen
816
817            * Coverage Tests:            $use_cov
818
819            * OpenChange Bindings:
820              - Qt4:                     $enable_openchange_qt4
821
822            * Installation prefix:       $prefix
823
824 ===============================================================
825
826 ])
827