#!/bin/bash
#
#  BLIS    
#  An object-based framework for developing high-performance BLAS-like
#  libraries.
#
#  Copyright (C) 2014, The University of Texas at Austin
#
#  Redistribution and use in source and binary forms, with or without
#  modification, are permitted provided that the following conditions are
#  met:
#   - Redistributions of source code must retain the above copyright
#     notice, this list of conditions and the following disclaimer.
#   - Redistributions in binary form must reproduce the above copyright
#     notice, this list of conditions and the following disclaimer in the
#     documentation and/or other materials provided with the distribution.
#   - Neither the name of The University of Texas at Austin nor the names
#     of its contributors may be used to endorse or promote products
#     derived from this software without specific prior written permission.
#
#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
#  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
#  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
#  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
#  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
#  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
#  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
#  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
#  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
#  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
#  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
#

#
# Makefile
#
# Field G. Van Zee
# 
# Makefile for standalone BLIS test drivers.
#

#
# --- Makefile PHONY target definitions ----------------------------------------
#

.PHONY: all \
        blis-gemm-st openblas-gemm-st mkl-gemm-st acml-gemm-st \
        blis-gemm-mt openblas-gemm-mt mkl-gemm-mt acml-gemm-mt \
        clean cleanx



#
# --- Makefile initialization --------------------------------------------------
#

# Define the name of the common makefile fragment.
COMMON_MK_FILE    := common.mk

# Important locations and directory names.
RELPATH           := ../..
CONFIG_DIR        := config



#
# --- Include makefile configuration file --------------------------------------
#

# Construct the path to the makefile configuration file that was generated by
# the configure script.
COMMON_MK_PATH    := $(RELPATH)/$(COMMON_MK_FILE)

# Include the common makefile fragment.
-include $(COMMON_MK_PATH)

# Detect whether we actually got the common makefile fragment. If we didn't,
# then it is likely that the user has not yet generated it (via configure).
ifeq ($(strip $(COMMON_MK_INCLUDED)),yes)
COMMON_MK_PRESENT := yes
else
COMMON_MK_PRESENT := no
endif

# Override the DIST_PATH value obtained from config.mk, since it is relative
# to the build directory.
DIST_PATH         := ..

# Now we have access to CONFIG_NAME, which tells us which sub-directory of the
# config directory to use as our configuration.
CONFIG_PATH       := $(RELPATH)/$(CONFIG_DIR)/$(CONFIG_NAME)



#
# --- BLAS and LAPACK implementations ------------------------------------------
#

# BLIS library and header path. This is simply wherever it was installed.
BLIS_LIB_PATH  := $(INSTALL_PREFIX)/lib
BLIS_INC_PATH  := $(INSTALL_PREFIX)/include/blis

# BLIS library.
BLIS_LIB       := $(BLIS_LIB_PATH)/libblis.a

# BLAS library path(s). This is where the BLAS libraries reside.
HOME_LIB_PATH  := $(HOME)/flame/lib
#MKL_LIB_PATH   := /opt/apps/intel/13/composer_xe_2013.2.146/mkl/lib/intel64
MKL_LIB_PATH   := $(HOME)/intel/mkl/lib/intel64
ICC_LIB_PATH   := /opt/apps/intel/13/composer_xe_2013.2.146/compiler/lib/intel64
ACML_LIB_PATH  := $(HOME_LIB_PATH)/acml/5.3.1/gfortran64_fma4_int64/lib
ACMLP_LIB_PATH := $(HOME_LIB_PATH)/acml/5.3.1/gfortran64_fma4_mp_int64/lib

# OpenBLAS
OPENBLAS_LIB   := $(HOME_LIB_PATH)/libopenblas.a
OPENBLASP_LIB  := $(HOME_LIB_PATH)/libopenblasp.a

# ATLAS
ATLAS_LIB      := $(HOME_LIB_PATH)/libf77blas.a \
                  $(HOME_LIB_PATH)/libatlas.a

# MKL
MKL_LIB        := -L$(MKL_LIB_PATH) \
                  -lmkl_intel_lp64 \
                  -lmkl_core \
                  -lmkl_sequential \
                  -lpthread -lm -ldl
#MKLP_LIB       := -L$(MKL_LIB_PATH) \
#                  -lmkl_intel_thread \
#                  -lmkl_core \
#                  -lmkl_intel_ilp64 \
#                  -L$(ICC_LIB_PATH) \
#                  -liomp5
MKLP_LIB       := -L$(MKL_LIB_PATH) \
                  -lmkl_intel_lp64 \
                  -lmkl_core \
                  -lmkl_gnu_thread \
                  -lpthread -lm -ldl
                  #-L$(ICC_LIB_PATH) \
                  #-lgomp

