# $Id: Portfile 60759 2009-11-22 15:35:51Z ryandesign@macports.org $

PortSystem 1.0
name              lighttpd-devel
version           1.5.0-r1691
categories        www
platforms         darwin
maintainers       ryandesign
description       A secure, fast, compliant and flexible web-server
long_description  lighttpd is a secure, fast, compliant and very flexible\
                  web-server which has been optimized for high-performance\
                  environments. It has a very low memory footprint\
                  compared to other webservers and takes care of cpu-load. \
                  This is the 1.5.x pre-release version.
homepage          http://www.lighttpd.net/
master_sites      ${homepage}assets/2007/2/23/
distname          lighttpd-${version}
worksrcdir        lighttpd-1.5.0
checksums         ${distname}.tar.gz \
                    md5 529909adbafee7e2c26bb427226f1457 \
                    sha1 afe4ce968fc898404cd9e61e8e48b2ea3f6db5ca \
                    rmd160 fc3bb80265e0090fce622822d4658568a5aa536c
depends_lib       port:pcre \
                  port:zlib \
                  path:lib/pkgconfig/glib-2.0.pc:glib2
patchfiles        patch-doc-lighttpd.conf \
                  patch-src-settings.h

post-patch {
	reinplace "s|__PREFIX|${prefix}|g" "${worksrcpath}/doc/lighttpd.conf"
}

configure.args    --mandir=${prefix}/share/man

# Startup item.
set lighttpd_config_name   lighttpd.conf
set lighttpd_config        ${prefix}/etc/${name}/${lighttpd_config_name}
set lighttpd_pidfile_name  lighttpd.pid
set lighttpd_pidfile       ${prefix}/var/run/${lighttpd_pidfile_name}

startupitem.create  yes
startupitem.init    "PIDFILE=${lighttpd_pidfile}"
startupitem.start   "${prefix}/sbin/lighttpd -f ${lighttpd_config}"
startupitem.stop    "kill \$(cat \$PIDFILE)"

post-destroot {
   file mkdir "${destroot}${prefix}/etc/${name}/"
   xinstall -m 644 -v "${worksrcpath}/doc/lighttpd.conf" \
                      "${destroot}${lighttpd_config}.default"
}

post-install {
  ui_msg "\n Before starting lighttpd it must be configured.\n\
    Lighttpd is configured by editing ${lighttpd_config}\n\
    There's a sample config file at ${lighttpd_config}.default.\n\
    Please note that the launchd daemon relies on the PID being at\n\
    ${lighttpd_pidfile}."
}

variant mysql4 conflicts mysql5 {
   depends_lib-append    port:mysql4
   configure.args-append --with-mysql=${prefix}/bin/mysql_config

   post-configure {
      reinplace "s|<mysql/mysql.h>|\"${prefix}/include/mysql/mysql.h\"|g" \
                "${worksrcpath}/src/mod_mysql_vhost.c"
   }
}

variant mysql5 conflicts mysql4 {
   depends_lib-append    path:bin/mysql_config5:mysql5
   configure.args-append --with-mysql=${prefix}/bin/mysql_config5

   post-configure {
      reinplace "s|<mysql/mysql.h>|\"${prefix}/include/mysql5/mysql/mysql.h\"|g" \
                "${worksrcpath}/src/mod_mysql_vhost.c"
   }
}

variant ssl {
   depends_lib-append   port:openssl
   configure.args-append --with-openssl=${prefix}/include/openssl
}

variant cml {
   depends_lib-append   port:lua \
                        port:libmemcache \
                        port:memcached \
                        port:pkgconfig
                        
   configure.args-append --with-lua=${prefix} \
                         --with-memcache
}

variant davprops {
   depends_lib-append   port:libxml2 \
                        port:sqlite3 \
                        port:pkgconfig
                        
   configure.args-append --with-webdav-props
}

variant bzip2 {
   depends_lib-append   port:bzip2
                        
   configure.args-append --with-bzip2
}

variant attr {
   configure.args-append --with-attr
}

default_variants	+bzip2

livecheck.type	regex
livecheck.url	http://www.lighttpd.net/2007/2/3/lighttpd-1-5-0-pre
livecheck.regex	{<a href="http://www.lighttpd.net/assets/.*/lighttpd-(.*?).tar.gz">lighttpd-\1.tar.gz</a>}
