1#
2# Copyright 2017, Data61
3# Commonwealth Scientific and Industrial Research Organisation (CSIRO)
4# ABN 41 687 119 230.
5#
6# This software may be distributed and modified according to the terms of
7# the BSD 2-Clause license. Note that NO WARRANTY is provided.
8# See "LICENSE_BSD2.txt" for details.
9#
10# @TAG(DATA61_BSD)
11#
12
13cmake_minimum_required(VERSION 3.7.2)
14
15project(libsel4platsupport C ASM)
16
17set(configure_string "")
18
19config_option(
20    LibSel4PlatSupportUseDebugPutChar
21    LIB_SEL4_PLAT_SUPPORT_USE_SEL4_DEBUG_PUTCHAR
22    "Redirect putchar() to seL4_DebugPutchar()"
23    DEFAULT
24    ON
25    DEPENDS
26    "KernelPrinting"
27    DEFAULT_DISABLED
28    OFF
29)
30
31config_option(
32    LibSel4PlatSupportStart
33    LIB_SEL4_PLAT_SUPPORT_START
34    "Supply _start entry point. Emit _start with a default definition that sets up a \
35    stack and does what's required to enter main()."
36    DEFAULT
37    OFF
38)
39
40config_option(
41    LibSel4SupportSel4Start
42    LIB_SEL4_PLAT_SUPPORT_SEL4_START
43    "Supply _sel4_start entry point. Emit a _sel4_start that sets up a stack and does \
44    what's required to enter a regular _start routine"
45    DEFAULT
46    ON
47)
48mark_as_advanced(LibSel4PlatSupportUseDebugPutChar LibSel4PlatSupportStart LibSel4SupportSel4Start)
49add_config_library(sel4platsupport "${configure_string}")
50
51if(KernelArchRiscV)
52    set(kernel_arch arm)
53else()
54    set(kernel_arch ${KernelArch})
55endif()
56
57file(
58    GLOB
59        deps
60        src/*.c
61        src/cspace/*.c
62        src/arch/${kernel_arch}/*.c
63        src/plat/${KernelPlatform}/*.c
64        src/mach/${KernelArmMach}/*.c
65        src/sel4_arch/${KernelSel4Arch}/*.S
66        src/arch/${kernel_arch}/*.S
67)
68
69list(SORT deps)
70
71add_library(sel4platsupport STATIC EXCLUDE_FROM_ALL ${deps})
72target_include_directories(
73    sel4platsupport
74    PUBLIC include "arch_include/${kernel_arch}" plat_include/${KernelPlatform}
75)
76if(NOT "${KernelArmMach}" STREQUAL "")
77    target_include_directories(sel4platsupport PUBLIC include "mach_include/${KernelArmMach}")
78endif()
79target_link_libraries(
80    sel4platsupport
81    PUBLIC
82        muslc
83        sel4
84        sel4runtime
85        sel4simple
86        utils
87        sel4vspace
88        platsupport
89        sel4simple-default
90    PRIVATE sel4platsupport_Config sel4muslcsys_Config sel4_autoconf
91)
92