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.h',
74 'include/a/regress_linear.h',
75 'include/a/regress_simple.h',
79 'include/a/trajbell.h',
80 'include/a/trajpoly3.h',
81 'include/a/trajpoly5.h',
82 'include/a/trajpoly7.h',
83 'include/a/trajtrap.h',
86 'include/a/version.h',
102 'src/regress_linear.c',
103 'src/regress_simple.c',
116 a_include = include_directories('include')
117 a_meson_h = meson.current_build_dir() / 'a.meson.h'
118 a_h = meson.current_source_dir() / 'include' / 'a' / 'a.h'
120 python = import('python').find_installation()
121 res = run_command(python, '-c', '''import os, sys
122 dir = os.path.dirname('@1@')
123 src = os.path.basename('@0@')
124 dst = os.path.basename('@1@')
125 cur = "#if defined(A_HAVE_H)"
126 new = '#include "' + dst + '"\n' + cur
127 with open('@0@', "r") as f:
129 res = txt.replace(cur, new)
131 new = os.path.join(dir, src)
132 with open(new, "wb") as f:
133 f.write(res.encode())
134 dir = os.path.dirname('@0@')
135 res = os.path.relpath('@1@', dir)
136 sys.stdout.write(res.replace("\\", "/"))
137 '''.format(a_h, a_meson_h), capture: true, check: true
139 if res.returncode() == 0
140 c_args += ['-DA_EXPORTS', '-DA_HAVE_H="' + res.stdout() + '"']
143 a = both_libraries('a', sources, c_args: c_args, cpp_args: c_args,
144 dependencies: compiler.find_library('m', required: false),
145 implicit_include_directories: false,
146 include_directories: a_include,
148 link_args: get_option('math'),
151 version: meson.project_version(),
154 install_headers(a_meson_h, subdir: 'a')
155 install_headers(meson.current_build_dir() / 'a.h', subdir: 'a')
156 install_subdir('include/a', exclude_files: ['a.h'],
157 install_dir: get_option('includedir'),
160 if get_option('rust')
162 add_languages('rust')
163 if get_option('float').to_int() == 4
164 rust_args += ['--cfg', 'feature="float"']
166 static_library('liba', 'src/lib.rs',
167 rust_args: rust_args,
169 link_with: a.get_static_lib(),