#!/bin/bash ############################################################################### # Copyright (c) 2014-2023 libbitcoin-explorer developers (see COPYING). # # GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY # ############################################################################### # Script to build and install libbitcoin-explorer. # # Script options: # --with-icu Compile with International Components for Unicode. # Since the addition of BIP-39 and later BIP-38 # support, libbitcoin conditionally incorporates ICU # to provide BIP-38 and BIP-39 passphrase # normalization features. Currently # libbitcoin-explorer is the only other library that # accesses this feature, so if you do not intend to # use passphrase normalization this dependency can # be avoided. # --build-icu Builds ICU libraries. # --build-boost Builds Boost libraries. # --build-zmq Builds ZeroMQ libraries. # --build-dir= Location of downloaded and intermediate files. # --prefix= Library install location (defaults to /usr/local). # --disable-shared Disables shared library builds. # --disable-static Disables static library builds. # --verbose Display verbose output (defaults to quiet on called tooling). # --help Display usage, overriding script execution. # # Verified on Ubuntu 14.04, requires gcc-4.8 or newer. # Verified on OSX 10.10, using MacPorts and Homebrew repositories, requires # Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn) or newer. # This script does not like spaces in the --prefix or --build-dir, sorry. # Values (e.g. yes|no) in the '--disable-' options are not supported. # All command line options are passed to 'configure' of each repo, with # the exception of the --build- options, which are for the script only. # Depending on the caller's permission to the --prefix or --build-dir # directory, the script may need to be sudo'd. # Define constants. #============================================================================== # Sentinel for comparison of sequential build. #------------------------------------------------------------------------------ SEQUENTIAL=1 # Git clone parameters. #------------------------------------------------------------------------------ if [[ $GIT_CLONE_PARAMS ]]; then display_message "Using shell-defined GIT_CLONE_PARAMS value." else GIT_CLONE_PARAMS="--depth 1 --single-branch" fi # The default build directory. #------------------------------------------------------------------------------ BUILD_DIR="build-libbitcoin-explorer" PRESUMED_CI_PROJECT_PATH=$(pwd) # ICU archive. #------------------------------------------------------------------------------ ICU_URL="https://github.com/unicode-org/icu/releases/download/release-55-2/icu4c-55_2-src.tgz" ICU_ARCHIVE="icu4c-55_2-src.tgz" # ZMQ archive. #------------------------------------------------------------------------------ ZMQ_URL="https://github.com/zeromq/libzmq/releases/download/v4.3.4/zeromq-4.3.4.tar.gz" ZMQ_ARCHIVE="zeromq-4.3.4.tar.gz" # Boost archive. #------------------------------------------------------------------------------ BOOST_URL="http://downloads.sourceforge.net/project/boost/boost/1.73.0/boost_1_73_0.tar.bz2" BOOST_ARCHIVE="boost_1_73_0.tar.bz2" # Define utility functions. #============================================================================== configure_links() { # Configure dynamic linker run-time bindings when installing to system. if [[ ($OS == Linux) && ($PREFIX == "/usr/local") ]]; then ldconfig fi } configure_options() { display_message "configure options:" for OPTION in "$@"; do if [[ $OPTION ]]; then display_message "$OPTION" fi done ./configure "$@" } create_directory() { local DIRECTORY="$1" rm -rf "$DIRECTORY" mkdir "$DIRECTORY" } display_heading_message() { printf "\n********************** %s **********************\n" "$@" } display_message() { printf "%s\n" "$@" } display_error() { >&2 printf "%s\n" "$@" } initialize_git() { display_heading_message "Initialize git" # Initialize git repository at the root of the current directory. git init git config user.name anonymous } # make_project_directory project_name jobs [configure_options] make_project_directory() { local PROJ_NAME=$1 local JOBS=$2 local TEST=$3 shift 3 push_directory "$PROJ_NAME" local PROJ_CONFIG_DIR PROJ_CONFIG_DIR=$(pwd) ./autogen.sh configure_options "$@" make_jobs "$JOBS" if [[ $TEST == true ]]; then make_tests "$JOBS" fi make install configure_links pop_directory } # make_jobs jobs [make_options] make_jobs() { local JOBS=$1 shift 1 VERBOSITY="" if [[ DISPLAY_VERBOSE ]]; then VERBOSITY="VERBOSE=1" fi SEQUENTIAL=1 # Avoid setting -j1 (causes problems on single threaded systems [TRAVIS]). if [[ $JOBS > $SEQUENTIAL ]]; then make -j"$JOBS" "$@" $VERBOSITY else make "$@" $VERBOSITY fi } # make_tests jobs make_tests() { local JOBS=$1 disable_exit_on_error # Build and run unit tests relative to the primary directory. # VERBOSE=1 ensures test runner output sent to console (gcc). make_jobs "$JOBS" check "VERBOSE=1" local RESULT=$? # Test runners emit to the test.log file. if [[ -e "test.log" ]]; then cat "test.log" fi if [[ $RESULT -ne 0 ]]; then exit $RESULT fi enable_exit_on_error } pop_directory() { popd >/dev/null } push_directory() { local DIRECTORY="$1" pushd "$DIRECTORY" >/dev/null } enable_exit_on_error() { set -e } disable_exit_on_error() { set +e } display_help() { display_message "Usage: ./install.sh [OPTION]..." display_message "Manage the installation of libbitcoin-explorer." display_message "Script options:" display_message " --with-icu Compile with International Components for Unicode." display_message " Since the addition of BIP-39 and later BIP-38 " display_message " support, libbitcoin conditionally incorporates ICU " display_message " to provide BIP-38 and BIP-39 passphrase " display_message " normalization features. Currently " display_message " libbitcoin-explorer is the only other library that " display_message " accesses this feature, so if you do not intend to " display_message " use passphrase normalization this dependency can " display_message " be avoided." display_message " --build-icu Builds ICU libraries." display_message " --build-boost Builds Boost libraries." display_message " --build-zmq Build ZeroMQ libraries." display_message " --build-dir= Location of downloaded and intermediate files." display_message " --prefix= Library install location (defaults to /usr/local)." display_message " --disable-shared Disables shared library builds." display_message " --disable-static Disables static library builds." display_message " --help Display usage, overriding script execution." display_message "" display_message "All unrecognized options provided shall be passed as configuration options for " display_message "all dependencies." } # Define environment initialization functions #============================================================================== parse_command_line_options() { for OPTION in "$@"; do case $OPTION in # Standard script options. (--help) DISPLAY_HELP="yes";; (--verbose) DISPLAY_VERBOSE="yes";; # Standard build options. (--prefix=*) PREFIX="${OPTION#*=}";; (--disable-shared) DISABLE_SHARED="yes";; (--disable-static) DISABLE_STATIC="yes";; # Common project options. (--with-icu) WITH_ICU="yes";; # Custom build options (in the form of --build-