Makefile 5.7 KB

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