1{ stdenv, lib, fetchFromGitHub, fetchpatch
2, autoreconfHook, perl, pkg-config, flux, zlib
3, libjpeg, freetype, libpng, giflib
4, enableX11 ? true, xorg
5, enableSDL ? true, SDL }:
6
7stdenv.mkDerivation rec {
8 pname = "directfb";
9 version = "1.7.7";
10
11 src = fetchFromGitHub {
12 owner = "deniskropp";
13 repo = "DirectFB";
14 rev = "DIRECTFB_${lib.replaceStrings ["."] ["_"] version}";
15 sha256 = "0bs3yzb7hy3mgydrj8ycg7pllrd2b6j0gxj596inyr7ihssr3i0y";
16 };
17
18 patches = [
19 # Fixes build in "davinci" with glibc >= 2.28
20 # The "davinci" module is only enabled on 32-bit arm.
21 # https://github.com/deniskropp/DirectFB/pull/17
22 (fetchpatch {
23 url = "https://github.com/deniskropp/DirectFB/commit/3a236241bbec3f15b012b6f0dbe94353d8094557.patch";
24 sha256 = "0rj3gv0zlb225sqjz04p4yagy4xacf3210aa8vra8i1f0fv0w4kw";
25 })
26
27 # Fixes for build of `pkgsMusl.directfb`; applied everywhere to prevent patchrot
28 (fetchpatch {
29 url = "https://git.alpinelinux.org/aports/plain/community/directfb/0001-directfb-fix-musl-compile.patch?id=f8158258493fc0c3eb5de2302e40f4bc44ecfb09";
30 sha256 = "sha256-hmwzbaXu30ZkAqUn1NmvtlJkM6ctddKcO4hxh+1LSS4=";
31 })
32 (fetchpatch {
33 url = "https://git.alpinelinux.org/aports/plain/community/directfb/0002-Fix-musl-PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP-comp.patch?id=f8158258493fc0c3eb5de2302e40f4bc44ecfb09";
34 sha256 = "sha256-j3+mcP6hV9LKuba1GOdcM1cZfmXuJtRgx4vE484jIns=";
35 })
36 ];
37
38 postPatch = ''
39 # https://github.com/deniskropp/DirectFB/blob/master/src/core/Makefile.am#L15
40 # BUILDTIME is embedded in the result
41 # if switching to cmake then a similar substitution has to be done
42 substituteInPlace src/core/Makefile.am \
43 --replace '`date -u "+%Y-%m-%d %H:%M"`' "`date -u \"+%Y-%m-%d %H:%M\" --date="@''${SOURCE_DATE_EPOCH}"`"
44 '' + lib.optionalString stdenv.hostPlatform.isMusl ''
45 # Specifically patch out two drivers that have build errors with musl libc,
46 # while leaving the rest of the default selection enabled
47 substituteInPlace configure.in \
48 --replace checkfor_lirc={yes,no} \
49 --replace checkfor_matrox={yes,no}
50 '';
51
52 nativeBuildInputs = [ autoreconfHook perl pkg-config flux ];
53
54 buildInputs = [ zlib libjpeg freetype giflib libpng ]
55 ++ lib.optional enableSDL SDL
56 ++ lib.optionals enableX11 (with xorg; [
57 xorgproto libX11 libXext
58 libXrender
59 ]);
60
61 NIX_LDFLAGS = "-lgcc_s";
62
63 configureFlags = [
64 "--enable-sdl"
65 "--enable-zlib"
66 "--with-gfxdrivers=all"
67 "--enable-devmem"
68 "--enable-fbdev"
69 "--enable-mmx"
70 "--enable-sse"
71 "--with-software"
72 ]
73 ++ lib.optional (!stdenv.hostPlatform.isMusl) "--with-smooth-scaling"
74 ++ lib.optional enableX11 "--enable-x11"
75 ;
76
77 # Disable parallel building as parallel builds fail due to incomplete
78 # depends between autogenerated CoreSlave.h and it's include sites:
79 # CC prealloc_surface_pool_bridge.lo
80 # prealloc_surface_pool_bridge.c:41:10:
81 # fatal error: core/CoreSlave.h: No such file or directory
82 #
83 # Dependencies are specified manually in src/core/Makefile.am. Instead
84 # of fixing them one by one locally let's disable parallel builds until
85 # upstream fixes them.
86 enableParallelBuilding = false;
87
88 meta = with lib; {
89 description = "Graphics and input library designed with embedded systems in mind";
90 longDescription = ''
91 DirectFB is a thin library that provides hardware graphics acceleration,
92 input device handling and abstraction, integrated windowing system with
93 support for translucent windows and multiple display layers, not only on
94 top of the Linux Framebuffer Device. It is a complete hardware
95 abstraction layer with software fallbacks for every graphics operation
96 that is not supported by the underlying hardware. DirectFB adds graphical
97 power to embedded systems and sets a new standard for graphics under
98 Linux.
99 '';
100 homepage = "https://github.com/deniskropp/DirectFB";
101 license = licenses.lgpl21;
102 platforms = platforms.linux;
103 maintainers = [ maintainers.bjornfor ];
104 };
105}