blob: 86cef2c20fb263613d62eed78335900b0c419da9 [file] [log] [blame]
Per Åstrand87ca5da2021-04-15 09:47:03 +02001#
Per Åstrand087ea212022-04-06 09:40:11 +02002# Copyright (c) 2020-2022 Arm Limited. All rights reserved.
Per Åstrand87ca5da2021-04-15 09:47:03 +02003#
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
21cmake_minimum_required(VERSION 3.0.2)
22
23# Set the project name and version
24project("ethosu_remoteproc" VERSION 1.0)
25
26# Make sure KDIR is set
27set(KDIR "" CACHE PATH "Path to Linux kernel sources")
28if (NOT EXISTS ${KDIR})
29 message(FATAL_ERROR "Can't build kernel module without KDIR.")
30endif()
31
32# Depend on all h and c files
33file(GLOB_RECURSE SOURCES RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c" "*.h")
34
35file(GLOB_RECURSE OBJ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*.c")
36list(TRANSFORM OBJ REPLACE "^(.*)[.]c" "\\1.o")
37list(TRANSFORM OBJ PREPEND ${CMAKE_CURRENT_SOURCE_DIR}/)
38
Davide Grohmann43e7dc42022-08-22 09:54:42 +020039set(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 +020040
Per Åstrand87ca5da2021-04-15 09:47:03 +020041# Build the kernel module
42add_custom_target(ethosu-remoteproc-module ALL
43 COMMAND ${CMAKE_MAKE_PROGRAM} -C ${KDIR}
44 EXTRA_CFLAGS=-I${KDIR}/../../../drivers/remoteproc M=${CMAKE_CURRENT_SOURCE_DIR}
Per Åstrand9f36f2e2021-09-30 09:57:34 +020045 ${MODULES}
Lior Dekelc3f4a832021-12-02 10:58:12 +020046 CROSS_COMPILE=${CROSS_COMPILE} ARCH=${ARCH} modules
Per Åstrand87ca5da2021-04-15 09:47:03 +020047 BYPRODUCTS
48 ${CMAKE_CURRENT_SOURCE_DIR}/ethosu_remoteproc.ko
49 ${CMAKE_CURRENT_SOURCE_DIR}/ethosu_remoteproc.mod.o
50 ${CMAKE_CURRENT_SOURCE_DIR}/modules.order
51 ${CMAKE_CURRENT_SOURCE_DIR}/Module.symvers
52 ${OBJ}
53 DEPENDS ${SOURCES} Kbuild Kconfig
Per Åstrand9f36f2e2021-09-30 09:57:34 +020054 COMMENT "Building remoteproc modules"
Per Åstrand87ca5da2021-04-15 09:47:03 +020055 VERBATIM)
56
Per Åstrand087ea212022-04-06 09:40:11 +020057install(FILES ethosu_remoteproc.ko DESTINATION "modules")
58install(FILES corstone1000_es_reset.ko DESTINATION "modules")