PortSystem              1.0
PortGroup               xcode 1.0

name                    bootstrap_cmds
version                 86
epoch                   1
categories              devel
maintainers             nomaintainer
homepage                http://opensource.apple.com/source/${name}/
master_sites            http://opensource.apple.com/tarballs/${name}/
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  fca2a2bd26a1ca825e25281322914b70d3485278 \
                        sha256  8b8be9a719c60e532454a4fc614e74140ff10a822855b5e6c123872a4d122077

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  072e399562eb021e4fa0cd66132153afcc02f417 \
                    sha256  2ae65cd2ca6f0f684b25aad46a649aeb95a774d06a8287c59962fba42900a2fc

    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
    }

}

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