-
Notifications
You must be signed in to change notification settings - Fork 0
/
compile.m
95 lines (86 loc) · 3.01 KB
/
compile.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
95
% COMPILE Compiles code in the KLEIN directory
%
% COMPILE([ROOT], [FILES]) compiles files given by FILES. FILES must be
% cell, and if it is {}, then this function compiles all. ROOT is the
% root directory /mnt/data/klein (or t:\klein, for example).
%
% REVISION HISTORY
%
% 12/2/2003 Thang Created this file so I can compile the code
% nicely in linux as well as Windows without messy makefiles!
% 12/9/2003 Thang Made this a function with two arguments.
% 12/16/2003 Thang Lost a bunch of versio n of this. Added
% nmfastwalsh and some more default parameters
%
function compile(root, files)
if ((nargin < 1) | (length(root) == 0))
if (ispc)
% root = 't:\mseq';
else
% root = '/mnt/data/mseq';
end
root = '.';
end
oldDir = pwd;
if (isdir(root))
cd(root);
else
disp(['Invalid parameter root = ' root]);
disp(['Please read the help text and follow appropriately:']);
help compile;
return;
end
if (nargin < 2)
files = {};
end
if (iscell(files) == 0)
files = {files};
end
% each cell in mexfiles contains N subcells. The first subcell is the name
% of the mex file to be compiled (must be in directory with the same name)
% and the subsequent subcells are cpp files to compile (matlabaux.cpp is
% assumed to be included)
mexfiles = getmexfiles;
curdir = pwd;
if (length(files) == 0)
disp(['compiling ' num2str(length(mexfiles)) ' MEX files...']);
for i=1:length(mexfiles)
if (isoctave() == 1)
cmd = ['mex -DCOMPILE_IN_MATLAB -I' curdir '/matlabaux -I' curdir '/matlabaux/octave ' curdir '/matlabaux/matlabaux.cpp -o ' curdir '/mseq/' mexfiles{i}{2}];
else
cmd = ['mex -DCOMPILE_IN_MATLAB -I' curdir '/matlabaux ' curdir '/matlabaux/matlabaux.cpp -outdir ' curdir '/mseq -output ' mexfiles{i}{2}];
end
for j=3:length(mexfiles{i})
cmd = [cmd ' ' curdir '/' mexfiles{i}{2} '/' mexfiles{i}{j}];
end
% disp(cmd);
% return;
if (length(mexfiles{i}{1}))
disp(['compiling : ' mexfiles{i}{2} ' - ' mexfiles{i}{1}]);
else
disp(['compiling : ' mexfiles{i}{2}]);
end
eval(cmd);
end
else
disp(['compiling ' num2str(length(files)) ' MEX files...']);
for k=1:length(files)
for i=1:length(mexfiles)
if (strcmpi(files{k},mexfiles{i}{2}) == 1)
cmd = ['mex -DCOMPILE_IN_MATLAB -I' curdir '/matlabaux ' curdir '/matlabaux/matlabaux.cpp -outdir ' curdir '/mseq -output ' mexfiles{i}{2}];
for j=3:length(mexfiles{i})
cmd = [cmd ' ' curdir '/' mexfiles{i}{2} '/' mexfiles{i}{j}];
end
disp(cmd);
if (length(mexfiles{i}{1}))
disp(['compiling : ' mexfiles{i}{2} ' - ' mexfiles{i}{1}]);
else
disp(['compiling : ' mexfiles{i}{2}]);
end
eval(cmd);
break;
end
end
end
end
cd(oldDir);