#
# Makefile for the simple demonstration functions in simple.h.
# See README for details.
#
# To use:
#	Do "make matlab", "make octave", or "make tela" to make the
#	appropriate binary.
#	
PERL	  = perl
TOP	  = ../../../..
MV	  = mv
MATWRAP = $(PERL) -w $(TOP)/bin/matwrap
#

all::
	@echo 'Type "make matlab" to make the matlab example, "make octave"'
	@echo 'to make the octave example, and "make tela" to make the'
	@echo 'tela example.'
	@false

########################################################################
#
# Instructions for making the matlab modules:
# Note that all of the matlab stub functions go into the directory 'wrap_m'.
#
matlab::
	test -d $(MATLAB_STUBDIR) || mkdir $(MATLAB_STUBDIR)
	$(MAKE) simple_matlab.mexaxp

#
# Force mex to use the gnu C++ compiler.
#
MEXVARS = ../mex_cpp.sh

#
# Command to run MEX:
#
MEX = mex -f $(MEXVARS)

#
# Where to put the matlab stub functions.
# This directory must be in your matlab path.
#
MATLAB_STUBDIR = wrap_m

#
# (How do you find out what the extension of a MEX file is on your
# architecture?  .mexaxp is for DEC (Compaq) alphas running Digital Unix.)
#
simple_matlab.mexaxp: simple.h
	$(MATWRAP) -language matlab simple.h \
		-o simple_matlab.c -outdir $(MATLAB_STUBDIR)
	$(MEX) simple_matlab.c $(OFILES)

########################################################################
#
# Instructions for making the octave modules:
#
MKOCTFILE = mkoctfile

octave:: simple_octave.oct

simple_octave.oct: simple.h
	$(MATWRAP) -language octave simple.h \
		-o simple_octave.cc -stub simple_stub.m
	$(MKOCTFILE) simple_octave.cc

########################################################################
#
# Instruction for making the tela modules:
#
TELAKKA	  = telakka

tela:: tela_simple

tela_simple: simple.h
	$(MATWRAP) -language tela simple.h -o tela_single_axon.ct
	@echo Ignore warning messages about symbol index out of range,
	@echo if they appear.
	$(TELAKKA) tela_simple.ct $(OFILES) $(LIBS)
	$(MV) tela tela_simple

########################################################################
#
#
clean::
	$(RM) -rf $(MATLAB_STUBDIR) *.o *_matlab.c *_octave.cc *.mexaxp *.oct \
	*.mex4 *_stub.m *_matlab.c octave-core so_locations *.ct tela_simple
