aboutsummaryrefslogtreecommitdiffstats
path: root/configure.in
blob: e56331ea13f735c2442cf7c6cc5715ce5022de0c (plain) (blame)
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
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
# Process this file with autoconf to produce a configure script.
AC_INIT(camel)
AM_CONFIG_HEADER(config.h)

EVOLUTION_MAJOR_VERSION=0
EVOLUTION_MINOR_VERSION=10
EVOLUTION_MICRO_VERSION=99
VERSION=$EVOLUTION_MAJOR_VERSION.$EVOLUTION_MINOR_VERSION.$EVOLUTION_MICRO_VERSION
PACKAGE=evolution

AM_INIT_AUTOMAKE($PACKAGE, $VERSION)
AC_SUBST(VERSION)

AC_DEFUN(EVO_CHECK_LIB, [
    dispname="$1"
    pkgname="$2"
    minvers="$3"
    maxvers="$4"

    AC_MSG_CHECKING(for $dispname)

    if gnome-config --libs $pkgname > /dev/null 2>&1; then
        pkgvers=`gnome-config --modversion $pkgname | sed -e 's/^[[^0-9]]*//'`
    else
        pkgvers=not
    fi
    AC_MSG_RESULT($pkgvers found)

    pkgvers=`echo $pkgvers | awk -F. '{ print $[]1 * 1000000 + $[]2 * 10000 + $[]3 * 100 + $[]4;}'`
    cmpminvers=`echo $minvers | awk -F. '{ print $[]1 * 1000000 + $[]2 * 10000 + $[]3 * 100 + $[]4;}'`
    cmpmaxvers=`echo $maxvers | awk -F. '{ print $[]1 * 1000000 + $[]2 * 10000 + $[]3 * 100 + $[]4;}'`
    ok=yes
    if test "$pkgvers" -lt $cmpminvers; then
        ok=no
    elif test -n "$maxvers" -a "$pkgvers" -ge $cmpmaxvers; then
        ok=no
    fi
    if test $ok = no; then
        case $maxvers in
        "")
            dispvers="$minvers or higher"
            ;;
        $minvers)
            dispvers="$minvers (exactly)"
            ;;
        *)
            dispvers="$minvers or higher, but less than $maxvers,"
            ;;
        esac

        AC_MSG_ERROR([
""
"You need $dispname $dispvers to build Evolution"
"If you think you already have this installed, consult the README."])
    fi
])


dnl Initialize maintainer mode
AM_MAINTAINER_MODE

AC_ISC_POSIX
AC_PROG_CC
AC_PROG_CPP
AM_PROG_LEX
AC_PROG_YACC
case $YACC in
*yacc*)
    AC_MSG_ERROR(You need bison to build Evolution)
    ;;
esac
AC_STDC_HEADERS
AC_ARG_PROGRAM
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET

dnl Initialize xml-i18n-tools
AM_PROG_XML_I18N_TOOLS

dnl Initialize libtool
AM_PROG_LIBTOOL

AM_ACLOCAL_INCLUDE(macros)
GNOME_INIT()
GNOME_COMPILE_WARNINGS
GNOME_X_CHECKS
EVO_CHECK_LIB(gnome-libs, gnome, 1.2.9)

ALL_LINGUAS="az ca da de el en_GB es fi fr ga gl hu it ja ko lt nl nn no pl pt pt_BR ru sk sl sv tr uk"
AM_GNOME_GETTEXT
localedir='$(prefix)/$(DATADIRNAME)/locale'
AC_SUBST(localedir)

dnl
dnl Purify support
dnl
AC_ARG_ENABLE(purify, 
[  --enable-purify=[no/yes]      Enable support for building executables with
                                Purify.],,enable_purify=no)
AC_PATH_PROG(PURIFY, purify, impure)
AC_ARG_WITH(purify-options, [  --with-purify-options=OPTIONS      Options passed to the purify command line (defaults to PURIFYOPTIONS variable).])
if test "x$with_purify_options" = "xno"; then
  with_purify_options="-always-use-cache-dir=yes -cache-dir=/gnome/lib/purify"
fi
if test "x$PURIFYOPTIONS" = "x"; then
  PURIFYOPTIONS=$with_purify_options
fi
AC_SUBST(PURIFY)
AM_CONDITIONAL(ENABLE_PURIFY, test "x$enable_purify" = "xyes" -a "x$PURIFY" != "ximpure")
PURIFY="$PURIFY $PURIFYOPTIONS"


AC_PATH_PROG(SENDMAIL, sendmail, /usr/sbin/sendmail, /usr/sbin:/usr/lib)
AC_DEFINE_UNQUOTED(SENDMAIL_PATH, "$SENDMAIL")

AC_MSG_CHECKING(system mail directory)
if test -d /var/mail; then
    system_mail_dir=/var/mail
else
    system_mail_dir=/var/spool/mail
fi
AC_DEFINE_UNQUOTED(SYSTEM_MAIL_DIR, "$system_mail_dir")

dnl * Time zone stuff
AC_CACHE_CHECK(for timezone variable, ac_cv_var_timezone,
    AC_TRY_COMPILE([
        #include <time.h>
    ], [
        timezone = 1;
    ], ac_cv_var_timezone=yes, ac_cv_var_timezone=no))
if test $ac_cv_var_timezone = yes; then
    AC_DEFINE(HAVE_TIMEZONE)
