blob: 3731a23f19e41f60504c692c1f31d106917ac12d [file] [log] [blame]
Brad Bishop1a4b7ee2018-12-16 17:11:34 -08001From f6d0dc338fe867c1b064682ae7f15bffe019b306 Mon Sep 17 00:00:00 2001
2From: Hubert Figuiere <hub@figuiere.net>
3Date: Tue, 12 Apr 2016 02:55:47 +0000
4Subject: [PATCH] Bug 13770 - Require C++11 from now on.
5
6git-svn-id: svn+ssh://svn.abisource.com/svnroot/abiword/trunk@35197 bcba8976-2d24-0410-9c9c-aab3bd5fdfd6
7
8Upstream-Status: Backport
9Signed-off-by: Khem Raj <raj.khem@gmail.com>
10---
11 ax_cxx_compile_stdcxx_11.m4 | 133 +++++++++++++++++++++++++++++++++++
12 configure.ac | 1 +
13 src/wp/ap/gtk/ap_UnixApp.cpp | 2 +-
14 3 files changed, 135 insertions(+), 1 deletion(-)
15 create mode 100644 ax_cxx_compile_stdcxx_11.m4
16
17diff --git a/ax_cxx_compile_stdcxx_11.m4 b/ax_cxx_compile_stdcxx_11.m4
18new file mode 100644
19index 0000000..af37acd
20--- /dev/null
21+++ b/ax_cxx_compile_stdcxx_11.m4
22@@ -0,0 +1,133 @@
23+# ============================================================================
24+# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
25+# ============================================================================
26+#
27+# SYNOPSIS
28+#
29+# AX_CXX_COMPILE_STDCXX_11([ext|noext],[mandatory|optional])
30+#
31+# DESCRIPTION
32+#
33+# Check for baseline language coverage in the compiler for the C++11
34+# standard; if necessary, add switches to CXXFLAGS to enable support.
35+#
36+# The first argument, if specified, indicates whether you insist on an
37+# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g.
38+# -std=c++11). If neither is specified, you get whatever works, with
39+# preference for an extended mode.
40+#
41+# The second argument, if specified 'mandatory' or if left unspecified,
42+# indicates that baseline C++11 support is required and that the macro
43+# should error out if no mode with that support is found. If specified
44+# 'optional', then configuration proceeds regardless, after defining
45+# HAVE_CXX11 if and only if a supporting mode is found.
46+#
47+# LICENSE
48+#
49+# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
50+# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
51+# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
52+#
53+# Copying and distribution of this file, with or without modification, are
54+# permitted in any medium without royalty provided the copyright notice
55+# and this notice are preserved. This file is offered as-is, without any
56+# warranty.
57+
58+#serial 3
59+
60+m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [
61+ template <typename T>
62+ struct check
63+ {
64+ static_assert(sizeof(int) <= sizeof(T), "not big enough");
65+ };
66+
67+ typedef check<check<bool>> right_angle_brackets;
68+
69+ int a;
70+ decltype(a) b;
71+
72+ typedef check<int> check_type;
73+ check_type c;
74+ check_type&& cr = static_cast<check_type&&>(c);
75+
76+ auto d = a;
77+])
78+
79+AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [dnl
80+ m4_if([$1], [], [],
81+ [$1], [ext], [],
82+ [$1], [noext], [],
83+ [m4_fatal([invalid argument `$1' to AX_CXX_COMPILE_STDCXX_11])])dnl
84+ m4_if([$2], [], [ax_cxx_compile_cxx11_required=true],
85+ [$2], [mandatory], [ax_cxx_compile_cxx11_required=true],
86+ [$2], [optional], [ax_cxx_compile_cxx11_required=false],
87+ [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX_11])])dnl
88+ AC_LANG_PUSH([C++])dnl
89+ ac_success=no
90+ AC_CACHE_CHECK(whether $CXX supports C++11 features by default,
91+ ax_cv_cxx_compile_cxx11,
92+ [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
93+ [ax_cv_cxx_compile_cxx11=yes],
94+ [ax_cv_cxx_compile_cxx11=no])])
95+ if test x$ax_cv_cxx_compile_cxx11 = xyes; then
96+ ac_success=yes
97+ fi
98+
99+ m4_if([$1], [noext], [], [dnl
100+ if test x$ac_success = xno; then
101+ for switch in -std=gnu++11 -std=gnu++0x; do
102+ cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
103+ AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
104+ $cachevar,
105+ [ac_save_CXXFLAGS="$CXXFLAGS"
106+ CXXFLAGS="$CXXFLAGS $switch"
107+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
108+ [eval $cachevar=yes],
109+ [eval $cachevar=no])
110+ CXXFLAGS="$ac_save_CXXFLAGS"])
111+ if eval test x\$$cachevar = xyes; then
112+ CXXFLAGS="$CXXFLAGS $switch"
113+ ac_success=yes
114+ break
115+ fi
116+ done
117+ fi])
118+
119+ m4_if([$1], [ext], [], [dnl
120+ if test x$ac_success = xno; then
121+ for switch in -std=c++11 -std=c++0x; do
122+ cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx11_$switch])
123+ AC_CACHE_CHECK(whether $CXX supports C++11 features with $switch,
124+ $cachevar,
125+ [ac_save_CXXFLAGS="$CXXFLAGS"
126+ CXXFLAGS="$CXXFLAGS $switch"
127+ AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_11_testbody])],
128+ [eval $cachevar=yes],
129+ [eval $cachevar=no])
130+ CXXFLAGS="$ac_save_CXXFLAGS"])
131+ if eval test x\$$cachevar = xyes; then
132+ CXXFLAGS="$CXXFLAGS $switch"
133+ ac_success=yes
134+ break
135+ fi
136+ done
137+ fi])
138+ AC_LANG_POP([C++])
139+ if test x$ax_cxx_compile_cxx11_required = xtrue; then
140+ if test x$ac_success = xno; then
141+ AC_MSG_ERROR([*** A compiler with support for C++11 language features is required.])
142+ fi
143+ else
144+ if test x$ac_success = xno; then
145+ HAVE_CXX11=0
146+ AC_MSG_NOTICE([No compiler with C++11 support was found])
147+ else
148+ HAVE_CXX11=1
149+ AC_DEFINE(HAVE_CXX11,1,
150+ [define if the compiler supports basic C++11 syntax])
151+ fi
152+
153+ AC_SUBST(HAVE_CXX11)
154+ fi
155+])
156diff --git a/configure.ac b/configure.ac
157index 48228be..f7be7de 100644
158--- a/configure.ac
159+++ b/configure.ac
160@@ -131,6 +131,7 @@ win_pkgs="$enchant_req"
161
162 AC_PROG_CC
163 AC_PROG_CXX
164+AX_CXX_COMPILE_STDCXX_11(noext,mandatory)
165 #AC_PROG_OBJC
166 AC_PROG_INSTALL
167 # For libtool 1.5.x compatability (AC_PROG_LIBTOOL is deprecated version of LT_INIT)
168diff --git a/src/wp/ap/gtk/ap_UnixApp.cpp b/src/wp/ap/gtk/ap_UnixApp.cpp
169index 061a304..260f8e5 100644
170--- a/src/wp/ap/gtk/ap_UnixApp.cpp
171+++ b/src/wp/ap/gtk/ap_UnixApp.cpp
172@@ -863,7 +863,7 @@ static bool is_so (const char *file) {
173 if (len < (strlen(G_MODULE_SUFFIX) + 2)) // this is ".so" and at least one char for the filename
174 return false;
175 const char *suffix = file+(len-3);
176- if(0 == strcmp (suffix, "."G_MODULE_SUFFIX))
177+ if(0 == strcmp (suffix, "." G_MODULE_SUFFIX))
178 return true;
179 return false;
180 }