


COREMEX Compile CORE_ functions.
COREMEX(SOURCE), where SOURCE is the name of a CORE_ source
file, checks if the .dll file of the same name is older than any of
the following source files: {SOURCE, CORE_library.c, CORE_mextools.c}.
If any of these files have been modified since the .dll was created
(or if no such .dll exists), COREMEX calls:
mex SOURCE CORE_library.c CORE_mextools.c LAPACK
where LAPACK is the static LAPACK library definition file for the
currently chosen compiler. This compiles the MEX code in SOURCE
and links to both CORE_library functions and BLAS/LAPACK.
COREMEX(SOURCE, OPTIONS) allows specification of command line options
to be passed to MEX.
Example:
If the current compiler is set to be LCC and CORE_testfile.c has
been modified since CORE_testfile.dll was created (i.e., 'Modified'
in Windows),
COREmex('CORE_testfile.c', '-v -g')
calls
mex -v -g CORE_testfile.c ...
CORE_library.c CORE_mextools.c lcc_libmwlapack.lib
If not using the OPTIONS argument, the following syntax is valid:
COREMEX CORE_testfile.c

0001 function COREmex(source, options) 0002 %COREMEX Compile CORE_ functions. 0003 % COREMEX(SOURCE), where SOURCE is the name of a CORE_ source 0004 % file, checks if the .dll file of the same name is older than any of 0005 % the following source files: {SOURCE, CORE_library.c, CORE_mextools.c}. 0006 % If any of these files have been modified since the .dll was created 0007 % (or if no such .dll exists), COREMEX calls: 0008 % mex SOURCE CORE_library.c CORE_mextools.c LAPACK 0009 % where LAPACK is the static LAPACK library definition file for the 0010 % currently chosen compiler. This compiles the MEX code in SOURCE 0011 % and links to both CORE_library functions and BLAS/LAPACK. 0012 % 0013 % COREMEX(SOURCE, OPTIONS) allows specification of command line options 0014 % to be passed to MEX. 0015 % 0016 % Example: 0017 % If the current compiler is set to be LCC and CORE_testfile.c has 0018 % been modified since CORE_testfile.dll was created (i.e., 'Modified' 0019 % in Windows), 0020 % COREmex('CORE_testfile.c', '-v -g') 0021 % calls 0022 % mex -v -g CORE_testfile.c ... 0023 % CORE_library.c CORE_mextools.c lcc_libmwlapack.lib 0024 % 0025 % If not using the OPTIONS argument, the following syntax is valid: 0026 % COREMEX CORE_testfile.c 0027 0028 %%%%%%%%%%%%%%%%%%%%%%%%%%%% Parse Inputs %%%%%%%%%%%%%%%%%%%%%%%%%%%% 0029 if (nargin < 2), options = ''; end 0030 [pat,nam,ext] = fileparts(source); 0031 if (~exist(source, 'file')), 0032 error(['Source file ' SOURCE ' not found.']); 0033 end 0034 0035 %%%%%%%%%%%%%%%%%%%%%% Check if Compile Needed %%%%%%%%%%%%%%%%%%%%%%% 0036 src1 = dir(source); 0037 src2 = dir('CORE_library.c'); 0038 src3 = dir('CORE_mextools.c'); 0039 dll = dir([pat nam '.dll']); 0040 if (~isempty(dll)) 0041 srclist = [datenum(src1.date) datenum(src2.date) datenum(src3.date)]; 0042 if (all(datenum(dll.date) > srclist)), return; end 0043 end 0044 0045 %%%%%%%%%%%%%%%%%%%%% Choose LAPACK definitions %%%%%%%%%%%%%%%%%%%%%% 0046 % We need to figure out which compiler we're using so we can link the 0047 % appropriate static LAPACK library definition ... 0048 [stat,rslt] = system('echo %USERPROFILE%'); 0049 mexopts = [rslt(1:end-1) '\Application Data\Mathworks\MATLAB\R13\mexopts.bat']; 0050 origname = textread(mexopts, 'rem %s', 1, 'headerlines', 1); 0051 switch (upper(origname{1}(1:3))) 0052 case 'MSV', lapack = 'msvc_libmwlapack.lib'; 0053 case 'BCC', lapack = 'borland_libmwlapack.lib'; 0054 case 'LCC', lapack = 'lcc_libmwlapack.lib'; 0055 otherwise, error('Do not have the static LAPACK definition for that compiler.'); 0056 end 0057 0058 0059 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Compile %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 0060 eval(['mex ' options ' ' source ' CORE_library.c CORE_mextools.c ' lapack]);