# -*- 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      frankheckenbach ftgl 2.4.0 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
revision          1
categories        graphics
license           MIT
maintainers       nomaintainer

description       Freetype / OpenGL bridge
long_description  FTGL takes freetype fonts, decodes them, and generate an OpenGL \
                  object out of it.  It supports a lot of rendering modes.

checksums         rmd160  c904e2aa2e5dc5329867ce120f4b1ebe1910ff65 \
                  sha256  933a371dbb2f44c9fa3121484d46081b5f1ed08c18908ba49bff92811629aede \
                  size    630956

use_autoreconf              yes
autoreconf.env              LIBTOOLIZE=${prefix}/bin/glibtoolize
autoreconf.cmd              ./autogen.sh
autoreconf.args

depends_lib-append \
    port:freetype 

depends_build-append \
    port:autoconf \
    port:automake \
    port:gsed \
    port:libtool \
    port:pkgconfig

patchfiles                  AC_ARG_WITH.patch \
                            dylib_file.patch \
                            patch-src-FTVectoriser.cpp.diff

# Don't use MacPorts X11 since there doesn't seem to be a need to do so.
# Don't use MacPorts OpenGL (mesa) since that would bring in X11 deps.
configure.args-append       ac_cv_header_GL_gl_h=no \
                            ac_cv_header_GL_glu_h=no \
                            --with-gl-lib=/System/Library/Frameworks/OpenGL.framework/Libraries \
                            --with-glu-lib=/System/Library/Frameworks/OpenGL.framework/Libraries \
                            --without-x

# Skip building the example program by failing to find GLUT
configure.args-append       ac_cv_header_GL_glut_h=no \
                            ac_cv_header_GLUT_glut_h=no

# Build requires c++11 but does not seem to explicitly enable it...
configure.cxxflags-append -std=c++11
compiler.cxx_standard       2011

# Don't warn that OpenGL is deprecated in macOS; it clutters up the log.
configure.cflags-append     -DGL_SILENCE_DEPRECATION
configure.cxxflags-append   -DGL_SILENCE_DEPRECATION

# https://github.com/frankheckenbach/ftgl/issues/17
if {[string match *gcc* ${configure.compiler}]} {
    configure.cxxflags-append \
                            -fpermissive
}

variant doc description {build documentation} {
    depends_build-append    bin:doxygen:doxygen \
                            bin:dvips:texlive-basic \
                            bin:pdflatex:texlive-latex \
                            bin:epstopdf:texlive-fontutils \
                            bin:convert:ImageMagick
}

if {![variant_isset doc]} {
    configure.args-append   ac_cv_path_DOXYGEN=no \
                            ac_cv_path_DVIPS=no \
                            ac_cv_path_LATEX=no \
                            ac_cv_path_KPSEWHICH=no \
                            ac_cv_path_EPSTOPDF=no \
                            ac_cv_path_CONVERT=no
}
