# -*- 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

name           bsdmake
version        24
revision       1
# stealth upgraded from Apple-hosted to github-hosted
dist_subdir    ${name}/${version}_1
categories     devel
license        BSD
maintainers    {raimue @raimue} \
               openmaintainer
installs_libs  no

description    BSD make
long_description \
    BSD make is a build tool to create programs and libraries by rules \
    specified in a Makefile. This port is based on the last version from Apple as \
    provided by Xcode 4.2.

homepage       http://opensource.apple.com/
               # see also http://www.freebsd.org/cgi/cvsweb.cgi/src/usr.bin/make/
master_sites   https://github.com/apple-oss-distributions/${name}/archive

checksums      rmd160  1f08d49704391725cc304c455ead7e48103fd8cf \
               sha256  096f333f94193215931a9fab86b9bca0713fbd22ec465bf55510067b53940e62 \
               size    238536
worksrcdir     ${name}-${name}-${version}

patchfiles     patch-Makefile.diff \
               patch-mk.diff \
               patch-pathnames.diff \
               patch-setrlimit.diff

post-patch {
    reinplace "s:@PREFIX@:${prefix}:g" \
        ${worksrcpath}/mk/bsd.README \
        ${worksrcpath}/mk/bsd.cpu.mk \
        ${worksrcpath}/mk/bsd.doc.mk \
        ${worksrcpath}/mk/bsd.obj.mk \
        ${worksrcpath}/mk/bsd.own.mk \
        ${worksrcpath}/mk/bsd.port.mk \
        ${worksrcpath}/mk/bsd.port.subdir.mk \
        ${worksrcpath}/mk/sys.mk \
        ${worksrcpath}/pathnames.h
    reinplace "s:@INSTALL_USER@:${install.user}:g"   ${worksrcpath}/mk/bsd.own.mk
    reinplace "s:@INSTALL_GROUP@:${install.group}:g" ${worksrcpath}/mk/bsd.own.mk
}

use_configure no

build.target
# Using some pseudo MACHINE here, this ends up as ${MACHINE} in Makefiles
build.args -f Makefile.dist \
           CC="${configure.cc}" \
           CFLAGS="-D__FBSDID=__RCSID -mdynamic-no-pic \
                   -DMACHINE=\\\\\\\"MacPorts\\\\\\\" \
                   -DMACHINE_ARCH=\\\\\\\"${configure.build_arch}\\\\\\\"" \
           WARNS=1

destroot {
    xinstall -m 755 ${worksrcpath}/pmake ${destroot}${prefix}/bin/bsdmake
    xinstall -m 444 ${worksrcpath}/make.1 ${destroot}${prefix}/share/man/man1/bsdmake.1
    xinstall -d ${destroot}${prefix}/share/mk/bsdmake
    xinstall -m 644 {*}[glob ${worksrcpath}/mk/*] ${destroot}${prefix}/share/mk/bsdmake
}

livecheck.type none
