diff options
-rw-r--r-- | configure.ac | 31 | ||||
-rw-r--r-- | m4/ax_check_compile_flag.m4 | 53 | ||||
-rw-r--r-- | src/Makefile.am | 5 | ||||
-rw-r--r-- | test/Makefile.am | 4 | ||||
-rw-r--r-- | tools/Makefile.am | 10 |
5 files changed, 91 insertions, 12 deletions
diff --git a/configure.ac b/configure.ac index 1245a7d..6e44fa9 100644 --- a/configure.ac +++ b/configure.ac @@ -38,10 +38,41 @@ AC_USE_SYSTEM_EXTENSIONS AC_PROG_CC_STDC +m4_include([m4/ax_check_compile_flag.m4]) + # Initialize libtool AC_DISABLE_STATIC AC_PROG_LIBTOOL +# ----------------------------------------------------------------------------- +# Compiler Flags / Libraries +# ----------------------------------------------------------------------------- +m4_define(COMPILER_FLAGS, [ + -Wno-unused-parameter + -Wno-sign-compare dnl lots of work to get rid of this + -Wmissing-prototypes + -Wstrict-prototypes + -Wlogical-op + -Wpointer-arith + -Wuninitialized + -Winit-self + -Wstrict-prototypes + -Wimplicit-fallthrough + -Wredundant-decls + -Wincompatible-pointer-types + -Wformat=2 + -Wno-missing-field-initializers + -Wmissing-declarations + + -fvisibility=hidden +]) +m4_foreach_w([_flag], COMPILER_FLAGS, [ + AX_CHECK_COMPILE_FLAG(_flag, AVAILABLE_FLAGS="$AVAILABLE_FLAGS _flag", [], [-Werror]) +]) +AM_CFLAGS="$AM_CFLAGS $AVAILABLE_FLAGS" +AM_CFLAGS="$AM_CFLAGS -D_GNU_SOURCE" +AC_SUBST(AM_CFLAGS) + # Initialize X.Org macros 1.8 or later for MAN_SUBSTS set by XORG_MANPAGE_SECTIONS m4_ifndef([XORG_MACROS_VERSION], [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])]) diff --git a/m4/ax_check_compile_flag.m4 b/m4/ax_check_compile_flag.m4 new file mode 100644 index 0000000..bd753b3 --- /dev/null +++ b/m4/ax_check_compile_flag.m4 @@ -0,0 +1,53 @@ +# =========================================================================== +# https://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) +# +# DESCRIPTION +# +# Check whether the given FLAG works with the current language's compiler +# or gives an error. (Warnings, however, are ignored) +# +# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on +# success/failure. +# +# If EXTRA-FLAGS is defined, it is added to the current language's default +# flags (e.g. CFLAGS) when the check is done. The check is thus made with +# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to +# force the compiler to issue an error when a bad flag is given. +# +# INPUT gives an alternative input source to AC_COMPILE_IFELSE. +# +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this +# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> +# Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com> +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 6 + +AC_DEFUN([AX_CHECK_COMPILE_FLAG], +[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF +AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl +AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ + ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS + _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" + AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], + [AS_VAR_SET(CACHEVAR,[yes])], + [AS_VAR_SET(CACHEVAR,[no])]) + _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) +AS_VAR_IF(CACHEVAR,yes, + [m4_default([$2], :)], + [m4_default([$3], :)]) +AS_VAR_POPDEF([CACHEVAR])dnl +])dnl AX_CHECK_COMPILE_FLAGS diff --git a/src/Makefile.am b/src/Makefile.am index 4ac7d4a..675e266 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -30,11 +30,8 @@ include common.mk @DRIVER_NAME@_drv_la_LTLIBRARIES = @DRIVER_NAME@_drv.la @DRIVER_NAME@_drv_la_LDFLAGS = -module -avoid-version @DRIVER_NAME@_drv_ladir = @inputdir@ - -AM_CPPFLAGS=-I$(top_srcdir)/include/ -AM_CFLAGS = $(XORG_CFLAGS) $(CWARNFLAGS) - @DRIVER_NAME@_drv_la_SOURCES = $(DRIVER_SOURCES) +@DRIVER_NAME@_drv_la_CFLAGS = $(AM_CFLAGS) $(XORG_CFLAGS) -I$(top_srcdir)/include EXTRA_DIST = \ gwacom/wacom-device.c \ diff --git a/test/Makefile.am b/test/Makefile.am index d2b7f33..5401af0 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -5,13 +5,13 @@ check_PROGRAMS = wacom-tests check_LTLIBRARIES = wacom_drv_test.la wacom_drv_test_la_SOURCES = $(DRIVER_SOURCES) wacom-test-suite.c wacom-test-suite.h -wacom_drv_test_la_CFLAGS = -DENABLE_TESTS -I$(top_srcdir)/include -I$(top_srcdir)/src $(XORG_CFLAGS) $(CWARNFLAGS) -fvisibility=default +wacom_drv_test_la_CFLAGS = $(AM_CFLAGS) $(XORG_CFLAGS) -I$(top_srcdir)/include -I$(top_srcdir)/src -DENABLE_TESTS -fvisibility=default wacom_drv_test_la_LDFLAGS = -module -avoid-version -rpath $(abs_builddir) wacom_drv_test_la_LIBADD = $(XORG_LIBS) wacom_tests_LDADD = -ldl wacom_tests_LDFLAGS = -rpath $(abs_builddir)/.libs -wacom_tests_CFLAGS = -DENABLE_TESTS $(CWARNFLAGS) +wacom_tests_CFLAGS = $(AM_CFLAGS) -DENABLE_TESTS wacom_tests_SOURCES = wacom-tests.c TESTS=$(check_PROGRAMS) diff --git a/tools/Makefile.am b/tools/Makefile.am index 113ee90..d54ab71 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -20,19 +20,17 @@ bin_PROGRAMS = xsetwacom isdv4-serial-debugger isdv4-serial-inputattach -AM_CPPFLAGS = -I$(top_srcdir)/include $(CWARNFLAGS) -AM_CFLAGS = $(CWARNFLAGS) - shared_sources = tools-shared.h tools-shared.c isdv4_serial_debugger_SOURCES = isdv4-serial-debugger.c $(shared_sources) +isdv4_serial_debugger_CFLAGS = $(AM_CFLAGS) -I$(top_srcdir)/include isdv4_serial_inputattach_SOURCES = isdv4-serial-inputattach.c $(shared_sources) -isdv4_serial_inputattach_CFLAGS = $(AM_CFLAGS) $(UDEV_CFLAGS) +isdv4_serial_inputattach_CFLAGS = $(AM_CFLAGS) $(UDEV_CFLAGS) -I$(top_srcdir)/include isdv4_serial_inputattach_LDADD = $(UDEV_LIBS) xsetwacom_SOURCES = xsetwacom.c -xsetwacom_CFLAGS = $(AM_CFLAGS) $(X11_CFLAGS) +xsetwacom_CFLAGS = $(AM_CFLAGS) $(X11_CFLAGS) -I$(top_srcdir)/include xsetwacom_LDADD = $(X11_LIBS) if FUZZINTERFACE @@ -42,7 +40,7 @@ endif if UNITTESTS check_PROGRAMS = xsetwacom-test xsetwacom_test_SOURCES=xsetwacom.c $(top_srcdir)/test/wacom-test-suite.c $(top_srcdir)/test/wacom-test-suite.h -xsetwacom_test_CFLAGS=-DENABLE_TESTS -I$(top_srcdir)/test $(AM_CFLAGS) $(X11_CFLAGS) -Wno-error +xsetwacom_test_CFLAGS=$(AM_CFLAGS) $(X11_CFLAGS) -I$(top_srcdir)/include -DENABLE_TESTS -I$(top_srcdir)/test -Wno-unused-function xsetwacom_test_LDADD = $(X11_LIBS) TESTS=$(check_PROGRAMS) |