parser: switch pkg_free(tob) to free_to(tob) to free To header structure
[sip-router] / pkg / ser / gentoo / sip-router-3.1.4-r1.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 group_kstandard group_kmysql group_kradius group_kpostgres group_kpresence group_kxml group_kperl group_kldap
22 acc acc_radius alias_db app_lua app_python auth auth_identity auth_db auth_diameter auth_radius avpops
23 benchmark blst
24 call_control carrierroute cfg_db cfg_rpc cfgutils counters cpl-c ctl
25 db_berkeley db_flatstore db_mysql db_oracle db_postgres db_text db_unixodbc
26 debugger dialog dialplan dispatcher diversion domain domainpolicy drouting
27 enum exec
28 geoip group
29 h350 htable imc iptrtpproxy jabber kex
30 lcr ldap
31 matrix maxfwd mediaproxy memcached misc_radius mi_datagram mi_fifo mi_rpc mi_xmlrpc mqueue msilo mtree
32 nathelper nat_traversal
33 osp
34 path pdb pdt peering perl perlvdb permissions pike pipelimit prefix_route
35 presence presence_conference presence_dialoginfo presence_mwi presence_xml
36 pua pua_bla pua_dialoginfo pua_mi pua_usrloc pua_xmpp purple pv
37 qos
38 ratelimit regex registrar rls rtimer rr rtpproxy
39 sanity seas siptrace siputils sl sms snmpstats speeddial sqlops statistics sst
40 textops textopsx tls tm tmx topoh
41 uac uac_redirect uri_db userblacklist usrloc utils
42 xcap_client xcap_server xhttp xlog xmlops xmlrpc xmpp"
43
44 #osp? ( net-libs/osptoolkit )
45 #pdb? ( pdb-server )
46 #seas? ( www.wesip.eu )
47
48 RDEPEND="
49         >=sys-libs/ncurses-5.7
50         >=sys-libs/readline-6.1_p2
51         group_mysql? ( >=dev-db/mysql-5.1.50 sys-libs/zlib )
52         group_radius? ( >=net-dialup/radiusclient-ng-0.5.0 )
53         group_presence? ( dev-libs/libxml2 net-misc/curl )
54         group_postgres? ( dev-db/postgresql-base )
55         group_standard? ( dev-libs/libxml2 dev-libs/openssl net-misc/curl )
56         group_kmysql? ( >=dev-db/mysql-5.1.50 sys-libs/zlib )
57         group_kradius? ( >=net-dialup/radiusclient-ng-0.5.0 )
58         group_kpresence? ( dev-libs/libxml2 net-misc/curl )
59         group_kpostgres? ( dev-db/postgresql-base )
60         group_kstandard? ( dev-libs/libxml2 dev-libs/openssl net-misc/curl )
61         group_kxml? ( dev-libs/libxml2 dev-libs/xmlrpc-c )
62         group_kperl? ( dev-lang/perl dev-perl/perl-ldap )
63         group_kldap? ( net-nds/openldap )
64         acc_radius? ( net-dialup/radiusclient-ng )
65         app_lua? ( dev-lang/lua )
66         app_python? ( dev-lang/python )
67         auth_identity? ( dev-libs/openssl net-misc/curl )
68         carrierroute? ( dev-libs/confuse )
69         cpl-c? ( dev-libs/libxml2 )
70         db_berkeley? ( >=sys-libs/db-4.6 )
71         db_mysql? ( >=dev-db/mysql-5.1.50 )
72         db_oracle? ( dev-db/oracle-instantclient-basic )
73         db_postgres? ( dev-db/postgresql-base )
74         db_unixodbc? ( dev-db/unixODBC )
75         dialplan? ( dev-libs/libpcre )
76         geoip? ( dev-libs/geoip )
77         h350? ( net-nds/openldap )
78         jabber? ( dev-libs/expat )
79         lcr? ( dev-libs/libpcre )
80         ldap? ( net-nds/openldap )
81         memcached? ( dev-libs/libmemcache net-misc/memcached )
82         mi_xmlrpc? ( dev-libs/libxml2 dev-libs/xmlrpc-c )
83         peering? ( net-dialup/radiusclient-ng )
84         perl? ( dev-lang/perl dev-perl/perl-ldap )
85         presence? ( dev-libs/libxml2 )
86         presence_conference? ( dev-libs/libxml2 )
87         presence_xml? ( dev-libs/libxml2 )
88         pua? ( dev-libs/libxml2 )
89         pua_bla? ( dev-libs/libxml2 )
90         pua_dialoginfo? ( dev-libs/libxml2 )
91         pua_usrloc? ( dev-libs/libxml2 )
92         pua_xmpp? ( dev-libs/libxml2 )
93         purple? ( net-im/pidgin )
94         regex? ( dev-libs/libpcre )
95         rls? ( dev-libs/libxml2 )
96         snmpstats? ( net-analyzer/net-snmp sys-apps/lm_sensors )
97         tls? (
98                 sys-libs/zlib
99                 >=dev-libs/openssl-1.0.0a-r1
100         )
101         utils? ( net-misc/curl )
102         xcap_client? ( dev-libs/libxml2 net-misc/curl )
103         xcap_server? ( dev-libs/libxml2 )
104         xmlops? ( dev-libs/libxml2 )
105         xmpp? ( dev-libs/expat )
106 "
107 DEPEND="${RDEPEND}
108         >=sys-devel/bison-1.35
109         >=sys-devel/flex-2.5.4a
110         app-text/docbook2X"
111
112 src_unpack() {
113         unpack ${A}
114         cd "${S}"
115
116         use ipv6 || \
117                 sed -i -e "s/-DUSE_IPV6//g" Makefile.defs || die
118 }
119
120 src_compile() {
121         # iptrtpproxy broken as the needed netfilter module is not supported
122         local mod_exc="iptrtpproxy"
123         local group_inc=""
124         local k=""
125         if use flavour_kamailio; then
126                 k="k"
127                 use group_kxml && group_inc="${group_inc} kxml"
128                 use group_kperl && group_inc="${group_inc} kperl"
129                 use group_kldap && group_inc="${group_inc} kldap"
130         fi
131         # you can USE flavour=kamailio but also group_standard. It will be converted to group_kstandard
132         # same as mysql/kmysql, postgres/kpostgres, radius/kradius, presence/kpresence
133         (use group_standard || use group_kstandard) && group_inc="${group_inc} ${k}standard"
134         use group_standard_dep && group_inc="${group_inc} standard_dep"
135         (use group_mysql || use group_kmysql) && group_inc="${group_inc} ${k}mysql"
136         (use group_radius || use group_kradius) && group_inc="${group_inc} ${k}radius"
137         (use group_postgres || use group_kpostgres) && group_inc="${group_inc} ${k}postgres"
138         (use group_presence || use group_kpresence) && group_inc="${group_inc} ${k}presence"
139         use group_stable && group_inc="${group_inc} stable"
140         use group_experimental && group_inc="${group_inc} experimental"
141         # TODO: skip_modules?
142
143         local mod_inc=""
144         # FIXME: some IUSE flags must not be included here in mod_inc
145         # e.g.: flavour_kamailio, flavour_ser, debug, sctp, ipv6
146         for i in ${IUSE[@]}; do
147                 for j in ${i[@]}; do
148                         [[ ! "${i}" =~ "flavour_" ]] && \
149                                 [ ! "${i}" == "debug" ] && \
150                                 [ ! "${i}" == "ipv6" ] && \
151                                 [ ! "${i}" == "sctp" ] && \
152                                 [[ ! "${i}" =~ "group_" ]] && \
153                         use "${i}" && mod_inc="${mod_inc} ${i}"
154                 done
155         done
156
157         if use tls; then
158                 tls_hooks=1
159         else
160                 tls_hooks=0
161         fi
162
163         if use debug; then
164                 mode=debug
165         else
166                 mode=release
167         fi
168
169         if use flavour_kamailio; then
170                 flavour=kamailio
171         elif use flavour_ser; then
172                 flavour=ser # SER compatibility names
173         else
174                 flavour=sip-router # defaults: Siprouter compatibility names
175         fi
176
177         if use sctp; then
178                 sctp=1
179         else
180                 sctp=0
181         fi
182
183         emake \
184                 CC="$(tc-getCC)" \
185                 CPU_TYPE="$(get-flag march)" \
186                 SCTP="${sctp}" \
187                 CC_EXTRA_OPTS=-I/usr/gnu/include \
188                 mode="${mode}" \
189                 TLS_HOOKS="${tls_hooks}" \
190                 FLAVOUR="${flavour}" \
191                 group_include="${group_inc}" \
192                 include_modules="${mod_inc}" \
193                 exclude_modules="${mod_exc}" \
194                 prefix="/" \
195                 all || die "emake all failed"
196 }
197
198 src_install() {
199         emake -j1 \
200                 BASEDIR="${D}" \
201                 FLAVOUR="${flavour}" \
202                 prefix="/" \
203                 bin_dir=/usr/sbin/ \
204                 cfg_dir=/etc/${MY_PN}/ \
205                 lib_dir=/usr/$(get_libdir)/${MY_PN}/ \
206                 modules_dir="/usr/$(get_libdir)/${MY_PN}/" \
207                 man_dir="/usr/share/man/" \
208                 doc_dir="/usr/share/doc/${P}/" \
209                 install || die "emake install failed"
210
211         [ "${flavour}" == "sip-router" ] || \
212                 sed -e "s/siprouter/${flavour}/g" \
213                         ${FILESDIR}/${MY_PN}.init > ${flavour}.init || die
214
215         newinitd "${flavour}".init "${flavour}"
216         newconfd "${FILESDIR}/${MY_PN}".confd "${flavour}"
217
218
219 }
220
221 pkg_preinst() {
222         if [[ -z "$(egetent passwd ${MY_PN})" ]]; then
223                 einfo "Adding ${MY_PN} user and group"
224                 enewgroup "${MY_PN}"
225                 enewuser  "${MY_PN}" -1 -1 /dev/null "${MY_PN}"
226         fi
227
228         chown -R root:"${MY_PN}"  "${D}/etc/${MY_PN}"
229         chmod -R u=rwX,g=rX,o= "${D}/etc/${MY_PN}"
230
231         has_version "${CATEGORY}/ser"
232         previous_installed_version=$?
233 }
234
235 pkg_postinst() {
236         if [[ $previous_installed_version = 1 ]] ; then
237                 einfo "You have a previous version of SER on ${ROOT}etc/ser"
238                 einfo "Consider or verify to remove it"
239                 einfo
240                 einfo "Now you've installed Sip-Router ON ${ROOT}etc/${MY_PN}"
241         fi
242         if [ use mediaproxy ]; then
243                 echo "You have enabled mediaproxy support. In order to use it, you have
244                 to run it somewhere."
245         fi
246         if [ use rtpproxy ]; then
247                 "You have enabled rtpproxy support. In order to use it, you have to run
248                 it somewhere."
249         fi
250 }
251
252 pkg_prerm () {
253         /etc/init.d/"${MY_PN}" stop >/dev/null
254 }