else
    AC_CACHE_CHECK(for tm_gmtoff in struct tm, ac_cv_struct_tm_gmtoff,
        AC_TRY_COMPILE([
            #include <time.h>
            ], [
            struct tm tm;
            tm.tm_gmtoff = 1;
            ], ac_cv_struct_tm_gmtoff=yes, ac_cv_struct_tm_gmtoff=no))
    if test $ac_cv_struct_tm_gmtoff = yes; then
        AC_DEFINE(HAVE_TM_GMTOFF)
    else
        AC_ERROR(unable to find a way to determine timezone)
    fi
fi

AC_CHECK_FUNCS(mkstemp mkdtemp isblank)

dnl **************************************************
dnl ctime_r prototype
dnl **************************************************

AC_CACHE_CHECK([if ctime_r wants three arguments], ac_cv_ctime_r_three_args,
[
    AC_TRY_COMPILE([
        #include <time.h>
    ],[
        char *buf;
        time_t date;
        ctime_r( &date, buf, 100 );
    ],[
        ac_cv_ctime_r_three_args=yes
    ],[
        ac_cv_ctime_r_three_args=no
    ])
])
    
if test x"$ac_cv_ctime_r_three_args" = xyes ; then
    AC_DEFINE(CTIME_R_THREE_ARGS)
fi

dnl **************************************************
dnl gethostbyname_r prototype
dnl **************************************************

AC_CHECK_FUNCS(gethostbyname_r,[
AC_CACHE_CHECK([if gethostbyname_r wants five arguments], ac_cv_gethostbyname_r_five_args,
[
    AC_TRY_COMPILE([
        #include "confdefs.h"
        #include <sys/types.h>
        #include <sys/socket.h>
        #include <netinet/in.h>
        #include <netdb.h>

        #define BUFSIZE (sizeof(struct hostent)+10)
    ],[
        struct hostent hent;
        char buffer[BUFSIZE];
        int bufsize=BUFSIZE;
        int h_errno;

        (void)gethostbyname_r( "www.ximian.com", &hent, buffer, bufsize, &h_errno);
    ],[
        ac_cv_gethostbyname_r_five_args=yes
    ],[
        ac_cv_gethostbyname_r_five_args=no
    ])
])])
    
if test x"$ac_cv_gethostbyname_r_five_args" = xyes ; then
    AC_DEFINE(GETHOSTBYNAME_R_FIVE_ARGS)
fi

dnl **************************************************
dnl * pas-backend-file stuff.
dnl * check for version 3.1.17 of db.h.  First check
dnl * in db.h, then in db3/db.h (For Red Hat Linux
dnl * 7.0).
dnl **************************************************

AC_ARG_WITH(db3-includes, [  --with-db3-includes=PREFIX     Location of db3 includes.],
    with_db3_includes="$withval")

DB3_CFLAGS=

AC_CACHE_CHECK([for libdb3 version 3.1.17], ac_cv_db3_version_check,
[
    CPPFLAGS_save="$CPPFLAGS"
    if test "x${with_db3_includes}" != "x"; then
        CPPFLAGS="-I$with_db3_includes $CPPFLAGS"
    fi

    AC_TRY_COMPILE([
        #include <db.h>
    ],[
        #if DB_VERSION_MAJOR != 3 || \
            DB_VERSION_MINOR != 1 || \
            DB_VERSION_PATCH != 17
        #error
        #endif
    ], ac_cv_db3_version_check=yes, ac_cv_db3_version_check=no)

    CPPFLAGS="$CPPFLAGS_save"
])

if test $ac_cv_db3_version_check = yes; then
    AC_DEFINE(HAVE_DB_H)
    if test "x${with_db3_includes}" != "x"; then
        DB3_CFLAGS="-I$with_db3_includes"
    fi
else
    AC_CACHE_CHECK([for libdb3 version 3.1.17 in db3/db.h], ac_cv_db3_db3_db_h_version_check,
    [
        CPPFLAGS_save="$CPPFLAGS"
        if test "x${with_db3_includes}" != "x"; then
            CPPFLAGS="-I$with_db3_includes $CPPFLAGS"
        fi

        AC_TRY_COMPILE([
            #include <db3/db.h>
        ],[
            #if DB_VERSION_MAJOR != 3 || \
                DB_VERSION_MINOR != 1 || \
                DB_VERSION_PATCH != 17
            #error
            #endif
        ], ac_cv_db3_db3_db_h_version_check=yes, ac_cv_db3_db3_db_h_version_check=no)

        CPPFLAGS="$CPPFLAGS_save"
    ])
    if test $ac_cv_db3_db3_db_h_version_check = yes; then
        AC_DEFINE(HAVE_DB3_DB_H)
        if test "x${with_db3_includes}" != "x"; then
            DB3_CFLAGS="-I$with_db3_includes"
        fi
    else
        AC_ERROR(You must have libdb3 version 3.1.17 installed to compile evolution)
    fi
fi

AC_SUBST(DB3_CFLAGS)


AC_ARG_WITH(db3-libs, [  --with-db3-libs=PREFIX     Location of db3 libs.],
    with_db3_libs="$withval", with_db3_libs="/usr/lib/")

DB3_LDADD=

if test $ac_cv_db3_version_check = yes; then
    HAVE_DB3_DB_H_INTERNAL=0
else
    HAVE_DB3_DB_H_INTERNAL=1
fi

