-
Notifications
You must be signed in to change notification settings - Fork 0
/
make_csd.m
94 lines (88 loc) · 4.12 KB
/
make_csd.m
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
%MAKE_FACTOR Compilation of CSD mex-files
MATLAB_PATH = matlabroot;
COMPILE_OPTIONS = '';
v = ver('matlab');
matver = sscanf(v.Version, '%d.%d.%d')';
COMPILE_OPTIONS = [ COMPILE_OPTIONS ' -DMATLAB_VERSION=0x' sprintf('%02d%02d', matver(1), matver(2)) ];
MATLAB_VERSION = matver(1) + matver(2)/100;
if MATLAB_VERSION < 7.14
error('Requires Matlab 2012a (7.14) or higher with Lapack version 3.3.0 or higher.')
end
if strcmpi('GLNX86', computer) || strcmpi('GLNXA64', computer) ...
|| strcmpi('MACI', computer) || strcmpi('MAC', computer) ...
|| strcmpi('MACI64', computer)
% GNU/Linux (x86-32 or x86-64) or MacOS (Intel or PPC)
LAPACK_PATH = ' -lmwlapack';
if MATLAB_VERSION < 7.05
BLAS_PATH = '';
else
BLAS_PATH = ' -lmwblas';
end
if strcmpi('GLNX86', computer) || strcmpi('GLNXA64', computer)
COMPILE_OPTIONS = [COMPILE_OPTIONS,' -DSkip_f2c_Undefs',' -DNON_UNIX_STDIO'];
else
COMPILE_OPTIONS = [COMPILE_OPTIONS,' -DSkip_f2c_Undefs'];
end
elseif strcmpi('PCWIN', computer) || strcmpi('PCWIN64', computer)
% Windows (x86-32 or x86-64)
if strcmpi('PCWIN', computer)
if MATLAB_VERSION < 7.06
MANUFACTURER = 'lcc';
else
cc = mex.getCompilerConfigurations('C','Selected');
MANUFACTURER = cc.Manufacturer;
end
switch lower(MANUFACTURER)
case {'lcc'}
BLAS_PATH = fullfile(MATLAB_PATH, 'extern', 'lib', 'win32', 'lcc', 'libmwblas.lib');
LAPACK_PATH = fullfile(MATLAB_PATH, 'extern', 'lib', 'win32', 'lcc', 'libmwlapack.lib');
COMPILE_OPTIONS = [COMPILE_OPTIONS,' -DLCCWIN32'];
case {'microsoft'}
BLAS_PATH = fullfile(MATLAB_PATH, 'extern', 'lib', 'win32', 'microsoft', 'libmwblas.lib');
LAPACK_PATH = fullfile(MATLAB_PATH, 'extern', 'lib', 'win32', 'microsoft', 'libmwlapack.lib');
case {'sybase'}
BLAS_PATH = fullfile(MATLAB_PATH, 'extern', 'lib', 'win32', 'watcom', 'libmwblas.lib');
LAPACK_PATH = fullfile(MATLAB_PATH, 'extern', 'lib', 'win32', 'watcom', 'libmwlapack.lib');
COMPILE_OPTIONS = [COMPILE_OPTIONS,' -DWATCOMWIN32'];
otherwise
disp('Try "mex -setup", because BLAS/LAPACK library is not available!')
end
else
cc = mex.getCompilerConfigurations('C','Selected');
MANUFACTURER = cc.Manufacturer;
switch lower(MANUFACTURER)
case {'gnu'}
BLAS_PATH = fullfile(MATLAB_PATH, 'extern', 'lib', 'win64', 'mingw64', 'libmwblas.lib');
LAPACK_PATH = fullfile(MATLAB_PATH, 'extern', 'lib', 'win64', 'mingw64', 'libmwlapack.lib');
case {'microsoft'}
BLAS_PATH = fullfile(MATLAB_PATH, 'extern', 'lib', 'win64', 'microsoft', 'libmwblas.lib');
LAPACK_PATH = fullfile(MATLAB_PATH, 'extern', 'lib', 'win64', 'microsoft', 'libmwlapack.lib');
otherwise
disp('Try "mex -setup", because BLAS/LAPACK library is not available!')
end
end
if MATLAB_VERSION < 7.05
BLAS_PATH = ''; % On <= 7.4, BLAS in included in LAPACK
else
BLAS_PATH = [' "' BLAS_PATH '"'];
end
LAPACK_PATH = [' "' LAPACK_PATH '"'];
COMPILE_OPTIONS = [COMPILE_OPTIONS,' -DMSDOS',' -DUSE_CLOCK',' -DNO_ONEXIT'];
else
error('Unsupported platform')
end
% Large array dims for 64 bits platforms appeared in Matlab 7.3
if (strcmpi('GLNXA64', computer) || strcmpi('PCWIN64', computer) ...
|| strcmpi('MACI64', computer))
if ~(MATLAB_VERSION < 9.04)
COMPILE_OPTIONS = [ COMPILE_OPTIONS ' -R2018a' ];
elseif ~(MATLAB_VERSION < 7.03)
COMPILE_OPTIONS = [ COMPILE_OPTIONS ' -largeArrayDims' ];
end
end
% Comment next line to suppress optimization
COMPILE_OPTIONS = [ ' -O' COMPILE_OPTIONS ];
% Comment next line to suppress compilation debugging info
%COMPILE_OPTIONS = [ ' -v' COMPILE_OPTIONS ];
disp('Compiling csd...')
eval(['mex ', COMPILE_OPTIONS, ' csd.c', BLAS_PATH, LAPACK_PATH]);