Debian Codegraph @

biosig4c++/mma/Makefile.in

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