1# 2# SPDX-License-Identifier: BSD-3-Clause 3# 4# Copyright © 2019 Keith Packard 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: 9# 10# 1. Redistributions of source code must retain the above copyright 11# notice, this list of conditions and the following disclaimer. 12# 13# 2. Redistributions in binary form must reproduce the above 14# copyright notice, this list of conditions and the following 15# disclaimer in the documentation and/or other materials provided 16# with the distribution. 17# 18# 3. Neither the name of the copyright holder nor the names of its 19# contributors may be used to endorse or promote products derived 20# from this software without specific prior written permission. 21# 22# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 27# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33# OF THE POSSIBILITY OF SUCH DAMAGE. 34# 35 36has_arm_semihost = false 37 38src_semihost = [] 39 40machine_dir = 'machine' / host_cpu_family 41if fs.is_dir(machine_dir) 42 subdir(machine_dir) 43endif 44 45# If host_cpu_family supports ARM-style semihosting, the meson.build 46# will add the support files to src_semihost. Check to see if that 47# happened and add the rest of the needed files 48 49if src_semihost != [] 50 src_semihost += files([ 51 'close.c', 52 'exit.c', 53 'fstat.c', 54 'getentropy.c', 55 'gettimeofday.c', 56 'isatty.c', 57 'kill.c', 58 'lseek.c', 59 'lseek64.c', 60 'mapstdio.c', 61 'open.c', 62 'read.c', 63 'sysconf.c', 64 'times.c', 65 'unlink.c', 66 'write.c', 67 'sys_clock.c', 68 'sys_close.c', 69 'sys_elapsed.c', 70 'sys_errno.c', 71 'sys_exit.c', 72 'sys_exit_extended.c', 73 'sys_feature.c', 74 'sys_flen.c', 75 'sys_get_cmdline.c', 76 'sys_getc.c', 77 'sys_heapinfo.c', 78 'sys_iserror.c', 79 'sys_istty.c', 80 'sys_open.c', 81 'sys_putc.c', 82 'sys_read.c', 83 'sys_remove.c', 84 'sys_rename.c', 85 'sys_seek.c', 86 'sys_system.c', 87 'sys_tickfreq.c', 88 'sys_time.c', 89 'sys_tmpnam.c', 90 'sys_write.c', 91 'sys_write0.c', 92 ]) 93 94 if tinystdio 95 src_semihost += 'iob.c' 96 endif 97 98 install_headers('semihost.h', 99 install_dir: include_dir 100 ) 101 102 inc = [inc, include_directories('.')] 103 104 has_semihost = true 105 106 has_arm_semihost = true 107 108 has_semihost_args = true 109 110 foreach target : targets 111 value = get_variable('target_' + target) 112 113 instdir = join_paths(lib_dir, value[0]) 114 115 if target == '' 116 libsemihost_name = 'semihost' 117 else 118 libsemihost_name = join_paths(target, 'libsemihost') 119 endif 120 121 set_variable('lib_semihost' + target, 122 static_library(libsemihost_name, 123 src_semihost, 124 install : true, 125 install_dir : instdir, 126 include_directories : inc, 127 c_args : value[1] + c_args)) 128 129 endforeach 130endif 131 132if not has_semihost and get_option('fake-semihost') 133 subdir('fake') 134endif 135