]> jfr.im git - irc/unrealircd/unrealircd.git/blame - configure.ac
./Config: import settings from UnrealIRCd 6.1.5
[irc/unrealircd/unrealircd.git] / configure.ac
CommitLineData
7dbf154d 1dnl Process this file with autoconf to produce a configure script.
23516d8e
NPB
2
3dnl When updating the version, remember to update the following files
4dnl appropriately:
1498f1e7
BM
5dnl include/windows/setup.h
6dnl src/windows/unrealinst.iss
6d1d3de6 7dnl doc/Config.header
23516d8e
NPB
8dnl src/version.c.SH
9
f2c92ee4 10AC_INIT([unrealircd], [6.1.6-rc1], [https://bugs.unrealircd.org/], [], [https://unrealircd.org/])
7dbf154d 11AC_CONFIG_SRCDIR([src/ircd.c])
12AC_CONFIG_HEADER([include/setup.h])
13AC_CONFIG_AUX_DIR([autoconf])
14AC_CONFIG_MACRO_DIR([autoconf/m4])
15
16if test "x$enable_dynamic_linking" = "x"; then
17 echo "Please use ./Config instead of ./configure"
18 exit 1
19fi
20
74ea7af9
BM
21dnl Save CFLAGS, use this when building the libraries like c-ares
22orig_cflags="$CFLAGS"
23
21d0af6e 24dnl Save build directory early on (used in our m4 macros too)
dfa83aa6 25BUILDDIR_NOW="`pwd`"
21d0af6e 26
23516d8e 27dnl Calculate the versions. Perhaps the use of expr is a little too extravagant
537c9a2e 28# Generation version number (e.g.: X in X.Y.Z)
757adc76 29UNREAL_VERSION_GENERATION=["6"]
537c9a2e 30AC_DEFINE_UNQUOTED([UNREAL_VERSION_GENERATION], [$UNREAL_VERSION_GENERATION], [Generation version number (e.g.: X for X.Y.Z)])
23516d8e 31
537c9a2e 32# Major version number (e.g.: Y in X.Y.Z)
b093ba53 33UNREAL_VERSION_MAJOR=["1"]
537c9a2e 34AC_DEFINE_UNQUOTED([UNREAL_VERSION_MAJOR], [$UNREAL_VERSION_MAJOR], [Major version number (e.g.: Y for X.Y.Z)])
23516d8e 35
537c9a2e 36# Minor version number (e.g.: Z in X.Y.Z)
5a17e551 37UNREAL_VERSION_MINOR=["6"]
537c9a2e 38AC_DEFINE_UNQUOTED([UNREAL_VERSION_MINOR], [$UNREAL_VERSION_MINOR], [Minor version number (e.g.: Z for X.Y.Z)])
23516d8e
NPB
39
40# The version suffix such as a beta marker or release candidate
2f2ee0ba 41# marker. (e.g.: -rcX for unrealircd-3.2.9-rcX). This macro is a
23516d8e 42# string instead of an integer because it contains arbitrary data.
f2c92ee4 43UNREAL_VERSION_SUFFIX=["-rc1"]
2f2ee0ba 44AC_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)])
23516d8e 45
7dbf154d 46AC_PATH_PROG(RM,rm)
47AC_PATH_PROG(CP,cp)
48AC_PATH_PROG(TOUCH,touch)
49AC_PATH_PROG(OPENSSLPATH,openssl)
81e2099f
BM
50AS_IF([test x"$OPENSSLPATH" = "x"],
51[
52echo ""
53echo "Apparently you do not have both the openssl binary and openssl development libraries installed."
54echo "The following packages are required:"
55echo "1) The library package is often called 'openssl-dev', 'openssl-devel' or 'libssl-dev'"
56echo "2) The binary package is usually called 'openssl'."
57echo "NOTE: you or your system administrator needs to install the library AND the binary package."
58echo "After doing so, simply re-run ./Config"
59exit 1
60])
61
7dbf154d 62AC_PATH_PROG(INSTALL,install)
7dbf154d 63AC_PATH_PROG(GUNZIP, gunzip)
64AC_PATH_PROG(PKGCONFIG, pkg-config)
65
e3488880
BM
66dnl Check for compiler
67AC_PROG_CC_C99
68AS_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
54a2fad8
BM
71dnl Check for make moved down, so the above compiler check takes precedence.
72AC_CHECK_PROG(MAKER, gmake, gmake, make)
73AC_PATH_PROG(GMAKE,gmake)
74AS_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
7dbf154d 78dnl Checks for libraries.
79AC_CHECK_LIB(descrypt, crypt,
80 [AC_DEFINE([HAVE_CRYPT], [], [Define if you have crypt])
e0c2ccd9 81 IRCDLIBS="$IRCDLIBS-ldescrypt "],
7dbf154d 82 [AC_CHECK_LIB(crypt, crypt,
83 [AC_DEFINE([HAVE_CRYPT], [], [Define if you have crypt])
e0c2ccd9 84 IRCDLIBS="$IRCDLIBS-lcrypt "])])
7dbf154d 85
8783280a
BM
86dnl Check for big-endian system, even though these hardly exist anymore...
87AS_CASE([$host_cpu],
88 [i?86|amd64|x86_64],
89 [ac_cv_c_bigendian=no]
90)
91AC_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
bae1dcf1
BM
98dnl HARDENING START
99dnl This is taken from https://github.com/kmcallister/autoharden
100dnl 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.
104saved_CC="$CC"
105saved_CXX="$CXX"
106saved_LD="$LD"
107flag_wrap="$srcdir/extras/wrap-compiler-for-flag-check"
108CC="$flag_wrap $CC"
109CXX="$flag_wrap $CXX"
110LD="$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.
f320e32b 114AC_DEFUN([check_cc_flag],
bae1dcf1 115 [AC_LANG_PUSH(C)
f320e32b 116 AX_CHECK_COMPILE_FLAG([$1], [$2], [$3], [-Werror $4])
bae1dcf1
BM
117 AC_LANG_POP(C)])
118
119AC_DEFUN([check_link_flag],
120 [AX_CHECK_LINK_FLAG([$1], [$2], [$3], [-Werror $4])])
121
122AC_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
128HARDEN_CFLAGS=""
129HARDEN_LDFLAGS=""
130AS_IF([test x"$hardening" != x"no"], [
f320e32b 131 check_cc_flag([-fno-strict-overflow], [HARDEN_CFLAGS="$HARDEN_CFLAGS -fno-strict-overflow"])
bae1dcf1
BM
132
133 # This one will likely succeed, even on platforms where it does nothing.
a24e53c0 134 check_cc_flag([-D_FORTIFY_SOURCE=3], [HARDEN_CFLAGS="$HARDEN_CFLAGS -D_FORTIFY_SOURCE=3"])
bae1dcf1 135
f320e32b 136 check_cc_flag([-fstack-protector-all],
bae1dcf1
BM
137 [check_link_flag([-fstack-protector-all],
138 [HARDEN_CFLAGS="$HARDEN_CFLAGS -fstack-protector-all"
f320e32b 139 check_cc_flag([-Wstack-protector], [HARDEN_CFLAGS="$HARDEN_CFLAGS -Wstack-protector"],
bae1dcf1 140 [], [-fstack-protector-all])
f320e32b 141 check_cc_flag([--param ssp-buffer-size=1], [HARDEN_CFLAGS="$HARDEN_CFLAGS --param ssp-buffer-size=1"],
bae1dcf1
BM
142 [], [-fstack-protector-all])])])
143
e50b599b
BM
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
15a5905d
BM
147 # Control Flow Enforcement (ROP hardening) - requires CPU hardware support
148 check_cc_flag([-fcf-protection], [HARDEN_CFLAGS="$HARDEN_CFLAGS -fcf-protection"])
149
bae1dcf1
BM
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.
f320e32b 153 check_cc_flag([-fPIE],
bae1dcf1 154 [check_link_flag([-fPIE -pie],
4fd616f9
BM
155 [HARDEN_BINCFLAGS="-fPIE"
156 HARDEN_BINLDFLAGS="-pie"],
bae1dcf1 157 [check_link_flag([-fPIE -Wl,-pie],
4fd616f9
BM
158 [HARDEN_BINCFLAGS="-fPIE"
159 HARDEN_BINLDFLAGS="-Wl,-pie"])])])
bae1dcf1
BM
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"])])])
164AC_SUBST([HARDEN_CFLAGS])
165AC_SUBST([HARDEN_LDFLAGS])
4fd616f9
BM
166AC_SUBST([HARDEN_BINCFLAGS])
167AC_SUBST([HARDEN_BINLDFLAGS])
bae1dcf1
BM
168
169# End of flag tests.
170CC="$saved_CC"
171CXX="$saved_CXX"
172LD="$saved_LD"
173dnl HARDENING END
174
dd2af3b3 175dnl UnrealIRCd might not be strict-aliasing safe at this time
f320e32b 176check_cc_flag([-fno-strict-aliasing], [CFLAGS="$CFLAGS -fno-strict-aliasing"])
dd2af3b3 177
70a8985d
BM
178dnl UnrealIRCd should be able to compile with -fno-common
179dnl This also makes ASan (if it is in use) able to instrument these variables.
180check_cc_flag([-fno-common], [CFLAGS="$CFLAGS -fno-common"])
181
dd2af3b3
BM
182dnl Previously -funsigned-char was in a config check. It would always
183dnl be enabled with gcc and clang. We now unconditionally enable it,
184dnl skipping the check. This will cause an error if someone uses a
185dnl non-gcc/non-clang compiler that does not support -funsigned-char
186dnl which is good. After all, we really depend on it.
187dnl UnrealIRCd should never be compiled without char being unsigned.
188CFLAGS="$CFLAGS -funsigned-char"
189
190dnl Compiler -W checks...
191
8e264068
BM
192dnl == ADD THESE WARNINGS ==
193
dd2af3b3
BM
194dnl We should be able to turn this on unconditionally:
195CFLAGS="$CFLAGS -Wall"
196
197dnl More warnings (if the compiler supports it):
f320e32b
BM
198check_cc_flag([-Wextra], [CFLAGS="$CFLAGS -Wextra"])
199check_cc_flag([-Waggregate-return], [CFLAGS="$CFLAGS -Waggregate-return"])
1068960b
BM
200check_cc_flag([-Wformat-nonliteral], [CFLAGS="$CFLAGS -Wformat-nonliteral"])
201
dd2af3b3
BM
202dnl The following few are more experimental, if they have false positives we'll have
203dnl to disable them:
f320e32b
BM
204dnl Can't use this, too bad: check_cc_flag([-Wlogical-op], [CFLAGS="$CFLAGS -Wlogical-op"])
205check_cc_flag([-Wduplicated-cond], [CFLAGS="$CFLAGS -Wduplicated-cond"])
206check_cc_flag([-Wduplicated-branches], [CFLAGS="$CFLAGS -Wduplicated-branches"])
dd2af3b3 207
8e264068
BM
208check_cc_flag([-Wparentheses], [CFLAGS="$CFLAGS -Wparentheses"])
209
210dnl == REMOVE THESE WARNINGS ==
211
dd2af3b3 212dnl And now to filter out certain warnings:
f320e32b 213dnl [!] NOTE REGARDING THE check_cc_flag used by these:
b2307af8
BM
214dnl We check for the -Woption even though we are going to use -Wno-option.
215dnl This is due to the following (odd) gcc behavior:
216dnl "When an unrecognized warning option is requested (e.g.,
217dnl -Wunknown-warning), GCC emits a diagnostic stating that the option is not
218dnl recognized. However, if the -Wno- form is used, the behavior is slightly
219dnl different: no diagnostic is produced for -Wno-unknown-warning unless
220dnl other diagnostics are being produced. This allows the use of new -Wno-
221dnl options with old compilers, but if something goes wrong, the compiler
222dnl warns that an unrecognized option is present."
223dnl Since we don't want to use any unrecognized -Wno-option, we test for
224dnl -Woption instead.
dd2af3b3
BM
225
226dnl Pointer signedness warnings are really a pain and 99.9% of the time
227dnl they are of absolutely no use whatsoever. IMO the person who decided
228dnl to enable this without -Wall should be shot on sight.
f320e32b 229check_cc_flag([-Wpointer-sign], [CFLAGS="$CFLAGS -Wno-pointer-sign"])
dd2af3b3
BM
230
231dnl This is purely for charsys.c... I like it so we can easily read
232dnl this for non-utf8. We can remove it once we ditch non-utf8 some day
233dnl of course, or decide to ignore me and encode them.
f320e32b 234check_cc_flag([-Winvalid-source-encoding], [CFLAGS="$CFLAGS -Wno-invalid-source-encoding"])
dd2af3b3 235
f320e32b 236check_cc_flag([-Wformat-zero-length], [CFLAGS="$CFLAGS -Wno-format-zero-length"])
dd2af3b3 237
f320e32b 238check_cc_flag([-Wformat-truncation], [CFLAGS="$CFLAGS -Wno-format-truncation"])
dd2af3b3 239
b183a3ea
BM
240check_cc_flag([-Wformat-overflow], [CFLAGS="$CFLAGS -Wno-format-overflow"])
241
dd2af3b3
BM
242dnl While it can be useful to occasionally to compile with warnings about
243dnl unused variables and parameters, we often 'think ahead' when coding things
244dnl so they may be useless now but not later. Similarly, for variables, we
245dnl don't always care about a variable that may still be present in a build
246dnl without DEBUGMODE. Unused variables are optimized out anyway.
f320e32b
BM
247check_cc_flag([-Wunused], [CFLAGS="$CFLAGS -Wno-unused"])
248check_cc_flag([-Wunused-parameter], [CFLAGS="$CFLAGS -Wno-unused-parameter"])
657985bf 249check_cc_flag([-Wunused-but-set-parameter], [CFLAGS="$CFLAGS -Wno-unused-but-set-parameter"])
dd2af3b3
BM
250
251dnl We use this and this warning is meaningless since 'char' is always unsigned
252dnl in UnrealIRCd compiles (-funsigned-char).
f320e32b 253check_cc_flag([-Wchar-subscripts], [CFLAGS="$CFLAGS -Wno-char-subscripts"])
dd2af3b3 254
f320e32b 255check_cc_flag([-Wsign-compare], [CFLAGS="$CFLAGS -Wno-sign-compare"])
dd2af3b3 256
8b222a1e 257dnl Don't warn about empty body, we use this, eg via Debug(()) or in if's.
f320e32b 258check_cc_flag([-Wempty-body], [CFLAGS="$CFLAGS -Wno-empty-body"])
8b222a1e 259
e767dc5e
BM
260dnl This warns about all our hook calls - RunHook() and others
261check_cc_flag([-Wdeprecated-non-prototype], [CFLAGS="$CFLAGS -Wno-deprecated-non-prototype"])
262
1f8add88
BM
263dnl Yeah this old clang version is a bit problematic
264dnl (ships in Ubuntu 16.04 for example)
265dnl -Wtautological-compare has false positives
266dnl -Wno-pragmas is needed, despite -Wno-unknown-warning-option
ec3407a4 267AS_IF([$CC --version | grep -q "clang version 3."],
1f8add88 268 [CFLAGS="$CFLAGS -Wno-tautological-compare -Wno-pragmas"])
ec3407a4 269
3b5b2b5c
BM
270dnl This one MUST be LAST!!
271dnl It disables -Wsomeunknownoption being an error. Which is needed for
272dnl the pragma's in individual files to selectively disable some warnings
273dnl on clang/gcc (that may exist in eg gcc but not in clang or vice versa).
d35a1bae 274check_cc_flag([-Wpragmas], [no_pragmas=1],[no_pragmas=0])
a55f2e0c
BM
275check_cc_flag([-Wunknown-warning-option], [unknown_warning_option=1], [unknown_warning_option=0])
276
277if test "$unknown_warning_option" = "1"; then
278 dnl This is the best option
279 CFLAGS="$CFLAGS -Wno-unknown-warning-option"
280else
d35a1bae 281 if test "$no_pragmas" = "1"; then
a55f2e0c
BM
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.
da8b70d7 285 CFLAGS="$CFLAGS -Wno-pragmas"
a55f2e0c
BM
286 fi
287fi
3b5b2b5c 288
dd2af3b3
BM
289dnl End of -W... compiler checks.
290
291
7dbf154d 292dnl module checking based on Hyb7's module checking code
293AC_DEFUN([AC_ENABLE_DYN],
294[
295AC_CHECK_FUNC(dlopen,, [AC_CHECK_LIB(dl, dlopen,IRCDLIBS="$IRCDLIBS -ldl",
296[
297AC_MSG_WARN(Dynamic linking is not enabled because dlopen was not found)
298AC_DEFINE(STATIC_LINKING)
299])])
300
301hold_cflags=$CFLAGS
ecf260df 302DYNAMIC_LDFLAGS=""
ec294b13 303CFLAGS="$CFLAGS -Wl,-export-dynamic"
7dbf154d 304AC_CACHE_CHECK(if we need the -export-dynamic flag, ac_cv_export_dynamic, [
305AC_TRY_LINK(, [int i];, ac_cv_export_dynamic=yes, ac_cv_export_dynamic=no)])
7dbf154d 306CFLAGS=$hold_cflags
ecf260df
BM
307if test "$ac_cv_export_dynamic" = "yes"; then
308 DYNAMIC_LDFLAGS="-Wl,-export-dynamic"
7dbf154d 309fi
310
311AC_CACHE_CHECK(for compiler option to produce PIC,ac_cv_pic,[
312if test "$ac_cv_prog_gcc" = "yes"; then
313 ac_cv_pic="-fPIC -DPIC -shared"
314 case `uname -s` in
315 Darwin*[)]
7d2dea92 316 ac_cv_pic="-std=gnu89 -bundle -flat_namespace -undefined suppress"
7dbf154d 317 ;;
318 HP-UX*[)]
319 ac_cv_pic="-fPIC"
320 ;;
321 esac
322else
323case `uname -s` in
324 SunOS*[)]
325 ac_cv_pic="-KPIC -DPIC -G"
326 ;;
327esac
328fi
329])
330AC_CACHE_CHECK(if your system prepends an underscore on symbols,ac_cv_underscore,[
331cat >uscore.c << __EOF__
d9d423ad 332int main(void) {
7dbf154d 333 return 0;
334}
335__EOF__
336$CC -o uscore $CFLAGS uscore.c 1>&5
337if test -z "`strings -a uscore |grep '^_main$'`"; then
338ac_cv_underscore=no
339else
340ac_cv_underscore=yes
341fi
342rm -f uscore uscore.c
343])
344dnl libtool has built-in tests that determine proper underscorage
345if test "$ac_cv_underscore" = "yes"; then
346 AC_DEFINE([UNDERSCORE], [], [Define if your system prepends an underscore to symbols])
347fi
348
ecf260df 349MODULEFLAGS="$ac_cv_pic $DYNAMIC_LDFLAGS"
7dbf154d 350dnl DYNAMIC_LINKING is not meant to be defined in include/setup.h, it's
351dnl defined in the Makefiles using -D. Having it defined globally will
352dnl only cause braindamage and symbol collisions :-D.
353dnl AC_DEFINE([DYNAMIC_LINKING], [], [Link dynamically as opposed to statically. (Dynamic linking is the only supported method of linking atm)])
354])
c19165c8
BM
355
356AC_CACHE_CHECK([if your system has IPv6 support], [ac_cv_ip6], [
c19165c8 357AC_TRY_RUN([
7dbf154d 358#include <sys/types.h>
359#include <sys/socket.h>
d9d423ad
SJ
360#include <stdlib.h>
361int main(void) {
c51c3800
BM
362int s = socket(AF_INET6, SOCK_STREAM, 0);
363exit(0); /* We only check if the code compiles, that's enough. We can deal with missing runtime IPv6 */
7dbf154d 364}
c19165c8
BM
365],
366 [ac_cv_ip6=yes],
367 [ac_cv_ip6=no])
7dbf154d 368])
c19165c8
BM
369if test "$ac_cv_ip6" = "no"; then
370 AC_MSG_ERROR([Your system does not support IPv6])
371fi
7dbf154d 372
0e7ef37a 373AC_MSG_CHECKING([if you have getsockopt TCP_INFO])
099e9950
BM
374AC_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;
0e7ef37a
BM
386 #if defined(__FreeBSD__)
387 ti.__tcpi_pmtu = 0;
388 #else
099e9950 389 ti.tcpi_pmtu = 0;
0e7ef37a 390 #endif
099e9950
BM
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])
0e7ef37a 397 AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)])
099e9950 398
7dbf154d 399AC_CHECK_HEADER(sys/syslog.h,
400 AC_DEFINE([SYSSYSLOGH], [], [Define if you have the <sys/syslog.h> header file.]))
7dbf154d 401AC_CHECK_HEADER(sys/rusage.h,
402 AC_DEFINE([RUSAGEH], [], [Define if you have the <sys/rusage.h> header file.]))
403AC_CHECK_HEADER(glob.h,
404 AC_DEFINE([GLOBH], [], [Define if you have the <glob.h> header file.]))
9f710925 405AC_CHECK_HEADERS([stdint.h inttypes.h])
a9e06556 406
7dbf154d 407dnl Checks for library functions.
7dbf154d 408AC_CHECK_FUNCS(strlcpy,
409 AC_DEFINE([HAVE_STRLCPY], [], [Define if you have strlcpy. Otherwise, an internal implementation will be used!]))
410AC_CHECK_FUNCS(strlcat,
411 AC_DEFINE([HAVE_STRLCAT], [], [Define if you have strlcat]))
412AC_CHECK_FUNCS(strlncat,
413 AC_DEFINE([HAVE_STRLNCAT], [], [Define if you have strlncat]))
c550d956
BM
414AC_CHECK_FUNCS(strlncpy,
415 AC_DEFINE([HAVE_STRLNCPY], [], [Define if you have strlncpy]))
7dbf154d 416
7dbf154d 417AC_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])])])
421AC_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
3b3f63b9 436AC_CHECK_FUNCS(explicit_bzero,AC_DEFINE([HAVE_EXPLICIT_BZERO], [], [Define if you have explicit_bzero]))
7dbf154d 437AC_CHECK_FUNCS(syslog,AC_DEFINE([HAVE_SYSLOG], [], [Define if you have syslog]))
401ab6f5 438AC_CHECK_FUNCS(strnlen,AC_DEFINE([HAVE_STRNLEN], [], [Define if you have strnlen]))
7dbf154d 439AC_SUBST(CRYPTOLIB)
440AC_SUBST(MODULEFLAGS)
ecf260df 441AC_SUBST(DYNAMIC_LDFLAGS)
7dbf154d 442AC_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])])
7dbf154d 445AC_ARG_WITH(permissions, [AS_HELP_STRING([--with-permissions=permissions], [Specify the default permissions for
446configuration files])],
964bb656 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.])],
7dbf154d 451 [AC_DEFINE([DEFAULT_PERMISSIONS], [0600], [The default permissions for configuration files. Set to 0 to prevent unrealircd from calling chmod() on the files.])])
5e94fc9c
BM
452
453AC_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
459AC_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
465AC_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
dfa83aa6
BM
471dnl We have to pass the builddir as well, for the module manager
472AC_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
5e94fc9c
BM
478AC_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
484AC_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
490AC_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
496AC_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
502AC_ARG_WITH(datadir, [AS_HELP_STRING([--with-datadir=path],[Specify the directory where permanent data is stored])],
e5ec2a64
BM
503 [AC_DEFINE_UNQUOTED([PERMDATADIR], ["$withval"], [Define the location of permanent data files])
504 PERMDATADIR="$withval"],
5e94fc9c 505 [AC_DEFINE_UNQUOTED([DATADIR], ["$HOME/unrealircd/data"], [Define the location of permanent data files])
e5ec2a64 506 PERMDATADIR="$HOME/unrealircd/data"])
5e94fc9c
BM
507
508AC_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
514AC_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"],
12dfccf5
BM
517 [AC_DEFINE_UNQUOTED([PIDFILE], ["$HOME/unrealircd/data/unrealircd.pid"], [Define the path of the pid file])
518 PIDFILE="$HOME/unrealircd/data/unrealircd.pid"])
9252ce30 519
39688517
BM
520AC_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
2b94733c
NPB
526dnl Ensure that this “feature” can be disabled as it makes it harder to package unrealircd.
527dnl Users have always been able to specify “./configure LDFLAGS=-Wl,-rpath,/path/to/blah”—binki
528AC_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"])
531AS_IF([test "x$with_privatelibdir" = "xno"],
532 [PRIVATELIBDIR=],
533 [test "x$with_privatelibdir" = "xyes"],
534 [PRIVATELIBDIR="$HOME/unrealircd/lib"],
535 [PRIVATELIBDIR="$with_privatelibdir"])
536AS_IF([test "x$PRIVATELIBDIR" = "x"],
537 [LDFLAGS_PRIVATELIBS=""],
538 [AC_DEFINE_UNQUOTED([PRIVATELIBDIR], ["$PRIVATELIBDIR"], [Define the location of private libraries])
d1d87d4d 539 LDFLAGS_PRIVATELIBS="-Wl,-rpath,$PRIVATELIBDIR"
9252ce30
BM
540 LDFLAGS="$LDFLAGS $LDFLAGS_PRIVATELIBS"
541 export LDFLAGS])
fd35f965 542
dfa83aa6 543AC_SUBST(BUILDDIR)
5e94fc9c
BM
544AC_SUBST(BINDIR)
545AC_SUBST(SCRIPTDIR)
546AC_SUBST(CONFDIR)
547AC_SUBST(MODULESDIR)
548AC_SUBST(LOGDIR)
549AC_SUBST(CACHEDIR)
550AC_SUBST(TMPDIR)
e5ec2a64
BM
551dnl Why o why PERMDATADIR and not DATADIR you ask?
552dnl well, Because DATADIR conflicts with the Windows SDK header files.. amazing.
553AC_SUBST(PERMDATADIR)
5e94fc9c
BM
554AC_SUBST(DOCDIR)
555AC_SUBST(PIDFILE)
39688517 556AC_SUBST(CONTROLFILE)
9252ce30 557AC_SUBST(LDFLAGS_PRIVATELIBS)
7dbf154d 558
6d3a9865 559AC_ARG_WITH(maxconnections, [AS_HELP_STRING([--with-maxconnections=size], [Specify the max file descriptors to use])],
7dbf154d 560 [ac_fd=$withval],
6d3a9865
BM
561 [ac_fd=0])
562AC_DEFINE_UNQUOTED([MAXCONNECTIONS_REQUEST], [$ac_fd], [Set to the maximum number of connections you want])
7dbf154d 563
7dbf154d 564AC_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])])])
7dbf154d 567AC_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])])])
05e3ed63 570AC_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])
5688825e 571AC_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])
5daf7e7e 572AC_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])
60d14e7d 573AC_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])
f89348d2 574AC_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])
7dbf154d 575CHECK_SSL
fa9bdcd7 576CHECK_SSL_CTX_SET1_CURVES_LIST
79bd78c0 577CHECK_SSL_CTX_SET_MIN_PROTO_VERSION
f419a61f 578CHECK_SSL_CTX_SET_SECURITY_LEVEL
b3510c5d 579CHECK_ASN1_TIME_diff
75efe020 580CHECK_X509_get0_notAfter
83d2498e 581CHECK_X509_check_host
7dbf154d 582AC_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"])
584AS_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
821a0464
BM
588AC_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
aff3c16c 594AC_ARG_ENABLE([asan],
001c1e78 595 [AS_HELP_STRING([--enable-asan],
d9166bd6 596 [Enable address sanitizer and other debugging options, not recommended for production servers!])],
001c1e78
BM
597 [ac_cv_asan="$enableval"],
598 [ac_cv_asan="no"])
aff3c16c 599
5e427e9f
WP
600AC_CHECK_FUNCS([poll],
601 AC_DEFINE([HAVE_POLL], [], [Define if you have poll]))
6a210e34
WP
602AC_CHECK_FUNCS([epoll_create epoll_ctl epoll_wait],
603 AC_DEFINE([HAVE_EPOLL], [], [Define if you have epoll]))
ad25d019
WP
604AC_CHECK_FUNCS([kqueue kevent],
605 AC_DEFINE([HAVE_KQUEUE], [], [Define if you have kqueue]))
6a210e34 606
7dbf154d 607dnl c-ares needs PATH_SEPARATOR set or it will
608dnl fail on certain solaris boxes. We might as
609dnl well set it here.
610export PATH_SEPARATOR
611
05e3ed63
BM
612dnl Use system pcre2 when available, unless --without-system-pcre2.
613has_system_pcre2="no"
614AS_IF([test "x$with_system_pcre2" = "xyes"],[
4b456251 615PKG_CHECK_MODULES([PCRE2], libpcre2-8 >= 10.36,[has_system_pcre2=yes
05e3ed63
BM
616AS_IF([test "x$PRIVATELIBDIR" != "x"], [rm -f "$PRIVATELIBDIR/"libpcre2*])],[has_system_pcre2=no])])
617
618AS_IF([test "$has_system_pcre2" = "no"], [
547b2d69 619dnl REMEMBER TO CHANGE WITH A NEW PCRE2 RELEASE!
ed2113e9 620pcre2_version="10.42"
547b2d69
BM
621AC_MSG_RESULT(extracting PCRE2 regex library)
622cur_dir=`pwd`
623cd extras
624dnl remove old pcre2 directory to force a recompile...
625dnl and remove its installation prefix just to clean things up.
626rm -rf pcre2-$pcre2_version pcre2
627if test "x$ac_cv_path_GUNZIP" = "x" ; then
628 tar xfz pcre2.tar.gz
629else
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
634fi
635AC_MSG_RESULT(configuring PCRE2 regex library)
636cd pcre2-$pcre2_version
ab8fab79 637./configure --enable-jit --enable-shared --prefix=$cur_dir/extras/pcre2 --libdir=$PRIVATELIBDIR || exit 1
547b2d69
BM
638AC_MSG_RESULT(compiling PCRE2 regex library)
639$ac_cv_prog_MAKER || exit 1
640AC_MSG_RESULT(installing PCRE2 regex library)
17e2a17e 641rm -f "$PRIVATELIBDIR/"libpcre2*
547b2d69
BM
642$ac_cv_prog_MAKER install || exit 1
643PCRE2_CFLAGS="-I$cur_dir/extras/pcre2/include"
644AC_SUBST(PCRE2_CFLAGS)
547b2d69
BM
645PCRE2_LIBS=
646dnl See c-ares's compilation section for more info on this hack.
647dnl ensure that we're linking against the bundled version of pcre2
648dnl (we only reach this code if linking against the bundled version is desired).
649AS_IF([test -n "$ac_cv_path_PKGCONFIG"],
fd35f965 650 [PCRE2_LIBS="`$ac_cv_path_PKGCONFIG --libs libpcre2-8.pc`"])
547b2d69
BM
651dnl For when pkg-config isn't available -- or for when pkg-config
652dnl doesn't see the libpcre2-8.pc file somehow... (#3982)
653AS_IF([test -z "$PCRE2_LIBS"],
fd35f965 654 [PCRE2_LIBS="$PRIVATELIBDIR/libpcre2-8.so"])
547b2d69
BM
655AC_SUBST(PCRE2_LIBS)
656cd $cur_dir
547b2d69
BM
657])
658
9fdd93f0
BM
659dnl Use system argon2 when available, unless --without-system-argon2
660has_system_argon2="no"
661AS_IF([test "x$with_system_argon2" = "xyes"],[
4965fc67 662PKG_CHECK_MODULES([ARGON2], [libargon2 >= 0~20161029],[has_system_argon2=yes
9fdd93f0
BM
663AS_IF([test "x$PRIVATELIBDIR" != "x"], [rm -f "$PRIVATELIBDIR/"libargon2*])],[has_system_argon2=no])])
664
665AS_IF([test "$has_system_argon2" = "no"],[
a852b480 666dnl REMEMBER TO CHANGE WITH A NEW ARGON2 RELEASE!
8f311bb9 667argon2_version="20190702"
a852b480
BM
668AC_MSG_RESULT(extracting Argon2 library)
669cur_dir=`pwd`
670cd extras
671dnl remove old argon2 directory to force a recompile...
672dnl and remove its installation prefix just to clean things up.
673rm -rf argon2-$argon2_version argon2
674if test "x$ac_cv_path_GUNZIP" = "x" ; then
efaba7f9 675 tar xfz argon2.tar.gz
a852b480 676else
efaba7f9
BM
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
a852b480
BM
681fi
682AC_MSG_RESULT(compiling Argon2 library)
683cd argon2-$argon2_version
684$ac_cv_prog_MAKER || exit 1
685AC_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.
775fa471
BM
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.
692rm -f "$PRIVATELIBDIR/"libargon2*
693# Now copy the new library files:
a852b480
BM
694cp -av $cur_dir/extras/argon2/lib/* $PRIVATELIBDIR/
695ARGON2_CFLAGS="-I$cur_dir/extras/argon2/include"
696AC_SUBST(ARGON2_CFLAGS)
b335f8c2 697ARGON2_LIBS="-L$PRIVATELIBDIR -largon2"
a852b480
BM
698AC_SUBST(ARGON2_LIBS)
699cd $cur_dir
a852b480
BM
700])
701
5daf7e7e
BM
702dnl Use system sodium when available, unless --without-system-sodium
703has_system_sodium="no"
704AS_IF([test "x$with_system_sodium" = "xyes"],[
705PKG_CHECK_MODULES([SODIUM], [libsodium >= 1.0.16],[has_system_sodium=yes
706AS_IF([test "x$PRIVATELIBDIR" != "x"], [rm -f "$PRIVATELIBDIR/"libsodium*])],[has_system_sodium=no])])
707
708AS_IF([test "$has_system_sodium" = "no"],[
709dnl REMEMBER TO CHANGE WITH A NEW SODIUM RELEASE!
710sodium_version="1.0.18"
711AC_MSG_RESULT(extracting sodium library)
712cur_dir=`pwd`
713cd extras
714dnl remove old sodium directory to force a recompile...
715dnl and remove its installation prefix just to clean things up.
716rm -rf sodium-$sodium_version sodium
717if test "x$ac_cv_path_GUNZIP" = "x" ; then
718 tar xfz libsodium.tar.gz
719else
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
724fi
725AC_MSG_RESULT(compiling sodium library)
726cd libsodium-$sodium_version
727save_cflags="$CFLAGS"
728CFLAGS="$orig_cflags"
729export CFLAGS
6d81d040 730./configure --prefix=$cur_dir/extras/sodium --libdir=$PRIVATELIBDIR --enable-shared --disable-static --enable-opt || exit 1
5daf7e7e
BM
731CFLAGS="$save_cflags"
732AC_MSG_RESULT(compiling sodium resolver library)
733$ac_cv_prog_MAKER || exit 1
734AC_MSG_RESULT(installing sodium resolver library)
17e2a17e 735rm -f "$PRIVATELIBDIR/"libsodium*
5daf7e7e
BM
736$ac_cv_prog_MAKER install || exit 1
737SODIUM_CFLAGS="-I$cur_dir/extras/sodium/include"
738AC_SUBST(SODIUM_CFLAGS)
739SODIUM_LIBS=
740dnl See c-ares's compilation section for more info on this hack.
741dnl ensure that we're linking against the bundled version
742dnl (we only reach this code if linking against the bundled version is desired).
743AS_IF([test -n "$ac_cv_path_PKGCONFIG"],
744 [SODIUM_LIBS="`$ac_cv_path_PKGCONFIG --libs libsodium.pc`"])
745dnl For when pkg-config isn't available
746AS_IF([test -z "$SODIUM_LIBS"],
747 [SODIUM_LIBS="-L$PRIVATELIBDIR -lsodium"])
748AC_SUBST(SODIUM_LIBS)
749cd $cur_dir
750])
751
c133dfd3
BM
752dnl Use system c-ares when available, unless --without-system-cares.
753has_system_cares="no"
60d14e7d
BM
754AS_IF([test "x$with_system_cares" = "xyes"],[
755PKG_CHECK_MODULES([CARES], libcares >= 1.6.0,[has_system_cares=yes
6591e6bc 756AS_IF([test "x$PRIVATELIBDIR" != "x"], [rm -f "$PRIVATELIBDIR/"libcares*])],[has_system_cares=no])])
c133dfd3 757
60d14e7d 758AS_IF([test "$has_system_cares" = "no"], [
7dbf154d 759dnl REMEMBER TO CHANGE WITH A NEW C-ARES RELEASE!
999d5306 760dnl NOTE: when changing this here, ALSO change it in extras/curlinstall
7dbf154d 761dnl and in the comment in this file around line 400!
8e252774 762cares_version="1.19.1"
7dbf154d 763AC_MSG_RESULT(extracting c-ares resolver library)
764cur_dir=`pwd`
765cd extras
766dnl remove old c-ares directory to force a recompile...
f5848752 767rm -rf c-ares-$cares_version c-ares
7dbf154d 768if test "x$ac_cv_path_GUNZIP" = "x" ; then
769 tar xfz c-ares.tar.gz
770else
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
775fi
776AC_MSG_RESULT(configuring c-ares library)
f5848752 777cd c-ares-$cares_version
74ea7af9
BM
778save_cflags="$CFLAGS"
779CFLAGS="$orig_cflags"
780export CFLAGS
ed50c8fb 781./configure --prefix=$cur_dir/extras/c-ares --libdir=$PRIVATELIBDIR --enable-shared --disable-tests || exit 1
74ea7af9 782CFLAGS="$save_cflags"
7dbf154d 783AC_MSG_RESULT(compiling c-ares resolver library)
784$ac_cv_prog_MAKER || exit 1
785AC_MSG_RESULT(installing c-ares resolver library)
17e2a17e 786rm -f "$PRIVATELIBDIR/"libcares*
7dbf154d 787$ac_cv_prog_MAKER install || exit 1
788CARES_CFLAGS="-I$cur_dir/extras/c-ares/include"
789AC_SUBST(CARES_CFLAGS)
63add509 790CARES_LIBS="-L$PRIVATELIBDIR"
7dbf154d 791
792dnl Set default library parameters for when pkg-config is not available
9c30f7b6
BM
793dnl Ugly cd'ing out of extras/c-ares-xxx ;)
794dnl Note: must be a full path, not relative path.
795cd ../..
fd35f965 796CARESLIBSALT="$PRIVATELIBDIR/libcares.so"
9c30f7b6 797cd -
7dbf154d 798case `uname -s` in
a6c7bb10 799 *FreeBSD*)
800 CARESLIBSALT="$CARESLIBSALT"
801 ;;
802 *Linux*)
803 CARESLIBSALT="$CARESLIBSALT -lrt"
804 ;;
805 *SunOS*)
806 CARESLIBSALT="$CARESLIBSALT -lrt"
807 ;;
7dbf154d 808esac
809
810dnl Use pkg-config for c-ares libraries, and if not available use defaults
fd35f965 811dnl from above (also if pkg-config returns an empty result).
7dbf154d 812if test "x$ac_cv_path_PKGCONFIG" = "x" ; then
813 CARES_LIBS="$CARES_LIBS $CARESLIBSALT"
814else
815 CARES_LIBSPRE="$CARES_LIBS"
fd35f965 816 dnl the sed expression forces an absolute path to the .so file to be generated
a6c7bb10 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.
fd35f965 820 [CARES_LIBS="$CARES_LIBS `$ac_cv_path_PKGCONFIG --libs libcares.pc | sed -e 's,-L\([^ ]\+lib\) -lcares,\1/libcares.so,'`"]
7dbf154d 821 if test "$CARES_LIBS" = "$CARES_LIBSPRE " ; then
822 CARES_LIBS="$CARES_LIBS $CARESLIBSALT"
823 fi
824fi
825AC_SUBST(CARES_LIBS)
826cd $cur_dir
7dbf154d 827])
828
f89348d2
BM
829dnl Use system jansson when available, unless --without-system-jansson
830has_system_jansson="no"
831AS_IF([test "x$with_system_jansson" = "xyes"],[
832PKG_CHECK_MODULES([JANSSON], [jansson >= 2.0.0],[has_system_jansson=yes
833AS_IF([test "x$PRIVATELIBDIR" != "x"], [rm -f "$PRIVATELIBDIR/"libjansson*])],[has_system_jansson=no])])
834
835AS_IF([test "$has_system_jansson" = "no"],[
836dnl REMEMBER TO CHANGE WITH A NEW JANSSON RELEASE!
6b9cb967 837jansson_version="2.14"
f89348d2
BM
838AC_MSG_RESULT(extracting jansson library)
839cur_dir=`pwd`
840cd extras
841dnl remove old jansson directory to force a recompile...
842dnl and remove its installation prefix just to clean things up.
843rm -rf jansson-$jansson_version jansson
844if test "x$ac_cv_path_GUNZIP" = "x" ; then
845 tar xfz jansson.tar.gz
846else
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
851fi
852AC_MSG_RESULT(compiling jansson library)
853cd jansson-$jansson_version
854save_cflags="$CFLAGS"
855CFLAGS="$orig_cflags"
856export CFLAGS
6d81d040 857./configure --prefix=$cur_dir/extras/jansson --libdir=$PRIVATELIBDIR --enable-shared --disable-static || exit 1
f89348d2
BM
858CFLAGS="$save_cflags"
859AC_MSG_RESULT(compiling jansson resolver library)
860$ac_cv_prog_MAKER || exit 1
861AC_MSG_RESULT(installing jansson resolver library)
17e2a17e 862rm -f "$PRIVATELIBDIR/"libjansson*
f89348d2
BM
863$ac_cv_prog_MAKER install || exit 1
864JANSSON_CFLAGS="-I$cur_dir/extras/jansson/include"
865AC_SUBST(JANSSON_CFLAGS)
866JANSSON_LIBS=
867dnl See c-ares's compilation section for more info on this hack.
868dnl ensure that we're linking against the bundled version
869dnl (we only reach this code if linking against the bundled version is desired).
870AS_IF([test -n "$ac_cv_path_PKGCONFIG"],
871 [JANSSON_LIBS="`$ac_cv_path_PKGCONFIG --libs jansson.pc`"])
872dnl ^^^ FIXME FIXME this is likely incorrect the .pc etc
873dnl For when pkg-config isn't available
874AS_IF([test -z "$JANSSON_LIBS"],
875 [JANSSON_LIBS="-L$PRIVATELIBDIR -ljansson"])
876AC_SUBST(JANSSON_LIBS)
877cd $cur_dir
878])
879
880
f81d2207
BM
881AX_PTHREAD()
882
b2e4cf82 883CHECK_LIBCURL
7dbf154d 884
ed7bf1da
BM
885CHECK_GEOIP_CLASSIC
886
9c3d5dff 887CHECK_LIBMAXMINDDB
888
101d2dd6 889UNRLINCDIR="`pwd`/include"
821a0464
BM
890
891dnl Moved to the very end to ensure it doesn't affect any libs or tests.
892if test "$ac_cv_werror" = "yes" ; then
893 CFLAGS="$CFLAGS -Werror"
894fi
895
aff3c16c
BM
896dnl Address sanitizer build
897if test "$ac_cv_asan" = "yes" ; then
a24e53c0 898 CFLAGS="$CFLAGS -O2 -fno-inline -fsanitize=address -fno-omit-frame-pointer -DNOCLOSEFD"
aff3c16c
BM
899 IRCDLIBS="-fsanitize=address $IRCDLIBS"
900fi
901
902AC_SUBST(IRCDLIBS)
903
101d2dd6
BM
904AC_SUBST(UNRLINCDIR)
905
d012c49f 906AC_CONFIG_FILES([Makefile
4fd616f9 907 src/Makefile
d012c49f 908 src/modules/Makefile
101d2dd6
BM
909 src/modules/chanmodes/Makefile
910 src/modules/usermodes/Makefile
de59bf47 911 src/modules/extbans/Makefile
cbfcfa14 912 src/modules/rpc/Makefile
bd21ea90 913 src/modules/third/Makefile
0e125abc 914 extras/unrealircd-upgrade-script
ed082e62 915 unrealircd])
d012c49f 916AC_OUTPUT
5e94fc9c 917chmod 0700 unrealircd