build-package.sh: add function for setting up GHC

This commit is contained in:
Leonid Pliushch 2020-06-20 22:43:34 +03:00
parent 79cc841782
commit 2f58b9f435
2 changed files with 38 additions and 0 deletions

View File

@ -41,6 +41,10 @@ source "$TERMUX_SCRIPTDIR/scripts/build/termux_error_exit.sh"
# shellcheck source=scripts/build/termux_download.sh
source "$TERMUX_SCRIPTDIR/scripts/build/termux_download.sh"
# Utility function for setting up GHC toolchain.
# shellcheck source=scripts/build/setup/termux_setup_ghc.sh
source "$TERMUX_SCRIPTDIR/scripts/build/setup/termux_setup_ghc.sh"
# Utility function for golang-using packages to setup a go toolchain.
# shellcheck source=scripts/build/setup/termux_setup_golang.sh
source "$TERMUX_SCRIPTDIR/scripts/build/setup/termux_setup_golang.sh"

View File

@ -0,0 +1,34 @@
# Utility function to setup a GHC toolchain.
termux_setup_ghc() {
if [ "$TERMUX_ON_DEVICE_BUILD" = "false" ]; then
local TERMUX_GHC_VERSION=8.10.1
local TERMUX_GHC_TEMP_FOLDER="${TERMUX_COMMON_CACHEDIR}/ghc-${TERMUX_GHC_VERSION}"
local TERMUX_GHC_RUNTIME_FOLDER="${TERMUX_COMMON_CACHEDIR}/ghc-${TERMUX_GHC_VERSION}-runtime"
local TERMUX_GHC_TAR="${TERMUX_GHC_TEMP_FOLDER}.tar.xz"
export PATH="$TERMUX_GHC_RUNTIME_FOLDER/bin:$PATH"
if [ -d "$TERMUX_GHC_RUNTIME_FOLDER" ]; then return; fi
termux_download "https://downloads.haskell.org/~ghc/${TERMUX_GHC_VERSION}/ghc-${TERMUX_GHC_VERSION}-x86_64-deb10-linux.tar.xz" \
"$TERMUX_GHC_TAR" \
c1e31d798b013699b3c0de4fda27fb4cda47f572df0e75e3bd598a3012060615
rm -Rf "$TERMUX_GHC_TEMP_FOLDER"
tar xf "$TERMUX_GHC_TAR" -C "$TERMUX_COMMON_CACHEDIR"
(set -e
unset CC CXX CFLAGS CXXFLAGS CPPFLAGS LDFLAGS AR AS CPP LD RANLIB READELF STRIP
cd "$TERMUX_GHC_TEMP_FOLDER"
./configure --prefix="$TERMUX_GHC_RUNTIME_FOLDER"
make install
)
rm -Rf "$TERMUX_GHC_TEMP_FOLDER"
else
if [ "$(dpkg-query -W -f '${db:Status-Status}\n' ghc 2>/dev/null)" != "installed" ]; then
echo "Package 'ghc' is not installed."
exit 1
fi
fi
}