2018-07-21 02:44:44 +02:00
|
|
|
{ stdenv, makeStaticLibraries,
|
2018-03-03 07:28:08 +01:00
|
|
|
coreutils, rsync, bash,
|
2019-09-22 09:38:09 +02:00
|
|
|
openssl, zlib, sqlite, libxml2, libyaml, libmysqlclient, lmdb, leveldb, postgresql,
|
2018-11-19 15:14:15 +01:00
|
|
|
version, git-version, gambit, src }:
|
2018-03-03 07:28:08 +01:00
|
|
|
|
|
|
|
# TODO: distinct packages for gerbil-release and gerbil-devel
|
|
|
|
# TODO: make static compilation work
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-13 23:52:01 +02:00
|
|
|
pname = "gerbil";
|
|
|
|
inherit version;
|
2018-11-19 15:14:15 +01:00
|
|
|
inherit src;
|
2018-03-03 07:28:08 +01:00
|
|
|
|
|
|
|
# Use makeStaticLibraries to enable creation of statically linked binaries
|
2019-09-22 09:38:09 +02:00
|
|
|
buildInputs_libraries = [ openssl zlib sqlite libxml2 libyaml libmysqlclient lmdb leveldb postgresql ];
|
2018-03-03 07:28:08 +01:00
|
|
|
buildInputs_staticLibraries = map makeStaticLibraries buildInputs_libraries;
|
|
|
|
|
2018-11-19 15:14:15 +01:00
|
|
|
buildInputs = [ gambit rsync bash ]
|
2018-03-03 07:28:08 +01:00
|
|
|
++ buildInputs_libraries ++ buildInputs_staticLibraries;
|
|
|
|
|
2019-09-22 09:38:09 +02:00
|
|
|
NIX_CFLAGS_COMPILE = [ "-I${libmysqlclient}/include/mysql" "-L${libmysqlclient}/lib/mysql" ];
|
2018-03-03 07:28:08 +01:00
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
echo '(define (gerbil-version-string) "v${git-version}")' > src/gerbil/runtime/gx-version.scm
|
|
|
|
|
|
|
|
patchShebangs .
|
|
|
|
|
2018-12-26 01:41:15 +01:00
|
|
|
grep -Fl '#!/usr/bin/env' `find . -type f -executable` | while read f ; do
|
2018-03-03 07:28:08 +01:00
|
|
|
substituteInPlace "$f" --replace '#!/usr/bin/env' '#!${coreutils}/bin/env'
|
|
|
|
done
|
2018-12-26 01:41:15 +01:00
|
|
|
grep -Fl '"gsc"' `find . -type f -name '*.s*'` | while read f ; do
|
|
|
|
substituteInPlace "$f" --replace '"gsc"' '"${gambit}/bin/gsc"'
|
|
|
|
done
|
|
|
|
substituteInPlace "etc/gerbil.el" --replace '"gxc"' "\"$out/bin/gxc\""
|
2018-03-03 07:28:08 +01:00
|
|
|
|
|
|
|
cat > etc/gerbil_static_libraries.sh <<EOF
|
|
|
|
#OPENSSL_LIBCRYPTO=${makeStaticLibraries openssl}/lib/libcrypto.a # MISSING!
|
|
|
|
#OPENSSL_LIBSSL=${makeStaticLibraries openssl}/lib/libssl.a # MISSING!
|
|
|
|
ZLIB=${makeStaticLibraries zlib}/lib/libz.a
|
|
|
|
# SQLITE=${makeStaticLibraries sqlite}/lib/sqlite.a # MISSING!
|
|
|
|
# LIBXML2=${makeStaticLibraries libxml2}/lib/libxml2.a # MISSING!
|
|
|
|
# YAML=${makeStaticLibraries libyaml}/lib/libyaml.a # MISSING!
|
2019-09-22 09:38:09 +02:00
|
|
|
MYSQL=${makeStaticLibraries libmysqlclient}/lib/mariadb/libmariadb.a
|
2018-03-03 07:28:08 +01:00
|
|
|
# LMDB=${makeStaticLibraries lmdb}/lib/mysql/libmysqlclient_r.a # MISSING!
|
|
|
|
LEVELDB=${makeStaticLibraries lmdb}/lib/libleveldb.a
|
|
|
|
EOF
|
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
|
|
|
|
# Enable all optional libraries
|
|
|
|
substituteInPlace "src/std/build-features.ss" --replace '#f' '#t'
|
|
|
|
|
|
|
|
# gxprof testing uses $HOME/.cache/gerbil/gxc
|
|
|
|
export HOME=$$PWD
|
|
|
|
|
|
|
|
# Build, replacing make by build.sh
|
|
|
|
( cd src && sh build.sh )
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
mkdir -p $out/
|
|
|
|
cp -fa bin lib etc doc $out/
|
|
|
|
|
|
|
|
cat > $out/bin/gxi <<EOF
|
|
|
|
#!${bash}/bin/bash -e
|
|
|
|
export GERBIL_HOME=$out
|
|
|
|
case "\$1" in -:*) GSIOPTIONS=\$1 ; shift ;; esac
|
|
|
|
if [[ \$# = 0 ]] ; then
|
2018-11-19 15:14:15 +01:00
|
|
|
exec ${gambit}/bin/gsi \$GSIOPTIONS \$GERBIL_HOME/lib/gxi-init \$GERBIL_HOME/lib/gxi-interactive - ;
|
2018-03-03 07:28:08 +01:00
|
|
|
else
|
2018-11-19 15:14:15 +01:00
|
|
|
exec ${gambit}/bin/gsi \$GSIOPTIONS \$GERBIL_HOME/lib/gxi-init "\$@"
|
2018-03-03 07:28:08 +01:00
|
|
|
fi
|
|
|
|
EOF
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
dontStrip = true;
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
description = "Gerbil Scheme";
|
|
|
|
homepage = "https://github.com/vyzo/gerbil";
|
|
|
|
license = stdenv.lib.licenses.lgpl2;
|
|
|
|
# NB regarding platforms: only actually tested on Linux, *should* work everywhere,
|
|
|
|
# but *might* need adaptation e.g. on macOS. Please report success and/or failure to fare.
|
|
|
|
platforms = stdenv.lib.platforms.unix;
|
|
|
|
maintainers = with stdenv.lib.maintainers; [ fare ];
|
|
|
|
};
|
|
|
|
}
|