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