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

name                httrack
version             3.49.2
revision            2
categories          net
platforms           darwin
maintainers         nomaintainer
license             GPL-2+

description         Website Copier/Offline Browser

long_description    HTTrack is an offline browser utility that allows you to \
                    download a website from the Internet to a local directory.

homepage            http://www.httrack.com/
master_sites        http://mirror.httrack.com/historical/

checksums           rmd160  e1ce07330443a0f4db366d1355681319026eae05 \
                    sha256  3477a0e5568e241c63c9899accbfcdb6aadef2812fcce0173688567b4c7d4025

depends_build       port:gmake
depends_lib         path:lib/libssl.dylib:openssl \
                    port:libiconv \
                    port:zlib

patchfiles          patch-src-htsweb.c.diff \
                    patch-src-webhttrack.diff

# See https://trac.macports.org/ticket/42384
patchfiles-append   patch-libiconv.diff
depends_build-append \
                    port:autoconf-archive

post-patch {
    reinplace -locale C "s|@PREFIX@|${prefix}|g" \
        ${worksrcpath}/src/htsweb.c \
        ${worksrcpath}/src/webhttrack
}

configure.args      --with-sysroot=${prefix} \
                    --with-zlib=${prefix}

# Makefile fails during parallel builds
use_parallel_build  no
use_autoreconf      yes

post-destroot {
    # Remove metadata files not used by darwin or OS X
    file delete ${destroot}${prefix}/share/pixmaps/httrack.xpm
    file delete -force ${destroot}${prefix}/share/applications/
}

test.run            yes
test.target         check

livecheck.type      regex
livecheck.url       http://download.httrack.com/cserv.php3?queryVersionNumberDigit
livecheck.regex     ^(.+)$