Merged revisions 292225 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:=$(DESTDIR)$(ASTDATADIR)/sounds
20 SOUNDS_CACHE_DIR?=
21 MOH_DIR:=$(DESTDIR)$(ASTDATADIR)/moh
22 CORE_SOUNDS_VERSION:=1.4.20
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 -WAV,-wav,$(MCS))
31 MCS:=$(subst -ULAW,-ulaw,$(MCS))
32 MCS:=$(subst -ALAW,-alaw,$(MCS))
33 MCS:=$(subst -GSM,-gsm,$(MCS))
34 MCS:=$(subst -G729,-g729,$(MCS))
35 MCS:=$(subst -G722,-g722,$(MCS))
36 MCS:=$(subst -SLN16,-sln16,$(MCS))
37 MCS:=$(subst -SIREN7,-siren7,$(MCS))
38 MCS:=$(subst -SIREN14,-siren14,$(MCS))
39 CORE_SOUNDS:=$(MCS:CORE-SOUNDS-%=asterisk-core-sounds-%-$(CORE_SOUNDS_VERSION).tar.gz)
40 CORE_SOUND_TAGS:=$(MCS:CORE-SOUNDS-%=$(SOUNDS_DIR)/.asterisk-core-sounds-%-$(CORE_SOUNDS_VERSION))
41 MES:=$(subst -EN-,-en-,$(MENUSELECT_EXTRA_SOUNDS))
42 MES:=$(subst -FR-,-fr-,$(MES))
43 MES:=$(subst -ES-,-es-,$(MES))
44 MES:=$(subst -WAV,-wav,$(MES))
45 MES:=$(subst -ULAW,-ulaw,$(MES))
46 MES:=$(subst -ALAW,-alaw,$(MES))
47 MES:=$(subst -GSM,-gsm,$(MES))
48 MES:=$(subst -G729,-g729,$(MES))
49 MES:=$(subst -G722,-g722,$(MES))
50 MES:=$(subst -SLN16,-sln16,$(MES))
51 MES:=$(subst -SIREN7,-siren7,$(MES))
52 MES:=$(subst -SIREN14,-siren14,$(MES))
53 EXTRA_SOUNDS:=$(MES:EXTRA-SOUNDS-%=asterisk-extra-sounds-%-$(EXTRA_SOUNDS_VERSION).tar.gz)
54 EXTRA_SOUND_TAGS:=$(MES:EXTRA-SOUNDS-%=$(SOUNDS_DIR)/.asterisk-extra-sounds-%-$(EXTRA_SOUNDS_VERSION))
55 MM:=$(subst -OPSOUND-,-opsound-,$(MENUSELECT_MOH))
56 MM:=$(subst -WAV,-wav,$(MM))
57 MM:=$(subst -ULAW,-ulaw,$(MM))
58 MM:=$(subst -ALAW,-alaw,$(MM))
59 MM:=$(subst -GSM,-gsm,$(MM))
60 MM:=$(subst -G729,-g729,$(MM))
61 MM:=$(subst -G722,-g722,$(MM))
62 MM:=$(subst -SLN16,-sln16,$(MM))
63 MM:=$(subst -SIREN7,-siren7,$(MM))
64 MM:=$(subst -SIREN14,-siren14,$(MM))
65 MOH:=$(MM:MOH-%=asterisk-moh-%-$(MOH_VERSION).tar.gz)
66 MOH_TAGS:=$(MM:MOH-%=$(MOH_DIR)/.asterisk-moh-%-$(MOH_VERSION))
67 # If "fetch" is used, --continue is not a valid option.
68 ifneq ($(findstring wget,$(DOWNLOAD)),)
69 DOWNLOAD+=--continue $(WGET_EXTRA_ARGS)
70 endif
71
72 ifneq ($(SOUNDS_CACHE_DIR),)
73
74 define sound_format_lang_rule
75 $(1)/.asterisk-$(2)$(if $(3),-$(3),)-%: have_download
76         $(CMD_PREFIX)PACKAGE=$$(subst $(1)/.asterisk,asterisk,$$@).tar.gz; \
77         if test ! -f $$(SOUNDS_CACHE_DIR)/$$$${PACKAGE}; then \
78           (cd $$(SOUNDS_CACHE_DIR); $$(DOWNLOAD) $$(SOUNDS_URL)/$$$${PACKAGE}); \
79         fi; \
80         if test ! -f $$(SOUNDS_CACHE_DIR)/$$$${PACKAGE}.sha1; then \
81           (cd $$(SOUNDS_CACHE_DIR); $$(DOWNLOAD) $$(SOUNDS_URL)/$$$${PACKAGE}.sha1); \
82         fi; \
83         $(LN) -sf $$(SOUNDS_CACHE_DIR)/$$$${PACKAGE} .; \
84         $(LN) -sf $$(SOUNDS_CACHE_DIR)/$$$${PACKAGE}.sha1 .; \
85         $$(SHA1SUM) -c --status $$$${PACKAGE}.sha1 || \
86           ( \
87             rm -f $$(SOUNDS_CACHE_DIR)/$$$${PACKAGE} $$(SOUNDS_CACHE_DIR)/$$$${PACKAGE}.sha1 $$$${PACKAGE} $$$${PACKAGE}.sha1; \
88             echo "Bad checksum: $$$${PACKAGE}" 1>&2; \
89             exit 1; \
90           ) || exit 1; \
91         rm -f $$(subst -$(4),,$$@)-*; \
92         (cd $(1)$(if $(3),/$(3),); cat $$(CURDIR)/$$$${PACKAGE} | gzip -d | tar xof -) && touch $$@
93 endef
94
95 define sound_download_rule
96 asterisk-$(1)-%.tar.gz: have_download
97         $(CMD_PREFIX) \
98         if test ! -f $$(SOUNDS_CACHE_DIR)/$$@; then \
99           (cd $$(SOUNDS_CACHE_DIR); $$(DOWNLOAD) $$(SOUNDS_URL)/$$@); \
100         fi; \
101         if test ! -f $$(SOUNDS_CACHE_DIR)/$$@.sha1; then \
102           (cd $$(SOUNDS_CACHE_DIR); $$(DOWNLOAD) $$(SOUNDS_URL)/$$@.sha1); \
103         fi; \
104         $(LN) -sf $$(SOUNDS_CACHE_DIR)/$$@ .; \
105         $(LN) -sf $$(SOUNDS_CACHE_DIR)/$$@.sha1 .; \
106         $$(SHA1SUM) -c --status $$@.sha1 || \
107           ( \
108             rm -f $$(SOUNDS_CACHE_DIR)/$$@ $$(SOUNDS_CACHE_DIR)/$$@.sha1 $$@ $$@.sha1; \
109             echo "Bad checksum: $$@" 1>&2; \
110             exit 1; \
111           ) || exit 1
112 endef
113
114 else
115
116 define sound_format_lang_rule
117 $(1)/.asterisk-$(2)$(if $(3),-$(3),)-%: have_download
118         $(CMD_PREFIX)PACKAGE=$$(subst $(1)/.asterisk,asterisk,$$@).tar.gz; \
119         if test ! -f $$$${PACKAGE}; then \
120           $$(DOWNLOAD) $$(SOUNDS_URL)/$$$${PACKAGE} || exit 1; \
121         fi; \
122         rm -f $$(subst -$(4),,$$@)-*; \
123         (cd $(1)$(if $(3),/$(3),); cat $$(CURDIR)/$$$${PACKAGE} | gzip -d | tar xof -) && touch $$@
124 endef
125
126 define sound_download_rule
127 asterisk-$(1)-%.tar.gz: have_download
128         $(CMD_PREFIX)if test ! -f $$@ && test ! -f $$(SOUNDS_DIR)/.$$(subst .tar.gz,,$$@); then \
129           $$(DOWNLOAD) $$(SOUNDS_URL)/$$@; \
130         fi
131 endef
132
133 endif
134
135 all: $(SOUNDS_CACHE_DIR) $(CORE_SOUNDS) $(EXTRA_SOUNDS) $(MOH)
136
137 have_download:
138         @if test "$(DOWNLOAD)" = ":" ; then \
139                 echo "**************************************************"; \
140                 echo "***                                            ***"; \
141                 echo "*** You must have either wget or fetch to be   ***"; \
142                 echo "*** able to automatically download and install ***"; \
143                 echo "*** the requested sound packages.              ***"; \
144                 echo "***                                            ***"; \
145                 echo "*** Please install one of these, or remove any ***"; \
146                 echo "*** extra sound package selections in          ***"; \
147                 echo "*** menuselect before installing Asterisk.     ***"; \
148                 echo "***                                            ***"; \
149                 echo "**************************************************"; \
150                 exit 1; \
151         fi
152
153 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,en,$(CORE_SOUNDS_VERSION)))
154
155 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,en_AU,$(CORE_SOUNDS_VERSION)))
156
157 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,es,$(CORE_SOUNDS_VERSION)))
158
159 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,fr,$(CORE_SOUNDS_VERSION)))
160
161 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),extra-sounds,en,$(EXTRA_SOUNDS_VERSION)))
162
163 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),extra-sounds,es,$(EXTRA_SOUNDS_VERSION)))
164
165 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),extra-sounds,fr,$(EXTRA_SOUNDS_VERSION)))
166
167 $(eval $(call sound_format_lang_rule,$(MOH_DIR),moh,,$(MOH_VERSION)))
168
169 $(eval $(call sound_download_rule,core-sounds))
170
171 $(eval $(call sound_download_rule,extra-sounds))
172
173 $(eval $(call sound_download_rule,moh))
174
175 dist-clean:
176         rm -f *.tar.gz
177
178 $(SOUNDS_DIR)/en $(MOH_DIR) $(SOUNDS_DIR)/en_AU $(SOUNDS_DIR)/es $(SOUNDS_DIR)/fr $(SOUNDS_CACHE_DIR):
179         $(INSTALL) -d $@
180
181 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)
182
183 uninstall:
184         rm -rf $(SOUNDS_DIR)
185         rm -rf $(MOH_DIR)
186
187 core_sounds_version:
188         @echo $(CORE_SOUNDS_VERSION)
189
190 extra_sounds_version:
191         @echo $(EXTRA_SOUNDS_VERSION)
192
193 moh_version:
194         @echo $(MOH_VERSION)