Build: Make compiler warnings configurable
Use the SR_ARG_ENABLE_WARNINGS macro to configure and check for the availability of compiler warning flags. Maintain separate sets of warning flags for C and C++. The configure option --enable-warnings=[min|max|fatal|no] can be used to set the compiler warning level for all languages. The default level is "max".
This commit is contained in:
parent
24138539c1
commit
4cf2f34f43
|
@ -22,15 +22,15 @@ ACLOCAL_AMFLAGS = -I m4
|
|||
|
||||
local_includes = -Iinclude -I$(srcdir)/include -I$(srcdir)/src -I.
|
||||
if BINDINGS_CXX
|
||||
local_includes += -Ibindings/cxx/include -I${srcdir}/bindings/cxx/include -Ibindings/cxx
|
||||
local_includes += -Ibindings/cxx/include -I$(srcdir)/bindings/cxx/include -Ibindings/cxx
|
||||
endif
|
||||
# Ensure that local include directories are always searched first.
|
||||
AM_CPPFLAGS = $(local_includes) -DFIRMWARE_DIR='"$(FIRMWARE_DIR)"'
|
||||
|
||||
# The check CFLAGS are a superset of the libsigrok CFLAGS, and the
|
||||
# python bindings CFLAGS are a superset of the C++ bindings CFLAGS.
|
||||
AM_CFLAGS = $(CHECK_CFLAGS)
|
||||
AM_CXXFLAGS = $(PYSIGROK_CFLAGS)
|
||||
AM_CFLAGS = $(SR_WFLAGS) $(CHECK_CFLAGS)
|
||||
AM_CXXFLAGS = $(SR_WXXFLAGS) $(PYSIGROK_CFLAGS)
|
||||
|
||||
lib_LTLIBRARIES = libsigrok.la
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@ AH_BOTTOM([#endif /* SR_CONFIG_H */])
|
|||
# Enable more compiler warnings via -Wall and -Wextra. Add -fvisibility=hidden
|
||||
# and enforce use of SR_API to explicitly mark all public API functions.
|
||||
CFLAGS="$CFLAGS -std=c11"
|
||||
CFLAGS="$CFLAGS -Wall -Wextra -Wmissing-prototypes"
|
||||
CFLAGS="$CFLAGS -fvisibility=hidden"
|
||||
CFLAGS="$CFLAGS -D_POSIX_C_SOURCE=200112L"
|
||||
|
||||
|
@ -150,6 +149,7 @@ SR_PKG_CHECK([check], [SR_PKGLIBS_CHECK], [check >= 0.9.4])
|
|||
AM_CONDITIONAL([HAVE_CHECK], [test "x$sr_have_check" = xyes])
|
||||
|
||||
AC_LANG([C])
|
||||
SR_ARG_ENABLE_WARNINGS([SR_WFLAGS], [-Wall], [-Wall -Wextra -Wmissing-prototypes])
|
||||
|
||||
# Check host characteristics.
|
||||
AC_C_BIGENDIAN
|
||||
|
@ -264,6 +264,7 @@ SR_DRIVER([ZEROPLUS Logic Cube], [zeroplus-logic-cube], [libusb])
|
|||
###############################
|
||||
|
||||
AC_LANG([C++])
|
||||
SR_ARG_ENABLE_WARNINGS([SR_WXXFLAGS], [-Wall], [-Wall -Wextra])
|
||||
|
||||
AC_ARG_ENABLE([bindings],
|
||||
[AS_HELP_STRING([--enable-bindings], [build language bindings [default=yes]])],
|
||||
|
@ -466,6 +467,8 @@ libsigrok configuration summary:
|
|||
- Prefix.......................... $prefix
|
||||
- Building on..................... $build
|
||||
- Building for.................... $host
|
||||
- C compiler warnings............. $SR_WFLAGS
|
||||
- C++ compiler warnings........... $SR_WXXFLAGS
|
||||
|
||||
Detected libraries (required):
|
||||
- glib-2.0 >= 2.32.0.............. $sr_glib_version
|
||||
|
|
10
m4/sigrok.m4
10
m4/sigrok.m4
|
@ -16,7 +16,7 @@
|
|||
## You should have received a copy of the GNU General Public License
|
||||
## along with sigrok. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#serial 20150821
|
||||
#serial 20150823
|
||||
|
||||
## SR_APPEND(var-name, [list-sep,] element)
|
||||
##
|
||||
|
@ -125,9 +125,9 @@ m4_define([_SR_ARG_ENABLE_WARNINGS_ONCE],
|
|||
AC_PROVIDE([$0])[]dnl
|
||||
AC_ARG_ENABLE([warnings],
|
||||
[AS_HELP_STRING([[--enable-warnings[=min|max|fatal|no]]],
|
||||
[set compile pedantry level [default=min]])],
|
||||
[set compile pedantry level [default=max]])],
|
||||
[sr_enable_warnings=$enableval],
|
||||
[sr_enable_warnings=min])[]dnl
|
||||
[sr_enable_warnings=max])[]dnl
|
||||
dnl
|
||||
# Test whether the compiler accepts each flag. Look at standard output,
|
||||
# since GCC only shows a warning message if an option is not supported.
|
||||
|
@ -173,9 +173,9 @@ int main(int argc, char** argv) { return (argv != 0) ? argc : 0; }
|
|||
]])])
|
||||
AS_CASE([$sr_enable_warnings],
|
||||
[no], [],
|
||||
[max], [sr_check_compile_warning_flags $3],
|
||||
[min], [sr_check_compile_warning_flags $2],
|
||||
[fatal], [sr_check_compile_warning_flags $3 -Werror],
|
||||
[sr_check_compile_warning_flags $2])
|
||||
[sr_check_compile_warning_flags $3])
|
||||
rm -f "$sr_conftest"
|
||||
AC_SUBST([$1], [$sr_warning_flags])
|
||||
AC_MSG_RESULT([[$]{sr_warning_flags:-none}])[]dnl
|
||||
|
|
Loading…
Reference in New Issue