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) += lttng-probe-signal.o
83 ifneq ($(CONFIG_BLOCK),)
84 # need blk_cmd_buf_len
85 ifneq ($(CONFIG_EVENT_TRACING),)
86 obj-$(CONFIG_LTTNG) += lttng-probe-block.o
87 endif # CONFIG_EVENT_TRACING
90 ifneq ($(CONFIG_NET),)
91 obj-$(CONFIG_LTTNG) += lttng-probe-napi.o
92 obj-$(CONFIG_LTTNG) += lttng-probe-skb.o
93 obj-$(CONFIG_LTTNG) += lttng-probe-net.o
94 obj-$(CONFIG_LTTNG) += $(shell \
95 if [ $(VERSION) -ge 4 \
96 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 1 \) ] ; then \
97 echo "lttng-probe-sock.o" ; fi;)
98 obj-$(CONFIG_LTTNG) += $(shell \
99 if [ $(VERSION) -ge 4 \
100 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 1 \) ] ; then \
101 echo "lttng-probe-udp.o" ; fi;)
104 ifneq ($(CONFIG_SND_SOC),)
105 obj-$(CONFIG_LTTNG) += lttng-probe-asoc.o
106 endif # CONFIG_SND_SOC
108 ifneq ($(CONFIG_EXT3_FS),)
109 ext3_dep = $(srctree)/fs/ext3/*.h
110 ext3_dep_check = $(wildcard $(ext3_dep))
112 if [ $(VERSION) -lt 4 -o \( $(VERSION) -eq 4 -a $(PATCHLEVEL) -lt 3 \) ] ; then \
113 if [ $(VERSION) -ge 4 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 1 \) ] ; then \
114 if [ \( $(VERSION) -ge 4 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 4 \) \) -a \
115 -z "$(ext3_dep_check)" ] ; then \
119 echo "lttng-probe-ext3.o" ; \
123 $(warning Files $(ext3_dep) not found. Probe "ext3" is disabled. Use full kernel source tree to enable it.)
126 obj-$(CONFIG_LTTNG) += $(ext3)
127 endif # CONFIG_EXT3_FS
129 ifneq ($(CONFIG_GPIOLIB),)
130 obj-$(CONFIG_LTTNG) += $(shell \
131 if [ $(VERSION) -ge 3 ] ; then \
132 echo "lttng-probe-gpio.o" ; fi;)
133 endif # CONFIG_GPIOLIB
135 ifneq ($(CONFIG_JBD2),)
136 obj-$(CONFIG_LTTNG) += lttng-probe-jbd2.o
139 ifneq ($(CONFIG_JBD),)
140 obj-$(CONFIG_LTTNG) += $(shell \
141 if [ $(VERSION) -ge 4 \
142 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 1 \) ] ; then \
143 echo "lttng-probe-jbd.o" ; fi;)
146 ifneq ($(CONFIG_REGULATOR),)
147 obj-$(CONFIG_LTTNG) += lttng-probe-regulator.o
148 endif # CONFIG_REGULATOR
150 ifneq ($(CONFIG_SCSI),)
151 obj-$(CONFIG_LTTNG) += lttng-probe-scsi.o
154 obj-$(CONFIG_LTTNG) += lttng-probe-vmscan.o
156 # lock probe does not work, so disabling it for now
157 #ifneq ($(CONFIG_LOCKDEP),)
158 # obj-$(CONFIG_LTTNG) += lttng-probe-lock.o
159 #endif # CONFIG_LOCKDEP
161 ifneq ($(CONFIG_BTRFS_FS),)
162 btrfs_dep = $(srctree)/fs/btrfs/*.h
163 ifneq ($(wildcard $(btrfs_dep)),)
164 obj-$(CONFIG_LTTNG) += lttng-probe-btrfs.o
166 $(warning Files $(btrfs_dep) not found. Probe "btrfs" is disabled. Use full kernel source tree to enable it.)
167 endif # $(wildcard $(btrfs_dep))
168 endif # CONFIG_BTRFS_FS
170 obj-$(CONFIG_LTTNG) += lttng-probe-compaction.o
172 ifneq ($(CONFIG_EXT4_FS),)
173 ext4_dep = $(srctree)/fs/ext4/*.h
174 ifneq ($(wildcard $(ext4_dep)),)
175 obj-$(CONFIG_LTTNG) += lttng-probe-ext4.o
177 $(warning Files $(ext4_dep) not found. Probe "ext4" is disabled. Use full kernel source tree to enable it.)
178 endif # $(wildcard $(ext4_dep))
179 endif # CONFIG_EXT4_FS
181 obj-$(CONFIG_LTTNG) += $(shell \
182 if [ $(VERSION) -ge 4 \
183 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 4 \) ] ; then \
184 echo "lttng-probe-printk.o" ; fi;)
186 ifneq ($(CONFIG_FRAME_WARN),0)
187 CFLAGS_lttng-probe-printk.o += -Wframe-larger-than=2200
190 obj-$(CONFIG_LTTNG) += $(shell \
191 if [ $(VERSION) -ge 4 \
192 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 6 \) \
193 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -eq 5 -a $(SUBLEVEL) -ge 2 \) \
194 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -eq 4 -a $(SUBLEVEL) -ge 9 \) \
195 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -eq 0 -a $(SUBLEVEL) -ge 41 \) ] ; then \
196 echo "lttng-probe-random.o" ; fi;)
198 obj-$(CONFIG_LTTNG) += $(shell \
199 if [ $(VERSION) -ge 4 \
200 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 2 \) ] ; then \
201 echo "lttng-probe-rcu.o" ; fi;)
203 ifneq ($(CONFIG_REGMAP),)
204 regmap_dep_4_1 = $(srctree)/drivers/base/regmap/trace.h
205 ifneq ($(wildcard $(regmap_dep_4_1)),)
206 obj-$(CONFIG_LTTNG) += lttng-probe-regmap.o
208 $(warning File $(regmap_dep_4_1) not found. Probe "regmap" is disabled. Need Linux 4.1+ kernel source tree to enable it.)
209 endif # $(wildcard $(regmap_dep_4_1)),
210 endif # CONFIG_REGMAP
212 ifneq ($(CONFIG_PM_RUNTIME),)
213 obj-$(CONFIG_LTTNG) += $(shell \
214 if [ $(VERSION) -ge 4 \
215 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 2 \) ] ; then \
216 echo "lttng-probe-rpm.o" ; fi;)
217 endif # CONFIG_PM_RUNTIME
219 ifneq ($(CONFIG_SUNRPC),)
220 obj-$(CONFIG_LTTNG) += $(shell \
221 if [ $(VERSION) -ge 4 \
222 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 4 \) ] ; then \
223 echo "lttng-probe-sunrpc.o" ; fi;)
224 endif # CONFIG_SUNRPC
226 ifneq ($(CONFIG_VIDEO_V4L2),)
227 obj-$(CONFIG_LTTNG) += $(shell \
228 if [ $(VERSION) -ge 4 \
229 -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 14 \) ] ; then \
230 echo "lttng-probe-v4l2.o" ; fi;)
231 endif # CONFIG_VIDEO_V4L2
233 obj-$(CONFIG_LTTNG) += lttng-probe-workqueue.o
235 ifneq ($(CONFIG_KALLSYMS_ALL),)
236 obj-$(CONFIG_LTTNG) += lttng-probe-writeback.o
238 ifdef CONFIG_LOCALVERSION # Check if dot-config is included.
239 $(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.)
241 endif # CONFIG_KALLSYMS_ALL
243 ifneq ($(CONFIG_KPROBES),)
244 obj-$(CONFIG_LTTNG) += lttng-kprobes.o
245 endif # CONFIG_KPROBES
247 ifneq ($(CONFIG_UPROBES),)
248 obj-$(CONFIG_LTTNG) += lttng-uprobes.o
249 endif # CONFIG_UPROBES
251 ifneq ($(CONFIG_KRETPROBES),)
252 obj-$(CONFIG_LTTNG) += lttng-kretprobes.o
253 endif # CONFIG_KRETPROBES
255 ifneq ($(CONFIG_PREEMPTIRQ_EVENTS),)
256 obj-$(CONFIG_LTTNG) += lttng-probe-preemptirq.o
257 endif # CONFIG_PREEMPTIRQ_EVENTS