Skip to content

Commit a682bc7

Browse files
committed
Merge pull request #3242
2041365 Bugfix: Use BOOST_CPPFLAGS when testing for boost sleep vs sleep_for (Luke Dashjr) e18e100 configure: Minor grammatical changes to be more clear (Luke Dashjr) a9dbcf0 configure: Change --with[out]-qt to --with[out]-gui and add --with[out]-cli and --with[out]-daemon to support more build configurations (Luke Dashjr) f472990 Bugfix: Correct captitalisation of Qt (Luke Dashjr) f930341 configure: Internal changes to make building bitcoind and bitcoin-cli optional (Luke Dashjr) 4a290b5 Cleanup LevelDB library dependencies (Luke Dashjr) 9b4e03b Bugfix: Undefine _FORTIFY_SOURCE before redefining it, to avoid warnings on compilers that define it by default (Luke Dashjr) 123e4f8 Bugfix: configure: Allow user-provided CXXFLAGS to override default optimisation, debug, and warning flags (Luke Dashjr)
2 parents 1ab310e + 2041365 commit a682bc7

File tree

4 files changed

+114
-48
lines changed

4 files changed

+114
-48
lines changed

configure.ac

Lines changed: 72 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ m4_include([pkg.m4])
2424
dnl faketime breaks configure and is only needed for make. Disable it here.
2525
unset FAKETIME
2626

27+
if test "x${CXXFLAGS+set}" = "xset"; then
28+
CXXFLAGS_overridden=yes
29+
else
30+
CXXFLAGS_overridden=no
31+
fi
32+
2733
dnl ==============================================================
2834
dnl Setup for automake
2935
dnl ==============================================================
@@ -92,7 +98,7 @@ AC_ARG_ENABLE([hardening],
9298

9399
AC_ARG_ENABLE([ccache],
94100
[AS_HELP_STRING([--enable-ccache],
95-
[enable building with ccache (default is yes if ccache is found)])],
101+
[use ccache for building (default is yes if ccache is found)])],
96102
[use_ccache=$enableval],
97103
[use_ccache=auto])
98104

@@ -134,7 +140,9 @@ PKG_PROG_PKG_CONFIG
134140
## TODO: Remove these hard-coded paths and flags. They are here for the sake of
135141
## compatibility with the legacy buildsystem.
136142
##
137-
CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter"
143+
if test "x$CXXFLAGS_overridden" = "xno"; then
144+
CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter"
145+
fi
138146
CPPFLAGS="$CPPFLAGS -DBOOST_SPIRIT_THREADSAFE -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS"
139147

140148
AC_LANG_PUSH([C++])
@@ -182,7 +190,9 @@ case $host in
182190

