From 4791b99e2dea0593775a8c75f62c8406d340191e Mon Sep 17 00:00:00 2001 From: Cory Fields Date: Mon, 9 Jun 2014 15:17:27 -0400 Subject: [PATCH] crypto: create a separate lib for crypto functions This lib has no dependencies on other bitcoin functionality. Attempting to use bitcoin headers will result in a failure to compile. --- src/Makefile.am | 23 +++++++++++++++-------- src/Makefile.qt.include | 2 +- src/Makefile.qttest.include | 2 +- src/Makefile.test.include | 2 +- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index c666fb7662..3948ca0780 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -23,7 +23,8 @@ BITCOIN_INCLUDES=-I$(builddir) -I$(builddir)/obj $(BITCOIN_CONFIG_INCLUDES) $(BO noinst_LIBRARIES = \ libbitcoin_server.a \ libbitcoin_common.a \ - libbitcoin_cli.a + libbitcoin_cli.a \ + crypto/libbitcoin_crypto.a if ENABLE_WALLET BITCOIN_INCLUDES += $(BDB_CPPFLAGS) noinst_LIBRARIES += libbitcoin_wallet.a @@ -76,10 +77,6 @@ BITCOIN_CORE_H = \ rpcserver.h \ script.h \ serialize.h \ - crypto/common.h \ - crypto/sha2.h \ - crypto/sha1.h \ - crypto/ripemd160.h \ sync.h \ threadsafety.h \ tinyformat.h \ @@ -145,6 +142,16 @@ libbitcoin_wallet_a_SOURCES = \ walletdb.cpp \ $(BITCOIN_CORE_H) +crypto_libbitcoin_crypto_a_CPPFLAGS = $(BITCOIN_CONFIG_INCLUDES) +crypto_libbitcoin_crypto_a_SOURCES = \ + crypto/sha1.cpp \ + crypto/sha2.cpp \ + crypto/ripemd160.cpp \ + crypto/common.h \ + crypto/sha2.h \ + crypto/sha1.h \ + crypto/ripemd160.h + libbitcoin_common_a_CPPFLAGS = $(BITCOIN_INCLUDES) libbitcoin_common_a_SOURCES = \ base58.cpp \ @@ -157,9 +164,6 @@ libbitcoin_common_a_SOURCES = \ protocol.cpp \ rpcprotocol.cpp \ script.cpp \ - crypto/sha1.cpp \ - crypto/sha2.cpp \ - crypto/ripemd160.cpp \ sync.cpp \ util.cpp \ version.cpp \ @@ -183,6 +187,7 @@ nodist_libbitcoin_common_a_SOURCES = $(srcdir)/obj/build.h bitcoind_LDADD = \ libbitcoin_server.a \ libbitcoin_common.a \ + crypto/libbitcoin_crypto.a \ $(LIBLEVELDB) \ $(LIBMEMENV) if ENABLE_WALLET @@ -202,6 +207,7 @@ bitcoind_CPPFLAGS = $(BITCOIN_INCLUDES) bitcoin_cli_LDADD = \ libbitcoin_cli.a \ libbitcoin_common.a \ + crypto/libbitcoin_crypto.a \ $(BOOST_LIBS) bitcoin_cli_SOURCES = bitcoin-cli.cpp bitcoin_cli_CPPFLAGS = $(BITCOIN_INCLUDES) @@ -238,6 +244,7 @@ LIBBITCOIN_SERVER=libbitcoin_server.a LIBBITCOIN_WALLET=libbitcoin_wallet.a LIBBITCOIN_COMMON=libbitcoin_common.a LIBBITCOIN_CLI=libbitcoin_cli.a +LIBBITCOIN_CRYPTO=crypto/libbitcoin_crypto.a LIBBITCOINQT=qt/libbitcoinqt.a if ENABLE_TESTS diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index 647434e1ef..091138dc38 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -355,7 +355,7 @@ qt_bitcoin_qt_LDADD = qt/libbitcoinqt.a $(LIBBITCOIN_SERVER) if ENABLE_WALLET qt_bitcoin_qt_LDADD += $(LIBBITCOIN_WALLET) endif -qt_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBLEVELDB) $(LIBMEMENV) \ +qt_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_CRYPTO) $(LIBLEVELDB) $(LIBMEMENV) \ $(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) qt_bitcoin_qt_LDFLAGS = $(QT_LDFLAGS) diff --git a/src/Makefile.qttest.include b/src/Makefile.qttest.include index e0b49d0240..0aa31a406d 100644 --- a/src/Makefile.qttest.include +++ b/src/Makefile.qttest.include @@ -30,7 +30,7 @@ qt_test_test_bitcoin_qt_LDADD = $(LIBBITCOINQT) $(LIBBITCOIN_SERVER) if ENABLE_WALLET qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_WALLET) endif -qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBLEVELDB) \ +qt_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_CRYPTO) $(LIBLEVELDB) \ $(LIBMEMENV) $(BOOST_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) $(QT_LIBS) \ $(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) qt_test_test_bitcoin_qt_LDFLAGS = $(QT_LDFLAGS) diff --git a/src/Makefile.test.include b/src/Makefile.test.include index 02fb3ba5fe..64f997f4b5 100644 --- a/src/Makefile.test.include +++ b/src/Makefile.test.include @@ -63,7 +63,7 @@ endif test_test_bitcoin_SOURCES = $(BITCOIN_TESTS) $(JSON_TEST_FILES) $(RAW_TEST_FILES) test_test_bitcoin_CPPFLAGS = $(BITCOIN_INCLUDES) -I$(builddir)/test/ $(TESTDEFS) -test_test_bitcoin_LDADD = $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBLEVELDB) $(LIBMEMENV) \ +test_test_bitcoin_LDADD = $(LIBBITCOIN_SERVER) $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_CRYPTO) $(LIBLEVELDB) $(LIBMEMENV) \ $(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) if ENABLE_WALLET test_test_bitcoin_LDADD += $(LIBBITCOIN_WALLET)