# -*- 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 92802 2012-05-07 06:56:59Z jeremyhu@macports.org $

PortSystem	1.0

name		asymptote
version		2.15
revision    1
categories	graphics
maintainers	gmail.com:loshea
description	a vector graphics language
long_description Asymptote is a powerful descriptive \
                 vector graphics language that provides a natural \
                 coordinate-based framework for technical drawing. \
                 Labels and equations are typeset with LaTeX, for \
                 high-quality PostScript output.
homepage	http://asymptote.sourceforge.net
license         LGPL-3+
platforms	darwin
configure.args  --with-latex=${prefix}/share/texmf-local/tex/latex \
                --mandir=${prefix}/share/man
master_sites	sourceforge
extract.suffix  .src.tgz
checksums       rmd160  1916f4160034d4d76280bfed8ebe0bb898fc80ce \
                sha256  89034b7f072fe0476bc00a9c4c52189f67cdc1cb9c07bab1fd88bc50b2e0c887
depends_build   port:texinfo
depends_lib	port:readline \
                port:texlive \
                port:ghostscript \
                port:fftw-3 \
                port:gsl \
                port:libsigsegv \
                port:ncurses \
                path:lib/libgc.dylib:boehmgc

# clang does not support the '--no-var-tracking' option
if {${configure.compiler} == "clang"} {
    patchfiles              patch-configure.ac.diff
    use_autoconf            yes
}

post-destroot {
    set python.bin ""
    if {[variant_isset python27]} {
        set python.bin ${prefix}/bin/python2.7
    } elseif {[variant_isset python26]} {
        set python.bin ${prefix}/bin/python2.6
    }
    if {${python.bin} != ""} {
        eval reinplace {"s|#!/usr/bin/env python|#!${python.bin}|"} \
            [glob -directory ${destroot}${prefix}/share/${name}/GUI *.py]
    } else {
        delete ${destroot}${prefix}/bin/xasy
    }
}

post-activate {
  # run `mktexlsr` to make sure the asymptote files are found:
  system "mktexlsr"
}
post-deactivate {
  system "mktexlsr"
}

variant python26 conflicts python27 description {Enable xasy GUI using Python 2.6} {
    depends_lib-append port:py26-tkinter port:py26-pil
}
variant python27 conflicts python26 description {Enable xasy GUI using Python 2.7} {
    depends_lib-append port:py27-tkinter port:py27-pil
}
if {![variant_isset python26]} {
    default_variants +python27
}
