]> jfr.im git - irc/znc/znc.git/blame - configure.ac
Increase the version number to 1.7.2
[irc/znc/znc.git] / configure.ac
CommitLineData
6f2335d5
US
1dnl This redefines AC_PROG_CC to a version which errors out instead. This is
2dnl because all our tests should be done with the C++ compiler. This should
3dnl catch stuff which accidentally uses the C compiler.
4AC_DEFUN([AC_PROG_CC], [m4_errprint(__file__:__line__[: Something is trying to use the C compiler. Since this is a C++ project, this should not happen!
5])m4_exit(1)])
6
5ca6291f
US
7dnl Needed for AC_PATH_PROGS_FEATURE_CHECK which was added in 2.62
8AC_PREREQ([2.62])
55b5c242 9dnl Keep the version number in sync with version.h!
5cde1eb3 10AC_INIT([znc], [1.7.2])
2ed4d1b6 11LIBZNC_VERSION=1.7.2
7d912d1d 12AC_CONFIG_MACRO_DIR([m4])
afeab4a9 13AC_CONFIG_SRCDIR([src/znc.cpp])
9c4a5a1d 14AC_LANG([C++])
afeab4a9 15AC_CONFIG_HEADERS([include/znc/zncconfig.h])
3ecbf133 16AH_TOP([#ifndef ZNCCONFIG_H
17#define ZNCCONFIG_H])
18AH_BOTTOM([#endif /* ZNCCONFIG_H */])
9c4a5a1d 19
226d8db5 20AC_DEFUN([ZNC_AUTO_FAIL], [
521695fb 21 # This looks better in the summary at the end
22 $1="not found"
16464664 23 if test "x$old_$1" != "xauto" ; then
521695fb 24 AC_MSG_ERROR([$2])
25 else
26 AC_MSG_WARN([$3])
27 fi
28])
29
9c4a5a1d 30# AC_PROG_CXX sets CXXFLAGS to "-O2 -g" if it is unset which we don't want
0a36695a 31CXXFLAGS="$CXXFLAGS "
d9591e95 32AC_PROG_CXX
1f89b67a
AS
33# "Optional" because we want custom error message
34AX_CXX_COMPILE_STDCXX_11([noext], [optional])
35if test x"$HAVE_CXX11" != x1; then
79ec016f 36 AC_MSG_ERROR([Upgrade your compiler. GCC 4.8+ and Clang 3.2+ are known to work.])
1f89b67a
AS
37fi
38
d1de3746 39appendLib () {
d9591e95 40 if test "$LIBS" != ""; then
41 LIBS="$LIBS $*"
42 else
43 LIBS=$*
44 fi
45}
46
d1de3746 47appendCXX () {
d9591e95 48 if test "$CXXFLAGS" != ""; then
49 CXXFLAGS="$CXXFLAGS $*"
50 else
51 CXXFLAGS=$*
52 fi
53}
0a622749 54
90cf81e6 55appendMod () {
56 if test "$MODFLAGS" != ""; then
57 MODFLAGS="$MODFLAGS $*"
58 else
59 MODFLAGS=$*
60 fi
61}
62
d1de3746 63appendLD () {
0a622749 64 if test "$LDFLAGS" != ""; then
65 LDFLAGS="$LDFLAGS $*"
66 else
67 LDFLAGS=$*
68 fi
69}
70
1cce7f69
AS
71AC_PROG_INSTALL
72AC_PROG_GREP
73AC_PROG_SED
74AC_CANONICAL_HOST
75AC_SYS_LARGEFILE
76ZNC_VISIBILITY
77AC_PATH_PROG([GIT], [git])
524ec572
WK
78PKG_PROG_PKG_CONFIG()
79
759d11fc 80AC_ARG_ENABLE( [debug],
7e61148a 81 AS_HELP_STRING([--enable-debug], [enable debugging]),
759d11fc 82 [DEBUG="$enableval"],
83 [DEBUG="no"])
84AC_ARG_ENABLE( [ipv6],
f4e36a0b 85 AS_HELP_STRING([--disable-ipv6], [disable ipv6 support]),
759d11fc 86 [IPV6="$enableval"],
f4e36a0b 87 [IPV6="yes"])
759d11fc 88AC_ARG_ENABLE( [openssl],
9c4a5a1d 89 AS_HELP_STRING([--disable-openssl], [disable openssl]),
f0232425 90 [SSL="$enableval"],
16464664 91 [SSL="auto"])
ea947956
IR
92AC_ARG_ENABLE( [zlib],
93 AS_HELP_STRING([--disable-zlib], [disable zlib]),
94 [ZLIB="$enableval"],
95 [ZLIB="auto"])
759d11fc 96AC_ARG_ENABLE( [perl],
a44e6eaa 97 AS_HELP_STRING([--enable-perl], [enable perl]),
16464664 98 [PERL="$enableval"],
a44e6eaa 99 [PERL="no"])
a564e25c 100AC_ARG_ENABLE( [python],
ba915eb9
AS
101 AS_HELP_STRING([--enable-python[[[=python3]]]], [enable python.
102 By default python3.pc of pkg-config is used, but you can use
103 another name, for example python-3.1]),
a564e25c 104 [PYTHON="$enableval"],
105 [PYTHON="no"])
a44e6eaa 106AC_ARG_ENABLE( [swig],
3d152b16
AS
107 AS_HELP_STRING([--enable-swig], [Enable automatic generation of source files needed for modperl/modpython.
108 This value is ignored if perl and python are disabled.
109 Usually no need to enable it.
110 ]),
7d912d1d
AS
111 [USESWIG="$enableval"],
112 [USESWIG="auto"])
63ab3c09
KF
113AC_ARG_ENABLE( [cyrus],
114 AS_HELP_STRING([--enable-cyrus], [enable cyrus]),
115 [if test "$enableval" = "yes" ; then CYRUS=1; fi],)
29dab181 116AC_ARG_ENABLE( [optimization],
9c4a5a1d 117 AS_HELP_STRING([--disable-optimization], [Disable some compiler optimizations to
29dab181 118 decrease memory usage while compiling]),
119 [OPTIMIZE="$enableval"],
120 [OPTIMIZE="yes"])
717d0596
AS
121AC_ARG_ENABLE( [tdns],
122 AS_HELP_STRING([--disable-tdns], [disable threads usage for DNS resolving]),
123 [TDNS="$enableval"],
124 [TDNS="auto"])
fe6a930a 125AC_ARG_ENABLE( [run-from-source],
d252a2b4 126 AS_HELP_STRING([--enable-run-from-source], [ZNC will be runnable without installation]),
0f6c1f9e 127 [if test "x$enableval" = "xyes" ; then
40a1bbac 128 AC_DEFINE([RUN_FROM_SOURCE], [1],
129 [Define if ZNC should be runnable without installation])
d72fc441 130 fi
131 RUNFROMSOURCE="$enableval"],
132 [RUNFROMSOURCE="no"])
0f9f2468 133AC_ARG_ENABLE( [poll],
134 AS_HELP_STRING([--disable-poll], [use select() instead of poll()]),
135 [POLL="$enableval"],
136 [POLL="yes"])
6f40e5dd 137
17907784 138AC_ARG_WITH( [gtest],
6f40e5dd
AS
139 AS_HELP_STRING([--with-gtest=DIR], [Path to directory with src/gtest-all.cc file.
140 If not specified, git submodule will be used.
141 If it is not available either, "make test" will fail.]))
142if test "x$with_gtest" != xno; then
143 AC_SUBST([GTEST_DIR], [$with_gtest])
144fi
145AC_ARG_WITH([gmock],
146 AS_HELP_STRING([--with-gmock=DIR], [Path to directory with src/gmock-all.cc and src/gmock_main.cc files.
147 If not specified, git submodule will be used.
148 If it is not available either, "make test" will fail.]))
149if test "x$with_gmock" != xno; then
150 AC_SUBST([GMOCK_DIR], [$with_gmock])
151fi
152
74213c9a 153
40641b40
WK
154AC_ARG_WITH([systemdsystemunitdir],
155 AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
d5437282
AS
156 [
157 if test x"$with_systemdsystemunitdir" = xyes; then
158 with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
159 fi
160 ])
40641b40
WK
161if test "x$with_systemdsystemunitdir" != xno; then
162 AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
163fi
164AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
165
1cce7f69
AS
166case "${host_os}" in
167 freebsd*)
168 # -D__GNU_LIBRARY__ makes this work on fbsd 4.11
169 appendCXX -I/usr/local/include -D__GNU_LIBRARY__
170 appendLib -L/usr/local/lib -lcompat
171 appendMod -L/usr/local/lib
172 ;;
173 solaris*)
174 appendLib -lsocket -lnsl -lresolv
175 ISSUN=1
176 ;;
177 cygwin)
178 # We don't want to use -std=gnu++11 instead of -std=c++11, but among other things, -std=c++11 defines __STRICT_ANSI__ which makes cygwin not to compile: undefined references to strerror_r, to fdopen, to strcasecmp, etc (their declarations in system headers are between ifdef)
179 appendCXX -U__STRICT_ANSI__
180 ISCYGWIN=1
181 ;;
182 darwin*)
183 ISDARWIN=1
184
1cce7f69
AS
185 AC_PATH_PROG([BREW], [brew])
186 if test -n "$BREW"; then
187 # add default homebrew paths
188
189 if test "x$HAVE_ICU" != "xno"; then
190 AC_MSG_CHECKING([icu4c via homebrew])
191 icu4c_prefix=`$BREW --prefix icu4c`
192 if test -n "$icu4c_prefix"; then
a08d0497 193 export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$icu4c_prefix/lib/pkgconfig"
1cce7f69
AS
194 AC_MSG_RESULT([$icu4c_prefix])
195 else
196 AC_MSG_RESULT([no])
197 fi
198 fi
199
200 if test "x$PYTHON" != "xno"; then
201 brew_python_pc="$PYTHON"
202 # This is duplication of non-darwin python logic below...
203 if test "x$brew_python_pc" = "xyes"; then
204 brew_python_pc="python3"
205 fi
206 AC_MSG_CHECKING([python3 via homebrew])
207 python3_prefix=`$BREW --prefix python3`
208 if test -n "$python3_prefix"; then
209 python3_prefix=`find "$python3_prefix/" -name $brew_python_pc.pc | head -n1`
210 if test -n "$python3_prefix"; then
211 python3_prefix=`dirname "$python3_prefix"`
a08d0497 212 export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$python3_prefix"
1cce7f69
AS
213 AC_MSG_RESULT([$python3_prefix])
214 else
215 AC_MSG_RESULT([no $brew_python_pc.pc found])
216 fi
217 else
218 AC_MSG_RESULT([no])
219 fi
220 fi
221
222 if test "x$SSL" != "xno"; then
223 AC_MSG_CHECKING([openssl via homebrew])
f2936375
N
224 openssl_prefix=`$BREW --prefix openssl`
225 if test -n "$openssl_prefix"; then
226 export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$openssl_prefix/lib/pkgconfig"
227 AC_MSG_RESULT([$openssl_prefix])
1cce7f69 228 else
f2936375 229 AC_MSG_RESULT([no])
1cce7f69
AS
230 fi
231 fi
232 fi
233 ;;
234esac
235
759d11fc 236if test "$DEBUG" != "no"; then
02605581 237 appendCXX -ggdb3
40a1bbac 238 AC_DEFINE([_DEBUG], [1], [Define for debugging])
a1e8b086
AS
239 if test "x$ISCYGWIN" != x1; then
240 # These enable some debug options in g++'s STL, e.g. invalid use of iterators
241 # But they cause crashes on cygwin while loading modules
242 AC_DEFINE([_GLIBCXX_DEBUG], [1], [Enable extra debugging checks in libstdc++])
243 AC_DEFINE([_GLIBCXX_DEBUG_PEDANTIC], [1], [Enable extra debugging checks in libstdc++])
a1e8b086 244 fi
759d11fc 245else
29dab181 246 if test "x$OPTIMIZE" = "xyes"; then
247 appendCXX -O2
0734c6ac
N
248
249 # In old times needed to define _FORTIFY_SOURCE to 2 ourself.
250 # Then GCC started to define it itself to 2. It was ok.
251 # But then GCC 4.7 started to define it to 0 or 2 depending on optimization level, and it started to conflict with our define.
252 AC_MSG_CHECKING([whether compiler predefines _FORTIFY_SOURCE])
253 AC_COMPILE_IFELSE([
254 AC_LANG_PROGRAM([[
255 ]], [[
256 #ifndef _FORTIFY_SOURCE
257 #error "Just checking, nothing fatal here"
258 #endif
259 ]])
260 ], [
261 AC_MSG_RESULT([yes])
262 ], [
263 AC_MSG_RESULT([no])
264 appendCXX "-D_FORTIFY_SOURCE=2"
265 ])
29dab181 266 fi
759d11fc 267fi
268
269if test "$IPV6" != "no"; then
40a1bbac 270 AC_DEFINE([HAVE_IPV6], [1], [Define if IPv6 support is enabled])
759d11fc 271fi
d9591e95 272
9f665430 273if test "x$GXX" = "xyes"; then
7e34dd3b 274 appendCXX -Wall -W -Wno-unused-parameter -Woverloaded-virtual -Wshadow
9f665430 275fi
276
0f9f2468 277if test "$POLL" = "yes"; then
72c1fa0c
US
278 # poll() is broken on Mac OS, it fails with POLLNVAL for pipe()s.
279 if test -n "$ISDARWIN"
280 then
281 # Did they give us --enable-poll?
282 if test -n "$enable_poll"
283 then
284 # Yes, they asked for this.
285 AC_MSG_WARN([poll() is known to be broken on Mac OS X. You have been warned.])
286 else
287 # No, our default value of "yes" got applied.
288 AC_MSG_WARN([poll() is known to be broken on Mac OS X. Using select() instead.])
289 AC_MSG_WARN([Use --enable-poll for forcing poll() to be used.])
290 POLL=no
291 fi
292 fi
293 if test "$POLL" = "yes"; then
294 AC_DEFINE([CSOCK_USE_POLL], [1], [Use poll() instead of select()])
295 fi
0f9f2468 296fi
297
7de2b935 298AC_CHECK_LIB( gnugetopt, getopt_long,)
f3762e8b 299AC_CHECK_FUNCS([lstat getopt_long getpassphrase clock_gettime tcsetattr])
6d957ed9 300
e2c694c9 301# ----- Check for dlopen
302
85a27066 303AC_SEARCH_LIBS([dlopen], [dl], [],
304 [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.])])
e2c694c9 305
717d0596 306# ----- Check for pthreads
e2c694c9 307
582cd635
AS
308AX_PTHREAD([
309 AC_DEFINE([HAVE_PTHREAD], [1], [Define if you have POSIX threads libraries and header files.])
310 appendCXX "$PTHREAD_CFLAGS"
311 appendLib "$PTHREAD_LIBS"
312], [
313 AC_MSG_ERROR([This compiler/OS doesn't seem to support pthreads.])
314])
315
316# Note that old broken systems, such as OpenBSD, NetBSD, which don't support AI_ADDRCONFIG, also have thread-unsafe getaddrinfo().
317# Gladly, they fixed thread-safety before support of AI_ADDRCONFIG, so this can be abused to detect the thread-safe getaddrinfo().
318#
319# TODO: drop support of blocking DNS at some point. OpenBSD supports AI_ADDRCONFIG since Nov 2014, and their getaddrinfo() is thread-safe since Nov 2013. NetBSD's one is thread-safe since ages ago.
1d3ea7c6 320DNS_TEXT=blocking
717d0596
AS
321if test "x$TDNS" != "xno"; then
322 old_TDNS=$TDNS
582cd635
AS
323 AC_MSG_CHECKING([whether getaddrinfo() supports AI_ADDRCONFIG])
324 AC_COMPILE_IFELSE([
325 AC_LANG_PROGRAM([[
326 #include <sys/types.h>
327 #include <sys/socket.h>
328 #include <netdb.h>
329 ]], [[
330 int x = AI_ADDRCONFIG;
331 (void) x;
332 ]])
333 ], [
334 AC_MSG_RESULT([yes])
335 TDNS=yes
1d3ea7c6 336 ], [
582cd635 337 AC_MSG_RESULT([no])
1d3ea7c6
AS
338 TDNS=no
339 ])
340 if test "x$TDNS" = "xyes"; then
717d0596
AS
341 DNS_TEXT=threads
342 AC_DEFINE([HAVE_THREADED_DNS], [1], [Define if threaded DNS is enabled])
1d3ea7c6 343 else
717d0596 344 ZNC_AUTO_FAIL([TDNS],
1d3ea7c6
AS
345 [support for threaded DNS not found. Try --disable-tdns.
346Disabling it may result in a slight performance decrease but will not have any other side-effects],
347 [support for threaded DNS not found, so DNS resolving will be blocking])
348 fi
f77e5266 349fi
350
e2c694c9 351# ----- Check for openssl
352
4676fa0a 353SSL_TEXT="$SSL"
f0232425 354if test "x$SSL" != "xno"; then
521695fb 355 old_SSL=$SSL
68c5ee59 356 PKG_CHECK_MODULES([openssl], [openssl], [
357 appendLib "$openssl_LIBS"
358 appendCXX "$openssl_CFLAGS"
359 ], [
68c5ee59 360 # Don't reorder this!
361 # On some arches libssl depends on libcrypto without linking to it :(
4676fa0a
US
362 AC_CHECK_LIB( crypto, BIO_new,, SSL=no ; SSL_TEXT="no (libcrypt not found)" )
363 AC_CHECK_LIB( ssl, SSL_shutdown,, SSL=no ; SSL_TEXT="no (libssl not found)" )
68c5ee59 364 ])
521695fb 365
f94cb24f
AS
366 if test "x$SSL" != "xno"; then
367 AC_MSG_CHECKING([whether openssl is usable])
368 AC_LINK_IFELSE([
369 AC_LANG_PROGRAM([[
370 #include <openssl/ssl.h>
dddcef52 371 #include <openssl/dh.h>
f94cb24f 372 ]], [[
f6eb4367 373 SSL_CTX* ctx = SSL_CTX_new(SSLv23_method());
f94cb24f
AS
374 SSL* ssl = SSL_new(ctx);
375 DH* dh = DH_new();
afb48300
US
376 DH_free(dh);
377 SSL_free(ssl);
378 SSL_CTX_free(ctx);
f94cb24f
AS
379 ]])
380 ], [
381 AC_MSG_RESULT([yes])
382 ], [
383 AC_MSG_RESULT([no])
384 SSL=no
4676fa0a 385 SSL_TEXT="no (openssl not usable)"
f94cb24f 386 ])
53e5e99d 387
f94cb24f
AS
388 fi
389
521695fb 390 if test "x$SSL" = "xno" ; then
391 ZNC_AUTO_FAIL([SSL],
16464664 392 [OpenSSL not found. Try --disable-openssl.],
393 [OpenSSL was not found and thus disabled])
521695fb 394 NOSSL=1
395 else
40a1bbac 396 AC_DEFINE([HAVE_LIBSSL], [1], [Define if openssl is enabled])
16464664 397 SSL=yes
4676fa0a 398 SSL_TEXT=yes
521695fb 399 fi
f0232425 400else
401 NOSSL=1
4676fa0a 402 SSL_TEXT="no (explicitly disabled)"
d9591e95 403fi
404
ea947956
IR
405# ----- Check for zlib
406
407old_ZLIB="$ZLIB"
4676fa0a 408ZLIB_TEXT="$ZLIB"
ea947956
IR
409if test "x$ZLIB" != "xno"; then
410 AC_MSG_CHECKING([whether zlib is usable])
411 my_saved_LIBS="$LIBS"
412 appendLib "-lz"
413 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
414 #include "zlib.h"
415 ]], [[
416 z_stream zs;
417 (void) deflateInit2(&zs, 0, 0, 0, 0, 0);
418 (void) deflate(&zs, 0);
419 ]])
420 ], [
421 AC_MSG_RESULT([yes])
422 ZLIB=yes
4676fa0a 423 ZLIB_TEXT=yes
ea947956
IR
424 ], [
425 AC_MSG_RESULT([no])
426 ZLIB=no
4676fa0a 427 ZLIB_TEXT="no (libz not found)"
ea947956
IR
428 ])
429 if test "x$ZLIB" = "xno"; then
430 ZNC_AUTO_FAIL([ZLIB],
431 [zlib was not found. Try --disable-zlib],
432 [zlib was not found and thus disabled])
433 LIBS="$my_saved_LIBS"
434 else
435 AC_DEFINE([HAVE_ZLIB], [1], [Define if zlib is available])
436 fi
437fi
438
1c07c384
N
439AC_ARG_ENABLE( [charset],
440 AS_HELP_STRING([--disable-charset], [disable ICU support]),
441 [HAVE_ICU="$enableval"],
442 [HAVE_ICU="auto"])
443if test "x$HAVE_ICU" != "xno"
444then
445 old_HAVE_ICU="$HAVE_ICU"
446 PKG_CHECK_MODULES([icu], [icu-uc], [
447 appendLib "$icu_LIBS"
448 appendCXX "$icu_CFLAGS"
449 HAVE_ICU=yes
450 AC_DEFINE([HAVE_ICU], [1], [Enable ICU library for Unicode handling])
451 AC_DEFINE([U_USING_ICU_NAMESPACE], [0], [Do not clutter global namespace with ICU C++ stuff])
452 ], [
453 ZNC_AUTO_FAIL([HAVE_ICU],
454 [support for charset conversion not found. Try --disable-charset.],
455 [support for charset conversion not found and thus disabled])
456 HAVE_ICU="no (icu-uc not found via pkg-config)"
457 ])
458fi
459
90ae7853
AS
460# For integration test only
461PKG_CHECK_MODULES([qt], [Qt5Network >= 5.4], [], [:])
462
759d11fc 463AC_ARG_WITH( [module-prefix],
65394f61 464 AS_HELP_STRING([--with-module-prefix], [module object code [LIBDIR/znc]]),
759d11fc 465 [MODDIR=$withval],
608fbdbd 466 [MODDIR="${libdir}/znc"] )
467
468AC_ARG_WITH( [module-data-prefix],
9c4a5a1d 469 AS_HELP_STRING([--with-module-data-prefix=DIR],
65394f61 470 [static module data (webadmin skins) [DATADIR/znc]]),
608fbdbd 471 [DATADIR=$withval],
472 [DATADIR="${datadir}/znc"] )
473
57cfa950 474appendMod "$CXXFLAGS"
ea589120 475appendMod "$CFLAG_VISIBILITY"
6d957ed9 476
37b70a29 477if test -z "$ISSUN" -a -z "$ISDARWIN" -a -z "$ISCYGWIN"; then
57cfa950 478 # This is an unknown compiler flag on some OS
479 appendLD -Wl,--export-dynamic
480fi
90cf81e6 481
57cfa950 482if test -z "$ISCYGWIN" ; then
483 # cygwin doesn't need -fPIC, everything else does (for modules)
484 # warning: -fPIC ignored for target (all code is position independent)
485 appendMod -fPIC
486else
d252a2b4 487 # But cygwin does want most of ZNC in a shared lib
2dbd8378 488 # See https://cygwin.com/ml/cygwin-apps/2015-07/msg00108.html for the reasoning behind the name.
c336ef5e 489 LIBZNC="cygznc-${LIBZNC_VERSION}.dll"
37b70a29 490 LIBZNCDIR="$bindir"
90ae7853
AS
491 # See above about __STRICT_ANSI__
492 qt_CFLAGS="$qt_CFLAGS -U__STRICT_ANSI__"
57cfa950 493fi
2814df8f 494
57cfa950 495if test -z "$ISDARWIN"; then
496 MODLINK="-shared"
497else
498 # Mac OS X differentiates between shared libs (-dynamiclib)
499 # and loadable modules (-bundle).
500 MODLINK="-bundle -flat_namespace -undefined suppress"
501 # TODO test if -twolevel_namespace and/or
502 # -undefined dynamic_lookup work
503 # (dynamic_lookup might only work on 10.4 and later)
504fi
34337d7b 505
a564e25c 506if test "x$PERL" != xno -o "x$PYTHON" != xno; then
7d912d1d
AS
507 old_USESWIG="$USESWIG"
508 if test "x$USESWIG" != "xno"; then
1f89b67a 509 AC_PROG_SWIG([3.0.0])
7d912d1d 510 test -z "$SWIG" && USESWIG=no
3d152b16 511 if test "x$USESWIG" = xno -a "x$old_USESWIG" = yes; then
16f510f8 512 AC_MSG_ERROR([Could not found appropriate SWIG installation. Check config.log for details.])
3d152b16 513 fi
a564e25c 514 fi
561a1805 515 if test -r "$srcdir/modules/modperl/generated.tar.gz" -a -r "$srcdir/modules/modpython/generated.tar.gz"; then
b1b92468
AS
516 AC_MSG_NOTICE([modperl/modpython files are found, disabling SWIG])
517 USESWIG=no
518 fi
7d912d1d 519 if test "x$USESWIG" = xno; then
561a1805 520 if test ! -r "$srcdir/modules/modperl/generated.tar.gz" -o ! -r "$srcdir/modules/modpython/generated.tar.gz"; then
cc52a7d2 521 AC_MSG_ERROR([Can not build modperl/modpython. Either install SWIG, or build ZNC from a tarball, or disable modperl/modpython. Check config.log for details.])
a564e25c 522 else
cc52a7d2 523 AC_MSG_NOTICE([modperl/modpython files are found, no SWIG needed])
a564e25c 524 fi
44d8aaa1 525 USESWIG="not needed"
3d152b16 526 SWIG=""
a564e25c 527 else
7d912d1d 528 USESWIG=yes
a564e25c 529 fi
530else
7d912d1d 531 if test "x$USESWIG" = "xyes"; then
3d152b16 532 AC_MSG_WARN([swig is used only for perl and python, but both are disabled. Disabling swig.])
a564e25c 533 fi
54f558a4 534 USESWIG='not needed'
a564e25c 535fi
536
4676fa0a 537PERL_TEXT="$PERL"
57cfa950 538if test "x$PERL" != "xno"; then
539 old_PERL="$PERL"
540 AC_PATH_PROG([PERL_BINARY], [perl], [])
0bc606a9 541 if test -n "$PERL_BINARY" && eval "$PERL_BINARY -e'use 5.010'"; then
57cfa950 542 my_saved_LDFLAGS="$LDFLAGS"
543 appendLD `$PERL_BINARY -MExtUtils::Embed -e ccopts -e ldopts`
5f1a1d01 544 AC_CHECK_LIB(perl, perl_alloc,
545 [: No, we do not want autoconf to do sth automatically],
4676fa0a 546 PERL="no" ; PERL_TEXT="no (libperl not found)")
57cfa950 547 LDFLAGS="$my_saved_LDFLAGS"
90cf81e6 548 else
57cfa950 549 PERL="no"
4676fa0a 550 PERL_TEXT="no (perl binary not found or too old)"
6d957ed9 551 fi
57cfa950 552 if test "x$PERL" = "xno"; then
553 ZNC_AUTO_FAIL([PERL],
554 [perl not found. Try --disable-perl.],
555 [perl was not found and thus disabled])
39a215f3 556 PERL_BINARY=""
57cfa950 557 else
a564e25c 558 PERL="yes"
4676fa0a 559 PERL_TEXT="yes"
a564e25c 560 fi
561fi
562
4676fa0a 563PYTHON_TEXT="$PYTHON"
a564e25c 564if test "x$PYTHON" != "xno"; then
565 # Default value for just --enable-python
566 if test "x$PYTHON" = "xyes"; then
ba915eb9 567 PYTHON="python3"
a564e25c 568 fi
569 old_PYTHON="$PYTHON"
ba915eb9
AS
570 if test -z "$PKG_CONFIG"; then
571 AC_MSG_ERROR([pkg-config is required for modpython.])
572 fi
573 PKG_CHECK_MODULES([python], [$PYTHON >= 3.0],, AC_MSG_ERROR([$PYTHON.pc not found or is wrong. Try --disable-python or install python3.]))
574 my_saved_LIBS="$LIBS"
63250c2b 575 my_saved_CXXFLAGS="$CXXFLAGS"
ba915eb9
AS
576 appendLib $python_LIBS
577 appendCXX $python_CFLAGS
4676fa0a 578 AC_CHECK_FUNC([Py_Initialize], [], [PYTHON="no" ; PYTHON_TEXT="no (libpython not found)"])
ba915eb9
AS
579 if test "x$PYTHON" != "xno"; then
580 # Yes, modpython depends on perl.
581 AC_PATH_PROG([PERL_BINARY], [perl])
582 if test -z "$PERL_BINARY"; then
583 AC_MSG_ERROR([To compile modpython you need to be able to execute perl scripts. Try --disable-python or install perl.])
a44e6eaa 584 fi
e17348ca 585 LIBS="$my_saved_LIBS"
ba915eb9 586 CXXFLAGS="$my_saved_CXXFLAGS"
a564e25c 587 fi
4fe4a45d
AS
588 if test "x$HAVE_ICU" != "xyes"; then
589 AC_MSG_ERROR([Modpython requires ZNC to be compiled with charset support, but ICU library not found. Try --disable-python or install libicu.])
590 fi
a564e25c 591 if test "x$PYTHON" = "xno"; then
592 ZNC_AUTO_FAIL([PYTHON],
593 [python not found. Try --disable-python.],
594 [python was not found and thus disabled])
595 PYTHONCFG_BINARY=""
596 else
597 PYTHON="yes"
4676fa0a 598 PYTHON_TEXT="yes"
6d957ed9 599 fi
57cfa950 600fi
b0f94ba4 601
63ab3c09 602if test -n "$CYRUS"; then
57cfa950 603 AC_CHECK_LIB( sasl2, sasl_server_init,
604 [: Dont let autoconf add -lsasl2, Makefile handles that],
63ab3c09 605 AC_MSG_ERROR([could not find libsasl2. Try --disable-cyrus.]))
57cfa950 606fi
61449c6f 607
57cfa950 608# Check if we want modtcl
609AC_ARG_ENABLE( [tcl],
610 AS_HELP_STRING([--enable-tcl], [enable modtcl]),
611 [TCL="$enableval"],
612 [TCL="no"])
613
614AC_ARG_WITH( [tcl-flags],
615 AS_HELP_STRING([--with-tcl-flags=FLAGS],
616 [The flags needed for compiling and linking modtcl]),
617 [TCL_FLAGS="$withval"],)
618
619if test x"$TCL" = "xyes"
620then
621 AC_ARG_WITH( [tcl],
622 AS_HELP_STRING([--with-tcl=DIR],
623 [directory containing tclConfig.sh]),
624 TCL_DIR="${withval}")
625
626 # This will need to be extended in the future, but I don't think
627 # it's a good idea to stuff a shitload of random stuff in here right now
398e9dec 628 for path in $TCL_DIR /usr/lib /usr/lib/tcl8.4 /usr/lib/tcl8.5 /usr/lib/tcl8.6
57cfa950 629 do
630 file="${path}/tclConfig.sh"
d9b4ba18 631 AC_MSG_CHECKING([for ${file}])
632 if test -r ${file}
633 then
634 TCL_CONF=${file}
635 AC_MSG_RESULT([yes])
636 break
637 fi
638 AC_MSG_RESULT([no])
57cfa950 639 done
640
641 if test x"${TCL_CONF}" = x
61449c6f 642 then
57cfa950 643 # They --enable-tcl'd, so give them some sane default
644 TCL_FLAGS="-I/usr/include/tcl -ltcl"
645 AC_MSG_WARN([Could not find tclConfig.sh, using some sane defaults.])
646 else
647 AC_MSG_CHECKING([modtcl flags])
648 . ${TCL_CONF}
649 # eval because those vars depend on other vars in there
650 eval "TCL_LIB_SPEC=\"${TCL_LIB_SPEC}\""
651 eval "TCL_INCLUDE_SPEC=\"${TCL_INCLUDE_SPEC}\""
652 TCL_FLAGS="$TCL_INCLUDE_SPEC $TCL_LIB_SPEC"
653 AC_MSG_RESULT([$TCL_FLAGS])
61449c6f 654 fi
e17348ca 655 my_saved_LIBS="$LIBS"
656 appendLib "$TCL_FLAGS"
89bd5275 657 AC_CHECK_FUNC([Tcl_CreateInterp], [TCL_TEST=yes], [TCL_TEST=no])
658 if test x"$TCL_TEST" = "xno"; then
7b9d7094 659 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])
89bd5275 660 fi
e17348ca 661 LIBS="$my_saved_LIBS"
d9591e95 662fi
663
797b0a7f
AS
664AC_CACHE_CHECK([for GNU make], [ac_cv_path_GNUMAKE], [
665 AC_PATH_PROGS_FEATURE_CHECK([GNUMAKE], [make gmake], [[
666 if $ac_path_GNUMAKE --version | $GREP GNU > /dev/null; then
667 ac_cv_path_GNUMAKE=$ac_path_GNUMAKE
668 ac_path_GNUMAKE_found=:
669 fi
670 ]], [AC_MSG_ERROR([could not find GNU make])]
671 )
672])
a08d737c 673GNUMAKE=`echo $ac_cv_path_GNUMAKE | $SED "s%.*/%%"`
797b0a7f 674
1c06af3b
AS
675# this is in the end, for not trying to include it when it doesn't exist yet
676appendCXX "-include znc/zncconfig.h"
a83c8239 677appendMod "-include znc/zncconfig.h"
1c06af3b 678
d9591e95 679AC_SUBST([CXXFLAGS])
9c4a5a1d 680AC_SUBST([CPPFLAGS])
49fb58f7 681AC_SUBST([MODFLAGS])
0a622749 682AC_SUBST([LDFLAGS])
d9591e95 683AC_SUBST([LIBS])
432a04e5 684AC_SUBST([LIBZNC])
685AC_SUBST([LIBZNCDIR])
f94cb24f 686AC_SUBST([ISCYGWIN])
90cf81e6 687AC_SUBST([MODLINK])
3e868c5c 688AC_SUBST([NOSSL])
61449c6f 689AC_SUBST([TCL_FLAGS])
63ab3c09 690AC_SUBST([CYRUS])
44c5f493 691AC_SUBST([MODDIR])
608fbdbd 692AC_SUBST([DATADIR])
c7c0d171 693AC_SUBST([PERL])
ba915eb9 694AC_SUBST([PYTHON])
7d912d1d 695AC_SUBST([SWIG])
ba915eb9
AS
696AC_SUBST([python_CFLAGS])
697AC_SUBST([python_LIBS])
90ae7853
AS
698AC_SUBST([qt_CFLAGS])
699AC_SUBST([qt_LIBS])
d9591e95 700AC_CONFIG_FILES([Makefile])
97a85e39 701AC_CONFIG_FILES([znc-buildmod])
f59b7122 702AC_CONFIG_FILES([man/Makefile])
bbb62bed 703AC_CONFIG_FILES([znc.pc])
704AC_CONFIG_FILES([znc-uninstalled.pc])
f72e2f8a 705AC_CONFIG_FILES([modules/Makefile])
d9591e95 706AC_OUTPUT
c3872985 707
700c8996
AS
708if test "x$ISCYGWIN" = x1; then
709 # Side effect of undefining __STRICT_ANSI__
710 # http://llvm.org/bugs/show_bug.cgi?id=13530
711 echo >> include/znc/zncconfig.h
712 echo '#ifndef ZNCCONFIG_H_ADDITIONS' >> include/znc/zncconfig.h
713 echo '#define ZNCCONFIG_H_ADDITIONS' >> include/znc/zncconfig.h
714 echo '#ifdef __clang__' >> include/znc/zncconfig.h
715 echo 'struct __float128;' >> include/znc/zncconfig.h
716 echo '#endif' >> include/znc/zncconfig.h
717 echo '#endif' >> include/znc/zncconfig.h
718fi
719
c3872985 720echo
d252a2b4 721echo ZNC AC_PACKAGE_VERSION configured
c3872985 722echo
6d33c570 723echo "prefix: $prefix"
d72fc441 724echo "debug: $DEBUG"
725echo "ipv6: $IPV6"
4676fa0a 726echo "openssl: $SSL_TEXT"
717d0596 727echo "dns: $DNS_TEXT"
4676fa0a
US
728echo "perl: $PERL_TEXT"
729echo "python: $PYTHON_TEXT"
7d912d1d 730echo "swig: $USESWIG"
63ab3c09
KF
731if test x"$CYRUS" = "x" ; then
732 echo "cyrus: no"
3f27be8b 733else
63ab3c09 734 echo "cyrus: yes"
3f27be8b 735fi
61449c6f 736if test x"$TCL_FLAGS" = "x" ; then
d72fc441 737 echo "tcl: no"
738else
739 echo "tcl: yes"
740fi
cfc12271 741echo "charset: $HAVE_ICU"
4676fa0a 742echo "zlib: $ZLIB_TEXT"
d72fc441 743echo "run from src: $RUNFROMSOURCE"
797b0a7f
AS
744echo
745echo "Now you can run \"$GNUMAKE\" to compile ZNC"
d72fc441 746