## --------------------------------------------------------------------------
## makefile
##

make: installs mocha mex file and associated shared object file locally
into $OBJ_DIR=${EPICS_HOST_ARCH}/$(MATLAB_VERSION)

make install: installs mocha mex file and associated shared object file 
into INSTALL_PATH?=$(INSTALL_MOCHA_LIBDIR) where:
INSTALL_MOCHA_LIBDIR= $(CAFE_BASE)/mocha/$(MOCHA_VERSION)/lib/${EPICS_HOST_ARCH}/$(MATLAB_VERSION)

make clean:
rm $(OBJ_DIR)/*.o $(OBJ_DIR)/*.so $(OBJ_DIR)/*.$(MEXE)

## --------------------------------------------------------------------------


#RHEL8
module load gcc/10.4.0
module load matlab/<version>

#Before compiling, update version number in macchinettaSwitch.cpp
#Find the following line and change version/date
#plhs[0]=mxCreateString((char *) "mocha-1.20.1 : 7 May 2024");

make -f makefile_rel_1.20-gcc-10.4.0
# installs mex file locally
# RHEL8-x86_64/><version>

make -f makefile_rel_1.20-gcc-10.4.0 install
# installs mex file centrally to
/opt/gfa/cafe/mocha/mocha-1.20.1-gcc-10.4.0/lib/RHEL8-x86_64/<version>

#Create AIT module instance
cd /opt/psi/Cafe/cafe-matlab
mdkir 2023a-RHEL8-gcc-10.4.0-cafe-1.20.1
cd 2023a-RHEL8-gcc-10.4.0-cafe-1.20.1
mkdir libexec
cd libexec
cp /opt/gfa/cafe/mocha/mocha-1.20.1-gcc-10.4.0/lib/RHEL8-x86_64/2023a/* .


#Declare new module, e.g., <new_matlab_version>
cd /opt/psi/Cafe/modulefiles/cafe-matlab
cp 2024a <new_matlab_version>
#in new module, 
module load matlab/<new_matlab_version>

cp .release-2024a .release-<new_matlab_version>
