2021-05-06 20:56:46 +01:00
|
|
|
{ lib, appleDerivation, stdenv, bison, flex }:
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
# Hard to get CC to pull this off without infinite recursion
|
|
|
|
targetTargetPrefix = lib.optionalString
|
|
|
|
(with stdenv; hostPlatform != targetPlatform)
|
|
|
|
(stdenv.targetPlatform.config + "-");
|
|
|
|
|
|
|
|
in
|
2015-02-08 06:53:52 +00:00
|
|
|
|
|
|
|
appleDerivation {
|
2021-03-14 17:50:12 +00:00
|
|
|
nativeBuildInputs = [ bison flex ];
|
2015-02-08 06:53:52 +00:00
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
cd migcom.tproj
|
2021-01-11 21:40:24 +00:00
|
|
|
|
|
|
|
# redundant file, don't know why apple not removing it.
|
|
|
|
rm handler.c
|
|
|
|
|
2015-02-08 06:53:52 +00:00
|
|
|
yacc -d parser.y
|
|
|
|
flex --header-file=lexxer.yy.h -o lexxer.yy.c lexxer.l
|
|
|
|
|
2021-05-06 20:56:46 +01:00
|
|
|
$CC -std=gnu99 -Os -dead_strip -DMIG_VERSION=\"$pname-$version\" -I. -o migcom *.c
|
2015-02-08 06:53:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
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
|
2019-02-07 01:13:51 +00:00
|
|
|
ln -s $out/libexec/migcom $out/bin/migcom
|
2015-02-08 06:53:52 +00:00
|
|
|
cp mig.1 $out/share/man/man1
|
|
|
|
cp migcom.1 $out/share/man/man1
|
|
|
|
|
|
|
|
substituteInPlace $out/bin/mig \
|
2020-11-19 09:12:01 +00:00
|
|
|
--replace 'arch=`/usr/bin/arch`' 'arch=${stdenv.targetPlatform.darwinArch}' \
|
2015-02-08 06:53:52 +00:00
|
|
|
--replace '/usr/bin/' "" \
|
|
|
|
--replace '/bin/rmdir' "rmdir" \
|
2021-05-06 20:56:46 +01:00
|
|
|
--replace 'C=''${MIGCC}' "C=${targetTargetPrefix}cc"
|
2015-02-08 06:53:52 +00:00
|
|
|
'';
|
2017-08-10 23:57:42 +01:00
|
|
|
}
|