@@ -1,4 +1,18 @@
1−{ lib, stdenv, fetchFromGitHub, autoconf, automake, libtool, libjack2, alsaLib, pkg-config }:
1+{ stdenv
2+, lib
3+, fetchFromGitHub
4+, fetchpatch
5+, cmake
6+, pkg-config
7+, alsaSupport ? stdenv.hostPlatform.isLinux
8+, alsaLib
9+, jackSupport ? true
10+, jack
11+, coremidiSupport ? stdenv.hostPlatform.isDarwin
12+, CoreMIDI
13+, CoreAudio
14+, CoreServices
15+}:
216
317stdenv.mkDerivation rec {
418 version = "4.0.0";
@@ -11,21 +25,45 @@ stdenv.mkDerivation rec {
1125 sha256 = "1g31p6a96djlbk9jh5r4pjly3x76lhccva9hrw6xzdma8dsjzgyq";
1226 };
1327
14− enableParallelBuilding = true;
28+ patches = [
29+ # PR #230, fix CMake problems
30+ (fetchpatch {
31+ name = "RtMidi-Fix-JACK_HAS_PORT_RENAME-define.patch";
32+ url = "https://github.com/thestk/rtmidi/pull/230/commits/768a30a61b60240b66cc2d43bc27a544ff9f1622.patch";
33+ sha256 = "1sym4f7nb2qyyxfhi1l0xsm2hfh6gddn81y36qvfq4mcs33vvid0";
34+ })
35+ (fetchpatch {
36+ name = "RtMidi-Add-prefix-define-for-pkgconfig.patch";
37+ url = "https://github.com/thestk/rtmidi/pull/230/commits/7a32e23e3f6cb43c0d2d58443ce205d438e76f44.patch";
38+ sha256 = "06im8mb05wah6bnkadw2gpkhmilxb8p84pxqr50b205cchpq304w";
39+ })
40+ ];
1541
16− nativeBuildInputs = [ pkg-config ];
17− buildInputs = [ autoconf automake libtool libjack2 alsaLib ];
18−
19− preConfigure = ''
20− ./autogen.sh --no-configure
21− ./configure
42+ postPatch = ''
43+ substituteInPlace rtmidi.pc.in \
44+ --replace 'Requires:' 'Requires.private:'
45+ substituteInPlace CMakeLists.txt \
46+ --replace 'PUBLIC_HEADER RtMidi.h' 'PUBLIC_HEADER "RtMidi.h;rtmidi_c.h"' \
47+ --replace 'PUBLIC_HEADER DESTINATION $''\{CMAKE_INSTALL_INCLUDEDIR}' 'PUBLIC_HEADER DESTINATION $''\{CMAKE_INSTALL_INCLUDEDIR}/rtmidi'
2248 '';
2349
24− meta = {
50+ nativeBuildInputs = [ cmake pkg-config ];
51+
52+ buildInputs = lib.optional alsaSupport alsaLib
53+ ++ lib.optional jackSupport jack
54+ ++ lib.optionals coremidiSupport [ CoreMIDI CoreAudio CoreServices ];
55+
56+ cmakeFlags = [
57+ "-DRTMIDI_API_ALSA=${if alsaSupport then "ON" else "OFF"}"
58+ "-DRTMIDI_API_JACK=${if jackSupport then "ON" else "OFF"}"
59+ "-DRTMIDI_API_CORE=${if coremidiSupport then "ON" else "OFF"}"
60+ ];
61+
62+ meta = with lib; {
2563 description = "A set of C++ classes that provide a cross platform API for realtime MIDI input/output";
26− homepage = "http://www.music.mcgill.ca/~gary/rtmidi/";
27− license = lib.licenses.mit;
28− maintainers = [ lib.maintainers.magnetophon ];
29− platforms = with lib.platforms; linux ++ darwin;
64+ homepage = "https://www.music.mcgill.ca/~gary/rtmidi/";
65+ license = licenses.mit;
66+ maintainers = with maintainers; [ magnetophon ];
67+ platforms = platforms.unix;
3068 };
3169}