blob: 0192bdcb9c16637ccad06b11e5e8356256115994 [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#
Davide Grohmannf0364232022-06-16 17:42:58 +020019
Kristofer Jonsson116a6352020-08-20 17:25:23 +020020cmake_minimum_required(VERSION 3.0.2)
21
22# Set the project name and version
23project("ethosu_kernel" 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
34# Build the kernel module
35add_custom_target(kernel ALL
Mikael Olsson47e9bd02023-11-14 10:43:30 +010036 COMMAND ${CMAKE_MAKE_PROGRAM} -C ${KDIR} CF=-Wsparse-error C=2 M=${CMAKE_CURRENT_SOURCE_DIR} CONFIG_ETHOSU=m CROSS_COMPILE=${CROSS_COMPILE} ARCH=${ARCH} modules
Kristofer Jonsson116a6352020-08-20 17:25:23 +020037 BYPRODUCTS ethosu.ko
38 DEPENDS ${SOURCES} Kbuild Kconfig
39 COMMENT "Building ethosu.ko"
40 VERBATIM)
41
42# Install the kernel object and headers
43install(FILES ethosu.ko DESTINATION "modules")
44install(FILES "uapi/ethosu.h" DESTINATION "include/uapi")