mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
configure.ac: add m4 macros that can check for compiler option support
We now use this to set certain options, if supported by the compilers (C/C++). Currently we enable various options, like -Wno-format-truncation. We use this to ignore complaints about possibly truncations due to the use of the snprintf() family of functions - where forced truncation is the whole point.
This commit is contained in:
parent
4b3901f63b
commit
3021e01559
2 changed files with 54 additions and 2 deletions
|
@ -77,8 +77,6 @@ case "${host_os}" in
|
|||
OSMINORVERSION=15
|
||||
SOURCE_CPP_DEFINES="${SOURCE_CPP_DEFINES} -D_POSIX_SOURCE \
|
||||
-D_DEFAULT_SOURCE -D_BSD_SOURCE -D_SVID_SOURCE"
|
||||
CPP_COMPILER_FLAGS="-fno-strict-aliasing -Wno-write-strings \
|
||||
-Wno-unused-result"
|
||||
;;
|
||||
freebsd*)
|
||||
build_freebsd=yes
|
||||
|
@ -306,6 +304,20 @@ AC_PROG_CC_C99
|
|||
AC_PATH_X
|
||||
AC_PATH_XTRA
|
||||
|
||||
dnl check some compiler flags
|
||||
C_FLAG_CHECK([-Wno-format-truncation])
|
||||
CXX_FLAG_CHECK([-Wno-format-truncation])
|
||||
|
||||
C_FLAG_CHECK([-fno-strict-aliasing])
|
||||
CXX_FLAG_CHECK([-fno-strict-aliasing])
|
||||
|
||||
C_FLAG_CHECK([-Wno-write-strings])
|
||||
CXX_FLAG_CHECK([-Wno-write-strings])
|
||||
|
||||
C_FLAG_CHECK([-Wno-unused-result])
|
||||
CXX_FLAG_CHECK([-Wno-unused-result])
|
||||
|
||||
|
||||
dnl Add X11 goodies here
|
||||
EXTRA_LIBS="${X_LIBS} ${EXTRA_LIBS}"
|
||||
EXTRA_INCS="${X_CFLAGS} ${EXTRA_INCS}"
|
||||
|
|
40
cde/m4/compiler_flag_chk.m4
Normal file
40
cde/m4/compiler_flag_chk.m4
Normal file
|
@ -0,0 +1,40 @@
|
|||
dnl From stackoverflow, with some changes
|
||||
dnl @synopsis CXX_FLAGS_CHECK [compiler flags]
|
||||
dnl @summary check whether compiler supports given C++ flags or not
|
||||
AC_DEFUN([CXX_FLAG_CHECK],
|
||||
[dnl
|
||||
AC_MSG_CHECKING([if $CXX supports $1])
|
||||
AC_LANG_PUSH([C++])
|
||||
ac_saved_cxxflags="$CXX_COMPILER_FLAGS"
|
||||
CXX_COMPILER_FLAGS="-Werror $1"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
|
||||
[cxx_flag_check=yes],
|
||||
[cxx_flag_check=no]
|
||||
)
|
||||
AC_MSG_RESULT([$cxx_flag_check])
|
||||
CXX_COMPILER_FLAGS="$ac_saved_cxxflags"
|
||||
if test "$cxx_flag_check" = yes
|
||||
then
|
||||
CXX_COMPILER_FLAGS="$CXX_COMPILER_FLAGS $1"
|
||||
fi
|
||||
AC_LANG_POP([C++])
|
||||
])
|
||||
|
||||
AC_DEFUN([C_FLAG_CHECK],
|
||||
[dnl
|
||||
AC_MSG_CHECKING([if $CC supports $1])
|
||||
AC_LANG_PUSH([C])
|
||||
ac_saved_ccflags="$C_COMPILER_FLAGS"
|
||||
C_COMPILER_FLAGS="-Werror $1"
|
||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
|
||||
[cc_flag_check=yes],
|
||||
[cc_flag_check=no]
|
||||
)
|
||||
AC_MSG_RESULT([$cc_flag_check])
|
||||
C_COMPILER_FLAGS="$ac_saved_ccflags"
|
||||
if test "$cc_flag_check" = yes
|
||||
then
|
||||
C_COMPILER_FLAGS="$C_COMPILER_FLAGS $1"
|
||||
fi
|
||||
AC_LANG_POP([C])
|
||||
])
|
Loading…
Add table
Add a link
Reference in a new issue