eb638b6638ba4a95c582a96c8a8789786a4dc641
[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 EMPTY:=
72 BS:=$(EMPTY)\$(EMPTY)
73
74 ifneq ($(SOUNDS_CACHE_DIR),)
75
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)
85           fi; $(BS)
86           cp -p $$(SOUNDS_CACHE_DIR)/$$$${PACKAGE} .; $(BS)
87         fi; $(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)
91         touch $$@
92 endef
93
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)
102           fi; $(BS)
103           cp -p $$(SOUNDS_CACHE_DIR)/$$@ .; $(BS)
104         fi
105 endef
106
107 else
108
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)
114         fi; $(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)
118         touch $$@
119 endef
120
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)
125         fi
126 endef
127
128 endif
129
130 all: $(SOUNDS_CACHE_DIR) $(CORE_SOUNDS) $(EXTRA_SOUNDS) $(MOH)
131
132 have_download:
133         @if test "$(DOWNLOAD)" = ":" ; then \
134                 echo "**************************************************"; \
135                 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.              ***"; \
139                 echo "***                                            ***"; \
140                 echo "*** Please install one of these, or remove any ***"; \
141                 echo "*** extra sound package selections in          ***"; \
142                 echo "*** menuselecct before installing Asterisk.    ***"; \
143                 echo "***                                            ***"; \
144                 echo "**************************************************"; \
145                 exit 1; \
146         fi
147
148 $(eval $(call sound_format_lang_rule,SOUNDS_DIR,core-sounds,en,CORE_SOUNDS))
149
150 $(eval $(call sound_format_lang_rule,SOUNDS_DIR,core-sounds,es,CORE_SOUNDS))
151
152 $(eval $(call sound_format_lang_rule,SOUNDS_DIR,core-sounds,fr,CORE_SOUNDS))
153
154 $(eval $(call sound_format_lang_rule,SOUNDS_DIR,extra-sounds,en,EXTRA_SOUNDS))
155
156 $(eval $(call sound_format_lang_rule,SOUNDS_DIR,extra-sounds,es,EXTRA_SOUNDS))
157
158 $(eval $(call sound_format_lang_rule,SOUNDS_DIR,extra-sounds,fr,EXTRA_SOUNDS))
159
160 $(eval $(call sound_format_lang_rule,MOH_DIR,moh,,MOH))
161
162 $(eval $(call sound_download_rule,core))
163
164 $(eval $(call sound_download_rule,extra))
165
166 $(eval $(call sound_download_rule,moh))
167
168 dist-clean:
169         rm -f *.tar.gz
170
171 $(SOUNDS_DIR)/en $(MOH_DIR) $(SOUNDS_DIR)/es $(SOUNDS_DIR)/fr $(SOUNDS_CACHE_DIR):
172         mkdir -p $@
173
174 install: ${SOUNDS_CACHE_DIR} $(SOUNDS_DIR)/en $(SOUNDS_DIR)/es $(SOUNDS_DIR)/fr $(MOH_DIR) $(CORE_SOUND_TAGS) $(EXTRA_SOUND_TAGS) $(MOH_TAGS)
175
176 uninstall:
177         rm -rf $(SOUNDS_DIR)
178         rm -rf $(MOH_DIR)
179
180 core_sounds_version:
181         @echo $(CORE_SOUNDS_VERSION)
182
183 extra_sounds_version:
184         @echo $(EXTRA_SOUNDS_VERSION)
185
186 moh_version:
187         @echo $(MOH_VERSION)