function mccsavepath(filename)
%MCCSAVEPATH Generate an mccpath file for use with Compiler 2.0.
%   MCCSAVEPATH generates a file named 'mccpath' in the current
%   directory. The contents of 'mccpath' are MCC command-line
%   switches which set up the MCC search path to be the same as
%   MATLAB's search path. MCC searches for a file named 'mccpath'
%   in the present working directory, and the %MATLAB% directory
%   (on PCs) and in $HOME/matlab (on UNIX). If it finds one, it
%   reads it in and treats its contents as if they had been entered
%   at the start of the command line.
%
%   MCCSAVEPATH(FILENAME) places the output it generates into
%   FILENAME. 

%   Copyright (c) 1984-1998 by The MathWorks, Inc.
%   $Revision: 1.1 $ $Date: 1998/07/27 14:49:56 $

if (nargin < 1)
    filename = 'mccpath';
end

p = strrep(matlabpath, pathsep, sprintf('\n-I '));
p = ['-I ' p sprintf('\n')];

f = fopen(filename, 'wt');

try
    fprintf(f, '%s', p);
catch
    err = lasterr;
    fclose(f);
    error(err);
end

fclose(f);






