# Makefile to compile sload.exe for loading data supported by libbiosig into Mathematica
# Copyright (C) 2010, 2011 Alois Schloegl

###########################################
# user-defined variables 
########################################### 
MLINKDIR  = C:/Program\ Files/Wolfram\ Research/Mathematica/7.0/SystemFiles/Links/MathLink/DeveloperKit
SYS       = Windows# Set this value with the result of evaluating $SystemID
MLLIB     = ml32i3m # Set this to ML64i3 if using a 64-bit system
###########################################


CC	  = g++ 
RM        = rm 
CADDSDIR  = ${MLINKDIR}/${SYS}/CompilerAdditions/mldev32
INCDIR    = ${CADDSDIR}/include
LIBDIR    = ${CADDSDIR}/lib

EXTRALIBS = -mwindows -lm -lpthread -lstdc++ -L.. -lbiosig -lws2_32 # -lcholmod -lz #Set these with appropriate libs for your system.

MPREP     = ${CADDSDIR}/bin/mprep.exe

all : sload.exe

win win32 :
	$(MAKE) -f Makefile.win32

../libbiosig.a: 
	$(MAKE) -C .. -f Makefile.win32 libbiosig.a

.c.o :
	${CC} -c -I${INCDIR} $<

sloadtm.c : sload.tm
	${MPREP} $? -o $@

sload.exe : sload.o sloadtm.o ../libbiosig.a
	${CC} sloadtm.o sload.o -static-libgcc -static-libstdc++ -L${LIBDIR} -l${MLLIB} ${EXTRALIBS} -o $@

clean:
	-$(RM) *.o
	-$(RM) *.obj
	-$(RM) *tm.c
	-$(RM) sload
	-$(RM) sload.exe
	
