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(libsel4muslcsys C) 16 17set(configure_string "") 18 19config_string(LibSel4MuslcSysMorecoreBytes LIB_SEL4_MUSLC_SYS_MORECORE_BYTES "Malloc limit \ 20 This value sets the number of bytes reserved for the region malloc \ 21 allocates from. Note that you won't actually be able to allocate this \ 22 entire amount because there is some bookkeeping overhead. This area is \ 23 allocated statically." DEFAULT 1048576 UNQUOTE) 24 25config_option( 26 LibSel4MuslcSysDebugHalt 27 LIB_SEL4_MUSLC_SYS_DEBUG_HALT 28 "Perform seL4_DebugHalt on _exit and _abort \ 29 Controls whether or not a DebugHalt should be called to implement Exit \ 30 style syscalls. This is useful if you have a single app and thread, but \ 31 should be turned off if using multiple threads that may wish to exit \ 32 independently of the whole system" 33 DEFAULT 34 ON 35) 36 37config_option( 38 LibSel4MuslcSysCPIOFS 39 LIB_SEL4_MUSLC_SYS_CPIO_FS 40 "Implementation of a simple file system usi g CPIO archives \ 41 If this is enabled open and read syscalls will attempt to use the cpio archive \ 42 _cpio_archive. This implements a basic read only POSIX interface to that file system" 43 DEFAULT 44 OFF 45) 46 47config_option( 48 LibSel4MuslcSysArchPutcharWeak 49 LIB_SEL4_MUSLC_SYS_ARCH_PUTCHAR_WEAK 50 "Make __arch_putchar a weak symbol \ 51 This allows you to override __arch_putchar in another library or your \ 52 application." 53 DEFAULT 54 OFF 55) 56 57config_string( 58 LibSel4MuslcSysConstructorPriority 59 LIB_SEL4_MUSLC_SYS_CONSTRUCTOR_PRIORITY 60 "Set the priority of the muslc initialisation constructors such that 61 they occur after external initialisation of the system call 62 dependencies." 63 DEFAULT 64 "MUSLCSYS_WITH_VSYSCALL_PRIORITY + 10" 65 UNQUOTE 66) 67mark_as_advanced( 68 LibSel4MuslcSysMorecoreBytes 69 LibSel4MuslcSysDebugHalt 70 LibSel4MuslcSysCPIOFS 71 LibSel4MuslcSysArchPutcharWeak 72) 73add_config_library(sel4muslcsys "${configure_string}") 74 75file(GLOB deps src/*.c) 76 77list(SORT deps) 78 79# TODO: This use to be calculated by the following line. Need to use a generator expression and generate 80# this into a header file at build time 81# MUSLC_HIGHEST_SYSCALL := $(shell cat $(STAGE_DIR)/include/bits/syscall.h | sed 's/^.*[^0-9]\([0-9]*\)$$/\1/' | sort -nr | head -1) 82set(HighestSyscall 400) 83 84set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_XOPEN_SOURCE=700 -DMUSLC_HIGHEST_SYSCALL=${HighestSyscall}") 85 86add_library(sel4muslcsys STATIC EXCLUDE_FROM_ALL ${deps}) 87# Force the muslcsys_init_muslc constructor to be included in dependants 88target_link_options(sel4muslcsys BEFORE INTERFACE "-Wl,-umuslcsys_init_muslc") 89target_include_directories(sel4muslcsys PUBLIC include) 90target_link_libraries( 91 sel4muslcsys 92 PUBLIC 93 # These quotes are needed to prevent cmake splitting these arguments 94 "-Wl,-u -Wl,__vsyscall_ptr" 95 muslc 96 sel4 97 cpio 98 utils 99 sel4utils 100 sel4muslcsys_Config 101 PRIVATE sel4_autoconf 102) 103