diff options
author | Harald Welte <laforge@osmocom.org> | 2021-11-25 14:54:31 +0100 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2021-11-25 14:54:31 +0100 |
commit | d7d9df20b1e04f9de3718906d5a84f5fdd2b6548 (patch) | |
tree | ff69a503797510597ac005dfb6f01c5dd6d884b0 | |
parent | 551b9752bcd5d3d21bb2df0736b1801bda3d0d10 (diff) |
configure.ac: introduce --enable-werror and --enable-sanitize
... just like in other osmocom projects
-rw-r--r-- | configure.ac | 31 | ||||
-rwxr-xr-x | 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]*) ;; |