xref: /OK3568_Linux_fs/kernel/drivers/base/arm/Makefile (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
2*4882a593Smuzhiyun#
3*4882a593Smuzhiyun# (C) COPYRIGHT 2021-2022 ARM Limited. All rights reserved.
4*4882a593Smuzhiyun#
5*4882a593Smuzhiyun# This program is free software and is provided to you under the terms of the
6*4882a593Smuzhiyun# GNU General Public License version 2 as published by the Free Software
7*4882a593Smuzhiyun# Foundation, and any use by you of this program is subject to the terms
8*4882a593Smuzhiyun# of such GNU license.
9*4882a593Smuzhiyun#
10*4882a593Smuzhiyun# This program is distributed in the hope that it will be useful,
11*4882a593Smuzhiyun# but WITHOUT ANY WARRANTY; without even the implied warranty of
12*4882a593Smuzhiyun# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13*4882a593Smuzhiyun# GNU General Public License for more details.
14*4882a593Smuzhiyun#
15*4882a593Smuzhiyun# You should have received a copy of the GNU General Public License
16*4882a593Smuzhiyun# along with this program; if not, you can access it online at
17*4882a593Smuzhiyun# http://www.gnu.org/licenses/gpl-2.0.html.
18*4882a593Smuzhiyun#
19*4882a593Smuzhiyun#
20*4882a593Smuzhiyun
21*4882a593Smuzhiyun#
22*4882a593Smuzhiyun# Paths
23*4882a593Smuzhiyun#
24*4882a593SmuzhiyunKERNEL_SRC ?= /lib/modules/$(shell uname -r)/build
25*4882a593SmuzhiyunKDIR ?= $(KERNEL_SRC)
26*4882a593Smuzhiyun
27*4882a593Smuzhiyunifeq ($(KDIR),)
28*4882a593Smuzhiyun    $(error Must specify KDIR to point to the kernel to target))
29*4882a593Smuzhiyunendif
30*4882a593Smuzhiyun
31*4882a593Smuzhiyunvars :=
32*4882a593Smuzhiyun#
33*4882a593Smuzhiyun# Default configuration values
34*4882a593Smuzhiyun#
35*4882a593SmuzhiyunCONFIG_MALI_BASE_MODULES ?= n
36*4882a593Smuzhiyun
37*4882a593Smuzhiyunifeq ($(CONFIG_MALI_BASE_MODULES),y)
38*4882a593Smuzhiyun    CONFIG_MALI_CSF_SUPPORT ?= n
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun    ifneq ($(CONFIG_DMA_SHARED_BUFFER),n)
41*4882a593Smuzhiyun        CONFIG_DMA_SHARED_BUFFER_TEST_EXPORTER ?= y
42*4882a593Smuzhiyun    else
43*4882a593Smuzhiyun        # Prevent misuse when CONFIG_DMA_SHARED_BUFFER=n
44*4882a593Smuzhiyun        CONFIG_DMA_SHARED_BUFFER_TEST_EXPORTER = n
45*4882a593Smuzhiyun    endif
46*4882a593Smuzhiyun
47*4882a593Smuzhiyun    CONFIG_MALI_MEMORY_GROUP_MANAGER ?= y
48*4882a593Smuzhiyun
49*4882a593Smuzhiyun    ifneq ($(CONFIG_MALI_CSF_SUPPORT), n)
50*4882a593Smuzhiyun        CONFIG_MALI_PROTECTED_MEMORY_ALLOCATOR ?= y
51*4882a593Smuzhiyun    endif
52*4882a593Smuzhiyun
53*4882a593Smuzhiyunelse
54*4882a593Smuzhiyun    # Prevent misuse when CONFIG_MALI_BASE_MODULES=n
55*4882a593Smuzhiyun    CONFIG_DMA_SHARED_BUFFER_TEST_EXPORTER = n
56*4882a593Smuzhiyun    CONFIG_MALI_MEMORY_GROUP_MANAGER = n
57*4882a593Smuzhiyun    CONFIG_MALI_PROTECTED_MEMORY_ALLOCATOR = n
58*4882a593Smuzhiyun
59*4882a593Smuzhiyunendif
60*4882a593Smuzhiyun
61*4882a593SmuzhiyunCONFIGS := \
62*4882a593Smuzhiyun    CONFIG_MALI_BASE_MODULES \
63*4882a593Smuzhiyun    CONFIG_MALI_CSF_SUPPORT \
64*4882a593Smuzhiyun    CONFIG_DMA_SHARED_BUFFER_TEST_EXPORTER \
65*4882a593Smuzhiyun    CONFIG_MALI_MEMORY_GROUP_MANAGER \
66*4882a593Smuzhiyun    CONFIG_MALI_PROTECTED_MEMORY_ALLOCATOR \
67*4882a593Smuzhiyun
68*4882a593Smuzhiyun
69*4882a593Smuzhiyun#
70*4882a593Smuzhiyun# MAKE_ARGS to pass the custom CONFIGs on out-of-tree build
71*4882a593Smuzhiyun#
72*4882a593Smuzhiyun# Generate the list of CONFIGs and values.
73*4882a593Smuzhiyun# $(value config) is the name of the CONFIG option.
74*4882a593Smuzhiyun# $(value $(value config)) is its value (y, m).
75*4882a593Smuzhiyun# When the CONFIG is not set to y or m, it defaults to n.
76*4882a593SmuzhiyunMAKE_ARGS := $(foreach config,$(CONFIGS), \
77*4882a593Smuzhiyun                    $(if $(filter y m,$(value $(value config))), \
78*4882a593Smuzhiyun                        $(value config)=$(value $(value config)), \
79*4882a593Smuzhiyun                        $(value config)=n))
80*4882a593Smuzhiyun
81*4882a593Smuzhiyun#
82*4882a593Smuzhiyun# EXTRA_CFLAGS to define the custom CONFIGs on out-of-tree build
83*4882a593Smuzhiyun#
84*4882a593Smuzhiyun# Generate the list of CONFIGs defines with values from CONFIGS.
85*4882a593Smuzhiyun# $(value config) is the name of the CONFIG option.
86*4882a593Smuzhiyun# When set to y or m, the CONFIG gets defined to 1.
87*4882a593SmuzhiyunEXTRA_CFLAGS := $(foreach config,$(CONFIGS), \
88*4882a593Smuzhiyun                    $(if $(filter y m,$(value $(value config))), \
89*4882a593Smuzhiyun                        -D$(value config)=1))
90*4882a593Smuzhiyun
91*4882a593SmuzhiyunKBUILD_CFLAGS += -Wall -Werror
92*4882a593Smuzhiyun
93*4882a593Smuzhiyunifeq ($(CONFIG_GCOV_KERNEL), y)
94*4882a593Smuzhiyun    KBUILD_CFLAGS += $(call cc-option, -ftest-coverage)
95*4882a593Smuzhiyun    KBUILD_CFLAGS += $(call cc-option, -fprofile-arcs)
96*4882a593Smuzhiyun    EXTRA_CFLAGS += -DGCOV_PROFILE=1
97*4882a593Smuzhiyunendif
98*4882a593Smuzhiyun
99*4882a593Smuzhiyunifeq ($(CONFIG_MALI_KCOV),y)
100*4882a593Smuzhiyun    KBUILD_CFLAGS += $(call cc-option, -fsanitize-coverage=trace-cmp)
101*4882a593Smuzhiyun    EXTRA_CFLAGS += -DKCOV=1
102*4882a593Smuzhiyun    EXTRA_CFLAGS += -DKCOV_ENABLE_COMPARISONS=1
103*4882a593Smuzhiyunendif
104*4882a593Smuzhiyun
105*4882a593Smuzhiyun# The following were added to align with W=1 in scripts/Makefile.extrawarn
106*4882a593Smuzhiyun# from the Linux source tree (v5.18.14)
107*4882a593SmuzhiyunKBUILD_CFLAGS += -Wextra -Wunused -Wno-unused-parameter
108*4882a593SmuzhiyunKBUILD_CFLAGS += -Wmissing-declarations
109*4882a593SmuzhiyunKBUILD_CFLAGS += -Wmissing-format-attribute
110*4882a593SmuzhiyunKBUILD_CFLAGS += -Wmissing-prototypes
111*4882a593SmuzhiyunKBUILD_CFLAGS += -Wold-style-definition
112*4882a593Smuzhiyun# The -Wmissing-include-dirs cannot be enabled as the path to some of the
113*4882a593Smuzhiyun# included directories change depending on whether it is an in-tree or
114*4882a593Smuzhiyun# out-of-tree build.
115*4882a593SmuzhiyunKBUILD_CFLAGS += $(call cc-option, -Wunused-but-set-variable)
116*4882a593SmuzhiyunKBUILD_CFLAGS += $(call cc-option, -Wunused-const-variable)
117*4882a593SmuzhiyunKBUILD_CFLAGS += $(call cc-option, -Wpacked-not-aligned)
118*4882a593SmuzhiyunKBUILD_CFLAGS += $(call cc-option, -Wstringop-truncation)
119*4882a593Smuzhiyun# The following turn off the warnings enabled by -Wextra
120*4882a593SmuzhiyunKBUILD_CFLAGS += -Wno-sign-compare
121*4882a593SmuzhiyunKBUILD_CFLAGS += -Wno-shift-negative-value
122*4882a593Smuzhiyun# This flag is needed to avoid build errors on older kernels
123*4882a593SmuzhiyunKBUILD_CFLAGS += $(call cc-option, -Wno-cast-function-type)
124*4882a593Smuzhiyun
125*4882a593SmuzhiyunKBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN1
126*4882a593Smuzhiyun
127*4882a593Smuzhiyun# The following were added to align with W=2 in scripts/Makefile.extrawarn
128*4882a593Smuzhiyun# from the Linux source tree (v5.18.14)
129*4882a593SmuzhiyunKBUILD_CFLAGS += -Wdisabled-optimization
130*4882a593Smuzhiyun# The -Wshadow flag cannot be enabled unless upstream kernels are
131*4882a593Smuzhiyun# patched to fix redefinitions of certain built-in functions and
132*4882a593Smuzhiyun# global variables.
133*4882a593SmuzhiyunKBUILD_CFLAGS += $(call cc-option, -Wlogical-op)
134*4882a593SmuzhiyunKBUILD_CFLAGS += -Wmissing-field-initializers
135*4882a593Smuzhiyun# -Wtype-limits must be disabled due to build failures on kernel 5.x
136*4882a593SmuzhiyunKBUILD_CFLAGS += -Wno-type-limit
137*4882a593SmuzhiyunKBUILD_CFLAGS += $(call cc-option, -Wmaybe-uninitialized)
138*4882a593SmuzhiyunKBUILD_CFLAGS += $(call cc-option, -Wunused-macros)
139*4882a593Smuzhiyun
140*4882a593SmuzhiyunKBUILD_CPPFLAGS += -DKBUILD_EXTRA_WARN2
141*4882a593Smuzhiyun
142*4882a593Smuzhiyun# This warning is disabled to avoid build failures in some kernel versions
143*4882a593SmuzhiyunKBUILD_CFLAGS += -Wno-ignored-qualifiers
144*4882a593Smuzhiyun
145*4882a593Smuzhiyunall:
146*4882a593Smuzhiyun	$(MAKE) -C $(KDIR) M=$(CURDIR) $(MAKE_ARGS) EXTRA_CFLAGS="$(EXTRA_CFLAGS)" KBUILD_EXTRA_SYMBOLS="$(EXTRA_SYMBOLS)" modules
147*4882a593Smuzhiyun
148*4882a593Smuzhiyunmodules_install:
149*4882a593Smuzhiyun	$(MAKE) -C $(KDIR) M=$(CURDIR) $(MAKE_ARGS) modules_install
150*4882a593Smuzhiyun
151*4882a593Smuzhiyunclean:
152*4882a593Smuzhiyun	$(MAKE) -C $(KDIR) M=$(CURDIR) $(MAKE_ARGS) clean
153