1####### Makefile to compile biosig.exe for loading data supported by libbiosig into Mathematica 2### 3### Copyright (C) 2010-2020 Alois Schloegl <alois.schloegl@gmail.com> 4### This file is part of the "BioSig for C/C++" repository 5### (biosig4c++) at http://biosig.sf.net/ 6### 7############################################################## 8 9 10########################################### 11# user-defined variables 12########################################### 13CROSS ?= /home/schloegl/src/mxe.github.schloegl/usr/bin/i686-w64-mingw32.static 14CROSS64 ?= /home/schloegl/src/mxe.github.schloegl/usr/bin/x86_64-w64-mingw32.static 15 16exec_prefix ?= @prefix@ 17 18########################################### 19## set Mathematica variables 20MATHEMATICA_EXE = @MATHEMATICA@ 21MATHEMATICA_EXE ?= $(shell which mathematica) 22ifeq (,$(MATHEMATICA_EXE)) 23 $(error "mathematica not found in $$PATH - cannot compile biosig for Mathematica") 24endif 25MLINKDIR ?= $(shell dirname $(shell dirname $(shell readlink -f $(MATHEMATICA_EXE) ) ) ) 26 27ifneq (,$(findstring Darwin,$(shell uname))) 28MLINKDIR := /Applications/Mathematica.app/Contents/ 29SYS = MacOSX-x86-64 30LDFLAGS += -demangle -dynamic -arch x86_64 31LDFLAGS += -framework CoreFoundation -framework CoreVideo -framework VideoDecodeAcceleration 32else 33SYS = $(notdir $(shell ls -1d $(MLINKDIR)/SystemFiles/Links/MathLink/DeveloperKit/*)) 34ifneq (1,$(words ${SYS})) 35SYS = Linux-x86-64# Set this value with the result of evaluating $SystemID 36endif 37endif 38 39# automated detection of most recent MLINTERFACE, without starting mathematica 40# 10.0 supports 3 and 4, 9.0 and earlier supports only 3, 41MLIVER := $(shell ${CC} mliver.c -I${MLINKDIR}/SystemFiles/Links/MathLink/DeveloperKit/${SYS}/CompilerAdditions/ -E -o - | tail -1) 42 43# 44# Windows 45SYSwin = Windows# Set this value with the result of evaluating $SystemID 46MLLIBwin = ml32i4m# Set this to ML64i3 if using a 64-bit system 47SYSwin64 = Windows-x86-64# Set this value with the result of evaluating $SystemID 48MLLIBwin64 = ml64i4# Set this to ML64i3 if using a 64-bit system 49########################################### 50 51CADDSDIR = ${MLINKDIR}/SystemFiles/Links/MathLink/DeveloperKit/${SYS}/CompilerAdditions 52INCDIR = -I${CADDSDIR} -I${MLINKDIR}/SystemFiles/IncludeFiles/C/ 53LIBDIR += -L${CADDSDIR} 54 55EXTRALIBS += -lm -ldl -luuid -lstdc++ # Set these with appropriate libs for your system. 56 57ifeq (Darwin,$(shell uname)) 58MLLIB = MLi${MLIVER} # ML32i3 # Set this to ML64i3 if using a 64-bit system 59SED = gsed 60else 61MLLIB = ML$(shell getconf LONG_BIT)i${MLIVER} # ML32i3 # Set this to ML64i3 if using a 64-bit system 62EXTRALIBS += -lrt 63SED = sed 64endif 65LD = ${CC} 66 67 68ifneq (${MLIVER},) 69CFLAGS += -DMLINTERFACE=${MLIVER} 70endif 71 72MPREP = ${CADDSDIR}/mprep 73 74TARGET = biosig 75 76# make Linux-x86-64 77mma : $(patsubst %, ${SYS}/%.exe, $(TARGET)) 78# make Linux-x86-64, Windows, Windows-x86-64 79all : $(patsubst %, ${SYS}/%.exe, $(TARGET)) $(patsubst %, ${SYSwin}/%.exe, $(TARGET)) $(patsubst %, ${SYSwin64}/%.exe, $(TARGET)) 80 81.c.o: 82 ${CC} ${CFLAGS} -I.. ${INCDIR} -c "$<" 83 84%tm.c: %.tm 85 ${MPREP} "$<" -o "$@" 86 ${SED} -i 's# __DATE__# ",__DATE__," ",__TIME__,"#g' "$@" 87 88${SYS}/%.exe: %.o %tm.o 89 mkdir -p ${SYS} 90 ${LD} ${LDFLAGS} $? ${LIBDIR} -l${MLLIB} ${EXTRALIBS} -L.. -lbiosig -o "$@" 91 ln -sf "$@" 92 93 94### Install Biosig for Mathematica 95install : biosig.exe 96 mkdir -p $(DESTDIR)$(exec_prefix)/libexec/biosig/mathematica 97 install biosig.exe $(DESTDIR)$(exec_prefix)/libexec/biosig/mathematica/ 98 @echo " Biosig for Mathematica is installed in $(exec_prefix)/libexec/biosig/mathematica/biosig.exe"; 99 @echo " Usage: Start Mathematica and run"; 100 @echo "\tlink=Install[\"$(exec_prefix)/libexec/biosig/mathematica/biosig.exe\"];"; 101 @echo "\t?Sload\n\t?Uload\n"; 102 103uninstall: 104 ${RM} $(DESTDIR)$(datadir)/biosig/mathematica/{sload,biosig}.exe 105 -cd $(DESTDIR)$(datadir) && rmdir -p biosig/mathematica 106 ${RM} $(DESTDIR)$(exec_prefix)/libexec/biosig/mathematica/biosig.exe 107 -cd $(DESTDIR)$(exec_prefix)/libexec && rmdir -p biosig/mathematica 108 109########################################### 110# Win32 - cross-compilation 111########################################### 112 113CCw32 = $(CROSS)-gcc 114CADDSDIRwin = ${MLINKDIR}/SystemFiles/Links/MathLink/DeveloperKit/${SYSwin}/CompilerAdditions 115INCDIRwin = -I${CADDSDIRwin} 116LIBDIRwin = ${CADDSDIRwin} 117 118EXTRALIBSwin = -lgdi32 -lm -lstdc++ -lws2_32 $(LDLIBS) # Set these with appropriate libs for your system. 119 120MPREPwin = ${CADDSDIRwin}/mprep.exe 121 122%tm.win32.c : %.tm 123 WINEPREFIX=${HOME}/.wine32.mma wine ${MPREPwin} "$<" -o "$@" 124 ${SED} -i 's# __DATE__# ",__DATE__," ",__TIME__,"#g' "$@" 125 126${SYSwin}/%.obj : %.c 127 ${CCw32} -o "$@" -c "$<" $(shell $(CROSS)-pkg-config --cflags libbiosig) ${INCDIRwin} 128 129win32mma : $(patsubst %, ${SYSwin}/%.exe, $(TARGET)) 130 131#${SYSwin}/%.exe : ${SYSwin}/%.obj ${SYSwin}/%tm.obj # uses MPREP 132${SYSwin}/%.exe : ${SYSwin}/%.obj ${SYSwin}/%tm.win32.obj # uses MPREPwin 133 mkdir -p ${SYSwin} 134 ${CCw32} $? -mwindows -static-libgcc -static-libstdc++ $(shell $(CROSS)-pkg-config --libs libbiosig) -lssp -L${LIBDIRwin} -l${MLLIBwin} ${EXTRALIBSwin} -o "$@" 135 136 137########################################### 138# Win64 - cross-compilation 139########################################### 140 141CCw64 = $(CROSS64)-gcc 142CADDSDIRwin64 = ${MLINKDIR}/SystemFiles/Links/MathLink/DeveloperKit/${SYSwin64}/CompilerAdditions 143INCDIRwin64 = -I${CADDSDIRwin64} 144LIBDIRwin64 = ${CADDSDIRwin64} 145 146#MPREPwin64 = ${CADDSDIRwin64}/mprep.exe 147 148#%tm.win64.c : %.tm 149# WINEPREFIX=${HOME}/.wine64.mma wine64 ${MPREPwin64} "$<" -o "$@" 150 #${MPREP} "$<" -o "$@" 151# ${SED} -i 's# __DATE__# ",__DATE__," ",__TIME__,"#' "$@" 152 153${SYSwin64}/%.obj : %.c 154 ${CCw64} -o "$@" -c "$<" $(shell $(CROSS64)-pkg-config --cflags libbiosig) ${INCDIRwin64} 155 156win64mma : $(patsubst %, ${SYSwin64}/%.exe, $(TARGET)) 157 158#${SYSwin64}/%.exe : ${SYSwin64}/%.obj ${SYSwin64}/%tm.win64.obj # uses MPREPwin64 159${SYSwin64}/%.exe : ${SYSwin64}/%.obj ${SYSwin64}/%tm.obj # uses MPREP 160 mkdir -p ${SYSwin64} 161 ${CCw64} $? -static-libgcc -static-libstdc++ $(shell $(CROSS64)-pkg-config --libs libbiosig) -lssp -L${LIBDIRwin64} -l${MLLIBwin64} ${EXTRALIBSwin} -o "$@" 162 163 164########################################### 165clean: 166 -$(RM) *.o* */*.o* 167 -$(RM) *tm.c */*tm.c 168 -$(RM) *.exe */*.exe 169