@@ -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,12 +148,28 @@ AS_CASE([${with_tests}], [yes],
124148
125149# Require bitcoin of at least version 3.4.0 and output ${bitcoin_CPPFLAGS/LIBS/PKG}.
126150# ------------------------------------------------------------------------------
127- PKG_CHECK_MODULES([ bitcoin] , [ libbitcoin >= 3.4.0] )
151+ PKG_CHECK_MODULES([ bitcoin] , [ libbitcoin >= 3.4.0] ,
152+ [ bitcoin_INCLUDEDIR="`$PKG_CONFIG --variable=includedir "libbitcoin >= 3.4.0" 2>/dev/null`"
153+ bitcoin_OTHER_CFLAGS="`$PKG_CONFIG --cflags-only-other "libbitcoin >= 3.4.0" 2>/dev/null`"] ,
154+ [ bitcoin_INCLUDEDIR=""
155+ bitcoin_OTHER_CFLAGS=""] )
128156AC_SUBST ( [ bitcoin_PKG] , [ 'libbitcoin >= 3.4.0'] )
129157AC_SUBST ( [ bitcoin_CPPFLAGS] , [ ${bitcoin_CFLAGS}] )
158+ AS_IF ( [ test x${bitcoin_INCLUDEDIR} != "x"] ,
159+ [ AC_SUBST ( [ bitcoin_ISYS_CPPFLAGS] , [ "-isystem${bitcoin_INCLUDEDIR} ${bitcoin_OTHER_CFLAGS}"] ) ] ,
160+ [ AC_SUBST ( [ bitcoin_ISYS_CPPFLAGS] , [ ${bitcoin_OTHER_CFLAGS}] ) ] )
130161AC_MSG_NOTICE ( [ bitcoin_CPPFLAGS : ${bitcoin_CPPFLAGS}] )
162+ AC_MSG_NOTICE ( [ bitcoin_ISYS_CPPFLAGS : ${bitcoin_ISYS_CPPFLAGS}] )
163+ AC_MSG_NOTICE ( [ bitcoin_OTHER_CFLAGS : ${bitcoin_OTHER_CFLAGS}] )
164+ AC_MSG_NOTICE ( [ bitcoin_INCLUDEDIR : ${bitcoin_INCLUDEDIR}] )
131165AC_MSG_NOTICE ( [ bitcoin_LIBS : ${bitcoin_LIBS}] )
132166
167+ AS_CASE ( [ ${enable_isystem}] ,[ yes] ,
168+ [ AC_SUBST ( [ bitcoin_BUILD_CPPFLAGS] , [ ${bitcoin_ISYS_CPPFLAGS}] ) ] ,
169+ [ AC_SUBST ( [ bitcoin_BUILD_CPPFLAGS] , [ ${bitcoin_CPPFLAGS}] ) ] )
170+
171+ AC_MSG_NOTICE ( [ bitcoin_BUILD_CPPFLAGS : ${bitcoin_BUILD_CPPFLAGS}] )
172+
133173
134174# Set flags.
135175# ==============================================================================
@@ -145,12 +185,24 @@ AS_CASE([${CC}], [*],
145185 [ AX_CHECK_COMPILE_FLAG ( [ -Wall] ,
146186 [ CFLAGS="$CFLAGS -Wall"] ) ] )
147187
188+ # Warn on all stuff.
189+ # ------------------------------------------------------------------------------
190+ AS_CASE ( [ ${CC}] , [ *] ,
191+ [ AX_CHECK_COMPILE_FLAG ( [ -Wall] ,
192+ [ CXXFLAGS="$CXXFLAGS -Wall"] ) ] )
193+
148194# Warn on extra stuff.
149195# ------------------------------------------------------------------------------
150196AS_CASE ( [ ${CC}] , [ *] ,
151197 [ AX_CHECK_COMPILE_FLAG ( [ -Wextra] ,
152198 [ CFLAGS="$CFLAGS -Wextra"] ) ] )
153199
200+ # Warn on extra stuff.
201+ # ------------------------------------------------------------------------------
202+ AS_CASE ( [ ${CC}] , [ *] ,
203+ [ AX_CHECK_COMPILE_FLAG ( [ -Wextra] ,
204+ [ CXXFLAGS="$CXXFLAGS -Wextra"] ) ] )
205+
154206# Be really annoying.
155207# ------------------------------------------------------------------------------
156208AS_CASE ( [ ${CC}] , [ *] ,
@@ -159,6 +211,26 @@ AS_CASE([${CC}], [*],
159211 [ AX_CHECK_COMPILE_FLAG ( [ -pedantic] ,
160212 [ CFLAGS="$CFLAGS -pedantic"] ) ] ) ] )
161213
214+ # Be really annoying.
215+ # ------------------------------------------------------------------------------
216+ AS_CASE ( [ ${CC}] , [ *] ,
217+ [ AX_CHECK_COMPILE_FLAG ( [ -Wpedantic] ,
218+ [ CXXFLAGS="$CXXFLAGS -Wpedantic"] ,
219+ [ AX_CHECK_COMPILE_FLAG ( [ -pedantic] ,
220+ [ CXXFLAGS="$CXXFLAGS -pedantic"] ) ] ) ] )
221+
222+ # Disallow warning on style order of declarations.
223+ # ------------------------------------------------------------------------------
224+ AS_CASE ( [ ${CC}] , [ *] ,
225+ [ AX_CHECK_COMPILE_FLAG ( [ -Wno-reorder] ,
226+ [ CXXFLAGS="$CXXFLAGS -Wno-reorder"] ) ] )
227+
228+ # Suppress warning for incomplete field initialization.
229+ # ------------------------------------------------------------------------------
230+ AS_CASE ( [ ${CC}] , [ *] ,
231+ [ AX_CHECK_COMPILE_FLAG ( [ -Wno-missing-field-initializers] ,
232+ [ CXXFLAGS="$CXXFLAGS -Wno-missing-field-initializers"] ) ] )
233+
162234# Conform to style.
163235# ------------------------------------------------------------------------------
164236AS_CASE ( [ ${CC}] , [ *] ,
@@ -183,12 +255,6 @@ AS_CASE([${CC}], [*],
183255 [ AX_CHECK_LINK_FLAG ( [ -fstack-protector-all] ,
184256 [ LDFLAGS="$LDFLAGS -fstack-protector-all"] ) ] )
185257
186- # Hide internal functions from external libs. Enabled in gcc only.
187- # ------------------------------------------------------------------------------
188- AS_CASE ( [ ${CC}] , [ *gcc*] ,
189- [ AX_CHECK_COMPILE_FLAG ( [ -fvisibility-hidden] ,
190- [ CXXFLAGS="$CXXFLAGS -fvisibility-hidden"] ) ] )
191-
192258# Hide inlines from external libs. Enabled in gcc only.
193259# ------------------------------------------------------------------------------
194260AS_CASE ( [ ${CC}] , [ *gcc*] ,
0 commit comments