2018-11-21 03:17:47 +01:00
TERMUX_PKG_HOMEPAGE = https://nim-lang.org/
TERMUX_PKG_DESCRIPTION = "Nim programming language compiler"
2019-01-31 12:44:02 +01:00
TERMUX_PKG_LICENSE = "MIT"
2019-02-09 01:03:11 +01:00
TERMUX_PKG_VERSION = 0.19.4
TERMUX_PKG_SHA256 = f441135ee311099be81a46dba5bab3323579cd18aabc6e079b9697a71d6ca94c
2018-11-21 03:17:47 +01:00
TERMUX_PKG_SRCURL = https://nim-lang.org/download/nim-$TERMUX_PKG_VERSION .tar.xz
2019-01-31 12:46:37 +01:00
TERMUX_PKG_DEPENDS = "clang, git, libandroid-glob"
2018-11-21 03:17:47 +01:00
TERMUX_PKG_HOSTBUILD = yes
TERMUX_PKG_BUILD_IN_SRC = yes
termux_step_host_build( ) {
2019-01-31 12:46:37 +01:00
cp -r ../src/* ./
2018-11-21 03:17:47 +01:00
make -j $TERMUX_MAKE_PROCESSES CC = gcc LD = gcc
}
termux_step_make( ) {
2019-01-31 12:46:37 +01:00
if [ $TERMUX_ARCH = "x86_64" ] ; then
2018-11-21 03:17:47 +01:00
export NIM_ARCH = amd64
elif [ $TERMUX_ARCH = "i686" ] ; then
export NIM_ARCH = i386
elif [ $TERMUX_ARCH = "aarch64" ] ; then
2019-01-31 12:46:37 +01:00
# -Oz breaks aarch64 build
2018-11-21 03:17:47 +01:00
CFLAGS += " -Os"
2019-01-31 12:46:37 +01:00
export NIM_ARCH = arm64
else
2018-11-21 03:17:47 +01:00
export NIM_ARCH = arm
fi
LDFLAGS += " -landroid-glob"
sed -i " s%\@CC\@% ${ CC } %g " config/nim.cfg
sed -i " s%\@CFLAGS\@% ${ CFLAGS } %g " config/nim.cfg
sed -i " s%\@LDFLAGS\@% ${ LDFLAGS } %g " config/nim.cfg
2019-01-31 12:46:37 +01:00
sed -i " s%\@CPPFLAGS\@% ${ CPPFLAGS } %g " config/nim.cfg
2018-11-21 03:17:47 +01:00
find -name "stdlib_osproc.c" | xargs -n 1 sed -i 's' ,"/system/bin/sh\"\,\ 14" ,"/data/data/com.termux/files/usr/bin/sh\"\,\ 38" ,'g'
PATH = $TERMUX_PKG_HOSTBUILD_DIR /bin:$PATH
if [ $NIM_ARCH = "amd64" ] ; then
sed -i 's/arm64/amd64/g' makefile
fi
export CFLAGS = " $CPPFLAGS $CFLAGS -w -fno-strict-aliasing "
2019-01-31 12:46:37 +01:00
make LD = $CC uos = linux mycpu = $NIM_ARCH myos = android -j $TERMUX_MAKE_PROCESSES useShPath = $TERMUX_PREFIX /bin/sh
2018-11-21 03:17:47 +01:00
cp config/nim.cfg ../host-build/config
2019-01-31 12:46:37 +01:00
2018-11-21 03:17:47 +01:00
nim --opt:size --define:termux -d:release --os:android --cpu:$NIM_ARCH -t:-I/data/data/com.termux/files/usr/include -l:"-L/data/data/com.termux/files/usr/lib -landroid-glob" c koch.nim
cd dist/nimble/src
nim --define:termux -d:release --os:android --cpu:$NIM_ARCH -t:-I/data/data/com.termux/files/usr/include -l:"-L/data/data/com.termux/files/usr/lib -landroid-glob" c nimble.nim
}
2019-01-31 12:46:37 +01:00
2018-11-21 03:17:47 +01:00
termux_step_make_install( ) {
./install.sh $TERMUX_PREFIX /lib
2019-01-31 12:46:37 +01:00
cp koch $TERMUX_PREFIX /lib/nim/bin/
cp dist/nimble/src/nimble $TERMUX_PREFIX /lib/nim/bin/
ln -sfr $TERMUX_PREFIX /lib/nim/bin/nim $TERMUX_PREFIX /bin/
ln -sfr $TERMUX_PREFIX /lib/nim/bin/koch $TERMUX_PREFIX /bin/
ln -sfr $TERMUX_PREFIX /lib/nim/bin/nimble $TERMUX_PREFIX /bin/
2018-11-21 03:17:47 +01:00
}