# -*- 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
# $Id: Portfile 84550 2011-09-27 21:05:11Z snc@macports.org $

PortSystem 1.0

name                sdcc29
version             2.9.0
categories          lang
platforms           darwin
#license             GPLv3
maintainers         michaelld openmaintainer
description         ANSI C compiler targeting Intel 8051, Maxim 80DS390, Zilog Z80
long_description    SDCC is a freeware, retargettable, optimizing ANSI C \
                    compiler that targets the Intel 8051, Maxim 80DS390, and \
                    Zilog Z80 based MCUs. Work is in progress on supporting \
                    Motorola 68HC08 as well as Microchip PIC16 and PIC18 series.

homepage            http://sdcc.sourceforge.net/
master_sites        sourceforge
checksums           md5     a6151ed328fd3bc48305ffbc628dc122 \
                    sha1    03308a233a67e7fdce3f7e4972acb8731ae42666 \
                    rmd160  38f23365b676132651f0322779bff498eb7e2b8d

dist_subdir		    sdcc

depends_build       port:gputils
depends_lib         port:readline
depends_run         port:gputils

use_bzip2           yes
distfiles           sdcc-src-${version}${extract.suffix}

worksrcdir          sdcc

# requires "sizeof (long)" to be the a single value, so no universal;
# universal isn't really required anyway.
universal_variant   no

# Setting CPP explicitly is bad, because 'cpp' and
# 'gcc -E' are not the same.
configure.cpp       {}

# make sure to not use any already installed headers and libraries;
# these are set in CPATH and LIBRARY_PATH anyway.
configure.args-append --prefix=${prefix}/libexec/${name}
configure.ldflags-delete "-L${prefix}/lib"
configure.cppflags-delete "-I${prefix}/include"

platform darwin 8 {
    depends_build-append    port:gmake
    build.cmd               ${prefix}/bin/gmake
    build.type              gnu
}

platform darwin 11 {
    post-patch {
        # 10.7 provides 'getline()' already, but it is not
        # interchangeable with that provided by SDCC. change SDCC's
        # internal to "sdcc_getline", but not the #includes
        reinplace "/getline/s@getline @sdcc_getline @g" \
            ${worksrcpath}/as/link/getline.h \
            ${worksrcpath}/as/link/getline.c \
            ${worksrcpath}/as/link/lklib.c \
            ${worksrcpath}/as/link/lkrel.c \
            ${worksrcpath}/as/link/lksdcclib.c
    }
}