# ACML
ACML_LIB       := -L$(ACML_LIB_PATH) \
                  -lgfortran -lm -lrt -ldl -lacml
ACMLP_LIB      := -L$(ACMLP_LIB_PATH) \
                  -lgfortran -lm -lrt -ldl -lacml_mp



#
# --- General build definitions ------------------------------------------------
#

TEST_SRC_PATH  := .
TEST_OBJ_PATH  := .

# Gather all local object files.
TEST_OBJS      := $(patsubst $(TEST_SRC_PATH)/%.c, \
                             $(TEST_OBJ_PATH)/%.o, \
                             $(wildcard $(TEST_SRC_PATH)/*.c))

# Override CFLAGS from make_defs.mk here, if desired.
#CFLAGS         := -g -O2 -march=native

# Add installed and local header paths to CFLAGS
CFLAGS         += -I$(BLIS_INC_PATH) -I$(TEST_SRC_PATH) #-I$(ACML_INC_PATH)

LINKER         := $(CC)
LDFLAGS        := #-L/home/00146/field/gnu/gcc-4.8.2/lib64
LDFLAGS        += -lgfortran -lm -lpthread -fopenmp


# Datatype
DT_S     := -DDT=BLIS_FLOAT
DT_D     := -DDT=BLIS_DOUBLE
DT_C     := -DDT=BLIS_SCOMPLEX
DT_Z     := -DDT=BLIS_DCOMPLEX

# Which library?
BLI_DEF  := -DBLIS
BLA_DEF  := -DBLAS

# Complex implementation type
D3MHW    := -DIND=BLIS_3MH
D3M3     := -DIND=BLIS_3M3
D3M2     := -DIND=BLIS_3M2
D3M1     := -DIND=BLIS_3M1
D4MHW    := -DIND=BLIS_4MH
D4M1B    := -DIND=BLIS_4M1B
D4M1A    := -DIND=BLIS_4M1A
DNAT     := -DIND=BLIS_NAT

# Implementation string
STR_3MHW := -DSTR=\"3mhw\"
STR_3M3  := -DSTR=\"3m3\"
STR_3M2  := -DSTR=\"3m2\"
STR_3M1  := -DSTR=\"3m1\"
STR_4MHW := -DSTR=\"4mhw\"
STR_4M1B := -DSTR=\"4m1b\"
STR_4M1A := -DSTR=\"4m1a\"
STR_NAT  := -DSTR=\"asm\"
STR_OBL  := -DSTR=\"openblas\"
STR_MKL  := -DSTR=\"mkl\"
STR_ACML := -DSTR=\"acml\"

# Single or multithreaded string
STR_ST   := -DTHR_STR=\"st\"
STR_MT   := -DTHR_STR=\"mt\"

# Problem size specification
PDEF_ST  := -DP_BEGIN=80 \
            -DP_END=2000 \
            -DP_INC=80

PDEF_MT  := -DP_BEGIN=80 \
            -DP_END=4000 \
            -DP_INC=80



#
# --- Targets/rules ------------------------------------------------------------
#

all: blis-all openblas-all

intel: blis-all openblas-all mkl-all

amd: blis-all openblas-all acml-all

blis-all: blis-gemm-st \
          blis-gemm-mt

openblas-all: openblas-gemm-st \
              openblas-gemm-mt

mkl-all: mkl-gemm-st \
         mkl-gemm-mt

acml-all: acml-gemm-st \
          acml-gemm-mt

blis-gemm-st: \
      test_sgemm_asm_blis_st.x \
      test_dgemm_asm_blis_st.x \
      \
      test_cgemm_3mhw_blis_st.x \
      test_zgemm_3mhw_blis_st.x \
      test_cgemm_3m3_blis_st.x \
      test_zgemm_3m3_blis_st.x \
      test_cgemm_3m2_blis_st.x \
      test_zgemm_3m2_blis_st.x \
      test_cgemm_3m1_blis_st.x \
      test_zgemm_3m1_blis_st.x \
      test_cgemm_4mhw_blis_st.x \
      test_zgemm_4mhw_blis_st.x \
      test_cgemm_4m1b_blis_st.x \
      test_zgemm_4m1b_blis_st.x \
      test_cgemm_4m1a_blis_st.x \
      test_zgemm_4m1a_blis_st.x \
      test_cgemm_asm_blis_st.x \
      test_zgemm_asm_blis_st.x

blis-gemm-mt: \
      test_sgemm_asm_blis_mt.x \
      test_dgemm_asm_blis_mt.x \
      \
      test_cgemm_3mhw_blis_mt.x \
      test_zgemm_3mhw_blis_mt.x \
      test_cgemm_3m3_blis_mt.x \
      test_zgemm_3m3_blis_mt.x \
      test_cgemm_3m2_blis_mt.x \
      test_zgemm_3m2_blis_mt.x \
      test_cgemm_3m1_blis_mt.x \
      test_zgemm_3m1_blis_mt.x \
      test_cgemm_4mhw_blis_mt.x \
      test_zgemm_4mhw_blis_mt.x \
      test_cgemm_4m1b_blis_mt.x \
      test_zgemm_4m1b_blis_mt.x \
      test_cgemm_4m1a_blis_mt.x \
      test_zgemm_4m1a_blis_mt.x \
      test_cgemm_asm_blis_mt.x \
      test_zgemm_asm_blis_mt.x

openblas-gemm-st: \
      test_sgemm_openblas_st.x \
      test_dgemm_openblas_st.x \
      test_cgemm_openblas_st.x \
      test_zgemm_openblas_st.x

openblas-gemm-mt: \
      test_cgemm_openblas_mt.x \
      test_zgemm_openblas_mt.x

mkl-gemm-st: \
      test_sgemm_mkl_st.x \
      test_dgemm_mkl_st.x \
      test_cgemm_mkl_st.x \
      test_zgemm_mkl_st.x

mkl-gemm-mt: \
      test_cgemm_mkl_mt.x \
      test_zgemm_mkl_mt.x

acml-gemm-st: \
      test_sgemm_acml_st.x \
      test_dgemm_acml_st.x \
      test_cgemm_acml_st.x \
      test_zgemm_acml_st.x

acml-gemm-mt: \
      test_cgemm_acml_mt.x \
      test_zgemm_acml_mt.x



# --Object file rules --

$(TEST_OBJ_PATH)/%.o: $(TEST_SRC_PATH)/%.c
	$(CC) $(CFLAGS) -c $< -o $@

# blis 3mhw
test_z%_3mhw_blis_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_Z) $(BLI_DEF) $(D3MHW) $(STR_3MHW) $(STR_ST) -c $< -o $@

test_c%_3mhw_blis_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_C) $(BLI_DEF) $(D3MHW) $(STR_3MHW) $(STR_ST) -c $< -o $@

test_z%_3mhw_blis_mt.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_MT) $(DT_Z) $(BLI_DEF) $(D3MHW) $(STR_3MHW) $(STR_MT) -c $< -o $@

test_c%_3mhw_blis_mt.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_MT) $(DT_C) $(BLI_DEF) $(D3MHW) $(STR_3MHW) $(STR_MT) -c $< -o $@

# blis 3m3
test_z%_3m3_blis_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_Z) $(BLI_DEF) $(D3M3)  $(STR_3M3)  $(STR_ST) -c $< -o $@

test_c%_3m3_blis_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_C) $(BLI_DEF) $(D3M3)  $(STR_3M3)  $(STR_ST) -c $< -o $@

test_z%_3m3_blis_mt.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_MT) $(DT_Z) $(BLI_DEF) $(D3M3)  $(STR_3M3)  $(STR_MT) -c $< -o $@

test_c%_3m3_blis_mt.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_MT) $(DT_C) $(BLI_DEF) $(D3M3)  $(STR_3M3)  $(STR_MT) -c $< -o $@

# blis 3m2
test_z%_3m2_blis_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_Z) $(BLI_DEF) $(D3M2)  $(STR_3M2)  $(STR_ST) -c $< -o $@

test_c%_3m2_blis_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_C) $(BLI_DEF) $(D3M2)  $(STR_3M2)  $(STR_ST) -c $< -o $@

test_z%_3m2_blis_mt.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_MT) $(DT_Z) $(BLI_DEF) $(D3M2)  $(STR_3M2)  $(STR_MT) -c $< -o $@

test_c%_3m2_blis_mt.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_MT) $(DT_C) $(BLI_DEF) $(D3M2)  $(STR_3M2)  $(STR_MT) -c $< -o $@

# blis 3m1
test_z%_3m1_blis_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_Z) $(BLI_DEF) $(D3M1)  $(STR_3M1)  $(STR_ST) -c $< -o $@

test_c%_3m1_blis_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_C) $(BLI_DEF) $(D3M1)  $(STR_3M1)  $(STR_ST) -c $< -o $@

test_z%_3m1_blis_mt.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_MT) $(DT_Z) $(BLI_DEF) $(D3M1)  $(STR_3M1)  $(STR_MT) -c $< -o $@

test_c%_3m1_blis_mt.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_MT) $(DT_C) $(BLI_DEF) $(D3M1)  $(STR_3M1)  $(STR_MT) -c $< -o $@

# blis 4mhw
test_z%_4mhw_blis_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_Z) $(BLI_DEF) $(D4MHW) $(STR_4MHW) $(STR_ST) -c $< -o $@

test_c%_4mhw_blis_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_C) $(BLI_DEF) $(D4MHW) $(STR_4MHW) $(STR_ST) -c $< -o $@

test_z%_4mhw_blis_mt.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_MT) $(DT_Z) $(BLI_DEF) $(D4MHW) $(STR_4MHW) $(STR_MT) -c $< -o $@

test_c%_4mhw_blis_mt.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_MT) $(DT_C) $(BLI_DEF) $(D4MHW) $(STR_4MHW) $(STR_MT) -c $< -o $@

# blis 4m1b
test_z%_4m1b_blis_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_Z) $(BLI_DEF) $(D4M1B) $(STR_4M1B) $(STR_ST) -c $< -o $@

test_c%_4m1b_blis_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_C) $(BLI_DEF) $(D4M1B) $(STR_4M1B) $(STR_ST) -c $< -o $@

test_z%_4m1b_blis_mt.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_MT) $(DT_Z) $(BLI_DEF) $(D4M1B) $(STR_4M1B) $(STR_MT) -c $< -o $@

test_c%_4m1b_blis_mt.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_MT) $(DT_C) $(BLI_DEF) $(D4M1B) $(STR_4M1B) $(STR_MT) -c $< -o $@

# blis 4m1a
test_z%_4m1a_blis_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_Z) $(BLI_DEF) $(D4M1A) $(STR_4M1A) $(STR_ST) -c $< -o $@

test_c%_4m1a_blis_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_C) $(BLI_DEF) $(D4M1A) $(STR_4M1A) $(STR_ST) -c $< -o $@

test_z%_4m1a_blis_mt.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_MT) $(DT_Z) $(BLI_DEF) $(D4M1A) $(STR_4M1A) $(STR_MT) -c $< -o $@

test_c%_4m1a_blis_mt.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_MT) $(DT_C) $(BLI_DEF) $(D4M1A) $(STR_4M1A) $(STR_MT) -c $< -o $@

# blis asm
test_d%_asm_blis_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_D) $(BLI_DEF) $(DNAT)  $(STR_NAT)  $(STR_ST) -c $< -o $@

test_s%_asm_blis_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_S) $(BLI_DEF) $(DNAT)  $(STR_NAT)  $(STR_ST) -c $< -o $@

test_z%_asm_blis_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_Z) $(BLI_DEF) $(DNAT)  $(STR_NAT)  $(STR_ST) -c $< -o $@

test_c%_asm_blis_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_C) $(BLI_DEF) $(DNAT)  $(STR_NAT)  $(STR_ST) -c $< -o $@

test_d%_asm_blis_mt.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_MT) $(DT_D) $(BLI_DEF) $(DNAT)  $(STR_NAT)  $(STR_MT) -c $< -o $@

test_s%_asm_blis_mt.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_MT) $(DT_S) $(BLI_DEF) $(DNAT)  $(STR_NAT)  $(STR_MT) -c $< -o $@

test_z%_asm_blis_mt.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_MT) $(DT_Z) $(BLI_DEF) $(DNAT)  $(STR_NAT)  $(STR_MT) -c $< -o $@

test_c%_asm_blis_mt.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_MT) $(DT_C) $(BLI_DEF) $(DNAT)  $(STR_NAT)  $(STR_MT) -c $< -o $@

# openblas
test_d%_openblas_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_D) $(BLA_DEF) $(DNAT)  $(STR_OBL)  $(STR_ST) -c $< -o $@

test_s%_openblas_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_S) $(BLA_DEF) $(DNAT)  $(STR_OBL)  $(STR_ST) -c $< -o $@

test_z%_openblas_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_Z) $(BLA_DEF) $(DNAT)  $(STR_OBL)  $(STR_ST) -c $< -o $@

test_c%_openblas_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_C) $(BLA_DEF) $(DNAT)  $(STR_OBL)  $(STR_ST) -c $< -o $@

test_z%_openblas_mt.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_MT) $(DT_Z) $(BLA_DEF) $(DNAT)  $(STR_OBL)  $(STR_MT) -c $< -o $@

test_c%_openblas_mt.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_MT) $(DT_C) $(BLA_DEF) $(DNAT)  $(STR_OBL)  $(STR_MT) -c $< -o $@

# mkl
test_d%_mkl_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_D) $(BLA_DEF) $(DNAT)  $(STR_MKL)  $(STR_ST) -c $< -o $@

test_s%_mkl_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_S) $(BLA_DEF) $(DNAT)  $(STR_MKL)  $(STR_ST) -c $< -o $@

test_z%_mkl_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_Z) $(BLA_DEF) $(DNAT)  $(STR_MKL)  $(STR_ST) -c $< -o $@

test_c%_mkl_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_C) $(BLA_DEF) $(DNAT)  $(STR_MKL)  $(STR_ST) -c $< -o $@

test_z%_mkl_mt.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_MT) $(DT_Z) $(BLA_DEF) $(DNAT)  $(STR_MKL)  $(STR_MT) -c $< -o $@

test_c%_mkl_mt.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_MT) $(DT_C) $(BLA_DEF) $(DNAT)  $(STR_MKL)  $(STR_MT) -c $< -o $@

# acml
test_d%_acml_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_D) $(BLA_DEF) $(DNAT)  $(STR_ACML) $(STR_ST) -c $< -o $@

test_s%_acml_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_S) $(BLA_DEF) $(DNAT)  $(STR_ACML) $(STR_ST) -c $< -o $@

test_z%_acml_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_Z) $(BLA_DEF) $(DNAT)  $(STR_ACML) $(STR_ST) -c $< -o $@

test_c%_acml_st.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_ST) $(DT_C) $(BLA_DEF) $(DNAT)  $(STR_ACML) $(STR_ST) -c $< -o $@

test_z%_acml_mt.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_MT) $(DT_Z) $(BLA_DEF) $(DNAT)  $(STR_ACML) $(STR_MT) -c $< -o $@

test_c%_acml_mt.o: test_%.c
	$(CC) $(CFLAGS) $(PDEF_MT) $(DT_C) $(BLA_DEF) $(DNAT)  $(STR_ACML) $(STR_MT) -c $< -o $@


# -- Executable file rules --

# NOTE: For the BLAS test drivers, we place the BLAS libraries before BLIS
# on the link command line in case BLIS was configured with the BLAS
# compatibility layer. This prevents BLIS from inadvertently getting called
# for the BLAS routines we are trying to test with.

test_%_openblas_st.x: test_%_openblas_st.o $(BLIS_LIB)
	$(LINKER) $<  $(OPENBLAS_LIB)  $(BLIS_LIB) $(LDFLAGS) -o $@

test_%_openblas_mt.x: test_%_openblas_mt.o $(BLIS_LIB)
	$(LINKER) $<  $(OPENBLASP_LIB) $(BLIS_LIB) $(LDFLAGS) -o $@

test_%_mkl_st.x: test_%_mkl_st.o $(BLIS_LIB)
	$(LINKER) $<  $(MKL_LIB)       $(BLIS_LIB) $(LDFLAGS) -o $@

test_%_mkl_mt.x: test_%_mkl_mt.o $(BLIS_LIB)
	$(LINKER) $<  $(MKLP_LIB)      $(BLIS_LIB) $(LDFLAGS) -o $@

test_%_acml_st.x: test_%_acml_st.o $(BLIS_LIB)
	$(LINKER) $<  $(ACML_LIB)      $(BLIS_LIB) $(LDFLAGS) -o $@

test_%_acml_mt.x: test_%_acml_mt.o $(BLIS_LIB)
	$(LINKER) $<  $(ACMLP_LIB)     $(BLIS_LIB) $(LDFLAGS) -o $@

test_%_blis_st.x: test_%_blis_st.o $(BLIS_LIB)
	$(LINKER) $<                   $(BLIS_LIB) $(LDFLAGS) -o $@

test_%_blis_mt.x: test_%_blis_mt.o $(BLIS_LIB)
	$(LINKER) $<                   $(BLIS_LIB) $(LDFLAGS) -o $@


# -- Clean rules --

clean: cleanx

cleanx:
	- $(RM_F) *.o *.x

