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',
66 'include/a/notefreqs.h',
68 'include/a/pid_fuzzy.h',
69 'include/a/pid_neuro.h',
76 'include/a/trajbell.h',
77 'include/a/trajpoly3.h',
78 'include/a/trajpoly5.h',
79 'include/a/trajpoly7.h',
80 'include/a/trajtrap.h',
83 'include/a/version.h',
110 a_include = include_directories('include')
111 a_meson_h = meson.current_build_dir() / 'a.meson.h'
112 a_h = meson.current_source_dir() / 'include' / 'a' / 'a.h'
114 python = import('python').find_installation()
115 res = run_command(python, '-c', '''import os, sys
116 dir = os.path.dirname('@1@')
117 src = os.path.basename('@0@')
118 dst = os.path.basename('@1@')
119 cur = "#if defined(A_HAVE_H)"
120 new = '#include "' + dst + '"\n' + cur
121 with open('@0@', "r") as f:
123 res = txt.replace(cur, new)
125 new = os.path.join(dir, src)
126 with open(new, "wb") as f:
127 f.write(res.encode())
128 dir = os.path.dirname('@0@')
129 res = os.path.relpath('@1@', dir)
130 sys.stdout.write(res.replace("\\", "/"))
131 '''.format(a_h, a_meson_h), capture: true, check: true
133 if res.returncode() == 0
134 c_args += ['-DA_EXPORTS', '-DA_HAVE_H="' + res.stdout() + '"']
137 a = both_libraries('a', sources, c_args: c_args, cpp_args: c_args,
138 dependencies: compiler.find_library('m', required: false),
139 implicit_include_directories: false,
140 include_directories: a_include,
142 link_args: get_option('math'),
145 version: meson.project_version(),
148 install_headers(a_meson_h, subdir: 'a')
149 install_headers(meson.current_build_dir() / 'a.h', subdir: 'a')
150 install_subdir('include/a', exclude_files: ['a.h'],
151 install_dir: get_option('includedir'),
154 if get_option('rust')
156 add_languages('rust')
157 if get_option('float').to_int() == 4
158 rust_args += ['--cfg', 'feature="float"']
160 static_library('liba', 'src/lib.rs',
161 rust_args: rust_args,
163 link_with: a.get_static_lib(),