# $Id: Portfile 92837 2012-05-09 00:51:48Z ryandesign@macports.org $

PortSystem        1.0

name              pound
version           2.5
revision          1
categories        www
platforms         darwin
maintainers       gmail.com:rcavanaugh

description       A reverse proxy, load balancer and HTTPS front-end for Web server(s)
long_description  The Pound program is a reverse proxy, load balancer and\
                  HTTPS front-end for Web server(s). Pound was developed to\
                  enable distributing the load among several Web-servers and\
                  to allow for a convenient SSL wrapper for those Web servers\
                  that do not offer it natively.

homepage          http://www.apsis.ch/pound/
distname          Pound-${version}
extract.suffix    .tgz
master_sites      ${homepage}

checksums         sha1    0bc8c45b9afb64fb8810b44213345c2a67ce8a8c \
                  rmd160  6f8d55eff11b25b0ac0dab66aac90af5380e2753

# TODO use tcmalloc and/or hoard
depends_lib       port:openssl port:pcre

patchfiles        pound-2.5-openssl.patch
patch.pre_args    -p1

configure.args    --with-ssl=${prefix}

set pound_config_name   pound.cfg
set pound_config        ${prefix}/etc/${pound_config_name}
set pound_pidfile_name  pound.pid
set pound_pidfile       ${prefix}/var/run/${pound_pidfile_name}

pre-configure {
  reinplace "s|-o @I_OWNER@ -g @I_GRP@||g" ${worksrcpath}/Makefile.in
}

startupitem.create  yes
startupitem.init    "PIDFILE=${pound_pidfile}"
startupitem.start   "${prefix}/sbin/pound -f ${pound_config} -p \$PIDFILE"
startupitem.stop    "kill \$(cat \$PIDFILE)"

post-install {
  ui_msg "\n Before starting pound it must be configured.\n\
    Pound is configured by editing ${pound_config}\n\
    Details on the format of ${pound_config_name} can be found in\n\
    the pound man page or at ${homepage}\n"
}
