# -*- 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 84891 2011-10-04 04:05:33Z ryandesign@macports.org $

PortSystem          1.0

name                asterisk
version             1.6.2.20
categories          net
platforms           darwin
maintainers         viagente.ca:marc.blanchet mr_bond openmaintainer

description         An Open Source PBX and telephony toolkit
long_description    Asterisk is an open source PBX and telephony toolkit.  It \
                    provides the ability to develop telephony applications on top of internet \
                    telephony (Voice over IP) as well as traditional telephony connectivity (PSTN).
                
homepage            http://www.asterisk.org
master_sites        http://downloads.digium.com/pub/asterisk/releases/
                    
depends_lib         port:ncurses \
                    port:openssl \
                    port:zlib \
                    port:bison \
                    port:curl \
                    port:iksemel \
                    port:libogg \
                    port:libvorbis \
                    port:lua \
                    port:openldap \
                    port:popt \
                    port:portaudio \
                    port:spandsp-devel \
                    port:speex \
                    port:sqlite3 \
                    port:wget

checksums           rmd160  8584d0f2e274517ce84576dfa7e936b9befb9fe2 \
                    sha256  4f3ef1de4644195e0d91816d6741c46ddb5d9ad28b07e631f594674ac9006a27

startupitem.create      yes
startupitem.netchange   yes
startupitem.executable  ${prefix}/sbin/asterisk -d

universal_variant   no

patchfiles          makeopts.in.diff menuselect_Makefile.diff

configure.args      --without-h323 \
                    --without-netsnmp

configure.optflags  -O3

build.env           ASTCFLAGS=-I${prefix}/include \
                    ASTLDFLAGS=-L${prefix}/lib \
                    NOISY_BUILD=1 \
                    OPTIMIZE=${configure.optflags}

destroot.keepdirs   ${destroot}${prefix}/var/log/asterisk \
                    ${destroot}${prefix}/var/run/asterisk \
                    ${destroot}${prefix}/var/spool/asterisk \
                    ${destroot}${prefix}/var/spool/asterisk/dictate \
                    ${destroot}${prefix}/var/spool/asterisk/meetme \
                    ${destroot}${prefix}/var/spool/asterisk/monitor \
                    ${destroot}${prefix}/var/spool/asterisk/outgoing \
                    ${destroot}${prefix}/var/spool/asterisk/system \
                    ${destroot}${prefix}/var/spool/asterisk/tmp \
                    ${destroot}${prefix}/var/spool/asterisk/voicemail

variant home_sound_cache description {Use/Build sound file cache from .asterisk_sounds_cache in your home directory} {
    configure.args-append --with-sounds-cache=~/.asterisk_sounds_cache
}

post-destroot {
    system "rsync -a ${worksrcpath}/configs/*.sample ${destroot}${prefix}/etc/asterisk"
    xinstall -m 644 ${filespath}/asterisk.conf.sample.in ${destroot}${prefix}/etc/asterisk/asterisk.conf.sample
    reinplace "s|@PREFIX@|${prefix}|g" ${destroot}${prefix}/etc/asterisk/asterisk.conf.sample
    xinstall -d ${destroot}${prefix}/var/log/asterisk \
                ${destroot}${prefix}/var/run/asterisk \
                ${destroot}${prefix}/var/spool/asterisk/outgoing
}
