# -*- 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 57429 2009-09-11 03:31:16Z ryandesign@macports.org $

PortSystem 1.0

name                sqsh
version             2.1.6
categories          sysutils database
maintainers         dh openmaintainer

description         A Sybase Shell
long_description    Sqsh (pronounced skwish) is short for SQshelL (pronounced s-q-shell), \
                    a replacement for the venerable 'isql' program supplied by Sybase.
homepage            http://sqsh.sourceforge.net/
platforms           darwin

master_sites        sourceforge
checksums           md5     32bca47e73c8cf1665a4b610e07931c0 \
                    sha1    a3b3089705678539dfb04518050dbd4a0764df8a \
                    rmd160  41a1c6eb39af0c7fb15efc6f8582ee20d364c950

depends_lib         port:readline port:freetds

post-patch {
	reinplace "s|LDFLAGS        =|LDFLAGS        = @LDFLAGS@|g" ${worksrcpath}/src/Makefile.in
}

configure.env       SYBASE=${prefix} CPPFLAGS=-I${prefix}/include/freetds INCDIRS=${prefix}/include LIBDIRS=${prefix}/lib
configure.args      --with-readline --mandir=${prefix}/share/man

build.target        build         
use_parallel_build  yes

destroot.target-append install.man

post-destroot {
    file rename ${destroot}${prefix}/etc/sqshrc ${destroot}${prefix}/etc/sqshrc.sample
}

post-activate {
   if {![file exists ${prefix}/etc/sqshrc]} {
      file copy ${prefix}/etc/sqshrc.sample ${prefix}/etc/sqshrc
   } else {
      ui_msg "\n****************************************************************"
      ui_msg "The already existing sqshrc has been retained.  The distribution's"
      ui_msg "sqshrc has instead been installed to "
      ui_msg "    ${prefix}/etc/sqshrc.sample "
      ui_msg "****************************************************************"
   }
}
