##############################################################################
#  Makefile
#    used to build Face Detection sample
#
#  Control variables
#    CC      - Lets you to choose Microsoft or Intel compiler.
#              Default is Intel compiler, set it to "cl" to
#              build with Microsoft one
#

## Name of the application to build
BinName = Face_Detection.exe


##############################################################################
#
# project directories
#

#
# Directory name for obj-files
#
ObjDir = .\obj\

#
# Directory name for exe-files
#
BinDir = .\bin\

#
# Directory name for sources files
#
SrcDir = .\samples

#
##############################################################################

##############################################################################
#
# list of object files
#

OBJS =  \
"$(ObjDir)\FaceDetection.obj" \
"$(ObjDir)\ippiImage.obj" \
"$(ObjDir)\ippiImageStore.obj" \
"$(ObjDir)\StdAfx.obj"

#
##############################################################################

##############################################################################
#
# Tuning of IPP libraries set
#

IPPLIB = \
  ippi.lib  \
  ippcv.lib \
  ipps.lib  \
  ippcc.lib

#
##############################################################################

##############################################################################
#
# compiler environment
#

#
#   code generation & diagnostic flags
#

CFLAGS = /nologo /c /GX /W3 /O2 /MD /EHsc

!IF "$(CC)" == "icl.exe" 
CFLAGS = $(CFLAGS) /Qwd9,171,593,810,981,1418
!ENDIF

#
#   build defenitions
#

CDEFINES = /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_AFXDLL" /D "_MBCS"


#
# include paths
#

CINCLUDE =  \
/I "$(IPPROOT)\include"

#
##############################################################################


##############################################################################
#
# linker environment
#

LINK32 = link.exe

#
# System libraries
#

SYSLIB = kernel32.lib user32.lib

#
#   linker flags
#

LINKFLAGS = /nologo /subsystem:console /incremental:no /machine:I386 /opt:noref

#
##############################################################################


all : prepare build

{$(SrcDir)}.cpp{$(ObjDir)}.obj::
   $(CC) $(CFLAGS) $(CINCLUDE) $(CDEFINES) /Fo$(ObjDir)\ $<

$(BinDir)\$(BinName) : $(OBJS)
   $(LINK32) $(LINKFLAGS) \
             $(SYSLIB) \
             $(IPPLIB) \
             $(OBJS) \
             /out:$@

build : $(BinDir)\$(BinName)

prepare :
   @if not exist $(ObjDir)   mkdir $(ObjDir)
   @if not exist $(BinDir)   mkdir $(BinDir)

clean:
   @echo Cleaning ...
   @if exist $(ObjDir) rd /s /q $(ObjDir)
   @if exist $(BinDir) rd /s /q $(BinDir)

help:
   @echo Usage of this Makefile:
   @echo "nmake          - prepare and build phases
   @echo "nmake prepare  - creates directories
   @echo "nmake clean    - removes directories created
   @echo "nmake build    - builds
   @echo "nmake help"    - help
