Merged revisions 48190 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 PWD:=$(shell pwd)
19 SOUNDS_DIR:=$(DESTDIR)$(ASTDATADIR)/sounds
20 MOH_DIR:=$(DESTDIR)$(ASTDATADIR)/moh
21 CORE_SOUNDS_VERSION:=1.4.3
22 EXTRA_SOUNDS_VERSION:=1.4.3
23 SOUNDS_URL:=http://ftp.digium.com/pub/telephony/sounds/releases
24 MCS:=$(subst -EN-,-en-,$(MENUSELECT_CORE_SOUNDS))
25 MCS:=$(subst -FR-,-fr-,$(MCS))
26 MCS:=$(subst -ES-,-es-,$(MCS))
27 MCS:=$(subst -WAV,-wav,$(MCS))
28 MCS:=$(subst -ULAW,-ulaw,$(MCS))
29 MCS:=$(subst -ALAW,-alaw,$(MCS))
30 MCS:=$(subst -GSM,-gsm,$(MCS))
31 MCS:=$(subst -G729,-g729,$(MCS))
32 MCS:=$(subst -G722,-g722,$(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 WGET_ARGS:=--continue
56
57 all: $(CORE_SOUNDS) $(EXTRA_SOUNDS) $(MOH)
58
59 have_download:
60         @if test "$(DOWNLOAD)" = ":" ; then \
61                 echo "**************************************************"; \
62                 echo "***                                            ***"; \
63                 echo "*** You must have either wget or fetch to be   ***"; \
64                 echo "*** able to automatically download and install ***"; \
65                 echo "*** the requested sound packages.              ***"; \
66                 echo "***                                            ***"; \
67                 echo "*** Please install one of these, or remove any ***"; \
68                 echo "*** extra sound package selections in          ***"; \
69                 echo "*** menuselecct before installing Asterisk.    ***"; \
70                 echo "***                                            ***"; \
71                 echo "**************************************************"; \
72                 exit 1; \
73         fi
74
75 $(SOUNDS_DIR)/.asterisk-core-sounds-en-%: have_download
76         @PACKAGE=$(subst $(SOUNDS_DIR)/.asterisk,asterisk,$@).tar.gz; \
77         if test ! -f $${PACKAGE}; then $(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$${PACKAGE}; fi; \
78         if test ! -f $${PACKAGE}; then exit 1; fi; \
79         rm -f $(subst -$(CORE_SOUNDS_VERSION),,$@)-* && \
80         (cd $(SOUNDS_DIR); cat $(PWD)/$${PACKAGE} | gzip -d | tar xf -) && \
81         touch $@
82
83 $(SOUNDS_DIR)/.asterisk-core-sounds-es-%: have_download
84         @PACKAGE=$(subst $(SOUNDS_DIR)/.asterisk,asterisk,$@).tar.gz; \
85         if test ! -f $${PACKAGE}; then $(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$${PACKAGE}; fi; \
86         if test ! -f $${PACKAGE}; then exit 1; fi; \
87         rm -f $(subst -$(CORE_SOUNDS_VERSION),,$@)-* && \
88         (cd $(SOUNDS_DIR)/es; cat $(PWD)/$${PACKAGE} | gzip -d | tar xf -) && \
89         touch $@
90
91 $(SOUNDS_DIR)/.asterisk-core-sounds-fr-%: have_download
92         @PACKAGE=$(subst $(SOUNDS_DIR)/.asterisk,asterisk,$@).tar.gz; \
93         if test ! -f $${PACKAGE}; then $(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$${PACKAGE}; fi; \
94         if test ! -f $${PACKAGE}; then exit 1; fi; \
95         rm -f $(subst -$(CORE_SOUNDS_VERSION),,$@)-* && \
96         (cd $(SOUNDS_DIR)/fr; cat $(PWD)/$${PACKAGE} | gzip -d | tar xf -) && \
97         touch $@
98
99 $(SOUNDS_DIR)/.asterisk-extra-sounds-en-%: have_download
100         @PACKAGE=$(subst $(SOUNDS_DIR)/.asterisk,asterisk,$@).tar.gz; \
101         if test ! -f $${PACKAGE}; then $(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$${PACKAGE}; fi; \
102         if test ! -f $${PACKAGE}; then exit 1; fi; \
103         rm -f $(subst -$(EXTRA_SOUNDS_VERSION),,$@)-* && \
104         (cd $(SOUNDS_DIR); cat $(PWD)/$${PACKAGE} | gzip -d | tar xf -) && \
105         touch $@
106
107 $(SOUNDS_DIR)/.asterisk-extra-sounds-es-%: have_download
108         @PACKAGE=$(subst $(SOUNDS_DIR)/.asterisk,asterisk,$@).tar.gz; \
109         if test ! -f $${PACKAGE}; then $(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$${PACKAGE}; fi; \
110         if test ! -f $${PACKAGE}; then exit 1; fi; \
111         rm -f $(subst -$(EXTRA_SOUNDS_VERSION),,$@)-* && \
112         (cd $(SOUNDS_DIR)/es; cat $(PWD)/$${PACKAGE} | gzip -d | tar xf -) && \
113         touch $@
114
115 $(SOUNDS_DIR)/.asterisk-extra-sounds-fr-%: have_download
116         @PACKAGE=$(subst $(SOUNDS_DIR)/.asterisk,asterisk,$@).tar.gz; \
117         if test ! -f $${PACKAGE}; then $(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$${PACKAGE}; fi; \
118         if test ! -f $${PACKAGE}; then exit 1; fi; \
119         rm -f $(subst -$(EXTRA_SOUNDS_VERSION),,$@)-* && \
120         (cd $(SOUNDS_DIR)/fr; cat $(PWD)/$${PACKAGE} | gzip -d | tar xf -) && \
121         touch $@
122
123 $(MOH_DIR)/.asterisk-moh-%: have_download
124         @PACKAGE=$(subst $(MOH_DIR)/.asterisk,asterisk,$@).tar.gz; \
125         if test ! -f $${PACKAGE}; then $(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$${PACKAGE}; fi; \
126         if test ! -f $${PACKAGE}; then exit 1; fi; \
127         (cd $(MOH_DIR); cat $(PWD)/$${PACKAGE} | gzip -d | tar xf -) && \
128         touch $@
129
130 asterisk-core-%.tar.gz: have_download
131         @$(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$@
132
133 asterisk-extra-%.tar.gz: have_download
134         @$(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$@
135
136 asterisk-moh-%.tar.gz: have_download
137         @$(DOWNLOAD) $(WGET_ARGS) $(SOUNDS_URL)/$@
138
139 dist-clean:
140         rm -f *.tar.gz
141
142 $(SOUNDS_DIR) $(MOH_DIR) $(SOUNDS_DIR)/es $(SOUNDS_DIR)/fr:
143         mkdir -p $@
144
145 install: $(SOUNDS_DIR) $(SOUNDS_DIR)/es $(SOUNDS_DIR)/fr $(MOH_DIR) $(CORE_SOUND_TAGS) $(EXTRA_SOUND_TAGS) $(MOH_TAGS)
146
147 uninstall:
148         rm -rf $(SOUNDS_DIR)
149         rm -rf $(MOH_DIR)