From e2852126681ab73aa2c66824d266a707febff9c6 Mon Sep 17 00:00:00 2001
From: Matt Birkholz <matt@birchwood-abbey.net>
Date: Fri, 19 May 2017 13:18:57 -0700
Subject: [PATCH] gtk plugins: Add MIT_CFLAGS for maximal warnage.

---
 src/cairo/Makefile.am  |  1 +
 src/cairo/configure.ac | 32 ++++++++++++++++++++++++++++++++
 src/gl/Makefile.am     |  1 +
 src/gl/configure.ac    | 32 ++++++++++++++++++++++++++++++++
 src/glib/Makefile.am   |  1 +
 src/glib/configure.ac  | 32 ++++++++++++++++++++++++++++++++
 src/gtk/Makefile.am    |  1 +
 src/gtk/configure.ac   | 32 ++++++++++++++++++++++++++++++++
 src/pango/Makefile.am  |  1 +
 src/pango/configure.ac | 32 ++++++++++++++++++++++++++++++++
 src/x11/Makefile.am    |  4 ++--
 11 files changed, 167 insertions(+), 2 deletions(-)

diff --git a/src/cairo/Makefile.am b/src/cairo/Makefile.am
index 858457a07..b257d28e1 100644
--- a/src/cairo/Makefile.am
+++ b/src/cairo/Makefile.am
@@ -49,6 +49,7 @@ AM_UPDATE_INFO_DIR = no
 
 AM_CPPFLAGS = -I@MIT_SCHEME_INCLUDEDIR@
 AM_CFLAGS = `pkg-config --cflags pangocairo`
+AM_CFLAGS += @MIT_CFLAGS@
 LIBS = `pkg-config --libs pangocairo`
 
 cairo_shim_la_LDFLAGS = -module -avoid-version -shared
diff --git a/src/cairo/configure.ac b/src/cairo/configure.ac
index 747cb1d15..5cf8d7a96 100644
--- a/src/cairo/configure.ac
+++ b/src/cairo/configure.ac
@@ -67,6 +67,37 @@ if ! pkg-config --exists cairo 2>/dev/null; then
     AC_MSG_ERROR([Cairo not found.])
 fi
 