AC_CACHE_CHECK([for -ldb 3.1.17], ac_cv_db3_lib_check,
[
    LIBS_save="$LIBS"
    LIBS="$with_db3_libs/libdb.a $LIBS"
    CPPFLAGS_save="$CPPFLAGS"
    CPPFLAGS="$CPPFLAGS $DB3_CFLAGS"

    AC_TRY_RUN([
#if $HAVE_DB3_DB_H_INTERNAL
#include <db3/db.h>
#else
#include <db.h>
#endif
int
main (void)
{
    int major, minor, patch;
    db_version (&major, &minor, &patch);
    if (major == 3 &&
        minor == 1 &&
        patch == 17)
        return 0;
    else
        return 1;
}
], ac_cv_db3_lib_check=yes, ac_cv_db3_lib_check=no)

    LIBS="$LIBS_save"
    CPPFLAGS="$CPPFLAGS_save"
])

if test $ac_cv_db3_lib_check = yes; then
    DB3_LDADD="$with_db3_libs/libdb.a"
else
    AC_CACHE_CHECK([for -ldb3 3.1.17], ac_cv_db3_lib_db3_check,
    [
        LIBS_save="$LIBS"
        LIBS="$with_db3_libs/libdb3.a $LIBS"
        CPPFLAGS_save="$CPPFLAGS"
        CPPFLAGS="$CPPFLAGS $DB3_CFLAGS"
    
        AC_TRY_RUN([
#if $HAVE_DB3_DB_H_INTERNAL
#include <db3/db.h>
#else
#include <db.h>
#endif
int
main (void)
{
    int major, minor, patch;
    db_version (&major, &minor, &patch);
    if (major == 3 &&
        minor == 1 &&
        patch == 17)
        return 0;
    else
        return 1;
}
], ac_cv_db3_lib_db3_check=yes, ac_cv_db3_lib_db3_check=no)
    
        LIBS="$LIBS_save"
        CPPFLAGS="$CPPFLAGS_save"
    ])
fi

if test $ac_cv_db3_lib_db3_check = yes; then
    DB3_LDADD="$with_db3_libs/libdb3.a"
