monero-gui/get_libwallet_api.sh

170 lines
5.8 KiB
Bash
Raw Normal View History

2016-05-17 16:03:59 +03:00
#!/bin/bash
2016-10-09 21:49:56 +03:00
MONERO_URL=https://github.com/monero-project/monero.git
MONERO_BRANCH=master
# MONERO_URL=https://github.com/mbg033/monero.git
# MONERO_BRANCH=develop
# Buidling "debug" build optionally
# default build type
BUILD_TYPE=$1
if [ -z $BUILD_TYPE ]; then
BUILD_TYPE=release
fi
STATIC=false
2017-01-01 06:55:49 +02:00
ANDROID=false
if [ "$BUILD_TYPE" == "release" ]; then
echo "Building libwallet release"
CMAKE_BUILD_TYPE=Release
elif [ "$BUILD_TYPE" == "release-static" ]; then
echo "Building libwallet release-static"
CMAKE_BUILD_TYPE=Release
STATIC=true
2017-01-01 06:55:49 +02:00
elif [ "$BUILD_TYPE" == "release-android" ]; then
echo "Building libwallet release-static for ANDROID"
CMAKE_BUILD_TYPE=Release
STATIC=true
ANDROID=true
elif [ "$BUILD_TYPE" == "debug-android" ]; then
echo "Building libwallet debug-static for ANDROID"
CMAKE_BUILD_TYPE=Debug
STATIC=true
ANDROID=true
elif [ "$BUILD_TYPE" == "debug" ]; then
echo "Building libwallet debug"
CMAKE_BUILD_TYPE=Debug
else
2017-01-01 06:55:49 +02:00
echo "Valid build types are release, release-static, release-android, debug-android and debug"
exit 1;
fi
2016-07-06 16:24:14 +03:00
# thanks to SO: http://stackoverflow.com/a/20283965/4118915
if test -z "$CPU_CORE_COUNT"; then
CPU_CORE_COUNT=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu)
fi
2016-05-17 16:03:59 +03:00
pushd $(pwd)
ROOT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $ROOT_DIR/utils.sh
2016-05-17 16:03:59 +03:00
INSTALL_DIR=$ROOT_DIR/wallet
MONERO_DIR=$ROOT_DIR/monero
2016-05-17 16:03:59 +03:00
# init and update monero submodule
if [ ! -d $MONERO_DIR/src ]; then
git submodule init monero
2016-05-17 16:03:59 +03:00
fi
git submodule update
2016-05-17 16:03:59 +03:00
echo "cleaning up existing monero build dir, libs and includes"
rm -fr $MONERO_DIR/build
rm -fr $MONERO_DIR/lib
rm -fr $MONERO_DIR/include
2016-12-09 10:42:12 +02:00
rm -fr $MONERO_DIR/bin
mkdir -p $MONERO_DIR/build/release
pushd $MONERO_DIR/build/release
2016-05-17 16:03:59 +03:00
# reusing function from "utils.sh"
platform=$(get_platform)
2016-11-23 23:30:36 +02:00
# default make executable
make_exec="make"
## OS X
if [ "$platform" == "darwin" ]; then
echo "Configuring build for MacOS.."
if [ "$STATIC" == true ]; then
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D BUILD_GUI_DEPS=ON -D INSTALL_VENDORED_LIBUNBOUND=ON -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" ../..
else
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D BUILD_GUI_DEPS=ON -D INSTALL_VENDORED_LIBUNBOUND=ON -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" ../..
fi
## LINUX 64
2016-12-15 15:56:33 +02:00
elif [ "$platform" == "linux64" ]; then
2016-12-21 08:23:05 +02:00
echo "Configuring build for Linux x64"
2017-01-01 06:55:49 +02:00
if [ "$ANDROID" == true ]; then
echo "Configuring build for Android on Linux host"
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D STATIC=ON -D ARCH="armv7-a" -D ANDROID=true -D BUILD_GUI_DEPS=ON -D USE_LTO=OFF -D INSTALL_VENDORED_LIBUNBOUND=ON -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" ../..
elif [ "$STATIC" == true ]; then
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D STATIC=ON -D ARCH="x86-64" -D BUILD_64=ON -D BUILD_GUI_DEPS=ON -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" ../..
else
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D BUILD_GUI_DEPS=ON -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" ../..
fi
## LINUX 32
2016-12-15 15:56:33 +02:00
elif [ "$platform" == "linux32" ]; then
2016-12-21 08:23:05 +02:00
echo "Configuring build for Linux i686"
if [ "$STATIC" == true ]; then
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D STATIC=ON -D ARCH="i686" -D BUILD_64=OFF -D BUILD_GUI_DEPS=ON -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" ../..
else
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D BUILD_GUI_DEPS=ON -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" ../..
fi
## LINUX other (arm7 for example)
2016-12-21 08:23:05 +02:00
elif [ "$platform" == "linux" ]; then
echo "Configuring build for Linux general"
if [ "$STATIC" == true ]; then
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D STATIC=ON -D BUILD_GUI_DEPS=ON -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" ../..
else
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D BUILD_GUI_DEPS=ON -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" ../..
fi
## Windows 64
## Windows is always static to work outside msys2
elif [ "$platform" == "mingw64" ]; then
2016-07-01 15:02:19 +03:00
# Do something under Windows NT platform
echo "Configuring build for MINGW64.."
2016-12-18 15:07:02 +02:00
BOOST_ROOT=/mingw64/boost
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D STATIC=ON -D BOOST_ROOT="$BOOST_ROOT" -D ARCH="x86-64" -D BUILD_GUI_DEPS=ON -D INSTALL_VENDORED_LIBUNBOUND=ON -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" -G "MSYS Makefiles" ../..
## Windows 32
elif [ "$platform" == "mingw32" ]; then
2016-07-01 15:02:19 +03:00
# Do something under Windows NT platform
echo "Configuring build for MINGW32.."
2016-12-18 15:07:02 +02:00
BOOST_ROOT=/mingw32/boost
cmake -D CMAKE_BUILD_TYPE=$CMAKE_BUILD_TYPE -D STATIC=ON -D Boost_DEBUG=ON -D BOOST_ROOT="$BOOST_ROOT" -D ARCH="i686" -D BUILD_64=OFF -D BUILD_GUI_DEPS=ON -D INSTALL_VENDORED_LIBUNBOUND=ON -D CMAKE_INSTALL_PREFIX="$MONERO_DIR" -G "MSYS Makefiles" ../..
2016-11-23 23:30:36 +02:00
make_exec="mingw32-make"
else
echo "Unsupported platform: $platform"
popd
exit 1
2016-07-01 15:02:19 +03:00
fi
2016-05-17 16:03:59 +03:00
2016-12-09 10:42:12 +02:00
# Build libwallet_merged
pushd $MONERO_DIR/build/release/src/wallet
2016-11-23 23:30:36 +02:00
eval $make_exec version -C ../..
eval $make_exec -j$CPU_CORE_COUNT
eval $make_exec install -j$CPU_CORE_COUNT
2016-05-17 16:03:59 +03:00
popd
2016-09-03 13:06:44 +03:00
2016-12-09 10:42:12 +02:00
# Build monerod
# win32 need to build daemon manually with msys2 toolchain
2017-01-01 06:55:49 +02:00
if [ "$platform" != "mingw32" ] && [ "$ANDROID" != true ]; then
pushd $MONERO_DIR/build/release/src/daemon
eval make -j$CPU_CORE_COUNT
eval make install -j$CPU_CORE_COUNT
popd
fi
2016-12-09 10:42:12 +02:00
2016-09-03 13:06:44 +03:00
# unbound is one more dependency. can't be merged to the wallet_merged
# since filename conflict (random.c.obj)
2016-09-19 17:55:34 +03:00
# for Linux, we use libunbound shipped with the system, so we don't need to build it
2017-01-01 06:55:49 +02:00
if [ "$platform" != "linux32" ] && ([ "$ANDROID" == true ] || [ "$platform" != "linux64" ]); then
echo "Building libunbound..."
pushd $MONERO_DIR/build/release/external/unbound
# no need to make, it was already built as dependency for libwallet
# make -j$CPU_CORE_COUNT
2016-12-04 21:03:24 +02:00
$make_exec install -j$CPU_CORE_COUNT
popd
fi
2016-09-03 13:06:44 +03:00
2017-01-01 06:55:49 +02:00
popd