PortSystem 1.0

name            cc65
conflicts       grc
version         2.13.3
categories      lang
platforms       darwin
maintainers     gmail.com:trashgod openmaintainer

description     6502 C compiler
long_description \
                cc65 is a complete cross development package for 65(C)02 \
                systems, including a powerful macro assembler, a C compiler, \
                linker, librarian and several other tools.

# Per http://www.cc65.org/ discontinued support in 2013, moved to github
# No version tags on github yet
homepage        http://cc65.github.io/cc65
distfiles       cc65-sources-${version}.tar.bz2
use_bzip2       yes

master_sites    http://cc65.oldos.net/ \
                http://bj.spline.de/cc65/ \
                ftp://ftp.musoftware.de/pub/uz/cc65/ \
                ftp://ftp.musoftware.de/pub/uz/cc65/old/

checksums       rmd160  ad728cb61113af4592460bce7d42ca57f6a2fb1a \
                sha256  a98a1b69d3fa15551fe7d53d5bebfc5f9b2aafb9642ee14b735587a421e00468

use_configure   no

build.target    bins libs
build.args      -f make/gcc.mak prefix=${prefix}
use_parallel_build no

destroot.args   -f make/gcc.mak prefix=${destroot}${prefix}

post-patch {
    foreach file [glob ${worksrcpath}/src/*/make/gcc.mak] {
        reinplace -E "s|^CC\[\[:space:\]\]*=\[\[:space:\]\]*gcc|CC=${configure.cc}|" $file
    }
}

variant docs description {Install extra documentation} {
    depends_build-append port:linuxdoc-tools
    build.target-append docs
    post-destroot {
        set docdir ${destroot}${prefix}/share/doc/${name}
        file mkdir "${docdir}/html"
        foreach file [glob -directory ${docdir} *.htm*] {
            move ${file} "${docdir}/html"
        }
    }
}