text: .PHONY: help
  
  help::
  	$(ECHO) "Makefile Usage:"
  	$(ECHO) "  make all TARGET=<sw_emu/hw_emu/hw> DEVICE=<FPGA platform>"
  	$(ECHO) "      Command to generate the design for specified Target and Device."
  	$(ECHO) ""
  	$(ECHO) "  make clean "
  	$(ECHO) "      Command to remove the generated non-hardware files."
  	$(ECHO) ""
  	$(ECHO) "  make cleanall"
  	$(ECHO) "      Command to remove all the generated files."
  	$(ECHO) ""
  	$(ECHO) "  make check TARGET=<sw_emu/hw_emu/hw> DEVICE=<FPGA platform>"
  	$(ECHO) "      Command to run application in emulation."
  	$(ECHO) ""
  	$(ECHO) "  make build TARGET=<sw_emu/hw_emu/hw> DEVICE=<FPGA platform>"
  	$(ECHO) "      Command to build xclbin application."
  	$(ECHO) ""
  	$(ECHO) "  make run_nimbix DEVICE=<FPGA platform>"
  	$(ECHO) "      Command to run application on Nimbix Cloud."
  	$(ECHO) ""
  	$(ECHO) "  make aws_build DEVICE=<FPGA platform>"
  	$(ECHO) "      Command to build AWS xclbin application on AWS Cloud."
  	$(ECHO) ""
  
  # Points to Utility Directory
  COMMON_REPO = ../../../
  ABS_COMMON_REPO = $(shell readlink -f $(COMMON_REPO))
  
  TARGETS := hw
  TARGET := $(TARGETS)
  DEVICE := $(DEVICES)
  XCLBIN := ./xclbin
  
  include ./utils.mk
  
  DSA := $(call device2dsa, $(DEVICE))
  BUILD_DIR := ./_x.$(TARGET).$(DSA)
  
  BUILD_DIR_apply_watermark = $(BUILD_DIR)/apply_watermark
  
  CXX := $(XILINX_SDX)/bin/xcpp
  XOCC := $(XILINX_SDX)/bin/xocc
  
  #Include Libraries
  include $(ABS_COMMON_REPO)/libs/opencl/opencl.mk
  include $(ABS_COMMON_REPO)/libs/xcl2/xcl2.mk
  include $(ABS_COMMON_REPO)/libs/bitmap/bitmap.mk
  CXXFLAGS += $(xcl2_CXXFLAGS) $(bitmap_CXXFLAGS)
  LDFLAGS += $(xcl2_LDFLAGS) $(bitmap_LDFLAGS)
  HOST_SRCS += $(xcl2_SRCS) $(bitmap_SRCS)
  CXXFLAGS += $(opencl_CXXFLAGS) -Wall -O0 -g -std=c++14
  LDFLAGS += $(opencl_LDFLAGS)
  
  HOST_SRCS += src/host.cpp
  
  # Host compiler global settings
  CXXFLAGS += -fmessage-length=0
  LDFLAGS += -lrt -lstdc++ 
  
  # Kernel compiler global settings
  CLFLAGS += -t $(TARGET) --platform $(DEVICE) --save-temps 
  CLFLAGS +=  --max_memory_ports apply_watermark
  
  # Kernel linker flags
  LDCLFLAGS += --sp apply_watermark_1.m_axi_gmem0:DDR[0] --sp apply_watermark_1.m_axi_gmem1:DDR[1]
  
  EXECUTABLE = host
  CMD_ARGS = $(XCLBIN)/apply_watermark.$(TARGET).$(DSA).xclbin ./data/input.bmp ./data/golden.bmp
  
  EMCONFIG_DIR = $(XCLBIN)/$(DSA)
  
  BINARY_CONTAINERS += $(XCLBIN)/apply_watermark.$(TARGET).$(DSA).xclbin
  BINARY_CONTAINER_apply_watermark_OBJS += $(XCLBIN)/apply_watermark.$(TARGET).$(DSA).xo
  
  CP = cp -rf
  DATA = ./data
  
  .PHONY: all clean cleanall docs emconfig
  all: check-devices $(EXECUTABLE) $(BINARY_CONTAINERS) emconfig
  
  .PHONY: exe
  exe: $(EXECUTABLE)
  
  .PHONY: build
  build: $(BINARY_CONTAINERS)
  
  # Building kernel
  $(XCLBIN)/apply_watermark.$(TARGET).$(DSA).xo: src/apply_watermark.cl
  	mkdir -p $(XCLBIN)
  	$(XOCC) $(CLFLAGS) --temp_dir $(BUILD_DIR_apply_watermark) -c -k apply_watermark -I'$(<D)' -o'$@' '$<'
  $(XCLBIN)/apply_watermark.$(TARGET).$(DSA).xclbin: $(BINARY_CONTAINER_apply_watermark_OBJS)
  	mkdir -p $(XCLBIN)
  	$(XOCC) $(CLFLAGS) --temp_dir $(BUILD_DIR_apply_watermark) -l $(LDCLFLAGS) --nk apply_watermark:1 -o'$@' $(+)
  
  # Building Host
  $(EXECUTABLE): check-xrt $(HOST_SRCS) $(HOST_HDRS)
  	$(CXX) $(CXXFLAGS) $(HOST_SRCS) $(HOST_HDRS) -o '$@' $(LDFLAGS)
  
  emconfig:$(EMCONFIG_DIR)/emconfig.json
  $(EMCONFIG_DIR)/emconfig.json:
  	emconfigutil --platform $(DEVICE) --od $(EMCONFIG_DIR)
  
  check: all
  ifeq ($(findstring xilinx_u50_xdma, $(DEVICE)), xilinx_u50_xdma)
  $(error Nothing to be done for make)
  endif
  ifeq ($(findstring xilinx_aws-vu9p-f1-04261818, $(DEVICE)), xilinx_aws-vu9p-f1-04261818)
  $(error Nothing to be done for make)
  endif
  ifeq ($(findstring xilinx:u50:xdma, $(DEVICE)), xilinx:u50:xdma)
  $(error Nothing to be done for make)
  endif
  ifeq ($(findstring xilinx:aws-vu9p-f1-04261818:dynamic, $(DEVICE)), xilinx:aws-vu9p-f1-04261818:dynamic)
  $(error Nothing to be done for make)
  endif
  
  ifeq ($(TARGET),$(filter $(TARGET),sw_emu hw_emu))
  	$(CP) $(EMCONFIG_DIR)/emconfig.json .
  	XCL_EMULATION_MODE=$(TARGET) ./$(EXECUTABLE) $(XCLBIN)/apply_watermark.$(TARGET).$(DSA).xclbin ./data/input.bmp ./data/golden.bmp
  else
  	 ./$(EXECUTABLE) $(XCLBIN)/apply_watermark.$(TARGET).$(DSA).xclbin ./data/input.bmp ./data/golden.bmp
  endif
  	sdx_analyze profile -i profile_summary.csv -f html
  
  run_nimbix: all
  	$(COMMON_REPO)/utility/nimbix/run_nimbix.py $(EXECUTABLE) $(CMD_ARGS) $(DSA)
  
  aws_build: check-aws_repo $(BINARY_CONTAINERS)
  	$(COMMON_REPO)/utility/aws/run_aws.py $(BINARY_CONTAINERS)
  
  # Cleaning stuff
  clean:
  	-$(RMDIR) $(EXECUTABLE) $(XCLBIN)/{*sw_emu*,*hw_emu*} 
  	-$(RMDIR) profile_* TempConfig system_estimate.xtxt *.rpt *.csv 
  	-$(RMDIR) src/*.ll _xocc_* .Xil emconfig.json dltmp* xmltmp* *.log *.jou *.wcfg *.wdb
  
  cleanall: clean
  	-$(RMDIR) $(XCLBIN)
  	-$(RMDIR) _x.*
  	-$(RMDIR) ./output.bmp 
  