aboutsummaryrefslogtreecommitdiffstats
path: root/sounds/Makefile
blob: 9826d9fb8eae1729e11777834c9a159118ee94f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
#
# Asterisk -- A telephony toolkit for Linux.
# 
# Makefile for sound files
#
# Copyright (C) 2006, Digium, Inc.
#
# Kevin P. Fleming <kpfleming@digium.com>
#
# This program is free software, distributed under the terms of
# the GNU General Public License
#

.PHONY: dist-clean all uninstall have_download install

-include $(ASTTOPDIR)/menuselect.makeopts $(ASTTOPDIR)/makeopts

CMD_PREFIX?=@
SOUNDS_DIR:=$(DESTDIR)$(ASTDATADIR)/sounds
SOUNDS_CACHE_DIR?=
MOH_DIR:=$(DESTDIR)$(ASTDATADIR)/moh
CORE_SOUNDS_VERSION:=1.4.21
EXTRA_SOUNDS_VERSION:=1.4.11
MOH_VERSION:=2.03
SOUNDS_URL:=http://downloads.asterisk.org/pub/telephony/sounds/releases
MCS:=$(subst -EN-,-en-,$(MENUSELECT_CORE_SOUNDS))
MCS:=$(subst -EN_AU-,-en_AU-,$(MCS))
MCS:=$(subst -FR-,-fr-,$(MCS))
MCS:=$(subst -ES-,-es-,$(MCS))
MCS:=$(subst -RU-,-ru-,$(MCS))
MCS:=$(subst -WAV,-wav,$(MCS))
MCS:=$(subst -ULAW,-ulaw,$(MCS))
MCS:=$(subst -ALAW,-alaw,$(MCS))
MCS:=$(subst -GSM,-gsm,$(MCS))
MCS:=$(subst -G729,-g729,$(MCS))
MCS:=$(subst -G722,-g722,$(MCS))
MCS:=$(subst -SLN16,-sln16,$(MCS))
MCS:=$(subst -SIREN7,-siren7,$(MCS))
MCS:=$(subst -SIREN14,-siren14,$(MCS))
CORE_SOUNDS:=$(MCS:CORE-SOUNDS-%=asterisk-core-sounds-%-$(CORE_SOUNDS_VERSION).tar.gz)
CORE_SOUND_TAGS:=$(MCS:CORE-SOUNDS-%=$(SOUNDS_DIR)/.asterisk-core-sounds-%-$(CORE_SOUNDS_VERSION))
MES:=$(subst -EN-,-en-,$(MENUSELECT_EXTRA_SOUNDS))
MES:=$(subst -FR-,-fr-,$(MES))
MES:=$(subst -ES-,-es-,$(MES))
MES:=$(subst -WAV,-wav,$(MES))
MES:=$(subst -ULAW,-ulaw,$(MES))
MES:=$(subst -ALAW,-alaw,$(MES))
MES:=$(subst -GSM,-gsm,$(MES))
MES:=$(subst -G729,-g729,$(MES))
MES:=$(subst -G722,-g722,$(MES))
MES:=$(subst -SLN16,-sln16,$(MES))
MES:=$(subst -SIREN7,-siren7,$(MES))
MES:=$(subst -SIREN14,-siren14,$(MES))
EXTRA_SOUNDS:=$(MES:EXTRA-SOUNDS-%=asterisk-extra-sounds-%-$(EXTRA_SOUNDS_VERSION).tar.gz)
EXTRA_SOUND_TAGS:=$(MES:EXTRA-SOUNDS-%=$(SOUNDS_DIR)/.asterisk-extra-sounds-%-$(EXTRA_SOUNDS_VERSION))
MM:=$(subst -OPSOUND-,-opsound-,$(MENUSELECT_MOH))
MM:=$(subst -WAV,-wav,$(MM))
MM:=$(subst -ULAW,-ulaw,$(MM))
MM:=$(subst -ALAW,-alaw,$(MM))
MM:=$(subst -GSM,-gsm,$(MM))
MM:=$(subst -G729,-g729,$(MM))
MM:=$(subst -G722,-g722,$(MM))
MM:=$(subst -SLN16,-sln16,$(MM))
MM:=$(subst -SIREN7,-siren7,$(MM))
MM:=$(subst -SIREN14,-siren14,$(MM))
MOH:=$(MM:MOH-%=asterisk-moh-%-$(MOH_VERSION).tar.gz)
MOH_TAGS:=$(MM:MOH-%=$(MOH_DIR)/.asterisk-moh-%-$(MOH_VERSION))
# If "fetch" is used, --continue is not a valid option.
ifneq ($(findstring wget,$(DOWNLOAD)),)
DOWNLOAD+=--continue $(WGET_EXTRA_ARGS)
endif

ifneq ($(SOUNDS_CACHE_DIR),)

