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

PortSystem              1.0

name                    imake
version                 1.0.10
revision                0
categories              x11 devel
license                 X11
installs_libs           no
platforms               darwin
maintainers             {mcalhoun @MarcusCalhoun-Lopez} openmaintainer

description             Discontinued imake build system.
long_description        ${description}

homepage                https://www.x.org/wiki/
master_sites            xorg:individual/util/

use_xz                  yes

checksums               rmd160  66e2900e145b0dda4676424f04bffbf4a2f1a55a \
                        sha256  75decbcea8d7b354cf36adc9675e53c4790ee3de56a14bd87b42c8e8aad2ecf5 \
                        size    155284

depends_run             port:xorg-cf-files \
                        path:bin/perl:perl5
depends_build           port:pkgconfig \
                        port:xorg-xorgproto

if {${os.platform} eq "darwin" && ${os.major} >= 12} {
    depends_lib-append  port:tradcpp
    set cppcmd ${prefix}/bin/tradcpp
} else {
    set cppcmd /usr/bin/cpp
}

configure.env-append    RAWCPP=${cppcmd}

patchfiles              patch-imakemdep.h.diff
post-patch {
    reinplace "s|::CPPCMD::|${cppcmd}|" ${worksrcpath}/imakemdep.h
}

configure.env-append    HAS_PERL=yes

post-configure {
    # Ensure that the MacPorts perl is used
    reinplace \
        "s|#!/usr/bin/perl|#!${prefix}/bin/perl|" \
        ${worksrcpath}/mkhtmlindex.pl
}

livecheck.type          regex
livecheck.url           "https://www.x.org/releases/individual/util/?C=M;O=D"
livecheck.regex         ${name}-(\\d+(?:\\.\\d+)*)
