# $Id: Portfile 38272 2008-07-14 15:21:23Z jmr@macports.org $

PortSystem      1.0

name            wview

version         4.0.1

categories      science

maintainers     mac.com:mbrooksclark

homepage        http://wviewweather.com/

description     Daemons that download and archive data from supported weather stations

long_description \
  wview is a unix application for weather stations. It archives weather \
  data from the station. Generates full html web sites with graphics. \
  ftp/ssh export capability. MySQL/PostgreSQL archiving. International. \
  Weather alarms. Data feed. RSS feed. Stations currently supported include: \
  Davis Vantage Pro/Pro2, Vaisala WXT-510, La Crosse WS-2300, and a \
  weather station simulator.

platforms        darwin

master_sites     sourceforge:wview

depends_lib      port:gd2 port:radlib

checksums        md5 1042769d7c94395bcc3732de7c1c8e87 \
                 sha1 949c76e1a2179eedb7104a7b28a526d4e4ffe953 \
                 rmd160 86e581f2d9779650d0189b0dbfb068b71b5affc8

configure.args   --exec-prefix=${prefix}

variant env      description { Install config files and templates (first time install) } {
  destroot.target-append install-env
}

variant mysql5 	description { Includes mySQL5 database support } {
  configure.args-append --enable-mysql
  configure.ldflags-append  -L${prefix}/lib/mysql5/mysql
  depends_lib-append port:mysql5
}

variant pgresql   description { Includes Postgresql database support } {
  configure.args-append --enable-pgresql
  depends_lib-append port:postgresql83
}

variant vpro      description { Support for Davis Vantage Pro WX Station } {
  configure.args-append --enable-station-vp2
}

variant wxt510    description { Support for Vaisala WXT-510 WX Station } {
  configure.args-append --enable-station-wxt510
}

variant ws2300    description { Support for the La Crosse WS-2300 series stations } {
  configure.args-append --enable-station-ws2300
}

variant wmr918    description { Support for the for the Oregon Scientific WMR918/968 WX Station} {
  configure.args-append --enable-station-wmr918
}

variant sim       description { Support for the Simulated WX Station } {
  configure.args-append --enable-station-sim
}

variant http      description { Enable support for uploading data to Weather Underground } {
  configure.args-append --enable-http
  depends_lib-append port:curl
}

destroot.violate_mtree

post-destroot {
  xinstall -d -o root -g wheel -m 755 \
    ${worksrcpath}/examples/MacOSX/wview ${destroot}/Library/StartupItems/wview

  xinstall -o root -g wheel -m 755 ${worksrcpath}/examples/MacOSX/wview/wview \
    ${destroot}/Library/StartupItems/wview/wview

  xinstall -o root -g wheel -m 644 \
    ${worksrcpath}/examples/MacOSX/wview/StartupParameters.plist \
    ${destroot}/Library/StartupItems/wview/StartupParameters.plist


  file mkdir ${destroot}${prefix}/share/doc/${name}

  file copy ${worksrcpath}/wview-Quick-Start-MacOSX.html \
    ${destroot}${prefix}/share/doc/${name}/wview-Quick-Start-MacOSX.html

  file copy ${worksrcpath}/wview-Quick-Start.html \
    ${destroot}${prefix}/share/doc/${name}/wview-Quick-Start.html

  file copy ${worksrcpath}/wview-User-Manual.html \
    ${destroot}${prefix}/share/doc/${name}/wview-User-Manual.html

  file copy ${worksrcpath}/COPYING \
    ${destroot}${prefix}/share/doc/${name}/COPYING

  file copy ${worksrcpath}/UPGRADE \
    ${destroot}${prefix}/share/doc/${name}/UPGRADE


}

post-install {
  ui_msg "\n#####################################"
  ui_msg "Run\n"
  ui_msg "\tsudo ${prefix}/bin/wviewconfig and\n"
  ui_msg "\tsudo ${prefix}/bin/wviewhtmlconfig\n"
  ui_msg "before launching wview\n"
  ui_msg "\n#####################################"
  ui_msg "html templates and config files are stored in ${prefix}/etc/wview/\n"
  ui_msg "archive files are stored in ${prefix}/var/wview/\n"
  ui_msg "\n#####################################"
  ui_msg "Start the daemons with the command:\n"
  ui_msg "\tsudo /sbin/SystemStarter start wview\n"
  ui_msg "\n#####################################"
}
