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#
35math_test_src = [
36  'acosf_vec.c',
37  'acoshf_vec.c',
38  'acosh_vec.c',
39  'acos_vec.c',
40  'asinf_vec.c',
41  'asinhf_vec.c',
42  'asinh_vec.c',
43  'asin_vec.c',
44  'atan2f_vec.c',
45  'atan2_vec.c',
46  'atanf_vec.c',
47  'atanhf_vec.c',
48  'atanh_vec.c',
49  'atan_vec.c',
50  'ceilf_vec.c',
51  'ceil_vec.c',
52  'convert.c',
53  'conv_vec.c',
54  'cosf_vec.c',
55  'coshf_vec.c',
56  'cosh_vec.c',
57  'cos_vec.c',
58  'dvec.c',
59  'erfcf_vec.c',
60  'erfc_vec.c',
61  'erff_vec.c',
62  'erf_vec.c',
63  'expf_vec.c',
64  'exp_vec.c',
65  'fabsf_vec.c',
66  'fabs_vec.c',
67  'floorf_vec.c',
68  'floor_vec.c',
69  'fmodf_vec.c',
70  'fmod_vec.c',
71  'gammaf_vec.c',
72  'gamma_vec.c',
73  'hypotf_vec.c',
74  'hypot_vec.c',
75  'iconv_vec.c',
76  'j0f_vec.c',
77  'j0_vec.c',
78  'j1f_vec.c',
79  'j1_vec.c',
80  'jnf_vec.c',
81  'jn_vec.c',
82  'log10f_vec.c',
83  'log10_vec.c',
84  'log1pf_vec.c',
85  'log1p_vec.c',
86  'log2f_vec.c',
87  'log2_vec.c',
88  'logf_vec.c',
89  'log_vec.c',
90  'math2.c',
91  'math.c',
92  'sinf_vec.c',
93  'sinhf_vec.c',
94  'sinh_vec.c',
95  'sin_vec.c',
96  'sprint_ivec.c',
97  'sprint_vec.c',
98  'sqrtf_vec.c',
99  'sqrt_vec.c',
100  'string.c',
101  'tanf_vec.c',
102  'tanhf_vec.c',
103  'tanh_vec.c',
104  'tan_vec.c',
105  'test.c',
106  'test_is.c',
107  'y0f_vec.c',
108  'y0_vec.c',
109  'y1f_vec.c',
110  'y1_vec.c',
111  'ynf_vec.c',
112  'yn_vec.c',
113]
114
115#  'dcvt.c',
116#  'test_ieee.c',
117
118foreach target : targets
119  value = get_variable('target_' + target)
120
121  libs = [get_variable('lib_m' + target), get_variable('lib_c' + target)]
122  if is_variable('lib_semihost' + target)
123    libs += [get_variable('lib_semihost' + target)]
124  endif
125  if is_variable('lib_crt' + target)
126    libs += [get_variable('lib_crt'+ target)]
127  endif
128
129  if target == ''
130    test_name = 'math_test'
131  else
132    test_name = join_paths(target, 'math_test')
133  endif
134
135  test('math' + target,
136       executable(test_name, math_test_src,
137		  c_args:  value[1] + ['-Wno-missing-braces', '-Wno-implicit-int', '-Wno-return-type', '-D_XOPEN_SOURCE=700', '-D_GNU_SOURCE'] + test_c_args,
138		  link_with: libs,
139		  link_args: value[1] + test_link_args + ['-Wl,--gc-sections'],
140		  include_directories: inc),
141       env: ['MESON_SOURCE_ROOT=' + meson.source_root()])
142endforeach
143
144if enable_native_tests
145
146  native_lib_m = meson.get_compiler('c').find_library('m', required: false)
147
148  if native_lib_m.found()
149    test('math-native',
150	 executable('math_test_native', math_test_src,
151		    c_args: ['-Wno-missing-braces', '-Wno-implicit-int', '-Wno-return-type', '-D_XOPEN_SOURCE=700', '-D_GNU_SOURCE', '-DNO_NEWLIB'],
152		    dependencies: native_lib_m))
153  endif
154endif
155