void-packages/srcpkgs/j/template

141 lines
3.9 KiB
Bash
Raw Normal View History

2019-09-27 08:41:02 +00:00
# Template file for 'j'
pkgname=j
2019-12-17 09:42:24 +00:00
_vmaj=901
2020-01-30 05:15:00 +00:00
_vmin=e
2019-12-17 09:42:24 +00:00
_vrel=${_vmaj}-release${_vmin:+-}${_vmin}
version=${_vmaj}.${_vmin}
revision=5
archs="aarch64* armv[67]* i686* x86_64*"
2019-12-17 09:42:24 +00:00
wrksrc="jsource-j${_vrel}"
2019-09-27 08:41:02 +00:00
makedepends="libedit-devel libgomp-devel libomp-devel"
short_desc="Modern, high-performance, ASCII-based successor to APL"
maintainer="B. Wilson <x@wilsonb.com>"
license="GPL-3.0-or-later"
homepage="https://jsoftware.com/"
2019-12-17 09:42:24 +00:00
distfiles="https://github.com/jsoftware/jsource/archive/j${_vrel}.tar.gz"
2020-01-30 05:15:00 +00:00
checksum=23d1cac75ae8426d4e301b178fac1f29e85d7a0c80cefe4740c104d9c1eeab7a
2019-09-27 08:41:02 +00:00
_jsz="j${XBPS_TARGET_WORDSIZE}"
_jtype="release"
_jbuilder="voidlinux.org"
_jlib="/usr/lib/j"
_jshare="/usr/share/j"
_jetc="/etc/j"
_juser=".j"
case "${XBPS_TARGET_MACHINE}" in
aarch64*|arm*) _jpl="raspberry";;
*) _jpl="linux";;
2019-09-27 08:41:02 +00:00
esac
case "${XBPS_TARGET_MACHINE}" in
*-musl) makedepends+=" musl-fts-devel";;
2019-09-27 08:41:02 +00:00
esac
2020-01-21 01:51:34 +00:00
do_configure() {
cp jsrc/jversion-x.h jsrc/jversion.h
vsed -i "/jplatform/s@unknown@${_jpl}@;
/jtype/s@beta@${_jtype}-${_vmin}@;
/jbuilder/s@unknown@${_jbuilder}@" \
jsrc/jversion.h
# Remove version directory component from "~install" and "~user" paths
cp jlibrary/bin/profile.ijs jlibrary/bin/profile.ijs.new
vsed -i "/^install=./s@/usr/share/j/[0-9.]\+@${_jshare}@;
/^user=./s@home,userx@home,'/${_juser}'@" \
jlibrary/bin/profile.ijs.new
# Munge the build scripts into reason:
# 1) Short-circut their fragile compiler detection to directly use gcc;
# 2) Make sure they pick up our CFLAGS and LDFLAGS; and
# 3) Ensure they propogate errors to do_build()
vsed -i '/^compiler/s/=.*/=gcc/;
/^common="\$common/n;
/^common/s/="/&$CFLAGS /;
/^LDFLAGS/s/="/&$LDFLAGS /;
/^#!/a\set -o errexit' \
make2/build_jconsole.sh make2/build_libj.sh
2020-01-21 01:51:34 +00:00
}
2019-09-27 08:41:02 +00:00
2020-01-21 01:51:34 +00:00
##
# Crossbuilds do not distinguish between AVX- and non-AVX targets, so instead
# we build all applicable binaries and install a wrapper script that executes
# the correct one on the target machine.
2020-01-21 01:51:34 +00:00
do_build() {
cd make2 # The build scripts assume this is $PWD
export USE_OPENMP=1
jplatform=${_jpl} j64x=${_jsz} ./build_jconsole.sh
jplatform=${_jpl} j64x=${_jsz} ./build_libj.sh
2019-09-27 08:41:02 +00:00
2020-01-21 01:51:34 +00:00
if [ "${_jsz}" = 'j64' ]; then
jplatform=${_jpl} j64x=${_jsz}avx ./build_jconsole.sh
jplatform=${_jpl} j64x=${_jsz}avx ./build_libj.sh
2019-09-27 08:41:02 +00:00
jplatform=${_jpl} j64x=${_jsz}avx2 ./build_jconsole.sh
jplatform=${_jpl} j64x=${_jsz}avx2 ./build_libj.sh
2020-01-21 01:51:34 +00:00
fi
2019-09-27 08:41:02 +00:00
}
do_check() {
2020-01-21 01:51:34 +00:00
if [ -d "${_jlib}/j64avx2" ] \
&& sed -n '/^flags/{s/\<avx2\>//;t;q1}' /proc/cpuinfo; then
javx='avx2'
elif [ -d "${_jlib}/j64avx" ] \
&& sed -n '/^flags/{s/\<avx\>//;t;q1}' /proc/cpuinfo; then
javx='avx'
else
javx=''
2019-09-27 08:41:02 +00:00
fi
2020-01-21 01:51:34 +00:00
mkdir -p test/bin
cp -r jlibrary/addons test/bin
cp -r jlibrary/system test/bin
cp -r jlibrary/tools test/bin
cp -r "bin/${_jpl}/${_jsz}${javx}" test/bin
cp jlibrary/bin/profile.ijs "test/bin/${_jsz}${javx}"
2020-01-21 01:51:34 +00:00
echo 'RECHO ddall' | "test/bin/${_jsz}${javx}/jconsole" test/tsu.ijs
2020-01-21 01:51:34 +00:00
}
##
# Script to detect AVX/AVX2 support and launch appropriate jconsole binary
_jconsole_wrapper_script() {
cat <<JC
#!/usr/bin/env sh
cpu_has_avx() { sed -n '/^flags/{s/\<avx\>//;t;q1}' /proc/cpuinfo; }
cpu_has_avx2() { sed -n '/^flags/{s/\<avx2\>//;t;q1}' /proc/cpuinfo; }
if [ -d "${_jlib}/j64avx2" ] && cpu_has_avx2; then
javx='avx2'
elif [ -d "${_jlib}/j64avx" ] && cpu_has_avx; then
javx='avx'
elif [ -d "${_jlib}/j64" ]; then
javx=''
else
>&2 echo "\${0}: Cannot find jconsole executable"
exit 1
fi
exec ${_jlib}/${_jsz}\${javx}/jconsole -jprofile "${_jetc}/profile.ijs" "\${@}"
2020-01-21 01:51:34 +00:00
JC
2019-09-27 08:41:02 +00:00
}
do_install() {
vmkdir "${_jshare}" 0755
vcopy jlibrary/system "${_jshare}"
vcopy jlibrary/tools "${_jshare}"
vmkdir "${_jlib}" 0755
2020-01-21 01:51:34 +00:00
vcopy "bin/${_jpl}/*" "${_jlib}"
2019-09-27 08:41:02 +00:00
vmkdir "${_jetc}" 0755
vinstall "${FILESDIR}/profilex_template.ijs" 644 "${_jetc}"
vinstall "jlibrary/bin/profile.ijs.new" 644 "${_jetc}" profile.ijs
2019-09-27 08:41:02 +00:00
2020-01-21 01:51:34 +00:00
_jconsole_wrapper_script >bin/jc.sh
vbin "bin/jc.sh" jc
2019-09-27 08:41:02 +00:00
}