1 dnl Needed for AC_PATH_PROGS_FEATURE_CHECK which was added in 2.62
3 dnl Keep the version number in sync with main.h!
4 AC_INIT([znc], [0.204])
5 AC_CONFIG_MACRO_DIR([m4])
6 AC_CONFIG_SRCDIR([znc.cpp])
8 AC_CONFIG_HEADERS([zncconfig.h])
9 AH_TOP([#ifndef ZNCCONFIG_H
11 AH_BOTTOM([#endif /* ZNCCONFIG_H */])
13 AC_DEFUN([ZNC_AUTO_FAIL], [
14 # This looks better in the summary at the end
16 if test "x$old_$1" != "xauto" ; then
23 # AC_PROG_CXX sets CXXFLAGS to "-O2 -g" if it is unset which we don't want
34 if test "$LIBS" != ""; then
42 if test "$CXXFLAGS" != ""; then
43 CXXFLAGS="$CXXFLAGS $*"
50 if test "$MODFLAGS" != ""; then
51 MODFLAGS="$MODFLAGS $*"
58 if test "$LDFLAGS" != ""; then
65 appendCXX "-D_FORTIFY_SOURCE=2"
69 # -D__GNU_LIBRARY__ makes this work on fbsd 4.11
70 appendCXX -I/usr/local/include -D__GNU_LIBRARY__
71 appendLib -L/usr/local/lib -lcompat
72 appendMod -L/usr/local/lib
75 appendLib -lsocket -lnsl -lresolv
86 AC_ARG_WITH( [openssl],
87 AS_HELP_STRING([--with-openssl=DIR], [openssl installation prefix]),
89 AC_ARG_ENABLE( [extra],
90 AS_HELP_STRING([--enable-extra], [enable some extra modules]),
93 AC_ARG_ENABLE( [debug],
94 AS_HELP_STRING([--enable-debug], [enable debugging]),
97 AC_ARG_ENABLE( [ipv6],
98 AS_HELP_STRING([--disable-ipv6], [disable ipv6 support]),
101 AC_ARG_ENABLE( [openssl],
102 AS_HELP_STRING([--disable-openssl], [disable openssl]),
105 AC_ARG_ENABLE( [perl],
106 AS_HELP_STRING([--enable-perl], [enable perl]),
109 AC_ARG_ENABLE( [python],
110 AS_HELP_STRING([--enable-python[[[=python3]]]], [enable python.
111 By default python3.pc of pkg-config is used, but you can use
112 another name, for example python-3.1]),
113 [PYTHON="$enableval"],
115 AC_ARG_ENABLE( [swig],
116 AS_HELP_STRING([--disable-swig], [Disable automatic generation of source files needed for modperl/modpython.
117 This value is ignored if perl and python are disabled. If you disable swig,
118 but still want to use these modules, please download the necessary files to modules/modperl and/or to modules/modpython.
119 Check http://en.znc.in/wiki/Modperl and http://en.znc.in/wiki/Modpython for details.]),
120 [USESWIG="$enableval"],
122 AC_ARG_ENABLE( [sasl],
123 AS_HELP_STRING([--enable-sasl], [enable sasl]),
124 [if test "$enableval" = "yes" ; then SASL=1; fi],)
125 AC_ARG_ENABLE( [optimization],
126 AS_HELP_STRING([--disable-optimization], [Disable some compiler optimizations to
127 decrease memory usage while compiling]),
128 [OPTIMIZE="$enableval"],
130 AC_ARG_ENABLE( [c-ares],
131 AS_HELP_STRING([--disable-c-ares], [disable c-ares usage]),
134 AC_ARG_ENABLE( [run-from-source],
135 AS_HELP_STRING([--enable-run-from-source], [znc will be runnable without installation]),
136 [if test "x$enableval" = "xyes" ; then
137 AC_DEFINE([RUN_FROM_SOURCE], [1],
138 [Define if ZNC should be runnable without installation])
140 RUNFROMSOURCE="$enableval"],
141 [RUNFROMSOURCE="no"])
142 AC_ARG_ENABLE( [poll],
143 AS_HELP_STRING([--disable-poll], [use select() instead of poll()]),
147 if test "$DEBUG" != "no"; then
149 AC_DEFINE([_DEBUG], [1], [Define for debugging])
150 # These enable some debug options in g++'s STL, e.g. invalid use of iterators
151 AC_DEFINE([_GLIBCXX_DEBUG], [1], [Enable extra debugging checks in libstdc++])
152 AC_DEFINE([_GLIBCXX_DEBUG_PEDANTIC], [1], [Enable extra debugging checks in libstdc++])
153 AC_DEFINE([_GLIBCXX_CONCEPT_CHECKS], [1], [Enable extra debugging checks in libstdc++])
155 if test "x$OPTIMIZE" = "xyes"; then
160 if test "$IPV6" != "no"; then
161 AC_DEFINE([HAVE_IPV6], [1], [Define if IPv6 support is enabled])
164 if test "x$GXX" = "xyes"; then
165 appendCXX -Wall -W -Wno-unused-parameter -Woverloaded-virtual -Wshadow
168 if test "$POLL" = "yes"; then
169 # poll() is broken on Mac OS, it fails with POLLNVAL for pipe()s.
170 if test -n "$ISDARWIN"
172 # Did they give us --enable-poll?
173 if test -n "$enable_poll"
175 # Yes, they asked for this.
176 AC_MSG_WARN([poll() is known to be broken on Mac OS X. You have been warned.])
178 # No, our default value of "yes" got applied.
179 AC_MSG_WARN([poll() is known to be broken on Mac OS X. Using select() instead.])
180 AC_MSG_WARN([Use --enable-poll for forcing poll() to be used.])
184 if test "$POLL" = "yes"; then
185 AC_DEFINE([CSOCK_USE_POLL], [1], [Use poll() instead of select()])
189 AC_CHECK_LIB( gnugetopt, getopt_long,)
190 AC_CHECK_FUNCS([lstat getopt_long getphassphrase])
191 PKG_PROG_PKG_CONFIG()
193 # ----- Check for dlopen
195 AC_SEARCH_LIBS([dlopen], [dl], [],
196 [AC_MSG_ERROR([Could not find dlopen. ZNC will not work on this box until you upgrade this ancient system or at least install the necessary system libraries.])])
198 # ----- Check for c-ares
200 if test "x$ARES" != "xno"; then
202 if test -z "$PKG_CONFIG"
205 ZNC_AUTO_FAIL([ARES],
206 [pkg-config not found. Try --disable-c-ares.
207 Disabling c-ares may result in a slight performance decrease but will not have any other side-effects],
208 [pkg-config was not found and thus c-ares was disabled])
210 PKG_CHECK_MODULES([c_ares], [libcares >= 1.5.0],, ARES=no)
212 if test "x$ARES" = "xno" ; then
213 ZNC_AUTO_FAIL([ARES],
214 [c-ares not found. Try --disable-c-ares.
215 Disabling c-ares may result in a slight performance decrease but will not have any other side-effects],
216 [c-ares was not found and thus disabled])
218 AC_DEFINE([HAVE_C_ARES], [1], [Define if c-ares is enabled])
219 appendCXX $c_ares_CFLAGS
220 appendLib $c_ares_LIBS
226 # ----- Check for openssl
228 if test "x$SSL" != "xno"; then
229 if test -n "$OPENSSL"; then
230 appendLib -L${OPENSSL}/lib
231 appendLib -L${OPENSSL}/lib64
232 appendCXX -I${OPENSSL}/include
233 PKG_CONFIG_PATH="$OPENSSL/lib/pkgconfig/:$OPENSSL/lib64/pkgconfig/:$PKG_CONFIG_PATH"
237 PKG_CHECK_MODULES([openssl], [openssl], [
238 appendLib "$openssl_LIBS"
239 appendCXX "$openssl_CFLAGS"
241 # Don't reorder this!
242 # On some arches libssl depends on libcrypto without linking to it :(
243 AC_CHECK_LIB( crypto, BIO_new,, SSL=no )
244 AC_CHECK_LIB( ssl, SSL_shutdown,, SSL=no )
247 if test "x$SSL" = "xno" ; then
249 [OpenSSL not found. Try --disable-openssl.],
250 [OpenSSL was not found and thus disabled])
253 AC_DEFINE([HAVE_LIBSSL], [1], [Define if openssl is enabled])
260 AC_ARG_WITH( [module-prefix],
261 AS_HELP_STRING([--with-module-prefix], [module object code [LIBDIR/znc]]),
263 [MODDIR="${libdir}/znc"] )
265 AC_ARG_WITH( [module-data-prefix],
266 AS_HELP_STRING([--with-module-data-prefix=DIR],
267 [static module data (webadmin skins) [DATADIR/znc]]),
269 [DATADIR="${datadir}/znc"] )
271 appendMod "$CXXFLAGS"
272 appendMod "$CFLAG_VISIBILITY"
274 if test -z "$ISSUN" -a -z "$ISDARWIN" -a -z "$ISCYGWIN"; then
275 # This is an unknown compiler flag on some OS
276 appendLD -Wl,--export-dynamic
279 if test -z "$ISCYGWIN" ; then
280 # cygwin doesn't need -fPIC, everything else does (for modules)
281 # warning: -fPIC ignored for target (all code is position independent)
284 # But cygwin does want most of znc in a shared lib
289 if test -z "$ISDARWIN"; then
292 # Mac OS X differentiates between shared libs (-dynamiclib)
293 # and loadable modules (-bundle).
294 MODLINK="-bundle -flat_namespace -undefined suppress"
295 # TODO test if -twolevel_namespace and/or
296 # -undefined dynamic_lookup work
297 # (dynamic_lookup might only work on 10.4 and later)
300 if test "x$PERL" != xno -o "x$PYTHON" != xno; then
301 old_USESWIG="$USESWIG"
302 if test "x$USESWIG" != "xno"; then
303 AC_PROG_SWIG([1.3.40])
304 test -z "$SWIG" && USESWIG=no
306 if test "x$USESWIG" = xno; then
308 AC_MSG_WARN([$SWIG_ERROR])
309 if test "x$old_USESWIG" = xno; then
310 USESWIG="no, need manual download for perl/python bindings"
311 AC_MSG_WARN([swig was disabled, so you should put needed sources to modules/
312 Please check http://en.znc.in/wiki/Modperl or http://en.znc.in/wiki/Modpython for details.])
314 AC_MSG_ERROR([swig was not found. Try --disable-perl --disable-python, or download the necessary sources and use --disable-swig.
315 Please check http://en.znc.in/wiki/Modperl or http://en.znc.in/wiki/Modpython for details.])
321 if test "x$USESWIG" = "xyes"; then
322 AC_MSG_WARN([swig is needed only for perl and python, but both are disabled. Disabling swig.])
327 if test "x$PERL" != "xno"; then
329 AC_PATH_PROG([PERL_BINARY], [perl], [])
330 if test -n "$PERL_BINARY" && eval "$PERL_BINARY -e'use 5.010'"; then
331 my_saved_LDFLAGS="$LDFLAGS"
332 appendLD `$PERL_BINARY -MExtUtils::Embed -e ccopts -e ldopts`
333 AC_CHECK_LIB(perl, perl_alloc,
334 [: No, we do not want autoconf to do sth automatically],
336 LDFLAGS="$my_saved_LDFLAGS"
340 if test "x$PERL" = "xno"; then
341 ZNC_AUTO_FAIL([PERL],
342 [perl not found. Try --disable-perl.],
343 [perl was not found and thus disabled])
350 if test "x$PYTHON" != "xno"; then
351 # Default value for just --enable-python
352 if test "x$PYTHON" = "xyes"; then
356 if test -z "$PKG_CONFIG"; then
357 AC_MSG_ERROR([pkg-config is required for modpython.])
359 PKG_CHECK_MODULES([python], [$PYTHON >= 3.0],, AC_MSG_ERROR([$PYTHON.pc not found or is wrong. Try --disable-python or install python3.]))
360 if test "x$USESWIG" = xyes; then :
361 PKG_CHECK_MODULES([python32], [$PYTHON >= 3.2], [PYTHON_32=yes], [PYTHON_32=no])
362 if test "x$PYTHON_32" = xyes; then
363 AC_MSG_NOTICE([python 3.2+ found, requiring newer swig.])
364 AC_PROG_SWIG([2.0.4])
365 if test -z "$SWIG"; then
366 AC_MSG_ERROR([$SWIG_ERROR])
370 my_saved_LIBS="$LIBS"
371 my_saved_CXXFLAGS="$CXXFLAGS"
372 appendLib $python_LIBS
373 appendCXX $python_CFLAGS
374 AC_CHECK_FUNC([Py_Initialize], [], [PYTHON="no"])
375 if test "x$PYTHON" != "xno"; then
376 # Yes, modpython depends on perl.
377 AC_PATH_PROG([PERL_BINARY], [perl])
378 if test -z "$PERL_BINARY"; then
379 AC_MSG_ERROR([To compile modpython you need to be able to execute perl scripts. Try --disable-python or install perl.])
381 LIBS="$my_saved_LIBS"
382 CXXFLAGS="$my_saved_CXXFLAGS"
386 if test "x$PYTHON" = "xno"; then
387 ZNC_AUTO_FAIL([PYTHON],
388 [python not found. Try --disable-python.],
389 [python was not found and thus disabled])
396 if test -n "$SASL"; then
397 AC_CHECK_LIB( sasl2, sasl_server_init,
398 [: Dont let autoconf add -lsasl2, Makefile handles that],
399 AC_MSG_ERROR([could not find libsasl2. Try --disable-sasl.]))
402 # Check if we want modtcl
403 AC_ARG_ENABLE( [tcl],
404 AS_HELP_STRING([--enable-tcl], [enable modtcl]),
408 AC_ARG_WITH( [tcl-flags],
409 AS_HELP_STRING([--with-tcl-flags=FLAGS],
410 [The flags needed for compiling and linking modtcl]),
411 [TCL_FLAGS="$withval"],)
413 if test x"$TCL" = "xyes"
416 AS_HELP_STRING([--with-tcl=DIR],
417 [directory containing tclConfig.sh]),
418 TCL_DIR="${withval}")
420 # This will need to be extended in the future, but I don't think
421 # it's a good idea to stuff a shitload of random stuff in here right now
422 for path in $TCL_DIR /usr/lib /usr/lib/tcl8.4 /usr/lib/tcl8.5
424 file="${path}/tclConfig.sh"
425 AC_MSG_CHECKING([for ${file}])
435 if test x"${TCL_CONF}" = x
437 # They --enable-tcl'd, so give them some sane default
438 TCL_FLAGS="-I/usr/include/tcl -ltcl"
439 AC_MSG_WARN([Could not find tclConfig.sh, using some sane defaults.])
441 AC_MSG_CHECKING([modtcl flags])
443 # eval because those vars depend on other vars in there
444 eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
445 eval "TCL_INCLUDE_SPEC=\"${TCL_INCLUDE_SPEC}\""
446 TCL_FLAGS="$TCL_INCLUDE_SPEC $TCL_LIB_SPEC"
447 AC_MSG_RESULT([$TCL_FLAGS])
449 my_saved_LIBS="$LIBS"
450 appendLib "$TCL_FLAGS"
451 AC_CHECK_FUNC([Tcl_CreateInterp], [TCL_TEST=yes], [TCL_TEST=no])
452 if test x"$TCL_TEST" = "xno"; then
453 AC_MSG_ERROR([tcl not found, try --disable-tcl, or install tcl properly. If tcl is installed to a non-standard path, use --enable-tcl --with-tcl=/path])
455 LIBS="$my_saved_LIBS"
458 if test x"$EXTRA" = "xyes"
460 AC_CHECK_FUNC( iconv, CHARSET=1 )
461 AC_CHECK_LIB( iconv, iconv_open, LIBICONV=-liconv ; CHARSET=1 )
462 if test "x$CHARSET" = "x1"
464 AC_MSG_CHECKING([whether iconv expects a const second argument])
469 const char input[] = "X"; const char *inptr = input; size_t inbytes = 1;
470 char buf[1]; char *outptr = buf; size_t outbytes = 1;
471 iconv_t ic = iconv_open("ISO8859-1", "UTF8");
472 iconv(ic, (char**)&inptr, &inbytes, &outptr, &outbytes);
475 appendMod -DICONV_CONST=
478 appendMod -DICONV_CONST=const
481 AC_MSG_WARN([libiconv was not found, disabling the charset module])
485 AC_CACHE_CHECK([for GNU make], [ac_cv_path_GNUMAKE], [
486 AC_PATH_PROGS_FEATURE_CHECK([GNUMAKE], [make gmake], [[
487 if $ac_path_GNUMAKE --version | $GREP GNU > /dev/null; then
488 ac_cv_path_GNUMAKE=$ac_path_GNUMAKE
489 ac_path_GNUMAKE_found=:
491 ]], [AC_MSG_ERROR([could not find GNU make])]
494 GNUMAKE_DIRNAME=`AS_DIRNAME(["$ac_cv_path_GNUMAKE"])`
495 GNUMAKE=`echo $ac_cv_path_GNUMAKE | $SED "s%$GNUMAKE_DIRNAME/%%"`
503 AC_SUBST([LIBZNCDIR])
507 AC_SUBST([TCL_FLAGS])
516 AC_SUBST([python_CFLAGS])
517 AC_SUBST([python_LIBS])
518 AC_CONFIG_FILES([Makefile])
519 AC_CONFIG_FILES([znc-config])
520 AC_CONFIG_FILES([znc-buildmod])
521 AC_CONFIG_FILES([man/Makefile])
522 AC_CONFIG_FILES([znc.pc])
523 AC_CONFIG_FILES([znc-uninstalled.pc])
524 AC_CONFIG_FILES([modules/Makefile])
525 AC_CONFIG_FILES([test/Makefile])
529 echo znc AC_PACKAGE_VERSION configured
531 echo "prefix: $prefix"
537 echo "python: $PYTHON"
538 echo "swig: $USESWIG"
539 if test x"$SASL" = "x" ; then
545 if test x"$TCL_FLAGS" = "x" ; then
550 if test x"$CHARSET" = "x" ; then
555 echo "run from src: $RUNFROMSOURCE"
557 echo "Now you can run \"$GNUMAKE\" to compile ZNC"