@@ -44,6 +44,9 @@ AC_PROG_CXX
4444# Enable shared libraries if available, and static if they don't conflict.
4545AC_PROG_LIBTOOL
4646
47+ # Enable sed for substitution.
48+ AC_PROG_SED
49+
4750# Compute the canonical host-system type variable host, including host_os.
4851AC_CANONICAL_HOST
4952
@@ -52,6 +55,9 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
5255
5356# Check for pkg-config.
5457PKG_PROG_PKG_CONFIG
58+ AS_IF ( [ test -n "$PKG_CONFIG"] , [ ] ,
59+ [ AC_MSG_ERROR ( [ pkg-config is required but was not found.] ) ] )
60+
5561
5662# Declare environment variables that affect the build.
5763# ------------------------------------------------------------------------------
@@ -126,6 +132,16 @@ AS_CASE([${enable_ndebug}], [yes], AC_DEFINE([NDEBUG]))
126132# ------------------------------------------------------------------------------
127133AS_CASE ( [ ${enable_shared}] , [ yes] , AC_DEFINE ( [ BOOST_ALL_DYN_LINK] ) )
128134
135+ # Implement --enable-isystem.
136+ # ------------------------------------------------------------------------------
137+ AC_MSG_CHECKING ( [ --enable-isystem option] )
138+ AC_ARG_ENABLE ( [ isystem] ,
139+ AS_HELP_STRING ( [ --enable-isystem] ,
140+ [ Substitute -isystem for -I in dependencies. @<:@ default=no@:>@ ] ) ,
141+ [ enable_isystem=$enableval] ,
142+ [ enable_isystem=no] )
143+ AC_MSG_RESULT ( [ $enable_isystem] )
144+
129145
130146# Check dependencies.
131147# ==============================================================================
@@ -134,11 +150,19 @@ AS_CASE([${enable_shared}], [yes], AC_DEFINE([BOOST_ALL_DYN_LINK]))
134150AS_CASE ( [ ${CC}] , [ *] ,
135151 [ AX_BOOST_BASE ( [ 1.57.0] ,
136152 [ AC_SUBST ( [ boost_CPPFLAGS] , [ ${BOOST_CPPFLAGS}] )
153+ AC_SUBST ( [ boost_ISYS_CPPFLAGS] , [ `echo ${BOOST_CPPFLAGS} | $SED s/^-I/-isystem/g | $SED s/' -I'/' -isystem'/g`] )
137154 AC_SUBST ( [ boost_LDFLAGS] , [ ${BOOST_LDFLAGS}] )
138155 AC_MSG_NOTICE ( [ boost_CPPFLAGS : ${boost_CPPFLAGS}] )
156+ AC_MSG_NOTICE ( [ boost_ISYS_CPPFLAGS : ${boost_ISYS_CPPFLAGS}] )
139157 AC_MSG_NOTICE ( [ boost_LDFLAGS : ${boost_LDFLAGS}] ) ] ,
140158 [ AC_MSG_ERROR ( [ Boost 1.57.0 or later is required but was not found.] ) ] ) ] )
141159
160+ AS_CASE ( [ ${enable_isystem}] ,[ yes] ,
161+ [ AC_SUBST ( [ boost_BUILD_CPPFLAGS] , [ ${boost_ISYS_CPPFLAGS}] ) ] ,
162+ [ AC_SUBST ( [ boost_BUILD_CPPFLAGS] , [ ${boost_CPPFLAGS}] ) ] )
163+
164+ AC_MSG_NOTICE ( [ boost_BUILD_CPPFLAGS : ${boost_BUILD_CPPFLAGS}] )
165+
142166AS_CASE ( [ ${with_tests}] , [ yes] ,
143167 [ AX_BOOST_UNIT_TEST_FRAMEWORK
144168 AC_SUBST ( [ boost_unit_test_framework_LIBS] , [ ${BOOST_UNIT_TEST_FRAMEWORK_LIB}] )
@@ -149,30 +173,78 @@ AS_CASE([${with_tests}], [yes],
149173# ------------------------------------------------------------------------------
150174AS_CASE ( [ ${bash_completiondir}] , [ yes] ,
151175 [ PKG_CHECK_MODULES([ bash_completion] , [ bash-completion >= 2.0.0] ,
152- [ bash_completiondir="`pkg-config --variable=completionsdir bash-completion`"] ,
153- [ bash_completiondir="${datadir}/bash-completion/completions"] )
176+ [ bash_completion_INCLUDEDIR="`$PKG_CONFIG --variable=includedir "bash-completion >= 2.0.0" 2>/dev/null`"
177+ bash_completion_OTHER_CFLAGS="`$PKG_CONFIG --cflags-only-other "bash-completion >= 2.0.0" 2>/dev/null`"
178+ bash_completiondir="`$PKG_CONFIG --variable=completionsdir "bash-completion >= 2.0.0" 2>/dev/null`"] ,
179+ [ bash_completion_INCLUDEDIR=""
180+ bash_completion_OTHER_CFLAGS=""
181+ bash_completiondir="${datadir}/bash-completion/completions"] )
154182 AC_SUBST ( [ bash_completion_PKG] , [ 'bash-completion >= 2.0.0'] )
155183 AC_SUBST ( [ bash_completion_CPPFLAGS] , [ ${bash_completion_CFLAGS}] )
184+ AS_IF ( [ test x${bash_completion_INCLUDEDIR} != "x"] ,
185+ [ AC_SUBST ( [ bash_completion_ISYS_CPPFLAGS] , [ "-isystem${bash_completion_INCLUDEDIR} ${bash_completion_OTHER_CFLAGS}"] ) ] ,
186+ [ AC_SUBST ( [ bash_completion_ISYS_CPPFLAGS] , [ ${bash_completion_OTHER_CFLAGS}] ) ] )
156187 AC_MSG_NOTICE ( [ bash_completion_CPPFLAGS : ${bash_completion_CPPFLAGS}] )
188+ AC_MSG_NOTICE ( [ bash_completion_ISYS_CPPFLAGS : ${bash_completion_ISYS_CPPFLAGS}] )
189+ AC_MSG_NOTICE ( [ bash_completion_OTHER_CFLAGS : ${bash_completion_OTHER_CFLAGS}] )
190+ AC_MSG_NOTICE ( [ bash_completion_INCLUDEDIR : ${bash_completion_INCLUDEDIR}] )
157191 AC_MSG_NOTICE ( [ bash_completion_LIBS : ${bash_completion_LIBS}] ) ] ,
158192 [ AC_SUBST ( [ bash_completion_PKG] , [ ] ) ] )
159193
194+ AS_CASE ( [ ${enable_isystem}] ,[ yes] ,
195+ [ AC_SUBST ( [ bash_completion_BUILD_CPPFLAGS] , [ ${bash_completion_ISYS_CPPFLAGS}] ) ] ,
196+ [ AC_SUBST ( [ bash_completion_BUILD_CPPFLAGS] , [ ${bash_completion_CPPFLAGS}] ) ] )
197+
198+ AC_MSG_NOTICE ( [ bash_completion_BUILD_CPPFLAGS : ${bash_completion_BUILD_CPPFLAGS}] )
199+
160200# Require bitcoin-node of at least version 3.4.0 and output ${bitcoin_node_CPPFLAGS/LIBS/PKG}.
161201# ------------------------------------------------------------------------------
162- PKG_CHECK_MODULES([ bitcoin_node] , [ libbitcoin-node >= 3.4.0] )
202+ PKG_CHECK_MODULES([ bitcoin_node] , [ libbitcoin-node >= 3.4.0] ,
203+ [ bitcoin_node_INCLUDEDIR="`$PKG_CONFIG --variable=includedir "libbitcoin-node >= 3.4.0" 2>/dev/null`"
204+ bitcoin_node_OTHER_CFLAGS="`$PKG_CONFIG --cflags-only-other "libbitcoin-node >= 3.4.0" 2>/dev/null`"] ,
205+ [ bitcoin_node_INCLUDEDIR=""
206+ bitcoin_node_OTHER_CFLAGS=""] )
163207AC_SUBST ( [ bitcoin_node_PKG] , [ 'libbitcoin-node >= 3.4.0'] )
164208AC_SUBST ( [ bitcoin_node_CPPFLAGS] , [ ${bitcoin_node_CFLAGS}] )
209+ AS_IF ( [ test x${bitcoin_node_INCLUDEDIR} != "x"] ,
210+ [ AC_SUBST ( [ bitcoin_node_ISYS_CPPFLAGS] , [ "-isystem${bitcoin_node_INCLUDEDIR} ${bitcoin_node_OTHER_CFLAGS}"] ) ] ,
211+ [ AC_SUBST ( [ bitcoin_node_ISYS_CPPFLAGS] , [ ${bitcoin_node_OTHER_CFLAGS}] ) ] )
165212AC_MSG_NOTICE ( [ bitcoin_node_CPPFLAGS : ${bitcoin_node_CPPFLAGS}] )
213+ AC_MSG_NOTICE ( [ bitcoin_node_ISYS_CPPFLAGS : ${bitcoin_node_ISYS_CPPFLAGS}] )
214+ AC_MSG_NOTICE ( [ bitcoin_node_OTHER_CFLAGS : ${bitcoin_node_OTHER_CFLAGS}] )
215+ AC_MSG_NOTICE ( [ bitcoin_node_INCLUDEDIR : ${bitcoin_node_INCLUDEDIR}] )
166216AC_MSG_NOTICE ( [ bitcoin_node_LIBS : ${bitcoin_node_LIBS}] )
167217
218+ AS_CASE ( [ ${enable_isystem}] ,[ yes] ,
219+ [ AC_SUBST ( [ bitcoin_node_BUILD_CPPFLAGS] , [ ${bitcoin_node_ISYS_CPPFLAGS}] ) ] ,
220+ [ AC_SUBST ( [ bitcoin_node_BUILD_CPPFLAGS] , [ ${bitcoin_node_CPPFLAGS}] ) ] )
221+
222+ AC_MSG_NOTICE ( [ bitcoin_node_BUILD_CPPFLAGS : ${bitcoin_node_BUILD_CPPFLAGS}] )
223+
168224# Require bitcoin-protocol of at least version 3.4.0 and output ${bitcoin_protocol_CPPFLAGS/LIBS/PKG}.
169225# ------------------------------------------------------------------------------
170- PKG_CHECK_MODULES([ bitcoin_protocol] , [ libbitcoin-protocol >= 3.4.0] )
226+ PKG_CHECK_MODULES([ bitcoin_protocol] , [ libbitcoin-protocol >= 3.4.0] ,
227+ [ bitcoin_protocol_INCLUDEDIR="`$PKG_CONFIG --variable=includedir "libbitcoin-protocol >= 3.4.0" 2>/dev/null`"
228+ bitcoin_protocol_OTHER_CFLAGS="`$PKG_CONFIG --cflags-only-other "libbitcoin-protocol >= 3.4.0" 2>/dev/null`"] ,
229+ [ bitcoin_protocol_INCLUDEDIR=""
230+ bitcoin_protocol_OTHER_CFLAGS=""] )
171231AC_SUBST ( [ bitcoin_protocol_PKG] , [ 'libbitcoin-protocol >= 3.4.0'] )
172232AC_SUBST ( [ bitcoin_protocol_CPPFLAGS] , [ ${bitcoin_protocol_CFLAGS}] )
233+ AS_IF ( [ test x${bitcoin_protocol_INCLUDEDIR} != "x"] ,
234+ [ AC_SUBST ( [ bitcoin_protocol_ISYS_CPPFLAGS] , [ "-isystem${bitcoin_protocol_INCLUDEDIR} ${bitcoin_protocol_OTHER_CFLAGS}"] ) ] ,
235+ [ AC_SUBST ( [ bitcoin_protocol_ISYS_CPPFLAGS] , [ ${bitcoin_protocol_OTHER_CFLAGS}] ) ] )
173236AC_MSG_NOTICE ( [ bitcoin_protocol_CPPFLAGS : ${bitcoin_protocol_CPPFLAGS}] )
237+ AC_MSG_NOTICE ( [ bitcoin_protocol_ISYS_CPPFLAGS : ${bitcoin_protocol_ISYS_CPPFLAGS}] )
238+ AC_MSG_NOTICE ( [ bitcoin_protocol_OTHER_CFLAGS : ${bitcoin_protocol_OTHER_CFLAGS}] )
239+ AC_MSG_NOTICE ( [ bitcoin_protocol_INCLUDEDIR : ${bitcoin_protocol_INCLUDEDIR}] )
174240AC_MSG_NOTICE ( [ bitcoin_protocol_LIBS : ${bitcoin_protocol_LIBS}] )
175241
242+ AS_CASE ( [ ${enable_isystem}] ,[ yes] ,
243+ [ AC_SUBST ( [ bitcoin_protocol_BUILD_CPPFLAGS] , [ ${bitcoin_protocol_ISYS_CPPFLAGS}] ) ] ,
244+ [ AC_SUBST ( [ bitcoin_protocol_BUILD_CPPFLAGS] , [ ${bitcoin_protocol_CPPFLAGS}] ) ] )
245+
246+ AC_MSG_NOTICE ( [ bitcoin_protocol_BUILD_CPPFLAGS : ${bitcoin_protocol_BUILD_CPPFLAGS}] )
247+
176248
177249# Set flags.
178250# ==============================================================================
@@ -188,12 +260,24 @@ AS_CASE([${CC}], [*],
188260 [ AX_CHECK_COMPILE_FLAG ( [ -Wall] ,
189261 [ CFLAGS="$CFLAGS -Wall"] ) ] )
190262
263+ # Warn on all stuff.
264+ # ------------------------------------------------------------------------------
265+ AS_CASE ( [ ${CC}] , [ *] ,
266+ [ AX_CHECK_COMPILE_FLAG ( [ -Wall] ,
267+ [ CXXFLAGS="$CXXFLAGS -Wall"] ) ] )
268+
191269# Warn on extra stuff.
192270# ------------------------------------------------------------------------------
193271AS_CASE ( [ ${CC}] , [ *] ,
194272 [ AX_CHECK_COMPILE_FLAG ( [ -Wextra] ,
195273 [ CFLAGS="$CFLAGS -Wextra"] ) ] )
196274
275+ # Warn on extra stuff.
276+ # ------------------------------------------------------------------------------
277+ AS_CASE ( [ ${CC}] , [ *] ,
278+ [ AX_CHECK_COMPILE_FLAG ( [ -Wextra] ,
279+ [ CXXFLAGS="$CXXFLAGS -Wextra"] ) ] )
280+
197281# Be really annoying.
198282# ------------------------------------------------------------------------------
199283AS_CASE ( [ ${CC}] , [ *] ,
@@ -202,6 +286,26 @@ AS_CASE([${CC}], [*],
202286 [ AX_CHECK_COMPILE_FLAG ( [ -pedantic] ,
203287 [ CFLAGS="$CFLAGS -pedantic"] ) ] ) ] )
204288
289+ # Be really annoying.
290+ # ------------------------------------------------------------------------------
291+ AS_CASE ( [ ${CC}] , [ *] ,
292+ [ AX_CHECK_COMPILE_FLAG ( [ -Wpedantic] ,
293+ [ CXXFLAGS="$CXXFLAGS -Wpedantic"] ,
294+ [ AX_CHECK_COMPILE_FLAG ( [ -pedantic] ,
295+ [ CXXFLAGS="$CXXFLAGS -pedantic"] ) ] ) ] )
296+
297+ # Disallow warning on style order of declarations.
298+ # ------------------------------------------------------------------------------
299+ AS_CASE ( [ ${CC}] , [ *] ,
300+ [ AX_CHECK_COMPILE_FLAG ( [ -Wno-reorder] ,
301+ [ CXXFLAGS="$CXXFLAGS -Wno-reorder"] ) ] )
302+
303+ # Suppress warning for incomplete field initialization.
304+ # ------------------------------------------------------------------------------
305+ AS_CASE ( [ ${CC}] , [ *] ,
306+ [ AX_CHECK_COMPILE_FLAG ( [ -Wno-missing-field-initializers] ,
307+ [ CXXFLAGS="$CXXFLAGS -Wno-missing-field-initializers"] ) ] )
308+
205309# Conform to style.
206310# ------------------------------------------------------------------------------
207311AS_CASE ( [ ${CC}] , [ *] ,
@@ -214,18 +318,6 @@ AS_CASE([${CC}], [*clang*],
214318 [ AX_CHECK_COMPILE_FLAG ( [ -Wno-mismatched-tags] ,
215319 [ CXXFLAGS="$CXXFLAGS -Wno-mismatched-tags"] ) ] )
216320
217- # Clean up boost 1.55 headers. Enabled in gcc only.
218- # ------------------------------------------------------------------------------
219- AS_CASE ( [ ${CC}] , [ *gcc*] ,
220- [ AX_CHECK_COMPILE_FLAG ( [ -Wno-deprecated-declarations] ,
221- [ CXXFLAGS="$CXXFLAGS -Wno-deprecated-declarations"] ) ] )
222-
223- # Clean up boost 1.55 headers. Enabled in clang only.
224- # ------------------------------------------------------------------------------
225- AS_CASE ( [ ${CC}] , [ *clang*] ,
226- [ AX_CHECK_COMPILE_FLAG ( [ -Wno-redeclared-class-member] ,
227- [ CXXFLAGS="$CXXFLAGS -Wno-redeclared-class-member"] ) ] )
228-
229321# Protect stack.
230322# ------------------------------------------------------------------------------
231323AS_CASE ( [ ${CC}] , [ *] ,
@@ -238,12 +330,6 @@ AS_CASE([${CC}], [*],
238330 [ AX_CHECK_LINK_FLAG ( [ -fstack-protector-all] ,
239331 [ LDFLAGS="$LDFLAGS -fstack-protector-all"] ) ] )
240332
241- # Hide internal functions from external libs. Enabled in gcc only.
242- # ------------------------------------------------------------------------------
243- AS_CASE ( [ ${CC}] , [ *gcc*] ,
244- [ AX_CHECK_COMPILE_FLAG ( [ -fvisibility-hidden] ,
245- [ CXXFLAGS="$CXXFLAGS -fvisibility-hidden"] ) ] )
246-
247333# Hide inlines from external libs. Enabled in gcc only.
248334# ------------------------------------------------------------------------------
249335AS_CASE ( [ ${CC}] , [ *gcc*] ,
0 commit comments