#
# Jan Chrin
# June 2016
#
# Makefile to build a simple C++ cafe client 
#

#-py37- libcafe.so: undefined reference to `cy_event_handler_wrapper
#CAFE version to link to
#CAFE_VERSION=cafe-1.14.4-sls2-gcc-7.3.0
CAFE_VERSION=cafe-1.22.0-hipa-gcc-11.5.0
#CAFE_VERSION=cafe-1.15.0-gcc-10.3.0

PYTHON_INCLUDE=/opt/gfa/python-3.7/latest/include/python3.7m
PYTHON_LIB=/opt/gfa/python-3.7/latest/lib

EPICS_BASE=${EPICS}/base-7.0.10

#CAFE project base
CAFE_BASE=/psi.ch/project/cafe
CAFE_CPP_BASE=${CAFE_BASE}/bin/cpp


BOOST_BASE=${CAFE_BASE}/boost/boost_1_61_0/include

INCLUDE_PATH += -I$(CAFE_CPP_BASE)/$(CAFE_VERSION)/include \
 -I$(EPICS_BASE)/include  -I$(EPICS_BASE)/include/compiler/gcc \
  -I$(EPICS_BASE)/include/os/Linux \
 -I$(BOOST_BASE)
 #-I${PYTHON_INCLUDE}
 #-I$(BOOST_BASE)/boost

LIB_DIR += -L$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} \
 -Wl,-rpath,$(EPICS_BASE)/lib/${EPICS_HOST_ARCH} \
 -L$(CAFE_CPP_BASE)/$(CAFE_VERSION)/lib/${EPICS_HOST_ARCH} \
 -Wl,-rpath,$(CAFE_CPP_BASE)/$(CAFE_VERSION)/lib/${EPICS_HOST_ARCH} 
 #-L/opt/psi/Programming/gcc/10.3.0/lib64 -Wl,-rpath,/opt/psi/Programming/gcc/10.3.0/lib64 \
 #-L$(PYTHON_LIB) -Wl,-rpath,$(PYTHON_LIB) 


LIBS += -lcafe -lca -lCom
#-lQt5Core -lpython3.7m

${EPICS_HOST_ARCH}/cafeTest: cafeTest.cc callbacks.h
	g++ cafeTest.cc -o  ${EPICS_HOST_ARCH}/cafeTest \
	$(INCLUDE_PATH) $(LIB_DIR) $(LIBS)
	
${EPICS_HOST_ARCH}/monitorTest: monitorTest.cc 
	g++ monitorTest.cc -o ${EPICS_HOST_ARCH}/monitorTest \
	$(INCLUDE_PATH) $(LIB_DIR) $(LIBS)



clean:
	rm -f ${EPICS_HOST_ARCH}/cafeTest.o ${EPICS_HOST_ARCH}/cafeTest ${EPICS_HOST_ARCH}/monitorTest.o ${EPICS_HOST_ARCH}/monitorTest

