# $Id: Portfile 105900 2013-05-09 15:11:20Z macsforever2000@macports.org $

PortSystem      1.0
PortGroup       active_variants 1.1

name            wxMaxima
version         12.01.0
maintainers     usami-k openmaintainer
license         gpl
platforms       darwin
categories      math aqua
description     Graphical user interface for Maxima
long_description \
                wxMaxima is a cross platform GUI for the computer algebra \
                system maxima based on wxWidgets.
homepage        http://wxmaxima.sourceforge.net/
master_sites    sourceforge:project/wxmaxima/${name}/${version}
livecheck.regex ${name}-(\[a-z0-9.\]+)${extract.suffix}
checksums           md5     ef71ba8339fcdd7b715619af51bfa65e \
                    sha1    d80002ddea3260b0f3315072f23b4bb3cce3a10a \
                    rmd160  47891ac06c2e9b789c9581901c1e410e932beecd
patchfiles      patch-src_main.cpp.diff \
                patch-src_Config.cpp.diff \
                patch-src_wxMaxima.cpp.diff

depends_lib     port:libiconv \
                path:lib/pkgconfig/sdl.pc:libsdl \
                port:libxml2 \
                port:wxWidgets \
                port:zlib
depends_run     port:maxima

platform darwin 11 {
    if {[vercmp $xcodeversion 4.4] < 0} {
        if {[vercmp $xcodeversion 4.3] >= 0} {
            configure.cxxflags-append -isysroot ${developer_dir}/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.6.sdk
        } else {
            configure.cxxflags-append -isysroot ${developer_dir}/SDKs/MacOSX10.6.sdk
        }
    }
}

post-patch {
    reinplace "s|@@PREFIX@@|${prefix}|" ${worksrcpath}/src/main.cpp
}

depends_skip_archcheck  maxima
supported_archs         i386 ppc
configure.args  --enable-dnd --enable-printing --enable-unicode-glyphs
build.target-append wxMaxima.app

if {[catch {registry_active wxwidgets-devel}] == 0} {
    default_variants +wxwidgets_devel
}

if {[catch {registry_active wxwidgets30}] == 0} {
    default_variants +wxwidgets30
}

if { ![variant_isset wxwidgets_devel] } {
    default_variants    +wxwidgets30
}

destroot {
    xinstall -m 755 -d ${destroot}${applications_dir}
    file copy ${worksrcpath}/wxMaxima.app ${destroot}${applications_dir}

    set docPath ${prefix}/share/doc/${name}
    xinstall -m 755 -d ${destroot}${docPath}
    foreach f { AUTHORS COPYING README } {
        xinstall -m 644 ${worksrcpath}/${f} ${destroot}${docPath}
    }
}

variant wxwidgets_devel description {Build against wxWidgets-devel rather than wxWidgets} {
    # if the user has installed wxWidgets-devel, force using that
    # (from gobject-introspection)
    depends_lib-delete  port:wxWidgets
    depends_lib-append  port:wxWidgets-devel

    require_active_variants gnuplot wxwidgets_devel

    supported_archs     i386 x86_64
}

variant wxwidgets30 description {Build against wxWidgets30 rather than wxWidgets} {
    # if the user has installed wxWidgets30, force using that
    # (from gobject-introspection)
    depends_lib-delete  port:wxWidgets
    depends_lib-append  port:wxWidgets30

    require_active_variants gnuplot wxwidgets30

    supported_archs     i386 x86_64
}
