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