]> git.ipfire.org Git - thirdparty/lldpd.git/blobdiff - configure.ac
tests: fix skip instruction
[thirdparty/lldpd.git] / configure.ac
index f8be3b4ff5334a93cc5050a351429a6d170520ec..2741f374a81ef6b2cfaeca253241c80537e22e59 100644 (file)
@@ -48,7 +48,6 @@ AC_PROG_CC_C99
 if test x"$ac_cv_prog_cc_c99" = x"no"; then
   AC_MSG_FAILURE([*** C99 support is mandatory])
 fi
-AC_PROG_CXX
 AM_PROG_CC_C_O
 AC_PROG_LIBTOOL
 AC_PROG_LN_S
@@ -77,19 +76,21 @@ AX_CFLAGS_GCC_OPTION([-W], [LLDP_CFLAGS])
 AX_CFLAGS_GCC_OPTION([-Wextra], [LLDP_CFLAGS])
 AX_CFLAGS_GCC_OPTION([-Wformat], [LLDP_CFLAGS])
 AX_CFLAGS_GCC_OPTION([-Wformat-security], [LLDP_CFLAGS])
+AX_CFLAGS_GCC_OPTION([-Wimplicit-fallthrough], [LLDP_CFLAGS])
 AX_CFLAGS_GCC_OPTION([-Wfatal-errors], [LLDP_CFLAGS])
-AX_CFLAGS_GCC_OPTION([-Wcast-align], [LLDP_CFLAGS])
 AX_CFLAGS_GCC_OPTION([-Wheader-guard], [LLDP_CFLAGS])
 AX_CFLAGS_GCC_OPTION([-Wdocumentation], [LLDP_CFLAGS])
 AX_CFLAGS_GCC_OPTION([-Winline], [LLDP_CFLAGS])
 AX_CFLAGS_GCC_OPTION([-Wpointer-arith], [LLDP_CFLAGS])
 AX_CFLAGS_GCC_OPTION([-fno-omit-frame-pointer], [LLDP_CFLAGS])
+AX_CFLAGS_GCC_OPTION([-Wno-cast-align], [LLDP_CFLAGS]) dnl clang is bad at this
 AX_CFLAGS_GCC_OPTION([-Wno-unused-parameter], [LLDP_CFLAGS])
 AX_CFLAGS_GCC_OPTION([-Wno-missing-field-initializers], [LLDP_CFLAGS])
 AX_CFLAGS_GCC_OPTION([-Wno-sign-compare], [LLDP_CFLAGS]) dnl Should be fixed later
 AX_LDFLAGS_OPTION([-Wl,-z,relro], [LLDP_LDFLAGS])
 AX_LDFLAGS_OPTION([-Wl,-z,now], [LLDP_LDFLAGS])
