# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           perl5 1.0

perl5.branches      5.28 5.30 5.32 5.34
perl5.setup         OpenGL 0.70
revision            1
platforms           {darwin < 22}
# can be distributed under the same terms as Perl itself
# see https://metacpan.org/pod/OpenGL#AUTHORS
license             {Artistic-1 GPL}
maintainers         nomaintainer
description         Perl OpenGL: a.k.a. POGL
long_description    Perl OpenGL (a.k.a. POGL) is a perl5 interface to \
                    opengl, glu, and glut. Virtually all of the OpenGL 1.0 and 1.1 \
                    functions are available as well as most of 1.2.  The functional \
                    interface is very similar to using C with most changes made in an \
                    obvious way (see man page for details).  High-level object interfaces \
                    are available in the form of OpenGL::Array, OpenGL::Image, and \
                    OpenGL::Shader.

checksums           rmd160  84eee832fed158d7bb4d303fbaf0022de792779a \
                    sha256  b20e2af4404b4901ab35bba6ad5e3a8aa60bff72413c99288f01018c4cf874e0 \
                    size    783810

# to correctly configure supported OpenGL capabilities, the port must be able
# to query the display on the target machine during the configure phase
# clear archive_sites to avoid loading an inappropriately configured prebuilt binary
archive_sites

if {${perl5.major} != ""} {
    depends_build-append \
                    port:p${perl5.major}-time-hires

    depends_lib-append \
                    port:mesa \
                    port:libGLU \
                    port:freeglut \
                    port:xorg-libXext \
                    port:xorg-libXmu \
                    port:xorg-libXi \
                    port:xorg-libice \
                    port:xorg-libX11

    # glext_procs.h:582: error: redefinition of typedef ‘GLsizeiptr’
    compiler.c_standard 2011

    patchfiles      patch-Makefile.PL.diff \
                    patch-utils-Makefile.macosx.diff

    post-patch {
        reinplace "s|@@MP_PREFIX@@|${prefix}|" ${worksrcpath}/Makefile.PL
        reinplace "s|@@MP_CC@@|${configure.cc}|" ${worksrcpath}/utils/Makefile.macosx
    }

    configure.pre_args-append verbose interface=GLX

    # pogl_gl_Mult_Prog.c:216:31: error: initialization of 'GLhandleARB' {aka 'void *'}
    # from 'unsigned int' makes pointer from integer without a cast [-Wint-conversion]
    if {[string match *gcc* ${configure.compiler}]} {
        configure.args-append \
                    CCFLAGS=-Wno-error=int-conversion
    }
}
