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