| 1 | # |
| 2 | # Makefile for the LTT probes. |
| 3 | # Only build from the package top-level directory. Never use with make directly. |
| 4 | |
| 5 | ifneq ($(KERNELRELEASE),) |
| 6 | ifneq ($(CONFIG_TRACEPOINTS),) |
| 7 | |
| 8 | ccflags-y += -I$(PWD)/probes |
| 9 | obj-m += lttng-types.o |
| 10 | |
| 11 | obj-m += lttng-probe-sched.o |
| 12 | obj-m += lttng-probe-irq.o |
| 13 | obj-m += lttng-probe-timer.o |
| 14 | obj-m += lttng-probe-kmem.o |
| 15 | obj-m += lttng-probe-module.o |
| 16 | obj-m += lttng-probe-power.o |
| 17 | |
| 18 | obj-m += lttng-probe-statedump.o |
| 19 | |
| 20 | ifneq ($(CONFIG_KVM),) |
| 21 | obj-m += lttng-probe-kvm.o |
| 22 | endif |
| 23 | |
| 24 | obj-m += $(shell \ |
| 25 | if [ $(VERSION) -ge 3 \ |
| 26 | -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -ge 6 -a $(SUBLEVEL) -ge 33 \) ] ; then \ |
| 27 | echo "lttng-probe-signal.o" ; fi;) |
| 28 | |
| 29 | ifneq ($(CONFIG_BLOCK),) |
| 30 | ifneq ($(CONFIG_EVENT_TRACING),) # need blk_cmd_buf_len |
| 31 | obj-m += lttng-probe-block.o |
| 32 | endif |
| 33 | endif |
| 34 | |
| 35 | ifneq ($(CONFIG_NET),) |
| 36 | obj-m += lttng-probe-napi.o |
| 37 | obj-m += lttng-probe-skb.o |
| 38 | obj-m += $(shell \ |
| 39 | if [ $(VERSION) -ge 3 \ |
| 40 | -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -ge 6 -a $(SUBLEVEL) -ge 37 \) ] ; then \ |
| 41 | echo "lttng-probe-net.o" ; fi;) |
| 42 | obj-m += $(shell \ |
| 43 | if [ $(VERSION) -ge 3 -a $(PATCHLEVEL) -ge 1 ] ; then \ |
| 44 | echo "lttng-probe-sock.o" ; fi;) |
| 45 | obj-m += $(shell \ |
| 46 | if [ $(VERSION) -ge 3 -a $(PATCHLEVEL) -ge 1 ] ; then \ |
| 47 | echo "lttng-probe-udp.o" ; fi;) |
| 48 | endif |
| 49 | |
| 50 | ifneq ($(CONFIG_SND_SOC),) |
| 51 | obj-m += $(shell \ |
| 52 | if [ $(VERSION) -ge 3 \ |
| 53 | -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -ge 6 -a $(SUBLEVEL) -ge 38 \) ] ; then \ |
| 54 | echo "lttng-probe-asoc.o" ; fi;) |
| 55 | endif |
| 56 | |
| 57 | ifneq ($(CONFIG_EXT3_FS),) |
| 58 | ext3_dep = $(srctree)/fs/ext3/*.h |
| 59 | ext3_dep_check = $(wildcard $(ext3_dep)) |
| 60 | ext3 = $(shell \ |
| 61 | if [ $(VERSION) -ge 3 -a $(PATCHLEVEL) -ge 1 ] ; then \ |
| 62 | if [ $(VERSION) -ge 3 -a $(PATCHLEVEL) -ge 4 -a \ |
| 63 | -z "$(ext3_dep_check)" ] ; then \ |
| 64 | echo "warn" ; \ |
| 65 | exit ; \ |
| 66 | fi; \ |
| 67 | echo "lttng-probe-ext3.o" ; \ |
| 68 | fi;) |
| 69 | ifeq ($(ext3),warn) |
| 70 | $(warning Files $(ext3_dep) not found. Probe "ext3" is disabled. Use full kernel source tree to enable it.) |
| 71 | ext3 = |
| 72 | endif |
| 73 | obj-m += $(ext3) |
| 74 | endif |
| 75 | |
| 76 | ifneq ($(CONFIG_GPIOLIB),) |
| 77 | obj-m += $(shell \ |
| 78 | if [ $(VERSION) -ge 3 ] ; then \ |
| 79 | echo "lttng-probe-gpio.o" ; fi;) |
| 80 | endif |
| 81 | |
| 82 | ifneq ($(CONFIG_JBD2),) |
| 83 | obj-m += lttng-probe-jbd2.o |
| 84 | endif |
| 85 | |
| 86 | ifneq ($(CONFIG_JBD),) |
| 87 | obj-m += $(shell \ |
| 88 | if [ $(VERSION) -ge 3 -a $(PATCHLEVEL) -ge 1 ] ; then \ |
| 89 | echo "lttng-probe-jbd.o" ; fi;) |
| 90 | endif |
| 91 | |
| 92 | ifneq ($(CONFIG_REGULATOR),) |
| 93 | obj-m += $(shell \ |
| 94 | if [ $(VERSION) -ge 3 \ |
| 95 | -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -ge 6 -a $(SUBLEVEL) -ge 38 \) ] ; then \ |
| 96 | echo "lttng-probe-regulator.o" ; fi;) |
| 97 | endif |
| 98 | |
| 99 | ifneq ($(CONFIG_SCSI),) |
| 100 | obj-m += $(shell \ |
| 101 | if [ $(VERSION) -ge 3 \ |
| 102 | -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -ge 6 -a $(SUBLEVEL) -ge 35 \) ] ; then \ |
| 103 | echo "lttng-probe-scsi.o" ; fi;) |
| 104 | endif |
| 105 | |
| 106 | vmscan = $(shell \ |
| 107 | if [ $(VERSION) -ge 3 \ |
| 108 | -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -ge 6 -a $(SUBLEVEL) -ge 36 \) ] ; then \ |
| 109 | echo "lttng-probe-vmscan.o" ; fi;) |
| 110 | ifneq ($(CONFIG_SWAP),) |
| 111 | obj-m += $(vmscan) |
| 112 | else |
| 113 | ifneq ($(CONFIG_CGROUP_MEM_RES_CTLR),) |
| 114 | obj-m += $(vmscan) |
| 115 | endif |
| 116 | endif |
| 117 | |
| 118 | # lock probe does not work, so disabling it for now |
| 119 | #ifneq ($(CONFIG_LOCKDEP),) |
| 120 | #obj-m += lttng-probe-lock.o |
| 121 | #endif |
| 122 | |
| 123 | ifneq ($(CONFIG_BTRFS_FS),) |
| 124 | btrfs_dep = $(srctree)/fs/btrfs/*.h |
| 125 | btrfs = $(shell \ |
| 126 | if [ $(VERSION) -ge 3 \ |
| 127 | -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -ge 6 -a $(SUBLEVEL) -ge 39 \) ] ; then \ |
| 128 | echo "lttng-probe-btrfs.o" ; fi;) |
| 129 | ifneq ($(btrfs),) |
| 130 | ifeq ($(wildcard $(btrfs_dep)),) |
| 131 | $(warning Files $(btrfs_dep) not found. Probe "btrfs" is disabled. Use full kernel source tree to enable it.) |
| 132 | btrfs = |
| 133 | endif |
| 134 | endif |
| 135 | obj-m += $(btrfs) |
| 136 | endif |
| 137 | |
| 138 | obj-m += $(shell \ |
| 139 | if [ $(VERSION) -ge 3 \ |
| 140 | -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -ge 6 -a $(SUBLEVEL) -ge 38 \) ] ; then \ |
| 141 | echo "lttng-probe-compaction.o" ; fi;) |
| 142 | |
| 143 | ifneq ($(CONFIG_EXT4_FS),) |
| 144 | ext4_dep = $(srctree)/fs/ext4/*.h |
| 145 | ext4 = lttng-probe-ext4.o |
| 146 | ifeq ($(wildcard $(ext4_dep)),) |
| 147 | $(warning Files $(ext4_dep) not found. Probe "ext4" is disabled. Use full kernel source tree to enable it.) |
| 148 | ext4 = |
| 149 | endif |
| 150 | obj-m += $(ext4) |
| 151 | endif |
| 152 | |
| 153 | obj-m += $(shell \ |
| 154 | if [ $(VERSION) -ge 3 -a $(PATCHLEVEL) -ge 4 ] ; then \ |
| 155 | echo "lttng-probe-printk.o" ; fi;) |
| 156 | ifneq ($(CONFIG_FRAME_WARN),0) |
| 157 | CFLAGS_lttng-probe-printk.o += -Wframe-larger-than=2200 |
| 158 | endif |
| 159 | |
| 160 | obj-m += $(shell \ |
| 161 | if [ \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 6 \) \ |
| 162 | -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -eq 5 -a $(SUBLEVEL) -ge 2 \) \ |
| 163 | -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -eq 4 -a $(SUBLEVEL) -ge 9 \) \ |
| 164 | -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -eq 0 -a $(SUBLEVEL) -ge 41 \) ] ; then \ |
| 165 | echo "lttng-probe-random.o" ; fi;) |
| 166 | |
| 167 | obj-m += $(shell \ |
| 168 | if [ $(VERSION) -ge 3 -a $(PATCHLEVEL) -ge 2 ] ; then \ |
| 169 | echo "lttng-probe-rcu.o" ; fi;) |
| 170 | |
| 171 | ifneq ($(CONFIG_REGMAP),) |
| 172 | obj-m += $(shell \ |
| 173 | if [ $(VERSION) -ge 3 -a $(PATCHLEVEL) -ge 2 ] ; then \ |
| 174 | echo "lttng-probe-regmap.o" ; fi;) |
| 175 | endif |
| 176 | |
| 177 | ifneq ($(CONFIG_PM_RUNTIME),) |
| 178 | obj-m += $(shell \ |
| 179 | if [ $(VERSION) -ge 3 -a $(PATCHLEVEL) -ge 2 ] ; then \ |
| 180 | echo "lttng-probe-rpm.o" ; fi;) |
| 181 | endif |
| 182 | |
| 183 | ifneq ($(CONFIG_SUNRPC),) |
| 184 | obj-m += $(shell \ |
| 185 | if [ $(VERSION) -ge 3 -a $(PATCHLEVEL) -ge 4 ] ; then \ |
| 186 | echo "lttng-probe-sunrpc.o" ; fi;) |
| 187 | endif |
| 188 | |
| 189 | obj-m += lttng-probe-workqueue.o |
| 190 | |
| 191 | ifneq ($(CONFIG_KALLSYMS_ALL),) |
| 192 | obj-m += $(shell \ |
| 193 | if [ $(VERSION) -ge 3 \ |
| 194 | -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -ge 6 -a $(SUBLEVEL) -ge 36 \) ] ; then \ |
| 195 | echo "lttng-probe-writeback.o" ; fi;) |
| 196 | endif |
| 197 | |
| 198 | |
| 199 | ifneq ($(CONFIG_KPROBES),) |
| 200 | obj-m += lttng-kprobes.o |
| 201 | endif |
| 202 | |
| 203 | |
| 204 | ifneq ($(CONFIG_KRETPROBES),) |
| 205 | obj-m += lttng-kretprobes.o |
| 206 | endif |
| 207 | |
| 208 | ifneq ($(CONFIG_DYNAMIC_FTRACE),) |
| 209 | obj-m += lttng-ftrace.o |
| 210 | endif |
| 211 | |
| 212 | endif |
| 213 | |
| 214 | else |
| 215 | KERNELDIR ?= /lib/modules/$(shell uname -r)/build |
| 216 | PWD := $(shell pwd) |
| 217 | CFLAGS = $(EXTCFLAGS) |
| 218 | |
| 219 | default: |
| 220 | $(MAKE) -C $(KERNELDIR) M=$(PWD) modules |
| 221 | |
| 222 | modules_install: |
| 223 | $(MAKE) -C $(KERNELDIR) M=$(PWD) modules_install |
| 224 | /sbin/depmod -a |
| 225 | |
| 226 | clean: |
| 227 | $(MAKE) -C $(KERNELDIR) M=$(PWD) clean |
| 228 | |
| 229 | endif |