Merged revisions 332369 via svnmerge from
[asterisk/asterisk.git] / sounds / Makefile
1 #
2 # Asterisk -- A telephony toolkit for Linux.
3
4 # Makefile for sound files
5 #
6 # Copyright (C) 2006, Digium, Inc.
7 #
8 # Kevin P. Fleming <kpfleming@digium.com>
9 #
10 # This program is free software, distributed under the terms of
11 # the GNU General Public License
12 #
13
14 .PHONY: dist-clean all uninstall have_download install
15
16 -include $(ASTTOPDIR)/menuselect.makeopts $(ASTTOPDIR)/makeopts
17
18 CMD_PREFIX?=@
19 SOUNDS_DIR:=$(MAKE_ASTDATADIR)/sounds
20 SOUNDS_CACHE_DIR?=
21 MOH_DIR:=$(MAKE_ASTDATADIR)/moh
22 CORE_SOUNDS_VERSION:=1.4.21
23 EXTRA_SOUNDS_VERSION:=1.4.11
24 MOH_VERSION:=2.03
25 SOUNDS_URL:=http://downloads.asterisk.org/pub/telephony/sounds/releases
26 MCS:=$(subst -EN-,-en-,$(MENUSELECT_CORE_SOUNDS))
27 MCS:=$(subst -EN_AU-,-en_AU-,$(MCS))
28 MCS:=$(subst -FR-,-fr-,$(MCS))
29 MCS:=$(subst -ES-,-es-,$(MCS))
30 MCS:=$(subst -RU-,-ru-,$(MCS))
31 MCS:=$(subst -WAV,-wav,$(MCS))
32 MCS:=$(subst -ULAW,-ulaw,$(MCS))
33 MCS:=$(subst -ALAW,-alaw,$(MCS))
34 MCS:=$(subst -GSM,-gsm,$(MCS))
35 MCS:=$(subst -G729,-g729,$(MCS))
36 MCS:=$(subst -G722,-g722,$(MCS))
37 MCS:=$(subst -SLN16,-sln16,$(MCS))
38 MCS:=$(subst -SIREN7,-siren7,$(MCS))
39 MCS:=$(subst -SIREN14,-siren14,$(MCS))
40 CORE_SOUNDS:=$(MCS:CORE-SOUNDS-%=asterisk-core-sounds-%-$(CORE_SOUNDS_VERSION).tar.gz)
41 CORE_SOUND_TAGS:=$(MCS:CORE-SOUNDS-%=$(SOUNDS_DIR)/.asterisk-core-sounds-%-$(CORE_SOUNDS_VERSION))
42 MES:=$(subst -EN-,-en-,$(MENUSELECT_EXTRA_SOUNDS))
43 MES:=$(subst -FR-,-fr-,$(MES))
44 MES:=$(subst -ES-,-es-,$(MES))
45 MES:=$(subst -WAV,-wav,$(MES))
46 MES:=$(subst -ULAW,-ulaw,$(MES))
47 MES:=$(subst -ALAW,-alaw,$(MES))
48 MES:=$(subst -GSM,-gsm,$(MES))
49 MES:=$(subst -G729,-g729,$(MES))
50 MES:=$(subst -G722,-g722,$(MES))
51 MES:=$(subst -SLN16,-sln16,$(MES))
52 MES:=$(subst -SIREN7,-siren7,$(MES))
53 MES:=$(subst -SIREN14,-siren14,$(MES))
54 EXTRA_SOUNDS:=$(MES:EXTRA-SOUNDS-%=asterisk-extra-sounds-%-$(EXTRA_SOUNDS_VERSION).tar.gz)
55 EXTRA_SOUND_TAGS:=$(MES:EXTRA-SOUNDS-%=$(SOUNDS_DIR)/.asterisk-extra-sounds-%-$(EXTRA_SOUNDS_VERSION))
56 MM:=$(subst -OPSOUND-,-opsound-,$(MENUSELECT_MOH))
57 MM:=$(subst -WAV,-wav,$(MM))
58 MM:=$(subst -ULAW,-ulaw,$(MM))
59 MM:=$(subst -ALAW,-alaw,$(MM))
60 MM:=$(subst -GSM,-gsm,$(MM))
61 MM:=$(subst -G729,-g729,$(MM))
62 MM:=$(subst -G722,-g722,$(MM))
63 MM:=$(subst -SLN16,-sln16,$(MM))
64 MM:=$(subst -SIREN7,-siren7,$(MM))
65 MM:=$(subst -SIREN14,-siren14,$(MM))
66 MOH:=$(MM:MOH-%=asterisk-moh-%-$(MOH_VERSION).tar.gz)
67 MOH_TAGS:=$(MM:MOH-%=$(MOH_DIR)/.asterisk-moh-%-$(MOH_VERSION))
68 # If "fetch" is used, --continue is not a valid option.
69 ifneq ($(findstring wget,$(DOWNLOAD)),)
70 DOWNLOAD+=--continue $(WGET_EXTRA_ARGS)
71 endif
72
73 ifneq ($(SOUNDS_CACHE_DIR),)
74
75 define sound_format_lang_rule
76 $(1)/.asterisk-$(2)$(if $(3),-$(3),)-%: have_download
77         $(CMD_PREFIX)PACKAGE=$$(subst $(1)/.asterisk,asterisk,$$@).tar.gz; \
78         if test ! -f $$(SOUNDS_CACHE_DIR)/$$$${PACKAGE}; then \
79           (cd $$(SOUNDS_CACHE_DIR); $$(DOWNLOAD) $$(SOUNDS_URL)/$$$${PACKAGE}); \
80         fi; \
81         if test ! -f $$(SOUNDS_CACHE_DIR)/$$$${PACKAGE}.sha1; then \
82           (cd $$(SOUNDS_CACHE_DIR); $$(DOWNLOAD) $$(SOUNDS_URL)/$$$${PACKAGE}.sha1); \
83         fi; \
84         $(LN) -sf $$(SOUNDS_CACHE_DIR)/$$$${PACKAGE} .; \
85         $(LN) -sf $$(SOUNDS_CACHE_DIR)/$$$${PACKAGE}.sha1 .; \
86         $$(SHA1SUM) -c --status $$$${PACKAGE}.sha1 || \
87           ( \
88             rm -f $$(SOUNDS_CACHE_DIR)/$$$${PACKAGE} $$(SOUNDS_CACHE_DIR)/$$$${PACKAGE}.sha1 $$$${PACKAGE} $$$${PACKAGE}.sha1; \
89             echo "Bad checksum: $$$${PACKAGE}" 1>&2; \
90             exit 1; \
91           ) || exit 1; \
92         rm -f $$(subst -$(4),,$$@)-*; \
93         (cd $(1)$(if $(3),/$(3),); cat $$(CURDIR)/$$$${PACKAGE} | gzip -d | tar xof -) && touch $$@
94 endef
95
96 define sound_download_rule
97 asterisk-$(1)-%.tar.gz: have_download
98         $(CMD_PREFIX) \
99         if test ! -f $$(SOUNDS_CACHE_DIR)/$$@; then \
100           (cd $$(SOUNDS_CACHE_DIR); $$(DOWNLOAD) $$(SOUNDS_URL)/$$@); \
101         fi; \
102         if test ! -f $$(SOUNDS_CACHE_DIR)/$$@.sha1; then \
103           (cd $$(SOUNDS_CACHE_DIR); $$(DOWNLOAD) $$(SOUNDS_URL)/$$@.sha1); \
104         fi; \
105         $(LN) -sf $$(SOUNDS_CACHE_DIR)/$$@ .; \
106         $(LN) -sf $$(SOUNDS_CACHE_DIR)/$$@.sha1 .; \
107         $$(SHA1SUM) -c --status $$@.sha1 || \
108           ( \
109             rm -f $$(SOUNDS_CACHE_DIR)/$$@ $$(SOUNDS_CACHE_DIR)/$$@.sha1 $$@ $$@.sha1; \
110             echo "Bad checksum: $$@" 1>&2; \
111             exit 1; \
112           ) || exit 1
113 endef
114
115 else
116
117 define sound_format_lang_rule
118 $(1)/.asterisk-$(2)$(if $(3),-$(3),)-%: have_download
119         $(CMD_PREFIX)PACKAGE=$$(subst $(1)/.asterisk,asterisk,$$@).tar.gz; \
120         if test ! -f $$$${PACKAGE}; then \
121           $$(DOWNLOAD) $$(SOUNDS_URL)/$$$${PACKAGE} || exit 1; \
122         fi; \
123         rm -f $$(subst -$(4),,$$@)-*; \
124         (cd $(1)$(if $(3),/$(3),); cat $$(CURDIR)/$$$${PACKAGE} | gzip -d | tar xof -) && touch $$@
125 endef
126
127 define sound_download_rule
128 asterisk-$(1)-%.tar.gz: have_download
129         $(CMD_PREFIX)if test ! -f $$@ && test ! -f $$(SOUNDS_DIR)/.$$(subst .tar.gz,,$$@); then \
130           $$(DOWNLOAD) $$(SOUNDS_URL)/$$@; \
131         fi
132 endef
133
134 endif
135
136 all: $(SOUNDS_CACHE_DIR) $(CORE_SOUNDS) $(EXTRA_SOUNDS) $(MOH)
137
138 have_download:
139         @if test "$(DOWNLOAD)" = ":" ; then \
140                 echo "**************************************************"; \
141                 echo "***                                            ***"; \
142                 echo "*** You must have either wget or fetch to be   ***"; \
143                 echo "*** able to automatically download and install ***"; \
144                 echo "*** the requested sound packages.              ***"; \
145                 echo "***                                            ***"; \
146                 echo "*** Please install one of these, or remove any ***"; \
147                 echo "*** extra sound package selections in          ***"; \
148                 echo "*** menuselect before installing Asterisk.     ***"; \
149                 echo "***                                            ***"; \
150                 echo "**************************************************"; \
151                 exit 1; \
152         fi
153
154 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,en,$(CORE_SOUNDS_VERSION)))
155
156 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,en_AU,$(CORE_SOUNDS_VERSION)))
157
158 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,es,$(CORE_SOUNDS_VERSION)))
159
160 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,fr,$(CORE_SOUNDS_VERSION)))
161
162 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,ru,$(CORE_SOUNDS_VERSION)))
163
164 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),extra-sounds,en,$(EXTRA_SOUNDS_VERSION)))
165
166 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),extra-sounds,es,$(EXTRA_SOUNDS_VERSION)))
167
168 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),extra-sounds,fr,$(EXTRA_SOUNDS_VERSION)))
169
170 $(eval $(call sound_format_lang_rule,$(MOH_DIR),moh,,$(MOH_VERSION)))
171
172 $(eval $(call sound_download_rule,core-sounds))
173
174 $(eval $(call sound_download_rule,extra-sounds))
175
176 $(eval $(call sound_download_rule,moh))
177
178 dist-clean:
179         rm -f *.tar.gz
180
181 $(SOUNDS_DIR)/en $(MOH_DIR) $(SOUNDS_DIR)/en_AU $(SOUNDS_DIR)/es $(SOUNDS_DIR)/fr $(SOUNDS_DIR)/ru $(SOUNDS_CACHE_DIR):
182         mkdir -p $@
183
184 install: $(SOUNDS_CACHE_DIR) $(SOUNDS_DIR)/en $(SOUNDS_DIR)/en_AU $(SOUNDS_DIR)/es $(SOUNDS_DIR)/fr $(MOH_DIR) $(CORE_SOUND_TAGS) $(EXTRA_SOUND_TAGS) $(MOH_TAGS)
185
186 uninstall:
187         rm -rf $(SOUNDS_DIR)
188         rm -rf $(MOH_DIR)
189
190 core_sounds_version:
191         @echo $(CORE_SOUNDS_VERSION)
192
193 extra_sounds_version:
194         @echo $(EXTRA_SOUNDS_VERSION)
195
196 moh_version:
197         @echo $(MOH_VERSION)