@@ -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# ------------------------------------------------------------------------------
@@ -103,6 +109,16 @@ AS_CASE([${enable_ndebug}], [yes], AC_DEFINE([NDEBUG]))
103109# ------------------------------------------------------------------------------
104110AS_CASE ( [ ${enable_shared}] , [ yes] , AC_DEFINE ( [ BOOST_ALL_DYN_LINK] ) )
105111
112+ # Implement --enable-isystem.
113+ # ------------------------------------------------------------------------------
114+ AC_MSG_CHECKING ( [ --enable-isystem option] )
115+ AC_ARG_ENABLE ( [ isystem] ,
116+ AS_HELP_STRING ( [ --enable-isystem] ,
117+ [ Substitute -isystem for -I in dependencies. @<:@ default=no@:>@ ] ) ,
118+ [ enable_isystem=$enableval] ,
119+ [ enable_isystem=no] )
120+ AC_MSG_RESULT ( [ $enable_isystem] )
121+
106122
107123# Check dependencies.
108124# ==============================================================================
@@ -111,11 +127,19 @@ AS_CASE([${enable_shared}], [yes], AC_DEFINE([BOOST_ALL_DYN_LINK]))
111127AS_CASE ( [ ${CC}] , [ *] ,
112128 [ AX_BOOST_BASE ( [ 1.57.0] ,
113129 [ AC_SUBST ( [ boost_CPPFLAGS] , [ ${BOOST_CPPFLAGS}] )
130+ AC_SUBST ( [ boost_ISYS_CPPFLAGS] , [ `echo ${BOOST_CPPFLAGS} | $SED s/^-I/-isystem/g | $SED s/' -I'/' -isystem'/g`] )
114131 AC_SUBST ( [ boost_LDFLAGS] , [ ${BOOST_LDFLAGS}] )
115132 AC_MSG_NOTICE ( [ boost_CPPFLAGS : ${boost_CPPFLAGS}] )
133+ AC_MSG_NOTICE ( [ boost_ISYS_CPPFLAGS : ${boost_ISYS_CPPFLAGS}] )
116134 AC_MSG_NOTICE ( [ boost_LDFLAGS : ${boost_LDFLAGS}] ) ] ,
117135 [ AC_MSG_ERROR ( [ Boost 1.57.0 or later is required but was not found.] ) ] ) ] )
118136
137+ AS_CASE ( [ ${enable_isystem}] ,[ yes] ,
138+ [ AC_SUBST ( [ boost_BUILD_CPPFLAGS] , [ ${boost_ISYS_CPPFLAGS}] ) ] ,
139+ [ AC_SUBST ( [ boost_BUILD_CPPFLAGS] , [ ${boost_CPPFLAGS}] ) ] )
140+
141+ AC_MSG_NOTICE ( [ boost_BUILD_CPPFLAGS : ${boost_BUILD_CPPFLAGS}] )
142+
119143AS_CASE ( [ ${with_tests}] , [ yes] ,
120144 [ AX_BOOST_UNIT_TEST_FRAMEWORK
121145 AC_SUBST ( [ boost_unit_test_framework_LIBS] , [ ${BOOST_UNIT_TEST_FRAMEWORK_LIB}] )
@@ -124,20 +148,52 @@ AS_CASE([${with_tests}], [yes],
124148
125149# Require zmq of at least version 4.2.0 and output ${zmq_CPPFLAGS/LIBS/PKG}.
126150# ------------------------------------------------------------------------------
127- PKG_CHECK_MODULES([ zmq] , [ libzmq >= 4.2.0] )
151+ PKG_CHECK_MODULES([ zmq] , [ libzmq >= 4.2.0] ,
152+ [ zmq_INCLUDEDIR="`$PKG_CONFIG --variable=includedir "libzmq >= 4.2.0" 2>/dev/null`"
153+ zmq_OTHER_CFLAGS="`$PKG_CONFIG --cflags-only-other "libzmq >= 4.2.0" 2>/dev/null`"] ,
154+ [ zmq_INCLUDEDIR=""
155+ zmq_OTHER_CFLAGS=""] )
128156AC_SUBST ( [ zmq_PKG] , [ 'libzmq >= 4.2.0'] )
129157AC_SUBST ( [ zmq_CPPFLAGS] , [ ${zmq_CFLAGS}] )
158+ AS_IF ( [ test x${zmq_INCLUDEDIR} != "x"] ,
159+ [ AC_SUBST ( [ zmq_ISYS_CPPFLAGS] , [ "-isystem${zmq_INCLUDEDIR} ${zmq_OTHER_CFLAGS}"] ) ] ,
160+ [ AC_SUBST ( [ zmq_ISYS_CPPFLAGS] , [ ${zmq_OTHER_CFLAGS}] ) ] )
130161AC_MSG_NOTICE ( [ zmq_CPPFLAGS : ${zmq_CPPFLAGS}] )
162+ AC_MSG_NOTICE ( [ zmq_ISYS_CPPFLAGS : ${zmq_ISYS_CPPFLAGS}] )
163+ AC_MSG_NOTICE ( [ zmq_OTHER_CFLAGS : ${zmq_OTHER_CFLAGS}] )
164+ AC_MSG_NOTICE ( [ zmq_INCLUDEDIR : ${zmq_INCLUDEDIR}] )
131165AC_MSG_NOTICE ( [ zmq_LIBS : ${zmq_LIBS}] )
132166
167+ AS_CASE ( [ ${enable_isystem}] ,[ yes] ,
168+ [ AC_SUBST ( [ zmq_BUILD_CPPFLAGS] , [ ${zmq_ISYS_CPPFLAGS}] ) ] ,
169+ [ AC_SUBST ( [ zmq_BUILD_CPPFLAGS] , [ ${zmq_CPPFLAGS}] ) ] )
170+
171+ AC_MSG_NOTICE ( [ zmq_BUILD_CPPFLAGS : ${zmq_BUILD_CPPFLAGS}] )
172+
133173# Require bitcoin of at least version 3.4.0 and output ${bitcoin_CPPFLAGS/LIBS/PKG}.
134174# ------------------------------------------------------------------------------
135- PKG_CHECK_MODULES([ bitcoin] , [ libbitcoin >= 3.4.0] )
175+ PKG_CHECK_MODULES([ bitcoin] , [ libbitcoin >= 3.4.0] ,
176+ [ bitcoin_INCLUDEDIR="`$PKG_CONFIG --variable=includedir "libbitcoin >= 3.4.0" 2>/dev/null`"
177+ bitcoin_OTHER_CFLAGS="`$PKG_CONFIG --cflags-only-other "libbitcoin >= 3.4.0" 2>/dev/null`"] ,
178+ [ bitcoin_INCLUDEDIR=""
179+ bitcoin_OTHER_CFLAGS=""] )
136180AC_SUBST ( [ bitcoin_PKG] , [ 'libbitcoin >= 3.4.0'] )
137181AC_SUBST ( [ bitcoin_CPPFLAGS] , [ ${bitcoin_CFLAGS}] )
182+ AS_IF ( [ test x${bitcoin_INCLUDEDIR} != "x"] ,
183+ [ AC_SUBST ( [ bitcoin_ISYS_CPPFLAGS] , [ "-isystem${bitcoin_INCLUDEDIR} ${bitcoin_OTHER_CFLAGS}"] ) ] ,
184+ [ AC_SUBST ( [ bitcoin_ISYS_CPPFLAGS] , [ ${bitcoin_OTHER_CFLAGS}] ) ] )
138185AC_MSG_NOTICE ( [ bitcoin_CPPFLAGS : ${bitcoin_CPPFLAGS}] )
186+ AC_MSG_NOTICE ( [ bitcoin_ISYS_CPPFLAGS : ${bitcoin_ISYS_CPPFLAGS}] )
187+ AC_MSG_NOTICE ( [ bitcoin_OTHER_CFLAGS : ${bitcoin_OTHER_CFLAGS}] )
188+ AC_MSG_NOTICE ( [ bitcoin_INCLUDEDIR : ${bitcoin_INCLUDEDIR}] )
139189AC_MSG_NOTICE ( [ bitcoin_LIBS : ${bitcoin_LIBS}] )
140190
191+ AS_CASE ( [ ${enable_isystem}] ,[ yes] ,
192+ [ AC_SUBST ( [ bitcoin_BUILD_CPPFLAGS] , [ ${bitcoin_ISYS_CPPFLAGS}] ) ] ,
193+ [ AC_SUBST ( [ bitcoin_BUILD_CPPFLAGS] , [ ${bitcoin_CPPFLAGS}] ) ] )
194+
195+ AC_MSG_NOTICE ( [ bitcoin_BUILD_CPPFLAGS : ${bitcoin_BUILD_CPPFLAGS}] )
196+
141197
142198# Set flags.
143199# ==============================================================================
@@ -153,12 +209,24 @@ AS_CASE([${CC}], [*],
153209 [ AX_CHECK_COMPILE_FLAG ( [ -Wall] ,
154210 [ CFLAGS="$CFLAGS -Wall"] ) ] )
155211
212+ # Warn on all stuff.
213+ # ------------------------------------------------------------------------------
214+ AS_CASE ( [ ${CC}] , [ *] ,
215+ [ AX_CHECK_COMPILE_FLAG ( [ -Wall] ,
216+ [ CXXFLAGS="$CXXFLAGS -Wall"] ) ] )
217+
156218# Warn on extra stuff.
157219# ------------------------------------------------------------------------------
158220AS_CASE ( [ ${CC}] , [ *] ,
159221 [ AX_CHECK_COMPILE_FLAG ( [ -Wextra] ,
160222 [ CFLAGS="$CFLAGS -Wextra"] ) ] )
161223
224+ # Warn on extra stuff.
225+ # ------------------------------------------------------------------------------
226+ AS_CASE ( [ ${CC}] , [ *] ,
227+ [ AX_CHECK_COMPILE_FLAG ( [ -Wextra] ,
228+ [ CXXFLAGS="$CXXFLAGS -Wextra"] ) ] )
229+
162230# Be really annoying.
163231# ------------------------------------------------------------------------------
164232AS_CASE ( [ ${CC}] , [ *] ,
@@ -167,6 +235,26 @@ AS_CASE([${CC}], [*],
167235 [ AX_CHECK_COMPILE_FLAG ( [ -pedantic] ,
168236 [ CFLAGS="$CFLAGS -pedantic"] ) ] ) ] )
169237
238+ # Be really annoying.
239+ # ------------------------------------------------------------------------------
240+ AS_CASE ( [ ${CC}] , [ *] ,
241+ [ AX_CHECK_COMPILE_FLAG ( [ -Wpedantic] ,
242+ [ CXXFLAGS="$CXXFLAGS -Wpedantic"] ,
243+ [ AX_CHECK_COMPILE_FLAG ( [ -pedantic] ,
244+ [ CXXFLAGS="$CXXFLAGS -pedantic"] ) ] ) ] )
245+
246+ # Disallow warning on style order of declarations.
247+ # ------------------------------------------------------------------------------
248+ AS_CASE ( [ ${CC}] , [ *] ,
249+ [ AX_CHECK_COMPILE_FLAG ( [ -Wno-reorder] ,
250+ [ CXXFLAGS="$CXXFLAGS -Wno-reorder"] ) ] )
251+
252+ # Suppress warning for incomplete field initialization.
253+ # ------------------------------------------------------------------------------
254+ AS_CASE ( [ ${CC}] , [ *] ,
255+ [ AX_CHECK_COMPILE_FLAG ( [ -Wno-missing-field-initializers] ,
256+ [ CXXFLAGS="$CXXFLAGS -Wno-missing-field-initializers"] ) ] )
257+
170258# Conform to style.
171259# ------------------------------------------------------------------------------
172260AS_CASE ( [ ${CC}] , [ *] ,
@@ -179,12 +267,6 @@ AS_CASE([${CC}], [*clang*],
179267 [ AX_CHECK_COMPILE_FLAG ( [ -Wno-mismatched-tags] ,
180268 [ CXXFLAGS="$CXXFLAGS -Wno-mismatched-tags"] ) ] )
181269
182- # Clean up boost 1.55 headers. Enabled in gcc only.
183- # ------------------------------------------------------------------------------
184- AS_CASE ( [ ${CC}] , [ *gcc*] ,
185- [ AX_CHECK_COMPILE_FLAG ( [ -Wno-deprecated-declarations] ,
186- [ CXXFLAGS="$CXXFLAGS -Wno-deprecated-declarations"] ) ] )
187-
188270# Protect stack.
189271# ------------------------------------------------------------------------------
190272AS_CASE ( [ ${CC}] , [ *] ,
@@ -197,12 +279,6 @@ AS_CASE([${CC}], [*],
197279 [ AX_CHECK_LINK_FLAG ( [ -fstack-protector-all] ,
198280 [ LDFLAGS="$LDFLAGS -fstack-protector-all"] ) ] )
199281
200- # Hide internal functions from external libs. Enabled in gcc only.
201- # ------------------------------------------------------------------------------
202- AS_CASE ( [ ${CC}] , [ *gcc*] ,
203- [ AX_CHECK_COMPILE_FLAG ( [ -fvisibility-hidden] ,
204- [ CXXFLAGS="$CXXFLAGS -fvisibility-hidden"] ) ] )
205-
206282# Hide inlines from external libs. Enabled in gcc only.
207283# ------------------------------------------------------------------------------
208284AS_CASE ( [ ${CC}] , [ *gcc*] ,
0 commit comments