532e06aaf76a9b98b584851d3fc78a193cc5934c
[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.19
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 -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)
69 endif
70
71 ifneq ($(SOUNDS_CACHE_DIR),)
72
73 define sound_format_lang_rule
74 $$($(1))/.asterisk-$(2)$(if $(3),-$(3),)-%: have_download
75         $(CMD_PREFIX)PACKAGE=$$(subst $$($(1))/.asterisk,asterisk,$$@).tar.gz; \
76         if test ! -f $$$${PACKAGE}; then \
77           if test ! -f $$(SOUNDS_CACHE_DIR)/$$$${PACKAGE}; then \
78             (cd $$(SOUNDS_CACHE_DIR); \
79               ( \
80                 $$(DOWNLOAD) $$(SOUNDS_URL)/$$$${PACKAGE} && \
81                 $$(DOWNLOAD) $$(SOUNDS_URL)/$$$${PACKAGE}.sha1 && \
82                 $$(SHA1SUM) -c --status $$$${PACKAGE}.sha1 \
83               ) || \
84               (echo "Bad checksum: $$$${PACKAGE}" 1>&2; exit 1) \
85             ); \
86           fi; \
87           $(LN) -sf $$(SOUNDS_CACHE_DIR)/$$$${PACKAGE} .; \
88         fi; \
89         $(if $($(4)_VERSION),rm -f $$(subst -$$($(4)_VERSION),,$$@)-*,); \
90         (cd $$($(1))$(if $(3),/$(3),); cat $$(CURDIR)/$$$${PACKAGE} | gzip -d | tar xof -) && touch $$@
91 endef
92
93 define sound_download_rule
94 asterisk-$(1)-%.tar.gz: have_download
95         $(CMD_PREFIX)if test ! -f $$@ && test ! -f $$(SOUNDS_DIR)/.$$(subst .tar.gz,,$/$@); then \
96           if test ! -f $$(SOUNDS_CACHE_DIR)/$$@; then \
97             (cd $$(SOUNDS_CACHE_DIR); \
98               ( \
99                 $$(DOWNLOAD) $$(SOUNDS_URL)/$$@ && \
100                 $$(DOWNLOAD) $$(SOUNDS_URL)/$$@.sha1 && \
101                 $$(SHA1SUM) -c --status $$@.sha1 \
102               ) || \
103               (echo "Bad checksum: $$@" 1>&2; exit 1) \
104             ); \
105           fi; \
106           $(LN) -sf $$(SOUNDS_CACHE_DIR)/$$@ .; \
107         fi
108 endef
109
110 else
111
112 define sound_format_lang_rule
113 $$($(1))/.asterisk-$(2)$(if $(3),-$(3),)-%: have_download
114         $(CMD_PREFIX)PACKAGE=$$(subst $$($(1))/.asterisk,asterisk,$$@).tar.gz; \
115         if test ! -f $$$${PACKAGE}; then \
116           ($$(DOWNLOAD) $$(SOUNDS_URL)/$$$${PACKAGE} || exit 1); \
117         fi; \
118         $(if $($(4)_VERSION),rm -f $$(subst -$$($(4)_VERSION),,$$@)-*,); \
119         (cd $$($(1))$(if $(3),/$(3),); cat $$(CURDIR)/$$$${PACKAGE} | gzip -d | tar xof -) && touch $$@
120 endef
121
122 define sound_download_rule
123 asterisk-$(1)-%.tar.gz: have_download
124         $(CMD_PREFIX)if test ! -f $$@ && test ! -f $$(SOUNDS_DIR)/.$$(subst .tar.gz,,$$@); then \
125           $$(DOWNLOAD) $$(SOUNDS_URL)/$$@; \
126         fi
127 endef
128
129 endif
130
131 all: $(SOUNDS_CACHE_DIR) $(CORE_SOUNDS) $(EXTRA_SOUNDS) $(MOH)
132
133 have_download:
134         @if test "$(DOWNLOAD)" = ":" ; then \
135                 echo "**************************************************"; \
136                 echo "***                                            ***"; \
137                 echo "*** You must have either wget or fetch to be   ***"; \
138                 echo "*** able to automatically download and install ***"; \
139                 echo "*** the requested sound packages.              ***"; \
140                 echo "***                                            ***"; \
141                 echo "*** Please install one of these, or remove any ***"; \
142                 echo "*** extra sound package selections in          ***"; \
143                 echo "*** menuselecct before installing Asterisk.    ***"; \
144                 echo "***                                            ***"; \
145                 echo "**************************************************"; \
146                 exit 1; \
147         fi
148
149 $(eval $(call sound_format_lang_rule,SOUNDS_DIR,core-sounds,en,CORE_SOUNDS))
150
151 $(eval $(call sound_format_lang_rule,SOUNDS_DIR,core-sounds,es,CORE_SOUNDS))
152
153 $(eval $(call sound_format_lang_rule,SOUNDS_DIR,core-sounds,fr,CORE_SOUNDS))
154
155 $(eval $(call sound_format_lang_rule,SOUNDS_DIR,extra-sounds,en,EXTRA_SOUNDS))
156
157 $(eval $(call sound_format_lang_rule,SOUNDS_DIR,extra-sounds,es,EXTRA_SOUNDS))
158
159 $(eval $(call sound_format_lang_rule,SOUNDS_DIR,extra-sounds,fr,EXTRA_SOUNDS))
160
161 $(eval $(call sound_format_lang_rule,MOH_DIR,moh,,MOH))
162
163 $(eval $(call sound_download_rule,core))
164
165 $(eval $(call sound_download_rule,extra))
166
167 $(eval $(call sound_download_rule,moh))
168
169 dist-clean:
170         rm -f *.tar.gz
171
172 $(SOUNDS_DIR)/en $(MOH_DIR) $(SOUNDS_DIR)/es $(SOUNDS_DIR)/fr $(SOUNDS_CACHE_DIR):
173         $(INSTALL) -d $@
174
175 install: ${SOUNDS_CACHE_DIR} $(SOUNDS_DIR)/en $(SOUNDS_DIR)/es $(SOUNDS_DIR)/fr $(MOH_DIR) $(CORE_SOUND_TAGS) $(EXTRA_SOUND_TAGS) $(MOH_TAGS)
176
177 uninstall:
178         rm -rf $(SOUNDS_DIR)
179         rm -rf $(MOH_DIR)
180
181 core_sounds_version:
182         @echo $(CORE_SOUNDS_VERSION)
183
184 extra_sounds_version:
185         @echo $(EXTRA_SOUNDS_VERSION)
186
187 moh_version:
188         @echo $(MOH_VERSION)