Makefile 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  1. #
  2. # Makefile for DAHDI Linux kernel modules
  3. #
  4. # Copyright (C) 2001-2010 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. DAHDIVERSION:=$(shell build_tools/make_version . dahdi/linux)
  55. endif
  56. all: modules
  57. modules: prereq
  58. ifeq (no,$(HAS_KSRC))
  59. @echo "You do not appear to have the sources for the $(KVERS) kernel installed."
  60. @exit 1
  61. endif
  62. $(KMAKE) modules DAHDI_BUILD_ALL=$(DAHDI_BUILD_ALL)
  63. include/dahdi/version.h: FORCE
  64. @DAHDIVERSION="${DAHDIVERSION}" build_tools/make_version_h > $@.tmp
  65. @if cmp -s $@.tmp $@ ; then :; else \
  66. mv $@.tmp $@ ; \
  67. fi
  68. @rm -f $@.tmp
  69. prereq: include/dahdi/version.h firmware-loaders
  70. stackcheck: $(CHECKSTACK) modules
  71. objdump -d drivers/dahdi/*.ko drivers/dahdi/*/*.ko | $(CHECKSTACK)
  72. install: all install-modules install-devices install-include install-firmware install-xpp-firm
  73. @echo "###################################################"
  74. @echo "###"
  75. @echo "### DAHDI installed successfully."
  76. @echo "### If you have not done so before, install the package"
  77. @echo "### dahdi-tools."
  78. @echo "###"
  79. @echo "###################################################"
  80. uninstall: uninstall-modules uninstall-devices uninstall-include uninstall-firmware
  81. install-modconf:
  82. build_tools/genmodconf $(BUILDVER) "$(ROOT_PREFIX)" "$(filter-out dahdi dahdi_dummy xpp dahdi_transcode dahdi_dynamic,$(BUILD_MODULES)) $(MODULE_ALIASES)"
  83. @if [ -d /etc/modutils ]; then \
  84. /sbin/update-modules ; \
  85. fi
  86. install-xpp-firm:
  87. $(MAKE) -C drivers/dahdi/xpp/firmwares install
  88. install-firmware:
  89. ifeq ($(HOTPLUG_FIRMWARE),yes)
  90. $(MAKE) -C drivers/dahdi/firmware hotplug-install DESTDIR=$(DESTDIR) HOTPLUG_FIRMWARE=$(HOTPLUG_FIRMWARE)
  91. endif
  92. uninstall-firmware:
  93. $(MAKE) -C drivers/dahdi/firmware hotplug-uninstall DESTDIR=$(DESTDIR)
  94. firmware-loaders:
  95. $(MAKE) -C drivers/dahdi/firmware firmware-loaders
  96. install-include:
  97. for hdr in $(INST_HEADERS); do \
  98. install -D -m 644 include/dahdi/$$hdr $(DESTDIR)/usr/include/dahdi/$$hdr; \
  99. done
  100. @rm -rf $(DESTDIR)/usr/include/zaptel
  101. uninstall-include:
  102. for hdr in $(INST_HEADERS); do \
  103. rm -f $(DESTDIR)/usr/include/dahdi/$$hdr; \
  104. done
  105. -rmdir $(DESTDIR)/usr/include/dahdi
  106. install-devices:
  107. install -d $(DESTDIR)$(UDEV_DIR)
  108. build_tools/genudevrules > $(DESTDIR)$(UDEV_DIR)/dahdi.rules
  109. install -m 644 drivers/dahdi/xpp/xpp.rules $(DESTDIR)$(UDEV_DIR)/
  110. uninstall-devices:
  111. rm -f $(DESTDIR)$(UDEV_DIR)/dahdi.rules
  112. install-modules: modules
  113. ifndef DESTDIR
  114. @if modinfo zaptel > /dev/null 2>&1; then \
  115. echo -n "Removing Zaptel modules for kernel $(KVERS), please wait..."; \
  116. build_tools/uninstall-modules zaptel $(KVERS); \
  117. rm -rf /lib/modules/$(KVERS)/zaptel; \
  118. echo "done."; \
  119. fi
  120. build_tools/uninstall-modules dahdi $(KVERS)
  121. endif
  122. $(KMAKE) INSTALL_MOD_PATH=$(DESTDIR) INSTALL_MOD_DIR=dahdi modules_install
  123. [ `id -u` = 0 ] && /sbin/depmod -a $(KVERS) || :
  124. uninstall-modules:
  125. ifdef DESTDIR
  126. @echo "Uninstalling modules is not supported with a DESTDIR specified."
  127. @exit 1
  128. else
  129. @if modinfo dahdi > /dev/null 2>&1 ; then \
  130. echo -n "Removing DAHDI modules for kernel $(KVERS), please wait..."; \
  131. build_tools/uninstall-modules dahdi $(KVERS); \
  132. rm -rf /lib/modules/$(KVERS)/dahdi; \
  133. echo "done."; \
  134. fi
  135. [ `id -u` = 0 ] && /sbin/depmod -a $(KVERS) || :
  136. endif
  137. update:
  138. @if [ -d .svn ]; then \
  139. echo "Updating from Subversion..." ; \
  140. svn update | tee update.out; \
  141. rm -f .version; \
  142. if [ `grep -c ^C update.out` -gt 0 ]; then \
  143. echo ; echo "The following files have conflicts:" ; \
  144. grep ^C update.out | cut -b4- ; \
  145. fi ; \
  146. rm -f update.out; \
  147. else \
  148. echo "Not under version control"; \
  149. fi
  150. clean:
  151. ifneq (no,$(HAS_KSRC))
  152. $(KMAKE) clean
  153. endif
  154. @rm -f $(GENERATED_DOCS)
  155. $(MAKE) -C drivers/dahdi/firmware clean
  156. distclean: dist-clean
  157. dist-clean: clean
  158. @rm -f include/dahdi/version.h
  159. @$(MAKE) -C drivers/dahdi/firmware dist-clean
  160. @rm -f drivers/dahdi/vpmadt032_loader/*.o_shipped
  161. firmware-download:
  162. @$(MAKE) -C drivers/dahdi/firmware all
  163. test:
  164. ./test-script $(DESTDIR)/lib/modules/$(KVERS) dahdi
  165. docs: $(GENERATED_DOCS)
  166. README.html: README
  167. $(ASCIIDOC_CMD) -o $@ $<
  168. dahdi-api.html: drivers/dahdi/dahdi-base.c
  169. build_tools/kernel-doc --kernel $(KSRC) $^ >$@
  170. .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
  171. FORCE: