1 project('liba', 'c', 'cpp',
6 'buildtype=debugoptimized',
11 a_have_h = configuration_data()
12 a_have_h.set('version', meson.version())
13 a_have_h.set('A_VERSION', meson.project_version())
14 a_have_h.set('A_VERSION_MAJOR', meson.project_version().split('.')[0])
15 a_have_h.set('A_VERSION_MINOR', meson.project_version().split('.')[1])
16 a_have_h.set('A_VERSION_PATCH', meson.project_version().split('.')[2])
17 a_have_h.set('A_SIZE_FLOAT', get_option('float'))
18 if target_machine.endian() == 'little'
19 a_have_h.set('A_BYTE_ORDER', 1234)
20 elif target_machine.endian() == 'big'
21 a_have_h.set('A_BYTE_ORDER', 4321)
24 compiler = meson.get_compiler('c')
25 a_have_h.set('A_SIZE_POINTER', compiler.sizeof('void *'))
27 math = ['expm1', 'log1p', 'hypot', 'atan2',
28 'csqrt', 'cpow', 'cexp', 'clog',
29 'csin', 'ccos', 'ctan',
30 'csinh', 'ccosh', 'ctanh',
31 'casin', 'cacos', 'catan',
32 'casinh', 'cacosh', 'catanh']
35 float = get_option('float').to_int()
36 have = 'A_HAVE_' + func.to_upper()
42 if compiler.has_function(func)
43 a_have_h.set(have, '1')
48 input: 'include/a.meson.h.in',
50 configuration: a_have_h,
58 'include/a/complex.h',
67 'include/a/notefreqs.h',
69 'include/a/pid_fuzzy.h',
70 'include/a/pid_neuro.h',
74 'include/a/regress.h',
75 'include/a/regress_linear.h',
76 'include/a/regress_simple.h',
80 'include/a/trajbell.h',
81 'include/a/trajpoly3.h',
82 'include/a/trajpoly5.h',
83 'include/a/trajpoly7.h',
84 'include/a/trajtrap.h',
87 'include/a/version.h',
104 'src/regress_linear.c',
105 'src/regress_simple.c',
118 a_include = include_directories('include')
119 a_meson_h = meson.current_build_dir() / 'a.meson.h'
120 a_h = meson.current_source_dir() / 'include' / 'a' / 'a.h'
122 python = import('python').find_installation()
123 res = run_command(python, '-c', '''import os, sys
124 dir = os.path.dirname('@1@')
125 src = os.path.basename('@0@')
126 dst = os.path.basename('@1@')
127 cur = "#if defined(A_HAVE_H)"
128 new = '#include "' + dst + '"\n' + cur
129 with open('@0@', "r") as f:
131 res = txt.replace(cur, new)
133 new = os.path.join(dir, src)
134 with open(new, "wb") as f:
135 f.write(res.encode())
136 dir = os.path.dirname('@0@')
137 res = os.path.relpath('@1@', dir)
138 sys.stdout.write(res.replace("\\", "/"))
139 '''.format(a_h, a_meson_h), capture: true, check: true
141 if res.returncode() == 0
142 c_args += ['-DA_EXPORTS', '-DA_HAVE_H="' + res.stdout() + '"']
145 a = both_libraries('a', sources, c_args: c_args, cpp_args: c_args,
146 dependencies: compiler.find_library('m', required: false),
147 implicit_include_directories: false,
148 include_directories: a_include,
150 link_args: get_option('math'),
153 version: meson.project_version(),
156 install_headers(a_meson_h, subdir: 'a')
157 install_headers(meson.current_build_dir() / 'a.h', subdir: 'a')
158 install_subdir('include/a', exclude_files: ['a.h'],
159 install_dir: get_option('includedir'),
162 if get_option('rust')
164 add_languages('rust')
165 if get_option('float').to_int() == 4
166 rust_args += ['--cfg', 'feature="float"']
168 static_library('liba', 'src/lib.rs',
169 rust_args: rust_args,
171 link_with: a.get_static_lib(),