summaryrefslogtreecommitdiffstats
path: root/usr.sbin/nsd/acx_nlnetlabs.m4
diff options
context:
space:
mode:
authorjakob <jakob@openbsd.org>2010-04-15 20:56:49 +0000
committerjakob <jakob@openbsd.org>2010-04-15 20:56:49 +0000
commita8b34139e8c467814ac9bb265e73d274ef552d6d (patch)
treeca67dedb456a0d323df48580f7b9cf00a73626fe /usr.sbin/nsd/acx_nlnetlabs.m4
parentTurn DIO_INHOLE() into a function, returning the next select code to probe at; (diff)
downloadwireguard-openbsd-a8b34139e8c467814ac9bb265e73d274ef552d6d.tar.xz
wireguard-openbsd-a8b34139e8c467814ac9bb265e73d274ef552d6d.zip
NSD v3.2.5
Diffstat (limited to 'usr.sbin/nsd/acx_nlnetlabs.m4')
-rw-r--r--usr.sbin/nsd/acx_nlnetlabs.m4276
1 files changed, 198 insertions, 78 deletions
diff --git a/usr.sbin/nsd/acx_nlnetlabs.m4 b/usr.sbin/nsd/acx_nlnetlabs.m4
index 3baa9d3bf13..bb7ac286722 100644
--- a/usr.sbin/nsd/acx_nlnetlabs.m4
+++ b/usr.sbin/nsd/acx_nlnetlabs.m4
@@ -2,10 +2,17 @@
# Copyright 2009, Wouter Wijngaards, NLnet Labs.
# BSD licensed.
#
-# Version 2
-# 2009-07-03
-# Changelog
-# - fixup LDFLAGS for empty ssl dir.
+# Version 8
+# 2010-03-01 Fix RPATH using CONFIG_COMMANDS to run at the very end.
+# 2010-02-18 WITH_SSL outputs the LIBSSL_LDFLAGS, LIBS, CPPFLAGS seperate, -ldl
+# 2010-02-01 added ACX_CHECK_MEMCMP_SIGNED, AHX_MEMCMP_BROKEN
+# 2010-01-20 added AHX_COONFIG_STRLCAT
+# 2009-07-14 U_CHAR detection improved for windows crosscompile.
+# added ACX_FUNC_MALLOC
+# fixup some #if to #ifdef
+# NONBLOCKING test for mingw crosscompile.
+# 2009-07-13 added ACX_WITH_SSL_OPTIONAL
+# 2009-07-03 fixup LDFLAGS for empty ssl dir.
#
# Automates some of the checking constructs. Aims at portability for POSIX.
# Documentation for functions is below.
@@ -30,6 +37,8 @@
# ACX_TYPE_IN_PORT_T - in_port_t type.
# ACX_ARG_RPATH - add --disable-rpath option.
# ACX_WITH_SSL - add --with-ssl option, link -lcrypto.
+# ACX_WITH_SSL_OPTIONAL - add --with-ssl option, link -lcrypto,
+# where --without-ssl is also accepted
# ACX_LIB_SSL - setup to link -lssl.
# ACX_SYS_LARGEFILE - improved sys_largefile, fseeko, >2G files.
# ACX_CHECK_GETADDRINFO_WITH_INCLUDES - find getaddrinfo, portably.
@@ -37,6 +46,7 @@
# ACX_CHECK_NONBLOCKING_BROKEN - see if nonblocking sockets really work.
# ACX_MKDIR_ONE_ARG - determine mkdir(2) number of arguments.
# ACX_FUNC_IOCTLSOCKET - find ioctlsocket, portably.
+# ACX_FUNC_MALLOC - check malloc, define replacement .
# AHX_CONFIG_FORMAT_ATTRIBUTE - config.h text for format.
# AHX_CONFIG_UNUSED_ATTRIBUTE - config.h text for unused.
# AHX_CONFIG_FSEEKO - define fseeko, ftello fallback.
@@ -48,6 +58,7 @@
# AHX_CONFIG_INET_NTOP - inet_ntop compat prototype
# AHX_CONFIG_INET_ATON - inet_aton compat prototype
# AHX_CONFIG_MEMMOVE - memmove compat prototype
+# AHX_CONFIG_STRLCAT - strlcat compat prototype
# AHX_CONFIG_STRLCPY - strlcpy compat prototype
# AHX_CONFIG_GMTIME_R - gmtime_r compat prototype
# AHX_CONFIG_W32_SLEEP - w32 compat for sleep
@@ -60,6 +71,8 @@
# AHX_CONFIG_FLAG_OMITTED - define omitted flag
# AHX_CONFIG_FLAG_EXT - define omitted extension flag
# AHX_CONFIG_EXT_FLAGS - define the stripped extension flags
+# ACX_CHECK_MEMCMP_SIGNED - check if memcmp uses signed characters.
+# AHX_MEMCMP_BROKEN - replace memcmp func for CHECK_MEMCMP_SIGNED.
#
dnl Escape backslashes as \\, for C:\ paths, for the C preprocessor defines.
@@ -480,14 +493,20 @@ AC_PROG_LIBTOOL
dnl Detect if u_char type is defined, otherwise define it.
AC_DEFUN([ACX_TYPE_U_CHAR],
- [AC_CHECK_TYPE(u_char, unsigned char)])
+[AC_CHECK_TYPE([u_char], ,
+ [AC_DEFINE([u_char], [unsigned char], [Define to 'unsigned char if not defined])], [
+AC_INCLUDES_DEFAULT
+#ifdef HAVE_WINSOCK2_H
+# include <winsock2.h>
+#endif
+]) ])
dnl Detect if rlim_t type is defined, otherwise define it.
AC_DEFUN([ACX_TYPE_RLIM_T],
[AC_CHECK_TYPE(rlim_t, ,
[AC_DEFINE([rlim_t], [unsigned long], [Define to 'int' if not defined])], [
AC_INCLUDES_DEFAULT
-#if HAVE_SYS_RESOURCE_H
+#ifdef HAVE_SYS_RESOURCE_H
# include <sys/resource.h>
#endif
]) ])
@@ -498,31 +517,34 @@ AC_DEFUN([ACX_TYPE_SOCKLEN_T],
AC_CHECK_TYPE(socklen_t, ,
[AC_DEFINE([socklen_t], [int], [Define to 'int' if not defined])], [
AC_INCLUDES_DEFAULT
-#if HAVE_SYS_SOCKET_H
+#ifdef HAVE_SYS_SOCKET_H
# include <sys/socket.h>
#endif
+#ifdef HAVE_WS2TCPIP_H
+# include <ws2tcpip.h>
+#endif
]) ])
-dnl Detect if socklen_t type is defined, otherwise define it.
+dnl Detect if in_addr_t type is defined, otherwise define it.
AC_DEFUN([ACX_TYPE_IN_ADDR_T],
[ AC_CHECK_TYPE(in_addr_t, [], [AC_DEFINE([in_addr_t], [uint32_t], [in_addr_t])], [
AC_INCLUDES_DEFAULT
-#if HAVE_SYS_TYPES_H
+#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
-#if HAVE_NETINET_IN_H
+#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
]) ])
-dnl Detect if socklen_t type is defined, otherwise define it.
+dnl Detect if in_port_t type is defined, otherwise define it.
AC_DEFUN([ACX_TYPE_IN_PORT_T],
[ AC_CHECK_TYPE(in_port_t, [], [AC_DEFINE([in_port_t], [uint16_t], [in_port_t])], [
AC_INCLUDES_DEFAULT
-#if HAVE_SYS_TYPES_H
+#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
-#if HAVE_NETINET_IN_H
+#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
]) ])
@@ -535,12 +557,14 @@ AC_ARG_ENABLE(rpath,
[ --disable-rpath disable hardcoded rpath (default=enabled)],
enable_rpath=$enableval, enable_rpath=yes)
if test "x$enable_rpath" = xno; then
- AC_MSG_RESULT([Fixing libtool for -rpath problems.])
+ dnl AC_MSG_RESULT([Fixing libtool for -rpath problems.])
+ AC_CONFIG_COMMANDS([disable-rpath], [
sed < libtool > libtool-2 \
's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_RPATH_SED__ "/'
mv libtool-2 libtool
chmod 755 libtool
libtool="./libtool"
+ ])
fi
])
@@ -555,22 +579,11 @@ AC_DEFUN([ACX_RUNTIME_PATH_ADD], [
fi
])
-dnl Check for SSL.
-dnl Adds --with-ssl option, searches for openssl and defines HAVE_SSL if found
-dnl Setup of CPPFLAGS, CFLAGS. Adds -lcrypto to LIBS.
-dnl Checks main header files of SSL.
-dnl
-AC_DEFUN([ACX_WITH_SSL],
-[
-AC_ARG_WITH(ssl, AC_HELP_STRING([--with-ssl=pathname],
- [enable SSL (will check /usr/local/ssl
- /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /opt/local /usr/sfw /usr)]),[
- ],[
- withval="yes"
- ])
- if test x_$withval = x_no; then
- AC_MSG_ERROR([Need SSL library to do digital signature cryptography])
- fi
+dnl Common code for both ACX_WITH_SSL and ACX_WITH_SSL_OPTIONAL
+dnl Takes one argument; the withval checked in those 2 functions
+dnl sets up the environment for the given openssl path
+AC_DEFUN([ACX_SSL_CHECKS], [
+ withval=$1
if test x_$withval != x_no; then
AC_MSG_CHECKING(for SSL)
if test x_$withval = x_ -o x_$withval = x_yes; then
@@ -581,10 +594,11 @@ AC_ARG_WITH(ssl, AC_HELP_STRING([--with-ssl=pathname],
if test -f "$dir/include/openssl/ssl.h"; then
found_ssl="yes"
AC_DEFINE_UNQUOTED([HAVE_SSL], [], [Define if you have the SSL libraries installed.])
- dnl assume /usr/include is already in the include-path.
- if test "$ssldir" != "/usr"; then
- CPPFLAGS="$CPPFLAGS -I$ssldir/include"
- fi
+ dnl assume /usr/include is already in the include-path.
+ if test "$ssldir" != "/usr"; then
+ CPPFLAGS="$CPPFLAGS -I$ssldir/include"
+ LIBSSL_CPPFLAGS="$LIBSSL_CPPFLAGS -I$ssldir/include"
+ fi
break;
fi
done
@@ -593,61 +607,108 @@ AC_ARG_WITH(ssl, AC_HELP_STRING([--with-ssl=pathname],
else
AC_MSG_RESULT(found in $ssldir)
HAVE_SSL=yes
- dnl assume /usr is already in the lib and dynlib paths.
- if test "$ssldir" != "/usr" -a "$ssldir" != ""; then
+ dnl assume /usr is already in the lib and dynlib paths.
+ if test "$ssldir" != "/usr" -a "$ssldir" != ""; then
LDFLAGS="$LDFLAGS -L$ssldir/lib"
- ACX_RUNTIME_PATH_ADD([$ssldir/lib])
- fi
-
- AC_MSG_CHECKING([for HMAC_CTX_init in -lcrypto])
- LIBS="$LIBS -lcrypto"
- AC_TRY_LINK(, [
- int HMAC_CTX_init(void);
- (void)HMAC_CTX_init();
- ], [
- AC_MSG_RESULT(yes)
- AC_DEFINE([HAVE_HMAC_CTX_INIT], 1,
- [If you have HMAC_CTX_init])
- ], [
- AC_MSG_RESULT(no)
- # check if -lwsock32 or -lgdi32 are needed.
- BAKLIBS="$LIBS"
- LIBS="$LIBS -lgdi32"
- AC_MSG_CHECKING([if -lcrypto needs -lgdi32])
- AC_TRY_LINK([], [
- int HMAC_CTX_init(void);
- (void)HMAC_CTX_init();
- ],[
- AC_DEFINE([HAVE_HMAC_CTX_INIT], 1,
- [If you have HMAC_CTX_init])
- AC_MSG_RESULT(yes)
- ],[
- AC_MSG_RESULT(no)
- LIBS="$BAKLIBS"
- LIBS="$LIBS -ldl"
- AC_MSG_CHECKING([if -lcrypto needs -ldl])
- AC_TRY_LINK([], [
- int HMAC_CTX_init(void);
- (void)HMAC_CTX_init();
- ],[
- AC_DEFINE([HAVE_HMAC_CTX_INIT], 1,
- [If you have HMAC_CTX_init])
- AC_MSG_RESULT(yes)
- ],[
- AC_MSG_RESULT(no)
+ LIBSSL_LDFLAGS="$LIBSSL_LDFLAGS -L$ssldir/lib"
+ ACX_RUNTIME_PATH_ADD([$ssldir/lib])
+ fi
+
+ AC_MSG_CHECKING([for HMAC_CTX_init in -lcrypto])
+ LIBS="$LIBS -lcrypto"
+ LIBSSL_LIBS="$LIBSSL_LIBS -lcrypto"
+ AC_TRY_LINK(, [
+ int HMAC_CTX_init(void);
+ (void)HMAC_CTX_init();
+ ], [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE([HAVE_HMAC_CTX_INIT], 1,
+ [If you have HMAC_CTX_init])
+ ], [
+ AC_MSG_RESULT(no)
+ # check if -lwsock32 or -lgdi32 are needed.
+ BAKLIBS="$LIBS"
+ BAKSSLLIBS="$LIBSSL_LIBS"
+ LIBS="$LIBS -lgdi32"
+ LIBSSL_LIBS="$LIBSSL_LIBS -lgdi32"
+ AC_MSG_CHECKING([if -lcrypto needs -lgdi32])
+ AC_TRY_LINK([], [
+ int HMAC_CTX_init(void);
+ (void)HMAC_CTX_init();
+ ],[
+ AC_DEFINE([HAVE_HMAC_CTX_INIT], 1,
+ [If you have HMAC_CTX_init])
+ AC_MSG_RESULT(yes)
+ ],[
+ AC_MSG_RESULT(no)
+ LIBS="$BAKLIBS"
+ LIBSSL_LIBS="$BAKSSLLIBS"
+ LIBS="$LIBS -ldl"
+ LIBSSL_LIBS="$LIBSSL_LIBS -ldl"
+ AC_MSG_CHECKING([if -lcrypto needs -ldl])
+ AC_TRY_LINK([], [
+ int HMAC_CTX_init(void);
+ (void)HMAC_CTX_init();
+ ],[
+ AC_DEFINE([HAVE_HMAC_CTX_INIT], 1,
+ [If you have HMAC_CTX_init])
+ AC_MSG_RESULT(yes)
+ ],[
+ AC_MSG_RESULT(no)
AC_MSG_ERROR([OpenSSL found in $ssldir, but version 0.9.7 or higher is required])
- ])
- ])
+ ])
+ ])
])
fi
AC_SUBST(HAVE_SSL)
- AC_SUBST(RUNTIME_PATH)
+ AC_SUBST(RUNTIME_PATH)
+ # openssl engine functionality needs dlopen().
+ BAKLIBS="$LIBS"
+ AC_SEARCH_LIBS([dlopen], [dl])
+ if test "$LIBS" != "$BAKLIBS"; then
+ LIBSSL_LIBS="$LIBSSL_LIBS -ldl"
+ fi
fi
AC_CHECK_HEADERS([openssl/ssl.h],,, [AC_INCLUDES_DEFAULT])
AC_CHECK_HEADERS([openssl/err.h],,, [AC_INCLUDES_DEFAULT])
AC_CHECK_HEADERS([openssl/rand.h],,, [AC_INCLUDES_DEFAULT])
+])dnl End of ACX_SSL_CHECKS
+
+dnl Check for SSL, where SSL is mandatory
+dnl Adds --with-ssl option, searches for openssl and defines HAVE_SSL if found
+dnl Setup of CPPFLAGS, CFLAGS. Adds -lcrypto to LIBS.
+dnl Checks main header files of SSL.
+dnl
+AC_DEFUN([ACX_WITH_SSL],
+[
+AC_ARG_WITH(ssl, AC_HELP_STRING([--with-ssl=pathname],
+ [enable SSL (will check /usr/local/ssl
+ /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /opt/local /usr/sfw /usr)]),[
+ ],[
+ withval="yes"
+ ])
+ if test x_$withval = x_no; then
+ AC_MSG_ERROR([Need SSL library to do digital signature cryptography])
+ fi
+ ACX_SSL_CHECKS($withval)
])dnl End of ACX_WITH_SSL
+dnl Check for SSL, where ssl is optional (--without-ssl is allowed)
+dnl Adds --with-ssl option, searches for openssl and defines HAVE_SSL if found
+dnl Setup of CPPFLAGS, CFLAGS. Adds -lcrypto to LIBS.
+dnl Checks main header files of SSL.
+dnl
+AC_DEFUN([ACX_WITH_SSL_OPTIONAL],
+[
+AC_ARG_WITH(ssl, AC_HELP_STRING([--with-ssl=pathname],
+ [enable SSL (will check /usr/local/ssl
+ /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /opt/local /usr/sfw /usr)]),[
+ ],[
+ withval="yes"
+ ])
+ ACX_SSL_CHECKS($withval)
+])dnl End of ACX_WITH_SSL_OPTIONAL
+
dnl Setup to use -lssl
dnl To use -lcrypto, use the ACX_WITH_SSL setup (before this one).
AC_DEFUN([ACX_LIB_SSL],
@@ -779,6 +840,10 @@ dnl a nonblocking socket do not work, a new call to select is necessary.
AC_DEFUN([ACX_CHECK_NONBLOCKING_BROKEN],
[
AC_MSG_CHECKING([if nonblocking sockets work])
+if echo $target | grep mingw32 >/dev/null; then
+ AC_MSG_RESULT([no (windows)])
+ AC_DEFINE([NONBLOCKING_IS_BROKEN], 1, [Define if the network stack does not fully support nonblocking io (causes lower performance).])
+else
AC_RUN_IFELSE(AC_LANG_PROGRAM([
#include <stdio.h>
#include <string.h>
@@ -904,6 +969,7 @@ AC_RUN_IFELSE(AC_LANG_PROGRAM([
], [
AC_MSG_RESULT([crosscompile(yes)])
])
+fi
])dnl End of ACX_CHECK_NONBLOCKING_BROKEN
dnl Check if mkdir has one or two arguments.
@@ -947,6 +1013,16 @@ AC_DEFINE(HAVE_IOCTLSOCKET, 1, [if the function 'ioctlsocket' is available])
],[AC_MSG_RESULT(no)])
])dnl end of ACX_FUNC_IOCTLSOCKET
+dnl detect malloc and provide malloc compat prototype.
+dnl $1: unique name for compat code
+AC_DEFUN([ACX_FUNC_MALLOC],
+[
+ AC_FUNC_MALLOC
+ if test "$ac_cv_func_malloc_0_nonnull" = no; then
+ AC_DEFINE_UNQUOTED([malloc], [rpl_malloc_$1], [Define if replacement function should be used.])
+ fi
+])
+
dnl Define fallback for fseeko and ftello if needed.
AC_DEFUN([AHX_CONFIG_FSEEKO],
[
@@ -1033,6 +1109,16 @@ void *memmove(void *dest, const void *src, size_t n);
#endif
])
+dnl provide strlcat compat prototype.
+dnl $1: unique name for compat code
+AC_DEFUN([AHX_CONFIG_STRLCAT],
+[
+#ifndef HAVE_STRLCAT
+#define strlcat strlcat_$1
+size_t strlcat(char *dst, const char *src, size_t siz);
+#endif
+])
+
dnl provide strlcpy compat prototype.
dnl $1: unique name for compat code
AC_DEFUN([AHX_CONFIG_STRLCPY],
@@ -1149,4 +1235,38 @@ AHX_CONFIG_FLAG_EXT(-D_ALL_SOURCE)
AHX_CONFIG_FLAG_EXT(-D_LARGEFILE_SOURCE=1)
])
+dnl check if memcmp is using signed characters and replace if so.
+AC_DEFUN([ACX_CHECK_MEMCMP_SIGNED],
+[AC_MSG_CHECKING([if memcmp compares unsigned])
+AC_RUN_IFELSE([AC_LANG_SOURCE([[
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+int main(void)
+{
+ char a = 255, b = 0;
+ if(memcmp(&a, &b, 1) < 0)
+ return 1;
+ return 0;
+}
+]])], [AC_MSG_RESULT([yes]) ],
+[ AC_MSG_RESULT([no])
+ AC_DEFINE([MEMCMP_IS_BROKEN], [1], [Define if memcmp() does not compare unsigned bytes])
+ AC_LIBOBJ([memcmp])
+], [ AC_MSG_RESULT([cross-compile no])
+ AC_DEFINE([MEMCMP_IS_BROKEN], [1], [Define if memcmp() does not compare unsigned bytes])
+ AC_LIBOBJ([memcmp])
+]) ])
+
+dnl define memcmp to its replacement, pass unique id for program as arg
+AC_DEFUN([AHX_MEMCMP_BROKEN], [
+#ifdef MEMCMP_IS_BROKEN
+# ifdef memcmp
+# undef memcmp
+# endif
+#define memcmp memcmp_$1
+int memcmp(const void *x, const void *y, size_t n);
+#endif
+])
+
dnl End of file