ocamlPackages.lablgl: simplify build and fix Darwin

This commit is contained in:
Emily 2024-06-21 14:24:56 +01:00
parent 5cb1babeb3
commit fd276f75c8
2 changed files with 14 additions and 79 deletions

View File

@ -1,67 +0,0 @@
diff -Naur lablGL.ori/Makefile.config lablGL/Makefile.config
--- lablGL.ori/Makefile.config 1970-01-01 01:00:00.000000000 +0100
+++ lablGL/Makefile.config 2013-06-02 08:13:10.000000000 +0200
@@ -0,0 +1,63 @@
+# LablGL and Togl configuration file
+#
+# Please have a look at the config/Makefile in the Objective Caml distribution,
+# or at the labltklink script to get the information needed here
+#
+
+##### Adjust these always
+
+# Uncomment if you have the fast ".opt" compilers
+#CAMLC = ocamlc.opt
+#CAMLOPT = ocamlopt.opt
+
+# Where to put the lablgl script
+BINDIR = @BINDIR@
+
+# Where to find X headers
+XINCLUDES = @XINCLUDES@
+# X libs (for broken RTLD_GLOBAL: e.g. FreeBSD 4.0)
+#XLIBS = -L/usr/X11R6/lib -lXext -lXmu -lX11 -lXi
+
+# Where to find Tcl/Tk headers
+# This must the same version as for LablTk
+TKINCLUDES = @TKINCLUDES@
+# Tcl/Tk libs (for broken RTLD_GLOBAL: e.g. FreeBSD 4.0)
+#TKLIBS = -L/usr/local/lib -ltk84 -ltcl84
+
+# Where to find OpenGL/Mesa/Glut headers and libraries
+GLINCLUDES =
+GLLIBS = -lGL -lGLU
+GLUTLIBS = -lglut
+# The following libraries may be required (try to add them one at a time)
+#GLLIBS = -lGL -lGLU -lXmu -lXext -lXi -lcipher -lpthread
+
+# How to index a library after installing (ranlib required on MacOSX)
+RANLIB = :
+#RANLIB = ranlib
+
+##### Uncomment these for windows
+#TKLIBS = tk83.lib tcl83.lib gdi32.lib user32.lib
+#GLLIBS = opengl32.lib glu32.lib
+#TOOLCHAIN = msvc
+#XA = .lib
+#XB = .bat
+#XE = .exe
+#XO = .obj
+#XS = .dll
+
+##### Adjust these if non standard
+
+# The Objective Caml library directory
+#LIBDIR = `ocamlc -where`
+
+# Where to put dlls (if dynamic loading available)
+DLLDIR = @DLLDIR@
+
+# Where to put LablGL (standard)
+INSTALLDIR = @INSTALLDIR@
+
+# Where is Togl (default)
+#TOGLDIR = Togl
+
+# C Compiler options
+#COPTS = -c -O

View File

@ -1,4 +1,4 @@
{ lib, stdenv, fetchFromGitHub, ocaml, findlib, libGLU, libGL, libglut, camlp-streams, darwin } :
{ lib, stdenv, fetchFromGitHub, ocaml, findlib, libGLU, libglut, camlp-streams } :
if lib.versionOlder ocaml.version "4.06"
then throw "lablgl is not available for OCaml ${ocaml.version}"
@ -21,25 +21,27 @@ stdenv.mkDerivation rec {
buildInputs = [ libglut camlp-streams ];
propagatedBuildInputs = [
libGLU
libGL
] ++ lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.GLUT
darwin.apple_sdk.libs.Xplugin
];
patches = [ ./Makefile.config.patch ./META.patch ];
patches = [ ./META.patch ];
preConfigure = ''
mkdir -p $out/bin
mkdir -p $out/lib/ocaml/${ocaml.version}/site-lib/stublibs
substituteInPlace Makefile.config \
--subst-var-by BINDIR $out/bin/ \
--subst-var-by INSTALLDIR $out/lib/ocaml/${ocaml.version}/site-lib/lablgl/ \
--subst-var-by DLLDIR $out/lib/ocaml/${ocaml.version}/site-lib/stublibs/ \
--subst-var-by TKINCLUDES "" \
--subst-var-by XINCLUDES ""
cp \
Makefile.config.${if stdenv.hostPlatform.isDarwin then "osx" else "ex"} \
Makefile.config
'';
makeFlags = [
"BINDIR=${placeholder "out"}/bin/"
"INSTALLDIR=${placeholder "out"}/lib/ocaml/${ocaml.version}/site-lib/lablgl/"
"DLLDIR=${placeholder "out"}/lib/ocaml/${ocaml.version}/site-lib/stublibs/"
"XINCLUDES="
"TKINCLUDES="
"TKLIBS="
];
buildFlags = [ "lib" "libopt" "glut" "glutopt" ];
postInstall = ''