File: configure.in

package info (click to toggle)
cherokee 0.7.2-4
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 8,808 kB
  • ctags: 6,577
  • sloc: ansic: 45,071; python: 9,628; sh: 9,468; makefile: 1,639; xml: 61; perl: 32
file content (1336 lines) | stat: -rw-r--r-- 35,586 bytes parent folder | download
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
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
dnl -*- mode: m4-mode -*-
dnl Process this file with autoconf to produce a configure script.

AC_COPYRIGHT([
Copyright (C) 2001-2008 Alvaro Lopez Ortega

This program is free software; you can redistribute it and/or
modify it under the terms of version 2 of the GNU General Public
License as published by the Free Software Foundation.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
])

dnl require autoconf 2.56
AC_PREREQ(2.56)

dnl Version
m4_define([cherokee_major_version], [0])
m4_define([cherokee_minor_version], [7])
m4_define([cherokee_micro_version], [2])
m4_define([cherokee_version], m4_format('%s.%s.%s', cherokee_major_version, cherokee_minor_version, cherokee_micro_version))

dnl Init autoconf and automake
AC_INIT([cherokee], [cherokee_version], [http://bugs.cherokee-project.com], [cherokee])
AC_CONFIG_SRCDIR([cherokee/server.c])
AM_INIT_AUTOMAKE([no-define])

dnl Define version
AC_DEFINE(PACKAGE_MAJOR_VERSION, "cherokee_major_version", [Version string])
AC_DEFINE(PACKAGE_MINOR_VERSION, "cherokee_minor_version", [Version string])
AC_DEFINE(PACKAGE_MICRO_VERSION, "cherokee_micro_version", [Version string])

PACKAGE_MAJOR_VERSION="cherokee_major_version"
PACKAGE_MINOR_VERSION="cherokee_minor_version"
PACKAGE_MICRO_VERSION="cherokee_micro_version"
AC_SUBST(PACKAGE_MAJOR_VERSION)
AC_SUBST(PACKAGE_MINOR_VERSION)
AC_SUBST(PACKAGE_MICRO_VERSION)

dnl Define library soname
CHEROKEE_AGE=0
CHEROKEE_CURRENT=0
CHEROKEE_REVISION=1
AC_SUBST(CHEROKEE_AGE)
AC_SUBST(CHEROKEE_CURRENT)
AC_SUBST(CHEROKEE_REVISION)

dnl Check the SVN revision
AC_ARG_ENABLE(beta, AC_HELP_STRING([--enable-beta], [Enable beta development]),
		    is_beta="$enableval", is_beta="no")

if test x"$is_beta" = "xyes"; then
  if test -d ".svn"; then
     svn_rev="`svn info -R | grep Revision | sort | tail -1 | sed 's/Revision: //'`";   
  fi

  PACKAGE_PATCH_VERSION="b$svn_rev"

  dnl Redefine versions
  PACKAGE_VERSION="$PACKAGE_MAJOR_VERSION.$PACKAGE_MINOR_VERSION.$PACKAGE_MICRO_VERSION$PACKAGE_PATCH_VERSION"
  AC_DEFINE_UNQUOTED(PACKAGE_VERSION, "${PACKAGE_VERSION}", [Package version])

  VERSION="$PACKAGE_MAJOR_VERSION.$PACKAGE_MINOR_VERSION.$PACKAGE_MICRO_VERSION$PACKAGE_PATCH_VERSION"
  AC_DEFINE(VERSION, $VERSION, [Software version])
else

  PACKAGE_PATCH_VERSION=""
fi

dnl Path version
AC_SUBST(PACKAGE_PATCH_VERSION)
AC_DEFINE_UNQUOTED(PACKAGE_PATCH_VERSION, "${PACKAGE_PATCH_VERSION}", [Version string])

dnl Initial CFLAGS
AC_MSG_CHECKING(initial CFLAGS)
AC_MSG_RESULT($CFLAGS)

dnl Check for CPU / vendor / OS
AC_CANONICAL_HOST

os_string="UNIX"
so_suffix=so
mod_suffix=$so_suffix

AC_MSG_CHECKING([host platform characteristics])
	case "$host" in
	*-*-mingw*|*-*-cygwin*)
		so_suffix=DLL
		mod_suffix=$so_suffix
	     os_string="Win32"
          libdl=
          ;;
	*-*-linux*)
          libdl="-ldl"
          ;;
	*-*-solaris*)
	     AC_DEFINE(SOLARIS, 1, [It is Solaris])	     
		setenv_is_threadsafe="yes"
          libdl="-ldl"
          ;;
	*-*-hpux*)
          libdl="-ldl"
          ;;
	*-*-*freebsd*|*-*-*openbsd*|*-*-*netbsd*|*-*-*dragonfly*)
          libdl=
          ;;
	*-*-darwin*)
		so_suffix=dylib
		mod_suffix=so
          libdl="-ldl"
          ;;
	*)
		AC_MSG_WARN([*** Please add $host to configure.in checks!])
          libdl="-ldl"
          ;;
esac
AC_MSG_RESULT(ok)

AC_MSG_CHECKING([L2 cache line size])
case "$host_cpu" in
	i386|i486)
		CPU_CACHE_LINE=32
	;;
	i586|i686)
		CPU_CACHE_LINE=64
	;;
	i786)	
		CPU_CACHE_LINE=128
	;;
	athlon)	
		CPU_CACHE_LINE=64
	;;
	x86_64)	
		CPU_CACHE_LINE=64
	;;
	sparc*)	
		CPU_CACHE_LINE=64
	;;
	powerpc)
		CPU_CACHE_LINE=128
	;;
	*)
		CPU_CACHE_LINE=128
	;;
esac
AC_DEFINE_UNQUOTED(CPU_CACHE_LINE, $CPU_CACHE_LINE, [L2 cache line size])
AC_MSG_RESULT($CPU_CACHE_LINE)

dnl
dnl OS string
dnl
AC_ARG_ENABLE(os_string, AC_HELP_STRING([--enable-os-string=STR], [Set a customized OS type string]), [os_string="$enableval"])
AC_DEFINE_UNQUOTED(OS_TYPE, "${os_string}", [OS type])

