In the first phase of testing my code has to run in a Matlab Simulink environment (2010b 32bits) compiled as S-function. The compiler is the one that comes with Visual Studio 2010.
I currently have a script that compiles my code that looks like this:
mex -c -v foo_main.c
mex -c -v foo_1.c
mex -c -v foo_2.c
% etc...
mex -v foo_wrapper.c foo_main.obj foo_1.obj foo_2.obj % etc...
During the years the number of files has greatly increased, to the extent that compilation takes quite some time.
My question is: does it exists a method to check if an *.obj
does not correspond to its *.c
counterpart and recompile it only when necessary?
I am wary of creating special scripts because I would have to change them on a case-by-case basis and I see this as a road prone to errors and unnecessary risks.
EDIT:
My current solution is to take the date
property of the files and compare them:
c_file = dir(fullfile(pwd,'\\foo.c'));
obj_file = dir(fullfile(pwd,'\\foo.obj'));
if (datenum(c_file.date) > datenum(obj_file.date))
mex -c -v foo.c
end
I understand that this is not the cleanest solution and, in the comments, m.s. suggests to use a nmake
file. I never created one and I do not know how to use it from a Matlab script.
Can it be done? Which steps should I follow to create and use it?