1 % Copyright (C) 2013-2014 Czech Technical University in Prague
4 % - Carlos Jenkins <carlos@jenkins.co.cr>
6 % This document contains proprietary information belonging to Czech
7 % Technical University in Prague. Passing on and copying of this
8 % document, and communication of its contents is not permitted
9 % without prior written authorization.
11 % File : compile_blocks.m
13 % Compile all the C-MEX S-Function in current folder.
16 % http://www.mathworks.com/help/matlab/ref/mex.html
17 % http://www.mathworks.com/help/matlab/matlab_external/custom-building-mex-files.html
20 function compile_blocks()
23 % -g Create a binary MEX-file containing additional symbolic
24 % information for use in debugging. This option disables the mex
25 % default behavior of optimizing built object code
26 % (see the -O option).
27 % -v Verbose mode. Print the values for important internal variables
28 % after the options file is processed and all command-line
29 % arguments are considered. Prints each compile step and final
30 % link step fully evaluated.
33 matlabRootPath=strcat('"',matlabroot(),'"');
34 mex = fullfile(matlabRootPath, 'bin', 'mex');
36 sources = dir('sfunction_*.c');
40 if strcmp(i.name, 'sfunction_canreceive.c') || ...
41 strcmp(i.name, 'sfunction_cantransmit.c'),
42 local_opts = [local_opts ' ' ...
43 '-I' matlabRootPath '/toolbox/shared/can/src/scanutil ' ...
44 '-I' matlabRootPath '/toolbox/rtw/targets/common/can/datatypes ' ...
45 matlabRootPath '/toolbox/rtw/targets/common/can/datatypes/sfun_can_util.c '...
46 matlabRootPath '/toolbox/rtw/targets/common/can/datatypes/can_msg.c'];
48 command = [mex ' ' i.name ' ' local_opts];
50 [status, result] = system(command);
53 throw(MException('rpp:compile_block_failure', [i.name, ' failed to compile']))