summary refs log tree commit diff
path: root/pkgs/os-specific/darwin/apple-source-releases/bootstrap_cmds/default.nix
blob: 5ac971d02f76e800864311f97366c85d2a53a266 (plain) (blame)
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
{ lib, stdenv, appleDerivation, yacc, flex }:

appleDerivation {
  nativeBuildInputs = [ yacc flex ];

  buildPhase = ''
    cd migcom.tproj

    # redundant file, don't know why apple not removing it.
    rm handler.c

    yacc -d parser.y
    flex --header-file=lexxer.yy.h -o lexxer.yy.c lexxer.l

    cc -std=gnu99 -Os -dead_strip -DMIG_VERSION=\"$pname-$version\" -I. -o migcom *.c
  '';

  installPhase = ''
    mkdir -p $out/bin $out/libexec $out/share/man/man1

    chmod +x mig.sh
    cp mig.sh   $out/bin/mig
    cp migcom   $out/libexec
    ln -s $out/libexec/migcom $out/bin/migcom
    cp mig.1    $out/share/man/man1
    cp migcom.1 $out/share/man/man1

    substituteInPlace $out/bin/mig \
      --replace 'arch=`/usr/bin/arch`' 'arch=${stdenv.targetPlatform.darwinArch}' \
      --replace '/usr/bin/' "" \
      --replace '/bin/rmdir' "rmdir" \
      --replace 'C=''${MIGCC}' "C=cc"
  '';
}