Makefile 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. #
  2. # Asterisk -- An open source telephony toolkit.
  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. .PHONY: dist-clean all uninstall have_download install
  14. -include $(ASTTOPDIR)/menuselect.makeopts $(ASTTOPDIR)/makeopts
  15. CMD_PREFIX?=@
  16. SOUNDS_DIR:=$(DESTDIR)$(ASTDATADIR)/sounds
  17. SOUNDS_CACHE_DIR?=
  18. MOH_DIR:=$(DESTDIR)$(ASTDATADIR)/moh
  19. CORE_SOUNDS_VERSION:=1.6.1
  20. EXTRA_SOUNDS_VERSION:=1.5.2
  21. MOH_VERSION:=2.03
  22. SOUNDS_URL:=http://downloads.asterisk.org/pub/telephony/sounds/releases
  23. MCS:=$(subst -EN-,-en-,$(MENUSELECT_CORE_SOUNDS))
  24. MCS:=$(subst -EN_AU-,-en_AU-,$(MCS))
  25. MCS:=$(subst -EN_GB-,-en_GB-,$(MCS))
  26. MCS:=$(subst -EN_NZ-,-en_NZ-,$(MCS))
  27. MCS:=$(subst -FR-,-fr-,$(MCS))
  28. MCS:=$(subst -ES-,-es-,$(MCS))
  29. MCS:=$(subst -RU-,-ru-,$(MCS))
  30. MCS:=$(subst -IT-,-it-,$(MCS))
  31. MCS:=$(subst -JA-,-ja-,$(MCS))
  32. MCS:=$(subst -SV-,-sv-,$(MCS))
  33. MCS:=$(subst -WAV,-wav,$(MCS))
  34. MCS:=$(subst -ULAW,-ulaw,$(MCS))
  35. MCS:=$(subst -ALAW,-alaw,$(MCS))
  36. MCS:=$(subst -GSM,-gsm,$(MCS))
  37. MCS:=$(subst -G729,-g729,$(MCS))
  38. MCS:=$(subst -G722,-g722,$(MCS))
  39. MCS:=$(subst -SLN16,-sln16,$(MCS))
  40. MCS:=$(subst -SIREN7,-siren7,$(MCS))
  41. MCS:=$(subst -SIREN14,-siren14,$(MCS))
  42. CORE_SOUNDS:=$(MCS:CORE-SOUNDS-%=asterisk-core-sounds-%-$(CORE_SOUNDS_VERSION).tar.gz)
  43. CORE_SOUND_TAGS:=$(MCS:CORE-SOUNDS-%=.asterisk-core-sounds-%-$(CORE_SOUNDS_VERSION))
  44. MES:=$(subst -EN-,-en-,$(MENUSELECT_EXTRA_SOUNDS))
  45. MES:=$(subst -EN_GB-,-en_GB-,$(MES))
  46. MES:=$(subst -FR-,-fr-,$(MES))
  47. MES:=$(subst -WAV,-wav,$(MES))
  48. MES:=$(subst -ULAW,-ulaw,$(MES))
  49. MES:=$(subst -ALAW,-alaw,$(MES))
  50. MES:=$(subst -GSM,-gsm,$(MES))
  51. MES:=$(subst -G729,-g729,$(MES))
  52. MES:=$(subst -G722,-g722,$(MES))
  53. MES:=$(subst -SLN16,-sln16,$(MES))
  54. MES:=$(subst -SIREN7,-siren7,$(MES))
  55. MES:=$(subst -SIREN14,-siren14,$(MES))
  56. EXTRA_SOUNDS:=$(MES:EXTRA-SOUNDS-%=asterisk-extra-sounds-%-$(EXTRA_SOUNDS_VERSION).tar.gz)
  57. EXTRA_SOUND_TAGS:=$(MES:EXTRA-SOUNDS-%=.asterisk-extra-sounds-%-$(EXTRA_SOUNDS_VERSION))
  58. MM:=$(subst -OPSOUND-,-opsound-,$(MENUSELECT_MOH))
  59. MM:=$(subst -WAV,-wav,$(MM))
  60. MM:=$(subst -ULAW,-ulaw,$(MM))
  61. MM:=$(subst -ALAW,-alaw,$(MM))
  62. MM:=$(subst -GSM,-gsm,$(MM))
  63. MM:=$(subst -G729,-g729,$(MM))
  64. MM:=$(subst -G722,-g722,$(MM))
  65. MM:=$(subst -SLN16,-sln16,$(MM))
  66. MM:=$(subst -SIREN7,-siren7,$(MM))
  67. MM:=$(subst -SIREN14,-siren14,$(MM))
  68. MOH:=$(MM:MOH-%=asterisk-moh-%-$(MOH_VERSION).tar.gz)
  69. MOH_TAGS:=$(MM:MOH-%=.asterisk-moh-%-$(MOH_VERSION))
  70. # If "fetch" is used, --continue is not a valid option.
  71. ifneq ($(findstring wget,$(DOWNLOAD)),)
  72. DOWNLOAD+=--continue $(WGET_EXTRA_ARGS)
  73. endif
  74. define sound_format_lang_rule
  75. .PHONY: .asterisk-$(2)$(if $(3),-$(3),)-%
  76. .asterisk-$(2)$(if $(3),-$(3),)-%: asterisk-$(2)$(if $(3),-$(3),)-%.tar.gz
  77. $(CMD_PREFIX) \
  78. if test ! -f "$(1)$(if $(3),/$(3),)/$$@"; then \
  79. PACKAGE=$$(subst .asterisk,asterisk,$$@).tar.gz; \
  80. ( \
  81. mkdir -p "$(1)$(if $(3),/$(3),)"; \
  82. cd "$(1)$(if $(3),/$(3),)"; \
  83. rm -f $$(subst -$(4),,$$@)-*; \
  84. cat $$(CURDIR)/$$$${PACKAGE} | gzip -d | tar xof - \
  85. ) && touch "$(1)$(if $(3),/$(3),)/$$@"; \
  86. fi
  87. asterisk-$(2)$(if $(3),-$(3),)-%.tar.gz: have_download
  88. ifneq ($(SOUNDS_CACHE_DIR),)
  89. $(CMD_PREFIX) \
  90. if test ! -f "$(1)$(if $(3),/$(3),)/.$$(subst .tar.gz,,$$@)"; then \
  91. if test ! -d "$$(SOUNDS_CACHE_DIR)/"; then \
  92. mkdir -p "$$(SOUNDS_CACHE_DIR)/"; \
  93. fi; \
  94. if test ! -f "$$(SOUNDS_CACHE_DIR)/$$@"; then \
  95. (cd "$$(SOUNDS_CACHE_DIR)"; $$(DOWNLOAD) $$(SOUNDS_URL)/$$@); \
  96. fi; \
  97. if test ! -f "$$(SOUNDS_CACHE_DIR)/$$@.sha1"; then \
  98. (cd "$$(SOUNDS_CACHE_DIR)"; $$(DOWNLOAD) $$(SOUNDS_URL)/$$@.sha1); \
  99. fi; \
  100. $$(LN) -sf "$$(SOUNDS_CACHE_DIR)/$$@" .; \
  101. $$(LN) -sf "$$(SOUNDS_CACHE_DIR)/$$@.sha1" .; \
  102. $$(SHA1SUM) -c --status $$@.sha1 || \
  103. ( \
  104. rm -f "$$(SOUNDS_CACHE_DIR)/$$@" "$$(SOUNDS_CACHE_DIR)/$$@.sha1" $$@ $$@.sha1; \
  105. echo "Bad checksum: $$@" 1>&2; \
  106. exit 1; \
  107. ) || exit 1; \
  108. fi
  109. else
  110. $(CMD_PREFIX) \
  111. if test ! -f $$@ && test ! -f "$(1)$(if $(3),/$(3),)/.$$(subst .tar.gz,,$$@)"; then \
  112. $$(DOWNLOAD) $$(SOUNDS_URL)/$$@; \
  113. fi
  114. endif
  115. endef # sound_format_lang_rule
  116. all: $(CORE_SOUNDS) $(EXTRA_SOUNDS) $(MOH)
  117. have_download:
  118. @if test "$(DOWNLOAD)" = ":" ; then \
  119. echo "**************************************************"; \
  120. echo "*** ***"; \
  121. echo "*** You must have either wget, curl, or fetch ***"; \
  122. echo "*** to be able to automatically download and ***"; \
  123. echo "*** install the requested sound packages. ***"; \
  124. echo "*** ***"; \
  125. echo "*** Please install one of these, or remove any ***"; \
  126. echo "*** extra sound package selections in ***"; \
  127. echo "*** menuselect before installing Asterisk. ***"; \
  128. echo "*** ***"; \
  129. echo "**************************************************"; \
  130. exit 1; \
  131. fi
  132. $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,en,$(CORE_SOUNDS_VERSION)))
  133. $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,en_AU,$(CORE_SOUNDS_VERSION)))
  134. $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,en_GB,$(CORE_SOUNDS_VERSION)))
  135. $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,en_NZ,$(CORE_SOUNDS_VERSION)))
  136. $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,es,$(CORE_SOUNDS_VERSION)))
  137. $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,fr,$(CORE_SOUNDS_VERSION)))
  138. $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,it,$(CORE_SOUNDS_VERSION)))
  139. $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,ru,$(CORE_SOUNDS_VERSION)))
  140. $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,ja,$(CORE_SOUNDS_VERSION)))
  141. $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),core-sounds,sv,$(CORE_SOUNDS_VERSION)))
  142. $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),extra-sounds,en,$(EXTRA_SOUNDS_VERSION)))
  143. $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),extra-sounds,en_GB,$(EXTRA_SOUNDS_VERSION)))
  144. $(eval $(call sound_format_lang_rule,$(SOUNDS_DIR),extra-sounds,fr,$(EXTRA_SOUNDS_VERSION)))
  145. $(eval $(call sound_format_lang_rule,$(MOH_DIR),moh,,$(MOH_VERSION)))
  146. dist-clean:
  147. rm -f *.tar.gz
  148. install: $(CORE_SOUND_TAGS) $(EXTRA_SOUND_TAGS) $(MOH_TAGS)
  149. uninstall:
  150. rm -rf "$(SOUNDS_DIR)"
  151. rm -rf "$(MOH_DIR)"
  152. core_sounds_version:
  153. @echo $(CORE_SOUNDS_VERSION)
  154. extra_sounds_version:
  155. @echo $(EXTRA_SOUNDS_VERSION)
  156. moh_version:
  157. @echo $(MOH_VERSION)