summaryrefslogtreecommitdiff
blob: def195d9199bb623de187f920c63bba8922e1511 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/net-misc/asterisk/asterisk-0.9.0.ebuild,v 1.2 2004/06/15 02:33:07 agriffis Exp $

IUSE="doc alsa mysql gtk mmx nopri nozaptel noiax vhosts"

inherit eutils webapp-apache

DESCRIPTION="Asterisk: A Modular Open Source PBX System"
HOMEPAGE="http://www.asterisk.org/"
SRC_URI="ftp://ftp.asterisk.org/pub/telephony/asterisk/${P}.tar.gz"

SLOT="0"
LICENSE="GPL-2"
KEYWORDS="~x86"

DEPEND="virtual/glibc
	media-sound/mpg123
	dev-libs/newt
	doc? ( app-doc/doxygen )
	alsa? ( media-libs/alsa-lib )
	mysql? ( dev-db/mysql )
	gtk? ( =x11-libs/gtk+-1.2* )
	!noiax? ( >=net-libs/iax-0.2.2 )
	!nopri? ( >=net-libs/libpri-0.4 )
	!nozaptel? ( >=net-misc/zaptel-0.9.1
		     >=net-libs/zapata-0.9.1 )"

pkg_setup() {
	NO_WEBSERVER=0

	webapp-detect || NO_WEBSERVER=1
	webapp-pkg_setup "${NO_WEBSERVER}"
	if [ $NO_WEBSERVER -eq 0 ]; then
		einfo "Voicemail webapp will be installed into: ${ROOT}${HTTPD_ROOT}"
	else
		einfo "Skipping installation of Voicemail webapp"
	fi
}

src_unpack() {
	unpack ${A}

	cd ${S}
#	epatch ${FILESDIR}/${PV}/${P}-makefile-fix.diff

	# set cflags & mmx optimization
	sed -i -e "s:^\(OPTIMIZE=\).*:\1 ${CFLAGS}:" Makefile

	if use mmx; then
		einfo "enabling mmx optimization"
		sed -i -e "s:^#\(K6OPT.*\):\1:" Makefile
	fi

	# change image path in voicemail cgi
	sed -i -e "s:^\(\$astpath = \).*:\1 \"/asterisk\";:" contrib/scripts/vmail.cgi
}

src_compile() {
	# build asterisk first...
	einfo "Building Asterisk..."
	cd ${S}
	emake -j1 || die "Make failed"
}

src_install() {
	emake -j1 DESTDIR=${D} install || die "Make install failed"
	emake -j1 DESTDIR=${D} samples || die "Make install samples failed"

	# install addmailbox and astgenkey
	dosbin contrib/scripts/addmailbox
	dosbin contrib/scripts/astgenkey

	# documentation
	use doc && \
		emake -j1 DESTDIR=${D} progdocs

	# voicemail webapp
	if [ $NO_WEBSERVER -eq 0 ]; then
	    einfo "Installing voicemail webapp"
	    insinto ${HTTPD_CGIBIN}
	    doins contrib/scripts/vmail.cgi
	    fperms 1755 ${HTTPD_CGIBIN}/vmail.cgi

	    insinto ${HTTPD_ROOT}/asterisk
	    for i in "images/*.gif"; do
		doins $i
	    done
	fi


	# install necessary files
	dodir /etc/env.d
	echo "LD_LIBRARY_PATH=\"/usr/lib/asterisk\"" > ${D}/etc/env.d/25asterisk

	exeinto /etc/init.d
	newexe  ${FILESDIR}/${PV}/asterisk.rc6 asterisk

	insinto /etc/conf.d
	newins  ${FILESDIR}/${PV}/asterisk.confd asterisk

	# don't delete these, even if they are empty
	keepdir /var/spool/asterisk/voicemail/default/1234/INBOX
	keepdir /var/log/asterisk/cdr-csv

	# install standard docs...
	dodoc BUGS CREDITS LICENSE ChangeLog HARDWARE README SECURITY

	docinto scripts
	dodoc contrib/scripts/*.pl
	dodoc contrib/scripts/*.sql
}

pkg_postinst() {
	einfo "Asterisk has been installed"
	einfo ""
	einfo "to add new Mailboxes use: /usr/sbin/addmailbox"
	einfo ""
	einfo "If you want to know more about asterisk, visit these sites:"
	einfo "http://www.automated.it/guidetoasterisk.htm"
	einfo "http://asterisk.xvoip.com/"
	einfo "http://www.voip-info.org/wiki-Asterisk"
	einfo "http://ns1.jnetdns.de/jn/relaunch/asterisk/"
}