summaryrefslogtreecommitdiffstats
path: root/pkgs/development/compilers/fasm/default.nix
blob: 02776217b25ae6721dfc865b5de6fa455b3fd999 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
{
  stdenv,
  lib,
  fasm-bin,
  isx86_64,
}:

stdenv.mkDerivation {
  inherit (fasm-bin) version src meta;

  pname = "fasm";

  nativeBuildInputs = [ fasm-bin ];

  buildPhase = ''
    fasm source/linux${lib.optionalString isx86_64 "/x64"}/fasm.asm fasm
    for tool in listing prepsrc symbols; do
      fasm tools/libc/$tool.asm
      cc -o tools/libc/fasm-$tool tools/libc/$tool.o
    done
  '';

  outputs = [
    "out"
    "doc"
  ];

  installPhase = ''
    install -Dt $out/bin fasm tools/libc/fasm-*

    docs=$doc/share/doc/fasm
    mkdir -p $docs
    cp -r examples/ *.txt tools/fas.txt $docs
    cp tools/readme.txt $docs/tools.txt
  '';

  passthru.updateScript = fasm-bin.updateScript;
}