]> git.ipfire.org Git - thirdparty/lldpd.git/blobdiff - configure.ac
tests: fix when Dot3 is not enabled
[thirdparty/lldpd.git] / configure.ac
index 814251473e8f1813ab1432cdffdc30201abca305..532d0a8d9e297a5309783f13fed8ec1548d5c4a9 100644 (file)
@@ -89,7 +89,8 @@ 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],
@@ -115,6 +116,34 @@ if test x"$pie" = x"yes"; then
     [AX_LDFLAGS_OPTION([-fPIE -Wl,-pie], [LLDP_BIN_LDFLAGS])])
 fi
 
+# Sanitizers
+AC_ARG_ENABLE([sanitizers],
+  AS_HELP_STRING([--enable-sanitizers],
+    [Enable code instrumentation with selected sanitizers @<:@default=no@:>@]),
+  [
+case "$enableval" in
+    no) sanitizers= ;;
+    yes) sanitizers="-fsanitize=address,undefined" ;;
+    *) sanitizers="-fsanitize=$enableval" ;;
+esac
+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])
+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
@@ -145,7 +174,10 @@ PKG_CHECK_MODULES([libbsd], [libbsd-overlay], [
   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_TRY_LINK([
+@%:@include <sys/time.h>
+@%:@include <sys/types.h>
+],[],
     [
       AC_MSG_RESULT(yes)
       LLDP_CFLAGS="$LLDP_CFLAGS $libbsd_CFLAGS"
@@ -164,6 +196,7 @@ AC_CHECK_FUNCS([setproctitle_init])
 AC_REPLACE_FUNCS([strlcpy
                   strnlen
                   strndup
+                  strtonum
                   getline
                   asprintf
                   vsyslog
@@ -171,9 +204,6 @@ AC_REPLACE_FUNCS([strlcpy
 # Optional functions
 AC_CHECK_FUNCS([setresuid setresgid])
 
-CFLAGS="$_save_CFLAGS"
-LIBS="$_save_LIBS"
-
 # Check for res_init. On OSX, res_init is a symbol in libsystem_info
 # and a macro in resolv.h. We need to ensure we test with resolv.h.
 m4_pushdef([AC_LANG_CALL(C)], [
@@ -261,6 +291,7 @@ else
    lldp_CHECK_JANSSON
    lldp_CHECK_JSONC
 fi
+lldp_ARG_ENABLE([json0], [use of pre-0.9.2 JSON/json-c format], [no])
 
 # Seccomp
 AC_ARG_WITH([seccomp],
@@ -297,7 +328,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
@@ -339,6 +370,11 @@ if test x"$os" = x"Linux"; then
     fi
 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])
+
 #######################
 # Output results
 AC_SUBST([LLDP_CFLAGS])
@@ -352,6 +388,11 @@ AM_CONDITIONAL([USE_JSON], [test x"$with_json" = x"json-c" || test -x"$with_json
 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
@@ -370,6 +411,7 @@ cat <<EOF
   Linker.........: $LD $LLDP_LDFLAGS $LLDP_BIN_LDFLAGS $LDFLAGS $LIBS
   Libevent.......: $libevent
   Readline.......: ${ax_cv_lib_readline}
+
  Optional features:
   SNMP support...: ${with_snmp-no}
   CDP............: $enable_cdp
@@ -384,10 +426,19 @@ cat <<EOF
   JSON output....: ${with_json-no}
   Oldies support.: $enable_oldies
   seccomp........: ${with_seccomp-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 ---------------
+$($LD --version || true)
 ---------------------------------------------
 
 Check the above options and compile with: