Subject: [bug#43654] [PATCH] Add perl-opengl

From: Andreas Enge <[email-masked]>
Date: Tue, 6 Oct 2020 00:35:43 +0200

On Mon, Oct 05, 2020 at 10:51:29PM +0200, Andreas Enge wrote:
> So one option would be to disable the test ("#:tests? #f") and create the
> essentially empty glversion.txt file above inside a phase. There would not
> even be a need to store it as a an auxiliary file; see the use of
> "call-with-output-file" in guix/tests.scm, for instance.

Something like this:
         (add-before 'configure 'glversion
           ;; Building utils/glversion.txt fails, and is probably
           ;; dependent on the graphics card in the build system.
           ;; Replace it by a content-free file; while this breaks
           ;; the test, the examples in the examples/ subdirectory
           ;; can be run.
           (lambda _
             (substitute* "Makefile.PL"
               (("unlink") "# unlink") ; prevent utils/glversion.txt
                                       ; from being deleted once...
               (("\\.\"\\$make_ver clean\"") "")) ; ...and twice...
             (substitute* "utils/Makefile"
               (("all: glversion.txt") "all: ")) ; ...and thrice.
             (call-with-output-file "utils/glversion.txt"
               (lambda (port)
                 (display (string-append "FREEGLUT=\nGLUT=\nVERSION=\n"
                                         "VENDOR=\nRENDERER=\n"
                                         "EXTENSIONS=\n")
                          port)))
             #t))

I tried to add the following instead of patching Makefile.PL:
         (add-before 'configure 'fix-interface
           ;; Libraries are not found in default locations, so force
           ;; an interface.
           (lambda _
             (substitute* "Makefile.PL"
               (("die \"FreeGLUT or GLUT libraries")
                "$interface_lib = 'FREEGLUT'; #"))
             #t))

But it fails during compilation with error messages such as this one:
/gnu/store/1qmd9achfkm1njzxf8hi86q53pmy9sxk-mesa-20.0.7/include/GL/glxext.h:530:169: error: unknown type name ‘GLintptr’; did you mean ‘GLint’?
>From some search engine results, I surmise that I am missing the
  $DEFS .= " -DGL_GLEXT_LEGACY";
from line 525 of Makefile.PL.

So maybe we will have to replace the "-L/what/ever" as you do it in your
cdr/match phase; but instead of adding a patch that drops the "-L" in
favour of some "@@libpaths@@" text, only to replace the new text again
in a phase, I would use just a phase. For instance, instead of replacing
"^@@libdirs@@", just replace "-L/usr/local/freeglut/lib".

But it is already tomorrow, time to stop.

Andreas