From f9081aa622535dc5dc92097541bde52285a58714 Mon Sep 17 00:00:00 2001 From: yzx9 Date: Sun, 27 Oct 2024 20:23:32 +0800 Subject: [PATCH] openctm: fix darwin support --- pkgs/by-name/op/openctm/package.nix | 35 ++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/pkgs/by-name/op/openctm/package.nix b/pkgs/by-name/op/openctm/package.nix index d89640ca8210..bb6bd763ea1d 100644 --- a/pkgs/by-name/op/openctm/package.nix +++ b/pkgs/by-name/op/openctm/package.nix @@ -6,6 +6,7 @@ libglut, gtk2, libGLU, + darwin, }: stdenv.mkDerivation (finalAttrs: { @@ -26,18 +27,30 @@ stdenv.mkDerivation (finalAttrs: { nativeBuildInputs = [ pkg-config ]; - buildInputs = [ - libglut - gtk2 - libGLU - ]; + buildInputs = + [ + libglut + libGLU + ] + ++ lib.optionals stdenv.hostPlatform.isLinux [ gtk2 ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.apple_sdk.frameworks.Cocoa ]; - postPatch = '' - substituteInPlace tools/tinyxml/Makefile.linux \ - --replace-warn "-Wno-format" "-Wno-format -Wno-format-security" - substituteInPlace tools/Makefile.linux \ - --replace-warn "-lglut" "-lglut -lGL -lGLU" - ''; + postPatch = + lib.optionalString stdenv.hostPlatform.isLinux '' + substituteInPlace "tools/tinyxml/Makefile.linux" \ + --replace-warn "-Wno-format" "-Wno-format -Wno-format-security" + substituteInPlace "tools/Makefile.linux" \ + --replace-warn "-lglut" "-lglut -lGL -lGLU" + '' + + lib.optionalString stdenv.hostPlatform.isDarwin '' + substituteInPlace "lib/Makefile.macosx" \ + "tools/Makefile.macosx" \ + "tools/jpeg/makefile.macosx" \ + "tools/zlib/Makefile.macosx" \ + --replace-warn "gcc" "${stdenv.cc.targetPrefix}cc" + substituteInPlace "lib/Makefile.macosx" "tools/Makefile.macosx" "tools/tinyxml/Makefile.macosx" \ + --replace-warn "g++" "${stdenv.cc.targetPrefix}c++" + ''; makeFlags = [ "BINDIR=$(bin)/bin/"