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# 35srcs_string = [ 36 'bcmp.c', 37 'bcopy.c', 38 'bzero.c', 39 'explicit_bzero.c', 40 'ffsl.c', 41 'ffsll.c', 42 'fls.c', 43 'flsl.c', 44 'flsll.c', 45 'gnu_basename.c', 46 'index.c', 47 'memccpy.c', 48 'memchr.c', 49 'memcmp.c', 50 'memcpy.c', 51 'memmem.c', 52 'memmove.c', 53 'mempcpy.c', 54 'memrchr.c', 55 'memset.c', 56 'rawmemchr.c', 57 'rindex.c', 58 'stpcpy.c', 59 'stpncpy.c', 60 'strcasecmp.c', 61 'strcasecmp_l.c', 62 'strcasestr.c', 63 'strcat.c', 64 'strchr.c', 65 'strchrnul.c', 66 'strcoll.c', 67 'strcoll_l.c', 68 'strcpy.c', 69 'strcspn.c', 70 'strdup.c', 71 'strerror.c', 72 'strerror_r.c', 73 'strlcat.c', 74 'strlcpy.c', 75 'strlen.c', 76 'strlwr.c', 77 'strncasecmp.c', 78 'strncasecmp_l.c', 79 'strncat.c', 80 'strncmp.c', 81 'strncpy.c', 82 'strndup.c', 83 'strnlen.c', 84 'strnstr.c', 85 'strpbrk.c', 86 'strrchr.c', 87 'strsep.c', 88 'strsignal.c', 89 'strspn.c', 90 'strstr.c', 91 'strtok.c', 92 'strtok_r.c', 93 'strupr.c', 94 'strverscmp.c', 95 'strxfrm.c', 96 'strxfrm_l.c', 97 'swab.c', 98 'timingsafe_bcmp.c', 99 'timingsafe_memcmp.c', 100 'u_strerr.c', 101 'wcpcpy.c', 102 'wcpncpy.c', 103 'wcscasecmp.c', 104 'wcscasecmp_l.c', 105 'wcscat.c', 106 'wcschr.c', 107 'wcscmp.c', 108 'wcscoll.c', 109 'wcscoll_l.c', 110 'wcscpy.c', 111 'wcscspn.c', 112 'wcsdup.c', 113 'wcslcat.c', 114 'wcslcpy.c', 115 'wcslen.c', 116 'wcsncasecmp.c', 117 'wcsncasecmp_l.c', 118 'wcsncat.c', 119 'wcsncmp.c', 120 'wcsncpy.c', 121 'wcsnlen.c', 122 'wcspbrk.c', 123 'wcsrchr.c', 124 'wcsspn.c', 125 'wcsstr.c', 126 'wcstok.c', 127 'wcswidth.c', 128 'wcsxfrm.c', 129 'wcsxfrm_l.c', 130 'wcwidth.c', 131 'wmemchr.c', 132 'wmemcmp.c', 133 'wmemcpy.c', 134 'wmemmove.c', 135 'wmempcpy.c', 136 'wmemset.c', 137 'xpg_strerror_r.c', 138] 139 140hdrs_string = [ 141 'local.h', 142 'str-two-way.h', 143] 144 145srcs_strcmp = [ 146 'strcmp.c' 147] 148 149srcs_string_use = [] 150foreach file : srcs_string 151 s_file = fs.replace_suffix(file, '.S') 152 if file in srcs_machine 153 message('libc/string/' + file + ': machine overrides generic') 154 elif s_file in srcs_machine 155 message('libc/string/' + s_file + ': machine overrides generic') 156 else 157 srcs_string_use += file 158 endif 159endforeach 160 161srcs_strcmp_use = [] 162foreach file : srcs_strcmp 163 s_file = fs.replace_suffix(file, '.S') 164 if file in srcs_machine 165 message('libc/string/' + file + ': machine overrides generic') 166 elif s_file in srcs_machine 167 message('libc/string/' + s_file + ': machine overrides generic') 168 else 169 srcs_strcmp_use += file 170 endif 171endforeach 172 173if fast_strcmp 174 cargs_strcmp = ['-O3'] 175else 176 cargs_strcmp = [] 177endif 178 179src_string = files(srcs_string_use) 180 181# Need a sub-library to pass custom cflags to strcmp 182 183if srcs_strcmp_use != [] 184 foreach target : targets 185 value = get_variable('target_' + target) 186 187 set_variable('lib_string' + target, 188 static_library('strcmp' + target, 189 srcs_strcmp_use, 190 pic: false, 191 c_args: value[1] + c_args + cargs_strcmp, 192 include_directories: inc)) 193 endforeach 194endif 195