From d7d9df20b1e04f9de3718906d5a84f5fdd2b6548 Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Thu, 25 Nov 2021 14:54:31 +0100 Subject: configure.ac: introduce --enable-werror and --enable-sanitize ... just like in other osmocom projects --- configure.ac | 31 +++++++++++++++++++++++++++++++ git-version-gen | 4 ++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index 964ef03..eb5a3ad 100644 --- a/configure.ac +++ b/configure.ac @@ -40,6 +40,37 @@ AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])], CFLAGS="$saved_CFLAGS" AC_SUBST(SYMBOL_VISIBILITY) +AC_ARG_ENABLE(sanitize, + [AS_HELP_STRING( + [--enable-sanitize], + [Compile with address sanitizer enabled], + )], + [sanitize=$enableval], [sanitize="no"]) +if test x"$sanitize" = x"yes" +then + CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined" + CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined" +fi + +AC_ARG_ENABLE(werror, + [AS_HELP_STRING( + [--enable-werror], + [Turn all compiler warnings into errors, with exceptions: + a) deprecation (allow upstream to mark deprecation without breaking builds); + b) "#warning" pragmas (allow to remind ourselves of errors without breaking builds) + ] + )], + [werror=$enableval], [werror="no"]) +if test x"$werror" = x"yes" +then + WERROR_FLAGS="-Werror" + WERROR_FLAGS+=" -Wno-error=deprecated -Wno-error=deprecated-declarations" + WERROR_FLAGS+=" -Wno-error=cpp" # "#warning" + CFLAGS="$CFLAGS $WERROR_FLAGS" + CPPFLAGS="$CPPFLAGS $WERROR_FLAGS" +fi + + dnl Generate the output AC_CONFIG_HEADER(config.h) diff --git a/git-version-gen b/git-version-gen index 42cf3d2..2a9abb5 100755 --- a/git-version-gen +++ b/git-version-gen @@ -93,8 +93,8 @@ if test -n "$v" then : # use $v elif - v=`git describe --abbrev=4 --match='v*' HEAD 2>/dev/null \ - || git describe --abbrev=4 HEAD 2>/dev/null` \ + v=`git describe --abbrev=4 HEAD 2>/dev/null \ + || git describe --abbrev=4 --match='v*' HEAD 2>/dev/null` \ && case $v in [0-9]*) ;; v[0-9]*) ;; -- cgit v1.2.3