define sound_format_lang_rule
$(1)/.asterisk-$(2)$(if $(3),-$(3),)-%: have_download
	$(CMD_PREFIX)PACKAGE=$$(subst $(1)/.asterisk,asterisk,$$@).tar.gz; \
	if test ! -f $$(SOUNDS_CACHE_DIR)/$$$${PACKAGE}; then \
	  (cd $$(SOUNDS_CACHE_DIR); $$(DOWNLOAD) $$(SOUNDS_URL)/$$$${PACKAGE}); \
	fi; \
	if test ! -f $$(SOUNDS_CACHE_DIR)/$$$${PACKAGE}.sha1; then \
	  (cd $$(SOUNDS_CACHE_DIR); $$(DOWNLOAD) $$(SOUNDS_URL)/$$$${PACKAGE}.sha1); \
	fi; \
	$(LN) -sf $$(SOUNDS_CACHE_DIR)/$$$${PACKAGE} .; \
	$(LN) -sf $$(SOUNDS_CACHE_DIR)/$$$${PACKAGE}.sha1 .; \
	$$(SHA1SUM) -c --status $$$${PACKAGE}.sha1 || \
	  ( \
	    rm -f $$(SOUNDS_CACHE_DIR)/$$$${PACKAGE} $$(SOUNDS_CACHE_DIR)/$$$${PACKAGE}.sha1 $$$${PACKAGE} $$$${PACKAGE}.sha1; \
	    echo "Bad checksum: $$$${PACKAGE}" 1>&2; \
	    exit 1; \
	  ) || exit 1; \
	rm -f $$(subst -$(4),,$$@)-*; \
	(cd $(1)$(if $(3),/$(3),); cat $$(CURDIR)/$$$${PACKAGE} | gzip -d | tar xof -) && touch $$@
endef

define sound_download_rule
asterisk-$(1)-%.tar.gz: have_download
	$(CMD_PREFIX) \
	if test ! -f $$(SOUNDS_CACHE_DIR)/$$@; then \
	  (cd $$(SOUNDS_CACHE_DIR); $$(DOWNLOAD) $$(SOUNDS_URL)/$$@); \
	fi; \
	if test ! -f $$(SOUNDS_CACHE_DIR)/$$@.sha1; then \
	  (cd $$(SOUNDS_CACHE_DIR); $$(DOWNLOAD) $$(SOUNDS_URL)/$$@.sha1); \
	fi; \
	$(LN) -sf $$(SOUNDS_CACHE_DIR)/$$@ .; \
	$(LN) -sf $$(SOUNDS_CACHE_DIR)/$$@.sha1 .; \
	$$(SHA1SUM) -c --status $$@.sha1 || \
	  ( \
	    rm -f $$(SOUNDS_CACHE_DIR)/$$@ $$(SOUNDS_CACHE_DIR)/$$@.sha1 $$@ $$@.sha1; \
	    echo "Bad checksum: $$@" 1>&2; \
	    exit 1; \
	  ) || exit 1
endef

else

define sound_format_lang_rule
$(1)/.asterisk-$(2)$(if $(3),-$(3),)-%: have_download
	$(CMD_PREFIX)PACKAGE=$$(subst $(1)/.asterisk,asterisk,$$@).tar.gz; \
	if test ! -f $$$${PACKAGE}; then \
	  $$(DOWNLOAD) $$(SOUNDS_URL)/$$$${PACKAGE} || exit 1; \
	fi; \
	rm -f $$(subst -$(4),,$$@)-*; \
	(cd $(1)$(if $(3),/$(3),); cat $$(CURDIR)/$$$${PACKAGE} | gzip -d | tar xof -) && touch $$@
endef

define sound_download_rule
asterisk-$(1)-%.tar.gz: have_download
	$(CMD_PREFIX)if test ! -f $$@ && test ! -f $$(SOUNDS_DIR)/.$$(subst .tar.gz,,$$@); then \
	  $$(DOWNLOAD) $$(SOUNDS_URL)/$$@; \
	fi
endef

endif

all: $(SOUNDS_CACHE_DIR) $(CORE_SOUNDS) $(EXTRA_SOUNDS) $(MOH)

have_download:
	@if test "$(DOWNLOAD)" = ":" ; then \
		echo "**************************************************"; \
		echo "***                                            ***"; \
		echo "*** You must have either wget or fetch to be   ***"; \
		echo "*** able to automatically download and install ***"; \
		echo "*** the requested sound packages.              ***"; \
		echo "***                                            ***"; \
		echo "*** Please install one of these, or remove any ***"; \
		echo "*** extra sound package selections in          ***"; \
		echo "*** menuselect before installing Asterisk.     ***"; \
		echo "***                                            ***"; \
		echo "**************************************************"; \
		exit 1; \
	fi

$(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,en,$(CORE_SOUNDS_VERSION)))

$(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,en_AU,$(CORE_SOUNDS_VERSION)))

$(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,es,$(CORE_SOUNDS_VERSION)))

$(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,fr,$(CORE_SOUNDS_VERSION)))

$(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,ru,$(CORE_SOUNDS_VERSION)))

$(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),extra-sounds,en,$(EXTRA_SOUNDS_VERSION)))

$(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),extra-sounds,es,$(EXTRA_SOUNDS_VERSION)))

$(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),extra-sounds,fr,$(EXTRA_SOUNDS_VERSION)))

$(eval $(call sound_format_lang_rule,$(MOH_DIR),moh,,$(MOH_VERSION)))

$(eval $(call sound_download_rule,core-sounds))

$(eval $(call sound_download_rule,extra-sounds))

$(eval $(call sound_download_rule,moh))

dist-clean:
	rm -f *.tar.gz

$(SOUNDS_DIR)/en $(MOH_DIR) $(SOUNDS_DIR)/en_AU $(SOUNDS_DIR)/es $(SOUNDS_DIR)/fr $(SOUNDS_DIR)/ru $(SOUNDS_CACHE_DIR):
	mkdir -p $@

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)

uninstall:
	rm -rf $(SOUNDS_DIR)
	rm -rf $(MOH_DIR)

core_sounds_version:
	@echo $(CORE_SOUNDS_VERSION)

extra_sounds_version:
	@echo $(EXTRA_SOUNDS_VERSION)

moh_version:
	@echo $(MOH_VERSION)