Fri, 02 Dec 2011 19:22:01 +0100
Correct DB path, add gtalk config and build logic, note CAPI header problem.
1 ##
2 ## asterisk.spec -- OpenPKG RPM Package Specification
3 ## Copyright (c) 2000-2009 OpenPKG Foundation e.V. <http://openpkg.net/>
4 ##
5 ## Permission to use, copy, modify, and distribute this software for
6 ## any purpose with or without fee is hereby granted, provided that
7 ## the above copyright notice and this permission notice appear in all
8 ## copies.
9 ##
10 ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
11 ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
12 ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
13 ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
14 ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
15 ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
16 ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
17 ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
18 ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
19 ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
20 ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
21 ## SUCH DAMAGE.
22 ##
24 # package version
25 %define V_opkg 1.8.7.1
26 %define V_asterisk 1.8.7.1
27 %define V_asterisk_fax_subdir 1.8.4
28 %define V_asterisk_fax_digium 1.8.4_1.3.0
29 %define V_asterisk_sounds_core 1.4.22
30 %define V_asterisk_sounds_extra 1.4.11
31 %define V_asterisk_sounds_amoogab 1.4
32 %define V_asterisk_sounds_amootts current
33 %define V_asterisk_sounds_custom 1.0
34 %define V_asterisk_sounds_mohop 2.03
35 %define V_asterisk_addons_mp3dec 1
36 %define V_fswitch_sounds_en 1.0.16
37 %define V_fswitch_sounds_fr 1.0.14
38 %define V_fswitch_sounds_ru 1.0.13
39 %define V_fswitch_music 1.0.8
40 %define V_asterisk_codecs_ilbc 20110104
41 %define V_chan_capi 1.1.5.20110914
43 # package information
44 Name: asterisk
45 Summary: Private Branch Exchange (PBX)
46 URL: http://www.asterisk.org/
47 Vendor: Mark Spencer et al.
48 Packager: OpenPKG Foundation e.V.
49 Distribution: OpenPKG Community
50 Class: BASE
51 Group: VoIP
52 License: GPL
53 Version: %{V_opkg}
54 Release: 20111104
56 # package options
57 %option with_dahdi no
58 %option with_capi no
59 %option with_ogg no
60 %option with_mp3 no
61 %option with_fax no
62 %option with_avcodec no
63 %option with_ldap no
64 %option with_radius no
65 %option with_sqlite no
66 %option with_srtp no
67 %option with_pgsql no
68 %option with_lua no
69 %option with_gtalk no
70 %option with_jabber no
71 %option with_imap no
72 %option with_odbc no
73 %option with_libpri no
74 %option with_esounds no
75 %option with_xfersips yes
76 %option with_proxymwi yes
77 %option with_smdipoll 10
79 # list of sources
80 Source0: http://downloads.asterisk.org/pub/telephony/asterisk/releases/asterisk-%{V_asterisk}.tar.gz
81 Source1: ftp://ftp.chan-capi.org/chan-capi/chan_capi-%{V_chan_capi}.tar.gz
82 Source2: ftp://ftp.europalab.com/pub/sfw/machsnds/asterisk-moh-freeplay-sln16.tar.gz
84 Source3: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-moh-opsound-sln16-%{V_asterisk_sounds_mohop}.tar.gz
85 Source4: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-moh-opsound-sln16-%{V_asterisk_sounds_mohop}.tar.gz.sha1
86 Source5: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-core-sounds-en-sln16-%{V_asterisk_sounds_core}.tar.gz
87 Source6: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-core-sounds-en-sln16-%{V_asterisk_sounds_core}.tar.gz.sha1
88 Source7: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-core-sounds-es-sln16-%{V_asterisk_sounds_core}.tar.gz
89 Source8: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-core-sounds-es-sln16-%{V_asterisk_sounds_core}.tar.gz.sha1
90 Source9: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-core-sounds-en_AU-sln16-%{V_asterisk_sounds_core}.tar.gz
91 Source10: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-core-sounds-en_AU-sln16-%{V_asterisk_sounds_core}.tar.gz.sha1
92 Source11: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-core-sounds-fr-sln16-%{V_asterisk_sounds_core}.tar.gz
93 Source12: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-core-sounds-fr-sln16-%{V_asterisk_sounds_core}.tar.gz.sha1
94 Source13: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-core-sounds-ru-sln16-%{V_asterisk_sounds_core}.tar.gz
95 Source14: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-core-sounds-ru-sln16-%{V_asterisk_sounds_core}.tar.gz.sha1
96 Source15: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-extra-sounds-en-sln16-%{V_asterisk_sounds_extra}.tar.gz
97 Source16: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-extra-sounds-en-sln16-%{V_asterisk_sounds_extra}.tar.gz.sha1
98 Source16: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-extra-sounds-fr-sln16-%{V_asterisk_sounds_extra}.tar.gz
99 Source17: http://downloads.asterisk.org/pub/telephony/sounds/releases/asterisk-extra-sounds-fr-sln16-%{V_asterisk_sounds_extra}.tar.gz.sha1
100 Source18: http://www.amooma.de/asterisk/sprachbausteine/asterisk-%{V_asterisk_sounds_amoogab}-de-prompts.tar.gz
101 Source19: http://www.amooma.de/asterisk/sprachbausteine/asterisk-core-sounds-de-gsm-current.tar.gz
102 Source20: ftp://ftp.europalab.com/pub/sfw/machsnds/de-digits/de-digits-%{V_asterisk_sounds_custom}.tar.bz2
103 Source21: ftp://ftp.europalab.com/pub/sfw/machsnds/de-sounds/astmultisnds-de-sln16-%{V_asterisk_sounds_custom}.tar.bz2
104 Source22: ftp://ftp.europalab.com/pub/sfw/machsnds/msvbsnds-sln16-%{V_asterisk_sounds_custom}.tar.bz2
105 Source23: http://files.freeswitch.org/freeswitch-sounds-en-us-callie-48000-%{V_fswitch_sounds_en}.tar.gz
106 Source24: http://files.freeswitch.org/freeswitch-sounds-es-mx-maria-44100.tar.gz
107 Source25: http://files.freeswitch.org/freeswitch-sounds-fr-ca-june-48000-%{V_fswitch_sounds_fr}.tar.gz
108 Source26: http://files.freeswitch.org/freeswitch-sounds-ru-RU-elena-48000-%{V_fswitch_sounds_ru}.tar.gz
109 Source27: http://files.freeswitch.org/freeswitch-sounds-music-48000-%{V_fswitch_music}.tar.gz
110 Source28: http://svn.digium.com/svn/thirdparty/mp3/trunk/addons/mp3-%{V_asterisk_addons_mp3dec}.tar.gz
111 Source29: http://downloads.digium.com/pub/telephony/fax/res_fax_digium/asterisk-%{V_asterisk_fax_subdir}/x86-64/res_fax_digium-%{V_asterisk_fax_digium}-generic_64.tar.gz
112 Source30: http://downloads.digium.com/pub/telephony/fax/res_fax_digium/asterisk-%{V_asterisk_fax_subdir}/x86-32/res_fax_digium-%{V_asterisk_fax_digium}-generic_32.tar.gz
113 Source31: ilbc-20110104.tar.gz
114 Source32: asterisk.txt
115 Source33: rc.asterisk
116 Source34: wakeup.agi
117 Patch0: asterisk.patch
118 Patch1: asterisk.patch.xfersips
119 Patch2: asterisk.patch.proxymwi
121 # build information
122 Prefix: %{l_prefix}
123 BuildRoot: %{l_buildroot}
124 BuildPreReq: OpenPKG, openpkg >= 20040130, bison, gcc, make, grep, pkgconfig
125 PreReq: OpenPKG, openpkg >= 20040130, MTA
126 BuildPreReq: zlib, curl, openssl, ncurses, speex, sox, popt, gmime, libxml
127 PreReq: zlib, curl, openssl, ncurses, speex, sox, popt, gmime, libxml
128 %if "%{with_ogg}" == "yes"
129 BuildPreReq: vorbis-libs
130 PreReq: vorbis-libs
131 %endif
132 %if "%{with_mp3}" == "yes"
133 PreReq: mpg123
134 %endif
135 %if "%{with_imap}" == "yes"
136 BuildPreReq: imap
137 PreReq: imap
138 %endif
139 %if "%{with_sqlite}" == "yes"
140 BuildPreReq: sqlite
141 PreReq: sqlite
142 %endif
143 %if "%{with_srtp}" == "yes"
144 BuildPreReq: srtp
145 PreReq: srtp
146 %endif
147 %if "%{with_pgsql}" == "yes"
148 BuildPreReq: postgresql
149 PreReq: postgresql
150 %endif
151 %if "%{with_lua}" == "yes"
152 BuildPreReq: lua
153 PreReq: lua
154 %endif
155 %if "%{with_avcodec}" == "yes"
156 BuildPreReq: ffmpeg
157 PreReq: ffmpeg
158 %endif
159 %if "%{with_ldap}" == "yes"
160 BuildPreReq: openldap
161 PreReq: openldap
162 %endif
163 %if "%{with_radius}" == "yes"
164 BuildPreReq: radiusclient
165 PreReq: radiusclient
166 %endif
167 %if "%{with_gtalk}" == "yes"
168 %define with_jabber yes
169 %endif
170 %if "%{with_jabber}" == "yes"
171 BuildPreReq: iksemel
172 PreReq: iksemel
173 %endif
174 %if "%{with_odbc}" == "yes"
175 BuildPreReq: unixodbc, sqlite, sqlite::with_odbc = yes
176 PreReq: unixodbc, sqlite, sqlite::with_odbc = yes
177 %endif
178 %if "%{with_libpri}" == "yes"
179 BuildPreReq: libpri > 1.4.11.5
180 PreReq: libpri > 1.4.11.5
181 %endif
182 %if "%{with_esounds}" == "yes"
183 BuildPreReq: sox
184 %endif
185 AutoReq: no
186 AutoReqProv: no
188 %description
189 Asterisk is a complete Private Branch Exchange (PBX) in software.
190 It provides more than the features normally expected from a PBX,
191 and can transceive Voice over IP (VoIP) in many protocols. Asterisk
192 provides voicemail services with directory, call conferencing,
193 interactive voice response and call queuing as well. It has support
194 for three way calling, caller ID, ADSI, and SIP, and requires no
195 additional hardware for VoIP applications.
197 This copy of Asterisk is optionally patched to allow the asterisk
198 server to respond to SIP/TLS transfer requests using the Transfer()
199 application. Should this option be chosen, the asterisk server
200 successfully dispatches all transfer destinations using 'SIPS'
201 technology by means of the standard SIP/2.0 302 Moved Temporarily
202 message, with a URI resembling <sips:extension@hostname.tld:port>.
204 This copy of Asterisk is optionally patched as well to enclose the
205 correct user name in NOTIFY messages when MWI logic detects changes
206 in the state of Messages-Waiting. Asterisk will send NOTIFY messages
207 with the URI 'user@hostname' instead of simply 'hostname'. This can
208 be used by a external SIP proxy to route the MWI to the correct phone.
210 %track
211 prog asterisk = {
212 version = %{V_asterisk}
213 url = http://downloads.asterisk.org/pub/telephony/asterisk/releases/
214 regex = asterisk-(\d+\.\d+(\.\d+)+)\.tar\.gz
215 }
216 prog asterisk:fax_digium_32 = {
217 version = %{V_asterisk_fax_digium}
218 url = http://downloads.digium.com/pub/telephony/fax/res_fax_digium/asterisk-1.8.0/x86-32/
219 regex = res_fax_digium-(__VER__)-generic_32.tar.gz\.tar\.gz
220 }
221 prog asterisk:fax_digium_64 = {
222 version = %{V_asterisk_fax_digium}
223 url = http://downloads.digium.com/pub/telephony/fax/res_fax_digium/asterisk-1.8.0/x86-64/
224 regex = res_fax_digium-(__VER__)-generic_64.tar.gz\.tar\.gz
225 }
226 prog asterisk:sounds_core = {
227 version = %{V_asterisk_sounds_core}
228 url = http://downloads.asterisk.org/pub/telephony/sounds/releases/
229 regex = asterisk-core-sounds-en-sln16-(\d+\.\d+(\.\d+)+)\.tar\.gz
230 }
231 prog asterisk:sounds_extra = {
232 version = %{V_asterisk_sounds_extra}
233 url = http://downloads.asterisk.org/pub/telephony/sounds/releases/
234 regex = asterisk-extra-sounds-en-sln16-(\d+\.\d+(\.\d+)+)\.tar\.gz
235 }
236 prog asterisk:sounds_amootts = {
237 version = %{V_asterisk_sounds_amootts}
238 url = http://www.amooma.de/asterisk/sprachbausteine/
239 regex = asterisk-core-sounds-de-gsm-(__VER__)\.tar\.gz
240 }
241 prog asterisk:sounds_amoogab = {
242 version = %{V_asterisk_sounds_amoogab}
243 url = http://www.amooma.de/asterisk/sprachbausteine/
244 regex = asterisk-(__VER__)-de-prompts\.tar\.gz
245 }
246 prog asterisk:sounds_digits = {
247 version = %{V_asterisk_sounds_custom}
248 url = ftp://ftp.europalab.com/pub/sfw/machsnds/de-digits/
249 regex = de-digits-(__VER__)\.tar\.bz2
250 }
251 prog asterisk:sounds_custom = {
252 version = %{V_asterisk_sounds_custom}
253 url = ftp://ftp.europalab.com/pub/sfw/machsnds/de-sounds/
254 regex = astmultisnds-de-sln16-(__VER__)\.tar\.bz2
255 }
256 prog asterisk:sounds_mohop = {
257 version = %{V_asterisk_sounds_mohop}
258 url = http://downloads.asterisk.org/pub/telephony/sounds/releases/
259 regex = asterisk-moh-opsound-sln16-(__VER__)\.tar\.gz
260 }
261 prog asterisk:chan_capi = {
262 version = %{V_chan_capi}
263 url = ftp://ftp.chan-capi.org/chan-capi/
264 regex = chan_capi-(__VER__)\.tar\.gz
265 }
267 %prep
268 %if "%{with_capi}" == "yes"
269 ( echo "Note that the system header files capi20.h, capicmd.h, and capiutils.h might"
270 echo "need adjusting in accordance withthe CAPI hardware vendor's kernel driver."
271 ) | %{l_rpmtool} msg -b -t warn
272 %endif
273 %setup -q -n asterisk-%{V_asterisk}
274 %setup -q -n asterisk-%{V_asterisk} -D -T -a 1
275 %setup -q -n asterisk-%{V_asterisk} -D -T -a 2
276 %if "%{with_fax}" == "yes"
277 %setup -q -n asterisk-%{V_asterisk} -D -T -a 28
278 %setup -q -n asterisk-%{V_asterisk} -D -T -a 29
279 %endif
280 ( cd addons
281 %{l_tar} zxf %{_sourcedir}/mp3-%{V_asterisk_addons_mp3dec}.tar.gz
282 ) || exit $?
283 ( cd codecs
284 %{l_tar} zxf %{_sourcedir}/ilbc-%{V_asterisk_codecs_ilbc}.tar.gz
285 mv ilbc-%{V_asterisk_codecs_ilbc}/* ilbc/
286 rmdir ilbc-%{V_asterisk_codecs_ilbc}
287 ) || exit $?
288 %patch -p0
289 %if "%{with_xfersips}" == "yes"
290 %patch -p0 -P 1
291 %endif
292 %if "%{with_proxymwi}" == "yes"
293 %patch -p0 -P 2
294 %endif
295 %{l_shtool} subst \
296 -e 's;\(astdatadir=.*\)\${astvarlibdir};\1${datadir};' \
297 -e 's;\(astvarlibdir=.*\)/lib/asterisk;\1/asterisk/lib;' \
298 -e 's;\(astdbdir=.*\)\${astvarlibdir};\1${localstatedir}/asterisk/db;' \
299 -e 's;\(dir=.*{localstatedir}\)/\([^/][^/]*\)/asterisk;\1/asterisk/\2;g' \
300 configure
301 %{l_shtool} subst \
302 -e 's;ffmpeg/avcodec\.h;libavcodec/avcodec.h;' \
303 -e 's;\(sqlite\)\(_exec\);\13\2;g' \
304 -e 's;-lradiusclient-ng;-lradiusclient;g' \
305 -e 's;radiusclient-ng\.h;radiusclient.h;g' \
306 -e 's;lua5\.1;lua;g' \
307 -e 's;-I${IMAP_TK_DIR}/c-client;-DUSE_SYSTEM_IMAP -I${IMAP_TK_DIR}/include/imap;g' \
308 -e 's;${IMAP_TK_DIR}/c-client/c-client\.a;-limap -lssl -lcrypto -lcrypt;g' \
309 configure
310 %{l_shtool} subst \
311 -e 's;\(sh\) \(bash\) ksh sh5;\2 \1;' \
312 configure
313 %{l_shtool} subst \
314 -e 's;^\(#define DEFAULT_DB .*\${ASTDBDIR}\)/astdb;\1/asterisk.db;' \
315 build_tools/make_defaults_h
316 %{l_shtool} subst \
317 -e 's;^\(_all:.* *\)cleantest *;\1;' \
318 -e 's; *-I/usr/local/ssl/include;;g' \
319 -e 's;/opt/ssl/include;%{l_prefix}/include;g' \
320 -e 's;/usr/local;%{l_prefix};g' \
321 Makefile
322 %{l_shtool} subst \
323 -e 's;\$(SUBMAKE);$(MAKE);g' \
324 -e 's;\$(SILENTMAKE);$(MAKE) --quiet --no-print-directory;g' \
325 -e 's;\$(MAKE_MENUSELECT); $(MAKE) -C menuselect;g' \
326 Makefile
327 %{l_shtool} subst \
328 -e 's; *-L/usr/local/ssl/lib;;g' \
329 -e 's;/opt/ssl/lib;%{l_prefix}/lib;g' \
330 -e 's;/usr/local;%{l_prefix};g' \
331 -e 's;\(ASTLINK=\)$;\1-Wl,--export-dynamic;g' \
332 -e 's;\( CFLAGS=\)"[^"]+";"%{l_cflags -O}";g' \
333 main/Makefile
334 %{l_shtool} subst \
335 -e 's;\(<defaultenabled>\)no\(</defaultenabled>\);\1yes\2;g' \
336 apps/app_ivrdemo.c \
337 apps/app_saycounted.c \
338 apps/app_rpt.c \
339 utils/utils.xml \
340 agi/agi.xml
341 %{l_shtool} subst \
342 -e 's;\(-DSOLARIS\);\1 -D__EXTENSIONS__=1;g' \
343 main/editline/Makefile.in \
344 main/db1-ast/Makefile
345 %{l_shtool} subst \
346 -e 's;%s/astdb;%s/asterisk.db;g' \
347 main/asterisk.c
348 %{l_shtool} subst \
349 -e 's;u_int\([0-9]*\)_t;uint\1_t;g' \
350 main/db1-ast/hash/hash.h
351 %{l_shtool} subst \
352 -e 's;if \(((tmp = strchr(name\);while \1;g' \
353 main/abstract_jb.c
354 %{l_shtool} subst \
355 -e 's;\(/etc/radiusclient-ng/radiusclient.conf\);%{l_prefix}\1;g' \
356 -e 's;\(radiusclient\)-ng;\1;g' \
357 cdr/cdr_radius.c \
358 cel/cel_radius.c
359 %{l_shtool} subst \
360 -e 's;\(sqlite\)\(\.h\);\13\2;g' \
361 cdr/cdr_sqlite.c
362 %{l_shtool} subst \
363 -e 's;\(#define DEFAULT_POLLING_INTERVAL\) .*;\1 %{with_smdipoll};' \
364 res/res_smdi.c
365 %{l_shtool} subst \
366 -e 's;\(ASTERISK_HEADER_DIR=\).*;\1%{l_prefix}/include;g' \
367 -e 's;\(MODULES_DIR=\).*;\1%{l_prefix}/lib/asterisk/modules;g' \
368 -e 's;\(CONFIG_DIR=\).*;\1%{l_prefix}/etc/asterisk;g' \
369 -e 's;\(\$(MODULES_DIR)\);$(DESTDIR)\1;g' \
370 -e 's;\${CONFIG_DIR};$(DESTDIR)$(CONFIG_DIR);g' \
371 -e 's;^\(USE_OWN_LIBCAPI\)=yes;\1=no;' \
372 chan_capi-%{V_chan_capi}/Makefile
374 %build
375 # sanity check operating system
376 %if "%{with_dahdi}" == "yes"
377 dahdi_prefix=""
378 case "%{l_platform -t}" in
379 *-linux* )
380 if [ ! -f /usr/include/dahdi/user.h ]; then
381 echo "option \"with_dahdi\" requires DAHDI Linux drivers installed" 1>&2; exit 1
382 fi
383 dahdi_prefix=/usr
384 ;;
385 *-freebsd* )
386 if [ ! -f /usr/local/include/dahdi/user.h ]; then
387 echo "option \"with_dahdi\" requires DAHDI FreeBSD drivers installed" 1>&2; exit 1
388 fi
389 dahdi_prefix=/usr/local
390 ;;
391 * ) echo "option \"with_dahdi\" supported under Linux and FreeBSD only" 1>&2; exit 1 ;;
392 esac
393 %endif
394 # correct platform dependent build configuration
395 extflg=
396 case "%{l_platform -t}" in
397 *-linux* )
398 pthlibflg='-lpthread'
399 ;;
400 esac
402 # adapt buildconf to find mpg123 (for music on hold)
403 %if "%{with_mp3}" == "yes"
404 mpg123="%{l_prefix}/bin/mpg123"
405 %else
406 mpg123="`which false`"
407 %endif
408 %{l_shtool} subst \
409 -e "s;/usr/local/bin/mpg123;$mpg123;" \
410 -e "s;/usr/bin/mpg123;$mpg123;" \
411 res/res_musiconhold.c apps/app_mp3.c
413 # configure program
414 ( echo "ac_cv_prog_CONFIG_GMIME=%{l_prefix}/bin/gmime-config"
415 ) >config.cache
416 cflags="%{l_cflags -O}"
417 cppflags="%{l_cppflags ncurses lua}"
418 ldflags="%{l_ldflags}"
419 libs=""
420 cppflags="$cppflags `pkg-config gmime-2.4 --cflags-only-I`"
421 ldflags="$ldflags `pkg-config gmime-2.4 --libs-only-L`"
422 libs="$libs `pkg-config gmime-2.4 --libs-only-l` -lssl -lcrypto"
423 %if "%{with_ogg}" == "yes"
424 libs="$libs -logg -lm"
425 %endif
426 %if "%{with_avcodec}" == "yes"
427 libs="$libs -lavcodec -lavutil"
428 %endif
429 %if "%{with_ldap}" == "yes"
430 libs="$libs -lldap -llber"
431 %endif
432 %if "%{with_dahdi}" == "yes"
433 cppflags="$cppflags -I$dahdi_prefix/include"
434 ldflags="$ldflags -L$dahdi_prefix/lib"
435 %endif
436 CC="%{l_cc}" \
437 CFLAGS="$cflags" \
438 CPPFLAGS="$cppflags" \
439 LDFLAGS="$ldflags" \
440 LIBS="$libs" \
441 INSTALL="%{l_shtool} install -c" \
442 PTHREAD_LIBS="$pthlibflg" \
443 ./configure \
444 --cache-file=./config.cache \
445 --prefix=%{l_prefix} \
446 --mandir=%{l_prefix}/man \
447 --sysconfdir=%{l_prefix}/etc \
448 --localstatedir=%{l_prefix}/var \
449 --datarootdir=%{l_prefix}/share/asterisk \
450 --with-crypto=%{l_prefix} \
451 --with-libcurl=%{l_prefix} \
452 --with-ncurses=%{l_prefix} \
453 --with-gsm="internal" \
454 --with-popt=%{l_prefix} \
455 %if "%{with_sqlite}" == "yes"
456 --with-sqlite3=%{l_prefix} \
457 %else
458 --without-sqlite3 \
459 %endif
460 %if "%{with_srtp}" == "yes"
461 --with-srtp=%{l_prefix} \
462 %else
463 --without-srtp \
464 %endif
465 %if "%{with_pgsql}" == "yes"
466 --with-postgres=%{l_prefix} \
467 %else
468 --with-postgres=no \
469 %endif
470 --with-speex=%{l_prefix} \
471 --with-speexdsp=%{l_prefix} \
472 --with-ssl=%{l_prefix} \
473 --with-gmime=%{l_prefix} \
474 --with-z=%{l_prefix} \
475 %if "%{with_ogg}" == "yes"
476 --with-ogg=%{l_prefix} \
477 --with-vorbis=%{l_prefix} \
478 %else
479 --without-ogg \
480 --without-vorbis \
481 %endif
482 %if "%{with_jabber}" == "yes"
483 --with-iksemel=%{l_prefix} \
484 %else
485 --without-iksemel \
486 %endif
487 %if "%{with_lua}" == "yes"
488 --with-lua=%{l_prefix} \
489 %else
490 --without-lua \
491 %endif
492 %if "%{with_dahdi}" == "yes"
493 --with-dahdi=$dahdi_prefix \
494 --with-tonezone=$dahdi_prefix \
495 %else
496 --without-dahdi \
497 --without-tonezone \
498 %endif
499 %if "%{with_avcodec}" == "yes"
500 --with-avcodec=%{l_prefix} \
501 %else
502 --without-avcodec \
503 %endif
504 %if "%{with_ldap}" == "yes"
505 --with-ldap=%{l_prefix} \
506 %else
507 --without-ldap \
508 %endif
509 %if "%{with_radius}" == "yes"
510 --with-radius=%{l_prefix} \
511 %else
512 --without-radius \
513 %endif
514 %if "%{with_imap}" == "yes"
515 --with-imap=%{l_prefix} \
516 --disable-largefile \
517 %else
518 --without-imap \
519 %endif
520 --without-iodbc \
521 %if "%{with_odbc}" == "yes"
522 --with-unixodbc=%{l_prefix} \
523 %else
524 --without-unixodbc \
525 %endif
526 %if "%{with_libpri}" == "yes"
527 --with-pri=%{l_prefix} \
528 %else
529 --without-pri \
530 %endif
531 --with-sounds-cache=%_sourcedir \
532 --without-netsnmp \
533 --without-isdnnet \
534 --without-misdn \
535 --without-nbs \
536 --without-newt \
537 --without-asound \
538 --without-oss \
539 --without-sqlite \
540 --without-tds \
541 --without-osptk \
542 --without-suppserv \
543 --without-vpb \
544 --without-sdl \
545 --without-x11 \
546 --without-gtk2
548 # build menuselect
549 %{l_make} %{l_mflags -O} menuselect.makeopts
550 menuselect/menuselect \
551 --enable format_mp3 --enable app_fax --enable codec_ilbc \
552 --enable RADIO_RELAX --enable G711_NEW_ALGORITHM \
553 --enable G711_REDUCED_BRANCHING --enable CORE-SOUNDS-EN-SLN16 \
554 --enable CORE-SOUNDS-ES-SLN16 --enable CORE-SOUNDS-FR-SLN16 \
555 --enable CORE-SOUNDS-EN_AU-SLN16 --enable CORE-SOUNDS-RU-SLN16 \
556 --enable MOH-OPSOUND-SLN16 --enable EXTRA-SOUNDS-EN-SLN16 \
557 --enable EXTRA-SOUNDS-FR-SLN16 \
558 menuselect.makeopts
559 menuselect/menuselect \
560 --disable CORE-SOUNDS-EN-GSM \
561 --disable MOH-OPSOUND-WAV \
562 menuselect.makeopts
563 %if "%{with_imap}" == "yes"
564 menuselect/menuselect --enable IMAP_STORAGE menuselect.makeopts
565 %endif
567 # build program
568 %{l_make} %{l_mflags -O} \
569 CC="%{l_cc} $cflags -I../include -I../../include $cppflags" NOISY_BUILD=yes
571 %if "%{with_capi}" == "yes"
572 # build capi channel
573 ( cd chan_capi-*
574 ln -s ../include/asterisk .
575 ln -s ../include/asterisk.h .
576 %{l_make} %{l_mflags -O} V=1 \
577 INSTALL_PREFIX=%{l_prefix} \
578 ASTERISK_HEADER_DIR="`pwd`" \
579 ) || exit $?
580 %endif
582 %install
583 # install program
584 rm -rf $RPM_BUILD_ROOT
585 %{l_make} %{l_mflags} install \
586 DESTDIR=$RPM_BUILD_ROOT \
587 INSTALL_PREFIX=%{l_prefix}
589 %if "%{with_capi}" == "yes"
590 # install capi channel
591 ( cd chan_capi-*
592 %{l_make} %{l_mflags} install \
593 INSTALL_PREFIX=$RPM_BUILD_ROOT%{l_prefix} \
594 INSTALL="%{l_shtool} install -c" \
595 MODULES_DIR='$(INSTALL_PREFIX)/lib/asterisk/modules'
596 ) || exit $?
597 %endif
599 %if "%{with_fax}" == "yes"
600 # install fax support
601 case "%{l_platform -t}" in
602 amd64*-* )
603 %{l_shtool} install -c -m 755 \
604 res_fax_digium-%{V_asterisk_fax_digium}-generic_64/res_*.so \
605 $RPM_BUILD_ROOT%{l_prefix}/lib/asterisk/modules/
606 %{l_shtool} install -c -m 640 \
607 res_fax_digium-%{V_asterisk_fax_digium}-generic_64/*.conf \
608 $RPM_BUILD_ROOT%{l_prefix}/etc/asterisk/
609 ;;
610 i?86-* )
611 %{l_shtool} install -c -m 755 \
612 res_fax_digium-%{V_asterisk_fax_digium}-generic_32/res_*.so \
613 $RPM_BUILD_ROOT%{l_prefix}/lib/asterisk/modules/
614 %{l_shtool} install -c -m 640 \
615 res_fax_digium-%{V_asterisk_fax_digium}-generic_32/*.conf \
616 $RPM_BUILD_ROOT%{l_prefix}/etc/asterisk/
617 ;;
618 *-* )
619 echo "Error determining hardware architecture." \
620 | %{l_rpmtool} msg -b -t warn
621 exit 1;
622 ;;
623 esac
624 %endif
626 ( echo 'Start of sound installation block (RPM)'
627 %if "%{with_esounds}" == "yes"
628 # install freeswitch sound prompt files, expecting
629 # identical sound filenames to be overwritten later
630 cd $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/en
631 %{l_tar} zxf %{_sourcedir}/freeswitch-sounds-en-us-callie-48000-%{V_fswitch_sounds_en}.tar.gz
632 subs=`( cd en/us/callie && find * -type d -prune )`
633 for subdir in $subs; do
634 mkdir $subdir
635 mv -f en/us/callie/$subdir/*/* ${subdir}/
636 done
637 rm -rf en
638 cd $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/es
639 %{l_tar} zxf %{_sourcedir}/freeswitch-sounds-es-mx-maria-44100.tar.gz
640 subs=`( cd es/mx/maria && find * -type d -prune )`
641 for subdir in $subs; do
642 mkdir $subdir
643 mv -f es/mx/maria/$subdir/*/* ${subdir}/
644 done
645 rm -rf es
646 %{l_shtool} mkdir -f -p -m 755 \
647 $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/ru
648 cd $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/ru
649 %{l_tar} zxf %{_sourcedir}/freeswitch-sounds-ru-RU-elena-48000-%{V_fswitch_sounds_ru}.tar.gz
650 subs=`( cd ru/RU/elena && find * -type d -prune )`
651 for subdir in $subs; do
652 mkdir $subdir
653 mv -f ru/RU/elena/$subdir/*/* ${subdir}/
654 done
655 rm -rf ru
657 # install freeswitch music on hold files
658 cd $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/moh
659 %{l_tar} zxf %{_sourcedir}/freeswitch-sounds-music-48000-%{V_fswitch_music}.tar.gz
660 mv -f music/48000/* . && rm -rf music
662 # convert freeswitch 48000 and 441000 KHz to 8000 Khz
663 # ffmpeg -i <in> -ar 8000 -ac 1 -acodec pcm_s16le -f s16le <out>
664 cd $RPM_BUILD_ROOT%{l_prefix}/share/asterisk
665 for highfile in `find . -name '*.wav'`; do
666 lowfile=`echo $highfile | sed -e 's;\(.*\)\.wav;\1.sln16;'`
667 %{l_prefix}/bin/sox $highfile -t raw -r 16000 -s -2 -c 1 $lowfile
668 rm $highfile
669 done
670 %endif
672 # install australian nonversioned sound prompt files
673 cd $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/en_AU
674 %{l_tar} zxf %{_sourcedir}/asterisk-core-sounds-en_AU-current.tar.gz
676 # install main sound prompt files
677 #for codec in alaw ulaw g722 g729 gsm; do
678 for lang in en es fr; do
679 cd $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/${lang}
680 %{l_tar} zxf %{_sourcedir}/asterisk-core-sounds-${lang}-sln16-%{V_asterisk_sounds_core}.tar.gz
681 done
682 for lang in en fr; do
683 cd $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/${lang}
684 %{l_tar} zxf %{_sourcedir}/asterisk-extra-sounds-${lang}-sln16-%{V_asterisk_sounds_extra}.tar.gz
685 done
687 # install special case sound files
688 cd $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds
689 #%{l_tar} jxf %{SOURCE de-digits-%{V_asterisk_sounds_custom}.tar.bz2}
690 #( cd de && %{l_tar} zxf %{SOURCE asterisk-core-sounds-de-gsm-%{V_asterisk_sounds_amootts}.tar.gz} ) || exit $?
691 #%{l_tar} zxf %{SOURCE asterisk-%{V_asterisk_sounds_amoogab}-de-prompts.tar.gz}
692 #mv -f dictate/de/* de/dictate/ && rm -rf dictate/de
693 #mv -f digits/de/* de/digits/ && rm -rf digits/de
694 #mv -f letters/de/* de/letters/ && rm -rf letters/de
695 #mv -f phonetic/de/* de/phonetic/ && rm -rf phonetic/de
696 %{l_tar} jxf %{SOURCE astmultisnds-de-sln16-%{V_asterisk_sounds_custom}.tar.bz2}
697 %{l_tar} jxf %{SOURCE msvbsnds-sln16-%{V_asterisk_sounds_custom}.tar.bz2}
698 mv msvbsnds-sln16-%{V_asterisk_sounds_custom} msvb
700 # install additional asterisk music on hold
701 cd $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/moh
702 %{l_tar} zxf %{_sourcedir}/asterisk-moh-freeplay-sln16.tar.gz
703 %{l_tar} zxf %{_sourcedir}/asterisk-moh-opsound-sln16-%{V_asterisk_sounds_mohop}.tar.gz
705 # correct sound permissions
706 find $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/ -type f \
707 | xargs chmod 644
708 find $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/ -type d \
709 | xargs chmod 755
711 # apply provisional workaround for bug 0016104
712 # https://issues.asterisk.org/view.php?id=16104
713 cd $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds
714 cd en && ln -s vm-INBOX.sln16 vm-Voicemail.sln16
715 cd ../es && ln -s vm-INBOX.sln16 vm-Voicemail.sln16
716 cd ../de && ln -s vm-INBOX.sln16 vm-Voicemail.sln16
717 cd ../fr && ln -s vm-INBOX.sln16 vm-Voicemail.sln16
719 # # install nonstandard voicemail prompts
720 # %{l_shtool} mkdir -f -p -m 755 \
721 # $RPM_BUILD_ROOT%{l_prefix}/var/asterisk/spool/voicemail/default/%{exten}/unavail
722 # %{l_shtool} install -c -m 660 \
723 # %{_sourcedir}/ansage-%{V_ansage}.wav} \
724 # $RPM_BUILD_ROOT%{l_prefix}/var/asterisk/spool/voicemail/default/%{exten}/unavail.wav
725 ) || exit $? # End of sound installation block (RPM)
727 # strip down installation
728 rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/autosupport >/dev/null 2>&1 || true
729 rm -f $RPM_BUILD_ROOT%{l_prefix}/sbin/safe_asterisk >/dev/null 2>&1 || true
730 rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man8/autosupport.8 >/dev/null 2>&1 || true
731 rm -f $RPM_BUILD_ROOT%{l_prefix}/man/man8/safe_asterisk.8 >/dev/null 2>&1 || true
732 rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/images >/dev/null 2>&1 || true
733 rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/moh/.asterisk* >/dev/null 2>&1 || true
734 rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/moh/CREDIT* >/dev/null 2>&1 || true
735 rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/moh/CHANGES* >/dev/null 2>&1 || true
736 rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/moh/LICENSE* >/dev/null 2>&1 || true
737 rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/*/CREDIT* >/dev/null 2>&1 || true
738 rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/*/CHANGES* >/dev/null 2>&1 || true
739 rm -rf $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/sounds/*/.asterisk* >/dev/null 2>&1 || true
741 # create additional directories
742 %{l_shtool} mkdir -f -p -m 755 \
743 $RPM_BUILD_ROOT%{l_prefix}/var/asterisk/db \
744 $RPM_BUILD_ROOT%{l_prefix}/var/asterisk/spool/facsimile/rx \
745 $RPM_BUILD_ROOT%{l_prefix}/var/asterisk/spool/facsimile/tx \
746 $RPM_BUILD_ROOT%{l_prefix}/var/asterisk/spool/outgoing \
747 $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/licenses
749 # postadjust installation
750 strip $RPM_BUILD_ROOT%{l_prefix}/sbin/* \
751 $RPM_BUILD_ROOT%{l_prefix}/lib/asterisk/modules/* \
752 $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/agi-bin/* \
753 >/dev/null 2>&1 || true
754 mv $RPM_BUILD_ROOT%{l_prefix}/share/asterisk/agi-bin \
755 $RPM_BUILD_ROOT%{l_prefix}/lib/asterisk/agi-bin
757 # install AGI progs
758 ( cd agi
759 %{l_shtool} install -c -m 755 %{l_value -s -a} \
760 DialAnMp3.agi fastagi-test numeralize %{SOURCE wakeup.agi} \
761 $RPM_BUILD_ROOT%{l_prefix}/lib/asterisk/agi-bin/
762 ) || exit $?
763 for bin in $RPM_BUILD_ROOT%{l_prefix}/lib/asterisk/agi-bin/*.*; do
764 mv $bin `echo $bin | sed -e 's;\.[^.]*$;;'`
765 done
767 # install default configuration
768 for name in `grep "^<file" %{SOURCE asterisk.txt} | sed -e 's;^.*name=";;' -e 's;".*$;;'`; do
769 %if "%{with_dahdi}" == "no"
770 [ ".$name" = ".chan_dahdi.conf" ] && continue
771 %endif
772 %if "%{with_capi}" == "no"
773 [ ".$name" = ".capi.conf" ] && continue
774 %endif
775 %if "%{with_gtalk}" == "no"
776 [ ".$name" = ".gtalk.conf" ] && continue
777 %endif
778 %if "%{with_jabber}" == "no"
779 [ ".$name" = ".jabber.conf" ] && continue
780 %endif
781 %if "%{with_sqlite}" == "no"
782 [ ".$name" = ".cdr_sqlite3_custom.conf" ] && continue
783 %endif
784 %if "%{with_odbc}" == "no"
785 [ ".$name" = ".res_odbc.conf" ] && continue
786 [ ".$name" = ".func_odbc.conf" ] && continue
787 %endif
788 (echo ""; cat %{SOURCE asterisk.txt}; echo "") |\
789 sed -e "1,/^<file name=\"$name\">/d" -e "/<\/file>/,\$d" >$name
790 %{l_shtool} install -c -m 644 %{l_value -s -a} \
791 $name $RPM_BUILD_ROOT%{l_prefix}/etc/asterisk/
792 done
794 # install runcommand script
795 %{l_shtool} mkdir -f -p -m 755 \
796 $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d
797 %{l_shtool} install -c -m 755 %{l_value -s -a} \
798 %{SOURCE rc.asterisk} $RPM_BUILD_ROOT%{l_prefix}/etc/rc.d/
800 # determine installation files
801 %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
802 %{l_files_std} \
803 '%config %attr(640,%{l_mgrp},%{l_rgrp}) %{l_prefix}/etc/asterisk/*' \
804 '%config %attr(-,%{l_mgrp},%{l_mgrp}) %{l_prefix}/share/asterisk/licenses' \
805 '%attr(750,%{l_rgrp},%{l_rgrp}) %{l_prefix}/var/asterisk/spool/facsimile' \
806 '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/var/asterisk'
808 # '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/share/asterisk/sounds/es/vm-Voicemail.sln16' \
809 # '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/share/asterisk/sounds/de/vm-Voicemail.sln16' \
810 # '%attr(-,%{l_rusr},%{l_rgrp}) %{l_prefix}/share/asterisk/sounds/fr/vm-Voicemail.sln16' \
812 %files -f files
814 %clean
815 rm -rf $RPM_BUILD_ROOT
817 %post
818 %if "%{with_dahdi}" == "yes"
819 if [ $1 -eq 1 ]; then
820 case "%{l_platform -t}" in
821 *-freebsd* )
822 ( echo "To allow Asterisk to use the DAHDI /dev/dahdi/pseudo device(s)"
823 echo "you have add the following entry to /etc/devfs.rules:"
824 echo ""
825 echo "[openpkg_asterisk=10]"
826 echo "add path 'dahdi/pseudo*' mode 0664 user %{l_rusr} group %{l_rgrp}"
827 echo ""
828 ) | %{l_rpmtool} msg -b -t notice
829 ;;
830 esac
831 fi
832 %endif
833 %if "%{with_odbc}" == "yes"
834 # after install, optionally link into ODBC and create database
835 if $RPM_INSTALL_PREFIX/bin/odbcinst -q -s -n "asterisk-sqlite" >/dev/null 2>&1; then
836 :
837 else
838 ( echo "[asterisk-sqlite]"
839 echo "Description = Asterisk SQLite Database"
840 echo "Driver = SQLite3"
841 echo "Database = $RPM_INSTALL_PREFIX/var/asterisk/db/asterisk.sqlite"
842 echo "Timeout = 2000"
843 ) | $RPM_INSTALL_PREFIX/bin/odbcinst -i -s -l -n "asterisk-sqlite" -r >/dev/null 2>&1 || true
844 fi
845 if [ ! -f $RPM_INSTALL_PREFIX/var/asterisk/run/asterisk.db ]; then
846 ( umask 007
847 echo "CREATE TABLE map (key TEXT, val TEXT);" | $RPM_INSTALL_PREFIX/bin/isql "asterisk-sqlite" -b
848 chown %{l_rusr}:%{l_rgrp} $RPM_INSTALL_PREFIX/var/asterisk/db/asterisk.sqlite >/dev/null 2>&1 || true
849 ) || exit $?
850 fi
851 %endif
852 %if "%{with_fax}" == "yes"
853 ( echo "Asterisk has been installed with proprietary Digium fax support."
854 echo "The responsible module is called res_fax_digium and requires a"
855 echo "valid license. The license must be found in the directory"
856 echo "'licenses' which in turn must be found in %{l_prefix}/share/asterisk"
857 echo "or wherever astvarlibdir has been configured in 'asterisk.conf'."
858 echo ""
859 echo "Please see http://downloads.digium.com/pub/telephony/fax/ for information."
860 ) | %{l_rpmtool} msg -b -t notice
861 %endif
862 # after upgrade, restart service
863 [ $1 -eq 2 ] || exit 0
864 eval `%{l_rc} asterisk status 2>/dev/null`
865 [ ".$asterisk_active" = .yes ] && %{l_rc} asterisk restart
866 exit 0
868 %preun
869 # before erase, stop service and remove log files
870 [ $1 -eq 0 ] || exit 0
871 %{l_rc} asterisk stop 2>/dev/null
872 rm -f $RPM_INSTALL_PREFIX/var/asterisk/log/* >/dev/null 2>&1 || true
873 rm -f $RPM_INSTALL_PREFIX/var/asterisk/log/cdr-*/* >/dev/null 2>&1 || true
874 rm -f $RPM_INSTALL_PREFIX/var/asterisk/run/* >/dev/null 2>&1 || true
875 rm -f $RPM_INSTALL_PREFIX/var/asterisk/spool/*/* >/dev/null 2>&1 || true
876 rm -f $RPM_INSTALL_PREFIX/var/asterisk/lib/* >/dev/null 2>&1 || true
877 rm -f $RPM_INSTALL_PREFIX/var/asterisk/db/* >/dev/null 2>&1 || true
878 %if "%{with_odbc}" == "yes"
879 # before erase, optionally unlink from ODBC and destroy database
880 $RPM_INSTALL_PREFIX/bin/odbcinst -u -s -l -n "asterisk-sqlite" >/dev/null 2>&1 || true
881 %endif
882 exit 0