From 86e3c78776a4e6de08145eddf1496615ae5726d3 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 12 Oct 2011 19:04:57 -0400 Subject: [PATCH] configure: Test for compiler flags, and remove old config checks --- configure.ac | 36 ++++++++++++++++++++++++++++-------- include/verilated.mk.in | 9 ++++----- src/config_build.h.in | 27 --------------------------- test_verilated/Makefile_obj | 4 ---- 4 files changed, 32 insertions(+), 44 deletions(-) diff --git a/configure.ac b/configure.ac index 8d0bc3cde..bf145eb8e 100644 --- a/configure.ac +++ b/configure.ac @@ -94,21 +94,41 @@ fi # Checks for libraries. -# Checks for header files. -AC_HEADER_STDC -AC_HEADER_SYS_WAIT -AC_CHECK_HEADERS(fcntl.h unistd.h inttypes.h sys/file.h sys/time.h sys/un.h math.h stdint.h mingw/stdint.h) - # Checks for typedefs, structures AC_CHECK_TYPE(size_t,unsigned int) -AC_CHECK_TYPE(uint_t,unsigned int) -AC_CHECK_TYPE(ulong_t,unsigned long) AC_TYPE_SIZE_T -AC_STRUCT_TM # Checks for compiler characteristics. AC_C_INLINE +AC_DEFUN([_MY_CXX_CHECK_OPT], + [# _MY_CXX_CHECK_OPT(flag) -- Check if compiler supports specific options + ACO_SAVE_CXXFLAGS="$CXXFLAGS" + # -Werror needed otherwise unknown -Wno-div-by-zero won't report problems + CXXFLAGS="$CXXFLAGS $1 -Werror" + AC_MSG_CHECKING([whether $CXX accepts $1]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([],[])], + [_my_result=yes], + [_my_result=no]) + AC_MSG_RESULT($_my_result) + if test "$_my_result" = "yes" ; then + CFG_CXXFLAGS_NO_UNUSED="$CFG_CXXFLAGS_NO_UNUSED $1" + fi + CXXFLAGS="$ACO_SAVE_CXXFLAGS" + ])# _MY_CXX_CHECK_OPT + +# For example, -Wno-div-by-zero isn't in 4.1.2 +_MY_CXX_CHECK_OPT(-Wno-char-subscripts) +# Random code often does / 0. Unfortunately VL_DIV_I(0,0) will warn +# without this flag, even though there's a conditional to prevent the divide. +_MY_CXX_CHECK_OPT(-Wno-div-by-zero) +_MY_CXX_CHECK_OPT(-Wno-sign-compare) +_MY_CXX_CHECK_OPT(-Wno-uninitialized) +_MY_CXX_CHECK_OPT(-Wno-unused-parameter) +_MY_CXX_CHECK_OPT(-Wno-unused-variable) +AC_SUBST(CFG_CXXFLAGS_NO_UNUSED) + # Checks for library functions. # Checks for system services diff --git a/include/verilated.mk.in b/include/verilated.mk.in index bcdface87..4058d7908 100644 --- a/include/verilated.mk.in +++ b/include/verilated.mk.in @@ -16,6 +16,9 @@ RANLIB = ranlib CFG_WITH_CCWARN = @CFG_WITH_CCWARN@ CFG_WITH_LONGTESTS = @CFG_WITH_LONGTESTS@ +# Compiler flags to use to turn off unused and generated code warnings, such as -Wno-div-by-zero +CFG_CXXFLAGS_NO_UNUSED = @CFG_CXXFLAGS_NO_UNUSED@ + ###################################################################### # Programs @@ -43,11 +46,7 @@ VK_CPPFLAGS_ALWAYS += \ ifeq ($(CFG_WITH_CCWARN),yes) # Local... Else don't burden users VK_CPPFLAGS_WALL += -Wall \ - -Wno-char-subscripts \ - -Wno-sign-compare \ - -Wno-unused-parameter \ - -Wno-unused-variable \ - -Wno-uninitialized \ + $(CFG_CXXFLAGS_NO_UNUSED) \ -Werror endif diff --git a/src/config_build.h.in b/src/config_build.h.in index 0226da86f..f3119d59d 100644 --- a/src/config_build.h.in +++ b/src/config_build.h.in @@ -33,36 +33,9 @@ //********************************************************************** //**** Functions -// Set define if we have function: strdup (string) -#define HAVE_STRDUP 0 - //********************************************************************** //**** Headers -// Set define if we have header: -#define HAVE_FCNTL_H 0 - -// Set define if we have header: -#define HAVE_MATH_H 1 - -// Set define if we have header: -#define HAVE_UNISTD_H 0 - -// Set define if we have header: -#define HAVE_SYS_TIME_H 0 - -// Set define if we have header: -#define HAVE_SYS_UN_H 0 - -// Set define if we have header: -#define HAVE_STDINT_H 0 - -// Set define if we have header: -#define HAVE_MINGW_STDINT_H 0 - -// Set define if we have header: -#define HAVE_INTTYPES_H 0 - //********************************************************************** //**** Default environment diff --git a/test_verilated/Makefile_obj b/test_verilated/Makefile_obj index 9346793cf..b9a400ef1 100644 --- a/test_verilated/Makefile_obj +++ b/test_verilated/Makefile_obj @@ -22,10 +22,6 @@ include Vvgen.mk CPPFLAGS += -DVL_DEBUG=1 CPPFLAGS += $(CPPFLAGS_ADD) -# Random code often does / 0. Unfortunately VL_DIV_I(0,0) will warn -# without this flag, even though there's a conditional to prevent the divide. -CPPFLAGS += -Wno-div-by-zero - ####################################################################### # Linking final exe -- presumes have a sim_main.cpp