# -*- 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           compiler_blacklist_versions 1.0
PortGroup           github 1.0
PortGroup           legacysupport 1.0
PortGroup           makefile 1.0

github.setup        acpica acpica 20241212
git.branch          R[string range $version 0 3]_[string range $version 4 5]_[string range $version 6 7]
revision            0
categories          devel
# Comes with a restrictive Intel license in the source files, but the included
# acpisrc tool replaces them with an open source dual license.
# Why not just indicate triple licensing to start with? Who knows.
license             {Permissive GPL-2}
maintainers         {i0ntempest @i0ntempest} openmaintainer

description         ACPI compiler
long_description    A compiler for ACPI DSDT .asl files.

homepage            https://www.intel.com/content/www/us/en/developer/topic-technology/open/acpica/overview.html

checksums           rmd160  dfba8585032816ba634e1c6aeee04d5906ad86d0 \
                    sha256  98799e8008d6ac4b837281b8dc9bce30c6707489c73e83f467cc11acfe63bcfa \
                    size    7523679

# strnlen
legacysupport.newest_darwin_requires_legacy 10

depends_build       port:bison
depends_skip_archcheck-append \
                    bison

patchfiles          disable-silent-rules.patch
post-patch {
         reinplace "s|MACROPROC=  m4|MACROPROC=  gm4|" ${worksrcpath}/generate/unix/Makefile.config
}

platform darwin {
    if {${os.major} > 20 && ${configure.build_arch} eq "arm64"} {
       # See https://github.com/acpica/acpica/issues/781
       build.args-append \
                    OPT_CFLAGS="-DACPI_PACKED_POINTERS_NOT_SUPPORTED"
    } else {
        # CFLAGS has MacPorts optimization
        build.args-append \
                    OPT_CFLAGS=""
    }
}

# see generate/unix/Makefile.config
makefile.override-delete \
                    INSTALL

# dmtbdump2.c:1226: error: ‘for’ loop initial declaration used outside C99 mode
# aeinstall.c:443: error: ‘ACPI_RESOURCE_EXTENDED_IRQ’ has no member named ‘Interrupts’
compiler.blacklist-append \
                    *gcc-4.0 *gcc-4.2 {clang < 421}

livecheck.regex     ${name}-unix-(\[0-9.\]+)${extract.suffix}
livecheck.url       ${homepage}downloads/
livecheck.url       https://www.intel.com/content/www/us/en/download/776303
