# -*- 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               github 1.0
PortGroup               makefile 1.0

github.setup            mmp pbrt-v2 e6f6334f3c26ca29eba2b27af4e60fec9fdc7a8d
name                    pbrt2
version                 20190104
revision                4
homepage                https://www.pbrt.org

categories              graphics
license                 BSD
maintainers             {mcalhoun @MarcusCalhoun-Lopez} openmaintainer

description             a photorealistic rendering system
long_description        Source code for pbrt, the renderer described in the second edition of \
                        \"Physically Based Rendering: From Theory To Implementation\", \
                        by Matt Pharr, Wenzel Jakob, and Greg Humphreys.

checksums               rmd160  5640cbb10226d83f34335bcfb3e1592aafcfb6eb \
                        sha256  ccd8084fff96eaac71a6d24314a391a22fd218d84dea2adaa1c6ccd04968bca3 \
                        size    14349299
github.tarball_from     tarball

conflicts               pbrt3

compiler.blacklist-append \
                        *gcc-4.*

depends_lib-append      port:openexr2 \
                        port:tiff \
                        port:zlib

patchfiles-append       patch-Makefile.diff

post-patch {
    reinplace "s|__PREFIX__|${prefix}|g" ${worksrcpath}/src/Makefile
}

pre-configure {
    build.pre_args-append MARCH="[get_canonical_archflags cc]"
}

build.dir               ${worksrcpath}/src
build.target            ""
build.pre_args-append \
    CC=${configure.cc} \
    CXX=${configure.cxx} \
    EXR_INCLUDES=-I${prefix}/libexec/openexr2/include/OpenEXR \
    EXR_LIBDIR=-L${prefix}/libexec/openexr2/lib \
    HAVE_LIBTIF=1 \
    TIFF_INCLUDES=-I${prefix}/include \
    TIFF_LIBDIR=-L${prefix}/lib \
    OPT=${configure.optflags}

destroot {
    xinstall -m 0755 {*}[glob ${worksrcpath}/src/bin/*]        ${destroot}${prefix}/bin
    xinstall -m 0755 {*}[glob ${worksrcpath}/src/objs/*.dylib] ${destroot}${prefix}/lib
    ln -s            libpbrt.2.dylib                           ${destroot}${prefix}/lib/libpbrt.dylib
}

variant universal       {}
