1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 buildPackages,
6}:
7
8stdenv.mkDerivation (finalAttrs: {
9 pname = "pforth";
10 version = "2.0.1";
11
12 src = fetchFromGitHub {
13 owner = "philburk";
14 repo = "pforth";
15 rev = "v${finalAttrs.version}";
16 hash = "sha256-vEjFeHSJl+yAtatYJEnu+r9hmOr/kZOgIbSUXR/c8WU=";
17 };
18
19 # We build the dictionary in a cross-compile compatible way.
20 # For that, we perform steps, that the Makefile would otherwise do.
21 buildPhase = ''
22 runHook preBuild
23 make -C platforms/unix pfdicapp
24 pushd fth/
25 ${stdenv.hostPlatform.emulator buildPackages} ../platforms/unix/pforth -i system.fth
26 ${stdenv.hostPlatform.emulator buildPackages} ../platforms/unix/pforth -d pforth.dic <<< "include savedicd.fth sdad bye"
27 mv pforth.dic pfdicdat.h ../platforms/unix/
28 popd
29 make -C platforms/unix pforthapp
30 runHook postBuild
31 '';
32
33 installPhase = ''
34 runHook preInstall
35 install -Dm755 platforms/unix/pforth_standalone $out/bin/pforth
36 mkdir -p $out/share/pforth
37 cp -r fth/* $out/share/pforth/
38 runHook postInstall
39 '';
40
41 meta = {
42 homepage = "https://www.softsynth.com/pforth/";
43 description = "Portable Portable ANS-like Forth written in ANSI 'C'";
44 mainProgram = "pforth";
45 changelog = "https://github.com/philburk/pforth/blob/v${finalAttrs.version}/RELEASES.md";
46 license = lib.licenses.bsd0;
47 maintainers = with lib.maintainers; [
48 yrashk
49 ];
50 platforms = lib.platforms.unix;
51 };
52})
53# TODO: option for install the non-standalone executable