Merge #11747: Fix: Open files read only if requested
[bitcoinplatinum.git] / src / Makefile.am
blob4b65774fc6f583e42a26a43687ec8777c845aa19
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_INCLUDES=-I$(builddir) $(BDB_CPPFLAGS) $(BOOST_CPPFLAGS) $(LEVELDB_CPPFLAGS) $(CRYPTO_CFLAGS) $(SSL_CFLAGS)
23 BITCOIN_INCLUDES += -I$(srcdir)/secp256k1/include
24 BITCOIN_INCLUDES += $(UNIVALUE_CFLAGS)
26 LIBBITCOIN_SERVER=libbitcoin_server.a
27 LIBBITCOIN_COMMON=libbitcoin_common.a
28 LIBBITCOIN_CONSENSUS=libbitcoin_consensus.a
29 LIBBITCOIN_CLI=libbitcoin_cli.a
30 LIBBITCOIN_UTIL=libbitcoin_util.a
31 LIBBITCOIN_CRYPTO=crypto/libbitcoin_crypto.a
32 LIBBITCOINQT=qt/libbitcoinqt.a
33 LIBSECP256K1=secp256k1/libsecp256k1.la
35 if ENABLE_ZMQ
36 LIBBITCOIN_ZMQ=libbitcoin_zmq.a
37 endif
38 if BUILD_BITCOIN_LIBS
39 LIBBITCOINCONSENSUS=libbitcoinconsensus.la
40 endif
41 if ENABLE_WALLET
42 LIBBITCOIN_WALLET=libbitcoin_wallet.a
43 endif
45 $(LIBSECP256K1): $(wildcard secp256k1/src/*) $(wildcard secp256k1/include/*)
46         $(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) -C $(@D) $(@F)
48 # Make is not made aware of per-object dependencies to avoid limiting building parallelization
49 # But to build the less dependent modules first, we manually select their order here:
50 EXTRA_LIBRARIES += \
51   $(LIBBITCOIN_CRYPTO) \
52   $(LIBBITCOIN_UTIL) \
53   $(LIBBITCOIN_COMMON) \
54   $(LIBBITCOIN_CONSENSUS) \
55   $(LIBBITCOIN_SERVER) \
56   $(LIBBITCOIN_CLI) \
57   $(LIBBITCOIN_WALLET) \
58   $(LIBBITCOIN_ZMQ)
60 lib_LTLIBRARIES = $(LIBBITCOINCONSENSUS)
62 bin_PROGRAMS =
63 noinst_PROGRAMS =
64 TESTS =
65 BENCHMARKS =
67 if BUILD_BITCOIND
68   bin_PROGRAMS += bitcoind
69 endif
71 if BUILD_BITCOIN_UTILS
72   bin_PROGRAMS += bitcoin-cli bitcoin-tx
73 endif
75 .PHONY: FORCE check-symbols check-security
76 # bitcoin core #
77 BITCOIN_CORE_H = \
78   addrdb.h \
79   addrman.h \
80   base58.h \
81   bech32.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   consensus/tx_verify.h \
99   core_io.h \
100   core_memusage.h \
101   cuckoocache.h \
102   fs.h \
103   httprpc.h \
104   httpserver.h \
105   indirectmap.h \
106   init.h \
107   key.h \
108   keystore.h \
109   dbwrapper.h \
110   limitedmap.h \
111   memusage.h \
112   merkleblock.h \
113   miner.h \
114   net.h \
115   net_processing.h \
116   netaddress.h \
117   netbase.h \
118   netmessagemaker.h \
119   noui.h \
120   policy/feerate.h \
121   policy/fees.h \
122   policy/policy.h \
123   policy/rbf.h \
124   pow.h \
125   protocol.h \
126   random.h \
127   reverse_iterator.h \
128   reverselock.h \
129   rpc/blockchain.h \
130   rpc/client.h \
131   rpc/mining.h \
132   rpc/protocol.h \
133   rpc/safemode.h \
134   rpc/server.h \
135   rpc/register.h \
136   scheduler.h \
137   script/sigcache.h \
138   script/sign.h \
139   script/standard.h \
140   script/ismine.h \
141   streams.h \
142   support/allocators/secure.h \
143   support/allocators/zeroafterfree.h \
144   support/cleanse.h \
145   support/events.h \
146   support/lockedpool.h \
147   sync.h \
148   threadsafety.h \
149   threadinterrupt.h \
150   timedata.h \
151   torcontrol.h \
152   txdb.h \
153   txmempool.h \
154   ui_interface.h \
155   undo.h \
156   util.h \
157   utilmoneystr.h \
158   utiltime.h \
159   validation.h \
160   validationinterface.h \
161   versionbits.h \
162   wallet/coincontrol.h \
163   wallet/crypter.h \
164   wallet/db.h \
165   wallet/feebumper.h \
166   wallet/fees.h \
167   wallet/init.h \
168   wallet/rpcwallet.h \
169   wallet/wallet.h \
170   wallet/walletdb.h \
171   wallet/walletutil.h \
172   warnings.h \
173   zmq/zmqabstractnotifier.h \
174   zmq/zmqconfig.h\
175   zmq/zmqnotificationinterface.h \
176   zmq/zmqpublishnotifier.h
179 obj/build.h: FORCE
180         @$(MKDIR_P) $(builddir)/obj
181         @$(top_srcdir)/share/genbuild.sh "$(abs_top_builddir)/src/obj/build.h" \
182           "$(abs_top_srcdir)"
183 libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h
185 # server: shared between bitcoind and bitcoin-qt
186 libbitcoin_server_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(MINIUPNPC_CPPFLAGS) $(EVENT_CFLAGS) $(EVENT_PTHREADS_CFLAGS)
187 libbitcoin_server_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
188 libbitcoin_server_a_SOURCES = \
189   addrdb.cpp \
190   addrman.cpp \
191   bloom.cpp \
192   blockencodings.cpp \
193   chain.cpp \
194   checkpoints.cpp \
195   consensus/tx_verify.cpp \
196   httprpc.cpp \
197   httpserver.cpp \
198   init.cpp \
199   dbwrapper.cpp \
200   merkleblock.cpp \
201   miner.cpp \
202   net.cpp \
203   net_processing.cpp \
204   noui.cpp \
205   policy/fees.cpp \
206   policy/policy.cpp \
207   policy/rbf.cpp \
208   pow.cpp \
209   rest.cpp \
210   rpc/blockchain.cpp \
211   rpc/mining.cpp \
212   rpc/misc.cpp \
213   rpc/net.cpp \
214   rpc/rawtransaction.cpp \
215   rpc/safemode.cpp \
216   rpc/server.cpp \
217   script/sigcache.cpp \
218   script/ismine.cpp \
219   timedata.cpp \
220   torcontrol.cpp \
221   txdb.cpp \
222   txmempool.cpp \
223   ui_interface.cpp \
224   validation.cpp \
225   validationinterface.cpp \
226   versionbits.cpp \
227   $(BITCOIN_CORE_H)
229 if ENABLE_ZMQ
230 libbitcoin_zmq_a_CPPFLAGS = $(BITCOIN_INCLUDES) $(ZMQ_CFLAGS)
231 libbitcoin_zmq_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
232 libbitcoin_zmq_a_SOURCES = \
233   zmq/zmqabstractnotifier.cpp \
234   zmq/zmqnotificationinterface.cpp \
235   zmq/zmqpublishnotifier.cpp
236 endif
239 # wallet: shared between bitcoind and bitcoin-qt, but only linked
240 # when wallet enabled
241 libbitcoin_wallet_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
242 libbitcoin_wallet_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
243 libbitcoin_wallet_a_SOURCES = \
244   wallet/crypter.cpp \
245   wallet/db.cpp \
246   wallet/feebumper.cpp \
247   wallet/fees.cpp \
248   wallet/init.cpp \
249   wallet/rpcdump.cpp \
250   wallet/rpcwallet.cpp \
251   wallet/wallet.cpp \
252   wallet/walletdb.cpp \
253   wallet/walletutil.cpp \
254   $(BITCOIN_CORE_H)
256 # crypto primitives library
257 crypto_libbitcoin_crypto_a_CPPFLAGS = $(AM_CPPFLAGS)
258 crypto_libbitcoin_crypto_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
259 crypto_libbitcoin_crypto_a_SOURCES = \
260   crypto/aes.cpp \
261   crypto/aes.h \
262   crypto/chacha20.h \
263   crypto/chacha20.cpp \
264   crypto/common.h \
265   crypto/hmac_sha256.cpp \
266   crypto/hmac_sha256.h \
267   crypto/hmac_sha512.cpp \
268   crypto/hmac_sha512.h \
269   crypto/ripemd160.cpp \
270   crypto/ripemd160.h \
271   crypto/sha1.cpp \
272   crypto/sha1.h \
273   crypto/sha256.cpp \
274   crypto/sha256.h \
275   crypto/sha512.cpp \
276   crypto/sha512.h
278 if USE_ASM
279 crypto_libbitcoin_crypto_a_SOURCES += crypto/sha256_sse4.cpp
280 endif
282 # consensus: shared between all executables that validate any consensus rules.
283 libbitcoin_consensus_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
284 libbitcoin_consensus_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
285 libbitcoin_consensus_a_SOURCES = \
286   amount.h \
287   arith_uint256.cpp \
288   arith_uint256.h \
289   consensus/merkle.cpp \
290   consensus/merkle.h \
291   consensus/params.h \
292   consensus/validation.h \
293   hash.cpp \
294   hash.h \
295   prevector.h \
296   primitives/block.cpp \
297   primitives/block.h \
298   primitives/transaction.cpp \
299   primitives/transaction.h \
300   pubkey.cpp \
301   pubkey.h \
302   script/bitcoinconsensus.cpp \
303   script/interpreter.cpp \
304   script/interpreter.h \
305   script/script.cpp \
306   script/script.h \
307   script/script_error.cpp \
308   script/script_error.h \
309   serialize.h \
310   tinyformat.h \
311   uint256.cpp \
312   uint256.h \
313   utilstrencodings.cpp \
314   utilstrencodings.h \
315   version.h
317 # common: shared between bitcoind, and bitcoin-qt and non-server tools
318 libbitcoin_common_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
319 libbitcoin_common_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
320 libbitcoin_common_a_SOURCES = \
321   base58.cpp \
322   bech32.cpp \
323   chainparams.cpp \
324   coins.cpp \
325   compressor.cpp \
326   core_read.cpp \
327   core_write.cpp \
328   key.cpp \
329   keystore.cpp \
330   netaddress.cpp \
331   netbase.cpp \
332   policy/feerate.cpp \
333   protocol.cpp \
334   scheduler.cpp \
335   script/sign.cpp \
336   script/standard.cpp \
337   warnings.cpp \
338   $(BITCOIN_CORE_H)
340 # util: shared between all executables.
341 # This library *must* be included to make sure that the glibc
342 # backward-compatibility objects and their sanity checks are linked.
343 libbitcoin_util_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
344 libbitcoin_util_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
345 libbitcoin_util_a_SOURCES = \
346   support/lockedpool.cpp \
347   chainparamsbase.cpp \
348   clientversion.cpp \
349   compat/glibc_sanity.cpp \
350   compat/glibcxx_sanity.cpp \
351   compat/strnlen.cpp \
352   fs.cpp \
353   random.cpp \
354   rpc/protocol.cpp \
355   support/cleanse.cpp \
356   sync.cpp \
357   threadinterrupt.cpp \
358   util.cpp \
359   utilmoneystr.cpp \
360   utilstrencodings.cpp \
361   utiltime.cpp \
362   $(BITCOIN_CORE_H)
364 if GLIBC_BACK_COMPAT
365 libbitcoin_util_a_SOURCES += compat/glibc_compat.cpp
366 endif
368 # cli: shared between bitcoin-cli and bitcoin-qt
369 libbitcoin_cli_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
370 libbitcoin_cli_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
371 libbitcoin_cli_a_SOURCES = \
372   rpc/client.cpp \
373   $(BITCOIN_CORE_H)
375 nodist_libbitcoin_util_a_SOURCES = $(srcdir)/obj/build.h
378 # bitcoind binary #
379 bitcoind_SOURCES = bitcoind.cpp
380 bitcoind_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
381 bitcoind_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
382 bitcoind_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
384 if TARGET_WINDOWS
385 bitcoind_SOURCES += bitcoind-res.rc
386 endif
388 bitcoind_LDADD = \
389   $(LIBBITCOIN_SERVER) \
390   $(LIBBITCOIN_COMMON) \
391   $(LIBUNIVALUE) \
392   $(LIBBITCOIN_UTIL) \
393   $(LIBBITCOIN_WALLET) \
394   $(LIBBITCOIN_ZMQ) \
395   $(LIBBITCOIN_CONSENSUS) \
396   $(LIBBITCOIN_CRYPTO) \
397   $(LIBLEVELDB) \
398   $(LIBLEVELDB_SSE42) \
399   $(LIBMEMENV) \
400   $(LIBSECP256K1)
402 bitcoind_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(ZMQ_LIBS)
404 # bitcoin-cli binary #
405 bitcoin_cli_SOURCES = bitcoin-cli.cpp
406 bitcoin_cli_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(EVENT_CFLAGS)
407 bitcoin_cli_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
408 bitcoin_cli_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
410 if TARGET_WINDOWS
411 bitcoin_cli_SOURCES += bitcoin-cli-res.rc
412 endif
414 bitcoin_cli_LDADD = \
415   $(LIBBITCOIN_CLI) \
416   $(LIBUNIVALUE) \
417   $(LIBBITCOIN_UTIL) \
418   $(LIBBITCOIN_CRYPTO)
420 bitcoin_cli_LDADD += $(BOOST_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(EVENT_LIBS)
423 # bitcoin-tx binary #
424 bitcoin_tx_SOURCES = bitcoin-tx.cpp
425 bitcoin_tx_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
426 bitcoin_tx_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
427 bitcoin_tx_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS)
429 if TARGET_WINDOWS
430 bitcoin_tx_SOURCES += bitcoin-tx-res.rc
431 endif
433 bitcoin_tx_LDADD = \
434   $(LIBUNIVALUE) \
435   $(LIBBITCOIN_COMMON) \
436   $(LIBBITCOIN_UTIL) \
437   $(LIBBITCOIN_CONSENSUS) \
438   $(LIBBITCOIN_CRYPTO) \
439   $(LIBSECP256K1)
441 bitcoin_tx_LDADD += $(BOOST_LIBS) $(CRYPTO_LIBS)
444 # bitcoinconsensus library #
445 if BUILD_BITCOIN_LIBS
446 include_HEADERS = script/bitcoinconsensus.h
447 libbitcoinconsensus_la_SOURCES = $(crypto_libbitcoin_crypto_a_SOURCES) $(libbitcoin_consensus_a_SOURCES)
449 if GLIBC_BACK_COMPAT
450   libbitcoinconsensus_la_SOURCES += compat/glibc_compat.cpp
451 endif
453 libbitcoinconsensus_la_LDFLAGS = $(AM_LDFLAGS) -no-undefined $(RELDFLAGS)
454 libbitcoinconsensus_la_LIBADD = $(LIBSECP256K1)
455 libbitcoinconsensus_la_CPPFLAGS = $(AM_CPPFLAGS) -I$(builddir)/obj -I$(srcdir)/secp256k1/include -DBUILD_BITCOIN_INTERNAL
456 libbitcoinconsensus_la_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
458 endif
461 CTAES_DIST =  crypto/ctaes/bench.c
462 CTAES_DIST += crypto/ctaes/ctaes.c
463 CTAES_DIST += crypto/ctaes/ctaes.h
464 CTAES_DIST += crypto/ctaes/README.md
465 CTAES_DIST += crypto/ctaes/test.c
467 CLEANFILES = $(EXTRA_LIBRARIES)
469 CLEANFILES += *.gcda *.gcno
470 CLEANFILES += compat/*.gcda compat/*.gcno
471 CLEANFILES += consensus/*.gcda consensus/*.gcno
472 CLEANFILES += crypto/*.gcda crypto/*.gcno
473 CLEANFILES += policy/*.gcda policy/*.gcno
474 CLEANFILES += primitives/*.gcda primitives/*.gcno
475 CLEANFILES += script/*.gcda script/*.gcno
476 CLEANFILES += support/*.gcda support/*.gcno
477 CLEANFILES += univalue/*.gcda univalue/*.gcno
478 CLEANFILES += wallet/*.gcda wallet/*.gcno
479 CLEANFILES += wallet/test/*.gcda wallet/test/*.gcno
480 CLEANFILES += zmq/*.gcda zmq/*.gcno
481 CLEANFILES += obj/build.h
483 EXTRA_DIST = $(CTAES_DIST)
486 config/bitcoin-config.h: config/stamp-h1
487         @$(MAKE) -C $(top_builddir) $(subdir)/$(@)
488 config/stamp-h1: $(top_srcdir)/$(subdir)/config/bitcoin-config.h.in $(top_builddir)/config.status
489         $(AM_V_at)$(MAKE) -C $(top_builddir) $(subdir)/$(@)
490 $(top_srcdir)/$(subdir)/config/bitcoin-config.h.in:  $(am__configure_deps)
491         $(AM_V_at)$(MAKE) -C $(top_srcdir) $(subdir)/config/bitcoin-config.h.in
493 clean-local:
494         -$(MAKE) -C secp256k1 clean
495         -$(MAKE) -C univalue clean
496         -rm -f leveldb/*/*.gcda leveldb/*/*.gcno leveldb/helpers/memenv/*.gcda leveldb/helpers/memenv/*.gcno
497         -rm -f config.h
498         -rm -rf test/__pycache__
500 .rc.o:
501         @test -f $(WINDRES)
502         ## FIXME: How to get the appropriate modulename_CPPFLAGS in here?
503         $(AM_V_GEN) $(WINDRES) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(CPPFLAGS) -DWINDRES_PREPROC -i $< -o $@
505 check-symbols: $(bin_PROGRAMS)
506 if GLIBC_BACK_COMPAT
507         @echo "Checking glibc back compat..."
508         $(AM_V_at) READELF=$(READELF) CPPFILT=$(CPPFILT) $(top_srcdir)/contrib/devtools/symbol-check.py < $(bin_PROGRAMS)
509 endif
511 check-security: $(bin_PROGRAMS)
512 if HARDEN
513         @echo "Checking binary security..."
514         $(AM_V_at) READELF=$(READELF) OBJDUMP=$(OBJDUMP) $(top_srcdir)/contrib/devtools/security-check.py < $(bin_PROGRAMS)
515 endif
517 %.pb.cc %.pb.h: %.proto
518         @test -f $(PROTOC)
519         $(AM_V_GEN) $(PROTOC) --cpp_out=$(@D) --proto_path=$(<D) $<
521 if EMBEDDED_LEVELDB
522 include Makefile.leveldb.include
523 endif
525 if ENABLE_TESTS
526 include Makefile.test.include
527 endif
529 if ENABLE_BENCH
530 include Makefile.bench.include
531 endif
533 if ENABLE_QT
534 include Makefile.qt.include
535 endif
537 if ENABLE_QT_TESTS
538 include Makefile.qttest.include
539 endif