1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
# SPDX-License-Identifier: GPL-2.0-only OR MIT
#
# Copyright (C) 2023 The Falco Authors.
#
# This file is dual licensed under either the MIT or GPL 2. See
# MIT.txt or GPL.txt for full copies of the license.
#
@DRIVER_NAME@-y += main.o dynamic_params_table.o fillers_table.o flags_table.o ppm_events.o ppm_fillers.o event_table.o syscall_table64.o ppm_cputime.o ppm_tp.o syscall_ia32_64_map.o
obj-m += @DRIVER_NAME@.o
ccflags-y := @KBUILD_FLAGS@
ifeq ($(strip $(MAKEFILE_LIST)),Makefile)
#
# If MAKEFILE_LIST is just "Makefile", it means `make` was invoked pointing to
# this Makefile. Targets don't make any sense if the Makefile was included.
#
KERNELDIR ?= /lib/modules/$(shell uname -r)/build
TOP := $(shell pwd)
all:
$(MAKE) -C $(KERNELDIR) M=$(TOP) modules
clean:
$(MAKE) -C $(KERNELDIR) M=$(TOP) clean
install: all
$(MAKE) -C $(KERNELDIR) M=$(TOP) modules_install
else
# See https://github.com/falcosecurity/libs/issues/2277
#
# This needs to point to the Linux kernel sources. Prior to Linux 6.13 we could
# use the $(CURDIR), but in 6.13 this changed. See the link above for notes. At
# this time it isn't clear how to make this work generically (all kernel
# versions, all architectures, all OSs, dkms or not). Until a proven "good"
# solution is found I'm doing THIS, which works for Debian.
KERNELDIR ?= $(realpath $(MODLIB)/build)
#
# Get the path of the module sources
#
FIRST_MAKEFILE := $(firstword $(MAKEFILE_LIST))
FIRST_MAKEFILE_FILENAME := $(notdir $(FIRST_MAKEFILE))
FIRST_MAKEFILE_DIRNAME := $(shell basename $(dir $(FIRST_MAKEFILE)))
ifeq ($(FIRST_MAKEFILE_DIRNAME)/$(FIRST_MAKEFILE_FILENAME), scripts/Makefile.build)
# Build phase
MODULE_MAKEFILE_DIR := $(dir $(abspath $(lastword $(MAKEFILE_LIST))))
MAKEFILE_INC_FILES := $(shell find $(MODULE_MAKEFILE_DIR)/configure -type f -name Makefile.inc)
$(info [configure-kmod] Including $(MAKEFILE_INC_FILES))
include $(MAKEFILE_INC_FILES)
endif
endif # $(strip $(MAKEFILE_LIST)),Makefile
|