# -*- 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        c-amie analog-ce 6.0.18
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
name                analog
revision            0
categories          www
license             GPL-2
maintainers         nomaintainer
description         A program which analyses logfiles from WWW servers
long_description    {*}description. It is designed to be fast and to produce accurate \
                    and attractive statistics: and combined with Report Magic, you can \
                    generate even prettier reports.

homepage            http://www.c-amie.co.uk/software/analog/

checksums           rmd160  092c6c6e524cb9f5595a31bc8751b6df16a15822 \
                    sha256  0f3e3bb058b7d9378538b279f98b124f367db948c0643e2534099341708cfa1b \
                    size    4089366

# Note, it'd be nice to use an already-installed version of jpeg and libpng
# as well, but analog currently doesn't have a HAVE_ define for them, just
# zlib
depends_lib         lib:libz.1:zlib \
                    path:include/turbojpeg.h:libjpeg-turbo \
                    port:bzip2 \
                    port:libpng \
                    port:pcre2

patchfiles          patch-src_anlghead.h \
                    patch-src-Makefile.diff

post-patch {
    reinplace "s|@@PREFIX@@|${prefix}|g" "${worksrcpath}/src/anlghead.h"
}

use_configure       no

build.args          DEFS="-DHAVE_BZLIB -DHAVE_PCRE -DHAVE_ZLIB" \
                    LIBS="-lbz2 -ljpeg -lpcre2-8 -lpng -lz"
build.target        analog

destroot {
    xinstall -m 755 -d "${destroot}${prefix}/bin" \
        "${destroot}${prefix}/share/doc/${name}" \
        "${destroot}${prefix}/share/man/man1" \
        "${destroot}${prefix}/share/${name}"
    foreach item [list examples how-to images lang] {
        file copy ${worksrcpath}/${item} ${destroot}${prefix}/share/${name}
    }
    foreach item [glob ${worksrcpath}/docs/*] {
        file copy ${item} ${destroot}${prefix}/share/doc/${name}
    }
    xinstall -m 644 -W ${worksrcpath} ${name}.man \
        "${destroot}${prefix}/share/man/man1/${name}.1"
    xinstall -m 755 -W ${worksrcpath} ${name} "${destroot}${prefix}/bin"
}

platform darwin {
    build.args-append   OS="OSX"
}
