1# SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note 2# 3# (C) COPYRIGHT 2022 ARM Limited. All rights reserved. 4# 5# This program is free software and is provided to you under the terms of the 6# GNU General Public License version 2 as published by the Free Software 7# Foundation, and any use by you of this program is subject to the terms 8# of such GNU license. 9# 10# This program is distributed in the hope that it will be useful, 11# but WITHOUT ANY WARRANTY; without even the implied warranty of 12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13# GNU General Public License for more details. 14# 15# You should have received a copy of the GNU General Public License 16# along with this program; if not, you can access it online at 17# http://www.gnu.org/licenses/gpl-2.0.html. 18# 19# 20 21KERNEL_SRC ?= /lib/modules/$(shell uname -r)/build 22KDIR ?= $(KERNEL_SRC) 23 24ifeq ($(KDIR),) 25 $(error Must specify KDIR to point to the kernel to target)) 26endif 27 28CONFIG_MALI_CORESIGHT ?= n 29ifeq ($(CONFIG_MALI_CORESIGHT),y) 30 31 ifeq ($(CONFIG_ARM64), y) 32 CONFIG_CORESIGHT_MALI_SOURCES_ETM ?= y 33 endif 34 35 CONFIG_CORESIGHT_MALI_SOURCES_ITM ?= y 36 CONFIG_CORESIGHT_MALI_SOURCES_ELA ?= y 37endif 38 39CONFIGS := \ 40 CONFIG_MALI_CORESIGHT \ 41 CONFIG_CORESIGHT_MALI_SOURCES_ETM \ 42 CONFIG_CORESIGHT_MALI_SOURCES_ITM \ 43 CONFIG_CORESIGHT_MALI_SOURCES_ELA 44 45 46# 47# MAKE_ARGS to pass the custom CONFIGs on out-of-tree build 48# 49# Generate the list of CONFIGs and values. 50# $(value config) is the name of the CONFIG option. 51# $(value $(value config)) is its value (y, m). 52# When the CONFIG is not set to y or m, it defaults to n. 53MAKE_ARGS := $(foreach config,$(CONFIGS), \ 54 $(if $(filter y m,$(value $(value config))), \ 55 $(value config)=$(value $(value config)), \ 56 $(value config)=n)) 57 58# 59# EXTRA_CFLAGS to define the custom CONFIGs on out-of-tree build 60# 61# Generate the list of CONFIGs defines with values from CONFIGS. 62# $(value config) is the name of the CONFIG option. 63# When set to y or m, the CONFIG gets defined to 1. 64EXTRA_CFLAGS := $(foreach config,$(CONFIGS), \ 65 $(if $(filter y m,$(value $(value config))), \ 66 -D$(value config)=1)) 67 68# 69# KBUILD_EXTRA_SYMBOLS to prevent warnings about unknown functions 70# 71EXTRA_SYMBOLS += $(CURDIR)/../../../../../drivers/gpu/arm/midgard/Module.symvers 72EXTRA_SYMBOLS += $(CURDIR)/../../../../../drivers/hwtracing/coresight/mali/Module.symvers 73 74# The following were added to align with W=1 in scripts/Makefile.extrawarn 75# from the Linux source tree 76KBUILD_CFLAGS += -Wall -Werror 77KBUILD_CFLAGS += -Wextra -Wunused -Wno-unused-parameter 78KBUILD_CFLAGS += -Wmissing-declarations 79KBUILD_CFLAGS += -Wmissing-format-attribute 80KBUILD_CFLAGS += -Wmissing-prototypes 81KBUILD_CFLAGS += -Wold-style-definition 82KBUILD_CFLAGS += -Wmissing-include-dirs 83KBUILD_CFLAGS += $(call cc-option, -Wunused-but-set-variable) 84KBUILD_CFLAGS += $(call cc-option, -Wunused-const-variable) 85KBUILD_CFLAGS += $(call cc-option, -Wpacked-not-aligned) 86KBUILD_CFLAGS += $(call cc-option, -Wstringop-truncation) 87# The following turn off the warnings enabled by -Wextra 88KBUILD_CFLAGS += -Wno-missing-field-initializers 89KBUILD_CFLAGS += -Wno-sign-compare 90KBUILD_CFLAGS += -Wno-type-limits 91 92KBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN1 93 94all: 95 $(MAKE) -C $(KDIR) M=$(CURDIR) $(MAKE_ARGS) EXTRA_CFLAGS="$(EXTRA_CFLAGS)" KBUILD_EXTRA_SYMBOLS="$(EXTRA_SYMBOLS)" modules 96 97modules_install: 98 $(MAKE) -C $(KDIR) M=$(CURDIR) $(MAKE_ARGS) modules_install 99 100clean: 101 $(MAKE) -C $(KDIR) M=$(CURDIR) $(MAKE_ARGS) clean 102