endif()
endif()
+#
+# Extra compiler options for the build matrix scripts to request -Werror or
+# its equivalent if required. The CMake variable name cannot be CFLAGS
+# because that is already used for a different purpose in CMake. Example
+# usage: cmake -DEXTRA_CFLAGS='-Wall -Wextra -Werror' ...
+#
+if(NOT "${EXTRA_CFLAGS}" STREQUAL "")
+ string(REPLACE " " ";" _extra_cflags_list ${EXTRA_CFLAGS})
+ add_compile_options(${_extra_cflags_list})
+ message(STATUS "Added extra compile options (${EXTRA_CFLAGS})")
+endif()
+
######################################
# Input files
######################################
export TCPDUMP_BIN
print_cc_version
+
+# The norm is to compile without any warnings, but tcpdump builds on some OSes
+# are not warning-free for one or another reason. If you manage to fix one of
+# these cases, please remember to remove respective exemption below to help any
+# later warnings in the same matrix subset trigger an error.
+# shellcheck disable=SC2006
+case `os_id`/"$CMAKE" in
+FreeBSD-*/yes)
+ # tcpdump.c:2290:3: error: implicit declaration of function 'bpf_dump'
+ # [-Werror=implicit-function-declaration]
+ [ "$BUILD_LIBPCAP" = yes ] && TCPDUMP_TAINTED=yes
+ case `cc_id` in
+ clang-*)
+ # tcpdump.c:2434:32: error: '_Generic' is a C11 extension
+ # [-Werror,-Wc11-extensions]
+ # tcpdump.c:2439:26: error: '_Generic' is a C11 extension
+ # [-Werror,-Wc11-extensions]
+ # tcpdump.c:2443:9: error: '_Generic' is a C11 extension
+ # [-Werror,-Wc11-extensions]
+ # tcpdump.c:244:16: error: no previous extern declaration for non-static variable
+ # 'capdns' [-Werror,-Wmissing-variable-declarations]
+ TCPDUMP_TAINTED=yes
+ ;;
+ esac
+ ;;
+esac
+# shellcheck disable=SC2006
+[ "$TCPDUMP_TAINTED" != yes ] && CFLAGS=`cc_werr_cflags`
+
if [ "$CMAKE" = no ]; then
if [ "$BUILD_LIBPCAP" = yes ]; then
echo "Using PKG_CONFIG_PATH=$PKG_CONFIG_PATH"
run_after_echo cd build
if [ "$BUILD_LIBPCAP" = yes ]; then
run_after_echo cmake -DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" \
+ ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
-DCMAKE_INSTALL_PREFIX="$PREFIX" -DCMAKE_PREFIX_PATH="$PREFIX" ..
LD_LIBRARY_PATH="$PREFIX/lib"
export LD_LIBRARY_PATH
else
run_after_echo cmake -DWITH_CRYPTO="$CRYPTO" -DENABLE_SMB="$SMB" \
+ ${CFLAGS:+-DEXTRA_CFLAGS="$CFLAGS"} \
-DCMAKE_INSTALL_PREFIX="$PREFIX" ..
fi
fi
run_after_echo make -s clean
-# The norm is to compile without any warnings, but tcpdump builds on some OSes
-# are not warning-free for one or another reason. If you manage to fix one of
-# these cases, please remember to raise the bar here so if the warnings appear
-# again, it will trigger an error.
-# shellcheck disable=SC2006
-[ "$TCPDUMP_TAINTED" != yes ] && CFLAGS=`cc_werr_cflags`
-run_after_echo make -s ${CFLAGS:+CFLAGS="$CFLAGS"}
+if [ "$CMAKE" = no ]; then
+ run_after_echo make -s ${CFLAGS:+CFLAGS="$CFLAGS"}
+else
+ # The "-s" flag is a no-op and CFLAGS is set using -DEXTRA_CFLAGS above.
+ run_after_echo make
+fi
run_after_echo make install
print_so_deps "$TCPDUMP_BIN"
run_after_echo "$TCPDUMP_BIN" -h