| 1 | # SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only) |
| 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 | obj-$(CONFIG_LTTNG) += src/ |
| 31 | obj-$(CONFIG_LTTNG) += tests/ |
| 32 | |
| 33 | else # KERNELRELEASE |
| 34 | |
| 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. |
| 38 | |
| 39 | KERNELDIR ?= /lib/modules/$(shell uname -r)/build |
| 40 | PWD := $(shell pwd) |
| 41 | CFLAGS = $(EXTCFLAGS) |
| 42 | |
| 43 | default: modules |
| 44 | |
| 45 | modules: |
| 46 | $(MAKE) -C $(KERNELDIR) M=$(PWD) CONFIG_LTTNG=m CONFIG_LTTNG_CLOCK_PLUGIN_TEST=m modules |
| 47 | |
| 48 | modules_install: |
| 49 | $(MAKE) -C $(KERNELDIR) M=$(PWD) CONFIG_LTTNG=m CONFIG_LTTNG_CLOCK_PLUGIN_TEST=m modules_install |
| 50 | |
| 51 | clean: |
| 52 | $(MAKE) -C $(KERNELDIR) M=$(PWD) clean |
| 53 | |
| 54 | %.i: %.c |
| 55 | $(MAKE) -C $(KERNELDIR) M=$(PWD) CONFIG_LTTNG=m CONFIG_LTTNG_CLOCK_PLUGIN_TEST=m $@ |
| 56 | |
| 57 | endif # KERNELRELEASE |