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