Updates for 1.4.25 core sounds and 1.4.14 extra sounds, plus new en_GB language set
[asterisk/asterisk.git] / sounds / Makefile
1 #
2 # Asterisk -- An open source telephony toolkit.
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.25
23 EXTRA_SOUNDS_VERSION:=1.4.14
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 -EN_GB-,-en_GB-,$(MCS))
29 MCS:=$(subst -FR-,-fr-,$(MCS))
30 MCS:=$(subst -ES-,-es-,$(MCS))
31 MCS:=$(subst -RU-,-ru-,$(MCS))
32 MCS:=$(subst -IT-,-it-,$(MCS))
33 MCS:=$(subst -WAV,-wav,$(MCS))
34 MCS:=$(subst -ULAW,-ulaw,$(MCS))
35 MCS:=$(subst -ALAW,-alaw,$(MCS))
36 MCS:=$(subst -GSM,-gsm,$(MCS))
37 MCS:=$(subst -G729,-g729,$(MCS))
38 MCS:=$(subst -G722,-g722,$(MCS))
39 MCS:=$(subst -SLN16,-sln16,$(MCS))
40 MCS:=$(subst -SIREN7,-siren7,$(MCS))
41 MCS:=$(subst -SIREN14,-siren14,$(MCS))
42 CORE_SOUNDS:=$(MCS:CORE-SOUNDS-%=asterisk-core-sounds-%-$(CORE_SOUNDS_VERSION).tar.gz)
43 CORE_SOUND_TAGS:=$(MCS:CORE-SOUNDS-%=.asterisk-core-sounds-%-$(CORE_SOUNDS_VERSION))
44 MES:=$(subst -EN-,-en-,$(MENUSELECT_EXTRA_SOUNDS))
45 MES:=$(subst -FR-,-fr-,$(MES))
46 MES:=$(subst -ES-,-es-,$(MES))
47 MES:=$(subst -WAV,-wav,$(MES))
48 MES:=$(subst -ULAW,-ulaw,$(MES))
49 MES:=$(subst -ALAW,-alaw,$(MES))
50 MES:=$(subst -GSM,-gsm,$(MES))
51 MES:=$(subst -G729,-g729,$(MES))
52 MES:=$(subst -G722,-g722,$(MES))
53 MES:=$(subst -SLN16,-sln16,$(MES))
54 MES:=$(subst -SIREN7,-siren7,$(MES))
55 MES:=$(subst -SIREN14,-siren14,$(MES))
56 EXTRA_SOUNDS:=$(MES:EXTRA-SOUNDS-%=asterisk-extra-sounds-%-$(EXTRA_SOUNDS_VERSION).tar.gz)
57 EXTRA_SOUND_TAGS:=$(MES:EXTRA-SOUNDS-%=.asterisk-extra-sounds-%-$(EXTRA_SOUNDS_VERSION))
58 MM:=$(subst -OPSOUND-,-opsound-,$(MENUSELECT_MOH))
59 MM:=$(subst -WAV,-wav,$(MM))
60 MM:=$(subst -ULAW,-ulaw,$(MM))
61 MM:=$(subst -ALAW,-alaw,$(MM))
62 MM:=$(subst -GSM,-gsm,$(MM))
63 MM:=$(subst -G729,-g729,$(MM))
64 MM:=$(subst -G722,-g722,$(MM))
65 MM:=$(subst -SLN16,-sln16,$(MM))
66 MM:=$(subst -SIREN7,-siren7,$(MM))
67 MM:=$(subst -SIREN14,-siren14,$(MM))
68 MOH:=$(MM:MOH-%=asterisk-moh-%-$(MOH_VERSION).tar.gz)
69 MOH_TAGS:=$(MM:MOH-%=.asterisk-moh-%-$(MOH_VERSION))
70 # If "fetch" is used, --continue is not a valid option.
71 ifneq ($(findstring wget,$(DOWNLOAD)),)
72 DOWNLOAD+=--continue $(WGET_EXTRA_ARGS)
73 endif
74
75
76 define sound_format_lang_rule
77 .PHONY: .asterisk-$(2)$(if $(3),-$(3),)-%
78
79 .asterisk-$(2)$(if $(3),-$(3),)-%: asterisk-$(2)$(if $(3),-$(3),)-%.tar.gz
80         $(CMD_PREFIX) \
81         if test ! -f "$(1)$(if $(3),/$(3),)/$$@"; then \
82           PACKAGE=$$(subst .asterisk,asterisk,$$@).tar.gz; \
83           ( \
84             mkdir -p "$(1)$(if $(3),/$(3),)"; \
85             cd "$(1)$(if $(3),/$(3),)"; \
86             rm -f $$(subst -$(4),,$$@)-*; \
87             cat $$(CURDIR)/$$$${PACKAGE} | gzip -d | tar xof - \
88           ) && touch "$(1)$(if $(3),/$(3),)/$$@"; \
89         fi
90
91 asterisk-$(2)$(if $(3),-$(3),)-%.tar.gz: have_download
92 ifneq ($(SOUNDS_CACHE_DIR),)
93         $(CMD_PREFIX) \
94         if test ! -f "$(1)$(if $(3),/$(3),)/.$$(subst .tar.gz,,$$@)"; then \
95           if test ! -d "$$(SOUNDS_CACHE_DIR)/"; then \
96             mkdir -p "$$(SOUNDS_CACHE_DIR)/"; \
97           fi; \
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         fi
113 else
114         $(CMD_PREFIX) \
115         if test ! -f $$@ && test ! -f "$(1)$(if $(3),/$(3),)/.$$(subst .tar.gz,,$$@)"; then \
116           $$(DOWNLOAD) $$(SOUNDS_URL)/$$@; \
117         fi
118 endif
119 endef # sound_format_lang_rule
120
121 all: $(CORE_SOUNDS) $(EXTRA_SOUNDS) $(MOH)
122
123 have_download:
124         @if test "$(DOWNLOAD)" = ":" ; then \
125                 echo "**************************************************"; \
126                 echo "***                                            ***"; \
127                 echo "*** You must have either wget or fetch to be   ***"; \
128                 echo "*** able to automatically download and install ***"; \
129                 echo "*** the requested sound packages.              ***"; \
130                 echo "***                                            ***"; \
131                 echo "*** Please install one of these, or remove any ***"; \
132                 echo "*** extra sound package selections in          ***"; \
133                 echo "*** menuselect before installing Asterisk.     ***"; \
134                 echo "***                                            ***"; \
135                 echo "**************************************************"; \
136                 exit 1; \
137         fi
138
139 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,en,$(CORE_SOUNDS_VERSION)))
140
141 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,en_AU,$(CORE_SOUNDS_VERSION)))
142
143 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,en_GB,$(CORE_SOUNDS_VERSION)))
144
145 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,es,$(CORE_SOUNDS_VERSION)))
146
147 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,fr,$(CORE_SOUNDS_VERSION)))
148
149 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,it,$(CORE_SOUNDS_VERSION)))
150
151 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,ru,$(CORE_SOUNDS_VERSION)))
152
153 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),extra-sounds,en,$(EXTRA_SOUNDS_VERSION)))
154
155 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),extra-sounds,es,$(EXTRA_SOUNDS_VERSION)))
156
157 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),extra-sounds,fr,$(EXTRA_SOUNDS_VERSION)))
158
159 $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),extra-sounds,en_GB,$(EXTRA_SOUNDS_VERSION)))
160
161 $(eval $(call sound_format_lang_rule,$(MOH_DIR),moh,,$(MOH_VERSION)))
162
163 dist-clean:
164         rm -f *.tar.gz
165
166 install: $(CORE_SOUND_TAGS) $(EXTRA_SOUND_TAGS) $(MOH_TAGS)
167
168 uninstall:
169         rm -rf "$(SOUNDS_DIR)"
170         rm -rf "$(MOH_DIR)"
171
172 core_sounds_version:
173         @echo $(CORE_SOUNDS_VERSION)
174
175 extra_sounds_version:
176         @echo $(EXTRA_SOUNDS_VERSION)
177
178 moh_version:
179         @echo $(MOH_VERSION)