c0e39cb5f886a01b60cc39eb476d26dd2d540daf
[asterisk/asterisk.git] / sounds / Makefile
1 #
2 # Asterisk -- A telephony toolkit for Linux.
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 SOUNDS_DIR:=$(DESTDIR)$(ASTDATADIR)/sounds
19 MOH_DIR:=$(DESTDIR)$(ASTDATADIR)/moh
20 CORE_SOUNDS_VERSION:=1.4.15
21 EXTRA_SOUNDS_VERSION:=1.4.9
22 SOUNDS_URL:=http://downloads.asterisk.org/pub/telephony/sounds/releases
23 MCS:=$(subst -EN-,-en-,$(MENUSELECT_CORE_SOUNDS))
24 MCS:=$(subst -FR-,-fr-,$(MCS))
25 MCS:=$(subst -ES-,-es-,$(MCS))
26 MCS:=$(subst -WAV,-wav,$(MCS))
27 MCS:=$(subst -ULAW,-ulaw,$(MCS))
28 MCS:=$(subst -ALAW,-alaw,$(MCS))
29 MCS:=$(subst -GSM,-gsm,$(MCS))
30 MCS:=$(subst -G729,-g729,$(MCS))
31 MCS:=$(subst -G722,-g722,$(MCS))
32 MCS:=$(subst -SLN16,-sln16,$(MCS))
33 MCS:=$(subst -SIREN7,-siren7,$(MCS))
34 MCS:=$(subst -SIREN14,-siren14,$(MCS))
35 CORE_SOUNDS:=$(MCS:CORE-SOUNDS-%=asterisk-core-sounds-%-$(CORE_SOUNDS_VERSION).tar.gz)
36 CORE_SOUND_TAGS:=$(MCS:CORE-SOUNDS-%=$(SOUNDS_DIR)/.asterisk-core-sounds-%-$(CORE_SOUNDS_VERSION))
37 MES:=$(subst -EN-,-en-,$(MENUSELECT_EXTRA_SOUNDS))
38 MES:=$(subst -FR-,-fr-,$(MES))
39 MES:=$(subst -ES-,-es-,$(MES))
40 MES:=$(subst -WAV,-wav,$(MES))
41 MES:=$(subst -ULAW,-ulaw,$(MES))
42 MES:=$(subst -ALAW,-alaw,$(MES))
43 MES:=$(subst -GSM,-gsm,$(MES))
44 MES:=$(subst -G729,-g729,$(MES))
45 MES:=$(subst -G722,-g722,$(MES))
46 MES:=$(subst -SLN16,-sln16,$(MES))
47 MES:=$(subst -SIREN7,-siren7,$(MES))
48 MES:=$(subst -SIREN14,-siren14,$(MES))
49 EXTRA_SOUNDS:=$(MES:EXTRA-SOUNDS-%=asterisk-extra-sounds-%-$(EXTRA_SOUNDS_VERSION).tar.gz)
50 EXTRA_SOUND_TAGS:=$(MES:EXTRA-SOUNDS-%=$(SOUNDS_DIR)/.asterisk-extra-sounds-%-$(EXTRA_SOUNDS_VERSION))
51 MM:=$(subst -OPSOUND-,-opsound-,$(MENUSELECT_MOH))
52 MM:=$(subst -WAV,-wav,$(MM))
53 MM:=$(subst -ULAW,-ulaw,$(MM))
54 MM:=$(subst -ALAW,-alaw,$(MM))
55 MM:=$(subst -GSM,-gsm,$(MM))
56 MM:=$(subst -G729,-g729,$(MM))
57 MM:=$(subst -G722,-g722,$(MM))
58 MM:=$(subst -SLN16,-sln16,$(MM))
59 MM:=$(subst -SIREN7,-siren7,$(MM))
60 MM:=$(subst -SIREN14,-siren14,$(MM))
61 MOH:=$(MM:MOH-%=asterisk-moh-%.tar.gz)
62 MOH_TAGS:=$(MM:MOH-%=$(MOH_DIR)/.asterisk-moh-%)
63 # If "fetch" is used, --continue is not a valid option.
64 ifeq ($(WGET),wget)
65 WGET_ARGS:=--continue
66 endif
67
68 all: $(CORE_SOUNDS) $(EXTRA_SOUNDS) $(MOH)
69
70 have_download:
71         @if test "$(DOWNLOAD)" = ":" ; then \
72                 echo "**************************************************"; \
73                 echo "***                                            ***"; \
74                 echo "*** You must have either wget or fetch to be   ***"; \
75                 echo "*** able to automatically download and install ***"; \
76                 echo "*** the requested sound packages.              ***"; \
77                 echo "***                                            ***"; \
78                 echo "*** Please install one of these, or remove any ***"; \
79                 echo "*** extra sound package selections in          ***"; \
80                 echo "*** menuselecct before installing Asterisk.    ***"; \
81                 echo "***                                            ***"; \
82                 echo "**************************************************"; \
83                 exit 1; \
84         fi
85
86 $(SOUNDS_DIR)/.asterisk-core-sounds-en-%: have_download
87         @PACKAGE=$(subst $(SOUNDS_DIR)/.asterisk,asterisk,$@).tar.gz; \
88         if test ! -f $${PACKAGE}; then $(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$${PACKAGE}; fi; \
89         if test ! -f $${PACKAGE}; then exit 1; fi; \
90         rm -f $(subst -$(CORE_SOUNDS_VERSION),,$@)-* && \
91         (cd $(SOUNDS_DIR)/en; cat $(CURDIR)/$${PACKAGE} | gzip -d | tar xof -) && \
92         touch $@
93
94 $(SOUNDS_DIR)/.asterisk-core-sounds-es-%: have_download
95         @PACKAGE=$(subst $(SOUNDS_DIR)/.asterisk,asterisk,$@).tar.gz; \
96         if test ! -f $${PACKAGE}; then $(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$${PACKAGE}; fi; \
97         if test ! -f $${PACKAGE}; then exit 1; fi; \
98         rm -f $(subst -$(CORE_SOUNDS_VERSION),,$@)-* && \
99         (cd $(SOUNDS_DIR)/es; cat $(CURDIR)/$${PACKAGE} | gzip -d | tar xof -) && \
100         touch $@
101
102 $(SOUNDS_DIR)/.asterisk-core-sounds-fr-%: have_download
103         @PACKAGE=$(subst $(SOUNDS_DIR)/.asterisk,asterisk,$@).tar.gz; \
104         if test ! -f $${PACKAGE}; then $(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$${PACKAGE}; fi; \
105         if test ! -f $${PACKAGE}; then exit 1; fi; \
106         rm -f $(subst -$(CORE_SOUNDS_VERSION),,$@)-* && \
107         (cd $(SOUNDS_DIR)/fr; cat $(CURDIR)/$${PACKAGE} | gzip -d | tar xof -) && \
108         touch $@
109
110 $(SOUNDS_DIR)/.asterisk-extra-sounds-en-%: have_download
111         @PACKAGE=$(subst $(SOUNDS_DIR)/.asterisk,asterisk,$@).tar.gz; \
112         if test ! -f $${PACKAGE}; then $(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$${PACKAGE}; fi; \
113         if test ! -f $${PACKAGE}; then exit 1; fi; \
114         rm -f $(subst -$(EXTRA_SOUNDS_VERSION),,$@)-* && \
115         (cd $(SOUNDS_DIR)/en; cat $(CURDIR)/$${PACKAGE} | gzip -d | tar xof -) && \
116         touch $@
117
118 $(SOUNDS_DIR)/.asterisk-extra-sounds-es-%: have_download
119         @PACKAGE=$(subst $(SOUNDS_DIR)/.asterisk,asterisk,$@).tar.gz; \
120         if test ! -f $${PACKAGE}; then $(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$${PACKAGE}; fi; \
121         if test ! -f $${PACKAGE}; then exit 1; fi; \
122         rm -f $(subst -$(EXTRA_SOUNDS_VERSION),,$@)-* && \
123         (cd $(SOUNDS_DIR)/es; cat $(CURDIR)/$${PACKAGE} | gzip -d | tar xof -) && \
124         touch $@
125
126 $(SOUNDS_DIR)/.asterisk-extra-sounds-fr-%: have_download
127         @PACKAGE=$(subst $(SOUNDS_DIR)/.asterisk,asterisk,$@).tar.gz; \
128         if test ! -f $${PACKAGE}; then $(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$${PACKAGE}; fi; \
129         if test ! -f $${PACKAGE}; then exit 1; fi; \
130         rm -f $(subst -$(EXTRA_SOUNDS_VERSION),,$@)-* && \
131         (cd $(SOUNDS_DIR)/fr; cat $(CURDIR)/$${PACKAGE} | gzip -d | tar xof -) && \
132         touch $@
133
134 $(MOH_DIR)/.asterisk-moh-%: have_download
135         @PACKAGE=$(subst $(MOH_DIR)/.asterisk,asterisk,$@).tar.gz; \
136         if test ! -f $${PACKAGE}; then $(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$${PACKAGE}; fi; \
137         if test ! -f $${PACKAGE}; then exit 1; fi; \
138         (cd $(MOH_DIR); cat $(CURDIR)/$${PACKAGE} | gzip -d | tar xof -) && \
139         touch $@
140
141 asterisk-core-%.tar.gz: have_download
142         @if test ! -f $@ && test ! -f $(SOUNDS_DIR)/.$(subst .tar.gz,,$@) ; then $(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$@;fi
143
144 asterisk-extra-%.tar.gz: have_download
145         @if test ! -f $@ && test ! -f $(SOUNDS_DIR)/.$(subst .tar.gz,,$@) ; then $(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$@;fi
146
147 asterisk-moh-%.tar.gz: have_download
148         @if test ! -f $@ && test ! -f $(MOH_DIR)/.$(subst .tar.gz,,$@) ; then $(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$@;fi
149
150 dist-clean:
151         rm -f *.tar.gz
152
153 $(SOUNDS_DIR)/en $(MOH_DIR) $(SOUNDS_DIR)/es $(SOUNDS_DIR)/fr:
154         mkdir -p $@
155
156 install: $(SOUNDS_DIR)/en $(SOUNDS_DIR)/es $(SOUNDS_DIR)/fr $(MOH_DIR) $(CORE_SOUND_TAGS) $(EXTRA_SOUND_TAGS) $(MOH_TAGS)
157
158 uninstall:
159         rm -rf $(SOUNDS_DIR)
160         rm -rf $(MOH_DIR)
161
162 core_sounds_version:
163         @echo $(CORE_SOUNDS_VERSION)
164
165 extra_sounds_version:
166         @echo $(EXTRA_SOUNDS_VERSION)