Home > chronux_2_00 > spikesort > utility > datatools > private > COREmex.m

COREmex

PURPOSE ^

COREMEX Compile CORE_ functions.

SYNOPSIS ^

function COREmex(source, options)

DESCRIPTION ^

COREMEX           Compile CORE_ functions.
   COREMEX(SOURCE), where SOURCE is the name of a CORE_ source
   file, checks if the .mexw32 or .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 mex library was compiled (or if no such compiled library exists), 
   COREMEX calls:
         mex SOURCE CORE_library.c CORE_mextools.c BLAS
   where LAPACK includes the static LAPACK library definition files for
   the currently chosen compiler (LCC or MSVC).  This compiles the MEX 
   code in SOURCE and links to CORE_library functions and BLAS.
   
   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.mexw32 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_libmwblas.lib

      If not using the OPTIONS argument, the following syntax is valid:
          COREMEX CORE_testfile.c

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

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

Generated on Fri 15-Aug-2008 11:35:42 by m2html © 2003