1# Copyright (c) 2013 The Chromium OS Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5AUTOMAKE_OPTIONS = subdir-objects
6ACLOCAL_AMFLAGS = ${ACLOCAL_FLAGS}
7
8if HAVE_SSE42
9CRAS_SSE4_2 = libcrasmix_sse42.la
10else
11CRAS_SSE4_2 =
12endif
13
14if HAVE_AVX
15CRAS_AVX = libcrasmix_avx.la
16else
17CRAS_AVX =
18endif
19
20if HAVE_AVX2
21CRAS_AVX2 = libcrasmix_avx2.la
22else
23CRAS_AVX2 =
24endif
25
26if HAVE_FMA
27CRAS_FMA = libcrasmix_fma.la
28else
29CRAS_FMA =
30endif
31
32if HAVE_WEBRTC_APM
33CRAS_WEBRTC_APM_SOURCES = \
34	server/cras_apm_list.c \
35	server/config/aec_config.c \
36	server/config/apm_config.c
37else
38CRAS_WEBRTC_APM_SOURCES =
39endif
40
41CRAS_UT_TMPDIR_CFLAGS=-DCRAS_UT_TMPDIR=\"/tmp\"
42COMMON_CPPFLAGS = -O2 -Wall -Werror -Wno-error=cpp
43COMMON_SIMD_CPPFLAGS = -O3 -Wall -Werror -Wno-error=cpp
44
45bin_PROGRAMS = cras cras_test_client cras_monitor cras_router
46
47if HAVE_DBUS
48CRAS_DBUS_SOURCES = \
49	common/cras_sbc_codec.c \
50	server/cras_bt_manager.c \
51	server/cras_bt_adapter.c \
52	server/cras_bt_device.c \
53	server/cras_bt_transport.c \
54	server/cras_bt_endpoint.c \
55	server/cras_bt_player.c \
56	server/cras_bt_io.c \
57	server/cras_bt_profile.c \
58	server/cras_dbus.c \
59	server/cras_dbus_util.c \
60	server/cras_dbus_control.c \
61	server/cras_hfp_ag_profile.c \
62	server/cras_hfp_iodev.c \
63	server/cras_hfp_info.c \
64	server/cras_hfp_slc.c \
65	server/cras_a2dp_endpoint.c \
66	server/cras_a2dp_info.c \
67	server/cras_a2dp_iodev.c \
68	server/cras_telephony.c \
69	server/cras_utf8.c
70else
71CRAS_DBUS_SOURCES =
72endif
73
74if HAVE_SELINUX
75CRAS_SELINUX_SOURCES = common/cras_selinux_helper.c
76CRAS_SELINUX_UNITTEST_SOURCES = tests/cras_selinux_helper_unittest.c
77else
78CRAS_SELINUX_SOURCES =
79CRAS_SELINUX_UNITTEST_SOURCES =
80endif
81
82cras_server_SOURCES = \
83	$(CRAS_DBUS_SOURCES) \
84	$(CRAS_SELINUX_SOURCES) \
85	$(CRAS_WEBRTC_APM_SOURCES) \
86	common/cras_audio_format.c \
87	common/cras_checksum.c \
88	common/cras_config.c \
89	common/cras_metrics.c \
90	common/cras_shm.c \
91	common/cras_util.c \
92	common/dumper.c \
93	common/edid_utils.c \
94	common/sfh.c \
95	dsp/biquad.c \
96	dsp/crossover.c \
97	dsp/crossover2.c \
98	dsp/dcblock.c \
99	dsp/drc.c \
100	dsp/drc_kernel.c \
101	dsp/drc_math.c \
102	dsp/dsp_util.c \
103	dsp/eq.c \
104	dsp/eq2.c \
105	server/audio_thread.c \
106	server/buffer_share.c \
107	server/config/cras_board_config.c \
108	server/config/cras_card_config.c \
109	server/config/cras_device_blacklist.c \
110	server/cras_alert.c \
111	server/cras_alsa_card.c \
112	server/cras_alsa_helpers.c \
113	server/cras_alsa_io.c \
114	server/cras_alsa_jack.c \
115	server/cras_alsa_mixer.c \
116	server/cras_alsa_mixer_name.c \
117	server/cras_alsa_ucm.c \
118	server/cras_alsa_ucm_section.c \
119	server/cras_audio_area.c \
120	server/cras_audio_thread_monitor.c \
121	server/cras_device_monitor.c \
122	server/cras_dsp.c \
123	server/cras_dsp_ini.c \
124	server/cras_dsp_mod_builtin.c \
125	server/cras_dsp_mod_ladspa.c \
126	server/cras_dsp_pipeline.c \
127	server/cras_empty_iodev.c \
128	server/cras_expr.c \
129	server/cras_fmt_conv.c \
130	server/cras_gpio_jack.c \
131	server/cras_hotword_handler.c \
132	server/cras_iodev.c \
133	server/cras_iodev_list.c \
134	server/cras_loopback_iodev.c \
135	server/cras_main_message.c \
136	server/cras_mix.c \
137	server/cras_non_empty_audio_handler.c \
138	server/cras_observer.c \
139	server/cras_ramp.c \
140	server/cras_rclient.c \
141	server/cras_rstream.c \
142	server/cras_server_metrics.c \
143	server/cras_system_state.c \
144	server/cras_tm.c \
145	server/cras_udev.c \
146	server/cras_volume_curve.c \
147	server/dev_io.c \
148	server/dev_stream.c \
149	server/input_data.c \
150	server/linear_resampler.c \
151	server/polled_interval_checker.c \
152	server/server_stream.c \
153	server/stream_list.c \
154	server/test_iodev.c \
155	server/rate_estimator.c \
156	server/softvol_curve.c
157
158libcrasserver_la_SOURCES = \
159	$(cras_server_SOURCES)
160libcrasserver_la_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
161	-I$(top_srcdir)/src/dsp -I$(top_srcdir)/src/server \
162	-I$(top_srcdir)/src/server/config \
163	$(DBUS_CFLAGS) $(SBC_CFLAGS) $(SELINUX_CFLAGS)
164libcrasserver_la_LIBADD = \
165	libcrasmix.la \
166	$(CRAS_SSE4_2) \
167	$(CRAS_AVX) \
168	$(CRAS_AVX2) \
169	$(CRAS_FMA) \
170	-lpthread -lasound -lrt -liniparser -ludev -ldl -lm -lspeexdsp \
171	$(SBC_LIBS) \
172	$(DBUS_LIBS) \
173	$(SELINUX_LIBS)
174
175cras_SOURCES = \
176	server/cras.c \
177	server/cras_server.c
178
179cras_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
180	-I$(top_srcdir)/src/dsp -I$(top_srcdir)/src/server \
181	-I$(top_srcdir)/src/server/config \
182	$(DBUS_CFLAGS) $(SBC_CFLAGS)
183
184cras_LDADD = \
185	libcrasmix.la \
186	libcrasserver.la \
187	$(CRAS_SSE4_2) \
188	$(CRAS_AVX) \
189	$(CRAS_AVX2) \
190	$(CRAS_FMA) \
191	-lpthread -lasound -lrt -liniparser -ludev -ldl -lm -lspeexdsp \
192	$(METRICS_LIBS) \
193	$(SBC_LIBS) \
194	$(DBUS_LIBS) \
195	$(WEBRTC_APM_LIBS)
196
197noinst_LTLIBRARIES = \
198	$(CRAS_SSE4_2) \
199	$(CRAS_AVX) \
200	$(CRAS_AVX2) \
201	$(CRAS_FMA) \
202	libcrasmix.la \
203	libcrasserver.la
204
205libcrasmix_la_SOURCES = \
206	server/cras_mix_ops.c
207
208libcrasmix_la_CFLAGS = \
209	$(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
210	-I$(top_srcdir)/src/dsp -I$(top_srcdir)/src/server \
211	-I$(top_srcdir)/src/server/config \
212	$(DBUS_CFLAGS) $(SBC_CFLAGS)
213
214libcrasmix_sse42_la_SOURCES = \
215	server/cras_mix_ops.c
216
217libcrasmix_sse42_la_CFLAGS = \
218	$(COMMON_SIMD_CPPFLAGS) -I$(top_srcdir)/src/common \
219	-I$(top_srcdir)/src/dsp -I$(top_srcdir)/src/server \
220	-I$(top_srcdir)/src/server/config \
221	$(DBUS_CFLAGS) $(SSE42_CFLAGS)
222
223libcrasmix_avx_la_SOURCES = \
224	server/cras_mix_ops.c
225
226libcrasmix_avx_la_CFLAGS = \
227	$(COMMON_SIMD_CPPFLAGS) -I$(top_srcdir)/src/common \
228	-I$(top_srcdir)/src/dsp -I$(top_srcdir)/src/server \
229	-I$(top_srcdir)/src/server/config \
230	$(DBUS_CFLAGS) $(AVX_CFLAGS)
231
232libcrasmix_avx2_la_SOURCES = \
233	server/cras_mix_ops.c
234
235libcrasmix_avx2_la_CFLAGS = \
236	$(COMMON_SIMD_CPPFLAGS) -I$(top_srcdir)/src/common \
237	-I$(top_srcdir)/src/dsp -I$(top_srcdir)/src/server \
238	-I$(top_srcdir)/src/server/config \
239	$(DBUS_CFLAGS) $(AVX2_CFLAGS)
240
241libcrasmix_fma_la_SOURCES = \
242	server/cras_mix_ops.c
243
244libcrasmix_fma_la_CFLAGS = \
245	$(COMMON_SIMD_CPPFLAGS) -I$(top_srcdir)/src/common \
246	-I$(top_srcdir)/src/dsp -I$(top_srcdir)/src/server \
247	-I$(top_srcdir)/src/server/config \
248	$(DBUS_CFLAGS) $(FMA_CFLAGS)
249
250lib_LTLIBRARIES = libcras.la
251libcras_la_SOURCES = \
252	common/cras_audio_format.c \
253	common/cras_config.c \
254	common/cras_file_wait.c \
255	common/cras_util.c \
256	common/edid_utils.c \
257	libcras/cras_client.c \
258	libcras/cras_helpers.c
259
260include_HEADERS = \
261	common/cras_audio_format.h \
262	common/cras_config.h \
263	common/cras_iodev_info.h \
264	common/cras_messages.h \
265	common/cras_shm.h \
266	common/cras_types.h \
267	common/cras_util.h \
268	common/edid_utils.h \
269	common/utlist.h \
270	libcras/cras_client.h \
271	libcras/cras_helpers.h
272
273libcras_la_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
274	-I$(top_srcdir)/src/libcras
275libcras_la_LIBADD = -lpthread -lasound -lrt
276libcras_la_LDFLAGS = -version-info 0:0:0
277
278asound_module_pcm_cras_LTLIBRARIES = libasound_module_pcm_cras.la
279asound_module_ctl_cras_LTLIBRARIES = libasound_module_ctl_cras.la
280asound_module_pcm_crasdir = @ALSA_PLUGIN_DIR@
281asound_module_ctl_crasdir = @ALSA_PLUGIN_DIR@
282libasound_module_pcm_cras_la_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
283	-I$(top_srcdir)/src/libcras
284libasound_module_pcm_cras_la_LDFLAGS = -module -avoid-version -export-dynamic -no-undefined \
285	$(LDFLAGS_NOUNDEFINED)
286libasound_module_ctl_cras_la_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
287	-I$(top_srcdir)/src/libcras
288libasound_module_ctl_cras_la_LDFLAGS = -module -avoid-version -export-dynamic -no-undefined \
289	$(LDFLAGS_NOUNDEFINED)
290libasound_module_pcm_cras_la_SOURCES = alsa_plugin/pcm_cras.c
291libasound_module_pcm_cras_la_LIBADD = -lasound libcras.la
292libasound_module_ctl_cras_la_SOURCES = alsa_plugin/ctl_cras.c
293libasound_module_ctl_cras_la_LIBADD = -lasound libcras.la
294
295# Inject a dependency between the installation rules of libcras and its modules.
296# This avoids a race when the modules are relinked before libcras is actually
297# installed.
298#
299# Automake will refuse to generate a rule that collides with a user-specified
300# one. The hide_install variable prevents automake from noticing these rules,
301# so everything else will behave as usual.
302hide_install=install
303$(hide_install)-asound_module_pcm_crasLTLIBRARIES: install-libLTLIBRARIES
304$(hide_install)-asound_module_ctl_crasLTLIBRARIES: install-libLTLIBRARIES
305
306if HAVE_DBUS
307DBUS_TESTS = \
308	a2dp_info_unittest \
309	a2dp_iodev_unittest \
310	alsa_io_unittest \
311	bt_device_unittest \
312	bt_io_unittest \
313	hfp_iodev_unittest \
314	hfp_slc_unittest
315else
316DBUS_TESTS =
317endif
318
319if HAVE_WEBRTC_APM
320CRAS_WEBRTC_APM_TESTS = \
321	apm_list_unittest
322else
323CRAS_WEBRTC_APM_TESTS =
324endif
325
326TESTS = \
327	$(DBUS_TESTS) \
328	$(CRAS_WEBRTC_APM_TESTS) \
329	audio_area_unittest \
330	audio_format_unittest \
331	audio_thread_unittest \
332	audio_thread_monitor_unittest \
333	alert_unittest \
334	alsa_card_unittest \
335	alsa_helpers_unittest \
336	alsa_jack_unittest \
337	alsa_mixer_unittest \
338	alsa_ucm_unittest \
339	array_unittest \
340	byte_buffer_unittest \
341	card_config_unittest \
342	checksum_unittest \
343	cras_client_unittest \
344	cras_tm_unittest \
345	device_monitor_unittest \
346	dev_io_unittest \
347	dev_stream_unittest \
348	device_blacklist_unittest \
349	dsp_core_unittest \
350	dsp_ini_unittest \
351	dsp_pipeline_unittest \
352	dsp_unittest \
353	dumper_unittest \
354	edid_utils_unittest \
355	expr_unittest \
356	file_wait_unittest \
357	float_buffer_unittest \
358	fmt_conv_unittest \
359	hfp_info_unittest \
360	buffer_share_unittest \
361	iodev_list_unittest \
362	iodev_unittest \
363	loopback_iodev_unittest \
364	mix_unittest \
365	linear_resampler_unittest \
366	observer_unittest \
367	polled_interval_checker_unittest \
368	ramp_unittest \
369	rate_estimator_unittest \
370	rclient_unittest \
371	rstream_unittest \
372	shm_unittest \
373	server_metrics_unittest \
374	softvol_curve_unittest \
375	stream_list_unittest \
376	system_state_unittest \
377	timing_unittest \
378	utf8_unittest \
379	util_unittest \
380	volume_curve_unittest
381
382check_PROGRAMS = $(TESTS)
383
384cras_test_client_SOURCES = tests/cras_test_client.c
385cras_test_client_LDADD = -lm libcras.la
386cras_test_client_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/libcras \
387	-I$(top_srcdir)/src/common -I$(top_builddir)/src/common
388
389tests/cras_test_client.c: common/cras_version.h
390
391cras_monitor_SOURCES = tests/cras_monitor.c
392cras_monitor_LDADD = -lm libcras.la
393cras_monitor_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/libcras \
394	-I$(top_srcdir)/src/common -I$(top_builddir)/src/common
395
396tests/cras_monitor.c: common/cras_version.h
397
398cras_router_SOURCES = tests/cras_router.c
399cras_router_LDADD = -lm libcras.la
400cras_router_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/libcras \
401        -I$(top_srcdir)/src/common -I$(top_srcdir)/src/dsp \
402	-I$(top_srcdir)/src/server -I$(top_builddir)/src/common
403
404tests/cras_router.c: common/cras_version.h
405
406CLEANFILES = common/cras_version.h
407.PHONY: common/cras_version.h
408common/cras_version.h:
409	if echo "$(CPPFLAGS)" | grep -q -- '-DVCSID='; then \
410		echo > $@.tmp; \
411	else \
412		commit="outoftree-$$(git rev-parse HEAD)"; \
413		if [ -n "$$(git diff-index --name-only HEAD)" ]; then \
414			commit="$${commit}-dirty"; \
415		fi; \
416		echo "#define VCSID \"$$commit\"" > $@.tmp; \
417	fi
418	diff $@.tmp $@ && rm -f $@.tmp || mv $@.tmp $@
419
420# dsp test programs (not run automatically)
421check_PROGRAMS += \
422	crossover_test \
423	crossover2_test \
424	dcblock_test \
425	drc_test \
426	dsp_util_test \
427	eq_test \
428	eq2_test \
429	cmpraw
430
431DSP_INCLUDE_PATHS = -I$(top_srcdir)/src/dsp -I$(top_srcdir)/src/common
432
433crossover_test_SOURCES = dsp/crossover.c dsp/biquad.c dsp/dsp_util.c \
434	dsp/tests/crossover_test.c dsp/tests/dsp_test_util.c dsp/tests/raw.c
435crossover_test_LDADD = -lrt -lm
436crossover_test_CPPFLAGS = $(COMMON_CPPFLAGS) $(DSP_INCLUDE_PATHS)
437
438crossover2_test_SOURCES = dsp/crossover2.c dsp/biquad.c dsp/dsp_util.c \
439	dsp/tests/crossover2_test.c dsp/tests/dsp_test_util.c dsp/tests/raw.c
440crossover2_test_LDADD = -lrt -lm
441crossover2_test_CPPFLAGS = $(COMMON_CPPFLAGS) $(DSP_INCLUDE_PATHS)
442
443dcblock_test_SOURCES = dsp/dcblock.c dsp/dsp_util.c dsp/tests/dcblock_test.c \
444	dsp/tests/dsp_test_util.c dsp/tests/raw.c
445dcblock_test_LDADD = -lrt -lm
446dcblock_test_CPPFLAGS = $(COMMON_CPPFLAGS) $(DSP_INCLUDE_PATHS)
447
448drc_test_SOURCES = dsp/drc.c dsp/drc_kernel.c dsp/drc_math.c \
449	dsp/crossover2.c dsp/eq2.c dsp/biquad.c dsp/dsp_util.c \
450	dsp/tests/drc_test.c dsp/tests/dsp_test_util.c dsp/tests/raw.c
451drc_test_LDADD = -lrt -lm
452drc_test_CPPFLAGS = $(COMMON_CPPFLAGS) $(DSP_INCLUDE_PATHS)
453
454dsp_util_test_SOURCES = dsp/tests/dsp_util_test.c dsp/dsp_util.c
455dsp_util_test_LDADD = -lm
456dsp_util_test_CPPFLAGS = $(COMMON_CPPFLAGS) $(DSP_INCLUDE_PATHS) -Wno-error=strict-aliasing
457
458eq_test_SOURCES = dsp/biquad.c dsp/eq.c dsp/dsp_util.c dsp/tests/eq_test.c \
459	dsp/tests/dsp_test_util.c dsp/tests/raw.c
460eq_test_LDADD = -lrt -lm
461eq_test_CPPFLAGS = $(COMMON_CPPFLAGS) $(DSP_INCLUDE_PATHS)
462
463eq2_test_SOURCES = dsp/biquad.c dsp/eq2.c dsp/dsp_util.c dsp/tests/eq2_test.c \
464	dsp/tests/dsp_test_util.c dsp/tests/raw.c
465eq2_test_LDADD = -lrt -lm
466eq2_test_CPPFLAGS = $(COMMON_CPPFLAGS) $(DSP_INCLUDE_PATHS)
467
468cmpraw_SOURCES = dsp/tests/cmpraw.c dsp/tests/raw.c
469cmpraw_LDADD = -lm
470cmpraw_CPPFLAGS = $(COMMON_CPPFLAGS) $(DSP_INCLUDE_PATHS)
471
472# unit tests
473alert_unittest_SOURCES = tests/alert_unittest.cc \
474	server/cras_alert.c
475alert_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) \
476	-I$(top_srcdir)/src/common \
477	-I$(top_srcdir)/src/server
478alert_unittest_LDADD = -lgtest -lpthread
479
480alsa_card_unittest_SOURCES = tests/alsa_card_unittest.cc \
481	server/cras_alsa_card.c server/cras_alsa_mixer_name.c \
482	server/cras_alsa_ucm_section.c
483alsa_card_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) \
484	-I$(top_srcdir)/src/common \
485	-I$(top_srcdir)/src/server \
486	-I$(top_srcdir)/src/server/config
487alsa_card_unittest_LDADD = -lgtest -lpthread
488
489alsa_helpers_unittest_SOURCES = tests/alsa_helpers_unittest.cc \
490	common/cras_audio_format.c
491alsa_helpers_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) \
492	-I$(top_srcdir)/src/common \
493	-I$(top_srcdir)/src/server
494alsa_helpers_unittest_LDADD = -lgtest -lpthread
495
496audio_area_unittest_SOURCES = tests/audio_area_unittest.cc \
497	server/cras_audio_area.c
498audio_area_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/server \
499	-I$(top_srcdir)/src/common
500audio_area_unittest_LDADD = -lgtest -lpthread
501
502audio_format_unittest_SOURCES = tests/audio_format_unittest.cc
503audio_format_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/server \
504	-I$(top_srcdir)/src/common
505audio_format_unittest_LDADD = -lgtest -lpthread
506
507if HAVE_DBUS
508a2dp_info_unittest_SOURCES = tests/a2dp_info_unittest.cc \
509	server/cras_a2dp_info.c
510a2dp_info_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/server \
511	-I$(top_srcdir)/src/common
512a2dp_info_unittest_LDADD = -lgtest -lpthread
513
514a2dp_iodev_unittest_SOURCES = tests/a2dp_iodev_unittest.cc \
515	server/cras_a2dp_iodev.c common/sfh.c
516a2dp_iodev_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/server \
517	-I$(top_srcdir)/src/common $(DBUS_CFLAGS)
518a2dp_iodev_unittest_LDADD = -lgtest -lpthread $(DBUS_LIBS)
519endif
520
521alsa_io_unittest_SOURCES = tests/alsa_io_unittest.cc server/softvol_curve.c \
522	common/sfh.c \
523	server/cras_alsa_ucm_section.c \
524	server/cras_alsa_mixer_name.c
525alsa_io_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) $(DBUS_CFLAGS) \
526	-I$(top_srcdir)/src/server \
527	-I$(top_srcdir)/src/common \
528	-I$(top_srcdir)/src/server/config
529alsa_io_unittest_LDADD = -lgtest -lpthread
530
531alsa_jack_unittest_SOURCES = tests/alsa_jack_unittest.cc \
532	server/cras_alsa_jack.c \
533	server/cras_alsa_ucm_section.c \
534	server/cras_alsa_mixer_name.c
535alsa_jack_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
536	-I$(top_srcdir)/src/server
537alsa_jack_unittest_LDADD = -lgtest -lpthread
538
539alsa_mixer_unittest_SOURCES = tests/alsa_mixer_unittest.cc \
540	server/cras_alsa_mixer_name.c \
541	server/cras_alsa_ucm_section.c
542alsa_mixer_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) \
543	-I$(top_srcdir)/src/common \
544	-I$(top_srcdir)/src/server \
545	-I$(top_srcdir)/src/server/config
546alsa_mixer_unittest_LDADD = -lgtest -lpthread
547
548alsa_ucm_unittest_SOURCES = tests/alsa_ucm_unittest.cc \
549	server/cras_alsa_mixer_name.c \
550	server/cras_alsa_ucm_section.c
551alsa_ucm_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) \
552	-I$(top_srcdir)/src/common \
553	-I$(top_srcdir)/src/server \
554	-I$(top_srcdir)/src/server/config
555alsa_ucm_unittest_LDADD = -lgtest -lpthread
556
557if HAVE_WEBRTC_APM
558apm_list_unittest_SOURCES = tests/apm_list_unittest.cc \
559	server/cras_apm_list.c
560apm_list_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) \
561	$(DSP_INCLUDE_PATHS) \
562	-I$(top_srcdir)/src/server \
563	-I$(top_srcdir)/src/server/config \
564	$(WEBRTC_APM_CFLAGS)
565apm_list_unittest_LDADD = -lgtest
566endif
567
568array_unittest_SOURCES = tests/array_unittest.cc
569array_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common
570array_unittest_LDADD = -lgtest -lpthread
571
572audio_thread_unittest_SOURCES = tests/audio_thread_unittest.cc \
573	server/dev_io.c tests/empty_audio_stub.cc
574audio_thread_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) \
575	-I$(top_srcdir)/src/common -I$(top_srcdir)/src/server
576audio_thread_unittest_LDADD = -lgtest -lpthread -lrt
577
578audio_thread_monitor_unittest_SOURCES = tests/audio_thread_monitor_unittest.cc
579audio_thread_monitor_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) \
580	-I$(top_srcdir)/src/common -I$(top_srcdir)/src/server
581audio_thread_monitor_unittest_LDADD = -lgtest -lpthread -lrt
582
583if HAVE_DBUS
584bt_device_unittest_SOURCES = tests/bt_device_unittest.cc \
585	server/cras_bt_device.c
586bt_device_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/server \
587	-I$(top_srcdir)/src/common $(DBUS_CFLAGS)
588bt_device_unittest_LDADD = -lgtest -lpthread $(DBUS_LIBS)
589
590bt_io_unittest_SOURCES = tests/bt_io_unittest.cc common/sfh.c
591bt_io_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/server \
592	-I$(top_srcdir)/src/common $(DBUS_CFLAGS)
593bt_io_unittest_LDADD = -lgtest -lpthread $(DBUS_LIBS)
594endif
595
596byte_buffer_unittest_SOURCES = tests/byte_buffer_unittest.cc
597byte_buffer_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common
598byte_buffer_unittest_LDADD = -lgtest -lpthread
599
600card_config_unittest_SOURCES = tests/card_config_unittest.cc \
601	server/config/cras_card_config.c
602card_config_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) \
603	-I$(top_srcdir)/src/common -I$(top_srcdir)/src/server \
604	-I$(top_srcdir)/src/server/config $(CRAS_UT_TMPDIR_CFLAGS)
605card_config_unittest_LDADD = -lgtest -liniparser -lpthread
606
607checksum_unittest_SOURCES = tests/checksum_unittest.cc common/cras_checksum.c
608checksum_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common
609checksum_unittest_LDADD = -lgtest -lpthread
610
611cras_client_unittest_SOURCES = tests/cras_client_unittest.cc \
612	common/cras_config.c common/cras_util.c common/cras_file_wait.c
613cras_client_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
614	-I$(top_srcdir)/src/libcras
615cras_client_unittest_LDADD = -lgtest -lpthread -lspeexdsp
616
617cras_tm_unittest_SOURCES = tests/cras_tm_unittest.cc server/cras_tm.c
618cras_tm_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
619	 -I$(top_srcdir)/src/server
620cras_tm_unittest_LDADD = -lgtest -lpthread
621
622dev_io_unittest_SOURCES = \
623	$(CRAS_SELINUX_UNITTEST_SOURCES) \
624	common/cras_audio_format.c \
625	common/cras_shm.c \
626	server/cras_audio_area.c \
627	server/cras_fmt_conv.c \
628	server/cras_mix.c \
629	server/cras_mix_ops.c \
630	server/dev_io.c \
631	server/dev_stream.c \
632	server/linear_resampler.c \
633	tests/dev_io_stubs.cc \
634	tests/iodev_stub.cc \
635	tests/empty_audio_stub.cc \
636	tests/rstream_stub.cc \
637	tests/dev_io_unittest.cc
638dev_io_unittest_CXXFLAGS = \
639	-std=c++11 -Wno-noexcept-type
640dev_io_unittest_CPPFLAGS = \
641	$(COMMON_CPPFLAGS) \
642	-I$(top_srcdir)/src/common \
643	-I$(top_srcdir)/src/server \
644	-I$(top_srcdir)/src/server/config \
645	$(SELINUX_CFLAGS)
646dev_io_unittest_LDADD = \
647	libcrasmix.la \
648	$(CRAS_SSE4_2) \
649	$(CRAS_AVX) \
650	$(CRAS_AVX2) \
651	$(CRAS_FMA) \
652	$(SELINUX_LIBS) \
653	-lgtest -lrt -lpthread -ldl -lm -lspeexdsp
654
655dev_stream_unittest_SOURCES = tests/dev_stream_unittest.cc \
656	server/dev_stream.c
657dev_stream_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) \
658	-I$(top_srcdir)/src/common -I$(top_srcdir)/src/server
659dev_stream_unittest_LDADD = -lgtest -liniparser -lpthread
660
661device_blacklist_unittest_SOURCES = tests/device_blacklist_unittest.cc \
662	server/config/cras_device_blacklist.c
663device_blacklist_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) \
664	-I$(top_srcdir)/src/common -I$(top_srcdir)/src/server \
665	-I$(top_srcdir)/src/server/config $(CRAS_UT_TMPDIR_CFLAGS)
666device_blacklist_unittest_LDADD = -lgtest -liniparser -lpthread
667
668device_monitor_unittest_SOURCES = tests/device_monitor_unittest.cc
669device_monitor_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
670	-I$(top_srcdir)/src/server
671device_monitor_unittest_LDADD = -lgtest -lpthread
672
673dsp_core_unittest_SOURCES = tests/dsp_core_unittest.cc dsp/eq.c dsp/eq2.c \
674	dsp/biquad.c dsp/dsp_util.c dsp/crossover.c dsp/crossover2.c dsp/drc.c \
675	dsp/drc_kernel.c dsp/drc_math.c
676dsp_core_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) $(DSP_INCLUDE_PATHS)
677dsp_core_unittest_LDADD = -lgtest -lpthread
678
679dsp_ini_unittest_SOURCES = tests/dsp_ini_unittest.cc \
680	server/cras_dsp_ini.c server/cras_expr.c common/dumper.c
681dsp_ini_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
682	-I$(top_srcdir)/src/server
683dsp_ini_unittest_LDADD = -lgtest -liniparser -lpthread
684
685dsp_pipeline_unittest_SOURCES = tests/cras_dsp_pipeline_unittest.cc \
686	server/cras_dsp_ini.c server/cras_expr.c server/cras_dsp_pipeline.c \
687	common/dumper.c dsp/dsp_util.c
688dsp_pipeline_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) \
689	-I$(top_srcdir)/src/server $(DSP_INCLUDE_PATHS)
690dsp_pipeline_unittest_LDADD = -lgtest -lrt -liniparser -lpthread
691
692dsp_unittest_SOURCES = tests/dsp_unittest.cc \
693	server/cras_dsp.c server/cras_dsp_ini.c server/cras_dsp_pipeline.c \
694	server/cras_expr.c common/dumper.c dsp/dsp_util.c \
695	dsp/tests/dsp_test_util.c
696dsp_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) \
697	-I$(top_srcdir)/src/server $(DSP_INCLUDE_PATHS)
698dsp_unittest_LDADD = -lgtest -lrt -liniparser -lpthread
699
700dumper_unittest_SOURCES = tests/dumper_unittest.cc common/dumper.c
701dumper_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common
702dumper_unittest_LDADD = -lgtest -lpthread
703
704edid_utils_unittest_SOURCES = tests/edid_utils_unittest.cc common/edid_utils.c
705edid_utils_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common
706edid_utils_unittest_LDADD = -lgtest -lpthread
707
708expr_unittest_SOURCES = tests/expr_unittest.cc server/cras_expr.c common/dumper.c
709expr_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
710	-I$(top_srcdir)/src/server
711expr_unittest_LDADD = -lgtest -lpthread
712
713file_wait_unittest_SOURCES = tests/file_wait_unittest.cc \
714	common/cras_file_wait.c common/cras_util.c
715file_wait_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
716	$(CRAS_UT_TMPDIR_CFLAGS)
717file_wait_unittest_LDADD = -lgtest -lpthread
718
719
720float_buffer_unittest_SOURCES = tests/float_buffer_unittest.cc
721float_buffer_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
722	-I$(top_srcdir)/src/server
723float_buffer_unittest_LDADD = -lgtest -lpthread
724
725fmt_conv_unittest_SOURCES = tests/fmt_conv_unittest.cc server/cras_fmt_conv.c
726fmt_conv_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
727	 -I$(top_srcdir)/src/server
728fmt_conv_unittest_LDADD = -lasound -lspeexdsp -lgtest -lpthread
729
730hfp_info_unittest_SOURCES = tests/hfp_info_unittest.cc
731hfp_info_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
732	-I$(top_srcdir)/src/server
733hfp_info_unittest_LDADD = -lgtest -lpthread
734
735if HAVE_DBUS
736hfp_iodev_unittest_SOURCES = tests/hfp_iodev_unittest.cc \
737	server/cras_hfp_iodev.c common/sfh.c
738hfp_iodev_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
739	-I$(top_srcdir)/src/server $(DBUS_CFLAGS)
740hfp_iodev_unittest_LDADD = -lgtest -lpthread $(DBUS_LIBS)
741
742hfp_slc_unittest_SOURCES = tests/hfp_slc_unittest.cc \
743	server/cras_hfp_slc.c
744hfp_slc_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
745	-I$(top_srcdir)/src/server $(DBUS_CFLAGS)
746hfp_slc_unittest_LDADD = -lgtest -lpthread $(DBUS_LIBS)
747endif
748
749buffer_share_unittest_SOURCES = tests/buffer_share_unittest.cc \
750	server/buffer_share.c
751buffer_share_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) \
752	-I$(top_srcdir)/src/common -I$(top_srcdir)/src/server
753buffer_share_unittest_LDADD = -lgtest -liniparser -lpthread
754
755iodev_list_unittest_SOURCES = tests/iodev_list_unittest.cc \
756	server/cras_iodev_list.c
757iodev_list_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
758	 -I$(top_srcdir)/src/server
759iodev_list_unittest_LDADD = -lgtest -lpthread
760
761loopback_iodev_unittest_SOURCES = tests/loopback_iodev_unittest.cc \
762	server/cras_loopback_iodev.c common/sfh.c
763loopback_iodev_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) \
764	-I$(top_srcdir)/src/common \
765	-I$(top_srcdir)/src/server
766loopback_iodev_unittest_LDADD = -lgtest -lpthread
767
768iodev_unittest_SOURCES = tests/iodev_unittest.cc \
769	server/cras_iodev.c
770iodev_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
771	 -I$(top_srcdir)/src/server
772iodev_unittest_LDADD = -lgtest -lpthread
773
774mix_unittest_SOURCES = tests/mix_unittest.cc server/cras_mix.c
775mix_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
776	 -I$(top_srcdir)/src/server
777mix_unittest_LDADD = libcrasmix.la \
778	$(CRAS_SSE4_2) \
779	$(CRAS_AVX) \
780	$(CRAS_AVX2) \
781	$(CRAS_FMA) \
782	-lgtest \
783	-lpthread
784
785linear_resampler_unittest_SOURCES = tests/linear_resampler_unittest.cc \
786	server/linear_resampler.c server/cras_audio_area.c
787linear_resampler_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
788	 -I$(top_srcdir)/src/server
789linear_resampler_unittest_LDADD = -lgtest -lpthread
790
791observer_unittest_SOURCES = tests/observer_unittest.cc
792observer_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
793	-I$(top_srcdir)/src/server
794observer_unittest_LDADD = -lgtest -lpthread
795
796polled_interval_checker_unittest_SOURCES = tests/polled_interval_checker_unittest.cc \
797    server/polled_interval_checker.c
798polled_interval_checker_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
799	-I$(top_srcdir)/src/server
800polled_interval_checker_unittest_LDADD = -lgtest -lpthread
801
802ramp_unittest_SOURCES = tests/ramp_unittest.cc
803ramp_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
804	-I$(top_srcdir)/src/server
805ramp_unittest_LDADD = -lgtest -lpthread
806
807rate_estimator_unittest_SOURCES = tests/rate_estimator_unittest.cc server/rate_estimator.c
808rate_estimator_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
809	 -I$(top_srcdir)/src/server
810rate_estimator_unittest_LDADD = -lgtest -lpthread
811
812rclient_unittest_SOURCES = tests/rclient_unittest.cc
813rclient_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
814	 -I$(top_srcdir)/src/server $(CRAS_UT_TMPDIR_CFLAGS)
815rclient_unittest_LDADD = -lgtest -lpthread
816
817rstream_unittest_SOURCES = tests/rstream_unittest.cc server/cras_rstream.c \
818	common/cras_shm.c $(CRAS_SELINUX_UNITTEST_SOURCES)
819rstream_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
820	 -I$(top_srcdir)/src/server $(SELINUX_CFLAGS)
821rstream_unittest_LDADD = $(SELINUX_LIBS) \
822	-lasound -lgtest -lpthread -lrt
823
824server_metrics_unittest_SOURCES = tests/server_metrics_unittest.cc
825server_metrics_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
826	-I$(top_srcdir)/src/server
827server_metrics_unittest_LDADD = -lgtest -lpthread
828
829shm_unittest_SOURCES = tests/shm_unittest.cc
830shm_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common
831shm_unittest_LDADD = -lgtest -lpthread
832
833softvol_curve_unittest_SOURCES = tests/softvol_curve_unittest.cc server/softvol_curve.c
834softvol_curve_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
835	 -I$(top_srcdir)/src/server
836softvol_curve_unittest_LDADD = -lgtest -lpthread
837
838stream_list_unittest_SOURCES = tests/stream_list_unittest.cc \
839	server/stream_list.c
840stream_list_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
841	 -I$(top_srcdir)/src/server
842stream_list_unittest_LDADD = -lgtest -lpthread
843
844system_state_unittest_SOURCES = tests/system_state_unittest.cc \
845	server/cras_system_state.c common/cras_shm.c \
846	server/config/cras_board_config.c $(CRAS_SELINUX_UNITTEST_SOURCES)
847system_state_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) \
848	-I$(top_srcdir)/src/common -I$(top_srcdir)/src/server \
849	-I$(top_srcdir)/src/server/config $(SELINUX_CFLAGS)
850system_state_unittest_LDADD = $(SELINUX_LIBS) \
851	-lgtest -liniparser -lpthread -lrt
852
853timing_unittest_SOURCES = \
854	$(CRAS_SELINUX_UNITTEST_SOURCES) \
855	common/cras_audio_format.c \
856	common/cras_shm.c \
857	server/cras_audio_area.c \
858	server/cras_fmt_conv.c \
859	server/cras_mix.c \
860	server/cras_mix_ops.c \
861	server/dev_io.c \
862	server/dev_stream.c \
863	server/linear_resampler.c \
864	tests/dev_io_stubs.cc \
865	tests/iodev_stub.cc \
866	tests/empty_audio_stub.cc \
867	tests/rstream_stub.cc \
868	tests/timing_unittest.cc
869timing_unittest_CXXFLAGS = \
870	-std=c++11 -Wno-noexcept-type
871timing_unittest_CPPFLAGS = \
872	$(COMMON_CPPFLAGS) \
873	-I$(top_srcdir)/src/common \
874	-I$(top_srcdir)/src/server \
875	-I$(top_srcdir)/src/server/config \
876	$(SELINUX_CFLAGS)
877timing_unittest_LDADD = \
878	libcrasmix.la \
879	$(CRAS_SSE4_2) \
880	$(CRAS_AVX) \
881	$(CRAS_AVX2) \
882	$(CRAS_FMA) \
883	$(SELINUX_LIBS) \
884	-lgtest -lrt -lpthread -ldl -lm -lspeexdsp
885
886utf8_unittest_SOURCES = tests/utf8_unittest.cc server/cras_utf8.c
887utf8_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common \
888	-I$(top_srcdir)/src/server
889utf8_unittest_LDADD = -lgtest -lpthread
890
891util_unittest_SOURCES = tests/util_unittest.cc common/cras_util.c \
892	common/cras_config.c
893util_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) -I$(top_srcdir)/src/common
894util_unittest_LDADD = -lgtest -lpthread
895
896volume_curve_unittest_SOURCES = tests/volume_curve_unittest.cc \
897	server/cras_volume_curve.c
898volume_curve_unittest_CPPFLAGS = $(COMMON_CPPFLAGS) \
899	-I$(top_srcdir)/src/common -I$(top_srcdir)/src/server
900volume_curve_unittest_LDADD = -lgtest -lpthread
901