-lldp_CHECK_CTORS
+
+AC_C_TYPEOF
 
 # Hardening
 AC_ARG_ENABLE([hardening],
@@ -107,6 +108,8 @@ if test x"$hardening" != x"no"; then
   AX_CFLAGS_GCC_OPTION([-fstack-protector], [LLDP_CFLAGS])
   AX_CFLAGS_GCC_OPTION([-fstack-protector-all], [LLDP_CFLAGS])
   AX_CFLAGS_GCC_OPTION([-fstack-protector-strong], [LLDP_CFLAGS])
+  AX_CFLAGS_GCC_OPTION([-fstack-protector-strong], [LLDP_CFLAGS])
+  AX_CFLAGS_GCC_OPTION([-fstack-clash-protection], [LLDP_CFLAGS])
   AX_CFLAGS_GCC_OPTION([-D_FORTIFY_SOURCE=2], [LLDP_CPPFLAGS])
 fi
 if test x"$pie" = x"yes"; then
@@ -117,8 +120,7 @@ fi
 
 # Sanitizers
 AC_ARG_ENABLE([sanitizers],
-  AS_HELP_STRING(
-    [--enable-sanitizers],
+  AS_HELP_STRING([--enable-sanitizers],
     [Enable code instrumentation with selected sanitizers @<:@default=no@:>@]),
   [
 case "$enableval" in
@@ -130,9 +132,25 @@ if test x"$sanitizers" != x; then
   LLDP_CFLAGS="$LLDP_CFLAGS $sanitizers"
   LLDP_LDFLAGS="$LLDP_LDFLAGS $sanitizers"
   AC_DEFINE([HAVE_ADDRESS_SANITIZER], 1, [Define if have both address and leak sanitizer])
+elif test x"$hardening" != x"no"; then
+  AX_LDFLAGS_OPTION([-fsanitize=safe-stack], [LLDP_BIN_LDFLAGS])
+  if test x"$ax_cv_ld_check_flag__fsanitize_safe_stack" != x"no"; then
+    AX_CFLAGS_GCC_OPTION([-fsanitize=safe-stack], [LLDP_CFLAGS])
+  fi
 fi
   ])
 
+# Code coverage
+AC_ARG_ENABLE([gcov],
+  AS_HELP_STRING([--enable-gcov],
+    [Enable coverage instrumentation @<:@default=no@:>@]),
+    [gcov="$enableval"],
+    [gcov="no"])
+if test x"$gcov" != x"no"; then
+  LLDP_CFLAGS="$LLDP_CFLAGS --coverage"
+  LLDP_LDFLAGS="$LLDP_LDFLAGS --coverage"
+fi
+
 # OS
 lldp_CHECK_OS
 lldp_CFLAGS_OS
@@ -157,23 +175,44 @@ AC_FUNC_REALLOC
 AC_FUNC_FORK
 
 # Some functions can be in libbsd
-PKG_CHECK_MODULES([libbsd], [libbsd-overlay], [
-  _save_CFLAGS="$CFLAGS"
-  _save_LIBS="$LIBS"
-  CFLAGS="$CFLAGS $libbsd_CFLAGS"
-  LIBS="$LIBS $libbsd_LIBS"
-  AC_MSG_CHECKING([if libbsd can be linked correctly])
-  AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])],
-    [
-      AC_MSG_RESULT(yes)
-      LLDP_CFLAGS="$LLDP_CFLAGS $libbsd_CFLAGS"
-      LLDP_LDFLAGS="$LLDP_LDFLAGS $libbsd_LIBS"
-    ],[
-      AC_MSG_RESULT(no)
-      CFLAGS="$_save_CFLAGS"
-      LIBS="$_save_LIBS"
-    ])
-], [:])
+AC_ARG_WITH([libbsd],
+  AS_HELP_STRING(
+    [--with-libbsd],
+    [Use libbsd @<:@default=auto@:>@]),
+  [],
+  [with_libbsd=auto])
+if test x"$with_libbsd" != x"no"; then
+  PKG_CHECK_MODULES([libbsd], [libbsd-overlay], [
+    _save_CFLAGS="$CFLAGS"
+    _save_LIBS="$LIBS"
+    CFLAGS="$CFLAGS $libbsd_CFLAGS"
+    LIBS="$LIBS $libbsd_LIBS"
+    AC_MSG_CHECKING([if libbsd can be linked correctly])
+    AC_TRY_LINK([
+  @%:@include <sys/time.h>
+  @%:@include <sys/types.h>
+  ],[],
+      [
+        AC_MSG_RESULT(yes)
+        LLDP_CFLAGS="$LLDP_CFLAGS $libbsd_CFLAGS"
+        LLDP_LDFLAGS="$LLDP_LDFLAGS $libbsd_LIBS"
+        with_libbsd=yes
+      ],[
+        AC_MSG_RESULT(no)
+        CFLAGS="$_save_CFLAGS"
+        LIBS="$_save_LIBS"
+        if test x"$with_libbsd" = x"yes"; then
+           AC_MSG_FAILURE([*** no libbsd support found])
+        fi
+        with_libbsd=no
+      ])
+  ], [
+    if test x"$with_libbsd" = x"yes"; then
+       AC_MSG_FAILURE([*** no libbsd support found])
+    fi
+    with_libbsd=no
+  ])
+fi
 
 # setproctitle may have an _init function
 AC_REPLACE_FUNCS([setproctitle])
