# -*- 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 99376 2012-11-04 03:31:08Z ryandesign@macports.org $

PortSystem      1.0

name            ngspice
version         24
license         BSD
categories      science cad
maintainers     nomaintainer
platforms       darwin
description     Circuit simulator based on Spice 3f5
long_description \
                Ngspice is a mixed-level/mixed-signal circuit simulator. Its \
                code is based on three open source software packages: Spice3f5, \
                Cider1b1 and Xspice. Ngspice is part of gEDA project, a full \
                GPL'd suite of Electronic Design Automation tools. \
                Note: this port does not compile the Cider module.

homepage        http://ngspice.sourceforge.net/
master_sites    sourceforge:project/ngspice/ng-spice-rework/${version}

checksums       rmd160  69363d58ef69724f5ac909dcda278095b12bb8dd \
                sha256  86d2748f6a62db2ed1c4601b24984f6698c88b910bf263ce975467bc6039f065

set docdir      ${prefix}/share/doc/${name}

if {${name} == ${subport}} {
    depends_lib         port:libedit \
                        port:xorg-libXaw
    
    configure.args      --enable-x \
                        --enable-xspice \
                        --with-editline \
                        --x-includes=${prefix}/include \
                        --x-libraries=${prefix}/lib
    
    post-destroot {
        xinstall -d ${destroot}${docdir}
        xinstall -m 644 -W ${worksrcpath} \
            ANALYSES \
            AUTHORS \
            BUGS \
            COPYING \
            ChangeLog \
            DEVICES \
            FAQ \
            NEWS \
            README \
            Stuarts_Poly_Notes \
            ${destroot}${docdir}
    }
    
    variant manual description {Legacy compatibility variant} {
        depends_run-append  port:ngspice-docs
    }
    
    livecheck.regex     ${name}-(\[0-9.\]+)${extract.suffix}
} else {
    livecheck.type      none
}

subport ngspice-docs {
    supported_archs     noarch
    description         PDF manual for ngspice
    long_description    ${description}
    
    distname            ${name}${version}-manual.pdf
    extract.suffix      .gz
    
    checksums           rmd160  ec9a55175ca352530565b224032b5bb04f14a51b \
                        sha256  dfb87979f285297f1e4c7fdbfc6380cc906f408019cdb39653d8e4411bb94ac4
    
    extract.only
    
    use_configure       no
    
    build {}
    
    destroot {
        xinstall -d ${destroot}${docdir}
        system "gzcat ${distpath}/${distfiles} > ${destroot}${docdir}/${name}-manual.pdf"
    }
}
