]> jfr.im git - irc/rizon/znc.git/blob - configure.ac
Increase the version number to 0.204
[irc/rizon/znc.git] / configure.ac
1 dnl Needed for AC_PATH_PROGS_FEATURE_CHECK which was added in 2.62
2 AC_PREREQ([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])
7 AC_LANG([C++])
8 AC_CONFIG_HEADERS([zncconfig.h])
9 AH_TOP([#ifndef ZNCCONFIG_H
10 #define ZNCCONFIG_H])
11 AH_BOTTOM([#endif /* ZNCCONFIG_H */])
12
13 AC_DEFUN([ZNC_AUTO_FAIL], [
14 # This looks better in the summary at the end
15 $1="not found"
16 if test "x$old_$1" != "xauto" ; then
17 AC_MSG_ERROR([$2])
18 else
19 AC_MSG_WARN([$3])
20 fi
21 ])
22
23 # AC_PROG_CXX sets CXXFLAGS to "-O2 -g" if it is unset which we don't want
24 CXXFLAGS="$CXXFLAGS "
25 AC_PROG_CXX
26 AC_PROG_INSTALL
27 AC_PROG_GREP
28 AC_PROG_SED
29 AC_CANONICAL_HOST
30 AC_SYS_LARGEFILE
31 gl_VISIBILITY
32
33 appendLib () {
34 if test "$LIBS" != ""; then
35 LIBS="$LIBS $*"
36 else
37 LIBS=$*
38 fi
39 }
40
41 appendCXX () {
42 if test "$CXXFLAGS" != ""; then
43 CXXFLAGS="$CXXFLAGS $*"
44 else
45 CXXFLAGS=$*
46 fi
47 }
48
49 appendMod () {
50 if test "$MODFLAGS" != ""; then
51 MODFLAGS="$MODFLAGS $*"
52 else
53 MODFLAGS=$*
54 fi
55 }
56
57 appendLD () {
58 if test "$LDFLAGS" != ""; then
59 LDFLAGS="$LDFLAGS $*"
60 else
61 LDFLAGS=$*
62 fi
63 }
64
65 appendCXX "-D_FORTIFY_SOURCE=2"
66
67 case "${host_os}" in
68 freebsd*)
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
73 ;;
74 solaris*)
75 appendLib -lsocket -lnsl -lresolv
76 ISSUN=1
77 ;;
78 cygwin)
79 ISCYGWIN=1
80 ;;
81 darwin*)
82 ISDARWIN=1
83 ;;
84 esac
85
86 AC_ARG_WITH( [openssl],
87 AS_HELP_STRING([--with-openssl=DIR], [openssl installation prefix]),
88 [OPENSSL=$withval],)
89 AC_ARG_ENABLE( [extra],
90 AS_HELP_STRING([--enable-extra], [enable some extra modules]),
91 [EXTRA="$enableval"],
92 [EXTRA="no"])
93 AC_ARG_ENABLE( [debug],
94 AS_HELP_STRING([--enable-debug], [enable debugging]),
95 [DEBUG="$enableval"],
96 [DEBUG="no"])
97 AC_ARG_ENABLE( [ipv6],
98 AS_HELP_STRING([--disable-ipv6], [disable ipv6 support]),
99 [IPV6="$enableval"],
100 [IPV6="yes"])
101 AC_ARG_ENABLE( [openssl],
102 AS_HELP_STRING([--disable-openssl], [disable openssl]),
103 [SSL="$enableval"],
104 [SSL="auto"])
105 AC_ARG_ENABLE( [perl],
106 AS_HELP_STRING([--enable-perl], [enable perl]),
107 [PERL="$enableval"],
108 [PERL="no"])
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"],
114 [PYTHON="no"])
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"],
121 [USESWIG="auto"])
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"],
129 [OPTIMIZE="yes"])
130 AC_ARG_ENABLE( [c-ares],
131 AS_HELP_STRING([--disable-c-ares], [disable c-ares usage]),
132 [ARES="$enableval"],
133 [ARES="auto"])
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])
139 fi
140 RUNFROMSOURCE="$enableval"],
141 [RUNFROMSOURCE="no"])
142 AC_ARG_ENABLE( [poll],
143 AS_HELP_STRING([--disable-poll], [use select() instead of poll()]),
144 [POLL="$enableval"],
145 [POLL="yes"])
146
147 if test "$DEBUG" != "no"; then
148 appendCXX -ggdb
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++])
154 else
155 if test "x$OPTIMIZE" = "xyes"; then
156 appendCXX -O2
157 fi
158 fi
159
160 if test "$IPV6" != "no"; then
161 AC_DEFINE([HAVE_IPV6], [1], [Define if IPv6 support is enabled])
162 fi
163
164 if test "x$GXX" = "xyes"; then
165 appendCXX -Wall -W -Wno-unused-parameter -Woverloaded-virtual -Wshadow
166 fi
167
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"
171 then
172 # Did they give us --enable-poll?
173 if test -n "$enable_poll"
174 then
175 # Yes, they asked for this.
176 AC_MSG_WARN([poll() is known to be broken on Mac OS X. You have been warned.])
177 else
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.])
181 POLL=no
182 fi
183 fi
184 if test "$POLL" = "yes"; then
185 AC_DEFINE([CSOCK_USE_POLL], [1], [Use poll() instead of select()])
186 fi
187 fi
188
189 AC_CHECK_LIB( gnugetopt, getopt_long,)
190 AC_CHECK_FUNCS([lstat getopt_long getphassphrase])
191 PKG_PROG_PKG_CONFIG()
192
193 # ----- Check for dlopen
194
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.])])
197
198 # ----- Check for c-ares
199
200 if test "x$ARES" != "xno"; then
201 old_ARES=$ARES
202 if test -z "$PKG_CONFIG"
203 then
204 ARES=no
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])
209 else
210 PKG_CHECK_MODULES([c_ares], [libcares >= 1.5.0],, ARES=no)
211
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])
217 else
218 AC_DEFINE([HAVE_C_ARES], [1], [Define if c-ares is enabled])
219 appendCXX $c_ares_CFLAGS
220 appendLib $c_ares_LIBS
221 ARES=yes
222 fi
223 fi
224 fi
225
226 # ----- Check for openssl
227
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"
234 fi
235
236 old_SSL=$SSL
237 PKG_CHECK_MODULES([openssl], [openssl], [
238 appendLib "$openssl_LIBS"
239 appendCXX "$openssl_CFLAGS"
240 ], [
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 )
245 ])
246
247 if test "x$SSL" = "xno" ; then
248 ZNC_AUTO_FAIL([SSL],
249 [OpenSSL not found. Try --disable-openssl.],
250 [OpenSSL was not found and thus disabled])
251 NOSSL=1
252 else
253 AC_DEFINE([HAVE_LIBSSL], [1], [Define if openssl is enabled])
254 SSL=yes
255 fi
256 else
257 NOSSL=1
258 fi
259
260 AC_ARG_WITH( [module-prefix],
261 AS_HELP_STRING([--with-module-prefix], [module object code [LIBDIR/znc]]),
262 [MODDIR=$withval],
263 [MODDIR="${libdir}/znc"] )
264
265 AC_ARG_WITH( [module-data-prefix],
266 AS_HELP_STRING([--with-module-data-prefix=DIR],
267 [static module data (webadmin skins) [DATADIR/znc]]),
268 [DATADIR=$withval],
269 [DATADIR="${datadir}/znc"] )
270
271 appendMod "$CXXFLAGS"
272 appendMod "$CFLAG_VISIBILITY"
273
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
277 fi
278
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)
282 appendMod -fPIC
283 else
284 # But cygwin does want most of znc in a shared lib
285 LIBZNC="libznc.dll"
286 LIBZNCDIR="$bindir"
287 fi
288
289 if test -z "$ISDARWIN"; then
290 MODLINK="-shared"
291 else
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)
298 fi
299
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
305 fi
306 if test "x$USESWIG" = xno; then
307 SWIG=""
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.])
313 else
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.])
316 fi
317 else
318 USESWIG=yes
319 fi
320 else
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.])
323 fi
324 USESWIG=no
325 fi
326
327 if test "x$PERL" != "xno"; then
328 old_PERL="$PERL"
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],
335 PERL="no")
336 LDFLAGS="$my_saved_LDFLAGS"
337 else
338 PERL="no"
339 fi
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])
344 PERL_BINARY=""
345 else
346 PERL="yes"
347 fi
348 fi
349
350 if test "x$PYTHON" != "xno"; then
351 # Default value for just --enable-python
352 if test "x$PYTHON" = "xyes"; then
353 PYTHON="python3"
354 fi
355 old_PYTHON="$PYTHON"
356 if test -z "$PKG_CONFIG"; then
357 AC_MSG_ERROR([pkg-config is required for modpython.])
358 fi
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])
367 fi
368 fi
369 fi
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.])
380 fi
381 LIBS="$my_saved_LIBS"
382 CXXFLAGS="$my_saved_CXXFLAGS"
383 else
384 PYTHON="no"
385 fi
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])
390 PYTHONCFG_BINARY=""
391 else
392 PYTHON="yes"
393 fi
394 fi
395
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.]))
400 fi
401
402 # Check if we want modtcl
403 AC_ARG_ENABLE( [tcl],
404 AS_HELP_STRING([--enable-tcl], [enable modtcl]),
405 [TCL="$enableval"],
406 [TCL="no"])
407
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"],)
412
413 if test x"$TCL" = "xyes"
414 then
415 AC_ARG_WITH( [tcl],
416 AS_HELP_STRING([--with-tcl=DIR],
417 [directory containing tclConfig.sh]),
418 TCL_DIR="${withval}")
419
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
423 do
424 file="${path}/tclConfig.sh"
425 AC_MSG_CHECKING([for ${file}])
426 if test -r ${file}
427 then
428 TCL_CONF=${file}
429 AC_MSG_RESULT([yes])
430 break
431 fi
432 AC_MSG_RESULT([no])
433 done
434
435 if test x"${TCL_CONF}" = x
436 then
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.])
440 else
441 AC_MSG_CHECKING([modtcl flags])
442 . ${TCL_CONF}
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])
448 fi
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])
454 fi
455 LIBS="$my_saved_LIBS"
456 fi
457
458 if test x"$EXTRA" = "xyes"
459 then
460 AC_CHECK_FUNC( iconv, CHARSET=1 )
461 AC_CHECK_LIB( iconv, iconv_open, LIBICONV=-liconv ; CHARSET=1 )
462 if test "x$CHARSET" = "x1"
463 then
464 AC_MSG_CHECKING([whether iconv expects a const second argument])
465 AC_COMPILE_IFELSE([
466 AC_LANG_PROGRAM([[
467 #include <iconv.h>
468 ]], [[
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);
473 ]])], [
474 AC_MSG_RESULT([no])
475 appendMod -DICONV_CONST=
476 ], [
477 AC_MSG_RESULT([yes])
478 appendMod -DICONV_CONST=const
479 ])
480 else
481 AC_MSG_WARN([libiconv was not found, disabling the charset module])
482 fi
483 fi
484
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=:
490 fi
491 ]], [AC_MSG_ERROR([could not find GNU make])]
492 )
493 ])
494 GNUMAKE_DIRNAME=`AS_DIRNAME(["$ac_cv_path_GNUMAKE"])`
495 GNUMAKE=`echo $ac_cv_path_GNUMAKE | $SED "s%$GNUMAKE_DIRNAME/%%"`
496
497 AC_SUBST([CXXFLAGS])
498 AC_SUBST([CPPFLAGS])
499 AC_SUBST([MODFLAGS])
500 AC_SUBST([LDFLAGS])
501 AC_SUBST([LIBS])
502 AC_SUBST([LIBZNC])
503 AC_SUBST([LIBZNCDIR])
504 AC_SUBST([MODLINK])
505 AC_SUBST([NOSSL])
506 AC_SUBST([EXTRA])
507 AC_SUBST([TCL_FLAGS])
508 AC_SUBST([SASL])
509 AC_SUBST([CHARSET])
510 AC_SUBST([LIBICONV])
511 AC_SUBST([MODDIR])
512 AC_SUBST([DATADIR])
513 AC_SUBST([PERL])
514 AC_SUBST([PYTHON])
515 AC_SUBST([SWIG])
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])
526 AC_OUTPUT
527
528 echo
529 echo znc AC_PACKAGE_VERSION configured
530 echo
531 echo "prefix: $prefix"
532 echo "debug: $DEBUG"
533 echo "ipv6: $IPV6"
534 echo "openssl: $SSL"
535 echo "c-ares: $ARES"
536 echo "perl: $PERL"
537 echo "python: $PYTHON"
538 echo "swig: $USESWIG"
539 if test x"$SASL" = "x" ; then
540 echo "sasl: no"
541 else
542 echo "sasl: yes"
543 fi
544 echo "extra: $EXTRA"
545 if test x"$TCL_FLAGS" = "x" ; then
546 echo "tcl: no"
547 else
548 echo "tcl: yes"
549 fi
550 if test x"$CHARSET" = "x" ; then
551 echo "charset: no"
552 else
553 echo "charset: yes"
554 fi
555 echo "run from src: $RUNFROMSOURCE"
556 echo
557 echo "Now you can run \"$GNUMAKE\" to compile ZNC"
558