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 36libdirs = ['argz', 'ctype', 'errno', 'iconv', 'misc', 37 'posix', 'search', 'signal', 'ssp', 'stdlib', 38 'string', 'time', 'xdr', 'locale'] 39 40if enable_picolib 41 libdirs += 'picolib' 42endif 43 44if tinystdio 45 libdirs += 'tinystdio' 46else 47 libdirs += ['stdio', 'reent'] 48 if newlib_stdio64 49 libdirs += 'stdio64' 50 endif 51endif 52 53libnames = libdirs 54 55inc_sys_headers_machine = [] 56inc_machine_headers_machine = [] 57srcs_machine = [] 58 59machine_dir = 'machine' / host_cpu_family 60if fs.is_dir(machine_dir) 61 62 machine_inc_dir = machine_dir / 'include' 63 if fs.is_dir(machine_inc_dir) 64 inc = [include_directories(machine_inc_dir), inc] 65 endif 66 67 inc = [include_directories(machine_dir), inc] 68 69 libdirs = [machine_dir] + libdirs 70 libnames = ['machine'] + libnames 71 72endif 73 74foreach libdir : libdirs 75 subdir(libdir) 76endforeach 77 78src_cpart = [] 79 80foreach libname : libnames 81 src_cpart += get_variable('src_' + libname, []) 82endforeach 83 84subdir('include') 85 86foreach target : targets 87 value = get_variable('target_' + target) 88 libobjs = [] 89 libsrcs_target = [] 90 91 foreach libname : libnames 92 if is_variable('lib_' + libname + target) 93 libobjs += get_variable('lib_' + libname + target).extract_all_objects(recursive:true) 94 endif 95 libsrcs_target += get_variable('src_' + libname + target, []) 96 endforeach 97 98 set_variable('src_cpart_' + target, libsrcs_target) 99 100 if target == '' 101 libcpart_name = 'cpart' 102 else 103 libcpart_name = 'cpart' + '_' + target 104 endif 105 106 local_lib_cpart_target = static_library(libcpart_name, 107 pic: false, 108 objects : libobjs, 109 include_directories: inc, 110 c_args: value[1] + c_args) 111 112 set_variable('lib_cpart' + target, local_lib_cpart_target) 113endforeach 114