summaryrefslogtreecommitdiffstats
path: root/usr.sbin/nsd/acx_nlnetlabs.m4
diff options
context:
space:
mode:
authorsthen <sthen@openbsd.org>2012-03-02 08:38:49 +0000
committersthen <sthen@openbsd.org>2012-03-02 08:38:49 +0000
commit044f85de9b3a9a419412d40324a941728546da27 (patch)
treeba6e6524923aa65c2ed25a1c7a7db934d8f68c67 /usr.sbin/nsd/acx_nlnetlabs.m4
parent_SPINLOCK_UNLOCKED isn't zero everywhere (*cough*hppa*cough*), so (diff)
downloadwireguard-openbsd-044f85de9b3a9a419412d40324a941728546da27.tar.xz
wireguard-openbsd-044f85de9b3a9a419412d40324a941728546da27.zip
import nsd 3.2.10, "cool" jakob@, also looked over by Brad
Diffstat (limited to 'usr.sbin/nsd/acx_nlnetlabs.m4')
-rw-r--r--usr.sbin/nsd/acx_nlnetlabs.m498
1 files changed, 80 insertions, 18 deletions
diff --git a/usr.sbin/nsd/acx_nlnetlabs.m4 b/usr.sbin/nsd/acx_nlnetlabs.m4
index 10fd9703b60..3a2e350823e 100644
--- a/usr.sbin/nsd/acx_nlnetlabs.m4
+++ b/usr.sbin/nsd/acx_nlnetlabs.m4
@@ -1,8 +1,18 @@
# acx_nlnetlabs.m4 - common macros for configure checks
-# Copyright 2009-2011, NLnet Labs, Wouter Wijngaards.
+# Copyright 2009, Wouter Wijngaards, NLnet Labs.
# BSD licensed.
#
-# Version 10
+# Version 20
+# 2012-01-20 Fix COMPILER_FLAGS_UNBOUND for gcc 4.6.2 assigned-not-used-warns.
+# 2011-12-05 Fix getaddrinfowithincludes on windows with fedora16 mingw32-gcc.
+# Fix ACX_MALLOC for redefined malloc error.
+# Fix GETADDRINFO_WITH_INCLUDES to add -lws2_32
+# 2011-11-10 Fix FLTO test to not drop a.out in current directory.
+# 2011-11-01 Fix FLTO test for llvm on Lion.
+# 2011-08-01 Fix nonblock test (broken at v13).
+# 2011-08-01 Fix autoconf 2.68 warnings
+# 2011-06-23 Add ACX_CHECK_FLTO to check -flto.
+# 2010-08-16 Fix FLAG_OMITTED for AS_TR_CPP changes in autoconf-2.66.
# 2010-07-02 Add check for ss_family (for minix).
# 2010-04-26 Fix to use CPPFLAGS for CHECK_COMPILER_FLAGS.
# 2010-03-01 Fix RPATH using CONFIG_COMMANDS to run at the very end.
@@ -31,6 +41,7 @@
# ACX_DETERMINE_EXT_FLAGS_UNBOUND - find out which flags enable BSD and POSIX.
# ACX_CHECK_FORMAT_ATTRIBUTE - find cc printf format syntax.
# ACX_CHECK_UNUSED_ATTRIBUTE - find cc variable unused syntax.
+# ACX_CHECK_FLTO - see if cc supports -flto and use it if so.
# ACX_LIBTOOL_C_ONLY - create libtool for C only, improved.
# ACX_TYPE_U_CHAR - u_char type.
# ACX_TYPE_RLIM_T - rlim_t type.
@@ -249,6 +260,8 @@ int test() {
a = getopt(2, opts, "a");
a = isascii(32);
str = gai_strerror(0);
+ if(str && t && tv.tv_usec && msg.msg_control)
+ a = 0;
return a;
}
], [CFLAGS="$CFLAGS $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_XOPEN_SOURCE_EXTENDED=1 -D_ALL_SOURCE"])
@@ -284,6 +297,8 @@ int test() {
a = getopt(2, opts, "a");
a = isascii(32);
str = gai_strerror(0);
+ if(str && t && tv.tv_usec && msg.msg_control)
+ a = 0;
return a;
}
], [CFLAGS="$CFLAGS $C99FLAG -D__EXTENSIONS__ -D_BSD_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -D_ALL_SOURCE"])
@@ -350,6 +365,8 @@ int test() {
const char* str = NULL;
t = ctime_r(&time, buf);
str = gai_strerror(0);
+ if(t && str)
+ a = 0;
return a;
}
], [CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200112"])
@@ -376,12 +393,32 @@ int test() {
srandom(32);
a = getopt(2, opts, "a");
a = isascii(32);
+ if(tv.tv_usec)
+ a = 0;
return a;
}
], [CFLAGS="$CFLAGS -D__EXTENSIONS__"])
])dnl End of ACX_DETERMINE_EXT_FLAGS_UNBOUND
+dnl Check if CC supports -flto.
+dnl in a way that supports clang and suncc (that flag does something else,
+dnl but fails to link). It sets it in CFLAGS if it works.
+AC_DEFUN([ACX_CHECK_FLTO],
+[AC_MSG_CHECKING([if $CC supports -flto])
+BAKCFLAGS="$CFLAGS"
+CFLAGS="$CFLAGS -flto"
+AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [
+ if $CC $CFLAGS -o conftest conftest.c 2>&1 | grep "warning: no debug symbols in executable" >/dev/null; then
+ CFLAGS="$BAKCFLAGS"
+ AC_MSG_RESULT(no)
+ else
+ AC_MSG_RESULT(yes)
+ fi
+ rm -f conftest conftest.c conftest.o
+], [CFLAGS="$BAKCFLAGS" ; AC_MSG_RESULT(no)])
+])
+
dnl Check the printf-format attribute (if any)
dnl result in HAVE_ATTR_FORMAT.
dnl Make sure you also include the AHX_CONFIG_FORMAT_ATTRIBUTE.
@@ -753,7 +790,7 @@ AC_DEFUN([ACX_CHECK_GETADDRINFO_WITH_INCLUDES],
AC_MSG_CHECKING(for getaddrinfo)
ac_cv_func_getaddrinfo=no
AC_LINK_IFELSE(
-[
+[AC_LANG_SOURCE([[
#ifdef __cplusplus
extern "C"
{
@@ -767,14 +804,21 @@ int main() {
;
return 0;
}
-],
+]])],
dnl this case on linux, solaris, bsd
-[ac_cv_func_getaddrinfo="yes"],
+[ac_cv_func_getaddrinfo="yes"
+dnl see if on windows
+if test "$ac_cv_header_windows_h" = "yes"; then
+ AC_DEFINE(USE_WINSOCK, 1, [Whether the windows socket API is used])
+ USE_WINSOCK="1"
+ LIBS="$LIBS -lws2_32"
+fi
+],
dnl no quick getaddrinfo, try mingw32 and winsock2 library.
ORIGLIBS="$LIBS"
LIBS="$LIBS -lws2_32"
AC_LINK_IFELSE(
-AC_LANG_PROGRAM(
+[AC_LANG_PROGRAM(
[
#ifdef HAVE_WS2TCPIP_H
#include <ws2tcpip.h>
@@ -783,7 +827,7 @@ AC_LANG_PROGRAM(
[
(void)getaddrinfo(NULL, NULL, NULL, NULL);
]
-),
+)],
[
ac_cv_func_getaddrinfo="yes"
dnl already: LIBS="$LIBS -lws2_32"
@@ -847,7 +891,8 @@ 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([
+AC_RUN_IFELSE([
+AC_LANG_SOURCE([[
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
@@ -871,7 +916,9 @@ AC_RUN_IFELSE(AC_LANG_PROGRAM([
#ifdef HAVE_TIME_H
#include <time.h>
#endif
-],[[
+
+int main(void)
+{
int port;
int sfd, cfd;
int num = 10;
@@ -964,7 +1011,9 @@ AC_RUN_IFELSE(AC_LANG_PROGRAM([
close(sfd);
close(cfd);
-]]), [
+ return 0;
+}
+]])], [
AC_MSG_RESULT([yes])
], [
AC_MSG_RESULT([no])
@@ -1004,13 +1053,13 @@ AC_DEFUN([ACX_FUNC_IOCTLSOCKET],
[
# check ioctlsocket
AC_MSG_CHECKING(for ioctlsocket)
-AC_LINK_IFELSE(AC_LANG_PROGRAM([
+AC_LINK_IFELSE([AC_LANG_PROGRAM([
#ifdef HAVE_WINSOCK2_H
#include <winsock2.h>
#endif
], [
(void)ioctlsocket(0, 0, NULL);
-]), [
+])], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_IOCTLSOCKET, 1, [if the function 'ioctlsocket' is available])
],[AC_MSG_RESULT(no)])
@@ -1020,10 +1069,23 @@ 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
+ AC_MSG_CHECKING([for GNU libc compatible malloc])
+ AC_RUN_IFELSE([AC_LANG_PROGRAM(
+[[#if defined STDC_HEADERS || defined HAVE_STDLIB_H
+#include <stdlib.h>
+#else
+char *malloc ();
+#endif
+]], [ if(malloc(0) != 0) return 1;])
+],
+ [AC_MSG_RESULT([no])
+ AC_LIBOBJ(malloc)
+ AC_DEFINE_UNQUOTED([malloc], [rpl_malloc_$1], [Define if replacement function should be used.])] ,
+ [AC_MSG_RESULT([yes])
+ AC_DEFINE([HAVE_MALLOC], 1, [If have GNU libc compatible malloc])],
+ [AC_MSG_RESULT([no (crosscompile)])
+ AC_LIBOBJ(malloc)
+ AC_DEFINE_UNQUOTED([malloc], [rpl_malloc_$1], [Define if replacement function should be used.])] )
])
dnl Define fallback for fseeko and ftello if needed.
@@ -1192,7 +1254,7 @@ AC_DEFUN([ACX_CFLAGS_STRIP],
[
if echo $CFLAGS | grep " $1" >/dev/null 2>&1; then
CFLAGS="`echo $CFLAGS | sed -e 's/ $1//g'`"
- AC_DEFINE(AS_TR_CPP(OMITTED_$1), 1, Put $1 define in config.h)
+ AC_DEFINE(m4_bpatsubst(OMITTED_$1,[[-=]],_), 1, Put $1 define in config.h)
fi
])
@@ -1223,7 +1285,7 @@ AC_DEFUN([AHX_CONFIG_FLAG_OMITTED],
dnl Wrapper for AHX_CONFIG_FLAG_OMITTED for -D style flags
dnl $1: the -DNAME or -DNAME=value string.
AC_DEFUN([AHX_CONFIG_FLAG_EXT],
-[AHX_CONFIG_FLAG_OMITTED(AS_TR_CPP(OMITTED_$1),m4_bpatsubst(m4_bpatsubst($1,-D,),=.*$,),m4_if(m4_bregexp($1,=),-1,1,m4_bpatsubst($1,^.*=,)))
+[AHX_CONFIG_FLAG_OMITTED(m4_bpatsubst(OMITTED_$1,[[-=]],_),m4_bpatsubst(m4_bpatsubst($1,-D,),=.*$,),m4_if(m4_bregexp($1,=),-1,1,m4_bpatsubst($1,^.*=,)))
])
dnl config.h part to define omitted cflags, use with ACX_STRIP_EXT_FLAGS.