function mkaccel(sys)
%MKACCEL(SYS) builds the specified block diagram's MEX file.
%	Calling this function is equivalent to choosing
%	'Build Accelerator...' from the Simulate menu.

%	Rick Spada  11-23-92
%	Copyright (c) 1990-94 by The MathWorks, Inc.

% if no sys specified, use the current block diagram
if nargin==0,
  sys=get_param;
end;

% no block diagram, go bye
if isempty(sys),
  error('No block diagram specified.');
end;

% get the compile command, and change '$model' to the model name
compile_command=strrep(get_param(sys,'Compile command'),'$model',sys);

% last thing to do is to codegen the block diagram and  evaluate
% the compile command
genres=gencode(sys);
if genres~= 0.
  disp(compile_command);
  eval(compile_command);
end

