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 inc_headers = ['semihost.h'] 99 install_headers(inc_headers, 100 install_dir: include_dir 101 ) 102 103 inc = [inc, include_directories('.')] 104 inc_args += '-I' + meson.current_source_dir() 105 106 has_semihost = true 107 108 has_arm_semihost = true 109 110 has_semihost_args = true 111 112 foreach target : targets 113 value = get_variable('target_' + target) 114 115 instdir = join_paths(lib_dir, value[0]) 116 117 if target == '' 118 libsemihost_name = 'semihost' 119 else 120 libsemihost_name = join_paths(target, 'libsemihost') 121 endif 122 123 set_variable('lib_semihost' + target, 124 static_library(libsemihost_name, 125 src_semihost, 126 install : true, 127 install_dir : instdir, 128 include_directories : inc, 129 c_args : value[1] + c_args)) 130 131 endforeach 132 133 if enable_cdefs_tests 134 ignore_headers = [] 135 foreach header : inc_headers 136 137 if not (header in ignore_headers) and not (header.startswith('_')) 138 test_name = 'check-cdef-' + header 139 140 test(test_name, 141 validate_cdefs, 142 args: [meson.current_source_dir() / header] + cc.cmd_array() + c_args + inc_args, 143 suite: 'headers') 144 endif 145 endforeach 146 endif 147 148endif 149 150if not has_semihost and get_option('fake-semihost') 151 subdir('fake') 152endif 153 154