2 # Asterisk -- A telephony toolkit for Linux.
4 # Makefile for sound files
6 # Copyright (C) 2006, Digium, Inc.
8 # Kevin P. Fleming <kpfleming@digium.com>
10 # This program is free software, distributed under the terms of
11 # the GNU General Public License
14 .PHONY: dist-clean all uninstall have_download install
16 -include $(ASTTOPDIR)/menuselect.makeopts $(ASTTOPDIR)/makeopts
19 SOUNDS_DIR:=$(DESTDIR)$(ASTDATADIR)/sounds
21 MOH_DIR:=$(DESTDIR)$(ASTDATADIR)/moh
22 CORE_SOUNDS_VERSION:=1.4.19
23 EXTRA_SOUNDS_VERSION:=1.4.11
25 SOUNDS_URL:=http://downloads.asterisk.org/pub/telephony/sounds/releases
26 MCS:=$(subst -EN-,-en-,$(MENUSELECT_CORE_SOUNDS))
27 MCS:=$(subst -FR-,-fr-,$(MCS))
28 MCS:=$(subst -ES-,-es-,$(MCS))
29 MCS:=$(subst -WAV,-wav,$(MCS))
30 MCS:=$(subst -ULAW,-ulaw,$(MCS))
31 MCS:=$(subst -ALAW,-alaw,$(MCS))
32 MCS:=$(subst -GSM,-gsm,$(MCS))
33 MCS:=$(subst -G729,-g729,$(MCS))
34 MCS:=$(subst -G722,-g722,$(MCS))
35 MCS:=$(subst -SLN16,-sln16,$(MCS))
36 MCS:=$(subst -SIREN7,-siren7,$(MCS))
37 MCS:=$(subst -SIREN14,-siren14,$(MCS))
38 CORE_SOUNDS:=$(MCS:CORE-SOUNDS-%=asterisk-core-sounds-%-$(CORE_SOUNDS_VERSION).tar.gz)
39 CORE_SOUND_TAGS:=$(MCS:CORE-SOUNDS-%=$(SOUNDS_DIR)/.asterisk-core-sounds-%-$(CORE_SOUNDS_VERSION))
40 MES:=$(subst -EN-,-en-,$(MENUSELECT_EXTRA_SOUNDS))
41 MES:=$(subst -FR-,-fr-,$(MES))
42 MES:=$(subst -ES-,-es-,$(MES))
43 MES:=$(subst -WAV,-wav,$(MES))
44 MES:=$(subst -ULAW,-ulaw,$(MES))
45 MES:=$(subst -ALAW,-alaw,$(MES))
46 MES:=$(subst -GSM,-gsm,$(MES))
47 MES:=$(subst -G729,-g729,$(MES))
48 MES:=$(subst -G722,-g722,$(MES))
49 MES:=$(subst -SLN16,-sln16,$(MES))
50 MES:=$(subst -SIREN7,-siren7,$(MES))
51 MES:=$(subst -SIREN14,-siren14,$(MES))
52 EXTRA_SOUNDS:=$(MES:EXTRA-SOUNDS-%=asterisk-extra-sounds-%-$(EXTRA_SOUNDS_VERSION).tar.gz)
53 EXTRA_SOUND_TAGS:=$(MES:EXTRA-SOUNDS-%=$(SOUNDS_DIR)/.asterisk-extra-sounds-%-$(EXTRA_SOUNDS_VERSION))
54 MM:=$(subst -OPSOUND-,-opsound-,$(MENUSELECT_MOH))
55 MM:=$(subst -WAV,-wav,$(MM))
56 MM:=$(subst -ULAW,-ulaw,$(MM))
57 MM:=$(subst -ALAW,-alaw,$(MM))
58 MM:=$(subst -GSM,-gsm,$(MM))
59 MM:=$(subst -G729,-g729,$(MM))
60 MM:=$(subst -G722,-g722,$(MM))
61 MM:=$(subst -SLN16,-sln16,$(MM))
62 MM:=$(subst -SIREN7,-siren7,$(MM))
63 MM:=$(subst -SIREN14,-siren14,$(MM))
64 MOH:=$(MM:MOH-%=asterisk-moh-%-$(MOH_VERSION).tar.gz)
65 MOH_TAGS:=$(MM:MOH-%=$(MOH_DIR)/.asterisk-moh-%-$(MOH_VERSION))
66 # If "fetch" is used, --continue is not a valid option.
67 ifneq ($(findstring wget,$(DOWNLOAD)),)
68 DOWNLOAD+=--continue $(WGET_EXTRA_ARGS)
74 ifneq ($(SOUNDS_CACHE_DIR),)
76 define sound_format_lang_rule
77 $$($(1))/.asterisk-$(2)$(if $(3),-$(3),)-%: have_download
78 $(CMD_PREFIX)PACKAGE=$$(subst $$($(1))/.asterisk,asterisk,$$@).tar.gz; $(BS)
79 if test ! -f $$$${PACKAGE}; then $(BS)
80 if test ! -f $$(SOUNDS_CACHE_DIR)/$$$${PACKAGE}; then $(BS)
81 (cd $$(SOUNDS_CACHE_DIR); ($$(DOWNLOAD) $$(SOUNDS_URL)/$$$${PACKAGE} && $(BS)
82 $$(DOWNLOAD) $$(SOUNDS_URL)/$$$${PACKAGE}.sha1 $(BS)
83 && $$(SHA1SUM) -c --status $$$${PACKAGE}.sha1) || $(BS)
84 (echo "Bad checksum: $$$${PACKAGE}" 1>&2; exit 1)); $(BS)
86 $(LN) -sf $$(SOUNDS_CACHE_DIR)/$$$${PACKAGE} .; $(BS)
88 $(if $($(4)_VERSION),\
89 $(EMPTY) rm -f $$(subst -$$($(4)_VERSION),,$$@)-* && $(BS)
90 ,) (cd $$($(1))$(if $(3),/$(3),); cat $$(CURDIR)/$$$${PACKAGE} | gzip -d | tar xof -) && $(BS)
94 define sound_download_rule
95 asterisk-$(1)-%.tar.gz: have_download
96 $(CMD_PREFIX)if test ! -f $$@ && test ! -f $$(SOUNDS_DIR)/.$$(subst .tar.gz,,$/$@); then $(BS)
97 if test ! -f $$(SOUNDS_CACHE_DIR)/$$@; then $(BS)
98 (cd $$(SOUNDS_CACHE_DIR); ($$(DOWNLOAD) $$(SOUNDS_URL)/$$@ && $(BS)
99 $$(DOWNLOAD) $$(SOUNDS_URL)/$$@.sha1 $(BS)
100 && $$(SHA1SUM) -c --status $$@.sha1) || $(BS)
101 (echo "Bad checksum: $$@" 1>&2; exit 1)); $(BS)
103 $(LN) -sf $$(SOUNDS_CACHE_DIR)/$$@ .; $(BS)
109 define sound_format_lang_rule
110 $$($(1))/.asterisk-$(2)$(if $(3),-$(3),)-%: have_download
111 $(CMD_PREFIX)PACKAGE=$$(subst $$($(1))/.asterisk,asterisk,$$@).tar.gz; $(BS)
112 if test ! -f $$$${PACKAGE}; then $(BS)
113 ($$(DOWNLOAD) $$(SOUNDS_URL)/$$$${PACKAGE} || exit 1); $(BS)
115 $(if $($(4)_VERSION),\
116 $(EMPTY) rm -f $$(subst -$$($(4)_VERSION),,$$@)-* && $(BS)
117 ,) (cd $$($(1))$(if $(3),/$(3),); cat $$(CURDIR)/$$$${PACKAGE} | gzip -d | tar xof -) && $(BS)
121 define sound_download_rule
122 asterisk-$(1)-%.tar.gz: have_download
123 $(CMD_PREFIX)if test ! -f $$@ && test ! -f $$(SOUNDS_DIR)/.$$(subst .tar.gz,,$$@); then $(BS)
124 $$(DOWNLOAD) $$(SOUNDS_URL)/$$@; $(BS)
130 all: $(SOUNDS_CACHE_DIR) $(CORE_SOUNDS) $(EXTRA_SOUNDS) $(MOH)
133 @if test "$(DOWNLOAD)" = ":" ; then \
134 echo "**************************************************"; \
136 echo "*** You must have either wget or fetch to be ***"; \
137 echo "*** able to automatically download and install ***"; \
138 echo "*** the requested sound packages. ***"; \
140 echo "*** Please install one of these, or remove any ***"; \
141 echo "*** extra sound package selections in ***"; \
142 echo "*** menuselecct before installing Asterisk. ***"; \
144 echo "**************************************************"; \
148 $(eval $(call sound_format_lang_rule,SOUNDS_DIR,core-sounds,en,CORE_SOUNDS))
150 $(eval $(call sound_format_lang_rule,SOUNDS_DIR,core-sounds,es,CORE_SOUNDS))
152 $(eval $(call sound_format_lang_rule,SOUNDS_DIR,core-sounds,fr,CORE_SOUNDS))
154 $(eval $(call sound_format_lang_rule,SOUNDS_DIR,extra-sounds,en,EXTRA_SOUNDS))
156 $(eval $(call sound_format_lang_rule,SOUNDS_DIR,extra-sounds,es,EXTRA_SOUNDS))
158 $(eval $(call sound_format_lang_rule,SOUNDS_DIR,extra-sounds,fr,EXTRA_SOUNDS))
160 $(eval $(call sound_format_lang_rule,MOH_DIR,moh,,MOH))
162 $(eval $(call sound_download_rule,core))
164 $(eval $(call sound_download_rule,extra))
166 $(eval $(call sound_download_rule,moh))
171 $(SOUNDS_DIR)/en $(MOH_DIR) $(SOUNDS_DIR)/es $(SOUNDS_DIR)/fr $(SOUNDS_CACHE_DIR):
174 install: ${SOUNDS_CACHE_DIR} $(SOUNDS_DIR)/en $(SOUNDS_DIR)/es $(SOUNDS_DIR)/fr $(MOH_DIR) $(CORE_SOUND_TAGS) $(EXTRA_SOUND_TAGS) $(MOH_TAGS)
181 @echo $(CORE_SOUNDS_VERSION)
183 extra_sounds_version:
184 @echo $(EXTRA_SOUNDS_VERSION)