# -*- 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 79026 2011-05-30 22:03:49Z snc@macports.org $

PortSystem          1.0

name                pspp-devel
set buildstamp      20110530030505
set buildhash       geb2a79
version             0.7.8
revision            3
# depends_test port:p5-text-diff
categories          math
license             GPL-3+
maintainers         snc
conflicts           pspp
description         Statistical analysis of sampled data (free \
                    replacement for SPSS).
long_description    PSPP is a program for \
                    statistical analysis of sampled data. It is a Free \
                    replacement for the proprietary program SPSS, and \
                    appears very similar to it with a few exceptions.

homepage            http://www.gnu.org/software/pspp/
platforms           darwin

master_sites        http://pspp.benpfaff.org/~blp/pspp-master/${buildstamp}
distname            pspp-${version}-${buildhash}

depends_lib		    port:gsl \
                    port:libiconv \
                    port:zlib \
                    port:libxml2 \
                    port:readline \
                    port:plotutils \
                    port:pkgconfig \
                    port:gtk2 \
                    port:libglade2 \
                    port:libtool

checksums           sha1    78b6a787f4682177c371c0278a5f82e2ba340a0a \
                    rmd160  a60ce379f29048dcbf6b10c24f1439cfd70fb3dc

#configure.optflags  -O0
#configure.cflags-append -g
configure.env-append CPPFLAGS=-I${prefix}/include
configure.perl      ${prefix}/bin/perl
configure.args      --disable-rpath \
                    --without-libpq \
                    --without-libncurses \
                    --with-packager=snc \
                    --with-packager-version=${version}-${buildstamp} \
                    --with-packager-bug-reports=${maintainers}

use_parallel_build  yes

test.run            yes
test.target         check

variant help conflicts no_gui description {Provide in-application help via yelp} {
    depends_run-append  port:yelp
}

variant ncurses description {Enable terminal resizing} {
    depends_lib-append  port:ncursesw
    configure.args-delete   --without-libncurses
}

variant doc description {Build documentation} {
    depends_lib-append   port:texinfo
    build.target-append  pdf html
    post-destroot {
        xinstall -d -m 0755 ${destroot}${prefix}/share/doc/${name}
        foreach fl [glob -nocomplain -directory ${worksrcpath}/doc *.pdf *.html] {
            copy ${fl} ${destroot}${prefix}/share/doc/${name}
        }
    }
}

variant postgres description {Enables reading of postgresql databases} {
    depends_lib-append  port:postgresql83
    configure.args-delete   --without-libpq
    configure.ldflags-append -L${prefix}/lib/postgresql83
}

variant no_graph description {Disable graphing features} {
    depends_lib-delete      port:plotutils
    configure.args-append   --without-libplot
}

variant no_gui conflicts help description {Disable PSPPIRE, the graphical interface} {
    depends_lib-delete      port:pkgconfig \
                            port:gtk2 \
                            port:libglade2
    configure.args-append   --without-gui
}

post-destroot {
    if {![variant_isset no_gui]} {
	    xinstall -d ${destroot}${applications_dir}/PSPP.app/Contents/MacOS
        xinstall -m 755 ${filespath}/PSPP.app/Contents/MacOS/psppire \
            ${destroot}${applications_dir}/PSPP.app/Contents/MacOS
	    xinstall -m 644 ${filespath}/PSPP.app/Contents/Info.plist \
		    ${destroot}${applications_dir}/PSPP.app/Contents
        reinplace s|@VERSION@|${version}|g \
            ${destroot}${applications_dir}/PSPP.app/Contents/Info.plist
        reinplace s|@PREFIX@|${prefix}|g \
            ${destroot}${applications_dir}/PSPP.app/Contents/MacOS/psppire
        reinplace s|@NAME@|${name}|g \
            ${destroot}${applications_dir}/PSPP.app/Contents/Info.plist
	    xinstall -m 644 ${filespath}/PSPP.app/Contents/PkgInfo \
	     	${destroot}${applications_dir}/PSPP.app/Contents
    }
}

livecheck.url               http://pspp.benpfaff.org/~blp/pspp-master/latest/
livecheck.regex             <td>dist_version<\\/td><td>(.*)<\\/td>
livecheck.version           ${version}-${buildhash}
