2014-10-15 18:48:58 -07:00
#!/bin/bash
2014-12-10 10:09:17 -08:00
exec 2> /dev/null
2015-07-06 15:38:09 -07:00
root_dir = " $( cd " $( dirname " ${ BASH_SOURCE [0] } " ) " && pwd ) /.. "
BITCOIN_DIR = " ${ root_dir } /libbitcoind "
2014-10-15 18:48:58 -07:00
os =
2015-06-24 14:06:27 -07:00
ext = so
2015-07-24 12:31:06 -07:00
2015-07-27 11:03:14 -07:00
host = ` uname -m` -` uname -a | awk '{print tolower($1)}' `
2015-07-28 12:37:10 -07:00
depends_dir = " ${ BITCOIN_DIR } " /depends
h_and_a_dir = " ${ depends_dir } " /" ${ host } "
2014-10-15 18:48:58 -07:00
2015-07-31 12:53:04 -07:00
mac_response =
check_mac_build_system ( ) {
if [ " ${ ext } " = = "dylib" ] ; then
if [ ! -d "/usr/include" ] ; then
if hash xcode-select 2>/dev/null; then
mac_response = "Please run 'xcode-select --install' from the command line because it seems that you've got Xcode, but not the Xcode command line tools that are required for compiling this project from source..."
else
mac_response = "please use the App Store to install Xcode and Xcode command line tools. After Xcode is installed, please run: 'xcode-select --install' from the command line"
fi
fi
fi
}
2014-12-10 10:09:17 -08:00
if test -f /etc/centos-release \
|| grep -q 'CentOS' /etc/redhat-release \
|| rpm -q --queryformat '%{VERSION}' centos-release > /dev/null; then
2014-12-01 23:58:44 -08:00
os = centos
2014-12-10 10:09:17 -08:00
elif grep -q 'Fedora' /etc/system-release; then
2014-12-01 23:58:44 -08:00
os = fedora
2014-12-10 10:09:17 -08:00
elif test -f /etc/redhat_release \
|| test -f /etc/redhat-release; then
2014-12-01 23:58:44 -08:00
os = rhel
2014-12-10 10:13:27 -08:00
elif uname -a | grep -q '^Darwin' ; then
os = osx
2015-06-24 14:06:27 -07:00
ext = dylib
2014-12-10 10:09:17 -08:00
elif test -f /etc/SuSE-release; then
2014-12-01 23:58:44 -08:00
os = suse
2014-12-10 10:09:17 -08:00
elif test -f /etc/mandrake-release \
|| test -f /etc/mandriva-release; then
os = mandriva
2014-12-10 10:13:27 -08:00
elif grep -q 'Linux Mint' /etc/issue; then
os = mint
2014-12-10 10:09:17 -08:00
elif grep -q 'Ubuntu' /etc/issue \
|| grep -q 'Ubuntu' /etc/lsb-release \
|| uname -v | grep -q 'Ubuntu' ; then
2014-12-01 23:58:44 -08:00
os = ubuntu
2014-12-10 10:09:17 -08:00
elif test -f /etc/debian_version \
|| test -f /etc/debian-version; then
os = debian
elif grep -q 'Arch Linux' /etc/issue \
|| test -d /lib/systemd -a " $( readlink /usr/bin/vi) " = 'ex' ; then
2014-10-15 18:48:58 -07:00
os = arch
2014-12-10 10:09:17 -08:00
elif test " $( uname -s) " = 'SunOS' ; then
os = solaris
elif test " $( uname -s) " = 'AIX' ; then
os = aix
elif test -d /system && test -d /data/data; then
os = android
2014-10-15 18:48:58 -07:00
fi
2015-07-06 15:38:09 -07:00
os_dir = ${ root_dir } /platform/${ os }
2015-07-29 14:06:40 -07:00
if [ " ${ os } " = = "osx" ] ; then
artifacts_dir = " ${ os_dir } /lib "
else
artifacts_dir = " ${ os_dir } "
fi
thread = " ${ artifacts_dir } " /lib/libboost_thread-mt.a
filesystem = " ${ artifacts_dir } " /lib/libboost_filesystem-mt.a
2015-08-03 15:37:47 -07:00
chrono = " ${ artifacts_dir } " /lib/libboost_chrono-mt.a
program_options = " ${ artifacts_dir } " /lib/libboost_program_options-mt.a
system = " ${ artifacts_dir } " /lib/libboost_system-mt.a
leveldb = " ${ BITCOIN_DIR } " /src/leveldb/libleveldb.a
memenv = " ${ BITCOIN_DIR } " /src/leveldb/libmemenv.a
libsecp256k1 = " ${ BITCOIN_DIR } " /src/secp256k1/.libs/libsecp256k1.a
2015-07-29 14:06:40 -07:00
2014-12-10 10:13:27 -08:00
if test -z " $os " -o x" $os " = x'android' -o x" $os " = x'aix' ; then
2014-12-10 10:09:17 -08:00
if test " $os " = 'android' -o " $os " = 'aix' ; then
echo 'Android or AIX detected!' >& 2
2014-12-01 23:58:44 -08:00
fi
2014-12-10 10:09:17 -08:00
echo 'OS not supported.' >& 2
exit 1
2014-10-15 18:48:58 -07:00
fi
2014-12-07 02:02:51 -08:00
if test x" $1 " = x'osdir' ; then
echo -n " $( pwd ) /platform/ ${ os } "
exit 0
fi
2015-07-06 15:38:09 -07:00
2015-07-10 14:20:58 -07:00
if test x" $1 " = x'btcdir' ; then
echo -n " ${ BITCOIN_DIR } "
exit 0
fi
2015-07-07 10:51:11 -07:00
if test -z " $1 " -o x" $1 " = x'ext' ; then
echo -n " ${ ext } "
fi
2015-07-06 15:38:09 -07:00
if test -z " $1 " -o x" $1 " = x'thread' ; then
echo -n " ${ thread } "
fi
2015-07-24 12:31:06 -07:00
if test -z " $1 " -o x" $1 " = x'filesystem' ; then
echo -n " ${ filesystem } "
fi
2015-08-03 15:37:47 -07:00
if test -z " $1 " -o x" $1 " = x'program_options' ; then
echo -n " ${ program_options } "
fi
if test -z " $1 " -o x" $1 " = x'system' ; then
echo -n " ${ system } "
fi
if test -z " $1 " -o x" $1 " = x'chrono' ; then
echo -n " ${ chrono } "
fi
2015-07-27 18:15:51 -07:00
if test -z " $1 " -o x" $1 " = x'depends_dir' ; then
echo -n " ${ depends_dir } "
2015-07-24 12:31:06 -07:00
fi
2015-08-03 15:37:47 -07:00
if test -z " $1 " -o x" $1 " = x'leveldb' ; then
echo -n " ${ leveldb } "
fi
if test -z " $1 " -o x" $1 " = x'memenv' ; then
echo -n " ${ memenv } "
fi
if test -z " $1 " -o x" $1 " = x'libsecp256k1' ; then
echo -n " ${ libsecp256k1 } "
fi
2015-07-28 12:37:10 -07:00
if test -z " $1 " -o x" $1 " = x'h_and_a_dir' ; then
echo -n " ${ h_and_a_dir } "
fi
2015-07-27 11:03:14 -07:00
if test -z " $1 " -o x" $1 " = x'host' ; then
echo -n " ${ host } "
fi
2015-08-03 15:37:47 -07:00
if test -z " $1 " -o x" $1 " = x'bdb' ; then
if [ " ${ BITCOINDJS_ENV } " = = "test" ] ; then
echo -n " ${ artifacts_dir } /lib/libdb_cxx.a "
fi
fi
2015-07-27 11:03:14 -07:00
if test -z " $1 " -o x" $1 " = x'load_archive' ; then
if [ " ${ os } " = = "osx" ] ; then
2015-08-03 15:37:47 -07:00
echo -n "-Wl,-all_load -Wl,--no-undefined"
2015-07-27 11:03:14 -07:00
else
2015-08-03 15:37:47 -07:00
echo -n " -Wl,--whole-archive ${ filesystem } ${ thread } " ${ BITCOIN_DIR } "/src/.libs/libbitcoind.a -Wl,--no-whole-archive"
2015-07-27 11:03:14 -07:00
fi
fi
2015-07-29 09:05:01 -07:00
if test -z " $1 " -o x" $1 " = x'artifacts_dir' ; then
2015-07-29 14:06:40 -07:00
echo -n " ${ artifacts_dir } "
2015-07-29 09:05:01 -07:00
fi
2015-07-31 12:53:04 -07:00
if test -z " $1 " -o x" $1 " = x'mac_dependencies' ; then
check_mac_build_system
echo -n " ${ mac_response } "
fi
2015-08-03 15:37:47 -07:00
if test -z " $1 " -o x" $1 " = x'bitcoind' ; then
echo -n " ${ BITCOIN_DIR } " /src/.libs/libbitcoind.a
fi