From 8b99b8dc65863c60f0473dc0bfeeaf6f8dd2550e Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 21 Dec 2018 22:20:18 +0100 Subject: meson.build: add rules for building with nasm Preparation for adding SIMD. --- meson.build | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) (limited to 'meson.build') 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) -- cgit v1.2.3