Makefile 5.8 KB

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