# -*- 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 75572 2011-01-31 00:36:48Z dh@macports.org $

PortSystem 1.0

name                sqsh
version             2.1.7
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     ce929dc8e23cedccac98288d24785e2d \
                    sha1    62aa2038dc17db24dd8f95b589ea927c27f47905

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 "****************************************************************"
   }
}
