summaryrefslogtreecommitdiffstats
path: root/pkgs/by-name/t4/t4kcommon/package.nix
blob: 4a6475884463eae3c871f10f369310502db3e465 (plain)
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
{
  lib,
  stdenv,
  fetchFromGitHub,
  fetchpatch,
  cmake,
  pkg-config,
  SDL,
  SDL_image,
  SDL_mixer,
  SDL_net,
  SDL_ttf,
  libpng,
  librsvg,
  libxml2,
}:

stdenv.mkDerivation (finalAttrs: {
  version = "0.1.1";
  pname = "t4kcommon";

  src = fetchFromGitHub {
    owner = "tux4kids";
    repo = "t4kcommon";
    rev = "upstream/${finalAttrs.version}";
    sha256 = "13q02xpmps9qg8zrzzy2gzv4a6afgi28lxk4z242j780v0gphchp";
  };

  patches = [
    # patch from debian to support libpng16 instead of libpng12
    (fetchpatch {
      url = "https://salsa.debian.org/tux4kids-pkg-team/t4kcommon/raw/f7073fa384f5a725139f54844e59b57338b69dc7/debian/patches/libpng16.patch";
      hash = "sha256-auQ8VvOyvLE1PD2dfeHZJV+MzIt1OtUa7OcOqsXTAYI=";
    })
    # Fix "Cannot specify link libraries for target "linebreak" which is not built by this project."
    ./linebreak-fix.patch
  ];

  # Workaround build failure on -fno-common toolchains like upstream
  # gcc-10. Otherwise build fails as:
  #   ld: CMakeFiles/t4k_common.dir/t4k_throttle.c.o:(.bss+0x0): multiple definition of
  #     `wrapped_lines'; CMakeFiles/t4k_common.dir/t4k_audio.c.o:(.bss+0x0): first defined here
  env.NIX_CFLAGS_COMPILE = "-fcommon -DGNULIB_UNISTR_U8_MBTOUC_UNSAFE -Wno-incompatible-pointer-types -std=gnu17";

  nativeBuildInputs = [
    cmake
    pkg-config
  ];
  buildInputs = [
    SDL
    SDL_image
    SDL_mixer
    SDL_net
    SDL_ttf
    libpng
    librsvg
    libxml2
  ];

  postPatch = ''
    substituteInPlace {src/,./}CMakeLists.txt \
      --replace-fail "cmake_minimum_required(VERSION 2.6)" "cmake_minimum_required(VERSION 3.10)"
  '';

  meta = {
    description = "Library of code shared between tuxmath and tuxtype";
    homepage = "https://github.com/tux4kids/t4kcommon";
    license = lib.licenses.gpl3Plus;
    maintainers = [ ];
    platforms = lib.platforms.linux;
  };
})