else
    AC_CACHE_CHECK([for -ldb-3.1 3.1.17], ac_cv_db3_lib_db31_check,
    [
        LIBS_save="$LIBS"
        LIBS="$with_db3_libs/libdb-3.1.a $LIBS"
        CPPFLAGS_save="$CPPFLAGS"
        CPPFLAGS="$CPPFLAGS $DB3_CFLAGS"
    
        AC_TRY_RUN([
#if $HAVE_DB3_DB_H_INTERNAL
#include <db3/db.h>
#else
#include <db.h>
#endif
int
main (void)
{
    int major, minor, patch;
    db_version (&major, &minor, &patch);
    if (major == 3 &&
        minor == 1 &&
        patch == 17)
        return 0;
    else
        return 1;
}
], ac_cv_db3_lib_db31_check=yes, ac_cv_db3_lib_db31_check=no)
    
        LIBS="$LIBS_save"
        CPPFLAGS="$CPPFLAGS_save"
    ])
    
    if test $ac_cv_db3_lib_db31_check = yes; then
        DB3_LDADD="$with_db3_libs/libdb-3.1.a"
    else
        AC_ERROR(Didn't find libdb 3.1.17 libraries.  You must have libdb version 3.1.17 installed to compile evolution)
    fi
fi

AC_SUBST(DB3_LDADD)

dnl **************************************************
dnl * ldap related stuff.
dnl **************************************************
AC_ARG_ENABLE(ldap, 
[  --enable-ldap=[no/yes]      Enable LDAP support in evolution],,enable_ldap=no)
if test x$enable_ldap = xyes; then
  LDAP_LIBS=
  AC_CHECK_LIB(resolv, res_query, LDAP_LIBS="-lresolv")
  AC_CHECK_LIB(lber, ber_get_tag, LDAP_LIBS="-llber $LDAP_LIBS", ,$LDAP_LIBS)
  if test x$ac_cv_lib_lber_ber_get_tag = xyes; then
    AC_CHECK_LIB(ldap, ldap_open, LDAP_LIBS="-lldap $LDAP_LIBS", ,$LDAP_LIBS)
  fi
fi


if test x$ac_cv_lib_ldap_ldap_open = xyes; then
dnl *
dnl * check for openldap version 2.x, since 1.x doesn't have the schema stuff
dnl *
    AC_MSG_CHECKING(if openldap is version 2.x)
    AC_EGREP_CPP(yes,
    [#include "ldap.h"
     #if LDAP_VENDOR_VERSION > 20000
     yes
     #endif
     ], is_2x=yes, is_2x=no)

    if test x$is_2x = xyes; then
        AC_MSG_RESULT(yes)
    AC_DEFINE(HAVE_LDAP)
    AC_SUBST(LDAP_LIBS)
    msg_ldap=yes
    else
    AC_MSG_ERROR(evolution requires OpenLDAP version >= 2)
    fi
else
    msg_ldap=no
        enable_ldap=no
fi
AM_CONDITIONAL(ENABLE_LDAP, test x$enable_ldap = xyes)

dnl **************************************************
dnl NNTP support.
dnl **************************************************
AC_ARG_ENABLE(nntp, 
[  --enable-nntp=[no/yes]      Enable NNTP support in evolution],,enable_nntp=no)
if test "x$enable_nntp" = "xyes"; then
    AC_DEFINE(ENABLE_NNTP)
    msg_nntp=yes
else
    msg_nntp=no
fi
AM_CONDITIONAL(ENABLE_NNTP, test x$enable_nntp = xyes)

dnl **************************************************
dnl * Posix thread support
dnl **************************************************

dnl Hah! Threads are no longer an option
dnl AC_ARG_WITH(threads, [  --with-threads          Include thread support],[
dnl FIXME: support more thread types, pth at least

GNOME_PTHREAD_CHECK

if test "x$PTHREAD_LIB" = "x" ; then
    AC_MSG_ERROR([POSIX threads are currently required for Evolution])
fi

dnl
dnl Notice that this is a hack, and we wont be able to use this forever, but
dnl at least for some time
dnl

THREADS_LIBS="$PTHREAD_LIB `glib-config --libs gthread`"
THREADS_CFLAGS="`glib-config --cflags gthread`"

AC_SUBST(THREADS_LIBS)
AC_SUBST(THREADS_CFLAGS)
AC_DEFINE(ENABLE_THREADS)

dnl **************************************************
dnl * File locking
dnl **************************************************

AC_ARG_ENABLE(dot-locking, 
[  --enable-dot-locking=[yes/no] Enable support for locking mail files with dot locking],,enable_dot_locking=yes)
if test "x$enable_dot_locking" = "xyes"; then
  AC_DEFINE(USE_DOT)
  msg_dot=yes
else
  msg_dot=no    
fi

AC_ARG_ENABLE(file-locking, 
[  --enable-file-locking=[fcntl/flock/no] Enable support for locking mail files with file locking],,enable_file_locking=fcntl)
if test "x$enable_file_locking" = "xfcntl"; then
  AC_DEFINE(USE_FCNTL)
  msg_file=fcntl
else
  if test "x$enable_file_locking" = "xflock"; then
    AC_DEFINE(USE_FLOCK)
    msg_file=flock
  else
    msg_file=no 
  fi
fi



dnl ***************
dnl GNOME Libraries
dnl ***************
EVO_CHECK_LIB(Bonobo, bonobox, 1.0.3)
EVO_CHECK_LIB(OAF, oaf, 0.6.2)
EVO_CHECK_LIB(libglade, libglade, 0.14)
EVO_CHECK_LIB(gdk-pixbuf with GNOME canvas support, gnomecanvaspixbuf, 0.9.0)
EVO_CHECK_LIB(GAL, gal, 0.8.99.2)
dnl FIXME: really a post-0.9.3 version (as of April 25) is needed for
dnl changes in Editor.idl (menesis)
EVO_CHECK_LIB(GtkHTML, gtkhtml, 0.9.3)
EVO_CHECK_LIB(GNOME-VFS, vfs, 1.0)
EVO_CHECK_LIB(libxml, xml, 1.8.10, 2.0)



dnl *************************
dnl CFLAGS and LIBS and stuff
dnl *************************
GLIB_CFLAGS="`glib-config --cflags`"
GLIB_LIBS="`glib-config --libs`"
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)

GAL_CFLAGS="`gnome-config --cflags gal`"
GAL_LIBS="`gnome-config --libs gal`"
AC_SUBST(GAL_CFLAGS)
AC_SUBST(GAL_LIBS)

EXTRA_GNOME_LIBS="`gnome-config --libs libglade gdk_pixbuf gnomecanvaspixbuf gnomeui gal` $THREADS_LIBS"
EXTRA_GNOME_CFLAGS="`gnome-config --cflags libglade gdk_pixbuf gnomecanvaspixbuf gnomeui gal` $THREADS_CFLAGS"

AC_SUBST(EXTRA_GNOME_LIBS)
AC_SUBST(EXTRA_GNOME_CFLAGS)

BONOBO_GNOME_LIBS="`gnome-config --libs bonobox_print libglade gdk_pixbuf gnomecanvaspixbuf gnomeui` $OAF_LIBS"
BONOBO_GNOME_CFLAGS="`gnome-config --cflags bonobox_print libglade gdk_pixbuf gnomecanvaspixbuf gnomeui` $OAF_CFLAGS"
AC_SUBST(BONOBO_GNOME_LIBS)
AC_SUBST(BONOBO_GNOME_CFLAGS)

BONOBO_HTML_GNOME_LIBS="`gnome-config --libs bonobox_print libglade gdk_pixbuf gtkhtml gnomecanvaspixbuf gnomeui ` $THREAD_LIBS"
BONOBO_HTML_GNOME_CFLAGS="`gnome-config --cflags bonobox_print libglade gdk_pixbuf gtkhtml gnomecanvaspixbuf gnomeui ` $THREAD_CFLAGS"
AC_SUBST(BONOBO_HTML_GNOME_LIBS)
AC_SUBST(BONOBO_HTML_GNOME_CFLAGS)

GNOME_PRINT_LIBS=`gnome-config --libs print`
GNOME_PRINT_CFLAGS=`gnome-config --cflags print`
AC_SUBST(GNOME_PRINT_LIBS)
AC_SUBST(GNOME_PRINT_CFLAGS)

GTKHTML_CFLAGS="`gnome-config --cflags gtkhtml`"
GTKHTML_LIBS="`gnome-config --libs gtkhtml`"
GTKHTML_DATADIR=`gnome-config --moddatadir gtkhtml`
AC_SUBST(GTKHTML_CFLAGS)
AC_SUBST(GTKHTML_LIBS)
AC_SUBST(GTKHTML_DATADIR)

GNOME_VFS_LIBS="`gnome-config --libs vfs`"
GNOME_VFS_CFLAGS="`gnome-config --cflags vfs`"
AC_SUBST(GNOME_VFS_LIBS)
AC_SUBST(GNOME_VFS_CFLAGS)

BONOBO_VFS_GNOME_LIBS="`gnome-config --libs bonobox libglade gdk_pixbuf gnomecanvaspixbuf vfs gnomeui `"
BONOBO_VFS_GNOME_CFLAGS="`gnome-config --cflags bonobox libglade gdk_pixbuf gnomecanvaspixbuf vfs gnomeui `"
AC_SUBST(BONOBO_VFS_GNOME_LIBS)
AC_SUBST(BONOBO_VFS_GNOME_CFLAGS)

CAMEL_CFLAGS="`gnome-config --cflags gal xml` $THREADS_CFLAGS"
CAMEL_LIBS="`gnome-config --libs gal xml` $THREADS_LIBS"
AC_SUBST(CAMEL_CFLAGS)
AC_SUBST(CAMEL_LIBS)

MAILER_CFLAGS="`gnome-config --cflags gtkhtml libglade gdk_pixbuf gnomecanvaspixbuf gnomeui gal bonobox bonobox_print vfs` $THREADS_CFLAGS"
MAILER_LIBS="`gnome-config --libs gtkhtml libglade gdk_pixbuf gnomecanvaspixbuf gnomeui gal bonobox bonobox_print vfs` $THREADS_LIBS"
AC_SUBST(MAILER_CFLAGS)
AC_SUBST(MAILER_LIBS)

dnl ******************************
dnl Pilot checking
dnl ******************************
AC_ARG_ENABLE(pilot-conduits, 
[  --enable-pilot-conduits=[no/yes] Enable support for building pilot conduits.],,enable_pilot_conduits=no)
if test "x$enable_pilot_conduits" = "xyes"; then
GNOME_PILOT_CHECK
fi
AM_CONDITIONAL(ENABLE_PILOT_CONDUITS, test "x$enable_pilot_conduits" = "xyes")
if test x$enable_pilot_conduits = xyes; then
   msg_pilot=yes
else
   msg_pilot=no
fi

dnl ********
dnl Kerberos
dnl ********
AC_ARG_WITH(krb5, [  --with-krb5=PREFIX      Location of Kerberos 5 libs/includes])
AC_ARG_WITH(krb4, [  --with-krb4=PREFIX      Location of Kerberos 4 libs/includes])
msg_krb5=no
if test ${with_krb5:=no} != no; then
    LDFLAGS_save="$LDFLAGS"

    mitlibs="-lkrb5 -lk5crypto -lcom_err"
    heimlibs="-lkrb5 -lcrypto -lasn1 -lcom_err -lroken"
    AC_CACHE_CHECK([for Kerberos 5], ac_cv_lib_kerberos5,
    [
        LDFLAGS="$LDFLAGS -L$with_krb5/lib $mitlibs"
        AC_TRY_LINK_FUNC(krb5_init_context, ac_cv_lib_kerberos5="$mitlibs",
        [
            LDFLAGS="$LDFLAGS_save -L$with_krb5/lib $heimlibs"
            AC_TRY_LINK_FUNC(krb5_init_context, ac_cv_lib_kerberos5="$heimlibs", ac_cv_lib_kerberos5=no)
        ])
        LDFLAGS="$LDFLAGS_save"
    ])
    if test "$ac_cv_lib_kerberos5" != no; then
        AC_DEFINE(HAVE_KRB5)
        msg_krb5=yes
        KRB5_CFLAGS="-I$with_krb5/include/krb5"
        KRB5_LDFLAGS="-L$with_krb5/lib $ac_cv_lib_kerberos5"
    fi
else
    AC_MSG_CHECKING(for Kerberos 5)
    AC_MSG_RESULT($with_krb5)
fi

msg_krb4=no
if test x${with_krb4:=no} != xno; then
    LDFLAGS_save="$LDFLAGS"
    AC_CACHE_CHECK(for Kerberos 4, ac_cv_lib_kerberos4,
    [
        ac_cv_lib_kerberos4=no

        case $ac_cv_lib_kerberos5 in
        *k5crypto*)
            # Look for MIT krb5 compat krb4
            LDFLAGS="$LDFLAGS -L$with_krb4/lib -lkrb4 -ldes425 $KRB5_LDFLAGS"
            AC_TRY_LINK_FUNC(krb_mk_req, ac_cv_lib_kerberos4="-lkrb4 -ldes425 $KRB5_LDFLAGS")
            ;;
        esac

        if test "$ac_cv_lib_kerberos4" = no; then
            # Look for KTH krb4
            LDFLAGS="$LDFLAGS_save -L$with_krb4/lib -lkrb -lcrypto -lcom_err -lroken"
            AC_TRY_LINK_FUNC(krb_mk_req, ac_cv_lib_kerberos4="-lkrb -lcrypto -lcom_err -lroken")
        fi
        if test "$ac_cv_lib_kerberos4" = no; then
            # Look for old MIT krb4
            LDFLAGS="$LDFLAGS_save -L$with_krb4/lib -lkrb"
            AC_TRY_LINK_FUNC(krb_mk_req, ac_cv_lib_kerberos4=-lkrb,
            [
                LDFLAGS="$LDFLAGS -ldes"
                AC_TRY_LINK_FUNC(krb_mk_req, ac_cv_lib_kerberos4="-lkrb -ldes")
            ])
        fi
    ])
    LDFLAGS="$LDFLAGS_save"
    if test "$ac_cv_lib_kerberos4" != no; then
        AC_DEFINE(HAVE_KRB4)
        msg_krb4=yes
        if test -f "$with_krb4/include/krb.h" -o -f "$with_krb4/include/port-sockets.h"; then
            KRB4_CFLAGS="-I$with_krb4/include"
        else
            KRB4_CFLAGS="-I$with_krb4/include/kerberosIV"
        fi
        KRB4_LDFLAGS="-L$with_krb4/lib $ac_cv_lib_kerberos4"

        CFLAGS_save="$CFLAGS"
        CFLAGS="$CFLAGS $KRB4_CFLAGS"
        AC_TRY_COMPILE([#include "krb.h"
        int krb_sendauth;
        ],[return 0],[AC_DEFINE(NEED_KRB_SENDAUTH_PROTO)],)
        CFLAGS="$CFLAGS_save"
    fi
else
    AC_MSG_CHECKING(for Kerberos 4)
    AC_MSG_RESULT(${with_krb4})
fi

AC_SUBST(KRB5_CFLAGS)
AC_SUBST(KRB5_LDFLAGS)
AC_SUBST(KRB4_CFLAGS)
AC_SUBST(KRB4_LDFLAGS)


dnl ===============================================================================
dnl = security extension support (SSL and S/MIME)
dnl =
dnl = The following voodoo does detection of mozilla libraries (nspr and nss) 
dnl = needed by Camel (SSL) and Evolution (S/MIME).
dnl =
dnl = The Evolution security extensions are only built if these libraries are found
dnl ===============================================================================
AC_ARG_WITH(nspr-includes, [  --with-nspr-includes=PREFIX     Location of Mozilla nspr4 includes.],
    with_nspr_includes="$withval", with_nspr_includes="/usr/include/mozilla")
have_nspr_includes="no"
if test "x${with_nspr_includes}" != "xno"; then
    CPPFLAGS_save="$CPPFLAGS"
    
    AC_MSG_CHECKING(for Mozilla nspr4 includes in $with_nspr_includes)
    AC_MSG_RESULT("")
    
    CPPFLAGS="$CPPFLAGS -I$with_nspr_includes"
    AC_CHECK_HEADERS(nspr.h prio.h, [ moz_nspr_includes="yes" ])
    CPPFLAGS="$CPPFLAGS_save"
    
    if test "x{$moz_nspr_includes}" != "xno" -a "x{$moz_nspr_includes}" != "x" ; then
        have_nspr_includes="yes"
        NSPR_CFLAGS="-I$with_nspr_includes"
    fi
else
    AC_MSG_CHECKING(for Mozilla nspr4 includes)
    AC_MSG_RESULT(no)
fi

AC_ARG_WITH(nspr-libs, [  --with-nspr-libs=PREFIX     Location of Mozilla nspr4 libs.],
    with_nspr_libs="$withval")
have_nspr_libs="no"
if test "x${with_nspr_libs}" != "xno" -a "x${have_nspr_includes}" != "xno"; then
    CFLAGS_save="$CFLAGS"
    LDFLAGS_save="$LDFLAGS"
    
    nsprlibs="-lnspr4 -lplc4 -lplds4 $PTHREAD_LIB"
    AC_CACHE_CHECK([for Mozilla nspr libraries], moz_nspr_libs,
    [
        CFLAGS="$CFLAGS $NSPR_CFLAGS"
        
        if test "x${with_nspr_libs}" != "x"; then
            LDFLAGS="$LDFLAGS -L$with_nspr_libs $nsprlibs"
        else
            LDFLAGS="$LDFLAGS $nsprlibs"
        fi
        
        AC_TRY_LINK_FUNC(PR_Init, moz_nspr_libs="yes", moz_nspr_libs="no")
        CFLAGS="$CFLAGS_save"
        LDFLAGS="$LDFLAGS_save"
    ])
    if test "x$moz_nspr_libs" != "xno"; then
        have_nspr_libs="yes"
        NSPR_LDFLAGS="-L$with_nspr_libs $nsprlibs"
    else
        NSPR_CLFAGS=""
    fi
else
    AC_MSG_CHECKING(for Mozilla nspr4 libraries)
    AC_MSG_RESULT(no)
fi

AC_ARG_WITH(nss-includes, [  --with-nss-includes=PREFIX     Location of Mozilla nss3 includes.],
    with_nss_includes="$withval", with_nss_includes="/usr/include/mozilla")
have_nss_includes="no"
if test "x${with_nss_includes}" != "xno" -a "x${have_nspr_libs}" != "xno"; then
    CPPFLAGS_save="$CPPFLAGS"
    
    AC_MSG_CHECKING(for Mozilla nss3 includes in $with_nss_includes)
    AC_MSG_RESULT("")

        if test "x${with_nspr_includes}" != "x"; then
            CPPFLAGS="$CPPFLAGS -I$with_nspr_includes -I$with_nss_includes"
        else
            CPPFLAGS="$CPPFLAGS -I$with_nss_includes"
        fi

    AC_CHECK_HEADERS(nss.h ssl.h smime.h, [ moz_nspr_includes="yes" ])
    CPPFLAGS="$CPPFLAGS_save"
    
    if test "x{$moz_nss_includes}" != "xno" -a "x{$moz_nss_includes}" != "x"; then
        have_nss_includes="yes"
        NSS_CFLAGS="-I$with_nss_includes"
    else
        NSPR_CFLAGS=""
        NSPR_LDFLAGS=""
    fi
else
    AC_MSG_CHECKING(for Mozilla nss3 includes)
    AC_MSG_RESULT(no)
fi

AC_ARG_WITH(nss-libs, [  --with-nss-libs=PREFIX         Location of Mozilla nss3 libs.],
    with_nss_libs="$withval")
msg_nss="no"
if test "x${with_nss_libs}" != "xno" -a "x${have_nss_includes}" != "xno"; then
    LDFLAGS_save="$LDFLAGS"
    
    nsprlibs="-lnspr4 -lplc4 -lplds4 $PTHREAD_LIB"
    nsslibs="-lnss3 -lnssckbi -lssl3 -lsmime3"
    AC_CACHE_CHECK([for Mozilla nss libraries], moz_nss_libs,
    [
        LDFLAGS="$LDFLAGS -L$with_nspr_libs $nsprlibs -L$with_nss_libs $nsslibs"
        AC_TRY_LINK_FUNC(NSS_Init, moz_nss_libs="yes", moz_nss_libs="no")
        LDFLAGS="$LDFLAGS_save"
    ])
    if test "$moz_nss_libs" != no; then
        AC_DEFINE(HAVE_NSS)
        msg_nss="yes"
        NSS_LDFLAGS="-L$with_nss_libs $nsslibs"
    else
        NSS_CFLAGS=""
        NSPR_CFLAGS=""
        NSPR_LDFLAGS=""
    fi
else
    AC_MSG_CHECKING(for Mozilla nss libraries)
    AC_MSG_RESULT(no)
fi

AC_SUBST(NSPR_CFLAGS)
AC_SUBST(NSPR_LDFLAGS)
AC_SUBST(NSS_CFLAGS)
AC_SUBST(NSS_LDFLAGS)

dnl ====================================
dnl = End mozilla hacks
dnl ====================================

dnl ******************************
dnl OpenSSL
dnl ******************************

AC_ARG_WITH(openssl-includes, [  --with-openssl-includes=PREFIX     Location of OpenSSL includes.],
    with_openssl_includes="$withval", with_openssl_includes="/usr/include")
have_openssl_includes="no"
if test "x${with_openssl_includes}" != "xno"; then
    CPPFLAGS_save="$CPPFLAGS"
    
    AC_MSG_CHECKING(for OpenSSL includes)
    AC_MSG_RESULT("")
    
    CPPFLAGS="$CPPFLAGS -I$with_openssl_includes"
    AC_CHECK_HEADERS(openssl/ssl.h openssl/x509.h, [ openssl_includes="yes" ])
    CPPFLAGS="$CPPFLAGS_save"
    
    if test "x{$openssl_includes}" != "xno" -a "x{$openssl_includes}" != "x"; then
        have_openssl_includes="yes"
        OPENSSL_CFLAGS="-I$with_openssl_includes"
    else
        OPENSSL_CFLAGS=""
    fi
else
    AC_MSG_CHECKING(for OpenSSL includes)
    AC_MSG_RESULT(no)
fi

AC_ARG_WITH(openssl-libs, [  --with-openssl-libs=PREFIX         Location of OpenSSL libs.],
    with_openssl_libs="$withval")
msg_openssl="no"
if test "x${with_openssl_libs}" != "xno" -a "x${have_openssl_includes}" != "xno"; then
    LDFLAGS_save="$LDFLAGS"

    case $with_openssl_libs in
    ""|-L*) ;;
    *) $with_openssl_libs="-L$with_openssl_libs" ;;
    esac

    AC_CHECK_LIB(dl, dlopen, DL_LDFLAGS="-ldl", DL_LDFLAGS="")
    AC_CACHE_CHECK([for OpenSSL libraries], openssl_libs,
    [
        LDFLAGS="$LDFLAGS $with_openssl_libs -lssl -lcrypto $DL_LDFLAGS"
        AC_TRY_LINK_FUNC(SSL_read, openssl_libs="yes", openssl_libs="no")
        LDFLAGS="$LDFLAGS_save"
    ])
    if test "x${openssl_libs}" != "xno"; then
        AC_DEFINE(HAVE_OPENSSL)
        msg_openssl="yes"
        OPENSSL_LDFLAGS="$with_openssl_libs -lssl -lcrypto $DL_LDFLAGS"
    else
        OPENSSL_CFLAGS=""
        OPENSSL_LDFLAGS=""
    fi
