function generateBuildTools(h,language,buildToolType,buildTool)
%

%   Copyright 2014 The MathWorks, Inc.

if nargin==2
    % Build Tools
    tools = coder.make.internal.LanguageToolRegistry.getItems( language, 'Build Tools' );
    for i = 1:tools.length()
        toolInfo = tools.getValue( i );
        h.createAndAddBuildTool( 'build', toolInfo.Name, toolInfo );
    end
    % Now that the platform is set, set the proper MEX extension.
    h.setMexExtBasedOnPlatform();
    % Prebuild Tools
    tools = coder.make.internal.LanguageToolRegistry.getItems( language, 'Prebuild Tools' );
    for i = 1:tools.length()
        toolInfo = tools.getValue( i );
        h.createAndAddBuildTool( 'prebuild', toolInfo.Name, toolInfo );
    end
    % Postbuild Tools
    tools = coder.make.internal.LanguageToolRegistry.getItems( language, 'Postbuild Tools' );
    for i = 1:tools.length()
        toolInfo = tools.getValue( i );
        h.createAndAddBuildTool( 'postbuild', toolInfo.Name, toolInfo );
    end
    % Add the build tool keys to the list of reserved names
    h.addReservedNames( 'BuildTools', h.BuildTools.keys() );
    h.addReservedNames( 'BuildTools', h.PrebuildTools.keys() );
    h.addReservedNames( 'BuildTools', h.PostbuildTools.keys() );
else
    toolInfo = coder.make.internal.LanguageToolRegistry.getCBuildItems( [  ], buildToolType, buildTool );
    buildToolTypes = { 'Build Tool', 'Prebuild Tool', 'Postbuild Tool' };
    buildToolArgs = { 'build', 'prebuild', 'postbuild' };
    buildToolProps = { 'BuildTools', 'PrebuildTools', 'PostbuildTools' };
    idx = find( strcmpi( buildToolTypes, buildToolType ) );
    if isempty( idx )
        assert( false, [ 'Incorrect input ''', buildToolType, ''' to method "generateBuildTools()". ', 'It must be any of the following: ', coder.make.internal.cell2str( buildToolTypes, ',' ) ] );
    end
    h.createAndAddBuildTool( buildToolArgs{ idx }, toolInfo.Name, toolInfo );
    h.addReservedNames( buildToolProps{ idx }, buildTool );
end
end
