2024-03-04 03:59:50 +00:00
|
|
|
{ pkgs,
|
|
|
|
lib,
|
2024-03-06 04:50:56 +00:00
|
|
|
stdenv,
|
2024-03-25 17:53:17 +00:00
|
|
|
am-kernels,
|
2024-04-05 03:30:52 +00:00
|
|
|
dtc,
|
|
|
|
defconfig ? "alldefconfig",
|
2024-03-04 03:59:50 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "nemu";
|
|
|
|
version = "2024-03-02";
|
|
|
|
|
|
|
|
src = ./.;
|
|
|
|
|
|
|
|
nativeBuildInputs = with pkgs; [
|
|
|
|
gnumake
|
2024-03-06 04:50:56 +00:00
|
|
|
pkg-config
|
2024-03-04 03:59:50 +00:00
|
|
|
flex
|
|
|
|
bison
|
2024-03-25 17:53:17 +00:00
|
|
|
dtc
|
2024-03-04 03:59:50 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = with pkgs; [
|
|
|
|
readline
|
|
|
|
libllvm
|
|
|
|
];
|
|
|
|
|
2024-03-06 04:50:56 +00:00
|
|
|
checkInputs = [
|
|
|
|
pkgs.check
|
|
|
|
am-kernels
|
|
|
|
];
|
|
|
|
|
2024-03-04 03:59:50 +00:00
|
|
|
configurePhase = ''
|
2024-03-06 04:50:56 +00:00
|
|
|
export NEMU_HOME=$(pwd)
|
2024-04-05 03:30:52 +00:00
|
|
|
make ${defconfig}
|
2024-03-04 03:59:50 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
make
|
|
|
|
'';
|
|
|
|
|
2024-04-05 03:30:52 +00:00
|
|
|
doCheck = (defconfig == "alldefconfig");
|
|
|
|
checkPhase = if doCheck then ''
|
2024-03-25 09:02:12 +00:00
|
|
|
export IMAGES_PATH=${am-kernels}/share/binary
|
2024-03-04 03:59:50 +00:00
|
|
|
make test
|
2024-04-05 03:30:52 +00:00
|
|
|
'' else "";
|
2024-03-04 03:59:50 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin
|
2024-04-05 03:30:52 +00:00
|
|
|
mkdir -p $out/lib
|
2024-03-04 03:59:50 +00:00
|
|
|
make PREFIX=$out install
|
|
|
|
'';
|
|
|
|
|
2024-03-06 04:50:56 +00:00
|
|
|
shellHook = ''
|
|
|
|
export NEMU_HOME=$(pwd)
|
|
|
|
'';
|
|
|
|
|
2024-03-04 03:59:50 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "NJU EMUlator, a full system x86/mips32/riscv32/riscv64 emulator for teaching";
|
|
|
|
homepage = "https://github.com/NJU-ProjectN/nemu.git";
|
|
|
|
license = with licenses; [ ];
|
|
|
|
maintainers = with maintainers; [ ];
|
|
|
|
};
|
|
|
|
}
|