aboutsummaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2018-12-27 11:25:30 +0100
committerAnton Khirnov <anton@khirnov.net>2018-12-27 11:56:47 +0100
commitebb69e5e3765c0a65f92d4eb5e4ae8ba56c23f94 (patch)
tree9ab88212e897e7c4f32a5bca312c7a1208239c46 /meson.build
parent8b99b8dc65863c60f0473dc0bfeeaf6f8dd2550e (diff)
Add CPU feature detection.
Will be used for dynamically dispatching future asm functions.
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build25
1 files changed, 20 insertions, 5 deletions
diff --git a/meson.build b/meson.build
index 2e034b2..5bcfb02 100644
--- a/meson.build
+++ b/meson.build
@@ -4,6 +4,7 @@ project('libmg2d', 'c',
add_project_arguments('-D_XOPEN_SOURCE=700', language : 'c')
lib_src = [
+ 'cpu.c',
'ell_relax.c',
'log.c',
'mg2d.c',
@@ -17,15 +18,28 @@ dep_tp = declare_dependency(link_args : '-lthreadpool')
deps = [dep_tp]
-# x86 SIMD
+cdata = configuration_data()
+cdata.set10('ARCH_X86', false)
+cdata.set10('ARCH_X86_64', false)
+cdata.set10('HAVE_EXTERNAL_ASM', false)
+
arch = host_machine.cpu_family()
-if arch == 'x86_64'
- nasm = find_program('nasm', required : false)
- if not nasm.found()
- warning('nasm not found, no SIMD will be built')
+if arch.startswith('x86')
+ cdata.set10('ARCH_X86', true)
+
+ if arch == 'x86_64'
+ cdata.set10('ARCH_X86_64', true)
+ nasm = find_program('nasm', required : get_option('nasm'))
+ if nasm.found()
+ cdata.set10('HAVE_EXTERNAL_ASM', true)
+ else
+ warning('nasm not found, no SIMD will be built')
+ endif
endif
endif
+configure_file(output : 'config.h', output_format : 'c', configuration : cdata)
+
if nasm.found()
cdata_asm = configuration_data()
cdata_asm.set10('ARCH_X86', true)
@@ -57,6 +71,7 @@ if nasm.found()
)
nasm_sources = files(
+ 'cpuid.asm',
)
lib_obj += nasm_gen.process(nasm_sources)