forked from DALnet/bahamut
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.in
762 lines (699 loc) · 25.4 KB
/
configure.in
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
dnl Process this file with autoconf to produce a configure script.
dnl rewritten for my own personal sanity, and for more extensive
dnl checks - feb04 -epi
AC_INIT
AC_CONFIG_HEADER(include/setup.h)
PACKAGE=bahamut-release
VERSION=1.8
AC_SUBST(PACKAGE)
AC_SUBST(VERSION)
# autoheader templates
AH_TEMPLATE([BROKEN_FD_SETSIZE],[If on a system with a broken FD_SETSIZE])
AH_TEMPLATE([HAVE_ENCRYPTION_ON],[If we support encryption])
AH_TEMPLATE([HAVE_MINMAX],[If we have the MIN and MAX macros])
AH_TEMPLATE([OS_SOLARIS2],[If we're running on Solaris])
AH_TEMPLATE([OS_SOLARIS],[Not quite sure why we have two of these])
AH_TEMPLATE([SYS_ERRLIST_DECLARED],[If the sys_errlist array is defined])
AH_TEMPLATE([USE_HOOKMODULES],[Do we support loadable modules])
AH_TEMPLATE([MAXCONNECTIONS],[Maximum Connections we allow])
AH_TEMPLATE([NEED_EPOLL_DEFS],[epoll behavior])
AH_TEMPLATE([AIX],[AIX support])
AH_TEMPLATE([WRITEV_IOV],[Maxmimum number of iovecs supported by writev()])
dnl Put our options of here for ease of reading.
AC_ARG_ENABLE(hookmodules,
[ --disable-hookmodules disable support for loadable hook modules],,
[ check_hmodules="yes" ])
AC_ARG_ENABLE(openssl,
[ --enable-openssl[=DIR] Enable OpenSSL support (DIR optional).
--disable-openssl Disable OpenSSL support. ],
[ cf_enable_openssl=$enableval ],
[ cf_enable_openssl="auto" ])
AC_ARG_WITH(socketengine,
[ --with-socketengine=TYPE Set the socketengine type. Choices are:
kqueue poll select ],
[ check_sengine=$withval ],
[ check_sengine="yes" ])
AC_ARG_WITH(maxconnections,
[ --with-maxconnections=NUMBER Set the maximum number of sockets.],
[ check_maxconnections=$withval ],
[ check_maxconnections="auto" ])
dnl -------------------------------------------------------------------
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_cflags_warn_all.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_CFLAGS_WARN_ALL [(shellvar [,default, [A/NA]])]
#
# DESCRIPTION
#
# Try to find a compiler option that enables most reasonable warnings.
#
# For the GNU CC compiler it will be -Wall (and -ansi -pedantic) The
# result is added to the shellvar being CFLAGS by default.
#
# Currently this macro knows about GCC, Solaris C compiler, Digital Unix C
# compiler, C for AIX Compiler, HP-UX C compiler, IRIX C compiler, NEC
# SX-5 (Super-UX 10) C compiler, and Cray J90 (Unicos 10.0.0.8) C
# compiler.
#
# - $1 shell-variable-to-add-to : CFLAGS
# - $2 add-value-if-not-found : nothing
# - $3 action-if-found : add value to shellvariable
# - $4 action-if-not-found : nothing
#
# LICENSE
#
# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# 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, see <http://www.gnu.org/licenses/>.
#
# As a special exception, the respective Autoconf Macro's copyright owner
# gives unlimited permission to copy, distribute and modify the configure
# scripts that are the output of Autoconf when processing the Macro. You
# need not follow the terms of the GNU General Public License when using
# or distributing such scripts, even though portions of the text of the
# Macro appear in them. The GNU General Public License (GPL) does govern
# all other use of the material that constitutes the Autoconf Macro.
#
# This special exception to the GPL applies to versions of the Autoconf
# Macro released by the Autoconf Archive. When you make and distribute a
# modified version of the Autoconf Macro, you may extend this special
# exception to the GPL to apply to your modified version as well.
AC_DEFUN([AX_CFLAGS_WARN_ALL],[dnl
AS_VAR_PUSHDEF([FLAGS],[CFLAGS])dnl
AS_VAR_PUSHDEF([VAR],[ac_cv_cflags_warn_all])dnl
AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings],
VAR,[VAR="no, unknown"
AC_LANG_PUSH([C])
ac_save_[]FLAGS="$[]FLAGS"
for ac_arg dnl
in "-pedantic % -Wall" dnl GCC
"-xstrconst % -v" dnl Solaris C
"-std1 % -verbose -w0 -warnprotos" dnl Digital Unix
"-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX
"-ansi -ansiE % -fullwarn" dnl IRIX
"+ESlit % +w1" dnl HP-UX C
"-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10)
"-h conform % -h msglevel 2" dnl Cray C (Unicos)
#
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[return 0;]])],[VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break],[])
done
FLAGS="$ac_save_[]FLAGS"
AC_LANG_POP([])
])
case ".$VAR" in
.ok|.ok,*) m4_ifvaln($3,$3) ;;
.|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[
AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])
m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;;
*) m4_ifvaln($3,$3,[
if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
fi ]) ;;
esac
AS_VAR_POPDEF([VAR])dnl
AS_VAR_POPDEF([FLAGS])dnl
])
dnl the only difference - the LANG selection... and the default FLAGS
AC_DEFUN([AX_CXXFLAGS_WARN_ALL],[dnl
AS_VAR_PUSHDEF([FLAGS],[CXXFLAGS])dnl
AS_VAR_PUSHDEF([VAR],[ax_cv_cxxflags_warn_all])dnl
AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings],
VAR,[VAR="no, unknown"
AC_LANG_PUSH([C++])
ac_save_[]FLAGS="$[]FLAGS"
for ac_arg dnl
in "-pedantic % -Wall" dnl GCC
"-xstrconst % -v" dnl Solaris C
"-std1 % -verbose -w0 -warnprotos" dnl Digital Unix
"-qlanglvl=ansi % -qsrcmsg -qinfo=all:noppt:noppc:noobs:nocnd" dnl AIX
"-ansi -ansiE % -fullwarn" dnl IRIX
"+ESlit % +w1" dnl HP-UX C
"-Xc % -pvctl[,]fullmsg" dnl NEC SX-5 (Super-UX 10)
"-h conform % -h msglevel 2" dnl Cray C (Unicos)
#
do FLAGS="$ac_save_[]FLAGS "`echo $ac_arg | sed -e 's,%%.*,,' -e 's,%,,'`
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[return 0;]])],[VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break],[])
done
FLAGS="$ac_save_[]FLAGS"
AC_LANG_POP([])
])
case ".$VAR" in
.ok|.ok,*) m4_ifvaln($3,$3) ;;
.|.no|.no,*) m4_ifvaln($4,$4,[m4_ifval($2,[
AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])
m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $2"])]) ;;
*) m4_ifvaln($3,$3,[
if echo " $[]m4_ifval($1,$1,FLAGS) " | grep " $VAR " 2>&1 >/dev/null
then AC_RUN_LOG([: m4_ifval($1,$1,FLAGS) does contain $VAR])
else AC_RUN_LOG([: m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"])
m4_ifval($1,$1,FLAGS)="$m4_ifval($1,$1,FLAGS) $VAR"
fi ]) ;;
esac
AS_VAR_POPDEF([VAR])dnl
AS_VAR_POPDEF([FLAGS])dnl
])
dnl implementation tactics:
dnl the for-argument contains a list of options. The first part of
dnl these does only exist to detect the compiler - usually it is
dnl a global option to enable -ansi or -extrawarnings. All other
dnl compilers will fail about it. That was needed since a lot of
dnl compilers will give false positives for some option-syntax
dnl like -Woption or -Xoption as they think of it is a pass-through
dnl to later compile stages or something. The "%" is used as a
dnl delimimiter. A non-option comment can be given after "%%" marks
dnl which will be shown but not added to the respective C/CXXFLAGS.
dnl -------------------------------------------------------------------
# ===========================================================================
# http://www.gnu.org/software/autoconf-archive/ax_have_epoll.html
# ===========================================================================
#
# SYNOPSIS
#
# AX_HAVE_EPOLL([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
# AX_HAVE_EPOLL_PWAIT([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
#
# DESCRIPTION
#
# This macro determines whether the system supports the epoll I/O event
# interface. A neat usage example would be:
#
# AX_HAVE_EPOLL(
# [AX_CONFIG_FEATURE_ENABLE(epoll)],
# [AX_CONFIG_FEATURE_DISABLE(epoll)])
# AX_CONFIG_FEATURE(
# [epoll], [This platform supports epoll(7)],
# [HAVE_EPOLL], [This platform supports epoll(7).])
#
# The epoll interface was added to the Linux kernel in version 2.5.45, and
# the macro verifies that a kernel newer than this is installed. This
# check is somewhat unreliable if <linux/version.h> doesn't match the
# running kernel, but it is necessary regardless, because glibc comes with
# stubs for the epoll_create(), epoll_wait(), etc. that allow programs to
# compile and link even if the kernel is too old; the problem would then
# be detected only at runtime.
#
# Linux kernel version 2.6.19 adds the epoll_pwait() call in addition to
# epoll_wait(). The availability of that function can be tested with the
# second macro. Generally speaking, it is safe to assume that
# AX_HAVE_EPOLL would succeed if AX_HAVE_EPOLL_PWAIT has, but not the
# other way round.
#
# LICENSE
#
# Copyright (c) 2008 Peter Simons <simons@cryp.to>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
AC_DEFUN([AX_HAVE_EPOLL], [dnl
ax_have_epoll_cppflags="${CPPFLAGS}"
AC_CHECK_HEADER([linux/version.h], [CPPFLAGS="${CPPFLAGS} -DHAVE_LINUX_VERSION_H"])
AC_MSG_CHECKING([for Linux epoll(7) interface])
AC_CACHE_VAL([ax_cv_have_epoll], [dnl
AC_LINK_IFELSE([dnl
AC_LANG_PROGRAM([dnl
#include <sys/epoll.h>
#ifdef HAVE_LINUX_VERSION_H
# include <linux/version.h>
# if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,45)
# error linux kernel version is too old to have epoll
# endif
#endif
], [dnl
int fd, rc;
struct epoll_event ev;
fd = epoll_create(128);
rc = epoll_wait(fd, &ev, 1, 0);])],
[ax_cv_have_epoll=yes],
[ax_cv_have_epoll=no])])
CPPFLAGS="${ax_have_epoll_cppflags}"
AS_IF([test "${ax_cv_have_epoll}" = "yes"],
[AC_MSG_RESULT([yes])
$1],[AC_MSG_RESULT([no])
$2])
])dnl
AC_DEFUN([AX_HAVE_EPOLL_PWAIT], [dnl
ax_have_epoll_cppflags="${CPPFLAGS}"
AC_CHECK_HEADER([linux/version.h],
[CPPFLAGS="${CPPFLAGS} -DHAVE_LINUX_VERSION_H"])
AC_MSG_CHECKING([for Linux epoll(7) interface with signals extension])
AC_CACHE_VAL([ax_cv_have_epoll_pwait], [dnl
AC_LINK_IFELSE([dnl
AC_LANG_PROGRAM([dnl
#ifdef HAVE_LINUX_VERSION_H
# include <linux/version.h>
# if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,19)
# error linux kernel version is too old to have epoll_pwait
# endif
#endif
#include <sys/epoll.h>
#include <signal.h>
], [dnl
int fd, rc;
struct epoll_event ev;
fd = epoll_create(128);
rc = epoll_wait(fd, &ev, 1, 0);
rc = epoll_pwait(fd, &ev, 1, 0, (sigset_t const *)(0));])],
[ax_cv_have_epoll_pwait=yes],
[ax_cv_have_epoll_pwait=no])])
CPPFLAGS="${ax_have_epoll_cppflags}"
AS_IF([test "${ax_cv_have_epoll_pwait}" = "yes"],
[AC_MSG_RESULT([yes])
$1],[AC_MSG_RESULT([no])
$2])
])dnl
dnl -------------------------------------------------
dnl Checks for programs.
AC_PROG_CC
AX_CFLAGS_WARN_ALL
AC_CANONICAL_TARGET
AC_SEARCH_LIBS([strerror],[cposix])
AC_PROG_MAKE_SET
AC_PATH_PROG(RM, rm)
AC_PATH_PROG(CP, cp)
AC_PATH_PROG(MV, mv)
AC_PATH_PROG(SED, sed)
AC_PROG_INSTALL
AC_C_INLINE
dnl Checks for libraries.
dnl Replace `main' with a function in -lnsl:
AC_CHECK_LIB(nsl, gethostbyname)
AC_CHECK_FUNC(res_mkquery,, AC_CHECK_LIB(resolv, res_mkquery))
AC_CHECK_FUNC(__res_mkquery,, AC_CHECK_LIB(resolv, __res_mkquery))
AC_CHECK_LIB(socket, socket, zlib)
AC_CHECK_FUNC(crypt,, AC_CHECK_LIB(descrypt, crypt,,AC_CHECK_LIB(crypt, crypt,,)))
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([fcntl.h limits.h malloc.h netdb.h netinet/in.h stddef.h])
AC_CHECK_HEADERS([stdlib.h string.h strings.h sys/file.h sys/ioctl.h])
AC_CHECK_HEADERS([sys/param.h sys/socket.h sys/time.h syslog.h unistd.h])
AC_CHECK_HEADERS([zlib.h])
AC_CHECK_HEADERS(inttypes.h sys/resource.h errno.h stdlib.h stddef.h getopt.h)
AC_MSG_CHECKING(MIN and MAX definition)
AC_EGREP_CPP(yes,
[
#if defined( HAVE_SYS_PARAM_H )
#include <sys/param.h>
#ifdef MIN
yes
#endif
#endif
], AC_DEFINE(HAVE_MINMAX) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
dnl Checks for library functions.
AC_PROG_GCC_TRADITIONAL
AC_CHECK_FUNCS([alarm dup2 gethostbyname gethostname getpass gettimeofday])
AC_CHECK_FUNCS([inet_ntoa isascii memmove memset munmap setenv socket])
AC_CHECK_FUNCS([strcasecmp strchr strdup strerror strncasecmp strrchr strtol])
AC_CHECK_FUNCS([strtoul index strerror strtoken strtok inet_addr inet_netof])
AC_CHECK_FUNCS([inet_aton gettimeofday lrand48 sigaction bzero bcmp bcopy])
AC_CHECK_FUNCS([dn_skipname __dn_skipname getrusage times break])
dnl check for various OSes
case "$target" in
*-solaris2*)
solaris2="yes"
AC_DEFINE(OS_SOLARIS2)
AC_DEFINE(OS_SOLARIS)
AC_DEFINE_UNQUOTED(WRITEV_IOV, 16)
;;
*-freebsd*)
freebsd="yes"
AC_DEFINE_UNQUOTED(WRITEV_IOV, 32)
;;
*-netbsd*)
AC_DEFINE_UNQUOTED(WRITEV_IOV, 32)
;;
*-openbsd*)
AC_DEFINE_UNQUOTED(WRITEV_IOV, 32)
;;
*-linux*)
linux="yes"
AC_DEFINE_UNQUOTED(WRITEV_IOV, 32)
;;
*aix*)
aix="yes"
AC_DEFINE(AIX)
;;
*-darwin*)
check_hmodules="no"
AC_DEFINE_UNQUOTED(WRITEV_IOV, 32)
;;
esac
dnl Checks for loadable hook module support
set_hmodules="disabled"
if test "$check_hmodules" = "yes"; then
AC_CHECK_LIB(dl, dlopen)
AC_CHECK_HEADER(dlfcn.h)
AC_CHECK_FUNCS(dlopen dlsym, [set_hmodules="enabled"])
if test "$set_hmodules" = "enabled"; then
AC_DEFINE(USE_HOOKMODULES)
MOD_LDFLAGS="-Wl,-export-dynamic"
fi
fi
dnl Check for sys_errlist
dnl Stolen from BitchX
AC_MSG_CHECKING(for sys_errlist declaration)
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <sys/types.h>
#include <stdio.h>
#include <errno.h>
main()
{
char *s = sys_errlist[0];
exit(0);
}
]])],[AC_MSG_RESULT(yes)
AC_DEFINE(SYS_ERRLIST_DECLARED)],[AC_MSG_RESULT(no)],[AC_MSG_RESULT(cross compiling)])
dnl Openssl checks - combination of our old way and the hybrid7 method
save_LIBS="$LIBS"
AC_MSG_CHECKING(for OpenSSL)
if test "X$cf_enable_openssl" != "Xno" ; then
cf_openssl_basedir=""
if test "X$cf_enable_openssl" != "Xauto" &&
test "X$cf_enable_openssl" != "Xyes"; then
dnl Support for --enable-openssl=/some/place
cf_openssl_basedir="${cf_enable_openssl}"
else
dnl Do the auto-probe here. Check some common directory paths.
for dirs in $HOME/openssl /usr/local/ssl /usr/pkg /usr/local /usr/lib /usr/lib/ssl\
/opt /opt/openssl /usr/local/openssl ; do
if test -f "${dirs}/include/openssl/opensslv.h" ; then
cf_openssl_basedir="${dirs}"
break
fi
done
unset dirs
fi
dnl Now check cf_openssl_found to see if we found anything.
if test "X$cf_openssl_basedir" != "X" ; then
if test -f "${cf_openssl_basedir}/include/openssl/opensslv.h" ; then
SSL_INCLUDES="-I${cf_openssl_basedir}/include"
SSL_LDFLAGS="-L${cf_openssl_basedir}/lib"
if test "$cf_openssl_basedir" = "$HOME/openssl"; then
SSL_LDFLAGS="-L${cf_openssl_basedir}/lib -Wl,-rpath,${cf_openssl_basedir}/lib"
fi
else
dnl OpenSSL wasn't found in the directory specified. Naughty
dnl administrator...
cf_openssl_basedir=""
fi
else
dnl Check for stock FreeBSD 4.x and 5.x systems, since their files
dnl are in /usr/include and /usr/lib. In this case, we don't want to
dnl change INCLUDES or LIBS, but still want to enable OpenSSL.
dnl We can't do this check above, because some people want two versions
dnl of OpenSSL installed (stock FreeBSD 4.x/5.x and /usr/local/ssl)
dnl and they want /usr/local/ssl to have preference.
if test -f "/usr/include/openssl/opensslv.h" ; then
cf_openssl_basedir="/usr"
fi
fi
dnl If we have a basedir defined, then everything is okay. Otherwise,
dnl we have a problem.
if test "X$cf_openssl_basedir" != "X" ; then
CPPFLAGS="$CPPFLAGS $SSL_INCLUDES"
LDFLAGS="$LDFLAGS $SSL_LDFLAGS"
LIBS="-lssl -lcrypto $save_LIBS"
AC_MSG_RESULT($cf_openssl_basedir)
cf_enable_openssl="yes"
encryption="enabled"
AC_DEFINE(HAVE_ENCRYPTION_ON)
ENCRYPT_SRC="rc4.c dh.c libcrypto-compat.c"
AC_SUBST(ENCRYPT_SRC)
else
AC_MSG_RESULT(not found. Please check your path.)
cf_enable_openssl="no"
encryption="disabled"
fi
unset cf_openssl_basedir
else
dnl If --disable-openssl was specified
encryption="disabled"
AC_MSG_RESULT(disabled)
fi
unset save_LIBS
dnl end of openssl library test
dnl select a socket engine
if test "$check_sengine" = "yes"; then
engine="select"
if test "$freebsd" = "yes"; then
AC_CHECK_FUNC(kevent, [ engine="kqueue" ], )
elif test "$solaris2" = "yes"; then
engine="poll"
AC_CHECK_HEADER(sys/devpoll.h, engine="devpoll", )
elif test "$linux" = "yes"; then
AC_CHECK_FUNC(poll, [ engine="poll" ], )
AX_HAVE_EPOLL([ engine="epoll" ], )
AC_CHECK_HEADER(sys/epoll.h, HAVE_EPOLL_H=yes, HAVE_EPOLL_H=no)
# AC_CHECK_LIB(epoll, epoll_create,
# [LIBS="$LIBS -lepoll"; have_epoll_lib="yes"; engine="epoll"],
# have_epoll_lib="no")
# if test "$HAVE_EPOLL_H $have_epoll_lib" = "yes no"; then
# AC_MSG_CHECKING(for epoll_create [without -lepoll])
# AC_RUN_IFELSE([AC_LANG_SOURCE([[
# #include <stdint.h>
# #include <sys/epoll.h>
# #include <errno.h>
#
# #include <asm/unistd.h>
#
# _syscall1(int, epoll_create, int, size)
#
# int main(int argc, char **argv) { return epoll_create(5) < 1; }
# ]])],[have_epoll_lib="yes"],[have_epoll_lib="no"],[])
# AC_MSG_RESULT($have_epoll_lib)
# if test "$have_epoll_lib" = "yes"; then
# AC_DEFINE(NEED_EPOLL_DEFS)
# fi
# fi
# if test "$HAVE_EPOLL_H $have_epoll_lib" = "yes yes"; then
# engine="epoll";
# fi
else
AC_CHECK_FUNC(poll, [ engine="poll"], )
fi
elif test "$check_sengine" = "kqueue"; then
AC_CHECK_FUNC(kevent, [ engine="kqueue" ], )
if test "X$engine" = "X"; then
AC_MSG_NOTICE()
AC_MSG_NOTICE(kqueue not supported on this platform!)
AC_MSG_ERROR()
fi
AC_MSG_NOTICE(setting socketengine type to kqueue)
elif test "$check_sengine" = "poll"; then
AC_CHECK_FUNC(poll, [ engine="poll" ], )
if test "X$engine" = "X"; then
AC_MSG_NOTICE()
AC_MSG_NOTICE(poll not supported on this platform!)
AC_MSG_ERROR()
fi
AC_MSG_NOTICE(setting socketengine type to poll)
elif test "$check_sengine" = "devpoll"; then
AC_CHECK_HEADER(sys/devpoll.h, engine="devpoll", )
if test "X$engine" = "X"; then
AC_MSG_NOTICE()
AC_MSG_NOTICE(/dev/poll not supported on this system)
AC_MSG_ERROR()
fi
AC_MSG_NOTICE(setting socketengine to devpoll)
elif test "$check_sengine" = "epoll"; then
AC_CHECK_HEADER(sys/epoll.h, HAVE_EPOLL_H=yes, HAVE_EPOLL_H=no)
AC_CHECK_LIB(epoll, epoll_create,
[LIBS="$LIBS -lepoll"; have_epoll_lib="yes"; engine="epoll"],
have_epoll_lib="no")
if test "$HAVE_EPOLL_H $have_epoll_lib" = "yes no"; then
AC_MSG_CHECKING(for epoll_create [without -lepoll])
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#include <stdint.h>
#include <sys/epoll.h>
#include <errno.h>
#include <asm/unistd.h>
_syscall1(int, epoll_create, int, size)
int main(int argc, char **argv) { return epoll_create(5) < 1; }
]])],[have_epoll_lib="yes"],[have_epoll_lib="no"],[])
AC_MSG_RESULT($have_epoll_lib)
if test "$have_epoll_lib" = "yes"; then
AC_DEFINE(NEED_EPOLL_DEFS)
fi
fi
if test "$HAVE_EPOLL_H $have_epoll_lib" != "yes yes"; then
AC_MSG_NOTICE()
AC_MSG_ERROR(epoll is not supported on this machine)
AC_MSG_ERROR()
fi
AC_MSG_NOTICE(setting socketengine type to epoll)
engine="epoll";
elif test "$check_sengine" = "select"; then
AC_MSG_NOTICE(setting socketengine type to select.. for some stupid reason)
engine="select"
else
AC_MSG_NOTICE()
AC_MSG_NOTICE(socket engine type incorrect!)
AC_MSG_ERROR()
fi
SENGINE="socketengine_$engine.c"
dnl Check to see if we have a broken FD_SETSIZE
if test $engine = "select"; then
AC_MSG_CHECKING(to see if FD_SETSIZE is broken)
AC_RUN_IFELSE([AC_LANG_SOURCE([[
#define FD_SETSIZE 666
#include <sys/types.h>
#include <sys/time.h>
int main()
{
if(FD_SETSIZE != 666)
exit(1);
exit(0);
}
]])],[AC_MSG_RESULT(no)],[
AC_MSG_RESULT(YES)
AC_MSG_WARN(FD_SETSIZE is hard set by your operating system)
AC_MSG_WARN(MAXCONNECTIONS must be no higher than the hardwired FD_SETSIZE)
AC_DEFINE(BROKEN_FD_SETSIZE)
broken_fd_setsize="yes"
],[AC_MSG_RESULT(can't tell)])
fi
if test "$solaris2" != "yes" && test "$aix" != "yes" &&
test "$set_hmodules" = "enabled"; then
LDFLAGS="$LDFLAGS $MOD_LDFLAGS"
fi
if test "$check_maxconnections" = "auto"; then
AC_MSG_CHECKING(Maximum file descriptors);
AC_CACHE_VAL(bh_cv_maxconnections,
[
AC_LANG_CONFTEST(
[AC_LANG_SOURCE([[
#include <sys/types.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <stdio.h>
#ifdef RLIMIT_FDMAX
#define RLIMIT_FD_MAX RLIMIT_FDMAX
#else
#ifdef RLIMIT_NOFILE
#define RLIMIT_FD_MAX RLIMIT_NOFILE
#else
#ifdef RLIMIT_OPEN_MAX
#define RLIMIT_FD_MAX RLIMIT_OPEN_MAX
#else
#undef RLIMIT_FD_MAX
#endif
#endif
#endif
int main()
{
#ifndef BROKEN_FD_SETSIZE
#ifdef RLIMIT_FD_MAX
struct rlimit limit;
if(!getrlimit(RLIMIT_FD_MAX, &limit))
{
if(limit.rlim_max > 32768)
printf("32768");
else
printf("%ld", (long) limit.rlim_max);
}
else
#endif
printf("256");
#else
printf("%d", FD_SETSIZE);
#endif
return 0;
}
]])
])
$CC -o conftest conftest.c >/dev/null 2>&1
maxconnections=`./conftest`
AC_MSG_RESULT($maxconnections)
$RM -f conftest conftest.c
])
AC_DEFINE_UNQUOTED(MAXCONNECTIONS, ${maxconnections})
else
maxconnections=$check_maxconnections
AC_DEFINE_UNQUOTED(MAXCONNECTIONS, ${maxconnections})
fi
# zlib test
# ripped from http://autoconf-archive.cryp.to/check_zlib.html
#
ZLIB_HOME=/usr/local
if test ! -f "${ZLIB_HOME}/include/zlib.h"
then
ZLIB_HOME=/usr
fi
if test -n "${ZLIB_HOME}"
then
ZLIB_OLD_CPPFLAGS="$CPPFLAGS"
ZLIB_OLD_LDFLAGS="$LDFLAGS"
if test "x$ZLIB_HOME" = "x/usr"; then
:
else
CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include"
LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib"
fi
AC_LANG_PUSH([C])
AC_CHECK_LIB(z, inflateEnd, [zlib_cv_libz=yes], [zlib_cv_libz=no])
AC_CHECK_HEADER(zlib.h, [zlib_cv_zlib_h=yes], [zlib_cv_zlib_h=no])
AC_LANG_POP([])
if test "$zlib_cv_libz" = "yes" -a "$zlib_cv_zlib_h" = "yes"
then
#
# If both library and header were found, use them
#
AC_CHECK_LIB(z, inflateEnd)
AC_MSG_CHECKING(zlib in ${ZLIB_HOME})
AC_MSG_RESULT(ok)
else
#
# If either header or library was not found, revert and bomb
#
AC_MSG_CHECKING(zlib in ${ZLIB_HOME})
CPPFLAGS="$ZLIB_OLD_CPPFLAGS"
LDFLAGS="$ZLIB_OLD_LDFLAGS"
AC_MSG_RESULT(failed)
AC_MSG_ERROR(either specify a valid zlib installation with --with-zlib=DIR or disable zlib usage with --without-zlib)
fi
fi
if test "$engine" = "select" && test "$broken_fd_setsize" != "yes"; then
CFLAGS="$CFLAGS -DFD_SETSIZE=$maxconnections"
fi
if test $prefix = NONE; then
prefix=${HOME}/ircd
if test -f "${HOME}/bahamut/ircd" ; then
prefix=${HOME}/bahamut
fi
if test -f "${HOME}/dalnet/ircd" ; then
prefix=${HOME}/dalnet
fi
fi
INSTALL_DIR="${prefix}"
AC_SUBST(LIBS)
AC_SUBST(SENGINE)
AC_SUBST(INSTALL_DIR)
AC_CONFIG_FILES([Makefile src/Makefile tools/Makefile doc/Makefile])
AC_OUTPUT
echo ""
echo " ******* Bahamut Configuration Settings *******"
echo " System Build Type: $target"
echo " Socket Engine Type: $engine"
echo " Encryption: $encryption"
echo " Loadable Modules: $set_hmodules"
echo " Maximum Connections: $maxconnections"
echo " Install Directory: $prefix"
echo ""