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',
73 'include/a/regress_linear.h',
77 'include/a/trajbell.h',
78 'include/a/trajpoly3.h',
79 'include/a/trajpoly5.h',
80 'include/a/trajpoly7.h',
81 'include/a/trajtrap.h',
84 'include/a/version.h',
99 'src/regress_linear.c',
112 a_include = include_directories('include')
113 a_meson_h = meson.current_build_dir() / 'a.meson.h'
114 a_h = meson.current_source_dir() / 'include' / 'a' / 'a.h'
116 python = import('python').find_installation()
117 res = run_command(python, '-c', '''import os, sys
118 dir = os.path.dirname('@1@')
119 src = os.path.basename('@0@')
120 dst = os.path.basename('@1@')
121 cur = "#if defined(A_HAVE_H)"
122 new = '#include "' + dst + '"\n' + cur
123 with open('@0@', "r") as f:
125 res = txt.replace(cur, new)
127 new = os.path.join(dir, src)
128 with open(new, "wb") as f:
129 f.write(res.encode())
130 dir = os.path.dirname('@0@')
131 res = os.path.relpath('@1@', dir)
132 sys.stdout.write(res.replace("\\", "/"))
133 '''.format(a_h, a_meson_h), capture: true, check: true
135 if res.returncode() == 0
136 c_args += ['-DA_EXPORTS', '-DA_HAVE_H="' + res.stdout() + '"']
139 a = both_libraries('a', sources, c_args: c_args, cpp_args: c_args,
140 dependencies: compiler.find_library('m', required: false),
141 implicit_include_directories: false,
142 include_directories: a_include,
144 link_args: get_option('math'),
147 version: meson.project_version(),
150 install_headers(a_meson_h, subdir: 'a')
151 install_headers(meson.current_build_dir() / 'a.h', subdir: 'a')
152 install_subdir('include/a', exclude_files: ['a.h'],
153 install_dir: get_option('includedir'),
156 if get_option('rust')
158 add_languages('rust')
159 if get_option('float').to_int() == 4
160 rust_args += ['--cfg', 'feature="float"']
162 static_library('liba', 'src/lib.rs',
163 rust_args: rust_args,
165 link_with: a.get_static_lib(),