blob: c7f7ab8ff566ca708029835e33b4c4d9d5e07af5 [file] [log] [blame]
Per Åstrand87ca5da2021-04-15 09:47:03 +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
Per Åstrand87ca5da2021-04-15 09:47:03 +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#
Per Åstrand87ca5da2021-04-15 09:47:03 +020019
20cmake_minimum_required(VERSION 3.0.2)
21
22# Set the project name and version
23project("ethosu_remoteproc" 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
34file(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
Davide Grohmann43e7dc42022-08-22 09:54:42 +020038set(MODULES CONFIG_ARM_ETHOSU_RPROC=m CONFIG_ARM_JUNO_FPGA_RESET=m CONFIG_ARM_CORSTONE1000_ES_RESET=m)
Per Åstrand9f36f2e2021-09-30 09:57:34 +020039
Per Åstrand87ca5da2021-04-15 09:47:03 +020040# Build the kernel module
41add_custom_target(ethosu-remoteproc-module ALL
42 COMMAND ${CMAKE_MAKE_PROGRAM} -C ${KDIR}
Mikael Olssonc1a418d2023-10-31 10:49:06 +010043 EXTRA_CFLAGS=-I${KDIR}/../../../drivers/remoteproc C=2 M=${CMAKE_CURRENT_SOURCE_DIR}
Per Åstrand9f36f2e2021-09-30 09:57:34 +020044 ${MODULES}
Lior Dekelc3f4a832021-12-02 10:58:12 +020045 CROSS_COMPILE=${CROSS_COMPILE} ARCH=${ARCH} modules
Per Åstrand87ca5da2021-04-15 09:47:03 +020046 BYPRODUCTS
47 ${CMAKE_CURRENT_SOURCE_DIR}/ethosu_remoteproc.ko
48 ${CMAKE_CURRENT_SOURCE_DIR}/ethosu_remoteproc.mod.o
49 ${CMAKE_CURRENT_SOURCE_DIR}/modules.order
50 ${CMAKE_CURRENT_SOURCE_DIR}/Module.symvers
51 ${OBJ}
52 DEPENDS ${SOURCES} Kbuild Kconfig
Per Åstrand9f36f2e2021-09-30 09:57:34 +020053 COMMENT "Building remoteproc modules"
Per Åstrand87ca5da2021-04-15 09:47:03 +020054 VERBATIM)
55
Per Åstrand087ea212022-04-06 09:40:11 +020056install(FILES ethosu_remoteproc.ko DESTINATION "modules")
57install(FILES corstone1000_es_reset.ko DESTINATION "modules")