Commit | Line | Data |
---|---|---|
b7cdc182 | 1 | # SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) |
1c8284eb MD |
2 | |
3 | ifneq ($(KERNELRELEASE),) | |
1c8284eb | 4 | |
a8907e9a MJ |
5 | # This part of the Makefile is used when called by the kernel build system |
6 | # and defines the modules to be built. | |
7 | ||
98eb7f81 MD |
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 | |
a8907e9a | 13 | |
ca62d279 | 14 | TOP_LTTNG_MODULES_DIR := $(shell dirname $(lastword $(MAKEFILE_LIST))) |
39e088f3 | 15 | |
ca62d279 MD |
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 | |
a8907e9a | 18 | |
ca62d279 MD |
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 | ||
cfa6cc1d | 30 | obj-$(CONFIG_LTTNG) += src/ |
db758d11 | 31 | obj-$(CONFIG_LTTNG) += tests/ |
c340f071 | 32 | |
a8907e9a | 33 | else # KERNELRELEASE |
b37d476e | 34 | |
a8907e9a MJ |
35 | # This part of the Makefile is used when the 'make' command is runned in the |
36 | # base directory of the lttng-modules sources. It sets some environment and | |
37 | # calls the kernel build system to build the actual modules. | |
1c8284eb | 38 | |
a8907e9a MJ |
39 | KERNELDIR ?= /lib/modules/$(shell uname -r)/build |
40 | PWD := $(shell pwd) | |
41 | CFLAGS = $(EXTCFLAGS) | |
1c8284eb | 42 | |
87d1b66f MJ |
43 | default: modules |
44 | ||
45 | modules: | |
3a3b740f | 46 | $(MAKE) -C $(KERNELDIR) M=$(PWD) CONFIG_LTTNG=m CONFIG_LTTNG_CLOCK_PLUGIN_TEST=m modules |
1c8284eb MD |
47 | |
48 | modules_install: | |
3a3b740f | 49 | $(MAKE) -C $(KERNELDIR) M=$(PWD) CONFIG_LTTNG=m CONFIG_LTTNG_CLOCK_PLUGIN_TEST=m modules_install |
1c8284eb MD |
50 | |
51 | clean: | |
ebc53e02 | 52 | $(MAKE) -C $(KERNELDIR) M=$(PWD) clean |
1c8284eb | 53 | |
23e6a44f | 54 | %.i: %.c |
3a3b740f | 55 | $(MAKE) -C $(KERNELDIR) M=$(PWD) CONFIG_LTTNG=m CONFIG_LTTNG_CLOCK_PLUGIN_TEST=m $@ |
a8907e9a | 56 | |
b4809588 | 57 | endif # KERNELRELEASE |