openctm: fix darwin support

This commit is contained in:
yzx9 2024-10-27 20:23:32 +08:00
parent 44607a5f8a
commit f9081aa622
No known key found for this signature in database

View File

@ -6,6 +6,7 @@
libglut, libglut,
gtk2, gtk2,
libGLU, libGLU,
darwin,
}: }:
stdenv.mkDerivation (finalAttrs: { stdenv.mkDerivation (finalAttrs: {
@ -26,17 +27,29 @@ stdenv.mkDerivation (finalAttrs: {
nativeBuildInputs = [ pkg-config ]; nativeBuildInputs = [ pkg-config ];
buildInputs = [ buildInputs =
[
libglut libglut
gtk2
libGLU libGLU
]; ]
++ lib.optionals stdenv.hostPlatform.isLinux [ gtk2 ]
++ lib.optionals stdenv.hostPlatform.isDarwin [ darwin.apple_sdk.frameworks.Cocoa ];
postPatch = '' postPatch =
substituteInPlace tools/tinyxml/Makefile.linux \ lib.optionalString stdenv.hostPlatform.isLinux ''
substituteInPlace "tools/tinyxml/Makefile.linux" \
--replace-warn "-Wno-format" "-Wno-format -Wno-format-security" --replace-warn "-Wno-format" "-Wno-format -Wno-format-security"
substituteInPlace tools/Makefile.linux \ substituteInPlace "tools/Makefile.linux" \
--replace-warn "-lglut" "-lglut -lGL -lGLU" --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 = [ makeFlags = [