TOP=../..

include $(TOP)/configure/CONFIG
#----------------------------------------
#  ADD MACRO DEFINITIONS AFTER THIS LINE
#========================================

# EXTERNAL NON EPICS PACKAGES: USER INCLUDES AND LIBRARIES
#========================================================

USR_INCLUDES += $(ZLIB_INCLUDE)
USR_INCLUDES += $(XZ_INCLUDE)
USR_INCLUDES += $(LIBXML2_INCLUDE)
USR_INCLUDES += $(PCRE_INCLUDE)

# PATH TO THE EXTERNAL LIBRARIES
#===================================
z_DIR = $(ZLIB_LIB)
lzma_DIR = $(XZ_LIB)
xml2_DIR = $(LIBXML2_LIB)
pcre_DIR = $(PCRE_LIB)

# LINK EXTERNAL LIBRARIES STATICALLY
#====================================
USR_LIBS_Linux += xml2 z lzma pcre

# ================================================
# Build the IOC application
# ================================================
# This will attempt to build an IOC application 
# for every target including the host computer.
# ================================================

PROD_IOC_Linux += Motion

Motion_INCLUDES += $(ECASYN)/include

# Motion.dbd will be created and installed
DBD += Motion.dbd

# Motion.dbd will be made up from these files:
Motion_DBD += base.dbd 

# Ethercat 
Motion_DBD += ecAsyn.dbd

# Motor
Motion_DBD += motorSupport.dbd
#Motion_DBD += EtherCATMotorSupport.dbd
Motion_DBD += LinmotMotorSupport.dbd
Motion_DBD += devAerotech.dbd
Motion_DBD += devNewFocus.dbd
# The "pico.dbd" file below is a temporary workaround until the motor module is patched
Motion_DBD += pico.dbd

# Counter
Motion_DBD += apci1710.dbd
Motion_DBD += apci1710Support.dbd

# IOC Admin
Motion_DBD += devIocStats.dbd

# Autosave
Motion_DBD += asSupport.dbd

# Modbus
Motion_DBD += drvAsynIPPort.dbd 
Motion_DBD += modbusSupport.dbd

# Stream Device Support
Motion_DBD += stream.dbd 

#Asyn record
Motion_DBD += asyn.dbd

# Polynomial for LVDT
Motion_DBD +=polynomial.dbd

# Caput 
Motion_DBD += caPutLog.dbd

# DRV UI PCI
Motion_DBD += drvUioPciGen.dbd

# DEV BUS Mapped
Motion_DBD += devBusMapped.dbd

# DEVLIB 2 PCIE Bus support
Motion_DBD += epicspci.dbd
#Motion_DBD += $(CEXP_DBDS)

# The system command is available for all architectures
Motion_DBD += system.dbd

# If you have an EVR uncomment the following two lines:
Motion_DBD += evrSupport.dbd
Motion_DBD += devMrfEr.dbd

# performance measurment module
Motion_DBD += drvPerfMeasure.dbd

# Add PV Access support
Motion_DBD += PVAServerRegister.dbd
Motion_DBD += qsrv.dbd

# =========================================================

# ======================================================================
# <name>_registerRecordDeviceDriver.cpp will be created from <name>.dbd
Motion_SRCS += Motion_registerRecordDeviceDriver.cpp
Motion_SRCS_DEFAULT += MotionMain.cpp
Motion_SRCS_vxWorks += -nil-
Motion_SRCS += polynomial.c

# Ethercat libraries
Motion_LIBS += ecAsyn 
Motion_LIBS += scannerlib
Motion_LIBS += rtutils

# Motor libraries
#Motion_LIBS += EtherCATMotor
Motion_LIBS += LinmotMotor
Motion_LIBS += Aerotech
Motion_LIBS += NewFocus
Motion_LIBS += motor  

# Counter module libraries 
Motion_LIBS += apci1710 

# Asyn libraries
Motion_LIBS += asyn

# modbus libraries 
Motion_LIBS += modbus 

# Stream device libraries
Motion_LIBS += stream 

# GenPolySub libraries
#Motion_LIBS += genPolySub

# PV Access support
Motion_LIBS += qsrv
# EPICS_BASE_PVA_CORE_LIBS comes from pvAccessCPP and is defined at <>/cfg/CONFIG_PVACCESS_MODULE
Motion_LIBS += $(EPICS_BASE_PVA_CORE_LIBS)
Motion_LIBS += $(EPICS_BASE_IOC_LIBS)

Motion_INCLUDES += $(ECASYN)/include

# =====================================================
# Link in the code from other libraries
# =====================================================
# Needed to link in iocAdmin support
Motion_LIBS += devIocStats

# Needed to link in autosave support
Motion_LIBS += autosave

# Needed to link caPutLog support
Motion_LIBS += caPutLog

# ===================================
# Needed to link in the EVR support
# ===================================
Motion_LIBS += evrSupport
Motion_LIBS += devMrfEr


ifeq ($(T_A),linuxRT-x86_64)
   Motion_LIBS += drvMrf
	evrma_DIR = $(EVRMA_LIB)
       Motion_LIBS += evrma
endif

ifeq ($(T_A),rhel6-x86_64)
  Motion_LIBS += drvMrf
  evrma_DIR = $(EVRMA_LIB)
  Motion_LIBS += evrma
endif

# Change if going back to old build root
#
#ifeq ($(T_A),linuxRT_glibc-x86_64)
#   Motion_LIBS += drvMrf
#     evrma_DIR = $(EVRMA_LIB)
#       Motion_LIBS += evrma
#endif
#
#ifeq ($(T_A),linux-x86_64)
#  Motion_LIBS += drvMrf
#  evrma_DIR = $(EVRMA_LIB)
#  Motion_LIBS += evrma
#endif

# DRV UI PCI GEN
Motion_LIBS += drvUioPciGen

# Device support for accessing Memory Mapped registers
Motion_LIBS += devBusMapped

# Devlib2 pcie access bus support library
Motion_LIBS += epicspci

# PERF MEASURE
Motion_LIBS += perfMeasure

#Motion_LIBS += $(CEXP_LIBS)

# NOTE: To build SNL programs, SNCSEQ must be defined
ifneq ($(SNCSEQ),)
      Motion_SNCFLAGS += +r
      Motion_DBD += timeout.dbd
      Motion_DBD += initializeAerotech.dbd
      Motion_DBD += initializeLinmot.dbd
      Motion_SRCS += timeout.stt
      Motion_SRCS += initializeAerotech.stt
      Motion_SRCS += initializeLinmot.stt
      Motion_LIBS += seq pv
endif
                  

Motion_LIBS += $(EPICS_BASE_IOC_LIBS)

# ==================================================
# Install external epics executable
# Install scanner program from Ethercat epics module
#===================================================
BIN_INSTALLS += $(ECASYN_BIN)/scanner

# ==================================================
# Install postDeploy script in the bin directory
# This will facilitate cram to run this script 
# post deployment in production
# ==================================================
SCRIPTS += postDeploy

install:
	chmod +w $(TOP)/bin/rhel6-x86_64/postDeploy	
	cp $(TOP)/bin/rhel6-x86_64/postDeploy $(TOP)/bin

# ==================================================

include $(TOP)/configure/RULES
#----------------------------------------
#  ADD RULES AFTER THIS LINE

