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=solid-ircd VERSION=3.4.7 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 ----------------------------------------------------------------- dnl this adds our check for proper warnings checks dnl http://ac-archive.sourceforge.net/guidod/ax_cflags_warn_all.html dnl handy. 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_SAVE AC_LANG_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_TRY_COMPILE([],[return 0;], [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) done FLAGS="$ac_save_[]FLAGS" AC_LANG_RESTORE ]) 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],[ac_cv_cxxflags_warn_all])dnl AC_CACHE_CHECK([m4_ifval($1,$1,FLAGS) for maximum warnings], VAR,[VAR="no, unknown" AC_LANG_SAVE AC_LANG_CXX 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_TRY_COMPILE([],[return 0;], [VAR=`echo $ac_arg | sed -e 's,.*% *,,'` ; break]) done FLAGS="$ac_save_[]FLAGS" AC_LANG_RESTORE ]) 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 ------------------------------------------------------------------- dnl Checks for programs. AC_PROG_CC AX_CFLAGS_WARN_ALL AC_CANONICAL_SYSTEM AC_ISC_POSIX AC_PROG_MAKE_SET AC_PATH_PROG(RM, rm) AC_PATH_PROG(CP, cp) AC_PATH_PROG(MV, mv) 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) 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([utmp.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 #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_LIBS="-Wl,-export-dynamic" fi fi dnl Check for sys_errlist dnl Stolen from BitchX AC_MSG_CHECKING(for sys_errlist declaration) AC_TRY_RUN([ #include #include #include 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 /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_LIBS="-L${cf_openssl_basedir}/lib" 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 LIBS="$save_LIBS $SSL_LIBS -lssl -lcrypto" AC_MSG_RESULT($cf_openssl_basedir) cf_enable_openssl="yes" encryption="enabled" AC_DEFINE(HAVE_ENCRYPTION_ON) ENCRYPT_SRC="rc4.c dh.c" AC_SUBST(ENCRYPT_SRC) AC_DEFINE(HAVE_SSL) ssl_connections="enabled" 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 once we add epoll and /dev/poll support, these will be dnl updated with the appropriate checks 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" ], ) 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_TRY_RUN([ #include #include #include #include _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_TRY_RUN([ #include #include #include #include _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_TRY_RUN([ #define FD_SETSIZE 666 #include #include 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 LIBS="$LIBS $MOD_LIBS" fi if test "$check_maxconnections" = "auto"; then AC_MSG_CHECKING(Maximum file descriptors); AC_CACHE_VAL(maxconnections, [ AC_LANG_CONFTEST( [AC_LANG_SOURCE([[ #include #include #include #include #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 if test "$engine" = "select" && test "$broken_fd_setsize" != "yes"; then CFLAGS="$CFLAGS -DFD_SETSIZE=$maxconnections" fi if test $prefix = NONE; then prefix=${HOME}/ircd fi AC_DEFUN([TYPE_SOCKLEN_T], [AC_CACHE_CHECK([for socklen_t], ac_cv_type_socklen_t, [ AC_TRY_COMPILE( [#include #include ], [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]) fi ]) TYPE_SOCKLEN_T INSTALL_DIR="${prefix}" AC_SUBST(SSL_INCLUDES) AC_SUBST(SSL_LIBS) AC_SUBST(LIBS) AC_SUBST(SENGINE) AC_SUBST(INSTALL_DIR) AC_OUTPUT(Makefile src/Makefile tools/Makefile doc/Makefile) echo configuring zlib... ( cd zlib ./configure cd .. ) echo "" echo " ******* solid-ircd Configuration Settings *******" echo " System Build Type: $target" echo " Socket Engine Type: $engine" echo " Encryption: $encryption" echo " SSL Connections: $ssl_connections" echo " Loadable Modules: $set_hmodules" echo " Maximum Connections: $maxconnections" echo " Install Directory: $prefix" echo ""