aboutsummaryrefslogtreecommitdiff
path: root/meson.build
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2018-12-21 22:20:18 +0100
committerAnton Khirnov <anton@khirnov.net>2018-12-21 22:20:18 +0100
commit8b99b8dc65863c60f0473dc0bfeeaf6f8dd2550e (patch)
treea690fce79f9cf6485067b3a3abb43c9f101f6b6c /meson.build
parent060a617cbb44fa7e311ee1985ba255e348bdfb61 (diff)
meson.build: add rules for building with nasm
Preparation for adding SIMD.
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build48
1 files changed, 47 insertions, 1 deletions
diff --git a/meson.build b/meson.build
index de44684..2e034b2 100644
--- a/meson.build
+++ b/meson.build
@@ -8,6 +8,7 @@ lib_src = [
'log.c',
'mg2d.c',
]
+lib_obj = []
verscript = 'libmg2d.v'
ver_flag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), verscript)
@@ -16,4 +17,49 @@ dep_tp = declare_dependency(link_args : '-lthreadpool')
deps = [dep_tp]
-library('mg2d', lib_src, link_args : ver_flag, dependencies : deps)
+# x86 SIMD
+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')
+ endif
+endif
+
+if nasm.found()
+ cdata_asm = configuration_data()
+ cdata_asm.set10('ARCH_X86', true)
+ cdata_asm.set10('ARCH_X86_64', true)
+ cdata_asm.set10('ARCH_X86_32', false)
+ configure_file(output : 'config.asm', output_format : 'nasm', configuration : cdata_asm)
+
+ if host_machine.system() == 'windows'
+ nasm_format = 'win'
+ elif host_machine.system() == 'darwin'
+ nasm_format = 'macho'
+ else
+ nasm_format = 'elf'
+ endif
+ nasm_format += '64'
+
+ nasm_gen = generator(nasm,
+ output: '@BASENAME@.obj',
+ depfile: '@BASENAME@.obj.ndep',
+ arguments: [
+ '-f', nasm_format,
+ '-I', '@SOURCE_DIR@',
+ '-I', '@0@/'.format(meson.current_build_dir()),
+ '-MQ', '@OUTPUT@', '-MF', '@DEPFILE@',
+ '@EXTRA_ARGS@',
+ '@INPUT@',
+ '-o', '@OUTPUT@'
+ ]
+ )
+
+ nasm_sources = files(
+ )
+
+ lib_obj += nasm_gen.process(nasm_sources)
+endif
+
+library('mg2d', lib_src, lib_obj, link_args : ver_flag, dependencies : deps)