else
    AC_MSG_CHECKING(for OpenSSL libraries)
    AC_MSG_RESULT(no)
fi

AC_SUBST(OPENSSL_CFLAGS)
AC_SUBST(OPENSSL_LDFLAGS)

dnl ******************************
dnl See if we have SSL support
dnl ******************************

if test "x${msg_nss}" != "xno" -o "x${msg_openssl}" != "xno"; then
    msg_ssl="yes"
    AC_DEFINE(HAVE_SSL)
else
    msg_ssl="no"
fi

dnl ******************************
dnl gtk-doc
dnl ******************************

AC_CHECK_PROG(GTKDOC, gtkdoc-mkdb, true, false)
AM_CONDITIONAL(HAVE_GTK_DOC, $GTKDOC)
AC_SUBST(HAVE_GTK_DOC)

dnl Let people disable the gtk-doc stuff.
AC_ARG_ENABLE(gtk-doc, [  --enable-gtk-doc  Use gtk-doc to build documentation [default=auto]], enable_gtk_doc="$enableval", enable_gtk_doc=auto)

if test x$enable_gtk_doc = xauto ; then
  if test x$GTKDOC = xtrue ; then
    enable_gtk_doc=yes
  else
    enable_gtk_doc=no
  fi
fi

dnl NOTE: We need to use a separate automake conditional for this
dnl       to make this work with the tarballs.
AM_CONDITIONAL(ENABLE_GTK_DOC, test x$enable_gtk_doc = xyes)

