unrealircd

- supernets unrealircd source & configuration
git clone git://git.acid.vegas/unrealircd.git
Log | Files | Refs | Archive | README | LICENSE

configure.ac (37313B)

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