AM_CONDITIONAL(PLATFORM_WIN32, test x"$os_string" = "xWin32")

dnl
dnl Tracing
dnl
AC_ARG_ENABLE(trace, AC_HELP_STRING([--enable-trace], [Enable trace facility]), 
   [enable_trace="$enableval"
    AC_DEFINE(TRACE_ENABLED, 1, [Trace facility])
   ], [enable_trace="no"])


dnl
dnl Dynamic library loading library
dnl
LIBS="$LIBS $libdl"
AC_DEFINE_UNQUOTED(SO_SUFFIX, "${so_suffix}", [Dynamic loading libraries extension])
AC_DEFINE_UNQUOTED(MOD_SUFFIX, "${mod_suffix}", [Dynamic modules extension])

dnl
dnl Libtool options
dnl
if test "$os_string" != "Win32"; then
    # libtool option to control which symbols are exported
    # right now, symbols starting with _ are not exported
    LIBTOOL_EXPORT_OPTIONS='-export-symbols-regex "^[[^_]].*"'
else
    LIBTOOL_EXPORT_OPTIONS=
fi

AC_SUBST(LIBTOOL_EXPORT_OPTIONS)



AM_INIT_AUTOMAKE(cherokee, $VERSION)
AM_MAINTAINER_MODE

AM_CONFIG_HEADER(config.h)
AC_SUBST(VERSION)

AC_PATH_PROG(cherokeepath, cherokee)

AC_PROG_CC
AC_PROG_INSTALL
AC_PROG_MAKE_SET

AC_LIBTOOL_DLOPEN
AC_LIBTOOL_WIN32_DLL
AM_PROG_LIBTOOL

AC_FUNC_CLOSEDIR_VOID
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_FUNC_VPRINTF

AC_C_CONST
AC_C_BIGENDIAN
AC_C_INLINE
if test "$ac_cv_c_inline" != no; then
  AC_DEFINE(HAVE_INLINE, 1, [Compile supports inline])
fi

dnl
dnl Check for headers
dnl
AC_HEADER_STDC
AC_HEADER_DIRENT
AC_HEADER_TIME
AC_HEADER_SYS_WAIT

AC_CHECK_HEADERS(endian.h machine/endian.h sys/endian.h sys/isa_defs.h sys/utsname.h sys/poll.h poll.h )
AC_CHECK_HEADERS(sys/socket.h sys/un.h netinet/in.h arpa/inet.h netinet/tcp.h sys/ioctl.h fcntl.h sys/time.h)
AC_CHECK_HEADERS(sys/resource.h resource.h unistd.h syslog.h stdint.h inttypes.h error.h pwd.h sys/uio.h)
AC_CHECK_HEADERS(pthread.h netdb.h stdarg.h sys/filio.h sys/varargs.h sys/select.h sys/mman.h grp.h winsock.h)
AC_CHECK_HEADERS(winsock.h winsock2.h)

AC_SYS_LARGEFILE

AC_SIZE_T
AC_TYPE_SIGNAL
AC_TYPE_UID_T
AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_TYPE_PID_T
AC_STRUCT_ST_RDEV
AC_CHECK_TYPE(ino_t, unsigned)
AC_CHECK_TYPE(loff_t, off_t)
AC_CHECK_TYPE(offset_t, loff_t)
AC_CHECK_TYPE(ssize_t, int)
AC_CHECK_TYPE(wchar_t, unsigned short)

AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(unsigned int)
AC_CHECK_SIZEOF(unsigned long)
AC_CHECK_SIZEOF(unsigned long long)
AC_CHECK_SIZEOF(unsigned int)
AC_CHECK_SIZEOF(off_t)
AC_CHECK_SIZEOF(size_t)

