# -*- 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 110572 2013-09-02 08:38:43Z jeremyhu@macports.org $

PortSystem          1.0

name                aamath
version             0.3
revision            2
categories          math textproc
platforms           darwin
license             GPL-2
maintainers         snc openmaintainer
description         renders ASCII art from mathematical expressions
long_description    Aamath is a program that reads mathematical expressions in \
                    infix notation and renders them as ASCII art. It may be \
                    useful to send mathematics through text-only media, such as\
                    e-mail or newsgroups.

homepage            http://fuse.superglue.se/aamath/
master_sites        ${homepage}

checksums           rmd160  396ce7213a30a5c133dc964e2a531fe28a24b6c0 \
                    sha256  9843f4588695e2cd55ce5d8f58921d4f255e0e65ed9569e1dcddf3f68f77b631

depends_build       port:byacc port:flex
depends_lib         port:readline port:ncurses

worksrcdir          aamath

configure.cppflags-append -I${prefix}/include/ncurses
configure.ldflags-append -lreadline -ltermcap -lncurses

# TODO: Fix this buggy C++ code which clang is correct to complain about.
# ./expr.h:454:43: error: redefinition of parameter 'c'
# void render_symbol(Canvas& c, int r, int c, int h) const;
compiler.blacklist  *clang*

patchfiles          patch-Makefile.diff
post-patch {
    reinplace s|@@CXX@@|${configure.cxx}|g ${worksrcpath}/Makefile
    reinplace s|@@LDFLAGS@@|${configure.ldflags}|g ${worksrcpath}/Makefile
    reinplace "s|@@CFLAGS@@|${configure.cflags} ${configure.cppflags}|g" ${worksrcpath}/Makefile
}

use_configure       no
installs_libs       no

destroot {
    xinstall -m 755 ${worksrcpath}/aamath ${destroot}${prefix}/bin
    xinstall -m 644 ${worksrcpath}/aamath.1 ${destroot}${prefix}/share/man/man1
    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} COPYING ChangeLog README \
        ${destroot}${prefix}/share/doc/${name}
}

livecheck.type      regex
livecheck.url       ${homepage}
livecheck.regex     "${name}-(\\d+.\\d+).tar.gz"

use_parallel_build  no
