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

github.setup        acpica acpica 20260408
github.tarball_from archive
#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  1126b1156e2a0d30837a46ca6ad30b8cb7bb8664 \
                    sha256  ddc5d3e0f54030e2348484fff681861a161efb4e388e20631209574e7884ad39 \
                    size    7623586

# 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       https://www.intel.com/content/www/us/en/download/776303
