##******************************************************************************
##  Copyright(C) 2001-2013 Intel Corporation. All Rights Reserved.
##  
##  The source code, information  and  material ("Material") contained herein is
##  owned  by Intel Corporation or its suppliers or licensors, and title to such
##  Material remains  with Intel Corporation  or its suppliers or licensors. The
##  Material  contains proprietary information  of  Intel or  its  suppliers and
##  licensors. The  Material is protected by worldwide copyright laws and treaty
##  provisions. No  part  of  the  Material  may  be  used,  copied, reproduced,
##  modified, published, uploaded, posted, transmitted, distributed or disclosed
##  in any way  without Intel's  prior  express written  permission. No  license
##  under  any patent, copyright  or  other intellectual property rights  in the
##  Material  is  granted  to  or  conferred  upon  you,  either  expressly,  by
##  implication, inducement,  estoppel or  otherwise.  Any  license  under  such
##  intellectual  property  rights must  be express  and  approved  by  Intel in
##  writing.
##  
##  *Third Party trademarks are the property of their respective owners.
##  
##  Unless otherwise  agreed  by Intel  in writing, you may not remove  or alter
##  this  notice or  any other notice embedded  in Materials by Intel or Intel's
##  suppliers or licensors in any way.
##
##******************************************************************************
##  Content:
##      Intel(R) Math Kernel Library PBLAS C examples creation and run
##
##******************************************************************************
ROOTdir=$(shell pwd)
include make.inc
include pblasc.lst

help:
	@echo "Usage:"
	@echo
	@echo "make [help]"
	@echo "   print this help."
	@echo
	@echo "make <targets> [mpi=mpi_name] [compiler=compiler_name]"
	@echo "      [interface=interface_name] [LIBdir=<libdir>] [MPIdir=<mpidir>] [example=example_list]"
	@echo "   makes examples. Make sure environment is set properly before testing."
	@echo "   If variables are not set, the defaults are:"
	@echo "      mpi=intelmpi - test with Intel MPI 3.x (or 4.x)"
	@echo "      compiler=intel - test with Intel (R) compilers"
	@echo "      LIBdir=../../lib/ia32(intel64) - path to MKL binaries"
	@echo "      MPIdir not set - let the system locate MPI scripts like mpirun,"
	@echo "          set PATH, LD_LIBRARY_PATH properly before testing."
	@echo "   Variables could be set to:"
	@echo "      mpi=intelmpi - test with Intel MPI 3.x (or 4.x)"
	@echo "          Don't forget to start Intel MPI 3.x (or 4.x) daemon before testing."
	@echo "      mpi=openmpi - test with Open MPI 1.2"
	@echo "      mpi=mpich2 - test with MPICH2"
	@echo "      mpi=mpich-1.2.x - test with MPICH-1.2.x"
	@echo "      compiler=gnu - test with GNU C compiler, ilp64 libraries shouldn't be tested with gnu compiler."
	@echo "      compiler=intel - test with Intel (R) compilers"
	@echo "      LIBdir=<MKLdir> - path to MKL binaries, if they're not in"
	@echo "          ../../lib/ia32(intel64)."
	@echo "      MPIdir=<mpidir> - path to MPI. Specify MPIdir if it's not in"
	@echo "          the PATH. MPI scripts are taken from <mpidir>/bin (or bin64"
	@echo "          in case of Intel(R) 64)."
	@echo "          When testing with MPICH-1.2.x, make sure that MPICH was"
	@echo "          compiled by the same compiler as used to build the examples."
	@echo "      interface_name - can be lp64 or ilp64 for intel64. Default value is lp64."
	@echo "      example_list - list of examples to be performed. You can specify the list by taking"
	@echo "          several example names into double quotes and separating it by spaces. If example_list is"
	@echo "          not specified - all examples will be performed by default. Please type 'make list' to"
	@echo "          see list of all possible example names. "
	@echo "   Targets:"
	@echo "      libia32,libintel64,soia32,sointel64 - to link with static/dynamic MKL"
	@echo "                     for IA-32/Intel(R) 64 processor family"
	@echo "      cleanall - clean all objects"
	@echo "   Examples:"
	@echo "      make libia32 mpi=mpich2 "
	@echo "      make libintel64 mpi=intelmpi example=pblas1_s_example "
	@echo "      make cleanall"


ifdef example
ifeq ("$(filter-out $(PBLAS),$(example))","")
   testset = $(foreach example_name,$(example),$(example_name).txt)
else
   $(error Invalid name of test. Possible values of 'example': $(PBLAS))
endif
else
   testset = $(foreach example_name,$(PBLAS),$(example_name).txt)
endif

list: ; @echo "Possible values of 'example': $(PBLAS)"

ifdef arch
libia32    lib32:    ; (cd $(SRCdir); $(MAKE) arch=ia32    dynamic=no  $(testset))
libintel64 libem64t: ; (cd $(SRCdir); $(MAKE) arch=intel64 dynamic=no  $(testset))
soia32     so32:     ; (cd $(SRCdir); $(MAKE) arch=ia32    dynamic=yes $(testset))
sointel64  soem64t:  ; (cd $(SRCdir); $(MAKE) arch=intel64 dynamic=yes $(testset))
else
libia32    lib32:    ; ($(MAKE) arch=ia32    dynamic=no  libia32)
libintel64 libem64t: ; ($(MAKE) arch=intel64 dynamic=no  libintel64)
soia32     so32:     ; ($(MAKE) arch=ia32    dynamic=yes soia32)
sointel64  soem64t:  ; ($(MAKE) arch=intel64 dynamic=yes sointel64)
endif

cleanall: ; (cd $(SRCdir); $(MAKE) clean)
