about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/sparrow3d/default.nix
blob: a502b6249a16c8fdebcfec772d6e01f51ca51526 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
{ lib
, stdenv
, copyPkgconfigItems
, fetchFromGitHub
, makePkgconfigItem
, pkg-config
, SDL
, SDL_image
, SDL_mixer
, SDL_net
, SDL_ttf
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "sparrow3d";
  version = "unstable-2020-10-06";

  outputs = [ "out" "dev" ];

  src = fetchFromGitHub {
    owner = "theZiz";
    repo = "sparrow3d";
    rev = "2033349d7adeba34bda2c442e1fec22377471134";
    hash = "sha256-28j5nbTYBrMN8BQ6XrTlO1D8Viw+RiT3MAl99BAbhR4=";
  };

  pkgconfigItems = [
    (makePkgconfigItem rec {
      name = "sparrow3d";
      inherit (finalAttrs) version;
      inherit (finalAttrs.meta) description;

      cflags = [ "-isystem${variables.includedir}" ];
      libs = [
        "-L${variables.libdir}"
        "-lsparrow3d"
        "-lsparrowNet"
        "-lsparrowSound"
      ];
      variables = rec {
        prefix = "@dev@";
        exec_prefix = "@out@";
        includedir = "${prefix}/include";
        libdir = "${exec_prefix}/lib";
      };
    })
  ];

  nativeBuildInputs = [
    copyPkgconfigItems
    pkg-config
  ];

  propagatedBuildInputs = [
    SDL.dev
    SDL_image
    SDL_ttf
    SDL_mixer
    SDL_net
  ];

  postConfigure = ''
    NIX_CFLAGS_COMPILE=$(pkg-config --cflags SDL_image SDL_ttf SDL_mixer SDL_net)
  '';

  buildFlags = [ "dynamic" ];

  installPhase = ''
    runHook preInstall

    mkdir -p $out/lib
    cp libsparrow{3d,Net,Sound}.so $out/lib

    mkdir -p $dev/include
    cp sparrow*.h $dev/include

    runHook postInstall
  '';

  doCheck = true;

  checkPhase = ''
    runHook preCheck

    make all_no_static
    ./testfile.sh

    runHook postCheck
  '';

  meta = {
    homepage = "https://github.com/theZiz/sparrow3d";
    description = "A software renderer for different open handhelds like the gp2x, wiz, caanoo and pandora";
    license = lib.licenses.lgpl21;
    maintainers = with lib.maintainers; [ colinsane ];
    platforms = lib.platforms.linux;
  };
})