# -*- 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 20250404
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  1ac0ea704e6c0e80401d525399e3f04de20eaeac \
                    sha256  9991ec103b3660d17715780406ee7409f705cf87ac55e9a32374affe1a6f275a \
                    size    7718437

# 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
