From f4602f7b4e7fdcf4b3a5d2c0c353b50fef98aa7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20G=C3=B6ttsche?= Date: Tue, 8 Sep 2020 14:25:46 +0200 Subject: Add some default compiler warnings Compatible with gcc and clang. --- configure.ac | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'configure.ac') diff --git a/configure.ac b/configure.ac index 12676fa3..f22490f5 100644 --- a/configure.ac +++ b/configure.ac @@ -85,26 +85,13 @@ AC_CHECK_FUNCS([memmove strncasecmp strstr strdup]) save_cflags="${CFLAGS}" CFLAGS="${CFLAGS} -std=c99" -AC_MSG_CHECKING([whether gcc -std=c99 option works]) +AC_MSG_CHECKING([whether cc -std=c99 option works]) AC_COMPILE_IFELSE([AC_LANG_PROGRAM( [AC_INCLUDES_DEFAULT], [[char *a; a = strdup("foo"); int i = 0; i++; // C99]])], [AC_MSG_RESULT([yes])], - [AC_MSG_ERROR([htop is written in C99. A newer version of gcc is required.])]) + [AC_MSG_ERROR([htop is written in C99. A newer compiler is required.])]) CFLAGS="$save_cflags" -save_cflags="${CFLAGS}" -CFLAGS="$CFLAGS -Wextra" -AC_MSG_CHECKING([if compiler supports -Wextra]) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],[ - wextra_flag=-Wextra - AC_MSG_RESULT([yes]) -],[ - wextra_flag= - AC_MSG_RESULT([no]) -]) -CFLAGS="$save_cflags" -AC_SUBST(wextra_flag) - # Checks for features and flags. # ---------------------------------------------------------------------- PROCDIR=/proc @@ -279,6 +266,19 @@ then ]) fi +AM_CFLAGS="\ + -Wall\ + -Wcast-align\ + -Wextra\ + -Wmissing-format-attribute\ + -Wmissing-noreturn\ + -Wpointer-arith\ + -Wshadow\ + -Wstrict-prototypes\ + -Wundef\ + -Wunused\ + -Wwrite-strings" + AC_ARG_ENABLE([werror], [AS_HELP_STRING([--enable-werror], [Treat warnings as errors (default: warnings are not errors)])], [enable_werror="$enableval"], [enable_werror=no]) AS_IF([test "x$enable_werror" = "xyes"], [AM_CFLAGS="$AM_CFLAGS -Werror"]) AC_SUBST([AM_CFLAGS]) -- cgit v1.2.3