2021-08-10 14:31:46 +00:00
|
|
|
{ lib, stdenv, fetchurl, unzip, cmake, /*jdk,*/ alsa-lib, Carbon, CoreAudio, CoreFoundation, CoreMIDI, CoreServices }:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "portmidi";
|
2021-08-12 14:41:47 +00:00
|
|
|
version = "234";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2021-08-12 14:41:47 +00:00
|
|
|
url = "mirror://sourceforge/portmedia/portmedia-code-r${version}.zip";
|
|
|
|
sha256 = "1g7i8hgarihycadbgy2f7lifiy5cbc0mcrcazmwnmbbh1bqx6dyp";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-08-12 14:41:47 +00:00
|
|
|
prePatch = ''
|
|
|
|
cd portmidi/trunk
|
|
|
|
'';
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
cmakeFlags = let
|
|
|
|
#base = "${jdk}/jre/lib/${jdk.architecture}";
|
|
|
|
in [
|
|
|
|
"-DPORTMIDI_ENABLE_JAVA=0"
|
|
|
|
/* TODO: Fix Java support.
|
|
|
|
"-DJAVA_AWT_LIBRARY=${base}/libawt.so"
|
|
|
|
"-DJAVA_JVM_LIBRARY=${base}/server/libjvm.so"
|
|
|
|
*/
|
|
|
|
"-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY=Release"
|
|
|
|
"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY=Release"
|
|
|
|
"-DCMAKE_RUNTIME_OUTPUT_DIRECTORY=Release"
|
2021-08-10 14:31:46 +00:00
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
"-DCMAKE_OSX_ARCHITECTURES=${if stdenv.isAarch64 then "arm64" else "x86_64"}"
|
|
|
|
"-DCOREAUDIO_LIB=${CoreAudio}"
|
|
|
|
"-DCOREFOUNDATION_LIB=${CoreFoundation}"
|
|
|
|
"-DCOREMIDI_LIB=${CoreMIDI}"
|
|
|
|
"-DCORESERVICES_LIB=${CoreServices}"
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
2021-08-10 14:31:46 +00:00
|
|
|
NIX_LDFLAGS = lib.optionalString stdenv.isDarwin [
|
|
|
|
"-framework CoreAudio"
|
|
|
|
"-framework CoreFoundation"
|
|
|
|
"-framework CoreMIDI"
|
|
|
|
"-framework CoreServices"
|
|
|
|
];
|
|
|
|
|
|
|
|
patches = [
|
|
|
|
# XXX: This is to deactivate Java support.
|
|
|
|
(fetchurl {
|
|
|
|
url = "https://raw.github.com/Rogentos/argent-gentoo/master/media-libs/portmidi/files/portmidi-217-cmake-libdir-java-opts.patch";
|
|
|
|
sha256 = "1jbjwan61iqq9fqfpq2a4fd30k3clg7a6j0gfgsw87r8c76kqf6h";
|
|
|
|
})
|
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
# Remove hardcoded variables so we can set them properly
|
|
|
|
./remove-darwin-variables.diff
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
sed -i -e 's|/usr/local/|'"$out"'|' -e 's|/usr/share/|'"$out"'/share/|' \
|
|
|
|
pm_common/CMakeLists.txt pm_dylib/CMakeLists.txt pm_java/CMakeLists.txt
|
|
|
|
sed -i \
|
|
|
|
-e 's|-classpath .|-classpath '"$(pwd)"'/pm_java|' \
|
|
|
|
-e 's|pmdefaults/|'"$(pwd)"'/pm_java/&|g' \
|
|
|
|
-e 's|jportmidi/|'"$(pwd)"'/pm_java/&|g' \
|
|
|
|
-e 's/WORKING_DIRECTORY pm_java//' \
|
|
|
|
pm_java/CMakeLists.txt
|
|
|
|
'';
|
|
|
|
|
2021-08-10 14:31:46 +00:00
|
|
|
postInstall = let ext = stdenv.hostPlatform.extensions.sharedLibrary; in ''
|
2021-08-11 14:56:57 +00:00
|
|
|
ln -s libportmidi${ext} "$out/lib/libporttime${ext}"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
nativeBuildInputs = [ unzip cmake ];
|
2021-08-10 14:31:46 +00:00
|
|
|
buildInputs = lib.optionals stdenv.isLinux [
|
|
|
|
alsa-lib
|
|
|
|
] ++ lib.optionals stdenv.isDarwin [
|
|
|
|
Carbon CoreAudio CoreFoundation CoreMIDI CoreServices
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
hardeningDisable = [ "format" ];
|
|
|
|
|
2021-08-10 14:31:46 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "http://portmedia.sourceforge.net/portmidi/";
|
|
|
|
description = "Platform independent library for MIDI I/O";
|
2021-08-10 14:31:46 +00:00
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ angustrau ];
|
|
|
|
platforms = platforms.unix;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|