Makefile 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  1. #
  2. # Makefile for DAHDI Linux kernel modules
  3. #
  4. # Copyright (C) 2001-2009 Digium, Inc.
  5. #
  6. #
  7. PWD:=$(shell pwd)
  8. DAHDI_MODULES_EXTRA:=$(MODULES_EXTRA:%=%.o) $(SUBDIRS_EXTRA:%=%/)
  9. # If you want to build for a kernel other than the current kernel, set KVERS
  10. ifndef KVERS
  11. KVERS:=$(shell uname -r)
  12. endif
  13. ifndef KSRC
  14. ifneq (,$(wildcard /lib/modules/$(KVERS)/build))
  15. KSRC:=/lib/modules/$(KVERS)/build
  16. else
  17. KSRC_SEARCH_PATH:=/usr/src/linux
  18. KSRC:=$(shell for dir in $(KSRC_SEARCH_PATH); do if [ -d $$dir ]; then echo $$dir; break; fi; done)
  19. endif
  20. endif
  21. KVERS_MAJ:=$(shell echo $(KVERS) | cut -d. -f1-2)
  22. KINCLUDES:=$(KSRC)/include
  23. # We use the kernel's .config file as an indication that the KSRC
  24. # directory is indeed a valid and configured kernel source (or partial
  25. # source) directory.
  26. #
  27. # We also source it, as it has the format of Makefile variables list.
  28. # Thus we will have many CONFIG_* variables from there.
  29. KCONFIG:=$(KSRC)/.config
  30. ifneq (,$(wildcard $(KCONFIG)))
  31. HAS_KSRC:=yes
  32. include $(KCONFIG)
  33. else
  34. HAS_KSRC:=no
  35. endif
  36. CHECKSTACK=$(KSRC)/scripts/checkstack.pl
  37. # Set HOTPLUG_FIRMWARE=no to override automatic building with hotplug support
  38. # if it is enabled in the kernel.
  39. ifeq (yes,$(HAS_KSRC))
  40. HOTPLUG_FIRMWARE:=$(shell if grep -q '^CONFIG_FW_LOADER=[ym]' $(KCONFIG); then echo "yes"; else echo "no"; fi)
  41. endif
  42. UDEV_DIR:=/etc/udev/rules.d
  43. MODULE_ALIASES:=wcfxs wctdm8xxp wct2xxp
  44. INST_HEADERS:=kernel.h user.h fasthdlc.h wctdm_user.h dahdi_config.h
  45. DAHDI_BUILD_ALL:=m
  46. KMAKE=+$(MAKE) -C $(KSRC) SUBDIRS=$(PWD)/drivers/dahdi DAHDI_INCLUDE=$(PWD)/include DAHDI_MODULES_EXTRA="$(DAHDI_MODULES_EXTRA)" HOTPLUG_FIRMWARE=$(HOTPLUG_FIRMWARE)
  47. ROOT_PREFIX:=
  48. ASCIIDOC:=asciidoc
  49. ASCIIDOC_CMD:=$(ASCIIDOC) -n -a toc -a toclevels=4
  50. GENERATED_DOCS:=README.html
  51. ifneq ($(wildcard .version),)
  52. DAHDIVERSION:=$(shell cat .version)
  53. else
  54. ifneq ($(wildcard .svn),)
  55. DAHDIVERSION:=$(shell build_tools/make_version . dahdi/linux)
  56. else
  57. ifneq ($(wildcard .git),)
  58. DAHDIVERSION:=$(shell build_tools/make_version . dahdi/linux)
  59. endif
  60. endif
  61. endif
  62. all: modules
  63. modules: prereq
  64. ifeq (no,$(HAS_KSRC))
  65. @echo "You do not appear to have the sources for the $(KVERS) kernel installed."
  66. @exit 1
  67. endif
  68. $(KMAKE) modules DAHDI_BUILD_ALL=$(DAHDI_BUILD_ALL)
  69. include/dahdi/version.h: FORCE
  70. @DAHDIVERSION="${DAHDIVERSION}" build_tools/make_version_h > $@.tmp
  71. @if cmp -s $@.tmp $@ ; then :; else \
  72. mv $@.tmp $@ ; \
  73. fi
  74. @rm -f $@.tmp
  75. prereq: include/dahdi/version.h firmware-loaders
  76. stackcheck: $(CHECKSTACK) modules
  77. objdump -d drivers/dahdi/*.ko drivers/dahdi/*/*.ko | $(CHECKSTACK)
  78. install: all install-modules install-devices install-include install-firmware install-xpp-firm
  79. @echo "###################################################"
  80. @echo "###"
  81. @echo "### DAHDI installed successfully."
  82. @echo "### If you have not done so before, install the package"
  83. @echo "### dahdi-tools."
  84. @echo "###"
  85. @echo "###################################################"
  86. uninstall: uninstall-modules uninstall-devices uninstall-include uninstall-firmware
  87. install-modconf:
  88. build_tools/genmodconf $(BUILDVER) "$(ROOT_PREFIX)" "$(filter-out dahdi dahdi_dummy xpp dahdi_transcode dahdi_dynamic,$(BUILD_MODULES)) $(MODULE_ALIASES)"
  89. @if [ -d /etc/modutils ]; then \
  90. /sbin/update-modules ; \
  91. fi
  92. install-xpp-firm:
  93. $(MAKE) -C drivers/dahdi/xpp/firmwares install
  94. install-firmware:
  95. ifeq ($(HOTPLUG_FIRMWARE),yes)
  96. $(MAKE) -C drivers/dahdi/firmware hotplug-install DESTDIR=$(DESTDIR) HOTPLUG_FIRMWARE=$(HOTPLUG_FIRMWARE)
  97. endif
  98. uninstall-firmware:
  99. $(MAKE) -C drivers/dahdi/firmware hotplug-uninstall DESTDIR=$(DESTDIR)
  100. firmware-loaders:
  101. $(MAKE) -C drivers/dahdi/firmware firmware-loaders
  102. install-include:
  103. for hdr in $(INST_HEADERS); do \
  104. install -D -m 644 include/dahdi/$$hdr $(DESTDIR)/usr/include/dahdi/$$hdr; \
  105. done
  106. @rm -rf $(DESTDIR)/usr/include/zaptel
  107. uninstall-include:
  108. for hdr in $(INST_HEADERS); do \
  109. rm -f $(DESTDIR)/usr/include/dahdi/$$hdr; \
  110. done
  111. -rmdir $(DESTDIR)/usr/include/dahdi
  112. install-devices:
  113. install -d $(DESTDIR)$(UDEV_DIR)
  114. build_tools/genudevrules > $(DESTDIR)$(UDEV_DIR)/dahdi.rules
  115. install -m 644 drivers/dahdi/xpp/xpp.rules $(DESTDIR)$(UDEV_DIR)/
  116. uninstall-devices:
  117. rm -f $(DESTDIR)$(UDEV_DIR)/dahdi.rules
  118. install-modules: modules
  119. ifndef DESTDIR
  120. @if modinfo zaptel > /dev/null 2>&1; then \
  121. echo -n "Removing Zaptel modules for kernel $(KVERS), please wait..."; \
  122. build_tools/uninstall-modules zaptel $(KVERS); \
  123. rm -rf /lib/modules/$(KVERS)/zaptel; \
  124. echo "done."; \
  125. fi
  126. build_tools/uninstall-modules dahdi $(KVERS)
  127. endif
  128. $(KMAKE) INSTALL_MOD_PATH=$(DESTDIR) INSTALL_MOD_DIR=dahdi modules_install
  129. [ `id -u` = 0 ] && /sbin/depmod -a $(KVERS) || :
  130. uninstall-modules:
  131. ifdef DESTDIR
  132. @echo "Uninstalling modules is not supported with a DESTDIR specified."
  133. @exit 1
  134. else
  135. @if modinfo dahdi > /dev/null 2>&1 ; then \
  136. echo -n "Removing DAHDI modules for kernel $(KVERS), please wait..."; \
  137. build_tools/uninstall-modules dahdi $(KVERS); \
  138. rm -rf /lib/modules/$(KVERS)/dahdi; \
  139. echo "done."; \
  140. fi
  141. [ `id -u` = 0 ] && /sbin/depmod -a $(KVERS) || :
  142. endif
  143. update:
  144. @if [ -d .svn ]; then \
  145. echo "Updating from Subversion..." ; \
  146. svn update | tee update.out; \
  147. rm -f .version; \
  148. if [ `grep -c ^C update.out` -gt 0 ]; then \
  149. echo ; echo "The following files have conflicts:" ; \
  150. grep ^C update.out | cut -b4- ; \
  151. fi ; \
  152. rm -f update.out; \
  153. else \
  154. echo "Not under version control"; \
  155. fi
  156. clean:
  157. ifneq (no,$(HAS_KSRC))
  158. $(KMAKE) clean
  159. endif
  160. @rm -f $(GENERATED_DOCS)
  161. $(MAKE) -C drivers/dahdi/firmware clean
  162. distclean: dist-clean
  163. dist-clean: clean
  164. @rm -f include/dahdi/version.h
  165. @$(MAKE) -C drivers/dahdi/firmware dist-clean
  166. @rm -f drivers/dahdi/vpmadt032_loader/*.o_shipped
  167. firmware-download:
  168. @$(MAKE) -C drivers/dahdi/firmware all
  169. test:
  170. ./test-script $(DESTDIR)/lib/modules/$(KVERS) dahdi
  171. docs: $(GENERATED_DOCS)
  172. README.html: README
  173. $(ASCIIDOC_CMD) -o $@ $<
  174. dahdi-api.html: drivers/dahdi/dahdi-base.c
  175. build_tools/kernel-doc --kernel $(KSRC) $^ >$@
  176. .PHONY: distclean dist-clean clean all install devices modules stackcheck install-udev update install-modules install-include uninstall-modules firmware-download install-xpp-firm firmware-loaders
  177. FORCE: