d12246df6d734a80f1f51520bd9388d1b8b4b9b5
[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.11
21 EXTRA_SOUNDS_VERSION:=1.4.7
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 MOH:=$(MM:MOH-%=asterisk-moh-%.tar.gz)
54 MOH_TAGS:=$(MM:MOH-%=$(MOH_DIR)/.asterisk-moh-%)
55 # If "fetch" is used, --continue is not a valid option.
56 ifeq ($(WGET),wget)
57 WGET_ARGS:=--continue
58 endif
59
60 all: $(CORE_SOUNDS) $(EXTRA_SOUNDS) $(MOH)
61
62 have_download:
63         @if test "$(DOWNLOAD)" = ":" ; then \
64                 echo "**************************************************"; \
65                 echo "***                                            ***"; \
66                 echo "*** You must have either wget or fetch to be   ***"; \
67                 echo "*** able to automatically download and install ***"; \
68                 echo "*** the requested sound packages.              ***"; \
69                 echo "***                                            ***"; \
70                 echo "*** Please install one of these, or remove any ***"; \
71                 echo "*** extra sound package selections in          ***"; \
72                 echo "*** menuselecct before installing Asterisk.    ***"; \
73                 echo "***                                            ***"; \
74                 echo "**************************************************"; \
75                 exit 1; \
76         fi
77
78 $(SOUNDS_DIR)/.asterisk-core-sounds-en-%: have_download
79         @PACKAGE=$(subst $(SOUNDS_DIR)/.asterisk,asterisk,$@).tar.gz; \
80         if test ! -f $${PACKAGE}; then $(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$${PACKAGE}; fi; \
81         if test ! -f $${PACKAGE}; then exit 1; fi; \
82         rm -f $(subst -$(CORE_SOUNDS_VERSION),,$@)-* && \
83         (cd $(SOUNDS_DIR)/en; cat $(CURDIR)/$${PACKAGE} | gzip -d | tar xf -) && \
84         touch $@
85
86 $(SOUNDS_DIR)/.asterisk-core-sounds-es-%: 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)/es; cat $(CURDIR)/$${PACKAGE} | gzip -d | tar xf -) && \
92         touch $@
93
94 $(SOUNDS_DIR)/.asterisk-core-sounds-fr-%: 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)/fr; cat $(CURDIR)/$${PACKAGE} | gzip -d | tar xf -) && \
100         touch $@
101
102 $(SOUNDS_DIR)/.asterisk-extra-sounds-en-%: 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 -$(EXTRA_SOUNDS_VERSION),,$@)-* && \
107         (cd $(SOUNDS_DIR)/en; cat $(CURDIR)/$${PACKAGE} | gzip -d | tar xf -) && \
108         touch $@
109
110 $(SOUNDS_DIR)/.asterisk-extra-sounds-es-%: 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)/es; cat $(CURDIR)/$${PACKAGE} | gzip -d | tar xf -) && \
116         touch $@
117
118 $(SOUNDS_DIR)/.asterisk-extra-sounds-fr-%: 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)/fr; cat $(CURDIR)/$${PACKAGE} | gzip -d | tar xf -) && \
124         touch $@
125
126 $(MOH_DIR)/.asterisk-moh-%: have_download
127         @PACKAGE=$(subst $(MOH_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         (cd $(MOH_DIR); cat $(CURDIR)/$${PACKAGE} | gzip -d | tar xf -) && \
131         touch $@
132
133 asterisk-core-%.tar.gz: have_download
134         @if test ! -f $@ && test ! -f $(SOUNDS_DIR)/.$(subst .tar.gz,,$@) ; then $(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$@;fi
135
136 asterisk-extra-%.tar.gz: have_download
137         @if test ! -f $@ && test ! -f $(SOUNDS_DIR)/.$(subst .tar.gz,,$@) ; then $(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$@;fi
138
139 asterisk-moh-%.tar.gz: have_download
140         @if test ! -f $@ && test ! -f $(MOH_DIR)/.$(subst .tar.gz,,$@) ; then $(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$@;fi
141
142 dist-clean:
143         rm -f *.tar.gz
144
145 $(SOUNDS_DIR)/en $(MOH_DIR) $(SOUNDS_DIR)/es $(SOUNDS_DIR)/fr:
146         mkdir -p $@
147
148 install: $(SOUNDS_DIR)/en $(SOUNDS_DIR)/es $(SOUNDS_DIR)/fr $(MOH_DIR) $(CORE_SOUND_TAGS) $(EXTRA_SOUND_TAGS) $(MOH_TAGS)
149
150 uninstall:
151         rm -rf $(SOUNDS_DIR)
152         rm -rf $(MOH_DIR)
153
154 core_sounds_version:
155         @echo $(CORE_SOUNDS_VERSION)
156
157 extra_sounds_version:
158         @echo $(EXTRA_SOUNDS_VERSION)