| 1 | # SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1) |
| 2 | |
| 3 | ifneq ($(KERNELRELEASE),) |
| 4 | |
| 5 | # This part of the Makefile is used when called by the kernel build system |
| 6 | # and defines the modules to be built. |
| 7 | |
| 8 | ifdef CONFIG_LOCALVERSION # Check if dot-config is included. |
| 9 | ifeq ($(CONFIG_TRACEPOINTS),) |
| 10 | $(error The option CONFIG_TRACEPOINTS needs to be enabled in your kernel configuration) |
| 11 | endif # CONFIG_TRACEPOINTS |
| 12 | endif # ifdef CONFIG_LOCALVERSION |
| 13 | |
| 14 | TOP_LTTNG_MODULES_DIR := $(shell dirname $(lastword $(MAKEFILE_LIST))) |
| 15 | |
| 16 | lttng_check_linux_version = $(shell pwd)/include/linux/version.h |
| 17 | lttng_check_generated_linux_version = $(shell pwd)/include/generated/uapi/linux/version.h |
| 18 | |
| 19 | # |
| 20 | # Check for stale version.h, which can be a leftover from an old Linux |
| 21 | # kernel tree moved to a newer kernel version, only pruned by make |
| 22 | # distclean. |
| 23 | # |
| 24 | ifneq ($(wildcard $(lttng_check_linux_version)),) |
| 25 | ifneq ($(wildcard $(lttng_check_generated_linux_version)),) |
| 26 | $(error Duplicate version.h files found in $(lttng_check_linux_version) and $(lttng_check_generated_linux_version). Consider running make distclean on your kernel, or removing the stale $(lttng_check_linux_version) file) |
| 27 | endif |
| 28 | endif |
| 29 | |
| 30 | include $(TOP_LTTNG_MODULES_DIR)/Kbuild.common |
| 31 | |
| 32 | ccflags-y += -I$(TOP_LTTNG_MODULES_DIR) |
| 33 | |
| 34 | obj-$(CONFIG_LTTNG) += lttng-ring-buffer-client-discard.o |
| 35 | obj-$(CONFIG_LTTNG) += lttng-ring-buffer-client-overwrite.o |
| 36 | obj-$(CONFIG_LTTNG) += lttng-ring-buffer-metadata-client.o |
| 37 | obj-$(CONFIG_LTTNG) += lttng-ring-buffer-client-mmap-discard.o |
| 38 | obj-$(CONFIG_LTTNG) += lttng-ring-buffer-client-mmap-overwrite.o |
| 39 | obj-$(CONFIG_LTTNG) += lttng-ring-buffer-metadata-mmap-client.o |
| 40 | obj-$(CONFIG_LTTNG) += lttng-clock.o |
| 41 | |
| 42 | obj-$(CONFIG_LTTNG) += lttng-tracer.o |
| 43 | |
| 44 | obj-$(CONFIG_LTTNG) += lttng-wrapper.o |
| 45 | |
| 46 | lttng-tracer-objs := lttng-events.o lttng-abi.o lttng-string-utils.o \ |
| 47 | lttng-probes.o lttng-context.o \ |
| 48 | lttng-context-pid.o lttng-context-procname.o \ |
| 49 | lttng-context-prio.o lttng-context-nice.o \ |
| 50 | lttng-context-vpid.o lttng-context-tid.o \ |
| 51 | lttng-context-vtid.o lttng-context-ppid.o \ |
| 52 | lttng-context-vppid.o lttng-context-cpu-id.o \ |
| 53 | lttng-context-interruptible.o \ |
| 54 | lttng-context-need-reschedule.o \ |
| 55 | lttng-context-callstack.o lttng-calibrate.o \ |
| 56 | lttng-context-hostname.o \ |
| 57 | probes/lttng.o \ |
| 58 | lttng-tracker-pid.o \ |
| 59 | lttng-filter.o lttng-filter-interpreter.o \ |
| 60 | lttng-filter-specialize.o \ |
| 61 | lttng-filter-validator.o \ |
| 62 | probes/lttng-probe-user.o \ |
| 63 | lttng-tp-mempool.o \ |
| 64 | |
| 65 | lttng-wrapper-objs := wrapper/page_alloc.o \ |
| 66 | wrapper/random.o \ |
| 67 | wrapper/trace-clock.o \ |
| 68 | wrapper/kallsyms.o \ |
| 69 | wrapper/irqdesc.o \ |
| 70 | wrapper/fdtable.o \ |
| 71 | wrapper/genhd.o \ |
| 72 | lttng-wrapper-impl.o |
| 73 | |
| 74 | ifneq ($(CONFIG_HAVE_SYSCALL_TRACEPOINTS),) |
| 75 | lttng-tracer-objs += lttng-syscalls.o |
| 76 | endif # CONFIG_HAVE_SYSCALL_TRACEPOINTS |
| 77 | |
| 78 | ifneq ($(CONFIG_PERF_EVENTS),) |
| 79 | lttng-tracer-objs += $(shell \ |
| 80 | if [ $(VERSION) -ge 3 \ |
| 81 | -o \( $(VERSION) -eq 2 -a $(PATCHLEVEL) -eq 6 -a $(SUBLEVEL) -ge 33 \) ] ; then \ |
| 82 | echo "lttng-context-perf-counters.o" ; fi;) |
| 83 | endif # CONFIG_PERF_EVENTS |
| 84 | |
| 85 | ifneq ($(CONFIG_PREEMPT_RT_FULL),) |
| 86 | lttng-tracer-objs += lttng-context-migratable.o |
| 87 | lttng-tracer-objs += lttng-context-preemptible.o |
| 88 | endif # CONFIG_PREEMPT_RT_FULL |
| 89 | |
| 90 | ifneq ($(CONFIG_PREEMPT),) |
| 91 | lttng-tracer-objs += lttng-context-preemptible.o |
| 92 | endif |
| 93 | |
| 94 | lttng-tracer-objs += $(shell \ |
| 95 | if [ $(VERSION) -ge 4 \ |
| 96 | -o \( $(VERSION) -eq 3 -a $(PATCHLEVEL) -ge 15 \) ] ; then \ |
| 97 | echo "lttng-tracepoint.o" ; fi;) |
| 98 | |
| 99 | obj-$(CONFIG_LTTNG) += lttng-statedump.o |
| 100 | lttng-statedump-objs := lttng-statedump-impl.o |
| 101 | |
| 102 | obj-$(CONFIG_LTTNG) += probes/ |
| 103 | obj-$(CONFIG_LTTNG) += lib/ |
| 104 | obj-$(CONFIG_LTTNG) += tests/ |
| 105 | |
| 106 | else # KERNELRELEASE |
| 107 | |
| 108 | # This part of the Makefile is used when the 'make' command is runned in the |
| 109 | # base directory of the lttng-modules sources. It sets some environment and |
| 110 | # calls the kernel build system to build the actual modules. |
| 111 | |
| 112 | KERNELDIR ?= /lib/modules/$(shell uname -r)/build |
| 113 | PWD := $(shell pwd) |
| 114 | CFLAGS = $(EXTCFLAGS) |
| 115 | |
| 116 | default: modules |
| 117 | |
| 118 | modules: |
| 119 | $(MAKE) -C $(KERNELDIR) M=$(PWD) CONFIG_LTTNG=m CONFIG_LTTNG_CLOCK_PLUGIN_TEST=m modules |
| 120 | |
| 121 | modules_install: |
| 122 | $(MAKE) -C $(KERNELDIR) M=$(PWD) CONFIG_LTTNG=m CONFIG_LTTNG_CLOCK_PLUGIN_TEST=m modules_install |
| 123 | |
| 124 | clean: |
| 125 | $(MAKE) -C $(KERNELDIR) M=$(PWD) clean |
| 126 | |
| 127 | %.i: %.c |
| 128 | $(MAKE) -C $(KERNELDIR) M=$(PWD) CONFIG_LTTNG=m CONFIG_LTTNG_CLOCK_PLUGIN_TEST=m $@ |
| 129 | |
| 130 | endif # KERNELRELEASE |