@@ -182,6 +221,7 @@ AC_CHECK_FUNCS([setproctitle_init])
 AC_REPLACE_FUNCS([strlcpy
                   strnlen
                   strndup
+                  strtonum
                   getline
                   asprintf
                   vsyslog
@@ -202,10 +242,11 @@ m4_popdef([AC_LANG_CALL(C)])
 AC_CACHE_SAVE
 
 ## Unit tests wich check
-PKG_CHECK_MODULES([CHECK], [check >= 0.9.4], [have_check=yes], [have_check=no])
+PKG_CHECK_MODULES([check], [check >= 0.9.4], [have_check=yes], [have_check=no])
 
 # Third-party libraries
 lldp_CHECK_LIBEVENT
+lldp_CHECK_LIBCAP
 
 # Compatibility with pkg.m4 < 0.27
 m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR],
@@ -254,28 +295,8 @@ AC_ARG_WITH([xml],
   [with_xml=auto])
 lldp_CHECK_XML2
 
-# JSON
-AC_ARG_WITH([json],
-  AS_HELP_STRING(
-    [--with-json],
-    [Enable JSON output via janson or json-c @<:@default=auto@:>@]),
-  [],
-  [with_json=auto])
-if test x"$with_json" = x"yes" -o x"$with_json" = x"auto"; then
-   _with_json="$with_json"
-   with_json=auto
-   lldp_CHECK_JANSSON
-   if test x"$with_json" = x"no"; then
-     with_json=auto
-     lldp_CHECK_JSONC
-   fi
-   if test x"$with_json" = x"no" -a x"$_with_json" = x"yes"; then
-     AC_MSG_FAILURE([*** no JSON support found])
-   fi
-else
-   lldp_CHECK_JANSSON
-   lldp_CHECK_JSONC
-fi
+# JSON (built-in)
+lldp_ARG_ENABLE([json0], [use of pre-0.9.2 JSON/json-c format], [no])
 
 # Seccomp
 AC_ARG_WITH([seccomp],
@@ -312,7 +333,7 @@ lldp_ARG_WITH([apparmordir], [Directory for AppArmor profiles (Linux)],
                              [no])
 AC_SUBST([apparmordir], [$with_apparmordir])
 AM_CONDITIONAL(HAVE_APPARMORDIR,
-    [test -n "$with_apparmordir" -a "x$with_apprmordir" != xno ])
+    [test -n "$with_apparmordir" -a "x$with_apparmordir" != xno ])
 
 # Systemtap/DTrace
 lldp_SYSTEMTAP
@@ -331,6 +352,11 @@ lldp_ARG_WITH([privsep-chroot], [Which directory to use to chroot lldpd], [${run
 lldp_ARG_WITH([lldpd-ctl-socket], [Path to socket for communication with lldpd], [${runstatedir}/lldpd.socket])
 lldp_ARG_WITH([lldpd-pid-file], [Path to lldpd PID file], [${runstatedir}/lldpd.pid])
 
+# Netlink
+lldp_ARG_WITH_UNQUOTED([netlink-max-receive-bufsize], [Netlink maximum receive buffer size], [1024*1024])
+lldp_ARG_WITH_UNQUOTED([netlink-receive-bufsize], [Netlink initial receive buffer size], [0])
+lldp_ARG_WITH_UNQUOTED([netlink-send-bufsize], [Netlink send buffer size], [0])
+
 # CDP/FDP/EDP/SONMP
 lldp_ARG_ENABLE([cdp], [Cisco Discovery Protocol], [yes])
 lldp_ARG_ENABLE([fdp], [Foundry Discovery Protocol], [yes])
@@ -354,10 +380,8 @@ if test x"$os" = x"Linux"; then
     fi
 fi
 
-# Build date
-if test x"$SOURCE_DATE_EPOCH" != x; then
-   AC_DEFINE_UNQUOTED(BUILD_DATE, "[$SOURCE_DATE_EPOCH]", [Build date and time])
-fi
+AX_BUILD_DATE_EPOCH(BUILD_DATE, "%FT%TZ", [BUILD_DATE="(unknown)"])
+AC_DEFINE_UNQUOTED(BUILD_DATE, "[$BUILD_DATE]", [Build date and time])
 AC_DEFINE_UNQUOTED(LLDP_CC, "[$CC $LLDP_CFLAGS $LLDP_CPPFLAGS $CFLAGS $CPPFLAGS]", [C compiler command])
 AC_DEFINE_UNQUOTED(LLDP_LD, "[$LD $LLDP_LDFLAGS $LLDP_BIN_LDFLAGS $LDFLAGS $LIBS]", [Linker compiler command])
 
@@ -370,10 +394,12 @@ AC_SUBST([LLDP_BIN_LDFLAGS])
 AM_CONDITIONAL([HAVE_CHECK], [test x"$have_check" = x"yes"])
 AM_CONDITIONAL([USE_SNMP], [test x"$with_snmp" = x"yes"])
 AM_CONDITIONAL([USE_XML], [test x"$with_xml" = x"yes"])
-AM_CONDITIONAL([USE_JSON], [test x"$with_json" = x"json-c" || test -x"$with_json" = x"jansson"])
-AM_CONDITIONAL([USE_JANSSON], [test x"$with_json" = x"jansson"])
-AM_CONDITIONAL([USE_JSONC], [test x"$with_json" = x"json-c"])
 AM_CONDITIONAL([USE_SECCOMP], [test x"$with_seccomp" = x"yes"])
+dnl If old default of AR_FLAGS is otherwise being used (because of older automake),
+dnl replace it with one without 'u'
+if test "x$AR_FLAGS" = "xcru" ; then
+  AR_FLAGS="cr"
+fi
 AC_OUTPUT
 
 if test x"$LIBEVENT_EMBEDDED" = x; then
@@ -404,14 +430,18 @@ cat <<EOF
   DOT3...........: $enable_dot3
   CUSTOM.........: $enable_custom
   XML output.....: ${with_xml-no}
-  JSON output....: ${with_json-no}
   Oldies support.: $enable_oldies
   seccomp........: ${with_seccomp-no}
+  libbsd.........: ${with_libbsd-no}
 
  Privilege separation:
   Enabled........: $enable_privsep
   User/group.....: ${with_privsep_user}/${with_privsep_group}
   Chroot.........: ${with_privsep_chroot}
+
+ Instrumentation (for devs only):
+  Sanitizers.....: ${sanitizers:-none}
+  Coverage.......: ${gcov}
 ------------- Compiler version --------------
 $($CC --version || true)
 -------------- Linker version ---------------