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

name                    doxygen
version                 1.8.13
revision                2
categories              textproc devel
maintainers             css openmaintainer
license                 GPL-2
description             Documentation system for several programming languages
long_description        It can generate an on-line documentation browser \
                        (in HTML) and/or an off-line reference manual \
                        from a set of documented source files. There is \
                        also support for generating output in RTF \
                        (MS-Word), PostScript, hyperlinked PDF, \
                        compressed HTML, and Unix man pages. The \
                        documentation is extracted directly from the \
                        sources, which makes it much easier to keep the \
                        documentation consistent with the source code. \
                        You can configure doxygen to extract the code \
                        structure from undocumented source files. This \
                        is very useful to quickly find your way in large \
                        source distributions. You can also visualize the \
                        relations between the various elements by means \
                        of include dependency graphs, inheritance \
                        diagrams, and collaboration diagrams, which are \
                        all generated automatically.

platforms               darwin

homepage                http://www.doxygen.org/
master_sites            http://ftp.stack.nl/pub/users/dimitri/ \
                        ftp://ftp.stack.nl/pub/users/dimitri/
distfiles               ${distname}.src${extract.suffix}

checksums               ${distname}.src${extract.suffix} \
                        rmd160  00f6f8baeead8c3d99eabe1d61ffefa4e48af1f9 \
                        sha256  af667887bd7a87dc0dbf9ac8d86c96b552dfb8ca9c790ed1cbffaa6131573f6b

installs_libs           no

depends_build-append    bin:perl:perl5 \
                        bin:python2.7:python27 \
                        port:flex \
                        port:bison
license_noconflict      perl5 python27

depends_lib             port:libpng \
                        port:libiconv

patchfiles              patch-src-portable_c.c.diff \
                        fix_dumb_cxxflags.patch

# temporary patch to fix possible use of NULL pointer.
# see also: https://github.com/doxygen/doxygen/commit/381d9d286dd27ce0ba14989b51011070d8583d62
patchfiles-append       patch-src-xmlgen.cpp.diff

# see #50342
configure.args-append -DPython_ADDITIONAL_VERSIONS=2.7

# cmake PortGroup sets arch flags
# duplicate archflags can cause problems
# see #50044
# see #48331
# see https://cmake.org/pipermail/cmake-developers/2015-September/thread.html#26586
configure.universal_cflags
configure.universal_cxxflags
configure.universal_objcflags
configure.universal_objcxxflags
configure.universal_ldflags
configure.cc_archflags
configure.cxx_archflags
configure.objc_archflags
configure.objcxx_archflags
configure.ld_archflags

post-extract {
    # Use our flex
    delete ${worksrcpath}/src/ce_lex.cpp
    delete ${worksrcpath}/src/code.cpp
    delete ${worksrcpath}/src/commentcnv.cpp
    delete ${worksrcpath}/src/commentscan.cpp
    delete ${worksrcpath}/src/config.cpp
    delete ${worksrcpath}/src/declinfo.cpp
    delete ${worksrcpath}/src/defargs.cpp
    delete ${worksrcpath}/src/doctokenizer.cpp
    delete ${worksrcpath}/src/fortrancode.cpp
    delete ${worksrcpath}/src/fortranscanner.cpp
    delete ${worksrcpath}/src/pre.cpp
    delete ${worksrcpath}/src/pycode.cpp
    delete ${worksrcpath}/src/pyscanner.cpp
    delete ${worksrcpath}/src/scanner.cpp
    delete ${worksrcpath}/src/tclscanner.cpp
    delete ${worksrcpath}/src/vhdlcode.cpp
    delete ${worksrcpath}/src/vhdlscanner.cpp

    # Use our bison
    delete ${worksrcpath}/src/ce_parse.cpp
    delete ${worksrcpath}/src/ce_parse.h
    delete ${worksrcpath}/src/vhdlparser.cpp
    delete ${worksrcpath}/src/vhdlparser.h
}

set cxx_stdlibflags {}
if {[string match *clang* ${configure.cxx}]} {
    set cxx_stdlibflags -stdlib=${configure.cxx_stdlib}
}

# build fails out of source :/
cmake.out_of_source     no

destroot.args           INSTALL=${prefix} \
                        DOCDIR=${prefix}/share/doc/doxygen \
                        MAN1DIR=share/man/man1

variant docs description {Include the doxygen HTML and PDF documentation} {
    configure.args-append   -Dbuild_doc=YES \
                            -EPSTOPDF=${prefix}/bin/epstopdf

    depends_build-append    path:bin/dot:graphviz \
                            bin:gs:ghostscript \
                            port:texlive \
                            port:texlive-latex-extra

    build.target-append     docs
    use_parallel_build      no
}

variant wizard requires qt4 description {Compatibility variant} {}

variant qt4 conflicts qt5 description {Include the GUI wizard based on Qt4} {
    # use the Qt4 PortGroup, which provides a bunch of variables
    # and defines for how Qt4 was installed
    PortGroup qt4 1.0

    # tell configure to make the wizard app
    configure.args-append   -Dbuild_wizard=YES -Dforce_qt4=YES
}

variant qt5 conflicts qt4 description {Include the GUI wizard based on Qt5} {
    # use the Qt5 PortGroup, which provides a bunch of variables
    # and defines for how Qt5 was installed
    PortGroup qt5 1.0

    # tell configure to make the wizard app
    configure.args-append   -Dbuild_wizard=ON
}

livecheck.type          regex
livecheck.url           http://www.stack.nl/~dimitri/doxygen/download.html
livecheck.regex         {latest version of doxygen is (\d+(?:\.\d+)*)}