1{
2 lib,
3 stdenv,
4 makeSetupHook,
5 fetchFromGitHub,
6 libelf,
7 which,
8 pkg-config,
9 libglut,
10 avrgcc,
11 avrlibc,
12 libGLU,
13 libGL,
14}:
15
16let
17 setupHookDarwin = makeSetupHook {
18 name = "darwin-avr-gcc-hook";
19 substitutions = {
20 darwinSuffixSalt = stdenv.cc.suffixSalt;
21 avrSuffixSalt = avrgcc.suffixSalt;
22 };
23 } ./setup-hook-darwin.sh;
24in
25stdenv.mkDerivation rec {
26 pname = "simavr";
27 version = "1.7";
28
29 src = fetchFromGitHub {
30 owner = "buserror";
31 repo = "simavr";
32 rev = "v${version}";
33 sha256 = "0njz03lkw5374x1lxrq08irz4b86lzj2hibx46ssp7zv712pq55q";
34 };
35
36 makeFlags = [
37 "DESTDIR=$(out)"
38 "PREFIX="
39 "AVR_ROOT=${avrlibc}/avr"
40 "SIMAVR_VERSION=${version}"
41 "AVR=avr-"
42 ];
43
44 nativeBuildInputs = [
45 which
46 pkg-config
47 avrgcc
48 ]
49 ++ lib.optional stdenv.hostPlatform.isDarwin setupHookDarwin;
50 buildInputs = [
51 libelf
52 libglut
53 libGLU
54 libGL
55 ];
56
57 # remove forbidden references to $TMPDIR
58 preFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
59 patchelf --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" "$out"/bin/*
60 '';
61
62 doCheck = true;
63 checkTarget = "-C tests run_tests";
64
65 meta = with lib; {
66 description = "Lean and mean Atmel AVR simulator";
67 mainProgram = "simavr";
68 homepage = "https://github.com/buserror/simavr";
69 license = licenses.gpl3;
70 platforms = platforms.unix;
71 maintainers = with maintainers; [ goodrone ];
72 };
73
74}