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