From f8159bd37241f0363de9f4da794f7aea0b8fb7da Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Mon, 13 Apr 2020 09:10:20 +0200 Subject: [PATCH] build: default to c11 standard Rearrange pcap includes to fix builds on MinGW --- configure.ac | 33 ++++++++++++++++++++++----- src/suricata-common.h | 52 +++++++++++++++++++++---------------------- 2 files changed, 53 insertions(+), 32 deletions(-) diff --git a/configure.ac b/configure.ac index 37f81e930d..127848234d 100644 --- a/configure.ac +++ b/configure.ac @@ -323,14 +323,23 @@ esac AC_MSG_RESULT(ok) - # check if our target supports thread local storage - AC_MSG_CHECKING(for thread local storage c11 thread_local support) + # check if our target supports c11 + AC_MSG_CHECKING(for c11 support) + OCFLAGS=$CFLAGS + CFLAGS="-std=c11" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[ static _Thread_local int i; i = 1; i++; ]])], - [AC_DEFINE([TLS_C11], [1], [Thread local storage]) - AC_MSG_RESULT([yes])], + AC_MSG_RESULT([yes]) + [AC_DEFINE([TLS_C11], [1], [C11 Thread local storage]) + CFLAGS="$OCFLAGS -std=c11"], [AC_MSG_RESULT([no]) + CFLAGS="$OCFLAGS" + have_c11=no have_c11_tls=no]) + if [ test "x$have_c11" = "xno" ]; then + CFLAGS="$CFLAGS -std=gnu99" + fi + # check if our target supports thread local storage AC_MSG_CHECKING(for thread local storage gnu __thread support) AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], @@ -1324,12 +1333,24 @@ return 0; CPPFLAGS="${CPPFLAGS} -I${with_libpcap_includes}" fi - AC_CHECK_HEADER(pcap.h,,[AC_MSG_ERROR(pcap.h not found ...)]) + AC_CHECK_HEADERS([pcap.h],[],[AC_MSG_ERROR(pcap.h not found ...)], + [[ + #ifdef HAVE_WINSOCK2_H + #include + #endif + #define _DEFAULT_SOURCE 1 + ]]) if test "$with_libpcap_libraries" != "no"; then LDFLAGS="${LDFLAGS} -L${with_libpcap_libraries}" fi - AC_CHECK_HEADERS([pcap.h pcap/pcap.h pcap/bpf.h]) + AC_CHECK_HEADERS([pcap.h pcap/pcap.h pcap/bpf.h],[],[], + [[ + #ifdef HAVE_WINSOCK2_H + #include + #endif + #define _DEFAULT_SOURCE 1 + ]]) LIBPCAP="" PKG_CHECK_MODULES([PCAP],libpcap,[CPPFLAGS="${CPPFLAGS} ${PCAP_CFLAGS}" LIBS="${LIBS} ${PCAP_LIBS}"],[:]) diff --git a/src/suricata-common.h b/src/suricata-common.h index 7c2a1d920f..b04f6da6e5 100644 --- a/src/suricata-common.h +++ b/src/suricata-common.h @@ -197,32 +197,6 @@ typedef unsigned char u_char #include #endif -#ifndef SC_PCAP_DONT_INCLUDE_PCAP_H -#ifdef HAVE_PCAP_H -#include -#endif - -#ifdef HAVE_PCAP_PCAP_H -#include -#endif -#endif - -#ifdef HAVE_UTIME_H -#include -#endif - -#ifdef HAVE_LIBGEN_H -#include -#endif - -#ifdef HAVE_GRP_H -#include -#endif - -#ifdef HAVE_PWD_H -#include -#endif - #if __CYGWIN__ #if !defined _X86_ && !defined __x86_64 #define _X86_ @@ -253,6 +227,32 @@ typedef unsigned char u_char #include #endif +#ifndef SC_PCAP_DONT_INCLUDE_PCAP_H +#ifdef HAVE_PCAP_H +#include +#endif + +#ifdef HAVE_PCAP_PCAP_H +#include +#endif +#endif + +#ifdef HAVE_UTIME_H +#include +#endif + +#ifdef HAVE_LIBGEN_H +#include +#endif + +#ifdef HAVE_GRP_H +#include +#endif + +#ifdef HAVE_PWD_H +#include +#endif + #include #ifndef JSON_ESCAPE_SLASH #define JSON_ESCAPE_SLASH 0 -- 2.47.2