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,
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/"