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

PortSystem          1.0
PortGroup           boost 1.0
PortGroup           lua 1.0
PortGroup           makefile 1.0
PortGroup           gitlab 1.0

gitlab.setup        saalen highlight 4.18 v
revision            0

categories          textproc devel
license             GPL-3
maintainers         {i0ntempest @i0ntempest} openmaintainer
description         converts source code to formatted text with syntax highlighting
long_description    ${description}

homepage            http://andre-simon.de/doku/highlight/en/highlight.php

checksums           rmd160  85ce6bdc4b091f42ebd0939dc75a6066a9a078c8 \
                    sha256  c65a74e2f90ccdbeafe219bb2104d5fd3399a1d827f19b5f90125d2d717abd6c \
                    size    1539431

boost.version       1.87

boost.depends_type  build

depends_build       port:cctools \
                    port:pkgconfig

post-patch {
    reinplace "s|/etc/highlight/|${prefix}/etc/highlight/|g" ${worksrcpath}/man/highlight.1
    reinplace "s|/usr/share/|${prefix}/share/|g" ${worksrcpath}/man/highlight.1
}

build.target        cli lib

compiler.cxx_standard \
                    2017
configure.cxxflags-append \
                    -std=c++17

# Yes, this project's makefile uses CFLAGS to compile its C++ code.
build.args          CFLAGS="\$CPPFLAGS \$CXXFLAGS" \
                    LDFLAGS="\$LDFLAGS \$CXXFLAGS" \
                    LUA_PKG_NAME=lua${lua.version}

makefile.override   PREFIX

post-destroot {
    file rename ${destroot}${prefix}/etc/highlight/filetypes.conf \
        ${destroot}${prefix}/etc/highlight/filetypes.conf.sample
}

post-activate {
    set conffile ${prefix}/etc/highlight/filetypes.conf
    # copy over the sample conf file if necessary
    if { ![file exists ${conffile}] } {
        file copy ${conffile}.sample ${conffile}
    }
}
