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