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