-
Notifications
You must be signed in to change notification settings - Fork 0
/
make.m
37 lines (30 loc) · 1004 Bytes
/
make.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
function make(rebuild)
if nargin < 1
rebuild = false;
end
filePath = mfilename('fullpath');
projectDir = fileparts(filePath);
currentDir = pwd;
returnToDir = onCleanup(@()cd(currentDir));
cd(projectDir);
options = '';
options = [options ' -L"' projectDir '" -lavbin'];
sourceFiles = dir(fullfile(projectDir, '*.c'));
for i = 1:length(sourceFiles)
source = sourceFiles(i);
[path, name] = fileparts(source.name);
mexname = [name '.' mexext];
mexfile = dir(mexname);
if rebuild || isempty(mexfile) || datenum(source.date) > datenum(mexfile.date)
command = sprintf('mex %s %s', options, source.name);
disp(command);
try
eval(command);
catch
disp(['Error building ''' source.name '''']);
end
else
disp([source.name ' is up to date']);
end
end
end