Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libntech
Submodule libntech updated 1 files
+10 −1 m4/cf3_gcc_flags.m4
19 changes: 17 additions & 2 deletions m4/cf3_gcc_flags.m4
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2021 Northern.tech AS
# Copyright 2026 Northern.tech AS
#
# This file is part of CFEngine 3 - written and maintained by Northern.tech AS.
#
Expand Down Expand Up @@ -48,33 +48,46 @@ if test x"$GCC" = "xyes" && test x"$HP_UX_AC" != x"yes"; then
CF3_CFLAGS="$CF3_CFLAGS -std=gnu99 -g -Wall"
AC_MSG_RESULT(yes)

dnl Save CFLAGS to restore after using it to test for compiler flag support
save_CFLAGS="$CFLAGS"
AC_MSG_CHECKING(for -Wno-pointer-sign)
CFLAGS="-Wno-pointer-sign"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main() {}])],
[AC_MSG_RESULT(yes)
CF3_CFLAGS="$CF3_CFLAGS -Wno-pointer-sign"],
[AC_MSG_RESULT(no)])

AC_MSG_CHECKING(for -Werror=implicit-function-declaration)
CFLAGS="-Werror=implicit-function-declaration"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main() {}])],
[AC_MSG_RESULT(yes)
CF3_CFLAGS="$CF3_CFLAGS -Werror=implicit-function-declaration"],
[AC_MSG_RESULT(no)])

AC_MSG_CHECKING(for -Wunused-parameter)
CFLAGS="-Wunused-parameter"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main() {}])],
[AC_MSG_RESULT(yes)
CF3_CFLAGS="$CF3_CFLAGS -Wunused-parameter"],
[AC_MSG_RESULT(no)])

AC_MSG_CHECKING(for -Wno-incompatible-pointer-types)
CFLAGS="-Wno-incompatible-pointer-types"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([int main() {}])],
[AC_MSG_RESULT(yes)
CF3_CFLAGS="$CF3_CFLAGS -Wno-incompatible-pointer-types"],
[AC_MSG_RESULT(no)])

dnl Clang does not like 'const const' construct arising from
dnl expansion of TYPED_SET_DECLARE macro
dnl
dnl This check is relying on explicit compilator detection due to
dnl GCC irregularities checking for -Wno-* command-line options
dnl (command line is not fully checked until actual warning occurs)
AC_MSG_CHECKING(for -Wno-duplicate-decl-specifier)
CFLAGS="-Wno-duplicate-decl-specifier"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([#ifndef __clang__
# GET_DIR_ERROR Not a clang
# error Not a clang
#endif
int main() {}])],
[AC_MSG_RESULT(yes)
Expand All @@ -85,3 +98,5 @@ else
fi

AC_SUBST([CF3_CFLAGS])
dnl restore CFLAGS
CFLAGS="$save_CFLAGS"
Loading