build: default to c11 standard

Rearrange pcap includes to fix builds on MinGW
pull/4832/head
Victor Julien 6 years ago
parent 1893e40e79
commit f8159bd372

@ -323,14 +323,23 @@
esac esac
AC_MSG_RESULT(ok) AC_MSG_RESULT(ok)
# check if our target supports thread local storage # check if our target supports c11
AC_MSG_CHECKING(for thread local storage c11 thread_local support) AC_MSG_CHECKING(for c11 support)
OCFLAGS=$CFLAGS
CFLAGS="-std=c11"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>]], AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>]],
[[ static _Thread_local int i; i = 1; i++; ]])], [[ 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]) [AC_MSG_RESULT([no])
CFLAGS="$OCFLAGS"
have_c11=no
have_c11_tls=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 # check if our target supports thread local storage
AC_MSG_CHECKING(for thread local storage gnu __thread support) AC_MSG_CHECKING(for thread local storage gnu __thread support)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>]], AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <stdlib.h>]],
@ -1324,12 +1333,24 @@ return 0;
CPPFLAGS="${CPPFLAGS} -I${with_libpcap_includes}" CPPFLAGS="${CPPFLAGS} -I${with_libpcap_includes}"
fi 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 <winsock2.h>
#endif
#define _DEFAULT_SOURCE 1
]])
if test "$with_libpcap_libraries" != "no"; then if test "$with_libpcap_libraries" != "no"; then
LDFLAGS="${LDFLAGS} -L${with_libpcap_libraries}" LDFLAGS="${LDFLAGS} -L${with_libpcap_libraries}"
fi 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 <winsock2.h>
#endif
#define _DEFAULT_SOURCE 1
]])
LIBPCAP="" LIBPCAP=""
PKG_CHECK_MODULES([PCAP],libpcap,[CPPFLAGS="${CPPFLAGS} ${PCAP_CFLAGS}" LIBS="${LIBS} ${PCAP_LIBS}"],[:]) PKG_CHECK_MODULES([PCAP],libpcap,[CPPFLAGS="${CPPFLAGS} ${PCAP_CFLAGS}" LIBS="${LIBS} ${PCAP_LIBS}"],[:])

@ -197,32 +197,6 @@ typedef unsigned char u_char
#include <netdb.h> #include <netdb.h>
#endif #endif
#ifndef SC_PCAP_DONT_INCLUDE_PCAP_H
#ifdef HAVE_PCAP_H
#include <pcap.h>
#endif
#ifdef HAVE_PCAP_PCAP_H
#include <pcap/pcap.h>
#endif
#endif
#ifdef HAVE_UTIME_H
#include <utime.h>
#endif
#ifdef HAVE_LIBGEN_H
#include <libgen.h>
#endif
#ifdef HAVE_GRP_H
#include <grp.h>
#endif
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
#if __CYGWIN__ #if __CYGWIN__
#if !defined _X86_ && !defined __x86_64 #if !defined _X86_ && !defined __x86_64
#define _X86_ #define _X86_
@ -253,6 +227,32 @@ typedef unsigned char u_char
#include <w32api/wtypes.h> #include <w32api/wtypes.h>
#endif #endif
#ifndef SC_PCAP_DONT_INCLUDE_PCAP_H
#ifdef HAVE_PCAP_H
#include <pcap.h>
#endif
#ifdef HAVE_PCAP_PCAP_H
#include <pcap/pcap.h>
#endif
#endif
#ifdef HAVE_UTIME_H
#include <utime.h>
#endif
#ifdef HAVE_LIBGEN_H
#include <libgen.h>
#endif
#ifdef HAVE_GRP_H
#include <grp.h>
#endif
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
#include <jansson.h> #include <jansson.h>
#ifndef JSON_ESCAPE_SLASH #ifndef JSON_ESCAPE_SLASH
#define JSON_ESCAPE_SLASH 0 #define JSON_ESCAPE_SLASH 0

Loading…
Cancel
Save