summaryrefslogtreecommitdiffstats
path: root/configure.ac
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2023-02-24 08:52:32 (EST)
committer P. J. McDermott <pj@pehjota.net>2023-02-24 08:52:32 (EST)
commit0b360f0c7de63ddb9bb20d2fead9e077d9fef735 (patch)
treea9c4e232ec16948407df94b94d8bac968de92330 /configure.ac
parent50e8259639936c867c486917aba8d9f748a35d2c (diff)
downloadoverworld-rpg-0b360f0c7de63ddb9bb20d2fead9e077d9fef735.zip
overworld-rpg-0b360f0c7de63ddb9bb20d2fead9e077d9fef735.tar.gz
overworld-rpg-0b360f0c7de63ddb9bb20d2fead9e077d9fef735.tar.bz2
build: Use ASAN and GCC warnings from Gnulib
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac79
1 files changed, 62 insertions, 17 deletions
diff --git a/configure.ac b/configure.ac
index 8767989..15f9e57 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,6 +19,7 @@ dnl Process this file with autoconf to produce a configure script.
AC_INIT([boukengine], [0.1.0], [mailto:pj@pehjota.net], [boukengine],
[http://www.pehjota.net/projects/overworld-rpg/])
AC_CONFIG_AUX_DIR([build-aux])
+AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([src/main.c])
AM_INIT_AUTOMAKE([gnu dist-bzip2 dist-xz subdir-objects])
@@ -83,23 +84,6 @@ fi
AM_CONDITIONAL([EMBEDDED_XCF2PNG], [${embedded_xcf2png}])
AC_SUBST([XCF2PNG])
-if test "x$GCC" = "xyes"; then
- GCC_CFLAGS="-pedantic -Wall -Wextra -Werror"
- GCC_CFLAGS="${GCC_CFLAGS} -Wformat=2 -Wswitch -Wswitch-enum"
- GCC_CFLAGS="${GCC_CFLAGS} -Wdeclaration-after-statement -Wundef -Wshadow"
- GCC_CFLAGS="${GCC_CFLAGS} -Wpointer-arith -Wbad-function-cast"
- GCC_CFLAGS="${GCC_CFLAGS} -Wcast-qual -Wcast-align -Wwrite-strings"
- #GCC_CFLAGS="${GCC_CFLAGS} -Wconversion"
- GCC_CFLAGS="${GCC_CFLAGS} -Wlogical-op -Waggregate-return"
- GCC_CFLAGS="${GCC_CFLAGS} -Wstrict-prototypes -Wold-style-definition"
- GCC_CFLAGS="${GCC_CFLAGS} -Wmissing-prototypes -Wmissing-declarations"
- GCC_CFLAGS="${GCC_CFLAGS} -Wredundant-decls -Wnested-externs"
- GCC_CFLAGS="${GCC_CFLAGS} -Wunreachable-code -Winline"
- GCC_CFLAGS="${GCC_CFLAGS} -Wdisabled-optimization"
- GCC_CFLAGS="${GCC_CFLAGS} -fstack-protector -Wstack-protector"
-fi
-AC_SUBST(GCC_CFLAGS)
-
AC_ARG_ENABLE([debug-tmx],
[AC_HELP_STRING([--enable-debug-tmx],
[enable debug output from TMX parser])],
@@ -142,6 +126,67 @@ if test "x$enable_debug_palettes" = "xyes"; then
listings.])
fi
+AX_CFLAGS_WARN_ALL() dnl Adds -Wall or equivalent
+AX_CHECK_COMPILE_FLAG([-Wpedantic], [AX_APPEND_FLAG([-Wpedantic])])
+AX_CHECK_COMPILE_FLAG([-Wextra], [AX_APPEND_FLAG([-Wextra])])
+
+AC_ARG_ENABLE([gcc-warnings],
+ [AS_HELP_STRING([--enable-gcc-warnings], [turn on many GCC warnings])],
+ [case "${enableval}" in yes|no) gcc_warnings=${enableval};;
+ *) AC_MSG_ERROR(
+ [bad value ${enableval} for gcc-warnings option]);;
+ esac],
+ [
+ gcc_warnings=no
+ test -d "${srcdir}/.git" && gcc_warnings=yes
+ ]
+)
+if test "x${gcc_warnings}" = 'xyes'; then
+ nowarns=''
+ nowarns="${nowarns} -Wsystem-headers"
+ gl_MANYWARN_ALL_GCC([warns])
+ gl_MANYWARN_COMPLEMENT([warns], [${warns}], [${nowarns}])
+ for warn in ${warns}; do
+ gl_WARN_ADD([${warn}])
+ done
+ AC_SUBST([WARN_CFLAGS])
+fi
+
+AX_CHECK_COMPILE_FLAG([-fdiagnostics-color=auto],
+ [AX_APPEND_FLAG([-fdiagnostics-color=auto])])
+
+AC_ARG_ENABLE([address-sanitization],
+ [AS_HELP_STRING([--enable-address-sanitization],
+ [turn on AddressSanitizer (if available)])],
+ [case "${enableval}" in yes|no) address_sanitization=${enableval};;
+ *) AC_MSG_ERROR(
+ [bad value ${enableval} for address-sanitization option]
+ );;
+ esac],
+ [
+ address_sanitization=no
+ gl_GCC_VERSION_IFELSE([4], [8],
+ [test -d "${srcdir}/.git" && address_sanitization=yes])
+ ]
+)
+if test "x${address_sanitization}" = 'xyes'; then
+ AX_CHECK_COMPILE_FLAG([-fsanitize=address],
+ [AX_APPEND_FLAG([-fsanitize=address], [ASAN_CFLAGS])])
+ AX_CHECK_COMPILE_FLAG([-fno-omit-frame-pointer],
+ [AX_APPEND_FLAG([-fno-omit-frame-pointer], [ASAN_CFLAGS])])
+ AC_SUBST([ASAN_CFLAGS])
+fi
+
+if ! test -d "${srcdir}/.git"; then
+ AX_CHECK_COMPILE_FLAG([-s], [AX_APPEND_FLAG([-s])])
+fi
+for flag in -Os -fno-unwind-tables -fno-asynchronous-unwind-tables \
+ -ffunction-sections -fdata-sections -Wl,--gc-sections \
+ -fstack-protector-strong -flto \
+ -Wl,-z,now -Wl,--hash-style=sysv -Wl,--build-id=none; do
+ AX_CHECK_COMPILE_FLAG([${flag}], [AX_APPEND_FLAG([${flag}])])
+done
+
AC_CONFIG_FILES([Makefile])
AC_CONFIG_HEADERS([config.h])
AC_OUTPUT()