diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2018-07-30 13:42:45 +0200 |
---|---|---|
committer | Lubomir Rintel <lkundrak@v3.sk> | 2018-07-30 13:42:45 +0200 |
commit | c2e9f9df9d77d863785af8c1ea3ed96a7a057080 (patch) | |
tree | 8496483e9414a2ba7ea589410502e6422f60319d | |
parent | 273c650cb679d53339394cd4204da4633c671ebe (diff) | |
parent | 792b79ed405d42b984b0ad9bf6519539f782c52a (diff) | |
download | network-manager-applet-c2e9f9df9d77d863785af8c1ea3ed96a7a057080.tar.gz |
merge: branch 'lr/compiler-options'
https://gitlab.gnome.org/GNOME/network-manager-applet/merge_requests/17
-rw-r--r-- | Makefile.am | 12 | ||||
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | m4/compiler_options.m4 | 56 |
3 files changed, 48 insertions, 23 deletions
diff --git a/Makefile.am b/Makefile.am index 3ad1af9a..601e5e46 100644 --- a/Makefile.am +++ b/Makefile.am @@ -55,6 +55,8 @@ SUBDIRS = \ . \ po +dflt_cppflags = -std=gnu99 + ############################################################################### icon16dir = $(datadir)/icons/hicolor/16x16/apps @@ -171,6 +173,7 @@ shared_files = \ noinst_LTLIBRARIES += src/utils/libutils-libnm.la src_utils_libutils_libnm_la_CPPFLAGS = \ + $(dflt_cppflags) \ "-I$(srcdir)/shared" \ $(GTK3_CFLAGS) \ $(LIBNM_CFLAGS) @@ -189,6 +192,7 @@ if WITH_LIBNM_GTK noinst_LTLIBRARIES += src/utils/libutils-libnm-glib.la src_utils_libutils_libnm_glib_la_CPPFLAGS = \ + $(dflt_cppflags) \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY \ "-I$(srcdir)/shared" \ $(GTK3_CFLAGS) \ @@ -210,6 +214,7 @@ check_programs += src/utils/tests/test-utils src_utils_tests_test_utils_SOURCES = src/utils/tests/test-utils.c src_utils_tests_test_utils_CPPFLAGS = \ + $(dflt_cppflags) \ "-I$(srcdir)/shared/" \ "-I$(srcdir)/src/utils" \ $(GTK3_CFLAGS) \ @@ -280,6 +285,7 @@ nodist_src_wireless_security_libwireless_security_libnm_la_SOURCES = \ $(wireless_security_c_gen) src_wireless_security_libwireless_security_libnm_la_CPPFLAGS = \ + $(dflt_cppflags) \ "-I$(srcdir)/shared" \ "-I$(srcdir)/src/utils" \ "-I$(srcdir)/src/libnma" \ @@ -305,6 +311,7 @@ nodist_src_wireless_security_libwireless_security_libnm_glib_la_SOURCES = \ $(wireless_security_c_gen) src_wireless_security_libwireless_security_libnm_glib_la_CPPFLAGS = \ + $(dflt_cppflags) \ $(GTK3_CFLAGS) \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY \ "-I$(srcdir)/shared" \ @@ -391,6 +398,7 @@ nodist_src_libnm_gtk_libnm_gtk_la_SOURCES = \ $(libnm_gtk_c_gen) src_libnm_gtk_libnm_gtk_la_CFLAGS = \ + $(dflt_cppflags) \ -DNETWORKMANAGER_COMPILATION=NM_NETWORKMANAGER_COMPILATION_LIB_LEGACY \ -DICONDIR=\""$(datadir)/icons"\" \ -DBINDIR=\""$(bindir)"\" \ @@ -448,6 +456,7 @@ endif check_programs += src/libnm-gtk/tests/test-mobile-providers src_libnm_gtk_tests_test_mobile_providers_CPPFLAGS = \ + $(dflt_cppflags) \ -DTEST_DATA_DIR=\""$(abs_srcdir)/src/libnm-gtk/tests"\" \ "-I$(srcdir)/shared" \ "-I$(srcdir)/src/libnm-gtk" \ @@ -547,6 +556,7 @@ nodist_src_libnma_libnma_la_SOURCES = \ $(libnma_c_gen) src_libnma_libnma_la_CFLAGS = \ + $(dflt_cppflags) \ -DICONDIR=\""$(datadir)/icons"\" \ -DBINDIR=\""$(bindir)"\" \ -DSYSCONFDIR=\""$(sysconfdir)"\" \ @@ -710,6 +720,7 @@ nodist_src_connection_editor_nm_connection_editor_SOURCES = \ $(connection_editor_c_gen) src_connection_editor_nm_connection_editor_CPPFLAGS = \ + $(dflt_cppflags) \ -DICONDIR=\""$(datadir)/icons"\" \ -DBINDIR=\""$(bindir)"\" \ -DSYSCONFDIR=\""$(sysconfdir)"\" \ @@ -835,6 +846,7 @@ nodist_src_nm_applet_SOURCES = \ $(nm_applet_c_gen) src_nm_applet_CPPFLAGS = \ + $(dflt_cppflags) \ -DICONDIR=\""$(datadir)/icons"\" \ -DBINDIR=\""$(bindir)"\" \ -DSYSCONFDIR=\""$(sysconfdir)"\" \ diff --git a/configure.ac b/configure.ac index 0bd31efc..5f0f16e1 100644 --- a/configure.ac +++ b/configure.ac @@ -290,11 +290,10 @@ GLIB_CONFIG_NMA GLIB_GSETTINGS AC_PATH_PROG(GLIB_COMPILE_RESOURCES, glib-compile-resources) -NM_COMPILER_WARNINGS([yes]) +NM_COMPILER_WARNINGS(CFLAGS, [yes]) NM_LTO NM_LD_GC - AC_ARG_WITH(more-asserts, AS_HELP_STRING([--with-more-asserts=level], [Enable more assertions for debugging (default: 0)]), [more_asserts=${with_more_asserts}], diff --git a/m4/compiler_options.m4 b/m4/compiler_options.m4 index d1363010..d42501e8 100644 --- a/m4/compiler_options.m4 +++ b/m4/compiler_options.m4 @@ -20,42 +20,45 @@ AC_DEFUN([_NM_COMPILER_FLAG], [ ]) dnl Check whether a particular compiler flag is supported, -dnl add it to CFLAGS if it is +dnl append it to the specified variable if the check succeeds. +dnl NM_COMPILER_FLAG([ENV-VAR], [FLAG], [ACTION-IF-SUPPORTED], [ACTION-IF-NOT-SUPPORTED]) AC_DEFUN([NM_COMPILER_FLAG], [ - _NM_COMPILER_FLAG([$1], [], [ - CFLAGS="$CFLAGS $1" - $2 - ], [$3]) + _NM_COMPILER_FLAG([$2], [], [ + eval "AS_TR_SH([$1])='$$1 $2'" + $3 + ], [$4]) ]) dnl Check whether a particular warning is not emitted with code provided, -dnl disable it in CFLAGS if the check fails. +dnl append an option to disable the warning to a specified variable if the check fails. +dnl NM_COMPILER_WARNING([ENV-VAR], [C-SNIPPET], [WARNING]]) AC_DEFUN([NM_COMPILER_WARNING], [ - _NM_COMPILER_FLAG([-W$1], [$2], [CFLAGS="$CFLAGS -W$1"], [CFLAGS="$CFLAGS -Wno-$1"]) + _NM_COMPILER_FLAG([-W$2], [$3], [eval "AS_TR_SH([$1])='$$1 -W$2'"], [eval "AS_TR_SH([$1])='$$1 -Wno-$2'"]) ]) +dnl NM_COMPILER_WARNINGS([ENV-VAR], [MORE-WARNINGS]) 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=$1) + set_more_warnings="$enableval",set_more_warnings=$2) AC_MSG_CHECKING(for more warnings) if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then AC_MSG_RESULT(yes) dnl This is enabled in clang by default, makes little sense, dnl and causes the build to abort with -Werror. - CFLAGS_SAVED="$CFLAGS" - CFLAGS="$CFLAGS -Qunused-arguments" - AC_COMPILE_IFELSE([AC_LANG_SOURCE([])], [], CFLAGS="$CFLAGS_SAVED") + CFLAGS_SAVED="$$1" + eval "AS_TR_SH([$1])='$$1 -Qunused-arguments'" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([])], [], eval "AS_TR_SH([$1])='$CFLAGS_SAVED'") unset CFLAGS_SAVED dnl clang only warns about unknown warnings, unless dnl called with "-Werror=unknown-warning-option" dnl Test if the compiler supports that, and if it does dnl attach it to the CFLAGS. - NM_COMPILER_WARNING([unknown-warning-option], []) + NM_COMPILER_WARNING([$1], [unknown-warning-option], []) - CFLAGS="$CFLAGS -Wall -std=gnu99" + CFLAGS="$CFLAGS -Wall" if test "x$set_more_warnings" = xerror; then CFLAGS_MORE_WARNINGS="$CFLAGS_MORE_WARNINGS -Werror" @@ -89,7 +92,7 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then -Wno-unused-parameter \ ; do dnl GCC 4.4 does not warn when checking for -Wno-* flags (https://gcc.gnu.org/wiki/FAQ#wnowarning) - _NM_COMPILER_FLAG([$(printf '%s' "$option" | sed 's/^-Wno-/-W/')], [], + _NM_COMPILER_FLAG([$(printf '%s' "$option" | sed 's/^-Wno-/-W/')], [], [CFLAGS_MORE_WARNINGS="$CFLAGS_MORE_WARNINGS $option"], []) done unset option @@ -97,37 +100,48 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then dnl Disable warnings triggered by known compiler problems dnl https://bugzilla.gnome.org/show_bug.cgi?id=745821 - NM_COMPILER_WARNING([unknown-attributes], [#include <glib.h>]) + NM_COMPILER_WARNING([$1], [unknown-attributes], [#include <glib.h>]) dnl https://bugzilla.gnome.org/show_bug.cgi?id=744473 - NM_COMPILER_WARNING([typedef-redefinition], [#include <gio/gio.h>]) + NM_COMPILER_WARNING([$1], [typedef-redefinition], [#include <gio/gio.h>]) dnl https://llvm.org/bugs/show_bug.cgi?id=21614 - NM_COMPILER_WARNING([array-bounds], + NM_COMPILER_WARNING([$1], [array-bounds], [#include <string.h>] [void f () { strcmp ("something", "0"); }] ) dnl https://llvm.org/bugs/show_bug.cgi?id=22949 - NM_COMPILER_WARNING([parentheses-equality], + NM_COMPILER_WARNING([$1], [parentheses-equality], [#include <sys/wait.h>] [void f () { if (WIFCONTINUED(0)) return; }] ) dnl systemd-dhcp's log_internal macro and our handle_warn are sometimes dnl used in void context,u sometimes in int. Makes clang unhappy. - NM_COMPILER_WARNING([unused-value], + NM_COMPILER_WARNING([$1], [unused-value], [#define yolo ({ (666 + 666); })] [int f () { int i = yolo; yolo; return i; }] ) dnl clang 3.9 would like to see "{ { 0 } }" here, but that does not dnl look too wise. - NM_COMPILER_WARNING([missing-braces], + NM_COMPILER_WARNING([$1], [missing-braces], [union { int a[1]; int b[2]; } c = { 0 }] ) - CFLAGS="$CFLAGS_MORE_WARNINGS $CFLAGS" + dnl a new warning in gcc 8, glib 2.55 doesn't play nice yet + dnl https://bugzilla.gnome.org/show_bug.cgi?id=793272 + NM_COMPILER_WARNING([$1], [cast-function-type], + [#include <glib-object.h>] + [typedef struct { GObject parent; } NMObject;] + [typedef struct { GObjectClass parent; } NMObjectClass;] + [static void nm_object_init (NMObject *object) { } ] + [static void nm_object_class_init (NMObjectClass *object) { }] + [G_DEFINE_TYPE (NMObject, nm_object, G_TYPE_OBJECT)] + ) + + eval "AS_TR_SH([$1])='$CFLAGS_MORE_WARNINGS $$1'" else AC_MSG_RESULT(no) fi |