1 # SPDX-License-Identifier: (GPL-2.0 OR LGPL-2.1)
3 # Work-around for distro-specific public modules ABI breakages.
4 # Some distributions break the public module instrumentation ABI
5 # compared to upstream stable kernels without providing other mean than
6 # the kernel EXTRAVERSION to figure it out. Translate this information
7 # into a define visible from the C preprocessor.
9 DEB_API_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/abi-debian-version.sh $(CURDIR))
11 ifneq ($(DEB_API_VERSION), 0)
12 ccflags-y += -DDEBIAN_API_VERSION=$(DEB_API_VERSION)
15 RHEL_API_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/abi-rhel-version.sh $(CURDIR))
17 ifneq ($(RHEL_API_VERSION), 0)
18 ccflags-y += -DRHEL_API_VERSION=$(RHEL_API_VERSION)
21 SLE_API_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/abi-sle-version.sh $(CURDIR))
23 ifneq ($(SLE_API_VERSION), 0)
24 ccflags-y += -DSLE_API_VERSION=$(SLE_API_VERSION)
27 FEDORA_REVISION_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/abi-fedora-version.sh $(CURDIR))
29 ifneq ($(FEDORA_REVISION_VERSION), 0)
30 ccflags-y += -DFEDORA_REVISION_VERSION=$(FEDORA_REVISION_VERSION)
33 RT_PATCH_VERSION:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/rt-patch-version.sh $(CURDIR))
35 ifneq ($(RT_PATCH_VERSION), 0)
36 ccflags-y += -DRT_PATCH_VERSION=$(RT_PATCH_VERSION)
39 EXTRA_VERSION_NAME:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/extra-version-name.sh $(TOP_LTTNG_MODULES_DIR))
41 ifneq ($(EXTRA_VERSION_NAME), 0)
42 ccflags-y += -DLTTNG_EXTRA_VERSION_NAME='"$(EXTRA_VERSION_NAME)"'
45 EXTRA_VERSION_GIT:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/extra-version-git.sh $(TOP_LTTNG_MODULES_DIR))
47 ifneq ($(EXTRA_VERSION_GIT), 0)
48 ccflags-y += -DLTTNG_EXTRA_VERSION_GIT='"$(EXTRA_VERSION_GIT)"'
51 EXTRA_VERSION_PATCHES:=$(shell $(TOP_LTTNG_MODULES_DIR)/scripts/extra-version-patches.sh $(TOP_LTTNG_MODULES_DIR))
53 # Starting with kernel 4.12, the ftrace header was moved to private headers
54 # and as such is not available when building against distro headers instead
55 # of the full kernel sources. In the situation, define LTTNG_FTRACE_MISSING_HEADER
56 # so we can enable the compat code even if CONFIG_DYNAMIC_FTRACE is enabled.
57 ifneq ($(CONFIG_DYNAMIC_FTRACE),)
58 ftrace_dep = $(srctree)/kernel/trace/trace.h
59 ftrace_dep_check = $(wildcard $(ftrace_dep))
60 have_ftrace_header = $(shell \
61 if [ $(VERSION) -ge 5 -o \( $(VERSION) -eq 4 -a $(PATCHLEVEL) -ge 12 \) ] ; then \
62 if [ -z "$(ftrace_dep_check)" ] ; then \
69 ifeq ($(have_ftrace_header), no)
70 ccflags-y += -DLTTNG_FTRACE_MISSING_HEADER
74 mnt_ns_dep = $(srctree)/fs/mount.h
75 ifeq ($(wildcard $(mnt_ns_dep)),)
76 ccflags-y += -DLTTNG_MNT_NS_MISSING_HEADER