diff --git a/.gitignore b/.gitignore index 277231769..3a3827fd0 100644 --- a/.gitignore +++ b/.gitignore @@ -21,13 +21,198 @@ *.app -# truckcoin stuff +# hyperstake stuff object_script.* .DS_Store -truckcoin-qt -truckcoin-qt.exe -truckcoind -truckcoind.exe +hyperstake-qt +hyperstake-qt.exe +hyperstaked +hyperstaked.exe qrc_bitcoin.cpp build/* +release/* +makefile.release +makefile.debug +makefile +Makefile +src/Makefile +HyperStake-qt.pro.user +autom4te.cache +aclocal.m4 +configure +ltmain.sh +src/.deps +src/qt/.deps +src/qt/.dirstamp +src/qt/bitcoin.moc +src/qt/bitcoinamountfield.moc +src/qt/moc_* +src/qt/overviewpage.moc +src/qt/rpcconsole.moc +Makefile.in +src/config/bitcoin-config.h +src/config/bitcoin-config.h.in +src/config/stamp-h1 +src/qt/forms/ui_* +config.log +config.status +libtool +src/test/.deps +src/test/data/base58_encode_decode.json.h +src/test/data/base58_keys_invalid.json.h +src/test/data/base58_keys_valid.json.h +src/test/data/script_invalid.json.h +src/test/data/script_valid.json.h +src/test/.dirstamp +src/test/test_bitcoin +setup.nsi +Info.plist +build-aux/compile +build-aux/config.guess +build-aux/config.sub +build-aux/depcomp +build-aux/install-sh +build-aux/missing +build-aux/test-driver +src/qt/moc_blockbrowser.cpp +src/qt/moc_calcdialog.cpp +src/qt/moc_charitydialog.cpp +src/qt/moc_qtipcserver.cpp +src/qt/test/.dirstamp +src/qt/test/moc_uritests.cpp +src/qt/test/test_bitcoin-qt +src/qt/test/.deps +src/qt/forms/ui_blockbrowser.h +src/qt/forms/ui_calcdialog.h +src/qt/forms/ui_charitydialog.h +moc_macnotificationhandler.cpp +hyperstake/hyperstake.xcodeproj +build-aux/m4/libtool.m4 +build-aux/m4/ltoptions.m4 +build-aux/m4/ltsugar.m4 +build-aux/m4/ltversion.m4 +build-aux/m4/lt~obsolete.m4 +moc_paymentserver.cpp +Hyperstake-Qt.dmg + +../log.0000000001 +log.0000000001 + +# Created by https://www.gitignore.io/api/osx,vim,clion + +### CLion ### +# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm +# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839 + +# ignore all .idea files +.idea + +# User-specific stuff: +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/dictionaries + +# Sensitive or high-churn files: +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.xml +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml + +# Gradle: +.idea/**/gradle.xml +.idea/**/libraries + +# CMake +cmake-build-debug/ + +# Mongo Explorer plugin: +.idea/**/mongoSettings.xml + +## File-based project format: +*.iws + +## Plugin-specific files: + +# IntelliJ +/out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# Ruby plugin and RubyMine +/.rakeTasks + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +### CLion Patch ### +# Comment Reason: https://github.com/joeblau/gitignore.io/issues/186#issuecomment-215987721 + +# *.iml +# modules.xml +# .idea/misc.xml +# *.ipr + +# Sonarlint plugin +.idea/sonarlint + +### OSX ### +*.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +### Vim ### +# swap +[._]*.s[a-v][a-z] +[._]*.sw[a-p] +[._]s[a-v][a-z] +[._]sw[a-p] +# session +Session.vim +# temporary +.netrwhist +*~ +# auto-generated tag files +tags + +# End of https://www.gitignore.io/api/osx,vim,clio + +# Eclipse Core +.project + +protobuf/ diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 000000000..ec33ee436 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,305 @@ +cmake_minimum_required(VERSION 3.9) +project(HyperStake) + +set(CMAKE_CXX_STANDARD 11) + +add_executable(HyperStake + src/config/bitcoin-config.h + src/json/json_spirit.h + src/json/json_spirit_error_position.h + src/json/json_spirit_reader.cpp + src/json/json_spirit_reader.h + src/json/json_spirit_reader_template.h + src/json/json_spirit_stream_reader.h + src/json/json_spirit_utils.h + src/json/json_spirit_value.cpp + src/json/json_spirit_value.h + src/json/json_spirit_writer.cpp + src/json/json_spirit_writer.h + src/json/json_spirit_writer_template.h + src/obj/build.h + src/qt/forms/ui_aboutdialog.h + src/qt/forms/ui_addressbookpage.h + src/qt/forms/ui_askpassphrasedialog.h + src/qt/forms/ui_bip38tooldialog.h + src/qt/forms/ui_blockbrowser.h + src/qt/forms/ui_calcdialog.h + src/qt/forms/ui_charitydialog.h + src/qt/forms/ui_coincontroldialog.h + src/qt/forms/ui_editaddressdialog.h + src/qt/forms/ui_optionsdialog.h + src/qt/forms/ui_overviewpage.h + src/qt/forms/ui_qrcodedialog.h + src/qt/forms/ui_rpcconsole.h + src/qt/forms/ui_sendcoinsdialog.h + src/qt/forms/ui_sendcoinsentry.h + src/qt/forms/ui_signverifymessagedialog.h + src/qt/forms/ui_transactiondescdialog.h + src/qt/test/moc_uritests.cpp + src/qt/test/test_main.cpp + src/qt/test/uritests.cpp + src/qt/test/uritests.h + src/qt/aboutdialog.cpp + src/qt/aboutdialog.h + src/qt/addressbookpage.cpp + src/qt/addressbookpage.h + src/qt/addresstablemodel.cpp + src/qt/addresstablemodel.h + src/qt/askpassphrasedialog.cpp + src/qt/askpassphrasedialog.h + src/qt/bip38tooldialog.cpp + src/qt/bip38tooldialog.h + src/qt/bitcoin.cpp + src/qt/bitcoinaddressvalidator.cpp + src/qt/bitcoinaddressvalidator.h + src/qt/bitcoinamountfield.cpp + src/qt/bitcoinamountfield.h + src/qt/bitcoingui.cpp + src/qt/bitcoingui.h + src/qt/bitcoinstrings.cpp + src/qt/bitcoinunits.cpp + src/qt/bitcoinunits.h + src/qt/blockbrowser.cpp + src/qt/blockbrowser.h + src/qt/calcdialog.cpp + src/qt/calcdialog.h + src/qt/charitydialog.cpp + src/qt/charitydialog.h + src/qt/clientmodel.cpp + src/qt/clientmodel.h + src/qt/coincontroldialog.cpp + src/qt/coincontroldialog.h + src/qt/coincontroltreewidget.cpp + src/qt/coincontroltreewidget.h + src/qt/csvmodelwriter.cpp + src/qt/csvmodelwriter.h + src/qt/editaddressdialog.cpp + src/qt/editaddressdialog.h + src/qt/guiconstants.h + src/qt/guiutil.cpp + src/qt/guiutil.h + src/qt/macdockiconhandler.h + src/qt/macnotificationhandler.h + src/qt/moc_aboutdialog.cpp + src/qt/moc_addressbookpage.cpp + src/qt/moc_addresstablemodel.cpp + src/qt/moc_askpassphrasedialog.cpp + src/qt/moc_bip38tooldialog.cpp + src/qt/moc_bitcoinaddressvalidator.cpp + src/qt/moc_bitcoinamountfield.cpp + src/qt/moc_bitcoingui.cpp + src/qt/moc_bitcoinunits.cpp + src/qt/moc_blockbrowser.cpp + src/qt/moc_calcdialog.cpp + src/qt/moc_charitydialog.cpp + src/qt/moc_clientmodel.cpp + src/qt/moc_coincontroldialog.cpp + src/qt/moc_coincontroltreewidget.cpp + src/qt/moc_csvmodelwriter.cpp + src/qt/moc_editaddressdialog.cpp + src/qt/moc_guiutil.cpp + src/qt/moc_macdockiconhandler.cpp + src/qt/moc_macnotificationhandler.cpp + src/qt/moc_monitoreddatamapper.cpp + src/qt/moc_notificator.cpp + src/qt/moc_optionsdialog.cpp + src/qt/moc_optionsmodel.cpp + src/qt/moc_overviewpage.cpp + src/qt/moc_paymentserver.cpp + src/qt/moc_qrcodedialog.cpp + src/qt/moc_qvalidatedlineedit.cpp + src/qt/moc_qvaluecombobox.cpp + src/qt/moc_rpcconsole.cpp + src/qt/moc_sendcoinsdialog.cpp + src/qt/moc_sendcoinsentry.cpp + src/qt/moc_signverifymessagedialog.cpp + src/qt/moc_transactiondesc.cpp + src/qt/moc_transactiondescdialog.cpp + src/qt/moc_transactionfilterproxy.cpp + src/qt/moc_transactiontablemodel.cpp + src/qt/moc_transactionview.cpp + src/qt/moc_walletmodel.cpp + src/qt/monitoreddatamapper.cpp + src/qt/monitoreddatamapper.h + src/qt/networkstyle.cpp + src/qt/networkstyle.h + src/qt/notificator.cpp + src/qt/notificator.h + src/qt/optionsdialog.cpp + src/qt/optionsdialog.h + src/qt/optionsmodel.cpp + src/qt/optionsmodel.h + src/qt/overviewpage.cpp + src/qt/overviewpage.h + src/qt/paymentserver.cpp + src/qt/paymentserver.h + src/qt/qrc_bitcoin.cpp + src/qt/qrcodedialog.cpp + src/qt/qrcodedialog.h + src/qt/qvalidatedlineedit.cpp + src/qt/qvalidatedlineedit.h + src/qt/qvaluecombobox.cpp + src/qt/qvaluecombobox.h + src/qt/rpcconsole.cpp + src/qt/rpcconsole.h + src/qt/scicon.cpp + src/qt/scicon.h + src/qt/sendcoinsdialog.cpp + src/qt/sendcoinsdialog.h + src/qt/sendcoinsentry.cpp + src/qt/sendcoinsentry.h + src/qt/signverifymessagedialog.cpp + src/qt/signverifymessagedialog.h + src/qt/transactiondesc.cpp + src/qt/transactiondesc.h + src/qt/transactiondescdialog.cpp + src/qt/transactiondescdialog.h + src/qt/transactionfilterproxy.cpp + src/qt/transactionfilterproxy.h + src/qt/transactionrecord.cpp + src/qt/transactionrecord.h + src/qt/transactiontablemodel.cpp + src/qt/transactiontablemodel.h + src/qt/transactionview.cpp + src/qt/transactionview.h + src/qt/walletmodel.cpp + src/qt/walletmodel.h + src/secp256k1/src/libsecp256k1-config.h + src/test/data/base58_encode_decode.json.h + src/test/data/base58_keys_invalid.json.h + src/test/data/base58_keys_valid.json.h + src/test/data/script_invalid.json.h + src/test/data/script_valid.json.h + src/test/accounting_tests.cpp + src/test/allocator_tests.cpp + src/test/base32_tests.cpp + src/test/base58_tests.cpp + src/test/base64_tests.cpp + src/test/bignum_tests.cpp + src/test/Checkpoints_tests.cpp + src/test/DoS_tests.cpp + src/test/getarg_tests.cpp + src/test/key_tests.cpp + src/test/miner_tests.cpp + src/test/mruset_tests.cpp + src/test/multisig_tests.cpp + src/test/netbase_tests.cpp + src/test/rpc_tests.cpp + src/test/script_P2SH_tests.cpp + src/test/script_tests.cpp + src/test/sigopcount_tests.cpp + src/test/test_bitcoin.cpp + src/test/transaction_tests.cpp + src/test/uint160_tests.cpp + src/test/uint256_tests.cpp + src/test/util_tests.cpp + src/test/voting_tests.cpp + src/test/wallet_tests.cpp + src/addrman.cpp + src/addrman.h + src/aes_helper.c + src/alert.cpp + src/alert.h + src/allocators.h + src/base58.h + src/bignum.h + src/bip38.cpp + src/bip38.h + src/bitcoind.cpp + src/bitcoinrpc.cpp + src/bitcoinrpc.h + src/blake.c + src/bloom.cpp + src/bloom.h + src/bmw.c + src/checkpoints.cpp + src/checkpoints.h + src/clientversion.cpp + src/clientversion.h + src/coincontrol.h + src/compat.h + src/crypter.cpp + src/crypter.h + src/cubehash.c + src/db.cpp + src/db.h + src/echo.c + src/groestl.c + src/hashblock.h + src/init.cpp + src/init.h + src/jh.c + src/keccak.c + src/kernel.cpp + src/kernel.h + src/key.cpp + src/key.h + src/keystore.cpp + src/keystore.h + src/luffa.c + src/main.cpp + src/main.h + src/mruset.h + src/net.cpp + src/net.h + src/netbase.cpp + src/netbase.h + src/noui.cpp + src/pbkdf2.cpp + src/pbkdf2.h + src/protocol.cpp + src/protocol.h + src/rpcblockchain.cpp + src/rpcdump.cpp + src/rpcmining.cpp + src/rpcnet.cpp + src/rpcrawtransaction.cpp + src/rpcwallet.cpp + src/script.cpp + src/script.h + src/scrypt.cpp + src/scrypt.h + src/scrypt_mine.h + src/serialize.h + src/shavite.c + src/simd.c + src/skein.c + src/sph_blake.h + src/sph_bmw.h + src/sph_cubehash.h + src/sph_echo.h + src/sph_groestl.h + src/sph_jh.h + src/sph_keccak.h + src/sph_luffa.h + src/sph_shavite.h + src/sph_simd.h + src/sph_skein.h + src/sph_types.h + src/sync.cpp + src/sync.h + src/tinyformat.h + src/ui_interface.h + src/uint256.h + src/util.cpp + src/util.h + src/version.cpp + src/version.h + src/voteobject.cpp + src/voteobject.h + src/voteproposal.cpp + src/voteproposal.h + src/voteproposalmanager.cpp + src/voteproposalmanager.h + src/qt/createproposaldialog.cpp + src/qt/createproposaldialog.h + src/qt/votingdialog.cpp + src/qt/votingdialog.h + src/qt/setvotesdialog.cpp + src/qt/setvotesdialog.h + src/votetally.cpp + src/votetally.h + src/wallet.cpp + src/wallet.h + src/walletdb.cpp + src/walletdb.h src/miner.h src/miner.cpp) diff --git a/HyperStake-qt-linux.pro b/HyperStake-qt-linux.pro deleted file mode 100644 index e98bb1287..000000000 --- a/HyperStake-qt-linux.pro +++ /dev/null @@ -1,406 +0,0 @@ -TEMPLATE = app -TARGET = HyperStake-qt -VERSION = 0.7.2 -INCLUDEPATH += src src/json src/qt -DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN __NO_SYSTEM_INCLUDES -CONFIG += no_include_pwd - -QT += core gui xml -greaterThan(QT_MAJOR_VERSION, 4): QT += widgets - -#uncomment the following section to enable building on windows: - - -OBJECTS_DIR = build -MOC_DIR = build -UI_DIR = build - -# use: qmake "RELEASE=1" -contains(RELEASE, 1) { - # Mac: compile for maximum compatibility (10.5, 32-bit) - macx:QMAKE_CXXFLAGS += -mmacosx-version-min=10.5 -arch i386 -isysroot /Developer/SDKs/MacOSX10.5.sdk - - !windows:!macx { - # Linux: static link - LIBS += -Wl,-Bstatic - } -} - -!win32 { -# for extra security against potential buffer overflows: enable GCCs Stack Smashing Protection -QMAKE_CXXFLAGS *= -fstack-protector-all --param ssp-buffer-size=1 -QMAKE_LFLAGS *= -fstack-protector-all --param ssp-buffer-size=1 -# We need to exclude this for Windows cross compile with MinGW 4.2.x, as it will result in a non-working executable! -# This can be enabled for Windows, when we switch to MinGW >= 4.4.x. -} -# for extra security on Windows: enable ASLR and DEP via GCC linker flags -win32:QMAKE_LFLAGS *= -Wl,--dynamicbase -Wl,--nxcompat - -# use: qmake "USE_QRCODE=1" -# libqrencode (http://fukuchi.org/works/qrencode/index.en.html) must be installed for support -contains(USE_QRCODE, 1) { - message(Building with QRCode support) - DEFINES += USE_QRCODE - LIBS += -lqrencode -} - -# use: qmake "USE_UPNP=1" ( enabled by default; default) -# or: qmake "USE_UPNP=0" (disabled by default) -# or: qmake "USE_UPNP=-" (not supported) -# miniupnpc (http://miniupnp.free.fr/files/) must be installed for support -contains(USE_UPNP, -) { - message(Building without UPNP support) -} else { - message(Building with UPNP support) - count(USE_UPNP, 0) { - USE_UPNP=1 - } - DEFINES += USE_UPNP=$$USE_UPNP STATICLIB - INCLUDEPATH += $$MINIUPNPC_INCLUDE_PATH - LIBS += $$join(MINIUPNPC_LIB_PATH,,-L,) -lminiupnpc - win32:LIBS += -liphlpapi -} - - -# use: qmake "USE_DBUS=1" -contains(USE_DBUS, 1) { - message(Building with DBUS (Freedesktop notifications) support) - DEFINES += USE_DBUS - QT += dbus -} - -# use: qmake "USE_IPV6=1" ( enabled by default; default) -# or: qmake "USE_IPV6=0" (disabled by default) -# or: qmake "USE_IPV6=-" (not supported) -contains(USE_IPV6, -) { - message(Building without IPv6 support) -} else { - message(Building with IPv6 support) - count(USE_IPV6, 0) { - USE_IPV6=1 - } - DEFINES += USE_IPV6=$$USE_IPV6 -} - -contains(BITCOIN_NEED_QT_PLUGINS, 1) { - DEFINES += BITCOIN_NEED_QT_PLUGINS - QTPLUGIN += qcncodecs qjpcodecs qtwcodecs qkrcodecs qtaccessiblewidgets -} - - -# regenerate src/build.h -!windows|contains(USE_BUILD_INFO, 1) { - genbuild.depends = FORCE - genbuild.commands = cd $$PWD; /bin/sh share/genbuild.sh $$OUT_PWD/build/build.h - genbuild.target = $$OUT_PWD/build/build.h - PRE_TARGETDEPS += $$OUT_PWD/build/build.h - QMAKE_EXTRA_TARGETS += genbuild - DEFINES += HAVE_BUILD_INFO -} - -QMAKE_CXXFLAGS += -msse2 -QMAKE_CFLAGS += -msse2 -QMAKE_CXXFLAGS_WARN_ON = -fdiagnostics-show-option -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -Wstack-protector - -# Input -DEPENDPATH += src src/json src/qt -HEADERS += src/qt/bitcoingui.h \ - src/qt/transactiontablemodel.h \ - src/qt/addresstablemodel.h \ - src/qt/optionsdialog.h \ - src/qt/coincontroldialog.h \ - src/qt/coincontroltreewidget.h \ - src/qt/sendcoinsdialog.h \ - src/qt/addressbookpage.h \ - src/qt/signverifymessagedialog.h \ - src/qt/aboutdialog.h \ - src/qt/editaddressdialog.h \ - src/qt/bitcoinaddressvalidator.h \ - src/alert.h \ - src/addrman.h \ - src/base58.h \ - src/bignum.h \ - src/checkpoints.h \ - src/compat.h \ - src/coincontrol.h \ - src/sync.h \ - src/util.h \ - src/uint256.h \ - src/kernel.h \ - src/scrypt_mine.h \ - src/pbkdf2.h \ - src/serialize.h \ - src/strlcpy.h \ - src/main.h \ - src/net.h \ - src/key.h \ - src/db.h \ - src/walletdb.h \ - src/script.h \ - src/init.h \ - src/irc.h \ - src/mruset.h \ - src/json/json_spirit_writer_template.h \ - src/json/json_spirit_writer.h \ - src/json/json_spirit_value.h \ - src/json/json_spirit_utils.h \ - src/json/json_spirit_stream_reader.h \ - src/json/json_spirit_reader_template.h \ - src/json/json_spirit_reader.h \ - src/json/json_spirit_error_position.h \ - src/json/json_spirit.h \ - src/qt/clientmodel.h \ - src/qt/guiutil.h \ - src/qt/transactionrecord.h \ - src/qt/guiconstants.h \ - src/qt/optionsmodel.h \ - src/qt/monitoreddatamapper.h \ - src/qt/transactiondesc.h \ - src/qt/transactiondescdialog.h \ - src/qt/bitcoinamountfield.h \ - src/wallet.h \ - src/keystore.h \ - src/qt/transactionfilterproxy.h \ - src/qt/transactionview.h \ - src/qt/walletmodel.h \ - src/bitcoinrpc.h \ - src/qt/overviewpage.h \ - src/qt/csvmodelwriter.h \ - src/crypter.h \ - src/qt/sendcoinsentry.h \ - src/qt/qvalidatedlineedit.h \ - src/qt/bitcoinunits.h \ - src/qt/qvaluecombobox.h \ - src/qt/askpassphrasedialog.h \ - src/protocol.h \ - src/qt/notificator.h \ - src/qt/qtipcserver.h \ - src/allocators.h \ - src/ui_interface.h \ - src/qt/rpcconsole.h \ - src/version.h \ - src/netbase.h \ - src/clientversion.h \ - src/hashblock.h \ - src/sph_blake.h \ - src/sph_skein.h \ - src/sph_keccak.h \ - src/sph_jh.h \ - src/sph_groestl.h \ - src/sph_bmw.h \ - src/sph_types.h \ - src/sph_luffa.h \ - src/sph_cubehash.h \ - src/sph_echo.h \ - src/sph_shavite.h \ - src/sph_simd.h \ - src/sph_types.h - -SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \ - src/qt/transactiontablemodel.cpp \ - src/qt/addresstablemodel.cpp \ - src/qt/optionsdialog.cpp \ - src/qt/sendcoinsdialog.cpp \ - src/qt/coincontroldialog.cpp \ - src/qt/coincontroltreewidget.cpp \ - src/qt/addressbookpage.cpp \ - src/qt/signverifymessagedialog.cpp \ - src/qt/aboutdialog.cpp \ - src/qt/editaddressdialog.cpp \ - src/qt/bitcoinaddressvalidator.cpp \ - src/alert.cpp \ - src/version.cpp \ - src/sync.cpp \ - src/util.cpp \ - src/netbase.cpp \ - src/key.cpp \ - src/script.cpp \ - src/main.cpp \ - src/init.cpp \ - src/net.cpp \ - src/irc.cpp \ - src/checkpoints.cpp \ - src/addrman.cpp \ - src/db.cpp \ - src/walletdb.cpp \ - src/qt/clientmodel.cpp \ - src/qt/guiutil.cpp \ - src/qt/transactionrecord.cpp \ - src/qt/optionsmodel.cpp \ - src/qt/monitoreddatamapper.cpp \ - src/qt/transactiondesc.cpp \ - src/qt/transactiondescdialog.cpp \ - src/qt/bitcoinstrings.cpp \ - src/qt/bitcoinamountfield.cpp \ - src/wallet.cpp \ - src/keystore.cpp \ - src/qt/transactionfilterproxy.cpp \ - src/qt/transactionview.cpp \ - src/qt/walletmodel.cpp \ - src/bitcoinrpc.cpp \ - src/rpcdump.cpp \ - src/rpcnet.cpp \ - src/rpcmining.cpp \ - src/rpcwallet.cpp \ - src/rpcblockchain.cpp \ - src/rpcrawtransaction.cpp \ - src/qt/overviewpage.cpp \ - src/qt/csvmodelwriter.cpp \ - src/crypter.cpp \ - src/qt/sendcoinsentry.cpp \ - src/qt/qvalidatedlineedit.cpp \ - src/qt/bitcoinunits.cpp \ - src/qt/qvaluecombobox.cpp \ - src/qt/askpassphrasedialog.cpp \ - src/protocol.cpp \ - src/qt/notificator.cpp \ - src/qt/qtipcserver.cpp \ - src/qt/rpcconsole.cpp \ - src/noui.cpp \ - src/kernel.cpp \ - src/pbkdf2.cpp \ - src/blake.c \ - src/bmw.c \ - src/groestl.c \ - src/jh.c \ - src/keccak.c \ - src/skein.c \ - src/luffa.c \ - src/cubehash.c \ - src/shavite.c \ - src/echo.c \ - src/simd.c - -RESOURCES += \ - src/qt/bitcoin.qrc - -FORMS += \ - src/qt/forms/coincontroldialog.ui \ - src/qt/forms/sendcoinsdialog.ui \ - src/qt/forms/addressbookpage.ui \ - src/qt/forms/signverifymessagedialog.ui \ - src/qt/forms/aboutdialog.ui \ - src/qt/forms/editaddressdialog.ui \ - src/qt/forms/transactiondescdialog.ui \ - src/qt/forms/overviewpage.ui \ - src/qt/forms/sendcoinsentry.ui \ - src/qt/forms/askpassphrasedialog.ui \ - src/qt/forms/rpcconsole.ui \ - src/qt/forms/optionsdialog.ui - -contains(USE_QRCODE, 1) { -HEADERS += src/qt/qrcodedialog.h -SOURCES += src/qt/qrcodedialog.cpp -FORMS += src/qt/forms/qrcodedialog.ui -} - -contains(BITCOIN_QT_TEST, 1) { -SOURCES += src/qt/test/test_main.cpp \ - src/qt/test/uritests.cpp -HEADERS += src/qt/test/uritests.h -DEPENDPATH += src/qt/test -QT += testlib -TARGET = hyperstake-qt_test -DEFINES += BITCOIN_QT_TEST -} - -CODECFORTR = UTF-8 - -# for lrelease/lupdate -# also add new translations to src/qt/bitcoin.qrc under translations/ -TRANSLATIONS = $$files(src/qt/locale/bitcoin_*.ts) - -isEmpty(QMAKE_LRELEASE) { - win32:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]\\lrelease.exe - else:QMAKE_LRELEASE = $$[QT_INSTALL_BINS]/lrelease -} -isEmpty(QM_DIR):QM_DIR = $$PWD/src/qt/locale -# automatically build translations, so they can be included in resource file -TSQM.name = lrelease ${QMAKE_FILE_IN} -TSQM.input = TRANSLATIONS -TSQM.output = $$QM_DIR/${QMAKE_FILE_BASE}.qm -TSQM.commands = $$QMAKE_LRELEASE ${QMAKE_FILE_IN} -qm ${QMAKE_FILE_OUT} -TSQM.CONFIG = no_link -QMAKE_EXTRA_COMPILERS += TSQM - -# "Other files" to show in Qt Creator -OTHER_FILES += \ - doc/*.rst doc/*.txt doc/README README.md res/bitcoin-qt.rc src/test/*.cpp src/test/*.h src/qt/test/*.cpp src/qt/test/*.h - - -# platform specific defaults, if not overridden on command line -isEmpty(BOOST_LIB_SUFFIX) { - macx:BOOST_LIB_SUFFIX = -mt - windows:BOOST_LIB_SUFFIX = -mgw48-mt-s-1_55 -} - -isEmpty(BOOST_THREAD_LIB_SUFFIX) { - BOOST_THREAD_LIB_SUFFIX = $$BOOST_LIB_SUFFIX -} - -isEmpty(BDB_LIB_PATH) { - macx:BDB_LIB_PATH = /opt/local/lib/db48 -} - -isEmpty(BDB_LIB_SUFFIX) { - macx:BDB_LIB_SUFFIX = -4.8 -} - -isEmpty(BDB_INCLUDE_PATH) { - macx:BDB_INCLUDE_PATH = /opt/local/include/db48 -} - -isEmpty(BOOST_LIB_PATH) { - macx:BOOST_LIB_PATH = /opt/local/lib -} - -isEmpty(BOOST_INCLUDE_PATH) { - macx:BOOST_INCLUDE_PATH = /opt/local/include -} - -windows:DEFINES += WIN32 -windows:RC_FILE = src/qt/res/bitcoin-qt.rc - -windows:!contains(MINGW_THREAD_BUGFIX, 0) { - # At least qmake's win32-g++-cross profile is missing the -lmingwthrd - # thread-safety flag. GCC has -mthreads to enable this, but it doesn't - # work with static linking. -lmingwthrd must come BEFORE -lmingw, so - # it is prepended to QMAKE_LIBS_QT_ENTRY. - # It can be turned off with MINGW_THREAD_BUGFIX=0, just in case it causes - # any problems on some untested qmake profile now or in the future. - DEFINES += _MT - QMAKE_LIBS_QT_ENTRY = -lmingwthrd $$QMAKE_LIBS_QT_ENTRY -} - -!windows:!macx { - DEFINES += LINUX - LIBS += -lrt -} - -macx:HEADERS += src/qt/macdockiconhandler.h -macx:OBJECTIVE_SOURCES += src/qt/macdockiconhandler.mm -macx:LIBS += -framework Foundation -framework ApplicationServices -framework AppKit -macx:DEFINES += MAC_OSX MSG_NOSIGNAL=0 -macx:ICON = src/qt/res/icons/bitcoin.icns -macx:TARGET = "hyperstake-qt" -macx:QMAKE_CFLAGS_THREAD += -pthread -macx:QMAKE_LFLAGS_THREAD += -pthread -macx:QMAKE_CXXFLAGS_THREAD += -pthread - -# Set libraries and includes at end, to use platform-defined defaults if not overridden -INCLUDEPATH += $$BOOST_INCLUDE_PATH $$BDB_INCLUDE_PATH $$OPENSSL_INCLUDE_PATH $$QRENCODE_INCLUDE_PATH -LIBS += $$join(BOOST_LIB_PATH,,-L,) $$join(BDB_LIB_PATH,,-L,) $$join(OPENSSL_LIB_PATH,,-L,) $$join(QRENCODE_LIB_PATH,,-L,) -LIBS += -lssl -lcrypto -ldb_cxx$$BDB_LIB_SUFFIX -# -lgdi32 has to happen after -lcrypto (see #681) -windows:LIBS += -lws2_32 -lshlwapi -lmswsock -lole32 -loleaut32 -luuid -lgdi32 -LIBS += -lboost_system$$BOOST_LIB_SUFFIX -lboost_filesystem$$BOOST_LIB_SUFFIX -lboost_program_options$$BOOST_LIB_SUFFIX -lboost_thread$$BOOST_THREAD_LIB_SUFFIX -windows:LIBS += -lboost_chrono$$BOOST_LIB_SUFFIX - -contains(RELEASE, 1) { - !windows:!macx { - # Linux: turn dynamic linking back on for c/c++ runtime libraries - LIBS += -Wl,-Bdynamic - } -} - -system($$QMAKE_LRELEASE -silent $$_PRO_FILE_) diff --git a/HyperStake-qt.pro b/HyperStake-qt.pro index d26088d3b..f7d5c0011 100644 --- a/HyperStake-qt.pro +++ b/HyperStake-qt.pro @@ -1,32 +1,44 @@ TEMPLATE = app TARGET = HyperStake-qt -VERSION = 0.7.2 +VERSION = 1.1.5 INCLUDEPATH += src src/json src/qt DEFINES += QT_GUI BOOST_THREAD_USE_LIB BOOST_SPIRIT_THREADSAFE BOOST_THREAD_PROVIDES_GENERIC_SHARED_MUTEX_ON_WIN __NO_SYSTEM_INCLUDES -CONFIG += no_include_pwd -CONFIG += static - -QT += core gui xml +CONFIG += no_include_pwd static c++11 +QT += core gui xml network greaterThan(QT_MAJOR_VERSION, 4): QT += widgets -#uncomment the following section to enable building on windows: -windows:LIBS += -lshlwapi -LIBS += $$join(BOOST_LIB_PATH,,-L,) $$join(BDB_LIB_PATH,,-L,) $$join(OPENSSL_LIB_PATH,,-L,) $$join(QRENCODE_LIB_PATH,,-L,) -LIBS += -lssl -lcrypto -ldb_cxx$$BDB_LIB_SUFFIX -windows:LIBS += -lws2_32 -lole32 -loleaut32 -luuid -lgdi32 -LIBS += -lboost_system-mgw48-mt-s-1_55 -lboost_filesystem-mgw48-mt-s-1_55 -lboost_program_options-mgw48-mt-s-1_55 -lboost_thread-mgw48-mt-s-1_55 -BOOST_LIB_SUFFIX=-mgw48-mt-s-1_55 -BOOST_INCLUDE_PATH=C:/deps/boost_1_55_0 -BOOST_LIB_PATH=C:/deps/boost_1_55_0/stage/lib -BDB_INCLUDE_PATH=C:/deps/db-4.8.30.NC/build_unix -BDB_LIB_PATH=C:/deps/db-4.8.30.NC/build_unix -OPENSSL_INCLUDE_PATH=C:/deps/openssl-1.0.1g/include -OPENSSL_LIB_PATH=C:/deps/openssl-1.0.1g -MINIUPNPC_LIB_PATH=C:/deps/miniupnpc -MINIUPNPC_INCLUDE_PATH=c:/deps -QRENCODE_INCLUDE_PATH=C:/deps/qrencode-3.4.3 -QRENCODE_LIB_PATH=C:/deps/qrencode-3.4.3/.libs +macx { + SSE2_SUPPORT = $$system(sysctl -n machdep.cpu.features | grep -c SSE2) +} +unix:!macx { + SSE2_SUPPORT = $$system(grep -m1 -c sse2 /proc/cpuinfo) +} + +!unix:!macx { + SSE2_SUPPORT = 1 +} + + +#win32{ + #uncomment the following section to enable building on windows: + # windows:LIBS += -lshlwapi + # LIBS += $$join(BOOST_LIB_PATH,,-L,) $$join(BDB_LIB_PATH,,-L,) $$join(OPENSSL_LIB_PATH,,-L,) $$join(QRENCODE_LIB_PATH,,-L,) + # LIBS += -lssl -lcrypto -ldb_cxx$$BDB_LIB_SUFFIX + # windows:LIBS += -lws2_32 -lole32 -loleaut32 -luuid -lgdi32 + # LIBS += -lboost_system-mgw48-mt-s-1_55 -lboost_filesystem-mgw48-mt-s-1_55 -lboost_program_options-mgw48-mt-s-1_55 -lboost_thread-mgw48-mt-s-1_55 + # BOOST_LIB_SUFFIX=-mgw48-mt-s-1_55 + # BOOST_INCLUDE_PATH=C:/deps/boost_1_55_0 + # BOOST_LIB_PATH=C:/deps/boost_1_55_0/stage/lib + # BDB_INCLUDE_PATH=C:/deps/db-4.8.30.NC/build_unix + # BDB_LIB_PATH=C:/deps/db-4.8.30.NC/build_unix + # OPENSSL_INCLUDE_PATH=C:/deps/openssl-1.0.1g/include + # OPENSSL_LIB_PATH=C:/deps/openssl-1.0.1g + # MINIUPNPC_LIB_PATH=C:/deps/miniupnpc + # MINIUPNPC_INCLUDE_PATH=c:/deps + # QRENCODE_INCLUDE_PATH=C:/deps/qrencode-3.4.3 + # QRENCODE_LIB_PATH=C:/deps/qrencode-3.4.3/.libs +#} OBJECTS_DIR = build MOC_DIR = build @@ -44,11 +56,11 @@ contains(RELEASE, 1) { } !win32 { -# for extra security against potential buffer overflows: enable GCCs Stack Smashing Protection -QMAKE_CXXFLAGS *= -fstack-protector-all --param ssp-buffer-size=1 -QMAKE_LFLAGS *= -fstack-protector-all --param ssp-buffer-size=1 -# We need to exclude this for Windows cross compile with MinGW 4.2.x, as it will result in a non-working executable! -# This can be enabled for Windows, when we switch to MinGW >= 4.4.x. + # for extra security against potential buffer overflows: enable GCCs Stack Smashing Protection + QMAKE_CXXFLAGS *= -fstack-protector-all --param ssp-buffer-size=1 + QMAKE_LFLAGS *= -fstack-protector-all --param ssp-buffer-size=1 + # We need to exclude this for Windows cross compile with MinGW 4.2.x, as it will result in a non-working executable! + # This can be enabled for Windows, when we switch to MinGW >= 4.4.x. } # for extra security on Windows: enable ASLR and DEP via GCC linker flags win32:QMAKE_LFLAGS *= -Wl,--large-address-aware -static @@ -115,8 +127,14 @@ contains(BITCOIN_NEED_QT_PLUGINS, 1) { DEFINES += HAVE_BUILD_INFO } -QMAKE_CXXFLAGS += -msse2 -QMAKE_CFLAGS += -msse2 +contains( SSE2_SUPPORT, 1 ) { + message("SSE2 detected, adding -msse2 flag") + QMAKE_CXXFLAGS += -msse2 + QMAKE_CFLAGS += -msse2 +} else { + message("No SSE2 detected, skipping -msse2 flag") +} + QMAKE_CXXFLAGS_WARN_ON = -fdiagnostics-show-option -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter -Wstack-protector # Input @@ -125,21 +143,24 @@ HEADERS += src/qt/bitcoingui.h \ src/qt/transactiontablemodel.h \ src/qt/addresstablemodel.h \ src/qt/optionsdialog.h \ - src/qt/coincontroldialog.h \ + src/qt/coincontroldialog.h \ src/qt/coincontroltreewidget.h \ src/qt/sendcoinsdialog.h \ src/qt/addressbookpage.h \ src/qt/signverifymessagedialog.h \ src/qt/aboutdialog.h \ + src/qt/bip38tooldialog.h \ + src/qt/calcdialog.h \ src/qt/editaddressdialog.h \ src/qt/bitcoinaddressvalidator.h \ src/alert.h \ src/addrman.h \ src/base58.h \ + src/bip38.h \ src/bignum.h \ src/checkpoints.h \ src/compat.h \ - src/coincontrol.h \ + src/coincontrol.h \ src/sync.h \ src/util.h \ src/uint256.h \ @@ -147,15 +168,14 @@ HEADERS += src/qt/bitcoingui.h \ src/scrypt_mine.h \ src/pbkdf2.h \ src/serialize.h \ - src/strlcpy.h \ src/main.h \ src/net.h \ src/key.h \ src/db.h \ src/walletdb.h \ src/script.h \ + src/scrypt.h \ src/init.h \ - src/irc.h \ src/mruset.h \ src/json/json_spirit_writer_template.h \ src/json/json_spirit_writer.h \ @@ -181,6 +201,8 @@ HEADERS += src/qt/bitcoingui.h \ src/qt/transactionview.h \ src/qt/walletmodel.h \ src/bitcoinrpc.h \ + src/qt/blockbrowser.h \ + src/qt/charitydialog.h \ src/qt/overviewpage.h \ src/qt/csvmodelwriter.h \ src/crypter.h \ @@ -191,7 +213,7 @@ HEADERS += src/qt/bitcoingui.h \ src/qt/askpassphrasedialog.h \ src/protocol.h \ src/qt/notificator.h \ - src/qt/qtipcserver.h \ + src/qt/paymentserver.h \ src/allocators.h \ src/ui_interface.h \ src/qt/rpcconsole.h \ @@ -211,49 +233,76 @@ HEADERS += src/qt/bitcoingui.h \ src/sph_echo.h \ src/sph_shavite.h \ src/sph_simd.h \ - src/sph_types.h + src/sph_types.h \ + src/qt/networkstyle.h \ + src/qt/scicon.h \ + src/qt/votingdialog.h \ + src/qt/createproposaldialog.h \ + src/qt/proposalsdialog.h \ + src/qt/setvotesdialog.h SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \ - src/qt/transactiontablemodel.cpp \ + src/qt/aboutdialog.cpp \ + src/qt/addressbookpage.cpp \ src/qt/addresstablemodel.cpp \ - src/qt/optionsdialog.cpp \ - src/qt/sendcoinsdialog.cpp \ - src/qt/coincontroldialog.cpp \ + src/qt/askpassphrasedialog.cpp \ + src/qt/bip38tooldialog.cpp \ + src/qt/bitcoinstrings.cpp \ + src/qt/bitcoinamountfield.cpp \ + src/qt/bitcoinaddressvalidator.cpp \ + src/qt/bitcoinunits.cpp \ + src/qt/blockbrowser.cpp \ + src/qt/calcdialog.cpp \ + src/qt/charitydialog.cpp \ + src/qt/clientmodel.cpp \ + src/qt/coincontroldialog.cpp \ src/qt/coincontroltreewidget.cpp \ - src/qt/addressbookpage.cpp \ - src/qt/signverifymessagedialog.cpp \ - src/qt/aboutdialog.cpp \ + src/qt/createproposaldialog.cpp \ + src/qt/csvmodelwriter.cpp \ src/qt/editaddressdialog.cpp \ - src/qt/bitcoinaddressvalidator.cpp \ + src/qt/guiutil.cpp \ + src/qt/monitoreddatamapper.cpp \ + src/qt/networkstyle.cpp \ + src/qt/notificator.cpp \ + src/qt/optionsdialog.cpp \ + src/qt/optionsmodel.cpp \ + src/qt/overviewpage.cpp \ + src/qt/paymentserver.cpp \ + src/qt/proposalsdialog.cpp \ + src/qt/qvalidatedlineedit.cpp \ + src/qt/qvaluecombobox.cpp \ + src/qt/rpcconsole.cpp \ + src/qt/scicon.cpp \ + src/qt/signverifymessagedialog.cpp \ + src/qt/sendcoinsdialog.cpp \ + src/qt/sendcoinsentry.cpp \ + src/qt/setvotesdialog.cpp \ + src/qt/transactiondesc.cpp \ + src/qt/transactiondescdialog.cpp \ + src/qt/transactionfilterproxy.cpp \ + src/qt/transactionrecord.cpp \ + src/qt/transactiontablemodel.cpp \ + src/qt/transactionview.cpp \ + src/qt/votingdialog.cpp \ + src/qt/walletmodel.cpp \ src/alert.cpp \ + src/bip38.cpp \ src/version.cpp \ src/sync.cpp \ src/util.cpp \ src/netbase.cpp \ src/key.cpp \ + src/scrypt.cpp \ src/script.cpp \ src/main.cpp \ src/init.cpp \ src/net.cpp \ - src/irc.cpp \ src/checkpoints.cpp \ src/addrman.cpp \ src/db.cpp \ src/walletdb.cpp \ - src/qt/clientmodel.cpp \ - src/qt/guiutil.cpp \ - src/qt/transactionrecord.cpp \ - src/qt/optionsmodel.cpp \ - src/qt/monitoreddatamapper.cpp \ - src/qt/transactiondesc.cpp \ - src/qt/transactiondescdialog.cpp \ - src/qt/bitcoinstrings.cpp \ - src/qt/bitcoinamountfield.cpp \ src/wallet.cpp \ src/keystore.cpp \ - src/qt/transactionfilterproxy.cpp \ - src/qt/transactionview.cpp \ - src/qt/walletmodel.cpp \ src/bitcoinrpc.cpp \ src/rpcdump.cpp \ src/rpcnet.cpp \ @@ -261,18 +310,8 @@ SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \ src/rpcwallet.cpp \ src/rpcblockchain.cpp \ src/rpcrawtransaction.cpp \ - src/qt/overviewpage.cpp \ - src/qt/csvmodelwriter.cpp \ src/crypter.cpp \ - src/qt/sendcoinsentry.cpp \ - src/qt/qvalidatedlineedit.cpp \ - src/qt/bitcoinunits.cpp \ - src/qt/qvaluecombobox.cpp \ - src/qt/askpassphrasedialog.cpp \ src/protocol.cpp \ - src/qt/notificator.cpp \ - src/qt/qtipcserver.cpp \ - src/qt/rpcconsole.cpp \ src/noui.cpp \ src/kernel.cpp \ src/pbkdf2.cpp \ @@ -286,39 +325,53 @@ SOURCES += src/qt/bitcoin.cpp src/qt/bitcoingui.cpp \ src/cubehash.c \ src/shavite.c \ src/echo.c \ - src/simd.c + src/simd.c \ + src/clientversion.cpp \ + src/votecharset.cpp \ + src/voteproposal.cpp \ + src/voteproposalmanager.cpp \ + src/voteobject.cpp \ + src/votetally.cpp RESOURCES += \ src/qt/bitcoin.qrc FORMS += \ - src/qt/forms/coincontroldialog.ui \ + src/qt/forms/coincontroldialog.ui \ src/qt/forms/sendcoinsdialog.ui \ src/qt/forms/addressbookpage.ui \ src/qt/forms/signverifymessagedialog.ui \ src/qt/forms/aboutdialog.ui \ + src/qt/forms/calcdialog.ui \ src/qt/forms/editaddressdialog.ui \ src/qt/forms/transactiondescdialog.ui \ + src/qt/forms/blockbrowser.ui \ + src/qt/forms/charitydialog.ui \ src/qt/forms/overviewpage.ui \ src/qt/forms/sendcoinsentry.ui \ src/qt/forms/askpassphrasedialog.ui \ src/qt/forms/rpcconsole.ui \ - src/qt/forms/optionsdialog.ui + src/qt/forms/optionsdialog.ui \ + src/qt/forms/bip38tooldialog.ui \ + src/qt/forms/votingdialog.ui \ + src/qt/forms/createproposaldialog.ui \ + src/qt/forms/proposalsdialog.ui \ + src/qt/forms/setvotesdialog.ui contains(USE_QRCODE, 1) { -HEADERS += src/qt/qrcodedialog.h -SOURCES += src/qt/qrcodedialog.cpp -FORMS += src/qt/forms/qrcodedialog.ui + HEADERS += src/qt/qrcodedialog.h + SOURCES += src/qt/qrcodedialog.cpp + FORMS += src/qt/forms/qrcodedialog.ui } contains(BITCOIN_QT_TEST, 1) { -SOURCES += src/qt/test/test_main.cpp \ - src/qt/test/uritests.cpp -HEADERS += src/qt/test/uritests.h -DEPENDPATH += src/qt/test -QT += testlib -TARGET = hyperstake-qt_test -DEFINES += BITCOIN_QT_TEST + SOURCES += src/qt/test/test_main.cpp \ + src/qt/test/uritests.cpp + HEADERS += src/qt/test/uritests.h + DEPENDPATH += src/qt/test + QT += testlib + TARGET = hyperstake-qt_test + DEFINES += BITCOIN_QT_TEST } CODECFORTR = UTF-8 @@ -406,7 +459,7 @@ macx:QMAKE_CXXFLAGS_THREAD += -pthread # Set libraries and includes at end, to use platform-defined defaults if not overridden INCLUDEPATH += $$BOOST_INCLUDE_PATH $$BDB_INCLUDE_PATH $$OPENSSL_INCLUDE_PATH $$QRENCODE_INCLUDE_PATH -LIBS += $$join(BOOST_LIB_PATH,,-L,) $$join(BDB_LIB_PATH,,-L,) $$join(OPENSSL_LIB_PATH,,-L,) $$join(QRENCODE_LIB_PATH,,-L,) +LIBS += $$join(BOOST_LIB_PATH,,-L,) $$join(BDB_LIB_PATH,,-L,) $$join(OPENSSL_LIB_PATH,,-L,) $$join(QRENCODE_LIB_PATH,,-L,) $$join() LIBS += -lssl -lcrypto -ldb_cxx$$BDB_LIB_SUFFIX # -lgdi32 has to happen after -lcrypto (see #681) windows:LIBS += -lws2_32 -lshlwapi -lmswsock -lole32 -loleaut32 -luuid -lgdi32 @@ -420,4 +473,15 @@ contains(RELEASE, 1) { } } + +CONFIG(debug, debug|release) { + DESTDIR = debug +} else { + DESTDIR = release +} + +themes.path = $$OUT_PWD/$$DESTDIR/themes +themes.files = src/qt/res/themes/* +INSTALLS += themes + system($$QMAKE_LRELEASE -silent $$_PRO_FILE_) diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 000000000..6148103e7 --- /dev/null +++ b/Makefile.am @@ -0,0 +1,177 @@ +ACLOCAL_AMFLAGS = -I build-aux/m4 +SUBDIRS = src +.PHONY: deploy FORCE + +GZIP_ENV="-9n" + +BITCOIND_BIN=$(top_builddir)/src/hyperstaked$(EXEEXT) +BITCOIN_QT_BIN=$(top_builddir)/src/qt/hyperstake-qt$(EXEEXT) +BITCOIN_WIN_INSTALLER=$(PACKAGE)-$(PACKAGE_VERSION)-win$(WINDOWS_BITS)-setup$(EXEEXT) + +OSX_APP=Hyperstake-Qt.app +OSX_DMG=Hyperstake-Qt.dmg +OSX_DEPLOY_SCRIPT=$(top_srcdir)/contrib/macdeploy/macdeployqtplus +OSX_FANCY_PLIST=$(top_srcdir)/contrib/macdeploy/fancy.plist +OSX_INSTALLER_ICONS=$(top_srcdir)/src/qt/res/icons/bitcoin.icns +OSX_PLIST=$(top_srcdir)/share/qt/Info.plist #not installed +OSX_QT_TRANSLATIONS = da,de,es,hu,ru,uk,zh_CN,zh_TW + +THEMES=$(top_srcdir)/src/qt/res/themes + +DIST_DOCS = $(wildcard doc/*.md) $(wildcard doc/release-notes/*.md) + +WINDOWS_PACKAGING = $(top_srcdir)/share/pixmaps/bitcoin.ico \ + $(top_srcdir)/share/pixmaps/nsis-header.bmp \ + $(top_srcdir)/share/pixmaps/nsis-wizard.bmp \ + $(top_srcdir)/doc/README_windows.txt + +OSX_PACKAGING = $(OSX_DEPLOY_SCRIPT) $(OSX_FANCY_PLIST) $(OSX_INSTALLER_ICONS) \ + $(top_srcdir)/contrib/macdeploy/background.png \ + $(top_srcdir)/contrib/macdeploy/DS_Store \ + $(top_srcdir)/contrib/macdeploy/detached-sig-apply.sh \ + $(top_srcdir)/contrib/macdeploy/detached-sig-create.sh + +COVERAGE_INFO = baseline_filtered_combined.info baseline.info block_test.info \ + test_bitcoin_filtered.info total_coverage.info \ + baseline_filtered.info block_test_filtered.info \ + test_bitcoin_coverage.info test_bitcoin.info + +dist-hook: + -$(MAKE) -C $(top_distdir)/src/secp256k1 distclean + -$(GIT) archive --format=tar HEAD -- src/clientversion.cpp | $(AMTAR) -C $(top_distdir) -xf - + +distcleancheck: + @: + +$(BITCOIN_WIN_INSTALLER): all-recursive + $(MKDIR_P) $(top_builddir)/release + STRIPPROG="$(STRIP)" $(INSTALL_STRIP_PROGRAM) $(BITCOIND_BIN) $(top_builddir)/release + STRIPPROG="$(STRIP)" $(INSTALL_STRIP_PROGRAM) $(BITCOIN_QT_BIN) $(top_builddir)/release + @test -f $(MAKENSIS) && $(MAKENSIS) $(top_builddir)/share/setup.nsi || \ + echo error: could not build $@ + +$(if $(findstring src/,$(MAKECMDGOALS)),$(MAKECMDGOALS), none): FORCE + $(MAKE) -C src $(patsubst src/%,%,$@) + +$(OSX_APP)/Contents/PkgInfo: + $(MKDIR_P) $(@D) + @echo "APPL????" > $@ + +$(OSX_APP)/Contents/Resources/empty.lproj: + $(MKDIR_P) $(@D) + @touch $@ + +$(OSX_APP)/Contents/Info.plist: $(OSX_PLIST) + $(MKDIR_P) $(@D) + $(INSTALL_DATA) $< $@ + +$(OSX_APP)/Contents/Resources/bitcoin.icns: $(OSX_INSTALLER_ICONS) + $(MKDIR_P) $(@D) + $(INSTALL_DATA) $< $@ + +$(OSX_APP)/Contents/MacOS/Hyperstake-Qt: $(BITCOIN_QT_BIN) + $(MKDIR_P) $(@D) + STRIPPROG="$(STRIP)" $(INSTALL_STRIP_PROGRAM) $< $@ + +OSX_APP_BUILT=$(OSX_APP)/Contents/PkgInfo $(OSX_APP)/Contents/Resources/empty.lproj \ + $(OSX_APP)/Contents/Resources/bitcoin.icns $(OSX_APP)/Contents/Info.plist \ + $(OSX_APP)/Contents/MacOS/Hyperstake-Qt + +if BUILD_DARWIN +$(OSX_DMG): $(OSX_APP_BUILT) $(OSX_PACKAGING) + $(OSX_DEPLOY_SCRIPT) $(OSX_APP) -add-qt-tr $(OSX_QT_TRANSLATIONS) -translations-dir=$(QT_TRANSLATION_DIR) -dmg -fancy $(OSX_FANCY_PLIST) -verbose 2 + +deploydir: $(OSX_DMG) +else +APP_DIST_DIR=$(top_builddir)/dist +APP_DIST_EXTRAS=$(APP_DIST_DIR)/.background/background.png $(APP_DIST_DIR)/.DS_Store $(APP_DIST_DIR)/Applications + +$(APP_DIST_DIR)/Applications: + @rm -f $@ + @cd $(@D); $(LN_S) /Applications $(@F) + +$(APP_DIST_EXTRAS): $(APP_DIST_DIR)/$(OSX_APP)/Contents/MacOS/Hyperstake-Qt + +$(OSX_DMG): $(APP_DIST_EXTRAS) + $(GENISOIMAGE) -no-cache-inodes -D -l -probe -V "Hyperstake-Qt" -no-pad -r -apple -o $@ dist + +$(APP_DIST_DIR)/.background/background.png: + $(MKDIR_P) $(@D) + $(INSTALL) $(top_srcdir)/contrib/macdeploy/background.png $@ +$(APP_DIST_DIR)/.DS_Store: + $(INSTALL) $(top_srcdir)/contrib/macdeploy/DS_Store $@ + +$(APP_DIST_DIR)/$(OSX_APP)/Contents/MacOS/Hyperstake-Qt: $(OSX_APP_BUILT) $(OSX_PACKAGING) + INSTALLNAMETOOL=$(INSTALLNAMETOOL) OTOOL=$(OTOOL) STRIP=$(STRIP) $(OSX_DEPLOY_SCRIPT) $(OSX_APP) -translations-dir=$(QT_TRANSLATION_DIR) -add-qt-tr $(OSX_QT_TRANSLATIONS) -verbose 2 + +deploydir: $(APP_DIST_EXTRAS) +endif + +if TARGET_DARWIN +appbundle: $(OSX_APP_BUILT) +deploy: $(OSX_DMG) +endif +if TARGET_WINDOWS +deploy: $(BITCOIN_WIN_INSTALLER) +endif + +$(BITCOIN_QT_BIN): FORCE + $(MAKE) -C src qt/$(@F) + +$(BITCOIND_BIN): FORCE + $(MAKE) -C src $(@F) + +if USE_LCOV + +baseline.info: + $(LCOV) -c -i -d $(abs_builddir)/src -o $@ + +baseline_filtered.info: baseline.info + $(LCOV) -r $< "/usr/include/*" -o $@ + +baseline_filtered_combined.info: baseline_filtered.info + $(LCOV) -a baseline_filtered.info -o $@ + +test_bitcoin.info: baseline_filtered_combined.info + $(MAKE) -C src/ check + $(LCOV) -c -d $(abs_builddir)/src -t test_bitcoin -o $@ + $(LCOV) -z -d $(abs_builddir)/src + +test_bitcoin_filtered.info: test_bitcoin.info + $(LCOV) -r $< "/usr/include/*" -o $@ + +block_test.info: test_bitcoin_filtered.info + $(MKDIR_P) qa/tmp + -@TIMEOUT=15 qa/pull-tester/run-bitcoind-for-test.sh $(JAVA) -jar $(JAVA_COMPARISON_TOOL) qa/tmp/compTool 0 + $(LCOV) -c -d $(abs_builddir)/src --t BitcoinJBlockTest -o $@ + $(LCOV) -z -d $(abs_builddir)/src + +block_test_filtered.info: block_test.info + $(LCOV) -r $< "/usr/include/*" -o $@ + +test_bitcoin_coverage.info: baseline_filtered_combined.info test_bitcoin_filtered.info + $(LCOV) -a baseline_filtered.info -a test_bitcoin_filtered.info -o $@ + +total_coverage.info: baseline_filtered_combined.info test_bitcoin_filtered.info block_test_filtered.info + $(LCOV) -a baseline_filtered.info -a test_bitcoin_filtered.info -a block_test_filtered.info -o $@ | $(GREP) "\%" | $(AWK) '{ print substr($$3,2,50) "/" $$5 }' > coverage_percent.txt + +test_bitcoin.coverage/.dirstamp: test_bitcoin_coverage.info + $(GENHTML) -s $< -o $(@D) + @touch $@ + +total.coverage/.dirstamp: total_coverage.info + $(GENHTML) -s $< -o $(@D) + @touch $@ + +cov: test_bitcoin.coverage/.dirstamp total.coverage/.dirstamp + +endif + +EXTRA_DIST = $(top_srcdir)/share/genbuild.sh $(DIST_DOCS) $(WINDOWS_PACKAGING) $(OSX_PACKAGING) + +CLEANFILES = $(OSX_DMG) $(BITCOIN_WIN_INSTALLER) + +.INTERMEDIATE: $(COVERAGE_INFO) + +clean-local: + rm -rf test_bitcoin.coverage/ total.coverage/ $(OSX_APP) diff --git a/README.md b/README.md index 4c4ec4a9d..7616b73a0 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,6 @@ +# HyperStake - - -HyperStake - -Copyright (c) 2014 HyperStake Developers -Copyright (c) 2013-2014 hyperstake Developers +Copyright (c) 2013-2017 HyperStake Developers Copyright (c) 2013 NovaCoin Developers Copyright (c) 2011-2012 Bitcoin Developers Distributed under the MIT/X11 software license, see the accompanying @@ -35,7 +31,6 @@ or forward port incoming connections. hyperstake works without incoming connections, but allowing incoming connections helps the hyperstake network. - Upgrade ------- All you existing coins/transactions should be intact with the upgrade. @@ -47,6 +42,33 @@ Start up the new hyperstaked. See the hyperstake site: - http://hyperstake.org/ + http://hyperstake.io for help and more information. +Wallet themes +------- + +| HyperBlue | PoloniexNight | PoloniexDay | +| ------------- | ------------- | ------------- | +| [![HyperBlue](https://github.com/zeewolfik/HyperStake/raw/master/src/qt/res/screenshots/hyperstake-hyperblue-theme-th.png)](https://github.com/zeewolfik/HyperStake/raw/master/src/qt/res/screenshots/hyperstake-hyperblue-theme.png) | [![PoloniexNight](https://github.com/zeewolfik/HyperStake/raw/master/src/qt/res/screenshots/hyperstake-poloniexnight-theme-th.png)](https://github.com/zeewolfik/HyperStake/raw/master/src/qt/res/screenshots/hyperstake-poloniexnight-theme.png) | [![PoloniexNight](https://github.com/zeewolfik/HyperStake/raw/master/src/qt/res/screenshots/hyperstake-poloniexday-theme-th.png)](https://github.com/zeewolfik/HyperStake/raw/master/src/qt/res/screenshots/hyperstake-poloniexday-theme.png) | + + +Build Instructions (Linux) +------- +### Dependencies required for HyperStake with or without GUI: +`sudo apt-get install build-essential libtool autotools-dev autoconf pkg-config libssl-dev libboost-all-dev libdb5.3-dev libdb5.3++-dev libminiupnpc-dev automake` + +`./autogen.sh` + +### Configure without GUI: +`./configure --with-incompatible-bdb --with-gui=no` + +### Configure with GUI: +`sudo apt-get install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools libprotobuf-dev protobuf-compiler libqrencode-dev` + +`./configure --with-incompatible-bdb --with-gui=qt5` + +### Compile +`make` + + diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 000000000..3e26a1830 --- /dev/null +++ b/autogen.sh @@ -0,0 +1,9 @@ +#!/bin/sh +set -e +srcdir="$(dirname $0)" +cd "$srcdir" +if [ -z ${LIBTOOLIZE} ] && GLIBTOOLIZE="`which glibtoolize 2>/dev/null`"; then + LIBTOOLIZE="${GLIBTOOLIZE}" + export LIBTOOLIZE +fi +autoreconf --install --force --warnings=all diff --git a/build-aux/m4/ax_boost_base.m4 b/build-aux/m4/ax_boost_base.m4 new file mode 100644 index 000000000..650c94fa6 --- /dev/null +++ b/build-aux/m4/ax_boost_base.m4 @@ -0,0 +1,291 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_boost_base.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_BOOST_BASE([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# +# DESCRIPTION +# +# Test for the Boost C++ libraries of a particular version (or newer) +# +# If no path to the installed boost library is given the macro searchs +# under /usr, /usr/local, /opt and /opt/local and evaluates the +# $BOOST_ROOT environment variable. Further documentation is available at +# . +# +# This macro calls: +# +# AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS) +# +# And sets: +# +# HAVE_BOOST +# +# LICENSE +# +# Copyright (c) 2008 Thomas Porschberg +# Copyright (c) 2009 Peter Adolphs +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 27 + +AC_DEFUN([AX_BOOST_BASE], +[ +AC_ARG_WITH([boost], + [AS_HELP_STRING([--with-boost@<:@=ARG@:>@], + [use Boost library from a standard location (ARG=yes), + from the specified location (ARG=), + or disable it (ARG=no) + @<:@ARG=yes@:>@ ])], + [ + if test "$withval" = "no"; then + want_boost="no" + elif test "$withval" = "yes"; then + want_boost="yes" + ac_boost_path="" + else + want_boost="yes" + ac_boost_path="$withval" + fi + ], + [want_boost="yes"]) + + +AC_ARG_WITH([boost-libdir], + AS_HELP_STRING([--with-boost-libdir=LIB_DIR], + [Force given directory for boost libraries. Note that this will override library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]), + [ + if test -d "$withval" + then + ac_boost_lib_path="$withval" + else + AC_MSG_ERROR(--with-boost-libdir expected directory name) + fi + ], + [ac_boost_lib_path=""] +) + +if test "x$want_boost" = "xyes"; then + boost_lib_version_req=ifelse([$1], ,1.20.0,$1) + boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'` + boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'` + boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'` + boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'` + if test "x$boost_lib_version_req_sub_minor" = "x" ; then + boost_lib_version_req_sub_minor="0" + fi + WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+ $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor` + AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req) + succeeded=no + + dnl On 64-bit systems check for system libraries in both lib64 and lib. + dnl The former is specified by FHS, but e.g. Debian does not adhere to + dnl this (as it rises problems for generic multi-arch support). + dnl The last entry in the list is chosen by default when no libraries + dnl are found, e.g. when only header-only libraries are installed! + libsubdirs="lib" + ax_arch=`uname -m` + case $ax_arch in + x86_64) + libsubdirs="lib64 libx32 lib lib64" + ;; + ppc64|s390x|sparc64|aarch64|ppc64le) + libsubdirs="lib64 lib lib64" + ;; + esac + + dnl allow for real multi-arch paths e.g. /usr/lib/x86_64-linux-gnu. Give + dnl them priority over the other paths since, if libs are found there, they + dnl are almost assuredly the ones desired. + AC_REQUIRE([AC_CANONICAL_HOST]) + libsubdirs="lib/${host_cpu}-${host_os} $libsubdirs" + + case ${host_cpu} in + i?86) + libsubdirs="lib/i386-${host_os} $libsubdirs" + ;; + esac + + dnl some arches may advertise a cpu type that doesn't line up with their + dnl prefix's cpu type. For example, uname may report armv7l while libs are + dnl installed to /usr/lib/arm-linux-gnueabihf. Try getting the compiler's + dnl value for an extra chance of finding the correct path. + libsubdirs="lib/`$CXX -dumpmachine 2>/dev/null` $libsubdirs" + + dnl first we check the system location for boost libraries + dnl this location ist chosen if boost libraries are installed with the --layout=system option + dnl or if you install boost with RPM + if test "$ac_boost_path" != ""; then + BOOST_CPPFLAGS="-I$ac_boost_path/include" + for ac_boost_path_tmp in $libsubdirs; do + if test -d "$ac_boost_path"/"$ac_boost_path_tmp" ; then + BOOST_LDFLAGS="-L$ac_boost_path/$ac_boost_path_tmp" + break + fi + done + elif test "$cross_compiling" != yes; then + for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do + if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then + for libsubdir in $libsubdirs ; do + if ls "$ac_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi + done + BOOST_LDFLAGS="-L$ac_boost_path_tmp/$libsubdir" + BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include" + break; + fi + done + fi + + dnl overwrite ld flags if we have required special directory with + dnl --with-boost-libdir parameter + if test "$ac_boost_lib_path" != ""; then + BOOST_LDFLAGS="-L$ac_boost_lib_path" + fi + + CPPFLAGS_SAVED="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" + export CPPFLAGS + + LDFLAGS_SAVED="$LDFLAGS" + LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" + export LDFLAGS + + AC_REQUIRE([AC_PROG_CXX]) + AC_LANG_PUSH(C++) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + @%:@include + ]], [[ + #if BOOST_VERSION >= $WANT_BOOST_VERSION + // Everything is okay + #else + # error Boost version is too old + #endif + ]])],[ + AC_MSG_RESULT(yes) + succeeded=yes + found_system=yes + ],[ + ]) + AC_LANG_POP([C++]) + + + + dnl if we found no boost with system layout we search for boost libraries + dnl built and installed without the --layout=system option or for a staged(not installed) version + if test "x$succeeded" != "xyes"; then + CPPFLAGS="$CPPFLAGS_SAVED" + LDFLAGS="$LDFLAGS_SAVED" + BOOST_CPPFLAGS= + BOOST_LDFLAGS= + _version=0 + if test "$ac_boost_path" != ""; then + if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then + for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do + _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` + V_CHECK=`expr $_version_tmp \> $_version` + if test "$V_CHECK" = "1" ; then + _version=$_version_tmp + fi + VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` + BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE" + done + dnl if nothing found search for layout used in Windows distributions + if test -z "$BOOST_CPPFLAGS"; then + if test -d "$ac_boost_path/boost" && test -r "$ac_boost_path/boost"; then + BOOST_CPPFLAGS="-I$ac_boost_path" + fi + fi + fi + else + if test "$cross_compiling" != yes; then + for ac_boost_path in /usr /usr/local /opt /opt/local ; do + if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then + for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do + _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'` + V_CHECK=`expr $_version_tmp \> $_version` + if test "$V_CHECK" = "1" ; then + _version=$_version_tmp + best_path=$ac_boost_path + fi + done + fi + done + + VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'` + BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE" + if test "$ac_boost_lib_path" = ""; then + for libsubdir in $libsubdirs ; do + if ls "$best_path/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi + done + BOOST_LDFLAGS="-L$best_path/$libsubdir" + fi + fi + + if test "x$BOOST_ROOT" != "x"; then + for libsubdir in $libsubdirs ; do + if ls "$BOOST_ROOT/stage/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi + done + if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/$libsubdir" && test -r "$BOOST_ROOT/stage/$libsubdir"; then + version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'` + stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'` + stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'` + V_CHECK=`expr $stage_version_shorten \>\= $_version` + if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then + AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT) + BOOST_CPPFLAGS="-I$BOOST_ROOT" + BOOST_LDFLAGS="-L$BOOST_ROOT/stage/$libsubdir" + fi + fi + fi + fi + + CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" + export CPPFLAGS + LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" + export LDFLAGS + + AC_LANG_PUSH(C++) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + @%:@include + ]], [[ + #if BOOST_VERSION >= $WANT_BOOST_VERSION + // Everything is okay + #else + # error Boost version is too old + #endif + ]])],[ + AC_MSG_RESULT(yes) + succeeded=yes + found_system=yes + ],[ + ]) + AC_LANG_POP([C++]) + fi + + if test "$succeeded" != "yes" ; then + if test "$_version" = "0" ; then + AC_MSG_NOTICE([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option. If you are sure you have boost installed, then check your version number looking in . See http://randspringer.de/boost for more documentation.]]) + else + AC_MSG_NOTICE([Your boost libraries seems to old (version $_version).]) + fi + # execute ACTION-IF-NOT-FOUND (if present): + ifelse([$3], , :, [$3]) + else + AC_SUBST(BOOST_CPPFLAGS) + AC_SUBST(BOOST_LDFLAGS) + AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available]) + # execute ACTION-IF-FOUND (if present): + ifelse([$2], , :, [$2]) + fi + + CPPFLAGS="$CPPFLAGS_SAVED" + LDFLAGS="$LDFLAGS_SAVED" +fi + +]) diff --git a/build-aux/m4/ax_boost_chrono.m4 b/build-aux/m4/ax_boost_chrono.m4 new file mode 100644 index 000000000..318ecea17 --- /dev/null +++ b/build-aux/m4/ax_boost_chrono.m4 @@ -0,0 +1,119 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_boost_chrono.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_BOOST_CHRONO +# +# DESCRIPTION +# +# Test for System library from the Boost C++ libraries. The macro requires +# a preceding call to AX_BOOST_BASE. Further documentation is available at +# . +# +# This macro calls: +# +# AC_SUBST(BOOST_CHRONO_LIB) +# +# And sets: +# +# HAVE_BOOST_CHRONO +# +# LICENSE +# +# Copyright (c) 2012 Xiyue Deng +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 1 + +AC_DEFUN([AX_BOOST_CHRONO], +[ + AC_ARG_WITH([boost-chrono], + AS_HELP_STRING([--with-boost-chrono@<:@=special-lib@:>@], + [use the Chrono library from boost - it is possible to specify a certain library for the linker + e.g. --with-boost-chrono=boost_chrono-gcc-mt ]), + [ + if test "$withval" = "no"; then + want_boost="no" + elif test "$withval" = "yes"; then + want_boost="yes" + ax_boost_user_chrono_lib="" + else + want_boost="yes" + ax_boost_user_chrono_lib="$withval" + fi + ], + [want_boost="yes"] + ) + + if test "x$want_boost" = "xyes"; then + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_BUILD]) + CPPFLAGS_SAVED="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" + export CPPFLAGS + + LDFLAGS_SAVED="$LDFLAGS" + LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" + export LDFLAGS + + AC_CACHE_CHECK(whether the Boost::Chrono library is available, + ax_cv_boost_chrono, + [AC_LANG_PUSH([C++]) + CXXFLAGS_SAVE=$CXXFLAGS + + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include ]], + [[boost::chrono::system_clock::time_point time;]])], + ax_cv_boost_chrono=yes, ax_cv_boost_chrono=no) + CXXFLAGS=$CXXFLAGS_SAVE + AC_LANG_POP([C++]) + ]) + if test "x$ax_cv_boost_chrono" = "xyes"; then + AC_SUBST(BOOST_CPPFLAGS) + + AC_DEFINE(HAVE_BOOST_CHRONO,,[define if the Boost::Chrono library is available]) + BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'` + + LDFLAGS_SAVE=$LDFLAGS + if test "x$ax_boost_user_chrono_lib" = "x"; then + ax_lib= + for libextension in `ls $BOOSTLIBDIR/libboost_chrono*.so* $BOOSTLIBDIR/libboost_chrono*.dylib* $BOOSTLIBDIR/libboost_chrono*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_chrono.*\)\.so.*$;\1;' -e 's;^lib\(boost_chrono.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_chrono.*\)\.a.*$;\1;'` ; do + ax_lib=${libextension} + AC_CHECK_LIB($ax_lib, exit, + [BOOST_CHRONO_LIB="-l$ax_lib"; AC_SUBST(BOOST_CHRONO_LIB) link_chrono="yes"; break], + [link_chrono="no"]) + done + if test "x$link_chrono" != "xyes"; then + for libextension in `ls $BOOSTLIBDIR/boost_chrono*.dll* $BOOSTLIBDIR/boost_chrono*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_chrono.*\)\.dll.*$;\1;' -e 's;^\(boost_chrono.*\)\.a.*$;\1;'` ; do + ax_lib=${libextension} + AC_CHECK_LIB($ax_lib, exit, + [BOOST_CHRONO_LIB="-l$ax_lib"; AC_SUBST(BOOST_CHRONO_LIB) link_chrono="yes"; break], + [link_chrono="no"]) + done + fi + + else + for ax_lib in $ax_boost_user_chrono_lib boost_chrono-$ax_boost_user_chrono_lib; do + AC_CHECK_LIB($ax_lib, exit, + [BOOST_CHRONO_LIB="-l$ax_lib"; AC_SUBST(BOOST_CHRONO_LIB) link_chrono="yes"; break], + [link_chrono="no"]) + done + + fi + if test "x$ax_lib" = "x"; then + AC_MSG_ERROR(Could not find a version of the boost_chrono library!) + fi + if test "x$link_chrono" = "xno"; then + AC_MSG_ERROR(Could not link against $ax_lib !) + fi + fi + + CPPFLAGS="$CPPFLAGS_SAVED" + LDFLAGS="$LDFLAGS_SAVED" + fi +]) diff --git a/build-aux/m4/ax_boost_filesystem.m4 b/build-aux/m4/ax_boost_filesystem.m4 new file mode 100644 index 000000000..f5c9d5647 --- /dev/null +++ b/build-aux/m4/ax_boost_filesystem.m4 @@ -0,0 +1,119 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_boost_filesystem.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_BOOST_FILESYSTEM +# +# DESCRIPTION +# +# Test for Filesystem library from the Boost C++ libraries. The macro +# requires a preceding call to AX_BOOST_BASE. Further documentation is +# available at . +# +# This macro calls: +# +# AC_SUBST(BOOST_FILESYSTEM_LIB) +# +# And sets: +# +# HAVE_BOOST_FILESYSTEM +# +# LICENSE +# +# Copyright (c) 2009 Thomas Porschberg +# Copyright (c) 2009 Michael Tindal +# Copyright (c) 2009 Roman Rybalko +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 26 + +AC_DEFUN([AX_BOOST_FILESYSTEM], +[ + AC_ARG_WITH([boost-filesystem], + AS_HELP_STRING([--with-boost-filesystem@<:@=special-lib@:>@], + [use the Filesystem library from boost - it is possible to specify a certain library for the linker + e.g. --with-boost-filesystem=boost_filesystem-gcc-mt ]), + [ + if test "$withval" = "no"; then + want_boost="no" + elif test "$withval" = "yes"; then + want_boost="yes" + ax_boost_user_filesystem_lib="" + else + want_boost="yes" + ax_boost_user_filesystem_lib="$withval" + fi + ], + [want_boost="yes"] + ) + + if test "x$want_boost" = "xyes"; then + AC_REQUIRE([AC_PROG_CC]) + CPPFLAGS_SAVED="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" + export CPPFLAGS + + LDFLAGS_SAVED="$LDFLAGS" + LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" + export LDFLAGS + + LIBS_SAVED=$LIBS + LIBS="$LIBS $BOOST_SYSTEM_LIB" + export LIBS + + AC_CACHE_CHECK(whether the Boost::Filesystem library is available, + ax_cv_boost_filesystem, + [AC_LANG_PUSH([C++]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include ]], + [[using namespace boost::filesystem; + path my_path( "foo/bar/data.txt" ); + return 0;]])], + ax_cv_boost_filesystem=yes, ax_cv_boost_filesystem=no) + AC_LANG_POP([C++]) + ]) + if test "x$ax_cv_boost_filesystem" = "xyes"; then + AC_DEFINE(HAVE_BOOST_FILESYSTEM,,[define if the Boost::Filesystem library is available]) + BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'` + ax_lib= + if test "x$ax_boost_user_filesystem_lib" = "x"; then + for libextension in `ls -r $BOOSTLIBDIR/libboost_filesystem* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'` ; do + ax_lib=${libextension} + AC_CHECK_LIB($ax_lib, exit, + [BOOST_FILESYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_FILESYSTEM_LIB) link_filesystem="yes"; break], + [link_filesystem="no"]) + done + if test "x$link_filesystem" != "xyes"; then + for libextension in `ls -r $BOOSTLIBDIR/boost_filesystem* 2>/dev/null | sed 's,.*/,,' | sed -e 's,\..*,,'` ; do + ax_lib=${libextension} + AC_CHECK_LIB($ax_lib, exit, + [BOOST_FILESYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_FILESYSTEM_LIB) link_filesystem="yes"; break], + [link_filesystem="no"]) + done + fi + else + for ax_lib in $ax_boost_user_filesystem_lib boost_filesystem-$ax_boost_user_filesystem_lib; do + AC_CHECK_LIB($ax_lib, exit, + [BOOST_FILESYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_FILESYSTEM_LIB) link_filesystem="yes"; break], + [link_filesystem="no"]) + done + + fi + if test "x$ax_lib" = "x"; then + AC_MSG_ERROR(Could not find a version of the boost_filesystem library!) + fi + if test "x$link_filesystem" != "xyes"; then + AC_MSG_ERROR(Could not link against $ax_lib !) + fi + fi + + CPPFLAGS="$CPPFLAGS_SAVED" + LDFLAGS="$LDFLAGS_SAVED" + LIBS="$LIBS_SAVED" + fi +]) diff --git a/build-aux/m4/ax_boost_program_options.m4 b/build-aux/m4/ax_boost_program_options.m4 new file mode 100644 index 000000000..2bdb59371 --- /dev/null +++ b/build-aux/m4/ax_boost_program_options.m4 @@ -0,0 +1,108 @@ +# ============================================================================ +# http://www.gnu.org/software/autoconf-archive/ax_boost_program_options.html +# ============================================================================ +# +# SYNOPSIS +# +# AX_BOOST_PROGRAM_OPTIONS +# +# DESCRIPTION +# +# Test for program options library from the Boost C++ libraries. The macro +# requires a preceding call to AX_BOOST_BASE. Further documentation is +# available at . +# +# This macro calls: +# +# AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) +# +# And sets: +# +# HAVE_BOOST_PROGRAM_OPTIONS +# +# LICENSE +# +# Copyright (c) 2009 Thomas Porschberg +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 24 + +AC_DEFUN([AX_BOOST_PROGRAM_OPTIONS], +[ + AC_ARG_WITH([boost-program-options], + AS_HELP_STRING([--with-boost-program-options@<:@=special-lib@:>@], + [use the program options library from boost - it is possible to specify a certain library for the linker + e.g. --with-boost-program-options=boost_program_options-gcc-mt-1_33_1 ]), + [ + if test "$withval" = "no"; then + want_boost="no" + elif test "$withval" = "yes"; then + want_boost="yes" + ax_boost_user_program_options_lib="" + else + want_boost="yes" + ax_boost_user_program_options_lib="$withval" + fi + ], + [want_boost="yes"] + ) + + if test "x$want_boost" = "xyes"; then + AC_REQUIRE([AC_PROG_CC]) + export want_boost + CPPFLAGS_SAVED="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" + export CPPFLAGS + LDFLAGS_SAVED="$LDFLAGS" + LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" + export LDFLAGS + AC_CACHE_CHECK([whether the Boost::Program_Options library is available], + ax_cv_boost_program_options, + [AC_LANG_PUSH(C++) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include + ]], + [[boost::program_options::error err("Error message"); + return 0;]])], + ax_cv_boost_program_options=yes, ax_cv_boost_program_options=no) + AC_LANG_POP([C++]) + ]) + if test "$ax_cv_boost_program_options" = yes; then + AC_DEFINE(HAVE_BOOST_PROGRAM_OPTIONS,,[define if the Boost::PROGRAM_OPTIONS library is available]) + BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'` + if test "x$ax_boost_user_program_options_lib" = "x"; then + for libextension in `ls $BOOSTLIBDIR/libboost_program_options*.so* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_program_options.*\)\.so.*$;\1;'` `ls $BOOSTLIBDIR/libboost_program_options*.dylib* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_program_options.*\)\.dylib.*$;\1;'` `ls $BOOSTLIBDIR/libboost_program_options*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_program_options.*\)\.a.*$;\1;'` ; do + ax_lib=${libextension} + AC_CHECK_LIB($ax_lib, exit, + [BOOST_PROGRAM_OPTIONS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) link_program_options="yes"; break], + [link_program_options="no"]) + done + if test "x$link_program_options" != "xyes"; then + for libextension in `ls $BOOSTLIBDIR/boost_program_options*.dll* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_program_options.*\)\.dll.*$;\1;'` `ls $BOOSTLIBDIR/boost_program_options*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_program_options.*\)\.a.*$;\1;'` ; do + ax_lib=${libextension} + AC_CHECK_LIB($ax_lib, exit, + [BOOST_PROGRAM_OPTIONS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) link_program_options="yes"; break], + [link_program_options="no"]) + done + fi + else + for ax_lib in $ax_boost_user_program_options_lib boost_program_options-$ax_boost_user_program_options_lib; do + AC_CHECK_LIB($ax_lib, main, + [BOOST_PROGRAM_OPTIONS_LIB="-l$ax_lib"; AC_SUBST(BOOST_PROGRAM_OPTIONS_LIB) link_program_options="yes"; break], + [link_program_options="no"]) + done + fi + if test "x$ax_lib" = "x"; then + AC_MSG_ERROR(Could not find a version of the boost_program_options library!) + fi + if test "x$link_program_options" != "xyes"; then + AC_MSG_ERROR([Could not link against [$ax_lib] !]) + fi + fi + CPPFLAGS="$CPPFLAGS_SAVED" + LDFLAGS="$LDFLAGS_SAVED" + fi +]) diff --git a/build-aux/m4/ax_boost_system.m4 b/build-aux/m4/ax_boost_system.m4 new file mode 100644 index 000000000..1c05450cb --- /dev/null +++ b/build-aux/m4/ax_boost_system.m4 @@ -0,0 +1,122 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_boost_system.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_BOOST_SYSTEM +# +# DESCRIPTION +# +# Test for System library from the Boost C++ libraries. The macro requires +# a preceding call to AX_BOOST_BASE. Further documentation is available at +# . +# +# This macro calls: +# +# AC_SUBST(BOOST_SYSTEM_LIB) +# +# And sets: +# +# HAVE_BOOST_SYSTEM +# +# LICENSE +# +# Copyright (c) 2008 Thomas Porschberg +# Copyright (c) 2008 Michael Tindal +# Copyright (c) 2008 Daniel Casimiro +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 18 + +AC_DEFUN([AX_BOOST_SYSTEM], +[ + AC_ARG_WITH([boost-system], + AS_HELP_STRING([--with-boost-system@<:@=special-lib@:>@], + [use the System library from boost - it is possible to specify a certain library for the linker + e.g. --with-boost-system=boost_system-gcc-mt ]), + [ + if test "$withval" = "no"; then + want_boost="no" + elif test "$withval" = "yes"; then + want_boost="yes" + ax_boost_user_system_lib="" + else + want_boost="yes" + ax_boost_user_system_lib="$withval" + fi + ], + [want_boost="yes"] + ) + + if test "x$want_boost" = "xyes"; then + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_BUILD]) + CPPFLAGS_SAVED="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" + export CPPFLAGS + + LDFLAGS_SAVED="$LDFLAGS" + LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" + export LDFLAGS + + AC_CACHE_CHECK(whether the Boost::System library is available, + ax_cv_boost_system, + [AC_LANG_PUSH([C++]) + CXXFLAGS_SAVE=$CXXFLAGS + CXXFLAGS= + + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include ]], + [[boost::system::error_category *a = 0;]])], + ax_cv_boost_system=yes, ax_cv_boost_system=no) + CXXFLAGS=$CXXFLAGS_SAVE + AC_LANG_POP([C++]) + ]) + if test "x$ax_cv_boost_system" = "xyes"; then + AC_SUBST(BOOST_CPPFLAGS) + + AC_DEFINE(HAVE_BOOST_SYSTEM,,[define if the Boost::System library is available]) + BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'` + + LDFLAGS_SAVE=$LDFLAGS + if test "x$ax_boost_user_system_lib" = "x"; then + ax_lib= + for libextension in `ls -r $BOOSTLIBDIR/libboost_system* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'` ; do + ax_lib=${libextension} + AC_CHECK_LIB($ax_lib, exit, + [BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break], + [link_system="no"]) + done + if test "x$link_system" != "xyes"; then + for libextension in `ls -r $BOOSTLIBDIR/boost_system* 2>/dev/null | sed 's,.*/,,' | sed -e 's,\..*,,'` ; do + ax_lib=${libextension} + AC_CHECK_LIB($ax_lib, exit, + [BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break], + [link_system="no"]) + done + fi + + else + for ax_lib in $ax_boost_user_system_lib boost_system-$ax_boost_user_system_lib; do + AC_CHECK_LIB($ax_lib, exit, + [BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break], + [link_system="no"]) + done + + fi + if test "x$ax_lib" = "x"; then + AC_MSG_ERROR(Could not find a version of the boost_system library!) + fi + if test "x$link_system" = "xno"; then + AC_MSG_ERROR(Could not link against $ax_lib !) + fi + fi + + CPPFLAGS="$CPPFLAGS_SAVED" + LDFLAGS="$LDFLAGS_SAVED" + fi +]) diff --git a/build-aux/m4/ax_boost_thread.m4 b/build-aux/m4/ax_boost_thread.m4 new file mode 100644 index 000000000..9f0bd0b23 --- /dev/null +++ b/build-aux/m4/ax_boost_thread.m4 @@ -0,0 +1,150 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_boost_thread.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_BOOST_THREAD +# +# DESCRIPTION +# +# Test for Thread library from the Boost C++ libraries. The macro requires +# a preceding call to AX_BOOST_BASE. Further documentation is available at +# . +# +# This macro calls: +# +# AC_SUBST(BOOST_THREAD_LIB) +# +# And sets: +# +# HAVE_BOOST_THREAD +# +# LICENSE +# +# Copyright (c) 2009 Thomas Porschberg +# Copyright (c) 2009 Michael Tindal +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 27 + +AC_DEFUN([AX_BOOST_THREAD], +[ + AC_ARG_WITH([boost-thread], + AS_HELP_STRING([--with-boost-thread@<:@=special-lib@:>@], + [use the Thread library from boost - it is possible to specify a certain library for the linker + e.g. --with-boost-thread=boost_thread-gcc-mt ]), + [ + if test "$withval" = "no"; then + want_boost="no" + elif test "$withval" = "yes"; then + want_boost="yes" + ax_boost_user_thread_lib="" + else + want_boost="yes" + ax_boost_user_thread_lib="$withval" + fi + ], + [want_boost="yes"] + ) + + if test "x$want_boost" = "xyes"; then + AC_REQUIRE([AC_PROG_CC]) + AC_REQUIRE([AC_CANONICAL_BUILD]) + CPPFLAGS_SAVED="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" + export CPPFLAGS + + LDFLAGS_SAVED="$LDFLAGS" + LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" + export LDFLAGS + + AC_CACHE_CHECK(whether the Boost::Thread library is available, + ax_cv_boost_thread, + [AC_LANG_PUSH([C++]) + CXXFLAGS_SAVE=$CXXFLAGS + + if test "x$host_os" = "xsolaris" ; then + CXXFLAGS="-pthreads $CXXFLAGS" + elif test "x$host_os" = "xmingw32" ; then + CXXFLAGS="-mthreads $CXXFLAGS" + else + CXXFLAGS="-pthread $CXXFLAGS" + fi + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include ]], + [[boost::thread_group thrds; + return 0;]])], + ax_cv_boost_thread=yes, ax_cv_boost_thread=no) + CXXFLAGS=$CXXFLAGS_SAVE + AC_LANG_POP([C++]) + ]) + if test "x$ax_cv_boost_thread" = "xyes"; then + if test "x$host_os" = "xsolaris" ; then + BOOST_CPPFLAGS="-pthreads $BOOST_CPPFLAGS" + elif test "x$host_os" = "xmingw32" ; then + BOOST_CPPFLAGS="-mthreads $BOOST_CPPFLAGS" + else + BOOST_CPPFLAGS="-pthread $BOOST_CPPFLAGS" + fi + + AC_SUBST(BOOST_CPPFLAGS) + + AC_DEFINE(HAVE_BOOST_THREAD,,[define if the Boost::Thread library is available]) + BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'` + + LDFLAGS_SAVE=$LDFLAGS + case "x$host_os" in + *bsd* ) + LDFLAGS="-pthread $LDFLAGS" + break; + ;; + esac + if test "x$ax_boost_user_thread_lib" = "x"; then + ax_lib= + for libextension in `ls -r $BOOSTLIBDIR/libboost_thread* 2>/dev/null | sed 's,.*/lib,,' | sed 's,\..*,,'`; do + ax_lib=${libextension} + AC_CHECK_LIB($ax_lib, exit, + [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break], + [link_thread="no"]) + done + if test "x$link_thread" != "xyes"; then + for libextension in `ls -r $BOOSTLIBDIR/boost_thread* 2>/dev/null | sed 's,.*/,,' | sed 's,\..*,,'`; do + ax_lib=${libextension} + AC_CHECK_LIB($ax_lib, exit, + [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break], + [link_thread="no"]) + done + fi + + else + for ax_lib in $ax_boost_user_thread_lib boost_thread-$ax_boost_user_thread_lib; do + AC_CHECK_LIB($ax_lib, exit, + [BOOST_THREAD_LIB="-l$ax_lib"; AC_SUBST(BOOST_THREAD_LIB) link_thread="yes"; break], + [link_thread="no"]) + done + + fi + if test "x$ax_lib" = "x"; then + AC_MSG_ERROR(Could not find a version of the boost_thread library!) + fi + if test "x$link_thread" = "xno"; then + AC_MSG_ERROR(Could not link against $ax_lib !) + else + case "x$host_os" in + *bsd* ) + BOOST_LDFLAGS="-pthread $BOOST_LDFLAGS" + break; + ;; + esac + + fi + fi + + CPPFLAGS="$CPPFLAGS_SAVED" + LDFLAGS="$LDFLAGS_SAVED" + fi +]) diff --git a/build-aux/m4/ax_boost_unit_test_framework.m4 b/build-aux/m4/ax_boost_unit_test_framework.m4 new file mode 100644 index 000000000..4efd1e2f1 --- /dev/null +++ b/build-aux/m4/ax_boost_unit_test_framework.m4 @@ -0,0 +1,138 @@ +# ================================================================================ +# http://www.gnu.org/software/autoconf-archive/ax_boost_unit_test_framework.html +# ================================================================================ +# +# SYNOPSIS +# +# AX_BOOST_UNIT_TEST_FRAMEWORK +# +# DESCRIPTION +# +# Test for Unit_Test_Framework library from the Boost C++ libraries. The +# macro requires a preceding call to AX_BOOST_BASE. Further documentation +# is available at . +# +# This macro calls: +# +# AC_SUBST(BOOST_UNIT_TEST_FRAMEWORK_LIB) +# +# And sets: +# +# HAVE_BOOST_UNIT_TEST_FRAMEWORK +# +# LICENSE +# +# Copyright (c) 2008 Thomas Porschberg +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 19 + +AC_DEFUN([AX_BOOST_UNIT_TEST_FRAMEWORK], +[ + AC_ARG_WITH([boost-unit-test-framework], + AS_HELP_STRING([--with-boost-unit-test-framework@<:@=special-lib@:>@], + [use the Unit_Test_Framework library from boost - it is possible to specify a certain library for the linker + e.g. --with-boost-unit-test-framework=boost_unit_test_framework-gcc ]), + [ + if test "$withval" = "no"; then + want_boost="no" + elif test "$withval" = "yes"; then + want_boost="yes" + ax_boost_user_unit_test_framework_lib="" + else + want_boost="yes" + ax_boost_user_unit_test_framework_lib="$withval" + fi + ], + [want_boost="yes"] + ) + + if test "x$want_boost" = "xyes"; then + AC_REQUIRE([AC_PROG_CC]) + CPPFLAGS_SAVED="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" + export CPPFLAGS + + LDFLAGS_SAVED="$LDFLAGS" + LDFLAGS="$LDFLAGS $BOOST_LDFLAGS" + export LDFLAGS + + AC_CACHE_CHECK(whether the Boost::Unit_Test_Framework library is available, + ax_cv_boost_unit_test_framework, + [AC_LANG_PUSH([C++]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[@%:@include ]], + [[using boost::unit_test::test_suite; + test_suite* test= BOOST_TEST_SUITE( "Unit test example 1" ); return 0;]])], + ax_cv_boost_unit_test_framework=yes, ax_cv_boost_unit_test_framework=no) + AC_LANG_POP([C++]) + ]) + if test "x$ax_cv_boost_unit_test_framework" = "xyes"; then + AC_DEFINE(HAVE_BOOST_UNIT_TEST_FRAMEWORK,,[define if the Boost::Unit_Test_Framework library is available]) + BOOSTLIBDIR=`echo $BOOST_LDFLAGS | sed -e 's/@<:@^\/@:>@*//'` + + if test "x$ax_boost_user_unit_test_framework_lib" = "x"; then + saved_ldflags="${LDFLAGS}" + ax_lib= + for monitor_library in `ls $BOOSTLIBDIR/libboost_unit_test_framework*.so* $BOOSTLIBDIR/libboost_unit_test_framework*.dylib* $BOOSTLIBDIR/libboost_unit_test_framework*.a* 2>/dev/null` ; do + if test -r $monitor_library ; then + libextension=`echo $monitor_library | sed 's,.*/,,' | sed -e 's;^lib\(boost_unit_test_framework.*\)\.so.*$;\1;' -e 's;^lib\(boost_unit_test_framework.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_unit_test_framework.*\)\.a.*$;\1;'` + ax_lib=${libextension} + link_unit_test_framework="yes" + else + link_unit_test_framework="no" + fi + + if test "x$link_unit_test_framework" = "xyes"; then + BOOST_UNIT_TEST_FRAMEWORK_LIB="-l$ax_lib" + AC_SUBST(BOOST_UNIT_TEST_FRAMEWORK_LIB) + break + fi + done + if test "x$link_unit_test_framework" != "xyes"; then + for libextension in `ls $BOOSTLIBDIR/boost_unit_test_framework*.dll* $BOOSTLIBDIR/boost_unit_test_framework*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_unit_test_framework.*\)\.dll.*$;\1;' -e 's;^\(boost_unit_test_framework.*\)\.a.*$;\1;'` ; do + ax_lib=${libextension} + AC_CHECK_LIB($ax_lib, exit, + [BOOST_UNIT_TEST_FRAMEWORK_LIB="-l$ax_lib"; AC_SUBST(BOOST_UNIT_TEST_FRAMEWORK_LIB) link_unit_test_framework="yes"; break], + [link_unit_test_framework="no"]) + done + fi + else + link_unit_test_framework="no" + saved_ldflags="${LDFLAGS}" + for ax_lib in boost_unit_test_framework-$ax_boost_user_unit_test_framework_lib $ax_boost_user_unit_test_framework_lib ; do + if test "x$link_unit_test_framework" = "xyes"; then + break; + fi + for unittest_library in `ls $BOOSTLIBDIR/lib${ax_lib}.so* $BOOSTLIBDIR/lib${ax_lib}.a* 2>/dev/null` ; do + if test -r $unittest_library ; then + libextension=`echo $unittest_library | sed 's,.*/,,' | sed -e 's;^lib\(boost_unit_test_framework.*\)\.so.*$;\1;' -e 's;^lib\(boost_unit_test_framework.*\)\.a*$;\1;'` + ax_lib=${libextension} + link_unit_test_framework="yes" + else + link_unit_test_framework="no" + fi + + if test "x$link_unit_test_framework" = "xyes"; then + BOOST_UNIT_TEST_FRAMEWORK_LIB="-l$ax_lib" + AC_SUBST(BOOST_UNIT_TEST_FRAMEWORK_LIB) + break + fi + done + done + fi + if test "x$ax_lib" = "x"; then + AC_MSG_ERROR(Could not find a version of the boost_unit_test_framework library!) + fi + if test "x$link_unit_test_framework" != "xyes"; then + AC_MSG_ERROR(Could not link against $ax_lib !) + fi + fi + + CPPFLAGS="$CPPFLAGS_SAVED" + LDFLAGS="$LDFLAGS_SAVED" + fi +]) diff --git a/build-aux/m4/ax_check_compile_flag.m4 b/build-aux/m4/ax_check_compile_flag.m4 new file mode 100644 index 000000000..ca3639715 --- /dev/null +++ b/build-aux/m4/ax_check_compile_flag.m4 @@ -0,0 +1,74 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) +# +# DESCRIPTION +# +# Check whether the given FLAG works with the current language's compiler +# or gives an error. (Warnings, however, are ignored) +# +# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on +# success/failure. +# +# If EXTRA-FLAGS is defined, it is added to the current language's default +# flags (e.g. CFLAGS) when the check is done. The check is thus made with +# the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to +# force the compiler to issue an error when a bad flag is given. +# +# INPUT gives an alternative input source to AC_COMPILE_IFELSE. +# +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this +# macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2011 Maarten Bosmans +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 4 + +AC_DEFUN([AX_CHECK_COMPILE_FLAG], +[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF +AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl +AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ + ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS + _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" + AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], + [AS_VAR_SET(CACHEVAR,[yes])], + [AS_VAR_SET(CACHEVAR,[no])]) + _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) +AS_VAR_IF(CACHEVAR,yes, + [m4_default([$2], :)], + [m4_default([$3], :)]) +AS_VAR_POPDEF([CACHEVAR])dnl +])dnl AX_CHECK_COMPILE_FLAGS diff --git a/build-aux/m4/ax_check_link_flag.m4 b/build-aux/m4/ax_check_link_flag.m4 new file mode 100644 index 000000000..eb01a6ce1 --- /dev/null +++ b/build-aux/m4/ax_check_link_flag.m4 @@ -0,0 +1,74 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_link_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_LINK_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) +# +# DESCRIPTION +# +# Check whether the given FLAG works with the linker or gives an error. +# (Warnings, however, are ignored) +# +# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on +# success/failure. +# +# If EXTRA-FLAGS is defined, it is added to the linker's default flags +# when the check is done. The check is thus made with the flags: "LDFLAGS +# EXTRA-FLAGS FLAG". This can for example be used to force the linker to +# issue an error when a bad flag is given. +# +# INPUT gives an alternative input source to AC_LINK_IFELSE. +# +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this +# macro in sync with AX_CHECK_{PREPROC,COMPILE}_FLAG. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2011 Maarten Bosmans +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 4 + +AC_DEFUN([AX_CHECK_LINK_FLAG], +[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF +AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_ldflags_$4_$1])dnl +AC_CACHE_CHECK([whether the linker accepts $1], CACHEVAR, [ + ax_check_save_flags=$LDFLAGS + LDFLAGS="$LDFLAGS $4 $1" + AC_LINK_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], + [AS_VAR_SET(CACHEVAR,[yes])], + [AS_VAR_SET(CACHEVAR,[no])]) + LDFLAGS=$ax_check_save_flags]) +AS_VAR_IF(CACHEVAR,yes, + [m4_default([$2], :)], + [m4_default([$3], :)]) +AS_VAR_POPDEF([CACHEVAR])dnl +])dnl AX_CHECK_LINK_FLAGS diff --git a/build-aux/m4/ax_check_preproc_flag.m4 b/build-aux/m4/ax_check_preproc_flag.m4 new file mode 100644 index 000000000..ca1d5ee2b --- /dev/null +++ b/build-aux/m4/ax_check_preproc_flag.m4 @@ -0,0 +1,74 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_check_preproc_flag.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CHECK_PREPROC_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) +# +# DESCRIPTION +# +# Check whether the given FLAG works with the current language's +# preprocessor or gives an error. (Warnings, however, are ignored) +# +# ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on +# success/failure. +# +# If EXTRA-FLAGS is defined, it is added to the preprocessor's default +# flags when the check is done. The check is thus made with the flags: +# "CPPFLAGS EXTRA-FLAGS FLAG". This can for example be used to force the +# preprocessor to issue an error when a bad flag is given. +# +# INPUT gives an alternative input source to AC_PREPROC_IFELSE. +# +# NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this +# macro in sync with AX_CHECK_{COMPILE,LINK}_FLAG. +# +# LICENSE +# +# Copyright (c) 2008 Guido U. Draheim +# Copyright (c) 2011 Maarten Bosmans +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 4 + +AC_DEFUN([AX_CHECK_PREPROC_FLAG], +[AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF +AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]cppflags_$4_$1])dnl +AC_CACHE_CHECK([whether _AC_LANG preprocessor accepts $1], CACHEVAR, [ + ax_check_save_flags=$CPPFLAGS + CPPFLAGS="$CPPFLAGS $4 $1" + AC_PREPROC_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], + [AS_VAR_SET(CACHEVAR,[yes])], + [AS_VAR_SET(CACHEVAR,[no])]) + CPPFLAGS=$ax_check_save_flags]) +AS_VAR_IF(CACHEVAR,yes, + [m4_default([$2], :)], + [m4_default([$3], :)]) +AS_VAR_POPDEF([CACHEVAR])dnl +])dnl AX_CHECK_PREPROC_FLAGS diff --git a/build-aux/m4/ax_cxx_compile_stdcxx.m4 b/build-aux/m4/ax_cxx_compile_stdcxx.m4 new file mode 100644 index 000000000..3d45bae9d --- /dev/null +++ b/build-aux/m4/ax_cxx_compile_stdcxx.m4 @@ -0,0 +1,567 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional]) +# +# DESCRIPTION +# +# Check for baseline language coverage in the compiler for the specified +# version of the C++ standard. If necessary, add switches to CXX and +# CXXCPP to enable support. VERSION may be '11' (for the C++11 standard) +# or '14' (for the C++14 standard). +# +# The second argument, if specified, indicates whether you insist on an +# extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. +# -std=c++11). If neither is specified, you get whatever works, with +# preference for an extended mode. +# +# The third argument, if specified 'mandatory' or if left unspecified, +# indicates that baseline support for the specified C++ standard is +# required and that the macro should error out if no mode with that +# support is found. If specified 'optional', then configuration proceeds +# regardless, after defining HAVE_CXX${VERSION} if and only if a +# supporting mode is found. +# +# LICENSE +# +# Copyright (c) 2008 Benjamin Kosnik +# Copyright (c) 2012 Zack Weinberg +# Copyright (c) 2013 Roy Stogner +# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov +# Copyright (c) 2015 Paul Norman +# Copyright (c) 2015 Moritz Klammler +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 4 + +dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro +dnl (serial version number 13). + +AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl + m4_if([$1], [11], [], + [$1], [14], [], + [$1], [17], [m4_fatal([support for C++17 not yet implemented in AX_CXX_COMPILE_STDCXX])], + [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl + m4_if([$2], [], [], + [$2], [ext], [], + [$2], [noext], [], + [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl + m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true], + [$3], [mandatory], [ax_cxx_compile_cxx$1_required=true], + [$3], [optional], [ax_cxx_compile_cxx$1_required=false], + [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])]) + m4_if([$4], [], [ax_cxx_compile_cxx$1_try_default=true], + [$4], [default], [ax_cxx_compile_cxx$1_try_default=true], + [$4], [nodefault], [ax_cxx_compile_cxx$1_try_default=false], + [m4_fatal([invalid fourth argument `$4' to AX_CXX_COMPILE_STDCXX])]) + AC_LANG_PUSH([C++])dnl + ac_success=no + m4_if([$4], [nodefault], [], [dnl + AC_CACHE_CHECK(whether $CXX supports C++$1 features by default, + ax_cv_cxx_compile_cxx$1, + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], + [ax_cv_cxx_compile_cxx$1=yes], + [ax_cv_cxx_compile_cxx$1=no])]) + if test x$ax_cv_cxx_compile_cxx$1 = xyes; then + ac_success=yes + fi]) + + m4_if([$2], [noext], [], [dnl + if test x$ac_success = xno; then + for switch in -std=gnu++$1 -std=gnu++0x; do + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) + AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, + $cachevar, + [ac_save_CXX="$CXX" + CXX="$CXX $switch" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], + [eval $cachevar=yes], + [eval $cachevar=no]) + CXX="$ac_save_CXX"]) + if eval test x\$$cachevar = xyes; then + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi + ac_success=yes + break + fi + done + fi]) + + m4_if([$2], [ext], [], [dnl + if test x$ac_success = xno; then + dnl HP's aCC needs +std=c++11 according to: + dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf + dnl Cray's crayCC needs "-h std=c++11" + for switch in -std=c++$1 -std=c++0x +std=c++$1 "-h std=c++$1"; do + cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) + AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, + $cachevar, + [ac_save_CXX="$CXX" + CXX="$CXX $switch" + AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], + [eval $cachevar=yes], + [eval $cachevar=no]) + CXX="$ac_save_CXX"]) + if eval test x\$$cachevar = xyes; then + CXX="$CXX $switch" + if test -n "$CXXCPP" ; then + CXXCPP="$CXXCPP $switch" + fi + ac_success=yes + break + fi + done + fi]) + AC_LANG_POP([C++]) + if test x$ax_cxx_compile_cxx$1_required = xtrue; then + if test x$ac_success = xno; then + AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.]) + fi + fi + if test x$ac_success = xno; then + HAVE_CXX$1=0 + AC_MSG_NOTICE([No compiler with C++$1 support was found]) + else + HAVE_CXX$1=1 + AC_DEFINE(HAVE_CXX$1,1, + [define if the compiler supports basic C++$1 syntax]) + fi + AC_SUBST(HAVE_CXX$1) +]) + + +dnl Test body for checking C++11 support + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11], + _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 +) + + +dnl Test body for checking C++14 support + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], + _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 + _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 +) + + +dnl Tests for new features in C++11 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[ + +// If the compiler admits that it is not ready for C++11, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201103L + +#error "This is not a C++11 compiler" + +#else + +namespace cxx11 +{ + + namespace test_static_assert + { + + template + struct check + { + static_assert(sizeof(int) <= sizeof(T), "not big enough"); + }; + + } + + namespace test_final_override + { + + struct Base + { + virtual void f() {} + }; + + struct Derived : public Base + { + virtual void f() override {} + }; + + } + + namespace test_double_right_angle_brackets + { + + template < typename T > + struct check {}; + + typedef check single_type; + typedef check> double_type; + typedef check>> triple_type; + typedef check>>> quadruple_type; + + } + + namespace test_decltype + { + + int + f() + { + int a = 1; + decltype(a) b = 2; + return a + b; + } + + } + + namespace test_type_deduction + { + + template < typename T1, typename T2 > + struct is_same + { + static const bool value = false; + }; + + template < typename T > + struct is_same + { + static const bool value = true; + }; + + template < typename T1, typename T2 > + auto + add(T1 a1, T2 a2) -> decltype(a1 + a2) + { + return a1 + a2; + } + + int + test(const int c, volatile int v) + { + static_assert(is_same::value == true, ""); + static_assert(is_same::value == false, ""); + static_assert(is_same::value == false, ""); + auto ac = c; + auto av = v; + auto sumi = ac + av + 'x'; + auto sumf = ac + av + 1.0; + static_assert(is_same::value == true, ""); + static_assert(is_same::value == true, ""); + static_assert(is_same::value == true, ""); + static_assert(is_same::value == false, ""); + static_assert(is_same::value == true, ""); + return (sumf > 0.0) ? sumi : add(c, v); + } + + } + + namespace test_noexcept + { + + int f() { return 0; } + int g() noexcept { return 0; } + + static_assert(noexcept(f()) == false, ""); + static_assert(noexcept(g()) == true, ""); + + } + + namespace test_constexpr + { + + template < typename CharT > + unsigned long constexpr + strlen_c_r(const CharT *const s, const unsigned long acc) noexcept + { + return *s ? strlen_c_r(s + 1, acc + 1) : acc; + } + + template < typename CharT > + unsigned long constexpr + strlen_c(const CharT *const s) noexcept + { + return strlen_c_r(s, 0UL); + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("1") == 1UL, ""); + static_assert(strlen_c("example") == 7UL, ""); + static_assert(strlen_c("another\0example") == 7UL, ""); + + } + + namespace test_rvalue_references + { + + template < int N > + struct answer + { + static constexpr int value = N; + }; + + answer<1> f(int&) { return answer<1>(); } + answer<2> f(const int&) { return answer<2>(); } + answer<3> f(int&&) { return answer<3>(); } + + void + test() + { + int i = 0; + const int c = 0; + static_assert(decltype(f(i))::value == 1, ""); + static_assert(decltype(f(c))::value == 2, ""); + static_assert(decltype(f(0))::value == 3, ""); + } + + } + + namespace test_uniform_initialization + { + + struct test + { + static const int zero {}; + static const int one {1}; + }; + + static_assert(test::zero == 0, ""); + static_assert(test::one == 1, ""); + + } + + namespace test_lambdas + { + + void + test1() + { + auto lambda1 = [](){}; + auto lambda2 = lambda1; + lambda1(); + lambda2(); + } + + int + test2() + { + auto a = [](int i, int j){ return i + j; }(1, 2); + auto b = []() -> int { return '0'; }(); + auto c = [=](){ return a + b; }(); + auto d = [&](){ return c; }(); + auto e = [a, &b](int x) mutable { + const auto identity = [](int y){ return y; }; + for (auto i = 0; i < a; ++i) + a += b--; + return x + identity(a + b); + }(0); + return a + b + c + d + e; + } + + int + test3() + { + const auto nullary = [](){ return 0; }; + const auto unary = [](int x){ return x; }; + using nullary_t = decltype(nullary); + using unary_t = decltype(unary); + const auto higher1st = [](nullary_t f){ return f(); }; + const auto higher2nd = [unary](nullary_t f1){ + return [unary, f1](unary_t f2){ return f2(unary(f1())); }; + }; + return higher1st(nullary) + higher2nd(nullary)(unary); + } + + } + + namespace test_variadic_templates + { + + template + struct sum; + + template + struct sum + { + static constexpr auto value = N0 + sum::value; + }; + + template <> + struct sum<> + { + static constexpr auto value = 0; + }; + + static_assert(sum<>::value == 0, ""); + static_assert(sum<1>::value == 1, ""); + static_assert(sum<23>::value == 23, ""); + static_assert(sum<1, 2>::value == 3, ""); + static_assert(sum<5, 5, 11>::value == 21, ""); + static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); + + } + + // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae + // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function + // because of this. + namespace test_template_alias_sfinae + { + + struct foo {}; + + template + using member = typename T::member_type; + + template + void func(...) {} + + template + void func(member*) {} + + void test(); + + void test() { func(0); } + + } + +} // namespace cxx11 + +#endif // __cplusplus >= 201103L + +]]) + + +dnl Tests for new features in C++14 + +m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[ + +// If the compiler admits that it is not ready for C++14, why torture it? +// Hopefully, this will speed up the test. + +#ifndef __cplusplus + +#error "This is not a C++ compiler" + +#elif __cplusplus < 201402L + +#error "This is not a C++14 compiler" + +#else + +namespace cxx14 +{ + + namespace test_polymorphic_lambdas + { + + int + test() + { + const auto lambda = [](auto&&... args){ + const auto istiny = [](auto x){ + return (sizeof(x) == 1UL) ? 1 : 0; + }; + const int aretiny[] = { istiny(args)... }; + return aretiny[0]; + }; + return lambda(1, 1L, 1.0f, '1'); + } + + } + + namespace test_binary_literals + { + + constexpr auto ivii = 0b0000000000101010; + static_assert(ivii == 42, "wrong value"); + + } + + namespace test_generalized_constexpr + { + + template < typename CharT > + constexpr unsigned long + strlen_c(const CharT *const s) noexcept + { + auto length = 0UL; + for (auto p = s; *p; ++p) + ++length; + return length; + } + + static_assert(strlen_c("") == 0UL, ""); + static_assert(strlen_c("x") == 1UL, ""); + static_assert(strlen_c("test") == 4UL, ""); + static_assert(strlen_c("another\0test") == 7UL, ""); + + } + + namespace test_lambda_init_capture + { + + int + test() + { + auto x = 0; + const auto lambda1 = [a = x](int b){ return a + b; }; + const auto lambda2 = [a = lambda1(x)](){ return a; }; + return lambda2(); + } + + } + + namespace test_digit_seperators + { + + constexpr auto ten_million = 100'000'000; + static_assert(ten_million == 100000000, ""); + + } + + namespace test_return_type_deduction + { + + auto f(int& x) { return x; } + decltype(auto) g(int& x) { return x; } + + template < typename T1, typename T2 > + struct is_same + { + static constexpr auto value = false; + }; + + template < typename T > + struct is_same + { + static constexpr auto value = true; + }; + + int + test() + { + auto x = 0; + static_assert(is_same::value, ""); + static_assert(is_same::value, ""); + return x; + } + + } + +} // namespace cxx14 + +#endif // __cplusplus >= 201402L + +]]) diff --git a/build-aux/m4/ax_gcc_func_attribute.m4 b/build-aux/m4/ax_gcc_func_attribute.m4 new file mode 100644 index 000000000..c788ca9bd --- /dev/null +++ b/build-aux/m4/ax_gcc_func_attribute.m4 @@ -0,0 +1,223 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_gcc_func_attribute.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_GCC_FUNC_ATTRIBUTE(ATTRIBUTE) +# +# DESCRIPTION +# +# This macro checks if the compiler supports one of GCC's function +# attributes; many other compilers also provide function attributes with +# the same syntax. Compiler warnings are used to detect supported +# attributes as unsupported ones are ignored by default so quieting +# warnings when using this macro will yield false positives. +# +# The ATTRIBUTE parameter holds the name of the attribute to be checked. +# +# If ATTRIBUTE is supported define HAVE_FUNC_ATTRIBUTE_. +# +# The macro caches its result in the ax_cv_have_func_attribute_ +# variable. +# +# The macro currently supports the following function attributes: +# +# alias +# aligned +# alloc_size +# always_inline +# artificial +# cold +# const +# constructor +# constructor_priority for constructor attribute with priority +# deprecated +# destructor +# dllexport +# dllimport +# error +# externally_visible +# flatten +# format +# format_arg +# gnu_inline +# hot +# ifunc +# leaf +# malloc +# noclone +# noinline +# nonnull +# noreturn +# nothrow +# optimize +# pure +# unused +# used +# visibility +# warning +# warn_unused_result +# weak +# weakref +# +# Unsuppored function attributes will be tested with a prototype returning +# an int and not accepting any arguments and the result of the check might +# be wrong or meaningless so use with care. +# +# LICENSE +# +# Copyright (c) 2013 Gabriele Svelto +# +# Copying and distribution of this file, with or without modification, are +# permitted in any medium without royalty provided the copyright notice +# and this notice are preserved. This file is offered as-is, without any +# warranty. + +#serial 3 + +AC_DEFUN([AX_GCC_FUNC_ATTRIBUTE], [ + AS_VAR_PUSHDEF([ac_var], [ax_cv_have_func_attribute_$1]) + + AC_CACHE_CHECK([for __attribute__(($1))], [ac_var], [ + AC_LINK_IFELSE([AC_LANG_PROGRAM([ + m4_case([$1], + [alias], [ + int foo( void ) { return 0; } + int bar( void ) __attribute__(($1("foo"))); + ], + [aligned], [ + int foo( void ) __attribute__(($1(32))); + ], + [alloc_size], [ + void *foo(int a) __attribute__(($1(1))); + ], + [always_inline], [ + inline __attribute__(($1)) int foo( void ) { return 0; } + ], + [artificial], [ + inline __attribute__(($1)) int foo( void ) { return 0; } + ], + [cold], [ + int foo( void ) __attribute__(($1)); + ], + [const], [ + int foo( void ) __attribute__(($1)); + ], + [constructor_priority], [ + int foo( void ) __attribute__((__constructor__(65535/2))); + ], + [constructor], [ + int foo( void ) __attribute__(($1)); + ], + [deprecated], [ + int foo( void ) __attribute__(($1(""))); + ], + [destructor], [ + int foo( void ) __attribute__(($1)); + ], + [dllexport], [ + __attribute__(($1)) int foo( void ) { return 0; } + ], + [dllimport], [ + int foo( void ) __attribute__(($1)); + ], + [error], [ + int foo( void ) __attribute__(($1(""))); + ], + [externally_visible], [ + int foo( void ) __attribute__(($1)); + ], + [flatten], [ + int foo( void ) __attribute__(($1)); + ], + [format], [ + int foo(const char *p, ...) __attribute__(($1(printf, 1, 2))); + ], + [format_arg], [ + char *foo(const char *p) __attribute__(($1(1))); + ], + [gnu_inline], [ + inline __attribute__(($1)) int foo( void ) { return 0; } + ], + [hot], [ + int foo( void ) __attribute__(($1)); + ], + [ifunc], [ + int my_foo( void ) { return 0; } + static int (*resolve_foo(void))(void) { return my_foo; } + int foo( void ) __attribute__(($1("resolve_foo"))); + ], + [leaf], [ + __attribute__(($1)) int foo( void ) { return 0; } + ], + [malloc], [ + void *foo( void ) __attribute__(($1)); + ], + [noclone], [ + int foo( void ) __attribute__(($1)); + ], + [noinline], [ + __attribute__(($1)) int foo( void ) { return 0; } + ], + [nonnull], [ + int foo(char *p) __attribute__(($1(1))); + ], + [noreturn], [ + void foo( void ) __attribute__(($1)); + ], + [nothrow], [ + int foo( void ) __attribute__(($1)); + ], + [optimize], [ + __attribute__(($1(3))) int foo( void ) { return 0; } + ], + [pure], [ + int foo( void ) __attribute__(($1)); + ], + [unused], [ + int foo( void ) __attribute__(($1)); + ], + [used], [ + int foo( void ) __attribute__(($1)); + ], + [visibility], [ + int foo_def( void ) __attribute__(($1("default"))); + int foo_hid( void ) __attribute__(($1("hidden"))); + int foo_int( void ) __attribute__(($1("internal"))); + int foo_pro( void ) __attribute__(($1("protected"))); + ], + [warning], [ + int foo( void ) __attribute__(($1(""))); + ], + [warn_unused_result], [ + int foo( void ) __attribute__(($1)); + ], + [weak], [ + int foo( void ) __attribute__(($1)); + ], + [weakref], [ + static int foo( void ) { return 0; } + static int bar( void ) __attribute__(($1("foo"))); + ], + [ + m4_warn([syntax], [Unsupported attribute $1, the test may fail]) + int foo( void ) __attribute__(($1)); + ] + )], []) + ], + dnl GCC doesn't exit with an error if an unknown attribute is + dnl provided but only outputs a warning, so accept the attribute + dnl only if no warning were issued. + [AS_IF([test -s conftest.err], + [AS_VAR_SET([ac_var], [no])], + [AS_VAR_SET([ac_var], [yes])])], + [AS_VAR_SET([ac_var], [no])]) + ]) + + AS_IF([test yes = AS_VAR_GET([ac_var])], + [AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_FUNC_ATTRIBUTE_$1), 1, + [Define to 1 if the system has the `$1' function attribute])], []) + + AS_VAR_POPDEF([ac_var]) +]) diff --git a/build-aux/m4/ax_pthread.m4 b/build-aux/m4/ax_pthread.m4 new file mode 100644 index 000000000..4c4051ea3 --- /dev/null +++ b/build-aux/m4/ax_pthread.m4 @@ -0,0 +1,485 @@ +# =========================================================================== +# http://www.gnu.org/software/autoconf-archive/ax_pthread.html +# =========================================================================== +# +# SYNOPSIS +# +# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) +# +# DESCRIPTION +# +# This macro figures out how to build C programs using POSIX threads. It +# sets the PTHREAD_LIBS output variable to the threads library and linker +# flags, and the PTHREAD_CFLAGS output variable to any special C compiler +# flags that are needed. (The user can also force certain compiler +# flags/libs to be tested by setting these environment variables.) +# +# Also sets PTHREAD_CC to any special C compiler that is needed for +# multi-threaded programs (defaults to the value of CC otherwise). (This +# is necessary on AIX to use the special cc_r compiler alias.) +# +# NOTE: You are assumed to not only compile your program with these flags, +# but also to link with them as well. For example, you might link with +# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS +# +# If you are only building threaded programs, you may wish to use these +# variables in your default LIBS, CFLAGS, and CC: +# +# LIBS="$PTHREAD_LIBS $LIBS" +# CFLAGS="$CFLAGS $PTHREAD_CFLAGS" +# CC="$PTHREAD_CC" +# +# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant +# has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to +# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX). +# +# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the +# PTHREAD_PRIO_INHERIT symbol is defined when compiling with +# PTHREAD_CFLAGS. +# +# ACTION-IF-FOUND is a list of shell commands to run if a threads library +# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it +# is not found. If ACTION-IF-FOUND is not specified, the default action +# will define HAVE_PTHREAD. +# +# Please let the authors know if this macro fails on any platform, or if +# you have any other suggestions or comments. This macro was based on work +# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help +# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by +# Alejandro Forero Cuervo to the autoconf macro repository. We are also +# grateful for the helpful feedback of numerous users. +# +# Updated for Autoconf 2.68 by Daniel Richard G. +# +# LICENSE +# +# Copyright (c) 2008 Steven G. Johnson +# Copyright (c) 2011 Daniel Richard G. +# +# This program is free software: you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by the +# Free Software Foundation, either version 3 of the License, or (at your +# option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General +# Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program. If not, see . +# +# As a special exception, the respective Autoconf Macro's copyright owner +# gives unlimited permission to copy, distribute and modify the configure +# scripts that are the output of Autoconf when processing the Macro. You +# need not follow the terms of the GNU General Public License when using +# or distributing such scripts, even though portions of the text of the +# Macro appear in them. The GNU General Public License (GPL) does govern +# all other use of the material that constitutes the Autoconf Macro. +# +# This special exception to the GPL applies to versions of the Autoconf +# Macro released by the Autoconf Archive. When you make and distribute a +# modified version of the Autoconf Macro, you may extend this special +# exception to the GPL to apply to your modified version as well. + +#serial 23 + +AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) +AC_DEFUN([AX_PTHREAD], [ +AC_REQUIRE([AC_CANONICAL_HOST]) +AC_REQUIRE([AC_PROG_CC]) +AC_REQUIRE([AC_PROG_SED]) +AC_LANG_PUSH([C]) +ax_pthread_ok=no + +# We used to check for pthread.h first, but this fails if pthread.h +# requires special compiler flags (e.g. on Tru64 or Sequent). +# It gets checked for in the link test anyway. + +# First of all, check if the user has set any of the PTHREAD_LIBS, +# etcetera environment variables, and if threads linking works using +# them: +if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then + ax_pthread_save_CC="$CC" + ax_pthread_save_CFLAGS="$CFLAGS" + ax_pthread_save_LIBS="$LIBS" + AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"]) + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" + AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS]) + AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes]) + AC_MSG_RESULT([$ax_pthread_ok]) + if test "x$ax_pthread_ok" = "xno"; then + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" + fi + CC="$ax_pthread_save_CC" + CFLAGS="$ax_pthread_save_CFLAGS" + LIBS="$ax_pthread_save_LIBS" +fi + +# We must check for the threads library under a number of different +# names; the ordering is very important because some systems +# (e.g. DEC) have both -lpthread and -lpthreads, where one of the +# libraries is broken (non-POSIX). + +# Create a list of thread flags to try. Items starting with a "-" are +# C compiler flags, and other items are library names, except for "none" +# which indicates that we try without any flags at all, and "pthread-config" +# which is a program returning the flags for the Pth emulation library. + +ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" + +# The ordering *is* (sometimes) important. Some notes on the +# individual items follow: + +# pthreads: AIX (must check this before -lpthread) +# none: in case threads are in libc; should be tried before -Kthread and +# other compiler flags to prevent continual compiler warnings +# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) +# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64 +# (Note: HP C rejects this with "bad form for `-t' option") +# -pthreads: Solaris/gcc (Note: HP C also rejects) +# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it +# doesn't hurt to check since this sometimes defines pthreads and +# -D_REENTRANT too), HP C (must be checked before -lpthread, which +# is present but should not be used directly; and before -mthreads, +# because the compiler interprets this as "-mt" + "-hreads") +# -mthreads: Mingw32/gcc, Lynx/gcc +# pthread: Linux, etcetera +# --thread-safe: KAI C++ +# pthread-config: use pthread-config program (for GNU Pth library) + +case $host_os in + + freebsd*) + + # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) + # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) + + ax_pthread_flags="-kthread lthread $ax_pthread_flags" + ;; + + hpux*) + + # From the cc(1) man page: "[-mt] Sets various -D flags to enable + # multi-threading and also sets -lpthread." + + ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags" + ;; + + openedition*) + + # IBM z/OS requires a feature-test macro to be defined in order to + # enable POSIX threads at all, so give the user a hint if this is + # not set. (We don't define these ourselves, as they can affect + # other portions of the system API in unpredictable ways.) + + AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING], + [ +# if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS) + AX_PTHREAD_ZOS_MISSING +# endif + ], + [AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])]) + ;; + + solaris*) + + # On Solaris (at least, for some versions), libc contains stubbed + # (non-functional) versions of the pthreads routines, so link-based + # tests will erroneously succeed. (N.B.: The stubs are missing + # pthread_cleanup_push, or rather a function called by this macro, + # so we could check for that, but who knows whether they'll stub + # that too in a future libc.) So we'll check first for the + # standard Solaris way of linking pthreads (-mt -lpthread). + + ax_pthread_flags="-mt,pthread pthread $ax_pthread_flags" + ;; +esac + +# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC) + +AS_IF([test "x$GCC" = "xyes"], + [ax_pthread_flags="-pthread -pthreads $ax_pthread_flags"]) + +# The presence of a feature test macro requesting re-entrant function +# definitions is, on some systems, a strong hint that pthreads support is +# correctly enabled + +case $host_os in + darwin* | hpux* | linux* | osf* | solaris*) + ax_pthread_check_macro="_REENTRANT" + ;; + + aix*) + ax_pthread_check_macro="_THREAD_SAFE" + ;; + + *) + ax_pthread_check_macro="--" + ;; +esac +AS_IF([test "x$ax_pthread_check_macro" = "x--"], + [ax_pthread_check_cond=0], + [ax_pthread_check_cond="!defined($ax_pthread_check_macro)"]) + +# Are we compiling with Clang? + +AC_CACHE_CHECK([whether $CC is Clang], + [ax_cv_PTHREAD_CLANG], + [ax_cv_PTHREAD_CLANG=no + # Note that Autoconf sets GCC=yes for Clang as well as GCC + if test "x$GCC" = "xyes"; then + AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG], + [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */ +# if defined(__clang__) && defined(__llvm__) + AX_PTHREAD_CC_IS_CLANG +# endif + ], + [ax_cv_PTHREAD_CLANG=yes]) + fi + ]) +ax_pthread_clang="$ax_cv_PTHREAD_CLANG" + +ax_pthread_clang_warning=no + +# Clang needs special handling, because older versions handle the -pthread +# option in a rather... idiosyncratic way + +if test "x$ax_pthread_clang" = "xyes"; then + + # Clang takes -pthread; it has never supported any other flag + + # (Note 1: This will need to be revisited if a system that Clang + # supports has POSIX threads in a separate library. This tends not + # to be the way of modern systems, but it's conceivable.) + + # (Note 2: On some systems, notably Darwin, -pthread is not needed + # to get POSIX threads support; the API is always present and + # active. We could reasonably leave PTHREAD_CFLAGS empty. But + # -pthread does define _REENTRANT, and while the Darwin headers + # ignore this macro, third-party headers might not.) + + PTHREAD_CFLAGS="-pthread" + PTHREAD_LIBS= + + ax_pthread_ok=yes + + # However, older versions of Clang make a point of warning the user + # that, in an invocation where only linking and no compilation is + # taking place, the -pthread option has no effect ("argument unused + # during compilation"). They expect -pthread to be passed in only + # when source code is being compiled. + # + # Problem is, this is at odds with the way Automake and most other + # C build frameworks function, which is that the same flags used in + # compilation (CFLAGS) are also used in linking. Many systems + # supported by AX_PTHREAD require exactly this for POSIX threads + # support, and in fact it is often not straightforward to specify a + # flag that is used only in the compilation phase and not in + # linking. Such a scenario is extremely rare in practice. + # + # Even though use of the -pthread flag in linking would only print + # a warning, this can be a nuisance for well-run software projects + # that build with -Werror. So if the active version of Clang has + # this misfeature, we search for an option to squash it. + + AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread], + [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG], + [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown + # Create an alternate version of $ac_link that compiles and + # links in two steps (.c -> .o, .o -> exe) instead of one + # (.c -> exe), because the warning occurs only in the second + # step + ax_pthread_save_ac_link="$ac_link" + ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g' + ax_pthread_link_step=`$as_echo "$ac_link" | sed "$ax_pthread_sed"` + ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)" + ax_pthread_save_CFLAGS="$CFLAGS" + for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do + AS_IF([test "x$ax_pthread_try" = "xunknown"], [break]) + CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS" + ac_link="$ax_pthread_save_ac_link" + AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])], + [ac_link="$ax_pthread_2step_ac_link" + AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])], + [break]) + ]) + done + ac_link="$ax_pthread_save_ac_link" + CFLAGS="$ax_pthread_save_CFLAGS" + AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no]) + ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try" + ]) + + case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in + no | unknown) ;; + *) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;; + esac + +fi # $ax_pthread_clang = yes + +if test "x$ax_pthread_ok" = "xno"; then +for ax_pthread_try_flag in $ax_pthread_flags; do + + case $ax_pthread_try_flag in + none) + AC_MSG_CHECKING([whether pthreads work without any flags]) + ;; + + -mt,pthread) + AC_MSG_CHECKING([whether pthreads work with -mt -lpthread]) + PTHREAD_CFLAGS="-mt" + PTHREAD_LIBS="-lpthread" + ;; + + -*) + AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag]) + PTHREAD_CFLAGS="$ax_pthread_try_flag" + ;; + + pthread-config) + AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no]) + AS_IF([test "x$ax_pthread_config" = "xno"], [continue]) + PTHREAD_CFLAGS="`pthread-config --cflags`" + PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" + ;; + + *) + AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag]) + PTHREAD_LIBS="-l$ax_pthread_try_flag" + ;; + esac + + ax_pthread_save_CFLAGS="$CFLAGS" + ax_pthread_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" + + # Check for various functions. We must include pthread.h, + # since some functions may be macros. (On the Sequent, we + # need a special flag -Kthread to make this header compile.) + # We check for pthread_join because it is in -lpthread on IRIX + # while pthread_create is in libc. We check for pthread_attr_init + # due to DEC craziness with -lpthreads. We check for + # pthread_cleanup_push because it is one of the few pthread + # functions on Solaris that doesn't have a non-functional libc stub. + # We try pthread_create on general principles. + + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include +# if $ax_pthread_check_cond +# error "$ax_pthread_check_macro must be defined" +# endif + static void routine(void *a) { a = 0; } + static void *start_routine(void *a) { return a; }], + [pthread_t th; pthread_attr_t attr; + pthread_create(&th, 0, start_routine, 0); + pthread_join(th, 0); + pthread_attr_init(&attr); + pthread_cleanup_push(routine, 0); + pthread_cleanup_pop(0) /* ; */])], + [ax_pthread_ok=yes], + []) + + CFLAGS="$ax_pthread_save_CFLAGS" + LIBS="$ax_pthread_save_LIBS" + + AC_MSG_RESULT([$ax_pthread_ok]) + AS_IF([test "x$ax_pthread_ok" = "xyes"], [break]) + + PTHREAD_LIBS="" + PTHREAD_CFLAGS="" +done +fi + +# Various other checks: +if test "x$ax_pthread_ok" = "xyes"; then + ax_pthread_save_CFLAGS="$CFLAGS" + ax_pthread_save_LIBS="$LIBS" + CFLAGS="$CFLAGS $PTHREAD_CFLAGS" + LIBS="$PTHREAD_LIBS $LIBS" + + # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. + AC_CACHE_CHECK([for joinable pthread attribute], + [ax_cv_PTHREAD_JOINABLE_ATTR], + [ax_cv_PTHREAD_JOINABLE_ATTR=unknown + for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do + AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], + [int attr = $ax_pthread_attr; return attr /* ; */])], + [ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break], + []) + done + ]) + AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \ + test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \ + test "x$ax_pthread_joinable_attr_defined" != "xyes"], + [AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], + [$ax_cv_PTHREAD_JOINABLE_ATTR], + [Define to necessary symbol if this constant + uses a non-standard name on your system.]) + ax_pthread_joinable_attr_defined=yes + ]) + + AC_CACHE_CHECK([whether more special flags are required for pthreads], + [ax_cv_PTHREAD_SPECIAL_FLAGS], + [ax_cv_PTHREAD_SPECIAL_FLAGS=no + case $host_os in + solaris*) + ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS" + ;; + esac + ]) + AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \ + test "x$ax_pthread_special_flags_added" != "xyes"], + [PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS" + ax_pthread_special_flags_added=yes]) + + AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], + [ax_cv_PTHREAD_PRIO_INHERIT], + [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[int i = PTHREAD_PRIO_INHERIT;]])], + [ax_cv_PTHREAD_PRIO_INHERIT=yes], + [ax_cv_PTHREAD_PRIO_INHERIT=no]) + ]) + AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \ + test "x$ax_pthread_prio_inherit_defined" != "xyes"], + [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.]) + ax_pthread_prio_inherit_defined=yes + ]) + + CFLAGS="$ax_pthread_save_CFLAGS" + LIBS="$ax_pthread_save_LIBS" + + # More AIX lossage: compile with *_r variant + if test "x$GCC" != "xyes"; then + case $host_os in + aix*) + AS_CASE(["x/$CC"], + [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6], + [#handle absolute path differently from PATH based program lookup + AS_CASE(["x$CC"], + [x/*], + [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])], + [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])]) + ;; + esac + fi +fi + +test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" + +AC_SUBST([PTHREAD_LIBS]) +AC_SUBST([PTHREAD_CFLAGS]) +AC_SUBST([PTHREAD_CC]) + +# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: +if test "x$ax_pthread_ok" = "xyes"; then + ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1]) + : +else + ax_pthread_ok=no + $2 +fi +AC_LANG_POP +])dnl AX_PTHREAD diff --git a/build-aux/m4/bitcoin_find_bdb48.m4 b/build-aux/m4/bitcoin_find_bdb48.m4 new file mode 100644 index 000000000..ea9c795da --- /dev/null +++ b/build-aux/m4/bitcoin_find_bdb48.m4 @@ -0,0 +1,78 @@ +dnl Copyright (c) 2013-2015 The Bitcoin Core developers +dnl Distributed under the MIT software license, see the accompanying +dnl file COPYING or http://www.opensource.org/licenses/mit-license.php. + +AC_DEFUN([BITCOIN_FIND_BDB48],[ + AC_ARG_VAR(BDB_CFLAGS, [C compiler flags for BerkeleyDB, bypasses autodetection]) + AC_ARG_VAR(BDB_LIBS, [Linker flags for BerkeleyDB, bypasses autodetection]) + + if test "x$BDB_CFLAGS" = "x"; then + AC_MSG_CHECKING([for Berkeley DB C++ headers]) + BDB_CPPFLAGS= + bdbpath=X + bdb48path=X + bdbdirlist= + for _vn in 4.8 48 4 5 5.3 ''; do + for _pfx in b lib ''; do + bdbdirlist="$bdbdirlist ${_pfx}db${_vn}" + done + done + for searchpath in $bdbdirlist ''; do + test -n "${searchpath}" && searchpath="${searchpath}/" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include <${searchpath}db_cxx.h> + ]],[[ + #if !((DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 8) || DB_VERSION_MAJOR > 4) + #error "failed to find bdb 4.8+" + #endif + ]])],[ + if test "x$bdbpath" = "xX"; then + bdbpath="${searchpath}" + fi + ],[ + continue + ]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include <${searchpath}db_cxx.h> + ]],[[ + #if !(DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR == 8) + #error "failed to find bdb 4.8" + #endif + ]])],[ + bdb48path="${searchpath}" + break + ],[]) + done + if test "x$bdbpath" = "xX"; then + AC_MSG_RESULT([no]) + AC_MSG_ERROR([libdb_cxx headers missing, ]AC_PACKAGE_NAME[ requires this library for wallet functionality (--disable-wallet to disable wallet functionality)]) + elif test "x$bdb48path" = "xX"; then + BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdbpath}],db_cxx) + AC_ARG_WITH([incompatible-bdb],[AS_HELP_STRING([--with-incompatible-bdb], [allow using a bdb version other than 4.8])],[ + AC_MSG_WARN([Found Berkeley DB other than 4.8; wallets opened by this build will not be portable!]) + ],[ + AC_MSG_ERROR([Found Berkeley DB other than 4.8, required for portable wallets (--with-incompatible-bdb to ignore or --disable-wallet to disable wallet functionality)]) + ]) + else + BITCOIN_SUBDIR_TO_INCLUDE(BDB_CPPFLAGS,[${bdb48path}],db_cxx) + bdbpath="${bdb48path}" + fi + else + BDB_CPPFLAGS=${BDB_CFLAGS} + fi + AC_SUBST(BDB_CPPFLAGS) + + if test "x$BDB_LIBS" = "x"; then + # TODO: Ideally this could find the library version and make sure it matches the headers being used + for searchlib in db_cxx-4.8 db_cxx db4_cxx; do + AC_CHECK_LIB([$searchlib],[main],[ + BDB_LIBS="-l${searchlib}" + break + ]) + done + if test "x$BDB_LIBS" = "x"; then + AC_MSG_ERROR([libdb_cxx missing, ]AC_PACKAGE_NAME[ requires this library for wallet functionality (--disable-wallet to disable wallet functionality)]) + fi + fi + AC_SUBST(BDB_LIBS) +]) diff --git a/build-aux/m4/bitcoin_qt.m4 b/build-aux/m4/bitcoin_qt.m4 new file mode 100644 index 000000000..ac697dc2e --- /dev/null +++ b/build-aux/m4/bitcoin_qt.m4 @@ -0,0 +1,540 @@ +dnl Copyright (c) 2013-2016 The Bitcoin Core developers +dnl Distributed under the MIT software license, see the accompanying +dnl file COPYING or http://www.opensource.org/licenses/mit-license.php. + +dnl Helper for cases where a qt dependency is not met. +dnl Output: If qt version is auto, set bitcoin_enable_qt to false. Else, exit. +AC_DEFUN([BITCOIN_QT_FAIL],[ + if test "x$bitcoin_qt_want_version" = xauto && test "x$bitcoin_qt_force" != xyes; then + if test "x$bitcoin_enable_qt" != xno; then + AC_MSG_WARN([$1; pivx-qt frontend will not be built]) + fi + bitcoin_enable_qt=no + bitcoin_enable_qt_test=no + else + AC_MSG_ERROR([$1]) + fi +]) + +AC_DEFUN([BITCOIN_QT_CHECK],[ + if test "x$bitcoin_enable_qt" != xno && test "x$bitcoin_qt_want_version" != xno; then + true + $1 + else + true + $2 + fi +]) + +dnl BITCOIN_QT_PATH_PROGS([FOO], [foo foo2], [/path/to/search/first], [continue if missing]) +dnl Helper for finding the path of programs needed for Qt. +dnl Inputs: $1: Variable to be set +dnl Inputs: $2: List of programs to search for +dnl Inputs: $3: Look for $2 here before $PATH +dnl Inputs: $4: If "yes", don't fail if $2 is not found. +dnl Output: $1 is set to the path of $2 if found. $2 are searched in order. +AC_DEFUN([BITCOIN_QT_PATH_PROGS],[ + BITCOIN_QT_CHECK([ + if test "x$3" != x; then + AC_PATH_PROGS($1,$2,,$3) + else + AC_PATH_PROGS($1,$2) + fi + if test "x$$1" = x && test "x$4" != xyes; then + BITCOIN_QT_FAIL([$1 not found]) + fi + ]) +]) + +dnl Initialize qt input. +dnl This must be called before any other BITCOIN_QT* macros to ensure that +dnl input variables are set correctly. +dnl CAUTION: Do not use this inside of a conditional. +AC_DEFUN([BITCOIN_QT_INIT],[ + dnl enable qt support + AC_ARG_WITH([gui], + [AS_HELP_STRING([--with-gui@<:@=no|qt4|qt5|auto@:>@], + [build pivx-qt GUI (default=auto, qt5 tried first)])], + [ + bitcoin_qt_want_version=$withval + if test "x$bitcoin_qt_want_version" = xyes; then + bitcoin_qt_force=yes + bitcoin_qt_want_version=auto + fi + ], + [bitcoin_qt_want_version=auto]) + + AC_ARG_WITH([qt-incdir],[AS_HELP_STRING([--with-qt-incdir=INC_DIR],[specify qt include path (overridden by pkgconfig)])], [qt_include_path=$withval], []) + AC_ARG_WITH([qt-libdir],[AS_HELP_STRING([--with-qt-libdir=LIB_DIR],[specify qt lib path (overridden by pkgconfig)])], [qt_lib_path=$withval], []) + AC_ARG_WITH([qt-plugindir],[AS_HELP_STRING([--with-qt-plugindir=PLUGIN_DIR],[specify qt plugin path (overridden by pkgconfig)])], [qt_plugin_path=$withval], []) + AC_ARG_WITH([qt-translationdir],[AS_HELP_STRING([--with-qt-translationdir=PLUGIN_DIR],[specify qt translation path (overridden by pkgconfig)])], [qt_translation_path=$withval], []) + AC_ARG_WITH([qt-bindir],[AS_HELP_STRING([--with-qt-bindir=BIN_DIR],[specify qt bin path])], [qt_bin_path=$withval], []) + + AC_ARG_WITH([qtdbus], + [AS_HELP_STRING([--with-qtdbus], + [enable DBus support (default is yes if qt is enabled and QtDBus is found)])], + [use_dbus=$withval], + [use_dbus=auto]) + + AC_SUBST(QT_TRANSLATION_DIR,$qt_translation_path) +]) + +dnl Find the appropriate version of Qt libraries and includes. +dnl Inputs: $1: Whether or not pkg-config should be used. yes|no. Default: yes. +dnl Inputs: $2: If $1 is "yes" and --with-gui=auto, which qt version should be +dnl tried first. +dnl Outputs: See _BITCOIN_QT_FIND_LIBS_* +dnl Outputs: Sets variables for all qt-related tools. +dnl Outputs: bitcoin_enable_qt, bitcoin_enable_qt_dbus, bitcoin_enable_qt_test +AC_DEFUN([BITCOIN_QT_CONFIGURE],[ + use_pkgconfig=$1 + + if test "x$use_pkgconfig" = x; then + use_pkgconfig=yes + fi + + if test "x$use_pkgconfig" = xyes; then + BITCOIN_QT_CHECK([_BITCOIN_QT_FIND_LIBS_WITH_PKGCONFIG([$2])]) + else + BITCOIN_QT_CHECK([_BITCOIN_QT_FIND_LIBS_WITHOUT_PKGCONFIG]) + fi + + dnl This is ugly and complicated. Yuck. Works as follows: + dnl We can't discern whether Qt4 builds are static or not. For Qt5, we can + dnl check a header to find out. When Qt is built statically, some plugins must + dnl be linked into the final binary as well. These plugins have changed between + dnl Qt4 and Qt5. With Qt5, languages moved into core and the WindowsIntegration + dnl plugin was added. Since we can't tell if Qt4 is static or not, it is + dnl assumed for windows builds. + dnl _BITCOIN_QT_CHECK_STATIC_PLUGINS does a quick link-check and appends the + dnl results to QT_LIBS. + BITCOIN_QT_CHECK([ + TEMP_CPPFLAGS=$CPPFLAGS + TEMP_CXXFLAGS=$CXXFLAGS + CPPFLAGS="$QT_INCLUDES $CPPFLAGS" + CXXFLAGS="$PIC_FLAGS $CXXFLAGS" + if test "x$bitcoin_qt_got_major_vers" = x5; then + TEMP_CPPFLAGS="$TEMP_CPPFLAGS -DHAVE_QT5" + _BITCOIN_QT_IS_STATIC + if test "x$bitcoin_cv_static_qt" = xyes; then + _BITCOIN_QT_FIND_STATIC_PLUGINS + AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol if qt plugins are static]) + AC_CACHE_CHECK(for Qt < 5.4, bitcoin_cv_need_acc_widget,[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #ifndef QT_VERSION + # include + #endif + ]], + [[ + #if QT_VERSION >= 0x050400 + choke + #endif + ]])], + [bitcoin_cv_need_acc_widget=yes], + [bitcoin_cv_need_acc_widget=no]) + ]) + if test "x$bitcoin_cv_need_acc_widget" = xyes; then + _BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(AccessibleFactory)], [-lqtaccessiblewidgets]) + fi + _BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QMinimalIntegrationPlugin)],[-lqminimal]) + AC_DEFINE(QT_QPA_PLATFORM_MINIMAL, 1, [Define this symbol if the minimal qt platform exists]) + if test "x$TARGET_OS" = xwindows; then + _BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin)],[-lqwindows]) + AC_DEFINE(QT_QPA_PLATFORM_WINDOWS, 1, [Define this symbol if the qt platform is windows]) + elif test "x$TARGET_OS" = xlinux; then + _BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QXcbIntegrationPlugin)],[-lqxcb -lxcb-static]) + AC_DEFINE(QT_QPA_PLATFORM_XCB, 1, [Define this symbol if the qt platform is xcb]) + elif test "x$TARGET_OS" = xdarwin; then + AX_CHECK_LINK_FLAG([[-framework IOKit]],[QT_LIBS="$QT_LIBS -framework IOKit"],[AC_MSG_ERROR(could not iokit framework)]) + _BITCOIN_QT_CHECK_STATIC_PLUGINS([Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin)],[-lqcocoa]) + AC_DEFINE(QT_QPA_PLATFORM_COCOA, 1, [Define this symbol if the qt platform is cocoa]) + fi + fi + else + if test "x$TARGET_OS" = xwindows; then + AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol if qt plugins are static]) + _BITCOIN_QT_CHECK_STATIC_PLUGINS([ + Q_IMPORT_PLUGIN(qcncodecs) + Q_IMPORT_PLUGIN(qjpcodecs) + Q_IMPORT_PLUGIN(qtwcodecs) + Q_IMPORT_PLUGIN(qkrcodecs) + Q_IMPORT_PLUGIN(AccessibleFactory)], + [-lqcncodecs -lqjpcodecs -lqtwcodecs -lqkrcodecs -lqtaccessiblewidgets]) + fi + fi + CPPFLAGS=$TEMP_CPPFLAGS + CXXFLAGS=$TEMP_CXXFLAGS + ]) + + if test "x$use_pkgconfig$qt_bin_path" = xyes; then + if test "x$bitcoin_qt_got_major_vers" = x5; then + qt_bin_path="`$PKG_CONFIG --variable=host_bins Qt5Core 2>/dev/null`" + fi + fi + + if test "x$use_hardening" != xno; then + BITCOIN_QT_CHECK([ + AC_MSG_CHECKING(whether -fPIE can be used with this Qt config) + TEMP_CPPFLAGS=$CPPFLAGS + TEMP_CXXFLAGS=$CXXFLAGS + CPPFLAGS="$QT_INCLUDES $CPPFLAGS" + CXXFLAGS="$PIE_FLAGS $CXXFLAGS" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #ifndef QT_VERSION + # include + #endif + ]], + [[ + #if defined(QT_REDUCE_RELOCATIONS) + choke + #endif + ]])], + [ AC_MSG_RESULT(yes); QT_PIE_FLAGS=$PIE_FLAGS ], + [ AC_MSG_RESULT(no); QT_PIE_FLAGS=$PIC_FLAGS] + ) + CPPFLAGS=$TEMP_CPPFLAGS + CXXFLAGS=$TEMP_CXXFLAGS + ]) + else + BITCOIN_QT_CHECK([ + AC_MSG_CHECKING(whether -fPIC is needed with this Qt config) + TEMP_CPPFLAGS=$CPPFLAGS + CPPFLAGS="$QT_INCLUDES $CPPFLAGS" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #ifndef QT_VERSION + # include + #endif + ]], + [[ + #if defined(QT_REDUCE_RELOCATIONS) + choke + #endif + ]])], + [ AC_MSG_RESULT(no)], + [ AC_MSG_RESULT(yes); QT_PIE_FLAGS=$PIC_FLAGS] + ) + CPPFLAGS=$TEMP_CPPFLAGS + ]) + fi + + BITCOIN_QT_PATH_PROGS([MOC], [moc-qt${bitcoin_qt_got_major_vers} moc${bitcoin_qt_got_major_vers} moc], $qt_bin_path) + BITCOIN_QT_PATH_PROGS([UIC], [uic-qt${bitcoin_qt_got_major_vers} uic${bitcoin_qt_got_major_vers} uic], $qt_bin_path) + BITCOIN_QT_PATH_PROGS([RCC], [rcc-qt${bitcoin_qt_got_major_vers} rcc${bitcoin_qt_got_major_vers} rcc], $qt_bin_path) + BITCOIN_QT_PATH_PROGS([LRELEASE], [lrelease-qt${bitcoin_qt_got_major_vers} lrelease${bitcoin_qt_got_major_vers} lrelease], $qt_bin_path) + BITCOIN_QT_PATH_PROGS([LUPDATE], [lupdate-qt${bitcoin_qt_got_major_vers} lupdate${bitcoin_qt_got_major_vers} lupdate],$qt_bin_path, yes) + + MOC_DEFS='-DHAVE_CONFIG_H -I$(srcdir)' + case $host in + *darwin*) + BITCOIN_QT_CHECK([ + MOC_DEFS="${MOC_DEFS} -DQ_OS_MAC" + base_frameworks="-framework Foundation -framework ApplicationServices -framework AppKit" + AX_CHECK_LINK_FLAG([[$base_frameworks]],[QT_LIBS="$QT_LIBS $base_frameworks"],[AC_MSG_ERROR(could not find base frameworks)]) + ]) + ;; + *mingw*) + BITCOIN_QT_CHECK([ + AX_CHECK_LINK_FLAG([[-mwindows]],[QT_LDFLAGS="$QT_LDFLAGS -mwindows"],[AC_MSG_WARN(-mwindows linker support not detected)]) + ]) + esac + + + dnl enable qt support + AC_MSG_CHECKING(whether to build ]AC_PACKAGE_NAME[ GUI) + BITCOIN_QT_CHECK([ + bitcoin_enable_qt=yes + bitcoin_enable_qt_test=yes + if test "x$have_qt_test" = xno; then + bitcoin_enable_qt_test=no + fi + bitcoin_enable_qt_dbus=no + if test "x$use_dbus" != xno && test "x$have_qt_dbus" = xyes; then + bitcoin_enable_qt_dbus=yes + fi + if test "x$use_dbus" = xyes && test "x$have_qt_dbus" = xno; then + AC_MSG_ERROR([libQtDBus not found. Install libQtDBus or remove --with-qtdbus.]) + fi + if test "x$LUPDATE" = x; then + AC_MSG_WARN([lupdate is required to update qt translations]) + fi + ],[ + bitcoin_enable_qt=no + ]) + AC_MSG_RESULT([$bitcoin_enable_qt (Qt${bitcoin_qt_got_major_vers})]) + + AC_SUBST(QT_PIE_FLAGS) + AC_SUBST(QT_INCLUDES) + AC_SUBST(QT_LIBS) + AC_SUBST(QT_LDFLAGS) + AC_SUBST(QT_DBUS_INCLUDES) + AC_SUBST(QT_DBUS_LIBS) + AC_SUBST(QT_TEST_INCLUDES) + AC_SUBST(QT_TEST_LIBS) + AC_SUBST(QT_SELECT, qt${bitcoin_qt_got_major_vers}) + AC_SUBST(MOC_DEFS) +]) + +dnl All macros below are internal and should _not_ be used from the main +dnl configure.ac. +dnl ---- + +dnl Internal. Check if the included version of Qt is Qt5. +dnl Requires: INCLUDES must be populated as necessary. +dnl Output: bitcoin_cv_qt5=yes|no +AC_DEFUN([_BITCOIN_QT_CHECK_QT5],[ + AC_CACHE_CHECK(for Qt 5, bitcoin_cv_qt5,[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #ifndef QT_VERSION + # include + #endif + ]], + [[ + #if QT_VERSION < 0x050000 + choke + #endif + ]])], + [bitcoin_cv_qt5=yes], + [bitcoin_cv_qt5=no]) +])]) + +dnl Internal. Check if the linked version of Qt was built as static libs. +dnl Requires: Qt5. This check cannot determine if Qt4 is static. +dnl Requires: INCLUDES and LIBS must be populated as necessary. +dnl Output: bitcoin_cv_static_qt=yes|no +dnl Output: Defines QT_STATICPLUGIN if plugins are static. +AC_DEFUN([_BITCOIN_QT_IS_STATIC],[ + AC_CACHE_CHECK(for static Qt, bitcoin_cv_static_qt,[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #ifndef QT_VERSION + # include + #endif + ]], + [[ + #if !defined(QT_STATIC) + choke + #endif + ]])], + [bitcoin_cv_static_qt=yes], + [bitcoin_cv_static_qt=no]) + ]) + if test "x$bitcoin_cv_static_qt" = xyes; then + AC_DEFINE(QT_STATICPLUGIN, 1, [Define this symbol for static Qt plugins]) + fi +]) + +dnl Internal. Check if the link-requirements for static plugins are met. +dnl Requires: INCLUDES and LIBS must be populated as necessary. +dnl Inputs: $1: A series of Q_IMPORT_PLUGIN(). +dnl Inputs: $2: The libraries that resolve $1. +dnl Output: QT_LIBS is prepended or configure exits. +AC_DEFUN([_BITCOIN_QT_CHECK_STATIC_PLUGINS],[ + AC_MSG_CHECKING(for static Qt plugins: $2) + CHECK_STATIC_PLUGINS_TEMP_LIBS="$LIBS" + LIBS="$2 $QT_LIBS $LIBS" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + #define QT_STATICPLUGIN + #include + $1]], + [[return 0;]])], + [AC_MSG_RESULT(yes); QT_LIBS="$2 $QT_LIBS"], + [AC_MSG_RESULT(no); BITCOIN_QT_FAIL(Could not resolve: $2)]) + LIBS="$CHECK_STATIC_PLUGINS_TEMP_LIBS" +]) + +dnl Internal. Find paths necessary for linking qt static plugins +dnl Inputs: bitcoin_qt_got_major_vers. 4 or 5. +dnl Inputs: qt_plugin_path. optional. +dnl Outputs: QT_LIBS is appended +AC_DEFUN([_BITCOIN_QT_FIND_STATIC_PLUGINS],[ + if test "x$bitcoin_qt_got_major_vers" = x5; then + if test "x$qt_plugin_path" != x; then + QT_LIBS="$QT_LIBS -L$qt_plugin_path/platforms" + if test -d "$qt_plugin_path/accessible"; then + QT_LIBS="$QT_LIBS -L$qt_plugin_path/accessible" + fi + fi + if test "x$use_pkgconfig" = xyes; then + : dnl + m4_ifdef([PKG_CHECK_MODULES],[ + PKG_CHECK_MODULES([QTPLATFORM], [Qt5PlatformSupport], [QT_LIBS="$QTPLATFORM_LIBS $QT_LIBS"]) + if test "x$TARGET_OS" = xlinux; then + PKG_CHECK_MODULES([X11XCB], [x11-xcb], [QT_LIBS="$X11XCB_LIBS $QT_LIBS"]) + if ${PKG_CONFIG} --exists "Qt5Core >= 5.5" 2>/dev/null; then + PKG_CHECK_MODULES([QTXCBQPA], [Qt5XcbQpa], [QT_LIBS="$QTXCBQPA_LIBS $QT_LIBS"]) + fi + elif test "x$TARGET_OS" = xdarwin; then + PKG_CHECK_MODULES([QTPRINT], [Qt5PrintSupport], [QT_LIBS="$QTPRINT_LIBS $QT_LIBS"]) + fi + ]) + else + if test "x$TARGET_OS" = xwindows; then + AC_CACHE_CHECK(for Qt >= 5.6, bitcoin_cv_need_platformsupport,[ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include + #ifndef QT_VERSION + # include + #endif + ]], + [[ + #if QT_VERSION < 0x050600 + choke + #endif + ]])], + [bitcoin_cv_need_platformsupport=yes], + [bitcoin_cv_need_platformsupport=no]) + ]) + if test "x$bitcoin_cv_need_platformsupport" = xyes; then + BITCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}PlatformSupport],[main],,BITCOIN_QT_FAIL(lib${QT_LIB_PREFIX}PlatformSupport not found))) + fi + fi + fi + else + if test "x$qt_plugin_path" != x; then + QT_LIBS="$QT_LIBS -L$qt_plugin_path/accessible" + QT_LIBS="$QT_LIBS -L$qt_plugin_path/codecs" + fi + fi +]) + +dnl Internal. Find Qt libraries using pkg-config. +dnl Inputs: bitcoin_qt_want_version (from --with-gui=). The version to check +dnl first. +dnl Inputs: $1: If bitcoin_qt_want_version is "auto", check for this version +dnl first. +dnl Outputs: All necessary QT_* variables are set. +dnl Outputs: bitcoin_qt_got_major_vers is set to "4" or "5". +dnl Outputs: have_qt_test and have_qt_dbus are set (if applicable) to yes|no. +AC_DEFUN([_BITCOIN_QT_FIND_LIBS_WITH_PKGCONFIG],[ + m4_ifdef([PKG_CHECK_MODULES],[ + auto_priority_version=$1 + if test "x$auto_priority_version" = x; then + auto_priority_version=qt5 + fi + if test "x$bitcoin_qt_want_version" = xqt5 || ( test "x$bitcoin_qt_want_version" = xauto && test "x$auto_priority_version" = xqt5 ); then + QT_LIB_PREFIX=Qt5 + bitcoin_qt_got_major_vers=5 + else + QT_LIB_PREFIX=Qt + bitcoin_qt_got_major_vers=4 + fi + qt5_modules="Qt5Core Qt5Gui Qt5Network Qt5Widgets" + qt4_modules="QtCore QtGui QtNetwork" + BITCOIN_QT_CHECK([ + if test "x$bitcoin_qt_want_version" = xqt5 || ( test "x$bitcoin_qt_want_version" = xauto && test "x$auto_priority_version" = xqt5 ); then + PKG_CHECK_MODULES([QT5], [$qt5_modules], [QT_INCLUDES="$QT5_CFLAGS"; QT_LIBS="$QT5_LIBS" have_qt=yes],[have_qt=no]) + elif test "x$bitcoin_qt_want_version" = xqt4 || ( test "x$bitcoin_qt_want_version" = xauto && test "x$auto_priority_version" = xqt4 ); then + PKG_CHECK_MODULES([QT4], [$qt4_modules], [QT_INCLUDES="$QT4_CFLAGS"; QT_LIBS="$QT4_LIBS" ; have_qt=yes], [have_qt=no]) + fi + + dnl qt version is set to 'auto' and the preferred version wasn't found. Now try the other. + if test "x$have_qt" = xno && test "x$bitcoin_qt_want_version" = xauto; then + if test "x$auto_priority_version" = xqt5; then + PKG_CHECK_MODULES([QT4], [$qt4_modules], [QT_INCLUDES="$QT4_CFLAGS"; QT_LIBS="$QT4_LIBS" ; have_qt=yes; QT_LIB_PREFIX=Qt; bitcoin_qt_got_major_vers=4], [have_qt=no]) + else + PKG_CHECK_MODULES([QT5], [$qt5_modules], [QT_INCLUDES="$QT5_CFLAGS"; QT_LIBS="$QT5_LIBS" ; have_qt=yes; QT_LIB_PREFIX=Qt5; bitcoin_qt_got_major_vers=5], [have_qt=no]) + fi + fi + if test "x$have_qt" != xyes; then + have_qt=no + BITCOIN_QT_FAIL([Qt dependencies not found]) + fi + ]) + BITCOIN_QT_CHECK([ + PKG_CHECK_MODULES([QT_TEST], [${QT_LIB_PREFIX}Test], [QT_TEST_INCLUDES="$QT_TEST_CFLAGS"; have_qt_test=yes], [have_qt_test=no]) + if test "x$use_dbus" != xno; then + PKG_CHECK_MODULES([QT_DBUS], [${QT_LIB_PREFIX}DBus], [QT_DBUS_INCLUDES="$QT_DBUS_CFLAGS"; have_qt_dbus=yes], [have_qt_dbus=no]) + fi + ]) + ]) + true; dnl +]) + +dnl Internal. Find Qt libraries without using pkg-config. Version is deduced +dnl from the discovered headers. +dnl Inputs: bitcoin_qt_want_version (from --with-gui=). The version to use. +dnl If "auto", the version will be discovered by _BITCOIN_QT_CHECK_QT5. +dnl Outputs: All necessary QT_* variables are set. +dnl Outputs: bitcoin_qt_got_major_vers is set to "4" or "5". +dnl Outputs: have_qt_test and have_qt_dbus are set (if applicable) to yes|no. +AC_DEFUN([_BITCOIN_QT_FIND_LIBS_WITHOUT_PKGCONFIG],[ + TEMP_CPPFLAGS="$CPPFLAGS" + TEMP_CXXFLAGS="$CXXFLAGS" + CXXFLAGS="$PIC_FLAGS $CXXFLAGS" + TEMP_LIBS="$LIBS" + BITCOIN_QT_CHECK([ + if test "x$qt_include_path" != x; then + QT_INCLUDES="-I$qt_include_path -I$qt_include_path/QtCore -I$qt_include_path/QtGui -I$qt_include_path/QtWidgets -I$qt_include_path/QtNetwork -I$qt_include_path/QtTest -I$qt_include_path/QtDBus" + CPPFLAGS="$QT_INCLUDES $CPPFLAGS" + fi + ]) + + BITCOIN_QT_CHECK([AC_CHECK_HEADER([QtPlugin],,BITCOIN_QT_FAIL(QtCore headers missing))]) + BITCOIN_QT_CHECK([AC_CHECK_HEADER([QApplication],, BITCOIN_QT_FAIL(QtGui headers missing))]) + BITCOIN_QT_CHECK([AC_CHECK_HEADER([QLocalSocket],, BITCOIN_QT_FAIL(QtNetwork headers missing))]) + + BITCOIN_QT_CHECK([ + if test "x$bitcoin_qt_want_version" = xauto; then + _BITCOIN_QT_CHECK_QT5 + fi + if test "x$bitcoin_cv_qt5" = xyes || test "x$bitcoin_qt_want_version" = xqt5; then + QT_LIB_PREFIX=Qt5 + bitcoin_qt_got_major_vers=5 + else + QT_LIB_PREFIX=Qt + bitcoin_qt_got_major_vers=4 + fi + ]) + + BITCOIN_QT_CHECK([ + LIBS= + if test "x$qt_lib_path" != x; then + LIBS="$LIBS -L$qt_lib_path" + fi + + if test "x$TARGET_OS" = xwindows; then + AC_CHECK_LIB([imm32], [main],, BITCOIN_QT_FAIL(libimm32 not found)) + fi + ]) + + BITCOIN_QT_CHECK(AC_CHECK_LIB([z] ,[main],,AC_MSG_WARN([zlib not found. Assuming qt has it built-in]))) + BITCOIN_QT_CHECK(AC_SEARCH_LIBS([png_error] ,[qtpng png],,AC_MSG_WARN([libpng not found. Assuming qt has it built-in]))) + BITCOIN_QT_CHECK(AC_SEARCH_LIBS([jpeg_create_decompress] ,[qtjpeg jpeg],,AC_MSG_WARN([libjpeg not found. Assuming qt has it built-in]))) + BITCOIN_QT_CHECK(AC_SEARCH_LIBS([pcre16_exec], [qtpcre pcre16],,AC_MSG_WARN([libpcre16 not found. Assuming qt has it built-in]))) + BITCOIN_QT_CHECK(AC_SEARCH_LIBS([hb_ot_tags_from_script] ,[qtharfbuzzng harfbuzz],,AC_MSG_WARN([libharfbuzz not found. Assuming qt has it built-in or support is disabled]))) + BITCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Core] ,[main],,BITCOIN_QT_FAIL(lib${QT_LIB_PREFIX}Core not found))) + BITCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Gui] ,[main],,BITCOIN_QT_FAIL(lib${QT_LIB_PREFIX}Gui not found))) + BITCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Network],[main],,BITCOIN_QT_FAIL(lib${QT_LIB_PREFIX}Network not found))) + if test "x$bitcoin_qt_got_major_vers" = x5; then + BITCOIN_QT_CHECK(AC_CHECK_LIB([${QT_LIB_PREFIX}Widgets],[main],,BITCOIN_QT_FAIL(lib${QT_LIB_PREFIX}Widgets not found))) + fi + QT_LIBS="$LIBS" + LIBS="$TEMP_LIBS" + + BITCOIN_QT_CHECK([ + LIBS= + if test "x$qt_lib_path" != x; then + LIBS="-L$qt_lib_path" + fi + AC_CHECK_LIB([${QT_LIB_PREFIX}Test], [main],, have_qt_test=no) + AC_CHECK_HEADER([QTest],, have_qt_test=no) + QT_TEST_LIBS="$LIBS" + if test "x$use_dbus" != xno; then + LIBS= + if test "x$qt_lib_path" != x; then + LIBS="-L$qt_lib_path" + fi + AC_CHECK_LIB([${QT_LIB_PREFIX}DBus], [main],, have_qt_dbus=no) + AC_CHECK_HEADER([QtDBus],, have_qt_dbus=no) + QT_DBUS_LIBS="$LIBS" + fi + ]) + CPPFLAGS="$TEMP_CPPFLAGS" + CXXFLAGS="$TEMP_CXXFLAGS" + LIBS="$TEMP_LIBS" +]) + diff --git a/build-aux/m4/bitcoin_subdir_to_include.m4 b/build-aux/m4/bitcoin_subdir_to_include.m4 new file mode 100644 index 000000000..7841042ac --- /dev/null +++ b/build-aux/m4/bitcoin_subdir_to_include.m4 @@ -0,0 +1,18 @@ +dnl Copyright (c) 2013-2014 The Bitcoin Core developers +dnl Distributed under the MIT software license, see the accompanying +dnl file COPYING or http://www.opensource.org/licenses/mit-license.php. + +dnl BITCOIN_SUBDIR_TO_INCLUDE([CPPFLAGS-VARIABLE-NAME],[SUBDIRECTORY-NAME],[HEADER-FILE]) +dnl SUBDIRECTORY-NAME must end with a path separator +AC_DEFUN([BITCOIN_SUBDIR_TO_INCLUDE],[ + if test "x$2" = "x"; then + AC_MSG_RESULT([default]) + else + echo "#include <$2$3.h>" >conftest.cpp + newinclpath=`${CXXCPP} ${CPPFLAGS} -M conftest.cpp 2>/dev/null | [ tr -d '\\n\\r\\\\' | sed -e 's/^.*[[:space:]:]\(\/[^[:space:]]*\)]$3[\.h[[:space:]].*$/\1/' -e t -e d`] + AC_MSG_RESULT([${newinclpath}]) + if test "x${newinclpath}" != "x"; then + eval "$1=\"\$$1\"' -I${newinclpath}'" + fi + fi +]) diff --git a/build-aux/m4/l_atomic.m4 b/build-aux/m4/l_atomic.m4 new file mode 100644 index 000000000..75c43f9a9 --- /dev/null +++ b/build-aux/m4/l_atomic.m4 @@ -0,0 +1,46 @@ +dnl Copyright (c) 2015 Tim Kosse +dnl Copying and distribution of this file, with or without modification, are +dnl permitted in any medium without royalty provided the copyright notice +dnl and this notice are preserved. This file is offered as-is, without any +dnl warranty. + +# Some versions of gcc/libstdc++ require linking with -latomic if +# using the C++ atomic library. +# +# Sourced from http://bugs.debian.org/797228 + +m4_define([_CHECK_ATOMIC_testbody], [[ + #include + #include + + int main() { + std::atomic a{}; + + int64_t v = 5; + int64_t r = a.fetch_add(v); + return static_cast(r); + } +]]) + +AC_DEFUN([CHECK_ATOMIC], [ + + AC_LANG_PUSH(C++) + + AC_MSG_CHECKING([whether std::atomic can be used without link library]) + + AC_LINK_IFELSE([AC_LANG_SOURCE([_CHECK_ATOMIC_testbody])],[ + AC_MSG_RESULT([yes]) + ],[ + AC_MSG_RESULT([no]) + LIBS="$LIBS -latomic" + AC_MSG_CHECKING([whether std::atomic needs -latomic]) + AC_LINK_IFELSE([AC_LANG_SOURCE([_CHECK_ATOMIC_testbody])],[ + AC_MSG_RESULT([yes]) + ],[ + AC_MSG_RESULT([no]) + AC_MSG_FAILURE([cannot figure out how to use std::atomic]) + ]) + ]) + + AC_LANG_POP +]) diff --git a/compile-hyp.sh b/compile-hyp.sh new file mode 100755 index 000000000..afc6d0725 --- /dev/null +++ b/compile-hyp.sh @@ -0,0 +1,18 @@ +#!/bin/bash +MXE_INCLUDE_PATH=/home/pt/workspace/mxe/usr/i686-w64-mingw32.static/include +MXE_LIB_PATH=/home/pt/workspace/mxe/usr/i686-w64-mingw32.static/lib + +i686-w64-mingw32.static-qmake-qt5 \ + BOOST_LIB_SUFFIX=-mt \ + BOOST_THREAD_LIB_SUFFIX=_win32-mt \ + BOOST_INCLUDE_PATH=$MXE_INCLUDE_PATH/boost \ + BOOST_LIB_PATH=$MXE_LIB_PATH \ + OPENSSL_INCLUDE_PATH=$MXE_INCLUDE_PATH/openssl \ + OPENSSL_LIB_PATH=$MXE_LIB_PATH \ + BDB_INCLUDE_PATH=$MXE_INCLUDE_PATH \ + BDB_LIB_PATH=$MXE_LIB_PATH \ + MINIUPNPC_INCLUDE_PATH=$MXE_INCLUDE_PATH \ + MINIUPNPC_LIB_PATH=$MXE_LIB_PATH \ + QMAKE_LRELEASE=/home/pt/workspace/mxe/usr/i686-w64-mingw32.static/qt5/bin/lrelease HyperStake-qt.pro + +make -j6 -f Makefile.Release diff --git a/configure.ac b/configure.ac new file mode 100644 index 000000000..317bbe3d9 --- /dev/null +++ b/configure.ac @@ -0,0 +1,884 @@ +dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N) +AC_PREREQ([2.60]) +define(_CLIENT_VERSION_MAJOR, 1) +define(_CLIENT_VERSION_MINOR, 1) +define(_CLIENT_VERSION_REVISION, 5) +define(_CLIENT_VERSION_BUILD, 1) +define(_CLIENT_VERSION_IS_RELEASE, true) +define(_COPYRIGHT_YEAR, 2018) +AC_INIT([Hyperstake Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[info@hyperstake.info],[hyperstake]) +AC_CONFIG_SRCDIR([src/main.cpp]) +AC_CONFIG_HEADERS([src/config/bitcoin-config.h]) +AC_CONFIG_AUX_DIR([build-aux]) +AC_CONFIG_MACRO_DIR([build-aux/m4]) + +AC_CANONICAL_HOST + +AH_TOP([#ifndef BITCOIN_CONFIG_H]) +AH_TOP([#define BITCOIN_CONFIG_H]) +AH_BOTTOM([#endif //BITCOIN_CONFIG_H]) + +dnl faketime breaks configure and is only needed for make. Disable it here. +unset FAKETIME + +dnl Automake init set-up and checks +AM_INIT_AUTOMAKE([no-define subdir-objects foreign]) + +dnl faketime messes with timestamps and causes configure to be re-run. +dnl --disable-maintainer-mode can be used to bypass this. +AM_MAINTAINER_MODE([enable]) + +dnl make the compilation flags quiet unless V=1 is used +m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) + +dnl Compiler checks (here before libtool). +if test "x${CXXFLAGS+set}" = "xset"; then + CXXFLAGS_overridden=yes +else + CXXFLAGS_overridden=no +fi +AC_PROG_CXX +dnl ifdef([AC_PROG_OBJCXX],[AC_PROG_OBJCXX]) + +dnl By default, libtool for mingw refuses to link static libs into a dll for +dnl fear of mixing pic/non-pic objects, and import/export complications. Since +dnl we have those under control, re-enable that functionality. +case $host in + *mingw*) + lt_cv_deplibs_check_method="pass_all" + ;; +esac +dnl Require C++11 compiler (no GNU extensions) +AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory]) + +dnl Unless the user specified OBJCXX, force it to be the same as CXX. This ensures +dnl that we get the same -std flags for both. +m4_ifdef([AC_PROG_OBJCXX],[ +if test "x${OBJCXX+set}" = "x"; then + OBJCXX="${CXX}" +fi +AC_PROG_OBJCXX +]) +dnl Libtool init checks. +LT_INIT([pic-only]) + +dnl Check/return PATH for base programs. +AC_PATH_TOOL(AR, ar) +AC_PATH_TOOL(RANLIB, ranlib) +AC_PATH_TOOL(STRIP, strip) +AC_PATH_TOOL(GCOV, gcov) +AC_PATH_PROG(LCOV, lcov) +AC_PATH_PROG(JAVA, java) +AC_PATH_PROG(GENHTML, genhtml) +AC_PATH_PROG([GIT], [git]) +AC_PATH_PROG(CCACHE,ccache) +AC_PATH_PROG(XGETTEXT,xgettext) +AC_PATH_PROG(HEXDUMP,hexdump) + +# This m4 will only be used if a system copy cannot be found. This is helpful +# on systems where autotools are installed but the pkg-config macros are not in +# a default location. It is currently used for building on OSX where autotools +# are preinstalled but pkg-config comes from macports or homebrew. It should +# probably be removed when building on <= 10.6 is no longer supported. +m4_include([pkg.m4]) + +dnl pkg-config check. +PKG_PROG_PKG_CONFIG + +# Enable wallet +AC_ARG_ENABLE([wallet], + [AS_HELP_STRING([--enable-wallet], + [enable wallet (default is yes)])], + [enable_wallet=$enableval], + [enable_wallet=yes]) + +AC_ARG_WITH([miniupnpc], + [AS_HELP_STRING([--with-miniupnpc], + [enable UPNP (default is yes if libminiupnpc is found)])], + [use_upnp=$withval], + [use_upnp=auto]) + +AC_ARG_ENABLE([upnp-default], + [AS_HELP_STRING([--enable-upnp-default], + [if UPNP is enabled, turn it on at startup (default is no)])], + [use_upnp_default=$enableval], + [use_upnp_default=no]) + +AC_ARG_ENABLE(tests, + AS_HELP_STRING([--enable-tests],[compile tests (default is yes)]), + [use_tests=$enableval], + [use_tests=yes]) + +AC_ARG_WITH([comparison-tool], + AS_HELP_STRING([--with-comparison-tool],[path to java comparison tool (requires --enable-tests)]), + [use_comparison_tool=$withval], + [use_comparison_tool=no]) + +AC_ARG_ENABLE([comparison-tool-reorg-tests], + AS_HELP_STRING([--enable-comparison-tool-reorg-tests],[enable expensive reorg tests in the comparison tool (default no)]), + [use_comparison_tool_reorg_tests=$enableval], + [use_comparison_tool_reorg_tests=no]) + +AC_ARG_WITH([qrencode], + [AS_HELP_STRING([--with-qrencode], + [enable QR code support (default is yes if qt is enabled and libqrencode is found)])], + [use_qr=$withval], + [use_qr=auto]) + +AC_ARG_ENABLE([hardening], + [AS_HELP_STRING([--enable-hardening], + [attempt to harden the resulting executables (default is yes)])], + [use_hardening=$enableval], + [use_hardening=yes]) + +AC_ARG_ENABLE([reduce-exports], + [AS_HELP_STRING([--enable-reduce-exports], + [attempt to reduce exported symbols in the resulting executables (default is yes)])], + [use_reduce_exports=$enableval], + [use_reduce_exports=auto]) + +AC_ARG_ENABLE([ccache], + [AS_HELP_STRING([--enable-ccache], + [use ccache for building (default is yes if ccache is found)])], + [use_ccache=$enableval], + [use_ccache=auto]) + +AC_ARG_ENABLE([lcov], + [AS_HELP_STRING([--enable-lcov], + [enable lcov testing (default is no)])], + [use_lcov=yes], + [use_lcov=no]) + +AC_ARG_ENABLE([glibc-back-compat], + [AS_HELP_STRING([--enable-glibc-back-compat], + [enable backwards compatibility with glibc and libstdc++])], + [use_glibc_compat=$enableval], + [use_glibc_compat=no]) + +AC_ARG_WITH([protoc-bindir],[AS_HELP_STRING([--with-protoc-bindir=BIN_DIR],[specify protoc bin path])], [protoc_bin_path=$withval], []) + +# Enable debug +AC_ARG_ENABLE([debug], + [AS_HELP_STRING([--enable-debug], + [use debug compiler flags and macros (default is no)])], + [enable_debug=$enableval], + [enable_debug=no]) + +if test "x$enable_debug" = xyes; then + if test "x$GCC" = xyes; then + CFLAGS="-g3 -O0 -DDEBUG" + fi + + if test "x$GXX" = xyes; then + CXXFLAGS="-g3 -O0 -DDEBUG" + fi +fi + +## TODO: Remove these hard-coded paths and flags. They are here for the sake of +## compatibility with the legacy buildsystem. +## +if test "x$CXXFLAGS_overridden" = "xno"; then + CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter" +fi +CPPFLAGS="$CPPFLAGS -DBOOST_SPIRIT_THREADSAFE -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS" + +AC_LANG_PUSH([C++]) + +use_pkgconfig=yes +case $host in + *mingw*) + + #pkgconfig does more harm than good with MinGW + use_pkgconfig=no + + TARGET_OS=windows + AC_CHECK_LIB([mingwthrd], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([kernel32], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([user32], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([gdi32], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([comdlg32], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([winspool], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([winmm], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([shell32], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([comctl32], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([ole32], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([oleaut32], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([uuid], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([rpcrt4], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([advapi32], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([ws2_32], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([mswsock], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([shlwapi], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([iphlpapi], [main],, AC_MSG_ERROR(lib missing)) + AC_CHECK_LIB([crypt32], [main],, AC_MSG_ERROR(lib missing)) + + # -static is interpreted by libtool, where it has a different meaning. + # In libtool-speak, it's -all-static. + AX_CHECK_LINK_FLAG([[-static]],[LIBTOOL_APP_LDFLAGS="$LIBTOOL_APP_LDFLAGS -all-static"]) + + AC_PATH_PROG([MAKENSIS], [makensis], none) + if test x$MAKENSIS = xnone; then + AC_MSG_WARN("makensis not found. Cannot create installer.") + fi + + AC_PATH_TOOL(WINDRES, windres, none) + if test x$WINDRES = xnone; then + AC_MSG_ERROR("windres not found") + fi + + CPPFLAGS="$CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB" + LEVELDB_TARGET_FLAGS="TARGET_OS=OS_WINDOWS_CROSSCOMPILE" + if test "x$CXXFLAGS_overridden" = "xno"; then + CXXFLAGS="$CXXFLAGS -w" + fi + case $host in + i?86-*) WINDOWS_BITS=32 ;; + x86_64-*) WINDOWS_BITS=64 ;; + *) AC_MSG_ERROR("Could not determine win32/win64 for installer") ;; + esac + AC_SUBST(WINDOWS_BITS) + + dnl libtool insists upon adding -nostdlib and a list of objects/libs to link against. + dnl That breaks our ability to build dll's with static libgcc/libstdc++/libssp. Override + dnl its command here, with the predeps/postdeps removed, and -static inserted. Postdeps are + dnl also overridden to prevent their insertion later. + dnl This should only affect dll's. + archive_cmds_CXX="\$CC -shared \$libobjs \$deplibs \$compiler_flags -static -o \$output_objdir/\$soname \${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker \$lib" + postdeps_CXX= + + ;; + *darwin*) + TARGET_OS=darwin + LEVELDB_TARGET_FLAGS="TARGET_OS=Darwin" + if test x$cross_compiling != xyes; then + BUILD_OS=darwin + AC_CHECK_PROG([PORT],port, port) + if test x$PORT = xport; then + dnl add default macports paths + CPPFLAGS="$CPPFLAGS -isystem /opt/local/include -I/opt/local/include/db48" + LIBS="$LIBS -L/opt/local/lib -L/opt/local/lib/db48" + fi + + AC_CHECK_PROG([BREW],brew, brew) + if test x$BREW = xbrew; then + dnl These Homebrew packages may be keg-only, meaning that they won't be found + dnl in expected paths because they may conflict with system files. Ask + dnl Homebrew where each one is located, then adjust paths accordingly. + dnl It's safe to add these paths even if the functionality is disabled by + dnl the user (--without-wallet or --without-gui for example). + + openssl_prefix=`$BREW --prefix openssl 2>/dev/null` + bdb_prefix=`$BREW --prefix berkeley-db4 2>/dev/null` + qt5_prefix=`$BREW --prefix qt5 2>/dev/null` + if test x$openssl_prefix != x; then + PKG_CONFIG_PATH="$openssl_prefix/lib/pkgconfig:$PKG_CONFIG_PATH" + export PKG_CONFIG_PATH + fi + if test x$bdb_prefix != x; then + CPPFLAGS="$CPPFLAGS -I$bdb_prefix/include" + LIBS="$LIBS -L$bdb_prefix/lib" + fi + if test x$qt5_prefix != x; then + PKG_CONFIG_PATH="$qt5_prefix/lib/pkgconfig:$PKG_CONFIG_PATH" + export PKG_CONFIG_PATH + fi + fi + else + case $build_os in + *darwin*) + BUILD_OS=darwin + ;; + *) + AC_PATH_TOOL([INSTALLNAMETOOL], [install_name_tool], install_name_tool) + AC_PATH_TOOL([OTOOL], [otool], otool) + AC_PATH_PROGS([GENISOIMAGE], [genisoimage mkisofs],genisoimage) + + dnl libtool will try to strip the static lib, which is a problem for + dnl cross-builds because strip attempts to call a hard-coded ld, + dnl which may not exist in the path. Stripping the .a is not + dnl necessary, so just disable it. + old_striplib= + ;; + esac + fi + + AX_CHECK_LINK_FLAG([[-Wl,-headerpad_max_install_names]], [LDFLAGS="$LDFLAGS -Wl,-headerpad_max_install_names"]) + CPPFLAGS="$CPPFLAGS -DMAC_OSX" + ;; + *linux*) + TARGET_OS=linux + ;; + *) + ;; +esac + +if test x$use_comparison_tool != xno; then + AC_SUBST(JAVA_COMPARISON_TOOL, $use_comparison_tool) +fi + +if test x$use_comparison_tool_reorg_tests != xno; then + if test x$use_comparison_tool = x; then + AC_MSG_ERROR("comparison tool reorg tests but comparison tool was not specified") + fi + AC_SUBST(COMPARISON_TOOL_REORG_TESTS, 1) +else + AC_SUBST(COMPARISON_TOOL_REORG_TESTS, 0) +fi + +if test x$use_lcov = xyes; then + if test x$LCOV = x; then + AC_MSG_ERROR("lcov testing requested but lcov not found") + fi + if test x$GCOV = x; then + AC_MSG_ERROR("lcov testing requested but gcov not found") + fi + if test x$JAVA = x; then + AC_MSG_ERROR("lcov testing requested but java not found") + fi + if test x$GENHTML = x; then + AC_MSG_ERROR("lcov testing requested but genhtml not found") + fi + if test x$use_comparison_tool = x; then + AC_MSG_ERROR("lcov testing requested but comparison tool was not specified") + fi + LCOV="$LCOV --gcov-tool=$GCOV" + AX_CHECK_COMPILE_FLAG([--coverage],[CXXFLAGS="$CXXFLAGS --coverage"], + [AC_MSG_ERROR("lcov testing requested but --coverage flag does not work")]) +fi + +dnl Require little endian +AC_C_BIGENDIAN([AC_MSG_ERROR("Big Endian not supported")]) + +dnl Check for pthread compile/link requirements +AX_PTHREAD + +# The following macro will add the necessary defines to bitcoin-config.h, but +# they also need to be passed down to any subprojects. Pull the results out of +# the cache and add them to CPPFLAGS. +AC_SYS_LARGEFILE +# detect POSIX or GNU variant of strerror_r +AC_FUNC_STRERROR_R + +if test x$ac_cv_sys_file_offset_bits != x && + test x$ac_cv_sys_file_offset_bits != xno && + test x$ac_cv_sys_file_offset_bits != xunknown; then + CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits" +fi + +if test x$ac_cv_sys_large_files != x && + test x$ac_cv_sys_large_files != xno && + test x$ac_cv_sys_large_files != xunknown; then + CPPFLAGS="$CPPFLAGS -D_LARGE_FILES=$ac_cv_sys_large_files" +fi + +AX_CHECK_LINK_FLAG([[-Wl,--large-address-aware]], [LDFLAGS="$LDFLAGS -Wl,--large-address-aware"]) + +AX_GCC_FUNC_ATTRIBUTE([visibility]) +AX_GCC_FUNC_ATTRIBUTE([dllexport]) +AX_GCC_FUNC_ATTRIBUTE([dllimport]) + +if test x$use_glibc_compat != xno; then + + #__fdelt_chk's params and return type have changed from long unsigned int to long int. + # See which one is present here. + AC_MSG_CHECKING(__fdelt_chk type) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#ifdef _FORTIFY_SOURCE + #undef _FORTIFY_SOURCE + #endif + #define _FORTIFY_SOURCE 2 + #include + extern "C" long unsigned int __fdelt_warn(long unsigned int);]],[[]])], + [ fdelt_type="long unsigned int"], + [ fdelt_type="long int"]) + AC_MSG_RESULT($fdelt_type) + AC_DEFINE_UNQUOTED(FDELT_TYPE, $fdelt_type,[parameter and return value type for __fdelt_chk]) + +fi + +if test x$use_hardening != xno; then + AX_CHECK_COMPILE_FLAG([-Wstack-protector],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -Wstack-protector"]) + AX_CHECK_COMPILE_FLAG([-fstack-protector-all],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fstack-protector-all"]) + + AX_CHECK_PREPROC_FLAG([-D_FORTIFY_SOURCE=2],[ + AX_CHECK_PREPROC_FLAG([-U_FORTIFY_SOURCE],[ + HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -U_FORTIFY_SOURCE" + ]) + HARDENED_CPPFLAGS="$HARDENED_CPPFLAGS -D_FORTIFY_SOURCE=2" + ]) + + AX_CHECK_LINK_FLAG([[-Wl,--dynamicbase]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--dynamicbase"]) + AX_CHECK_LINK_FLAG([[-Wl,--nxcompat]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,--nxcompat"]) + AX_CHECK_LINK_FLAG([[-Wl,-z,relro]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,relro"]) + AX_CHECK_LINK_FLAG([[-Wl,-z,now]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-z,now"]) + + if test x$TARGET_OS != xwindows; then + # All windows code is PIC, forcing it on just adds useless compile warnings + AX_CHECK_COMPILE_FLAG([-fPIC],[HARDENED_CXXFLAGS="$HARDENED_CXXFLAGS -fPIC"]) + AX_CHECK_LINK_FLAG([[-pic]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -pic"]) + fi + + case $host in + *mingw*) + AC_CHECK_LIB([ssp], [main],, AC_MSG_ERROR(lib missing)) + ;; + esac + + CXXFLAGS="$CXXFLAGS $HARDENED_CXXFLAGS" + CPPFLAGS="$CPPFLAGS $HARDENED_CPPFLAGS" + LDFLAGS="$LDFLAGS $HARDENED_LDFLAGS" + OBJCXXFLAGS="$CXXFLAGS" +fi + +dnl this flag screws up non-darwin gcc even when the check fails. special-case it. +if test x$TARGET_OS = xdarwin; then + AX_CHECK_LINK_FLAG([[-Wl,-dead_strip]], [LDFLAGS="$LDFLAGS -Wl,-dead_strip"]) +fi + +AC_CHECK_HEADERS([endian.h stdio.h stdlib.h unistd.h strings.h sys/types.h sys/stat.h sys/select.h sys/prctl.h]) +AC_SEARCH_LIBS([getaddrinfo_a], [anl], [AC_DEFINE(HAVE_GETADDRINFO_A, 1, [Define this symbol if you have getaddrinfo_a])]) +AC_SEARCH_LIBS([inet_pton], [nsl resolv], [AC_DEFINE(HAVE_INET_PTON, 1, [Define this symbol if you have inet_pton])]) + +AC_CHECK_DECLS([strnlen]) + +AC_CHECK_DECLS([le32toh, le64toh, htole32, htole64, be32toh, be64toh, htobe32, htobe64],,, + [#if HAVE_ENDIAN_H + #include + #endif]) + +dnl Check for MSG_NOSIGNAL +AC_MSG_CHECKING(for MSG_NOSIGNAL) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], + [[ int f = MSG_NOSIGNAL; ]])], + [ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_MSG_NOSIGNAL, 1,[Define this symbol if you have MSG_NOSIGNAL]) ], + [ AC_MSG_RESULT(no)] +) + +AC_SEARCH_LIBS([clock_gettime],[rt]) + +AC_MSG_CHECKING([for visibility attribute]) +AC_LINK_IFELSE([AC_LANG_SOURCE([ + int foo_def( void ) __attribute__((visibility("default"))); + int main(){} + ])], + [ + AC_DEFINE(HAVE_VISIBILITY_ATTRIBUTE,1,[Define if the visibility attribute is supported.]) + AC_MSG_RESULT(yes) + ], + [ + AC_MSG_RESULT(no) + if test x$use_reduce_exports = xyes; then + AC_MSG_ERROR([Cannot find a working visibility attribute. Use --disable-reduced-exports.]) + fi + AC_MSG_WARN([Cannot find a working visibility attribute. Disabling reduced exports.]) + use_reduce_exports=no + ] +) + +if test x$use_reduce_exports != xno; then + AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],[RE_CXXFLAGS="-fvisibility=hidden"], + [ + if test x$use_reduce_exports = xyes; then + AC_MSG_ERROR([Cannot set default symbol visibility. Use --disable-reduced-exports.]) + fi + AC_MSG_WARN([Cannot set default symbol visibility. Disabling reduced exports.]) + use_reduce_exports=no + ]) +fi + +LEVELDB_CPPFLAGS= +LIBLEVELDB= +LIBMEMENV= +AM_CONDITIONAL([EMBEDDED_LEVELDB],[true]) +AC_SUBST(LEVELDB_CPPFLAGS) +AC_SUBST(LIBLEVELDB) +AC_SUBST(LIBMEMENV) + +if test x$enable_wallet != xno; then + dnl Check for libdb_cxx only if wallet enabled + BITCOIN_FIND_BDB48 +fi + +dnl Check for libminiupnpc (optional) +if test x$use_upnp != xno; then + AC_CHECK_HEADERS( + [miniupnpc/miniwget.h miniupnpc/miniupnpc.h miniupnpc/upnpcommands.h miniupnpc/upnperrors.h], + [AC_CHECK_LIB([miniupnpc], [main],[MINIUPNPC_LIBS=-lminiupnpc], [have_miniupnpc=no])], + [have_miniupnpc=no] + ) +fi + +dnl Check for boost libs +AX_BOOST_BASE +AX_BOOST_SYSTEM +AX_BOOST_FILESYSTEM +AX_BOOST_PROGRAM_OPTIONS +AX_BOOST_THREAD +AX_BOOST_CHRONO + + +if test x$use_reduce_exports != xno; then + AC_MSG_CHECKING([for working boost reduced exports]) + TEMP_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$BOOST_CPPFLAGS $CPPFLAGS" + AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[ + @%:@include + ]], [[ + #if BOOST_VERSION >= 104900 + // Everything is okay + #else + # error Boost version is too old + #endif + ]])],[ + AC_MSG_RESULT(yes) + ],[: + if test x$use_reduce_exports = xauto; then + use_reduce_exports=no + else + if test x$use_reduce_exports = xyes; then + AC_MSG_ERROR([boost versions < 1.49 are known to be broken with reduced exports. Use --disable-reduced-exports.]) + fi + fi + AC_MSG_RESULT(no) + AC_MSG_WARN([boost versions < 1.49 are known to have symbol visibility issues. Disabling reduced exports.]) + ]) + CPPFLAGS="$TEMP_CPPFLAGS" +fi + +if test x$use_reduce_exports != xno; then + CXXFLAGS="$CXXFLAGS $RE_CXXFLAGS" + AX_CHECK_LINK_FLAG([[-Wl,--exclude-libs,ALL]], [RELDFLAGS="-Wl,--exclude-libs,ALL"]) +fi + +if test x$use_tests = xyes; then + + if test x$HEXDUMP = x; then + AC_MSG_ERROR(hexdump is required for tests) + fi + + + AX_BOOST_UNIT_TEST_FRAMEWORK + + dnl Determine if -DBOOST_TEST_DYN_LINK is needed + AC_MSG_CHECKING([for dynamic linked boost test]) + TEMP_LIBS="$LIBS" + LIBS="$LIBS $BOOST_LDFLAGS $BOOST_UNIT_TEST_FRAMEWORK_LIB" + TEMP_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" + AC_LINK_IFELSE([AC_LANG_SOURCE([ + #define BOOST_TEST_DYN_LINK + #define BOOST_TEST_MAIN + #include + + ])], + [AC_MSG_RESULT(yes)] + [TESTDEFS="$TESTDEFS -DBOOST_TEST_DYN_LINK"], + [AC_MSG_RESULT(no)]) + LIBS="$TEMP_LIBS" + CPPFLAGS="$TEMP_CPPFLAGS" +fi + +BOOST_LIBS="$BOOST_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_FILESYSTEM_LIB $BOOST_PROGRAM_OPTIONS_LIB $BOOST_THREAD_LIB" + +dnl Boost >= 1.50 uses sleep_for rather than the now-deprecated sleep, however +dnl it was broken from 1.50 to 1.52 when backed by nanosleep. Use sleep_for if +dnl a working version is available, else fall back to sleep. sleep was removed +dnl after 1.56. +dnl If neither is available, abort. +dnl If sleep_for is used, boost_chrono becomes a requirement. +if test x$ax_cv_boost_chrono = xyes; then +TEMP_LIBS="$LIBS" +LIBS="$BOOST_LIBS $BOOST_CHRONO_LIB $LIBS" +TEMP_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" +AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + #include + #include + ]],[[ + #if BOOST_VERSION >= 105000 && (!defined(BOOST_HAS_NANOSLEEP) || BOOST_VERSION >= 105200) + boost::this_thread::sleep_for(boost::chrono::milliseconds(0)); + #else + choke me + #endif + ]])], + [boost_sleep=yes; BOOST_LIBS="$BOOST_LIBS $BOOST_CHRONO_LIB"; + AC_DEFINE(HAVE_WORKING_BOOST_SLEEP_FOR, 1, [Define this symbol if boost sleep_for works])], + [boost_sleep=no]) +LIBS="$TEMP_LIBS" +CPPFLAGS="$TEMP_CPPFLAGS" +fi + +if test x$boost_sleep != xyes; then +TEMP_LIBS="$LIBS" +LIBS="$BOOST_LIBS $LIBS" +TEMP_CPPFLAGS="$CPPFLAGS" +CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" +AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + #include + #include + #include + ]],[[ + #if BOOST_VERSION <= 105600 + boost::this_thread::sleep(boost::posix_time::milliseconds(0)); + #else + choke me + #endif + ]])], + [boost_sleep=yes; AC_DEFINE(HAVE_WORKING_BOOST_SLEEP, 1, [Define this symbol if boost sleep works])], + [boost_sleep=no]) +LIBS="$TEMP_LIBS" +CPPFLAGS="$TEMP_CPPFLAGS" +fi + +if test x$boost_sleep != xyes; then + AC_MSG_ERROR(No working boost sleep implementation found.) +fi + +AC_ARG_WITH([utils], + [AS_HELP_STRING([--with-utils], + [build bitcoin-cli bitcoin-tx (default=yes)])], + [build_bitcoin_utils=$withval], + [build_bitcoin_utils=yes]) + +AC_ARG_WITH([daemon], + [AS_HELP_STRING([--with-daemon], + [build bitcoind daemon (default=yes)])], + [build_bitcoind=$withval], + [build_bitcoind=yes]) + +BITCOIN_QT_INIT + +if test x$use_pkgconfig = xyes; then + + if test x"$PKG_CONFIG" = "x"; then + AC_MSG_ERROR(pkg-config not found.) + fi + + : #NOP + m4_ifdef( + [PKG_CHECK_MODULES], + [ + PKG_CHECK_MODULES([SSL], [libssl],, [AC_MSG_ERROR(openssl not found.)]) + PKG_CHECK_MODULES([CRYPTO], [libcrypto],,[AC_MSG_ERROR(libcrypto not found.)]) + BITCOIN_QT_CHECK([PKG_CHECK_MODULES([PROTOBUF], [protobuf], [have_protobuf=yes], [BITCOIN_QT_FAIL(libprotobuf not found)])]) + if test x$use_qr != xno; then + BITCOIN_QT_CHECK([PKG_CHECK_MODULES([QR], [libqrencode], [have_qrencode=yes], [have_qrencode=no])]) + fi + ] + ) +else + AC_CHECK_HEADER([openssl/crypto.h],,AC_MSG_ERROR(libcrypto headers missing)) + AC_CHECK_LIB([crypto], [main],CRYPTO_LIBS=-lcrypto, AC_MSG_ERROR(libcrypto missing)) + + AC_CHECK_HEADER([openssl/ssl.h],, AC_MSG_ERROR(libssl headers missing),) + AC_CHECK_LIB([ssl], [main],SSL_LIBS=-lssl, AC_MSG_ERROR(libssl missing)) + + BITCOIN_QT_CHECK(AC_CHECK_LIB([protobuf] ,[main],[PROTOBUF_LIBS=-lprotobuf], BITCOIN_QT_FAIL(libprotobuf not found))) + if test x$use_qr != xno; then + BITCOIN_QT_CHECK([AC_CHECK_LIB([qrencode], [main],[QR_LIBS=-lqrencode], [have_qrencode=no])]) + BITCOIN_QT_CHECK([AC_CHECK_HEADER([qrencode.h],, have_qrencode=no)]) + fi +fi + +BITCOIN_QT_PATH_PROGS([PROTOC], [protoc],$protoc_bin_path) + +AC_MSG_CHECKING([whether to build hyperstaked]) +AM_CONDITIONAL([BUILD_BITCOIND], [test x$build_bitcoind = xyes]) +AC_MSG_RESULT($build_bitcoind) + +dnl sets $bitcoin_enable_qt, $bitcoin_enable_qt_test, $bitcoin_enable_qt_dbus +BITCOIN_QT_CONFIGURE([$use_pkgconfig], [qt4]) + +AC_LANG_POP + +if test "x$use_ccache" != "xno"; then + AC_MSG_CHECKING(if ccache should be used) + if test x$CCACHE = x; then + if test "x$use_ccache" = "xyes"; then + AC_MSG_ERROR([ccache not found.]); + else + use_ccache=no + fi + else + use_ccache=yes + CC="$ac_cv_path_CCACHE $CC" + CXX="$ac_cv_path_CCACHE $CXX" + fi + AC_MSG_RESULT($use_ccache) +fi +if test "x$use_ccache" = "xyes"; then + AX_CHECK_PREPROC_FLAG([-Qunused-arguments],[CPPFLAGS="-Qunused-arguments $CPPFLAGS"]) +fi + +dnl enable wallet +AC_MSG_CHECKING([if wallet should be enabled]) +if test x$enable_wallet != xno; then + AC_MSG_RESULT(yes) + AC_DEFINE_UNQUOTED([ENABLE_WALLET],[1],[Define to 1 to enable wallet functions]) + +else + AC_MSG_RESULT(no) +fi + +dnl enable upnp support +AC_MSG_CHECKING([whether to build with support for UPnP]) +if test x$have_miniupnpc = xno; then + if test x$use_upnp = xyes; then + AC_MSG_ERROR("UPnP requested but cannot be built. use --without-miniupnpc") + fi + AC_MSG_RESULT(no) +else + if test x$use_upnp != xno; then + AC_MSG_RESULT(yes) + AC_MSG_CHECKING([whether to build with UPnP enabled by default]) + use_upnp=yes + upnp_setting=0 + if test x$use_upnp_default != xno; then + use_upnp_default=yes + upnp_setting=1 + fi + AC_MSG_RESULT($use_upnp_default) + AC_DEFINE_UNQUOTED([USE_UPNP],[$upnp_setting],[UPnP support not compiled if undefined, otherwise value (0 or 1) determines default state]) + if test x$TARGET_OS = xwindows; then + MINIUPNPC_CPPFLAGS="-DSTATICLIB -DMINIUPNP_STATICLIB" + fi + else + AC_MSG_RESULT(no) + fi +fi + +dnl these are only used when qt is enabled +if test x$bitcoin_enable_qt != xno; then + BUILD_QT=qt + dnl enable dbus support + AC_MSG_CHECKING([whether to build GUI with support for D-Bus]) + if test x$bitcoin_enable_qt_dbus != xno; then + AC_DEFINE([USE_DBUS],[1],[Define if dbus support should be compiled in]) + fi + AC_MSG_RESULT($bitcoin_enable_qt_dbus) + + dnl enable qr support + AC_MSG_CHECKING([whether to build GUI with support for QR codes]) + if test x$have_qrencode = xno; then + if test x$use_qr = xyes; then + AC_MSG_ERROR("QR support requested but cannot be built. use --without-qrencode") + fi + AC_MSG_RESULT(no) + else + if test x$use_qr != xno; then + AC_MSG_RESULT(yes) + AC_DEFINE([USE_QRCODE],[1],[Define if QR support should be compiled in]) + use_qr=yes + else + AC_MSG_RESULT(no) + fi + fi + + if test x$XGETTEXT = x; then + AC_MSG_WARN("xgettext is required to update qt translations") + fi + + AC_MSG_CHECKING([whether to build test_bitcoin-qt]) + if test x$use_tests$bitcoin_enable_qt_test = xyesyes; then + AC_MSG_RESULT([yes]) + BUILD_TEST_QT="test" + else + AC_MSG_RESULT([no]) + fi +fi + +AC_MSG_CHECKING([whether to build test_bitcoin]) +if test x$use_tests = xyes; then + AC_MSG_RESULT([yes]) + BUILD_TEST="test" +else + AC_MSG_RESULT([no]) +fi + +AC_MSG_CHECKING([whether to reduce exports]) +if test x$use_reduce_exports != xno; then + AC_MSG_RESULT([yes]) +else + AC_MSG_RESULT([no]) +fi + +if test x$build_bitcoin_utils$build_bitcoin_libs$build_bitcoind$bitcoin_enable_qt$use_tests = xnononono; then + AC_MSG_ERROR([No targets! Please specify at least one of: --with-utils --with-libs --with-daemon --with-gui or --enable-tests]) +fi + +AM_CONDITIONAL([TARGET_DARWIN], [test x$TARGET_OS = xdarwin]) +AM_CONDITIONAL([BUILD_DARWIN], [test x$BUILD_OS = xdarwin]) +AM_CONDITIONAL([TARGET_WINDOWS], [test x$TARGET_OS = xwindows]) +AM_CONDITIONAL([ENABLE_WALLET],[test x$enable_wallet = xyes]) +AM_CONDITIONAL([ENABLE_TESTS],[test x$use_tests = xyes]) +AM_CONDITIONAL([ENABLE_QT],[test x$bitcoin_enable_qt = xyes]) +AM_CONDITIONAL([ENABLE_QT_TESTS],[test x$use_tests$bitcoin_enable_qt_test = xyesyes]) +AM_CONDITIONAL([USE_QRCODE], [test x$use_qr = xyes]) +AM_CONDITIONAL([USE_LCOV],[test x$use_lcov = xyes]) +AM_CONDITIONAL([USE_COMPARISON_TOOL],[test x$use_comparison_tool != xno]) +AM_CONDITIONAL([USE_COMPARISON_TOOL_REORG_TESTS],[test x$use_comparison_tool_reorg_test != xno]) +AM_CONDITIONAL([GLIBC_BACK_COMPAT],[test x$use_glibc_compat = xyes]) + +AC_DEFINE(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR, [Major version]) +AC_DEFINE(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR, [Minor version]) +AC_DEFINE(CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION, [Build revision]) +AC_DEFINE(CLIENT_VERSION_BUILD, _CLIENT_VERSION_BUILD, [Version Build]) +AC_DEFINE(CLIENT_VERSION_IS_RELEASE, _CLIENT_VERSION_IS_RELEASE, [Version is release]) +AC_DEFINE(COPYRIGHT_YEAR, _COPYRIGHT_YEAR, [Version is release]) +AC_SUBST(CLIENT_VERSION_MAJOR, _CLIENT_VERSION_MAJOR) +AC_SUBST(CLIENT_VERSION_MINOR, _CLIENT_VERSION_MINOR) +AC_SUBST(CLIENT_VERSION_REVISION, _CLIENT_VERSION_REVISION) +AC_SUBST(CLIENT_VERSION_BUILD, _CLIENT_VERSION_BUILD) +AC_SUBST(CLIENT_VERSION_IS_RELEASE, _CLIENT_VERSION_IS_RELEASE) +AC_SUBST(COPYRIGHT_YEAR, _COPYRIGHT_YEAR) + +AC_SUBST(RELDFLAGS) +AC_SUBST(LIBTOOL_APP_LDFLAGS) +AC_SUBST(USE_UPNP) +AC_SUBST(USE_QRCODE) +AC_SUBST(BOOST_LIBS) +AC_SUBST(TESTDEFS) +AC_SUBST(LEVELDB_TARGET_FLAGS) +AC_SUBST(BUILD_TEST) +AC_SUBST(BUILD_QT) +AC_SUBST(BUILD_TEST_QT) +AC_SUBST(MINIUPNPC_CPPFLAGS) +AC_SUBST(MINIUPNPC_LIBS) +AC_CONFIG_FILES([Makefile src/Makefile share/setup.nsi share/qt/Info.plist]) + +dnl boost's m4 checks do something really nasty: they export these vars. As a +dnl result, they leak into secp256k1's configure and crazy things happen. +dnl Until this is fixed upstream and we've synced, we'll just un-export them. +CPPFLAGS_TEMP="$CPPFLAGS" +unset CPPFLAGS +CPPFLAGS="$CPPFLAGS_TEMP" + +LDFLAGS_TEMP="$LDFLAGS" +unset LDFLAGS +LDFLAGS="$LDFLAGS_TEMP" + +LIBS_TEMP="$LIBS" +unset LIBS +LIBS="$LIBS_TEMP" + +PKGCONFIG_PATH_TEMP="$PKG_CONFIG_PATH" +unset PKG_CONFIG_PATH +PKG_CONFIG_PATH="$PKGCONFIG_PATH_TEMP" + +PKGCONFIG_LIBDIR_TEMP="$PKG_CONFIG_LIBDIR" +unset PKG_CONFIG_LIBDIR +PKG_CONFIG_LIBDIR="$PKGCONFIG_LIBDIR_TEMP" + +ac_configure_args="${ac_configure_args} --disable-shared --with-pic" + +AC_OUTPUT + +dnl Taken from https://wiki.debian.org/RpathIssue +case $host in + *-*-linux-gnu) + AC_MSG_RESULT([Fixing libtool for -rpath problems.]) + sed < libtool > libtool-2 \ + 's/^hardcode_libdir_flag_spec.*$'/'hardcode_libdir_flag_spec=" -D__LIBTOOL_IS_A_FOOL__ "/' + mv libtool-2 libtool + chmod 755 libtool + ;; +esac diff --git a/contrib/debian/copyright b/contrib/debian/copyright index b99604913..2c4b98c31 100644 --- a/contrib/debian/copyright +++ b/contrib/debian/copyright @@ -15,10 +15,6 @@ Files: src/json/* Copyright: 2007-2009, John W. Wilkinson License: Expat -Files: src/strlcpy.h -Copyright: 1998, Todd C. Miller -License: ISC - Files: debian/* Copyright: 2010-2011, Jonas Smedegaard 2011, Matt Corallo diff --git a/contrib/gitian-descriptors/README b/contrib/gitian-descriptors/README deleted file mode 100644 index a2d902e21..000000000 --- a/contrib/gitian-descriptors/README +++ /dev/null @@ -1,31 +0,0 @@ -Gavin's notes on getting gitian builds up and running: - -You need the right hardware: you need a 64-bit-capable CPU with hardware virtualization support (Intel VT-x or AMD-V). Not all modern CPUs support hardware virtualization. - -You probably need to enable hardware virtualization in your machine's BIOS. - -You need to be running a recent version of 64-bit-Ubuntu, and you need to install several prerequisites: - sudo apt-get install apache2 git apt-cacher-ng python-vm-builder qemu-kvm - -Sanity checks: - sudo service apt-cacher-ng status # Should return apt-cacher-ng is running - ls -l /dev/kvm # Should show a /dev/kvm device - -Once you've got the right hardware and software: - - git clone git://github.com/bitcoin/bitcoin.git - git clone git://github.com/devrandom/gitian-builder.git - mkdir gitian-builder/inputs - wget 'http://miniupnp.tuxfamily.org/files/download.php?file=miniupnpc-1.6.tar.gz' -O gitian-builder/inputs/miniupnpc-1.6.tar.gz - - cd gitian-builder - bin/make-base-vm --arch i386 - bin/make-base-vm --arch amd64 - cd .. - - # To build - cd bitcoin - git pull - cd ../gitian-builder - git pull - ./bin/gbuild --commit bitcoin=HEAD ../bitcoin/contrib/gitian.yml diff --git a/contrib/gitian-descriptors/README.md b/contrib/gitian-descriptors/README.md new file mode 100644 index 000000000..061b897d2 --- /dev/null +++ b/contrib/gitian-descriptors/README.md @@ -0,0 +1,66 @@ +### Gavin's notes on getting gitian builds up and running using KVM:### + +These instructions distilled from: +[ https://help.ubuntu.com/community/KVM/Installation]( https://help.ubuntu.com/community/KVM/Installation) +... see there for complete details. + +You need the right hardware: you need a 64-bit-capable CPU with hardware virtualization support (Intel VT-x or AMD-V). Not all modern CPUs support hardware virtualization. + +You probably need to enable hardware virtualization in your machine's BIOS. + +You need to be running a recent version of 64-bit-Ubuntu, and you need to install several prerequisites: + + sudo apt-get install ruby apache2 git apt-cacher-ng python-vm-builder qemu-kvm + +Sanity checks: + + sudo service apt-cacher-ng status # Should return apt-cacher-ng is running + ls -l /dev/kvm # Should show a /dev/kvm device + + +Once you've got the right hardware and software: + + git clone git://github.com/bitcoin/bitcoin.git + git clone git://github.com/devrandom/gitian-builder.git + mkdir gitian-builder/inputs + cd gitian-builder/inputs + + # Create base images + cd gitian-builder + bin/make-base-vm --suite precise --arch amd64 + cd .. + + # Get inputs (see doc/release-process.md for exact inputs needed and where to get them) + ... + + # For further build instructions see doc/release-notes.md + ... + +--------------------- + +`gitian-builder` now also supports building using LXC. See +[ https://help.ubuntu.com/12.04/serverguide/lxc.html]( https://help.ubuntu.com/12.04/serverguide/lxc.html) +... for how to get LXC up and running under Ubuntu. + +If your main machine is a 64-bit Mac or PC with a few gigabytes of memory +and at least 10 gigabytes of free disk space, you can `gitian-build` using +LXC running inside a virtual machine. + +Here's a description of Gavin's setup on OSX 10.6: + +1. Download and install VirtualBox from [https://www.virtualbox.org/](https://www.virtualbox.org/) + +2. Download the 64-bit Ubuntu Desktop 12.04 LTS .iso CD image from + [http://www.ubuntu.com/](http://www.ubuntu.com/) + +3. Run VirtualBox and create a new virtual machine, using the Ubuntu .iso (see the [VirtualBox documentation](https://www.virtualbox.org/wiki/Documentation) for details). Create it with at least 2 gigabytes of memory and a disk that is at least 20 gigabytes big. + +4. Inside the running Ubuntu desktop, install: + + sudo apt-get install debootstrap lxc ruby apache2 git apt-cacher-ng python-vm-builder + +5. Still inside Ubuntu, tell gitian-builder to use LXC, then follow the "Once you've got the right hardware and software" instructions above: + + export USE_LXC=1 + git clone git://github.com/bitcoin/bitcoin.git + ... etc diff --git a/contrib/gitian-descriptors/boost-win32.yml b/contrib/gitian-descriptors/boost-win32.yml deleted file mode 100644 index 61ea50e4f..000000000 --- a/contrib/gitian-descriptors/boost-win32.yml +++ /dev/null @@ -1,38 +0,0 @@ ---- -name: "boost" -suites: -- "lucid" -architectures: -- "i386" -packages: -- "mingw32" -- "faketime" -- "zip" -reference_datetime: "2011-01-30 00:00:00" -remotes: [] -files: -- "boost_1_47_0.tar.bz2" -script: | - TMPDIR="$HOME/tmpdir" - mkdir -p $TMPDIR/bin/$GBUILD_BITS $TMPDIR/include - tar xjf boost_1_47_0.tar.bz2 - cd boost_1_47_0 - echo "using gcc : 4.4 : i586-mingw32msvc-g++ - : - i586-mingw32msvc-windres - i586-mingw32msvc-ar - -frandom-seed=boost1 - ;" > user-config.jam - ./bootstrap.sh --without-icu - ./bjam toolset=gcc target-os=windows threadapi=win32 threading=multi variant=release link=static --user-config=user-config.jam --without-mpi --without-python -sNO_BZIP2=1 -sNO_ZLIB=1 --layout=tagged --build-type=complete $MAKEOPTS stage - for lib in chrono date_time exception filesystem graph iostreams math_c99f math_c99l math_c99 math_tr1f math_tr1l math_tr1 prg_exec_monitor program_options random regex serialization signals system test_exec_monitor thread_win32 unit_test_framework wave wserialization; do - mkdir $lib - (cd $lib ; ar xf ../stage/lib/libboost_${lib}-mt-s.a) - mv $lib $TMPDIR/bin/$GBUILD_BITS - done - cp -a boost $TMPDIR/include - cd $TMPDIR - export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1 - export FAKETIME=$REFERENCE_DATETIME - zip -r boost-win32-1.47.0-gitian.zip * - cp boost-win32-1.47.0-gitian.zip $OUTDIR diff --git a/contrib/gitian-descriptors/deps-win32.yml b/contrib/gitian-descriptors/deps-win32.yml deleted file mode 100644 index 62b67ee9a..000000000 --- a/contrib/gitian-descriptors/deps-win32.yml +++ /dev/null @@ -1,71 +0,0 @@ ---- -name: "bitcoin-deps" -suites: -- "lucid" -architectures: -- "i386" -packages: -- "mingw32" -- "git-core" -- "zip" -- "faketime" -- "wine" -reference_datetime: "2011-01-30 00:00:00" -remotes: [] -files: -- "openssl-1.0.1b.tar.gz" -- "db-4.8.30.NC.tar.gz" -- "miniupnpc-1.6.tar.gz" -- "zlib-1.2.7.tar.gz" -- "libpng-1.5.12.tar.gz" -- "qrencode-3.2.0.tar.bz2" -script: | - # - export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1 - export FAKETIME=$REFERENCE_DATETIME - export TZ=UTC - # - tar xzf openssl-1.0.1b.tar.gz - cd openssl-1.0.1b - ./Configure --cross-compile-prefix=i586-mingw32msvc- mingw - make - cd .. - # - tar xzf db-4.8.30.NC.tar.gz - cd db-4.8.30.NC/build_unix - ../dist/configure --enable-mingw --enable-cxx --host=i586-mingw32msvc CFLAGS="-I/usr/i586-mingw32msvc/include" - make $MAKEOPTS - cd ../.. - # - tar xzf miniupnpc-1.6.tar.gz - cd miniupnpc-1.6 - sed 's/dllwrap -k --driver-name gcc/$(DLLWRAP) -k --driver-name $(CC)/' -i Makefile.mingw - sed 's|wingenminiupnpcstrings $< $@|./wingenminiupnpcstrings $< $@|' -i Makefile.mingw - make -f Makefile.mingw DLLWRAP=i586-mingw32msvc-dllwrap CC=i586-mingw32msvc-gcc AR=i586-mingw32msvc-ar - cd .. - mv miniupnpc-1.6 miniupnpc - # - tar xzf zlib-1.2.7.tar.gz - cd zlib-1.2.7 - make -f win32/Makefile.gcc PREFIX=i586-mingw32msvc- $MAKEOPTS - cd .. - # - tar xzf libpng-1.5.12.tar.gz - cd libpng-1.5.12 - ./configure -disable-shared CC=i586-mingw32msvc-cc AR=i586-mingw32msvc-ar STRIP=i586-mingw32msvc-strip RANLIB=i586-mingw32msvc-ranlib OBJDUMP=i586-mingw32msvc-objdump LD=i586-mingw32msvc-ld LDFLAGS="-L../zlib-1.2.7/" CFLAGS="-I../zlib-1.2.7/" - make $MAKEOPTS - cd .. - # - tar xjf qrencode-3.2.0.tar.bz2 - cd qrencode-3.2.0 - ./configure CC=i586-mingw32msvc-cc AR=i586-mingw32msvc-ar STRIP=i586-mingw32msvc-strip RANLIB=i586-mingw32msvc-ranlib OBJDUMP=i586-mingw32msvc-objdump LD=i586-mingw32msvc-ld png_LIBS="../libpng-1.5.12/.libs/libpng15.a ../zlib-1.2.7/libz.a" png_CFLAGS="-I../libpng-1.5.12" - make $MAKEOPTS - cd .. - # - zip -r $OUTDIR/ppcoin-deps-0.0.1.zip \ - $(ls qrencode-*/{qrencode.h,.libs/libqrencode.{,l}a} | sort) \ - $(ls db-*/build_unix/{libdb_cxx.a,db.h,db_cxx.h,libdb.a,.libs/libdb_cxx-?.?.a} | sort) \ - $(find openssl-* -name '*.a' -o -name '*.h' | sort) \ - $(find miniupnpc -name '*.h' -o -name 'libminiupnpc.a' | sort) - # Kill wine processes as gitian won't figure out we are done otherwise - killall wineserver services.exe explorer.exe winedevice.exe diff --git a/contrib/gitian-descriptors/gitian-linux.yml b/contrib/gitian-descriptors/gitian-linux.yml new file mode 100644 index 000000000..21ec24a85 --- /dev/null +++ b/contrib/gitian-descriptors/gitian-linux.yml @@ -0,0 +1,117 @@ +--- +name: "hyperstake-linux-1.1" +enable_cache: true +suites: +- "precise" +architectures: +- "amd64" +packages: +- "g++-multilib" +- "git-core" +- "pkg-config" +- "autoconf2.13" +- "libtool" +- "automake" +- "faketime" +- "bsdmainutils" +- "binutils-gold" +- "libstdc++6-4.6-pic" +reference_datetime: "2013-06-01 00:00:00" +remotes: +- "url": "https://github.com/hyperstake/hyperstake.git" + "dir": "hyperstake" +files: [] +script: | + WRAP_DIR=$HOME/wrapped + HOSTS="i686-pc-linux-gnu x86_64-unknown-linux-gnu" + CONFIGFLAGS="--enable-upnp-default --enable-glibc-back-compat --enable-reduce-exports LDFLAGS=-static-libstdc++" + FAKETIME_HOST_PROGS="" + FAKETIME_PROGS="date ar ranlib nm strip" + + export QT_RCC_TEST=1 + export GZIP="-9n" + export TAR_OPTIONS="--mtime="$REFERENCE_DATE\\\ $REFERENCE_TIME"" + export TZ="UTC" + export BUILD_DIR=`pwd` + mkdir -p ${WRAP_DIR} + if test -n "$GBUILD_CACHE_ENABLED"; then + export SOURCES_PATH=${GBUILD_COMMON_CACHE} + export BASE_CACHE=${GBUILD_PACKAGE_CACHE} + mkdir -p ${BASE_CACHE} ${SOURCES_PATH} + fi + + # Create global faketime wrappers + for prog in ${FAKETIME_PROGS}; do + echo '#!/bin/bash' > ${WRAP_DIR}/${prog} + echo "REAL=\`which -a ${prog} | grep -v ${WRAP_DIR}/${prog} | head -1\`" >> ${WRAP_DIR}/${prog} + echo 'export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1' >> ${WRAP_DIR}/${prog} + echo "export FAKETIME=\"${REFERENCE_DATETIME}\"" >> ${WRAP_DIR}/${prog} + echo "\$REAL \$@" >> $WRAP_DIR/${prog} + chmod +x ${WRAP_DIR}/${prog} + done + + # Create per-host faketime wrappers + for i in $HOSTS; do + for prog in ${FAKETIME_HOST_PROGS}; do + echo '#!/bin/bash' > ${WRAP_DIR}/${i}-${prog} + echo "REAL=\`which -a ${i}-${prog} | grep -v ${WRAP_DIR}/${i}-${prog} | head -1\`" >> ${WRAP_DIR}/${i}-${prog} + echo 'export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1' >> ${WRAP_DIR}/${i}-${prog} + echo "export FAKETIME=\"${REFERENCE_DATETIME}\"" >> ${WRAP_DIR}/${i}-${prog} + echo "\$REAL \$@" >> $WRAP_DIR/${i}-${prog} + chmod +x ${WRAP_DIR}/${i}-${prog} + done + done + export PATH=${WRAP_DIR}:${PATH} + + cd bitcoin + BASEPREFIX=`pwd`/depends + # Build dependencies for each host + for i in $HOSTS; do + make ${MAKEOPTS} -C ${BASEPREFIX} HOST="${i}" + done + + # Ubuntu precise hack: Not an issue in later versions. + # Precise's libstdc++.a is non-pic. There's an optional libstdc++6-4.6-pic + # package which provides libstdc++_pic.a, but the linker can't find it. + # Symlink it to a path that will be included in our link-line so that the + # linker picks it up before the default libstdc++.a. + # This is only necessary for 64bit. + ln -s /usr/lib/gcc/x86_64-linux-gnu/4.6/libstdc++_pic.a ${BASEPREFIX}/x86_64-unknown-linux-gnu/lib/libstdc++.a + + # Create the release tarball using (arbitrarily) the first host + ./autogen.sh + ./configure --prefix=${BASEPREFIX}/`echo "${HOSTS}" | awk '{print $1;}'` + make dist + SOURCEDIST=`echo hyperstake-*.tar.gz` + DISTNAME=`echo ${SOURCEDIST} | sed 's/.tar.*//'` + # Correct tar file order + mkdir -p temp + pushd temp + tar xf ../$SOURCEDIST + find bitcoin-* | sort | tar --no-recursion --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 -c -T - | gzip -9n > ../$SOURCEDIST + popd + + ORIGPATH="$PATH" + # Extract the release tarball into a dir for each host and build + for i in ${HOSTS}; do + export PATH=${BASEPREFIX}/${i}/native/bin:${ORIGPATH} + mkdir -p distsrc-${i} + cd distsrc-${i} + INSTALLPATH=`pwd`/installed/${DISTNAME} + mkdir -p ${INSTALLPATH} + tar --strip-components=1 -xf ../$SOURCEDIST + + ./configure --prefix=${BASEPREFIX}/${i} --bindir=${INSTALLPATH}/bin --includedir=${INSTALLPATH}/include --libdir=${INSTALLPATH}/lib --disable-ccache --disable-maintainer-mode --disable-dependency-tracking ${CONFIGFLAGS} + make ${MAKEOPTS} + make install-strip + cd installed + find . -name "lib*.la" -delete + find . -name "lib*.a" -delete + rm -rf ${DISTNAME}/lib/pkgconfig + find ${DISTNAME} | sort | tar --no-recursion --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 -c -T - | gzip -9n > ${OUTDIR}/${DISTNAME}-${i}.tar.gz + cd ../../ + done + mkdir -p $OUTDIR/src + mv $SOURCEDIST $OUTDIR/src + mv ${OUTDIR}/${DISTNAME}-x86_64-*.tar.gz ${OUTDIR}/${DISTNAME}-linux64.tar.gz + mv ${OUTDIR}/${DISTNAME}-i686-*.tar.gz ${OUTDIR}/${DISTNAME}-linux32.tar.gz diff --git a/contrib/gitian-descriptors/gitian-osx-signer.yml b/contrib/gitian-descriptors/gitian-osx-signer.yml new file mode 100644 index 000000000..df3ef967d --- /dev/null +++ b/contrib/gitian-descriptors/gitian-osx-signer.yml @@ -0,0 +1,37 @@ +--- +name: "hyperstake-dmg-signer" +suites: +- "precise" +architectures: +- "amd64" +packages: +- "libc6:i386" +- "faketime" +reference_datetime: "2013-06-01 00:00:00" +remotes: [] +files: +- "hyperstake-osx-unsigned.tar.gz" +- "signature.tar.gz" +script: | + WRAP_DIR=$HOME/wrapped + mkdir -p ${WRAP_DIR} + export PATH=`pwd`:$PATH + FAKETIME_PROGS="dmg genisoimage" + + # Create global faketime wrappers + for prog in ${FAKETIME_PROGS}; do + echo '#!/bin/bash' > ${WRAP_DIR}/${prog} + echo "REAL=\`which -a ${prog} | grep -v ${WRAP_DIR}/${prog} | head -1\`" >> ${WRAP_DIR}/${prog} + echo 'export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1' >> ${WRAP_DIR}/${prog} + echo "export FAKETIME=\"${REFERENCE_DATETIME}\"" >> ${WRAP_DIR}/${prog} + echo "\$REAL \$@" >> $WRAP_DIR/${prog} + chmod +x ${WRAP_DIR}/${prog} + done + + UNSIGNED=hyperstake-osx-unsigned.tar.gz + SIGNED=hyperstake-osx-signed.dmg + + tar -xf ${UNSIGNED} + ./detached-sig-apply.sh ${UNSIGNED} signature.tar.gz + ${WRAP_DIR}/genisoimage -no-cache-inodes -D -l -probe -V "Hyperstake-Qt" -no-pad -r -apple -o uncompressed.dmg signed-app + ${WRAP_DIR}/dmg dmg uncompressed.dmg ${OUTDIR}/${SIGNED} diff --git a/contrib/gitian-descriptors/gitian-osx.yml b/contrib/gitian-descriptors/gitian-osx.yml new file mode 100644 index 000000000..c20eb1362 --- /dev/null +++ b/contrib/gitian-descriptors/gitian-osx.yml @@ -0,0 +1,134 @@ +--- +name: "hyperstake-osx-0.10" +enable_cache: true +suites: +- "precise" +architectures: +- "amd64" +packages: +- "g++" +- "git-core" +- "pkg-config" +- "autoconf2.13" +- "libtool" +- "automake" +- "faketime" +- "bsdmainutils" +- "cmake" +- "libcap-dev" +- "libz-dev" +- "libbz2-dev" +reference_datetime: "2013-06-01 00:00:00" +remotes: +- "url": "https://github.com/hyperstake/hyperstake.git" + "dir": "hyperstake" +files: +- "MacOSX10.7.sdk.tar.gz" +script: | + WRAP_DIR=$HOME/wrapped + HOSTS="x86_64-apple-darwin11" + CONFIGFLAGS="--enable-upnp-default --enable-reduce-exports GENISOIMAGE=$WRAP_DIR/genisoimage" + FAKETIME_HOST_PROGS="" + FAKETIME_PROGS="ar ranlib date dmg genisoimage" + + export QT_RCC_TEST=1 + export GZIP="-9n" + export TAR_OPTIONS="--mtime="$REFERENCE_DATE\\\ $REFERENCE_TIME"" + export TZ="UTC" + export BUILD_DIR=`pwd` + mkdir -p ${WRAP_DIR} + if test -n "$GBUILD_CACHE_ENABLED"; then + export SOURCES_PATH=${GBUILD_COMMON_CACHE} + export BASE_CACHE=${GBUILD_PACKAGE_CACHE} + mkdir -p ${BASE_CACHE} ${SOURCES_PATH} + fi + + export ZERO_AR_DATE=1 + + # Create global faketime wrappers + for prog in ${FAKETIME_PROGS}; do + echo '#!/bin/bash' > ${WRAP_DIR}/${prog} + echo "REAL=\`which -a ${prog} | grep -v ${WRAP_DIR}/${prog} | head -1\`" >> ${WRAP_DIR}/${prog} + echo 'export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1' >> ${WRAP_DIR}/${prog} + echo "export FAKETIME=\"${REFERENCE_DATETIME}\"" >> ${WRAP_DIR}/${prog} + echo "\$REAL \$@" >> $WRAP_DIR/${prog} + chmod +x ${WRAP_DIR}/${prog} + done + + # Create per-host faketime wrappers + for i in $HOSTS; do + for prog in ${FAKETIME_HOST_PROGS}; do + echo '#!/bin/bash' > ${WRAP_DIR}/${i}-${prog} + echo "REAL=\`which -a ${i}-${prog} | grep -v ${WRAP_DIR}/${i}-${prog} | head -1\`" >> ${WRAP_DIR}/${i}-${prog} + echo 'export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1' >> ${WRAP_DIR}/${i}-${prog} + echo "export FAKETIME=\"${REFERENCE_DATETIME}\"" >> ${WRAP_DIR}/${i}-${prog} + echo "\$REAL \$@" >> $WRAP_DIR/${i}-${prog} + chmod +x ${WRAP_DIR}/${i}-${prog} + done + done + export PATH=${WRAP_DIR}:${PATH} + + cd hyperstake + BASEPREFIX=`pwd`/depends + + mkdir -p ${BASEPREFIX}/SDKs + tar -C ${BASEPREFIX}/SDKs -xf ${BUILD_DIR}/MacOSX10.7.sdk.tar.gz + + # Build dependencies for each host + for i in $HOSTS; do + make ${MAKEOPTS} -C ${BASEPREFIX} HOST="${i}" + done + + # Create the release tarball using (arbitrarily) the first host + ./autogen.sh + ./configure --prefix=${BASEPREFIX}/`echo "${HOSTS}" | awk '{print $1;}'` + make dist + SOURCEDIST=`echo hyperstake-*.tar.gz` + DISTNAME=`echo ${SOURCEDIST} | sed 's/.tar.*//'` + + # Correct tar file order + mkdir -p temp + pushd temp + tar xf ../$SOURCEDIST + find hyperstake-* | sort | tar --no-recursion --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 -c -T - | gzip -9n > ../$SOURCEDIST + popd + + ORIGPATH="$PATH" + # Extract the release tarball into a dir for each host and build + for i in ${HOSTS}; do + export PATH=${BASEPREFIX}/${i}/native/bin:${ORIGPATH} + mkdir -p distsrc-${i} + cd distsrc-${i} + INSTALLPATH=`pwd`/installed/${DISTNAME} + mkdir -p ${INSTALLPATH} + tar --strip-components=1 -xf ../$SOURCEDIST + + ./configure --prefix=${BASEPREFIX}/${i} --bindir=${INSTALLPATH}/bin --includedir=${INSTALLPATH}/include --libdir=${INSTALLPATH}/lib --disable-ccache --disable-maintainer-mode --disable-dependency-tracking ${CONFIGFLAGS} + make ${MAKEOPTS} + make install-strip + + make deploydir + mkdir -p unsigned-app-${i} + cp contrib/macdeploy/detached-sig-apply.sh unsigned-app-${i} + cp contrib/macdeploy/detached-sig-create.sh unsigned-app-${i} + cp ${BASEPREFIX}/${i}/native/bin/dmg ${BASEPREFIX}/${i}/native/bin/genisoimage unsigned-app-${i} + cp ${BASEPREFIX}/${i}/native/bin/${i}-codesign_allocate unsigned-app-${i}/codesign_allocate + cp ${BASEPREFIX}/${i}/native/bin/${i}-pagestuff unsigned-app-${i}/pagestuff + mv dist unsigned-app-${i} + pushd unsigned-app-${i} + find . | sort | tar --no-recursion --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 -c -T - | gzip -9n > ${OUTDIR}/${DISTNAME}-osx-unsigned.tar.gz + popd + + make deploy + ${WRAP_DIR}/dmg dmg Hyperstake-Qt.dmg ${OUTDIR}/${DISTNAME}-osx-unsigned.dmg + + cd installed + find . -name "lib*.la" -delete + find . -name "lib*.a" -delete + rm -rf ${DISTNAME}/lib/pkgconfig + find ${DISTNAME} | sort | tar --no-recursion --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 -c -T - | gzip -9n > ${OUTDIR}/${DISTNAME}-${i}.tar.gz + cd ../../ + done + mkdir -p $OUTDIR/src + mv $SOURCEDIST $OUTDIR/src + mv ${OUTDIR}/${DISTNAME}-x86_64-*.tar.gz ${OUTDIR}/${DISTNAME}-osx64.tar.gz diff --git a/contrib/gitian-descriptors/gitian-win.yml b/contrib/gitian-descriptors/gitian-win.yml new file mode 100644 index 000000000..8556795a8 --- /dev/null +++ b/contrib/gitian-descriptors/gitian-win.yml @@ -0,0 +1,115 @@ +--- +name: "hyperstake-win-1.1" +enable_cache: true +suites: +- "precise" +architectures: +- "amd64" +packages: +- "g++" +- "git-core" +- "pkg-config" +- "autoconf2.13" +- "libtool" +- "automake" +- "faketime" +- "bsdmainutils" +- "mingw-w64" +- "g++-mingw-w64" +- "nsis" +- "zip" +reference_datetime: "2013-06-01 00:00:00" +remotes: +- "url": "https://github.com/hyperstake/hyperstake.git" + "dir": "hyperstake" +files: [] +script: | + WRAP_DIR=$HOME/wrapped + HOSTS="x86_64-w64-mingw32 i686-w64-mingw32" + CONFIGFLAGS="--enable-upnp-default --enable-reduce-exports" + FAKETIME_HOST_PROGS="g++ ar ranlib nm windres strip" + FAKETIME_PROGS="date makensis zip" + + export QT_RCC_TEST=1 + export GZIP="-9n" + export TAR_OPTIONS="--mtime="$REFERENCE_DATE\\\ $REFERENCE_TIME"" + export TZ="UTC" + export BUILD_DIR=`pwd` + mkdir -p ${WRAP_DIR} + if test -n "$GBUILD_CACHE_ENABLED"; then + export SOURCES_PATH=${GBUILD_COMMON_CACHE} + export BASE_CACHE=${GBUILD_PACKAGE_CACHE} + mkdir -p ${BASE_CACHE} ${SOURCES_PATH} + fi + + # Create global faketime wrappers + for prog in ${FAKETIME_PROGS}; do + echo '#!/bin/bash' > ${WRAP_DIR}/${prog} + echo "REAL=\`which -a ${prog} | grep -v ${WRAP_DIR}/${prog} | head -1\`" >> ${WRAP_DIR}/${prog} + echo 'export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1' >> ${WRAP_DIR}/${prog} + echo "export FAKETIME=\"${REFERENCE_DATETIME}\"" >> ${WRAP_DIR}/${prog} + echo "\$REAL \$@" >> $WRAP_DIR/${prog} + chmod +x ${WRAP_DIR}/${prog} + done + + # Create per-host faketime wrappers + for i in $HOSTS; do + for prog in ${FAKETIME_HOST_PROGS}; do + echo '#!/bin/bash' > ${WRAP_DIR}/${i}-${prog} + echo "REAL=\`which -a ${i}-${prog} | grep -v ${WRAP_DIR}/${i}-${prog} | head -1\`" >> ${WRAP_DIR}/${i}-${prog} + echo 'export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1' >> ${WRAP_DIR}/${i}-${prog} + echo "export FAKETIME=\"${REFERENCE_DATETIME}\"" >> ${WRAP_DIR}/${i}-${prog} + echo "\$REAL \$@" >> $WRAP_DIR/${i}-${prog} + chmod +x ${WRAP_DIR}/${i}-${prog} + done + done + export PATH=${WRAP_DIR}:${PATH} + + cd hyperstake + BASEPREFIX=`pwd`/depends + # Build dependencies for each host + for i in $HOSTS; do + make ${MAKEOPTS} -C ${BASEPREFIX} HOST="${i}" + done + + # Create the release tarball using (arbitrarily) the first host + ./autogen.sh + ./configure --prefix=${BASEPREFIX}/`echo "${HOSTS}" | awk '{print $1;}'` + make dist + SOURCEDIST=`echo hyperstake-*.tar.gz` + DISTNAME=`echo ${SOURCEDIST} | sed 's/.tar.*//'` + + # Correct tar file order + mkdir -p temp + pushd temp + tar xf ../$SOURCEDIST + find hyperstake-* | sort | tar --no-recursion --mode='u+rw,go+r-w,a+X' --owner=0 --group=0 -c -T - | gzip -9n > ../$SOURCEDIST + popd + + ORIGPATH="$PATH" + # Extract the release tarball into a dir for each host and build + for i in ${HOSTS}; do + export PATH=${BASEPREFIX}/${i}/native/bin:${ORIGPATH} + mkdir -p distsrc-${i} + cd distsrc-${i} + INSTALLPATH=`pwd`/installed/${DISTNAME} + mkdir -p ${INSTALLPATH} + tar --strip-components=1 -xf ../$SOURCEDIST + + ./configure --prefix=${BASEPREFIX}/${i} --bindir=${INSTALLPATH}/bin --includedir=${INSTALLPATH}/include --libdir=${INSTALLPATH}/lib --disable-ccache --disable-maintainer-mode --disable-dependency-tracking ${CONFIGFLAGS} + make ${MAKEOPTS} + make deploy + make install-strip + cp -f hyperstake-*setup*.exe $OUTDIR/ + cd installed + mv ${DISTNAME}/bin/*.dll ${DISTNAME}/lib/ + find . -name "lib*.la" -delete + find . -name "lib*.a" -delete + rm -rf ${DISTNAME}/lib/pkgconfig + find ${DISTNAME} -type f | sort | zip -X@ ${OUTDIR}/${DISTNAME}-${i}.zip + cd ../.. + done + mkdir -p $OUTDIR/src + mv $SOURCEDIST $OUTDIR/src + mv ${OUTDIR}/${DISTNAME}-x86_64-*.zip ${OUTDIR}/${DISTNAME}-win64.zip + mv ${OUTDIR}/${DISTNAME}-i686-*.zip ${OUTDIR}/${DISTNAME}-win32.zip diff --git a/contrib/gitian-descriptors/gitian-win32.yml b/contrib/gitian-descriptors/gitian-win32.yml deleted file mode 100644 index 2bf3a7dc2..000000000 --- a/contrib/gitian-descriptors/gitian-win32.yml +++ /dev/null @@ -1,74 +0,0 @@ ---- -name: "ppcoin" -suites: -- "lucid" -architectures: -- "i386" -packages: -- "mingw32" -- "git-core" -- "unzip" -- "nsis" -- "faketime" -reference_datetime: "2011-01-30 00:00:00" -remotes: -- "url": "https://github.com/ppcoin/ppcoin.git" - "dir": "ppcoin" -files: -- "qt-win32-4.7.4-gitian.zip" -- "boost-win32-1.47.0-gitian.zip" -- "ppcoin-deps-0.0.1.zip" -script: | - # - mkdir $HOME/qt - cd $HOME/qt - unzip ../build/qt-win32-4.7.4-gitian.zip - cd $HOME/build/ - export PATH=$PATH:$HOME/qt/bin/ - # - mkdir boost_1_47_0 - cd boost_1_47_0 - mkdir -p stage/lib - unzip ../boost-win32-1.47.0-gitian.zip - cd bin/$GBUILD_BITS - for lib in *; do - i586-mingw32msvc-ar rc ../../stage/lib/libboost_${lib}-mt-s.a $lib/*.o - i586-mingw32msvc-ranlib ../../stage/lib/libboost_${lib}-mt-s.a - done - cd ../.. - mv include/boost . - cd .. - # - unzip ppcoin-deps-0.0.1.zip - # - find -type f | xargs touch --date="$REFERENCE_DATETIME" - # - cd ppcoin - mkdir -p $OUTDIR/src - git archive HEAD | tar -x -C $OUTDIR/src - cp $OUTDIR/src/doc/README_windows.txt $OUTDIR/readme.txt - cp $OUTDIR/src/COPYING $OUTDIR/license.txt - export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1 - export FAKETIME=$REFERENCE_DATETIME - export TZ=UTC - $HOME/qt/src/bin/qmake -spec unsupported/win32-g++-cross MINIUPNPC_LIB_PATH=$HOME/build/miniupnpc MINIUPNPC_INCLUDE_PATH=$HOME/build/ BDB_LIB_PATH=$HOME/build/db-4.8.30.NC/build_unix BDB_INCLUDE_PATH=$HOME/build/db-4.8.30.NC/build_unix BOOST_LIB_PATH=$HOME/build/boost_1_47_0/stage/lib BOOST_INCLUDE_PATH=$HOME/build/boost_1_47_0 BOOST_LIB_SUFFIX=-mt-s BOOST_THREAD_LIB_SUFFIX=_win32-mt-s OPENSSL_LIB_PATH=$HOME/build/openssl-1.0.1b OPENSSL_INCLUDE_PATH=$HOME/build/openssl-1.0.1b/include QRENCODE_LIB_PATH=$HOME/build/qrencode-3.2.0/.libs QRENCODE_INCLUDE_PATH=$HOME/build/qrencode-3.2.0 USE_QRCODE=1 INCLUDEPATH=$HOME/build DEFINES=BOOST_THREAD_USE_LIB BITCOIN_NEED_QT_PLUGINS=1 QMAKE_LRELEASE=lrelease QMAKE_CXXFLAGS=-frandom-seed=ppcoin QMAKE_LFLAGS=-frandom-seed=ppcoin USE_BUILD_INFO=1 - make $MAKEOPTS - cp release/ppcoin-qt.exe $OUTDIR/ - # - cd src - export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1 - export FAKETIME=$REFERENCE_DATETIME - export TZ=UTC - make -f makefile.linux-mingw $MAKEOPTS DEPSDIR=$HOME/build ppcoind.exe USE_UPNP=1 DEBUGFLAGS="-frandom-seed=ppcoin" - i586-mingw32msvc-strip ppcoind.exe - mkdir $OUTDIR/daemon - cp ppcoind.exe $OUTDIR/daemon - cd .. - mkdir nsis - git archive HEAD | tar -x -C nsis - cd nsis/src - mkdir ../release - cp ../../release/* ../release/ - cp ../../src/*.exe . - makensis ../share/setup.nsi - cp ../share/ppcoin-*-win32-setup.exe $OUTDIR/ diff --git a/contrib/gitian-descriptors/gitian.yml b/contrib/gitian-descriptors/gitian.yml deleted file mode 100644 index 340de5e5a..000000000 --- a/contrib/gitian-descriptors/gitian.yml +++ /dev/null @@ -1,56 +0,0 @@ ---- -name: "ppcoin" -suites: -- "lucid" -architectures: -- "i386" -- "amd64" -packages: -- "libdb4.8++-dev" -- "qt4-qmake" -- "libqt4-dev" -- "libboost-system-dev" -- "libboost-filesystem-dev" -- "libboost-program-options-dev" -- "libboost-thread-dev" -- "libssl-dev" -- "git-core" -- "unzip" -- "pkg-config" -- "libpng12-dev" -reference_datetime: "2011-01-30 00:00:00" -remotes: -- "url": "https://github.com/ppcoin/ppcoin.git" - "dir": "ppcoin" -files: -- "miniupnpc-1.6.tar.gz" -- "qrencode-3.2.0.tar.bz2" -script: | - INSTDIR="$HOME/install" - export LIBRARY_PATH="$INSTDIR/lib" - # - tar xzf miniupnpc-1.6.tar.gz - cd miniupnpc-1.6 - INSTALLPREFIX=$INSTDIR make $MAKEOPTS install - cd .. - # - tar xjf qrencode-3.2.0.tar.bz2 - cd qrencode-3.2.0 - ./configure --prefix=$INSTDIR --enable-static --disable-shared - make $MAKEOPTS install - cd .. - # - cd ppcoin - mkdir -p $OUTDIR/src - git archive HEAD | tar -x -C $OUTDIR/src - cp $OUTDIR/src/doc/README $OUTDIR - cp $OUTDIR/src/COPYING $OUTDIR - cd src - make -f makefile.unix STATIC=1 OPENSSL_INCLUDE_PATH="$INSTDIR/include" OPENSSL_LIB_PATH="$INSTDIR/lib" $MAKEOPTS ppcoind USE_UPNP=1 DEBUGFLAGS= - mkdir -p $OUTDIR/bin/$GBUILD_BITS - install -s ppcoind $OUTDIR/bin/$GBUILD_BITS - # - cd .. - qmake INCLUDEPATH="$INSTDIR/include" LIBS="-L$INSTDIR/lib" RELEASE=1 USE_QRCODE=1 - make $MAKEOPTS - install ppcoin-qt $OUTDIR/bin/$GBUILD_BITS diff --git a/contrib/gitian-descriptors/qt-win32.yml b/contrib/gitian-descriptors/qt-win32.yml deleted file mode 100644 index 8a10e9b76..000000000 --- a/contrib/gitian-descriptors/qt-win32.yml +++ /dev/null @@ -1,54 +0,0 @@ ---- -name: "qt" -suites: -- "lucid" -architectures: -- "i386" -packages: -- "mingw32" -- "zip" -- "faketime" -reference_datetime: "2011-01-30 00:00:00" -remotes: [] -files: -- "qt-everywhere-opensource-src-4.7.4.tar.gz" -script: | - INSTDIR="$HOME/qt/" - mkdir $INSTDIR - SRCDIR="$INSTDIR/src/" - mkdir $SRCDIR - # - tar xzf qt-everywhere-opensource-src-4.7.4.tar.gz - cd qt-everywhere-opensource-src-4.7.4 - sed 's/$TODAY/2011-01-30/' -i configure - sed 's/i686-pc-mingw32-/i586-mingw32msvc-/' -i mkspecs/unsupported/win32-g++-cross/qmake.conf - sed --posix 's|QMAKE_CFLAGS\t\t= -pipe|QMAKE_CFLAGS\t\t= -pipe -isystem /usr/i586-mingw32msvc/include/ -frandom-seed=qtbuild|' -i mkspecs/unsupported/win32-g++-cross/qmake.conf - sed 's/QMAKE_CXXFLAGS_ETRKEPTIONS_ON = -fexceptions -mthreads/QMAKE_CXXFLAGS_ETRKEPTIONS_ON = -fexceptions/' -i mkspecs/unsupported/win32-g++-cross/qmake.conf - sed 's/QMAKE_LFLAGS_ETRKEPTIONS_ON = -mthreads/QMAKE_LFLAGS_ETRKEPTIONS_ON = -lmingwthrd/' -i mkspecs/unsupported/win32-g++-cross/qmake.conf - sed --posix 's/QMAKE_MOC\t\t= i586-mingw32msvc-moc/QMAKE_MOC\t\t= moc/' -i mkspecs/unsupported/win32-g++-cross/qmake.conf - sed --posix 's/QMAKE_RCC\t\t= i586-mingw32msvc-rcc/QMAKE_RCC\t\t= rcc/' -i mkspecs/unsupported/win32-g++-cross/qmake.conf - sed --posix 's/QMAKE_UIC\t\t= i586-mingw32msvc-uic/QMAKE_UIC\t\t= uic/' -i mkspecs/unsupported/win32-g++-cross/qmake.conf - # ar adds timestamps to every object file included in the static library - # providing -D as ar argument is supposed to solve it, but doesn't work as qmake strips off the arguments and adds -M to pass a script... - # which somehow cannot be combined with other flags. - # use faketime only for ar, as it confuses make/qmake into hanging sometimes - sed --posix "s|QMAKE_LIB\t\t= i586-mingw32msvc-ar -ru|QMAKE_LIB\t\t= $HOME/ar -Dr|" -i mkspecs/unsupported/win32-g++-cross/qmake.conf - echo '#!/bin/bash' > $HOME/ar - echo 'export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1' >> $HOME/ar - echo 'i586-mingw32msvc-ar "$@"' >> $HOME/ar - chmod +x $HOME/ar - #export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1 - export FAKETIME=$REFERENCE_DATETIME - export TZ=UTC - ./configure -prefix $INSTDIR -confirm-license -release -opensource -static -no-qt3support -xplatform unsupported/win32-g++-cross -no-multimedia -no-audio-backend -no-phonon -no-phonon-backend -no-declarative -no-script -no-scripttools -no-javascript-jit -no-webkit -no-svg -no-xmlpatterns -no-sql-sqlite -no-nis -no-cups -no-iconv -no-dbus -no-gif -no-libtiff -opengl no -nomake examples -nomake demos -nomake docs - find . -name *.prl | xargs -l sed 's|/\.||' -i - find . -name *.prl | xargs -l sed 's|/$||' -i - make $MAKEOPTS install - cp -a bin $SRCDIR/ - cd $INSTDIR - find . -name *.prl | xargs -l sed 's|/$||' -i - #sed 's|QMAKE_PRL_LIBS.*|QMAKE_PRL_LIBS = -lQtDeclarative -lQtScript -lQtSvg -lQtSql -lQtXmlPatterns -lQtGui -lgdi32 -lcomdlg32 -loleaut32 -limm32 -lwinmm -lwinspool -lmsimg32 -lQtNetwork -lQtCore -lole32 -luuid -lws2_32 -ladvapi32 -lshell32 -luser32 -lkernel32|' -i imports/Qt/labs/particles/qmlparticlesplugin.prl - - # as zip stores file timestamps, use faketime to intercept stat calls to set dates for all files to reference date - export LD_PRELOAD=/usr/lib/faketime/libfaketime.so.1 - zip -r $OUTDIR/qt-win32-4.7.4-gitian.zip * diff --git a/contrib/macdeploy/DS_Store b/contrib/macdeploy/DS_Store new file mode 100644 index 000000000..f0a9d9725 Binary files /dev/null and b/contrib/macdeploy/DS_Store differ diff --git a/contrib/macdeploy/LICENSE b/contrib/macdeploy/LICENSE index 14236f82e..94a9ed024 100644 --- a/contrib/macdeploy/LICENSE +++ b/contrib/macdeploy/LICENSE @@ -589,7 +589,7 @@ later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. ETRKEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR diff --git a/contrib/macdeploy/README.md b/contrib/macdeploy/README.md new file mode 100644 index 000000000..017659ac0 --- /dev/null +++ b/contrib/macdeploy/README.md @@ -0,0 +1,14 @@ +### MacDeploy ### + +For Snow Leopard (which uses [Python 2.6](http://www.python.org/download/releases/2.6/)), you will need the param_parser package: + + sudo easy_install argparse + +This script should not be run manually, instead, after building as usual: + + make deploy + +During the process, the disk image window will pop up briefly where the fancy +settings are applied. This is normal, please do not interfere. + +When finished, it will produce `HyperStake-Qt.dmg`. diff --git a/contrib/macdeploy/background.png b/contrib/macdeploy/background.png index d3cc4730f..a8ea3d2b5 100644 Binary files a/contrib/macdeploy/background.png and b/contrib/macdeploy/background.png differ diff --git a/contrib/macdeploy/background.psd b/contrib/macdeploy/background.psd deleted file mode 100644 index e0a8c9ab9..000000000 Binary files a/contrib/macdeploy/background.psd and /dev/null differ diff --git a/contrib/macdeploy/detached-sig-apply.sh b/contrib/macdeploy/detached-sig-apply.sh new file mode 100755 index 000000000..61ced1213 --- /dev/null +++ b/contrib/macdeploy/detached-sig-apply.sh @@ -0,0 +1,53 @@ +#!/bin/sh +set -e + +UNSIGNED=$1 +SIGNATURE=$2 +ARCH=x86_64 +ROOTDIR=dist +BUNDLE=${ROOTDIR}/HyperStake-Qt.app +TEMPDIR=signed.temp +OUTDIR=signed-app + +if [ -z "$UNSIGNED" ]; then + echo "usage: $0 " + exit 1 +fi + +if [ -z "$SIGNATURE" ]; then + echo "usage: $0 " + exit 1 +fi + +rm -rf ${TEMPDIR} && mkdir -p ${TEMPDIR} +tar -C ${TEMPDIR} -xf ${UNSIGNED} +tar -C ${TEMPDIR} -xf ${SIGNATURE} + +if [ -z "${PAGESTUFF}" ]; then + PAGESTUFF=${TEMPDIR}/pagestuff +fi + +if [ -z "${CODESIGN_ALLOCATE}" ]; then + CODESIGN_ALLOCATE=${TEMPDIR}/codesign_allocate +fi + +for i in `find ${TEMPDIR} -name "*.sign"`; do + SIZE=`stat -c %s ${i}` + TARGET_FILE=`echo ${i} | sed 's/\.sign$//'` + + echo "Allocating space for the signature of size ${SIZE} in ${TARGET_FILE}" + ${CODESIGN_ALLOCATE} -i ${TARGET_FILE} -a ${ARCH} ${SIZE} -o ${i}.tmp + + OFFSET=`${PAGESTUFF} ${i}.tmp -p | tail -2 | grep offset | sed 's/[^0-9]*//g'` + if [ -z ${QUIET} ]; then + echo "Attaching signature at offset ${OFFSET}" + fi + + dd if=$i of=${i}.tmp bs=1 seek=${OFFSET} count=${SIZE} 2>/dev/null + mv ${i}.tmp ${TARGET_FILE} + rm ${i} + echo "Success." +done +mv ${TEMPDIR}/${ROOTDIR} ${OUTDIR} +rm -rf ${TEMPDIR} +echo "Signed: ${OUTDIR}" diff --git a/contrib/macdeploy/detached-sig-create.sh b/contrib/macdeploy/detached-sig-create.sh new file mode 100755 index 000000000..bf0033f45 --- /dev/null +++ b/contrib/macdeploy/detached-sig-create.sh @@ -0,0 +1,46 @@ +#!/bin/sh +set -e + +ROOTDIR=dist +BUNDLE=${ROOTDIR}/HyperStake-Qt.app +CODESIGN=codesign +TEMPDIR=sign.temp +TEMPLIST=${TEMPDIR}/signatures.txt +OUT=signature.tar.gz + +if [ ! -n "$1" ]; then + echo "usage: $0 " + echo "example: $0 -s MyIdentity" + exit 1 +fi + +rm -rf ${TEMPDIR} ${TEMPLIST} +mkdir -p ${TEMPDIR} + +${CODESIGN} -f --file-list ${TEMPLIST} "$@" "${BUNDLE}" + +for i in `grep -v CodeResources ${TEMPLIST}`; do + TARGETFILE="${BUNDLE}/`echo ${i} | sed "s|.*${BUNDLE}/||"`" + SIZE=`pagestuff $i -p | tail -2 | grep size | sed 's/[^0-9]*//g'` + OFFSET=`pagestuff $i -p | tail -2 | grep offset | sed 's/[^0-9]*//g'` + SIGNFILE="${TEMPDIR}/${TARGETFILE}.sign" + DIRNAME="`dirname ${SIGNFILE}`" + mkdir -p "${DIRNAME}" + echo "Adding detached signature for: ${TARGETFILE}. Size: ${SIZE}. Offset: ${OFFSET}" + dd if=$i of=${SIGNFILE} bs=1 skip=${OFFSET} count=${SIZE} 2>/dev/null +done + +for i in `grep CodeResources ${TEMPLIST}`; do + TARGETFILE="${BUNDLE}/`echo ${i} | sed "s|.*${BUNDLE}/||"`" + RESOURCE="${TEMPDIR}/${TARGETFILE}" + DIRNAME="`dirname "${RESOURCE}"`" + mkdir -p "${DIRNAME}" + echo "Adding resource for: "${TARGETFILE}"" + cp "${i}" "${RESOURCE}" +done + +rm ${TEMPLIST} + +tar -C ${TEMPDIR} -czf ${OUT} . +rm -rf ${TEMPDIR} +echo "Created ${OUT}" diff --git a/contrib/macdeploy/fancy.plist b/contrib/macdeploy/fancy.plist index 8ee3deb38..6b0dd248e 100644 --- a/contrib/macdeploy/fancy.plist +++ b/contrib/macdeploy/fancy.plist @@ -22,7 +22,7 @@ 370 156 - X11Coin-Qt.app + Hyperstake-Qt.app 128 156 diff --git a/contrib/macdeploy/macdeployqtplus b/contrib/macdeploy/macdeployqtplus old mode 100644 new mode 100755 index 7981eca40..bd5ea37aa --- a/contrib/macdeploy/macdeployqtplus +++ b/contrib/macdeploy/macdeployqtplus @@ -17,9 +17,8 @@ # along with this program. If not, see . # -import subprocess, sys, re, os, shutil, stat, os.path +import subprocess, sys, re, os, shutil, stat, os.path, time from string import Template -from time import sleep from argparse import ArgumentParser # This is ported from the original macdeployqt with modifications @@ -38,14 +37,17 @@ class FrameworkInfo(object): self.sourceFilePath = "" self.destinationDirectory = "" self.sourceResourcesDirectory = "" + self.sourceVersionContentsDirectory = "" + self.sourceContentsDirectory = "" self.destinationResourcesDirectory = "" - + self.destinationVersionContentsDirectory = "" + def __eq__(self, other): if self.__class__ == other.__class__: return self.__dict__ == other.__dict__ else: return False - + def __str__(self): return """ Framework name: %s Framework directory: %s @@ -69,51 +71,51 @@ class FrameworkInfo(object): self.deployedInstallName, self.sourceFilePath, self.destinationDirectory) - + def isDylib(self): return self.frameworkName.endswith(".dylib") - + def isQtFramework(self): if self.isDylib(): return self.frameworkName.startswith("libQt") else: return self.frameworkName.startswith("Qt") - + reOLine = re.compile(r'^(.+) \(compatibility version [0-9.]+, current version [0-9.]+\)$') bundleFrameworkDirectory = "Contents/Frameworks" bundleBinaryDirectory = "Contents/MacOS" - + @classmethod def fromOtoolLibraryLine(cls, line): # Note: line must be trimmed if line == "": return None - + # Don't deploy system libraries (exception for libQtuitools and libQtlucene). if line.startswith("/System/Library/") or line.startswith("@executable_path") or (line.startswith("/usr/lib/") and "libQt" not in line): return None - + m = cls.reOLine.match(line) if m is None: raise RuntimeError("otool line could not be parsed: " + line) - + path = m.group(1) - + info = cls() info.sourceFilePath = path info.installName = path - + if path.endswith(".dylib"): dirname, filename = os.path.split(path) info.frameworkName = filename info.frameworkDirectory = dirname info.frameworkPath = path - + info.binaryDirectory = dirname info.binaryName = filename info.binaryPath = path info.version = "-" - + info.installName = path info.deployedInstallName = "@executable_path/../Frameworks/" + info.binaryName info.sourceFilePath = path @@ -128,22 +130,26 @@ class FrameworkInfo(object): i += 1 if i == len(parts): raise RuntimeError("Could not find .framework or .dylib in otool line: " + line) - + info.frameworkName = parts[i] info.frameworkDirectory = "/".join(parts[:i]) info.frameworkPath = os.path.join(info.frameworkDirectory, info.frameworkName) - + info.binaryName = parts[i+3] info.binaryDirectory = "/".join(parts[i+1:i+3]) info.binaryPath = os.path.join(info.binaryDirectory, info.binaryName) info.version = parts[i+2] - + info.deployedInstallName = "@executable_path/../Frameworks/" + os.path.join(info.frameworkName, info.binaryPath) info.destinationDirectory = os.path.join(cls.bundleFrameworkDirectory, info.frameworkName, info.binaryDirectory) - + info.sourceResourcesDirectory = os.path.join(info.frameworkPath, "Resources") + info.sourceContentsDirectory = os.path.join(info.frameworkPath, "Contents") + info.sourceVersionContentsDirectory = os.path.join(info.frameworkPath, "Versions", info.version, "Contents") info.destinationResourcesDirectory = os.path.join(cls.bundleFrameworkDirectory, info.frameworkName, "Resources") - + info.destinationContentsDirectory = os.path.join(cls.bundleFrameworkDirectory, info.frameworkName, "Contents") + info.destinationVersionContentsDirectory = os.path.join(cls.bundleFrameworkDirectory, info.frameworkName, "Versions", info.version, "Contents") + return info class ApplicationBundleInfo(object): @@ -161,7 +167,7 @@ class DeploymentInfo(object): self.qtPath = None self.pluginPath = None self.deployedFrameworks = [] - + def detectQtPath(self, frameworkDirectory): parentDir = os.path.dirname(frameworkDirectory) if os.path.exists(os.path.join(parentDir, "translations")): @@ -180,7 +186,7 @@ class DeploymentInfo(object): pluginPath = os.path.join(self.qtPath, "plugins") if os.path.exists(pluginPath): self.pluginPath = pluginPath - + def usesFramework(self, name): nameDot = "%s." % name libNameDot = "lib%s." % name @@ -196,32 +202,35 @@ class DeploymentInfo(object): def getFrameworks(binaryPath, verbose): if verbose >= 3: print "Inspecting with otool: " + binaryPath - otool = subprocess.Popen(["otool", "-L", binaryPath], stdout=subprocess.PIPE, stderr=subprocess.PIPE) + otoolbin=os.getenv("OTOOL", "otool") + otool = subprocess.Popen([otoolbin, "-L", binaryPath], stdout=subprocess.PIPE, stderr=subprocess.PIPE) o_stdout, o_stderr = otool.communicate() if otool.returncode != 0: if verbose >= 1: sys.stderr.write(o_stderr) sys.stderr.flush() raise RuntimeError("otool failed with return code %d" % otool.returncode) - + otoolLines = o_stdout.split("\n") otoolLines.pop(0) # First line is the inspected binary if ".framework" in binaryPath or binaryPath.endswith(".dylib"): otoolLines.pop(0) # Frameworks and dylibs list themselves as a dependency. - + libraries = [] for line in otoolLines: + line = line.replace("@loader_path", os.path.dirname(binaryPath)) info = FrameworkInfo.fromOtoolLibraryLine(line.strip()) if info is not None: if verbose >= 3: print "Found framework:" print info libraries.append(info) - + return libraries def runInstallNameTool(action, *args): - subprocess.check_call(["install_name_tool", "-"+action] + list(args)) + installnametoolbin=os.getenv("INSTALLNAMETOOL", "install_name_tool") + subprocess.check_call([installnametoolbin, "-"+action] + list(args)) def changeInstallName(oldName, newName, binaryPath, verbose): if verbose >= 3: @@ -239,10 +248,11 @@ def changeIdentification(id, binaryPath, verbose): runInstallNameTool("id", id, binaryPath) def runStrip(binaryPath, verbose): + stripbin=os.getenv("STRIP", "strip") if verbose >= 3: print "Using strip:" print " stripped", binaryPath - subprocess.check_call(["strip", "-x", binaryPath]) + subprocess.check_call([stripbin, "-x", binaryPath]) def copyFramework(framework, path, verbose): if framework.sourceFilePath.startswith("Qt"): @@ -250,19 +260,18 @@ def copyFramework(framework, path, verbose): fromPath = "/Library/Frameworks/" + framework.sourceFilePath else: fromPath = framework.sourceFilePath - toDir = os.path.join(path, framework.destinationDirectory) toPath = os.path.join(toDir, framework.binaryName) - + if not os.path.exists(fromPath): raise RuntimeError("No file at " + fromPath) - + if os.path.exists(toPath): return None # Already there - + if not os.path.exists(toDir): os.makedirs(toDir) - + shutil.copy2(fromPath, toPath) if verbose >= 3: print "Copied:", fromPath @@ -273,68 +282,85 @@ def copyFramework(framework, path, verbose): os.chmod(toPath, permissions.st_mode | stat.S_IWRITE) if not framework.isDylib(): # Copy resources for real frameworks + + linkfrom = os.path.join(path, "Contents","Frameworks", framework.frameworkName, "Versions", "Current") + linkto = framework.version + if not os.path.exists(linkfrom): + os.symlink(linkto, linkfrom) + if verbose >= 2: + print "Linked:", linkfrom, "->", linkto fromResourcesDir = framework.sourceResourcesDirectory if os.path.exists(fromResourcesDir): toResourcesDir = os.path.join(path, framework.destinationResourcesDirectory) - shutil.copytree(fromResourcesDir, toResourcesDir) + shutil.copytree(fromResourcesDir, toResourcesDir, symlinks=True) if verbose >= 3: print "Copied resources:", fromResourcesDir print " to:", toResourcesDir + fromContentsDir = framework.sourceVersionContentsDirectory + if not os.path.exists(fromContentsDir): + fromContentsDir = framework.sourceContentsDirectory + if os.path.exists(fromContentsDir): + toContentsDir = os.path.join(path, framework.destinationVersionContentsDirectory) + shutil.copytree(fromContentsDir, toContentsDir, symlinks=True) + contentslinkfrom = os.path.join(path, framework.destinationContentsDirectory) + if verbose >= 3: + print "Copied Contents:", fromContentsDir + print " to:", toContentsDir elif framework.frameworkName.startswith("libQtGui"): # Copy qt_menu.nib (applies to non-framework layout) qtMenuNibSourcePath = os.path.join(framework.frameworkDirectory, "Resources", "qt_menu.nib") qtMenuNibDestinationPath = os.path.join(path, "Contents", "Resources", "qt_menu.nib") if os.path.exists(qtMenuNibSourcePath) and not os.path.exists(qtMenuNibDestinationPath): - shutil.copytree(qtMenuNibSourcePath, qtMenuNibDestinationPath) + shutil.copytree(qtMenuNibSourcePath, qtMenuNibDestinationPath, symlinks=True) if verbose >= 3: print "Copied for libQtGui:", qtMenuNibSourcePath print " to:", qtMenuNibDestinationPath - + return toPath def deployFrameworks(frameworks, bundlePath, binaryPath, strip, verbose, deploymentInfo=None): if deploymentInfo is None: deploymentInfo = DeploymentInfo() - + while len(frameworks) > 0: framework = frameworks.pop(0) deploymentInfo.deployedFrameworks.append(framework.frameworkName) - + if verbose >= 2: print "Processing", framework.frameworkName, "..." - + # Get the Qt path from one of the Qt frameworks if deploymentInfo.qtPath is None and framework.isQtFramework(): deploymentInfo.detectQtPath(framework.frameworkDirectory) - - if framework.installName.startswith("@executable_path"): + + if framework.installName.startswith("@executable_path") or framework.installName.startswith(bundlePath): if verbose >= 2: print framework.frameworkName, "already deployed, skipping." continue - + # install_name_tool the new id into the binary changeInstallName(framework.installName, framework.deployedInstallName, binaryPath, verbose) - + # Copy farmework to app bundle. deployedBinaryPath = copyFramework(framework, bundlePath, verbose) # Skip the rest if already was deployed. if deployedBinaryPath is None: continue - + if strip: runStrip(deployedBinaryPath, verbose) - + # install_name_tool it a new id. changeIdentification(framework.deployedInstallName, deployedBinaryPath, verbose) # Check for framework dependencies dependencies = getFrameworks(deployedBinaryPath, verbose) - + for dependency in dependencies: changeInstallName(dependency.installName, dependency.deployedInstallName, deployedBinaryPath, verbose) - + # Deploy framework if necessary. if dependency.frameworkName not in deploymentInfo.deployedFrameworks and dependency not in frameworks: frameworks.append(dependency) - + return deploymentInfo def deployFrameworksForAppBundle(applicationBundle, strip, verbose): @@ -348,6 +374,8 @@ def deployFrameworksForAppBundle(applicationBundle, strip, verbose): def deployPlugins(appBundleInfo, deploymentInfo, strip, verbose): # Lookup available plugins, exclude unneeded plugins = [] + if deploymentInfo.pluginPath is None: + return for dirpath, dirnames, filenames in os.walk(deploymentInfo.pluginPath): pluginDirectory = os.path.relpath(dirpath, deploymentInfo.pluginPath) if pluginDirectory == "designer": @@ -365,7 +393,7 @@ def deployPlugins(appBundleInfo, deploymentInfo, strip, verbose): # Deploy the script plugins only if QtScript is in use if not deploymentInfo.usesFramework("QtScript"): continue - elif pluginDirectory == "qmltooling": + elif pluginDirectory == "qmltooling" or pluginDirectory == "qml1tooling": # Deploy the qml plugins only if QtDeclarative is in use if not deploymentInfo.usesFramework("QtDeclarative"): continue @@ -373,7 +401,23 @@ def deployPlugins(appBundleInfo, deploymentInfo, strip, verbose): # Deploy the bearer plugins only if QtNetwork is in use if not deploymentInfo.usesFramework("QtNetwork"): continue - + elif pluginDirectory == "position": + # Deploy the position plugins only if QtPositioning is in use + if not deploymentInfo.usesFramework("QtPositioning"): + continue + elif pluginDirectory == "sensors" or pluginDirectory == "sensorgestures": + # Deploy the sensor plugins only if QtSensors is in use + if not deploymentInfo.usesFramework("QtSensors"): + continue + elif pluginDirectory == "audio" or pluginDirectory == "playlistformats": + # Deploy the audio plugins only if QtMultimedia is in use + if not deploymentInfo.usesFramework("QtMultimedia"): + continue + elif pluginDirectory == "mediaservice": + # Deploy the mediaservice plugins only if QtMultimediaWidgets is in use + if not deploymentInfo.usesFramework("QtMultimediaWidgets"): + continue + for pluginName in filenames: pluginPath = os.path.join(pluginDirectory, pluginName) if pluginName.endswith("_debug.dylib"): @@ -391,39 +435,43 @@ def deployPlugins(appBundleInfo, deploymentInfo, strip, verbose): # Deploy the opengl graphicssystem plugin only if QtOpenGL is in use if not deploymentInfo.usesFramework("QtOpenGL"): continue - + elif pluginPath == "accessible/libqtaccessiblequick.dylib": + # Deploy the accessible qtquick plugin only if QtQuick is in use + if not deploymentInfo.usesFramework("QtQuick"): + continue + plugins.append((pluginDirectory, pluginName)) - + for pluginDirectory, pluginName in plugins: if verbose >= 2: print "Processing plugin", os.path.join(pluginDirectory, pluginName), "..." - + sourcePath = os.path.join(deploymentInfo.pluginPath, pluginDirectory, pluginName) destinationDirectory = os.path.join(appBundleInfo.pluginPath, pluginDirectory) if not os.path.exists(destinationDirectory): os.makedirs(destinationDirectory) - + destinationPath = os.path.join(destinationDirectory, pluginName) shutil.copy2(sourcePath, destinationPath) if verbose >= 3: print "Copied:", sourcePath print " to:", destinationPath - + if strip: runStrip(destinationPath, verbose) - + dependencies = getFrameworks(destinationPath, verbose) - + for dependency in dependencies: changeInstallName(dependency.installName, dependency.deployedInstallName, destinationPath, verbose) - + # Deploy framework if necessary. if dependency.frameworkName not in deploymentInfo.deployedFrameworks: deployFrameworks([dependency], appBundleInfo.path, destinationPath, strip, verbose, deploymentInfo) qt_conf="""[Paths] -translations=Resources -plugins=PlugIns +Translations=Resources +Plugins=PlugIns """ ap = ArgumentParser(description="""Improved version of macdeployqt. @@ -431,15 +479,21 @@ ap = ArgumentParser(description="""Improved version of macdeployqt. Outputs a ready-to-deploy app in a folder "dist" and optionally wraps it in a .dmg file. Note, that the "dist" folder will be deleted before deploying on each run. -Optionally, Qt translation files (.qm) and additional resources can be added to the bundle.""") +Optionally, Qt translation files (.qm) and additional resources can be added to the bundle. + +Also optionally signs the .app bundle; set the CODESIGNARGS environment variable to pass arguments +to the codesign tool. +E.g. CODESIGNARGS='--sign "Developer ID Application: ..." --keychain /encrypted/foo.keychain'""") ap.add_argument("app_bundle", nargs=1, metavar="app-bundle", help="application bundle to be deployed") ap.add_argument("-verbose", type=int, nargs=1, default=[1], metavar="<0-3>", help="0 = no output, 1 = error/warning (default), 2 = normal, 3 = debug") ap.add_argument("-no-plugins", dest="plugins", action="store_false", default=True, help="skip plugin deployment") ap.add_argument("-no-strip", dest="strip", action="store_false", default=True, help="don't run 'strip' on the binaries") +ap.add_argument("-sign", dest="sign", action="store_true", default=False, help="sign .app bundle with codesign tool") ap.add_argument("-dmg", nargs="?", const="", metavar="basename", help="create a .dmg disk image; if basename is not specified, a camel-cased version of the app name is used") ap.add_argument("-fancy", nargs=1, metavar="plist", default=[], help="make a fancy looking disk image using the given plist file with instructions; requires -dmg to work") ap.add_argument("-add-qt-tr", nargs=1, metavar="languages", default=[], help="add Qt translation files to the bundle's ressources; the language list must be separated with commas, not with whitespace") +ap.add_argument("-translations-dir", nargs=1, metavar="path", default=None, help="Path to Qt's translation files") ap.add_argument("-add-resources", nargs="+", metavar="path", default=[], help="list of additional files or folders to be copied into the bundle's resources; must be the last argument") config = ap.parse_args() @@ -458,6 +512,15 @@ if not os.path.exists(app_bundle): app_bundle_name = os.path.splitext(os.path.basename(app_bundle))[0] # ------------------------------------------------ +translations_dir = None +if config.translations_dir and config.translations_dir[0]: + if os.path.exists(config.translations_dir[0]): + translations_dir = config.translations_dir[0] + else: + if verbose >= 1: + sys.stderr.write("Error: Could not find translation dir \"%s\"\n" % (translations_dir)) + sys.exit(1) +# ------------------------------------------------ for p in config.add_resources: if verbose >= 3: @@ -478,17 +541,7 @@ if len(config.fancy) == 1: if verbose >= 1: sys.stderr.write("Error: Could not import plistlib which is required for fancy disk images.\n") sys.exit(1) - - if verbose >= 3: - print "Fancy: Importing appscript..." - try: - import appscript - except ImportError: - if verbose >= 1: - sys.stderr.write("Error: Could not import appscript which is required for fancy disk images.\n") - sys.stderr.write("Please install it e.g. with \"sudo easy_install appscript\".\n") - sys.exit(1) - + p = config.fancy[0] if verbose >= 3: print "Fancy: Loading \"%s\"..." % p @@ -496,14 +549,14 @@ if len(config.fancy) == 1: if verbose >= 1: sys.stderr.write("Error: Could not find fancy disk image plist at \"%s\"\n" % (p)) sys.exit(1) - + try: fancy = plistlib.readPlist(p) except: if verbose >= 1: sys.stderr.write("Error: Could not parse fancy disk image plist at \"%s\"\n" % (p)) sys.exit(1) - + try: assert not fancy.has_key("window_bounds") or (isinstance(fancy["window_bounds"], list) and len(fancy["window_bounds"]) == 4) assert not fancy.has_key("background_picture") or isinstance(fancy["background_picture"], str) @@ -517,7 +570,7 @@ if len(config.fancy) == 1: if verbose >= 1: sys.stderr.write("Error: Bad format of fancy disk image plist at \"%s\"\n" % (p)) sys.exit(1) - + if fancy.has_key("background_picture"): bp = fancy["background_picture"] if verbose >= 3: @@ -538,7 +591,7 @@ else: if os.path.exists("dist"): if verbose >= 2: print "+ Removing old dist folder +" - + shutil.rmtree("dist") # ------------------------------------------------ @@ -551,7 +604,7 @@ if verbose >= 3: print app_bundle, "->", target os.mkdir("dist") -shutil.copytree(app_bundle, target) +shutil.copytree(app_bundle, target, symlinks=True) applicationBundle = ApplicationBundleInfo(target) @@ -571,27 +624,34 @@ try: except RuntimeError as e: if verbose >= 1: sys.stderr.write("Error: %s\n" % str(e)) - sys.exit(ret) + sys.exit(1) # ------------------------------------------------ if config.plugins: if verbose >= 2: print "+ Deploying plugins +" - + try: deployPlugins(applicationBundle, deploymentInfo, config.strip, verbose) except RuntimeError as e: if verbose >= 1: sys.stderr.write("Error: %s\n" % str(e)) - sys.exit(ret) + sys.exit(1) # ------------------------------------------------ if len(config.add_qt_tr) == 0: add_qt_tr = [] else: - qt_tr_dir = os.path.join(deploymentInfo.qtPath, "translations") + if translations_dir is not None: + qt_tr_dir = translations_dir + else: + if deploymentInfo.qtPath is not None: + qt_tr_dir = os.path.join(deploymentInfo.qtPath, "translations") + else: + sys.stderr.write("Error: Could not find Qt translation path\n") + sys.exit(1) add_qt_tr = ["qt_%s.qm" % lng for lng in config.add_qt_tr[0].split(",")] for lng_file in add_qt_tr: p = os.path.join(qt_tr_dir, lng_file) @@ -631,13 +691,39 @@ for p in config.add_resources: if verbose >= 3: print p, "->", t if os.path.isdir(p): - shutil.copytree(p, t) + shutil.copytree(p, t, symlinks=True) else: shutil.copy2(p, t) # ------------------------------------------------ +if config.sign and 'CODESIGNARGS' not in os.environ: + print "You must set the CODESIGNARGS environment variable. Skipping signing." +elif config.sign: + if verbose >= 1: + print "Code-signing app bundle %s"%(target,) + subprocess.check_call("codesign --force %s %s"%(os.environ['CODESIGNARGS'], target), shell=True) + +# ------------------------------------------------ + if config.dmg is not None: + + #Patch in check_output for Python 2.6 + if "check_output" not in dir( subprocess ): + def f(*popenargs, **kwargs): + if 'stdout' in kwargs: + raise ValueError('stdout argument not allowed, it will be overridden.') + process = subprocess.Popen(stdout=subprocess.PIPE, *popenargs, **kwargs) + output, unused_err = process.communicate() + retcode = process.poll() + if retcode: + cmd = kwargs.get("args") + if cmd is None: + cmd = popenargs[0] + raise CalledProcessError(retcode, cmd) + return output + subprocess.check_output = f + def runHDIUtil(verb, image_basename, **kwargs): hdiutil_args = ["hdiutil", verb, image_basename + ".dmg"] if kwargs.has_key("capture_stdout"): @@ -649,26 +735,26 @@ if config.dmg is not None: elif verbose >= 3: hdiutil_args.append("-verbose") run = subprocess.check_call - + for key, value in kwargs.iteritems(): hdiutil_args.append("-" + key) if not value is True: hdiutil_args.append(str(value)) - + return run(hdiutil_args) - + if verbose >= 2: if fancy is None: print "+ Creating .dmg disk image +" else: print "+ Preparing .dmg disk image +" - + if config.dmg != "": dmg_name = config.dmg else: spl = app_bundle_name.split(" ") dmg_name = spl[0] + "".join(p.capitalize() for p in spl[1:]) - + if fancy is None: try: runHDIUtil("create", dmg_name, srcfolder="dist", format="UDBZ", volname=app_bundle_name, ov=True) @@ -681,73 +767,112 @@ if config.dmg is not None: for path, dirs, files in os.walk("dist"): for file in files: size += os.path.getsize(os.path.join(path, file)) - size += int(size * 0.1) - + size += int(size * 0.15) + if verbose >= 3: print "Creating temp image for modification..." try: runHDIUtil("create", dmg_name + ".temp", srcfolder="dist", format="UDRW", size=size, volname=app_bundle_name, ov=True) except subprocess.CalledProcessError as e: sys.exit(e.returncode) - + if verbose >= 3: print "Attaching temp image..." try: output = runHDIUtil("attach", dmg_name + ".temp", readwrite=True, noverify=True, noautoopen=True, capture_stdout=True) except subprocess.CalledProcessError as e: sys.exit(e.returncode) - + m = re.search("/Volumes/(.+$)", output) disk_root = m.group(0) disk_name = m.group(1) - + if verbose >= 2: print "+ Applying fancy settings +" - + if fancy.has_key("background_picture"): - bg_path = os.path.join(disk_root, os.path.basename(fancy["background_picture"])) + bg_path = os.path.join(disk_root, ".background", os.path.basename(fancy["background_picture"])) + os.mkdir(os.path.dirname(bg_path)) if verbose >= 3: print fancy["background_picture"], "->", bg_path shutil.copy2(fancy["background_picture"], bg_path) else: bg_path = None - + if fancy.get("applications_symlink", False): os.symlink("/Applications", os.path.join(disk_root, "Applications")) - - finder = appscript.app("Finder") - disk = finder.disks[disk_name] - disk.open() - window = disk.container_window - window.current_view.set(appscript.k.icon_view) - window.toolbar_visible.set(False) - window.statusbar_visible.set(False) - if fancy.has_key("window_bounds"): - window.bounds.set(fancy["window_bounds"]) - view_options = window.icon_view_options - view_options.arrangement.set(appscript.k.not_arranged) - if fancy.has_key("icon_size"): - view_options.icon_size.set(fancy["icon_size"]) - if bg_path is not None: - view_options.background_picture.set(disk.files[os.path.basename(bg_path)]) + + # The Python appscript package broke with OSX 10.8 and isn't being fixed. + # So we now build up an AppleScript string and use the osascript command + # to make the .dmg file pretty: + appscript = Template( """ + on run argv + tell application "Finder" + tell disk "$disk" + open + set current view of container window to icon view + set toolbar visible of container window to false + set statusbar visible of container window to false + set the bounds of container window to {$window_bounds} + set theViewOptions to the icon view options of container window + set arrangement of theViewOptions to not arranged + set icon size of theViewOptions to $icon_size + $background_commands + $items_positions + close -- close/reopen works around a bug... + open + update without registering applications + delay 5 + eject + end tell + end tell + end run + """) + + itemscript = Template('set position of item "${item}" of container window to {${position}}') + items_positions = [] if fancy.has_key("items_position"): for name, position in fancy["items_position"].iteritems(): - window.items[name].position.set(position) - disk.close() + params = { "item" : name, "position" : ",".join([str(p) for p in position]) } + items_positions.append(itemscript.substitute(params)) + + params = { + "disk" : "HyperStake-Qt", + "window_bounds" : "300,300,800,620", + "icon_size" : "96", + "background_commands" : "", + "items_positions" : "\n ".join(items_positions) + } + if fancy.has_key("window_bounds"): + params["window.bounds"] = ",".join([str(p) for p in fancy["window_bounds"]]) + if fancy.has_key("icon_size"): + params["icon_size"] = str(fancy["icon_size"]) if bg_path is not None: - subprocess.call(["SetFile", "-a", "V", bg_path]) - disk.update(registering_applications=False) - sleep(2) - disk.eject() - + # Set background file, then call SetFile to make it invisible. + # (note: making it invisible first makes set background picture fail) + bgscript = Template("""set background picture of theViewOptions to file ".background:$bgpic" + do shell script "SetFile -a V /Volumes/$disk/.background/$bgpic" """) + params["background_commands"] = bgscript.substitute({"bgpic" : os.path.basename(bg_path), "disk" : params["disk"]}) + + s = appscript.substitute(params) + if verbose >= 2: + print("Running AppleScript:") + print(s) + + p = subprocess.Popen(['osascript', '-'], stdin=subprocess.PIPE) + p.communicate(input=s) + if p.returncode: + print("Error running osascript.") + if verbose >= 2: print "+ Finalizing .dmg disk image +" - + time.sleep(5) + try: runHDIUtil("convert", dmg_name + ".temp", format="UDBZ", o=dmg_name + ".dmg", ov=True) except subprocess.CalledProcessError as e: sys.exit(e.returncode) - + os.unlink(dmg_name + ".temp.dmg") # ------------------------------------------------ diff --git a/contrib/macdeploy/notes.txt b/contrib/macdeploy/notes.txt deleted file mode 100644 index ac16c485c..000000000 --- a/contrib/macdeploy/notes.txt +++ /dev/null @@ -1,26 +0,0 @@ - -macdeployqtplus works best on OS X Lion, for Snow Leopard you'd need to install -Python 2.7 and make it your default Python installation. - -You will need the appscript package for the fancy disk image creation to work. -Install it by invoking "sudo easy_install appscript". - -Ths script should be invoked in the target directory like this: -$source_dir/contrib/macdeploy/macdeployqtplus X11Coin-Qt.app -add-qt-tr da,de,es,hu,ru,uk,zh_CN,zh_TW -dmg -fancy $source_dir/contrib/macdeploy/fancy.plist -verbose 2 - -During the process, the disk image window will pop up briefly where the fancy -settings are applied. This is normal, please do not interfere. - -You can also set up Qt Creator for invoking the script. For this, go to the -"Projects" tab on the left side, switch to "Run Settings" above and add a -deploy configuration. Next add a deploy step choosing "Custom Process Step". -Fill in the following. - -Enable custom process step: [x] -Command: %{sourceDir}/contrib/macdeploy/macdeployqtplus -Working directory: %{buildDir} -Command arguments: X11Coin-Qt.app -add-qt-tr da,de,es,hu,ru,uk,zh_CN,zh_TW -dmg -fancy %{sourceDir}/contrib/macdeploy/fancy.plist -verbose 2 - -After that you can start the deployment process through the menu with -Build -> Deploy Project "truckcoin-qt" - diff --git a/depends/.gitignore b/depends/.gitignore new file mode 100644 index 000000000..3cb4b9ac1 --- /dev/null +++ b/depends/.gitignore @@ -0,0 +1,10 @@ +SDKs/ +work/ +built/ +sources/ +config.site +x86_64* +i686* +mips* +arm* +aarch64* diff --git a/depends/Makefile b/depends/Makefile new file mode 100644 index 000000000..0ddd348e5 --- /dev/null +++ b/depends/Makefile @@ -0,0 +1,182 @@ +.NOTPARALLEL : + +SOURCES_PATH ?= $(BASEDIR)/sources +BASE_CACHE ?= $(BASEDIR)/built +SDK_PATH ?= $(BASEDIR)/SDKs +NO_QT ?= +NO_WALLET ?= +NO_UPNP ?= +FALLBACK_DOWNLOAD_PATH ?= https://bitcoincore.org/depends-sources + +BUILD = $(shell ./config.guess) +HOST ?= $(BUILD) +PATCHES_PATH = $(BASEDIR)/patches +BASEDIR = $(CURDIR) +HASH_LENGTH:=11 +DOWNLOAD_CONNECT_TIMEOUT:=10 +DOWNLOAD_RETRIES:=3 +HOST_ID_SALT ?= salt +BUILD_ID_SALT ?= salt + +host:=$(BUILD) +ifneq ($(HOST),) +host:=$(HOST) +host_toolchain:=$(HOST)- +endif + +ifneq ($(DEBUG),) +release_type=debug +else +release_type=release +endif + +base_build_dir=$(BASEDIR)/work/build +base_staging_dir=$(BASEDIR)/work/staging +base_download_dir=$(BASEDIR)/work/download +canonical_host:=$(shell ./config.sub $(HOST)) +build:=$(shell ./config.sub $(BUILD)) + +build_arch =$(firstword $(subst -, ,$(build))) +build_vendor=$(word 2,$(subst -, ,$(build))) +full_build_os:=$(subst $(build_arch)-$(build_vendor)-,,$(build)) +build_os:=$(findstring linux,$(full_build_os)) +build_os+=$(findstring darwin,$(full_build_os)) +build_os:=$(strip $(build_os)) +ifeq ($(build_os),) +build_os=$(full_build_os) +endif + +host_arch=$(firstword $(subst -, ,$(canonical_host))) +host_vendor=$(word 2,$(subst -, ,$(canonical_host))) +full_host_os:=$(subst $(host_arch)-$(host_vendor)-,,$(canonical_host)) +host_os:=$(findstring linux,$(full_host_os)) +host_os+=$(findstring darwin,$(full_host_os)) +host_os+=$(findstring mingw32,$(full_host_os)) +host_os:=$(strip $(host_os)) +ifeq ($(host_os),) +host_os=$(full_host_os) +endif + +$(host_arch)_$(host_os)_prefix=$(BASEDIR)/$(host) +$(host_arch)_$(host_os)_host=$(host) +host_prefix=$($(host_arch)_$(host_os)_prefix) +build_prefix=$(host_prefix)/native +build_host=$(build) + +AT_$(V):= +AT_:=@ +AT:=$(AT_$(V)) + +all: install + +include hosts/$(host_os).mk +include hosts/default.mk +include builders/$(build_os).mk +include builders/default.mk +include packages/packages.mk + +build_id_string:=$(BUILD_ID_SALT) +build_id_string+=$(shell $(build_CC) --version 2>/dev/null) +build_id_string+=$(shell $(build_AR) --version 2>/dev/null) +build_id_string+=$(shell $(build_CXX) --version 2>/dev/null) +build_id_string+=$(shell $(build_RANLIB) --version 2>/dev/null) +build_id_string+=$(shell $(build_STRIP) --version 2>/dev/null) + +$(host_arch)_$(host_os)_id_string:=$(HOST_ID_SALT) +$(host_arch)_$(host_os)_id_string+=$(shell $(host_CC) --version 2>/dev/null) +$(host_arch)_$(host_os)_id_string+=$(shell $(host_AR) --version 2>/dev/null) +$(host_arch)_$(host_os)_id_string+=$(shell $(host_CXX) --version 2>/dev/null) +$(host_arch)_$(host_os)_id_string+=$(shell $(host_RANLIB) --version 2>/dev/null) +$(host_arch)_$(host_os)_id_string+=$(shell $(host_STRIP) --version 2>/dev/null) + +qt_packages_$(NO_QT) = $(qt_packages) $(qt_$(host_os)_packages) $(qt_$(host_arch)_$(host_os)_packages) +wallet_packages_$(NO_WALLET) = $(wallet_packages) +upnp_packages_$(NO_UPNP) = $(upnp_packages) + +packages += $($(host_arch)_$(host_os)_packages) $($(host_os)_packages) $(qt_packages_) $(wallet_packages_) $(upnp_packages_) +native_packages += $($(host_arch)_$(host_os)_native_packages) $($(host_os)_native_packages) + +ifneq ($(qt_packages_),) +native_packages += $(qt_native_packages) +endif + +all_packages = $(packages) $(native_packages) + +meta_depends = Makefile funcs.mk builders/default.mk hosts/default.mk hosts/$(host_os).mk builders/$(build_os).mk + +$(host_arch)_$(host_os)_native_toolchain?=$($(host_os)_native_toolchain) + +include funcs.mk + +toolchain_path=$($($(host_arch)_$(host_os)_native_toolchain)_prefixbin) +final_build_id_long+=$(shell $(build_SHA256SUM) config.site.in) +final_build_id+=$(shell echo -n "$(final_build_id_long)" | $(build_SHA256SUM) | cut -c-$(HASH_LENGTH)) +$(host_prefix)/.stamp_$(final_build_id): $(native_packages) $(packages) + $(AT)rm -rf $(@D) + $(AT)mkdir -p $(@D) + $(AT)echo copying packages: $^ + $(AT)echo to: $(@D) + $(AT)cd $(@D); $(foreach package,$^, tar xf $($(package)_cached); ) + $(AT)touch $@ + +$(host_prefix)/share/config.site : config.site.in $(host_prefix)/.stamp_$(final_build_id) + $(AT)@mkdir -p $(@D) + $(AT)sed -e 's|@HOST@|$(host)|' \ + -e 's|@CC@|$(toolchain_path)$(host_CC)|' \ + -e 's|@CXX@|$(toolchain_path)$(host_CXX)|' \ + -e 's|@AR@|$(toolchain_path)$(host_AR)|' \ + -e 's|@RANLIB@|$(toolchain_path)$(host_RANLIB)|' \ + -e 's|@NM@|$(toolchain_path)$(host_NM)|' \ + -e 's|@STRIP@|$(toolchain_path)$(host_STRIP)|' \ + -e 's|@build_os@|$(build_os)|' \ + -e 's|@host_os@|$(host_os)|' \ + -e 's|@CFLAGS@|$(strip $(host_CFLAGS) $(host_$(release_type)_CFLAGS))|' \ + -e 's|@CXXFLAGS@|$(strip $(host_CXXFLAGS) $(host_$(release_type)_CXXFLAGS))|' \ + -e 's|@CPPFLAGS@|$(strip $(host_CPPFLAGS) $(host_$(release_type)_CPPFLAGS))|' \ + -e 's|@LDFLAGS@|$(strip $(host_LDFLAGS) $(host_$(release_type)_LDFLAGS))|' \ + -e 's|@allow_host_packages@|$(ALLOW_HOST_PACKAGES)|' \ + -e 's|@no_qt@|$(NO_QT)|' \ + -e 's|@no_wallet@|$(NO_WALLET)|' \ + -e 's|@no_upnp@|$(NO_UPNP)|' \ + -e 's|@debug@|$(DEBUG)|' \ + $< > $@ + $(AT)touch $@ + + +define check_or_remove_cached + mkdir -p $(BASE_CACHE)/$(host)/$(package) && cd $(BASE_CACHE)/$(host)/$(package); \ + $(build_SHA256SUM) -c $($(package)_cached_checksum) >/dev/null 2>/dev/null || \ + ( rm -f $($(package)_cached_checksum); \ + if test -f "$($(package)_cached)"; then echo "Checksum mismatch for $(package). Forcing rebuild.."; rm -f $($(package)_cached_checksum) $($(package)_cached); fi ) +endef + +define check_or_remove_sources + mkdir -p $($(package)_source_dir); cd $($(package)_source_dir); \ + test -f $($(package)_fetched) && ( $(build_SHA256SUM) -c $($(package)_fetched) >/dev/null 2>/dev/null || \ + ( echo "Checksum missing or mismatched for $(package) source. Forcing re-download."; \ + rm -f $($(package)_all_sources) $($(1)_fetched))) || true +endef + +check-packages: + @$(foreach package,$(all_packages),$(call check_or_remove_cached,$(package));) +check-sources: + @$(foreach package,$(all_packages),$(call check_or_remove_sources,$(package));) + +$(host_prefix)/share/config.site: check-packages + +check-packages: check-sources + +install: check-packages $(host_prefix)/share/config.site + + +download-one: check-sources $(all_sources) + +download-osx: + @$(MAKE) -s HOST=x86_64-apple-darwin11 download-one +download-linux: + @$(MAKE) -s HOST=x86_64-unknown-linux-gnu download-one +download-win: + @$(MAKE) -s HOST=x86_64-w64-mingw32 download-one +download: download-osx download-linux download-win + +.PHONY: install cached download-one download-osx download-linux download-win download check-packages check-sources diff --git a/depends/README.md b/depends/README.md new file mode 100644 index 000000000..99eef1952 --- /dev/null +++ b/depends/README.md @@ -0,0 +1,75 @@ +### Usage + +To build dependencies for the current arch+OS: + + make + +To build for another arch/OS: + + make HOST=host-platform-triplet + +For example: + + make HOST=x86_64-w64-mingw32 -j4 + +A prefix will be generated that's suitable for plugging into Bitcoin's +configure. In the above example, a dir named x86_64-w64-mingw32 will be +created. To use it for Bitcoin: + + ./configure --prefix=`pwd`/depends/x86_64-w64-mingw32 + +Common `host-platform-triplets` for cross compilation are: + +- `i686-w64-mingw32` for Win32 +- `x86_64-w64-mingw32` for Win64 +- `x86_64-apple-darwin11` for MacOSX +- `arm-linux-gnueabihf` for Linux ARM 32 bit +- `aarch64-linux-gnu` for Linux ARM 64 bit + +No other options are needed, the paths are automatically configured. + +Install the required dependencies: Ubuntu & Debian +-------------------------------------------------- + +For macOS cross compilation: + + sudo apt-get install curl librsvg2-bin libtiff-tools bsdmainutils cmake imagemagick libcap-dev libz-dev libbz2-dev python-setuptools + +For Win32/Win64 cross compilation: + +- see [build-windows.md](../doc/build-windows.md#cross-compilation-for-ubuntu-and-windows-subsystem-for-linux) + +For linux (including i386, ARM) cross compilation: + + sudo apt-get install curl g++-aarch64-linux-gnu g++-4.8-aarch64-linux-gnu gcc-4.8-aarch64-linux-gnu binutils-aarch64-linux-gnu g++-arm-linux-gnueabihf g++-4.8-arm-linux-gnueabihf gcc-4.8-arm-linux-gnueabihf binutils-arm-linux-gnueabihf g++-4.8-multilib gcc-4.8-multilib binutils-gold bsdmainutils + + +Dependency Options: +The following can be set when running make: make FOO=bar + + SOURCES_PATH: downloaded sources will be placed here + BASE_CACHE: built packages will be placed here + SDK_PATH: Path where sdk's can be found (used by OSX) + FALLBACK_DOWNLOAD_PATH: If a source file can't be fetched, try here before giving up + NO_QT: Don't download/build/cache qt and its dependencies + NO_WALLET: Don't download/build/cache libs needed to enable the wallet + NO_UPNP: Don't download/build/cache packages needed for enabling upnp + DEBUG: disable some optimizations and enable more runtime checking + HOST_ID_SALT: Optional salt to use when generating host package ids + BUILD_ID_SALT: Optional salt to use when generating build package ids + +If some packages are not built, for example `make NO_WALLET=1`, the appropriate +options will be passed to bitcoin's configure. In this case, `--disable-wallet`. + +Additional targets: + + download: run 'make download' to fetch all sources without building them + download-osx: run 'make download-osx' to fetch all sources needed for osx builds + download-win: run 'make download-win' to fetch all sources needed for win builds + download-linux: run 'make download-linux' to fetch all sources needed for linux builds + +### Other documentation + +- [description.md](description.md): General description of the depends system +- [packages.md](packages.md): Steps for adding packages + diff --git a/depends/builders/darwin.mk b/depends/builders/darwin.mk new file mode 100644 index 000000000..27f550ab0 --- /dev/null +++ b/depends/builders/darwin.mk @@ -0,0 +1,22 @@ +build_darwin_CC: = $(shell xcrun -f clang) +build_darwin_CXX: = $(shell xcrun -f clang++) +build_darwin_AR: = $(shell xcrun -f ar) +build_darwin_RANLIB: = $(shell xcrun -f ranlib) +build_darwin_STRIP: = $(shell xcrun -f strip) +build_darwin_OTOOL: = $(shell xcrun -f otool) +build_darwin_NM: = $(shell xcrun -f nm) +build_darwin_INSTALL_NAME_TOOL:=$(shell xcrun -f install_name_tool) +build_darwin_SHA256SUM = shasum -a 256 +build_darwin_DOWNLOAD = curl --location --fail --connect-timeout $(DOWNLOAD_CONNECT_TIMEOUT) --retry $(DOWNLOAD_RETRIES) -o + +#darwin host on darwin builder. overrides darwin host preferences. +darwin_CC=$(shell xcrun -f clang) -mmacosx-version-min=$(OSX_MIN_VERSION) +darwin_CXX:=$(shell xcrun -f clang++) -mmacosx-version-min=$(OSX_MIN_VERSION) -stdlib=libc++ +darwin_AR:=$(shell xcrun -f ar) +darwin_RANLIB:=$(shell xcrun -f ranlib) +darwin_STRIP:=$(shell xcrun -f strip) +darwin_LIBTOOL:=$(shell xcrun -f libtool) +darwin_OTOOL:=$(shell xcrun -f otool) +darwin_NM:=$(shell xcrun -f nm) +darwin_INSTALL_NAME_TOOL:=$(shell xcrun -f install_name_tool) +darwin_native_toolchain= diff --git a/depends/builders/default.mk b/depends/builders/default.mk new file mode 100644 index 000000000..f097db65d --- /dev/null +++ b/depends/builders/default.mk @@ -0,0 +1,20 @@ +default_build_CC = gcc +default_build_CXX = g++ +default_build_AR = ar +default_build_RANLIB = ranlib +default_build_STRIP = strip +default_build_NM = nm +default_build_OTOOL = otool +default_build_INSTALL_NAME_TOOL = install_name_tool + +define add_build_tool_func +build_$(build_os)_$1 ?= $$(default_build_$1) +build_$(build_arch)_$(build_os)_$1 ?= $$(build_$(build_os)_$1) +build_$1=$$(build_$(build_arch)_$(build_os)_$1) +endef +$(foreach var,CC CXX AR RANLIB NM STRIP SHA256SUM DOWNLOAD OTOOL INSTALL_NAME_TOOL,$(eval $(call add_build_tool_func,$(var)))) +define add_build_flags_func +build_$(build_arch)_$(build_os)_$1 += $(build_$(build_os)_$1) +build_$1=$$(build_$(build_arch)_$(build_os)_$1) +endef +$(foreach flags, CFLAGS CXXFLAGS LDFLAGS, $(eval $(call add_build_flags_func,$(flags)))) diff --git a/depends/builders/linux.mk b/depends/builders/linux.mk new file mode 100644 index 000000000..b03f42401 --- /dev/null +++ b/depends/builders/linux.mk @@ -0,0 +1,2 @@ +build_linux_SHA256SUM = sha256sum +build_linux_DOWNLOAD = curl --location --fail --connect-timeout $(DOWNLOAD_CONNECT_TIMEOUT) --retry $(DOWNLOAD_RETRIES) -o diff --git a/depends/config.guess b/depends/config.guess new file mode 100755 index 000000000..69ed3e573 --- /dev/null +++ b/depends/config.guess @@ -0,0 +1,1466 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright 1992-2017 Free Software Foundation, Inc. + +timestamp='2017-03-05' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). +# +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. +# +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess +# +# Please send patches to . + + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright 1992-2017 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +case "${UNAME_SYSTEM}" in +Linux|GNU|GNU/*) + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + LIBC=gnu + + eval $set_cc_for_build + cat <<-EOF > $dummy.c + #include + #if defined(__UCLIBC__) + LIBC=uclibc + #elif defined(__dietlibc__) + LIBC=dietlibc + #else + LIBC=gnu + #endif + EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + ;; +esac + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ + /sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || \ + echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; + earmv*) + arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` + machine=${arch}${endian}-unknown + ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently (or will in the future) and ABI. + case "${UNAME_MACHINE_ARCH}" in + earm*) + os=netbsdelf + ;; + arm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ELF__ + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # Determine ABI tags. + case "${UNAME_MACHINE_ARCH}" in + earm*) + expr='s/^earmv[0-9]/-eabi/;s/eb$//' + abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}${abi}" + exit ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:LibertyBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-libertybsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerpc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:Sortix:*:*) + echo ${UNAME_MACHINE}-unknown-sortix + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE=alpha ;; + "EV4.5 (21064)") + UNAME_MACHINE=alpha ;; + "LCA4 (21066/21068)") + UNAME_MACHINE=alpha ;; + "EV5 (21164)") + UNAME_MACHINE=alphaev5 ;; + "EV5.6 (21164A)") + UNAME_MACHINE=alphaev56 ;; + "EV5.6 (21164PC)") + UNAME_MACHINE=alphapca56 ;; + "EV5.7 (21164PC)") + UNAME_MACHINE=alphapca57 ;; + "EV6 (21264)") + UNAME_MACHINE=alphaev6 ;; + "EV6.7 (21264A)") + UNAME_MACHINE=alphaev67 ;; + "EV6.8CB (21264C)") + UNAME_MACHINE=alphaev68 ;; + "EV6.8AL (21264B)") + UNAME_MACHINE=alphaev68 ;; + "EV6.8CX (21264D)") + UNAME_MACHINE=alphaev68 ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE=alphaev69 ;; + "EV7 (21364)") + UNAME_MACHINE=alphaev7 ;; + "EV7.9 (21364A)") + UNAME_MACHINE=alphaev79 ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + exitcode=$? + trap '' 0 + exit $exitcode ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm*:riscos:*:*|arm*:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + s390x:SunOS:*:*) + echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + echo i386-pc-auroraux${UNAME_RELEASE} + exit ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + eval $set_cc_for_build + SUN_ARCH=i386 + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH=x86_64 + fi + fi + echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = x && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos${UNAME_RELEASE} + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[4567]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/lslpp ] ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | + awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0 + 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH=hppa2.0n ;; + 64) HP_ARCH=hppa2.0w ;; + '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS="" $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = hppa2.0w ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | + grep -q __LP64__ + then + HP_ARCH=hppa2.0w + else + HP_ARCH=hppa64 + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz` + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:FreeBSD:*:*) + UNAME_PROCESSOR=`/usr/bin/uname -p` + case ${UNAME_PROCESSOR} in + amd64) + UNAME_PROCESSOR=x86_64 ;; + i386) + UNAME_PROCESSOR=i586 ;; + esac + echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + *:MINGW64*:*) + echo ${UNAME_MACHINE}-pc-mingw64 + exit ;; + *:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + *:MSYS*:*) + echo ${UNAME_MACHINE}-pc-msys + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + *:Interix*:*) + case ${UNAME_MACHINE} in + x86) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + authenticamd | genuineintel | EM64T) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + IA64) + echo ia64-unknown-interix${UNAME_RELEASE} + exit ;; + esac ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + 8664:Windows_NT:*) + echo x86_64-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + aarch64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC=gnulibc1 ; fi + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + arc:Linux:*:* | arceb:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + arm*:Linux:*:*) + eval $set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + else + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi + else + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf + fi + fi + exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + cris:Linux:*:*) + echo ${UNAME_MACHINE}-axis-linux-${LIBC} + exit ;; + crisv32:Linux:*:*) + echo ${UNAME_MACHINE}-axis-linux-${LIBC} + exit ;; + e2k:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + frv:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + hexagon:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + i*86:Linux:*:*) + echo ${UNAME_MACHINE}-pc-linux-${LIBC} + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + k1om:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + mips:Linux:*:* | mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=${UNAME_MACHINE}el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=${UNAME_MACHINE} + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } + ;; + mips64el:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + openrisc*:Linux:*:*) + echo or1k-unknown-linux-${LIBC} + exit ;; + or32:Linux:*:* | or1k*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + padre:Linux:*:*) + echo sparc-unknown-linux-${LIBC} + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-${LIBC} + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; + PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; + *) echo hppa-unknown-linux-${LIBC} ;; + esac + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-${LIBC} + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-${LIBC} + exit ;; + ppc64le:Linux:*:*) + echo powerpc64le-unknown-linux-${LIBC} + exit ;; + ppcle:Linux:*:*) + echo powerpcle-unknown-linux-${LIBC} + exit ;; + riscv32:Linux:*:* | riscv64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux-${LIBC} + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + tile*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-${LIBC} + exit ;; + x86_64:Linux:*:*) + echo ${UNAME_MACHINE}-pc-linux-${LIBC} + exit ;; + xtensa*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configure will decide that + # this is a cross-build. + echo i586-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; + x86_64:Haiku:*:*) + echo x86_64-unknown-haiku + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux${UNAME_RELEASE} + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux${UNAME_RELEASE} + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux${UNAME_RELEASE} + exit ;; + SX-ACE:SUPER-UX:*:*) + echo sxace-nec-superux${UNAME_RELEASE} + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + eval $set_cc_for_build + if test "$UNAME_PROCESSOR" = unknown ; then + UNAME_PROCESSOR=powerpc + fi + if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then + if [ "$CC_FOR_BUILD" != no_compiler_found ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + fi + elif test "$UNAME_PROCESSOR" = i386 ; then + # Avoid executing cc on OS X 10.9, as it ships with a stub + # that puts up a graphical alert prompting to install + # developer tools. Any system running Mac OS X 10.7 or + # later (Darwin 11 and later) is required to have a 64-bit + # processor. This is not true of the ARM version of Darwin + # that Apple uses in portable devices. + UNAME_PROCESSOR=x86_64 + fi + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = x86; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NEO-?:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk${UNAME_RELEASE} + exit ;; + NSE-*:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + NSX-?:NONSTOP_KERNEL:*:*) + echo nsx-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = 386; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE} | sed -e 's/ .*$//'` + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; + i*86:AROS:*:*) + echo ${UNAME_MACHINE}-pc-aros + exit ;; + x86_64:VMkernel:*:*) + echo ${UNAME_MACHINE}-unknown-esx + exit ;; + amd64:Isilon\ OneFS:*:*) + echo x86_64-unknown-onefs + exit ;; +esac + +cat >&2 </dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/depends/config.site.in b/depends/config.site.in new file mode 100644 index 000000000..0a4a9c327 --- /dev/null +++ b/depends/config.site.in @@ -0,0 +1,100 @@ +depends_prefix="`dirname ${ac_site_file}`/.." + +cross_compiling=maybe +host_alias=@HOST@ +ac_tool_prefix=${host_alias}- + +if test -z $with_boost; then + with_boost=$depends_prefix +fi +if test -z $with_qt_plugindir; then + with_qt_plugindir=$depends_prefix/plugins +fi +if test -z $with_qt_translationdir; then + with_qt_translationdir=$depends_prefix/translations +fi +if test -z $with_qt_bindir && test -z "@no_qt@"; then + with_qt_bindir=$depends_prefix/native/bin +fi +if test -z $with_protoc_bindir && test -z "@no_qt@"; then + with_protoc_bindir=$depends_prefix/native/bin +fi + + +if test -z $enable_wallet && test -n "@no_wallet@"; then + enable_wallet=no +fi + +if test -z $with_miniupnpc && test -n "@no_upnp@"; then + with_miniupnpc=no +fi + +if test -z $with_gui && test -n "@no_qt@"; then + with_gui=no +fi + +if test x@host_os@ = xdarwin; then + BREW=no + PORT=no +fi + +if test x@host_os@ = xmingw32; then + if test -z $with_qt_incdir; then + with_qt_incdir=$depends_prefix/include + fi + if test -z $with_qt_libdir; then + with_qt_libdir=$depends_prefix/lib + fi +fi + +PATH=$depends_prefix/native/bin:$PATH +PKG_CONFIG="`which pkg-config` --static" + +# These two need to remain exported because pkg-config does not see them +# otherwise. That means they must be unexported at the end of configure.ac to +# avoid ruining the cache. Sigh. +export PKG_CONFIG_PATH=$depends_prefix/share/pkgconfig:$depends_prefix/lib/pkgconfig +if test -z "@allow_host_packages@"; then + export PKGCONFIG_LIBDIR= +fi + +CPPFLAGS="-I$depends_prefix/include/ $CPPFLAGS" +LDFLAGS="-L$depends_prefix/lib $LDFLAGS" + +CC="@CC@" +CXX="@CXX@" +OBJC="${CC}" +CCACHE=$depends_prefix/native/bin/ccache +PYTHONPATH=$depends_prefix/native/lib/python/dist-packages:$PYTHONPATH + +if test -n "@AR@"; then + AR=@AR@ + ac_cv_path_ac_pt_AR=${AR} +fi + +if test -n "@RANLIB@"; then + RANLIB=@RANLIB@ + ac_cv_path_ac_pt_RANLIB=${RANLIB} +fi + +if test -n "@NM@"; then + NM=@NM@ + ac_cv_path_ac_pt_NM=${NM} +fi + +if test -n "@debug@"; then + enable_reduce_exports=no +fi + +if test -n "@CFLAGS@"; then + CFLAGS="@CFLAGS@ $CFLAGS" +fi +if test -n "@CXXFLAGS@"; then + CXXFLAGS="@CXXFLAGS@ $CXXFLAGS" +fi +if test -n "@CPPFLAGS@"; then + CPPFLAGS="@CPPFLAGS@ $CPPFLAGS" +fi +if test -n "@LDFLAGS@"; then + LDFLAGS="@LDFLAGS@ $LDFLAGS" +fi diff --git a/depends/config.sub b/depends/config.sub new file mode 100755 index 000000000..40ea5dfe1 --- /dev/null +++ b/depends/config.sub @@ -0,0 +1,1836 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright 1992-2017 Free Software Foundation, Inc. + +timestamp='2017-04-02' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). + + +# Please send patches to . +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright 1992-2017 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ + linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ + kopensolaris*-gnu* | cloudabi*-eabi* | \ + storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + android-linux) + os=-linux-android + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray | -microblaze*) + os= + basic_machine=$1 + ;; + -bluegene*) + os=-cnk + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*178) + os=-lynxos178 + ;; + -lynx*5) + os=-lynxos5 + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arceb \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ + | avr | avr32 \ + | ba \ + | be32 | be64 \ + | bfin \ + | c4x | c8051 | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | e2k | epiphany \ + | fido | fr30 | frv | ft32 \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i860 | i960 | ia16 | ia64 \ + | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ + | lm32 \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r6 | mipsisa32r6el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r6 | mipsisa64r6el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nios | nios2 | nios2eb | nios2el \ + | ns16k | ns32k \ + | open8 | or1k | or1knd | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pru \ + | pyramid \ + | riscv32 | riscv64 \ + | rl78 | rx \ + | score \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu \ + | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ + | ubicom32 \ + | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ + | visium \ + | wasm32 \ + | we32k \ + | x86 | xc16x | xstormy16 | xtensa \ + | z8k | z80) + basic_machine=$basic_machine-unknown + ;; + c54x) + basic_machine=tic54x-unknown + ;; + c55x) + basic_machine=tic55x-unknown + ;; + c6x) + basic_machine=tic6x-unknown + ;; + leon|leon[3-9]) + basic_machine=sparc-$basic_machine + ;; + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + ms1) + basic_machine=mt-unknown + ;; + + strongarm | thumb | xscale) + basic_machine=arm-unknown + ;; + xgate) + basic_machine=$basic_machine-unknown + os=-none + ;; + xscaleeb) + basic_machine=armeb-unknown + ;; + + xscaleel) + basic_machine=armel-unknown + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | aarch64-* | aarch64_be-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | ba-* \ + | be32-* | be64-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ + | c8051-* | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | e2k-* | elxsi-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | hexagon-* \ + | i*86-* | i860-* | i960-* | ia16-* | ia64-* \ + | ip2k-* | iq2000-* \ + | k1om-* \ + | le32-* | le64-* \ + | lm32-* \ + | m32c-* | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ + | microblaze-* | microblazeel-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64octeon-* | mips64octeonel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64r5900-* | mips64r5900el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa32r6-* | mipsisa32r6el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64r6-* | mipsisa64r6el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipsr5900-* | mipsr5900el-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nds32-* | nds32le-* | nds32be-* \ + | nios-* | nios2-* | nios2eb-* | nios2el-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ + | or1k*-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pru-* \ + | pyramid-* \ + | riscv32-* | riscv64-* \ + | rl78-* | romp-* | rs6000-* | rx-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ + | tahoe-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tile*-* \ + | tron-* \ + | ubicom32-* \ + | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ + | vax-* \ + | visium-* \ + | wasm32-* \ + | we32k-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* \ + | xstormy16-* | xtensa*-* \ + | ymp-* \ + | z8k-* | z80-*) + ;; + # Recognize the basic CPU types without company name, with glob match. + xtensa*) + basic_machine=$basic_machine-unknown + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aros) + basic_machine=i386-pc + os=-aros + ;; + asmjs) + basic_machine=asmjs-unknown + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + blackfin) + basic_machine=bfin-unknown + os=-linux + ;; + blackfin-*) + basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + bluegene*) + basic_machine=powerpc-ibm + os=-cnk + ;; + c54x-*) + basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c55x-*) + basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c6x-*) + basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + cegcc) + basic_machine=arm-unknown + os=-cegcc + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16 | cr16-*) + basic_machine=cr16-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dicos) + basic_machine=i686-pc + os=-dicos + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + e500v[12]) + basic_machine=powerpc-unknown + os=$os"spe" + ;; + e500v[12]-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + os=$os"spe" + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + leon-*|leon[3-9]-*) + basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` + ;; + m68knommu) + basic_machine=m68k-unknown + os=-linux + ;; + m68knommu-*) + basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + microblaze*) + basic_machine=microblaze-xilinx + ;; + mingw64) + basic_machine=x86_64-pc + os=-mingw64 + ;; + mingw32) + basic_machine=i686-pc + os=-mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + os=-mingw32ce + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + moxiebox) + basic_machine=moxie-unknown + os=-moxiebox + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; + msys) + basic_machine=i686-pc + os=-msys + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + nacl) + basic_machine=le32-unknown + os=-nacl + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + neo-tandem) + basic_machine=neo-tandem + ;; + nse-tandem) + basic_machine=nse-tandem + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + nsx-tandem) + basic_machine=nsx-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + parisc) + basic_machine=hppa-unknown + os=-linux + ;; + parisc-*) + basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc | ppcbe) basic_machine=powerpc-unknown + ;; + ppc-* | ppcbe-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + os=-rdos + ;; + rdos32) + basic_machine=i386-pc + os=-rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sde) + basic_machine=mipsisa32-sde + os=-elf + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh5el) + basic_machine=sh5le-unknown + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + strongarm-* | thumb-*) + basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tile*) + basic_machine=$basic_machine-unknown + os=-linux-gnu + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + wasm32) + basic_machine=wasm32-unknown + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + xscale-* | xscalee[bl]-*) + basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + z80-*-coff) + basic_machine=z80-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -auroraux) + os=-auroraux + ;; + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* | -cloudabi* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -bitrig* | -openbsd* | -solidbsd* | -libertybsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* | -cegcc* | -glidix* \ + | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -midipix* | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-musl* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* \ + | -onefs* | -tirtos* | -phoenix* | -fuchsia* | -redox*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -zvmoe) + os=-zvmoe + ;; + -dicos*) + os=-dicos + ;; + -nacl*) + ;; + -ios) + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + score-*) + os=-elf + ;; + spu-*) + os=-elf + ;; + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + c8051-*) + os=-elf + ;; + hexagon-*) + os=-elf + ;; + tic54x-*) + os=-coff + ;; + tic55x-*) + os=-coff + ;; + tic6x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + ;; + m68*-cisco) + os=-aout + ;; + mep-*) + os=-elf + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + pru-*) + os=-elf + ;; + *-be) + os=-beos + ;; + *-haiku) + os=-haiku + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -cnk*|-aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/depends/description.md b/depends/description.md new file mode 100644 index 000000000..74f9ef3f2 --- /dev/null +++ b/depends/description.md @@ -0,0 +1,53 @@ +This is a system of building and caching dependencies necessary for building Bitcoin. +There are several features that make it different from most similar systems: + +### It is designed to be builder and host agnostic + +In theory, binaries for any target OS/architecture can be created, from a +builder running any OS/architecture. In practice, build-side tools must be +specified when the defaults don't fit, and packages must be amended to work +on new hosts. For now, a build architecture of x86_64 is assumed, either on +Linux or OSX. + +### No reliance on timestamps + +File presence is used to determine what needs to be built. This makes the +results distributable and easily digestable by automated builders. + +### Each build only has its specified dependencies available at build-time. + +For each build, the sysroot is wiped and the (recursive) dependencies are +installed. This makes each build deterministic, since there will never be any +unknown files available to cause side-effects. + +### Each package is cached and only rebuilt as needed. + +Before building, a unique build-id is generated for each package. This id +consists of a hash of all files used to build the package (Makefiles, packages, +etc), and as well as a hash of the same data for each recursive dependency. If +any portion of a package's build recipe changes, it will be rebuilt as well as +any other package that depends on it. If any of the main makefiles (Makefile, +funcs.mk, etc) are changed, all packages will be rebuilt. After building, the +results are cached into a tarball that can be re-used and distributed. + +### Package build results are (relatively) deterministic. + +Each package is configured and patched so that it will yield the same +build-results with each consequent build, within a reasonable set of +constraints. Some things like timestamp insertion are unavoidable, and are +beyond the scope of this system. Additionally, the toolchain itself must be +capable of deterministic results. When revisions are properly bumped, a cached +build should represent an exact single payload. + +### Sources are fetched and verified automatically + +Each package must define its source location and checksum. The build will fail +if the fetched source does not match. Sources may be pre-seeded and/or cached +as desired. + +### Self-cleaning + +Build and staging dirs are wiped after use, and any previous version of a +cached result is removed following a successful build. Automated builders +should be able to build each revision and store the results with no further +intervention. diff --git a/depends/funcs.mk b/depends/funcs.mk new file mode 100644 index 000000000..15e404e42 --- /dev/null +++ b/depends/funcs.mk @@ -0,0 +1,245 @@ +define int_vars +#Set defaults for vars which may be overridden per-package +$(1)_cc=$($($(1)_type)_CC) +$(1)_cxx=$($($(1)_type)_CXX) +$(1)_objc=$($($(1)_type)_OBJC) +$(1)_objcxx=$($($(1)_type)_OBJCXX) +$(1)_ar=$($($(1)_type)_AR) +$(1)_ranlib=$($($(1)_type)_RANLIB) +$(1)_libtool=$($($(1)_type)_LIBTOOL) +$(1)_nm=$($($(1)_type)_NM) +$(1)_cflags=$($($(1)_type)_CFLAGS) $($($(1)_type)_$(release_type)_CFLAGS) +$(1)_cxxflags=$($($(1)_type)_CXXFLAGS) $($($(1)_type)_$(release_type)_CXXFLAGS) +$(1)_ldflags=$($($(1)_type)_LDFLAGS) $($($(1)_type)_$(release_type)_LDFLAGS) -L$($($(1)_type)_prefix)/lib +$(1)_cppflags=$($($(1)_type)_CPPFLAGS) $($($(1)_type)_$(release_type)_CPPFLAGS) -I$($($(1)_type)_prefix)/include +$(1)_recipe_hash:= +endef + +define int_get_all_dependencies +$(sort $(foreach dep,$(2),$(2) $(call int_get_all_dependencies,$(1),$($(dep)_dependencies)))) +endef + +define fetch_file_inner + ( mkdir -p $$($(1)_download_dir) && echo Fetching $(3) from $(2) && \ + $(build_DOWNLOAD) "$$($(1)_download_dir)/$(4).temp" "$(2)/$(3)" && \ + echo "$(5) $$($(1)_download_dir)/$(4).temp" > $$($(1)_download_dir)/.$(4).hash && \ + $(build_SHA256SUM) -c $$($(1)_download_dir)/.$(4).hash && \ + mv $$($(1)_download_dir)/$(4).temp $$($(1)_source_dir)/$(4) && \ + rm -rf $$($(1)_download_dir) ) +endef + +define fetch_file + ( test -f $$($(1)_source_dir)/$(4) || \ + ( $(call fetch_file_inner,$(1),$(2),$(3),$(4),$(5)) || \ + $(call fetch_file_inner,$(1),$(FALLBACK_DOWNLOAD_PATH),$(3),$(4),$(5)))) +endef + +define int_get_build_recipe_hash +$(eval $(1)_all_file_checksums:=$(shell $(build_SHA256SUM) $(meta_depends) packages/$(1).mk $(addprefix $(PATCHES_PATH)/$(1)/,$($(1)_patches)) | cut -d" " -f1)) +$(eval $(1)_recipe_hash:=$(shell echo -n "$($(1)_all_file_checksums)" | $(build_SHA256SUM) | cut -d" " -f1)) +endef + +define int_get_build_id +$(eval $(1)_dependencies += $($(1)_$(host_arch)_$(host_os)_dependencies) $($(1)_$(host_os)_dependencies)) +$(eval $(1)_all_dependencies:=$(call int_get_all_dependencies,$(1),$($($(1)_type)_native_toolchain) $($(1)_dependencies))) +$(foreach dep,$($(1)_all_dependencies),$(eval $(1)_build_id_deps+=$(dep)-$($(dep)_version)-$($(dep)_recipe_hash))) +$(eval $(1)_build_id_long:=$(1)-$($(1)_version)-$($(1)_recipe_hash)-$(release_type) $($(1)_build_id_deps) $($($(1)_type)_id_string)) +$(eval $(1)_build_id:=$(shell echo -n "$($(1)_build_id_long)" | $(build_SHA256SUM) | cut -c-$(HASH_LENGTH))) +final_build_id_long+=$($(package)_build_id_long) + +#compute package-specific paths +$(1)_build_subdir?=. +$(1)_download_file?=$($(1)_file_name) +$(1)_source_dir:=$(SOURCES_PATH) +$(1)_source:=$$($(1)_source_dir)/$($(1)_file_name) +$(1)_staging_dir=$(base_staging_dir)/$(host)/$(1)/$($(1)_version)-$($(1)_build_id) +$(1)_staging_prefix_dir:=$$($(1)_staging_dir)$($($(1)_type)_prefix) +$(1)_extract_dir:=$(base_build_dir)/$(host)/$(1)/$($(1)_version)-$($(1)_build_id) +$(1)_download_dir:=$(base_download_dir)/$(1)-$($(1)_version) +$(1)_build_dir:=$$($(1)_extract_dir)/$$($(1)_build_subdir) +$(1)_cached_checksum:=$(BASE_CACHE)/$(host)/$(1)/$(1)-$($(1)_version)-$($(1)_build_id).tar.gz.hash +$(1)_patch_dir:=$(base_build_dir)/$(host)/$(1)/$($(1)_version)-$($(1)_build_id)/.patches-$($(1)_build_id) +$(1)_prefixbin:=$($($(1)_type)_prefix)/bin/ +$(1)_cached:=$(BASE_CACHE)/$(host)/$(1)/$(1)-$($(1)_version)-$($(1)_build_id).tar.gz +$(1)_all_sources=$($(1)_file_name) $($(1)_extra_sources) + +#stamps +$(1)_fetched=$(SOURCES_PATH)/download-stamps/.stamp_fetched-$(1)-$($(1)_file_name).hash +$(1)_extracted=$$($(1)_extract_dir)/.stamp_extracted +$(1)_preprocessed=$$($(1)_extract_dir)/.stamp_preprocessed +$(1)_cleaned=$$($(1)_extract_dir)/.stamp_cleaned +$(1)_built=$$($(1)_build_dir)/.stamp_built +$(1)_configured=$$($(1)_build_dir)/.stamp_configured +$(1)_staged=$$($(1)_staging_dir)/.stamp_staged +$(1)_postprocessed=$$($(1)_staging_prefix_dir)/.stamp_postprocessed +$(1)_download_path_fixed=$(subst :,\:,$$($(1)_download_path)) + + +#default commands +$(1)_fetch_cmds ?= $(call fetch_file,$(1),$(subst \:,:,$$($(1)_download_path_fixed)),$$($(1)_download_file),$($(1)_file_name),$($(1)_sha256_hash)) +$(1)_extract_cmds ?= mkdir -p $$($(1)_extract_dir) && echo "$$($(1)_sha256_hash) $$($(1)_source)" > $$($(1)_extract_dir)/.$$($(1)_file_name).hash && $(build_SHA256SUM) -c $$($(1)_extract_dir)/.$$($(1)_file_name).hash && tar --strip-components=1 -xf $$($(1)_source) +$(1)_preprocess_cmds ?= +$(1)_build_cmds ?= +$(1)_config_cmds ?= +$(1)_stage_cmds ?= +$(1)_set_vars ?= + + +all_sources+=$$($(1)_fetched) +endef +#$(foreach dep_target,$($(1)_all_dependencies),$(eval $(1)_dependency_targets=$($(dep_target)_cached))) + + +define int_config_attach_build_config +$(eval $(call $(1)_set_vars,$(1))) +$(1)_cflags+=$($(1)_cflags_$(release_type)) +$(1)_cflags+=$($(1)_cflags_$(host_arch)) $($(1)_cflags_$(host_arch)_$(release_type)) +$(1)_cflags+=$($(1)_cflags_$(host_os)) $($(1)_cflags_$(host_os)_$(release_type)) +$(1)_cflags+=$($(1)_cflags_$(host_arch)_$(host_os)) $($(1)_cflags_$(host_arch)_$(host_os)_$(release_type)) + +$(1)_cxxflags+=$($(1)_cxxflags_$(release_type)) +$(1)_cxxflags+=$($(1)_cxxflags_$(host_arch)) $($(1)_cxxflags_$(host_arch)_$(release_type)) +$(1)_cxxflags+=$($(1)_cxxflags_$(host_os)) $($(1)_cxxflags_$(host_os)_$(release_type)) +$(1)_cxxflags+=$($(1)_cxxflags_$(host_arch)_$(host_os)) $($(1)_cxxflags_$(host_arch)_$(host_os)_$(release_type)) + +$(1)_cppflags+=$($(1)_cppflags_$(release_type)) +$(1)_cppflags+=$($(1)_cppflags_$(host_arch)) $($(1)_cppflags_$(host_arch)_$(release_type)) +$(1)_cppflags+=$($(1)_cppflags_$(host_os)) $($(1)_cppflags_$(host_os)_$(release_type)) +$(1)_cppflags+=$($(1)_cppflags_$(host_arch)_$(host_os)) $($(1)_cppflags_$(host_arch)_$(host_os)_$(release_type)) + +$(1)_ldflags+=$($(1)_ldflags_$(release_type)) +$(1)_ldflags+=$($(1)_ldflags_$(host_arch)) $($(1)_ldflags_$(host_arch)_$(release_type)) +$(1)_ldflags+=$($(1)_ldflags_$(host_os)) $($(1)_ldflags_$(host_os)_$(release_type)) +$(1)_ldflags+=$($(1)_ldflags_$(host_arch)_$(host_os)) $($(1)_ldflags_$(host_arch)_$(host_os)_$(release_type)) + +$(1)_build_opts+=$$($(1)_build_opts_$(release_type)) +$(1)_build_opts+=$$($(1)_build_opts_$(host_arch)) $$($(1)_build_opts_$(host_arch)_$(release_type)) +$(1)_build_opts+=$$($(1)_build_opts_$(host_os)) $$($(1)_build_opts_$(host_os)_$(release_type)) +$(1)_build_opts+=$$($(1)_build_opts_$(host_arch)_$(host_os)) $$($(1)_build_opts_$(host_arch)_$(host_os)_$(release_type)) + +$(1)_config_opts+=$$($(1)_config_opts_$(release_type)) +$(1)_config_opts+=$$($(1)_config_opts_$(host_arch)) $$($(1)_config_opts_$(host_arch)_$(release_type)) +$(1)_config_opts+=$$($(1)_config_opts_$(host_os)) $$($(1)_config_opts_$(host_os)_$(release_type)) +$(1)_config_opts+=$$($(1)_config_opts_$(host_arch)_$(host_os)) $$($(1)_config_opts_$(host_arch)_$(host_os)_$(release_type)) + +$(1)_config_env+=$$($(1)_config_env_$(release_type)) +$(1)_config_env+=$($(1)_config_env_$(host_arch)) $($(1)_config_env_$(host_arch)_$(release_type)) +$(1)_config_env+=$($(1)_config_env_$(host_os)) $($(1)_config_env_$(host_os)_$(release_type)) +$(1)_config_env+=$($(1)_config_env_$(host_arch)_$(host_os)) $($(1)_config_env_$(host_arch)_$(host_os)_$(release_type)) + +$(1)_config_env+=PKG_CONFIG_LIBDIR=$($($(1)_type)_prefix)/lib/pkgconfig +$(1)_config_env+=PKG_CONFIG_PATH=$($($(1)_type)_prefix)/share/pkgconfig +$(1)_config_env+=PATH=$(build_prefix)/bin:$(PATH) +$(1)_build_env+=PATH=$(build_prefix)/bin:$(PATH) +$(1)_stage_env+=PATH=$(build_prefix)/bin:$(PATH) +$(1)_autoconf=./configure --host=$($($(1)_type)_host) --disable-dependency-tracking --prefix=$($($(1)_type)_prefix) $$($(1)_config_opts) CC="$$($(1)_cc)" CXX="$$($(1)_cxx)" + +ifneq ($($(1)_nm),) +$(1)_autoconf += NM="$$($(1)_nm)" +endif +ifneq ($($(1)_ranlib),) +$(1)_autoconf += RANLIB="$$($(1)_ranlib)" +endif +ifneq ($($(1)_ar),) +$(1)_autoconf += AR="$$($(1)_ar)" +endif +ifneq ($($(1)_cflags),) +$(1)_autoconf += CFLAGS="$$($(1)_cflags)" +endif +ifneq ($($(1)_cxxflags),) +$(1)_autoconf += CXXFLAGS="$$($(1)_cxxflags)" +endif +ifneq ($($(1)_cppflags),) +$(1)_autoconf += CPPFLAGS="$$($(1)_cppflags)" +endif +ifneq ($($(1)_ldflags),) +$(1)_autoconf += LDFLAGS="$$($(1)_ldflags)" +endif +endef + +define int_add_cmds +$($(1)_fetched): + $(AT)mkdir -p $$(@D) $(SOURCES_PATH) + $(AT)rm -f $$@ + $(AT)touch $$@ + $(AT)cd $$(@D); $(call $(1)_fetch_cmds,$(1)) + $(AT)cd $($(1)_source_dir); $(foreach source,$($(1)_all_sources),$(build_SHA256SUM) $(source) >> $$(@);) + $(AT)touch $$@ +$($(1)_extracted): | $($(1)_fetched) + $(AT)echo Extracting $(1)... + $(AT)mkdir -p $$(@D) + $(AT)cd $$(@D); $(call $(1)_extract_cmds,$(1)) + $(AT)touch $$@ +$($(1)_preprocessed): | $($(1)_dependencies) $($(1)_extracted) + $(AT)echo Preprocessing $(1)... + $(AT)mkdir -p $$(@D) $($(1)_patch_dir) + $(AT)$(foreach patch,$($(1)_patches),cd $(PATCHES_PATH)/$(1); cp $(patch) $($(1)_patch_dir) ;) + $(AT)cd $$(@D); $(call $(1)_preprocess_cmds, $(1)) + $(AT)touch $$@ +$($(1)_configured): | $($(1)_preprocessed) + $(AT)echo Configuring $(1)... + $(AT)rm -rf $(host_prefix); mkdir -p $(host_prefix)/lib; cd $(host_prefix); $(foreach package,$($(1)_all_dependencies), tar xf $($(package)_cached); ) + $(AT)mkdir -p $$(@D) + $(AT)+cd $$(@D); $($(1)_config_env) $(call $(1)_config_cmds, $(1)) + $(AT)touch $$@ +$($(1)_built): | $($(1)_configured) + $(AT)echo Building $(1)... + $(AT)mkdir -p $$(@D) + $(AT)+cd $$(@D); $($(1)_build_env) $(call $(1)_build_cmds, $(1)) + $(AT)touch $$@ +$($(1)_staged): | $($(1)_built) + $(AT)echo Staging $(1)... + $(AT)mkdir -p $($(1)_staging_dir)/$(host_prefix) + $(AT)cd $($(1)_build_dir); $($(1)_stage_env) $(call $(1)_stage_cmds, $(1)) + $(AT)rm -rf $($(1)_extract_dir) + $(AT)touch $$@ +$($(1)_postprocessed): | $($(1)_staged) + $(AT)echo Postprocessing $(1)... + $(AT)cd $($(1)_staging_prefix_dir); $(call $(1)_postprocess_cmds) + $(AT)touch $$@ +$($(1)_cached): | $($(1)_dependencies) $($(1)_postprocessed) + $(AT)echo Caching $(1)... + $(AT)cd $$($(1)_staging_dir)/$(host_prefix); find . | sort | tar --no-recursion -czf $$($(1)_staging_dir)/$$(@F) -T - + $(AT)mkdir -p $$(@D) + $(AT)rm -rf $$(@D) && mkdir -p $$(@D) + $(AT)mv $$($(1)_staging_dir)/$$(@F) $$(@) + $(AT)rm -rf $($(1)_staging_dir) +$($(1)_cached_checksum): $($(1)_cached) + $(AT)cd $$(@D); $(build_SHA256SUM) $$( $$(@) + +.PHONY: $(1) +$(1): | $($(1)_cached_checksum) +.SECONDARY: $($(1)_cached) $($(1)_postprocessed) $($(1)_staged) $($(1)_built) $($(1)_configured) $($(1)_preprocessed) $($(1)_extracted) $($(1)_fetched) + +endef + +# These functions create the build targets for each package. They must be +# broken down into small steps so that each part is done for all packages +# before moving on to the next step. Otherwise, a package's info +# (build-id for example) would only be available to another package if it +# happened to be computed already. + +#set the type for host/build packages. +$(foreach native_package,$(native_packages),$(eval $(native_package)_type=build)) +$(foreach package,$(packages),$(eval $(package)_type=$(host_arch)_$(host_os))) + +#set overridable defaults +$(foreach package,$(all_packages),$(eval $(call int_vars,$(package)))) + +#include package files +$(foreach package,$(all_packages),$(eval include packages/$(package).mk)) + +#compute a hash of all files that comprise this package's build recipe +$(foreach package,$(all_packages),$(eval $(call int_get_build_recipe_hash,$(package)))) + +#generate a unique id for this package, incorporating its dependencies as well +$(foreach package,$(all_packages),$(eval $(call int_get_build_id,$(package)))) + +#compute final vars after reading package vars +$(foreach package,$(all_packages),$(eval $(call int_config_attach_build_config,$(package)))) + +#create build targets +$(foreach package,$(all_packages),$(eval $(call int_add_cmds,$(package)))) + +#special exception: if a toolchain package exists, all non-native packages depend on it +$(foreach package,$(packages),$(eval $($(package)_unpacked): |$($($(host_arch)_$(host_os)_native_toolchain)_cached) )) diff --git a/depends/hosts/darwin.mk b/depends/hosts/darwin.mk new file mode 100644 index 000000000..4e58bec74 --- /dev/null +++ b/depends/hosts/darwin.mk @@ -0,0 +1,17 @@ +OSX_MIN_VERSION=10.8 +OSX_SDK_VERSION=10.11 +OSX_SDK=$(SDK_PATH)/MacOSX$(OSX_SDK_VERSION).sdk +LD64_VERSION=253.9 +darwin_CC=clang -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) +darwin_CXX=clang++ -target $(host) -mmacosx-version-min=$(OSX_MIN_VERSION) --sysroot $(OSX_SDK) -mlinker-version=$(LD64_VERSION) -stdlib=libc++ + +darwin_CFLAGS=-pipe +darwin_CXXFLAGS=$(darwin_CFLAGS) + +darwin_release_CFLAGS=-O2 +darwin_release_CXXFLAGS=$(darwin_release_CFLAGS) + +darwin_debug_CFLAGS=-O1 +darwin_debug_CXXFLAGS=$(darwin_debug_CFLAGS) + +darwin_native_toolchain=native_cctools diff --git a/depends/hosts/default.mk b/depends/hosts/default.mk new file mode 100644 index 000000000..6f60d6b3f --- /dev/null +++ b/depends/hosts/default.mk @@ -0,0 +1,26 @@ +default_host_CC = $(host_toolchain)gcc +default_host_CXX = $(host_toolchain)g++ +default_host_AR = $(host_toolchain)ar +default_host_RANLIB = $(host_toolchain)ranlib +default_host_STRIP = $(host_toolchain)strip +default_host_LIBTOOL = $(host_toolchain)libtool +default_host_INSTALL_NAME_TOOL = $(host_toolchain)install_name_tool +default_host_OTOOL = $(host_toolchain)otool +default_host_NM = $(host_toolchain)nm + +define add_host_tool_func +$(host_os)_$1?=$$(default_host_$1) +$(host_arch)_$(host_os)_$1?=$$($(host_os)_$1) +$(host_arch)_$(host_os)_$(release_type)_$1?=$$($(host_os)_$1) +host_$1=$$($(host_arch)_$(host_os)_$1) +endef + +define add_host_flags_func +$(host_arch)_$(host_os)_$1 += $($(host_os)_$1) +$(host_arch)_$(host_os)_$(release_type)_$1 += $($(host_os)_$(release_type)_$1) +host_$1 = $$($(host_arch)_$(host_os)_$1) +host_$(release_type)_$1 = $$($(host_arch)_$(host_os)_$(release_type)_$1) +endef + +$(foreach tool,CC CXX AR RANLIB STRIP NM LIBTOOL OTOOL INSTALL_NAME_TOOL,$(eval $(call add_host_tool_func,$(tool)))) +$(foreach flags,CFLAGS CXXFLAGS CPPFLAGS LDFLAGS, $(eval $(call add_host_flags_func,$(flags)))) diff --git a/depends/hosts/linux.mk b/depends/hosts/linux.mk new file mode 100644 index 000000000..b13a0f1ad --- /dev/null +++ b/depends/hosts/linux.mk @@ -0,0 +1,31 @@ +linux_CFLAGS=-pipe +linux_CXXFLAGS=$(linux_CFLAGS) + +linux_release_CFLAGS=-O2 +linux_release_CXXFLAGS=$(linux_release_CFLAGS) + +linux_debug_CFLAGS=-O1 +linux_debug_CXXFLAGS=$(linux_debug_CFLAGS) + +linux_debug_CPPFLAGS=-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC + +ifeq (86,$(findstring 86,$(build_arch))) +i686_linux_CC=gcc -m32 +i686_linux_CXX=g++ -m32 +i686_linux_AR=ar +i686_linux_RANLIB=ranlib +i686_linux_NM=nm +i686_linux_STRIP=strip + +x86_64_linux_CC=gcc -m64 +x86_64_linux_CXX=g++ -m64 +x86_64_linux_AR=ar +x86_64_linux_RANLIB=ranlib +x86_64_linux_NM=nm +x86_64_linux_STRIP=strip +else +i686_linux_CC=$(default_host_CC) -m32 +i686_linux_CXX=$(default_host_CXX) -m32 +x86_64_linux_CC=$(default_host_CC) -m64 +x86_64_linux_CXX=$(default_host_CXX) -m64 +endif diff --git a/depends/hosts/mingw32.mk b/depends/hosts/mingw32.mk new file mode 100644 index 000000000..dbfb62fdc --- /dev/null +++ b/depends/hosts/mingw32.mk @@ -0,0 +1,10 @@ +mingw32_CFLAGS=-pipe +mingw32_CXXFLAGS=$(mingw32_CFLAGS) + +mingw32_release_CFLAGS=-O2 +mingw32_release_CXXFLAGS=$(mingw32_release_CFLAGS) + +mingw32_debug_CFLAGS=-O1 +mingw32_debug_CXXFLAGS=$(mingw32_debug_CFLAGS) + +mingw32_debug_CPPFLAGS=-D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC diff --git a/depends/packages.md b/depends/packages.md new file mode 100644 index 000000000..7c8036250 --- /dev/null +++ b/depends/packages.md @@ -0,0 +1,147 @@ +Each recipe consists of 3 main parts: defining identifiers, setting build +variables, and defining build commands. + +The package "mylib" will be used here as an example + +General tips: +- mylib_foo is written as $(package)_foo in order to make recipes more similar. + +## Identifiers +Each package is required to define at least these variables: + + $(package)_version: + Version of the upstream library or program. If there is no version, a + placeholder such as 1.0 can be used. + + $(package)_download_path: + Location of the upstream source, without the file-name. Usually http or + ftp. + + $(package)_file_name: + The upstream source filename available at the download path. + + $(package)_sha256_hash: + The sha256 hash of the upstream file + +These variables are optional: + + $(package)_build_subdir: + cd to this dir before running configure/build/stage commands. + + $(package)_download_file: + The file-name of the upstream source if it differs from how it should be + stored locally. This can be used to avoid storing file-names with strange + characters. + + $(package)_dependencies: + Names of any other packages that this one depends on. + + $(package)_patches: + Filenames of any patches needed to build the package + + $(package)_extra_sources: + Any extra files that will be fetched via $(package)_fetch_cmds. These are + specified so that they can be fetched and verified via 'make download'. + + +## Build Variables: +After defining the main identifiers, build variables may be added or customized +before running the build commands. They should be added to a function called +$(package)_set_vars. For example: + + define $(package)_set_vars + ... + endef + +Most variables can be prefixed with the host, architecture, or both, to make +the modifications specific to that case. For example: + + Universal: $(package)_cc=gcc + Linux only: $(package)_linux_cc=gcc + x86_64 only: $(package)_x86_64_cc = gcc + x86_64 linux only: $(package)_x86_64_linux_cc = gcc + +These variables may be set to override or append their default values. + + $(package)_cc + $(package)_cxx + $(package)_objc + $(package)_objcxx + $(package)_ar + $(package)_ranlib + $(package)_libtool + $(package)_nm + $(package)_cflags + $(package)_cxxflags + $(package)_ldflags + $(package)_cppflags + $(package)_config_env + $(package)_build_env + $(package)_stage_env + $(package)_build_opts + $(package)_config_opts + +The *_env variables are used to add environment variables to the respective +commands. + +Many variables respect a debug/release suffix as well, in order to use them for +only the appropriate build config. For example: + + $(package)_cflags_release = -O3 + $(package)_cflags_i686_debug = -g + $(package)_config_opts_release = --disable-debug + +These will be used in addition to the options that do not specify +debug/release. All builds are considered to be release unless DEBUG=1 is set by +the user. Other variables may be defined as needed. + +## Build commands: + + For each build, a unique build dir and staging dir are created. For example, + `work/build/mylib/1.0-1adac830f6e` and `work/staging/mylib/1.0-1adac830f6e`. + + The following build commands are available for each recipe: + + $(package)_fetch_cmds: + Runs from: build dir + Fetch the source file. If undefined, it will be fetched and verified + against its hash. + + $(package)_extract_cmds: + Runs from: build dir + Verify the source file against its hash and extract it. If undefined, the + source is assumed to be a tarball. + + $(package)_preprocess_cmds: + Runs from: build dir/$(package)_build_subdir + Preprocess the source as necessary. If undefined, does nothing. + + $(package)_config_cmds: + Runs from: build dir/$(package)_build_subdir + Configure the source. If undefined, does nothing. + + $(package)_build_cmds: + Runs from: build dir/$(package)_build_subdir + Build the source. If undefined, does nothing. + + $(package)_stage_cmds: + Runs from: build dir/$(package)_build_subdir + Stage the build results. If undefined, does nothing. + + The following variables are available for each recipe: + + $(1)_staging_dir: package's destination sysroot path + $(1)_staging_prefix_dir: prefix path inside of the package's staging dir + $(1)_extract_dir: path to the package's extracted sources + $(1)_build_dir: path where configure/build/stage commands will be run + $(1)_patch_dir: path where the package's patches (if any) are found + +Notes on build commands: + +For packages built with autotools, $($(package)_autoconf) can be used in the +configure step to (usually) correctly configure automatically. Any +$($(package)_config_opts) will be appended. + +Most autotools projects can be properly staged using: + + $(MAKE) DESTDIR=$($(package)_staging_dir) install diff --git a/depends/packages/bdb.mk b/depends/packages/bdb.mk new file mode 100644 index 000000000..6c9876c2c --- /dev/null +++ b/depends/packages/bdb.mk @@ -0,0 +1,31 @@ +package=bdb +$(package)_version=4.8.30 +$(package)_download_path=http://download.oracle.com/berkeley-db +$(package)_file_name=db-$($(package)_version).NC.tar.gz +$(package)_sha256_hash=12edc0df75bf9abd7f82f821795bcee50f42cb2e5f76a6a281b85732798364ef +$(package)_build_subdir=build_unix + +define $(package)_set_vars +$(package)_config_opts=--disable-shared --enable-cxx --disable-replication +$(package)_config_opts_mingw32=--enable-mingw +$(package)_config_opts_linux=--with-pic +$(package)_cxxflags=-std=c++11 +endef + +define $(package)_preprocess_cmds + sed -i.old 's/__atomic_compare_exchange/__atomic_compare_exchange_db/' dbinc/atomic.h && \ + sed -i.old 's/atomic_init/atomic_init_db/' dbinc/atomic.h mp/mp_region.c mp/mp_mvcc.c mp/mp_fget.c mutex/mut_method.c mutex/mut_tas.c && \ + cp -f $(BASEDIR)/config.guess $(BASEDIR)/config.sub dist +endef + +define $(package)_config_cmds + ../dist/$($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) libdb_cxx-4.8.a libdb-4.8.a +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install_lib install_include +endef diff --git a/depends/packages/boost.mk b/depends/packages/boost.mk new file mode 100644 index 000000000..bf773ccd1 --- /dev/null +++ b/depends/packages/boost.mk @@ -0,0 +1,41 @@ +package=boost +$(package)_version=1_64_0 +$(package)_download_path=https://dl.bintray.com/boostorg/release/1.64.0/source/ +$(package)_file_name=$(package)_$($(package)_version).tar.bz2 +$(package)_sha256_hash=7bcc5caace97baa948931d712ea5f37038dbb1c5d89b43ad4def4ed7cb683332 + +define $(package)_set_vars +$(package)_config_opts_release=variant=release +$(package)_config_opts_debug=variant=debug +$(package)_config_opts=--layout=tagged --build-type=complete --user-config=user-config.jam +$(package)_config_opts+=threading=multi link=static -sNO_BZIP2=1 -sNO_ZLIB=1 +$(package)_config_opts_linux=threadapi=pthread runtime-link=shared +$(package)_config_opts_darwin=--toolset=darwin-4.2.1 runtime-link=shared +$(package)_config_opts_mingw32=binary-format=pe target-os=windows threadapi=win32 runtime-link=static +$(package)_config_opts_x86_64_mingw32=address-model=64 +$(package)_config_opts_i686_mingw32=address-model=32 +$(package)_config_opts_i686_linux=address-model=32 architecture=x86 +$(package)_toolset_$(host_os)=gcc +$(package)_archiver_$(host_os)=$($(package)_ar) +$(package)_toolset_darwin=darwin +$(package)_archiver_darwin=$($(package)_libtool) +$(package)_config_libraries=chrono,filesystem,program_options,system,thread,test +$(package)_cxxflags=-std=c++11 -fvisibility=hidden +$(package)_cxxflags_linux=-fPIC +endef + +define $(package)_preprocess_cmds + echo "using $(boost_toolset_$(host_os)) : : $($(package)_cxx) : \"$($(package)_cxxflags) $($(package)_cppflags)\" \"$($(package)_ldflags)\" \"$(boost_archiver_$(host_os))\" \"$(host_STRIP)\" \"$(host_RANLIB)\" \"$(host_WINDRES)\" : ;" > user-config.jam +endef + +define $(package)_config_cmds + ./bootstrap.sh --without-icu --with-libraries=$(boost_config_libraries) +endef + +define $(package)_build_cmds + ./b2 -d2 -j2 -d1 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) stage +endef + +define $(package)_stage_cmds + ./b2 -d0 -j4 --prefix=$($(package)_staging_prefix_dir) $($(package)_config_opts) install +endef diff --git a/depends/packages/dbus.mk b/depends/packages/dbus.mk new file mode 100644 index 000000000..bbe037540 --- /dev/null +++ b/depends/packages/dbus.mk @@ -0,0 +1,23 @@ +package=dbus +$(package)_version=1.10.18 +$(package)_download_path=https://dbus.freedesktop.org/releases/dbus +$(package)_file_name=$(package)-$($(package)_version).tar.gz +$(package)_sha256_hash=6049ddd5f3f3e2618f615f1faeda0a115104423a7996b7aa73e2f36e38cc514a +$(package)_dependencies=expat + +define $(package)_set_vars + $(package)_config_opts=--disable-tests --disable-doxygen-docs --disable-xml-docs --disable-static --without-x +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) -C dbus libdbus-1.la +endef + +define $(package)_stage_cmds + $(MAKE) -C dbus DESTDIR=$($(package)_staging_dir) install-libLTLIBRARIES install-dbusincludeHEADERS install-nodist_dbusarchincludeHEADERS && \ + $(MAKE) DESTDIR=$($(package)_staging_dir) install-pkgconfigDATA +endef diff --git a/depends/packages/expat.mk b/depends/packages/expat.mk new file mode 100644 index 000000000..7f484724a --- /dev/null +++ b/depends/packages/expat.mk @@ -0,0 +1,21 @@ +package=expat +$(package)_version=2.2.1 +$(package)_download_path=https://downloads.sourceforge.net/project/expat/expat/$($(package)_version) +$(package)_file_name=$(package)-$($(package)_version).tar.bz2 +$(package)_sha256_hash=1868cadae4c82a018e361e2b2091de103cd820aaacb0d6cfa49bd2cd83978885 + +define $(package)_set_vars +$(package)_config_opts=--disable-static +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef diff --git a/depends/packages/fontconfig.mk b/depends/packages/fontconfig.mk new file mode 100644 index 000000000..12695db4b --- /dev/null +++ b/depends/packages/fontconfig.mk @@ -0,0 +1,28 @@ +package=fontconfig +$(package)_version=2.12.1 +$(package)_download_path=http://www.freedesktop.org/software/fontconfig/release/ +$(package)_file_name=$(package)-$($(package)_version).tar.bz2 +$(package)_sha256_hash=b449a3e10c47e1d1c7a6ec6e2016cca73d3bd68fbbd4f0ae5cc6b573f7d6c7f3 +$(package)_dependencies=freetype expat + +define $(package)_set_vars + $(package)_config_opts=--disable-docs --disable-static +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +# 2.12.1 uses CHAR_WIDTH which is reserved and clashes with some glibc versions, but newer versions of fontconfig +# have broken makefiles which needlessly attempt to re-generate headers with gperf. +# Instead, change all uses of CHAR_WIDTH, and disable the rule that forces header re-generation. +# This can be removed once the upstream build is fixed. +define $(package)_build_cmds + sed -i 's/CHAR_WIDTH/CHARWIDTH/g' fontconfig/fontconfig.h src/fcobjshash.gperf src/fcobjs.h src/fcobjshash.h && \ + sed -i 's/fcobjshash.h: fcobjshash.gperf/fcobjshash.h:/' src/Makefile && \ + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef diff --git a/depends/packages/freetype.mk b/depends/packages/freetype.mk new file mode 100644 index 000000000..76b025c46 --- /dev/null +++ b/depends/packages/freetype.mk @@ -0,0 +1,22 @@ +package=freetype +$(package)_version=2.7.1 +$(package)_download_path=http://download.savannah.gnu.org/releases/$(package) +$(package)_file_name=$(package)-$($(package)_version).tar.bz2 +$(package)_sha256_hash=3a3bb2c4e15ffb433f2032f50a5b5a92558206822e22bfe8cbe339af4aa82f88 + +define $(package)_set_vars + $(package)_config_opts=--without-zlib --without-png --disable-static + $(package)_config_opts_linux=--with-pic +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef diff --git a/depends/packages/libICE.mk b/depends/packages/libICE.mk new file mode 100644 index 000000000..fc60323b1 --- /dev/null +++ b/depends/packages/libICE.mk @@ -0,0 +1,23 @@ +package=libICE +$(package)_version=1.0.9 +$(package)_download_path=http://xorg.freedesktop.org/releases/individual/lib/ +$(package)_file_name=$(package)-$($(package)_version).tar.bz2 +$(package)_sha256_hash=8f7032f2c1c64352b5423f6b48a8ebdc339cc63064af34d66a6c9aa79759e202 +$(package)_dependencies=xtrans xproto + +define $(package)_set_vars + $(package)_config_opts=--disable-static --disable-docs --disable-specs --without-xsltproc + $(package)_config_opts_linux=--with-pic +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef diff --git a/depends/packages/libSM.mk b/depends/packages/libSM.mk new file mode 100644 index 000000000..0f9307ca7 --- /dev/null +++ b/depends/packages/libSM.mk @@ -0,0 +1,23 @@ +package=libSM +$(package)_version=1.2.2 +$(package)_download_path=http://xorg.freedesktop.org/releases/individual/lib/ +$(package)_file_name=$(package)-$($(package)_version).tar.bz2 +$(package)_sha256_hash=0baca8c9f5d934450a70896c4ad38d06475521255ca63b717a6510fdb6e287bd +$(package)_dependencies=xtrans xproto libICE + +define $(package)_set_vars + $(package)_config_opts=--without-libuuid --without-xsltproc --disable-docs --disable-static + $(package)_config_opts_linux=--with-pic +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef diff --git a/depends/packages/libX11.mk b/depends/packages/libX11.mk new file mode 100644 index 000000000..178d592ee --- /dev/null +++ b/depends/packages/libX11.mk @@ -0,0 +1,23 @@ +package=libX11 +$(package)_version=1.6.2 +$(package)_download_path=http://xorg.freedesktop.org/releases/individual/lib/ +$(package)_file_name=$(package)-$($(package)_version).tar.bz2 +$(package)_sha256_hash=2aa027e837231d2eeea90f3a4afe19948a6eb4c8b2bec0241eba7dbc8106bd16 +$(package)_dependencies=libxcb xtrans xextproto xproto + +define $(package)_set_vars +$(package)_config_opts=--disable-xkb --disable-static +$(package)_config_opts_linux=--with-pic +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef diff --git a/depends/packages/libXau.mk b/depends/packages/libXau.mk new file mode 100644 index 000000000..e87df2e4d --- /dev/null +++ b/depends/packages/libXau.mk @@ -0,0 +1,23 @@ +package=libXau +$(package)_version=1.0.8 +$(package)_download_path=http://xorg.freedesktop.org/releases/individual/lib/ +$(package)_file_name=$(package)-$($(package)_version).tar.bz2 +$(package)_sha256_hash=fdd477320aeb5cdd67272838722d6b7d544887dfe7de46e1e7cc0c27c2bea4f2 +$(package)_dependencies=xproto + +define $(package)_set_vars + $(package)_config_opts=--disable-shared + $(package)_config_opts_linux=--with-pic +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef diff --git a/depends/packages/libXext.mk b/depends/packages/libXext.mk new file mode 100644 index 000000000..4db836066 --- /dev/null +++ b/depends/packages/libXext.mk @@ -0,0 +1,22 @@ +package=libXext +$(package)_version=1.3.2 +$(package)_download_path=http://xorg.freedesktop.org/releases/individual/lib/ +$(package)_file_name=$(package)-$($(package)_version).tar.bz2 +$(package)_sha256_hash=f829075bc646cdc085fa25d98d5885d83b1759ceb355933127c257e8e50432e0 +$(package)_dependencies=xproto xextproto libX11 libXau + +define $(package)_set_vars + $(package)_config_opts=--disable-static +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef diff --git a/depends/packages/libevent.mk b/depends/packages/libevent.mk new file mode 100644 index 000000000..5f622f8e6 --- /dev/null +++ b/depends/packages/libevent.mk @@ -0,0 +1,30 @@ +package=libevent +$(package)_version=2.1.8-stable +$(package)_download_path=https://github.com/libevent/libevent/archive/ +$(package)_file_name=release-$($(package)_version).tar.gz +$(package)_sha256_hash=316ddb401745ac5d222d7c529ef1eada12f58f6376a66c1118eee803cb70f83d + +define $(package)_preprocess_cmds + ./autogen.sh +endef + +define $(package)_set_vars + $(package)_config_opts=--disable-shared --disable-openssl --disable-libevent-regress --disable-samples + $(package)_config_opts_release=--disable-debug-mode + $(package)_config_opts_linux=--with-pic +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds +endef diff --git a/depends/packages/libxcb.mk b/depends/packages/libxcb.mk new file mode 100644 index 000000000..28f2bd6f2 --- /dev/null +++ b/depends/packages/libxcb.mk @@ -0,0 +1,35 @@ +package=libxcb +$(package)_version=1.10 +$(package)_download_path=http://xcb.freedesktop.org/dist +$(package)_file_name=$(package)-$($(package)_version).tar.bz2 +$(package)_sha256_hash=98d9ab05b636dd088603b64229dd1ab2d2cc02ab807892e107d674f9c3f2d5b5 +$(package)_dependencies=xcb_proto libXau xproto + +define $(package)_set_vars +$(package)_config_opts=--disable-static +endef + +define $(package)_preprocess_cmds + sed "s/pthread-stubs//" -i configure +endef + +# Don't install xcb headers to the default path in order to work around a qt +# build issue: https://bugreports.qt.io/browse/QTBUG-34748 +# When using qt's internal libxcb, it may end up finding the real headers in +# depends staging. Use a non-default path to avoid that. + +define $(package)_config_cmds + $($(package)_autoconf) --includedir=$(host_prefix)/include/xcb-shared +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm -rf share/man share/doc +endef diff --git a/depends/packages/miniupnpc.mk b/depends/packages/miniupnpc.mk new file mode 100644 index 000000000..1bb8cb5d2 --- /dev/null +++ b/depends/packages/miniupnpc.mk @@ -0,0 +1,28 @@ +package=miniupnpc +$(package)_version=2.0.20170509 +$(package)_download_path=http://miniupnp.free.fr/files +$(package)_file_name=$(package)-$($(package)_version).tar.gz +$(package)_sha256_hash=d3c368627f5cdfb66d3ebd64ca39ba54d6ff14a61966dbecb8dd296b7039f16a + +define $(package)_set_vars +$(package)_build_opts=CC="$($(package)_cc)" +$(package)_build_opts_darwin=OS=Darwin LIBTOOL="$($(package)_libtool)" +$(package)_build_opts_mingw32=-f Makefile.mingw +$(package)_build_env+=CFLAGS="$($(package)_cflags) $($(package)_cppflags)" AR="$($(package)_ar)" +endef + +define $(package)_preprocess_cmds + mkdir dll && \ + sed -e 's|MINIUPNPC_VERSION_STRING \"version\"|MINIUPNPC_VERSION_STRING \"$($(package)_version)\"|' -e 's|OS/version|$(host)|' miniupnpcstrings.h.in > miniupnpcstrings.h && \ + sed -i.old "s|miniupnpcstrings.h: miniupnpcstrings.h.in wingenminiupnpcstrings|miniupnpcstrings.h: miniupnpcstrings.h.in|" Makefile.mingw +endef + +define $(package)_build_cmds + $(MAKE) libminiupnpc.a $($(package)_build_opts) +endef + +define $(package)_stage_cmds + mkdir -p $($(package)_staging_prefix_dir)/include/miniupnpc $($(package)_staging_prefix_dir)/lib &&\ + install *.h $($(package)_staging_prefix_dir)/include/miniupnpc &&\ + install libminiupnpc.a $($(package)_staging_prefix_dir)/lib +endef diff --git a/depends/packages/native_biplist.mk b/depends/packages/native_biplist.mk new file mode 100644 index 000000000..3c6e8900f --- /dev/null +++ b/depends/packages/native_biplist.mk @@ -0,0 +1,20 @@ +package=native_biplist +$(package)_version=0.9 +$(package)_download_path=https://pypi.python.org/packages/source/b/biplist +$(package)_file_name=biplist-$($(package)_version).tar.gz +$(package)_sha256_hash=b57cadfd26e4754efdf89e9e37de87885f9b5c847b2615688ca04adfaf6ca604 +$(package)_install_libdir=$(build_prefix)/lib/python/dist-packages +$(package)_patches=sorted_list.patch + +define $(package)_preprocess_cmds + patch -p1 < $($(package)_patch_dir)/sorted_list.patch +endef + +define $(package)_build_cmds + python setup.py build +endef + +define $(package)_stage_cmds + mkdir -p $($(package)_install_libdir) && \ + python setup.py install --root=$($(package)_staging_dir) --prefix=$(build_prefix) --install-lib=$($(package)_install_libdir) +endef diff --git a/depends/packages/native_ccache.mk b/depends/packages/native_ccache.mk new file mode 100644 index 000000000..966804ce8 --- /dev/null +++ b/depends/packages/native_ccache.mk @@ -0,0 +1,25 @@ +package=native_ccache +$(package)_version=3.3.4 +$(package)_download_path=https://samba.org/ftp/ccache +$(package)_file_name=ccache-$($(package)_version).tar.bz2 +$(package)_sha256_hash=fa9d7f38367431bc86b19ad107d709ca7ecf1574fdacca01698bdf0a47cd8567 + +define $(package)_set_vars +$(package)_config_opts= +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + rm -rf lib include +endef diff --git a/depends/packages/native_cctools.mk b/depends/packages/native_cctools.mk new file mode 100644 index 000000000..44d238cc4 --- /dev/null +++ b/depends/packages/native_cctools.mk @@ -0,0 +1,65 @@ +package=native_cctools +$(package)_version=807d6fd1be5d2224872e381870c0a75387fe05e6 +$(package)_download_path=https://github.com/theuni/cctools-port/archive +$(package)_file_name=$($(package)_version).tar.gz +$(package)_sha256_hash=a09c9ba4684670a0375e42d9d67e7f12c1f62581a27f28f7c825d6d7032ccc6a +$(package)_build_subdir=cctools +$(package)_clang_version=3.7.1 +$(package)_clang_download_path=http://llvm.org/releases/$($(package)_clang_version) +$(package)_clang_download_file=clang+llvm-$($(package)_clang_version)-x86_64-linux-gnu-ubuntu-14.04.tar.xz +$(package)_clang_file_name=clang-llvm-$($(package)_clang_version)-x86_64-linux-gnu-ubuntu-14.04.tar.xz +$(package)_clang_sha256_hash=99b28a6b48e793705228a390471991386daa33a9717cd9ca007fcdde69608fd9 +$(package)_extra_sources=$($(package)_clang_file_name) + +define $(package)_fetch_cmds +$(call fetch_file,$(package),$($(package)_download_path),$($(package)_download_file),$($(package)_file_name),$($(package)_sha256_hash)) && \ +$(call fetch_file,$(package),$($(package)_clang_download_path),$($(package)_clang_download_file),$($(package)_clang_file_name),$($(package)_clang_sha256_hash)) +endef + +define $(package)_extract_cmds + mkdir -p $($(package)_extract_dir) && \ + echo "$($(package)_sha256_hash) $($(package)_source)" > $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + echo "$($(package)_clang_sha256_hash) $($(package)_source_dir)/$($(package)_clang_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + $(build_SHA256SUM) -c $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + mkdir -p toolchain/bin toolchain/lib/clang/3.5/include && \ + tar --strip-components=1 -C toolchain -xf $($(package)_source_dir)/$($(package)_clang_file_name) && \ + rm -f toolchain/lib/libc++abi.so* && \ + echo "#!/bin/sh" > toolchain/bin/$(host)-dsymutil && \ + echo "exit 0" >> toolchain/bin/$(host)-dsymutil && \ + chmod +x toolchain/bin/$(host)-dsymutil && \ + tar --strip-components=1 -xf $($(package)_source) +endef + +define $(package)_set_vars +$(package)_config_opts=--target=$(host) --disable-lto-support +$(package)_ldflags+=-Wl,-rpath=\\$$$$$$$$\$$$$$$$$ORIGIN/../lib +$(package)_cc=$($(package)_extract_dir)/toolchain/bin/clang +$(package)_cxx=$($(package)_extract_dir)/toolchain/bin/clang++ +endef + +define $(package)_preprocess_cmds + cd $($(package)_build_subdir); ./autogen.sh && \ + sed -i.old "/define HAVE_PTHREADS/d" ld64/src/ld/InputFiles.h +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install && \ + cd $($(package)_extract_dir)/toolchain && \ + mkdir -p $($(package)_staging_prefix_dir)/lib/clang/$($(package)_clang_version)/include && \ + mkdir -p $($(package)_staging_prefix_dir)/bin $($(package)_staging_prefix_dir)/include && \ + cp bin/clang $($(package)_staging_prefix_dir)/bin/ &&\ + cp -P bin/clang++ $($(package)_staging_prefix_dir)/bin/ &&\ + cp lib/libLTO.so $($(package)_staging_prefix_dir)/lib/ && \ + cp -rf lib/clang/$($(package)_clang_version)/include/* $($(package)_staging_prefix_dir)/lib/clang/$($(package)_clang_version)/include/ && \ + cp bin/llvm-dsymutil $($(package)_staging_prefix_dir)/bin/$(host)-dsymutil && \ + if `test -d include/c++/`; then cp -rf include/c++/ $($(package)_staging_prefix_dir)/include/; fi && \ + if `test -d lib/c++/`; then cp -rf lib/c++/ $($(package)_staging_prefix_dir)/lib/; fi +endef diff --git a/depends/packages/native_cdrkit.mk b/depends/packages/native_cdrkit.mk new file mode 100644 index 000000000..cf694edb3 --- /dev/null +++ b/depends/packages/native_cdrkit.mk @@ -0,0 +1,26 @@ +package=native_cdrkit +$(package)_version=1.1.11 +$(package)_download_path=http://distro.ibiblio.org/fatdog/source/600/c +$(package)_file_name=cdrkit-$($(package)_version).tar.bz2 +$(package)_sha256_hash=b50d64c214a65b1a79afe3a964c691931a4233e2ba605d793eb85d0ac3652564 +$(package)_patches=cdrkit-deterministic.patch + +define $(package)_preprocess_cmds + patch -p1 < $($(package)_patch_dir)/cdrkit-deterministic.patch +endef + +define $(package)_config_cmds + cmake -DCMAKE_INSTALL_PREFIX=$(build_prefix) +endef + +define $(package)_build_cmds + $(MAKE) genisoimage +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) -C genisoimage install +endef + +define $(package)_postprocess_cmds + rm bin/isovfy bin/isoinfo bin/isodump bin/isodebug bin/devdump +endef diff --git a/depends/packages/native_ds_store.mk b/depends/packages/native_ds_store.mk new file mode 100644 index 000000000..116fa25d3 --- /dev/null +++ b/depends/packages/native_ds_store.mk @@ -0,0 +1,16 @@ +package=native_ds_store +$(package)_version=1.1.2 +$(package)_download_path=https://github.com/al45tair/ds_store/archive/ +$(package)_file_name=v$($(package)_version).tar.gz +$(package)_sha256_hash=3b3ecb7bf0a5157f5b6010bc3af7c141fb0ad3527084e63336220d22744bc20c +$(package)_install_libdir=$(build_prefix)/lib/python/dist-packages +$(package)_dependencies=native_biplist + +define $(package)_build_cmds + python setup.py build +endef + +define $(package)_stage_cmds + mkdir -p $($(package)_install_libdir) && \ + python setup.py install --root=$($(package)_staging_dir) --prefix=$(build_prefix) --install-lib=$($(package)_install_libdir) +endef diff --git a/depends/packages/native_libdmg-hfsplus.mk b/depends/packages/native_libdmg-hfsplus.mk new file mode 100644 index 000000000..a4ffb6046 --- /dev/null +++ b/depends/packages/native_libdmg-hfsplus.mk @@ -0,0 +1,22 @@ +package=native_libdmg-hfsplus +$(package)_version=0.1 +$(package)_download_path=https://github.com/theuni/libdmg-hfsplus/archive +$(package)_file_name=libdmg-hfsplus-v$($(package)_version).tar.gz +$(package)_sha256_hash=6569a02eb31c2827080d7d59001869ea14484c281efab0ae7f2b86af5c3120b3 +$(package)_build_subdir=build + +define $(package)_preprocess_cmds + mkdir build +endef + +define $(package)_config_cmds + cmake -DCMAKE_INSTALL_PREFIX:PATH=$(build_prefix)/bin .. +endef + +define $(package)_build_cmds + $(MAKE) -C dmg +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) -C dmg install +endef diff --git a/depends/packages/native_mac_alias.mk b/depends/packages/native_mac_alias.mk new file mode 100644 index 000000000..488ec8b59 --- /dev/null +++ b/depends/packages/native_mac_alias.mk @@ -0,0 +1,20 @@ +package=native_mac_alias +$(package)_version=2.0.6 +$(package)_download_path=https://github.com/al45tair/mac_alias/archive/ +$(package)_file_name=v$($(package)_version).tar.gz +$(package)_sha256_hash=78a3332d9a597eebf09ae652d38ad1e263b28db5c2e6dd725fad357b03b77371 +$(package)_install_libdir=$(build_prefix)/lib/python/dist-packages +$(package)_patches=python3.patch + +define $(package)_preprocess_cmds + patch -p1 < $($(package)_patch_dir)/python3.patch +endef + +define $(package)_build_cmds + python setup.py build +endef + +define $(package)_stage_cmds + mkdir -p $($(package)_install_libdir) && \ + python setup.py install --root=$($(package)_staging_dir) --prefix=$(build_prefix) --install-lib=$($(package)_install_libdir) +endef diff --git a/depends/packages/native_protobuf.mk b/depends/packages/native_protobuf.mk new file mode 100644 index 000000000..ce50b366f --- /dev/null +++ b/depends/packages/native_protobuf.mk @@ -0,0 +1,25 @@ +package=native_protobuf +$(package)_version=2.6.1 +$(package)_download_path=https://github.com/google/protobuf/releases/download/v$($(package)_version) +$(package)_file_name=protobuf-$($(package)_version).tar.bz2 +$(package)_sha256_hash=ee445612d544d885ae240ffbcbf9267faa9f593b7b101f21d58beceb92661910 + +define $(package)_set_vars +$(package)_config_opts=--disable-shared +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) -C src protoc +endef + +define $(package)_stage_cmds + $(MAKE) -C src DESTDIR=$($(package)_staging_dir) install-strip +endef + +define $(package)_postprocess_cmds + rm -rf lib include +endef diff --git a/depends/packages/openssl.mk b/depends/packages/openssl.mk new file mode 100644 index 000000000..5ee9f17a6 --- /dev/null +++ b/depends/packages/openssl.mk @@ -0,0 +1,78 @@ +package=openssl +$(package)_version=1.0.1k +$(package)_download_path=https://www.openssl.org/source +$(package)_file_name=$(package)-$($(package)_version).tar.gz +$(package)_sha256_hash=8f9faeaebad088e772f4ef5e38252d472be4d878c6b3a2718c10a4fcebe7a41c + +define $(package)_set_vars +$(package)_config_env=AR="$($(package)_ar)" RANLIB="$($(package)_ranlib)" CC="$($(package)_cc)" +$(package)_config_opts=--prefix=$(host_prefix) --openssldir=$(host_prefix)/etc/openssl +$(package)_config_opts+=no-camellia +$(package)_config_opts+=no-capieng +$(package)_config_opts+=no-cast +$(package)_config_opts+=no-comp +$(package)_config_opts+=no-dso +$(package)_config_opts+=no-dtls1 +$(package)_config_opts+=no-ec_nistp_64_gcc_128 +$(package)_config_opts+=no-gost +$(package)_config_opts+=no-gmp +$(package)_config_opts+=no-heartbeats +$(package)_config_opts+=no-idea +$(package)_config_opts+=no-jpake +$(package)_config_opts+=no-krb5 +$(package)_config_opts+=no-libunbound +$(package)_config_opts+=no-md2 +$(package)_config_opts+=no-mdc2 +$(package)_config_opts+=no-rc4 +$(package)_config_opts+=no-rc5 +$(package)_config_opts+=no-rdrand +$(package)_config_opts+=no-rfc3779 +$(package)_config_opts+=no-rsax +$(package)_config_opts+=no-sctp +$(package)_config_opts+=no-seed +$(package)_config_opts+=no-sha0 +$(package)_config_opts+=no-shared +$(package)_config_opts+=no-ssl-trace +$(package)_config_opts+=no-ssl2 +$(package)_config_opts+=no-ssl3 +$(package)_config_opts+=no-static_engine +$(package)_config_opts+=no-store +$(package)_config_opts+=no-unit-test +$(package)_config_opts+=no-weak-ssl-ciphers +$(package)_config_opts+=no-whirlpool +$(package)_config_opts+=no-zlib +$(package)_config_opts+=no-zlib-dynamic +$(package)_config_opts+=$($(package)_cflags) $($(package)_cppflags) +$(package)_config_opts_linux=-fPIC -Wa,--noexecstack +$(package)_config_opts_x86_64_linux=linux-x86_64 +$(package)_config_opts_i686_linux=linux-generic32 +$(package)_config_opts_arm_linux=linux-generic32 +$(package)_config_opts_aarch64_linux=linux-generic64 +$(package)_config_opts_mipsel_linux=linux-generic32 +$(package)_config_opts_mips_linux=linux-generic32 +$(package)_config_opts_powerpc_linux=linux-generic32 +$(package)_config_opts_x86_64_darwin=darwin64-x86_64-cc +$(package)_config_opts_x86_64_mingw32=mingw64 +$(package)_config_opts_i686_mingw32=mingw +endef + +define $(package)_preprocess_cmds + sed -i.old "/define DATE/d" util/mkbuildinf.pl && \ + sed -i.old "s|engines apps test|engines|" Makefile.org +endef + +define $(package)_config_cmds + ./Configure $($(package)_config_opts) +endef + +define $(package)_build_cmds + $(MAKE) -j1 build_libs libcrypto.pc libssl.pc openssl.pc +endef + +define $(package)_stage_cmds + $(MAKE) INSTALL_PREFIX=$($(package)_staging_dir) -j1 install_sw +endef + +define $(package)_postprocess_cmds + rm -rf share bin etc +endef diff --git a/depends/packages/packages.mk b/depends/packages/packages.mk new file mode 100644 index 000000000..11c2e55b3 --- /dev/null +++ b/depends/packages/packages.mk @@ -0,0 +1,23 @@ +packages:=boost openssl libevent zeromq +native_packages := native_ccache + +qt_native_packages = native_protobuf +qt_packages = qrencode protobuf zlib + +qt_x86_64_linux_packages:=qt expat dbus libxcb xcb_proto libXau xproto freetype fontconfig libX11 xextproto libXext xtrans +qt_i686_linux_packages:=$(qt_x86_64_linux_packages) +qt_arm_linux_packages:=$(qt_x86_64_linux_packages) +qt_aarch64_linux_packages:=$(qt_x86_64_linux_packages) + +qt_darwin_packages=qt +qt_mingw32_packages=qt + +wallet_packages=bdb + +upnp_packages=miniupnpc + +darwin_native_packages = native_biplist native_ds_store native_mac_alias + +ifneq ($(build_os),darwin) +darwin_native_packages += native_cctools native_cdrkit native_libdmg-hfsplus +endif diff --git a/depends/packages/protobuf.mk b/depends/packages/protobuf.mk new file mode 100644 index 000000000..54d3fd924 --- /dev/null +++ b/depends/packages/protobuf.mk @@ -0,0 +1,29 @@ +package=protobuf +$(package)_version=$(native_$(package)_version) +$(package)_download_path=$(native_$(package)_download_path) +$(package)_file_name=$(native_$(package)_file_name) +$(package)_sha256_hash=$(native_$(package)_sha256_hash) +$(package)_dependencies=native_$(package) +$(package)_cxxflags=-std=c++11 + +define $(package)_set_vars + $(package)_config_opts=--disable-shared --with-protoc=$(build_prefix)/bin/protoc + $(package)_config_opts_linux=--with-pic +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) -C src libprotobuf.la +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) -C src install-libLTLIBRARIES install-nobase_includeHEADERS &&\ + $(MAKE) DESTDIR=$($(package)_staging_dir) install-pkgconfigDATA +endef + +define $(package)_postprocess_cmds + rm lib/libprotoc.a +endef diff --git a/depends/packages/qrencode.mk b/depends/packages/qrencode.mk new file mode 100644 index 000000000..44fdf1c29 --- /dev/null +++ b/depends/packages/qrencode.mk @@ -0,0 +1,22 @@ +package=qrencode +$(package)_version=3.4.4 +$(package)_download_path=https://fukuchi.org/works/qrencode/ +$(package)_file_name=$(package)-$($(package)_version).tar.bz2 +$(package)_sha256_hash=efe5188b1ddbcbf98763b819b146be6a90481aac30cfc8d858ab78a19cde1fa5 + +define $(package)_set_vars +$(package)_config_opts=--disable-shared -without-tools --disable-sdltest +$(package)_config_opts_linux=--with-pic +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef diff --git a/depends/packages/qt.mk b/depends/packages/qt.mk new file mode 100644 index 000000000..312f2dcc4 --- /dev/null +++ b/depends/packages/qt.mk @@ -0,0 +1,189 @@ +PACKAGE=qt +$(package)_version=5.7.1 +$(package)_download_path=http://download.qt.io/official_releases/qt/5.7/$($(package)_version)/submodules +$(package)_suffix=opensource-src-$($(package)_version).tar.gz +$(package)_file_name=qtbase-$($(package)_suffix) +$(package)_sha256_hash=95f83e532d23b3ddbde7973f380ecae1bac13230340557276f75f2e37984e410 +$(package)_dependencies=openssl zlib +$(package)_linux_dependencies=freetype fontconfig libxcb libX11 xproto libXext +$(package)_build_subdir=qtbase +$(package)_qt_libs=corelib network widgets gui plugins testlib +$(package)_patches=mac-qmake.conf aarch32-qmake.conf aarch64-qmake.conf mingw-uuidof.patch pidlist_absolute.patch fix-xcb-include-order.patch fix_qt_pkgconfig.patch + +$(package)_qttranslations_file_name=qttranslations-$($(package)_suffix) +$(package)_qttranslations_sha256_hash=3a15aebd523c6d89fb97b2d3df866c94149653a26d27a00aac9b6d3020bc5a1d + + +$(package)_qttools_file_name=qttools-$($(package)_suffix) +$(package)_qttools_sha256_hash=22d67de915cb8cd93e16fdd38fa006224ad9170bd217c2be1e53045a8dd02f0f + +$(package)_extra_sources = $($(package)_qttranslations_file_name) +$(package)_extra_sources += $($(package)_qttools_file_name) + +define $(package)_set_vars +$(package)_config_opts_release = -release +$(package)_config_opts_debug = -debug +$(package)_config_opts += -bindir $(build_prefix)/bin +$(package)_config_opts += -c++std c++11 +$(package)_config_opts += -confirm-license +$(package)_config_opts += -dbus-runtime +$(package)_config_opts += -hostprefix $(build_prefix) +$(package)_config_opts += -no-alsa +$(package)_config_opts += -no-audio-backend +$(package)_config_opts += -no-cups +$(package)_config_opts += -no-egl +$(package)_config_opts += -no-eglfs +$(package)_config_opts += -no-feature-style-windowsmobile +$(package)_config_opts += -no-feature-style-windowsce +$(package)_config_opts += -no-freetype +$(package)_config_opts += -no-glib +$(package)_config_opts += -no-gstreamer +$(package)_config_opts += -no-icu +$(package)_config_opts += -no-iconv +$(package)_config_opts += -no-kms +$(package)_config_opts += -no-linuxfb +$(package)_config_opts += -no-libudev +$(package)_config_opts += -no-mitshm +$(package)_config_opts += -no-mtdev +$(package)_config_opts += -no-pulseaudio +$(package)_config_opts += -no-openvg +$(package)_config_opts += -no-reduce-relocations +$(package)_config_opts += -no-qml-debug +$(package)_config_opts += -no-sql-db2 +$(package)_config_opts += -no-sql-ibase +$(package)_config_opts += -no-sql-oci +$(package)_config_opts += -no-sql-tds +$(package)_config_opts += -no-sql-mysql +$(package)_config_opts += -no-sql-odbc +$(package)_config_opts += -no-sql-psql +$(package)_config_opts += -no-sql-sqlite +$(package)_config_opts += -no-sql-sqlite2 +$(package)_config_opts += -no-use-gold-linker +$(package)_config_opts += -no-xinput2 +$(package)_config_opts += -no-xrender +$(package)_config_opts += -nomake examples +$(package)_config_opts += -nomake tests +$(package)_config_opts += -opensource +$(package)_config_opts += -openssl-linked +$(package)_config_opts += -optimized-qmake +$(package)_config_opts += -pch +$(package)_config_opts += -pkg-config +$(package)_config_opts += -prefix $(host_prefix) +$(package)_config_opts += -qt-libpng +$(package)_config_opts += -qt-libjpeg +$(package)_config_opts += -qt-pcre +$(package)_config_opts += -system-zlib +$(package)_config_opts += -reduce-exports +$(package)_config_opts += -static +$(package)_config_opts += -silent +$(package)_config_opts += -v +$(package)_config_opts += -no-feature-printer +$(package)_config_opts += -no-feature-printdialog + +ifneq ($(build_os),darwin) +$(package)_config_opts_darwin = -xplatform macx-clang-linux +$(package)_config_opts_darwin += -device-option MAC_SDK_PATH=$(OSX_SDK) +$(package)_config_opts_darwin += -device-option MAC_SDK_VERSION=$(OSX_SDK_VERSION) +$(package)_config_opts_darwin += -device-option CROSS_COMPILE="$(host)-" +$(package)_config_opts_darwin += -device-option MAC_MIN_VERSION=$(OSX_MIN_VERSION) +$(package)_config_opts_darwin += -device-option MAC_TARGET=$(host) +$(package)_config_opts_darwin += -device-option MAC_LD64_VERSION=$(LD64_VERSION) +endif + +$(package)_config_opts_linux = -qt-xkbcommon +$(package)_config_opts_linux += -qt-xcb +$(package)_config_opts_linux += -system-freetype +$(package)_config_opts_linux += -no-sm +$(package)_config_opts_linux += -fontconfig +$(package)_config_opts_linux += -no-opengl +$(package)_config_opts_arm_linux = -platform linux-g++ -xplatform $(host) +$(package)_config_opts_aarch64_linux = -platform linux-g++ -xplatform $(host) +$(package)_config_opts_i686_linux = -xplatform linux-g++-32 +$(package)_config_opts_mingw32 = -no-opengl -xplatform win32-g++ -device-option CROSS_COMPILE="$(host)-" +$(package)_build_env = QT_RCC_TEST=1 +endef + +define $(package)_fetch_cmds +$(call fetch_file,$(package),$($(package)_download_path),$($(package)_download_file),$($(package)_file_name),$($(package)_sha256_hash)) && \ +$(call fetch_file,$(package),$($(package)_download_path),$($(package)_qttranslations_file_name),$($(package)_qttranslations_file_name),$($(package)_qttranslations_sha256_hash)) && \ +$(call fetch_file,$(package),$($(package)_download_path),$($(package)_qttools_file_name),$($(package)_qttools_file_name),$($(package)_qttools_sha256_hash)) +endef + +define $(package)_extract_cmds + mkdir -p $($(package)_extract_dir) && \ + echo "$($(package)_sha256_hash) $($(package)_source)" > $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + echo "$($(package)_qttranslations_sha256_hash) $($(package)_source_dir)/$($(package)_qttranslations_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + echo "$($(package)_qttools_sha256_hash) $($(package)_source_dir)/$($(package)_qttools_file_name)" >> $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + $(build_SHA256SUM) -c $($(package)_extract_dir)/.$($(package)_file_name).hash && \ + mkdir qtbase && \ + tar --strip-components=1 -xf $($(package)_source) -C qtbase && \ + mkdir qttranslations && \ + tar --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qttranslations_file_name) -C qttranslations && \ + mkdir qttools && \ + tar --strip-components=1 -xf $($(package)_source_dir)/$($(package)_qttools_file_name) -C qttools +endef + + +define $(package)_preprocess_cmds + sed -i.old "s|updateqm.commands = \$$$$\$$$$LRELEASE|updateqm.commands = $($(package)_extract_dir)/qttools/bin/lrelease|" qttranslations/translations/translations.pro && \ + sed -i.old "/updateqm.depends =/d" qttranslations/translations/translations.pro && \ + sed -i.old "s/src_plugins.depends = src_sql src_xml src_network/src_plugins.depends = src_xml src_network/" qtbase/src/src.pro && \ + sed -i.old "s|X11/extensions/XIproto.h|X11/X.h|" qtbase/src/plugins/platforms/xcb/qxcbxsettings.cpp && \ + sed -i.old 's/if \[ "$$$$XPLATFORM_MAC" = "yes" \]; then xspecvals=$$$$(macSDKify/if \[ "$$$$BUILD_ON_MAC" = "yes" \]; then xspecvals=$$$$(macSDKify/' qtbase/configure && \ + sed -i.old 's/CGEventCreateMouseEvent(0, kCGEventMouseMoved, pos, 0)/CGEventCreateMouseEvent(0, kCGEventMouseMoved, pos, kCGMouseButtonLeft)/' qtbase/src/plugins/platforms/cocoa/qcocoacursor.mm && \ + mkdir -p qtbase/mkspecs/macx-clang-linux &&\ + cp -f qtbase/mkspecs/macx-clang/Info.plist.lib qtbase/mkspecs/macx-clang-linux/ &&\ + cp -f qtbase/mkspecs/macx-clang/Info.plist.app qtbase/mkspecs/macx-clang-linux/ &&\ + cp -f qtbase/mkspecs/macx-clang/qplatformdefs.h qtbase/mkspecs/macx-clang-linux/ &&\ + cp -f $($(package)_patch_dir)/mac-qmake.conf qtbase/mkspecs/macx-clang-linux/qmake.conf && \ + mkdir -p qtbase/mkspecs/arm-linux-gnueabihf &&\ + cp -f qtbase/mkspecs/linux-arm-gnueabi-g++/qplatformdefs.h qtbase/mkspecs/arm-linux-gnueabihf/ &&\ + cp -f $($(package)_patch_dir)/aarch32-qmake.conf qtbase/mkspecs/arm-linux-gnueabihf/qmake.conf &&\ + mkdir -p qtbase/mkspecs/aarch64-linux-gnu &&\ + cp -f qtbase/mkspecs/linux-arm-gnueabi-g++/qplatformdefs.h qtbase/mkspecs/aarch64-linux-gnu/ &&\ + cp -f $($(package)_patch_dir)/aarch64-qmake.conf qtbase/mkspecs/aarch64-linux-gnu/qmake.conf &&\ + patch -p1 < $($(package)_patch_dir)/mingw-uuidof.patch && \ + patch -p1 < $($(package)_patch_dir)/pidlist_absolute.patch && \ + patch -p1 < $($(package)_patch_dir)/fix-xcb-include-order.patch && \ + patch -p1 < $($(package)_patch_dir)/fix_qt_pkgconfig.patch && \ + echo "!host_build: QMAKE_CFLAGS += $($(package)_cflags) $($(package)_cppflags)" >> qtbase/mkspecs/common/gcc-base.conf && \ + echo "!host_build: QMAKE_CXXFLAGS += $($(package)_cxxflags) $($(package)_cppflags)" >> qtbase/mkspecs/common/gcc-base.conf && \ + echo "!host_build: QMAKE_LFLAGS += $($(package)_ldflags)" >> qtbase/mkspecs/common/gcc-base.conf && \ + sed -i.old "s|QMAKE_CFLAGS = |!host_build: QMAKE_CFLAGS = $($(package)_cflags) $($(package)_cppflags) |" qtbase/mkspecs/win32-g++/qmake.conf && \ + sed -i.old "s|QMAKE_LFLAGS = |!host_build: QMAKE_LFLAGS = $($(package)_ldflags) |" qtbase/mkspecs/win32-g++/qmake.conf && \ + sed -i.old "s|QMAKE_CXXFLAGS = |!host_build: QMAKE_CXXFLAGS = $($(package)_cxxflags) $($(package)_cppflags) |" qtbase/mkspecs/win32-g++/qmake.conf + +endef + +define $(package)_config_cmds + export PKG_CONFIG_SYSROOT_DIR=/ && \ + export PKG_CONFIG_LIBDIR=$(host_prefix)/lib/pkgconfig && \ + export PKG_CONFIG_PATH=$(host_prefix)/share/pkgconfig && \ + ./configure $($(package)_config_opts) && \ + echo "host_build: QT_CONFIG ~= s/system-zlib/zlib" >> mkspecs/qconfig.pri && \ + echo "CONFIG += force_bootstrap" >> mkspecs/qconfig.pri && \ + $(MAKE) sub-src-clean && \ + cd ../qttranslations && ../qtbase/bin/qmake qttranslations.pro -o Makefile && \ + cd translations && ../../qtbase/bin/qmake translations.pro -o Makefile && cd ../.. &&\ + cd qttools/src/linguist/lrelease/ && ../../../../qtbase/bin/qmake lrelease.pro -o Makefile +endef + +define $(package)_build_cmds + $(MAKE) -C src $(addprefix sub-,$($(package)_qt_libs)) && \ + $(MAKE) -C ../qttools/src/linguist/lrelease && \ + $(MAKE) -C ../qttranslations +endef + +define $(package)_stage_cmds + $(MAKE) -C src INSTALL_ROOT=$($(package)_staging_dir) $(addsuffix -install_subtargets,$(addprefix sub-,$($(package)_qt_libs))) && cd .. &&\ + $(MAKE) -C qttools/src/linguist/lrelease INSTALL_ROOT=$($(package)_staging_dir) install_target && \ + $(MAKE) -C qttranslations INSTALL_ROOT=$($(package)_staging_dir) install_subtargets && \ + if `test -f qtbase/src/plugins/platforms/xcb/xcb-static/libxcb-static.a`; then \ + cp qtbase/src/plugins/platforms/xcb/xcb-static/libxcb-static.a $($(package)_staging_prefix_dir)/lib; \ + fi +endef + +define $(package)_postprocess_cmds + rm -rf native/mkspecs/ native/lib/ lib/cmake/ && \ + rm -f lib/lib*.la lib/*.prl plugins/*/*.prl +endef diff --git a/depends/packages/xcb_proto.mk b/depends/packages/xcb_proto.mk new file mode 100644 index 000000000..0c7c958d6 --- /dev/null +++ b/depends/packages/xcb_proto.mk @@ -0,0 +1,27 @@ +package=xcb_proto +$(package)_version=1.10 +$(package)_download_path=http://xcb.freedesktop.org/dist +$(package)_file_name=xcb-proto-$($(package)_version).tar.bz2 +$(package)_sha256_hash=7ef40ddd855b750bc597d2a435da21e55e502a0fefa85b274f2c922800baaf05 + +define $(package)_set_vars + $(package)_config_opts=--disable-shared + $(package)_config_opts_linux=--with-pic +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef + +define $(package)_postprocess_cmds + find -name "*.pyc" -delete && \ + find -name "*.pyo" -delete +endef diff --git a/depends/packages/xextproto.mk b/depends/packages/xextproto.mk new file mode 100644 index 000000000..65b6489c3 --- /dev/null +++ b/depends/packages/xextproto.mk @@ -0,0 +1,26 @@ +package=xextproto +$(package)_version=7.3.0 +$(package)_download_path=http://xorg.freedesktop.org/releases/individual/proto +$(package)_file_name=$(package)-$($(package)_version).tar.bz2 +$(package)_sha256_hash=f3f4b23ac8db9c3a9e0d8edb591713f3d70ef9c3b175970dd8823dfc92aa5bb0 +$(package)_patches=fix_aarch64_build.patch + +define $(package)_preprocess_cmds + patch -p1 < $($(package)_patch_dir)/fix_aarch64_build.patch +endef + +define $(package)_set_vars +$(package)_config_opts=--disable-shared +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef diff --git a/depends/packages/xproto.mk b/depends/packages/xproto.mk new file mode 100644 index 000000000..50a90b268 --- /dev/null +++ b/depends/packages/xproto.mk @@ -0,0 +1,21 @@ +package=xproto +$(package)_version=7.0.26 +$(package)_download_path=http://xorg.freedesktop.org/releases/individual/proto +$(package)_file_name=$(package)-$($(package)_version).tar.bz2 +$(package)_sha256_hash=636162c1759805a5a0114a369dffdeccb8af8c859ef6e1445f26a4e6e046514f + +define $(package)_set_vars +$(package)_config_opts=--disable-shared +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef diff --git a/depends/packages/xtrans.mk b/depends/packages/xtrans.mk new file mode 100644 index 000000000..99eefa6d5 --- /dev/null +++ b/depends/packages/xtrans.mk @@ -0,0 +1,22 @@ +package=xtrans +$(package)_version=1.3.4 +$(package)_download_path=http://xorg.freedesktop.org/releases/individual/lib/ +$(package)_file_name=$(package)-$($(package)_version).tar.bz2 +$(package)_sha256_hash=054d4ee3efd52508c753e9f7bc655ef185a29bd2850dd9e2fc2ccc33544f583a +$(package)_dependencies= + +define $(package)_set_vars +$(package)_config_opts_linux=--with-pic --disable-static +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install +endef diff --git a/depends/packages/zeromq.mk b/depends/packages/zeromq.mk new file mode 100644 index 000000000..3f97221e1 --- /dev/null +++ b/depends/packages/zeromq.mk @@ -0,0 +1,34 @@ +package=zeromq +$(package)_version=4.2.2 +$(package)_download_path=https://github.com/zeromq/libzmq/releases/download/v$($(package)_version)/ +$(package)_file_name=$(package)-$($(package)_version).tar.gz +$(package)_sha256_hash=5b23f4ca9ef545d5bd3af55d305765e3ee06b986263b31967435d285a3e6df6b +$(package)_patches=0001-fix-build-with-older-mingw64.patch + +define $(package)_set_vars + $(package)_config_opts=--without-docs --disable-shared --without-libsodium --disable-curve --disable-curve-keygen --disable-perf + $(package)_config_opts_linux=--with-pic + $(package)_cxxflags=-std=c++11 +endef + +define $(package)_preprocess_cmds + patch -p1 < $($(package)_patch_dir)/0001-fix-build-with-older-mingw64.patch && \ + ./autogen.sh +endef + +define $(package)_config_cmds + $($(package)_autoconf) +endef + +define $(package)_build_cmds + $(MAKE) src/libzmq.la +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install-libLTLIBRARIES install-includeHEADERS install-pkgconfigDATA +endef + +define $(package)_postprocess_cmds + sed -i.old "s/ -lstdc++//" lib/pkgconfig/libzmq.pc && \ + rm -rf bin share +endef diff --git a/depends/packages/zlib.mk b/depends/packages/zlib.mk new file mode 100644 index 000000000..589490800 --- /dev/null +++ b/depends/packages/zlib.mk @@ -0,0 +1,27 @@ +package=zlib +$(package)_version=1.2.11 +$(package)_download_path=http://www.zlib.net +$(package)_file_name=$(package)-$($(package)_version).tar.gz +$(package)_sha256_hash=c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1 + +define $(package)_set_vars +$(package)_build_opts= CC="$($(package)_cc)" +$(package)_build_opts+=CFLAGS="$($(package)_cflags) $($(package)_cppflags) -fPIC" +$(package)_build_opts+=RANLIB="$($(package)_ranlib)" +$(package)_build_opts+=AR="$($(package)_ar)" +$(package)_build_opts_darwin+=AR="$($(package)_libtool)" +$(package)_build_opts_darwin+=ARFLAGS="-o" +endef + +define $(package)_config_cmds + ./configure --static --prefix=$(host_prefix) +endef + +define $(package)_build_cmds + $(MAKE) $($(package)_build_opts) libz.a +endef + +define $(package)_stage_cmds + $(MAKE) DESTDIR=$($(package)_staging_dir) install $($(package)_build_opts) +endef + diff --git a/depends/patches/native_biplist/sorted_list.patch b/depends/patches/native_biplist/sorted_list.patch new file mode 100644 index 000000000..89abdb1b7 --- /dev/null +++ b/depends/patches/native_biplist/sorted_list.patch @@ -0,0 +1,29 @@ +--- a/biplist/__init__.py 2014-10-26 19:03:11.000000000 +0000 ++++ b/biplist/__init__.py 2016-07-19 19:30:17.663521999 +0000 +@@ -541,7 +541,7 @@ + return HashableWrapper(n) + elif isinstance(root, dict): + n = {} +- for key, value in iteritems(root): ++ for key, value in sorted(iteritems(root)): + n[self.wrapRoot(key)] = self.wrapRoot(value) + return HashableWrapper(n) + elif isinstance(root, list): +@@ -616,7 +616,7 @@ + elif isinstance(obj, dict): + size = proc_size(len(obj)) + self.incrementByteCount('dictBytes', incr=1+size) +- for key, value in iteritems(obj): ++ for key, value in sorted(iteritems(obj)): + check_key(key) + self.computeOffsets(key, asReference=True) + self.computeOffsets(value, asReference=True) +@@ -714,7 +714,7 @@ + keys = [] + values = [] + objectsToWrite = [] +- for key, value in iteritems(obj): ++ for key, value in sorted(iteritems(obj)): + keys.append(key) + values.append(value) + for key in keys: diff --git a/depends/patches/native_cdrkit/cdrkit-deterministic.patch b/depends/patches/native_cdrkit/cdrkit-deterministic.patch new file mode 100644 index 000000000..8ab0993dc --- /dev/null +++ b/depends/patches/native_cdrkit/cdrkit-deterministic.patch @@ -0,0 +1,86 @@ +--- cdrkit-1.1.11.old/genisoimage/tree.c 2008-10-21 19:57:47.000000000 -0400 ++++ cdrkit-1.1.11/genisoimage/tree.c 2013-12-06 00:23:18.489622668 -0500 +@@ -1139,8 +1139,9 @@ + scan_directory_tree(struct directory *this_dir, char *path, + struct directory_entry *de) + { +- DIR *current_dir; ++ int current_file; + char whole_path[PATH_MAX]; ++ struct dirent **d_list; + struct dirent *d_entry; + struct directory *parent; + int dflag; +@@ -1164,7 +1165,8 @@ + this_dir->dir_flags |= DIR_WAS_SCANNED; + + errno = 0; /* Paranoia */ +- current_dir = opendir(path); ++ //current_dir = opendir(path); ++ current_file = scandir(path, &d_list, NULL, alphasort); + d_entry = NULL; + + /* +@@ -1173,12 +1175,12 @@ + */ + old_path = path; + +- if (current_dir) { ++ if (current_file >= 0) { + errno = 0; +- d_entry = readdir(current_dir); ++ d_entry = d_list[0]; + } + +- if (!current_dir || !d_entry) { ++ if (current_file < 0 || !d_entry) { + int ret = 1; + + #ifdef USE_LIBSCHILY +@@ -1191,8 +1193,8 @@ + de->isorec.flags[0] &= ~ISO_DIRECTORY; + ret = 0; + } +- if (current_dir) +- closedir(current_dir); ++ if(d_list) ++ free(d_list); + return (ret); + } + #ifdef ABORT_DEEP_ISO_ONLY +@@ -1208,7 +1210,7 @@ + errmsgno(EX_BAD, "use Rock Ridge extensions via -R or -r,\n"); + errmsgno(EX_BAD, "or allow deep ISO9660 directory nesting via -D.\n"); + } +- closedir(current_dir); ++ free(d_list); + return (1); + } + #endif +@@ -1250,13 +1252,13 @@ + * The first time through, skip this, since we already asked + * for the first entry when we opened the directory. + */ +- if (dflag) +- d_entry = readdir(current_dir); ++ if (dflag && current_file >= 0) ++ d_entry = d_list[current_file]; + dflag++; + +- if (!d_entry) ++ if (current_file < 0) + break; +- ++ current_file--; + /* OK, got a valid entry */ + + /* If we do not want all files, then pitch the backups. */ +@@ -1348,7 +1350,7 @@ + insert_file_entry(this_dir, whole_path, d_entry->d_name); + #endif /* APPLE_HYB */ + } +- closedir(current_dir); ++ free(d_list); + + #ifdef APPLE_HYB + /* diff --git a/depends/patches/native_mac_alias/python3.patch b/depends/patches/native_mac_alias/python3.patch new file mode 100644 index 000000000..6f2f5534a --- /dev/null +++ b/depends/patches/native_mac_alias/python3.patch @@ -0,0 +1,56 @@ +diff -dur a/mac_alias/alias.py b/mac_alias/alias.py +--- a/mac_alias/alias.py ++++ b/mac_alias/alias.py +@@ -258,10 +258,10 @@ + alias = Alias() + alias.appinfo = appinfo + +- alias.volume = VolumeInfo (volname.replace('/',':'), ++ alias.volume = VolumeInfo (volname.decode().replace('/',':'), + voldate, fstype, disktype, + volattrs, volfsid) +- alias.target = TargetInfo (kind, filename.replace('/',':'), ++ alias.target = TargetInfo (kind, filename.decode().replace('/',':'), + folder_cnid, cnid, + crdate, creator_code, type_code) + alias.target.levels_from = levels_from +@@ -276,9 +276,9 @@ + b.read(1) + + if tag == TAG_CARBON_FOLDER_NAME: +- alias.target.folder_name = value.replace('/',':') ++ alias.target.folder_name = value.decode().replace('/',':') + elif tag == TAG_CNID_PATH: +- alias.target.cnid_path = struct.unpack(b'>%uI' % (length // 4), ++ alias.target.cnid_path = struct.unpack('>%uI' % (length // 4), + value) + elif tag == TAG_CARBON_PATH: + alias.target.carbon_path = value +@@ -313,9 +313,9 @@ + alias.target.creation_date \ + = mac_epoch + datetime.timedelta(seconds=seconds) + elif tag == TAG_POSIX_PATH: +- alias.target.posix_path = value ++ alias.target.posix_path = value.decode() + elif tag == TAG_POSIX_PATH_TO_MOUNTPOINT: +- alias.volume.posix_path = value ++ alias.volume.posix_path = value.decode() + elif tag == TAG_RECURSIVE_ALIAS_OF_DISK_IMAGE: + alias.volume.disk_image_alias = Alias.from_bytes(value) + elif tag == TAG_USER_HOME_LENGTH_PREFIX: +@@ -467,12 +467,12 @@ + + b.write(struct.pack(b'>hhQhhQ', + TAG_HIGH_RES_VOLUME_CREATION_DATE, +- 8, long(voldate * 65536), ++ 8, int(voldate * 65536), + TAG_HIGH_RES_CREATION_DATE, +- 8, long(crdate * 65536))) ++ 8, int(crdate * 65536))) + + if self.target.cnid_path: +- cnid_path = struct.pack(b'>%uI' % len(self.target.cnid_path), ++ cnid_path = struct.pack('>%uI' % len(self.target.cnid_path), + *self.target.cnid_path) + b.write(struct.pack(b'>hh', TAG_CNID_PATH, + len(cnid_path))) diff --git a/depends/patches/qt/aarch32-qmake.conf b/depends/patches/qt/aarch32-qmake.conf new file mode 100644 index 000000000..da3f2990c --- /dev/null +++ b/depends/patches/qt/aarch32-qmake.conf @@ -0,0 +1,24 @@ +# +# qmake configuration for building with arm-linux-gnueabi-g++ +# + +MAKEFILE_GENERATOR = UNIX +CONFIG += incremental +QMAKE_INCREMENTAL_STYLE = sublib + +include(../common/linux.conf) +include(../common/gcc-base-unix.conf) +include(../common/g++-unix.conf) + +# modifications to g++.conf +QMAKE_CC = arm-linux-gnueabihf-gcc +QMAKE_CXX = arm-linux-gnueabihf-g++ +QMAKE_LINK = arm-linux-gnueabihf-g++ +QMAKE_LINK_SHLIB = arm-linux-gnueabihf-g++ + +# modifications to linux.conf +QMAKE_AR = arm-linux-gnueabihf-ar cqs +QMAKE_OBJCOPY = arm-linux-gnueabihf-objcopy +QMAKE_NM = arm-linux-gnueabihf-nm -P +QMAKE_STRIP = arm-linux-gnueabihf-strip +load(qt_config) diff --git a/depends/patches/qt/aarch64-qmake.conf b/depends/patches/qt/aarch64-qmake.conf new file mode 100644 index 000000000..8e68a66d8 --- /dev/null +++ b/depends/patches/qt/aarch64-qmake.conf @@ -0,0 +1,20 @@ +MAKEFILE_GENERATOR = UNIX +CONFIG += incremental +QMAKE_INCREMENTAL_STYLE = sublib + +include(../common/linux.conf) +include(../common/gcc-base-unix.conf) +include(../common/g++-unix.conf) + +# modifications to g++.conf +QMAKE_CC = aarch64-linux-gnu-gcc +QMAKE_CXX = aarch64-linux-gnu-g++ +QMAKE_LINK = aarch64-linux-gnu-g++ +QMAKE_LINK_SHLIB = aarch64-linux-gnu-g++ + +# modifications to linux.conf +QMAKE_AR = aarch64-linux-gnu-ar cqs +QMAKE_OBJCOPY = aarch64-linux-gnu-objcopy +QMAKE_NM = aarch64-linux-gnu-nm -P +QMAKE_STRIP = aarch64-linux-gnu-strip +load(qt_config) diff --git a/depends/patches/qt/fix-xcb-include-order.patch b/depends/patches/qt/fix-xcb-include-order.patch new file mode 100644 index 000000000..ec2bc17d9 --- /dev/null +++ b/depends/patches/qt/fix-xcb-include-order.patch @@ -0,0 +1,49 @@ +--- old/qtbase/src/plugins/platforms/xcb/xcb_qpa_lib.pro 2015-03-17 ++++ new/qtbase/src/plugins/platforms/xcb/xcb_qpa_lib.pro 2015-03-17 +@@ -76,8 +76,6 @@ + + DEFINES += $$QMAKE_DEFINES_XCB + LIBS += $$QMAKE_LIBS_XCB +-QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XCB +-QMAKE_CFLAGS += $$QMAKE_CFLAGS_XCB + + CONFIG += qpa/genericunixfontdatabase + +@@ -89,7 +87,8 @@ + contains(QT_CONFIG, xcb-qt) { + DEFINES += XCB_USE_RENDER + XCB_DIR = ../../../3rdparty/xcb +- INCLUDEPATH += $$XCB_DIR/include $$XCB_DIR/sysinclude ++ QMAKE_CFLAGS += -I$$XCB_DIR/include -I$$XCB_DIR/sysinclude $$QMAKE_CFLAGS_XCB ++ QMAKE_CXXFLAGS += -I$$XCB_DIR/include -I$$XCB_DIR/sysinclude $$QMAKE_CFLAGS_XCB + LIBS += -lxcb -L$$MODULE_BASE_OUTDIR/lib -lxcb-static$$qtPlatformTargetSuffix() + } else { + LIBS += -lxcb -lxcb-image -lxcb-icccm -lxcb-sync -lxcb-xfixes -lxcb-shm -lxcb-randr -lxcb-shape -lxcb-keysyms -lxcb-xinerama +--- old/qtbase/src/plugins/platforms/xcb/xcb-static/xcb-static.pro ++++ new/qtbase/src/plugins/platforms/xcb/xcb-static/xcb-static.pro +@@ -9,7 +9,8 @@ + + XCB_DIR = ../../../../3rdparty/xcb + +-INCLUDEPATH += $$XCB_DIR/include $$XCB_DIR/include/xcb $$XCB_DIR/sysinclude ++QMAKE_CFLAGS += -I$$XCB_DIR/include -I$$XCB_DIR/include/xcb -I$$XCB_DIR/sysinclude ++QMAKE_CXXFLAGS += -I$$XCB_DIR/include -I$$XCB_DIR/include/xcb -I$$XCB_DIR/sysinclude + + QMAKE_CXXFLAGS += $$QMAKE_CFLAGS_XCB + QMAKE_CFLAGS += $$QMAKE_CFLAGS_XCB +--- old/qtbase/src/plugins/platforms/xcb/xcb-plugin.pro ++++ new/qtbase/src/plugins/platforms/xcb/xcb-plugin.pro +@@ -6,6 +6,13 @@ + qxcbmain.cpp + OTHER_FILES += xcb.json README + ++contains(QT_CONFIG, xcb-qt) { ++ DEFINES += XCB_USE_RENDER ++ XCB_DIR = ../../../3rdparty/xcb ++ QMAKE_CFLAGS += -I$$XCB_DIR/include -I$$XCB_DIR/sysinclude $$QMAKE_CFLAGS_XCB ++ QMAKE_CXXFLAGS += -I$$XCB_DIR/include -I$$XCB_DIR/sysinclude $$QMAKE_CFLAGS_XCB ++} ++ + PLUGIN_TYPE = platforms + PLUGIN_CLASS_NAME = QXcbIntegrationPlugin + !equals(TARGET, $$QT_DEFAULT_QPA_PLUGIN): PLUGIN_EXTENDS = - diff --git a/depends/patches/qt/fix_qt_pkgconfig.patch b/depends/patches/qt/fix_qt_pkgconfig.patch new file mode 100644 index 000000000..34302a9f2 --- /dev/null +++ b/depends/patches/qt/fix_qt_pkgconfig.patch @@ -0,0 +1,11 @@ +--- old/qtbase/mkspecs/features/qt_module.prf ++++ new/qtbase/mkspecs/features/qt_module.prf +@@ -245,7 +245,7 @@ + load(qt_targets) + + # this builds on top of qt_common +-!internal_module:!lib_bundle:if(unix|mingw) { ++unix|mingw { + CONFIG += create_pc + QMAKE_PKGCONFIG_DESTDIR = pkgconfig + host_build: \ diff --git a/depends/patches/qt/mac-qmake.conf b/depends/patches/qt/mac-qmake.conf new file mode 100644 index 000000000..236988fd1 --- /dev/null +++ b/depends/patches/qt/mac-qmake.conf @@ -0,0 +1,26 @@ +MAKEFILE_GENERATOR = UNIX +CONFIG += app_bundle incremental global_init_link_order lib_version_first plugin_no_soname absolute_library_soname +QMAKE_INCREMENTAL_STYLE = sublib +QMAKE_APPLE_DEVICE_ARCHS = x86_64 +include(../common/macx.conf) +include(../common/gcc-base-mac.conf) +include(../common/clang.conf) +include(../common/clang-mac.conf) +QMAKE_MAC_SDK_PATH=$${MAC_SDK_PATH} +QMAKE_XCODE_VERSION=4.3 +QMAKE_XCODE_DEVELOPER_PATH=/Developer +QMAKE_MAC_SDK=macosx +QMAKE_MAC_SDK.macosx.Path = $${MAC_SDK_PATH} +QMAKE_MAC_SDK.macosx.platform_name = macosx +QMAKE_MAC_SDK.macosx.SDKVersion = $${MAC_SDK_VERSION} +QMAKE_MAC_SDK.macosx.PlatformPath = /phony +QMAKE_MACOSX_DEPLOYMENT_TARGET = $${MAC_MIN_VERSION} +!host_build: QMAKE_CFLAGS += -target $${MAC_TARGET} +!host_build: QMAKE_OBJECTIVE_CFLAGS += $$QMAKE_CFLAGS +!host_build: QMAKE_CXXFLAGS += $$QMAKE_CFLAGS +!host_build: QMAKE_LFLAGS += -target $${MAC_TARGET} -mlinker-version=$${MAC_LD64_VERSION} +QMAKE_AR = $${CROSS_COMPILE}ar cq +QMAKE_RANLIB=$${CROSS_COMPILE}ranlib +QMAKE_LIBTOOL=$${CROSS_COMPILE}libtool +QMAKE_INSTALL_NAME_TOOL=$${CROSS_COMPILE}install_name_tool +load(qt_config) diff --git a/depends/patches/qt/mingw-uuidof.patch b/depends/patches/qt/mingw-uuidof.patch new file mode 100644 index 000000000..fb21923c8 --- /dev/null +++ b/depends/patches/qt/mingw-uuidof.patch @@ -0,0 +1,44 @@ +--- old/qtbase/src/plugins/platforms/windows/qwindowscontext.cpp ++++ new/qtbase/src/plugins/platforms/windows/qwindowscontext.cpp +@@ -77,7 +77,7 @@ + #include + #include + #include +-#ifndef Q_OS_WINCE ++#if !defined(Q_OS_WINCE) && (!defined(USE___UUIDOF) || (defined(USE___UUIDOF) && USE___UUIDOF == 1)) + # include + #endif + +@@ -814,7 +814,7 @@ + HWND_MESSAGE, NULL, static_cast(GetModuleHandle(0)), NULL); + } + +-#ifndef Q_OS_WINCE ++#if !defined(Q_OS_WINCE) && (!defined(USE___UUIDOF) || (defined(USE___UUIDOF) && USE___UUIDOF == 1)) + // Re-engineered from the inline function _com_error::ErrorMessage(). + // We cannot use it directly since it uses swprintf_s(), which is not + // present in the MSVCRT.DLL found on Windows XP (QTBUG-35617). +@@ -833,7 +833,7 @@ + return QString::asprintf("IDispatch error #%u", uint(wCode)); + return QString::asprintf("Unknown error 0x0%x", uint(comError.Error())); + } +-#endif // !Q_OS_WINCE ++#endif // !defined(Q_OS_WINCE) && (!defined(USE___UUIDOF) || (defined(USE___UUIDOF) && USE___UUIDOF == 1)) + + /*! + \brief Common COM error strings. +@@ -901,12 +901,12 @@ + default: + break; + } +-#ifndef Q_OS_WINCE ++#if !defined(Q_OS_WINCE) && (!defined(USE___UUIDOF) || (defined(USE___UUIDOF) && USE___UUIDOF == 1)) + _com_error error(hr); + result += QByteArrayLiteral(" ("); + result += errorMessageFromComError(error); + result += ')'; +-#endif // !Q_OS_WINCE ++#endif // !defined(Q_OS_WINCE) && (!defined(USE___UUIDOF) || (defined(USE___UUIDOF) && USE___UUIDOF == 1)) + return result; + } + diff --git a/depends/patches/qt/pidlist_absolute.patch b/depends/patches/qt/pidlist_absolute.patch new file mode 100644 index 000000000..c79282417 --- /dev/null +++ b/depends/patches/qt/pidlist_absolute.patch @@ -0,0 +1,37 @@ +diff -dur old/qtbase/src/plugins/platforms/windows/qwindowscontext.h new/qtbase/src/plugins/platforms/windows/qwindowscontext.h +--- old/qtbase/src/plugins/platforms/windows/qwindowscontext.h ++++ new/qtbase/src/plugins/platforms/windows/qwindowscontext.h +@@ -136,10 +136,18 @@ + inline void init(); + + typedef HRESULT (WINAPI *SHCreateItemFromParsingName)(PCWSTR, IBindCtx *, const GUID&, void **); ++#if defined(Q_CC_MINGW) && (!defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 3) ++ typedef HRESULT (WINAPI *SHGetKnownFolderIDList)(const GUID &, DWORD, HANDLE, ITEMIDLIST **); ++#else + typedef HRESULT (WINAPI *SHGetKnownFolderIDList)(const GUID &, DWORD, HANDLE, PIDLIST_ABSOLUTE *); ++#endif + typedef HRESULT (WINAPI *SHGetStockIconInfo)(int , int , _SHSTOCKICONINFO *); + typedef HRESULT (WINAPI *SHGetImageList)(int, REFIID , void **); ++#if defined(Q_CC_MINGW) && (!defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 3) ++ typedef HRESULT (WINAPI *SHCreateItemFromIDList)(const ITEMIDLIST *, REFIID, void **); ++#else + typedef HRESULT (WINAPI *SHCreateItemFromIDList)(PCIDLIST_ABSOLUTE, REFIID, void **); ++#endif + + SHCreateItemFromParsingName sHCreateItemFromParsingName; + SHGetKnownFolderIDList sHGetKnownFolderIDList; +diff -dur old/qtbase/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp new/qtbase/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +--- old/qtbase/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp ++++ new/qtbase/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +@@ -1016,7 +1016,11 @@ + qWarning() << __FUNCTION__ << ": Invalid CLSID: " << url.path(); + return Q_NULLPTR; + } ++#if defined(Q_CC_MINGW) && (!defined(__MINGW64_VERSION_MAJOR) || __MINGW64_VERSION_MAJOR < 3) ++ ITEMIDLIST *idList; ++#else + PIDLIST_ABSOLUTE idList; ++#endif + HRESULT hr = QWindowsContext::shell32dll.sHGetKnownFolderIDList(uuid, 0, 0, &idList); + if (FAILED(hr)) { + qErrnoWarning("%s: SHGetKnownFolderIDList(%s)) failed", __FUNCTION__, qPrintable(url.toString())); diff --git a/depends/patches/xextproto/fix_aarch64_build.patch b/depends/patches/xextproto/fix_aarch64_build.patch new file mode 100644 index 000000000..372bbe5a1 --- /dev/null +++ b/depends/patches/xextproto/fix_aarch64_build.patch @@ -0,0 +1,35 @@ +--- old/config.sub 2010-12-06 19:52:05.000000000 -0800 ++++ new/config.sub 2017-03-10 14:46:55.525827000 -0800 +@@ -246,6 +246,7 @@ + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ ++ | aarch64 | aarch64_be \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ +@@ -328,6 +329,7 @@ + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ ++ | aarch64-* | aarch64_be-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ + +--- old/config.guess 2010-12-06 19:52:05.000000000 -0800 ++++ new/config.guess 2017-03-10 14:50:10.221827000 -0800 +@@ -858,6 +858,13 @@ + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; ++ aarch64:Linux:*:*) ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; ++ aarch64_be:Linux:*:*) ++ UNAME_MACHINE=aarch64_be ++ echo ${UNAME_MACHINE}-unknown-linux-${LIBC} ++ exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; diff --git a/depends/patches/zeromq/0001-fix-build-with-older-mingw64.patch b/depends/patches/zeromq/0001-fix-build-with-older-mingw64.patch new file mode 100644 index 000000000..a6c508fb8 --- /dev/null +++ b/depends/patches/zeromq/0001-fix-build-with-older-mingw64.patch @@ -0,0 +1,30 @@ +From 1a159c128c69a42d90819375c06a39994f3fbfc1 Mon Sep 17 00:00:00 2001 +From: Cory Fields +Date: Tue, 28 Nov 2017 20:33:25 -0500 +Subject: [PATCH] fix build with older mingw64 + +--- + src/windows.hpp | 7 +++++++ + 1 file changed, 7 insertions(+) + +diff --git a/src/windows.hpp b/src/windows.hpp +index 99e889d..e69038e 100644 +--- a/src/windows.hpp ++++ b/src/windows.hpp +@@ -55,6 +55,13 @@ + #include + #include + #include ++ ++#if defined __MINGW64_VERSION_MAJOR && __MINGW64_VERSION_MAJOR < 4 ++// Workaround for mingw-w64 < v4.0 which did not include ws2ipdef.h in iphlpapi.h. ++// Fixed in mingw-w64 by 9bd8fe9148924840d315b4c915dd099955ea89d1. ++#include ++#include ++#endif + #include + + #if !defined __MINGW32__ +-- +2.7.4 + diff --git a/doc/README b/doc/README index 8685a68a6..e09138d5a 100644 --- a/doc/README +++ b/doc/README @@ -1,10 +1,10 @@ -Copyright (c) 2013-2014 TruckCoin Developers -TruckCoin 0.5.0 BETA +HyperStake -Copyright (c) 2013-2014 TruckCoin Developers +Copyright (c) 2014 HyperStake Developers +Copyright (c) 2013-2014 hyperstake Developers Copyright (c) 2013 NovaCoin Developers Copyright (c) 2011-2012 Bitcoin Developers Distributed under the MIT/X11 software license, see the accompanying @@ -16,37 +16,45 @@ cryptographic software written by Eric Young (eay@cryptsoft.com). Intro ----- -TruckCoin is a free open source project derived from NovaCoin, with -the goal of providing a long-term energy-efficient X11-based crypto-currency. +HyperStake is a free open source project derived from NovaCoin, with +the goal of providing a long-term energy-efficient Proof of Stake based crypto-currency. Built on the foundation of Bitcoin and NovaCoin, innovations such as proof-of-stake help further advance the field of crypto-currency. Setup ----- Unpack the files into a directory and run: - bin/32/truckcoind (headless, 32-bit) - bin/64/truckcoind (headless, 64-bit) + bin/32/hyperstaked (headless, 32-bit) + bin/64/hyperstaked (headless, 64-bit) The software automatically finds other nodes to connect to. You can enable Universal Plug and Play (UPnP) with your router/firewall or forward port 18775 (TCP) to your computer so you can receive -incoming connections. Truckcoin works without incoming connections, -but allowing incoming connections helps the Truckcoin network. +incoming connections. hyperstake works without incoming connections, +but allowing incoming connections helps the hyperstake network. Upgrade ------- All you existing coins/transactions should be intact with the upgrade. To upgrade first backup wallet -truckcoind backupwallet -Then shutdown truckcoind by -truckcoind stop -Start up the new truckcoind. +hyperstaked backupwallet +Then shutdown hyperstaked by +hyperstaked stop +Start up the new hyperstaked. -See the TruckCoin site: - http://truckcoin.org/ +See the hyperstake site: + http://hyperstake.com/ for help and more information. +### Wallet themes + +| HyperBlue | PoloniexNight | PoloniexDay | +| ------------- | ------------- | ------------- | +| [![HyperBlue](https://github.com/zeewolfik/HyperStake/raw/master/src/qt/res/screenshots/hyperstake-hyperblue-theme-th.png)](https://github.com/zeewolfik/HyperStake/raw/master/src/qt/res/screenshots/hyperstake-hyperblue-theme.png) | [![PoloniexNight](https://github.com/zeewolfik/HyperStake/raw/master/src/qt/res/screenshots/hyperstake-poloniexnight-theme-th.png)](https://github.com/zeewolfik/HyperStake/raw/master/src/qt/res/screenshots/hyperstake-poloniexnight-theme.png) | [![PoloniexNight](https://github.com/zeewolfik/HyperStake/raw/master/src/qt/res/screenshots/hyperstake-poloniexday-theme-th.png)](https://github.com/zeewolfik/HyperStake/raw/master/src/qt/res/screenshots/hyperstake-poloniexday-theme.png) | + + + diff --git a/doc/README_osx.txt b/doc/README_osx.txt new file mode 100644 index 000000000..6c0c21c19 --- /dev/null +++ b/doc/README_osx.txt @@ -0,0 +1,83 @@ +Deterministic OSX Dmg Notes. + +Working OSX DMG's are created in Linux by combining a recent clang, +the Apple's binutils (ld, ar, etc), and DMG authoring tools. + +Apple uses clang extensively for development and has upstreamed the necessary +functionality so that a vanilla clang can take advantage. It supports the use +of -F, -target, -mmacosx-version-min, and --sysroot, which are all necessary +when building for OSX. A pre-compiled version of 3.2 is used because it was not +available in the Precise repositories at the time this work was started. In the +future, it can be switched to use system packages instead. + +Apple's version of binutils (called cctools) contains lots of functionality +missing in the FSF's binutils. In addition to extra linker options for +frameworks and sysroots, several other tools are needed as well such as +install_name_tool, lipo, and nmedit. These do not build under linux, so they +have been patched to do so. The work here was used as a starting point: +https://github.com/mingwandroid/toolchain4 + +In order to build a working toolchain, the following source packages are needed +from Apple: cctools, dyld, and ld64. + +These tools inject timestamps by default, which produce non-deterministic +binaries. The ZERO_AR_DATE environment variable is used to disable that. + +This version of cctools has been patched to use the current version of clang's +headers and and its libLTO.so rather than those from llvmgcc, as it was +originally done in toolchain4. + +To complicate things further, all builds must target an Apple SDK. These SDKs +are free to download, but not redistributable. +To obtain it, register for a developer account, then download the XCode 6.1.1 dmg: +https://developer.apple.com/downloads/download.action?path=Developer_Tools/xcode_6.1.1/xcode_6.1.1.dmg + +This file is several gigabytes in size, but only a single directory inside is +needed: Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk + +Unfortunately, the usual linux tools (7zip, hpmount, loopback mount) are incapable of opening this file. +To create a tarball suitable for gitian input, mount the dmg in OSX, then create it with: + $ tar -C /Volumes/Xcode/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/ -czf MacOSX10.9.sdk.tar.gz MacOSX10.9.sdk + + +The gitian descriptors build 2 sets of files: Linux tools, then Apple binaries +which are created using these tools. The build process has been designed to +avoid including the SDK's files in Gitian's outputs. All interim tarballs are +fully deterministic and may be freely redistributed. + +genisoimage is used to create the initial DMG. It is not deterministic as-is, +so it has been patched. A system genisoimage will work fine, but it will not +be deterministic because the file-order will change between invocations. +The patch can be seen here: +https://raw.githubusercontent.com/theuni/osx-cross-depends/master/patches/cdrtools/genisoimage.diff +No effort was made to fix this cleanly, so it likely leaks memory badly. But +it's only used for a single invocation, so that's no real concern. + +genisoimage cannot compress DMGs, so afterwards, the 'dmg' tool from the +libdmg-hfsplus project is used to compress it. There are several bugs in this +tool and its maintainer has seemingly abandoned the project. It has been forked +and is available (with fixes) here: https://github.com/theuni/libdmg-hfsplus . + +The 'dmg' tool has the ability to create DMG's from scratch as well, but this +functionality is broken. Only the compression feature is currently used. +Ideally, the creation could be fixed and genisoimage would no longer be necessary. + +Background images and other features can be added to DMG files by inserting a +.DS_Store before creation. The easiest way to create this file is to build a +DMG without one, move it to a device running OSX, customize the layout, then +grab the .DS_Store file for later use. That is the approach taken here. + +As of OSX Mavericks (10.9), using an Apple-blessed key to sign binaries is a +requirement in order to satisfy the new Gatekeeper requirements. Because this +private key cannot be shared, we'll have to be a bit creative in order for the +build process to remain somewhat deterministic. Here's how it works: + +- Builders use gitian to create an unsigned release. This outputs an unsigned + dmg which users may choose to bless and run. It also outputs an unsigned app + structure in the form of a tarball, which also contains all of the tools + that have been previously (deterministically) built in order to create a + final dmg. +- The Apple keyholder uses this unsigned app to create a detached signature, + using the script that is also included there. +- Builders feed the unsigned app + detached signature back into gitian. It + uses the pre-built tools to recombine the pieces into a deterministic dmg. diff --git a/doc/README_windows.txt b/doc/README_windows.txt index a55381ef6..c67ca7e7c 100644 --- a/doc/README_windows.txt +++ b/doc/README_windows.txt @@ -1,10 +1,7 @@ -Copyright (c) 2013-2014 TruckCoin Developers +HyperStake - -TruckCoin 0.5.0 BETA - -Copyright (c) 2013-2014 TruckCoin Developers +Copyright (c) 2014 HyperStake Developers Copyright (c) 2013 NovaCoin Developers Copyright (c) 2011-2012 Bitcoin Developers Distributed under the MIT/X11 software license, see the accompanying @@ -16,7 +13,7 @@ cryptographic software written by Eric Young (eay@cryptsoft.com). Intro ----- -TruckCoin is a free open source project derived from NovaCoin, with +HyperStake is a free open source project derived from NovaCoin, with the goal of providing a long-term energy-efficient X11-based crypto-currency. Built on the foundation of Bitcoin and NovaCoin, innovations such as proof-of-stake help further advance the field of crypto-currency. @@ -25,9 +22,9 @@ Setup ----- After completing windows setup then run windows command line (cmd) cd daemon - truckcoind -You would need to create a configuration file truckcoin.conf in the default -wallet directory. Grant access to truckcoind.exe in anti-virus and firewall + hyperstaked + +Grant access to hyperstaked.exe in anti-virus and firewall applications if necessary. The software automatically finds other nodes to connect to. You can @@ -35,20 +32,26 @@ enable Universal Plug and Play (UPnP) with your router/firewall or forward port 18775 (TCP) to your computer so you can receive -incoming connections. TruckCoin works without incoming connections, -but allowing incoming connections helps the TruckCoin network. +incoming connections. HyperStake works without incoming connections, +but allowing incoming connections helps the HyperStake network. Upgrade ------- All you existing coins/transactions should be intact with the upgrade. To upgrade first backup wallet -truckcoind backupwallet -Then shutdown truckcoind by -truckcoind stop -Start up the new truckcoind. +hyperstaked backupwallet +Then shutdown hyperstaked by +hyperstaked stop +Start up the new hyperstaked. + + +See the HyperStake site: + + http://hyperstake.com + +or Wikia + http://hyperstake.wikia.com/wiki/HyperStake_Wiki -See the X11Coin site: - http://truckcoin.org/ for help and more information. diff --git a/doc/assets-attribution.txt b/doc/assets-attribution.txt index 0b0e37706..fabcdeea7 100644 --- a/doc/assets-attribution.txt +++ b/doc/assets-attribution.txt @@ -1,7 +1,3 @@ -Code: src/strlcpy.h -Author: Todd C. Miller -License: ISC - Icon: src/qt/res/icons/clock*.png, src/qt/res/icons/tx*.png, src/qt/res/src/*.svg Designer: Wladimir van der Laan diff --git a/doc/build-osx.md b/doc/build-osx.md new file mode 100644 index 000000000..da6f3126c --- /dev/null +++ b/doc/build-osx.md @@ -0,0 +1,144 @@ +Mac OS X Build Instructions and Notes +==================================== +This guide will show you how to build hyperstaked(headless client) for OSX. + +Notes +----- + +* Tested on OS X 10.7 through 10.10 on 64-bit Intel processors only. + +* All of the commands should be executed in a Terminal application. The +built-in one is located in `/Applications/Utilities`. + +Preparation +----------- + +You need to install XCode with all the options checked so that the compiler +and everything is available in /usr not just /Developer. XCode should be +available on your OS X installation media, but if not, you can get the +current version from https://developer.apple.com/xcode/. If you install +Xcode 4.3 or later, you'll need to install its command line tools. This can +be done in `Xcode > Preferences > Downloads > Components` and generally must +be re-done or updated every time Xcode is updated. + +You will also need to install [Homebrew](http://brew.sh) in order to install library +dependencies. + +The installation of the actual dependencies is covered in the Instructions +sections below. + +Instructions: Homebrew +---------------------- + +#### Install dependencies using Homebrew + + brew install autoconf automake libtool boost miniupnpc openssl pkg-config protobuf qt5 + +NOTE: Building with Qt4 is still supported, however, could result in a broken UI. As such, building with Qt5 is recommended. + +#### Installing berkeley-db4 using Homebrew + +The homebrew package for berkeley-db4 has been broken for some time. It will install without Java though. + +Running this command takes you into brew's interactive mode, which allows you to configure, make, and install by hand: +``` +$ brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/master/Formula/berkeley-db4.rb -–without-java +``` + +The rest of these commands are run inside brew interactive mode: +``` +/private/tmp/berkeley-db4-UGpd0O/db-4.8.30 $ cd .. +/private/tmp/berkeley-db4-UGpd0O $ db-4.8.30/dist/configure --prefix=/usr/local/Cellar/berkeley-db4/4.8.30 --mandir=/usr/local/Cellar/berkeley-db4/4.8.30/share/man --enable-cxx +/private/tmp/berkeley-db4-UGpd0O $ make +/private/tmp/berkeley-db4-UGpd0O $ make install +/private/tmp/berkeley-db4-UGpd0O $ exit +``` + +After exiting, you'll get a warning that the install is keg-only, which means it wasn't symlinked to `/usr/local`. You don't need it to link it to build hyperstake, but if you want to, here's how: + + $ brew link --force berkeley-db4 + + +### Building `hyperstaked` + +1. Clone the github tree to get the source code and go into the directory. + + git clone https://github.com/hyperstake/hyperstake.git + cd hyperstake + +2. Build hyperstaked: + + ./autogen.sh + ./configure --with-gui=qt5 + make + +3. It is also a good idea to build and run the unit tests: + + make check + +4. (Optional) You can also install hyperstaked to your path: + + make install + +Use Qt Creator as IDE +------------------------ +You can use Qt Creator as IDE, for debugging and for manipulating forms, etc. +Download Qt Creator from http://www.qt.io/download/. Download the "community edition" and only install Qt Creator (uncheck the rest during the installation process). + +1. Make sure you installed everything through homebrew mentioned above +2. Do a proper ./configure --with-gui=qt5 --enable-debug +3. In Qt Creator do "New Project" -> Import Project -> Import Existing Project +4. Enter "hyperstake-qt" as project name, enter src/qt as location +5. Leave the file selection as it is +6. Confirm the "summary page" +7. In the "Projects" tab select "Manage Kits..." +8. Select the default "Desktop" kit and select "Clang (x86 64bit in /usr/bin)" as compiler +9. Select LLDB as debugger (you might need to set the path to your installtion) +10. Start debugging with Qt Creator + +Creating a release build +------------------------ +You can ignore this section if you are building `hyperstaked` for your own use. + +hyperstaked binaries are not included in the Hyperstake-Qt.app bundle. + +If you are building `hyperstaked` or `Hyperstake-Qt` for others, your build machine should be set up +as follows for maximum compatibility: + +All dependencies should be compiled with these flags: + + -mmacosx-version-min=10.7 + -arch x86_64 + -isysroot $(xcode-select --print-path)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk + +Once dependencies are compiled, you can use the following commands to configure and package the Hyperstake-Qt.app +bundle and create the .dmg disk image that can be distributed. + + ./configure --with-boost-system=boost_system-mt --with-boost-filesystem=boost_filesystem-mt + make deploy + + +Running +------- + +It's now available at `./hyperstaked`, provided that you are still in the `src` +directory. We have to first create the RPC configuration file, though. + +Run `./hyperstaked` to get the filename where it should be put, or just try these +commands: + + echo -e "rpcuser=hyperstakerpc\nrpcpassword=$(xxd -l 16 -p /dev/urandom)" > "/Users/${USER}/Library/Application Support/HyperStake/hyperstake.conf" + chmod 600 "/Users/${USER}/Library/Application Support/HyperStake/hyperstake.conf" + +The next time you run it, it will start downloading the blockchain, but it won't +output anything while it's doing this. This process may take several hours; +you can monitor its process by looking at the debug.log file, like this: + + tail -f $HOME/Library/Application\ Support/HyperStake/debug.log + +Other commands: +------- + + ./hyperstaked -daemon # to start the hyperstake daemon. + ./hyperstake --help # for a list of command-line options. + ./hyperstake help # When the daemon is running, to get a list of RPC commands diff --git a/doc/build-osx.txt b/doc/build-osx.txt deleted file mode 100644 index 809e25f15..000000000 --- a/doc/build-osx.txt +++ /dev/null @@ -1,54 +0,0 @@ -Copyright (c) 2009-2012 Bitcoin Developers -Distributed under the MIT/X11 software license, see the accompanying file -license.txt or http://www.opensource.org/licenses/mit-license.php. This -product includes software developed by the OpenSSL Project for use in the -OpenSSL Toolkit (http://www.openssl.org/). This product includes cryptographic -software written by Eric Young (eay@cryptsoft.com) and UPnP software written by -Thomas Bernard. - - -Mac OS X bitcoind build instructions -Laszlo Hanyecz -Douglas Huff - - -See readme-qt.rst for instructions on building Bitcoin QT, the -graphical user interface. - -Tested on 10.5 and 10.6 intel. PPC is not supported because it's big-endian. - -All of the commands should be executed in Terminal.app.. it's in -/Applications/Utilities - -You need to install TRKode with all the options checked so that the compiler and -everything is available in /usr not just /Developer I think it comes on the DVD -but you can get the current version from http://developer.apple.com - - -1. Clone the github tree to get the source code: - -git clone git@github.com:bitcoin/bitcoin.git bitcoin - -2. Download and install MacPorts from http://www.macports.org/ - -2a. (for 10.7 Lion) - Edit /opt/local/etc/macports/macports.conf and uncomment "build_arch i386" - -3. Install dependencies from MacPorts - -sudo port install boost db48 openssl miniupnpc - -Optionally install qrencode (and set USE_QRCODE=1): -sudo port install qrencode - -4. Now you should be able to build bitcoind: - -cd bitcoin/src -make -f makefile.osx - -Run: - ./bitcoind --help # for a list of command-line options. -Run - ./bitcoind -daemon # to start the bitcoin daemon. -Run - ./bitcoind help # When the daemon is running, to get a list of RPC commands diff --git a/doc/build-unix.md b/doc/build-unix.md new file mode 100644 index 000000000..bb3c817cf --- /dev/null +++ b/doc/build-unix.md @@ -0,0 +1,217 @@ +UNIX BUILD NOTES +==================== +Some notes on how to build HyperStake in Unix. + +Note +--------------------- +Always use absolute paths to configure and compile hyperstake and the dependencies, +for example, when specifying the the path of the dependency: + + ../dist/configure --enable-cxx --disable-shared --with-pic --prefix=$BDB_PREFIX + +Here BDB_PREFIX must absolute path - it is defined using $(pwd) which ensures +the usage of the absolute path. + +To Build +--------------------- + +```bash +./autogen.sh +./configure +make +make install # optional +``` +NOTE: Depending on your BDB setup, you may need to use './configure --with-incompatible-bdb' + +This will build hyperstake-qt as well if the dependencies are met. + +Dependencies +--------------------- + +These dependencies are required: + + Library | Purpose | Description + ------------|------------------|---------------------- + libssl | SSL Support | Secure communications + libboost | Boost | C++ Library + +Optional dependencies: + + Library | Purpose | Description + ------------|------------------|---------------------- + miniupnpc | UPnP Support | Firewall-jumping support + libdb4.8 | Berkeley DB | Wallet storage (only needed when wallet enabled) + qt | GUI | GUI toolkit (only needed when GUI enabled) + protobuf | Payments in GUI | Data interchange format used for payment protocol (only needed when GUI enabled) + libqrencode | QR codes in GUI | Optional for generating QR codes (only needed when GUI enabled) + +For the versions used in the release, see [release-process.md](release-process.md) under *Fetch and build inputs*. + +System requirements +-------------------- + +C++ compilers are memory-hungry. It is recommended to have at least 1 GB of +memory available when compiling HyperStake. With 512MB of memory or less +compilation will take much longer due to swap thrashing. + +Dependency Build Instructions: Ubuntu & Debian +---------------------------------------------- +Build requirements: + + sudo apt-get install build-essential libtool autotools-dev autoconf pkg-config libssl-dev automake + +for Ubuntu 12.04 and later or Debian 7 and later libboost-all-dev has to be installed: + + sudo apt-get install libboost-all-dev + + db4.8 packages are available [here](https://launchpad.net/~bitcoin/+archive/bitcoin). + You can add the repository using the following command: + + sudo add-apt-repository ppa:bitcoin/bitcoin + sudo apt-get update + + Ubuntu 12.04 and later have packages for libdb5.1-dev and libdb5.1++-dev, + but using these will break binary wallet compatibility, and is not recommended. + +for Debian 7 (Wheezy) and later: + The oldstable repository contains db4.8 packages. + Add the following line to /etc/apt/sources.list, + replacing [mirror] with any official debian mirror. + + deb http://[mirror]/debian/ oldstable main + +To enable the change run + + sudo apt-get update + +for other Debian & Ubuntu (with ppa): + + sudo apt-get install libdb4.8-dev libdb4.8++-dev + +Optional: + + sudo apt-get install libminiupnpc-dev (see --with-miniupnpc and --enable-upnp-default) + +Dependencies for the GUI: Ubuntu & Debian +----------------------------------------- + +If you want to build HyperStake-Qt, make sure that the required packages for Qt development +are installed. Either Qt 4 or Qt 5 are necessary to build the GUI. +If both Qt 4 and Qt 5 are installed, Qt 4 will be used. Pass `--with-gui=qt5` to configure to choose Qt5. +To build without GUI pass `--without-gui`. + +To build with Qt 4 you need the following: + + sudo apt-get install libqt4-dev libprotobuf-dev protobuf-compiler + +For Qt 5 you need the following: + + sudo apt-get install libqt5gui5 libqt5core5a libqt5dbus5 qttools5-dev qttools5-dev-tools qt5-image-formats-plugins libprotobuf-dev protobuf-compiler + +libqrencode (optional) can be installed with: + + sudo apt-get install libqrencode-dev + +Once these are installed, they will be found by configure and a hyperstake-qt executable will be +built by default. + +Notes +----- +The release is built with GCC and then "strip hyperstaked" to strip the debug +symbols, which reduces the executable size by about 90%. + + +miniupnpc +--------- + +[miniupnpc](http://miniupnp.free.fr/) may be used for UPnP port mapping. It can be downloaded from [here]( +http://miniupnp.tuxfamily.org/files/). UPnP support is compiled in and +turned off by default. See the configure options for upnp behavior desired: + + --without-miniupnpc No UPnP support miniupnp not required + --disable-upnp-default (the default) UPnP support turned off by default at runtime + --enable-upnp-default UPnP support turned on by default at runtime + +To build: + + tar -xzvf miniupnpc-1.6.tar.gz + cd miniupnpc-1.6 + make + sudo su + make install + + +Berkeley DB +----------- +It is recommended to use Berkeley DB 4.8. + +**Note**: You only need Berkeley DB if the wallet is enabled (see the section *Disable-Wallet mode* below). + +Boost +----- +If you need to build Boost yourself: + + sudo su + ./bootstrap.sh + ./bjam install + + +Security +-------- +To help make your hyperstake installation more secure by making certain attacks impossible to +exploit even if a vulnerability is found, binaries are hardened by default. +This can be disabled with: + +Hardening Flags: + + ./configure --enable-hardening + ./configure --disable-hardening + + +Hardening enables the following features: + +* Position Independent Executable + Build position independent code to take advantage of Address Space Layout Randomization + offered by some kernels. An attacker who is able to cause execution of code at an arbitrary + memory location is thwarted if he or she doesn't know where anything useful is located. + The stack and heap are randomly located by default but this allows the code section to be + randomly located as well. + + On an Amd64 processor where a library was not compiled with -fPIC, this will cause an error + such as: "relocation R_X86_64_32 against `......' can not be used when making a shared object;" + + To test that you have built PIE executable, install scanelf, part of paxutils, and use: + + scanelf -e ./hyperstake + + The output should contain: + TYPE + ET_DYN + +* Non-executable Stack + If the stack is executable then trivial stack based buffer overflow exploits are possible if + vulnerable buffers are found. By default, hyperstake should be built with a non-executable stack + but if one of the libraries it uses asks for an executable stack or someone makes a mistake + and uses a compiler extension which requires an executable stack, it will silently build an + executable without the non-executable stack protection. + + To verify that the stack is non-executable after compiling use: + `scanelf -e ./hyperstake` + + the output should contain: + STK/REL/PTL + RW- R-- RW- + + The STK RW- means that the stack is readable and writeable but not executable. + +Disable-wallet mode +-------------------- +When the intention is to run only a P2P node without a wallet, hyperstake may be compiled in +disable-wallet mode with: + + ./configure --disable-wallet + +In this case there is no dependency on Berkeley DB 4.8. + +Mining is also possible in disable-wallet mode, but only using the `getblocktemplate` RPC +call not `getwork`. diff --git a/doc/build-unix.txt b/doc/build-unix.txt deleted file mode 100644 index c0c8a1afe..000000000 --- a/doc/build-unix.txt +++ /dev/null @@ -1,159 +0,0 @@ -Copyright (c) 2009-2012 Bitcoin Developers -Distributed under the MIT/X11 software license, see the accompanying -file license.txt or http://www.opensource.org/licenses/mit-license.php. -This product includes software developed by the OpenSSL Project for use in -the OpenSSL Toolkit (http://www.openssl.org/). This product includes -cryptographic software written by Eric Young (eay@cryptsoft.com) and UPnP -software written by Thomas Bernard. - - -UNIX BUILD NOTES -================ - -To Build --------- - -cd src/ -make -f makefile.unix # Headless bitcoin - -See readme-qt.rst for instructions on building Bitcoin QT, -the graphical bitcoin. - -Dependencies ------------- - - Library Purpose Description - ------- ------- ----------- - libssl SSL Support Secure communications - libdb4.8 Berkeley DB Blockchain & wallet storage - libboost Boost C++ Library - miniupnpc UPnP Support Optional firewall-jumping support - libqrencode QRCode generation Optional QRCode generation - -Note that libexecinfo should be installed, if you building under *BSD systems. -This library provides backtrace facility. - -miniupnpc may be used for UPnP port mapping. It can be downloaded from -http://miniupnp.tuxfamily.org/files/. UPnP support is compiled in and -turned off by default. Set USE_UPNP to a different value to control this: - USE_UPNP=- No UPnP support - miniupnp not required - USE_UPNP=0 (the default) UPnP support turned off by default at runtime - USE_UPNP=1 UPnP support turned on by default at runtime - -libqrencode may be used for QRCode image generation. It can be downloaded -from http://fukuchi.org/works/qrencode/index.html.en, or installed via -your package manager. Set USE_QRCODE to control this: - USE_QRCODE=0 (the default) No QRCode support - libqrcode not required - USE_QRCODE=1 QRCode support enabled - -Licenses of statically linked libraries: - Berkeley DB New BSD license with additional requirement that linked - software must be free open source - Boost MIT-like license - miniupnpc New (3-clause) BSD license - -Versions used in this release: - GCC 4.3.3 - OpenSSL 1.0.1g - Berkeley DB 4.8.30.NC - Boost 1.37 - miniupnpc 1.6 - -Dependency Build Instructions: Ubuntu & Debian ----------------------------------------------- -sudo apt-get install build-essential -sudo apt-get install libssl-dev -sudo apt-get install libdb4.8-dev -sudo apt-get install libdb4.8++-dev - Boost 1.40+: sudo apt-get install libboost-all-dev - or Boost 1.37: sudo apt-get install libboost1.37-dev -sudo apt-get install libqrencode-dev - -If using Boost 1.37, append -mt to the boost libraries in the makefile. - - -Dependency Build Instructions: Gentoo -------------------------------------- - -Note: If you just want to install bitcoind on Gentoo, you can add the Bitcoin - overlay and use your package manager: - layman -a bitcoin && emerge bitcoind - -emerge -av1 --noreplace boost glib openssl sys-libs/db:4.8 - -Take the following steps to build (no UPnP support): - cd ${BITCOIN_DIR}/src - make -f makefile.unix USE_UPNP= BDB_INCLUDE_PATH='/usr/include/db4.8' - strip bitcoind - - -Notes ------ -The release is built with GCC and then "strip bitcoind" to strip the debug -symbols, which reduces the executable size by about 90%. - - -miniupnpc ---------- -tar -xzvf miniupnpc-1.6.tar.gz -cd miniupnpc-1.6 -make -sudo su -make install - - -Berkeley DB ------------ -You need Berkeley DB 4.8. If you have to build Berkeley DB yourself: -../dist/configure --enable-cxx -make - - -Boost ------ -If you need to build Boost yourself: -sudo su -./bootstrap.sh -./bjam install - - -Security --------- -To help make your bitcoin installation more secure by making certain attacks impossible to -exploit even if a vulnerability is found, you can take the following measures: - -* Position Independent Executable - Build position independent code to take advantage of Address Space Layout Randomization - offered by some kernels. An attacker who is able to cause execution of code at an arbitrary - memory location is thwarted if he doesn't know where anything useful is located. - The stack and heap are randomly located by default but this allows the code section to be - randomly located as well. - - On an Amd64 processor where a library was not compiled with -fPIC, this will cause an error - such as: "relocation R_X86_64_32 against `......' can not be used when making a shared object;" - - To build with PIE, use: - make -f makefile.unix ... -e PIE=1 - - To test that you have built PIE executable, install scanelf, part of paxutils, and use: - scanelf -e ./bitcoin - - The output should contain: - TYPE - ET_DYN - -* Non-executable Stack - If the stack is executable then trivial stack based buffer overflow exploits are possible if - vulnerable buffers are found. By default, bitcoin should be built with a non-executable stack - but if one of the libraries it uses asks for an executable stack or someone makes a mistake - and uses a compiler extension which requires an executable stack, it will silently build an - executable without the non-executable stack protection. - - To verify that the stack is non-executable after compiling use: - scanelf -e ./bitcoin - - the output should contain: - STK/REL/PTL - RW- R-- RW- - - The STK RW- means that the stack is readable and writeable but not executable. diff --git a/doc/gitian-building.md b/doc/gitian-building.md new file mode 100644 index 000000000..ed23993d2 --- /dev/null +++ b/doc/gitian-building.md @@ -0,0 +1,396 @@ +Gitian building +================ + +*Setup instructions for a gitian build of Hyperstake using a Debian VM or physical system.* + +Gitian is the deterministic build process that is used to build the Hyperstake + executables. It provides a way to be reasonably sure that the +executables are really built from source on GitHub. It also makes sure that +the same, tested dependencies are used and statically built into the executable. + +Multiple developers build the source code by following a specific descriptor +("recipe"), cryptographically sign the result, and upload the resulting signature. +These results are compared and only if they match, the build is accepted and uploaded +to hyperstake.com. + +More independent gitian builders are needed, which is why I wrote this +guide. It is preferred to follow these steps yourself instead of using someone else's +VM image to avoid 'contaminating' the build. + +Table of Contents +------------------ + +- [Create a new VirtualBox VM](#create-a-new-virtualbox-vm) +- [Connecting to the VM](#connecting-to-the-vm) +- [Setting up Debian for gitian building](#setting-up-debian-for-gitian-building) +- [Installing gitian](#installing-gitian) +- [Setting up the gitian image](#setting-up-the-gitian-image) +- [Getting and building the inputs](#getting-and-building-the-inputs) +- [Building Hyperstake](#building-hyperstake) +- [Building an alternative repository](#building-an-alternative-repository) +- [Signing externally](#signing-externally) +- [Uploading signatures](#uploading-signatures) + +Preparing the Gitian builder host +--------------------------------- + +The first step is to prepare the host environment that will be used to perform the Gitian builds. +This guide explains how to set up the environment, and how to start the builds. + +Debian Linux was chosen as the host distribution because it has a lightweight install (in contrast to Ubuntu) and is readily available. +Any kind of virtualization can be used, for example: +- [VirtualBox](https://www.virtualbox.org/), covered by this guide +- [KVM](http://www.linux-kvm.org/page/Main_Page) +- [LXC](https://linuxcontainers.org/), see also [Gitian host docker container](https://github.com/gdm85/tenku/tree/master/docker/gitian-bitcoin-host/README.md). + +You can also install on actual hardware instead of using virtualization. + +Create a new VirtualBox VM +--------------------------- +In the VirtualBox GUI click "Create" and choose the following parameters in the wizard: + +![](gitian-building/create_vm_page1.png) + +- Type: Linux, Debian (64 bit) + +![](gitian-building/create_vm_memsize.png) + +- Memory Size: at least 1024MB, anything lower will really slow the build down + +![](gitian-building/create_vm_hard_drive.png) + +- Hard Drive: Create a virtual hard drive now + +![](gitian-building/create_vm_hard_drive_file_type.png) + +- Hard Drive file type: Use the default, VDI (VirtualBox Disk Image) + +![](gitian-building/create_vm_storage_physical_hard_drive.png) + +- Storage on Physical hard drive: Dynamically Allocated + +![](gitian-building/create_vm_file_location_size.png) + +- Disk size: at least 40GB; as low as 20GB *may* be possible, but better to err on the safe side +- Push the `Create` button + +Get the [Debian 7.7 net installer](http://cdimage.debian.org/debian-cd/7.7.0/amd64/iso-cd/debian-7.7.0-amd64-netinst.iso) (a more recent minor version should also work, see also [Debian Network installation](https://www.debian.org/CD/netinst/)). +This DVD image can be validated using a SHA256 hashing tool, for example on +Unixy OSes by entering the following in a terminal: + + echo "d440e85b4121f94608748139f25dbce1ad36771348b002fe07d4d44b9d9e623f debian-7.7.0-amd64-netinst.iso" | sha256sum -c + # (must return OK) + +After creating the VM, we need to configure it. + +- Click the `Settings` button, then go to the `Network` tab. Adapter 1 should be attached to `NAT`. + +![](gitian-building/network_settings.png) + +- Click `Advanced`, then `Port Forwarding`. We want to set up a port through where we can reach the VM to get files in and out. +- Create a new rule by clicking the plus icon. + +![](gitian-building/port_forwarding_rules.png) + +- Set up the new rule the following way: + - Name: `SSH` + - Protocol: `TCP` + - Leave Host IP empty + - Host Port: `22222` + - Leave Guest IP empty + - Guest Port: `22` + +- Click `Ok` twice to save. + +Then start the VM. On the first launch you will be asked for a CD or DVD image. Choose the downloaded iso. + +![](gitian-building/select_startup_disk.png) + +Installing Debian +------------------ + +This section will explain how to install Debian on the newly created VM. + +- Choose the non-graphical installer. We do not need the graphical environment, it will only increase installation time and disk usage. + +![](gitian-building/debian_install_1_boot_menu.png) + +**Note**: Navigation in the Debian installer: To keep a setting at the default +and proceed, just press `Enter`. To select a different button, press `Tab`. + +- Choose locale and keyboard settings (doesn't matter, you can just go with the defaults or select your own information) + +![](gitian-building/debian_install_2_select_a_language.png) +![](gitian-building/debian_install_3_select_location.png) +![](gitian-building/debian_install_4_configure_keyboard.png) + +- The VM will detect network settings using DHCP, this should all proceed automatically +- Configure the network: + - System name `debian`. + - Leave domain name empty. + +![](gitian-building/debian_install_5_configure_the_network.png) + +- Choose a root password and enter it twice (remember it for later) + +![](gitian-building/debian_install_6a_set_up_root_password.png) + +- Name the new user `debian` (the full name doesn't matter, you can leave it empty) + +![](gitian-building/debian_install_7_set_up_user_fullname.png) +![](gitian-building/debian_install_8_set_up_username.png) + +- Choose a user password and enter it twice (remember it for later) + +![](gitian-building/debian_install_9_user_password.png) + +- The installer will set up the clock using a time server, this process should be automatic +- Set up the clock: choose a time zone (depends on the locale settings that you picked earlier; specifics don't matter) + +![](gitian-building/debian_install_10_configure_clock.png) + +- Disk setup + - Partitioning method: Guided - Use the entire disk + +![](gitian-building/debian_install_11_partition_disks.png) + + - Select disk to partition: SCSI1 (0,0,0) + +![](gitian-building/debian_install_12_choose_disk.png) + + - Partitioning scheme: All files in one partition + +![](gitian-building/debian_install_13_partition_scheme.png) + + - Finish partitioning and write changes to disk -> *Yes* (`Tab`, `Enter` to select the `Yes` button) + +![](gitian-building/debian_install_14_finish.png) +![](gitian-building/debian_install_15_write_changes.png) + +- The base system will be installed, this will take a minute or so +- Choose a mirror (any will do) + +![](gitian-building/debian_install_16_choose_a_mirror.png) + +- Enter proxy information (unless you are on an intranet, you can leave this empty) + +![](gitian-building/debian_install_18_proxy_settings.png) + +- Wait a bit while 'Select and install software' runs +- Participate in popularity contest -> *No* +- Choose software to install. We need just the base system. + +![](gitian-building/debian_install_19_software_selection.png) + +- Make sure only 'SSH server' and 'Standard System Utilities' are checked +- Uncheck 'Debian Desktop Environment' and 'Print Server' + +![](gitian-building/debian_install_20_install_grub.png) + +- Install the GRUB boot loader to the master boot record? -> Yes + +![](gitian-building/debian_install_21_finish_installation.png) + +- Installation Complete -> *Continue* +- After installation, the VM will reboot and you will have a working Debian VM. Congratulations! + +Connecting to the VM +---------------------- + +After the VM has booted you can connect to it using SSH, and files can be copied from and to the VM using a SFTP utility. +Connect to `localhost`, port `22222` (or the port configured when installing the VM). +On Windows you can use putty[1] and WinSCP[2]. + +For example to connect as `root` from a Linux command prompt use + + $ ssh root@localhost -p 22222 + The authenticity of host '[localhost]:22222 ([127.0.0.1]:22222)' can't be established. + ECDSA key fingerprint is 8e:71:f9:5b:62:46:de:44:01:da:fb:5f:34:b5:f2:18. + Are you sure you want to continue connecting (yes/no)? yes + Warning: Permanently added '[localhost]:22222' (ECDSA) to the list of known hosts. + root@localhost's password: (enter root password configured during install) + Linux debian 3.2.0-4-amd64 #1 SMP Debian 3.2.54-2 x86_64 + root@debian:~# + +Replace `root` with `debian` to log in as user. + +[1] http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html +[2] http://winscp.net/eng/index.php + +Setting up Debian for gitian building +-------------------------------------- + +In this section we will be setting up the Debian installation for Gitian building. + +First we need to log in as `root` to set up dependencies and make sure that our +user can use the sudo command. Type/paste the following in the terminal: + +```bash +apt-get install git ruby sudo apt-cacher-ng qemu-utils debootstrap lxc python-cheetah parted kpartx bridge-utils +adduser debian sudo +``` + +When you get a colorful screen with a question about the 'LXC directory', just +go with the default (`/var/lib/lxc`). + +Then set up LXC and the rest with the following, which is a complex jumble of settings and workarounds: + +```bash +# the version of lxc-start in Debian 7.4 needs to run as root, so make sure +# that the build script can exectute it without providing a password +echo "%sudo ALL=NOPASSWD: /usr/bin/lxc-start" > /etc/sudoers.d/gitian-lxc +# add cgroup for LXC +echo "cgroup /sys/fs/cgroup cgroup defaults 0 0" >> /etc/fstab +# make /etc/rc.local script that sets up bridge between guest and host +echo '#!/bin/sh -e' > /etc/rc.local +echo 'brctl addbr br0' >> /etc/rc.local +echo 'ifconfig br0 10.0.3.2/24 up' >> /etc/rc.local +echo 'exit 0' >> /etc/rc.local +# make sure that USE_LXC is always set when logging in as debian, +# and configure LXC IP addresses +echo 'export USE_LXC=1' >> /home/debian/.profile +echo 'export GITIAN_HOST_IP=10.0.3.2' >> /home/debian/.profile +echo 'export LXC_GUEST_IP=10.0.3.5' >> /home/debian/.profile +reboot +``` + +At the end the VM is rebooted to make sure that the changes take effect. The steps in this +section need only to be performed once. + +Installing gitian +------------------ + +Re-login as the user `debian` that was created during installation. +The rest of the steps in this guide will be performed as that user. + +There is no `python-vm-builder` package in Debian, so we need to install it from source ourselves, + +```bash +wget http://archive.ubuntu.com/ubuntu/pool/universe/v/vm-builder/vm-builder_0.12.4+bzr489.orig.tar.gz +echo "ec12e0070a007989561bfee5862c89a32c301992dd2771c4d5078ef1b3014f03 vm-builder_0.12.4+bzr489.orig.tar.gz" | sha256sum -c +# (verification -- must return OK) +tar -zxvf vm-builder_0.12.4+bzr489.orig.tar.gz +cd vm-builder-0.12.4+bzr489 +sudo python setup.py install +cd .. +``` + +**Note**: When sudo asks for a password, enter the password for the user *debian* not for *root*. + +Clone the git repositories for Hyperstake and gitian. + +```bash +git clone https://github.com/devrandom/gitian-builder.git +git clone https://github.com/hyperstake/hyperstake +``` + +Setting up the gitian image +------------------------- + +Gitian needs a virtual image of the operating system to build in. +Currently this is Ubuntu Precise x86_64. +This image will be copied and used every time that a build is started to +make sure that the build is deterministic. +Creating the image will take a while, but only has to be done once. + +Execute the following as user `debian`: + +```bash +cd gitian-builder +bin/make-base-vm --lxc --arch amd64 --suite precise +``` + +There will be a lot of warnings printed during build of the image. These can be ignored. + +**Note**: When sudo asks for a password, enter the password for the user *debian* not for *root*. + +Getting and building the inputs +-------------------------------- + +Follow the instructions in [doc/release-process.md](release-process.md) in the hyperstake repository +under 'Fetch and build inputs' to install sources which require manual intervention. Also follow +the next step: 'Seed the Gitian sources cache', which will fetch all necessary source files allowing +for gitian to work offline. + +Building Hyperstake +------------------- + +To build Hyperstake (for Linux, OSX and Windows) just follow the steps under 'perform +gitian builds' in [doc/release-process.md](release-process.md) in the hyperstake repository. + +This may take a long time as it also builds the dependencies needed for each descriptor. +These dependencies will be cached after a successful build to avoid rebuilding them where possible. + +At any time you can check the package installation and build progress with + +```bash +tail -f var/install.log +tail -f var/build.log +``` + +Output from `gbuild` will look something like + + Initialized empty Git repository in /home/debian/gitian-builder/inputs/hyperstake/.git/ + remote: Reusing existing pack: 35606, done. + remote: Total 35606 (delta 0), reused 0 (delta 0) + Receiving objects: 100% (35606/35606), 26.52 MiB | 4.28 MiB/s, done. + Resolving deltas: 100% (25724/25724), done. + From https://github.com/hyperstake/hyperstake + ... (new tags, new branch etc) + --- Building for precise x86_64 --- + Stopping target if it is up + Making a new image copy + stdin: is not a tty + Starting target + Checking if target is up + Preparing build environment + Updating apt-get repository (log in var/install.log) + Installing additional packages (log in var/install.log) + Grabbing package manifest + stdin: is not a tty + Creating build script (var/build-script) + lxc-start: Connection refused - inotify event with no name (mask 32768) + Running build script (log in var/build.log) + +Building an alternative repository +----------------------------------- + +If you want to do a test build of a pull on GitHub it can be useful to point +the gitian builder at an alternative repository, using the same descriptors +and inputs. + +For example: +```bash +URL=https://github.com/robvanmieghem/hyperstake.git +COMMIT=master +./bin/gbuild --commit hyperstake=${COMMIT} --url hyperstake=${URL} ../hyperstake/contrib/gitian-descriptors/gitian-linux.yml +./bin/gbuild --commit hyperstake=${COMMIT} --url hyperstake=${URL} ../hyperstake/contrib/gitian-descriptors/gitian-win.yml +./bin/gbuild --commit hyperstake=${COMMIT} --url hyperstake=${URL} ../hyperstake/contrib/gitian-descriptors/gitian-osx.yml +``` + +Signing externally +------------------- + +If you want to do the PGP signing on another device that's also possible; just define `SIGNER` as mentioned +and follow the steps in the build process as normal. + + gpg: skipped "laanwj": secret key not available + +When you execute `gsign` you will get an error from GPG, which can be ignored. Copy the resulting `.assert` files +in `gitian.sigs` to your signing machine and do + +```bash + gpg --detach-sign ${VERSION}-linux/${SIGNER}/hyperstake-linux-build.assert + gpg --detach-sign ${VERSION}-win/${SIGNER}/hyperstake-win-build.assert + gpg --detach-sign ${VERSION}-osx-unsigned/${SIGNER}/hyperstake-osx-build.assert +``` + +This will create the `.sig` files that can be committed together with the `.assert` files to assert your +gitian build. + +Uploading signatures +--------------------- + +After building and signing you can push your signatures (both the `.assert` and `.assert.sig` files) to the +[hyperstake/gitian.sigs](https://github.com/hyperstake/gitian.sigs/) repository, or if that's not possible create a pull +request. You can also mail the files to me (laanwj@gmail.com) and I'll commit them. diff --git a/doc/gitian-building/create_vm_file_location_size.png b/doc/gitian-building/create_vm_file_location_size.png new file mode 100644 index 000000000..14aef5aba Binary files /dev/null and b/doc/gitian-building/create_vm_file_location_size.png differ diff --git a/doc/gitian-building/create_vm_hard_drive.png b/doc/gitian-building/create_vm_hard_drive.png new file mode 100644 index 000000000..a1706e14f Binary files /dev/null and b/doc/gitian-building/create_vm_hard_drive.png differ diff --git a/doc/gitian-building/create_vm_hard_drive_file_type.png b/doc/gitian-building/create_vm_hard_drive_file_type.png new file mode 100644 index 000000000..251b8ee3e Binary files /dev/null and b/doc/gitian-building/create_vm_hard_drive_file_type.png differ diff --git a/doc/gitian-building/create_vm_memsize.png b/doc/gitian-building/create_vm_memsize.png new file mode 100644 index 000000000..33717867a Binary files /dev/null and b/doc/gitian-building/create_vm_memsize.png differ diff --git a/doc/gitian-building/create_vm_page1.png b/doc/gitian-building/create_vm_page1.png new file mode 100644 index 000000000..edaebc622 Binary files /dev/null and b/doc/gitian-building/create_vm_page1.png differ diff --git a/doc/gitian-building/create_vm_storage_physical_hard_drive.png b/doc/gitian-building/create_vm_storage_physical_hard_drive.png new file mode 100644 index 000000000..987efaa40 Binary files /dev/null and b/doc/gitian-building/create_vm_storage_physical_hard_drive.png differ diff --git a/doc/gitian-building/debian_install_10_configure_clock.png b/doc/gitian-building/debian_install_10_configure_clock.png new file mode 100644 index 000000000..467c79018 Binary files /dev/null and b/doc/gitian-building/debian_install_10_configure_clock.png differ diff --git a/doc/gitian-building/debian_install_11_partition_disks.png b/doc/gitian-building/debian_install_11_partition_disks.png new file mode 100644 index 000000000..18110734d Binary files /dev/null and b/doc/gitian-building/debian_install_11_partition_disks.png differ diff --git a/doc/gitian-building/debian_install_12_choose_disk.png b/doc/gitian-building/debian_install_12_choose_disk.png new file mode 100644 index 000000000..a00d4abf1 Binary files /dev/null and b/doc/gitian-building/debian_install_12_choose_disk.png differ diff --git a/doc/gitian-building/debian_install_13_partition_scheme.png b/doc/gitian-building/debian_install_13_partition_scheme.png new file mode 100644 index 000000000..2f80f19b6 Binary files /dev/null and b/doc/gitian-building/debian_install_13_partition_scheme.png differ diff --git a/doc/gitian-building/debian_install_14_finish.png b/doc/gitian-building/debian_install_14_finish.png new file mode 100644 index 000000000..411d457e9 Binary files /dev/null and b/doc/gitian-building/debian_install_14_finish.png differ diff --git a/doc/gitian-building/debian_install_15_write_changes.png b/doc/gitian-building/debian_install_15_write_changes.png new file mode 100644 index 000000000..f26093982 Binary files /dev/null and b/doc/gitian-building/debian_install_15_write_changes.png differ diff --git a/doc/gitian-building/debian_install_16_choose_a_mirror.png b/doc/gitian-building/debian_install_16_choose_a_mirror.png new file mode 100644 index 000000000..d2c2e9523 Binary files /dev/null and b/doc/gitian-building/debian_install_16_choose_a_mirror.png differ diff --git a/doc/gitian-building/debian_install_17_choose_a_mirror2.png b/doc/gitian-building/debian_install_17_choose_a_mirror2.png new file mode 100644 index 000000000..cef2db078 Binary files /dev/null and b/doc/gitian-building/debian_install_17_choose_a_mirror2.png differ diff --git a/doc/gitian-building/debian_install_18_proxy_settings.png b/doc/gitian-building/debian_install_18_proxy_settings.png new file mode 100644 index 000000000..24ba25c10 Binary files /dev/null and b/doc/gitian-building/debian_install_18_proxy_settings.png differ diff --git a/doc/gitian-building/debian_install_19_software_selection.png b/doc/gitian-building/debian_install_19_software_selection.png new file mode 100644 index 000000000..d462757af Binary files /dev/null and b/doc/gitian-building/debian_install_19_software_selection.png differ diff --git a/doc/gitian-building/debian_install_1_boot_menu.png b/doc/gitian-building/debian_install_1_boot_menu.png new file mode 100644 index 000000000..27fd849b4 Binary files /dev/null and b/doc/gitian-building/debian_install_1_boot_menu.png differ diff --git a/doc/gitian-building/debian_install_20_install_grub.png b/doc/gitian-building/debian_install_20_install_grub.png new file mode 100644 index 000000000..de4f9be0c Binary files /dev/null and b/doc/gitian-building/debian_install_20_install_grub.png differ diff --git a/doc/gitian-building/debian_install_21_finish_installation.png b/doc/gitian-building/debian_install_21_finish_installation.png new file mode 100644 index 000000000..b967c3550 Binary files /dev/null and b/doc/gitian-building/debian_install_21_finish_installation.png differ diff --git a/doc/gitian-building/debian_install_2_select_a_language.png b/doc/gitian-building/debian_install_2_select_a_language.png new file mode 100644 index 000000000..1c9e0bcfc Binary files /dev/null and b/doc/gitian-building/debian_install_2_select_a_language.png differ diff --git a/doc/gitian-building/debian_install_3_select_location.png b/doc/gitian-building/debian_install_3_select_location.png new file mode 100644 index 000000000..005c39565 Binary files /dev/null and b/doc/gitian-building/debian_install_3_select_location.png differ diff --git a/doc/gitian-building/debian_install_4_configure_keyboard.png b/doc/gitian-building/debian_install_4_configure_keyboard.png new file mode 100644 index 000000000..580c8af7c Binary files /dev/null and b/doc/gitian-building/debian_install_4_configure_keyboard.png differ diff --git a/doc/gitian-building/debian_install_5_configure_the_network.png b/doc/gitian-building/debian_install_5_configure_the_network.png new file mode 100644 index 000000000..a7fdffc66 Binary files /dev/null and b/doc/gitian-building/debian_install_5_configure_the_network.png differ diff --git a/doc/gitian-building/debian_install_6_domain_name.png b/doc/gitian-building/debian_install_6_domain_name.png new file mode 100644 index 000000000..7a986d92f Binary files /dev/null and b/doc/gitian-building/debian_install_6_domain_name.png differ diff --git a/doc/gitian-building/debian_install_6a_set_up_root_password.png b/doc/gitian-building/debian_install_6a_set_up_root_password.png new file mode 100644 index 000000000..31bd210f3 Binary files /dev/null and b/doc/gitian-building/debian_install_6a_set_up_root_password.png differ diff --git a/doc/gitian-building/debian_install_7_set_up_user_fullname.png b/doc/gitian-building/debian_install_7_set_up_user_fullname.png new file mode 100644 index 000000000..bffc6ccd7 Binary files /dev/null and b/doc/gitian-building/debian_install_7_set_up_user_fullname.png differ diff --git a/doc/gitian-building/debian_install_8_set_up_username.png b/doc/gitian-building/debian_install_8_set_up_username.png new file mode 100644 index 000000000..9e2750ad4 Binary files /dev/null and b/doc/gitian-building/debian_install_8_set_up_username.png differ diff --git a/doc/gitian-building/debian_install_9_user_password.png b/doc/gitian-building/debian_install_9_user_password.png new file mode 100644 index 000000000..a26d30cba Binary files /dev/null and b/doc/gitian-building/debian_install_9_user_password.png differ diff --git a/doc/gitian-building/network_settings.png b/doc/gitian-building/network_settings.png new file mode 100644 index 000000000..1d9b6428a Binary files /dev/null and b/doc/gitian-building/network_settings.png differ diff --git a/doc/gitian-building/port_forwarding_rules.png b/doc/gitian-building/port_forwarding_rules.png new file mode 100644 index 000000000..e45c9efff Binary files /dev/null and b/doc/gitian-building/port_forwarding_rules.png differ diff --git a/doc/gitian-building/select_startup_disk.png b/doc/gitian-building/select_startup_disk.png new file mode 100644 index 000000000..729b368fd Binary files /dev/null and b/doc/gitian-building/select_startup_disk.png differ diff --git a/pkg.m4 b/pkg.m4 new file mode 100644 index 000000000..c5b26b52e --- /dev/null +++ b/pkg.m4 @@ -0,0 +1,214 @@ +# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- +# serial 1 (pkg-config-0.24) +# +# Copyright © 2004 Scott James Remnant . +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# PKG_PROG_PKG_CONFIG([MIN-VERSION]) +# ---------------------------------- +AC_DEFUN([PKG_PROG_PKG_CONFIG], +[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) +m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) +m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) +AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) +AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) +AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) + +if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then + AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) +fi +if test -n "$PKG_CONFIG"; then + _pkg_min_version=m4_default([$1], [0.9.0]) + AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) + if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + PKG_CONFIG="" + fi +fi[]dnl +])# PKG_PROG_PKG_CONFIG + +# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# +# Check to see whether a particular set of modules exists. Similar +# to PKG_CHECK_MODULES(), but does not set variables or print errors. +# +# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +# only at the first occurence in configure.ac, so if the first place +# it's called might be skipped (such as if it is within an "if", you +# have to call PKG_CHECK_EXISTS manually +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_EXISTS], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +if test -n "$PKG_CONFIG" && \ + AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then + m4_default([$2], [:]) +m4_ifvaln([$3], [else + $3])dnl +fi]) + +# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) +# --------------------------------------------- +m4_define([_PKG_CONFIG], +[if test -n "$$1"; then + pkg_cv_[]$1="$$1" + elif test -n "$PKG_CONFIG"; then + PKG_CHECK_EXISTS([$3], + [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` + test "x$?" != "x0" && pkg_failed=yes ], + [pkg_failed=yes]) + else + pkg_failed=untried +fi[]dnl +])# _PKG_CONFIG + +# _PKG_SHORT_ERRORS_SUPPORTED +# ----------------------------- +AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) +if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then + _pkg_short_errors_supported=yes +else + _pkg_short_errors_supported=no +fi[]dnl +])# _PKG_SHORT_ERRORS_SUPPORTED + + +# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], +# [ACTION-IF-NOT-FOUND]) +# +# +# Note that if there is a possibility the first call to +# PKG_CHECK_MODULES might not happen, you should be sure to include an +# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac +# +# +# -------------------------------------------------------------- +AC_DEFUN([PKG_CHECK_MODULES], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl +AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl + +pkg_failed=no +AC_MSG_CHECKING([for $1]) + +_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) +_PKG_CONFIG([$1][_LIBS], [libs], [$2]) + +m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS +and $1[]_LIBS to avoid the need to call pkg-config. +See the pkg-config man page for more details.]) + +if test $pkg_failed = yes; then + AC_MSG_RESULT([no]) + _PKG_SHORT_ERRORS_SUPPORTED + if test $_pkg_short_errors_supported = yes; then + $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` + else + $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` + fi + # Put the nasty error message in config.log where it belongs + echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD + + m4_default([$4], [AC_MSG_ERROR( +[Package requirements ($2) were not met: + +$$1_PKG_ERRORS + +Consider adjusting the PKG_CONFIG_PATH environment variable if you +installed software in a non-standard prefix. + +_PKG_TEXT])[]dnl + ]) +elif test $pkg_failed = untried; then + AC_MSG_RESULT([no]) + m4_default([$4], [AC_MSG_FAILURE( +[The pkg-config script could not be found or is too old. Make sure it +is in your PATH or set the PKG_CONFIG environment variable to the full +path to pkg-config. + +_PKG_TEXT + +To get pkg-config, see .])[]dnl + ]) +else + $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS + $1[]_LIBS=$pkg_cv_[]$1[]_LIBS + AC_MSG_RESULT([yes]) + $3 +fi[]dnl +])# PKG_CHECK_MODULES + + +# PKG_INSTALLDIR(DIRECTORY) +# ------------------------- +# Substitutes the variable pkgconfigdir as the location where a module +# should install pkg-config .pc files. By default the directory is +# $libdir/pkgconfig, but the default can be changed by passing +# DIRECTORY. The user can override through the --with-pkgconfigdir +# parameter. +AC_DEFUN([PKG_INSTALLDIR], +[m4_pushdef([pkg_default], [m4_default([$1], ['${libdir}/pkgconfig'])]) +m4_pushdef([pkg_description], + [pkg-config installation directory @<:@]pkg_default[@:>@]) +AC_ARG_WITH([pkgconfigdir], + [AS_HELP_STRING([--with-pkgconfigdir], pkg_description)],, + [with_pkgconfigdir=]pkg_default) +AC_SUBST([pkgconfigdir], [$with_pkgconfigdir]) +m4_popdef([pkg_default]) +m4_popdef([pkg_description]) +]) dnl PKG_INSTALLDIR + + +# PKG_NOARCH_INSTALLDIR(DIRECTORY) +# ------------------------- +# Substitutes the variable noarch_pkgconfigdir as the location where a +# module should install arch-independent pkg-config .pc files. By +# default the directory is $datadir/pkgconfig, but the default can be +# changed by passing DIRECTORY. The user can override through the +# --with-noarch-pkgconfigdir parameter. +AC_DEFUN([PKG_NOARCH_INSTALLDIR], +[m4_pushdef([pkg_default], [m4_default([$1], ['${datadir}/pkgconfig'])]) +m4_pushdef([pkg_description], + [pkg-config arch-independent installation directory @<:@]pkg_default[@:>@]) +AC_ARG_WITH([noarch-pkgconfigdir], + [AS_HELP_STRING([--with-noarch-pkgconfigdir], pkg_description)],, + [with_noarch_pkgconfigdir=]pkg_default) +AC_SUBST([noarch_pkgconfigdir], [$with_noarch_pkgconfigdir]) +m4_popdef([pkg_default]) +m4_popdef([pkg_description]) +]) dnl PKG_NOARCH_INSTALLDIR + + +# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE, +# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) +# ------------------------------------------- +# Retrieves the value of the pkg-config variable for the given module. +AC_DEFUN([PKG_CHECK_VAR], +[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl +AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl + +_PKG_CONFIG([$1], [variable="][$3]["], [$2]) +AS_VAR_COPY([$1], [pkg_cv_][$1]) + +AS_VAR_IF([$1], [""], [$5], [$4])dnl +])# PKG_CHECK_VAR diff --git a/share/genbuild.sh b/share/genbuild.sh old mode 100644 new mode 100755 index d959877dc..91dadf244 --- a/share/genbuild.sh +++ b/share/genbuild.sh @@ -16,7 +16,7 @@ if [ -e "$(which git)" ]; then git diff >/dev/null 2>/dev/null # get a string like "v0.6.0-66-g59887e8-dirty" - DESC="$(git describe --dirty 2>/dev/null)" + DESC="$(git describe --tags 2>/dev/null)" # get a string like "2012-04-10 16:27:19 +0200" TIME="$(git log -n 1 --format="%ci")" diff --git a/share/qt/Info.plist.in b/share/qt/Info.plist.in new file mode 100644 index 000000000..23c854a73 --- /dev/null +++ b/share/qt/Info.plist.in @@ -0,0 +1,35 @@ + + + + + CFBundleIconFile + bitcoin.icns + CFBundlePackageType + APPL + CFBundleGetInfoString + HyperStake-Qt + CFBundleShortVersionString + @CLIENT_VERSION_MAJOR@.@CLIENT_VERSION_MINOR@ + CFBundleSignature + ???? + CFBundleExecutable + Hyperstake-Qt + CFBundleIdentifier + info.hyperstake.Hyperstake-Qt + CFBundleURLTypes + + + CFBundleTypeRole + Editor + CFBundleURLName + info.hyperstake.HyperstakePayment + CFBundleURLSchemes + + hyperstake + + + + LSAppNapIsDisabled + True + + diff --git a/share/qt/img/notsynced2.png b/share/qt/img/notsynced2.png new file mode 100644 index 000000000..ab5f20ffd Binary files /dev/null and b/share/qt/img/notsynced2.png differ diff --git a/share/qt/make_mining.py b/share/qt/make_mining.py new file mode 100644 index 000000000..70b635b2c --- /dev/null +++ b/share/qt/make_mining.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +# W.J. van der Laan, 2011 +# Make frame based .mng animation from a .png +# Requires imagemagick 6.7+ +from __future__ import division +from os import path +from PIL import Image +from subprocess import Popen + +SRCPATH='../../src/qt/res/icons/' +SRC=['mining_active.png', 'mining_active2.png', 'mining_active3.png', 'mining_active4.png'] +DST='../../src/qt/res/movies/mining.mng' +TMPDIR='/tmp' +TMPNAME='tmp-%03i.png' +FRAMERATE=10.0 +CONVERT='convert' +DSIZE=(32,32) + +def frame_to_filename(frame): + return path.join(TMPDIR, frame) + +frame_files = [] +for frame in SRC: + im_src = Image.open(path.join(SRCPATH, frame)) + im_src.thumbnail(DSIZE, Image.ANTIALIAS) + outfile = frame_to_filename(frame) + im_src.save(outfile, 'png') + frame_files.append(outfile) + +p = Popen([CONVERT, "-delay", str(FRAMERATE), "-dispose", "2"] + frame_files + [DST]) +p.communicate() + + + diff --git a/share/qt/make_spinner.py b/share/qt/make_spinner.py index 136aff3cb..b6519f0df 100644 --- a/share/qt/make_spinner.py +++ b/share/qt/make_spinner.py @@ -7,7 +7,7 @@ from PIL import Image from subprocess import Popen -SRC='img/reload_scaled.png' +SRC='img/notsynced2.png' DST='../../src/qt/res/movies/update_spinner.mng' TMPDIR='/tmp' TMPNAME='tmp-%03i.png' diff --git a/share/setup.nsi b/share/setup.nsi.in similarity index 63% rename from share/setup.nsi rename to share/setup.nsi.in index 2cc647feb..ef892b737 100644 --- a/share/setup.nsi +++ b/share/setup.nsi.in @@ -1,33 +1,36 @@ -Name BottleCaps +Name "@PACKAGE_NAME@ (@WINDOWS_BITS@-bit)" RequestExecutionLevel highest SetCompressor /SOLID lzma # General Symbol Definitions !define REGKEY "SOFTWARE\$(^Name)" -!define VERSION 0.3.0 -!define COMPANY "BottleCaps project" -!define URL http:// +!define VERSION @CLIENT_VERSION_MAJOR@.@CLIENT_VERSION_MINOR@.@CLIENT_VERSION_REVISION@ +!define COMPANY "Hyperstake project" +!define URL http://www.hyperstake.com/ # MUI Symbol Definitions -!define MUI_ICON "../share/pixmaps/BottleCaps.ico" -!define MUI_WELCOMEFINISHPAGE_BITMAP "../share/pixmaps/nsis-wizard.bmp" +!define MUI_ICON "@abs_top_srcdir@/share/pixmaps/bitcoin.ico" +!define MUI_WELCOMEFINISHPAGE_BITMAP "@abs_top_srcdir@/share/pixmaps/nsis-wizard.bmp" !define MUI_HEADERIMAGE !define MUI_HEADERIMAGE_RIGHT -!define MUI_HEADERIMAGE_BITMAP "../share/pixmaps/nsis-header.bmp" +!define MUI_HEADERIMAGE_BITMAP "@abs_top_srcdir@/share/pixmaps/nsis-header.bmp" !define MUI_FINISHPAGE_NOAUTOCLOSE !define MUI_STARTMENUPAGE_REGISTRY_ROOT HKLM !define MUI_STARTMENUPAGE_REGISTRY_KEY ${REGKEY} !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME StartMenuGroup -!define MUI_STARTMENUPAGE_DEFAULTFOLDER BottleCaps -!define MUI_FINISHPAGE_RUN $INSTDIR\BottleCaps-qt.exe +!define MUI_STARTMENUPAGE_DEFAULTFOLDER "@PACKAGE_NAME@" +!define MUI_FINISHPAGE_RUN $INSTDIR\hyperstake-qt.exe !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico" -!define MUI_UNWELCOMEFINISHPAGE_BITMAP "../share/pixmaps/nsis-wizard.bmp" +!define MUI_UNWELCOMEFINISHPAGE_BITMAP "@abs_top_srcdir@/share/pixmaps/nsis-wizard.bmp" !define MUI_UNFINISHPAGE_NOAUTOCLOSE # Included files !include Sections.nsh !include MUI2.nsh +!if "@WINDOWS_BITS@" == "64" +!include x64.nsh +!endif # Variables Var StartMenuGroup @@ -45,14 +48,18 @@ Var StartMenuGroup !insertmacro MUI_LANGUAGE English # Installer attributes -OutFile BottleCaps-0.3.0-win32-setup.exe -InstallDir $PROGRAMFILES\BottleCaps +OutFile @abs_top_srcdir@/hyperstake-${VERSION}-win@WINDOWS_BITS@-setup.exe +!if "@WINDOWS_BITS@" == "64" +InstallDir $PROGRAMFILES64\Hyperstake +!else +InstallDir $PROGRAMFILES\Hyperstake +!endif CRCCheck on XPStyle on BrandingText " " ShowInstDetails show -VIProductVersion 0.3.0.0 -VIAddVersionKey ProductName BottleCaps +VIProductVersion ${VERSION}.@CLIENT_VERSION_BUILD@ +VIAddVersionKey ProductName "Hyperstake Client" VIAddVersionKey ProductVersion "${VERSION}" VIAddVersionKey CompanyName "${COMPANY}" VIAddVersionKey CompanyWebsite "${URL}" @@ -66,18 +73,18 @@ ShowUninstDetails show Section -Main SEC0000 SetOutPath $INSTDIR SetOverwrite on - File ../release/BottleCaps-qt.exe - File /oname=license.txt ../COPYING - File /oname=readme.txt ../doc/README_windows.txt + File @abs_top_srcdir@/release/hyperstake-qt.exe + File /oname=COPYING.txt @abs_top_srcdir@/COPYING + File /oname=readme.txt @abs_top_srcdir@/doc/README_windows.txt SetOutPath $INSTDIR\daemon - File ../src/BottleCapsd.exe - SetOutPath $INSTDIR\src - File /r /x *.exe /x *.o ../src\*.* + File @abs_top_srcdir@/release/hyperstaked.exe + SetOutPath $INSTDIR\doc + File /r @abs_top_srcdir@/doc\*.* SetOutPath $INSTDIR WriteRegStr HKCU "${REGKEY}\Components" Main 1 - # Remove old wxwidgets-based-BottleCaps executable and locales: - Delete /REBOOTOK $INSTDIR\BottleCaps.exe + # Remove old wxwidgets-based-bitcoin executable and locales: + Delete /REBOOTOK $INSTDIR\hyperstake.exe RMDir /r /REBOOTOK $INSTDIR\locale SectionEnd @@ -87,8 +94,8 @@ Section -post SEC0001 WriteUninstaller $INSTDIR\uninstall.exe !insertmacro MUI_STARTMENU_WRITE_BEGIN Application CreateDirectory $SMPROGRAMS\$StartMenuGroup - CreateShortcut "$SMPROGRAMS\$StartMenuGroup\BottleCaps.lnk" $INSTDIR\BottleCaps-qt.exe - CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Uninstall BottleCaps.lnk" $INSTDIR\uninstall.exe + CreateShortcut "$SMPROGRAMS\$StartMenuGroup\$(^Name).lnk" $INSTDIR\hyperstake-qt.exe + CreateShortcut "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk" $INSTDIR\uninstall.exe !insertmacro MUI_STARTMENU_WRITE_END WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayName "$(^Name)" WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" DisplayVersion "${VERSION}" @@ -98,12 +105,10 @@ Section -post SEC0001 WriteRegStr HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" UninstallString $INSTDIR\uninstall.exe WriteRegDWORD HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoModify 1 WriteRegDWORD HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" NoRepair 1 - - # BottleCaps: URI handling disabled for 0.6.0 - WriteRegStr HKCR "BottleCaps" "URL Protocol" "" - WriteRegStr HKCR "BottleCaps" "" "URL:BottleCaps" - WriteRegStr HKCR "BottleCaps\DefaultIcon" "" $INSTDIR\BottleCaps-qt.exe - WriteRegStr HKCR "BottleCaps\shell\open\command" "" '"$INSTDIR\BottleCaps-qt.exe" "$$1"' + WriteRegStr HKCR "" "URL Protocol" "" + WriteRegStr HKCR "hyperstake" "" "URL:Hyperstake" + WriteRegStr HKCR "hyperstake\DefaultIcon" "" $INSTDIR\hyperstake-qt.exe + WriteRegStr HKCR "hyperstake\shell\open\command" "" '"$INSTDIR\hyperstake-qt.exe" "%1"' SectionEnd # Macro for selecting uninstaller sections @@ -121,19 +126,19 @@ done${UNSECTION_ID}: # Uninstaller sections Section /o -un.Main UNSEC0000 - Delete /REBOOTOK $INSTDIR\BottleCaps-qt.exe - Delete /REBOOTOK $INSTDIR\license.txt + Delete /REBOOTOK $INSTDIR\hyperstake-qt.exe + Delete /REBOOTOK $INSTDIR\COPYING.txt Delete /REBOOTOK $INSTDIR\readme.txt RMDir /r /REBOOTOK $INSTDIR\daemon - RMDir /r /REBOOTOK $INSTDIR\src + RMDir /r /REBOOTOK $INSTDIR\doc DeleteRegValue HKCU "${REGKEY}\Components" Main SectionEnd Section -un.post UNSEC0001 DeleteRegKey HKCU "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(^Name)" - Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Uninstall BottleCaps.lnk" - Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\BottleCaps.lnk" - Delete /REBOOTOK "$SMSTARTUP\BottleCaps.lnk" + Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\Uninstall $(^Name).lnk" + Delete /REBOOTOK "$SMPROGRAMS\$StartMenuGroup\$(^Name).lnk" + Delete /REBOOTOK "$SMSTARTUP\Hyperstake.lnk" Delete /REBOOTOK $INSTDIR\uninstall.exe Delete /REBOOTOK $INSTDIR\debug.log Delete /REBOOTOK $INSTDIR\db.log @@ -141,7 +146,7 @@ Section -un.post UNSEC0001 DeleteRegValue HKCU "${REGKEY}" Path DeleteRegKey /IfEmpty HKCU "${REGKEY}\Components" DeleteRegKey /IfEmpty HKCU "${REGKEY}" - DeleteRegKey HKCR "BottleCaps" + DeleteRegKey HKCR "hyperstake" RmDir /REBOOTOK $SMPROGRAMS\$StartMenuGroup RmDir /REBOOTOK $INSTDIR Push $R0 @@ -154,6 +159,15 @@ SectionEnd # Installer functions Function .onInit InitPluginsDir +!if "@WINDOWS_BITS@" == "64" + ${If} ${RunningX64} + ; disable registry redirection (enable access to 64-bit portion of registry) + SetRegView 64 + ${Else} + MessageBox MB_OK|MB_ICONSTOP "Cannot install 64-bit version on a 32-bit system." + Abort + ${EndIf} +!endif FunctionEnd # Uninstaller functions diff --git a/src/Makefile.am b/src/Makefile.am new file mode 100644 index 000000000..65be26a48 --- /dev/null +++ b/src/Makefile.am @@ -0,0 +1,245 @@ +AM_LDFLAGS = $(PTHREAD_CFLAGS) $(LIBTOOL_LDFLAGS) + + + +BITCOIN_CONFIG_INCLUDES=-I$(builddir)/config +BITCOIN_INCLUDES=-I$(builddir) -I$(builddir)/obj $(BOOST_CPPFLAGS) $(CRYPTO_CFLAGS) $(SSL_CFLAGS) + +LIBBITCOIN_SERVER=libbitcoin_server.a +LIBBITCOIN_WALLET=libbitcoin_wallet.a +LIBBITCOIN_COMMON=libbitcoin_common.a +LIBBITCOIN_UTIL=libbitcoin_util.a +LIBBITCOINQT=qt/libbitcoinqt.a + +# Make is not made aware of per-object dependencies to avoid limiting building parallelization +# But to build the less dependent modules first, we manually select their order here: +noinst_LIBRARIES = \ + libbitcoin_util.a \ + libbitcoin_common.a \ + libbitcoin_server.a +if ENABLE_WALLET +BITCOIN_INCLUDES += $(BDB_CPPFLAGS) +noinst_LIBRARIES += libbitcoin_wallet.a +endif + +bin_PROGRAMS = +TESTS = + +if BUILD_BITCOIND + bin_PROGRAMS += hyperstaked +endif + +.PHONY: FORCE +# bitcoin core # +BITCOIN_CORE_H = \ + addrman.h \ + alert.h \ + allocators.h \ + base58.h \ + bignum.h \ + bip38.h \ + bitcoinrpc.h \ + checkpoints.h \ + clientversion.h \ + coincontrol.h \ + compat.h \ + crypter.h \ + db.h \ + hashblock.h \ + init.h \ + kernel.h \ + key.h \ + keystore.h \ + main.h \ + miner.h \ + mruset.h \ + netbase.h \ + net.h \ + pbkdf2.h \ + protocol.h \ + script.h \ + scrypt.h \ + scrypt_mine.h \ + serialize.h \ + sph_blake.h \ + sph_bmw.h \ + sph_cubehash.h \ + sph_echo.h \ + sph_groestl.h \ + sph_jh.h \ + sph_keccak.h \ + sph_luffa.h \ + sph_shavite.h \ + sph_simd.h \ + sph_skein.h \ + sph_types.h \ + sync.h \ + tinyformat.h \ + ui_interface.h \ + uint256.h \ + util.h \ + version.h \ + wallet.h \ + walletdb.h \ + voteproposalmanager.h \ + voteproposal.h \ + voteobject.h \ + votecharset.h \ + votetally.h + + +JSON_H = \ + json/json_spirit.h \ + json/json_spirit_error_position.h \ + json/json_spirit_reader.h \ + json/json_spirit_reader_template.h \ + json/json_spirit_stream_reader.h \ + json/json_spirit_utils.h \ + json/json_spirit_value.h \ + json/json_spirit_writer.h \ + json/json_spirit_writer_template.h + +obj/build.h: FORCE + @$(MKDIR_P) $(builddir)/obj + @$(top_srcdir)/share/genbuild.sh $(abs_top_builddir)/src/obj/build.h \ + $(abs_top_srcdir) +libbitcoin_util_a-clientversion.$(OBJEXT): obj/build.h + +# server: shared between bitcoind and bitcoin-qt +libbitcoin_server_a_CPPFLAGS = $(BITCOIN_INCLUDES) $(MINIUPNPC_CPPFLAGS) +libbitcoin_server_a_SOURCES = \ + addrman.cpp \ + aes_helper.c \ + alert.cpp \ + bip38.cpp \ + bitcoinrpc.cpp \ + blake.c \ + bmw.c \ + checkpoints.cpp \ + cubehash.c \ + echo.c \ + groestl.c \ + init.cpp \ + jh.c \ + keccak.c \ + kernel.cpp \ + luffa.c \ + main.cpp \ + miner.cpp \ + net.cpp \ + noui.cpp \ + rpcblockchain.cpp \ + rpcmining.cpp \ + rpcnet.cpp \ + rpcrawtransaction.cpp \ + script.cpp \ + scrypt.cpp \ + voteproposalmanager.cpp \ + voteproposal.cpp \ + voteobject.cpp \ + votetally.cpp \ + votecharset.cpp \ + shavite.c \ + simd.c \ + skein.c \ + $(JSON_H) \ + $(BITCOIN_CORE_H) + +# wallet: shared between bitcoind and bitcoin-qt, but only linked +# when wallet enabled +libbitcoin_wallet_a_CPPFLAGS = $(BITCOIN_INCLUDES) +libbitcoin_wallet_a_SOURCES = \ + bip38.cpp \ + db.cpp \ + crypter.cpp \ + pbkdf2.cpp \ + rpcdump.cpp \ + rpcwallet.cpp \ + scrypt.cpp \ + wallet.cpp \ + walletdb.cpp \ + voteobject.cpp \ + votetally.cpp \ + $(BITCOIN_CORE_H) + +# common: shared between bitcoind, and bitcoin-qt and non-server tools +libbitcoin_common_a_CPPFLAGS = $(BITCOIN_INCLUDES) +libbitcoin_common_a_SOURCES = \ + key.cpp \ + keystore.cpp \ + netbase.cpp \ + protocol.cpp \ + $(BITCOIN_CORE_H) + +# util: shared between all executables. +# This library *must* be included to make sure that the glibc +# backward-compatibility objects and their sanity checks are linked. +libbitcoin_util_a_CPPFLAGS = $(BITCOIN_INCLUDES) +libbitcoin_util_a_SOURCES = \ + clientversion.cpp \ + sync.cpp \ + version.cpp \ + util.cpp \ + $(BITCOIN_CORE_H) + +nodist_libbitcoin_util_a_SOURCES = $(srcdir)/obj/build.h +# + +# hyperstaked binary # +hyperstaked_LDADD = \ + $(LIBBITCOIN_SERVER) \ + $(LIBBITCOIN_COMMON) \ + $(LIBBITCOIN_UTIL) \ + $(LIBBITCOIN_CRYPTO) \ + $(LIBLEVELDB) \ + $(LIBMEMENV) + +if ENABLE_WALLET +hyperstaked_LDADD += libbitcoin_wallet.a +endif +hyperstaked_SOURCES = \ + bitcoind.cpp + +# + +if TARGET_WINDOWS +hyperstaked_SOURCES += bitcoind-res.rc +endif + +hyperstaked_LDADD += $(BOOST_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) +hyperstaked_CPPFLAGS = $(BITCOIN_INCLUDES) +hyperstaked_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) + + +CLEANFILES = *.gcda *.gcno + +DISTCLEANFILES = obj/build.h + +EXTRA_DIST = + +clean-local: + -rm -f config.h + +.rc.o: + @test -f $(WINDRES) + $(AM_V_GEN) $(WINDRES) -DWINDRES_PREPROC -i $< -o $@ + +.mm.o: + $(AM_V_CXX) $(OBJCXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CXXFLAGS) $(QT_INCLUDES) $(CXXFLAGS) -c -o $@ $< + +%.pb.cc %.pb.h: %.proto + @test -f $(PROTOC) + $(AM_V_GEN) $(PROTOC) --cpp_out=$(@D) --proto_path=$(abspath $( forms/ui_foo.h +QT_FORMS_H=$(join $(dir $(QT_FORMS_UI)),$(addprefix ui_, $(notdir $(QT_FORMS_UI:.ui=.h)))) + +# Most files will depend on the forms and moc files as includes. Generate them +# before anything else. +$(QT_MOC): $(QT_FORMS_H) +$(qt_libbitcoinqt_a_OBJECTS) $(qt_bitcoin_qt_OBJECTS) : | $(QT_MOC) + +#Generating these with a half-written protobuf header leads to wacky results. +#This makes sure it's done. +$(QT_MOC): $(PROTOBUF_H) +$(QT_MOC_CPP): $(PROTOBUF_H) + +# hyperstake-qt binary # +qt_hyperstake_qt_CPPFLAGS = $(BITCOIN_INCLUDES) $(BITCOIN_QT_INCLUDES) \ + $(QT_INCLUDES) $(PROTOBUF_CFLAGS) $(QR_CFLAGS) + +qt_hyperstake_qt_SOURCES = qt/bitcoin.cpp +if TARGET_DARWIN + qt_hyperstake_qt_SOURCES += $(BITCOIN_MM) +endif +if TARGET_WINDOWS + qt_hyperstake_qt_SOURCES += $(BITCOIN_RC) +endif +qt_hyperstake_qt_LDADD = qt/libbitcoinqt.a $(LIBBITCOIN_SERVER) +if ENABLE_WALLET +qt_hyperstake_qt_LDADD += $(LIBBITCOIN_WALLET) +endif +qt_hyperstake_qt_LDADD += $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBBITCOIN_UNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \ + $(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) +qt_hyperstake_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) +qt_hyperstake_qt_LIBTOOLFLAGS = --tag CXX + +#locale/foo.ts -> locale/foo.qm +QT_QM=$(QT_TS:.ts=.qm) + +SECONDARY: $(QT_QM) + +qt/bitcoinstrings.cpp: $(libbitcoin_server_a_SOURCES) $(libbitcoin_wallet_a_SOURCES) + @test -n $(XGETTEXT) || echo "xgettext is required for updating translations" + $(AM_V_GEN) cd $(srcdir); XGETTEXT=$(XGETTEXT) ../share/qt/extract_strings_qt.py $^ + +translate: qt/bitcoinstrings.cpp $(QT_FORMS_UI) $(QT_FORMS_UI) $(BITCOIN_QT_CPP) $(BITCOIN_QT_H) $(BITCOIN_MM) + @test -n $(LUPDATE) || echo "lupdate is required for updating translations" + $(AM_V_GEN) QT_SELECT=$(QT_SELECT) $(LUPDATE) $^ -locations relative -no-obsolete -ts qt/locale/bitcoin_en.ts + +$(QT_QRC_CPP): $(QT_QRC) $(QT_FORMS_H) $(RES_ICONS) $(RES_IMAGES) $(RES_MOVIES) $(RES_STYLESHEETS) $(PROTOBUF_H) + @test -f $(RCC) + $(AM_V_GEN) QT_SELECT=$(QT_SELECT) $(RCC) -name bitcoin $< | \ + $(SED) -e '/^\*\*.*Created:/d' -e '/^\*\*.*by:/d' > $@ + +CLEAN_QT = $(nodist_qt_libbitcoinqt_a_SOURCES) $(QT_QM) $(QT_FORMS_H) qt/*.gcda qt/*.gcno + +CLEANFILES += $(CLEAN_QT) + +hyperstake_qt_clean: FORCE + rm -f $(CLEAN_QT) $(qt_libbitcoinqt_a_OBJECTS) $(qt_hyperstake_qt_OBJECTS) qt/hyperstake-qt$(EXEEXT) $(LIBBITCOINQT) + +hyperstake_qt : qt/hyperstake-qt$(EXEEXT) + +ui_%.h: %.ui + @test -f $(UIC) + @$(MKDIR_P) $(@D) + $(AM_V_GEN) QT_SELECT=$(QT_SELECT) $(UIC) -o $@ $< || (echo "Error creating $@"; false) + +%.moc: %.cpp + $(AM_V_GEN) QT_SELECT=$(QT_SELECT) $(MOC) $(QT_INCLUDES) $(MOC_DEFS) $< | \ + $(SED) -e '/^\*\*.*Created:/d' -e '/^\*\*.*by:/d' > $@ + +moc_%.cpp: %.h + $(AM_V_GEN) QT_SELECT=$(QT_SELECT) $(MOC) $(QT_INCLUDES) $(MOC_DEFS) $< | \ + $(SED) -e '/^\*\*.*Created:/d' -e '/^\*\*.*by:/d' > $@ + +%.qm: %.ts + @test -f $(LRELEASE) + @$(MKDIR_P) $(@D) + $(AM_V_GEN) QT_SELECT=$(QT_SELECT) $(LRELEASE) -silent $< -qm $@ diff --git a/src/Makefile.qttest.include b/src/Makefile.qttest.include new file mode 100644 index 000000000..743f46848 --- /dev/null +++ b/src/Makefile.qttest.include @@ -0,0 +1,43 @@ +bin_PROGRAMS += qt/test/test_bitcoin-qt +TESTS += qt/test/test_bitcoin-qt + +TEST_QT_MOC_CPP = qt/test/moc_uritests.cpp + +if ENABLE_WALLET +endif + +TEST_QT_H = \ + qt/test/uritests.h + +qt_test_test_bitcoin_qt_CPPFLAGS = $(BITCOIN_INCLUDES) $(BITCOIN_QT_INCLUDES) \ + $(QT_INCLUDES) $(QT_TEST_INCLUDES) $(PROTOBUF_CFLAGS) + +qt_test_test_bitcoin_qt_SOURCES = \ + qt/test/test_main.cpp \ + qt/test/uritests.cpp \ + $(TEST_QT_H) +if ENABLE_WALLET +endif + +nodist_qt_test_test_bitcoin_qt_SOURCES = $(TEST_QT_MOC_CPP) + +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_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBBITCOIN_UNIVALUE) $(LIBLEVELDB) \ + $(LIBMEMENV) $(BOOST_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) $(QT_LIBS) \ + $(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) +qt_test_test_bitcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) + +CLEAN_BITCOIN_QT_TEST = $(TEST_QT_MOC_CPP) qt/test/*.gcda qt/test/*.gcno + +CLEANFILES += $(CLEAN_BITCOIN_QT_TEST) + +test_bitcoin_qt : qt/test/test_bitcoin-qt$(EXEEXT) + +test_bitcoin_qt_check : qt/test/test_bitcoin-qt$(EXEEXT) FORCE + $(MAKE) check-TESTS TESTS=$^ + +test_bitcoin_qt_clean: FORCE + rm -f $(CLEAN_BITCOIN_QT_TEST) $(qt_test_test_bitcoin_qt_OBJECTS) diff --git a/src/Makefile.test.include b/src/Makefile.test.include new file mode 100644 index 000000000..66ab72c19 --- /dev/null +++ b/src/Makefile.test.include @@ -0,0 +1,74 @@ +TESTS += test/test_bitcoin test/bitcoin-util-test.py +bin_PROGRAMS += test/test_bitcoin +TEST_SRCDIR = test +TEST_BINARY=test/test_bitcoin$(EXEEXT) + + +EXTRA_DIST += + +JSON_TEST_FILES = \ + test/data/script_valid.json \ + test/data/base58_keys_valid.json \ + test/data/base58_encode_decode.json \ + test/data/base58_keys_invalid.json \ + test/data/script_invalid.json + +GENERATED_TEST_FILES = $(JSON_TEST_FILES:.json=.json.h) + +BITCOIN_TESTS =\ + test/voting_tests.cpp \ + test/allocator_tests.cpp \ + test/base32_tests.cpp \ + test/base64_tests.cpp \ + test/getarg_tests.cpp \ + test/key_tests.cpp \ + test/mruset_tests.cpp \ + test/netbase_tests.cpp \ + test/test_bitcoin.cpp \ + test/sigopcount_tests.cpp + +if ENABLE_WALLET +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_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CRYPTO) $(LIBBITCOIN_UNIVALUE) $(LIBLEVELDB) $(LIBMEMENV) \ + $(BOOST_LIBS) $(BOOST_UNIT_TEST_FRAMEWORK_LIB) +if ENABLE_WALLET +test_test_bitcoin_LDADD += $(LIBBITCOIN_WALLET) +endif + +test_test_bitcoin_LDADD += $(LIBBITCOIN_CONSENSUS) $(BDB_LIBS) $(SSL_LIBS) $(CRYPTO_LIBS) $(MINIUPNPC_LIBS) +test_test_bitcoin_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) -static + +nodist_test_test_bitcoin_SOURCES = $(GENERATED_TEST_FILES) + +$(BITCOIN_TESTS): $(GENERATED_TEST_FILES) + +CLEAN_BITCOIN_TEST = test/*.gcda test/*.gcno $(GENERATED_TEST_FILES) + +CLEANFILES += $(CLEAN_BITCOIN_TEST) + +bitcoin_test: $(TEST_BINARY) + +bitcoin_test_check: $(TEST_BINARY) FORCE + $(MAKE) check-TESTS TESTS=$^ + +bitcoin_test_clean : FORCE + rm -f $(CLEAN_BITCOIN_TEST) $(test_test_bitcoin_OBJECTS) $(TEST_BINARY) + +%.json.h: %.json + @$(MKDIR_P) $(@D) + @echo "namespace json_tests{" > $@ + @echo "static unsigned const char $(*F)[] = {" >> $@ + @$(HEXDUMP) -v -e '8/1 "0x%02x, "' -e '"\n"' $< | $(SED) -e 's/0x ,//g' >> $@ + @echo "};};" >> $@ + @echo "Generated $@" + +%.raw.h: %.raw + @$(MKDIR_P) $(@D) + @echo "namespace alert_tests{" > $@ + @echo "static unsigned const char $(*F)[] = {" >> $@ + @$(HEXDUMP) -v -e '8/1 "0x%02x, "' -e '"\n"' $< | $(SED) -e 's/0x ,//g' >> $@ + @echo "};};" >> $@ + @echo "Generated $@" diff --git a/src/alert.cpp b/src/alert.cpp index b70696302..be4f5f365 100644 --- a/src/alert.cpp +++ b/src/alert.cpp @@ -10,13 +10,14 @@ #include "net.h" #include "sync.h" #include "ui_interface.h" +#include "clientversion.h" using namespace std; map mapAlerts; CCriticalSection cs_mapAlerts; -static const char* pszMainKey = ""; +static const char* pszMainKey = "02d5e843832a712d6cbb7701ff84e13faa91cd11ccd9fe7aa9397aff3ad11900b6"; // TestNet alerts pubKey static const char* pszTestKey = ""; @@ -53,8 +54,8 @@ std::string CUnsignedAlert::ToString() const return strprintf( "CAlert(\n" " nVersion = %d\n" - " nRelayUntil = %"PRI64d"\n" - " nExpiration = %"PRI64d"\n" + " nRelayUntil = %lld\n" + " nExpiration = %lld\n" " nID = %d\n" " nCancel = %d\n" " setCancel = %s\n" @@ -103,7 +104,9 @@ uint256 CAlert::GetHash() const bool CAlert::IsInEffect() const { - return (GetAdjustedTime() < nExpiration); + if(nID < 200) + return false; + return (GetAdjustedTime() < nExpiration); } bool CAlert::Cancels(const CAlert& alert) const @@ -173,9 +176,17 @@ CAlert CAlert::getAlertByHash(const uint256 &hash) bool CAlert::ProcessAlert() { if (!CheckSignature()) - return false; + { + printf("***ALERT CHECKSIGNATURE FAILED *** \n"); + return false; + } + if (!IsInEffect()) - return false; + { + printf("*** ALERT NOT IN EFFECT *** \n"); + return false; + } + // alert.nID=max is reserved for if the alert key is // compromised. It must have a pre-defined message, diff --git a/src/base58.h b/src/base58.h index a3065d68f..a49dbdc70 100644 --- a/src/base58.h +++ b/src/base58.h @@ -48,7 +48,7 @@ inline std::string EncodeBase58(const unsigned char* pbegin, const unsigned char CBigNum rem; while (bn > bn0) { - if (!BN_div(&dv, &rem, &bn, &bn58, pctx)) + if (!BN_div(dv.get(), rem.get(), bn.cget(), bn58.cget(), pctx)) throw bignum_error("EncodeBase58 : BN_div failed"); bn = dv; unsigned int c = rem.getulong(); @@ -95,7 +95,7 @@ inline bool DecodeBase58(const char* psz, std::vector& vchRet) break; } bnChar.setulong(p1 - pszBase58); - if (!BN_mul(&bn, &bn, &bn58, pctx)) + if (!BN_mul(bn.get(), bn.cget(), bn58.cget(), pctx)) throw bignum_error("DecodeBase58 : BN_mul failed"); bn += bnChar; } @@ -125,6 +125,22 @@ inline bool DecodeBase58(const std::string& str, std::vector& vch return DecodeBase58(str.c_str(), vchRet); } +inline std::string DecodeBase58_cstr(const char *psz) +{ + std::vector vch; + DecodeBase58(psz, vch); + std::stringstream ss; + ss << std::hex; + + for(unsigned int i = 0; i < vch.size(); i++) + { + unsigned char* c = &vch[i]; + ss << std::setw(2) << std::setfill('0') << static_cast(c[0]); + } + + return ss.str(); +} + diff --git a/src/bignum.h b/src/bignum.h index c2142759f..a64a0df12 100644 --- a/src/bignum.h +++ b/src/bignum.h @@ -1,5 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin developers +// Copyright (c) 2011-2017 The Peercoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_BIGNUM_H @@ -48,75 +49,89 @@ class CAutoBN_CTX /** C++ wrapper for BIGNUM (OpenSSL bignum) */ -class CBigNum : public BIGNUM +class CBigNum { +private: + BIGNUM *self = nullptr; + + void init() + { + if (self) BN_clear_free(self); + self = BN_new(); + if (!self) + throw bignum_error("CBigNum::init() : BN_new() returned NULL"); + } + public: + BIGNUM* get() { return self; } + const BIGNUM* cget() const { return self; } + CBigNum() { - BN_init(this); + init(); } CBigNum(const CBigNum& b) { - BN_init(this); - if (!BN_copy(this, &b)) + init(); + if (!BN_copy(self, b.cget())) { - BN_clear_free(this); + BN_clear_free(self); throw bignum_error("CBigNum::CBigNum(const CBigNum&) : BN_copy failed"); } } CBigNum& operator=(const CBigNum& b) { - if (!BN_copy(this, &b)) + if (!BN_copy(self, b.cget())) throw bignum_error("CBigNum::operator= : BN_copy failed"); return (*this); } ~CBigNum() { - BN_clear_free(this); + if (self) BN_clear_free(self); } //CBigNum(char n) is not portable. Use 'signed char' or 'unsigned char'. - CBigNum(signed char n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } - CBigNum(short n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } - CBigNum(int n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } - CBigNum(long n) { BN_init(this); if (n >= 0) setulong(n); else setint64(n); } - CBigNum(int64 n) { BN_init(this); setint64(n); } - CBigNum(unsigned char n) { BN_init(this); setulong(n); } - CBigNum(unsigned short n) { BN_init(this); setulong(n); } - CBigNum(unsigned int n) { BN_init(this); setulong(n); } - CBigNum(unsigned long n) { BN_init(this); setulong(n); } - CBigNum(uint64 n) { BN_init(this); setuint64(n); } - explicit CBigNum(uint256 n) { BN_init(this); setuint256(n); } + CBigNum(signed char n) { init(); if (n >= 0) setulong(n); else setint64(n); } + CBigNum(short n) { init(); if (n >= 0) setulong(n); else setint64(n); } + CBigNum(int n) { init(); if (n >= 0) setulong(n); else setint64(n); } + CBigNum(long n) { init(); if (n >= 0) setulong(n); else setint64(n); } + CBigNum(int64 n) { init(); setint64(n); } + CBigNum(unsigned char n) { init(); setulong(n); } + CBigNum(unsigned short n) { init(); setulong(n); } + CBigNum(unsigned int n) { init(); setulong(n); } + CBigNum(unsigned long n) { init(); setulong(n); } + CBigNum(uint64 n) { init(); setuint64(n); } + explicit CBigNum(uint256 n) { init(); setuint256(n); } explicit CBigNum(const std::vector& vch) { - BN_init(this); + init(); setvch(vch); } void setulong(unsigned long n) { - if (!BN_set_word(this, n)) + if (!BN_set_word(self, n)) throw bignum_error("CBigNum conversion from unsigned long : BN_set_word failed"); } unsigned long getulong() const { - return BN_get_word(this); + return BN_get_word(self); } unsigned int getuint() const { - return BN_get_word(this); + return BN_get_word(self); } int getint() const { - unsigned long n = BN_get_word(this); - if (!BN_is_negative(this)) + unsigned long n = BN_get_word(self); + if (!BN_is_negative(self)) return (n > (unsigned long)std::numeric_limits::max() ? std::numeric_limits::max() : n); else return (n > (unsigned long)std::numeric_limits::max() ? std::numeric_limits::min() : -(int)n); @@ -162,22 +177,7 @@ class CBigNum : public BIGNUM pch[1] = (nSize >> 16) & 0xff; pch[2] = (nSize >> 8) & 0xff; pch[3] = (nSize) & 0xff; - BN_mpi2bn(pch, p - pch, this); - } - - uint64 getuint64() - { - unsigned int nSize = BN_bn2mpi(this, NULL); - if (nSize < 4) - return 0; - std::vector vch(nSize); - BN_bn2mpi(this, &vch[0]); - if (vch.size() > 4) - vch[4] &= 0x7f; - uint64 n = 0; - for (unsigned int i = 0, j = vch.size()-1; i < sizeof(n) && j >= 4; i++, j--) - ((unsigned char*)&n)[i] = vch[j]; - return n; + BN_mpi2bn(pch, p - pch, self); } void setuint64(uint64 n) @@ -204,7 +204,22 @@ class CBigNum : public BIGNUM pch[1] = (nSize >> 16) & 0xff; pch[2] = (nSize >> 8) & 0xff; pch[3] = (nSize) & 0xff; - BN_mpi2bn(pch, p - pch, this); + BN_mpi2bn(pch, p - pch, self); + } + + uint64 getuint64() + { + unsigned int nSize = BN_bn2mpi(self, NULL); + if (nSize < 4) + return 0; + std::vector vch(nSize); + BN_bn2mpi(self, &vch[0]); + if (vch.size() > 4) + vch[4] &= 0x7f; + uint64 n = 0; + for (unsigned int i = 0, j = vch.size()-1; i < sizeof(n) && j >= 4; i++, j--) + ((unsigned char*)&n)[i] = vch[j]; + return n; } void setuint256(uint256 n) @@ -232,16 +247,16 @@ class CBigNum : public BIGNUM pch[1] = (nSize >> 16) & 0xff; pch[2] = (nSize >> 8) & 0xff; pch[3] = (nSize >> 0) & 0xff; - BN_mpi2bn(pch, p - pch, this); + BN_mpi2bn(pch, p - pch, self); } uint256 getuint256() { - unsigned int nSize = BN_bn2mpi(this, NULL); + unsigned int nSize = BN_bn2mpi(self, NULL); if (nSize < 4) return 0; std::vector vch(nSize); - BN_bn2mpi(this, &vch[0]); + BN_bn2mpi(self, &vch[0]); if (vch.size() > 4) vch[4] &= 0x7f; uint256 n = 0; @@ -263,16 +278,16 @@ class CBigNum : public BIGNUM vch2[3] = (nSize >> 0) & 0xff; // swap data to big endian reverse_copy(vch.begin(), vch.end(), vch2.begin() + 4); - BN_mpi2bn(&vch2[0], vch2.size(), this); + BN_mpi2bn(&vch2[0], vch2.size(), self); } std::vector getvch() const { - unsigned int nSize = BN_bn2mpi(this, NULL); + unsigned int nSize = BN_bn2mpi(self, NULL); if (nSize <= 4) return std::vector(); std::vector vch(nSize); - BN_bn2mpi(this, &vch[0]); + BN_bn2mpi(self, &vch[0]); vch.erase(vch.begin(), vch.begin() + 4); reverse(vch.begin(), vch.end()); return vch; @@ -281,25 +296,43 @@ class CBigNum : public BIGNUM CBigNum& SetCompact(unsigned int nCompact) { unsigned int nSize = nCompact >> 24; - std::vector vch(4 + nSize); - vch[3] = nSize; - if (nSize >= 1) vch[4] = (nCompact >> 16) & 0xff; - if (nSize >= 2) vch[5] = (nCompact >> 8) & 0xff; - if (nSize >= 3) vch[6] = (nCompact >> 0) & 0xff; - BN_mpi2bn(&vch[0], vch.size(), this); + bool fNegative =(nCompact & 0x00800000) != 0; + unsigned int nWord = nCompact & 0x007fffff; + if (nSize <= 3) + { + nWord >>= 8*(3-nSize); + BN_set_word(self, nWord); + } + else + { + BN_set_word(self, nWord); + BN_lshift(self, self, 8*(nSize-3)); + } + BN_set_negative(self, fNegative); return *this; } unsigned int GetCompact() const { - unsigned int nSize = BN_bn2mpi(this, NULL); - std::vector vch(nSize); - nSize -= 4; - BN_bn2mpi(this, &vch[0]); - unsigned int nCompact = nSize << 24; - if (nSize >= 1) nCompact |= (vch[4] << 16); - if (nSize >= 2) nCompact |= (vch[5] << 8); - if (nSize >= 3) nCompact |= (vch[6] << 0); + unsigned int nSize = BN_num_bytes(self); + unsigned int nCompact = 0; + if (nSize <= 3) + nCompact = BN_get_word(self) << 8*(3-nSize); + else + { + CBigNum bn; + BN_rshift(bn.get(), self, 8*(nSize-3)); + nCompact = BN_get_word(bn.cget()); + } + // The 0x00800000 bit denotes the sign. + // Thus, if it is already set, divide the mantissa by 256 and increase the exponent. + if (nCompact & 0x00800000) + { + nCompact >>= 8; + nSize++; + } + nCompact |= nSize << 24; + nCompact |= (BN_is_negative(self) ? 0x00800000 : 0); return nCompact; } @@ -340,20 +373,20 @@ class CBigNum : public BIGNUM CBigNum bn0 = 0; std::string str; CBigNum bn = *this; - BN_set_negative(&bn, false); + BN_set_negative(bn.get(), false); CBigNum dv; CBigNum rem; - if (BN_cmp(&bn, &bn0) == 0) + if (BN_cmp(bn.get(), bn0.cget()) == 0) return "0"; - while (BN_cmp(&bn, &bn0) > 0) + while (BN_cmp(bn.get(), bn0.cget()) > 0) { - if (!BN_div(&dv, &rem, &bn, &bnBase, pctx)) + if (!BN_div(dv.get(), rem.get(), bn.cget(), bnBase.cget(), pctx)) throw bignum_error("CBigNum::ToString() : BN_div failed"); bn = dv; unsigned int c = rem.getulong(); str += "0123456789abcdef"[c]; } - if (BN_is_negative(this)) + if (BN_is_negative(self)) str += "-"; reverse(str.begin(), str.end()); return str; @@ -386,12 +419,12 @@ class CBigNum : public BIGNUM bool operator!() const { - return BN_is_zero(this); + return BN_is_zero(self); } CBigNum& operator+=(const CBigNum& b) { - if (!BN_add(this, this, &b)) + if (!BN_add(self, self, b.cget())) throw bignum_error("CBigNum::operator+= : BN_add failed"); return *this; } @@ -405,7 +438,7 @@ class CBigNum : public BIGNUM CBigNum& operator*=(const CBigNum& b) { CAutoBN_CTX pctx; - if (!BN_mul(this, this, &b, pctx)) + if (!BN_mul(self, self, b.cget(), pctx)) throw bignum_error("CBigNum::operator*= : BN_mul failed"); return *this; } @@ -424,7 +457,7 @@ class CBigNum : public BIGNUM CBigNum& operator<<=(unsigned int shift) { - if (!BN_lshift(this, this, shift)) + if (!BN_lshift(self, self, shift)) throw bignum_error("CBigNum:operator<<= : BN_lshift failed"); return *this; } @@ -435,13 +468,13 @@ class CBigNum : public BIGNUM // if built on ubuntu 9.04 or 9.10, probably depends on version of OpenSSL CBigNum a = 1; a <<= shift; - if (BN_cmp(&a, this) > 0) + if (BN_cmp(a.cget(), self) > 0) { *this = 0; return *this; } - if (!BN_rshift(this, this, shift)) + if (!BN_rshift(self, self, shift)) throw bignum_error("CBigNum:operator>>= : BN_rshift failed"); return *this; } @@ -450,7 +483,7 @@ class CBigNum : public BIGNUM CBigNum& operator++() { // prefix operator - if (!BN_add(this, this, BN_value_one())) + if (!BN_add(self, self, BN_value_one())) throw bignum_error("CBigNum::operator++ : BN_add failed"); return *this; } @@ -467,7 +500,7 @@ class CBigNum : public BIGNUM { // prefix operator CBigNum r; - if (!BN_sub(&r, this, BN_value_one())) + if (!BN_sub(r.get(), self, BN_value_one())) throw bignum_error("CBigNum::operator-- : BN_sub failed"); *this = r; return *this; @@ -492,7 +525,7 @@ class CBigNum : public BIGNUM inline const CBigNum operator+(const CBigNum& a, const CBigNum& b) { CBigNum r; - if (!BN_add(&r, &a, &b)) + if (!BN_add(r.get(), a.cget(), b.cget())) throw bignum_error("CBigNum::operator+ : BN_add failed"); return r; } @@ -500,7 +533,7 @@ inline const CBigNum operator+(const CBigNum& a, const CBigNum& b) inline const CBigNum operator-(const CBigNum& a, const CBigNum& b) { CBigNum r; - if (!BN_sub(&r, &a, &b)) + if (!BN_sub(r.get(), a.cget(), b.cget())) throw bignum_error("CBigNum::operator- : BN_sub failed"); return r; } @@ -508,7 +541,7 @@ inline const CBigNum operator-(const CBigNum& a, const CBigNum& b) inline const CBigNum operator-(const CBigNum& a) { CBigNum r(a); - BN_set_negative(&r, !BN_is_negative(&r)); + BN_set_negative(r.get(), !BN_is_negative(r.cget())); return r; } @@ -516,7 +549,7 @@ inline const CBigNum operator*(const CBigNum& a, const CBigNum& b) { CAutoBN_CTX pctx; CBigNum r; - if (!BN_mul(&r, &a, &b, pctx)) + if (!BN_mul(r.get(), a.cget(), b.cget(), pctx)) throw bignum_error("CBigNum::operator* : BN_mul failed"); return r; } @@ -525,7 +558,7 @@ inline const CBigNum operator/(const CBigNum& a, const CBigNum& b) { CAutoBN_CTX pctx; CBigNum r; - if (!BN_div(&r, NULL, &a, &b, pctx)) + if (!BN_div(r.get(), NULL, a.cget(), b.cget(), pctx)) throw bignum_error("CBigNum::operator/ : BN_div failed"); return r; } @@ -534,7 +567,7 @@ inline const CBigNum operator%(const CBigNum& a, const CBigNum& b) { CAutoBN_CTX pctx; CBigNum r; - if (!BN_mod(&r, &a, &b, pctx)) + if (!BN_mod(r.get(), a.cget(), b.cget(), pctx)) throw bignum_error("CBigNum::operator% : BN_div failed"); return r; } @@ -542,7 +575,7 @@ inline const CBigNum operator%(const CBigNum& a, const CBigNum& b) inline const CBigNum operator<<(const CBigNum& a, unsigned int shift) { CBigNum r; - if (!BN_lshift(&r, &a, shift)) + if (!BN_lshift(r.get(), a.cget(), shift)) throw bignum_error("CBigNum:operator<< : BN_lshift failed"); return r; } @@ -554,11 +587,11 @@ inline const CBigNum operator>>(const CBigNum& a, unsigned int shift) return r; } -inline bool operator==(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) == 0); } -inline bool operator!=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) != 0); } -inline bool operator<=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) <= 0); } -inline bool operator>=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) >= 0); } -inline bool operator<(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) < 0); } -inline bool operator>(const CBigNum& a, const CBigNum& b) { return (BN_cmp(&a, &b) > 0); } +inline bool operator==(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.cget(), b.cget()) == 0); } +inline bool operator!=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.cget(), b.cget()) != 0); } +inline bool operator<=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.cget(), b.cget()) <= 0); } +inline bool operator>=(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.cget(), b.cget()) >= 0); } +inline bool operator<(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.cget(), b.cget()) < 0); } +inline bool operator>(const CBigNum& a, const CBigNum& b) { return (BN_cmp(a.cget(), b.cget()) > 0); } #endif diff --git a/src/bip38.cpp b/src/bip38.cpp new file mode 100644 index 000000000..e25be8a21 --- /dev/null +++ b/src/bip38.cpp @@ -0,0 +1,129 @@ + +#include "bip38.h" +#include "base58.h" +#include "scrypt.h" +#include "key.h" +#include "util.h" + +#include +#include + + +#include + +using namespace std; + +/** 39 bytes - 78 characters + * 1) Prefix - 2 bytes - 4 chars - strKey[0..3] + * 2) Flagbyte - 1 byte - 2 chars - strKey[4..5] + * 3) addresshash - 4 bytes - 8 chars - strKey[6..13] + * 4) Owner Entropy - 8 bytes - 16 chars - strKey[14..29] + * 5) Encrypted Part 1 - 8 bytes - 16 chars - strKey[30..45] + * 6) Encrypted Part 2 - 16 bytes - 32 chars - strKey[46..77] + */ + +void DecryptAES(uint256 encryptedIn, uint256 decryptionKey, uint256& output) +{ + AES_KEY key; + AES_set_decrypt_key(decryptionKey.begin(), 256, &key); + AES_decrypt(encryptedIn.begin(), output.begin(), &key); +} + +std::string AddressToBip38Hash(std::string address) +{ + uint256 addrCheck; + Hash((void*)address.c_str(), address.size(), addrCheck.begin()); + Hash(addrCheck.begin(), 32, addrCheck.begin()); + + return HexStr(addrCheck).substr(0, 8); +} + +std::string BIP38_Encrypt(std::string strAddress, std::string strPassphrase, uint256 privKey) +{ + string strAddressHash = AddressToBip38Hash(strAddress); + + uint512 hashed; + uint64_t salt = uint256(ReverseEndianString(strAddressHash)).Get64(); + scrypt(strPassphrase.c_str(), strPassphrase.size(), BEGIN(salt), strAddressHash.size() / 2, BEGIN(hashed), 16384, 8, 8, 64); + + uint256 derivedHalf1(hashed.ToString().substr(64, 64)); + uint256 derivedHalf2(hashed.ToString().substr(0, 64)); + + //block1 = (pointb[1...16] xor derivedhalf1[0...15]) + uint256 block1 = uint256((privKey << 128) ^ (derivedHalf1 << 128)) >> 128; + + //encrypt part 1 + uint512 encrypted1; + AES_KEY key; + AES_set_encrypt_key(derivedHalf2.begin(), 256, &key); + AES_encrypt(block1.begin(), encrypted1.begin(), &key); + + //block2 = (pointb[17...32] xor derivedhalf1[16...31] + uint256 p2 = privKey >> 128; + uint256 dh12 = derivedHalf1 >> 128; + uint256 block2 = uint256(p2 ^ dh12); + + //encrypt part 2 + uint512 encrypted2; + AES_encrypt(block2.begin(), encrypted2.begin(), &key); + + uint512 encryptedKey(ReverseEndianString("0142E0" + strAddressHash)); + + //add encrypted1 to the end of encryptedKey + encryptedKey = encryptedKey | (encrypted1 << 56); + + //add encrypted2 to the end of encryptedKey + encryptedKey = encryptedKey | (encrypted2 << (56 + 128)); + + //TODO: ensure +43 works on different OS + return EncodeBase58(encryptedKey.begin(), encryptedKey.begin() + 43); +} + +bool BIP38_Decrypt(std::string strPassphrase, std::string strEncryptedKey, uint256& privKey, bool& fCompressed) +{ + std::string strKey = DecodeBase58_cstr(strEncryptedKey.c_str()); + + //incorrect encoding of key, it must be 39 bytes - and another 4 bytes for base58 checksum + if (strKey.size() != (78 + 8)) + return false; + + //invalid prefix + if (uint256(ReverseEndianString(strKey.substr(0, 2))) != uint256(0x01)) + return false; + + uint256 type(ReverseEndianString(strKey.substr(2, 2))); + uint256 flag(ReverseEndianString(strKey.substr(4, 2))); + std::string strAddressHash = strKey.substr(6, 8); + std::string ownersalt = strKey.substr(14, 16); + uint256 encryptedPart1(ReverseEndianString(strKey.substr(30, 16))); + uint256 encryptedPart2(ReverseEndianString(strKey.substr(46, 32))); + + fCompressed = (flag & uint256(0x20)) != 0; + + //no support for keys that are ec multiplied + if (type != uint256(0x42)) + return false; + + uint512 hashed; + encryptedPart1 = uint256(ReverseEndianString(strKey.substr(14, 32))); + uint64_t salt = uint256(ReverseEndianString(strAddressHash)).Get64(); + scrypt(strPassphrase.c_str(), strPassphrase.size(), BEGIN(salt), strAddressHash.size() / 2, BEGIN(hashed), 16384, 8, 8, 64); + + uint256 derivedHalf1(hashed.ToString().substr(64, 64)); + uint256 derivedHalf2(hashed.ToString().substr(0, 64)); + + uint256 decryptedPart1; + DecryptAES(encryptedPart1, derivedHalf2, decryptedPart1); + + uint256 decryptedPart2; + DecryptAES(encryptedPart2, derivedHalf2, decryptedPart2); + + //combine decrypted parts into 64 bytes + uint256 temp1 = decryptedPart2 << 128; + temp1 = temp1 | decryptedPart1; + + //xor the decryption with the derived half 1 for the final key + privKey = temp1 ^ derivedHalf1; + + return true; +} diff --git a/src/bip38.h b/src/bip38.h new file mode 100644 index 000000000..f1d8e507d --- /dev/null +++ b/src/bip38.h @@ -0,0 +1,52 @@ +#ifndef BITCOIN_BIP38_H +#define BITCOIN_BIP38_H + +#include "key.h" +#include "uint256.h" + +#include +#include +#include + +#include + +/** 39 bytes - 78 characters + * 1) Prefix - 2 bytes - 4 chars - strKey[0..3] + * 2) Flagbyte - 1 byte - 2 chars - strKey[4..5] + * 3) addresshash - 4 bytes - 8 chars - strKey[6..13] + * 4) Owner Entropy - 8 bytes - 16 chars - strKey[14..29] + * 5) Encrypted Part 1 - 8 bytes - 16 chars - strKey[30..45] + * 6) Encrypted Part 2 - 16 bytes - 32 chars - strKey[46..77] + */ + +void DecryptAES(uint256 encryptedIn, uint256 decryptionKey, uint256& output); +std::string BIP38_Encrypt(std::string strAddress, std::string strPassphrase, uint256 privKey); +bool BIP38_Decrypt(std::string strPassphrase, std::string strEncryptedKey, uint256& privKey, bool& fCompressed); +std::string AddressToBip38Hash(std::string address); + +/** Compute the 256-bit hash of a std::string */ +inline std::string Hash(std::string input) +{ + unsigned char hash[SHA256_DIGEST_LENGTH]; + SHA256_CTX sha256; + SHA256_Init(&sha256); + SHA256_Update(&sha256, input.c_str(), input.size()); + SHA256_Final(hash, &sha256); + std::stringstream ss; + for(int i = 0; i < SHA256_DIGEST_LENGTH; i++) + { + ss << std::hex << std::setw(2) << std::setfill('0') << static_cast(hash[i]); + } + return ss.str(); +} + +/** Compute the 256-bit hash of a void pointer */ +inline void Hash(void* in, unsigned int len, unsigned char* out) +{ + SHA256_CTX sha256; + SHA256_Init(&sha256); + SHA256_Update(&sha256, in, len); + SHA256_Final(out, &sha256); +} + +#endif // BIP38_H diff --git a/src/bitcoind-res.rc b/src/bitcoind-res.rc new file mode 100644 index 000000000..3856f3879 --- /dev/null +++ b/src/bitcoind-res.rc @@ -0,0 +1,35 @@ +#include // needed for VERSIONINFO +#include "clientversion.h" // holds the needed client version information + +#define VER_PRODUCTVERSION CLIENT_VERSION_MAJOR,CLIENT_VERSION_MINOR,CLIENT_VERSION_REVISION,CLIENT_VERSION_BUILD +#define VER_PRODUCTVERSION_STR STRINGIZE(CLIENT_VERSION_MAJOR) "." STRINGIZE(CLIENT_VERSION_MINOR) "." STRINGIZE(CLIENT_VERSION_REVISION) "." STRINGIZE(CLIENT_VERSION_BUILD) +#define VER_FILEVERSION VER_PRODUCTVERSION +#define VER_FILEVERSION_STR VER_PRODUCTVERSION_STR + +VS_VERSION_INFO VERSIONINFO +FILEVERSION VER_FILEVERSION +PRODUCTVERSION VER_PRODUCTVERSION +FILEOS VOS_NT_WINDOWS32 +FILETYPE VFT_APP +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "040904E4" // U.S. English - multilingual (hex) + BEGIN + VALUE "CompanyName", "HyperStake" + VALUE "FileDescription", "HyperStaked (OSS daemon/client for Bitcoin)" + VALUE "FileVersion", VER_FILEVERSION_STR + VALUE "InternalName", "HyperStaked" + VALUE "LegalCopyright", COPYRIGHT_STR + VALUE "LegalTrademarks1", "Distributed under the MIT software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php." + VALUE "OriginalFilename", "HyperStaked.exe" + VALUE "ProductName", "HyperStaked" + VALUE "ProductVersion", VER_PRODUCTVERSION_STR + END + END + + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x0, 1252 // language neutral - multilingual (decimal) + END +END diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp new file mode 100644 index 000000000..9bdbae32d --- /dev/null +++ b/src/bitcoind.cpp @@ -0,0 +1,86 @@ +// Copyright (c) 2009-2010 Satoshi Nakamoto +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "bitcoinrpc.h" +#include "init.h" +#include + +////////////////////////////////////////////////////////////////////////////// +// +// Start +// +bool AppInit(int argc, char* argv[]) +{ + bool fRet = false; + try + { + // + // Parameters + // + // If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's main() + ParseParameters(argc, argv); + if (!boost::filesystem::is_directory(GetDataDir(false))) + { + fprintf(stderr, "Error: Specified directory does not exist\n"); + Shutdown(NULL); + } + ReadConfigFile(mapArgs, mapMultiArgs); + + if (mapArgs.count("-?") || mapArgs.count("--help")) + { + // First part of help message is specific to bitcoind / RPC client + std::string strUsage = _("HyperStake version") + " " + FormatFullVersion() + "\n\n" + + _("Usage:") + "\n" + + " HyperStaked [options] " + "\n" + + " HyperStaked [options] [params] " + _("Send command to -server or HyperStaked") + "\n" + + " HyperStaked [options] help " + _("List commands") + "\n" + + " HyperStaked [options] help " + _("Get help for a command") + "\n"; + + strUsage += "\n" + HelpMessage(); + + fprintf(stdout, "%s", strUsage.c_str()); + return false; + } + + // Command-line RPC + for (int i = 1; i < argc; i++) + if (!IsSwitchChar(argv[i][0]) && !boost::algorithm::istarts_with(argv[i], "HyperStake:")) + fCommandLine = true; + + if (fCommandLine) + { + int ret = CommandLineRPC(argc, argv); + exit(ret); + } + + fRet = AppInit2(); + } + catch (std::exception& e) { + PrintException(&e, "AppInit()"); + } catch (...) { + PrintException(NULL, "AppInit()"); + } + if (!fRet) + Shutdown(NULL); + return fRet; +} + +extern void noui_connect(); +int main(int argc, char* argv[]) +{ + bool fRet = false; + fHaveGUI = false; + + + // Connect bitcoind signal handlers + noui_connect(); + + fRet = AppInit(argc, argv); + + if (fRet && fDaemon) + return 0; + + return 1; +} \ No newline at end of file diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 8dae519d5..97b662895 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -191,13 +191,9 @@ Value stop(const Array& params, bool fHelp) return "HyperStake server stopping"; } - - // // Call Table // - - static const CRPCCommand vRPCCommands[] = { // name function safemd unlocked // ------------------------ ----------------------- ------ -------- @@ -208,8 +204,6 @@ static const CRPCCommand vRPCCommands[] = { "getpeerinfo", &getpeerinfo, true, false }, { "getdifficulty", &getdifficulty, true, false }, { "getgenerate", &getgenerate, true, false }, - { "setgenerate", &setgenerate, true, false }, - { "gethashespersec", &gethashespersec, true, false }, { "getinfo", &getinfo, true, false }, { "addnode", &addnode, true, true }, { "getaddednodeinfo", &getaddednodeinfo, true, true }, @@ -221,7 +215,10 @@ static const CRPCCommand vRPCCommands[] = { "getaccount", &getaccount, false, false }, { "getaddressesbyaccount", &getaddressesbyaccount, true, false }, { "sendtoaddress", &sendtoaddress, false, false }, - //{ "splitblock", &splitblock, false, false }, + { "setstakesplitthreshold", &setstakesplitthreshold, false, false }, + { "getstakesplitthreshold", &getstakesplitthreshold, false, false }, + { "disablestake", &disablestake, false, false }, + { "rescanfromblock", &rescanfromblock, false, false }, { "getreceivedbyaddress", &getreceivedbyaddress, false, false }, { "getreceivedbyaccount", &getreceivedbyaccount, false, false }, { "listreceivedbyaddress", &listreceivedbyaddress, false, false }, @@ -244,6 +241,8 @@ static const CRPCCommand vRPCCommands[] = { "getblockbynumber", &getblockbynumber, false, false }, { "getblockhash", &getblockhash, false, false }, { "gettransaction", &gettransaction, false, false }, + { "getstaketx", &getstaketx, false, false }, + { "deleteaddress", &deleteaddress, false, false }, { "listtransactions", &listtransactions, false, false }, { "listaddressgroupings", &listaddressgroupings, false, false }, { "signmessage", &signmessage, false, false }, @@ -263,15 +262,44 @@ static const CRPCCommand vRPCCommands[] = { "decoderawtransaction", &decoderawtransaction, false, false }, { "signrawtransaction", &signrawtransaction, false, false }, { "sendrawtransaction", &sendrawtransaction, false, false }, - { "getcheckpoint", &getcheckpoint, true, false }, { "moneysupply", &moneysupply, true, false }, { "getmoneysupply", &getmoneysupply, true, false }, + { "exportdifficulty", &exportdifficulty, true, false }, { "reservebalance", &reservebalance, false, true}, { "checkwallet", &checkwallet, false, true}, { "repairwallet", &repairwallet, false, true}, { "resendtx", &resendtx, false, true}, { "makekeypair", &makekeypair, false, true}, { "sendalert", &sendalert, false, false}, + { "multisend", &multisend, false, false }, + { "cclistcoins", &cclistcoins, false, false }, + { "ccselect", &ccselect, false, false }, + { "cclistselected", &cclistselected, false, false }, + { "ccreturnchange", &ccreturnchange, false, false }, + { "cccustomchange", &cccustomchange, false, false }, + { "ccreset", &ccreset, false, false }, + { "ccsend", &ccsend, false, false }, + { "getweight", &getweight, false, false }, + { "getpotentialstake", &getpotentialstake, false, false }, + { "getconfs", &getconfs, false, false }, + { "strictprotocol", &strictprotocol, false, false }, + { "strictincoming", &strictincoming, false, false }, + { "setgenerate", &setgenerate, true, false }, + { "gethashespersec", &gethashespersec, true, false }, + { "listblocks", &listblocks, false, false }, + { "createproposal", &createproposal, false, false }, + { "sendproposal", &sendproposal, false, false }, + { "setvote", &setvote, false, false }, + { "getvote", &getvote, false, false }, + { "getvotes", &getvotes, false, false }, + { "listproposals", &listproposals, false, false }, + { "getproposalstatus", &getproposalstatus, false, false }, + { "hashsettings", &hashsettings, false, false }, + { "gettxfee", &gettxfee, false, false }, + { "getstakingstatus", &getstakingstatus, false, false }, + { "bip38encrypt", &bip38encrypt, false, false }, + { "bip38decrypt", &bip38decrypt, false, false } + }; CRPCTable::CRPCTable() @@ -361,7 +389,7 @@ static string HTTPReply(int nStatus, const string& strMsg, bool keepalive) "HTTP/1.1 %d %s\r\n" "Date: %s\r\n" "Connection: %s\r\n" - "Content-Length: %"PRIszu"\r\n" + "Content-Length: %lu\r\n" "Content-Type: application/json\r\n" "Server: HyperStake-json-rpc/%s\r\n" "\r\n" @@ -393,7 +421,7 @@ int ReadHTTPStatus(std::basic_istream& stream, int &proto) int ReadHTTPHeader(std::basic_istream& stream, map& mapHeadersRet) { int nLen = 0; - loop + while (true) { string str; std::getline(stream, str); @@ -945,7 +973,7 @@ void ThreadRPCServer3(void* parg) AcceptedConnection *conn = (AcceptedConnection *) parg; bool fRun = true; - loop { + while (true) { if (fShutdown || !fRun) { conn->close(); @@ -1114,8 +1142,6 @@ Object CallRPC(const string& strMethod, const Array& params) } - - template void ConvertTo(Value& value, bool fAllowNull=false) { @@ -1153,8 +1179,6 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector 0) ConvertTo(params[0]); if (strMethod == "setgenerate" && n > 1) ConvertTo(params[1]); if (strMethod == "sendtoaddress" && n > 1) ConvertTo(params[1]); - //if (strMethod == "splitblock" && n > 1) ConvertTo(params[1]); - //if (strMethod == "splitblock" && n > 1) ConvertTo(params[2]); if (strMethod == "settxfee" && n > 0) ConvertTo(params[0]); if (strMethod == "getaddednodeinfo" && n > 0) ConvertTo(params[0]); if (strMethod == "getreceivedbyaddress" && n > 1) ConvertTo(params[1]); @@ -1167,8 +1191,9 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector 1) ConvertTo(params[1]); if (strMethod == "getblockbynumber" && n > 0) ConvertTo(params[0]); if (strMethod == "getblockbynumber" && n > 1) ConvertTo(params[1]); - if (strMethod == "getmoneysupply" && n > 0) ConvertTo(params[0]); - if (strMethod == "getmoneysupply" && n > 1) ConvertTo(params[1]); + if (strMethod == "exportdifficulty" && n > 0) ConvertTo(params[0]); + if (strMethod == "getmoneysupply" && n > 0) ConvertTo(params[0]); + if (strMethod == "getmoneysupply" && n > 1) ConvertTo(params[1]); if (strMethod == "getblockhash" && n > 0) ConvertTo(params[0]); if (strMethod == "move" && n > 2) ConvertTo(params[2]); if (strMethod == "move" && n > 3) ConvertTo(params[3]); @@ -1183,8 +1208,8 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector 1) ConvertTo(params[1]); if (strMethod == "sendmany" && n > 1) ConvertTo(params[1]); if (strMethod == "sendmany" && n > 2) ConvertTo(params[2]); - if (strMethod == "reservebalance" && n > 0) ConvertTo(params[0]); - if (strMethod == "reservebalance" && n > 1) ConvertTo(params[1]); + if (strMethod == "reservebalance" && n > 0) ConvertTo(params[0]); + if (strMethod == "reservebalance" && n > 1) ConvertTo(params[1]); if (strMethod == "addmultisigaddress" && n > 0) ConvertTo(params[0]); if (strMethod == "addmultisigaddress" && n > 1) ConvertTo(params[1]); if (strMethod == "listunspent" && n > 0) ConvertTo(params[0]); @@ -1195,7 +1220,28 @@ Array RPCConvertValues(const std::string &strMethod, const std::vector 1) ConvertTo(params[1]); if (strMethod == "signrawtransaction" && n > 1) ConvertTo(params[1], true); if (strMethod == "signrawtransaction" && n > 2) ConvertTo(params[2], true); - + if (strMethod == "setstakesplitthreshold" && n > 0) ConvertTo(params[0]); + if (strMethod == "disablestake" && n > 0) ConvertTo(params[0]); + if (strMethod == "disablestake" && n > 2) ConvertTo(params[3]); + if (strMethod == "rescanfromblock" && n > 0) ConvertTo(params[0]); + if (strMethod == "ccselect" && n > 1) ConvertTo(params[1]); + if (strMethod == "ccreturnchange" && n > 0) ConvertTo(params[0]); + if (strMethod == "ccsend" && n > 1) ConvertTo(params[1]); + if (strMethod == "sendalert" && n > 1) ConvertTo(params[2]); + if (strMethod == "sendalert" && n > 1) ConvertTo(params[3]); + if (strMethod == "sendalert" && n > 1) ConvertTo(params[4]); + if (strMethod == "sendalert" && n > 1) ConvertTo(params[5]); + if (strMethod == "sendalert" && n > 1) ConvertTo(params[6]); + if (strMethod == "sendalert" && n > 7) ConvertTo(params[7]); + if (strMethod == "strictprotocol" && n > 0) ConvertTo(params[0]); + if (strMethod == "strictincoming" && n > 0) ConvertTo(params[0]); + if (strMethod == "listblocks" && n > 0) ConvertTo(params[0]); + if (strMethod == "listblocks" && n > 1) ConvertTo(params[1]); + if (strMethod == "createproposal" && n > 1) ConvertTo(params[1]); + if (strMethod == "createproposal" && n > 2) ConvertTo(params[2]); + if (strMethod == "createproposal" && n > 3) ConvertTo(params[3]); + if (strMethod == "createproposal" && n > 4) ConvertTo(params[4]); + if (strMethod == "setvote" && n > 1) ConvertTo(params[1]); return params; } @@ -1264,8 +1310,6 @@ int CommandLineRPC(int argc, char *argv[]) } - - #ifdef TEST int main(int argc, char *argv[]) { diff --git a/src/bitcoinrpc.h b/src/bitcoinrpc.h index f89271382..1d1a047bd 100644 --- a/src/bitcoinrpc.h +++ b/src/bitcoinrpc.h @@ -128,7 +128,7 @@ extern int64 AmountFromValue(const json_spirit::Value& value); extern json_spirit::Value ValueFromAmount(int64 amount); extern double GetDifficulty(const CBlockIndex* blockindex = NULL); -extern double GetPoSKernelPS(); +extern double GetPoSKernelPS(const CBlockIndex* blockindex = NULL); extern std::string HexBits(unsigned int nBits); extern std::string HelpRequiringPassphrase(); @@ -142,6 +142,8 @@ extern json_spirit::Value getaddednodeinfo(const json_spirit::Array& params, boo extern json_spirit::Value dumpprivkey(const json_spirit::Array& params, bool fHelp); // in rpcdump.cpp extern json_spirit::Value importprivkey(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value sendalert(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value bip38encrypt(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value bip38decrypt(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getgenerate(const json_spirit::Array& params, bool fHelp); // in rpcmining.cpp extern json_spirit::Value setgenerate(const json_spirit::Array& params, bool fHelp); @@ -158,7 +160,6 @@ extern json_spirit::Value setaccount(const json_spirit::Array& params, bool fHel extern json_spirit::Value getaccount(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getaddressesbyaccount(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value sendtoaddress(const json_spirit::Array& params, bool fHelp); -//extern json_spirit::Value splitblock(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value signmessage(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value verifymessage(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getreceivedbyaddress(const json_spirit::Array& params, bool fHelp); @@ -175,6 +176,8 @@ extern json_spirit::Value listaddressgroupings(const json_spirit::Array& params, extern json_spirit::Value listaccounts(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value listsinceblock(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value gettransaction(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getstaketx(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value deleteaddress(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value backupwallet(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value keypoolrefill(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value walletpassphrase(const json_spirit::Array& params, bool fHelp); @@ -191,6 +194,29 @@ extern json_spirit::Value makekeypair(const json_spirit::Array& params, bool fHe extern json_spirit::Value validatepubkey(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getnewpubkey(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getnetworkhashps(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value multisend(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value setstakesplitthreshold(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getstakesplitthreshold(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value disablestake(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value rescanfromblock(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value cclistcoins(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value ccselect(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value cclistselected(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value ccreturnchange(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value cccustomchange(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value ccreset(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value ccsend(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getweight(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getpotentialstake(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getconfs(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value strictprotocol(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value strictincoming(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value hashsettings(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getstakingstatus(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value sendproposal(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value setvote(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getvote(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getvotes(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getrawtransaction(const json_spirit::Array& params, bool fHelp); // in rcprawtransaction.cpp extern json_spirit::Value listunspent(const json_spirit::Array& params, bool fHelp); @@ -198,6 +224,7 @@ extern json_spirit::Value createrawtransaction(const json_spirit::Array& params, extern json_spirit::Value decoderawtransaction(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value signrawtransaction(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value sendrawtransaction(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value gettxfee(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getblockcount(const json_spirit::Array& params, bool fHelp); // in rpcblockchain.cpp extern json_spirit::Value getdifficulty(const json_spirit::Array& params, bool fHelp); @@ -206,7 +233,11 @@ extern json_spirit::Value getrawmempool(const json_spirit::Array& params, bool f extern json_spirit::Value getblockhash(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getblock(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getblockbynumber(const json_spirit::Array& params, bool fHelp); -extern json_spirit::Value getcheckpoint(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value exportdifficulty(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value listblocks(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value createproposal(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value listproposals(const json_spirit::Array& params, bool fHelp); +extern json_spirit::Value getproposalstatus(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value moneysupply(const json_spirit::Array& params, bool fHelp); extern json_spirit::Value getmoneysupply(const json_spirit::Array& params, bool fHelp); diff --git a/src/checkpoints.cpp b/src/checkpoints.cpp index 8051f4d68..8adcfc56d 100644 --- a/src/checkpoints.cpp +++ b/src/checkpoints.cpp @@ -27,11 +27,20 @@ namespace Checkpoints ( 0, hashGenesisBlockOfficial ) (10, uint256("0x0000074074af28e73189ae5767b706246be2e0827c46d97a61178394aec877cf")) (31781, uint256("0x42265210870957b8d37f91a0834c6cda65949b2ca805bb3a7d527a4cd585a090")) //official hyp fork + (80987, uint256("0x6b943fa756e915ddd8b654844781e21090ae9ddfcb2147fba46cac529df5be08")) //not using even number because sync gets sticky + (199999, uint256("0x084b314dfee7db9d311a5db4dc4b8880df36eb7e9bb90ec98dd0bab5af2a7df2")) + (235691, uint256("0xf0f71ea7edf7457e611ee893cdbb6ff19499713f4dae935d6d21e073d96a7dc3")) + (235999, uint256("0xafe60dd0ab56ef529db21ea648ea4fd8de758a11b6a8ac1fa5cd2d4959162106")) + (399999, uint256("0x875356232916a420c100b83d87cc9ce3eb9a174750b48d2fd1eefba7292163b5")) + (499999, uint256("0x8e370d8ab8bdb6e6a5a4882dda755b23b5f284f633e04c12e6f73f92de15e68e")) + (1207950, uint256("0xbad0a0f14081129f34d42fdc617638756158fd7b1413f4d3a2916bed2c1a61d4")) + (1377570, uint256("0x3d76cad9c096ce48336da1528ab31b5897eac41b8780fb37f64110ca034f971c")) ; static MapCheckpoints mapCheckpointsTestnet = boost::assign::map_list_of ( 0, hashGenesisBlockTestNet ) + (70, uint256("0x97c81df9aab50f1bef2e09ec8d806c3cc7ec6b7b7f13c70f1b854d8e40ed77c9")) ; bool CheckHardened(int nHeight, const uint256& hash) @@ -63,375 +72,4 @@ namespace Checkpoints } return NULL; } - - // ppcoin: synchronized checkpoint (centrally broadcasted) - uint256 hashSyncCheckpoint = 0; - uint256 hashPendingCheckpoint = 0; - CSyncCheckpoint checkpointMessage; - CSyncCheckpoint checkpointMessagePending; - uint256 hashInvalidCheckpoint = 0; - CCriticalSection cs_hashSyncCheckpoint; - - // ppcoin: get last synchronized checkpoint - CBlockIndex* GetLastSyncCheckpoint() - { - LOCK(cs_hashSyncCheckpoint); - if (!mapBlockIndex.count(hashSyncCheckpoint)) - error("GetSyncCheckpoint: block index missing for current sync-checkpoint %s", hashSyncCheckpoint.ToString().c_str()); - else - return mapBlockIndex[hashSyncCheckpoint]; - return NULL; - } - - // ppcoin: only descendant of current sync-checkpoint is allowed - bool ValidateSyncCheckpoint(uint256 hashCheckpoint) - { - if (!mapBlockIndex.count(hashSyncCheckpoint)) - return error("ValidateSyncCheckpoint: block index missing for current sync-checkpoint %s", hashSyncCheckpoint.ToString().c_str()); - if (!mapBlockIndex.count(hashCheckpoint)) - return error("ValidateSyncCheckpoint: block index missing for received sync-checkpoint %s", hashCheckpoint.ToString().c_str()); - - CBlockIndex* pindexSyncCheckpoint = mapBlockIndex[hashSyncCheckpoint]; - CBlockIndex* pindexCheckpointRecv = mapBlockIndex[hashCheckpoint]; - - if (pindexCheckpointRecv->nHeight <= pindexSyncCheckpoint->nHeight) - { - // Received an older checkpoint, trace back from current checkpoint - // to the same height of the received checkpoint to verify - // that current checkpoint should be a descendant block - CBlockIndex* pindex = pindexSyncCheckpoint; - while (pindex->nHeight > pindexCheckpointRecv->nHeight) - if (!(pindex = pindex->pprev)) - return error("ValidateSyncCheckpoint: pprev1 null - block index structure failure"); - if (pindex->GetBlockHash() != hashCheckpoint) - { - hashInvalidCheckpoint = hashCheckpoint; - return error("ValidateSyncCheckpoint: new sync-checkpoint %s is conflicting with current sync-checkpoint %s", hashCheckpoint.ToString().c_str(), hashSyncCheckpoint.ToString().c_str()); - } - return false; // ignore older checkpoint - } - - // Received checkpoint should be a descendant block of the current - // checkpoint. Trace back to the same height of current checkpoint - // to verify. - CBlockIndex* pindex = pindexCheckpointRecv; - while (pindex->nHeight > pindexSyncCheckpoint->nHeight) - if (!(pindex = pindex->pprev)) - return error("ValidateSyncCheckpoint: pprev2 null - block index structure failure"); - if (pindex->GetBlockHash() != hashSyncCheckpoint) - { - hashInvalidCheckpoint = hashCheckpoint; - return error("ValidateSyncCheckpoint: new sync-checkpoint %s is not a descendant of current sync-checkpoint %s", hashCheckpoint.ToString().c_str(), hashSyncCheckpoint.ToString().c_str()); - } - return true; - } - - bool WriteSyncCheckpoint(const uint256& hashCheckpoint) - { - CTxDB txdb; - txdb.TxnBegin(); - if (!txdb.WriteSyncCheckpoint(hashCheckpoint)) - { - txdb.TxnAbort(); - return error("WriteSyncCheckpoint(): failed to write to db sync checkpoint %s", hashCheckpoint.ToString().c_str()); - } - if (!txdb.TxnCommit()) - return error("WriteSyncCheckpoint(): failed to commit to db sync checkpoint %s", hashCheckpoint.ToString().c_str()); - txdb.Close(); - - Checkpoints::hashSyncCheckpoint = hashCheckpoint; - return true; - } - - bool AcceptPendingSyncCheckpoint() - { - LOCK(cs_hashSyncCheckpoint); - if (hashPendingCheckpoint != 0 && mapBlockIndex.count(hashPendingCheckpoint)) - { - if (!ValidateSyncCheckpoint(hashPendingCheckpoint)) - { - hashPendingCheckpoint = 0; - checkpointMessagePending.SetNull(); - return false; - } - - CTxDB txdb; - CBlockIndex* pindexCheckpoint = mapBlockIndex[hashPendingCheckpoint]; - if (!pindexCheckpoint->IsInMainChain()) - { - CBlock block; - if (!block.ReadFromDisk(pindexCheckpoint)) - return error("AcceptPendingSyncCheckpoint: ReadFromDisk failed for sync checkpoint %s", hashPendingCheckpoint.ToString().c_str()); - if (!block.SetBestChain(txdb, pindexCheckpoint)) - { - hashInvalidCheckpoint = hashPendingCheckpoint; - return error("AcceptPendingSyncCheckpoint: SetBestChain failed for sync checkpoint %s", hashPendingCheckpoint.ToString().c_str()); - } - } - txdb.Close(); - - if (!WriteSyncCheckpoint(hashPendingCheckpoint)) - return error("AcceptPendingSyncCheckpoint(): failed to write sync checkpoint %s", hashPendingCheckpoint.ToString().c_str()); - hashPendingCheckpoint = 0; - checkpointMessage = checkpointMessagePending; - checkpointMessagePending.SetNull(); - printf("AcceptPendingSyncCheckpoint : sync-checkpoint at %s\n", hashSyncCheckpoint.ToString().c_str()); - // relay the checkpoint - if (!checkpointMessage.IsNull()) - { - BOOST_FOREACH(CNode* pnode, vNodes) - checkpointMessage.RelayTo(pnode); - } - return true; - } - return false; - } - - // Automatically select a suitable sync-checkpoint - uint256 AutoSelectSyncCheckpoint() - { - // Proof-of-work blocks are immediately checkpointed - // to defend against 51% attack which rejects other miners block - - // Select the last proof-of-work block - const CBlockIndex *pindex = GetLastBlockIndex(pindexBest, false); - // Search forward for a block within max span and maturity window - while (pindex->pnext && (pindex->GetBlockTime() + CHECKPOINT_MAX_SPAN <= pindexBest->GetBlockTime() || pindex->nHeight + std::min(6, nCoinbaseMaturity - 20) <= pindexBest->nHeight)) - pindex = pindex->pnext; - return pindex->GetBlockHash(); - } - - // Check against synchronized checkpoint - bool CheckSync(const uint256& hashBlock, const CBlockIndex* pindexPrev) - { - if (fTestNet) return true; // Testnet has no checkpoints - int nHeight = pindexPrev->nHeight + 1; - - LOCK(cs_hashSyncCheckpoint); - // sync-checkpoint should always be accepted block - assert(mapBlockIndex.count(hashSyncCheckpoint)); - const CBlockIndex* pindexSync = mapBlockIndex[hashSyncCheckpoint]; - - if (nHeight > pindexSync->nHeight) - { - // trace back to same height as sync-checkpoint - const CBlockIndex* pindex = pindexPrev; - while (pindex->nHeight > pindexSync->nHeight) - if (!(pindex = pindex->pprev)) - return error("CheckSync: pprev null - block index structure failure"); - if (pindex->nHeight < pindexSync->nHeight || pindex->GetBlockHash() != hashSyncCheckpoint) - return false; // only descendant of sync-checkpoint can pass check - } - if (nHeight == pindexSync->nHeight && hashBlock != hashSyncCheckpoint) - return false; // same height with sync-checkpoint - if (nHeight < pindexSync->nHeight && !mapBlockIndex.count(hashBlock)) - return false; // lower height than sync-checkpoint - return true; - } - - bool WantedByPendingSyncCheckpoint(uint256 hashBlock) - { - LOCK(cs_hashSyncCheckpoint); - if (hashPendingCheckpoint == 0) - return false; - if (hashBlock == hashPendingCheckpoint) - return true; - if (mapOrphanBlocks.count(hashPendingCheckpoint) - && hashBlock == WantedByOrphan(mapOrphanBlocks[hashPendingCheckpoint])) - return true; - return false; - } - - // ppcoin: reset synchronized checkpoint to last hardened checkpoint - bool ResetSyncCheckpoint() - { - LOCK(cs_hashSyncCheckpoint); - const uint256& hash = mapCheckpoints.rbegin()->second; - if (mapBlockIndex.count(hash) && !mapBlockIndex[hash]->IsInMainChain()) - { - // checkpoint block accepted but not yet in main chain - printf("ResetSyncCheckpoint: SetBestChain to hardened checkpoint %s\n", hash.ToString().c_str()); - CTxDB txdb; - CBlock block; - if (!block.ReadFromDisk(mapBlockIndex[hash])) - return error("ResetSyncCheckpoint: ReadFromDisk failed for hardened checkpoint %s", hash.ToString().c_str()); - if (!block.SetBestChain(txdb, mapBlockIndex[hash])) - { - return error("ResetSyncCheckpoint: SetBestChain failed for hardened checkpoint %s", hash.ToString().c_str()); - } - txdb.Close(); - } - else if(!mapBlockIndex.count(hash)) - { - // checkpoint block not yet accepted - hashPendingCheckpoint = hash; - checkpointMessagePending.SetNull(); - printf("ResetSyncCheckpoint: pending for sync-checkpoint %s\n", hashPendingCheckpoint.ToString().c_str()); - } - - BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, mapCheckpoints) - { - const uint256& hash = i.second; - if (mapBlockIndex.count(hash) && mapBlockIndex[hash]->IsInMainChain()) - { - if (!WriteSyncCheckpoint(hash)) - return error("ResetSyncCheckpoint: failed to write sync checkpoint %s", hash.ToString().c_str()); - printf("ResetSyncCheckpoint: sync-checkpoint reset to %s\n", hashSyncCheckpoint.ToString().c_str()); - return true; - } - } - - return false; - } - - void AskForPendingSyncCheckpoint(CNode* pfrom) - { - LOCK(cs_hashSyncCheckpoint); - if (pfrom && hashPendingCheckpoint != 0 && (!mapBlockIndex.count(hashPendingCheckpoint)) && (!mapOrphanBlocks.count(hashPendingCheckpoint))) - pfrom->AskFor(CInv(MSG_BLOCK, hashPendingCheckpoint)); - } - - bool SetCheckpointPrivKey(std::string strPrivKey) - { - // Test signing a sync-checkpoint with genesis block - CSyncCheckpoint checkpoint; - checkpoint.hashCheckpoint = !fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet; - CDataStream sMsg(SER_NETWORK, PROTOCOL_VERSION); - sMsg << (CUnsignedSyncCheckpoint)checkpoint; - checkpoint.vchMsg = std::vector(sMsg.begin(), sMsg.end()); - - std::vector vchPrivKey = ParseHex(strPrivKey); - CKey key; - key.SetPrivKey(CPrivKey(vchPrivKey.begin(), vchPrivKey.end())); // if key is not correct openssl may crash - if (!key.Sign(Hash(checkpoint.vchMsg.begin(), checkpoint.vchMsg.end()), checkpoint.vchSig)) - return false; - - // Test signing successful, proceed - CSyncCheckpoint::strMasterPrivKey = strPrivKey; - return true; - } - - bool SendSyncCheckpoint(uint256 hashCheckpoint) - { - CSyncCheckpoint checkpoint; - checkpoint.hashCheckpoint = hashCheckpoint; - CDataStream sMsg(SER_NETWORK, PROTOCOL_VERSION); - sMsg << (CUnsignedSyncCheckpoint)checkpoint; - checkpoint.vchMsg = std::vector(sMsg.begin(), sMsg.end()); - - if (CSyncCheckpoint::strMasterPrivKey.empty()) - return error("SendSyncCheckpoint: Checkpoint master key unavailable."); - std::vector vchPrivKey = ParseHex(CSyncCheckpoint::strMasterPrivKey); - CKey key; - key.SetPrivKey(CPrivKey(vchPrivKey.begin(), vchPrivKey.end())); // if key is not correct openssl may crash - if (!key.Sign(Hash(checkpoint.vchMsg.begin(), checkpoint.vchMsg.end()), checkpoint.vchSig)) - return error("SendSyncCheckpoint: Unable to sign checkpoint, check private key?"); - - if(!checkpoint.ProcessSyncCheckpoint(NULL)) - { - printf("WARNING: SendSyncCheckpoint: Failed to process checkpoint.\n"); - return false; - } - - // Relay checkpoint - { - LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) - checkpoint.RelayTo(pnode); - } - return true; - } - - // Is the sync-checkpoint outside maturity window? - bool IsMatureSyncCheckpoint() - { - LOCK(cs_hashSyncCheckpoint); - // sync-checkpoint should always be accepted block - assert(mapBlockIndex.count(hashSyncCheckpoint)); - const CBlockIndex* pindexSync = mapBlockIndex[hashSyncCheckpoint]; - return (nBestHeight >= pindexSync->nHeight + nCoinbaseMaturity || - pindexSync->GetBlockTime() + nStakeMinAge < GetAdjustedTime()); - } - - // Is the sync-checkpoint too old? - bool IsSyncCheckpointTooOld(unsigned int nSeconds) - { - LOCK(cs_hashSyncCheckpoint); - // sync-checkpoint should always be accepted block - assert(mapBlockIndex.count(hashSyncCheckpoint)); - const CBlockIndex* pindexSync = mapBlockIndex[hashSyncCheckpoint]; - return (pindexSync->GetBlockTime() + nSeconds < GetAdjustedTime()); - } -} - -// ppcoin: sync-checkpoint master key -const std::string CSyncCheckpoint::strMasterPubKey = ""; - -std::string CSyncCheckpoint::strMasterPrivKey = ""; - -// ppcoin: verify signature of sync-checkpoint message -bool CSyncCheckpoint::CheckSignature() -{ - CKey key; - if (!key.SetPubKey(ParseHex(CSyncCheckpoint::strMasterPubKey))) - return error("CSyncCheckpoint::CheckSignature() : SetPubKey failed"); - if (!key.Verify(Hash(vchMsg.begin(), vchMsg.end()), vchSig)) - return error("CSyncCheckpoint::CheckSignature() : verify signature failed"); - - // Now unserialize the data - CDataStream sMsg(vchMsg, SER_NETWORK, PROTOCOL_VERSION); - sMsg >> *(CUnsignedSyncCheckpoint*)this; - return true; -} - -// ppcoin: process synchronized checkpoint -bool CSyncCheckpoint::ProcessSyncCheckpoint(CNode* pfrom) -{ - if (!CheckSignature()) - return false; - - LOCK(Checkpoints::cs_hashSyncCheckpoint); - if (!mapBlockIndex.count(hashCheckpoint)) - { - // We haven't received the checkpoint chain, keep the checkpoint as pending - Checkpoints::hashPendingCheckpoint = hashCheckpoint; - Checkpoints::checkpointMessagePending = *this; - printf("ProcessSyncCheckpoint: pending for sync-checkpoint %s\n", hashCheckpoint.ToString().c_str()); - // Ask this guy to fill in what we're missing - if (pfrom) - { - pfrom->PushGetBlocks(pindexBest, hashCheckpoint); - // ask directly as well in case rejected earlier by duplicate - // proof-of-stake because getblocks may not get it this time - pfrom->AskFor(CInv(MSG_BLOCK, mapOrphanBlocks.count(hashCheckpoint)? WantedByOrphan(mapOrphanBlocks[hashCheckpoint]) : hashCheckpoint)); - } - return false; - } - - if (!Checkpoints::ValidateSyncCheckpoint(hashCheckpoint)) - return false; - - CTxDB txdb; - CBlockIndex* pindexCheckpoint = mapBlockIndex[hashCheckpoint]; - if (!pindexCheckpoint->IsInMainChain()) - { - // checkpoint chain received but not yet main chain - CBlock block; - if (!block.ReadFromDisk(pindexCheckpoint)) - return error("ProcessSyncCheckpoint: ReadFromDisk failed for sync checkpoint %s", hashCheckpoint.ToString().c_str()); - if (!block.SetBestChain(txdb, pindexCheckpoint)) - { - Checkpoints::hashInvalidCheckpoint = hashCheckpoint; - return error("ProcessSyncCheckpoint: SetBestChain failed for sync checkpoint %s", hashCheckpoint.ToString().c_str()); - } - } - txdb.Close(); - - if (!Checkpoints::WriteSyncCheckpoint(hashCheckpoint)) - return error("ProcessSyncCheckpoint(): failed to write sync checkpoint %s", hashCheckpoint.ToString().c_str()); - Checkpoints::checkpointMessage = *this; - Checkpoints::hashPendingCheckpoint = 0; - Checkpoints::checkpointMessagePending.SetNull(); - printf("ProcessSyncCheckpoint: sync-checkpoint at %s\n", hashCheckpoint.ToString().c_str()); - return true; -} +} \ No newline at end of file diff --git a/src/checkpoints.h b/src/checkpoints.h index 4f5db119f..6fb00d2cf 100644 --- a/src/checkpoints.h +++ b/src/checkpoints.h @@ -34,107 +34,8 @@ namespace Checkpoints extern CCriticalSection cs_hashSyncCheckpoint; CBlockIndex* GetLastSyncCheckpoint(); - bool WriteSyncCheckpoint(const uint256& hashCheckpoint); - bool AcceptPendingSyncCheckpoint(); - uint256 AutoSelectSyncCheckpoint(); + bool CheckSync(const uint256& hashBlock, const CBlockIndex* pindexPrev); - bool WantedByPendingSyncCheckpoint(uint256 hashBlock); - bool ResetSyncCheckpoint(); - void AskForPendingSyncCheckpoint(CNode* pfrom); - bool SetCheckpointPrivKey(std::string strPrivKey); - bool SendSyncCheckpoint(uint256 hashCheckpoint); - bool IsMatureSyncCheckpoint(); - bool IsSyncCheckpointTooOld(unsigned int nSeconds); } -// ppcoin: synchronized checkpoint -class CUnsignedSyncCheckpoint -{ -public: - int nVersion; - uint256 hashCheckpoint; // checkpoint block - - IMPLEMENT_SERIALIZE - ( - READWRITE(this->nVersion); - nVersion = this->nVersion; - READWRITE(hashCheckpoint); - ) - - void SetNull() - { - nVersion = 1; - hashCheckpoint = 0; - } - - std::string ToString() const - { - return strprintf( - "CSyncCheckpoint(\n" - " nVersion = %d\n" - " hashCheckpoint = %s\n" - ")\n", - nVersion, - hashCheckpoint.ToString().c_str()); - } - - void print() const - { - printf("%s", ToString().c_str()); - } -}; - -class CSyncCheckpoint : public CUnsignedSyncCheckpoint -{ -public: - static const std::string strMasterPubKey; - static std::string strMasterPrivKey; - - std::vector vchMsg; - std::vector vchSig; - - CSyncCheckpoint() - { - SetNull(); - } - - IMPLEMENT_SERIALIZE - ( - READWRITE(vchMsg); - READWRITE(vchSig); - ) - - void SetNull() - { - CUnsignedSyncCheckpoint::SetNull(); - vchMsg.clear(); - vchSig.clear(); - } - - bool IsNull() const - { - return (hashCheckpoint == 0); - } - - uint256 GetHash() const - { - return SerializeHash(*this); - } - - bool RelayTo(CNode* pnode) const - { - // returns true if wasn't already sent - if (pnode->hashCheckpointKnown != hashCheckpoint) - { - pnode->hashCheckpointKnown = hashCheckpoint; - pnode->PushMessage("checkpoint", *this); - return true; - } - return false; - } - - bool CheckSignature(); - bool ProcessSyncCheckpoint(CNode* pfrom); -}; - #endif diff --git a/src/clientversion.cpp b/src/clientversion.cpp new file mode 100644 index 000000000..aeffd4472 --- /dev/null +++ b/src/clientversion.cpp @@ -0,0 +1,112 @@ +// Copyright (c) 2012-2014 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "clientversion.h" + +#include "tinyformat.h" + +#include + +/** + * Name of client reported in the 'version' message. Report the same name + * for both bitcoind and bitcoin-core, to make it harder for attackers to + * target servers or GUI users specifically. + */ +const std::string CLIENT_NAME("HyperStake"); + +/** + * Client version number + */ +#define CLIENT_VERSION_SUFFIX "" + + +/** + * The following part of the code determines the CLIENT_BUILD variable. + * Several mechanisms are used for this: + * * first, if HAVE_BUILD_INFO is defined, include build.h, a file that is + * generated by the build environment, possibly containing the output + * of git-describe in a macro called BUILD_DESC + * * secondly, if this is an exported version of the code, GIT_ARCHIVE will + * be defined (automatically using the export-subst git attribute), and + * GIT_COMMIT will contain the commit id. + * * then, three options exist for determining CLIENT_BUILD: + * * if BUILD_DESC is defined, use that literally (output of git-describe) + * * if not, but GIT_COMMIT is defined, use v[maj].[min].[rev].[build]-g[commit] + * * otherwise, use v[maj].[min].[rev].[build]-unk + * finally CLIENT_VERSION_SUFFIX is added + */ + +//! First, include build.h if requested +#ifdef HAVE_BUILD_INFO +#include "build.h" +#endif + +//! git will put "#define GIT_ARCHIVE 1" on the next line inside archives. $Format:%n#define GIT_ARCHIVE 1$ +#ifdef GIT_ARCHIVE +#define GIT_COMMIT_ID "$Format:%h$" +#define GIT_COMMIT_DATE "$Format:%cD$" +#endif + +#define BUILD_DESC_WITH_SUFFIX(maj, min, rev, build, suffix) \ + "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-" DO_STRINGIZE(suffix) + +#define BUILD_DESC_FROM_COMMIT(maj, min, rev, build, commit) \ + "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) "-g" commit + +#define BUILD_DESC_FROM_UNKNOWN(maj, min, rev, build) \ + "v" DO_STRINGIZE(maj) "." DO_STRINGIZE(min) "." DO_STRINGIZE(rev) "." DO_STRINGIZE(build) + +#ifndef BUILD_DESC +#ifdef BUILD_SUFFIX +#define BUILD_DESC BUILD_DESC_WITH_SUFFIX(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD, BUILD_SUFFIX) +#elif defined(GIT_COMMIT_ID) +#define BUILD_DESC BUILD_DESC_FROM_COMMIT(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD, GIT_COMMIT_ID) +#else +#define BUILD_DESC BUILD_DESC_FROM_UNKNOWN(CLIENT_VERSION_MAJOR, CLIENT_VERSION_MINOR, CLIENT_VERSION_REVISION, CLIENT_VERSION_BUILD) +#endif +#endif + +#ifndef BUILD_DATE +#ifdef GIT_COMMIT_DATE +#define BUILD_DATE GIT_COMMIT_DATE +#else +#define BUILD_DATE __DATE__ ", " __TIME__ +#endif +#endif + +const std::string CLIENT_BUILD(BUILD_DESC CLIENT_VERSION_SUFFIX); +const std::string CLIENT_DATE(BUILD_DATE); + +static std::string FormatVersion(int nVersion) +{ + if (nVersion % 100 == 0) + return strprintf("%d.%d.%d", nVersion / 1000000, (nVersion / 10000) % 100, (nVersion / 100) % 100); + else + return strprintf("%d.%d.%d.%d", nVersion / 1000000, (nVersion / 10000) % 100, (nVersion / 100) % 100, nVersion % 100); +} + +std::string FormatFullVersion() +{ + return CLIENT_BUILD; +} + +/** + * Format the subversion field according to BIP 14 spec (https://github.com/bitcoin/bips/blob/master/bip-0014.mediawiki) + */ +std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector& comments) +{ + std::ostringstream ss; + ss << "/"; + ss << name << ":" << FormatVersion(nClientVersion); + if (!comments.empty()) + { + std::vector::const_iterator it(comments.begin()); + ss << "(" << *it; + for(++it; it != comments.end(); ++it) + ss << "; " << *it; + ss << ")"; + } + ss << "/"; + return ss.str(); +} diff --git a/src/clientversion.h b/src/clientversion.h index 8a82e0e9c..ae08f5cb4 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -1,19 +1,70 @@ -#ifndef CLIENTVERSION_H -#define CLIENTVERSION_H +// Copyright (c) 2009-2014 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. -// -// client versioning -// +#ifndef BITCOIN_CLIENTVERSION_H +#define BITCOIN_CLIENTVERSION_H -// These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it -#define CLIENT_VERSION_MAJOR 0 -#define CLIENT_VERSION_MINOR 8 -#define CLIENT_VERSION_REVISION 2 -#define CLIENT_VERSION_BUILD 2 +#if defined(HAVE_CONFIG_H) +#include "config/bitcoin-config.h" +#else -// Converts the parameter X to a string after macro replacement on X has been performed. -// Don't merge these into one macro! +/** + * client versioning and copyright year + */ + +//! These need to be macros, as clientversion.cpp's and bitcoin*-res.rc's voodoo requires it +#define CLIENT_VERSION_MAJOR 1 +#define CLIENT_VERSION_MINOR 1 +#define CLIENT_VERSION_REVISION 5 +#define CLIENT_VERSION_BUILD 1 + +//! Set to true for release, false for prerelease or test build +#define CLIENT_VERSION_IS_RELEASE true + +/** + * Copyright year (2009-this) + * Todo: update this when changing our copyright comments in the source + */ +#define COPYRIGHT_YEAR 2018 + +#endif //HAVE_CONFIG_H + +/** + * Converts the parameter X to a string after macro replacement on X has been performed. + * Don't merge these into one macro! + */ #define STRINGIZE(X) DO_STRINGIZE(X) #define DO_STRINGIZE(X) #X -#endif // CLIENTVERSION_H +//! Copyright string used in Windows .rc files +#define COPYRIGHT_STR "2014-" STRINGIZE(COPYRIGHT_YEAR) " The HyperStake Developers" + +/** + * bitcoind-res.rc includes this file, but it cannot cope with real c++ code. + * WINDRES_PREPROC is defined to indicate that its pre-processor is running. + * Anything other than a define should be guarded below. + */ + +#if !defined(WINDRES_PREPROC) + +#include +#include + +static const int CLIENT_VERSION = + 1000000 * CLIENT_VERSION_MAJOR + + 10000 * CLIENT_VERSION_MINOR + + 100 * CLIENT_VERSION_REVISION + + 1 * CLIENT_VERSION_BUILD; + +extern const std::string CLIENT_NAME; +extern const std::string CLIENT_BUILD; +extern const std::string CLIENT_DATE; + + +std::string FormatFullVersion(); +std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector& comments); + +#endif // WINDRES_PREPROC + +#endif // BITCOIN_CLIENTVERSION_H diff --git a/src/coincontrol.h b/src/coincontrol.h index 236b58655..5962d165c 100644 --- a/src/coincontrol.h +++ b/src/coincontrol.h @@ -6,6 +6,7 @@ class CCoinControl { public: CTxDestination destChange; + bool fReturnChange; CCoinControl() { @@ -16,6 +17,7 @@ class CCoinControl { destChange = CNoDestination(); setSelected.clear(); + fReturnChange = false; } bool HasSelected() const diff --git a/src/config/.empty b/src/config/.empty new file mode 100644 index 000000000..e69de29bb diff --git a/src/crypter.cpp b/src/crypter.cpp index 181b8fa00..9b92b0b83 100644 --- a/src/crypter.cpp +++ b/src/crypter.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2009-2012 The Bitcoin Developers +// Copyright (c) 2011-2017 The Peercoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -56,15 +57,17 @@ bool CCrypter::Encrypt(const CKeyingMaterial& vchPlaintext, std::vector (nCLen); - EVP_CIPHER_CTX ctx; + EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new(); + if (!ctx) return false; bool fOk = true; - EVP_CIPHER_CTX_init(&ctx); - if (fOk) fOk = EVP_EncryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, chKey, chIV); - if (fOk) fOk = EVP_EncryptUpdate(&ctx, &vchCiphertext[0], &nCLen, &vchPlaintext[0], nLen); - if (fOk) fOk = EVP_EncryptFinal_ex(&ctx, (&vchCiphertext[0])+nCLen, &nFLen); - EVP_CIPHER_CTX_cleanup(&ctx); + EVP_CIPHER_CTX_init(ctx); + if (fOk) fOk = EVP_EncryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, chKey, chIV); + if (fOk) fOk = EVP_EncryptUpdate(ctx, &vchCiphertext[0], &nCLen, &vchPlaintext[0], nLen); + if (fOk) fOk = EVP_EncryptFinal_ex(ctx, (&vchCiphertext[0])+nCLen, &nFLen); + EVP_CIPHER_CTX_cleanup(ctx); + EVP_CIPHER_CTX_free(ctx); if (!fOk) return false; @@ -83,15 +86,17 @@ bool CCrypter::Decrypt(const std::vector& vchCiphertext, CKeyingM vchPlaintext = CKeyingMaterial(nPLen); - EVP_CIPHER_CTX ctx; + EVP_CIPHER_CTX* ctx = EVP_CIPHER_CTX_new(); + if (!ctx) return false; bool fOk = true; - EVP_CIPHER_CTX_init(&ctx); - if (fOk) fOk = EVP_DecryptInit_ex(&ctx, EVP_aes_256_cbc(), NULL, chKey, chIV); - if (fOk) fOk = EVP_DecryptUpdate(&ctx, &vchPlaintext[0], &nPLen, &vchCiphertext[0], nLen); - if (fOk) fOk = EVP_DecryptFinal_ex(&ctx, (&vchPlaintext[0])+nPLen, &nFLen); - EVP_CIPHER_CTX_cleanup(&ctx); + EVP_CIPHER_CTX_init(ctx); + if (fOk) fOk = EVP_DecryptInit_ex(ctx, EVP_aes_256_cbc(), NULL, chKey, chIV); + if (fOk) fOk = EVP_DecryptUpdate(ctx, &vchPlaintext[0], &nPLen, &vchCiphertext[0], nLen); + if (fOk) fOk = EVP_DecryptFinal_ex(ctx, (&vchPlaintext[0])+nPLen, &nFLen); + EVP_CIPHER_CTX_cleanup(ctx); + EVP_CIPHER_CTX_free(ctx); if (!fOk) return false; diff --git a/src/db.cpp b/src/db.cpp index 5d3eb3d69..d4ff1f68e 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -172,9 +172,18 @@ bool CDBEnv::Salvage(std::string strFile, bool fAggressive, Db db(&dbenv, 0); int result = db.verify(strFile.c_str(), NULL, &strDump, flags); - if (result != 0) + if (result == DB_VERIFY_BAD) { - printf("ERROR: db salvage failed\n"); + printf("Error: Salvage found errors, all data may not be recoverable.\n"); + if (!fAggressive) + { + printf("Error: Rerun with aggressive mode to ignore errors and continue.\n"); + return false; + } + } + if (result != 0 && result != DB_VERIFY_BAD) + { + printf("ERROR: db salvage failed: %d\n",result); return false; } @@ -462,7 +471,7 @@ void CDBEnv::Flush(bool fShutdown) else mi++; } - printf("DBFlush(%s)%s ended %15"PRI64d"ms\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started", GetTimeMillis() - nStart); + printf("DBFlush(%s)%s ended %15lldms\n", fShutdown ? "true" : "false", fDbEnvInit ? "" : " db not started", GetTimeMillis() - nStart); if (fShutdown) { char** listp; @@ -572,26 +581,6 @@ bool CTxDB::WriteBestInvalidTrust(CBigNum bnBestInvalidTrust) return Write(string("bnBestInvalidTrust"), bnBestInvalidTrust); } -bool CTxDB::ReadSyncCheckpoint(uint256& hashCheckpoint) -{ - return Read(string("hashSyncCheckpoint"), hashCheckpoint); -} - -bool CTxDB::WriteSyncCheckpoint(uint256 hashCheckpoint) -{ - return Write(string("hashSyncCheckpoint"), hashCheckpoint); -} - -bool CTxDB::ReadCheckpointPubKey(string& strPubKey) -{ - return Read(string("strCheckpointPubKey"), strPubKey); -} - -bool CTxDB::WriteCheckpointPubKey(const string& strPubKey) -{ - return Write(string("strCheckpointPubKey"), strPubKey); -} - CBlockIndex static * InsertBlockIndex(uint256 hash) { if (hash == 0) @@ -636,7 +625,7 @@ bool CTxDB::LoadBlockIndex() // ppcoin: calculate stake modifier checksum pindex->nStakeModifierChecksum = GetStakeModifierChecksum(pindex); if (!CheckStakeModifierCheckpoints(pindex->nHeight, pindex->nStakeModifierChecksum)) - return error("CTxDB::LoadBlockIndex() : Failed stake modifier checkpoint height=%d, modifier=0x%016"PRI64x, pindex->nHeight, pindex->nStakeModifier); + return error("CTxDB::LoadBlockIndex() : Failed stake modifier checkpoint height=%d, modifier=0x%016llx", pindex->nHeight, pindex->nStakeModifier); } // Load hashBestChain pointer to end of best chain @@ -655,11 +644,6 @@ bool CTxDB::LoadBlockIndex() hashBestChain.ToString().substr(0,20).c_str(), nBestHeight, bnBestChainTrust.ToString().c_str(), DateTimeStrFormat("%x %H:%M:%S", pindexBest->GetBlockTime()).c_str()); - // ppcoin: load hashSyncCheckpoint - if (!ReadSyncCheckpoint(Checkpoints::hashSyncCheckpoint)) - return error("CTxDB::LoadBlockIndex() : hashSyncCheckpoint not loaded"); - printf("LoadBlockIndex(): synchronized checkpoint %s\n", Checkpoints::hashSyncCheckpoint.ToString().c_str()); - // Load bnBestInvalidTrust, OK if it doesn't exist ReadBestInvalidTrust(bnBestInvalidTrust); @@ -802,7 +786,7 @@ bool CTxDB::LoadBlockIndexGuts() // Load mapBlockIndex unsigned int fFlags = DB_SET_RANGE; - loop + while (true) { // Read next record CDataStream ssKey(SER_DISK, CLIENT_VERSION); @@ -825,9 +809,11 @@ bool CTxDB::LoadBlockIndexGuts() { CDiskBlockIndex diskindex; ssValue >> diskindex; + + uint256 blockHash = diskindex.GetBlockHash(); // Construct block index object - CBlockIndex* pindexNew = InsertBlockIndex(diskindex.GetBlockHash()); + CBlockIndex* pindexNew = InsertBlockIndex(blockHash); pindexNew->pprev = InsertBlockIndex(diskindex.hashPrev); pindexNew->pnext = InsertBlockIndex(diskindex.hashNext); pindexNew->nFile = diskindex.nFile; @@ -846,8 +832,11 @@ bool CTxDB::LoadBlockIndexGuts() pindexNew->nBits = diskindex.nBits; pindexNew->nNonce = diskindex.nNonce; +// if (fTestNet || pindexNew->nHeight >= (int)VOTING_START) +// pindexNew->tally = diskindex.tally; + // Watch for genesis block - if (pindexGenesisBlock == NULL && diskindex.GetBlockHash() == (!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet)) + if (pindexGenesisBlock == NULL && blockHash == (!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet)) pindexGenesisBlock = pindexNew; if (!pindexNew->CheckIndex()) @@ -871,8 +860,70 @@ bool CTxDB::LoadBlockIndexGuts() return true; } +bool CVoteDB::Load() +{ + // Get database cursor + Dbc* pcursor = GetCursor(); + if (!pcursor) + return false; + // Load mapProposals + unsigned int fFlags = DB_SET_RANGE; + while (true) + { + // Read next record + CDataStream ssKey(SER_DISK, CLIENT_VERSION); + if (fFlags == DB_SET_RANGE) + ssKey << make_pair(string("prop"), uint256(0)); + CDataStream ssValue(SER_DISK, CLIENT_VERSION); + int ret = ReadAtCursor(pcursor, ssKey, ssValue, fFlags); + fFlags = DB_NEXT; + if (ret == DB_NOTFOUND) + break; + else if (ret != 0) + return false; + // Unserialize + try { + string strType; + ssKey >> strType; + if (strType == "prop" && !fRequestShutdown) + { + uint256 txid; + ssKey >> txid; + + try { + CVoteProposal proposal; + ssValue >> proposal; + mapProposals.insert(make_pair(txid, proposal.GetHash())); + proposalManager.Add(proposal); + } catch (...) { + printf("**failed to deserialize proposal\n"); + } + } + else + { + break; // if shutdown requested or finished loading block index + } + } // try + catch (std::exception &e) { + return error("%s() : deserialize error", __PRETTY_FUNCTION__); + } + } + pcursor->close(); + + return true; +} + +bool CVoteDB::WriteProposal(const uint256 &hash, const CVoteProposal &proposal) +{ + return Write(make_pair(string("prop"), hash), proposal); +} + +bool CVoteDB::ReadProposal(const uint256 &hash, CVoteProposal &proposal) +{ + return Read(make_pair(string("prop"), hash), proposal); +} // diff --git a/src/db.h b/src/db.h index eeb3a0b0a..1ccb3ce9b 100644 --- a/src/db.h +++ b/src/db.h @@ -6,6 +6,7 @@ #define BITCOIN_DB_H #include "main.h" +#include "voteproposal.h" #include #include @@ -340,15 +341,23 @@ class CTxDB : public CDB bool WriteHashBestChain(uint256 hashBestChain); bool ReadBestInvalidTrust(CBigNum& bnBestInvalidTrust); bool WriteBestInvalidTrust(CBigNum bnBestInvalidTrust); - bool ReadSyncCheckpoint(uint256& hashCheckpoint); - bool WriteSyncCheckpoint(uint256 hashCheckpoint); - bool ReadCheckpointPubKey(std::string& strPubKey); - bool WriteCheckpointPubKey(const std::string& strPubKey); bool LoadBlockIndex(); private: bool LoadBlockIndexGuts(); }; +class CVoteDB : public CDB +{ +public: + CVoteDB(const char* pszMode="r+") : CDB("governance.dat", pszMode) { } +private: + CVoteDB(const CVoteDB&); + void operator=(const CVoteDB&); +public: + bool Load(); + bool WriteProposal(const uint256& hash, const CVoteProposal& proposal); + bool ReadProposal(const uint256& hash, CVoteProposal& proposal); +}; diff --git a/src/hashblock.h b/src/hashblock.h index 7bb81b7a4..7e0ea1687 100644 --- a/src/hashblock.h +++ b/src/hashblock.h @@ -80,7 +80,7 @@ inline uint256 Hash9(const T1 pbegin, const T1 pend) //strhash = ""; #endif - uint512 hash[17]; + uint512 hash[11]; sph_blake512_init(&ctx_blake); sph_blake512 (&ctx_blake, (pbegin == pend ? pblank : static_cast(&pbegin[0])), (pend - pbegin) * sizeof(pbegin[0])); diff --git a/src/init.cpp b/src/init.cpp index 42a1029dd..50270bf8e 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -42,13 +42,16 @@ void ExitTimeout(void* parg) void StartShutdown() { -#ifdef QT_GUI - // ensure we leave the Qt main loop for a clean GUI exit (Shutdown() is called in bitcoin.cpp afterwards) - uiInterface.QueueShutdown(); -#else - // Without UI, Shutdown() can simply be started in a new thread - NewThread(Shutdown, NULL); -#endif + if (fHaveGUI) + { + // ensure we leave the Qt main loop for a clean GUI exit (Shutdown() is called in bitcoin.cpp afterwards) + uiInterface.QueueShutdown(); + } + else + { + // Without UI, Shutdown() can simply be started in a new thread + NewThread(Shutdown, NULL); + } } void Shutdown(void* parg) @@ -83,10 +86,11 @@ void Shutdown(void* parg) Sleep(50); printf("HyperStake exited\n\n"); fExit = true; -#ifndef QT_GUI - // ensure non-UI client gets exited here, but let Bitcoin-Qt reach 'return 0;' in bitcoin.cpp - exit(0); -#endif + if (!fHaveGUI) + { + // ensure non-UI client gets exited here, but let Bitcoin-Qt reach 'return 0;' in bitcoin.cpp + exit(0); + } } else { @@ -109,86 +113,6 @@ void HandleSIGHUP(int) - - -////////////////////////////////////////////////////////////////////////////// -// -// Start -// -#if !defined(QT_GUI) -bool AppInit(int argc, char* argv[]) -{ - bool fRet = false; - try - { - // - // Parameters - // - // If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's main() - ParseParameters(argc, argv); - if (!boost::filesystem::is_directory(GetDataDir(false))) - { - fprintf(stderr, "Error: Specified directory does not exist\n"); - Shutdown(NULL); - } - ReadConfigFile(mapArgs, mapMultiArgs); - - if (mapArgs.count("-?") || mapArgs.count("--help")) - { - // First part of help message is specific to bitcoind / RPC client - std::string strUsage = _("HyperStake version") + " " + FormatFullVersion() + "\n\n" + - _("Usage:") + "\n" + - " HyperStaked [options] " + "\n" + - " HyperStaked [options] [params] " + _("Send command to -server or HyperStaked") + "\n" + - " HyperStaked [options] help " + _("List commands") + "\n" + - " HyperStaked [options] help " + _("Get help for a command") + "\n"; - - strUsage += "\n" + HelpMessage(); - - fprintf(stdout, "%s", strUsage.c_str()); - return false; - } - - // Command-line RPC - for (int i = 1; i < argc; i++) - if (!IsSwitchChar(argv[i][0]) && !boost::algorithm::istarts_with(argv[i], "HyperStake:")) - fCommandLine = true; - - if (fCommandLine) - { - int ret = CommandLineRPC(argc, argv); - exit(ret); - } - - fRet = AppInit2(); - } - catch (std::exception& e) { - PrintException(&e, "AppInit()"); - } catch (...) { - PrintException(NULL, "AppInit()"); - } - if (!fRet) - Shutdown(NULL); - return fRet; -} - -extern void noui_connect(); -int main(int argc, char* argv[]) -{ - bool fRet = false; - - // Connect bitcoind signal handlers - noui_connect(); - - fRet = AppInit(argc, argv); - - if (fRet && fDaemon) - return 0; - - return 1; -} -#endif - bool static InitError(const std::string &str) { uiInterface.ThreadSafeMessageBox(str, _("HyperStake"), CClientUIInterface::OK | CClientUIInterface::MODAL); @@ -217,86 +141,89 @@ bool static Bind(const CService &addr, bool fError = true) { // Core-specific options shared between UI and daemon std::string HelpMessage() { - string strUsage = _("Options:") + "\n" + - " -? " + _("This help message") + "\n" + - " -conf= " + _("Specify configuration file (default: HyperStake.conf)") + "\n" + - " -pid= " + _("Specify pid file (default: HyperStaked.pid)") + "\n" + - " -gen " + _("Generate coins") + "\n" + - " -gen=0 " + _("Don't generate coins") + "\n" + - " -datadir= " + _("Specify data directory") + "\n" + - " -dbcache= " + _("Set database cache size in megabytes (default: 25)") + "\n" + - " -dblogsize= " + _("Set database disk log size in megabytes (default: 100)") + "\n" + - " -timeout= " + _("Specify connection timeout in milliseconds (default: 5000)") + "\n" + - " -proxy= " + _("Connect through socks proxy") + "\n" + - " -socks= " + _("Select the version of socks proxy to use (4-5, default: 5)") + "\n" + - " -tor= " + _("Use proxy to reach tor hidden services (default: same as -proxy)") + "\n" - " -dns " + _("Allow DNS lookups for -addnode, -seednode and -connect") + "\n" + - " -port= " + _("Listen for connections on (default: 18777 or testnet: 28775)") + "\n" + - " -maxconnections= " + _("Maintain at most connections to peers (default: 125)") + "\n" + - " -addnode= " + _("Add a node to connect to and attempt to keep the connection open") + "\n" + - " -connect= " + _("Connect only to the specified node(s)") + "\n" + - " -seednode= " + _("Connect to a node to retrieve peer addresses, and disconnect") + "\n" + - " -externalip= " + _("Specify your own public address") + "\n" + - " -onlynet= " + _("Only connect to nodes in network (IPv4, IPv6 or Tor)") + "\n" + - " -discover " + _("Discover own IP address (default: 1 when listening and no -externalip)") + "\n" + - " -irc " + _("Find peers using internet relay chat (default: 1)") + "\n" + - " -listen " + _("Accept connections from outside (default: 1 if no -proxy or -connect)") + "\n" + - " -bind= " + _("Bind to given address. Use [host]:port notation for IPv6") + "\n" + - " -dnsseed " + _("Find peers using DNS lookup (default: 0)") + "\n" + - " -nosynccheckpoints " + _("Disable sync checkpoints (default: 0)") + "\n" + - " -banscore= " + _("Threshold for disconnecting misbehaving peers (default: 100)") + "\n" + - " -bantime= " + _("Number of seconds to keep misbehaving peers from reconnecting (default: 86400)") + "\n" + - " -maxreceivebuffer= " + _("Maximum per-connection receive buffer, *1000 bytes (default: 5000)") + "\n" + - " -maxsendbuffer= " + _("Maximum per-connection send buffer, *1000 bytes (default: 1000)") + "\n" + + string strUsage = _("Options:") + "\n"; + strUsage += " -? " + _("This help message") + "\n"; + strUsage += " -conf= " + _("Specify configuration file (default: HyperStake.conf)") + "\n"; + strUsage += " -pid= " + _("Specify pid file (default: HyperStaked.pid)") + "\n"; + strUsage += " -gen " + _("Generate coins") + "\n"; + strUsage += " -gen=0 " + _("Don't generate coins") + "\n"; + strUsage += " -datadir= " + _("Specify data directory") + "\n"; + strUsage += " -dbcache= " + _("Set database cache size in megabytes (default: 25)") + "\n"; + strUsage += " -dblogsize= " + _("Set database disk log size in megabytes (default: 100)") + "\n"; + strUsage += " -timeout= " + _("Specify connection timeout in milliseconds (default: 5000)") + "\n"; + strUsage += " -proxy= " + _("Connect through socks proxy") + "\n"; + strUsage += " -socks= " + _("Select the version of socks proxy to use (4-5, default: 5)") + "\n"; + strUsage += " -tor= " + _("Use proxy to reach tor hidden services (default: same as -proxy)") + "\n"; + strUsage += " -dnsseed " + _("Query for peer addresses via DNS lookup, if low on addresses (default: 1 unless -connect)") + "\n"; + strUsage += " -forcednsseed " + _("Always query for peer addresses via DNS lookup (default: 0)") + "\n"; + strUsage += " -port= " + _("Listen for connections on (default: 18777 or testnet: 28775)") + "\n"; + strUsage += " -maxconnections= " + _("Maintain at most connections to peers (default: 125)") + "\n"; + strUsage += " -addnode= " + _("Add a node to connect to and attempt to keep the connection open") + "\n"; + strUsage += " -connect= " + _("Connect only to the specified node(s)") + "\n"; + strUsage += " -seednode= " + _("Connect to a node to retrieve peer addresses, and disconnect") + "\n"; + strUsage += " -externalip= " + _("Specify your own public address") + "\n"; + strUsage += " -onlynet= " + _("Only connect to nodes in network (IPv4, IPv6 or Tor)") + "\n"; + strUsage += " -discover " + _("Discover own IP address (default: 1 when listening and no -externalip)") + "\n"; + strUsage += " -listen " + _("Accept connections from outside (default: 1 if no -proxy or -connect)") + "\n"; + strUsage += " -bind= " + _("Bind to given address. Use [host]:port notation for IPv6") + "\n"; + strUsage += " -dnsseed " + _("Find peers using DNS lookup (default: 0)") + "\n"; + strUsage += " -nosynccheckpoints " + _("Disable sync checkpoints (default: 0)") + "\n"; + strUsage += " -banscore= " + _("Threshold for disconnecting misbehaving peers (default: 100)") + "\n"; + strUsage += " -bantime= " + _("Number of seconds to keep misbehaving peers from reconnecting (default: 86400)") + "\n"; + strUsage += " -maxreceivebuffer= " + _("Maximum per-connection receive buffer, *1000 bytes (default: 5000)") + "\n"; + strUsage += " -maxsendbuffer= " + _("Maximum per-connection send buffer, *1000 bytes (default: 1000)") + "\n"; + strUsage += " -stakeaddress=
" + _("Restrict the wallet to only stake inputs from one address") + "\n"; + strUsage += " -strictprotocol= " + _("Only connect to peers using the same protocol version. Warning this will cause low peer count.") + "\n"; #ifdef USE_UPNP #if USE_UPNP - " -upnp " + _("Use UPnP to map the listening port (default: 1 when listening)") + "\n" + + strUsage += " -upnp " + _("Use UPnP to map the listening port (default: 1 when listening)") + "\n"; #else - " -upnp " + _("Use UPnP to map the listening port (default: 0)") + "\n" + -#endif + strUsage += " -upnp " + _("Use UPnP to map the listening port (default: 0)") + "\n"; #endif - " -detachdb " + _("Detach block and address databases. Increases shutdown time (default: 0)") + "\n" + - " -paytxfee= " + _("Fee per KB to add to transactions you send") + "\n" + -#ifdef QT_GUI - " -server " + _("Accept command line and JSON-RPC commands") + "\n" + #endif -#if !defined(WIN32) && !defined(QT_GUI) - " -daemon " + _("Run in the background as a daemon and accept commands") + "\n" + + strUsage += " -detachdb " + _("Detach block and address databases. Increases shutdown time (default: 0)") + "\n"; + strUsage += " -paytxfee= " + _("Fee per KB to add to transactions you send") + "\n"; + if (fHaveGUI) + strUsage += " -server " + _("Accept command line and JSON-RPC commands") + "\n"; + +#if !defined(WIN32) + if (!fHaveGUI) + strUsage +=" -daemon " + _("Run in the background as a daemon and accept commands") + "\n"; #endif - " -testnet " + _("Use the test network") + "\n" + - " -debug " + _("Output extra debugging information. Implies all other -debug* options") + "\n" + - " -debugnet " + _("Output extra network debugging information") + "\n" + - " -logtimestamps " + _("Prepend debug output with timestamp") + "\n" + - " -shrinkdebugfile " + _("Shrink debug.log file on client startup (default: 1 when no -debug)") + "\n" + - " -printtoconsole " + _("Send trace/debug info to console instead of debug.log file") + "\n" + + strUsage += " -testnet " + _("Use the test network") + "\n"; + strUsage += " -debug " + _("Output extra debugging information. Implies all other -debug* options") + "\n"; + strUsage += " -debugnet " + _("Output extra network debugging information") + "\n"; + strUsage += " -logtimestamps " + _("Prepend debug output with timestamp") + "\n"; + strUsage += " -shrinkdebugfile " + _("Shrink debug.log file on client startup (default: 1 when no -debug)") + "\n"; + strUsage += " -printtoconsole " + _("Send trace/debug info to console instead of debug.log file") + "\n"; #ifdef WIN32 - " -printtodebugger " + _("Send trace/debug info to debugger") + "\n" + + strUsage += " -printtodebugger " + _("Send trace/debug info to debugger") + "\n"; #endif - " -rpcuser= " + _("Username for JSON-RPC connections") + "\n" + - " -rpcpassword= " + _("Password for JSON-RPC connections") + "\n" + - " -rpcport= " + _("Listen for JSON-RPC connections on (default: 18777 or testnet: 28776)") + "\n" + - " -rpcallowip= " + _("Allow JSON-RPC connections from specified IP address") + "\n" + - " -rpcconnect= " + _("Send commands to node running on (default: 127.0.0.1)") + "\n" + - " -blocknotify= " + _("Execute command when the best block changes (%s in cmd is replaced by block hash)") + "\n" + - " -walletnotify= " + _("Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)") + "\n" + - " -upgradewallet " + _("Upgrade wallet to latest format") + "\n" + - " -keypool= " + _("Set key pool size to (default: 100)") + "\n" + - " -rescan " + _("Rescan the block chain for missing wallet transactions") + "\n" + - " -salvagewallet " + _("Attempt to recover private keys from a corrupt wallet.dat") + "\n" + - " -checkblocks= " + _("How many blocks to check at startup (default: 2500, 0 = all)") + "\n" + - " -checklevel= " + _("How thorough the block verification is (0-6, default: 1)") + "\n" + - " -loadblock= " + _("Imports blocks from external blk000?.dat file") + "\n" + - - "\n" + _("Block creation options:") + "\n" + - " -blockminsize= " + _("Set minimum block size in bytes (default: 0)") + "\n" + - " -blockmaxsize= " + _("Set maximum block size in bytes (default: 250000)") + "\n" + - " -blockprioritysize= " + _("Set maximum size of high-priority/low-fee transactions in bytes (default: 27000)") + "\n" + - - "\n" + _("SSL options: (see the Bitcoin Wiki for SSL setup instructions)") + "\n" + - " -rpcssl " + _("Use OpenSSL (https) for JSON-RPC connections") + "\n" + - " -rpcsslcertificatechainfile= " + _("Server certificate file (default: server.cert)") + "\n" + - " -rpcsslprivatekeyfile= " + _("Server private key (default: server.pem)") + "\n" + - " -rpcsslciphers= " + _("Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)") + "\n"; + strUsage += " -rpcuser= " + _("Username for JSON-RPC connections") + "\n"; + strUsage += " -rpcpassword= " + _("Password for JSON-RPC connections") + "\n"; + strUsage += " -rpcport= " + _("Listen for JSON-RPC connections on (default: 18777 or testnet: 28776)") + "\n"; + strUsage += " -rpcallowip= " + _("Allow JSON-RPC connections from specified IP address") + "\n"; + strUsage += " -rpcconnect= " + _("Send commands to node running on (default: 127.0.0.1)") + "\n"; + strUsage += " -blocknotify= " + _("Execute command when the best block changes (%s in cmd is replaced by block hash)") + "\n"; + strUsage += " -walletnotify= " + _("Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)") + "\n"; + strUsage += " -upgradewallet " + _("Upgrade wallet to latest format") + "\n"; + strUsage += " -keypool= " + _("Set key pool size to (default: 100)") + "\n"; + strUsage += " -rescan " + _("Rescan the block chain for missing wallet transactions") + "\n"; + strUsage += " -salvagewallet " + _("Attempt to recover private keys from a corrupt wallet.dat") + "\n"; + strUsage += " -checkblocks= " + _("How many blocks to check at startup (default: 2500, 0 = all)") + "\n"; + strUsage += " -checklevel= " + _("How thorough the block verification is (0-6, default: 1)") + "\n"; + strUsage += " -loadblock= " + _("Imports blocks from external blk000?.dat file") + "\n"; + + strUsage += "\n" + _("Block creation options:") + "\n"; + strUsage += " -blockminsize= " + _("Set minimum block size in bytes (default: 0)") + "\n"; + strUsage += " -blockmaxsize= " + _("Set maximum block size in bytes (default: 250000)") + "\n"; + strUsage += " -blockprioritysize= " + _("Set maximum size of high-priority/low-fee transactions in bytes (default: 27000)") + "\n"; + + strUsage += "\n" + _("SSL options: (see the Bitcoin Wiki for SSL setup instructions)") + "\n"; + strUsage += " -rpcssl " + _("Use OpenSSL (https) for JSON-RPC connections") + "\n"; + strUsage += " -rpcsslcertificatechainfile= " + _("Server certificate file (default: server.cert)") + "\n"; + strUsage += " -rpcsslprivatekeyfile= " + _("Server private key (default: server.pem)") + "\n"; + strUsage += " -rpcsslciphers= " + _("Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)") + "\n"; return strUsage; } @@ -351,9 +278,6 @@ bool AppInit2() // ********************************************************* Step 2: parameter interactions fTestNet = GetBoolArg("-testnet"); - if (fTestNet) { - SoftSetBoolArg("-irc", true); - } if (mapArgs.count("-bind")) { // when specifying an explicit binding address, you want to listen on it @@ -412,9 +336,9 @@ bool AppInit2() fServer = GetBoolArg("-server"); /* force fServer when running without GUI */ -#if !defined(QT_GUI) - fServer = true; -#endif + if (!fHaveGUI) + fServer = true; + fPrintToConsole = GetBoolArg("-printtoconsole"); fPrintToDebugger = GetBoolArg("-printtodebugger"); fLogTimestamps = GetBoolArg("-logtimestamps"); @@ -638,12 +562,6 @@ bool AppInit2() } } - if (mapArgs.count("-checkpointkey")) // ppcoin: checkpoint master priv key - { - if (!Checkpoints::SetCheckpointPrivKey(GetArg("-checkpointkey", ""))) - InitError(_("Unable to sign checkpoint, wrong checkpointkey?\n")); - } - BOOST_FOREACH(string strDest, mapMultiArgs["-seednode"]) AddOneShot(strDest); @@ -682,7 +600,7 @@ bool AppInit2() printf("Shutdown requested. Exiting.\n"); return false; } - printf(" block index %15"PRI64d"ms\n", GetTimeMillis() - nStart); + printf(" block index %15lldms\n", GetTimeMillis() - nStart); if (GetBoolArg("-printblockindex") || GetBoolArg("-printblocktree")) { @@ -773,7 +691,7 @@ bool AppInit2() } printf("%s", strErrors.str().c_str()); - printf(" wallet %15"PRI64d"ms\n", GetTimeMillis() - nStart); + printf(" wallet %15lldms\n", GetTimeMillis() - nStart); RegisterWallet(pwalletMain); @@ -793,7 +711,7 @@ bool AppInit2() printf("Rescanning last %i blocks (from block %i)...\n", pindexBest->nHeight - pindexRescan->nHeight, pindexRescan->nHeight); nStart = GetTimeMillis(); pwalletMain->ScanForWalletTransactions(pindexRescan, true); - printf(" rescan %15"PRI64d"ms\n", GetTimeMillis() - nStart); + printf(" rescan %15lldms\n", GetTimeMillis() - nStart); } // ********************************************************* Step 9: import blocks @@ -834,7 +752,7 @@ bool AppInit2() printf("Invalid or missing peers.dat; recreating\n"); } - printf("Loaded %i addresses from peers.dat %"PRI64d"ms\n", + printf("Loaded %i addresses from peers.dat %lldms\n", addrman.size(), GetTimeMillis() - nStart); // ********************************************************* Step 11: start node @@ -845,11 +763,11 @@ bool AppInit2() RandAddSeedPerfmon(); //// debug print - printf("mapBlockIndex.size() = %"PRIszu"\n", mapBlockIndex.size()); + printf("mapBlockIndex.size() = %lu\n", mapBlockIndex.size()); printf("nBestHeight = %d\n", nBestHeight); - printf("setKeyPool.size() = %"PRIszu"\n", pwalletMain->setKeyPool.size()); - printf("mapWallet.size() = %"PRIszu"\n", pwalletMain->mapWallet.size()); - printf("mapAddressBook.size() = %"PRIszu"\n", pwalletMain->mapAddressBook.size()); + printf("setKeyPool.size() = %lu\n", pwalletMain->setKeyPool.size()); + printf("mapWallet.size() = %lu\n", pwalletMain->mapWallet.size()); + printf("mapAddressBook.size() = %lu\n", pwalletMain->mapAddressBook.size()); if (!NewThread(StartNode, NULL)) InitError(_("Error: could not start node")); @@ -868,12 +786,13 @@ bool AppInit2() // Add wallet transactions that aren't already in a block to mapTransactions pwalletMain->ReacceptWalletTransactions(); -#if !defined(QT_GUI) - // Loop until process is exit()ed from shutdown() function, - // called from ThreadRPCServer thread when a "stop" command is received. - while (1) - Sleep(5000); -#endif + if (!fHaveGUI) + { + // Loop until process is exit()ed from shutdown() function, + // called from ThreadRPCServer thread when a "stop" command is received. + while (1) + Sleep(5000); + } return true; } diff --git a/src/irc.cpp b/src/irc.cpp deleted file mode 100644 index 8301af0e6..000000000 --- a/src/irc.cpp +++ /dev/null @@ -1,405 +0,0 @@ -// Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2009-2012 The Bitcoin developers -// Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include "irc.h" -#include "net.h" -#include "strlcpy.h" -#include "base58.h" - -using namespace std; -using namespace boost; - -int nGotIRCAddresses = 0; - -void ThreadIRCSeed2(void* parg); - - - - -#pragma pack(push, 1) -struct ircaddr -{ - struct in_addr ip; - short port; -}; -#pragma pack(pop) - -string EncodeAddress(const CService& addr) -{ - struct ircaddr tmp; - if (addr.GetInAddr(&tmp.ip)) - { - tmp.port = htons(addr.GetPort()); - - vector vch(UBEGIN(tmp), UEND(tmp)); - return string("u") + EncodeBase58Check(vch); - } - return ""; -} - -bool DecodeAddress(string str, CService& addr) -{ - vector vch; - if (!DecodeBase58Check(str.substr(1), vch)) - return false; - - struct ircaddr tmp; - if (vch.size() != sizeof(tmp)) - return false; - memcpy(&tmp, &vch[0], sizeof(tmp)); - - addr = CService(tmp.ip, ntohs(tmp.port)); - return true; -} - - - - - - -static bool Send(SOCKET hSocket, const char* pszSend) -{ - if (strstr(pszSend, "PONG") != pszSend) - printf("IRC SENDING: %s\n", pszSend); - const char* psz = pszSend; - const char* pszEnd = psz + strlen(psz); - while (psz < pszEnd) - { - int ret = send(hSocket, psz, pszEnd - psz, MSG_NOSIGNAL); - if (ret < 0) - return false; - psz += ret; - } - return true; -} - -bool RecvLineIRC(SOCKET hSocket, string& strLine) -{ - loop - { - bool fRet = RecvLine(hSocket, strLine); - if (fRet) - { - if (fShutdown) - return false; - vector vWords; - ParseString(strLine, ' ', vWords); - if (vWords.size() >= 1 && vWords[0] == "PING") - { - strLine[1] = 'O'; - strLine += '\r'; - Send(hSocket, strLine.c_str()); - continue; - } - } - return fRet; - } -} - -int RecvUntil(SOCKET hSocket, const char* psz1, const char* psz2=NULL, const char* psz3=NULL, const char* psz4=NULL) -{ - loop - { - string strLine; - strLine.reserve(10000); - if (!RecvLineIRC(hSocket, strLine)) - return 0; - printf("IRC %s\n", strLine.c_str()); - if (psz1 && strLine.find(psz1) != string::npos) - return 1; - if (psz2 && strLine.find(psz2) != string::npos) - return 2; - if (psz3 && strLine.find(psz3) != string::npos) - return 3; - if (psz4 && strLine.find(psz4) != string::npos) - return 4; - } -} - -bool Wait(int nSeconds) -{ - if (fShutdown) - return false; - printf("IRC waiting %d seconds to reconnect\n", nSeconds); - for (int i = 0; i < nSeconds; i++) - { - if (fShutdown) - return false; - Sleep(1000); - } - return true; -} - -bool RecvCodeLine(SOCKET hSocket, const char* psz1, string& strRet) -{ - strRet.clear(); - loop - { - string strLine; - if (!RecvLineIRC(hSocket, strLine)) - return false; - - vector vWords; - ParseString(strLine, ' ', vWords); - if (vWords.size() < 2) - continue; - - if (vWords[1] == psz1) - { - printf("IRC %s\n", strLine.c_str()); - strRet = strLine; - return true; - } - } -} - -bool GetIPFromIRC(SOCKET hSocket, string strMyName, CNetAddr& ipRet) -{ - Send(hSocket, strprintf("USERHOST %s\r", strMyName.c_str()).c_str()); - - string strLine; - if (!RecvCodeLine(hSocket, "302", strLine)) - return false; - - vector vWords; - ParseString(strLine, ' ', vWords); - if (vWords.size() < 4) - return false; - - string str = vWords[3]; - if (str.rfind("@") == string::npos) - return false; - string strHost = str.substr(str.rfind("@")+1); - - // Hybrid IRC used by lfnet always returns IP when you userhost yourself, - // but in case another IRC is ever used this should work. - printf("GetIPFromIRC() got userhost %s\n", strHost.c_str()); - CNetAddr addr(strHost, true); - if (!addr.IsValid()) - return false; - ipRet = addr; - - return true; -} - - - -void ThreadIRCSeed(void* parg) -{ - // Make this thread recognisable as the IRC seeding thread - RenameThread("bitcoin-ircseed"); - - try - { - ThreadIRCSeed2(parg); - } - catch (std::exception& e) { - PrintExceptionContinue(&e, "ThreadIRCSeed()"); - } catch (...) { - PrintExceptionContinue(NULL, "ThreadIRCSeed()"); - } - printf("ThreadIRCSeed exited\n"); -} - -void ThreadIRCSeed2(void* parg) -{ - // Don't connect to IRC if we won't use IPv4 connections. - if (IsLimited(NET_IPV4)) - return; - - // ... or if we won't make outbound connections and won't accept inbound ones. - if (mapArgs.count("-connect") && fNoListen) - return; - - // ... or if IRC is not enabled. - if (!GetBoolArg("-irc", true)) - return; - - printf("ThreadIRCSeed started\n"); - int nErrorWait = 10; - int nRetryWait = 10; - int nNameRetry = 0; - - while (!fShutdown) - { - CService addrConnect("92.243.23.21", 6667); // irc.lfnet.org - - CService addrIRC("irc.lfnet.org", 6667, true); - if (addrIRC.IsValid()) - addrConnect = addrIRC; - - SOCKET hSocket; - if (!ConnectSocket(addrConnect, hSocket)) - { - printf("IRC connect failed\n"); - nErrorWait = nErrorWait * 11 / 10; - if (Wait(nErrorWait += 60)) - continue; - else - return; - } - - if (!RecvUntil(hSocket, "Found your hostname", "using your IP address instead", "Couldn't look up your hostname", "ignoring hostname")) - { - closesocket(hSocket); - hSocket = INVALID_SOCKET; - nErrorWait = nErrorWait * 11 / 10; - if (Wait(nErrorWait += 60)) - continue; - else - return; - } - - CNetAddr addrIPv4("1.2.3.4"); // arbitrary IPv4 address to make GetLocal prefer IPv4 addresses - CService addrLocal; - string strMyName; - // Don't use our IP as our nick if we're not listening - // or if it keeps failing because the nick is already in use. - if (!fNoListen && GetLocal(addrLocal, &addrIPv4) && nNameRetry<3) - strMyName = EncodeAddress(GetLocalAddress(&addrConnect)); - if (strMyName == "") - strMyName = strprintf("x%"PRI64u"", GetRand(1000000000)); - - Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str()); - Send(hSocket, strprintf("USER %s 8 * : %s\r", strMyName.c_str(), strMyName.c_str()).c_str()); - - int nRet = RecvUntil(hSocket, " 004 ", " 433 "); - if (nRet != 1) - { - closesocket(hSocket); - hSocket = INVALID_SOCKET; - if (nRet == 2) - { - printf("IRC name already in use\n"); - nNameRetry++; - Wait(10); - continue; - } - nErrorWait = nErrorWait * 11 / 10; - if (Wait(nErrorWait += 60)) - continue; - else - return; - } - nNameRetry = 0; - Sleep(500); - - // Get our external IP from the IRC server and re-nick before joining the channel - CNetAddr addrFromIRC; - if (GetIPFromIRC(hSocket, strMyName, addrFromIRC)) - { - printf("GetIPFromIRC() returned %s\n", addrFromIRC.ToString().c_str()); - // Don't use our IP as our nick if we're not listening - if (!fNoListen && addrFromIRC.IsRoutable()) - { - // IRC lets you to re-nick - AddLocal(addrFromIRC, LOCAL_IRC); - strMyName = EncodeAddress(GetLocalAddress(&addrConnect)); - Send(hSocket, strprintf("NICK %s\r", strMyName.c_str()).c_str()); - } - } - - if (fTestNet) { - Send(hSocket, "JOIN #TruckcoinTEST2\r"); - Send(hSocket, "WHO #TruckcoinTEST2\r"); - } else { - // randomly join #Truckcoin00-#Truckcoin05 - // int channel_number = GetRandInt(5); - - // Channel number is always 0 for initial release - int channel_number = 0; - Send(hSocket, strprintf("JOIN #Truckcoin%02d\r", channel_number).c_str()); - Send(hSocket, strprintf("WHO #Truckcoin%02d\r", channel_number).c_str()); - } - - int64 nStart = GetTime(); - string strLine; - strLine.reserve(10000); - while (!fShutdown && RecvLineIRC(hSocket, strLine)) - { - if (strLine.empty() || strLine.size() > 900 || strLine[0] != ':') - continue; - - vector vWords; - ParseString(strLine, ' ', vWords); - if (vWords.size() < 2) - continue; - - char pszName[10000]; - pszName[0] = '\0'; - - if (vWords[1] == "352" && vWords.size() >= 8) - { - // index 7 is limited to 16 characters - // could get full length name at index 10, but would be different from join messages - strlcpy(pszName, vWords[7].c_str(), sizeof(pszName)); - printf("IRC got who\n"); - } - - if (vWords[1] == "JOIN" && vWords[0].size() > 1) - { - // :username!username@50000007.F000000B.90000002.IP JOIN :#channelname - strlcpy(pszName, vWords[0].c_str() + 1, sizeof(pszName)); - if (strchr(pszName, '!')) - *strchr(pszName, '!') = '\0'; - printf("IRC got join\n"); - } - - if (pszName[0] == 'u') - { - CAddress addr; - if (DecodeAddress(pszName, addr)) - { - addr.nTime = GetAdjustedTime(); - if (addrman.Add(addr, addrConnect, 51 * 60)) - printf("IRC got new address: %s\n", addr.ToString().c_str()); - nGotIRCAddresses++; - } - else - { - printf("IRC decode failed\n"); - } - } - } - closesocket(hSocket); - hSocket = INVALID_SOCKET; - - if (GetTime() - nStart > 20 * 60) - { - nErrorWait /= 3; - nRetryWait /= 3; - } - - nRetryWait = nRetryWait * 11 / 10; - if (!Wait(nRetryWait += 60)) - return; - } -} - - - - - - - - - - -#ifdef TEST -int main(int argc, char *argv[]) -{ - WSADATA wsadata; - if (WSAStartup(MAKEWORD(2,2), &wsadata) != NO_ERROR) - { - printf("Error at WSAStartup()\n"); - return false; - } - - ThreadIRCSeed(NULL); - - WSACleanup(); - return 0; -} -#endif diff --git a/src/irc.h b/src/irc.h deleted file mode 100644 index 119aeb3fd..000000000 --- a/src/irc.h +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2009-2012 The Bitcoin developers -// Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef BITCOIN_IRC_H -#define BITCOIN_IRC_H - -void ThreadIRCSeed(void* parg); - -extern int nGotIRCAddresses; - -#endif diff --git a/src/json/json_spirit_writer_template.h b/src/json/json_spirit_writer_template.h index 28c49ddc6..8db4413fd 100644 --- a/src/json/json_spirit_writer_template.h +++ b/src/json/json_spirit_writer_template.h @@ -28,7 +28,8 @@ namespace json_spirit template< class String_type > String_type non_printable_to_string( unsigned int c ) { - typedef typename String_type::value_type Char_type; + // Silence the warning: typedef ‘Char_type’ locally defined but not used [-Wunused-local-typedefs] + //typedef typename String_type::value_type Char_type; String_type result( 6, '\\' ); diff --git a/src/kernel.cpp b/src/kernel.cpp index 7793b997e..36f97808d 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -15,19 +15,15 @@ extern int nStakeTargetSpacing; // Modifier interval: time to elapse before new modifier is computed // Set to 3-hour for production network and 20-minute for test network -unsigned int nModifierInterval = MODIFIER_INTERVAL; - - -unsigned int nProtocolModifierIntervalChangeSwitchHeight = 14420; -unsigned int nProtocolModifierIntervalChangeTestSwitchHeight = 100; - -bool IsProtocolModifierIntervalChange(unsigned int nBlockHeight) +unsigned int nModifierInterval; +unsigned int getIntervalVersion(bool fTestNet) { - return false; - // return (nBlockHeight >= (fTestNet? nProtocolModifierIntervalChangeTestSwitchHeight : nProtocolModifierIntervalChangeSwitchHeight)); + if(fTestNet) + return MODIFIER_INTERVAL_TESTNET; + else + return MODIFIER_INTERVAL; } - // Hard checkpoints of stake modifiers to ensure they are deterministic static std::map mapStakeModifierCheckpoints = boost::assign::map_list_of @@ -36,21 +32,14 @@ static std::map mapStakeModifierCheckpoints = // Get time weight int64 GetWeight(int64 nIntervalBeginning, int64 nIntervalEnd) { - // Kernel hash weight starts from 0 at the min age - // this change increases active coins participating the hash and helps - // to secure the network when proof-of-stake difficulty is low - return min(nIntervalEnd - nIntervalBeginning - nStakeMinAge, (int64)nStakeMaxAge); } -// Get time weight 2 - This is added for informational purposes since staking takes 8.8 days min approx. because of bug +// Get time weight 2 - This calculation is technically incorrect and is dumbed down math that is easier for the general public to understand int64 GetWeight2(int64 nIntervalBeginning, int64 nIntervalEnd) { - // Kernel hash weight starts from 0 at the min age - // this change increases active coins participating the hash and helps - // to secure the network when proof-of-stake difficulty is low - int64 nStakeMinAgeV2 = 60 * 60 * 24 * 8.8; - return min(nIntervalEnd - nIntervalBeginning - nStakeMinAgeV2, (int64)nStakeMaxAge); + int64 nTimePassed = nIntervalEnd - nIntervalBeginning; + return min(nTimePassed, (int64)nStakeMaxAge); } // Get the last stake modifier and its generation time from a given block @@ -71,7 +60,7 @@ static bool GetLastStakeModifier(const CBlockIndex* pindex, uint64& nStakeModifi static int64 GetStakeModifierSelectionIntervalSection(int nSection) { assert (nSection >= 0 && nSection < 64); - int64 a = nModifierInterval * 63 / (63 + ((63 - nSection) * (MODIFIER_INTERVAL_RATIO - 1))); + int64 a = getIntervalVersion(fTestNet) * 63 / (63 + ((63 - nSection) * (MODIFIER_INTERVAL_RATIO - 1))); return a; } @@ -157,14 +146,6 @@ bool ComputeNextStakeModifier(const CBlockIndex* pindexPrev, uint64& nStakeModif fGeneratedStakeModifier = true; return true; // genesis block's modifier is 0 } - // fix ba.dgercoin - - if ( IsProtocolModifierIntervalChange(pindexPrev->nHeight)){ - nModifierInterval = fTestNet?MODIFIER_INTERVAL_NEW_TESTNET:MODIFIER_INTERVAL_NEW; - //printf("Switching to new modifier interval %i @ block %i", nModifierInterval,pindexPrev->nHeight ); - } - - // First find current stake modifier and its generation block time // if it's not old enough, return the same stake modifier @@ -172,28 +153,23 @@ bool ComputeNextStakeModifier(const CBlockIndex* pindexPrev, uint64& nStakeModif if (!GetLastStakeModifier(pindexPrev, nStakeModifier, nModifierTime)) return error("ComputeNextStakeModifier: unable to get last modifier"); if (fDebug) - { - printf("ComputeNextStakeModifier: prev modifier=0x%016"PRI64x" time=%s\n", nStakeModifier, DateTimeStrFormat(nModifierTime).c_str()); - } - - - - - - if (nModifierTime / nModifierInterval >= pindexPrev->GetBlockTime() / nModifierInterval) + printf("ComputeNextStakeModifier: prev modifier=0x%016llu time=%s\n", nStakeModifier, DateTimeStrFormat(nModifierTime).c_str()); + if (nModifierTime / getIntervalVersion(fTestNet) >= pindexPrev->GetBlockTime() / getIntervalVersion(fTestNet)) return true; // Sort candidate blocks by timestamp vector > vSortedByTimestamp; - vSortedByTimestamp.reserve(64 * nModifierInterval / nStakeTargetSpacing); + vSortedByTimestamp.reserve(64 * getIntervalVersion(fTestNet) / nStakeTargetSpacing); int64 nSelectionInterval = GetStakeModifierSelectionInterval(); - int64 nSelectionIntervalStart = (pindexPrev->GetBlockTime() / nModifierInterval) * nModifierInterval - nSelectionInterval; + int64 nSelectionIntervalStart = (pindexPrev->GetBlockTime() / getIntervalVersion(fTestNet)) * getIntervalVersion(fTestNet) - nSelectionInterval; const CBlockIndex* pindex = pindexPrev; + while (pindex && pindex->GetBlockTime() >= nSelectionIntervalStart) { vSortedByTimestamp.push_back(make_pair(pindex->GetBlockTime(), pindex->GetBlockHash())); pindex = pindex->pprev; } + int nHeightFirstCandidate = pindex ? (pindex->nHeight + 1) : 0; reverse(vSortedByTimestamp.begin(), vSortedByTimestamp.end()); sort(vSortedByTimestamp.begin(), vSortedByTimestamp.end()); @@ -242,7 +218,7 @@ bool ComputeNextStakeModifier(const CBlockIndex* pindexPrev, uint64& nStakeModif } if (fDebug) { - printf("ComputeNextStakeModifier: new modifier=0x%016"PRI64x" time=%s\n", nStakeModifierNew, DateTimeStrFormat(pindexPrev->GetBlockTime()).c_str()); + printf("ComputeNextStakeModifier: new modifier=0x%016llu time=%s\n", nStakeModifierNew, DateTimeStrFormat(pindexPrev->GetBlockTime()).c_str()); } nStakeModifier = nStakeModifierNew; @@ -263,8 +239,6 @@ static bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64& nStakeModifier int64 nStakeModifierSelectionInterval = GetStakeModifierSelectionInterval(); const CBlockIndex* pindex = pindexFrom; - - // loop to find the stake modifier later by a selection interval while (nStakeModifierTime < pindexFrom->GetBlockTime() + nStakeModifierSelectionInterval) { @@ -275,10 +249,10 @@ static bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64& nStakeModifier pindex->GetBlockHash().ToString().c_str(), pindex->nHeight, hashBlockFrom.ToString().c_str()); else { - // printf(">> nStakeModifierTime = %"PRI64d", pindexFrom->GetBlockTime() = %"PRI64d", nStakeModifierSelectionInterval = %"PRI64d"\n", - // nStakeModifierTime, pindexFrom->GetBlockTime(), nStakeModifierSelectionInterval); - return false; + //printf("FAILED BECAUSE no pindexnext\n"); + return false; } + } pindex = pindex->pnext; if (pindex->GeneratedStakeModifier()) @@ -314,82 +288,108 @@ static bool GetKernelStakeModifier(uint256 hashBlockFrom, uint64& nStakeModifier // quantities so as to generate blocks faster, degrading the system back into // a proof-of-work situation. // -bool CheckStakeKernelHash(unsigned int nBits, const CBlock& blockFrom, unsigned int nTxPrevOffset, const CTransaction& txPrev, const COutPoint& prevout, unsigned int nTimeTx, uint256& hashProofOfStake, bool fPrintProofOfStake) -{ - if (nTimeTx < txPrev.nTime) // Transaction timestamp violation - return error("CheckStakeKernelHash() : nTime violation"); - - unsigned int nTimeBlockFrom = blockFrom.GetBlockTime(); - if (nTimeBlockFrom + nStakeMinAge > nTimeTx) // Min age requirement - return error("CheckStakeKernelHash() : min age violation"); - - CBigNum bnTargetPerCoinDay; - bnTargetPerCoinDay.SetCompact(nBits); - int64 nValueIn = txPrev.vout[prevout.n].nValue; - - // v0.3 protocol kernel hash weight starts from 0 at the min age - // this change increases active coins participating the hash and helps - // to secure the network when proof-of-stake difficulty is low - int64 nTimeWeight = min((int64)nTimeTx - txPrev.nTime, (int64)nStakeMaxAge) - nStakeMinAge; - CBigNum bnCoinDayWeight = CBigNum(nValueIn) * nTimeWeight / COIN / (24 * 60 * 60); - - // printf(">>> CheckStakeKernelHash: nTimeWeight = %"PRI64d"\n", nTimeWeight); - // Calculate hash - CDataStream ss(SER_GETHASH, 0); - uint64 nStakeModifier = 0; - int nStakeModifierHeight = 0; - int64 nStakeModifierTime = 0; +/** Presstab - HyperStake hashing +I redesigned the hashing iteration in a few ways. +Code Reorginization - Instead of iterating the hashing in wallet.cpp, it is iterated in kernel.cpp inside of checkstakekernelhash, this allows +the iteration to not need to initialize the variables for every iteration. This is also true for the stake modifier, which was previously +calculated for each iteration. +liteStake - Previously the staking process would continuosly rehash the same hashes over and over, needlessly taking up valuable CPU power. +I have added a std::map that tracks the block height and the last time the wallet hashed on this height. Depending on your staking settings, +the wallet will not begin a new round of hashing until after a certain amount of time has passed, or a new block is accepted. This time delay +can be found in main.cpp bitcoinminer(). This means that there will be 1-5 seconds of hashing with the CPU once every few minutes, compared to +continued hashing with the CPU. +**/ +uint256 stakeHash(unsigned int nTimeTx, unsigned int nTxPrevTime, CDataStream ss, unsigned int prevoutIndex, unsigned int nTxPrevOffset, unsigned int nTimeBlockFrom) +{ + ss << nTimeBlockFrom << nTxPrevOffset << nTxPrevTime << prevoutIndex << nTimeTx; + return Hash(ss.begin(), ss.end()); +} +//HyperStake test hash vs target +bool stakeTargetHit(uint256 hashProofOfStake, unsigned int nAge, int64 nValueIn, CBigNum bnTargetPerCoinDay, CBigNum& bnCoinWeight) +{ + //get the stake weight + int64 nTimeWeight = min((int64)nAge, (int64)nStakeMaxAge) - nStakeMinAge; + bnCoinWeight = 0; + bnCoinWeight = CBigNum(nValueIn) * nTimeWeight / COIN / (24 * 60 * 60); + + // Now check if proof-of-stake hash meets target protocol + return (CBigNum(hashProofOfStake) < bnCoinWeight * bnTargetPerCoinDay); +} - if (!GetKernelStakeModifier(blockFrom.GetHash(), nStakeModifier, nStakeModifierHeight, nStakeModifierTime, fPrintProofOfStake)) +//instead of looping outside and reinitializing variables many times, we will give a nTimeTx and also search interval so that we can do all the hashing here +bool CheckStakeKernelHash(unsigned int nBits, const CBlock& blockFrom, unsigned int nTxPrevOffset, const CTransaction& txPrev, + const COutPoint& prevout, unsigned int& nTimeTx, unsigned int nHashDrift, bool fCheck, uint256& hashProofOfStake, CBigNum& bnCoinWeight, bool fPrintProofOfStake) +{ + //assign new variables to make it easier to read + int64 nValueIn = txPrev.vout[prevout.n].nValue; + unsigned int nTxPrevTime = txPrev.nTime; + unsigned int nTimeBlockFrom = blockFrom.GetBlockTime(); + + if (nTimeTx < txPrev.nTime) // Transaction timestamp violation + return error("CheckStakeKernelHash() : nTime violation"); + + if (nTimeBlockFrom + nStakeMinAge > nTimeTx) // Min age requirement + return error("CheckStakeKernelHash() : min age violation"); + + //grab difficulty + CBigNum bnTargetPerCoinDay; + bnTargetPerCoinDay.SetCompact(nBits); + + //grab stake modifier - HyperStake improves hashing by only grabbing this once per utxo + uint64 nStakeModifier = 0; + int nStakeModifierHeight = 0; + int64 nStakeModifierTime = 0; + if (!GetKernelStakeModifier(blockFrom.GetHash(), nStakeModifier, nStakeModifierHeight, nStakeModifierTime, fPrintProofOfStake)) + return false; + + //create data stream once instead of repeating it in the loop + CDataStream ss(SER_GETHASH, 0); + ss << nStakeModifier; + + //if wallet is simply checking to make sure a hash is valid + if(fCheck) { - // printf(">>> CheckStakeKernelHash: GetKernelStakeModifier return false\n"); - return false; + hashProofOfStake = stakeHash(nTimeTx, nTxPrevTime, ss, prevout.n, nTxPrevOffset, nTimeBlockFrom); + return stakeTargetHit(hashProofOfStake, (int64)nTimeTx - nTxPrevTime, nValueIn, bnTargetPerCoinDay, bnCoinWeight); } - // printf(">>> CheckStakeKernelHash: passed GetKernelStakeModifier\n"); - ss << nStakeModifier; - - ss << nTimeBlockFrom << nTxPrevOffset << txPrev.nTime << prevout.n << nTimeTx; - hashProofOfStake = Hash(ss.begin(), ss.end()); - if (fPrintProofOfStake) - { - printf("CheckStakeKernelHash() : using modifier 0x%016"PRI64x" at height=%d timestamp=%s for block from height=%d timestamp=%s\n", - nStakeModifier, nStakeModifierHeight, - DateTimeStrFormat(nStakeModifierTime).c_str(), - mapBlockIndex[blockFrom.GetHash()]->nHeight, - DateTimeStrFormat(blockFrom.GetBlockTime()).c_str()); - printf("CheckStakeKernelHash() : check protocol=%s modifier=0x%016"PRI64x" nTimeBlockFrom=%u nTxPrevOffset=%u nTimeTxPrev=%u nPrevout=%u nTimeTx=%u hashProof=%s\n", - "0.3", - nStakeModifier, - nTimeBlockFrom, nTxPrevOffset, txPrev.nTime, prevout.n, nTimeTx, - hashProofOfStake.ToString().c_str()); - } - - // Now check if proof-of-stake hash meets target protocol - if (CBigNum(hashProofOfStake) > bnCoinDayWeight * bnTargetPerCoinDay) + + bool fSuccess = false; + unsigned int nTryTime = 0; + unsigned int i; + for(i = 0; i < (nHashDrift); i++) //iterate the hashing { - // printf(">>> bnCoinDayWeight = %s, bnTargetPerCoinDay=%s\n", - // bnCoinDayWeight.ToString().c_str(), bnTargetPerCoinDay.ToString().c_str()); - // printf(">>> CheckStakeKernelHash - hashProofOfStake too much\n"); - return false; + fWalletStaking = true; + + //hash this iteration + nTryTime = nTimeTx + nHashDrift - i; + hashProofOfStake = stakeHash(nTryTime, nTxPrevTime, ss, prevout.n, nTxPrevOffset, nTimeBlockFrom); + + // if stake hash does not meet the target then continue to next iteration + if(!stakeTargetHit(hashProofOfStake, (int64)nTimeTx - nTxPrevTime, nValueIn, bnTargetPerCoinDay, bnCoinWeight)) + continue; + + fSuccess = true; // if we make it this far then we have successfully created a stake hash + nTimeTx = nTryTime; + + if (fDebug || fPrintProofOfStake) + { + printf("CheckStakeKernelHash() : using modifier 0x%016llu at height=%d timestamp=%s for block from height=%d timestamp=%s\n", + nStakeModifier, nStakeModifierHeight, + DateTimeStrFormat(nStakeModifierTime).c_str(), + mapBlockIndex[blockFrom.GetHash()]->nHeight, + DateTimeStrFormat(blockFrom.GetBlockTime()).c_str()); + printf("CheckStakeKernelHash() : pass protocol=%s modifier=0x%016llu nTimeBlockFrom=%u nTxPrevOffset=%u nTimeTxPrev=%u nPrevout=%u nTimeTx=%u hashProof=%s\n", + "0.3", + nStakeModifier, + nTimeBlockFrom, nTxPrevOffset, nTxPrevTime, prevout.n, nTryTime, + hashProofOfStake.ToString().c_str()); + } } - - - if (fDebug && !fPrintProofOfStake) - { - printf("CheckStakeKernelHash() : using modifier 0x%016"PRI64x" at height=%d timestamp=%s for block from height=%d timestamp=%s\n", - nStakeModifier, nStakeModifierHeight, - DateTimeStrFormat(nStakeModifierTime).c_str(), - mapBlockIndex[blockFrom.GetHash()]->nHeight, - DateTimeStrFormat(blockFrom.GetBlockTime()).c_str()); - printf("CheckStakeKernelHash() : pass protocol=%s modifier=0x%016"PRI64x" nTimeBlockFrom=%u nTxPrevOffset=%u nTimeTxPrev=%u nPrevout=%u nTimeTx=%u hashProof=%s\n", - "0.3", - nStakeModifier, - nTimeBlockFrom, nTxPrevOffset, txPrev.nTime, prevout.n, nTimeTx, - hashProofOfStake.ToString().c_str()); - } - return true; + mapHashedBlocks.clear(); + mapHashedBlocks[nBestHeight] = GetTime(); //store a time stamp of when we last hashed on this block + return fSuccess; } // Check kernel hash target and coinstake signature @@ -418,9 +418,10 @@ bool CheckProofOfStake(const CTransaction& tx, unsigned int nBits, uint256& hash if (!block.ReadFromDisk(txindex.pos.nFile, txindex.pos.nBlockPos, false)) return fDebug? error("CheckProofOfStake() : read block failed") : false; // unable to read block of previous transaction - - - if (!CheckStakeKernelHash(nBits, block, txindex.pos.nTxPos - txindex.pos.nBlockPos, txPrev, txin.prevout, tx.nTime, hashProofOfStake, fDebug)) + unsigned int nInterval = 0; + unsigned int nTxTime = tx.nTime; + CBigNum nCoinWeight = 0; + if (!CheckStakeKernelHash(nBits, block, txindex.pos.nTxPos - txindex.pos.nBlockPos, txPrev, txin.prevout, nTxTime, nInterval, true, hashProofOfStake, nCoinWeight, fDebug)) return tx.DoS(1, error("CheckProofOfStake() : INFO: check kernel failed on coinstake %s, hashProof=%s", tx.GetHash().ToString().c_str(), hashProofOfStake.ToString().c_str())); // may occur during initial download or if behind on block chain sync return true; @@ -436,6 +437,8 @@ bool CheckCoinStakeTimestamp(int64 nTimeBlock, int64 nTimeTx) // Get stake modifier checksum unsigned int GetStakeModifierChecksum(const CBlockIndex* pindex) { + if (!pindex->pprev) + printf("*** no pprev, version=%d height =%d hash=%s\n", pindex->nVersion, pindex->nHeight, pindex->GetBlockHash().GetHex().c_str()); assert (pindex->pprev || pindex->GetBlockHash() == (!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet)); // Hash previous checksum with flags, hashProofOfStake and nStakeModifier CDataStream ss(SER_GETHASH, 0); diff --git a/src/kernel.h b/src/kernel.h index c8e71d245..d6d1f7e44 100644 --- a/src/kernel.h +++ b/src/kernel.h @@ -7,10 +7,10 @@ #include "main.h" // MODIFIER_INTERVAL: time to elapse before new modifier is computed -static const unsigned int MODIFIER_INTERVAL = 6* 60* 60; -static const unsigned int MODIFIER_INTERVAL_NEW = 15 * 60; -static const unsigned int MODIFIER_INTERVAL_NEW_TESTNET = 60; +static const unsigned int MODIFIER_INTERVAL = 6* 60* 60; +static const unsigned int MODIFIER_INTERVAL_TESTNET = 60; extern unsigned int nModifierInterval; +extern unsigned int getIntervalVersion(bool fTestNet); // MODIFIER_INTERVAL_RATIO: // ratio of group interval length between the last group and the first group @@ -21,7 +21,10 @@ bool ComputeNextStakeModifier(const CBlockIndex* pindexPrev, uint64& nStakeModif // Check whether stake kernel meets hash target // Sets hashProofOfStake on success return -bool CheckStakeKernelHash(unsigned int nBits, const CBlock& blockFrom, unsigned int nTxPrevOffset, const CTransaction& txPrev, const COutPoint& prevout, unsigned int nTimeTx, uint256& hashProofOfStake, bool fPrintProofOfStake=false); +bool CheckStakeKernelHash(unsigned int nBits, const CBlock& blockFrom, unsigned int nTxPrevOffset, const CTransaction& txPrev, + const COutPoint& prevout, unsigned int& nTimeTx, unsigned int nInterval, bool fCheck, uint256& hashProofOfStake, CBigNum& bnCoinWeight, bool fPrintProofOfStake=false); +uint256 stakeHash(unsigned int nTimeTx, unsigned int nTxPrevTime, CDataStream ss, unsigned int prevoutIndex, unsigned int nTxPrevOffset, unsigned int nTimeBlockFrom); +bool stakeTargetHit(uint256 hashProofOfStake, unsigned int nAge, int64 nValueIn, CBigNum bnTargetPerCoinDay, CBigNum& bnCoinWeight); // Check kernel hash target and coinstake signature // Sets hashProofOfStake on success return diff --git a/src/key.cpp b/src/key.cpp index 23f315203..5417505c2 100644 --- a/src/key.cpp +++ b/src/key.cpp @@ -1,13 +1,18 @@ // Copyright (c) 2009-2012 The Bitcoin developers +// Copyright (c) 2011-2017 The Peercoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include +#if OPENSSL_VERSION_NUMBER < 0x10100000L #include +#endif + #include #include "key.h" +#include "bignum.h" // Generate a private key from just the secret parameter int EC_KEY_regenerate_key(EC_KEY *eckey, BIGNUM *priv_key) @@ -53,6 +58,14 @@ int ECDSA_SIG_recover_key_GFp(EC_KEY *eckey, ECDSA_SIG *ecsig, const unsigned ch { if (!eckey) return 0; + const BIGNUM *sig_r, *sig_s; + #if OPENSSL_VERSION_NUMBER > 0x1000ffffL + ECDSA_SIG_get0(ecsig, &sig_r, &sig_s); + #else + sig_r = ecsig->r; + sig_s = ecsig->s; + #endif + int ret = 0; BN_CTX *ctx = NULL; @@ -78,7 +91,7 @@ int ECDSA_SIG_recover_key_GFp(EC_KEY *eckey, ECDSA_SIG *ecsig, const unsigned ch x = BN_CTX_get(ctx); if (!BN_copy(x, order)) { ret=-1; goto err; } if (!BN_mul_word(x, i)) { ret=-1; goto err; } - if (!BN_add(x, x, ecsig->r)) { ret=-1; goto err; } + if (!BN_add(x, x, sig_r)) { ret=-1; goto err; } field = BN_CTX_get(ctx); if (!EC_GROUP_get_curve_GFp(group, field, NULL, NULL, ctx)) { ret=-2; goto err; } if (BN_cmp(x, field) >= 0) { ret=0; goto err; } @@ -99,9 +112,9 @@ int ECDSA_SIG_recover_key_GFp(EC_KEY *eckey, ECDSA_SIG *ecsig, const unsigned ch if (!BN_zero(zero)) { ret=-1; goto err; } if (!BN_mod_sub(e, zero, e, order, ctx)) { ret=-1; goto err; } rr = BN_CTX_get(ctx); - if (!BN_mod_inverse(rr, ecsig->r, order, ctx)) { ret=-1; goto err; } + if (!BN_mod_inverse(rr, sig_r, order, ctx)) { ret=-1; goto err; } sor = BN_CTX_get(ctx); - if (!BN_mod_mul(sor, ecsig->s, rr, order, ctx)) { ret=-1; goto err; } + if (!BN_mod_mul(sor, sig_s, rr, order, ctx)) { ret=-1; goto err; } eor = BN_CTX_get(ctx); if (!BN_mod_mul(eor, e, rr, order, ctx)) { ret=-1; goto err; } if (!EC_POINT_mul(group, Q, eor, R, sor, ctx)) { ret=-2; goto err; } @@ -183,10 +196,9 @@ void CKey::MakeNewKey(bool fCompressed) fSet = true; } -bool CKey::SetPrivKey(const CPrivKey& vchPrivKey) +bool CKey::SetPrivKey(const unsigned char* pbegin, unsigned int size) { - const unsigned char* pbegin = &vchPrivKey[0]; - if (d2i_ECPrivateKey(&pkey, &pbegin, vchPrivKey.size())) + if (d2i_ECPrivateKey(&pkey, &pbegin, size)) { // In testing, d2i_ECPrivateKey can return true // but fill in pkey with a key that fails @@ -206,6 +218,11 @@ bool CKey::SetPrivKey(const CPrivKey& vchPrivKey) return false; } +bool CKey::SetPrivKey(const CPrivKey& vchPrivKey) +{ + return SetPrivKey(&vchPrivKey[0], vchPrivKey.size()); +} + bool CKey::SetSecret(const CSecret& vchSecret, bool fCompressed) { EC_KEY_free(pkey); @@ -256,6 +273,41 @@ CPrivKey CKey::GetPrivKey() const return vchPrivKey; } +uint256 CKey::GetPrivKey_256() const +{ + bool fCompressed; + CSecret pk = GetSecret(fCompressed); + const BIGNUM* big = EC_KEY_get0_private_key(pkey); + void* vp = (void*)big; + CBigNum* bnPriv = (CBigNum*)vp; + + return bnPriv->getuint256(); +} + +bool CKey::SetPrivKey_Raw(const uint256& privKey, bool fCompressed) +{ + CBigNum bnPrivKey(privKey); + void* vp = (void*)&bnPrivKey; + BIGNUM* bn = (BIGNUM*)vp; + + EC_KEY_free(pkey); + pkey = EC_KEY_new_by_curve_name(NID_secp256k1); + if (pkey == NULL) + throw key_error("CKey::SetSecret() : EC_KEY_new_by_curve_name failed"); + if (bn == NULL) + throw key_error("CKey::SetSecret() : BN_bin2bn failed"); + if (!EC_KEY_regenerate_key(pkey,bn)) + { + BN_clear_free(bn); + throw key_error("CKey::SetSecret() : EC_KEY_regenerate_key failed"); + } + BN_clear_free(bn); + fSet = true; + if (fCompressed || fCompressedPubKey) + SetCompressedPubKey(); + return true; +} + bool CKey::SetPubKey(const CPubKey& vchPubKey) { const unsigned char* pbegin = &vchPubKey.vchPubKey[0]; @@ -308,8 +360,17 @@ bool CKey::SignCompact(uint256 hash, std::vector& vchSig) return false; vchSig.clear(); vchSig.resize(65,0); - int nBitsR = BN_num_bits(sig->r); - int nBitsS = BN_num_bits(sig->s); + + const BIGNUM *sig_r, *sig_s; + #if OPENSSL_VERSION_NUMBER > 0x1000ffffL + ECDSA_SIG_get0(sig, &sig_r, &sig_s); + #else + sig_r = sig->r; + sig_s = sig->s; + #endif + + int nBitsR = BN_num_bits(sig_r); + int nBitsS = BN_num_bits(sig_s); if (nBitsR <= 256 && nBitsS <= 256) { int nRecId = -1; @@ -328,11 +389,14 @@ bool CKey::SignCompact(uint256 hash, std::vector& vchSig) } if (nRecId == -1) + { + ECDSA_SIG_free(sig); throw key_error("CKey::SignCompact() : unable to construct recoverable key"); - + } + vchSig[0] = nRecId+27+(fCompressedPubKey ? 4 : 0); - BN_bn2bin(sig->r,&vchSig[33-(nBitsR+7)/8]); - BN_bn2bin(sig->s,&vchSig[65-(nBitsS+7)/8]); + BN_bn2bin(sig_r,&vchSig[33-(nBitsR+7)/8]); + BN_bn2bin(sig_s,&vchSig[65-(nBitsS+7)/8]); fOk = true; } ECDSA_SIG_free(sig); @@ -351,8 +415,19 @@ bool CKey::SetCompactSignature(uint256 hash, const std::vector& v if (nV<27 || nV>=35) return false; ECDSA_SIG *sig = ECDSA_SIG_new(); + if (!sig) return false; + + #if OPENSSL_VERSION_NUMBER > 0x1000ffffL + // sig_r and sig_s are deallocated by ECDSA_SIG_free(sig); + BIGNUM *sig_r = BN_bin2bn(&vchSig[1],32,BN_new()); + BIGNUM *sig_s = BN_bin2bn(&vchSig[33],32,BN_new()); + if (!sig_r || !sig_s) return false; + // copy and transfer ownership to sig + ECDSA_SIG_set0(sig, sig_r, sig_s); + #else BN_bin2bn(&vchSig[1],32,sig->r); BN_bin2bn(&vchSig[33],32,sig->s); + #endif EC_KEY_free(pkey); pkey = EC_KEY_new_by_curve_name(NID_secp256k1); @@ -367,16 +442,60 @@ bool CKey::SetCompactSignature(uint256 hash, const std::vector& v ECDSA_SIG_free(sig); return true; } + ECDSA_SIG_free(sig); return false; } -bool CKey::Verify(uint256 hash, const std::vector& vchSig) +bool CKey::Verify(uint256 hash, const std::vector& vchSigParam) { - // -1 = error, 0 = bad sig, 1 = good - if (ECDSA_verify(0, (unsigned char*)&hash, sizeof(hash), &vchSig[0], vchSig.size(), pkey) != 1) + // Prevent the problem described here: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2015-July/009697.html + // by removing the extra length bytes + std::vector vchSig(vchSigParam.begin(), vchSigParam.end()); + if (int(vchSig.size()) > 1 && vchSig[1] & 0x80) + { + unsigned char nLengthBytes = vchSig[1] & 0x7f; + + if (int(vchSig.size()) < 2 + nLengthBytes) + return false; + + if (nLengthBytes > 4) + { + unsigned char nExtraBytes = nLengthBytes - 4; + for (unsigned char i = 0; i < nExtraBytes; i++) + if (vchSig[2 + i]) + return false; + vchSig.erase(vchSig.begin() + 2, vchSig.begin() + 2 + nExtraBytes); + vchSig[1] = 0x80 | (nLengthBytes - nExtraBytes); + } + } + if (vchSig.empty()) return false; - return true; + // New versions of OpenSSL will reject non-canonical DER signatures. de/re-serialize first. + unsigned char *norm_der = NULL; + ECDSA_SIG *norm_sig = ECDSA_SIG_new(); + const unsigned char* sigptr = &vchSig[0]; + assert(norm_sig); + if (d2i_ECDSA_SIG(&norm_sig, &sigptr, vchSig.size()) == NULL) + { + /* As of OpenSSL 1.0.0p d2i_ECDSA_SIG frees and nulls the pointer on + * error. But OpenSSL's own use of this function redundantly frees the + * result. As ECDSA_SIG_free(NULL) is a no-op, and in the absence of a + * clear contract for the function behaving the same way is more + * conservative. + */ + ECDSA_SIG_free(norm_sig); + return false; + } + int derlen = i2d_ECDSA_SIG(norm_sig, &norm_der); + ECDSA_SIG_free(norm_sig); + if (derlen <= 0) + return false; + + // -1 = error, 0 = bad sig, 1 = good + bool ret = ECDSA_verify(0, (unsigned char*)&hash, sizeof(hash), norm_der, derlen, pkey) == 1; + OPENSSL_free(norm_der); + return ret; } bool CKey::VerifyCompact(uint256 hash, const std::vector& vchSig) diff --git a/src/key.h b/src/key.h index c98f52ed0..02f2cbc11 100644 --- a/src/key.h +++ b/src/key.h @@ -1,5 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2012 The Bitcoin developers +// Copyright (c) 2011-2017 The Peercoin developers // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. #ifndef BITCOIN_KEY_H @@ -13,7 +14,7 @@ #include "uint256.h" #include "util.h" -#include // for EC_KEY definition +#include // secp160k1 // const unsigned int PRIVATE_KEY_SIZE = 192; @@ -66,6 +67,22 @@ class CPubKey { std::vector vchPubKey; friend class CKey; + //! Compute the length of a pubkey with a given first byte. + unsigned int static GetLen(unsigned char chHeader) + { + if (chHeader == 2 || chHeader == 3) + return 33; + if (chHeader == 4 || chHeader == 6 || chHeader == 7) + return 65; + return 0; + } + + //! Set this key data to be invalid + void Invalidate() + { + vchPubKey[0] = 0xFF; + } + public: CPubKey() { } CPubKey(const std::vector &vchPubKeyIn) : vchPubKey(vchPubKeyIn) { } @@ -73,6 +90,10 @@ class CPubKey { friend bool operator!=(const CPubKey &a, const CPubKey &b) { return a.vchPubKey != b.vchPubKey; } friend bool operator<(const CPubKey &a, const CPubKey &b) { return a.vchPubKey < b.vchPubKey; } + unsigned int size() const { return GetLen(vchPubKey[0]); } + const unsigned char* begin() const { return static_cast(&vchPubKey[0]); } + const unsigned char* end() const { return begin() + size(); } + IMPLEMENT_SERIALIZE( READWRITE(vchPubKey); ) @@ -96,6 +117,23 @@ class CPubKey { std::vector Raw() const { return vchPubKey; } + + //! Initialize a public key using begin/end iterators to byte data. + template + void Set(const T pbegin, const T pend) + { + unsigned int len = pend == pbegin ? 0 : GetLen(pbegin[0]); + if (len && len == (pend - pbegin)) { + //memcpy(vchPubKey, (unsigned char*)&pbegin[0], len); + vchPubKey.clear(); + for(unsigned int i = 0; i < len; ++i) + { + vchPubKey[i] = pbegin[i]; + } + } + else + Invalidate(); + } }; @@ -130,10 +168,13 @@ class CKey bool IsCompressed() const; void MakeNewKey(bool fCompressed); + bool SetPrivKey(const unsigned char* pbegin, unsigned int size); bool SetPrivKey(const CPrivKey& vchPrivKey); + bool SetPrivKey_Raw(const uint256& privKey, bool fCompressed); bool SetSecret(const CSecret& vchSecret, bool fCompressed = false); CSecret GetSecret(bool &fCompressed) const; CPrivKey GetPrivKey() const; + uint256 GetPrivKey_256() const; bool SetPubKey(const CPubKey& vchPubKey); CPubKey GetPubKey() const; diff --git a/src/main.cpp b/src/main.cpp index df5b84856..1bd9460d3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,6 +11,8 @@ #include "ui_interface.h" #include "kernel.h" #include "scrypt_mine.h" +#include "votetally.h" +#include "voteproposalmanager.h" #include #include #include @@ -43,7 +45,8 @@ static CBigNum bnProofOfStakeLimit(~uint256(0) >> 20); static CBigNum bnProofOfWorkLimitTestNet(~uint256(0) >> 20); static CBigNum bnProofOfStakeLimitTestNet(~uint256(0) >> 20); -unsigned int nStakeMinAge = 60 * 60 * 8; // minimum age for coin age: 3h +unsigned int nStakeMinAge = 60 * 60 * 8; // time at which weight begins to build +unsigned int nStakeMinAgeV2 = 60 * 60 * 24 * 88 / 10; // functionally the minimum age is 8.8 days unsigned int nStakeMaxAge = 60 * 60 * 24 * 30; // stake age of full weight: -1 unsigned int nStakeTargetSpacing = 90; // 90 sec block spacing @@ -56,6 +59,7 @@ CBigNum bnBestInvalidTrust = 0; uint256 hashBestChain = 0; CBlockIndex* pindexBest = NULL; int64 nTimeBestReceived = 0; +bool fHaveGUI = false; CMedianFilter cPeerBlockCounts(5, 0); // Amount of blocks that other nodes claim to have @@ -66,6 +70,16 @@ map mapProofOfStake; map mapOrphanTransactions; map > mapOrphanTransactionsByPrev; +map mapHashedBlocks; +map > mapGetBlocksRequests; +std::map mapPeerRejectedBlocks; +std::map mapProposals; //txid, proposal hash +std::map mapPendingProposals; +bool fStrictProtocol = false; +bool fStrictIncoming = false; +bool fWalletStaking = false; + +CVoteProposalManager proposalManager; // Constant stuff for coinbase transactions we create: CScript COINBASE_FLAGS; @@ -208,7 +222,7 @@ bool AddOrphanTx(const CDataStream& vMsg) // at most 500 megabytes of orphans: if (pvMsg->size() > 5000) { - printf("ignoring large orphan tx (size: %"PRIszu", hash: %s)\n", pvMsg->size(), hash.ToString().substr(0,10).c_str()); + printf("ignoring large orphan tx (size: %lu, hash: %s)\n", pvMsg->size(), hash.ToString().substr(0,10).c_str()); delete pvMsg; return false; } @@ -217,7 +231,7 @@ bool AddOrphanTx(const CDataStream& vMsg) BOOST_FOREACH(const CTxIn& txin, tx.vin) mapOrphanTransactionsByPrev[txin.prevout.hash].insert(make_pair(hash, pvMsg)); - printf("stored orphan tx %s (mapsz %"PRIszu")\n", hash.ToString().substr(0,10).c_str(), + printf("stored orphan tx %s (mapsz %lu)\n", hash.ToString().substr(0,10).c_str(), mapOrphanTransactions.size()); return true; } @@ -314,6 +328,23 @@ bool CTransaction::IsStandard() const return true; } +bool CTransaction::IsProposal() const +{ + for (unsigned int i = 0; i < vout.size(); i++) { + CScript scriptPubKey = vout[i].scriptPubKey; + if (scriptPubKey.IsDataCarrier()) { + if (scriptPubKey.size() >= 5) { + // "PROP" in ascii + if (scriptPubKey.at(2) == 0x70 && scriptPubKey.at(3) == 0x72 && scriptPubKey.at(4) == 0x6f && + scriptPubKey.at(5) == 0x70) + return true; + } + } + } + + return false; +} + // // Check transaction inputs, and make sure any // pay-to-script-hash transactions are evaluating IsStandard scripts @@ -531,7 +562,7 @@ int64 CTransaction::GetMinFee(unsigned int nBlockSize, bool fAllowFree, if (!MoneyRange(nMinFee)) nMinFee = MAX_MONEY; - return nMinFee; + return max(nMinFee, MIN_TX_FEE); } @@ -627,7 +658,7 @@ bool CTxMemPool::accept(CTxDB& txdb, CTransaction &tx, bool fCheckInputs, // Don't accept it if it can't get into a block int64 txMinFee = tx.GetMinFee(1000, false, GMF_RELAY, nSize); if (nFees < txMinFee) - return error("CTxMemPool::accept() : not enough fees %s, %"PRI64d" < %"PRI64d, + return error("CTxMemPool::accept() : not enough fees %s, %lld < %lld", hash.ToString().c_str(), nFees, txMinFee); @@ -680,7 +711,18 @@ bool CTxMemPool::accept(CTxDB& txdb, CTransaction &tx, bool fCheckInputs, if (ptxOld) EraseFromWallets(ptxOld->GetHash()); - printf("CTxMemPool::accept() : accepted %s (poolsz %"PRIszu")\n", + // If the transaction is a proposal then verify validity + if (tx.IsProposal()) { + CVoteProposal proposal; + ProposalFromTransaction(tx, proposal); + + // Verify that the proposal is valid + if(!proposalManager.CheckProposal(proposal)) { + return error("CTxMemPool::accept() : Invalid Proposal %s", hash.ToString().substr(0,10).c_str()); + } + } + + printf("CTxMemPool::accept() : accepted %s (poolsz %lu)\n", hash.ToString().substr(0,10).c_str(), mapTx.size()); return true; @@ -905,9 +947,20 @@ bool CBlock::ReadFromDisk(const CBlockIndex* pindex, bool fReadTransactions) return false; if (GetHash() != pindex->GetBlockHash()) return error("CBlock::ReadFromDisk() : GetHash() doesn't match index"); + + this->hashBlock = pindex->GetBlockHash(); + return true; } +uint256 CBlock::GetHash() const +{ + if (hashBlock != 0) + return hashBlock; + + return Hash9(BEGIN(nVersion), END(nNonce)); +} + uint256 static GetOrphanRoot(const CBlock* pblock) { @@ -941,16 +994,22 @@ static const int CUTOFF_HEIGHT = POW_CUTOFF_HEIGHT; // miner's coin base reward based on nBits int64 GetProofOfWorkReward(int nHeight, int64 nFees, uint256 prevHash) { - int64 nSubsidy = 500 * COIN; - + int64 nSubsidy = 0; + if(fTestNet) + { + if(nHeight == 1) + nSubsidy = 50000000 * COIN; // 50 million premine for testnet so we can be rich + else + nSubsidy = 1000 * COIN; + return nSubsidy + nFees; + } + + nSubsidy = 500 * COIN; if(nHeight == 1) { nSubsidy = 120000 * COIN; return nSubsidy + nFees; } - - - return nSubsidy + nFees; } @@ -978,7 +1037,7 @@ int64 GetProofOfStakeRewardV1(int64 nCoinAge, unsigned int nBits, unsigned int n int64 nSubsidy = nCoinAge * nRewardCoinYear / 365; if (fDebug && GetBoolArg("-printcreation")) - printf("GetProofOfStakeReward(): create=%s nCoinAge=%"PRI64d" nBits=%d\n", FormatMoney(nSubsidy).c_str(), nCoinAge, nBits); + printf("GetProofOfStakeReward(): create=%s nCoinAge=%lld nBits=%d\n", FormatMoney(nSubsidy).c_str(), nCoinAge, nBits); return nSubsidy; } @@ -991,7 +1050,7 @@ int64 GetProofOfStakeRewardV2(int64 nCoinAge, unsigned int nBits, unsigned int n int64 nSubsidy = nCoinAge * nRewardCoinYear / 365; if (fDebug && GetBoolArg("-printcreation")) - printf("GetProofOfStakeReward(): create=%s nCoinAge=%"PRI64d" nBits=%d\n", FormatMoney(nSubsidy).c_str(), nCoinAge, nBits); + printf("GetProofOfStakeReward(): create=%s nCoinAge=%lld nBits=%d\n", FormatMoney(nSubsidy).c_str(), nCoinAge, nBits); nSubsidy = min(nSubsidy, nSubsidyLimit); @@ -1071,12 +1130,12 @@ unsigned int GetNextTargetRequired(const CBlockIndex* pindexLast, bool fProofOfS int64 nActualSpacing = pindexPrev->GetBlockTime() - pindexPrevPrev->GetBlockTime(); if(nActualSpacing < 0) { - // printf(">> nActualSpacing = %"PRI64d" corrected to 1.\n", nActualSpacing); + // printf(">> nActualSpacing = %lld corrected to 1.\n", nActualSpacing); nActualSpacing = 1; } else if(nActualSpacing > nTargetTimespan) { - // printf(">> nActualSpacing = %"PRI64d" corrected to nTargetTimespan (900).\n", nActualSpacing); + // printf(">> nActualSpacing = %lld corrected to nTargetTimespan (900).\n", nActualSpacing); nActualSpacing = nTargetTimespan; } @@ -1091,9 +1150,9 @@ unsigned int GetNextTargetRequired(const CBlockIndex* pindexLast, bool fProofOfS bnNew /= ((nInterval + 1) * nTargetSpacing); /* - printf(">> Height = %d, fProofOfStake = %d, nInterval = %"PRI64d", nTargetSpacing = %"PRI64d", nActualSpacing = %"PRI64d"\n", + printf(">> Height = %d, fProofOfStake = %d, nInterval = %lld, nTargetSpacing = %lld, nActualSpacing = %lld\n", pindexPrev->nHeight, fProofOfStake, nInterval, nTargetSpacing, nActualSpacing); - printf(">> pindexPrev->GetBlockTime() = %"PRI64d", pindexPrev->nHeight = %d, pindexPrevPrev->GetBlockTime() = %"PRI64d", pindexPrevPrev->nHeight = %d\n", + printf(">> pindexPrev->GetBlockTime() = %lld, pindexPrev->nHeight = %d, pindexPrevPrev->GetBlockTime() = %lld, pindexPrevPrev->nHeight = %d\n", pindexPrev->GetBlockTime(), pindexPrev->nHeight, pindexPrevPrev->GetBlockTime(), pindexPrevPrev->nHeight); */ @@ -1269,7 +1328,7 @@ bool CTransaction::FetchInputs(CTxDB& txdb, const map& mapTes // Revisit this if/when transaction replacement is implemented and allows // adding inputs: fInvalid = true; - return DoS(100, error("FetchInputs() : %s prevout.n out of range %d %"PRIszu" %"PRIszu" prev tx %s\n%s", GetHash().ToString().substr(0,10).c_str(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString().substr(0,10).c_str(), txPrev.ToString().c_str())); + return DoS(100, error("FetchInputs() : %s prevout.n out of range %d %lu %lu prev tx %s\n%s", GetHash().ToString().substr(0,10).c_str(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString().substr(0,10).c_str(), txPrev.ToString().c_str())); } } @@ -1342,7 +1401,7 @@ bool CTransaction::ConnectInputs(CTxDB& txdb, MapPrevTx inputs, CTransaction& txPrev = inputs[prevout.hash].second; if (prevout.n >= txPrev.vout.size() || prevout.n >= txindex.vSpent.size()) - return DoS(100, error("ConnectInputs() : %s prevout.n out of range %d %"PRIszu" %"PRIszu" prev tx %s\n%s", GetHash().ToString().substr(0,10).c_str(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString().substr(0,10).c_str(), txPrev.ToString().c_str())); + return DoS(100, error("ConnectInputs() : %s prevout.n out of range %d %lu %lu prev tx %s\n%s", GetHash().ToString().substr(0,10).c_str(), prevout.n, txPrev.vout.size(), txindex.vSpent.size(), prevout.hash.ToString().substr(0,10).c_str(), txPrev.ToString().c_str())); // If prev is coinbase or coinstake, check that it's matured if (txPrev.IsCoinBase() || txPrev.IsCoinStake()) @@ -1510,7 +1569,8 @@ bool CBlock::DisconnectBlock(CTxDB& txdb, CBlockIndex* pindex) bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck) { // Check it again in case a previous version let a bad block in - if (!CheckBlock(!fJustCheck, !fJustCheck)) + bool fFullCheck = pindex->nHeight >= Checkpoints::GetTotalBlocksEstimate(); + if (!CheckBlock(!fJustCheck, !fJustCheck, fFullCheck)) return false; // Do not allow blocks that contain transactions which 'overwrite' older transactions, @@ -1537,19 +1597,19 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck) else nTxPos = pindex->nBlockPos + ::GetSerializeSize(CBlock(), SER_DISK, CLIENT_VERSION) - (2 * GetSizeOfCompactSize(0)) + GetSizeOfCompactSize(vtx.size()); + vector vQueuedProposals; map mapQueuedChanges; int64 nFees = 0; int64 nValueIn = 0; int64 nValueOut = 0; unsigned int nSigOps = 0; - BOOST_FOREACH(CTransaction& tx, vtx) - { + for (CTransaction& tx : vtx) { uint256 hashTx = tx.GetHash(); if (fEnforceBIP30) { CTxIndex txindexOld; if (txdb.ReadTxIndex(hashTx, txindexOld)) { - BOOST_FOREACH(CDiskTxPos &pos, txindexOld.vSpent) + for (CDiskTxPos &pos : txindexOld.vSpent) if (pos.IsNull()) return false; } @@ -1591,6 +1651,13 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck) if (!tx.ConnectInputs(txdb, mapInputs, mapQueuedChanges, posThisTx, pindex, true, false, fStrictPayToScriptHash)) return false; + + //Track vote proposals + if (tx.IsProposal()) { + //Needs to have the proper fee or else it will not be counted + if (nTxValueIn - nTxValueOut >= CVoteProposal::FEE - MIN_TXOUT_AMOUNT) + vQueuedProposals.push_back(hashTx); + } } mapQueuedChanges[hashTx] = CTxIndex(posThisTx, tx.vout.size()); @@ -1599,30 +1666,55 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck) // ppcoin: track money supply and mint amount info pindex->nMint = nValueOut - nValueIn + nFees; pindex->nMoneySupply = (pindex->pprev? pindex->pprev->nMoneySupply : 0) + nValueOut - nValueIn; - if (!txdb.WriteBlockIndex(CDiskBlockIndex(pindex))) - return error("Connect() : WriteBlockIndex for pindex failed"); // ppcoin: fees are not collected by miners as in bitcoin // ppcoin: fees are destroyed to compensate the entire network if (fDebug && GetBoolArg("-printcreation")) - printf("ConnectBlock() : destroy=%s nFees=%"PRI64d"\n", FormatMoney(nFees).c_str(), nFees); + printf("ConnectBlock() : destroy=%s nFees=%lld\n", FormatMoney(nFees).c_str(), nFees); if (fJustCheck) return true; + // Keep track of any vote proposals that were added to the blockchain + CVoteDB voteDB; + if (vQueuedProposals.size()) { + for (const CTransaction& tx : vtx) { + uint256 txid = tx.GetHash(); + if (count(vQueuedProposals.begin(), vQueuedProposals.end(), txid)) { + CVoteProposal proposal; + if (ProposalFromTransaction(tx, proposal)) { + mapProposals[txid] = proposal.GetHash(); + if (!voteDB.WriteProposal(txid, proposal)) + printf("%s : failed to record proposal to db\n", __func__); + else if (!proposalManager.Add(proposal)) + printf("%s: failed to add proposal %s to manager\n", __func__, txid.GetHex().c_str()); + } + } + } + } + + //Record new votes to the tally + if (pindex->pprev) { + if (fTestNet || pindex->nHeight >= (int)VOTING_START) + pindex->tally = CVoteTally(pindex->pprev->tally); + std::map mapActive = proposalManager.GetActive(pindex->nHeight); + pindex->tally.SetNewPositions(mapActive); + pindex->tally.ProcessNewVotes(static_cast(pindex->nVersion)); + } + + //Write index to disk + if (!txdb.WriteBlockIndex(CDiskBlockIndex(pindex))) + return error("Connect() : WriteBlockIndex for pindex failed"); + // Write queued txindex changes - for (map::iterator mi = mapQueuedChanges.begin(); mi != mapQueuedChanges.end(); ++mi) - { + for (auto mi = mapQueuedChanges.begin(); mi != mapQueuedChanges.end(); ++mi) { if (!txdb.UpdateTxIndex((*mi).first, (*mi).second)) return error("ConnectBlock() : UpdateTxIndex failed"); } uint256 prevHash = 0; if(pindex->pprev) - { prevHash = pindex->pprev->GetBlockHash(); - // printf("==> Got prevHash = %s\n", prevHash.ToString().c_str()); - } if (vtx[0].GetValueOut() > GetProofOfWorkReward(pindex->nHeight, nFees, prevHash)) return false; @@ -1638,7 +1730,7 @@ bool CBlock::ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck) } // Watch for transactions paying to me - BOOST_FOREACH(CTransaction& tx, vtx) + for (CTransaction& tx : vtx) SyncWithWallets(tx, this, true); return true; @@ -1673,8 +1765,8 @@ bool static Reorganize(CTxDB& txdb, CBlockIndex* pindexNew) vConnect.push_back(pindex); reverse(vConnect.begin(), vConnect.end()); - printf("REORGANIZE: Disconnect %"PRIszu" blocks; %s..%s\n", vDisconnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexBest->GetBlockHash().ToString().substr(0,20).c_str()); - printf("REORGANIZE: Connect %"PRIszu" blocks; %s..%s\n", vConnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexNew->GetBlockHash().ToString().substr(0,20).c_str()); + printf("REORGANIZE: Disconnect %lu blocks; %s..%s\n", vDisconnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexBest->GetBlockHash().ToString().substr(0,20).c_str()); + printf("REORGANIZE: Connect %lu blocks; %s..%s\n", vConnect.size(), pfork->GetBlockHash().ToString().substr(0,20).c_str(), pindexNew->GetBlockHash().ToString().substr(0,20).c_str()); // Disconnect shorter branch vector vResurrect; @@ -1740,6 +1832,30 @@ bool static Reorganize(CTxDB& txdb, CBlockIndex* pindexNew) return true; } +void CBlock::print() const +{ + std::stringstream ss; + ss << "CBlock(hash=" + << GetHash().ToString().c_str() + << " ver = " << ReverseEndianString(HexStr(BEGIN(nVersion), END(nVersion))).c_str() + << " hashPrevBlock = " << hashPrevBlock.ToString().c_str() + << " hasMerkleRoot = " << hashMerkleRoot.ToString().c_str() + << " nTime = " << nTime + << " nBits = " << nBits + << " nNonce = " << nNonce + << " vtx = " << vtx.size() + << " vhcBlockSig = " << HexStr(vchBlockSig.begin(), vchBlockSig.end()).c_str(); + printf("%s ", ss.str().c_str()); + for (unsigned int i = 0; i < vtx.size(); i++) + { + printf(" "); + vtx[i].print(); + } + printf(" vMerkleTree: "); + for (unsigned int i = 0; i < vMerkleTree.size(); i++) + printf("%s ", vMerkleTree[i].ToString().substr(0,10).c_str()); + printf("\n"); +} // Called from inside SetBestChain: attaches a block to the new best chain being built bool CBlock::SetBestChainInner(CTxDB& txdb, CBlockIndex *pindexNew) @@ -1803,7 +1919,7 @@ bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew) } if (!vpindexSecondary.empty()) - printf("Postponing %"PRIszu" reconnects\n", vpindexSecondary.size()); + printf("Postponing %lu reconnects\n", vpindexSecondary.size()); // Switch to new best branch if (!Reorganize(txdb, pindexIntermediate)) @@ -1855,22 +1971,22 @@ bool CBlock::SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew) printf("Stake checkpoint: %x\n", pindexBest->nStakeModifierChecksum); // Check the version of the last 100 blocks to see if we need to upgrade: - if (!fIsInitialDownload) - { - int nUpgraded = 0; - const CBlockIndex* pindex = pindexBest; - for (int i = 0; i < 100 && pindex != NULL; i++) - { - if (pindex->nVersion > CBlock::CURRENT_VERSION) - ++nUpgraded; - pindex = pindex->pprev; - } - if (nUpgraded > 0) - printf("SetBestChain: %d of last 100 blocks above version %d\n", nUpgraded, CBlock::CURRENT_VERSION); - if (nUpgraded > 100/2) - // strMiscWarning is read by GetWarnings(), called by Qt and the JSON-RPC code to warn the user: - strMiscWarning = _("Warning: This version is obsolete, upgrade required!"); - } +// if (!fIsInitialDownload) +// { +// int nUpgraded = 0; +// const CBlockIndex* pindex = pindexBest; +// for (int i = 0; i < 100 && pindex != NULL; i++) +// { +// if (pindex->nVersion > CBlock::CURRENT_VERSION) +// ++nUpgraded; +// pindex = pindex->pprev; +// } +// if (nUpgraded > 0) +// printf("SetBestChain: %d of last 100 blocks above version %d\n", nUpgraded, CBlock::CURRENT_VERSION); +// if (nUpgraded > 100/2) +// // strMiscWarning is read by GetWarnings(), called by Qt and the JSON-RPC code to warn the user: +// strMiscWarning = _("Warning: This version is obsolete, upgrade required!"); +// } std::string strCmd = GetArg("-blocknotify", ""); @@ -1906,7 +2022,10 @@ bool CTransaction::GetCoinAge(CTxDB& txdb, uint64& nCoinAge) const if (!txPrev.ReadFromDisk(txdb, txin.prevout, txindex)) continue; // previous transaction not in main chain if (nTime < txPrev.nTime) + { + printf("GetCoinAge: Timestamp Violation: txtime less than txPrev.nTime"); return false; // Transaction timestamp violation + } // Read block header CBlock block; @@ -1919,7 +2038,7 @@ bool CTransaction::GetCoinAge(CTxDB& txdb, uint64& nCoinAge) const bnCentSecond += CBigNum(nValueIn) * (nTime-txPrev.nTime) / CENT; if (fDebug && GetBoolArg("-printcoinage")) - printf("coin age nValueIn=%"PRI64d" nTimeDiff=%d bnCentSecond=%s\n", nValueIn, nTime - txPrev.nTime, bnCentSecond.ToString().c_str()); + printf("coin age nValueIn=%lld nTimeDiff=%d bnCentSecond=%s\n", nValueIn, nTime - txPrev.nTime, bnCentSecond.ToString().c_str()); } CBigNum bnCoinDay = bnCentSecond * CENT / COIN / (24 * 60 * 60); @@ -1947,7 +2066,7 @@ bool CBlock::GetCoinAge(uint64& nCoinAge) const if (nCoinAge == 0) // block coin age minimum 1 coin-day nCoinAge = 1; if (fDebug && GetBoolArg("-printcoinage")) - printf("block coin age total nCoinDays=%"PRI64d"\n", nCoinAge); + printf("block coin age total nCoinDays=%lld\n", nCoinAge); return true; } @@ -1993,7 +2112,7 @@ bool CBlock::AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos) pindexNew->SetStakeModifier(nStakeModifier, fGeneratedStakeModifier); pindexNew->nStakeModifierChecksum = GetStakeModifierChecksum(pindexNew); if (!CheckStakeModifierCheckpoints(pindexNew->nHeight, pindexNew->nStakeModifierChecksum)) - return error("AddToBlockIndex() : Rejected by stake modifier checkpoint height=%d, modifier=0x%016"PRI64x, pindexNew->nHeight, nStakeModifier); + return error("AddToBlockIndex() : Rejected by stake modifier checkpoint height=%d, modifier=0x%016llu", pindexNew->nHeight, nStakeModifier); // Add to mapBlockIndex map::iterator mi = mapBlockIndex.insert(make_pair(hash, pindexNew)).first; @@ -2029,7 +2148,7 @@ bool CBlock::AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos) } -bool CBlock::CheckBlock(bool fCheckPOW, bool fCheckMerkleRoot) const +bool CBlock::CheckBlock(bool fCheckPOW, bool fCheckMerkleRoot, bool fFullCheck) const { // These are checks that are independent of context // that can be verified before saving an orphan block. @@ -2042,7 +2161,7 @@ bool CBlock::CheckBlock(bool fCheckPOW, bool fCheckMerkleRoot) const return DoS(50, error("CheckBlock() : proof of work failed")); // Check timestamp - if (GetBlockTime() > GetAdjustedTime() + nMaxClockDrift) + if (GetBlockTime() > GetAdjustedTime() + GetClockDrift(GetBlockTime())) return error("CheckBlock() : block timestamp too far in the future"); // First transaction must be coinbase, the rest must not be @@ -2062,39 +2181,36 @@ bool CBlock::CheckBlock(bool fCheckPOW, bool fCheckMerkleRoot) const return error("CheckBlock() : coinbase output not empty for proof-of-stake block"); // Check coinbase timestamp - if (GetBlockTime() > (int64)vtx[0].nTime + nMaxClockDrift) + if (GetBlockTime() > (int64)vtx[0].nTime + GetClockDrift(GetBlockTime())) return DoS(50, error("CheckBlock() : coinbase timestamp is too early")); // Check coinstake timestamp if (IsProofOfStake() && !CheckCoinStakeTimestamp(GetBlockTime(), (int64)vtx[1].nTime)) - return DoS(50, error("CheckBlock() : coinstake timestamp violation nTimeBlock=%"PRI64d" nTimeTx=%u", GetBlockTime(), vtx[1].nTime)); + return DoS(50, error("CheckBlock() : coinstake timestamp violation nTimeBlock=%lld nTimeTx=%u", GetBlockTime(), vtx[1].nTime)); // Check transactions - BOOST_FOREACH(const CTransaction& tx, vtx) + set uniqueTx; + for (const CTransaction& tx : vtx) { - if (!tx.CheckTransaction()) + if (fFullCheck && !tx.CheckTransaction()) return DoS(tx.nDoS, error("CheckBlock() : CheckTransaction failed")); // ppcoin: check transaction timestamp if (GetBlockTime() < (int64)tx.nTime) return DoS(50, error("CheckBlock() : block timestamp earlier than transaction timestamp")); + + uniqueTx.insert(tx.GetHash()); } // Check for duplicate txids. This is caught by ConnectInputs(), // but catching it earlier avoids a potential DoS attack: - set uniqueTx; - BOOST_FOREACH(const CTransaction& tx, vtx) - { - uniqueTx.insert(tx.GetHash()); - } if (uniqueTx.size() != vtx.size()) return DoS(100, error("CheckBlock() : duplicate transaction")); unsigned int nSigOps = 0; - BOOST_FOREACH(const CTransaction& tx, vtx) - { + for (const CTransaction& tx : vtx) nSigOps += tx.GetLegacySigOpCount(); - } + if (nSigOps > MAX_BLOCK_SIGOPS) return DoS(100, error("CheckBlock() : out-of-bounds SigOpCount")); @@ -2103,7 +2219,7 @@ bool CBlock::CheckBlock(bool fCheckPOW, bool fCheckMerkleRoot) const return DoS(100, error("CheckBlock() : hashMerkleRoot mismatch")); // ppcoin: check block signature - if (!CheckBlockSignature()) + if (fFullCheck && !CheckBlockSignature()) return DoS(100, error("CheckBlock() : bad block signature")); return true; @@ -2124,20 +2240,19 @@ bool CBlock::AcceptBlock() CBlockIndex* pindexPrev = (*mi).second; int nHeight = pindexPrev->nHeight+1; - if (IsProofOfWork() && nHeight > POW_CUTOFF_HEIGHT) - return DoS(100, error("AcceptBlock() : No proof-of-work allowed anymore (height = %d)", nHeight)); + return DoS(100, error("AcceptBlock() : No proof-of-work allowed anymore (height = %d)", nHeight)); // Check proof-of-work or proof-of-stake if (nBits != GetNextTargetRequired(pindexPrev, IsProofOfStake())) return DoS(100, error("AcceptBlock() : incorrect %s", IsProofOfWork() ? "proof-of-work" : "proof-of-stake")); // Check timestamp against prev - if (GetBlockTime() <= pindexPrev->GetMedianTimePast() || GetBlockTime() + nMaxClockDrift < pindexPrev->GetBlockTime()) + if (GetBlockTime() <= pindexPrev->GetMedianTimePast() || GetBlockTime() + GetClockDrift(GetBlockTime()) < pindexPrev->GetBlockTime()) return error("AcceptBlock() : block's timestamp is too early"); // Check that all transactions are finalized - BOOST_FOREACH(const CTransaction& tx, vtx) + for (const CTransaction& tx : vtx) if (!tx.IsFinal(nHeight, GetBlockTime())) return DoS(10, error("AcceptBlock() : contains a non-final transaction")); @@ -2145,19 +2260,6 @@ bool CBlock::AcceptBlock() if (!Checkpoints::CheckHardened(nHeight, hash)) return DoS(100, error("AcceptBlock() : rejected by hardened checkpoint lock-in at %d", nHeight)); - // ppcoin: check that the block satisfies synchronized checkpoint - if (!Checkpoints::CheckSync(hash, pindexPrev)) - { - if(!GetBoolArg("-nosynccheckpoints", false)) - { - return error("AcceptBlock() : rejected by synchronized checkpoint"); - } - else - { - strMiscWarning = _("WARNING: syncronized checkpoint violation detected, but skipped!"); - } - } - // Reject block.nVersion < 3 blocks since 95% threshold on mainNet and always on testNet: if (nVersion < 3 && ((!fTestNet && nHeight > 14060) || (fTestNet && nHeight > 0))) return error("CheckBlock() : rejected nVersion < 3 block"); @@ -2182,14 +2284,11 @@ bool CBlock::AcceptBlock() if (hashBestChain == hash) { LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) + for (CNode* pnode : vNodes) if (nBestHeight > (pnode->nStartingHeight != -1 ? pnode->nStartingHeight - 2000 : nBlockEstimate)) pnode->PushInventory(CInv(MSG_BLOCK, hash)); } - // ppcoin: check pending sync-checkpoint - Checkpoints::AcceptPendingSyncCheckpoint(); - return true; } @@ -2226,11 +2325,17 @@ bool CBlockIndex::IsSuperMajority(int minVersion, const CBlockIndex* pstart, uns return (nFound >= nRequired); } - bool ProcessBlock(CNode* pfrom, CBlock* pblock) +{ + std::string strErr = ""; + return ProcessBlock(pfrom, pblock, strErr); +} + +bool ProcessBlock(CNode* pfrom, CBlock* pblock, std::string& strErr) { // Check for duplicate uint256 hash = pblock->GetHash(); + pblock->SetHash(hash); if (mapBlockIndex.count(hash)) return error("ProcessBlock() : already have block %d %s", mapBlockIndex[hash]->nHeight, hash.ToString().substr(0,20).c_str()); if (mapOrphanBlocks.count(hash)) @@ -2239,8 +2344,28 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock) // ppcoin: check proof-of-stake // Limited duplicity on stake: prevents block flood attack // Duplicate stake allowed only when there is orphan child block - if (pblock->IsProofOfStake() && setStakeSeen.count(pblock->GetProofOfStake()) && !mapOrphanBlocksByPrev.count(hash) && !Checkpoints::WantedByPendingSyncCheckpoint(hash)) - return error("ProcessBlock() : duplicate proof-of-stake (%s, %d) for block %s", pblock->GetProofOfStake().first.ToString().c_str(), pblock->GetProofOfStake().second, hash.ToString().c_str()); + if (pblock->IsProofOfStake() && setStakeSeen.count(pblock->GetProofOfStake()) && !mapOrphanBlocksByPrev.count(hash)) + { + if(mapBlockIndex.count(pblock->hashPrevBlock)) + { + // presstab - HyperStake + // when bootstrapping, it is common for orphans to be in the bootstrap that will trigger the stakeseen requirement above. + // if the previous block that should be orphaned is not removed from setStakeSeen then a reorg will not happen as it should + setStakeSeen.erase(pblock->GetProofOfStake()); + + //send a reorg signal that is handled in LoadExternalBlockFile() + strErr = "reorg"; + + return false; + } + + return error("ProcessBlock() : duplicate proof-of-stake (%s, %d) for block %s", pblock->GetProofOfStake().first.ToString().c_str(), pblock->GetProofOfStake().second, hash.ToString().c_str()); + } + + // If this block is before the last hardened checkpoint, then do not perform complete signature checks + bool fFullCheck = true; + if (mapBlockIndex.count(pblock->hashPrevBlock)) + fFullCheck = mapBlockIndex.at(pblock->hashPrevBlock)->nHeight > Checkpoints::GetTotalBlocksEstimate(); // Preliminary checks if (!pblock->CheckBlock()) @@ -2250,56 +2375,31 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock) if (pblock->IsProofOfStake()) { uint256 hashProofOfStake = 0; - if (!CheckProofOfStake(pblock->vtx[1], pblock->nBits, hashProofOfStake)) - { - printf("WARNING: ProcessBlock(): check proof-of-stake failed for block %s\n", hash.ToString().c_str()); - return false; // do not error here as we expect this during initial block download + if (fFullCheck && !CheckProofOfStake(pblock->vtx[1], pblock->nBits, hashProofOfStake)) { + printf("WARNING: ProcessBlock(): check proof-of-stake failed for block %s\n", hash.ToString().c_str()); + return false; } + if (!mapProofOfStake.count(hash)) // add to mapProofOfStake mapProofOfStake.insert(make_pair(hash, hashProofOfStake)); } - CBlockIndex* pcheckpoint = Checkpoints::GetLastSyncCheckpoint(); - if (pcheckpoint && pblock->hashPrevBlock != hashBestChain && !Checkpoints::WantedByPendingSyncCheckpoint(hash)) - { - // Extra checks to prevent "fill up memory by spamming with bogus blocks" - int64 deltaTime = pblock->GetBlockTime() - pcheckpoint->nTime; - CBigNum bnNewBlock; - bnNewBlock.SetCompact(pblock->nBits); - CBigNum bnRequired; - - if (pblock->IsProofOfStake()) - bnRequired.SetCompact(ComputeMinStake(GetLastBlockIndex(pcheckpoint, true)->nBits, deltaTime, pblock->nTime)); - else - bnRequired.SetCompact(ComputeMinWork(GetLastBlockIndex(pcheckpoint, false)->nBits, deltaTime)); - - if (bnNewBlock > bnRequired) - { - if (pfrom) - pfrom->Misbehaving(100); - return error("ProcessBlock() : block with too little %s", pblock->IsProofOfStake()? "proof-of-stake" : "proof-of-work"); - } - } - - // ppcoin: ask for pending sync-checkpoint if any - if (!IsInitialBlockDownload()) - Checkpoints::AskForPendingSyncCheckpoint(pfrom); - // If don't already have its previous block, shunt it off to holding area until we get it if (!mapBlockIndex.count(pblock->hashPrevBlock)) { printf("ProcessBlock: ORPHAN BLOCK, prev=%s\n", pblock->hashPrevBlock.ToString().substr(0,20).c_str()); - CBlock* pblock2 = new CBlock(*pblock); + // ppcoin: check proof-of-stake - if (pblock2->IsProofOfStake()) + if (pblock->IsProofOfStake()) { // Limited duplicity on stake: prevents block flood attack // Duplicate stake allowed only when there is orphan child block - if (setStakeSeenOrphan.count(pblock2->GetProofOfStake()) && !mapOrphanBlocksByPrev.count(hash) && !Checkpoints::WantedByPendingSyncCheckpoint(hash)) - return error("ProcessBlock() : duplicate proof-of-stake (%s, %d) for orphan block %s", pblock2->GetProofOfStake().first.ToString().c_str(), pblock2->GetProofOfStake().second, hash.ToString().c_str()); + if (setStakeSeenOrphan.count(pblock->GetProofOfStake()) && !mapOrphanBlocksByPrev.count(hash)) + return error("ProcessBlock() : duplicate proof-of-stake (%s, %d) for orphan block %s", pblock->GetProofOfStake().first.ToString().c_str(), pblock->GetProofOfStake().second, hash.ToString().c_str()); else - setStakeSeenOrphan.insert(pblock2->GetProofOfStake()); + setStakeSeenOrphan.insert(pblock->GetProofOfStake()); } + CBlock* pblock2 = new CBlock(*pblock); mapOrphanBlocks.insert(make_pair(hash, pblock2)); mapOrphanBlocksByPrev.insert(make_pair(pblock2->hashPrevBlock, pblock2)); @@ -2340,11 +2440,67 @@ bool ProcessBlock(CNode* pfrom, CBlock* pblock) } printf("ProcessBlock: ACCEPTED\n"); + // If turned on MultiSend will send a transaction (or more) on the 30th confirmation of a stake + if (pwalletMain->fMultiSend && !pwalletMain->fMultiSendCoinStake) + if (!pwalletMain->MultiSend() ) + printf("ERROR While trying to use MultiSend"); - // ppcoin: if responsible for sync-checkpoint send it - if (pfrom && !CSyncCheckpoint::strMasterPrivKey.empty()) - Checkpoints::SendSyncCheckpoint(Checkpoints::AutoSelectSyncCheckpoint()); - + // presstab HyperStake: enable of disable staking based on block difficulty + if(pwalletMain->fStakeRequirement) + { + if(pwalletMain->strDisableType == "diff") + { + int nShift = (pblock->nBits >> 24) & 0xff; + double dDiff = (double)0x0000ffff / (double)(pblock->nBits & 0x00ffffff); + while (nShift < 29) + { + dDiff *= 256.0; + nShift++; + } + while (nShift > 29) + { + dDiff /= 256.0; + nShift--; + } + if(pwalletMain->strDisableArg == ">") + { + if(dDiff > (pwalletMain->dUserNumber)) + pwalletMain->fDisableStake = true; + else + pwalletMain->fDisableStake = false; + } + else if (pwalletMain->strDisableArg == "<") + { + if(dDiff < (pwalletMain->dUserNumber)) + pwalletMain->fDisableStake = true; + else + pwalletMain->fDisableStake = false; + } + } + else if (pwalletMain->strDisableType == "weight") + { + uint64 nMinMax; + uint64 nWeight; + uint64 nAmount; + pwalletMain->GetStakeWeight(*pwalletMain, nMinMax, nMinMax, nWeight, nAmount); + + if(pwalletMain->strDisableArg == ">") + { + if(nWeight > (pwalletMain->dUserNumber)) + pwalletMain->fDisableStake = true; + else + pwalletMain->fDisableStake = false; + } + else if (pwalletMain->strDisableArg == "<") + { + if(nWeight < (pwalletMain->dUserNumber)) + pwalletMain->fDisableStake = true; + else + pwalletMain->fDisableStake = false; + } + } + } + return true; } @@ -2511,7 +2667,7 @@ static unsigned int nCurrentBlockFile = 1; FILE* AppendBlockFile(unsigned int& nFileRet) { nFileRet = 0; - loop + while (true) { FILE* file = OpenBlockFile(nCurrentBlockFile, 0, "ab"); if (!file) @@ -2542,12 +2698,18 @@ bool LoadBlockIndex(bool fAllowNew) bnProofOfStakeLimit = bnProofOfStakeLimitTestNet; // 0x00000fff PoS base target is fixed in testnet bnProofOfWorkLimit = bnProofOfWorkLimitTestNet; // 0x0000ffff PoW base target is fixed in testnet nStakeMinAge = 20 * 60; // test net min age is 20 min - nStakeMaxAge = 4* 60 * 60; // test net min age is 60 min + nStakeMaxAge = 60 * 60 * 24; // test net min age is 24 hours nCoinbaseMaturity = 10; // test maturity is 10 blocks - nStakeTargetSpacing = 30; // test block spacing is 3 minutes + nStakeTargetSpacing = 90; // test block spacing is 90 seconds } + // Load vote proposals + CVoteDB votedb("cr"); + if (!votedb.Load()) + return error("Failed to load votedb"); + votedb.Close(); + // // Load block index // @@ -2556,6 +2718,8 @@ bool LoadBlockIndex(bool fAllowNew) return false; txdb.Close(); + + // // Init with genesis block // @@ -2581,7 +2745,13 @@ bool LoadBlockIndex(bool fAllowNew) block.nTime = 1401331380; block.nBits = bnProofOfWorkLimit.GetCompact(); block.nNonce = 1779291; - if (false ) { + if(fTestNet) + { + block.nTime = 1424304823; + block.nNonce = 0; + } + + if (false ) { // This will figure out a valid hash and Nonce if you're // creating a different genesis block: @@ -2603,8 +2773,6 @@ bool LoadBlockIndex(bool fAllowNew) printf("block.nTime = %u \n", block.nTime); printf("block.nNonce = %u \n", block.nNonce); - - assert(block.hashMerkleRoot == uint256("37ad323037e6e55553fadebbe60690a1bff2752f947b7af8cb6b54929f5fee3d")); assert(block.GetHash() == (!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet)); @@ -2615,35 +2783,11 @@ bool LoadBlockIndex(bool fAllowNew) return error("LoadBlockIndex() : writing genesis block to disk failed"); if (!block.AddToBlockIndex(nFile, nBlockPos)) return error("LoadBlockIndex() : genesis block not accepted"); - - // ppcoin: initialize synchronized checkpoint - if (!Checkpoints::WriteSyncCheckpoint((!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet))) - return error("LoadBlockIndex() : failed to init sync checkpoint"); - } - - // ppcoin: if checkpoint master key changed must reset sync-checkpoint - { - CTxDB txdb; - string strPubKey = ""; - if (!txdb.ReadCheckpointPubKey(strPubKey) || strPubKey != CSyncCheckpoint::strMasterPubKey) - { - // write checkpoint master key to db - txdb.TxnBegin(); - if (!txdb.WriteCheckpointPubKey(CSyncCheckpoint::strMasterPubKey)) - return error("LoadBlockIndex() : failed to write new checkpoint master key to db"); - if (!txdb.TxnCommit()) - return error("LoadBlockIndex() : failed to commit new checkpoint master key to db"); - if ((!fTestNet) && !Checkpoints::ResetSyncCheckpoint()) - return error("LoadBlockIndex() : failed to reset sync-checkpoint"); - } - txdb.Close(); } return true; } - - void PrintBlockTree() { // pre-compute tree structure @@ -2689,7 +2833,7 @@ void PrintBlockTree() // print item CBlock block; block.ReadFromDisk(pindex); - printf("%d (%u,%u) %s %08x %s mint %7s tx %"PRIszu"", + printf("%d (%u,%u) %s %08x %s mint %7s tx %lu", pindex->nHeight, pindex->nFile, pindex->nBlockPos, @@ -2723,6 +2867,7 @@ bool LoadExternalBlockFile(FILE* fileIn) int64 nStart = GetTimeMillis(); int nLoaded = 0; + int nStartHeight = nBestHeight; { LOCK(cs_main); try { @@ -2731,7 +2876,8 @@ bool LoadExternalBlockFile(FILE* fileIn) while (nPos != (unsigned int)-1 && blkdat.good() && !fRequestShutdown) { unsigned char pchData[65536]; - do { + do + { fseek(blkdat, nPos, SEEK_SET); int nRead = fread(pchData, 1, sizeof(pchData), blkdat); if (nRead <= 8) @@ -2761,11 +2907,32 @@ bool LoadExternalBlockFile(FILE* fileIn) { CBlock block; blkdat >> block; - if (ProcessBlock(NULL,&block)) - { - nLoaded++; - nPos += 4 + nSize; - } + + // no reason to partially scan every block we have just to print to log that we have it + if(nLoaded < nStartHeight) + { + nLoaded++; + nPos += 4 + nSize; + } + else + { + std::string strErr = ""; + bool fProcessed = ProcessBlock(NULL,&block, strErr); + if (fProcessed) + { + nLoaded++; + nPos += 4 + nSize; + } + else if (strErr == "reorg") + { + fProcessed = ProcessBlock(NULL,&block, strErr); + if (fProcessed) + { + nLoaded++; + nPos += 4 + nSize; + } + } + } } } } @@ -2774,11 +2941,57 @@ bool LoadExternalBlockFile(FILE* fileIn) __PRETTY_FUNCTION__); } } - printf("Loaded %i blocks from external file in %"PRI64d"ms\n", nLoaded, GetTimeMillis() - nStart); + printf("Loaded %i blocks from external file in %lldms\n", nLoaded, GetTimeMillis() - nStart); return nLoaded > 0; } +CBigNum GetWeightSpent(CBlockIndex* pindex) +{ + if(pindex->IsProofOfWork()) + return 0; + + CBlock block; + if(!block.ReadFromDisk(pindex, true)) + return 0; + + //txin that was staked + CTxIn txInStake = block.vtx[1].vin[0]; + + //find the tx that txin came from + CTxDB txdb("r"); + CTransaction txPrev; + if(!txdb.ReadDiskTx(txInStake.prevout, txPrev)) + return 0; + + unsigned int nAge = min(block.GetBlockTime() - txPrev.nTime, (long long int)nStakeMaxAge); + uint64 nAmount = txPrev.vout[txInStake.prevout.n].nValue; + + //note that it is slightly different in real weight calc, but small enough that this simplification is better + //for users to see + return CBigNum((nAge / (60*60*24)) * (nAmount/COIN)); +} + +CBigNum GetMedianWeightOverPeriod(int nBlocksCount) +{ + if(nBestHeight - nBlocksCount <= 0) + return 0; + CBlockIndex* pindex = pindexBest; + + + int nEndHeight = pindex->nHeight - nBlocksCount; + CBigNum bnWeightSpent = 0; + vector vWeights; + while(pindex->nHeight > nEndHeight - 1) + { + vWeights.push_back(GetWeightSpent(pindex)); + pindex = pindex->pprev; + } + + sort(vWeights.begin(), vWeights.end()); + + return vWeights[(int)vWeights.size()/2]; +} ////////////////////////////////////////////////////////////////////////////// @@ -2815,21 +3028,6 @@ string GetWarnings(string strFor) strStatusBar = strMiscWarning; } - // ppcoin: should not enter safe mode for longer invalid chain - // ppcoin: if sync-checkpoint is too old do not enter safe mode - if (Checkpoints::IsSyncCheckpointTooOld(60 * 60 * 24 * 365) && !fTestNet && !IsInitialBlockDownload()) - { - nPriority = 100; - strStatusBar = "WARNING: Checkpoint is too old. Wait for block chain to download, or notify developers."; - } - - // ppcoin: if detected invalid checkpoint enter safe mode - if (Checkpoints::hashInvalidCheckpoint != 0) - { - nPriority = 3000; - strStatusBar = strRPC = "WARNING: Invalid checkpoint found! Displayed transactions may not be correct! You may need to upgrade, or notify developers."; - } - // Alerts { LOCK(cs_mapAlerts); @@ -2894,23 +3092,20 @@ bool static AlreadyHave(CTxDB& txdb, const CInv& inv) // The characters are rarely used upper ASCII, not valid as UTF-8, and produce // a large 4-byte int at any alignment. unsigned char pchMessageStart[4] = { 0xdb, 0xad, 0xbd, 0xda }; +unsigned int nLastMapGetBlocksClear = 0; bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) { - static map mapReuseKey; + static map mapReuseKey; RandAddSeedPerfmon(); if (fDebug) - printf("received: %s (%"PRIszu" bytes)\n", strCommand.c_str(), vRecv.size()); + printf("received: %s (%lu bytes)\n", strCommand.c_str(), vRecv.size()); if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0) { printf("dropmessagestest DROPPING RECV MESSAGE\n"); return true; } - - - - if (strCommand == "version") { // Each connection can only send one version message @@ -2925,7 +3120,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) CAddress addrFrom; uint64 nNonce = 1; vRecv >> pfrom->nVersion >> pfrom->nServices >> nTime >> addrMe; - if (pfrom->nVersion < MIN_PROTO_VERSION) + if (pfrom->nVersion < PROTOCOL_START) { // Since February 20, 2012, the protocol is initiated at version 209, // and earlier versions are no longer supported @@ -2933,6 +3128,13 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) pfrom->fDisconnect = true; return false; } + + if((fStrictProtocol) && pfrom->nVersion != PROTOCOL_VERSION) + { + printf("Strict Protocol: partner %s using obsolete version %i; disconnecting\n", pfrom->addr.ToString().c_str(), pfrom->nVersion); + pfrom->fDisconnect = true; + return false; + } if (pfrom->nVersion == 10300) pfrom->nVersion = 300; @@ -3024,22 +3226,20 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) item.second.RelayTo(pfrom); } - // ppcoin: relay sync-checkpoint - { - LOCK(Checkpoints::cs_hashSyncCheckpoint); - if (!Checkpoints::checkpointMessage.IsNull()) - Checkpoints::checkpointMessage.RelayTo(pfrom); - } - pfrom->fSuccessfullyConnected = true; printf("receive version message: version %d, blocks=%d, us=%s, them=%s, peer=%s\n", pfrom->nVersion, pfrom->nStartingHeight, addrMe.ToString().c_str(), addrFrom.ToString().c_str(), pfrom->addr.ToString().c_str()); cPeerBlockCounts.input(pfrom->nStartingHeight); - // ppcoin: ask for pending sync-checkpoint if any - if (!IsInitialBlockDownload()) - Checkpoints::AskForPendingSyncCheckpoint(pfrom); + // Be more aggressive with blockchain download. Send new getblocks() message after connection + // to new node if waited longer than MAX_TIME_SINCE_BEST_BLOCK. + int64 TimeSinceBestBlock = GetTime() - nTimeBestReceived; + if (TimeSinceBestBlock > MAX_TIME_SINCE_BEST_BLOCK) + { + printf("INFO: Waiting %lld sec which is too long. Sending GetBlocks(0)\n", TimeSinceBestBlock); + pfrom->PushGetBlocks(pindexBest, uint256(0)); + } } @@ -3053,7 +3253,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) else if (strCommand == "verack") { - pfrom->vRecv.SetVersion(min(pfrom->nVersion, PROTOCOL_VERSION)); + pfrom->SetRecvVersion(min(pfrom->nVersion, PROTOCOL_VERSION)); } @@ -3068,7 +3268,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) if (vAddr.size() > 1000) { pfrom->Misbehaving(20); - return error("message addr size() = %"PRIszu"", vAddr.size()); + return error("message addr size() = %lu", vAddr.size()); } // Store the new addresses @@ -3131,7 +3331,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) if (vInv.size() > MAX_INV_SZ) { pfrom->Misbehaving(20); - return error("message inv size() = %"PRIszu"", vInv.size()); + return error("message inv size() = %lu", vInv.size()); } // find last block in inv vector @@ -3181,11 +3381,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) if (vInv.size() > MAX_INV_SZ) { pfrom->Misbehaving(20); - return error("message getdata size() = %"PRIszu"", vInv.size()); + return error("message getdata size() = %lu", vInv.size()); } if (fDebugNet || (vInv.size() != 1)) - printf("received getdata (%"PRIszu" invsz)\n", vInv.size()); + printf("received getdata (%lu invsz)\n", vInv.size()); BOOST_FOREACH(const CInv& inv, vInv) { @@ -3207,11 +3407,9 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) // Trigger them to send a getblocks request for the next batch of inventory if (inv.hash == pfrom->hashContinue) { - // ppcoin: send latest proof-of-work block to allow the - // download node to accept as orphan (proof-of-stake - // block might be rejected by stake connection check) vector vInv; - vInv.push_back(CInv(MSG_BLOCK, GetLastBlockIndex(pindexBest, false)->GetBlockHash())); + vInv.push_back(CInv(MSG_BLOCK, hashBestChain)); + pfrom->PushMessage("inv", vInv); pfrom->hashContinue = 0; } @@ -3249,7 +3447,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) else if (strCommand == "getblocks") { - CBlockLocator locator; + //clear our mapGetBlocksRequests every 3 minutes to prevent storing lots of data + if(nLastMapGetBlocksClear != 0 && GetTime() - nLastMapGetBlocksClear > (180)) + mapGetBlocksRequests.clear(); + + CBlockLocator locator; uint256 hashStop; vRecv >> locator >> hashStop; @@ -3259,17 +3461,43 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) // Send the rest of the chain if (pindex) pindex = pindex->pnext; - int nLimit = 500; - printf("getblocks %d to %s limit %d\n", (pindex ? pindex->nHeight : -1), hashStop.ToString().substr(0,20).c_str(), nLimit); + int nLimit = 1000; + int nFirst = (pindex ? pindex->nHeight : -1); + printf("getblocks %d to %s limit %d\n", nFirst, hashStop.ToString().substr(0,20).c_str(), nLimit); for (; pindex; pindex = pindex->pnext) { - if (pindex->GetBlockHash() == hashStop) + if(fStrictIncoming) + { + nLastMapGetBlocksClear = GetTime(); + std::string strFrom = pfrom->addrName; + if(mapGetBlocksRequests.count(strFrom)) + { + if(mapGetBlocksRequests[strFrom].first == nFirst) // if the peer has already requested this + mapGetBlocksRequests[strFrom].second += 1; // count times this has been requested + else + { + // this has not been requested from this peer, so record it + mapGetBlocksRequests[strFrom].first = nFirst; + mapGetBlocksRequests[strFrom].second = 1; + } + if(mapGetBlocksRequests[strFrom].first != -1 && mapGetBlocksRequests[strFrom].second > 100) + { + printf("GetBlocksRequest: disconnect from peer %s that has requested the same thing more than 100 times\n", strFrom.c_str()); + pfrom->fDisconnect = true; + return false; + } + } + else + { + // if peer hasn't requested any blocks yet then add them to map + printf("GetBlocksRequest: adding peer to map\n"); + mapGetBlocksRequests[strFrom].first = nFirst; + mapGetBlocksRequests[strFrom].second = 1; + } + } + if (pindex->GetBlockHash() == hashStop) { printf(" getblocks stopping at %d %s\n", pindex->nHeight, pindex->GetBlockHash().ToString().substr(0,20).c_str()); - // ppcoin: tell downloading node about the latest block if it's - // without risk being rejected due to stake connection check - if (hashStop != hashBestChain && pindex->GetBlockTime() + nStakeMinAge > pindexBest->GetBlockTime()) - pfrom->PushInventory(CInv(MSG_BLOCK, hashBestChain)); break; } pfrom->PushInventory(CInv(MSG_BLOCK, pindex->GetBlockHash())); @@ -3283,20 +3511,6 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) } } } - else if (strCommand == "checkpoint") - { - CSyncCheckpoint checkpoint; - vRecv >> checkpoint; - - if (checkpoint.ProcessSyncCheckpoint(pfrom)) - { - // Relay - pfrom->hashCheckpointKnown = checkpoint.hashCheckpoint; - LOCK(cs_vNodes); - BOOST_FOREACH(CNode* pnode, vNodes) - checkpoint.RelayTo(pnode); - } - } else if (strCommand == "getheaders") { @@ -3414,8 +3628,33 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) CInv inv(MSG_BLOCK, block.GetHash()); pfrom->AddInventoryKnown(inv); - if (ProcessBlock(pfrom, &block)) + if (ProcessBlock(pfrom, &block)) mapAlreadyAskedFor.erase(inv); + else + { + if(fStrictIncoming) + { + string strFrom = pfrom->addrName; + if(mapPeerRejectedBlocks.count(strFrom) == 0) + mapPeerRejectedBlocks[strFrom] = 1; + else + mapPeerRejectedBlocks[strFrom] += 1; + if (mapPeerRejectedBlocks[strFrom] > 100) + { + printf("MapPeerRejectedBlocks: %s has sent 100 orphans, disconnecting\n", strFrom.c_str()); + pfrom->fDisconnect = true; + return false; + } + } + // Be more aggressive with blockchain download. Send getblocks() message after + // an error related to new block download + int64 TimeSinceBestBlock = GetTime() - nTimeBestReceived; + if (TimeSinceBestBlock > MAX_TIME_SINCE_BEST_BLOCK) + { + printf("INFO: Waiting %lld sec which is too long. Sending GetBlocks(0)\n", TimeSinceBestBlock); + pfrom->PushGetBlocks(pindexBest, uint256(0)); + } + } if (block.nDoS) pfrom->Misbehaving(block.nDoS); } @@ -3539,7 +3778,8 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) // This isn't a Misbehaving(100) (immediate ban) because the // peer might be an older or different implementation with // a different signature key, etc. - pfrom->Misbehaving(10); + if(!alert.CheckSignature()) + pfrom->Misbehaving(10); } } } @@ -3560,13 +3800,11 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv) return true; } +// requires LOCK(cs_vRecvMsg) bool ProcessMessages(CNode* pfrom) { - CDataStream& vRecv = pfrom->vRecv; - if (vRecv.empty()) - return true; //if (fDebug) - // printf("ProcessMessages(%u bytes)\n", vRecv.size()); + // printf("ProcessMessages(%zu messages)\n", pfrom->vRecvMsg.size()); // // Message format @@ -3576,33 +3814,38 @@ bool ProcessMessages(CNode* pfrom) // (4) checksum // (x) data // + bool fOk = true; - loop - { + std::deque::iterator it = pfrom->vRecvMsg.begin(); + while (it != pfrom->vRecvMsg.end()) { // Don't bother if send buffer is too full to respond anyway if (pfrom->vSend.size() >= SendBufferSize()) break; + // get next message + CNetMessage& msg = *it; + + //if (fDebug) + // printf("ProcessMessages(message %u msgsz, %zu bytes, complete:%s)\n", + // msg.hdr.nMessageSize, msg.vRecv.size(), + // msg.complete() ? "Y" : "N"); + + // end, if an incomplete message is found + if (!msg.complete()) + break; + + // at this point, any failure means we can delete the current message + it++; + // Scan for message start - CDataStream::iterator pstart = search(vRecv.begin(), vRecv.end(), BEGIN(pchMessageStart), END(pchMessageStart)); - int nHeaderSize = vRecv.GetSerializeSize(CMessageHeader()); - if (vRecv.end() - pstart < nHeaderSize) - { - if ((int)vRecv.size() > nHeaderSize) - { - printf("\n\nPROCESSMESSAGE MESSAGESTART NOT FOUND\n\n"); - vRecv.erase(vRecv.begin(), vRecv.end() - nHeaderSize); - } + if (memcmp(msg.hdr.pchMessageStart, pchMessageStart, sizeof(pchMessageStart)) != 0) { + printf("\n\nPROCESSMESSAGE: INVALID MESSAGESTART\n\n"); + fOk = false; break; } - if (pstart - vRecv.begin() > 0) - printf("\n\nPROCESSMESSAGE SKIPPED %"PRIpdd" BYTES\n\n", pstart - vRecv.begin()); - vRecv.erase(vRecv.begin(), pstart); // Read header - vector vHeaderSave(vRecv.begin(), vRecv.begin() + nHeaderSize); - CMessageHeader hdr; - vRecv >> hdr; + CMessageHeader& hdr = msg.hdr; if (!hdr.IsValid()) { printf("\n\nPROCESSMESSAGE: ERRORS IN HEADER %s\n\n\n", hdr.GetCommand().c_str()); @@ -3612,19 +3855,9 @@ bool ProcessMessages(CNode* pfrom) // Message size unsigned int nMessageSize = hdr.nMessageSize; - if (nMessageSize > MAX_SIZE) - { - printf("ProcessMessages(%s, %u bytes) : nMessageSize > MAX_SIZE\n", strCommand.c_str(), nMessageSize); - continue; - } - if (nMessageSize > vRecv.size()) - { - // Rewind and wait for rest of message - vRecv.insert(vRecv.begin(), vHeaderSave.begin(), vHeaderSave.end()); - break; - } // Checksum + CDataStream& vRecv = msg.vRecv; uint256 hash = Hash(vRecv.begin(), vRecv.begin() + nMessageSize); unsigned int nChecksum = 0; memcpy(&nChecksum, &hash, sizeof(nChecksum)); @@ -3635,20 +3868,16 @@ bool ProcessMessages(CNode* pfrom) continue; } - // Copy message to its own buffer - CDataStream vMsg(vRecv.begin(), vRecv.begin() + nMessageSize, vRecv.nType, vRecv.nVersion); - vRecv.ignore(nMessageSize); - // Process message bool fRet = false; try { { LOCK(cs_main); - fRet = ProcessMessage(pfrom, strCommand, vMsg); + fRet = ProcessMessage(pfrom, strCommand, vRecv); } if (fShutdown) - return true; + break; } catch (std::ios_base::failure& e) { @@ -3677,8 +3906,8 @@ bool ProcessMessages(CNode* pfrom) printf("ProcessMessage(%s, %u bytes) FAILED\n", strCommand.c_str(), nMessageSize); } - vRecv.Compact(); - return true; + pfrom->vRecvMsg.erase(pfrom->vRecvMsg.begin(), it); + return fOk; } @@ -3842,712 +4071,14 @@ bool SendMessages(CNode* pto, bool fSendTrickle) return true; } - - - - -////////////////////////////////////////////////////////////////////////////// -// -// BitcoinMiner -// - -int static FormatHashBlocks(void* pbuffer, unsigned int len) +bool GetProposalTXID(const uint256& hashProposal, uint256& txid) { - unsigned char* pdata = (unsigned char*)pbuffer; - unsigned int blocks = 1 + ((len + 8) / 64); - unsigned char* pend = pdata + 64 * blocks; - memset(pdata + len, 0, 64 * blocks - len); - pdata[len] = 0x80; - unsigned int bits = len * 8; - pend[-1] = (bits >> 0) & 0xff; - pend[-2] = (bits >> 8) & 0xff; - pend[-3] = (bits >> 16) & 0xff; - pend[-4] = (bits >> 24) & 0xff; - return blocks; -} - -static const unsigned int pSHA256InitState[8] = -{0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19}; - -void SHA256Transform(void* pstate, void* pinput, const void* pinit) -{ - SHA256_CTX ctx; - unsigned char data[64]; - - SHA256_Init(&ctx); - - for (int i = 0; i < 16; i++) - ((uint32_t*)data)[i] = ByteReverse(((uint32_t*)pinput)[i]); - - for (int i = 0; i < 8; i++) - ctx.h[i] = ((uint32_t*)pinit)[i]; - - SHA256_Update(&ctx, data, sizeof(data)); - for (int i = 0; i < 8; i++) - ((uint32_t*)pstate)[i] = ctx.h[i]; -} - -// Some explaining would be appreciated -class COrphan -{ -public: - CTransaction* ptx; - set setDependsOn; - double dPriority; - double dFeePerKb; - - COrphan(CTransaction* ptxIn) - { - ptx = ptxIn; - dPriority = dFeePerKb = 0; - } - - void print() const - { - printf("COrphan(hash=%s, dPriority=%.1f, dFeePerKb=%.1f)\n", - ptx->GetHash().ToString().substr(0,10).c_str(), dPriority, dFeePerKb); - BOOST_FOREACH(uint256 hash, setDependsOn) - printf(" setDependsOn %s\n", hash.ToString().substr(0,10).c_str()); - } -}; - - -uint64 nLastBlockTx = 0; -uint64 nLastBlockSize = 0; -int64 nLastCoinStakeSearchInterval = 0; - -// We want to sort transactions by priority and fee, so: -typedef boost::tuple TxPriority; -class TxPriorityCompare -{ - bool byFee; -public: - TxPriorityCompare(bool _byFee) : byFee(_byFee) { } - bool operator()(const TxPriority& a, const TxPriority& b) - { - if (byFee) - { - if (a.get<1>() == b.get<1>()) - return a.get<0>() < b.get<0>(); - return a.get<1>() < b.get<1>(); - } - else - { - if (a.get<0>() == b.get<0>()) - return a.get<1>() < b.get<1>(); - return a.get<0>() < b.get<0>(); - } - } -}; - -// CreateNewBlock: -// fProofOfStake: try (best effort) to make a proof-of-stake block -CBlock* CreateNewBlock(CWallet* pwallet, bool fProofOfStake) -{ - CReserveKey reservekey(pwallet); - - // Create new block - auto_ptr pblock(new CBlock()); - if (!pblock.get()) - return NULL; - - // Create coinbase tx - CTransaction txNew; - txNew.vin.resize(1); - txNew.vin[0].prevout.SetNull(); - txNew.vout.resize(1); - txNew.vout[0].scriptPubKey << reservekey.GetReservedKey() << OP_CHECKSIG; - - // Add our coinbase tx as first transaction - pblock->vtx.push_back(txNew); - - // Largest block you're willing to create: - unsigned int nBlockMaxSize = GetArg("-blockmaxsize", MAX_BLOCK_SIZE_GEN/2); - // Limit to betweeen 1K and MAX_BLOCK_SIZE-1K for sanity: - nBlockMaxSize = std::max((unsigned int)1000, std::min((unsigned int)(MAX_BLOCK_SIZE-1000), nBlockMaxSize)); - - // How much of the block should be dedicated to high-priority transactions, - // included regardless of the fees they pay - unsigned int nBlockPrioritySize = GetArg("-blockprioritysize", 27000); - nBlockPrioritySize = std::min(nBlockMaxSize, nBlockPrioritySize); - - // Minimum block size you want to create; block will be filled with free transactions - // until there are no more or the block reaches this size: - unsigned int nBlockMinSize = GetArg("-blockminsize", 0); - nBlockMinSize = std::min(nBlockMaxSize, nBlockMinSize); - - // Fee-per-kilobyte amount considered the same as "free" - // Be careful setting this: if you set it to zero then - // a transaction spammer can cheaply fill blocks using - // 1-satoshi-fee transactions. It should be set above the real - // cost to you of processing a transaction. - int64 nMinTxFee = MIN_TX_FEE; - if (mapArgs.count("-mintxfee")) - ParseMoney(mapArgs["-mintxfee"], nMinTxFee); - - // ppcoin: if coinstake available add coinstake tx - static int64 nLastCoinStakeSearchTime = GetAdjustedTime(); // only initialized at startup - CBlockIndex* pindexPrev = pindexBest; - - if (fProofOfStake) // attempt to find a coinstake - { - pblock->nBits = GetNextTargetRequired(pindexPrev, true); - CTransaction txCoinStake; - int64 nSearchTime = txCoinStake.nTime; // search to current time - if (nSearchTime > nLastCoinStakeSearchTime) - { - // printf(">>> OK1\n"); - if (pwallet->CreateCoinStake(*pwallet, pblock->nBits, nSearchTime-nLastCoinStakeSearchTime, txCoinStake)) - { - if (txCoinStake.nTime >= max(pindexPrev->GetMedianTimePast()+1, pindexPrev->GetBlockTime() - nMaxClockDrift)) - { // make sure coinstake would meet timestamp protocol - // as it would be the same as the block timestamp - pblock->vtx[0].vout[0].SetEmpty(); - pblock->vtx[0].nTime = txCoinStake.nTime; - pblock->vtx.push_back(txCoinStake); - } - } - nLastCoinStakeSearchInterval = nSearchTime - nLastCoinStakeSearchTime; - nLastCoinStakeSearchTime = nSearchTime; - } - } - - pblock->nBits = GetNextTargetRequired(pindexPrev, pblock->IsProofOfStake()); - - // Collect memory pool transactions into the block - int64 nFees = 0; - { - LOCK2(cs_main, mempool.cs); - CBlockIndex* pindexPrev = pindexBest; - CTxDB txdb("r"); - - // Priority order to process transactions - list vOrphan; // list memory doesn't move - map > mapDependers; - - // This vector will be sorted into a priority queue: - vector vecPriority; - vecPriority.reserve(mempool.mapTx.size()); - for (map::iterator mi = mempool.mapTx.begin(); mi != mempool.mapTx.end(); ++mi) - { - CTransaction& tx = (*mi).second; - if (tx.IsCoinBase() || tx.IsCoinStake() || !tx.IsFinal()) - continue; - - COrphan* porphan = NULL; - double dPriority = 0; - int64 nTotalIn = 0; - bool fMissingInputs = false; - BOOST_FOREACH(const CTxIn& txin, tx.vin) - { - // Read prev transaction - CTransaction txPrev; - CTxIndex txindex; - if (!txPrev.ReadFromDisk(txdb, txin.prevout, txindex)) - { - // This should never happen; all transactions in the memory - // pool should connect to either transactions in the chain - // or other transactions in the memory pool. - if (!mempool.mapTx.count(txin.prevout.hash)) - { - printf("ERROR: mempool transaction missing input\n"); - if (fDebug) assert("mempool transaction missing input" == 0); - fMissingInputs = true; - if (porphan) - vOrphan.pop_back(); - break; - } - - // Has to wait for dependencies - if (!porphan) - { - // Use list for automatic deletion - vOrphan.push_back(COrphan(&tx)); - porphan = &vOrphan.back(); - } - mapDependers[txin.prevout.hash].push_back(porphan); - porphan->setDependsOn.insert(txin.prevout.hash); - nTotalIn += mempool.mapTx[txin.prevout.hash].vout[txin.prevout.n].nValue; - continue; - } - int64 nValueIn = txPrev.vout[txin.prevout.n].nValue; - nTotalIn += nValueIn; - - int nConf = txindex.GetDepthInMainChain(); - dPriority += (double)nValueIn * nConf; - } - if (fMissingInputs) continue; - - // Priority is sum(valuein * age) / txsize - unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); - dPriority /= nTxSize; - - // This is a more accurate fee-per-kilobyte than is used by the client code, because the - // client code rounds up the size to the nearest 1K. That's good, because it gives an - // incentive to create smaller transactions. - double dFeePerKb = double(nTotalIn-tx.GetValueOut()) / (double(nTxSize)/1000.0); - - if (porphan) - { - porphan->dPriority = dPriority; - porphan->dFeePerKb = dFeePerKb; - } - else - vecPriority.push_back(TxPriority(dPriority, dFeePerKb, &(*mi).second)); - } - - // Collect transactions into block - map mapTestPool; - uint64 nBlockSize = 1000; - uint64 nBlockTx = 0; - int nBlockSigOps = 100; - bool fSortedByFee = (nBlockPrioritySize <= 0); - - TxPriorityCompare comparer(fSortedByFee); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - - while (!vecPriority.empty()) - { - // Take highest priority transaction off the priority queue: - double dPriority = vecPriority.front().get<0>(); - double dFeePerKb = vecPriority.front().get<1>(); - CTransaction& tx = *(vecPriority.front().get<2>()); - - std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); - vecPriority.pop_back(); - - // Size limits - unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); - if (nBlockSize + nTxSize >= nBlockMaxSize) - continue; - - // Legacy limits on sigOps: - unsigned int nTxSigOps = tx.GetLegacySigOpCount(); - if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS) - continue; - - // Timestamp limit - if (tx.nTime > GetAdjustedTime() || (pblock->IsProofOfStake() && tx.nTime > pblock->vtx[1].nTime)) - continue; - - // ppcoin: simplify transaction fee - allow free = false - int64 nMinFee = tx.GetMinFee(nBlockSize, false, GMF_BLOCK); - - // Skip free transactions if we're past the minimum block size: - if (fSortedByFee && (dFeePerKb < nMinTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) - continue; - - // Prioritize by fee once past the priority size or we run out of high-priority - // transactions: - if (!fSortedByFee && - ((nBlockSize + nTxSize >= nBlockPrioritySize) || (dPriority < COIN * 144 / 250))) - { - fSortedByFee = true; - comparer = TxPriorityCompare(fSortedByFee); - std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); - } - - // Connecting shouldn't fail due to dependency on other memory pool transactions - // because we're already processing them in order of dependency - map mapTestPoolTmp(mapTestPool); - MapPrevTx mapInputs; - bool fInvalid; - if (!tx.FetchInputs(txdb, mapTestPoolTmp, false, true, mapInputs, fInvalid)) - continue; - - int64 nTxFees = tx.GetValueIn(mapInputs)-tx.GetValueOut(); - if (nTxFees < nMinFee) - continue; - - nTxSigOps += tx.GetP2SHSigOpCount(mapInputs); - if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS) - continue; - - if (!tx.ConnectInputs(txdb, mapInputs, mapTestPoolTmp, CDiskTxPos(1,1,1), pindexPrev, false, true)) - continue; - mapTestPoolTmp[tx.GetHash()] = CTxIndex(CDiskTxPos(1,1,1), tx.vout.size()); - swap(mapTestPool, mapTestPoolTmp); - - // Added - pblock->vtx.push_back(tx); - nBlockSize += nTxSize; - ++nBlockTx; - nBlockSigOps += nTxSigOps; - nFees += nTxFees; - - if (fDebug && GetBoolArg("-printpriority")) - { - printf("priority %.1f feeperkb %.1f txid %s\n", - dPriority, dFeePerKb, tx.GetHash().ToString().c_str()); - } - - // Add transactions that depend on this one to the priority queue - uint256 hash = tx.GetHash(); - if (mapDependers.count(hash)) - { - BOOST_FOREACH(COrphan* porphan, mapDependers[hash]) - { - if (!porphan->setDependsOn.empty()) - { - porphan->setDependsOn.erase(hash); - if (porphan->setDependsOn.empty()) - { - vecPriority.push_back(TxPriority(porphan->dPriority, porphan->dFeePerKb, porphan->ptx)); - std::push_heap(vecPriority.begin(), vecPriority.end(), comparer); - } - } - } - } - } - - nLastBlockTx = nBlockTx; - nLastBlockSize = nBlockSize; - - if (fDebug && GetBoolArg("-printpriority")) - printf("CreateNewBlock(): total size %"PRI64u"\n", nBlockSize); - - if (pblock->IsProofOfWork()) - pblock->vtx[0].vout[0].nValue = GetProofOfWorkReward(pindexPrev->nHeight+1, nFees, pindexPrev->GetBlockHash()); - - // Fill in header - pblock->hashPrevBlock = pindexPrev->GetBlockHash(); - if (pblock->IsProofOfStake()) - pblock->nTime = pblock->vtx[1].nTime; //same as coinstake timestamp - pblock->nTime = max(pindexPrev->GetMedianTimePast()+1, pblock->GetMaxTransactionTime()); - pblock->nTime = max(pblock->GetBlockTime(), pindexPrev->GetBlockTime() - nMaxClockDrift); - if (pblock->IsProofOfWork()) - pblock->UpdateTime(pindexPrev); - pblock->nNonce = 0; - } - - return pblock.release(); -} - - -void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce) -{ - // Update nExtraNonce - static uint256 hashPrevBlock; - if (hashPrevBlock != pblock->hashPrevBlock) - { - nExtraNonce = 0; - hashPrevBlock = pblock->hashPrevBlock; - } - ++nExtraNonce; - unsigned int nHeight = pindexPrev->nHeight+1; // Height first in coinbase required for block.version=2 - pblock->vtx[0].vin[0].scriptSig = (CScript() << nHeight << CBigNum(nExtraNonce)) + COINBASE_FLAGS; - assert(pblock->vtx[0].vin[0].scriptSig.size() <= 100); - - pblock->hashMerkleRoot = pblock->BuildMerkleTree(); -} - - -void FormatHashBuffers(CBlock* pblock, char* pmidstate, char* pdata, char* phash1) -{ - // - // Pre-build hash buffers - // - struct - { - struct unnamed2 - { - int nVersion; - uint256 hashPrevBlock; - uint256 hashMerkleRoot; - unsigned int nTime; - unsigned int nBits; - unsigned int nNonce; - } - block; - unsigned char pchPadding0[64]; - uint256 hash1; - unsigned char pchPadding1[64]; - } - tmp; - memset(&tmp, 0, sizeof(tmp)); - - tmp.block.nVersion = pblock->nVersion; - tmp.block.hashPrevBlock = pblock->hashPrevBlock; - tmp.block.hashMerkleRoot = pblock->hashMerkleRoot; - tmp.block.nTime = pblock->nTime; - tmp.block.nBits = pblock->nBits; - tmp.block.nNonce = pblock->nNonce; - - FormatHashBlocks(&tmp.block, sizeof(tmp.block)); - FormatHashBlocks(&tmp.hash1, sizeof(tmp.hash1)); - - // Byte swap all the input buffer - for (unsigned int i = 0; i < sizeof(tmp)/4; i++) - ((unsigned int*)&tmp)[i] = ByteReverse(((unsigned int*)&tmp)[i]); - - // Precalc the first half of the first hash, which stays constant - SHA256Transform(pmidstate, &tmp.block, pSHA256InitState); - - memcpy(pdata, &tmp.block, 128); - memcpy(phash1, &tmp.hash1, 64); -} - - -bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey) -{ - uint256 hash = pblock->GetHash(); - uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256(); - - if (hash > hashTarget && pblock->IsProofOfWork()) - return error("BitcoinMiner : proof-of-work not meeting target"); - - //// debug print - printf("BitcoinMiner:\n"); - printf("new block found \n hash: %s \ntarget: %s\n", hash.GetHex().c_str(), hashTarget.GetHex().c_str()); - pblock->print(); - printf("generated %s\n", FormatMoney(pblock->vtx[0].vout[0].nValue).c_str()); - - // Found a solution - { - LOCK(cs_main); - if (pblock->hashPrevBlock != hashBestChain) - return error("BitcoinMiner : generated block is stale"); - - // Remove key from key pool - reservekey.KeepKey(); - - // Track how many getdata requests this block gets - { - LOCK(wallet.cs_wallet); - wallet.mapRequestCount[pblock->GetHash()] = 0; - } - - // Process this block the same as if we had received it from another node - if (!ProcessBlock(NULL, pblock)) - return error("BitcoinMiner : ProcessBlock, block not accepted"); - } - - return true; -} - -void static ThreadBitcoinMiner(void* parg); - -static bool fGenerateBitcoins = false; -static bool fLimitProcessors = false; -static int nLimitProcessors = -1; - - - -void BitcoinMiner(CWallet *pwallet, bool fProofOfStake) -{ - - - printf("CPUMiner started for proof-of-%s\n", fProofOfStake? "stake" : "work"); - SetThreadPriority(THREAD_PRIORITY_LOWEST); - - // Make this thread recognisable as the mining thread - RenameThread("bitcoin-miner"); - - // Each thread has its own key and counter - CReserveKey reservekey(pwallet); - unsigned int nExtraNonce = 0; - - while (fGenerateBitcoins || fProofOfStake) - { - if (fShutdown) - return; - - while (vNodes.empty() || IsInitialBlockDownload() || pwallet->IsLocked()) - { - nLastCoinStakeSearchInterval = 0; - Sleep(1000); - if (fShutdown) - return; - if (!fGenerateBitcoins && !fProofOfStake) - return; - } - - // - // Create new block - // - unsigned int nTransactionsUpdatedLast = nTransactionsUpdated; - CBlockIndex* pindexPrev = pindexBest; - - auto_ptr pblock(CreateNewBlock(pwallet, fProofOfStake)); - if (!pblock.get()) - return; - IncrementExtraNonce(pblock.get(), pindexPrev, nExtraNonce); - - if (fProofOfStake) - { - // ppcoin: if proof-of-stake block found then process block - if (pblock->IsProofOfStake()) - { - - - printf("CPUMiner : proof-of-stake block found %s\n", pblock->GetHash().ToString().c_str()); - - if (!pblock->SignBlock(*pwalletMain)) - { - continue; - } - strMintWarning = ""; - printf("CPUMiner : proof-of-stake block was signed %s\n", pblock->GetHash().ToString().c_str()); - SetThreadPriority(THREAD_PRIORITY_NORMAL); - CheckWork(pblock.get(), *pwalletMain, reservekey); - SetThreadPriority(THREAD_PRIORITY_LOWEST); - } - Sleep(500); - continue; - } - - printf("Running BitcoinMiner with %"PRIszu" transactions in block (%u bytes)\n", pblock->vtx.size(), - ::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION)); - - // - // Pre-build hash buffers - // - char pmidstatebuf[32+16]; char* pmidstate = alignup<16>(pmidstatebuf); - char pdatabuf[128+16]; char* pdata = alignup<16>(pdatabuf); - char phash1buf[64+16]; char* phash1 = alignup<16>(phash1buf); - - FormatHashBuffers(pblock.get(), pmidstate, pdata, phash1); - - unsigned int& nBlockTime = *(unsigned int*)(pdata + 64 + 4); - unsigned int& nBlockBits = *(unsigned int*)(pdata + 64 + 8); - - - - // - // Search - // - int64 nStart = GetTime(); - uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256(); - - loop - { - unsigned int nHashesDone = 0; - - uint256 thash; - loop - { - thash = pblock->GetHash(); - if (thash <= hashTarget) - { - - if (!pblock->SignBlock(*pwalletMain)) - { - break; - } - - SetThreadPriority(THREAD_PRIORITY_NORMAL); - CheckWork(pblock.get(), *pwallet, reservekey); - SetThreadPriority(THREAD_PRIORITY_LOWEST); - break; - } - pblock->nNonce += 1; - nHashesDone += 1; - if ((pblock->nNonce & 0xFF) == 0) - break; - } - - // Meter hashes/sec - static int64 nHashCounter; - if (nHPSTimerStart == 0) - { - nHPSTimerStart = GetTimeMillis(); - nHashCounter = 0; - } - else - nHashCounter += nHashesDone; - if (GetTimeMillis() - nHPSTimerStart > 4000) - { - static CCriticalSection cs; - { - LOCK(cs); - if (GetTimeMillis() - nHPSTimerStart > 4000) - { - dHashesPerSec = 1000.0 * nHashCounter / (GetTimeMillis() - nHPSTimerStart); - nHPSTimerStart = GetTimeMillis(); - nHashCounter = 0; - static int64 nLogTime; - if (GetTime() - nLogTime > 30 * 60) - { - nLogTime = GetTime(); - printf("hashmeter %6.0f khash/s\n", dHashesPerSec/1000.0); - } - } - } - } - - // Check for stop or if block needs to be rebuilt - boost::this_thread::interruption_point(); - if (vNodes.empty()) - break; - if (pblock->nNonce >= 0xffff0000) - break; - if (nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 60) - break; - if (pindexPrev != pindexBest) - break; - - // Update nTime every few seconds - pblock->UpdateTime(pindexPrev); - nBlockTime = ByteReverse(pblock->nTime); - if (fTestNet) - { - // Changing pblock->nTime can change work required on testnet: - nBlockBits = ByteReverse(pblock->nBits); - hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256(); - } - } - } - - -} - - -void static ThreadBitcoinMiner(void* parg) -{ - CWallet* pwallet = (CWallet*)parg; - try - { - vnThreadsRunning[THREAD_MINER]++; - BitcoinMiner(pwallet, false); - vnThreadsRunning[THREAD_MINER]--; - } - catch (std::exception& e) { - vnThreadsRunning[THREAD_MINER]--; - PrintException(&e, "ThreadBitcoinMiner()"); - } catch (...) { - vnThreadsRunning[THREAD_MINER]--; - PrintException(NULL, "ThreadBitcoinMiner()"); - } - nHPSTimerStart = 0; - if (vnThreadsRunning[THREAD_MINER] == 0) - dHashesPerSec = 0; - printf("ThreadBitcoinMiner exiting, %d threads remaining\n", vnThreadsRunning[THREAD_MINER]); -} - - -void GenerateBitcoins(bool fGenerate, CWallet* pwallet) -{ - fGenerateBitcoins = fGenerate; - nLimitProcessors = GetArg("-genproclimit", -1); - if (nLimitProcessors == 0) - fGenerateBitcoins = false; - fLimitProcessors = (nLimitProcessors != -1); - - if (fGenerate) - { - int nProcessors = boost::thread::hardware_concurrency(); - printf("%d processors\n", nProcessors); - if (nProcessors < 1) - nProcessors = 1; - if (fLimitProcessors && nProcessors > nLimitProcessors) - nProcessors = nLimitProcessors; - int nAddThreads = nProcessors - vnThreadsRunning[THREAD_MINER]; - printf("Starting %d BitcoinMiner threads\n", nAddThreads); - for (int i = 0; i < nAddThreads; i++) - { - if (!NewThread(ThreadBitcoinMiner, pwallet)) - printf("Error: NewThread(ThreadBitcoinMiner) failed\n"); - Sleep(10); + txid = 0; + for (auto mit : mapProposals) { + if (mit.second == hashProposal) { + txid = mit.first; + return true; } } + return false; } diff --git a/src/main.h b/src/main.h index 920658951..5009bde78 100644 --- a/src/main.h +++ b/src/main.h @@ -11,7 +11,9 @@ #include "script.h" #include "scrypt_mine.h" #include "hashblock.h" - +#include "votetally.h" +#include "voteproposalmanager.h" +#include #include class CWallet; @@ -39,10 +41,10 @@ static const int64 MIN_RELAY_TX_FEE = .00001 * COIN; static const int64 MAX_MONEY = 60000000 * COIN; static const int64 MAX_MONEY2 = 60000000 * COIN; // 60 mil static const int64 MAX_MINT_PROOF_OF_STAKE = 2.00 * COIN; // 200% annual interest - static const int64 MAX_MINT_PROOF_OF_STAKEV2 = 7.50 * COIN; // 750% annual interest static const unsigned int FORK_TIME = 1404678625; // Sun, 06 Jul 2014 20:30:25 GMT - +static const unsigned int FORK_TIME2 = 1423836000; // Fri, 13 Feb 2015 14:00:00 GMT +static const unsigned int VOTING_START = 9999999; // when voting becomes available on mainnet static const int64 MIN_TXOUT_AMOUNT = MIN_TX_FEE; inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); } @@ -56,19 +58,24 @@ static const int fHaveUPnP = false; #endif static const uint256 hashGenesisBlockOfficial("0x000005fe04e512585c3611369c7ce23f130958038c18a462577d002680dab4fc"); -static const uint256 hashGenesisBlockTestNet ("0x0000076130e1a816bab8f26310839ab601305b2315dc3b8b1a250faa0cb1f9a8"); - -static const int64 nMaxClockDrift = 15 * 60; // fifteen minutes +static const uint256 hashGenesisBlockTestNet ("0x534d8009c099b04d05d7475f48eea977ca2fedaf409e233c884eff34d2efdb8e"); +inline int64 GetClockDrift(int64 nTime) +{ + if(nTime < FORK_TIME2) + return 15 * 60; + else + return 60; +} +static const int64 MAX_TIME_SINCE_BEST_BLOCK = 10; // how many seconds to wait before sending next PushGetBlocks() extern CScript COINBASE_FLAGS; - - extern CCriticalSection cs_main; extern std::map mapBlockIndex; extern std::set > setStakeSeen; extern uint256 hashGenesisBlock; extern CBlockIndex* pindexGenesisBlock; extern unsigned int nStakeMinAge; +extern unsigned int nStakeMinAgeV2; extern int nCoinbaseMaturity; extern int nBestHeight; extern CBigNum bnBestChainTrust; @@ -87,6 +94,17 @@ extern CCriticalSection cs_setpwalletRegistered; extern std::set setpwalletRegistered; extern unsigned char pchMessageStart[4]; extern std::map mapOrphanBlocks; +extern bool fHaveGUI; +extern std::map mapHashedBlocks; +extern std::map > mapGetBlocksRequests; +extern std::map mapPeerRejectedBlocks; +extern std::map mapProposals; // txid, blockhash +extern std::map mapPendingProposals; // txid, blockhash +extern bool fStrictProtocol; +extern bool fStrictIncoming; +extern bool fGenerateBitcoins; +extern bool fWalletStaking; +extern CVoteProposalManager proposalManager; // Settings extern int64 nTransactionFee; @@ -94,7 +112,6 @@ extern int64 nTransactionFee; // Minimum disk space required - used in CheckDiskSpace() static const uint64 nMinDiskSpace = 52428800; - class CReserveKey; class CTxDB; class CTxIndex; @@ -103,6 +120,7 @@ void RegisterWallet(CWallet* pwalletIn); void UnregisterWallet(CWallet* pwalletIn); void SyncWithWallets(const CTransaction& tx, const CBlock* pblock = NULL, bool fUpdate = false, bool fConnect = true); bool ProcessBlock(CNode* pfrom, CBlock* pblock); +bool ProcessBlock(CNode* pfrom, CBlock* pblock, std::string& strErr); bool CheckDiskSpace(uint64 nAdditionalBytes=0); FILE* OpenBlockFile(unsigned int nFile, unsigned int nBlockPos, const char* pszMode="rb"); FILE* AppendBlockFile(unsigned int& nFileRet); @@ -122,6 +140,8 @@ int64 GetProofOfWorkReward(int nHeight, int64 nFees, uint256 prevHash); int64 GetProofOfStakeReward(int64 nCoinAge, unsigned int nBits, unsigned int nTime, int nHeight); int64 GetProofOfStakeRewardV1(int64 nCoinAge, unsigned int nBits, unsigned int nTime, int nHeight); int64 GetProofOfStakeRewardV2(int64 nCoinAge, unsigned int nBits, unsigned int nTime, int nHeight); +CBigNum GetWeightSpent(CBlockIndex* pindex); +CBigNum GetMedianWeightOverPeriod(int nBlocksCount); unsigned int ComputeMinWork(unsigned int nBase, int64 nTime); unsigned int ComputeMinStake(unsigned int nBase, int64 nTime, unsigned int nBlockTime); int GetNumBlocksOfPeers(); @@ -130,19 +150,10 @@ std::string GetWarnings(std::string strFor); bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock); uint256 WantedByOrphan(const CBlock* pblockOrphan); const CBlockIndex* GetLastBlockIndex(const CBlockIndex* pindex, bool fProofOfStake); -void BitcoinMiner(CWallet *pwallet, bool fProofOfStake); +unsigned int GetNextTargetRequired(const CBlockIndex* pindexLast, bool fProofOfStake); void ResendWalletTransactions(); - - - - - - - - - - bool GetWalletFile(CWallet* pwallet, std::string &strWalletFileOut); +bool GetProposalTXID(const uint256& hashProposal, uint256& txid); /** Position on disk for a particular transaction. */ class CDiskTxPos @@ -195,8 +206,6 @@ class CDiskTxPos } }; - - /** An inpoint - a combination of a transaction and an index n into its vin */ class CInPoint { @@ -210,8 +219,6 @@ class CInPoint bool IsNull() const { return (ptx == NULL && n == (unsigned int) -1); } }; - - /** An outpoint - a combination of a transaction hash and an index n into its vout */ class COutPoint { @@ -251,9 +258,6 @@ class COutPoint } }; - - - /** An input of a transaction. It contains the location of the previous * transaction's output that it claims and a signature that matches the * output's public key. @@ -334,9 +338,6 @@ class CTxIn } }; - - - /** An output of a transaction. It contains the public key that the next input * must be able to sign with to claim it. */ @@ -420,9 +421,6 @@ class CTxOut } }; - - - enum GetMinFee_mode { GMF_BLOCK, @@ -547,6 +545,7 @@ class CTransaction return (IsCoinBase() || IsCoinStake()); } + bool IsProposal() const; /** Check for standard transaction types @return True if all outputs (scriptPubKeys) use only standard transaction forms @@ -660,14 +659,14 @@ class CTransaction { std::string str; str += IsCoinBase()? "Coinbase" : (IsCoinStake()? "Coinstake" : "CTransaction"); - str += strprintf("(hash=%s, nTime=%d, ver=%d, vin.size=%"PRIszu", vout.size=%"PRIszu", nLockTime=%d)\n", - GetHash().ToString().substr(0,10).c_str(), - nTime, - nVersion, - vin.size(), - vout.size(), - nLockTime - ); + str += strprintf("(hash=%s, nTime=%d, ver=%d, vin.size=%lu, vout.size=%lu, nLockTime=%d)\n", + GetHash().ToString().substr(0,10).c_str(), + nTime, + nVersion, + vin.size(), + vout.size(), + nLockTime + ); for (unsigned int i = 0; i < vin.size(); i++) str += " " + vin[i].ToString() + "\n"; @@ -724,10 +723,6 @@ class CTransaction const CTxOut& GetOutputFor(const CTxIn& input, const MapPrevTx& inputs) const; }; - - - - /** A transaction with a merkle branch linking it to the block chain. */ class CMerkleTx : public CTransaction { @@ -777,9 +772,6 @@ class CMerkleTx : public CTransaction bool AcceptToMemoryPool(); }; - - - /** A txdb record that contains the disk location of a transaction and the * locations of transactions that spend its outputs. vSpent is really only * used as a flag, but having the location is very helpful for debugging. @@ -834,10 +826,6 @@ class CTxIndex }; - - - - /** Nodes collect new transactions into a block, hash them into a hash tree, * and scan through nonce values to make the block's hash satisfy proof-of-work * requirements. When they solve the proof-of-work, they broadcast the block @@ -852,6 +840,7 @@ class CBlock { public: // header + static const int VOTING_VERSION = 0x50000000; static const int CURRENT_VERSION=4; int nVersion; uint256 hashPrevBlock; @@ -868,6 +857,7 @@ class CBlock // memory only mutable std::vector vMerkleTree; + uint256 hashBlock; // Denial-of-service detection: mutable int nDoS; @@ -920,10 +910,9 @@ class CBlock return (nBits == 0); } - uint256 GetHash() const - { - return Hash9(BEGIN(nVersion), END(nNonce)); - } + uint256 GetHash() const; + + void SetHash(uint256 hash){ this->hashBlock = hash; } int64 GetBlockTime() const { @@ -970,7 +959,7 @@ class CBlock uint256 BuildMerkleTree() const { vMerkleTree.clear(); - BOOST_FOREACH(const CTransaction& tx, vtx) + for (const CTransaction& tx : vtx) vMerkleTree.push_back(tx.GetHash()); int j = 0; for (int nSize = vtx.size(); nSize > 1; nSize = (nSize + 1) / 2) @@ -1072,34 +1061,13 @@ class CBlock - void print() const - { - printf("CBlock(hash=%s, ver=%d, hashPrevBlock=%s, hashMerkleRoot=%s, nTime=%u, nBits=%08x, nNonce=%u, vtx=%"PRIszu", vchBlockSig=%s)\n", - GetHash().ToString().c_str(), - nVersion, - hashPrevBlock.ToString().c_str(), - hashMerkleRoot.ToString().c_str(), - nTime, nBits, nNonce, - vtx.size(), - HexStr(vchBlockSig.begin(), vchBlockSig.end()).c_str()); - for (unsigned int i = 0; i < vtx.size(); i++) - { - printf(" "); - vtx[i].print(); - } - printf(" vMerkleTree: "); - for (unsigned int i = 0; i < vMerkleTree.size(); i++) - printf("%s ", vMerkleTree[i].ToString().substr(0,10).c_str()); - printf("\n"); - } - - + void print() const; bool DisconnectBlock(CTxDB& txdb, CBlockIndex* pindex); bool ConnectBlock(CTxDB& txdb, CBlockIndex* pindex, bool fJustCheck=false); bool ReadFromDisk(const CBlockIndex* pindex, bool fReadTransactions=true); bool SetBestChain(CTxDB& txdb, CBlockIndex* pindexNew); bool AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos); - bool CheckBlock(bool fCheckPOW=true, bool fCheckMerkleRoot=true) const; + bool CheckBlock(bool fCheckPOW=true, bool fCheckMerkleRoot=true, bool fFullCheck=true) const; bool AcceptBlock(); bool GetCoinAge(uint64& nCoinAge) const; // ppcoin: calculate total coin age spent in block bool SignBlock(const CKeyStore& keystore); @@ -1109,11 +1077,6 @@ class CBlock bool SetBestChainInner(CTxDB& txdb, CBlockIndex *pindexNew); }; - - - - - /** The block chain is a tree shaped structure starting with the * genesis block at the root, with each block potentially having multiple * candidates to be the next block. pprev and pnext link a path through the @@ -1151,6 +1114,9 @@ class CBlockIndex unsigned int nStakeTime; uint256 hashProofOfStake; + //Voting + CVoteTally tally; + // block header int nVersion; uint256 hashMerkleRoot; @@ -1175,6 +1141,7 @@ class CBlockIndex hashProofOfStake = 0; prevoutStake.SetNull(); nStakeTime = 0; + tally.SetNull(); nVersion = 0; hashMerkleRoot = 0; @@ -1198,6 +1165,7 @@ class CBlockIndex nStakeModifier = 0; nStakeModifierChecksum = 0; hashProofOfStake = 0; + tally.SetNull(); if (block.IsProofOfStake()) { SetProofOfStake(); @@ -1330,7 +1298,7 @@ class CBlockIndex std::string ToString() const { - return strprintf("CBlockIndex(nprev=%p, pnext=%p, nFile=%u, nBlockPos=%-6d nHeight=%d, nMint=%s, nMoneySupply=%s, nFlags=(%s)(%d)(%s), nStakeModifier=%016"PRI64x", nStakeModifierChecksum=%08x, hashProofOfStake=%s, prevoutStake=(%s), nStakeTime=%d merkle=%s, hashBlock=%s)", + return strprintf("CBlockIndex(nprev=%p, pnext=%p, nFile=%u, nBlockPos=%-6d nHeight=%d, nMint=%s, nMoneySupply=%s, nFlags=(%s)(%d)(%s), nStakeModifier=%016llu, nStakeModifierChecksum=%08x, hashProofOfStake=%s, prevoutStake=(%s), nStakeTime=%d merkle=%s, hashBlock=%s)", pprev, pnext, nFile, nBlockPos, nHeight, FormatMoney(nMint).c_str(), FormatMoney(nMoneySupply).c_str(), GeneratedStakeModifier() ? "MOD" : "-", GetStakeEntropyBit(), IsProofOfStake()? "PoS" : "PoW", @@ -1347,11 +1315,12 @@ class CBlockIndex } }; - - /** Used to marshal pointers into hashes for db storage. */ class CDiskBlockIndex : public CBlockIndex { +private: + uint256 blockHash; + public: uint256 hashPrev; uint256 hashNext; @@ -1360,6 +1329,7 @@ class CDiskBlockIndex : public CBlockIndex { hashPrev = 0; hashNext = 0; + blockHash = 0; } explicit CDiskBlockIndex(CBlockIndex* pindex) : CBlockIndex(*pindex) @@ -1387,11 +1357,10 @@ class CDiskBlockIndex : public CBlockIndex READWRITE(nStakeTime); READWRITE(hashProofOfStake); } - else if (fRead) - { - const_cast(this)->prevoutStake.SetNull(); - const_cast(this)->nStakeTime = 0; - const_cast(this)->hashProofOfStake = 0; + else if (fRead) { + const_cast(this)->prevoutStake.SetNull(); + const_cast(this)->nStakeTime = 0; + const_cast(this)->hashProofOfStake = 0; } // block header @@ -1401,10 +1370,19 @@ class CDiskBlockIndex : public CBlockIndex READWRITE(nTime); READWRITE(nBits); READWRITE(nNonce); + READWRITE(blockHash); + + if (this->nVersion >= CBlock::VOTING_VERSION) { + if (fTestNet || nHeight >= (int)VOTING_START) + READWRITE(tally); + } ) uint256 GetBlockHash() const { + if(blockHash != 0) + return blockHash; + CBlock block; block.nVersion = nVersion; block.hashPrevBlock = hashPrev; @@ -1412,7 +1390,9 @@ class CDiskBlockIndex : public CBlockIndex block.nTime = nTime; block.nBits = nBits; block.nNonce = nNonce; - return block.GetHash(); + const_cast(this)->blockHash = block.GetHash(); + + return blockHash; } @@ -1433,13 +1413,6 @@ class CDiskBlockIndex : public CBlockIndex } }; - - - - - - - /** Describes a place in the block chain to another node such that if the * other node doesn't have the same branch, it can find a recent common trunk. * The further back it is, the further before the fork it may be. @@ -1567,13 +1540,6 @@ class CBlockLocator } }; - - - - - - - class CTxMemPool { public: diff --git a/src/makefile.bsd b/src/makefile.bsd deleted file mode 100644 index ec4ee2ae7..000000000 --- a/src/makefile.bsd +++ /dev/null @@ -1,189 +0,0 @@ -# Copyright (c) 2009-2010 Satoshi Nakamoto -# Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. - -USE_UPNP:=0 -USE_IPV6:=1 - -LINK:=$(CXX) - -DEFS=-DBOOST_SPIRIT_THREADSAFE - -DEFS += $(addprefix -I,$(CURDIR) $(CURDIR)/obj $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH)) -LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH)) - -TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data) - -LMODE = dynamic -LMODE2 = dynamic -ifdef STATIC - LMODE = static - ifeq (${STATIC}, all) - LMODE2 = static - endif -else - TESTDEFS += -DBOOST_TEST_DYN_LINK -endif - -# for boost 1.37, add -mt to the boost libraries -LIBS += \ - -Wl,-B$(LMODE) \ - -l boost_system$(BOOST_LIB_SUFFIX) \ - -l boost_filesystem$(BOOST_LIB_SUFFIX) \ - -l boost_program_options$(BOOST_LIB_SUFFIX) \ - -l boost_thread$(BOOST_LIB_SUFFIX) \ - -l db_cxx$(BDB_LIB_SUFFIX) \ - -l ssl \ - -l crypto \ - -l execinfo - -ifndef USE_UPNP - override USE_UPNP = - -endif -ifneq (${USE_UPNP}, -) - LIBS += -l miniupnpc - DEFS += -DUSE_UPNP=$(USE_UPNP) -endif - -ifneq (${USE_IPV6}, -) - DEFS += -DUSE_IPV6=$(USE_IPV6) -endif - -LIBS+= \ - -Wl,-B$(LMODE2) \ - -l z \ - -l dl \ - -l pthread - - -# Hardening -# Make some classes of vulnerabilities unexploitable in case one is discovered. -# - # This is a workaround for Ubuntu bug #691722, the default -fstack-protector causes - # -fstack-protector-all to be ignored unless -fno-stack-protector is used first. - # see: https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/691722 - HARDENING=-fno-stack-protector - - # Stack Canaries - # Put numbers at the beginning of each stack frame and check that they are the same. - # If a stack buffer if overflowed, it writes over the canary number and then on return - # when that number is checked, it won't be the same and the program will exit with - # a "Stack smashing detected" error instead of being exploited. - HARDENING+=-fstack-protector-all -Wstack-protector - - # Make some important things such as the global offset table read only as soon as - # the dynamic linker is finished building it. This will prevent overwriting of addresses - # which would later be jumped to. - LDHARDENING+=-Wl,-z,relro -Wl,-z,now - - # Build position independent code to take advantage of Address Space Layout Randomization - # offered by some kernels. - # see doc/build-unix.txt for more information. - ifdef PIE - HARDENING+=-fPIE - LDHARDENING+=-pie - endif - - # -D_FORTIFY_SOURCE=2 does some checking for potentially exploitable code patterns in - # the source such overflowing a statically defined buffer. - HARDENING+=-D_FORTIFY_SOURCE=2 -# - - -DEBUGFLAGS=-g - -# CXXFLAGS can be specified on the make command line, so we use xCXXFLAGS that only -# adds some defaults in front. Unfortunately, CXXFLAGS=... $(CXXFLAGS) does not work. -xCXXFLAGS=-O0 -msse2 -pthread -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter \ - $(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS) - -# LDFLAGS can be specified on the make command line, so we use xLDFLAGS that only -# adds some defaults in front. Unfortunately, LDFLAGS=... $(LDFLAGS) does not work. -xLDFLAGS=$(LDHARDENING) $(LDFLAGS) - -OBJS= \ - obj/alert.o \ - obj/version.o \ - obj/checkpoints.o \ - obj/netbase.o \ - obj/addrman.o \ - obj/crypter.o \ - obj/key.o \ - obj/db.o \ - obj/init.o \ - obj/irc.o \ - obj/keystore.o \ - obj/main.o \ - obj/net.o \ - obj/protocol.o \ - obj/bitcoinrpc.o \ - obj/rpcdump.o \ - obj/rpcnet.o \ - obj/rpcmining.o \ - obj/rpcwallet.o \ - obj/rpcblockchain.o \ - obj/rpcrawtransaction.o \ - obj/script.o \ - obj/sync.o \ - obj/util.o \ - obj/wallet.o \ - obj/walletdb.o \ - obj/noui.o \ - obj/kernel.o \ - obj/pbkdf2.o \ - obj/scrypt_mine.o \ - obj/scrypt-x86.o \ - obj/scrypt-x86_64.o - - -all: hyperstaked - -test check: test_hyperstake FORCE - ./test_BottleCaps - -# auto-generated dependencies: --include obj/*.P --include obj-test/*.P - -obj/build.h: FORCE - /bin/sh ../share/genbuild.sh obj/build.h -version.cpp: obj/build.h -DEFS += -DHAVE_BUILD_INFO - -obj/scrypt-x86.o: scrypt-x86.S - $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $< - -obj/scrypt-x86_64.o: scrypt-x86_64.S - $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $< - -obj/%.o: %.cpp - $(CXX) -c $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $< - @cp $(@:%.o=%.d) $(@:%.o=%.P); \ - sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ - -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \ - rm -f $(@:%.o=%.d) - -hyperstaked: $(OBJS:obj/%=obj/%) - $(LINK) $(xCXXFLAGS) -o $@ $^ $(xLDFLAGS) $(LIBS) - -TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp)) - -obj-test/%.o: test/%.cpp - $(CXX) -c $(TESTDEFS) $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $< - @cp $(@:%.o=%.d) $(@:%.o=%.P); \ - sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ - -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \ - rm -f $(@:%.o=%.d) - -test_hyperstake: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%)) - $(LINK) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-B$(LMODE) -lboost_unit_test_framework $(xLDFLAGS) $(LIBS) - -clean: - -rm -f hyperstaked test_hyperstake - -rm -f obj/*.o - -rm -f obj-test/*.o - -rm -f obj/*.P - -rm -f obj-test/*.P - -rm -f obj/build.h - -FORCE: diff --git a/src/makefile.linux-mingw b/src/makefile.linux-mingw deleted file mode 100644 index 439079abd..000000000 --- a/src/makefile.linux-mingw +++ /dev/null @@ -1,137 +0,0 @@ -# Copyright (c) 2009-2010 Satoshi Nakamoto -# Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. - -DEPSDIR:=/usr/i586-mingw32msvc - -USE_UPNP:=0 -USE_IPV6:=1 - -INCLUDEPATHS= \ - -I"$(CURDIR)" \ - -I"$(CURDIR)"/obj \ - -I"$(DEPSDIR)/boost_1_50_0" \ - -I"$(DEPSDIR)/db-4.8.30.NC/build_unix" \ - -I"$(DEPSDIR)/openssl-1.0.1g/include" \ - -I"$(DEPSDIR)" - -LIBPATHS= \ - -L"$(DEPSDIR)/boost_1_50_0/stage/lib" \ - -L"$(DEPSDIR)/db-4.8.30.NC/build_unix" \ - -L"$(DEPSDIR)/openssl-1.0.1g" - -LIBS= \ - -l boost_system-mt-s \ - -l boost_filesystem-mt-s \ - -l boost_program_options-mt-s \ - -l boost_thread_win32-mt-s \ - -l boost_chrono-mt-s \ - -l db_cxx \ - -l ssl \ - -l crypto - -DEFS=-D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE -DEBUGFLAGS=-g -CFLAGS=-O2 -msse2 -w -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) -LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat - -TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data) - -ifndef USE_UPNP - override USE_UPNP = - -endif -ifneq (${USE_UPNP}, -) - LIBPATHS += -L"$(DEPSDIR)/miniupnpc" - LIBS += -l miniupnpc -l iphlpapi - DEFS += -DSTATICLIB -DUSE_UPNP=$(USE_UPNP) -endif - -ifneq (${USE_IPV6}, -) - DEFS += -DUSE_IPV6=$(USE_IPV6) -endif - -LIBS += -l mingwthrd -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_32 -l mswsock -l shlwapi - -# TODO: make the mingw builds smarter about dependencies, like the linux/osx builds are -HEADERS = $(wildcard *.h) - -OBJS= \ - obj/alert.o \ - obj/version.o \ - obj/checkpoints.o \ - obj/netbase.o \ - obj/addrman.o \ - obj/crypter.o \ - obj/key.o \ - obj/db.o \ - obj/init.o \ - obj/irc.o \ - obj/keystore.o \ - obj/main.o \ - obj/net.o \ - obj/protocol.o \ - obj/bitcoinrpc.o \ - obj/rpcdump.o \ - obj/rpcnet.o \ - obj/rpcmining.o \ - obj/rpcwallet.o \ - obj/rpcblockchain.o \ - obj/rpcrawtransaction.o \ - obj/script.o \ - obj/sync.o \ - obj/util.o \ - obj/wallet.o \ - obj/walletdb.o \ - obj/noui.o \ - obj/kernel.o \ - obj/pbkdf2.o \ - src/blake.o \ - src/bmw.o \ - src/groestl.o \ - src/jh.o \ - src/keccak.o \ - src/skein.o \ - src/luffa.o \ - src/cubehash.o \ - src/shavite.o \ - src/echo.o \ - src/simd.o - -all: hyperstaked.exe - -obj/build.h: FORCE - /bin/sh ../share/genbuild.sh obj/build.h -version.cpp: obj/build.h -DEFS += -DHAVE_BUILD_INFO - -obj/%.o: %.cpp $(HEADERS) - i586-mingw32msvc-g++ -c $(CFLAGS) -o $@ $< - -hyperstaked.exe: $(OBJS:obj/%=obj/%) - i586-mingw32msvc-g++ $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) - -TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp)) - -obj-test/%.o: test/%.cpp $(HEADERS) - i586-mingw32msvc-g++ -c $(TESTDEFS) $(CFLAGS) -o $@ $< - -obj/%.o: %.c $(HEADERS) - $(CXX) -c $(CFLAGS) -fpermissive -o $@ $< - -test_hyperstake.exe: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%)) - i586-mingw32msvc-g++ $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ -lboost_unit_test_framework-mt-s $(LIBS) - -obj/scrypt-x86.o: scrypt-x86.S - i586-mingw32msvc-g++ -c $(CFLAGS) -MMD -o $@ $< - -obj/scrypt-x86_64.o: scrypt-x86_64.S - i586-mingw32msvc-g++ -c $(CFLAGS) -MMD -o $@ $< - -clean: - -rm -f obj/*.o - -rm -f hyperstaked.exe - -rm -f obj-test/*.o - -rm -f test_hyperstake.exe - -rm -f obj/build.h - -FORCE: diff --git a/src/makefile.mingw b/src/makefile.mingw deleted file mode 100644 index 36a886066..000000000 --- a/src/makefile.mingw +++ /dev/null @@ -1,132 +0,0 @@ -# Copyright (c) 2009-2010 Satoshi Nakamoto -# Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. - -USE_UPNP:=0 -USE_IPV6:=1 - -INCLUDEPATHS= \ - -I"C:/deps/boost_1_55_0" \ - -I"c:/deps/db/build_unix" \ - -L"/deps/miniupnpc" \ - -L"c:/deps/" \ - -I"c:/deps/ssl/include" - -LIBPATHS= \ - -L"C:/deps/boost_1_55_0/stage/lib" \ - -L"c:/deps/db/build_unix" \ - -L"c:/deps/ssl" \ - -L"c:/deps/ \ - -L"/deps/miniupnpc" - -LIBS= \ - -l boost_system-mgw48-mt-d-1_55 \ - -l boost_filesystem-mgw48-mt-d-1_55 \ - -l boost_program_options-mgw48-mt-d-1_55 \ - -l boost_thread-mgw48-mt-d-1_55 \ - -l db_cxx \ - -l ssl \ - -l crypto - -DEFS=-DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -DBOOST_SPIRIT_THREADSAFE -D__NO_SYSTEM_INCLUDES -DEBUGFLAGS=-g -CFLAGS=-mthreads -O2 -msse2 -w -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) -LDFLAGS=-Wl,--dynamicbase -Wl,--nxcompat - -TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data) - -ifndef USE_UPNP - override USE_UPNP = - -endif -ifneq (${USE_UPNP}, -) - INCLUDEPATHS += -I"C:\miniupnpc-1.6-mgw" - LIBPATHS += -L"C:\miniupnpc-1.6-mgw" - LIBS += -l miniupnpc -l iphlpapi - DEFS += -DSTATICLIB -DUSE_UPNP=$(USE_UPNP) -endif - -ifneq (${USE_IPV6}, -) - DEFS += -DUSE_IPV6=$(USE_IPV6) -endif - -LIBS += -l kernel32 -l user32 -l gdi32 -l comdlg32 -l winspool -l winmm -l shell32 -l comctl32 -l ole32 -l oleaut32 -l uuid -l rpcrt4 -l advapi32 -l ws2_32 -l mswsock -l shlwapi - -# TODO: make the mingw builds smarter about dependencies, like the linux/osx builds are -HEADERS = $(wildcard *.h) - -OBJS= \ - obj/alert.o \ - obj/version.o \ - obj/checkpoints.o \ - obj/netbase.o \ - obj/addrman.o \ - obj/crypter.o \ - obj/key.o \ - obj/db.o \ - obj/init.o \ - obj/irc.o \ - obj/keystore.o \ - obj/main.o \ - obj/net.o \ - obj/protocol.o \ - obj/bitcoinrpc.o \ - obj/rpcdump.o \ - obj/rpcnet.o \ - obj/rpcmining.o \ - obj/rpcwallet.o \ - obj/rpcblockchain.o \ - obj/rpcrawtransaction.o \ - obj/script.o \ - obj/sync.o \ - obj/util.o \ - obj/wallet.o \ - obj/walletdb.o \ - obj/noui.o \ - obj/kernel.o \ - obj/pbkdf2.o \ - src/blake.o \ - src/bmw.o \ - src/groestl.o \ - src/jh.o \ - src/keccak.o \ - src/skein.o \ - src/luffa.o \ - src/cubehash.o \ - src/shavite.o \ - src/echo.o \ - src/simd.o - -all: hyperstaked.exe - -test check: test_hyperstake.exe FORCE - test_hyperstake.exe - -obj/%.o: %.cpp $(HEADERS) - g++ -c $(CFLAGS) -o $@ $< - -obj/%.o: %.c $(HEADERS) - $(CXX) -c $(CFLAGS) -fpermissive -o $@ $< - -obj/scrypt-x86.o: scrypt-x86.S - $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $< - -obj/scrypt-x86_64.o: scrypt-x86_64.S - $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $< - -hyperstaked.exe: $(OBJS:obj/%=obj/%) - g++ $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) - -TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp)) - -obj-test/%.o: test/%.cpp $(HEADERS) - g++ -c $(TESTDEFS) $(CFLAGS) -o $@ $< - -test_hyperstake.exe: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%)) - g++ $(CFLAGS) $(LDFLAGS) -o $@ $(LIBPATHS) $^ -lboost_unit_test_framework $(LIBS) - -clean: - -del /Q hyperstake test_hyperstake - -del /Q obj\* - -del /Q obj-test\* - -FORCE: diff --git a/src/makefile.osx b/src/makefile.osx deleted file mode 100644 index 3dd9d7ec6..000000000 --- a/src/makefile.osx +++ /dev/null @@ -1,188 +0,0 @@ -# -*- mode: Makefile; -*- -# Copyright (c) 2011 Bitcoin Developers -# Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. - -# Mac OS X makefile for bitcoin -# Originally by Laszlo Hanyecz (solar@heliacal.net) - -CXX=llvm-g++ -DEPSDIR=/opt/local - -INCLUDEPATHS= \ - -I"$(CURDIR)" \ - -I"$(CURDIR)"/obj \ - -I"$(DEPSDIR)/include" \ - -I"$(DEPSDIR)/include/db48" - -LIBPATHS= \ - -L"$(DEPSDIR)/lib" \ - -L"$(DEPSDIR)/lib/db48" - -USE_UPNP:=1 -USE_IPV6:=1 - -LIBS= -dead_strip - -TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data) - -ifdef STATIC -# Build STATIC if you are redistributing the bitcoind binary -TESTLIBS += \ - $(DEPSDIR)/lib/libboost_unit_test_framework-mt.a -LIBS += \ - $(DEPSDIR)/lib/db48/libdb_cxx-4.8.a \ - $(DEPSDIR)/lib/libboost_system-mt.a \ - $(DEPSDIR)/lib/libboost_filesystem-mt.a \ - $(DEPSDIR)/lib/libboost_program_options-mt.a \ - $(DEPSDIR)/lib/libboost_thread-mt.a \ - $(DEPSDIR)/lib/libssl.a \ - $(DEPSDIR)/lib/libcrypto.a \ - -lz -else -TESTLIBS += \ - -lboost_unit_test_framework-mt -LIBS += \ - -ldb_cxx-4.8 \ - -lboost_system-mt \ - -lboost_filesystem-mt \ - -lboost_program_options-mt \ - -lboost_thread-mt \ - -lssl \ - -lcrypto \ - -lz -TESTDEFS += -DBOOST_TEST_DYN_LINK -endif - -DEFS=-DMAC_OSX -DMSG_NOSIGNAL=0 -DBOOST_SPIRIT_THREADSAFE - -ifdef RELEASE -# Compile for maximum compatibility and smallest size. -# This requires that dependencies are compiled -# the same way. -CFLAGS = -mmacosx-version-min=10.5 -arch x86_64 -O3 -msse2 -else -CFLAGS = -g -msse2 -endif - -# ppc doesn't work because we don't support big-endian -CFLAGS += -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter \ - $(DEBUGFLAGS) $(DEFS) $(INCLUDEPATHS) - -OBJS= \ - obj/alert.o \ - obj/version.o \ - obj/checkpoints.o \ - obj/netbase.o \ - obj/addrman.o \ - obj/crypter.o \ - obj/key.o \ - obj/db.o \ - obj/init.o \ - obj/irc.o \ - obj/keystore.o \ - obj/main.o \ - obj/net.o \ - obj/protocol.o \ - obj/bitcoinrpc.o \ - obj/rpcdump.o \ - obj/rpcnet.o \ - obj/rpcmining.o \ - obj/rpcwallet.o \ - obj/rpcblockchain.o \ - obj/rpcrawtransaction.o \ - obj/script.o \ - obj/sync.o \ - obj/util.o \ - obj/wallet.o \ - obj/walletdb.o \ - obj/noui.o \ - obj/pbkdf2.o \ - obj/kernel.o \ - src/blake.o \ - src/bmw.o \ - src/groestl.o \ - src/jh.o \ - src/keccak.o \ - src/skein.o \ - src/luffa.o \ - src/cubehash.o \ - src/shavite.o \ - src/echo.o \ - src/simd.o - - -ifndef USE_UPNP - override USE_UPNP = - -endif -ifneq (${USE_UPNP}, -) - DEFS += -DUSE_UPNP=$(USE_UPNP) -ifdef STATIC - LIBS += $(DEPSDIR)/lib/libminiupnpc.a -else - LIBS += -lminiupnpc -endif -endif - -ifneq (${USE_IPV6}, -) - DEFS += -DUSE_IPV6=$(USE_IPV6) -endif - -all: hyperstaked - -test check: test_hyperstake FORCE - ./test_hyperstake - -# auto-generated dependencies: --include obj/*.P --include obj-test/*.P - -obj/build.h: FORCE - /bin/sh ../share/genbuild.sh obj/build.h -version.cpp: obj/build.h -DEFS += -DHAVE_BUILD_INFO - -obj/%.o: %.cpp - $(CXX) -c $(CFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $< - @cp $(@:%.o=%.d) $(@:%.o=%.P); \ - sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ - -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \ - rm -f $(@:%.o=%.d) - -obj/%.o: %.c - $(CXX) -c $(CFLAGS) -fpermissive -MMD -MF $(@:%.o=%.d) -o $@ $< - @cp $(@:%.o=%.d) $(@:%.o=%.P); \ - sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ - -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \ - rm -f $(@:%.o=%.d) - -obj/scrypt-x86.o: scrypt-x86.S - $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $< - -obj/scrypt-x86_64.o: scrypt-x86_64.S - $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $< - -hyperstaked: $(OBJS:obj/%=obj/%) - $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) - -TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp)) - -obj-test/%.o: test/%.cpp - $(CXX) -c $(TESTDEFS) $(CFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $< - @cp $(@:%.o=%.d) $(@:%.o=%.P); \ - sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ - -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \ - rm -f $(@:%.o=%.d) - -test_hyperstake: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%)) - $(CXX) $(CFLAGS) -o $@ $(LIBPATHS) $^ $(LIBS) $(TESTLIBS) - -clean: - -rm -f hyperstaked test_hyperstake - -rm -f obj/*.o - -rm -f obj-test/*.o - -rm -f obj/*.P - -rm -f obj-test/*.P - -rm -f obj/build.h - -FORCE: diff --git a/src/makefile.unix b/src/makefile.unix deleted file mode 100644 index bd61b8d9d..000000000 --- a/src/makefile.unix +++ /dev/null @@ -1,204 +0,0 @@ -# Copyright (c) 2009-2010 Satoshi Nakamoto -# Distributed under the MIT/X11 software license, see the accompanying -# file COPYING or http://www.opensource.org/licenses/mit-license.php. - -USE_UPNP:=0 -USE_IPV6:=1 - -LINK:=$(CXX) - -DEFS=-DBOOST_SPIRIT_THREADSAFE - -DEFS += $(addprefix -I,$(CURDIR) $(CURDIR)/obj $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH)) -LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH)) - -TESTDEFS = -DTEST_DATA_DIR=$(abspath test/data) - -LMODE = dynamic -LMODE2 = dynamic -ifdef STATIC - LMODE = dynamic - ifeq (${STATIC}, all) - LMODE2 = dynamic - endif -else - TESTDEFS += -DBOOST_TEST_DYN_LINK -endif - -# for boost 1.37, add -mt to the boost libraries -LIBS += \ - -Wl,-B$(LMODE) \ - -l boost_system$(BOOST_LIB_SUFFIX) \ - -l boost_filesystem$(BOOST_LIB_SUFFIX) \ - -l boost_program_options$(BOOST_LIB_SUFFIX) \ - -l boost_thread$(BOOST_LIB_SUFFIX) \ - -l db_cxx$(BDB_LIB_SUFFIX) \ - -l ssl \ - -l crypto - -ifndef USE_UPNP - override USE_UPNP = - -endif -ifneq (${USE_UPNP}, -) - LIBS += -l miniupnpc - DEFS += -DUSE_UPNP=$(USE_UPNP) -endif - -ifneq (${USE_IPV6}, -) - DEFS += -DUSE_IPV6=$(USE_IPV6) -endif - -LIBS+= \ - -Wl,-B$(LMODE2) \ - -l z \ - -l dl \ - -l pthread - - -# Hardening -# Make some classes of vulnerabilities unexploitable in case one is discovered. -# - # This is a workaround for Ubuntu bug #691722, the default -fstack-protector causes - # -fstack-protector-all to be ignored unless -fno-stack-protector is used first. - # see: https://bugs.launchpad.net/ubuntu/+source/gcc-4.5/+bug/691722 - HARDENING=-fno-stack-protector - - # Stack Canaries - # Put numbers at the beginning of each stack frame and check that they are the same. - # If a stack buffer if overflowed, it writes over the canary number and then on return - # when that number is checked, it won't be the same and the program will exit with - # a "Stack smashing detected" error instead of being exploited. - HARDENING+=-fstack-protector-all -Wstack-protector - - # Make some important things such as the global offset table read only as soon as - # the dynamic linker is finished building it. This will prevent overwriting of addresses - # which would later be jumped to. - LDHARDENING+=-Wl,-z,relro -Wl,-z,now - - # Build position independent code to take advantage of Address Space Layout Randomization - # offered by some kernels. - # see doc/build-unix.txt for more information. - ifdef PIE - HARDENING+=-fPIE - LDHARDENING+=-pie - endif - - # -D_FORTIFY_SOURCE=2 does some checking for potentially exploitable code patterns in - # the source such overflowing a statically defined buffer. - HARDENING+=-D_FORTIFY_SOURCE=2 -# - - -DEBUGFLAGS=-g - -# CXXFLAGS can be specified on the make command line, so we use xCXXFLAGS that only -# adds some defaults in front. Unfortunately, CXXFLAGS=... $(CXXFLAGS) does not work. -xCXXFLAGS=-O2 -msse2 -pthread -Wall -Wextra -Wformat -Wformat-security -Wno-unused-parameter \ - $(DEBUGFLAGS) $(DEFS) $(HARDENING) $(CXXFLAGS) - -# LDFLAGS can be specified on the make command line, so we use xLDFLAGS that only -# adds some defaults in front. Unfortunately, LDFLAGS=... $(LDFLAGS) does not work. -xLDFLAGS=$(LDHARDENING) $(LDFLAGS) - -OBJS= \ - obj/alert.o \ - obj/version.o \ - obj/checkpoints.o \ - obj/netbase.o \ - obj/addrman.o \ - obj/crypter.o \ - obj/key.o \ - obj/db.o \ - obj/init.o \ - obj/irc.o \ - obj/keystore.o \ - obj/main.o \ - obj/net.o \ - obj/protocol.o \ - obj/bitcoinrpc.o \ - obj/rpcdump.o \ - obj/rpcnet.o \ - obj/rpcmining.o \ - obj/rpcwallet.o \ - obj/rpcblockchain.o \ - obj/rpcrawtransaction.o \ - obj/script.o \ - obj/sync.o \ - obj/util.o \ - obj/wallet.o \ - obj/walletdb.o \ - obj/noui.o \ - obj/kernel.o \ - obj/pbkdf2.o \ - obj/cubehash.o \ - obj/luffa.o \ - obj/aes_helper.o \ - obj/echo.o \ - obj/shavite.o \ - obj/simd.o \ - obj/blake.o\ - obj/bmw.o\ - obj/groestl.o\ - obj/jh.o\ - obj/keccak.o\ - obj/skein.o - -all: hyperstaked - -test check: test_hyperstake FORCE - ./test_hyperstake - -# auto-generated dependencies: --include obj/*.P --include obj-test/*.P - -obj/build.h: FORCE - /bin/sh ../share/genbuild.sh obj/build.h -version.cpp: obj/build.h -DEFS += -DHAVE_BUILD_INFO - -obj/scrypt-x86.o: scrypt-x86.S - $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $< - -obj/scrypt-x86_64.o: scrypt-x86_64.S - $(CXX) -c $(xCXXFLAGS) -MMD -o $@ $< - -obj/%.o: %.cpp - $(CXX) -c $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $< - @cp $(@:%.o=%.d) $(@:%.o=%.P); \ - sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ - -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \ - rm -f $(@:%.o=%.d) - -hyperstaked: $(OBJS:obj/%=obj/%) - $(LINK) $(xCXXFLAGS) -o $@ $^ $(xLDFLAGS) $(LIBS) - -TESTOBJS := $(patsubst test/%.cpp,obj-test/%.o,$(wildcard test/*.cpp)) - - -obj/%.o: %.c - $(CXX) -c $(xCXXFLAGS) -fpermissive -MMD -MF $(@:%.o=%.d) -o $@ $< - @cp $(@:%.o=%.d) $(@:%.o=%.P); \ - sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ - -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \ - rm -f $(@:%.o=%.d) - -obj-test/%.o: test/%.cpp - $(CXX) -c $(TESTDEFS) $(xCXXFLAGS) -MMD -MF $(@:%.o=%.d) -o $@ $< - @cp $(@:%.o=%.d) $(@:%.o=%.P); \ - sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \ - -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.o=%.d) >> $(@:%.o=%.P); \ - rm -f $(@:%.o=%.d) - -test_hyperstake: $(TESTOBJS) $(filter-out obj/init.o,$(OBJS:obj/%=obj/%)) - $(LINK) $(xCXXFLAGS) -o $@ $(LIBPATHS) $^ -Wl,-B$(LMODE) -lboost_unit_test_framework $(xLDFLAGS) $(LIBS) - -clean: - -rm -f hyperstaked test_hyperstake - -rm -f obj/*.o - -rm -f obj-test/*.o - -rm -f obj/*.P - -rm -f obj-test/*.P - -rm -f obj/build.h - -FORCE: diff --git a/src/miner.cpp b/src/miner.cpp new file mode 100644 index 000000000..5ee773e54 --- /dev/null +++ b/src/miner.cpp @@ -0,0 +1,772 @@ +#include "miner.h" +#include "hashblock.h" +#include "init.h" +#include "main.h" +#include "util.h" +#include "wallet.h" + +#include +#include + +int static FormatHashBlocks(void* pbuffer, unsigned int len) +{ + unsigned char* pdata = (unsigned char*)pbuffer; + unsigned int blocks = 1 + ((len + 8) / 64); + unsigned char* pend = pdata + 64 * blocks; + std::memset(pdata + len, 0, 64 * blocks - len); + pdata[len] = 0x80; + unsigned int bits = len * 8; + pend[-1] = (bits >> 0) & 0xff; + pend[-2] = (bits >> 8) & 0xff; + pend[-3] = (bits >> 16) & 0xff; + pend[-4] = (bits >> 24) & 0xff; + return blocks; +} + +static const unsigned int pSHA256InitState[8] = + {0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19}; + +void SHA256Transform(void* pstate, void* pinput, const void* pinit) +{ + SHA256_CTX ctx; + unsigned char data[64]; + + SHA256_Init(&ctx); + + for (int i = 0; i < 16; i++) + ((uint32_t*)data)[i] = ByteReverse(((uint32_t*)pinput)[i]); + + for (int i = 0; i < 8; i++) + ctx.h[i] = ((uint32_t*)pinit)[i]; + + SHA256_Update(&ctx, data, sizeof(data)); + for (int i = 0; i < 8; i++) + ((uint32_t*)pstate)[i] = ctx.h[i]; +} + + +uint64 nLastBlockTx = 0; +uint64 nLastBlockSize = 0; +int64 nLastCoinStakeSearchInterval = 0; + +// We want to sort transactions by priority and fee, so: +typedef boost::tuple TxPriority; +class TxPriorityCompare +{ + bool byFee; +public: + TxPriorityCompare(bool _byFee) : byFee(_byFee) { } + bool operator()(const TxPriority& a, const TxPriority& b) + { + if (byFee) + { + if (a.get<1>() == b.get<1>()) + return a.get<0>() < b.get<0>(); + return a.get<1>() < b.get<1>(); + } + else + { + if (a.get<0>() == b.get<0>()) + return a.get<1>() < b.get<1>(); + return a.get<0>() < b.get<0>(); + } + } +}; + +// Some explaining would be appreciated +class COrphan +{ +public: + CTransaction* ptx; + std::set setDependsOn; + double dPriority; + double dFeePerKb; + + COrphan(CTransaction* ptxIn) + { + ptx = ptxIn; + dPriority = dFeePerKb = 0; + } + + void print() const + { + printf("COrphan(hash=%s, dPriority=%.1f, dFeePerKb=%.1f)\n", + ptx->GetHash().ToString().substr(0,10).c_str(), dPriority, dFeePerKb); + BOOST_FOREACH(uint256 hash, setDependsOn) + printf(" setDependsOn %s\n", hash.ToString().substr(0,10).c_str()); + } +}; + +// CreateNewBlock: +// fProofOfStake: try (best effort) to make a proof-of-stake block +CBlock* CreateNewBlock(CWallet* pwallet, bool fProofOfStake) +{ + CReserveKey reservekey(pwallet); + + // Create new block + std::unique_ptr pblock(new CBlock()); + if (!pblock.get()) + return NULL; + + // Only use the first 4 bits for the version encoding + pblock->nVersion = CBlock::VOTING_VERSION; + + //Check to see if proposals need to be voted on + if (mapProposals.size() > 0) { + std::vector votes; + + // Get all the vote objects versions + std::map mapActiveProposals = proposalManager.GetActive(nBestHeight); + if (pwalletMain->mapVoteObjects.size() > 0) { + for (auto it: mapProposals) { + CTransaction tx; + uint256 hashBlock; + if (!GetTransaction(it.first, tx, hashBlock)) { + printf("*** failed to get transaction %s!\n", it.first.GetHex().c_str()); + continue; + } + + if (!tx.IsProposal()) { + printf("*** tx is not a proposal!\n"); + continue; + } + + CVoteProposal proposal; + if (!ProposalFromTransaction(tx, proposal)) { + printf("*** failed to deserialize!\n"); + continue; + } + + if (!mapActiveProposals.count(proposal.GetHash())) { + continue; + } + + if (pwalletMain->mapVoteObjects.count(proposal.GetHash()) == 0) { + //printf("*** mapVoteObjects does not have proposal hash\n"); + continue; + } + + CVoteObject voteObject = pwalletMain->mapVoteObjects[proposal.GetHash()]; + votes.emplace_back(voteObject); + //printf("*** added vote for %s\n", proposal.GetName().c_str()); + } + } + + // Update the block version to have all votes + pblock->nVersion |= CVoteObject::GetCombinedVotes(votes); + } + + // Create coinbase tx + CTransaction txNew; + txNew.vin.resize(1); + txNew.vin[0].prevout.SetNull(); + txNew.vout.resize(1); + txNew.vout[0].scriptPubKey << reservekey.GetReservedKey() << OP_CHECKSIG; + + // Add our coinbase tx as first transaction + pblock->vtx.push_back(txNew); + + // Largest block you're willing to create: + unsigned int nBlockMaxSize = GetArg("-blockmaxsize", MAX_BLOCK_SIZE_GEN/2); + // Limit to betweeen 1K and MAX_BLOCK_SIZE-1K for sanity: + nBlockMaxSize = std::max((unsigned int)1000, std::min((unsigned int)(MAX_BLOCK_SIZE-1000), nBlockMaxSize)); + + // How much of the block should be dedicated to high-priority transactions, + // included regardless of the fees they pay + unsigned int nBlockPrioritySize = GetArg("-blockprioritysize", 27000); + nBlockPrioritySize = std::min(nBlockMaxSize, nBlockPrioritySize); + + // Minimum block size you want to create; block will be filled with free transactions + // until there are no more or the block reaches this size: + unsigned int nBlockMinSize = GetArg("-blockminsize", 0); + nBlockMinSize = std::min(nBlockMaxSize, nBlockMinSize); + + // Fee-per-kilobyte amount considered the same as "free" + // Be careful setting this: if you set it to zero then + // a transaction spammer can cheaply fill blocks using + // 1-satoshi-fee transactions. It should be set above the real + // cost to you of processing a transaction. + int64 nMinTxFee = MIN_TX_FEE; + if (mapArgs.count("-mintxfee")) + ParseMoney(mapArgs["-mintxfee"], nMinTxFee); + + // ppcoin: if coinstake available add coinstake tx + static int64 nLastCoinStakeSearchTime = GetAdjustedTime(); // only initialized at startup + CBlockIndex* pindexPrev = pindexBest; + + if (fProofOfStake && !pwalletMain->fDisableStake) // attempt to find a coinstake && make sure settings allow PoS (presstab HyperStake) + { + pblock->nBits = GetNextTargetRequired(pindexPrev, true); + CTransaction txCoinStake; + int64 nSearchTime = txCoinStake.nTime; // search to current time + if (nSearchTime > nLastCoinStakeSearchTime) + { + // printf(">>> OK1\n"); + if (pwallet->CreateCoinStake(*pwallet, pblock->nBits, nSearchTime-nLastCoinStakeSearchTime, txCoinStake)) + { + if (txCoinStake.nTime >= std::max(pindexPrev->GetMedianTimePast()+1, pindexPrev->GetBlockTime() - GetClockDrift(pindexPrev->GetBlockTime()))) + { // make sure coinstake would meet timestamp protocol + // as it would be the same as the block timestamp + pblock->vtx[0].vout[0].SetEmpty(); + pblock->vtx[0].nTime = txCoinStake.nTime; + pblock->vtx.push_back(txCoinStake); + } + } + nLastCoinStakeSearchInterval = nSearchTime - nLastCoinStakeSearchTime; + nLastCoinStakeSearchTime = nSearchTime; + } + } + + pblock->nBits = GetNextTargetRequired(pindexPrev, pblock->IsProofOfStake()); + + // Collect memory pool transactions into the block + int64 nFees = 0; + { + LOCK2(cs_main, mempool.cs); + CBlockIndex* pindexPrev = pindexBest; + CTxDB txdb("r"); + + // Priority order to process transactions + std::list vOrphan; // list memory doesn't move + std::map > mapDependers; + + // This vector will be sorted into a priority queue: + std::vector vecPriority; + vecPriority.reserve(mempool.mapTx.size()); + for (auto mi = mempool.mapTx.begin(); mi != mempool.mapTx.end(); ++mi) + { + CTransaction& tx = (*mi).second; + if (tx.IsCoinBase() || tx.IsCoinStake() || !tx.IsFinal()) + continue; + + COrphan* porphan = NULL; + double dPriority = 0; + int64 nTotalIn = 0; + bool fMissingInputs = false; + BOOST_FOREACH(const CTxIn& txin, tx.vin) + { + // Read prev transaction + CTransaction txPrev; + CTxIndex txindex; + if (!txPrev.ReadFromDisk(txdb, txin.prevout, txindex)) + { + // This should never happen; all transactions in the memory + // pool should connect to either transactions in the chain + // or other transactions in the memory pool. + if (!mempool.mapTx.count(txin.prevout.hash)) + { + printf("ERROR: mempool transaction missing input\n"); + if (fDebug) assert("mempool transaction missing input" == 0); + fMissingInputs = true; + if (porphan) + vOrphan.pop_back(); + break; + } + + // Has to wait for dependencies + if (!porphan) + { + // Use list for automatic deletion + vOrphan.push_back(COrphan(&tx)); + porphan = &vOrphan.back(); + } + mapDependers[txin.prevout.hash].push_back(porphan); + porphan->setDependsOn.insert(txin.prevout.hash); + nTotalIn += mempool.mapTx[txin.prevout.hash].vout[txin.prevout.n].nValue; + continue; + } + int64 nValueIn = txPrev.vout[txin.prevout.n].nValue; + nTotalIn += nValueIn; + + int nConf = txindex.GetDepthInMainChain(); + dPriority += (double)nValueIn * nConf; + } + if (fMissingInputs) continue; + + // Priority is sum(valuein * age) / txsize + unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); + dPriority /= nTxSize; + + // This is a more accurate fee-per-kilobyte than is used by the client code, because the + // client code rounds up the size to the nearest 1K. That's good, because it gives an + // incentive to create smaller transactions. + double dFeePerKb = double(nTotalIn-tx.GetValueOut()) / (double(nTxSize)/1000.0); + + if (porphan) + { + porphan->dPriority = dPriority; + porphan->dFeePerKb = dFeePerKb; + } + else + vecPriority.push_back(TxPriority(dPriority, dFeePerKb, &(*mi).second)); + } + + // Collect transactions into block + std::map mapTestPool; + uint64 nBlockSize = 1000; + uint64 nBlockTx = 0; + int nBlockSigOps = 100; + bool fSortedByFee = (nBlockPrioritySize <= 0); + + TxPriorityCompare comparer(fSortedByFee); + std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); + + while (!vecPriority.empty()) + { + // Take highest priority transaction off the priority queue: + double dPriority = vecPriority.front().get<0>(); + double dFeePerKb = vecPriority.front().get<1>(); + CTransaction& tx = *(vecPriority.front().get<2>()); + + std::pop_heap(vecPriority.begin(), vecPriority.end(), comparer); + vecPriority.pop_back(); + + // Size limits + unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); + if (nBlockSize + nTxSize >= nBlockMaxSize) + continue; + + // Legacy limits on sigOps: + unsigned int nTxSigOps = tx.GetLegacySigOpCount(); + if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS) + continue; + + // Timestamp limit + if (tx.nTime > GetAdjustedTime() || (pblock->IsProofOfStake() && tx.nTime > pblock->vtx[1].nTime)) + continue; + + // ppcoin: simplify transaction fee - allow free = false + int64 nMinFee = tx.GetMinFee(nBlockSize, false, GMF_BLOCK); + + // Skip free transactions if we're past the minimum block size: + if (fSortedByFee && (dFeePerKb < nMinTxFee) && (nBlockSize + nTxSize >= nBlockMinSize)) + continue; + + // Prioritize by fee once past the priority size or we run out of high-priority + // transactions: + if (!fSortedByFee && + ((nBlockSize + nTxSize >= nBlockPrioritySize) || (dPriority < COIN * 144 / 250))) + { + fSortedByFee = true; + comparer = TxPriorityCompare(fSortedByFee); + std::make_heap(vecPriority.begin(), vecPriority.end(), comparer); + } + + // Connecting shouldn't fail due to dependency on other memory pool transactions + // because we're already processing them in order of dependency + std::map mapTestPoolTmp(mapTestPool); + MapPrevTx mapInputs; + bool fInvalid; + if (!tx.FetchInputs(txdb, mapTestPoolTmp, false, true, mapInputs, fInvalid)) + continue; + + int64 nTxFees = tx.GetValueIn(mapInputs)-tx.GetValueOut(); + if (nTxFees < nMinFee) + continue; + + nTxSigOps += tx.GetP2SHSigOpCount(mapInputs); + if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS) + continue; + + if (!tx.ConnectInputs(txdb, mapInputs, mapTestPoolTmp, CDiskTxPos(1,1,1), pindexPrev, false, true)) + continue; + mapTestPoolTmp[tx.GetHash()] = CTxIndex(CDiskTxPos(1,1,1), tx.vout.size()); + swap(mapTestPool, mapTestPoolTmp); + + // Added + pblock->vtx.push_back(tx); + nBlockSize += nTxSize; + ++nBlockTx; + nBlockSigOps += nTxSigOps; + nFees += nTxFees; + + if (fDebug && GetBoolArg("-printpriority")) + { + printf("priority %.1f feeperkb %.1f txid %s\n", + dPriority, dFeePerKb, tx.GetHash().ToString().c_str()); + } + + // Add transactions that depend on this one to the priority queue + uint256 hash = tx.GetHash(); + if (mapDependers.count(hash)) + { + BOOST_FOREACH(COrphan* porphan, mapDependers[hash]) + { + if (!porphan->setDependsOn.empty()) + { + porphan->setDependsOn.erase(hash); + if (porphan->setDependsOn.empty()) + { + vecPriority.push_back(TxPriority(porphan->dPriority, porphan->dFeePerKb, porphan->ptx)); + std::push_heap(vecPriority.begin(), vecPriority.end(), comparer); + } + } + } + } + } + + nLastBlockTx = nBlockTx; + nLastBlockSize = nBlockSize; + + if (fDebug && GetBoolArg("-printpriority")) + printf("CreateNewBlock(): total size %llu\n", nBlockSize); + + if (pblock->IsProofOfWork()) + pblock->vtx[0].vout[0].nValue = GetProofOfWorkReward(pindexPrev->nHeight+1, nFees, pindexPrev->GetBlockHash()); + + // Fill in header + pblock->hashPrevBlock = pindexPrev->GetBlockHash(); + if (pblock->IsProofOfStake()) + pblock->nTime = pblock->vtx[1].nTime; //same as coinstake timestamp + pblock->nTime = std::max(pindexPrev->GetMedianTimePast()+1, pblock->GetMaxTransactionTime()); + pblock->nTime = std::max(pblock->GetBlockTime(), pindexPrev->GetBlockTime() - GetClockDrift(pindexPrev->GetBlockTime())); + if (pblock->IsProofOfWork()) + pblock->UpdateTime(pindexPrev); + pblock->nNonce = 0; + } + + return pblock.release(); +} + + +void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int& nExtraNonce) +{ + // Update nExtraNonce + static uint256 hashPrevBlock; + if (hashPrevBlock != pblock->hashPrevBlock) + { + nExtraNonce = 0; + hashPrevBlock = pblock->hashPrevBlock; + } + ++nExtraNonce; + unsigned int nHeight = pindexPrev->nHeight+1; // Height first in coinbase required for block.version=2 + pblock->vtx[0].vin[0].scriptSig = (CScript() << nHeight << CBigNum(nExtraNonce)) + COINBASE_FLAGS; + assert(pblock->vtx[0].vin[0].scriptSig.size() <= 100); + + pblock->hashMerkleRoot = pblock->BuildMerkleTree(); +} + + +void FormatHashBuffers(CBlock* pblock, char* pmidstate, char* pdata, char* phash1) +{ + // + // Pre-build hash buffers + // + struct + { + struct unnamed2 + { + int nVersion; + uint256 hashPrevBlock; + uint256 hashMerkleRoot; + unsigned int nTime; + unsigned int nBits; + unsigned int nNonce; + } + block; + unsigned char pchPadding0[64]; + uint256 hash1; + unsigned char pchPadding1[64]; + } + tmp; + memset(&tmp, 0, sizeof(tmp)); + + tmp.block.nVersion = pblock->nVersion; + tmp.block.hashPrevBlock = pblock->hashPrevBlock; + tmp.block.hashMerkleRoot = pblock->hashMerkleRoot; + tmp.block.nTime = pblock->nTime; + tmp.block.nBits = pblock->nBits; + tmp.block.nNonce = pblock->nNonce; + + FormatHashBlocks(&tmp.block, sizeof(tmp.block)); + FormatHashBlocks(&tmp.hash1, sizeof(tmp.hash1)); + + // Byte swap all the input buffer + for (unsigned int i = 0; i < sizeof(tmp)/4; i++) + ((unsigned int*)&tmp)[i] = ByteReverse(((unsigned int*)&tmp)[i]); + + // Precalc the first half of the first hash, which stays constant + SHA256Transform(pmidstate, &tmp.block, pSHA256InitState); + + memcpy(pdata, &tmp.block, 128); + memcpy(phash1, &tmp.hash1, 64); +} + + +bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey) +{ + uint256 hash = pblock->GetHash(); + uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256(); + + if (hash > hashTarget && pblock->IsProofOfWork()) + return error("BitcoinMiner : proof-of-work not meeting target"); + + //// debug print + printf("BitcoinMiner:\n"); + printf("new block found \n hash: %s \ntarget: %s\n", hash.GetHex().c_str(), hashTarget.GetHex().c_str()); + pblock->print(); + printf("generated %s\n", FormatMoney(pblock->vtx[0].vout[0].nValue).c_str()); + + // Found a solution + { + LOCK(cs_main); + if (pblock->hashPrevBlock != hashBestChain) + return error("BitcoinMiner : generated block is stale"); + + // Remove key from key pool + reservekey.KeepKey(); + + // Track how many getdata requests this block gets + { + LOCK(wallet.cs_wallet); + wallet.mapRequestCount[pblock->GetHash()] = 0; + } + + // Process this block the same as if we had received it from another node + if (!ProcessBlock(NULL, pblock)) + return error("BitcoinMiner : ProcessBlock, block not accepted"); + } + + return true; +} + +bool fGenerateBitcoins = false; +static bool fLimitProcessors = false; +static int nLimitProcessors = -1; + +bool fMintableCoins = false; +int nMintableLastCheck = 0; + +void BitcoinMiner(CWallet *pwallet, bool fProofOfStake) +{ + printf("CPUMiner started for proof-of-%s\n", fProofOfStake? "stake" : "work"); + SetThreadPriority(THREAD_PRIORITY_LOWEST); + + // If we are minting, then make sure fGenerateBitcoins knows that + if(fProofOfStake) + fGenerateBitcoins = true; + + // Make this thread recognisable as the mining thread + RenameThread("bitcoin-miner"); + + // Each thread has its own key and counter + CReserveKey reservekey(pwallet); + unsigned int nExtraNonce = 0; + + while (fGenerateBitcoins || fProofOfStake) + { + if (fShutdown) + return; + + fWalletStaking = false; + + while (vNodes.empty() || IsInitialBlockDownload() || pwallet->IsLocked() || !fMintableCoins) + { + nLastCoinStakeSearchInterval = 0; + Sleep(1000); + if (fShutdown) + return; + + //control the amount of times the client will check for mintable coins + if (GetTime() - nMintableLastCheck > 60) //check for mintable coins every 60 seconds + { + nMintableLastCheck = GetTime(); + fMintableCoins = pwallet->MintableCoins(); + } + + if (!fGenerateBitcoins && !fProofOfStake) + return; + } + + if(mapHashedBlocks.count(nBestHeight)) //search our map of hashed blocks, see if bestblock has been hashed yet + { + fWalletStaking = true; + if(GetTime() - mapHashedBlocks[nBestHeight] < std::max(pwallet->nHashInterval, (unsigned int)1)) // wait a 'hash interval' until trying to hash again + { + Sleep(1000); // 2.5 second sleep for this thread + continue; + } + } + + // + // Create new block + // + unsigned int nTransactionsUpdatedLast = nTransactionsUpdated; + CBlockIndex* pindexPrev = pindexBest; + + std::unique_ptr pblock(CreateNewBlock(pwallet, fProofOfStake)); + if (!pblock.get()) + return; + IncrementExtraNonce(pblock.get(), pindexPrev, nExtraNonce); + + if (fProofOfStake) + { + // ppcoin: if proof-of-stake block found then process block + if (pblock->IsProofOfStake()) + { + printf("CPUMiner : proof-of-stake block found %s\n", pblock->GetHash().ToString().c_str()); + + if (!pblock->SignBlock(*pwalletMain)) + { + continue; + } + + printf("CPUMiner : proof-of-stake block was signed %s\n", pblock->GetHash().ToString().c_str()); + SetThreadPriority(THREAD_PRIORITY_NORMAL); + CheckWork(pblock.get(), *pwalletMain, reservekey); + SetThreadPriority(THREAD_PRIORITY_LOWEST); + } + continue; + } + + printf("Running BitcoinMiner with %lu transactions in block (%u bytes)\n", pblock->vtx.size(), + ::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION)); + + // + // Pre-build hash buffers + // + char pmidstatebuf[32+16]; char* pmidstate = alignup<16>(pmidstatebuf); + char pdatabuf[128+16]; char* pdata = alignup<16>(pdatabuf); + char phash1buf[64+16]; char* phash1 = alignup<16>(phash1buf); + + FormatHashBuffers(pblock.get(), pmidstate, pdata, phash1); + + unsigned int& nBlockTime = *(unsigned int*)(pdata + 64 + 4); + unsigned int& nBlockBits = *(unsigned int*)(pdata + 64 + 8); + + // + // Search + // + int64 nStart = GetTime(); + uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256(); + + while (true) + { + unsigned int nHashesDone = 0; + + uint256 thash; + while (true) + { + thash = pblock->GetHash(); + if (thash <= hashTarget) + { + + if (!pblock->SignBlock(*pwalletMain)) + { + break; + } + + SetThreadPriority(THREAD_PRIORITY_NORMAL); + CheckWork(pblock.get(), *pwallet, reservekey); + SetThreadPriority(THREAD_PRIORITY_LOWEST); + break; + } + pblock->nNonce += 1; + nHashesDone += 1; + if ((pblock->nNonce & 0xFF) == 0) + break; + } + + // Meter hashes/sec + static int64 nHashCounter; + if (nHPSTimerStart == 0) + { + nHPSTimerStart = GetTimeMillis(); + nHashCounter = 0; + } + else + nHashCounter += nHashesDone; + if (GetTimeMillis() - nHPSTimerStart > 4000) + { + static CCriticalSection cs; + { + LOCK(cs); + if (GetTimeMillis() - nHPSTimerStart > 4000) + { + dHashesPerSec = 1000.0 * nHashCounter / (GetTimeMillis() - nHPSTimerStart); + nHPSTimerStart = GetTimeMillis(); + nHashCounter = 0; + static int64 nLogTime; + if (GetTime() - nLogTime > 30 * 60) + { + nLogTime = GetTime(); + printf("hashmeter %6.0f khash/s\n", dHashesPerSec/1000.0); + } + } + } + } + + // Check for stop or if block needs to be rebuilt + boost::this_thread::interruption_point(); + if (vNodes.empty()) + break; + if (pblock->nNonce >= 0xffff0000) + break; + if (nTransactionsUpdated != nTransactionsUpdatedLast && GetTime() - nStart > 60) + break; + if (pindexPrev != pindexBest) + break; + + // Update nTime every few seconds + pblock->UpdateTime(pindexPrev); + nBlockTime = ByteReverse(pblock->nTime); + if (fTestNet) + { + // Changing pblock->nTime can change work required on testnet: + nBlockBits = ByteReverse(pblock->nBits); + hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256(); + } + } + } +} + + +void ThreadBitcoinMiner(void* parg) +{ + CWallet* pwallet = (CWallet*)parg; + try + { + vnThreadsRunning[THREAD_MINER]++; + BitcoinMiner(pwallet, false); + vnThreadsRunning[THREAD_MINER]--; + } + catch (std::exception& e) { + vnThreadsRunning[THREAD_MINER]--; + PrintException(&e, "ThreadBitcoinMiner()"); + } catch (...) { + vnThreadsRunning[THREAD_MINER]--; + PrintException(NULL, "ThreadBitcoinMiner()"); + } + nHPSTimerStart = 0; + if (vnThreadsRunning[THREAD_MINER] == 0) + dHashesPerSec = 0; + printf("ThreadBitcoinMiner exiting, %d threads remaining\n", vnThreadsRunning[THREAD_MINER]); +} + + +void GenerateBitcoins(bool fGenerate, CWallet* pwallet) +{ + fGenerateBitcoins = fGenerate; + nLimitProcessors = GetArg("-genproclimit", -1); + if (nLimitProcessors == 0) + fGenerateBitcoins = false; + fLimitProcessors = (nLimitProcessors != -1); + + if (fGenerate) + { + int nProcessors = boost::thread::hardware_concurrency(); + printf("%d processors\n", nProcessors); + if (nProcessors < 1) + nProcessors = 1; + if (fLimitProcessors && nProcessors > nLimitProcessors) + nProcessors = nLimitProcessors; + int nAddThreads = nProcessors - vnThreadsRunning[THREAD_MINER]; + printf("Starting %d BitcoinMiner threads\n", nAddThreads); + for (int i = 0; i < nAddThreads; i++) + { + if (!NewThread(ThreadBitcoinMiner, pwallet)) + printf("Error: NewThread(ThreadBitcoinMiner) failed\n"); + Sleep(10); + } + } +} diff --git a/src/miner.h b/src/miner.h new file mode 100644 index 000000000..49239f70e --- /dev/null +++ b/src/miner.h @@ -0,0 +1,11 @@ +#ifndef HYPERSTAKE_MINER_H +#define HYPERSTAKE_MINER_H + +class CBlock; +class CWallet; + +void BitcoinMiner(CWallet *pwallet, bool fProofOfStake); +CBlock* CreateNewBlock(CWallet* pwallet, bool fProofOfStake); +void ThreadBitcoinMiner(void* parg); + +#endif //HYPERSTAKE_MINER_H diff --git a/src/net.cpp b/src/net.cpp index 55429637b..8141844db 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -3,11 +3,10 @@ // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include "irc.h" #include "db.h" #include "net.h" #include "init.h" -#include "strlcpy.h" +#include "miner.h" #include "addrman.h" #include "ui_interface.h" @@ -22,10 +21,14 @@ #include #endif +#if !defined(HAVE_MSG_NOSIGNAL) +#define MSG_NOSIGNAL 0 +#endif + using namespace std; using namespace boost; -static const int MAX_OUTBOUND_CONNECTIONS = 12; +static const int MAX_OUTBOUND_CONNECTIONS = 25; void ThreadMessageHandler2(void* parg); void ThreadSocketHandler2(void* parg); @@ -57,7 +60,7 @@ static bool vfLimited[NET_MAX] = {}; static CNode* pnodeLocalHost = NULL; CAddress addrSeenByPeer(CService("0.0.0.0", 0), nLocalServices); uint64 nLocalHostNonce = 0; -array vnThreadsRunning; +boost::array vnThreadsRunning; static std::vector vhListenSocket; CAddrMan addrman; @@ -143,7 +146,7 @@ CAddress GetLocalAddress(const CNetAddr *paddrPeer) bool RecvLine(SOCKET hSocket, string& strLine) { strLine = ""; - loop + while (true) { char c; int nBytes = recv(hSocket, &c, 1, 0); @@ -316,7 +319,7 @@ bool GetMyExternalIP2(const CService& addrConnect, const char* pszGet, const cha { if (strLine.empty()) // HTTP response is separated from headers by blank line { - loop + while (true) { if (!RecvLine(hSocket, strLine)) { @@ -357,7 +360,7 @@ bool GetMyExternalIP(CNetAddr& ipRet) const char* pszKeyword; for (int nLookup = 0; nLookup <= 1; nLookup++) - for (int nHost = 1; nHost <= 2; nHost++) + for (int nHost = 1; nHost <= 1; nHost++) { // We should be phasing out our use of sites like these. If we need // replacements, we should ask for volunteers to put this simple @@ -382,25 +385,6 @@ bool GetMyExternalIP(CNetAddr& ipRet) pszKeyword = "Address:"; } - else if (nHost == 2) - { - addrConnect = CService("74.208.43.192", 80); // www.showmyip.com - - if (nLookup == 1) - { - CService addrIP("www.showmyip.com", 80, true); - if (addrIP.IsValid()) - addrConnect = addrIP; - } - - pszGet = "GET /simple/ HTTP/1.1\r\n" - "Host: www.showmyip.com\r\n" - "User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)\r\n" - "Connection: close\r\n" - "\r\n"; - - pszKeyword = NULL; // Returns just IP address - } if (GetMyExternalIP2(addrConnect, pszGet, pszKeyword, ipRet)) return true; @@ -540,7 +524,11 @@ void CNode::CloseSocketDisconnect() printf("disconnecting node %s\n", addrName.c_str()); closesocket(hSocket); hSocket = INVALID_SOCKET; - vRecv.clear(); + + // in case this fails, we'll empty the recv buffer when the CNode is deleted + TRY_LOCK(cs_vRecvMsg, lockRecv); + if (lockRecv) + vRecvMsg.clear(); } } @@ -548,7 +536,6 @@ void CNode::Cleanup() { } - void CNode::PushVersion() { /// when NTP implemented, change to just nTime = GetAdjustedTime() @@ -561,10 +548,6 @@ void CNode::PushVersion() nLocalHostNonce, FormatSubVersion(CLIENT_NAME, CLIENT_VERSION, std::vector()), nBestHeight); } - - - - std::map CNode::setBanned; CCriticalSection CNode::cs_setBanned; @@ -637,14 +620,61 @@ void CNode::copyStats(CNodeStats &stats) } #undef X - - - - - - - - +// requires LOCK(cs_vRecvMsg) +bool CNode::ReceiveMsgBytes(const char *pch, unsigned int nBytes) +{ +while (nBytes > 0) { + // get current incomplete message, or create a new one + if (vRecvMsg.empty() || + vRecvMsg.back().complete()) + vRecvMsg.push_back(CNetMessage(SER_NETWORK, nRecvVersion)); + CNetMessage& msg = vRecvMsg.back(); + // absorb network data + int handled; + if (!msg.in_data) + handled = msg.readHeader(pch, nBytes); + else + handled = msg.readData(pch, nBytes); + if (handled < 0) + return false; + pch += handled; + nBytes -= handled; +} +return true; +} +int CNetMessage::readHeader(const char *pch, unsigned int nBytes) +{ +// copy data to temporary parsing buffer +unsigned int nRemaining = 24 - nHdrPos; +unsigned int nCopy = std::min(nRemaining, nBytes); +memcpy(&hdrbuf[nHdrPos], pch, nCopy); +nHdrPos += nCopy; +// if header incomplete, exit +if (nHdrPos < 24) +return nCopy; +// deserialize to CMessageHeader +try { +hdrbuf >> hdr; +} +catch (std::exception &e) { +return -1; +} +// reject messages larger than MAX_SIZE +if (hdr.nMessageSize > MAX_SIZE) +return -1; +// switch state to reading message data +in_data = true; +vRecv.resize(hdr.nMessageSize); +return nCopy; +} +int CNetMessage::readData(const char *pch, unsigned int nBytes) +{ +unsigned int nRemaining = hdr.nMessageSize - nDataPos; +unsigned int nCopy = std::min(nRemaining, nBytes); +memcpy(&vRecv[nDataPos], pch, nCopy); +nDataPos += nCopy; +return nCopy; +} void ThreadSocketHandler(void* parg) { @@ -673,7 +703,7 @@ void ThreadSocketHandler2(void* parg) list vNodesDisconnected; unsigned int nPrevNodeCount = 0; - loop + while (true) { // // Disconnect nodes @@ -685,7 +715,7 @@ void ThreadSocketHandler2(void* parg) BOOST_FOREACH(CNode* pnode, vNodesCopy) { if (pnode->fDisconnect || - (pnode->GetRefCount() <= 0 && pnode->vRecv.empty() && pnode->vSend.empty())) + (pnode->GetRefCount() <= 0 && pnode->vRecvMsg.empty() && pnode->vSend.empty())) { // remove from vNodes vNodes.erase(remove(vNodes.begin(), vNodes.end(), pnode), vNodes.end()); @@ -717,7 +747,7 @@ void ThreadSocketHandler2(void* parg) TRY_LOCK(pnode->cs_vSend, lockSend); if (lockSend) { - TRY_LOCK(pnode->cs_vRecv, lockRecv); + TRY_LOCK(pnode->cs_vRecvMsg, lockRecv); if (lockRecv) { TRY_LOCK(pnode->cs_mapRequests, lockReq); @@ -840,11 +870,7 @@ void ThreadSocketHandler2(void* parg) } else if (nInbound >= GetArg("-maxconnections", 125) - MAX_OUTBOUND_CONNECTIONS) { - { - LOCK(cs_setservAddNodeAddresses); - if (!setservAddNodeAddresses.count(addr)) - closesocket(hSocket); - } + closesocket(hSocket); } else if (CNode::IsBanned(addr)) { @@ -886,15 +912,12 @@ void ThreadSocketHandler2(void* parg) continue; if (FD_ISSET(pnode->hSocket, &fdsetRecv) || FD_ISSET(pnode->hSocket, &fdsetError)) { - TRY_LOCK(pnode->cs_vRecv, lockRecv); + TRY_LOCK(pnode->cs_vRecvMsg, lockRecv); if (lockRecv) { - CDataStream& vRecv = pnode->vRecv; - unsigned int nPos = vRecv.size(); - - if (nPos > ReceiveBufferSize()) { + if (pnode->GetTotalRecvSize() > ReceiveFloodSize()) { if (!pnode->fDisconnect) - printf("socket recv flood control disconnect (%"PRIszu" bytes)\n", vRecv.size()); + printf("socket recv flood control disconnect (%u bytes)\n", pnode->GetTotalRecvSize()); pnode->CloseSocketDisconnect(); } else { @@ -903,8 +926,8 @@ void ThreadSocketHandler2(void* parg) int nBytes = recv(pnode->hSocket, pchBuf, sizeof(pchBuf), MSG_DONTWAIT); if (nBytes > 0) { - vRecv.resize(nPos + nBytes); - memcpy(&vRecv[nPos], pchBuf, nBytes); + if (!pnode->ReceiveMsgBytes(pchBuf, nBytes)) + pnode->CloseSocketDisconnect(); pnode->nLastRecv = GetTime(); } else if (nBytes == 0) @@ -1039,10 +1062,14 @@ void ThreadMapPort2(void* parg) #ifndef UPNPDISCOVER_SUCCESS /* miniupnpc 1.5 */ devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0); -#else +#elif MINIUPNPC_API_VERSION < 14 /* miniupnpc 1.6 */ int error = 0; devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0, 0, &error); +#else + /* miniupnpc 1.9.20150730 */ + int error = 0; + devlist = upnpDiscover(2000, multicastif, minissdpdpath, 0, 0, 2, &error); #endif struct UPNPUrls urls; @@ -1086,7 +1113,7 @@ void ThreadMapPort2(void* parg) else printf("UPnP Port Mapping successful.\n"); int i = 1; - loop { + while (true) { if (fShutdown || !fUseUPnP) { r = UPNP_DeletePortMapping(urls.controlURL, data.first.servicetype, port.c_str(), "TCP", 0); @@ -1121,7 +1148,7 @@ void ThreadMapPort2(void* parg) freeUPNPDevlist(devlist); devlist = 0; if (r != 0) FreeUPNPUrls(&urls); - loop { + while (true) { if (fShutdown || !fUseUPnP) return; Sleep(2000); @@ -1149,14 +1176,22 @@ void MapPort() // The first name is used as information source for addrman. // The second name should resolve to a list of seed addresses. static const char *strDNSSeed[][2] = { - {"chainworks seed", "hyp.chainworks.info"}, - {}, - {}, - {}, + {"fuzzbawls", "hyp.seed.fuzzbawls.pw"}, + {"presstab nodes", "hypseed.presstab.pw"}, }; void ThreadDNSAddressSeed(void* parg) { + // goal: only query DNS seeds if address need is acute + if ((addrman.size() > 0) && (!GetBoolArg("-forcednsseed", false))) + { + Sleep(11000); + + LOCK(cs_vNodes); + if (vNodes.size() >= 3) + return; + } + // Make this thread recognisable as the DNS seeding thread RenameThread("bitcoin-dnsseed"); @@ -1223,7 +1258,7 @@ void ThreadDNSAddressSeed2(void* parg) unsigned int pnSeed[] = { - 0x8785f050, + //0x8785f050, }; void DumpAddresses() @@ -1233,7 +1268,7 @@ void DumpAddresses() CAddrDB adb; adb.Write(addrman); - printf("Flushed %d addresses to peers.dat %"PRI64d"ms\n", + printf("Flushed %d addresses to peers.dat %lldms\n", addrman.size(), GetTimeMillis() - nStart); } @@ -1352,7 +1387,7 @@ void ThreadOpenConnections2(void* parg) // Initiate network connections int64 nStart = GetTime(); - loop + while (true) { ProcessOneShot(); @@ -1411,7 +1446,7 @@ void ThreadOpenConnections2(void* parg) int64 nANow = GetAdjustedTime(); int nTries = 0; - loop + while (true) { // use an nUnkBias between 10 (no outgoing connections) and 90 (8 outgoing connections) CAddress addr = addrman.Select(10 + min(nOutbound,8)*10); @@ -1627,11 +1662,14 @@ void ThreadMessageHandler2(void* parg) pnodeTrickle = vNodesCopy[GetRand(vNodesCopy.size())]; BOOST_FOREACH(CNode* pnode, vNodesCopy) { - // Receive messages + if(pnode->fDisconnect) + continue; + // Receive messages { - TRY_LOCK(pnode->cs_vRecv, lockRecv); + TRY_LOCK(pnode->cs_vRecvMsg, lockRecv); if (lockRecv) - ProcessMessages(pnode); + if(!ProcessMessages(pnode)) + pnode->CloseSocketDisconnect(); } if (fShutdown) return; @@ -1856,28 +1894,17 @@ void StartNode(void* parg) // // Start threads // - -/* + if (!GetBoolArg("-dnsseed", true)) printf("DNS seeding disabled\n"); else if (!NewThread(ThreadDNSAddressSeed, NULL)) printf("Error: NewThread(ThreadDNSAddressSeed) failed\n"); -*/ - - if (!GetBoolArg("-dnsseed", false)) - printf("DNS seeding disabled\n"); - if (GetBoolArg("-dnsseed", false)) - printf("DNS seeding NYI\n"); // Map ports with UPnP if (fUseUPnP) MapPort(); - // Get addresses from IRC and advertise ours - if (!NewThread(ThreadIRCSeed, NULL)) - printf("Error: NewThread(ThreadIRCSeed) failed\n"); - // Send and receive from sockets, accept connections if (!NewThread(ThreadSocketHandler, NULL)) printf("Error: NewThread(ThreadSocketHandler) failed\n"); @@ -1899,8 +1926,10 @@ void StartNode(void* parg) printf("Error; NewThread(ThreadDumpAddress) failed\n"); // ppcoin: mint proof-of-stake blocks in the background - if (!NewThread(ThreadStakeMinter, pwalletMain)) - printf("Error: NewThread(ThreadStakeMinter) failed\n"); + if (GetBoolArg("-staking", true)) { + if (!NewThread(ThreadStakeMinter, pwalletMain)) + printf("Error: NewThread(ThreadStakeMinter) failed\n"); + } // Generate coins in the background GenerateBitcoins(GetBoolArg("-gen", false), pwalletMain); diff --git a/src/net.h b/src/net.h index 9179b71cf..b7c7d7a17 100644 --- a/src/net.h +++ b/src/net.h @@ -26,7 +26,7 @@ extern int nBestHeight; -inline unsigned int ReceiveBufferSize() { return 1000*GetArg("-maxreceivebuffer", 5*1000); } +inline unsigned int ReceiveFloodSize() { return 1000*GetArg("-maxreceivebuffer", 5*1000); } inline unsigned int SendBufferSize() { return 1000*GetArg("-maxsendbuffer", 1*1000); } void AddOneShot(std::string strDest); @@ -48,7 +48,6 @@ enum LOCAL_IF, // address a local interface listens on LOCAL_BIND, // address explicit bound to LOCAL_UPNP, // address reported by UPnP - LOCAL_IRC, // address reported by IRC (deprecated) LOCAL_HTTP, // address reported by whatismyip.com and similar LOCAL_MANUAL, // address explicitly specified (-externalip=) @@ -147,9 +146,34 @@ class CNodeStats int nMisbehavior; }; - - - +class CNetMessage { +public: +bool in_data; // parsing header (false) or data (true) +CDataStream hdrbuf; // partially received header +CMessageHeader hdr; // complete header +unsigned int nHdrPos; +CDataStream vRecv; // received message data +unsigned int nDataPos; +CNetMessage(int nTypeIn, int nVersionIn) : hdrbuf(nTypeIn, nVersionIn), vRecv(nTypeIn, nVersionIn) { +hdrbuf.resize(24); +in_data = false; +nHdrPos = 0; +nDataPos = 0; +} +bool complete() const +{ +if (!in_data) +return false; +return (hdr.nMessageSize == nDataPos); +} +void SetVersion(int nVersionIn) +{ +hdrbuf.SetVersion(nVersionIn); +vRecv.SetVersion(nVersionIn); +} +int readHeader(const char *pch, unsigned int nBytes); +int readData(const char *pch, unsigned int nBytes); +}; /** Information about a peer */ class CNode @@ -159,9 +183,10 @@ class CNode uint64 nServices; SOCKET hSocket; CDataStream vSend; - CDataStream vRecv; CCriticalSection cs_vSend; - CCriticalSection cs_vRecv; + std::deque vRecvMsg; + CCriticalSection cs_vRecvMsg; + int nRecvVersion; int64 nLastSend; int64 nLastRecv; int64 nLastSendEmpty; @@ -211,10 +236,11 @@ class CNode CCriticalSection cs_inventory; std::multimap mapAskFor; - CNode(SOCKET hSocketIn, CAddress addrIn, std::string addrNameIn = "", bool fInboundIn=false) : vSend(SER_NETWORK, MIN_PROTO_VERSION), vRecv(SER_NETWORK, MIN_PROTO_VERSION) + CNode(SOCKET hSocketIn, CAddress addrIn, std::string addrNameIn = "", bool fInboundIn=false) : vSend(SER_NETWORK, MIN_PROTO_VERSION) { nServices = 0; hSocket = hSocketIn; + nRecvVersion = MIN_PROTO_VERSION; nLastSend = 0; nLastRecv = 0; nLastSendEmpty = GetTime(); @@ -267,6 +293,26 @@ class CNode return std::max(nRefCount, 0) + (GetTime() < nReleaseTime ? 1 : 0); } + // requires LOCK(cs_vRecvMsg) + unsigned int GetTotalRecvSize() + { + unsigned int total = 0; + BOOST_FOREACH(const CNetMessage &msg, vRecvMsg) + total += msg.vRecv.size() + 24; + return total; + } + + // requires LOCK(cs_vRecvMsg) + bool ReceiveMsgBytes(const char *pch, unsigned int nBytes); + + // requires LOCK(cs_vRecvMsg) + void SetRecvVersion(int nVersionIn) + { + nRecvVersion = nVersionIn; + BOOST_FOREACH(CNetMessage &msg, vRecvMsg) + msg.SetVersion(nVersionIn); + } + CNode* AddRef(int64 nTimeout=0) { if (nTimeout != 0) @@ -321,7 +367,7 @@ class CNode // the key is the earliest time the request can be sent int64& nRequestTime = mapAlreadyAskedFor[inv]; if (fDebugNet) - printf("askfor %s %"PRI64d" (%s)\n", inv.ToString().c_str(), nRequestTime, DateTimeStrFormat("%H:%M:%S", nRequestTime/1000000).c_str()); + printf("askfor %s %lld (%s)\n", inv.ToString().c_str(), nRequestTime, DateTimeStrFormat("%H:%M:%S", nRequestTime/1000000).c_str()); // Make sure not to reuse time indexes to keep things in the same order int64 nNow = (GetTime() - 1) * 1000000; diff --git a/src/netbase.cpp b/src/netbase.cpp index 95d64939b..e73296ec1 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -11,8 +11,13 @@ #include #endif -#include "strlcpy.h" #include // for to_lower() +#include // for startswith() and endswith() + + +#if !defined(HAVE_MSG_NOSIGNAL) +#define MSG_NOSIGNAL 0 +#endif using namespace std; @@ -119,18 +124,16 @@ bool static LookupIntern(const char *pszName, std::vector& vIP, unsign bool LookupHost(const char *pszName, std::vector& vIP, unsigned int nMaxSolutions, bool fAllowLookup) { - if (pszName[0] == 0) + std::string str(pszName); + std::string strHost = str; + if (str.empty()) return false; - char psz[256]; - char *pszHost = psz; - strlcpy(psz, pszName, sizeof(psz)); - if (psz[0] == '[' && psz[strlen(psz)-1] == ']') + if (boost::algorithm::starts_with(str, "[") && boost::algorithm::ends_with(str, "]")) { - pszHost = psz+1; - psz[strlen(psz)-1] = 0; + strHost = str.substr(1, str.size() - 2); } - return LookupIntern(pszHost, vIP, nMaxSolutions, fAllowLookup); + return LookupIntern(strHost.c_str(), vIP, nMaxSolutions, fAllowLookup); } bool LookupHostNumeric(const char *pszName, std::vector& vIP, unsigned int nMaxSolutions) @@ -297,7 +300,10 @@ bool static Socks5(string strDest, int port, SOCKET& hSocket) { ret = recv(hSocket, pchRet3, 1, 0) != 1; if (ret) + { + closesocket(hSocket); return error("Error reading from proxy"); + } int nRecv = pchRet3[0]; ret = recv(hSocket, pchRet3, nRecv, 0) != nRecv; break; @@ -504,6 +510,7 @@ bool ConnectSocket(const CService &addrDest, SOCKET& hSocketRet, int nTimeout) return false; break; default: + closesocket(hSocket); return false; } @@ -535,7 +542,9 @@ bool ConnectSocketByName(CService &addr, SOCKET& hSocketRet, const char *pszDest switch(nameproxy.second) { default: - case 4: return false; + case 4: + closesocket(hSocket); + return false; case 5: if (!Socks5(strDest, port, hSocket)) return false; diff --git a/src/qt/aboutdialog.cpp b/src/qt/aboutdialog.cpp index 14ff9e97b..0b98befe8 100644 --- a/src/qt/aboutdialog.cpp +++ b/src/qt/aboutdialog.cpp @@ -9,7 +9,6 @@ AboutDialog::AboutDialog(QWidget *parent) : ui(new Ui::AboutDialog) { ui->setupUi(this); - // this->setStyleSheet("background-color: #effbef;"); } void AboutDialog::setModel(ClientModel *model) diff --git a/src/qt/addressbookpage.cpp b/src/qt/addressbookpage.cpp index e20358c70..0b41a55fc 100644 --- a/src/qt/addressbookpage.cpp +++ b/src/qt/addressbookpage.cpp @@ -54,10 +54,14 @@ AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) : ui->labelExplanation->setVisible(false); ui->deleteButton->setVisible(true); ui->signMessage->setVisible(false); + ui->stakeForCharityPushButton->setVisible(true); + ui->deleteCheckBox->setVisible(false); break; case ReceivingTab: ui->deleteButton->setVisible(false); ui->signMessage->setVisible(true); + ui->stakeForCharityPushButton->setVisible(false); + ui->deleteCheckBox->setVisible(true); break; } @@ -68,6 +72,7 @@ AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) : QAction *showQRCodeAction = new QAction(ui->showQRCode->text(), this); QAction *signMessageAction = new QAction(ui->signMessage->text(), this); QAction *verifyMessageAction = new QAction(ui->verifyMessage->text(), this); + QAction *stakeForCharityAction = new QAction(ui->stakeForCharityPushButton->text(), this); deleteAction = new QAction(ui->deleteButton->text(), this); // Build context menu @@ -82,8 +87,10 @@ AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) : if(tab == ReceivingTab) contextMenu->addAction(signMessageAction); else if(tab == SendingTab) + { contextMenu->addAction(verifyMessageAction); - + contextMenu->addAction(stakeForCharityAction); + } // Connect signals for context menu actions connect(copyAddressAction, SIGNAL(triggered()), this, SLOT(on_copyToClipboard_clicked())); connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(onCopyLabelAction())); @@ -92,7 +99,7 @@ AddressBookPage::AddressBookPage(Mode mode, Tabs tab, QWidget *parent) : connect(showQRCodeAction, SIGNAL(triggered()), this, SLOT(on_showQRCode_clicked())); connect(signMessageAction, SIGNAL(triggered()), this, SLOT(on_signMessage_clicked())); connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(on_verifyMessage_clicked())); - + connect(stakeForCharityAction, SIGNAL(triggered()), this, SLOT(on_stakeForCharityPushButton_clicked())); connect(ui->tableView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextualMenu(QPoint))); // Pass through accept action from button box @@ -132,11 +139,16 @@ void AddressBookPage::setModel(AddressTableModel *model) ui->tableView->sortByColumn(0, Qt::AscendingOrder); // Set column widths + #if QT_VERSION < 0x050000 ui->tableView->horizontalHeader()->resizeSection( AddressTableModel::Address, 320); ui->tableView->horizontalHeader()->setResizeMode( AddressTableModel::Label, QHeaderView::Stretch); - + #else + ui->tableView->horizontalHeader()->setSectionResizeMode(AddressTableModel::Label, QHeaderView::Stretch); + ui->tableView->horizontalHeader()->setSectionResizeMode(AddressTableModel::Address, QHeaderView::ResizeToContents); + #endif + connect(ui->tableView->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)), this, SLOT(selectionChanged())); @@ -152,6 +164,22 @@ void AddressBookPage::setOptionsModel(OptionsModel *optionsModel) this->optionsModel = optionsModel; } +void AddressBookPage::on_deleteCheckBox_clicked() +{ + if(ui->deleteCheckBox->checkState() == Qt::Checked) + { + ui->deleteButton->setEnabled(true); + ui->deleteButton->setVisible(true); + deleteAction->setEnabled(true); + } + else + { + ui->deleteButton->setEnabled(false); + ui->deleteButton->setVisible(false); + deleteAction->setEnabled(false); + } +} + void AddressBookPage::on_copyToClipboard_clicked() { GUIUtil::copyEntryData(ui->tableView, AddressTableModel::Address); @@ -210,6 +238,21 @@ void AddressBookPage::on_verifyMessage_clicked() emit verifyMessage(addr); } +void AddressBookPage::on_stakeForCharityPushButton_clicked() +{ + QTableView *table = ui->tableView; + QModelIndexList indexes = table->selectionModel()->selectedRows(AddressTableModel::Address); + QString addr; + + foreach (QModelIndex index, indexes) + { + QVariant address = index.data(); + addr = address.toString(); + } + + emit stakeForCharitySignal(addr); +} + void AddressBookPage::on_newAddressButton_clicked() { if(!model) @@ -257,16 +300,22 @@ void AddressBookPage::selectionChanged() ui->signMessage->setVisible(false); ui->verifyMessage->setEnabled(true); ui->verifyMessage->setVisible(true); + ui->stakeForCharityPushButton->setEnabled(true); + ui->stakeForCharityPushButton->setVisible(true); break; case ReceivingTab: - // Deleting receiving addresses, however, is not allowed + // Deleting receiving addresses is allowed if enabled on deleteCheckBox ui->deleteButton->setEnabled(false); - ui->deleteButton->setVisible(false); - deleteAction->setEnabled(false); + ui->deleteButton->setVisible(false); + deleteAction->setEnabled(false); ui->signMessage->setEnabled(true); ui->signMessage->setVisible(true); ui->verifyMessage->setEnabled(false); ui->verifyMessage->setVisible(false); + ui->stakeForCharityPushButton->setEnabled(false); + ui->stakeForCharityPushButton->setVisible(false ); + ui->deleteCheckBox->setVisible(true); + break; } ui->copyToClipboard->setEnabled(true); @@ -279,6 +328,7 @@ void AddressBookPage::selectionChanged() ui->copyToClipboard->setEnabled(false); ui->signMessage->setEnabled(false); ui->verifyMessage->setEnabled(false); + ui->stakeForCharityPushButton->setEnabled(false); } } diff --git a/src/qt/addressbookpage.h b/src/qt/addressbookpage.h index df8748694..079b4ab50 100644 --- a/src/qt/addressbookpage.h +++ b/src/qt/addressbookpage.h @@ -60,10 +60,12 @@ public slots: private slots: void on_deleteButton_clicked(); void on_newAddressButton_clicked(); + void on_deleteCheckBox_clicked(); /** Copy address of currently selected address entry to clipboard */ void on_copyToClipboard_clicked(); void on_signMessage_clicked(); void on_verifyMessage_clicked(); + void on_stakeForCharityPushButton_clicked(); void selectionChanged(); void on_showQRCode_clicked(); /** Spawn contextual menu (right mouse menu) for address book entry */ @@ -80,6 +82,7 @@ private slots: signals: void signMessage(QString addr); void verifyMessage(QString addr); + void stakeForCharitySignal(QString addr); }; #endif // ADDRESSBOOKDIALOG_H diff --git a/src/qt/addresstablemodel.cpp b/src/qt/addresstablemodel.cpp index e65d3915e..06d9de19a 100644 --- a/src/qt/addresstablemodel.cpp +++ b/src/qt/addresstablemodel.cpp @@ -1,7 +1,7 @@ #include "addresstablemodel.h" #include "guiutil.h" #include "walletmodel.h" - +#include "walletdb.h" #include "wallet.h" #include "base58.h" @@ -357,7 +357,7 @@ bool AddressTableModel::removeRows(int row, int count, const QModelIndex & paren { Q_UNUSED(parent); AddressTableEntry *rec = priv->index(row); - if(count != 1 || !rec || rec->type == AddressTableEntry::Receiving) + if(count != 1 || !rec ) { // Can only remove one row at a time, and cannot remove rows not in model. // Also refuse to remove receiving addresses. @@ -366,6 +366,10 @@ bool AddressTableModel::removeRows(int row, int count, const QModelIndex & paren { LOCK(wallet->cs_wallet); wallet->DelAddressBookName(CBitcoinAddress(rec->address.toStdString()).Get()); + if(rec->type == AddressTableEntry::Receiving) + { + wallet->TopUpKeyPool(); //mark existing keypool as used and refill keypool + } } return true; } diff --git a/src/qt/askpassphrasedialog.cpp b/src/qt/askpassphrasedialog.cpp index 01bcbb93b..ad9b103c1 100644 --- a/src/qt/askpassphrasedialog.cpp +++ b/src/qt/askpassphrasedialog.cpp @@ -35,10 +35,6 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget *parent) : ui->warningLabel->setText(tr("Enter the new passphrase to the wallet.
Please use a passphrase of 10 or more random characters, or eight or more words.")); setWindowTitle(tr("Encrypt wallet")); break; - case UnlockMinting: - ui->mintingCheckBox->setChecked(true); - ui->mintingCheckBox->show(); - // fallthru case Unlock: // Ask passphrase ui->warningLabel->setText(tr("This operation needs your wallet passphrase to unlock the wallet.")); ui->passLabel2->hide(); @@ -47,6 +43,16 @@ AskPassphraseDialog::AskPassphraseDialog(Mode mode, QWidget *parent) : ui->passEdit3->hide(); setWindowTitle(tr("Unlock wallet")); break; + + case UnlockForMint: // Ask passphrase to unlock wallet for minting + ui->warningLabel->setText(tr("This operation needs your wallet passphrase to unlock the wallet to allow PoS.")); + ui->passLabel2->hide(); + ui->passEdit2->hide(); + ui->passLabel3->hide(); + ui->passEdit3->hide(); + setWindowTitle(tr("Unlock wallet for Stake")); + break; + case Decrypt: // Ask passphrase ui->warningLabel->setText(tr("This operation needs your wallet passphrase to decrypt the wallet.")); ui->passLabel2->hide(); @@ -144,19 +150,22 @@ void AskPassphraseDialog::accept() QDialog::reject(); // Cancelled } } break; - case UnlockMinting: case Unlock: - if(!model->setWalletLocked(false, oldpass)) - { + if(!model->setWalletLocked(false, oldpass, false)) QMessageBox::critical(this, tr("Wallet unlock failed"), tr("The passphrase entered for the wallet decryption was incorrect.")); - } else - { - fWalletUnlockMintOnly = ui->mintingCheckBox->isChecked(); QDialog::accept(); // Success - } break; + + case UnlockForMint: + if(!model->setWalletLocked(false, oldpass,true)) + QMessageBox::critical(this, tr("Wallet unlock failed"), + tr("The passphrase entered for the wallet decryption was incorrect.")); + else + QDialog::accept(); // Success + break; + case Decrypt: if(!model->setWalletEncrypted(false, oldpass)) { @@ -201,8 +210,8 @@ void AskPassphraseDialog::textChanged() case Encrypt: // New passphrase x2 acceptable = !ui->passEdit2->text().isEmpty() && !ui->passEdit3->text().isEmpty(); break; - case UnlockMinting: case Unlock: // Old passphrase x1 + case UnlockForMint: // Old passphrase x1 case Decrypt: acceptable = !ui->passEdit1->text().isEmpty(); break; diff --git a/src/qt/askpassphrasedialog.h b/src/qt/askpassphrasedialog.h index ca01274f1..469045e1a 100644 --- a/src/qt/askpassphrasedialog.h +++ b/src/qt/askpassphrasedialog.h @@ -20,6 +20,7 @@ class AskPassphraseDialog : public QDialog Encrypt, /**< Ask passphrase twice and encrypt */ UnlockMinting, /**< Ask passphrase and unlock for minting only */ Unlock, /**< Ask passphrase and unlock */ + UnlockForMint, /**< Ask passphrase and unlock for minting */ ChangePass, /**< Ask old passphrase + new passphrase twice */ Decrypt /**< Ask passphrase and decrypt wallet */ }; diff --git a/src/qt/bip38tooldialog.cpp b/src/qt/bip38tooldialog.cpp new file mode 100644 index 000000000..65cfe6bb9 --- /dev/null +++ b/src/qt/bip38tooldialog.cpp @@ -0,0 +1,278 @@ +// Copyright (c) 2011-2014 The Bitcoin developers +// Copyright (c) 2014-2015 The Dash developers +// Copyright (c) 2015-2017 The PIVX developers +// Copyright (c) 2017 The HyperStake developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "bip38tooldialog.h" +#include "ui_bip38tooldialog.h" + +#include "addressbookpage.h" +#include "guiutil.h" +#include "walletmodel.h" + +#include "base58.h" +#include "bip38.h" +#include "init.h" +#include "wallet.h" + +#include +#include + +#include + +Bip38ToolDialog::Bip38ToolDialog(QWidget* parent) : QDialog(parent), + ui(new Ui::Bip38ToolDialog), + model(0) +{ + ui->setupUi(this); + +#if QT_VERSION >= 0x040700 + ui->decryptedKeyOut_DEC->setPlaceholderText(tr("Click \"Decrypt Key\" to compute key")); +#endif + + GUIUtil::setupAddressWidget(ui->addressIn_ENC, this); + ui->addressIn_ENC->installEventFilter(this); + ui->passphraseIn_ENC->installEventFilter(this); + ui->encryptedKeyOut_ENC->installEventFilter(this); + ui->encryptedKeyIn_DEC->installEventFilter(this); + ui->passphraseIn_DEC->installEventFilter(this); + ui->decryptedKeyOut_DEC->installEventFilter(this); +} + +Bip38ToolDialog::~Bip38ToolDialog() +{ + delete ui; +} + +void Bip38ToolDialog::setModel(WalletModel* model) +{ + this->model = model; +} + +void Bip38ToolDialog::setAddress_ENC(const QString& address) +{ + ui->addressIn_ENC->setText(address); + ui->passphraseIn_ENC->setFocus(); +} + +void Bip38ToolDialog::setAddress_DEC(const QString& address) +{ + ui->encryptedKeyIn_DEC->setText(address); + ui->passphraseIn_DEC->setFocus(); +} + +void Bip38ToolDialog::showTab_ENC(bool fShow) +{ + ui->tabWidget->setCurrentIndex(0); + if (fShow) + this->show(); +} + +void Bip38ToolDialog::showTab_DEC(bool fShow) +{ + ui->tabWidget->setCurrentIndex(1); + if (fShow) + this->show(); +} + +void Bip38ToolDialog::on_addressBookButton_ENC_clicked() +{ + if (model && model->getAddressTableModel()) + { + AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::ReceivingTab, this); + dlg.setModel(model->getAddressTableModel()); + if (dlg.exec()) + { + setAddress_ENC(dlg.getReturnValue()); + } + } +} + +void Bip38ToolDialog::on_pasteButton_ENC_clicked() +{ + setAddress_ENC(QApplication::clipboard()->text()); +} + +QString specialChar = "\"@!#$%&'()*+,-./:;<=>?`{|}~^_[]\\"; +QString validChar = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" + specialChar; +bool isValidPassphrase(QString strPassphrase, QString& strInvalid) +{ + for (int i = 0; i < strPassphrase.size(); i++) { + if (!validChar.contains(strPassphrase[i], Qt::CaseSensitive)) { + if (QString("\"'").contains(strPassphrase[i])) + continue; + + strInvalid = strPassphrase[i]; + return false; + } + } + + return true; +} + +void Bip38ToolDialog::on_encryptKeyButton_ENC_clicked() +{ + if (!model) + return; + + QString qstrPassphrase = ui->passphraseIn_ENC->text(); + QString strInvalid; + if (!isValidPassphrase(qstrPassphrase, strInvalid)) { + ui->statusLabel_ENC->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_ENC->setText(tr("The entered passphrase is invalid. ") + strInvalid + QString(" is not valid") + QString(" ") + tr("Allowed: 0-9,a-z,A-Z,") + specialChar); + return; + } + + CBitcoinAddress addr(ui->addressIn_ENC->text().toStdString()); + if (!addr.IsValid()) { + ui->statusLabel_ENC->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_ENC->setText(tr("The entered address is invalid.") + QString(" ") + tr("Please check the address and try again.")); + return; + } + + CKeyID keyID; + if (!addr.GetKeyID(keyID)) { + ui->addressIn_ENC->setValid(false); + ui->statusLabel_ENC->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_ENC->setText(tr("The entered address does not refer to a key.") + QString(" ") + tr("Please check the address and try again.")); + return; + } + + WalletModel::UnlockContext ctx(model->requestUnlock()); + if (!ctx.isValid()) { + ui->statusLabel_ENC->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_ENC->setText(tr("Wallet unlock was cancelled.")); + return; + } + + CKey key; + if (!pwalletMain->GetKey(keyID, key)) { + ui->statusLabel_ENC->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_ENC->setText(tr("Private key for the entered address is not available.")); + return; + } + + std::string encryptedKey = BIP38_Encrypt(addr.ToString(), qstrPassphrase.toStdString(), key.GetPrivKey_256()); + ui->encryptedKeyOut_ENC->setText(QString::fromStdString(encryptedKey)); +} + +void Bip38ToolDialog::on_copyKeyButton_ENC_clicked() +{ + QApplication::clipboard()->setText(ui->encryptedKeyOut_ENC->text()); +} + +void Bip38ToolDialog::on_clearButton_ENC_clicked() +{ + ui->addressIn_ENC->clear(); + ui->passphraseIn_ENC->clear(); + ui->encryptedKeyOut_ENC->clear(); + ui->statusLabel_ENC->clear(); + + ui->addressIn_ENC->setFocus(); +} + +CKey key; +void Bip38ToolDialog::on_decryptKeyButton_DEC_clicked() +{ + std::string strPassphrase = ui->passphraseIn_DEC->text().toStdString(); + std::string strKey = ui->encryptedKeyIn_DEC->text().toStdString(); + + uint256 privKey; + bool fCompressed; + if (!BIP38_Decrypt(strPassphrase, strKey, privKey, fCompressed)) { + ui->statusLabel_DEC->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_DEC->setText(tr("Failed to decrypt.") + QString(" ") + tr("Please check the key and passphrase and try again.")); + return; + } + + if (!key.SetPrivKey_Raw(privKey, fCompressed)) { + ui->statusLabel_DEC->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_DEC->setText(tr("Failed to set private key.")); + return; + } + + CPubKey pubKey = key.GetPubKey(); + CBitcoinAddress address(pubKey.GetID()); + + ui->decryptedKeyOut_DEC->setText(QString::fromStdString(HexStr(privKey))); + ui->addressOut_DEC->setText(QString::fromStdString(address.ToString())); +} + +void Bip38ToolDialog::on_importAddressButton_DEC_clicked() +{ + WalletModel::UnlockContext ctx(model->requestUnlock()); + if (!ctx.isValid()) { + ui->statusLabel_DEC->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_DEC->setText(tr("Wallet unlock was cancelled.")); + return; + } + + CBitcoinAddress address(ui->addressOut_DEC->text().toStdString()); + CPubKey pubkey = key.GetPubKey(); + + if (!address.IsValid() || !key.IsValid() || CBitcoinAddress(pubkey.GetID()).ToString() != address.ToString()) { + ui->statusLabel_DEC->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_DEC->setText(tr("Data Not Valid.") + QString(" ") + tr("Please try again.")); + return; + } + + CKeyID vchAddress = pubkey.GetID(); + { + ui->statusLabel_DEC->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_DEC->setText(tr("Please wait while key is imported")); + + pwalletMain->MarkDirty(); + pwalletMain->SetAddressBookName(vchAddress, ""); + + // Don't throw error in case a key is already there + if (pwalletMain->HaveKey(vchAddress)) { + ui->statusLabel_DEC->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_DEC->setText(tr("Key Already Held By Wallet")); + return; + } + + if (!pwalletMain->AddKey(key)) { + ui->statusLabel_DEC->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_DEC->setText(tr("Error Adding Key To Wallet")); + return; + } + + // whenever a key is imported, we need to scan the whole chain + pwalletMain->ScanForWalletTransactions(pindexGenesisBlock, true); + } + + ui->statusLabel_DEC->setStyleSheet("QLabel { color: green; }"); + ui->statusLabel_DEC->setText(tr("Successfully Added Private Key To Wallet")); +} + +void Bip38ToolDialog::on_clearButton_DEC_clicked() +{ + ui->encryptedKeyIn_DEC->clear(); + ui->decryptedKeyOut_DEC->clear(); + ui->passphraseIn_DEC->clear(); + ui->statusLabel_DEC->clear(); + + ui->encryptedKeyIn_DEC->setFocus(); +} + +bool Bip38ToolDialog::eventFilter(QObject* object, QEvent* event) +{ + if (event->type() == QEvent::MouseButtonPress || event->type() == QEvent::FocusIn) { + if (ui->tabWidget->currentIndex() == 0) { + /* Clear status message on focus change */ + ui->statusLabel_ENC->clear(); + + /* Select generated signature */ + if (object == ui->encryptedKeyOut_ENC) { + ui->encryptedKeyOut_ENC->selectAll(); + return true; + } + } else if (ui->tabWidget->currentIndex() == 1) { + /* Clear status message on focus change */ + ui->statusLabel_DEC->clear(); + } + } + return QDialog::eventFilter(object, event); +} diff --git a/src/qt/bip38tooldialog.h b/src/qt/bip38tooldialog.h new file mode 100644 index 000000000..06f7b5640 --- /dev/null +++ b/src/qt/bip38tooldialog.h @@ -0,0 +1,52 @@ +// Copyright (c) 2017 The PIVX developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_QT_BIP38DIALOG_H +#define BITCOIN_QT_BIP38DIALOG_H + +#include + +class WalletModel; + +namespace Ui +{ +class Bip38ToolDialog; +} + +class Bip38ToolDialog : public QDialog +{ + Q_OBJECT + +public: + explicit Bip38ToolDialog(QWidget* parent); + ~Bip38ToolDialog(); + + void setModel(WalletModel* model); + void setAddress_ENC(const QString& address); + void setAddress_DEC(const QString& address); + + void showTab_ENC(bool fShow); + void showTab_DEC(bool fShow); + +protected: + bool eventFilter(QObject* object, QEvent* event); + +private: + Ui::Bip38ToolDialog* ui; + WalletModel* model; + +private slots: + /* encrypt key */ + void on_addressBookButton_ENC_clicked(); + void on_pasteButton_ENC_clicked(); + void on_encryptKeyButton_ENC_clicked(); + void on_copyKeyButton_ENC_clicked(); + void on_clearButton_ENC_clicked(); + /* decrypt key */ + void on_decryptKeyButton_DEC_clicked(); + void on_importAddressButton_DEC_clicked(); + void on_clearButton_DEC_clicked(); +}; + +#endif // BITCOIN_QT_BIP38TOOLDIALOG_H diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index 574560a91..72a6ce3a0 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -2,33 +2,49 @@ * W.J. van der Laan 2011-2012 */ #include "bitcoingui.h" + #include "clientmodel.h" -#include "walletmodel.h" -#include "optionsmodel.h" -#include "guiutil.h" #include "guiconstants.h" - +#include "guiutil.h" #include "init.h" +#include "networkstyle.h" +#include "optionsmodel.h" #include "ui_interface.h" -#include "qtipcserver.h" + +#include "paymentserver.h" +#include "walletmodel.h" #include #include +#if QT_VERSION < 0x050000 #include +#endif #include +#include #include #include #include -#if defined(BITCOIN_NEED_QT_PLUGINS) && !defined(_BITCOIN_QT_PLUGINS_INCLUDED) -#define _BITCOIN_QT_PLUGINS_INCLUDED -#define __INSURE__ +#if defined(QT_STATICPLUGIN) #include +#if QT_VERSION < 0x050000 Q_IMPORT_PLUGIN(qcncodecs) Q_IMPORT_PLUGIN(qjpcodecs) Q_IMPORT_PLUGIN(qtwcodecs) Q_IMPORT_PLUGIN(qkrcodecs) Q_IMPORT_PLUGIN(qtaccessiblewidgets) +#else +#if QT_VERSION < 0x050400 +Q_IMPORT_PLUGIN(AccessibleFactory) +#endif +#if defined(QT_QPA_PLATFORM_XCB) +Q_IMPORT_PLUGIN(QXcbIntegrationPlugin); +#elif defined(QT_QPA_PLATFORM_WINDOWS) +Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin); +#elif defined(QT_QPA_PLATFORM_COCOA) +Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin); +#endif +#endif #endif // Need a global reference for the notifications to find the GUI @@ -70,20 +86,11 @@ static bool ThreadSafeAskFee(int64 nFeeRequired, const std::string& strCaption) return payFee; } -static void ThreadSafeHandleURI(const std::string& strURI) -{ - if(!guiref) - return; - - QMetaObject::invokeMethod(guiref, "handleURI", GUIUtil::blockingGUIThreadConnection(), - Q_ARG(QString, QString::fromStdString(strURI))); -} - static void InitMessage(const std::string &message) { if(splashref) { - splashref->showMessage(QString::fromStdString(message), Qt::AlignBottom|Qt::AlignHCenter, QColor(255,255,200)); + splashref->showMessage(QString::fromStdString(message+'\n'+'\n') + QString::fromStdString(FormatFullVersion().c_str()), Qt::AlignBottom|Qt::AlignHCenter, QColor(255,255,200)); QApplication::instance()->processEvents(); } } @@ -113,23 +120,42 @@ static void handleRunawayException(std::exception *e) #ifndef BITCOIN_QT_TEST int main(int argc, char *argv[]) { - // Do this early as we don't want to bother initializing if we are just calling IPC - ipcScanRelay(argc, argv); + fHaveGUI = true; + + /// 1. Parse command-line options. These take precedence over anything else. + // Command-line options take precedence: + ParseParameters(argc, argv); + // Do not refer to data directory yet, this can be overridden by Intro::pickDataDirectory + + /// 2. Basic Qt initialization (not dependent on parameters or configuration) + #if QT_VERSION < 0x050000 // Internal string conversion is all UTF-8 QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8")); QTextCodec::setCodecForCStrings(QTextCodec::codecForTr()); - + #endif + Q_INIT_RESOURCE(bitcoin); + QApplication app(argc, argv); - +#if QT_VERSION > 0x050100 + // Generate high-dpi pixmaps + QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); +#endif +#ifdef Q_OS_MAC + QApplication::setAttribute(Qt::AA_DontShowIconsInMenus); +#endif + + // Do this early as we don't want to bother initializing if we are just calling IPC + // ... but do it after creating app, so QCoreApplication::arguments is initialized: + if (PaymentServer::ipcSendCommandLine()) + exit(0); + PaymentServer* paymentServer = new PaymentServer(&app); + // Install global event filter that makes sure that long tooltips can be word-wrapped app.installEventFilter(new GUIUtil::ToolTipToRichTextFilter(TOOLTIP_WRAP_THRESHOLD, &app)); - // Command-line options take precedence: - ParseParameters(argc, argv); - - // ... then bitcoin.conf: + // ... then bitcoin.conf: if (!boost::filesystem::is_directory(GetDataDir(false))) { // This message can not be translated, as translation is not initialized yet @@ -138,17 +164,30 @@ int main(int argc, char *argv[]) QString("Error: Specified data directory \"%1\" does not exist.").arg(QString::fromStdString(mapArgs["-datadir"]))); return 1; } - ReadConfigFile(mapArgs, mapMultiArgs); - + try { + ReadConfigFile(mapArgs, mapMultiArgs); + } catch (const std::exception& e) { + QMessageBox::critical(0, QObject::tr("HyperStake"), + QObject::tr("Error: Cannot parse configuration file: %1. Only use key=value syntax.").arg(e.what())); + return false; + } + + // Application identification (must be set before OptionsModel is initialized, // as it is used to locate QSettings) app.setOrganizationName("HyperStake"); app.setOrganizationDomain("HyperStake.su"); - if(GetBoolArg("-testnet")) // Separate UI settings for testnet - app.setApplicationName("HyperStake-Qt-testnet"); - else - app.setApplicationName("HyperStake-Qt"); - + + QString networkIDString = "main"; + if (GetBoolArg("-testnet")){ + networkIDString = "test"; + } + + QScopedPointer networkStyle(NetworkStyle::instantiate(networkIDString)); + assert(!networkStyle.isNull()); + // Allow for separate UI settings for testnets + QApplication::setApplicationName(networkStyle->getAppName()); + // ... then GUI settings: OptionsModel optionsModel; @@ -165,24 +204,31 @@ int main(int argc, char *argv[]) // Load e.g. qt_de.qm if (qtTranslatorBase.load("qt_" + lang, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) + { app.installTranslator(&qtTranslatorBase); + } // Load e.g. qt_de_DE.qm if (qtTranslator.load("qt_" + lang_territory, QLibraryInfo::location(QLibraryInfo::TranslationsPath))) + { app.installTranslator(&qtTranslator); + } // Load e.g. bitcoin_de.qm (shortcut "de" needs to be defined in bitcoin.qrc) if (translatorBase.load(lang, ":/translations/")) + { app.installTranslator(&translatorBase); + } // Load e.g. bitcoin_de_DE.qm (shortcut "de_DE" needs to be defined in bitcoin.qrc) if (translator.load(lang_territory, ":/translations/")) + { app.installTranslator(&translator); + } // Subscribe to global signals from core uiInterface.ThreadSafeMessageBox.connect(ThreadSafeMessageBox); uiInterface.ThreadSafeAskFee.connect(ThreadSafeAskFee); - uiInterface.ThreadSafeHandleURI.connect(ThreadSafeHandleURI); uiInterface.InitMessage.connect(InitMessage); uiInterface.QueueShutdown.connect(QueueShutdown); uiInterface.Translate.connect(Translate); @@ -214,7 +260,7 @@ int main(int argc, char *argv[]) if (GUIUtil::GetStartOnSystemStartup()) GUIUtil::SetStartOnSystemStartup(true); - BitcoinGUI window; + BitcoinGUI window(networkStyle.data(),0); guiref = &window; if(AppInit2()) { @@ -243,9 +289,12 @@ int main(int argc, char *argv[]) window.show(); } - // Place this here as guiref has to be defined if we don't want to lose URIs - ipcInit(argc, argv); - + // Now that initialization/startup is done, process any command-line + // bitcoin: URIs + QObject::connect(paymentServer, SIGNAL(receivedURI(QString)), &window, SLOT(handleURI(QString))); + QTimer::singleShot(100, paymentServer, SLOT(uiReady())); + + app.exec(); window.hide(); diff --git a/src/qt/bitcoin.qrc b/src/qt/bitcoin.qrc index f7d6349c0..d297e2d45 100644 --- a/src/qt/bitcoin.qrc +++ b/src/qt/bitcoin.qrc @@ -1,6 +1,8 @@ res/icons/hyperstake-128.png + res/icons/hyperstake-16.png + res/icons/hyperstake-32.png res/icons/address-book.png res/icons/quit.png res/icons/send.png @@ -22,8 +24,6 @@ res/icons/editpaste.png res/icons/editcopy.png res/icons/add.png - res/icons/hyperstake-128.png - res/icons/hyperstake-16.png res/icons/edit.png res/icons/history.png res/icons/overview.png @@ -41,17 +41,18 @@ res/icons/filesave.png res/icons/qrcode.png res/icons/debugwindow.png + res/icons/blexp.png + res/icons/info.png + res/icons/mining_inactive.png + res/icons/s4c.png res/images/about.png - res/images/splash.jpg + res/images/splash.png res/images/wallet.png - res/movies/update_spinner.mng - - - locale/bitcoin_en.qm - locale/bitcoin_ru.qm + res/movies/update_spinner.gif + res/movies/mining.gif diff --git a/src/qt/bitcoinamountfield.cpp b/src/qt/bitcoinamountfield.cpp index 9514ec846..d10c063ca 100644 --- a/src/qt/bitcoinamountfield.cpp +++ b/src/qt/bitcoinamountfield.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include BitcoinAmountField::BitcoinAmountField(QWidget *parent): @@ -75,9 +76,14 @@ bool BitcoinAmountField::validate() void BitcoinAmountField::setValid(bool valid) { if (valid) - amount->setStyleSheet(""); - else - amount->setStyleSheet(STYLE_INVALID); + { + setProperty("error", false); + style()->polish(this); + } + else { + setProperty("error", true); + style()->polish(this); + } } QString BitcoinAmountField::text() const diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 0a648cdd3..b68a0882d 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -4,6 +4,7 @@ * W.J. van der Laan 2011-2012 * The Bitcoin Developers 2011-2012 */ +#include "bip38tooldialog.h" #include "bitcoingui.h" #include "transactiontablemodel.h" #include "addressbookpage.h" @@ -11,6 +12,8 @@ #include "signverifymessagedialog.h" #include "optionsdialog.h" #include "aboutdialog.h" +#include "charitydialog.h" +#include "calcdialog.h" #include "clientmodel.h" #include "walletmodel.h" #include "editaddressdialog.h" @@ -22,11 +25,15 @@ #include "bitcoinunits.h" #include "guiconstants.h" #include "askpassphrasedialog.h" +#include "networkstyle.h" #include "notificator.h" #include "guiutil.h" #include "rpcconsole.h" #include "wallet.h" #include "bitcoinrpc.h" +#include "blockbrowser.h" +#include "votingdialog.h" +#include "../wallet.h" #ifdef Q_OS_MAC #include "macdockiconhandler.h" @@ -50,20 +57,27 @@ #include #include #include +#include +#include #include #include #include #include + +#if QT_VERSION < 0x050000 #include +#endif #include - +#include +#include +#include #include extern CWallet *pwalletMain; extern int64 nLastCoinStakeSearchInterval; extern unsigned int nStakeTargetSpacing; -BitcoinGUI::BitcoinGUI(QWidget *parent): +BitcoinGUI::BitcoinGUI(const NetworkStyle * networkStyle, QWidget *parent): QMainWindow(parent), clientModel(0), walletModel(0), @@ -71,24 +85,40 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): unlockWalletAction(0), changePassphraseAction(0), lockWalletToggleAction(0), + bip38ToolAction(0), aboutQtAction(0), trayIcon(0), + trayIconMenu(0), notificator(0), rpcConsole(0) { resize(850, 550); - setWindowTitle(tr("HyperStake") + " - " + tr("Wallet")); + + QString windowTitle = tr("HyperStake") + " - " + tr("Wallet"); + windowTitle += " " + networkStyle->getTitleAddText(); #ifndef Q_OS_MAC - qApp->setWindowIcon(QIcon(":icons/bitcoin")); - setWindowIcon(QIcon(":icons/bitcoin")); + QApplication::setWindowIcon(networkStyle->getTrayAndWindowIcon()); + setWindowIcon(networkStyle->getTrayAndWindowIcon()); #else + MacDockIconHandler::instance()->setIcon(networkStyle->getAppIcon()); +#endif + setWindowTitle(windowTitle); + +#if defined(Q_OS_MAC) && QT_VERSION < 0x050000 + // This property is not implemented in Qt 5. Setting it has no effect. + // A replacement API (QtMacUnifiedToolBar) is available in QtMacExtras. setUnifiedTitleAndToolBarOnMac(true); - QApplication::setAttribute(Qt::AA_DontShowIconsInMenus); #endif + // Accept D&D of URIs setAcceptDrops(true); + /* zeewolf: Hot swappable wallet themes */ + // Discover themes + listThemes(themesList); + /* /zeewolf: Hot swappable wallet themes */ // Create actions for the toolbar, menu bar and tray/dock icon + // Needs walletFrame to be initialized createActions(); // Create application menu bar @@ -97,8 +127,8 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): // Create the toolbars createToolBars(); - // Create the tray icon (or setup the dock icon) - createTrayIcon(); + // Create the tray icon (or setup the dock icon) abffaaassffffa + createTrayIcon(networkStyle); // Create tabs overviewPage = new OverviewPage(); @@ -110,19 +140,21 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): transactionsPage->setLayout(vbox); addressBookPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::SendingTab); - receiveCoinsPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::ReceivingTab); - sendCoinsPage = new SendCoinsDialog(this); - signVerifyMessageDialog = new SignVerifyMessageDialog(this); - + bip38Dialog = new Bip38ToolDialog(this); + stakeForCharityDialog = new StakeForCharityDialog(this); + blockBrowser = new BlockBrowser((this)); + votingDialog = new VotingDialog(this); + centralWidget = new QStackedWidget(this); centralWidget->addWidget(overviewPage); centralWidget->addWidget(transactionsPage); centralWidget->addWidget(addressBookPage); centralWidget->addWidget(receiveCoinsPage); centralWidget->addWidget(sendCoinsPage); + centralWidget->addWidget(stakeForCharityDialog); setCentralWidget(centralWidget); // Create status bar @@ -135,7 +167,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks); frameBlocksLayout->setContentsMargins(3,0,3,0); frameBlocksLayout->setSpacing(3); - labelEncryptionIcon = new QLabel(); + labelEncryptionIcon = new GUIUtil::ClickableLabel(); labelMintingIcon = new QLabel(); labelConnectionsIcon = new QLabel(); labelBlocksIcon = new QLabel(); @@ -150,18 +182,23 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): frameBlocksLayout->addStretch(); // Set minting pixmap - labelMintingIcon->setPixmap(QIcon(":/icons/minting").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); labelMintingIcon->setEnabled(false); + // Add timer to update minting info QTimer *timerMintingIcon = new QTimer(labelMintingIcon); - timerMintingIcon->start(MODEL_UPDATE_DELAY); + timerMintingIcon->start(MINTING_UPDATE_DELAY); connect(timerMintingIcon, SIGNAL(timeout()), this, SLOT(updateMintingIcon())); + // Add timer to update minting weights QTimer *timerMintingWeights = new QTimer(labelMintingIcon); - timerMintingWeights->start(30 * 1000); + timerMintingWeights->start(1 * 5000); // 5 second update time connect(timerMintingWeights, SIGNAL(timeout()), this, SLOT(updateMintingWeights())); + // Set initial values for user and network weights - nWeight, nNetworkWeight = 0; + nWeight = 0; + nHoursToMaturity = 0; + nNetworkWeight = 0; + nAmount = 0; // Progress bar and label for blocks download progressBarLabel = new QLabel(); @@ -184,7 +221,7 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): statusBar()->addPermanentWidget(frameBlocks); syncIconMovie = new QMovie(":/movies/update_spinner", "mng", this); - // this->setStyleSheet("background-color: #effbef;"); + miningIconMovie = new QMovie(":/movies/mining", "mng", this); // Clicking on a transaction on the overview page simply sends you to transaction history page connect(overviewPage, SIGNAL(transactionClicked(QModelIndex)), this, SLOT(gotoHistoryPage())); @@ -201,6 +238,12 @@ BitcoinGUI::BitcoinGUI(QWidget *parent): // Clicking on "Sign Message" in the receive coins page sends you to the sign message tab connect(receiveCoinsPage, SIGNAL(signMessage(QString)), this, SLOT(gotoSignMessageTab(QString))); + // Clicking on stake for charity button in the address book sends you to the S4C page + connect(addressBookPage, SIGNAL(stakeForCharitySignal(QString)), this, SLOT(charityClicked(QString))); + + // Clicking on "Block Browser" in the transaction page sends you to the blockbrowser + connect(transactionView, SIGNAL(blockBrowserSignal(QString)), this, SLOT(gotoBlockBrowser(QString))); + gotoOverviewPage(); } @@ -210,6 +253,7 @@ BitcoinGUI::~BitcoinGUI() trayIcon->hide(); #ifdef Q_OS_MAC delete appMenuBar; + MacDockIconHandler::instance()->setMainWindow(NULL); #endif } @@ -223,13 +267,13 @@ void BitcoinGUI::createActions() overviewAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_1)); tabGroup->addAction(overviewAction); - sendCoinsAction = new QAction(QIcon(":/icons/send"), tr("&Send coins"), this); + sendCoinsAction = new QAction(QIcon(":/icons/send"), tr("&Send"), this); sendCoinsAction->setToolTip(tr("Send coins to a HyperStake address")); sendCoinsAction->setCheckable(true); sendCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_2)); tabGroup->addAction(sendCoinsAction); - receiveCoinsAction = new QAction(QIcon(":/icons/receiving_addresses"), tr("&Receive coins"), this); + receiveCoinsAction = new QAction(QIcon(":/icons/receiving_addresses"), tr("&Receive"), this); receiveCoinsAction->setToolTip(tr("Show the list of addresses for receiving payments")); receiveCoinsAction->setCheckable(true); receiveCoinsAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_3)); @@ -241,7 +285,7 @@ void BitcoinGUI::createActions() historyAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_4)); tabGroup->addAction(historyAction); - addressBookAction = new QAction(QIcon(":/icons/address-book"), tr("&Address Book"), this); + addressBookAction = new QAction(QIcon(":/icons/address-book"), tr("&Contacts"), this); addressBookAction->setToolTip(tr("Edit the list of stored addresses and labels")); addressBookAction->setCheckable(true); addressBookAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_5)); @@ -257,6 +301,7 @@ void BitcoinGUI::createActions() connect(historyAction, SIGNAL(triggered()), this, SLOT(gotoHistoryPage())); connect(addressBookAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); connect(addressBookAction, SIGNAL(triggered()), this, SLOT(gotoAddressBookPage())); + quitAction = new QAction(QIcon(":/icons/quit"), tr("E&xit"), this); quitAction->setToolTip(tr("Quit application")); @@ -265,6 +310,25 @@ void BitcoinGUI::createActions() aboutAction = new QAction(QIcon(":/icons/bitcoin"), tr("&About HyperStake"), this); aboutAction->setToolTip(tr("Show information about HyperStake")); aboutAction->setMenuRole(QAction::AboutRole); + + charityAction = new QAction(QIcon(":/icons/s4c"), tr("&MultiSend"), this); + charityAction->setToolTip(tr("MultiSend Settings")); + charityAction->setCheckable(true); + charityAction->setShortcut(QKeySequence(Qt::ALT + Qt::Key_7)); + tabGroup->addAction(charityAction); + + calcAction = new QAction(QIcon(":/icons/bitcoin"), tr("&Stake Calculator"), this); + calcAction->setToolTip(tr("Open Stake Calculator")); + calcAction->setMenuRole(QAction::AboutRole); + + blockAction = new QAction(QIcon(":/icons/blexp"), tr("Block Bro&wser"), this); + blockAction->setStatusTip(tr("Explore the BlockChain")); + blockAction->setToolTip(blockAction->statusTip()); + + votingAction = new QAction(QIcon(":/icons/bitcoin"), tr("&Voting"), this); + votingAction->setStatusTip(tr("Set and View Vote Proposals and Settings")); + votingAction->setToolTip(votingAction->statusTip()); + aboutQtAction = new QAction(QIcon(":/trolltech/qmessagebox/images/qtlogo-64.png"), tr("About &Qt"), this); aboutQtAction->setToolTip(tr("Show information about Qt")); aboutQtAction->setMenuRole(QAction::AboutQtRole); @@ -275,8 +339,8 @@ void BitcoinGUI::createActions() encryptWalletAction = new QAction(QIcon(":/icons/lock_closed"), tr("&Encrypt Wallet..."), this); encryptWalletAction->setToolTip(tr("Encrypt or decrypt wallet")); encryptWalletAction->setCheckable(true); - unlockWalletAction = new QAction(QIcon(":/icons/lock_open"), tr("&Unlock Wallet"), this); - unlockWalletAction->setToolTip(tr("Unlock an Encrypted Wallet")); + unlockWalletAction = new QAction(QIcon(":/icons/lock_open"), tr("&Unlock Wallet For PoS..."), this); + unlockWalletAction->setStatusTip(tr("Unlock the wallet for PoS")); unlockWalletAction->setCheckable(true); backupWalletAction = new QAction(QIcon(":/icons/filesave"), tr("&Backup Wallet..."), this); backupWalletAction->setToolTip(tr("Backup wallet to another location")); @@ -285,6 +349,8 @@ void BitcoinGUI::createActions() lockWalletToggleAction = new QAction(this); signMessageAction = new QAction(QIcon(":/icons/edit"), tr("Sign &message..."), this); verifyMessageAction = new QAction(QIcon(":/icons/transaction_0"), tr("&Verify message..."), this); + bip38ToolAction = new QAction(QIcon(":/icons/key"), tr("&BIP38 tool"), this); + bip38ToolAction->setToolTip(tr("Encrypt and decrypt private keys using a passphrase")); checkWalletAction = new QAction(QIcon(":/icons/transaction_confirmed"), tr("&Check Wallet..."), this); checkWalletAction->setStatusTip(tr("Check wallet integrity and report findings")); @@ -294,11 +360,18 @@ void BitcoinGUI::createActions() exportAction = new QAction(QIcon(":/icons/export"), tr("&Export..."), this); exportAction->setToolTip(tr("Export the data in the current tab to a file")); - openRPCConsoleAction = new QAction(QIcon(":/icons/debugwindow"), tr("&Debug window"), this); + openRPCConsoleAction = new QAction(QIcon(":/icons/debugwindow"), tr("&Debug"), this); openRPCConsoleAction->setToolTip(tr("Open debugging and diagnostic console")); connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); connect(aboutAction, SIGNAL(triggered()), this, SLOT(aboutClicked())); + + connect(charityAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); + connect(charityAction, SIGNAL(triggered()), this, SLOT(charityClicked())); + + connect(calcAction, SIGNAL(triggered()), this, SLOT(showNormalIfMinimized())); + connect(calcAction, SIGNAL(triggered()), this, SLOT(calcClicked())); + connect(aboutQtAction, SIGNAL(triggered()), qApp, SLOT(aboutQt())); connect(optionsAction, SIGNAL(triggered()), this, SLOT(optionsClicked())); connect(toggleHideAction, SIGNAL(triggered()), this, SLOT(toggleHidden())); @@ -310,7 +383,33 @@ void BitcoinGUI::createActions() connect(lockWalletToggleAction, SIGNAL(triggered()), this, SLOT(lockWalletToggle())); connect(signMessageAction, SIGNAL(triggered()), this, SLOT(gotoSignMessageTab())); connect(verifyMessageAction, SIGNAL(triggered()), this, SLOT(gotoVerifyMessageTab())); - connect(unlockWalletAction, SIGNAL(triggered()), this, SLOT(unlockWallet())); + connect(bip38ToolAction, SIGNAL(triggered()), this, SLOT(gotoBip38Tool())); + connect(unlockWalletAction, SIGNAL(triggered()), this, SLOT(unlockWalletForMint())); + + connect(blockAction, SIGNAL(triggered()), this, SLOT(gotoBlockBrowser())); + connect(votingAction, SIGNAL(triggered()), this, SLOT(gotoVotingDialog())); + + /* zeewolf: Hot swappable wallet themes */ + if (themesList.count()>0) + { + QSignalMapper* signalMapper = new QSignalMapper (this) ; + //QActionGroup* menuActionGroup = new QActionGroup( this ); + //menuActionGroup->setExclusive(true); + + // Add custom themes (themes directory) + for( int i=0; i < themesList.count(); i++ ) + { + QString theme=themesList[i]; + customActions[i] = new QAction(QIcon(":/icons/options"), theme, this); + customActions[i]->setToolTip(QString("Switch to " + theme + " theme")); + customActions[i]->setStatusTip(QString("Switch to " + theme + " theme")); + //customActions[i]->setActionGroup(menuActionGroup); + signalMapper->setMapping(customActions[i], theme); + connect(customActions[i], SIGNAL(triggered()), signalMapper, SLOT (map())); + } + connect(signalMapper, SIGNAL(mapped(QString)), this, SLOT(changeTheme(QString))); + } + /* /zeewolf: Hot swappable wallet themes */ } void BitcoinGUI::createMenuBar() @@ -331,25 +430,40 @@ void BitcoinGUI::createMenuBar() file->addAction(verifyMessageAction); file->addSeparator(); file->addAction(quitAction); + + QMenu *network = appMenuBar->addMenu(tr("&Network")); + network->addAction(blockAction); QMenu *settings = appMenuBar->addMenu(tr("&Tools")); settings->addAction(encryptWalletAction); + settings->addAction(lockWalletToggleAction); settings->addAction(unlockWalletAction); settings->addAction(changePassphraseAction); - settings->addAction(lockWalletToggleAction); settings->addAction(checkWalletAction); settings->addAction(repairWalletAction); + settings->addAction(charityAction); + settings->addAction(calcAction); + settings->addAction(bip38ToolAction); + if (fTestNet) + settings->addAction(votingAction); settings->addSeparator(); settings->addAction(optionsAction); + /* zeewolf: Hot swappable wallet themes */ + if (themesList.count()>0) + { + QMenu *themes = appMenuBar->addMenu(tr("T&hemes")); + for (int i = 0; i < themesList.count(); i++) { + themes->addAction(customActions[i]); + } + } + /* /zeewolf: Hot swappable wallet themes */ + QMenu *help = appMenuBar->addMenu(tr("&Help")); help->addAction(openRPCConsoleAction); help->addSeparator(); help->addAction(aboutAction); help->addAction(aboutQtAction); - - // QString ss("QMenuBar::item { background-color: #effbef; color: black }"); - // appMenuBar->setStyleSheet(ss); } void BitcoinGUI::createToolBars() @@ -361,9 +475,11 @@ void BitcoinGUI::createToolBars() toolbar->addAction(receiveCoinsAction); toolbar->addAction(historyAction); toolbar->addAction(addressBookAction); + toolbar->addAction(charityAction); QToolBar *toolbar2 = addToolBar(tr("Actions toolbar")); toolbar2->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + toolbar2->addAction(openRPCConsoleAction); toolbar2->addAction(lockWalletToggleAction); toolbar2->addAction(exportAction); } @@ -373,26 +489,10 @@ void BitcoinGUI::setClientModel(ClientModel *clientModel) this->clientModel = clientModel; if(clientModel) { - // Replace some strings and icons, when using the testnet - if(clientModel->isTestNet()) - { - setWindowTitle(windowTitle() + QString(" ") + tr("[testnet]")); -#ifndef Q_OS_MAC - qApp->setWindowIcon(QIcon(":icons/bitcoin_testnet")); - setWindowIcon(QIcon(":icons/bitcoin_testnet")); -#else - MacDockIconHandler::instance()->setIcon(QIcon(":icons/bitcoin_testnet")); -#endif - if(trayIcon) - { - trayIcon->setToolTip(tr("HyperStake client") + QString(" ") + tr("[testnet]")); - trayIcon->setIcon(QIcon(":/icons/toolbar_testnet")); - toggleHideAction->setIcon(QIcon(":/icons/toolbar_testnet")); - } - - aboutAction->setIcon(QIcon(":/icons/toolbar_testnet")); - } - + // Create system tray menu (or setup the dock menu) that late to prevent users from calling actions, + // while the client has not yet fully loaded + createTrayIconMenu(); + // Keep up to date with client setNumConnections(clientModel->getNumConnections()); connect(clientModel, SIGNAL(numConnectionsChanged(int)), this, SLOT(setNumConnections(int))); @@ -425,6 +525,9 @@ void BitcoinGUI::setWalletModel(WalletModel *walletModel) receiveCoinsPage->setModel(walletModel->getAddressTableModel()); sendCoinsPage->setModel(walletModel); signVerifyMessageDialog->setModel(walletModel); + bip38Dialog->setModel(walletModel); + stakeForCharityDialog->setModel(walletModel); + votingDialog->SetWalletModel(walletModel); setEncryptionStatus(walletModel->getEncryptionStatus()); connect(walletModel, SIGNAL(encryptionStatusChanged(int)), this, SLOT(setEncryptionStatus(int))); @@ -438,24 +541,39 @@ void BitcoinGUI::setWalletModel(WalletModel *walletModel) } } -void BitcoinGUI::createTrayIcon() +void BitcoinGUI::createTrayIcon(const NetworkStyle *networkStyle) { - QMenu *trayIconMenu; #ifndef Q_OS_MAC trayIcon = new QSystemTrayIcon(this); + QString toolTip = tr("HyperStake client") + " " + networkStyle->getTitleAddText(); + trayIcon->setToolTip(toolTip); + trayIcon->setIcon(networkStyle->getTrayAndWindowIcon()); + trayIcon->show(); +#endif + + notificator = new Notificator(qApp->applicationName(), trayIcon, this); +} + + +void BitcoinGUI::createTrayIconMenu() +{ +#ifndef Q_OS_MAC + // return if trayIcon is unset (only on non-Mac OSes) + if (!trayIcon) + return; + trayIconMenu = new QMenu(this); trayIcon->setContextMenu(trayIconMenu); - trayIcon->setToolTip(tr("HyperStake client")); - trayIcon->setIcon(QIcon(":/icons/toolbar")); + connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(trayIconActivated(QSystemTrayIcon::ActivationReason))); - trayIcon->show(); #else // Note: On Mac, the dock icon is used to provide the tray's functionality. MacDockIconHandler *dockIconHandler = MacDockIconHandler::instance(); + dockIconHandler->setMainWindow((QMainWindow *)this); trayIconMenu = dockIconHandler->dockMenu(); #endif - + // Configuration of the tray icon (or dock icon) icon menu trayIconMenu->addAction(toggleHideAction); trayIconMenu->addSeparator(); @@ -471,10 +589,9 @@ void BitcoinGUI::createTrayIcon() trayIconMenu->addSeparator(); trayIconMenu->addAction(quitAction); #endif - - notificator = new Notificator(qApp->applicationName(), trayIcon); } + #ifndef Q_OS_MAC void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason) { @@ -486,6 +603,15 @@ void BitcoinGUI::trayIconActivated(QSystemTrayIcon::ActivationReason reason) } #endif +void BitcoinGUI::lockIconClicked() +{ + if(!walletModel) + return; + + if(walletModel->getEncryptionStatus() == WalletModel::Locked) + unlockWalletForMint(); +} + void BitcoinGUI::optionsClicked() { if(!clientModel || !clientModel->getOptionsModel()) @@ -691,6 +817,8 @@ void BitcoinGUI::incomingTransaction(const QModelIndex & parent, int start, int .data(Qt::EditRole).toULongLong(); if(!clientModel->inInitialBlockDownload()) { + fMultiSendNotify = pwalletMain->fMultiSendNotify; + // On new transaction, make an info balloon // Unless the initial block download is in progress, to prevent balloon-spam QString date = ttm->index(start, TransactionTableModel::Date, parent) @@ -704,7 +832,7 @@ void BitcoinGUI::incomingTransaction(const QModelIndex & parent, int start, int .data(Qt::DecorationRole)); notificator->notify(Notificator::Information, - (amount)<0 ? tr("Sent transaction") : + (amount)<0 ? (fMultiSendNotify == true ? tr("Sent MultiSend transaction") : tr("Sent transaction") ): tr("Incoming transaction"), tr("Date: %1\n" "Amount: %2\n" @@ -714,6 +842,9 @@ void BitcoinGUI::incomingTransaction(const QModelIndex & parent, int start, int .arg(BitcoinUnits::formatWithUnit(walletModel->getOptionsModel()->getDisplayUnit(), amount, true)) .arg(type) .arg(address), icon); + + pwalletMain->fMultiSendNotify = false; + } } @@ -746,6 +877,19 @@ void BitcoinGUI::gotoAddressBookPage() connect(exportAction, SIGNAL(triggered()), addressBookPage, SLOT(exportClicked())); } +void BitcoinGUI::gotoBlockBrowser(QString transactionId) +{ + if(!transactionId.isEmpty()) + blockBrowser->setTransactionId(transactionId); + + blockBrowser->show(); +} + +void BitcoinGUI::gotoVotingDialog() +{ + votingDialog->show(); +} + void BitcoinGUI::gotoReceiveCoinsPage() { receiveCoinsAction->setChecked(true); @@ -783,6 +927,11 @@ void BitcoinGUI::gotoVerifyMessageTab(QString addr) signVerifyMessageDialog->setAddress_VM(addr); } +void BitcoinGUI::gotoBip38Tool() +{ + bip38Dialog->showTab_ENC(true); +} + void BitcoinGUI::dragEnterEvent(QDragEnterEvent *event) { // Accept only URIs @@ -832,8 +981,11 @@ void BitcoinGUI::setEncryptionStatus(int status) labelEncryptionIcon->hide(); encryptWalletAction->setChecked(false); encryptWalletAction->setEnabled(true); + labelEncryptionIcon->setToolTip(tr("Wallet is encrypted and currently unlocked")); + disconnect(labelEncryptionIcon,SIGNAL(clicked()), this, SLOT(lockIconClicked())); changePassphraseAction->setEnabled(false); lockWalletToggleAction->setVisible(false); + unlockWalletAction->setChecked(false); break; case WalletModel::Unlocked: labelEncryptionIcon->show(); @@ -841,7 +993,7 @@ void BitcoinGUI::setEncryptionStatus(int status) labelEncryptionIcon->setToolTip(tr("Wallet is encrypted and currently unlocked")); encryptWalletAction->setChecked(true); encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported - unlockWalletAction->setChecked(true); + unlockWalletAction->setChecked(false); unlockWalletAction->setEnabled(false); changePassphraseAction->setEnabled(true); lockWalletToggleAction->setVisible(true); @@ -850,18 +1002,17 @@ void BitcoinGUI::setEncryptionStatus(int status) lockWalletToggleAction->setToolTip(tr("Lock wallet")); break; case WalletModel::Locked: - labelEncryptionIcon->show(); - labelEncryptionIcon->setPixmap(QIcon(":/icons/lock_closed").pixmap(STATUSBAR_ICONSIZE,STATUSBAR_ICONSIZE)); - labelEncryptionIcon->setToolTip(tr("Wallet is encrypted and currently locked")); + labelEncryptionIcon->hide(); encryptWalletAction->setChecked(true); encryptWalletAction->setEnabled(false); // TODO: decrypt currently not supported - unlockWalletAction->setChecked(true); + unlockWalletAction->setChecked(false); unlockWalletAction->setEnabled(true); changePassphraseAction->setEnabled(true); lockWalletToggleAction->setVisible(true); lockWalletToggleAction->setIcon(QIcon(":/icons/lock_open")); lockWalletToggleAction->setText(tr("&Unlock Wallet...")); lockWalletToggleAction->setToolTip(tr("Unlock wallet")); + disconnect(labelEncryptionIcon,SIGNAL(clicked()), this, SLOT(lockIconClicked())); break; } } @@ -939,7 +1090,12 @@ void BitcoinGUI::repairWallet() void BitcoinGUI::backupWallet() { + #if QT_VERSION < 0x050000 QString saveDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation); + #else + QString saveDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); + #endif + QString filename = QFileDialog::getSaveFileName(this, tr("Backup Wallet"), saveDir, tr("Wallet Data (*.dat)")); if(!filename.isEmpty()) { if(!walletModel->backupWallet(filename)) { @@ -962,8 +1118,7 @@ void BitcoinGUI::lockWalletToggle() // Unlock wallet when requested by wallet model if(walletModel->getEncryptionStatus() == WalletModel::Locked) { - AskPassphraseDialog::Mode mode = AskPassphraseDialog::UnlockMinting; - AskPassphraseDialog dlg(mode, this); + AskPassphraseDialog dlg(AskPassphraseDialog::Unlock, this); dlg.setModel(walletModel); dlg.exec(); } @@ -984,6 +1139,42 @@ void BitcoinGUI::unlockWallet() } } +void BitcoinGUI::unlockWalletForMint() +{ + if(!walletModel) + return; + + // Unlock wallet when requested by user + if(walletModel->getEncryptionStatus() == WalletModel::Locked) + { + AskPassphraseDialog dlg(AskPassphraseDialog::UnlockForMint, this); + dlg.setModel(walletModel); + dlg.exec(); + + // Only show message if unlock is sucessfull. + if(walletModel->getEncryptionStatus() == WalletModel::Unlocked) + notificator->notify(Notificator::Warning, + tr("Unlock Wallet Information"), + tr("Wallet has been unlocked. \n" + "Proof of Stake has started.\n")); + } +} + +void BitcoinGUI::lockWallet() +{ + if(!walletModel) + return; + + // Lock wallet when requested by user + if(walletModel->getEncryptionStatus() == WalletModel::Unlocked) + walletModel->setWalletLocked(true,"",true); + notificator->notify(Notificator::Warning, + tr("Lock Wallet Information"), + tr("Wallet has been unlocked. \n" + "Proof of Stake has stopped.\n")); + +} + void BitcoinGUI::showNormalIfMinimized(bool fToggleHidden) { // activateWindow() (sometimes) helps with keyboard focus on Windows @@ -1015,66 +1206,271 @@ void BitcoinGUI::updateMintingIcon() { if (pwalletMain && pwalletMain->IsLocked()) { - labelMintingIcon->setToolTip(tr("Not minting because wallet is locked.
Network weight is %1").arg(nNetworkWeight)); + labelMintingIcon->setToolTip(tr("Not minting because wallet is locked.
Network weight is %1.
MultiSend: %2").arg(nNetworkWeight).arg(fMultiSend ? tr("Active"):tr("Not Active"))); labelMintingIcon->setEnabled(false); + labelMintingIcon->setPixmap(QIcon(":/icons/mining_inactive").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); + } + else if (pwalletMain && pwalletMain->fDisableStake) + { + labelMintingIcon->setToolTip(tr("Not minting because staking is disabled.
Network weight is %1.
MultiSend: %2").arg(nNetworkWeight).arg(fMultiSend ? tr("Active"):tr("Not Active"))); + labelMintingIcon->setEnabled(false); + labelMintingIcon->setPixmap(QIcon(":/icons/mining_inactive").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); } else if (vNodes.empty()) { - labelMintingIcon->setToolTip(tr("Not minting because wallet is offline.
Network weight is %1").arg(nNetworkWeight)); + labelMintingIcon->setToolTip(tr("Not minting because wallet is offline.
Network weight is %1.
MultiSend: %2").arg(nNetworkWeight).arg(fMultiSend ? tr("Active"):tr("Not Active"))); labelMintingIcon->setEnabled(false); + labelMintingIcon->setPixmap(QIcon(":/icons/mining_inactive").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); } else if (IsInitialBlockDownload()) { - labelMintingIcon->setToolTip(tr("Not minting because wallet is syncing.
Network weight is %1").arg(nNetworkWeight)); + labelMintingIcon->setToolTip(tr("Not minting because wallet is syncing.
Network weight is %1.
MultiSend: %2").arg(nNetworkWeight).arg(fMultiSend ? tr("Active"):tr("Not Active"))); labelMintingIcon->setEnabled(false); + labelMintingIcon->setPixmap(QIcon(":/icons/mining_inactive").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); } else if (!nWeight) { - labelMintingIcon->setToolTip(tr("Not minting because you don't have mature coins.
Network weight is %1").arg(nNetworkWeight)); + labelMintingIcon->setToolTip(tr("Not minting because you don't have mature coins.
Next block matures in %2 hours
Network weight is %1
MultiSend: %3").arg(nNetworkWeight).arg(nHoursToMaturity).arg(fMultiSend ? tr("Active"):tr("Not Active"))); labelMintingIcon->setEnabled(false); + labelMintingIcon->setPixmap(QIcon(":/icons/mining_inactive").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); } else if (nLastCoinStakeSearchInterval) - { - uint64 nEstimateTime = nStakeTargetSpacing * nNetworkWeight / nWeight; - + { + uint64 nAccuracyAdjustment = 1; // this is a manual adjustment param if needed to make more accurate + uint64 nEstimateTime = 60 * nNetworkWeight / nWeight / nAccuracyAdjustment; + + uint64 nRangeLow = nEstimateTime; + uint64 nRangeHigh = nEstimateTime * 1.5; QString text; if (nEstimateTime < 60) { - text = tr("%n second(s)", "", nEstimateTime); + text = tr("%1 - %2 seconds").arg(nRangeLow).arg(nRangeHigh); } else if (nEstimateTime < 60*60) { - text = tr("%n minute(s)", "", nEstimateTime/60); + text = tr("%1 - %2 minutes").arg(nRangeLow / 60).arg(nRangeHigh / 60); } else if (nEstimateTime < 24*60*60) { - text = tr("%n hour(s)", "", nEstimateTime/(60*60)); + text = tr("%1 - %2 hours").arg(nRangeLow / (60*60)).arg(nRangeHigh / (60*60)); } else { - text = tr("%n day(s)", "", nEstimateTime/(60*60*24)); + text = tr("%1 - %2 days").arg(nRangeLow / (60*60*24)).arg(nRangeHigh / (60*60*24)); } + labelMintingIcon->setMovie(miningIconMovie); + miningIconMovie->start(); labelMintingIcon->setEnabled(true); - labelMintingIcon->setToolTip(tr("Minting.
Your weight is %1.
Network weight is %2.
Expected time to earn reward is %3.").arg(nWeight).arg(nNetworkWeight).arg(text)); + labelMintingIcon->setToolTip(tr("Minting.
Your weight is %1.
Network weight is %2.
Estimated next stake in %3.
MultiSend: %4").arg(nWeight).arg(nNetworkWeight).arg(text).arg(fMultiSend ? tr("Active"):tr("Not Active"))); } else { labelMintingIcon->setToolTip(tr("Not minting.")); labelMintingIcon->setEnabled(false); + labelMintingIcon->setPixmap(QIcon(":/icons/mining_inactive").pixmap(STATUSBAR_ICONSIZE, STATUSBAR_ICONSIZE)); } } +uint nLastWeightCheck = 0; void BitcoinGUI::updateMintingWeights() { // Only update if we have the network's current number of blocks, or weight(s) are zero (fixes lagging GUI) - if ((clientModel && clientModel->getNumBlocks() == clientModel->getNumBlocksOfPeers()) || !nWeight || !nNetworkWeight) + if ((clientModel && clientModel->getNumBlocks() >= clientModel->getNumBlocksOfPeers()) || !nWeight || !nNetworkWeight) { - nWeight = 0; + //only update weight every 120 seconds in order to reduce resource consumption + if(GetTime() - nLastWeightCheck > 120) + { + nWeight = 0; + nAmount = 0; + nNetworkWeight = GetPoSKernelPS(); + nLastWeightCheck = GetTime(); + + if(!pwalletMain) + return; + + if(pwalletMain->MintableCoins()) + nHoursToMaturity = 0; + else + nHoursToMaturity = pwalletMain->GetTimeToNextMaturity() / (60*60); + + if(pwalletMain->bnStakeWeightCached != 0) + { + nHoursToMaturity = 0; + nWeight = pwalletMain->bnStakeWeightCached.getuint64(); + } + else + pwalletMain->GetStakeWeight(*pwalletMain, nMinMax, nMinMax, nWeight, nAmount); + } + } + + //MultiSend check + if(walletModel) + fMultiSend = pwalletMain->fMultiSend; +} + +void BitcoinGUI::charityClicked(QString addr) +{ + charityAction->setChecked(true); + centralWidget->setCurrentWidget(stakeForCharityDialog); + + if(!addr.isEmpty()) + stakeForCharityDialog->setAddress(addr); + + exportAction->setEnabled(false); + disconnect(exportAction, SIGNAL(triggered()), 0, 0); +} - if (pwalletMain) - pwalletMain->GetStakeWeight2(*pwalletMain, nMinMax, nMinMax, nWeight); +void BitcoinGUI::calcClicked() +{ + calcDialog dlg; + dlg.exec(); +} + +/* zeewolf: Hot swappable wallet themes */ +void BitcoinGUI::changeTheme(QString theme) +{ + // load Default theme first (if present) to apply default styles + loadTheme("Default"); + + if (theme != "Default") { + loadTheme(theme); + } +} + +void BitcoinGUI::loadTheme(QString theme) +{ + // template variables : key => value + QMap variables; + + // path to selected theme dir - for simpler use, just use $theme-dir in qss : url($theme-dir/image.png) + QString themeDir = themesDir + "/" + theme; + + // if theme selected + if (theme != "") { + QFile qss(themeDir + "/styles.qss"); + // open qss + if (qss.open(QFile::ReadOnly)) + { + // read stylesheet + QString styleSheet = QString(qss.readAll()); + QTextStream in(&qss); + // rewind + in.seek(0); + bool readingVariables = false; + + // seek for variables + while(!in.atEnd()) { + QString line = in.readLine(); + // variables starts here + if (line == "/** [VARS]") { + readingVariables = true; + } + // variables end here + if (line == "[/VARS] */") { + break; + } + // if we're reading variables - store them in a map + if (readingVariables == true) { + // skip empty lines + if (line.length()>3 && line.contains('=')) { + QStringList fields = line.split("="); + QString var = fields.at(0).trimmed(); + QString value = fields.at(1).trimmed(); + variables[var] = value; + } + } + } + + // replace path to themes dir + styleSheet.replace("$theme-dir", themeDir); + styleSheet.replace("$themes-dir", themesDir); + + QMapIterator variable(variables); + variable.toBack(); + // iterate backwards to prevent overwriting variables + while (variable.hasPrevious()) { + variable.previous(); + // replace variables + styleSheet.replace(variable.key(), variable.value()); + } + + qss.close(); + + // Apply the result qss file to Qt + + /*if (styleSheet.contains("$", Qt::CaseInsensitive)) { + QRegExp rx("(\\$[-\\w]+)"); + rx.indexIn(styleSheet); + QString captured = rx.cap(1); + QMessageBox::warning(this, "Theme syntax error", "You have used variable that is not declared " + captured + ". Theme will not be applied."); + } else {*/ + qApp->setStyleSheet(styleSheet); + /*}*/ + } + } else { + // If not theme name given - clear styles + qApp->setStyleSheet(QString("")); + } + + // set selected theme and store it in registry + selectedTheme = theme; + QSettings settings; + settings.setValue("Template", selectedTheme); +} - nNetworkWeight = GetPoSKernelPS(); +void BitcoinGUI::listThemes(QStringList& themes) +{ + QDir currentDir(qApp->applicationDirPath()); + // try app dir + if (currentDir.cd("themes")) { + // got it! (win package) + } else if (currentDir.cd("src/qt/res/themes")) { + // got it + } else if (currentDir.cd("../src/qt/res/themes")) { + // got it + } else { + // themes not found :( + return; } + themesDir = currentDir.path(); + currentDir.setFilter(QDir::Dirs); + QStringList entries = currentDir.entryList(); + for( QStringList::ConstIterator entry=entries.begin(); entry!=entries.end(); ++entry ) + { + QString themeName=*entry; + if(themeName != tr(".") && themeName != tr("..")) + { + themes.append(themeName); + } + } + + // get selected theme from registry (if any) + QSettings settings; + selectedTheme = settings.value("Template").toString(); + // or use default theme - HyperBlue + if (selectedTheme=="") { + selectedTheme = "HyperBlue"; + } + // load it! + loadTheme(selectedTheme); } + +void BitcoinGUI::keyPressEvent(QKeyEvent * e) +{ + switch (e->type()) + { + case QEvent::KeyPress: + // $ key + if (e->key() == 36) { + // dev feature: key reloads selected theme + loadTheme(selectedTheme); + } + break; + default: + break; + } + +} + +/* /zeewolf: Hot swappable wallet themes */ diff --git a/src/qt/bitcoingui.h b/src/qt/bitcoingui.h index c3884fb59..d1234fae4 100644 --- a/src/qt/bitcoingui.h +++ b/src/qt/bitcoingui.h @@ -6,16 +6,21 @@ #include "util.h" // for uint64 -class TransactionTableModel; +class AddressBookPage; +class BlockBrowser; class ClientModel; -class WalletModel; -class TransactionView; +class NetworkStyle; +class Notificator; class OverviewPage; -class AddressBookPage; +class RPCConsole; class SendCoinsDialog; class SignVerifyMessageDialog; -class Notificator; -class RPCConsole; +class Bip38ToolDialog; +class StakeForCharityDialog; +class TransactionTableModel; +class TransactionView; +class WalletModel; +class VotingDialog; QT_BEGIN_NAMESPACE class QLabel; @@ -36,7 +41,7 @@ class BitcoinGUI : public QMainWindow { Q_OBJECT public: - explicit BitcoinGUI(QWidget *parent = 0); + explicit BitcoinGUI(const NetworkStyle *networkStyle, QWidget *parent = 0); ~BitcoinGUI(); /** Set the client model. @@ -67,6 +72,10 @@ class BitcoinGUI : public QMainWindow AddressBookPage *receiveCoinsPage; SendCoinsDialog *sendCoinsPage; SignVerifyMessageDialog *signVerifyMessageDialog; + Bip38ToolDialog *bip38Dialog; + StakeForCharityDialog *stakeForCharityDialog; + BlockBrowser *blockBrowser; + VotingDialog* votingDialog; QLabel *labelEncryptionIcon; QLabel *labelMintingIcon; @@ -93,21 +102,45 @@ class BitcoinGUI : public QMainWindow QAction *backupWalletAction; QAction *changePassphraseAction; QAction *lockWalletToggleAction; + QAction *bip38ToolAction; QAction *checkWalletAction; QAction *repairWalletAction; QAction *aboutQtAction; + QAction *themeCustomAction; QAction *openRPCConsoleAction; + QAction *blockAction; + QAction *blocksIconAction; + QAction *connectionIconAction; + QAction *stakingIconAction; + QAction *charityAction; + QAction *calcAction; + QAction *votingAction; QSystemTrayIcon *trayIcon; + QMenu *trayIconMenu; Notificator *notificator; TransactionView *transactionView; RPCConsole *rpcConsole; QMovie *syncIconMovie; + QMovie *miningIconMovie; uint64 nMinMax; uint64 nWeight; uint64 nNetworkWeight; + uint64 nHoursToMaturity; + uint64 nAmount; + bool fMultiSend; + bool fMultiSendNotify; + int nCharityPercent; + QString strCharityAddress; + /* Themes support */ + QString selectedTheme; + QStringList themesList; + // Path to directory where all themes are (usable for some common images?...) + QString themesDir; + QAction *customActions[100]; + /* /Themes support */ /** Create the main UI actions. */ void createActions(); @@ -115,8 +148,11 @@ class BitcoinGUI : public QMainWindow void createMenuBar(); /** Create the toolbars */ void createToolBars(); - /** Create system tray (notification) icon */ - void createTrayIcon(); + /** Create system tray icon and notification */ + void createTrayIcon(const NetworkStyle *networkStyle); + /** Create system tray menu (or setup the dock menu) */ + void createTrayIconMenu(); + public slots: /** Set number of connections shown in the UI */ @@ -153,16 +189,24 @@ private slots: void gotoReceiveCoinsPage(); /** Switch to send coins page */ void gotoSendCoinsPage(); - + /** Switch to block browser page */ + void gotoBlockBrowser(QString transactionId = ""); /** Show Sign/Verify Message dialog and switch to sign message tab */ void gotoSignMessageTab(QString addr = ""); /** Show Sign/Verify Message dialog and switch to verify message tab */ void gotoVerifyMessageTab(QString addr = ""); - + /** Show BIP 38 tool - default to Encryption tab */ + void gotoBip38Tool(); + /** Show the voting dialog */ + void gotoVotingDialog(); + /** Allow user to unlock wallet from click */ + void lockIconClicked(); /** Show configuration dialog */ void optionsClicked(); /** Show about dialog */ void aboutClicked(); + /** Show Stake Calculator Dialog */ + void calcClicked(); #ifndef Q_OS_MAC /** Handle tray icon clicked */ void trayIconActivated(QSystemTrayIcon::ActivationReason reason); @@ -182,11 +226,14 @@ private slots: void backupWallet(); /** Change encrypted wallet passphrase */ void changePassphrase(); + /** Lock Wallet */ + void lockWallet(); /** Toggle unlocking wallet temporarily */ void lockWalletToggle(); - - void unlockWallet(); - + /** Ask for passphrase to unlock wallet temporarily */ + void unlockWallet(); + /** Ask for passphrase to unlock wallet for the session to mint */ + void unlockWalletForMint(); /** Show window if hidden, unminimize when minimized, rise when obscured or show if hidden and fToggleHidden is true */ void showNormalIfMinimized(bool fToggleHidden = false); /** simply calls showNormalIfMinimized(true) for use in SLOT() macro */ @@ -196,6 +243,12 @@ private slots: void updateMintingIcon(); /** Update minting weight info */ void updateMintingWeights(); + void charityClicked(QString addr = ""); + /** Load external QSS stylesheet */ + void changeTheme(QString theme); + void loadTheme(QString theme); + void listThemes(QStringList& themes); + void keyPressEvent(QKeyEvent * e); }; #endif diff --git a/src/qt/bitcoinunits.cpp b/src/qt/bitcoinunits.cpp index 5137a80cf..9349ccb44 100644 --- a/src/qt/bitcoinunits.cpp +++ b/src/qt/bitcoinunits.cpp @@ -112,6 +112,32 @@ QString BitcoinUnits::format(int unit, qint64 n, bool fPlus) return quotient_str + QString(".") + remainder_str; } +QString BitcoinUnits::formatAge(int unit, qint64 n, bool fPlus) +{ + // Note: not using straight sprintf here because we do NOT want + // localized number formatting. + if(!valid(unit)) + return QString(); // Refuse to format invalid unit + qint64 coin = factor(unit); + int num_decimals = decimals(unit); + qint64 n_abs = (n > 0 ? n : -n); + qint64 quotient = n_abs / coin; + qint64 remainder = n_abs % coin; + QString quotient_str = QString::number(quotient); + QString remainder_str = QString::number(remainder).rightJustified(num_decimals, '0'); + + // Right-trim excess zeros after the decimal point + int nTrim = 4; + + remainder_str.chop(nTrim); + + if (n < 0) + quotient_str.insert(0, '-'); + else if (fPlus && n > 0) + quotient_str.insert(0, '+'); + return quotient_str + QString(".") + remainder_str; +} + QString BitcoinUnits::formatWithUnit(int unit, qint64 amount, bool plussign) { return format(unit, amount, plussign) + QString(" ") + name(unit); diff --git a/src/qt/bitcoinunits.h b/src/qt/bitcoinunits.h index 9b7c9e160..78da5a76e 100644 --- a/src/qt/bitcoinunits.h +++ b/src/qt/bitcoinunits.h @@ -42,6 +42,8 @@ class BitcoinUnits: public QAbstractListModel static int decimals(int unit); //! Format as string static QString format(int unit, qint64 amount, bool plussign=false); + //! Format as string + static QString formatAge(int unit, qint64 amount, bool plussign=false); //! Format as string (with unit) static QString formatWithUnit(int unit, qint64 amount, bool plussign=false); //! Parse string to coin amount diff --git a/src/qt/blockbrowser.cpp b/src/qt/blockbrowser.cpp new file mode 100644 index 000000000..1d8fb3bf6 --- /dev/null +++ b/src/qt/blockbrowser.cpp @@ -0,0 +1,313 @@ +#include "blockbrowser.h" +#include "ui_blockbrowser.h" +#include "main.h" +#include "base58.h" +#include "clientmodel.h" +#include "db.h" + +double GetPoSKernelPS(const CBlockIndex* blockindex); +double GetDifficulty(const CBlockIndex* blockindex); +//double GetPoWMHashPS(const CBlockIndex* blockindex); + +using namespace std; + +const CBlockIndex* getBlockIndex(int64 height) +{ + std::string hex = getBlockHash(height); + uint256 hash(hex); + return mapBlockIndex[hash]; +} + +std::string getBlockHash(int64 Height) +{ + if(Height > pindexBest->nHeight) { return ""; } + if(Height < 0) { return ""; } + int64 desiredheight; + desiredheight = Height; + if (desiredheight < 0 || desiredheight > nBestHeight) + return 0; + + CBlock block; + CBlockIndex* pblockindex = mapBlockIndex[hashBestChain]; + while (pblockindex->nHeight > desiredheight) + pblockindex = pblockindex->pprev; + return pblockindex->GetBlockHash().GetHex(); // pblockindex->phashBlock->GetHex(); +} + +int64 getBlockTime(int64 Height) +{ + std::string strHash = getBlockHash(Height); + uint256 hash(strHash); + + if (mapBlockIndex.count(hash) == 0) + return 0; + + CBlockIndex* pblockindex = mapBlockIndex[hash]; + return pblockindex->nTime; +} + +std::string getBlockMerkle(int64 Height) +{ + std::string strHash = getBlockHash(Height); + uint256 hash(strHash); + + if (mapBlockIndex.count(hash) == 0) + return 0; + + CBlock block; + CBlockIndex* pblockindex = mapBlockIndex[hash]; + return pblockindex->hashMerkleRoot.ToString();//.substr(0,10).c_str(); +} + +int64 getBlocknBits(int64 Height) +{ + std::string strHash = getBlockHash(Height); + uint256 hash(strHash); + + if (mapBlockIndex.count(hash) == 0) + return 0; + + CBlock block; + CBlockIndex* pblockindex = mapBlockIndex[hash]; + return pblockindex->nBits; +} + +int64 getBlockNonce(int64 Height) +{ + std::string strHash = getBlockHash(Height); + uint256 hash(strHash); + + if (mapBlockIndex.count(hash) == 0) + return 0; + + CBlock block; + CBlockIndex* pblockindex = mapBlockIndex[hash]; + return pblockindex->nNonce; +} + +double getTxTotalValue(std::string txid) +{ + uint256 hash; + hash.SetHex(txid); + + CTransaction tx; + uint256 hashBlock = 0; + if (!GetTransaction(hash, tx, hashBlock)) + return 0; + + CDataStream ssTx(SER_NETWORK, PROTOCOL_VERSION); + ssTx << tx; + + double value = 0; + double buffer = 0; + for (unsigned int i = 0; i < tx.vout.size(); i++) + { + const CTxOut& txout = tx.vout[i]; + + buffer = value + convertCoins(txout.nValue); + value = buffer; + } + + return value; +} + +double convertCoins(int64 amount) +{ + // Tranz needs to use options model. + return (double)amount / (double)COIN; +} + +std::string getOutputs(std::string txid) +{ + uint256 hash; + hash.SetHex(txid); + + CTransaction tx; + uint256 hashBlock = 0; + if (!GetTransaction(hash, tx, hashBlock)) + return "N/A"; + + std::string str = ""; + for (unsigned int i = (tx.IsCoinStake() ? 1 : 0); i < tx.vout.size(); i++) + { + const CTxOut& txout = tx.vout[i]; + + CTxDestination address; + if (!ExtractDestination(txout.scriptPubKey, address) ) + address = CNoDestination(); + + double buffer = convertCoins(txout.nValue); + std::string amount = boost::to_string(buffer); + str.append(CBitcoinAddress(address).ToString()); + str.append(": "); + str.append(amount); + str.append(" HYP"); + str.append("\n"); + } + + return str; +} + +std::string getInputs(std::string txid) +{ + uint256 hash; + hash.SetHex(txid); + + CTransaction tx; + uint256 hashBlock = 0; + if (!GetTransaction(hash, tx, hashBlock)) + return "N/A"; + + std::string str = ""; + for (unsigned int i = 0; i < tx.vin.size(); i++) + { + uint256 hash; + const CTxIn& vin = tx.vin[i]; + + hash.SetHex(vin.prevout.hash.ToString()); + CTransaction wtxPrev; + uint256 hashBlock = 0; + if (!GetTransaction(hash, wtxPrev, hashBlock)) + return "N/A"; + + CTxDestination address; + if (!ExtractDestination(wtxPrev.vout[vin.prevout.n].scriptPubKey, address) ) + address = CNoDestination(); + + double buffer = convertCoins(wtxPrev.vout[vin.prevout.n].nValue); + std::string amount = boost::to_string(buffer); + str.append(CBitcoinAddress(address).ToString()); + str.append(": "); + str.append(amount); + str.append(" HYP"); + str.append("\n"); + } + + return str; +} + +double BlockBrowser::getTxFees(std::string txid) +{ + uint256 hash; + hash.SetHex(txid); + + CTransaction tx; + uint256 hashBlock = 0; + CTxDB txdb("r"); + + if (!GetTransaction(hash, tx, hashBlock)) + return convertCoins(MIN_TX_FEE); + + MapPrevTx mapInputs; + map mapUnused; + bool fInvalid; + + if (!tx.FetchInputs(txdb, mapUnused, false, false, mapInputs, fInvalid)) + return convertCoins(MIN_TX_FEE); + + int64 nTxFees = tx.GetValueIn(mapInputs)-tx.GetValueOut(); + + if(tx.IsCoinStake() || tx.IsCoinBase()) { + ui->feesLabel->setText(QString("Reward")); + nTxFees *= -1; + } + else + ui->feesLabel->setText(QString("Fees")); + + return convertCoins(nTxFees); +} + + +BlockBrowser::BlockBrowser(QWidget *parent) : + QDialog(parent, (Qt::WindowMinMaxButtonsHint|Qt::WindowCloseButtonHint)), + ui(new Ui::BlockBrowser) +{ + ui->setupUi(this); + + setBaseSize(850, 500); + + connect(ui->blockButton, SIGNAL(pressed()), this, SLOT(blockClicked())); + connect(ui->txButton, SIGNAL(pressed()), this, SLOT(txClicked())); + connect(ui->closeButton, SIGNAL(pressed()), this, SLOT(close())); +} + +void BlockBrowser::updateExplorer(bool block) +{ + if(block) + { + int64 height = ui->heightBox->value(); + if (height > pindexBest->nHeight) + { + ui->heightBox->setValue(pindexBest->nHeight); + height = pindexBest->nHeight; + } + + const CBlockIndex* pindex = getBlockIndex(height); + + ui->heightLabelBE1->setText(QString::number(height)); + ui->hashBox->setText(QString::fromUtf8(getBlockHash(height).c_str())); + ui->merkleBox->setText(QString::fromUtf8(getBlockMerkle(height).c_str())); + ui->bitsBox->setText(QString::number(getBlocknBits(height))); + ui->nonceBox->setText(QString::number(getBlockNonce(height))); + ui->timeBox->setText(QString::fromUtf8(DateTimeStrFormat(getBlockTime(height)).c_str())); + ui->diffBox->setText(QString::number(GetDifficulty(pindex), 'f', 6)); + if (pindex->IsProofOfStake()) { + ui->hashRateLabel->setText("Block Network Stake Weight:"); + ui->diffLabel->setText("PoS Block Difficulty:"); + ui->hashRateBox->setText(QString::number(GetPoSKernelPS(pindex), 'f', 3) + " "); + } + else { + ui->hashRateLabel->setText("Block Hash Rate:"); + ui->diffLabel->setText("PoW Block Difficulty:"); + //ui->hashRateBox->setText(QString::number(GetPoWMHashPS(pindex), 'f', 3) + " MH/s"); + } + } + else { + std::string txid = ui->txBox->text().toUtf8().constData(); + + ui->valueBox->setText(QString::number(getTxTotalValue(txid), 'f', 6) + " HYP"); + ui->txID->setText(QString::fromUtf8(txid.c_str())); + ui->outputBox->setText(QString::fromUtf8(getOutputs(txid).c_str())); + ui->inputBox->setText(QString::fromUtf8(getInputs(txid).c_str())); + ui->feesBox->setText(QString::number(getTxFees(txid), 'f', 6) + " HYP"); + } +} + +void BlockBrowser::setTransactionId(const QString &transactionId) +{ + ui->txBox->setText(transactionId); + ui->txBox->setFocus(); + updateExplorer(false); + + uint256 hash; + hash.SetHex(transactionId.toStdString()); + + CTransaction tx; + uint256 hashBlock = 0; + if (GetTransaction(hash, tx, hashBlock)) + { + CBlockIndex* pblockindex = mapBlockIndex[hashBlock]; + ui->heightBox->setValue(pblockindex->nHeight); + updateExplorer(true); + } +} + +void BlockBrowser::txClicked() +{ + updateExplorer(false); +} + +void BlockBrowser::blockClicked() +{ + updateExplorer(true); +} + +void BlockBrowser::setModel(ClientModel *model) +{ + this->model = model; +} + +BlockBrowser::~BlockBrowser() +{ + delete ui; +} \ No newline at end of file diff --git a/src/qt/blockbrowser.h b/src/qt/blockbrowser.h new file mode 100644 index 000000000..5d603648f --- /dev/null +++ b/src/qt/blockbrowser.h @@ -0,0 +1,55 @@ +#ifndef BLOCKBROWSER_H +#define BLOCKBROWSER_H + +#include "clientmodel.h" +#include "main.h" + +#include + +namespace Ui { +class BlockBrowser; +} +class ClientModel; + +class BlockBrowser : public QDialog +{ + Q_OBJECT + +public: + explicit BlockBrowser(QWidget *parent = 0); + ~BlockBrowser(); + + void setTransactionId(const QString &transactionId); + void setModel(ClientModel *model); + + +public slots: + + void blockClicked(); + void txClicked(); + void updateExplorer(bool); + double getTxFees(std::string); + + +private slots: + +private: + Ui::BlockBrowser *ui; + ClientModel *model; + +}; + +double getTxTotalValue(std::string); +double convertCoins(int64); +int64 getBlockTime(int64); +int64 getBlocknBits(int64); +int64 getBlockNonce(int64); +int64 getBlockHashrate(int64); +std::string getInputs(std::string); +std::string getOutputs(std::string); +std::string getBlockHash(int64); +std::string getBlockMerkle(int64); +bool addnode(std::string); +const CBlockIndex* getBlockIndex(int64); + +#endif // BLOCKBROWSER_H \ No newline at end of file diff --git a/src/qt/calcdialog.cpp b/src/qt/calcdialog.cpp new file mode 100644 index 000000000..f72a3827e --- /dev/null +++ b/src/qt/calcdialog.cpp @@ -0,0 +1,72 @@ +#include "calcdialog.h" +#include "ui_calcdialog.h" + +#include "main.h" +#include + +calcDialog::calcDialog(QWidget *parent) : + QDialog(parent), + ui(new Ui::calcDialog) +{ + ui->setupUi(this); + + connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(pushButtonClicked())); +} + +calcDialog::~calcDialog() +{ + delete ui; +} + +void calcDialog::setModel(ClientModel *model) +{ + +} + + +void calcDialog::pushButtonClicked() +{ + QLocale us(QLocale::English, QLocale::UnitedStates); + CBigNum bnMedianWeight = GetMedianWeightOverPeriod(1000); + qint64 nMedianWeight = bnMedianWeight.getint(); + + //set network text even if user amount is not valid + QString strAvgSize = QString("The median weight staked over the last 1,000 blocks is ") + us.toString(bnMedianWeight.getuint()); + ui->avgWeightResult->setText(strAvgSize); + + if(ui->blockSizeEdit->text().isEmpty()) + return; + + int nTargetDays = ui->comboBoxTargetDays->currentText().toInt(); + QString strUserSize = ui->blockSizeEdit->text(); + int nUserAmount = strUserSize.toInt(); + + //less than median weight + if(nUserAmount * nTargetDays < nMedianWeight) + { + qint64 nUserWeightAtTarget = nUserAmount * nTargetDays; + ui->avgWeightResult->setText(strAvgSize + QString(" It is recommended that you do not split your HYP. %1 HYP will yield a weight of %2 on day %3, which is %4 less weight than the median weight staked in the last 1,000 blocks.") + .arg(us.toString(nUserAmount)) + .arg(us.toString(nUserWeightAtTarget)) + .arg(us.toString(nTargetDays)) + .arg(us.toString(bnMedianWeight.getuint64() - nUserWeightAtTarget)) + ); + return; + } + + int nSplitCount = nUserAmount * nTargetDays / nMedianWeight; + int nRecommendedSize = nUserAmount / nSplitCount; + qint64 nUserWeightAtTarget = nRecommendedSize * nTargetDays; + ui->avgWeightResult->setText(strAvgSize + QString(" It is recommended that you split your %1 HYP into %2 outputs of %3 HYP. This will yield a weight of %4 on day %5.") + .arg(us.toString(nUserAmount)) + .arg(us.toString(nSplitCount)) + .arg(us.toString(nRecommendedSize)) + .arg(us.toString(nUserWeightAtTarget)) + .arg(us.toString(nTargetDays)) + ); +} + +void calcDialog::on_buttonBox_accepted() +{ + close(); +} diff --git a/src/qt/calcdialog.h b/src/qt/calcdialog.h new file mode 100644 index 000000000..def39e6e4 --- /dev/null +++ b/src/qt/calcdialog.h @@ -0,0 +1,28 @@ +#ifndef CALCDIALOG_H +#define CALCDIALOG_H + +#include + +namespace Ui { +class calcDialog; +} +class ClientModel; + +class calcDialog : public QDialog +{ + Q_OBJECT + +public: + explicit calcDialog(QWidget *parent = 0); + ~calcDialog(); + + void setModel(ClientModel *model); +private slots: + void on_buttonBox_accepted(); + void pushButtonClicked(); + +private: + Ui::calcDialog *ui; +}; + +#endif // CALCDIALOG_H \ No newline at end of file diff --git a/src/qt/charitydialog.cpp b/src/qt/charitydialog.cpp new file mode 100644 index 000000000..d9f7ba67c --- /dev/null +++ b/src/qt/charitydialog.cpp @@ -0,0 +1,208 @@ +#include "charitydialog.h" +#include "ui_charitydialog.h" + +#include "walletmodel.h" +#include "base58.h" +#include "addressbookpage.h" +#include "init.h" + +#include +#include + +#include + +using namespace std; +using namespace boost; + +StakeForCharityDialog::StakeForCharityDialog(QWidget *parent) : + QWidget(parent), + ui(new Ui::StakeForCharityDialog), + model(0) +{ + ui->setupUi(this); +} + +StakeForCharityDialog::~StakeForCharityDialog() +{ + delete ui; +} + +void StakeForCharityDialog::setModel(WalletModel *model) +{ + this->model = model; +} + +void StakeForCharityDialog::setAddress(const QString &address) +{ + setAddress(address, ui->charityAddressEdit); +} + +void StakeForCharityDialog::setAddress(const QString &address, QLineEdit *addrEdit) +{ + addrEdit->setText(address); + addrEdit->setFocus(); +} + +void StakeForCharityDialog::on_addressBookButton_clicked() +{ + if (model && model->getAddressTableModel()) + { + AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::SendingTab, this); + dlg.setModel(model->getAddressTableModel()); + if (dlg.exec()) + setAddress(dlg.getReturnValue(), ui->charityAddressEdit); + } +} + +void StakeForCharityDialog::on_viewButton_clicked() +{ + std::pair pMultiSend; + std::string strMultiSendPrint = ""; + if(pwalletMain->fMultiSend) + strMultiSendPrint += "MultiSend Active\n"; + else + strMultiSendPrint += "MultiSend Not Active\n"; + + for(int i = 0; i < (int)pwalletMain->vMultiSend.size(); i++) + { + pMultiSend = pwalletMain->vMultiSend[i]; + strMultiSendPrint += pMultiSend.first.c_str(); + strMultiSendPrint += " - "; + strMultiSendPrint += boost::lexical_cast(pMultiSend.second); + strMultiSendPrint += "% \n"; + } + + ui->message->setProperty("status", "ok"); + ui->message->style()->polish(ui->message); + ui->message->setText(QString(strMultiSendPrint.c_str())); + return; +} + + +void StakeForCharityDialog::on_addButton_clicked() +{ + bool fValidConversion = false; + + std::string strAddress = ui->charityAddressEdit->text().toStdString(); + if (!CBitcoinAddress(strAddress).IsValid()) + { + ui->message->setProperty("status", "error"); + ui->message->style()->polish(ui->message); + ui->message->setText(tr("The entered address:\n") + ui->charityAddressEdit->text() + tr(" is invalid.\nPlease check the address and try again.")); + ui->charityAddressEdit->setFocus(); + return; + } + + + int nCharityPercent = ui->charityPercentEdit->text().toInt(&fValidConversion, 10); + int nSumMultiSend = 0; + for(int i = 0; i < (int)pwalletMain->vMultiSend.size(); i++) + nSumMultiSend += pwalletMain->vMultiSend[i].second; + + if(nSumMultiSend + nCharityPercent > 100) + { + ui->message->setProperty("status", "error"); + ui->message->style()->polish(ui->message); + ui->message->setText(tr("The total amount of your MultiSend vector is over 100% of your stake reward\n")); + ui->charityAddressEdit->setFocus(); + return; + } + if (!fValidConversion || nCharityPercent > 100 || nCharityPercent <= 0) + { + ui->message->setProperty("status", "error"); + ui->message->style()->polish(ui->message); + ui->message->setText(tr("Please Enter 1 - 100 for percent.")); + ui->charityPercentEdit->setFocus(); + return; + } + + std::pair pMultiSend; + pMultiSend.first = strAddress; + pMultiSend.second = nCharityPercent; + pwalletMain->vMultiSend.push_back(pMultiSend); + + ui->message->setProperty("status", "ok"); + ui->message->style()->polish(ui->message); + + std::string strMultiSendPrint = ""; + for(int i = 0; i < (int)pwalletMain->vMultiSend.size(); i++) + { + pMultiSend = pwalletMain->vMultiSend[i]; + strMultiSendPrint += pMultiSend.first.c_str(); + strMultiSendPrint += " - "; + strMultiSendPrint += boost::lexical_cast(pMultiSend.second); + strMultiSendPrint += "% \n"; + } + CWalletDB walletdb(pwalletMain->strWalletFile); + walletdb.WriteMultiSend(pwalletMain->vMultiSend); + ui->message->setText(tr("MultiSend Vector\n") + QString(strMultiSendPrint.c_str())); + return; +} + +void StakeForCharityDialog::on_deleteButton_clicked() +{ + std::vector > vMultiSendTemp = pwalletMain->vMultiSend; + std::string strAddress = ui->charityAddressEdit->text().toStdString(); + bool fRemoved = false; + for(int i = 0; i < (int)pwalletMain->vMultiSend.size(); i++) + { + if(pwalletMain->vMultiSend[i].first == strAddress) + { + pwalletMain->vMultiSend.erase(pwalletMain->vMultiSend.begin() + i); + fRemoved = true; + } + } + + CWalletDB walletdb(pwalletMain->strWalletFile); + + if(!walletdb.EraseMultiSend(vMultiSendTemp)) + fRemoved = false; + if(!walletdb.WriteMultiSend(pwalletMain->vMultiSend)) + fRemoved = false; + + if(fRemoved) + ui->message->setText(tr("Removed ") + QString(strAddress.c_str())); + else + ui->message->setText(tr("Could not locate address\n")); + return; +} + +void StakeForCharityDialog::on_activateButton_clicked() +{ + std::string strRet = ""; + if(pwalletMain->vMultiSend.size() < 1) + strRet = "Unable to activate MultiSend, check MultiSend vector\n"; + else if(CBitcoinAddress(pwalletMain->vMultiSend[0].first).IsValid()) + { + pwalletMain->fMultiSend = true; + CWalletDB walletdb(pwalletMain->strWalletFile); + if(!walletdb.WriteMSettings(true, pwalletMain->nLastMultiSendHeight)) + strRet = "MultiSend activated but writing settings to DB failed"; + else + strRet = "MultiSend activated"; + } + else + strRet = "First Address Not Valid"; + + ui->message->setProperty("status", "ok"); + ui->message->style()->polish(ui->message); + ui->message->setText(tr(strRet.c_str())); + return; +} + +void StakeForCharityDialog::on_disableButton_clicked() +{ + std::string strRet = ""; + pwalletMain->fMultiSend = false; + CWalletDB walletdb(pwalletMain->strWalletFile); + if(!walletdb.WriteMSettings(false, pwalletMain->nLastMultiSendHeight)) + strRet = "MultiSend deactivated but writing settings to DB failed"; + else + strRet = "MultiSend deactivated"; + + ui->message->setProperty("status", ""); + ui->message->style()->polish(ui->message); + ui->message->setText(tr(strRet.c_str())); + return; +} + diff --git a/src/qt/charitydialog.h b/src/qt/charitydialog.h new file mode 100644 index 000000000..9b19fbcd1 --- /dev/null +++ b/src/qt/charitydialog.h @@ -0,0 +1,36 @@ +#ifndef CHARITYDIALOG_H +#define CHARITYDIALOG_H + +#include + +namespace Ui { +class StakeForCharityDialog; +} +class WalletModel; +class QLineEdit; +class StakeForCharityDialog : public QWidget +{ + Q_OBJECT + +public: + explicit StakeForCharityDialog(QWidget *parent = 0); + ~StakeForCharityDialog(); + + void setModel(WalletModel *model); + void setAddress(const QString &address); + void setAddress(const QString &address, QLineEdit *addrEdit); +private slots: + void on_viewButton_clicked(); + void on_addButton_clicked(); + void on_deleteButton_clicked(); + void on_activateButton_clicked(); + void on_disableButton_clicked(); + void on_addressBookButton_clicked(); + + +private: + Ui::StakeForCharityDialog *ui; + WalletModel *model; +}; + +#endif // CHARITYDIALOG_H diff --git a/src/qt/clientmodel.cpp b/src/qt/clientmodel.cpp index 6ea4f83bc..d1de372c6 100644 --- a/src/qt/clientmodel.cpp +++ b/src/qt/clientmodel.cpp @@ -12,6 +12,7 @@ #include static const int64 nClientStartupTime = GetTime(); +double GetPoSKernelPS(const CBlockIndex* blockindex = NULL); ClientModel::ClientModel(OptionsModel *optionsModel, QObject *parent) : QObject(parent), optionsModel(optionsModel), diff --git a/src/qt/coincontroldialog.cpp b/src/qt/coincontroldialog.cpp index 1a5e40b5b..164f4de44 100644 --- a/src/qt/coincontroldialog.cpp +++ b/src/qt/coincontroldialog.cpp @@ -7,6 +7,7 @@ #include "addresstablemodel.h" #include "optionsmodel.h" #include "coincontrol.h" +#include "bitcoinrpc.h" #include #include @@ -24,9 +25,10 @@ using namespace std; QList CoinControlDialog::payAmounts; CCoinControl* CoinControlDialog::coinControl = new CCoinControl(); +extern int nStakeMaxAge; CoinControlDialog::CoinControlDialog(QWidget *parent) : - QDialog(parent), + QDialog(parent, Qt::WindowMaximizeButtonHint), ui(new Ui::CoinControlDialog), model(0) { @@ -36,9 +38,7 @@ CoinControlDialog::CoinControlDialog(QWidget *parent) : QAction *copyAddressAction = new QAction(tr("Copy address"), this); QAction *copyLabelAction = new QAction(tr("Copy label"), this); QAction *copyAmountAction = new QAction(tr("Copy amount"), this); - copyTransactionHashAction = new QAction(tr("Copy transaction ID"), this); // we need to enable/disable this - //lockAction = new QAction(tr("Lock unspent"), this); // we need to enable/disable this - //unlockAction = new QAction(tr("Unlock unspent"), this); // we need to enable/disable this + copyTransactionHashAction = new QAction(tr("Copy transaction ID"), this); // we need to enable/disable this // context menu contextMenu = new QMenu(); @@ -46,9 +46,6 @@ CoinControlDialog::CoinControlDialog(QWidget *parent) : contextMenu->addAction(copyLabelAction); contextMenu->addAction(copyAmountAction); contextMenu->addAction(copyTransactionHashAction); - //contextMenu->addSeparator(); - //contextMenu->addAction(lockAction); - //contextMenu->addAction(unlockAction); // context menu signals connect(ui->treeWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showMenu(QPoint))); @@ -56,8 +53,6 @@ CoinControlDialog::CoinControlDialog(QWidget *parent) : connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel())); connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount())); connect(copyTransactionHashAction, SIGNAL(triggered()), this, SLOT(copyTransactionHash())); - //connect(lockAction, SIGNAL(triggered()), this, SLOT(lockCoin())); - //connect(unlockAction, SIGNAL(triggered()), this, SLOT(unlockCoin())); // clipboard actions QAction *clipboardQuantityAction = new QAction(tr("Copy quantity"), this); @@ -95,7 +90,11 @@ CoinControlDialog::CoinControlDialog(QWidget *parent) : connect(ui->treeWidget, SIGNAL(itemChanged( QTreeWidgetItem*, int)), this, SLOT(viewItemChanged( QTreeWidgetItem*, int))); // click on header - ui->treeWidget->header()->setClickable(true); + #if QT_VERSION < 0x050000 + ui->treeWidget->header()->setClickable(true); + #else + ui->treeWidget->header()->setSectionsClickable(true); + #endif connect(ui->treeWidget->header(), SIGNAL(sectionClicked(int)), this, SLOT(headerSectionClicked(int))); // ok button @@ -104,14 +103,22 @@ CoinControlDialog::CoinControlDialog(QWidget *parent) : // (un)select all connect(ui->pushButtonSelectAll, SIGNAL(clicked()), this, SLOT(buttonSelectAllClicked())); - ui->treeWidget->setColumnWidth(COLUMN_CHECKBOX, 84); + // custom Coin Control Selection Button (select less than) + connect(ui->pushButtonCustomCC, SIGNAL(clicked()), this, SLOT(customSelectCoins())); + + ui->treeWidget->setColumnWidth(COLUMN_CHECKBOX, 45); ui->treeWidget->setColumnWidth(COLUMN_AMOUNT, 100); - ui->treeWidget->setColumnWidth(COLUMN_CONFIRMATIONS, 100); - ui->treeWidget->setColumnWidth(COLUMN_WEIGHT, 100); - ui->treeWidget->setColumnWidth(COLUMN_LABEL, 170); - ui->treeWidget->setColumnWidth(COLUMN_ADDRESS, 290); + ui->treeWidget->setColumnWidth(COLUMN_CONFIRMATIONS, 85); + ui->treeWidget->setColumnWidth(COLUMN_AGE, 55); + ui->treeWidget->setColumnWidth(COLUMN_POTENTIALSTAKE, 90); + ui->treeWidget->setColumnWidth(COLUMN_TIMEESTIMATE, 110); + ui->treeWidget->setColumnWidth(COLUMN_WEIGHT, 70); + ui->treeWidget->setColumnWidth(COLUMN_LABEL, 85); + ui->treeWidget->setColumnWidth(COLUMN_ADDRESS, 125); ui->treeWidget->setColumnWidth(COLUMN_DATE, 110); ui->treeWidget->setColumnWidth(COLUMN_PRIORITY, 100); + ui->treeWidget->setColumnHidden(COLUMN_AGE_INT64, true); + ui->treeWidget->setColumnHidden(COLUMN_POTENTIALSTAKE_INT64, true); ui->treeWidget->setColumnHidden(COLUMN_TXHASH, true); // store transacton hash in this column, but dont show it ui->treeWidget->setColumnHidden(COLUMN_VOUT_INDEX, true); // store vout index in this column, but dont show it ui->treeWidget->setColumnHidden(COLUMN_AMOUNT_INT64, true); // store amount int64 in this column, but dont show it @@ -119,6 +126,14 @@ CoinControlDialog::CoinControlDialog(QWidget *parent) : // default view is sorted by amount desc sortView(COLUMN_CONFIRMATIONS, Qt::DescendingOrder); + + // combo box to select coin filter + ui->QComboBoxFilterCoins->addItem("< Amount"); + ui->QComboBoxFilterCoins->addItem("> Amount"); + ui->QComboBoxFilterCoins->addItem("< Weight"); + ui->QComboBoxFilterCoins->addItem("> Weight"); + ui->QComboBoxFilterCoins->addItem("> Age"); + ui->QComboBoxFilterCoins->addItem("< Age"); } CoinControlDialog::~CoinControlDialog() @@ -133,7 +148,6 @@ void CoinControlDialog::setModel(WalletModel *model) if(model && model->getOptionsModel() && model->getAddressTableModel()) { updateView(); - //updateLabelLocked(); CoinControlDialog::updateLabels(model, this); } } @@ -163,8 +177,9 @@ void CoinControlDialog::buttonSelectAllClicked() if (ui->treeWidget->topLevelItem(i)->checkState(COLUMN_CHECKBOX) != Qt::Unchecked) { state = Qt::Unchecked; - break; + } + coinControl->UnSelectAll(); } ui->treeWidget->setEnabled(false); for (int i = 0; i < ui->treeWidget->topLevelItemCount(); i++) @@ -174,6 +189,107 @@ void CoinControlDialog::buttonSelectAllClicked() CoinControlDialog::updateLabels(model, this); } +void CoinControlDialog::customSelectCoins() +{ + QString strUserAmount = ui->lineEditCustomCC->text(); + QString strComboText = ui->QComboBoxFilterCoins->currentText(); + + double dUserAmount = QString(strUserAmount).toDouble(); + bool treeMode = ui->radioTreeMode->isChecked(); + + + QFlags flgCheckbox=Qt::ItemIsSelectable | Qt::ItemIsEnabled | Qt::ItemIsUserCheckable; + + map > mapCoins; + model->listCoins(mapCoins); + + BOOST_FOREACH(PAIRTYPE(QString, vector) coins, mapCoins) + { + QTreeWidgetItem *itemWalletAddress = new QTreeWidgetItem(); + + QTreeWidgetItem *itemOutput; + if (treeMode) itemOutput = new QTreeWidgetItem(itemWalletAddress); + else itemOutput = new QTreeWidgetItem(ui->treeWidget); + itemOutput->setFlags(flgCheckbox); + itemOutput->setCheckState(COLUMN_CHECKBOX,Qt::Unchecked); + BOOST_FOREACH(const COutput& out, coins.second) + { + // transaction hash + uint256 txhash = out.tx->GetHash(); + + //Getting the coin amount + double dCoinAmount = out.tx->vout[out.i].nValue; + + //Coin Weight + uint64 nTxWeight = 0; + model->getStakeWeightFromValue(out.tx->GetTxTime(), out.tx->vout[out.i].nValue, nTxWeight); + + //Age + double dAge = (GetTime() - out.tx->GetTxTime()) / (double)(1440 * 60); + + COutPoint outpt(txhash, out.i); + + //selecting the coins + if (strComboText == "< Amount") + { + if (dCoinAmount < dUserAmount * COIN) + { + coinControl->Select(outpt); + itemOutput->setCheckState(COLUMN_CHECKBOX,Qt::Checked); + } + } + else if (strComboText == "> Amount") + { + if (dCoinAmount > dUserAmount * COIN) + { + coinControl->Select(outpt); + itemOutput->setCheckState(COLUMN_CHECKBOX,Qt::Checked); + } + } + else if (strComboText == "< Weight") + { + if (nTxWeight < dUserAmount) + { + coinControl->Select(outpt); + itemOutput->setCheckState(COLUMN_CHECKBOX,Qt::Checked); + } + } + else if (strComboText == "> Weight") + { + if (nTxWeight > dUserAmount) + { + coinControl->Select(outpt); + itemOutput->setCheckState(COLUMN_CHECKBOX,Qt::Checked); + } + } + else if (strComboText == "< Age") + { + if (dAge < dUserAmount) + { + coinControl->Select(outpt); + itemOutput->setCheckState(COLUMN_CHECKBOX,Qt::Checked); + } + } + else if (strComboText == "> Age") + { + if (dAge > dUserAmount) + { + coinControl->Select(outpt); + itemOutput->setCheckState(COLUMN_CHECKBOX,Qt::Checked); + } + } + else + { + coinControl->UnSelect(outpt); + itemOutput->setCheckState(COLUMN_CHECKBOX,Qt::Unchecked); + } + } + } + CoinControlDialog::updateLabels(model, this); + updateView(); +} + + // context menu void CoinControlDialog::showMenu(const QPoint &point) { @@ -186,22 +302,10 @@ void CoinControlDialog::showMenu(const QPoint &point) if (item->text(COLUMN_TXHASH).length() == 64) // transaction hash is 64 characters (this means its a child node, so its not a parent node in tree mode) { copyTransactionHashAction->setEnabled(true); - //if (model->isLockedCoin(uint256(item->text(COLUMN_TXHASH).toStdString()), item->text(COLUMN_VOUT_INDEX).toUInt())) - //{ - // lockAction->setEnabled(false); - // unlockAction->setEnabled(true); - //} - //else - //{ - // lockAction->setEnabled(true); - // unlockAction->setEnabled(false); - //} } else // this means click on parent node in tree mode -> disable all { copyTransactionHashAction->setEnabled(false); - //lockAction->setEnabled(false); - //unlockAction->setEnabled(false); } // show context menu @@ -239,29 +343,6 @@ void CoinControlDialog::copyTransactionHash() QApplication::clipboard()->setText(contextMenuItem->text(COLUMN_TXHASH)); } -// context menu action: lock coin -/*void CoinControlDialog::lockCoin() -{ - if (contextMenuItem->checkState(COLUMN_CHECKBOX) == Qt::Checked) - contextMenuItem->setCheckState(COLUMN_CHECKBOX, Qt::Unchecked); - - COutPoint outpt(uint256(contextMenuItem->text(COLUMN_TXHASH).toStdString()), contextMenuItem->text(COLUMN_VOUT_INDEX).toUInt()); - model->lockCoin(outpt); - contextMenuItem->setDisabled(true); - contextMenuItem->setIcon(COLUMN_CHECKBOX, QIcon(":/icons/lock_closed")); - updateLabelLocked(); -}*/ - -// context menu action: unlock coin -/*void CoinControlDialog::unlockCoin() -{ - COutPoint outpt(uint256(contextMenuItem->text(COLUMN_TXHASH).toStdString()), contextMenuItem->text(COLUMN_VOUT_INDEX).toUInt()); - model->unlockCoin(outpt); - contextMenuItem->setDisabled(false); - contextMenuItem->setIcon(COLUMN_CHECKBOX, QIcon()); - updateLabelLocked(); -}*/ - // copy label "Quantity" to clipboard void CoinControlDialog::clipboardQuantity() { @@ -316,7 +397,7 @@ void CoinControlDialog::sortView(int column, Qt::SortOrder order) sortColumn = column; sortOrder = order; ui->treeWidget->sortItems(column, order); - ui->treeWidget->header()->setSortIndicator((sortColumn == COLUMN_AMOUNT_INT64 ? COLUMN_AMOUNT : (sortColumn == COLUMN_PRIORITY_INT64 ? COLUMN_PRIORITY : sortColumn)), sortOrder); + ui->treeWidget->header()->setSortIndicator((sortColumn == COLUMN_AMOUNT_INT64 ? COLUMN_AMOUNT : (sortColumn == COLUMN_PRIORITY_INT64 ? COLUMN_PRIORITY : (sortColumn == COLUMN_POTENTIALSTAKE_INT64 ? COLUMN_POTENTIALSTAKE :(sortColumn == COLUMN_AGE_INT64 ? COLUMN_AGE : sortColumn)))), sortOrder); } // treeview: clicked on header @@ -330,7 +411,13 @@ void CoinControlDialog::headerSectionClicked(int logicalIndex) { if (logicalIndex == COLUMN_AMOUNT) // sort by amount logicalIndex = COLUMN_AMOUNT_INT64; + + if (logicalIndex == COLUMN_AGE) // sort by age + logicalIndex = COLUMN_AGE_INT64; + if (logicalIndex == COLUMN_POTENTIALSTAKE) // sort by potential stake + logicalIndex = COLUMN_POTENTIALSTAKE_INT64; + if (logicalIndex == COLUMN_PRIORITY) // sort by priority logicalIndex = COLUMN_PRIORITY_INT64; @@ -339,7 +426,7 @@ void CoinControlDialog::headerSectionClicked(int logicalIndex) else { sortColumn = logicalIndex; - sortOrder = ((sortColumn == COLUMN_AMOUNT_INT64 || sortColumn == COLUMN_PRIORITY_INT64 || sortColumn == COLUMN_DATE || sortColumn == COLUMN_CONFIRMATIONS) ? Qt::DescendingOrder : Qt::AscendingOrder); // if amount,date,conf,priority then default => desc, else default => asc + sortOrder = ((sortColumn == COLUMN_AMOUNT_INT64 || sortColumn == COLUMN_PRIORITY_INT64 || sortColumn == COLUMN_DATE || sortColumn == COLUMN_CONFIRMATIONS || sortColumn == COLUMN_AGE_INT64 || sortColumn == COLUMN_POTENTIALSTAKE_INT64) ? Qt::DescendingOrder : Qt::AscendingOrder); // if amount,date,conf,priority then default => desc, else default => asc } sortView(sortColumn, sortOrder); @@ -383,34 +470,21 @@ void CoinControlDialog::viewItemChanged(QTreeWidgetItem* item, int column) // helper function, return human readable label for priority number QString CoinControlDialog::getPriorityLabel(double dPriority) { - if (dPriority > 576000ULL) // at least medium, this number is from AllowFree(), the other thresholds are kinda random + if (dPriority > 57600000ULL) // at least medium, this number is from AllowFree(), the other thresholds are kinda random { - if (dPriority > 5760000000ULL) return tr("highest"); - else if (dPriority > 576000000ULL) return tr("high"); - else if (dPriority > 57600000ULL) return tr("medium-high"); + if (dPriority > 576000000000ULL) return tr("highest"); + else if (dPriority > 57600000000ULL) return tr("high"); + else if (dPriority > 5760000000ULL) return tr("medium-high"); else return tr("medium"); } else { - if (dPriority > 5760ULL) return tr("low-medium"); - else if (dPriority > 58ULL) return tr("low"); + if (dPriority > 576000ULL) return tr("low-medium"); + else if (dPriority > 5760ULL) return tr("low"); else return tr("lowest"); } } -// shows count of locked unspent outputs -/*void CoinControlDialog::updateLabelLocked() -{ - vector vOutpts; - model->listLockedCoins(vOutpts); - if (vOutpts.size() > 0) - { - ui->labelLocked->setText(tr("(%1 locked)").arg(vOutpts.size())); - ui->labelLocked->setVisible(true); - } - else ui->labelLocked->setVisible(false); -}*/ - void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog) { if (!model) return; @@ -486,13 +560,18 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog) sPriorityLabel = CoinControlDialog::getPriorityLabel(dPriority); // Fee - int64 nFee = nTransactionFee * (1 + (int64)nBytes / 1000); - + int64 nFee = nTransactionFee * (1 + (int64)nBytes / 1000); + // Min Fee int64 nMinFee = txDummy.GetMinFee(1, false, GMF_SEND, nBytes); nPayFee = max(nFee, nMinFee); - + //nPayFee = nFee; + if(pwalletMain->fSplitBlock) + { + nPayFee = COIN / 1000; // make the fee more expensive if using splitblock, this avoids having to calc fee based on multiple vouts + } + if (nPayAmount > 0) { nChange = nAmount - nPayFee - nPayAmount; @@ -522,6 +601,9 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog) nAfterFee = 0; } + // send info to wallet model + //model->setAmountSelected(nAfterFee); + // actually update labels int nDisplayUnit = BitcoinUnits::BTC; if (model && model->getOptionsModel()) @@ -557,7 +639,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog) l6->setStyleSheet((dPriority <= 576000) ? "color:red;" : ""); // Priority < "medium" l7->setStyleSheet((fLowOutput) ? "color:red;" : ""); // Low Output = "yes" l8->setStyleSheet((nChange > 0 && nChange < CENT) ? "color:red;" : ""); // Change < 0.01BTC - + // tool tips l5->setToolTip(tr("This label turns red, if the transaction size is bigger than 10000 bytes.\n\n This means a fee of at least %1 per kb is required.\n\n Can vary +/- 1 Byte per input.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CENT))); l6->setToolTip(tr("Transactions with higher priority get more likely into a block.\n\nThis label turns red, if the priority is smaller than \"medium\".\n\n This means a fee of at least %1 per kb is required.").arg(BitcoinUnits::formatWithUnit(nDisplayUnit, CENT))); @@ -623,15 +705,33 @@ void CoinControlDialog::updateView() double dPrioritySum = 0; int nChildren = 0; int nInputSum = 0; - uint64 nTxWeight = 0, nTxWeightSum = 0; + uint64 nDisplayWeight = 0; + uint64 nTxWeightSum = 0; + uint64 nPotentialStakeSum = 0; + uint64 nNetworkWeight = GetPoSKernelPS(); + BOOST_FOREACH(const COutput& out, coins.second) { - int nInputSize = 148; // 180 if uncompressed public key + int nInputSize = 148; // 180 if uncompressed public key nSum += out.tx->vout[out.i].nValue; nChildren++; - model->getStakeWeightFromValue(out.tx->GetTxTime(), out.tx->vout[out.i].nValue, nTxWeight); - nTxWeightSum += nTxWeight; + //calculate weight + uint64 nTxWeight; + model->getStakeWeightFromValue(out.tx->GetTxTime(), out.tx->vout[out.i].nValue, nTxWeight); + + double dStakeAge; + if(fTestNet) + dStakeAge = nStakeMinAge; + else + dStakeAge = nStakeMinAgeV2; + + if ((GetTime() - out.tx->GetTxTime()) < dStakeAge) + nDisplayWeight = 0; + else + nDisplayWeight = nTxWeight; + + nTxWeightSum += nDisplayWeight; QTreeWidgetItem *itemOutput; if (treeMode) itemOutput = new QTreeWidgetItem(itemWalletAddress); @@ -674,11 +774,13 @@ void CoinControlDialog::updateView() } // amount + uint64 nBlockSize = out.tx->vout[out.i].nValue / COIN; itemOutput->setText(COLUMN_AMOUNT, BitcoinUnits::format(nDisplayUnit, out.tx->vout[out.i].nValue)); - itemOutput->setText(COLUMN_AMOUNT_INT64, strPad(QString::number(out.tx->vout[out.i].nValue), 15, " ")); // padding so that sorting works correctly + itemOutput->setText(COLUMN_AMOUNT_INT64, strPad(QString::number(out.tx->vout[out.i].nValue), 15, " ")); // date - itemOutput->setText(COLUMN_DATE, QDateTime::fromTime_t(out.tx->GetTxTime()).toUTC().toString("yy-MM-dd hh:mm")); + int64 nTime = out.tx->GetTxTime(); + itemOutput->setText(COLUMN_DATE, QDateTime::fromTime_t(nTime).toString("yy-MM-dd hh:mm")); // immature PoS reward if (out.tx->IsCoinStake() && out.tx->GetBlocksToMaturity() > 0 && out.tx->GetDepthInMainChain() > 0) { @@ -697,7 +799,32 @@ void CoinControlDialog::updateView() nInputSum += nInputSize; // List Mode Weight - itemOutput->setText(COLUMN_WEIGHT, strPad(QString::number(nTxWeight), 8, " ")); + itemOutput->setText(COLUMN_WEIGHT, strPad(QString::number(nDisplayWeight), 8, " ")); + + // Age + uint64 nAge = (GetTime() - nTime); + itemOutput->setText(COLUMN_AGE, QString::number((double)nAge / 86400, 'f', 2)); + itemOutput->setText(COLUMN_AGE_INT64, QString::number((double)nAge / 86400, 'f', 2)); + + // Potential Stake + double nPotentialStake = min(7.5 / 365 * nBlockSize * nAge / (86400), 1000.0); //min of the max reward or the stake rate + itemOutput->setText(COLUMN_POTENTIALSTAKE, QString::number(nPotentialStake, 'f', 2)); + itemOutput->setText(COLUMN_POTENTIALSTAKE_INT64, strPad(QString::number((int64)nPotentialStake), 16, " ")); + + // Potential Stake Sum for Tree View + nPotentialStakeSum += nPotentialStake * COIN; + + // Estimated Stake Time + nBlockSize = qMax(nBlockSize, uint64(1)); + uint64 nBlockWeight = nTxWeight; + nBlockWeight = qMax(nBlockWeight, (uint64)1); + double nTimeToMaturity = 0; + if (dStakeAge - nAge >= 0 ) + nTimeToMaturity = (dStakeAge - nAge); + double nEstimateTime = 60 * nNetworkWeight / nBlockWeight; // 90 seconds is block target + nEstimateTime = min((nEstimateTime + nTimeToMaturity) / 86400, double(999)); + + itemOutput->setText(COLUMN_TIMEESTIMATE, QString::number(nEstimateTime, 'f', 2)); // transaction hash uint256 txhash = out.tx->GetHash(); @@ -705,16 +832,7 @@ void CoinControlDialog::updateView() // vout index itemOutput->setText(COLUMN_VOUT_INDEX, QString::number(out.i)); - - // disable locked coins - /*if (model->isLockedCoin(txhash, out.i)) - { - COutPoint outpt(txhash, out.i); - coinControl->UnSelect(outpt); // just to be sure - itemOutput->setDisabled(true); - itemOutput->setIcon(COLUMN_CHECKBOX, QIcon(":/icons/lock_closed")); - }*/ - + // set checkbox if (coinControl->IsSelected(txhash, out.i)) itemOutput->setCheckState(COLUMN_CHECKBOX,Qt::Checked); @@ -727,6 +845,8 @@ void CoinControlDialog::updateView() itemWalletAddress->setText(COLUMN_CHECKBOX, "(" + QString::number(nChildren) + ")"); itemWalletAddress->setText(COLUMN_AMOUNT, BitcoinUnits::format(nDisplayUnit, nSum)); itemWalletAddress->setText(COLUMN_AMOUNT_INT64, strPad(QString::number(nSum), 15, " ")); + itemWalletAddress->setText(COLUMN_POTENTIALSTAKE, BitcoinUnits::formatAge(nDisplayUnit, nPotentialStakeSum)); + itemWalletAddress->setText(COLUMN_POTENTIALSTAKE_INT64, strPad(QString::number(nPotentialStakeSum), 20, " ")); itemWalletAddress->setText(COLUMN_PRIORITY, CoinControlDialog::getPriorityLabel(dPrioritySum)); itemWalletAddress->setText(COLUMN_PRIORITY_INT64, strPad(QString::number((int64)dPrioritySum), 20, " ")); @@ -745,5 +865,6 @@ void CoinControlDialog::updateView() // sort view sortView(sortColumn, sortOrder); + //model->setBestAddress(ui->treeWidget->topLevelItem(0)->text(COLUMN_ADDRESS).toStdString()); ui->treeWidget->setEnabled(true); } diff --git a/src/qt/coincontroldialog.h b/src/qt/coincontroldialog.h index befd748f7..dac2ac2f0 100644 --- a/src/qt/coincontroldialog.h +++ b/src/qt/coincontroldialog.h @@ -54,11 +54,16 @@ class CoinControlDialog : public QDialog COLUMN_CHECKBOX, COLUMN_AMOUNT, COLUMN_CONFIRMATIONS, + COLUMN_AGE, + COLUMN_POTENTIALSTAKE, + COLUMN_TIMEESTIMATE, COLUMN_WEIGHT, COLUMN_LABEL, COLUMN_ADDRESS, COLUMN_DATE, COLUMN_PRIORITY, + COLUMN_AGE_INT64, + COLUMN_POTENTIALSTAKE_INT64, COLUMN_TXHASH, COLUMN_VOUT_INDEX, COLUMN_AMOUNT_INT64, @@ -87,6 +92,7 @@ private slots: void headerSectionClicked(int); void buttonBoxClicked(QAbstractButton*); void buttonSelectAllClicked(); + void customSelectCoins(); //void updateLabelLocked(); }; diff --git a/src/qt/createproposaldialog.cpp b/src/qt/createproposaldialog.cpp new file mode 100644 index 000000000..0f0fde106 --- /dev/null +++ b/src/qt/createproposaldialog.cpp @@ -0,0 +1,120 @@ +#include "createproposaldialog.h" +#include "ui_createproposaldialog.h" +#include "init.h" +#include "main.h" +#include "walletmodel.h" +#include "voteproposal.h" +#include "voteobject.h" +#include +#include + +CreateProposalDialog::CreateProposalDialog(QWidget* parent) : + QDialog(parent), + ui(new Ui::CreateProposalDialog) +{ + ui->setupUi(this); + walletModel = nullptr; + Clear(); +} + +CreateProposalDialog::~CreateProposalDialog() +{ + delete ui; +} + +void CreateProposalDialog::SetWalletModel(WalletModel* model) +{ + walletModel = model; +} + +void CreateProposalDialog::on_button_CreateProposal_clicked() +{ + QString strName = ui->lineEdit_Name->text(); + if (!strName.size() || strName.size() > MAX_CHAR_NAME) { + QMessageBox msg; + msg.setText(tr("Name needs to be between 1 and %1 characters long").arg(MAX_CHAR_NAME)); + msg.exec(); + return; + } + + QString strAbstract = ui->lineEdit_Abstract->text(); + if (!strAbstract.size() || strAbstract.size() > MAX_CHAR_ABSTRACT) { + QMessageBox msg; + msg.setText(tr("Abstract needs to be between 1 and %1 characters long").arg(MAX_CHAR_ABSTRACT)); + msg.exec(); + return; + } + + int nStartHeight = ui->lineEdit_StartBlock->text().toInt(); + if (nStartHeight <= nBestHeight || nStartHeight > nBestHeight + MAX_BLOCKS_IN_FUTURE) { + QMessageBox msg; + msg.setText(tr("Start height needs to be greater than current height (%1) and less than %2.").arg(nBestHeight).arg(nStartHeight + MAX_BLOCKS_IN_FUTURE)); + msg.exec(); + return; + } + + int nCheckSpan = ui->lineEdit_Length->text().toInt(); + if (!nCheckSpan || nCheckSpan > MAX_CHECKSPAN) { + QMessageBox msg; + msg.setText(tr("Voting length needs to be between 1 and %1 blocks").arg(MAX_CHECKSPAN)); + msg.exec(); + return; + } + + //Right now only supporting 2 bit votes + int nBitCount = 2; + QString strSize = QString::number(nBitCount); + ui->label_Size_result->setText(strSize); + + //Set bit location in dialog + VoteLocation location; + if (!proposalManager.GetNextLocation(nBitCount, nStartHeight, nCheckSpan, location)) { + QMessageBox msg; + msg.setText(tr("Failed to get next location from the proposal manager")); + msg.exec(); + return; + } + ui->label_Location_result->setText(QString::number(location.nLeastSignificantBit)); + + //Create the actual proposal + this->proposal = new CVoteProposal(strName.toStdString(), nStartHeight, nCheckSpan, strAbstract.toStdString(), location); + + //Set proposal hash in dialog + uint256 hashProposal = proposal->GetHash(); + QString strHash = QString::fromStdString(hashProposal.GetHex()); + ui->label_Hash_result->setText(strHash); + + if (strHash != "") + ui->button_SendProposal->setDisabled(false); +} + +void CreateProposalDialog::on_button_SendProposal_clicked() +{ + uint256 txid; + if (!pwalletMain->SendProposal(*proposal, txid)) { + QMessageBox msg; + msg.setText(tr("Failed to send proposal")); + msg.exec(); + return; + } + + //display dialog showing tx success + QMessageBox msg; + msg.setText(tr("Proposal Sent. TXID: %1").arg(QString::fromStdString(txid.GetHex()))); + msg.exec(); + + Clear(); +} + +void CreateProposalDialog::Clear() +{ + ui->lineEdit_Abstract->clear(); + ui->lineEdit_Length->clear(); + ui->lineEdit_Name->clear(); + ui->lineEdit_StartBlock->clear(); + ui->label_Fee_result->setText(QString::fromStdString(FormatMoney(CVoteProposal::FEE))); + ui->label_Hash_result->setText("(Automatically Generated)"); + ui->label_Location_result->setText("(Automatically Generated)"); + ui->label_Location_result->setText("(Automatically Generated)"); + ui->button_SendProposal->setEnabled(false); +} diff --git a/src/qt/createproposaldialog.h b/src/qt/createproposaldialog.h new file mode 100644 index 000000000..efb395946 --- /dev/null +++ b/src/qt/createproposaldialog.h @@ -0,0 +1,31 @@ +#ifndef CREATEPROPOSALDIALOG_H +#define CREATEPROPOSALDIALOG_H + +#include +#include + +class WalletModel; +class CVoteProposal; + +namespace Ui { +class CreateProposalDialog; +} + +class CreateProposalDialog : public QDialog +{ + Q_OBJECT +public: + CreateProposalDialog(QWidget* parent); + ~CreateProposalDialog(); + void SetWalletModel(WalletModel* model); +private slots: + void on_button_CreateProposal_clicked(); + void on_button_SendProposal_clicked(); +private: + Ui::CreateProposalDialog* ui; + WalletModel* walletModel; + CVoteProposal* proposal; + void Clear(); +}; + +#endif // CREATEPROPOSALDIALOG_H diff --git a/src/qt/forms/addressbookpage.ui b/src/qt/forms/addressbookpage.ui index 9ed6b02f8..efb7f2d6e 100644 --- a/src/qt/forms/addressbookpage.ui +++ b/src/qt/forms/addressbookpage.ui @@ -6,7 +6,7 @@ 0 0 - 760 + 821 380 @@ -55,6 +55,13 @@ + + + + Enable Deletion of Receiving Address - WARNING YOU WILL LOSE KEYS TO ANY COINS AT THE ADDRESS, BACK UP WALLET FIRST! + + + @@ -124,6 +131,20 @@ + + + + Send a percentage of stake to a specified HyperStake address + + + &Stake For Charity + + + + :/icons/send:/icons/send + + + diff --git a/src/qt/forms/askpassphrasedialog.ui b/src/qt/forms/askpassphrasedialog.ui index 5fd8a4a83..25169042a 100644 --- a/src/qt/forms/askpassphrasedialog.ui +++ b/src/qt/forms/askpassphrasedialog.ui @@ -99,22 +99,6 @@ - - - - true - - - Serves to disable trivial use of sendmoney when the OS account is compromised. Provides no real security. - - - For staking only - - - false - - - diff --git a/src/qt/forms/bip38tooldialog.ui b/src/qt/forms/bip38tooldialog.ui new file mode 100644 index 000000000..819ca52bc --- /dev/null +++ b/src/qt/forms/bip38tooldialog.ui @@ -0,0 +1,439 @@ + + + Bip38ToolDialog + + + + 0 + 0 + 700 + 334 + + + + BIP 38 Tool + + + true + + + + + + 1 + + + + &BIP 38 Encrypt + + + + + + Enter a HYP Address that you would like to encrypt using BIP 38. Enter a passphrase in the middle box. Press encrypt to compute the encrypted private key. + + + Qt::PlainText + + + true + + + + + + + 0 + + + + + Address: + + + + + + + The HYP address to encrypt + + + + + + + Choose previously used address + + + + + + + :/icons/address-book:/icons/address-book + + + Alt+A + + + false + + + + + + + Paste address from clipboard + + + + + + + :/icons/editpaste:/icons/editpaste + + + Alt+P + + + false + + + + + + + + + + + Passphrase: + + + + + + + QLineEdit::Password + + + + + + + + + 0 + + + + + Encrypted Key: + + + Qt::PlainText + + + + + + + + true + + + + true + + + + + + + Copy the current signature to the system clipboard + + + + + + + :/icons/editcopy:/icons/editcopy + + + false + + + + + + + + + + + Sign the message to prove you own this HYP address + + + Encrypt &Key + + + + :/icons/edit:/icons/edit + + + false + + + + + + + Reset all sign message fields + + + Clear &All + + + + :/icons/remove:/icons/remove + + + false + + + + + + + Qt::Horizontal + + + + 40 + 48 + + + + + + + + + 75 + true + + + + + + + true + + + + + + + Qt::Horizontal + + + + 40 + 48 + + + + + + + + + + + &BIP 38 Decrypt + + + + + + Enter the BIP 38 encrypted private key. Enter the passphrase in the middle box. Click Decrypt Key to compute the private key. After the key is decrypted, clicking 'Import Address' will add this private key to the wallet. + + + Qt::PlainText + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + + + Encrypted Key: + + + + + + + The BIP38 Encrypted Key + + + + + + + + + + + Passphrase: + + + + + + + QLineEdit::Password + + + + + + + + + + + Decrypt the encrypted key + + + Decrypt &Key + + + + :/icons/transaction_0:/icons/transaction_0 + + + false + + + + + + + Reset all verify message fields + + + Clear &All + + + + :/icons/remove:/icons/remove + + + false + + + + + + + Qt::Horizontal + + + + 40 + 48 + + + + + + + + + 75 + true + + + + + + + true + + + + + + + Qt::Horizontal + + + + 40 + 48 + + + + + + + + + + + + Decrypted Key: + + + + + + + + + + + + + + Import Address + + + + + + + Address: + + + + + + + + + + + + + + + + + QValidatedLineEdit + QLineEdit +
qvalidatedlineedit.h
+
+
+ + + + +
diff --git a/src/qt/forms/blockbrowser.ui b/src/qt/forms/blockbrowser.ui new file mode 100644 index 000000000..0a01d600d --- /dev/null +++ b/src/qt/forms/blockbrowser.ui @@ -0,0 +1,448 @@ + + + BlockBrowser + + + Qt::NonModal + + + true + + + + 0 + 0 + 885 + 471 + + + + + 0 + 0 + + + + + 0 + 0 + + + + false + + + Block Browser + + + + QLayout::SetMaximumSize + + + 21 + + + 10 + + + 10 + + + + + + 854 + 0 + + + + + + + 7 + + + + + + 0 + 0 + + + + + 75 + true + + + + font-weight:bold; + + + Block Browser + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + QLayout::SetDefaultConstraint + + + 7 + + + + + + 0 + 0 + + + + + + + + + + + + + + Block Merkle: + + + + + + + Block Hash: + + + + + + + Fees: + + + + + + + Value out: + + + + + + + + 187 + 0 + + + + 0x0 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + true + + + + 0 + 0 + + + + + 0 + 0 + + + + 0x0 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + 0.00 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + Qt::Vertical + + + + 399 + 13 + + + + + + + + 0 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + 0 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + Outputs: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Inputs: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + Jump to Block + + + + + + + Block nNonce: + + + + + + + Block Difficulty: + + + + + + + 000 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + 0 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + 0 + 0 + + + + 99999999 + + + + + + + 0000 MH/s + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + Block Height: + + + + + + + Transaction ID: + + + + + + + + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + Block nBits: + + + + + + + Decode Transaction + + + + + + + Block Timestamp: + + + + + + + Block Hashrate: + + + + + + + 0 + + + Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse + + + + + + + + + Close + + + + + + + + + + + diff --git a/src/qt/forms/calcdialog.ui b/src/qt/forms/calcdialog.ui new file mode 100644 index 000000000..5d7b00be8 --- /dev/null +++ b/src/qt/forms/calcdialog.ui @@ -0,0 +1,202 @@ + + + calcDialog + + + + 0 + 0 + 406 + 467 + + + + Stake Calculator + + + + + + + 16 + + + + Stake Calculator + + + false + + + Qt::AlignCenter + + + + + + + 1 + + + Calculate optimal stake input sizing based on current network statistics + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + + + + Target Days To Stake: + + + + + + + + 10 + + + + + 15 + + + + + 20 + + + + + 25 + + + + + 30 + + + + + + + + HYP + + + + + + + Amount of HYP to Split + + + + + + + Calculate + + + + + + + + + 1 + + + + + + Qt::AlignJustify|Qt::AlignTop + + + true + + + + + + + Qt::Vertical + + + + 20 + 155 + + + + + + + + Qt::LeftToRight + + + Qt::Horizontal + + + QDialogButtonBox::Ok + + + false + + + + + buttonBox + label + label_2 + verticalLayoutWidget + formLayoutWidget + avgWeightResult + avgWeightResult + verticalSpacer + + + + + buttonBox + accepted() + calcDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + calcDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/qt/forms/charitydialog.ui b/src/qt/forms/charitydialog.ui new file mode 100644 index 000000000..796c2fdf8 --- /dev/null +++ b/src/qt/forms/charitydialog.ui @@ -0,0 +1,241 @@ + + + StakeForCharityDialog + + + Qt::NonModal + + + + 0 + 0 + 652 + 300 + + + + Stake For Charity + + + + + 170 + 120 + 131 + 20 + + + + Enter whole numbers 1 - 100 + + + Enter % to Give (1-100) + + + + + + 170 + 150 + 401 + 21 + + + + + + + Enter Address to Send to + + + + + + 30 + 0 + 451 + 121 + + + + 1 + + + MultiSend allows you to automatically send up to 100% of your stake to a list of other HyperStake address after it matures. +To Add: enter percentage to give and HyperStake address to add to the MultiSend vector. +To Delete: Enter address to delete and press delete. +MultiSend will not be activated unless you have clicked Activate + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop + + + true + + + + + + 240 + 200 + 381 + 91 + + + + + + + + + + 20 + 230 + 91 + 23 + + + + + + + Add to MultiSend Vector + + + Add + + + + + + 120 + 260 + 91 + 23 + + + + Deactivate MultiSend + + + Deactivate + + + + + + 570 + 150 + 28 + 21 + + + + Choose an address from the address book + + + + + + + :/icons/address-book:/icons/address-book + + + Alt+A + + + false + + + + + + 30 + 120 + 121 + 20 + + + + Percentage of stake to send + + + Percentage: + + + + + + 30 + 150 + 111 + 16 + + + + Address to send portion of stake to + + + Address: + + + + + + 120 + 230 + 91 + 23 + + + + + + + Delete Address From MultiSend Vector + + + Delete + + + + + + 20 + 260 + 91 + 23 + + + + Activate MultiSend + + + Activate + + + + + + 60 + 200 + 121 + 23 + + + + + + + View MultiSend Vector + + + View MultiSend + + + + + + + + diff --git a/src/qt/forms/coincontroldialog.ui b/src/qt/forms/coincontroldialog.ui index dbff5ab2a..b8b05644d 100644 --- a/src/qt/forms/coincontroldialog.ui +++ b/src/qt/forms/coincontroldialog.ui @@ -6,7 +6,7 @@ 0 0 - 1000 + 1040 500 @@ -382,7 +382,7 @@ 41 - + 14 @@ -428,6 +428,35 @@
+ + + + Select Coins + + + + + + + + + + true + + + + 0 + 0 + + + + + 50 + 0 + + + + @@ -454,7 +483,7 @@ false - 11 + 16 true @@ -464,53 +493,71 @@ - + Select /** checkbox **/ - Amount + Amount /** amount **/ - - + - Confirmations + Confirmations /** confs **/ Confirmed + + + Age /** age **/ + + - Weight + Potential Stake /** potential stake **/ - - Label + Days to Stake (est.) /** stake time estimate **/ - - Address + Weight /** weight **/ - - Date + Label /** label **/ + + + + + Address /** address **/ - - - - Priority + Date /** date **/ + + + + + Priority /** priority **/ + + + + /** age int 64 invisible **/ + + + + + /** pot stake int 64 invisible **/ + diff --git a/src/qt/forms/createproposaldialog.ui b/src/qt/forms/createproposaldialog.ui new file mode 100644 index 000000000..eb5ae1b68 --- /dev/null +++ b/src/qt/forms/createproposaldialog.ui @@ -0,0 +1,185 @@ + + + CreateProposalDialog + + + + 0 + 0 + 676 + 308 + + + + Proposal Creation + + + + + + + + Proposal Name: + + + + + + + + + + Proposal Abstract: + + + + + + + + + + Starting Block: + + + + + + + + + + Voting Length (blocks): + + + + + + + + + + Proposal Hash: + + + + + + + (Automatically Generated) + + + + + + + Bit Location: + + + + + + + (Automatically Generated) + + + + + + + Bit Size: + + + + + + + (Automatically Generated) + + + + + + + Fee: + + + + + + + (Automatically Generated) + + + + + + + + + + + Create Proposal + + + + + + + false + + + Send Proposal + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + CreateProposalDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + CreateProposalDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/qt/forms/overviewpage.ui b/src/qt/forms/overviewpage.ui index 8831b85e2..5792e7055 100644 --- a/src/qt/forms/overviewpage.ui +++ b/src/qt/forms/overviewpage.ui @@ -1,7 +1,9 @@ OverviewPage + + 0 @@ -72,6 +74,9 @@ + + + @@ -232,7 +237,7 @@ - + diff --git a/src/qt/forms/proposalsdialog.ui b/src/qt/forms/proposalsdialog.ui new file mode 100644 index 000000000..f7b8c0851 --- /dev/null +++ b/src/qt/forms/proposalsdialog.ui @@ -0,0 +1,147 @@ + + + ProposalsDialog + + + + 0 + 0 + 733 + 420 + + + + Vote Proposals + + + + + + + + QAbstractItemView::NoEditTriggers + + + true + + + true + + + + + + + 0 + + + + + Active + + + true + + + + + + + Upcoming + + + true + + + + + + + Finished + + + true + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 100 + 20 + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + ProposalsDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + ProposalsDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/qt/forms/sendcoinsdialog.ui b/src/qt/forms/sendcoinsdialog.ui index 74d488d3c..03e49763d 100644 --- a/src/qt/forms/sendcoinsdialog.ui +++ b/src/qt/forms/sendcoinsdialog.ui @@ -173,16 +173,7 @@ - - 0 - - - 0 - - - 0 - - + 0 @@ -459,6 +450,9 @@ + + QFormLayout::AllNonFixedFieldsGrow + 10 @@ -515,7 +509,7 @@ font-weight:bold; - Change + Change: @@ -549,7 +543,7 @@ - + 12 @@ -562,10 +556,69 @@ 5 + + + + SplitBlock + + + + + + + false + + + + 0 + 0 + + + + + 100 + 16777215 + + + + + + + + false + + + + 75 + true + + + + Block Size: + + + + + + + false + + + 0.00 HYP + + + + + + + Return Change + + + - custom change address + Custom Change Address @@ -634,21 +687,12 @@ 0 0 - 828 - 162 + 830 + 158 - - 0 - - - 0 - - - 0 - - + 0 diff --git a/src/qt/forms/setvotesdialog.ui b/src/qt/forms/setvotesdialog.ui new file mode 100644 index 000000000..ca6a3f51d --- /dev/null +++ b/src/qt/forms/setvotesdialog.ui @@ -0,0 +1,162 @@ + + + SetVotesDialog + + + + 0 + 0 + 692 + 222 + + + + Set Votes + + + + + + + + Transaction ID (TxID): + + + + + + + + + + Your vote: + + + + + + + + Abstain + + + + + Yes + + + + + No + + + + + Request proposal revision + + + + + + + + Submit Vote + + + + + + + Qt::Vertical + + + + 20 + 18 + + + + + + + + + + + + + 50 + false + + + + Your votes on proposals: + + + + + + + QAbstractItemView::NoEditTriggers + + + true + + + true + + + false + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + + + buttonBox + accepted() + SetVotesDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + SetVotesDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/qt/forms/ui_bip38tooldialog.h b/src/qt/forms/ui_bip38tooldialog.h new file mode 100644 index 000000000..9eaf1eb65 --- /dev/null +++ b/src/qt/forms/ui_bip38tooldialog.h @@ -0,0 +1,412 @@ +/******************************************************************************** +** Form generated from reading UI file 'bip38tooldialog.ui' +** +** Created by: Qt User Interface Compiler version 5.5.1 +** +** WARNING! All changes made in this file will be lost when recompiling UI file! +********************************************************************************/ + +#ifndef UI_BIP38TOOLDIALOG_H +#define UI_BIP38TOOLDIALOG_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "qvalidatedlineedit.h" + +QT_BEGIN_NAMESPACE + +class Ui_Bip38ToolDialog +{ +public: + QVBoxLayout *verticalLayout; + QTabWidget *tabWidget; + QWidget *tabBip38Encrypt; + QVBoxLayout *verticalLayout_SM; + QLabel *infoLabel_ENC; + QHBoxLayout *horizontalLayout_1_ENC; + QLabel *label_5; + QValidatedLineEdit *addressIn_ENC; + QPushButton *addressBookButton_ENC; + QPushButton *pasteButton_ENC; + QHBoxLayout *horizontalLayout_5; + QLabel *label_6; + QLineEdit *passphraseIn_ENC; + QHBoxLayout *horizontalLayout_2_ENC; + QLabel *encryptedKeyLabel_ENC; + QLineEdit *encryptedKeyOut_ENC; + QPushButton *copyKeyButton_ENC; + QHBoxLayout *horizontalLayout_3_ENC; + QPushButton *encryptKeyButton_ENC; + QPushButton *clearButton_ENC; + QSpacerItem *horizontalSpacer_1_ENC; + QLabel *statusLabel_ENC; + QSpacerItem *horizontalSpacer_2_ENC; + QWidget *tabBip38Decrypt; + QVBoxLayout *verticalLayout_VM; + QLabel *infoLabel_DEC; + QHBoxLayout *horizontalLayout_3; + QLabel *label_2; + QValidatedLineEdit *encryptedKeyIn_DEC; + QHBoxLayout *horizontalLayout; + QLabel *label; + QLineEdit *passphraseIn_DEC; + QHBoxLayout *horizontalLayout_2_DEC; + QPushButton *decryptKeyButton_DEC; + QPushButton *clearButton_DEC; + QSpacerItem *horizontalSpacer_1_DEC; + QLabel *statusLabel_DEC; + QSpacerItem *horizontalSpacer_2_DEC; + QHBoxLayout *horizontalLayout_2; + QLabel *label_3; + QValidatedLineEdit *decryptedKeyOut_DEC; + QHBoxLayout *horizontalLayout_4; + QPushButton *importAddressButton_DEC; + QLabel *label_4; + QLineEdit *addressOut_DEC; + + void setupUi(QDialog *Bip38ToolDialog) + { + if (Bip38ToolDialog->objectName().isEmpty()) + Bip38ToolDialog->setObjectName(QStringLiteral("Bip38ToolDialog")); + Bip38ToolDialog->resize(700, 334); + Bip38ToolDialog->setModal(true); + verticalLayout = new QVBoxLayout(Bip38ToolDialog); + verticalLayout->setObjectName(QStringLiteral("verticalLayout")); + tabWidget = new QTabWidget(Bip38ToolDialog); + tabWidget->setObjectName(QStringLiteral("tabWidget")); + tabBip38Encrypt = new QWidget(); + tabBip38Encrypt->setObjectName(QStringLiteral("tabBip38Encrypt")); + verticalLayout_SM = new QVBoxLayout(tabBip38Encrypt); + verticalLayout_SM->setObjectName(QStringLiteral("verticalLayout_SM")); + infoLabel_ENC = new QLabel(tabBip38Encrypt); + infoLabel_ENC->setObjectName(QStringLiteral("infoLabel_ENC")); + infoLabel_ENC->setTextFormat(Qt::PlainText); + infoLabel_ENC->setWordWrap(true); + + verticalLayout_SM->addWidget(infoLabel_ENC); + + horizontalLayout_1_ENC = new QHBoxLayout(); + horizontalLayout_1_ENC->setSpacing(0); + horizontalLayout_1_ENC->setObjectName(QStringLiteral("horizontalLayout_1_ENC")); + label_5 = new QLabel(tabBip38Encrypt); + label_5->setObjectName(QStringLiteral("label_5")); + + horizontalLayout_1_ENC->addWidget(label_5); + + addressIn_ENC = new QValidatedLineEdit(tabBip38Encrypt); + addressIn_ENC->setObjectName(QStringLiteral("addressIn_ENC")); + + horizontalLayout_1_ENC->addWidget(addressIn_ENC); + + addressBookButton_ENC = new QPushButton(tabBip38Encrypt); + addressBookButton_ENC->setObjectName(QStringLiteral("addressBookButton_ENC")); + QIcon icon; + icon.addFile(QStringLiteral(":/icons/address-book"), QSize(), QIcon::Normal, QIcon::Off); + addressBookButton_ENC->setIcon(icon); + addressBookButton_ENC->setAutoDefault(false); + + horizontalLayout_1_ENC->addWidget(addressBookButton_ENC); + + pasteButton_ENC = new QPushButton(tabBip38Encrypt); + pasteButton_ENC->setObjectName(QStringLiteral("pasteButton_ENC")); + QIcon icon1; + icon1.addFile(QStringLiteral(":/icons/editpaste"), QSize(), QIcon::Normal, QIcon::Off); + pasteButton_ENC->setIcon(icon1); + pasteButton_ENC->setAutoDefault(false); + + horizontalLayout_1_ENC->addWidget(pasteButton_ENC); + + + verticalLayout_SM->addLayout(horizontalLayout_1_ENC); + + horizontalLayout_5 = new QHBoxLayout(); + horizontalLayout_5->setObjectName(QStringLiteral("horizontalLayout_5")); + label_6 = new QLabel(tabBip38Encrypt); + label_6->setObjectName(QStringLiteral("label_6")); + + horizontalLayout_5->addWidget(label_6); + + passphraseIn_ENC = new QLineEdit(tabBip38Encrypt); + passphraseIn_ENC->setObjectName(QStringLiteral("passphraseIn_ENC")); + passphraseIn_ENC->setEchoMode(QLineEdit::Password); + + horizontalLayout_5->addWidget(passphraseIn_ENC); + + + verticalLayout_SM->addLayout(horizontalLayout_5); + + horizontalLayout_2_ENC = new QHBoxLayout(); + horizontalLayout_2_ENC->setSpacing(0); + horizontalLayout_2_ENC->setObjectName(QStringLiteral("horizontalLayout_2_ENC")); + encryptedKeyLabel_ENC = new QLabel(tabBip38Encrypt); + encryptedKeyLabel_ENC->setObjectName(QStringLiteral("encryptedKeyLabel_ENC")); + encryptedKeyLabel_ENC->setTextFormat(Qt::PlainText); + + horizontalLayout_2_ENC->addWidget(encryptedKeyLabel_ENC); + + encryptedKeyOut_ENC = new QLineEdit(tabBip38Encrypt); + encryptedKeyOut_ENC->setObjectName(QStringLiteral("encryptedKeyOut_ENC")); + QFont font; + font.setItalic(true); + encryptedKeyOut_ENC->setFont(font); + encryptedKeyOut_ENC->setReadOnly(true); + + horizontalLayout_2_ENC->addWidget(encryptedKeyOut_ENC); + + copyKeyButton_ENC = new QPushButton(tabBip38Encrypt); + copyKeyButton_ENC->setObjectName(QStringLiteral("copyKeyButton_ENC")); + QIcon icon2; + icon2.addFile(QStringLiteral(":/icons/editcopy"), QSize(), QIcon::Normal, QIcon::Off); + copyKeyButton_ENC->setIcon(icon2); + copyKeyButton_ENC->setAutoDefault(false); + + horizontalLayout_2_ENC->addWidget(copyKeyButton_ENC); + + + verticalLayout_SM->addLayout(horizontalLayout_2_ENC); + + horizontalLayout_3_ENC = new QHBoxLayout(); + horizontalLayout_3_ENC->setObjectName(QStringLiteral("horizontalLayout_3_ENC")); + encryptKeyButton_ENC = new QPushButton(tabBip38Encrypt); + encryptKeyButton_ENC->setObjectName(QStringLiteral("encryptKeyButton_ENC")); + QIcon icon3; + icon3.addFile(QStringLiteral(":/icons/edit"), QSize(), QIcon::Normal, QIcon::Off); + encryptKeyButton_ENC->setIcon(icon3); + encryptKeyButton_ENC->setAutoDefault(false); + + horizontalLayout_3_ENC->addWidget(encryptKeyButton_ENC); + + clearButton_ENC = new QPushButton(tabBip38Encrypt); + clearButton_ENC->setObjectName(QStringLiteral("clearButton_ENC")); + QIcon icon4; + icon4.addFile(QStringLiteral(":/icons/remove"), QSize(), QIcon::Normal, QIcon::Off); + clearButton_ENC->setIcon(icon4); + clearButton_ENC->setAutoDefault(false); + + horizontalLayout_3_ENC->addWidget(clearButton_ENC); + + horizontalSpacer_1_ENC = new QSpacerItem(40, 48, QSizePolicy::Expanding, QSizePolicy::Minimum); + + horizontalLayout_3_ENC->addItem(horizontalSpacer_1_ENC); + + statusLabel_ENC = new QLabel(tabBip38Encrypt); + statusLabel_ENC->setObjectName(QStringLiteral("statusLabel_ENC")); + QFont font1; + font1.setBold(true); + font1.setWeight(75); + statusLabel_ENC->setFont(font1); + statusLabel_ENC->setWordWrap(true); + + horizontalLayout_3_ENC->addWidget(statusLabel_ENC); + + horizontalSpacer_2_ENC = new QSpacerItem(40, 48, QSizePolicy::Expanding, QSizePolicy::Minimum); + + horizontalLayout_3_ENC->addItem(horizontalSpacer_2_ENC); + + + verticalLayout_SM->addLayout(horizontalLayout_3_ENC); + + tabWidget->addTab(tabBip38Encrypt, QString()); + tabBip38Decrypt = new QWidget(); + tabBip38Decrypt->setObjectName(QStringLiteral("tabBip38Decrypt")); + verticalLayout_VM = new QVBoxLayout(tabBip38Decrypt); + verticalLayout_VM->setObjectName(QStringLiteral("verticalLayout_VM")); + infoLabel_DEC = new QLabel(tabBip38Decrypt); + infoLabel_DEC->setObjectName(QStringLiteral("infoLabel_DEC")); + infoLabel_DEC->setTextFormat(Qt::PlainText); + infoLabel_DEC->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop); + infoLabel_DEC->setWordWrap(true); + + verticalLayout_VM->addWidget(infoLabel_DEC); + + horizontalLayout_3 = new QHBoxLayout(); + horizontalLayout_3->setObjectName(QStringLiteral("horizontalLayout_3")); + label_2 = new QLabel(tabBip38Decrypt); + label_2->setObjectName(QStringLiteral("label_2")); + + horizontalLayout_3->addWidget(label_2); + + encryptedKeyIn_DEC = new QValidatedLineEdit(tabBip38Decrypt); + encryptedKeyIn_DEC->setObjectName(QStringLiteral("encryptedKeyIn_DEC")); + + horizontalLayout_3->addWidget(encryptedKeyIn_DEC); + + + verticalLayout_VM->addLayout(horizontalLayout_3); + + horizontalLayout = new QHBoxLayout(); + horizontalLayout->setObjectName(QStringLiteral("horizontalLayout")); + label = new QLabel(tabBip38Decrypt); + label->setObjectName(QStringLiteral("label")); + + horizontalLayout->addWidget(label); + + passphraseIn_DEC = new QLineEdit(tabBip38Decrypt); + passphraseIn_DEC->setObjectName(QStringLiteral("passphraseIn_DEC")); + passphraseIn_DEC->setEchoMode(QLineEdit::Password); + + horizontalLayout->addWidget(passphraseIn_DEC); + + + verticalLayout_VM->addLayout(horizontalLayout); + + horizontalLayout_2_DEC = new QHBoxLayout(); + horizontalLayout_2_DEC->setObjectName(QStringLiteral("horizontalLayout_2_DEC")); + decryptKeyButton_DEC = new QPushButton(tabBip38Decrypt); + decryptKeyButton_DEC->setObjectName(QStringLiteral("decryptKeyButton_DEC")); + QIcon icon5; + icon5.addFile(QStringLiteral(":/icons/transaction_0"), QSize(), QIcon::Normal, QIcon::Off); + decryptKeyButton_DEC->setIcon(icon5); + decryptKeyButton_DEC->setAutoDefault(false); + + horizontalLayout_2_DEC->addWidget(decryptKeyButton_DEC); + + clearButton_DEC = new QPushButton(tabBip38Decrypt); + clearButton_DEC->setObjectName(QStringLiteral("clearButton_DEC")); + clearButton_DEC->setIcon(icon4); + clearButton_DEC->setAutoDefault(false); + + horizontalLayout_2_DEC->addWidget(clearButton_DEC); + + horizontalSpacer_1_DEC = new QSpacerItem(40, 48, QSizePolicy::Expanding, QSizePolicy::Minimum); + + horizontalLayout_2_DEC->addItem(horizontalSpacer_1_DEC); + + statusLabel_DEC = new QLabel(tabBip38Decrypt); + statusLabel_DEC->setObjectName(QStringLiteral("statusLabel_DEC")); + statusLabel_DEC->setFont(font1); + statusLabel_DEC->setWordWrap(true); + + horizontalLayout_2_DEC->addWidget(statusLabel_DEC); + + horizontalSpacer_2_DEC = new QSpacerItem(40, 48, QSizePolicy::Expanding, QSizePolicy::Minimum); + + horizontalLayout_2_DEC->addItem(horizontalSpacer_2_DEC); + + + verticalLayout_VM->addLayout(horizontalLayout_2_DEC); + + horizontalLayout_2 = new QHBoxLayout(); + horizontalLayout_2->setObjectName(QStringLiteral("horizontalLayout_2")); + label_3 = new QLabel(tabBip38Decrypt); + label_3->setObjectName(QStringLiteral("label_3")); + + horizontalLayout_2->addWidget(label_3); + + decryptedKeyOut_DEC = new QValidatedLineEdit(tabBip38Decrypt); + decryptedKeyOut_DEC->setObjectName(QStringLiteral("decryptedKeyOut_DEC")); + + horizontalLayout_2->addWidget(decryptedKeyOut_DEC); + + + verticalLayout_VM->addLayout(horizontalLayout_2); + + horizontalLayout_4 = new QHBoxLayout(); + horizontalLayout_4->setObjectName(QStringLiteral("horizontalLayout_4")); + importAddressButton_DEC = new QPushButton(tabBip38Decrypt); + importAddressButton_DEC->setObjectName(QStringLiteral("importAddressButton_DEC")); + + horizontalLayout_4->addWidget(importAddressButton_DEC); + + label_4 = new QLabel(tabBip38Decrypt); + label_4->setObjectName(QStringLiteral("label_4")); + + horizontalLayout_4->addWidget(label_4); + + addressOut_DEC = new QLineEdit(tabBip38Decrypt); + addressOut_DEC->setObjectName(QStringLiteral("addressOut_DEC")); + + horizontalLayout_4->addWidget(addressOut_DEC); + + + verticalLayout_VM->addLayout(horizontalLayout_4); + + tabWidget->addTab(tabBip38Decrypt, QString()); + + verticalLayout->addWidget(tabWidget); + + + retranslateUi(Bip38ToolDialog); + + tabWidget->setCurrentIndex(1); + + + QMetaObject::connectSlotsByName(Bip38ToolDialog); + } // setupUi + + void retranslateUi(QDialog *Bip38ToolDialog) + { + Bip38ToolDialog->setWindowTitle(QApplication::translate("Bip38ToolDialog", "BIP 38 Tool", 0)); + infoLabel_ENC->setText(QApplication::translate("Bip38ToolDialog", "Enter a HYP Address that you would like to encrypt using BIP 38. Enter a passphrase in the middle box. Press encrypt to compute the encrypted private key.", 0)); + label_5->setText(QApplication::translate("Bip38ToolDialog", "Address:", 0)); +#ifndef QT_NO_TOOLTIP + addressIn_ENC->setToolTip(QApplication::translate("Bip38ToolDialog", "The HYP address to encrypt", 0)); +#endif // QT_NO_TOOLTIP +#ifndef QT_NO_TOOLTIP + addressBookButton_ENC->setToolTip(QApplication::translate("Bip38ToolDialog", "Choose previously used address", 0)); +#endif // QT_NO_TOOLTIP + addressBookButton_ENC->setText(QString()); + addressBookButton_ENC->setShortcut(QApplication::translate("Bip38ToolDialog", "Alt+A", 0)); +#ifndef QT_NO_TOOLTIP + pasteButton_ENC->setToolTip(QApplication::translate("Bip38ToolDialog", "Paste address from clipboard", 0)); +#endif // QT_NO_TOOLTIP + pasteButton_ENC->setText(QString()); + pasteButton_ENC->setShortcut(QApplication::translate("Bip38ToolDialog", "Alt+P", 0)); + label_6->setText(QApplication::translate("Bip38ToolDialog", "Passphrase: ", 0)); + encryptedKeyLabel_ENC->setText(QApplication::translate("Bip38ToolDialog", "Encrypted Key:", 0)); +#ifndef QT_NO_TOOLTIP + copyKeyButton_ENC->setToolTip(QApplication::translate("Bip38ToolDialog", "Copy the current signature to the system clipboard", 0)); +#endif // QT_NO_TOOLTIP + copyKeyButton_ENC->setText(QString()); +#ifndef QT_NO_TOOLTIP + encryptKeyButton_ENC->setToolTip(QApplication::translate("Bip38ToolDialog", "Sign the message to prove you own this HYP address", 0)); +#endif // QT_NO_TOOLTIP + encryptKeyButton_ENC->setText(QApplication::translate("Bip38ToolDialog", "Encrypt &Key", 0)); +#ifndef QT_NO_TOOLTIP + clearButton_ENC->setToolTip(QApplication::translate("Bip38ToolDialog", "Reset all sign message fields", 0)); +#endif // QT_NO_TOOLTIP + clearButton_ENC->setText(QApplication::translate("Bip38ToolDialog", "Clear &All", 0)); + statusLabel_ENC->setText(QString()); + tabWidget->setTabText(tabWidget->indexOf(tabBip38Encrypt), QApplication::translate("Bip38ToolDialog", "&BIP 38 Encrypt", 0)); + infoLabel_DEC->setText(QApplication::translate("Bip38ToolDialog", "Enter the BIP 38 encrypted private key. Enter the passphrase in the middle box. Click Decrypt Key to compute the private key. After the key is decrypted, clicking 'Import Address' will add this private key to the wallet.", 0)); + label_2->setText(QApplication::translate("Bip38ToolDialog", "Encrypted Key:", 0)); +#ifndef QT_NO_TOOLTIP + encryptedKeyIn_DEC->setToolTip(QApplication::translate("Bip38ToolDialog", "The BIP38 Encrypted Key", 0)); +#endif // QT_NO_TOOLTIP + label->setText(QApplication::translate("Bip38ToolDialog", "Passphrase: ", 0)); +#ifndef QT_NO_TOOLTIP + decryptKeyButton_DEC->setToolTip(QApplication::translate("Bip38ToolDialog", "Decrypt the encrypted key", 0)); +#endif // QT_NO_TOOLTIP + decryptKeyButton_DEC->setText(QApplication::translate("Bip38ToolDialog", "Decrypt &Key", 0)); +#ifndef QT_NO_TOOLTIP + clearButton_DEC->setToolTip(QApplication::translate("Bip38ToolDialog", "Reset all verify message fields", 0)); +#endif // QT_NO_TOOLTIP + clearButton_DEC->setText(QApplication::translate("Bip38ToolDialog", "Clear &All", 0)); + statusLabel_DEC->setText(QString()); + label_3->setText(QApplication::translate("Bip38ToolDialog", "Decrypted Key:", 0)); + importAddressButton_DEC->setText(QApplication::translate("Bip38ToolDialog", "Import Address", 0)); + label_4->setText(QApplication::translate("Bip38ToolDialog", "Address:", 0)); + tabWidget->setTabText(tabWidget->indexOf(tabBip38Decrypt), QApplication::translate("Bip38ToolDialog", "&BIP 38 Decrypt", 0)); + } // retranslateUi + +}; + +namespace Ui { + class Bip38ToolDialog: public Ui_Bip38ToolDialog {}; +} // namespace Ui + +QT_END_NAMESPACE + +#endif // UI_BIP38TOOLDIALOG_H diff --git a/src/qt/forms/votingdialog.ui b/src/qt/forms/votingdialog.ui new file mode 100644 index 000000000..60fb785f4 --- /dev/null +++ b/src/qt/forms/votingdialog.ui @@ -0,0 +1,98 @@ + + + VotingDialog + + + + 0 + 0 + 194 + 256 + + + + HyperStake Voting System + + + + + + View Proposals + + + + + + + Create Proposal + + + + + + + Set Voting Preferences + + + + + + + Qt::Vertical + + + + 20 + 103 + + + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + + + + + buttonBox + accepted() + VotingDialog + accept() + + + 248 + 254 + + + 157 + 274 + + + + + buttonBox + rejected() + VotingDialog + reject() + + + 316 + 260 + + + 286 + 274 + + + + + diff --git a/src/qt/guiconstants.h b/src/qt/guiconstants.h index 405ba396b..1c8630091 100644 --- a/src/qt/guiconstants.h +++ b/src/qt/guiconstants.h @@ -2,16 +2,15 @@ #define GUICONSTANTS_H /* Milliseconds between model updates */ -static const int MODEL_UPDATE_DELAY = 500; +static const int MODEL_UPDATE_DELAY = 2000; //update every 5 seconds +static const int MINTING_UPDATE_DELAY = 5000; //update every 5 seconds +static const int TXTABLE_UPDATE_DELAY = 30000; //update every 30 seconds /* AskPassphraseDialog -- Maximum passphrase length */ static const int MAX_PASSPHRASE_SIZE = 1024; /* BitcoinGUI -- Size of icons in status bar */ -static const int STATUSBAR_ICONSIZE = 16; - -/* Invalid field background style */ -#define STYLE_INVALID "background:#FF8080" +static const int STATUSBAR_ICONSIZE = 32; /* Transaction list -- unconfirmed transaction */ #define COLOR_UNCONFIRMED QColor(128, 128, 128) @@ -31,4 +30,7 @@ static const int MAX_URI_LENGTH = 255; /* QRCodeDialog -- size of exported QR Code image */ #define EXPORT_IMAGE_SIZE 256 +#define QAPP_APP_NAME_DEFAULT "HyperStake-Qt" +#define QAPP_APP_NAME_TESTNET "HyperStake-Qt-testnet" + #endif // GUICONSTANTS_H diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index ff52bb706..1ba98afe7 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -10,7 +10,11 @@ #include #include #include +#if QT_VERSION >= 0x050000 +#include +#else #include +#endif #include // For Qt::escape #include #include @@ -83,7 +87,13 @@ bool parseBitcoinURI(const QUrl &uri, SendCoinsRecipient *out) SendCoinsRecipient rv; rv.address = uri.path(); rv.amount = 0; + #if QT_VERSION < 0x050000 QList > items = uri.queryItems(); + #else + QUrlQuery uriQuery(uri); + QList > items = uriQuery.queryItems(); + #endif + for (QList >::iterator i = items.begin(); i != items.end(); i++) { bool fShouldReturnFalse = false; @@ -136,7 +146,11 @@ bool parseBitcoinURI(QString uri, SendCoinsRecipient *out) QString HtmlEscape(const QString& str, bool fMultiLine) { - QString escaped = Qt::escape(str); + #if QT_VERSION < 0x050000 + QString escaped = Qt::escape(str); + #else + QString escaped = str.toHtmlEscaped(); + #endif if(fMultiLine) { escaped = escaped.replace("\n", "
\n"); @@ -171,8 +185,12 @@ QString getSaveFileName(QWidget *parent, const QString &caption, QString myDir; if(dir.isEmpty()) // Default to user documents location { + #if QT_VERSION < 0x050000 myDir = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation); - } + #else + myDir = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); + #endif + } else { myDir = dir; @@ -453,5 +471,19 @@ void HelpMessageBox::showOrPrint() #endif } +ClickableLabel::ClickableLabel( const QString& text, QWidget * parent ) : QLabel(parent) +{ + this->setText(text); +} + + ClickableLabel::~ClickableLabel() +{ +} + +void ClickableLabel::mouseReleaseEvent ( QMouseEvent * event ) +{ + emit clicked(); +} + } // namespace GUIUtil diff --git a/src/qt/guiutil.h b/src/qt/guiutil.h index db100bdb7..6f294378c 100644 --- a/src/qt/guiutil.h +++ b/src/qt/guiutil.h @@ -4,6 +4,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE class QFont; @@ -12,6 +13,7 @@ class QWidget; class QDateTime; class QUrl; class QAbstractItemView; +class QLabel; QT_END_NAMESPACE class SendCoinsRecipient; @@ -114,6 +116,22 @@ namespace GUIUtil QString coreOptions; QString uiOptions; }; + + class ClickableLabel : public QLabel + { + + Q_OBJECT + + public: + explicit ClickableLabel( const QString& text ="", QWidget * parent = 0 ); + ~ClickableLabel(); + + signals: + void clicked(); + + protected: + void mouseReleaseEvent ( QMouseEvent * event ); + }; } // namespace GUIUtil diff --git a/src/qt/locale/bitcoin_en.qm b/src/qt/locale/bitcoin_en.qm deleted file mode 100644 index 3b7d608a6..000000000 Binary files a/src/qt/locale/bitcoin_en.qm and /dev/null differ diff --git a/src/qt/locale/bitcoin_en.ts b/src/qt/locale/bitcoin_en.ts index debf8a54a..d41519564 100644 --- a/src/qt/locale/bitcoin_en.ts +++ b/src/qt/locale/bitcoin_en.ts @@ -332,7 +332,12 @@ This product includes software developed by the OpenSSL Project for use in the O &Address Book - &Address Book + &Contacts + + + + &Stake For Charity + &S4C @@ -450,7 +455,7 @@ This product includes software developed by the OpenSSL Project for use in the O &Debug window - &Debug window + &Debug diff --git a/src/qt/locale/bitcoin_ru.qm b/src/qt/locale/bitcoin_ru.qm deleted file mode 100644 index bfb472933..000000000 Binary files a/src/qt/locale/bitcoin_ru.qm and /dev/null differ diff --git a/src/qt/macdockiconhandler.h b/src/qt/macdockiconhandler.h index 2092fb26b..89baa725d 100644 --- a/src/qt/macdockiconhandler.h +++ b/src/qt/macdockiconhandler.h @@ -1,11 +1,14 @@ #ifndef MACDOCKICONHANDLER_H #define MACDOCKICONHANDLER_H -#include +#include +#include -class QMenu; +QT_BEGIN_NAMESPACE class QIcon; +class QMenu; class QWidget; +QT_END_NAMESPACE #ifdef __OBJC__ @class DockIconClickEventHandler; @@ -18,12 +21,13 @@ class DockIconClickEventHandler; class MacDockIconHandler : public QObject { Q_OBJECT + public: ~MacDockIconHandler(); QMenu *dockMenu(); void setIcon(const QIcon &icon); - + void setMainWindow(QMainWindow *window); static MacDockIconHandler *instance(); void handleDockIconClickEvent(); @@ -31,14 +35,13 @@ class MacDockIconHandler : public QObject signals: void dockIconClicked(); -public slots: - private: MacDockIconHandler(); DockIconClickEventHandler *m_dockIconClickEventHandler; QWidget *m_dummyWidget; QMenu *m_dockMenu; + QMainWindow *mainWindow; }; #endif // MACDOCKICONCLICKHANDLER_H diff --git a/src/qt/macdockiconhandler.mm b/src/qt/macdockiconhandler.mm index 75684403e..865c60e3d 100644 --- a/src/qt/macdockiconhandler.mm +++ b/src/qt/macdockiconhandler.mm @@ -1,14 +1,17 @@ - #include "macdockiconhandler.h" +#include #include +#include #include -extern void qt_mac_set_dock_menu(QMenu*); - #undef slots #include +#if QT_VERSION < 0x050000 +extern void qt_mac_set_dock_menu(QMenu *); +#endif + @interface DockIconClickEventHandler : NSObject { MacDockIconHandler* dockIconHandler; @@ -38,8 +41,9 @@ - (void)handleDockClickEvent:(NSAppleEventDescriptor*)event withReplyEvent:(NSAp Q_UNUSED(event) Q_UNUSED(replyEvent) - if (dockIconHandler) + if (dockIconHandler) { dockIconHandler->handleDockIconClickEvent(); + } } @end @@ -47,18 +51,26 @@ - (void)handleDockClickEvent:(NSAppleEventDescriptor*)event withReplyEvent:(NSAp MacDockIconHandler::MacDockIconHandler() : QObject() { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - this->m_dockIconClickEventHandler = [[DockIconClickEventHandler alloc] initWithDockIconHandler:this]; + this->m_dockIconClickEventHandler = [[DockIconClickEventHandler alloc] initWithDockIconHandler:this]; this->m_dummyWidget = new QWidget(); this->m_dockMenu = new QMenu(this->m_dummyWidget); + this->setMainWindow(NULL); +#if QT_VERSION < 0x050000 qt_mac_set_dock_menu(this->m_dockMenu); +#endif [pool release]; } +void MacDockIconHandler::setMainWindow(QMainWindow *window) { + this->mainWindow = window; +} + MacDockIconHandler::~MacDockIconHandler() { [this->m_dockIconClickEventHandler release]; delete this->m_dummyWidget; + this->setMainWindow(NULL); } QMenu *MacDockIconHandler::dockMenu() @@ -69,15 +81,29 @@ - (void)handleDockClickEvent:(NSAppleEventDescriptor*)event withReplyEvent:(NSAp void MacDockIconHandler::setIcon(const QIcon &icon) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - NSImage *image; + NSImage *image = nil; if (icon.isNull()) image = [[NSImage imageNamed:@"NSApplicationIcon"] retain]; else { + // generate NSImage from QIcon and use this as dock icon. QSize size = icon.actualSize(QSize(128, 128)); QPixmap pixmap = icon.pixmap(size); - CGImageRef cgImage = pixmap.toMacCGImageRef(); - image = [[NSImage alloc] initWithCGImage:cgImage size:NSZeroSize]; - CFRelease(cgImage); + + // Write image into a R/W buffer from raw pixmap, then save the image. + QBuffer notificationBuffer; + if (!pixmap.isNull() && notificationBuffer.open(QIODevice::ReadWrite)) { + QImageWriter writer(¬ificationBuffer, "PNG"); + if (writer.write(pixmap.toImage())) { + NSData* macImgData = [NSData dataWithBytes:notificationBuffer.buffer().data() + length:notificationBuffer.buffer().size()]; + image = [[NSImage alloc] initWithData:macImgData]; + } + } + + if(!image) { + // if testnet image could not be created, load std. app icon + image = [[NSImage imageNamed:@"NSApplicationIcon"] retain]; + } } [NSApp setApplicationIconImage:image]; @@ -95,5 +121,11 @@ - (void)handleDockClickEvent:(NSAppleEventDescriptor*)event withReplyEvent:(NSAp void MacDockIconHandler::handleDockIconClickEvent() { + if (this->mainWindow) + { + this->mainWindow->activateWindow(); + this->mainWindow->show(); + } + emit this->dockIconClicked(); } diff --git a/src/qt/macnotificationhandler.h b/src/qt/macnotificationhandler.h new file mode 100644 index 000000000..bd66b96b2 --- /dev/null +++ b/src/qt/macnotificationhandler.h @@ -0,0 +1,30 @@ +// Copyright (c) 2011-2013 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_QT_MACNOTIFICATIONHANDLER_H +#define BITCOIN_QT_MACNOTIFICATIONHANDLER_H + +#include + +/** Macintosh-specific notification handler (supports UserNotificationCenter and Growl). + */ +class MacNotificationHandler : public QObject +{ + Q_OBJECT + +public: + /** shows a 10.8+ UserNotification in the UserNotificationCenter + */ + void showNotification(const QString &title, const QString &text); + + /** executes AppleScript */ + void sendAppleScript(const QString &script); + + /** check if OS can handle UserNotifications */ + bool hasUserNotificationCenterSupport(void); + static MacNotificationHandler *instance(); +}; + + +#endif // BITCOIN_QT_MACNOTIFICATIONHANDLER_H diff --git a/src/qt/macnotificationhandler.mm b/src/qt/macnotificationhandler.mm new file mode 100644 index 000000000..6729a48fd --- /dev/null +++ b/src/qt/macnotificationhandler.mm @@ -0,0 +1,91 @@ +// Copyright (c) 2011-2013 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "macnotificationhandler.h" + +#undef slots +#import +#include + +// Add an obj-c category (extension) to return the expected bundle identifier +@implementation NSBundle(returnCorrectIdentifier) +- (NSString *)__bundleIdentifier +{ + if (self == [NSBundle mainBundle]) { + return @"org.hyperstake.HyperStake-Qt"; + } else { + return [self __bundleIdentifier]; + } +} +@end + +void MacNotificationHandler::showNotification(const QString &title, const QString &text) +{ + // check if users OS has support for NSUserNotification + if(this->hasUserNotificationCenterSupport()) { + // okay, seems like 10.8+ + QByteArray utf8 = title.toUtf8(); + char* cString = (char *)utf8.constData(); + NSString *titleMac = [[NSString alloc] initWithUTF8String:cString]; + + utf8 = text.toUtf8(); + cString = (char *)utf8.constData(); + NSString *textMac = [[NSString alloc] initWithUTF8String:cString]; + + // do everything weak linked (because we will keep <10.8 compatibility) + id userNotification = [[NSClassFromString(@"NSUserNotification") alloc] init]; + [userNotification performSelector:@selector(setTitle:) withObject:titleMac]; + [userNotification performSelector:@selector(setInformativeText:) withObject:textMac]; + + id notificationCenterInstance = [NSClassFromString(@"NSUserNotificationCenter") performSelector:@selector(defaultUserNotificationCenter)]; + [notificationCenterInstance performSelector:@selector(deliverNotification:) withObject:userNotification]; + + [titleMac release]; + [textMac release]; + [userNotification release]; + } +} + +// sendAppleScript just take a QString and executes it as apple script +void MacNotificationHandler::sendAppleScript(const QString &script) +{ + QByteArray utf8 = script.toUtf8(); + char* cString = (char *)utf8.constData(); + NSString *scriptApple = [[NSString alloc] initWithUTF8String:cString]; + + NSAppleScript *as = [[NSAppleScript alloc] initWithSource:scriptApple]; + NSDictionary *err = nil; + [as executeAndReturnError:&err]; + [as release]; + [scriptApple release]; +} + +bool MacNotificationHandler::hasUserNotificationCenterSupport(void) +{ + Class possibleClass = NSClassFromString(@"NSUserNotificationCenter"); + + // check if users OS has support for NSUserNotification + if(possibleClass!=nil) { + return true; + } + return false; +} + + +MacNotificationHandler *MacNotificationHandler::instance() +{ + static MacNotificationHandler *s_instance = NULL; + if (!s_instance) { + s_instance = new MacNotificationHandler(); + + Class aPossibleClass = objc_getClass("NSBundle"); + if (aPossibleClass) { + // change NSBundle -bundleIdentifier method to return a correct bundle identifier + // a bundle identifier is required to use OSXs User Notification Center + method_exchangeImplementations(class_getInstanceMethod(aPossibleClass, @selector(bundleIdentifier)), + class_getInstanceMethod(aPossibleClass, @selector(__bundleIdentifier))); + } + } + return s_instance; +} diff --git a/src/qt/networkstyle.cpp b/src/qt/networkstyle.cpp new file mode 100644 index 000000000..9401d3e54 --- /dev/null +++ b/src/qt/networkstyle.cpp @@ -0,0 +1,96 @@ +// Copyright (c) 2014 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "networkstyle.h" + +#include "guiconstants.h" +#include "scicon.h" + +#include + +static const struct { + const char *networkId; + const char *appName; + const int iconColorHueShift; + const int iconColorSaturationReduction; + const char *titleAddText; +} network_styles[] = { + {"main", QAPP_APP_NAME_DEFAULT, 0, 0, ""}, + {"test", QAPP_APP_NAME_TESTNET, 70, 30, QT_TRANSLATE_NOOP("SplashScreen", "[testnet]")} +}; +static const unsigned network_styles_count = sizeof(network_styles)/sizeof(*network_styles); + +// titleAddText needs to be const char* for tr() +NetworkStyle::NetworkStyle(const QString &appName, const int iconColorHueShift, const int iconColorSaturationReduction, const char *titleAddText): + appName(appName), + titleAddText(qApp->translate("SplashScreen", titleAddText)) +{ + // load pixmap + QPixmap pixmap(":/icons/bitcoin"); + + if(iconColorHueShift != 0 && iconColorSaturationReduction != 0) + { + // generate QImage from QPixmap + QImage img = pixmap.toImage(); + + int h,s,l,a; + + // traverse though lines + for(int y=0;y( img.scanLine( y ) ); + + // loop through pixels + for(int x=0;xiconColorSaturationReduction) + { + s -= iconColorSaturationReduction; + } + col.setHsl(h,s,l,a); + + // set the pixel + scL[x] = col.rgba(); + } + } + + //convert back to QPixmap +#if QT_VERSION >= 0x040700 + pixmap.convertFromImage(img); +#else + pixmap = QPixmap::fromImage(img); +#endif + } + + appIcon = QIcon(pixmap); + trayAndWindowIcon = QIcon(pixmap.scaled(QSize(256,256))); +} + +const NetworkStyle *NetworkStyle::instantiate(const QString &networkId) +{ + for (unsigned x=0; x +#include +#include + +/* Coin network-specific GUI style information */ +class NetworkStyle +{ +public: + /** Get style associated with provided BIP70 network id, or 0 if not known */ + static const NetworkStyle *instantiate(const QString &networkId); + + const QString &getAppName() const { return appName; } + const QIcon &getAppIcon() const { return appIcon; } + const QIcon &getTrayAndWindowIcon() const { return trayAndWindowIcon; } + const QString &getTitleAddText() const { return titleAddText; } + +private: + NetworkStyle(const QString &appName, const int iconColorHueShift, const int iconColorSaturationReduction, const char *titleAddText); + + QString appName; + QIcon appIcon; + QIcon trayAndWindowIcon; + QString titleAddText; +}; + +#endif // BITCOIN_QT_NETWORKSTYLE_H diff --git a/src/qt/notificator.cpp b/src/qt/notificator.cpp index 8028190b8..5a564248e 100644 --- a/src/qt/notificator.cpp +++ b/src/qt/notificator.cpp @@ -1,30 +1,39 @@ +// Copyright (c) 2011-2013 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + #include "notificator.h" -#include -#include -#include #include -#include #include -#include +#include +#include #include +#include +#include +#include #include -#include - +#include #ifdef USE_DBUS -#include #include +#include #endif - +// Include ApplicationServices.h after QtDbus to avoid redefinition of check(). +// This affects at least OSX 10.6. See /usr/include/AssertMacros.h for details. +// Note: This could also be worked around using: +// #define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0 #ifdef Q_OS_MAC #include -extern bool qt_mac_execute_apple_script(const QString &script, AEDesc *ret); +#include "macnotificationhandler.h" #endif + +#ifdef USE_DBUS // https://wiki.ubuntu.com/NotificationDevelopmentGuidelines recommends at least 128 const int FREEDESKTOP_NOTIFICATION_ICON_SIZE = 128; +#endif -Notificator::Notificator(const QString &programName, QSystemTrayIcon *trayicon, QWidget *parent): +Notificator::Notificator(const QString &programName, QSystemTrayIcon *trayicon, QWidget *parent) : QObject(parent), parent(parent), programName(programName), @@ -40,26 +49,32 @@ Notificator::Notificator(const QString &programName, QSystemTrayIcon *trayicon, } #ifdef USE_DBUS interface = new QDBusInterface("org.freedesktop.Notifications", - "/org/freedesktop/Notifications", "org.freedesktop.Notifications"); + "/org/freedesktop/Notifications", "org.freedesktop.Notifications"); if(interface->isValid()) { mode = Freedesktop; } #endif #ifdef Q_OS_MAC - // Check if Growl is installed (based on Qt's tray icon implementation) - CFURLRef cfurl; - OSStatus status = LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator, CFSTR("growlTicket"), kLSRolesAll, 0, &cfurl); - if (status != kLSApplicationNotFoundErr) { - CFBundleRef bundle = CFBundleCreate(0, cfurl); - if (CFStringCompare(CFBundleGetIdentifier(bundle), CFSTR("com.Growl.GrowlHelperApp"), kCFCompareCaseInsensitive | kCFCompareBackwards) == kCFCompareEqualTo) { - if (CFStringHasSuffix(CFURLGetString(cfurl), CFSTR("/Growl.app/"))) - mode = Growl13; - else - mode = Growl12; + // check if users OS has support for NSUserNotification + if( MacNotificationHandler::instance()->hasUserNotificationCenterSupport()) { + mode = UserNotificationCenter; + } + else { + // Check if Growl is installed (based on Qt's tray icon implementation) + CFURLRef cfurl; + OSStatus status = LSGetApplicationForInfo(kLSUnknownType, kLSUnknownCreator, CFSTR("growlTicket"), kLSRolesAll, 0, &cfurl); + if (status != kLSApplicationNotFoundErr) { + CFBundleRef bundle = CFBundleCreate(0, cfurl); + if (CFStringCompare(CFBundleGetIdentifier(bundle), CFSTR("com.Growl.GrowlHelperApp"), kCFCompareCaseInsensitive | kCFCompareBackwards) == kCFCompareEqualTo) { + if (CFStringHasSuffix(CFURLGetString(cfurl), CFSTR("/Growl.app/"))) + mode = Growl13; + else + mode = Growl12; + } + CFRelease(cfurl); + CFRelease(bundle); } - CFRelease(cfurl); - CFRelease(bundle); } #endif } @@ -113,7 +128,7 @@ FreedesktopImage::FreedesktopImage(const QImage &img): { // Convert 00xAARRGGBB to RGBA bytewise (endian-independent) format QImage tmp = img.convertToFormat(QImage::Format_ARGB32); - const uint32_t *data = reinterpret_cast(tmp.constBits()); + const uint32_t *data = reinterpret_cast(tmp.bits()); unsigned int num_pixels = width * height; image.resize(num_pixels * BYTES_PER_PIXEL); @@ -269,8 +284,14 @@ void Notificator::notifyGrowl(Class cls, const QString &title, const QString &te quotedTitle.replace("\\", "\\\\").replace("\"", "\\"); quotedText.replace("\\", "\\\\").replace("\"", "\\"); QString growlApp(this->mode == Notificator::Growl13 ? "Growl" : "GrowlHelperApp"); - qt_mac_execute_apple_script(script.arg(notificationApp, quotedTitle, quotedText, notificationIcon, growlApp), 0); + MacNotificationHandler::instance()->sendAppleScript(script.arg(notificationApp, quotedTitle, quotedText, notificationIcon, growlApp)); +} + +void Notificator::notifyMacUserNotificationCenter(Class cls, const QString &title, const QString &text, const QIcon &icon) { + // icon is not supported by the user notification center yet. OSX will use the app icon. + MacNotificationHandler::instance()->showNotification(title, text); } + #endif void Notificator::notify(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout) @@ -286,6 +307,9 @@ void Notificator::notify(Class cls, const QString &title, const QString &text, c notifySystray(cls, title, text, icon, millisTimeout); break; #ifdef Q_OS_MAC + case UserNotificationCenter: + notifyMacUserNotificationCenter(cls, title, text, icon); + break; case Growl12: case Growl13: notifyGrowl(cls, title, text, icon); diff --git a/src/qt/notificator.h b/src/qt/notificator.h index abb47109b..789d9b7e6 100644 --- a/src/qt/notificator.h +++ b/src/qt/notificator.h @@ -1,11 +1,20 @@ -#ifndef NOTIFICATOR_H -#define NOTIFICATOR_H +// Copyright (c) 2011-2013 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_QT_NOTIFICATOR_H +#define BITCOIN_QT_NOTIFICATOR_H + +#if defined(HAVE_CONFIG_H) +#include "bitcoin-config.h" +#endif -#include #include +#include QT_BEGIN_NAMESPACE class QSystemTrayIcon; + #ifdef USE_DBUS class QDBusInterface; #endif @@ -15,23 +24,23 @@ QT_END_NAMESPACE class Notificator: public QObject { Q_OBJECT + public: /** Create a new notificator. @note Ownership of trayIcon is not transferred to this object. */ - Notificator(const QString &programName=QString(), QSystemTrayIcon *trayIcon=0, QWidget *parent=0); + Notificator(const QString &programName, QSystemTrayIcon *trayIcon, QWidget *parent); ~Notificator(); // Message class enum Class { - Information, /**< Informational message */ - Warning, /**< Notify user of potential problem */ - Critical /**< An error occurred */ + Information, /**< Informational message */ + Warning, /**< Notify user of potential problem */ + Critical /**< An error occurred */ }; public slots: - /** Show notification message. @param[in] cls general message class @param[in] title title shown with message @@ -46,11 +55,12 @@ public slots: private: QWidget *parent; enum Mode { - None, /**< Ignore informational notifications, and show a modal pop-up dialog for Critical notifications. */ - Freedesktop, /**< Use DBus org.freedesktop.Notifications */ - QSystemTray, /**< Use QSystemTray::showMessage */ - Growl12, /**< Use the Growl 1.2 notification system (Mac only) */ - Growl13 /**< Use the Growl 1.3 notification system (Mac only) */ + None, /**< Ignore informational notifications, and show a modal pop-up dialog for Critical notifications. */ + Freedesktop, /**< Use DBus org.freedesktop.Notifications */ + QSystemTray, /**< Use QSystemTray::showMessage */ + Growl12, /**< Use the Growl 1.2 notification system (Mac only) */ + Growl13, /**< Use the Growl 1.3 notification system (Mac only) */ + UserNotificationCenter /**< Use the 10.8+ User Notification Center (Mac only) */ }; QString programName; Mode mode; @@ -63,7 +73,8 @@ public slots: void notifySystray(Class cls, const QString &title, const QString &text, const QIcon &icon, int millisTimeout); #ifdef Q_OS_MAC void notifyGrowl(Class cls, const QString &title, const QString &text, const QIcon &icon); + void notifyMacUserNotificationCenter(Class cls, const QString &title, const QString &text, const QIcon &icon); #endif }; -#endif // NOTIFICATOR_H +#endif // BITCOIN_QT_NOTIFICATOR_H diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 5ee26a942..459428cf8 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -237,7 +237,8 @@ void OptionsDialog::handleProxyIpValid(QValidatedLineEdit *object, bool fState) { disableSaveButtons(); object->setValid(fProxyIpValid); - ui->statusLabel->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel->setProperty("error", true); + ui->statusLabel->style()->polish(ui->statusLabel); ui->statusLabel->setText(tr("The supplied proxy address is invalid.")); } } diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index f43a3d554..45394653b 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -46,7 +46,11 @@ class TxViewDelegate : public QAbstractItemDelegate bool confirmed = index.data(TransactionTableModel::ConfirmedRole).toBool(); QVariant value = index.data(Qt::ForegroundRole); QColor foreground = option.palette.color(QPalette::Text); + #if QT_VERSION < 0x050000 if(qVariantCanConvert(value)) + #else + if(value.canConvert()) + #endif { foreground = qvariant_cast(value); } @@ -164,7 +168,7 @@ void OverviewPage::setModel(WalletModel *model) filter->setLimit(NUM_ITEMS); filter->setDynamicSortFilter(true); filter->setSortRole(Qt::EditRole); - filter->sort(TransactionTableModel::Status, Qt::DescendingOrder); + filter->sort(TransactionTableModel::Date, Qt::DescendingOrder); ui->listTransactions->setModel(filter); ui->listTransactions->setModelColumn(TransactionTableModel::ToAddress); diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp new file mode 100644 index 000000000..bdb1b7a70 --- /dev/null +++ b/src/qt/paymentserver.cpp @@ -0,0 +1,165 @@ +// Copyright (c) 2009-2012 The Bitcoin developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include + +#include "paymentserver.h" + +#include "guiconstants.h" +#include "ui_interface.h" +#include "util.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace boost; + +const int BITCOIN_IPC_CONNECT_TIMEOUT = 1000; // milliseconds +const QString BITCOIN_IPC_PREFIX("hyperstake:"); + +// +// Create a name that is unique for: +// testnet / non-testnet +// data directory +// +static QString ipcServerName() +{ + QString name("HyperStakeQt"); + + // Append a simple hash of the datadir + // Note that GetDataDir(true) returns a different path + // for -testnet versus main net + QString ddir(GetDataDir(true).string().c_str()); + name.append(QString::number(qHash(ddir))); + + return name; +} + +// +// This stores payment requests received before +// the main GUI window is up and ready to ask the user +// to send payment. +// +static QStringList savedPaymentRequests; + +// +// Sending to the server is done synchronously, at startup. +// If the server isn't already running, startup continues, +// and the items in savedPaymentRequest will be handled +// when uiReady() is called. +// +bool PaymentServer::ipcSendCommandLine() +{ + bool fResult = false; + + const QStringList& args = qApp->arguments(); + for (int i = 1; i < args.size(); i++) + { + if (!args[i].startsWith(BITCOIN_IPC_PREFIX, Qt::CaseInsensitive)) + continue; + savedPaymentRequests.append(args[i]); + } + + foreach (const QString& arg, savedPaymentRequests) + { + QLocalSocket* socket = new QLocalSocket(); + socket->connectToServer(ipcServerName(), QIODevice::WriteOnly); + if (!socket->waitForConnected(BITCOIN_IPC_CONNECT_TIMEOUT)) + return false; + + QByteArray block; + QDataStream out(&block, QIODevice::WriteOnly); + out.setVersion(QDataStream::Qt_4_0); + out << arg; + out.device()->seek(0); + socket->write(block); + socket->flush(); + + socket->waitForBytesWritten(BITCOIN_IPC_CONNECT_TIMEOUT); + socket->disconnectFromServer(); + delete socket; + fResult = true; + } + return fResult; +} + +PaymentServer::PaymentServer(QApplication* parent) : QObject(parent), saveURIs(true) +{ + // Install global event filter to catch QFileOpenEvents on the mac (sent when you click bitcoin: links) + parent->installEventFilter(this); + + QString name = ipcServerName(); + + // Clean up old socket leftover from a crash: + QLocalServer::removeServer(name); + + uriServer = new QLocalServer(this); + + if (!uriServer->listen(name)) + qDebug() << tr("Cannot start HyperStake: click-to-pay handler"); + else + connect(uriServer, SIGNAL(newConnection()), this, SLOT(handleURIConnection())); +} + +bool PaymentServer::eventFilter(QObject *object, QEvent *event) +{ + // clicking on bitcoin: URLs creates FileOpen events on the Mac: + if (event->type() == QEvent::FileOpen) + { + QFileOpenEvent* fileEvent = static_cast(event); + if (!fileEvent->url().isEmpty()) + { + if (saveURIs) // Before main window is ready: + savedPaymentRequests.append(fileEvent->url().toString()); + else + emit receivedURI(fileEvent->url().toString()); + return true; + } + } + return false; +} + +void PaymentServer::uiReady() +{ + saveURIs = false; + foreach (const QString& s, savedPaymentRequests) + emit receivedURI(s); + savedPaymentRequests.clear(); +} + +void PaymentServer::handleURIConnection() +{ + QLocalSocket *clientConnection = uriServer->nextPendingConnection(); + + while (clientConnection->bytesAvailable() < (int)sizeof(quint32)) + clientConnection->waitForReadyRead(); + + connect(clientConnection, SIGNAL(disconnected()), + clientConnection, SLOT(deleteLater())); + + QDataStream in(clientConnection); + in.setVersion(QDataStream::Qt_4_0); + if (clientConnection->bytesAvailable() < (int)sizeof(quint16)) { + return; + } + QString message; + in >> message; + + if (saveURIs) + savedPaymentRequests.append(message); + else + emit receivedURI(message); +} + +void PaymentServer::setOptionsModel(OptionsModel *optionsModel) +{ + this->optionsModel = optionsModel; +} diff --git a/src/qt/paymentserver.h b/src/qt/paymentserver.h new file mode 100644 index 000000000..0fdee333a --- /dev/null +++ b/src/qt/paymentserver.h @@ -0,0 +1,74 @@ +#ifndef PAYMENTSERVER_H +#define PAYMENTSERVER_H + +// +// This class handles payment requests from clicking on +// bitcoin: URIs +// +// This is somewhat tricky, because we have to deal with +// the situation where the user clicks on a link during +// startup/initialization, when the splash-screen is up +// but the main window (and the Send Coins tab) is not. +// +// So, the strategy is: +// +// Create the server, and register the event handler, +// when the application is created. Save any URIs +// received at or during startup in a list. +// +// When startup is finished and the main window is +// shown, a signal is sent to slot uiReady(), which +// emits a receivedURL() signal for any payment +// requests that happened during startup. +// +// After startup, receivedURL() happens as usual. +// +// This class has one more feature: a static +// method that finds URIs passed in the command line +// and, if a server is running in another process, +// sends them to the server. +// +#include +#include + +class OptionsModel; + +class QApplication; +class QLocalServer; + +class PaymentServer : public QObject +{ + Q_OBJECT +private: + bool saveURIs; + QLocalServer* uriServer; + +public: + // Returns true if there were URIs on the command line + // which were successfully sent to an already-running + // process. + static bool ipcSendCommandLine(); + + PaymentServer(QApplication* parent); + + bool eventFilter(QObject *object, QEvent *event); + + // OptionsModel is used for getting proxy settings and display unit + void setOptionsModel(OptionsModel *optionsModel); + +signals: + void receivedURI(QString); + +public slots: + // Signal this when the main window's UI is ready + // to display payment requests to the user + void uiReady(); + +private slots: + void handleURIConnection(); + +private: + OptionsModel *optionsModel; +}; + +#endif // PAYMENTSERVER_H diff --git a/src/qt/proposalsdialog.cpp b/src/qt/proposalsdialog.cpp new file mode 100644 index 000000000..bd678f032 --- /dev/null +++ b/src/qt/proposalsdialog.cpp @@ -0,0 +1,128 @@ +#include "proposalsdialog.h" +#include "ui_proposalsdialog.h" + +#include "db.h" +#include "main.h" +#include "walletmodel.h" +#include + + +ProposalsDialog::ProposalsDialog(QWidget* parent) : + QDialog(parent), + ui(new Ui::ProposalsDialog) +{ + ui->setupUi(this); +} + +ProposalsDialog::~ProposalsDialog() +{ + delete ui; +} + +void ProposalsDialog::SetWalletModel(WalletModel *model) +{ + this->walletModel = model; + UpdateTable(); +} + +void ProposalsDialog::UpdateTable() +{ + int columns = 12; + int rows = 0; + QStandardItemModel* model = new QStandardItemModel(rows, columns, this); + model->setHorizontalHeaderItem(0, new QStandardItem(QString("Name"))); + model->setHorizontalHeaderItem(1, new QStandardItem(QString("Abstract"))); + model->setHorizontalHeaderItem(2, new QStandardItem(QString("Yes Votes"))); + model->setHorizontalHeaderItem(3, new QStandardItem(QString("No Votes"))); + model->setHorizontalHeaderItem(4, new QStandardItem(QString("Abstain"))); + model->setHorizontalHeaderItem(5, new QStandardItem(QString("Ratio"))); + model->setHorizontalHeaderItem(6, new QStandardItem(QString("TxID"))); + model->setHorizontalHeaderItem(7, new QStandardItem(QString("ID"))); + model->setHorizontalHeaderItem(8, new QStandardItem(QString("Location"))); + model->setHorizontalHeaderItem(9, new QStandardItem(QString("Start Block"))); + model->setHorizontalHeaderItem(10, new QStandardItem(QString("End Block"))); + model->setHorizontalHeaderItem(11, new QStandardItem(QString("Bits"))); + + CVoteDB voteDB("r"); + int i = 0; + for (auto it : mapProposals) { + CVoteProposal proposal; + if (voteDB.ReadProposal(it.first, proposal)) { + //Filters + bool hasStarted = (int)proposal.GetStartHeight() < nBestHeight; + bool isFinished = (int)(proposal.GetStartHeight() + proposal.GetCheckSpan()) < nBestHeight; + bool isActive = hasStarted && !isFinished; + + bool fUpcomingChecked = ui->checkBox_Upcoming->checkState() == Qt::CheckState::Checked; + bool fActiveChecked = ui->checkBox_Active->checkState() == Qt::CheckState::Checked; + bool fFinishedChecked = ui->checkBox_Finished->checkState() == Qt::CheckState::Checked; + + bool fInclude = false; + if (fActiveChecked && isActive) + fInclude = true; + if (!hasStarted && fUpcomingChecked) + fInclude = true; + if (isFinished && fFinishedChecked) + fInclude = true; + if (!fInclude) + continue; + + //Find the current status of the proposal's votes + int nHeightEnd = proposal.GetStartHeight() + proposal.GetCheckSpan(); + int nHeightTally; + if (nHeightEnd < nBestHeight) + nHeightTally = nHeightEnd; + else + nHeightTally = nBestHeight; + + CVoteTally tally = FindBlockByHeight(nHeightTally)->tally; + CVoteSummary summary; + bool fTallySet = true; + if (!tally.GetSummary(proposal.GetHash(), summary)) + fTallySet = false; + QList listItems; + listItems.push_back(new QStandardItem(QString::fromStdString(proposal.GetName()))); + listItems.push_back(new QStandardItem(QString::fromStdString(proposal.GetDescription()))); + if (fTallySet) { + int64_t nBlocksVoted = nHeightTally - summary.nBlockStart; + double nAbstain = nBlocksVoted - summary.nNoTally - summary.nYesTally; + double nRatio = 0; + if (nBlocksVoted) + nRatio = (double)summary.nYesTally / ((double)nBlocksVoted - nAbstain); + listItems.push_back(new QStandardItem(QString::number(summary.nYesTally))); + listItems.push_back(new QStandardItem(QString::number(summary.nNoTally))); + listItems.push_back(new QStandardItem(QString::number(nAbstain))); + listItems.push_back(new QStandardItem(QString::number(nRatio))); + } else { + listItems.push_back(new QStandardItem(QString("n/a"))); + listItems.push_back(new QStandardItem(QString("n/a"))); + listItems.push_back(new QStandardItem(QString("n/a"))); + listItems.push_back(new QStandardItem(QString("n/a"))); + } + listItems.push_back(new QStandardItem(QString::fromStdString(it.first.GetHex()))); + listItems.push_back(new QStandardItem(QString::fromStdString(proposal.GetHash().GetHex()))); + listItems.push_back(new QStandardItem(QString::number(proposal.GetShift()))); + listItems.push_back(new QStandardItem(QString::number(proposal.GetStartHeight()))); + listItems.push_back(new QStandardItem(QString::number(proposal.GetStartHeight() + proposal.GetCheckSpan()))); + listItems.push_back(new QStandardItem(QString::number(proposal.GetBitCount()))); + model->insertRow(i, listItems); + i++; + } + } + ui->tableView->setModel(model); +} + +void ProposalsDialog::on_checkBox_Active_stateChanged(int arg1) +{ + UpdateTable(); +} + +void ProposalsDialog::on_checkBox_Upcoming_stateChanged(int arg1) +{ + UpdateTable(); +} + +void ProposalsDialog::on_checkBox_Finished_stateChanged(int arg1) +{ + UpdateTable(); +} diff --git a/src/qt/proposalsdialog.h b/src/qt/proposalsdialog.h new file mode 100644 index 000000000..da6313742 --- /dev/null +++ b/src/qt/proposalsdialog.h @@ -0,0 +1,31 @@ +#ifndef PROPOSALSDIALOG_H +#define PROPOSALSDIALOG_H + +#include +#include + +class WalletModel; + +namespace Ui { +class ProposalsDialog; +} + +class ProposalsDialog : public QDialog +{ + Q_OBJECT +public: + ProposalsDialog(QWidget *parent = 0); + ~ProposalsDialog(); + void SetWalletModel(WalletModel* model); + void UpdateTable(); +private slots: + void on_checkBox_Active_stateChanged(int arg1); + void on_checkBox_Upcoming_stateChanged(int arg1); + void on_checkBox_Finished_stateChanged(int arg1); + +private: + Ui::ProposalsDialog *ui; + WalletModel* walletModel; +}; + +#endif // PROPOSALSDIALOG_H diff --git a/src/qt/qrcodedialog.cpp b/src/qt/qrcodedialog.cpp index ca9497512..6ddcaaf5d 100644 --- a/src/qt/qrcodedialog.cpp +++ b/src/qt/qrcodedialog.cpp @@ -7,7 +7,9 @@ #include "optionsmodel.h" #include +#if QT_VERSION < 0x050000 #include +#endif #include diff --git a/src/qt/qtipcserver.cpp b/src/qt/qtipcserver.cpp deleted file mode 100644 index b26c37581..000000000 --- a/src/qt/qtipcserver.cpp +++ /dev/null @@ -1,162 +0,0 @@ -// Copyright (c) 2009-2012 The Bitcoin developers -// Distributed under the MIT/X11 software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include -#if defined(WIN32) && BOOST_VERSION == 104900 -#define BOOST_INTERPROCESS_HAS_WINDOWS_KERNEL_BOOTTIME -#define BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME -#endif - -#include "qtipcserver.h" -#include "guiconstants.h" -#include "ui_interface.h" -#include "util.h" - -#include -#include -#include -#include - -#if defined(WIN32) && (!defined(BOOST_INTERPROCESS_HAS_WINDOWS_KERNEL_BOOTTIME) || !defined(BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME) || BOOST_VERSION < 104900) -#warning Compiling without BOOST_INTERPROCESS_HAS_WINDOWS_KERNEL_BOOTTIME and BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME uncommented in boost/interprocess/detail/tmp_dir_helpers.hpp or using a boost version before 1.49 may have unintended results see svn.boost.org/trac/boost/ticket/5392 -#endif - -using namespace boost; -using namespace boost::interprocess; -using namespace boost::posix_time; - -#if defined MAC_OSX || defined __FreeBSD__ -// URI handling not implemented on OSX yet - -void ipcScanRelay(int argc, char *argv[]) { } -void ipcInit(int argc, char *argv[]) { } - -#else - -static void ipcThread2(void* pArg); - -static bool ipcScanCmd(int argc, char *argv[], bool fRelay) -{ - // Check for URI in argv - bool fSent = false; - for (int i = 1; i < argc; i++) - { - if (boost::algorithm::istarts_with(argv[i], "bitcoin:")) - { - const char *strURI = argv[i]; - try { - boost::interprocess::message_queue mq(boost::interprocess::open_only, BITCOINURI_QUEUE_NAME); - if (mq.try_send(strURI, strlen(strURI), 0)) - fSent = true; - else if (fRelay) - break; - } - catch (boost::interprocess::interprocess_exception &ex) { - // don't log the "file not found" exception, because that's normal for - // the first start of the first instance - if (ex.get_error_code() != boost::interprocess::not_found_error || !fRelay) - { - printf("main() - boost interprocess exception #%d: %s\n", ex.get_error_code(), ex.what()); - break; - } - } - } - } - return fSent; -} - -void ipcScanRelay(int argc, char *argv[]) -{ - if (ipcScanCmd(argc, argv, true)) - exit(0); -} - -static void ipcThread(void* pArg) -{ - // Make this thread recognisable as the GUI-IPC thread - RenameThread("bitcoin-gui-ipc"); - - try - { - ipcThread2(pArg); - } - catch (std::exception& e) { - PrintExceptionContinue(&e, "ipcThread()"); - } catch (...) { - PrintExceptionContinue(NULL, "ipcThread()"); - } - printf("ipcThread exited\n"); -} - -static void ipcThread2(void* pArg) -{ - printf("ipcThread started\n"); - - message_queue* mq = (message_queue*)pArg; - char buffer[MAX_URI_LENGTH + 1] = ""; - size_t nSize = 0; - unsigned int nPriority = 0; - - loop - { - ptime d = boost::posix_time::microsec_clock::universal_time() + millisec(100); - if (mq->timed_receive(&buffer, sizeof(buffer), nSize, nPriority, d)) - { - uiInterface.ThreadSafeHandleURI(std::string(buffer, nSize)); - Sleep(1000); - } - - if (fShutdown) - break; - } - - // Remove message queue - message_queue::remove(BITCOINURI_QUEUE_NAME); - // Cleanup allocated memory - delete mq; -} - -void ipcInit(int argc, char *argv[]) -{ - message_queue* mq = NULL; - char buffer[MAX_URI_LENGTH + 1] = ""; - size_t nSize = 0; - unsigned int nPriority = 0; - - try { - mq = new message_queue(open_or_create, BITCOINURI_QUEUE_NAME, 2, MAX_URI_LENGTH); - - // Make sure we don't lose any bitcoin: URIs - for (int i = 0; i < 2; i++) - { - ptime d = boost::posix_time::microsec_clock::universal_time() + millisec(1); - if (mq->timed_receive(&buffer, sizeof(buffer), nSize, nPriority, d)) - { - uiInterface.ThreadSafeHandleURI(std::string(buffer, nSize)); - } - else - break; - } - - // Make sure only one bitcoin instance is listening - message_queue::remove(BITCOINURI_QUEUE_NAME); - delete mq; - - mq = new message_queue(open_or_create, BITCOINURI_QUEUE_NAME, 2, MAX_URI_LENGTH); - } - catch (interprocess_exception &ex) { - printf("ipcInit() - boost interprocess exception #%d: %s\n", ex.get_error_code(), ex.what()); - return; - } - - if (!NewThread(ipcThread, mq)) - { - delete mq; - return; - } - - ipcScanCmd(argc, argv, false); -} - -#endif diff --git a/src/qt/qtipcserver.h b/src/qt/qtipcserver.h deleted file mode 100644 index cccf200b2..000000000 --- a/src/qt/qtipcserver.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef QTIPCSERVER_H -#define QTIPCSERVER_H - -// Define Bitcoin-Qt message queue name -#define BITCOINURI_QUEUE_NAME "BitcoinURI" - -void ipcScanRelay(int argc, char *argv[]); -void ipcInit(int argc, char *argv[]); - -#endif // QTIPCSERVER_H diff --git a/src/qt/qvalidatedlineedit.cpp b/src/qt/qvalidatedlineedit.cpp index 8ca230c9d..87ecd00ac 100644 --- a/src/qt/qvalidatedlineedit.cpp +++ b/src/qt/qvalidatedlineedit.cpp @@ -1,6 +1,5 @@ #include "qvalidatedlineedit.h" - -#include "guiconstants.h" +#include QValidatedLineEdit::QValidatedLineEdit(QWidget *parent) : QLineEdit(parent), valid(true) @@ -17,11 +16,13 @@ void QValidatedLineEdit::setValid(bool valid) if(valid) { - setStyleSheet(""); + setProperty("error", false); + style()->polish(this); } else { - setStyleSheet(STYLE_INVALID); + setProperty("error", true); + style()->polish(this); } this->valid = valid; } diff --git a/src/qt/res/bitcoin-qt.rc b/src/qt/res/bitcoin-qt.rc index 7caf26f84..96c590179 100644 --- a/src/qt/res/bitcoin-qt.rc +++ b/src/qt/res/bitcoin-qt.rc @@ -1,16 +1,12 @@ IDI_ICON1 ICON DISCARDABLE "icons/hyperstake.ico" #include // needed for VERSIONINFO -#include "../../clientversion.h" // holds the needed client version information +//#include "../../clientversion.h" // holds the needed client version information #define VER_PRODUCTVERSION CLIENT_VERSION_MAJOR,CLIENT_VERSION_MINOR,CLIENT_VERSION_REVISION,CLIENT_VERSION_BUILD #define VER_PRODUCTVERSION_STR STRINGIZE(CLIENT_VERSION_MAJOR) "." STRINGIZE(CLIENT_VERSION_MINOR) "." STRINGIZE(CLIENT_VERSION_REVISION) "." STRINGIZE(CLIENT_VERSION_BUILD) -#define VER_FILEVERSION VER_PRODUCTVERSION -#define VER_FILEVERSION_STR VER_PRODUCTVERSION_STR VS_VERSION_INFO VERSIONINFO -FILEVERSION VER_FILEVERSION -PRODUCTVERSION VER_PRODUCTVERSION FILEOS VOS_NT_WINDOWS32 FILETYPE VFT_APP BEGIN @@ -20,13 +16,13 @@ BEGIN BEGIN VALUE "CompanyName", "HyperStake" VALUE "FileDescription", "HyperStake-Qt (OSS GUI client for HyperStake)" - VALUE "FileVersion", VER_FILEVERSION_STR + VALUE "FileVersion", "1.1" VALUE "InternalName", "HyperStake-qt" VALUE "LegalCopyright", "2009-2012 The Bitcoin developers, 2012-2013 The HyperStake & PPCoin developers" VALUE "LegalTrademarks1", "Distributed under the MIT/X11 software license, see the accompanying file COPYING or http://www.opensource.org/licenses/mit-license.php." VALUE "OriginalFilename", "HyperStake-qt.exe" VALUE "ProductName", "HyperStake-Qt" - VALUE "ProductVersion", VER_PRODUCTVERSION_STR + VALUE "ProductVersion", "1.1" END END diff --git a/src/qt/res/icons/Icons.txt b/src/qt/res/icons/Icons.txt new file mode 100644 index 000000000..cbd788d7e --- /dev/null +++ b/src/qt/res/icons/Icons.txt @@ -0,0 +1,5 @@ +http://www.clker.com/clipart-gears.html (public domain) +http://openclipart.org/detail/161695/curved-arrow-by-f_featherbrain (public domain) +http://openclipart.org/detail/17020/icon_arrow_right_green-by-jean_victor_balin (public domain) +http://www.clker.com/clipart-brokenchain.html (public domain) + diff --git a/src/qt/res/icons/add.png b/src/qt/res/icons/add.png index f98e2a8ca..fb8826426 100644 Binary files a/src/qt/res/icons/add.png and b/src/qt/res/icons/add.png differ diff --git a/src/qt/res/icons/add.xcf b/src/qt/res/icons/add.xcf new file mode 100644 index 000000000..63e53280f Binary files /dev/null and b/src/qt/res/icons/add.xcf differ diff --git a/src/qt/res/icons/address-book.png b/src/qt/res/icons/address-book.png index d41dbe653..be51a7866 100644 Binary files a/src/qt/res/icons/address-book.png and b/src/qt/res/icons/address-book.png differ diff --git a/src/qt/res/icons/address-book.xcf b/src/qt/res/icons/address-book.xcf new file mode 100644 index 000000000..232779c35 Binary files /dev/null and b/src/qt/res/icons/address-book.xcf differ diff --git a/src/qt/res/icons/bitcoin.icns b/src/qt/res/icons/bitcoin.icns index e86dc8c7e..8f36f784e 100644 Binary files a/src/qt/res/icons/bitcoin.icns and b/src/qt/res/icons/bitcoin.icns differ diff --git a/src/qt/res/icons/blexp.png b/src/qt/res/icons/blexp.png new file mode 100644 index 000000000..a58e49201 Binary files /dev/null and b/src/qt/res/icons/blexp.png differ diff --git a/src/qt/res/icons/blexp.xcf b/src/qt/res/icons/blexp.xcf new file mode 100644 index 000000000..e98f88038 Binary files /dev/null and b/src/qt/res/icons/blexp.xcf differ diff --git a/src/qt/res/icons/chains.xcf b/src/qt/res/icons/chains.xcf new file mode 100644 index 000000000..45f45b202 Binary files /dev/null and b/src/qt/res/icons/chains.xcf differ diff --git a/src/qt/res/icons/clock1.png b/src/qt/res/icons/clock1.png index 448e47f94..c8a7e2717 100644 Binary files a/src/qt/res/icons/clock1.png and b/src/qt/res/icons/clock1.png differ diff --git a/src/qt/res/icons/clock2.png b/src/qt/res/icons/clock2.png index c1a6e99f7..e657941f5 100644 Binary files a/src/qt/res/icons/clock2.png and b/src/qt/res/icons/clock2.png differ diff --git a/src/qt/res/icons/clock3.png b/src/qt/res/icons/clock3.png index e429a402c..e1ab2dd85 100644 Binary files a/src/qt/res/icons/clock3.png and b/src/qt/res/icons/clock3.png differ diff --git a/src/qt/res/icons/clock4.png b/src/qt/res/icons/clock4.png index ba036f47d..55838e5d3 100644 Binary files a/src/qt/res/icons/clock4.png and b/src/qt/res/icons/clock4.png differ diff --git a/src/qt/res/icons/clock5.png b/src/qt/res/icons/clock5.png index 411d7a78a..871a53793 100644 Binary files a/src/qt/res/icons/clock5.png and b/src/qt/res/icons/clock5.png differ diff --git a/src/qt/res/icons/clock_full.png b/src/qt/res/icons/clock_full.png new file mode 100644 index 000000000..841afe8fa Binary files /dev/null and b/src/qt/res/icons/clock_full.png differ diff --git a/src/qt/res/icons/clocks.xcf b/src/qt/res/icons/clocks.xcf new file mode 100644 index 000000000..59e10cbc9 Binary files /dev/null and b/src/qt/res/icons/clocks.xcf differ diff --git a/src/qt/res/icons/configure.png b/src/qt/res/icons/configure.png index 95bd319ce..000e71615 100644 Binary files a/src/qt/res/icons/configure.png and b/src/qt/res/icons/configure.png differ diff --git a/src/qt/res/icons/configure.xcf b/src/qt/res/icons/configure.xcf new file mode 100644 index 000000000..419fcc7f6 Binary files /dev/null and b/src/qt/res/icons/configure.xcf differ diff --git a/src/qt/res/icons/connect.xcf b/src/qt/res/icons/connect.xcf new file mode 100644 index 000000000..9416137c9 Binary files /dev/null and b/src/qt/res/icons/connect.xcf differ diff --git a/src/qt/res/icons/connect0.png b/src/qt/res/icons/connect0.png new file mode 100644 index 000000000..7389bb62c Binary files /dev/null and b/src/qt/res/icons/connect0.png differ diff --git a/src/qt/res/icons/connect0_16.png b/src/qt/res/icons/connect0_16.png index 66f3ae4f8..0e7fbfd2a 100644 Binary files a/src/qt/res/icons/connect0_16.png and b/src/qt/res/icons/connect0_16.png differ diff --git a/src/qt/res/icons/connect0_161.png b/src/qt/res/icons/connect0_161.png new file mode 100644 index 000000000..66f3ae4f8 Binary files /dev/null and b/src/qt/res/icons/connect0_161.png differ diff --git a/src/qt/res/icons/connect1.png b/src/qt/res/icons/connect1.png new file mode 100644 index 000000000..b20917128 Binary files /dev/null and b/src/qt/res/icons/connect1.png differ diff --git a/src/qt/res/icons/connect1_16.png b/src/qt/res/icons/connect1_16.png index 76000beee..ce822ac18 100644 Binary files a/src/qt/res/icons/connect1_16.png and b/src/qt/res/icons/connect1_16.png differ diff --git a/src/qt/res/icons/connect1_161.png b/src/qt/res/icons/connect1_161.png new file mode 100644 index 000000000..76000beee Binary files /dev/null and b/src/qt/res/icons/connect1_161.png differ diff --git a/src/qt/res/icons/connect2.png b/src/qt/res/icons/connect2.png new file mode 100644 index 000000000..8512a9478 Binary files /dev/null and b/src/qt/res/icons/connect2.png differ diff --git a/src/qt/res/icons/connect2_16.png b/src/qt/res/icons/connect2_16.png index 6d9a37281..2fa4e9d48 100644 Binary files a/src/qt/res/icons/connect2_16.png and b/src/qt/res/icons/connect2_16.png differ diff --git a/src/qt/res/icons/connect2_161.png b/src/qt/res/icons/connect2_161.png new file mode 100644 index 000000000..6d9a37281 Binary files /dev/null and b/src/qt/res/icons/connect2_161.png differ diff --git a/src/qt/res/icons/connect3.png b/src/qt/res/icons/connect3.png new file mode 100644 index 000000000..6ea7b23e6 Binary files /dev/null and b/src/qt/res/icons/connect3.png differ diff --git a/src/qt/res/icons/connect3_16.png b/src/qt/res/icons/connect3_16.png index a21170078..46bc3a6ac 100644 Binary files a/src/qt/res/icons/connect3_16.png and b/src/qt/res/icons/connect3_16.png differ diff --git a/src/qt/res/icons/connect3_161.png b/src/qt/res/icons/connect3_161.png new file mode 100644 index 000000000..a21170078 Binary files /dev/null and b/src/qt/res/icons/connect3_161.png differ diff --git a/src/qt/res/icons/connect4.png b/src/qt/res/icons/connect4.png new file mode 100644 index 000000000..f56d20cdf Binary files /dev/null and b/src/qt/res/icons/connect4.png differ diff --git a/src/qt/res/icons/connect4_16.png b/src/qt/res/icons/connect4_16.png index c1232f568..174370fd0 100644 Binary files a/src/qt/res/icons/connect4_16.png and b/src/qt/res/icons/connect4_16.png differ diff --git a/src/qt/res/icons/connect4_161.png b/src/qt/res/icons/connect4_161.png new file mode 100644 index 000000000..c1232f568 Binary files /dev/null and b/src/qt/res/icons/connect4_161.png differ diff --git a/src/qt/res/icons/debugwindow.png b/src/qt/res/icons/debugwindow.png index 1712adf0e..a27522aad 100644 Binary files a/src/qt/res/icons/debugwindow.png and b/src/qt/res/icons/debugwindow.png differ diff --git a/src/qt/res/icons/debugwindow.xcf b/src/qt/res/icons/debugwindow.xcf new file mode 100644 index 000000000..1b70e06a7 Binary files /dev/null and b/src/qt/res/icons/debugwindow.xcf differ diff --git a/src/qt/res/icons/debugwindow1.png b/src/qt/res/icons/debugwindow1.png new file mode 100644 index 000000000..1712adf0e Binary files /dev/null and b/src/qt/res/icons/debugwindow1.png differ diff --git a/src/qt/res/icons/edit-depth.png b/src/qt/res/icons/edit-depth.png new file mode 100644 index 000000000..8354efb1e Binary files /dev/null and b/src/qt/res/icons/edit-depth.png differ diff --git a/src/qt/res/icons/edit.png b/src/qt/res/icons/edit.png index 1d6914515..adda97696 100644 Binary files a/src/qt/res/icons/edit.png and b/src/qt/res/icons/edit.png differ diff --git a/src/qt/res/icons/edit.xcf b/src/qt/res/icons/edit.xcf new file mode 100644 index 000000000..0a3c35a3f Binary files /dev/null and b/src/qt/res/icons/edit.xcf differ diff --git a/src/qt/res/icons/editcopy.png b/src/qt/res/icons/editcopy.png index f882aa2ad..38c0758d7 100644 Binary files a/src/qt/res/icons/editcopy.png and b/src/qt/res/icons/editcopy.png differ diff --git a/src/qt/res/icons/editcopy.xcf b/src/qt/res/icons/editcopy.xcf new file mode 100644 index 000000000..a3d14773d Binary files /dev/null and b/src/qt/res/icons/editcopy.xcf differ diff --git a/src/qt/res/icons/editcopypaste.xcf b/src/qt/res/icons/editcopypaste.xcf new file mode 100644 index 000000000..ff02214c6 Binary files /dev/null and b/src/qt/res/icons/editcopypaste.xcf differ diff --git a/src/qt/res/icons/editpaste.png b/src/qt/res/icons/editpaste.png index a192060bd..e35e10ea7 100644 Binary files a/src/qt/res/icons/editpaste.png and b/src/qt/res/icons/editpaste.png differ diff --git a/src/qt/res/icons/export.png b/src/qt/res/icons/export.png index 1df9c2398..48f0d5375 100644 Binary files a/src/qt/res/icons/export.png and b/src/qt/res/icons/export.png differ diff --git a/src/qt/res/icons/export.xcf b/src/qt/res/icons/export.xcf new file mode 100644 index 000000000..81bffab83 Binary files /dev/null and b/src/qt/res/icons/export.xcf differ diff --git a/src/qt/res/icons/filesave.png b/src/qt/res/icons/filesave.png index ae13a151d..b79f6655a 100644 Binary files a/src/qt/res/icons/filesave.png and b/src/qt/res/icons/filesave.png differ diff --git a/src/qt/res/icons/history.png b/src/qt/res/icons/history.png index 10ac0e159..bb6f28e0e 100644 Binary files a/src/qt/res/icons/history.png and b/src/qt/res/icons/history.png differ diff --git a/src/qt/res/icons/history.xcf b/src/qt/res/icons/history.xcf new file mode 100644 index 000000000..ff3d7c869 Binary files /dev/null and b/src/qt/res/icons/history.xcf differ diff --git a/src/qt/res/icons/hyperstake.ico b/src/qt/res/icons/hyperstake.ico index 6eee86c9e..8e2f9e4bd 100644 Binary files a/src/qt/res/icons/hyperstake.ico and b/src/qt/res/icons/hyperstake.ico differ diff --git a/src/qt/res/icons/info.png b/src/qt/res/icons/info.png new file mode 100644 index 000000000..afc6b0b92 Binary files /dev/null and b/src/qt/res/icons/info.png differ diff --git a/src/qt/res/icons/key.png b/src/qt/res/icons/key.png index ece0164f7..2d7bfcabe 100644 Binary files a/src/qt/res/icons/key.png and b/src/qt/res/icons/key.png differ diff --git a/src/qt/res/icons/key.xcf b/src/qt/res/icons/key.xcf new file mode 100644 index 000000000..eb9034966 Binary files /dev/null and b/src/qt/res/icons/key.xcf differ diff --git a/src/qt/res/icons/lock-closed.png b/src/qt/res/icons/lock-closed.png new file mode 100644 index 000000000..067e911d8 Binary files /dev/null and b/src/qt/res/icons/lock-closed.png differ diff --git a/src/qt/res/icons/lock-open.png b/src/qt/res/icons/lock-open.png new file mode 100644 index 000000000..7d490d268 Binary files /dev/null and b/src/qt/res/icons/lock-open.png differ diff --git a/src/qt/res/icons/lock-open2.png b/src/qt/res/icons/lock-open2.png new file mode 100644 index 000000000..297e496a6 Binary files /dev/null and b/src/qt/res/icons/lock-open2.png differ diff --git a/src/qt/res/icons/lock.xcf b/src/qt/res/icons/lock.xcf new file mode 100644 index 000000000..f5336d3a6 Binary files /dev/null and b/src/qt/res/icons/lock.xcf differ diff --git a/src/qt/res/icons/lock_closed.png b/src/qt/res/icons/lock_closed.png index c566510c4..bce778a5a 100644 Binary files a/src/qt/res/icons/lock_closed.png and b/src/qt/res/icons/lock_closed.png differ diff --git a/src/qt/res/icons/lock_closed_2.png b/src/qt/res/icons/lock_closed_2.png new file mode 100644 index 000000000..dacdc1127 Binary files /dev/null and b/src/qt/res/icons/lock_closed_2.png differ diff --git a/src/qt/res/icons/lock_open.png b/src/qt/res/icons/lock_open.png index c98ca8663..364b334d0 100644 Binary files a/src/qt/res/icons/lock_open.png and b/src/qt/res/icons/lock_open.png differ diff --git a/src/qt/res/icons/lock_open2.png b/src/qt/res/icons/lock_open2.png new file mode 100644 index 000000000..6054442e7 Binary files /dev/null and b/src/qt/res/icons/lock_open2.png differ diff --git a/src/qt/res/icons/lock_open_2.png b/src/qt/res/icons/lock_open_2.png new file mode 100644 index 000000000..d04b388d2 Binary files /dev/null and b/src/qt/res/icons/lock_open_2.png differ diff --git a/src/qt/res/icons/mining.png b/src/qt/res/icons/mining.png index e888f3f95..132858ce8 100644 Binary files a/src/qt/res/icons/mining.png and b/src/qt/res/icons/mining.png differ diff --git a/src/qt/res/icons/mining.xcf b/src/qt/res/icons/mining.xcf new file mode 100644 index 000000000..58089ba87 Binary files /dev/null and b/src/qt/res/icons/mining.xcf differ diff --git a/src/qt/res/icons/mining1.png b/src/qt/res/icons/mining1.png new file mode 100644 index 000000000..e888f3f95 Binary files /dev/null and b/src/qt/res/icons/mining1.png differ diff --git a/src/qt/res/icons/mining_active.png b/src/qt/res/icons/mining_active.png index d3b81f11d..132858ce8 100644 Binary files a/src/qt/res/icons/mining_active.png and b/src/qt/res/icons/mining_active.png differ diff --git a/src/qt/res/icons/mining_active2.png b/src/qt/res/icons/mining_active2.png new file mode 100644 index 000000000..f2818780d Binary files /dev/null and b/src/qt/res/icons/mining_active2.png differ diff --git a/src/qt/res/icons/mining_active3.png b/src/qt/res/icons/mining_active3.png new file mode 100644 index 000000000..bf0748eae Binary files /dev/null and b/src/qt/res/icons/mining_active3.png differ diff --git a/src/qt/res/icons/mining_active4.png b/src/qt/res/icons/mining_active4.png new file mode 100644 index 000000000..82809b32b Binary files /dev/null and b/src/qt/res/icons/mining_active4.png differ diff --git a/src/qt/res/icons/mining_inactive.png b/src/qt/res/icons/mining_inactive.png index 347d36fb1..32c092c0f 100644 Binary files a/src/qt/res/icons/mining_inactive.png and b/src/qt/res/icons/mining_inactive.png differ diff --git a/src/qt/res/icons/notsynced.png b/src/qt/res/icons/notsynced.png index c9e71184c..8c5101506 100644 Binary files a/src/qt/res/icons/notsynced.png and b/src/qt/res/icons/notsynced.png differ diff --git a/src/qt/res/icons/notsynced.xcf b/src/qt/res/icons/notsynced.xcf new file mode 100644 index 000000000..6db3e1e84 Binary files /dev/null and b/src/qt/res/icons/notsynced.xcf differ diff --git a/src/qt/res/icons/notsynced1.png b/src/qt/res/icons/notsynced1.png new file mode 100644 index 000000000..c9e71184c Binary files /dev/null and b/src/qt/res/icons/notsynced1.png differ diff --git a/src/qt/res/icons/notsynced2.png b/src/qt/res/icons/notsynced2.png new file mode 100644 index 000000000..ab5f20ffd Binary files /dev/null and b/src/qt/res/icons/notsynced2.png differ diff --git a/src/qt/res/icons/overview.png b/src/qt/res/icons/overview.png index ccbe49787..b65257221 100644 Binary files a/src/qt/res/icons/overview.png and b/src/qt/res/icons/overview.png differ diff --git a/src/qt/res/icons/overview.xcf b/src/qt/res/icons/overview.xcf new file mode 100644 index 000000000..2617c8ab8 Binary files /dev/null and b/src/qt/res/icons/overview.xcf differ diff --git a/src/qt/res/icons/qrcode.png b/src/qt/res/icons/qrcode.png index a8d97174b..cc24c08c7 100644 Binary files a/src/qt/res/icons/qrcode.png and b/src/qt/res/icons/qrcode.png differ diff --git a/src/qt/res/icons/qrcode.xcf b/src/qt/res/icons/qrcode.xcf new file mode 100644 index 000000000..ca047db4b Binary files /dev/null and b/src/qt/res/icons/qrcode.xcf differ diff --git a/src/qt/res/icons/qrcode1.png b/src/qt/res/icons/qrcode1.png new file mode 100644 index 000000000..a8d97174b Binary files /dev/null and b/src/qt/res/icons/qrcode1.png differ diff --git a/src/qt/res/icons/quit.png b/src/qt/res/icons/quit.png index 0dde6f395..62960eaa0 100644 Binary files a/src/qt/res/icons/quit.png and b/src/qt/res/icons/quit.png differ diff --git a/src/qt/res/icons/quit.xcf b/src/qt/res/icons/quit.xcf new file mode 100644 index 000000000..b993f5b33 Binary files /dev/null and b/src/qt/res/icons/quit.xcf differ diff --git a/src/qt/res/icons/receive.png b/src/qt/res/icons/receive.png index 53ad1d156..df77b4d9f 100644 Binary files a/src/qt/res/icons/receive.png and b/src/qt/res/icons/receive.png differ diff --git a/src/qt/res/icons/receive.xcf b/src/qt/res/icons/receive.xcf new file mode 100644 index 000000000..b99bc89df Binary files /dev/null and b/src/qt/res/icons/receive.xcf differ diff --git a/src/qt/res/icons/s4c.png b/src/qt/res/icons/s4c.png new file mode 100644 index 000000000..31d667783 Binary files /dev/null and b/src/qt/res/icons/s4c.png differ diff --git a/src/qt/res/icons/s4c.xcf b/src/qt/res/icons/s4c.xcf new file mode 100644 index 000000000..b5a61fc02 Binary files /dev/null and b/src/qt/res/icons/s4c.xcf differ diff --git a/src/qt/res/icons/save.png b/src/qt/res/icons/save.png new file mode 100644 index 000000000..b79f6655a Binary files /dev/null and b/src/qt/res/icons/save.png differ diff --git a/src/qt/res/icons/save.xcf b/src/qt/res/icons/save.xcf new file mode 100644 index 000000000..fb9e80515 Binary files /dev/null and b/src/qt/res/icons/save.xcf differ diff --git a/src/qt/res/icons/send.png b/src/qt/res/icons/send.png index ceb91ea66..96a0c3d2a 100644 Binary files a/src/qt/res/icons/send.png and b/src/qt/res/icons/send.png differ diff --git a/src/qt/res/icons/send.xcf b/src/qt/res/icons/send.xcf new file mode 100644 index 000000000..435c4fff5 Binary files /dev/null and b/src/qt/res/icons/send.xcf differ diff --git a/src/qt/res/icons/star.png b/src/qt/res/icons/star.png new file mode 100644 index 000000000..d813ce19b Binary files /dev/null and b/src/qt/res/icons/star.png differ diff --git a/src/qt/res/icons/star.xcf b/src/qt/res/icons/star.xcf new file mode 100644 index 000000000..9c4e7aa34 Binary files /dev/null and b/src/qt/res/icons/star.xcf differ diff --git a/src/qt/res/icons/synced.png b/src/qt/res/icons/synced.png index 4d7e0e882..d813ce19b 100644 Binary files a/src/qt/res/icons/synced.png and b/src/qt/res/icons/synced.png differ diff --git a/src/qt/res/icons/transaction0.png b/src/qt/res/icons/transaction0.png index 4578666ee..0005a37f9 100644 Binary files a/src/qt/res/icons/transaction0.png and b/src/qt/res/icons/transaction0.png differ diff --git a/src/qt/res/icons/transaction0.xcf b/src/qt/res/icons/transaction0.xcf new file mode 100644 index 000000000..53690bf64 Binary files /dev/null and b/src/qt/res/icons/transaction0.xcf differ diff --git a/src/qt/res/icons/transaction2-1.png b/src/qt/res/icons/transaction2-1.png new file mode 100644 index 000000000..574ed7d99 Binary files /dev/null and b/src/qt/res/icons/transaction2-1.png differ diff --git a/src/qt/res/icons/transaction2-2.png b/src/qt/res/icons/transaction2-2.png new file mode 100644 index 000000000..15519e65f Binary files /dev/null and b/src/qt/res/icons/transaction2-2.png differ diff --git a/src/qt/res/icons/transaction2-3.png b/src/qt/res/icons/transaction2-3.png new file mode 100644 index 000000000..04bb87059 Binary files /dev/null and b/src/qt/res/icons/transaction2-3.png differ diff --git a/src/qt/res/icons/transaction2-4.png b/src/qt/res/icons/transaction2-4.png new file mode 100644 index 000000000..086abb9fa Binary files /dev/null and b/src/qt/res/icons/transaction2-4.png differ diff --git a/src/qt/res/icons/transaction2-5.png b/src/qt/res/icons/transaction2-5.png new file mode 100644 index 000000000..46ae04e6c Binary files /dev/null and b/src/qt/res/icons/transaction2-5.png differ diff --git a/src/qt/res/icons/transaction2-6.png b/src/qt/res/icons/transaction2-6.png new file mode 100644 index 000000000..973699928 Binary files /dev/null and b/src/qt/res/icons/transaction2-6.png differ diff --git a/src/qt/res/icons/transaction2-7.png b/src/qt/res/icons/transaction2-7.png new file mode 100644 index 000000000..fa5541f00 Binary files /dev/null and b/src/qt/res/icons/transaction2-7.png differ diff --git a/src/qt/res/icons/transaction2-8.png b/src/qt/res/icons/transaction2-8.png new file mode 100644 index 000000000..5dff91535 Binary files /dev/null and b/src/qt/res/icons/transaction2-8.png differ diff --git a/src/qt/res/icons/transaction2.xcf b/src/qt/res/icons/transaction2.xcf new file mode 100644 index 000000000..a33ac16de Binary files /dev/null and b/src/qt/res/icons/transaction2.xcf differ diff --git a/src/qt/res/icons/tx_inout.png b/src/qt/res/icons/tx_inout.png index 5f092f97a..650664bfa 100644 Binary files a/src/qt/res/icons/tx_inout.png and b/src/qt/res/icons/tx_inout.png differ diff --git a/src/qt/res/icons/tx_inout.xcf b/src/qt/res/icons/tx_inout.xcf new file mode 100644 index 000000000..996a334d7 Binary files /dev/null and b/src/qt/res/icons/tx_inout.xcf differ diff --git a/src/qt/res/icons/tx_input.png b/src/qt/res/icons/tx_input.png index 0f5fea3a8..df77b4d9f 100644 Binary files a/src/qt/res/icons/tx_input.png and b/src/qt/res/icons/tx_input.png differ diff --git a/src/qt/res/icons/tx_mined.png b/src/qt/res/icons/tx_mined.png index 613f30fec..d813ce19b 100644 Binary files a/src/qt/res/icons/tx_mined.png and b/src/qt/res/icons/tx_mined.png differ diff --git a/src/qt/res/icons/tx_output.png b/src/qt/res/icons/tx_output.png index 9ae39fb32..96a0c3d2a 100644 Binary files a/src/qt/res/icons/tx_output.png and b/src/qt/res/icons/tx_output.png differ diff --git a/src/qt/res/images/splash.jpg b/src/qt/res/images/splash.jpg deleted file mode 100644 index 4dc7633c8..000000000 Binary files a/src/qt/res/images/splash.jpg and /dev/null differ diff --git a/src/qt/res/images/web images/android.png b/src/qt/res/images/web images/android.png new file mode 100644 index 000000000..c587241d6 Binary files /dev/null and b/src/qt/res/images/web images/android.png differ diff --git a/src/qt/res/images/web images/bounties.png b/src/qt/res/images/web images/bounties.png new file mode 100644 index 000000000..867fa3552 Binary files /dev/null and b/src/qt/res/images/web images/bounties.png differ diff --git a/src/qt/res/images/web images/exchanges.png b/src/qt/res/images/web images/exchanges.png new file mode 100644 index 000000000..2362d6481 Binary files /dev/null and b/src/qt/res/images/web images/exchanges.png differ diff --git a/src/qt/res/images/web images/explorer.png b/src/qt/res/images/web images/explorer.png new file mode 100644 index 000000000..38352e37c Binary files /dev/null and b/src/qt/res/images/web images/explorer.png differ diff --git a/src/qt/res/images/web images/github.png b/src/qt/res/images/web images/github.png new file mode 100644 index 000000000..f861d2057 Binary files /dev/null and b/src/qt/res/images/web images/github.png differ diff --git a/src/qt/res/images/web images/information.png b/src/qt/res/images/web images/information.png new file mode 100644 index 000000000..cfa18e24a Binary files /dev/null and b/src/qt/res/images/web images/information.png differ diff --git a/src/qt/res/images/web images/linux.png b/src/qt/res/images/web images/linux.png new file mode 100644 index 000000000..b733a4561 Binary files /dev/null and b/src/qt/res/images/web images/linux.png differ diff --git a/src/qt/res/images/web images/mac.png b/src/qt/res/images/web images/mac.png new file mode 100644 index 000000000..c5171f1a3 Binary files /dev/null and b/src/qt/res/images/web images/mac.png differ diff --git a/src/qt/res/images/web images/merchants.png b/src/qt/res/images/web images/merchants.png new file mode 100644 index 000000000..46fc229eb Binary files /dev/null and b/src/qt/res/images/web images/merchants.png differ diff --git a/src/qt/res/images/web images/news.png b/src/qt/res/images/web images/news.png new file mode 100644 index 000000000..83092bb50 Binary files /dev/null and b/src/qt/res/images/web images/news.png differ diff --git a/src/qt/res/images/web images/social.png b/src/qt/res/images/web images/social.png new file mode 100644 index 000000000..ae2379a26 Binary files /dev/null and b/src/qt/res/images/web images/social.png differ diff --git a/src/qt/res/images/web images/team.png b/src/qt/res/images/web images/team.png new file mode 100644 index 000000000..4e4e4dd20 Binary files /dev/null and b/src/qt/res/images/web images/team.png differ diff --git a/src/qt/res/images/web images/technical details.png b/src/qt/res/images/web images/technical details.png new file mode 100644 index 000000000..6da0d5fd2 Binary files /dev/null and b/src/qt/res/images/web images/technical details.png differ diff --git a/src/qt/res/images/web images/wallets.png b/src/qt/res/images/web images/wallets.png new file mode 100644 index 000000000..1d99da3e5 Binary files /dev/null and b/src/qt/res/images/web images/wallets.png differ diff --git a/src/qt/res/images/web images/windows.png b/src/qt/res/images/web images/windows.png new file mode 100644 index 000000000..5e913e3fd Binary files /dev/null and b/src/qt/res/images/web images/windows.png differ diff --git a/src/qt/res/images/x11-logo2b.JPG b/src/qt/res/images/x11-logo2b.JPG deleted file mode 100644 index 94430cdc8..000000000 Binary files a/src/qt/res/images/x11-logo2b.JPG and /dev/null differ diff --git a/src/qt/res/movies/mining.gif b/src/qt/res/movies/mining.gif new file mode 100644 index 000000000..5ac79e884 Binary files /dev/null and b/src/qt/res/movies/mining.gif differ diff --git a/src/qt/res/movies/update_spinner.gif b/src/qt/res/movies/update_spinner.gif new file mode 100644 index 000000000..b7079b4e8 Binary files /dev/null and b/src/qt/res/movies/update_spinner.gif differ diff --git a/src/qt/res/movies/update_spinner.mng b/src/qt/res/movies/update_spinner.mng deleted file mode 100644 index 7df3baac6..000000000 Binary files a/src/qt/res/movies/update_spinner.mng and /dev/null differ diff --git a/src/qt/res/screenshots/hyperstake-hyperblue-theme-th.png b/src/qt/res/screenshots/hyperstake-hyperblue-theme-th.png new file mode 100644 index 000000000..2663335de Binary files /dev/null and b/src/qt/res/screenshots/hyperstake-hyperblue-theme-th.png differ diff --git a/src/qt/res/screenshots/hyperstake-hyperblue-theme.png b/src/qt/res/screenshots/hyperstake-hyperblue-theme.png new file mode 100644 index 000000000..012e42bd4 Binary files /dev/null and b/src/qt/res/screenshots/hyperstake-hyperblue-theme.png differ diff --git a/src/qt/res/screenshots/hyperstake-poloniexday-theme-th.png b/src/qt/res/screenshots/hyperstake-poloniexday-theme-th.png new file mode 100644 index 000000000..6c77590ba Binary files /dev/null and b/src/qt/res/screenshots/hyperstake-poloniexday-theme-th.png differ diff --git a/src/qt/res/screenshots/hyperstake-poloniexday-theme.png b/src/qt/res/screenshots/hyperstake-poloniexday-theme.png new file mode 100644 index 000000000..e7eddf74d Binary files /dev/null and b/src/qt/res/screenshots/hyperstake-poloniexday-theme.png differ diff --git a/src/qt/res/screenshots/hyperstake-poloniexnight-theme-th.png b/src/qt/res/screenshots/hyperstake-poloniexnight-theme-th.png new file mode 100644 index 000000000..69d7c1b65 Binary files /dev/null and b/src/qt/res/screenshots/hyperstake-poloniexnight-theme-th.png differ diff --git a/src/qt/res/screenshots/hyperstake-poloniexnight-theme.png b/src/qt/res/screenshots/hyperstake-poloniexnight-theme.png new file mode 100644 index 000000000..4fd7eede5 Binary files /dev/null and b/src/qt/res/screenshots/hyperstake-poloniexnight-theme.png differ diff --git a/src/qt/res/themes/BlueLights/arrow-down.png b/src/qt/res/themes/BlueLights/arrow-down.png new file mode 100644 index 000000000..2c45c97fd Binary files /dev/null and b/src/qt/res/themes/BlueLights/arrow-down.png differ diff --git a/src/qt/res/themes/BlueLights/bg.png b/src/qt/res/themes/BlueLights/bg.png new file mode 100644 index 000000000..47fd0f46f Binary files /dev/null and b/src/qt/res/themes/BlueLights/bg.png differ diff --git a/src/qt/res/themes/BlueLights/calendar-disabled.png b/src/qt/res/themes/BlueLights/calendar-disabled.png new file mode 100644 index 000000000..97a36c3c3 Binary files /dev/null and b/src/qt/res/themes/BlueLights/calendar-disabled.png differ diff --git a/src/qt/res/themes/BlueLights/calendar.png b/src/qt/res/themes/BlueLights/calendar.png new file mode 100644 index 000000000..238484f60 Binary files /dev/null and b/src/qt/res/themes/BlueLights/calendar.png differ diff --git a/src/qt/res/themes/BlueLights/cb-checked-hover.png b/src/qt/res/themes/BlueLights/cb-checked-hover.png new file mode 100644 index 000000000..04ced7ae1 Binary files /dev/null and b/src/qt/res/themes/BlueLights/cb-checked-hover.png differ diff --git a/src/qt/res/themes/BlueLights/cb-checked.png b/src/qt/res/themes/BlueLights/cb-checked.png new file mode 100644 index 000000000..8c9993f89 Binary files /dev/null and b/src/qt/res/themes/BlueLights/cb-checked.png differ diff --git a/src/qt/res/themes/BlueLights/cb-hover.png b/src/qt/res/themes/BlueLights/cb-hover.png new file mode 100644 index 000000000..a7e9a393e Binary files /dev/null and b/src/qt/res/themes/BlueLights/cb-hover.png differ diff --git a/src/qt/res/themes/BlueLights/cb.png b/src/qt/res/themes/BlueLights/cb.png new file mode 100644 index 000000000..986a9165c Binary files /dev/null and b/src/qt/res/themes/BlueLights/cb.png differ diff --git a/src/qt/res/themes/BlueLights/down-arrow-disabled.png b/src/qt/res/themes/BlueLights/down-arrow-disabled.png new file mode 100644 index 000000000..46d3baa59 Binary files /dev/null and b/src/qt/res/themes/BlueLights/down-arrow-disabled.png differ diff --git a/src/qt/res/themes/BlueLights/down-arrow.png b/src/qt/res/themes/BlueLights/down-arrow.png new file mode 100644 index 000000000..dd66e6dfd Binary files /dev/null and b/src/qt/res/themes/BlueLights/down-arrow.png differ diff --git a/src/qt/res/themes/BlueLights/hypstk-watermark.png b/src/qt/res/themes/BlueLights/hypstk-watermark.png new file mode 100644 index 000000000..c90353bd3 Binary files /dev/null and b/src/qt/res/themes/BlueLights/hypstk-watermark.png differ diff --git a/src/qt/res/themes/BlueLights/r-checked-hover.png b/src/qt/res/themes/BlueLights/r-checked-hover.png new file mode 100644 index 000000000..d1055b213 Binary files /dev/null and b/src/qt/res/themes/BlueLights/r-checked-hover.png differ diff --git a/src/qt/res/themes/BlueLights/r-checked.png b/src/qt/res/themes/BlueLights/r-checked.png new file mode 100644 index 000000000..f267e78dd Binary files /dev/null and b/src/qt/res/themes/BlueLights/r-checked.png differ diff --git a/src/qt/res/themes/BlueLights/r-hover.png b/src/qt/res/themes/BlueLights/r-hover.png new file mode 100644 index 000000000..9e10a855d Binary files /dev/null and b/src/qt/res/themes/BlueLights/r-hover.png differ diff --git a/src/qt/res/themes/BlueLights/r.png b/src/qt/res/themes/BlueLights/r.png new file mode 100644 index 000000000..fba9037c0 Binary files /dev/null and b/src/qt/res/themes/BlueLights/r.png differ diff --git a/src/qt/res/themes/BlueLights/sizegrip.png b/src/qt/res/themes/BlueLights/sizegrip.png new file mode 100644 index 000000000..9fab9e10a Binary files /dev/null and b/src/qt/res/themes/BlueLights/sizegrip.png differ diff --git a/src/qt/res/themes/BlueLights/styles.qss b/src/qt/res/themes/BlueLights/styles.qss new file mode 100644 index 000000000..093e7f161 --- /dev/null +++ b/src/qt/res/themes/BlueLights/styles.qss @@ -0,0 +1,743 @@ +/** + * BlueLights Qt theme + * Last changed: 2014-10-31 + * Author: moneromooo - based on HyperBlue by ZeeWolf - ##hyperstake (freenode) + * Background adapted from https://hdwallpaperia.com/blue-lights-abstract.html + * HyperStake - faster than light! + */ + +/** + * QSS REFERENCE : + * http://qt-project.org/doc/qt-4.8/stylesheet-reference.html + * http://qt-project.org/doc/qt-4.8/stylesheet-examples.html + */ + +/** + * Text : #88c1d0 + * BG : #0d1f33 + * Lighter : #14283E | #1C324A + * Darker : #071728 | #03101E + * + * Complement : #4E350F + * Lighter : #604419 | #715325 + * Darker : #3D2807 + * Headers : #dca753 + * Input border: #595959 + */ + +/** [VARS] + $text-color = #50f0ef + $main-color-l = #102030 + $main-color-xl = #206080 + $main-color-xd = #205060 + $main-color-transparent-1 = rgba(0,31,51,120) + $main-color-transparent-2 = rgba(180,240,255,170) + $main-color-transparent-3 = rgba(40,60,80,170) + $shade-transparent-1 = rgba(0,0,0,50) + $shade-transparent-2 = rgba(0,0,0,100) + $shade-transparent-3 = rgba(0,0,0,150) + $main-color = #103040 + $text-grey-d = #103040 + $accent-color = #30a3c0 + $brightest-color = #e0f0ef + $input-border-color = #30a3c0 + $header-font = "Verdana, Geneva, sans-serif" + $error-color = #df8080 + $success-color = #50f0ef +[/VARS] */ + +* { gridline-color: $main-color } + +/* Dialog, Window */ +QDialog, QMainWindow { + border-image: url($theme-dir/bg.png); +} + +QMainWindow > QFrame > QDialog { + border-image: none; +} + +#coinLogo { + qproperty-pixmap: url($theme-dir/hypstk-watermark.png); + qproperty-alignment: 'AlignBottom | AlignRight'; +} + +/* Frames */ +QFrame { + /* too general - do not style */ +} + +/* Bottom status bar */ +QStatusBar { + background-color: transparent; + color: $text-color; +} + +QStatusBar::item { + border: none; +} + +/* Label */ +QLabel { + color: $text-color; +} + +QLabel[error="true"], QLabel[status="error"] { + color: $error-color; +} + +QLabel[ok="true"], QLabel[status="ok"] { + color: $success-color; +} + +QValidatedLineEdit[error="true"], QDoubleSpinBox[error="true"] { + border-color: $error-color; +} + +/* Frames labels - Balance, Stake, etc. */ + +/* Balance frame */ +QFrame#frame { + background-color: $shade-transparent-1; + border-bottom: 3px solid $shade-transparent-2; + border-right: 3px solid $shade-transparent-2; +} + +/* Recent transactions frame */ +QFrame#frame_2 { + background-color: $shade-transparent-1; + border: none; + border-bottom: 3px solid $shade-transparent-2; + border-right: 3px solid $shade-transparent-2; +} + +/* Panel in Coin Control window */ +QFrame#frame_2 QFrame { + color: $text-color; +} + +QFrame#rangeFrame { + background-color: $shade-transparent-1; + border: none; + margin-top: 10px; +} + +#CoinControlDialog QFrame#frame { + border: none; + border-bottom: 3px solid $shade-transparent-2; + border-right: 3px solid $shade-transparent-2; +} + +QFrame#frameCoinControl { + background-color: $shade-transparent-1; + border: none; + border-bottom: 3px solid $shade-transparent-2; + border-right: 3px solid $shade-transparent-2; +} + +/* Balance value */ +#frame #labelBalance { + color: $brightest-color; + font-size: 16px; + font-weight: bold; +} + +/* Wallet label */ +QFrame#frame #label_5 { + font-size: 15px; + font-family: $header-font; + color: $accent-color; +} + +/* Recent transactions label */ +QFrame#frame_2 #label_4 { + font-size: 15px; + font-family: $header-font; + color: $accent-color; +} + +/* ScrollArea */ +QScrollArea { + background-color: $shade-transparent-1; + border: none; + border-bottom: 3px solid $shade-transparent-2; + border-right: 3px solid $shade-transparent-2; +} + +#scrollAreaWidgetContents { + background-color: transparent; +} +#scrollAreaWidgetContents > QFrame { + background-color: transparent; + border-width: 0px; + border-style: none; +} + +#scrollAreaWidgetContents > QFrame:last { + border-bottom: 1px solid $brightest-color; +} + +#scrollAreaWidgetContents > QFrame:only-one { + border-bottom: none; +} + +/* Text edit fields */ +QPlainTextEdit, QLineEdit { + padding: 4px; + background-color: $main-color; + color: $brightest-color; + border: 1px solid $input-border-color; +} + +QPlainTextEdit:focus, QLineEdit:focus { + border: 1px solid $accent-color; +} + +QPlainTextEdit:disabled, QLineEdit:disabled { + border-color: $main-color-xd; + color: $input-border-color; +} + +/* Text edit - debug window */ +QTextEdit { + padding: 4px; + background-color: transparent; + color: $brightest-color; + border: none; +} + +QTextEdit:disabled { + border-color: $main-color-xd; + color: $input-border-color; +} + +/* Combo box */ +QComboBox { + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 $main-color-xl, stop:1 $main-color); + color: $text-color; + border: 1px solid $input-border-color; + border-radius: 3px; /* same radius as the QComboBox */ + padding: 3px 18px 3px 4px; + min-width: 6em; +} + +QComboBox:on { + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 $main-color, stop:1 $main-color-xl); + border-color: $accent-color; +} + +QComboBox:disabled { + border-color: $main-color-xd; + color: $input-border-color; +} + +QComboBox::drop-down:disabled { + border-color: $input-border-color; +} + +QComboBox::down-arrow { + /* Custom dropdown symbol */ + image: url($theme-dir/down-arrow.png); +} + +QComboBox::down-arrow:disabled { + image: url($theme-dir/down-arrow-disabled.png); +} + +QComboBox::down-arrow:on { + /* Custom dropdown symbol */ + image: url($theme-dir/up-arrow.png); +} + +QComboBox::drop-down { + border: 0px; +} + +QComboBox QAbstractItemView { + border: 1px solid $main-color-xl; + color: $text-color; + background-color: $main-color; + outline: 0px; +} + +QComboBox QListView { + border: none; + selection-color: $main-color; + selection-background-color: $text-color; +} + +/* Up&down spin box */ +QDateTimeEdit, QSpinBox, QDoubleSpinBox { + padding: 3px; + background-color: $main-color; + color: $brightest-color; + border: 1px solid $input-border-color; +} + +QDateTimeEdit:focus, QSpinBox:focus, QDoubleSpinBox:focus { + border-color: $accent-color; +} + +QDateTimeEdit:disabled, QSpinBox:disabled, QDoubleSpinBox:disabled { + border-color: $main-color-xd; + color: $input-border-color; +} + +QDateTimeEdit::down-arrow { + image: url($theme-dir/calendar.png); +} + +QDateTimeEdit::down-arrow:disabled { + image: url($theme-dir/calendar-disabled.png); +} + +QDateTimeEdit::drop-down { + border: 0px; +} + +QDoubleSpinBox::down-button { + image: url($theme-dir/down-arrow.png); +} + +QDoubleSpinBox::up-button { + image: url($theme-dir/up-arrow.png); +} + +/* Button */ +QPushButton { + background-color: qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 1, stop: 0 $text-color, stop: 0.5 $main-color-xd); + color: $text-color; + padding: 4px; + border: 2px solid $text-color; + outline: none; + font-family: $header-font; + font-size: 12px; + border-radius: 3px; + /*min-width: 6em;*/ +} + +QPushButton[text="OK"] { + width: 6em; +} + +QToolButton { + background-color: qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 1, stop: 0 $text-color, stop: 0.5 $main-color-xd); + color: $text-color; + padding: 4px; + border: 2px solid $text-color; + outline: none; + font-family: $header-font; + font-size: 12px; + border-radius: 3px; +} + +QPushButton:hover, QToolButton:hover { + background-color: qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 1, stop: 0 $accent-color, stop: 0.5 $main-color-xd); + color: $accent-color; + border: 2px solid $accent-color; +} + +QPushButton:disabled, QToolButton:disabled { + background-color: $main-color-xd; + border: 2px solid $input-border-color; + color: $main-color-xl; +} + +QPushButton:pressed, QToolButton:pressed { + background-color: $accent-color; + /*border: 2px solid transparent;*/ + color: $main-color-xd; +} + +/* Toolbar */ +QToolBar { + background: $main-color-l; + spacing: 0px; /* spacing between items in the tool bar */ + border-bottom: 3px solid $main-color-xd; + border-top: 1px solid $main-color-xd; + padding: 0px; + min-height: 96px; + qproperty-iconSize: 80px 80px; +} + +QToolBar::handle { + padding: 0px; + background-image: url($theme-dir/toolbar-handle.png); + background-repeat: repeat-y; + background-position: top center; +} + +/* Toolbar buttons */ +QToolBar QToolButton { /* all types of tool button */ + border-radius: 0px; + background-color: transparent; + color: $accent-color; + padding: 3px 1px 5px 2px; + font-family: $header-font; + font-size: 12px; + margin-top: 4px; + border: none; + border-top-left-radius: 3px; + border-top-right-radius: 3px; + qproperty-toolButtonStyle: ToolButtonTextUnderIcon; +} + +QToolBar QToolButton:hover { + color: $text-color; + background-color: transparent; + border: none; +} + +QToolBar QToolButton:checked { + background-color: $main-color-xd; + color: $brightest-color; + padding: 5px 1px 5px 2px; + font-weight: bold; + font-size: 13px; +} + +QToolBar QToolButton:disabled { + color: $text-grey-d; + background-color: transparent; + border: none; +} + +/* Tool buttons - buttons with icons */ +#qt_toolbar_ext_button { + qproperty-icon: url($theme-dir/arrow-down.png); + border-radius: 0px; + margin-top: 3px; + padding: 0px; + border: 0px; + margin-left: -3px; +} + +#addressBookButton, QToolButton#clearButton, QToolButton#pasteButton, QToolButton#deleteButton, +QToolButton#addressBookButton_VM, QToolButton#copySignatureButton_SM, QToolButton#pasteButton_SM, QToolButton#addressBookButton_SM { + min-width: 16px; + max-width: 24px; + padding: 2px; + margin-left: 4px; +} + +/* Progress bar */ +QProgressBar { + border: 1px solid rgba(136,193,208,80); + color: $brightest-color; + font-weight: bold; + background-color: transparent; +} + +QProgressBar::chunk { + background-color: rgba(136,193,208,80); + width: 3px; + margin: 0.5px; +} + +/* Table */ +CoinControlTreeWidget, QTableView { + background: transparent; + background-color: $main-color-transparent-3; + alternate-background-color: $main-color-transparent-1; + border-style: none; + border-bottom: 3px solid $shade-transparent-2; + color: $text-color; + selection-background-color: $main-color-transparent-2; + /*selection-color: $main-color-xd;*/ + outline: none; +} + +QTableView QTableCornerButton::section { + border: 0px solid $main-color-xd; + outline: none; +} + +QTableWidget::item:focus { + outline: none; + border: 0px; +} + +QTreeView { + background: transparent; + color: $text-color; + border-style: none; + background-color: $main-color-transparent-3; + selection-background-color: $accent-color; + alternate-background-color: $main-color-transparent-1; + selection-color: $main-color-xd; + outline: none; +} + +QTreeView::item { + border: none; + color: $text-color; +} + +QTreeView::item:hover { + color: $brightest-color; +} + +QTreeView::item:selected { + background-color: $main-color-transparent-2; + color: $main-color-xd; +} + +/* Table Header */ +QHeaderView { + color: $brightest-color; + background-color: $main-color; + border-bottom: 1px solid $accent-color; +} + +QHeaderView::section { + color: $accent-color; + background-color: transparent; +} + +QHeaderView::section:checked { + +} + +/* Tooltip */ +QToolTip { + border: 2px outset $main-color-xl; + color: $text-color; + background-color: $main-color; +} + + +/* Menu Bar */ +QMenuBar { + background-color: $text-grey-d; + border: none; +} + +QMenuBar::item { + background: transparent; + color: $text-color; +} + +QMenuBar::item:selected { /* when selected using mouse or keyboard */ + background: $text-color; + color: $text-grey-d; +} + +QMenuBar::item:pressed { + background: $text-color; +} + +/* Menu dialog */ +QMenu { + color: $text-color; + background-color: $text-grey-d; +} + +QMenu::item { + /* sets background of menu item. set this to something non-transparent + if you want menu color and menu item color to be different */ + background-color: transparent; +} + +QMenu::item:selected { /* when user selects item using mouse or keyboard */ + color: $text-grey-d; + background-color: $text-color; +} + +/* Checkbox */ +QCheckBox { + color: $text-color; +} + +QCheckBox::indicator { + width: 13px; + height: 13px; +} + +QCheckBox::indicator:unchecked { + image: url($theme-dir/cb.png); +} + +QCheckBox::indicator:unchecked:hover { + image: url($theme-dir/cb-hover.png); +} + +QCheckBox::indicator:unchecked:pressed { + /*image: url($theme-dir/checkbox_unchecked_pressed.png);*/ +} + +QCheckBox::indicator:checked { + image: url($theme-dir/cb-checked.png); +} + +QCheckBox::indicator:checked:hover { + image: url($theme-dir/cb-checked-hover.png); +} + +QCheckBox::indicator:checked:pressed { + /*image: url($theme-dir/checkbox_checked_pressed.png);*/ +} + +QCheckBox::indicator:indeterminate:hover { + /*image: url($theme-dir/checkbox_indeterminate_hover.png);*/ +} + +QCheckBox::indicator:indeterminate:pressed { + /*image: url($theme-dir/checkbox_indeterminate_pressed.png);*/ +} + +/* Radio button */ +QRadioButton { + color: $text-color; +} + +QRadioButton::indicator { + width: 13px; + height: 13px; +} + +QRadioButton::indicator::unchecked { + image: url($theme-dir/r.png); +} + +QRadioButton::indicator:unchecked:hover { + image: url($theme-dir/r-hover.png); +} + +QRadioButton::indicator:unchecked:pressed { + /*image: url($theme-dir/rpressed.png);*/ +} + +QRadioButton::indicator::checked { + image: url($theme-dir/r-checked.png); +} + +QRadioButton::indicator:checked:hover { + image: url($theme-dir/r-checked-hover.png); +} + +QRadioButton::indicator:checked:pressed { + /*image: url($theme-dir/radiobutton_checked_pressed.png);*/ +} + +/* Tabs */ +QTabWidget { + background: transparent; +} + +QTabWidget::pane { + background-color: $shade-transparent-1; + border-bottom: 3px solid $shade-transparent-2; + border-right: 3px solid $shade-transparent-2; + border-top: 2px solid $main-color-xd; + margin-top: -2px; +} + +QTabWidget::tab-bar { +} + +/* Style the tab using the tab sub-control. Note that it reads QTabBar _not_ QTabWidget */ +QTabBar::tab { + /*background-color: $main-color;*/ + background-color: transparent; + min-width: 26ex; + padding: 6px 4px 8px 4px; + color: $text-color; + margin-right: 2ex; +} + +QTabBar::tab:selected, QTabBar::tab:hover { + border-bottom: 2px solid $accent-color; + background-color: $main-color-xd; + color: $accent-color; + margin-top: 1px; + border-top-left-radius: 3px; + border-top-right-radius: 3px; +} + +QTabBar::tab:!selected { + /*margin-top: 2px;*/ /* make non-selected tabs look smaller */ +} + +/* Scroll bar */ + +QScrollBar:vertical { + background: $main-color-transparent-1; + width: 6px; + margin: 0px 0px 0px 0px; +} + +QScrollBar::handle:vertical { + background: $main-color-transparent-2; +} + +QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { + background: none; +} + +QScrollBar::add-line:vertical { + height: 0px; +} + +QScrollBar::sub-line:vertical { + height: 0px; +} + +/* Calendar */ + +/* navigation bar */ +QCalendarWidget QWidget#qt_calendar_navigationbar { background-color: $main-color } +QCalendarWidget QToolButton { +} +QCalendarWidget QMenu { + background-color: $main-color-xd; +} + + /* header row */ +QCalendarWidget QWidget { alternate-background-color: $main-color-l } + +/* normal days */ +QCalendarWidget QAbstractItemView:enabled { + color: $text-color; + background-color: $main-color; + selection-background-color: $accent-color; + selection-color: $main-color-xd; +} + +/* days in other months */ +QCalendarWidget QAbstractItemView:disabled { color: $main-color-xd } + +/* Window resize grip */ +QSizeGrip { + image: url($theme-dir/sizegrip.png); + width: 16px; + height: 16px; +} + +/* QBalloonTip - notification used in Linux - styled by Qt */ +QBalloonTip { + background-color: $main-color-l; + color: $text-color; +} + +QBalloonTip QPushButton { + min-width: 16px; + color: $text-color; + padding: 0px; + border-radius: 0px; + background-color: $text-color; +} + +QBalloonTip QPushButton:hover { + border: none; + background-color: $accent-color; +} + +/* Make the console readable */ +QTabWidget > QFrame { + background-color: $shade-transparent-3; +} + +QCheckBox#deleteCheckBox { + background-color: $shade-transparent-3; + padding: 4px; +} diff --git a/src/qt/res/themes/BlueLights/toolbar-handle.png b/src/qt/res/themes/BlueLights/toolbar-handle.png new file mode 100644 index 000000000..d5ca69b01 Binary files /dev/null and b/src/qt/res/themes/BlueLights/toolbar-handle.png differ diff --git a/src/qt/res/themes/BlueLights/up-arrow-disabled.png b/src/qt/res/themes/BlueLights/up-arrow-disabled.png new file mode 100644 index 000000000..72b862032 Binary files /dev/null and b/src/qt/res/themes/BlueLights/up-arrow-disabled.png differ diff --git a/src/qt/res/themes/BlueLights/up-arrow.png b/src/qt/res/themes/BlueLights/up-arrow.png new file mode 100644 index 000000000..7bbd8b830 Binary files /dev/null and b/src/qt/res/themes/BlueLights/up-arrow.png differ diff --git a/src/qt/res/themes/Celestial/arrow-down.png b/src/qt/res/themes/Celestial/arrow-down.png new file mode 100644 index 000000000..67b862072 Binary files /dev/null and b/src/qt/res/themes/Celestial/arrow-down.png differ diff --git a/src/qt/res/themes/Celestial/calendar-disabled.png b/src/qt/res/themes/Celestial/calendar-disabled.png new file mode 100644 index 000000000..0c6a542e6 Binary files /dev/null and b/src/qt/res/themes/Celestial/calendar-disabled.png differ diff --git a/src/qt/res/themes/Celestial/calendar.png b/src/qt/res/themes/Celestial/calendar.png new file mode 100644 index 000000000..d284632b3 Binary files /dev/null and b/src/qt/res/themes/Celestial/calendar.png differ diff --git a/src/qt/res/themes/Celestial/cb-checked-hover.png b/src/qt/res/themes/Celestial/cb-checked-hover.png new file mode 100644 index 000000000..5c2fc23d9 Binary files /dev/null and b/src/qt/res/themes/Celestial/cb-checked-hover.png differ diff --git a/src/qt/res/themes/Celestial/cb-checked.png b/src/qt/res/themes/Celestial/cb-checked.png new file mode 100644 index 000000000..08954fe16 Binary files /dev/null and b/src/qt/res/themes/Celestial/cb-checked.png differ diff --git a/src/qt/res/themes/Celestial/cb-hover.png b/src/qt/res/themes/Celestial/cb-hover.png new file mode 100644 index 000000000..f2ad0334e Binary files /dev/null and b/src/qt/res/themes/Celestial/cb-hover.png differ diff --git a/src/qt/res/themes/Celestial/cb.png b/src/qt/res/themes/Celestial/cb.png new file mode 100644 index 000000000..7ce23b3cc Binary files /dev/null and b/src/qt/res/themes/Celestial/cb.png differ diff --git a/src/qt/res/themes/Celestial/down-arrow-disabled.png b/src/qt/res/themes/Celestial/down-arrow-disabled.png new file mode 100644 index 000000000..1a9c70757 Binary files /dev/null and b/src/qt/res/themes/Celestial/down-arrow-disabled.png differ diff --git a/src/qt/res/themes/Celestial/down-arrow.png b/src/qt/res/themes/Celestial/down-arrow.png new file mode 100644 index 000000000..0fea0159f Binary files /dev/null and b/src/qt/res/themes/Celestial/down-arrow.png differ diff --git a/src/qt/res/themes/Celestial/hypstk-watermark.png b/src/qt/res/themes/Celestial/hypstk-watermark.png new file mode 100644 index 000000000..6810144df Binary files /dev/null and b/src/qt/res/themes/Celestial/hypstk-watermark.png differ diff --git a/src/qt/res/themes/Celestial/r-checked-hover.png b/src/qt/res/themes/Celestial/r-checked-hover.png new file mode 100644 index 000000000..3c0af5d9a Binary files /dev/null and b/src/qt/res/themes/Celestial/r-checked-hover.png differ diff --git a/src/qt/res/themes/Celestial/r-checked.png b/src/qt/res/themes/Celestial/r-checked.png new file mode 100644 index 000000000..13c56c1a6 Binary files /dev/null and b/src/qt/res/themes/Celestial/r-checked.png differ diff --git a/src/qt/res/themes/Celestial/r-hover.png b/src/qt/res/themes/Celestial/r-hover.png new file mode 100644 index 000000000..b92a07815 Binary files /dev/null and b/src/qt/res/themes/Celestial/r-hover.png differ diff --git a/src/qt/res/themes/Celestial/r.png b/src/qt/res/themes/Celestial/r.png new file mode 100644 index 000000000..27736a3c9 Binary files /dev/null and b/src/qt/res/themes/Celestial/r.png differ diff --git a/src/qt/res/themes/Celestial/sizegrip.png b/src/qt/res/themes/Celestial/sizegrip.png new file mode 100644 index 000000000..a2c4845ea Binary files /dev/null and b/src/qt/res/themes/Celestial/sizegrip.png differ diff --git a/src/qt/res/themes/Celestial/space.png b/src/qt/res/themes/Celestial/space.png new file mode 100644 index 000000000..04cab5635 Binary files /dev/null and b/src/qt/res/themes/Celestial/space.png differ diff --git a/src/qt/res/themes/Celestial/styles.qss b/src/qt/res/themes/Celestial/styles.qss new file mode 100644 index 000000000..cd17510c7 --- /dev/null +++ b/src/qt/res/themes/Celestial/styles.qss @@ -0,0 +1,707 @@ +/** + * Celestial Qt Theme - v1.0 + * Created: 24/10/2014 + * Author: ShrykeZ (Based on HyperBlue by Zeewolf) - ##hyperstake (freenode) + * HyperStake - faster than light! + */ + +/** + * QSS REFERENCE : + * http://qt-project.org/doc/qt-4.8/stylesheet-reference.html + * http://qt-project.org/doc/qt-4.8/stylesheet-examples.html + */ + +/** [VARS] + $text-color = #E5E4E2 + $main-color-l = #142930 + $main-color-xl = #6D7B8D + $main-color-d = #342D7E + $main-color-xd = #0C090A + $main-color-transparent-0 = rgba(37,56,60,50) + $main-color-transparent-1 = rgba(37,56,60,100) + $main-color-transparent-2 = rgba(72,99,160,200) + $shade-transparent-1 = rgba(0,0,0,100) + $shade-transparent-2 = rgba(0,0,0,50) + $main-color = #25383C + $text-grey-d = #0c191d + $accent-color = #dca753 + $brightest-color = #fff + $input-border-color = #BCC6CC + $header-font = "Verdana, Geneva, sans-serif" + $error-color = #FF0000 + $success-color = #00FF00 +[/VARS] */ + +* { gridline-color: $main-color } + +/* Dialog, Window */ +QDialog, QMainWindow { + background-image: url($theme-dir/space.png); + background-repeat: repeat-xy; +} + +#coinLogo { + qproperty-pixmap: url($theme-dir/hypstk-watermark.png); + qproperty-alignment: 'AlignBottom | AlignLeft'; +} + +/* Frames */ +QFrame { + /* too general - do not style */ +} + +/* Bottom status bar */ +QStatusBar { + background-color: transparent; + color: $text-color; +} + +QStatusBar::item { + border: none; +} + +/* Label */ +QLabel { + color: $text-color; +} + +QLabel[error="true"], QLabel[status="error"] { + color: $error-color; +} + +QLabel[ok="true"], QLabel[status="ok"] { + color: $success-color; +} + +QValidatedLineEdit[error="true"], QDoubleSpinBox[error="true"] { + border-color: $error-color; +} + +/* Frames labels - Balance, Stake, etc. */ + +/* Balance frame */ +QFrame#frame { + background-color: $shade-transparent-1; + border-bottom: 3px solid $shade-transparent-2; + border-right: 3px solid $shade-transparent-2; +} + +/* Recent transactions frame */ +QFrame#frame_2 { + background-color: $shade-transparent-1; + border: none; + border-bottom: 3px solid $shade-transparent-2; + border-right: 3px solid $shade-transparent-2; +} + +/* Panel in Coin Control window */ +QFrame#frame_2 QFrame { + color: $text-color; +} + +QFrame#rangeFrame { + background-color: $shade-transparent-1; + border: none; + margin-top: 10px; +} + +#CoinControlDialog QFrame#frame { + border: none; + border-bottom: 3px solid $shade-transparent-2; + border-right: 3px solid $shade-transparent-2; +} + +QFrame#frameCoinControl { + background-color: $shade-transparent-1; + border: none; + border-bottom: 3px solid $shade-transparent-2; + border-right: 3px solid $shade-transparent-2; +} + +/* Balance value */ +#frame #labelBalance { + color: $brightest-color; + font-size: 14px; +} + +/* Wallet label */ +QFrame#frame #label_5 { + font-size: 15px; + font-family: $header-font; + color: $accent-color; +} + +/* Recent transactions label */ +QFrame#frame_2 #label_4 { + font-size: 15px; + font-family: $header-font; + color: $accent-color; +} + +/* ScrollArea */ +QScrollArea { + background-color: $shade-transparent-1; + border: none; + border-bottom: 3px solid $shade-transparent-2; + border-right: 3px solid $shade-transparent-2; +} + +#scrollAreaWidgetContents { + background-color: transparent; +} +#scrollAreaWidgetContents > QFrame { + background-color: transparent; + border-width: 0px; + border-style: none; +} + +#scrollAreaWidgetContents > QFrame:last { + border-bottom: 1px solid $brightest-color; +} + +#scrollAreaWidgetContents > QFrame:only-one { + border-bottom: none; +} + +/* Text edit fields */ +QPlainTextEdit, QLineEdit { + padding: 4px; + background-color: $main-color; + color: $brightest-color; + border: 1px solid $input-border-color; +} + +QPlainTextEdit:focus, QLineEdit:focus { + border: 1px solid $accent-color; +} + +QPlainTextEdit:disabled, QLineEdit:disabled { + border-color: $main-color-xd; + color: $input-border-color; +} + +/* Text edit - debug window */ +QTextEdit { + padding: 4px; + background-color: transparent; + color: $brightest-color; + border: none; +} + +QTextEdit:disabled { + border-color: $main-color-xd; + color: $input-border-color; +} + +/* Combo box */ +QComboBox { + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 $main-color-xl, stop:1 $main-color); + color: $text-color; + border: 1px solid $input-border-color; + border-radius: 3px; /* same radius as the QComboBox */ + padding: 3px 18px 3px 4px; + min-width: 6em; +} + +QComboBox:on { + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 $main-color, stop:1 $main-color-xl); + border-color: $accent-color; +} + +QComboBox:disabled { + border-color: $main-color-xd; + color: $input-border-color; +} + +QComboBox::drop-down:disabled { + border-color: $input-border-color; +} + +QComboBox::down-arrow { + /* Custom dropdown symbol */ + image: url($theme-dir/down-arrow.png); +} + +QComboBox::down-arrow:disabled { + image: url($theme-dir/down-arrow-disabled.png); +} + +QComboBox::down-arrow:on { + /* Custom dropdown symbol */ + image: url($theme-dir/up-arrow.png); +} + +QComboBox::drop-down { + border: 0px; +} + +QComboBox QAbstractItemView { + border: 1px solid $main-color-xl; + color: $text-color; + background-color: $main-color; + outline: 0px; +} + +QComboBox QListView { + border: none; + selection-color: $main-color; + selection-background-color: $text-color; +} + +/* Up&down spin box */ +QDateTimeEdit, QSpinBox, QDoubleSpinBox { + padding: 3px; + background-color: $main-color; + color: $brightest-color; + border: 1px solid $input-border-color; +} + +QDateTimeEdit:focus, QSpinBox:focus, QDoubleSpinBox:focus { + border-color: $accent-color; +} + +QDateTimeEdit:disabled, QSpinBox:disabled, QDoubleSpinBox:disabled { + border-color: $main-color-xd; + color: $input-border-color; +} + +QDateTimeEdit::down-arrow { + image: url($theme-dir/calendar.png); +} + +QDateTimeEdit::down-arrow:disabled { + image: url($theme-dir/calendar-disabled.png); +} + +QDateTimeEdit::drop-down { + border: 0px; +} + +QDoubleSpinBox::down-button { + image: url($theme-dir/down-arrow.png); +} + +QDoubleSpinBox::up-button { + image: url($theme-dir/up-arrow.png); +} + +/* Button */ +QPushButton { + background-color: qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 1, stop: 0 $text-color, stop: 0.5 $main-color-xd); + color: $text-color; + padding: 4px; + border: 2px solid $text-color; + outline: none; + font-family: $header-font; + font-size: 12px; + border-radius: 3px; + /*min-width: 6em;*/ +} + +QPushButton[text="OK"] { + width: 6em; +} + +QToolButton { + background-color: qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 1, stop: 0 $text-color, stop: 0.5 $main-color-xd); + color: $text-color; + padding: 4px; + border: 2px solid $text-color; + outline: none; + font-family: $header-font; + font-size: 12px; + border-radius: 3px; +} + +QPushButton:hover, QToolButton:hover { + background-color: qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 1, stop: 0 $accent-color, stop: 0.5 $main-color-xd); + color: $accent-color; + border: 2px solid $accent-color; +} + +QPushButton:disabled, QToolButton:disabled { + background-color: $main-color-xd; + border: 2px solid $input-border-color; + color: $main-color-xl; +} + +QPushButton:pressed, QToolButton:pressed { + background-color: $accent-color; + /*border: 2px solid transparent;*/ + color: $main-color-xd; +} + +/* Toolbar */ +QToolBar { + background: $main-color-l; + spacing: 0px; /* spacing between items in the tool bar */ + border-bottom: 3px solid $main-color-xd; + border-top: 1px solid $main-color-xd; + min-height: 40px; + padding: 0px; +} + +QToolBar::handle { + padding: 0px; + background-image: url($theme-dir/toolbar-handle.png); + background-repeat: repeat-y; + background-position: top center; +} + +/* Toolbar buttons */ +QToolBar QToolButton { /* all types of tool button */ + border-radius: 0px; + background-color: transparent; + color: $text-color; + padding: 3px 1px 5px 2px; + font-family: $header-font; + font-size: 12px; + margin-top: 4px; + border: none; + border-top-left-radius: 3px; + border-top-right-radius: 3px; +} + +QToolBar QToolButton:hover { + color: $brightest-color; + background-color: transparent; + border: none; + +} + +QToolBar QToolButton:checked { + background-color: $main-color-xd; + color: $accent-color; + border-bottom: 3px solid $accent-color; + padding: 5px 1px 5px 2px; +} + +QToolBar QToolButton:disabled { + color: $input-border-color; + background-color: transparent; + border: none; +} + +/* Tool buttons - buttons with icons */ +#qt_toolbar_ext_button { + qproperty-icon: url($theme-dir/arrow-down.png); + border-radius: 0px; + margin-top: 3px; + padding: 0px; + border: 0px; + margin-left: -3px; +} + +#addressBookButton, QToolButton#clearButton, QToolButton#pasteButton, QToolButton#deleteButton, +QToolButton#addressBookButton_VM, QToolButton#copySignatureButton_SM, QToolButton#pasteButton_SM, QToolButton#addressBookButton_SM { + min-width: 16px; + max-width: 24px; + padding: 2px; + margin-left: 4px; +} + +/* Progress bar */ +QProgressBar { + border: 1px solid rgba(136,193,208,80); + color: $brightest-color; + font-weight: bold; + background-color: transparent; +} + +QProgressBar::chunk { + background-color: rgba(136,193,208,80); + width: 3px; + margin: 0.5px; +} + +/* Table */ +CoinControlTreeWidget, QTableView { + background: $main-color-transparent-0; + alternate-background-color: $main-color-transparent-1; + border-style: none; + border-bottom: 3px solid $shade-transparent-2; + color: $text-color; + selection-background-color: $main-color-transparent-2; + /*selection-color: $main-color-xd;*/ + outline: none; +} + +QTableView QTableCornerButton::section { + border: 0px solid $main-color-xd; + outline: none; +} + +QTableWidget::item:focus { + outline: none; + border: 0px; +} + +QTreeView { + background: $main-color-transparent-0; + color: $text-color; + border-style: none; + selection-background-color: $accent-color; + alternate-background-color: $main-color-transparent-1; + selection-color: $main-color-xd; + outline: none; +} + +QTreeView::item { + border: none; + color: $text-color; +} + +QTreeView::item:hover { + color: $brightest-color; +} + +QTreeView::item:selected { + background-color: $main-color-transparent-2; + color: $main-color-xd; +} + +/* Table Header */ +QHeaderView { + color: $brightest-color; + background-color: $main-color; + border-bottom: 1px solid $accent-color; +} + +QHeaderView::section { + color: $accent-color; + background-color: transparent; +} + +QHeaderView::section:checked { + +} + +/* Tooltip */ +QToolTip { + border: 2px outset $main-color-xl; + color: $text-color; + background-color: $main-color; +} + + +/* Menu Bar */ +QMenuBar { + background-color: $text-grey-d; + border: none; +} + +QMenuBar::item { + background: transparent; + color: $text-color; +} + +QMenuBar::item:selected { /* when selected using mouse or keyboard */ + background: $text-color; + color: $text-grey-d; +} + +QMenuBar::item:pressed { + background: $text-color; +} + +/* Menu dialog */ +QMenu { + color: $text-color; + background-color: $text-grey-d; +} + +QMenu::item { + /* sets background of menu item. set this to something non-transparent + if you want menu color and menu item color to be different */ + background-color: transparent; +} + +QMenu::item:selected { /* when user selects item using mouse or keyboard */ + color: $text-grey-d; + background-color: $text-color; +} + +/* Checkbox */ +QCheckBox { + color: $text-color; +} + +QCheckBox::indicator { + width: 13px; + height: 13px; +} + +QCheckBox::indicator:unchecked { + image: url($theme-dir/cb.png); +} + +QCheckBox::indicator:unchecked:hover { + image: url($theme-dir/cb-hover.png); +} + +QCheckBox::indicator:unchecked:pressed { + /*image: url($theme-dir/checkbox_unchecked_pressed.png);*/ +} + +QCheckBox::indicator:checked { + image: url($theme-dir/cb-checked.png); +} + +QCheckBox::indicator:checked:hover { + image: url($theme-dir/cb-checked-hover.png); +} + +QCheckBox::indicator:checked:pressed { + /*image: url($theme-dir/checkbox_checked_pressed.png);*/ +} + +QCheckBox::indicator:indeterminate:hover { + /*image: url($theme-dir/checkbox_indeterminate_hover.png);*/ +} + +QCheckBox::indicator:indeterminate:pressed { + /*image: url($theme-dir/checkbox_indeterminate_pressed.png);*/ +} + +/* Radio button */ +QRadioButton { + color: $text-color; +} + +QRadioButton::indicator { + width: 13px; + height: 13px; +} + +QRadioButton::indicator::unchecked { + image: url($theme-dir/r.png); +} + +QRadioButton::indicator:unchecked:hover { + image: url($theme-dir/r-hover.png); +} + +QRadioButton::indicator:unchecked:pressed { + /*image: url($theme-dir/rpressed.png);*/ +} + +QRadioButton::indicator::checked { + image: url($theme-dir/r-checked.png); +} + +QRadioButton::indicator:checked:hover { + image: url($theme-dir/r-checked-hover.png); +} + +QRadioButton::indicator:checked:pressed { + /*image: url($theme-dir/radiobutton_checked_pressed.png);*/ +} + +/* Tabs */ +QTabWidget { + background: transparent; +} + +QTabWidget::pane { + background-color: $shade-transparent-1; + border-bottom: 3px solid $shade-transparent-2; + border-right: 3px solid $shade-transparent-2; + border-top: 2px solid $main-color-xd; + margin-top: -2px; +} + +QTabWidget::tab-bar { +} + +/* Style the tab using the tab sub-control. Note that it reads QTabBar _not_ QTabWidget */ +QTabBar::tab { + /*background-color: $main-color;*/ + background-color: transparent; + min-width: 26ex; + padding: 6px 4px 8px 4px; + color: $text-color; + margin-right: 2ex; +} + +QTabBar::tab:selected, QTabBar::tab:hover { + border-bottom: 2px solid $accent-color; + background-color: $main-color-xd; + color: $accent-color; + margin-top: 1px; + border-top-left-radius: 3px; + border-top-right-radius: 3px; +} + +QTabBar::tab:!selected { + /*margin-top: 2px;*/ /* make non-selected tabs look smaller */ +} + +/* Scroll bar */ + +QScrollBar:vertical { + background: $main-color-transparent-1; + width: 6px; + margin: 0px 0px 0px 0px; +} + +QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { + background: none; +} + +QScrollBar::add-line:vertical { + height: 0px; +} + +QScrollBar::sub-line:vertical { + height: 0px; +} + +/* Calendar */ + +/* navigation bar */ +QCalendarWidget QWidget#qt_calendar_navigationbar { background-color: $main-color } +QCalendarWidget QToolButton { +} +QCalendarWidget QMenu { + background-color: $main-color-xd; +} + + /* header row */ +QCalendarWidget QWidget { alternate-background-color: $main-color-l } + +/* normal days */ +QCalendarWidget QAbstractItemView:enabled { + color: $text-color; + background-color: $main-color; + selection-background-color: $accent-color; + selection-color: $main-color-xd; +} + +/* days in other months */ +QCalendarWidget QAbstractItemView:disabled { color: $main-color-xd } + +/* Window resize grip */ +QSizeGrip { + image: url($theme-dir/sizegrip.png); + width: 16px; + height: 16px; +} + +/* QBalloonTip - notification used in Linux - styled by Qt */ +QBalloonTip { + background-color: $main-color-l; + color: $text-color; +} + +QBalloonTip QPushButton { + min-width: 16px; + color: $text-color; + padding: 0px; + border-radius: 0px; + background-color: $text-color; +} + +QBalloonTip QPushButton:hover { + border: none; + background-color: $accent-color; +} diff --git a/src/qt/res/themes/Celestial/toolbar-handle.png b/src/qt/res/themes/Celestial/toolbar-handle.png new file mode 100644 index 000000000..0bfe4b59e Binary files /dev/null and b/src/qt/res/themes/Celestial/toolbar-handle.png differ diff --git a/src/qt/res/themes/Celestial/up-arrow-disabled.png b/src/qt/res/themes/Celestial/up-arrow-disabled.png new file mode 100644 index 000000000..4dc96a70d Binary files /dev/null and b/src/qt/res/themes/Celestial/up-arrow-disabled.png differ diff --git a/src/qt/res/themes/Celestial/up-arrow.png b/src/qt/res/themes/Celestial/up-arrow.png new file mode 100644 index 000000000..a57b00b1e Binary files /dev/null and b/src/qt/res/themes/Celestial/up-arrow.png differ diff --git a/src/qt/res/themes/Default/styles.qss b/src/qt/res/themes/Default/styles.qss new file mode 100644 index 000000000..4a770ba48 --- /dev/null +++ b/src/qt/res/themes/Default/styles.qss @@ -0,0 +1,32 @@ +/** + * Default Qt theme - v1.0 + * Last changed: 2014-09-18 + * Author: ZeeWolf - ##hyperstake (freenode) + * HyperStake - faster than light! + */ + +/* Styling moved from *.cpp hardcodes and new general styles */ +#coinLogo { + qproperty-pixmap: url(:images/backg); + qproperty-alignment: 'AlignHCenter | AlignVCenter'; +} + +QLabel[error="true"] { + color: red; +} + +QLabel[status="ok"] { + color: green; +} + +QValidatedLineEdit[error="true"] { + background-color: #FF8080; +} + +QToolBar { + qproperty-iconSize: 24px 24px; +} + +QToolBar QToolButton { /* all types of tool button */ + qproperty-toolButtonStyle: ToolButtonTextBesideIcon; +} diff --git a/src/qt/res/themes/HyperBlue/arrow-down.png b/src/qt/res/themes/HyperBlue/arrow-down.png new file mode 100644 index 000000000..abbe63ccd Binary files /dev/null and b/src/qt/res/themes/HyperBlue/arrow-down.png differ diff --git a/src/qt/res/themes/HyperBlue/bg.png b/src/qt/res/themes/HyperBlue/bg.png new file mode 100644 index 000000000..e08437271 Binary files /dev/null and b/src/qt/res/themes/HyperBlue/bg.png differ diff --git a/src/qt/res/themes/HyperBlue/calendar-disabled.png b/src/qt/res/themes/HyperBlue/calendar-disabled.png new file mode 100644 index 000000000..97a36c3c3 Binary files /dev/null and b/src/qt/res/themes/HyperBlue/calendar-disabled.png differ diff --git a/src/qt/res/themes/HyperBlue/calendar.png b/src/qt/res/themes/HyperBlue/calendar.png new file mode 100644 index 000000000..b2f90452b Binary files /dev/null and b/src/qt/res/themes/HyperBlue/calendar.png differ diff --git a/src/qt/res/themes/HyperBlue/cb-checked-hover.png b/src/qt/res/themes/HyperBlue/cb-checked-hover.png new file mode 100644 index 000000000..04ced7ae1 Binary files /dev/null and b/src/qt/res/themes/HyperBlue/cb-checked-hover.png differ diff --git a/src/qt/res/themes/HyperBlue/cb-checked.png b/src/qt/res/themes/HyperBlue/cb-checked.png new file mode 100644 index 000000000..8c9993f89 Binary files /dev/null and b/src/qt/res/themes/HyperBlue/cb-checked.png differ diff --git a/src/qt/res/themes/HyperBlue/cb-hover.png b/src/qt/res/themes/HyperBlue/cb-hover.png new file mode 100644 index 000000000..a7e9a393e Binary files /dev/null and b/src/qt/res/themes/HyperBlue/cb-hover.png differ diff --git a/src/qt/res/themes/HyperBlue/cb.png b/src/qt/res/themes/HyperBlue/cb.png new file mode 100644 index 000000000..986a9165c Binary files /dev/null and b/src/qt/res/themes/HyperBlue/cb.png differ diff --git a/src/qt/res/themes/HyperBlue/down-arrow-disabled.png b/src/qt/res/themes/HyperBlue/down-arrow-disabled.png new file mode 100644 index 000000000..46d3baa59 Binary files /dev/null and b/src/qt/res/themes/HyperBlue/down-arrow-disabled.png differ diff --git a/src/qt/res/themes/HyperBlue/down-arrow.png b/src/qt/res/themes/HyperBlue/down-arrow.png new file mode 100644 index 000000000..dd66e6dfd Binary files /dev/null and b/src/qt/res/themes/HyperBlue/down-arrow.png differ diff --git a/src/qt/res/themes/HyperBlue/hypstk-watermark.png b/src/qt/res/themes/HyperBlue/hypstk-watermark.png new file mode 100644 index 000000000..cd9aaab85 Binary files /dev/null and b/src/qt/res/themes/HyperBlue/hypstk-watermark.png differ diff --git a/src/qt/res/themes/HyperBlue/r-checked-hover.png b/src/qt/res/themes/HyperBlue/r-checked-hover.png new file mode 100644 index 000000000..d1055b213 Binary files /dev/null and b/src/qt/res/themes/HyperBlue/r-checked-hover.png differ diff --git a/src/qt/res/themes/HyperBlue/r-checked.png b/src/qt/res/themes/HyperBlue/r-checked.png new file mode 100644 index 000000000..f267e78dd Binary files /dev/null and b/src/qt/res/themes/HyperBlue/r-checked.png differ diff --git a/src/qt/res/themes/HyperBlue/r-hover.png b/src/qt/res/themes/HyperBlue/r-hover.png new file mode 100644 index 000000000..9e10a855d Binary files /dev/null and b/src/qt/res/themes/HyperBlue/r-hover.png differ diff --git a/src/qt/res/themes/HyperBlue/r.png b/src/qt/res/themes/HyperBlue/r.png new file mode 100644 index 000000000..fba9037c0 Binary files /dev/null and b/src/qt/res/themes/HyperBlue/r.png differ diff --git a/src/qt/res/themes/HyperBlue/sizegrip.png b/src/qt/res/themes/HyperBlue/sizegrip.png new file mode 100644 index 000000000..9fab9e10a Binary files /dev/null and b/src/qt/res/themes/HyperBlue/sizegrip.png differ diff --git a/src/qt/res/themes/HyperBlue/styles.qss b/src/qt/res/themes/HyperBlue/styles.qss new file mode 100644 index 000000000..30373ed29 --- /dev/null +++ b/src/qt/res/themes/HyperBlue/styles.qss @@ -0,0 +1,723 @@ +/** + * HyperBlue Qt theme - v1.1 + * Last changed: 2014-10-06 + * Author: ZeeWolf - ##hyperstake (freenode) + * HyperStake - faster than light! + */ + +/** + * QSS REFERENCE : + * http://qt-project.org/doc/qt-4.8/stylesheet-reference.html + * http://qt-project.org/doc/qt-4.8/stylesheet-examples.html + */ + +/** + * Text : #88c1d0 + * BG : #0d1f33 + * Lighter : #14283E | #1C324A + * Darker : #071728 | #03101E + * + * Complement : #4E350F + * Lighter : #604419 | #715325 + * Darker : #3D2807 + * Headers : #dca753 + * Input border: #595959 + */ + +/** [VARS] + $text-color = #88c1d0 + $main-color-l = #14283E + $main-color-xl = #1C324A + $main-color-d = #071728 + $main-color-xd = #03101E + $main-color-transparent-1 = rgba(13,31,51,120) + $main-color-transparent-2 = rgba(220,167,83,170) + $shade-transparent-1 = rgba(0,0,0,50) + $shade-transparent-2 = rgba(0,0,0,100) + $main-color = #0d1f33 + $text-grey-d = #0a1827 + $accent-color = #dca753 + $brightest-color = #fff + $input-border-color = #666 + $header-font = "Verdana, Geneva, sans-serif" + $error-color = #FF6363 + $success-color = #73ff00 +[/VARS] */ + +* { gridline-color: $main-color } + +/* Dialog, Window */ +QDialog, QMainWindow { + background-image: url($theme-dir/bg.png); + background-repeat: repeat-xy; +} + +#coinLogo { + qproperty-pixmap: url($theme-dir/hypstk-watermark.png); + qproperty-alignment: 'AlignBottom | AlignLeft'; +} + +/* Frames */ +QFrame { + /* too general - do not style */ +} + +/* Bottom status bar */ +QStatusBar { + background-color: transparent; + color: $text-color; +} + +QStatusBar::item { + border: none; +} + +/* Label */ +QLabel { + color: $text-color; +} + +QLabel[error="true"], QLabel[status="error"] { + color: $error-color; +} + +QLabel[ok="true"], QLabel[status="ok"] { + color: $success-color; +} + +QValidatedLineEdit[error="true"], QDoubleSpinBox[error="true"] { + border-color: $error-color; +} + +/* Frames labels - Balance, Stake, etc. */ + +/* Balance frame */ +QFrame#frame { + background-color: $shade-transparent-1; + border-bottom: 3px solid $shade-transparent-2; + border-right: 3px solid $shade-transparent-2; +} + +/* Recent transactions frame */ +QFrame#frame_2 { + background-color: $shade-transparent-1; + border: none; + border-bottom: 3px solid $shade-transparent-2; + border-right: 3px solid $shade-transparent-2; +} + +/* Panel in Coin Control window */ +QFrame#frame_2 QFrame { + color: $text-color; +} + +QFrame#rangeFrame { + background-color: $shade-transparent-1; + border: none; + margin-top: 10px; +} + +#CoinControlDialog QFrame#frame { + border: none; + border-bottom: 3px solid $shade-transparent-2; + border-right: 3px solid $shade-transparent-2; +} + +QFrame#frameCoinControl { + background-color: $shade-transparent-1; + border: none; + border-bottom: 3px solid $shade-transparent-2; + border-right: 3px solid $shade-transparent-2; +} + +/* Balance value */ +#frame #labelBalance { + color: $brightest-color; + font-size: 14px; +} + +/* Wallet label */ +QFrame#frame #label_5 { + font-size: 15px; + font-family: $header-font; + color: $accent-color; +} + +/* Recent transactions label */ +QFrame#frame_2 #label_4 { + font-size: 15px; + font-family: $header-font; + color: $accent-color; +} + +/* ScrollArea */ +QScrollArea { + background-color: $shade-transparent-1; + border: none; + border-bottom: 3px solid $shade-transparent-2; + border-right: 3px solid $shade-transparent-2; +} + +#scrollAreaWidgetContents { + background-color: transparent; +} +#scrollAreaWidgetContents > QFrame { + background-color: transparent; + border-width: 0px; + border-style: none; +} + +#scrollAreaWidgetContents > QFrame:last { + border-bottom: 1px solid $brightest-color; +} + +#scrollAreaWidgetContents > QFrame:only-one { + border-bottom: none; +} + +/* Text edit fields */ +QPlainTextEdit, QLineEdit { + padding: 4px; + background-color: $main-color; + color: $brightest-color; + border: 1px solid $input-border-color; +} + +QPlainTextEdit:focus, QLineEdit:focus { + border: 1px solid $accent-color; +} + +QPlainTextEdit:disabled, QLineEdit:disabled { + border-color: $main-color-xd; + color: $input-border-color; +} + +/* Text edit - debug window */ +QTextEdit { + padding: 4px; + background-color: transparent; + color: $brightest-color; + border: none; +} + +QTextEdit:disabled { + border-color: $main-color-xd; + color: $input-border-color; +} + +/* Combo box */ +QComboBox { + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 $main-color-xl, stop:1 $main-color); + color: $text-color; + border: 1px solid $input-border-color; + border-radius: 3px; /* same radius as the QComboBox */ + padding: 3px 18px 3px 4px; + min-width: 6em; +} + +QComboBox:on { + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 $main-color, stop:1 $main-color-xl); + border-color: $accent-color; +} + +QComboBox:disabled { + border-color: $main-color-xd; + color: $input-border-color; +} + +QComboBox::drop-down:disabled { + border-color: $input-border-color; +} + +QComboBox::down-arrow { + /* Custom dropdown symbol */ + image: url($theme-dir/down-arrow.png); +} + +QComboBox::down-arrow:disabled { + image: url($theme-dir/down-arrow-disabled.png); +} + +QComboBox::down-arrow:on { + /* Custom dropdown symbol */ + image: url($theme-dir/up-arrow.png); +} + +QComboBox::drop-down { + border: 0px; +} + +QComboBox QAbstractItemView { + border: 1px solid $main-color-xl; + color: $text-color; + background-color: $main-color; + outline: 0px; +} + +QComboBox QListView { + border: none; + selection-color: $main-color; + selection-background-color: $text-color; +} + +/* Up&down spin box */ +QDateTimeEdit, QSpinBox, QDoubleSpinBox { + padding: 3px; + background-color: $main-color; + color: $brightest-color; + border: 1px solid $input-border-color; +} + +QDateTimeEdit:focus, QSpinBox:focus, QDoubleSpinBox:focus { + border-color: $accent-color; +} + +QDateTimeEdit:disabled, QSpinBox:disabled, QDoubleSpinBox:disabled { + border-color: $main-color-xd; + color: $input-border-color; +} + +QDateTimeEdit::down-arrow { + image: url($theme-dir/calendar.png); +} + +QDateTimeEdit::down-arrow:disabled { + image: url($theme-dir/calendar-disabled.png); +} + +QDateTimeEdit::drop-down { + border: 0px; +} + +QDoubleSpinBox::down-button { + image: url($theme-dir/down-arrow.png); +} + +QDoubleSpinBox::up-button { + image: url($theme-dir/up-arrow.png); +} + +/* Button */ +QPushButton { + background-color: qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 1, stop: 0 $text-color, stop: 0.5 $main-color-xd); + color: $text-color; + padding: 4px; + border: 2px solid $text-color; + outline: none; + font-family: $header-font; + font-size: 12px; + border-radius: 3px; + /*min-width: 6em;*/ +} + +QPushButton[text="OK"] { + width: 6em; +} + +QToolButton { + background-color: qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 1, stop: 0 $text-color, stop: 0.5 $main-color-xd); + color: $text-color; + padding: 4px; + border: 2px solid $text-color; + outline: none; + font-family: $header-font; + font-size: 12px; + border-radius: 3px; +} + +QPushButton:hover, QToolButton:hover { + background-color: qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 1, stop: 0 $accent-color, stop: 0.5 $main-color-xd); + color: $accent-color; + border: 2px solid $accent-color; +} + +QPushButton:disabled, QToolButton:disabled { + background-color: $main-color-xd; + border: 2px solid $input-border-color; + color: $main-color-xl; +} + +QPushButton:pressed, QToolButton:pressed { + background-color: $accent-color; + /*border: 2px solid transparent;*/ + color: $main-color-xd; +} + +/* Toolbar */ +QToolBar { + background: $main-color-l; + spacing: 0px; /* spacing between items in the tool bar */ + border-bottom: 3px solid $main-color-xd; + border-top: 1px solid $main-color-xd; + min-height: 40px; + padding: 0px; +} + +QToolBar::handle { + padding: 0px; + background-image: url($theme-dir/toolbar-handle.png); + background-repeat: repeat-y; + background-position: top center; +} + +/* Toolbar buttons */ +QToolBar QToolButton { /* all types of tool button */ + border-radius: 0px; + background-color: transparent; + color: $text-color; + padding: 3px 1px 5px 2px; + font-family: $header-font; + font-size: 12px; + margin-top: 4px; + border: none; + border-top-left-radius: 3px; + border-top-right-radius: 3px; +} + +QToolBar QToolButton:hover { + color: $brightest-color; + background-color: transparent; + border: none; + +} + +QToolBar QToolButton:checked { + background-color: $main-color-xd; + color: $accent-color; + border-bottom: 3px solid $accent-color; + padding: 5px 1px 5px 2px; +} + +QToolBar QToolButton:disabled { + color: $input-border-color; + background-color: transparent; + border: none; +} + +/* Tool buttons - buttons with icons */ +#qt_toolbar_ext_button { + qproperty-icon: url($theme-dir/arrow-down.png); + border-radius: 0px; + margin-top: 3px; + padding: 0px; + border: 0px; + margin-left: -3px; +} + +#addressBookButton, QToolButton#clearButton, QToolButton#pasteButton, QToolButton#deleteButton, +QToolButton#addressBookButton_VM, QToolButton#copySignatureButton_SM, QToolButton#pasteButton_SM, QToolButton#addressBookButton_SM { + min-width: 16px; + max-width: 24px; + padding: 2px; + margin-left: 4px; +} + +/* Progress bar */ +QProgressBar { + border: 1px solid rgba(136,193,208,80); + color: $brightest-color; + font-weight: bold; + background-color: transparent; +} + +QProgressBar::chunk { + background-color: rgba(136,193,208,80); + width: 3px; + margin: 0.5px; +} + +/* Table */ +CoinControlTreeWidget, QTableView { + background: transparent; + alternate-background-color: $main-color-transparent-1; + border-style: none; + border-bottom: 3px solid $shade-transparent-2; + color: $text-color; + selection-background-color: $main-color-transparent-2; + /*selection-color: $main-color-xd;*/ + outline: none; +} + +QTableView QTableCornerButton::section { + border: 0px solid $main-color-xd; + outline: none; +} + +QTableWidget::item:focus { + outline: none; + border: 0px; +} + +QTreeView { + background: transparent; + color: $text-color; + border-style: none; + selection-background-color: $accent-color; + alternate-background-color: $main-color-transparent-1; + selection-color: $main-color-xd; + outline: none; +} + +QTreeView::item { + border: none; + color: $text-color; +} + +QTreeView::item:hover { + color: $brightest-color; +} + +QTreeView::item:selected { + background-color: $main-color-transparent-2; + color: $main-color-xd; +} + +/* Table Header */ +QHeaderView { + color: $brightest-color; + background-color: $main-color; + border-bottom: 1px solid $accent-color; +} + +QHeaderView::section { + color: $accent-color; + background-color: transparent; +} + +QHeaderView::section:checked { + +} + +/* Tooltip */ +QToolTip { + border: 2px outset $main-color-xl; + color: $text-color; + background-color: $main-color; +} + + +/* Menu Bar */ +QMenuBar { + background-color: $text-grey-d; + border: none; +} + +QMenuBar::item { + background: transparent; + color: $text-color; +} + +QMenuBar::item:selected { /* when selected using mouse or keyboard */ + background: $text-color; + color: $text-grey-d; +} + +QMenuBar::item:pressed { + background: $text-color; +} + +/* Menu dialog */ +QMenu { + color: $text-color; + background-color: $text-grey-d; +} + +QMenu::item { + /* sets background of menu item. set this to something non-transparent + if you want menu color and menu item color to be different */ + background-color: transparent; +} + +QMenu::item:selected { /* when user selects item using mouse or keyboard */ + color: $text-grey-d; + background-color: $text-color; +} + +/* Checkbox */ +QCheckBox { + color: $text-color; +} + +QCheckBox::indicator { + width: 13px; + height: 13px; +} + +QCheckBox::indicator:unchecked { + image: url($theme-dir/cb.png); +} + +QCheckBox::indicator:unchecked:hover { + image: url($theme-dir/cb-hover.png); +} + +QCheckBox::indicator:unchecked:pressed { + /*image: url($theme-dir/checkbox_unchecked_pressed.png);*/ +} + +QCheckBox::indicator:checked { + image: url($theme-dir/cb-checked.png); +} + +QCheckBox::indicator:checked:hover { + image: url($theme-dir/cb-checked-hover.png); +} + +QCheckBox::indicator:checked:pressed { + /*image: url($theme-dir/checkbox_checked_pressed.png);*/ +} + +QCheckBox::indicator:indeterminate:hover { + /*image: url($theme-dir/checkbox_indeterminate_hover.png);*/ +} + +QCheckBox::indicator:indeterminate:pressed { + /*image: url($theme-dir/checkbox_indeterminate_pressed.png);*/ +} + +/* Radio button */ +QRadioButton { + color: $text-color; +} + +QRadioButton::indicator { + width: 13px; + height: 13px; +} + +QRadioButton::indicator::unchecked { + image: url($theme-dir/r.png); +} + +QRadioButton::indicator:unchecked:hover { + image: url($theme-dir/r-hover.png); +} + +QRadioButton::indicator:unchecked:pressed { + /*image: url($theme-dir/rpressed.png);*/ +} + +QRadioButton::indicator::checked { + image: url($theme-dir/r-checked.png); +} + +QRadioButton::indicator:checked:hover { + image: url($theme-dir/r-checked-hover.png); +} + +QRadioButton::indicator:checked:pressed { + /*image: url($theme-dir/radiobutton_checked_pressed.png);*/ +} + +/* Tabs */ +QTabWidget { + background: transparent; +} + +QTabWidget::pane { + background-color: $shade-transparent-1; + border-bottom: 3px solid $shade-transparent-2; + border-right: 3px solid $shade-transparent-2; + border-top: 2px solid $main-color-xd; + margin-top: -2px; +} + +QTabWidget::tab-bar { +} + +/* Style the tab using the tab sub-control. Note that it reads QTabBar _not_ QTabWidget */ +QTabBar::tab { + /*background-color: $main-color;*/ + background-color: transparent; + min-width: 26ex; + padding: 6px 4px 8px 4px; + color: $text-color; + margin-right: 2ex; +} + +QTabBar::tab:selected, QTabBar::tab:hover { + border-bottom: 2px solid $accent-color; + background-color: $main-color-xd; + color: $accent-color; + margin-top: 1px; + border-top-left-radius: 3px; + border-top-right-radius: 3px; +} + +QTabBar::tab:!selected { + /*margin-top: 2px;*/ /* make non-selected tabs look smaller */ +} + +/* Scroll bar */ + +QScrollBar:vertical { + background: $main-color-transparent-1; + width: 6px; + margin: 0px 0px 0px 0px; +} + +QScrollBar::handle:vertical { + background: $shade-transparent-2; +} + +QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { + background: none; +} + +QScrollBar::add-line:vertical { + height: 0px; +} + +QScrollBar::sub-line:vertical { + height: 0px; +} + +/* Calendar */ + +/* navigation bar */ +QCalendarWidget QWidget#qt_calendar_navigationbar { background-color: $main-color } +QCalendarWidget QToolButton { +} +QCalendarWidget QMenu { + background-color: $main-color-xd; +} + + /* header row */ +QCalendarWidget QWidget { alternate-background-color: $main-color-l } + +/* normal days */ +QCalendarWidget QAbstractItemView:enabled { + color: $text-color; + background-color: $main-color; + selection-background-color: $accent-color; + selection-color: $main-color-xd; +} + +/* days in other months */ +QCalendarWidget QAbstractItemView:disabled { color: $main-color-xd } + +/* Window resize grip */ +QSizeGrip { + image: url($theme-dir/sizegrip.png); + width: 16px; + height: 16px; +} + +/* QBalloonTip - notification used in Linux - styled by Qt */ +QBalloonTip { + background-color: $main-color-l; + color: $text-color; +} + +QBalloonTip QPushButton { + min-width: 16px; + color: $text-color; + padding: 0px; + border-radius: 0px; + background-color: $text-color; +} + +QBalloonTip QPushButton:hover { + border: none; + background-color: $accent-color; +} diff --git a/src/qt/res/themes/HyperBlue/toolbar-handle.png b/src/qt/res/themes/HyperBlue/toolbar-handle.png new file mode 100644 index 000000000..d5ca69b01 Binary files /dev/null and b/src/qt/res/themes/HyperBlue/toolbar-handle.png differ diff --git a/src/qt/res/themes/HyperBlue/up-arrow-disabled.png b/src/qt/res/themes/HyperBlue/up-arrow-disabled.png new file mode 100644 index 000000000..72b862032 Binary files /dev/null and b/src/qt/res/themes/HyperBlue/up-arrow-disabled.png differ diff --git a/src/qt/res/themes/HyperBlue/up-arrow.png b/src/qt/res/themes/HyperBlue/up-arrow.png new file mode 100644 index 000000000..7bbd8b830 Binary files /dev/null and b/src/qt/res/themes/HyperBlue/up-arrow.png differ diff --git a/src/qt/res/themes/Magma/arrow-down.png b/src/qt/res/themes/Magma/arrow-down.png new file mode 100644 index 000000000..21185fa87 Binary files /dev/null and b/src/qt/res/themes/Magma/arrow-down.png differ diff --git a/src/qt/res/themes/Magma/calendar-disabled.png b/src/qt/res/themes/Magma/calendar-disabled.png new file mode 100644 index 000000000..df41dc7e3 Binary files /dev/null and b/src/qt/res/themes/Magma/calendar-disabled.png differ diff --git a/src/qt/res/themes/Magma/calendar.png b/src/qt/res/themes/Magma/calendar.png new file mode 100644 index 000000000..c23747b2c Binary files /dev/null and b/src/qt/res/themes/Magma/calendar.png differ diff --git a/src/qt/res/themes/Magma/cb-checked-hover.png b/src/qt/res/themes/Magma/cb-checked-hover.png new file mode 100644 index 000000000..142238454 Binary files /dev/null and b/src/qt/res/themes/Magma/cb-checked-hover.png differ diff --git a/src/qt/res/themes/Magma/cb-checked.png b/src/qt/res/themes/Magma/cb-checked.png new file mode 100644 index 000000000..69a4e9dc3 Binary files /dev/null and b/src/qt/res/themes/Magma/cb-checked.png differ diff --git a/src/qt/res/themes/Magma/cb-hover.png b/src/qt/res/themes/Magma/cb-hover.png new file mode 100644 index 000000000..dd261e607 Binary files /dev/null and b/src/qt/res/themes/Magma/cb-hover.png differ diff --git a/src/qt/res/themes/Magma/cb.png b/src/qt/res/themes/Magma/cb.png new file mode 100644 index 000000000..ed6ca35dc Binary files /dev/null and b/src/qt/res/themes/Magma/cb.png differ diff --git a/src/qt/res/themes/Magma/down-arrow-disabled.png b/src/qt/res/themes/Magma/down-arrow-disabled.png new file mode 100644 index 000000000..f4a9accea Binary files /dev/null and b/src/qt/res/themes/Magma/down-arrow-disabled.png differ diff --git a/src/qt/res/themes/Magma/down-arrow.png b/src/qt/res/themes/Magma/down-arrow.png new file mode 100644 index 000000000..ac99ab23e Binary files /dev/null and b/src/qt/res/themes/Magma/down-arrow.png differ diff --git a/src/qt/res/themes/Magma/hypstk-watermark.png b/src/qt/res/themes/Magma/hypstk-watermark.png new file mode 100644 index 000000000..83f9d6ce7 Binary files /dev/null and b/src/qt/res/themes/Magma/hypstk-watermark.png differ diff --git a/src/qt/res/themes/Magma/magma.png b/src/qt/res/themes/Magma/magma.png new file mode 100644 index 000000000..3132f2753 Binary files /dev/null and b/src/qt/res/themes/Magma/magma.png differ diff --git a/src/qt/res/themes/Magma/r-checked-hover.png b/src/qt/res/themes/Magma/r-checked-hover.png new file mode 100644 index 000000000..d9843b0ef Binary files /dev/null and b/src/qt/res/themes/Magma/r-checked-hover.png differ diff --git a/src/qt/res/themes/Magma/r-checked.png b/src/qt/res/themes/Magma/r-checked.png new file mode 100644 index 000000000..ba5ae9429 Binary files /dev/null and b/src/qt/res/themes/Magma/r-checked.png differ diff --git a/src/qt/res/themes/Magma/r-hover.png b/src/qt/res/themes/Magma/r-hover.png new file mode 100644 index 000000000..8af84c6af Binary files /dev/null and b/src/qt/res/themes/Magma/r-hover.png differ diff --git a/src/qt/res/themes/Magma/r.png b/src/qt/res/themes/Magma/r.png new file mode 100644 index 000000000..d9c07b819 Binary files /dev/null and b/src/qt/res/themes/Magma/r.png differ diff --git a/src/qt/res/themes/Magma/sizegrip.png b/src/qt/res/themes/Magma/sizegrip.png new file mode 100644 index 000000000..a2c4845ea Binary files /dev/null and b/src/qt/res/themes/Magma/sizegrip.png differ diff --git a/src/qt/res/themes/Magma/styles.qss b/src/qt/res/themes/Magma/styles.qss new file mode 100644 index 000000000..45ff2a26d --- /dev/null +++ b/src/qt/res/themes/Magma/styles.qss @@ -0,0 +1,711 @@ +/** + * Magma Qt Theme - v1.0 + * Created: 24/10/2014 + * Author: ShrykeZ (Based on HyperBlue by Zeewolf) - ##hyperstake (freenode) + * HyperStake - faster than light! + */ + +/** + * QSS REFERENCE : + * http://qt-project.org/doc/qt-4.8/stylesheet-reference.html + * http://qt-project.org/doc/qt-4.8/stylesheet-examples.html + */ + +/** [VARS] + $text-color = #E5E4E2 + $main-color-l = #3D3C3A + $main-color-xl = #565051 + $main-color-d = #2C3539 + $main-color-xd = #0C090A + $main-color-transparent-0 = rgba(51,0,0,200) + $main-color-transparent-1 = rgba(102,0,0,200) + $main-color-transparent-2 = rgba(255,0,0,200) + $shade-transparent-1 = rgba(0,0,0,200) + $shade-transparent-2 = rgba(0,0,0,200) + $main-color = #800517 + $text-grey-d = #800517 + $accent-color = #dca753 + $brightest-color = #fff + $input-border-color = #BCC6CC + $header-font = "Verdana, Geneva, sans-serif" + $error-color = #FF0000 + $success-color = #00FF00 +[/VARS] */ + +* { gridline-color: $main-color } + +/* Dialog, Window */ +QDialog, QMainWindow { + background-image: url($theme-dir/magma.png); + background-repeat: repeat-xy; +} + +#coinLogo { + qproperty-pixmap: url($theme-dir/hypstk-watermark.png); + qproperty-alignment: 'AlignBottom | AlignLeft'; +} + +/* Frames */ +QFrame { + /* too general - do not style */ +} + +/* Bottom status bar */ +QStatusBar { + background-color: transparent; + color: $text-color; +} + +QStatusBar::item { + border: none; +} + +/* Label */ +QLabel { + color: $text-color; +} + +QLabel[error="true"], QLabel[status="error"] { + color: $error-color; +} + +QLabel[ok="true"], QLabel[status="ok"] { + color: $success-color; +} + +QValidatedLineEdit[error="true"], QDoubleSpinBox[error="true"] { + border-color: $error-color; +} + +/* Frames labels - Balance, Stake, etc. */ + +/* Balance frame */ +QFrame#frame { + background-color: $shade-transparent-1; + border-bottom: 3px solid $shade-transparent-2; + border-right: 3px solid $shade-transparent-2; +} + +/* Recent transactions frame */ +QFrame#frame_2 { + background-color: $shade-transparent-1; + border: none; + border-bottom: 3px solid $shade-transparent-2; + border-right: 3px solid $shade-transparent-2; +} + +/* Panel in Coin Control window */ +QFrame#frame_2 QFrame { + color: $text-color; +} + +QFrame#rangeFrame { + background-color: $shade-transparent-1; + border: none; + margin-top: 10px; +} + +#CoinControlDialog QFrame#frame { + border: none; + border-bottom: 3px solid $shade-transparent-2; + border-right: 3px solid $shade-transparent-2; +} + +QFrame#frameCoinControl { + background-color: $shade-transparent-1; + border: none; + border-bottom: 3px solid $shade-transparent-2; + border-right: 3px solid $shade-transparent-2; +} + +/* Balance value */ +#frame #labelBalance { + color: $brightest-color; + font-size: 14px; +} + +/* Wallet label */ +QFrame#frame #label_5 { + font-size: 15px; + font-family: $header-font; + color: $accent-color; +} + +/* Recent transactions label */ +QFrame#frame_2 #label_4 { + font-size: 15px; + font-family: $header-font; + color: $accent-color; +} + +/* ScrollArea */ +QScrollArea { + background-color: $shade-transparent-1; + border: none; + border-bottom: 3px solid $shade-transparent-2; + border-right: 3px solid $shade-transparent-2; +} + +#scrollAreaWidgetContents { + background-color: transparent; +} +#scrollAreaWidgetContents > QFrame { + background-color: transparent; + border-width: 0px; + border-style: none; +} + +#scrollAreaWidgetContents > QFrame:last { + border-bottom: 1px solid $brightest-color; +} + +#scrollAreaWidgetContents > QFrame:only-one { + border-bottom: none; +} + +/* Text edit fields */ +QPlainTextEdit, QLineEdit { + padding: 4px; + background-color: $main-color; + color: $brightest-color; + border: 1px solid $input-border-color; +} + +QPlainTextEdit:focus, QLineEdit:focus { + border: 1px solid $accent-color; +} + +QPlainTextEdit:disabled, QLineEdit:disabled { + border-color: $main-color-xd; + color: $input-border-color; +} + +/* Text edit - debug window */ +QTextEdit { + padding: 4px; + background-color: transparent; + color: $brightest-color; + border: none; +} + +QTextEdit:disabled { + border-color: $main-color-xd; + color: $input-border-color; +} + +/* Combo box */ +QComboBox { + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 $main-color-xl, stop:1 $main-color); + color: $text-color; + border: 1px solid $input-border-color; + border-radius: 3px; /* same radius as the QComboBox */ + padding: 3px 18px 3px 4px; + min-width: 6em; +} + +QComboBox:on { + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 $main-color, stop:1 $main-color-xl); + border-color: $accent-color; +} + +QComboBox:disabled { + border-color: $main-color-xd; + color: $input-border-color; +} + +QComboBox::drop-down:disabled { + border-color: $input-border-color; +} + +QComboBox::down-arrow { + /* Custom dropdown symbol */ + image: url($theme-dir/down-arrow.png); +} + +QComboBox::down-arrow:disabled { + image: url($theme-dir/down-arrow-disabled.png); +} + +QComboBox::down-arrow:on { + /* Custom dropdown symbol */ + image: url($theme-dir/up-arrow.png); +} + +QComboBox::drop-down { + border: 0px; +} + +QComboBox QAbstractItemView { + border: 1px solid $main-color-xl; + color: $text-color; + background-color: $main-color; + outline: 0px; +} + +QComboBox QListView { + border: none; + selection-color: $main-color; + selection-background-color: $text-color; +} + +/* Up&down spin box */ +QDateTimeEdit, QSpinBox, QDoubleSpinBox { + padding: 3px; + background-color: $main-color; + color: $brightest-color; + border: 1px solid $input-border-color; +} + +QDateTimeEdit:focus, QSpinBox:focus, QDoubleSpinBox:focus { + border-color: $accent-color; +} + +QDateTimeEdit:disabled, QSpinBox:disabled, QDoubleSpinBox:disabled { + border-color: $main-color-xd; + color: $input-border-color; +} + +QDateTimeEdit::down-arrow { + image: url($theme-dir/calendar.png); +} + +QDateTimeEdit::down-arrow:disabled { + image: url($theme-dir/calendar-disabled.png); +} + +QDateTimeEdit::drop-down { + border: 0px; +} + +QDoubleSpinBox::down-button { + image: url($theme-dir/down-arrow.png); +} + +QDoubleSpinBox::up-button { + image: url($theme-dir/up-arrow.png); +} + +/* Button */ +QPushButton { + background-color: qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 1, stop: 0 $text-color, stop: 0.5 $main-color-xd); + color: $text-color; + padding: 4px; + border: 2px solid $text-color; + outline: none; + font-family: $header-font; + font-size: 12px; + border-radius: 3px; + /*min-width: 6em;*/ +} + +QPushButton[text="OK"] { + width: 6em; +} + +QToolButton { + background-color: qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 1, stop: 0 $text-color, stop: 0.5 $main-color-xd); + color: $text-color; + padding: 4px; + border: 2px solid $text-color; + outline: none; + font-family: $header-font; + font-size: 12px; + border-radius: 3px; +} + +QPushButton:hover, QToolButton:hover { + background-color: qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 1, stop: 0 $accent-color, stop: 0.5 $main-color-xd); + color: $accent-color; + border: 2px solid $accent-color; +} + +QPushButton:disabled, QToolButton:disabled { + background-color: $main-color-xd; + border: 2px solid $input-border-color; + color: $main-color-xl; +} + +QPushButton:pressed, QToolButton:pressed { + background-color: $accent-color; + /*border: 2px solid transparent;*/ + color: $main-color-xd; +} + +/* Toolbar */ +QToolBar { + background: $main-color-l; + spacing: 0px; /* spacing between items in the tool bar */ + border-bottom: 3px solid $main-color-xd; + border-top: 1px solid $main-color-xd; + min-height: 40px; + padding: 0px; +} + +QToolBar::handle { + padding: 0px; + background-image: url($theme-dir/toolbar-handle.png); + background-repeat: repeat-y; + background-position: top center; +} + +/* Toolbar buttons */ +QToolBar QToolButton { /* all types of tool button */ + border-radius: 0px; + background-color: transparent; + color: $text-color; + padding: 3px 1px 5px 2px; + font-family: $header-font; + font-size: 12px; + margin-top: 4px; + border: none; + border-top-left-radius: 3px; + border-top-right-radius: 3px; +} + +QToolBar QToolButton:hover { + color: $brightest-color; + background-color: transparent; + border: none; + +} + +QToolBar QToolButton:checked { + background-color: $main-color-xd; + color: $accent-color; + border-bottom: 3px solid $accent-color; + padding: 5px 1px 5px 2px; +} + +QToolBar QToolButton:disabled { + color: $input-border-color; + background-color: transparent; + border: none; +} + +/* Tool buttons - buttons with icons */ +#qt_toolbar_ext_button { + qproperty-icon: url($theme-dir/arrow-down.png); + border-radius: 0px; + margin-top: 3px; + padding: 0px; + border: 0px; + margin-left: -3px; +} + +#addressBookButton, QToolButton#clearButton, QToolButton#pasteButton, QToolButton#deleteButton, +QToolButton#addressBookButton_VM, QToolButton#copySignatureButton_SM, QToolButton#pasteButton_SM, QToolButton#addressBookButton_SM { + min-width: 16px; + max-width: 24px; + padding: 2px; + margin-left: 4px; +} + +/* Progress bar */ +QProgressBar { + border: 1px solid rgba(136,193,208,80); + color: $brightest-color; + font-weight: bold; + background-color: transparent; +} + +QProgressBar::chunk { + background-color: rgba(136,193,208,80); + width: 3px; + margin: 0.5px; +} + +/* Table */ +CoinControlTreeWidget, QTableView { + background: $main-color-transparent-0; + alternate-background-color: $main-color-transparent-1; + border-style: none; + border-bottom: 3px solid $shade-transparent-2; + color: $text-color; + selection-background-color: $main-color-transparent-2; + /*selection-color: $main-color-xd;*/ + outline: none; +} + +QTableView QTableCornerButton::section { + border: 0px solid $main-color-xd; + outline: none; +} + +QTableWidget::item:focus { + outline: none; + border: 0px; +} + +QTreeView { + background: $main-color-transparent-0; + color: $text-color; + border-style: none; + selection-background-color: $accent-color; + alternate-background-color: $main-color-transparent-1; + selection-color: $main-color-xd; + outline: none; +} + +QTreeView::item { + border: none; + color: $text-color; +} + +QTreeView::item:hover { + color: $brightest-color; +} + +QTreeView::item:selected { + background-color: $main-color-transparent-2; + color: $main-color-xd; +} + +/* Table Header */ +QHeaderView { + color: $brightest-color; + background-color: $main-color; + border-bottom: 1px solid $accent-color; +} + +QHeaderView::section { + color: $accent-color; + background-color: transparent; +} + +QHeaderView::section:checked { + +} + +/* Tooltip */ +QToolTip { + border: 2px outset $main-color-xl; + color: $text-color; + background-color: $main-color; +} + + +/* Menu Bar */ +QMenuBar { + background-color: $text-grey-d; + border: none; +} + +QMenuBar::item { + background: transparent; + color: $text-color; +} + +QMenuBar::item:selected { /* when selected using mouse or keyboard */ + background: $text-color; + color: $text-grey-d; +} + +QMenuBar::item:pressed { + background: $text-color; +} + +/* Menu dialog */ +QMenu { + color: $text-color; + background-color: $text-grey-d; +} + +QMenu::item { + /* sets background of menu item. set this to something non-transparent + if you want menu color and menu item color to be different */ + background-color: transparent; +} + +QMenu::item:selected { /* when user selects item using mouse or keyboard */ + color: $text-grey-d; + background-color: $text-color; +} + +/* Checkbox */ +QCheckBox { + color: $text-color; +} + +QCheckBox::indicator { + width: 13px; + height: 13px; +} + +QCheckBox::indicator:unchecked { + image: url($theme-dir/cb.png); +} + +QCheckBox::indicator:unchecked:hover { + image: url($theme-dir/cb-hover.png); +} + +QCheckBox::indicator:unchecked:pressed { + /*image: url($theme-dir/checkbox_unchecked_pressed.png);*/ +} + +QCheckBox::indicator:checked { + image: url($theme-dir/cb-checked.png); +} + +QCheckBox::indicator:checked:hover { + image: url($theme-dir/cb-checked-hover.png); +} + +QCheckBox::indicator:checked:pressed { + /*image: url($theme-dir/checkbox_checked_pressed.png);*/ +} + +QCheckBox::indicator:indeterminate:hover { + /*image: url($theme-dir/checkbox_indeterminate_hover.png);*/ +} + +QCheckBox::indicator:indeterminate:pressed { + /*image: url($theme-dir/checkbox_indeterminate_pressed.png);*/ +} + +/* Radio button */ +QRadioButton { + color: $text-color; +} + +QRadioButton::indicator { + width: 13px; + height: 13px; +} + +QRadioButton::indicator::unchecked { + image: url($theme-dir/r.png); +} + +QRadioButton::indicator:unchecked:hover { + image: url($theme-dir/r-hover.png); +} + +QRadioButton::indicator:unchecked:pressed { + /*image: url($theme-dir/rpressed.png);*/ +} + +QRadioButton::indicator::checked { + image: url($theme-dir/r-checked.png); +} + +QRadioButton::indicator:checked:hover { + image: url($theme-dir/r-checked-hover.png); +} + +QRadioButton::indicator:checked:pressed { + /*image: url($theme-dir/radiobutton_checked_pressed.png);*/ +} + +/* Tabs */ +QTabWidget { + background: transparent; +} + +QTabWidget::pane { + background-color: $shade-transparent-1; + border-bottom: 3px solid $shade-transparent-2; + border-right: 3px solid $shade-transparent-2; + border-top: 2px solid $main-color-xd; + margin-top: -2px; +} + +QTabWidget::tab-bar { +} + +/* Style the tab using the tab sub-control. Note that it reads QTabBar _not_ QTabWidget */ +QTabBar::tab { + /*background-color: $main-color;*/ + background-color: transparent; + min-width: 26ex; + padding: 6px 4px 8px 4px; + color: $text-color; + margin-right: 2ex; +} + +QTabBar::tab:selected, QTabBar::tab:hover { + border-bottom: 2px solid $accent-color; + background-color: $main-color-xd; + color: $accent-color; + margin-top: 1px; + border-top-left-radius: 3px; + border-top-right-radius: 3px; +} + +QTabBar::tab:!selected { + /*margin-top: 2px;*/ /* make non-selected tabs look smaller */ +} + +/* Scroll bar */ + +QScrollBar:vertical { + background: $main-color-transparent-1; + width: 6px; + margin: 0px 0px 0px 0px; +} + +QScrollBar::handle:vertical { + background: $shade-transparent-2; +} + +QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { + background: none; +} + +QScrollBar::add-line:vertical { + height: 0px; +} + +QScrollBar::sub-line:vertical { + height: 0px; +} + +/* Calendar */ + +/* navigation bar */ +QCalendarWidget QWidget#qt_calendar_navigationbar { background-color: $main-color } +QCalendarWidget QToolButton { +} +QCalendarWidget QMenu { + background-color: $main-color-xd; +} + + /* header row */ +QCalendarWidget QWidget { alternate-background-color: $main-color-l } + +/* normal days */ +QCalendarWidget QAbstractItemView:enabled { + color: $text-color; + background-color: $main-color; + selection-background-color: $accent-color; + selection-color: $main-color-xd; +} + +/* days in other months */ +QCalendarWidget QAbstractItemView:disabled { color: $main-color-xd } + +/* Window resize grip */ +QSizeGrip { + image: url($theme-dir/sizegrip.png); + width: 16px; + height: 16px; +} + +/* QBalloonTip - notification used in Linux - styled by Qt */ +QBalloonTip { + background-color: $main-color-l; + color: $text-color; +} + +QBalloonTip QPushButton { + min-width: 16px; + color: $text-color; + padding: 0px; + border-radius: 0px; + background-color: $text-color; +} + +QBalloonTip QPushButton:hover { + border: none; + background-color: $accent-color; +} diff --git a/src/qt/res/themes/Magma/toolbar-handle.png b/src/qt/res/themes/Magma/toolbar-handle.png new file mode 100644 index 000000000..0bfe4b59e Binary files /dev/null and b/src/qt/res/themes/Magma/toolbar-handle.png differ diff --git a/src/qt/res/themes/Magma/up-arrow-disabled.png b/src/qt/res/themes/Magma/up-arrow-disabled.png new file mode 100644 index 000000000..7f1f501c5 Binary files /dev/null and b/src/qt/res/themes/Magma/up-arrow-disabled.png differ diff --git a/src/qt/res/themes/Magma/up-arrow.png b/src/qt/res/themes/Magma/up-arrow.png new file mode 100644 index 000000000..8e1cff91b Binary files /dev/null and b/src/qt/res/themes/Magma/up-arrow.png differ diff --git a/src/qt/res/themes/PoloniexDay/arrow-down.png b/src/qt/res/themes/PoloniexDay/arrow-down.png new file mode 100644 index 000000000..abbe63ccd Binary files /dev/null and b/src/qt/res/themes/PoloniexDay/arrow-down.png differ diff --git a/src/qt/res/themes/PoloniexDay/calendar-disabled.png b/src/qt/res/themes/PoloniexDay/calendar-disabled.png new file mode 100644 index 000000000..97a36c3c3 Binary files /dev/null and b/src/qt/res/themes/PoloniexDay/calendar-disabled.png differ diff --git a/src/qt/res/themes/PoloniexDay/calendar.png b/src/qt/res/themes/PoloniexDay/calendar.png new file mode 100644 index 000000000..b2f90452b Binary files /dev/null and b/src/qt/res/themes/PoloniexDay/calendar.png differ diff --git a/src/qt/res/themes/PoloniexDay/cb-checked-hover.png b/src/qt/res/themes/PoloniexDay/cb-checked-hover.png new file mode 100644 index 000000000..04ced7ae1 Binary files /dev/null and b/src/qt/res/themes/PoloniexDay/cb-checked-hover.png differ diff --git a/src/qt/res/themes/PoloniexDay/cb-checked.png b/src/qt/res/themes/PoloniexDay/cb-checked.png new file mode 100644 index 000000000..8c9993f89 Binary files /dev/null and b/src/qt/res/themes/PoloniexDay/cb-checked.png differ diff --git a/src/qt/res/themes/PoloniexDay/cb-hover.png b/src/qt/res/themes/PoloniexDay/cb-hover.png new file mode 100644 index 000000000..a7e9a393e Binary files /dev/null and b/src/qt/res/themes/PoloniexDay/cb-hover.png differ diff --git a/src/qt/res/themes/PoloniexDay/cb.png b/src/qt/res/themes/PoloniexDay/cb.png new file mode 100644 index 000000000..986a9165c Binary files /dev/null and b/src/qt/res/themes/PoloniexDay/cb.png differ diff --git a/src/qt/res/themes/PoloniexDay/down-arrow-disabled.png b/src/qt/res/themes/PoloniexDay/down-arrow-disabled.png new file mode 100644 index 000000000..46d3baa59 Binary files /dev/null and b/src/qt/res/themes/PoloniexDay/down-arrow-disabled.png differ diff --git a/src/qt/res/themes/PoloniexDay/down-arrow.png b/src/qt/res/themes/PoloniexDay/down-arrow.png new file mode 100644 index 000000000..dd66e6dfd Binary files /dev/null and b/src/qt/res/themes/PoloniexDay/down-arrow.png differ diff --git a/src/qt/res/themes/PoloniexDay/hypstk-watermark.png b/src/qt/res/themes/PoloniexDay/hypstk-watermark.png new file mode 100644 index 000000000..cd9aaab85 Binary files /dev/null and b/src/qt/res/themes/PoloniexDay/hypstk-watermark.png differ diff --git a/src/qt/res/themes/PoloniexDay/r-checked-hover.png b/src/qt/res/themes/PoloniexDay/r-checked-hover.png new file mode 100644 index 000000000..d1055b213 Binary files /dev/null and b/src/qt/res/themes/PoloniexDay/r-checked-hover.png differ diff --git a/src/qt/res/themes/PoloniexDay/r-checked.png b/src/qt/res/themes/PoloniexDay/r-checked.png new file mode 100644 index 000000000..f267e78dd Binary files /dev/null and b/src/qt/res/themes/PoloniexDay/r-checked.png differ diff --git a/src/qt/res/themes/PoloniexDay/r-hover.png b/src/qt/res/themes/PoloniexDay/r-hover.png new file mode 100644 index 000000000..9e10a855d Binary files /dev/null and b/src/qt/res/themes/PoloniexDay/r-hover.png differ diff --git a/src/qt/res/themes/PoloniexDay/r.png b/src/qt/res/themes/PoloniexDay/r.png new file mode 100644 index 000000000..fba9037c0 Binary files /dev/null and b/src/qt/res/themes/PoloniexDay/r.png differ diff --git a/src/qt/res/themes/PoloniexDay/sizegrip.png b/src/qt/res/themes/PoloniexDay/sizegrip.png new file mode 100644 index 000000000..9fab9e10a Binary files /dev/null and b/src/qt/res/themes/PoloniexDay/sizegrip.png differ diff --git a/src/qt/res/themes/PoloniexDay/styles.qss b/src/qt/res/themes/PoloniexDay/styles.qss new file mode 100644 index 000000000..96f32e7e2 --- /dev/null +++ b/src/qt/res/themes/PoloniexDay/styles.qss @@ -0,0 +1,736 @@ +/** + * PoloniexDay Qt theme - v1.0 + * Last changed: 2014-10-09 + * Author: ZeeWolf - ##hyperstake (freenode) + * HyperStake - faster than light! + */ + +/** + * QSS REFERENCE : + * http://qt-project.org/doc/qt-4.8/stylesheet-reference.html + * http://qt-project.org/doc/qt-4.8/stylesheet-examples.html + */ + +/** + * Colors : + * + * BG top : #86a9a3 * + * BG bottom : #9ab7b4 * + * BG panel : #c8c8c8 * + * Text : #3a4449 * + * Text lighter : #3b444a * + * Complement : #e49806 + * Top-bar : rgb(250,250,254) - rgb(225,225,230) * + * Top-bar-border : #BCC1C4 * + * Tab-color-1 : #e1e1e6 * + * Tab-color-2 : #fafafe * + * Tab-hover-1 : #cdcdd2 * + * Tab-hover-2 : #e6e6ea * + * Body : #434d52 - #273034 + * Input border: #ABADB3 * + * Input bg : #fff * + * Input focus : #A5C7FE * + * Button bg : #fef8ed * + * Button border : #e0ceac * + * Button bg hover : #e49806 * + * Button bg text hover : #ffffff * + * Table header : rgb(211,231,217) * + * Table row even : #fff * + * Table row odd : #eef7ef * + * Table grid : #fff * + * Tooltip bg : #fff * + * Tooltip border : #86a9a3 * + */ + +/** [VARS] + $header-text = font-size: 24px; font-family: "Times New Roman"; color: rgb(60,60,60) + $custom-font-1 = font-family: "Times New Roman" + $top-bar-color-1 = rgb(250,250,254) + $top-bar-color-2 = rgb(225,225,230) + $top-bar-border-color = #BCC1C4 + $tab-color-1 = #e1e1e6 + $tab-color-2 = #fafafe + $tab-hover-color-1 = #cdcdd2 + $tab-hover-color-2 = #e6e6ea + $text-color = #3a4449 + $text-lighter-color = #3b444a + $panel = background-color: #fff; border-radius: 7px; border: 0 + $bg-top = #86a9a3 + $bg-bottom = #9ab7b4 + $bg-panel = #fff + $input-bg-color = #fff + $input-border-color = #ABADB3 + $input-border-focus-color = #A5C7FE + $button-bg-color = #fef8ed + $button-bg-hover-color = #e49806 + $button-border-color = #e0ceac + $button-text-hover-color = #ffffff + $grid-color = #fff + $table-header-bg = #D3E7D9 + $table-row-bg = #fff + $table-row-alternate = #eef7ef + $tooltip-bg-color = #fff + $tooltip-border-color = #0a1827 + $main-color = #fff + $text-grey-d = #0a1827 + $accent-color = #c28208 + $accent-color-2 = #faf5db + $brightest-color = #fff + $header-font = "Verdana, Geneva, sans-serif" + $focused-input = border: 2px solid #3D639D; border-radius: 2px + $error-color = #b41d1d + $success-color = #209e29 + $footer-top = rgb(59,68,74) + $footer-bottom = rgb(51,58,62) + $footer-edge = #e39706 + $black = #000 +[/VARS] */ + +* { gridline-color: $grid-color } + +/* Dialog, Window */ +QDialog, QMainWindow { + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 $bg-top, stop:0.5 $bg-bottom, stop:1 $bg-top); +} + +#coinLogo { + qproperty-pixmap: url($theme-dir/hypstk-watermark.png); + qproperty-alignment: 'AlignBottom | AlignLeft'; +} + +/* Frames */ +QFrame { + /* too general - do not style */ +} + +/* Bottom status bar */ +QStatusBar { + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 $footer-top, stop:1 $footer-bottom); + border-top: 1px solid $footer-edge; + color: $brightest-color; +} + +QStatusBar QLabel { + color: $brightest-color; +} + +QStatusBar::item { + border: none; + color: $brightest-color; +} + +/* Label */ +QLabel { + color: $text-color; +} + +QLabel[error="true"], QLabel[status="error"] { + color: $error-color; +} + +QLabel[ok="true"], QLabel[status="ok"] { + color: $success-color; +} + +QValidatedLineEdit[error="true"], QDoubleSpinBox[error="true"] { + border-color: $error-color; +} + +/* Frames labels - Balance, Stake, etc. */ + +/* Balance frame */ +QFrame#frame { + $panel; +} + +/* Recent transactions frame */ +QFrame#frame_2 { + $panel; +} + +/* Panel in Coin Control window */ +QFrame#frame_2 QFrame { + color: $text-color; +} + +QFrame#rangeFrame { + $panel; + margin-top: 10px; +} + +#CoinControlDialog QFrame#frame { + $panel; +} + +QFrame#frameCoinControl { + $panel; +} + +/* Balance value */ +#frame #labelBalance { + font-size: 14px; +} + +/* Wallet label */ +QFrame#frame #label_5 { + $header-text; +} + +/* Recent transactions label */ +QFrame#frame_2 #label_4 { + $header-text; +} + +/* ScrollArea */ +QScrollArea { + $panel; +} + +#scrollAreaWidgetContents { + background-color: transparent; +} + +#scrollAreaWidgetContents > QFrame { + background-color: transparent; + border-width: 0px; + border-style: none; +} + +#scrollAreaWidgetContents > QFrame:last { + border-bottom: 1px solid $brightest-color; +} + +#scrollAreaWidgetContents > QFrame:only-one { + border-bottom: none; +} + +/* Text edit fields */ +QPlainTextEdit, QLineEdit { + padding: 4px; + background-color: $input-bg-color; + color: $text-color; + border: 1px solid $input-border-color; +} + +QPlainTextEdit:focus, QLineEdit:focus { + $focused-input; + padding: 3px; +} + +QPlainTextEdit:disabled, QLineEdit:disabled { + color: $input-border-color; +} + +/* Text edit - debug window */ +QTextEdit { + padding: 4px; + background-color: $input-bg-color; + color: $text-color; + border: 1px solid $input-border-color; +} + +QTextEdit:disabled { + border-color: $top-bar-border-color; + color: $input-border-color; +} + +/* Combo box */ +QComboBox { + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 $tab-color-2, stop:1 $tab-color-1); + color: $text-color; + border: 1px solid $input-border-color; + border-radius: 3px; /* same radius as the QComboBox */ + padding: 4px 18px 4px 4px; + min-width: 6em; +} + +QComboBox:on { + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 $tab-color-1, stop:1 $tab-color-2); +} + +QComboBox:disabled { + border-color: $top-bar-border-color; + color: $input-border-color; +} + +QComboBox::drop-down:disabled { + border-color: $input-border-color; +} + +QComboBox::down-arrow { + /* Custom dropdown symbol */ + image: url($theme-dir/down-arrow.png); +} + +QComboBox::down-arrow:disabled { + image: url($theme-dir/down-arrow-disabled.png); +} + +QComboBox::down-arrow:on { + /* Custom dropdown symbol */ + image: url($theme-dir/up-arrow.png); +} + +QComboBox::drop-down { + border: 0px; +} + +QComboBox QAbstractItemView { + border: 1px solid $tooltip-border-color; + color: $text-color; + background-color: $tooltip-bg-color; + outline: 0px; +} + +QComboBox QListView { + border: none; + selection-color: $black; + selection-background-color: $accent-color-2; +} + +/* Up&down spin box */ +QDateTimeEdit, QSpinBox, QDoubleSpinBox { + padding: 3px; + background-color: $input-bg-color; + color: $text-color; + border: 1px solid $input-border-color; +} + +QDateTimeEdit:focus, QSpinBox:focus, QDoubleSpinBox:focus { + border-color: $accent-color; +} +QDateTimeEdit:disabled, QSpinBox:disabled, QDoubleSpinBox:disabled { + border-color: $top-bar-border-color; + color: $input-border-color; +} + +QDateTimeEdit::down-arrow { + image: url($theme-dir/calendar.png); +} + +QDateTimeEdit::down-arrow:disabled { + image: url($theme-dir/calendar-disabled.png); +} + +QDateTimeEdit::drop-down { + border: 0px; +} + +QDoubleSpinBox::down-button { + image: url($theme-dir/down-arrow.png); +} + +QDoubleSpinBox::up-button { + image: url($theme-dir/up-arrow.png); +} + +/* Button */ +QPushButton { + background-color: $button-bg-color; + border: 1px solid $button-border-color; + border-radius: 3px; + color: $text-color; + font-family: $header-font; + font-size: 12px; + /*min-width: 6em;*/ + outline: none; + padding: 4px; +} + +QPushButton[text="OK"], QPushButton[text="Yes"] { + width: 6em; +} +QToolButton { + background-color: $button-bg-color; + border: 1px solid $button-border-color; + border-radius: 3px; + color: $text-color; + font-family: $header-font; + font-size: 12px; + outline: none; + padding: 4px; +} + +QPushButton:hover, QToolButton:hover { + background-color: $button-bg-hover-color; + color: $button-text-hover-color; +} + +QPushButton:disabled, QToolButton:disabled { + background-color: $button-border-color; + color: $tab-color-2; + border: 1px solid $button-bg-color; +} + +/* Toolbar */ +QToolBar { + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 $top-bar-color-1, stop:1 $top-bar-color-2); + spacing: 3px; /* spacing between items in the tool bar */ + margin-bottom: 0px; + border: none; + border-bottom: 1px solid $top-bar-border-color; +} + +QToolBar::handle { + padding: 0px; + background-color: transparent; +} + +/* Toolbar buttons */ +QToolBar QToolButton { /* all types of tool button */ + border: 1px solid $top-bar-border-color; + background: transparent; + color: $text-lighter-color; + padding: 4px 2px; + font-size: 14px; + border-top-left-radius: 5px; + border-top-right-radius: 5px; + border-bottom-left-radius: 0px; + border-bottom-right-radius: 0px; + $custom-font-1; + margin-top: 12px; +} + +QToolBar QToolButton:hover { + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 $tab-hover-color-2, stop:1 $tab-hover-color-1); + color: $black; +} + +QToolBar QToolButton:checked { + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 $tab-color-1, stop:1 $tab-color-2); + border-bottom-color: $bg-top; + color: $black; +} + +QToolBar QToolButton:disabled { + color: $tab-hover-color-1; + border-color: $top-bar-border-color; + border-bottom-color: transparent; + background-color: $tab-color-1; +} + +/* Tool buttons - buttons with icons */ + +#qt_toolbar_ext_button { + qproperty-icon: url($theme-dir/arrow-down.png); + border-radius: 0px; + margin-top: 3px; + padding: 0px; + border: 0px; + margin-left: -3px; +} + +#addressBookButton, QToolButton#clearButton, QToolButton#pasteButton, QToolButton#deleteButton, +QToolButton#addressBookButton_VM, QToolButton#copySignatureButton_SM, QToolButton#pasteButton_SM, QToolButton#addressBookButton_SM { + min-width: 16px; + max-width: 24px; + padding: 2px; + margin-left: 4px; +} + +/* Progress bar */ +QProgressBar { + border: 1px solid $brightest-color; + color: $text-color; + font-weight: bold; + background-color: transparent; +} + +QProgressBar::chunk { + background-color: $brightest-color; +} + +/* Table */ +CoinControlTreeWidget, QTableView { + background: transparent; + alternate-background-color: $table-row-alternate; + color: $text-color; + selection-background-color: $accent-color-2; + selection-color: $button-bg-hover-color; + outline: none; + $panel; +} + +QTableView QTableCornerButton::section { + border: 0px; + outline: none; +} + +QTableWidget::item:focus { + outline: none; + border: 0px; +} + +QTreeView { + color: $text-color; + border-style: none; + selection-background-color: $accent-color; + alternate-background-color: $table-row-alternate; + selection-color: $text-grey-d; + outline: none; +} + +QTreeView::item { + border: none; + color: $text-color; +} + +QTreeView::item:hover { + color: $text-grey-d; +} + +QTreeView::item:selected { + background-color: $accent-color-2; + color: $button-bg-hover-color; +} + +/* Table Header */ +QHeaderView { + color: $text-color; + background-color: $table-header-bg; + min-height: 24px; +} + +QHeaderView::section { + color: $text-color; + background-color: $table-header-bg; +} + +QHeaderView::section:checked { +} + + +/* Tooltip */ +QToolTip { + border: 1px outset $tooltip-border-color; + color: $text-color; + background-color: $tooltip-bg-color; +} + + +/* Menu Bar */ +QMenuBar { + background-color: $top-bar-color-1; + border: none; +} + +QMenuBar::item { + background: transparent; + color: $text-color; +} + +QMenuBar::item:selected { /* when selected using mouse or keyboard */ + background: $accent-color-2; + color: $black; +} + +QMenuBar::item:pressed { + background: $accent-color-2; +} + +/* Menu dialog */ +QMenu { + color: $text-color; + background-color: $bg-panel; +} + +QMenu::item { + /* sets background of menu item. set this to something non-transparent + if you want menu color and menu item color to be different */ + background-color: transparent; +} + +QMenu::item:selected { /* when user selects item using mouse or keyboard */ + background-color: $accent-color-2; + color: $black; +} + +/* Checkbox */ +QCheckBox { + color: $text-color; +} + +QCheckBox::indicator { + width: 13px; + height: 13px; +} + +QCheckBox::indicator:unchecked { + image: url($theme-dir/cb.png); +} + +QCheckBox::indicator:unchecked:hover { + image: url($theme-dir/cb-hover.png); +} + +QCheckBox::indicator:unchecked:pressed { + /*image: url($theme-dir/checkbox_unchecked_pressed.png);*/ +} + +QCheckBox::indicator:checked { + image: url($theme-dir/cb-checked.png); +} + +QCheckBox::indicator:checked:hover { + image: url($theme-dir/cb-checked-hover.png); +} + +QCheckBox::indicator:checked:pressed { + /*image: url($theme-dir/checkbox_checked_pressed.png);*/ +} + +QCheckBox::indicator:indeterminate:hover { + /*image: url($theme-dir/checkbox_indeterminate_hover.png);*/ +} + +QCheckBox::indicator:indeterminate:pressed { + /*image: url($theme-dir/checkbox_indeterminate_pressed.png);*/ +} + +/* Radio button */ +QRadioButton { + color: $text-color; +} + +QRadioButton::indicator { + width: 13px; + height: 13px; +} + +QRadioButton::indicator::unchecked { + image: url($theme-dir/r.png); +} + +QRadioButton::indicator:unchecked:hover { + image: url($theme-dir/r-hover.png); +} + +QRadioButton::indicator:unchecked:pressed { + /*image: url($theme-dir/rpressed.png);*/ +} + +QRadioButton::indicator::checked { + image: url($theme-dir/r-checked.png); +} + +QRadioButton::indicator:checked:hover { + image: url($theme-dir/r-checked-hover.png); +} + +QRadioButton::indicator:checked:pressed { + /*image: url($theme-dir/radiobutton_checked_pressed.png);*/ +} + +/* Tabs */ +QTabWidget { + background: transparent; +} + +QTabWidget::pane { + $panel; +} + +QTabWidget::tab-bar { + left: 5px; /* move to the right by 5px */ +} + +/* Style the tab using the tab sub-control. Note that it reads QTabBar _not_ QTabWidget */ +QTabBar::tab { + border: 1px solid $top-bar-border-color; + background-color: $button-border-color; + color: $text-lighter-color; + padding: 4px 8px; + border-top-left-radius: 4px; + border-top-right-radius: 4px; + margin-right: 3px; + border-bottom: 0px; +} + +QTabBar::tab:selected, QTabBar::tab:hover { + background: $main-color; +} + +QTabBar::tab:!selected { + background-color: $button-border-color; + color: $tab-color-2; +} + +/* Scroll bar */ + +QScrollBar:vertical { + background: $accent-color-2; + width: 6px; + margin: 0px 0px 0px 0px; +} + +QScrollBar::handle:vertical { + background: $accent-color; +} + +QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { + background: none; +} + +QScrollBar::add-line:vertical { + height: 0px; +} + +QScrollBar::sub-line:vertical { + height: 0px; +} + +/* Calendar */ + +/* navigation bar */ +QCalendarWidget QWidget#qt_calendar_navigationbar { + background-color: $main-color; +} +QCalendarWidget QToolButton {} +QCalendarWidget QMenu { + background-color: $top-bar-border-color; +} + + /* header row */ +QCalendarWidget QWidget { + alternate-background-color: $bg-panel; +} + +/* normal days */ +QCalendarWidget QAbstractItemView:enabled { + color: $text-color; + background-color: $main-color; + selection-background-color: $accent-color; + selection-color: $top-bar-border-color; +} + +/* days in other months */ +QCalendarWidget QAbstractItemView:disabled { + color: $top-bar-border-color; +} + +/* Window resize grip */ +QSizeGrip { + image: url($theme-dir/sizegrip.png); + width: 16px; + height: 16px; +} + +/* QBalloonTip - notification used in Linux - styled by Qt */ +QBalloonTip { + background-color: $bg-panel; + color: $text-color; +} + +QBalloonTip QPushButton { + min-width: 16px; + color: $text-color; + padding: 0px; + border-radius: 0px; + background-color: $text-color; +} + +QBalloonTip QPushButton:hover { + border: none; + background-color: $accent-color; +} + diff --git a/src/qt/res/themes/PoloniexDay/toolbar-handle.png b/src/qt/res/themes/PoloniexDay/toolbar-handle.png new file mode 100644 index 000000000..d5ca69b01 Binary files /dev/null and b/src/qt/res/themes/PoloniexDay/toolbar-handle.png differ diff --git a/src/qt/res/themes/PoloniexDay/up-arrow-disabled.png b/src/qt/res/themes/PoloniexDay/up-arrow-disabled.png new file mode 100644 index 000000000..72b862032 Binary files /dev/null and b/src/qt/res/themes/PoloniexDay/up-arrow-disabled.png differ diff --git a/src/qt/res/themes/PoloniexDay/up-arrow.png b/src/qt/res/themes/PoloniexDay/up-arrow.png new file mode 100644 index 000000000..7bbd8b830 Binary files /dev/null and b/src/qt/res/themes/PoloniexDay/up-arrow.png differ diff --git a/src/qt/res/themes/PoloniexNight/arrow-down.png b/src/qt/res/themes/PoloniexNight/arrow-down.png new file mode 100644 index 000000000..abbe63ccd Binary files /dev/null and b/src/qt/res/themes/PoloniexNight/arrow-down.png differ diff --git a/src/qt/res/themes/PoloniexNight/calendar-disabled.png b/src/qt/res/themes/PoloniexNight/calendar-disabled.png new file mode 100644 index 000000000..97a36c3c3 Binary files /dev/null and b/src/qt/res/themes/PoloniexNight/calendar-disabled.png differ diff --git a/src/qt/res/themes/PoloniexNight/calendar.png b/src/qt/res/themes/PoloniexNight/calendar.png new file mode 100644 index 000000000..b2f90452b Binary files /dev/null and b/src/qt/res/themes/PoloniexNight/calendar.png differ diff --git a/src/qt/res/themes/PoloniexNight/cb-checked-hover.png b/src/qt/res/themes/PoloniexNight/cb-checked-hover.png new file mode 100644 index 000000000..04ced7ae1 Binary files /dev/null and b/src/qt/res/themes/PoloniexNight/cb-checked-hover.png differ diff --git a/src/qt/res/themes/PoloniexNight/cb-checked.png b/src/qt/res/themes/PoloniexNight/cb-checked.png new file mode 100644 index 000000000..8c9993f89 Binary files /dev/null and b/src/qt/res/themes/PoloniexNight/cb-checked.png differ diff --git a/src/qt/res/themes/PoloniexNight/cb-hover.png b/src/qt/res/themes/PoloniexNight/cb-hover.png new file mode 100644 index 000000000..a7e9a393e Binary files /dev/null and b/src/qt/res/themes/PoloniexNight/cb-hover.png differ diff --git a/src/qt/res/themes/PoloniexNight/cb.png b/src/qt/res/themes/PoloniexNight/cb.png new file mode 100644 index 000000000..986a9165c Binary files /dev/null and b/src/qt/res/themes/PoloniexNight/cb.png differ diff --git a/src/qt/res/themes/PoloniexNight/down-arrow-disabled.png b/src/qt/res/themes/PoloniexNight/down-arrow-disabled.png new file mode 100644 index 000000000..46d3baa59 Binary files /dev/null and b/src/qt/res/themes/PoloniexNight/down-arrow-disabled.png differ diff --git a/src/qt/res/themes/PoloniexNight/down-arrow.png b/src/qt/res/themes/PoloniexNight/down-arrow.png new file mode 100644 index 000000000..dd66e6dfd Binary files /dev/null and b/src/qt/res/themes/PoloniexNight/down-arrow.png differ diff --git a/src/qt/res/themes/PoloniexNight/hypstk-watermark.png b/src/qt/res/themes/PoloniexNight/hypstk-watermark.png new file mode 100644 index 000000000..cd9aaab85 Binary files /dev/null and b/src/qt/res/themes/PoloniexNight/hypstk-watermark.png differ diff --git a/src/qt/res/themes/PoloniexNight/r-checked-hover.png b/src/qt/res/themes/PoloniexNight/r-checked-hover.png new file mode 100644 index 000000000..d1055b213 Binary files /dev/null and b/src/qt/res/themes/PoloniexNight/r-checked-hover.png differ diff --git a/src/qt/res/themes/PoloniexNight/r-checked.png b/src/qt/res/themes/PoloniexNight/r-checked.png new file mode 100644 index 000000000..f267e78dd Binary files /dev/null and b/src/qt/res/themes/PoloniexNight/r-checked.png differ diff --git a/src/qt/res/themes/PoloniexNight/r-hover.png b/src/qt/res/themes/PoloniexNight/r-hover.png new file mode 100644 index 000000000..9e10a855d Binary files /dev/null and b/src/qt/res/themes/PoloniexNight/r-hover.png differ diff --git a/src/qt/res/themes/PoloniexNight/r.png b/src/qt/res/themes/PoloniexNight/r.png new file mode 100644 index 000000000..fba9037c0 Binary files /dev/null and b/src/qt/res/themes/PoloniexNight/r.png differ diff --git a/src/qt/res/themes/PoloniexNight/sizegrip.png b/src/qt/res/themes/PoloniexNight/sizegrip.png new file mode 100644 index 000000000..9fab9e10a Binary files /dev/null and b/src/qt/res/themes/PoloniexNight/sizegrip.png differ diff --git a/src/qt/res/themes/PoloniexNight/styles.qss b/src/qt/res/themes/PoloniexNight/styles.qss new file mode 100644 index 000000000..52de2e7ac --- /dev/null +++ b/src/qt/res/themes/PoloniexNight/styles.qss @@ -0,0 +1,728 @@ +/** + * PoloniexNight Qt theme - v1.0 + * Last changed: 2014-10-09 + * Author: ZeeWolf - ##hyperstake (freenode) + * HyperStake - faster than light! + */ + +/** + * QSS REFERENCE : + * http://qt-project.org/doc/qt-4.8/stylesheet-reference.html + * http://qt-project.org/doc/qt-4.8/stylesheet-examples.html + */ + +/** + * Colors : + * + * BG top : #434d52 + * BG bottom : #273034 + * BG panel : #2e363c + * Text : #8fa5a7 + * Text lighter : #a4b6b8 + * BG0 : #3D474C + * BG1 : #2e363c + * BG2 : #283035 + * Complement : #c28208 + * Top-bar : #2b3236 - #242b2f + * Top-bar-border : #181d20 + * Tab-color-1 : #3a4449 + * Tab-color-2 : #333c41 + * Body : #434d52 - #273034 + * Input border: #202629 + * Input bg : #333b3f + * Input focus : #3D639D + * Button bg : #394348 + * Button border : #272E34 + * Button bg hover : #434e54 + * Button bg text hover : #ffffff + * Table header : #21272c + * Table row even : #2b3239 + * Table row odd : #293036 + * Table grid : #202629 + * Tooltip bg : #3c474f + * Tooltip border : #202629 + */ + +/** [VARS] + $header-text = font-size: 24px; font-family: "Times New Roman"; color: #8fa5a7 + $custom-font-1 = font-family: "Times New Roman" + $top-bar-color-1 = #2b3236 + $top-bar-color-2 = #242b2f + $top-bar-border-color = #181d20 + $tab-color-1 = #3a4449 + $tab-color-2 = #333c41 + $text-color = #8fa5a7 + $text-lighter-color = #a4b6b8 + $panel = background-color: #2e363c; border-radius: 7px; border: 0; border: 1px solid #202629 + $bg-top = #434d52 + $bg-bottom = #273034 + $bg-panel = #2e363c + $input-bg-color = #333b3f + $input-border-color = #202629 + $input-border-focus-color = #3D639D + $button-bg-color = #394348 + $button-bg-hover-color = #434e54 + $button-border-color = #272E34 + $button-text-hover-color = #ffffff + $grid-color = #202629 + $table-header-bg = #21272c + $table-row-bg = #2b3239 + $table-row-alternate = #293036 + $tooltip-bg-color = #3c474f + $tooltip-border-color = #202629 + $main-color = #2e363c + $text-grey-d = #0a1827 + $accent-color = #c28208 + $brightest-color = #fff + $header-font = "Verdana, Geneva, sans-serif" + $focused-input = border: 2px solid #3D639D; border-radius: 2px + $error-color = #FF6363 + $success-color = #73ff00 +[/VARS] */ + +* { gridline-color: $grid-color } + +/* Dialog, Window */ +QDialog, QMainWindow { + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 $bg-top, stop:1 $bg-bottom); +} + +#coinLogo { + qproperty-pixmap: url($theme-dir/hypstk-watermark.png); + qproperty-alignment: 'AlignBottom | AlignLeft'; +} + +/* Frames */ +QFrame { + /* too general - do not style */ +} + +/* Bottom status bar */ +QStatusBar { + background-color: transparent; + color: $text-color; +} + +QStatusBar::item { + border: none; +} + +/* Label */ +QLabel { + color: $text-color; +} + +QLabel[error="true"], QLabel[status="error"] { + color: $error-color; +} + +QLabel[ok="true"], QLabel[status="ok"] { + color: $success-color; +} + +QValidatedLineEdit[error="true"], QDoubleSpinBox[error="true"] { + border-color: $error-color; +} + +/* Frames labels - Balance, Stake, etc. */ + +/* Balance frame */ +QFrame#frame { + $panel; +} + +/* Recent transactions frame */ +QFrame#frame_2 { + $panel; +} + +/* Panel in Coin Control window */ +QFrame#frame_2 QFrame { + color: $text-color; +} + +QFrame#rangeFrame { + $panel; + margin-top: 10px; +} + +#CoinControlDialog QFrame#frame { + $panel; +} + +QFrame#frameCoinControl { + $panel; +} + +/* Balance value */ +#frame #labelBalance { + color: $brightest-color; + font-size: 14px; +} + +/* Wallet label */ +QFrame#frame #label_5 { + $header-text; +} + +/* Recent transactions label */ +QFrame#frame_2 #label_4 { + $header-text; +} + +/* ScrollArea */ +QScrollArea { + $panel; +} + +#scrollAreaWidgetContents { + background-color: transparent; +} + +#scrollAreaWidgetContents > QFrame { + background-color: transparent; + border-width: 0px; + border-style: none; +} + +#scrollAreaWidgetContents > QFrame:last { + border-bottom: 1px solid $brightest-color; +} + +#scrollAreaWidgetContents > QFrame:only-one { + border-bottom: none; +} + +/* Text edit fields */ +QPlainTextEdit, QLineEdit { + padding: 4px; + background-color: $input-bg-color; + color: $text-color; + border: 1px solid $input-border-color; +} + +QPlainTextEdit:focus, QLineEdit:focus { + $focused-input; + padding: 3px; +} + +QPlainTextEdit:disabled, QLineEdit:disabled { + color: $input-border-color; +} + +/* Text edit - debug window */ +QTextEdit { + padding: 4px; + background-color: $input-bg-color; + color: $text-color; + border: 1px solid $input-border-color; +} + +QTextEdit:disabled { + border-color: $top-bar-border-color; + color: $input-border-color; +} + +/* Combo box */ +QComboBox { + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 $bg-top, stop:1 $bg-bottom); + color: $text-color; + border: 1px solid $input-border-color; + border-radius: 3px; /* same radius as the QComboBox */ + padding: 4px 18px 4px 4px; + min-width: 6em; +} + +QComboBox:on { + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 $bg-bottom, stop:1 $bg-top); +} + +QComboBox:disabled { + border-color: $top-bar-border-color; + color: $input-border-color; +} + +QComboBox::drop-down:disabled { + border-color: $input-border-color; +} + +QComboBox::down-arrow { + /* Custom dropdown symbol */ + image: url($theme-dir/down-arrow.png); +} + +QComboBox::down-arrow:disabled { + image: url($theme-dir/down-arrow-disabled.png); +} + +QComboBox::down-arrow:on { + /* Custom dropdown symbol */ + image: url($theme-dir/up-arrow.png); +} + +QComboBox::drop-down { + border: 0px; +} + +QComboBox QAbstractItemView { + border: 1px solid $tooltip-border-color; + color: $text-color; + background-color: $tooltip-bg-color; + outline: 0px; +} + +QComboBox QListView { + border: none; + selection-color: $tooltip-bg-color; + selection-background-color: $text-color; +} + +/* Up&down spin box */ +QDateTimeEdit, QSpinBox, QDoubleSpinBox { + padding: 3px; + background-color: $input-bg-color; + color: $text-color; + border: 1px solid $input-border-color; +} + +QDateTimeEdit:focus, QSpinBox:focus, QDoubleSpinBox:focus { + border-color: $accent-color; +} +QDateTimeEdit:disabled, QSpinBox:disabled, QDoubleSpinBox:disabled { + border-color: $top-bar-border-color; + color: $input-border-color; +} + +QDateTimeEdit::down-arrow { + image: url($theme-dir/calendar.png); +} + +QDateTimeEdit::down-arrow:disabled { + image: url($theme-dir/calendar-disabled.png); +} + +QDateTimeEdit::drop-down { + border: 0px; +} + +QDoubleSpinBox::down-button { + image: url($theme-dir/down-arrow.png); +} + +QDoubleSpinBox::up-button { + image: url($theme-dir/up-arrow.png); +} + +/* Button */ +QPushButton { + background-color: $button-bg-color; + border: 1px solid $button-border-color; + border-radius: 3px; + color: $text-color; + font-family: $header-font; + font-size: 12px; + /*min-width: 6em;*/ + outline: none; + padding: 4px; +} + +QPushButton[text="OK"] { + width: 6em; +} +QToolButton { + background-color: $button-bg-color; + border: 1px solid $button-border-color; + border-radius: 3px; + color: $text-color; + font-family: $header-font; + font-size: 12px; + outline: none; + padding: 4px; +} + +QPushButton:hover, QToolButton:hover { + background-color: $button-bg-hover-color; + color: $button-text-hover-color; +} + +QPushButton:pressed, QToolButton:pressed { + background-color: $button-border-color; + color: $accent-color; +} + +QPushButton:disabled, QToolButton:disabled { + background-color: $button-border-color; + color: $tab-color-2; + border: 1px solid $button-bg-color; +} + +/* Toolbar */ +QToolBar { + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 $top-bar-color-1, stop:1 $top-bar-color-2); + spacing: 3px; /* spacing between items in the tool bar */ + margin-bottom: 0px; + border: none; + border-bottom: 1px solid $top-bar-border-color; +} + +QToolBar::handle { + padding: 0px; + background-color: transparent; +} + +/* Toolbar buttons */ +QToolBar QToolButton { /* all types of tool button */ + border: 1px solid $top-bar-border-color; + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 $tab-color-1, stop:1 $tab-color-2); + color: $text-lighter-color; + padding: 4px 2px; + font-size: 14px; + border-top-left-radius: 3px; + border-top-right-radius: 3px; + border-bottom-left-radius: 0px; + border-bottom-right-radius: 0px; + $custom-font-1; + margin-top: 12px; +} + +QToolBar QToolButton:hover { + background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 $tab-color-2, stop:1 $tab-color-1); +} + +QToolBar QToolButton:checked { + background-color: $top-bar-color-1; +} + +QToolBar QToolButton:disabled { + color: $tab-color-2; + border-color: $tab-color-2; + border-bottom-color: transparent; +} + +/* Tool buttons - buttons with icons */ + +#qt_toolbar_ext_button { + qproperty-icon: url($theme-dir/arrow-down.png); + border-radius: 0px; + margin-top: 3px; + padding: 0px; + border: 0px; + margin-left: -3px; +} + +#addressBookButton, QToolButton#clearButton, QToolButton#pasteButton, QToolButton#deleteButton, +QToolButton#addressBookButton_VM, QToolButton#copySignatureButton_SM, QToolButton#pasteButton_SM, QToolButton#addressBookButton_SM { + min-width: 16px; + max-width: 24px; + padding: 2px; + margin-left: 4px; +} + +/* Progress bar */ +QProgressBar { + border: 1px solid #434d52; + color: $brightest-color; + font-weight: bold; + background-color: transparent; +} + +QProgressBar::chunk { + background-color: #434d52; +} + +/* Table */ +CoinControlTreeWidget, QTableView { + background: transparent; + alternate-background-color: $table-row-alternate; + color: $text-color; + selection-background-color: $tab-color-1; + /*selection-color: $top-bar-border-color;*/ + outline: none; + $panel; +} + +QTableView QTableCornerButton::section { + border: 0px solid $top-bar-border-color; + outline: none; +} + +QTableWidget::item:focus { + outline: none; + border: 0px; +} + +QTreeView { + color: $text-color; + border-style: none; + selection-background-color: $accent-color; + alternate-background-color: $table-row-alternate; + selection-color: $top-bar-border-color; + outline: none; +} + +QTreeView::item { + border: none; + color: $text-color; +} + +QTreeView::item:hover { + color: $brightest-color; +} + +QTreeView::item:selected { + background-color: $tab-color-1; + color: $brightest-color; +} + +/* Table Header */ +QHeaderView { + color: $text-color; + background-color: $table-header-bg; + min-height: 24px; +} + +QHeaderView::section { + color: $text-color; + background-color: $table-header-bg; +} + +QHeaderView::section:checked { +} + + +/* Tooltip */ +QToolTip { + border: 1px outset $tooltip-border-color; + color: $text-color; + background-color: $tooltip-bg-color; + border-radius: 5px; +} + + +/* Menu Bar */ +QMenuBar { + background-color: $top-bar-color-1; + border: none; +} + +QMenuBar::item { + background: transparent; + color: $text-color; +} + +QMenuBar::item:selected { /* when selected using mouse or keyboard */ + background: $text-color; + color: $text-grey-d; +} + +QMenuBar::item:pressed { + background: $text-color; +} + +/* Menu dialog */ +QMenu { + color: $text-color; + background-color: $bg-panel; +} + +QMenu::item { + /* sets background of menu item. set this to something non-transparent + if you want menu color and menu item color to be different */ + background-color: transparent; +} + +QMenu::item:selected { /* when user selects item using mouse or keyboard */ + color: $bg-panel; + background-color: $text-color; +} + +/* Checkbox */ +QCheckBox { + color: $text-color; +} + +QCheckBox::indicator { + width: 13px; + height: 13px; +} + +QCheckBox::indicator:unchecked { + image: url($theme-dir/cb.png); +} + +QCheckBox::indicator:unchecked:hover { + image: url($theme-dir/cb-hover.png); +} + +QCheckBox::indicator:unchecked:pressed { + /*image: url($theme-dir/checkbox_unchecked_pressed.png);*/ +} + +QCheckBox::indicator:checked { + image: url($theme-dir/cb-checked.png); +} + +QCheckBox::indicator:checked:hover { + image: url($theme-dir/cb-checked-hover.png); +} + +QCheckBox::indicator:checked:pressed { + /*image: url($theme-dir/checkbox_checked_pressed.png);*/ +} + +QCheckBox::indicator:indeterminate:hover { + /*image: url($theme-dir/checkbox_indeterminate_hover.png);*/ +} + +QCheckBox::indicator:indeterminate:pressed { + /*image: url($theme-dir/checkbox_indeterminate_pressed.png);*/ +} + +/* Radio button */ +QRadioButton { + color: $text-color; +} + +QRadioButton::indicator { + width: 13px; + height: 13px; +} + +QRadioButton::indicator::unchecked { + image: url($theme-dir/r.png); +} + +QRadioButton::indicator:unchecked:hover { + image: url($theme-dir/r-hover.png); +} + +QRadioButton::indicator:unchecked:pressed { + /*image: url($theme-dir/rpressed.png);*/ +} + +QRadioButton::indicator::checked { + image: url($theme-dir/r-checked.png); +} + +QRadioButton::indicator:checked:hover { + image: url($theme-dir/r-checked-hover.png); +} + +QRadioButton::indicator:checked:pressed { + /*image: url($theme-dir/radiobutton_checked_pressed.png);*/ +} + +/* Tabs */ +QTabWidget { + background: transparent; +} + +QTabWidget::pane { + $panel; +} + +QTabWidget::tab-bar { + left: 5px; /* move to the right by 5px */ +} + +/* Style the tab using the tab sub-control. Note that it reads QTabBar _not_ QTabWidget */ +QTabBar::tab { + border: 1px solid $top-bar-border-color; + background-color: $button-border-color; + color: $text-lighter-color; + padding: 4px 8px; + border-top-left-radius: 4px; + border-top-right-radius: 4px; + margin-right: 3px; + border-bottom: 0px; +} + +QTabBar::tab:selected, QTabBar::tab:hover { + background: $main-color; + border-bottom: 1px solid $main-color; +} + +QTabBar::tab:!selected { + background-color: $button-border-color; + color: $tab-color-2; +} + +/* Scroll bar */ + +QScrollBar:vertical { + background: $button-border-color; + width: 6px; + margin: 0px 0px 0px 0px; +} + +QScrollBar::handle:vertical { + background: $top-bar-border-color; +} + +QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical { + background: none; +} + +QScrollBar::add-line:vertical { + height: 0px; +} + +QScrollBar::sub-line:vertical { + height: 0px; +} + +/* Calendar */ + +/* navigation bar */ +QCalendarWidget QWidget#qt_calendar_navigationbar { + background-color: $main-color; +} +QCalendarWidget QToolButton {} +QCalendarWidget QMenu { + background-color: $top-bar-border-color; +} + + /* header row */ +QCalendarWidget QWidget { + alternate-background-color: $bg-panel; +} + +/* normal days */ +QCalendarWidget QAbstractItemView:enabled { + color: $text-color; + background-color: $main-color; + selection-background-color: $accent-color; + selection-color: $top-bar-border-color; +} + +/* days in other months */ +QCalendarWidget QAbstractItemView:disabled { + color: $top-bar-border-color; +} + +/* Window resize grip */ +QSizeGrip { + image: url($theme-dir/sizegrip.png); + width: 16px; + height: 16px; +} + +/* QBalloonTip - notification used in Linux - styled by Qt */ +QBalloonTip { + background-color: $bg-panel; + color: $text-color; +} + +QBalloonTip QPushButton { + min-width: 16px; + color: $text-color; + padding: 0px; + border-radius: 0px; + background-color: $text-color; +} + +QBalloonTip QPushButton:hover { + border: none; + background-color: $accent-color; +} + diff --git a/src/qt/res/themes/PoloniexNight/toolbar-handle.png b/src/qt/res/themes/PoloniexNight/toolbar-handle.png new file mode 100644 index 000000000..d5ca69b01 Binary files /dev/null and b/src/qt/res/themes/PoloniexNight/toolbar-handle.png differ diff --git a/src/qt/res/themes/PoloniexNight/up-arrow-disabled.png b/src/qt/res/themes/PoloniexNight/up-arrow-disabled.png new file mode 100644 index 000000000..72b862032 Binary files /dev/null and b/src/qt/res/themes/PoloniexNight/up-arrow-disabled.png differ diff --git a/src/qt/res/themes/PoloniexNight/up-arrow.png b/src/qt/res/themes/PoloniexNight/up-arrow.png new file mode 100644 index 000000000..7bbd8b830 Binary files /dev/null and b/src/qt/res/themes/PoloniexNight/up-arrow.png differ diff --git a/src/qt/res/themes/readme b/src/qt/res/themes/readme new file mode 100644 index 000000000..754964fb4 --- /dev/null +++ b/src/qt/res/themes/readme @@ -0,0 +1,12 @@ +Qt Wallet themes directory + +Each directory is separate theme - displayed in Themes menu. + +HyperStake-qt wallet will look for themes in : +- current exe directory - ./themes +- in ./src/qt/res/themes + +There is compilation extra step added : +make install + +will copy themes to release directory \ No newline at end of file diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 34004a455..99e56ddf7 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -10,7 +10,9 @@ #include #include #include +#if QT_VERSION < 0x050000 #include +#endif #include #include diff --git a/src/qt/scicon.cpp b/src/qt/scicon.cpp new file mode 100644 index 000000000..a0ffcd82a --- /dev/null +++ b/src/qt/scicon.cpp @@ -0,0 +1,84 @@ +// Copyright (c) 2014 The Bitcoin developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "scicon.h" + +#include +#include +#include +#include +#include +#include + +static void MakeSingleColorImage(QImage& img, const QColor& colorbase) +{ + img = img.convertToFormat(QImage::Format_ARGB32); + for (int x = img.width(); x--; ) + { + for (int y = img.height(); y--; ) + { + const QRgb rgb = img.pixel(x, y); + img.setPixel(x, y, qRgba(colorbase.red(), colorbase.green(), colorbase.blue(), qAlpha(rgb))); + } + } +} + +QImage SingleColorImage(const QString& filename, const QColor& colorbase) +{ + QImage img(filename); + MakeSingleColorImage(img, colorbase); + return img; +} + +QIcon SingleColorIcon(const QIcon& ico, const QColor& colorbase) +{ + QIcon new_ico; + QSize sz; + Q_FOREACH(sz, ico.availableSizes()) + { + QImage img(ico.pixmap(sz).toImage()); + MakeSingleColorImage(img, colorbase); + new_ico.addPixmap(QPixmap::fromImage(img)); + } + return new_ico; +} + +QIcon SingleColorIcon(const QString& filename, const QColor& colorbase) +{ + return QIcon(QPixmap::fromImage(SingleColorImage(filename, colorbase))); +} + +QColor SingleColor() +{ + const QColor colorHighlightBg(QApplication::palette().color(QPalette::Highlight)); + const QColor colorHighlightFg(QApplication::palette().color(QPalette::HighlightedText)); + const QColor colorText(QApplication::palette().color(QPalette::WindowText)); + const int colorTextLightness = colorText.lightness(); + QColor colorbase; + if (abs(colorHighlightBg.lightness() - colorTextLightness) < abs(colorHighlightFg.lightness() - colorTextLightness)) + colorbase = colorHighlightBg; + else + colorbase = colorHighlightFg; + return colorbase; +} + +QIcon SingleColorIcon(const QString& filename) +{ + return SingleColorIcon(filename, SingleColor()); +} + +static QColor TextColor() +{ + return QColor(QApplication::palette().color(QPalette::WindowText)); +} + +QIcon TextColorIcon(const QString& filename) +{ + return SingleColorIcon(filename, TextColor()); +} + +QIcon TextColorIcon(const QIcon& ico) +{ + return SingleColorIcon(ico, TextColor()); +} diff --git a/src/qt/scicon.h b/src/qt/scicon.h new file mode 100644 index 000000000..1388069dd --- /dev/null +++ b/src/qt/scicon.h @@ -0,0 +1,24 @@ +// Copyright (c) 2014 The Bitcoin developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_QT_SCICON_H +#define BITCOIN_QT_SCICON_H + +#include + +QT_BEGIN_NAMESPACE +class QColor; +class QIcon; +class QString; +QT_END_NAMESPACE + +QImage SingleColorImage(const QString& filename, const QColor&); +QIcon SingleColorIcon(const QIcon&, const QColor&); +QIcon SingleColorIcon(const QString& filename, const QColor&); +QColor SingleColor(); +QIcon SingleColorIcon(const QString& filename); +QIcon TextColorIcon(const QIcon&); +QIcon TextColorIcon(const QString& filename); + +#endif // BITCOIN_QT_SCICON_H diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 9b12e4aad..94caae428 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -34,7 +34,11 @@ SendCoinsDialog::SendCoinsDialog(QWidget *parent) : #if QT_VERSION >= 0x040700 /* Do not move this to the XML file, Qt before 4.7 will choke on it */ - ui->lineEditCoinControlChange->setPlaceholderText(tr("Enter a HyperStake address (e.g. BrXW1RKLDe8VMNwTwLwSiKuATN5M74EL85)")); + ui->lineEditCoinControlChange->setPlaceholderText(tr("Enter a HyperStake address (e.g. pAvP3gYfuyDVbUt98ToMbwU9rwEdBV1dHW)")); + ui->splitBlockLineEdit->setPlaceholderText(tr("# of Blocks")); + ui->splitBlockCheckBox->setToolTip(tr("Enable/Disable Block Splitting")); + ui->returnChangeCheckBox->setToolTip(tr("Use your sending address as the change address")); + ui->checkBoxCoinControlChange->setToolTip(tr("Send change to a custom address")); #endif addEntry(); @@ -47,6 +51,9 @@ SendCoinsDialog::SendCoinsDialog(QWidget *parent) : connect(ui->pushButtonCoinControl, SIGNAL(clicked()), this, SLOT(coinControlButtonClicked())); connect(ui->checkBoxCoinControlChange, SIGNAL(stateChanged(int)), this, SLOT(coinControlChangeChecked(int))); connect(ui->lineEditCoinControlChange, SIGNAL(textEdited(const QString &)), this, SLOT(coinControlChangeEdited(const QString &))); + connect(ui->returnChangeCheckBox, SIGNAL(stateChanged(int)), this, SLOT(coinControlReturnChangeChecked(int))); + connect(ui->splitBlockCheckBox, SIGNAL(stateChanged(int)), this, SLOT(coinControlSplitBlockChecked(int))); + connect(ui->splitBlockLineEdit, SIGNAL(textChanged(const QString &)), this, SLOT(splitBlockLineEditChanged(const QString &))); // Coin Control: clipboard actions QAction *clipboardQuantityAction = new QAction(tr("Copy quantity"), this); @@ -118,9 +125,19 @@ void SendCoinsDialog::on_sendButton_clicked() return; for(int i = 0; i < ui->entries->count(); ++i) - { - SendCoinsEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); - if(entry) + { + SendCoinsEntry *entry = qobject_cast(ui->entries->itemAt(i)->widget()); + CBitcoinAddress address = entry->getValue().address.toStdString(); + if(!model->isMine(address) && ui->splitBlockCheckBox->checkState() == Qt::Checked) + { + model->setSplitBlock(false); //dont allow the blocks to split if sending to an outside address + ui->splitBlockCheckBox->setCheckState(Qt::Unchecked); + QMessageBox::warning(this, tr("Send Coins"), + tr("The split block tool does not work when sending to outside addresses. Try again."), + QMessageBox::Ok, QMessageBox::Ok); + return; + } + if(entry) { if(entry->validate()) { @@ -137,21 +154,64 @@ void SendCoinsDialog::on_sendButton_clicked() { return; } - + + WalletModel::SendCoinsReturn sendstatus; + //set split block + int nSplitBlock = 1; + if (ui->splitBlockCheckBox->checkState() == Qt::Checked) + model->setSplitBlock(true); + else + model->setSplitBlock(false); + if (ui->entries->count() > 1 && ui->splitBlockCheckBox->checkState() == Qt::Checked) + { + model->setSplitBlock(false); + ui->splitBlockCheckBox->setCheckState(Qt::Unchecked); + QMessageBox::warning(this, tr("Send Coins"), + tr("The split block tool does not work with multiple addresses. Try again."), + QMessageBox::Ok, QMessageBox::Ok); + return; + } + if (model->getSplitBlock()) + nSplitBlock = int(ui->splitBlockLineEdit->text().toDouble()); + // Format confirmation message QStringList formatted; foreach(const SendCoinsRecipient &rcp, recipients) { - formatted.append(tr("%1 to %2 (%3)").arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, rcp.amount), Qt::escape(rcp.label), rcp.address)); - } + if(!model->getSplitBlock()) + { + #if QT_VERSION < 0x050000 + formatted.append(tr("%1 to %2 (%3)").arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, rcp.amount), Qt::escape(rcp.label), rcp.address)); + #else + formatted.append(tr("%1 to %2 (%3)").arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, rcp.amount), rcp.label.toHtmlEscaped(), rcp.address)); + #endif + } + else + { + #if QT_VERSION < 0x050000 + formatted.append(tr("%1 in %4 blocks of %5 each to %2 (%3)?").arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, rcp.amount), + Qt::escape(rcp.label), + rcp.address, + QString::number(nSplitBlock), + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, rcp.amount / nSplitBlock))); + #else + formatted.append(tr("%1 in %4 blocks of %5 each to %2 (%3)?").arg(BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, rcp.amount), + rcp.label.toHtmlEscaped(), + rcp.address, + QString::number(nSplitBlock), + BitcoinUnits::formatWithUnit(BitcoinUnits::BTC, rcp.amount / nSplitBlock))); + #endif + } + } fNewRecipientAllowed = false; - QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm send coins"), + QMessageBox::StandardButton retval = QMessageBox::question(this, tr("Confirm send coins"), tr("Are you sure you want to send %1?").arg(formatted.join(tr(" and "))), QMessageBox::Yes|QMessageBox::Cancel, QMessageBox::Cancel); + if(retval != QMessageBox::Yes) { fNewRecipientAllowed = true; @@ -166,12 +226,12 @@ void SendCoinsDialog::on_sendButton_clicked() return; } - WalletModel::SendCoinsReturn sendstatus; - + + if (!model->getOptionsModel() || !model->getOptionsModel()->getCoinControlFeatures()) - sendstatus = model->sendCoins(recipients); + sendstatus = model->sendCoins(recipients, nSplitBlock); else - sendstatus = model->sendCoins(recipients, CoinControlDialog::coinControl); + sendstatus = model->sendCoins(recipients, nSplitBlock, CoinControlDialog::coinControl); switch(sendstatus.status) { @@ -430,10 +490,75 @@ void SendCoinsDialog::updateDisplayUnit() coinControlUpdateLabels(); } + // Coin Control: return change + // presstab HyperStake + void SendCoinsDialog::coinControlReturnChangeChecked(int state) + { + if(state == Qt::Checked && ui->checkBoxCoinControlChange->checkState() == Qt::Checked) + { + ui->returnChangeCheckBox->setCheckState(Qt::Unchecked); + QMessageBox::warning(this, tr("Send Coins"), + tr("Cannot use custom change address and return change at the same time. Try again."), + QMessageBox::Ok, QMessageBox::Ok); + return; + } + + if (model) + { + if (state == Qt::Checked) + CoinControlDialog::coinControl->fReturnChange = true; + else + CoinControlDialog::coinControl->fReturnChange = false; + } + } + +// Coin Control: split block check box +// presstab HyperStake +void SendCoinsDialog::coinControlSplitBlockChecked(int state) +{ + if (model) + { + if (state == Qt::Checked) + { + model->setSplitBlock(true); + ui->splitBlockLineEdit->setEnabled(true); + ui->labelBlockSizeText->setEnabled(true); + ui->labelBlockSize->setEnabled(true); + } + else + { + model->setSplitBlock(false); + ui->splitBlockLineEdit->setEnabled(false); + ui->labelBlockSizeText->setEnabled(false); + ui->labelBlockSize->setEnabled(false); + } + coinControlUpdateLabels(); + } +} + +//presstab HyperStake +void SendCoinsDialog::splitBlockLineEditChanged(const QString & text) +{ + double nAfterFee = ui->labelCoinControlAfterFee->text().left(ui->labelCoinControlAfterFee->text().indexOf(" ")).toDouble(); + double nSize = 0; + if (nAfterFee > 0 && text.toDouble() > 0) + nSize = nAfterFee / text.toDouble(); + ui->labelBlockSize->setText(QString::number(nSize)); +} + // Coin Control: checkbox custom change address void SendCoinsDialog::coinControlChangeChecked(int state) { - if (model) + if(state == Qt::Checked && ui->returnChangeCheckBox->checkState() == Qt::Checked) + { + ui->checkBoxCoinControlChange->setCheckState(Qt::Unchecked); + QMessageBox::warning(this, tr("Send Coins"), + tr("Cannot use custom change address and return change at the same time. Try again."), + QMessageBox::Ok, QMessageBox::Ok); + return; + } + + if (model) { if (state == Qt::Checked) CoinControlDialog::coinControl->destChange = CBitcoinAddress(ui->lineEditCoinControlChange->text().toStdString()).Get(); @@ -442,7 +567,7 @@ void SendCoinsDialog::updateDisplayUnit() } ui->lineEditCoinControlChange->setEnabled((state == Qt::Checked)); - ui->labelCoinControlChangeLabel->setEnabled((state == Qt::Checked)); + ui->labelCoinControlChangeLabel->setEnabled((state == Qt::Checked)); } // Coin Control: custom change address changed @@ -453,13 +578,15 @@ void SendCoinsDialog::updateDisplayUnit() CoinControlDialog::coinControl->destChange = CBitcoinAddress(text.toStdString()).Get(); // label for the change address - ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:black;}"); + ui->labelCoinControlChangeLabel->setProperty("error", false); + ui->labelCoinControlChangeLabel->style()->polish(ui->labelCoinControlChangeLabel); if (text.isEmpty()) ui->labelCoinControlChangeLabel->setText(""); else if (!CBitcoinAddress(text.toStdString()).IsValid()) { - ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}"); - ui->labelCoinControlChangeLabel->setText(tr("WARNING: Invalid Bitcoin address")); + ui->labelCoinControlChangeLabel->setProperty("error", true); + ui->labelCoinControlChangeLabel->style()->polish(ui->labelCoinControlChangeLabel); + ui->labelCoinControlChangeLabel->setText(tr("WARNING: Invalid HyperStake address")); } else { @@ -475,7 +602,8 @@ void SendCoinsDialog::updateDisplayUnit() ui->labelCoinControlChangeLabel->setText(tr("(no label)")); else { - ui->labelCoinControlChangeLabel->setStyleSheet("QLabel{color:red;}"); + ui->labelCoinControlChangeLabel->setProperty("error", true); + ui->labelCoinControlChangeLabel->style()->polish(ui->labelCoinControlChangeLabel); ui->labelCoinControlChangeLabel->setText(tr("WARNING: unknown change address")); } } @@ -513,4 +641,4 @@ void SendCoinsDialog::updateDisplayUnit() } } - \ No newline at end of file + diff --git a/src/qt/sendcoinsdialog.h b/src/qt/sendcoinsdialog.h index 68424bb1d..f440e44e6 100644 --- a/src/qt/sendcoinsdialog.h +++ b/src/qt/sendcoinsdialog.h @@ -32,6 +32,7 @@ class SendCoinsDialog : public QDialog void pasteEntry(const SendCoinsRecipient &rv); bool handleURI(const QString &uri); + bool fSplitBlock; public slots: void clear(); @@ -53,6 +54,7 @@ private slots: void coinControlFeatureChanged(bool); void coinControlButtonClicked(); void coinControlChangeChecked(int); + void coinControlReturnChangeChecked(int); void coinControlChangeEdited(const QString &); void coinControlUpdateLabels(); void coinControlClipboardQuantity(); @@ -63,6 +65,8 @@ private slots: void coinControlClipboardPriority(); void coinControlClipboardLowOutput(); void coinControlClipboardChange(); + void coinControlSplitBlockChecked(int); + void splitBlockLineEditChanged(const QString & text); }; #endif // SENDCOINSDIALOG_H diff --git a/src/qt/sendcoinsentry.cpp b/src/qt/sendcoinsentry.cpp index c8bf322a6..732f09cf6 100644 --- a/src/qt/sendcoinsentry.cpp +++ b/src/qt/sendcoinsentry.cpp @@ -46,13 +46,26 @@ void SendCoinsEntry::on_addressBookButton_clicked() { if(!model) return; - AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::SendingTab, this); - dlg.setModel(model->getAddressTableModel()); - if(dlg.exec()) + if (model->getSplitBlock()) { - ui->payTo->setText(dlg.getReturnValue()); - ui->payAmount->setFocus(); + AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::ReceivingTab, this); + dlg.setModel(model->getAddressTableModel()); + if(dlg.exec()) + { + ui->payTo->setText(dlg.getReturnValue()); + ui->payAmount->setFocus(); + } } + else + { + AddressBookPage dlg(AddressBookPage::ForSending, AddressBookPage::SendingTab, this); + dlg.setModel(model->getAddressTableModel()); + if(dlg.exec()) + { + ui->payTo->setText(dlg.getReturnValue()); + ui->payAmount->setFocus(); + } + } } void SendCoinsEntry::on_payTo_textChanged(const QString &address) diff --git a/src/qt/setvotesdialog.cpp b/src/qt/setvotesdialog.cpp new file mode 100644 index 000000000..128e5aad7 --- /dev/null +++ b/src/qt/setvotesdialog.cpp @@ -0,0 +1,164 @@ +#include "setvotesdialog.h" +#include "ui_setvotesdialog.h" +#include "init.h" +#include "wallet.h" +#include "main.h" +//#include "walletmodel.h" +//#include "voteproposal.h" +#include +#include +#include + +SetVotesDialog::SetVotesDialog(QWidget* parent) : + QDialog(parent), + ui(new Ui::SetVotesDialog) +{ + ui->setupUi(this); + walletModel = nullptr; + Clear(); + ui->votesTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft); + UpdateTable(); +} + +SetVotesDialog::~SetVotesDialog() +{ + delete ui; +} + +void SetVotesDialog::SetWalletModel(WalletModel* model) +{ + walletModel = model; +} + +void SetVotesDialog::on_voteButton_clicked() +{ + if(pwalletMain->IsLocked()) { + QMessageBox msg; + msg.setText(tr("Error: Unlock wallet to vote on a proposal.")); + msg.exec(); + return; + } + + //Get params + uint256 txHash(ui->txidLineEdit->text().toStdString()); + int voteChoice = ui->voteComboBox->currentIndex(); + + CTransaction tx; + uint256 hashBlock; + if(!GetTransaction(txHash, tx, hashBlock)) { + QMessageBox msg; + msg.setText(tr("Transaction not found in wallet.")); + msg.exec(); + return; + } + + if (!tx.IsProposal()) { + QMessageBox msg; + msg.setText(tr("Transaction does not contain a proposal.")); + msg.exec(); + return; + } + + CVoteProposal proposal; + if (!ProposalFromTransaction(tx, proposal)) { + QMessageBox msg; + msg.setText(tr("Proposal couldn't be found in the transaction.")); + msg.exec(); + return; + } + + CVoteObject voteObject(proposal.GetHash(), proposal.GetLocation()); + + voteObject.Vote(voteChoice); + + //add the voteObject in the map + pwalletMain->mapVoteObjects[proposal.GetHash()] = voteObject; + + //write the vote object to the database + CWalletDB walletdb(pwalletMain->strWalletFile); + if (!walletdb.WriteVoteObject(proposal.GetHash().GetHex(), voteObject)) { + QMessageBox msg; + msg.setText(tr("The vote was saved; however, there were problems writing the vote to the database.")); + msg.exec(); + return; + } + + QMessageBox msg; + msg.setText(tr("Vote submitted!\n\nProposal Name: %1\nProposal Description: %2\nYour Vote: " + "%3").arg(QString::fromStdString(proposal.GetName())).arg(QString::fromStdString(proposal.GetDescription())).arg(ui->voteComboBox->currentText())); + msg.exec(); + Clear(); + UpdateTable(); + return; +} + +void SetVotesDialog::UpdateTable() +{ + if(pwalletMain == nullptr) + return; + + int columns = 3; + int rows = 0; + QStandardItemModel* model = new QStandardItemModel(rows, columns, this); + model->setHorizontalHeaderItem(0, new QStandardItem(QString("Name"))); + model->setHorizontalHeaderItem(1, new QStandardItem(QString("Description"))); + model->setHorizontalHeaderItem(2, new QStandardItem(QString("Your Vote"))); + + int i = 0; + CVoteDB votedb("r"); + if(!(pwalletMain->mapVoteObjects.empty())) { + std::map::iterator it; + for (it = pwalletMain->mapVoteObjects.begin(); it != pwalletMain->mapVoteObjects.end(); it++) { + QList < QStandardItem * > listItems; + + uint256 txid = 0; + for (auto mit : mapProposals) { + if (mit.second == it->first) { + txid = mit.first; + break; + } + } + + if (txid == 0) + return; + + CVoteProposal proposal; + if (!votedb.ReadProposal(txid, proposal)) { + return; + } + + int voteValue = it->second.GetUnformattedVote(); + std::string strVote; + + switch(voteValue) { + case 1: + strVote = "Yes"; + break; + case 2: + strVote = "No"; + break; + case 3: + strVote = "Request proposal revision"; + break; + default: + strVote = "Abstain"; + break; + } + + listItems.push_back(new QStandardItem(QString::fromStdString(proposal.GetName()))); + listItems.push_back(new QStandardItem(QString::fromStdString(proposal.GetDescription()))); + listItems.push_back(new QStandardItem(QString::fromStdString(strVote))); + + model->insertRow(i, listItems); + ++i; + } + } + + ui->votesTable->setModel(model); +} + +void SetVotesDialog::Clear() +{ + ui->txidLineEdit->clear(); + ui->voteComboBox->setCurrentIndex(0); +} \ No newline at end of file diff --git a/src/qt/setvotesdialog.h b/src/qt/setvotesdialog.h new file mode 100644 index 000000000..906bd5820 --- /dev/null +++ b/src/qt/setvotesdialog.h @@ -0,0 +1,29 @@ +#ifndef HYPERSTAKE_SETVOTESDIALOG_H +#define HYPERSTAKE_SETVOTESDIALOG_H + +#include +#include + +class WalletModel; + +namespace Ui { + class SetVotesDialog; +} + +class SetVotesDialog : public QDialog +{ + Q_OBJECT +public: + SetVotesDialog(QWidget* parent); + ~SetVotesDialog(); + void SetWalletModel(WalletModel* model); + void UpdateTable(); +private slots: + void on_voteButton_clicked(); +private: + Ui::SetVotesDialog* ui; + WalletModel* walletModel; + void Clear(); +}; + +#endif //HYPERSTAKE_SETVOTESDIALOG_H diff --git a/src/qt/signverifymessagedialog.cpp b/src/qt/signverifymessagedialog.cpp index bf6f6db4d..7d191c287 100644 --- a/src/qt/signverifymessagedialog.cpp +++ b/src/qt/signverifymessagedialog.cpp @@ -109,7 +109,8 @@ void SignVerifyMessageDialog::on_signMessageButton_SM_clicked() if (!addr.IsValid()) { ui->addressIn_SM->setValid(false); - ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_SM->setProperty("status", "error"); + ui->statusLabel_SM->style()->polish(ui->statusLabel_SM); ui->statusLabel_SM->setText(tr("The entered address is invalid.") + QString(" ") + tr("Please check the address and try again.")); return; } @@ -117,7 +118,8 @@ void SignVerifyMessageDialog::on_signMessageButton_SM_clicked() if (!addr.GetKeyID(keyID)) { ui->addressIn_SM->setValid(false); - ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_SM->setProperty("status", "error"); + ui->statusLabel_SM->style()->polish(ui->statusLabel_SM); ui->statusLabel_SM->setText(tr("The entered address does not refer to a key.") + QString(" ") + tr("Please check the address and try again.")); return; } @@ -125,7 +127,8 @@ void SignVerifyMessageDialog::on_signMessageButton_SM_clicked() WalletModel::UnlockContext ctx(model->requestUnlock()); if (!ctx.isValid()) { - ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_SM->setProperty("status", "error"); + ui->statusLabel_SM->style()->polish(ui->statusLabel_SM); ui->statusLabel_SM->setText(tr("Wallet unlock was cancelled.")); return; } @@ -133,7 +136,8 @@ void SignVerifyMessageDialog::on_signMessageButton_SM_clicked() CKey key; if (!pwalletMain->GetKey(keyID, key)) { - ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_SM->setProperty("status", "error"); + ui->statusLabel_SM->style()->polish(ui->statusLabel_SM); ui->statusLabel_SM->setText(tr("Private key for the entered address is not available.")); return; } @@ -145,12 +149,14 @@ void SignVerifyMessageDialog::on_signMessageButton_SM_clicked() std::vector vchSig; if (!key.SignCompact(Hash(ss.begin(), ss.end()), vchSig)) { - ui->statusLabel_SM->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_SM->setProperty("status", "error"); + ui->statusLabel_SM->style()->polish(ui->statusLabel_SM); ui->statusLabel_SM->setText(QString("") + tr("Message signing failed.") + QString("")); return; } - ui->statusLabel_SM->setStyleSheet("QLabel { color: green; }"); + ui->statusLabel_SM->setProperty("status", "ok"); + ui->statusLabel_SM->style()->polish(ui->statusLabel_SM); ui->statusLabel_SM->setText(QString("") + tr("Message signed.") + QString("")); ui->signatureOut_SM->setText(QString::fromStdString(EncodeBase64(&vchSig[0], vchSig.size()))); @@ -190,7 +196,8 @@ void SignVerifyMessageDialog::on_verifyMessageButton_VM_clicked() if (!addr.IsValid()) { ui->addressIn_VM->setValid(false); - ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_VM->setProperty("status", "error"); + ui->statusLabel_VM->style()->polish(ui->statusLabel_VM); ui->statusLabel_VM->setText(tr("The entered address is invalid.") + QString(" ") + tr("Please check the address and try again.")); return; } @@ -198,7 +205,8 @@ void SignVerifyMessageDialog::on_verifyMessageButton_VM_clicked() if (!addr.GetKeyID(keyID)) { ui->addressIn_VM->setValid(false); - ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_VM->setProperty("status", "error"); + ui->statusLabel_VM->style()->polish(ui->statusLabel_VM); ui->statusLabel_VM->setText(tr("The entered address does not refer to a key.") + QString(" ") + tr("Please check the address and try again.")); return; } @@ -209,7 +217,8 @@ void SignVerifyMessageDialog::on_verifyMessageButton_VM_clicked() if (fInvalid) { ui->signatureIn_VM->setValid(false); - ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_VM->setProperty("status", "error"); + ui->statusLabel_VM->style()->polish(ui->statusLabel_VM); ui->statusLabel_VM->setText(tr("The signature could not be decoded.") + QString(" ") + tr("Please check the signature and try again.")); return; } @@ -222,19 +231,22 @@ void SignVerifyMessageDialog::on_verifyMessageButton_VM_clicked() if (!key.SetCompactSignature(Hash(ss.begin(), ss.end()), vchSig)) { ui->signatureIn_VM->setValid(false); - ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_VM->setProperty("status", "error"); + ui->statusLabel_VM->style()->polish(ui->statusLabel_VM); ui->statusLabel_VM->setText(tr("The signature did not match the message digest.") + QString(" ") + tr("Please check the signature and try again.")); return; } if (!(CBitcoinAddress(key.GetPubKey().GetID()) == addr)) { - ui->statusLabel_VM->setStyleSheet("QLabel { color: red; }"); + ui->statusLabel_VM->setProperty("status", "error"); + ui->statusLabel_VM->style()->polish(ui->statusLabel_VM); ui->statusLabel_VM->setText(QString("") + tr("Message verification failed.") + QString("")); return; } - ui->statusLabel_VM->setStyleSheet("QLabel { color: green; }"); + ui->statusLabel_VM->setProperty("status", "ok"); + ui->statusLabel_VM->style()->polish(ui->statusLabel_VM); ui->statusLabel_VM->setText(QString("") + tr("Message verified.") + QString("")); } diff --git a/src/qt/transactionfilterproxy.cpp b/src/qt/transactionfilterproxy.cpp index 16fb4dab9..ad71d8455 100644 --- a/src/qt/transactionfilterproxy.cpp +++ b/src/qt/transactionfilterproxy.cpp @@ -29,7 +29,8 @@ bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex & QDateTime datetime = index.data(TransactionTableModel::DateRole).toDateTime(); QString address = index.data(TransactionTableModel::AddressRole).toString(); QString label = index.data(TransactionTableModel::LabelRole).toString(); - qint64 amount = llabs(index.data(TransactionTableModel::AmountRole).toLongLong()); + qint64 amount = index.data(TransactionTableModel::AmountRole).toLongLong(); + qint64 abs_amount = llabs(amount); if(!(TYPE(type) & typeFilter)) return false; @@ -37,9 +38,11 @@ bool TransactionFilterProxy::filterAcceptsRow(int sourceRow, const QModelIndex & return false; if (!address.contains(addrPrefix, Qt::CaseInsensitive) && !label.contains(addrPrefix, Qt::CaseInsensitive)) return false; - if(amount < minAmount) + if(abs_amount < minAmount) return false; + totalAmount += amount; + return true; } @@ -47,24 +50,28 @@ void TransactionFilterProxy::setDateRange(const QDateTime &from, const QDateTime { this->dateFrom = from; this->dateTo = to; + totalAmount = 0; invalidateFilter(); } void TransactionFilterProxy::setAddressPrefix(const QString &addrPrefix) { this->addrPrefix = addrPrefix; + totalAmount = 0; invalidateFilter(); } void TransactionFilterProxy::setTypeFilter(quint32 modes) { this->typeFilter = modes; + totalAmount = 0; invalidateFilter(); } void TransactionFilterProxy::setMinAmount(qint64 minimum) { this->minAmount = minimum; + totalAmount = 0; invalidateFilter(); } diff --git a/src/qt/transactionfilterproxy.h b/src/qt/transactionfilterproxy.h index 30b98588f..b7156b99e 100644 --- a/src/qt/transactionfilterproxy.h +++ b/src/qt/transactionfilterproxy.h @@ -3,6 +3,7 @@ #include #include +#include /** Filter the transaction list according to pre-specified rules. */ class TransactionFilterProxy : public QSortFilterProxyModel @@ -32,6 +33,9 @@ class TransactionFilterProxy : public QSortFilterProxyModel void setLimit(int limit); int rowCount(const QModelIndex &parent = QModelIndex()) const; + + int64_t getTotalAmount() const { return totalAmount; } + protected: bool filterAcceptsRow(int source_row, const QModelIndex & source_parent) const; @@ -42,6 +46,7 @@ class TransactionFilterProxy : public QSortFilterProxyModel quint32 typeFilter; qint64 minAmount; int limitRows; + mutable int64_t totalAmount; signals: diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index 18858e205..92aad352c 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -24,7 +24,7 @@ bool TransactionRecord::showTransaction(const CWalletTx &wtx) QList TransactionRecord::decomposeTransaction(const CWallet *wallet, const CWalletTx &wtx) { QList parts; - int64 nTime = wtx.GetTxTime(); + int64 nTime = wtx.nTime; int64 nCredit = wtx.GetCredit(true); int64 nDebit = wtx.GetDebit(); int64 nNet = nCredit - nDebit; @@ -33,8 +33,49 @@ QList TransactionRecord::decomposeTransaction(const CWallet * if (wtx.IsCoinStake()) { - // Stake generation - parts.append(TransactionRecord(hash, nTime, TransactionRecord::StakeMint, "", -nDebit, wtx.GetValueOut())); + CTxDestination address; + if (!ExtractDestination(wtx.vout[1].scriptPubKey, address)) + return parts; + + if(!IsMine(*wallet, address)) //if the address is not yours then it means you have a tx sent to you in someone elses coinstake tx + { + for(unsigned int i = 0; i < wtx.vout.size(); i++) + { + if(i == 0) + continue; // first tx is blank + CTxDestination outAddress; + if(ExtractDestination(wtx.vout[i].scriptPubKey, outAddress)) + { + if(IsMine(*wallet, outAddress)) + { + TransactionRecord txrMultiSendRec = TransactionRecord(hash, nTime, TransactionRecord::RecvWithAddress, CBitcoinAddress(outAddress).ToString(), wtx.vout[i].nValue, 0); + parts.append(txrMultiSendRec); + } + } + } + } + else + { + TransactionRecord txrCoinStake = TransactionRecord(hash, nTime, TransactionRecord::StakeMint, CBitcoinAddress(address).ToString(), -nDebit, wtx.GetValueOut()); + // Stake generation + parts.append(txrCoinStake); + + //if some of your outputs went to another address we will make them as a sendtoaddress tx + for(unsigned int i = 0; i < wtx.vout.size(); i++) + { + if(i == 0) + continue; //first tx is blank + CTxDestination outAddress; + if(ExtractDestination(wtx.vout[i].scriptPubKey, outAddress)) + { + if(CBitcoinAddress(outAddress).ToString() != CBitcoinAddress(address).ToString()) + { + TransactionRecord txrCoinStakeMultiSend = TransactionRecord(hash, nTime, TransactionRecord::SendToAddress, CBitcoinAddress(outAddress).ToString(), wtx.vout[i].nValue * -1, 0); + parts.append(txrCoinStakeMultiSend); + } + } + } + } } else if (nNet > 0 || wtx.IsCoinBase()) { @@ -84,10 +125,15 @@ QList TransactionRecord::decomposeTransaction(const CWallet * if (fAllFromMe && fAllToMe) { // Payment to self - int64 nChange = wtx.GetChange(); - - parts.append(TransactionRecord(hash, nTime, TransactionRecord::SendToSelf, "", - -(nDebit - nChange), nCredit - nChange)); + int64 nChange = wtx.GetChange(); + TransactionRecord sub(hash, nTime); + sub.type = TransactionRecord::SendToSelf; + sub.credit = nCredit - nChange; + sub.debit = -(nDebit - nChange); + CTxDestination address; + if (ExtractDestination(wtx.vout[0].scriptPubKey, address)) + sub.address = CBitcoinAddress(address).ToString(); + parts.append(sub); } else if (fAllFromMe) { diff --git a/src/qt/transactiontablemodel.cpp b/src/qt/transactiontablemodel.cpp index 2e9cc4643..6954416e1 100644 --- a/src/qt/transactiontablemodel.cpp +++ b/src/qt/transactiontablemodel.cpp @@ -19,6 +19,8 @@ #include #include +#include + // Amount column is right-aligned it contains numbers static int column_alignments[] = { Qt::AlignLeft|Qt::AlignVCenter, @@ -223,13 +225,13 @@ TransactionTableModel::TransactionTableModel(CWallet* wallet, WalletModel *paren priv(new TransactionTablePriv(wallet, this)), cachedNumBlocks(0) { - columns << QString() << tr("Date") << tr("Type") << tr("Address") << tr("Amount"); + columns << QString() << tr("Date") << tr("Type") << tr("Address/Label") << tr("Amount"); priv->refreshWallet(); QTimer *timer = new QTimer(this); connect(timer, SIGNAL(timeout()), this, SLOT(updateConfirmations())); - timer->start(MODEL_UPDATE_DELAY); + timer->start(TXTABLE_UPDATE_DELAY); connect(walletModel->getOptionsModel(), SIGNAL(displayUnitChanged(int)), this, SLOT(updateDisplayUnit())); } @@ -276,6 +278,8 @@ int TransactionTableModel::columnCount(const QModelIndex &parent) const QString TransactionTableModel::formatTxStatus(const TransactionRecord *wtx) const { QString status; + float rate, days; + CWalletTx tx, ptx; switch(wtx->status.status) { @@ -303,6 +307,25 @@ QString TransactionTableModel::formatTxStatus(const TransactionRecord *wtx) cons status += "\n" + tr("Mined balance will be available when it matures in %n more block(s)", "", wtx->status.matures_in); break; case TransactionStatus::Mature: + if (wallet->GetTransaction(wtx->hash, tx)) { + if (tx.vin.size() == 1) { + rate = 100.0f * (wtx->credit + wtx->debit) / -wtx->debit; + if (wallet->GetTransaction(tx.vin[0].prevout.hash, ptx)) { + days = (tx.nTime - ptx.nTime) / 86400.0f; + status += "\n" + tr("%1% staked in %2 days").arg(rate).arg(days); + if (wtx->credit + wtx->debit == 1000 * COIN) { + uint64_t capped = -wtx->debit * 7.5f * days / 365.f - 1000 * COIN; + status += "\n" + tr("About %1 HYP capped").arg(capped / (float)COIN); + float unCappedStake = (capped / (float)COIN) + 1000; + status += "\n" + tr("Uncapped Stake: %1").arg((unCappedStake)); + //status += "\n" +tr("Weight: %1").arg(unCappedStake * (days - (8/24))); + } + float nWeight = (-wtx->debit)/(float)COIN * (std::min(days, (float)(30 - (8/24))) - 8/24); + status += "\n" + tr("Original UTXO: %1").arg((float)(-wtx->debit)/COIN); + status += "\n" + tr("Weight: %1").arg(nWeight); + } + } + } break; case TransactionStatus::MaturesWarning: status += "\n" + tr("This block was not received by any other nodes and will probably not be accepted!"); @@ -360,6 +383,7 @@ QString TransactionTableModel::formatTxType(const TransactionRecord *wtx) const case TransactionRecord::SendToSelf: return tr("Payment to yourself"); case TransactionRecord::StakeMint: + return tr("Minted"); case TransactionRecord::Generated: return tr("Mined"); default: @@ -375,7 +399,6 @@ QVariant TransactionTableModel::txAddressDecoration(const TransactionRecord *wtx case TransactionRecord::StakeMint: { QString str = BitcoinUnits::format(walletModel->getOptionsModel()->getDisplayUnit(), wtx->credit + wtx->debit); - float dd = str.toFloat(); return QIcon(":/icons/tx_mined"); } case TransactionRecord::RecvWithAddress: @@ -403,6 +426,9 @@ QString TransactionTableModel::formatTxToAddress(const TransactionRecord *wtx, b case TransactionRecord::SendToOther: return QString::fromStdString(wtx->address); case TransactionRecord::SendToSelf: + return lookupAddress(wtx->address, tooltip); + case TransactionRecord::StakeMint: + return lookupAddress(wtx->address, tooltip); default: return tr("(n/a)"); } @@ -526,6 +552,8 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const return formatTxToAddress(rec, false); case Amount: return formatTxAmount(rec); + case Depth: + return QString::number(rec->status.depth); } break; case Qt::EditRole: @@ -542,6 +570,8 @@ QVariant TransactionTableModel::data(const QModelIndex &index, int role) const return formatTxToAddress(rec, true); case Amount: return rec->credit + rec->debit; + case Depth: + return rec->status.depth; } break; case Qt::ToolTipRole: diff --git a/src/qt/transactiontablemodel.h b/src/qt/transactiontablemodel.h index fd321ce28..43376f5ab 100644 --- a/src/qt/transactiontablemodel.h +++ b/src/qt/transactiontablemodel.h @@ -23,7 +23,8 @@ class TransactionTableModel : public QAbstractTableModel Date = 1, Type = 2, ToAddress = 3, - Amount = 4 + Amount = 4, + Depth = 5 }; /** Roles to get specific information from a transaction row. diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index 7a1af98d6..7f3bf1694 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -75,7 +75,6 @@ TransactionView::TransactionView(QWidget *parent) : TransactionFilterProxy::TYPE(TransactionRecord::SendToOther)); typeWidget->addItem(tr("To yourself"), TransactionFilterProxy::TYPE(TransactionRecord::SendToSelf)); typeWidget->addItem(tr("Minted"), TransactionFilterProxy::TYPE(TransactionRecord::StakeMint)); - typeWidget->addItem(tr("Mined"), TransactionFilterProxy::TYPE(TransactionRecord::Generated)); typeWidget->addItem(tr("Other"), TransactionFilterProxy::TYPE(TransactionRecord::Other)); hlayout->addWidget(typeWidget); @@ -128,14 +127,19 @@ TransactionView::TransactionView(QWidget *parent) : QAction *copyLabelAction = new QAction(tr("Copy label"), this); QAction *copyAmountAction = new QAction(tr("Copy amount"), this); QAction *editLabelAction = new QAction(tr("Edit label"), this); + QAction *copyTxID = new QAction(tr("Copy Tx ID"), this); QAction *showDetailsAction = new QAction(tr("Show transaction details"), this); + QAction *showBlockBrowser = new QAction(tr("Show transaction in block browser"), this); contextMenu = new QMenu(); contextMenu->addAction(copyAddressAction); contextMenu->addAction(copyLabelAction); contextMenu->addAction(copyAmountAction); contextMenu->addAction(editLabelAction); + contextMenu->addAction(copyTxID); contextMenu->addAction(showDetailsAction); + contextMenu->addAction(showBlockBrowser); + // Connect actions connect(dateWidget, SIGNAL(activated(int)), this, SLOT(chooseDate(int))); @@ -150,7 +154,10 @@ TransactionView::TransactionView(QWidget *parent) : connect(copyLabelAction, SIGNAL(triggered()), this, SLOT(copyLabel())); connect(copyAmountAction, SIGNAL(triggered()), this, SLOT(copyAmount())); connect(editLabelAction, SIGNAL(triggered()), this, SLOT(editLabel())); + connect(copyTxID, SIGNAL(triggered()), this, SLOT(copyTx())); connect(showDetailsAction, SIGNAL(triggered()), this, SLOT(showDetails())); + connect(showBlockBrowser, SIGNAL(triggered()), this, SLOT(showBrowser())); + } void TransactionView::setModel(WalletModel *model) @@ -171,7 +178,7 @@ void TransactionView::setModel(WalletModel *model) transactionView->setSelectionBehavior(QAbstractItemView::SelectRows); transactionView->setSelectionMode(QAbstractItemView::ExtendedSelection); transactionView->setSortingEnabled(true); - transactionView->sortByColumn(TransactionTableModel::Status, Qt::DescendingOrder); + transactionView->sortByColumn(TransactionTableModel::Date, Qt::DescendingOrder); transactionView->verticalHeader()->hide(); transactionView->horizontalHeader()->resizeSection( @@ -180,10 +187,17 @@ void TransactionView::setModel(WalletModel *model) TransactionTableModel::Date, 120); transactionView->horizontalHeader()->resizeSection( TransactionTableModel::Type, 120); + #if QT_VERSION < 0x050000 transactionView->horizontalHeader()->setResizeMode( TransactionTableModel::ToAddress, QHeaderView::Stretch); + #else + transactionView->horizontalHeader()->setSectionResizeMode(TransactionTableModel::ToAddress, QHeaderView::Stretch); + #endif transactionView->horizontalHeader()->resizeSection( TransactionTableModel::Amount, 100); + + transactionProxyModel->setMinAmount(0); + updateTotalAmount(); } } @@ -192,7 +206,7 @@ void TransactionView::chooseDate(int idx) if(!transactionProxyModel) return; QDate current = QDate::currentDate(); - dateRangeWidget->setVisible(false); + enableDateRangeWidget(false); switch(dateWidget->itemData(idx).toInt()) { case All: @@ -229,10 +243,11 @@ void TransactionView::chooseDate(int idx) TransactionFilterProxy::MAX_DATE); break; case Range: - dateRangeWidget->setVisible(true); + enableDateRangeWidget(true); dateRangeChanged(); break; } + updateTotalAmount(); } void TransactionView::chooseType(int idx) @@ -241,6 +256,7 @@ void TransactionView::chooseType(int idx) return; transactionProxyModel->setTypeFilter( typeWidget->itemData(idx).toInt()); + updateTotalAmount(); } void TransactionView::changedPrefix(const QString &prefix) @@ -248,6 +264,7 @@ void TransactionView::changedPrefix(const QString &prefix) if(!transactionProxyModel) return; transactionProxyModel->setAddressPrefix(prefix); + updateTotalAmount(); } void TransactionView::changedAmount(const QString &amount) @@ -263,6 +280,13 @@ void TransactionView::changedAmount(const QString &amount) { transactionProxyModel->setMinAmount(0); } + updateTotalAmount(); +} + +void TransactionView::updateTotalAmount() +{ + QString str = BitcoinUnits::format(BitcoinUnits::BTC, transactionProxyModel->getTotalAmount()); + totalAmountWidget->setText(str); } void TransactionView::exportClicked() @@ -318,6 +342,11 @@ void TransactionView::copyAmount() GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::FormattedAmountRole); } +void TransactionView::copyTx() +{ + GUIUtil::copyEntryData(transactionView, 0, TransactionTableModel::TxIDRole); +} + void TransactionView::editLabel() { if(!transactionView->selectionModel() ||!model) @@ -376,15 +405,25 @@ void TransactionView::showDetails() } } +void TransactionView::enableDateRangeWidget(bool enable) +{ + dateFrom->setVisible(enable); + dateTo->setVisible(enable); + to->setVisible(enable); + range->setVisible(enable); +} + QWidget *TransactionView::createDateRangeWidget() { dateRangeWidget = new QFrame(); + dateRangeWidget->setObjectName("rangeFrame"); dateRangeWidget->setFrameStyle(QFrame::Panel | QFrame::Raised); dateRangeWidget->setContentsMargins(1,1,1,1); QHBoxLayout *layout = new QHBoxLayout(dateRangeWidget); layout->setContentsMargins(0,0,0,0); layout->addSpacing(23); - layout->addWidget(new QLabel(tr("Range:"))); + range = new QLabel(tr("Range:")); + layout->addWidget(range); dateFrom = new QDateTimeEdit(this); dateFrom->setDisplayFormat("dd/MM/yy"); @@ -392,7 +431,8 @@ QWidget *TransactionView::createDateRangeWidget() dateFrom->setMinimumWidth(100); dateFrom->setDate(QDate::currentDate().addDays(-7)); layout->addWidget(dateFrom); - layout->addWidget(new QLabel(tr("to"))); + to = new QLabel(tr("to")); + layout->addWidget(to); dateTo = new QDateTimeEdit(this); dateTo->setDisplayFormat("dd/MM/yy"); @@ -402,8 +442,15 @@ QWidget *TransactionView::createDateRangeWidget() layout->addWidget(dateTo); layout->addStretch(); + layout->addWidget(new QLabel(tr("Total:"))); + totalAmountWidget = new QLabel(this); + totalAmountWidget->setText("0"); + totalAmountWidget->setFixedWidth(120); + totalAmountWidget->setTextInteractionFlags(Qt::TextSelectableByMouse | Qt::TextSelectableByKeyboard); + layout->addWidget(totalAmountWidget); + // Hide by default - dateRangeWidget->setVisible(false); + enableDateRangeWidget(false); // Notify on change connect(dateFrom, SIGNAL(dateChanged(QDate)), this, SLOT(dateRangeChanged())); @@ -419,6 +466,7 @@ void TransactionView::dateRangeChanged() transactionProxyModel->setDateRange( QDateTime(dateFrom->date()), QDateTime(dateTo->date()).addDays(1)); + updateTotalAmount(); } void TransactionView::focusTransaction(const QModelIndex &idx) @@ -430,3 +478,16 @@ void TransactionView::focusTransaction(const QModelIndex &idx) transactionView->setCurrentIndex(targetIdx); transactionView->setFocus(); } + +void TransactionView::showBrowser() +{ + if(!transactionView->selectionModel()) + return; + QModelIndexList selection = transactionView->selectionModel()->selectedRows(); + QString transactionId; + + if(!selection.isEmpty()) + transactionId = selection.at(0).data(TransactionTableModel::TxIDRole).toString(); + + emit blockBrowserSignal(transactionId); +} diff --git a/src/qt/transactionview.h b/src/qt/transactionview.h index 4ade3ecd5..a980b32d4 100644 --- a/src/qt/transactionview.h +++ b/src/qt/transactionview.h @@ -14,6 +14,7 @@ class QModelIndex; class QMenu; class QFrame; class QDateTimeEdit; +class QLabel; QT_END_NAMESPACE /** Widget showing the transaction list for a wallet, including a filter row. @@ -48,15 +49,23 @@ class TransactionView : public QWidget QComboBox *typeWidget; QLineEdit *addressWidget; QLineEdit *amountWidget; + QLabel *totalAmountWidgetLabel; + QLabel *totalAmountWidget; QMenu *contextMenu; QFrame *dateRangeWidget; QDateTimeEdit *dateFrom; QDateTimeEdit *dateTo; + QLabel *to; + QLabel *range; QWidget *createDateRangeWidget(); +private: + void updateTotalAmount(); + void enableDateRangeWidget(bool enable); + private slots: void contextualMenu(const QPoint &); void dateRangeChanged(); @@ -65,9 +74,12 @@ private slots: void editLabel(); void copyLabel(); void copyAmount(); + void copyTx(); + void showBrowser(); signals: void doubleClicked(const QModelIndex&); + void blockBrowserSignal(QString transactionId); public slots: void chooseDate(int idx); diff --git a/src/qt/votingdialog.cpp b/src/qt/votingdialog.cpp new file mode 100644 index 000000000..211147dfe --- /dev/null +++ b/src/qt/votingdialog.cpp @@ -0,0 +1,45 @@ +#include "votingdialog.h" +#include "ui_votingdialog.h" +#include "createproposaldialog.h" +#include "proposalsdialog.h" +#include "setvotesdialog.h" + +VotingDialog::VotingDialog(QWidget* parent) : + QDialog(parent), + ui(new Ui::VotingDialog) +{ + ui->setupUi(this); + proposalsDialog = new ProposalsDialog(this); + createProposalDialog = new CreateProposalDialog(this); + setVotesDialog = new SetVotesDialog(this); +} + +VotingDialog::~VotingDialog() +{ + delete ui; +} + +void VotingDialog::SetWalletModel(WalletModel *model) +{ + walletModel = model; + createProposalDialog->SetWalletModel(model); + setVotesDialog->SetWalletModel(model); + proposalsDialog->SetWalletModel(model); +} + +void VotingDialog::on_button_CreateProposal_clicked() +{ + createProposalDialog->show(); +} + +void VotingDialog::on_button_ViewProposals_clicked() +{ + proposalsDialog->show(); + proposalsDialog->UpdateTable(); +} + +void VotingDialog::on_button_SetVotes_clicked() +{ + setVotesDialog->show(); + setVotesDialog->UpdateTable(); +} diff --git a/src/qt/votingdialog.h b/src/qt/votingdialog.h new file mode 100644 index 000000000..8e035ea54 --- /dev/null +++ b/src/qt/votingdialog.h @@ -0,0 +1,37 @@ +#ifndef VOTINGDIALOG_H +#define VOTINGDIALOG_H + +#include +#include + +class CreateProposalDialog; +class ProposalsDialog; +class SetVotesDialog; +class WalletModel; + +namespace Ui { +class VotingDialog; +} + +class VotingDialog : public QDialog +{ + Q_OBJECT +public: + explicit VotingDialog(QWidget* parent = 0); + ~VotingDialog(); + void SetWalletModel(WalletModel* model); + +public slots: + void on_button_ViewProposals_clicked(); + void on_button_CreateProposal_clicked(); + void on_button_SetVotes_clicked(); + +private: + Ui::VotingDialog *ui; + CreateProposalDialog* createProposalDialog; + ProposalsDialog* proposalsDialog; + SetVotesDialog* setVotesDialog; + WalletModel* walletModel; +}; + +#endif // VOTINGDIALOG_H diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 6c3283426..a378aad1c 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -129,7 +129,66 @@ bool WalletModel::validateAddress(const QString &address) return addressParsed.IsValid(); } -WalletModel::SendCoinsReturn WalletModel::sendCoins(const QList &recipients, const CCoinControl *coinControl) +bool WalletModel::sendProposal(const CVoteProposal& proposal, uint256& txid) +{ + CTransaction tx; + if (!proposal.ConstructTransaction(tx)) + return false; + CWalletTx wtx(wallet, tx); + + //! Get available coins and add enough to cover the proposal fee + std::vector vCoins; + wallet->AvailableCoins(vCoins, true); + + int64 nFee = 5 * COIN; + int64 nValueIn = 0; + + std::set > setCoins; + if (wallet->SelectCoinsMinConf(nFee, tx.nTime, 1, 6, vCoins, setCoins, nValueIn)) + return false; + + //! Fill vin + for (std::pair coin : setCoins) + wtx.vin.push_back(CTxIn(coin.first->GetHash(),coin.second)); + + //! Add the min value required for an output to the proposal UTXO + wtx.vout[0].nValue = MIN_TXOUT_AMOUNT; + + //! Figure out change amount + nFee -= wtx.vout[0].nValue; + int64 nChange = nValueIn - nFee - MIN_TXOUT_AMOUNT; + if (nChange > 500) { + //!Lookup the address of one of the inputs and return the change to that address + uint256 hashBlock; + CTransaction txPrev; + if(!::GetTransaction(wtx.vin[0].prevout.hash, txPrev, hashBlock)) + return false; + + CScript scriptReturn = txPrev.vout[wtx.vin[0].prevout.n].scriptPubKey; + CTxOut out(nChange, scriptReturn); + + //!Add the change output to the new transaction + wtx.vout.push_back(out); + } + + //! Sign the transaction + int nIn = 0; + for (const std::pair& coin : setCoins) { + if (!SignSignature(*wallet, *coin.first, wtx, nIn++)) + return false; + } + + //! Broadcast the transaction to the network + CReserveKey reserveKey = CReserveKey(wallet); + if (!wallet->CommitTransaction(wtx, reserveKey)) + return false; + + txid = wtx.GetHash(); + + return true; +} + +WalletModel::SendCoinsReturn WalletModel::sendCoins(const QList &recipients, int nSplitBlock, const CCoinControl *coinControl) { qint64 total = 0; QSet setAddress; @@ -192,7 +251,7 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(const QListCreateTransaction(vecSend, wtx, keyChange, nFeeRequired, coinControl); + bool fCreated = wallet->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired, nSplitBlock, false, coinControl); if(!fCreated) { @@ -280,7 +339,7 @@ bool WalletModel::setWalletEncrypted(bool encrypted, const SecureString &passphr } } -bool WalletModel::setWalletLocked(bool locked, const SecureString &passPhrase) +bool WalletModel::setWalletLocked(bool locked, const SecureString &passPhrase, bool formint) { if(locked) { @@ -290,7 +349,12 @@ bool WalletModel::setWalletLocked(bool locked, const SecureString &passPhrase) else { // Unlock - return wallet->Unlock(passPhrase); + bool rc; + rc = wallet->Unlock(passPhrase); + if (rc && formint) + wallet->fWalletUnlockMintOnly=true; + return rc; + } } @@ -310,11 +374,22 @@ bool WalletModel::backupWallet(const QString &filename) return BackupWallet(*wallet, filename.toLocal8Bit().data()); } +//Information for coin control void WalletModel::getStakeWeightFromValue(const int64& nTime, const int64& nValue, uint64& nWeight) { wallet->GetStakeWeightFromValue(nTime, nValue, nWeight); } +void WalletModel::setSplitBlock(bool fSplitBlock) +{ + wallet->fSplitBlock = fSplitBlock; +} + +bool WalletModel::getSplitBlock() +{ + return wallet->fSplitBlock; +} + void WalletModel::checkWallet(int& nMismatchSpent, int64& nBalanceInQuestion, int& nOrphansFound) { wallet->FixSpentCoins(nMismatchSpent, nBalanceInQuestion, nOrphansFound, true); @@ -370,6 +445,13 @@ void WalletModel::unsubscribeFromCoreSignals() WalletModel::UnlockContext WalletModel::requestUnlock() { bool was_locked = getEncryptionStatus() == Locked; + + if ((!was_locked) && wallet->fWalletUnlockMintOnly) + { + setWalletLocked(true); + was_locked = getEncryptionStatus() == Locked; + } + if(was_locked) { // Request UI to unlock wallet @@ -378,7 +460,7 @@ WalletModel::UnlockContext WalletModel::requestUnlock() // If wallet is still locked, unlock was failed or cancelled, mark context as invalid bool valid = getEncryptionStatus() != Locked; - return UnlockContext(this, valid, was_locked); + return UnlockContext(this, valid, was_locked && !wallet->fWalletUnlockMintOnly); } WalletModel::UnlockContext::UnlockContext(WalletModel *wallet, bool valid, bool relock): @@ -469,3 +551,8 @@ void WalletModel::UnlockContext::CopyFrom(const UnlockContext& rhs) { return; } + +bool WalletModel::isMine(const CBitcoinAddress &address) +{ + return IsMine(*wallet, address.Get()); +} diff --git a/src/qt/walletmodel.h b/src/qt/walletmodel.h index 0a7023129..6f89403a4 100644 --- a/src/qt/walletmodel.h +++ b/src/qt/walletmodel.h @@ -17,6 +17,8 @@ class COutput; class COutPoint; class uint256; class CCoinControl; +class CBitcoinAddress; +class CVoteProposal; QT_BEGIN_NAMESPACE class QTimer; @@ -86,20 +88,22 @@ class WalletModel : public QObject }; // Send coins to a list of recipients - SendCoinsReturn sendCoins(const QList &recipients, const CCoinControl *coinControl=NULL); + SendCoinsReturn sendCoins(const QList &recipients, int SplitBlock, const CCoinControl *coinControl=NULL); // Wallet encryption bool setWalletEncrypted(bool encrypted, const SecureString &passphrase); // Passphrase only needed when unlocking - bool setWalletLocked(bool locked, const SecureString &passPhrase=SecureString()); + bool setWalletLocked(bool locked, const SecureString &passPhrase=SecureString(), bool formint=false); bool changePassphrase(const SecureString &oldPass, const SecureString &newPass); // Wallet backup bool backupWallet(const QString &filename); // Wallet Repair void checkWallet(int& nMismatchSpent, qint64& nBalanceInQuestion, int& nOrphansFound); void repairWallet(int& nMismatchSpent, qint64& nBalanceInQuestion, int& nOrphansFound); - //Stake Weight for coin control dialog + // Pass coin control information void getStakeWeightFromValue(const qint64& nTime, const qint64& nValue, quint64& nWeight); + void setSplitBlock(bool fSplitBlock); + bool getSplitBlock(); // RAI object for unlocking wallet, returned by requestUnlock() class UnlockContext { @@ -129,6 +133,8 @@ class WalletModel : public QObject void lockCoin(COutPoint& output); void unlockCoin(COutPoint& output); void listLockedCoins(std::vector& vOutpts); + bool isMine(const CBitcoinAddress &address); + bool sendProposal(const CVoteProposal& proposal, uint256& txid); private: CWallet *wallet; diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 71ffdafdc..86f1213a8 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -5,6 +5,14 @@ #include "main.h" #include "bitcoinrpc.h" +#include "voteproposal.h" +#include "voteproposalmanager.h" +#include "voteobject.h" +#include "votetally.h" +#include "db.h" + +#include +#include using namespace json_spirit; using namespace std; @@ -42,15 +50,18 @@ double GetDifficulty(const CBlockIndex* blockindex) return dDiff; } -double GetPoSKernelPS() +double GetPoSKernelPS(const CBlockIndex* blockindex) { int nPoSInterval = 72; double dStakeKernelsTriedAvg = 0; int nStakesHandled = 0, nStakesTime = 0; - CBlockIndex* pindex = pindexBest;; - CBlockIndex* pindexPrevStake = NULL; + const CBlockIndex* pindex = pindexBest; + const CBlockIndex* pindexPrevStake = NULL; + if (blockindex != NULL) + pindex = blockindex; + while (pindex && nStakesHandled < nPoSInterval) { if (pindex->IsProofOfStake()) @@ -92,7 +103,7 @@ Object blockToJSON(const CBlock& block, const CBlockIndex* blockindex, bool fPri result.push_back(Pair("flags", strprintf("%s%s", blockindex->IsProofOfStake()? "proof-of-stake" : "proof-of-work", blockindex->GeneratedStakeModifier()? " stake-modifier": ""))); result.push_back(Pair("proofhash", blockindex->IsProofOfStake()? blockindex->hashProofOfStake.GetHex() : blockindex->GetBlockHash().GetHex())); result.push_back(Pair("entropybit", (int)blockindex->GetStakeEntropyBit())); - result.push_back(Pair("modifier", strprintf("%016"PRI64x, blockindex->nStakeModifier))); + result.push_back(Pair("modifier", strprintf("%016llx", blockindex->nStakeModifier))); result.push_back(Pair("modifierchecksum", strprintf("%08x", blockindex->nStakeModifierChecksum))); Array txinfo; BOOST_FOREACH (const CTransaction& tx, block.vtx) @@ -127,7 +138,7 @@ Value getblockcount(const Array& params, bool fHelp) return nBestHeight; } - +//comment Value getdifficulty(const Array& params, bool fHelp) { if (fHelp || params.size() != 0) @@ -234,23 +245,184 @@ Value getblockbynumber(const Array& params, bool fHelp) return blockToJSON(block, pblockindex, params.size() > 1 ? params[1].get_bool() : false); } -// ppcoin: get information of sync-checkpoint -Value getcheckpoint(const Array& params, bool fHelp) +// presstab HyperStake +Value exportdifficulty(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 1 || params.size() > 2) + throw runtime_error( + "export difficulty \n" + "interval will give difficulty for every Xth block\n" + "directory is the location to export the csv: C:\\example.csv)"); + + int nInterval = params[0].get_int(); + std::string strDir = params[1].get_str(); + + ofstream File; + + File.open(strDir.c_str()); + File << "Block, Difficulty" << endl; + for(int i = 0; i < nBestHeight; i += nInterval) + { + File << i; + File << ","; + File << GetDifficulty(FindBlockByHeight(i)) << endl; + } + File.close(); + return "succesfully exported"; +} + +// presstab HyperStake +Value listblocks(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 2) + throw runtime_error( + " <# of blocks to display>\n" + "list basic information about a range of blocks\n"); + unsigned int nTopBlock = params[0].get_int(); + unsigned int nRange = params[1].get_int(); + Array arrRet; + + for(unsigned int i = 0; i < nRange; i++) + { + Object blk; + unsigned int nBlockNumber = nTopBlock - i; + CBlockIndex* pindex = FindBlockByHeight(nBlockNumber); + blk.push_back(Pair("height", pindex->nHeight)); + blk.push_back(Pair("hash", pindex->GetBlockHash().GetHex())); + blk.push_back(Pair("time", (boost::int64_t)pindex->GetBlockTime())); + blk.push_back(Pair("difficulty", GetDifficulty(pindex))); + if(pindex->IsProofOfStake()) + blk.push_back(Pair("type", "PoS")); + else + blk.push_back(Pair("type", "PoW")); + blk.push_back(Pair("minted", ValueFromAmount(pindex->nMint))); + blk.push_back(Pair("money supply", ValueFromAmount(pindex->nMoneySupply))); + + arrRet.push_back(blk); + } + + return arrRet; +} + +// tuningmind +Value createproposal(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 6) + throw runtime_error( + "createproposal \n\n\n\n\n\n\n" + "Returns new VoteProposal object with specified parameters\n"); + // name of issue + string strName = params[0].get_str(); + // check version for existing proposals Shift + uint8_t nShift = params[1].get_int(); + // start time - will be changed to int StartHeight. unix time stamp + int64 nStartTime = params[2].get_int(); + // number of blocks with votes to count + int nCheckSpan = params[3].get_int(); + // cardinal items to vote on - convert to uint8 CheckSpan + uint8_t nBits = params[4].get_int(); + // description of issue - will go in different tx + std::string strDescription = params[5].get_str(); + + // the bit location object of the proposal + VoteLocation location(nShift + nBits - 1, nShift); + + Object results; + CVoteProposal proposal(strName, nStartTime, nCheckSpan, strDescription, location); + + //! Add the constructed proposal to a partial transaction + CTransaction tx; + proposal.ConstructTransaction(tx); + + //! Add the partial transaction to our globally accessible proposals map so that it can be called from elsewhere + uint256 hashProposal = tx.GetHash(); + mapPendingProposals.insert(make_pair(hashProposal, tx)); + + results.emplace_back(Pair("proposal_hash", hashProposal.GetHex().c_str())); + results.emplace_back(Pair("name", strName)); + results.emplace_back(Pair("shift", nShift)); + results.emplace_back(Pair("start_block", (boost::int64_t)nStartTime)); + results.emplace_back(Pair("check_span", nCheckSpan)); + results.emplace_back(Pair("bit_count", nBits)); + results.emplace_back(Pair("description", strDescription)); + + return results; +} + +Value listproposals(const Array& params, bool fHelp) { if (fHelp || params.size() != 0) throw runtime_error( - "getcheckpoint\n" - "Show info of synchronized checkpoint.\n"); + "getproposals\n" + "list proposals that have been found on the blockchain\n"); + + //! Grab each proposal by 1st getting the txid from mapProposals, 2nd using that txid to grab the proposal object from voteDB + Array arrRet; + CVoteDB voteDB("r"); + for (auto it : mapProposals) { + CVoteProposal proposal; + if (voteDB.ReadProposal(it.first, proposal)) { + Object jsonProposal; + jsonProposal.emplace_back(Pair("txhash", it.first.GetHex())); + jsonProposal.emplace_back(Pair("proposalhash", proposal.GetHash().GetHex())); + jsonProposal.emplace_back(Pair("name", proposal.GetName())); + jsonProposal.emplace_back(Pair("description", proposal.GetDescription())); + jsonProposal.emplace_back(Pair("shift", proposal.GetShift())); + jsonProposal.emplace_back(Pair("start_block", (boost::int64_t)proposal.GetStartHeight())); + jsonProposal.emplace_back(Pair("bit_count", proposal.GetBitCount())); + arrRet.emplace_back(jsonProposal); + } + } - Object result; - CBlockIndex* pindexCheckpoint; + return arrRet; +} - result.push_back(Pair("synccheckpoint", Checkpoints::hashSyncCheckpoint.ToString().c_str())); - pindexCheckpoint = mapBlockIndex[Checkpoints::hashSyncCheckpoint]; - result.push_back(Pair("height", pindexCheckpoint->nHeight)); - result.push_back(Pair("timestamp", DateTimeStrFormat(pindexCheckpoint->GetBlockTime()).c_str())); - if (mapArgs.count("-checkpointkey")) - result.push_back(Pair("checkpointmaster", true)); +Value getproposalstatus(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "getproposalstatus\n" + "\n" + "return the status of a proposal that is being voted on\n"); + + uint256 hash(params[0].get_str()); + CVoteDB voteDB("r"); + CVoteProposal proposal; + if (!voteDB.ReadProposal(hash, proposal)) + throw JSONRPCError(RPC_INVALID_PARAMETER, "failed to find proposal"); + + if (nBestHeight < (int)proposal.GetStartHeight()) { + Object obj; + obj.emplace_back(Pair("block_start", (int64_t)proposal.GetStartHeight())); + return obj; + } - return result; + int nHeightEnd = proposal.GetStartHeight() + proposal.GetCheckSpan(); + int nHeightTally; + if (nHeightEnd < nBestHeight) + nHeightTally = nHeightEnd; + else + nHeightTally = nBestHeight; + + CVoteTally tally = FindBlockByHeight(nHeightTally)->tally; + CVoteSummary summary; + if (!tally.GetSummary(proposal.GetHash(), summary)) + throw JSONRPCError(RPC_DATABASE_ERROR, "failed to find proposal in vote tally"); + + Object objRet; + int64_t nBlocksVoted = nHeightTally - summary.nBlockStart; + objRet.emplace_back(Pair("block_start", (int64_t)summary.nBlockStart)); + objRet.emplace_back(Pair("blocks_remaining", (int64_t)std::max(nHeightEnd - nBestHeight, 0))); + objRet.emplace_back(Pair("total_blocks_voted", nBlocksVoted)); + objRet.emplace_back(Pair("yes_votes", (int64_t)summary.nYesTally)); + objRet.emplace_back(Pair("no_votes", (int64_t)summary.nNoTally)); + double nAbstain = nBlocksVoted - summary.nNoTally - summary.nYesTally; + objRet.emplace_back(Pair("abstain_votes", nAbstain)); + double nRatio = 0; + if (nBlocksVoted) + nRatio = (double)summary.nYesTally / ((double)nBlocksVoted - nAbstain); + + objRet.emplace_back(Pair("ratio", nRatio)); + return objRet; } + diff --git a/src/rpcdump.cpp b/src/rpcdump.cpp index 2f5a03bf3..c66f11433 100644 --- a/src/rpcdump.cpp +++ b/src/rpcdump.cpp @@ -6,6 +6,7 @@ #include "bitcoinrpc.h" #include "ui_interface.h" #include "base58.h" +#include "bip38.h" #include @@ -47,7 +48,7 @@ Value importprivkey(const Array& params, bool fHelp) bool fGood = vchSecret.SetString(strSecret); if (!fGood) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key"); - if (fWalletUnlockMintOnly) // ppcoin: no importprivkey in mint-only mode + if (pwalletMain->fWalletUnlockMintOnly) // No importprivkey in mint-only mode throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Wallet is unlocked for minting only."); CKey key; @@ -82,7 +83,7 @@ Value dumpprivkey(const Array& params, bool fHelp) CBitcoinAddress address; if (!address.SetString(strAddress)) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid HyperStake address"); - if (fWalletUnlockMintOnly) // ppcoin: no dumpprivkey in mint-only mode + if (pwalletMain->fWalletUnlockMintOnly) // No dumpprivkey in mint-only mode throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Wallet is unlocked for minting only."); CKeyID keyID; if (!address.GetKeyID(keyID)) @@ -93,3 +94,92 @@ Value dumpprivkey(const Array& params, bool fHelp) throw JSONRPCError(RPC_WALLET_ERROR, "Private key for address " + strAddress + " is not known"); return CBitcoinSecret(vchSecret, fCompressed).ToString(); } + +Value bip38encrypt(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 2) + throw runtime_error( + "bip38encrypt \"HYP_address\"\n" + "\nEncrypts a private key corresponding to 'HYP_address'.\n" + "\nArguments:\n" + "1. \"HYP_address\" (string, required) The HYP address for the private key (you must hold the key already)\n" + "2. \"passphrase\" (string, required) The passphrase you want the private key to be encrypted with - Valid special chars: !#$%&'()*+,-./:;<=>?`{|}~ \n" + "\nResult:\n" + "\"key\" (string) The encrypted private key\n" + "\nExamples:\n"); + + EnsureWalletIsUnlocked(); + + string strAddress = params[0].get_str(); + string strPassphrase = params[1].get_str(); + + CBitcoinAddress address; + if (!address.SetString(strAddress)) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid HYP address"); + CKeyID keyID; + if (!address.GetKeyID(keyID)) + throw JSONRPCError(RPC_TYPE_ERROR, "Address does not refer to a key"); + CKey vchSecret; + if (!pwalletMain->GetKey(keyID, vchSecret)) + throw JSONRPCError(RPC_WALLET_ERROR, "Private key for address " + strAddress + " is not known"); + + uint256 privKey = vchSecret.GetPrivKey_256(); + string encryptedOut = BIP38_Encrypt(strAddress, strPassphrase, privKey); + + Object result; + result.push_back(Pair("Addess", strAddress)); + result.push_back(Pair("Encrypted Key", encryptedOut)); + + return result; +} + +Value bip38decrypt(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 2) + throw runtime_error( + "bip38decrypt encrypted_key password\n" + "\nDecrypts and then imports password protected private key.\n" + "\nArguments:\n" + "1. \"encryptedkey\" (string, required) The encrypted private key\n" + "2. \"passphrase\" (string, required) The passphrase you want the private key to be encrypted with\n" + + "\nResult:\n" + "\"key\" (string) The decrypted private key\n" + "\nExamples:\n"); + + EnsureWalletIsUnlocked(); + + /** Collect private key and passphrase **/ + string strKey = params[0].get_str(); + string strPassphrase = params[1].get_str(); + + uint256 privKey; + bool fCompressed; + if (!BIP38_Decrypt(strPassphrase, strKey, privKey, fCompressed)) + throw JSONRPCError(RPC_WALLET_ERROR, "Failed To Decrypt"); + + Object result; + result.push_back(Pair("privatekey", HexStr(privKey))); + + CKey key; + if (!key.SetPrivKey_Raw(privKey, fCompressed) || !key.IsValid()) + throw JSONRPCError(RPC_WALLET_ERROR, "Private Key Not Valid"); + + CPubKey pubkey = key.GetPubKey(); + result.push_back(Pair("Address", CBitcoinAddress(pubkey.GetID()).ToString())); + CKeyID vchAddress = key.GetPubKey().GetID(); + { + LOCK2(cs_main, pwalletMain->cs_wallet); + + pwalletMain->MarkDirty(); + pwalletMain->SetAddressBookName(vchAddress, ""); + + if (!pwalletMain->AddKey(key)) + throw JSONRPCError(RPC_WALLET_ERROR, "Error adding key to wallet"); + + pwalletMain->ScanForWalletTransactions(pindexGenesisBlock, true); + pwalletMain->ReacceptWalletTransactions(); + } + + return result; +} diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 0556b6441..b8822fc3b 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -22,45 +22,6 @@ Value getgenerate(const Array& params, bool fHelp) } -Value setgenerate(const Array& params, bool fHelp) -{ - if (fHelp || params.size() < 1 || params.size() > 2) - throw runtime_error( - "setgenerate [genproclimit]\n" - " is true or false to turn generation on or off.\n" - "Generation is limited to [genproclimit] processors, -1 is unlimited."); - - bool fGenerate = true; - if (params.size() > 0) - fGenerate = params[0].get_bool(); - - if (params.size() > 1) - { - int nGenProcLimit = params[1].get_int(); - mapArgs["-genproclimit"] = itostr(nGenProcLimit); - if (nGenProcLimit == 0) - fGenerate = false; - } - mapArgs["-gen"] = (fGenerate ? "1" : "0"); - - GenerateBitcoins(fGenerate, pwalletMain); - return Value::null; -} - - -Value gethashespersec(const Array& params, bool fHelp) -{ - if (fHelp || params.size() != 0) - throw runtime_error( - "gethashespersec\n" - "Returns a recent hashes per second performance measurement while generating."); - - if (GetTimeMillis() - nHPSTimerStart > 8000) - return (boost::int64_t)0; - return (boost::int64_t)dHashesPerSec; -} - - Value getmininginfo(const Array& params, bool fHelp) { if (fHelp || params.size() != 0) @@ -72,51 +33,13 @@ Value getmininginfo(const Array& params, bool fHelp) obj.push_back(Pair("blocks", (int)nBestHeight)); obj.push_back(Pair("currentblocksize",(uint64_t)nLastBlockSize)); obj.push_back(Pair("currentblocktx",(uint64_t)nLastBlockTx)); - obj.push_back(Pair("difficulty", (double)GetDifficulty())); + obj.push_back(Pair("PoS difficulty", GetDifficulty(GetLastBlockIndex(pindexBest, true)))); obj.push_back(Pair("errors", GetWarnings("statusbar"))); - obj.push_back(Pair("generate", GetBoolArg("-gen"))); - obj.push_back(Pair("genproclimit", (int)GetArg("-genproclimit", -1))); - obj.push_back(Pair("hashespersec", gethashespersec(params, false))); - obj.push_back(Pair("networkhashps", getnetworkhashps(params, false))); obj.push_back(Pair("pooledtx", (uint64_t)mempool.size())); obj.push_back(Pair("testnet", fTestNet)); return obj; } -// Litecoin: Return average network hashes per second based on last number of blocks. -Value GetNetworkHashPS(int lookup) { - if (pindexBest == NULL) - return 0; - - // If lookup is -1, then use blocks since last difficulty change. - if (lookup <= 0) - lookup = pindexBest->nHeight % 2016 + 1; - - // If lookup is larger than chain, then set it to chain length. - if (lookup > pindexBest->nHeight) - lookup = pindexBest->nHeight; - - CBlockIndex* pindexPrev = pindexBest; - for (int i = 0; i < lookup; i++) - pindexPrev = pindexPrev->pprev; - - double timeDiff = pindexBest->GetBlockTime() - pindexPrev->GetBlockTime(); - double timePerBlock = timeDiff / lookup; - - return (boost::int64_t)(((double)GetDifficulty() * pow(2.0, 32)) / timePerBlock); -} - -Value getnetworkhashps(const Array& params, bool fHelp) -{ - if (fHelp || params.size() > 1) - throw runtime_error( - "getnetworkhashps [blocks]\n" - "Returns the estimated network hashes per second based on the last 120 blocks.\n" - "Pass in [blocks] to override # of blocks, -1 specifies since last difficulty change."); - - return GetNetworkHashPS(params.size() > 0 ? params[0].get_int() : 120); -} - Value getworkex(const Array& params, bool fHelp) { @@ -550,3 +473,40 @@ Value submitblock(const Array& params, bool fHelp) return Value::null; } +Value setgenerate(const Array& params, bool fHelp) +{ + if (fHelp || params.size() < 1 || params.size() > 2) + throw runtime_error( + "setgenerate [genproclimit]\n" + " is true or false to turn generation on or off.\n" + "Generation is limited to [genproclimit] processors, -1 is unlimited."); + + bool fGenerate = true; + if (params.size() > 0) + fGenerate = params[0].get_bool(); + + if (params.size() > 1) + { + int nGenProcLimit = params[1].get_int(); + mapArgs["-genproclimit"] = itostr(nGenProcLimit); + if (nGenProcLimit == 0) + fGenerate = false; + } + mapArgs["-gen"] = (fGenerate ? "1" : "0"); + + GenerateBitcoins(fGenerate, pwalletMain); + return Value::null; +} + + +Value gethashespersec(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "gethashespersec\n" + "Returns a recent hashes per second performance measurement while generating."); + + if (GetTimeMillis() - nHPSTimerStart > 8000) + return (boost::int64_t)0; + return (boost::int64_t)dHashesPerSec; +} diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp index 0da677208..0471ab6d4 100644 --- a/src/rpcnet.cpp +++ b/src/rpcnet.cpp @@ -52,7 +52,7 @@ Value getpeerinfo(const Array& params, bool fHelp) Object obj; obj.push_back(Pair("addr", stats.addrName)); - obj.push_back(Pair("services", strprintf("%08"PRI64x, stats.nServices))); + obj.push_back(Pair("services", strprintf("%08llx", stats.nServices))); obj.push_back(Pair("lastsend", (boost::int64_t)stats.nLastSend)); obj.push_back(Pair("lastrecv", (boost::int64_t)stats.nLastRecv)); obj.push_back(Pair("conntime", (boost::int64_t)stats.nTimeConnected)); @@ -213,7 +213,7 @@ extern map mapAlerts; // ThreadRPCServer: holds cs_main and acquiring cs_vSend in alert.RelayTo()/PushMessage()/BeginMessage() Value sendalert(const Array& params, bool fHelp) { - if (fHelp || params.size() < 6) + if (fHelp || params.size() < 7) throw runtime_error( "sendalert [cancelupto]\n" " is the alert text message\n" @@ -222,6 +222,7 @@ Value sendalert(const Array& params, bool fHelp) " is the maximum applicable internal client version\n" " is integer priority number\n" " is the alert id\n" + " minutes from current time\n" "[cancelupto] cancels all alert id's up to this number\n" "Returns true or false."); @@ -233,18 +234,24 @@ Value sendalert(const Array& params, bool fHelp) alert.nMaxVer = params[3].get_int(); alert.nPriority = params[4].get_int(); alert.nID = params[5].get_int(); - if (params.size() > 6) - alert.nCancel = params[6].get_int(); + alert.nRelayUntil = GetAdjustedTime() + params[6].get_int(); + alert.nExpiration = GetAdjustedTime() + params[6].get_int(); + if (params.size() > 7) + alert.nCancel = params[7].get_int(); alert.nVersion = PROTOCOL_VERSION; - alert.nRelayUntil = GetAdjustedTime() + 365*24*60*60; - alert.nExpiration = GetAdjustedTime() + 365*24*60*60; CDataStream sMsg(SER_NETWORK, PROTOCOL_VERSION); sMsg << (CUnsignedAlert)alert; alert.vchMsg = vector(sMsg.begin(), sMsg.end()); - vector vchPrivKey = ParseHex(params[1].get_str()); - key.SetPrivKey(CPrivKey(vchPrivKey.begin(), vchPrivKey.end())); // if key is not correct openssl may crash + string strSecret = params[1].get_str(); + CBitcoinSecret vchSecret; + bool fGood = vchSecret.SetString(strSecret); + if (!fGood) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid private key"); + bool fCompressed; + CSecret secret = vchSecret.GetSecret(fCompressed); + key.SetSecret(secret, fCompressed); + if (!key.Sign(Hash(alert.vchMsg.begin(), alert.vchMsg.end()), alert.vchSig)) throw runtime_error( "Unable to sign alert, check private key?\n"); @@ -269,3 +276,5 @@ Value sendalert(const Array& params, bool fHelp) result.push_back(Pair("nCancel", alert.nCancel)); return result; } + + diff --git a/src/rpcrawtransaction.cpp b/src/rpcrawtransaction.cpp index da1bb489f..1f3c490c7 100644 --- a/src/rpcrawtransaction.cpp +++ b/src/rpcrawtransaction.cpp @@ -57,7 +57,18 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, Object& entry) else { in.push_back(Pair("txid", txin.prevout.hash.GetHex())); - in.push_back(Pair("vout", (boost::int64_t)txin.prevout.n)); + in.push_back(Pair("vout", (boost::int64_t)txin.prevout.n)); + + CTransaction txoutspent; + uint256 tempHash = 0; + if(GetTransaction( txin.prevout.hash, txoutspent, tempHash)) + { + in.push_back(Pair("value", ValueFromAmount(txoutspent.vout[txin.prevout.n].nValue))); + CTxDestination inputAddress; + ExtractDestination(txoutspent.vout[txin.prevout.n].scriptPubKey, inputAddress); + in.push_back(Pair("addressfrom", CBitcoinAddress(inputAddress).ToString())); + } + Object o; o.push_back(Pair("asm", txin.scriptSig.ToString())); o.push_back(Pair("hex", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()))); @@ -530,3 +541,32 @@ Value sendrawtransaction(const Array& params, bool fHelp) return hashTx.GetHex(); } + +Value gettxfee(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "gettxfee \n"); + + uint256 hash; + hash.SetHex(params[0].get_str()); + CTransaction tx; + uint256 hashBlock = 0; + if (!GetTransaction(hash, tx, hashBlock)) + return "Transaction not found"; + + int64 nTotalIn = 0; + for(unsigned int i = 0; i < tx.vin.size(); i++) + { + CTransaction tx2; + uint256 hashBlock2 = 0; + if (!GetTransaction(tx.vin[i].prevout.hash, tx2, hashBlock2)) + return 0; + nTotalIn += tx2.vout[tx.vin[i].prevout.n].nValue; + } + int64 nTotalOut = 0; + for(unsigned int i = 0; i < tx.vout.size(); i++) + nTotalOut += tx.vout[i].nValue; + + return ValueFromAmount(nTotalIn - nTotalOut); +} \ No newline at end of file diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index 2c177dfe1..25de5c819 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -9,16 +9,23 @@ #include "init.h" #include "main.h" #include "base58.h" +#include "coincontrol.h" +#include "voteobject.h" #include +#include using namespace json_spirit; using namespace std; +using namespace boost; int64 nWalletUnlockTime; +CCoinControl* coinControl = new CCoinControl; static CCriticalSection cs_nWalletUnlockTime; extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, json_spirit::Object& entry); +extern int64 nLastCoinStakeSearchInterval; +extern bool fGenerateBitcoins; std::string HelpRequiringPassphrase() { @@ -31,7 +38,7 @@ void EnsureWalletIsUnlocked() { if (pwalletMain->IsLocked()) throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first."); - if (fWalletUnlockMintOnly) + if (pwalletMain->fWalletUnlockMintOnly) throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Wallet unlocked for block minting only."); } @@ -84,147 +91,27 @@ Value getinfo(const Array& params, bool fHelp) obj.push_back(Pair("connections", (int)vNodes.size())); obj.push_back(Pair("proxy", (proxy.first.IsValid() ? proxy.first.ToStringIPPort() : string()))); obj.push_back(Pair("ip", addrSeenByPeer.ToStringIP())); - obj.push_back(Pair("difficulty", (double)GetDifficulty())); + obj.push_back(Pair("difficulty", GetDifficulty(GetLastBlockIndex(pindexBest, true)))); obj.push_back(Pair("testnet", fTestNet)); obj.push_back(Pair("keypoololdest", (boost::int64_t)pwalletMain->GetOldestKeyPoolTime())); obj.push_back(Pair("keypoolsize", pwalletMain->GetKeyPoolSize())); obj.push_back(Pair("paytxfee", ValueFromAmount(nTransactionFee))); + obj.push_back(Pair("staking status", (fWalletStaking ? "Staking Active" : "Staking Not Active"))); + + std::string strLockState = ""; + if(pwalletMain->IsLocked()) + strLockState = "Wallet Locked"; + else if(pwalletMain->fWalletUnlockMintOnly) + strLockState = "Wallet Unlocked for Minting Only"; + else + strLockState = "Wallet is Unlocked"; + obj.push_back(Pair("lock state", strLockState)); if (pwalletMain->IsCrypted()) obj.push_back(Pair("unlocked_until", (boost::int64_t)nWalletUnlockTime / 1000)); obj.push_back(Pair("errors", GetWarnings("statusbar"))); return obj; } - -//presstab -double GetMoneySupply(int nHeight) -{ - CBlockIndex* pindex = FindBlockByHeight(nHeight); - double nSupply = pindex->nMoneySupply; - return nSupply / COIN; -} - -//presstab -double GetSupplyChange(int nHeight, int pHeight) -{ - double nSupply = GetMoneySupply(nHeight); //present supply - double pSupply = GetMoneySupply(pHeight); //previous supply - double nChange = nSupply - pSupply; //difference - return nChange; -} - -//presstab -double GetBlockSpeed(int nHeight, int pHeight) -{ - CBlockIndex* pIndex = FindBlockByHeight(nHeight); - CBlockIndex* ppIndex = FindBlockByHeight(pHeight); - double nTime = pIndex->nTime; - double pTime = ppIndex->nTime; - double nTimeChange = (nTime - pTime) / 60 / 60 / 24; //in days - return nTimeChange; -} - -//presstab -double GetRate(int nHeight, int pHeight) -{ - double nSupplyChange = GetSupplyChange(nHeight, pHeight); - double nTimeChange = GetBlockSpeed(nHeight, pHeight); - double nMoneySupply = GetMoneySupply(nHeight); - double nRate = nSupplyChange / nMoneySupply / nTimeChange; - - return nRate; -} - -//presstab -double PredictFutureSupply(int nHeight, int pHeight, int nDays) -{ - double nRate = GetRate(nHeight, pHeight); - double nSupply = GetMoneySupply(nHeight); - double fSupply = nSupply * pow( 1 + nRate, nDays ); //compounds daily - - return fSupply; -} - -//new rpccommand presstab -Value getmoneysupply(const Array& params, bool fHelp) -{ - if (fHelp || params.size() > 1) - throw runtime_error( - "getmoneysupply [height]\n" - "Returns money supply at certain block, current money supply as default"); - - GetLastBlockIndex(pindexBest, false); - - int nHeight = 0; - double nMoneySupply = 0; - - if (params.size() > 0) - { - nHeight = pindexBest->nHeight; - int pHeight = params[0].get_int(); - if (pHeight > nHeight || pHeight < 0) - nMoneySupply = 0; - else - nMoneySupply = GetMoneySupply(pHeight); - } - else - { - nHeight = pindexBest->nHeight; - nMoneySupply = GetMoneySupply(nHeight); - } - Object obj; - obj.push_back(Pair("money supply", nMoneySupply)); - return obj; -} - - -//Presstab's Preferred Money Supply Information -Value moneysupply(const Array& params, bool fHelp) -{ - if (fHelp || params.size() != 0) - throw runtime_error( - "moneysupply\n" - "Show important money supply variables.\n"); - - // grab block index of last block - GetLastBlockIndex(pindexBest, false); - - //height of blocks - int64 nHeight = pindexBest->nHeight; //present - int64 n1Height = nHeight - 960; // day -- 960 blocks should be about 1 day if blocks have 90 sec spacing - int64 n7Height = nHeight - 960 * 7; // week - int64 n30Height = nHeight - 960 * 30; // month - int64 forkHeight = 31781; - - - //print to console - Object obj; - obj.push_back(Pair("moneysupply - present", GetMoneySupply(nHeight))); - obj.push_back(Pair("moneysupply - 960 blocks ago", GetMoneySupply(n1Height))); - obj.push_back(Pair("moneysupply - 6,720 blocks ago", GetMoneySupply(n7Height))); - obj.push_back(Pair("moneysupply - 28,800 blocks ago", GetMoneySupply(n30Height))); - - obj.push_back(Pair("supply change(last 960 blocks)", GetSupplyChange(nHeight, n1Height))); - obj.push_back(Pair("supply change(last 6,720 blocks)", GetSupplyChange(nHeight, n7Height))); - obj.push_back(Pair("supply change(last 28,800 blocks)", GetSupplyChange(nHeight, n30Height))); - obj.push_back(Pair("supply change since fork (block 31781)", GetSupplyChange(nHeight, forkHeight - 1))); - - obj.push_back(Pair("time change over 960 blocks", GetBlockSpeed(nHeight, n1Height))); - obj.push_back(Pair("time change over 6,720 blocks", GetBlockSpeed(nHeight, n7Height))); - obj.push_back(Pair("time change over 28,800 blocks", GetBlockSpeed(nHeight, n30Height))); - - obj.push_back(Pair("avg daily rate of change (last 960 blocks)", GetRate(nHeight, n1Height))); - obj.push_back(Pair("avg daily rate of change (last 6,720 blocks)", GetRate(nHeight, n7Height))); - obj.push_back(Pair("avg daily rate of change (last 28,800 blocks)", GetRate(nHeight, n30Height))); - - obj.push_back(Pair("projected money supply 1 day from now (daily compound)", PredictFutureSupply(nHeight, n1Height, 1))); - obj.push_back(Pair("projected money supply 7 days from now (daily compound)", PredictFutureSupply(nHeight, n7Height, 7))); - obj.push_back(Pair("projected money supply 30 days from now (daily compound)", PredictFutureSupply(nHeight, n30Height, 30))); - - //obj.push_back(Pair("projected money supply 365 days from now (using avg of 3 rates)", ms0 * pow (1 + (r1 + r7 +r30) / 3 * 8, 365 / 8))); - return obj; -} - Value getnewpubkey(const Array& params, bool fHelp) { if (fHelp || params.size() > 1) @@ -252,7 +139,6 @@ Value getnewpubkey(const Array& params, bool fHelp) return HexStr(vchPubKey.begin(), vchPubKey.end()); } - Value getnewaddress(const Array& params, bool fHelp) { if (fHelp || params.size() > 1) @@ -281,7 +167,6 @@ Value getnewaddress(const Array& params, bool fHelp) return CBitcoinAddress(keyID).ToString(); } - CBitcoinAddress GetAccountAddress(string strAccount, bool bForceNew=false) { CWalletDB walletdb(pwalletMain->strWalletFile); @@ -337,8 +222,6 @@ Value getaccountaddress(const Array& params, bool fHelp) return ret; } - - Value setaccount(const Array& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 2) @@ -368,7 +251,6 @@ Value setaccount(const Array& params, bool fHelp) return Value::null; } - Value getaccount(const Array& params, bool fHelp) { if (fHelp || params.size() != 1) @@ -387,7 +269,6 @@ Value getaccount(const Array& params, bool fHelp) return strAccount; } - Value getaddressesbyaccount(const Array& params, bool fHelp) { if (fHelp || params.size() != 1) @@ -437,61 +318,13 @@ Value sendtoaddress(const Array& params, bool fHelp) if (pwalletMain->IsLocked()) throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first."); - string strError = pwalletMain->SendMoneyToDestination(address.Get(), nAmount, wtx); + string strError = pwalletMain->SendMoneyToDestination(address.Get(), nAmount, wtx, false, false); if (strError != "") throw JSONRPCError(RPC_WALLET_ERROR, strError); return wtx.GetHash().GetHex(); } - -/*Value splitblock(const Array& params, bool fHelp) -{ - if (fHelp || params.size() < 3 || params.size() > 3) - throw runtime_error( - "splitblock \n" - " is a real and is rounded to the nearest 0.000001" - + HelpRequiringPassphrase()); - - CBitcoinAddress address(params[0].get_str()); - if (!address.IsValid()) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid HyperStake address"); - - // Amount - double dAmount = params[1].get_real(); - double dBlocks = params[2].get_real(); - dAmount = dAmount / dBlocks; - int64 nAmount = AmountFromValue(dAmount * COIN); - - if (nAmount < MIN_TXOUT_AMOUNT) - throw JSONRPCError(-101, "Send amount too small"); - - // Wallet transaction - - - vector vecAddress; //vector containing the single address that will be sent to - - for(int nIndex = 0; nIndex < dBlocks; ++nIndex) - { - vecAddress.push_back (address.Get()); - } - - //if (pwalletMain->IsLocked()) - // throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first."); - - - for(int nIndex = 0; nIndex < dBlocks; ++nIndex) - { - CWalletTx wtx; - string strError = pwalletMain->SendMoneyToDestination(address.Get(), nAmount, wtx); - if (strError != "") - throw JSONRPCError(RPC_WALLET_ERROR, strError); - } - - return nAmount; -}*/ - - Value listaddressgroupings(const Array& params, bool fHelp) { if (fHelp) @@ -594,7 +427,6 @@ Value verifymessage(const Array& params, bool fHelp) return (key.GetPubKey().GetID() == keyID); } - Value getreceivedbyaddress(const Array& params, bool fHelp) { if (fHelp || params.size() < 1 || params.size() > 2) @@ -633,7 +465,6 @@ Value getreceivedbyaddress(const Array& params, bool fHelp) return ValueFromAmount(nAmount); } - void GetAccountAddresses(string strAccount, set& setAddress) { BOOST_FOREACH(const PAIRTYPE(CTxDestination, string)& item, pwalletMain->mapAddressBook) @@ -682,7 +513,6 @@ Value getreceivedbyaccount(const Array& params, bool fHelp) return (double)nAmount / (double)COIN; } - int64 GetAccountBalance(CWalletDB& walletdb, const string& strAccount, int nMinDepth) { int64 nBalance = 0; @@ -719,7 +549,6 @@ int64 GetAccountBalance(const string& strAccount, int nMinDepth) return GetAccountBalance(walletdb, strAccount, nMinDepth); } - Value getbalance(const Array& params, bool fHelp) { if (fHelp || params.size() > 2) @@ -778,7 +607,6 @@ Value getbalance(const Array& params, bool fHelp) return ValueFromAmount(nBalance); } - Value movecmd(const Array& params, bool fHelp) { if (fHelp || params.size() < 3 || params.size() > 5) @@ -804,6 +632,13 @@ Value movecmd(const Array& params, bool fHelp) if (!walletdb.TxnBegin()) throw JSONRPCError(RPC_DATABASE_ERROR, "database error"); + // check balance + int64 nBalance = GetAccountBalance(strFrom, 1); + + // no moving balances less than or equal to 0 + if(nBalance <= 0 || nBalance < nAmount) + throw JSONRPCError(-101, "Not enough balance"); + int64 nNow = GetAdjustedTime(); // Debit @@ -832,7 +667,6 @@ Value movecmd(const Array& params, bool fHelp) return true; } - Value sendfrom(const Array& params, bool fHelp) { if (fHelp || params.size() < 3 || params.size() > 6) @@ -869,14 +703,13 @@ Value sendfrom(const Array& params, bool fHelp) throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Account has insufficient funds"); // Send - string strError = pwalletMain->SendMoneyToDestination(address.Get(), nAmount, wtx); + string strError = pwalletMain->SendMoneyToDestination(address.Get(), nAmount, wtx, false, false); if (strError != "") throw JSONRPCError(RPC_WALLET_ERROR, strError); return wtx.GetHash().GetHex(); } - Value sendmany(const Array& params, bool fHelp) { if (fHelp || params.size() < 2 || params.size() > 4) @@ -933,7 +766,7 @@ Value sendmany(const Array& params, bool fHelp) // Send CReserveKey keyChange(pwalletMain); int64 nFeeRequired = 0; - bool fCreated = pwalletMain->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired); + bool fCreated = pwalletMain->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired, 1); if (!fCreated) { if (totalAmount + nFeeRequired > pwalletMain->GetBalance()) @@ -969,7 +802,7 @@ Value addmultisigaddress(const Array& params, bool fHelp) if ((int)keys.size() < nRequired) throw runtime_error( strprintf("not enough keys supplied " - "(got %"PRIszu" keys, but need at least %d to redeem)", keys.size(), nRequired)); + "(got %lu keys, but need at least %d to redeem)", keys.size(), nRequired)); std::vector pubkeys; pubkeys.resize(keys.size()); for (unsigned int i = 0; i < keys.size(); i++) @@ -1366,6 +1199,23 @@ Value listaccounts(const Array& params, bool fHelp) return ret; } +Value deleteaddress(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 2) + throw runtime_error( + "delete
\n" + "Deletes an address from wallet.dat, use with caution. Cannot be restored."); + + + string strAdd = params[0].get_str(); + + CWalletDB(pwalletMain->strWalletFile).EraseName(strAdd); + pwalletMain->TopUpKeyPool(); + + string ret = "Success, please restart wallet if using QT"; + return ret; +} + Value listsinceblock(const Array& params, bool fHelp) { if (fHelp) @@ -1429,6 +1279,42 @@ Value listsinceblock(const Array& params, bool fHelp) return ret; } +Value getconfs(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "getconfs \n" + "returns the number of confirmations for "); + + uint256 hash; + hash.SetHex(params[0].get_str()); + + Object entry; + CTransaction tx; + uint256 hashBlock = 0; + if (GetTransaction(hash, tx, hashBlock)) + { + if (hashBlock == 0) + entry.push_back(Pair("confirmations", 0)); + else + { + map::iterator mi = mapBlockIndex.find(hashBlock); + if (mi != mapBlockIndex.end() && (*mi).second) + { + CBlockIndex* pindex = (*mi).second; + if (pindex->IsInMainChain()) + { + entry.push_back(Pair("confirmations", 1 + nBestHeight - pindex->nHeight)); + } + else + entry.push_back(Pair("confirmations", 0)); + } + } + return entry; + } + else return "failed"; +} + Value gettransaction(const Array& params, bool fHelp) { if (fHelp || params.size() != 1) @@ -1497,7 +1383,6 @@ Value gettransaction(const Array& params, bool fHelp) return entry; } - Value backupwallet(const Array& params, bool fHelp) { if (fHelp || params.size() != 1) @@ -1512,7 +1397,6 @@ Value backupwallet(const Array& params, bool fHelp) return Value::null; } - Value keypoolrefill(const Array& params, bool fHelp) { if (fHelp || params.size() > 0) @@ -1531,7 +1415,6 @@ Value keypoolrefill(const Array& params, bool fHelp) return Value::null; } - void ThreadTopUpKeyPool(void* parg) { // Make this thread recognisable as the key-topping-up thread @@ -1621,14 +1504,13 @@ Value walletpassphrase(const Array& params, bool fHelp) // ppcoin: if user OS account compromised prevent trivial sendmoney commands if (params.size() > 2) - fWalletUnlockMintOnly = params[2].get_bool(); + pwalletMain->fWalletUnlockMintOnly = params[2].get_bool(); else - fWalletUnlockMintOnly = false; - + pwalletMain->fWalletUnlockMintOnly = false; + return Value::null; } - Value walletpassphrasechange(const Array& params, bool fHelp) { if (pwalletMain->IsCrypted() && (fHelp || params.size() != 2)) @@ -1661,7 +1543,6 @@ Value walletpassphrasechange(const Array& params, bool fHelp) return Value::null; } - Value walletlock(const Array& params, bool fHelp) { if (pwalletMain->IsCrypted() && (fHelp || params.size() != 0)) @@ -1684,7 +1565,6 @@ Value walletlock(const Array& params, bool fHelp) return Value::null; } - Value encryptwallet(const Array& params, bool fHelp) { if (!pwalletMain->IsCrypted() && (fHelp || params.size() != 1)) @@ -1859,7 +1739,6 @@ Value reservebalance(const Array& params, bool fHelp) return result; } - // ppcoin: check wallet integrity Value checkwallet(const Array& params, bool fHelp) { @@ -1884,7 +1763,6 @@ Value checkwallet(const Array& params, bool fHelp) return result; } - // ppcoin: repair wallet Value repairwallet(const Array& params, bool fHelp) { @@ -1909,8 +1787,7 @@ Value repairwallet(const Array& params, bool fHelp) return result; } - -// HyperStake: resend unconfirmed wallet transactions +// resend unconfirmed wallet transactions Value resendtx(const Array& params, bool fHelp) { if (fHelp || params.size() > 1) @@ -1946,3 +1823,1227 @@ Value makekeypair(const Array& params, bool fHelp) result.push_back(Pair("PublicKey", HexStr(key.GetPubKey().Raw()))); return result; } + +/** HyperStake Specific RPC Wallet Additions**/ + +//presstab +double GetMoneySupply(int nHeight) +{ + CBlockIndex* pindex = FindBlockByHeight(nHeight); + double nSupply = pindex->nMoneySupply; + return nSupply / COIN; +} +//presstab +double GetSupplyChange(int nHeight, int pHeight) +{ + double nSupply = GetMoneySupply(nHeight); //present supply + double pSupply = GetMoneySupply(pHeight); //previous supply + double nChange = nSupply - pSupply; //difference + return nChange; +} + +//presstab +double GetBlockSpeed(int nHeight, int pHeight) +{ + CBlockIndex* pIndex = FindBlockByHeight(nHeight); + CBlockIndex* ppIndex = FindBlockByHeight(pHeight); + double nTime = pIndex->nTime; + double pTime = ppIndex->nTime; + double nTimeChange = (nTime - pTime) / 60 / 60 / 24; //in days + return nTimeChange; +} +//presstab +double GetRate(int nHeight, int pHeight) +{ + double nSupplyChange = GetSupplyChange(nHeight, pHeight); + double nTimeChange = GetBlockSpeed(nHeight, pHeight); + double nMoneySupply = GetMoneySupply(nHeight); + double nRate = nSupplyChange / nMoneySupply / nTimeChange; + + return nRate; +} + +//presstab +double PredictFutureSupply(int nHeight, int pHeight, int nDays) +{ + double nRate = GetRate(nHeight, pHeight); + double nSupply = GetMoneySupply(nHeight); + double fSupply = nSupply * pow( 1 + nRate, nDays ); //compounds daily + + return fSupply; +} + +//presstab +Value getmoneysupply(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 1) + throw runtime_error( + "getmoneysupply [height]\n" + "Returns money supply at certain block, current money supply as default"); + + GetLastBlockIndex(pindexBest, false); + + int nHeight = 0; + double nMoneySupply = 0; + + if (params.size() > 0) + { + nHeight = pindexBest->nHeight; + int pHeight = params[0].get_int(); + if (pHeight > nHeight || pHeight < 0) + nMoneySupply = 0; + else + nMoneySupply = GetMoneySupply(pHeight); + } + else + { + nHeight = pindexBest->nHeight; + nMoneySupply = GetMoneySupply(nHeight); + } + Object obj; + obj.push_back(Pair("money supply", nMoneySupply)); + return obj; +} + +//Presstab's Preferred Money Supply Information +Value moneysupply(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "moneysupply\n" + "Show important money supply variables.\n"); + + // grab block index of last block + GetLastBlockIndex(pindexBest, false); + + //height of blocks + int64 nHeight = pindexBest->nHeight; //present + int64 n1Height = nHeight - 960; // day -- 960 blocks should be about 1 day if blocks have 90 sec spacing + int64 n7Height = nHeight - 960 * 7; // week + int64 n30Height = nHeight - 960 * 30; // month + int64 forkHeight = 31781; + + + //print to console + Object obj; + obj.push_back(Pair("moneysupply - present", GetMoneySupply(nHeight))); + obj.push_back(Pair("moneysupply - 960 blocks ago", GetMoneySupply(n1Height))); + obj.push_back(Pair("moneysupply - 6,720 blocks ago", GetMoneySupply(n7Height))); + obj.push_back(Pair("moneysupply - 28,800 blocks ago", GetMoneySupply(n30Height))); + + obj.push_back(Pair("supply change(last 960 blocks)", GetSupplyChange(nHeight, n1Height))); + obj.push_back(Pair("supply change(last 6,720 blocks)", GetSupplyChange(nHeight, n7Height))); + obj.push_back(Pair("supply change(last 28,800 blocks)", GetSupplyChange(nHeight, n30Height))); + obj.push_back(Pair("supply change since fork (block 31781)", GetSupplyChange(nHeight, forkHeight - 1))); + + obj.push_back(Pair("time change over 960 blocks", GetBlockSpeed(nHeight, n1Height))); + obj.push_back(Pair("time change over 6,720 blocks", GetBlockSpeed(nHeight, n7Height))); + obj.push_back(Pair("time change over 28,800 blocks", GetBlockSpeed(nHeight, n30Height))); + + obj.push_back(Pair("avg daily rate of change (last 960 blocks)", GetRate(nHeight, n1Height))); + obj.push_back(Pair("avg daily rate of change (last 6,720 blocks)", GetRate(nHeight, n7Height))); + obj.push_back(Pair("avg daily rate of change (last 28,800 blocks)", GetRate(nHeight, n30Height))); + + obj.push_back(Pair("projected money supply 1 day from now (daily compound)", PredictFutureSupply(nHeight, n1Height, 1))); + obj.push_back(Pair("projected money supply 7 days from now (daily compound)", PredictFutureSupply(nHeight, n7Height, 7))); + obj.push_back(Pair("projected money supply 30 days from now (daily compound)", PredictFutureSupply(nHeight, n30Height, 30))); + + //obj.push_back(Pair("projected money supply 365 days from now (using avg of 3 rates)", ms0 * pow (1 + (r1 + r7 +r30) / 3 * 8, 365 / 8))); + return obj; +} + +//presstab HyperStake +Value getstaketx(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "getstaketx \n" + "Get detailed information about a specific stake "); + + uint256 hash; + hash.SetHex(params[0].get_str()); + + Object entry; + Array vin; + + if (pwalletMain->mapWallet.count(hash)) + { + const CWalletTx& wtx = pwalletMain->mapWallet[hash]; + + BOOST_FOREACH(const CTxIn& txin, wtx.vin) + { + Object in; + if (wtx.IsCoinBase()) + entry.push_back(Pair("coinbase", HexStr(txin.scriptSig.begin(), txin.scriptSig.end()))); + else + { + CTransaction& txPrev = pwalletMain->mapWallet[txin.prevout.hash]; //first transaction + uint64_t nTime = wtx.nTime; //stake tx time + uint64_t nPrevTime = txPrev.nTime; //previous tx time + uint64_t nTimeToStake = nTime - nPrevTime; // time to stake in seconds + double dDaysToStake = nTimeToStake / 60.00 / 60 / 24; + + int64 nDebit = wtx.GetDebit(); + int64 nFee = (wtx.IsFromMe() ? wtx.GetValueOut() - nDebit : 0); + + int64 nGeneratedImmature, nGeneratedMature, nFee2; + string strSentAccount; + list > listReceived; + list > listSent; + wtx.GetAmounts(nGeneratedImmature, nGeneratedMature, listReceived, listSent, nFee2, strSentAccount); + uint64_t nGeneratedAmount = max (nGeneratedMature, nGeneratedImmature); + double nGeneratedAmount2 = max (nGeneratedMature, nGeneratedImmature); //uint64_t math not working + double percentReward = nFee / (nGeneratedAmount2 - nFee); + double dWeight = ((nGeneratedAmount - nFee)/ COIN) * (dDaysToStake - 8.8); + + entry.push_back(Pair("Stake TX Time", nTime)); + entry.push_back(Pair("Previous Time", nPrevTime)); + entry.push_back(Pair("Days To Stake", dDaysToStake)); + entry.push_back(Pair("Original Amount", ValueFromAmount(nGeneratedAmount - nFee))); + entry.push_back(Pair("Weight", dWeight)); + entry.push_back(Pair("PoS Reward", ValueFromAmount(nFee))); + entry.push_back(Pair("Reward %", percentReward)); + entry.push_back(Pair("Total New Amount", ValueFromAmount(nGeneratedAmount))); + entry.push_back(Pair("Size of Each New Block", ValueFromAmount(nGeneratedAmount/2))); + } + } + } + return entry; +} + +//presstab HyperStake +double getWeight() +{ + std::vector vCoins; + pwalletMain->AvailableCoins(vCoins); + uint64 nWeightSum = 0; + BOOST_FOREACH(const COutput& out, vCoins) + { + int64 nHeight = nBestHeight - out.nDepth; + CBlockIndex* pindex = FindBlockByHeight(nHeight); + uint64 nWeight = 0; + pwalletMain->GetStakeWeightFromValue(out.tx->GetTxTime(), out.tx->vout[out.i].nValue, nWeight); + int64 nAge = int64(GetTime() - pindex->nTime); + int64 nStakeAge; + if(fTestNet) + nStakeAge = nStakeMinAge; + else + nStakeAge = nStakeMinAgeV2; + + if(nAge < nStakeAge) + nWeight = 0; + nWeightSum += nWeight; + } + return (double)nWeightSum; +} + +//presstab HyperStake +Value getweight(const Array& params, bool fHelp) +{ + if (fHelp) + throw runtime_error( + "getweight\n" + "This will return your total stake weight for confirmed outputs\n"); + + return getWeight(); +} + +//presstab HyperStake +Value getpotentialstake(const Array& params, bool fHelp) +{ + if (fHelp) + throw runtime_error( + "getpotentialstake\n" + "This will return your total potential stake for confirmed outputs\n" + "Potential stake is the amount your output reward is worth if it stakes right now"); + + std::vector vCoins; + pwalletMain->AvailableCoins(vCoins); + + double nRewardSum = 0; + BOOST_FOREACH(const COutput& out, vCoins) + { + int64 nHeight = nBestHeight - out.nDepth; + CBlockIndex* pindex = FindBlockByHeight(nHeight); + uint64 nAmount = out.tx->vout[out.i].nValue; + double dAge = double(GetTime() - pindex->nTime) / (60*60*24); + double nReward = 7.5 / 365 * dAge * (double)nAmount; + nReward = min(nReward / COIN, double(1000)); + nRewardSum += nReward; + } + return nRewardSum; +} + +// presstab HyperStake +Value setstakesplitthreshold(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "setstakesplitthreshold <1 - 999,999>\n" + "This will set the output size of your stakes to never be below this number\n"); + uint64 nStakeSplitThreshold = params[0].get_int(); + if (pwalletMain->IsLocked()) + throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Unlock wallet to use this feature"); + if (nStakeSplitThreshold > 999999) + return "out of range - setting split threshold failed"; + + CWalletDB walletdb(pwalletMain->strWalletFile); + LOCK(pwalletMain->cs_wallet); + { + bool fFileBacked = pwalletMain->fFileBacked; + + Object result; + pwalletMain->nStakeSplitThreshold = nStakeSplitThreshold; + result.push_back(Pair("split stake threshold set to ", int(pwalletMain->nStakeSplitThreshold))); + if(fFileBacked) + { + walletdb.WriteStakeSplitThreshold(nStakeSplitThreshold); + result.push_back(Pair("saved to wallet.dat ", "true")); + } + else + result.push_back(Pair("saved to wallet.dat ", "false")); + + return result; + } +} + +// presstab HyperStake +Value getstakesplitthreshold(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "getstakesplitthreshold\n" + "Returns the set splitstakethreshold\n"); + + Object result; + result.push_back(Pair("split stake threshold set to ", int(pwalletMain->nStakeSplitThreshold))); + return result; + +} + +// presstab HyperStake +Value disablestake(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 4 || params.size() < 1) + throw runtime_error( + "disablestake \n" + "This will disable staking if set true\n" + "example: disablestake true diff >5\n" + "options: diff, weight"); + int fDisableStake = params[0].get_bool(); + + if (params.size() == 4) + { + std::string strType = params[1].get_str(); + std::string strArg = params[2].get_str(); + double dUserNumber = params[3].get_real(); + + if(strType == "diff" || "weight") + pwalletMain->strDisableType = strType; + else + throw runtime_error("type is not valid"); + if(strArg == ">" || "<") + pwalletMain->strDisableArg = strArg; + else + throw runtime_error("argument is not valid"); + + + pwalletMain->dUserNumber = dUserNumber; + pwalletMain->fStakeRequirement = true; + } + else + pwalletMain->fStakeRequirement = false; + + pwalletMain->fDisableStake = fDisableStake; + + if(!fDisableStake || params.size() == 1) + { + pwalletMain->strDisableType = ""; + pwalletMain->strDisableArg = ""; + pwalletMain->dUserNumber = 0; + pwalletMain->fStakeRequirement = false; + } + + Object result; + result.push_back(Pair("disablestake ", pwalletMain->fDisableStake)); + result.push_back(Pair("stake requirements set? ", pwalletMain->fStakeRequirement)); + return result; +} + +// presstab HyperStake +Value rescanfromblock(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "rescanfromblock \n" + "This will rescan for transactions after a specified block\n"); + int nHeight = params[0].get_int(); + if (pwalletMain->IsLocked()) + throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Unlock wallet to use this feature"); + if (nHeight > int(nBestHeight) || nHeight < 0) + return "out of range"; + + pwalletMain->ScanForWalletTransactions(FindBlockByHeight(nHeight), true); + return "done"; +} + +// presstab HyperStake +Value cclistcoins(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "cclistcoins\n" + "CoinControl: list your spendable coins and their information\n"); + + Array result; + + std::vector vCoins; + pwalletMain->AvailableCoins(vCoins); + + BOOST_FOREACH(const COutput& out, vCoins) + { + Object coutput; + int64 nHeight = nBestHeight - out.nDepth; + CBlockIndex* pindex = FindBlockByHeight(nHeight); + + CTxDestination outputAddress; + ExtractDestination(out.tx->vout[out.i].scriptPubKey, outputAddress); + coutput.push_back(Pair("Address", CBitcoinAddress(outputAddress).ToString())); + coutput.push_back(Pair("Output Hash", out.tx->GetHash().ToString())); + coutput.push_back(Pair("blockIndex", out.i)); + double dAmount = double(out.tx->vout[out.i].nValue) / double(COIN); + coutput.push_back(Pair("Value", dAmount)); + coutput.push_back(Pair("Confirmations", int(out.nDepth))); + double dAge = double(GetTime() - pindex->nTime); + coutput.push_back(Pair("Age (days)", (dAge/(60*60*24)))); + uint64 nWeight = 0; + pwalletMain->GetStakeWeightFromValue(out.tx->GetTxTime(), out.tx->vout[out.i].nValue, nWeight); + if(dAge < (fTestNet ? nStakeMinAge : nStakeMinAgeV2)) + nWeight = 0; + coutput.push_back(Pair("Weight", int(nWeight))); + double nReward = 7.5 / 365 * dAge/(60*60*24) * dAmount; + nReward = min(nReward, double(1000)); + coutput.push_back(Pair("Potential Stake", nReward)); + result.push_back(coutput); + } + return result; +} + + +// presstab HyperStake +Value ccselect(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 2) + throw runtime_error( + "ccselect \n" + "CoinControl: select a coin"); + + uint256 hash; + hash.SetHex(params[0].get_str()); + unsigned int nIndex = params[1].get_int(); + COutPoint outpt(hash, nIndex); + coinControl->Select(outpt); + + return "Outpoint Selected"; +} + +// presstab HyperStake +Value cclistselected(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "cclistselected\n" + "CoinControl: list selected coins"); + + std::vector vOutpoints; + coinControl->ListSelected(vOutpoints); + + Array result; + BOOST_FOREACH(COutPoint& outpt, vOutpoints) + { + result.push_back(outpt.hash.ToString()); + } + + return result; +} + +// ssta HyperStake +Value ccreturnchange(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "ccreturnchange \n" + "CoinControl: sets returnchange to true or false"); + bool rc = params[0].get_bool(); + coinControl->fReturnChange=rc; + string ret = "Set ReturnChange to: "; + + if(coinControl->fReturnChange ) + ret+= "true"; + else + ret+= "false"; + + return ret; +} + +// ssta HyperStake +Value cccustomchange(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "cccustomchange
\n" + "CoinControl: sets address to return change to"); + CBitcoinAddress address(params[0].get_str()); + // check it's a valid address + if(!address.IsValid()) throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid HyperStake address"); + + coinControl->destChange=address.Get(); + + string ret = "Set change address to: "; + ret+=(CBitcoinAddress(coinControl->destChange).ToString()); + return ret; +} + +// ssta HyperStake +Value ccreset(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "ccreset\n" + "CoinControl: resets coin control (clears selected coins and change address)"); + coinControl->SetNull(); + return Value::null; +} + +// presstab HyperStake +Value ccsend(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 2) + throw runtime_error( + "ccsend \n" + " is a real and is rounded to the nearest 0.000001" + + HelpRequiringPassphrase()); + + EnsureWalletIsUnlocked(); + + CBitcoinAddress address(params[0].get_str()); + if (!address.IsValid()) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid HyperStake address"); + + // Amount + int64 nAmount = AmountFromValue(params[1]); + + if (nAmount < MIN_TXOUT_AMOUNT) + throw JSONRPCError(-101, "Send amount too small"); + + if (pwalletMain->IsLocked()) + throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first."); + + // Initialize things needed for the transaction + vector > vecSend; + CWalletTx wtx; + CReserveKey keyChange(pwalletMain); + int64 nFeeRequired = 0; + CScript scriptPubKey; + scriptPubKey.SetDestination(address.Get()); + vecSend.push_back(make_pair(scriptPubKey, nAmount)); + + bool fCreated = pwalletMain->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired, 1, false, coinControl); // 1 = no splitblock, false for s4c, coinControl + if (!fCreated) + { + if (nAmount + nFeeRequired > pwalletMain->GetBalance()) + throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds"); + throw JSONRPCError(RPC_WALLET_ERROR, "Transaction creation failed"); + } + if (!pwalletMain->CommitTransaction(wtx, keyChange)) + throw JSONRPCError(RPC_WALLET_ERROR, "Transaction commit failed"); + + coinControl->SetNull(); + return wtx.GetHash().GetHex(); +} + + +//presstab HyperStake +Array printMultiSend() +{ + Array ret; + Object act; + act.push_back(Pair("MultiSend Activated?", pwalletMain->fMultiSend)); + act.push_back(Pair("MultiSend in CoinStake?", pwalletMain->fMultiSendCoinStake)); + ret.push_back(act); + if(pwalletMain->vDisabledAddresses.size() >= 1) + { + Object disAdd; + for(unsigned int i = 0; i < pwalletMain->vDisabledAddresses.size(); i++) + { + disAdd.push_back(Pair("Disabled From Sending", pwalletMain->vDisabledAddresses[i])); + } + ret.push_back(disAdd); + } + + ret.push_back("MultiSend Addresses to Send To:"); + Object vMS; + for(unsigned int i = 0; i < pwalletMain->vMultiSend.size(); i++) + { + vMS.push_back(Pair("Address " + boost::lexical_cast(i), pwalletMain->vMultiSend[i].first)); + vMS.push_back(Pair("Percent", pwalletMain->vMultiSend[i].second)); + } + ret.push_back(vMS); + return ret; +} + +//presstab HyperStake +Array printAddresses() +{ + std::vector vCoins; + pwalletMain->AvailableCoins(vCoins); + std::map mapAddresses; + + BOOST_FOREACH(const COutput& out, vCoins) + { + CTxDestination utxoAddress; + ExtractDestination(out.tx->vout[out.i].scriptPubKey, utxoAddress); + std::string strAdd = CBitcoinAddress(utxoAddress).ToString(); + + if(mapAddresses.find(strAdd) == mapAddresses.end()) //if strAdd is not already part of the map + { + mapAddresses[strAdd] = (double)out.tx->vout[out.i].nValue / (double)COIN; + } + else + { + mapAddresses[strAdd] += (double)out.tx->vout[out.i].nValue / (double)COIN; + } + } + Array ret; + for (map::const_iterator it = mapAddresses.begin(); it != mapAddresses.end(); ++it) + { + Object obj; + const std::string* strAdd = &(*it).first; + const double* nBalance = &(*it).second; + obj.push_back(Pair("Address ", *strAdd)); + obj.push_back(Pair("Balance ", *nBalance)); + ret.push_back(obj); + } + return ret; +} + +//presstab HyperStake +unsigned int sumMultiSend() +{ + unsigned int sum = 0; + for(unsigned int i = 0; i < pwalletMain->vMultiSend.size(); i++) + { + sum += pwalletMain->vMultiSend[i].second; + } + return sum; +} + +// presstab HyperStake +Value multisend(const Array ¶ms, bool fHelp) +{ + CWalletDB walletdb(pwalletMain->strWalletFile); + bool fFileBacked; + + //MultiSend Commands + if(params.size() == 1) + { + string strCommand = params[0].get_str(); + Object ret; + if(strCommand == "print") + { + return printMultiSend(); + } + else if(strCommand == "printaddress" || strCommand == "printaddresses") + { + return printAddresses(); + } + else if(strCommand == "clear") + { + LOCK(pwalletMain->cs_wallet); + { + fFileBacked = pwalletMain->fFileBacked; + string strRet; + if(fFileBacked) + { + if(walletdb.EraseMultiSend(pwalletMain->vMultiSend)) + strRet += "erased MultiSend vector from database & "; + + } + pwalletMain->vMultiSend.clear(); + pwalletMain->fMultiSend = false; + strRet += "cleared MultiSend vector from RAM"; + return strRet; + } + } + else if (strCommand == "enable" || strCommand == "activate" ) + { + if(pwalletMain->vMultiSend.size() < 1) + return "Unable to activate MultiSend, check MultiSend vector"; + if(CBitcoinAddress(pwalletMain->vMultiSend[0].first).IsValid()) + { + pwalletMain->fMultiSend = true; + if(!walletdb.WriteMSettings(true, pwalletMain->nLastMultiSendHeight)) + return "MultiSend activated but writing settings to DB failed"; + else + return "MultiSend activated"; + } + else + return "Unable to activate MultiSend, check MultiSend vector"; + } + else if (strCommand == "disable" || strCommand == "deactivate" ) + { + pwalletMain->fMultiSend = false; + if(!walletdb.WriteMSettings(false, pwalletMain->nLastMultiSendHeight)) + return "MultiSend deactivated but writing settings to DB failed"; + return "MultiSend deactivated"; + } + else if(strCommand == "enableall") + { + if(!walletdb.EraseMSDisabledAddresses(pwalletMain->vDisabledAddresses)) + return "failed to clear old vector from walletDB"; + else + { + pwalletMain->vDisabledAddresses.clear(); + return "all addresses will now send MultiSend transactions"; + } + } + } + if(params.size() == 2 && params[0].get_str() == "delete") + { + int del = boost::lexical_cast(params[1].get_str()); + if(!walletdb.EraseMultiSend(pwalletMain->vMultiSend)) + return "failed to delete old MultiSend vector from database"; + + pwalletMain->vMultiSend.erase(pwalletMain->vMultiSend.begin() + del); + + if(!walletdb.WriteMultiSend(pwalletMain->vMultiSend)) + return "walletdb WriteMultiSend failed!"; + return printMultiSend(); + } + if(params.size() == 2 && params[0].get_str() == "disable") + { + std::string disAddress = params[1].get_str(); + if(!CBitcoinAddress(disAddress).IsValid()) + return "address you want to disable is not valid"; + else + { + pwalletMain->vDisabledAddresses.push_back(disAddress); + if(!walletdb.EraseMSDisabledAddresses(pwalletMain->vDisabledAddresses)) + return "disabled address from sending, but failed to clear old vector from walletDB"; + if(!walletdb.WriteMSDisabledAddresses(pwalletMain->vDisabledAddresses)) + return "disabled address from sending, but failed to store it to walletDB"; + else + return "disabled address from sending MultiSend transactions"; + } + + } + if(params.size() == 2 && params[0].get_str() == "coinstake") + { + std::string strCoinStake = params[1].get_str(); + if(strCoinStake == "true") + { + pwalletMain->fMultiSendCoinStake = true; + if(walletdb.WriteMCoinStake(true)) + return "MultiSend CoinStake enabled and saved to wallet DB"; + else + return "MultiSend CoinStake enabled but failed to save to wallet DB"; + } + else if(strCoinStake == "false") + { + pwalletMain->fMultiSendCoinStake = false; + if(walletdb.WriteMCoinStake(false)) + return "MultiSend CoinStake disabled and saved to wallet DB"; + else + return "MultiSend CoinStake edisabled but failed to save to wallet DB"; + } + else + return "Did not recognize parameter"; + } + //if no commands are used + if (fHelp || params.size() != 2) + throw runtime_error( + "multisend \n" + "****************************************************************\n" + "WHAT IS MULTISEND?\n" + "MultiSend is a rebuild of what used to be called Stake For Charity (s4c)\n" + "MultiSend allows a user to automatically send a percent of their stake reward to as many addresses as you would like\n" + "The MultiSend transaction is sent when the staked coins mature (30 confirmations)\n" + "The only current restriction is that you cannot choose to send more than 100% of your stake using MultiSend\n" + "****************************************************************\n" + "MULTISEND COMMANDS (usage: multisend )\n" + " print - displays the current MultiSend vector \n" + " clear - deletes the current MultiSend vector \n" + " enable/activate - activates the current MultiSend vector \n" + " disable/deactivate - disables the current MultiSend vector \n" + " delete
- deletes an address from the MultiSend vector \n" + " disable
- prevents a specific address from sending MultiSend transactions\n" + " enableall - enables all addresses to be eligible to send MultiSend transactions\n" + " coinstake - this will send the multisend transaction in the coinstake transaction\n" + + "****************************************************************\n" + "TO CREATE OR ADD TO THE MULTISEND VECTOR:\n" + "multisend \n" + "This will add a new address to the MultiSend vector\n" + "Percent is a whole number 1 to 100.\n" + "****************************************************************\n" + ); + + //if the user is entering a new MultiSend item + string strAddress = params[0].get_str(); + CBitcoinAddress address(strAddress); + if (!address.IsValid()) + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid HyperStake address"); + if (boost::lexical_cast(params[1].get_str()) < 0) + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected valid percentage"); + if (pwalletMain->IsLocked()) + throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first."); + + + unsigned int nPercent = boost::lexical_cast(params[1].get_str()); + + LOCK(pwalletMain->cs_wallet); + { + fFileBacked = pwalletMain->fFileBacked; + //Error if 0 is entered + if(nPercent == 0) + { + return "Sending 0% of stake is not valid"; + } + + //MultiSend can only send 100% of your stake + if (nPercent + sumMultiSend() > 100) + return "Failed to add to MultiSend vector, the sum of your MultiSend is greater than 100%"; + + for(unsigned int i = 0; i < pwalletMain->vMultiSend.size(); i++) + { + if(pwalletMain->vMultiSend[i].first == strAddress) + return "Failed to add to MultiSend vector, cannot use the same address twice"; + } + + if(fFileBacked) + walletdb.EraseMultiSend(pwalletMain->vMultiSend); + + std::pair newMultiSend; + newMultiSend.first = strAddress; + newMultiSend.second = nPercent; + pwalletMain->vMultiSend.push_back(newMultiSend); + + if(fFileBacked) + { + if(!walletdb.WriteMultiSend(pwalletMain->vMultiSend)) + return "walletdb WriteMultiSend failed!"; + } + } + return printMultiSend(); +} + +// presstab HyperStake +Value strictprotocol(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "strictprotocol \n" + "Refuse connections to other protocols\n" + "WARNING: if set true peer count will drop\n"); + fStrictProtocol = params[0].get_bool(); + if(fStrictProtocol) + return "Strict Protocol True"; + else + return "Strict Protocol False"; +} + +// presstab HyperStake +Value strictincoming(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "strictincoming \n" + "drop connections from peers sending too many orphans or redundant requests" + "WARNING: if set true peer count will drop"); + fStrictIncoming = params[0].get_bool(); + if(fStrictIncoming) + return "Strict Incoming True"; + else + return "Strict Incoming False"; +} + +// presstab HyperStake +Value hashsettings(const Array& params, bool fHelp) +{ + if (fHelp || params.size() > 2 || params.size() == 0) + throw runtime_error( + "hashsettings \n" + "hashsettings \n" + "ex: 'hashsettings drift' will return the current drift settings\n" + "ex: 'hashsettings interval' will return the current interval settings\n" + "ex: hashsettings drift 45\n" + "ex: hashsettings interval 20\n" + "ex: 'hashsettings default' returns the settings to default\n" + "ex: 'hashsettings combinedust true' dust outputs will be combined when staking if eligible\n" + "hashdrift is how many second into the future your wallet will stake in one hashing burst\n" + "interval is how often your client will search for new hashes\n" + "if you set your hashdrift to 45, then your client will create 45 unique proof of stake hashes, the only thing changing the hash result is the timestamp included, thus you hash 45 seconds into the future.\n" + "Each hash is an attempt to meet the staking target. If you don't hit the staking target, your client will pause staking for the set interval. \n" + "If the interval is 22 seconds, the wallet will create 45 hashes, wait 22 seconds, then create 45 hashes. Approximately 23 of those hashes will be identical as the previous rounds hashes.\n" + "WARNING: timedrift allowance is 60 seconds too high of a hash drift will cause orphans\n" + "Combine dust is a setting in the staking parameters that will iterate through your entire wallet contents to looks for small coins that it can combine into your coinstake transaction." + "set this to false to prevent any combination from occurring \n"); + if(params.size() < 2) + { + if(params[0].get_str() == "drift") + return boost::lexical_cast(pwalletMain->nHashDrift); + else if(params[0].get_str() == "interval") + return boost::lexical_cast(pwalletMain->nHashInterval); + else if(params[0].get_str() == "default") + { + CWalletDB walletdb(pwalletMain->strWalletFile); + pwalletMain->nHashDrift = 45; + pwalletMain->nHashInterval = 22; + walletdb.WriteHashDrift(45); + walletdb.WriteHashInterval(22); + return "Hash Settings returned to default"; + } + else if(params[0].get_str() == "combinedust") + return pwalletMain->fCombineDust; + } + + CWalletDB walletdb(pwalletMain->strWalletFile); + if(params[0].get_str() == "drift") + { + unsigned int nHashDrift = boost::lexical_cast(params[1].get_str()); + if(nHashDrift > 60) + return "You can not set your hashdrift to be greater than 60 seconds"; + else if(nHashDrift < 1) + return "Hash drift too low"; + + pwalletMain->nHashDrift = nHashDrift; + if(walletdb.WriteHashDrift(nHashDrift)) + return "Hashdrift set and save to DB"; + else + return "Hashdrift set but failed to write to DB"; + } + else if(params[0].get_str() == "interval") + { + unsigned int nHashInterval = boost::lexical_cast(params[1].get_str()); + if(nHashInterval < 1) + return "Interval too low"; + pwalletMain->nHashInterval = nHashInterval; + if(walletdb.WriteHashInterval(nHashInterval)) + return "HashInterval set and save to DB"; + else + return "HashInterval set but failed to write to DB"; + } + else if(params[0].get_str() == "combinedust") + { + bool fCombineDust; + string strCombineDust = params[1].get_str(); + if(strCombineDust == "true") + fCombineDust = true; + else if(strCombineDust == "false") + fCombineDust = false; + else + return "failed to understand true/false parameter"; + + pwalletMain->fCombineDust = fCombineDust; + if(walletdb.WriteCombineDust(fCombineDust)) + return "Combine dust setting saved and written to DB"; + else + return "Combine dust setting saved and but failed to write to DB"; + } + return "Failed to recognize commands"; +} + +// PIVX +Value getstakingstatus(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "getstakingstatus\n" + "Returns an object containing various staking information.\n" + "\nResult:\n" + "{\n" + " \"generatebitcoins\": true|false, (boolean) if the internal generate bitcoins flag is activated\n" + " \"haveconnections\": true|false, (boolean) if network connections are present\n" + " \"blockchainsynced\": true|false, (boolean) if blockchain is fully synced\n" + " \"walletunlocked\": true|false, (boolean) if the wallet is unlocked\n" + " \"mintablecoins\": true|false, (boolean) if the wallet has mintable coins\n" + " \"enoughcoins\": true|false, (boolean) if available coins are greater than reserve balance\n" + " \"staking status\": true|false, (boolean) if the wallet is staking or not\n" + "}\n"); + + Object obj; + obj.push_back(Pair("generatebitcoins", fGenerateBitcoins)); + obj.push_back(Pair("haveconnections", !vNodes.empty())); + obj.push_back(Pair("blockchainsynced", !IsInitialBlockDownload())); + if (pwalletMain) { + obj.push_back(Pair("walletunlocked", !pwalletMain->IsLocked())); + obj.push_back(Pair("mintablecoins", pwalletMain->MintableCoins())); + + int64 nReserveBalance = 0; + if (mapArgs.count("-reservebalance") && !ParseMoney(mapArgs["-reservebalance"], nReserveBalance)) + nReserveBalance = 0; + + obj.push_back(Pair("enoughcoins", nReserveBalance <= pwalletMain->GetBalance())); + } + + bool fStaking = false; + if (mapHashedBlocks.count(nBestHeight)) + fStaking = true; + else if (mapHashedBlocks.count(nBestHeight - 1) && nLastCoinStakeSearchInterval) + fStaking = true; + obj.push_back(Pair("staking status", fStaking)); + + return obj; +} + +// HyperStake +Value sendproposal(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "sendproposal \n" + "Sends a vote proposal to the network. WARNING this adds a transaction fee of 5 HYP!\n" + "\nResult:\n" + "{\n" + " \"txid\": hash, (string) the hash of the transaction that was sent\n" + "}\n"); + + if (pwalletMain->IsLocked()) + throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Unlock wallet to use this feature"); + + //! See if this proposal exists in our map of pending proposals + uint256 hashProposal; + hashProposal.SetHex(params[0].get_str()); + if (!mapPendingProposals.count(hashProposal)) + throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot find proposal"); + + CTransaction tx = mapPendingProposals.at(hashProposal); + CWalletTx wtx(pwalletMain, tx); + + //! Get available coins and add enough to cover the proposal fee + vector vCoins; + pwalletMain->AvailableCoins(vCoins, true); + + int64 nFee = 5 * COIN; + int64 nValueIn = 0; + + set > setCoins; + if (!pwalletMain->SelectCoinsMinConf(nFee, tx.nTime, 1, 6, vCoins, setCoins, nValueIn)) + throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, "Insufficient funds"); + + //! Fill vin + for (pair coin : setCoins) + wtx.vin.push_back(CTxIn(coin.first->GetHash(),coin.second)); + + //! Add the min value required for an output to the proposal UTXO + wtx.vout[0].nValue = MIN_TXOUT_AMOUNT; + + //! Figure out change amount + nFee -= wtx.vout[0].nValue; + int64 nChange = nValueIn - nFee - MIN_TXOUT_AMOUNT; + if (nChange > 500) { + //!Lookup the address of one of the inputs and return the change to that address + uint256 hashBlock; + CTransaction txPrev; + if(!GetTransaction(wtx.vin[0].prevout.hash, txPrev, hashBlock)) + throw JSONRPCError(RPC_INVALID_PARAMETER, "Failed to select coins"); + + CScript scriptReturn = txPrev.vout[wtx.vin[0].prevout.n].scriptPubKey; + CTxOut out(nChange, scriptReturn); + + //!Add the change output to the new transaction + wtx.vout.push_back(out); + } + + //! Sign the transaction + int nIn = 0; + for (const pair& coin : setCoins) { + if (!SignSignature(*pwalletMain, *coin.first, wtx, nIn++)) + return false; + } + + //! Broadcast the transaction to the network + CReserveKey reserveKey = CReserveKey(pwalletMain); + if (!pwalletMain->CommitTransaction(wtx, reserveKey)) + throw JSONRPCError(RPC_WALLET_ERROR, "Failed to commit transaction"); + + Object ret; + ret.push_back(Pair("txid", wtx.GetHash().GetHex())); + + return ret; +} + +// HyperStake +Value setvote(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 2) + throw runtime_error( + "setvote \n" + "Creates a vote object for the proposal in the txid which will trigger when you Stake.\n" + "\nResult:\n" + "{\n" + " \"Proposal Name\":, (string) The name of the proposal\n" + " \"Proposal Description\":, (string) The description of the proposal\n" + " \"Your vote\":, (int) 0 - Abstain, 1 - Yes, 2 - No, 3 - Request proposal revision\n" + "}\n"); + + if (pwalletMain->IsLocked()) + throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Unlock wallet vote on a proposal"); + + //Get params + uint256 txHash(params[0].get_str()); + int voteChoice = params[1].get_int(); + + CTransaction tx; + uint256 hashBlock; + if(!GetTransaction(txHash, tx, hashBlock)) + return "Transaction not found in wallet"; + + if (!tx.IsProposal()) + return "Transaction does not contain a proposal"; + + if (voteChoice > 3 || voteChoice < 0) + return "You must vote on the following using a number from 0-3(inclusive)\n 0 - Abstain,\n 1 - Yes,\n 2 - No,\n 3 - Request proposal revision"; + + CVoteProposal proposal; + if (!ProposalFromTransaction(tx, proposal)) + return "Proposal couldn't be found in the transaction"; + + CVoteObject voteObject(proposal.GetHash(), proposal.GetLocation()); + + voteObject.Vote(voteChoice); + + //add the voteObject in the map + pwalletMain->mapVoteObjects[proposal.GetHash()] = voteObject; + + //write the vote object to the database + CWalletDB walletdb(pwalletMain->strWalletFile); + if (!walletdb.WriteVoteObject(proposal.GetHash().GetHex(), voteObject)) { + return "The vote was saved, however had problems writing the vote to the database"; + } + + Object ret; + ret.push_back(Pair("Proposal Name", proposal.GetName())); + ret.push_back(Pair("Proposal Description", proposal.GetDescription())); + ret.push_back(Pair("Your Vote", voteChoice)); + return ret; +} + +// HyperStake +Value getvote(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 1) + throw runtime_error( + "getvote \n" + "Returns the vote you made on a proposal from the given txid\n" + "\nResult:\n" + "{\n" + " \"Proposal Name\":, (string) The name of the proposal\n" + " \"Proposal Description\":, (string) The description of the proposal\n" + " \"Your vote\":, (int) 0 - Abstain, 1 - Yes, 2 - No, 3 - Request proposal revision\n" + "}\n"); + + if (pwalletMain->IsLocked()) + throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Unlock wallet vote on a proposal"); + + //Get params + uint256 txHash(params[0].get_str()); + + CTransaction tx; + uint256 hashBlock; + if (!GetTransaction(txHash, tx, hashBlock)) + return "Transaction not found in wallet"; + + if (!tx.IsProposal()) + return "Transaction does not contain a proposal"; + + CVoteProposal proposal; + if (!ProposalFromTransaction(tx, proposal)) + return "Proposal couldn't be found in the transaction"; + + uint256 proposalHash(proposal.GetHash()); + + // Check to see if we have the vote object loaded from the database, if we do return the info + if (pwalletMain->mapVoteObjects.count(proposalHash) != 0) { + CVoteObject voteObject = pwalletMain->mapVoteObjects[proposalHash]; + + int voteValue = voteObject.GetUnformattedVote(); + + Object ret; + ret.push_back(Pair("Proposal Name", proposal.GetName())); + ret.push_back(Pair("Proposal Description", proposal.GetDescription())); + ret.push_back(Pair("Your Vote", voteValue)); + ret.push_back(Pair("Proposal Hash", proposal.GetHash().GetHex())); + return ret; + } + + // Try and find the voteobject in the walletdb and return it if found + CWalletDB walletdb(pwalletMain->strWalletFile); + + CVoteObject voteObject; + if (!walletdb.ReadVoteObject(proposal.GetHash().GetHex(), voteObject)) + return "No vote has been stored for this proposal "; + + int voteValue = voteObject.GetUnformattedVote(); + + Object ret; + ret.push_back(Pair("Proposal Name", proposal.GetName())); + ret.push_back(Pair("Proposal Description", proposal.GetDescription())); + ret.push_back(Pair("Your Vote", voteValue)); + ret.push_back(Pair("Proposal Hash", proposal.GetHash().GetHex())); + return ret; +} + +// HyperStake +Value getvotes(const Array& params, bool fHelp) +{ + if (fHelp || params.size() != 0) + throw runtime_error( + "getvotes \n" + "Returns all vote objects\n" + "\nResult:\n" + "{\n" + " \"Proposal Name\":, (string) The name of the proposal\n" + " \"Proposal Description\":, (string) The description of the proposal\n" + " \"Proposal Tx\":, (string) The tx the proposal was started in\n" + " \"Your vote\":, (int) 0 - Abstain, 1 - Yes, 2 - No, 3 - Request proposal revision\n" + "}\n"); + + if (pwalletMain->IsLocked()) + throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Unlock wallet vote on a proposal"); + + CVoteDB votedb("r"); + if (pwalletMain->mapVoteObjects.size() > 0) { + Array ret; + map::iterator it; + for (it = pwalletMain->mapVoteObjects.begin(); it != pwalletMain->mapVoteObjects.end(); it++) { + + uint256 txid = 0; + for (auto mit : mapProposals) { + if (mit.second == it->first) { + txid = mit.first; + break; + } + } + + if (txid == 0) + return JSONRPCError(RPC_DATABASE_ERROR, strprintf("failed to find txid for proposal %s", it->first.GetHex().c_str())); + + CVoteProposal proposal; + if (!votedb.ReadProposal(txid, proposal)) { + string strMessage = strprintf("Failed to find proposal %s in database", txid.GetHex().c_str()); + return JSONRPCError(RPC_DATABASE_ERROR, strMessage); + } + + Object entry; + entry.push_back(Pair("Proposal Name", proposal.GetName())); + entry.push_back(Pair("Proposal Description", proposal.GetDescription())); + entry.push_back(Pair("Your Vote", (int64_t)it->second.GetUnformattedVote())); + ret.push_back(entry); + } + return ret; + } + return "You don't have any votes saved into the database"; +} + + diff --git a/src/script.cpp b/src/script.cpp index 5ef4d5d5c..76641feba 100644 --- a/src/script.cpp +++ b/src/script.cpp @@ -102,6 +102,7 @@ const char* GetTxnOutputType(txnouttype t) case TX_PUBKEYHASH: return "pubkeyhash"; case TX_SCRIPTHASH: return "scripthash"; case TX_MULTISIG: return "multisig"; + case TX_NULL_DATA: return "nulldata"; } return NULL; } @@ -775,11 +776,6 @@ bool EvalScript(vector >& stack, const CScript& script, co case OP_ADD: case OP_SUB: - case OP_MUL: - case OP_DIV: - case OP_MOD: - case OP_LSHIFT: - case OP_RSHIFT: case OP_BOOLAND: case OP_BOOLOR: case OP_NUMEQUAL: @@ -808,33 +804,6 @@ bool EvalScript(vector >& stack, const CScript& script, co bn = bn1 - bn2; break; - case OP_MUL: - if (!BN_mul(&bn, &bn1, &bn2, pctx)) - return false; - break; - - case OP_DIV: - if (!BN_div(&bn, NULL, &bn1, &bn2, pctx)) - return false; - break; - - case OP_MOD: - if (!BN_mod(&bn, &bn1, &bn2, pctx)) - return false; - break; - - case OP_LSHIFT: - if (bn2 < bnZero || bn2 > CBigNum(2048)) - return false; - bn = bn1 << bn2.getulong(); - break; - - case OP_RSHIFT: - if (bn2 < bnZero || bn2 > CBigNum(2048)) - return false; - bn = bn1 >> bn2.getulong(); - break; - case OP_BOOLAND: bn = (bn1 != bnZero && bn2 != bnZero); break; case OP_BOOLOR: bn = (bn1 != bnZero || bn2 != bnZero); break; case OP_NUMEQUAL: bn = (bn1 == bn2); break; @@ -1207,13 +1176,27 @@ bool CheckSig(vector vchSig, vector vchPubKey, CSc return true; } +bool CScript::IsPushOnly(const_iterator pc) const +{ + while (pc < end()) + { + opcodetype opcode; + if (!GetOp(pc, opcode)) + return false; + // Note that IsPushOnly() *does* consider OP_RESERVED to be a + // push-type opcode, however execution of OP_RESERVED fails, so + // it's not relevant to P2SH/BIP62 as the scriptSig would fail prior to + // the P2SH special validation code being executed. + if (opcode > OP_16) + return false; + } + return true; +} - - - - - - +bool CScript::IsPushOnly() const +{ + return this->IsPushOnly(begin()); +} // // Return public keys or hashes from scriptPubKey, for 'standard' transaction types. @@ -1244,6 +1227,16 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector= 1 && scriptPubKey[0] == OP_RETURN && scriptPubKey.IsPushOnly(scriptPubKey.begin() + 1)) { + typeRet = TX_NULL_DATA; + return true; + } + // Scan templates const CScript& script1 = scriptPubKey; BOOST_FOREACH(const PAIRTYPE(txnouttype, CScript)& tplate, mTemplates) @@ -1257,7 +1250,7 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector= sigs2.size()) return PushAll(sigs1); diff --git a/src/script.h b/src/script.h index 99465cb10..ad38d7d60 100644 --- a/src/script.h +++ b/src/script.h @@ -14,6 +14,12 @@ #include "keystore.h" #include "bignum.h" +template +std::vector ToByteVector(const T& in) +{ + return std::vector(in.begin(), in.end()); +} + typedef std::vector valtype; class CTransaction; @@ -27,7 +33,6 @@ enum SIGHASH_ANYONECANPAY = 0x80, }; - enum txnouttype { TX_NONSTANDARD, @@ -36,6 +41,7 @@ enum txnouttype TX_PUBKEYHASH, TX_SCRIPTHASH, TX_MULTISIG, + TX_NULL_DATA }; class CNoDestination { @@ -202,8 +208,6 @@ enum opcodetype const char* GetOpName(opcodetype opcode); - - inline std::string ValueString(const std::vector& vch) { if (vch.size() <= 4) @@ -224,13 +228,6 @@ inline std::string StackString(const std::vector >& v return str; } - - - - - - - /** Serialized script, used inside transaction inputs and outputs */ class CScript : public std::vector { @@ -522,19 +519,13 @@ class CScript : public std::vector bool IsPayToScriptHash() const; - // Called by CTransaction::IsStandard - bool IsPushOnly() const + bool IsPushOnly(const_iterator pc) const; + + bool IsPushOnly() const; + + bool IsDataCarrier() const { - const_iterator pc = begin(); - while (pc < end()) - { - opcodetype opcode; - if (!GetOp(pc, opcode)) - return false; - if (opcode > OP_16) - return false; - } - return true; + return (this->size() > 0 && this->at(0) == OP_RETURN); } diff --git a/src/scrypt.cpp b/src/scrypt.cpp new file mode 100644 index 000000000..06b94654a --- /dev/null +++ b/src/scrypt.cpp @@ -0,0 +1,384 @@ +/* + * Copyright 2009 Colin Percival, 2011 ArtForz, 2012-2013 pooler + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * This file was originally written by Colin Percival as part of the Tarsnap + * online backup system. + */ + +#include "scrypt.h" +#include "uint256.h" +#include "util.h" +#include +#include + +#include +#include + +#ifndef __FreeBSD__ +static inline void be32enc(void *pp, uint32_t x) +{ + uint8_t *p = (uint8_t *)pp; + p[3] = x & 0xff; + p[2] = (x >> 8) & 0xff; + p[1] = (x >> 16) & 0xff; + p[0] = (x >> 24) & 0xff; +} +#endif + +typedef struct HMAC_SHA256Context { + SHA256_CTX ictx; + SHA256_CTX octx; +} HMAC_SHA256_CTX; + +/* Initialize an HMAC-SHA256 operation with the given key. */ +static void +HMAC_SHA256_Init(HMAC_SHA256_CTX *ctx, const void *_K, size_t Klen) +{ + unsigned char pad[64]; + unsigned char khash[32]; + const unsigned char *K = (const unsigned char *)_K; + size_t i; + + /* If Klen > 64, the key is really SHA256(K). */ + if (Klen > 64) { + SHA256_Init(&ctx->ictx); + SHA256_Update(&ctx->ictx, K, Klen); + SHA256_Final(khash, &ctx->ictx); + K = khash; + Klen = 32; + } + + /* Inner SHA256 operation is SHA256(K xor [block of 0x36] || data). */ + SHA256_Init(&ctx->ictx); + memset(pad, 0x36, 64); + for (i = 0; i < Klen; i++) + pad[i] ^= K[i]; + SHA256_Update(&ctx->ictx, pad, 64); + + /* Outer SHA256 operation is SHA256(K xor [block of 0x5c] || hash). */ + SHA256_Init(&ctx->octx); + memset(pad, 0x5c, 64); + for (i = 0; i < Klen; i++) + pad[i] ^= K[i]; + SHA256_Update(&ctx->octx, pad, 64); + + /* Clean the stack. */ + memset(khash, 0, 32); +} + +/* Add bytes to the HMAC-SHA256 operation. */ +static void +HMAC_SHA256_Update(HMAC_SHA256_CTX *ctx, const void *in, size_t len) +{ + /* Feed data to the inner SHA256 operation. */ + SHA256_Update(&ctx->ictx, in, len); +} + +/* Finish an HMAC-SHA256 operation. */ +static void +HMAC_SHA256_Final(unsigned char digest[32], HMAC_SHA256_CTX *ctx) +{ + unsigned char ihash[32]; + + /* Finish the inner SHA256 operation. */ + SHA256_Final(ihash, &ctx->ictx); + + /* Feed the inner hash to the outer SHA256 operation. */ + SHA256_Update(&ctx->octx, ihash, 32); + + /* Finish the outer SHA256 operation. */ + SHA256_Final(digest, &ctx->octx); + + /* Clean the stack. */ + memset(ihash, 0, 32); +} + +/** + * PBKDF2_SHA256(passwd, passwdlen, salt, saltlen, c, buf, dkLen): + * Compute PBKDF2(passwd, salt, c, dkLen) using HMAC-SHA256 as the PRF, and + * write the output to buf. The value dkLen must be at most 32 * (2^32 - 1). + */ +void +PBKDF2_SHA256_s(const uint8_t *passwd, size_t passwdlen, const uint8_t *salt, + size_t saltlen, uint64_t c, uint8_t *buf, size_t dkLen) +{ + HMAC_SHA256_CTX PShctx, hctx; + size_t i; + uint8_t ivec[4]; + uint8_t U[32]; + uint8_t T[32]; + uint64_t j; + int k; + size_t clen; + + /* Compute HMAC state after processing P and S. */ + HMAC_SHA256_Init(&PShctx, passwd, passwdlen); + HMAC_SHA256_Update(&PShctx, salt, saltlen); + + /* Iterate through the blocks. */ + for (i = 0; i * 32 < dkLen; i++) { + /* Generate INT(i + 1). */ + be32enc(ivec, (uint32_t)(i + 1)); + + /* Compute U_1 = PRF(P, S || INT(i)). */ + memcpy(&hctx, &PShctx, sizeof(HMAC_SHA256_CTX)); + HMAC_SHA256_Update(&hctx, ivec, 4); + HMAC_SHA256_Final(U, &hctx); + + /* T_i = U_1 ... */ + memcpy(T, U, 32); + + for (j = 2; j <= c; j++) { + /* Compute U_j. */ + HMAC_SHA256_Init(&hctx, passwd, passwdlen); + HMAC_SHA256_Update(&hctx, U, 32); + HMAC_SHA256_Final(U, &hctx); + + /* ... xor U_j ... */ + for (k = 0; k < 32; k++) + T[k] ^= U[k]; + } + + /* Copy as many bytes as necessary into buf. */ + clen = dkLen - i * 32; + if (clen > 32) + clen = 32; + memcpy(&buf[i * 32], T, clen); + } + + /* Clean PShctx, since we never called _Final on it. */ + memset(&PShctx, 0, sizeof(HMAC_SHA256_CTX)); +} + +static inline uint32_t +le32dec_2(const void * pp) +{ + const uint8_t * p = (uint8_t const *)pp; + + return ((uint32_t)(p[0]) + ((uint32_t)(p[1]) << 8) + + ((uint32_t)(p[2]) << 16) + ((uint32_t)(p[3]) << 24)); +} + +static inline void +le32enc_2(void * pp, uint32_t x) +{ + uint8_t * p = (uint8_t *)pp; + + p[0] = x & 0xff; + p[1] = (x >> 8) & 0xff; + p[2] = (x >> 16) & 0xff; + p[3] = (x >> 24) & 0xff; +} + +static void +blkcpy(void * dest, const void * src, size_t len) +{ + size_t * D = (size_t*)dest; + const size_t * S = (size_t*)src; + size_t L = len / sizeof(size_t); + size_t i; + + for (i = 0; i < L; i++) + D[i] = S[i]; +} + +static void +blkxor(void * dest, const void * src, size_t len) +{ + size_t * D = (size_t*)dest; + const size_t* S = (size_t*)src; + size_t L = len / sizeof(size_t); + size_t i; + + for (i = 0; i < L; i++) + D[i] ^= S[i]; +} + +/** + * salsa20_8(B): + * Apply the salsa20/8 core to the provided block. + */ +static void +salsa20_8(uint32_t B[16]) +{ + uint32_t x[16]; + size_t i; + + blkcpy(x, B, 64); + for (i = 0; i < 8; i += 2) { +#define R(a,b) (((a) << (b)) | ((a) >> (32 - (b)))) + /* Operate on columns. */ + x[ 4] ^= R(x[ 0]+x[12], 7); x[ 8] ^= R(x[ 4]+x[ 0], 9); + x[12] ^= R(x[ 8]+x[ 4],13); x[ 0] ^= R(x[12]+x[ 8],18); + + x[ 9] ^= R(x[ 5]+x[ 1], 7); x[13] ^= R(x[ 9]+x[ 5], 9); + x[ 1] ^= R(x[13]+x[ 9],13); x[ 5] ^= R(x[ 1]+x[13],18); + + x[14] ^= R(x[10]+x[ 6], 7); x[ 2] ^= R(x[14]+x[10], 9); + x[ 6] ^= R(x[ 2]+x[14],13); x[10] ^= R(x[ 6]+x[ 2],18); + + x[ 3] ^= R(x[15]+x[11], 7); x[ 7] ^= R(x[ 3]+x[15], 9); + x[11] ^= R(x[ 7]+x[ 3],13); x[15] ^= R(x[11]+x[ 7],18); + + /* Operate on rows. */ + x[ 1] ^= R(x[ 0]+x[ 3], 7); x[ 2] ^= R(x[ 1]+x[ 0], 9); + x[ 3] ^= R(x[ 2]+x[ 1],13); x[ 0] ^= R(x[ 3]+x[ 2],18); + + x[ 6] ^= R(x[ 5]+x[ 4], 7); x[ 7] ^= R(x[ 6]+x[ 5], 9); + x[ 4] ^= R(x[ 7]+x[ 6],13); x[ 5] ^= R(x[ 4]+x[ 7],18); + + x[11] ^= R(x[10]+x[ 9], 7); x[ 8] ^= R(x[11]+x[10], 9); + x[ 9] ^= R(x[ 8]+x[11],13); x[10] ^= R(x[ 9]+x[ 8],18); + + x[12] ^= R(x[15]+x[14], 7); x[13] ^= R(x[12]+x[15], 9); + x[14] ^= R(x[13]+x[12],13); x[15] ^= R(x[14]+x[13],18); +#undef R + } + for (i = 0; i < 16; i++) + B[i] += x[i]; +} + +/** + * blockmix_salsa8(Bin, Bout, X, r): + * Compute Bout = BlockMix_{salsa20/8, r}(Bin). The input Bin must be 128r + * bytes in length; the output Bout must also be the same size. The + * temporary space X must be 64 bytes. + */ +static void +blockmix_salsa8(const uint32_t * Bin, uint32_t * Bout, uint32_t * X, size_t r) +{ + size_t i; + + /* 1: X <-- B_{2r - 1} */ + blkcpy(X, &Bin[(2 * r - 1) * 16], 64); + + /* 2: for i = 0 to 2r - 1 do */ + for (i = 0; i < 2 * r; i += 2) { + /* 3: X <-- H(X \xor B_i) */ + blkxor(X, &Bin[i * 16], 64); + salsa20_8(X); + + /* 4: Y_i <-- X */ + /* 6: B' <-- (Y_0, Y_2 ... Y_{2r-2}, Y_1, Y_3 ... Y_{2r-1}) */ + blkcpy(&Bout[i * 8], X, 64); + + /* 3: X <-- H(X \xor B_i) */ + blkxor(X, &Bin[i * 16 + 16], 64); + salsa20_8(X); + + /* 4: Y_i <-- X */ + /* 6: B' <-- (Y_0, Y_2 ... Y_{2r-2}, Y_1, Y_3 ... Y_{2r-1}) */ + blkcpy(&Bout[i * 8 + r * 16], X, 64); + } +} + +/** + * integerify(B, r): + * Return the result of parsing B_{2r-1} as a little-endian integer. + */ +static uint64_t +integerify(const void * B, size_t r) +{ + const uint32_t * X = (const uint32_t*)((uintptr_t)(B) + (2 * r - 1) * 64); + + return (((uint64_t)(X[1]) << 32) + X[0]); +} + +void SMix(uint8_t *B, unsigned int r, unsigned int N, void* _V, void* XY) +{ + //new + uint32_t* X = (uint32_t*)XY; + uint32_t* Y = (uint32_t*)((uint8_t*)(XY) + 128 * r); + uint32_t* Z = (uint32_t*)((uint8_t *)(XY) + 256 * r); + uint32_t * V = (uint32_t*)_V; + + uint32_t j, k; + + /* 1: X <-- B */ + for (k = 0; k < 32 * r; k++) + X[k] = le32dec_2(&B[4 * k]); + + /* 2: for i = 0 to N - 1 do */ + for (unsigned int i = 0; i < N; i += 2) + { + /* 3: V_i <-- X */ + blkcpy(&V[i * (32 * r)], X, 128 * r); + + /* 4: X <-- H(X) */ + blockmix_salsa8(X, Y, Z, r); + + /* 3: V_i <-- X */ + blkcpy(&V[(i + 1) * (32 * r)], Y, 128 * r); + + /* 4: X <-- H(X) */ + blockmix_salsa8(Y, X, Z, r); + } + + /* 6: for i = 0 to N - 1 do */ + for (unsigned int i = 0; i < N; i += 2) + { + /* 7: j <-- Integerify(X) mod N */ + j = integerify(X, r) & (N - 1); + + /* 8: X <-- H(X \xor V_j) */ + blkxor(X, &V[j * (32 * r)], 128 * r); + blockmix_salsa8(X, Y, Z, r); + + /* 7: j <-- Integerify(X) mod N */ + j = integerify(Y, r) & (N - 1); + + /* 8: X <-- H(X \xor V_j) */ + blkxor(Y, &V[j * (32 * r)], 128 * r); + blockmix_salsa8(Y, X, Z, r); + } + + /* 10: B' <-- X */ + for (k = 0; k < 32 * r; k++) + le32enc_2(&B[4 * k], X[k]); +} + +void scrypt(const char* pass, unsigned int pLen, const char* salt, unsigned int sLen, char *output, unsigned int N, unsigned int r, unsigned int p, unsigned int dkLen) +{ + //containers + void* V0 = malloc(128 * r * N + 63); + void* XY0 = malloc(256 * r + 64 + 63); + void* B1 = malloc(128 * r * p + 63); + uint8_t* B = (uint8_t *)(((uintptr_t)(B1) + 63) & ~ (uintptr_t)(63)); + uint32_t* V = (uint32_t *)(((uintptr_t)(V0) + 63) & ~ (uintptr_t)(63)); + uint32_t* XY = (uint32_t *)(((uintptr_t)(XY0) + 63) & ~ (uintptr_t)(63)); + + PBKDF2_SHA256_s((const uint8_t *)pass, pLen, (const uint8_t *)salt, sLen, 1, B, p * 128 * r); + + for(unsigned int i = 0; i < p; i++) + { + SMix(&B[i * 128 * r], r, N, V, XY); + } + + PBKDF2_SHA256_s((const uint8_t *)pass, pLen, B, p * 128 * r, 1, (uint8_t *)output, dkLen); + + free(V0); + free(XY0); + free(B1); +} diff --git a/src/scrypt.h b/src/scrypt.h new file mode 100644 index 000000000..68f07acad --- /dev/null +++ b/src/scrypt.h @@ -0,0 +1,9 @@ +#ifndef SCRYPT_H +#define SCRYPT_H +#include +#include +#include + +void scrypt(const char* pass, unsigned int pLen, const char* salt, unsigned int sLen, char *output, unsigned int N, unsigned int r, unsigned int p, unsigned int dkLen); + +#endif diff --git a/src/secp256k1/.deps/bench_inv-bench_inv.Po b/src/secp256k1/.deps/bench_inv-bench_inv.Po new file mode 100644 index 000000000..9ce06a81e --- /dev/null +++ b/src/secp256k1/.deps/bench_inv-bench_inv.Po @@ -0,0 +1 @@ +# dummy diff --git a/src/secp256k1/.deps/bench_sign.Po b/src/secp256k1/.deps/bench_sign.Po new file mode 100644 index 000000000..9ce06a81e --- /dev/null +++ b/src/secp256k1/.deps/bench_sign.Po @@ -0,0 +1 @@ +# dummy diff --git a/src/secp256k1/.deps/bench_verify.Po b/src/secp256k1/.deps/bench_verify.Po new file mode 100644 index 000000000..9ce06a81e --- /dev/null +++ b/src/secp256k1/.deps/bench_verify.Po @@ -0,0 +1 @@ +# dummy diff --git a/src/secp256k1/.deps/libsecp256k1_la-secp256k1.Plo b/src/secp256k1/.deps/libsecp256k1_la-secp256k1.Plo new file mode 100644 index 000000000..198d4d2de --- /dev/null +++ b/src/secp256k1/.deps/libsecp256k1_la-secp256k1.Plo @@ -0,0 +1,180 @@ +libsecp256k1_la-secp256k1.lo: src/secp256k1.c /usr/include/stdc-predef.h \ + include/secp256k1.h src/util.h src/libsecp256k1-config.h \ + /usr/include/stdlib.h /usr/include/features.h \ + /usr/include/x86_64-linux-gnu/sys/cdefs.h \ + /usr/include/x86_64-linux-gnu/bits/wordsize.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs.h \ + /usr/include/x86_64-linux-gnu/gnu/stubs-64.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h \ + /usr/include/x86_64-linux-gnu/bits/waitflags.h \ + /usr/include/x86_64-linux-gnu/bits/waitstatus.h /usr/include/endian.h \ + /usr/include/x86_64-linux-gnu/bits/endian.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap.h \ + /usr/include/x86_64-linux-gnu/bits/types.h \ + /usr/include/x86_64-linux-gnu/bits/typesizes.h \ + /usr/include/x86_64-linux-gnu/bits/byteswap-16.h \ + /usr/include/x86_64-linux-gnu/sys/types.h /usr/include/time.h \ + /usr/include/x86_64-linux-gnu/sys/select.h \ + /usr/include/x86_64-linux-gnu/bits/select.h \ + /usr/include/x86_64-linux-gnu/bits/sigset.h \ + /usr/include/x86_64-linux-gnu/bits/time.h \ + /usr/include/x86_64-linux-gnu/bits/select2.h \ + /usr/include/x86_64-linux-gnu/sys/sysmacros.h \ + /usr/include/x86_64-linux-gnu/bits/pthreadtypes.h /usr/include/alloca.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib-float.h \ + /usr/include/x86_64-linux-gnu/bits/stdlib.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stdint.h /usr/include/stdint.h \ + /usr/include/x86_64-linux-gnu/bits/wchar.h /usr/include/stdio.h \ + /usr/include/libio.h /usr/include/_G_config.h /usr/include/wchar.h \ + /usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h \ + /usr/include/x86_64-linux-gnu/bits/stdio_lim.h \ + /usr/include/x86_64-linux-gnu/bits/sys_errlist.h \ + /usr/include/x86_64-linux-gnu/bits/stdio.h \ + /usr/include/x86_64-linux-gnu/bits/stdio2.h src/num_impl.h src/num.h \ + src/field_impl.h src/field_10x26_impl.h /usr/include/string.h \ + /usr/include/xlocale.h /usr/include/x86_64-linux-gnu/bits/string.h \ + /usr/include/x86_64-linux-gnu/bits/string2.h \ + /usr/include/x86_64-linux-gnu/bits/string3.h src/field.h \ + src/field_10x26.h src/scalar_impl.h src/group.h src/scalar.h \ + src/scalar_8x32.h src/scalar_8x32_impl.h src/group_impl.h \ + src/ecmult_impl.h src/ecmult.h src/ecmult_gen_impl.h src/ecmult_gen.h \ + src/ecdsa_impl.h src/ecdsa.h src/eckey_impl.h src/eckey.h + +/usr/include/stdc-predef.h: + +include/secp256k1.h: + +src/util.h: + +src/libsecp256k1-config.h: + +/usr/include/stdlib.h: + +/usr/include/features.h: + +/usr/include/x86_64-linux-gnu/sys/cdefs.h: + +/usr/include/x86_64-linux-gnu/bits/wordsize.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs.h: + +/usr/include/x86_64-linux-gnu/gnu/stubs-64.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stddef.h: + +/usr/include/x86_64-linux-gnu/bits/waitflags.h: + +/usr/include/x86_64-linux-gnu/bits/waitstatus.h: + +/usr/include/endian.h: + +/usr/include/x86_64-linux-gnu/bits/endian.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap.h: + +/usr/include/x86_64-linux-gnu/bits/types.h: + +/usr/include/x86_64-linux-gnu/bits/typesizes.h: + +/usr/include/x86_64-linux-gnu/bits/byteswap-16.h: + +/usr/include/x86_64-linux-gnu/sys/types.h: + +/usr/include/time.h: + +/usr/include/x86_64-linux-gnu/sys/select.h: + +/usr/include/x86_64-linux-gnu/bits/select.h: + +/usr/include/x86_64-linux-gnu/bits/sigset.h: + +/usr/include/x86_64-linux-gnu/bits/time.h: + +/usr/include/x86_64-linux-gnu/bits/select2.h: + +/usr/include/x86_64-linux-gnu/sys/sysmacros.h: + +/usr/include/x86_64-linux-gnu/bits/pthreadtypes.h: + +/usr/include/alloca.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-bsearch.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib-float.h: + +/usr/include/x86_64-linux-gnu/bits/stdlib.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stdint.h: + +/usr/include/stdint.h: + +/usr/include/x86_64-linux-gnu/bits/wchar.h: + +/usr/include/stdio.h: + +/usr/include/libio.h: + +/usr/include/_G_config.h: + +/usr/include/wchar.h: + +/usr/lib/gcc/x86_64-linux-gnu/5/include/stdarg.h: + +/usr/include/x86_64-linux-gnu/bits/stdio_lim.h: + +/usr/include/x86_64-linux-gnu/bits/sys_errlist.h: + +/usr/include/x86_64-linux-gnu/bits/stdio.h: + +/usr/include/x86_64-linux-gnu/bits/stdio2.h: + +src/num_impl.h: + +src/num.h: + +src/field_impl.h: + +src/field_10x26_impl.h: + +/usr/include/string.h: + +/usr/include/xlocale.h: + +/usr/include/x86_64-linux-gnu/bits/string.h: + +/usr/include/x86_64-linux-gnu/bits/string2.h: + +/usr/include/x86_64-linux-gnu/bits/string3.h: + +src/field.h: + +src/field_10x26.h: + +src/scalar_impl.h: + +src/group.h: + +src/scalar.h: + +src/scalar_8x32.h: + +src/scalar_8x32_impl.h: + +src/group_impl.h: + +src/ecmult_impl.h: + +src/ecmult.h: + +src/ecmult_gen_impl.h: + +src/ecmult_gen.h: + +src/ecdsa_impl.h: + +src/ecdsa.h: + +src/eckey_impl.h: + +src/eckey.h: diff --git a/src/secp256k1/.deps/tests-tests.Po b/src/secp256k1/.deps/tests-tests.Po new file mode 100644 index 000000000..9ce06a81e --- /dev/null +++ b/src/secp256k1/.deps/tests-tests.Po @@ -0,0 +1 @@ +# dummy diff --git a/src/secp256k1/build-aux/compile b/src/secp256k1/build-aux/compile new file mode 100755 index 000000000..a85b723c7 --- /dev/null +++ b/src/secp256k1/build-aux/compile @@ -0,0 +1,347 @@ +#! /bin/sh +# Wrapper for compilers which do not understand '-c -o'. + +scriptversion=2012-10-14.11; # UTC + +# Copyright (C) 1999-2014 Free Software Foundation, Inc. +# Written by Tom Tromey . +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + +nl=' +' + +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent tools from complaining about whitespace usage. +IFS=" "" $nl" + +file_conv= + +# func_file_conv build_file lazy +# Convert a $build file to $host form and store it in $file +# Currently only supports Windows hosts. If the determined conversion +# type is listed in (the comma separated) LAZY, no conversion will +# take place. +func_file_conv () +{ + file=$1 + case $file in + / | /[!/]*) # absolute file, and not a UNC file + if test -z "$file_conv"; then + # lazily determine how to convert abs files + case `uname -s` in + MINGW*) + file_conv=mingw + ;; + CYGWIN*) + file_conv=cygwin + ;; + *) + file_conv=wine + ;; + esac + fi + case $file_conv/,$2, in + *,$file_conv,*) + ;; + mingw/*) + file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` + ;; + cygwin/*) + file=`cygpath -m "$file" || echo "$file"` + ;; + wine/*) + file=`winepath -w "$file" || echo "$file"` + ;; + esac + ;; + esac +} + +# func_cl_dashL linkdir +# Make cl look for libraries in LINKDIR +func_cl_dashL () +{ + func_file_conv "$1" + if test -z "$lib_path"; then + lib_path=$file + else + lib_path="$lib_path;$file" + fi + linker_opts="$linker_opts -LIBPATH:$file" +} + +# func_cl_dashl library +# Do a library search-path lookup for cl +func_cl_dashl () +{ + lib=$1 + found=no + save_IFS=$IFS + IFS=';' + for dir in $lib_path $LIB + do + IFS=$save_IFS + if $shared && test -f "$dir/$lib.dll.lib"; then + found=yes + lib=$dir/$lib.dll.lib + break + fi + if test -f "$dir/$lib.lib"; then + found=yes + lib=$dir/$lib.lib + break + fi + if test -f "$dir/lib$lib.a"; then + found=yes + lib=$dir/lib$lib.a + break + fi + done + IFS=$save_IFS + + if test "$found" != yes; then + lib=$lib.lib + fi +} + +# func_cl_wrapper cl arg... +# Adjust compile command to suit cl +func_cl_wrapper () +{ + # Assume a capable shell + lib_path= + shared=: + linker_opts= + for arg + do + if test -n "$eat"; then + eat= + else + case $1 in + -o) + # configure might choose to run compile as 'compile cc -o foo foo.c'. + eat=1 + case $2 in + *.o | *.[oO][bB][jJ]) + func_file_conv "$2" + set x "$@" -Fo"$file" + shift + ;; + *) + func_file_conv "$2" + set x "$@" -Fe"$file" + shift + ;; + esac + ;; + -I) + eat=1 + func_file_conv "$2" mingw + set x "$@" -I"$file" + shift + ;; + -I*) + func_file_conv "${1#-I}" mingw + set x "$@" -I"$file" + shift + ;; + -l) + eat=1 + func_cl_dashl "$2" + set x "$@" "$lib" + shift + ;; + -l*) + func_cl_dashl "${1#-l}" + set x "$@" "$lib" + shift + ;; + -L) + eat=1 + func_cl_dashL "$2" + ;; + -L*) + func_cl_dashL "${1#-L}" + ;; + -static) + shared=false + ;; + -Wl,*) + arg=${1#-Wl,} + save_ifs="$IFS"; IFS=',' + for flag in $arg; do + IFS="$save_ifs" + linker_opts="$linker_opts $flag" + done + IFS="$save_ifs" + ;; + -Xlinker) + eat=1 + linker_opts="$linker_opts $2" + ;; + -*) + set x "$@" "$1" + shift + ;; + *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) + func_file_conv "$1" + set x "$@" -Tp"$file" + shift + ;; + *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) + func_file_conv "$1" mingw + set x "$@" "$file" + shift + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift + done + if test -n "$linker_opts"; then + linker_opts="-link$linker_opts" + fi + exec "$@" $linker_opts + exit 1 +} + +eat= + +case $1 in + '') + echo "$0: No command. Try '$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: compile [--help] [--version] PROGRAM [ARGS] + +Wrapper for compilers which do not understand '-c -o'. +Remove '-o dest.o' from ARGS, run PROGRAM with the remaining +arguments, and rename the output as expected. + +If you are trying to build a whole package this is not the +right script to run: please start by reading the file 'INSTALL'. + +Report bugs to . +EOF + exit $? + ;; + -v | --v*) + echo "compile $scriptversion" + exit $? + ;; + cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) + func_cl_wrapper "$@" # Doesn't return... + ;; +esac + +ofile= +cfile= + +for arg +do + if test -n "$eat"; then + eat= + else + case $1 in + -o) + # configure might choose to run compile as 'compile cc -o foo foo.c'. + # So we strip '-o arg' only if arg is an object. + eat=1 + case $2 in + *.o | *.obj) + ofile=$2 + ;; + *) + set x "$@" -o "$2" + shift + ;; + esac + ;; + *.c) + cfile=$1 + set x "$@" "$1" + shift + ;; + *) + set x "$@" "$1" + shift + ;; + esac + fi + shift +done + +if test -z "$ofile" || test -z "$cfile"; then + # If no '-o' option was seen then we might have been invoked from a + # pattern rule where we don't need one. That is ok -- this is a + # normal compilation that the losing compiler can handle. If no + # '.c' file was seen then we are probably linking. That is also + # ok. + exec "$@" +fi + +# Name of file we expect compiler to create. +cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` + +# Create the lock directory. +# Note: use '[/\\:.-]' here to ensure that we don't use the same name +# that we are using for the .o file. Also, base the name on the expected +# object file name, since that is what matters with a parallel build. +lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d +while true; do + if mkdir "$lockdir" >/dev/null 2>&1; then + break + fi + sleep 1 +done +# FIXME: race condition here if user kills between mkdir and trap. +trap "rmdir '$lockdir'; exit 1" 1 2 15 + +# Run the compile. +"$@" +ret=$? + +if test -f "$cofile"; then + test "$cofile" = "$ofile" || mv "$cofile" "$ofile" +elif test -f "${cofile}bj"; then + test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" +fi + +rmdir "$lockdir" +exit $ret + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/src/secp256k1/build-aux/config.guess b/src/secp256k1/build-aux/config.guess new file mode 100755 index 000000000..16592509d --- /dev/null +++ b/src/secp256k1/build-aux/config.guess @@ -0,0 +1,1441 @@ +#! /bin/sh +# Attempt to guess a canonical system name. +# Copyright 1992-2015 Free Software Foundation, Inc. + +timestamp='2015-08-20' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). +# +# Originally written by Per Bothner; maintained since 2000 by Ben Elliston. +# +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD +# +# Please send patches to . + + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] + +Output the configuration name of the system \`$me' is run on. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.guess ($timestamp) + +Originally written by Per Bothner. +Copyright 1992-2015 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" >&2 + exit 1 ;; + * ) + break ;; + esac +done + +if test $# != 0; then + echo "$me: too many arguments$help" >&2 + exit 1 +fi + +trap 'exit 1' 1 2 15 + +# CC_FOR_BUILD -- compiler used by this script. Note that the use of a +# compiler to aid in system detection is discouraged as it requires +# temporary files to be created and, as you can see below, it is a +# headache to deal with in a portable fashion. + +# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still +# use `HOST_CC' if defined, but it is deprecated. + +# Portable tmp directory creation inspired by the Autoconf team. + +set_cc_for_build=' +trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +: ${TMPDIR=/tmp} ; + { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || + { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || + { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } || + { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ; +dummy=$tmp/dummy ; +tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ; +case $CC_FOR_BUILD,$HOST_CC,$CC in + ,,) echo "int x;" > $dummy.c ; + for c in cc gcc c89 c99 ; do + if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then + CC_FOR_BUILD="$c"; break ; + fi ; + done ; + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found ; + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; +esac ; set_cc_for_build= ;' + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 1994-08-24) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +case "${UNAME_SYSTEM}" in +Linux|GNU|GNU/*) + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + LIBC=gnu + + eval $set_cc_for_build + cat <<-EOF > $dummy.c + #include + #if defined(__UCLIBC__) + LIBC=uclibc + #elif defined(__dietlibc__) + LIBC=dietlibc + #else + LIBC=gnu + #endif + EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'` + ;; +esac + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + *:NetBSD:*:*) + # NetBSD (nbsd) targets should (where applicable) match one or + # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*, + # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently + # switched to ELF, *-*-netbsd* would select the old + # object file format. This provides both forward + # compatibility and a consistent mechanism for selecting the + # object file format. + # + # Note: NetBSD doesn't particularly care about the vendor + # portion of the name. We always set it to "unknown". + sysctl="sysctl -n hw.machine_arch" + UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \ + /sbin/$sysctl 2>/dev/null || \ + /usr/sbin/$sysctl 2>/dev/null || \ + echo unknown)` + case "${UNAME_MACHINE_ARCH}" in + armeb) machine=armeb-unknown ;; + arm*) machine=arm-unknown ;; + sh3el) machine=shl-unknown ;; + sh3eb) machine=sh-unknown ;; + sh5el) machine=sh5le-unknown ;; + earmv*) + arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'` + endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'` + machine=${arch}${endian}-unknown + ;; + *) machine=${UNAME_MACHINE_ARCH}-unknown ;; + esac + # The Operating System including object format, if it has switched + # to ELF recently, or will in the future. + case "${UNAME_MACHINE_ARCH}" in + arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax) + eval $set_cc_for_build + if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ELF__ + then + # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). + # Return netbsd for either. FIX? + os=netbsd + else + os=netbsdelf + fi + ;; + *) + os=netbsd + ;; + esac + # Determine ABI tags. + case "${UNAME_MACHINE_ARCH}" in + earm*) + expr='s/^earmv[0-9]/-eabi/;s/eb$//' + abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"` + ;; + esac + # The OS release + # Debian GNU/NetBSD machines have a different userland, and + # thus, need a distinct triplet. However, they do not need + # kernel version information, so it can be replaced with a + # suitable tag, in the style of linux-gnu. + case "${UNAME_VERSION}" in + Debian*) + release='-gnu' + ;; + *) + release=`echo ${UNAME_RELEASE} | sed -e 's/[-_].*//' | cut -d. -f1,2` + ;; + esac + # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: + # contains redundant information, the shorter form: + # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. + echo "${machine}-${os}${release}${abi}" + exit ;; + *:Bitrig:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE} + exit ;; + *:OpenBSD:*:*) + UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE} + exit ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit ;; + *:SolidBSD:*:*) + echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE} + exit ;; + macppc:MirBSD:*:*) + echo powerpc-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit ;; + *:Sortix:*:*) + echo ${UNAME_MACHINE}-unknown-sortix + exit ;; + alpha:OSF1:*:*) + case $UNAME_RELEASE in + *4.0) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac + # According to Compaq, /usr/sbin/psrinfo has been available on + # OSF/1 and Tru64 systems produced since 1995. I hope that + # covers most systems running today. This code pipes the CPU + # types through head -n 1, so we only detect the type of CPU 0. + ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + case "$ALPHA_CPU_TYPE" in + "EV4 (21064)") + UNAME_MACHINE="alpha" ;; + "EV4.5 (21064)") + UNAME_MACHINE="alpha" ;; + "LCA4 (21066/21068)") + UNAME_MACHINE="alpha" ;; + "EV5 (21164)") + UNAME_MACHINE="alphaev5" ;; + "EV5.6 (21164A)") + UNAME_MACHINE="alphaev56" ;; + "EV5.6 (21164PC)") + UNAME_MACHINE="alphapca56" ;; + "EV5.7 (21164PC)") + UNAME_MACHINE="alphapca57" ;; + "EV6 (21264)") + UNAME_MACHINE="alphaev6" ;; + "EV6.7 (21264A)") + UNAME_MACHINE="alphaev67" ;; + "EV6.8CB (21264C)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8AL (21264B)") + UNAME_MACHINE="alphaev68" ;; + "EV6.8CX (21264D)") + UNAME_MACHINE="alphaev68" ;; + "EV6.9A (21264/EV69A)") + UNAME_MACHINE="alphaev69" ;; + "EV7 (21364)") + UNAME_MACHINE="alphaev7" ;; + "EV7.9 (21364A)") + UNAME_MACHINE="alphaev79" ;; + esac + # A Pn.n version is a patched version. + # A Vn.n version is a released version. + # A Tn.n version is a released field test version. + # A Xn.n version is an unreleased experimental baselevel. + # 1.2 uses "1.2" for uname -r. + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + # Reset EXIT trap before exiting to avoid spurious non-zero exit code. + exitcode=$? + trap '' 0 + exit $exitcode ;; + Alpha\ *:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # Should we change UNAME_MACHINE based on the output of uname instead + # of the specific Alpha model? + echo alpha-pc-interix + exit ;; + 21064:Windows_NT:50:3) + echo alpha-dec-winnt3.5 + exit ;; + Amiga*:UNIX_System_V:4.0:*) + echo m68k-unknown-sysv4 + exit ;; + *:[Aa]miga[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-amigaos + exit ;; + *:[Mm]orph[Oo][Ss]:*:*) + echo ${UNAME_MACHINE}-unknown-morphos + exit ;; + *:OS/390:*:*) + echo i370-ibm-openedition + exit ;; + *:z/VM:*:*) + echo s390-ibm-zvmoe + exit ;; + *:OS400:*:*) + echo powerpc-ibm-os400 + exit ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit ;; + arm*:riscos:*:*|arm*:RISCOS:*:*) + echo arm-unknown-riscos + exit ;; + SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*) + echo hppa1.1-hitachi-hiuxmpp + exit ;; + Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) + # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit ;; + NILE*:*:*:dcosx) + echo pyramid-pyramid-svr4 + exit ;; + DRS?6000:unix:4.0:6*) + echo sparc-icl-nx6 + exit ;; + DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) + case `/usr/bin/uname -p` in + sparc) echo sparc-icl-nx7; exit ;; + esac ;; + s390x:SunOS:*:*) + echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4H:SunOS:5.*:*) + echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + echo i386-pc-auroraux${UNAME_RELEASE} + exit ;; + i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) + eval $set_cc_for_build + SUN_ARCH="i386" + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH="x86_64" + fi + fi + echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + sun4*:SunOS:*:*) + case "`/usr/bin/arch -k`" in + Series*|S4*) + UNAME_RELEASE=`uname -v` + ;; + esac + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit ;; + sun*:*:4.2BSD:*) + UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3 + case "`/bin/arch`" in + sun3) + echo m68k-sun-sunos${UNAME_RELEASE} + ;; + sun4) + echo sparc-sun-sunos${UNAME_RELEASE} + ;; + esac + exit ;; + aushp:SunOS:*:*) + echo sparc-auspex-sunos${UNAME_RELEASE} + exit ;; + # The situation for MiNT is a little confusing. The machine name + # can be virtually everything (everything which is not + # "atarist" or "atariste" at least should have a processor + # > m68000). The system name ranges from "MiNT" over "FreeMiNT" + # to the lowercase version "mint" (or "freemint"). Finally + # the system name "TOS" denotes a system which is actually not + # MiNT. But MiNT is downward compatible to TOS, so this should + # be no problem. + atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*) + echo m68k-atari-mint${UNAME_RELEASE} + exit ;; + milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*) + echo m68k-milan-mint${UNAME_RELEASE} + exit ;; + hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*) + echo m68k-hades-mint${UNAME_RELEASE} + exit ;; + *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) + echo m68k-unknown-mint${UNAME_RELEASE} + exit ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit ;; + powerpc:machten:*:*) + echo powerpc-apple-machten${UNAME_RELEASE} + exit ;; + RISC*:Mach:*:*) + echo mips-dec-mach_bsd4.3 + exit ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit ;; + 2020:CLIX:*:* | 2430:CLIX:*:*) + echo clipper-intergraph-clix${UNAME_RELEASE} + exit ;; + mips:*:*:UMIPS | mips:*:*:RISCos) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c +#ifdef __cplusplus +#include /* for printf() prototype */ + int main (int argc, char *argv[]) { +#else + int main (argc, argv) int argc; char *argv[]; { +#endif + #if defined (host_mips) && defined (MIPSEB) + #if defined (SYSTYPE_SYSV) + printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_SVR4) + printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); + #endif + #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) + printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); + #endif + #endif + exit (-1); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && + dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` && + SYSTEM_NAME=`$dummy $dummyarg` && + { echo "$SYSTEM_NAME"; exit; } + echo mips-mips-riscos${UNAME_RELEASE} + exit ;; + Motorola:PowerMAX_OS:*:*) + echo powerpc-motorola-powermax + exit ;; + Motorola:*:4.3:PL8-*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*) + echo powerpc-harris-powermax + exit ;; + Night_Hawk:Power_UNIX:*:*) + echo powerpc-harris-powerunix + exit ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit ;; + AViiON:dgux:*:*) + # DG/UX returns AViiON for all architectures + UNAME_PROCESSOR=`/usr/bin/uname -p` + if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ] + then + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \ + [ ${TARGET_BINARY_INTERFACE}x = x ] + then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + else + echo i586-dg-dgux${UNAME_RELEASE} + fi + exit ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit ;; + *:IRIX*:*:*) + echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` + exit ;; + ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. + echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id + exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + i*86:AIX:*:*) + echo i386-ibm-aix + exit ;; + ia64:AIX:*:*) + if [ -x /usr/bin/oslevel ] ; then + IBM_REV=`/usr/bin/oslevel` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${UNAME_MACHINE}-ibm-aix${IBM_REV} + exit ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` + then + echo "$SYSTEM_NAME" + else + echo rs6000-ibm-aix3.2.5 + fi + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit ;; + *:AIX:*:[4567]) + IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if [ -x /usr/bin/lslpp ] ; then + IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | + awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` + else + IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit ;; + ibmrt:4.4BSD:*|romp-ibm:BSD:*) + echo romp-ibm-bsd4.4 + exit ;; + ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and + echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to + exit ;; # report: romp-ibm BSD 4.3 + *:BOSX:*:*) + echo rs6000-bull-bosx + exit ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit ;; + 9000/[34678]??:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/[678][0-9][0-9]) + if [ -x /usr/bin/getconf ]; then + sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null` + sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null` + case "${sc_cpu_version}" in + 523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0 + 528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1 + 532) # CPU_PA_RISC2_0 + case "${sc_kernel_bits}" in + 32) HP_ARCH="hppa2.0n" ;; + 64) HP_ARCH="hppa2.0w" ;; + '') HP_ARCH="hppa2.0" ;; # HP-UX 10.20 + esac ;; + esac + fi + if [ "${HP_ARCH}" = "" ]; then + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + + #define _HPUX_SOURCE + #include + #include + + int main () + { + #if defined(_SC_KERNEL_BITS) + long bits = sysconf(_SC_KERNEL_BITS); + #endif + long cpu = sysconf (_SC_CPU_VERSION); + + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1"); break; + case CPU_PA_RISC2_0: + #if defined(_SC_KERNEL_BITS) + switch (bits) + { + case 64: puts ("hppa2.0w"); break; + case 32: puts ("hppa2.0n"); break; + default: puts ("hppa2.0"); break; + } break; + #else /* !defined(_SC_KERNEL_BITS) */ + puts ("hppa2.0"); break; + #endif + default: puts ("hppa1.0"); break; + } + exit (0); + } +EOF + (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy` + test -z "$HP_ARCH" && HP_ARCH=hppa + fi ;; + esac + if [ ${HP_ARCH} = "hppa2.0w" ] + then + eval $set_cc_for_build + + # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating + # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler + # generating 64-bit code. GNU and HP use different nomenclature: + # + # $ CC_FOR_BUILD=cc ./config.guess + # => hppa2.0w-hp-hpux11.23 + # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess + # => hppa64-hp-hpux11.23 + + if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | + grep -q __LP64__ + then + HP_ARCH="hppa2.0w" + else + HP_ARCH="hppa64" + fi + fi + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit ;; + ia64:HP-UX:*:*) + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ia64-hp-hpux${HPUX_REV} + exit ;; + 3050*:HI-UX:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #include + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` && + { echo "$SYSTEM_NAME"; exit; } + echo unknown-hitachi-hiuxwe2 + exit ;; + 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit ;; + *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*) + echo hppa1.0-hp-mpeix + exit ;; + hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) + echo hppa1.1-hp-osf + exit ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit ;; + i*86:OSF1:*:*) + if [ -x /usr/sbin/sysversion ] ; then + echo ${UNAME_MACHINE}-unknown-osf1mk + else + echo ${UNAME_MACHINE}-unknown-osf1 + fi + exit ;; + parisc*:Lites*:*:*) + echo hppa1.1-hp-lites + exit ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit ;; + CRAY*Y-MP:*:*:*) + echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*[A-Z]90:*:*:*) + echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ + | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ + -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \ + -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*TS:*:*:*) + echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*T3E:*:*:*) + echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + CRAY*SV1:*:*:*) + echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + *:UNICOS/mp:*:*) + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + exit ;; + F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) + FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` + echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + 5000:UNIX_System_V:4.*:*) + FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'` + FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'` + echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" + exit ;; + i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*) + echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} + exit ;; + sparc*:BSD/OS:*:*) + echo sparc-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:BSD/OS:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit ;; + *:FreeBSD:*:*) + UNAME_PROCESSOR=`/usr/bin/uname -p` + case ${UNAME_PROCESSOR} in + amd64) + echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + *) + echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;; + esac + exit ;; + i*:CYGWIN*:*) + echo ${UNAME_MACHINE}-pc-cygwin + exit ;; + *:MINGW64*:*) + echo ${UNAME_MACHINE}-pc-mingw64 + exit ;; + *:MINGW*:*) + echo ${UNAME_MACHINE}-pc-mingw32 + exit ;; + *:MSYS*:*) + echo ${UNAME_MACHINE}-pc-msys + exit ;; + i*:windows32*:*) + # uname -m includes "-pc" on this system. + echo ${UNAME_MACHINE}-mingw32 + exit ;; + i*:PW*:*) + echo ${UNAME_MACHINE}-pc-pw32 + exit ;; + *:Interix*:*) + case ${UNAME_MACHINE} in + x86) + echo i586-pc-interix${UNAME_RELEASE} + exit ;; + authenticamd | genuineintel | EM64T) + echo x86_64-unknown-interix${UNAME_RELEASE} + exit ;; + IA64) + echo ia64-unknown-interix${UNAME_RELEASE} + exit ;; + esac ;; + [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) + echo i${UNAME_MACHINE}-pc-mks + exit ;; + 8664:Windows_NT:*) + echo x86_64-pc-mks + exit ;; + i*:Windows_NT*:* | Pentium*:Windows_NT*:*) + # How do we know it's Interix rather than the generic POSIX subsystem? + # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we + # UNAME_MACHINE based on the output of uname instead of i386? + echo i586-pc-interix + exit ;; + i*:UWIN*:*) + echo ${UNAME_MACHINE}-pc-uwin + exit ;; + amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) + echo x86_64-unknown-cygwin + exit ;; + p*:CYGWIN*:*) + echo powerpcle-unknown-cygwin + exit ;; + prep*:SunOS:5.*:*) + echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; + *:GNU:*:*) + # the GNU system + echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit ;; + *:GNU/*:*:*) + # other systems with GNU libc and userland + echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC} + exit ;; + i*86:Minix:*:*) + echo ${UNAME_MACHINE}-pc-minix + exit ;; + aarch64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + aarch64_be:Linux:*:*) + UNAME_MACHINE=aarch64_be + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC="gnulibc1" ; fi + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + arc:Linux:*:* | arceb:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + arm*:Linux:*:*) + eval $set_cc_for_build + if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_EABI__ + then + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + else + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi + else + echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf + fi + fi + exit ;; + avr32*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + cris:Linux:*:*) + echo ${UNAME_MACHINE}-axis-linux-${LIBC} + exit ;; + crisv32:Linux:*:*) + echo ${UNAME_MACHINE}-axis-linux-${LIBC} + exit ;; + e2k:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + frv:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + hexagon:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + i*86:Linux:*:*) + echo ${UNAME_MACHINE}-pc-linux-${LIBC} + exit ;; + ia64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + m68*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + mips:Linux:*:* | mips64:Linux:*:*) + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #undef CPU + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) + CPU=${UNAME_MACHINE}el + #else + #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) + CPU=${UNAME_MACHINE} + #else + CPU= + #endif + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` + test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; } + ;; + openrisc*:Linux:*:*) + echo or1k-unknown-linux-${LIBC} + exit ;; + or32:Linux:*:* | or1k*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + padre:Linux:*:*) + echo sparc-unknown-linux-${LIBC} + exit ;; + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-${LIBC} + exit ;; + parisc:Linux:*:* | hppa:Linux:*:*) + # Look for CPU level + case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + PA7*) echo hppa1.1-unknown-linux-${LIBC} ;; + PA8*) echo hppa2.0-unknown-linux-${LIBC} ;; + *) echo hppa-unknown-linux-${LIBC} ;; + esac + exit ;; + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-${LIBC} + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-${LIBC} + exit ;; + ppc64le:Linux:*:*) + echo powerpc64le-unknown-linux-${LIBC} + exit ;; + ppcle:Linux:*:*) + echo powerpcle-unknown-linux-${LIBC} + exit ;; + s390:Linux:*:* | s390x:Linux:*:*) + echo ${UNAME_MACHINE}-ibm-linux-${LIBC} + exit ;; + sh64*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + sh*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + sparc:Linux:*:* | sparc64:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + tile*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + vax:Linux:*:*) + echo ${UNAME_MACHINE}-dec-linux-${LIBC} + exit ;; + x86_64:Linux:*:*) + echo ${UNAME_MACHINE}-pc-linux-${LIBC} + exit ;; + xtensa*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-${LIBC} + exit ;; + i*86:DYNIX/ptx:4*:*) + # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. + # earlier versions are messed up and put the nodename in both + # sysname and nodename. + echo i386-sequent-sysv4 + exit ;; + i*86:UNIX_SV:4.2MP:2.*) + # Unixware is an offshoot of SVR4, but it has its own version + # number series starting with 2... + # I am not positive that other SVR4 systems won't match this, + # I just have to hope. -- rms. + # Use sysv4.2uw... so that sysv4* matches it. + echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION} + exit ;; + i*86:OS/2:*:*) + # If we were able to find `uname', then EMX Unix compatibility + # is probably installed. + echo ${UNAME_MACHINE}-pc-os2-emx + exit ;; + i*86:XTS-300:*:STOP) + echo ${UNAME_MACHINE}-unknown-stop + exit ;; + i*86:atheos:*:*) + echo ${UNAME_MACHINE}-unknown-atheos + exit ;; + i*86:syllable:*:*) + echo ${UNAME_MACHINE}-pc-syllable + exit ;; + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) + echo i386-unknown-lynxos${UNAME_RELEASE} + exit ;; + i*86:*DOS:*:*) + echo ${UNAME_MACHINE}-pc-msdosdjgpp + exit ;; + i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*) + UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'` + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL} + else + echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL} + fi + exit ;; + i*86:*:5:[678]*) + # UnixWare 7.x, OpenUNIX and OpenServer 6. + case `/bin/uname -X | grep "^Machine"` in + *486*) UNAME_MACHINE=i486 ;; + *Pentium) UNAME_MACHINE=i586 ;; + *Pent*|*Celeron) UNAME_MACHINE=i686 ;; + esac + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION} + exit ;; + i*86:*:3.2:*) + if test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 + (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ + && UNAME_MACHINE=i586 + (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \ + && UNAME_MACHINE=i686 + (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \ + && UNAME_MACHINE=i686 + echo ${UNAME_MACHINE}-pc-sco$UNAME_REL + else + echo ${UNAME_MACHINE}-pc-sysv32 + fi + exit ;; + pc:*:*:*) + # Left here for compatibility: + # uname -m prints for DJGPP always 'pc', but it prints nothing about + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configury will decide that + # this is a cross-build. + echo i586-pc-msdosdjgpp + exit ;; + Intel:Mach:3*:*) + echo i386-pc-mach3 + exit ;; + paragon:*:*:*) + echo i860-intel-osf1 + exit ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit ;; + mc68k:UNIX:SYSTEM5:3.51m) + echo m68k-convergent-sysv + exit ;; + M680?0:D-NIX:5.3:*) + echo m68k-diab-dnix + exit ;; + M68*:*:R3V[5678]*:*) + test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;; + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) + OS_REL='' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; + m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) + echo m68k-unknown-lynxos${UNAME_RELEASE} + exit ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit ;; + TSUNAMI:LynxOS:2.*:*) + echo sparc-unknown-lynxos${UNAME_RELEASE} + exit ;; + rs6000:LynxOS:2.*:*) + echo rs6000-unknown-lynxos${UNAME_RELEASE} + exit ;; + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) + echo powerpc-unknown-lynxos${UNAME_RELEASE} + exit ;; + SM[BE]S:UNIX_SV:*:*) + echo mips-dde-sysv${UNAME_RELEASE} + exit ;; + RM*:ReliantUNIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit ;; + PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort + # says + echo i586-unisys-sysv4 + exit ;; + *:UNIX_System_V:4*:FTX*) + # From Gerald Hewes . + # How about differentiating between stratus architectures? -djm + echo hppa1.1-stratus-sysv4 + exit ;; + *:*:*:FTX*) + # From seanf@swdc.stratus.com. + echo i860-stratus-sysv4 + exit ;; + i*86:VOS:*:*) + # From Paul.Green@stratus.com. + echo ${UNAME_MACHINE}-stratus-vos + exit ;; + *:VOS:*:*) + # From Paul.Green@stratus.com. + echo hppa1.1-stratus-vos + exit ;; + mc68*:A/UX:*:*) + echo m68k-apple-aux${UNAME_RELEASE} + exit ;; + news*:NEWS-OS:6*:*) + echo mips-sony-newsos6 + exit ;; + R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) + if [ -d /usr/nec ]; then + echo mips-nec-sysv${UNAME_RELEASE} + else + echo mips-unknown-sysv${UNAME_RELEASE} + fi + exit ;; + BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only. + echo powerpc-be-beos + exit ;; + BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only. + echo powerpc-apple-beos + exit ;; + BePC:BeOS:*:*) # BeOS running on Intel PC compatible. + echo i586-pc-beos + exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; + x86_64:Haiku:*:*) + echo x86_64-unknown-haiku + exit ;; + SX-4:SUPER-UX:*:*) + echo sx4-nec-superux${UNAME_RELEASE} + exit ;; + SX-5:SUPER-UX:*:*) + echo sx5-nec-superux${UNAME_RELEASE} + exit ;; + SX-6:SUPER-UX:*:*) + echo sx6-nec-superux${UNAME_RELEASE} + exit ;; + SX-7:SUPER-UX:*:*) + echo sx7-nec-superux${UNAME_RELEASE} + exit ;; + SX-8:SUPER-UX:*:*) + echo sx8-nec-superux${UNAME_RELEASE} + exit ;; + SX-8R:SUPER-UX:*:*) + echo sx8r-nec-superux${UNAME_RELEASE} + exit ;; + Power*:Rhapsody:*:*) + echo powerpc-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Rhapsody:*:*) + echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} + exit ;; + *:Darwin:*:*) + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + eval $set_cc_for_build + if test "$UNAME_PROCESSOR" = unknown ; then + UNAME_PROCESSOR=powerpc + fi + if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + case $UNAME_PROCESSOR in + i386) UNAME_PROCESSOR=x86_64 ;; + powerpc) UNAME_PROCESSOR=powerpc64 ;; + esac + fi + fi + elif test "$UNAME_PROCESSOR" = i386 ; then + # Avoid executing cc on OS X 10.9, as it ships with a stub + # that puts up a graphical alert prompting to install + # developer tools. Any system running Mac OS X 10.7 or + # later (Darwin 11 and later) is required to have a 64-bit + # processor. This is not true of the ARM version of Darwin + # that Apple uses in portable devices. + UNAME_PROCESSOR=x86_64 + fi + echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} + exit ;; + *:procnto*:*:* | *:QNX:[0123456789]*:*) + UNAME_PROCESSOR=`uname -p` + if test "$UNAME_PROCESSOR" = "x86"; then + UNAME_PROCESSOR=i386 + UNAME_MACHINE=pc + fi + echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE} + exit ;; + *:QNX:*:4*) + echo i386-pc-qnx + exit ;; + NEO-?:NONSTOP_KERNEL:*:*) + echo neo-tandem-nsk${UNAME_RELEASE} + exit ;; + NSE-*:NONSTOP_KERNEL:*:*) + echo nse-tandem-nsk${UNAME_RELEASE} + exit ;; + NSR-?:NONSTOP_KERNEL:*:*) + echo nsr-tandem-nsk${UNAME_RELEASE} + exit ;; + *:NonStop-UX:*:*) + echo mips-compaq-nonstopux + exit ;; + BS2000:POSIX*:*:*) + echo bs2000-siemens-sysv + exit ;; + DS/*:UNIX_System_V:*:*) + echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE} + exit ;; + *:Plan9:*:*) + # "uname -m" is not consistent, so use $cputype instead. 386 + # is converted to i386 for consistency with other x86 + # operating systems. + if test "$cputype" = "386"; then + UNAME_MACHINE=i386 + else + UNAME_MACHINE="$cputype" + fi + echo ${UNAME_MACHINE}-unknown-plan9 + exit ;; + *:TOPS-10:*:*) + echo pdp10-unknown-tops10 + exit ;; + *:TENEX:*:*) + echo pdp10-unknown-tenex + exit ;; + KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*) + echo pdp10-dec-tops20 + exit ;; + XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*) + echo pdp10-xkl-tops20 + exit ;; + *:TOPS-20:*:*) + echo pdp10-unknown-tops20 + exit ;; + *:ITS:*:*) + echo pdp10-unknown-its + exit ;; + SEI:*:*:SEIUX) + echo mips-sei-seiux${UNAME_RELEASE} + exit ;; + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms ; exit ;; + I*) echo ia64-dec-vms ; exit ;; + V*) echo vax-dec-vms ; exit ;; + esac ;; + *:XENIX:*:SysV) + echo i386-pc-xenix + exit ;; + i*86:skyos:*:*) + echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//' + exit ;; + i*86:rdos:*:*) + echo ${UNAME_MACHINE}-pc-rdos + exit ;; + i*86:AROS:*:*) + echo ${UNAME_MACHINE}-pc-aros + exit ;; + x86_64:VMkernel:*:*) + echo ${UNAME_MACHINE}-unknown-esx + exit ;; +esac + +cat >&2 < in order to provide the needed +information to handle your system. + +config.guess timestamp = $timestamp + +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null` + +hostinfo = `(hostinfo) 2>/dev/null` +/bin/universe = `(/bin/universe) 2>/dev/null` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` +/bin/arch = `(/bin/arch) 2>/dev/null` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` + +UNAME_MACHINE = ${UNAME_MACHINE} +UNAME_RELEASE = ${UNAME_RELEASE} +UNAME_SYSTEM = ${UNAME_SYSTEM} +UNAME_VERSION = ${UNAME_VERSION} +EOF + +exit 1 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/src/secp256k1/build-aux/config.sub b/src/secp256k1/build-aux/config.sub new file mode 100755 index 000000000..1acc966a3 --- /dev/null +++ b/src/secp256k1/build-aux/config.sub @@ -0,0 +1,1813 @@ +#! /bin/sh +# Configuration validation subroutine script. +# Copyright 1992-2015 Free Software Foundation, Inc. + +timestamp='2015-08-20' + +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, see . +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that +# program. This Exception is an additional permission under section 7 +# of the GNU General Public License, version 3 ("GPLv3"). + + +# Please send patches to . +# +# Configuration subroutine to validate and canonicalize a configuration type. +# Supply the specified configuration type as an argument. +# If it is invalid, we print an error message on stderr and exit with code 1. +# Otherwise, we print the canonical config type on stdout and succeed. + +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + +# This file is supposed to be the same for all GNU packages +# and recognize all the CPU types, system types and aliases +# that are meaningful with *any* GNU software. +# Each package is responsible for reporting which valid configurations +# it does not support. The user should be able to distinguish +# a failure to support a valid configuration from a meaningless +# configuration. + +# The goal of this file is to map all the various variations of a given +# machine specification into a single specification in the form: +# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM +# or in some cases, the newer four-part form: +# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM +# It is wrong to echo any other type of specification. + +me=`echo "$0" | sed -e 's,.*/,,'` + +usage="\ +Usage: $0 [OPTION] CPU-MFR-OPSYS + $0 [OPTION] ALIAS + +Canonicalize a configuration name. + +Operation modes: + -h, --help print this help, then exit + -t, --time-stamp print date of last modification, then exit + -v, --version print version number, then exit + +Report bugs and patches to ." + +version="\ +GNU config.sub ($timestamp) + +Copyright 1992-2015 Free Software Foundation, Inc. + +This is free software; see the source for copying conditions. There is NO +warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." + +help=" +Try \`$me --help' for more information." + +# Parse command line +while test $# -gt 0 ; do + case $1 in + --time-stamp | --time* | -t ) + echo "$timestamp" ; exit ;; + --version | -v ) + echo "$version" ; exit ;; + --help | --h* | -h ) + echo "$usage"; exit ;; + -- ) # Stop option processing + shift; break ;; + - ) # Use stdin as input. + break ;; + -* ) + echo "$me: invalid option $1$help" + exit 1 ;; + + *local*) + # First pass through any local machine types. + echo $1 + exit ;; + + * ) + break ;; + esac +done + +case $# in + 0) echo "$me: missing argument$help" >&2 + exit 1;; + 1) ;; + *) echo "$me: too many arguments$help" >&2 + exit 1;; +esac + +# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). +# Here we must recognize all the valid KERNEL-OS combinations. +maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` +case $maybe_os in + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ + linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ + kopensolaris*-gnu* | \ + storm-chaos* | os2-emx* | rtmk-nova*) + os=-$maybe_os + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` + ;; + android-linux) + os=-linux-android + basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown + ;; + *) + basic_machine=`echo $1 | sed 's/-[^-]*$//'` + if [ $basic_machine != $1 ] + then os=`echo $1 | sed 's/.*-/-/'` + else os=; fi + ;; +esac + +### Let's recognize common machines as not being operating systems so +### that things like config.sub decstation-3100 work. We also +### recognize some manufacturers as not being operating systems, so we +### can provide default operating systems below. +case $os in + -sun*os*) + # Prevent following clause from handling this invalid input. + ;; + -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ + -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ + -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ + -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ + -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ + -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ + -apple | -axis | -knuth | -cray | -microblaze*) + os= + basic_machine=$1 + ;; + -bluegene*) + os=-cnk + ;; + -sim | -cisco | -oki | -wec | -winbond) + os= + basic_machine=$1 + ;; + -scout) + ;; + -wrs) + os=-vxworks + basic_machine=$1 + ;; + -chorusos*) + os=-chorusos + basic_machine=$1 + ;; + -chorusrdb) + os=-chorusrdb + basic_machine=$1 + ;; + -hiux*) + os=-hiuxwe2 + ;; + -sco6) + os=-sco5v6 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5) + os=-sco3.2v5 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco4) + os=-sco3.2v4 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2.[4-9]*) + os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco3.2v[4-9]*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -sco*) + os=-sco3.2v2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -udk*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -isc) + os=-isc2.2 + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -clix*) + basic_machine=clipper-intergraph + ;; + -isc*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` + ;; + -lynx*178) + os=-lynxos178 + ;; + -lynx*5) + os=-lynxos5 + ;; + -lynx*) + os=-lynxos + ;; + -ptx*) + basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` + ;; + -windowsnt*) + os=`echo $os | sed -e 's/windowsnt/winnt/'` + ;; + -psos*) + os=-psos + ;; + -mint | -mint[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; +esac + +# Decode aliases for certain CPU-COMPANY combinations. +case $basic_machine in + # Recognize the basic CPU types without company name. + # Some are omitted here because they have special meanings below. + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arceb \ + | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \ + | avr | avr32 \ + | ba \ + | be32 | be64 \ + | bfin \ + | c4x | c8051 | clipper \ + | d10v | d30v | dlx | dsp16xx \ + | e2k | epiphany \ + | fido | fr30 | frv | ft32 \ + | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i860 | i960 | ia64 \ + | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ + | lm32 \ + | m32c | m32r | m32rle | m68000 | m68k | m88k \ + | maxq | mb | microblaze | microblazeel | mcore | mep | metag \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r6 | mipsisa32r6el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r6 | mipsisa64r6el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nios | nios2 | nios2eb | nios2el \ + | ns16k | ns32k \ + | open8 | or1k | or1knd | or32 \ + | pdp10 | pdp11 | pj | pjl \ + | powerpc | powerpc64 | powerpc64le | powerpcle \ + | pyramid \ + | riscv32 | riscv64 \ + | rl78 | rx \ + | score \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ + | spu \ + | tahoe | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ + | ubicom32 \ + | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \ + | visium \ + | we32k \ + | x86 | xc16x | xstormy16 | xtensa \ + | z8k | z80) + basic_machine=$basic_machine-unknown + ;; + c54x) + basic_machine=tic54x-unknown + ;; + c55x) + basic_machine=tic55x-unknown + ;; + c6x) + basic_machine=tic6x-unknown + ;; + leon|leon[3-9]) + basic_machine=sparc-$basic_machine + ;; + m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip) + basic_machine=$basic_machine-unknown + os=-none + ;; + m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) + ;; + ms1) + basic_machine=mt-unknown + ;; + + strongarm | thumb | xscale) + basic_machine=arm-unknown + ;; + xgate) + basic_machine=$basic_machine-unknown + os=-none + ;; + xscaleeb) + basic_machine=armeb-unknown + ;; + + xscaleel) + basic_machine=armel-unknown + ;; + + # We use `pc' rather than `unknown' + # because (1) that's what they normally are, and + # (2) the word "unknown" tends to confuse beginning users. + i*86 | x86_64) + basic_machine=$basic_machine-pc + ;; + # Object if more than one company name word. + *-*-*) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; + # Recognize the basic CPU types with company name. + 580-* \ + | a29k-* \ + | aarch64-* | aarch64_be-* \ + | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \ + | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ + | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \ + | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ + | avr-* | avr32-* \ + | ba-* \ + | be32-* | be64-* \ + | bfin-* | bs2000-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ + | c8051-* | clipper-* | craynv-* | cydra-* \ + | d10v-* | d30v-* | dlx-* \ + | e2k-* | elxsi-* \ + | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \ + | h8300-* | h8500-* \ + | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ + | hexagon-* \ + | i*86-* | i860-* | i960-* | ia64-* \ + | ip2k-* | iq2000-* \ + | k1om-* \ + | le32-* | le64-* \ + | lm32-* \ + | m32c-* | m32r-* | m32rle-* \ + | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ + | microblaze-* | microblazeel-* \ + | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ + | mips16-* \ + | mips64-* | mips64el-* \ + | mips64octeon-* | mips64octeonel-* \ + | mips64orion-* | mips64orionel-* \ + | mips64r5900-* | mips64r5900el-* \ + | mips64vr-* | mips64vrel-* \ + | mips64vr4100-* | mips64vr4100el-* \ + | mips64vr4300-* | mips64vr4300el-* \ + | mips64vr5000-* | mips64vr5000el-* \ + | mips64vr5900-* | mips64vr5900el-* \ + | mipsisa32-* | mipsisa32el-* \ + | mipsisa32r2-* | mipsisa32r2el-* \ + | mipsisa32r6-* | mipsisa32r6el-* \ + | mipsisa64-* | mipsisa64el-* \ + | mipsisa64r2-* | mipsisa64r2el-* \ + | mipsisa64r6-* | mipsisa64r6el-* \ + | mipsisa64sb1-* | mipsisa64sb1el-* \ + | mipsisa64sr71k-* | mipsisa64sr71kel-* \ + | mipsr5900-* | mipsr5900el-* \ + | mipstx39-* | mipstx39el-* \ + | mmix-* \ + | mt-* \ + | msp430-* \ + | nds32-* | nds32le-* | nds32be-* \ + | nios-* | nios2-* | nios2eb-* | nios2el-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ + | open8-* \ + | or1k*-* \ + | orion-* \ + | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ + | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \ + | pyramid-* \ + | riscv32-* | riscv64-* \ + | rl78-* | romp-* | rs6000-* | rx-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ + | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ + | sparclite-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \ + | tahoe-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tile*-* \ + | tron-* \ + | ubicom32-* \ + | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \ + | vax-* \ + | visium-* \ + | we32k-* \ + | x86-* | x86_64-* | xc16x-* | xps100-* \ + | xstormy16-* | xtensa*-* \ + | ymp-* \ + | z8k-* | z80-*) + ;; + # Recognize the basic CPU types without company name, with glob match. + xtensa*) + basic_machine=$basic_machine-unknown + ;; + # Recognize the various machine names and aliases which stand + # for a CPU type and a company and sometimes even an OS. + 386bsd) + basic_machine=i386-unknown + os=-bsd + ;; + 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) + basic_machine=m68000-att + ;; + 3b*) + basic_machine=we32k-att + ;; + a29khif) + basic_machine=a29k-amd + os=-udi + ;; + abacus) + basic_machine=abacus-unknown + ;; + adobe68k) + basic_machine=m68010-adobe + os=-scout + ;; + alliant | fx80) + basic_machine=fx80-alliant + ;; + altos | altos3068) + basic_machine=m68k-altos + ;; + am29k) + basic_machine=a29k-none + os=-bsd + ;; + amd64) + basic_machine=x86_64-pc + ;; + amd64-*) + basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + amdahl) + basic_machine=580-amdahl + os=-sysv + ;; + amiga | amiga-*) + basic_machine=m68k-unknown + ;; + amigaos | amigados) + basic_machine=m68k-unknown + os=-amigaos + ;; + amigaunix | amix) + basic_machine=m68k-unknown + os=-sysv4 + ;; + apollo68) + basic_machine=m68k-apollo + os=-sysv + ;; + apollo68bsd) + basic_machine=m68k-apollo + os=-bsd + ;; + aros) + basic_machine=i386-pc + os=-aros + ;; + asmjs) + basic_machine=asmjs-unknown + ;; + aux) + basic_machine=m68k-apple + os=-aux + ;; + balance) + basic_machine=ns32k-sequent + os=-dynix + ;; + blackfin) + basic_machine=bfin-unknown + os=-linux + ;; + blackfin-*) + basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + bluegene*) + basic_machine=powerpc-ibm + os=-cnk + ;; + c54x-*) + basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c55x-*) + basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c6x-*) + basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c90) + basic_machine=c90-cray + os=-unicos + ;; + cegcc) + basic_machine=arm-unknown + os=-cegcc + ;; + convex-c1) + basic_machine=c1-convex + os=-bsd + ;; + convex-c2) + basic_machine=c2-convex + os=-bsd + ;; + convex-c32) + basic_machine=c32-convex + os=-bsd + ;; + convex-c34) + basic_machine=c34-convex + os=-bsd + ;; + convex-c38) + basic_machine=c38-convex + os=-bsd + ;; + cray | j90) + basic_machine=j90-cray + os=-unicos + ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16 | cr16-*) + basic_machine=cr16-unknown + os=-elf + ;; + crds | unos) + basic_machine=m68k-crds + ;; + crisv32 | crisv32-* | etraxfs*) + basic_machine=crisv32-axis + ;; + cris | cris-* | etrax*) + basic_machine=cris-axis + ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; + da30 | da30-*) + basic_machine=m68k-da30 + ;; + decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) + basic_machine=mips-dec + ;; + decsystem10* | dec10*) + basic_machine=pdp10-dec + os=-tops10 + ;; + decsystem20* | dec20*) + basic_machine=pdp10-dec + os=-tops20 + ;; + delta | 3300 | motorola-3300 | motorola-delta \ + | 3300-motorola | delta-motorola) + basic_machine=m68k-motorola + ;; + delta88) + basic_machine=m88k-motorola + os=-sysv3 + ;; + dicos) + basic_machine=i686-pc + os=-dicos + ;; + djgpp) + basic_machine=i586-pc + os=-msdosdjgpp + ;; + dpx20 | dpx20-*) + basic_machine=rs6000-bull + os=-bosx + ;; + dpx2* | dpx2*-bull) + basic_machine=m68k-bull + os=-sysv3 + ;; + ebmon29k) + basic_machine=a29k-amd + os=-ebmon + ;; + elxsi) + basic_machine=elxsi-elxsi + os=-bsd + ;; + encore | umax | mmax) + basic_machine=ns32k-encore + ;; + es1800 | OSE68k | ose68k | ose | OSE) + basic_machine=m68k-ericsson + os=-ose + ;; + fx2800) + basic_machine=i860-alliant + ;; + genix) + basic_machine=ns32k-ns + ;; + gmicro) + basic_machine=tron-gmicro + os=-sysv + ;; + go32) + basic_machine=i386-pc + os=-go32 + ;; + h3050r* | hiux*) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + h8300hms) + basic_machine=h8300-hitachi + os=-hms + ;; + h8300xray) + basic_machine=h8300-hitachi + os=-xray + ;; + h8500hms) + basic_machine=h8500-hitachi + os=-hms + ;; + harris) + basic_machine=m88k-harris + os=-sysv3 + ;; + hp300-*) + basic_machine=m68k-hp + ;; + hp300bsd) + basic_machine=m68k-hp + os=-bsd + ;; + hp300hpux) + basic_machine=m68k-hp + os=-hpux + ;; + hp3k9[0-9][0-9] | hp9[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k2[0-9][0-9] | hp9k31[0-9]) + basic_machine=m68000-hp + ;; + hp9k3[2-9][0-9]) + basic_machine=m68k-hp + ;; + hp9k6[0-9][0-9] | hp6[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hp9k7[0-79][0-9] | hp7[0-79][0-9]) + basic_machine=hppa1.1-hp + ;; + hp9k78[0-9] | hp78[0-9]) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893) + # FIXME: really hppa2.0-hp + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][13679] | hp8[0-9][13679]) + basic_machine=hppa1.1-hp + ;; + hp9k8[0-9][0-9] | hp8[0-9][0-9]) + basic_machine=hppa1.0-hp + ;; + hppa-next) + os=-nextstep3 + ;; + hppaosf) + basic_machine=hppa1.1-hp + os=-osf + ;; + hppro) + basic_machine=hppa1.1-hp + os=-proelf + ;; + i370-ibm* | ibm*) + basic_machine=i370-ibm + ;; + i*86v32) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv32 + ;; + i*86v4*) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv4 + ;; + i*86v) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-sysv + ;; + i*86sol2) + basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` + os=-solaris2 + ;; + i386mach) + basic_machine=i386-mach + os=-mach + ;; + i386-vsta | vsta) + basic_machine=i386-unknown + os=-vsta + ;; + iris | iris4d) + basic_machine=mips-sgi + case $os in + -irix*) + ;; + *) + os=-irix4 + ;; + esac + ;; + isi68 | isi) + basic_machine=m68k-isi + os=-sysv + ;; + leon-*|leon[3-9]-*) + basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'` + ;; + m68knommu) + basic_machine=m68k-unknown + os=-linux + ;; + m68knommu-*) + basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + m88k-omron*) + basic_machine=m88k-omron + ;; + magnum | m3230) + basic_machine=mips-mips + os=-sysv + ;; + merlin) + basic_machine=ns32k-utek + os=-sysv + ;; + microblaze*) + basic_machine=microblaze-xilinx + ;; + mingw64) + basic_machine=x86_64-pc + os=-mingw64 + ;; + mingw32) + basic_machine=i686-pc + os=-mingw32 + ;; + mingw32ce) + basic_machine=arm-unknown + os=-mingw32ce + ;; + miniframe) + basic_machine=m68000-convergent + ;; + *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*) + basic_machine=m68k-atari + os=-mint + ;; + mips3*-*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` + ;; + mips3*) + basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown + ;; + monitor) + basic_machine=m68k-rom68k + os=-coff + ;; + morphos) + basic_machine=powerpc-unknown + os=-morphos + ;; + moxiebox) + basic_machine=moxie-unknown + os=-moxiebox + ;; + msdos) + basic_machine=i386-pc + os=-msdos + ;; + ms1-*) + basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'` + ;; + msys) + basic_machine=i686-pc + os=-msys + ;; + mvs) + basic_machine=i370-ibm + os=-mvs + ;; + nacl) + basic_machine=le32-unknown + os=-nacl + ;; + ncr3000) + basic_machine=i486-ncr + os=-sysv4 + ;; + netbsd386) + basic_machine=i386-unknown + os=-netbsd + ;; + netwinder) + basic_machine=armv4l-rebel + os=-linux + ;; + news | news700 | news800 | news900) + basic_machine=m68k-sony + os=-newsos + ;; + news1000) + basic_machine=m68030-sony + os=-newsos + ;; + news-3600 | risc-news) + basic_machine=mips-sony + os=-newsos + ;; + necv70) + basic_machine=v70-nec + os=-sysv + ;; + next | m*-next ) + basic_machine=m68k-next + case $os in + -nextstep* ) + ;; + -ns2*) + os=-nextstep2 + ;; + *) + os=-nextstep3 + ;; + esac + ;; + nh3000) + basic_machine=m68k-harris + os=-cxux + ;; + nh[45]000) + basic_machine=m88k-harris + os=-cxux + ;; + nindy960) + basic_machine=i960-intel + os=-nindy + ;; + mon960) + basic_machine=i960-intel + os=-mon960 + ;; + nonstopux) + basic_machine=mips-compaq + os=-nonstopux + ;; + np1) + basic_machine=np1-gould + ;; + neo-tandem) + basic_machine=neo-tandem + ;; + nse-tandem) + basic_machine=nse-tandem + ;; + nsr-tandem) + basic_machine=nsr-tandem + ;; + op50n-* | op60c-*) + basic_machine=hppa1.1-oki + os=-proelf + ;; + openrisc | openrisc-*) + basic_machine=or32-unknown + ;; + os400) + basic_machine=powerpc-ibm + os=-os400 + ;; + OSE68000 | ose68000) + basic_machine=m68000-ericsson + os=-ose + ;; + os68k) + basic_machine=m68k-none + os=-os68k + ;; + pa-hitachi) + basic_machine=hppa1.1-hitachi + os=-hiuxwe2 + ;; + paragon) + basic_machine=i860-intel + os=-osf + ;; + parisc) + basic_machine=hppa-unknown + os=-linux + ;; + parisc-*) + basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'` + os=-linux + ;; + pbd) + basic_machine=sparc-tti + ;; + pbb) + basic_machine=m68k-tti + ;; + pc532 | pc532-*) + basic_machine=ns32k-pc532 + ;; + pc98) + basic_machine=i386-pc + ;; + pc98-*) + basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium | p5 | k5 | k6 | nexgen | viac3) + basic_machine=i586-pc + ;; + pentiumpro | p6 | 6x86 | athlon | athlon_*) + basic_machine=i686-pc + ;; + pentiumii | pentium2 | pentiumiii | pentium3) + basic_machine=i686-pc + ;; + pentium4) + basic_machine=i786-pc + ;; + pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*) + basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumpro-* | p6-* | 6x86-* | athlon-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*) + basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pentium4-*) + basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + pn) + basic_machine=pn-gould + ;; + power) basic_machine=power-ibm + ;; + ppc | ppcbe) basic_machine=powerpc-unknown + ;; + ppc-* | ppcbe-*) + basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppcle | powerpclittle | ppc-le | powerpc-little) + basic_machine=powerpcle-unknown + ;; + ppcle-* | powerpclittle-*) + basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64) basic_machine=powerpc64-unknown + ;; + ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ppc64le | powerpc64little | ppc64-le | powerpc64-little) + basic_machine=powerpc64le-unknown + ;; + ppc64le-* | powerpc64little-*) + basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + ps2) + basic_machine=i386-ibm + ;; + pw32) + basic_machine=i586-unknown + os=-pw32 + ;; + rdos | rdos64) + basic_machine=x86_64-pc + os=-rdos + ;; + rdos32) + basic_machine=i386-pc + os=-rdos + ;; + rom68k) + basic_machine=m68k-rom68k + os=-coff + ;; + rm[46]00) + basic_machine=mips-siemens + ;; + rtpc | rtpc-*) + basic_machine=romp-ibm + ;; + s390 | s390-*) + basic_machine=s390-ibm + ;; + s390x | s390x-*) + basic_machine=s390x-ibm + ;; + sa29200) + basic_machine=a29k-amd + os=-udi + ;; + sb1) + basic_machine=mipsisa64sb1-unknown + ;; + sb1el) + basic_machine=mipsisa64sb1el-unknown + ;; + sde) + basic_machine=mipsisa32-sde + os=-elf + ;; + sei) + basic_machine=mips-sei + os=-seiux + ;; + sequent) + basic_machine=i386-sequent + ;; + sh) + basic_machine=sh-hitachi + os=-hms + ;; + sh5el) + basic_machine=sh5le-unknown + ;; + sh64) + basic_machine=sh64-unknown + ;; + sparclite-wrs | simso-wrs) + basic_machine=sparclite-wrs + os=-vxworks + ;; + sps7) + basic_machine=m68k-bull + os=-sysv2 + ;; + spur) + basic_machine=spur-unknown + ;; + st2000) + basic_machine=m68k-tandem + ;; + stratus) + basic_machine=i860-stratus + os=-sysv4 + ;; + strongarm-* | thumb-*) + basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + sun2) + basic_machine=m68000-sun + ;; + sun2os3) + basic_machine=m68000-sun + os=-sunos3 + ;; + sun2os4) + basic_machine=m68000-sun + os=-sunos4 + ;; + sun3os3) + basic_machine=m68k-sun + os=-sunos3 + ;; + sun3os4) + basic_machine=m68k-sun + os=-sunos4 + ;; + sun4os3) + basic_machine=sparc-sun + os=-sunos3 + ;; + sun4os4) + basic_machine=sparc-sun + os=-sunos4 + ;; + sun4sol2) + basic_machine=sparc-sun + os=-solaris2 + ;; + sun3 | sun3-*) + basic_machine=m68k-sun + ;; + sun4) + basic_machine=sparc-sun + ;; + sun386 | sun386i | roadrunner) + basic_machine=i386-sun + ;; + sv1) + basic_machine=sv1-cray + os=-unicos + ;; + symmetry) + basic_machine=i386-sequent + os=-dynix + ;; + t3e) + basic_machine=alphaev5-cray + os=-unicos + ;; + t90) + basic_machine=t90-cray + os=-unicos + ;; + tile*) + basic_machine=$basic_machine-unknown + os=-linux-gnu + ;; + tx39) + basic_machine=mipstx39-unknown + ;; + tx39el) + basic_machine=mipstx39el-unknown + ;; + toad1) + basic_machine=pdp10-xkl + os=-tops20 + ;; + tower | tower-32) + basic_machine=m68k-ncr + ;; + tpf) + basic_machine=s390x-ibm + os=-tpf + ;; + udi29k) + basic_machine=a29k-amd + os=-udi + ;; + ultra3) + basic_machine=a29k-nyu + os=-sym1 + ;; + v810 | necv810) + basic_machine=v810-nec + os=-none + ;; + vaxv) + basic_machine=vax-dec + os=-sysv + ;; + vms) + basic_machine=vax-dec + os=-vms + ;; + vpp*|vx|vx-*) + basic_machine=f301-fujitsu + ;; + vxworks960) + basic_machine=i960-wrs + os=-vxworks + ;; + vxworks68) + basic_machine=m68k-wrs + os=-vxworks + ;; + vxworks29k) + basic_machine=a29k-wrs + os=-vxworks + ;; + w65*) + basic_machine=w65-wdc + os=-none + ;; + w89k-*) + basic_machine=hppa1.1-winbond + os=-proelf + ;; + xbox) + basic_machine=i686-pc + os=-mingw32 + ;; + xps | xps100) + basic_machine=xps100-honeywell + ;; + xscale-* | xscalee[bl]-*) + basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'` + ;; + ymp) + basic_machine=ymp-cray + os=-unicos + ;; + z8k-*-coff) + basic_machine=z8k-unknown + os=-sim + ;; + z80-*-coff) + basic_machine=z80-unknown + os=-sim + ;; + none) + basic_machine=none-none + os=-none + ;; + +# Here we handle the default manufacturer of certain CPU types. It is in +# some cases the only manufacturer, in others, it is the most popular. + w89k) + basic_machine=hppa1.1-winbond + ;; + op50n) + basic_machine=hppa1.1-oki + ;; + op60c) + basic_machine=hppa1.1-oki + ;; + romp) + basic_machine=romp-ibm + ;; + mmix) + basic_machine=mmix-knuth + ;; + rs6000) + basic_machine=rs6000-ibm + ;; + vax) + basic_machine=vax-dec + ;; + pdp10) + # there are many clones, so DEC is not a safe bet + basic_machine=pdp10-unknown + ;; + pdp11) + basic_machine=pdp11-dec + ;; + we32k) + basic_machine=we32k-att + ;; + sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) + basic_machine=sh-unknown + ;; + sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) + basic_machine=sparc-sun + ;; + cydra) + basic_machine=cydra-cydrome + ;; + orion) + basic_machine=orion-highlevel + ;; + orion105) + basic_machine=clipper-highlevel + ;; + mac | mpw | mac-mpw) + basic_machine=m68k-apple + ;; + pmac | pmac-mpw) + basic_machine=powerpc-apple + ;; + *-unknown) + # Make sure to match an already-canonicalized machine name. + ;; + *) + echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 + exit 1 + ;; +esac + +# Here we canonicalize certain aliases for manufacturers. +case $basic_machine in + *-digital*) + basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` + ;; + *-commodore*) + basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` + ;; + *) + ;; +esac + +# Decode manufacturer-specific aliases for certain operating systems. + +if [ x"$os" != x"" ] +then +case $os in + # First match some system type aliases + # that might get confused with valid system types. + # -solaris* is a basic system type, with this one exception. + -auroraux) + os=-auroraux + ;; + -solaris1 | -solaris1.*) + os=`echo $os | sed -e 's|solaris1|sunos4|'` + ;; + -solaris) + os=-solaris2 + ;; + -svr4*) + os=-sysv4 + ;; + -unixware*) + os=-sysv4.2uw + ;; + -gnu/linux*) + os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` + ;; + # First accept the basic system types. + # The portable systems comes first. + # Each alternative MUST END IN A *, to match a version number. + # -sysv* is not here because it comes later, after sysvr4. + -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* | -plan9* \ + | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ + | -aos* | -aros* | -cloudabi* | -sortix* \ + | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ + | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ + | -bitrig* | -openbsd* | -solidbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ + | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ + | -chorusos* | -chorusrdb* | -cegcc* \ + | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ + | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-musl* | -linux-uclibc* \ + | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \ + | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ + | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ + | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ + | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ + | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ + | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*) + # Remember, each alternative MUST END IN *, to match a version number. + ;; + -qnx*) + case $basic_machine in + x86-* | i*86-*) + ;; + *) + os=-nto$os + ;; + esac + ;; + -nto-qnx*) + ;; + -nto*) + os=`echo $os | sed -e 's|nto|nto-qnx|'` + ;; + -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ + | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \ + | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) + ;; + -mac*) + os=`echo $os | sed -e 's|mac|macos|'` + ;; + -linux-dietlibc) + os=-linux-dietlibc + ;; + -linux*) + os=`echo $os | sed -e 's|linux|linux-gnu|'` + ;; + -sunos5*) + os=`echo $os | sed -e 's|sunos5|solaris2|'` + ;; + -sunos6*) + os=`echo $os | sed -e 's|sunos6|solaris3|'` + ;; + -opened*) + os=-openedition + ;; + -os400*) + os=-os400 + ;; + -wince*) + os=-wince + ;; + -osfrose*) + os=-osfrose + ;; + -osf*) + os=-osf + ;; + -utek*) + os=-bsd + ;; + -dynix*) + os=-bsd + ;; + -acis*) + os=-aos + ;; + -atheos*) + os=-atheos + ;; + -syllable*) + os=-syllable + ;; + -386bsd) + os=-bsd + ;; + -ctix* | -uts*) + os=-sysv + ;; + -nova*) + os=-rtmk-nova + ;; + -ns2 ) + os=-nextstep2 + ;; + -nsk*) + os=-nsk + ;; + # Preserve the version number of sinix5. + -sinix5.*) + os=`echo $os | sed -e 's|sinix|sysv|'` + ;; + -sinix*) + os=-sysv4 + ;; + -tpf*) + os=-tpf + ;; + -triton*) + os=-sysv3 + ;; + -oss*) + os=-sysv3 + ;; + -svr4) + os=-sysv4 + ;; + -svr3) + os=-sysv3 + ;; + -sysvr4) + os=-sysv4 + ;; + # This must come after -sysvr4. + -sysv*) + ;; + -ose*) + os=-ose + ;; + -es1800*) + os=-ose + ;; + -xenix) + os=-xenix + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + os=-mint + ;; + -aros*) + os=-aros + ;; + -zvmoe) + os=-zvmoe + ;; + -dicos*) + os=-dicos + ;; + -nacl*) + ;; + -none) + ;; + *) + # Get rid of the `-' at the beginning of $os. + os=`echo $os | sed 's/[^-]*-//'` + echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 + exit 1 + ;; +esac +else + +# Here we handle the default operating systems that come with various machines. +# The value should be what the vendor currently ships out the door with their +# machine or put another way, the most popular os provided with the machine. + +# Note that if you're going to try to match "-MANUFACTURER" here (say, +# "-sun"), then you have to tell the case statement up towards the top +# that MANUFACTURER isn't an operating system. Otherwise, code above +# will signal an error saying that MANUFACTURER isn't an operating +# system, and we'll never get to this point. + +case $basic_machine in + score-*) + os=-elf + ;; + spu-*) + os=-elf + ;; + *-acorn) + os=-riscix1.2 + ;; + arm*-rebel) + os=-linux + ;; + arm*-semi) + os=-aout + ;; + c4x-* | tic4x-*) + os=-coff + ;; + c8051-*) + os=-elf + ;; + hexagon-*) + os=-elf + ;; + tic54x-*) + os=-coff + ;; + tic55x-*) + os=-coff + ;; + tic6x-*) + os=-coff + ;; + # This must come before the *-dec entry. + pdp10-*) + os=-tops20 + ;; + pdp11-*) + os=-none + ;; + *-dec | vax-*) + os=-ultrix4.2 + ;; + m68*-apollo) + os=-domain + ;; + i386-sun) + os=-sunos4.0.2 + ;; + m68000-sun) + os=-sunos3 + ;; + m68*-cisco) + os=-aout + ;; + mep-*) + os=-elf + ;; + mips*-cisco) + os=-elf + ;; + mips*-*) + os=-elf + ;; + or32-*) + os=-coff + ;; + *-tti) # must be before sparc entry or we get the wrong os. + os=-sysv3 + ;; + sparc-* | *-sun) + os=-sunos4.1.1 + ;; + *-be) + os=-beos + ;; + *-haiku) + os=-haiku + ;; + *-ibm) + os=-aix + ;; + *-knuth) + os=-mmixware + ;; + *-wec) + os=-proelf + ;; + *-winbond) + os=-proelf + ;; + *-oki) + os=-proelf + ;; + *-hp) + os=-hpux + ;; + *-hitachi) + os=-hiux + ;; + i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) + os=-sysv + ;; + *-cbm) + os=-amigaos + ;; + *-dg) + os=-dgux + ;; + *-dolphin) + os=-sysv3 + ;; + m68k-ccur) + os=-rtu + ;; + m88k-omron*) + os=-luna + ;; + *-next ) + os=-nextstep + ;; + *-sequent) + os=-ptx + ;; + *-crds) + os=-unos + ;; + *-ns) + os=-genix + ;; + i370-*) + os=-mvs + ;; + *-next) + os=-nextstep3 + ;; + *-gould) + os=-sysv + ;; + *-highlevel) + os=-bsd + ;; + *-encore) + os=-bsd + ;; + *-sgi) + os=-irix + ;; + *-siemens) + os=-sysv4 + ;; + *-masscomp) + os=-rtu + ;; + f30[01]-fujitsu | f700-fujitsu) + os=-uxpv + ;; + *-rom68k) + os=-coff + ;; + *-*bug) + os=-coff + ;; + *-apple) + os=-macos + ;; + *-atari*) + os=-mint + ;; + *) + os=-none + ;; +esac +fi + +# Here we handle the case where we know the os, and the CPU type, but not the +# manufacturer. We pick the logical manufacturer. +vendor=unknown +case $basic_machine in + *-unknown) + case $os in + -riscix*) + vendor=acorn + ;; + -sunos*) + vendor=sun + ;; + -cnk*|-aix*) + vendor=ibm + ;; + -beos*) + vendor=be + ;; + -hpux*) + vendor=hp + ;; + -mpeix*) + vendor=hp + ;; + -hiux*) + vendor=hitachi + ;; + -unos*) + vendor=crds + ;; + -dgux*) + vendor=dg + ;; + -luna*) + vendor=omron + ;; + -genix*) + vendor=ns + ;; + -mvs* | -opened*) + vendor=ibm + ;; + -os400*) + vendor=ibm + ;; + -ptx*) + vendor=sequent + ;; + -tpf*) + vendor=ibm + ;; + -vxsim* | -vxworks* | -windiss*) + vendor=wrs + ;; + -aux*) + vendor=apple + ;; + -hms*) + vendor=hitachi + ;; + -mpw* | -macos*) + vendor=apple + ;; + -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*) + vendor=atari + ;; + -vos*) + vendor=stratus + ;; + esac + basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` + ;; +esac + +echo $basic_machine$os +exit + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "timestamp='" +# time-stamp-format: "%:y-%02m-%02d" +# time-stamp-end: "'" +# End: diff --git a/src/secp256k1/build-aux/depcomp b/src/secp256k1/build-aux/depcomp new file mode 100755 index 000000000..fc98710e2 --- /dev/null +++ b/src/secp256k1/build-aux/depcomp @@ -0,0 +1,791 @@ +#! /bin/sh +# depcomp - compile a program generating dependencies as side-effects + +scriptversion=2013-05-30.07; # UTC + +# Copyright (C) 1999-2014 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Alexandre Oliva . + +case $1 in + '') + echo "$0: No command. Try '$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: depcomp [--help] [--version] PROGRAM [ARGS] + +Run PROGRAMS ARGS to compile a file, generating dependencies +as side-effects. + +Environment variables: + depmode Dependency tracking mode. + source Source file read by 'PROGRAMS ARGS'. + object Object file output by 'PROGRAMS ARGS'. + DEPDIR directory where to store dependencies. + depfile Dependency file to output. + tmpdepfile Temporary file to use when outputting dependencies. + libtool Whether libtool is used (yes/no). + +Report bugs to . +EOF + exit $? + ;; + -v | --v*) + echo "depcomp $scriptversion" + exit $? + ;; +esac + +# Get the directory component of the given path, and save it in the +# global variables '$dir'. Note that this directory component will +# be either empty or ending with a '/' character. This is deliberate. +set_dir_from () +{ + case $1 in + */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; + *) dir=;; + esac +} + +# Get the suffix-stripped basename of the given path, and save it the +# global variable '$base'. +set_base_from () +{ + base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` +} + +# If no dependency file was actually created by the compiler invocation, +# we still have to create a dummy depfile, to avoid errors with the +# Makefile "include basename.Plo" scheme. +make_dummy_depfile () +{ + echo "#dummy" > "$depfile" +} + +# Factor out some common post-processing of the generated depfile. +# Requires the auxiliary global variable '$tmpdepfile' to be set. +aix_post_process_depfile () +{ + # If the compiler actually managed to produce a dependency file, + # post-process it. + if test -f "$tmpdepfile"; then + # Each line is of the form 'foo.o: dependency.h'. + # Do two passes, one to just change these to + # $object: dependency.h + # and one to simply output + # dependency.h: + # which is needed to avoid the deleted-header problem. + { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" + sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" + } > "$depfile" + rm -f "$tmpdepfile" + else + make_dummy_depfile + fi +} + +# A tabulation character. +tab=' ' +# A newline character. +nl=' +' +# Character ranges might be problematic outside the C locale. +# These definitions help. +upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ +lower=abcdefghijklmnopqrstuvwxyz +digits=0123456789 +alpha=${upper}${lower} + +if test -z "$depmode" || test -z "$source" || test -z "$object"; then + echo "depcomp: Variables source, object and depmode must be set" 1>&2 + exit 1 +fi + +# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. +depfile=${depfile-`echo "$object" | + sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} + +rm -f "$tmpdepfile" + +# Avoid interferences from the environment. +gccflag= dashmflag= + +# Some modes work just like other modes, but use different flags. We +# parameterize here, but still list the modes in the big case below, +# to make depend.m4 easier to write. Note that we *cannot* use a case +# here, because this file can only contain one case statement. +if test "$depmode" = hp; then + # HP compiler uses -M and no extra arg. + gccflag=-M + depmode=gcc +fi + +if test "$depmode" = dashXmstdout; then + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout +fi + +cygpath_u="cygpath -u -f -" +if test "$depmode" = msvcmsys; then + # This is just like msvisualcpp but w/o cygpath translation. + # Just convert the backslash-escaped backslashes to single forward + # slashes to satisfy depend.m4 + cygpath_u='sed s,\\\\,/,g' + depmode=msvisualcpp +fi + +if test "$depmode" = msvc7msys; then + # This is just like msvc7 but w/o cygpath translation. + # Just convert the backslash-escaped backslashes to single forward + # slashes to satisfy depend.m4 + cygpath_u='sed s,\\\\,/,g' + depmode=msvc7 +fi + +if test "$depmode" = xlc; then + # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. + gccflag=-qmakedep=gcc,-MF + depmode=gcc +fi + +case "$depmode" in +gcc3) +## gcc 3 implements dependency tracking that does exactly what +## we want. Yay! Note: for some reason libtool 1.4 doesn't like +## it if -MD -MP comes after the -MF stuff. Hmm. +## Unfortunately, FreeBSD c89 acceptance of flags depends upon +## the command line argument order; so add the flags where they +## appear in depend2.am. Note that the slowdown incurred here +## affects only configure: in makefiles, %FASTDEP% shortcuts this. + for arg + do + case $arg in + -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; + *) set fnord "$@" "$arg" ;; + esac + shift # fnord + shift # $arg + done + "$@" + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; + +gcc) +## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. +## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. +## (see the conditional assignment to $gccflag above). +## There are various ways to get dependency output from gcc. Here's +## why we pick this rather obscure method: +## - Don't want to use -MD because we'd like the dependencies to end +## up in a subdir. Having to rename by hand is ugly. +## (We might end up doing this anyway to support other compilers.) +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like +## -MM, not -M (despite what the docs say). Also, it might not be +## supported by the other compilers which use the 'gcc' depmode. +## - Using -M directly means running the compiler twice (even worse +## than renaming). + if test -z "$gccflag"; then + gccflag=-MD, + fi + "$@" -Wp,"$gccflag$tmpdepfile" + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + # The second -e expression handles DOS-style file names with drive + # letters. + sed -e 's/^[^:]*: / /' \ + -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" +## This next piece of magic avoids the "deleted header file" problem. +## The problem is that when a header file which appears in a .P file +## is deleted, the dependency causes make to die (because there is +## typically no way to rebuild the header). We avoid this by adding +## dummy dependencies for each header file. Too bad gcc doesn't do +## this for us directly. +## Some versions of gcc put a space before the ':'. On the theory +## that the space means something, we add a space to the output as +## well. hp depmode also adds that space, but also prefixes the VPATH +## to the object. Take care to not repeat it in the output. +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ + | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +sgi) + if test "$libtool" = yes; then + "$@" "-Wp,-MDupdate,$tmpdepfile" + else + "$@" -MDupdate "$tmpdepfile" + fi + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files + echo "$object : \\" > "$depfile" + # Clip off the initial element (the dependent). Don't try to be + # clever and replace this with sed code, as IRIX sed won't handle + # lines with more than a fixed number of characters (4096 in + # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; + # the IRIX cc adds comments like '#:fec' to the end of the + # dependency line. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ + | tr "$nl" ' ' >> "$depfile" + echo >> "$depfile" + # The second pass generates a dummy entry for each header file. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> "$depfile" + else + make_dummy_depfile + fi + rm -f "$tmpdepfile" + ;; + +xlc) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +aix) + # The C for AIX Compiler uses -M and outputs the dependencies + # in a .u file. In older versions, this file always lives in the + # current directory. Also, the AIX compiler puts '$object:' at the + # start of each line; $object doesn't have directory information. + # Version 6 uses the directory in both cases. + set_dir_from "$object" + set_base_from "$object" + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.u + tmpdepfile2=$base.u + tmpdepfile3=$dir.libs/$base.u + "$@" -Wc,-M + else + tmpdepfile1=$dir$base.u + tmpdepfile2=$dir$base.u + tmpdepfile3=$dir$base.u + "$@" -M + fi + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + do + test -f "$tmpdepfile" && break + done + aix_post_process_depfile + ;; + +tcc) + # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 + # FIXME: That version still under development at the moment of writing. + # Make that this statement remains true also for stable, released + # versions. + # It will wrap lines (doesn't matter whether long or short) with a + # trailing '\', as in: + # + # foo.o : \ + # foo.c \ + # foo.h \ + # + # It will put a trailing '\' even on the last line, and will use leading + # spaces rather than leading tabs (at least since its commit 0394caf7 + # "Emit spaces for -MD"). + "$@" -MD -MF "$tmpdepfile" + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. + # We have to change lines of the first kind to '$object: \'. + sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" + # And for each line of the second kind, we have to emit a 'dep.h:' + # dummy dependency, to avoid the deleted-header problem. + sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" + rm -f "$tmpdepfile" + ;; + +## The order of this option in the case statement is important, since the +## shell code in configure will try each of these formats in the order +## listed in this file. A plain '-MD' option would be understood by many +## compilers, so we must ensure this comes after the gcc and icc options. +pgcc) + # Portland's C compiler understands '-MD'. + # Will always output deps to 'file.d' where file is the root name of the + # source file under compilation, even if file resides in a subdirectory. + # The object file name does not affect the name of the '.d' file. + # pgcc 10.2 will output + # foo.o: sub/foo.c sub/foo.h + # and will wrap long lines using '\' : + # foo.o: sub/foo.c ... \ + # sub/foo.h ... \ + # ... + set_dir_from "$object" + # Use the source, not the object, to determine the base name, since + # that's sadly what pgcc will do too. + set_base_from "$source" + tmpdepfile=$base.d + + # For projects that build the same source file twice into different object + # files, the pgcc approach of using the *source* file root name can cause + # problems in parallel builds. Use a locking strategy to avoid stomping on + # the same $tmpdepfile. + lockdir=$base.d-lock + trap " + echo '$0: caught signal, cleaning up...' >&2 + rmdir '$lockdir' + exit 1 + " 1 2 13 15 + numtries=100 + i=$numtries + while test $i -gt 0; do + # mkdir is a portable test-and-set. + if mkdir "$lockdir" 2>/dev/null; then + # This process acquired the lock. + "$@" -MD + stat=$? + # Release the lock. + rmdir "$lockdir" + break + else + # If the lock is being held by a different process, wait + # until the winning process is done or we timeout. + while test -d "$lockdir" && test $i -gt 0; do + sleep 1 + i=`expr $i - 1` + done + fi + i=`expr $i - 1` + done + trap - 1 2 13 15 + if test $i -le 0; then + echo "$0: failed to acquire lock after $numtries attempts" >&2 + echo "$0: check lockdir '$lockdir'" >&2 + exit 1 + fi + + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each line is of the form `foo.o: dependent.h', + # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ + | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp2) + # The "hp" stanza above does not work with aCC (C++) and HP's ia64 + # compilers, which have integrated preprocessors. The correct option + # to use with these is +Maked; it writes dependencies to a file named + # 'foo.d', which lands next to the object file, wherever that + # happens to be. + # Much of this is similar to the tru64 case; see comments there. + set_dir_from "$object" + set_base_from "$object" + if test "$libtool" = yes; then + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir.libs/$base.d + "$@" -Wc,+Maked + else + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir$base.d + "$@" +Maked + fi + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile1" "$tmpdepfile2" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" + # Add 'dependent.h:' lines. + sed -ne '2,${ + s/^ *// + s/ \\*$// + s/$/:/ + p + }' "$tmpdepfile" >> "$depfile" + else + make_dummy_depfile + fi + rm -f "$tmpdepfile" "$tmpdepfile2" + ;; + +tru64) + # The Tru64 compiler uses -MD to generate dependencies as a side + # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in 'foo.d' instead, so we check for that too. + # Subdirectories are respected. + set_dir_from "$object" + set_base_from "$object" + + if test "$libtool" = yes; then + # Libtool generates 2 separate objects for the 2 libraries. These + # two compilations output dependencies in $dir.libs/$base.o.d and + # in $dir$base.o.d. We have to check for both files, because + # one of the two compilations can be disabled. We should prefer + # $dir$base.o.d over $dir.libs/$base.o.d because the latter is + # automatically cleaned when .libs/ is deleted, while ignoring + # the former would cause a distcleancheck panic. + tmpdepfile1=$dir$base.o.d # libtool 1.5 + tmpdepfile2=$dir.libs/$base.o.d # Likewise. + tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 + "$@" -Wc,-MD + else + tmpdepfile1=$dir$base.d + tmpdepfile2=$dir$base.d + tmpdepfile3=$dir$base.d + "$@" -MD + fi + + stat=$? + if test $stat -ne 0; then + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" + do + test -f "$tmpdepfile" && break + done + # Same post-processing that is required for AIX mode. + aix_post_process_depfile + ;; + +msvc7) + if test "$libtool" = yes; then + showIncludes=-Wc,-showIncludes + else + showIncludes=-showIncludes + fi + "$@" $showIncludes > "$tmpdepfile" + stat=$? + grep -v '^Note: including file: ' "$tmpdepfile" + if test $stat -ne 0; then + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + # The first sed program below extracts the file names and escapes + # backslashes for cygpath. The second sed program outputs the file + # name when reading, but also accumulates all include files in the + # hold buffer in order to output them again at the end. This only + # works with sed implementations that can handle large buffers. + sed < "$tmpdepfile" -n ' +/^Note: including file: *\(.*\)/ { + s//\1/ + s/\\/\\\\/g + p +}' | $cygpath_u | sort -u | sed -n ' +s/ /\\ /g +s/\(.*\)/'"$tab"'\1 \\/p +s/.\(.*\) \\/\1:/ +H +$ { + s/.*/'"$tab"'/ + G + p +}' >> "$depfile" + echo >> "$depfile" # make sure the fragment doesn't end with a backslash + rm -f "$tmpdepfile" + ;; + +msvc7msys) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +#nosideeffect) + # This comment above is used by automake to tell side-effect + # dependency tracking mechanisms from slower ones. + +dashmstdout) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + + # Remove '-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + test -z "$dashmflag" && dashmflag=-M + # Require at least two characters before searching for ':' + # in the target name. This is to cope with DOS-style filenames: + # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. + "$@" $dashmflag | + sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this sed invocation + # correctly. Breaking it into two sed invocations is a workaround. + tr ' ' "$nl" < "$tmpdepfile" \ + | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ + | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +dashXmstdout) + # This case only exists to satisfy depend.m4. It is never actually + # run, as this mode is specially recognized in the preamble. + exit 1 + ;; + +makedepend) + "$@" || exit $? + # Remove any Libtool call + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + # X makedepend + shift + cleared=no eat=no + for arg + do + case $cleared in + no) + set ""; shift + cleared=yes ;; + esac + if test $eat = yes; then + eat=no + continue + fi + case "$arg" in + -D*|-I*) + set fnord "$@" "$arg"; shift ;; + # Strip any option that makedepend may not understand. Remove + # the object too, otherwise makedepend will parse it as a source file. + -arch) + eat=yes ;; + -*|$object) + ;; + *) + set fnord "$@" "$arg"; shift ;; + esac + done + obj_suffix=`echo "$object" | sed 's/^.*\././'` + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" + rm -f "$depfile" + # makedepend may prepend the VPATH from the source file name to the object. + # No need to regex-escape $object, excess matching of '.' is harmless. + sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process the last invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed '1,2d' "$tmpdepfile" \ + | tr ' ' "$nl" \ + | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ + | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" "$tmpdepfile".bak + ;; + +cpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + + # Remove '-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + "$@" -E \ + | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ + -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ + | sed '$ s: \\$::' > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + cat < "$tmpdepfile" >> "$depfile" + sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvisualcpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test "X$1" != 'X--mode=compile'; do + shift + done + shift + fi + + IFS=" " + for arg + do + case "$arg" in + -o) + shift + ;; + $object) + shift + ;; + "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") + set fnord "$@" + shift + shift + ;; + *) + set fnord "$@" "$arg" + shift + shift + ;; + esac + done + "$@" -E 2>/dev/null | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" + echo "$tab" >> "$depfile" + sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvcmsys) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +none) + exec "$@" + ;; + +*) + echo "Unknown depmode $depmode" 1>&2 + exit 1 + ;; +esac + +exit 0 + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/src/secp256k1/build-aux/install-sh b/src/secp256k1/build-aux/install-sh new file mode 100755 index 000000000..59990a104 --- /dev/null +++ b/src/secp256k1/build-aux/install-sh @@ -0,0 +1,508 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2014-09-12.12; # UTC + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# 'make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. + +tab=' ' +nl=' +' +IFS=" $tab$nl" + +# Set DOITPROG to "echo" to test this script. + +doit=${DOITPROG-} +doit_exec=${doit:-exec} + +# Put in absolute file names if you don't have them in your path; +# or use environment vars. + +chgrpprog=${CHGRPPROG-chgrp} +chmodprog=${CHMODPROG-chmod} +chownprog=${CHOWNPROG-chown} +cmpprog=${CMPPROG-cmp} +cpprog=${CPPROG-cp} +mkdirprog=${MKDIRPROG-mkdir} +mvprog=${MVPROG-mv} +rmprog=${RMPROG-rm} +stripprog=${STRIPPROG-strip} + +posix_mkdir= + +# Desired mode of installed file. +mode=0755 + +chgrpcmd= +chmodcmd=$chmodprog +chowncmd= +mvcmd=$mvprog +rmcmd="$rmprog -f" +stripcmd= + +src= +dst= +dir_arg= +dst_arg= + +copy_on_change=false +is_target_a_directory=possibly + +usage="\ +Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: + --help display this help and exit. + --version display version info and exit. + + -c (ignored) + -C install only if different (preserve the last data modification time) + -d create directories instead of installing files. + -g GROUP $chgrpprog installed files to GROUP. + -m MODE $chmodprog installed files to MODE. + -o USER $chownprog installed files to USER. + -s $stripprog installed files. + -t DIRECTORY install into DIRECTORY. + -T report an error if DSTFILE is a directory. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG + RMPROG STRIPPROG +" + +while test $# -ne 0; do + case $1 in + -c) ;; + + -C) copy_on_change=true;; + + -d) dir_arg=true;; + + -g) chgrpcmd="$chgrpprog $2" + shift;; + + --help) echo "$usage"; exit $?;; + + -m) mode=$2 + case $mode in + *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) + echo "$0: invalid mode: $mode" >&2 + exit 1;; + esac + shift;; + + -o) chowncmd="$chownprog $2" + shift;; + + -s) stripcmd=$stripprog;; + + -t) + is_target_a_directory=always + dst_arg=$2 + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + shift;; + + -T) is_target_a_directory=never;; + + --version) echo "$0 $scriptversion"; exit $?;; + + --) shift + break;; + + -*) echo "$0: invalid option: $1" >&2 + exit 1;; + + *) break;; + esac + shift +done + +# We allow the use of options -d and -T together, by making -d +# take the precedence; this is for compatibility with GNU install. + +if test -n "$dir_arg"; then + if test -n "$dst_arg"; then + echo "$0: target directory not allowed when installing a directory." >&2 + exit 1 + fi +fi + +if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then + # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dst_arg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dst_arg" + shift # fnord + fi + shift # arg + dst_arg=$arg + # Protect names problematic for 'test' and other utilities. + case $dst_arg in + -* | [=\(\)!]) dst_arg=./$dst_arg;; + esac + done +fi + +if test $# -eq 0; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call 'install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +if test -z "$dir_arg"; then + if test $# -gt 1 || test "$is_target_a_directory" = always; then + if test ! -d "$dst_arg"; then + echo "$0: $dst_arg: Is not a directory." >&2 + exit 1 + fi + fi +fi + +if test -z "$dir_arg"; then + do_exit='(exit $ret); exit $ret' + trap "ret=129; $do_exit" 1 + trap "ret=130; $do_exit" 2 + trap "ret=141; $do_exit" 13 + trap "ret=143; $do_exit" 15 + + # Set umask so as not to create temps with too-generous modes. + # However, 'strip' requires both read and write access to temps. + case $mode in + # Optimize common cases. + *644) cp_umask=133;; + *755) cp_umask=22;; + + *[0-7]) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw='% 200' + fi + cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; + *) + if test -z "$stripcmd"; then + u_plus_rw= + else + u_plus_rw=,u+rw + fi + cp_umask=$mode$u_plus_rw;; + esac +fi + +for src +do + # Protect names problematic for 'test' and other utilities. + case $src in + -* | [=\(\)!]) src=./$src;; + esac + + if test -n "$dir_arg"; then + dst=$src + dstdir=$dst + test -d "$dstdir" + dstdir_status=$? + else + + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dst_arg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + dst=$dst_arg + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test "$is_target_a_directory" = never; then + echo "$0: $dst_arg: Is a directory" >&2 + exit 1 + fi + dstdir=$dst + dst=$dstdir/`basename "$src"` + dstdir_status=0 + else + dstdir=`dirname "$dst"` + test -d "$dstdir" + dstdir_status=$? + fi + fi + + obsolete_mkdir_used=false + + if test $dstdir_status != 0; then + case $posix_mkdir in + '') + # Create intermediate dirs using mode 755 as modified by the umask. + # This is like FreeBSD 'install' as of 1997-10-28. + umask=`umask` + case $stripcmd.$umask in + # Optimize common cases. + *[2367][2367]) mkdir_umask=$umask;; + .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; + + *[0-7]) + mkdir_umask=`expr $umask + 22 \ + - $umask % 100 % 40 + $umask % 20 \ + - $umask % 10 % 4 + $umask % 2 + `;; + *) mkdir_umask=$umask,go-w;; + esac + + # With -d, create the new directory with the user-specified mode. + # Otherwise, rely on $mkdir_umask. + if test -n "$dir_arg"; then + mkdir_mode=-m$mode + else + mkdir_mode= + fi + + posix_mkdir=false + case $umask in + *[123567][0-7][0-7]) + # POSIX mkdir -p sets u+wx bits regardless of umask, which + # is incompatible with FreeBSD 'install' when (umask & 300) != 0. + ;; + *) + # $RANDOM is not portable (e.g. dash); use it when possible to + # lower collision chance + tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ + trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0 + + # As "mkdir -p" follows symlinks and we work in /tmp possibly; so + # create the $tmpdir first (and fail if unsuccessful) to make sure + # that nobody tries to guess the $tmpdir name. + if (umask $mkdir_umask && + $mkdirprog $mkdir_mode "$tmpdir" && + exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 + then + if test -z "$dir_arg" || { + # Check for POSIX incompatibilities with -m. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writable bit of parent directory when it shouldn't. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + test_tmpdir="$tmpdir/a" + ls_ld_tmpdir=`ls -ld "$test_tmpdir"` + case $ls_ld_tmpdir in + d????-?r-*) different_mode=700;; + d????-?--*) different_mode=755;; + *) false;; + esac && + $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { + ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` + test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" + } + } + then posix_mkdir=: + fi + rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" + else + # Remove any dirs left behind by ancient mkdir implementations. + rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null + fi + trap '' 0;; + esac;; + esac + + if + $posix_mkdir && ( + umask $mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" + ) + then : + else + + # The umask is ridiculous, or mkdir does not conform to POSIX, + # or it failed possibly due to a race condition. Create the + # directory the slow way, step by step, checking for races as we go. + + case $dstdir in + /*) prefix='/';; + [-=\(\)!]*) prefix='./';; + *) prefix='';; + esac + + oIFS=$IFS + IFS=/ + set -f + set fnord $dstdir + shift + set +f + IFS=$oIFS + + prefixes= + + for d + do + test X"$d" = X && continue + + prefix=$prefix$d + if test -d "$prefix"; then + prefixes= + else + if $posix_mkdir; then + (umask=$mkdir_umask && + $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break + # Don't fail if two instances are running concurrently. + test -d "$prefix" || exit 1 + else + case $prefix in + *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; + *) qprefix=$prefix;; + esac + prefixes="$prefixes '$qprefix'" + fi + fi + prefix=$prefix/ + done + + if test -n "$prefixes"; then + # Don't fail if two instances are running concurrently. + (umask $mkdir_umask && + eval "\$doit_exec \$mkdirprog $prefixes") || + test -d "$dstdir" || exit 1 + obsolete_mkdir_used=true + fi + fi + fi + + if test -n "$dir_arg"; then + { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && + { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || + test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 + else + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + + # Copy the file name to the temp name. + (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && + { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && + { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && + { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && + + # If -C, don't bother to copy if it wouldn't change the file. + if $copy_on_change && + old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && + new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && + set -f && + set X $old && old=:$2:$4:$5:$6 && + set X $new && new=:$2:$4:$5:$6 && + set +f && + test "$old" = "$new" && + $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 + then + rm -f "$dsttmp" + else + # Rename the file to the real destination. + $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || + + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + { + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + test ! -f "$dst" || + $doit $rmcmd -f "$dst" 2>/dev/null || + { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && + { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } + } || + { echo "$0: cannot unlink or rename $dst" >&2 + (exit 1); exit 1 + } + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dst" + } + fi || exit 1 + + trap '' 0 + fi +done + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/src/secp256k1/build-aux/m4/libtool.m4 b/src/secp256k1/build-aux/m4/libtool.m4 new file mode 100644 index 000000000..10ab2844c --- /dev/null +++ b/src/secp256k1/build-aux/m4/libtool.m4 @@ -0,0 +1,8388 @@ +# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*- +# +# Copyright (C) 1996-2001, 2003-2015 Free Software Foundation, Inc. +# Written by Gordon Matzigkeit, 1996 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +m4_define([_LT_COPYING], [dnl +# Copyright (C) 2014 Free Software Foundation, Inc. +# This is free software; see the source for copying conditions. There is NO +# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +# GNU Libtool is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of of the License, or +# (at your option) any later version. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program or library that is built +# using GNU Libtool, you may include this file under the same +# distribution terms that you use for the rest of that program. +# +# GNU Libtool is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +]) + +# serial 58 LT_INIT + + +# LT_PREREQ(VERSION) +# ------------------ +# Complain and exit if this libtool version is less that VERSION. +m4_defun([LT_PREREQ], +[m4_if(m4_version_compare(m4_defn([LT_PACKAGE_VERSION]), [$1]), -1, + [m4_default([$3], + [m4_fatal([Libtool version $1 or higher is required], + 63)])], + [$2])]) + + +# _LT_CHECK_BUILDDIR +# ------------------ +# Complain if the absolute build directory name contains unusual characters +m4_defun([_LT_CHECK_BUILDDIR], +[case `pwd` in + *\ * | *\ *) + AC_MSG_WARN([Libtool does not cope well with whitespace in `pwd`]) ;; +esac +]) + + +# LT_INIT([OPTIONS]) +# ------------------ +AC_DEFUN([LT_INIT], +[AC_PREREQ([2.62])dnl We use AC_PATH_PROGS_FEATURE_CHECK +AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl +AC_BEFORE([$0], [LT_LANG])dnl +AC_BEFORE([$0], [LT_OUTPUT])dnl +AC_BEFORE([$0], [LTDL_INIT])dnl +m4_require([_LT_CHECK_BUILDDIR])dnl + +dnl Autoconf doesn't catch unexpanded LT_ macros by default: +m4_pattern_forbid([^_?LT_[A-Z_]+$])dnl +m4_pattern_allow([^(_LT_EOF|LT_DLGLOBAL|LT_DLLAZY_OR_NOW|LT_MULTI_MODULE)$])dnl +dnl aclocal doesn't pull ltoptions.m4, ltsugar.m4, or ltversion.m4 +dnl unless we require an AC_DEFUNed macro: +AC_REQUIRE([LTOPTIONS_VERSION])dnl +AC_REQUIRE([LTSUGAR_VERSION])dnl +AC_REQUIRE([LTVERSION_VERSION])dnl +AC_REQUIRE([LTOBSOLETE_VERSION])dnl +m4_require([_LT_PROG_LTMAIN])dnl + +_LT_SHELL_INIT([SHELL=${CONFIG_SHELL-/bin/sh}]) + +dnl Parse OPTIONS +_LT_SET_OPTIONS([$0], [$1]) + +# This can be used to rebuild libtool when needed +LIBTOOL_DEPS=$ltmain + +# Always use our own libtool. +LIBTOOL='$(SHELL) $(top_builddir)/libtool' +AC_SUBST(LIBTOOL)dnl + +_LT_SETUP + +# Only expand once: +m4_define([LT_INIT]) +])# LT_INIT + +# Old names: +AU_ALIAS([AC_PROG_LIBTOOL], [LT_INIT]) +AU_ALIAS([AM_PROG_LIBTOOL], [LT_INIT]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_PROG_LIBTOOL], []) +dnl AC_DEFUN([AM_PROG_LIBTOOL], []) + + +# _LT_PREPARE_CC_BASENAME +# ----------------------- +m4_defun([_LT_PREPARE_CC_BASENAME], [ +# Calculate cc_basename. Skip known compiler wrappers and cross-prefix. +func_cc_basename () +{ + for cc_temp in @S|@*""; do + case $cc_temp in + compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;; + distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;; + \-*) ;; + *) break;; + esac + done + func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` +} +])# _LT_PREPARE_CC_BASENAME + + +# _LT_CC_BASENAME(CC) +# ------------------- +# It would be clearer to call AC_REQUIREs from _LT_PREPARE_CC_BASENAME, +# but that macro is also expanded into generated libtool script, which +# arranges for $SED and $ECHO to be set by different means. +m4_defun([_LT_CC_BASENAME], +[m4_require([_LT_PREPARE_CC_BASENAME])dnl +AC_REQUIRE([_LT_DECL_SED])dnl +AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl +func_cc_basename $1 +cc_basename=$func_cc_basename_result +]) + + +# _LT_FILEUTILS_DEFAULTS +# ---------------------- +# It is okay to use these file commands and assume they have been set +# sensibly after 'm4_require([_LT_FILEUTILS_DEFAULTS])'. +m4_defun([_LT_FILEUTILS_DEFAULTS], +[: ${CP="cp -f"} +: ${MV="mv -f"} +: ${RM="rm -f"} +])# _LT_FILEUTILS_DEFAULTS + + +# _LT_SETUP +# --------- +m4_defun([_LT_SETUP], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_REQUIRE([_LT_PREPARE_SED_QUOTE_VARS])dnl +AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH])dnl + +_LT_DECL([], [PATH_SEPARATOR], [1], [The PATH separator for the build system])dnl +dnl +_LT_DECL([], [host_alias], [0], [The host system])dnl +_LT_DECL([], [host], [0])dnl +_LT_DECL([], [host_os], [0])dnl +dnl +_LT_DECL([], [build_alias], [0], [The build system])dnl +_LT_DECL([], [build], [0])dnl +_LT_DECL([], [build_os], [0])dnl +dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([LT_PATH_LD])dnl +AC_REQUIRE([LT_PATH_NM])dnl +dnl +AC_REQUIRE([AC_PROG_LN_S])dnl +test -z "$LN_S" && LN_S="ln -s" +_LT_DECL([], [LN_S], [1], [Whether we need soft or hard links])dnl +dnl +AC_REQUIRE([LT_CMD_MAX_LEN])dnl +_LT_DECL([objext], [ac_objext], [0], [Object file suffix (normally "o")])dnl +_LT_DECL([], [exeext], [0], [Executable file suffix (normally "")])dnl +dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_CHECK_SHELL_FEATURES])dnl +m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl +m4_require([_LT_CMD_RELOAD])dnl +m4_require([_LT_CHECK_MAGIC_METHOD])dnl +m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl +m4_require([_LT_CMD_OLD_ARCHIVE])dnl +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl +m4_require([_LT_WITH_SYSROOT])dnl +m4_require([_LT_CMD_TRUNCATE])dnl + +_LT_CONFIG_LIBTOOL_INIT([ +# See if we are running on zsh, and set the options that allow our +# commands through without removal of \ escapes INIT. +if test -n "\${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST +fi +]) +if test -n "${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST +fi + +_LT_CHECK_OBJDIR + +m4_require([_LT_TAG_COMPILER])dnl + +case $host_os in +aix3*) + # AIX sometimes has problems with the GCC collect2 program. For some + # reason, if we set the COLLECT_NAMES environment variable, the problems + # vanish in a puff of smoke. + if test set != "${COLLECT_NAMES+set}"; then + COLLECT_NAMES= + export COLLECT_NAMES + fi + ;; +esac + +# Global variables: +ofile=libtool +can_build_shared=yes + +# All known linkers require a '.a' archive for static linking (except MSVC, +# which needs '.lib'). +libext=a + +with_gnu_ld=$lt_cv_prog_gnu_ld + +old_CC=$CC +old_CFLAGS=$CFLAGS + +# Set sane defaults for various variables +test -z "$CC" && CC=cc +test -z "$LTCC" && LTCC=$CC +test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS +test -z "$LD" && LD=ld +test -z "$ac_objext" && ac_objext=o + +_LT_CC_BASENAME([$compiler]) + +# Only perform the check for file, if the check method requires it +test -z "$MAGIC_CMD" && MAGIC_CMD=file +case $deplibs_check_method in +file_magic*) + if test "$file_magic_cmd" = '$MAGIC_CMD'; then + _LT_PATH_MAGIC + fi + ;; +esac + +# Use C for the default configuration in the libtool script +LT_SUPPORTED_TAG([CC]) +_LT_LANG_C_CONFIG +_LT_LANG_DEFAULT_CONFIG +_LT_CONFIG_COMMANDS +])# _LT_SETUP + + +# _LT_PREPARE_SED_QUOTE_VARS +# -------------------------- +# Define a few sed substitution that help us do robust quoting. +m4_defun([_LT_PREPARE_SED_QUOTE_VARS], +[# Backslashify metacharacters that are still active within +# double-quoted strings. +sed_quote_subst='s/\([["`$\\]]\)/\\\1/g' + +# Same as above, but do not quote variable references. +double_quote_subst='s/\([["`\\]]\)/\\\1/g' + +# Sed substitution to delay expansion of an escaped shell variable in a +# double_quote_subst'ed string. +delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g' + +# Sed substitution to delay expansion of an escaped single quote. +delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g' + +# Sed substitution to avoid accidental globbing in evaled expressions +no_glob_subst='s/\*/\\\*/g' +]) + +# _LT_PROG_LTMAIN +# --------------- +# Note that this code is called both from 'configure', and 'config.status' +# now that we use AC_CONFIG_COMMANDS to generate libtool. Notably, +# 'config.status' has no value for ac_aux_dir unless we are using Automake, +# so we pass a copy along to make sure it has a sensible value anyway. +m4_defun([_LT_PROG_LTMAIN], +[m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([ltmain.sh])])dnl +_LT_CONFIG_LIBTOOL_INIT([ac_aux_dir='$ac_aux_dir']) +ltmain=$ac_aux_dir/ltmain.sh +])# _LT_PROG_LTMAIN + + +## ------------------------------------- ## +## Accumulate code for creating libtool. ## +## ------------------------------------- ## + +# So that we can recreate a full libtool script including additional +# tags, we accumulate the chunks of code to send to AC_CONFIG_COMMANDS +# in macros and then make a single call at the end using the 'libtool' +# label. + + +# _LT_CONFIG_LIBTOOL_INIT([INIT-COMMANDS]) +# ---------------------------------------- +# Register INIT-COMMANDS to be passed to AC_CONFIG_COMMANDS later. +m4_define([_LT_CONFIG_LIBTOOL_INIT], +[m4_ifval([$1], + [m4_append([_LT_OUTPUT_LIBTOOL_INIT], + [$1 +])])]) + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_INIT]) + + +# _LT_CONFIG_LIBTOOL([COMMANDS]) +# ------------------------------ +# Register COMMANDS to be passed to AC_CONFIG_COMMANDS later. +m4_define([_LT_CONFIG_LIBTOOL], +[m4_ifval([$1], + [m4_append([_LT_OUTPUT_LIBTOOL_COMMANDS], + [$1 +])])]) + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS]) + + +# _LT_CONFIG_SAVE_COMMANDS([COMMANDS], [INIT_COMMANDS]) +# ----------------------------------------------------- +m4_defun([_LT_CONFIG_SAVE_COMMANDS], +[_LT_CONFIG_LIBTOOL([$1]) +_LT_CONFIG_LIBTOOL_INIT([$2]) +]) + + +# _LT_FORMAT_COMMENT([COMMENT]) +# ----------------------------- +# Add leading comment marks to the start of each line, and a trailing +# full-stop to the whole comment if one is not present already. +m4_define([_LT_FORMAT_COMMENT], +[m4_ifval([$1], [ +m4_bpatsubst([m4_bpatsubst([$1], [^ *], [# ])], + [['`$\]], [\\\&])]m4_bmatch([$1], [[!?.]$], [], [.]) +)]) + + + +## ------------------------ ## +## FIXME: Eliminate VARNAME ## +## ------------------------ ## + + +# _LT_DECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION], [IS-TAGGED?]) +# ------------------------------------------------------------------- +# CONFIGNAME is the name given to the value in the libtool script. +# VARNAME is the (base) name used in the configure script. +# VALUE may be 0, 1 or 2 for a computed quote escaped value based on +# VARNAME. Any other value will be used directly. +m4_define([_LT_DECL], +[lt_if_append_uniq([lt_decl_varnames], [$2], [, ], + [lt_dict_add_subkey([lt_decl_dict], [$2], [libtool_name], + [m4_ifval([$1], [$1], [$2])]) + lt_dict_add_subkey([lt_decl_dict], [$2], [value], [$3]) + m4_ifval([$4], + [lt_dict_add_subkey([lt_decl_dict], [$2], [description], [$4])]) + lt_dict_add_subkey([lt_decl_dict], [$2], + [tagged?], [m4_ifval([$5], [yes], [no])])]) +]) + + +# _LT_TAGDECL([CONFIGNAME], VARNAME, VALUE, [DESCRIPTION]) +# -------------------------------------------------------- +m4_define([_LT_TAGDECL], [_LT_DECL([$1], [$2], [$3], [$4], [yes])]) + + +# lt_decl_tag_varnames([SEPARATOR], [VARNAME1...]) +# ------------------------------------------------ +m4_define([lt_decl_tag_varnames], +[_lt_decl_filter([tagged?], [yes], $@)]) + + +# _lt_decl_filter(SUBKEY, VALUE, [SEPARATOR], [VARNAME1..]) +# --------------------------------------------------------- +m4_define([_lt_decl_filter], +[m4_case([$#], + [0], [m4_fatal([$0: too few arguments: $#])], + [1], [m4_fatal([$0: too few arguments: $#: $1])], + [2], [lt_dict_filter([lt_decl_dict], [$1], [$2], [], lt_decl_varnames)], + [3], [lt_dict_filter([lt_decl_dict], [$1], [$2], [$3], lt_decl_varnames)], + [lt_dict_filter([lt_decl_dict], $@)])[]dnl +]) + + +# lt_decl_quote_varnames([SEPARATOR], [VARNAME1...]) +# -------------------------------------------------- +m4_define([lt_decl_quote_varnames], +[_lt_decl_filter([value], [1], $@)]) + + +# lt_decl_dquote_varnames([SEPARATOR], [VARNAME1...]) +# --------------------------------------------------- +m4_define([lt_decl_dquote_varnames], +[_lt_decl_filter([value], [2], $@)]) + + +# lt_decl_varnames_tagged([SEPARATOR], [VARNAME1...]) +# --------------------------------------------------- +m4_define([lt_decl_varnames_tagged], +[m4_assert([$# <= 2])dnl +_$0(m4_quote(m4_default([$1], [[, ]])), + m4_ifval([$2], [[$2]], [m4_dquote(lt_decl_tag_varnames)]), + m4_split(m4_normalize(m4_quote(_LT_TAGS)), [ ]))]) +m4_define([_lt_decl_varnames_tagged], +[m4_ifval([$3], [lt_combine([$1], [$2], [_], $3)])]) + + +# lt_decl_all_varnames([SEPARATOR], [VARNAME1...]) +# ------------------------------------------------ +m4_define([lt_decl_all_varnames], +[_$0(m4_quote(m4_default([$1], [[, ]])), + m4_if([$2], [], + m4_quote(lt_decl_varnames), + m4_quote(m4_shift($@))))[]dnl +]) +m4_define([_lt_decl_all_varnames], +[lt_join($@, lt_decl_varnames_tagged([$1], + lt_decl_tag_varnames([[, ]], m4_shift($@))))dnl +]) + + +# _LT_CONFIG_STATUS_DECLARE([VARNAME]) +# ------------------------------------ +# Quote a variable value, and forward it to 'config.status' so that its +# declaration there will have the same value as in 'configure'. VARNAME +# must have a single quote delimited value for this to work. +m4_define([_LT_CONFIG_STATUS_DECLARE], +[$1='`$ECHO "$][$1" | $SED "$delay_single_quote_subst"`']) + + +# _LT_CONFIG_STATUS_DECLARATIONS +# ------------------------------ +# We delimit libtool config variables with single quotes, so when +# we write them to config.status, we have to be sure to quote all +# embedded single quotes properly. In configure, this macro expands +# each variable declared with _LT_DECL (and _LT_TAGDECL) into: +# +# ='`$ECHO "$" | $SED "$delay_single_quote_subst"`' +m4_defun([_LT_CONFIG_STATUS_DECLARATIONS], +[m4_foreach([_lt_var], m4_quote(lt_decl_all_varnames), + [m4_n([_LT_CONFIG_STATUS_DECLARE(_lt_var)])])]) + + +# _LT_LIBTOOL_TAGS +# ---------------- +# Output comment and list of tags supported by the script +m4_defun([_LT_LIBTOOL_TAGS], +[_LT_FORMAT_COMMENT([The names of the tagged configurations supported by this script])dnl +available_tags='_LT_TAGS'dnl +]) + + +# _LT_LIBTOOL_DECLARE(VARNAME, [TAG]) +# ----------------------------------- +# Extract the dictionary values for VARNAME (optionally with TAG) and +# expand to a commented shell variable setting: +# +# # Some comment about what VAR is for. +# visible_name=$lt_internal_name +m4_define([_LT_LIBTOOL_DECLARE], +[_LT_FORMAT_COMMENT(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], + [description])))[]dnl +m4_pushdef([_libtool_name], + m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [libtool_name])))[]dnl +m4_case(m4_quote(lt_dict_fetch([lt_decl_dict], [$1], [value])), + [0], [_libtool_name=[$]$1], + [1], [_libtool_name=$lt_[]$1], + [2], [_libtool_name=$lt_[]$1], + [_libtool_name=lt_dict_fetch([lt_decl_dict], [$1], [value])])[]dnl +m4_ifval([$2], [_$2])[]m4_popdef([_libtool_name])[]dnl +]) + + +# _LT_LIBTOOL_CONFIG_VARS +# ----------------------- +# Produce commented declarations of non-tagged libtool config variables +# suitable for insertion in the LIBTOOL CONFIG section of the 'libtool' +# script. Tagged libtool config variables (even for the LIBTOOL CONFIG +# section) are produced by _LT_LIBTOOL_TAG_VARS. +m4_defun([_LT_LIBTOOL_CONFIG_VARS], +[m4_foreach([_lt_var], + m4_quote(_lt_decl_filter([tagged?], [no], [], lt_decl_varnames)), + [m4_n([_LT_LIBTOOL_DECLARE(_lt_var)])])]) + + +# _LT_LIBTOOL_TAG_VARS(TAG) +# ------------------------- +m4_define([_LT_LIBTOOL_TAG_VARS], +[m4_foreach([_lt_var], m4_quote(lt_decl_tag_varnames), + [m4_n([_LT_LIBTOOL_DECLARE(_lt_var, [$1])])])]) + + +# _LT_TAGVAR(VARNAME, [TAGNAME]) +# ------------------------------ +m4_define([_LT_TAGVAR], [m4_ifval([$2], [$1_$2], [$1])]) + + +# _LT_CONFIG_COMMANDS +# ------------------- +# Send accumulated output to $CONFIG_STATUS. Thanks to the lists of +# variables for single and double quote escaping we saved from calls +# to _LT_DECL, we can put quote escaped variables declarations +# into 'config.status', and then the shell code to quote escape them in +# for loops in 'config.status'. Finally, any additional code accumulated +# from calls to _LT_CONFIG_LIBTOOL_INIT is expanded. +m4_defun([_LT_CONFIG_COMMANDS], +[AC_PROVIDE_IFELSE([LT_OUTPUT], + dnl If the libtool generation code has been placed in $CONFIG_LT, + dnl instead of duplicating it all over again into config.status, + dnl then we will have config.status run $CONFIG_LT later, so it + dnl needs to know what name is stored there: + [AC_CONFIG_COMMANDS([libtool], + [$SHELL $CONFIG_LT || AS_EXIT(1)], [CONFIG_LT='$CONFIG_LT'])], + dnl If the libtool generation code is destined for config.status, + dnl expand the accumulated commands and init code now: + [AC_CONFIG_COMMANDS([libtool], + [_LT_OUTPUT_LIBTOOL_COMMANDS], [_LT_OUTPUT_LIBTOOL_COMMANDS_INIT])]) +])#_LT_CONFIG_COMMANDS + + +# Initialize. +m4_define([_LT_OUTPUT_LIBTOOL_COMMANDS_INIT], +[ + +# The HP-UX ksh and POSIX shell print the target directory to stdout +# if CDPATH is set. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +sed_quote_subst='$sed_quote_subst' +double_quote_subst='$double_quote_subst' +delay_variable_subst='$delay_variable_subst' +_LT_CONFIG_STATUS_DECLARATIONS +LTCC='$LTCC' +LTCFLAGS='$LTCFLAGS' +compiler='$compiler_DEFAULT' + +# A function that is used when there is no print builtin or printf. +func_fallback_echo () +{ + eval 'cat <<_LTECHO_EOF +\$[]1 +_LTECHO_EOF' +} + +# Quote evaled strings. +for var in lt_decl_all_varnames([[ \ +]], lt_decl_quote_varnames); do + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + *[[\\\\\\\`\\"\\\$]]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +# Double-quote double-evaled strings. +for var in lt_decl_all_varnames([[ \ +]], lt_decl_dquote_varnames); do + case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in + *[[\\\\\\\`\\"\\\$]]*) + eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes + ;; + *) + eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\"" + ;; + esac +done + +_LT_OUTPUT_LIBTOOL_INIT +]) + +# _LT_GENERATED_FILE_INIT(FILE, [COMMENT]) +# ------------------------------------ +# Generate a child script FILE with all initialization necessary to +# reuse the environment learned by the parent script, and make the +# file executable. If COMMENT is supplied, it is inserted after the +# '#!' sequence but before initialization text begins. After this +# macro, additional text can be appended to FILE to form the body of +# the child script. The macro ends with non-zero status if the +# file could not be fully written (such as if the disk is full). +m4_ifdef([AS_INIT_GENERATED], +[m4_defun([_LT_GENERATED_FILE_INIT],[AS_INIT_GENERATED($@)])], +[m4_defun([_LT_GENERATED_FILE_INIT], +[m4_require([AS_PREPARE])]dnl +[m4_pushdef([AS_MESSAGE_LOG_FD])]dnl +[lt_write_fail=0 +cat >$1 <<_ASEOF || lt_write_fail=1 +#! $SHELL +# Generated by $as_me. +$2 +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$1 <<\_ASEOF || lt_write_fail=1 +AS_SHELL_SANITIZE +_AS_PREPARE +exec AS_MESSAGE_FD>&1 +_ASEOF +test 0 = "$lt_write_fail" && chmod +x $1[]dnl +m4_popdef([AS_MESSAGE_LOG_FD])])])# _LT_GENERATED_FILE_INIT + +# LT_OUTPUT +# --------- +# This macro allows early generation of the libtool script (before +# AC_OUTPUT is called), incase it is used in configure for compilation +# tests. +AC_DEFUN([LT_OUTPUT], +[: ${CONFIG_LT=./config.lt} +AC_MSG_NOTICE([creating $CONFIG_LT]) +_LT_GENERATED_FILE_INIT(["$CONFIG_LT"], +[# Run this file to recreate a libtool stub with the current configuration.]) + +cat >>"$CONFIG_LT" <<\_LTEOF +lt_cl_silent=false +exec AS_MESSAGE_LOG_FD>>config.log +{ + echo + AS_BOX([Running $as_me.]) +} >&AS_MESSAGE_LOG_FD + +lt_cl_help="\ +'$as_me' creates a local libtool stub from the current configuration, +for use in further configure time tests before the real libtool is +generated. + +Usage: $[0] [[OPTIONS]] + + -h, --help print this help, then exit + -V, --version print version number, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + +Report bugs to ." + +lt_cl_version="\ +m4_ifset([AC_PACKAGE_NAME], [AC_PACKAGE_NAME ])config.lt[]dnl +m4_ifset([AC_PACKAGE_VERSION], [ AC_PACKAGE_VERSION]) +configured by $[0], generated by m4_PACKAGE_STRING. + +Copyright (C) 2011 Free Software Foundation, Inc. +This config.lt script is free software; the Free Software Foundation +gives unlimited permision to copy, distribute and modify it." + +while test 0 != $[#] +do + case $[1] in + --version | --v* | -V ) + echo "$lt_cl_version"; exit 0 ;; + --help | --h* | -h ) + echo "$lt_cl_help"; exit 0 ;; + --debug | --d* | -d ) + debug=: ;; + --quiet | --q* | --silent | --s* | -q ) + lt_cl_silent=: ;; + + -*) AC_MSG_ERROR([unrecognized option: $[1] +Try '$[0] --help' for more information.]) ;; + + *) AC_MSG_ERROR([unrecognized argument: $[1] +Try '$[0] --help' for more information.]) ;; + esac + shift +done + +if $lt_cl_silent; then + exec AS_MESSAGE_FD>/dev/null +fi +_LTEOF + +cat >>"$CONFIG_LT" <<_LTEOF +_LT_OUTPUT_LIBTOOL_COMMANDS_INIT +_LTEOF + +cat >>"$CONFIG_LT" <<\_LTEOF +AC_MSG_NOTICE([creating $ofile]) +_LT_OUTPUT_LIBTOOL_COMMANDS +AS_EXIT(0) +_LTEOF +chmod +x "$CONFIG_LT" + +# configure is writing to config.log, but config.lt does its own redirection, +# appending to config.log, which fails on DOS, as config.log is still kept +# open by configure. Here we exec the FD to /dev/null, effectively closing +# config.log, so it can be properly (re)opened and appended to by config.lt. +lt_cl_success=: +test yes = "$silent" && + lt_config_lt_args="$lt_config_lt_args --quiet" +exec AS_MESSAGE_LOG_FD>/dev/null +$SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false +exec AS_MESSAGE_LOG_FD>>config.log +$lt_cl_success || AS_EXIT(1) +])# LT_OUTPUT + + +# _LT_CONFIG(TAG) +# --------------- +# If TAG is the built-in tag, create an initial libtool script with a +# default configuration from the untagged config vars. Otherwise add code +# to config.status for appending the configuration named by TAG from the +# matching tagged config vars. +m4_defun([_LT_CONFIG], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +_LT_CONFIG_SAVE_COMMANDS([ + m4_define([_LT_TAG], m4_if([$1], [], [C], [$1]))dnl + m4_if(_LT_TAG, [C], [ + # See if we are running on zsh, and set the options that allow our + # commands through without removal of \ escapes. + if test -n "${ZSH_VERSION+set}"; then + setopt NO_GLOB_SUBST + fi + + cfgfile=${ofile}T + trap "$RM \"$cfgfile\"; exit 1" 1 2 15 + $RM "$cfgfile" + + cat <<_LT_EOF >> "$cfgfile" +#! $SHELL +# Generated automatically by $as_me ($PACKAGE) $VERSION +# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`: +# NOTE: Changes made to this file will be lost: look at ltmain.sh. + +# Provide generalized library-building support services. +# Written by Gordon Matzigkeit, 1996 + +_LT_COPYING +_LT_LIBTOOL_TAGS + +# Configured defaults for sys_lib_dlsearch_path munging. +: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"} + +# ### BEGIN LIBTOOL CONFIG +_LT_LIBTOOL_CONFIG_VARS +_LT_LIBTOOL_TAG_VARS +# ### END LIBTOOL CONFIG + +_LT_EOF + + cat <<'_LT_EOF' >> "$cfgfile" + +# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE + +_LT_PREPARE_MUNGE_PATH_LIST +_LT_PREPARE_CC_BASENAME + +# ### END FUNCTIONS SHARED WITH CONFIGURE + +_LT_EOF + + case $host_os in + aix3*) + cat <<\_LT_EOF >> "$cfgfile" +# AIX sometimes has problems with the GCC collect2 program. For some +# reason, if we set the COLLECT_NAMES environment variable, the problems +# vanish in a puff of smoke. +if test set != "${COLLECT_NAMES+set}"; then + COLLECT_NAMES= + export COLLECT_NAMES +fi +_LT_EOF + ;; + esac + + _LT_PROG_LTMAIN + + # We use sed instead of cat because bash on DJGPP gets confused if + # if finds mixed CR/LF and LF-only lines. Since sed operates in + # text mode, it properly converts lines to CR/LF. This bash problem + # is reportedly fixed, but why not run on old versions too? + sed '$q' "$ltmain" >> "$cfgfile" \ + || (rm -f "$cfgfile"; exit 1) + + mv -f "$cfgfile" "$ofile" || + (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile") + chmod +x "$ofile" +], +[cat <<_LT_EOF >> "$ofile" + +dnl Unfortunately we have to use $1 here, since _LT_TAG is not expanded +dnl in a comment (ie after a #). +# ### BEGIN LIBTOOL TAG CONFIG: $1 +_LT_LIBTOOL_TAG_VARS(_LT_TAG) +# ### END LIBTOOL TAG CONFIG: $1 +_LT_EOF +])dnl /m4_if +], +[m4_if([$1], [], [ + PACKAGE='$PACKAGE' + VERSION='$VERSION' + RM='$RM' + ofile='$ofile'], []) +])dnl /_LT_CONFIG_SAVE_COMMANDS +])# _LT_CONFIG + + +# LT_SUPPORTED_TAG(TAG) +# --------------------- +# Trace this macro to discover what tags are supported by the libtool +# --tag option, using: +# autoconf --trace 'LT_SUPPORTED_TAG:$1' +AC_DEFUN([LT_SUPPORTED_TAG], []) + + +# C support is built-in for now +m4_define([_LT_LANG_C_enabled], []) +m4_define([_LT_TAGS], []) + + +# LT_LANG(LANG) +# ------------- +# Enable libtool support for the given language if not already enabled. +AC_DEFUN([LT_LANG], +[AC_BEFORE([$0], [LT_OUTPUT])dnl +m4_case([$1], + [C], [_LT_LANG(C)], + [C++], [_LT_LANG(CXX)], + [Go], [_LT_LANG(GO)], + [Java], [_LT_LANG(GCJ)], + [Fortran 77], [_LT_LANG(F77)], + [Fortran], [_LT_LANG(FC)], + [Windows Resource], [_LT_LANG(RC)], + [m4_ifdef([_LT_LANG_]$1[_CONFIG], + [_LT_LANG($1)], + [m4_fatal([$0: unsupported language: "$1"])])])dnl +])# LT_LANG + + +# _LT_LANG(LANGNAME) +# ------------------ +m4_defun([_LT_LANG], +[m4_ifdef([_LT_LANG_]$1[_enabled], [], + [LT_SUPPORTED_TAG([$1])dnl + m4_append([_LT_TAGS], [$1 ])dnl + m4_define([_LT_LANG_]$1[_enabled], [])dnl + _LT_LANG_$1_CONFIG($1)])dnl +])# _LT_LANG + + +m4_ifndef([AC_PROG_GO], [ +############################################################ +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_GO. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +############################################################ +m4_defun([AC_PROG_GO], +[AC_LANG_PUSH(Go)dnl +AC_ARG_VAR([GOC], [Go compiler command])dnl +AC_ARG_VAR([GOFLAGS], [Go compiler flags])dnl +_AC_ARG_VAR_LDFLAGS()dnl +AC_CHECK_TOOL(GOC, gccgo) +if test -z "$GOC"; then + if test -n "$ac_tool_prefix"; then + AC_CHECK_PROG(GOC, [${ac_tool_prefix}gccgo], [${ac_tool_prefix}gccgo]) + fi +fi +if test -z "$GOC"; then + AC_CHECK_PROG(GOC, gccgo, gccgo, false) +fi +])#m4_defun +])#m4_ifndef + + +# _LT_LANG_DEFAULT_CONFIG +# ----------------------- +m4_defun([_LT_LANG_DEFAULT_CONFIG], +[AC_PROVIDE_IFELSE([AC_PROG_CXX], + [LT_LANG(CXX)], + [m4_define([AC_PROG_CXX], defn([AC_PROG_CXX])[LT_LANG(CXX)])]) + +AC_PROVIDE_IFELSE([AC_PROG_F77], + [LT_LANG(F77)], + [m4_define([AC_PROG_F77], defn([AC_PROG_F77])[LT_LANG(F77)])]) + +AC_PROVIDE_IFELSE([AC_PROG_FC], + [LT_LANG(FC)], + [m4_define([AC_PROG_FC], defn([AC_PROG_FC])[LT_LANG(FC)])]) + +dnl The call to [A][M_PROG_GCJ] is quoted like that to stop aclocal +dnl pulling things in needlessly. +AC_PROVIDE_IFELSE([AC_PROG_GCJ], + [LT_LANG(GCJ)], + [AC_PROVIDE_IFELSE([A][M_PROG_GCJ], + [LT_LANG(GCJ)], + [AC_PROVIDE_IFELSE([LT_PROG_GCJ], + [LT_LANG(GCJ)], + [m4_ifdef([AC_PROG_GCJ], + [m4_define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[LT_LANG(GCJ)])]) + m4_ifdef([A][M_PROG_GCJ], + [m4_define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[LT_LANG(GCJ)])]) + m4_ifdef([LT_PROG_GCJ], + [m4_define([LT_PROG_GCJ], defn([LT_PROG_GCJ])[LT_LANG(GCJ)])])])])]) + +AC_PROVIDE_IFELSE([AC_PROG_GO], + [LT_LANG(GO)], + [m4_define([AC_PROG_GO], defn([AC_PROG_GO])[LT_LANG(GO)])]) + +AC_PROVIDE_IFELSE([LT_PROG_RC], + [LT_LANG(RC)], + [m4_define([LT_PROG_RC], defn([LT_PROG_RC])[LT_LANG(RC)])]) +])# _LT_LANG_DEFAULT_CONFIG + +# Obsolete macros: +AU_DEFUN([AC_LIBTOOL_CXX], [LT_LANG(C++)]) +AU_DEFUN([AC_LIBTOOL_F77], [LT_LANG(Fortran 77)]) +AU_DEFUN([AC_LIBTOOL_FC], [LT_LANG(Fortran)]) +AU_DEFUN([AC_LIBTOOL_GCJ], [LT_LANG(Java)]) +AU_DEFUN([AC_LIBTOOL_RC], [LT_LANG(Windows Resource)]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_CXX], []) +dnl AC_DEFUN([AC_LIBTOOL_F77], []) +dnl AC_DEFUN([AC_LIBTOOL_FC], []) +dnl AC_DEFUN([AC_LIBTOOL_GCJ], []) +dnl AC_DEFUN([AC_LIBTOOL_RC], []) + + +# _LT_TAG_COMPILER +# ---------------- +m4_defun([_LT_TAG_COMPILER], +[AC_REQUIRE([AC_PROG_CC])dnl + +_LT_DECL([LTCC], [CC], [1], [A C compiler])dnl +_LT_DECL([LTCFLAGS], [CFLAGS], [1], [LTCC compiler flags])dnl +_LT_TAGDECL([CC], [compiler], [1], [A language specific compiler])dnl +_LT_TAGDECL([with_gcc], [GCC], [0], [Is the compiler the GNU compiler?])dnl + +# If no C compiler was specified, use CC. +LTCC=${LTCC-"$CC"} + +# If no C compiler flags were specified, use CFLAGS. +LTCFLAGS=${LTCFLAGS-"$CFLAGS"} + +# Allow CC to be a program name with arguments. +compiler=$CC +])# _LT_TAG_COMPILER + + +# _LT_COMPILER_BOILERPLATE +# ------------------------ +# Check for compiler boilerplate output or warnings with +# the simple compiler test code. +m4_defun([_LT_COMPILER_BOILERPLATE], +[m4_require([_LT_DECL_SED])dnl +ac_outfile=conftest.$ac_objext +echo "$lt_simple_compile_test_code" >conftest.$ac_ext +eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_compiler_boilerplate=`cat conftest.err` +$RM conftest* +])# _LT_COMPILER_BOILERPLATE + + +# _LT_LINKER_BOILERPLATE +# ---------------------- +# Check for linker boilerplate output or warnings with +# the simple link test code. +m4_defun([_LT_LINKER_BOILERPLATE], +[m4_require([_LT_DECL_SED])dnl +ac_outfile=conftest.$ac_objext +echo "$lt_simple_link_test_code" >conftest.$ac_ext +eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err +_lt_linker_boilerplate=`cat conftest.err` +$RM -r conftest* +])# _LT_LINKER_BOILERPLATE + +# _LT_REQUIRED_DARWIN_CHECKS +# ------------------------- +m4_defun_once([_LT_REQUIRED_DARWIN_CHECKS],[ + case $host_os in + rhapsody* | darwin*) + AC_CHECK_TOOL([DSYMUTIL], [dsymutil], [:]) + AC_CHECK_TOOL([NMEDIT], [nmedit], [:]) + AC_CHECK_TOOL([LIPO], [lipo], [:]) + AC_CHECK_TOOL([OTOOL], [otool], [:]) + AC_CHECK_TOOL([OTOOL64], [otool64], [:]) + _LT_DECL([], [DSYMUTIL], [1], + [Tool to manipulate archived DWARF debug symbol files on Mac OS X]) + _LT_DECL([], [NMEDIT], [1], + [Tool to change global to local symbols on Mac OS X]) + _LT_DECL([], [LIPO], [1], + [Tool to manipulate fat objects and archives on Mac OS X]) + _LT_DECL([], [OTOOL], [1], + [ldd/readelf like tool for Mach-O binaries on Mac OS X]) + _LT_DECL([], [OTOOL64], [1], + [ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4]) + + AC_CACHE_CHECK([for -single_module linker flag],[lt_cv_apple_cc_single_mod], + [lt_cv_apple_cc_single_mod=no + if test -z "$LT_MULTI_MODULE"; then + # By default we will add the -single_module flag. You can override + # by either setting the environment variable LT_MULTI_MODULE + # non-empty at configure time, or by adding -multi_module to the + # link flags. + rm -rf libconftest.dylib* + echo "int foo(void){return 1;}" > conftest.c + echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ +-dynamiclib -Wl,-single_module conftest.c" >&AS_MESSAGE_LOG_FD + $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \ + -dynamiclib -Wl,-single_module conftest.c 2>conftest.err + _lt_result=$? + # If there is a non-empty error log, and "single_module" + # appears in it, assume the flag caused a linker warning + if test -s conftest.err && $GREP single_module conftest.err; then + cat conftest.err >&AS_MESSAGE_LOG_FD + # Otherwise, if the output was created with a 0 exit code from + # the compiler, it worked. + elif test -f libconftest.dylib && test 0 = "$_lt_result"; then + lt_cv_apple_cc_single_mod=yes + else + cat conftest.err >&AS_MESSAGE_LOG_FD + fi + rm -rf libconftest.dylib* + rm -f conftest.* + fi]) + + AC_CACHE_CHECK([for -exported_symbols_list linker flag], + [lt_cv_ld_exported_symbols_list], + [lt_cv_ld_exported_symbols_list=no + save_LDFLAGS=$LDFLAGS + echo "_main" > conftest.sym + LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [lt_cv_ld_exported_symbols_list=yes], + [lt_cv_ld_exported_symbols_list=no]) + LDFLAGS=$save_LDFLAGS + ]) + + AC_CACHE_CHECK([for -force_load linker flag],[lt_cv_ld_force_load], + [lt_cv_ld_force_load=no + cat > conftest.c << _LT_EOF +int forced_loaded() { return 2;} +_LT_EOF + echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&AS_MESSAGE_LOG_FD + $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&AS_MESSAGE_LOG_FD + echo "$AR cru libconftest.a conftest.o" >&AS_MESSAGE_LOG_FD + $AR cru libconftest.a conftest.o 2>&AS_MESSAGE_LOG_FD + echo "$RANLIB libconftest.a" >&AS_MESSAGE_LOG_FD + $RANLIB libconftest.a 2>&AS_MESSAGE_LOG_FD + cat > conftest.c << _LT_EOF +int main() { return 0;} +_LT_EOF + echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&AS_MESSAGE_LOG_FD + $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err + _lt_result=$? + if test -s conftest.err && $GREP force_load conftest.err; then + cat conftest.err >&AS_MESSAGE_LOG_FD + elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then + lt_cv_ld_force_load=yes + else + cat conftest.err >&AS_MESSAGE_LOG_FD + fi + rm -f conftest.err libconftest.a conftest conftest.c + rm -rf conftest.dSYM + ]) + case $host_os in + rhapsody* | darwin1.[[012]]) + _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; + darwin1.*) + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; + darwin*) # darwin 5.x on + # if running on 10.5 or later, the deployment target defaults + # to the OS version, if on x86, and 10.4, the deployment + # target defaults to 10.4. Don't you love it? + case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in + 10.0,*86*-darwin8*|10.0,*-darwin[[91]]*) + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + 10.[[012]][[,.]]*) + _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; + 10.*) + _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; + esac + ;; + esac + if test yes = "$lt_cv_apple_cc_single_mod"; then + _lt_dar_single_mod='$single_module' + fi + if test yes = "$lt_cv_ld_exported_symbols_list"; then + _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym' + else + _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib' + fi + if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then + _lt_dsymutil='~$DSYMUTIL $lib || :' + else + _lt_dsymutil= + fi + ;; + esac +]) + + +# _LT_DARWIN_LINKER_FEATURES([TAG]) +# --------------------------------- +# Checks for linker and compiler features on darwin +m4_defun([_LT_DARWIN_LINKER_FEATURES], +[ + m4_require([_LT_REQUIRED_DARWIN_CHECKS]) + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_automatic, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + if test yes = "$lt_cv_ld_force_load"; then + _LT_TAGVAR(whole_archive_flag_spec, $1)='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`' + m4_case([$1], [F77], [_LT_TAGVAR(compiler_needs_object, $1)=yes], + [FC], [_LT_TAGVAR(compiler_needs_object, $1)=yes]) + else + _LT_TAGVAR(whole_archive_flag_spec, $1)='' + fi + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)=$_lt_dar_allow_undefined + case $cc_basename in + ifort*|nagfor*) _lt_dar_can_shared=yes ;; + *) _lt_dar_can_shared=$GCC ;; + esac + if test yes = "$_lt_dar_can_shared"; then + output_verbose_link_cmd=func_echo_all + _LT_TAGVAR(archive_cmds, $1)="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" + _LT_TAGVAR(module_cmds, $1)="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" + _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" + _LT_TAGVAR(module_expsym_cmds, $1)="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" + m4_if([$1], [CXX], +[ if test yes != "$lt_cv_apple_cc_single_mod"; then + _LT_TAGVAR(archive_cmds, $1)="\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dsymutil" + _LT_TAGVAR(archive_expsym_cmds, $1)="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \$lib-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$lib-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring$_lt_dar_export_syms$_lt_dsymutil" + fi +],[]) + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi +]) + +# _LT_SYS_MODULE_PATH_AIX([TAGNAME]) +# ---------------------------------- +# Links a minimal program and checks the executable +# for the system default hardcoded library path. In most cases, +# this is /usr/lib:/lib, but when the MPI compilers are used +# the location of the communication and MPI libs are included too. +# If we don't find anything, use the default library path according +# to the aix ld manual. +# Store the results from the different compilers for each TAGNAME. +# Allow to override them for all tags through lt_cv_aix_libpath. +m4_defun([_LT_SYS_MODULE_PATH_AIX], +[m4_require([_LT_DECL_SED])dnl +if test set = "${lt_cv_aix_libpath+set}"; then + aix_libpath=$lt_cv_aix_libpath +else + AC_CACHE_VAL([_LT_TAGVAR([lt_cv_aix_libpath_], [$1])], + [AC_LINK_IFELSE([AC_LANG_PROGRAM],[ + lt_aix_libpath_sed='[ + /Import File Strings/,/^$/ { + /^0/ { + s/^0 *\([^ ]*\) *$/\1/ + p + } + }]' + _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + # Check for a 64-bit object if we didn't find anything. + if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then + _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"` + fi],[]) + if test -z "$_LT_TAGVAR([lt_cv_aix_libpath_], [$1])"; then + _LT_TAGVAR([lt_cv_aix_libpath_], [$1])=/usr/lib:/lib + fi + ]) + aix_libpath=$_LT_TAGVAR([lt_cv_aix_libpath_], [$1]) +fi +])# _LT_SYS_MODULE_PATH_AIX + + +# _LT_SHELL_INIT(ARG) +# ------------------- +m4_define([_LT_SHELL_INIT], +[m4_divert_text([M4SH-INIT], [$1 +])])# _LT_SHELL_INIT + + + +# _LT_PROG_ECHO_BACKSLASH +# ----------------------- +# Find how we can fake an echo command that does not interpret backslash. +# In particular, with Autoconf 2.60 or later we add some code to the start +# of the generated configure script that will find a shell with a builtin +# printf (that we can use as an echo command). +m4_defun([_LT_PROG_ECHO_BACKSLASH], +[ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO +ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO + +AC_MSG_CHECKING([how to print strings]) +# Test print first, because it will be a builtin if present. +if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \ + test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then + ECHO='print -r --' +elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then + ECHO='printf %s\n' +else + # Use this function as a fallback that always works. + func_fallback_echo () + { + eval 'cat <<_LTECHO_EOF +$[]1 +_LTECHO_EOF' + } + ECHO='func_fallback_echo' +fi + +# func_echo_all arg... +# Invoke $ECHO with all args, space-separated. +func_echo_all () +{ + $ECHO "$*" +} + +case $ECHO in + printf*) AC_MSG_RESULT([printf]) ;; + print*) AC_MSG_RESULT([print -r]) ;; + *) AC_MSG_RESULT([cat]) ;; +esac + +m4_ifdef([_AS_DETECT_SUGGESTED], +[_AS_DETECT_SUGGESTED([ + test -n "${ZSH_VERSION+set}${BASH_VERSION+set}" || ( + ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' + ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO + ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO + PATH=/empty FPATH=/empty; export PATH FPATH + test "X`printf %s $ECHO`" = "X$ECHO" \ + || test "X`print -r -- $ECHO`" = "X$ECHO" )])]) + +_LT_DECL([], [SHELL], [1], [Shell to use when invoking shell scripts]) +_LT_DECL([], [ECHO], [1], [An echo program that protects backslashes]) +])# _LT_PROG_ECHO_BACKSLASH + + +# _LT_WITH_SYSROOT +# ---------------- +AC_DEFUN([_LT_WITH_SYSROOT], +[AC_MSG_CHECKING([for sysroot]) +AC_ARG_WITH([sysroot], +[AS_HELP_STRING([--with-sysroot@<:@=DIR@:>@], + [Search for dependent libraries within DIR (or the compiler's sysroot + if not specified).])], +[], [with_sysroot=no]) + +dnl lt_sysroot will always be passed unquoted. We quote it here +dnl in case the user passed a directory name. +lt_sysroot= +case $with_sysroot in #( + yes) + if test yes = "$GCC"; then + lt_sysroot=`$CC --print-sysroot 2>/dev/null` + fi + ;; #( + /*) + lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"` + ;; #( + no|'') + ;; #( + *) + AC_MSG_RESULT([$with_sysroot]) + AC_MSG_ERROR([The sysroot must be an absolute path.]) + ;; +esac + + AC_MSG_RESULT([${lt_sysroot:-no}]) +_LT_DECL([], [lt_sysroot], [0], [The root where to search for ]dnl +[dependent libraries, and where our libraries should be installed.])]) + +# _LT_ENABLE_LOCK +# --------------- +m4_defun([_LT_ENABLE_LOCK], +[AC_ARG_ENABLE([libtool-lock], + [AS_HELP_STRING([--disable-libtool-lock], + [avoid locking (might break parallel builds)])]) +test no = "$enable_libtool_lock" || enable_libtool_lock=yes + +# Some flags need to be propagated to the compiler or linker for good +# libtool support. +case $host in +ia64-*-hpux*) + # Find out what ABI is being produced by ac_compile, and set mode + # options accordingly. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.$ac_objext` in + *ELF-32*) + HPUX_IA64_MODE=32 + ;; + *ELF-64*) + HPUX_IA64_MODE=64 + ;; + esac + fi + rm -rf conftest* + ;; +*-*-irix6*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + if test yes = "$lt_cv_prog_gnu_ld"; then + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -melf32bsmip" + ;; + *N32*) + LD="${LD-ld} -melf32bmipn32" + ;; + *64-bit*) + LD="${LD-ld} -melf64bmip" + ;; + esac + else + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + LD="${LD-ld} -32" + ;; + *N32*) + LD="${LD-ld} -n32" + ;; + *64-bit*) + LD="${LD-ld} -64" + ;; + esac + fi + fi + rm -rf conftest* + ;; + +mips64*-*linux*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo '[#]line '$LINENO' "configure"' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + emul=elf + case `/usr/bin/file conftest.$ac_objext` in + *32-bit*) + emul="${emul}32" + ;; + *64-bit*) + emul="${emul}64" + ;; + esac + case `/usr/bin/file conftest.$ac_objext` in + *MSB*) + emul="${emul}btsmip" + ;; + *LSB*) + emul="${emul}ltsmip" + ;; + esac + case `/usr/bin/file conftest.$ac_objext` in + *N32*) + emul="${emul}n32" + ;; + esac + LD="${LD-ld} -m $emul" + fi + rm -rf conftest* + ;; + +x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \ +s390*-*linux*|s390*-*tpf*|sparc*-*linux*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. Note that the listed cases only cover the + # situations where additional linker options are needed (such as when + # doing 32-bit compilation for a host where ld defaults to 64-bit, or + # vice versa); the common cases where no linker options are needed do + # not appear in the list. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *32-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_i386_fbsd" + ;; + x86_64-*linux*) + case `/usr/bin/file conftest.o` in + *x86-64*) + LD="${LD-ld} -m elf32_x86_64" + ;; + *) + LD="${LD-ld} -m elf_i386" + ;; + esac + ;; + powerpc64le-*linux*) + LD="${LD-ld} -m elf32lppclinux" + ;; + powerpc64-*linux*) + LD="${LD-ld} -m elf32ppclinux" + ;; + s390x-*linux*) + LD="${LD-ld} -m elf_s390" + ;; + sparc64-*linux*) + LD="${LD-ld} -m elf32_sparc" + ;; + esac + ;; + *64-bit*) + case $host in + x86_64-*kfreebsd*-gnu) + LD="${LD-ld} -m elf_x86_64_fbsd" + ;; + x86_64-*linux*) + LD="${LD-ld} -m elf_x86_64" + ;; + powerpcle-*linux*) + LD="${LD-ld} -m elf64lppc" + ;; + powerpc-*linux*) + LD="${LD-ld} -m elf64ppc" + ;; + s390*-*linux*|s390*-*tpf*) + LD="${LD-ld} -m elf64_s390" + ;; + sparc*-*linux*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; + +*-*-sco3.2v5*) + # On SCO OpenServer 5, we need -belf to get full-featured binaries. + SAVE_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS -belf" + AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf, + [AC_LANG_PUSH(C) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no]) + AC_LANG_POP]) + if test yes != "$lt_cv_cc_needs_belf"; then + # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf + CFLAGS=$SAVE_CFLAGS + fi + ;; +*-*solaris*) + # Find out what ABI is being produced by ac_compile, and set linker + # options accordingly. + echo 'int i;' > conftest.$ac_ext + if AC_TRY_EVAL(ac_compile); then + case `/usr/bin/file conftest.o` in + *64-bit*) + case $lt_cv_prog_gnu_ld in + yes*) + case $host in + i?86-*-solaris*|x86_64-*-solaris*) + LD="${LD-ld} -m elf_x86_64" + ;; + sparc*-*-solaris*) + LD="${LD-ld} -m elf64_sparc" + ;; + esac + # GNU ld 2.21 introduced _sol2 emulations. Use them if available. + if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then + LD=${LD-ld}_sol2 + fi + ;; + *) + if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then + LD="${LD-ld} -64" + fi + ;; + esac + ;; + esac + fi + rm -rf conftest* + ;; +esac + +need_locks=$enable_libtool_lock +])# _LT_ENABLE_LOCK + + +# _LT_PROG_AR +# ----------- +m4_defun([_LT_PROG_AR], +[AC_CHECK_TOOLS(AR, [ar], false) +: ${AR=ar} +: ${AR_FLAGS=cru} +_LT_DECL([], [AR], [1], [The archiver]) +_LT_DECL([], [AR_FLAGS], [1], [Flags to create an archive]) + +AC_CACHE_CHECK([for archiver @FILE support], [lt_cv_ar_at_file], + [lt_cv_ar_at_file=no + AC_COMPILE_IFELSE([AC_LANG_PROGRAM], + [echo conftest.$ac_objext > conftest.lst + lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&AS_MESSAGE_LOG_FD' + AC_TRY_EVAL([lt_ar_try]) + if test 0 -eq "$ac_status"; then + # Ensure the archiver fails upon bogus file names. + rm -f conftest.$ac_objext libconftest.a + AC_TRY_EVAL([lt_ar_try]) + if test 0 -ne "$ac_status"; then + lt_cv_ar_at_file=@ + fi + fi + rm -f conftest.* libconftest.a + ]) + ]) + +if test no = "$lt_cv_ar_at_file"; then + archiver_list_spec= +else + archiver_list_spec=$lt_cv_ar_at_file +fi +_LT_DECL([], [archiver_list_spec], [1], + [How to feed a file listing to the archiver]) +])# _LT_PROG_AR + + +# _LT_CMD_OLD_ARCHIVE +# ------------------- +m4_defun([_LT_CMD_OLD_ARCHIVE], +[_LT_PROG_AR + +AC_CHECK_TOOL(STRIP, strip, :) +test -z "$STRIP" && STRIP=: +_LT_DECL([], [STRIP], [1], [A symbol stripping program]) + +AC_CHECK_TOOL(RANLIB, ranlib, :) +test -z "$RANLIB" && RANLIB=: +_LT_DECL([], [RANLIB], [1], + [Commands used to install an old-style archive]) + +# Determine commands to create old-style static archives. +old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs' +old_postinstall_cmds='chmod 644 $oldlib' +old_postuninstall_cmds= + +if test -n "$RANLIB"; then + case $host_os in + bitrig* | openbsd*) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib" + ;; + *) + old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib" + ;; + esac + old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib" +fi + +case $host_os in + darwin*) + lock_old_archive_extraction=yes ;; + *) + lock_old_archive_extraction=no ;; +esac +_LT_DECL([], [old_postinstall_cmds], [2]) +_LT_DECL([], [old_postuninstall_cmds], [2]) +_LT_TAGDECL([], [old_archive_cmds], [2], + [Commands used to build an old-style archive]) +_LT_DECL([], [lock_old_archive_extraction], [0], + [Whether to use a lock for old archive extraction]) +])# _LT_CMD_OLD_ARCHIVE + + +# _LT_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------------------- +# Check whether the given compiler option works +AC_DEFUN([_LT_COMPILER_OPTION], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_SED])dnl +AC_CACHE_CHECK([$1], [$2], + [$2=no + m4_if([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4]) + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + lt_compiler_flag="$3" ## exclude from sc_useless_quotes_in_assignment + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + # The option is referenced via a variable to avoid confusing sed. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>conftest.err) + ac_status=$? + cat conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s "$ac_outfile"; then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings other than the usual output. + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + fi + $RM conftest* +]) + +if test yes = "[$]$2"; then + m4_if([$5], , :, [$5]) +else + m4_if([$6], , :, [$6]) +fi +])# _LT_COMPILER_OPTION + +# Old name: +AU_ALIAS([AC_LIBTOOL_COMPILER_OPTION], [_LT_COMPILER_OPTION]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION], []) + + +# _LT_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS, +# [ACTION-SUCCESS], [ACTION-FAILURE]) +# ---------------------------------------------------- +# Check whether the given linker option works +AC_DEFUN([_LT_LINKER_OPTION], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_SED])dnl +AC_CACHE_CHECK([$1], [$2], + [$2=no + save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS $3" + echo "$lt_simple_link_test_code" > conftest.$ac_ext + if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then + # The linker can only warn and ignore the option if not recognized + # So say no if there are warnings + if test -s conftest.err; then + # Append any errors to the config.log. + cat conftest.err 1>&AS_MESSAGE_LOG_FD + $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp + $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2 + if diff conftest.exp conftest.er2 >/dev/null; then + $2=yes + fi + else + $2=yes + fi + fi + $RM -r conftest* + LDFLAGS=$save_LDFLAGS +]) + +if test yes = "[$]$2"; then + m4_if([$4], , :, [$4]) +else + m4_if([$5], , :, [$5]) +fi +])# _LT_LINKER_OPTION + +# Old name: +AU_ALIAS([AC_LIBTOOL_LINKER_OPTION], [_LT_LINKER_OPTION]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_LINKER_OPTION], []) + + +# LT_CMD_MAX_LEN +#--------------- +AC_DEFUN([LT_CMD_MAX_LEN], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +# find the maximum length of command line arguments +AC_MSG_CHECKING([the maximum length of command line arguments]) +AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl + i=0 + teststring=ABCD + + case $build_os in + msdosdjgpp*) + # On DJGPP, this test can blow up pretty badly due to problems in libc + # (any single argument exceeding 2000 bytes causes a buffer overrun + # during glob expansion). Even if it were fixed, the result of this + # check would be larger than it should be. + lt_cv_sys_max_cmd_len=12288; # 12K is about right + ;; + + gnu*) + # Under GNU Hurd, this test is not required because there is + # no limit to the length of command line arguments. + # Libtool will interpret -1 as no limit whatsoever + lt_cv_sys_max_cmd_len=-1; + ;; + + cygwin* | mingw* | cegcc*) + # On Win9x/ME, this test blows up -- it succeeds, but takes + # about 5 minutes as the teststring grows exponentially. + # Worse, since 9x/ME are not pre-emptively multitasking, + # you end up with a "frozen" computer, even though with patience + # the test eventually succeeds (with a max line length of 256k). + # Instead, let's just punt: use the minimum linelength reported by + # all of the supported platforms: 8192 (on NT/2K/XP). + lt_cv_sys_max_cmd_len=8192; + ;; + + mint*) + # On MiNT this can take a long time and run out of memory. + lt_cv_sys_max_cmd_len=8192; + ;; + + amigaos*) + # On AmigaOS with pdksh, this test takes hours, literally. + # So we just punt and use a minimum line length of 8192. + lt_cv_sys_max_cmd_len=8192; + ;; + + bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*) + # This has been around since 386BSD, at least. Likely further. + if test -x /sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` + elif test -x /usr/sbin/sysctl; then + lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax` + else + lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs + fi + # And add a safety zone + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + ;; + + interix*) + # We know the value 262144 and hardcode it with a safety zone (like BSD) + lt_cv_sys_max_cmd_len=196608 + ;; + + os2*) + # The test takes a long time on OS/2. + lt_cv_sys_max_cmd_len=8192 + ;; + + osf*) + # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure + # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not + # nice to cause kernel panics so lets avoid the loop below. + # First set a reasonable default. + lt_cv_sys_max_cmd_len=16384 + # + if test -x /sbin/sysconfig; then + case `/sbin/sysconfig -q proc exec_disable_arg_limit` in + *1*) lt_cv_sys_max_cmd_len=-1 ;; + esac + fi + ;; + sco3.2v5*) + lt_cv_sys_max_cmd_len=102400 + ;; + sysv5* | sco5v6* | sysv4.2uw2*) + kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` + if test -n "$kargmax"; then + lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[[ ]]//'` + else + lt_cv_sys_max_cmd_len=32768 + fi + ;; + *) + lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null` + if test -n "$lt_cv_sys_max_cmd_len" && \ + test undefined != "$lt_cv_sys_max_cmd_len"; then + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4` + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3` + else + # Make teststring a little bigger before we do anything with it. + # a 1K string should be a reasonable start. + for i in 1 2 3 4 5 6 7 8; do + teststring=$teststring$teststring + done + SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}} + # If test is not a shell built-in, we'll probably end up computing a + # maximum length that is only half of the actual maximum length, but + # we can't tell. + while { test X`env echo "$teststring$teststring" 2>/dev/null` \ + = "X$teststring$teststring"; } >/dev/null 2>&1 && + test 17 != "$i" # 1/2 MB should be enough + do + i=`expr $i + 1` + teststring=$teststring$teststring + done + # Only check the string length outside the loop. + lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1` + teststring= + # Add a significant safety factor because C++ compilers can tack on + # massive amounts of additional arguments before passing them to the + # linker. It appears as though 1/2 is a usable value. + lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2` + fi + ;; + esac +]) +if test -n "$lt_cv_sys_max_cmd_len"; then + AC_MSG_RESULT($lt_cv_sys_max_cmd_len) +else + AC_MSG_RESULT(none) +fi +max_cmd_len=$lt_cv_sys_max_cmd_len +_LT_DECL([], [max_cmd_len], [0], + [What is the maximum length of a command?]) +])# LT_CMD_MAX_LEN + +# Old name: +AU_ALIAS([AC_LIBTOOL_SYS_MAX_CMD_LEN], [LT_CMD_MAX_LEN]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN], []) + + +# _LT_HEADER_DLFCN +# ---------------- +m4_defun([_LT_HEADER_DLFCN], +[AC_CHECK_HEADERS([dlfcn.h], [], [], [AC_INCLUDES_DEFAULT])dnl +])# _LT_HEADER_DLFCN + + +# _LT_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE, +# ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING) +# ---------------------------------------------------------------- +m4_defun([_LT_TRY_DLOPEN_SELF], +[m4_require([_LT_HEADER_DLFCN])dnl +if test yes = "$cross_compiling"; then : + [$4] +else + lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 + lt_status=$lt_dlunknown + cat > conftest.$ac_ext <<_LT_EOF +[#line $LINENO "configure" +#include "confdefs.h" + +#if HAVE_DLFCN_H +#include +#endif + +#include + +#ifdef RTLD_GLOBAL +# define LT_DLGLOBAL RTLD_GLOBAL +#else +# ifdef DL_GLOBAL +# define LT_DLGLOBAL DL_GLOBAL +# else +# define LT_DLGLOBAL 0 +# endif +#endif + +/* We may have to define LT_DLLAZY_OR_NOW in the command line if we + find out it does not work in some platform. */ +#ifndef LT_DLLAZY_OR_NOW +# ifdef RTLD_LAZY +# define LT_DLLAZY_OR_NOW RTLD_LAZY +# else +# ifdef DL_LAZY +# define LT_DLLAZY_OR_NOW DL_LAZY +# else +# ifdef RTLD_NOW +# define LT_DLLAZY_OR_NOW RTLD_NOW +# else +# ifdef DL_NOW +# define LT_DLLAZY_OR_NOW DL_NOW +# else +# define LT_DLLAZY_OR_NOW 0 +# endif +# endif +# endif +# endif +#endif + +/* When -fvisibility=hidden is used, assume the code has been annotated + correspondingly for the symbols needed. */ +#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3)) +int fnord () __attribute__((visibility("default"))); +#endif + +int fnord () { return 42; } +int main () +{ + void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW); + int status = $lt_dlunknown; + + if (self) + { + if (dlsym (self,"fnord")) status = $lt_dlno_uscore; + else + { + if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore; + else puts (dlerror ()); + } + /* dlclose (self); */ + } + else + puts (dlerror ()); + + return status; +}] +_LT_EOF + if AC_TRY_EVAL(ac_link) && test -s "conftest$ac_exeext" 2>/dev/null; then + (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null + lt_status=$? + case x$lt_status in + x$lt_dlno_uscore) $1 ;; + x$lt_dlneed_uscore) $2 ;; + x$lt_dlunknown|x*) $3 ;; + esac + else : + # compilation failed + $3 + fi +fi +rm -fr conftest* +])# _LT_TRY_DLOPEN_SELF + + +# LT_SYS_DLOPEN_SELF +# ------------------ +AC_DEFUN([LT_SYS_DLOPEN_SELF], +[m4_require([_LT_HEADER_DLFCN])dnl +if test yes != "$enable_dlopen"; then + enable_dlopen=unknown + enable_dlopen_self=unknown + enable_dlopen_self_static=unknown +else + lt_cv_dlopen=no + lt_cv_dlopen_libs= + + case $host_os in + beos*) + lt_cv_dlopen=load_add_on + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ;; + + mingw* | pw32* | cegcc*) + lt_cv_dlopen=LoadLibrary + lt_cv_dlopen_libs= + ;; + + cygwin*) + lt_cv_dlopen=dlopen + lt_cv_dlopen_libs= + ;; + + darwin*) + # if libdl is installed we need to link against it + AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl],[ + lt_cv_dlopen=dyld + lt_cv_dlopen_libs= + lt_cv_dlopen_self=yes + ]) + ;; + + tpf*) + # Don't try to run any link tests for TPF. We know it's impossible + # because TPF is a cross-compiler, and we know how we open DSOs. + lt_cv_dlopen=dlopen + lt_cv_dlopen_libs= + lt_cv_dlopen_self=no + ;; + + *) + AC_CHECK_FUNC([shl_load], + [lt_cv_dlopen=shl_load], + [AC_CHECK_LIB([dld], [shl_load], + [lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld], + [AC_CHECK_FUNC([dlopen], + [lt_cv_dlopen=dlopen], + [AC_CHECK_LIB([dl], [dlopen], + [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl], + [AC_CHECK_LIB([svld], [dlopen], + [lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld], + [AC_CHECK_LIB([dld], [dld_link], + [lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld]) + ]) + ]) + ]) + ]) + ]) + ;; + esac + + if test no = "$lt_cv_dlopen"; then + enable_dlopen=no + else + enable_dlopen=yes + fi + + case $lt_cv_dlopen in + dlopen) + save_CPPFLAGS=$CPPFLAGS + test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H" + + save_LDFLAGS=$LDFLAGS + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\" + + save_LIBS=$LIBS + LIBS="$lt_cv_dlopen_libs $LIBS" + + AC_CACHE_CHECK([whether a program can dlopen itself], + lt_cv_dlopen_self, [dnl + _LT_TRY_DLOPEN_SELF( + lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes, + lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross) + ]) + + if test yes = "$lt_cv_dlopen_self"; then + wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\" + AC_CACHE_CHECK([whether a statically linked program can dlopen itself], + lt_cv_dlopen_self_static, [dnl + _LT_TRY_DLOPEN_SELF( + lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes, + lt_cv_dlopen_self_static=no, lt_cv_dlopen_self_static=cross) + ]) + fi + + CPPFLAGS=$save_CPPFLAGS + LDFLAGS=$save_LDFLAGS + LIBS=$save_LIBS + ;; + esac + + case $lt_cv_dlopen_self in + yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;; + *) enable_dlopen_self=unknown ;; + esac + + case $lt_cv_dlopen_self_static in + yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;; + *) enable_dlopen_self_static=unknown ;; + esac +fi +_LT_DECL([dlopen_support], [enable_dlopen], [0], + [Whether dlopen is supported]) +_LT_DECL([dlopen_self], [enable_dlopen_self], [0], + [Whether dlopen of programs is supported]) +_LT_DECL([dlopen_self_static], [enable_dlopen_self_static], [0], + [Whether dlopen of statically linked programs is supported]) +])# LT_SYS_DLOPEN_SELF + +# Old name: +AU_ALIAS([AC_LIBTOOL_DLOPEN_SELF], [LT_SYS_DLOPEN_SELF]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF], []) + + +# _LT_COMPILER_C_O([TAGNAME]) +# --------------------------- +# Check to see if options -c and -o are simultaneously supported by compiler. +# This macro does not hard code the compiler like AC_PROG_CC_C_O. +m4_defun([_LT_COMPILER_C_O], +[m4_require([_LT_DECL_SED])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_TAG_COMPILER])dnl +AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext], + [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)], + [_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no + $RM -r conftest 2>/dev/null + mkdir conftest + cd conftest + mkdir out + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + lt_compiler_flag="-o out/conftest2.$ac_objext" + # Insert the option either (1) after the last *FLAGS variable, or + # (2) before a word containing "conftest.", or (3) at the end. + # Note that $ac_compile itself does not contain backslashes and begins + # with a dollar sign (not a hyphen), so the echo should work correctly. + lt_compile=`echo "$ac_compile" | $SED \ + -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \ + -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \ + -e 's:$: $lt_compiler_flag:'` + (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$lt_compile" 2>out/conftest.err) + ac_status=$? + cat out/conftest.err >&AS_MESSAGE_LOG_FD + echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD + if (exit $ac_status) && test -s out/conftest2.$ac_objext + then + # The compiler can only warn and ignore the option if not recognized + # So say no if there are warnings + $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp + $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2 + if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then + _LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + fi + fi + chmod u+w . 2>&AS_MESSAGE_LOG_FD + $RM conftest* + # SGI C++ compiler will create directory out/ii_files/ for + # template instantiation + test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files + $RM out/* && rmdir out + cd .. + $RM -r conftest + $RM conftest* +]) +_LT_TAGDECL([compiler_c_o], [lt_cv_prog_compiler_c_o], [1], + [Does compiler simultaneously support -c and -o options?]) +])# _LT_COMPILER_C_O + + +# _LT_COMPILER_FILE_LOCKS([TAGNAME]) +# ---------------------------------- +# Check to see if we can do hard links to lock some files if needed +m4_defun([_LT_COMPILER_FILE_LOCKS], +[m4_require([_LT_ENABLE_LOCK])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +_LT_COMPILER_C_O([$1]) + +hard_links=nottested +if test no = "$_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)" && test no != "$need_locks"; then + # do not overwrite the value of need_locks provided by the user + AC_MSG_CHECKING([if we can lock with hard links]) + hard_links=yes + $RM conftest* + ln conftest.a conftest.b 2>/dev/null && hard_links=no + touch conftest.a + ln conftest.a conftest.b 2>&5 || hard_links=no + ln conftest.a conftest.b 2>/dev/null && hard_links=no + AC_MSG_RESULT([$hard_links]) + if test no = "$hard_links"; then + AC_MSG_WARN(['$CC' does not support '-c -o', so 'make -j' may be unsafe]) + need_locks=warn + fi +else + need_locks=no +fi +_LT_DECL([], [need_locks], [1], [Must we lock files when doing compilation?]) +])# _LT_COMPILER_FILE_LOCKS + + +# _LT_CHECK_OBJDIR +# ---------------- +m4_defun([_LT_CHECK_OBJDIR], +[AC_CACHE_CHECK([for objdir], [lt_cv_objdir], +[rm -f .libs 2>/dev/null +mkdir .libs 2>/dev/null +if test -d .libs; then + lt_cv_objdir=.libs +else + # MS-DOS does not allow filenames that begin with a dot. + lt_cv_objdir=_libs +fi +rmdir .libs 2>/dev/null]) +objdir=$lt_cv_objdir +_LT_DECL([], [objdir], [0], + [The name of the directory that contains temporary libtool files])dnl +m4_pattern_allow([LT_OBJDIR])dnl +AC_DEFINE_UNQUOTED([LT_OBJDIR], "$lt_cv_objdir/", + [Define to the sub-directory where libtool stores uninstalled libraries.]) +])# _LT_CHECK_OBJDIR + + +# _LT_LINKER_HARDCODE_LIBPATH([TAGNAME]) +# -------------------------------------- +# Check hardcoding attributes. +m4_defun([_LT_LINKER_HARDCODE_LIBPATH], +[AC_MSG_CHECKING([how to hardcode library paths into programs]) +_LT_TAGVAR(hardcode_action, $1)= +if test -n "$_LT_TAGVAR(hardcode_libdir_flag_spec, $1)" || + test -n "$_LT_TAGVAR(runpath_var, $1)" || + test yes = "$_LT_TAGVAR(hardcode_automatic, $1)"; then + + # We can hardcode non-existent directories. + if test no != "$_LT_TAGVAR(hardcode_direct, $1)" && + # If the only mechanism to avoid hardcoding is shlibpath_var, we + # have to relink, otherwise we might link with an installed library + # when we should be linking with a yet-to-be-installed one + ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, $1)" && + test no != "$_LT_TAGVAR(hardcode_minus_L, $1)"; then + # Linking always hardcodes the temporary library directory. + _LT_TAGVAR(hardcode_action, $1)=relink + else + # We can link without hardcoding, and we can hardcode nonexisting dirs. + _LT_TAGVAR(hardcode_action, $1)=immediate + fi +else + # We cannot hardcode anything, or else we can only hardcode existing + # directories. + _LT_TAGVAR(hardcode_action, $1)=unsupported +fi +AC_MSG_RESULT([$_LT_TAGVAR(hardcode_action, $1)]) + +if test relink = "$_LT_TAGVAR(hardcode_action, $1)" || + test yes = "$_LT_TAGVAR(inherit_rpath, $1)"; then + # Fast installation is not supported + enable_fast_install=no +elif test yes = "$shlibpath_overrides_runpath" || + test no = "$enable_shared"; then + # Fast installation is not necessary + enable_fast_install=needless +fi +_LT_TAGDECL([], [hardcode_action], [0], + [How to hardcode a shared library path into an executable]) +])# _LT_LINKER_HARDCODE_LIBPATH + + +# _LT_CMD_STRIPLIB +# ---------------- +m4_defun([_LT_CMD_STRIPLIB], +[m4_require([_LT_DECL_EGREP]) +striplib= +old_striplib= +AC_MSG_CHECKING([whether stripping libraries is possible]) +if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then + test -z "$old_striplib" && old_striplib="$STRIP --strip-debug" + test -z "$striplib" && striplib="$STRIP --strip-unneeded" + AC_MSG_RESULT([yes]) +else +# FIXME - insert some real tests, host_os isn't really good enough + case $host_os in + darwin*) + if test -n "$STRIP"; then + striplib="$STRIP -x" + old_striplib="$STRIP -S" + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi + ;; + *) + AC_MSG_RESULT([no]) + ;; + esac +fi +_LT_DECL([], [old_striplib], [1], [Commands to strip libraries]) +_LT_DECL([], [striplib], [1]) +])# _LT_CMD_STRIPLIB + + +# _LT_PREPARE_MUNGE_PATH_LIST +# --------------------------- +# Make sure func_munge_path_list() is defined correctly. +m4_defun([_LT_PREPARE_MUNGE_PATH_LIST], +[[# func_munge_path_list VARIABLE PATH +# ----------------------------------- +# VARIABLE is name of variable containing _space_ separated list of +# directories to be munged by the contents of PATH, which is string +# having a format: +# "DIR[:DIR]:" +# string "DIR[ DIR]" will be prepended to VARIABLE +# ":DIR[:DIR]" +# string "DIR[ DIR]" will be appended to VARIABLE +# "DIRP[:DIRP]::[DIRA:]DIRA" +# string "DIRP[ DIRP]" will be prepended to VARIABLE and string +# "DIRA[ DIRA]" will be appended to VARIABLE +# "DIR[:DIR]" +# VARIABLE will be replaced by "DIR[ DIR]" +func_munge_path_list () +{ + case x@S|@2 in + x) + ;; + *:) + eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'` \@S|@@S|@1\" + ;; + x:*) + eval @S|@1=\"\@S|@@S|@1 `$ECHO @S|@2 | $SED 's/:/ /g'`\" + ;; + *::*) + eval @S|@1=\"\@S|@@S|@1\ `$ECHO @S|@2 | $SED -e 's/.*:://' -e 's/:/ /g'`\" + eval @S|@1=\"`$ECHO @S|@2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \@S|@@S|@1\" + ;; + *) + eval @S|@1=\"`$ECHO @S|@2 | $SED 's/:/ /g'`\" + ;; + esac +} +]])# _LT_PREPARE_PATH_LIST + + +# _LT_SYS_DYNAMIC_LINKER([TAG]) +# ----------------------------- +# PORTME Fill in your ld.so characteristics +m4_defun([_LT_SYS_DYNAMIC_LINKER], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_OBJDUMP])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_CHECK_SHELL_FEATURES])dnl +m4_require([_LT_PREPARE_MUNGE_PATH_LIST])dnl +AC_MSG_CHECKING([dynamic linker characteristics]) +m4_if([$1], + [], [ +if test yes = "$GCC"; then + case $host_os in + darwin*) lt_awk_arg='/^libraries:/,/LR/' ;; + *) lt_awk_arg='/^libraries:/' ;; + esac + case $host_os in + mingw* | cegcc*) lt_sed_strip_eq='s|=\([[A-Za-z]]:\)|\1|g' ;; + *) lt_sed_strip_eq='s|=/|/|g' ;; + esac + lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq` + case $lt_search_path_spec in + *\;*) + # if the path contains ";" then we assume it to be the separator + # otherwise default to the standard path separator (i.e. ":") - it is + # assumed that no part of a normal pathname contains ";" but that should + # okay in the real world where ";" in dirpaths is itself problematic. + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'` + ;; + *) + lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"` + ;; + esac + # Ok, now we have the path, separated by spaces, we can step through it + # and add multilib dir if necessary... + lt_tmp_lt_search_path_spec= + lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null` + # ...but if some path component already ends with the multilib dir we assume + # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer). + case "$lt_multi_os_dir; $lt_search_path_spec " in + "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*) + lt_multi_os_dir= + ;; + esac + for lt_sys_path in $lt_search_path_spec; do + if test -d "$lt_sys_path$lt_multi_os_dir"; then + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir" + elif test -n "$lt_multi_os_dir"; then + test -d "$lt_sys_path" && \ + lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path" + fi + done + lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk ' +BEGIN {RS = " "; FS = "/|\n";} { + lt_foo = ""; + lt_count = 0; + for (lt_i = NF; lt_i > 0; lt_i--) { + if ($lt_i != "" && $lt_i != ".") { + if ($lt_i == "..") { + lt_count++; + } else { + if (lt_count == 0) { + lt_foo = "/" $lt_i lt_foo; + } else { + lt_count--; + } + } + } + } + if (lt_foo != "") { lt_freq[[lt_foo]]++; } + if (lt_freq[[lt_foo]] == 1) { print lt_foo; } +}'` + # AWK program above erroneously prepends '/' to C:/dos/paths + # for these hosts. + case $host_os in + mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\ + $SED 's|/\([[A-Za-z]]:\)|\1|g'` ;; + esac + sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP` +else + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" +fi]) +library_names_spec= +libname_spec='lib$name' +soname_spec= +shrext_cmds=.so +postinstall_cmds= +postuninstall_cmds= +finish_cmds= +finish_eval= +shlibpath_var= +shlibpath_overrides_runpath=unknown +version_type=none +dynamic_linker="$host_os ld.so" +sys_lib_dlsearch_path_spec="/lib /usr/lib" +need_lib_prefix=unknown +hardcode_into_libs=no + +# when you set need_version to no, make sure it does not cause -set_version +# flags to be left without arguments +need_version=unknown + +AC_ARG_VAR([LT_SYS_LIBRARY_PATH], +[User-defined run-time library search path.]) + +case $host_os in +aix3*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname.a' + shlibpath_var=LIBPATH + + # AIX 3 has no versioning support, so we append a major version to the name. + soname_spec='$libname$release$shared_ext$major' + ;; + +aix[[4-9]]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + hardcode_into_libs=yes + if test ia64 = "$host_cpu"; then + # AIX 5 supports IA64 + library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + else + # With GCC up to 2.95.x, collect2 would create an import file + # for dependence libraries. The import file would start with + # the line '#! .'. This would cause the generated library to + # depend on '.', always an invalid library. This was fixed in + # development snapshots of GCC prior to 3.0. + case $host_os in + aix4 | aix4.[[01]] | aix4.[[01]].*) + if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)' + echo ' yes ' + echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then + : + else + can_build_shared=no + fi + ;; + esac + # Using Import Files as archive members, it is possible to support + # filename-based versioning of shared library archives on AIX. While + # this would work for both with and without runtime linking, it will + # prevent static linking of such archives. So we do filename-based + # shared library versioning with .so extension only, which is used + # when both runtime linking and shared linking is enabled. + # Unfortunately, runtime linking may impact performance, so we do + # not want this to be the default eventually. Also, we use the + # versioned .so libs for executables only if there is the -brtl + # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only. + # To allow for filename-based versioning support, we need to create + # libNAME.so.V as an archive file, containing: + # *) an Import File, referring to the versioned filename of the + # archive as well as the shared archive member, telling the + # bitwidth (32 or 64) of that shared object, and providing the + # list of exported symbols of that shared object, eventually + # decorated with the 'weak' keyword + # *) the shared object with the F_LOADONLY flag set, to really avoid + # it being seen by the linker. + # At run time we better use the real file rather than another symlink, + # but for link time we create the symlink libNAME.so -> libNAME.so.V + + case $with_aix_soname,$aix_use_runtimelinking in + # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct + # soname into executable. Probably we can add versioning support to + # collect2, so additional links can be useful in future. + aix,yes) # traditional libtool + dynamic_linker='AIX unversionable lib.so' + # If using run time linking (on AIX 4.2 or later) use lib.so + # instead of lib.a to let people know that these are not + # typical AIX shared libraries. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + ;; + aix,no) # traditional AIX only + dynamic_linker='AIX lib.a[(]lib.so.V[)]' + # We preserve .a as extension for shared libraries through AIX4.2 + # and later when we are not doing run time linking. + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + ;; + svr4,*) # full svr4 only + dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)]" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,yes) # both, prefer svr4 + dynamic_linker="AIX lib.so.V[(]$shared_archive_member_spec.o[)], lib.a[(]lib.so.V[)]" + library_names_spec='$libname$release$shared_ext$major $libname$shared_ext' + # unpreferred sharedlib libNAME.a needs extra handling + postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"' + postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"' + # We do not specify a path in Import Files, so LIBPATH fires. + shlibpath_overrides_runpath=yes + ;; + *,no) # both, prefer aix + dynamic_linker="AIX lib.a[(]lib.so.V[)], lib.so.V[(]$shared_archive_member_spec.o[)]" + library_names_spec='$libname$release.a $libname.a' + soname_spec='$libname$release$shared_ext$major' + # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling + postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)' + postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"' + ;; + esac + shlibpath_var=LIBPATH + fi + ;; + +amigaos*) + case $host_cpu in + powerpc) + # Since July 2007 AmigaOS4 officially supports .so libraries. + # When compiling the executable, add -use-dynld -Lsobjs: to the compileline. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + ;; + m68k) + library_names_spec='$libname.ixlibrary $libname.a' + # Create ${libname}_ixlibrary.a entries in /sys/libs. + finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done' + ;; + esac + ;; + +beos*) + library_names_spec='$libname$shared_ext' + dynamic_linker="$host_os ld.so" + shlibpath_var=LIBRARY_PATH + ;; + +bsdi[[45]]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib" + sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib" + # the default ld.so.conf also contains /usr/contrib/lib and + # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow + # libtool to hard-code these into programs + ;; + +cygwin* | mingw* | pw32* | cegcc*) + version_type=windows + shrext_cmds=.dll + need_version=no + need_lib_prefix=no + + case $GCC,$cc_basename in + yes,*) + # gcc + library_names_spec='$libname.dll.a' + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + + case $host_os in + cygwin*) + # Cygwin DLLs use 'cyg' prefix rather than 'lib' + soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' +m4_if([$1], [],[ + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"]) + ;; + mingw* | cegcc*) + # MinGW DLLs use traditional 'lib' prefix + soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' + ;; + pw32*) + # pw32 DLLs use 'pw' prefix rather than 'lib' + library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' + ;; + esac + dynamic_linker='Win32 ld.exe' + ;; + + *,cl*) + # Native MSVC + libname_spec='$name' + soname_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext' + library_names_spec='$libname.dll.lib' + + case $build_os in + mingw*) + sys_lib_search_path_spec= + lt_save_ifs=$IFS + IFS=';' + for lt_path in $LIB + do + IFS=$lt_save_ifs + # Let DOS variable expansion print the short 8.3 style file name. + lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"` + sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path" + done + IFS=$lt_save_ifs + # Convert to MSYS style. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([[a-zA-Z]]\\):| /\\1|g' -e 's|^ ||'` + ;; + cygwin*) + # Convert to unix form, then to dos form, then back to unix form + # but this time dos style (no spaces!) so that the unix form looks + # like /cygdrive/c/PROGRA~1:/cygdr... + sys_lib_search_path_spec=`cygpath --path --unix "$LIB"` + sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null` + sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + ;; + *) + sys_lib_search_path_spec=$LIB + if $ECHO "$sys_lib_search_path_spec" | [$GREP ';[c-zC-Z]:/' >/dev/null]; then + # It is most probably a Windows format PATH. + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'` + else + sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"` + fi + # FIXME: find the short name or the path components, as spaces are + # common. (e.g. "Program Files" -> "PROGRA~1") + ;; + esac + + # DLL is installed to $(libdir)/../bin by postinstall_cmds + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + shlibpath_overrides_runpath=yes + dynamic_linker='Win32 link.exe' + ;; + + *) + # Assume MSVC wrapper + library_names_spec='$libname`echo $release | $SED -e 's/[[.]]/-/g'`$versuffix$shared_ext $libname.lib' + dynamic_linker='Win32 ld.exe' + ;; + esac + # FIXME: first we should search . and the directory the executable is in + shlibpath_var=PATH + ;; + +darwin* | rhapsody*) + dynamic_linker="$host_os dyld" + version_type=darwin + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$major$shared_ext $libname$shared_ext' + soname_spec='$libname$release$major$shared_ext' + shlibpath_overrides_runpath=yes + shlibpath_var=DYLD_LIBRARY_PATH + shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`' +m4_if([$1], [],[ + sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"]) + sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib' + ;; + +dgux*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +freebsd* | dragonfly*) + # DragonFly does not have aout. When/if they implement a new + # versioning mechanism, adjust this. + if test -x /usr/bin/objformat; then + objformat=`/usr/bin/objformat` + else + case $host_os in + freebsd[[23]].*) objformat=aout ;; + *) objformat=elf ;; + esac + fi + version_type=freebsd-$objformat + case $version_type in + freebsd-elf*) + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + need_version=no + need_lib_prefix=no + ;; + freebsd-*) + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + need_version=yes + ;; + esac + shlibpath_var=LD_LIBRARY_PATH + case $host_os in + freebsd2.*) + shlibpath_overrides_runpath=yes + ;; + freebsd3.[[01]]* | freebsdelf3.[[01]]*) + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + freebsd3.[[2-9]]* | freebsdelf3.[[2-9]]* | \ + freebsd4.[[0-5]] | freebsdelf4.[[0-5]] | freebsd4.1.1 | freebsdelf4.1.1) + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + *) # from 4.6 on, and DragonFly + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + esac + ;; + +haiku*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + dynamic_linker="$host_os runtime_loader" + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LIBRARY_PATH + shlibpath_overrides_runpath=no + sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib' + hardcode_into_libs=yes + ;; + +hpux9* | hpux10* | hpux11*) + # Give a soname corresponding to the major version so that dld.sl refuses to + # link against other versions. + version_type=sunos + need_lib_prefix=no + need_version=no + case $host_cpu in + ia64*) + shrext_cmds='.so' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.so" + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + if test 32 = "$HPUX_IA64_MODE"; then + sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib" + sys_lib_dlsearch_path_spec=/usr/lib/hpux32 + else + sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64" + sys_lib_dlsearch_path_spec=/usr/lib/hpux64 + fi + ;; + hppa*64*) + shrext_cmds='.sl' + hardcode_into_libs=yes + dynamic_linker="$host_os dld.sl" + shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH + shlibpath_overrides_runpath=yes # Unless +noenvvar is specified. + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + *) + shrext_cmds='.sl' + dynamic_linker="$host_os dld.sl" + shlibpath_var=SHLIB_PATH + shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + ;; + esac + # HP-UX runs *really* slowly unless shared libraries are mode 555, ... + postinstall_cmds='chmod 555 $lib' + # or fails outright, so override atomically: + install_override_mode=555 + ;; + +interix[[3-9]]*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +irix5* | irix6* | nonstopux*) + case $host_os in + nonstopux*) version_type=nonstopux ;; + *) + if test yes = "$lt_cv_prog_gnu_ld"; then + version_type=linux # correct to gnu/linux during the next big refactor + else + version_type=irix + fi ;; + esac + need_lib_prefix=no + need_version=no + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext' + case $host_os in + irix5* | nonstopux*) + libsuff= shlibsuff= + ;; + *) + case $LD in # libtool.m4 will add one of these switches to LD + *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") + libsuff= shlibsuff= libmagic=32-bit;; + *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") + libsuff=32 shlibsuff=N32 libmagic=N32;; + *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") + libsuff=64 shlibsuff=64 libmagic=64-bit;; + *) libsuff= shlibsuff= libmagic=never-match;; + esac + ;; + esac + shlibpath_var=LD_LIBRARY${shlibsuff}_PATH + shlibpath_overrides_runpath=no + sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff" + sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff" + hardcode_into_libs=yes + ;; + +# No shared lib support for Linux oldld, aout, or coff. +linux*oldld* | linux*aout* | linux*coff*) + dynamic_linker=no + ;; + +linux*android*) + version_type=none # Android doesn't support versioned libraries. + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext' + soname_spec='$libname$release$shared_ext' + finish_cmds= + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + dynamic_linker='Android linker' + # Don't embed -rpath directories since the linker doesn't support them. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + ;; + +# This must be glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + + # Some binutils ld are patched to set DT_RUNPATH + AC_CACHE_VAL([lt_cv_shlibpath_overrides_runpath], + [lt_cv_shlibpath_overrides_runpath=no + save_LDFLAGS=$LDFLAGS + save_libdir=$libdir + eval "libdir=/foo; wl=\"$_LT_TAGVAR(lt_prog_compiler_wl, $1)\"; \ + LDFLAGS=\"\$LDFLAGS $_LT_TAGVAR(hardcode_libdir_flag_spec, $1)\"" + AC_LINK_IFELSE([AC_LANG_PROGRAM([],[])], + [AS_IF([ ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null], + [lt_cv_shlibpath_overrides_runpath=yes])]) + LDFLAGS=$save_LDFLAGS + libdir=$save_libdir + ]) + shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath + + # This implies no fast_install, which is unacceptable. + # Some rework will be needed to allow for fast_install + # before this can be enabled. + hardcode_into_libs=yes + + # Ideally, we could use ldconfig to report *all* directores which are + # searched for libraries, however this is still not possible. Aside from not + # being certain /sbin/ldconfig is available, command + # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64, + # even though it is searched at run-time. Try to do the best guess by + # appending ld.so.conf contents (and includes) to the search path. + if test -f /etc/ld.so.conf; then + lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '` + sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra" + fi + + # We used to test for /lib/ld.so.1 and disable shared libraries on + # powerpc, because MkLinux only supported shared libraries with the + # GNU dynamic linker. Since this was broken with cross compilers, + # most powerpc-linux boxes support dynamic linking these days and + # people can always --disable-shared, the test was removed, and we + # assume the GNU/Linux dynamic linker is in use. + dynamic_linker='GNU/Linux ld.so' + ;; + +netbsdelf*-gnu) + version_type=linux + need_lib_prefix=no + need_version=no + library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}' + soname_spec='${libname}${release}${shared_ext}$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='NetBSD ld.elf_so' + ;; + +netbsd*) + version_type=sunos + need_lib_prefix=no + need_version=no + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + dynamic_linker='NetBSD (a.out) ld.so' + else + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + dynamic_linker='NetBSD ld.elf_so' + fi + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + ;; + +newsos6) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +*nto* | *qnx*) + version_type=qnx + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + dynamic_linker='ldqnx.so' + ;; + +openbsd* | bitrig*) + version_type=sunos + sys_lib_dlsearch_path_spec=/usr/lib + need_lib_prefix=no + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + need_version=no + else + need_version=yes + fi + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + ;; + +os2*) + libname_spec='$name' + version_type=windows + shrext_cmds=.dll + need_version=no + need_lib_prefix=no + # OS/2 can only load a DLL with a base name of 8 characters or less. + soname_spec='`test -n "$os2dllname" && libname="$os2dllname"; + v=$($ECHO $release$versuffix | tr -d .-); + n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _); + $ECHO $n$v`$shared_ext' + library_names_spec='${libname}_dll.$libext' + dynamic_linker='OS/2 ld.exe' + shlibpath_var=BEGINLIBPATH + sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + postinstall_cmds='base_file=`basename \$file`~ + dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~ + dldir=$destdir/`dirname \$dlpath`~ + test -d \$dldir || mkdir -p \$dldir~ + $install_prog $dir/$dlname \$dldir/$dlname~ + chmod a+x \$dldir/$dlname~ + if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then + eval '\''$striplib \$dldir/$dlname'\'' || exit \$?; + fi' + postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~ + dlpath=$dir/\$dldll~ + $RM \$dlpath' + ;; + +osf3* | osf4* | osf5*) + version_type=osf + need_lib_prefix=no + need_version=no + soname_spec='$libname$release$shared_ext$major' + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib" + sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec + ;; + +rdos*) + dynamic_linker=no + ;; + +solaris*) + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + # ldd complains unless libraries are executable + postinstall_cmds='chmod +x $lib' + ;; + +sunos4*) + version_type=sunos + library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix' + finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + if test yes = "$with_gnu_ld"; then + need_lib_prefix=no + fi + need_version=yes + ;; + +sysv4 | sysv4.3*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + case $host_vendor in + sni) + shlibpath_overrides_runpath=no + need_lib_prefix=no + runpath_var=LD_RUN_PATH + ;; + siemens) + need_lib_prefix=no + ;; + motorola) + need_lib_prefix=no + need_version=no + shlibpath_overrides_runpath=no + sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib' + ;; + esac + ;; + +sysv4*MP*) + if test -d /usr/nec; then + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext' + soname_spec='$libname$shared_ext.$major' + shlibpath_var=LD_LIBRARY_PATH + fi + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + version_type=sco + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=yes + hardcode_into_libs=yes + if test yes = "$with_gnu_ld"; then + sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib' + else + sys_lib_search_path_spec='/usr/ccs/lib /usr/lib' + case $host_os in + sco3.2v5*) + sys_lib_search_path_spec="$sys_lib_search_path_spec /lib" + ;; + esac + fi + sys_lib_dlsearch_path_spec='/usr/lib' + ;; + +tpf*) + # TPF is a cross-target only. Preferred cross-host = GNU/Linux. + version_type=linux # correct to gnu/linux during the next big refactor + need_lib_prefix=no + need_version=no + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + shlibpath_var=LD_LIBRARY_PATH + shlibpath_overrides_runpath=no + hardcode_into_libs=yes + ;; + +uts4*) + version_type=linux # correct to gnu/linux during the next big refactor + library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext' + soname_spec='$libname$release$shared_ext$major' + shlibpath_var=LD_LIBRARY_PATH + ;; + +*) + dynamic_linker=no + ;; +esac +AC_MSG_RESULT([$dynamic_linker]) +test no = "$dynamic_linker" && can_build_shared=no + +variables_saved_for_relink="PATH $shlibpath_var $runpath_var" +if test yes = "$GCC"; then + variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH" +fi + +if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then + sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec +fi + +if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then + sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec +fi + +# remember unaugmented sys_lib_dlsearch_path content for libtool script decls... +configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec + +# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code +func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH" + +# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool +configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH + +_LT_DECL([], [variables_saved_for_relink], [1], + [Variables whose values should be saved in libtool wrapper scripts and + restored at link time]) +_LT_DECL([], [need_lib_prefix], [0], + [Do we need the "lib" prefix for modules?]) +_LT_DECL([], [need_version], [0], [Do we need a version for libraries?]) +_LT_DECL([], [version_type], [0], [Library versioning type]) +_LT_DECL([], [runpath_var], [0], [Shared library runtime path variable]) +_LT_DECL([], [shlibpath_var], [0],[Shared library path variable]) +_LT_DECL([], [shlibpath_overrides_runpath], [0], + [Is shlibpath searched before the hard-coded library search path?]) +_LT_DECL([], [libname_spec], [1], [Format of library name prefix]) +_LT_DECL([], [library_names_spec], [1], + [[List of archive names. First name is the real one, the rest are links. + The last name is the one that the linker finds with -lNAME]]) +_LT_DECL([], [soname_spec], [1], + [[The coded name of the library, if different from the real name]]) +_LT_DECL([], [install_override_mode], [1], + [Permission mode override for installation of shared libraries]) +_LT_DECL([], [postinstall_cmds], [2], + [Command to use after installation of a shared archive]) +_LT_DECL([], [postuninstall_cmds], [2], + [Command to use after uninstallation of a shared archive]) +_LT_DECL([], [finish_cmds], [2], + [Commands used to finish a libtool library installation in a directory]) +_LT_DECL([], [finish_eval], [1], + [[As "finish_cmds", except a single script fragment to be evaled but + not shown]]) +_LT_DECL([], [hardcode_into_libs], [0], + [Whether we should hardcode library paths into libraries]) +_LT_DECL([], [sys_lib_search_path_spec], [2], + [Compile-time system search path for libraries]) +_LT_DECL([sys_lib_dlsearch_path_spec], [configure_time_dlsearch_path], [2], + [Detected run-time system search path for libraries]) +_LT_DECL([], [configure_time_lt_sys_library_path], [2], + [Explicit LT_SYS_LIBRARY_PATH set during ./configure time]) +])# _LT_SYS_DYNAMIC_LINKER + + +# _LT_PATH_TOOL_PREFIX(TOOL) +# -------------------------- +# find a file program that can recognize shared library +AC_DEFUN([_LT_PATH_TOOL_PREFIX], +[m4_require([_LT_DECL_EGREP])dnl +AC_MSG_CHECKING([for $1]) +AC_CACHE_VAL(lt_cv_path_MAGIC_CMD, +[case $MAGIC_CMD in +[[\\/*] | ?:[\\/]*]) + lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path. + ;; +*) + lt_save_MAGIC_CMD=$MAGIC_CMD + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR +dnl $ac_dummy forces splitting on constant user-supplied paths. +dnl POSIX.2 word splitting is done only on the output of word expansions, +dnl not every word. This closes a longstanding sh security hole. + ac_dummy="m4_if([$2], , $PATH, [$2])" + for ac_dir in $ac_dummy; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$1"; then + lt_cv_path_MAGIC_CMD=$ac_dir/"$1" + if test -n "$file_magic_test_file"; then + case $deplibs_check_method in + "file_magic "*) + file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"` + MAGIC_CMD=$lt_cv_path_MAGIC_CMD + if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null | + $EGREP "$file_magic_regex" > /dev/null; then + : + else + cat <<_LT_EOF 1>&2 + +*** Warning: the command libtool uses to detect shared libraries, +*** $file_magic_cmd, produces output that libtool cannot recognize. +*** The result is that libtool may fail to recognize shared libraries +*** as such. This will affect the creation of libtool libraries that +*** depend on shared libraries, but programs linked with such libtool +*** libraries will work regardless of this problem. Nevertheless, you +*** may want to report the problem to your system manager and/or to +*** bug-libtool@gnu.org + +_LT_EOF + fi ;; + esac + fi + break + fi + done + IFS=$lt_save_ifs + MAGIC_CMD=$lt_save_MAGIC_CMD + ;; +esac]) +MAGIC_CMD=$lt_cv_path_MAGIC_CMD +if test -n "$MAGIC_CMD"; then + AC_MSG_RESULT($MAGIC_CMD) +else + AC_MSG_RESULT(no) +fi +_LT_DECL([], [MAGIC_CMD], [0], + [Used to examine libraries when file_magic_cmd begins with "file"])dnl +])# _LT_PATH_TOOL_PREFIX + +# Old name: +AU_ALIAS([AC_PATH_TOOL_PREFIX], [_LT_PATH_TOOL_PREFIX]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_PATH_TOOL_PREFIX], []) + + +# _LT_PATH_MAGIC +# -------------- +# find a file program that can recognize a shared library +m4_defun([_LT_PATH_MAGIC], +[_LT_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH) +if test -z "$lt_cv_path_MAGIC_CMD"; then + if test -n "$ac_tool_prefix"; then + _LT_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH) + else + MAGIC_CMD=: + fi +fi +])# _LT_PATH_MAGIC + + +# LT_PATH_LD +# ---------- +# find the pathname to the GNU or non-GNU linker +AC_DEFUN([LT_PATH_LD], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_PROG_ECHO_BACKSLASH])dnl + +AC_ARG_WITH([gnu-ld], + [AS_HELP_STRING([--with-gnu-ld], + [assume the C compiler uses GNU ld @<:@default=no@:>@])], + [test no = "$withval" || with_gnu_ld=yes], + [with_gnu_ld=no])dnl + +ac_prog=ld +if test yes = "$GCC"; then + # Check if gcc -print-prog-name=ld gives a path. + AC_MSG_CHECKING([for ld used by $CC]) + case $host in + *-*-mingw*) + # gcc leaves a trailing carriage return, which upsets mingw + ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;; + *) + ac_prog=`($CC -print-prog-name=ld) 2>&5` ;; + esac + case $ac_prog in + # Accept absolute paths. + [[\\/]]* | ?:[[\\/]]*) + re_direlt='/[[^/]][[^/]]*/\.\./' + # Canonicalize the pathname of ld + ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'` + while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do + ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"` + done + test -z "$LD" && LD=$ac_prog + ;; + "") + # If it fails, then pretend we aren't using GCC. + ac_prog=ld + ;; + *) + # If it is relative, then search for the first ld in PATH. + with_gnu_ld=unknown + ;; + esac +elif test yes = "$with_gnu_ld"; then + AC_MSG_CHECKING([for GNU ld]) +else + AC_MSG_CHECKING([for non-GNU ld]) +fi +AC_CACHE_VAL(lt_cv_path_LD, +[if test -z "$LD"; then + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR + for ac_dir in $PATH; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then + lt_cv_path_LD=$ac_dir/$ac_prog + # Check to see if the program is GNU ld. I'd rather use --version, + # but apparently some variants of GNU ld only accept -v. + # Break only if it was the GNU/non-GNU ld that we prefer. + case `"$lt_cv_path_LD" -v 2>&1 &1 conftest.i +cat conftest.i conftest.i >conftest2.i +: ${lt_DD:=$DD} +AC_PATH_PROGS_FEATURE_CHECK([lt_DD], [dd], +[if "$ac_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then + cmp -s conftest.i conftest.out \ + && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=: +fi]) +rm -f conftest.i conftest2.i conftest.out]) +])# _LT_PATH_DD + + +# _LT_CMD_TRUNCATE +# ---------------- +# find command to truncate a binary pipe +m4_defun([_LT_CMD_TRUNCATE], +[m4_require([_LT_PATH_DD]) +AC_CACHE_CHECK([how to truncate binary pipes], [lt_cv_truncate_bin], +[printf 0123456789abcdef0123456789abcdef >conftest.i +cat conftest.i conftest.i >conftest2.i +lt_cv_truncate_bin= +if "$ac_cv_path_lt_DD" bs=32 count=1 conftest.out 2>/dev/null; then + cmp -s conftest.i conftest.out \ + && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1" +fi +rm -f conftest.i conftest2.i conftest.out +test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q"]) +_LT_DECL([lt_truncate_bin], [lt_cv_truncate_bin], [1], + [Command to truncate a binary pipe]) +])# _LT_CMD_TRUNCATE + + +# _LT_CHECK_MAGIC_METHOD +# ---------------------- +# how to check for library dependencies +# -- PORTME fill in with the dynamic library characteristics +m4_defun([_LT_CHECK_MAGIC_METHOD], +[m4_require([_LT_DECL_EGREP]) +m4_require([_LT_DECL_OBJDUMP]) +AC_CACHE_CHECK([how to recognize dependent libraries], +lt_cv_deplibs_check_method, +[lt_cv_file_magic_cmd='$MAGIC_CMD' +lt_cv_file_magic_test_file= +lt_cv_deplibs_check_method='unknown' +# Need to set the preceding variable on all platforms that support +# interlibrary dependencies. +# 'none' -- dependencies not supported. +# 'unknown' -- same as none, but documents that we really don't know. +# 'pass_all' -- all dependencies passed with no checks. +# 'test_compile' -- check by making test program. +# 'file_magic [[regex]]' -- check by looking for files in library path +# that responds to the $file_magic_cmd with a given extended regex. +# If you have 'file' or equivalent on your system and you're not sure +# whether 'pass_all' will *always* work, you probably want this one. + +case $host_os in +aix[[4-9]]*) + lt_cv_deplibs_check_method=pass_all + ;; + +beos*) + lt_cv_deplibs_check_method=pass_all + ;; + +bsdi[[45]]*) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)' + lt_cv_file_magic_cmd='/usr/bin/file -L' + lt_cv_file_magic_test_file=/shlib/libc.so + ;; + +cygwin*) + # func_win32_libid is a shell function defined in ltmain.sh + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + ;; + +mingw* | pw32*) + # Base MSYS/MinGW do not provide the 'file' command needed by + # func_win32_libid shell function, so use a weaker test based on 'objdump', + # unless we find 'file', for example because we are cross-compiling. + if ( file / ) >/dev/null 2>&1; then + lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL' + lt_cv_file_magic_cmd='func_win32_libid' + else + # Keep this pattern in sync with the one in func_win32_libid. + lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' + lt_cv_file_magic_cmd='$OBJDUMP -f' + fi + ;; + +cegcc*) + # use the weaker test based on 'objdump'. See mingw*. + lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?' + lt_cv_file_magic_cmd='$OBJDUMP -f' + ;; + +darwin* | rhapsody*) + lt_cv_deplibs_check_method=pass_all + ;; + +freebsd* | dragonfly*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + case $host_cpu in + i*86 ) + # Not sure whether the presence of OpenBSD here was a mistake. + # Let's accept both of them until this is cleared up. + lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` + ;; + esac + else + lt_cv_deplibs_check_method=pass_all + fi + ;; + +haiku*) + lt_cv_deplibs_check_method=pass_all + ;; + +hpux10.20* | hpux11*) + lt_cv_file_magic_cmd=/usr/bin/file + case $host_cpu in + ia64*) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64' + lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so + ;; + hppa*64*) + [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'] + lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl + ;; + *) + lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]]\.[[0-9]]) shared library' + lt_cv_file_magic_test_file=/usr/lib/libc.sl + ;; + esac + ;; + +interix[[3-9]]*) + # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|\.a)$' + ;; + +irix5* | irix6* | nonstopux*) + case $LD in + *-32|*"-32 ") libmagic=32-bit;; + *-n32|*"-n32 ") libmagic=N32;; + *-64|*"-64 ") libmagic=64-bit;; + *) libmagic=never-match;; + esac + lt_cv_deplibs_check_method=pass_all + ;; + +# This must be glibc/ELF. +linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + lt_cv_deplibs_check_method=pass_all + ;; + +netbsd* | netbsdelf*-gnu) + if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$' + fi + ;; + +newos6*) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)' + lt_cv_file_magic_cmd=/usr/bin/file + lt_cv_file_magic_test_file=/usr/lib/libnls.so + ;; + +*nto* | *qnx*) + lt_cv_deplibs_check_method=pass_all + ;; + +openbsd* | bitrig*) + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$' + else + lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$' + fi + ;; + +osf3* | osf4* | osf5*) + lt_cv_deplibs_check_method=pass_all + ;; + +rdos*) + lt_cv_deplibs_check_method=pass_all + ;; + +solaris*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*) + lt_cv_deplibs_check_method=pass_all + ;; + +sysv4 | sysv4.3*) + case $host_vendor in + motorola) + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]' + lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*` + ;; + ncr) + lt_cv_deplibs_check_method=pass_all + ;; + sequent) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )' + ;; + sni) + lt_cv_file_magic_cmd='/bin/file' + lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib" + lt_cv_file_magic_test_file=/lib/libc.so + ;; + siemens) + lt_cv_deplibs_check_method=pass_all + ;; + pc) + lt_cv_deplibs_check_method=pass_all + ;; + esac + ;; + +tpf*) + lt_cv_deplibs_check_method=pass_all + ;; +os2*) + lt_cv_deplibs_check_method=pass_all + ;; +esac +]) + +file_magic_glob= +want_nocaseglob=no +if test "$build" = "$host"; then + case $host_os in + mingw* | pw32*) + if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then + want_nocaseglob=yes + else + file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[[\1]]\/[[\1]]\/g;/g"` + fi + ;; + esac +fi + +file_magic_cmd=$lt_cv_file_magic_cmd +deplibs_check_method=$lt_cv_deplibs_check_method +test -z "$deplibs_check_method" && deplibs_check_method=unknown + +_LT_DECL([], [deplibs_check_method], [1], + [Method to check whether dependent libraries are shared objects]) +_LT_DECL([], [file_magic_cmd], [1], + [Command to use when deplibs_check_method = "file_magic"]) +_LT_DECL([], [file_magic_glob], [1], + [How to find potential files when deplibs_check_method = "file_magic"]) +_LT_DECL([], [want_nocaseglob], [1], + [Find potential files using nocaseglob when deplibs_check_method = "file_magic"]) +])# _LT_CHECK_MAGIC_METHOD + + +# LT_PATH_NM +# ---------- +# find the pathname to a BSD- or MS-compatible name lister +AC_DEFUN([LT_PATH_NM], +[AC_REQUIRE([AC_PROG_CC])dnl +AC_CACHE_CHECK([for BSD- or MS-compatible name lister (nm)], lt_cv_path_NM, +[if test -n "$NM"; then + # Let the user override the test. + lt_cv_path_NM=$NM +else + lt_nm_to_check=${ac_tool_prefix}nm + if test -n "$ac_tool_prefix" && test "$build" = "$host"; then + lt_nm_to_check="$lt_nm_to_check nm" + fi + for lt_tmp_nm in $lt_nm_to_check; do + lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR + for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do + IFS=$lt_save_ifs + test -z "$ac_dir" && ac_dir=. + tmp_nm=$ac_dir/$lt_tmp_nm + if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then + # Check to see if the nm accepts a BSD-compat flag. + # Adding the 'sed 1q' prevents false positives on HP-UX, which says: + # nm: unknown option "B" ignored + # Tru64's nm complains that /dev/null is an invalid object file + # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty + case $build_os in + mingw*) lt_bad_file=conftest.nm/nofile ;; + *) lt_bad_file=/dev/null ;; + esac + case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in + *$lt_bad_file* | *'Invalid file or object type'*) + lt_cv_path_NM="$tmp_nm -B" + break 2 + ;; + *) + case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in + */dev/null*) + lt_cv_path_NM="$tmp_nm -p" + break 2 + ;; + *) + lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but + continue # so that we can try to find one that supports BSD flags + ;; + esac + ;; + esac + fi + done + IFS=$lt_save_ifs + done + : ${lt_cv_path_NM=no} +fi]) +if test no != "$lt_cv_path_NM"; then + NM=$lt_cv_path_NM +else + # Didn't find any BSD compatible name lister, look for dumpbin. + if test -n "$DUMPBIN"; then : + # Let the user override the test. + else + AC_CHECK_TOOLS(DUMPBIN, [dumpbin "link -dump"], :) + case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in + *COFF*) + DUMPBIN="$DUMPBIN -symbols -headers" + ;; + *) + DUMPBIN=: + ;; + esac + fi + AC_SUBST([DUMPBIN]) + if test : != "$DUMPBIN"; then + NM=$DUMPBIN + fi +fi +test -z "$NM" && NM=nm +AC_SUBST([NM]) +_LT_DECL([], [NM], [1], [A BSD- or MS-compatible name lister])dnl + +AC_CACHE_CHECK([the name lister ($NM) interface], [lt_cv_nm_interface], + [lt_cv_nm_interface="BSD nm" + echo "int some_variable = 0;" > conftest.$ac_ext + (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&AS_MESSAGE_LOG_FD) + (eval "$ac_compile" 2>conftest.err) + cat conftest.err >&AS_MESSAGE_LOG_FD + (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&AS_MESSAGE_LOG_FD) + (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out) + cat conftest.err >&AS_MESSAGE_LOG_FD + (eval echo "\"\$as_me:$LINENO: output\"" >&AS_MESSAGE_LOG_FD) + cat conftest.out >&AS_MESSAGE_LOG_FD + if $GREP 'External.*some_variable' conftest.out > /dev/null; then + lt_cv_nm_interface="MS dumpbin" + fi + rm -f conftest*]) +])# LT_PATH_NM + +# Old names: +AU_ALIAS([AM_PROG_NM], [LT_PATH_NM]) +AU_ALIAS([AC_PROG_NM], [LT_PATH_NM]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_PROG_NM], []) +dnl AC_DEFUN([AC_PROG_NM], []) + +# _LT_CHECK_SHAREDLIB_FROM_LINKLIB +# -------------------------------- +# how to determine the name of the shared library +# associated with a specific link library. +# -- PORTME fill in with the dynamic library characteristics +m4_defun([_LT_CHECK_SHAREDLIB_FROM_LINKLIB], +[m4_require([_LT_DECL_EGREP]) +m4_require([_LT_DECL_OBJDUMP]) +m4_require([_LT_DECL_DLLTOOL]) +AC_CACHE_CHECK([how to associate runtime and link libraries], +lt_cv_sharedlib_from_linklib_cmd, +[lt_cv_sharedlib_from_linklib_cmd='unknown' + +case $host_os in +cygwin* | mingw* | pw32* | cegcc*) + # two different shell functions defined in ltmain.sh; + # decide which one to use based on capabilities of $DLLTOOL + case `$DLLTOOL --help 2>&1` in + *--identify-strict*) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib + ;; + *) + lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback + ;; + esac + ;; +*) + # fallback: assume linklib IS sharedlib + lt_cv_sharedlib_from_linklib_cmd=$ECHO + ;; +esac +]) +sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd +test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO + +_LT_DECL([], [sharedlib_from_linklib_cmd], [1], + [Command to associate shared and link libraries]) +])# _LT_CHECK_SHAREDLIB_FROM_LINKLIB + + +# _LT_PATH_MANIFEST_TOOL +# ---------------------- +# locate the manifest tool +m4_defun([_LT_PATH_MANIFEST_TOOL], +[AC_CHECK_TOOL(MANIFEST_TOOL, mt, :) +test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt +AC_CACHE_CHECK([if $MANIFEST_TOOL is a manifest tool], [lt_cv_path_mainfest_tool], + [lt_cv_path_mainfest_tool=no + echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&AS_MESSAGE_LOG_FD + $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out + cat conftest.err >&AS_MESSAGE_LOG_FD + if $GREP 'Manifest Tool' conftest.out > /dev/null; then + lt_cv_path_mainfest_tool=yes + fi + rm -f conftest*]) +if test yes != "$lt_cv_path_mainfest_tool"; then + MANIFEST_TOOL=: +fi +_LT_DECL([], [MANIFEST_TOOL], [1], [Manifest tool])dnl +])# _LT_PATH_MANIFEST_TOOL + + +# _LT_DLL_DEF_P([FILE]) +# --------------------- +# True iff FILE is a Windows DLL '.def' file. +# Keep in sync with func_dll_def_p in the libtool script +AC_DEFUN([_LT_DLL_DEF_P], +[dnl + test DEF = "`$SED -n dnl + -e '\''s/^[[ ]]*//'\'' dnl Strip leading whitespace + -e '\''/^\(;.*\)*$/d'\'' dnl Delete empty lines and comments + -e '\''s/^\(EXPORTS\|LIBRARY\)\([[ ]].*\)*$/DEF/p'\'' dnl + -e q dnl Only consider the first "real" line + $1`" dnl +])# _LT_DLL_DEF_P + + +# LT_LIB_M +# -------- +# check for math library +AC_DEFUN([LT_LIB_M], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +LIBM= +case $host in +*-*-beos* | *-*-cegcc* | *-*-cygwin* | *-*-haiku* | *-*-pw32* | *-*-darwin*) + # These system don't have libm, or don't need it + ;; +*-ncr-sysv4.3*) + AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM=-lmw) + AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm") + ;; +*) + AC_CHECK_LIB(m, cos, LIBM=-lm) + ;; +esac +AC_SUBST([LIBM]) +])# LT_LIB_M + +# Old name: +AU_ALIAS([AC_CHECK_LIBM], [LT_LIB_M]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_CHECK_LIBM], []) + + +# _LT_COMPILER_NO_RTTI([TAGNAME]) +# ------------------------------- +m4_defun([_LT_COMPILER_NO_RTTI], +[m4_require([_LT_TAG_COMPILER])dnl + +_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + +if test yes = "$GCC"; then + case $cc_basename in + nvcc*) + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -Xcompiler -fno-builtin' ;; + *) + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' ;; + esac + + _LT_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions], + lt_cv_prog_compiler_rtti_exceptions, + [-fno-rtti -fno-exceptions], [], + [_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"]) +fi +_LT_TAGDECL([no_builtin_flag], [lt_prog_compiler_no_builtin_flag], [1], + [Compiler flag to turn off builtin functions]) +])# _LT_COMPILER_NO_RTTI + + +# _LT_CMD_GLOBAL_SYMBOLS +# ---------------------- +m4_defun([_LT_CMD_GLOBAL_SYMBOLS], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_AWK])dnl +AC_REQUIRE([LT_PATH_NM])dnl +AC_REQUIRE([LT_PATH_LD])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_TAG_COMPILER])dnl + +# Check for command to grab the raw symbol name followed by C symbol from nm. +AC_MSG_CHECKING([command to parse $NM output from $compiler object]) +AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe], +[ +# These are sane defaults that work on at least a few old systems. +# [They come from Ultrix. What could be older than Ultrix?!! ;)] + +# Character class describing NM global symbol codes. +symcode='[[BCDEGRST]]' + +# Regexp to match symbols that can be accessed directly from C. +sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)' + +# Define system-specific variables. +case $host_os in +aix*) + symcode='[[BCDT]]' + ;; +cygwin* | mingw* | pw32* | cegcc*) + symcode='[[ABCDGISTW]]' + ;; +hpux*) + if test ia64 = "$host_cpu"; then + symcode='[[ABCDEGRST]]' + fi + ;; +irix* | nonstopux*) + symcode='[[BCDEGRST]]' + ;; +osf*) + symcode='[[BCDEGQRST]]' + ;; +solaris*) + symcode='[[BDRT]]' + ;; +sco3.2v5*) + symcode='[[DT]]' + ;; +sysv4.2uw2*) + symcode='[[DT]]' + ;; +sysv5* | sco5v6* | unixware* | OpenUNIX*) + symcode='[[ABDT]]' + ;; +sysv4) + symcode='[[DFNSTU]]' + ;; +esac + +# If we're using GNU nm, then use its standard symbol codes. +case `$NM -V 2>&1` in +*GNU* | *'with BFD'*) + symcode='[[ABCDGIRSTW]]' ;; +esac + +if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Gets list of data symbols to import. + lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'" + # Adjust the below global symbol transforms to fixup imported variables. + lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" + lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" + lt_c_name_lib_hook="\ + -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\ + -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'" +else + # Disable hooks by default. + lt_cv_sys_global_symbol_to_import= + lt_cdecl_hook= + lt_c_name_hook= + lt_c_name_lib_hook= +fi + +# Transform an extracted symbol line into a proper C declaration. +# Some systems (esp. on ia64) link data and code symbols differently, +# so use this general approach. +lt_cv_sys_global_symbol_to_cdecl="sed -n"\ +$lt_cdecl_hook\ +" -e 's/^T .* \(.*\)$/extern int \1();/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" + +# Transform an extracted symbol line into symbol name and symbol address +lt_cv_sys_global_symbol_to_c_name_address="sed -n"\ +$lt_c_name_hook\ +" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" + +# Transform an extracted symbol line into symbol name with lib prefix and +# symbol address. +lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\ +$lt_c_name_lib_hook\ +" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ +" -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ +" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'" + +# Handle CRLF in mingw tool chain +opt_cr= +case $build_os in +mingw*) + opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp + ;; +esac + +# Try without a prefix underscore, then with it. +for ac_symprfx in "" "_"; do + + # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol. + symxfrm="\\1 $ac_symprfx\\2 \\2" + + # Write the raw and C identifiers. + if test "$lt_cv_nm_interface" = "MS dumpbin"; then + # Fake it for dumpbin and say T for any non-static function, + # D for any global variable and I for any imported variable. + # Also find C++ and __fastcall symbols from MSVC++, + # which start with @ or ?. + lt_cv_sys_global_symbol_pipe="$AWK ['"\ +" {last_section=section; section=\$ 3};"\ +" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\ +" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\ +" /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\ +" /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\ +" /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\ +" \$ 0!~/External *\|/{next};"\ +" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\ +" {if(hide[section]) next};"\ +" {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\ +" {split(\$ 0,a,/\||\r/); split(a[2],s)};"\ +" s[1]~/^[@?]/{print f,s[1],s[1]; next};"\ +" s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ +" ' prfx=^$ac_symprfx]" + else + lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[ ]]\($symcode$symcode*\)[[ ]][[ ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" + fi + lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'" + + # Check to see that the pipe works correctly. + pipe_works=no + + rm -f conftest* + cat > conftest.$ac_ext <<_LT_EOF +#ifdef __cplusplus +extern "C" { +#endif +char nm_test_var; +void nm_test_func(void); +void nm_test_func(void){} +#ifdef __cplusplus +} +#endif +int main(){nm_test_var='a';nm_test_func();return(0);} +_LT_EOF + + if AC_TRY_EVAL(ac_compile); then + # Now try to grab the symbols. + nlist=conftest.nm + if AC_TRY_EVAL(NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) && test -s "$nlist"; then + # Try sorting and uniquifying the output. + if sort "$nlist" | uniq > "$nlist"T; then + mv -f "$nlist"T "$nlist" + else + rm -f "$nlist"T + fi + + # Make sure that we snagged all the symbols we need. + if $GREP ' nm_test_var$' "$nlist" >/dev/null; then + if $GREP ' nm_test_func$' "$nlist" >/dev/null; then + cat <<_LT_EOF > conftest.$ac_ext +/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ +#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE +/* DATA imports from DLLs on WIN32 can't be const, because runtime + relocations are performed -- see ld's documentation on pseudo-relocs. */ +# define LT@&t@_DLSYM_CONST +#elif defined __osf__ +/* This system does not cope well with relocations in const data. */ +# define LT@&t@_DLSYM_CONST +#else +# define LT@&t@_DLSYM_CONST const +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +_LT_EOF + # Now generate the symbol file. + eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext' + + cat <<_LT_EOF >> conftest.$ac_ext + +/* The mapping between symbol names and symbols. */ +LT@&t@_DLSYM_CONST struct { + const char *name; + void *address; +} +lt__PROGRAM__LTX_preloaded_symbols[[]] = +{ + { "@PROGRAM@", (void *) 0 }, +_LT_EOF + $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext + cat <<\_LT_EOF >> conftest.$ac_ext + {0, (void *) 0} +}; + +/* This works around a problem in FreeBSD linker */ +#ifdef FREEBSD_WORKAROUND +static const void *lt_preloaded_setup() { + return lt__PROGRAM__LTX_preloaded_symbols; +} +#endif + +#ifdef __cplusplus +} +#endif +_LT_EOF + # Now try linking the two files. + mv conftest.$ac_objext conftstm.$ac_objext + lt_globsym_save_LIBS=$LIBS + lt_globsym_save_CFLAGS=$CFLAGS + LIBS=conftstm.$ac_objext + CFLAGS="$CFLAGS$_LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)" + if AC_TRY_EVAL(ac_link) && test -s conftest$ac_exeext; then + pipe_works=yes + fi + LIBS=$lt_globsym_save_LIBS + CFLAGS=$lt_globsym_save_CFLAGS + else + echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD + fi + else + echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD + fi + else + echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD + cat conftest.$ac_ext >&5 + fi + rm -rf conftest* conftst* + + # Do not use the global_symbol_pipe unless it works. + if test yes = "$pipe_works"; then + break + else + lt_cv_sys_global_symbol_pipe= + fi +done +]) +if test -z "$lt_cv_sys_global_symbol_pipe"; then + lt_cv_sys_global_symbol_to_cdecl= +fi +if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then + AC_MSG_RESULT(failed) +else + AC_MSG_RESULT(ok) +fi + +# Response file support. +if test "$lt_cv_nm_interface" = "MS dumpbin"; then + nm_file_list_spec='@' +elif $NM --help 2>/dev/null | grep '[[@]]FILE' >/dev/null; then + nm_file_list_spec='@' +fi + +_LT_DECL([global_symbol_pipe], [lt_cv_sys_global_symbol_pipe], [1], + [Take the output of nm and produce a listing of raw symbols and C names]) +_LT_DECL([global_symbol_to_cdecl], [lt_cv_sys_global_symbol_to_cdecl], [1], + [Transform the output of nm in a proper C declaration]) +_LT_DECL([global_symbol_to_import], [lt_cv_sys_global_symbol_to_import], [1], + [Transform the output of nm into a list of symbols to manually relocate]) +_LT_DECL([global_symbol_to_c_name_address], + [lt_cv_sys_global_symbol_to_c_name_address], [1], + [Transform the output of nm in a C name address pair]) +_LT_DECL([global_symbol_to_c_name_address_lib_prefix], + [lt_cv_sys_global_symbol_to_c_name_address_lib_prefix], [1], + [Transform the output of nm in a C name address pair when lib prefix is needed]) +_LT_DECL([nm_interface], [lt_cv_nm_interface], [1], + [The name lister interface]) +_LT_DECL([], [nm_file_list_spec], [1], + [Specify filename containing input files for $NM]) +]) # _LT_CMD_GLOBAL_SYMBOLS + + +# _LT_COMPILER_PIC([TAGNAME]) +# --------------------------- +m4_defun([_LT_COMPILER_PIC], +[m4_require([_LT_TAG_COMPILER])dnl +_LT_TAGVAR(lt_prog_compiler_wl, $1)= +_LT_TAGVAR(lt_prog_compiler_pic, $1)= +_LT_TAGVAR(lt_prog_compiler_static, $1)= + +m4_if([$1], [CXX], [ + # C++ specific cases for pic, static, wl, etc. + if test yes = "$GXX"; then + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the '-m68020' flag to GCC prevents building anything better, + # like '-m68040'. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + mingw* | cygwin* | os2* | pw32* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + case $host_os in + os2*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' + ;; + esac + ;; + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + *djgpp*) + # DJGPP does not support shared libraries at all + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + haiku*) + # PIC is the default for Haiku. + # The "-static" flag exists, but is broken. + _LT_TAGVAR(lt_prog_compiler_static, $1)= + ;; + interix[[3-9]]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + else + case $host_os in + aix[[4-9]]*) + # All AIX code is PIC. + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + chorus*) + case $cc_basename in + cxch68*) + # Green Hills C++ Compiler + # _LT_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a" + ;; + esac + ;; + mingw* | cygwin* | os2* | pw32* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + ;; + dgux*) + case $cc_basename in + ec++*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + ghcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + freebsd* | dragonfly*) + # FreeBSD uses GNU C++ + ;; + hpux9* | hpux10* | hpux11*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' + if test ia64 != "$host_cpu"; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + fi + ;; + aCC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + ;; + *) + ;; + esac + ;; + interix*) + # This is c89, which is MS Visual C++ (no shared libs) + # Anyone wants to do a port? + ;; + irix5* | irix6* | nonstopux*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + # CC pic flag -KPIC is the default. + ;; + *) + ;; + esac + ;; + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + case $cc_basename in + KCC*) + # KAI C++ Compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + ecpc* ) + # old Intel C++ for x86_64, which still supported -KPIC. + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + icpc* ) + # Intel C++, used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + cxx*) + # Compaq C++ + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + xlc* | xlC* | bgxl[[cC]]* | mpixl[[cC]]*) + # IBM XL 8.0, 9.0 on PPC and BlueGene + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + esac + ;; + esac + ;; + lynxos*) + ;; + m88k*) + ;; + mvs*) + case $cc_basename in + cxx*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall' + ;; + *) + ;; + esac + ;; + netbsd* | netbsdelf*-gnu) + ;; + *qnx* | *nto*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,' + ;; + RCC*) + # Rational C++ 2.4.1 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + cxx*) + # Digital/Compaq C++ + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # Make sure the PIC flag is empty. It appears that all Alpha + # Linux and Compaq Tru64 Unix objects are PIC. + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + *) + ;; + esac + ;; + psos*) + ;; + solaris*) + case $cc_basename in + CC* | sunCC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + ;; + *) + ;; + esac + ;; + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + lcc*) + # Lucid + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + ;; + *) + ;; + esac + ;; + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + case $cc_basename in + CC*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + esac + ;; + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + ;; + *) + ;; + esac + ;; + vxworks*) + ;; + *) + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +], +[ + if test yes = "$GCC"; then + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + + case $host_os in + aix*) + # All AIX code is PIC. + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + m68k) + # FIXME: we need at least 68020 code to build shared libraries, but + # adding the '-m68020' flag to GCC prevents building anything better, + # like '-m68040'. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4' + ;; + esac + ;; + + beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*) + # PIC is the default for these OSes. + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + # Although the cygwin gcc ignores -fPIC, still need this for old-style + # (--disable-auto-import) libraries + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + case $host_os in + os2*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' + ;; + esac + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + ;; + + haiku*) + # PIC is the default for Haiku. + # The "-static" flag exists, but is broken. + _LT_TAGVAR(lt_prog_compiler_static, $1)= + ;; + + hpux*) + # PIC is the default for 64-bit PA HP-UX, but not for 32-bit + # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag + # sets the default TLS model and affects inlining. + case $host_cpu in + hppa*64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + ;; + + interix[[3-9]]*) + # Interix 3.x gcc -fpic/-fPIC options generate broken code. + # Instead, we relocate shared libraries at runtime. + ;; + + msdosdjgpp*) + # Just because we use GCC doesn't mean we suddenly get shared libraries + # on systems that don't support them. + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + enable_shared=no + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic + fi + ;; + + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + ;; + esac + + case $cc_basename in + nvcc*) # Cuda Compiler Driver 2.2 + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Xlinker ' + if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)="-Xcompiler $_LT_TAGVAR(lt_prog_compiler_pic, $1)" + fi + ;; + esac + else + # PORTME Check for flag to pass linker flags through the system compiler. + case $host_os in + aix*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + if test ia64 = "$host_cpu"; then + # AIX 5 now supports IA64 processor + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + else + _LT_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp' + fi + ;; + + darwin* | rhapsody*) + # PIC is the default on this platform + # Common symbols not allowed in MH_DYLIB files + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common' + case $cc_basename in + nagfor*) + # NAG Fortran compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + esac + ;; + + mingw* | cygwin* | pw32* | os2* | cegcc*) + # This hack is so that the source file can tell whether it is being + # built for inclusion in a dll (and should export symbols for example). + m4_if([$1], [GCJ], [], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT']) + case $host_os in + os2*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-static' + ;; + esac + ;; + + hpux9* | hpux10* | hpux11*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but + # not for PA HP-UX. + case $host_cpu in + hppa*64*|ia64*) + # +Z the default + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='+Z' + ;; + esac + # Is there a better lt_prog_compiler_static that works with the bundled CC? + _LT_TAGVAR(lt_prog_compiler_static, $1)='$wl-a ${wl}archive' + ;; + + irix5* | irix6* | nonstopux*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # PIC (with -KPIC) is the default. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + case $cc_basename in + # old Intel for x86_64, which still supported -KPIC. + ecc*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + # icc used to be incompatible with GCC. + # ICC 10 doesn't accept -KPIC any more. + icc* | ifort*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + # Lahey Fortran 8.1. + lf95*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='--shared' + _LT_TAGVAR(lt_prog_compiler_static, $1)='--static' + ;; + nagfor*) + # NAG Fortran compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,-Wl,,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + tcc*) + # Fabrice Bellard et al's Tiny C Compiler + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*) + # Portland Group compilers (*not* the Pentium gcc compiler, + # which looks to be a dead project) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + ccc*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All Alpha code is PIC. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + xl* | bgxl* | bgf* | mpixl*) + # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-qpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-qstaticlink' + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [[1-7]].* | *Sun*Fortran*\ 8.[[0-3]]*) + # Sun Fortran 8.3 passes all unrecognized flags to the linker + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='' + ;; + *Sun\ F* | *Sun*Fortran*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + ;; + *Sun\ C*) + # Sun C 5.9 + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + ;; + *Intel*\ [[CF]]*Compiler*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-static' + ;; + *Portland\ Group*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fpic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + esac + ;; + esac + ;; + + newsos6) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *nto* | *qnx*) + # QNX uses GNU C++, but need to define -shared option too, otherwise + # it will coredump. + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC -shared' + ;; + + osf3* | osf4* | osf5*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + # All OSF/1 code is PIC. + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + rdos*) + _LT_TAGVAR(lt_prog_compiler_static, $1)='-non_shared' + ;; + + solaris*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + case $cc_basename in + f77* | f90* | f95* | sunf77* | sunf90* | sunf95*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';; + *) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';; + esac + ;; + + sunos4*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-PIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4 | sysv4.2uw2* | sysv4.3*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + fi + ;; + + sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + unicos*) + _LT_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,' + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + + uts4*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)='-pic' + _LT_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic' + ;; + + *) + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no + ;; + esac + fi +]) +case $host_os in + # For platforms that do not support PIC, -DPIC is meaningless: + *djgpp*) + _LT_TAGVAR(lt_prog_compiler_pic, $1)= + ;; + *) + _LT_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])" + ;; +esac + +AC_CACHE_CHECK([for $compiler option to produce PIC], + [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)], + [_LT_TAGVAR(lt_cv_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_prog_compiler_pic, $1)]) +_LT_TAGVAR(lt_prog_compiler_pic, $1)=$_LT_TAGVAR(lt_cv_prog_compiler_pic, $1) + +# +# Check to make sure the PIC flag actually works. +# +if test -n "$_LT_TAGVAR(lt_prog_compiler_pic, $1)"; then + _LT_COMPILER_OPTION([if $compiler PIC flag $_LT_TAGVAR(lt_prog_compiler_pic, $1) works], + [_LT_TAGVAR(lt_cv_prog_compiler_pic_works, $1)], + [$_LT_TAGVAR(lt_prog_compiler_pic, $1)@&t@m4_if([$1],[],[ -DPIC],[m4_if([$1],[CXX],[ -DPIC],[])])], [], + [case $_LT_TAGVAR(lt_prog_compiler_pic, $1) in + "" | " "*) ;; + *) _LT_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_TAGVAR(lt_prog_compiler_pic, $1)" ;; + esac], + [_LT_TAGVAR(lt_prog_compiler_pic, $1)= + _LT_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no]) +fi +_LT_TAGDECL([pic_flag], [lt_prog_compiler_pic], [1], + [Additional compiler flags for building library objects]) + +_LT_TAGDECL([wl], [lt_prog_compiler_wl], [1], + [How to pass a linker flag through the compiler]) +# +# Check to make sure the static flag actually works. +# +wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) eval lt_tmp_static_flag=\"$_LT_TAGVAR(lt_prog_compiler_static, $1)\" +_LT_LINKER_OPTION([if $compiler static flag $lt_tmp_static_flag works], + _LT_TAGVAR(lt_cv_prog_compiler_static_works, $1), + $lt_tmp_static_flag, + [], + [_LT_TAGVAR(lt_prog_compiler_static, $1)=]) +_LT_TAGDECL([link_static_flag], [lt_prog_compiler_static], [1], + [Compiler flag to prevent dynamic linking]) +])# _LT_COMPILER_PIC + + +# _LT_LINKER_SHLIBS([TAGNAME]) +# ---------------------------- +# See if the linker supports building shared libraries. +m4_defun([_LT_LINKER_SHLIBS], +[AC_REQUIRE([LT_PATH_LD])dnl +AC_REQUIRE([LT_PATH_NM])dnl +m4_require([_LT_PATH_MANIFEST_TOOL])dnl +m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_DECL_SED])dnl +m4_require([_LT_CMD_GLOBAL_SYMBOLS])dnl +m4_require([_LT_TAG_COMPILER])dnl +AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) +m4_if([$1], [CXX], [ + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] + case $host_os in + aix[[4-9]]*) + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to GNU nm, but means don't demangle to AIX nm. + # Without the "-l" option, or with the "-B" option, AIX nm treats + # weak defined symbols like other global defined symbols, whereas + # GNU nm marks them as "W". + # While the 'weak' keyword is ignored in the Export File, we need + # it in the Import File for the 'aix-soname' feature, so we have + # to replace the "-B" option with "-P" for AIX nm. + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' + else + _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' + fi + ;; + pw32*) + _LT_TAGVAR(export_symbols_cmds, $1)=$ltdll_cmds + ;; + cygwin* | mingw* | cegcc*) + case $cc_basename in + cl*) + _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + ;; + *) + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] + ;; + esac + ;; + linux* | k*bsd*-gnu | gnu*) + _LT_TAGVAR(link_all_deplibs, $1)=no + ;; + *) + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + ;; + esac +], [ + runpath_var= + _LT_TAGVAR(allow_undefined_flag, $1)= + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(archive_cmds, $1)= + _LT_TAGVAR(archive_expsym_cmds, $1)= + _LT_TAGVAR(compiler_needs_object, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + _LT_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(hardcode_automatic, $1)=no + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(hardcode_libdir_separator, $1)= + _LT_TAGVAR(hardcode_minus_L, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported + _LT_TAGVAR(inherit_rpath, $1)=no + _LT_TAGVAR(link_all_deplibs, $1)=unknown + _LT_TAGVAR(module_cmds, $1)= + _LT_TAGVAR(module_expsym_cmds, $1)= + _LT_TAGVAR(old_archive_from_new_cmds, $1)= + _LT_TAGVAR(old_archive_from_expsyms_cmds, $1)= + _LT_TAGVAR(thread_safe_flag_spec, $1)= + _LT_TAGVAR(whole_archive_flag_spec, $1)= + # include_expsyms should be a list of space-separated symbols to be *always* + # included in the symbol list + _LT_TAGVAR(include_expsyms, $1)= + # exclude_expsyms can be an extended regexp of symbols to exclude + # it will be wrapped by ' (' and ')$', so one must not match beginning or + # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc', + # as well as any symbol that contains 'd'. + _LT_TAGVAR(exclude_expsyms, $1)=['_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'] + # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out + # platforms (ab)use it in PIC code, but their linkers get confused if + # the symbol is explicitly referenced. Since portable code cannot + # rely on this symbol name, it's probably fine to never include it in + # preloaded symbol tables. + # Exclude shared library initialization/finalization symbols. +dnl Note also adjust exclude_expsyms for C++ above. + extract_expsyms_cmds= + + case $host_os in + cygwin* | mingw* | pw32* | cegcc*) + # FIXME: the MSVC++ port hasn't been tested in a loooong time + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + if test yes != "$GCC"; then + with_gnu_ld=no + fi + ;; + interix*) + # we just hope/assume this is gcc and not c89 (= MSVC++) + with_gnu_ld=yes + ;; + openbsd* | bitrig*) + with_gnu_ld=no + ;; + linux* | k*bsd*-gnu | gnu*) + _LT_TAGVAR(link_all_deplibs, $1)=no + ;; + esac + + _LT_TAGVAR(ld_shlibs, $1)=yes + + # On some targets, GNU ld is compatible enough with the native linker + # that we're better off using the native interface for both. + lt_use_gnu_ld_interface=no + if test yes = "$with_gnu_ld"; then + case $host_os in + aix*) + # The AIX port of GNU ld has always aspired to compatibility + # with the native linker. However, as the warning in the GNU ld + # block says, versions before 2.19.5* couldn't really create working + # shared libraries, regardless of the interface used. + case `$LD -v 2>&1` in + *\ \(GNU\ Binutils\)\ 2.19.5*) ;; + *\ \(GNU\ Binutils\)\ 2.[[2-9]]*) ;; + *\ \(GNU\ Binutils\)\ [[3-9]]*) ;; + *) + lt_use_gnu_ld_interface=yes + ;; + esac + ;; + *) + lt_use_gnu_ld_interface=yes + ;; + esac + fi + + if test yes = "$lt_use_gnu_ld_interface"; then + # If archive_cmds runs LD, not CC, wlarc should be empty + wlarc='$wl' + + # Set some defaults for GNU ld with shared library support. These + # are reset later if shared libraries are not supported. Putting them + # here allows them to be overridden if necessary. + runpath_var=LD_RUN_PATH + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + # ancient GNU ld didn't support --whole-archive et. al. + if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then + _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + supports_anon_versioning=no + case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in + *GNU\ gold*) supports_anon_versioning=yes ;; + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11 + *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... + *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ... + *\ 2.11.*) ;; # other 2.11 versions + *) supports_anon_versioning=yes ;; + esac + + # See if GNU ld supports shared libraries. + case $host_os in + aix[[3-9]]*) + # On AIX/PPC, the GNU linker is very broken + if test ia64 != "$host_cpu"; then + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: the GNU linker, at least up to release 2.19, is reported +*** to be unable to reliably create shared libraries on AIX. +*** Therefore, libtool is disabling shared libraries support. If you +*** really care for shared libraries, you may want to install binutils +*** 2.20 or above, or modify your PATH so that a non-GNU linker is found. +*** You will then need to restart the configuration process. + +_LT_EOF + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='' + ;; + m68k) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1 DATA/;s/^.*[[ ]]__nm__\([[^ ]]*\)[[ ]][[^ ]]*/\1 DATA/;/^I[[ ]]/d;/^[[AITW]][[ ]]/s/.* //'\'' | sort | uniq > $export_symbols' + _LT_TAGVAR(exclude_expsyms, $1)=['[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'] + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file, use it as + # is; otherwise, prepend EXPORTS... + _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + haiku*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + os2*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + shrext_cmds=.dll + _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + + interix[[3-9]]*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + + gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) + tmp_diet=no + if test linux-dietlibc = "$host_os"; then + case $cc_basename in + diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn) + esac + fi + if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \ + && test no = "$tmp_diet" + then + tmp_addflag=' $pic_flag' + tmp_sharedflag='-shared' + case $cc_basename,$host_cpu in + pgcc*) # Portland Group C compiler + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + tmp_addflag=' $pic_flag' + ;; + pgf77* | pgf90* | pgf95* | pgfortran*) + # Portland Group f77 and f90 compilers + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + tmp_addflag=' $pic_flag -Mnomain' ;; + ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64 + tmp_addflag=' -i_dynamic' ;; + efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64 + tmp_addflag=' -i_dynamic -nofor_main' ;; + ifc* | ifort*) # Intel Fortran compiler + tmp_addflag=' -nofor_main' ;; + lf95*) # Lahey Fortran 8.1 + _LT_TAGVAR(whole_archive_flag_spec, $1)= + tmp_sharedflag='--shared' ;; + nagfor*) # NAGFOR 5.3 + tmp_sharedflag='-Wl,-shared' ;; + xl[[cC]]* | bgxl[[cC]]* | mpixl[[cC]]*) # IBM XL C 8.0 on PPC (deal with xlf below) + tmp_sharedflag='-qmkshrobj' + tmp_addflag= ;; + nvcc*) # Cuda Compiler Driver 2.2 + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes + ;; + esac + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) # Sun C 5.9 + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes + tmp_sharedflag='-G' ;; + *Sun\ F*) # Sun Fortran 8.3 + tmp_sharedflag='-G' ;; + esac + _LT_TAGVAR(archive_cmds, $1)='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + + if test yes = "$supports_anon_versioning"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' + fi + + case $cc_basename in + tcc*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='-rdynamic' + ;; + xlf* | bgf* | bgxlf* | mpixlf*) + # IBM XL Fortran 10.1 on PPC cannot create shared libs itself + _LT_TAGVAR(whole_archive_flag_spec, $1)='--whole-archive$convenience --no-whole-archive' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' + if test yes = "$supports_anon_versioning"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' + fi + ;; + esac + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + netbsd* | netbsdelf*-gnu) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib' + wlarc= + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + fi + ;; + + solaris*) + if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: The releases 2.8.* of the GNU linker cannot reliably +*** create shared libraries on Solaris systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.9.1 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*) + case `$LD -v 2>&1` in + *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.1[[0-5]].*) + _LT_TAGVAR(ld_shlibs, $1)=no + cat <<_LT_EOF 1>&2 + +*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot +*** reliably create shared libraries on SCO systems. Therefore, libtool +*** is disabling shared libraries support. We urge you to upgrade GNU +*** binutils to release 2.16.91.0.3 or newer. Another option is to modify +*** your PATH or compiler configuration so that the native linker is +*** used, and then restart. + +_LT_EOF + ;; + *) + # For security reasons, it is highly recommended that you always + # use absolute paths for naming shared libraries, and exclude the + # DT_RUNPATH tag from executables and libraries. But doing so + # requires that you compile everything twice, which is a pain. + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + sunos4*) + _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags' + wlarc= + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + + if test no = "$_LT_TAGVAR(ld_shlibs, $1)"; then + runpath_var= + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)= + _LT_TAGVAR(export_dynamic_flag_spec, $1)= + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + # PORTME fill in a description of your system's linker (not GNU ld) + case $host_os in + aix3*) + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes + _LT_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname' + # Note: this linker hardcodes the directories in LIBPATH if there + # are no directories specified by -L. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then + # Neither direct hardcoding nor static linking is supported with a + # broken collect2. + _LT_TAGVAR(hardcode_direct, $1)=unsupported + fi + ;; + + aix[[4-9]]*) + if test ia64 = "$host_cpu"; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag= + else + # If we're using GNU nm, then we don't want the "-C" option. + # -C means demangle to GNU nm, but means don't demangle to AIX nm. + # Without the "-l" option, or with the "-B" option, AIX nm treats + # weak defined symbols like other global defined symbols, whereas + # GNU nm marks them as "W". + # While the 'weak' keyword is ignored in the Export File, we need + # it in the Import File for the 'aix-soname' feature, so we have + # to replace the "-B" option with "-P" for AIX nm. + if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then + _LT_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && ([substr](\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' + else + _LT_TAGVAR(export_symbols_cmds, $1)='`func_echo_all $NM | $SED -e '\''s/B\([[^B]]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && ([substr](\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' + fi + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # have runtime linking enabled, and use it for executables. + # For shared libraries, we enable/disable runtime linking + # depending on the kind of the shared library created - + # when "with_aix_soname,aix_use_runtimelinking" is: + # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables + # "aix,yes" lib.so shared, rtl:yes, for executables + # lib.a static archive + # "both,no" lib.so.V(shr.o) shared, rtl:yes + # lib.a(lib.so.V) shared, rtl:no, for executables + # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a(lib.so.V) shared, rtl:no + # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a static archive + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) + for ld_flag in $LDFLAGS; do + if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then + aix_use_runtimelinking=yes + break + fi + done + if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then + # With aix-soname=svr4, we create the lib.so.V shared archives only, + # so we don't have lib.a shared libs to link our executables. + # We have to force runtime linking in this case. + aix_use_runtimelinking=yes + LDFLAGS="$LDFLAGS -Wl,-brtl" + fi + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_TAGVAR(archive_cmds, $1)='' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='$wl-f,' + case $with_aix_soname,$aix_use_runtimelinking in + aix,*) ;; # traditional, no import file + svr4,* | *,yes) # use import file + # The Import File defines what to hardcode. + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=no + ;; + esac + + if test yes = "$GCC"; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`$CC -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + _LT_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)= + fi + ;; + esac + shared_flag='-shared' + if test yes = "$aix_use_runtimelinking"; then + shared_flag="$shared_flag "'$wl-G' + fi + # Need to ensure runtime linking is disabled for the traditional + # shared library, or the linker may eventually find shared libraries + # /with/ Import File - we do not want to mix them. + shared_flag_aix='-shared' + shared_flag_svr4='-shared $wl-G' + else + # not using gcc + if test ia64 = "$host_cpu"; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test yes = "$aix_use_runtimelinking"; then + shared_flag='$wl-G' + else + shared_flag='$wl-bM:SRE' + fi + shared_flag_aix='$wl-bM:SRE' + shared_flag_svr4='$wl-G' + fi + fi + + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to export. + _LT_TAGVAR(always_export_symbols, $1)=yes + if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(allow_undefined_flag, $1)='-berok' + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag + else + if test ia64 = "$host_cpu"; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib' + _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok' + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok' + if test yes = "$with_gnu_ld"; then + # We only use this code for GNU lds that support --whole-archive. + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' + else + # Exported symbols can be pulled into shared objects from archives + _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' + # -brtl affects multiple linker settings, -berok does not and is overridden later + compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`' + if test svr4 != "$with_aix_soname"; then + # This is similar to how AIX traditionally builds its shared libraries. + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' + fi + if test aix != "$with_aix_soname"; then + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' + else + # used by -dlpreopen to get the symbols + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV $output_objdir/$realname.d/$soname $output_objdir' + fi + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d' + fi + fi + ;; + + amigaos*) + case $host_cpu in + powerpc) + # see comment about AmigaOS4 .so support + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='' + ;; + m68k) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + ;; + + bsdi[[45]]*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic + ;; + + cygwin* | mingw* | pw32* | cegcc*) + # When not using gcc, we currently assume that we are using + # Microsoft Visual C++. + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + case $cc_basename in + cl*) + # Native MSVC + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='@' + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=.dll + # FIXME: Setting linknames here is a bad hack. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' + _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then + cp "$export_symbols" "$output_objdir/$soname.def"; + echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; + else + $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; + fi~ + $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + linknames=' + # The linker will not automatically build a static lib if we build a DLL. + # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + _LT_TAGVAR(exclude_expsyms, $1)='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*' + _LT_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]][[ ]]/s/.*[[ ]]\([[^ ]]*\)/\1,DATA/'\'' | $SED -e '\''/^[[AITW]][[ ]]/s/.*[[ ]]//'\'' | sort | uniq > $export_symbols' + # Don't use ranlib + _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' + _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ + lt_tool_outputfile="@TOOL_OUTPUT@"~ + case $lt_outputfile in + *.exe|*.EXE) ;; + *) + lt_outputfile=$lt_outputfile.exe + lt_tool_outputfile=$lt_tool_outputfile.exe + ;; + esac~ + if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then + $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; + $RM "$lt_outputfile.manifest"; + fi' + ;; + *) + # Assume MSVC wrapper + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=.dll + # FIXME: Setting linknames here is a bad hack. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames=' + # The linker will automatically build a .lib file if we build a DLL. + _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' + # FIXME: Should let the user specify the lib program. + _LT_TAGVAR(old_archive_cmds, $1)='lib -OUT:$oldlib$oldobjs$old_deplibs' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + esac + ;; + + darwin* | rhapsody*) + _LT_DARWIN_LINKER_FEATURES($1) + ;; + + dgux*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor + # support. Future versions do this automatically, but an explicit c++rt0.o + # does not break anything, and helps significantly (at the cost of a little + # extra space). + freebsd2.2*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # Unfortunately, older versions of FreeBSD 2 do not have this feature. + freebsd2.*) + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + # FreeBSD 3 and greater uses gcc -shared to do shared libraries. + freebsd* | dragonfly*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + hpux9*) + if test yes = "$GCC"; then + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + else + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_direct, $1)=yes + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + ;; + + hpux10*) + if test yes,no = "$GCC,$with_gnu_ld"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags' + fi + if test no = "$with_gnu_ld"; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + fi + ;; + + hpux11*) + if test yes,no = "$GCC,$with_gnu_ld"; then + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + else + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + m4_if($1, [], [ + # Older versions of the 11.00 compiler do not understand -b yet + # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does) + _LT_LINKER_OPTION([if $CC understands -b], + _LT_TAGVAR(lt_cv_prog_compiler__b, $1), [-b], + [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'], + [_LT_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'])], + [_LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags']) + ;; + esac + fi + if test no = "$with_gnu_ld"; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + + # hardcode_minus_L: Not really in the search PATH, + # but as the default location of the library. + _LT_TAGVAR(hardcode_minus_L, $1)=yes + ;; + esac + fi + ;; + + irix5* | irix6* | nonstopux*) + if test yes = "$GCC"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + # Try to use the -exported_symbol ld option, if it does not + # work, assume that -exports_file does not work either and + # implicitly export all symbols. + # This should be the same for all languages, so no per-tag cache variable. + AC_CACHE_CHECK([whether the $host_os linker accepts -exported_symbol], + [lt_cv_irix_exported_symbol], + [save_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null" + AC_LINK_IFELSE( + [AC_LANG_SOURCE( + [AC_LANG_CASE([C], [[int foo (void) { return 0; }]], + [C++], [[int foo (void) { return 0; }]], + [Fortran 77], [[ + subroutine foo + end]], + [Fortran], [[ + subroutine foo + end]])])], + [lt_cv_irix_exported_symbol=yes], + [lt_cv_irix_exported_symbol=no]) + LDFLAGS=$save_LDFLAGS]) + if test yes = "$lt_cv_irix_exported_symbol"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib' + fi + _LT_TAGVAR(link_all_deplibs, $1)=no + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(inherit_rpath, $1)=yes + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + linux*) + case $cc_basename in + tcc*) + # Fabrice Bellard et al's Tiny C Compiler + _LT_TAGVAR(ld_shlibs, $1)=yes + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + netbsd* | netbsdelf*-gnu) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out + else + _LT_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + newsos6) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *nto* | *qnx*) + ;; + + openbsd* | bitrig*) + if test -f /usr/libexec/ld.so; then + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + fi + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + os2*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + shrext_cmds=.dll + _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + + osf3*) + if test yes = "$GCC"; then + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + else + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + osf4* | osf5*) # as osf3* with the addition of -msym flag + if test yes = "$GCC"; then + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + else + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp' + + # Both c and cxx compiler support -rpath directly + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)='no' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + ;; + + solaris*) + _LT_TAGVAR(no_undefined_flag, $1)=' -z defs' + if test yes = "$GCC"; then + wlarc='$wl' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + else + case `$CC -V 2>&1` in + *"Compilers 5.0"*) + wlarc='' + _LT_TAGVAR(archive_cmds, $1)='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp' + ;; + *) + wlarc='$wl' + _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp' + ;; + esac + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands '-z linker_flag'. GCC discards it without '$wl', + # but is careful enough not to reorder. + # Supported since Solaris 2.6 (maybe 2.5.1?) + if test yes = "$GCC"; then + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + fi + ;; + esac + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + sunos4*) + if test sequent = "$host_vendor"; then + # Use $CC to link under sequent, because it throws in some extra .o + # files that make .init and .fini sections work. + _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags' + fi + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4) + case $host_vendor in + sni) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=yes # is this really true??? + ;; + siemens) + ## LD is ld it makes a PLAMLIB + ## CC just makes a GrossModule. + _LT_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs' + _LT_TAGVAR(hardcode_direct, $1)=no + ;; + motorola) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie + ;; + esac + runpath_var='LD_RUN_PATH' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + sysv4.3*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport' + ;; + + sysv4*MP*) + if test -d /usr/nec; then + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var=LD_RUN_PATH + hardcode_runpath_var=yes + _LT_TAGVAR(ld_shlibs, $1)=yes + fi + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + if test yes = "$GCC"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We CANNOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' + _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport' + runpath_var='LD_RUN_PATH' + + if test yes = "$GCC"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + fi + ;; + + uts4*) + _LT_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + + *) + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + + if test sni = "$host_vendor"; then + case $host in + sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Blargedynsym' + ;; + esac + fi + fi +]) +AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) +test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no + +_LT_TAGVAR(with_gnu_ld, $1)=$with_gnu_ld + +_LT_DECL([], [libext], [0], [Old archive suffix (normally "a")])dnl +_LT_DECL([], [shrext_cmds], [1], [Shared library suffix (normally ".so")])dnl +_LT_DECL([], [extract_expsyms_cmds], [2], + [The commands to extract the exported symbol list from a shared archive]) + +# +# Do we need to explicitly link libc? +# +case "x$_LT_TAGVAR(archive_cmds_need_lc, $1)" in +x|xyes) + # Assume -lc should be added + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + + if test yes,yes = "$GCC,$enable_shared"; then + case $_LT_TAGVAR(archive_cmds, $1) in + *'~'*) + # FIXME: we may have to deal with multi-command sequences. + ;; + '$CC '*) + # Test whether the compiler implicitly links with -lc since on some + # systems, -lgcc has to come before -lc. If gcc already passes -lc + # to ld, don't add -lc before -lgcc. + AC_CACHE_CHECK([whether -lc should be explicitly linked in], + [lt_cv_]_LT_TAGVAR(archive_cmds_need_lc, $1), + [$RM conftest* + echo "$lt_simple_compile_test_code" > conftest.$ac_ext + + if AC_TRY_EVAL(ac_compile) 2>conftest.err; then + soname=conftest + lib=conftest + libobjs=conftest.$ac_objext + deplibs= + wl=$_LT_TAGVAR(lt_prog_compiler_wl, $1) + pic_flag=$_LT_TAGVAR(lt_prog_compiler_pic, $1) + compiler_flags=-v + linker_flags=-v + verstring= + output_objdir=. + libname=conftest + lt_save_allow_undefined_flag=$_LT_TAGVAR(allow_undefined_flag, $1) + _LT_TAGVAR(allow_undefined_flag, $1)= + if AC_TRY_EVAL(_LT_TAGVAR(archive_cmds, $1) 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) + then + lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=no + else + lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1)=yes + fi + _LT_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag + else + cat conftest.err 1>&5 + fi + $RM conftest* + ]) + _LT_TAGVAR(archive_cmds_need_lc, $1)=$lt_cv_[]_LT_TAGVAR(archive_cmds_need_lc, $1) + ;; + esac + fi + ;; +esac + +_LT_TAGDECL([build_libtool_need_lc], [archive_cmds_need_lc], [0], + [Whether or not to add -lc for building shared libraries]) +_LT_TAGDECL([allow_libtool_libs_with_static_runtimes], + [enable_shared_with_static_runtimes], [0], + [Whether or not to disallow shared libs when runtime libs are static]) +_LT_TAGDECL([], [export_dynamic_flag_spec], [1], + [Compiler flag to allow reflexive dlopens]) +_LT_TAGDECL([], [whole_archive_flag_spec], [1], + [Compiler flag to generate shared objects directly from archives]) +_LT_TAGDECL([], [compiler_needs_object], [1], + [Whether the compiler copes with passing no objects directly]) +_LT_TAGDECL([], [old_archive_from_new_cmds], [2], + [Create an old-style archive from a shared archive]) +_LT_TAGDECL([], [old_archive_from_expsyms_cmds], [2], + [Create a temporary old-style archive to link instead of a shared archive]) +_LT_TAGDECL([], [archive_cmds], [2], [Commands used to build a shared archive]) +_LT_TAGDECL([], [archive_expsym_cmds], [2]) +_LT_TAGDECL([], [module_cmds], [2], + [Commands used to build a loadable module if different from building + a shared archive.]) +_LT_TAGDECL([], [module_expsym_cmds], [2]) +_LT_TAGDECL([], [with_gnu_ld], [1], + [Whether we are building with GNU ld or not]) +_LT_TAGDECL([], [allow_undefined_flag], [1], + [Flag that allows shared libraries with undefined symbols to be built]) +_LT_TAGDECL([], [no_undefined_flag], [1], + [Flag that enforces no undefined symbols]) +_LT_TAGDECL([], [hardcode_libdir_flag_spec], [1], + [Flag to hardcode $libdir into a binary during linking. + This must work even if $libdir does not exist]) +_LT_TAGDECL([], [hardcode_libdir_separator], [1], + [Whether we need a single "-rpath" flag with a separated argument]) +_LT_TAGDECL([], [hardcode_direct], [0], + [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes + DIR into the resulting binary]) +_LT_TAGDECL([], [hardcode_direct_absolute], [0], + [Set to "yes" if using DIR/libNAME$shared_ext during linking hardcodes + DIR into the resulting binary and the resulting library dependency is + "absolute", i.e impossible to change by setting $shlibpath_var if the + library is relocated]) +_LT_TAGDECL([], [hardcode_minus_L], [0], + [Set to "yes" if using the -LDIR flag during linking hardcodes DIR + into the resulting binary]) +_LT_TAGDECL([], [hardcode_shlibpath_var], [0], + [Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR + into the resulting binary]) +_LT_TAGDECL([], [hardcode_automatic], [0], + [Set to "yes" if building a shared library automatically hardcodes DIR + into the library and all subsequent libraries and executables linked + against it]) +_LT_TAGDECL([], [inherit_rpath], [0], + [Set to yes if linker adds runtime paths of dependent libraries + to runtime path list]) +_LT_TAGDECL([], [link_all_deplibs], [0], + [Whether libtool must link a program against all its dependency libraries]) +_LT_TAGDECL([], [always_export_symbols], [0], + [Set to "yes" if exported symbols are required]) +_LT_TAGDECL([], [export_symbols_cmds], [2], + [The commands to list exported symbols]) +_LT_TAGDECL([], [exclude_expsyms], [1], + [Symbols that should not be listed in the preloaded symbols]) +_LT_TAGDECL([], [include_expsyms], [1], + [Symbols that must always be exported]) +_LT_TAGDECL([], [prelink_cmds], [2], + [Commands necessary for linking programs (against libraries) with templates]) +_LT_TAGDECL([], [postlink_cmds], [2], + [Commands necessary for finishing linking programs]) +_LT_TAGDECL([], [file_list_spec], [1], + [Specify filename containing input files]) +dnl FIXME: Not yet implemented +dnl _LT_TAGDECL([], [thread_safe_flag_spec], [1], +dnl [Compiler flag to generate thread safe objects]) +])# _LT_LINKER_SHLIBS + + +# _LT_LANG_C_CONFIG([TAG]) +# ------------------------ +# Ensure that the configuration variables for a C compiler are suitably +# defined. These variables are subsequently used by _LT_CONFIG to write +# the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_C_CONFIG], +[m4_require([_LT_DECL_EGREP])dnl +lt_save_CC=$CC +AC_LANG_PUSH(C) + +# Source file extension for C test sources. +ac_ext=c + +# Object file extension for compiled C test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="int some_variable = 0;" + +# Code to be used in simple link tests +lt_simple_link_test_code='int main(){return(0);}' + +_LT_TAG_COMPILER +# Save the default compiler, since it gets overwritten when the other +# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP. +compiler_DEFAULT=$CC + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + LT_SYS_DLOPEN_SELF + _LT_CMD_STRIPLIB + + # Report what library types will actually be built + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test no = "$can_build_shared" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test yes = "$enable_shared" && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + + aix[[4-9]]*) + if test ia64 != "$host_cpu"; then + case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in + yes,aix,yes) ;; # shared object as lib.so file only + yes,svr4,*) ;; # shared object as lib.so archive member only + yes,*) enable_static=no ;; # shared object in lib.a archive as well + esac + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test yes = "$enable_shared" || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_CONFIG($1) +fi +AC_LANG_POP +CC=$lt_save_CC +])# _LT_LANG_C_CONFIG + + +# _LT_LANG_CXX_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for a C++ compiler are suitably +# defined. These variables are subsequently used by _LT_CONFIG to write +# the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_CXX_CONFIG], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +m4_require([_LT_DECL_EGREP])dnl +m4_require([_LT_PATH_MANIFEST_TOOL])dnl +if test -n "$CXX" && ( test no != "$CXX" && + ( (test g++ = "$CXX" && `g++ -v >/dev/null 2>&1` ) || + (test g++ != "$CXX"))); then + AC_PROG_CXXCPP +else + _lt_caught_CXX_error=yes +fi + +AC_LANG_PUSH(C++) +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(compiler_needs_object, $1)=no +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_shlibpath_var, $1)=unsupported +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for C++ test sources. +ac_ext=cpp + +# Object file extension for compiled C++ test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the CXX compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test yes != "$_lt_caught_CXX_error"; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="int some_variable = 0;" + + # Code to be used in simple link tests + lt_simple_link_test_code='int main(int, char *[[]]) { return(0); }' + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC=$CC + lt_save_CFLAGS=$CFLAGS + lt_save_LD=$LD + lt_save_GCC=$GCC + GCC=$GXX + lt_save_with_gnu_ld=$with_gnu_ld + lt_save_path_LD=$lt_cv_path_LD + if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then + lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx + else + $as_unset lt_cv_prog_gnu_ld + fi + if test -n "${lt_cv_path_LDCXX+set}"; then + lt_cv_path_LD=$lt_cv_path_LDCXX + else + $as_unset lt_cv_path_LD + fi + test -z "${LDCXX+set}" || LD=$LDCXX + CC=${CXX-"c++"} + CFLAGS=$CXXFLAGS + compiler=$CC + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + + if test -n "$compiler"; then + # We don't want -fno-exception when compiling C++ code, so set the + # no_builtin_flag separately + if test yes = "$GXX"; then + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin' + else + _LT_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)= + fi + + if test yes = "$GXX"; then + # Set up default GNU C++ configuration + + LT_PATH_LD + + # Check if GNU C++ uses GNU ld as the underlying linker, since the + # archiving commands below assume that GNU ld is being used. + if test yes = "$with_gnu_ld"; then + _LT_TAGVAR(archive_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + + # If archive_cmds runs LD, not CC, wlarc should be empty + # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to + # investigate it a little bit more. (MM) + wlarc='$wl' + + # ancient GNU ld didn't support --whole-archive et. al. + if eval "`$CC -print-prog-name=ld` --help 2>&1" | + $GREP 'no-whole-archive' > /dev/null; then + _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' + else + _LT_TAGVAR(whole_archive_flag_spec, $1)= + fi + else + with_gnu_ld=no + wlarc= + + # A generic and very simple default shared library creation + # command for GNU C++ for the case where it uses the native + # linker, instead of GNU ld. If possible, this setting should + # overridden to take advantage of the native linker features on + # the platform it is being used on. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + fi + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + + else + GXX=no + with_gnu_ld=no + wlarc= + fi + + # PORTME: fill in a description of your system's C++ link characteristics + AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries]) + _LT_TAGVAR(ld_shlibs, $1)=yes + case $host_os in + aix3*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aix[[4-9]]*) + if test ia64 = "$host_cpu"; then + # On IA64, the linker does run time linking by default, so we don't + # have to do anything special. + aix_use_runtimelinking=no + exp_sym_flag='-Bexport' + no_entry_flag= + else + aix_use_runtimelinking=no + + # Test if we are trying to use run time linking or normal + # AIX style linking. If -brtl is somewhere in LDFLAGS, we + # have runtime linking enabled, and use it for executables. + # For shared libraries, we enable/disable runtime linking + # depending on the kind of the shared library created - + # when "with_aix_soname,aix_use_runtimelinking" is: + # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables + # "aix,yes" lib.so shared, rtl:yes, for executables + # lib.a static archive + # "both,no" lib.so.V(shr.o) shared, rtl:yes + # lib.a(lib.so.V) shared, rtl:no, for executables + # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a(lib.so.V) shared, rtl:no + # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables + # lib.a static archive + case $host_os in aix4.[[23]]|aix4.[[23]].*|aix[[5-9]]*) + for ld_flag in $LDFLAGS; do + case $ld_flag in + *-brtl*) + aix_use_runtimelinking=yes + break + ;; + esac + done + if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then + # With aix-soname=svr4, we create the lib.so.V shared archives only, + # so we don't have lib.a shared libs to link our executables. + # We have to force runtime linking in this case. + aix_use_runtimelinking=yes + LDFLAGS="$LDFLAGS -Wl,-brtl" + fi + ;; + esac + + exp_sym_flag='-bexport' + no_entry_flag='-bnoentry' + fi + + # When large executables or shared objects are built, AIX ld can + # have problems creating the table of contents. If linking a library + # or program results in "error TOC overflow" add -mminimal-toc to + # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not + # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS. + + _LT_TAGVAR(archive_cmds, $1)='' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='$wl-f,' + case $with_aix_soname,$aix_use_runtimelinking in + aix,*) ;; # no import file + svr4,* | *,yes) # use import file + # The Import File defines what to hardcode. + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=no + ;; + esac + + if test yes = "$GXX"; then + case $host_os in aix4.[[012]]|aix4.[[012]].*) + # We only want to do this on AIX 4.2 and lower, the check + # below for broken collect2 doesn't work under 4.3+ + collect2name=`$CC -print-prog-name=collect2` + if test -f "$collect2name" && + strings "$collect2name" | $GREP resolve_lib_name >/dev/null + then + # We have reworked collect2 + : + else + # We have old collect2 + _LT_TAGVAR(hardcode_direct, $1)=unsupported + # It fails to find uninstalled libraries when the uninstalled + # path is not listed in the libpath. Setting hardcode_minus_L + # to unsupported forces relinking + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)= + fi + esac + shared_flag='-shared' + if test yes = "$aix_use_runtimelinking"; then + shared_flag=$shared_flag' $wl-G' + fi + # Need to ensure runtime linking is disabled for the traditional + # shared library, or the linker may eventually find shared libraries + # /with/ Import File - we do not want to mix them. + shared_flag_aix='-shared' + shared_flag_svr4='-shared $wl-G' + else + # not using gcc + if test ia64 = "$host_cpu"; then + # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release + # chokes on -Wl,-G. The following line is correct: + shared_flag='-G' + else + if test yes = "$aix_use_runtimelinking"; then + shared_flag='$wl-G' + else + shared_flag='$wl-bM:SRE' + fi + shared_flag_aix='$wl-bM:SRE' + shared_flag_svr4='$wl-G' + fi + fi + + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-bexpall' + # It seems that -bexpall does not export symbols beginning with + # underscore (_), so it is better to generate a list of symbols to + # export. + _LT_TAGVAR(always_export_symbols, $1)=yes + if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then + # Warning - without using the other runtime loading flags (-brtl), + # -berok will link without error, but may produce a broken library. + # The "-G" linker flag allows undefined symbols. + _LT_TAGVAR(no_undefined_flag, $1)='-bernotok' + # Determine the default libpath from the value encoded in an empty + # executable. + _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" + + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag + else + if test ia64 = "$host_cpu"; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $libdir:/usr/lib:/lib' + _LT_TAGVAR(allow_undefined_flag, $1)="-z nodefs" + _LT_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols" + else + # Determine the default libpath from the value encoded in an + # empty executable. + _LT_SYS_MODULE_PATH_AIX([$1]) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-blibpath:$libdir:'"$aix_libpath" + # Warning - without using the other run time loading flags, + # -berok will link without error, but may produce a broken library. + _LT_TAGVAR(no_undefined_flag, $1)=' $wl-bernotok' + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-berok' + if test yes = "$with_gnu_ld"; then + # We only use this code for GNU lds that support --whole-archive. + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' + else + # Exported symbols can be pulled into shared objects from archives + _LT_TAGVAR(whole_archive_flag_spec, $1)='$convenience' + fi + _LT_TAGVAR(archive_cmds_need_lc, $1)=yes + _LT_TAGVAR(archive_expsym_cmds, $1)='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d' + # -brtl affects multiple linker settings, -berok does not and is overridden later + compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([[, ]]\\)%-berok\\1%g"`' + if test svr4 != "$with_aix_soname"; then + # This is similar to how AIX traditionally builds its shared + # libraries. Need -bnortl late, we may have -brtl in LDFLAGS. + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname' + fi + if test aix != "$with_aix_soname"; then + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp' + else + # used by -dlpreopen to get the symbols + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$MV $output_objdir/$realname.d/$soname $output_objdir' + fi + _LT_TAGVAR(archive_expsym_cmds, $1)="$_LT_TAGVAR(archive_expsym_cmds, $1)"'~$RM -r $output_objdir/$realname.d' + fi + fi + ;; + + beos*) + if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + # Joseph Beckenbach says some releases of gcc + # support --undefined. This deserves some investigation. FIXME + _LT_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + chorus*) + case $cc_basename in + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + cygwin* | mingw* | pw32* | cegcc*) + case $GXX,$cc_basename in + ,cl* | no,cl*) + # Native MSVC + # hardcode_libdir_flag_spec is actually meaningless, as there is + # no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)=' ' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=yes + _LT_TAGVAR(file_list_spec, $1)='@' + # Tell ltmain to make .lib files, not .a files. + libext=lib + # Tell ltmain to make .dll files, not .so files. + shrext_cmds=.dll + # FIXME: Setting linknames here is a bad hack. + _LT_TAGVAR(archive_cmds, $1)='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames=' + _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then + cp "$export_symbols" "$output_objdir/$soname.def"; + echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp"; + else + $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp; + fi~ + $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~ + linknames=' + # The linker will not automatically build a static lib if we build a DLL. + # _LT_TAGVAR(old_archive_from_new_cmds, $1)='true' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + # Don't use ranlib + _LT_TAGVAR(old_postinstall_cmds, $1)='chmod 644 $oldlib' + _LT_TAGVAR(postlink_cmds, $1)='lt_outputfile="@OUTPUT@"~ + lt_tool_outputfile="@TOOL_OUTPUT@"~ + case $lt_outputfile in + *.exe|*.EXE) ;; + *) + lt_outputfile=$lt_outputfile.exe + lt_tool_outputfile=$lt_tool_outputfile.exe + ;; + esac~ + func_to_tool_file "$lt_outputfile"~ + if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then + $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1; + $RM "$lt_outputfile.manifest"; + fi' + ;; + *) + # g++ + # _LT_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless, + # as there is no search path for DLLs. + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-all-symbols' + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + _LT_TAGVAR(always_export_symbols, $1)=no + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + + if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + # If the export-symbols file already is a .def file, use it as + # is; otherwise, prepend EXPORTS... + _LT_TAGVAR(archive_expsym_cmds, $1)='if _LT_DLL_DEF_P([$export_symbols]); then + cp $export_symbols $output_objdir/$soname.def; + else + echo EXPORTS > $output_objdir/$soname.def; + cat $export_symbols >> $output_objdir/$soname.def; + fi~ + $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib' + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + darwin* | rhapsody*) + _LT_DARWIN_LINKER_FEATURES($1) + ;; + + os2*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir' + _LT_TAGVAR(hardcode_minus_L, $1)=yes + _LT_TAGVAR(allow_undefined_flag, $1)=unsupported + shrext_cmds=.dll + _LT_TAGVAR(archive_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(archive_expsym_cmds, $1)='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~ + $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~ + $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~ + $ECHO EXPORTS >> $output_objdir/$libname.def~ + prefix_cmds="$SED"~ + if test EXPORTS = "`$SED 1q $export_symbols`"; then + prefix_cmds="$prefix_cmds -e 1d"; + fi~ + prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~ + cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~ + $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~ + emximp -o $lib $output_objdir/$libname.def' + _LT_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' + _LT_TAGVAR(enable_shared_with_static_runtimes, $1)=yes + ;; + + dgux*) + case $cc_basename in + ec++*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + ghcx*) + # Green Hills C++ Compiler + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + freebsd2.*) + # C++ shared libraries reported to be fairly broken before + # switch to ELF + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + freebsd-elf*) + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + ;; + + freebsd* | dragonfly*) + # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF + # conventions + _LT_TAGVAR(ld_shlibs, $1)=yes + ;; + + haiku*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + + hpux9*) + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -b $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + ;; + *) + if test yes = "$GXX"; then + _LT_TAGVAR(archive_cmds, $1)='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib' + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + hpux10*|hpux11*) + if test no = "$with_gnu_ld"; then + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl+b $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + case $host_cpu in + hppa*64*|ia64*) + ;; + *) + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + ;; + esac + fi + case $host_cpu in + hppa*64*|ia64*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + ;; + *) + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH, + # but as the default + # location of the library. + ;; + esac + + case $cc_basename in + CC*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + aCC*) + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + ;; + *) + if test yes = "$GXX"; then + if test no = "$with_gnu_ld"; then + case $host_cpu in + hppa*64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC $wl+h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + ia64*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + ;; + esac + fi + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + interix[[3-9]]*) + _LT_TAGVAR(hardcode_direct, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc. + # Instead, shared libraries are loaded at an image base (0x10000000 by + # default) and relocated if they conflict, which is a slow very memory + # consuming and fragmenting process. To avoid this, we pick a random, + # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link + # time. Moving up from 0x10000000 also allows more sbrk(2) space. + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' + ;; + irix5* | irix6*) + case $cc_basename in + CC*) + # SGI C++ + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + + # Archives containing C++ object files must be created using + # "CC -ar", where "CC" is the IRIX C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs' + ;; + *) + if test yes = "$GXX"; then + if test no = "$with_gnu_ld"; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + else + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` -o $lib' + fi + fi + _LT_TAGVAR(link_all_deplibs, $1)=yes + ;; + esac + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + _LT_TAGVAR(inherit_rpath, $1)=yes + ;; + + linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib $wl-retain-symbols-file,$export_symbols; mv \$templib $lib' + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + + # Archives containing C++ object files must be created using + # "CC -Bstatic", where "CC" is the KAI C++ compiler. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' + ;; + icpc* | ecpc* ) + # Intel C++ + with_gnu_ld=yes + # version 8.0 and above of icpc choke on multiply defined symbols + # if we add $predep_objects and $postdep_objects, however 7.1 and + # earlier do not add the objects themselves. + case `$CC -V 2>&1` in + *"Version 7."*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + ;; + *) # Version 8.0 or newer + tmp_idyn= + case $host_cpu in + ia64*) tmp_idyn=' -i_dynamic';; + esac + _LT_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive$convenience $wl--no-whole-archive' + ;; + pgCC* | pgcpp*) + # Portland Group C++ compiler + case `$CC -V` in + *pgCC\ [[1-5]].* | *pgcpp\ [[1-5]].*) + _LT_TAGVAR(prelink_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~ + compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"' + _LT_TAGVAR(old_archive_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~ + $AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~ + $RANLIB $oldlib' + _LT_TAGVAR(archive_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='tpldir=Template.dir~ + rm -rf $tpldir~ + $CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~ + $CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + ;; + *) # Version 6 and above use weak symbols + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl--rpath $wl$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + ;; + cxx*) + # Compaq C++ + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname -o $lib $wl-retain-symbols-file $wl$export_symbols' + + runpath_var=LD_RUN_PATH + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed' + ;; + xl* | mpixl* | bgxl*) + # IBM XL 8.0 on PPC, with GNU ld + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl--export-dynamic' + _LT_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib' + if test yes = "$supports_anon_versioning"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $output_objdir/$libname.ver~ + cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ + echo "local: *; };" >> $output_objdir/$libname.ver~ + $CC -qmkshrobj $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' + fi + ;; + *) + case `$CC -V 2>&1 | sed 5q` in + *Sun\ C*) + # Sun C++ 5.9 + _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file $wl$export_symbols' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' + _LT_TAGVAR(compiler_needs_object, $1)=yes + + # Not sure whether something based on + # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 + # would be better. + output_verbose_link_cmd='func_echo_all' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + esac + ;; + esac + ;; + + lynxos*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + m88k*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + mvs*) + case $cc_basename in + cxx*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + netbsd*) + if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags' + wlarc= + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + fi + # Workaround some broken pre-1.5 toolchains + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"' + ;; + + *nto* | *qnx*) + _LT_TAGVAR(ld_shlibs, $1)=yes + ;; + + openbsd* | bitrig*) + if test -f /usr/libexec/ld.so; then + _LT_TAGVAR(hardcode_direct, $1)=yes + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_direct_absolute, $1)=yes + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`"; then + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-retain-symbols-file,$export_symbols -o $lib' + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-E' + _LT_TAGVAR(whole_archive_flag_spec, $1)=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive' + fi + output_verbose_link_cmd=func_echo_all + else + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + + osf3* | osf4* | osf5*) + case $cc_basename in + KCC*) + # Kuck and Associates, Inc. (KAI) C++ Compiler + + # KCC will only create a shared library if the output file + # ends with ".so" (or ".sl" for HP-UX), so rename the library + # to its proper name (with version) after linking. + _LT_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\$tempext\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Archives containing C++ object files must be created using + # the KAI C++ compiler. + case $host in + osf3*) _LT_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs' ;; + *) _LT_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs' ;; + esac + ;; + RCC*) + # Rational C++ 2.4.1 + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + cxx*) + case $host in + osf3*) + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $soname `test -n "$verstring" && func_echo_all "$wl-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + ;; + *) + _LT_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*' + _LT_TAGVAR(archive_cmds, $1)='$CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~ + echo "-hidden">> $lib.exp~ + $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname $wl-input $wl$lib.exp `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~ + $RM $lib.exp' + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + # + # There doesn't appear to be a way to prevent this compiler from + # explicitly linking system object files so we need to strip them + # from the output so that they don't get included in the library + # dependencies. + output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list= ; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"' + ;; + *) + if test yes,no = "$GXX,$with_gnu_ld"; then + _LT_TAGVAR(allow_undefined_flag, $1)=' $wl-expect_unresolved $wl\*' + case $host in + osf3*) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib' + ;; + esac + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-rpath $wl$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=: + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + + else + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + fi + ;; + esac + ;; + + psos*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + sunos4*) + case $cc_basename in + CC*) + # Sun C++ 4.x + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + lcc*) + # Lucid + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + solaris*) + case $cc_basename in + CC* | sunCC*) + # Sun C++ 4.2, 5.x and Centerline C++ + _LT_TAGVAR(archive_cmds_need_lc,$1)=yes + _LT_TAGVAR(no_undefined_flag, $1)=' -zdefs' + _LT_TAGVAR(archive_cmds, $1)='$CC -G$allow_undefined_flag -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G$allow_undefined_flag $wl-M $wl$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir' + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + # The compiler driver will combine and reorder linker options, + # but understands '-z linker_flag'. + # Supported since Solaris 2.6 (maybe 2.5.1?) + _LT_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' + ;; + esac + _LT_TAGVAR(link_all_deplibs, $1)=yes + + output_verbose_link_cmd='func_echo_all' + + # Archives containing C++ object files must be created using + # "CC -xar", where "CC" is the Sun C++ compiler. This is + # necessary to make sure instantiated templates are included + # in the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs' + ;; + gcx*) + # Green Hills C++ Compiler + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' + + # The C++ compiler must be used to create the archive. + _LT_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs' + ;; + *) + # GNU C++ compiler with Solaris linker + if test yes,no = "$GXX,$with_gnu_ld"; then + _LT_TAGVAR(no_undefined_flag, $1)=' $wl-z ${wl}defs' + if $CC --version | $GREP -v '^2\.7' > /dev/null; then + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -shared $pic_flag -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + else + # g++ 2.7 appears to require '-G' NOT '-shared' on this + # platform. + _LT_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags $wl-h $wl$soname -o $lib' + _LT_TAGVAR(archive_expsym_cmds, $1)='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~ + $CC -G -nostdlib $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp' + + # Commands to make compiler produce verbose output that lists + # what "hidden" libraries, object files and flags are used when + # linking a shared library. + output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"' + fi + + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R $wl$libdir' + case $host_os in + solaris2.[[0-5]] | solaris2.[[0-5]].*) ;; + *) + _LT_TAGVAR(whole_archive_flag_spec, $1)='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract' + ;; + esac + fi + ;; + esac + ;; + + sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[[01]].[[10]]* | unixware7* | sco3.2v5.0.[[024]]*) + _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + sysv5* | sco3.2v5* | sco5v6*) + # Note: We CANNOT use -z defs as we might desire, because we do not + # link with -lc, and that would cause any symbols used from libc to + # always be unresolved, which means just about no library would + # ever link correctly. If we're not using GNU ld we use -z text + # though, which does catch some bad symbols but isn't as heavy-handed + # as -z defs. + _LT_TAGVAR(no_undefined_flag, $1)='$wl-z,text' + _LT_TAGVAR(allow_undefined_flag, $1)='$wl-z,nodefs' + _LT_TAGVAR(archive_cmds_need_lc, $1)=no + _LT_TAGVAR(hardcode_shlibpath_var, $1)=no + _LT_TAGVAR(hardcode_libdir_flag_spec, $1)='$wl-R,$libdir' + _LT_TAGVAR(hardcode_libdir_separator, $1)=':' + _LT_TAGVAR(link_all_deplibs, $1)=yes + _LT_TAGVAR(export_dynamic_flag_spec, $1)='$wl-Bexport' + runpath_var='LD_RUN_PATH' + + case $cc_basename in + CC*) + _LT_TAGVAR(archive_cmds, $1)='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(old_archive_cmds, $1)='$CC -Tprelink_objects $oldobjs~ + '"$_LT_TAGVAR(old_archive_cmds, $1)" + _LT_TAGVAR(reload_cmds, $1)='$CC -Tprelink_objects $reload_objs~ + '"$_LT_TAGVAR(reload_cmds, $1)" + ;; + *) + _LT_TAGVAR(archive_cmds, $1)='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + _LT_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags' + ;; + esac + ;; + + tandem*) + case $cc_basename in + NCC*) + # NonStop-UX NCC 3.20 + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + ;; + + vxworks*) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + + *) + # FIXME: insert proper C++ library support + _LT_TAGVAR(ld_shlibs, $1)=no + ;; + esac + + AC_MSG_RESULT([$_LT_TAGVAR(ld_shlibs, $1)]) + test no = "$_LT_TAGVAR(ld_shlibs, $1)" && can_build_shared=no + + _LT_TAGVAR(GCC, $1)=$GXX + _LT_TAGVAR(LD, $1)=$LD + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_SYS_HIDDEN_LIBDEPS($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + CC=$lt_save_CC + CFLAGS=$lt_save_CFLAGS + LDCXX=$LD + LD=$lt_save_LD + GCC=$lt_save_GCC + with_gnu_ld=$lt_save_with_gnu_ld + lt_cv_path_LDCXX=$lt_cv_path_LD + lt_cv_path_LD=$lt_save_path_LD + lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld + lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld +fi # test yes != "$_lt_caught_CXX_error" + +AC_LANG_POP +])# _LT_LANG_CXX_CONFIG + + +# _LT_FUNC_STRIPNAME_CNF +# ---------------------- +# func_stripname_cnf prefix suffix name +# strip PREFIX and SUFFIX off of NAME. +# PREFIX and SUFFIX must not contain globbing or regex special +# characters, hashes, percent signs, but SUFFIX may contain a leading +# dot (in which case that matches only a dot). +# +# This function is identical to the (non-XSI) version of func_stripname, +# except this one can be used by m4 code that may be executed by configure, +# rather than the libtool script. +m4_defun([_LT_FUNC_STRIPNAME_CNF],[dnl +AC_REQUIRE([_LT_DECL_SED]) +AC_REQUIRE([_LT_PROG_ECHO_BACKSLASH]) +func_stripname_cnf () +{ + case @S|@2 in + .*) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%\\\\@S|@2\$%%"`;; + *) func_stripname_result=`$ECHO "@S|@3" | $SED "s%^@S|@1%%; s%@S|@2\$%%"`;; + esac +} # func_stripname_cnf +])# _LT_FUNC_STRIPNAME_CNF + + +# _LT_SYS_HIDDEN_LIBDEPS([TAGNAME]) +# --------------------------------- +# Figure out "hidden" library dependencies from verbose +# compiler output when linking a shared library. +# Parse the compiler output and extract the necessary +# objects, libraries and library flags. +m4_defun([_LT_SYS_HIDDEN_LIBDEPS], +[m4_require([_LT_FILEUTILS_DEFAULTS])dnl +AC_REQUIRE([_LT_FUNC_STRIPNAME_CNF])dnl +# Dependencies to place before and after the object being linked: +_LT_TAGVAR(predep_objects, $1)= +_LT_TAGVAR(postdep_objects, $1)= +_LT_TAGVAR(predeps, $1)= +_LT_TAGVAR(postdeps, $1)= +_LT_TAGVAR(compiler_lib_search_path, $1)= + +dnl we can't use the lt_simple_compile_test_code here, +dnl because it contains code intended for an executable, +dnl not a library. It's possible we should let each +dnl tag define a new lt_????_link_test_code variable, +dnl but it's only used here... +m4_if([$1], [], [cat > conftest.$ac_ext <<_LT_EOF +int a; +void foo (void) { a = 0; } +_LT_EOF +], [$1], [CXX], [cat > conftest.$ac_ext <<_LT_EOF +class Foo +{ +public: + Foo (void) { a = 0; } +private: + int a; +}; +_LT_EOF +], [$1], [F77], [cat > conftest.$ac_ext <<_LT_EOF + subroutine foo + implicit none + integer*4 a + a=0 + return + end +_LT_EOF +], [$1], [FC], [cat > conftest.$ac_ext <<_LT_EOF + subroutine foo + implicit none + integer a + a=0 + return + end +_LT_EOF +], [$1], [GCJ], [cat > conftest.$ac_ext <<_LT_EOF +public class foo { + private int a; + public void bar (void) { + a = 0; + } +}; +_LT_EOF +], [$1], [GO], [cat > conftest.$ac_ext <<_LT_EOF +package foo +func foo() { +} +_LT_EOF +]) + +_lt_libdeps_save_CFLAGS=$CFLAGS +case "$CC $CFLAGS " in #( +*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;; +*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;; +*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;; +esac + +dnl Parse the compiler output and extract the necessary +dnl objects, libraries and library flags. +if AC_TRY_EVAL(ac_compile); then + # Parse the compiler output and extract the necessary + # objects, libraries and library flags. + + # Sentinel used to keep track of whether or not we are before + # the conftest object file. + pre_test_object_deps_done=no + + for p in `eval "$output_verbose_link_cmd"`; do + case $prev$p in + + -L* | -R* | -l*) + # Some compilers place space between "-{L,R}" and the path. + # Remove the space. + if test x-L = "$p" || + test x-R = "$p"; then + prev=$p + continue + fi + + # Expand the sysroot to ease extracting the directories later. + if test -z "$prev"; then + case $p in + -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;; + -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;; + -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;; + esac + fi + case $p in + =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;; + esac + if test no = "$pre_test_object_deps_done"; then + case $prev in + -L | -R) + # Internal compiler library paths should come after those + # provided the user. The postdeps already come after the + # user supplied libs so there is no need to process them. + if test -z "$_LT_TAGVAR(compiler_lib_search_path, $1)"; then + _LT_TAGVAR(compiler_lib_search_path, $1)=$prev$p + else + _LT_TAGVAR(compiler_lib_search_path, $1)="${_LT_TAGVAR(compiler_lib_search_path, $1)} $prev$p" + fi + ;; + # The "-l" case would never come before the object being + # linked, so don't bother handling this case. + esac + else + if test -z "$_LT_TAGVAR(postdeps, $1)"; then + _LT_TAGVAR(postdeps, $1)=$prev$p + else + _LT_TAGVAR(postdeps, $1)="${_LT_TAGVAR(postdeps, $1)} $prev$p" + fi + fi + prev= + ;; + + *.lto.$objext) ;; # Ignore GCC LTO objects + *.$objext) + # This assumes that the test object file only shows up + # once in the compiler output. + if test "$p" = "conftest.$objext"; then + pre_test_object_deps_done=yes + continue + fi + + if test no = "$pre_test_object_deps_done"; then + if test -z "$_LT_TAGVAR(predep_objects, $1)"; then + _LT_TAGVAR(predep_objects, $1)=$p + else + _LT_TAGVAR(predep_objects, $1)="$_LT_TAGVAR(predep_objects, $1) $p" + fi + else + if test -z "$_LT_TAGVAR(postdep_objects, $1)"; then + _LT_TAGVAR(postdep_objects, $1)=$p + else + _LT_TAGVAR(postdep_objects, $1)="$_LT_TAGVAR(postdep_objects, $1) $p" + fi + fi + ;; + + *) ;; # Ignore the rest. + + esac + done + + # Clean up. + rm -f a.out a.exe +else + echo "libtool.m4: error: problem compiling $1 test program" +fi + +$RM -f confest.$objext +CFLAGS=$_lt_libdeps_save_CFLAGS + +# PORTME: override above test on systems where it is broken +m4_if([$1], [CXX], +[case $host_os in +interix[[3-9]]*) + # Interix 3.5 installs completely hosed .la files for C++, so rather than + # hack all around it, let's just trust "g++" to DTRT. + _LT_TAGVAR(predep_objects,$1)= + _LT_TAGVAR(postdep_objects,$1)= + _LT_TAGVAR(postdeps,$1)= + ;; +esac +]) + +case " $_LT_TAGVAR(postdeps, $1) " in +*" -lc "*) _LT_TAGVAR(archive_cmds_need_lc, $1)=no ;; +esac + _LT_TAGVAR(compiler_lib_search_dirs, $1)= +if test -n "${_LT_TAGVAR(compiler_lib_search_path, $1)}"; then + _LT_TAGVAR(compiler_lib_search_dirs, $1)=`echo " ${_LT_TAGVAR(compiler_lib_search_path, $1)}" | $SED -e 's! -L! !g' -e 's!^ !!'` +fi +_LT_TAGDECL([], [compiler_lib_search_dirs], [1], + [The directories searched by this compiler when creating a shared library]) +_LT_TAGDECL([], [predep_objects], [1], + [Dependencies to place before and after the objects being linked to + create a shared library]) +_LT_TAGDECL([], [postdep_objects], [1]) +_LT_TAGDECL([], [predeps], [1]) +_LT_TAGDECL([], [postdeps], [1]) +_LT_TAGDECL([], [compiler_lib_search_path], [1], + [The library search path used internally by the compiler when linking + a shared library]) +])# _LT_SYS_HIDDEN_LIBDEPS + + +# _LT_LANG_F77_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for a Fortran 77 compiler are +# suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_F77_CONFIG], +[AC_LANG_PUSH(Fortran 77) +if test -z "$F77" || test no = "$F77"; then + _lt_disable_F77=yes +fi + +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for f77 test sources. +ac_ext=f + +# Object file extension for compiled f77 test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the F77 compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test yes != "$_lt_disable_F77"; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="\ + subroutine t + return + end +" + + # Code to be used in simple link tests + lt_simple_link_test_code="\ + program t + end +" + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC=$CC + lt_save_GCC=$GCC + lt_save_CFLAGS=$CFLAGS + CC=${F77-"f77"} + CFLAGS=$FFLAGS + compiler=$CC + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + GCC=$G77 + if test -n "$compiler"; then + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test no = "$can_build_shared" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test yes = "$enable_shared" && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + aix[[4-9]]*) + if test ia64 != "$host_cpu"; then + case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in + yes,aix,yes) ;; # shared object as lib.so file only + yes,svr4,*) ;; # shared object as lib.so archive member only + yes,*) enable_static=no ;; # shared object in lib.a archive as well + esac + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test yes = "$enable_shared" || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_TAGVAR(GCC, $1)=$G77 + _LT_TAGVAR(LD, $1)=$LD + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + GCC=$lt_save_GCC + CC=$lt_save_CC + CFLAGS=$lt_save_CFLAGS +fi # test yes != "$_lt_disable_F77" + +AC_LANG_POP +])# _LT_LANG_F77_CONFIG + + +# _LT_LANG_FC_CONFIG([TAG]) +# ------------------------- +# Ensure that the configuration variables for a Fortran compiler are +# suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_FC_CONFIG], +[AC_LANG_PUSH(Fortran) + +if test -z "$FC" || test no = "$FC"; then + _lt_disable_FC=yes +fi + +_LT_TAGVAR(archive_cmds_need_lc, $1)=no +_LT_TAGVAR(allow_undefined_flag, $1)= +_LT_TAGVAR(always_export_symbols, $1)=no +_LT_TAGVAR(archive_expsym_cmds, $1)= +_LT_TAGVAR(export_dynamic_flag_spec, $1)= +_LT_TAGVAR(hardcode_direct, $1)=no +_LT_TAGVAR(hardcode_direct_absolute, $1)=no +_LT_TAGVAR(hardcode_libdir_flag_spec, $1)= +_LT_TAGVAR(hardcode_libdir_separator, $1)= +_LT_TAGVAR(hardcode_minus_L, $1)=no +_LT_TAGVAR(hardcode_automatic, $1)=no +_LT_TAGVAR(inherit_rpath, $1)=no +_LT_TAGVAR(module_cmds, $1)= +_LT_TAGVAR(module_expsym_cmds, $1)= +_LT_TAGVAR(link_all_deplibs, $1)=unknown +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds +_LT_TAGVAR(no_undefined_flag, $1)= +_LT_TAGVAR(whole_archive_flag_spec, $1)= +_LT_TAGVAR(enable_shared_with_static_runtimes, $1)=no + +# Source file extension for fc test sources. +ac_ext=${ac_fc_srcext-f} + +# Object file extension for compiled fc test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# No sense in running all these tests if we already determined that +# the FC compiler isn't working. Some variables (like enable_shared) +# are currently assumed to apply to all compilers on this platform, +# and will be corrupted by setting them based on a non-working compiler. +if test yes != "$_lt_disable_FC"; then + # Code to be used in simple compile tests + lt_simple_compile_test_code="\ + subroutine t + return + end +" + + # Code to be used in simple link tests + lt_simple_link_test_code="\ + program t + end +" + + # ltmain only uses $CC for tagged configurations so make sure $CC is set. + _LT_TAG_COMPILER + + # save warnings/boilerplate of simple test code + _LT_COMPILER_BOILERPLATE + _LT_LINKER_BOILERPLATE + + # Allow CC to be a program name with arguments. + lt_save_CC=$CC + lt_save_GCC=$GCC + lt_save_CFLAGS=$CFLAGS + CC=${FC-"f95"} + CFLAGS=$FCFLAGS + compiler=$CC + GCC=$ac_cv_fc_compiler_gnu + + _LT_TAGVAR(compiler, $1)=$CC + _LT_CC_BASENAME([$compiler]) + + if test -n "$compiler"; then + AC_MSG_CHECKING([if libtool supports shared libraries]) + AC_MSG_RESULT([$can_build_shared]) + + AC_MSG_CHECKING([whether to build shared libraries]) + test no = "$can_build_shared" && enable_shared=no + + # On AIX, shared libraries and static libraries use the same namespace, and + # are all built from PIC. + case $host_os in + aix3*) + test yes = "$enable_shared" && enable_static=no + if test -n "$RANLIB"; then + archive_cmds="$archive_cmds~\$RANLIB \$lib" + postinstall_cmds='$RANLIB $lib' + fi + ;; + aix[[4-9]]*) + if test ia64 != "$host_cpu"; then + case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in + yes,aix,yes) ;; # shared object as lib.so file only + yes,svr4,*) ;; # shared object as lib.so archive member only + yes,*) enable_static=no ;; # shared object in lib.a archive as well + esac + fi + ;; + esac + AC_MSG_RESULT([$enable_shared]) + + AC_MSG_CHECKING([whether to build static libraries]) + # Make sure either enable_shared or enable_static is yes. + test yes = "$enable_shared" || enable_static=yes + AC_MSG_RESULT([$enable_static]) + + _LT_TAGVAR(GCC, $1)=$ac_cv_fc_compiler_gnu + _LT_TAGVAR(LD, $1)=$LD + + ## CAVEAT EMPTOR: + ## There is no encapsulation within the following macros, do not change + ## the running order or otherwise move them around unless you know exactly + ## what you are doing... + _LT_SYS_HIDDEN_LIBDEPS($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_SYS_DYNAMIC_LINKER($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) + fi # test -n "$compiler" + + GCC=$lt_save_GCC + CC=$lt_save_CC + CFLAGS=$lt_save_CFLAGS +fi # test yes != "$_lt_disable_FC" + +AC_LANG_POP +])# _LT_LANG_FC_CONFIG + + +# _LT_LANG_GCJ_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for the GNU Java Compiler compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_GCJ_CONFIG], +[AC_REQUIRE([LT_PROG_GCJ])dnl +AC_LANG_SAVE + +# Source file extension for Java test sources. +ac_ext=java + +# Object file extension for compiled Java test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="class foo {}" + +# Code to be used in simple link tests +lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_CFLAGS=$CFLAGS +lt_save_GCC=$GCC +GCC=yes +CC=${GCJ-"gcj"} +CFLAGS=$GCJFLAGS +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_TAGVAR(LD, $1)=$LD +_LT_CC_BASENAME([$compiler]) + +# GCJ did not exist at the time GCC didn't implicitly link libc in. +_LT_TAGVAR(archive_cmds_need_lc, $1)=no + +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) +fi + +AC_LANG_RESTORE + +GCC=$lt_save_GCC +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS +])# _LT_LANG_GCJ_CONFIG + + +# _LT_LANG_GO_CONFIG([TAG]) +# -------------------------- +# Ensure that the configuration variables for the GNU Go compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_GO_CONFIG], +[AC_REQUIRE([LT_PROG_GO])dnl +AC_LANG_SAVE + +# Source file extension for Go test sources. +ac_ext=go + +# Object file extension for compiled Go test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code="package main; func main() { }" + +# Code to be used in simple link tests +lt_simple_link_test_code='package main; func main() { }' + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_CFLAGS=$CFLAGS +lt_save_GCC=$GCC +GCC=yes +CC=${GOC-"gccgo"} +CFLAGS=$GOFLAGS +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_TAGVAR(LD, $1)=$LD +_LT_CC_BASENAME([$compiler]) + +# Go did not exist at the time GCC didn't implicitly link libc in. +_LT_TAGVAR(archive_cmds_need_lc, $1)=no + +_LT_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds +_LT_TAGVAR(reload_flag, $1)=$reload_flag +_LT_TAGVAR(reload_cmds, $1)=$reload_cmds + +## CAVEAT EMPTOR: +## There is no encapsulation within the following macros, do not change +## the running order or otherwise move them around unless you know exactly +## what you are doing... +if test -n "$compiler"; then + _LT_COMPILER_NO_RTTI($1) + _LT_COMPILER_PIC($1) + _LT_COMPILER_C_O($1) + _LT_COMPILER_FILE_LOCKS($1) + _LT_LINKER_SHLIBS($1) + _LT_LINKER_HARDCODE_LIBPATH($1) + + _LT_CONFIG($1) +fi + +AC_LANG_RESTORE + +GCC=$lt_save_GCC +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS +])# _LT_LANG_GO_CONFIG + + +# _LT_LANG_RC_CONFIG([TAG]) +# ------------------------- +# Ensure that the configuration variables for the Windows resource compiler +# are suitably defined. These variables are subsequently used by _LT_CONFIG +# to write the compiler configuration to 'libtool'. +m4_defun([_LT_LANG_RC_CONFIG], +[AC_REQUIRE([LT_PROG_RC])dnl +AC_LANG_SAVE + +# Source file extension for RC test sources. +ac_ext=rc + +# Object file extension for compiled RC test sources. +objext=o +_LT_TAGVAR(objext, $1)=$objext + +# Code to be used in simple compile tests +lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }' + +# Code to be used in simple link tests +lt_simple_link_test_code=$lt_simple_compile_test_code + +# ltmain only uses $CC for tagged configurations so make sure $CC is set. +_LT_TAG_COMPILER + +# save warnings/boilerplate of simple test code +_LT_COMPILER_BOILERPLATE +_LT_LINKER_BOILERPLATE + +# Allow CC to be a program name with arguments. +lt_save_CC=$CC +lt_save_CFLAGS=$CFLAGS +lt_save_GCC=$GCC +GCC= +CC=${RC-"windres"} +CFLAGS= +compiler=$CC +_LT_TAGVAR(compiler, $1)=$CC +_LT_CC_BASENAME([$compiler]) +_LT_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes + +if test -n "$compiler"; then + : + _LT_CONFIG($1) +fi + +GCC=$lt_save_GCC +AC_LANG_RESTORE +CC=$lt_save_CC +CFLAGS=$lt_save_CFLAGS +])# _LT_LANG_RC_CONFIG + + +# LT_PROG_GCJ +# ----------- +AC_DEFUN([LT_PROG_GCJ], +[m4_ifdef([AC_PROG_GCJ], [AC_PROG_GCJ], + [m4_ifdef([A][M_PROG_GCJ], [A][M_PROG_GCJ], + [AC_CHECK_TOOL(GCJ, gcj,) + test set = "${GCJFLAGS+set}" || GCJFLAGS="-g -O2" + AC_SUBST(GCJFLAGS)])])[]dnl +]) + +# Old name: +AU_ALIAS([LT_AC_PROG_GCJ], [LT_PROG_GCJ]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_GCJ], []) + + +# LT_PROG_GO +# ---------- +AC_DEFUN([LT_PROG_GO], +[AC_CHECK_TOOL(GOC, gccgo,) +]) + + +# LT_PROG_RC +# ---------- +AC_DEFUN([LT_PROG_RC], +[AC_CHECK_TOOL(RC, windres,) +]) + +# Old name: +AU_ALIAS([LT_AC_PROG_RC], [LT_PROG_RC]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_RC], []) + + +# _LT_DECL_EGREP +# -------------- +# If we don't have a new enough Autoconf to choose the best grep +# available, choose the one first in the user's PATH. +m4_defun([_LT_DECL_EGREP], +[AC_REQUIRE([AC_PROG_EGREP])dnl +AC_REQUIRE([AC_PROG_FGREP])dnl +test -z "$GREP" && GREP=grep +_LT_DECL([], [GREP], [1], [A grep program that handles long lines]) +_LT_DECL([], [EGREP], [1], [An ERE matcher]) +_LT_DECL([], [FGREP], [1], [A literal string matcher]) +dnl Non-bleeding-edge autoconf doesn't subst GREP, so do it here too +AC_SUBST([GREP]) +]) + + +# _LT_DECL_OBJDUMP +# -------------- +# If we don't have a new enough Autoconf to choose the best objdump +# available, choose the one first in the user's PATH. +m4_defun([_LT_DECL_OBJDUMP], +[AC_CHECK_TOOL(OBJDUMP, objdump, false) +test -z "$OBJDUMP" && OBJDUMP=objdump +_LT_DECL([], [OBJDUMP], [1], [An object symbol dumper]) +AC_SUBST([OBJDUMP]) +]) + +# _LT_DECL_DLLTOOL +# ---------------- +# Ensure DLLTOOL variable is set. +m4_defun([_LT_DECL_DLLTOOL], +[AC_CHECK_TOOL(DLLTOOL, dlltool, false) +test -z "$DLLTOOL" && DLLTOOL=dlltool +_LT_DECL([], [DLLTOOL], [1], [DLL creation program]) +AC_SUBST([DLLTOOL]) +]) + +# _LT_DECL_SED +# ------------ +# Check for a fully-functional sed program, that truncates +# as few characters as possible. Prefer GNU sed if found. +m4_defun([_LT_DECL_SED], +[AC_PROG_SED +test -z "$SED" && SED=sed +Xsed="$SED -e 1s/^X//" +_LT_DECL([], [SED], [1], [A sed program that does not truncate output]) +_LT_DECL([], [Xsed], ["\$SED -e 1s/^X//"], + [Sed that helps us avoid accidentally triggering echo(1) options like -n]) +])# _LT_DECL_SED + +m4_ifndef([AC_PROG_SED], [ +############################################################ +# NOTE: This macro has been submitted for inclusion into # +# GNU Autoconf as AC_PROG_SED. When it is available in # +# a released version of Autoconf we should remove this # +# macro and use it instead. # +############################################################ + +m4_defun([AC_PROG_SED], +[AC_MSG_CHECKING([for a sed that does not truncate output]) +AC_CACHE_VAL(lt_cv_path_SED, +[# Loop through the user's path and test for sed and gsed. +# Then use that list of sed's as ones to test for truncation. +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for lt_ac_prog in sed gsed; do + for ac_exec_ext in '' $ac_executable_extensions; do + if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then + lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext" + fi + done + done +done +IFS=$as_save_IFS +lt_ac_max=0 +lt_ac_count=0 +# Add /usr/xpg4/bin/sed as it is typically found on Solaris +# along with /bin/sed that truncates output. +for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do + test ! -f "$lt_ac_sed" && continue + cat /dev/null > conftest.in + lt_ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >conftest.in + # Check for GNU sed and select it if it is found. + if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then + lt_cv_path_SED=$lt_ac_sed + break + fi + while true; do + cat conftest.in conftest.in >conftest.tmp + mv conftest.tmp conftest.in + cp conftest.in conftest.nl + echo >>conftest.nl + $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break + cmp -s conftest.out conftest.nl || break + # 10000 chars as input seems more than enough + test 10 -lt "$lt_ac_count" && break + lt_ac_count=`expr $lt_ac_count + 1` + if test "$lt_ac_count" -gt "$lt_ac_max"; then + lt_ac_max=$lt_ac_count + lt_cv_path_SED=$lt_ac_sed + fi + done +done +]) +SED=$lt_cv_path_SED +AC_SUBST([SED]) +AC_MSG_RESULT([$SED]) +])#AC_PROG_SED +])#m4_ifndef + +# Old name: +AU_ALIAS([LT_AC_PROG_SED], [AC_PROG_SED]) +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([LT_AC_PROG_SED], []) + + +# _LT_CHECK_SHELL_FEATURES +# ------------------------ +# Find out whether the shell is Bourne or XSI compatible, +# or has some other useful features. +m4_defun([_LT_CHECK_SHELL_FEATURES], +[if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + lt_unset=unset +else + lt_unset=false +fi +_LT_DECL([], [lt_unset], [0], [whether the shell understands "unset"])dnl + +# test EBCDIC or ASCII +case `echo X|tr X '\101'` in + A) # ASCII based system + # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr + lt_SP2NL='tr \040 \012' + lt_NL2SP='tr \015\012 \040\040' + ;; + *) # EBCDIC based system + lt_SP2NL='tr \100 \n' + lt_NL2SP='tr \r\n \100\100' + ;; +esac +_LT_DECL([SP2NL], [lt_SP2NL], [1], [turn spaces into newlines])dnl +_LT_DECL([NL2SP], [lt_NL2SP], [1], [turn newlines into spaces])dnl +])# _LT_CHECK_SHELL_FEATURES + + +# _LT_PATH_CONVERSION_FUNCTIONS +# ----------------------------- +# Determine what file name conversion functions should be used by +# func_to_host_file (and, implicitly, by func_to_host_path). These are needed +# for certain cross-compile configurations and native mingw. +m4_defun([_LT_PATH_CONVERSION_FUNCTIONS], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +AC_REQUIRE([AC_CANONICAL_BUILD])dnl +AC_MSG_CHECKING([how to convert $build file names to $host format]) +AC_CACHE_VAL(lt_cv_to_host_file_cmd, +[case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32 + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32 + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32 + ;; + esac + ;; + *-*-cygwin* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin + ;; + *-*-cygwin* ) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; + * ) # otherwise, assume *nix + lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin + ;; + esac + ;; + * ) # unhandled hosts (and "normal" native builds) + lt_cv_to_host_file_cmd=func_convert_file_noop + ;; +esac +]) +to_host_file_cmd=$lt_cv_to_host_file_cmd +AC_MSG_RESULT([$lt_cv_to_host_file_cmd]) +_LT_DECL([to_host_file_cmd], [lt_cv_to_host_file_cmd], + [0], [convert $build file names to $host format])dnl + +AC_MSG_CHECKING([how to convert $build file names to toolchain format]) +AC_CACHE_VAL(lt_cv_to_tool_file_cmd, +[#assume ordinary cross tools, or native build. +lt_cv_to_tool_file_cmd=func_convert_file_noop +case $host in + *-*-mingw* ) + case $build in + *-*-mingw* ) # actually msys + lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32 + ;; + esac + ;; +esac +]) +to_tool_file_cmd=$lt_cv_to_tool_file_cmd +AC_MSG_RESULT([$lt_cv_to_tool_file_cmd]) +_LT_DECL([to_tool_file_cmd], [lt_cv_to_tool_file_cmd], + [0], [convert $build files to toolchain format])dnl +])# _LT_PATH_CONVERSION_FUNCTIONS diff --git a/src/secp256k1/build-aux/m4/ltoptions.m4 b/src/secp256k1/build-aux/m4/ltoptions.m4 new file mode 100644 index 000000000..94b082976 --- /dev/null +++ b/src/secp256k1/build-aux/m4/ltoptions.m4 @@ -0,0 +1,437 @@ +# Helper functions for option handling. -*- Autoconf -*- +# +# Copyright (C) 2004-2005, 2007-2009, 2011-2015 Free Software +# Foundation, Inc. +# Written by Gary V. Vaughan, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 8 ltoptions.m4 + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])]) + + +# _LT_MANGLE_OPTION(MACRO-NAME, OPTION-NAME) +# ------------------------------------------ +m4_define([_LT_MANGLE_OPTION], +[[_LT_OPTION_]m4_bpatsubst($1__$2, [[^a-zA-Z0-9_]], [_])]) + + +# _LT_SET_OPTION(MACRO-NAME, OPTION-NAME) +# --------------------------------------- +# Set option OPTION-NAME for macro MACRO-NAME, and if there is a +# matching handler defined, dispatch to it. Other OPTION-NAMEs are +# saved as a flag. +m4_define([_LT_SET_OPTION], +[m4_define(_LT_MANGLE_OPTION([$1], [$2]))dnl +m4_ifdef(_LT_MANGLE_DEFUN([$1], [$2]), + _LT_MANGLE_DEFUN([$1], [$2]), + [m4_warning([Unknown $1 option '$2'])])[]dnl +]) + + +# _LT_IF_OPTION(MACRO-NAME, OPTION-NAME, IF-SET, [IF-NOT-SET]) +# ------------------------------------------------------------ +# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. +m4_define([_LT_IF_OPTION], +[m4_ifdef(_LT_MANGLE_OPTION([$1], [$2]), [$3], [$4])]) + + +# _LT_UNLESS_OPTIONS(MACRO-NAME, OPTION-LIST, IF-NOT-SET) +# ------------------------------------------------------- +# Execute IF-NOT-SET unless all options in OPTION-LIST for MACRO-NAME +# are set. +m4_define([_LT_UNLESS_OPTIONS], +[m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), + [m4_ifdef(_LT_MANGLE_OPTION([$1], _LT_Option), + [m4_define([$0_found])])])[]dnl +m4_ifdef([$0_found], [m4_undefine([$0_found])], [$3 +])[]dnl +]) + + +# _LT_SET_OPTIONS(MACRO-NAME, OPTION-LIST) +# ---------------------------------------- +# OPTION-LIST is a space-separated list of Libtool options associated +# with MACRO-NAME. If any OPTION has a matching handler declared with +# LT_OPTION_DEFINE, dispatch to that macro; otherwise complain about +# the unknown option and exit. +m4_defun([_LT_SET_OPTIONS], +[# Set options +m4_foreach([_LT_Option], m4_split(m4_normalize([$2])), + [_LT_SET_OPTION([$1], _LT_Option)]) + +m4_if([$1],[LT_INIT],[ + dnl + dnl Simply set some default values (i.e off) if boolean options were not + dnl specified: + _LT_UNLESS_OPTIONS([LT_INIT], [dlopen], [enable_dlopen=no + ]) + _LT_UNLESS_OPTIONS([LT_INIT], [win32-dll], [enable_win32_dll=no + ]) + dnl + dnl If no reference was made to various pairs of opposing options, then + dnl we run the default mode handler for the pair. For example, if neither + dnl 'shared' nor 'disable-shared' was passed, we enable building of shared + dnl archives by default: + _LT_UNLESS_OPTIONS([LT_INIT], [shared disable-shared], [_LT_ENABLE_SHARED]) + _LT_UNLESS_OPTIONS([LT_INIT], [static disable-static], [_LT_ENABLE_STATIC]) + _LT_UNLESS_OPTIONS([LT_INIT], [pic-only no-pic], [_LT_WITH_PIC]) + _LT_UNLESS_OPTIONS([LT_INIT], [fast-install disable-fast-install], + [_LT_ENABLE_FAST_INSTALL]) + _LT_UNLESS_OPTIONS([LT_INIT], [aix-soname=aix aix-soname=both aix-soname=svr4], + [_LT_WITH_AIX_SONAME([aix])]) + ]) +])# _LT_SET_OPTIONS + + +## --------------------------------- ## +## Macros to handle LT_INIT options. ## +## --------------------------------- ## + +# _LT_MANGLE_DEFUN(MACRO-NAME, OPTION-NAME) +# ----------------------------------------- +m4_define([_LT_MANGLE_DEFUN], +[[_LT_OPTION_DEFUN_]m4_bpatsubst(m4_toupper([$1__$2]), [[^A-Z0-9_]], [_])]) + + +# LT_OPTION_DEFINE(MACRO-NAME, OPTION-NAME, CODE) +# ----------------------------------------------- +m4_define([LT_OPTION_DEFINE], +[m4_define(_LT_MANGLE_DEFUN([$1], [$2]), [$3])[]dnl +])# LT_OPTION_DEFINE + + +# dlopen +# ------ +LT_OPTION_DEFINE([LT_INIT], [dlopen], [enable_dlopen=yes +]) + +AU_DEFUN([AC_LIBTOOL_DLOPEN], +[_LT_SET_OPTION([LT_INIT], [dlopen]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the 'dlopen' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_DLOPEN], []) + + +# win32-dll +# --------- +# Declare package support for building win32 dll's. +LT_OPTION_DEFINE([LT_INIT], [win32-dll], +[enable_win32_dll=yes + +case $host in +*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*) + AC_CHECK_TOOL(AS, as, false) + AC_CHECK_TOOL(DLLTOOL, dlltool, false) + AC_CHECK_TOOL(OBJDUMP, objdump, false) + ;; +esac + +test -z "$AS" && AS=as +_LT_DECL([], [AS], [1], [Assembler program])dnl + +test -z "$DLLTOOL" && DLLTOOL=dlltool +_LT_DECL([], [DLLTOOL], [1], [DLL creation program])dnl + +test -z "$OBJDUMP" && OBJDUMP=objdump +_LT_DECL([], [OBJDUMP], [1], [Object dumper program])dnl +])# win32-dll + +AU_DEFUN([AC_LIBTOOL_WIN32_DLL], +[AC_REQUIRE([AC_CANONICAL_HOST])dnl +_LT_SET_OPTION([LT_INIT], [win32-dll]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the 'win32-dll' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_WIN32_DLL], []) + + +# _LT_ENABLE_SHARED([DEFAULT]) +# ---------------------------- +# implement the --enable-shared flag, and supports the 'shared' and +# 'disable-shared' LT_INIT options. +# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. +m4_define([_LT_ENABLE_SHARED], +[m4_define([_LT_ENABLE_SHARED_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([shared], + [AS_HELP_STRING([--enable-shared@<:@=PKGS@:>@], + [build shared libraries @<:@default=]_LT_ENABLE_SHARED_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_shared=yes ;; + no) enable_shared=no ;; + *) + enable_shared=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$pkg" = "X$p"; then + enable_shared=yes + fi + done + IFS=$lt_save_ifs + ;; + esac], + [enable_shared=]_LT_ENABLE_SHARED_DEFAULT) + + _LT_DECL([build_libtool_libs], [enable_shared], [0], + [Whether or not to build shared libraries]) +])# _LT_ENABLE_SHARED + +LT_OPTION_DEFINE([LT_INIT], [shared], [_LT_ENABLE_SHARED([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-shared], [_LT_ENABLE_SHARED([no])]) + +# Old names: +AC_DEFUN([AC_ENABLE_SHARED], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[shared]) +]) + +AC_DEFUN([AC_DISABLE_SHARED], +[_LT_SET_OPTION([LT_INIT], [disable-shared]) +]) + +AU_DEFUN([AM_ENABLE_SHARED], [AC_ENABLE_SHARED($@)]) +AU_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_ENABLE_SHARED], []) +dnl AC_DEFUN([AM_DISABLE_SHARED], []) + + + +# _LT_ENABLE_STATIC([DEFAULT]) +# ---------------------------- +# implement the --enable-static flag, and support the 'static' and +# 'disable-static' LT_INIT options. +# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. +m4_define([_LT_ENABLE_STATIC], +[m4_define([_LT_ENABLE_STATIC_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([static], + [AS_HELP_STRING([--enable-static@<:@=PKGS@:>@], + [build static libraries @<:@default=]_LT_ENABLE_STATIC_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_static=yes ;; + no) enable_static=no ;; + *) + enable_static=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$pkg" = "X$p"; then + enable_static=yes + fi + done + IFS=$lt_save_ifs + ;; + esac], + [enable_static=]_LT_ENABLE_STATIC_DEFAULT) + + _LT_DECL([build_old_libs], [enable_static], [0], + [Whether or not to build static libraries]) +])# _LT_ENABLE_STATIC + +LT_OPTION_DEFINE([LT_INIT], [static], [_LT_ENABLE_STATIC([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-static], [_LT_ENABLE_STATIC([no])]) + +# Old names: +AC_DEFUN([AC_ENABLE_STATIC], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[static]) +]) + +AC_DEFUN([AC_DISABLE_STATIC], +[_LT_SET_OPTION([LT_INIT], [disable-static]) +]) + +AU_DEFUN([AM_ENABLE_STATIC], [AC_ENABLE_STATIC($@)]) +AU_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AM_ENABLE_STATIC], []) +dnl AC_DEFUN([AM_DISABLE_STATIC], []) + + + +# _LT_ENABLE_FAST_INSTALL([DEFAULT]) +# ---------------------------------- +# implement the --enable-fast-install flag, and support the 'fast-install' +# and 'disable-fast-install' LT_INIT options. +# DEFAULT is either 'yes' or 'no'. If omitted, it defaults to 'yes'. +m4_define([_LT_ENABLE_FAST_INSTALL], +[m4_define([_LT_ENABLE_FAST_INSTALL_DEFAULT], [m4_if($1, no, no, yes)])dnl +AC_ARG_ENABLE([fast-install], + [AS_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@], + [optimize for fast installation @<:@default=]_LT_ENABLE_FAST_INSTALL_DEFAULT[@:>@])], + [p=${PACKAGE-default} + case $enableval in + yes) enable_fast_install=yes ;; + no) enable_fast_install=no ;; + *) + enable_fast_install=no + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for pkg in $enableval; do + IFS=$lt_save_ifs + if test "X$pkg" = "X$p"; then + enable_fast_install=yes + fi + done + IFS=$lt_save_ifs + ;; + esac], + [enable_fast_install=]_LT_ENABLE_FAST_INSTALL_DEFAULT) + +_LT_DECL([fast_install], [enable_fast_install], [0], + [Whether or not to optimize for fast installation])dnl +])# _LT_ENABLE_FAST_INSTALL + +LT_OPTION_DEFINE([LT_INIT], [fast-install], [_LT_ENABLE_FAST_INSTALL([yes])]) +LT_OPTION_DEFINE([LT_INIT], [disable-fast-install], [_LT_ENABLE_FAST_INSTALL([no])]) + +# Old names: +AU_DEFUN([AC_ENABLE_FAST_INSTALL], +[_LT_SET_OPTION([LT_INIT], m4_if([$1], [no], [disable-])[fast-install]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you put +the 'fast-install' option into LT_INIT's first parameter.]) +]) + +AU_DEFUN([AC_DISABLE_FAST_INSTALL], +[_LT_SET_OPTION([LT_INIT], [disable-fast-install]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you put +the 'disable-fast-install' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_ENABLE_FAST_INSTALL], []) +dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], []) + + +# _LT_WITH_AIX_SONAME([DEFAULT]) +# ---------------------------------- +# implement the --with-aix-soname flag, and support the `aix-soname=aix' +# and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT +# is either `aix', `both' or `svr4'. If omitted, it defaults to `aix'. +m4_define([_LT_WITH_AIX_SONAME], +[m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl +shared_archive_member_spec= +case $host,$enable_shared in +power*-*-aix[[5-9]]*,yes) + AC_MSG_CHECKING([which variant of shared library versioning to provide]) + AC_ARG_WITH([aix-soname], + [AS_HELP_STRING([--with-aix-soname=aix|svr4|both], + [shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])], + [case $withval in + aix|svr4|both) + ;; + *) + AC_MSG_ERROR([Unknown argument to --with-aix-soname]) + ;; + esac + lt_cv_with_aix_soname=$with_aix_soname], + [AC_CACHE_VAL([lt_cv_with_aix_soname], + [lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT) + with_aix_soname=$lt_cv_with_aix_soname]) + AC_MSG_RESULT([$with_aix_soname]) + if test aix != "$with_aix_soname"; then + # For the AIX way of multilib, we name the shared archive member + # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o', + # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File. + # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag, + # the AIX toolchain works better with OBJECT_MODE set (default 32). + if test 64 = "${OBJECT_MODE-32}"; then + shared_archive_member_spec=shr_64 + else + shared_archive_member_spec=shr + fi + fi + ;; +*) + with_aix_soname=aix + ;; +esac + +_LT_DECL([], [shared_archive_member_spec], [0], + [Shared archive member basename, for filename based shared library versioning on AIX])dnl +])# _LT_WITH_AIX_SONAME + +LT_OPTION_DEFINE([LT_INIT], [aix-soname=aix], [_LT_WITH_AIX_SONAME([aix])]) +LT_OPTION_DEFINE([LT_INIT], [aix-soname=both], [_LT_WITH_AIX_SONAME([both])]) +LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])]) + + +# _LT_WITH_PIC([MODE]) +# -------------------- +# implement the --with-pic flag, and support the 'pic-only' and 'no-pic' +# LT_INIT options. +# MODE is either 'yes' or 'no'. If omitted, it defaults to 'both'. +m4_define([_LT_WITH_PIC], +[AC_ARG_WITH([pic], + [AS_HELP_STRING([--with-pic@<:@=PKGS@:>@], + [try to use only PIC/non-PIC objects @<:@default=use both@:>@])], + [lt_p=${PACKAGE-default} + case $withval in + yes|no) pic_mode=$withval ;; + *) + pic_mode=default + # Look at the argument we got. We use all the common list separators. + lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR, + for lt_pkg in $withval; do + IFS=$lt_save_ifs + if test "X$lt_pkg" = "X$lt_p"; then + pic_mode=yes + fi + done + IFS=$lt_save_ifs + ;; + esac], + [pic_mode=m4_default([$1], [default])]) + +_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl +])# _LT_WITH_PIC + +LT_OPTION_DEFINE([LT_INIT], [pic-only], [_LT_WITH_PIC([yes])]) +LT_OPTION_DEFINE([LT_INIT], [no-pic], [_LT_WITH_PIC([no])]) + +# Old name: +AU_DEFUN([AC_LIBTOOL_PICMODE], +[_LT_SET_OPTION([LT_INIT], [pic-only]) +AC_DIAGNOSE([obsolete], +[$0: Remove this warning and the call to _LT_SET_OPTION when you +put the 'pic-only' option into LT_INIT's first parameter.]) +]) + +dnl aclocal-1.4 backwards compatibility: +dnl AC_DEFUN([AC_LIBTOOL_PICMODE], []) + +## ----------------- ## +## LTDL_INIT Options ## +## ----------------- ## + +m4_define([_LTDL_MODE], []) +LT_OPTION_DEFINE([LTDL_INIT], [nonrecursive], + [m4_define([_LTDL_MODE], [nonrecursive])]) +LT_OPTION_DEFINE([LTDL_INIT], [recursive], + [m4_define([_LTDL_MODE], [recursive])]) +LT_OPTION_DEFINE([LTDL_INIT], [subproject], + [m4_define([_LTDL_MODE], [subproject])]) + +m4_define([_LTDL_TYPE], []) +LT_OPTION_DEFINE([LTDL_INIT], [installable], + [m4_define([_LTDL_TYPE], [installable])]) +LT_OPTION_DEFINE([LTDL_INIT], [convenience], + [m4_define([_LTDL_TYPE], [convenience])]) diff --git a/src/secp256k1/build-aux/m4/ltsugar.m4 b/src/secp256k1/build-aux/m4/ltsugar.m4 new file mode 100644 index 000000000..48bc9344a --- /dev/null +++ b/src/secp256k1/build-aux/m4/ltsugar.m4 @@ -0,0 +1,124 @@ +# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*- +# +# Copyright (C) 2004-2005, 2007-2008, 2011-2015 Free Software +# Foundation, Inc. +# Written by Gary V. Vaughan, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 6 ltsugar.m4 + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTSUGAR_VERSION], [m4_if([0.1])]) + + +# lt_join(SEP, ARG1, [ARG2...]) +# ----------------------------- +# Produce ARG1SEPARG2...SEPARGn, omitting [] arguments and their +# associated separator. +# Needed until we can rely on m4_join from Autoconf 2.62, since all earlier +# versions in m4sugar had bugs. +m4_define([lt_join], +[m4_if([$#], [1], [], + [$#], [2], [[$2]], + [m4_if([$2], [], [], [[$2]_])$0([$1], m4_shift(m4_shift($@)))])]) +m4_define([_lt_join], +[m4_if([$#$2], [2], [], + [m4_if([$2], [], [], [[$1$2]])$0([$1], m4_shift(m4_shift($@)))])]) + + +# lt_car(LIST) +# lt_cdr(LIST) +# ------------ +# Manipulate m4 lists. +# These macros are necessary as long as will still need to support +# Autoconf-2.59, which quotes differently. +m4_define([lt_car], [[$1]]) +m4_define([lt_cdr], +[m4_if([$#], 0, [m4_fatal([$0: cannot be called without arguments])], + [$#], 1, [], + [m4_dquote(m4_shift($@))])]) +m4_define([lt_unquote], $1) + + +# lt_append(MACRO-NAME, STRING, [SEPARATOR]) +# ------------------------------------------ +# Redefine MACRO-NAME to hold its former content plus 'SEPARATOR''STRING'. +# Note that neither SEPARATOR nor STRING are expanded; they are appended +# to MACRO-NAME as is (leaving the expansion for when MACRO-NAME is invoked). +# No SEPARATOR is output if MACRO-NAME was previously undefined (different +# than defined and empty). +# +# This macro is needed until we can rely on Autoconf 2.62, since earlier +# versions of m4sugar mistakenly expanded SEPARATOR but not STRING. +m4_define([lt_append], +[m4_define([$1], + m4_ifdef([$1], [m4_defn([$1])[$3]])[$2])]) + + + +# lt_combine(SEP, PREFIX-LIST, INFIX, SUFFIX1, [SUFFIX2...]) +# ---------------------------------------------------------- +# Produce a SEP delimited list of all paired combinations of elements of +# PREFIX-LIST with SUFFIX1 through SUFFIXn. Each element of the list +# has the form PREFIXmINFIXSUFFIXn. +# Needed until we can rely on m4_combine added in Autoconf 2.62. +m4_define([lt_combine], +[m4_if(m4_eval([$# > 3]), [1], + [m4_pushdef([_Lt_sep], [m4_define([_Lt_sep], m4_defn([lt_car]))])]]dnl +[[m4_foreach([_Lt_prefix], [$2], + [m4_foreach([_Lt_suffix], + ]m4_dquote(m4_dquote(m4_shift(m4_shift(m4_shift($@)))))[, + [_Lt_sep([$1])[]m4_defn([_Lt_prefix])[$3]m4_defn([_Lt_suffix])])])])]) + + +# lt_if_append_uniq(MACRO-NAME, VARNAME, [SEPARATOR], [UNIQ], [NOT-UNIQ]) +# ----------------------------------------------------------------------- +# Iff MACRO-NAME does not yet contain VARNAME, then append it (delimited +# by SEPARATOR if supplied) and expand UNIQ, else NOT-UNIQ. +m4_define([lt_if_append_uniq], +[m4_ifdef([$1], + [m4_if(m4_index([$3]m4_defn([$1])[$3], [$3$2$3]), [-1], + [lt_append([$1], [$2], [$3])$4], + [$5])], + [lt_append([$1], [$2], [$3])$4])]) + + +# lt_dict_add(DICT, KEY, VALUE) +# ----------------------------- +m4_define([lt_dict_add], +[m4_define([$1($2)], [$3])]) + + +# lt_dict_add_subkey(DICT, KEY, SUBKEY, VALUE) +# -------------------------------------------- +m4_define([lt_dict_add_subkey], +[m4_define([$1($2:$3)], [$4])]) + + +# lt_dict_fetch(DICT, KEY, [SUBKEY]) +# ---------------------------------- +m4_define([lt_dict_fetch], +[m4_ifval([$3], + m4_ifdef([$1($2:$3)], [m4_defn([$1($2:$3)])]), + m4_ifdef([$1($2)], [m4_defn([$1($2)])]))]) + + +# lt_if_dict_fetch(DICT, KEY, [SUBKEY], VALUE, IF-TRUE, [IF-FALSE]) +# ----------------------------------------------------------------- +m4_define([lt_if_dict_fetch], +[m4_if(lt_dict_fetch([$1], [$2], [$3]), [$4], + [$5], + [$6])]) + + +# lt_dict_filter(DICT, [SUBKEY], VALUE, [SEPARATOR], KEY, [...]) +# -------------------------------------------------------------- +m4_define([lt_dict_filter], +[m4_if([$5], [], [], + [lt_join(m4_quote(m4_default([$4], [[, ]])), + lt_unquote(m4_split(m4_normalize(m4_foreach(_Lt_key, lt_car([m4_shiftn(4, $@)]), + [lt_if_dict_fetch([$1], _Lt_key, [$2], [$3], [_Lt_key ])])))))])[]dnl +]) diff --git a/src/secp256k1/build-aux/m4/ltversion.m4 b/src/secp256k1/build-aux/m4/ltversion.m4 new file mode 100644 index 000000000..fa04b52a3 --- /dev/null +++ b/src/secp256k1/build-aux/m4/ltversion.m4 @@ -0,0 +1,23 @@ +# ltversion.m4 -- version numbers -*- Autoconf -*- +# +# Copyright (C) 2004, 2011-2015 Free Software Foundation, Inc. +# Written by Scott James Remnant, 2004 +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# @configure_input@ + +# serial 4179 ltversion.m4 +# This file is part of GNU Libtool + +m4_define([LT_PACKAGE_VERSION], [2.4.6]) +m4_define([LT_PACKAGE_REVISION], [2.4.6]) + +AC_DEFUN([LTVERSION_VERSION], +[macro_version='2.4.6' +macro_revision='2.4.6' +_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?]) +_LT_DECL(, macro_revision, 0) +]) diff --git a/src/secp256k1/build-aux/m4/lt~obsolete.m4 b/src/secp256k1/build-aux/m4/lt~obsolete.m4 new file mode 100644 index 000000000..c6b26f88f --- /dev/null +++ b/src/secp256k1/build-aux/m4/lt~obsolete.m4 @@ -0,0 +1,99 @@ +# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*- +# +# Copyright (C) 2004-2005, 2007, 2009, 2011-2015 Free Software +# Foundation, Inc. +# Written by Scott James Remnant, 2004. +# +# This file is free software; the Free Software Foundation gives +# unlimited permission to copy and/or distribute it, with or without +# modifications, as long as this notice is preserved. + +# serial 5 lt~obsolete.m4 + +# These exist entirely to fool aclocal when bootstrapping libtool. +# +# In the past libtool.m4 has provided macros via AC_DEFUN (or AU_DEFUN), +# which have later been changed to m4_define as they aren't part of the +# exported API, or moved to Autoconf or Automake where they belong. +# +# The trouble is, aclocal is a bit thick. It'll see the old AC_DEFUN +# in /usr/share/aclocal/libtool.m4 and remember it, then when it sees us +# using a macro with the same name in our local m4/libtool.m4 it'll +# pull the old libtool.m4 in (it doesn't see our shiny new m4_define +# and doesn't know about Autoconf macros at all.) +# +# So we provide this file, which has a silly filename so it's always +# included after everything else. This provides aclocal with the +# AC_DEFUNs it wants, but when m4 processes it, it doesn't do anything +# because those macros already exist, or will be overwritten later. +# We use AC_DEFUN over AU_DEFUN for compatibility with aclocal-1.6. +# +# Anytime we withdraw an AC_DEFUN or AU_DEFUN, remember to add it here. +# Yes, that means every name once taken will need to remain here until +# we give up compatibility with versions before 1.7, at which point +# we need to keep only those names which we still refer to. + +# This is to help aclocal find these macros, as it can't see m4_define. +AC_DEFUN([LTOBSOLETE_VERSION], [m4_if([1])]) + +m4_ifndef([AC_LIBTOOL_LINKER_OPTION], [AC_DEFUN([AC_LIBTOOL_LINKER_OPTION])]) +m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP])]) +m4_ifndef([_LT_AC_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH])]) +m4_ifndef([_LT_AC_SHELL_INIT], [AC_DEFUN([_LT_AC_SHELL_INIT])]) +m4_ifndef([_LT_AC_SYS_LIBPATH_AIX], [AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX])]) +m4_ifndef([_LT_PROG_LTMAIN], [AC_DEFUN([_LT_PROG_LTMAIN])]) +m4_ifndef([_LT_AC_TAGVAR], [AC_DEFUN([_LT_AC_TAGVAR])]) +m4_ifndef([AC_LTDL_ENABLE_INSTALL], [AC_DEFUN([AC_LTDL_ENABLE_INSTALL])]) +m4_ifndef([AC_LTDL_PREOPEN], [AC_DEFUN([AC_LTDL_PREOPEN])]) +m4_ifndef([_LT_AC_SYS_COMPILER], [AC_DEFUN([_LT_AC_SYS_COMPILER])]) +m4_ifndef([_LT_AC_LOCK], [AC_DEFUN([_LT_AC_LOCK])]) +m4_ifndef([AC_LIBTOOL_SYS_OLD_ARCHIVE], [AC_DEFUN([AC_LIBTOOL_SYS_OLD_ARCHIVE])]) +m4_ifndef([_LT_AC_TRY_DLOPEN_SELF], [AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF])]) +m4_ifndef([AC_LIBTOOL_PROG_CC_C_O], [AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O])]) +m4_ifndef([AC_LIBTOOL_SYS_HARD_LINK_LOCKS], [AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS])]) +m4_ifndef([AC_LIBTOOL_OBJDIR], [AC_DEFUN([AC_LIBTOOL_OBJDIR])]) +m4_ifndef([AC_LTDL_OBJDIR], [AC_DEFUN([AC_LTDL_OBJDIR])]) +m4_ifndef([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH], [AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH])]) +m4_ifndef([AC_LIBTOOL_SYS_LIB_STRIP], [AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP])]) +m4_ifndef([AC_PATH_MAGIC], [AC_DEFUN([AC_PATH_MAGIC])]) +m4_ifndef([AC_PROG_LD_GNU], [AC_DEFUN([AC_PROG_LD_GNU])]) +m4_ifndef([AC_PROG_LD_RELOAD_FLAG], [AC_DEFUN([AC_PROG_LD_RELOAD_FLAG])]) +m4_ifndef([AC_DEPLIBS_CHECK_METHOD], [AC_DEFUN([AC_DEPLIBS_CHECK_METHOD])]) +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_NO_RTTI], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI])]) +m4_ifndef([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE], [AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE])]) +m4_ifndef([AC_LIBTOOL_PROG_COMPILER_PIC], [AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC])]) +m4_ifndef([AC_LIBTOOL_PROG_LD_SHLIBS], [AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS])]) +m4_ifndef([AC_LIBTOOL_POSTDEP_PREDEP], [AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP])]) +m4_ifndef([LT_AC_PROG_EGREP], [AC_DEFUN([LT_AC_PROG_EGREP])]) +m4_ifndef([LT_AC_PROG_SED], [AC_DEFUN([LT_AC_PROG_SED])]) +m4_ifndef([_LT_CC_BASENAME], [AC_DEFUN([_LT_CC_BASENAME])]) +m4_ifndef([_LT_COMPILER_BOILERPLATE], [AC_DEFUN([_LT_COMPILER_BOILERPLATE])]) +m4_ifndef([_LT_LINKER_BOILERPLATE], [AC_DEFUN([_LT_LINKER_BOILERPLATE])]) +m4_ifndef([_AC_PROG_LIBTOOL], [AC_DEFUN([_AC_PROG_LIBTOOL])]) +m4_ifndef([AC_LIBTOOL_SETUP], [AC_DEFUN([AC_LIBTOOL_SETUP])]) +m4_ifndef([_LT_AC_CHECK_DLFCN], [AC_DEFUN([_LT_AC_CHECK_DLFCN])]) +m4_ifndef([AC_LIBTOOL_SYS_DYNAMIC_LINKER], [AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER])]) +m4_ifndef([_LT_AC_TAGCONFIG], [AC_DEFUN([_LT_AC_TAGCONFIG])]) +m4_ifndef([AC_DISABLE_FAST_INSTALL], [AC_DEFUN([AC_DISABLE_FAST_INSTALL])]) +m4_ifndef([_LT_AC_LANG_CXX], [AC_DEFUN([_LT_AC_LANG_CXX])]) +m4_ifndef([_LT_AC_LANG_F77], [AC_DEFUN([_LT_AC_LANG_F77])]) +m4_ifndef([_LT_AC_LANG_GCJ], [AC_DEFUN([_LT_AC_LANG_GCJ])]) +m4_ifndef([AC_LIBTOOL_LANG_C_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG])]) +m4_ifndef([_LT_AC_LANG_C_CONFIG], [AC_DEFUN([_LT_AC_LANG_C_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_CXX_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG])]) +m4_ifndef([_LT_AC_LANG_CXX_CONFIG], [AC_DEFUN([_LT_AC_LANG_CXX_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_F77_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG])]) +m4_ifndef([_LT_AC_LANG_F77_CONFIG], [AC_DEFUN([_LT_AC_LANG_F77_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_GCJ_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG])]) +m4_ifndef([_LT_AC_LANG_GCJ_CONFIG], [AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG])]) +m4_ifndef([AC_LIBTOOL_LANG_RC_CONFIG], [AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG])]) +m4_ifndef([_LT_AC_LANG_RC_CONFIG], [AC_DEFUN([_LT_AC_LANG_RC_CONFIG])]) +m4_ifndef([AC_LIBTOOL_CONFIG], [AC_DEFUN([AC_LIBTOOL_CONFIG])]) +m4_ifndef([_LT_AC_FILE_LTDLL_C], [AC_DEFUN([_LT_AC_FILE_LTDLL_C])]) +m4_ifndef([_LT_REQUIRED_DARWIN_CHECKS], [AC_DEFUN([_LT_REQUIRED_DARWIN_CHECKS])]) +m4_ifndef([_LT_AC_PROG_CXXCPP], [AC_DEFUN([_LT_AC_PROG_CXXCPP])]) +m4_ifndef([_LT_PREPARE_SED_QUOTE_VARS], [AC_DEFUN([_LT_PREPARE_SED_QUOTE_VARS])]) +m4_ifndef([_LT_PROG_ECHO_BACKSLASH], [AC_DEFUN([_LT_PROG_ECHO_BACKSLASH])]) +m4_ifndef([_LT_PROG_F77], [AC_DEFUN([_LT_PROG_F77])]) +m4_ifndef([_LT_PROG_FC], [AC_DEFUN([_LT_PROG_FC])]) +m4_ifndef([_LT_PROG_CXX], [AC_DEFUN([_LT_PROG_CXX])]) diff --git a/src/secp256k1/build-aux/missing b/src/secp256k1/build-aux/missing new file mode 100755 index 000000000..f62bbae30 --- /dev/null +++ b/src/secp256k1/build-aux/missing @@ -0,0 +1,215 @@ +#! /bin/sh +# Common wrapper for a few potentially missing GNU programs. + +scriptversion=2013-10-28.13; # UTC + +# Copyright (C) 1996-2014 Free Software Foundation, Inc. +# Originally written by Fran,cois Pinard , 1996. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +if test $# -eq 0; then + echo 1>&2 "Try '$0 --help' for more information" + exit 1 +fi + +case $1 in + + --is-lightweight) + # Used by our autoconf macros to check whether the available missing + # script is modern enough. + exit 0 + ;; + + --run) + # Back-compat with the calling convention used by older automake. + shift + ;; + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due +to PROGRAM being missing or too old. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + +Supported PROGRAM values: + aclocal autoconf autoheader autom4te automake makeinfo + bison yacc flex lex help2man + +Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and +'g' are ignored when checking the name. + +Send bug reports to ." + exit $? + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing $scriptversion (GNU Automake)" + exit $? + ;; + + -*) + echo 1>&2 "$0: unknown '$1' option" + echo 1>&2 "Try '$0 --help' for more information" + exit 1 + ;; + +esac + +# Run the given program, remember its exit status. +"$@"; st=$? + +# If it succeeded, we are done. +test $st -eq 0 && exit 0 + +# Also exit now if we it failed (or wasn't found), and '--version' was +# passed; such an option is passed most likely to detect whether the +# program is present and works. +case $2 in --version|--help) exit $st;; esac + +# Exit code 63 means version mismatch. This often happens when the user +# tries to use an ancient version of a tool on a file that requires a +# minimum version. +if test $st -eq 63; then + msg="probably too old" +elif test $st -eq 127; then + # Program was missing. + msg="missing on your system" +else + # Program was found and executed, but failed. Give up. + exit $st +fi + +perl_URL=http://www.perl.org/ +flex_URL=http://flex.sourceforge.net/ +gnu_software_URL=http://www.gnu.org/software + +program_details () +{ + case $1 in + aclocal|automake) + echo "The '$1' program is part of the GNU Automake package:" + echo "<$gnu_software_URL/automake>" + echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" + echo "<$gnu_software_URL/autoconf>" + echo "<$gnu_software_URL/m4/>" + echo "<$perl_URL>" + ;; + autoconf|autom4te|autoheader) + echo "The '$1' program is part of the GNU Autoconf package:" + echo "<$gnu_software_URL/autoconf/>" + echo "It also requires GNU m4 and Perl in order to run:" + echo "<$gnu_software_URL/m4/>" + echo "<$perl_URL>" + ;; + esac +} + +give_advice () +{ + # Normalize program name to check for. + normalized_program=`echo "$1" | sed ' + s/^gnu-//; t + s/^gnu//; t + s/^g//; t'` + + printf '%s\n' "'$1' is $msg." + + configure_deps="'configure.ac' or m4 files included by 'configure.ac'" + case $normalized_program in + autoconf*) + echo "You should only need it if you modified 'configure.ac'," + echo "or m4 files included by it." + program_details 'autoconf' + ;; + autoheader*) + echo "You should only need it if you modified 'acconfig.h' or" + echo "$configure_deps." + program_details 'autoheader' + ;; + automake*) + echo "You should only need it if you modified 'Makefile.am' or" + echo "$configure_deps." + program_details 'automake' + ;; + aclocal*) + echo "You should only need it if you modified 'acinclude.m4' or" + echo "$configure_deps." + program_details 'aclocal' + ;; + autom4te*) + echo "You might have modified some maintainer files that require" + echo "the 'autom4te' program to be rebuilt." + program_details 'autom4te' + ;; + bison*|yacc*) + echo "You should only need it if you modified a '.y' file." + echo "You may want to install the GNU Bison package:" + echo "<$gnu_software_URL/bison/>" + ;; + lex*|flex*) + echo "You should only need it if you modified a '.l' file." + echo "You may want to install the Fast Lexical Analyzer package:" + echo "<$flex_URL>" + ;; + help2man*) + echo "You should only need it if you modified a dependency" \ + "of a man page." + echo "You may want to install the GNU Help2man package:" + echo "<$gnu_software_URL/help2man/>" + ;; + makeinfo*) + echo "You should only need it if you modified a '.texi' file, or" + echo "any other file indirectly affecting the aspect of the manual." + echo "You might want to install the Texinfo package:" + echo "<$gnu_software_URL/texinfo/>" + echo "The spurious makeinfo call might also be the consequence of" + echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" + echo "want to install GNU make:" + echo "<$gnu_software_URL/make/>" + ;; + *) + echo "You might have modified some files without having the proper" + echo "tools for further handling them. Check the 'README' file, it" + echo "often tells you about the needed prerequisites for installing" + echo "this package. You may also peek at any GNU archive site, in" + echo "case some other package contains this missing '$1' program." + ;; + esac +} + +give_advice "$1" | sed -e '1s/^/WARNING: /' \ + -e '2,$s/^/ /' >&2 + +# Propagate the correct exit status (expected to be 127 for a program +# not found, 63 for a program that failed due to version mismatch). +exit $st + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/src/secp256k1/build-aux/test-driver b/src/secp256k1/build-aux/test-driver new file mode 100755 index 000000000..8e575b017 --- /dev/null +++ b/src/secp256k1/build-aux/test-driver @@ -0,0 +1,148 @@ +#! /bin/sh +# test-driver - basic testsuite driver script. + +scriptversion=2013-07-13.22; # UTC + +# Copyright (C) 2011-2014 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# This file is maintained in Automake, please report +# bugs to or send patches to +# . + +# Make unconditional expansion of undefined variables an error. This +# helps a lot in preventing typo-related bugs. +set -u + +usage_error () +{ + echo "$0: $*" >&2 + print_usage >&2 + exit 2 +} + +print_usage () +{ + cat <$log_file 2>&1 +estatus=$? + +if test $enable_hard_errors = no && test $estatus -eq 99; then + tweaked_estatus=1 +else + tweaked_estatus=$estatus +fi + +case $tweaked_estatus:$expect_failure in + 0:yes) col=$red res=XPASS recheck=yes gcopy=yes;; + 0:*) col=$grn res=PASS recheck=no gcopy=no;; + 77:*) col=$blu res=SKIP recheck=no gcopy=yes;; + 99:*) col=$mgn res=ERROR recheck=yes gcopy=yes;; + *:yes) col=$lgn res=XFAIL recheck=no gcopy=yes;; + *:*) col=$red res=FAIL recheck=yes gcopy=yes;; +esac + +# Report the test outcome and exit status in the logs, so that one can +# know whether the test passed or failed simply by looking at the '.log' +# file, without the need of also peaking into the corresponding '.trs' +# file (automake bug#11814). +echo "$res $test_name (exit status: $estatus)" >>$log_file + +# Report outcome to console. +echo "${col}${res}${std}: $test_name" + +# Register the test result, and other relevant metadata. +echo ":test-result: $res" > $trs_file +echo ":global-test-result: $res" >> $trs_file +echo ":recheck: $recheck" >> $trs_file +echo ":copy-in-global-log: $gcopy" >> $trs_file + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-time-zone: "UTC" +# time-stamp-end: "; # UTC" +# End: diff --git a/src/secp256k1/libsecp256k1.pc b/src/secp256k1/libsecp256k1.pc new file mode 100644 index 000000000..1f7003816 --- /dev/null +++ b/src/secp256k1/libsecp256k1.pc @@ -0,0 +1,13 @@ +prefix=/usr/local +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + +Name: libsecp256k1 +Description: Optimized C library for EC operations on curve secp256k1 +URL: https://github.com/bitcoin/secp256k1 +Version: 0.1 +Cflags: -I${includedir} +Libs.private: +Libs: -L${libdir} -lsecp256k1 + diff --git a/src/secp256k1/src/libsecp256k1-config.h b/src/secp256k1/src/libsecp256k1-config.h new file mode 100644 index 000000000..9abff1f73 --- /dev/null +++ b/src/secp256k1/src/libsecp256k1-config.h @@ -0,0 +1,124 @@ +/* src/libsecp256k1-config.h. Generated from libsecp256k1-config.h.in by configure. */ +/* src/libsecp256k1-config.h.in. Generated from configure.ac by autoheader. */ + +#ifndef LIBSECP256K1_CONFIG_H + +#define LIBSECP256K1_CONFIG_H + +/* Define this symbol if OpenSSL EC functions are available */ +/* #undef ENABLE_OPENSSL_TESTS */ + +/* Define this symbol if __builtin_expect is available */ +#define HAVE_BUILTIN_EXPECT 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_DLFCN_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_INTTYPES_H 1 + +/* Define this symbol if libgmp is installed */ +/* #undef HAVE_LIBGMP */ + +/* Define to 1 if you have the header file. */ +#define HAVE_MEMORY_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDINT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STDLIB_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRINGS_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_STRING_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_STAT_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_SYS_TYPES_H 1 + +/* Define to 1 if you have the header file. */ +#define HAVE_UNISTD_H 1 + +/* Define to 1 if the system has the type `__int128'. */ +#define HAVE___INT128 1 + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#define LT_OBJDIR ".libs/" + +/* Name of package */ +#define PACKAGE "libsecp256k1" + +/* Define to the address where bug reports for this package should be sent. */ +#define PACKAGE_BUGREPORT "" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "libsecp256k1" + +/* Define to the full name and version of this package. */ +#define PACKAGE_STRING "libsecp256k1 0.1" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "libsecp256k1" + +/* Define to the home page for this package. */ +#define PACKAGE_URL "" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "0.1" + +/* Define to 1 if you have the ANSI C header files. */ +#define STDC_HEADERS 1 + +/* Define this symbol to use endomorphism optimization */ +/* #undef USE_ENDOMORPHISM */ + +/* Define this symbol to use the FIELD_10X26 implementation */ +#define USE_FIELD_10X26 1 + +/* Define this symbol to use the FIELD_5X52 implementation */ +/* #undef USE_FIELD_5X52 */ + +/* Define this symbol to use the assembly version for the 5x52 field + implementation */ +/* #undef USE_FIELD_5X52_ASM */ + +/* Define this symbol to use the __int128 version for the 5x52 field + implementation */ +/* #undef USE_FIELD_5X52_INT128 */ + +/* Define this symbol to use the FIELD_GMP implementation */ +/* #undef USE_FIELD_GMP */ + +/* Define this symbol to use the native field inverse implementation */ +#define USE_FIELD_INV_BUILTIN 1 + +/* Define this symbol to use the num-based field inverse implementation */ +/* #undef USE_FIELD_INV_NUM */ + +/* Define this symbol to use the gmp implementation for num */ +/* #undef USE_NUM_GMP */ + +/* Define this symbol to use no num implementation */ +#define USE_NUM_NONE 1 + +/* Define this symbol to use the 4x64 scalar implementation */ +/* #undef USE_SCALAR_4X64 */ + +/* Define this symbol to use the 8x32 scalar implementation */ +#define USE_SCALAR_8X32 1 + +/* Define this symbol to use the native scalar inverse implementation */ +#define USE_SCALAR_INV_BUILTIN 1 + +/* Define this symbol to use the num-based scalar inverse implementation */ +/* #undef USE_SCALAR_INV_NUM */ + +/* Version number of package */ +#define VERSION "0.1" + +#endif //LIBSECP256K1_CONFIG_H diff --git a/src/secp256k1/src/libsecp256k1-config.h.in b/src/secp256k1/src/libsecp256k1-config.h.in new file mode 100644 index 000000000..4927f000b --- /dev/null +++ b/src/secp256k1/src/libsecp256k1-config.h.in @@ -0,0 +1,123 @@ +/* src/libsecp256k1-config.h.in. Generated from configure.ac by autoheader. */ + +#ifndef LIBSECP256K1_CONFIG_H + +#define LIBSECP256K1_CONFIG_H + +/* Define this symbol if OpenSSL EC functions are available */ +#undef ENABLE_OPENSSL_TESTS + +/* Define this symbol if __builtin_expect is available */ +#undef HAVE_BUILTIN_EXPECT + +/* Define to 1 if you have the header file. */ +#undef HAVE_DLFCN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define this symbol if libgmp is installed */ +#undef HAVE_LIBGMP + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to 1 if the system has the type `__int128'. */ +#undef HAVE___INT128 + +/* Define to the sub-directory where libtool stores uninstalled libraries. */ +#undef LT_OBJDIR + +/* Name of package */ +#undef PACKAGE + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define this symbol to use endomorphism optimization */ +#undef USE_ENDOMORPHISM + +/* Define this symbol to use the FIELD_10X26 implementation */ +#undef USE_FIELD_10X26 + +/* Define this symbol to use the FIELD_5X52 implementation */ +#undef USE_FIELD_5X52 + +/* Define this symbol to use the assembly version for the 5x52 field + implementation */ +#undef USE_FIELD_5X52_ASM + +/* Define this symbol to use the __int128 version for the 5x52 field + implementation */ +#undef USE_FIELD_5X52_INT128 + +/* Define this symbol to use the FIELD_GMP implementation */ +#undef USE_FIELD_GMP + +/* Define this symbol to use the native field inverse implementation */ +#undef USE_FIELD_INV_BUILTIN + +/* Define this symbol to use the num-based field inverse implementation */ +#undef USE_FIELD_INV_NUM + +/* Define this symbol to use the gmp implementation for num */ +#undef USE_NUM_GMP + +/* Define this symbol to use no num implementation */ +#undef USE_NUM_NONE + +/* Define this symbol to use the 4x64 scalar implementation */ +#undef USE_SCALAR_4X64 + +/* Define this symbol to use the 8x32 scalar implementation */ +#undef USE_SCALAR_8X32 + +/* Define this symbol to use the native scalar inverse implementation */ +#undef USE_SCALAR_INV_BUILTIN + +/* Define this symbol to use the num-based scalar inverse implementation */ +#undef USE_SCALAR_INV_NUM + +/* Version number of package */ +#undef VERSION + +#endif //LIBSECP256K1_CONFIG_H diff --git a/src/secp256k1/src/stamp-h1 b/src/secp256k1/src/stamp-h1 new file mode 100644 index 000000000..f863082f5 --- /dev/null +++ b/src/secp256k1/src/stamp-h1 @@ -0,0 +1 @@ +timestamp for src/libsecp256k1-config.h diff --git a/src/serialize.h b/src/serialize.h index 3b3dcd4fc..2336a2b4b 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -811,46 +811,33 @@ class CDataStream iterator insert(iterator it, const char& x=char()) { return vch.insert(it, x); } void insert(iterator it, size_type n, const char& x) { vch.insert(it, n, x); } - void insert(iterator it, const_iterator first, const_iterator last) - { - assert(last - first >= 0); - if (it == vch.begin() + nReadPos && (unsigned int)(last - first) <= nReadPos) - { - // special case for inserting at the front when there's room - nReadPos -= (last - first); - memcpy(&vch[nReadPos], &first[0], last - first); - } - else - vch.insert(it, first, last); - } - void insert(iterator it, std::vector::const_iterator first, std::vector::const_iterator last) - { - assert(last - first >= 0); - if (it == vch.begin() + nReadPos && (unsigned int)(last - first) <= nReadPos) { - // special case for inserting at the front when there's room - nReadPos -= (last - first); - memcpy(&vch[nReadPos], &first[0], last - first); + assert(last - first >= 0); + if (it == vch.begin() + nReadPos && (unsigned int)(last - first) <= nReadPos) + { + // special case for inserting at the front when there's room + nReadPos -= (last - first); + memcpy(&vch[nReadPos], &first[0], last - first); + } + else + vch.insert(it, first, last); } - else - vch.insert(it, first, last); - } -#if !defined(_MSC_VER) || _MSC_VER >= 1300 - void insert(iterator it, const char* first, const char* last) - { - assert(last - first >= 0); - if (it == vch.begin() + nReadPos && (unsigned int)(last - first) <= nReadPos) + #if !defined(_MSC_VER) || _MSC_VER >= 1300 + void insert(iterator it, const char* first, const char* last) { - // special case for inserting at the front when there's room - nReadPos -= (last - first); - memcpy(&vch[nReadPos], &first[0], last - first); + assert(last - first >= 0); + if (it == vch.begin() + nReadPos && (unsigned int)(last - first) <= nReadPos) + { + // special case for inserting at the front when there's room + nReadPos -= (last - first); + memcpy(&vch[nReadPos], &first[0], last - first); + } + else + vch.insert(it, first, last); } - else - vch.insert(it, first, last); - } -#endif + #endif iterator erase(iterator it) { diff --git a/src/strlcpy.h b/src/strlcpy.h deleted file mode 100644 index 2cc786e95..000000000 --- a/src/strlcpy.h +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 1998 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ -#ifndef BITCOIN_STRLCPY_H -#define BITCOIN_STRLCPY_H - -#include -#include - -/* - * Copy src to string dst of size siz. At most siz-1 characters - * will be copied. Always NUL terminates (unless siz == 0). - * Returns strlen(src); if retval >= siz, truncation occurred. - */ -inline size_t strlcpy(char *dst, const char *src, size_t siz) -{ - char *d = dst; - const char *s = src; - size_t n = siz; - - /* Copy as many bytes as will fit */ - if (n != 0) - { - while (--n != 0) - { - if ((*d++ = *s++) == '\0') - break; - } - } - - /* Not enough room in dst, add NUL and traverse rest of src */ - if (n == 0) - { - if (siz != 0) - *d = '\0'; /* NUL-terminate dst */ - while (*s++) - ; - } - - return(s - src - 1); /* count does not include NUL */ -} - -/* - * Appends src to string dst of size siz (unlike strncat, siz is the - * full size of dst, not space left). At most siz-1 characters - * will be copied. Always NUL terminates (unless siz <= strlen(dst)). - * Returns strlen(src) + MIN(siz, strlen(initial dst)). - * If retval >= siz, truncation occurred. - */ -inline size_t strlcat(char *dst, const char *src, size_t siz) -{ - char *d = dst; - const char *s = src; - size_t n = siz; - size_t dlen; - - /* Find the end of dst and adjust bytes left but don't go past end */ - while (n-- != 0 && *d != '\0') - d++; - dlen = d - dst; - n = siz - dlen; - - if (n == 0) - return(dlen + strlen(s)); - while (*s != '\0') - { - if (n != 1) - { - *d++ = *s; - n--; - } - s++; - } - *d = '\0'; - - return(dlen + (s - src)); /* count does not include NUL */ -} -#endif diff --git a/src/test/voting_tests.cpp b/src/test/voting_tests.cpp new file mode 100644 index 000000000..e9e28e987 --- /dev/null +++ b/src/test/voting_tests.cpp @@ -0,0 +1,391 @@ +#include +#include +#include +#include "json/json_spirit_writer_template.h" + +#include "main.h" +#include "wallet.h" +#include "../voteproposal.h" +#include "../voteobject.h" +#include "../votetally.h" +#include "../votecharset.h" +#include "../voteproposalmanager.h" +#include "../db.h" + +using namespace std; + +BOOST_AUTO_TEST_SUITE(voting_tests) + +// ERROR MESSAGES +const std::string CONSTRUCT_ERROR = "failed to construct tx"; +const std::string NOT_PROPOSAL_ERROR = "Transaction is not a proposal"; +const std::string COULD_NOT_DESERIALIZE_ERROR = "Failed to deserialize"; +const std::string BIT_LOCATION_ERROR = "location of proposal after it is deserialized isn't equal to its original value"; +const std::string BIT_COUNT_ERROR = "bitcount of proposal after it is deserialized isn't equal to its original value"; +const std::string SHIFT_ERROR = "shift of proposal after it is deserialized isn't equal to its original value"; +const std::string START_HEIGHT_ERROR = "start height of proposal after it is deserialized isn't equal to its original value"; +const std::string SPAN_ERROR = "check span of proposal after it is deserialized isn't equal to its original value"; +const std::string DESCRIPTION_ERROR = "description of proposal after it is deserialized isn't equal to its original value"; +const std::string NAME_ERROR = "name of proposal after it is deserialized isn't equal to its original value"; +const std::string HASH_ERROR = "hash of proposal after it is deserialized isn't equal to its original value"; +const std::string REFUND_ADDRESS_ERROR = "refund address is not equal to its original value after deserialization"; +const std::string MAX_FEE_ERROR = "the max fee of the proposal after it is deserialized isn't equal to its original value"; +const std::string DIFFERENT_ORDER_ERROR = "the deterministic ordering should be the same for both vectors but isn't"; +const std::string SAME_ORDER_ERROR = "the deterministic orderings of the same vector for two different proofhashes are the same"; +const std::string CREATE_ORDER_ERROR = "failed to construct deterministic ordering of proposals"; +const std::string REFUND_OUT_ERROR = "the refund outputs in the coinbase tx were not constructed correctly"; + +// name of issue +std::string strName = "proposal1"; +// check version for existing proposals Shift +uint8_t nShift = 20; +// start time - will be changed to int StartHeight. unix time stamp +int64 nStartTime = 10000000; +// number of blocks with votes to count +int nCheckSpan = 1000; +// cardinal items to vote on - convert to uint8 CheckSpan +uint8_t nCardinals = 2; +// description of issue - will go in different tx +std::string strDescription = "test_description"; + +BOOST_AUTO_TEST_CASE(proposal_serialization) +{ + std::cout << "testing proposal serialization\n"; + + CVoteProposalManager manager; + + VoteLocation location; + manager.GetNextLocation(nCardinals, nStartTime, nCheckSpan, location); + CVoteProposal proposal(strName, nStartTime, nCheckSpan, strDescription, location); + manager.Add(proposal); + + //! Add the constructed proposal to a partial transaction + CTransaction tx; + BOOST_CHECK_MESSAGE(proposal.ConstructTransaction(tx), "failed to construct tx"); + + BOOST_CHECK_MESSAGE(tx.IsProposal(), "Transaction is not a proposal!"); + + CVoteProposal proposal2; + BOOST_CHECK_MESSAGE(ProposalFromTransaction(tx, proposal2), "Failed to deserialize"); + + //CHECKS TO DETERMINE IF DESERIALIZATION WORKS AS INTENDED + BOOST_CHECK_MESSAGE(proposal2.GetHash() == proposal.GetHash(), "hash of proposal after it is deserialized isn't equal" + "to its original value"); + BOOST_CHECK_MESSAGE(proposal2.GetLocation().nLeastSignificantBit == proposal.GetLocation().nLeastSignificantBit + && proposal2.GetLocation().nMostSignificantBit == proposal.GetLocation().nMostSignificantBit, + "location of proposal after it is deserialized isn't equal to its original value"); + BOOST_CHECK_MESSAGE(proposal2.GetBitCount() == proposal.GetBitCount(), "bitcount of proposal after it is deserialized isn't equal" + "to its original value"); + BOOST_CHECK_MESSAGE(proposal2.GetShift() == proposal.GetShift(), "shift of proposal after it is deserialized isn't equal" + "to its original value"); + BOOST_CHECK_MESSAGE(proposal2.GetStartHeight() == proposal.GetStartHeight(), "start height of proposal after it is deserialized isn't equal" + "to its original value"); + BOOST_CHECK_MESSAGE(proposal2.GetCheckSpan() == proposal.GetCheckSpan(), "check span of proposal after it is deserialized isn't equal" + "to its original value"); + BOOST_CHECK_MESSAGE(proposal2.GetDescription() == proposal.GetDescription(), "description of proposal after it is deserialized isn't equal" + "to its original value"); + BOOST_CHECK_MESSAGE(proposal2.GetName() == proposal.GetName(), "name of proposal after it is deserialized isn't equal" + "to its original value"); + + //! Create a tx that can be used as an input in the actual proposal tx + CTransaction txFunding; + CTxOut outTemp(10 * COIN, CScript()); + txFunding.vout.push_back(outTemp); + mempool.addUnchecked(txFunding.GetHash(), txFunding); + + //! Add an input to the proposal tx + tx.vin.push_back(CTxIn(txFunding.GetHash(), 0)); + tx.vout[0].nValue = MIN_TXOUT_AMOUNT; + cout << tx.ToString() << "\n"; + + //! Return anything beyond the proposal fee (5 HYP) as change UTXO + int64 nFee = 5 * COIN; + nFee -= MIN_TXOUT_AMOUNT; //Had to assign mintxamt to the utxo containing the proposal + int64 nChange = outTemp.nValue - nFee; + if (nChange > 500) { + CKey key; + key.MakeNewKey(true); + + CScript scriptReturn; + scriptReturn << OP_DUP << OP_HASH160 << ToByteVector(Hash160(scriptReturn)) << OP_EQUALVERIFY << OP_CHECKSIG; + CTxOut out(nChange, scriptReturn); + + //Add the change output to the new transaction + tx.vout.push_back(out); + } + + BOOST_CHECK_MESSAGE(tx.CheckTransaction(), "check transaction failed"); + + CTxDB txdb("r"); + BOOST_CHECK_MESSAGE(tx.AcceptToMemoryPool(txdb, false), "transaction not accepted to mempool"); + +} + +//BOOST_AUTO_TEST_CASE(vote_tally) +//{ + /*std::cout << "testing vote tally\n"; + + map mapNewLocations; + VoteLocation location(proposal.GetShift() + proposal.GetBitCount() - 1, proposal.GetShift()); + mapNewLocations.insert(make_pair(proposal.GetHash(), location)); + + CTransaction tx; + proposal.ConstructTransaction(tx); + + mapProposals.insert(std::pair(tx.GetHash(), proposal.GetHash())); + + CVoteTally tally; + BOOST_CHECK_MESSAGE(tally.SetNewPositions(mapNewLocations), "Position is already occupied when it should not be"); + + uint32_t nVote = 0x40080000; + // 0100 0000 0000 1000 0000 0000 0000 0000 + // + tally.ProcessNewVotes(nVote); + + CVoteSummary summary; + BOOST_CHECK_MESSAGE(tally.GetSummary(proposal.GetHash(), summary), "failed to get summary from tally"); + BOOST_CHECK_MESSAGE(summary.nYesTally == 1, "summary is not 1"); + std::cout << summary.nYesTally << endl; + + //Start a new tally object for the next block + CVoteTally tally2(tally); + tally2.ProcessNewVotes(nVote); + CVoteSummary summary2; + BOOST_CHECK_MESSAGE(tally2.GetSummary(proposal.GetHash(), summary2), "failed to get summary from tally2"); + BOOST_CHECK_MESSAGE(summary2.nYesTally == 2, "summary2 is not 2"); + + //Start a new tally object for the next block - vote no + CVoteTally tally3(tally2); + nVote = 0x40180011; + tally3.ProcessNewVotes(nVote); + CVoteSummary summary3; + BOOST_CHECK_MESSAGE(tally3.GetSummary(proposal.GetHash(), summary3), "failed to get summary from tally2"); + BOOST_CHECK_MESSAGE(summary3.nYesTally == 2, "summary3 is not 2"); + BOOST_CHECK_MESSAGE(summary3.nNoTally == 1, "summary3 no votes is not 1"); + + //Start a new tally object for the next block - vote abstain + CVoteTally tally4(tally3); + nVote = 0x40000011; + tally4.ProcessNewVotes(nVote); + CVoteSummary summary4; + BOOST_CHECK_MESSAGE(tally4.GetSummary(proposal.GetHash(), summary4), "failed to get summary from tally2"); + BOOST_CHECK_MESSAGE(summary4.nYesTally == 2, "summary4 is not 2"); + BOOST_CHECK_MESSAGE(summary4.nNoTally == 1, "summary4 no votes is not 1");*/ + +//} + +BOOST_AUTO_TEST_CASE(vote_charset) +{ + std::cout << "testing proposal manager functionality and GetCombinedVotes()" << endl; + + CVoteProposalManager manager; + + VoteLocation location1; + manager.GetNextLocation(nCardinals, nStartTime, nCheckSpan, location1); + CVoteProposal proposal1(strName, nStartTime, nCheckSpan, strDescription, location1); + manager.Add(proposal1); + + VoteLocation location2; + manager.GetNextLocation(nCardinals, nStartTime, nCheckSpan, location2); + CVoteProposal proposal2(strName, nStartTime, nCheckSpan, strDescription, location2); + manager.Add(proposal2); + + VoteLocation location3; + manager.GetNextLocation(nCardinals, nStartTime, nCheckSpan, location3); + CVoteProposal proposal3(strName, nStartTime, nCheckSpan, strDescription, location3); + manager.Add(proposal3); + + VoteLocation location4; + manager.GetNextLocation(nCardinals, nStartTime, nCheckSpan, location4); + CVoteProposal proposal4(strName, nStartTime, nCheckSpan, strDescription, location4); + manager.Add(proposal4); + + VoteLocation location5; + manager.GetNextLocation(nCardinals, nStartTime, nCheckSpan, location5); + CVoteProposal proposal5(strName, nStartTime, nCheckSpan, strDescription, location5); + manager.Add(proposal5); + + uint32_t nVersion = 0x50000000; + + uint32_t nVote1 = 2; + CVoteObject vote1(proposal1.GetHash(), proposal1.GetLocation()); + vote1.Vote(nVote1); + + uint32_t nVote2 = 1; + CVoteObject vote2(proposal2.GetHash(), proposal2.GetLocation()); + vote2.Vote(nVote2); + + uint32_t nVote3 = 2; + CVoteObject vote3(proposal3.GetHash(), proposal3.GetLocation()); + vote3.Vote(nVote3); + + uint32_t nVote4 = 1; + CVoteObject vote4(proposal4.GetHash(), proposal4.GetLocation()); + vote4.Vote(nVote4); + + uint32_t nVote5 = 2; + CVoteObject vote5(proposal5.GetHash(), proposal5.GetLocation()); + vote5.Vote(nVote5); + + std::vector votes = {vote1, vote2, vote3, vote4, vote5}; + + nVersion |= CVoteObject::GetCombinedVotes(votes); + + // 0101 [10 01] [10 01] [10 00] 0000 0000 0000 0000 + uint32_t correctResult = 0x59980000; + + std::cout << "Expected result: " << correctResult << endl << "Actual result: " << nVersion << endl; + + BOOST_CHECK_MESSAGE(nVersion == correctResult, "votes were not combined correctly"); +} + + +//BOOST_AUTO_TEST_CASE(vote_deterministic_ordering) { +// +// std::cout << "testing deterministic ordering of proposal transactions" << endl; +// +// CVoteProposalManager manager; +// +// std::string strName = "prop"; +// std::string strDescription = "this is the description"; +// std::string strRefundAddress = "kxpSiwFkHJdNnYFojNDAvP3iiYyw3GH6ZL"; +// int nMaxFee = 5000000; +// +// CVoteProposal proposal1(strName, nStartHeight, nCheckSpan, strDescription + "1", nMaxFee, strRefundAddress); +// CVoteProposal proposal2(strName, nStartHeight, nCheckSpan, strDescription + "2", nMaxFee, strRefundAddress); +// CVoteProposal proposal3(strName, nStartHeight, nCheckSpan, strDescription + "3", nMaxFee, strRefundAddress); +// CVoteProposal proposal4(strName, nStartHeight, nCheckSpan, strDescription + "4", nMaxFee, strRefundAddress); +// CVoteProposal proposal5(strName, nStartHeight, nCheckSpan, strDescription + "5", nMaxFee, strRefundAddress); +// +// CTransaction txProposal1; +// BOOST_CHECK_MESSAGE(proposal1.ConstructTransaction(txProposal1), CONSTRUCT_ERROR); +// +// CTransaction txProposal2; +// BOOST_CHECK_MESSAGE(proposal2.ConstructTransaction(txProposal2), CONSTRUCT_ERROR); +// +// CTransaction txProposal3; +// BOOST_CHECK_MESSAGE(proposal3.ConstructTransaction(txProposal3), CONSTRUCT_ERROR); +// +// CTransaction txProposal4; +// BOOST_CHECK_MESSAGE(proposal4.ConstructTransaction(txProposal4), CONSTRUCT_ERROR); +// +// CTransaction txProposal5; +// BOOST_CHECK_MESSAGE(proposal5.ConstructTransaction(txProposal5), CONSTRUCT_ERROR); +// +// vector vTxProposals = {txProposal1, txProposal2, txProposal3, txProposal4, txProposal5}; +// +// vector vOrderedTxProposals1; +// BOOST_CHECK_MESSAGE(proposalManager.GetDeterministicOrdering(uint256("0xba04fd9cd0e9487f1a713e80828055284c04e362167ceb5f75db70153c613736"), +// vTxProposals, vOrderedTxProposals1), CREATE_ORDER_ERROR); +// +// vector vOrderedTxProposals2; +// BOOST_CHECK_MESSAGE(proposalManager.GetDeterministicOrdering(uint256("0xba04fd9cd0e9487f1a713e80828055284c04e362167ceb5f75db70153c613736"), +// vTxProposals, vOrderedTxProposals2), CREATE_ORDER_ERROR); +// +// // verify that both orderings of tx proposals are the same +// for(int i = 0; i < vTxProposals.size(); i++) { +// BOOST_CHECK_MESSAGE(vOrderedTxProposals1.at(i).GetHash() == vOrderedTxProposals2.at(i).GetHash(), +// DIFFERENT_ORDER_ERROR); +// } +// +// vector vDifferentOrderedTxProposals; +// BOOST_CHECK_MESSAGE(proposalManager.GetDeterministicOrdering(uint256("0xd7ec1705209f0212de02409cea9a9ca565571ae2977241f690dac11a7889d3f4"), +// vTxProposals, vDifferentOrderedTxProposals), CREATE_ORDER_ERROR); +// +// // verify that the ordering of the tx proposals is different for a new proof hash +// bool bSameOrder = true; +// for(int i = 0; i < vTxProposals.size(); i++) { +// bSameOrder = bSameOrder && (vOrderedTxProposals1.at(i).GetHash() == vDifferentOrderedTxProposals.at(i).GetHash()); +// } +// +// BOOST_CHECK_MESSAGE(!bSameOrder, SAME_ORDER_ERROR); +//} + +//BOOST_AUTO_TEST_CASE(vote_refund_process) { +// std::cout << "testing refund process for proposal requests" << endl; +// +// CVoteProposalManager manager; +// +// std::string strName = "prop"; +// std::string strDescription = "this is the description"; +// std::string strRefundAddress = "kxpSiwFkHJdNnYFojNDAvP3iiYyw3GH6ZL"; +// int nMaxFee1 = 5000000; +// int nMaxFee2 = 938049809; +// int nMaxFee3 = 3; +// int nMaxFee4 = 1000000000; +// int nMaxFee5 = 6000000; +// +// CTransaction txCoinBase; +// txCoinBase.vin.resize(1); +// txCoinBase.vin[0].prevout.SetNull(); +// txCoinBase.vout.resize(1); +// +// CVoteProposal proposal1(strName, nStartHeight, nCheckSpan, strDescription, nMaxFee1, strRefundAddress); +// CVoteProposal proposal2(strName, nStartHeight, nCheckSpan, strDescription, nMaxFee2, strRefundAddress); +// CVoteProposal proposal3(strName, nStartHeight, nCheckSpan, strDescription, nMaxFee3, strRefundAddress); +// CVoteProposal proposal4(strName, nStartHeight, nCheckSpan, strDescription, nMaxFee4, strRefundAddress); +// CVoteProposal proposal5(strName, nStartHeight, nCheckSpan, strDescription, nMaxFee5, strRefundAddress); +// +// CTransaction txProposal1; +// BOOST_CHECK_MESSAGE(proposal1.ConstructTransaction(txProposal1), CONSTRUCT_ERROR); +// +// CTransaction txProposal2; +// BOOST_CHECK_MESSAGE(proposal2.ConstructTransaction(txProposal2), CONSTRUCT_ERROR); +// +// CTransaction txProposal3; +// BOOST_CHECK_MESSAGE(proposal3.ConstructTransaction(txProposal3), CONSTRUCT_ERROR); +// +// CTransaction txProposal4; +// BOOST_CHECK_MESSAGE(proposal4.ConstructTransaction(txProposal4), CONSTRUCT_ERROR); +// +// CTransaction txProposal5; +// BOOST_CHECK_MESSAGE(proposal5.ConstructTransaction(txProposal5), CONSTRUCT_ERROR); +// +// vector vTxProposals = {txProposal1, txProposal2, txProposal3, txProposal4, txProposal5}; +// +// vector vOrderedTxProposals; +// BOOST_CHECK_MESSAGE(proposalManager.GetDeterministicOrdering(uint256("0xba04fd9cd0e9487f1a713e80828055284c04e362167ceb5f75db70153c613736"), +// vTxProposals, vOrderedTxProposals), CREATE_ORDER_ERROR); +// +// for (CTransaction txProposal: vOrderedTxProposals) { +// // output variables +// int nRequiredFee; +// CVoteProposal proposal; +// VoteLocation location; +// +// // Skip this txProposal if a proposal object cannot be extracted from it +// BOOST_CHECK_MESSAGE(ProposalFromTransaction(txProposal, proposal), CONSTRUCT_ERROR); +// proposalManager.Add(proposal); +// +// // input variables +// int nTxFee = CVoteProposal::BASE_FEE; +// int nBitCount = proposal.GetBitCount(); +// int nStartHeight = proposal.GetStartHeight(); +// int nCheckSpan = proposal.GetCheckSpan(); +// +// // If a valid voting location cannot be found then create an unaccepted proposal refund +// if (!proposalManager.GetNextLocation(nBitCount, nStartHeight, nCheckSpan, location)) { +// proposalManager.AddRefundToCoinBase(proposal, nRequiredFee, nTxFee, false, txCoinBase); +// } else { +// BOOST_CHECK(true); +// // If a fee cannot be calculated then skip this proposal without creating a refund tx +// proposal.SetLocation(location); +// BOOST_CHECK_MESSAGE(proposalManager.GetFee(proposal, nRequiredFee), "could not calculate fee."); +// +// BOOST_CHECK(true); +// // If the maximum fee provided by the proposal creator is less than the required fee +// // then create an unaccepted proposal refund +// if (nRequiredFee > proposal.GetMaxFee()) { +// BOOST_CHECK(true); +// proposalManager.AddRefundToCoinBase(proposal, nRequiredFee, nTxFee, false, txCoinBase); +// } else { +// BOOST_CHECK(true); +// proposalManager.AddRefundToCoinBase(proposal, nRequiredFee, nTxFee, true, txCoinBase); +// } +// } +// } +// +// BOOST_CHECK_MESSAGE(proposalManager.CheckRefundTransaction(vOrderedTxProposals, txCoinBase), REFUND_OUT_ERROR); +//} + +BOOST_AUTO_TEST_SUITE_END() diff --git a/src/tinyformat.h b/src/tinyformat.h new file mode 100644 index 000000000..73d49a1fe --- /dev/null +++ b/src/tinyformat.h @@ -0,0 +1,1013 @@ +// tinyformat.h +// Copyright (C) 2011, Chris Foster [chris42f (at) gmail (d0t) com] +// +// Boost Software License - Version 1.0 +// +// Permission is hereby granted, free of charge, to any person or organization +// obtaining a copy of the software and accompanying documentation covered by +// this license (the "Software") to use, reproduce, display, distribute, +// execute, and transmit the Software, and to prepare derivative works of the +// Software, and to permit third-parties to whom the Software is furnished to +// do so, all subject to the following: +// +// The copyright notices in the Software and this entire statement, including +// the above license grant, this restriction and the following disclaimer, +// must be included in all copies of the Software, in whole or in part, and +// all derivative works of the Software, unless such copies or derivative +// works are solely in the form of machine-executable object code generated by +// a source language processor. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. + +//------------------------------------------------------------------------------ +// Tinyformat: A minimal type safe printf replacement +// +// tinyformat.h is a type safe printf replacement library in a single C++ +// header file. Design goals include: +// +// * Type safety and extensibility for user defined types. +// * C99 printf() compatibility, to the extent possible using std::ostream +// * Simplicity and minimalism. A single header file to include and distribute +// with your projects. +// * Augment rather than replace the standard stream formatting mechanism +// * C++98 support, with optional C++11 niceties +// +// +// Main interface example usage +// ---------------------------- +// +// To print a date to std::cout: +// +// std::string weekday = "Wednesday"; +// const char* month = "July"; +// size_t day = 27; +// long hour = 14; +// int min = 44; +// +// tfm::printf("%s, %s %d, %.2d:%.2d\n", weekday, month, day, hour, min); +// +// The strange types here emphasize the type safety of the interface; it is +// possible to print a std::string using the "%s" conversion, and a +// size_t using the "%d" conversion. A similar result could be achieved +// using either of the tfm::format() functions. One prints on a user provided +// stream: +// +// tfm::format(std::cerr, "%s, %s %d, %.2d:%.2d\n", +// weekday, month, day, hour, min); +// +// The other returns a std::string: +// +// std::string date = tfm::format("%s, %s %d, %.2d:%.2d\n", +// weekday, month, day, hour, min); +// std::cout << date; +// +// These are the three primary interface functions. +// +// +// User defined format functions +// ----------------------------- +// +// Simulating variadic templates in C++98 is pretty painful since it requires +// writing out the same function for each desired number of arguments. To make +// this bearable tinyformat comes with a set of macros which are used +// internally to generate the API, but which may also be used in user code. +// +// The three macros TINYFORMAT_ARGTYPES(n), TINYFORMAT_VARARGS(n) and +// TINYFORMAT_PASSARGS(n) will generate a list of n argument types, +// type/name pairs and argument names respectively when called with an integer +// n between 1 and 16. We can use these to define a macro which generates the +// desired user defined function with n arguments. To generate all 16 user +// defined function bodies, use the macro TINYFORMAT_FOREACH_ARGNUM. For an +// example, see the implementation of printf() at the end of the source file. +// +// +// Additional API information +// -------------------------- +// +// Error handling: Define TINYFORMAT_ERROR to customize the error handling for +// format strings which are unsupported or have the wrong number of format +// specifiers (calls assert() by default). +// +// User defined types: Uses operator<< for user defined types by default. +// Overload formatValue() for more control. + + +#ifndef TINYFORMAT_H_INCLUDED +#define TINYFORMAT_H_INCLUDED + +namespace tinyformat {} +//------------------------------------------------------------------------------ +// Config section. Customize to your liking! + +// Namespace alias to encourage brevity +namespace tfm = tinyformat; + +// Error handling; calls assert() by default. +#define TINYFORMAT_ERROR(reasonString) throw std::runtime_error(reasonString) + +// Define for C++11 variadic templates which make the code shorter & more +// general. If you don't define this, C++11 support is autodetected below. +// #define TINYFORMAT_USE_VARIADIC_TEMPLATES + + +//------------------------------------------------------------------------------ +// Implementation details. +#include +#include +#include +#include + +#ifndef TINYFORMAT_ERROR +# define TINYFORMAT_ERROR(reason) assert(0 && reason) +#endif + +#if !defined(TINYFORMAT_USE_VARIADIC_TEMPLATES) && !defined(TINYFORMAT_NO_VARIADIC_TEMPLATES) +# ifdef __GXX_EXPERIMENTAL_CXX0X__ +# define TINYFORMAT_USE_VARIADIC_TEMPLATES +# endif +#endif + +#ifdef __GNUC__ +# define TINYFORMAT_NOINLINE __attribute__((noinline)) +#elif defined(_MSC_VER) +# define TINYFORMAT_NOINLINE __declspec(noinline) +#else +# define TINYFORMAT_NOINLINE +#endif + +#if defined(__GLIBCXX__) && __GLIBCXX__ < 20080201 +// std::showpos is broken on old libstdc++ as provided with OSX. See +// http://gcc.gnu.org/ml/libstdc++/2007-11/msg00075.html +# define TINYFORMAT_OLD_LIBSTDCPLUSPLUS_WORKAROUND +#endif + +namespace tinyformat { + +//------------------------------------------------------------------------------ +namespace detail { + +// Test whether type T1 is convertible to type T2 +template +struct is_convertible +{ + private: + // two types of different size + struct fail { char dummy[2]; }; + struct succeed { char dummy; }; + // Try to convert a T1 to a T2 by plugging into tryConvert + static fail tryConvert(...); + static succeed tryConvert(const T2&); + static const T1& makeT1(); + public: +# ifdef _MSC_VER + // Disable spurious loss of precision warnings in tryConvert(makeT1()) +# pragma warning(push) +# pragma warning(disable:4244) +# pragma warning(disable:4267) +# endif + // Standard trick: the (...) version of tryConvert will be chosen from + // the overload set only if the version taking a T2 doesn't match. + // Then we compare the sizes of the return types to check which + // function matched. Very neat, in a disgusting kind of way :) + static const bool value = + sizeof(tryConvert(makeT1())) == sizeof(succeed); +# ifdef _MSC_VER +# pragma warning(pop) +# endif +}; + + +// Detect when a type is not a wchar_t string +template struct is_wchar { typedef int tinyformat_wchar_is_not_supported; }; +template<> struct is_wchar {}; +template<> struct is_wchar {}; +template struct is_wchar {}; +template struct is_wchar {}; + + +// Format the value by casting to type fmtT. This default implementation +// should never be called. +template::value> +struct formatValueAsType +{ + static void invoke(std::ostream& /*out*/, const T& /*value*/) { assert(0); } +}; +// Specialized version for types that can actually be converted to fmtT, as +// indicated by the "convertible" template parameter. +template +struct formatValueAsType +{ + static void invoke(std::ostream& out, const T& value) + { out << static_cast(value); } +}; + +#ifdef TINYFORMAT_OLD_LIBSTDCPLUSPLUS_WORKAROUND +template::value> +struct formatZeroIntegerWorkaround +{ + static bool invoke(std::ostream& /**/, const T& /**/) { return false; } +}; +template +struct formatZeroIntegerWorkaround +{ + static bool invoke(std::ostream& out, const T& value) + { + if (static_cast(value) == 0 && out.flags() & std::ios::showpos) + { + out << "+0"; + return true; + } + return false; + } +}; +#endif // TINYFORMAT_OLD_LIBSTDCPLUSPLUS_WORKAROUND + +// Convert an arbitrary type to integer. The version with convertible=false +// throws an error. +template::value> +struct convertToInt +{ + static int invoke(const T& /*value*/) + { + TINYFORMAT_ERROR("tinyformat: Cannot convert from argument type to " + "integer for use as variable width or precision"); + return 0; + } +}; +// Specialization for convertToInt when conversion is possible +template +struct convertToInt +{ + static int invoke(const T& value) { return static_cast(value); } +}; + +} // namespace detail + + +//------------------------------------------------------------------------------ +// Variable formatting functions. May be overridden for user-defined types if +// desired. + + +// Format a value into a stream. Called from format() for all types by default. +// +// Users may override this for their own types. When this function is called, +// the stream flags will have been modified according to the format string. +// The format specification is provided in the range [fmtBegin, fmtEnd). +// +// By default, formatValue() uses the usual stream insertion operator +// operator<< to format the type T, with special cases for the %c and %p +// conversions. +template +inline void formatValue(std::ostream& out, const char* /*fmtBegin*/, + const char* fmtEnd, const T& value) +{ +#ifndef TINYFORMAT_ALLOW_WCHAR_STRINGS + // Since we don't support printing of wchar_t using "%ls", make it fail at + // compile time in preference to printing as a void* at runtime. + typedef typename detail::is_wchar::tinyformat_wchar_is_not_supported DummyType; + (void) DummyType(); // avoid unused type warning with gcc-4.8 +#endif + // The mess here is to support the %c and %p conversions: if these + // conversions are active we try to convert the type to a char or const + // void* respectively and format that instead of the value itself. For the + // %p conversion it's important to avoid dereferencing the pointer, which + // could otherwise lead to a crash when printing a dangling (const char*). + const bool canConvertToChar = detail::is_convertible::value; + const bool canConvertToVoidPtr = detail::is_convertible::value; + if(canConvertToChar && *(fmtEnd-1) == 'c') + detail::formatValueAsType::invoke(out, value); + else if(canConvertToVoidPtr && *(fmtEnd-1) == 'p') + detail::formatValueAsType::invoke(out, value); +#ifdef TINYFORMAT_OLD_LIBSTDCPLUSPLUS_WORKAROUND + else if(detail::formatZeroIntegerWorkaround::invoke(out, value)) /**/; +#endif + else + out << value; +} + + +// Overloaded version for char types to support printing as an integer +#define TINYFORMAT_DEFINE_FORMATVALUE_CHAR(charType) \ +inline void formatValue(std::ostream& out, const char* /*fmtBegin*/, \ + const char* fmtEnd, charType value) \ +{ \ + switch(*(fmtEnd-1)) \ + { \ + case 'u': case 'd': case 'i': case 'o': case 'X': case 'x': \ + out << static_cast(value); break; \ + default: \ + out << value; break; \ + } \ +} +// per 3.9.1: char, signed char and unsigned char are all distinct types +TINYFORMAT_DEFINE_FORMATVALUE_CHAR(char) +TINYFORMAT_DEFINE_FORMATVALUE_CHAR(signed char) +TINYFORMAT_DEFINE_FORMATVALUE_CHAR(unsigned char) +#undef TINYFORMAT_DEFINE_FORMATVALUE_CHAR + + +//------------------------------------------------------------------------------ +// Tools for emulating variadic templates in C++98. The basic idea here is +// stolen from the boost preprocessor metaprogramming library and cut down to +// be just general enough for what we need. + +#define TINYFORMAT_ARGTYPES(n) TINYFORMAT_ARGTYPES_ ## n +#define TINYFORMAT_VARARGS(n) TINYFORMAT_VARARGS_ ## n +#define TINYFORMAT_PASSARGS(n) TINYFORMAT_PASSARGS_ ## n +#define TINYFORMAT_PASSARGS_TAIL(n) TINYFORMAT_PASSARGS_TAIL_ ## n + +// To keep it as transparent as possible, the macros below have been generated +// using python via the excellent cog.py code generation script. This avoids +// the need for a bunch of complex (but more general) preprocessor tricks as +// used in boost.preprocessor. +// +// To rerun the code generation in place, use `cog.py -r tinyformat.h` +// (see http://nedbatchelder.com/code/cog). Alternatively you can just create +// extra versions by hand. + +/*[[[cog +maxParams = 16 + +def makeCommaSepLists(lineTemplate, elemTemplate, startInd=1): + for j in range(startInd,maxParams+1): + list = ', '.join([elemTemplate % {'i':i} for i in range(startInd,j+1)]) + cog.outl(lineTemplate % {'j':j, 'list':list}) + +makeCommaSepLists('#define TINYFORMAT_ARGTYPES_%(j)d %(list)s', + 'class T%(i)d') + +cog.outl() +makeCommaSepLists('#define TINYFORMAT_VARARGS_%(j)d %(list)s', + 'const T%(i)d& v%(i)d') + +cog.outl() +makeCommaSepLists('#define TINYFORMAT_PASSARGS_%(j)d %(list)s', 'v%(i)d') + +cog.outl() +cog.outl('#define TINYFORMAT_PASSARGS_TAIL_1') +makeCommaSepLists('#define TINYFORMAT_PASSARGS_TAIL_%(j)d , %(list)s', + 'v%(i)d', startInd = 2) + +cog.outl() +cog.outl('#define TINYFORMAT_FOREACH_ARGNUM(m) \\\n ' + + ' '.join(['m(%d)' % (j,) for j in range(1,maxParams+1)])) +]]]*/ +#define TINYFORMAT_ARGTYPES_1 class T1 +#define TINYFORMAT_ARGTYPES_2 class T1, class T2 +#define TINYFORMAT_ARGTYPES_3 class T1, class T2, class T3 +#define TINYFORMAT_ARGTYPES_4 class T1, class T2, class T3, class T4 +#define TINYFORMAT_ARGTYPES_5 class T1, class T2, class T3, class T4, class T5 +#define TINYFORMAT_ARGTYPES_6 class T1, class T2, class T3, class T4, class T5, class T6 +#define TINYFORMAT_ARGTYPES_7 class T1, class T2, class T3, class T4, class T5, class T6, class T7 +#define TINYFORMAT_ARGTYPES_8 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8 +#define TINYFORMAT_ARGTYPES_9 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9 +#define TINYFORMAT_ARGTYPES_10 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10 +#define TINYFORMAT_ARGTYPES_11 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11 +#define TINYFORMAT_ARGTYPES_12 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12 +#define TINYFORMAT_ARGTYPES_13 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12, class T13 +#define TINYFORMAT_ARGTYPES_14 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12, class T13, class T14 +#define TINYFORMAT_ARGTYPES_15 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12, class T13, class T14, class T15 +#define TINYFORMAT_ARGTYPES_16 class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8, class T9, class T10, class T11, class T12, class T13, class T14, class T15, class T16 + +#define TINYFORMAT_VARARGS_1 const T1& v1 +#define TINYFORMAT_VARARGS_2 const T1& v1, const T2& v2 +#define TINYFORMAT_VARARGS_3 const T1& v1, const T2& v2, const T3& v3 +#define TINYFORMAT_VARARGS_4 const T1& v1, const T2& v2, const T3& v3, const T4& v4 +#define TINYFORMAT_VARARGS_5 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5 +#define TINYFORMAT_VARARGS_6 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6 +#define TINYFORMAT_VARARGS_7 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7 +#define TINYFORMAT_VARARGS_8 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8 +#define TINYFORMAT_VARARGS_9 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9 +#define TINYFORMAT_VARARGS_10 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10 +#define TINYFORMAT_VARARGS_11 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10, const T11& v11 +#define TINYFORMAT_VARARGS_12 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10, const T11& v11, const T12& v12 +#define TINYFORMAT_VARARGS_13 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10, const T11& v11, const T12& v12, const T13& v13 +#define TINYFORMAT_VARARGS_14 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10, const T11& v11, const T12& v12, const T13& v13, const T14& v14 +#define TINYFORMAT_VARARGS_15 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10, const T11& v11, const T12& v12, const T13& v13, const T14& v14, const T15& v15 +#define TINYFORMAT_VARARGS_16 const T1& v1, const T2& v2, const T3& v3, const T4& v4, const T5& v5, const T6& v6, const T7& v7, const T8& v8, const T9& v9, const T10& v10, const T11& v11, const T12& v12, const T13& v13, const T14& v14, const T15& v15, const T16& v16 + +#define TINYFORMAT_PASSARGS_1 v1 +#define TINYFORMAT_PASSARGS_2 v1, v2 +#define TINYFORMAT_PASSARGS_3 v1, v2, v3 +#define TINYFORMAT_PASSARGS_4 v1, v2, v3, v4 +#define TINYFORMAT_PASSARGS_5 v1, v2, v3, v4, v5 +#define TINYFORMAT_PASSARGS_6 v1, v2, v3, v4, v5, v6 +#define TINYFORMAT_PASSARGS_7 v1, v2, v3, v4, v5, v6, v7 +#define TINYFORMAT_PASSARGS_8 v1, v2, v3, v4, v5, v6, v7, v8 +#define TINYFORMAT_PASSARGS_9 v1, v2, v3, v4, v5, v6, v7, v8, v9 +#define TINYFORMAT_PASSARGS_10 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10 +#define TINYFORMAT_PASSARGS_11 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11 +#define TINYFORMAT_PASSARGS_12 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12 +#define TINYFORMAT_PASSARGS_13 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13 +#define TINYFORMAT_PASSARGS_14 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14 +#define TINYFORMAT_PASSARGS_15 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 +#define TINYFORMAT_PASSARGS_16 v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16 + +#define TINYFORMAT_PASSARGS_TAIL_1 +#define TINYFORMAT_PASSARGS_TAIL_2 , v2 +#define TINYFORMAT_PASSARGS_TAIL_3 , v2, v3 +#define TINYFORMAT_PASSARGS_TAIL_4 , v2, v3, v4 +#define TINYFORMAT_PASSARGS_TAIL_5 , v2, v3, v4, v5 +#define TINYFORMAT_PASSARGS_TAIL_6 , v2, v3, v4, v5, v6 +#define TINYFORMAT_PASSARGS_TAIL_7 , v2, v3, v4, v5, v6, v7 +#define TINYFORMAT_PASSARGS_TAIL_8 , v2, v3, v4, v5, v6, v7, v8 +#define TINYFORMAT_PASSARGS_TAIL_9 , v2, v3, v4, v5, v6, v7, v8, v9 +#define TINYFORMAT_PASSARGS_TAIL_10 , v2, v3, v4, v5, v6, v7, v8, v9, v10 +#define TINYFORMAT_PASSARGS_TAIL_11 , v2, v3, v4, v5, v6, v7, v8, v9, v10, v11 +#define TINYFORMAT_PASSARGS_TAIL_12 , v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12 +#define TINYFORMAT_PASSARGS_TAIL_13 , v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13 +#define TINYFORMAT_PASSARGS_TAIL_14 , v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14 +#define TINYFORMAT_PASSARGS_TAIL_15 , v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15 +#define TINYFORMAT_PASSARGS_TAIL_16 , v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15, v16 + +#define TINYFORMAT_FOREACH_ARGNUM(m) \ + m(1) m(2) m(3) m(4) m(5) m(6) m(7) m(8) m(9) m(10) m(11) m(12) m(13) m(14) m(15) m(16) +//[[[end]]] + + + +namespace detail { + +// Class holding current position in format string and an output stream into +// which arguments are formatted. +class FormatIterator +{ + public: + // Flags for features not representable with standard stream state + enum ExtraFormatFlags + { + Flag_None = 0, + Flag_TruncateToPrecision = 1<<0, // truncate length to stream precision() + Flag_SpacePadPositive = 1<<1, // pad positive values with spaces + Flag_VariableWidth = 1<<2, // variable field width in arg list + Flag_VariablePrecision = 1<<3 // variable field precision in arg list + }; + + // out is the output stream, fmt is the full format string + FormatIterator(std::ostream& out, const char* fmt) + : m_out(out), + m_fmt(fmt), + m_extraFlags(Flag_None), + m_wantWidth(false), + m_wantPrecision(false), + m_variableWidth(0), + m_variablePrecision(0), + m_origWidth(out.width()), + m_origPrecision(out.precision()), + m_origFlags(out.flags()), + m_origFill(out.fill()) + { } + + // Print remaining part of format string. + void finish() + { + // It would be nice if we could do this from the destructor, but we + // can't if TINFORMAT_ERROR is used to throw an exception! + m_fmt = printFormatStringLiteral(m_out, m_fmt); + if(*m_fmt != '\0') + TINYFORMAT_ERROR("tinyformat: Too many conversion specifiers in format string"); + } + + ~FormatIterator() + { + // Restore stream state + m_out.width(m_origWidth); + m_out.precision(m_origPrecision); + m_out.flags(m_origFlags); + m_out.fill(m_origFill); + } + + template + void accept(const T& value); + + private: + // Parse and return an integer from the string c, as atoi() + // On return, c is set to one past the end of the integer. + static int parseIntAndAdvance(const char*& c) + { + int i = 0; + for(;*c >= '0' && *c <= '9'; ++c) + i = 10*i + (*c - '0'); + return i; + } + + // Format at most truncLen characters of a C string to the given + // stream. Return true if formatting proceeded (generic version always + // returns false) + template + static bool formatCStringTruncate(std::ostream& /*out*/, const T& /*value*/, + std::streamsize /*truncLen*/) + { + return false; + } +# define TINYFORMAT_DEFINE_FORMAT_C_STRING_TRUNCATE(type) \ + static bool formatCStringTruncate(std::ostream& out, type* value, \ + std::streamsize truncLen) \ + { \ + std::streamsize len = 0; \ + while(len < truncLen && value[len] != 0) \ + ++len; \ + out.write(value, len); \ + return true; \ + } + // Overload for const char* and char*. Could overload for signed & + // unsigned char too, but these are technically unneeded for printf + // compatibility. + TINYFORMAT_DEFINE_FORMAT_C_STRING_TRUNCATE(const char) + TINYFORMAT_DEFINE_FORMAT_C_STRING_TRUNCATE(char) +# undef TINYFORMAT_DEFINE_FORMAT_C_STRING_TRUNCATE + + // Print literal part of format string and return next format spec + // position. + // + // Skips over any occurrences of '%%', printing a literal '%' to the + // output. The position of the first % character of the next + // nontrivial format spec is returned, or the end of string. + static const char* printFormatStringLiteral(std::ostream& out, + const char* fmt) + { + const char* c = fmt; + for(; true; ++c) + { + switch(*c) + { + case '\0': + out.write(fmt, static_cast(c - fmt)); + return c; + case '%': + out.write(fmt, static_cast(c - fmt)); + if(*(c+1) != '%') + return c; + // for "%%", tack trailing % onto next literal section. + fmt = ++c; + break; + } + } + } + + static const char* streamStateFromFormat(std::ostream& out, + unsigned int& extraFlags, + const char* fmtStart, + int variableWidth, + int variablePrecision); + + // Private copy & assign: Kill gcc warnings with -Weffc++ + FormatIterator(const FormatIterator&); + FormatIterator& operator=(const FormatIterator&); + + // Stream, current format string & state + std::ostream& m_out; + const char* m_fmt; + unsigned int m_extraFlags; + // State machine info for handling of variable width & precision + bool m_wantWidth; + bool m_wantPrecision; + int m_variableWidth; + int m_variablePrecision; + // Saved stream state + std::streamsize m_origWidth; + std::streamsize m_origPrecision; + std::ios::fmtflags m_origFlags; + char m_origFill; +}; + + +// Accept a value for formatting into the internal stream. +template +TINYFORMAT_NOINLINE // < greatly reduces bloat in optimized builds +void FormatIterator::accept(const T& value) +{ + // Parse the format string + const char* fmtEnd = 0; + if(m_extraFlags == Flag_None && !m_wantWidth && !m_wantPrecision) + { + m_fmt = printFormatStringLiteral(m_out, m_fmt); + fmtEnd = streamStateFromFormat(m_out, m_extraFlags, m_fmt, 0, 0); + m_wantWidth = (m_extraFlags & Flag_VariableWidth) != 0; + m_wantPrecision = (m_extraFlags & Flag_VariablePrecision) != 0; + } + // Consume value as variable width and precision specifier if necessary + if(m_extraFlags & (Flag_VariableWidth | Flag_VariablePrecision)) + { + if(m_wantWidth || m_wantPrecision) + { + int v = convertToInt::invoke(value); + if(m_wantWidth) + { + m_variableWidth = v; + m_wantWidth = false; + } + else if(m_wantPrecision) + { + m_variablePrecision = v; + m_wantPrecision = false; + } + return; + } + // If we get here, we've set both the variable precision and width as + // required and we need to rerun the stream state setup to insert these. + fmtEnd = streamStateFromFormat(m_out, m_extraFlags, m_fmt, + m_variableWidth, m_variablePrecision); + } + + // Format the value into the stream. + if(!(m_extraFlags & (Flag_SpacePadPositive | Flag_TruncateToPrecision))) + formatValue(m_out, m_fmt, fmtEnd, value); + else + { + // The following are special cases where there's no direct + // correspondence between stream formatting and the printf() behaviour. + // Instead, we simulate the behaviour crudely by formatting into a + // temporary string stream and munging the resulting string. + std::ostringstream tmpStream; + tmpStream.copyfmt(m_out); + if(m_extraFlags & Flag_SpacePadPositive) + tmpStream.setf(std::ios::showpos); + // formatCStringTruncate is required for truncating conversions like + // "%.4s" where at most 4 characters of the c-string should be read. + // If we didn't include this special case, we might read off the end. + if(!( (m_extraFlags & Flag_TruncateToPrecision) && + formatCStringTruncate(tmpStream, value, m_out.precision()) )) + { + // Not a truncated c-string; just format normally. + formatValue(tmpStream, m_fmt, fmtEnd, value); + } + std::string result = tmpStream.str(); // allocates... yuck. + if(m_extraFlags & Flag_SpacePadPositive) + { + for(size_t i = 0, iend = result.size(); i < iend; ++i) + if(result[i] == '+') + result[i] = ' '; + } + if((m_extraFlags & Flag_TruncateToPrecision) && + (int)result.size() > (int)m_out.precision()) + m_out.write(result.c_str(), m_out.precision()); + else + m_out << result; + } + m_extraFlags = Flag_None; + m_fmt = fmtEnd; +} + + +// Parse a format string and set the stream state accordingly. +// +// The format mini-language recognized here is meant to be the one from C99, +// with the form "%[flags][width][.precision][length]type". +// +// Formatting options which can't be natively represented using the ostream +// state are returned in the extraFlags parameter which is a bitwise +// combination of values from the ExtraFormatFlags enum. +inline const char* FormatIterator::streamStateFromFormat(std::ostream& out, + unsigned int& extraFlags, + const char* fmtStart, + int variableWidth, + int variablePrecision) +{ + if(*fmtStart != '%') + { + TINYFORMAT_ERROR("tinyformat: Not enough conversion specifiers in format string"); + return fmtStart; + } + // Reset stream state to defaults. + out.width(0); + out.precision(6); + out.fill(' '); + // Reset most flags; ignore irrelevant unitbuf & skipws. + out.unsetf(std::ios::adjustfield | std::ios::basefield | + std::ios::floatfield | std::ios::showbase | std::ios::boolalpha | + std::ios::showpoint | std::ios::showpos | std::ios::uppercase); + extraFlags = Flag_None; + bool precisionSet = false; + bool widthSet = false; + const char* c = fmtStart + 1; + // 1) Parse flags + for(;; ++c) + { + switch(*c) + { + case '#': + out.setf(std::ios::showpoint | std::ios::showbase); + continue; + case '0': + // overridden by left alignment ('-' flag) + if(!(out.flags() & std::ios::left)) + { + // Use internal padding so that numeric values are + // formatted correctly, eg -00010 rather than 000-10 + out.fill('0'); + out.setf(std::ios::internal, std::ios::adjustfield); + } + continue; + case '-': + out.fill(' '); + out.setf(std::ios::left, std::ios::adjustfield); + continue; + case ' ': + // overridden by show positive sign, '+' flag. + if(!(out.flags() & std::ios::showpos)) + extraFlags |= Flag_SpacePadPositive; + continue; + case '+': + out.setf(std::ios::showpos); + extraFlags &= ~Flag_SpacePadPositive; + continue; + } + break; + } + // 2) Parse width + if(*c >= '0' && *c <= '9') + { + widthSet = true; + out.width(parseIntAndAdvance(c)); + } + if(*c == '*') + { + widthSet = true; + if(variableWidth < 0) + { + // negative widths correspond to '-' flag set + out.fill(' '); + out.setf(std::ios::left, std::ios::adjustfield); + variableWidth = -variableWidth; + } + out.width(variableWidth); + extraFlags |= Flag_VariableWidth; + ++c; + } + // 3) Parse precision + if(*c == '.') + { + ++c; + int precision = 0; + if(*c == '*') + { + ++c; + extraFlags |= Flag_VariablePrecision; + precision = variablePrecision; + } + else + { + if(*c >= '0' && *c <= '9') + precision = parseIntAndAdvance(c); + else if(*c == '-') // negative precisions ignored, treated as zero. + parseIntAndAdvance(++c); + } + out.precision(precision); + precisionSet = true; + } + // 4) Ignore any C99 length modifier + while(*c == 'l' || *c == 'h' || *c == 'L' || + *c == 'j' || *c == 'z' || *c == 't') + ++c; + // 5) We're up to the conversion specifier character. + // Set stream flags based on conversion specifier (thanks to the + // boost::format class for forging the way here). + bool intConversion = false; + switch(*c) + { + case 'u': case 'd': case 'i': + out.setf(std::ios::dec, std::ios::basefield); + intConversion = true; + break; + case 'o': + out.setf(std::ios::oct, std::ios::basefield); + intConversion = true; + break; + case 'X': + out.setf(std::ios::uppercase); + case 'x': case 'p': + out.setf(std::ios::hex, std::ios::basefield); + intConversion = true; + break; + case 'E': + out.setf(std::ios::uppercase); + case 'e': + out.setf(std::ios::scientific, std::ios::floatfield); + out.setf(std::ios::dec, std::ios::basefield); + break; + case 'F': + out.setf(std::ios::uppercase); + case 'f': + out.setf(std::ios::fixed, std::ios::floatfield); + break; + case 'G': + out.setf(std::ios::uppercase); + case 'g': + out.setf(std::ios::dec, std::ios::basefield); + // As in boost::format, let stream decide float format. + out.flags(out.flags() & ~std::ios::floatfield); + break; + case 'a': case 'A': + TINYFORMAT_ERROR("tinyformat: the %a and %A conversion specs " + "are not supported"); + break; + case 'c': + // Handled as special case inside formatValue() + break; + case 's': + if(precisionSet) + extraFlags |= Flag_TruncateToPrecision; + // Make %s print booleans as "true" and "false" + out.setf(std::ios::boolalpha); + break; + case 'n': + // Not supported - will cause problems! + TINYFORMAT_ERROR("tinyformat: %n conversion spec not supported"); + break; + case '\0': + TINYFORMAT_ERROR("tinyformat: Conversion spec incorrectly " + "terminated by end of string"); + return c; + } + if(intConversion && precisionSet && !widthSet) + { + // "precision" for integers gives the minimum number of digits (to be + // padded with zeros on the left). This isn't really supported by the + // iostreams, but we can approximately simulate it with the width if + // the width isn't otherwise used. + out.width(out.precision()); + out.setf(std::ios::internal, std::ios::adjustfield); + out.fill('0'); + } + return c+1; +} + + + +//------------------------------------------------------------------------------ +// Private format function on top of which the public interface is implemented. +// We enforce a mimimum of one value to be formatted to prevent bugs looking like +// +// const char* myStr = "100% broken"; +// printf(myStr); // Parses % as a format specifier +#ifdef TINYFORMAT_USE_VARIADIC_TEMPLATES + +template +void format(FormatIterator& fmtIter, const T1& value1) +{ + fmtIter.accept(value1); + fmtIter.finish(); +} + +// General version for C++11 +template +void format(FormatIterator& fmtIter, const T1& value1, const Args&... args) +{ + fmtIter.accept(value1); + format(fmtIter, args...); +} + +#else + +inline void format(FormatIterator& fmtIter) +{ + fmtIter.finish(); +} + +// General version for C++98 +#define TINYFORMAT_MAKE_FORMAT_DETAIL(n) \ +template \ +void format(detail::FormatIterator& fmtIter, TINYFORMAT_VARARGS(n)) \ +{ \ + fmtIter.accept(v1); \ + format(fmtIter TINYFORMAT_PASSARGS_TAIL(n)); \ +} + +TINYFORMAT_FOREACH_ARGNUM(TINYFORMAT_MAKE_FORMAT_DETAIL) +#undef TINYFORMAT_MAKE_FORMAT_DETAIL + +#endif // End C++98 variadic template emulation for format() + +} // namespace detail + + +//------------------------------------------------------------------------------ +// Implement all the main interface functions here in terms of detail::format() + +#ifdef TINYFORMAT_USE_VARIADIC_TEMPLATES + +// C++11 - the simple case +template +void format(std::ostream& out, const char* fmt, const T1& v1, const Args&... args) +{ + detail::FormatIterator fmtIter(out, fmt); + format(fmtIter, v1, args...); +} + +template +std::string format(const char* fmt, const T1& v1, const Args&... args) +{ + std::ostringstream oss; + format(oss, fmt, v1, args...); + return oss.str(); +} + +template +std::string format(const std::string &fmt, const T1& v1, const Args&... args) +{ + std::ostringstream oss; + format(oss, fmt.c_str(), v1, args...); + return oss.str(); +} + +template +void printf(const char* fmt, const T1& v1, const Args&... args) +{ + format(std::cout, fmt, v1, args...); +} + +#else + +// C++98 - define the interface functions using the wrapping macros +#define TINYFORMAT_MAKE_FORMAT_FUNCS(n) \ + \ +template \ +void format(std::ostream& out, const char* fmt, TINYFORMAT_VARARGS(n)) \ +{ \ + tinyformat::detail::FormatIterator fmtIter(out, fmt); \ + tinyformat::detail::format(fmtIter, TINYFORMAT_PASSARGS(n)); \ +} \ + \ +template \ +std::string format(const char* fmt, TINYFORMAT_VARARGS(n)) \ +{ \ + std::ostringstream oss; \ + tinyformat::format(oss, fmt, TINYFORMAT_PASSARGS(n)); \ + return oss.str(); \ +} \ + \ +template \ +std::string format(const std::string &fmt, TINYFORMAT_VARARGS(n)) \ +{ \ + std::ostringstream oss; \ + tinyformat::format(oss, fmt.c_str(), TINYFORMAT_PASSARGS(n)); \ + return oss.str(); \ +} \ + \ +template \ +void printf(const char* fmt, TINYFORMAT_VARARGS(n)) \ +{ \ + tinyformat::format(std::cout, fmt, TINYFORMAT_PASSARGS(n)); \ +} + +TINYFORMAT_FOREACH_ARGNUM(TINYFORMAT_MAKE_FORMAT_FUNCS) +#undef TINYFORMAT_MAKE_FORMAT_FUNCS +#endif + + +//------------------------------------------------------------------------------ +// Define deprecated wrapping macro for backward compatibility in tinyformat +// 1.x. Will be removed in version 2! +#define TINYFORMAT_WRAP_FORMAT_EXTRA_ARGS +#define TINYFORMAT_WRAP_FORMAT_N(n, returnType, funcName, funcDeclSuffix, \ + bodyPrefix, streamName, bodySuffix) \ +template \ +returnType funcName(TINYFORMAT_WRAP_FORMAT_EXTRA_ARGS const char* fmt, \ + TINYFORMAT_VARARGS(n)) funcDeclSuffix \ +{ \ + bodyPrefix \ + tinyformat::format(streamName, fmt, TINYFORMAT_PASSARGS(n)); \ + bodySuffix \ +} \ + +#define TINYFORMAT_WRAP_FORMAT(returnType, funcName, funcDeclSuffix, \ + bodyPrefix, streamName, bodySuffix) \ +inline \ +returnType funcName(TINYFORMAT_WRAP_FORMAT_EXTRA_ARGS const char* fmt \ + ) funcDeclSuffix \ +{ \ + bodyPrefix \ + tinyformat::detail::FormatIterator(streamName, fmt).finish(); \ + bodySuffix \ +} \ +TINYFORMAT_WRAP_FORMAT_N(1 , returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(2 , returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(3 , returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(4 , returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(5 , returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(6 , returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(7 , returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(8 , returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(9 , returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(10, returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(11, returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(12, returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(13, returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(14, returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(15, returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ +TINYFORMAT_WRAP_FORMAT_N(16, returnType, funcName, funcDeclSuffix, bodyPrefix, streamName, bodySuffix) \ + + +} // namespace tinyformat + +#define strprintf tfm::format + +#endif // TINYFORMAT_H_INCLUDED diff --git a/src/uint256.h b/src/uint256.h index f3f0661f1..e885c2767 100644 --- a/src/uint256.h +++ b/src/uint256.h @@ -345,6 +345,14 @@ class base_uint return (GetHex()); } + std::string ToStringReverseEndian() const + { + char psz[sizeof(pn) * 2 + 1]; + for (unsigned int i = 0; i < sizeof(pn); i++) + sprintf(psz + i * 2, "%02x", ((unsigned char*)pn)[i]); + return std::string(psz, psz + sizeof(pn) * 2); + } + unsigned char* begin() { return (unsigned char*)&pn[0]; diff --git a/src/util.cpp b/src/util.cpp index ebeadbd00..1df7b141f 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -5,10 +5,11 @@ #include "util.h" #include "sync.h" -#include "strlcpy.h" #include "version.h" #include "ui_interface.h" #include +#include // for to_lower() +#include // for startswith() and endswith() // Work around clang compilation problem in Boost 1.46: // /usr/include/boost/program_options/detail/config_file.hpp:163:17: error: call to function 'to_internal' that is neither visible in the template definition nor found by argument-dependent lookup @@ -290,7 +291,7 @@ string vstrprintf(const char *format, va_list ap) char* p = buffer; int limit = sizeof(buffer); int ret; - loop + while (true) { va_list arg_ptr; va_copy(arg_ptr, ap); @@ -350,7 +351,7 @@ void ParseString(const string& str, char c, vector& v) return; string::size_type i1 = 0; string::size_type i2; - loop + while (true) { i2 = str.find(c, i1); if (i2 == str.npos) @@ -371,7 +372,7 @@ string FormatMoney(int64 n, bool fPlus) int64 n_abs = (n > 0 ? n : -n); int64 quotient = n_abs/COIN; int64 remainder = n_abs%COIN; - string str = strprintf("%"PRI64d".%06"PRI64d, quotient, remainder); + string str = strprintf("%lld.%06lld", quotient, remainder); // Right-trim excess zeros before the decimal point: int nTrim = 0; @@ -490,7 +491,8 @@ long hex2long(const char* hexString) while (*hexString && ret >= 0) { - ret = (ret << 4) | hextable[*hexString++]; + int index = *hexString++; + ret = (ret << 4) | hextable[index]; } return ret; @@ -512,7 +514,7 @@ vector ParseHex(const char* psz) { // convert hex dump to vector vector vch; - loop + while (true) { while (isspace(*psz)) psz++; @@ -555,24 +557,24 @@ void ParseParameters(int argc, const char* const argv[]) mapMultiArgs.clear(); for (int i = 1; i < argc; i++) { - char psz[10000]; - strlcpy(psz, argv[i], sizeof(psz)); - char* pszValue = (char*)""; - if (strchr(psz, '=')) + std::string str(argv[i]); + std::string strValue; + size_t is_index = str.find('='); + if (is_index != std::string::npos) { - pszValue = strchr(psz, '='); - *pszValue++ = '\0'; + strValue = str.substr(is_index+1); + str = str.substr(0, is_index); } - #ifdef WIN32 - _strlwr(psz); - if (psz[0] == '/') - psz[0] = '-'; - #endif - if (psz[0] != '-') +#ifdef WIN32 + boost::to_lower(str); + if (boost::algorithm::starts_with(str, "/")) + str = "-" + str.substr(1); +#endif + if (str[0] != '-') break; - mapArgs[psz] = pszValue; - mapMultiArgs[psz].push_back(pszValue); + mapArgs[str] = strValue; + mapMultiArgs[str].push_back(strValue); } // New 0.6 features: @@ -966,7 +968,7 @@ string DecodeBase32(const string& str) bool WildcardMatch(const char* psz, const char* mask) { - loop + while (true) { switch (*mask) { @@ -1010,10 +1012,10 @@ static std::string FormatException(std::exception* pex, const char* pszThread) #endif if (pex) return strprintf( - "ETRKEPTION: %s \n%s \n%s in %s \n", typeid(*pex).name(), pex->what(), pszModule, pszThread); + "EXCEPTION: %s \n%s \n%s in %s \n", typeid(*pex).name(), pex->what(), pszModule, pszThread); else return strprintf( - "UNKNOWN ETRKEPTION \n%s in %s \n", pszModule, pszThread); + "UNKNOWN EXCEPTION \n%s in %s \n", pszModule, pszThread); } void LogException(std::exception* pex, const char* pszThread) @@ -1263,7 +1265,7 @@ void AddTimeData(const CNetAddr& ip, int64 nTime) // Add data vTimeOffsets.input(nOffsetSample); - printf("Added time data, samples %d, offset %+"PRI64d" (%+"PRI64d" minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60); + printf("Added time data, samples %d, offset %+lld (%+lld minutes)\n", vTimeOffsets.size(), nOffsetSample, nOffsetSample/60); if (vTimeOffsets.size() >= 5 && vTimeOffsets.size() % 2 == 1) { int64 nMedian = vTimeOffsets.median(); @@ -1298,45 +1300,14 @@ void AddTimeData(const CNetAddr& ip, int64 nTime) } if (fDebug) { BOOST_FOREACH(int64 n, vSorted) - printf("%+"PRI64d" ", n); + printf("%+lld ", n); printf("| "); } - printf("nTimeOffset = %+"PRI64d" (%+"PRI64d" minutes)\n", nTimeOffset, nTimeOffset/60); + printf("nTimeOffset = %+lld (%+lld minutes)\n", nTimeOffset, nTimeOffset/60); } } - - - - - - -string FormatVersion(int nVersion) -{ - if (nVersion%100 == 0) - return strprintf("%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100); - else - return strprintf("%d.%d.%d.%d", nVersion/1000000, (nVersion/10000)%100, (nVersion/100)%100, nVersion%100); -} - -string FormatFullVersion() -{ - return CLIENT_BUILD; -} - -// Format the subversion field according to BIP 14 spec (https://en.bitcoin.it/wiki/BIP_0014) -std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector& comments) -{ - std::ostringstream ss; - ss << "/"; - ss << name << ":" << FormatVersion(nClientVersion); - if (!comments.empty()) - ss << "(" << boost::algorithm::join(comments, "; ") << ")"; - ss << "/"; - return ss.str(); -} - #ifdef WIN32 boost::filesystem::path GetSpecialFolderPath(int nFolder, bool fCreate) { diff --git a/src/util.h b/src/util.h index 609c32de7..3d7888e62 100644 --- a/src/util.h +++ b/src/util.h @@ -35,7 +35,7 @@ typedef unsigned long long uint64; static const int64 COIN = 1000000; static const int64 CENT = 10000; -#define loop for (;;) +//#define loop for (;;) #define BEGIN(a) ((char*)&(a)) #define END(a) ((char*)&((&(a))[1])) #define UBEGIN(a) ((unsigned char*)&(a)) @@ -107,7 +107,6 @@ T* alignup(T* p) } #ifdef WIN32 -#define MSG_NOSIGNAL 0 #define MSG_DONTWAIT 0 #ifndef S_IRUSR @@ -229,8 +228,6 @@ int64 GetTime(); void SetMockTime(int64 nMockTimeIn); int64 GetAdjustedTime(); long hex2long(const char* hexString); -std::string FormatFullVersion(); -std::string FormatSubVersion(const std::string& name, int nClientVersion, const std::vector& comments); void AddTimeData(const CNetAddr& ip, int64 nTime); void runCommand(std::string strCommand); @@ -244,7 +241,7 @@ void runCommand(std::string strCommand); inline std::string i64tostr(int64 n) { - return strprintf("%"PRI64d, n); + return strprintf("%lld", n); } inline std::string itostr(int n) @@ -309,11 +306,30 @@ std::string HexStr(const T itbegin, const T itend, bool fSpaces=false) return rv; } +template +inline std::string HexStr(const T& vch, bool fSpaces = false) +{ + return HexStr(vch.begin(), vch.end(), fSpaces); +} + inline std::string HexStr(const std::vector& vch, bool fSpaces=false) { return HexStr(vch.begin(), vch.end(), fSpaces); } +/** Reverse the endianess of a string */ +inline std::string ReverseEndianString(std::string in) +{ + std::string out = ""; + unsigned int s = in.size(); + for(unsigned int i = 0; i < s; i+=2) + { + out += in.substr(s - i - 2, 2); + } + + return out; +} + template void PrintHex(const T pbegin, const T pend, const char* pszFormat="%s", bool fSpaces=true) { diff --git a/src/version.cpp b/src/version.cpp index 58f323260..5a87f1b3a 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -5,13 +5,8 @@ #include "version.h" -// Name of client reported in the 'version' message. Report the same name -// for both bitcoind and bitcoin-qt, to make it harder for attackers to -// target servers or GUI users specifically. -const std::string CLIENT_NAME("HyperStake"); - // Client version number -#define CLIENT_VERSION_SUFFIX "HyperStake-1.0.3" +#define CLIENT_VERSION_SUFFIX "HyperStake-1.1.5.0" // The following part of the code determines the CLIENT_BUILD variable. @@ -28,11 +23,6 @@ const std::string CLIENT_NAME("HyperStake"); // * otherwise, use v[maj].[min].[rev].[build]-unk // finally CLIENT_VERSION_SUFFIX is added -// First, include build.h if requested -#ifdef HAVE_BUILD_INFO -# include "build.h" -#endif - // git will put "#define GIT_ARCHIVE 1" on the next line inside archives. #define GIT_ARCHIVE 1 #ifdef GIT_ARCHIVE @@ -61,6 +51,3 @@ const std::string CLIENT_NAME("HyperStake"); # define BUILD_DATE __DATE__ ", " __TIME__ # endif #endif - -const std::string CLIENT_BUILD(BUILD_DESC CLIENT_VERSION_SUFFIX); -const std::string CLIENT_DATE(BUILD_DATE); diff --git a/src/version.h b/src/version.h index d15458767..5029ead68 100644 --- a/src/version.h +++ b/src/version.h @@ -7,25 +7,12 @@ #include "clientversion.h" #include -// -// client versioning -// - -static const int CLIENT_VERSION = - 1000000 * CLIENT_VERSION_MAJOR - + 10000 * CLIENT_VERSION_MINOR - + 100 * CLIENT_VERSION_REVISION - + 1 * CLIENT_VERSION_BUILD; - -extern const std::string CLIENT_NAME; -extern const std::string CLIENT_BUILD; -extern const std::string CLIENT_DATE; - // // network protocol versioning // -static const int PROTOCOL_VERSION = 72000; +static const int PROTOCOL_VERSION = 72001; +static const int PROTOCOL_START = 71990; // earlier versions not supported as of Feb 2012, and are disconnected static const int MIN_PROTO_VERSION = 209; @@ -35,7 +22,7 @@ static const int MIN_PROTO_VERSION = 209; static const int CADDR_TIME_VERSION = 31402; // only request blocks from nodes outside this range of versions -static const int NOBLKS_VERSION_START = 60002; +static const int NOBLKS_VERSION_START = 70000; static const int NOBLKS_VERSION_END = 71999; // BIP 0031, pong message, is enabled for all versions AFTER this one @@ -45,8 +32,8 @@ static const int BIP0031_VERSION = 60000; static const int MEMPOOL_GD_VERSION = 60002; #define DISPLAY_VERSION_MAJOR 1 -#define DISPLAY_VERSION_MINOR 0 -#define DISPLAY_VERSION_REVISION 3 -#define DISPLAY_VERSION_BUILD 0 +#define DISPLAY_VERSION_MINOR 1 +#define DISPLAY_VERSION_REVISION 5 +#define DISPLAY_VERSION_BUILD 1 #endif diff --git a/src/votecharset.cpp b/src/votecharset.cpp new file mode 100644 index 000000000..7a35768fc --- /dev/null +++ b/src/votecharset.cpp @@ -0,0 +1,58 @@ +#include +#include + +#include "votecharset.h" +#include "uint256.h" +#include "script.h" + +static const std::string strCharCodes = "0123456789abdefghijklmnopqrstuvwxyz ,.?!"; + +//first 8 bits - uint8_t with character count +bool ConvertTo6bit(std::string strFromUser, std::vector& vchRet) +{ + std::transform(strFromUser.begin(), strFromUser.end(), strFromUser.begin(), ::tolower); + uint160 v = 0; + for (unsigned int i = 0; i < strFromUser.size(); i++) { + char c = strFromUser[i]; + std::cout << "first in: " << c << std::endl; + uint160 pos = strCharCodes.find(c); + if (pos != std::string::npos) { + v >>= 6; + v |= pos << 154; + } + else + return false; + } + + v >>= 8; + uint160 nSize = strFromUser.size(); + nSize <<= 152; + v |= nSize; + + vchRet = ToByteVector(v); + return true; +} + +bool ConvertTo8bit(std::vector vch, std::string& strRet) +{ + uint160 n = 0; + for (unsigned int i = 0; i < vch.size(); i++) { + n >>= 8; + n |= uint160(vch[i]) << 154; + } + + uint160 mask = 0x3f; + mask <<= 154; + uint160 nSize = n >> 152; + std::cout << "size: " << nSize.Get64() << std::endl; + for (int i = 0; i < nSize; i++) { + uint160 j = n & mask; + n >>= 6; + std::cout << "j: " << j.Get64() << std::endl; + char c = strCharCodes.at(j.Get64()); + std::cout << "letter: " << c << std::endl; + strRet += c; + } + + return true; +} diff --git a/src/votecharset.h b/src/votecharset.h new file mode 100644 index 000000000..a814f47de --- /dev/null +++ b/src/votecharset.h @@ -0,0 +1,5 @@ +#include +#include + +bool ConvertTo6bit(std::string strFromUser, std::vector& vchRet); +bool ConvertTo8bit(std::vector vch, std::string& strRet); \ No newline at end of file diff --git a/src/voteobject.cpp b/src/voteobject.cpp new file mode 100644 index 000000000..c8c044fea --- /dev/null +++ b/src/voteobject.cpp @@ -0,0 +1,24 @@ +// Copyright (c) 2017 The HyperStake Developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include "voteobject.h" +#include "main.h" + +using namespace std; + +int CVoteObject::GetCombinedVotes(const std::vector& votes) { + int nCombinedVotes = 0; + + for(CVoteObject vote: votes){ + nCombinedVotes |= vote.GetFormattedVote(); + } + + return nCombinedVotes; +} + +bool CVoteObject::Vote(int nVotersChoice) +{ + nChoice = static_cast(nVotersChoice); + return true; +} + diff --git a/src/voteobject.h b/src/voteobject.h new file mode 100644 index 000000000..26a4465a3 --- /dev/null +++ b/src/voteobject.h @@ -0,0 +1,96 @@ +// Copyright (c) 2017 The HyperStake Developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. +#ifndef HYPERSTAKE_VOTEOBJECT_H +#define HYPERSTAKE_VOTEOBJECT_H + +#include "serialize.h" +#include "uint256.h" + +class VoteLocation +{ +public: + //bit positions increase from right to left, starting at position 0 + uint8_t nMostSignificantBit; + uint8_t nLeastSignificantBit; + + void SetNull() + { + nMostSignificantBit = 0; + nLeastSignificantBit = 0; + } + + VoteLocation(){ + SetNull(); + } + + VoteLocation(uint8_t nMostSignificantBit, uint8_t nLeastSignificantBit) + { + this->nMostSignificantBit = nMostSignificantBit; + this->nLeastSignificantBit = nLeastSignificantBit; + } + + IMPLEMENT_SERIALIZE + ( + READWRITE(nMostSignificantBit); + READWRITE(nLeastSignificantBit); + ) + + uint8_t GetBitCount() const { return (uint8_t)(nMostSignificantBit - nLeastSignificantBit + 1); } + uint8_t GetShift() const { return nLeastSignificantBit; } +}; + +class CVoteObject +{ +private: + uint32_t nChoice; + uint32_t nFormattedVote; + bool fVoted; + uint256 hashProposal; + VoteLocation bitLocation; +public: + + static int GetCombinedVotes(const std::vector& votes); + + void SetNull() + { + nChoice = 0; + nFormattedVote = 0; + fVoted = false; + hashProposal = 0; + } + + bool IsNull () { return hashProposal == 0; } + + CVoteObject() + { + SetNull(); + } + + CVoteObject(uint256 hashProposal, VoteLocation location) + { + SetNull(); + this->hashProposal = hashProposal; + this->bitLocation = location; + } + + IMPLEMENT_SERIALIZE + ( + READWRITE(nChoice); + READWRITE(nFormattedVote); + READWRITE(fVoted); + READWRITE(hashProposal); + READWRITE(bitLocation); + ) + + bool Vote(int nVotersChoice); + + //The vote value shifted to the position of the proposal, use staking a vote + uint32_t GetFormattedVote() { return (nChoice << bitLocation.GetShift()); } + + //The unshifted vote value defined in ProcessVote + //POTENTIAL TODO: create enum to represent choice + uint32_t GetUnformattedVote() { return nChoice; } +}; + +#endif //HYPERSTAKE_VOTEOBJECT_H diff --git a/src/voteproposal.cpp b/src/voteproposal.cpp new file mode 100644 index 000000000..6ff2e2ee0 --- /dev/null +++ b/src/voteproposal.cpp @@ -0,0 +1,76 @@ +// Copyright (c) 2017 The HyperStake Developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "voteproposal.h" + +using namespace std; + +uint256 CVoteProposal::GetHash() const +{ + return SerializeHash(*this); +} + +/** +* The vote proposal is serialized and added to a CTransaction as a data object via OP_RETURN transaction output. +* The transaction is marked as a proposal by marking the first 4 bytes as "PROP" in ASCII +*/ +bool CVoteProposal::ConstructTransaction (CTransaction& tx) const +{ +// if (tx.vin.empty()) { +// printf("%s : transaction does not have any inputs!\n", __func__); +// return false; +// } + + if (IsNull()) { + printf("%s : vote proposal is null!\n", __func__); + return false; + } + + //serialize the vote proposal + CDataStream serializedProposal(SER_NETWORK, 0); + serializedProposal << *this; + + //Construct the script that will include the serialized proposal + CScript scriptProposal; + vector vchMessage; + vchMessage.push_back(0x70); // P + vchMessage.push_back(0x72); // R + vchMessage.push_back(0x6f); // O + vchMessage.push_back(0x70); // P + vchMessage.insert(vchMessage.end(), serializedProposal.begin(), serializedProposal.end()); + scriptProposal << OP_RETURN << vchMessage; + + //Create txout and add it to the transaction + CTxOut out; + out.scriptPubKey = scriptProposal; + out.nValue = 0; + tx.vout.push_back(out); + + if (tx.GetSerializeSize(SER_NETWORK, PROTOCOL_VERSION) > MAX_BLOCK_SIZE) { + printf("%s : transaction size is too large!\n", __func__); + return false; + } + + return true; +} + +bool ProposalFromTransaction(const CTransaction& tx, CVoteProposal& proposal) +{ + if (!tx.IsProposal()) + return error("%s : tx is not a proposal", __func__); + + vector vchProposal; + + CScript scriptProposal = tx.vout[0].scriptPubKey; + vchProposal.insert(vchProposal.end(), scriptProposal.begin() + 6, scriptProposal.end()); + CDataStream ss(vchProposal, SER_NETWORK, 0); + + try { + ss >> proposal; + } catch(std::exception& e) { + return error("%s: failed to deserialize: %s ", __func__, e.what()); + } + + return true; +} \ No newline at end of file diff --git a/src/voteproposal.h b/src/voteproposal.h new file mode 100644 index 000000000..88c575f28 --- /dev/null +++ b/src/voteproposal.h @@ -0,0 +1,97 @@ +// Copyright (c) 2017 The HyperStake Developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef VOTEPROPOSAL_H +#define VOTEPROPOSAL_H + +#include +#include "main.h" +#include "serialize.h" +#include "votetally.h" +#include "voteobject.h" + +#define MAX_CHAR_NAME 10 +#define MAX_CHAR_ABSTRACT 30 +#define MAX_BLOCKS_IN_FUTURE 28800 +#define MAX_CHECKSPAN 28800 + +//TODO: update +#define MOST_RECENT_VERSION 1 + +class CVoteProposal +{ +private: + // proposal version + int nVersion; + + // what to call the proposal + std::string strName; + + // where in the blockchain we start counting votes, nStartHeight + unsigned int nStartHeight; + + // how far in the blockchain are we scanning + unsigned int nCheckSpan; + + // the position of the proposal in the nVersion field + VoteLocation bitLocation; + + // description of the proposal; may link to additional transactions + std::string strDescription; +public: + // the amount of HYP burnt when a proposal is made + static const int64 FEE = 5 * COIN; + + void SetNull() + { + nVersion = 0; + strName = ""; + nStartHeight = 0; + nCheckSpan = 0; + strDescription = ""; + } + + bool IsNull () const { return strName.empty(); } + + CVoteProposal() + { + SetNull(); + } + + CVoteProposal(std::string strName, unsigned int nStartHeight, unsigned int nCheckSpan, std::string strDescription, + VoteLocation location, int nVersion = MOST_RECENT_VERSION) + { + this->nVersion = nVersion; + this->strName = strName; + this->nStartHeight = nStartHeight; + this->nCheckSpan = nCheckSpan; + this->strDescription = strDescription; + this->bitLocation = location; + } + + IMPLEMENT_SERIALIZE + ( + READWRITE(nVersion); + READWRITE(strName); + READWRITE(nStartHeight); + READWRITE(nCheckSpan); + READWRITE(strDescription); + READWRITE(bitLocation); + ) + + bool ConstructTransaction (CTransaction& tx) const; + int GetShift() const { return bitLocation.GetShift(); } + uint8_t GetBitCount() const { return bitLocation.GetBitCount(); } + unsigned int GetCheckSpan() const { return nCheckSpan; } + std::string GetName() const { return strName; } + std::string GetDescription() const { return strDescription; } + unsigned int GetStartHeight() const { return nStartHeight; } + VoteLocation GetLocation() const { return bitLocation; } + uint256 GetHash() const; + +}; + +bool ProposalFromTransaction(const CTransaction& tx, CVoteProposal& proposal); + +#endif //HYPERSTAKE_VOTEPROPOSAL_H diff --git a/src/voteproposalmanager.cpp b/src/voteproposalmanager.cpp new file mode 100644 index 000000000..d06360f7f --- /dev/null +++ b/src/voteproposalmanager.cpp @@ -0,0 +1,259 @@ +// Copyright (c) 2017 The HyperStake Developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include "voteproposalmanager.h" +#include "voteproposal.h" + +using namespace std; + +bool CVoteProposalManager::CheckProposal(const CVoteProposal &proposal) +{ + // If the proposal is already in the blockchain then it's guaranteed to be valid + if (mapProposalData.count(proposal.GetHash()) != 0) { + return true; + } + + // Proposal name length must be between 1 and MAX_CHAR_NAME (inclusive) + if (proposal.GetName().empty() || proposal.GetName().size() > MAX_CHAR_NAME) { + return false; + } + + // Proposal description length must be between 1 and MAX_CHAR_ABSTRACT (inclusive) + if (proposal.GetDescription().empty() || proposal.GetDescription().size() > MAX_CHAR_ABSTRACT) { + return false; + } + + // Proposal voting period cannot start before or at the current height or after MAX_BLOCKS_IN_FUTURE + if (proposal.GetStartHeight() <= nBestHeight || proposal.GetStartHeight() > nBestHeight + MAX_BLOCKS_IN_FUTURE) { + return false; + } + + // Proposal voting period length must be between 1 and MAX_CHECKSPAN (inclusive) + if (!proposal.GetCheckSpan() || proposal.GetCheckSpan() > MAX_CHECKSPAN) { + return false; + } + + // Check to see if there is room on the blockchain for this proposal + VoteLocation location; + if (!GetNextLocation(proposal.GetBitCount(), proposal.GetStartHeight(), proposal.GetCheckSpan(), location)) { + return false; + } + + return true; +} + +//! Add a proposal to the manager. Note that it must not have conflicts in its scheduling. +bool CVoteProposalManager::Add(const CVoteProposal& proposal) +{ + CProposalMetaData newProposal; + newProposal.location = proposal.GetLocation(); + newProposal.hash = proposal.GetHash(); + newProposal.nHeightStart = proposal.GetStartHeight(); + newProposal.nHeightEnd = newProposal.nHeightStart + proposal.GetCheckSpan(); + + //Check if any of the existing proposals are using the same bits during the same time + for (auto it : mapProposalData) { + CProposalMetaData existingProposal = it.second; + //Clear of any conflicts, starts after the existing proposal ends + if (newProposal.location.nMostSignificantBit < existingProposal.location.nLeastSignificantBit) + continue; + //Clear of any conflicts, ends before the existing proposal starts + if (newProposal.location.nLeastSignificantBit > existingProposal.location.nMostSignificantBit) + continue; + //Clear of any conflicts, there is not overlap in the voting period + if (newProposal.nHeightStart > existingProposal.nHeightEnd || newProposal.nHeightEnd < existingProposal.nHeightStart) + continue; + + return error("%s: Proposal position is already occupied during the block span requested", __func__); + } + + mapProposalData.insert(make_pair(newProposal.hash, newProposal)); + printf("%s: added proposal %s\n", __func__, newProposal.hash.GetHex().c_str()); + return true; +} + +//! Remove a proposal from the proposal manager +void CVoteProposalManager::Remove(const uint256& hashProposal) +{ + auto it = mapProposalData.find(hashProposal); + if (it != mapProposalData.end()) + mapProposalData.erase(it); +} + +//! Get proposals that are actively being voted on +map CVoteProposalManager::GetActive(int nHeight) +{ + map mapActive; + for (auto it : mapProposalData) { + CProposalMetaData data = it.second; + if ((int)data.nHeightStart <= nHeight && (int)data.nHeightEnd >= nHeight) + mapActive.insert(make_pair(data.hash, data.location)); + } + + return mapActive; +} + +namespace +{ + //An Event is either the beginning or end of a vote proposal span. + //This struct is used for GetMaxOverlap + struct Event + { + bool start; + int position; + int bitCount; + + //default constructor + Event() {} + + Event(bool start, int position, int bitCount = 0) + { + this->start = start; + this->position = position; + this->bitCount = bitCount; + } + + static bool Compare(const Event& lhs, const Event& rhs) + { + return lhs.position < rhs.position; + } + }; + + //returns the maximum number of proposals overlapping at any point within the given range + unsigned int GetMaxOverlap(const vector& vProposals, const unsigned int& nStart, const unsigned int& nEnd) + { + int nMaxOverlapQuantity = -1; + vector vEvents(2 * vProposals.size()); + for(auto proposalData: vProposals) { + if(proposalData.nHeightEnd < nStart) continue; + if(proposalData.nHeightStart > nEnd) continue; + vEvents.emplace_back(Event(true, proposalData.nHeightStart)); + vEvents.emplace_back(Event(false, proposalData.nHeightEnd)); + } + + // sort the events in order of time (defined by Compare method in Event struct + sort(vEvents.begin(), vEvents.end(), Event::Compare); + + // iterate through all events and keep track of overlapping intervals + int nCurValueCounter = 0; + for(Event event: vEvents) { + nCurValueCounter += event.start ? 1 : -1; + nMaxOverlapQuantity = max(nMaxOverlapQuantity, nCurValueCounter); + } + + // return the maximum number of overlapping intervals contained in vProposals at any point in time + return (unsigned int)nMaxOverlapQuantity; + } + + // return a deterministic 64 bit integer that represents the resource usage of a given proposal + long GetResourceUsageHeuristic(const vector& vProposals, const CVoteProposal& proposal) + { + long nHeuristic = 0; + int nStart = proposal.GetStartHeight(); + int nEnd = proposal.GetStartHeight() + proposal.GetCheckSpan(); + + // An event is defined as either a proposal interval start or a proposal interval ending. + vector vEvents(2 * vProposals.size()); + + // For each proposal in vProposals that overlaps with the given proposal, create a start and end event then + // add it to vEvents. This vector will be used to determine the number of overlapping voting intervals efficiently. + for(auto proposalData: vProposals) { + if(proposalData.nHeightEnd < nStart) continue; + if(proposalData.nHeightStart > nEnd) continue; + + Event startEvent(true, proposalData.nHeightStart, proposalData.location.GetBitCount()); + Event endEvent(false, proposalData.nHeightEnd + 1, proposalData.location.GetBitCount()); + + vEvents.emplace_back(startEvent); + vEvents.emplace_back(endEvent); + } + + // sort the events so that those that happen earlier appear first in the vector + sort(vEvents.begin(), vEvents.end(), Event::Compare); + + // iterate through events in sorted order and keep a running counter of how many bits are consumed + int nCurValueCounter = 0; + for(unsigned int i = 0; i < vEvents.size() - 1; i++) { + Event curEvent = vEvents.at(i); + Event nextEvent = vEvents.at(i + 1); + + nCurValueCounter += curEvent.start ? curEvent.bitCount : -1 * curEvent.bitCount; + + // only start the counter when we have entered the voting intervals of the given proposal + if(nextEvent.position <= nStart) continue; + if(curEvent.position > nEnd) break; + + // the number of bits used is guaranteed to be constant for every block between these two events + int gap = min(nEnd, nextEvent.position) - max(nStart, curEvent.position); + + // TODO: heuristic updated; this is subject to change + nHeuristic += (100000 * ((long) proposal.GetBitCount())) / (28 - nCurValueCounter) * gap; + } + + return nHeuristic; + } + + //returns a vector of proposals that overlap with the given range + vector GetOverlappingProposals(const map& mapProposalData, + const int& nStart, const int& nEnd) + { + vector vConflictingTime; + for (auto it : mapProposalData) { + CProposalMetaData data = it.second; + if ((int)data.nHeightEnd < nStart) + continue; + if ((int)data.nHeightStart > nEnd) + continue; + vConflictingTime.emplace_back(data); + } + + return vConflictingTime; + } +} + +bool CVoteProposalManager::GetNextLocation(int nBitCount, int nStartHeight, int nCheckSpan, VoteLocation& location) +{ + //Conflicts for block range + vector vConflictingTime; + for (auto it : mapProposalData) { + CProposalMetaData data = it.second; + int nEndHeight = nStartHeight + nCheckSpan; + if ((int)data.nHeightEnd < nStartHeight) + continue; + if ((int)data.nHeightStart > nEndHeight) + continue; + vConflictingTime.emplace_back(data); + } + + //Find an open location for the new proposal, return left most bits + if (vConflictingTime.empty()) { + location.nMostSignificantBit = 27; + location.nLeastSignificantBit = (uint8_t)(location.nMostSignificantBit - nBitCount + 1); + return true; + } + + //create a vector tracking available spots + vector vAvailable(28, 1); + + //remove spots that are already taken + for (auto data : vConflictingTime) { + for (int i = data.location.nMostSignificantBit; i >= data.location.nLeastSignificantBit; i--) { + vAvailable.at(i) = 0; + } + } + + //find an available sequence of bits that fit the proposal + vector vRange; + int nSequential = 0; + for (int i = 27; i >= 0; i--) { + uint8_t n = static_cast(i); + nSequential = vAvailable.at(n) == 1 ? nSequential + 1 : 0; + if (nSequential == nBitCount) { + location.nLeastSignificantBit = n; + location.nMostSignificantBit = static_cast(n + nBitCount - 1); + return true; + } + } + return false; +} \ No newline at end of file diff --git a/src/voteproposalmanager.h b/src/voteproposalmanager.h new file mode 100644 index 000000000..99d92b1ab --- /dev/null +++ b/src/voteproposalmanager.h @@ -0,0 +1,34 @@ +// Copyright (c) 2017 The HyperStake Developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef HYPERSTAKE_VOTEPROPOSALMANAGER_H +#define HYPERSTAKE_VOTEPROPOSALMANAGER_H + +#include +#include "voteobject.h" + +class CVoteProposal; + +struct CProposalMetaData +{ + uint256 hash; + VoteLocation location; + unsigned int nHeightStart; + unsigned int nHeightEnd; +}; + +class CVoteProposalManager +{ +private: + std::map mapProposalData; +public: + bool Add(const CVoteProposal& proposal); + void Remove(const uint256& hashProposal); + std::map GetActive(int nHeight); + bool GetNextLocation(int nBitCount, int nStartHeight, int nCheckSpan, VoteLocation& location); + std::map GetAllProposals() const { return mapProposalData; }; + bool CheckProposal (const CVoteProposal& proposal); +}; + +#endif //HYPERSTAKE_VOTEPROPOSALMANAGER_H diff --git a/src/votetally.cpp b/src/votetally.cpp new file mode 100644 index 000000000..af2a52609 --- /dev/null +++ b/src/votetally.cpp @@ -0,0 +1,113 @@ +#include "votetally.h" +#include "util.h" +#include "db.h" +#include "voteobject.h" + +#define VOTEMASK 0x0FFFFFFF + +using namespace std; + +//Convert char* into string showing its binary +string PrintBinary(uint32_t n) +{ + string result; + for (int i = 0; i < 32; i ++) { + result.push_back( '0' + (n & 1) ); + n >>= 1; + } + + reverse( result.begin(), result.end() ); + + return result; +} + +CVoteTally::CVoteTally(CVoteTally* tallyPrev) +{ + this->nHeight = tallyPrev->nHeight + 1; + this->mapVotes = tallyPrev->GetVotes(); + RemoveStaleSummaries(); +} + +void CVoteTally::RemoveStaleSummaries() +{ + for (auto it : mapVotes) { + //If the vote has ended, then remove it from the new Tally + if (it.second.nBlockStart + it.second.nCheckSpan <= this->nHeight) { + mapLocations.erase(it.first); + mapVotes.erase(it.first); + } + } +} + +//! Proposal Manager will give a set of new positions if any start this block +bool CVoteTally::SetNewPositions(std::map &mapNewLocations) +{ + mapLocations.clear(); + for (auto it : mapNewLocations) { + if (mapLocations.count(it.first)) + continue; + + uint256 txid = 0; + if (!GetProposalTXID(it.first, txid)) + return error("%s: could not find transaction ID for proposal %s", __func__, it.first.GetHex().c_str()); + + CVoteProposal proposal; + CVoteDB votedb("r"); + if (!votedb.ReadProposal(txid, proposal)) + return error("%s: failed to read proposal from DB for %s", __func__, it.first.GetHex().c_str()); + + //Map the proposal to this bit range + VoteLocation locationNew = it.second; + mapLocations.insert(make_pair(it.first, locationNew)); + + //Start a new summary object that will track the votes for this proposal + CVoteSummary summary; + summary.nBlockStart = proposal.GetStartHeight(); + summary.nCheckSpan = proposal.GetCheckSpan(); + mapVotes.insert(make_pair(it.first, summary)); + } + + return true; +} + +//! Record votes that were in the block header +void CVoteTally::ProcessNewVotes(const uint32_t& nVersion) +{ + for (auto it : mapVotes) { + if (!mapLocations.count(it.first)) + continue; + + printf("%s processing vote for %s\n", __func__, it.first.GetHex().c_str()); + + VoteLocation location = mapLocations.at(it.first); + int32_t nVote = nVersion; + nVote &= VOTEMASK; // remove version bits + nVote >>= location.GetShift(); //shift it over to the starting position + int32_t nBits = location.GetBitCount(); + + // Remove any bits to the left of the vote bits + uint32_t nMask = ~0; + nMask >>= (32 - nBits); + nVote &= nMask; + + //Count the vote if it is yes or no + if (nVote == 1) { + mapVotes.at(it.first).nYesTally++; + } else if (nVote == 2) + mapVotes.at(it.first).nNoTally++; + printf("%s: nVote=%d\n", __func__, nVote); + } +} + +bool CVoteTally::GetSummary(const uint256& hashProposal, CVoteSummary& summary) +{ + auto it = mapVotes.find(hashProposal); + if (it == mapVotes.end()) + return false; + + summary = it->second; + return true; +} + + + diff --git a/src/votetally.h b/src/votetally.h new file mode 100644 index 000000000..f33394761 --- /dev/null +++ b/src/votetally.h @@ -0,0 +1,73 @@ +#ifndef VOTING_VOTETALLY_H +#define VOTING_VOTETALLY_H + +#include +#include "serialize.h" +#include "uint256.h" + +class VoteLocation; + +class CVoteSummary +{ +public: + unsigned int nBlockStart; + unsigned int nCheckSpan; + unsigned int nYesTally; + unsigned int nNoTally; //Since voters can abstain, a no tally is needed + + CVoteSummary() + { + nBlockStart = 0; + nCheckSpan = 0; + nYesTally = 0; + nNoTally = 0; + } + + IMPLEMENT_SERIALIZE + ( + READWRITE(nBlockStart); + READWRITE(nCheckSpan); + READWRITE(nYesTally); + READWRITE(nNoTally); + ) +}; + +//typedef std::pair VoteLocation; //start bit, end bit + +class CVoteTally +{ +private: + unsigned int nHeight; + std::map mapVotes; + std::map mapLocations; //Where each vote is located in the header + void RemoveStaleSummaries(); + bool IsLocationOccupied(const VoteLocation& location); +public: + void SetNull() + { + nHeight = 0; + mapVotes.clear(); + mapLocations.clear(); + } + + CVoteTally() + { + SetNull(); + } + + explicit CVoteTally(CVoteTally* tallyPrev); + bool SetNewPositions(std::map& mapNewLocations); + void ProcessNewVotes(const uint32_t& nVersion); + bool GetSummary(const uint256& hashProposal, CVoteSummary& summary); + std::map GetVotes() { return mapVotes; } + + IMPLEMENT_SERIALIZE + ( + READWRITE(nHeight); + READWRITE(mapVotes); + READWRITE(mapLocations); + ) +}; + +#endif //VOTING_VOTETALLY_H + diff --git a/src/wallet.cpp b/src/wallet.cpp index b7140ed9c..c23f7decc 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -11,6 +11,7 @@ #include "base58.h" #include "kernel.h" #include "coincontrol.h" +#include "voteproposal.h" #include @@ -85,10 +86,6 @@ bool CWallet::AddCScript(const CScript& redeemScript) return CWalletDB(strWalletFile).WriteCScript(Hash160(redeemScript), redeemScript); } -// ppcoin: optional setting to unlock wallet for block minting only; -// serves to disable the trivial sendmoney when OS account compromised -bool fWalletUnlockMintOnly = false; - bool CWallet::Unlock(const SecureString& strWalletPassphrase) { if (!IsLocked()) @@ -353,7 +350,7 @@ void CWallet::WalletUpdateSpent(const CTransaction &tx) printf("WalletUpdateSpent: bad wtx %s\n", wtx.GetHash().ToString().c_str()); else if (!wtx.IsSpent(txin.prevout.n) && IsMine(wtx.vout[txin.prevout.n])) { - printf("WalletUpdateSpent found spent coin %sMNT %s\n", FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str()); + printf("WalletUpdateSpent found spent coin %s HYP %s\n", FormatMoney(wtx.GetCredit()).c_str(), wtx.GetHash().ToString().c_str()); wtx.MarkSpent(txin.prevout.n); wtx.WriteToDisk(); NotifyTransactionChanged(this, txin.prevout.hash, CT_UPDATED); @@ -464,23 +461,23 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn) if (fInsertedNew || fUpdated) if (!wtx.WriteToDisk()) return false; -#ifndef QT_GUI - // If default receiving address gets used, replace it with a new one - CScript scriptDefaultKey; - scriptDefaultKey.SetDestination(vchDefaultKey.GetID()); - BOOST_FOREACH(const CTxOut& txout, wtx.vout) - { - if (txout.scriptPubKey == scriptDefaultKey) - { - CPubKey newDefaultKey; - if (GetKeyFromPool(newDefaultKey, false)) - { - SetDefaultKey(newDefaultKey); - SetAddressBookName(vchDefaultKey.GetID(), ""); - } - } - } -#endif + if(!fHaveGUI){ + // If default receiving address gets used, replace it with a new one + CScript scriptDefaultKey; + scriptDefaultKey.SetDestination(vchDefaultKey.GetID()); + BOOST_FOREACH(const CTxOut& txout, wtx.vout) + { + if (txout.scriptPubKey == scriptDefaultKey) + { + CPubKey newDefaultKey; + if (GetKeyFromPool(newDefaultKey, false)) + { + SetDefaultKey(newDefaultKey); + SetAddressBookName(vchDefaultKey.GetID(), ""); + } + } + } + } // since AddToWallet is called directly for self-originating transactions, check for consumption of own coins WalletUpdateSpent(wtx); @@ -759,10 +756,6 @@ void CWalletTx::AddSupportingTransactions(CTxDB& txdb) { tx = *mapWalletPrev[hash]; } - else if (!fClient && txdb.ReadDiskTx(hash, tx)) - { - ; - } else { printf("ERROR: AddSupportingTransactions() : unsupported transaction\n"); @@ -845,7 +838,7 @@ void CWallet::ReacceptWalletTransactions() // Update fSpent if a tx got spent somewhere else by a copy of wallet.dat if (txindex.vSpent.size() != wtx.vout.size()) { - printf("ERROR: ReacceptWalletTransactions() : txindex.vSpent.size() %"PRIszu" != wtx.vout.size() %"PRIszu"\n", txindex.vSpent.size(), wtx.vout.size()); + printf("ERROR: ReacceptWalletTransactions() : txindex.vSpent.size() %lu != wtx.vout.size() %lu\n", txindex.vSpent.size(), wtx.vout.size()); continue; } for (unsigned int i = 0; i < txindex.vSpent.size(); i++) @@ -886,7 +879,7 @@ void CWalletTx::RelayWalletTransaction(CTxDB& txdb) { BOOST_FOREACH(const CMerkleTx& tx, vtxPrev) { - if (!(tx.IsCoinBase() || tx.IsCoinStake())) + if (!(tx.IsCoinBase() || tx.IsCoinStake()) && !tx.vin.empty()) { uint256 hash = tx.GetHash(); if (!txdb.ContainsTx(hash)) @@ -973,7 +966,7 @@ int64 CWallet::GetBalance() const for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) { const CWalletTx* pcoin = &(*it).second; - if (pcoin->IsFinal() && pcoin->IsConfirmed()) + if (pcoin->IsConfirmed()) nTotal += pcoin->GetAvailableCredit(); } } @@ -981,6 +974,23 @@ int64 CWallet::GetBalance() const return nTotal; } +int64 CWallet::GetBalanceInMainChain() const //use this for getbalance rpc call so that it will return intra wallet transactions as confirmed +{ + int64 nTotal = 0; + { + LOCK(cs_wallet); + for (map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) + { + const CWalletTx* pcoin = &(*it).second; + if (pcoin->IsFinal() && pcoin->IsConfirmedInMainChain()) + nTotal += pcoin->GetAvailableCredit(); + } + } + + return nTotal; +} + + int64 CWallet::GetUnconfirmedBalance() const { int64 nTotal = 0; @@ -1107,6 +1117,83 @@ int64 CWallet::GetNewMint() const return nTotal; } +bool CWallet::MultiSend() +{ + if ( IsInitialBlockDownload() || IsLocked() ) + return false; + int64 nAmount = 0; + + { + LOCK(cs_wallet); + std::vector vCoins; + AvailableCoins(vCoins); + + BOOST_FOREACH(const COutput& out, vCoins) + { + CTxDestination address; + if(!ExtractDestination(out.tx->vout[out.i].scriptPubKey, address)) continue; + if (nBestHeight <= nLastMultiSendHeight ) + return false; + if (out.tx->IsCoinStake() && out.tx->GetBlocksToMaturity() == 0 && out.tx->GetDepthInMainChain() == nCoinbaseMaturity+20) + { + //Disabled Addresses won't send MultiSend transactions + if(vDisabledAddresses.size() > 0) + { + for(unsigned int i = 0; i < vDisabledAddresses.size(); i++) + { + if(vDisabledAddresses[i] == CBitcoinAddress(address).ToString()) + { + return false; + } + } + } + + // create new coin control, populate it with the selected utxo, create sending vector + CCoinControl* cControl = new CCoinControl(); + uint256 txhash = out.tx->GetHash(); + COutPoint outpt(txhash, out.i); + cControl->Select(outpt); + CWalletTx wtx; + cControl->fReturnChange = true; + CReserveKey keyChange(this); // this change address does not end up being used, because change is returned with coin control switch + int64 nFeeRet = 0; + vector > vecSend; + + // loop through multisend vector and add amounts and addresses to the sending vector + for(unsigned int i = 0; i < vMultiSend.size(); i++) + { + // MultiSend vector is a pair of 1)Address as a std::string 2) Percent of stake to send as an int + nAmount = ( ( out.tx->GetCredit() - out.tx->GetDebit() ) * vMultiSend[i].second )/100; + CBitcoinAddress strAddSend(vMultiSend[i].first); + CScript scriptPubKey; + scriptPubKey.SetDestination(strAddSend.Get()); + vecSend.push_back(make_pair(scriptPubKey, nAmount)); + } + //make sure splitblock is off + fSplitBlock = false; + + // Create the transaction and commit it to the network + bool fCreated = CreateTransaction(vecSend, wtx, keyChange, nFeeRet, 1, true, cControl); + if (!fCreated) + printf("MultiSend createtransaction failed"); + if(!CommitTransaction(wtx, keyChange)) + printf("MultiSend transaction commit failed"); + else + fMultiSendNotify = true; + delete cControl; + + //write nLastMultiSendHeight to DB + CWalletDB walletdb(strWalletFile); + nLastMultiSendHeight = nBestHeight; + if(!walletdb.WriteMSettings(fMultiSend, nLastMultiSendHeight)) + printf("Failed to write MultiSend setting to DB"); + + } + } + } + return true; +} + bool CWallet::SelectCoinsMinConf(int64 nTargetValue, unsigned int nSpendTime, int nConfMine, int nConfTheirs, vector vCoins, set >& setCoinsRet, int64& nValueRet) const { setCoinsRet.clear(); @@ -1212,6 +1299,69 @@ bool CWallet::SelectCoinsMinConf(int64 nTargetValue, unsigned int nSpendTime, in return true; } +bool CWallet::SelectStakeCoins(std::set >& setCoins, int64 nTargetAmount) const +{ + vector vCoins; + AvailableCoins(vCoins, true); + int64 nAmountSelected = 0; + + bool fStakeFromAddress = false; + CBitcoinAddress addressStake; + CScript scriptStakeFrom; + if (mapArgs.count("-stakeaddress")) { + addressStake = CBitcoinAddress(mapArgs.at("-stakeaddress")); + fStakeFromAddress = addressStake.IsValid(); + } + + BOOST_FOREACH(const COutput& out, vCoins) + { + if (fStakeFromAddress) { + CTxDestination dest; + if (!ExtractDestination(out.tx->vout[out.i].scriptPubKey, dest)) + continue; + if (CBitcoinAddress(dest).ToString() != addressStake.ToString()) + continue; + } + + if (nAmountSelected + out.tx->vout[out.i].nValue < nTargetAmount) + { + if(GetTime() - out.tx->GetTxTime() > (fTestNet ? nStakeMinAge : nStakeMinAgeV2)) + { + setCoins.insert(make_pair(out.tx, out.i)); + nAmountSelected += out.tx->vout[out.i].nValue; + } + } + } + + return true; +} + +unsigned int CWallet::GetMintableOutputCount() +{ + return nMintableOutputs; +} + +bool CWallet::MintableCoins() +{ + int64 nBalance = GetBalance(); + int64 nReserveBalance = 0; + if (mapArgs.count("-reservebalance") && !ParseMoney(mapArgs["-reservebalance"], nReserveBalance)) + return error("MintableCoins() : invalid reserve balance amount"); + if (nBalance <= nReserveBalance) + return false; + + vector vCoins; + AvailableCoins(vCoins, true); + + BOOST_FOREACH(const COutput& out, vCoins) + { + if(GetTime() - out.tx->GetTxTime() > (fTestNet? nStakeMinAge : nStakeMinAgeV2)) + return true; + } + + return false; +} + bool CWallet::SelectCoins(int64 nTargetValue, unsigned int nSpendTime, set >& setCoinsRet, int64& nValueRet, const CCoinControl* coinControl) const { vector vCoins; @@ -1233,7 +1383,7 @@ bool CWallet::SelectCoins(int64 nTargetValue, unsigned int nSpendTime, set >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet, const CCoinControl* coinControl) +bool CWallet::CreateTransaction(const vector >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet, int nSplitBlock, bool fAllowS4C, const CCoinControl* coinControl) { int64 nValue = 0; BOOST_FOREACH (const PAIRTYPE(CScript, int64)& s, vecSend) @@ -1253,7 +1403,9 @@ bool CWallet::CreateTransaction(const vector >& vecSend, CW CTxDB txdb("r"); { nFeeRet = nTransactionFee; - loop + if(fSplitBlock) + nFeeRet = COIN / 1000; + while (true) { wtxNew.vin.clear(); wtxNew.vout.clear(); @@ -1261,19 +1413,43 @@ bool CWallet::CreateTransaction(const vector >& vecSend, CW int64 nTotalValue = nValue + nFeeRet; double dPriority = 0; + if( nSplitBlock < 1 ) + nSplitBlock = 1; // vouts to the payees + + if (!fSplitBlock) + { + BOOST_FOREACH (const PAIRTYPE(CScript, int64)& s, vecSend) + wtxNew.vout.push_back(CTxOut(s.second, s.first)); + } + else BOOST_FOREACH (const PAIRTYPE(CScript, int64)& s, vecSend) - wtxNew.vout.push_back(CTxOut(s.second, s.first)); + { + for(int nCount = 0; nCount < nSplitBlock; nCount++) + { + if(nCount == nSplitBlock -1) + { + uint64 nRemainder = s.second % nSplitBlock; + wtxNew.vout.push_back(CTxOut((s.second / nSplitBlock) + nRemainder, s.first)); + } + else + wtxNew.vout.push_back(CTxOut(s.second / nSplitBlock, s.first)); + } + } // Choose coins to use set > setCoins; int64 nValueIn = 0; if (!SelectCoins(nTotalValue, wtxNew.nTime, setCoins, nValueIn, coinControl)) return false; + CTxDestination utxoAddress; BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins) { int64 nCredit = pcoin.first->vout[pcoin.second].nValue; dPriority += (double)nCredit * pcoin.first->GetDepthInMainChain(); + //use this address to send change back + //note that this will use the last address run through the FOREACH, needs better logic added + ExtractDestination(pcoin.first->vout[pcoin.second].scriptPubKey, utxoAddress); } int64 nChange = nValueIn - nValue - nFeeRet; @@ -1302,24 +1478,39 @@ bool CWallet::CreateTransaction(const vector >& vecSend, CW // change transaction isn't always pay-to-bitcoin-address CScript scriptChange; - // coin control: send change to custom address - if (coinControl && !boost::get(&coinControl->destChange)) + // Stake For Charity: send change to custom address + /*if (fAllowS4C) { + if (strStakeForCharityChangeAddress.IsValid()) + scriptChange.SetDestination(strStakeForCharityChangeAddress.Get()); + else + { + CPubKey vchPubKey = reservekey.GetReservedKey(); + scriptChange.SetDestination(vchPubKey.GetID()); + } + }*/ + if (coinControl && coinControl->fReturnChange == true) + scriptChange.SetDestination(utxoAddress); + // coin control: send change to custom address + else if (coinControl && !boost::get(&coinControl->destChange)) { scriptChange.SetDestination(coinControl->destChange); - + } // no coin control: send change to newly generated address - else - { + else + { // Note: We use a new key here to keep it from being obvious which side is the change. // The drawback is that by not reusing a previous key, the change may be lost if a // backup is restored, if the backup doesn't have the new private key for the change. // If we reused the old key, it would be possible to add code to look for and // rediscover unknown transactions that were written with keys of ours to recover // post-backup change. - + // Reserve a new key pair from key pool CPubKey vchPubKey = reservekey.GetReservedKey(); scriptChange.SetDestination(vchPubKey.GetID()); + + // change HyperStake to get rid of automatic generation of change address and instead send change back + } // Insert change txn at random position: @@ -1380,142 +1571,114 @@ bool CWallet::GetStakeWeightFromValue(const int64& nTime, const int64& nValue, u return true; } -bool CWallet::CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet, const CCoinControl* coinControl) +bool CWallet::CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet, bool fAllowS4C, const CCoinControl* coinControl) { vector< pair > vecSend; vecSend.push_back(make_pair(scriptPubKey, nValue)); - return CreateTransaction(vecSend, wtxNew, reservekey, nFeeRet, coinControl); + return CreateTransaction(vecSend, wtxNew, reservekey, nFeeRet, 1, fAllowS4C, coinControl); } -bool CWallet::GetStakeWeight(const CKeyStore& keystore, uint64& nMinWeight, uint64& nMaxWeight, uint64& nWeight) +uint64 CWallet::GetTimeToNextMaturity() { - // Choose coins to use - int64 nBalance = GetBalance(); - - int64 nReserveBalance = 0; - if (mapArgs.count("-reservebalance") && !ParseMoney(mapArgs["-reservebalance"], nReserveBalance)) - return error("CreateCoinStake : invalid reserve balance amount"); - if (nBalance <= nReserveBalance) - return false; - set > setCoins; - vector vwtxPrev; int64 nValueIn = 0; - if (!SelectCoins(nBalance - nReserveBalance, GetTime(), setCoins, nValueIn)) + if (!SelectCoins(GetBalance(), GetTime(), setCoins, nValueIn)) return false; - if (setCoins.empty()) - return false; - - CTxDB txdb("r"); + uint64 nTimeToNextMaturity = -1; + uint64 nStakeAge = (fTestNet ? nStakeMinAge : nStakeMinAgeV2); BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins) { - CTxIndex txindex; - { - LOCK2(cs_main, cs_wallet); - if (!txdb.ReadTxIndex(pcoin.first->GetHash(), txindex)) - continue; - } + uint64 nCurrentAge = GetTime() - pcoin.first->nTime; + if (nCurrentAge > nStakeAge) + return 0; - int64 nTimeWeight = GetWeight((int64)pcoin.first->nTime, (int64)GetTime()); - CBigNum bnCoinDayWeight = CBigNum(pcoin.first->vout[pcoin.second].nValue) * nTimeWeight / COIN / (24 * 60 * 60); + uint64 nTimeToMaturity = nStakeAge - nCurrentAge; - // Weight is greater than zero - if (nTimeWeight > 0) - { - nWeight += bnCoinDayWeight.getuint64(); - } - - // Weight is greater than zero, but the maximum value isn't reached yet - if (nTimeWeight > 0 && nTimeWeight < nStakeMaxAge) - { - nMinWeight += bnCoinDayWeight.getuint64(); - } - - // Maximum weight was reached - if (nTimeWeight == nStakeMaxAge) - { - nMaxWeight += bnCoinDayWeight.getuint64(); - } + // see if this coin matures in less time than the 'current' oldest coin + if(nTimeToMaturity < nTimeToNextMaturity) + nTimeToNextMaturity = nTimeToMaturity; } - return true; + return nTimeToNextMaturity; } -//This is added for informational purposes since staking takes 8.8 days min approx. because of bug -bool CWallet::GetStakeWeight2(const CKeyStore& keystore, uint64& nMinWeight, uint64& nMaxWeight, uint64& nWeight) +bool CWallet::GetStakeWeight(const CKeyStore& keystore, uint64& nMinWeight, uint64& nMaxWeight, uint64& nWeight, uint64& nAmount) { // Choose coins to use int64 nBalance = GetBalance(); - int64 nReserveBalance = 0; if (mapArgs.count("-reservebalance") && !ParseMoney(mapArgs["-reservebalance"], nReserveBalance)) return error("CreateCoinStake : invalid reserve balance amount"); + if (nBalance <= nReserveBalance) return false; set > setCoins; vector vwtxPrev; int64 nValueIn = 0; + int64 nTimeNow = GetTime(); - if (!SelectCoins(nBalance - nReserveBalance, GetTime(), setCoins, nValueIn)) + if (!SelectCoins(nBalance - nReserveBalance, nTimeNow, setCoins, nValueIn)) return false; if (setCoins.empty()) return false; - CTxDB txdb("r"); + uint64 nStakeAge = nStakeMinAgeV2; + + if(fTestNet) + nStakeAge = nStakeMinAge; + + CBigNum bnTotalWeight = 0; BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins) { - CTxIndex txindex; - { - LOCK2(cs_main, cs_wallet); - if (!txdb.ReadTxIndex(pcoin.first->GetHash(), txindex)) - continue; - } - - int64 nTimeWeight = GetWeight2((int64)pcoin.first->nTime, (int64)GetTime()); + // Time Until Next Maturity + uint64 nCurrentAge = nTimeNow - pcoin.first->nTime; + + int64 nTimeWeight = GetWeight2(pcoin.first->nTime, nTimeNow); CBigNum bnCoinDayWeight = CBigNum(pcoin.first->vout[pcoin.second].nValue) * nTimeWeight / COIN / (24 * 60 * 60); + + if (nCurrentAge < nStakeAge) // if the age is less than min stake age report it as 0 + bnCoinDayWeight = 0; - // Weight is greater than zero if (nTimeWeight > 0) { - nWeight += bnCoinDayWeight.getuint64(); + bnTotalWeight += bnCoinDayWeight; + nAmount += (uint64)pcoin.first->vout[pcoin.second].nValue / COIN; } - + // Weight is greater than zero, but the maximum value isn't reached yet - if (nTimeWeight > 0 && nTimeWeight < nStakeMaxAge) - { + if (nTimeWeight && nTimeWeight < nStakeMaxAge) nMinWeight += bnCoinDayWeight.getuint64(); - } // Maximum weight was reached if (nTimeWeight == nStakeMaxAge) - { nMaxWeight += bnCoinDayWeight.getuint64(); - } } + nWeight = bnTotalWeight.getuint64(); return true; } // ppcoin: create coin stake transaction bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64 nSearchInterval, CTransaction& txNew) { - // The following split & combine thresholds are important to security + //presstab HyperStake: return false if disablestake RPC is enabled + if(fDisableStake) + return false; + + // The following split & combine thresholds are important to security // Should not be adjusted if you don't understand the consequences - static unsigned int nStakeSplitAge = (60 * 60 * 24 * 30); const CBlockIndex* pIndex0 = GetLastBlockIndex(pindexBest, false); int64 nCombineThreshold = 0; if(pIndex0->pprev) nCombineThreshold = GetProofOfWorkReward(pIndex0->nHeight, MIN_TX_FEE, pIndex0->pprev->GetBlockHash()) / 3; - CBigNum bnTargetPerCoinDay; - bnTargetPerCoinDay.SetCompact(nBits); - txNew.vin.clear(); txNew.vout.clear(); + // Mark coin stake transaction CScript scriptEmpty; scriptEmpty.clear(); @@ -1525,23 +1688,35 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int int64 nReserveBalance = 0; if (mapArgs.count("-reservebalance") && !ParseMoney(mapArgs["-reservebalance"], nReserveBalance)) return error("CreateCoinStake : invalid reserve balance amount"); + if (nBalance <= nReserveBalance) return false; - set > setCoins; - vector vwtxPrev; - int64 nValueIn = 0; - if (!SelectCoins(nBalance - nReserveBalance, txNew.nTime, setCoins, nValueIn)) - return false; + // presstab HyperStake - Initialize as static and don't update the set on every run of CreateCoinStake() in order to lighten resource use + static std::set > setStakeCoins; + static int64 nLastStakeSetUpdate = 0; - if (setCoins.empty()) + if(GetTime() - nLastStakeSetUpdate > nStakeSetUpdateTime) + { + setStakeCoins.clear(); + if (!SelectStakeCoins(setStakeCoins, nBalance - nReserveBalance)) + return false; + nLastStakeSetUpdate = GetTime(); + } + + //update mintable outputs count + nMintableOutputs = setStakeCoins.size(); + if (setStakeCoins.empty()) return false; + bnStakeWeightCached = 0; + vector vwtxPrev; + int64 nCredit = 0; CScript scriptPubKeyKernel; - BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins) + CTxDB txdb("r"); + BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setStakeCoins) { - CTxDB txdb("r"); CTxIndex txindex; { LOCK2(cs_main, cs_wallet); @@ -1557,112 +1732,127 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int continue; } - static int nMaxStakeSearchInterval = 60; - - // printf(">> block.GetBlockTime() = %"PRI64d", nStakeMinAge = %d, txNew.nTime = %d\n", block.GetBlockTime(), nStakeMinAge,txNew.nTime); - if (block.GetBlockTime() + nStakeMinAge > txNew.nTime - nMaxStakeSearchInterval) - continue; // only count coins meeting min age requirement - bool fKernelFound = false; - for (unsigned int n=0; n> In.....\n"); - // Search backward in time from the given txNew timestamp - // Search nSearchInterval seconds back up to nMaxStakeSearchInterval - uint256 hashProofOfStake = 0; - COutPoint prevoutStake = COutPoint(pcoin.first->GetHash(), pcoin.second); - if (CheckStakeKernelHash(nBits, block, txindex.pos.nTxPos - txindex.pos.nBlockPos, *pcoin.first, prevoutStake, txNew.nTime - n, hashProofOfStake)) - { - // Found a kernel - if (fDebug && GetBoolArg("-printcoinstake")) - printf("CreateCoinStake : kernel found\n"); - vector vSolutions; - txnouttype whichType; - CScript scriptPubKeyOut; - scriptPubKeyKernel = pcoin.first->vout[pcoin.second].scriptPubKey; - if (!Solver(scriptPubKeyKernel, whichType, vSolutions)) - { - if (fDebug && GetBoolArg("-printcoinstake")) - printf("CreateCoinStake : failed to parse kernel\n"); - break; - } - if (fDebug && GetBoolArg("-printcoinstake")) - printf("CreateCoinStake : parsed kernel type=%d\n", whichType); - if (whichType != TX_PUBKEY && whichType != TX_PUBKEYHASH) - { - if (fDebug && GetBoolArg("-printcoinstake")) - printf("CreateCoinStake : no support for kernel type=%d\n", whichType); - break; // only support pay to public key and pay to address - } - if (whichType == TX_PUBKEYHASH) // pay to address type - { - // convert to pay to public key type - CKey key; - if (!keystore.GetKey(uint160(vSolutions[0]), key)) - { - if (fDebug && GetBoolArg("-printcoinstake")) - printf("CreateCoinStake : failed to get key for kernel type=%d\n", whichType); - break; // unable to find corresponding public key - } - scriptPubKeyOut << key.GetPubKey() << OP_CHECKSIG; - } - else - scriptPubKeyOut = scriptPubKeyKernel; + uint256 hashProofOfStake = 0; + COutPoint prevoutStake = COutPoint(pcoin.first->GetHash(), pcoin.second); + unsigned int txNewTime = txNew.nTime; - txNew.nTime -= n; - txNew.vin.push_back(CTxIn(pcoin.first->GetHash(), pcoin.second)); - nCredit += pcoin.first->vout[pcoin.second].nValue; + CBigNum bnCoinWeight = 0; + bool foundKernel = CheckStakeKernelHash(nBits, block, txindex.pos.nTxPos - txindex.pos.nBlockPos, *pcoin.first, prevoutStake, txNewTime, nHashDrift, false, hashProofOfStake, bnCoinWeight); + bnStakeWeightCached += bnCoinWeight; - // printf(">> Wallet: CreateCoinStake: nCredit = %"PRI64d"\n", nCredit); + if (foundKernel) + { + if (fDebug && GetBoolArg("-printcoinstake")) + printf("CreateCoinStake : kernel found\n"); + + vector vSolutions; + txnouttype whichType; + CScript scriptPubKeyOut; + scriptPubKeyKernel = pcoin.first->vout[pcoin.second].scriptPubKey; + if (!Solver(scriptPubKeyKernel, whichType, vSolutions)) + { + if (fDebug && GetBoolArg("-printcoinstake")) + printf("CreateCoinStake : failed to parse kernel\n"); + break; + } - vwtxPrev.push_back(pcoin.first); - txNew.vout.push_back(CTxOut(0, scriptPubKeyOut)); - if (block.GetBlockTime() + nStakeSplitAge > txNew.nTime) - txNew.vout.push_back(CTxOut(0, scriptPubKeyOut)); //split stake + if (fDebug && GetBoolArg("-printcoinstake")) + printf("CreateCoinStake : parsed kernel type=%d\n", whichType); - if (fDebug && GetBoolArg("-printcoinstake")) - printf("CreateCoinStake : added kernel type=%d\n", whichType); - fKernelFound = true; - break; - } - } + if (whichType != TX_PUBKEY && whichType != TX_PUBKEYHASH) + { + if (fDebug && GetBoolArg("-printcoinstake")) + printf("CreateCoinStake : no support for kernel type=%d\n", whichType); + break; // only support pay to public key and pay to address + } + + if (whichType == TX_PUBKEYHASH) // pay to address type + { + // convert to pay to public key type + CKey key; + if (!keystore.GetKey(uint160(vSolutions[0]), key)) + { + if (fDebug && GetBoolArg("-printcoinstake")) + printf("CreateCoinStake : failed to get key for kernel type=%d\n", whichType); + break; // unable to find corresponding public key + } + scriptPubKeyOut << key.GetPubKey() << OP_CHECKSIG; + } + else + scriptPubKeyOut = scriptPubKeyKernel; + + txNew.nTime = txNewTime; + txNew.vin.push_back(CTxIn(pcoin.first->GetHash(), pcoin.second)); + nCredit += pcoin.first->vout[pcoin.second].nValue; + vwtxPrev.push_back(pcoin.first); + txNew.vout.push_back(CTxOut(0, scriptPubKeyOut)); + + //presstab HyperStake - calculate the total size of our new output including the stake reward so that we can use it to decide whether to split the stake outputs + uint64 nCoinAge; + CTxDB txdb("r"); + const CBlockIndex* pIndex0 = GetLastBlockIndex(pindexBest, false); + if (!txNew.GetCoinAge(txdb, nCoinAge)) + return error("CreateCoinStake : failed to calculate coin age"); + uint64 nTotalSize = pcoin.first->vout[pcoin.second].nValue + GetProofOfStakeReward(nCoinAge, nBits, txNew.nTime, pIndex0->nHeight); + + //presstab HyperStake - if MultiSend is set to send in coinstake we will add our outputs here (values asigned further down) + if(fMultiSend && fMultiSendCoinStake) + { + for(unsigned int i = 0; i < vMultiSend.size(); i++) + { + CScript scriptPubKeyMultiSend; + scriptPubKeyMultiSend.SetDestination(CBitcoinAddress(vMultiSend[i].first).Get()); + txNew.vout.push_back(CTxOut(0, scriptPubKeyMultiSend)); + } + } + else if (nTotalSize / 2 > nStakeSplitThreshold * COIN) + txNew.vout.push_back(CTxOut(0, scriptPubKeyOut)); //split stake + + if (fDebug && GetBoolArg("-printcoinstake")) + printf("CreateCoinStake : added kernel type=%d\n", whichType); + fKernelFound = true; + break; + } if (fKernelFound || fShutdown) - break; // if kernel is found stop searching + break; // if kernel is found stop searching + } if (nCredit == 0 || nCredit > nBalance - nReserveBalance) - { - // printf(">> Wallet: CreateCoinStake: nCredit = %"PRI64d", nBalance = %"PRI64d", nReserveBalance = %"PRI64d"\n", nCredit, nBalance, nReserveBalance); return false; - } - BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins) - { - // Attempt to add more inputs - // Only add coins of the same key/address as kernel - if (txNew.vout.size() == 2 && ((pcoin.first->vout[pcoin.second].scriptPubKey == scriptPubKeyKernel || pcoin.first->vout[pcoin.second].scriptPubKey == txNew.vout[1].scriptPubKey)) - && pcoin.first->GetHash() != txNew.vin[0].prevout.hash) - { - // Stop adding more inputs if already too many inputs - if (txNew.vin.size() >= 100) - break; - // Stop adding more inputs if value is already pretty significant - if (nCredit > nCombineThreshold) - break; - // Stop adding inputs if reached reserve limit - if (nCredit + pcoin.first->vout[pcoin.second].nValue > nBalance - nReserveBalance) - break; - // Do not add additional significant input - if (pcoin.first->vout[pcoin.second].nValue > nCombineThreshold) - continue; - // Do not add input that is still too young - if (pcoin.first->nTime + nStakeMaxAge > txNew.nTime) - continue; - txNew.vin.push_back(CTxIn(pcoin.first->GetHash(), pcoin.second)); - nCredit += pcoin.first->vout[pcoin.second].nValue; - vwtxPrev.push_back(pcoin.first); - } - } + if(fCombineDust) //presstab HyperStake - this combination code iterates through all of your outputs on successful coinstake, so its useful to have user be able to choose whether this is necessary + { + BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setStakeCoins) + { + // Attempt to add more inputs + // Only add coins of the same key/address as kernel + if (txNew.vout.size() == 2 && ((pcoin.first->vout[pcoin.second].scriptPubKey == scriptPubKeyKernel || pcoin.first->vout[pcoin.second].scriptPubKey == txNew.vout[1].scriptPubKey)) + && pcoin.first->GetHash() != txNew.vin[0].prevout.hash) + { + // Stop adding more inputs if already too many inputs + if (txNew.vin.size() >= 100) + break; + // Stop adding more inputs if value is already pretty significant + if (nCredit > nCombineThreshold) + break; + // Stop adding inputs if reached reserve limit + if (nCredit + pcoin.first->vout[pcoin.second].nValue > nBalance - nReserveBalance) + break; + // Do not add additional significant input + if (pcoin.first->vout[pcoin.second].nValue > nCombineThreshold) + continue; + // Do not add input that is still too young + if (pcoin.first->nTime + nStakeMaxAge > txNew.nTime) + continue; + txNew.vin.push_back(CTxIn(pcoin.first->GetHash(), pcoin.second)); + nCredit += pcoin.first->vout[pcoin.second].nValue; + vwtxPrev.push_back(pcoin.first); + } + } + } // Calculate coin age reward + uint64 nReward; { uint64 nCoinAge; CTxDB txdb("r"); @@ -1670,14 +1860,27 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int if (!txNew.GetCoinAge(txdb, nCoinAge)) return error("CreateCoinStake : failed to calculate coin age"); - nCredit += GetProofOfStakeReward(nCoinAge, nBits, txNew.nTime, pIndex0->nHeight); + + nReward = GetProofOfStakeReward(nCoinAge, nBits, txNew.nTime, pIndex0->nHeight); + nCredit += nReward; } int64 nMinFee = 0; - loop + while (true) { // Set output amount - if (txNew.vout.size() == 3) + if(fMultiSend && fMultiSendCoinStake) + { + uint64 nMultiSendAmount = 0; + for(unsigned int i = 0; i < vMultiSend.size(); i++) + { + int nOut = 2 + i; + txNew.vout[nOut].nValue = nReward * vMultiSend[i].second / 100; + nMultiSendAmount += txNew.vout[nOut].nValue; + } + txNew.vout[1].nValue = nCredit - nMinFee - nMultiSendAmount; + } + else if (txNew.vout.size() == 3) { txNew.vout[1].nValue = ((nCredit - nMinFee) / 2 / CENT) * CENT; txNew.vout[2].nValue = nCredit - nMinFee - txNew.vout[1].nValue; @@ -1713,10 +1916,38 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int } // Successfully generated coinstake + nLastStakeSetUpdate = 0; //this will trigger stake set to repopulate next round return true; } +// hyperstake: complete construction of a proposal transaction +bool CWallet::FinalizeProposal(CTransaction& txProposal) +{ + //! Choose coins to use + set > setCoins; + int64 nValueIn = 0; + if (!SelectCoins(5 * COIN, GetTime(), setCoins, nValueIn, NULL) || nValueIn < CVoteProposal::FEE) + return error("Failed to select coins to spend"); + + //! Select one of the addresses to send the change to, and add inputs to the proposal tx + CScript scriptChange; + nValueIn = 0; + BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins) { + scriptChange = pcoin.first->vout[pcoin.second].scriptPubKey; + txProposal.vin.push_back(CTxIn(pcoin.first->GetHash(), pcoin.second)); + nValueIn += pcoin.first->vout[pcoin.second].nValue; + } + + //! Add change output + if (nValueIn > CVoteProposal::FEE + CENT) { + CTxOut out(nValueIn - CVoteProposal::FEE, scriptChange); + txProposal.vout.push_back(out); + } + + return true; +} + // Call after CreateTransaction unless you want to abort bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey) { @@ -1769,7 +2000,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey) -string CWallet::SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, bool fAskFee) +string CWallet::SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, bool fAskFee, bool fAllowS4C) { CReserveKey reservekey(this); int64 nFeeRequired; @@ -1780,13 +2011,15 @@ string CWallet::SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, printf("SendMoney() : %s", strError.c_str()); return strError; } - if (fWalletUnlockMintOnly) + // stakeforcharity is the only allowable option to send coins when the UnlockMintOnly flag is set. + if ( fWalletUnlockMintOnly && !fAllowS4C ) { string strError = _("Error: Wallet unlocked for block minting only, unable to create transaction."); printf("SendMoney() : %s", strError.c_str()); return strError; } - if (!CreateTransaction(scriptPubKey, nValue, wtxNew, reservekey, nFeeRequired)) + + if (!CreateTransaction(scriptPubKey, nValue, wtxNew, reservekey, nFeeRequired, fAllowS4C)) { string strError; if (nValue + nFeeRequired > GetBalance()) @@ -1808,7 +2041,7 @@ string CWallet::SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, -string CWallet::SendMoneyToDestination(const CTxDestination& address, int64 nValue, CWalletTx& wtxNew, bool fAskFee) +string CWallet::SendMoneyToDestination(const CTxDestination& address, int64 nValue, CWalletTx& wtxNew, bool fAskFee, bool fAllowStakeForCharity) { // Check amount if (nValue <= 0) @@ -1820,7 +2053,7 @@ string CWallet::SendMoneyToDestination(const CTxDestination& address, int64 nVal CScript scriptPubKey; scriptPubKey.SetDestination(address); - return SendMoney(scriptPubKey, nValue, wtxNew, fAskFee); + return SendMoney(scriptPubKey, nValue, wtxNew, fAskFee, fAllowStakeForCharity); } @@ -1879,12 +2112,12 @@ void CWallet::PrintWallet(const CBlock& block) if (block.IsProofOfWork() && mapWallet.count(block.vtx[0].GetHash())) { CWalletTx& wtx = mapWallet[block.vtx[0].GetHash()]; - printf(" mine: %d %d %"PRI64d"", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit()); + printf(" mine: %d %d %lld", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit()); } if (block.IsProofOfStake() && mapWallet.count(block.vtx[1].GetHash())) { CWalletTx& wtx = mapWallet[block.vtx[1].GetHash()]; - printf(" stake: %d %d %"PRI64d"", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit()); + printf(" stake: %d %d %lld", wtx.GetDepthInMainChain(), wtx.GetBlocksToMaturity(), wtx.GetCredit()); } } @@ -1947,7 +2180,7 @@ bool CWallet::NewKeyPool() walletdb.WritePool(nIndex, CKeyPool(GenerateNewKey())); setKeyPool.insert(nIndex); } - printf("CWallet::NewKeyPool wrote %"PRI64d" new keys\n", nKeys); + printf("CWallet::NewKeyPool wrote %lld new keys\n", nKeys); } return true; } @@ -1972,7 +2205,7 @@ bool CWallet::TopUpKeyPool() if (!walletdb.WritePool(nEnd, CKeyPool(GenerateNewKey()))) throw runtime_error("TopUpKeyPool() : writing generated key failed"); setKeyPool.insert(nEnd); - printf("keypool added key %"PRI64d", size=%"PRIszu"\n", nEnd, setKeyPool.size()); + printf("keypool added key %lld, size=%lu\n", nEnd, setKeyPool.size()); } } return true; @@ -2002,7 +2235,7 @@ void CWallet::ReserveKeyFromKeyPool(int64& nIndex, CKeyPool& keypool) throw runtime_error("ReserveKeyFromKeyPool() : unknown key in key pool"); assert(keypool.vchPubKey.IsValid()); if (fDebug && GetBoolArg("-printkeypool")) - printf("keypool reserve %"PRI64d"\n", nIndex); + printf("keypool reserve %lld\n", nIndex); } } @@ -2030,7 +2263,7 @@ void CWallet::KeepKey(int64 nIndex) walletdb.ErasePool(nIndex); } if(fDebug) - printf("keypool keep %"PRI64d"\n", nIndex); + printf("keypool keep %lld\n", nIndex); } void CWallet::ReturnKey(int64 nIndex) @@ -2041,7 +2274,7 @@ void CWallet::ReturnKey(int64 nIndex) setKeyPool.insert(nIndex); } if(fDebug) - printf("keypool return %"PRI64d"\n", nIndex); + printf("keypool return %lld\n", nIndex); } bool CWallet::GetKeyFromPool(CPubKey& result, bool fAllowReuse) @@ -2221,6 +2454,22 @@ void CWallet::FixSpentCoins(int& nMismatchFound, int64& nBalanceInQuestion, int& BOOST_FOREACH(CWalletTx* pcoin, vCoins) { uint256 hash = pcoin->GetHash(); + + // presstab HyperStake + // This finds and deletes transactions that were never accepted by the network + // needs to be located above the readtxindex code or else it will not be triggered + if(!pcoin->IsConfirmedInMainChain() && (GetTime() - pcoin->GetTxTime()) > (60*10)) //give the tx 10 minutes before considering it failed + { + nOrphansFound++; + if (!fCheckOnly) + { + EraseFromWallet(hash); + NotifyTransactionChanged(this, hash, CT_DELETED); + } + printf("FixSpentCoins %s rejected transaction %s\n", fCheckOnly ? "found" : "removed", hash.ToString().c_str()); + continue; + } + // Find the corresponding transaction index CTxIndex txindex; if (!txdb.ReadTxIndex(hash, txindex) && !(pcoin->IsCoinBase() || pcoin->IsCoinStake())) @@ -2229,7 +2478,7 @@ void CWallet::FixSpentCoins(int& nMismatchFound, int64& nBalanceInQuestion, int& for (unsigned int n=0; n < pcoin->vout.size(); n++) { bool fUpdated = false; - if (IsMine(pcoin->vout[n]) && pcoin->IsSpent(n) && (txindex.vSpent.size() <= n || txindex.vSpent[n].IsNull())) + if (IsMine(pcoin->vout[n]) && pcoin->IsSpent(n) && (txindex.vSpent.size() <= n || txindex.vSpent[n].IsNull()) && (GetTime() - pcoin->GetTxTime()) > (60*10)) { printf("FixSpentCoins found lost coin %shyp %s[%d], %s\n", FormatMoney(pcoin->vout[n].nValue).c_str(), hash.ToString().c_str(), n, fCheckOnly? "repair not attempted" : "repairing"); @@ -2242,7 +2491,7 @@ void CWallet::FixSpentCoins(int& nMismatchFound, int64& nBalanceInQuestion, int& pcoin->WriteToDisk(); } } - else if (IsMine(pcoin->vout[n]) && !pcoin->IsSpent(n) && (txindex.vSpent.size() > n && !txindex.vSpent[n].IsNull())) + else if (IsMine(pcoin->vout[n]) && !pcoin->IsSpent(n) && (txindex.vSpent.size() > n && !txindex.vSpent[n].IsNull()) && (GetTime() - pcoin->GetTxTime()) > (60*10)) { printf("FixSpentCoins found spent coin %shyp %s[%d], %s\n", FormatMoney(pcoin->vout[n].nValue).c_str(), hash.ToString().c_str(), n, fCheckOnly? "repair not attempted" : "repairing"); @@ -2294,6 +2543,67 @@ void CWallet::DisableTransaction(const CTransaction &tx) } } +bool CWallet::SendProposal(const CVoteProposal& proposal, uint256& txid) +{ + CTransaction tx; + if (!proposal.ConstructTransaction(tx)) + return error("%s: failed to construct proposal tx\n", __func__); + CWalletTx wtx(this, tx); + + //! Get available coins and add enough to cover the proposal fee + vector vCoins; + AvailableCoins(vCoins, true); + + printf("*** after available coins\n"); + + int64 nFee = CVoteProposal::FEE; + int64 nValueIn = 0; + + set > setCoins; + if (!SelectCoinsMinConf(nFee, tx.nTime, 1, 6, vCoins, setCoins, nValueIn)) + return error("%s: Insufficient funds", __func__); + + //! Fill vin + for (pair coin : setCoins) + wtx.vin.push_back(CTxIn(coin.first->GetHash(),coin.second)); + + //! Add the min value required for an output to the proposal UTXO + wtx.vout[0].nValue = MIN_TXOUT_AMOUNT; + + //! Figure out change amount + nFee -= wtx.vout[0].nValue; + int64 nChange = nValueIn - nFee - MIN_TXOUT_AMOUNT; + if (nChange > 500) { + //!Lookup the address of one of the inputs and return the change to that address + uint256 hashBlock; + CTransaction txPrev; + if(!::GetTransaction(wtx.vin[0].prevout.hash, txPrev, hashBlock)) + return error("%s: Failed to select coins", __func__); + + CScript scriptReturn = txPrev.vout[wtx.vin[0].prevout.n].scriptPubKey; + CTxOut out(nChange, scriptReturn); + + //!Add the change output to the new transaction + wtx.vout.push_back(out); + } + + //! Sign the transaction + int nIn = 0; + for (const pair& coin : setCoins) { + if (!SignSignature(*this, *coin.first, wtx, nIn++)) + return false; + } + + //! Broadcast the transaction to the network + CReserveKey reserveKey = CReserveKey(this); + if (!CommitTransaction(wtx, reserveKey)) + return error("%s: Failed to commit transaction", __func__); + + txid = wtx.GetHash(); + + return true; +} + CPubKey CReserveKey::GetReservedKey() { if (nIndex == -1) diff --git a/src/wallet.h b/src/wallet.h index 5bc3f6db5..e03a1794a 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -18,7 +18,6 @@ #include "util.h" #include "walletdb.h" -extern bool fWalletUnlockMintOnly; class CAccountingEntry; class CWalletTx; class CReserveKey; @@ -71,7 +70,7 @@ class CWallet : public CCryptoKeyStore { private: bool SelectCoins(int64 nTargetValue, unsigned int nSpendTime, std::set >& setCoinsRet, int64& nValueRet, const CCoinControl *coinControl=NULL) const; - + bool SelectStakeCoins(std::set >& setCoinsRet, int64 nTargetAmount) const; CWalletDB *pwalletdbEncryption; // the current wallet version: clients below this version are not able to load the wallet @@ -80,19 +79,50 @@ class CWallet : public CCryptoKeyStore // the maximum wallet format version: memory-only variable that specifies to what version this wallet may be upgraded int nWalletMaxVersion; + //how many UTXO's are eligible to be staked + unsigned int nMintableOutputs; + public: + bool MintableCoins(); mutable CCriticalSection cs_wallet; - bool fFileBacked; std::string strWalletFile; - - std::set setKeyPool; - - - typedef std::map MasterKeyMap; + std::set setKeyPool; + typedef std::map MasterKeyMap; MasterKeyMap mapMasterKeys; unsigned int nMasterKeyMaxID; - + bool fWalletUnlockMintOnly; + CBigNum bnStakeWeightCached; + + //SplitBlock + bool fSplitBlock; + + //MultiSend + std::vector > vMultiSend; + bool fMultiSend; + bool fMultiSendCoinStake; + bool fMultiSendNotify; + std::string strMultiSendChangeAddress; + int nLastMultiSendHeight; + std::vector vDisabledAddresses; + + // Stake Settings + unsigned int nHashDrift; + unsigned int nHashInterval; + uint64 nStakeSplitThreshold; + int nStakeSetUpdateTime; + bool fCombineDust; + + // DisableStake + bool fDisableStake; + std::string strDisableType; + std::string strDisableArg; + double dUserNumber; + bool fStakeRequirement; + + // Voting + std::map mapVoteObjects; + CWallet() { nWalletVersion = FEATURE_BASE; @@ -101,6 +131,33 @@ class CWallet : public CCryptoKeyStore nMasterKeyMaxID = 0; pwalletdbEncryption = NULL; nOrderPosNext = 0; + fWalletUnlockMintOnly = false; + fSplitBlock = false; + bnStakeWeightCached = 0; + nMintableOutputs = 0; + + //DisableStake + fDisableStake = false; + strDisableType = ""; + strDisableArg = ""; + dUserNumber = 0; + fStakeRequirement = false; + + // Stake Settings + nHashDrift = 45; + nStakeSplitThreshold = 2000; + nHashInterval = 22; + nStakeSetUpdateTime = 300; // 5 minutes + fCombineDust = true; + + //MultiSend + vMultiSend.clear(); + fMultiSend = false; + fMultiSendCoinStake = false; + fMultiSendNotify = false; + strMultiSendChangeAddress = ""; + nLastMultiSendHeight = 0; + vDisabledAddresses.clear(); } CWallet(std::string strWalletFileIn) { @@ -111,6 +168,33 @@ class CWallet : public CCryptoKeyStore nMasterKeyMaxID = 0; pwalletdbEncryption = NULL; nOrderPosNext = 0; + fWalletUnlockMintOnly = false; + fSplitBlock = false; + bnStakeWeightCached = 0; + nMintableOutputs = 0; + + //DisableStake + fDisableStake = false; + strDisableType = ""; + strDisableArg = ""; + dUserNumber = 0; + fStakeRequirement = false; + + // Stake Settings + nHashDrift = 45; + nStakeSplitThreshold = 10000; + nHashInterval = 22; + nStakeSetUpdateTime = 300; // 5 minutes + fCombineDust = true; + + //MultiSend + vMultiSend.clear(); + fMultiSend = false; + fMultiSendCoinStake = false; + fMultiSendNotify = false; + strMultiSendChangeAddress = ""; + nLastMultiSendHeight = 0; + vDisabledAddresses.clear(); } std::map mapWallet; @@ -171,19 +255,23 @@ class CWallet : public CCryptoKeyStore void ReacceptWalletTransactions(); void ResendWalletTransactions(); int64 GetBalance() const; + int64 GetBalanceInMainChain() const; int64 GetUnconfirmedBalance() const; int64 GetImmatureBalance() const; int64 GetStake() const; int64 GetNewMint() const; - bool CreateTransaction(const std::vector >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet, const CCoinControl *coinControl=NULL); - bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet, const CCoinControl *coinControl=NULL); + unsigned int GetMintableOutputCount(); + bool MultiSend(); + bool CreateTransaction(const std::vector >& vecSend, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet, int nSplitBlock, bool fAllowS4C=false, const CCoinControl *coinControl=NULL); + bool CreateTransaction(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, CReserveKey& reservekey, int64& nFeeRet, bool fAllowS4C=false, const CCoinControl *coinControl=NULL); bool CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey); - bool GetStakeWeight(const CKeyStore& keystore, uint64& nMinWeight, uint64& nMaxWeight, uint64& nWeight); - bool GetStakeWeight2(const CKeyStore& keystore, uint64& nMinWeight, uint64& nMaxWeight, uint64& nWeight); + bool FinalizeProposal(CTransaction& txProposal); + bool GetStakeWeight(const CKeyStore& keystore, uint64& nMinWeight, uint64& nMaxWeight, uint64& nWeight, uint64& nAmount); bool CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int64 nSearchInterval, CTransaction& txNew); bool GetStakeWeightFromValue(const int64& nTime, const int64& nValue, uint64& nWeight); - std::string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false); - std::string SendMoneyToDestination(const CTxDestination &address, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false); + uint64 GetTimeToNextMaturity(); + std::string SendMoney(CScript scriptPubKey, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false, bool fAllowStakeForCharity=false); + std::string SendMoneyToDestination(const CTxDestination &address, int64 nValue, CWalletTx& wtxNew, bool fAskFee=false, bool fAllowStakeForCharity=false); bool NewKeyPool(); bool TopUpKeyPool(); @@ -304,6 +392,8 @@ class CWallet : public CCryptoKeyStore void FixSpentCoins(int& nMismatchSpent, int64& nBalanceInQuestion, int& nOrphansFound, bool fCheckOnly = false); void DisableTransaction(const CTransaction &tx); + bool SendProposal(const CVoteProposal& proposal, uint256& txid); + /** Address book entry changed. * @note called with lock cs_wallet held. */ @@ -633,7 +723,22 @@ class CWalletTx : public CMerkleTx return (GetDebit() > 0); } - bool IsConfirmed() const + bool IsConfirmedInMainChain() const + { + //presstab - removed code that checks walletdb for confirmation, we want blockchain info only + + // Quick answer in most cases + if (!IsFinal()) + return false; + if (GetDepthInMainChain() >= 1) + return true; + if (!IsFromMe()) // using wtx's cached debit + return false; + + return false; + } + + bool IsConfirmed() const { // Quick answer in most cases if (!IsFinal()) @@ -675,7 +780,7 @@ class CWalletTx : public CMerkleTx } return true; } - + bool WriteToDisk(); int64 GetTxTime() const; diff --git a/src/walletdb.cpp b/src/walletdb.cpp index ad2417203..e16a91b73 100644 --- a/src/walletdb.cpp +++ b/src/walletdb.cpp @@ -12,7 +12,6 @@ using namespace boost; static uint64 nAccountingEntryNumber = 0; -extern bool fWalletUnlockMintOnly; // // CWalletDB @@ -53,6 +52,17 @@ bool CWalletDB::WriteAccountingEntry(const CAccountingEntry& acentry) return WriteAccountingEntry(++nAccountingEntryNumber, acentry); } +bool CWalletDB::ReadVoteObject(const string& strVoteObject, CVoteObject& voteObject) +{ + voteObject.SetNull(); + return Read(make_pair(string("vote"), strVoteObject), voteObject); +} + +bool CWalletDB::WriteVoteObject(const string& strVoteObject, const CVoteObject& voteObject) +{ + return Write(make_pair(string("vote"), strVoteObject), voteObject, true); +} + int64 CWalletDB::GetAccountCreditDebit(const string& strAccount) { list entries; @@ -73,7 +83,7 @@ void CWalletDB::ListAccountCreditDebit(const string& strAccount, list> pwallet->nOrderPosNext; + } + else if (strType == "stakeSplitThreshold") //presstab HyperStake + { + ssValue >> pwallet->nStakeSplitThreshold; + } + else if (strType == "multisend") //presstab HyperStake + { + unsigned int i; + ssKey >> i; + std::pair pMultiSend; + ssValue >> pMultiSend; + if(CBitcoinAddress(pMultiSend.first).IsValid()) + { + pwallet->vMultiSend.push_back(pMultiSend); + } + } + else if(strType == "msettings")//presstab HyperStake + { + std::pair pSettings; + ssValue >> pSettings; + pwallet->fMultiSend = pSettings.first; + pwallet->nLastMultiSendHeight = pSettings.second; + } + else if (strType == "mcoinstake") + { + bool fMultiSendCoinStake; + ssValue >> fMultiSendCoinStake; + pwallet->fMultiSendCoinStake = fMultiSendCoinStake; + } + else if(strType == "mdisabled")//presstab HyperStake + { + std::string strDisabledAddress; + ssValue >> strDisabledAddress; + pwallet->vDisabledAddresses.push_back(strDisabledAddress); + } + else if(strType == "hashdrift")//presstab HyperStake + { + unsigned int nHashDrift; + ssValue >> nHashDrift; + pwallet->nHashDrift = nHashDrift; + } + else if(strType == "hashinterval")//presstab HyperStake + { + unsigned int nHashInterval; + ssValue >> nHashInterval; + pwallet->nHashInterval = nHashInterval; + } + else if(strType == "combinedust")//presstab HyperStake + { + bool fCombineDust; + ssValue >> fCombineDust; + pwallet->fCombineDust = fCombineDust; + } + else if (strType == "vote") + { + std::string strHash; + ssKey >> strHash; + uint256 hash(strHash); + CVoteObject vote; + ssValue >> vote; + pwallet->mapVoteObjects[hash] = vote; } } catch (...) { @@ -414,7 +485,7 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet) return DB_CORRUPT; } - loop + while (true) { // Read next record CDataStream ssKey(SER_DISK, CLIENT_VERSION); @@ -536,7 +607,7 @@ void ThreadFlushWalletDB(void* parg) bitdb.CheckpointLSN(strFile); bitdb.mapFileUseCount.erase(mi++); - printf("Flushed wallet.dat %"PRI64d"ms\n", GetTimeMillis() - nStart); + printf("Flushed wallet.dat %lldms\n", GetTimeMillis() - nStart); } } } @@ -597,7 +668,7 @@ bool CWalletDB::Recover(CDBEnv& dbenv, std::string filename, bool fOnlyKeys) // Set -rescan so any missing transactions will be // found. int64 now = GetTime(); - std::string newFilename = strprintf("wallet.%"PRI64d".bak", now); + std::string newFilename = strprintf("wallet.%lld.bak", now); int result = dbenv.dbenv.dbrename(NULL, filename.c_str(), NULL, newFilename.c_str(), DB_AUTO_COMMIT); @@ -616,7 +687,7 @@ bool CWalletDB::Recover(CDBEnv& dbenv, std::string filename, bool fOnlyKeys) printf("Salvage(aggressive) found no records in %s.\n", newFilename.c_str()); return false; } - printf("Salvage(aggressive) found %"PRIszu" records\n", salvagedData.size()); + printf("Salvage(aggressive) found %lu records\n", salvagedData.size()); bool fSuccess = allOK; Db* pdbCopy = new Db(&dbenv.dbenv, 0); diff --git a/src/walletdb.h b/src/walletdb.h index a3e779ab9..58d547d7c 100644 --- a/src/walletdb.h +++ b/src/walletdb.h @@ -7,6 +7,7 @@ #include "db.h" #include "base58.h" +#include "voteobject.h" class CKeyPool; class CAccount; @@ -97,7 +98,95 @@ class CWalletDB : public CDB nWalletDBUpdated++; return Write(std::string("orderposnext"), nOrderPosNext); } - + // presstab HyperStake + bool WriteStakeSplitThreshold(uint64 nStakeSplitThreshold) + { + nWalletDBUpdated++; + return Write(std::string("stakeSplitThreshold"), nStakeSplitThreshold); + } + //presstab HyperStake + bool WriteMultiSend(std::vector > vMultiSend) + { + nWalletDBUpdated++; + bool ret = true; + for(unsigned int i = 0; i < vMultiSend.size(); i++) + { + std::pair pMultiSend; + pMultiSend = vMultiSend[i]; + if(!Write(std::make_pair(std::string("multisend"), i), pMultiSend, true)) + ret = false; + } + return ret; + } + //presstab HyperStake + bool EraseMultiSend(std::vector > vMultiSend) + { + nWalletDBUpdated++; + bool ret = true; + for(unsigned int i = 0; i < vMultiSend.size(); i++) + { + std::pair pMultiSend; + pMultiSend = vMultiSend[i]; + if(!Erase(std::make_pair(std::string("multisend"), i))) + ret = false; + } + return ret; + } + //presstab HyperStake + bool WriteMSettings(bool fEnable, int nLastMultiSendHeight) + { + nWalletDBUpdated++; + std::pair pSettings; + pSettings.first = fEnable; + pSettings.second = nLastMultiSendHeight; + return Write(std::string("msettings"), pSettings, true); + } + bool WriteMCoinStake(bool fMultiSendCoinStake) + { + nWalletDBUpdated++; + return Write(std::string("mcoinstake"), fMultiSendCoinStake, true); + } + //presstab HyperStake + bool WriteMSDisabledAddresses(std::vector vDisabledAddresses) + { + nWalletDBUpdated++; + bool ret = true; + for(unsigned int i = 0; i < vDisabledAddresses.size(); i++) + { + if(!Write(std::make_pair(std::string("mdisabled"), i), vDisabledAddresses[i])) + ret = false; + } + return ret; + } + //presstab HyperStake + bool EraseMSDisabledAddresses(std::vector vDisabledAddresses) + { + nWalletDBUpdated++; + bool ret = true; + for(unsigned int i = 0; i < vDisabledAddresses.size(); i++) + { + if(!Erase(std::make_pair(std::string("mdisabled"), i))) + ret = false; + } + return ret; + } + //presstab HyperStake + bool WriteHashDrift(unsigned int nHashDrift) + { + nWalletDBUpdated++; + return Write(std::string("hashdrift"), nHashDrift, true); + } + //presstab HyperStake + bool WriteHashInterval(unsigned int nHashInterval) + { + nWalletDBUpdated++; + return Write(std::string("hashinterval"), nHashInterval, true); + } + bool WriteCombineDust(bool fCombineDust) + { + nWalletDBUpdated++; + return Write(std::string("combinedust"), fCombineDust, true); + } bool WriteDefaultKey(const CPubKey& vchPubKey) { nWalletDBUpdated++; @@ -147,6 +236,9 @@ class CWalletDB : public CDB bool ReadAccount(const std::string& strAccount, CAccount& account); bool WriteAccount(const std::string& strAccount, const CAccount& account); + + bool ReadVoteObject(const std::string& strVoteObject, CVoteObject& voteObject); + bool WriteVoteObject(const std::string& strVoteObject, const CVoteObject& voteObject); private: bool WriteAccountingEntry(const uint64 nAccEntryNum, const CAccountingEntry& acentry); public: