blob: 0586a462530f51f926da977ab4bf4ac83bbe2514 [file] [log] [blame]
Kristofer Jonsson116a6352020-08-20 17:25:23 +02001#
Mikael Olssonc1a418d2023-10-31 10:49:06 +01002# SPDX-FileCopyrightText: Copyright 2020-2023 Arm Limited and/or its affiliates <open-source-office@arm.com>
3# SPDX-License-Identifier: GPL-2.0-only
Kristofer Jonsson116a6352020-08-20 17:25:23 +02004#
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 licence.
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#
Kristofer Jonsson116a6352020-08-20 17:25:23 +020019
20cmake_minimum_required(VERSION 3.0.2)
21
22# Set the project name and version
23project("mhu-mailbox" VERSION 1.0)
24
25# Make sure KDIR is set
26set(KDIR "" CACHE PATH "Path to Linux kernel sources")
27if (NOT EXISTS ${KDIR})
28 message(FATAL_ERROR "Can't build kernel module without KDIR.")
29endif()
30
31# Depend on all h and c files
32file(GLOB_RECURSE SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c" "*.h")
33
Per Åstrandbb4089d2020-10-05 11:00:23 +020034file(GLOB_RECURSE OBJ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c")
35list(TRANSFORM OBJ REPLACE "^(.*)[.]c" "\\1.o")
36list(TRANSFORM OBJ PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/)
37
Kristofer Jonsson116a6352020-08-20 17:25:23 +020038# Build the kernel module
39add_custom_target(mailbox-module ALL
Per Åstrandbb4089d2020-10-05 11:00:23 +020040 COMMAND ${CMAKE_MAKE_PROGRAM} -C ${KDIR}
Mikael Olsson47e9bd02023-11-14 10:43:30 +010041 CF=-Wsparse-error C=2 M=${CMAKE_CURRENT_SOURCE_DIR} CONFIG_ARM_MHU_V2=m CONFIG_ARM_MHU=m
Lior Dekelc3f4a832021-12-02 10:58:12 +020042 CROSS_COMPILE=${CROSS_COMPILE} ARCH=${ARCH} modules
Per Åstrandbb4089d2020-10-05 11:00:23 +020043 BYPRODUCTS
44 ${CMAKE_CURRENT_SOURCE_DIR}/arm_mhu.ko
45 ${CMAKE_CURRENT_SOURCE_DIR}/arm_mhu.o
46 ${CMAKE_CURRENT_SOURCE_DIR}/arm_mhu.mod.o
47 ${CMAKE_CURRENT_SOURCE_DIR}/arm_mhu.mod.c
48 ${CMAKE_CURRENT_SOURCE_DIR}/arm_mhu_v2.ko
49 ${CMAKE_CURRENT_SOURCE_DIR}/arm_mhu_v2.o
50 ${CMAKE_CURRENT_SOURCE_DIR}/arm_mhu_v2.mod.o
51 ${CMAKE_CURRENT_SOURCE_DIR}/arm_mhu_v2.mod.c
52 ${CMAKE_CURRENT_SOURCE_DIR}/modules.order
53 ${CMAKE_CURRENT_SOURCE_DIR}/Module.symvers
54 ${OBJ}
Kristofer Jonsson116a6352020-08-20 17:25:23 +020055 DEPENDS ${SOURCES} Kbuild Kconfig
Per Åstrandbb4089d2020-10-05 11:00:23 +020056 COMMENT "Building arm_mhu.ko arm_mhu_v2.ko"
Kristofer Jonsson116a6352020-08-20 17:25:23 +020057 VERBATIM)
Per Åstrandbb4089d2020-10-05 11:00:23 +020058
Mikael Olssonc1a418d2023-10-31 10:49:06 +010059install(FILES arm_mhu.ko arm_mhu_v2.ko DESTINATION "modules")