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. When MCC is run from a DOS or UNIX shell, it searches for a
%   file named 'mccpath' in the present working directory, then the
%   user's preferences directory (as returned by PREFDIR), and finally
%   the MATLAB/bin directory. If it finds one, it reads it 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. 
%
%   See also PREFDIR.

%   Copyright 1984-2000 The MathWorks, Inc.
%   $Revision: 1.3 $ $Date: 2000/08/30 17:35: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);






