Merge #9911: Wshadow: various gcc fixes
[bitcoinplatinum.git] / src / Makefile.am
blobe8d22313dca33d8ac6adff107e72f8cfd53325be
1 # Copyright (c) 2013-2016 The Bitcoin Core developers
2 # Distributed under the MIT software license, see the accompanying
3 # file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 DIST_SUBDIRS = secp256k1 univalue
7 AM_LDFLAGS = $(PTHREAD_CFLAGS) $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS)
8 AM_CXXFLAGS = $(HARDENED_CXXFLAGS) $(ERROR_CXXFLAGS)
9 AM_CPPFLAGS = $(HARDENED_CPPFLAGS)
10 EXTRA_LIBRARIES =
12 if EMBEDDED_UNIVALUE
13 LIBUNIVALUE = univalue/libunivalue.la
15 $(LIBUNIVALUE): $(wildcard univalue/lib/*) $(wildcard univalue/include/*)
16         $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F)
17 else
18 LIBUNIVALUE = $(UNIVALUE_LIBS)
19 endif
21 BITCOIN_CONFIG_INCLUDES=-I$(builddir)/config
22 BITCOIN_INCLUDES=-I$(builddir) -I$(builddir)/obj $(BDB_CPPFLAGS) $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) $(CRYPTO_CFLAGS) $(SSL_CFLAGS)
24 BITCOIN_INCLUDES += -I$(srcdir)/secp256k1/include
25 BITCOIN_INCLUDES += $(UNIVALUE_CFLAGS)
27 LIBBITCOIN_SERVER=libbitcoin_server.a
28 LIBBITCOIN_COMMON=libbitcoin_common.a
29 LIBBITCOIN_CONSENSUS=libbitcoin_consensus.a
30 LIBBITCOIN_CLI=libbitcoin_cli.a
31 LIBBITCOIN_UTIL=libbitcoin_util.a
32 LIBBITCOIN_CRYPTO=crypto/libbitcoin_crypto.a
33 LIBBITCOINQT=qt/libbitcoinqt.a
34 LIBSECP256K1=secp256k1/libsecp256k1.la
36 if ENABLE_ZMQ
37 LIBBITCOIN_ZMQ=libbitcoin_zmq.a
38 endif
39 if BUILD_BITCOIN_LIBS
40 LIBBITCOINCONSENSUS=libbitcoinconsensus.la
41 endif
42 if ENABLE_WALLET
43 LIBBITCOIN_WALLET=libbitcoin_wallet.a
44 endif
46 $(LIBSECP256K1): $(wildcard secp256k1/src/*) $(wildcard secp256k1/include/*)
47         $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F)
49 # Make is not made aware of per-object dependencies to avoid limiting building parallelization
50 # But to build the less dependent modules first, we manually select their order here:
51 EXTRA_LIBRARIES += \
52   $(LIBBITCOIN_CRYPTO) \
53   $(LIBBITCOIN_UTIL) \
54   $(LIBBITCOIN_COMMON) \
55   $(LIBBITCOIN_CONSENSUS) \
56   $(LIBBITCOIN_SERVER) \
57   $(LIBBITCOIN_CLI) \
58   $(LIBBITCOIN_WALLET) \
59   $(LIBBITCOIN_ZMQ)
61 lib_LTLIBRARIES = $(LIBBITCOINCONSENSUS)
63 bin_PROGRAMS =
64 noinst_PROGRAMS =
65 TESTS =
66 BENCHMARKS =
68 if BUILD_BITCOIND
69   bin_PROGRAMS += bitcoind
70 endif
72 if BUILD_BITCOIN_UTILS
73   bin_PROGRAMS += bitcoin-cli bitcoin-tx
74 endif
76 .PHONY: FORCE check-symbols check-security
77 # bitcoin core #
78 BITCOIN_CORE_H = \
79   addrdb.h \
80   addrman.h \
81   base58.h \
82   bloom.h \
83   blockencodings.h \
84   chain.h \
85   chainparams.h \
86   chainparamsbase.h \
87   chainparamsseeds.h \
88   checkpoints.h \
89   checkqueue.h \
90   clientversion.h \
91   coins.h \
92   compat.h \
93   compat/byteswap.h \
94   compat/endian.h \
95   compat/sanity.h \
96   compressor.h \
97   consensus/consensus.h \
98   core_io.h \
99   core_memusage.h \
100   cuckoocache.h \
101   httprpc.h \
102   httpserver.h \
103   indirectmap.h \
104   init.h \
105   key.h \
106   keystore.h \
107   dbwrapper.h \
108   limitedmap.h \
109   memusage.h \
110   merkleblock.h \
111   miner.h \
112   net.h \
113   net_processing.h \
114   netaddress.h \
115   netbase.h \
116   netmessagemaker.h \
117   noui.h \
118   policy/fees.h \
119   policy/policy.h \
120   policy/rbf.h \
121   pow.h \
122   protocol.h \
123   random.h \
124   reverselock.h \
125   rpc/client.h \
126   rpc/protocol.h \
127   rpc/server.h \
128   rpc/register.h \
129   scheduler.h \
130   script/sigcache.h \
131   script/sign.h \
132   script/standard.h \
133   script/ismine.h \
134   streams.h \
135   support/allocators/secure.h \
136   support/allocators/zeroafterfree.h \
137   support/cleanse.h \
138   support/events.h \
139   support/lockedpool.h \
140   sync.h \
141   threadsafety.h \
142   threadinterrupt.h \
143   timedata.h \
144   torcontrol.h \
145   txdb.h \
146   txmempool.h \
147   ui_interface.h \
148   undo.h \
149   util.h \
150   utilmoneystr.h \
151   utiltime.h \
152   validation.h \
153   validationinterface.h \
154   versionbits.h \
155   wallet/coincontrol.h \
156   wallet/crypter.h \
157   wallet/db.h \
158   wallet/rpcwallet.h \
159   wallet/wallet.h \
160   wallet/walletdb.h \
161   warnings.h \
162   zmq/zmqabstractnotifier.h \
163   zmq/zmqconfig.h\
164   zmq/zmqnotificationinterface.h \
165   zmq/zmqpublishnotifier.h
168 obj/build.h: FORCE
169         @$(MKDIR_P) $(builddir)/obj
170         @$(top_srcdir)/share/genbuild.sh $(abs_top_builddir)/src/obj/build.h \
171           $(abs_top_srcdir)
172 libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h
174 # server: shared between bitcoind and bitcoin-qt
175 libbitcoin_server_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(MINIUPNPC_CPPFLAGS) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS)
176 libbitcoin_server_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
177 libbitcoin_server_a_SOURCES = \
178   addrman.cpp \
179   addrdb.cpp \
180   bloom.cpp \
181   blockencodings.cpp \
182   chain.cpp \
183   checkpoints.cpp \
184   httprpc.cpp \
185   httpserver.cpp \
186   init.cpp \
187   dbwrapper.cpp \
188   merkleblock.cpp \
189   miner.cpp \
190   net.cpp \
191   net_processing.cpp \
192   noui.cpp \
193   policy/fees.cpp \
194   policy/policy.cpp \
195   pow.cpp \
196   rest.cpp \
197   rpc/blockchain.cpp \
198   rpc/mining.cpp \
199   rpc/misc.cpp \
200   rpc/net.cpp \
201   rpc/rawtransaction.cpp \
202   rpc/server.cpp \
203   script/sigcache.cpp \
204   script/ismine.cpp \
205   timedata.cpp \
206   torcontrol.cpp \
207   txdb.cpp \
208   txmempool.cpp \
209   ui_interface.cpp \
210   validation.cpp \
211   validationinterface.cpp \
212   versionbits.cpp \
213   $(BITCOIN_CORE_H)
215 if ENABLE_ZMQ
216 libbitcoin_zmq_a_CPPFLAGS = $(BITCOIN_INCLUDES) $(ZMQ_CFLAGS)
217 libbitcoin_zmq_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
218 libbitcoin_zmq_a_SOURCES = \
219   zmq/zmqabstractnotifier.cpp \
220   zmq/zmqnotificationinterface.cpp \
221   zmq/zmqpublishnotifier.cpp
222 endif
225 # wallet: shared between bitcoind and bitcoin-qt, but only linked
226 # when wallet enabled
227 libbitcoin_wallet_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
228 libbitcoin_wallet_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
229 libbitcoin_wallet_a_SOURCES = \
230   wallet/crypter.cpp \
231   wallet/db.cpp \
232   wallet/rpcdump.cpp \
233   wallet/rpcwallet.cpp \
234   wallet/wallet.cpp \
235   wallet/walletdb.cpp \
236   policy/rbf.cpp \
237   $(BITCOIN_CORE_H)
239 # crypto primitives library
240 crypto_libbitcoin_crypto_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_CONFIG_INCLUDES)
241 crypto_libbitcoin_crypto_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
242 crypto_libbitcoin_crypto_a_SOURCES = \
243   crypto/aes.cpp \
244   crypto/aes.h \
245   crypto/common.h \
246   crypto/hmac_sha256.cpp \
247   crypto/hmac_sha256.h \
248   crypto/hmac_sha512.cpp \
249   crypto/hmac_sha512.h \
250   crypto/ripemd160.cpp \
251   crypto/ripemd160.h \
252   crypto/sha1.cpp \
253   crypto/sha1.h \
254   crypto/sha256.cpp \
255   crypto/sha256.h \
256   crypto/sha512.cpp \
257   crypto/sha512.h
259 # consensus: shared between all executables that validate any consensus rules.
260 libbitcoin_consensus_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
261 libbitcoin_consensus_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
262 libbitcoin_consensus_a_SOURCES = \
263   amount.h \
264   arith_uint256.cpp \
265   arith_uint256.h \
266   consensus/merkle.cpp \
267   consensus/merkle.h \
268   consensus/params.h \
269   consensus/validation.h \
270   hash.cpp \
271   hash.h \
272   prevector.h \
273   primitives/block.cpp \
274   primitives/block.h \
275   primitives/transaction.cpp \
276   primitives/transaction.h \
277   pubkey.cpp \
278   pubkey.h \
279   script/bitcoinconsensus.cpp \
280   script/interpreter.cpp \
281   script/interpreter.h \
282   script/script.cpp \
283   script/script.h \
284   script/script_error.cpp \
285   script/script_error.h \
286   serialize.h \
287   tinyformat.h \
288   uint256.cpp \
289   uint256.h \
290   utilstrencodings.cpp \
291   utilstrencodings.h \
292   version.h
294 # common: shared between bitcoind, and bitcoin-qt and non-server tools
295 libbitcoin_common_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
296 libbitcoin_common_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
297 libbitcoin_common_a_SOURCES = \
298   amount.cpp \
299   base58.cpp \
300   chainparams.cpp \
301   coins.cpp \
302   compressor.cpp \
303   core_read.cpp \
304   core_write.cpp \
305   key.cpp \
306   keystore.cpp \
307   netaddress.cpp \
308   netbase.cpp \
309   protocol.cpp \
310   scheduler.cpp \
311   script/sign.cpp \
312   script/standard.cpp \
313   warnings.cpp \
314   $(BITCOIN_CORE_H)
316 # util: shared between all executables.
317 # This library *must* be included to make sure that the glibc
318 # backward-compatibility objects and their sanity checks are linked.
319 libbitcoin_util_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
320 libbitcoin_util_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
321 libbitcoin_util_a_SOURCES = \
322   support/lockedpool.cpp \
323   chainparamsbase.cpp \
324   clientversion.cpp \
325   compat/glibc_sanity.cpp \
326   compat/glibcxx_sanity.cpp \
327   compat/strnlen.cpp \
328   random.cpp \
329   rpc/protocol.cpp \
330   support/cleanse.cpp \
331   sync.cpp \
332   threadinterrupt.cpp \
333   util.cpp \
334   utilmoneystr.cpp \
335   utilstrencodings.cpp \
336   utiltime.cpp \
337   $(BITCOIN_CORE_H)
339 if GLIBC_BACK_COMPAT
340 libbitcoin_util_a_SOURCES += compat/glibc_compat.cpp
341 endif
343 # cli: shared between bitcoin-cli and bitcoin-qt
344 libbitcoin_cli_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
345 libbitcoin_cli_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
346 libbitcoin_cli_a_SOURCES = \
347   rpc/client.cpp \
348   $(BITCOIN_CORE_H)
350 nodist_libbitcoin_util_a_SOURCES = $(srcdir)/obj/build.h
353 # bitcoind binary #
354 bitcoind_SOURCES = bitcoind.cpp
355 bitcoind_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
356 bitcoind_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
357 bitcoind_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
359 if TARGET_WINDOWS
360 bitcoind_SOURCES += bitcoind-res.rc
361 endif
363 bitcoind_LDADD = \
364   $(LIBBITCOIN_SERVER) \
365   $(LIBBITCOIN_COMMON) \
366   $(LIBUNIVALUE) \
367   $(LIBBITCOIN_UTIL) \
368   $(LIBBITCOIN_WALLET) \
369   $(LIBBITCOIN_ZMQ) \
370   $(LIBBITCOIN_CONSENSUS) \
371   $(LIBBITCOIN_CRYPTO) \
372   $(LIBLEVELDB) \
373   $(LIBMEMENV) \
374   $(LIBSECP256K1)
376 bitcoind_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(ZMQ_LIBS)
378 # bitcoin-cli binary #
379 bitcoin_cli_SOURCES = bitcoin-cli.cpp
380 bitcoin_cli_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS)
381 bitcoin_cli_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
382 bitcoin_cli_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
384 if TARGET_WINDOWS
385 bitcoin_cli_SOURCES += bitcoin-cli-res.rc
386 endif
388 bitcoin_cli_LDADD = \
389   $(LIBBITCOIN_CLI) \
390   $(LIBUNIVALUE) \
391   $(LIBBITCOIN_UTIL) \
392   $(LIBBITCOIN_CRYPTO)
394 bitcoin_cli_LDADD += $(BOOST_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(EVENT_LIBS)
397 # bitcoin-tx binary #
398 bitcoin_tx_SOURCES = bitcoin-tx.cpp
399 bitcoin_tx_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
400 bitcoin_tx_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
401 bitcoin_tx_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
403 if TARGET_WINDOWS
404 bitcoin_tx_SOURCES += bitcoin-tx-res.rc
405 endif
407 bitcoin_tx_LDADD = \
408   $(LIBUNIVALUE) \
409   $(LIBBITCOIN_COMMON) \
410   $(LIBBITCOIN_UTIL) \
411   $(LIBBITCOIN_CONSENSUS) \
412   $(LIBBITCOIN_CRYPTO) \
413   $(LIBSECP256K1)
415 bitcoin_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS)
418 # bitcoinconsensus library #
419 if BUILD_BITCOIN_LIBS
420 include_HEADERS = script/bitcoinconsensus.h
421 libbitcoinconsensus_la_SOURCES = $(crypto_libbitcoin_crypto_a_SOURCES) $(libbitcoin_consensus_a_SOURCES)
423 if GLIBC_BACK_COMPAT
424   libbitcoinconsensus_la_SOURCES += compat/glibc_compat.cpp
425 endif
427 libbitcoinconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS)
428 libbitcoinconsensus_la_LIBADD = $(LIBSECP256K1)
429 libbitcoinconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL
430 libbitcoinconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
432 endif
435 CTAES_DIST =  crypto/ctaes/bench.c
436 CTAES_DIST += crypto/ctaes/ctaes.c
437 CTAES_DIST += crypto/ctaes/ctaes.h
438 CTAES_DIST += crypto/ctaes/README.md
439 CTAES_DIST += crypto/ctaes/test.c
441 CLEANFILES = $(EXTRA_LIBRARIES)
443 CLEANFILES += *.gcda *.gcno
444 CLEANFILES += compat/*.gcda compat/*.gcno
445 CLEANFILES += consensus/*.gcda consensus/*.gcno
446 CLEANFILES += crypto/*.gcda crypto/*.gcno
447 CLEANFILES += policy/*.gcda policy/*.gcno
448 CLEANFILES += primitives/*.gcda primitives/*.gcno
449 CLEANFILES += script/*.gcda script/*.gcno
450 CLEANFILES += support/*.gcda support/*.gcno
451 CLEANFILES += univalue/*.gcda univalue/*.gcno
452 CLEANFILES += wallet/*.gcda wallet/*.gcno
453 CLEANFILES += wallet/test/*.gcda wallet/test/*.gcno
454 CLEANFILES += zmq/*.gcda zmq/*.gcno
456 DISTCLEANFILES = obj/build.h
458 EXTRA_DIST = $(CTAES_DIST)
460 clean-local:
461         -$(MAKE) -C secp256k1 clean
462         -$(MAKE) -C univalue clean
463         -rm -f leveldb/*/*.gcda leveldb/*/*.gcno leveldb/helpers/memenv/*.gcda leveldb/helpers/memenv/*.gcno
464         -rm -f config.h
465         -rm -rf test/__pycache__
467 .rc.o:
468         @test -f $(WINDRES)
469         ## FIXME: How to get the appropriate modulename_CPPFLAGS in here?
470         $(AM_V_GEN) $(WINDRES) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CPPFLAGS) -DWINDRES_PREPROC -i $< -o $@
472 .mm.o:
473         $(AM_V_CXX) $(OBJCXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
474           $(CPPFLAGS) $(AM_CXXFLAGS) $(QT_INCLUDES) $(AM_CXXFLAGS) $(PIE_FLAGS) $(CXXFLAGS) -c -o $@ $<
476 check-symbols: $(bin_PROGRAMS)
477 if GLIBC_BACK_COMPAT
478         @echo "Checking glibc back compat..."
479         $(AM_V_at) READELF=$(READELF) CPPFILT=$(CPPFILT) $(top_srcdir)/contrib/devtools/symbol-check.py < $(bin_PROGRAMS)
480 endif
482 check-security: $(bin_PROGRAMS)
483 if HARDEN
484         @echo "Checking binary security..."
485         $(AM_V_at) READELF=$(READELF) OBJDUMP=$(OBJDUMP) $(top_srcdir)/contrib/devtools/security-check.py < $(bin_PROGRAMS)
486 endif
488 %.pb.cc %.pb.h: %.proto
489         @test -f $(PROTOC)
490         $(AM_V_GEN) $(PROTOC) --cpp_out=$(@D) --proto_path=$(<D) $<
492 if EMBEDDED_LEVELDB
493 include Makefile.leveldb.include
494 endif
496 if ENABLE_TESTS
497 include Makefile.test.include
498 endif
500 if ENABLE_BENCH
501 include Makefile.bench.include
502 endif
504 if ENABLE_QT
505 include Makefile.qt.include
506 endif
508 if ENABLE_QT_TESTS
509 include Makefile.qttest.include
510 endif