PortSystem              1.0
PortGroup               xcode 1.0

name                    bootstrap_cmds
version                 121.100.1
epoch                   1
categories              devel
maintainers             nomaintainer
homepage                http://opensource.apple.com/source/${name}/
master_sites            https://github.com/apple-oss-distributions/${name}/archive
license                 APSL-2
installs_libs           no
description             Darwin Core OS Bootstrap Commands
long_description        Bootstrapping tools like the Mach Interface \
                        Generator (MIG) required to build the XNU kernel.

checksums               rmd160  f297049f1f8e43d1d53ba1d47d268e81f1ba1e0f \
                        sha256  c119228064f6e3f12dc22c38b9966aa36d9e89b78405e139fc2e75df399f62e3 \
                        size    108737

xcode.target            migcom
xcode.destroot.path     ${prefix}/bin

patchfiles              cc_fallback.patch

# for replath and decomment
if {${os.major} < 12} {
    version         80
    revision        5
    checksums       rmd160  772c9bf34e1f65ca5850b2cbc604504e60b8f117 \
                    sha256  446cb2090064496a0ee9043415d8e9bf6b1695d2cfffc4e2b31b4975ed02d914 \
                    size    279127

    supported_archs i386 ppc
    xcode.project   migcom.tproj/migcom.xcodeproj

    pre-build {
        file delete ${worksrcpath}/Makefile
        system "CC=${configure.cc} make -C ${worksrcpath} decomment.tproj/decomment relpath.tproj/relpath"
    }

    post-destroot {
        catch {file rename ${worksrcpath}/migcom.tproj/build/UninstalledProducts/migcom ${destroot}${prefix}/bin/}
        file rename ${destroot}${prefix}/bin/migcom ${destroot}${prefix}/libexec/migcom
        file rename ${worksrcpath}/decomment.tproj/decomment ${destroot}${prefix}/bin/
        file rename ${worksrcpath}/relpath.tproj/relpath ${destroot}${prefix}/bin/
        file rename ${worksrcpath}/migcom.tproj/mig.sh ${destroot}${prefix}/bin/mig
        file rename ${worksrcpath}/migcom.tproj/mig.1 ${worksrcpath}/migcom.tproj/migcom.1 \
            ${destroot}${prefix}/share/man/man1/
    }

} else {
    xcode.project   mig.xcodeproj

    post-extract {
        reinplace "s|\$(DT_TOOLCHAIN_DIR)/usr|${prefix}|g" \
            ${worksrcpath}/mig.xcodeproj/project.pbxproj
        foreach f [glob ${worksrcpath}/xcodescripts/*.sh] {
            reinplace "s|\$DSTROOT/\$DT_TOOLCHAIN_DIR/usr|${destroot}${prefix}|g" $f
        }
    }

    post-destroot {
        file rename ${destroot}${prefix}/bin/migcom ${destroot}${prefix}/libexec/migcom
    }

}

# handle stealth update; remove with next version change
dist_subdir             ${name}/${version}_1
worksrcdir              ${name}-${distname}

livecheck.type          regex
livecheck.regex         "${name}-(\[\\d.\]+)"
