]> jfr.im git - irc/unrealircd/unrealircd.git/blob - configure.ac
./Config: import settings from UnrealIRCd 6.1.5
[irc/unrealircd/unrealircd.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2
3 dnl When updating the version, remember to update the following files
4 dnl appropriately:
5 dnl include/windows/setup.h
6 dnl src/windows/unrealinst.iss
7 dnl doc/Config.header
8 dnl src/version.c.SH
9
10 AC_INIT([unrealircd], [6.1.6-rc1], [https://bugs.unrealircd.org/], [], [https://unrealircd.org/])
11 AC_CONFIG_SRCDIR([src/ircd.c])
12 AC_CONFIG_HEADER([include/setup.h])
13 AC_CONFIG_AUX_DIR([autoconf])
14 AC_CONFIG_MACRO_DIR([autoconf/m4])
15
16 if test "x$enable_dynamic_linking" = "x"; then
17 echo "Please use ./Config instead of ./configure"
18 exit 1
19 fi
20
21 dnl Save CFLAGS, use this when building the libraries like c-ares
22 orig_cflags="$CFLAGS"
23
24 dnl Save build directory early on (used in our m4 macros too)
25 BUILDDIR_NOW="`pwd`"
26
27 dnl Calculate the versions. Perhaps the use of expr is a little too extravagant
28 # Generation version number (e.g.: X in X.Y.Z)
29 UNREAL_VERSION_GENERATION=["6"]
30 AC_DEFINE_UNQUOTED([UNREAL_VERSION_GENERATION], [$UNREAL_VERSION_GENERATION], [Generation version number (e.g.: X for X.Y.Z)])
31
32 # Major version number (e.g.: Y in X.Y.Z)
33 UNREAL_VERSION_MAJOR=["1"]
34 AC_DEFINE_UNQUOTED([UNREAL_VERSION_MAJOR], [$UNREAL_VERSION_MAJOR], [Major version number (e.g.: Y for X.Y.Z)])
35
36 # Minor version number (e.g.: Z in X.Y.Z)
37 UNREAL_VERSION_MINOR=["6"]
38 AC_DEFINE_UNQUOTED([UNREAL_VERSION_MINOR], [$UNREAL_VERSION_MINOR], [Minor version number (e.g.: Z for X.Y.Z)])
39
40 # The version suffix such as a beta marker or release candidate
41 # marker. (e.g.: -rcX for unrealircd-3.2.9-rcX). This macro is a
42 # string instead of an integer because it contains arbitrary data.
43 UNREAL_VERSION_SUFFIX=["-rc1"]
44 AC_DEFINE_UNQUOTED([UNREAL_VERSION_SUFFIX], ["$UNREAL_VERSION_SUFFIX"], [Version suffix such as a beta marker or release candidate marker. (e.g.: -rcX for unrealircd-3.2.9-rcX)])
45
46 AC_PATH_PROG(RM,rm)
47 AC_PATH_PROG(CP,cp)
48 AC_PATH_PROG(TOUCH,touch)
49 AC_PATH_PROG(OPENSSLPATH,openssl)
50 AS_IF([test x"$OPENSSLPATH" = "x"],
51 [
52 echo ""
53 echo "Apparently you do not have both the openssl binary and openssl development libraries installed."
54 echo "The following packages are required:"
55 echo "1) The library package is often called 'openssl-dev', 'openssl-devel' or 'libssl-dev'"
56 echo "2) The binary package is usually called 'openssl'."
57 echo "NOTE: you or your system administrator needs to install the library AND the binary package."
58 echo "After doing so, simply re-run ./Config"
59 exit 1
60 ])
61
62 AC_PATH_PROG(INSTALL,install)
63 AC_PATH_PROG(GUNZIP, gunzip)
64 AC_PATH_PROG(PKGCONFIG, pkg-config)
65
66 dnl Check for compiler
67 AC_PROG_CC_C99
68 AS_IF([test "$ac_cv_prog_cc_c99" = "no"],
69 [AC_MSG_ERROR([No C99 compiler was found. Please install gcc or clang and other build tools. Eg, on Debian/Ubuntu you probably want to run the following as root: apt-get install build-essential ])])
70
71 dnl Check for make moved down, so the above compiler check takes precedence.
72 AC_CHECK_PROG(MAKER, gmake, gmake, make)
73 AC_PATH_PROG(GMAKE,gmake)
74 AS_IF([$MAKER --version | grep -q "GNU Make"],
75 [GNUMAKE="0"],
76 [AC_MSG_ERROR([It seems your system does not have make/gmake installed. If you are on Linux then install make, otherwise install gmake.])])
77
78 dnl Checks for libraries.
79 AC_CHECK_LIB(descrypt, crypt,
80 [AC_DEFINE([HAVE_CRYPT], [], [Define if you have crypt])
81 IRCDLIBS="$IRCDLIBS-ldescrypt "],
82 [AC_CHECK_LIB(crypt, crypt,
83 [AC_DEFINE([HAVE_CRYPT], [], [Define if you have crypt])
84 IRCDLIBS="$IRCDLIBS-lcrypt "])])
85
86 dnl Check for big-endian system, even though these hardly exist anymore...
87 AS_CASE([$host_cpu],
88 [i?86|amd64|x86_64],
89 [ac_cv_c_bigendian=no]
90 )
91 AC_C_BIGENDIAN(
92 AC_DEFINE(NATIVE_BIG_ENDIAN, 1, [machine is bigendian]),
93 AC_DEFINE(NATIVE_LITTLE_ENDIAN, 1, [machine is littleendian]),
94 AC_MSG_ERROR([unknown endianness]),
95 AC_MSG_ERROR([universal endianness is not supported - compile separately and use lipo(1)])
96 )
97
98 dnl HARDENING START
99 dnl This is taken from https://github.com/kmcallister/autoharden
100 dnl With some very small modifications (to remove C++ checking for instance)
101 # We want to check for compiler flag support, but there is no way to make
102 # clang's "argument unused" warning fatal. So we invoke the compiler through a
103 # wrapper script that greps for this message.
104 saved_CC="$CC"
105 saved_CXX="$CXX"
106 saved_LD="$LD"
107 flag_wrap="$srcdir/extras/wrap-compiler-for-flag-check"
108 CC="$flag_wrap $CC"
109 CXX="$flag_wrap $CXX"
110 LD="$flag_wrap $LD"
111
112 # We use the same hardening flags for C and C++. We must check that each flag
113 # is supported by both compilers.
114 AC_DEFUN([check_cc_flag],
115 [AC_LANG_PUSH(C)
116 AX_CHECK_COMPILE_FLAG([$1], [$2], [$3], [-Werror $4])
117 AC_LANG_POP(C)])
118
119 AC_DEFUN([check_link_flag],
120 [AX_CHECK_LINK_FLAG([$1], [$2], [$3], [-Werror $4])])
121
122 AC_ARG_ENABLE([hardening],
123 [AS_HELP_STRING([--enable-hardening],
124 [Enable compiler and linker options to frustrate memory corruption exploits @<:@yes@:>@])],
125 [hardening="$enableval"],
126 [hardening="yes"])
127
128 HARDEN_CFLAGS=""
129 HARDEN_LDFLAGS=""
130 AS_IF([test x"$hardening" != x"no"], [
131 check_cc_flag([-fno-strict-overflow], [HARDEN_CFLAGS="$HARDEN_CFLAGS -fno-strict-overflow"])
132
133 # This one will likely succeed, even on platforms where it does nothing.
134 check_cc_flag([-D_FORTIFY_SOURCE=3], [HARDEN_CFLAGS="$HARDEN_CFLAGS -D_FORTIFY_SOURCE=3"])
135
136 check_cc_flag([-fstack-protector-all],
137 [check_link_flag([-fstack-protector-all],
138 [HARDEN_CFLAGS="$HARDEN_CFLAGS -fstack-protector-all"
139 check_cc_flag([-Wstack-protector], [HARDEN_CFLAGS="$HARDEN_CFLAGS -Wstack-protector"],
140 [], [-fstack-protector-all])
141 check_cc_flag([--param ssp-buffer-size=1], [HARDEN_CFLAGS="$HARDEN_CFLAGS --param ssp-buffer-size=1"],
142 [], [-fstack-protector-all])])])
143
144 # Added in UnrealIRCd 5.0.5 (default on Ubuntu 19.10)
145 check_cc_flag([-fstack-clash-protection], [HARDEN_CFLAGS="$HARDEN_CFLAGS -fstack-clash-protection"])
146
147 # Control Flow Enforcement (ROP hardening) - requires CPU hardware support
148 check_cc_flag([-fcf-protection], [HARDEN_CFLAGS="$HARDEN_CFLAGS -fcf-protection"])
149
150 # At the link step, we might want -pie (GCC) or -Wl,-pie (Clang on OS X)
151 #
152 # The linker checks also compile code, so we need to include -fPIE as well.
153 check_cc_flag([-fPIE],
154 [check_link_flag([-fPIE -pie],
155 [HARDEN_BINCFLAGS="-fPIE"
156 HARDEN_BINLDFLAGS="-pie"],
157 [check_link_flag([-fPIE -Wl,-pie],
158 [HARDEN_BINCFLAGS="-fPIE"
159 HARDEN_BINLDFLAGS="-Wl,-pie"])])])
160
161 check_link_flag([-Wl,-z,relro],
162 [HARDEN_LDFLAGS="$HARDEN_LDFLAGS -Wl,-z,relro"
163 check_link_flag([-Wl,-z,now], [HARDEN_LDFLAGS="$HARDEN_LDFLAGS -Wl,-z,now"])])])
164 AC_SUBST([HARDEN_CFLAGS])
165 AC_SUBST([HARDEN_LDFLAGS])
166 AC_SUBST([HARDEN_BINCFLAGS])
167 AC_SUBST([HARDEN_BINLDFLAGS])
168
169 # End of flag tests.
170 CC="$saved_CC"
171 CXX="$saved_CXX"
172 LD="$saved_LD"
173 dnl HARDENING END
174
175 dnl UnrealIRCd might not be strict-aliasing safe at this time
176 check_cc_flag([-fno-strict-aliasing], [CFLAGS="$CFLAGS -fno-strict-aliasing"])
177
178 dnl UnrealIRCd should be able to compile with -fno-common
179 dnl This also makes ASan (if it is in use) able to instrument these variables.
180 check_cc_flag([-fno-common], [CFLAGS="$CFLAGS -fno-common"])
181
182 dnl Previously -funsigned-char was in a config check. It would always
183 dnl be enabled with gcc and clang. We now unconditionally enable it,
184 dnl skipping the check. This will cause an error if someone uses a
185 dnl non-gcc/non-clang compiler that does not support -funsigned-char
186 dnl which is good. After all, we really depend on it.
187 dnl UnrealIRCd should never be compiled without char being unsigned.
188 CFLAGS="$CFLAGS -funsigned-char"
189
190 dnl Compiler -W checks...
191
192 dnl == ADD THESE WARNINGS ==
193
194 dnl We should be able to turn this on unconditionally:
195 CFLAGS="$CFLAGS -Wall"
196
197 dnl More warnings (if the compiler supports it):
198 check_cc_flag([-Wextra], [CFLAGS="$CFLAGS -Wextra"])
199 check_cc_flag([-Waggregate-return], [CFLAGS="$CFLAGS -Waggregate-return"])
200 check_cc_flag([-Wformat-nonliteral], [CFLAGS="$CFLAGS -Wformat-nonliteral"])
201
202 dnl The following few are more experimental, if they have false positives we'll have
203 dnl to disable them:
204 dnl Can't use this, too bad: check_cc_flag([-Wlogical-op], [CFLAGS="$CFLAGS -Wlogical-op"])
205 check_cc_flag([-Wduplicated-cond], [CFLAGS="$CFLAGS -Wduplicated-cond"])
206 check_cc_flag([-Wduplicated-branches], [CFLAGS="$CFLAGS -Wduplicated-branches"])
207
208 check_cc_flag([-Wparentheses], [CFLAGS="$CFLAGS -Wparentheses"])
209
210 dnl == REMOVE THESE WARNINGS ==
211
212 dnl And now to filter out certain warnings:
213 dnl [!] NOTE REGARDING THE check_cc_flag used by these:
214 dnl We check for the -Woption even though we are going to use -Wno-option.
215 dnl This is due to the following (odd) gcc behavior:
216 dnl "When an unrecognized warning option is requested (e.g.,
217 dnl -Wunknown-warning), GCC emits a diagnostic stating that the option is not
218 dnl recognized. However, if the -Wno- form is used, the behavior is slightly
219 dnl different: no diagnostic is produced for -Wno-unknown-warning unless
220 dnl other diagnostics are being produced. This allows the use of new -Wno-
221 dnl options with old compilers, but if something goes wrong, the compiler
222 dnl warns that an unrecognized option is present."
223 dnl Since we don't want to use any unrecognized -Wno-option, we test for
224 dnl -Woption instead.
225
226 dnl Pointer signedness warnings are really a pain and 99.9% of the time
227 dnl they are of absolutely no use whatsoever. IMO the person who decided
228 dnl to enable this without -Wall should be shot on sight.
229 check_cc_flag([-Wpointer-sign], [CFLAGS="$CFLAGS -Wno-pointer-sign"])
230
231 dnl This is purely for charsys.c... I like it so we can easily read
232 dnl this for non-utf8. We can remove it once we ditch non-utf8 some day
233 dnl of course, or decide to ignore me and encode them.
234 check_cc_flag([-Winvalid-source-encoding], [CFLAGS="$CFLAGS -Wno-invalid-source-encoding"])
235
236 check_cc_flag([-Wformat-zero-length], [CFLAGS="$CFLAGS -Wno-format-zero-length"])
237
238 check_cc_flag([-Wformat-truncation], [CFLAGS="$CFLAGS -Wno-format-truncation"])
239
240 check_cc_flag([-Wformat-overflow], [CFLAGS="$CFLAGS -Wno-format-overflow"])
241
242 dnl While it can be useful to occasionally to compile with warnings about
243 dnl unused variables and parameters, we often 'think ahead' when coding things
244 dnl so they may be useless now but not later. Similarly, for variables, we
245 dnl don't always care about a variable that may still be present in a build
246 dnl without DEBUGMODE. Unused variables are optimized out anyway.
247 check_cc_flag([-Wunused], [CFLAGS="$CFLAGS -Wno-unused"])
248 check_cc_flag([-Wunused-parameter], [CFLAGS="$CFLAGS -Wno-unused-parameter"])
249 check_cc_flag([-Wunused-but-set-parameter], [CFLAGS="$CFLAGS -Wno-unused-but-set-parameter"])
250
251 dnl We use this and this warning is meaningless since 'char' is always unsigned
252 dnl in UnrealIRCd compiles (-funsigned-char).
253 check_cc_flag([-Wchar-subscripts], [CFLAGS="$CFLAGS -Wno-char-subscripts"])
254
255 check_cc_flag([-Wsign-compare], [CFLAGS="$CFLAGS -Wno-sign-compare"])
256
257 dnl Don't warn about empty body, we use this, eg via Debug(()) or in if's.
258 check_cc_flag([-Wempty-body], [CFLAGS="$CFLAGS -Wno-empty-body"])
259
260 dnl This warns about all our hook calls - RunHook() and others
261 check_cc_flag([-Wdeprecated-non-prototype], [CFLAGS="$CFLAGS -Wno-deprecated-non-prototype"])
262
263 dnl Yeah this old clang version is a bit problematic
264 dnl (ships in Ubuntu 16.04 for example)
265 dnl -Wtautological-compare has false positives
266 dnl -Wno-pragmas is needed, despite -Wno-unknown-warning-option
267 AS_IF([$CC --version | grep -q "clang version 3."],
268 [CFLAGS="$CFLAGS -Wno-tautological-compare -Wno-pragmas"])
269
270 dnl This one MUST be LAST!!
271 dnl It disables -Wsomeunknownoption being an error. Which is needed for
272 dnl the pragma's in individual files to selectively disable some warnings
273 dnl on clang/gcc (that may exist in eg gcc but not in clang or vice versa).
274 check_cc_flag([-Wpragmas], [no_pragmas=1],[no_pragmas=0])
275 check_cc_flag([-Wunknown-warning-option], [unknown_warning_option=1], [unknown_warning_option=0])
276
277 if test "$unknown_warning_option" = "1"; then
278 dnl This is the best option
279 CFLAGS="$CFLAGS -Wno-unknown-warning-option"
280 else
281 if test "$no_pragmas" = "1"; then
282 dnl This is a fallback needed for older gcc/clang, it also
283 dnl disables several other useful warnings/errors related
284 dnl to pragma's unfortunately.
285 CFLAGS="$CFLAGS -Wno-pragmas"
286 fi
287 fi
288
289 dnl End of -W... compiler checks.
290
291
292 dnl module checking based on Hyb7's module checking code
293 AC_DEFUN([AC_ENABLE_DYN],
294 [
295 AC_CHECK_FUNC(dlopen,, [AC_CHECK_LIB(dl, dlopen,IRCDLIBS="$IRCDLIBS -ldl",
296 [
297 AC_MSG_WARN(Dynamic linking is not enabled because dlopen was not found)
298 AC_DEFINE(STATIC_LINKING)
299 ])])
300
301 hold_cflags=$CFLAGS
302 DYNAMIC_LDFLAGS=""
303 CFLAGS="$CFLAGS -Wl,-export-dynamic"
304 AC_CACHE_CHECK(if we need the -export-dynamic flag, ac_cv_export_dynamic, [
305 AC_TRY_LINK(, [int i];, ac_cv_export_dynamic=yes, ac_cv_export_dynamic=no)])
306 CFLAGS=$hold_cflags
307 if test "$ac_cv_export_dynamic" = "yes"; then
308 DYNAMIC_LDFLAGS="-Wl,-export-dynamic"
309 fi
310
311 AC_CACHE_CHECK(for compiler option to produce PIC,ac_cv_pic,[
312 if test "$ac_cv_prog_gcc" = "yes"; then
313 ac_cv_pic="-fPIC -DPIC -shared"
314 case `uname -s` in
315 Darwin*[)]
316 ac_cv_pic="-std=gnu89 -bundle -flat_namespace -undefined suppress"
317 ;;
318 HP-UX*[)]
319 ac_cv_pic="-fPIC"
320 ;;
321 esac
322 else
323 case `uname -s` in
324 SunOS*[)]
325 ac_cv_pic="-KPIC -DPIC -G"
326 ;;
327 esac
328 fi
329 ])
330 AC_CACHE_CHECK(if your system prepends an underscore on symbols,ac_cv_underscore,[
331 cat >uscore.c << __EOF__
332 int main(void) {
333 return 0;
334 }
335 __EOF__
336 $CC -o uscore $CFLAGS uscore.c 1>&5
337 if test -z "`strings -a uscore |grep '^_main$'`"; then
338 ac_cv_underscore=no
339 else
340 ac_cv_underscore=yes
341 fi
342 rm -f uscore uscore.c
343 ])
344 dnl libtool has built-in tests that determine proper underscorage
345 if test "$ac_cv_underscore" = "yes"; then
346 AC_DEFINE([UNDERSCORE], [], [Define if your system prepends an underscore to symbols])
347 fi
348
349 MODULEFLAGS="$ac_cv_pic $DYNAMIC_LDFLAGS"
350 dnl DYNAMIC_LINKING is not meant to be defined in include/setup.h, it's
351 dnl defined in the Makefiles using -D. Having it defined globally will
352 dnl only cause braindamage and symbol collisions :-D.
353 dnl AC_DEFINE([DYNAMIC_LINKING], [], [Link dynamically as opposed to statically. (Dynamic linking is the only supported method of linking atm)])
354 ])
355
356 AC_CACHE_CHECK([if your system has IPv6 support], [ac_cv_ip6], [
357 AC_TRY_RUN([
358 #include <sys/types.h>
359 #include <sys/socket.h>
360 #include <stdlib.h>
361 int main(void) {
362 int s = socket(AF_INET6, SOCK_STREAM, 0);
363 exit(0); /* We only check if the code compiles, that's enough. We can deal with missing runtime IPv6 */
364 }
365 ],
366 [ac_cv_ip6=yes],
367 [ac_cv_ip6=no])
368 ])
369 if test "$ac_cv_ip6" = "no"; then
370 AC_MSG_ERROR([Your system does not support IPv6])
371 fi
372
373 AC_MSG_CHECKING([if you have getsockopt TCP_INFO])
374 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
375 [[#include <sys/types.h>
376 #include <stdlib.h>
377 #include <sys/socket.h>
378 #include <netinet/in.h>
379 #include <netinet/tcp.h>
380 #include <sys/socket.h>]],
381 [[
382 socklen_t optlen = sizeof(struct tcp_info);
383 struct tcp_info ti;
384 ti.tcpi_rtt = 0;
385 ti.tcpi_rttvar = 0;
386 #if defined(__FreeBSD__)
387 ti.__tcpi_pmtu = 0;
388 #else
389 ti.tcpi_pmtu = 0;
390 #endif
391 ti.tcpi_snd_cwnd = 0;
392 ti.tcpi_snd_mss = 0;
393 ti.tcpi_rcv_mss = 0;
394 getsockopt(0, IPPROTO_TCP, TCP_INFO, &ti, &optlen);
395 ]])],
396 [AC_DEFINE(HAVE_TCP_INFO, 1, [Have getsockopt TCP_INFO])
397 AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
398
399 AC_CHECK_HEADER(sys/syslog.h,
400 AC_DEFINE([SYSSYSLOGH], [], [Define if you have the <sys/syslog.h> header file.]))
401 AC_CHECK_HEADER(sys/rusage.h,
402 AC_DEFINE([RUSAGEH], [], [Define if you have the <sys/rusage.h> header file.]))
403 AC_CHECK_HEADER(glob.h,
404 AC_DEFINE([GLOBH], [], [Define if you have the <glob.h> header file.]))
405 AC_CHECK_HEADERS([stdint.h inttypes.h])
406
407 dnl Checks for library functions.
408 AC_CHECK_FUNCS(strlcpy,
409 AC_DEFINE([HAVE_STRLCPY], [], [Define if you have strlcpy. Otherwise, an internal implementation will be used!]))
410 AC_CHECK_FUNCS(strlcat,
411 AC_DEFINE([HAVE_STRLCAT], [], [Define if you have strlcat]))
412 AC_CHECK_FUNCS(strlncat,
413 AC_DEFINE([HAVE_STRLNCAT], [], [Define if you have strlncat]))
414 AC_CHECK_FUNCS(strlncpy,
415 AC_DEFINE([HAVE_STRLNCPY], [], [Define if you have strlncpy]))
416
417 AC_CHECK_FUNCS([getrusage],
418 [AC_DEFINE([GETRUSAGE_2], [], [Define if you have getrusage])],
419 [AC_CHECK_FUNCS([times],
420 [AC_DEFINE([TIMES_2], [], [Define if you have times])])])
421 AC_CHECK_FUNCS([setproctitle],
422 [AC_DEFINE([HAVE_SETPROCTITLE], [], [Define if you have setproctitle])],
423 [AC_CHECK_LIB([util],
424 [setproctitle],
425 [AC_DEFINE([HAVE_SETPROCTITLE], [], [Define if you have setproctitle])
426 IRCDLIBS="$IRCDLIBS-lutil"],
427 [
428 AC_EGREP_HEADER([#define.*PS_STRINGS.*],[sys/exec.h],
429 [AC_DEFINE([HAVE_PSSTRINGS],[], [Define if you have PS_STRINGS])],
430 [AC_CHECK_FUNCS([pstat],
431 [AC_DEFINE([HAVE_PSTAT], [], [Define if you have pstat])])])
432 ])
433 ]
434 )
435
436 AC_CHECK_FUNCS(explicit_bzero,AC_DEFINE([HAVE_EXPLICIT_BZERO], [], [Define if you have explicit_bzero]))
437 AC_CHECK_FUNCS(syslog,AC_DEFINE([HAVE_SYSLOG], [], [Define if you have syslog]))
438 AC_CHECK_FUNCS(strnlen,AC_DEFINE([HAVE_STRNLEN], [], [Define if you have strnlen]))
439 AC_SUBST(CRYPTOLIB)
440 AC_SUBST(MODULEFLAGS)
441 AC_SUBST(DYNAMIC_LDFLAGS)
442 AC_ARG_WITH(nick-history, [AS_HELP_STRING([--with-nick-history=length],[Specify the length of the nickname history])],
443 [AC_DEFINE_UNQUOTED([NICKNAMEHISTORYLENGTH], [$withval], [Set to the nickname history length you want])],
444 [AC_DEFINE([NICKNAMEHISTORYLENGTH], [2000], [Set to the nickname history length you want])])
445 AC_ARG_WITH(permissions, [AS_HELP_STRING([--with-permissions=permissions], [Specify the default permissions for
446 configuration files])],
447 dnl We have an apparently out-of-place 0 here because of a MacOSX bug and because
448 dnl we assume that a user thinks that `chmod 0600 blah' is the same as `chmod 600 blah'
449 dnl (#3189)
450 [AC_DEFINE_UNQUOTED([DEFAULT_PERMISSIONS], [0$withval], [The default permissions for configuration files. Set to 0 to prevent unrealircd from calling chmod() on the files.])],
451 [AC_DEFINE([DEFAULT_PERMISSIONS], [0600], [The default permissions for configuration files. Set to 0 to prevent unrealircd from calling chmod() on the files.])])
452
453 AC_ARG_WITH(bindir, [AS_HELP_STRING([--with-bindir=path],[Specify the directory for the unrealircd binary])],
454 [AC_DEFINE_UNQUOTED([BINDIR], ["$withval"], [Define the directory where the unrealircd binary is located])
455 BINDIR="$withval"],
456 [AC_DEFINE_UNQUOTED([BINDIR], ["$HOME/unrealircd/bin"], [Define the directory where the unrealircd binary is located])
457 BINDIR="$HOME/unrealircd/bin"])
458
459 AC_ARG_WITH(scriptdir, [AS_HELP_STRING([--with-scriptdir=path],[Specify the directory for the unrealircd start-stop script])],
460 [AC_DEFINE_UNQUOTED([SCRIPTDIR], ["$withval"], [Define the directory where the unrealircd start stop scripts is located])
461 SCRIPTDIR="$withval"],
462 [AC_DEFINE_UNQUOTED([SCRIPTDIR], ["$HOME/unrealircd"], [Define the directory where the unrealircd start stop scripts is located])
463 SCRIPTDIR="$HOME/unrealircd"])
464
465 AC_ARG_WITH(confdir, [AS_HELP_STRING([--with-confdir=path],[Specify the directory where configuration files are stored])],
466 [AC_DEFINE_UNQUOTED([CONFDIR], ["$withval"], [Define the location of the configuration files])
467 CONFDIR="$withval"],
468 [AC_DEFINE_UNQUOTED([CONFDIR], ["$HOME/unrealircd/conf"], [Define the location of the configuration files])
469 CONFDIR="$HOME/unrealircd/conf"])
470
471 dnl We have to pass the builddir as well, for the module manager
472 AC_ARG_WITH(builddir, [AS_HELP_STRING([--with-builddir=path],[Specify the build directory])],
473 [AC_DEFINE_UNQUOTED([BUILDDIR], ["$withval"], [Define the build directory])
474 BUILDDIR="$withval"],
475 [AC_DEFINE_UNQUOTED([BUILDDIR], ["$BUILDDIR_NOW"], [Specify the build directory])
476 BUILDDIR="$BUILDDIR_NOW"])
477
478 AC_ARG_WITH(modulesdir, [AS_HELP_STRING([--with-modulesdir=path],[Specify the directory for loadable modules])],
479 [AC_DEFINE_UNQUOTED([MODULESDIR], ["$withval"], [Define the location of the modules])
480 MODULESDIR="$withval"],
481 [AC_DEFINE_UNQUOTED([MODULESDIR], ["$HOME/unrealircd/modules"], [Define the location of the modules])
482 MODULESDIR="$HOME/unrealircd/modules"])
483
484 AC_ARG_WITH(logdir, [AS_HELP_STRING([--with-logdir=path],[Specify the directory where log files are stored])],
485 [AC_DEFINE_UNQUOTED([LOGDIR], ["$withval"], [Define the location of the log files])
486 LOGDIR="$withval"],
487 [AC_DEFINE_UNQUOTED([LOGDIR], ["$HOME/unrealircd/logs"], [Define the location of the log files])
488 LOGDIR="$HOME/unrealircd/logs"])
489
490 AC_ARG_WITH(cachedir, [AS_HELP_STRING([--with-cachedir=path],[Specify the directory where cached files are stored])],
491 [AC_DEFINE_UNQUOTED([CACHEDIR], ["$withval"], [Define the location of the cached remote include files])
492 CACHEDIR="$withval"],
493 [AC_DEFINE_UNQUOTED([CACHEDIR], ["$HOME/unrealircd/cache"], [Define the location of the cached remote include files])
494 CACHEDIR="$HOME/unrealircd/cache"])
495
496 AC_ARG_WITH(tmpdir, [AS_HELP_STRING([--with-tmpdir=path],[Specify the directory where private temporary files are stored. Should not be readable or writable by others, so not /tmp!!])],
497 [AC_DEFINE_UNQUOTED([TMPDIR], ["$withval"], [Define the location of private temporary files])
498 TMPDIR="$withval"],
499 [AC_DEFINE_UNQUOTED([TMPDIR], ["$HOME/unrealircd/tmp"], [Define the location of private temporary files])
500 TMPDIR="$HOME/unrealircd/tmp"])
501
502 AC_ARG_WITH(datadir, [AS_HELP_STRING([--with-datadir=path],[Specify the directory where permanent data is stored])],
503 [AC_DEFINE_UNQUOTED([PERMDATADIR], ["$withval"], [Define the location of permanent data files])
504 PERMDATADIR="$withval"],
505 [AC_DEFINE_UNQUOTED([DATADIR], ["$HOME/unrealircd/data"], [Define the location of permanent data files])
506 PERMDATADIR="$HOME/unrealircd/data"])
507
508 AC_ARG_WITH(docdir, [AS_HELP_STRING([--with-docdir=path],[Specify the directory where documentation is stored])],
509 [AC_DEFINE_UNQUOTED([DOCDIR], ["$withval"], [Define the location of the documentation])
510 DOCDIR="$withval"],
511 [AC_DEFINE_UNQUOTED([DOCDIR], ["$HOME/unrealircd/doc"], [Define the location of the documentation])
512 DOCDIR="$HOME/unrealircd/doc"])
513
514 AC_ARG_WITH(pidfile, [AS_HELP_STRING([--with-pidfile=path],[Specify the path of the pid file])],
515 [AC_DEFINE_UNQUOTED([PIDFILE], ["$withval"], [Define the path of the pid file])
516 PIDFILE="$withval"],
517 [AC_DEFINE_UNQUOTED([PIDFILE], ["$HOME/unrealircd/data/unrealircd.pid"], [Define the path of the pid file])
518 PIDFILE="$HOME/unrealircd/data/unrealircd.pid"])
519
520 AC_ARG_WITH(controlfile, [AS_HELP_STRING([--with-controlfile=path],[Specify the path of the control socket])],
521 [AC_DEFINE_UNQUOTED([CONTROLFILE], ["$withval"], [Define the path of the control socket])
522 CONTROLFILE="$withval"],
523 [AC_DEFINE_UNQUOTED([CONTROLFILE], ["$HOME/unrealircd/data/unrealircd.ctl"], [Define the path of the control socket])
524 CONTROLFILE="$HOME/unrealircd/data/unrealircd.ctl"])
525
526 dnl Ensure that this “feature” can be disabled as it makes it harder to package unrealircd.
527 dnl Users have always been able to specify “./configure LDFLAGS=-Wl,-rpath,/path/to/blah”—binki
528 AC_ARG_WITH(privatelibdir, [AS_HELP_STRING([--with-privatelibdir=path],[Specify the directory where private libraries are stored. Disable when building a package for a distro])],
529 [],
530 [with_privatelibdir="yes"])
531 AS_IF([test "x$with_privatelibdir" = "xno"],
532 [PRIVATELIBDIR=],
533 [test "x$with_privatelibdir" = "xyes"],
534 [PRIVATELIBDIR="$HOME/unrealircd/lib"],
535 [PRIVATELIBDIR="$with_privatelibdir"])
536 AS_IF([test "x$PRIVATELIBDIR" = "x"],
537 [LDFLAGS_PRIVATELIBS=""],
538 [AC_DEFINE_UNQUOTED([PRIVATELIBDIR], ["$PRIVATELIBDIR"], [Define the location of private libraries])
539 LDFLAGS_PRIVATELIBS="-Wl,-rpath,$PRIVATELIBDIR"
540 LDFLAGS="$LDFLAGS $LDFLAGS_PRIVATELIBS"
541 export LDFLAGS])
542
543 AC_SUBST(BUILDDIR)
544 AC_SUBST(BINDIR)
545 AC_SUBST(SCRIPTDIR)
546 AC_SUBST(CONFDIR)
547 AC_SUBST(MODULESDIR)
548 AC_SUBST(LOGDIR)
549 AC_SUBST(CACHEDIR)
550 AC_SUBST(TMPDIR)
551 dnl Why o why PERMDATADIR and not DATADIR you ask?
552 dnl well, Because DATADIR conflicts with the Windows SDK header files.. amazing.
553 AC_SUBST(PERMDATADIR)
554 AC_SUBST(DOCDIR)
555 AC_SUBST(PIDFILE)
556 AC_SUBST(CONTROLFILE)
557 AC_SUBST(LDFLAGS_PRIVATELIBS)
558
559 AC_ARG_WITH(maxconnections, [AS_HELP_STRING([--with-maxconnections=size], [Specify the max file descriptors to use])],
560 [ac_fd=$withval],
561 [ac_fd=0])
562 AC_DEFINE_UNQUOTED([MAXCONNECTIONS_REQUEST], [$ac_fd], [Set to the maximum number of connections you want])
563
564 AC_ARG_WITH(no-operoverride, [AS_HELP_STRING([--with-no-operoverride], [Disable OperOverride])],
565 [AS_IF([test $withval = "yes"],
566 [AC_DEFINE([NO_OPEROVERRIDE], [], [Define if you want OperOverride disabled])])])
567 AC_ARG_WITH(operoverride-verify, [AS_HELP_STRING([--with-operoverride-verify], [Require opers to invite themselves to +s/+p channels])],
568 [AS_IF([test $withval = "yes"],
569 [AC_DEFINE([OPEROVERRIDE_VERIFY], [], [Define if you want opers to have to use /invite to join +s/+p channels])])])
570 AC_ARG_WITH(system-pcre2, [AS_HELP_STRING([--without-system-pcre2], [Use the system pcre2 package instead of bundled, discovered using pkg-config])], [], [with_system_pcre2=yes])
571 AC_ARG_WITH(system-argon2, [AS_HELP_STRING([--with-system-argon2], [Use system argon2 instead of bundled version. Normally we prefer the one shipped with unrealircd because it is much faster])], [], [with_system_argon2=no])
572 AC_ARG_WITH(system-sodium, [AS_HELP_STRING([--without-system-sodium], [Use bundled version instead of system sodium library. Normally autodetected via pkg-config])], [], [with_system_sodium=yes])
573 AC_ARG_WITH(system-cares, [AS_HELP_STRING([--without-system-cares], [Use bundled version instead of system c-ares. Normally autodetected via pkg-config.])], [], [with_system_cares=yes])
574 AC_ARG_WITH(system-jansson, [AS_HELP_STRING([--without-system-jansson], [Use bundled version instead of system jansson. Normally autodetected via pkg-config.])], [], [with_system_jansson=yes])
575 CHECK_SSL
576 CHECK_SSL_CTX_SET1_CURVES_LIST
577 CHECK_SSL_CTX_SET_MIN_PROTO_VERSION
578 CHECK_SSL_CTX_SET_SECURITY_LEVEL
579 CHECK_ASN1_TIME_diff
580 CHECK_X509_get0_notAfter
581 CHECK_X509_check_host
582 AC_ARG_ENABLE(dynamic-linking, [AS_HELP_STRING([--disable-dynamic-linking], [Make the IRCd statically link with shared objects rather than dynamically (noone knows if disabling dynamic linking actually does anything or not)])],
583 [enable_dynamic_linking=$enableval], [enable_dynamic_linking="yes"])
584 AS_IF([test $enable_dynamic_linking = "yes"],
585 [AC_ENABLE_DYN],
586 [AC_DEFINE([STATIC_LINKING], [], [Link... statically(?) (defining this macro will probably cause the build tofail)])])
587
588 AC_ARG_ENABLE([werror],
589 [AS_HELP_STRING([--enable-werror],
590 [Turn compilation warnings into errors (-Werror)])],
591 [ac_cv_werror="$enableval"],
592 [ac_cv_werror="no"])
593
594 AC_ARG_ENABLE([asan],
595 [AS_HELP_STRING([--enable-asan],
596 [Enable address sanitizer and other debugging options, not recommended for production servers!])],
597 [ac_cv_asan="$enableval"],
598 [ac_cv_asan="no"])
599
600 AC_CHECK_FUNCS([poll],
601 AC_DEFINE([HAVE_POLL], [], [Define if you have poll]))
602 AC_CHECK_FUNCS([epoll_create epoll_ctl epoll_wait],
603 AC_DEFINE([HAVE_EPOLL], [], [Define if you have epoll]))
604 AC_CHECK_FUNCS([kqueue kevent],
605 AC_DEFINE([HAVE_KQUEUE], [], [Define if you have kqueue]))
606
607 dnl c-ares needs PATH_SEPARATOR set or it will
608 dnl fail on certain solaris boxes. We might as
609 dnl well set it here.
610 export PATH_SEPARATOR
611
612 dnl Use system pcre2 when available, unless --without-system-pcre2.
613 has_system_pcre2="no"
614 AS_IF([test "x$with_system_pcre2" = "xyes"],[
615 PKG_CHECK_MODULES([PCRE2], libpcre2-8 >= 10.36,[has_system_pcre2=yes
616 AS_IF([test "x$PRIVATELIBDIR" != "x"], [rm -f "$PRIVATELIBDIR/"libpcre2*])],[has_system_pcre2=no])])
617
618 AS_IF([test "$has_system_pcre2" = "no"], [
619 dnl REMEMBER TO CHANGE WITH A NEW PCRE2 RELEASE!
620 pcre2_version="10.42"
621 AC_MSG_RESULT(extracting PCRE2 regex library)
622 cur_dir=`pwd`
623 cd extras
624 dnl remove old pcre2 directory to force a recompile...
625 dnl and remove its installation prefix just to clean things up.
626 rm -rf pcre2-$pcre2_version pcre2
627 if test "x$ac_cv_path_GUNZIP" = "x" ; then
628 tar xfz pcre2.tar.gz
629 else
630 cp pcre2.tar.gz pcre2.tar.gz.bak
631 gunzip -f pcre2.tar.gz
632 cp pcre2.tar.gz.bak pcre2.tar.gz
633 tar xf pcre2.tar
634 fi
635 AC_MSG_RESULT(configuring PCRE2 regex library)
636 cd pcre2-$pcre2_version
637 ./configure --enable-jit --enable-shared --prefix=$cur_dir/extras/pcre2 --libdir=$PRIVATELIBDIR || exit 1
638 AC_MSG_RESULT(compiling PCRE2 regex library)
639 $ac_cv_prog_MAKER || exit 1
640 AC_MSG_RESULT(installing PCRE2 regex library)
641 rm -f "$PRIVATELIBDIR/"libpcre2*
642 $ac_cv_prog_MAKER install || exit 1
643 PCRE2_CFLAGS="-I$cur_dir/extras/pcre2/include"
644 AC_SUBST(PCRE2_CFLAGS)
645 PCRE2_LIBS=
646 dnl See c-ares's compilation section for more info on this hack.
647 dnl ensure that we're linking against the bundled version of pcre2
648 dnl (we only reach this code if linking against the bundled version is desired).
649 AS_IF([test -n "$ac_cv_path_PKGCONFIG"],
650 [PCRE2_LIBS="`$ac_cv_path_PKGCONFIG --libs libpcre2-8.pc`"])
651 dnl For when pkg-config isn't available -- or for when pkg-config
652 dnl doesn't see the libpcre2-8.pc file somehow... (#3982)
653 AS_IF([test -z "$PCRE2_LIBS"],
654 [PCRE2_LIBS="$PRIVATELIBDIR/libpcre2-8.so"])
655 AC_SUBST(PCRE2_LIBS)
656 cd $cur_dir
657 ])
658
659 dnl Use system argon2 when available, unless --without-system-argon2
660 has_system_argon2="no"
661 AS_IF([test "x$with_system_argon2" = "xyes"],[
662 PKG_CHECK_MODULES([ARGON2], [libargon2 >= 0~20161029],[has_system_argon2=yes
663 AS_IF([test "x$PRIVATELIBDIR" != "x"], [rm -f "$PRIVATELIBDIR/"libargon2*])],[has_system_argon2=no])])
664
665 AS_IF([test "$has_system_argon2" = "no"],[
666 dnl REMEMBER TO CHANGE WITH A NEW ARGON2 RELEASE!
667 argon2_version="20190702"
668 AC_MSG_RESULT(extracting Argon2 library)
669 cur_dir=`pwd`
670 cd extras
671 dnl remove old argon2 directory to force a recompile...
672 dnl and remove its installation prefix just to clean things up.
673 rm -rf argon2-$argon2_version argon2
674 if test "x$ac_cv_path_GUNZIP" = "x" ; then
675 tar xfz argon2.tar.gz
676 else
677 cp argon2.tar.gz argon2.tar.gz.bak
678 gunzip -f argon2.tar.gz
679 cp argon2.tar.gz.bak argon2.tar.gz
680 tar xf argon2.tar
681 fi
682 AC_MSG_RESULT(compiling Argon2 library)
683 cd argon2-$argon2_version
684 $ac_cv_prog_MAKER || exit 1
685 AC_MSG_RESULT(installing Argon2 library)
686 $ac_cv_prog_MAKER install PREFIX=$cur_dir/extras/argon2 || exit 1
687 # We need to manually copy the libs to PRIVATELIBDIR because
688 # there is no way to tell make install in libargon2 to do so.
689 # BUT FIRST, delete the old library so it becomes an unlink+create
690 # operation rather than overwriting the existing file which would
691 # lead to a crash of the currently running IRCd.
692 rm -f "$PRIVATELIBDIR/"libargon2*
693 # Now copy the new library files:
694 cp -av $cur_dir/extras/argon2/lib/* $PRIVATELIBDIR/
695 ARGON2_CFLAGS="-I$cur_dir/extras/argon2/include"
696 AC_SUBST(ARGON2_CFLAGS)
697 ARGON2_LIBS="-L$PRIVATELIBDIR -largon2"
698 AC_SUBST(ARGON2_LIBS)
699 cd $cur_dir
700 ])
701
702 dnl Use system sodium when available, unless --without-system-sodium
703 has_system_sodium="no"
704 AS_IF([test "x$with_system_sodium" = "xyes"],[
705 PKG_CHECK_MODULES([SODIUM], [libsodium >= 1.0.16],[has_system_sodium=yes
706 AS_IF([test "x$PRIVATELIBDIR" != "x"], [rm -f "$PRIVATELIBDIR/"libsodium*])],[has_system_sodium=no])])
707
708 AS_IF([test "$has_system_sodium" = "no"],[
709 dnl REMEMBER TO CHANGE WITH A NEW SODIUM RELEASE!
710 sodium_version="1.0.18"
711 AC_MSG_RESULT(extracting sodium library)
712 cur_dir=`pwd`
713 cd extras
714 dnl remove old sodium directory to force a recompile...
715 dnl and remove its installation prefix just to clean things up.
716 rm -rf sodium-$sodium_version sodium
717 if test "x$ac_cv_path_GUNZIP" = "x" ; then
718 tar xfz libsodium.tar.gz
719 else
720 cp libsodium.tar.gz libsodium.tar.gz.bak
721 gunzip -f libsodium.tar.gz
722 cp libsodium.tar.gz.bak libsodium.tar.gz
723 tar xf libsodium.tar
724 fi
725 AC_MSG_RESULT(compiling sodium library)
726 cd libsodium-$sodium_version
727 save_cflags="$CFLAGS"
728 CFLAGS="$orig_cflags"
729 export CFLAGS
730 ./configure --prefix=$cur_dir/extras/sodium --libdir=$PRIVATELIBDIR --enable-shared --disable-static --enable-opt || exit 1
731 CFLAGS="$save_cflags"
732 AC_MSG_RESULT(compiling sodium resolver library)
733 $ac_cv_prog_MAKER || exit 1
734 AC_MSG_RESULT(installing sodium resolver library)
735 rm -f "$PRIVATELIBDIR/"libsodium*
736 $ac_cv_prog_MAKER install || exit 1
737 SODIUM_CFLAGS="-I$cur_dir/extras/sodium/include"
738 AC_SUBST(SODIUM_CFLAGS)
739 SODIUM_LIBS=
740 dnl See c-ares's compilation section for more info on this hack.
741 dnl ensure that we're linking against the bundled version
742 dnl (we only reach this code if linking against the bundled version is desired).
743 AS_IF([test -n "$ac_cv_path_PKGCONFIG"],
744 [SODIUM_LIBS="`$ac_cv_path_PKGCONFIG --libs libsodium.pc`"])
745 dnl For when pkg-config isn't available
746 AS_IF([test -z "$SODIUM_LIBS"],
747 [SODIUM_LIBS="-L$PRIVATELIBDIR -lsodium"])
748 AC_SUBST(SODIUM_LIBS)
749 cd $cur_dir
750 ])
751
752 dnl Use system c-ares when available, unless --without-system-cares.
753 has_system_cares="no"
754 AS_IF([test "x$with_system_cares" = "xyes"],[
755 PKG_CHECK_MODULES([CARES], libcares >= 1.6.0,[has_system_cares=yes
756 AS_IF([test "x$PRIVATELIBDIR" != "x"], [rm -f "$PRIVATELIBDIR/"libcares*])],[has_system_cares=no])])
757
758 AS_IF([test "$has_system_cares" = "no"], [
759 dnl REMEMBER TO CHANGE WITH A NEW C-ARES RELEASE!
760 dnl NOTE: when changing this here, ALSO change it in extras/curlinstall
761 dnl and in the comment in this file around line 400!
762 cares_version="1.19.1"
763 AC_MSG_RESULT(extracting c-ares resolver library)
764 cur_dir=`pwd`
765 cd extras
766 dnl remove old c-ares directory to force a recompile...
767 rm -rf c-ares-$cares_version c-ares
768 if test "x$ac_cv_path_GUNZIP" = "x" ; then
769 tar xfz c-ares.tar.gz
770 else
771 cp c-ares.tar.gz c-ares.tar.gz.bak
772 gunzip -f c-ares.tar.gz
773 cp c-ares.tar.gz.bak c-ares.tar.gz
774 tar xf c-ares.tar
775 fi
776 AC_MSG_RESULT(configuring c-ares library)
777 cd c-ares-$cares_version
778 save_cflags="$CFLAGS"
779 CFLAGS="$orig_cflags"
780 export CFLAGS
781 ./configure --prefix=$cur_dir/extras/c-ares --libdir=$PRIVATELIBDIR --enable-shared --disable-tests || exit 1
782 CFLAGS="$save_cflags"
783 AC_MSG_RESULT(compiling c-ares resolver library)
784 $ac_cv_prog_MAKER || exit 1
785 AC_MSG_RESULT(installing c-ares resolver library)
786 rm -f "$PRIVATELIBDIR/"libcares*
787 $ac_cv_prog_MAKER install || exit 1
788 CARES_CFLAGS="-I$cur_dir/extras/c-ares/include"
789 AC_SUBST(CARES_CFLAGS)
790 CARES_LIBS="-L$PRIVATELIBDIR"
791
792 dnl Set default library parameters for when pkg-config is not available
793 dnl Ugly cd'ing out of extras/c-ares-xxx ;)
794 dnl Note: must be a full path, not relative path.
795 cd ../..
796 CARESLIBSALT="$PRIVATELIBDIR/libcares.so"
797 cd -
798 case `uname -s` in
799 *FreeBSD*)
800 CARESLIBSALT="$CARESLIBSALT"
801 ;;
802 *Linux*)
803 CARESLIBSALT="$CARESLIBSALT -lrt"
804 ;;
805 *SunOS*)
806 CARESLIBSALT="$CARESLIBSALT -lrt"
807 ;;
808 esac
809
810 dnl Use pkg-config for c-ares libraries, and if not available use defaults
811 dnl from above (also if pkg-config returns an empty result).
812 if test "x$ac_cv_path_PKGCONFIG" = "x" ; then
813 CARES_LIBS="$CARES_LIBS $CARESLIBSALT"
814 else
815 CARES_LIBSPRE="$CARES_LIBS"
816 dnl the sed expression forces an absolute path to the .so file to be generated
817 dnl because this is what libtool would do. If this wasn't done and /usr/lib*/libcares.so
818 dnl exists, then unrealircd would still try to link against the system c-ares.
819 dnl The [] quotation is needed because the sed expression has [] in it.
820 [CARES_LIBS="$CARES_LIBS `$ac_cv_path_PKGCONFIG --libs libcares.pc | sed -e 's,-L\([^ ]\+lib\) -lcares,\1/libcares.so,'`"]
821 if test "$CARES_LIBS" = "$CARES_LIBSPRE " ; then
822 CARES_LIBS="$CARES_LIBS $CARESLIBSALT"
823 fi
824 fi
825 AC_SUBST(CARES_LIBS)
826 cd $cur_dir
827 ])
828
829 dnl Use system jansson when available, unless --without-system-jansson
830 has_system_jansson="no"
831 AS_IF([test "x$with_system_jansson" = "xyes"],[
832 PKG_CHECK_MODULES([JANSSON], [jansson >= 2.0.0],[has_system_jansson=yes
833 AS_IF([test "x$PRIVATELIBDIR" != "x"], [rm -f "$PRIVATELIBDIR/"libjansson*])],[has_system_jansson=no])])
834
835 AS_IF([test "$has_system_jansson" = "no"],[
836 dnl REMEMBER TO CHANGE WITH A NEW JANSSON RELEASE!
837 jansson_version="2.14"
838 AC_MSG_RESULT(extracting jansson library)
839 cur_dir=`pwd`
840 cd extras
841 dnl remove old jansson directory to force a recompile...
842 dnl and remove its installation prefix just to clean things up.
843 rm -rf jansson-$jansson_version jansson
844 if test "x$ac_cv_path_GUNZIP" = "x" ; then
845 tar xfz jansson.tar.gz
846 else
847 cp jansson.tar.gz jansson.tar.gz.bak
848 gunzip -f jansson.tar.gz
849 cp jansson.tar.gz.bak jansson.tar.gz
850 tar xf jansson.tar
851 fi
852 AC_MSG_RESULT(compiling jansson library)
853 cd jansson-$jansson_version
854 save_cflags="$CFLAGS"
855 CFLAGS="$orig_cflags"
856 export CFLAGS
857 ./configure --prefix=$cur_dir/extras/jansson --libdir=$PRIVATELIBDIR --enable-shared --disable-static || exit 1
858 CFLAGS="$save_cflags"
859 AC_MSG_RESULT(compiling jansson resolver library)
860 $ac_cv_prog_MAKER || exit 1
861 AC_MSG_RESULT(installing jansson resolver library)
862 rm -f "$PRIVATELIBDIR/"libjansson*
863 $ac_cv_prog_MAKER install || exit 1
864 JANSSON_CFLAGS="-I$cur_dir/extras/jansson/include"
865 AC_SUBST(JANSSON_CFLAGS)
866 JANSSON_LIBS=
867 dnl See c-ares's compilation section for more info on this hack.
868 dnl ensure that we're linking against the bundled version
869 dnl (we only reach this code if linking against the bundled version is desired).
870 AS_IF([test -n "$ac_cv_path_PKGCONFIG"],
871 [JANSSON_LIBS="`$ac_cv_path_PKGCONFIG --libs jansson.pc`"])
872 dnl ^^^ FIXME FIXME this is likely incorrect the .pc etc
873 dnl For when pkg-config isn't available
874 AS_IF([test -z "$JANSSON_LIBS"],
875 [JANSSON_LIBS="-L$PRIVATELIBDIR -ljansson"])
876 AC_SUBST(JANSSON_LIBS)
877 cd $cur_dir
878 ])
879
880
881 AX_PTHREAD()
882
883 CHECK_LIBCURL
884
885 CHECK_GEOIP_CLASSIC
886
887 CHECK_LIBMAXMINDDB
888
889 UNRLINCDIR="`pwd`/include"
890
891 dnl Moved to the very end to ensure it doesn't affect any libs or tests.
892 if test "$ac_cv_werror" = "yes" ; then
893 CFLAGS="$CFLAGS -Werror"
894 fi
895
896 dnl Address sanitizer build
897 if test "$ac_cv_asan" = "yes" ; then
898 CFLAGS="$CFLAGS -O2 -fno-inline -fsanitize=address -fno-omit-frame-pointer -DNOCLOSEFD"
899 IRCDLIBS="-fsanitize=address $IRCDLIBS"
900 fi
901
902 AC_SUBST(IRCDLIBS)
903
904 AC_SUBST(UNRLINCDIR)
905
906 AC_CONFIG_FILES([Makefile
907 src/Makefile
908 src/modules/Makefile
909 src/modules/chanmodes/Makefile
910 src/modules/usermodes/Makefile
911 src/modules/extbans/Makefile
912 src/modules/rpc/Makefile
913 src/modules/third/Makefile
914 extras/unrealircd-upgrade-script
915 unrealircd])
916 AC_OUTPUT
917 chmod 0700 unrealircd