#*****************************************************************************
# *                                                                           *
# * Copyright Intel Corporation.                                              *
# *                                                                           *
# *****************************************************************************
#
# This code is covered by the Community Source License (CPL), version
# 1.0 as published by IBM and reproduced in the file "license.txt" in the
# "license" subdirectory. Redistribution in source and binary form, with
# or without modification, is permitted ONLY within the regulations
# contained in above mentioned license.
#
# Use of the name and trademark "Intel(R) MPI Benchmarks" is allowed ONLY
# within the regulations of the "License for Use of "Intel(R) MPI
# Benchmarks" Name and Trademark" as reproduced in the file
# "use-of-trademark-license.txt" in the "license" subdirectory.
#
# THE PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR
# CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT
# LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, NON-INFRINGEMENT,
# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each Recipient is
# solely responsible for determining the appropriateness of using and
# distributing the Program and assumes all risks associated with its
# exercise of rights under this Agreement, including but not limited to
# the risks and costs of program errors, compliance with applicable
# laws, damage to or loss of data, programs or equipment, and
# unavailability or interruption of operations.
#
# EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR
# ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
# WITHOUT LIMITATION LOST PROFITS), 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 OR
# DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
# HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
#
# EXPORT LAWS: THIS LICENSE ADDS NO RESTRICTIONS TO THE EXPORT LAWS OF
# YOUR JURISDICTION. It is licensee's responsibility to comply with any
# export regulations applicable in licensee's jurisdiction. Under
# CURRENT U.S. export regulations this software is eligible for export
# from the U.S. and can be downloaded by or otherwise exported or
# reexported worldwide EXCEPT to U.S. embargoed destinations which
# include Cuba, Iraq, Libya, North Korea, Iran, Syria, Sudan,
# Afghanistan and any other country to which the U.S. has embargoed
# goods and services.
#
#  ***************************************************************************

CC  = cl.exe
CPP = cl.exe

CFLAGS   = $(CFLAGS) -DWIN32 -DWIN_IMB
CPPFLAGS = $(CPPFLAGS) -DWIN32 -DWIN_IMB

CLINKER     = $(CC)
CPPLINKER   = $(CPP)

MPI_INCLUDE = %I_MPI_ROOT%\intel64\include
LIBS = %I_MPI_ROOT%\intel64\lib\release\impi.lib

default: all

!IFDEF TARGET

!INCLUDE $(TARGET)/Makefile_win.$(TARGET).mk

clean:
	@cd $(TARGET)
	del /f /q $(C_OBJ) $(BECHMARK_SUITE_OBJ)
	del /f /q IMB-$(TARGET).exe
	@cd ..
	del /f /q IMB-$(TARGET).exe

all: MOVE_TO_TARGET_DIR $(TARGET)
	cd ..
	copy .\$(TARGET)\IMB-$(TARGET).exe

$(TARGET): $(C_OBJ) $(BECHMARK_SUITE_OBJ)
	$(CPPLINKER) $(LDFLAGS) /FeIMB-$(TARGET) $(C_OBJ) $(BECHMARK_SUITE_OBJ) "$(LIB_PATH)" "$(LIBS)"

MOVE_TO_TARGET_DIR:
	cd ./$(TARGET)

.cpp.obj:
	$(CPP) /I"$(MPI_INCLUDE)" /I.. $(CPPFLAGS) -c $*.cpp
!ELSE

TARGET       = IMB-RMA IMB-MT IMB-MPI1 IMB-NBC IMB-IO IMB-EXT
CLEAN_TARGET = C_IMB-RMA C_IMB-MT C_IMB-MPI1 C_IMB-NBC C_IMB-IO C_IMB-EXT

all: $(TARGET)

$(TARGET):
	nmake -f Makefile_win TARGET=$(*:IMB-=)

clean: $(CLEAN_TARGET)

$(CLEAN_TARGET):
	nmake -f Makefile_win clean TARGET=$(*:C_IMB-=)
!ENDIF