+if test ${GCC} = yes; then
+
+    MIT_CFLAGS="-Wall -Wundef -Wpointer-arith -Winline"
+    MIT_CFLAGS="${MIT_CFLAGS} -Wstrict-prototypes -Wnested-externs"
+    MIT_CFLAGS="${MIT_CFLAGS} -Wredundant-decls"
+
+    AC_MSG_CHECKING([for GCC>=4])
+    AC_COMPILE_IFELSE(
+	[AC_LANG_PROGRAM(
+	    [[
+	    #if __GNUC__ >= 4
+	    ;
+	    #else
+	    #error "gcc too old"
+	    #endif
+	    ]],
+	    [[]]
+	)],
+	[
+	AC_MSG_RESULT([yes])
+	MIT_CFLAGS="${MIT_CFLAGS} -Wextra -Wno-sign-compare"
+	MIT_CFLAGS="${MIT_CFLAGS} -Wno-unused-parameter"
+	MIT_CFLAGS="${MIT_CFLAGS} -Wold-style-definition"
+	# The generated shim code violates this big-time.
+	# MIT_CFLAGS="${MIT_CFLAGS} -Wmissing-prototypes"
+	MIT_CFLAGS="${MIT_CFLAGS} -Wunreachable-code"
+	MIT_CFLAGS="${MIT_CFLAGS} -Wwrite-strings"
+	],
+	[AC_MSG_RESULT([no])])
+fi
+
 MIT_SCHEME_PROJECT=mit-scheme-pucked
 : ${MIT_SCHEME_EXE=mit-scheme}
 MIT_SCHEME_LIBDIR=`( echo "(display (->namestring" ;\
@@ -86,6 +117,7 @@ pdfdir='$(datarootdir)/doc/$(MIT_SCHEME_PROJECT)/pdf'
 
 AC_SUBST([MIT_SCHEME_PROJECT])
 AC_SUBST([MIT_SCHEME_EXE])
+AC_SUBST([MIT_CFLAGS])
 AC_SUBST([MIT_SCHEME_LIBDIR])
 AC_SUBST([MIT_SCHEME_INCLUDEDIR])
 AC_SUBST([MIT_SCHEME_OS_SUFFIX])
diff --git a/src/gl/Makefile.am b/src/gl/Makefile.am
index cbac409d7..d894c286c 100644
--- a/src/gl/Makefile.am
+++ b/src/gl/Makefile.am
@@ -50,6 +50,7 @@ scmlib_sub_DATA += make.scm gl-@MIT_SCHEME_OS_SUFFIX@.pkd
 
 AM_CPPFLAGS = -I@MIT_SCHEME_INCLUDEDIR@
 AM_CFLAGS = `pkg-config --cflags gl glu gtk+-3.0`
+AM_CFLAGS += @MIT_CFLAGS@
 LIBS = `pkg-config --libs gl glu gtk+-3.0`
 
 gl_shim_la_LIBADD = gl-adapter.lo
diff --git a/src/gl/configure.ac b/src/gl/configure.ac
index 394600b6b..945b1ddce 100644
--- a/src/gl/configure.ac
+++ b/src/gl/configure.ac
@@ -67,6 +67,37 @@ if ! pkg-config --exists gl glu gtk+-3.0 2>/dev/null; then
     AC_MSG_ERROR([libGL not found.])
 fi
 
+if test ${GCC} = yes; then
+
+    MIT_CFLAGS="-Wall -Wundef -Wpointer-arith -Winline"
+    MIT_CFLAGS="${MIT_CFLAGS} -Wstrict-prototypes -Wnested-externs"
+    MIT_CFLAGS="${MIT_CFLAGS} -Wredundant-decls"
+
+    AC_MSG_CHECKING([for GCC>=4])
+    AC_COMPILE_IFELSE(
+	[AC_LANG_PROGRAM(
+	    [[
+	    #if __GNUC__ >= 4
+	    ;
+	    #else
+	    #error "gcc too old"
+	    #endif
+	    ]],
+	    [[]]
+	)],
+	[
+	AC_MSG_RESULT([yes])
+	MIT_CFLAGS="${MIT_CFLAGS} -Wextra -Wno-sign-compare"
+	MIT_CFLAGS="${MIT_CFLAGS} -Wno-unused-parameter"
+	MIT_CFLAGS="${MIT_CFLAGS} -Wold-style-definition"
+	# The generated shim code violates this big-time.
+	# MIT_CFLAGS="${MIT_CFLAGS} -Wmissing-prototypes"
+	MIT_CFLAGS="${MIT_CFLAGS} -Wunreachable-code"
+	MIT_CFLAGS="${MIT_CFLAGS} -Wwrite-strings"
+	],
+	[AC_MSG_RESULT([no])])
+fi
+
 MIT_SCHEME_PROJECT=mit-scheme-pucked
 : ${MIT_SCHEME_EXE=mit-scheme}
 MIT_SCHEME_LIBDIR=`( echo "(display (->namestring" ;\
@@ -86,6 +117,7 @@ pdfdir='$(datarootdir)/doc/$(MIT_SCHEME_PROJECT)/pdf'
 
 AC_SUBST([MIT_SCHEME_PROJECT])
 AC_SUBST([MIT_SCHEME_EXE])
+AC_SUBST([MIT_CFLAGS])
 AC_SUBST([MIT_SCHEME_LIBDIR])
 AC_SUBST([MIT_SCHEME_INCLUDEDIR])
 AC_SUBST([MIT_SCHEME_OS_SUFFIX])
diff --git a/src/glib/Makefile.am b/src/glib/Makefile.am
index ec03457b5..eabe887d9 100644
--- a/src/glib/Makefile.am
+++ b/src/glib/Makefile.am
@@ -52,6 +52,7 @@ AM_UPDATE_INFO_DIR = no
 
 AM_CPPFLAGS = -I@MIT_SCHEME_INCLUDEDIR@
 AM_CFLAGS = `pkg-config --cflags gio-2.0`
+AM_CFLAGS += @MIT_CFLAGS@
 LIBS = `pkg-config --libs glib-2.0 gthread-2.0 gio-2.0`
 
 glib_shim_la_LIBADD = glibio.lo
diff --git a/src/glib/configure.ac b/src/glib/configure.ac
index 210ce7037..4a08ab238 100644
--- a/src/glib/configure.ac
+++ b/src/glib/configure.ac
@@ -67,6 +67,37 @@ if ! pkg-config --exists glib-2.0 2>/dev/null; then
     AC_MSG_ERROR([GLib 2.0 not found.])
 fi
 
+if test ${GCC} = yes; then
+
+    MIT_CFLAGS="-Wall -Wundef -Wpointer-arith -Winline"
+    MIT_CFLAGS="${MIT_CFLAGS} -Wstrict-prototypes -Wnested-externs"
+    MIT_CFLAGS="${MIT_CFLAGS} -Wredundant-decls"
+
+    AC_MSG_CHECKING([for GCC>=4])
+    AC_COMPILE_IFELSE(
+	[AC_LANG_PROGRAM(
+	    [[
+	    #if __GNUC__ >= 4
+	    ;
+	    #else
+	    #error "gcc too old"
+	    #endif
+	    ]],
+	    [[]]
+	)],
+	[
+	AC_MSG_RESULT([yes])
+	MIT_CFLAGS="${MIT_CFLAGS} -Wextra -Wno-sign-compare"
+	MIT_CFLAGS="${MIT_CFLAGS} -Wno-unused-parameter"
+	MIT_CFLAGS="${MIT_CFLAGS} -Wold-style-definition"
+	# The generated shim code violates this big-time.
+	# MIT_CFLAGS="${MIT_CFLAGS} -Wmissing-prototypes"
+	MIT_CFLAGS="${MIT_CFLAGS} -Wunreachable-code"
+	MIT_CFLAGS="${MIT_CFLAGS} -Wwrite-strings"
+	],
+	[AC_MSG_RESULT([no])])
+fi
+
 MIT_SCHEME_PROJECT=mit-scheme-pucked
 : ${MIT_SCHEME_EXE=mit-scheme}
 MIT_SCHEME_LIBDIR=`( echo "(display (->namestring" ;\
@@ -86,6 +117,7 @@ pdfdir='$(datarootdir)/doc/$(MIT_SCHEME_PROJECT)/pdf'
 
 AC_SUBST([MIT_SCHEME_PROJECT])
 AC_SUBST([MIT_SCHEME_EXE])
+AC_SUBST([MIT_CFLAGS])
 AC_SUBST([MIT_SCHEME_LIBDIR])
 AC_SUBST([MIT_SCHEME_INCLUDEDIR])
 AC_SUBST([MIT_SCHEME_OS_SUFFIX])
diff --git a/src/gtk/Makefile.am b/src/gtk/Makefile.am
index 17dcda32d..e60ca8475 100644
--- a/src/gtk/Makefile.am
+++ b/src/gtk/Makefile.am
@@ -62,6 +62,7 @@ AM_UPDATE_INFO_DIR = no
 
 AM_CPPFLAGS = -I@MIT_SCHEME_INCLUDEDIR@
 AM_CFLAGS = `pkg-config --cflags gtk+-3.0`
+AM_CFLAGS += @MIT_CFLAGS@
 LIBS = `pkg-config --libs gtk+-3.0 gthread-2.0`
 
 gtk_shim_la_LIBADD = gtkio.lo scmwidget.lo gtkpanedview.lo gtkscrolledview.lo
diff --git a/src/gtk/configure.ac b/src/gtk/configure.ac
index adb5882a0..0541b90d1 100644
--- a/src/gtk/configure.ac
+++ b/src/gtk/configure.ac
@@ -93,6 +93,37 @@ fi
 ln -sf gtkscrolledview-$GTK_VERSION.c gtkscrolledview.c
 ln -sf gtkpanedview-$GTK_VERSION.c gtkpanedview.c
 
+if test ${GCC} = yes; then
+
+    MIT_CFLAGS="-Wall -Wundef -Wpointer-arith -Winline"
+    MIT_CFLAGS="${MIT_CFLAGS} -Wstrict-prototypes -Wnested-externs"
+    MIT_CFLAGS="${MIT_CFLAGS} -Wredundant-decls"
+
+    AC_MSG_CHECKING([for GCC>=4])
+    AC_COMPILE_IFELSE(
+	[AC_LANG_PROGRAM(
+	    [[
+	    #if __GNUC__ >= 4
+	    ;
+	    #else
+	    #error "gcc too old"
+	    #endif
+	    ]],
+	    [[]]
+	)],
+	[
+	AC_MSG_RESULT([yes])
+	MIT_CFLAGS="${MIT_CFLAGS} -Wextra -Wno-sign-compare"
+	MIT_CFLAGS="${MIT_CFLAGS} -Wno-unused-parameter"
+	MIT_CFLAGS="${MIT_CFLAGS} -Wold-style-definition"
+	# The generated shim code violates this big-time.
+	# MIT_CFLAGS="${MIT_CFLAGS} -Wmissing-prototypes"
+	MIT_CFLAGS="${MIT_CFLAGS} -Wunreachable-code"
+	MIT_CFLAGS="${MIT_CFLAGS} -Wwrite-strings"
+	],
+	[AC_MSG_RESULT([no])])
+fi
+
 MIT_SCHEME_PROJECT=mit-scheme-pucked
 : ${MIT_SCHEME_EXE=mit-scheme}
 MIT_SCHEME_LIBDIR=`( echo "(display (->namestring" ;\
@@ -112,6 +143,7 @@ pdfdir='$(datarootdir)/doc/$(MIT_SCHEME_PROJECT)/pdf'
 
 AC_SUBST([MIT_SCHEME_PROJECT])
 AC_SUBST([MIT_SCHEME_EXE])
+AC_SUBST([MIT_CFLAGS])
 AC_SUBST([MIT_SCHEME_LIBDIR])
 AC_SUBST([MIT_SCHEME_INCLUDEDIR])
 AC_SUBST([MIT_SCHEME_OS_SUFFIX])
diff --git a/src/pango/Makefile.am b/src/pango/Makefile.am
index 4197e1a38..a1df14554 100644
--- a/src/pango/Makefile.am
+++ b/src/pango/Makefile.am
@@ -48,6 +48,7 @@ AM_UPDATE_INFO_DIR = no
 
 AM_CPPFLAGS = -I@MIT_SCHEME_INCLUDEDIR@
 AM_CFLAGS = `pkg-config --cflags pango`
+AM_CFLAGS += @MIT_CFLAGS@
 LIBS = `pkg-config --libs pango`
 
 pango_shim_la_LDFLAGS = -module -avoid-version -shared
diff --git a/src/pango/configure.ac b/src/pango/configure.ac
index 6a99aaab1..ffcac50ff 100644
--- a/src/pango/configure.ac
+++ b/src/pango/configure.ac
@@ -67,6 +67,37 @@ if ! pkg-config --exists pango 2>/dev/null; then
     AC_MSG_ERROR([Pango not found.])
 fi
 
+if test ${GCC} = yes; then
+
+    MIT_CFLAGS="-Wall -Wundef -Wpointer-arith -Winline"
+    MIT_CFLAGS="${MIT_CFLAGS} -Wstrict-prototypes -Wnested-externs"
+    MIT_CFLAGS="${MIT_CFLAGS} -Wredundant-decls"
+
+    AC_MSG_CHECKING([for GCC>=4])
+    AC_COMPILE_IFELSE(
+	[AC_LANG_PROGRAM(
+	    [[
+	    #if __GNUC__ >= 4
+	    ;
+	    #else
+	    #error "gcc too old"
+	    #endif
+	    ]],
+	    [[]]
+	)],
+	[
+	AC_MSG_RESULT([yes])
+	MIT_CFLAGS="${MIT_CFLAGS} -Wextra -Wno-sign-compare"
+	MIT_CFLAGS="${MIT_CFLAGS} -Wno-unused-parameter"
+	MIT_CFLAGS="${MIT_CFLAGS} -Wold-style-definition"
+	# The generated shim code violates this big-time.
+	# MIT_CFLAGS="${MIT_CFLAGS} -Wmissing-prototypes"
+	MIT_CFLAGS="${MIT_CFLAGS} -Wunreachable-code"
+	MIT_CFLAGS="${MIT_CFLAGS} -Wwrite-strings"
+	],
+	[AC_MSG_RESULT([no])])
+fi
+
 MIT_SCHEME_PROJECT=mit-scheme-pucked
 : ${MIT_SCHEME_EXE=mit-scheme}
 MIT_SCHEME_LIBDIR=`( echo "(display (->namestring" ;\
@@ -86,6 +117,7 @@ pdfdir='$(datarootdir)/doc/$(MIT_SCHEME_PROJECT)/pdf'
 
 AC_SUBST([MIT_SCHEME_PROJECT])
 AC_SUBST([MIT_SCHEME_EXE])
+AC_SUBST([MIT_CFLAGS])
 AC_SUBST([MIT_SCHEME_LIBDIR])
 AC_SUBST([MIT_SCHEME_INCLUDEDIR])
 AC_SUBST([MIT_SCHEME_OS_SUFFIX])
diff --git a/src/x11/Makefile.am b/src/x11/Makefile.am
index 29ab3245c..51de78469 100644
--- a/src/x11/Makefile.am
+++ b/src/x11/Makefile.am
@@ -46,8 +46,8 @@ scmlib_sub_DATA += make.scm @MIT_SCHEME_PKD@
 #AM_MAKEINFOHTMLFLAGS = --no-split
 
 AM_CPPFLAGS = -I@MIT_SCHEME_INCLUDEDIR@
-AM_CFLAGS = @MIT_CFLAGS@
-AM_CFLAGS += `pkg-config --cflags x11`
+AM_CFLAGS = `pkg-config --cflags x11`
+AM_CFLAGS += @MIT_CFLAGS@
 LIBS = `pkg-config --libs x11`
 
 x11_shim_la_LIBADD = x11base.lo x11color.lo x11graph.lo x11term.lo
-- 
2.25.1