# Copyright 2015-2016 Intel Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice (including the next
# paragraph) shall be included in all copies or substantial portions of the
# Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.

noinst_LTLIBRARIES += compiler/libintel_compiler.la

compiler_libintel_compiler_la_CPPFLAGS = \
	-I$(top_builddir)/src/intel/compiler \
	-I$(top_srcdir)/src/intel/compiler \
	$(AM_CPPFLAGS)

compiler_libintel_compiler_la_SOURCES = \
	$(COMPILER_FILES) \
	$(COMPILER_GENERATED_FILES)

BUILT_SOURCES += $(COMPILER_GENERATED_FILES)

compiler/brw_nir_trig_workarounds.c: compiler/brw_nir_trig_workarounds.py \
                                     $(top_srcdir)/src/compiler/nir/nir_algebraic.py
	$(MKDIR_GEN)
	$(AM_V_GEN) $(PYTHON2) $(PYTHON_FLAGS) $(srcdir)/compiler/brw_nir_trig_workarounds.py -p $(top_srcdir)/src/compiler/nir > $@ || ($(RM) $@; false)

EXTRA_DIST += \
	compiler/brw_nir_trig_workarounds.py

# ----------------------------------------------------------------------------
#  Tests
# ----------------------------------------------------------------------------

TEST_LIBS = \
	$(top_builddir)/src/gtest/libgtest.la \
	compiler/libintel_compiler.la \
	common/libintel_common.la \
	$(top_builddir)/src/compiler/nir/libnir.la \
	$(top_builddir)/src/util/libmesautil.la \
	$(top_builddir)/src/intel/isl/libisl.la \
	$(PTHREAD_LIBS) \
	$(DLOPEN_LIBS)

COMPILER_TESTS = \
	compiler/test_fs_cmod_propagation \
	compiler/test_fs_copy_propagation \
	compiler/test_fs_saturate_propagation \
	compiler/test_eu_compact \
	compiler/test_eu_validate \
	compiler/test_vf_float_conversions \
	compiler/test_vec4_cmod_propagation \
	compiler/test_vec4_copy_propagation \
	compiler/test_vec4_register_coalesce

TESTS += $(COMPILER_TESTS)
check_PROGRAMS += $(COMPILER_TESTS)

compiler_test_fs_cmod_propagation_SOURCES = \
	compiler/test_fs_cmod_propagation.cpp
compiler_test_fs_cmod_propagation_LDADD = $(TEST_LIBS)

compiler_test_fs_copy_propagation_SOURCES = \
	compiler/test_fs_copy_propagation.cpp
compiler_test_fs_copy_propagation_LDADD = $(TEST_LIBS)

compiler_test_fs_saturate_propagation_SOURCES = \
	compiler/test_fs_saturate_propagation.cpp
compiler_test_fs_saturate_propagation_LDADD = $(TEST_LIBS)

compiler_test_vf_float_conversions_SOURCES = \
	compiler/test_vf_float_conversions.cpp
compiler_test_vf_float_conversions_LDADD = $(TEST_LIBS)

compiler_test_vec4_register_coalesce_SOURCES = \
	compiler/test_vec4_register_coalesce.cpp
compiler_test_vec4_register_coalesce_LDADD = $(TEST_LIBS)

compiler_test_vec4_copy_propagation_SOURCES = \
	compiler/test_vec4_copy_propagation.cpp
compiler_test_vec4_copy_propagation_LDADD = $(TEST_LIBS)

compiler_test_vec4_cmod_propagation_SOURCES = \
	compiler/test_vec4_cmod_propagation.cpp
compiler_test_vec4_cmod_propagation_LDADD = $(TEST_LIBS)

# Strictly speaking this is neither a C++ test nor using gtest - we can address
# address that at a later point. Until then, this allows us a to simplify things.
compiler_test_eu_compact_SOURCES = \
	compiler/test_eu_compact.cpp
compiler_test_eu_compact_LDADD = $(TEST_LIBS)

compiler_test_eu_validate_SOURCES = \
	compiler/test_eu_validate.cpp
compiler_test_eu_validate_LDADD = $(TEST_LIBS)