AC_CACHE_CHECK([for long long],samba_cv_have_longlong,[
AC_TRY_RUN([#include <stdio.h>
main() { long long x = 1000000; x *= x; exit(((x/1000000) == 1000000)? 0: 1); }],
samba_cv_have_longlong=yes,samba_cv_have_longlong=no,samba_cv_have_longlong=cross)])
if test x"$samba_cv_have_longlong" = x"yes"; then
    AC_DEFINE(HAVE_LONGLONG,1,[Whether the host supports long long's])
fi

AC_FUNC_MEMCMP
AC_FUNC_MMAP

AC_CHECK_FUNCS(gmtime gmtime_r localtime localtime_r getrlimit getdtablesize readdir readdir_r flockfile funlockfile)

FW_CHECK_PWD
FW_CHECK_GRP

AC_CHECK_MEMBER(struct tm.tm_gmtoff,
                AC_DEFINE([HAVE_STRUCT_TM_GMTOFF],[1],[gmtoff in struct tm]),,[#include <time.h>])

AH_BOTTOM([
/* Give us an unsigned 32-bit data type. */
#if SIZEOF_UNSIGNED_LONG==4
#define UWORD32 unsigned long
#elif SIZEOF_UNSIGNED_INT==4
#define UWORD32 unsigned int
#else
#error I do not know what to use for a UWORD32.
#endif
])


dnl Find socket()
dnl Likely combinations:
dnl		-lsocket [ -lnsl_s | -lnsl ]
dnl		-linet
AC_CHECK_LIB(ws2_32, main)
AC_CHECK_LIB(wsock32, main)

AC_CHECK_FUNC(socket, :, [	
	AC_CHECK_LIB(socket, main)
	AC_CHECK_LIB(net, main)
	AC_CHECK_LIB(nsl_s, main)
	AC_CHECK_LIB(nsl, main)
	AC_CHECK_LIB(inet, socket)
	AC_CHECK_LIB(gen, main)
])

AC_SEARCH_LIBS(accept, socket)
AC_SEARCH_LIBS(bind, socket)
AC_SEARCH_LIBS(listen, socket)
AC_SEARCH_LIBS(setsockopt, socket)

dnl
dnl Check for fd events inspect functions
dnl
AC_CHECK_FUNC(poll, have_poll=yes)
AC_CHECK_FUNC(kqueue, have_kqueue=yes)
AC_CHECK_FUNC(select, have_select=yes)

if test "x-$have_select" != "x-yes" -a "x-$ac_cv_header_winsock2_h" = "x-yes"; then 
     AC_MSG_CHECKING([for select in ws2_32])
     AC_TRY_LINK([#include <winsock2.h>],
				[select(0,0,0,0,0)],
				[AC_MSG_RESULT(yes)
				 have_win32_select=yes],
				[AC_MSG_RESULT(no)])
fi

dnl
dnl Epoll
dnl
AC_CHECK_HEADER(sys/epoll.h, have_epoll_include=yes, have_epoll_include=no)

AC_ARG_ENABLE(epoll, AC_HELP_STRING([--disable-epoll],[Disable epoll() support]),
		    wants_epoll="$enableval", wants_epoll="yes")

have_epoll=no
if test "x$have_epoll_include" = "xyes" && test "x$wants_epoll" = "xyes"; then
 	AC_MSG_CHECKING(for epoll system call)

     AC_RUN_IFELSE([
		#include <stdint.h>
		#include <sys/param.h>
		#include <sys/types.h>
		#include <sys/syscall.h>
		#include <sys/epoll.h>
		#include <unistd.h>

		int epoll_create (int size) {
	        return (syscall(__NR_epoll_create, size));
		}
	
		int main (int argc, char **argv) {
	        int epfd;
	        epfd = epoll_create(256);
	    	   exit (epfd == -1 ? 1 : 0);
		}
	], 
	have_epoll=yes,
	have_epoll=no,
	have_epoll=yes)
	AC_MSG_RESULT($have_epoll)
fi

dnl
dnl Solaris 10: Event ports
dnl
AC_CHECK_HEADER(port.h, have_port_include=yes, have_port_include=no)

have_port=no
if test "x$have_port_include" = "xyes"; then
    	AC_MSG_CHECKING(for event ports support)

     AC_RUN_IFELSE([
		#include <stdint.h>
		#include <unistd.h>
		#include <port.h>
	
		int main (int argc, char **argv) {
	        int port;
		   port = port_create();
	    	   exit (port < 0 ? 1 : 0);
		}
	], 
	have_port=yes,
	have_port=no,
	have_port=cross)
	AC_MSG_RESULT($have_port)
fi



if test "$have_epoll" = yes; then
	AC_DEFINE(HAVE_EPOLL, 1, [Have epoll])
fi
AM_CONDITIONAL(COMPILE_EPOLL, test x"$have_epoll" = "xyes")

if test "$have_kqueue" = yes; then
	AC_DEFINE(HAVE_KQUEUE, 1, [Have kqueue])
fi
AM_CONDITIONAL(COMPILE_KQUEUE, test x"$have_kqueue" = "xyes")

if test "$have_port" = yes; then
	AC_DEFINE(HAVE_PORT, 1, [Have event ports])
fi
AM_CONDITIONAL(COMPILE_PORT, test x"$have_port" = "xyes")

if test "$have_poll" = yes; then
	AC_DEFINE(HAVE_POLL, 1, [Have poll])
fi
AM_CONDITIONAL(COMPILE_POLL, test x"$have_poll" = "xyes")

if test "$have_win32_select" = yes; then
	AC_DEFINE(HAVE_WIN32_SELECT, 1, [Have Win32 select])
fi
AM_CONDITIONAL(COMPILE_WIN32_SELECT, test x"$have_win32_select" = "xyes")

if test "$have_select" = yes; then
     AC_DEFINE(HAVE_SELECT, 1, [Have select])
fi
AM_CONDITIONAL(COMPILE_SELECT, test x"$have_select" = "xyes" -a x"$have_win32_select" != "xyes")


dnl
dnl Check for inet_pton.  We have our own, but on Solaris the version in
dnl libresolv is more lenient in ways that Solaris's internal DNS resolution
dnl code requires, so if we use our own *and* link with libresolv (which may
dnl be forced by Perl) DNS resolution fails.
dnl
AC_SEARCH_LIBS(inet_pton, [socket nsl resolv])
AC_CHECK_FUNCS(inet_pton inet_ntop inet_addr)

AC_SEARCH_LIBS(gethostbyname, [socket nsl resolv])
AC_CHECK_FUNCS(gethostbyname gethostbyname_r)

dnl
dnl Check for inet_addr
dnl
AC_SEARCH_LIBS(inet_addr, xnet) 
AC_CHECK_FUNCS(inet_addr)

dnl
dnl TCP_CORK
dnl
HYDRA_TCP_CORK

dnl
dnl Check for GNU getopt_long()
dnl
#AC_SEARCH_LIBS(getopt_long, [iberty gnugetopt])
AC_CHECK_HEADERS(getopt.h)
AC_CHECK_FUNC(getopt_long, have_getopt_long="yes")
AM_CONDITIONAL(HAVE_GETOPT_LONG, test x"$have_getopt_long" = "xyes")


dnl
dnl Pthread
dnl
with_pthread="yes"
have_pthread="no"
AC_ARG_ENABLE(pthread, AC_HELP_STRING([--disable-pthread],[Disable threading support]),
		    with_pthread="$enableval", with_pthread="yes")

AM_CONDITIONAL(USE_PTHREAD, test "x$with_pthread" = "xyes")
if test "x$with_pthread" = "xyes"
then
	dnl
     dnl Basic checkings (c&p'ed from squid)
	dnl
	AC_MSG_CHECKING([for special a pthread case])

	oldcflags="$CFLAGS"
     CFLAGS="$CFLAGS -D_REENTRANT"
	PTHREAD_CFLAGS="-D_REENTRANT"

	case "$host" in
    	   i386-unknown-freebsd*)
           if test "$GCC" = "yes" ; then
              if test -z "$PRESET_LDFLAGS"; then
                PTHREAD_LIBS="-pthread"
			 have_pthread="yes"
              fi
           fi
		 AC_MSG_RESULT([-pthread])
           ;;
       *-solaris2.*)
           if test "$GCC" = "yes" ; then
              CFLAGS="$CFLAGS -pthreads"
              PTHREAD_CFLAGS="-pthreads"
		    AC_MSG_RESULT([-pthreads])
           else
              CFLAGS="$CFLAGS -mt"
              PTHREAD_CFLAGS="-mt"
		    AC_MSG_RESULT([-mt])
           fi
	      have_pthread="yes"
           ;;
	  *)
		 AC_MSG_RESULT([no])
 		 ;;
     esac

	if test "$have_pthread" != "yes"; then
        AC_CHECK_LIB(pthread, main, have_pthread=yes, have_pthread=no)
	   if test "$have_pthread" = "yes"; then
	   	 PTHREAD_LIBS="-lpthread"   
	   fi
     fi

	dnl
	dnl More detailed checks on the pthread support
	dnl
	AC_MSG_CHECKING([for pthread_rwlock_t support])

	have_pthread_rwlock_t=yes
	AC_TRY_COMPILE([#include <pthread.h>],
			[pthread_rwlock_t rwlock; pthread_rwlock_init( &rwlock, NULL);],
			compiled=yes, compiled=no)

	if test "$compiled" = "yes"; then
	   	AC_MSG_RESULT([ok])
	else
	     dnl Didn't find rwlock_t. 
	     dnl Try defining _XOPEN_SOURCE=500
	     dnl
		oldcflags2="$CFLAGS"
		CFLAGS="$CFLAGS -D_XOPEN_SOURCE=500"

		AC_TRY_COMPILE([#include <pthread.h>], 
			    [pthread_rwlock_t rwlock; pthread_rwlock_init( &rwlock, NULL);],
			    compiled=yes, compiled=no)

		if test "$compiled" = "yes"; then
		    AC_MSG_RESULT([-D_XOPEN_SOURCE=500])
		    PTHREAD_CFLAGS="-D_XOPEN_SOURCE=500"
		else
		    have_pthread_rwlock_t=no
		    AC_MSG_RESULT([no])
		fi

		CFLAGS="$oldcflags2"
	fi

	if test "$have_pthread_rwlock_t" = "yes"; then
		AC_DEFINE(HAVE_PTHREAD_RWLOCK_T, 1, [Define if your pthread library includes pthread_rwlock_t])
	else
		AC_MSG_ERROR([pthread_rwlock_t support missing])
	fi

	AC_CHECK_FUNC(pthread_attr_setschedpolicy, have_pthread_attr_setschedpolicy=yes)
	if test x"$have_pthread_attr_setschedpolicy" = "xyes"; then
	     AC_DEFINE(HAVE_PTHREAD_SETSCHEDPOLICY, 1, [Pthread support pthread_attr_setschedpolicy])
	fi

	CFLAGS="$oldcflags"
fi

if test "$have_pthread" = "yes"; then
	AC_DEFINE(HAVE_PTHREAD, 1, [Have pthread support])
	AC_SUBST(PTHREAD_CFLAGS)
	AC_SUBST(PTHREAD_LIBS)
fi

dnl
dnl Is setenv() threadsafe?
dnl
if test "$setenv_is_threadsafe" = "yes"; then
AC_DEFINE(SETENV_IS_THREADSAFE, 1, [setenv function is thread safe])
fi

dnl
dnl Check for vsyslog
dnl
AC_CHECK_FUNCS(syslog vsyslog strsep strcasestr memmove strerror bcopy strlcat)

dnl
dnl Check for Glib (usually Linux)
dnl
AC_PREPROC_IFELSE([
#include <features.h>
#ifndef __GLIBC__
    chokeme
#endif
], [
    AC_DEFINE([HAVE_GLIBC], [1], [Define to 1 if you have glibc.])
    AC_DEFINE([_GNU_SOURCE], [1], [Define to 1 if you have glibc.])
])

dnl
dnl Does this platform require array notation to assign to a va_list?
dnl If cross-compiling, we assume va_list is "normal".  If this breaks
dnl you, set ac_cv_valistisarray=true and maybe define HAVE_VA_LIST_AS_ARRAY
dnl also just to be sure.
dnl
AC_MSG_CHECKING(whether va_list assignments need array notation)
AC_CACHE_VAL(ac_cv_valistisarray,
        [AC_TRY_RUN([#include <stdlib.h>
		     #include <stdarg.h>
		     void foo(int i, ...) {
			va_list ap1, ap2;
			va_start(ap1, i);
			ap2 = ap1;
			if (va_arg(ap2, int) != 123 || va_arg(ap1, int) != 123) { exit(1); }
			va_end(ap1); va_end(ap2);
		     }
		     int main()
		     { foo(0, 123); return(0); }],
		    [ac_cv_valistisarray=false],
		    [ac_cv_valistisarray=true],
		    [ac_cv_valistisarray=false])])
					     
if test "$ac_cv_valistisarray" = true ; then
	AC_DEFINE(HAVE_VA_LIST_AS_ARRAY,,[va_list works copying an array])
	AC_MSG_RESULT(yes)
else
	AC_MSG_RESULT(no)
fi


dnl
dnl Check if the global variable `timezone' exists. If so, define
dnl HAVE_INT_TIMEZONE.
dnl
AC_STRUCT_TIMEZONE

AC_MSG_CHECKING(for global timezone)
AC_TRY_LINK([#include <time.h>],
[int res; res = timezone / 60;],
[AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_INT_TIMEZONE,, [Set to 1 if you have the global variable timezone])],
AC_MSG_RESULT(no))


dnl
dnl Check for RTDL constants (from Haskell code)
dnl
dnl ** check for libdl & RTLD_NEXT
dnl ** sometimes RTLD_NEXT is hidden in #ifdefs we really don't wan to set
AC_MSG_CHECKING(for RTLD_NEXT from dlfcn.h)
AC_EGREP_CPP(yes,
[
 #include <dlfcn.h>
 #ifdef RTLD_NEXT
        yes
 #endif
], [
  AC_MSG_RESULT(yes)
  AC_DEFINE(HAVE_RTLDNEXT,,[Have RTDL_NEXT])
  HaveRtldNext=YES
], [
  AC_MSG_RESULT(no)
  HaveRtldNext=NO
  ])    
AC_SUBST(HaveRtldNext)

dnl ** RTLD_LOCAL isn't available on cygwin or openbsd
AC_MSG_CHECKING(for RTLD_LOCAL from dlfcn.h)
AC_EGREP_CPP(yes,
[
 #include <dlfcn.h>
 #ifdef RTLD_LOCAL
        yes
 #endif
], [
  AC_MSG_RESULT(yes)
  AC_DEFINE(HAVE_RTLDLOCAL,,[Have RTDL_LOCAL])
  HaveRtldLocal=YES
], [
  AC_MSG_RESULT(no)
  HaveRtldLocal=NO
  ])    
AC_SUBST(HaveRtldLocal)

dnl ** RTLD_GLOBAL isn't available on openbsd
AC_MSG_CHECKING(for RTLD_GLOBAL from dlfcn.h)
AC_EGREP_CPP(yes,
[
 #include <dlfcn.h>
 #ifdef RTLD_GLOBAL
        yes
 #endif
], [
  AC_MSG_RESULT(yes)
  AC_DEFINE(HAVE_RTLDGLOBAL,,[Have RTDL_GLOBAL])
  HaveRtldGlobal=YES
], [
  AC_MSG_RESULT(no)
  HaveRtldGlobal=NO
  ])    
AC_SUBST(HaveRtldGlobal)

dnl ** RTLD_NOW isn't available on openbsd
AC_MSG_CHECKING(for RTLD_NOW from dlfcn.h)
AC_EGREP_CPP(yes,
[
 #include <dlfcn.h>
 #ifdef RTLD_NOW
        yes
 #endif
], [
  AC_MSG_RESULT(yes)
  AC_DEFINE(HAVE_RTLDNOW,,[Have RTDL_NOW])
  HaveRtldNow=YES
], [
  AC_MSG_RESULT(no)
  HaveRtldNow=NO
  ])    
AC_SUBST(HaveRtldNow)


dnl
dnl Check of off64_t
dnl
AC_CACHE_CHECK([for off64_t],samba_cv_HAVE_OFF64_T,[
AC_TRY_RUN([
#if defined(HAVE_UNISTD_H)
#include <unistd.h>
#endif
#include <stdio.h>
#include <sys/stat.h>
main() { struct stat64 st; off64_t s; if (sizeof(off_t) == sizeof(off64_t)) exit(1); exit((lstat64("/dev/null", &st)==0)?0:1); }],
samba_cv_HAVE_OFF64_T=yes,samba_cv_HAVE_OFF64_T=no,samba_cv_HAVE_OFF64_T=cross)])
if test x"$samba_cv_HAVE_OFF64_T" = x"yes"; then
    AC_DEFINE(HAVE_OFF64_T,1,[Whether off64_t is available])
fi


# From etr_socket_nsl.m4
ETR_SOCKET_NSL

# From sendfile_samba.m4
SENDFILE_CHECK

# readdir_r()
LIBWWW_READDIR_R_TYPE


dnl
dnl IPv6 Support
dnl I got this mostly from Apache's tests
dnl

AC_ARG_ENABLE(ipv6,
  AC_HELP_STRING([--disable-ipv6], [Disable IPv6 support]),
  [ if test "$enableval" = "no"; then
       disabled_ipv6=1
    fi ],
  [ disabled_ipv6=0 ] )

AC_SEARCH_LIBS(getaddrinfo, socket inet6)
AC_SEARCH_LIBS(getnameinfo, socket inet6)
AC_SEARCH_LIBS(gai_strerror, socket inet6)
AC_CHECK_FUNC(gai_strerror)

APR_CHECK_WORKING_GETADDRINFO
APR_CHECK_WORKING_GETNAMEINFO

AC_ACME_SOCKADDR_UN
AC_ACME_SOCKADDR_IN6
AC_ACME_SOCKADDR_STORAGE

AC_MSG_CHECKING(if the system supports IPv6)
have_ipv6="no"

if test "$disabled_ipv6" = 1; then
    AC_MSG_RESULT([no -- disabled by user])
else
    if test "x$ac_cv_acme_sockaddr_in6" = "xyes"; then
        if test "x$ac_cv_working_getaddrinfo" = "xyes"; then
            if test "x$ac_cv_working_getnameinfo" = "xyes"; then
                have_ipv6="yes"
                AC_MSG_RESULT([yes])
 		      AC_DEFINE(HAVE_IPV6, 1, [Define if you have IPv6 support.])
            else
                AC_MSG_RESULT([no -- no getnameinfo])
            fi
        else
            AC_MSG_RESULT([no -- no working getaddrinfo])
        fi
    else
        AC_MSG_RESULT([no -- no sockaddr_in6])
    fi
fi

dnl 
dnl Test whether SO_RCVTIMEO is broken
dnl 
AC_CACHE_CHECK([whether setsockopt(SO_RCVTIMEO) is broken],
  ac_cv_so_rcvtimeo_broken, [dnl
    AC_RUN_IFELSE([AC_LANG_SOURCE([[
#if defined(HAVE_SYS_TYPES_H)
#include <sys/types.h>
#endif

#if defined(HAVE_SYS_SOCKET_H)
#include <sys/socket.h>
#endif

#if defined(HAVE_SYS_TIME_H)
#include <sys/time.h>
#endif

int main(void) {
        int fd;
        int ret;
        struct timeval new_tv;

        /* Open the socket (INET/TCP).*/
        fd = socket(AF_INET, SOCK_STREAM, 0);

        /* set the timeout for the incoming queue */
        /* 1 second for example */
        new_tv.tv_sec = 1;
        new_tv.tv_usec = 0;

        ret = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &new_tv, sizeof(new_tv)); 
        return ret;
}
]])],[ac_cv_so_rcvtimeo_broken=no],[ac_cv_so_rcvtimeo_broken=yes],[ac_cv_so_rcvtimeo_broken=cross])])
if test x"$ac_cv_so_rcvtimeo_broken" = x"yes"; then
  AC_DEFINE(HAVE_BROKEN_SO_RCVTIMEO, 1, [Define if setsockopt(SO_RCVTIMEO) is broken])
fi


dnl
dnl Look for socklen_t
dnl
AC_MSG_CHECKING([for socklen_t])
AC_TRY_COMPILE(
 [#include <sys/types.h>
  #include <sys/socket.h>],
 [socklen_t len = 42; return 0;],
 ac_cv_type_socklen_t=yes,
 ac_cv_type_socklen_t=no
)

if test $ac_cv_type_socklen_t != yes; then
  AC_DEFINE(socklen_t, int, [Substitute for socklen_t])
  AC_MSG_RESULT(int)
else
  AC_MSG_RESULT(yes)
fi

dnl
dnl Check of __func__ and co..
dnl
AC_MSG_CHECKING([whether our compiler supports __func__])
AC_TRY_COMPILE([],
 [const char *cp = __func__;],
 AC_MSG_RESULT([yes]),
 AC_MSG_RESULT([no])
 AC_MSG_CHECKING([whether our compiler supports __FUNCTION__])
 AC_TRY_COMPILE([],
   [const char *cp = __FUNCTION__;],
   AC_MSG_RESULT([yes])
   AC_DEFINE(__func__, __FUNCTION__,
         [Define to appropriate substitue if compiler doesnt have __func__]),
   AC_MSG_RESULT([no])
   AC_DEFINE(__func__, __FILE__,
         [Define to appropriate substitue if compiler doesnt have __func__])))

dnl
dnl Check for pcre library
dnl
have_pcre="built-in"

AC_ARG_ENABLE(internal_pcre, 
		    AC_HELP_STRING([--enable-internal-pcre],[Enable internal PCRE]), 
		    use_internal_pcre="$enableval", use_internal_pcre="no")

if test "x$use_internal_pcre" != "xyes"; then
  AC_CHECK_LIB(pcre, pcre_compile, have_pcre_lib=yes, have_pcre_lib=no)
  AC_CHECK_HEADER(pcre.h, have_pcre_include=yes, have_pcre_include=no)
  if test "$have_pcre_lib $have_pcre_include" = "yes yes"; then
     have_pcre="yes"
  fi
fi

AM_CONDITIONAL(USE_INTERNAL_PCRE, test $have_pcre = "built-in")

dnl
dnl PAM
dnl
AC_ARG_ENABLE(pam, AC_HELP_STRING([--disable-pam],[Disable PAM support]), use_pam="$enableval", use_pam="yes")
if test "x$use_pam" = "xyes"; then
     AC_CHECK_LIB(pam, pam_start, have_pam_lib=yes, have_pam_lib=no)
     AC_CHECK_LIB(pam, _pam_dispatch, have_pam_dispatch=yes, have_pam_dispatch=no)
     AC_CHECK_HEADER(security/pam_modules.h, have_pam_include=yes, have_pam_include=no)
     AC_CHECK_HEADERS(security/_pam_macros.h security/pam_appl.h)
fi

if test "$use_pam $have_pam_lib $have_pam_include" = "yes yes yes"; then
   have_pam="yes"
else
   have_pam="no"
fi
AM_CONDITIONAL(HAVE_PAM, test "x$have_pam" = "xyes")

if test "$have_pam_dispatch" = "yes"; then
	AC_DEFINE(HAVE_PAM_DISPATCH, 1, [Have _pam_dispatch function])
fi

dnl
dnl crypt()
dnl
AC_CHECK_HEADERS(crypt.h)

AC_CHECK_FUNC(crypt, system_crypt="yes", system_crypt="no")
AC_CHECK_LIB(crypt, crypt, have_crypt_lib="yes", have_crypt_lib="no")
if test "x$have_crypt_lib" = "xyes"; then
	CRYPT_LIBS="-lcrypt"
	AC_SUBST(CRYPT_LIBS)
fi

use_crypt="no"
if test "$system_crypt $have_crypt_lib" != "no no"; then
   use_crypt="yes"
   AC_DEFINE(HAVE_CRYPT, 1, [Have crypt function])
fi

dnl
dnl crypt_r()
dnl
AC_CHECK_FUNC(crypt_r, system_crypt_r="yes", system_crypt_r="no")
AC_CHECK_LIB(crypt, crypt_r, have_crypt_r_lib="yes", have_crypt_r_lib="no")

use_crypt_r="no"
if test "$system_crypt_r $have_crypt_r_lib" != "no no"; then
   use_crypt_r="yes"
   AC_DEFINE(HAVE_CRYPT_R, 1, [Have crypt_r function])
fi

dnl
dnl crypt_r and pthread 
dnl
if test "$use_crypt_r" = "yes"; then
	dnl
	dnl struct crypt_data
	dnl
	oldcflags="$CFLAGS"
	CFLAGS="$CFLAGS -D_GNU_SOURCE"

	AC_MSG_CHECKING([for struct crypt_data])
	AC_TRY_COMPILE([#include <crypt.h>], 
				[struct crypt_data data;]
			    ,
				AC_MSG_RESULT([-D_GNU_SOURCE])
				CRYPT_CFLAGS="-D_GNU_SOURCE"
				AC_SUBST(CRYPT_CFLAGS)
			    ,
				AC_MSG_ERROR([struct crypt_data is not known]))

	CFLAGS="$oldcflags"
fi

AM_CONDITIONAL(USE_CRYPT, test "x$use_crypt x$use_crypt_r" != "xno xno")


dnl
dnl SSL and TLS
dnl
AC_ARG_ENABLE([tls], 
[AC_HELP_STRING([--disable-tls],[Disable TLS/SSL support])
AC_HELP_STRING([--enable-tls=[gnutls|openssl]])],
		    enable_tls="$enableval", enable_tls="undef")

case "$enable_tls" in
	no)
		check_gnutls=no
		check_openssl=no
		;;
	undef|yes)
		check_gnutls=yes
		check_openssl=yes
		;;
	gnu*)
		check_gnutls=yes
		check_openssl=no
		;;
	open*)
		check_gnutls=no
		check_openssl=yes
		;;	
	*)
		AC_MSG_ERROR([Incorrect TLS library])
		;;
esac

have_tls="no"

if test "$check_gnutls" = "yes"  && test "$have_tls" = "no"
then
		dnl
		dnl GNUTLS
		dnl
		PKG_CHECK_MODULES(GNUTLS, gnutls >= "1.0.4", [have_gnutls=yes], [have_gnutls=no])
		if test "$have_gnutls" = "yes"
		then
			   TLS_LIBS="$GNUTLS_LIBS"
			   TLS_CFLAGS="$GNUTLS_CFLAGS"

			   AC_CHECK_LIB(gcrypt, gcry_control, [TLS_LIBS="$TLS_LIBS -lgcrypt"])
			   AC_CHECK_LIB(gpg-error, gpg_strerror, [TLS_LIBS="$TLS_LIBS -lgpg-error"])

			   AC_SUBST(TLS_LIBS)
			   AC_SUBST(TLS_CFLAGS)

			   AC_DEFINE(HAVE_TLS, 1, [Have TLS support])
			   AC_DEFINE(HAVE_GNUTLS, 1, [Have libgnutls])
			   have_tls="gnutls"
		else
			   enable_tls=no
		fi
fi

if test "$check_openssl" = "yes" && test "$have_tls" = "no"
then
		dnl
		dnl OpenSSL
		dnl
		AC_CHECK_LIB(crypto, BN_init)

		AC_CHECK_HEADERS([openssl/engine.h])
		AC_CHECK_LIB(ssl, SSL_accept, [have_openssl=yes], [have_openssl=no])
		if test "$have_openssl" = "yes"
		then
			TLS_LIBS="-lssl"
			AC_SUBST(TLS_LIBS)

			AC_DEFINE(HAVE_TLS, 1, [Have TLS support])
			AC_DEFINE(HAVE_OPENSSL, 1, [Have OpenSSL library])
			have_tls="openssl"
		else
			enable_tls=no
		fi
fi

dnl
dnl LDAP
dnl
AC_ARG_WITH([ldap],
        AC_HELP_STRING([--with-ldap=@<:@ARG@:>@],
            [use OpenLDAP development library @<:@default=yes@:>@, optionally specify path to dev libs]
        ),
        [
        if test "$withval" = "no"; then
            want_ldap="no"
        elif test "$withval" = "yes"; then
            want_ldap="yes"
        else
            want_ldap="yes"
            LDAP_CONFIG="$withval"
        fi
        ],
        [want_ldap="yes"]
)

if test "$want_ldap" = "yes"; then
       AC_CHECK_LIB(ldap, ldap_init, have_ldap_lib=yes, have_ldap_lib=no)
       AC_CHECK_HEADER(ldap.h, have_ldap_include=yes, have_ldap_include=no)

	  AC_CHECK_LIB(ldap, ldap_start_tls_s, [
		AC_DEFINE(LDAP_HAVE_START_TLS_S,, Define if you have ldap_start_tls_s)
  	  ])

       if test "$have_ldap_lib $have_ldap_include" = "yes yes"; then
          have_ldap="yes"
       else
          have_ldap="no"
       fi
else
       have_ldap="no"
fi

AM_CONDITIONAL(HAVE_LDAP, test $have_ldap = "yes")


dnl
dnl Check for MySQL 4.0.0 support
dnl
AX_LIB_MYSQL(4.0.0)

dnl
dnl Python's docutils
dnl 
AC_MSG_CHECKING([for Python's docutils])
if python -c "import docutils" >/dev/null 2>/dev/null; then
  docutils_found=yes
else
  docutils_found=no
fi
AM_CONDITIONAL(PYTHON_DOCUTILS, test "x$docutils_found" = "xyes")
AC_MSG_RESULT([$docutils_found])

if test "x$docutils_found" != "xyes"; then
  echo
  echo "*WARNING*: Python module docutils is not installed!"
  echo "           It will not be able to generate the documentation."
  echo
fi

dnl
dnl WWW root directory
dnl
AC_ARG_WITH(wwwroot, AC_HELP_STRING([--with-wwwroot=DIR], [Set the WWW root directory]),
		  WWW_ROOT="$withval", WWW_ROOT="$localstatedir/www")

AC_SUBST(WWW_ROOT)


dnl
dnl Look for misc binaries
dnl
AC_PATH_PROG(PHPCGI, php-cgi)
AC_ARG_VAR(PHPCGI, [path to PHP-cgi])

AC_MSG_CHECKING([$PHPCGI supports FastCGI])
if test "x$PHPCGI" = "x"; then
   AC_MSG_RESULT([no])
else
   $PHPCGI -v | grep 'cgi-fcgi' >/dev/null 2>/dev/null
   if test $? != 0; then
      PHPCGI=""
      AC_MSG_RESULT([no])
   else
      AC_MSG_RESULT([yes])
   fi
fi

if test "x$PHPCGI" = "x"; then
   for n in php-cgi php; do
     for p in /usr/lib/cgi-bin /usr/bin /usr/local/bin; do
       phpcgi_path="$p/php-cgi"
	  AC_MSG_CHECKING([for $phpcgi_path])
	  if test -x "$phpcgi_path"; then
	     $phpcgi_path -v | grep 'cgi-fcgi' >/dev/null 2>/dev/null
		if test $? = 0; then
		  PHPCGI=$phpcgi_path
	       AC_MSG_RESULT([yes])
		else
	       AC_MSG_RESULT([not fcgi])
		fi
		break
	  else
	     AC_MSG_RESULT([no])
	  fi
     done
	if test "x$PHPCGI" != x; then
	  break;
	fi
   done
fi

if test "x$PHPCGI" = "x"; then
   PHPCGI="php-cgi"
fi

AC_SUBST(PHPCGI)


dnl
dnl Options
dnl
use_static_module=""
AC_ARG_ENABLE(static-module,
	   AC_HELP_STRING([--enable-static-module=MODULE][]),
	   [use_static_module="$use_static_module $enableval "],[])

modules="error_redir server_info file admin dirlist fcgi fastcgi scgi redir common nn cgi phpcgi mirror gzip ncsa combined w3c pam ldap mysql htpasswd plain htdigest round_robin directory extensions request header not and or"

# Remove modules that will not be compiles
#
if test "x$have_pam" != "xyes"; then
	modules=`echo $modules | sed s/pam//`
fi
if test "x$have_ldap" != "xyes"; then
	modules=`echo $modules | sed s/ldap//`
fi
if test "x$have_mysql" != "xyes"; then
	modules=`echo $modules | sed s/mysql//`
fi
if test "$use_crypt" != "yes"; then
	modules=`echo $modules | sed s/htpasswd//`
fi

add_calls=""
init_calls=""
headers=""
ext_defs=""

for mod in $modules; do
	AC_MSG_CHECKING([module "$mod"])

	if echo $use_static_module | grep -w $mod >/dev/null || echo $use_static_module | grep all >/dev/null; then
		 ext_defs="$ext_defs \n extern cherokee_plugin_info_t cherokee_${mod}_info;"

		 headers="$headers \n void PLUGIN_INIT_NAME($mod) (cherokee_plugin_loader_t *loader);"
		 add_calls="$add_calls \n add_static_entry (loader, \"$mod\", PLUGIN_INFO_PTR($mod));"
		 init_calls="$init_calls \n PLUGIN_INIT_NAME($mod)(loader);"

	      AC_MSG_RESULT([static])
	else
	      AC_MSG_RESULT([dynamic])
	fi
done

AC_MSG_CHECKING([loader.autoconf files])
printf "$ext_defs\n"                                 > ${srcdir}/cherokee/loader.autoconf.h
printf "$headers \n\n $add_calls \n\n $init_calls\n" > ${srcdir}/cherokee/loader.autoconf.inc
AC_MSG_RESULT([done])

dnl
dnl Static/Dynamic modules
dnl
conf_h="${srcdir}/cherokee/loader.autoconf.h"
AM_CONDITIONAL(STATIC_HANDLER_SERVER_INFO,    grep server_info    $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_HANDLER_FILE,           grep file           $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_HANDLER_ADMIN,          grep admin          $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_HANDLER_DIRLIST,        grep dirlist        $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_HANDLER_FCGI,           grep fcgi           $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_HANDLER_FASTCGI,        grep fastcgi        $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_HANDLER_SCGI,           grep scgi           $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_HANDLER_REDIR,          grep redir          $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_HANDLER_ERROR_REDIR,    grep redir          $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_HANDLER_COMMON,         grep common         $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_HANDLER_NN,             grep nn             $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_HANDLER_CGI,            grep cgi            $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_HANDLER_PHPCGI,         grep phpcgi         $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_HANDLER_MIRROR,         grep mirror         $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_ENCODER_GZIP,           grep gzip           $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_LOGGER_NCSA,            grep ncsa           $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_LOGGER_COMBINED,        grep combined       $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_LOGGER_W3C,             grep w3c            $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_VALIDATOR_PAM,          grep pam            $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_VALIDATOR_LDAP,         grep ldap           $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_VALIDATOR_MYSQL,        grep mysql          $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_VALIDATOR_HTPASSWD,     grep htpasswd       $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_VALIDATOR_PLAIN,        grep plain          $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_VALIDATOR_HTDIGEST,     grep htdigest       $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_BALANCER_ROUND_ROBIN,   grep round_robin    $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_RULE_DIRECTORY,         grep directory      $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_RULE_EXTENSIONS,        grep extensions     $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_RULE_REQUEST,           grep request        $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_RULE_HEADER,            grep header         $conf_h >/dev/null)
# These must be at the end
AM_CONDITIONAL(STATIC_RULE_NOT,               grep _not_          $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_RULE_AND,               grep _and_          $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_RULE_OR,                grep _or_           $conf_h >/dev/null)

AC_OUTPUT([
Makefile 
cget/Makefile 
cherokee-config
cherokee.pc
cherokee.spec
cherokee/Makefile 
cherokee/Makefile.MingW 
contrib/Makefile 
icons/Makefile
m4/Makefile 
qa/Makefile
doc/Makefile
themes/Makefile 
themes/default/Makefile 
themes/firefox3/Makefile 
windows/Makefile
windows/cherokee.nsi
www/Makefile 
admin/Makefile
admin/static/Makefile
admin/static/js/Makefile
admin/static/css/Makefile
admin/static/images/Makefile
])


methods=""
if test "$have_epoll"        = yes; then methods="${methods}epoll ";  fi
if test "$have_kqueue"       = yes; then methods="${methods}kqueue "; fi
if test "$have_poll"         = yes; then methods="${methods}poll ";   fi
if test "$have_port"         = yes; then methods="${methods}port ";   fi
if test "$have_win32_select" = yes; then methods="${methods}win32 ";  fi
if test "$have_select"       = yes; then methods="${methods}select";  fi

if test "$use_crypt_r" = "yes"; then
	crypt_type="multithread"
elif test "$use_crypt" = "yes"; then
	crypt_type="single thread"
else
	crypt_type="no"
fi

echo
echo ============================
echo "Install prefix        $prefix"
echo "cflags                $CFLAGS"
echo "trace                 $enable_trace"
echo "sendfile()            $with_sendfile_support"
echo "IPv6 support          $have_ipv6"
i=1
for m in $methods; do
	echo "Polling method $i      $m"
	i=`expr $i + 1`
done
echo "Threading support     $have_pthread"
echo "TLS support           $have_tls"
echo "PCRE library          $have_pcre"
echo "Compatible PAM        $have_pam"
echo "LDAP                  $have_ldap"
echo "MySQL                 $have_mysql"
echo "crypt support         $crypt_type"
if test "x$is_beta" = "xyes"; then
echo "Beta release          $svn_rev"
fi
echo
eval eval echo "Installation dir      $bindir"
echo ============================
echo
if test "x$cherokeepath" != "x" ; then
	echo Warning: You have an old copy of Cherokee at $cherokeepath.
	echo	
fi

cat <<THEEND
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the GPL License, available in this     |
| distribution in the file COPYING.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+

Thank you for using Cherokee.
THEEND