# -*- 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

github.setup            mmp pbrt-v2 e6f6334f3c26ca29eba2b27af4e60fec9fdc7a8d
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from     tarball
name                    pbrt2
version                 20190104
revision                3
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

conflicts               pbrt3

use_configure           no

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

patchfiles-append       patch-Makefile.diff

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

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

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

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 {}
