blob: 236b0ea25e5171156dab88db073608108cf7d3cb [file] [log] [blame]
Kristofer Jonsson116a6352020-08-20 17:25:23 +02001#
Kristofer Jonsson35de9e62022-03-08 13:25:45 +01002# Copyright (c) 2020-2022 Arm Limited.
Kristofer Jonsson116a6352020-08-20 17:25:23 +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#
Davide Grohmannf0364232022-06-16 17:42:58 +020020
Kristofer Jonsson116a6352020-08-20 17:25:23 +020021cmake_minimum_required(VERSION 3.0.2)
22
23# Set the project name and version
24project("ethosu_kernel" 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
35# Build the kernel module
36add_custom_target(kernel ALL
Lior Dekelc3f4a832021-12-02 10:58:12 +020037 COMMAND ${CMAKE_MAKE_PROGRAM} -C ${KDIR} M=${CMAKE_CURRENT_SOURCE_DIR} CONFIG_ETHOSU=m CROSS_COMPILE=${CROSS_COMPILE} ARCH=${ARCH} modules
Kristofer Jonsson116a6352020-08-20 17:25:23 +020038 BYPRODUCTS ethosu.ko
39 DEPENDS ${SOURCES} Kbuild Kconfig
40 COMMENT "Building ethosu.ko"
41 VERBATIM)
42
43# Install the kernel object and headers
44install(FILES ethosu.ko DESTINATION "modules")
45install(FILES "uapi/ethosu.h" DESTINATION "include/uapi")