dnl ********
dnl movemail
dnl ********
AC_ARG_WITH(movemail, [  --with-movemail=PATH    Path to a movemail binary])
AC_MSG_CHECKING(for movemail)
if test x$with_movemail = xyes -o x$with_movemail = x; then
    with_movemail=no
fi
if test x$with_movemail != xno; then
    AC_DEFINE_UNQUOTED(MOVEMAIL_PATH, "$with_movemail")
    AC_MSG_RESULT($with_movemail)
else
    emacs_exec_dir=`emacs --batch --eval '(message exec-directory)' 2>&1`
    case $emacs_exec_dir in
    /*) if test -x $emacs_exec_dir/movemail; then
        if test -u $emacs_exec_dir/movemail -o -g $emacs_exec_dir/movemail; then
        AC_MSG_RESULT($emacs_exec_dir/movemail)
        AC_DEFINE_UNQUOTED(MOVEMAIL_PATH, "$emacs_exec_dir/movemail")
        else
        AC_MSG_RESULT($emacs_exec_dir/movemail... not set-id: ignored)
        fi
    else
        AC_MSG_RESULT(no)
    fi
    ;;
    *)
    AC_MSG_RESULT(no)
    ;;
    esac
fi

dnl
dnl Compose program
dnl
compose_libs="bonobo gnomeui"
COMPOSE_LIBS="`gnome-config --libs $compose_libs`"
COMPOSE_CFLAGS="`gnome-config --cflags $compose_libs`"
AC_SUBST(COMPOSE_LIBS)
AC_SUBST(COMPOSE_CFLAGS)

dnl ******************
dnl Sub-version number
dnl ******************
AC_ARG_WITH(sub-version, [  --with-sub-version=VERSION Specify a sub-version string])
AC_DEFINE_UNQUOTED(SUB_VERSION, "$with_sub_version")

dnl ******************************
dnl Makefiles
dnl ******************************

AC_CONFIG_SUBDIRS(libical)

EVOLUTION_DIR=`(cd $srcdir; pwd)`
AC_SUBST(EVOLUTION_DIR)

AC_OUTPUT([
Makefile
macros/Makefile
intl/Makefile
po/Makefile.in
e-util/Makefile
e-util/ename/Makefile
libibex/Makefile
my-evolution/Makefile
camel/Makefile
camel/providers/Makefile
camel/providers/pop3/Makefile
camel/providers/sendmail/Makefile
camel/providers/smtp/Makefile
camel/providers/imap/Makefile
camel/providers/nntp/Makefile
camel/providers/local/Makefile
camel/tests/Makefile
camel/tests/lib/Makefile
camel/tests/message/Makefile
camel/tests/misc/Makefile
camel/tests/folder/Makefile
camel/tests/smime/Makefile
camel/tests/stream/Makefile
composer/Makefile
widgets/Makefile
widgets/meeting-time-sel/Makefile
widgets/misc/Makefile
widgets/menus/Makefile
addressbook/Makefile
addressbook/conduit/Makefile
addressbook/contact-editor/Makefile
addressbook/printing/Makefile
addressbook/backend/Makefile
addressbook/backend/idl/Makefile
addressbook/backend/pas/Makefile
addressbook/backend/ebook/Makefile
addressbook/gui/Makefile
addressbook/gui/merging/Makefile
addressbook/gui/widgets/Makefile
addressbook/gui/search/Makefile
addressbook/gui/component/Makefile
addressbook/gui/component/select-names/Makefile
shell/Makefile
shell/glade/Makefile
shell/importer/Makefile
mail/Makefile
mail/importers/Makefile
data/Makefile
libversit/Makefile
libibex/Makefile
calendar/Makefile
calendar/idl/Makefile
calendar/cal-util/Makefile
calendar/cal-client/Makefile
calendar/pcs/Makefile
calendar/gui/Makefile
calendar/gui/alarm-notify/Makefile
calendar/gui/dialogs/Makefile
calendar/conduits/Makefile
calendar/conduits/calendar/Makefile
calendar/conduits/todo/Makefile
filter/Makefile
wombat/Makefile
composer/Makefile
importers/Makefile
art/Makefile
ui/Makefile
default_user/Makefile
default_user/local/Makefile
default_user/local/Calendar/Makefile
default_user/local/Contacts/Makefile
default_user/local/Drafts/Makefile
default_user/local/Inbox/Makefile
default_user/local/Outbox/Makefile
default_user/local/Sent/Makefile
default_user/local/Tasks/Makefile
default_user/local/Trash/Makefile
views/Makefile
views/addressbook/Makefile
views/mail/Makefile
views/tasks/Makefile
tools/Makefile
doc/Makefile
doc/C/Makefile
doc/devel/Makefile
doc/devel/calendar/Makefile
doc/devel/calendar/cal-client/Makefile
doc/devel/calendar/cal-util/Makefile
doc/devel/executive-summary/Makefile
])

if test "x$with_sub_version" != "x"; then
echo "
    Evolution ($with_sub_version) has been configured as follows: "
else
echo "
    Evolution has been configured as follows: "
fi

echo "
    Mail Directory:   $system_mail_dir
    LDAP support:     $msg_ldap
    NNTP support:     $msg_nntp
    Pilot conduits:   $msg_pilot
    Kerberos 4/5:     $msg_krb4/$msg_krb5
    SSL support:      $msg_ssl
    S/MIME support:   $msg_nss
    Use movemail:     $with_movemail
    Dot Locking:      $msg_dot
    File Locking:     $msg_file
    Gtk-doc:      $enable_gtk_doc"

if test x$enable_gtk_doc = xyes; then
echo "
    Programming documentation files will be built automatically.
"
else
echo "
    Programming documentation files will not be built.
    You may want to install the gtk-doc package
    so that you will get the Evolution Developer's Guide.
"
fi