summary refs log tree commit diff
path: root/m4
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2015-05-05 17:48:57 +0200
committerMichael Biebl <biebl@debian.org>2015-05-05 17:48:57 +0200
commitf408e27bccfacf347605a8d98649975a68f38a17 (patch)
tree654fd6695c31511baf919b1c0870d119a352ed75 /m4
parent2c032d8f1c6292c1338a615e6ec40252889ba85c (diff)
Imported Upstream version 1.0.2 upstream/1.0.2
Diffstat (limited to 'm4')
-rw-r--r--m4/compiler_warnings.m486
-rw-r--r--m4/gtk-doc.m447
-rw-r--r--m4/intltool.m425
3 files changed, 101 insertions, 57 deletions
diff --git a/m4/compiler_warnings.m4 b/m4/compiler_warnings.m4
index c05a26d0..5c8d2077 100644
--- a/m4/compiler_warnings.m4
+++ b/m4/compiler_warnings.m4
@@ -1,3 +1,24 @@
+dnl Check whether a particular compiler flag works with code provided,
+dnl disable it in CFLAGS if the check fails.
+AC_DEFUN([NM_COMPILER_WARNING], [
+	CFLAGS_SAVED="$CFLAGS"
+	CFLAGS="$CFLAGS -Werror -W$1"
+	AC_MSG_CHECKING(whether -W$1 works)
+
+	AC_COMPILE_IFELSE([AC_LANG_SOURCE([[]])], [
+		AC_COMPILE_IFELSE([AC_LANG_SOURCE([[$2]])], [
+			AC_MSG_RESULT(yes)
+			CFLAGS="$CFLAGS_SAVED -W$1"
+		],[
+			AC_MSG_RESULT(no)
+			CFLAGS="$CFLAGS_SAVED -Wno-$1"
+		])
+	],[
+		AC_MSG_RESULT(not supported)
+		CFLAGS="$CFLAGS_SAVED"
+	])
+])
+
 AC_DEFUN([NM_COMPILER_WARNINGS],
 [AC_ARG_ENABLE(more-warnings,
 	AS_HELP_STRING([--enable-more-warnings], [Possible values: no/yes/error]),
@@ -5,22 +26,26 @@ AC_DEFUN([NM_COMPILER_WARNINGS],
 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_MORE_WARNINGS="-Wall -std=gnu89"
+	CFLAGS="$CFLAGS -Qunused-arguments"
+	AC_COMPILE_IFELSE([AC_LANG_SOURCE([])], [], CFLAGS="$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.
-	CFLAGS_EXTRA="-Werror=unknown-warning-option"
-	CFLAGS="$CFLAGS_MORE_WARNINGS $CFLAGS_EXTRA $CFLAGS_SAVED"
-	AC_TRY_COMPILE([], [],
-		has_option=yes,
-		has_option=no,)
-	if test $has_option = no; then
-		CFLAGS_EXTRA=
+	NM_COMPILER_WARNING([unknown-warning-option], [])
+
+	CFLAGS_SAVED="$CFLAGS"
+	CFLAGS_MORE_WARNINGS="-Wall -std=gnu89"
+
+	if test "x$set_more_warnings" = xerror; then
+		CFLAGS_MORE_WARNINGS="$CFLAGS_MORE_WARNINGS -Werror"
 	fi
-	unset has_option
 
 	for option in -Wshadow -Wmissing-declarations -Wmissing-prototypes \
 		      -Wdeclaration-after-statement -Wformat-security \
@@ -29,9 +54,10 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
 		      -fno-strict-aliasing -Wno-unused-but-set-variable \
 		      -Wundef -Wimplicit-function-declaration \
 		      -Wpointer-arith -Winit-self \
-		      -Wmissing-include-dirs; do
-		CFLAGS="$CFLAGS_MORE_WARNINGS $CFLAGS_EXTRA $option $CFLAGS_SAVED"
-		AC_MSG_CHECKING([whether gcc understands $option])
+		      -Wmissing-include-dirs -Wno-pragmas; do
+		dnl GCC 4.4 does not warn when checking for -Wno-* flags (https://gcc.gnu.org/wiki/FAQ#wnowarning)
+		CFLAGS="$CFLAGS_MORE_WARNINGS $(printf '%s' "$option" | sed 's/^-Wno-/-W/')  $CFLAGS_SAVED"
+		AC_MSG_CHECKING([whether compiler understands $option])
 		AC_TRY_COMPILE([], [],
 			has_option=yes,
 			has_option=no,)
@@ -42,12 +68,38 @@ if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then
 		unset has_option
 	done
 	unset option
-	unset CFLAGS_EXTRA
-	if test "x$set_more_warnings" = xerror; then
-		CFLAGS_MORE_WARNINGS="$CFLAGS_MORE_WARNINGS -Werror"
-	fi
-	CFLAGS="$CFLAGS_MORE_WARNINGS $CFLAGS_SAVED"
+
+	CFLAGS="$CFLAGS_SAVED"
 	unset CFLAGS_SAVED
+
+	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>])
+
+	dnl https://bugzilla.gnome.org/show_bug.cgi?id=744473
+	NM_COMPILER_WARNING([typedef-redefinition], [#include <gio/gio.h>])
+
+	dnl https://llvm.org/bugs/show_bug.cgi?id=21614
+	NM_COMPILER_WARNING([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],
+		[#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],
+		[#define yolo ({ (666 + 666); })]
+		[int f () { int i = yolo; yolo; return i; }]
+	)
+
+	CFLAGS="$CFLAGS_MORE_WARNINGS $CFLAGS"
 else
 	AC_MSG_RESULT(no)
 fi
diff --git a/m4/gtk-doc.m4 b/m4/gtk-doc.m4
index ac2eccb4..36755432 100644
--- a/m4/gtk-doc.m4
+++ b/m4/gtk-doc.m4
@@ -1,6 +1,6 @@
 dnl -*- mode: autoconf -*-
 
-# serial 1
+# serial 2
 
 dnl Usage:
 dnl   GTK_DOC_CHECK([minimum-gtk-doc-version])
@@ -10,8 +10,24 @@ AC_DEFUN([GTK_DOC_CHECK],
   AC_BEFORE([AC_PROG_LIBTOOL],[$0])dnl setup libtool first
   AC_BEFORE([AM_PROG_LIBTOOL],[$0])dnl setup libtool first
 
+  ifelse([$1],[],[gtk_doc_requires="gtk-doc"],[gtk_doc_requires="gtk-doc >= $1"])
+  AC_MSG_CHECKING([for gtk-doc])
+  PKG_CHECK_EXISTS([$gtk_doc_requires],[have_gtk_doc=yes],[have_gtk_doc=no])
+  AC_MSG_RESULT($have_gtk_doc)
+
+  if test "$have_gtk_doc" = "no"; then
+      AC_MSG_WARN([
+  You will not be able to create source packages with 'make dist'
+  because $gtk_doc_requires is not found.])
+  fi
+
   dnl check for tools we added during development
-  AC_PATH_PROG([GTKDOC_CHECK],[gtkdoc-check])
+  dnl Use AC_CHECK_PROG to avoid the check target using an absolute path that
+  dnl may not be writable by the user. Currently, automake requires that the
+  dnl test name must end in '.test'.
+  dnl https://bugzilla.gnome.org/show_bug.cgi?id=701638
+  AC_CHECK_PROG([GTKDOC_CHECK],[gtkdoc-check],[gtkdoc-check.test])
+  AC_PATH_PROG([GTKDOC_CHECK_PATH],[gtkdoc-check])
   AC_PATH_PROGS([GTKDOC_REBASE],[gtkdoc-rebase],[true])
   AC_PATH_PROG([GTKDOC_MKPDF],[gtkdoc-mkpdf])
 
@@ -28,22 +44,22 @@ AC_DEFUN([GTK_DOC_CHECK],
                    [use gtk-doc to build documentation [[default=no]]]),,
     [enable_gtk_doc=no])
 
-  if test x$enable_gtk_doc = xyes; then
-    ifelse([$1],[],
-      [PKG_CHECK_EXISTS([gtk-doc],,
-                        AC_MSG_ERROR([gtk-doc not installed and --enable-gtk-doc requested]))],
-      [PKG_CHECK_EXISTS([gtk-doc >= $1],,
-                        AC_MSG_ERROR([You need to have gtk-doc >= $1 installed to build $PACKAGE_NAME]))])
-    dnl don't check for glib if we build glib
-    if test "x$PACKAGE_NAME" != "xglib"; then
-      dnl don't fail if someone does not have glib
-      PKG_CHECK_MODULES(GTKDOC_DEPS, glib-2.0 >= 2.10.0 gobject-2.0  >= 2.10.0,,[:])
-    fi
-  fi
-
   AC_MSG_CHECKING([whether to build gtk-doc documentation])
   AC_MSG_RESULT($enable_gtk_doc)
 
+  if test "x$enable_gtk_doc" = "xyes" && test "$have_gtk_doc" = "no"; then
+    AC_MSG_ERROR([
+  You must have $gtk_doc_requires installed to build documentation for
+  $PACKAGE_NAME. Please install gtk-doc or disable building the
+  documentation by adding '--disable-gtk-doc' to '[$]0'.])
+  fi
+
+  dnl don't check for glib if we build glib
+  if test "x$PACKAGE_NAME" != "xglib"; then
+    dnl don't fail if someone does not have glib
+    PKG_CHECK_MODULES(GTKDOC_DEPS, glib-2.0 >= 2.10.0 gobject-2.0  >= 2.10.0,,[:])
+  fi
+
   dnl enable/disable output formats
   AC_ARG_ENABLE([gtk-doc-html],
     AS_HELP_STRING([--enable-gtk-doc-html],
@@ -63,6 +79,7 @@ AC_DEFUN([GTK_DOC_CHECK],
   fi
   AC_SUBST([AM_DEFAULT_VERBOSITY])
 
+  AM_CONDITIONAL([HAVE_GTK_DOC], [test x$have_gtk_doc = xyes])
   AM_CONDITIONAL([ENABLE_GTK_DOC], [test x$enable_gtk_doc = xyes])
   AM_CONDITIONAL([GTK_DOC_BUILD_HTML], [test x$enable_gtk_doc_html = xyes])
   AM_CONDITIONAL([GTK_DOC_BUILD_PDF], [test x$enable_gtk_doc_pdf = xyes])
diff --git a/m4/intltool.m4 b/m4/intltool.m4
index 33353eda..c25b7b1a 100644
--- a/m4/intltool.m4
+++ b/m4/intltool.m4
@@ -155,31 +155,6 @@ fi
 # Substitute ALL_LINGUAS so we can use it in po/Makefile
 AC_SUBST(ALL_LINGUAS)
 
-# Set DATADIRNAME correctly if it is not set yet
-# (copied from glib-gettext.m4)
-if test -z "$DATADIRNAME"; then
-  AC_LINK_IFELSE(
-    [AC_LANG_PROGRAM([[]],
-                     [[extern int _nl_msg_cat_cntr;
-                       return _nl_msg_cat_cntr]])],
-    [DATADIRNAME=share],
-    [case $host in
-    *-*-solaris*)
-    dnl On Solaris, if bind_textdomain_codeset is in libc,
-    dnl GNU format message catalog is always supported,
-    dnl since both are added to the libc all together.
-    dnl Hence, we'd like to go with DATADIRNAME=share
-    dnl in this case.
-    AC_CHECK_FUNC(bind_textdomain_codeset,
-      [DATADIRNAME=share], [DATADIRNAME=lib])
-    ;;
-    *)
-    [DATADIRNAME=lib]
-    ;;
-    esac])
-fi
-AC_SUBST(DATADIRNAME)
-
 IT_PO_SUBDIR([po])
 
 ])