aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2019-11-19 11:06:43 +0100
committerAleksander Morgado <aleksander@aleksander.es>2020-01-30 11:59:14 +0100
commit1c078531a017358241a35475fb24f2bd65d501db (patch)
treea2dd47febbed8353ca3917f396f905a342fa19dc
parent4bfd955e64af56b47d398a857be4e8e1b16ce260 (diff)
build: use AX_IS_RELEASE() and AX_COMPILER_FLAGS()
The autoconf macros AX_COMPILER_FLAGS_{CFLAGS|GIR|LDFLAGS} test for compiler and linker support of various flags, and add the flags to the generated output. If the command-line option '--enable-compile-warnings' is specified to 'configure', a number of additional warning options is also added to the output. This is the default. This update requires the presence of the GNU autoconf-archive in the system.
-rw-r--r--cli/Makefile.am9
-rw-r--r--configure.ac32
-rw-r--r--libmm-glib/Makefile.am12
-rw-r--r--libmm-glib/generated/Makefile.am9
-rw-r--r--libqcdm/src/Makefile.am13
-rw-r--r--libqcdm/tests/Makefile.am11
-rw-r--r--m4/compiler_warnings.m435
-rw-r--r--plugins/Makefile.am2
-rw-r--r--src/Makefile.am2
-rw-r--r--src/tests/Makefile.am2
-rw-r--r--test/Makefile.am8
11 files changed, 84 insertions, 51 deletions
diff --git a/cli/Makefile.am b/cli/Makefile.am
index 76ef4a9f..c5221103 100644
--- a/cli/Makefile.am
+++ b/cli/Makefile.am
@@ -1,6 +1,7 @@
bin_PROGRAMS = mmcli
mmcli_CPPFLAGS = \
+ $(WARN_CFLAGS) \
$(MMCLI_CFLAGS) \
-I$(top_srcdir) \
-I$(top_srcdir)/include \
@@ -34,13 +35,17 @@ mmcli_SOURCES = \
$(NULL)
mmcli_LDADD = \
- $(MMCLI_LIBS) \
$(top_builddir)/libmm-glib/libmm-glib.la \
$(NULL)
+mmcli_LDFLAGS = \
+ $(WARN_LDFLAGS) \
+ $(MMCLI_LIBS) \
+ $(NULL)
+
if WITH_UDEV
mmcli_CPPFLAGS += $(GUDEV_CFLAGS)
-mmcli_LDADD += $(GUDEV_LIBS)
+mmcli_LDFLAGS += $(GUDEV_LIBS)
endif
completiondir = $(datadir)/bash-completion/completions
diff --git a/configure.ac b/configure.ac
index 5e56dfd2..57495032 100644
--- a/configure.ac
+++ b/configure.ac
@@ -51,6 +51,33 @@ LT_PREREQ([2.2])
LT_INIT([disable-static])
dnl-----------------------------------------------------------------------------
+dnl Compiler warnings
+dnl
+
+dnl Make sure autoconf-archive is available
+m4_pattern_forbid([^AX_(COMPILER_FLAGS|COMPILER_FLAGS_(CFLAGS|GIR|LDFLAGS))\b],
+ [Unexpanded AX_ macro found. Please install GNU autoconf-archive])
+
+dnl Detect git or release builds
+AX_IS_RELEASE([git-directory])
+
+dnl Function type cast disabled: used throughout the code especially to
+dnl cast GAsyncReadyCallbacks with the real object type instead of GObject
+DISABLED_WARNINGS="${DISABLED_WARNINGS} -Wno-cast-function-type"
+
+dnl All message protocol structs are packed, never complain about it
+DISABLED_WARNINGS="${DISABLED_WARNINGS} -Wno-packed"
+
+dnl Setup compiler checks
+AX_COMPILER_FLAGS()
+AX_COMPILER_FLAGS_CFLAGS(,,,[${DISABLED_WARNINGS}])
+
+dnl Specify gnu89 mode
+if test "$GCC" = "yes"; then
+ CFLAGS="$CFLAGS -std=gnu89"
+fi
+
+dnl-----------------------------------------------------------------------------
dnl Version definitions
dnl
@@ -384,8 +411,6 @@ case $with_qmi in
;;
esac
-NM_COMPILER_WARNINGS
-
dnl-----------------------------------------------------------------------------
dnl Distribution version string
dnl
@@ -534,7 +559,10 @@ echo "
compiler: ${CC}
cflags: ${CFLAGS}
ldflags: ${LDFLAGS}
+ warn cflags: ${WARN_CFLAGS}
+ warn ldflags: ${WARN_LDFLAGS}
maintainer mode: ${USE_MAINTAINER_MODE}
+ release: ${ax_is_release}
System paths:
prefix: ${prefix}
diff --git a/libmm-glib/Makefile.am b/libmm-glib/Makefile.am
index f75cc28d..49f1e832 100644
--- a/libmm-glib/Makefile.am
+++ b/libmm-glib/Makefile.am
@@ -92,6 +92,7 @@ libmm_glib_la_SOURCES = \
$(NULL)
libmm_glib_la_CPPFLAGS = \
+ $(LIBMM_GLIB_CFLAGS) \
-I$(srcdir) \
-I$(top_srcdir) \
-I$(top_builddir) \
@@ -100,22 +101,20 @@ libmm_glib_la_CPPFLAGS = \
-I${top_srcdir}/libmm-glib/generated \
-I${top_builddir}/libmm-glib/generated \
-DLIBMM_GLIB_COMPILATION \
- $(AM_CPPFLAGS) \
$(NULL)
-libmm_glib_la_CFLAGS = \
- $(LIBMM_GLIB_CFLAGS) \
- $(AM_CFLAGS) \
+libmm_glib_gla_CFLAGS = \
+ $(WARN_CFLAGS) \
$(NULL)
libmm_glib_la_LIBADD = \
${top_builddir}/libmm-glib/generated/libmm-generated.la \
- $(LIBMM_GLIB_LIBS) \
$(NULL)
libmm_glib_la_LDFLAGS = \
-version-info $(MM_GLIB_LT_CURRENT):$(MM_GLIB_LT_REVISION):$(MM_GLIB_LT_AGE) \
- $(AM_LDFLAGS) \
+ $(WARN_LDFLAGS) \
+ $(LIBMM_GLIB_LIBS) \
$(NULL)
includedir = @includedir@/libmm-glib
@@ -209,6 +208,7 @@ ModemManager_1_0_gir_CFLAGS = $(libmm_glib_la_CPPFLAGS)
ModemManager_1_0_gir_LIBS = libmm-glib.la
ModemManager_1_0_gir_EXPORT_PACKAGES = libmm-glib
ModemManager_1_0_gir_SCANNERFLAGS = \
+ $(WARN_SCANNERFLAGS) \
--c-include "libmm-glib.h" \
--identifier-prefix=MM \
--identifier-prefix=Mm \
diff --git a/libmm-glib/generated/Makefile.am b/libmm-glib/generated/Makefile.am
index 5f4a5ad9..0f6161dc 100644
--- a/libmm-glib/generated/Makefile.am
+++ b/libmm-glib/generated/Makefile.am
@@ -244,7 +244,14 @@ libmm_generated_la_CPPFLAGS = \
-Wno-shadow \
$(NULL)
-libmm_generated_la_LIBADD = $(LIBMM_GLIB_LIBS)
+libmm_generated_la_CFLAGS = \
+ $(WARN_CFLAGS) \
+ $(NULL)
+
+libmm_generated_la_LDFLAGS = \
+ $(WARN_LDFLAGS) \
+ $(LIBMM_GLIB_LIBS) \
+ $(NULL)
includedir = @includedir@/libmm-glib
nodist_include_HEADERS = $(GENERATED_H)
diff --git a/libqcdm/src/Makefile.am b/libqcdm/src/Makefile.am
index f13098f3..69143bdf 100644
--- a/libqcdm/src/Makefile.am
+++ b/libqcdm/src/Makefile.am
@@ -1,5 +1,13 @@
-AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
-AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
+
+AM_CFLAGS = \
+ $(WARN_CFLAGS) \
+ $(CODE_COVERAGE_CFLAGS) \
+ $(NULL)
+
+AM_LDFLAGS = \
+ $(WARN_LDFLAGS) \
+ $(CODE_COVERAGE_LDFLAGS) \
+ $(NULL)
noinst_LTLIBRARIES = libqcdm.la libqcdm-test.la
@@ -41,4 +49,3 @@ libqcdm_test_la_SOURCES = \
libqcdm_test_la_LIBADD = \
$(MM_LIBS)
-
diff --git a/libqcdm/tests/Makefile.am b/libqcdm/tests/Makefile.am
index c00f1b01..961c5e1d 100644
--- a/libqcdm/tests/Makefile.am
+++ b/libqcdm/tests/Makefile.am
@@ -1,7 +1,14 @@
include $(top_srcdir)/gtester.make
-AM_CFLAGS = $(CODE_COVERAGE_CFLAGS)
-AM_LDFLAGS = $(CODE_COVERAGE_LDFLAGS)
+AM_CFLAGS = \
+ $(WARN_CFLAGS) \
+ $(CODE_COVERAGE_CFLAGS) \
+ $(NULL)
+
+AM_LDFLAGS = \
+ $(WARN_LDFLAGS) \
+ $(CODE_COVERAGE_LDFLAGS) \
+ $(NULL)
noinst_PROGRAMS = test-qcdm modepref ipv6pref reset
TEST_PROGS += test-qcdm
diff --git a/m4/compiler_warnings.m4 b/m4/compiler_warnings.m4
deleted file mode 100644
index 35d005c2..00000000
--- a/m4/compiler_warnings.m4
+++ /dev/null
@@ -1,35 +0,0 @@
-AC_DEFUN([NM_COMPILER_WARNINGS],
-[AC_ARG_ENABLE(more-warnings,
- AS_HELP_STRING([--enable-more-warnings], [Possible values: no/yes/error]),
- set_more_warnings="$enableval",set_more_warnings=error)
-AC_MSG_CHECKING(for more warnings)
-if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
- AC_MSG_RESULT(yes)
- CFLAGS="-Wall -std=gnu89 $CFLAGS"
-
- for option in -Wmissing-declarations -Wmissing-prototypes \
- -Wdeclaration-after-statement -Wstrict-prototypes \
- -Wno-unused-parameter -Wno-sign-compare \
- -Wno-deprecated-declarations -Wno-unused-function \
- -Wunused-variable -Wformat-security; do
- SAVE_CFLAGS="$CFLAGS"
- CFLAGS="$CFLAGS $option -Werror"
- AC_MSG_CHECKING([whether gcc understands $option])
- AC_TRY_COMPILE([], [],
- has_option=yes,
- has_option=no,)
- if test $has_option = no; then
- CFLAGS="$SAVE_CFLAGS"
- fi
- AC_MSG_RESULT($has_option)
- unset has_option
- unset SAVE_CFLAGS
- done
- unset option
- if test "x$set_more_warnings" = xerror; then
- CFLAGS="$CFLAGS -Werror"
- fi
-else
- AC_MSG_RESULT(no)
-fi
-])
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index c50ee3b4..b158bb57 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -6,6 +6,7 @@ include $(top_srcdir)/gtester.make
################################################################################
AM_CFLAGS = \
+ $(WARN_CFLAGS) \
$(MM_CFLAGS) \
$(CODE_COVERAGE_CFLAGS) \
$(GUDEV_CFLAGS) \
@@ -22,6 +23,7 @@ AM_CFLAGS = \
$(NULL)
AM_LDFLAGS = \
+ $(WARN_LDFLAGS) \
$(MM_LIBS) \
$(CODE_COVERAGE_LDFLAGS) \
$(GUDEV_LIBS) \
diff --git a/src/Makefile.am b/src/Makefile.am
index 46a874b3..84c810d6 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -12,6 +12,7 @@ BUILT_SOURCES =
CLEANFILES =
AM_CFLAGS = \
+ $(WARN_CFLAGS) \
$(MM_CFLAGS) \
$(CODE_COVERAGE_CFLAGS) \
$(GUDEV_CFLAGS) \
@@ -26,6 +27,7 @@ AM_CFLAGS = \
$(NULL)
AM_LDFLAGS = \
+ $(WARN_LDFLAGS) \
$(MM_LIBS) \
$(CODE_COVERAGE_LDFLAGS) \
$(GUDEV_LIBS) \
diff --git a/src/tests/Makefile.am b/src/tests/Makefile.am
index 2631f9ba..26a05fa3 100644
--- a/src/tests/Makefile.am
+++ b/src/tests/Makefile.am
@@ -6,6 +6,7 @@ include $(top_srcdir)/gtester.make
################################################################################
AM_CFLAGS = \
+ $(WARN_CFLAGS) \
$(MM_CFLAGS) \
$(CODE_COVERAGE_CFLAGS) \
-I$(top_srcdir) \
@@ -27,6 +28,7 @@ LDADD = \
$(NULL)
AM_LDFLAGS = \
+ $(WARN_LDFLAGS) \
$(MM_LIBS) \
$(CODE_COVERAGE_LDFLAGS) \
-lutil \
diff --git a/test/Makefile.am b/test/Makefile.am
index ba737bc5..bf54f0af 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -2,6 +2,14 @@
noinst_PROGRAMS =
EXTRA_DIST =
+AM_CFLAGS = \
+ $(WARN_CFLAGS) \
+ $(NULL)
+
+AM_LDFLAGS = \
+ $(WARN_LDFLAGS) \
+ $(NULL)
+
################################################################################
# lsudev
################################################################################