-
Notifications
You must be signed in to change notification settings - Fork 7
/
Makefile.var
113 lines (104 loc) · 2.92 KB
/
Makefile.var
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# Makefile default variables
#
# Copyright (C) 1991-2020 Wellcome Centre for Human Neuroimaging
#
# $Id: Makefile.var 8020 2020-11-26 15:00:31Z guillaume $
#
###############################################################################
#
# This file defines variables used in Makefile and has been tested under
# Linux, Windows and macOS.
#
# If you have to tweak this file to compile the SPM MEX-files for your
# platform, please send the details to <fil.spm@ucl.ac.uk> so they can be
# included here.
#
# You can find some more help online on the SPM wikibook:
# * Linux:
# https://en.wikibooks.org/wiki/SPM/Installation_on_64bit_Linux
# * Windows:
# https://en.wikibooks.org/wiki/SPM/Installation_on_64bit_Windows
# MinGW: http://www.mingw.org/
# * macOS:
# https://en.wikibooks.org/wiki/SPM/Installation_on_64bit_Mac_OS_(Intel)
#
###############################################################################
SHELL = /bin/sh
MAKE = make
MEXOPTS = -O -largeArrayDims
MEXEND =
MOSUF = o # mex output object suffix
UNAME = uname
AR = ar rcs
COPY = cp -f
DEL = rm -f
MOVE = mv -f
TAR = tar
ZIP = gzip -f
OMPFLAG = -fopenmp
WARNFLAG = -Wall -Wextra -Wpedantic
USE_OPENMP ?= 0
ifndef PLATFORM
PLATFORM = $(shell $(UNAME))
endif
##### Linux #####
ifeq (Linux,$(PLATFORM))
MEXEXT = mexa64
MEXBIN ?= /usr/local/MATLAB/R2018a/bin/mex
#MEXOPTS += CFLAGS='$$CFLAGS $(WARNFLAG)'
endif
##### MacOS #####
ifeq (Darwin,$(PLATFORM))
MEXEXT = mexmaci64
MEXBIN ?= mex
# https://stackoverflow.com/questions/37362414/
OMPFLAG = -fopenmp=libiomp5
endif
##### Windows #####
ifeq (MINGW32,$(word 1,$(subst _, ,$(PLATFORM)))) # MSVC
override PLATFORM = windows
MEXEXT = mexw64
MEXBIN ?= cmd /c "mex.bat
MEXOPTS += -DSPM_WIN32
MEXEND = "
MOSUF = obj
AR = lib.exe /out:
OMPFLAG = /openmp
endif
ifeq (MSYS,$(word 1,$(subst _, ,$(PLATFORM)))) # GCC
MEXEXT = mexw64
MEXBIN ?= mex
MEXOPTS += -DSPM_WIN32
MOSUF = obj
endif
#### Octave ####
ifeq (octave,$(PLATFORM))
MEXEXT = mex
MEXBIN ?= mkoctfile
MEXOPTS = --mex -DOCTAVE_MEX_FILE
#MEXOPTS += $(WARNFLAG)
override PLATFORM = $(shell $(UNAME))
ifeq (MINGW64,$(word 1,$(subst _, ,$(PLATFORM))))
MEXOPTS += -DSPM_WIN32
endif
OMPFLAG =
endif
#### Otherwise ####
ifndef MEXEXT
$(error Unknowm platform $(PLATFORM))
endif
MATLABROOT = $(realpath $(shell which $(firstword $(MEXBIN))))
ifeq (1,$(USE_OPENMP))
ifneq ($(OMPFLAG),)
MEXOPTS += CFLAGS='$$CFLAGS $(OMPFLAG)' LDFLAGS='$$LDFLAGS $(OMPFLAG)'
endif
endif
MEX = $(MEXBIN) $(MEXOPTS)
SUF = $(MEXEXT)
define verb
@ echo "_____________________________________________________________"
@ echo ""
@ echo " " $(1)
@ echo "_____________________________________________________________"
@ echo ""
endef