1####### Makefile for "BioSig for C/C++" ##################### 2### 3### Copyright (C) 2006-2020 Alois Schloegl <alois.schloegl@ist.ac.at> 4### This file is part of the "BioSig for C/C++" repository 5### (biosig4c++) at http://biosig.sf.net/ 6### 7############################################################## 8 9##### Target: GNU/Linux 10# 11## make && make install build and install libbiosig, but no other tools. 12# libbiosig is a prerequisite for building all the other tools below. 13# 14## make save2gdf - makes converter 15## make install_save2gdf - installs converter 16# 17## make mex4o - makes mexSLOAD, mexSOPEN for Octave (requires Octave-headers) 18## make mex4m - makes mexSLOAD, mexSOPEN for Matlab (requires Matlab, mex -setup must be configured) 19## make mexw32 - makes mexSLOAD.mexw32, mexSOPEN.mexw32 (requires that mingw32, gnumex libraries from Matlab/Win32) 20## make mexw64 - makes mexSLOAD.mexw64, mexSOPEN.mexw64 (requires that mce-w32, gnumex libraries from Matlab/Win64) 21## make mex - mex4o, mex4m, mexw32, mexw64 combined 22## make biosig4python - makes python interface (requires Python) 23## make biosig4java - makes Java interface (experimental) 24## make biosig4php - makes PHP interface (experimental) 25## make biosig4perl - makes perl interface (experimental) 26## make biosig4ruby - makes ruby interface (experimental) 27## make biosig4tcl - makes tcl/tk interface (experimental) 28## 29## make win32 and make win64 are obsolete. save2gdf.exe, and libbiosig.{a,dll} for windows can now be built 30## with the mingw-cross-compiler environment (mxe.cc). 31## git clone https://github.com/schloegl/mxe.git 32## make biosig 33## should do what you want. Please note, that win32mma does now also rely that libbiosig is built with MXE. 34## Make sure that CROSS or CROSS64 is properly defined when running `make` 35## 36## ??? 37## make sigviewer - makes sigviewer 38 39##### Target: Win32 40## make win32 - makes save2gdf.exe,libbiosig.lib,libbiosig.dll, for MSWindows, requires MinGW 41## make mexw32 mex/mexSLOAD.mexw32 - requires MinGW32 and GNUMEX libraries from Matlab/Win32 42## make win32/sigviewer.exe - requires sources of SigViewer, and MinGW32 (mex: make suitesparse zlib qt ) 43 44##### Target: Win64 45## make win64 - makes save2gdf.exe,libbiosig.lib,libbiosig.dll, for MSWindows, requires MinGW 46## make mexw64 mex/mexSLOAD.mexw64 - requires MCE-W64 and GNUMEX libraries from Matlab/Win64 47## make win64/sigviewer.exe - requires sources of SigViewer and MCE-W64, make suitesparse zlib qt 48 49##### Target: MacOSX w/ homebrew 50## make install_homebrew installs libbiosig and save2gdf 51 # requires: brew tap homebrew/dupes 52 # brew install libiconv 53 54############################### 55# whether dynamic or static linking is used, can be controlled with 56# LIBEXT. Setting it to 'a' links statically, 'so' links dynamically 57# 58LIBEXT = a 59#LIBEXT = so 60############################### 61 62 63## TARGET dependencies 64ifeq (,$(TARGET)) 65 CC ?= gcc 66 CXX ?= g++ 67 AR := ar rcs 68 PKGCONF := pkg-config 69ifneq (Darwin,$(shell uname)) 70 LFLAGS += -Wl,-z,relro,-z,now 71endif 72else ifeq (intel,$(TARGET)) 73 CC := /opt/intel/bin/icc 74 CXX := /opt/intel/bin/icc 75 LD := /opt/intel/bin/xild 76 AR := /opt/intel/bin/xiar crs 77else 78 prefix := $(dir $(shell which $(TARGET)-gcc)) 79 CC := $(TARGET)-gcc 80 CXX := $(TARGET)-g++ 81 LD := $(TARGET)-ld 82 AR := $(TARGET)-ar rcs 83 PKGCONF := $(TARGET)-pkg-config 84 ifeq (mingw, $(findstring mingw, $(TARGET))) 85 ## add gnulib's getlogin 86 SOURCES += win32/getlogin.c win32/getline.c win32/getdelim.c 87 OBJECTS += getlogin.o getline.o getdelim.o 88 ## exclude conflicting definition of sopen from mingw's io.h 89 CFLAGS += -I. 90 IO_H_FILE2 = io.h 91 CFLAGS += -I$(prefix)/include 92 LIBS += -lssp 93 LDLIBS += -liconv -lws2_32 94 endif 95endif 96 97ifeq (Darwin,$(shell uname)) 98 ## Homebrew: 99 ## brew tap homebrew/dupes 100 ## brew install libiconv 101 ## 102 LD = ld 103 CFLAGS += -I/usr/local/opt/libiconv/include 104 LDLIBS += -L/usr/local/opt/libiconv/lib/ -liconv -lstdc++ 105 LDFLAGS += -dylib -arch x86_64 -macosx_version_min 10.9 106 DLEXT = dylib 107 FULLDLEXT = ${BIOSIG_VERSION}.dylib 108 SONAME_PREFIX = -install_name # the last space character is crucial 109 SONAME_POSTFIX = .${MAJOR_VERSION}.${MINOR_VERSION}.$(DLEXT) 110else 111 LD = $(CXX) 112 LDFLAGS += -shared 113 DLEXT = so 114 FULLDLEXT = so.${BIOSIG_VERSION} 115 SONAME_PREFIX = -Wl,-soname= 116 SONAME_POSTFIX = .$(DLEXT).${MAJOR_VERSION}.${MINOR_VERSION} 117endif 118 119exec_prefix ?= /usr/local 120 121DEFINES_ALL = #-D=NDEBUG 122 123LIBS += $(LDLIBS) 124 125DELETE = rm -f 126COPY = cp -f 127DATA_DIR = data/ 128DATA_DIR_CFS = $(HOME)/L/data/test/CFS/ 129TEMP_DIR = test/ 130VERBOSE := -V0 131 132########################################################## 133## set Matlab and Octave variables 134MATLABDIR ?= $(shell dirname :) 135 136ifeq (.,$(MATLABDIR)) 137 #$(warning MATLABDIR is not defined) 138else 139 MEX = $(MATLABDIR)/mex 140 MEX_EXT := $(shell $(MATLABDIR)/mexext) 141endif 142########################################################## 143 144first: mex4o 145 146### Install mexbiosig for Matlab and Octave 147install: 148 mkdir -p $(DESTDIR)$(exec_prefix)/libexec/biosig/matlab 149 install *.mex* $(DESTDIR)$(exec_prefix)/libexec/biosig/matlab 150 @echo " mexBiosig for Matlab is installed in $(exec_prefix)/libexec/biosig/matlab"; 151 @echo " Usage: Start Matlab and addpath "; 152 @echo " addpath('$(exec_prefix)/libexec/biosig/matlab')"; 153 @echo " mexSLOAD"; 154 155uninstall: 156 # from older source installations 157 -${RM} $(DESTDIR)${prefix}/share/biosig/mex/* 158 -cd $(DESTDIR)${prefix}/share && rmdir -p biosig 159 # from later than 2.0.6 installations 160 -${RM} $(DESTDIR)$(exec_prefix)/libexec/biosig/matlab/{mexSLOAD,mexSOPEN,mexSSAVE,physicalunits}.mex* 161 -cd $(DESTDIR)$(exec_prefix)/libexec && rmdir -p biosig/matlab 162 163############################################################# 164# Compilation: Implicit, default rules 165############################################################# 166 167 168############################################################# 169# MEX-files for Octave and Matlab 170############################################################# 171 172# include directory for Win32-Matlab include 173W32MAT_INC = $(HOME)/bin/win32/Matlab/R2010b/extern/include/ -I../win32 174W64MAT_INC = $(HOME)/bin/win64/Matlab/R2010b/extern/include/ -I../win64 175# path to GNUMEX libraries, available from here http://sourceforge.net/projects/gnumex/ 176GNUMEX = $(HOME)/bin/win32/gnumex 177GNUMEX64 = $(HOME)/bin/win64/gnumex 178 179mexSOPEN.cpp : mexSLOAD.cpp 180 echo "#define mexSOPEN" > mexSOPEN.cpp 181 cat mexSLOAD.cpp >> mexSOPEN.cpp 182 183MEX_OBJECTS = mexSLOAD.cpp mexSOPEN.cpp mexSSAVE.cpp physicalunits.cpp 184 185mex4o: $(patsubst %.cpp, %.mex, $(MEX_OBJECTS)) 186oct: $(patsubst %.cpp, %.oct, $(MEX_OBJECTS)) 187mexw32: $(patsubst %.cpp, %.mexw32, $(MEX_OBJECTS)) 188mexw64: $(patsubst %.cpp, %.mexw64, $(MEX_OBJECTS)) 189 190ifdef MEX_EXT 191mex: mex4o mex4m mexw32 mexw64 192mex4m: $(patsubst %.cpp, %.$(MEX_EXT), $(MEX_OBJECTS)) 193 194%.$(MEX_EXT): %.cpp 195 $(MEX) $(MEX_OPTION) $(DEFINES) -I.. "$<" -L.. -lbiosig -output "$@" 196 197else 198mex: mex4o mexw32 mexw64 199endif 200 201ifneq (:,/usr/bin/octave) 202%.mex: %.cpp 203 $(MKOCTFILE) $(DEFINES) -I.. -v -g --mex "$<" -L.. -lbiosig -o "$@" 204 205%.oct: %.cpp 206 $(MKOCTFILE) $(DEFINES) -I.. "$<" -L.. -lbiosig -o "$@" 207endif 208 209%.mexw32: %.cpp 210 ## $(CROSS)-g++ is used instead of $(CXX), so it can be called from biosig as well as mxe. 211 $(CROSS)-g++ -shared $(GNUMEX)/mex.def -DMATLAB_MEX_FILE $(DEFINES) -x c++ \ 212 -I$(prefix)/include \ 213 -I$(W32MAT_INC) -O2 -o "$@" -L$(GNUMEX) -s "$<" -llibmx -llibmex $(shell $(CROSS)-pkg-config --libs libbiosig) 214 215%.mexw64: %.cpp 216 $(CROSS64)-g++ -shared $(GNUMEX64)/mex.def -DMATLAB_MEX_FILE $(DEFINES) -x c++ \ 217 -I$(prefix)/include \ 218 -I$(W64MAT_INC) -O2 -o "$@" -L$(GNUMEX64) -s "$<" -llibmx -llibmex $(shell $(CROSS64)-pkg-config --libs libbiosig) 219 220clean: 221 -$(DELETE) *.o *.obj *.o64 core octave-core *.oct *.mex* mexSOPEN.cpp 222 223