]>
Commit | Line | Data |
---|---|---|
7dbf154d | 1 | dnl Process this file with autoconf to produce a configure script. |
23516d8e NPB |
2 | |
3 | dnl When updating the version, remember to update the following files | |
4 | dnl appropriately: | |
1498f1e7 BM |
5 | dnl include/windows/setup.h |
6 | dnl src/windows/unrealinst.iss | |
6d1d3de6 | 7 | dnl doc/Config.header |
23516d8e NPB |
8 | dnl src/version.c.SH |
9 | ||
f2c92ee4 | 10 | AC_INIT([unrealircd], [6.1.6-rc1], [https://bugs.unrealircd.org/], [], [https://unrealircd.org/]) |
7dbf154d | 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 | ||
74ea7af9 BM |
21 | dnl Save CFLAGS, use this when building the libraries like c-ares |
22 | orig_cflags="$CFLAGS" | |
23 | ||
21d0af6e | 24 | dnl Save build directory early on (used in our m4 macros too) |
dfa83aa6 | 25 | BUILDDIR_NOW="`pwd`" |
21d0af6e | 26 | |
23516d8e | 27 | dnl 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 | 29 | UNREAL_VERSION_GENERATION=["6"] |
537c9a2e | 30 | AC_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 | 33 | UNREAL_VERSION_MAJOR=["1"] |
537c9a2e | 34 | AC_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 | 37 | UNREAL_VERSION_MINOR=["6"] |
537c9a2e | 38 | AC_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 | 43 | UNREAL_VERSION_SUFFIX=["-rc1"] |
2f2ee0ba | 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)]) |
23516d8e | 45 | |
7dbf154d | 46 | AC_PATH_PROG(RM,rm) |
47 | AC_PATH_PROG(CP,cp) | |
48 | AC_PATH_PROG(TOUCH,touch) | |
49 | AC_PATH_PROG(OPENSSLPATH,openssl) | |
81e2099f BM |
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 | ||
7dbf154d | 62 | AC_PATH_PROG(INSTALL,install) |
7dbf154d | 63 | AC_PATH_PROG(GUNZIP, gunzip) |
64 | AC_PATH_PROG(PKGCONFIG, pkg-config) | |
65 | ||
e3488880 BM |
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 | ||
54a2fad8 BM |
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 | ||
7dbf154d | 78 | dnl Checks for libraries. |
79 | AC_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 |
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 | ||
bae1dcf1 BM |
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. | |
f320e32b | 114 | AC_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 | ||
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"], [ | |
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"])])]) | |
164 | AC_SUBST([HARDEN_CFLAGS]) | |
165 | AC_SUBST([HARDEN_LDFLAGS]) | |
4fd616f9 BM |
166 | AC_SUBST([HARDEN_BINCFLAGS]) |
167 | AC_SUBST([HARDEN_BINLDFLAGS]) | |
bae1dcf1 BM |
168 | |
169 | # End of flag tests. | |
170 | CC="$saved_CC" | |
171 | CXX="$saved_CXX" | |
172 | LD="$saved_LD" | |
173 | dnl HARDENING END | |
174 | ||
dd2af3b3 | 175 | dnl UnrealIRCd might not be strict-aliasing safe at this time |
f320e32b | 176 | check_cc_flag([-fno-strict-aliasing], [CFLAGS="$CFLAGS -fno-strict-aliasing"]) |
dd2af3b3 | 177 | |
70a8985d BM |
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 | ||
dd2af3b3 BM |
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 | ||
8e264068 BM |
192 | dnl == ADD THESE WARNINGS == |
193 | ||
dd2af3b3 BM |
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): | |
f320e32b BM |
198 | check_cc_flag([-Wextra], [CFLAGS="$CFLAGS -Wextra"]) |
199 | check_cc_flag([-Waggregate-return], [CFLAGS="$CFLAGS -Waggregate-return"]) | |
1068960b BM |
200 | check_cc_flag([-Wformat-nonliteral], [CFLAGS="$CFLAGS -Wformat-nonliteral"]) |
201 | ||
dd2af3b3 BM |
202 | dnl The following few are more experimental, if they have false positives we'll have |
203 | dnl to disable them: | |
f320e32b BM |
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"]) | |
dd2af3b3 | 207 | |
8e264068 BM |
208 | check_cc_flag([-Wparentheses], [CFLAGS="$CFLAGS -Wparentheses"]) |
209 | ||
210 | dnl == REMOVE THESE WARNINGS == | |
211 | ||
dd2af3b3 | 212 | dnl And now to filter out certain warnings: |
f320e32b | 213 | dnl [!] NOTE REGARDING THE check_cc_flag used by these: |
b2307af8 BM |
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. | |
dd2af3b3 BM |
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. | |
f320e32b | 229 | check_cc_flag([-Wpointer-sign], [CFLAGS="$CFLAGS -Wno-pointer-sign"]) |
dd2af3b3 BM |
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. | |
f320e32b | 234 | check_cc_flag([-Winvalid-source-encoding], [CFLAGS="$CFLAGS -Wno-invalid-source-encoding"]) |
dd2af3b3 | 235 | |
f320e32b | 236 | check_cc_flag([-Wformat-zero-length], [CFLAGS="$CFLAGS -Wno-format-zero-length"]) |
dd2af3b3 | 237 | |
f320e32b | 238 | check_cc_flag([-Wformat-truncation], [CFLAGS="$CFLAGS -Wno-format-truncation"]) |
dd2af3b3 | 239 | |
b183a3ea BM |
240 | check_cc_flag([-Wformat-overflow], [CFLAGS="$CFLAGS -Wno-format-overflow"]) |
241 | ||
dd2af3b3 BM |
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. | |
f320e32b BM |
247 | check_cc_flag([-Wunused], [CFLAGS="$CFLAGS -Wno-unused"]) |
248 | check_cc_flag([-Wunused-parameter], [CFLAGS="$CFLAGS -Wno-unused-parameter"]) | |
657985bf | 249 | check_cc_flag([-Wunused-but-set-parameter], [CFLAGS="$CFLAGS -Wno-unused-but-set-parameter"]) |
dd2af3b3 BM |
250 | |
251 | dnl We use this and this warning is meaningless since 'char' is always unsigned | |
252 | dnl in UnrealIRCd compiles (-funsigned-char). | |
f320e32b | 253 | check_cc_flag([-Wchar-subscripts], [CFLAGS="$CFLAGS -Wno-char-subscripts"]) |
dd2af3b3 | 254 | |
f320e32b | 255 | check_cc_flag([-Wsign-compare], [CFLAGS="$CFLAGS -Wno-sign-compare"]) |
dd2af3b3 | 256 | |
8b222a1e | 257 | dnl Don't warn about empty body, we use this, eg via Debug(()) or in if's. |
f320e32b | 258 | check_cc_flag([-Wempty-body], [CFLAGS="$CFLAGS -Wno-empty-body"]) |
8b222a1e | 259 | |
e767dc5e BM |
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 | ||
1f8add88 BM |
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 | |
ec3407a4 | 267 | AS_IF([$CC --version | grep -q "clang version 3."], |
1f8add88 | 268 | [CFLAGS="$CFLAGS -Wno-tautological-compare -Wno-pragmas"]) |
ec3407a4 | 269 | |
3b5b2b5c BM |
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). | |
d35a1bae | 274 | check_cc_flag([-Wpragmas], [no_pragmas=1],[no_pragmas=0]) |
a55f2e0c BM |
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 | |
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 |
287 | fi | |
3b5b2b5c | 288 | |
dd2af3b3 BM |
289 | dnl End of -W... compiler checks. |
290 | ||
291 | ||
7dbf154d | 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 | |
ecf260df | 302 | DYNAMIC_LDFLAGS="" |
ec294b13 | 303 | CFLAGS="$CFLAGS -Wl,-export-dynamic" |
7dbf154d | 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)]) | |
7dbf154d | 306 | CFLAGS=$hold_cflags |
ecf260df BM |
307 | if test "$ac_cv_export_dynamic" = "yes"; then |
308 | DYNAMIC_LDFLAGS="-Wl,-export-dynamic" | |
7dbf154d | 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*[)] | |
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 | |
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__ | |
d9d423ad | 332 | int main(void) { |
7dbf154d | 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 | ||
ecf260df | 349 | MODULEFLAGS="$ac_cv_pic $DYNAMIC_LDFLAGS" |
7dbf154d | 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 | ]) | |
c19165c8 BM |
355 | |
356 | AC_CACHE_CHECK([if your system has IPv6 support], [ac_cv_ip6], [ | |
c19165c8 | 357 | AC_TRY_RUN([ |
7dbf154d | 358 | #include <sys/types.h> |
359 | #include <sys/socket.h> | |
d9d423ad SJ |
360 | #include <stdlib.h> |
361 | int main(void) { | |
c51c3800 BM |
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 */ | |
7dbf154d | 364 | } |
c19165c8 BM |
365 | ], |
366 | [ac_cv_ip6=yes], | |
367 | [ac_cv_ip6=no]) | |
7dbf154d | 368 | ]) |
c19165c8 BM |
369 | if test "$ac_cv_ip6" = "no"; then |
370 | AC_MSG_ERROR([Your system does not support IPv6]) | |
371 | fi | |
7dbf154d | 372 | |
0e7ef37a | 373 | AC_MSG_CHECKING([if you have getsockopt TCP_INFO]) |
099e9950 BM |
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; | |
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 | 399 | AC_CHECK_HEADER(sys/syslog.h, |
400 | AC_DEFINE([SYSSYSLOGH], [], [Define if you have the <sys/syslog.h> header file.])) | |
7dbf154d | 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.])) | |
9f710925 | 405 | AC_CHECK_HEADERS([stdint.h inttypes.h]) |
a9e06556 | 406 | |
7dbf154d | 407 | dnl Checks for library functions. |
7dbf154d | 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])) | |
c550d956 BM |
414 | AC_CHECK_FUNCS(strlncpy, |
415 | AC_DEFINE([HAVE_STRLNCPY], [], [Define if you have strlncpy])) | |
7dbf154d | 416 | |
7dbf154d | 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 | ||
3b3f63b9 | 436 | AC_CHECK_FUNCS(explicit_bzero,AC_DEFINE([HAVE_EXPLICIT_BZERO], [], [Define if you have explicit_bzero])) |
7dbf154d | 437 | AC_CHECK_FUNCS(syslog,AC_DEFINE([HAVE_SYSLOG], [], [Define if you have syslog])) |
401ab6f5 | 438 | AC_CHECK_FUNCS(strnlen,AC_DEFINE([HAVE_STRNLEN], [], [Define if you have strnlen])) |
7dbf154d | 439 | AC_SUBST(CRYPTOLIB) |
440 | AC_SUBST(MODULEFLAGS) | |
ecf260df | 441 | AC_SUBST(DYNAMIC_LDFLAGS) |
7dbf154d | 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])]) | |
7dbf154d | 445 | AC_ARG_WITH(permissions, [AS_HELP_STRING([--with-permissions=permissions], [Specify the default permissions for |
446 | configuration 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 | |
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 | ||
dfa83aa6 BM |
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 | ||
5e94fc9c BM |
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])], | |
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 | |
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"], | |
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 |
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 | ||
2b94733c NPB |
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]) | |
d1d87d4d | 539 | LDFLAGS_PRIVATELIBS="-Wl,-rpath,$PRIVATELIBDIR" |
9252ce30 BM |
540 | LDFLAGS="$LDFLAGS $LDFLAGS_PRIVATELIBS" |
541 | export LDFLAGS]) | |
fd35f965 | 542 | |
dfa83aa6 | 543 | AC_SUBST(BUILDDIR) |
5e94fc9c BM |
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) | |
e5ec2a64 BM |
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) | |
5e94fc9c BM |
554 | AC_SUBST(DOCDIR) |
555 | AC_SUBST(PIDFILE) | |
39688517 | 556 | AC_SUBST(CONTROLFILE) |
9252ce30 | 557 | AC_SUBST(LDFLAGS_PRIVATELIBS) |
7dbf154d | 558 | |
6d3a9865 | 559 | AC_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]) |
562 | AC_DEFINE_UNQUOTED([MAXCONNECTIONS_REQUEST], [$ac_fd], [Set to the maximum number of connections you want]) | |
7dbf154d | 563 | |
7dbf154d | 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])])]) | |
7dbf154d | 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])])]) | |
05e3ed63 | 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]) |
5688825e | 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]) |
5daf7e7e | 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]) |
60d14e7d | 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]) |
f89348d2 | 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]) |
7dbf154d | 575 | CHECK_SSL |
fa9bdcd7 | 576 | CHECK_SSL_CTX_SET1_CURVES_LIST |
79bd78c0 | 577 | CHECK_SSL_CTX_SET_MIN_PROTO_VERSION |
f419a61f | 578 | CHECK_SSL_CTX_SET_SECURITY_LEVEL |
b3510c5d | 579 | CHECK_ASN1_TIME_diff |
75efe020 | 580 | CHECK_X509_get0_notAfter |
83d2498e | 581 | CHECK_X509_check_host |
7dbf154d | 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 | ||
821a0464 BM |
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 | ||
aff3c16c | 594 | AC_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 |
600 | AC_CHECK_FUNCS([poll], |
601 | AC_DEFINE([HAVE_POLL], [], [Define if you have poll])) | |
6a210e34 WP |
602 | AC_CHECK_FUNCS([epoll_create epoll_ctl epoll_wait], |
603 | AC_DEFINE([HAVE_EPOLL], [], [Define if you have epoll])) | |
ad25d019 WP |
604 | AC_CHECK_FUNCS([kqueue kevent], |
605 | AC_DEFINE([HAVE_KQUEUE], [], [Define if you have kqueue])) | |
6a210e34 | 606 | |
7dbf154d | 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 | ||
05e3ed63 BM |
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"],[ | |
4b456251 | 615 | PKG_CHECK_MODULES([PCRE2], libpcre2-8 >= 10.36,[has_system_pcre2=yes |
05e3ed63 BM |
616 | AS_IF([test "x$PRIVATELIBDIR" != "x"], [rm -f "$PRIVATELIBDIR/"libpcre2*])],[has_system_pcre2=no])]) |
617 | ||
618 | AS_IF([test "$has_system_pcre2" = "no"], [ | |
547b2d69 | 619 | dnl REMEMBER TO CHANGE WITH A NEW PCRE2 RELEASE! |
ed2113e9 | 620 | pcre2_version="10.42" |
547b2d69 BM |
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 | |
ab8fab79 | 637 | ./configure --enable-jit --enable-shared --prefix=$cur_dir/extras/pcre2 --libdir=$PRIVATELIBDIR || exit 1 |
547b2d69 BM |
638 | AC_MSG_RESULT(compiling PCRE2 regex library) |
639 | $ac_cv_prog_MAKER || exit 1 | |
640 | AC_MSG_RESULT(installing PCRE2 regex library) | |
17e2a17e | 641 | rm -f "$PRIVATELIBDIR/"libpcre2* |
547b2d69 BM |
642 | $ac_cv_prog_MAKER install || exit 1 |
643 | PCRE2_CFLAGS="-I$cur_dir/extras/pcre2/include" | |
644 | AC_SUBST(PCRE2_CFLAGS) | |
547b2d69 BM |
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"], | |
fd35f965 | 650 | [PCRE2_LIBS="`$ac_cv_path_PKGCONFIG --libs libpcre2-8.pc`"]) |
547b2d69 BM |
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"], | |
fd35f965 | 654 | [PCRE2_LIBS="$PRIVATELIBDIR/libpcre2-8.so"]) |
547b2d69 BM |
655 | AC_SUBST(PCRE2_LIBS) |
656 | cd $cur_dir | |
547b2d69 BM |
657 | ]) |
658 | ||
9fdd93f0 BM |
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"],[ | |
4965fc67 | 662 | PKG_CHECK_MODULES([ARGON2], [libargon2 >= 0~20161029],[has_system_argon2=yes |
9fdd93f0 BM |
663 | AS_IF([test "x$PRIVATELIBDIR" != "x"], [rm -f "$PRIVATELIBDIR/"libargon2*])],[has_system_argon2=no])]) |
664 | ||
665 | AS_IF([test "$has_system_argon2" = "no"],[ | |
a852b480 | 666 | dnl REMEMBER TO CHANGE WITH A NEW ARGON2 RELEASE! |
8f311bb9 | 667 | argon2_version="20190702" |
a852b480 BM |
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 | |
efaba7f9 | 675 | tar xfz argon2.tar.gz |
a852b480 | 676 | else |
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 |
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. | |
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. | |
692 | rm -f "$PRIVATELIBDIR/"libargon2* | |
693 | # Now copy the new library files: | |
a852b480 BM |
694 | cp -av $cur_dir/extras/argon2/lib/* $PRIVATELIBDIR/ |
695 | ARGON2_CFLAGS="-I$cur_dir/extras/argon2/include" | |
696 | AC_SUBST(ARGON2_CFLAGS) | |
b335f8c2 | 697 | ARGON2_LIBS="-L$PRIVATELIBDIR -largon2" |
a852b480 BM |
698 | AC_SUBST(ARGON2_LIBS) |
699 | cd $cur_dir | |
a852b480 BM |
700 | ]) |
701 | ||
5daf7e7e BM |
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 | |
6d81d040 | 730 | ./configure --prefix=$cur_dir/extras/sodium --libdir=$PRIVATELIBDIR --enable-shared --disable-static --enable-opt || exit 1 |
5daf7e7e BM |
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) | |
17e2a17e | 735 | rm -f "$PRIVATELIBDIR/"libsodium* |
5daf7e7e BM |
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 | ||
c133dfd3 BM |
752 | dnl Use system c-ares when available, unless --without-system-cares. |
753 | has_system_cares="no" | |
60d14e7d BM |
754 | AS_IF([test "x$with_system_cares" = "xyes"],[ |
755 | PKG_CHECK_MODULES([CARES], libcares >= 1.6.0,[has_system_cares=yes | |
6591e6bc | 756 | AS_IF([test "x$PRIVATELIBDIR" != "x"], [rm -f "$PRIVATELIBDIR/"libcares*])],[has_system_cares=no])]) |
c133dfd3 | 757 | |
60d14e7d | 758 | AS_IF([test "$has_system_cares" = "no"], [ |
7dbf154d | 759 | dnl REMEMBER TO CHANGE WITH A NEW C-ARES RELEASE! |
999d5306 | 760 | dnl NOTE: when changing this here, ALSO change it in extras/curlinstall |
7dbf154d | 761 | dnl and in the comment in this file around line 400! |
8e252774 | 762 | cares_version="1.19.1" |
7dbf154d | 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... | |
f5848752 | 767 | rm -rf c-ares-$cares_version c-ares |
7dbf154d | 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) | |
f5848752 | 777 | cd c-ares-$cares_version |
74ea7af9 BM |
778 | save_cflags="$CFLAGS" |
779 | CFLAGS="$orig_cflags" | |
780 | export CFLAGS | |
ed50c8fb | 781 | ./configure --prefix=$cur_dir/extras/c-ares --libdir=$PRIVATELIBDIR --enable-shared --disable-tests || exit 1 |
74ea7af9 | 782 | CFLAGS="$save_cflags" |
7dbf154d | 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) | |
17e2a17e | 786 | rm -f "$PRIVATELIBDIR/"libcares* |
7dbf154d | 787 | $ac_cv_prog_MAKER install || exit 1 |
788 | CARES_CFLAGS="-I$cur_dir/extras/c-ares/include" | |
789 | AC_SUBST(CARES_CFLAGS) | |
63add509 | 790 | CARES_LIBS="-L$PRIVATELIBDIR" |
7dbf154d | 791 | |
792 | dnl Set default library parameters for when pkg-config is not available | |
9c30f7b6 BM |
793 | dnl Ugly cd'ing out of extras/c-ares-xxx ;) |
794 | dnl Note: must be a full path, not relative path. | |
795 | cd ../.. | |
fd35f965 | 796 | CARESLIBSALT="$PRIVATELIBDIR/libcares.so" |
9c30f7b6 | 797 | cd - |
7dbf154d | 798 | case `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 | 808 | esac |
809 | ||
810 | dnl Use pkg-config for c-ares libraries, and if not available use defaults | |
fd35f965 | 811 | dnl from above (also if pkg-config returns an empty result). |
7dbf154d | 812 | if test "x$ac_cv_path_PKGCONFIG" = "x" ; then |
813 | CARES_LIBS="$CARES_LIBS $CARESLIBSALT" | |
814 | else | |
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 | |
824 | fi | |
825 | AC_SUBST(CARES_LIBS) | |
826 | cd $cur_dir | |
7dbf154d | 827 | ]) |
828 | ||
f89348d2 BM |
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! | |
6b9cb967 | 837 | jansson_version="2.14" |
f89348d2 BM |
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 | |
6d81d040 | 857 | ./configure --prefix=$cur_dir/extras/jansson --libdir=$PRIVATELIBDIR --enable-shared --disable-static || exit 1 |
f89348d2 BM |
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) | |
17e2a17e | 862 | rm -f "$PRIVATELIBDIR/"libjansson* |
f89348d2 BM |
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 | ||
f81d2207 BM |
881 | AX_PTHREAD() |
882 | ||
b2e4cf82 | 883 | CHECK_LIBCURL |
7dbf154d | 884 | |
ed7bf1da BM |
885 | CHECK_GEOIP_CLASSIC |
886 | ||
9c3d5dff | 887 | CHECK_LIBMAXMINDDB |
888 | ||
101d2dd6 | 889 | UNRLINCDIR="`pwd`/include" |
821a0464 BM |
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 | ||
aff3c16c BM |
896 | dnl Address sanitizer build |
897 | if 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" |
900 | fi | |
901 | ||
902 | AC_SUBST(IRCDLIBS) | |
903 | ||
101d2dd6 BM |
904 | AC_SUBST(UNRLINCDIR) |
905 | ||
d012c49f | 906 | AC_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 | 916 | AC_OUTPUT |
5e94fc9c | 917 | chmod 0700 unrealircd |