# -*- 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 119755 2014-05-05 17:52:45Z devans@macports.org $

PortSystem          1.0

name                surf
version             1.0.6
categories          math
platforms           darwin
license             GPL-2
maintainers         gmail.com:shreevatsa.public \
                    openmaintainer
description         Visualization of real algebraic geometry.
long_description \
    surf is a tool to visualize some real algebraic geometry: \
    plane algebraic curves, algebraic surfaces and hyperplane sections of surfaces. \
    surf is script driven and has (optionally) a nifty GUI using the Gtk widget set.

homepage            http://surf.sourceforge.net/
master_sites        sourceforge:project/surf/surf/${version}/

checksums           rmd160  27e21733ecacff85ca8d0b982c6378fd58722c97 \
                    sha256  8a5326bd50ed8c4e4c49f13dac3b4cf419944d2279d71b897faafcbdc3f99cd8

# libX11 is needed not only for the GUI option but also to support X11 image file formats

depends_lib         port:gmp \
                    port:flex \
                    port:jpeg \
                    port:tiff \
                    port:xorg-libX11

patchfiles          patch-configure.diff

configure.args      --x-includes=${prefix}/include \
                    --x-libraries=${prefix}/lib \
                    --enable-cups=no \
                    --enable-gui=no
                    
variant gui description {Enable gtk1 based GUI} {
    depends_lib-append      port:gtk1 \
                            port:xorg-libXmu
    configure.args-delete   --enable-gui=no \
                            --enable-cups=no
}

default_variants +gui

post-destroot {
    copy ${worksrcpath}/examples ${destroot}${prefix}/share/${name}/
    system "chmod -R 755 ${destroot}${prefix}/share/${name}/examples/* && \
        chmod -R 644 ${destroot}${prefix}/share/${name}/examples/*/*"
    xinstall -d -m 755 ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 ${worksrcpath}/docs/manual.sgml ${destroot}${prefix}/share/doc/${name}/
}
