Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 1 | # |
Kristofer Jonsson | 35de9e6 | 2022-03-08 13:25:45 +0100 | [diff] [blame] | 2 | # Copyright (c) 2020-2022 Arm Limited. |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 3 | # |
| 4 | # This program is free software and is provided to you under the terms of the |
| 5 | # GNU General Public License version 2 as published by the Free Software |
| 6 | # Foundation, and any use by you of this program is subject to the terms |
| 7 | # of such GNU licence. |
| 8 | # |
| 9 | # This program is distributed in the hope that it will be useful, |
| 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | # GNU General Public License for more details. |
| 13 | # |
| 14 | # You should have received a copy of the GNU General Public License |
| 15 | # along with this program; if not, you can access it online at |
| 16 | # http://www.gnu.org/licenses/gpl-2.0.html. |
| 17 | # |
| 18 | # SPDX-License-Identifier: GPL-2.0-only |
| 19 | # |
| 20 | |
| 21 | cmake_minimum_required(VERSION 3.0.2) |
| 22 | |
| 23 | # Set the project name and version |
| 24 | project("mhu-mailbox" VERSION 1.0) |
| 25 | |
| 26 | # Make sure KDIR is set |
| 27 | set(KDIR "" CACHE PATH "Path to Linux kernel sources") |
| 28 | if (NOT EXISTS ${KDIR}) |
| 29 | message(FATAL_ERROR "Can't build kernel module without KDIR.") |
| 30 | endif() |
| 31 | |
| 32 | # Depend on all h and c files |
| 33 | file(GLOB_RECURSE SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c" "*.h") |
| 34 | |
Per Åstrand | bb4089d | 2020-10-05 11:00:23 +0200 | [diff] [blame] | 35 | file(GLOB_RECURSE OBJ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c") |
| 36 | list(TRANSFORM OBJ REPLACE "^(.*)[.]c" "\\1.o") |
| 37 | list(TRANSFORM OBJ PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/) |
| 38 | |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 39 | # Build the kernel module |
| 40 | add_custom_target(mailbox-module ALL |
Per Åstrand | bb4089d | 2020-10-05 11:00:23 +0200 | [diff] [blame] | 41 | COMMAND ${CMAKE_MAKE_PROGRAM} -C ${KDIR} |
| 42 | M=${CMAKE_CURRENT_SOURCE_DIR} CONFIG_ARM_MHU_V2=m CONFIG_ARM_MHU=m |
Lior Dekel | c3f4a83 | 2021-12-02 10:58:12 +0200 | [diff] [blame] | 43 | CROSS_COMPILE=${CROSS_COMPILE} ARCH=${ARCH} modules |
Per Åstrand | bb4089d | 2020-10-05 11:00:23 +0200 | [diff] [blame] | 44 | BYPRODUCTS |
| 45 | ${CMAKE_CURRENT_SOURCE_DIR}/arm_mhu.ko |
| 46 | ${CMAKE_CURRENT_SOURCE_DIR}/arm_mhu.o |
| 47 | ${CMAKE_CURRENT_SOURCE_DIR}/arm_mhu.mod.o |
| 48 | ${CMAKE_CURRENT_SOURCE_DIR}/arm_mhu.mod.c |
| 49 | ${CMAKE_CURRENT_SOURCE_DIR}/arm_mhu_v2.ko |
| 50 | ${CMAKE_CURRENT_SOURCE_DIR}/arm_mhu_v2.o |
| 51 | ${CMAKE_CURRENT_SOURCE_DIR}/arm_mhu_v2.mod.o |
| 52 | ${CMAKE_CURRENT_SOURCE_DIR}/arm_mhu_v2.mod.c |
| 53 | ${CMAKE_CURRENT_SOURCE_DIR}/modules.order |
| 54 | ${CMAKE_CURRENT_SOURCE_DIR}/Module.symvers |
| 55 | ${OBJ} |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 56 | DEPENDS ${SOURCES} Kbuild Kconfig |
Per Åstrand | bb4089d | 2020-10-05 11:00:23 +0200 | [diff] [blame] | 57 | COMMENT "Building arm_mhu.ko arm_mhu_v2.ko" |
Kristofer Jonsson | 116a635 | 2020-08-20 17:25:23 +0200 | [diff] [blame] | 58 | VERBATIM) |
Per Åstrand | bb4089d | 2020-10-05 11:00:23 +0200 | [diff] [blame] | 59 | |
Lior Dekel | c3f4a83 | 2021-12-02 10:58:12 +0200 | [diff] [blame] | 60 | install(FILES arm_mhu.ko arm_mhu_v2.ko DESTINATION "modules") |