Debian Codegraph @

Makefile

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