function checkLicense(checkout)
% CHECKLICENSE
% function to check the validity of slhdlcoder license

% Copyright 2005-2012 The MathWorks, Inc.

if nargin < 1
% always checkout a license when makehdl/checkhdl is run
checkout = true;
end

licenseAvailable = (license('checkout','Simulink_HDL_Coder') && ...
license('checkout','MATLAB_Coder'));

if checkout && ~licenseAvailable
% no license available
error(message('HDLShared:hdldialog:nolicenseavailable'));
end

if ~hdlcoderui.isslhdlcinstalled
% SL HDL Coder not installed => HDL Coder object not available =>
% license not available
error(message('HDLShared:hdldialog:nolicenseavailable'));
end

if ~(builtin('license','test','Fixed_Point_Toolbox'))
error(message('hdlcoder:engine:nofxplicenseavailable'));
end
% Load the fixed point toolbox early so that MATLAB authoring can resolve its
% paths. g561476. See also schema.m.
fi('DataType', 'double'); % This should not check out a license.
end