183191
CPPFLAGS="$CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -D__USE_MINGW_ANSI_STDIO"
184192
LEVELDB_TARGET_FLAGS="TARGET_OS=OS_WINDOWS_CROSSCOMPILE"
185-
CXXFLAGS="$CXXFLAGS -w"
193+
if test "x$CXXFLAGS_overridden" = "xno"; then
194+
CXXFLAGS="$CXXFLAGS -w"
195+
fi
186196
;;
187197
*darwin*)
188198
TARGET_OS=darwin
@@ -276,7 +286,12 @@ if test x$use_hardening != xno; then
276286
AX_CHECK_COMPILE_FLAG([-Wstack-protector],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wstack-protector"])
277287
AX_CHECK_COMPILE_FLAG([-fPIE],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fPIE"])
278288

279-
AX_CHECK_PREPROC_FLAG([-D_FORTIFY_SOURCE=2],[HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -D_FORTIFY_SOURCE=2"])
289+
AX_CHECK_PREPROC_FLAG([-D_FORTIFY_SOURCE=2],[
290+
AX_CHECK_PREPROC_FLAG([-U_FORTIFY_SOURCE],[
291+
HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -U_FORTIFY_SOURCE"
292+
])
293+
HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -D_FORTIFY_SOURCE=2"
294+
])
280295

281296
AX_CHECK_LINK_FLAG([[-Wl,--dynamicbase]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--dynamicbase"])
282297
AX_CHECK_LINK_FLAG([[-Wl,--nxcompat]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--nxcompat"])
@@ -313,6 +328,14 @@ AC_TRY_COMPILE([#include <sys/socket.h>],
313328
[ AC_MSG_RESULT(no)]
314329
)
315330

331+
LEVELDB_CPPFLAGS=
332+
LIBLEVELDB=
333+
LIBMEMENV=
334+
AM_CONDITIONAL([EMBEDDED_LEVELDB],[true])
335+
AC_SUBST(LEVELDB_CPPFLAGS)
336+
AC_SUBST(LIBLEVELDB)
337+
AC_SUBST(LIBMEMENV)
338+
316339
if test x$enable_wallet != xno; then
317340
dnl Check for libdb_cxx only if wallet enabled
318341
BITCOIN_FIND_BDB48
@@ -423,6 +446,18 @@ if test x$boost_sleep != xyes; then
423446
AC_MSG_ERROR(No working boost sleep implementation found. If on ubuntu 13.10 with libboost1.54-all-dev remove libboost.1.54-all-dev and use libboost1.53-all-dev)
424447
fi
425448

449+
AC_ARG_WITH([cli],
450+
[AS_HELP_STRING([--with-cli],
451+
[with CLI (default is yes)])],
452+
[build_bitcoin_cli=$withval],
453+
[build_bitcoin_cli=yes])
454+
455+
AC_ARG_WITH([daemon],
456+
[AS_HELP_STRING([--with-daemon],
457+
[with daemon (default is yes)])],
458+
[build_bitcoind=$withval],
459+
[build_bitcoind=yes])
460+
426461
BITCOIN_QT_INIT
427462

428463
if test x$use_pkgconfig = xyes; then
@@ -459,13 +494,21 @@ fi
459494

460495
BITCOIN_QT_PATH_PROGS([PROTOC], [protoc],$protoc_bin_path)
461496

497+
AC_MSG_CHECKING([whether to build bitcoind])
498+
AM_CONDITIONAL([BUILD_BITCOIND], [test x$build_bitcoind = xyes])
499+
AC_MSG_RESULT($build_bitcoind)
500+
501+
AC_MSG_CHECKING([whether to build bitcoin-cli])
502+
AM_CONDITIONAL([BUILD_BITCOIN_CLI], [test x$build_bitcoin_cli = xyes])
503+
AC_MSG_RESULT($build_bitcoin_cli)
504+
462505
dnl sets $bitcoin_enable_qt, $bitcoin_enable_qt_test, $bitcoin_enable_qt_dbus
463506
BITCOIN_QT_CONFIGURE([$use_pkgconfig], [qt4])
464507

465508

466509
if test x$use_ipv6 = xyes; then
467510
dnl Check for ipv6 build requirements
468-
AC_MSG_CHECKING(for IPV6 build support)
511+
AC_MSG_CHECKING(for operating system IPv6 support)
469512
AC_TRY_LINK([
470513
#if defined(_WINDOWS)
471514
#include <winsock2.h>
@@ -480,18 +523,17 @@ if test x$use_ipv6 = xyes; then
480523
struct sockaddr_in6 addr;
481524
#endif
482525
int temp = socket(AF_INET6, SOCK_STREAM, 0);],
483-
[AC_MSG_RESULT(yes); have_ipv6=yes; AC_DEFINE(HAVE_IPV6, 1, [Define this symbol if you have ipv6 build support])],
526+
[AC_MSG_RESULT(yes); have_ipv6=yes; AC_DEFINE(HAVE_IPV6, 1, [Define this symbol if you have operating system IPv6 support])],
484527
[AC_MSG_RESULT(no)]; have_ipv6=no)
485528
fi
486529
AC_LANG_POP
487530

488531
if test "x$use_ccache" != "xno"; then
489-
AC_MSG_CHECKING(if ccache should be enabled)
532+
AC_MSG_CHECKING(if ccache should be used)
490533
if test x$CCACHE = x; then
491534
if test "x$use_ccache" = "xyes"; then
492535
AC_MSG_ERROR([ccache not found.]);
493536
else
494-
AC_MSG_NOTICE([ccache not found. Falling back to default CC])
495537
use_ccache=no
496538
fi
497539
else
@@ -513,40 +555,40 @@ else
513555
fi
514556

515557
dnl enable ipv6 support
516-
AC_MSG_CHECKING([if ipv6 should be enabled])
558+
AC_MSG_CHECKING([whether to build with support for IPv6])
517559
if test x$have_ipv6 = xno; then
518560
if test x$use_ipv6 = xyes; then
519-
AC_MSG_ERROR("ipv6 requested but cannot be built. use --disable-ipv6")
561+
AC_MSG_ERROR([IPv6 requested, but cannot be built. use --disable-ipv6])
520562
fi
521563
AC_MSG_RESULT(no)
522564
else
523565
if test x$use_ipv6 = xyes; then
524566
AC_MSG_RESULT(yes)
525-
AC_DEFINE([USE_IPV6],[1],[Define if ipv6 support should be compiled in])
567+
AC_DEFINE([USE_IPV6],[1],[Define if IPv6 support should be compiled in])
526568
else
527569
AC_MSG_RESULT(no)
528570
fi
529571
fi
530572

531573
dnl enable upnp support
532-
AC_MSG_CHECKING([if upnp should be enabled])
574+
AC_MSG_CHECKING([whether to build with support for UPnP])
533575
if test x$have_miniupnpc = xno; then
534576
if test x$use_upnp = xyes; then
535-
AC_MSG_ERROR("upnp requested but cannot be built. use --without-miniupnpc")
577+
AC_MSG_ERROR("UPnP requested but cannot be built. use --without-miniupnpc")
536578
fi
537579
AC_MSG_RESULT(no)
538580
else
539581
if test x$use_upnp != xno; then
540582
AC_MSG_RESULT(yes)
541-
AC_MSG_CHECKING([if upnp should be on by default])
583+
AC_MSG_CHECKING([whether to build with UPnP enabled by default])
542584
use_upnp=yes
543585
upnp_setting=0
544586
if test x$use_upnp_default != xno; then
545587
use_upnp_default=yes
546588
upnp_setting=1
547589
fi
548590
AC_MSG_RESULT($use_upnp_default)
549-
AC_DEFINE_UNQUOTED([USE_UPNP],[$upnp_setting],[Define to 1 for upnp runtime support])
591+
AC_DEFINE_UNQUOTED([USE_UPNP],[$upnp_setting],[UPnP support not compiled if undefined, otherwise value (0 or 1) determines default state])
550592
if test x$TARGET_OS = xwindows; then
551593
CPPFLAGS="$CPPFLAGS -DSTATICLIB"
552594
fi
@@ -559,14 +601,14 @@ dnl these are only used when qt is enabled
559601
if test x$bitcoin_enable_qt != xno; then
560602
BUILD_QT=qt
561603
dnl enable dbus support
562-
AC_MSG_CHECKING([if dbus should be enabled])
604+
AC_MSG_CHECKING([whether to build GUI with support for D-Bus])
563605
if test x$bitcoin_enable_qt_dbus != xno; then
564606
AC_DEFINE([USE_DBUS],[1],[Define if dbus support should be compiled in])
565607
fi
566608
AC_MSG_RESULT($bitcoin_enable_qt_dbus)
567609

568610
dnl enable qr support
569-
AC_MSG_CHECKING([if qr should be enabled])
611+
AC_MSG_CHECKING([whether to build GUI with support for QR codes])
570612
if test x$have_qrencode = xno; then
571613
if test x$use_qr == xyes; then
572614
AC_MSG_ERROR("QR support requested but cannot be built. use --without-qrencode")
@@ -586,16 +628,25 @@ if test x$bitcoin_enable_qt != xno; then
586628
AC_MSG_WARN("xgettext is required to update qt translations")
587629
fi
588630

589-
if test x$use_tests = xyes; then
631+
AC_MSG_CHECKING([whether to build test_bitcoin-qt])
632+
if test x$use_tests$bitcoin_enable_qt_test = xyesyes; then
633+
AC_MSG_RESULT([yes])
590634
BUILD_TEST_QT="test"
591-
if test x$bitcoin_enable_qt_test != xyes; then
592-
AC_MSG_ERROR("QT Test lib not found. Use --disable-tests or --without-qt.")
593-
fi
635+
else
636+
AC_MSG_RESULT([no])
594637
fi
595638
fi
596639

640+
AC_MSG_CHECKING([whether to build test_bitcoin])
597641
if test x$use_tests = xyes; then
642+
AC_MSG_RESULT([yes])
598643
BUILD_TEST="test"
644+
else
645+
AC_MSG_RESULT([no])
646+
fi
647+
648+
if test "x$use_tests$build_bitcoind$use_qt" = "xnonono"; then
649+
AC_MSG_ERROR([No targets! Please specify at least one of: --enable-cli --enable-daemon --enable-gui or --enable-tests])
599650
fi
600651

601652
AM_CONDITIONAL([TARGET_DARWIN], [test x$TARGET_OS = xdarwin])

src/Makefile.am

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
include Makefile.include
22

3-
AM_CPPFLAGS += -I$(top_srcdir)/src/leveldb/helpers/memenv \
4-
-I$(builddir)
3+
AM_CPPFLAGS += -I$(builddir)
54

65
noinst_LIBRARIES = \
76
libbitcoin_server.a \
@@ -11,7 +10,15 @@ if ENABLE_WALLET
1110
noinst_LIBRARIES += libbitcoin_wallet.a
1211
endif
1312

14-
bin_PROGRAMS = bitcoind bitcoin-cli
13+
bin_PROGRAMS =
14+
15+
if BUILD_BITCOIND
16+
bin_PROGRAMS += bitcoind
17+
endif
18+
19+
if BUILD_BITCOIN_CLI
20+
bin_PROGRAMS += bitcoin-cli
21+
endif
1522

1623
SUBDIRS = . $(BUILD_QT) $(BUILD_TEST)
1724
DIST_SUBDIRS = . qt test
@@ -140,8 +147,8 @@ bitcoind_LDADD = \
140147
libbitcoin_server.a \
141148
libbitcoin_cli.a \
142149
libbitcoin_common.a \
143-
leveldb/libleveldb.a \
144-
leveldb/libmemenv.a
150+
$(LIBLEVELDB) \
151+
$(LIBMEMENV)
145152
if ENABLE_WALLET
146153
bitcoind_LDADD += libbitcoin_wallet.a
147154
endif
@@ -167,6 +174,7 @@ if TARGET_WINDOWS
167174
bitcoin_cli_SOURCES += bitcoin-cli-res.rc
168175
endif
169176

177+
# NOTE: This dependency is not strictly necessary, but without it make may try to build both in parallel, which breaks the LevelDB build system in a race
170178
leveldb/libleveldb.a: leveldb/libmemenv.a
171179

172180
leveldb/%.a:

src/Makefile.include

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
1+
if EMBEDDED_LEVELDB
2+
LEVELDB_CPPFLAGS += -I$(top_srcdir)/src/leveldb/include
3+
LEVELDB_CPPFLAGS += -I$(top_srcdir)/src/leveldb/helpers/memenv
4+
LIBLEVELDB += $(top_builddir)/src/leveldb/libleveldb.a
5+
LIBMEMENV += $(top_builddir)/src/leveldb/libmemenv.a
6+
endif
7+
18
AM_CPPFLAGS = $(INCLUDES) \
29
-I$(top_builddir)/src/obj \
3-
-I$(top_srcdir)/src/leveldb/include \
410
$(BDB_CPPFLAGS) \
5-
$(BOOST_INCLUDES)
11+
$(BOOST_CPPFLAGS) $(BOOST_INCLUDES)
12+
AM_CPPFLAGS += $(LEVELDB_CPPFLAGS)
613
AM_LDFLAGS = $(PTHREAD_CFLAGS)
714

815
LIBBITCOIN_SERVER=$(top_builddir)/src/libbitcoin_server.a
916
LIBBITCOIN_WALLET=$(top_builddir)/src/libbitcoin_wallet.a
1017
LIBBITCOIN_COMMON=$(top_builddir)/src/libbitcoin_common.a
1118
LIBBITCOIN_CLI=$(top_builddir)/src/libbitcoin_cli.a
12-
LIBLEVELDB=$(top_builddir)/src/leveldb/libleveldb.a
13-
LIBMEMENV=$(top_builddir)/src/leveldb/libmemenv.a
1419
LIBBITCOINQT=$(top_builddir)/src/qt/libbitcoinqt.a
1520

1621
$(LIBBITCOIN):
1722
$(MAKE) -C $(top_builddir)/src $(@F)
1823

24+
if EMBEDDED_LEVELDB
1925
$(LIBLEVELDB) $(LIBMEMENV):
2026
$(MAKE) -C $(top_builddir)/src leveldb/$(@F)
27+
endif
2128

2229
$(LIBBITCOINQT):
2330
$(MAKE) -C $(top_builddir)/src/qt $(@F)

0 commit comments

Comments
 (0)