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