TOP=../..

include $(TOP)/configure/CONFIG

USR_CXXFLAGS += -std=c++0x
USR_CXXFLAGS += -DHAVE_YAML
#----------------------------------------
#  ADD MACRO DEFINITIONS AFTER THIS LINE
#========================================
INCLUDES += -I$(TPG_INCLUDE)
INCLUDES += -I$(BSA_INCLUDE)
INCLUDES += -I$(YAML_INCLUDE)
INCLUDES += -I$(CPSW_DEVICE_LIBRARY_INCLUDE)
INCLUDES += -I$(YAMLREADER_INCLUDE)
INCLUDES += -I$(COMMONATCA_INCLUDE)
INCLUDES += -I$(BOOST_INCLUDE)

## this part is just for yaml loader driver
INCLUDES += -I$(CPSW_FRAMEWORK_INCLUDE)
#LIBS     += -L $(TPG_LIB)

#======================================================
# PATH TO "NON EPICS" EXTERNAL PACKAGES: USER LIBRARIES
#======================================================
# Support for CPSW
cpsw_DIR = $(CPSW_FRAMEWORK_LIB)
deviceLib_DIR = $(CPSW_DEVICE_LIBRARY_LIB)
boost_system_DIR = $(BOOST_LIB)
yaml-cpp_DIR = $(YAML_LIB)
yamlReader_DIR = $(YAMLREADER_LIB)
commonATCA_DIR = $(COMMONATCA_LIB)
# =====================================================

# ======================================================
# LINK "NON EPICS" EXTERNAL PACKAGE LIBRARIES STATICALLY
#=======================================================
USR_LIBS_Linux += yamlReader
USR_LIBS_Linux += deviceLib
USR_LIBS_Linux += cpsw
USR_LIBS_Linux += yaml-cpp
USR_LIBS_Linux += boost_system
USR_LIBS_Linux += commonATCA
#======================================================

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

# Use the following for RTEMS Only IOCs
#PROD_IOC_RTEMS = tpg

# tpg.dbd will be created and installed
DBD += tpgSupport.dbd

# tpg.dbd will be made up from these files:
tpgSupport_DBD += base.dbd
tpgSupport_DBD += devIocStats.dbd
tpgSupport_DBD += PVAServerRegister.dbd
tpgSupport_DBD += qsrv.dbd

tpgSupport_DBD += iocAdmin.dbd
tpgSupport_DBD += asSupport.dbd
tpgSupport_DBD += devSeqCar.dbd
tpgSupport_DBD += caPutLog.dbd
tpgSupport_DBD += $(CEXP_DBDS)
tpgSupport_DBD += sncMpsRateDrop.dbd
tpgSupport_DBD += sncFaultBuff.dbd

# ================================================================================
# The system command will be mainly used by linux hosted IOCs
# Very useful for changing kernel thread priorities for kernel drivers
# ================================================================================
tpgSupport_DBD += system.dbd

# Application dbds
tpgSupport_DBD += bsaBuffReserve.dbd
tpgSupport_DBD += bsaBufferMask.dbd
tpgSupport_DBD += bsaControl.dbd
#
# ======================================================================
# If you don't have an EVR comment the following two lines:
#tpgSupport_DBD += evrSupport.dbd
#tpgSupport_DBD += devMrfEr.dbd

# ======================================================================
# <name>_registerRecordDeviceDriver.cpp will be created from <name>.dbd
tpgSupport_SRCS += tpgSupport_registerRecordDeviceDriver.cpp
tpgSupport_SRCS += bsaBuffReserve.st
tpgSupport_SRCS += bsaBufferMask.st
tpgSupport_SRCS += bsaControl.st
tpgSupport_SRCS += burstApply.c
tpgSupport_SRCS += burstLoad.c
tpgSupport_SRCS += continuousApply.c 
tpgSupport_SRCS += continuousLoad.c

# ===========================================================
# bsaDriver and yamlLoader have been separated out to epics modules
# after testing these lines should be be revmoved
# ===========================================================
# BSA module will be turned to a separated module.
#tpgSupport_SRCS += bsaAsynDriver.cpp

# YAML loader module will be turned to a separate module.

#tpgSupport_SRCS += yamlLoader.cpp
# ===========================================================

tpgSupport_SRCS_DEFAULT += tpgSupportMain.cpp

tpgSupport_SRCS_vxWorks += -nil-

# ========================================================================
# ========================================================================
# Add locally compiled object code
# For example, subroutines
# ========================================================================
# tpgSupport_SRCS += file1.c
# tpgSupport_SRCS += file2.c
#
tpgSupport_SRCS += sncMpsRateDrop.stt
tpgSupport_SRCS += sncFaultBuff.stt

# =====================================================
# Link in the code from other libraries
# =====================================================
#
#
#

#pgSupport_LIBS += tpgSupport

# Needed to link in iocAdmin support
tpgSupport_LIBS += devIocStats

# Needed to link in autosave support
tpgSupport_LIBS += autosave

tpgSupport_LIBS += seq
tpgSupport_LIBS += pv
tpgSupport_LIBS += seqCar

# Needed to link caPutLog support
tpgSupport_LIBS += caPutLog

