13bca39a3d30d4dc6483c8d3ee07d6ba37778c12
[sip-router] / pkg / ser / gentoo / sip-router-3.1.3.ebuild
1 # Copyright 1999-2011 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 inherit eutils flag-o-matic toolchain-funcs multilib
6
7 DESCRIPTION="Sip-Router (Kamailio/SER) is an Open Source SIP Server"
8 HOMEPAGE="http://sip-router.org/"
9 MY_P="${P/sip-router/kamailio}"
10 MY_PN="${PN/-/}"
11 SRC_URI="http://www.kamailio.org/pub/kamailio/${PV}/src/${MY_P}_src.tar.gz"
12 S=${WORKDIR}/${MY_P}
13
14 SLOT="0"
15 LICENSE="GPL-2"
16 KEYWORDS="~amd64 ~x86"
17
18 #Documentation can be found here: http://www.kamailio.org/docs/modules/3.1.x/
19 IUSE="flavour_kamailio flavour_ser debug ipv6 sctp
20 group_standard group_standard_dep group_mysql group_radius group_postgres group_presence group_stable group_experimental
21 acc acc_radius alias_db app_lua app_python auth auth_identity auth_db auth_diameter auth_radius avpops
22 benchmark blst
23 call_control carrierroute cfg_db cfg_rpc cfgutils counters cpl-c ctl
24 db_berkeley db_flatstore db_mysql db_oracle db_postgres db_text db_unixodbc
25 debugger dialog dialplan dispatcher diversion domain domainpolicy drouting
26 enum exec
27 geoip group
28 h350 htable imc iptrtpproxy jabber kex
29 lcr ldap
30 matrix maxfwd mediaproxy memcached misc_radius mi_datagram mi_fifo mi_rpc mi_xmlrpc mqueue msilo mtree
31 nathelper nat_traversal
32 osp
33 path pdb pdt peering perl perlvdb permissions pike pipelimit prefix_route
34 presence presence_conference presence_dialoginfo presence_mwi presence_xml
35 pua pua_bla pua_dialoginfo pua_mi pua_usrloc pua_xmpp purple pv
36 qos
37 ratelimit regex registrar rls rtimer rr rtpproxy
38 sanity seas siptrace siputils sl sms snmpstats speeddial sqlops statistics sst
39 textops textopsx tls tm tmx topoh
40 uac uac_redirect uri_db userblacklist usrloc utils
41 xcap_client xcap_server xhttp xlog xmlops xmlrpc xmpp"
42
43 #osp? ( net-libs/osptoolkit )
44 #pdb? ( pdb-server )
45 #seas? ( www.wesip.eu )
46
47 RDEPEND="
48         >=sys-libs/ncurses-5.7
49         >=sys-libs/readline-6.1_p2
50         group_mysql? ( >=dev-db/mysql-5.1.50 sys-libs/zlib )
51         group_radius? ( >=net-dialup/radiusclient-ng-0.5.0 )
52         group_presence? ( dev-libs/libxml2 net-misc/curl )
53         group_postgres? ( dev-db/postgresql-base )
54         group_standard? ( dev-libs/libxml2 dev-libs/openssl net-misc/curl )
55         acc_radius? ( net-dialup/radiusclient-ng )
56         app_lua? ( dev-lang/lua )
57         app_python? ( dev-lang/python )
58         auth_identity? ( dev-libs/openssl net-misc/curl )
59         carrierroute? ( dev-libs/confuse )
60         cpl-c? ( dev-libs/libxml2 )
61         db_berkeley? ( >=sys-libs/db-4.6 )
62         db_mysql? ( >=dev-db/mysql-5.1.50 )
63         db_oracle? ( dev-db/oracle-instantclient-basic )
64         db_postgres? ( dev-db/postgresql-base )
65         db_unixodbc? ( dev-db/unixODBC )
66         dialplan? ( dev-libs/libpcre )
67         geoip? ( dev-libs/geoip )
68         h350? ( net-nds/openldap )
69         jabber? ( dev-libs/expat )
70         lcr? ( dev-libs/libpcre )
71         ldap? ( net-nds/openldap )
72         memcached? ( dev-libs/libmemcache net-misc/memcached )
73         mi_xmlrpc? ( dev-libs/libxml2 dev-libs/xmlrpc-c )
74         peering? ( net-dialup/radiusclient-ng )
75         perl? ( dev-lang/perl dev-perl/perl-ldap )
76         presence? ( dev-libs/libxml2 )
77         presence_conference? ( dev-libs/libxml2 )
78         presence_xml? ( dev-libs/libxml2 )
79         pua? ( dev-libs/libxml2 )
80         pua_bla? ( dev-libs/libxml2 )
81         pua_dialoginfo? ( dev-libs/libxml2 )
82         pua_usrloc? ( dev-libs/libxml2 )
83         pua_xmpp? ( dev-libs/libxml2 )
84         purple? ( net-im/pidgin )
85         regex? ( dev-libs/libpcre )
86         rls? ( dev-libs/libxml2 )
87         snmpstats? ( net-analyzer/net-snmp sys-apps/lm_sensors )
88         tls? (
89                 sys-libs/zlib
90                 >=dev-libs/openssl-1.0.0a-r1
91         )
92         utils? ( net-misc/curl )
93         xcap_client? ( dev-libs/libxml2 net-misc/curl )
94         xcap_server? ( dev-libs/libxml2 )
95         xmlops? ( dev-libs/libxml2 )
96         xmpp? ( dev-libs/expat )
97 "
98 DEPEND="${RDEPEND}
99         >=sys-devel/bison-1.35
100         >=sys-devel/flex-2.5.4a
101         app-text/docbook2X"
102
103 src_unpack() {
104         unpack ${A}
105         cd "${S}"
106
107         use ipv6 || \
108                 sed -i -e "s/-DUSE_IPV6//g" Makefile.defs || die
109 }
110
111 src_compile() {
112         #iptrtpproxy broken as the needed netfilter module is not supported
113         #local mod_exc="iptrtpproxy"
114         local mod_exc=""
115         local group_inc=""
116         use group_standard && group_inc="${group_inc} standard"
117         use group_standard_dep && group_inc="${group_inc} standard_dep"
118         use group_mysql && group_inc="${group_inc} mysql"
119         use group_radius && group_inc="${group_inc} radius"
120         use group_postgres && group_inc="${group_inc} postgres"
121         use group_presence && group_inc="${group_inc} presence"
122         use group_stable && group_inc="${group_inc} stable"
123         use group_experimental && group_inc="${group_inc} experimental"
124         # TODO: skip_modules?
125
126         local mod_inc=""
127         for i in ${IUSE[@]}; do
128                 for j in ${i[@]}; do
129                         use "${i}" && mod_inc="${mod_inc} ${i}"
130                 done
131         done
132
133         if use tls; then
134                 tls_hooks=1
135         else
136                 tls_hooks=0
137         fi
138
139         if use debug; then
140                 mode=debug
141         else
142                 mode=release
143         fi
144
145         if use flavour_kamailio; then
146                 flavour=kamailio
147         elif use flavour_ser; then
148                 flavour=ser # SER compatibility names
149         else
150                 flavour=sip-router # defaults: Siprouter compatibility names
151         fi
152
153         if use sctp; then
154                 sctp=1
155         else
156                 sctp=0
157         fi
158
159         emake \
160                 CC="$(tc-getCC)" \
161                 CPU_TYPE="$(get-flag march)" \
162                 SCTP="${sctp}" \
163                 CC_EXTRA_OPTS=-I/usr/gnu/include \
164                 mode="${mode}" \
165                 TLS_HOOKS="${tls_hooks}" \
166                 FLAVOUR="${flavour}" \
167                 group_include="${group_inc}" \
168                 include_modules="${mod_inc}" \
169                 exclude_modules="${mod_exc}" \
170                 prefix="/" \
171                 all || die "emake all failed"
172 }
173
174 src_install() {
175         emake -j1 \
176                 BASEDIR="${D}" \
177                 FLAVOUR="${flavour}" \
178                 prefix="/" \
179                 bin_dir=/usr/sbin/ \
180                 cfg_dir=/etc/${MY_PN}/ \
181                 lib_dir=/usr/$(get_libdir)/${MY_PN}/ \
182                 modules_dir="/usr/$(get_libdir)/${MY_PN}/" \
183                 man_dir="/usr/share/man/" \
184                 doc_dir="/usr/share/doc/${P}/" \
185                 install || die "emake install failed"
186
187         newinitd "${FILESDIR}/${MY_PN}".init "${MY_PN}"
188         newconfd "${FILESDIR}/${MY_PN}".confd "${MY_PN}"
189 }
190
191 pkg_preinst() {
192         if [[ -z "$(egetent passwd ${MY_PN})" ]]; then
193                 einfo "Adding ${MY_PN} user and group"
194                 enewgroup "${MY_PN}"
195                 enewuser  "${MY_PN}" -1 -1 /dev/null "${MY_PN}"
196         fi
197
198         chown -R root:"${MY_PN}"  "${D}/etc/${MY_PN}"
199         chmod -R u=rwX,g=rX,o= "${D}/etc/${MY_PN}"
200
201         has_version "${CATEGORY}/ser"
202         previous_installed_version=$?
203 }
204
205 pkg_postinst() {
206         if [[ $previous_installed_version = 1 ]] ; then
207                 einfo "You have a previous version of SER on ${ROOT}etc/ser"
208                 einfo "Consider or verify to remove it"
209                 einfo
210                 einfo "Now you've installed Sip-Router ON ${ROOT}etc/${MY_PN}"
211         fi
212         if [ use mediaproxy ]; then
213                 echo "You have enabled mediaproxy support. In order to use it, you have
214                 to run it somewhere."
215         fi
216         if [ use rtpproxy ]; then
217                 "You have enabled rtpproxy support. In order to use it, you have to run
218                 it somewhere."
219         fi
220 }
221
222 pkg_prerm () {
223         /etc/init.d/"${MY_PN}" stop >/dev/null
224 }