1 { gccStdenv, lib, coreutils,
3 version, git-version, src,
10 # We use Gambit, that works 10x better with GCC than Clang. See ../gambit/build.nix
11 let stdenv = gccStdenv; in
13 stdenv.mkDerivation rec {
18 buildInputs_libraries = [ openssl zlib sqlite ];
20 # TODO: either fix all of Gerbil's dependencies to provide static libraries,
21 # or give up and delete all tentative support for static libraries.
22 #buildInputs_staticLibraries = map makeStaticLibraries buildInputs_libraries;
24 buildInputs = buildInputs_libraries;
28 grep -Fl '#!/usr/bin/env' `find . -type f -executable` | while read f ; do
29 substituteInPlace "$f" --replace '#!/usr/bin/env' '#!${coreutils}/bin/env' ;
32 gerbil_stamp_version=v${git-version}
33 gambit_stamp_version=v${gambit-git-version}
34 gambit_stamp_ymd=${gambit-stampYmd}
35 gambit_stamp_hms=${gambit-stampHms}
37 for f in src/bootstrap/gerbil/compiler/driver__0.scm \
38 src/build/build-libgerbil.ss \
39 src/gerbil/compiler/driver.ss ; do
40 substituteInPlace "$f" --replace '"gcc"' '"${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}gcc"' ;
44 ## TODO: make static compilation work.
45 ## For that, get all the packages below to somehow expose static libraries,
46 ## so we can offer users the option to statically link them into Gambit and/or Gerbil.
47 ## Then add the following to the postPatch script above:
48 # cat > etc/gerbil_static_libraries.sh <<EOF
49 # OPENSSL_LIBCRYPTO=${makeStaticLibraries openssl}/lib/libcrypto.a # MISSING!
50 # OPENSSL_LIBSSL=${makeStaticLibraries openssl}/lib/libssl.a # MISSING!
51 # ZLIB=${makeStaticLibraries zlib}/lib/libz.a
52 # SQLITE=${makeStaticLibraries sqlite}/lib/sqlite.a # MISSING!
56 "--prefix=$out/gerbil"
60 "--enable-march=" # Avoid non-portable invalid instructions. Use =native if local build only.
64 export CC=${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}gcc \
65 CXX=${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}g++ \
66 CPP=${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}cpp \
67 CXXCPP=${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}cpp \
68 LD=${gccStdenv.cc}/bin/${gccStdenv.cc.targetPrefix}ld \
69 XMKMF=${coreutils}/bin/false
70 unset CFLAGS LDFLAGS LIBS CPPFLAGS CXXFLAGS
71 ./configure ${builtins.concatStringsSep " " configureFlags}
76 "-L${openssl.out}/lib"
83 # gxprof testing uses $HOME/.cache/gerbil/gxc
85 export GERBIL_BUILD_CORES=$NIX_BUILD_CORES
86 export GERBIL_GXC=$PWD/bin/gxc
87 export GERBIL_BASE=$PWD
88 export GERBIL_PREFIX=$PWD
89 export GERBIL_PATH=$PWD/lib
90 export PATH=$PWD/bin:$PATH
91 ${gambit-support.export-gambopt gambit-params}
93 # Build, replacing make by build.sh
94 ( cd src && sh build.sh )
96 f=build/lib/libgerbil.so.ldd ; [ -f $f ] && :
97 substituteInPlace "$f" --replace '(' \
98 '(${lib.strings.concatStrings (map (x: "\"${x}\" " ) extraLdOptions)}'
105 mkdir -p $out/gerbil $out/bin
107 (cd $out/bin ; ln -s ../gerbil/bin/* .)
109 '' + lib.optionalString stdenv.hostPlatform.isDarwin ''
110 libgerbil="$(realpath "$out/gerbil/lib/libgerbil.so")"
111 install_name_tool -id "$libgerbil" "$libgerbil"
117 description = "Gerbil Scheme";
118 homepage = "https://github.com/vyzo/gerbil";
119 license = lib.licenses.lgpl21Only; # dual, also asl20, like Gambit
120 # NB regarding platforms: regularly tested on Linux and on macOS.
121 # Please report success and/or failure to fare.
122 platforms = lib.platforms.unix;
123 maintainers = with lib.maintainers; [ fare ];
126 outputsToInstall = [ "out" ];