]> git.ipfire.org Git - location/libloc.git/commitdiff
configure: Enable more compiler warnings
authorMichael Tremer <michael.tremer@ipfire.org>
Thu, 6 Mar 2025 17:45:38 +0000 (17:45 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Thu, 6 Mar 2025 17:45:38 +0000 (17:45 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
configure.ac

index 8084f89a339245715fb1727e78d8055119f63917..e5b4fc587f996e49f6dcc5aa0fb7271d84182fdb 100644 (file)
@@ -21,11 +21,13 @@ AM_CPPFLAGS = \
        -DSYSCONFDIR=\""$(sysconfdir)"\" \
        -I${top_srcdir}/src
 
-AM_CFLAGS = ${my_CFLAGS} \
+AM_CFLAGS = \
+       $(OUR_CFLAGS) \
        -ffunction-sections \
        -fdata-sections
 
-AM_LDFLAGS = ${my_LDFLAGS}
+AM_LDFLAGS = \
+       $(OUR_LDFLAGS)
 
 # leaving a space here to work around automake's conditionals
  ifeq ($(OS),Darwin)
@@ -218,7 +220,10 @@ src_python__location_la_SOURCES = \
 
 src_python__location_la_CFLAGS = \
        $(AM_CFLAGS) \
-       $(PYTHON_CFLAGS)
+       $(PYTHON_CFLAGS) \
+       -Wno-cast-function-type \
+       -Wno-redundant-decls \
+       -Wno-strict-aliasing
 
 src_python__location_la_LDFLAGS = \
        $(AM_LDFLAGS) \
index 550b942680a4afa3e89783ccd17c9463126ddcf3..cb49bb82eec599bcc4a188fff00c733328ad7df5 100644 (file)
@@ -125,33 +125,65 @@ AC_CHECK_FUNCS([ \
     qsort \
 ])
 
-my_CFLAGS="\
--Wall \
--Wchar-subscripts \
--Wformat-security \
--Wmissing-declarations \
--Wmissing-prototypes \
--Wnested-externs \
--Wpointer-arith \
--Wshadow \
--Wsign-compare \
--Wstrict-prototypes \
--Wtype-limits \
-"
-AC_SUBST([my_CFLAGS])
-AC_SUBST([my_LDFLAGS])
+CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
+       -std=gnu17 \
+       -Wall \
+       -Wextra \
+       -Warray-bounds=2 \
+       -Wdate-time \
+       -Wendif-labels \
+       -Werror=format=2 \
+       -Werror=format-signedness \
+       -Werror=implicit-function-declaration \
+       -Werror=implicit-int \
+       -Werror=incompatible-pointer-types \
+       -Werror=int-conversion \
+       -Werror=missing-declarations \
+       -Werror=missing-prototypes \
+       -Werror=overflow \
+       -Werror=override-init \
+       -Werror=return-type \
+       -Werror=shift-count-overflow \
+       -Werror=shift-overflow=2 \
+       -Werror=strict-flex-arrays \
+       -Werror=undef \
+       -Wfloat-equal \
+       -Wimplicit-fallthrough=5 \
+       -Winit-self \
+       -Wlogical-op \
+       -Wmissing-include-dirs \
+       -Wmissing-noreturn \
+       -Wnested-externs \
+       -Wold-style-definition \
+       -Wpointer-arith \
+       -Wredundant-decls \
+       -Wshadow \
+       -Wstrict-aliasing=2 \
+       -Wstrict-prototypes \
+       -Wsuggest-attribute=noreturn \
+       -Wunused-function \
+       -Wwrite-strings \
+       -Wzero-length-bounds \
+       -Wno-unused-parameter \
+       -Wno-missing-field-initializers \
+       -fdiagnostics-show-option \
+       -fno-common \
+])
+
+# Enable -fno-semantic-interposition (if available)
+CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [-fno-semantic-interposition])
+CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [-fno-semantic-interposition])
 
 # Enable -fanalyzer if requested
 AC_ARG_ENABLE([analyzer],
        AS_HELP_STRING([--enable-analyzer], [enable static analyzer (-fanalyzer) @<:@default=disabled@:>@]),
        [], [enable_analyzer=no])
 AS_IF([test "x$enable_analyzer" = "xyes"],
-       CC_CHECK_FLAGS_APPEND([my_CFLAGS], [CFLAGS], [-fanalyzer])
+       CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [-fanalyzer])
 )
 
-# Enable -fno-semantic-interposition (if available)
-CC_CHECK_FLAGS_APPEND([my_CFLAGS], [CFLAGS], [-fno-semantic-interposition])
-CC_CHECK_FLAGS_APPEND([my_LDFLAGS], [LDFLAGS], [-fno-semantic-interposition])
+AC_SUBST([OUR_CFLAGS], $with_cflags)
+AC_SUBST([OUR_LDFLAGS], $with_ldflags)
 
 # ------------------------------------------------------------------------------