1 # SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
3 TOP_LTTNG_MODULES_DIR := $(shell dirname $(lastword $(MAKEFILE_LIST)))/..
5 include $(TOP_LTTNG_MODULES_DIR)/Kbuild.common
7 ccflags-y += -I$(TOP_LTTNG_MODULES_DIR)
9 obj-$(CONFIG_LTTNG) += lttng-probe-sched.o
10 obj-$(CONFIG_LTTNG) += lttng-probe-irq.o
11 obj-$(CONFIG_LTTNG) += lttng-probe-timer.o
12 obj-$(CONFIG_LTTNG) += lttng-probe-kmem.o
13 obj-$(CONFIG_LTTNG) += lttng-probe-module.o
14 obj-$(CONFIG_LTTNG) += lttng-probe-power.o
15 obj-$(CONFIG_LTTNG) += lttng-probe-statedump.o
17 ifneq ($(CONFIG_NET_9P),)
18 obj-$(CONFIG_LTTNG) += $(shell \
19 if [ $(VERSION) -ge 4 \
20 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -eq 10 \) ] ; then \
21 echo "lttng-probe-9p.o" ; fi;)
24 i2c_dep = $(srctree)/include/trace/events/i2c.h
25 ifneq ($(wildcard $(i2c_dep)),)
26 obj-$(CONFIG_LTTNG) += lttng-probe-i2c.o
29 ifneq ($(CONFIG_KVM),)
30 obj-$(CONFIG_LTTNG) += lttng-probe-kvm.o
31 ifneq ($(CONFIG_X86),)
32 kvm_dep_lapic = $(srctree)/arch/x86/kvm/lapic.h
33 kvm_dep_lapic_check = $(wildcard $(kvm_dep_lapic))
34 ifneq ($(kvm_dep_lapic_check),)
35 # search for iodev.h in any of its known locations
36 kvm_dep_iodev = $(srctree)/virt/kvm/iodev.h $(srctree)/include/kvm/iodev.h
37 kvm_dep_iodev_check = $(wildcard $(kvm_dep_iodev))
38 ifneq ($(kvm_dep_iodev_check),)
39 kvm_dep_emulate = $(srctree)/arch/x86/kvm/kvm_emulate.h
40 kvm_dep_emulate_wildcard = $(wildcard $(kvm_dep_emulate))
41 kvm_dep_emulate_check = $(shell \
42 if [ \( $(VERSION) -ge 6 \
43 -o \( $(VERSION) -eq 5 -a $(PATCHLEVEL) -eq 7 \) \) -a \
44 -z "$(kvm_dep_emulate_wildcard)" ] ; then \
49 ifeq ($(kvm_dep_emulate_check),ok)
50 CFLAGS_lttng-probe-kvm-x86.o += -I$(srctree)/virt/kvm \
51 -I$(srctree)/arch/x86/kvm
52 CFLAGS_lttng-probe-kvm-x86-mmu.o += -I$(srctree)/virt/kvm
53 obj-$(CONFIG_LTTNG) += lttng-probe-kvm-x86.o
54 obj-$(CONFIG_LTTNG) += lttng-probe-kvm-x86-mmu.o
55 else # ($(kvm_dep_emulate_check),ok)
56 $(warning File $(kvm_dep_emulate) not found. Probe "kvm" x86-specific is disabled. Use full kernel source tree to enable it.)
57 endif # ($(kvm_dep_emulate_check),ok)
58 else # $(kvm_dep_iodev_check)
59 $(warning File $(kvm_dep_iodev) not found. Probe "kvm" x86-specific is disabled. Use full kernel source tree to enable it.)
60 endif # $(kvm_dep_iodev_check)
61 else # $(kvm_dep_lapic_check)
62 $(warning File $(kvm_dep_lapic) not found. Probe "kvm" x86-specific is disabled. Use full kernel source tree to enable it.)
63 endif # $(kvm_dep_lapic_check)
67 ifneq ($(CONFIG_X86),)
68 x86_irq_vectors_dep = $(srctree)/arch/x86/include/asm/trace/irq_vectors.h
70 ifneq ($(wildcard $(x86_irq_vectors_dep)),)
71 obj-$(CONFIG_LTTNG) += lttng-probe-x86-irq-vectors.o
72 endif # $(wildcard $(x86_irq_vectors_dep))
74 x86_exceptions_dep = $(srctree)/arch/x86/include/asm/trace/exceptions.h
76 ifneq ($(wildcard $(x86_exceptions_dep)),)
77 obj-$(CONFIG_LTTNG) += lttng-probe-x86-exceptions.o
78 endif # $(wildcard $(x86_exceptions_dep))
81 obj-$(CONFIG_LTTNG) += $(shell \
82 if [ $(VERSION) -ge 3 \
83 -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -eq 6 -a $(SUBLEVEL) -ge 33 \) ] ; then \
84 echo "lttng-probe-signal.o" ; fi;)
86 ifneq ($(CONFIG_BLOCK),)
87 # need blk_cmd_buf_len
88 ifneq ($(CONFIG_EVENT_TRACING),)
89 obj-$(CONFIG_LTTNG) += lttng-probe-block.o
90 endif # CONFIG_EVENT_TRACING
93 ifneq ($(CONFIG_NET),)
94 obj-$(CONFIG_LTTNG) += lttng-probe-napi.o
95 obj-$(CONFIG_LTTNG) += lttng-probe-skb.o
96 obj-$(CONFIG_LTTNG) += $(shell \
97 if [ $(VERSION) -ge 3 \
98 -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -eq 6 -a $(SUBLEVEL) -ge 37 \) ] ; then \
99 echo "lttng-probe-net.o" ; fi;)
100 obj-$(CONFIG_LTTNG) += $(shell \
101 if [ $(VERSION) -ge 4 \
102 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 1 \) ] ; then \
103 echo "lttng-probe-sock.o" ; fi;)
104 obj-$(CONFIG_LTTNG) += $(shell \
105 if [ $(VERSION) -ge 4 \
106 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 1 \) ] ; then \
107 echo "lttng-probe-udp.o" ; fi;)
110 ifneq ($(CONFIG_SND_SOC),)
111 obj-$(CONFIG_LTTNG) += $(shell \
112 if [ $(VERSION) -ge 3 \
113 -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -eq 6 -a $(SUBLEVEL) -ge 38 \) ] ; then \
114 echo "lttng-probe-asoc.o" ; fi;)
115 endif # CONFIG_SND_SOC
117 ifneq ($(CONFIG_EXT3_FS),)
118 ext3_dep = $(srctree)/fs/ext3/*.h
119 ext3_dep_check = $(wildcard $(ext3_dep))
121 if [ $(VERSION) -lt 4 -o \( $(VERSION) -eq 4 -a $(PATCHLEVEL) -lt 3 \) ] ; then \
122 if [ $(VERSION) -ge 4 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 1 \) ] ; then \
123 if [ \( $(VERSION) -ge 4 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 4 \) \) -a \
124 -z "$(ext3_dep_check)" ] ; then \
128 echo "lttng-probe-ext3.o" ; \
132 $(warning Files $(ext3_dep) not found. Probe "ext3" is disabled. Use full kernel source tree to enable it.)
135 obj-$(CONFIG_LTTNG) += $(ext3)
136 endif # CONFIG_EXT3_FS
138 ifneq ($(CONFIG_GPIOLIB),)
139 obj-$(CONFIG_LTTNG) += $(shell \
140 if [ $(VERSION) -ge 3 ] ; then \
141 echo "lttng-probe-gpio.o" ; fi;)
142 endif # CONFIG_GPIOLIB
144 ifneq ($(CONFIG_JBD2),)
145 obj-$(CONFIG_LTTNG) += lttng-probe-jbd2.o
148 ifneq ($(CONFIG_JBD),)
149 obj-$(CONFIG_LTTNG) += $(shell \
150 if [ $(VERSION) -ge 4 \
151 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 1 \) ] ; then \
152 echo "lttng-probe-jbd.o" ; fi;)
155 ifneq ($(CONFIG_REGULATOR),)
156 obj-$(CONFIG_LTTNG) += $(shell \
157 if [ $(VERSION) -ge 3 \
158 -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -eq 6 -a $(SUBLEVEL) -ge 38 \) ] ; then \
159 echo "lttng-probe-regulator.o" ; fi;)
160 endif # CONFIG_REGULATOR
162 ifneq ($(CONFIG_SCSI),)
163 obj-$(CONFIG_LTTNG) += $(shell \
164 if [ $(VERSION) -ge 3 \
165 -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -eq 6 -a $(SUBLEVEL) -ge 35 \) ] ; then \
166 echo "lttng-probe-scsi.o" ; fi;)
169 obj-$(CONFIG_LTTNG) += $(shell \
170 if [ $(VERSION) -ge 3 \
171 -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -eq 6 -a $(SUBLEVEL) -ge 36 \) ] ; then \
172 echo "lttng-probe-vmscan.o" ; fi;)
174 # lock probe does not work, so disabling it for now
175 #ifneq ($(CONFIG_LOCKDEP),)
176 # obj-$(CONFIG_LTTNG) += lttng-probe-lock.o
177 #endif # CONFIG_LOCKDEP
179 ifneq ($(CONFIG_BTRFS_FS),)
180 btrfs_dep = $(srctree)/fs/btrfs/*.h
182 if [ $(VERSION) -ge 3 \
183 -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -eq 6 -a $(SUBLEVEL) -ge 39 \) ] ; then \
184 echo "lttng-probe-btrfs.o" ; fi;)
186 ifeq ($(wildcard $(btrfs_dep)),)
187 $(warning Files $(btrfs_dep) not found. Probe "btrfs" is disabled. Use full kernel source tree to enable it.)
189 endif # $(wildcard $(btrfs_dep))
191 obj-$(CONFIG_LTTNG) += $(btrfs)
192 endif # CONFIG_BTRFS_FS
194 obj-$(CONFIG_LTTNG) += $(shell \
195 if [ $(VERSION) -ge 3 \
196 -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -eq 6 -a $(SUBLEVEL) -ge 38 \) ] ; then \
197 echo "lttng-probe-compaction.o" ; fi;)
199 ifneq ($(CONFIG_EXT4_FS),)
200 ext4_dep = $(srctree)/fs/ext4/*.h
201 ext4 = lttng-probe-ext4.o
202 ifeq ($(wildcard $(ext4_dep)),)
203 $(warning Files $(ext4_dep) not found. Probe "ext4" is disabled. Use full kernel source tree to enable it.)
205 endif # $(wildcard $(ext4_dep))
206 obj-$(CONFIG_LTTNG) += $(ext4)
207 endif # CONFIG_EXT4_FS
209 obj-$(CONFIG_LTTNG) += $(shell \
210 if [ $(VERSION) -ge 4 \
211 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 4 \) ] ; then \
212 echo "lttng-probe-printk.o" ; fi;)
214 ifneq ($(CONFIG_FRAME_WARN),0)
215 CFLAGS_lttng-probe-printk.o += -Wframe-larger-than=2200
218 obj-$(CONFIG_LTTNG) += $(shell \
219 if [ $(VERSION) -ge 4 \
220 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 6 \) \
221 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -eq 5 -a $(SUBLEVEL) -ge 2 \) \
222 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -eq 4 -a $(SUBLEVEL) -ge 9 \) \
223 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -eq 0 -a $(SUBLEVEL) -ge 41 \) ] ; then \
224 echo "lttng-probe-random.o" ; fi;)
226 obj-$(CONFIG_LTTNG) += $(shell \
227 if [ $(VERSION) -ge 4 \
228 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 2 \) ] ; then \
229 echo "lttng-probe-rcu.o" ; fi;)
231 ifneq ($(CONFIG_REGMAP),)
232 regmap_dep_4_1 = $(srctree)/drivers/base/regmap/trace.h
233 ifneq ($(wildcard $(regmap_dep_4_1)),)
234 obj-$(CONFIG_LTTNG) += lttng-probe-regmap.o
236 $(warning File $(regmap_dep_4_1) not found. Probe "regmap" is disabled. Need Linux 4.1+ kernel source tree to enable it.)
237 endif # $(wildcard $(regmap_dep_4_1)),
238 endif # CONFIG_REGMAP
240 ifneq ($(CONFIG_PM_RUNTIME),)
241 obj-$(CONFIG_LTTNG) += $(shell \
242 if [ $(VERSION) -ge 4 \
243 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 2 \) ] ; then \
244 echo "lttng-probe-rpm.o" ; fi;)
245 endif # CONFIG_PM_RUNTIME
247 ifneq ($(CONFIG_SUNRPC),)
248 obj-$(CONFIG_LTTNG) += $(shell \
249 if [ $(VERSION) -ge 4 \
250 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 4 \) ] ; then \
251 echo "lttng-probe-sunrpc.o" ; fi;)
252 endif # CONFIG_SUNRPC
254 ifneq ($(CONFIG_VIDEO_V4L2),)
255 obj-$(CONFIG_LTTNG) += $(shell \
256 if [ $(VERSION) -ge 4 \
257 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 14 \) ] ; then \
258 echo "lttng-probe-v4l2.o" ; fi;)
259 endif # CONFIG_VIDEO_V4L2
261 obj-$(CONFIG_LTTNG) += lttng-probe-workqueue.o
263 ifneq ($(CONFIG_KALLSYMS_ALL),)
264 obj-$(CONFIG_LTTNG) += $(shell \
265 if [ $(VERSION) -ge 3 \
266 -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -eq 6 -a $(SUBLEVEL) -ge 36 \) ] ; then \
267 echo "lttng-probe-writeback.o" ; fi;)
269 ifdef CONFIG_LOCALVERSION # Check if dot-config is included.
270 $(warning CONFIG_KALLSYMS_ALL is disabled, therefore probe "writeback" is disabled. Rebuild your kernel with this configuration option enabled in order to trace this subsystem.)
272 endif # CONFIG_KALLSYMS_ALL
274 ifneq ($(CONFIG_KPROBES),)
275 obj-$(CONFIG_LTTNG) += lttng-kprobes.o
276 endif # CONFIG_KPROBES
278 ifneq ($(CONFIG_UPROBES),)
279 obj-$(CONFIG_LTTNG) += lttng-uprobes.o
280 endif # CONFIG_UPROBES
282 ifneq ($(CONFIG_KRETPROBES),)
283 obj-$(CONFIG_LTTNG) += lttng-kretprobes.o
284 endif # CONFIG_KRETPROBES
286 ifneq ($(CONFIG_PREEMPTIRQ_EVENTS),)
287 obj-$(CONFIG_LTTNG) += lttng-probe-preemptirq.o
288 endif # CONFIG_PREEMPTIRQ_EVENTS