1
2waypipe_source_files = ['dmabuf.c', 'handlers.c', 'kernel.c', 'mainloop.c', 'parsing.c', 'platform.c', 'shadow.c', 'interval.c', 'util.c', 'video.c']
3waypipe_deps = [
4	pthreads,        # To run expensive computations in parallel
5	rt,              # For shared memory
6]
7if config_data.has('HAS_DMABUF')
8	# General GPU buffer creation, aligned with dmabuf proto
9	waypipe_deps += [libgbm]
10endif
11if config_data.has('HAS_LZ4')
12	waypipe_deps += [liblz4] # Fast compression option
13endif
14if config_data.has('HAS_ZSTD')
15	waypipe_deps += [libzstd] # Slow compression option
16endif
17if config_data.has('HAS_VIDEO')
18	waypipe_deps += [libavcodec,libavutil,libswscale]
19endif
20if config_data.has('HAS_VAAPI')
21	waypipe_deps += [libva] # For NV12->RGB conversions
22endif
23
24# Conditionally compile SIMD-optimized code.
25# (The meson simd module is a bit too limited for this)
26kernel_libs = []
27if cc.has_argument('-mavx512f') and cc.has_argument('-mlzcnt') and cc.has_argument('-mbmi') and get_option('with_avx512f')
28	kernel_libs += static_library('kernel_avx512f', 'kernel_avx512f.c', c_args:['-mavx512f', '-mlzcnt', '-mbmi'])
29	config_data.set('HAVE_AVX512F', 1, description: 'Compiler supports AVX-512F')
30endif
31if cc.has_argument('-mavx2') and cc.has_argument('-mlzcnt') and cc.has_argument('-mbmi') and get_option('with_avx2')
32	kernel_libs += static_library('kernel_avx2', 'kernel_avx2.c', c_args:['-mavx2', '-mlzcnt', '-mbmi'])
33	config_data.set('HAVE_AVX2', 1, description: 'Compiler supports AVX2')
34endif
35if cc.has_argument('-msse3') and get_option('with_sse3')
36	kernel_libs += static_library('kernel_sse3', 'kernel_sse3.c', c_args:['-msse3'])
37	config_data.set('HAVE_SSE3', 1, description: 'Compiler supports SSE 3')
38endif
39if ( host_machine.cpu_family() == 'aarch64' or cc.has_argument('-mfpu=neon') ) and get_option('with_neon_opts')
40	neon_args = host_machine.cpu_family() == 'aarch64' ? [] : ['-mfpu=neon']
41
42	# Clang additionally enforces that NEON code only be compiled
43	# to target a CPU that actually supports NEON instructions,
44	# so bump the host CPU version for the optionally executed code only.
45	if host_machine.cpu_family() == 'arm' and cc.get_id() == 'clang'
46		host_cpu = host_machine.cpu()
47		if host_cpu.contains('4') or host_cpu.contains('5') or host_cpu.contains('6')
48			neon_args += ['-march=armv7-a']
49		endif
50	endif
51
52	kernel_libs += static_library('kernel_neon', 'kernel_neon.c', c_args:neon_args)
53	config_data.set('HAVE_NEON', 1, description: 'Compiler supports NEON')
54endif
55
56configure_file(
57	output: 'config-waypipe.h',
58	configuration: config_data,
59)
60
61lib_waypipe_src = static_library(
62	'waypipe_src',
63	waypipe_source_files + protocols_src,
64	include_directories: waypipe_includes,
65	link_with: kernel_libs,
66	dependencies: waypipe_deps,
67)
68
69waypipe_prog = executable(
70	'waypipe',
71	['waypipe.c', 'bench.c', 'client.c', 'server.c'],
72	link_with: lib_waypipe_src,
73	install: true
74)
75