# Needed to link cexpsh() support
tpgSupport_LIBS += $(CEXP_LIBS)


# QSrv Service
tpgSupport_LIBS += qsrv
tpgSupport_LIBS += $(EPICS_BASE_PVA_CORE_LIBS)
#
tpgSupport_LIBS += $(EPICS_BASE_IOC_LIBS)

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


# =============================================
# Begin to link in the EVR support for
# RTEMS, linux, and linuxRT
# If you don't have an EVR, you can comment out 
# the lines below.
# =============================================
# tpgSupport_LIBS += evrSupport
# tpgSupport_LIBS += devMrfEr

ifneq ($(T_A),linuxRT-x86)
  ifneq ($(T_A),linuxRT-x86_64)
   ifneq ($(T_A),linuxRT_glibc-x86_64)
    ifneq ($(T_A),linux-x86)
      ifneq ($(T_A),linux-x86_64)
#       tpgSupport_LIBS += mrfVme64x
      endif
    endif
  endif
 endif
endif

 ifeq ($(T_A),linuxRT-x86)
#  tpgSupport_LIBS += drvMrf
 endif

 ifeq ($(T_A),linuxRT-x86_64)
#  tpgSupport_LIBS += drvMrf
 endif
 
 ifeq ($(T_A),linuxRT_glibc-x86_64)
#  tpgSupport_LIBS += drvMrf
 endif

 ifeq ($(T_A),linux-x86)
#  tpgSupport_LIBS += drvMrf
 endif

 ifeq ($(T_A),linux-x86_64)
#  tpgSupport_LIBS += drvMrf
 endif
# =====================================================
# END EVR libraries
# =====================================================

# NOTE: To build SNL programs, SNCSEQ must be defined
# in the <top>/configure/RELEASE file

ifneq ($(SNCSEQ),)
    # This builds sncExample as a component of tpg
    tpgSupport_SNCFLAGS += +r
    tpgSupport_DBD += sncExample.dbd
    tpgSupport_SRCS += sncExample.stt
    tpgSupport_LIBS += seq pv

    # The following builds sncProgram as a standalone application
  ifneq ($(T_A),linuxRT-x86)
    PROD_HOST += sncProgram
    sncProgram_SNCFLAGS += +m
    sncProgram_SRCS += sncProgram.st
    sncProgram_LIBS += seq pv
    sncProgram_LIBS += $(EPICS_BASE_HOST_LIBS)
  endif
endif

tpgSupport_LIBS += $(EPICS_BASE_IOC_LIBS)

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

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

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

# activeFanout.dbd will be made up from these files:
activeFanout_DBD += base.dbd
activeFanout_DBD += devIocStats.dbd
activeFanout_DBD += asSupport.dbd
activeFanout_DBD += caPutLog.dbd
activeFanout_DBD += $(CEXP_DBDS)
activeFanout_DBD += yamlLoader.dbd
activeFanout_DBD += yamlDownloader.dbd
activeFanout_DBD += ycpswasyn.dbd

# ================================================================================
# The system command will be mainly used by linux hosted IOCs
# Very useful for changing kernel thread priorities for kernel drivers
# ================================================================================
activeFanout_DBD += system.dbd
activeFanout_DBD += asyn.dbd
activeFanout_DBD += ATCACommon.dbd
activeFanout_DBD += af_asubRPhase.dbd
activeFanout_DBD += af_asubRPower.dbd

# activeFanout_registerRecordDeviceDriver.cpp derives from activeFanout.dbd
activeFanout_SRCS += activeFanout_registerRecordDeviceDriver.cpp

# Code for activeFanout subroutine records
activeFanout_SRCS += af_asubRPhase.c
activeFanout_SRCS += af_asubRPower.c

# Build the main IOC entry point on workstation OSs.
activeFanout_SRCS_DEFAULT += afMain.cpp
activeFanout_SRCS_vxWorks += -nil-

# Needed to link in iocAdmin support
activeFanout_LIBS += devIocStats

# Needed to link in autosave support
activeFanout_LIBS += autosave

# Needed to link caPutLog support
activeFanout_LIBS += caPutLog

# Needed to link cexpsh() support
activeFanout_LIBS += $(CEXP_LIBS)
activeFanout_LIBS += $(CEXP_SYS_LIBS)

# Needed to link yamlLoader support
activeFanout_LIBS += yamlLoader

# Needed to link yamlDownloader support
activeFanout_LIBS += yamlDownloader

# Needed to link ycpswAsyn support
activeFanout_LIBS += ycpswasyn

# Needed to link asyn support
activeFanout_LIBS += asyn

# Needed to link ATCACommon support
activeFanout_LIBS += ATCACommon

# Link QSRV (pvAccess Server) if available
ifdef EPICS_QSRV_MAJOR_VERSION
   activeFanout_LIBS += qsrv
   activeFanout_LIBS += $(EPICS_BASE_PVA_CORE_LIBS)
   activeFanout_DBD += PVAServerRegister.dbd
   activeFanout_DBD += qsrv.dbd
endif

# Finally link to the EPICS Base libraries
activeFanout_LIBS += $(EPICS_BASE_IOC_LIBS)

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

