function [sysLibs, sysLibPathsForCompiler, sysLibPathsForMex] = ...
    getFormattedSysLibInfo(lBuildInfo, compToolChain)
% Determine system library names and paths depending on toolchain
% requirements

%   Copyright 2018-2019 The MathWorks, Inc.

[sysLibs, sysLibPaths] = lBuildInfo.getSysLibInfo();
sysLibPaths = regexprep(sysLibPaths, '^\$\(MATLAB_ROOT\)', ...
    regexptranslate('escape', matlabroot), 'once');

if any(strcmp(compToolChain, {'mingw64', 'unix'}))
    sysLibs = regexprep(sysLibs, '.*', '-l$0', 'once');
else
    % compToolChain must be one of the allowed values
    assert(any(strcmp(compToolChain, {'lcc', 'vcx64', 'intel'})), ...
        'compToolChain = %s is not recognized', compToolChain);
    
    sysLibs = regexprep(sysLibs, '.*', 'lib$0.lib');
    
    % g1310518: filename of sf_runtime is not platform independent
    sysLibs = regexprep(sysLibs, 'libsf_runtime.lib', 'sf_runtime.lib');
end

% Mex always expects a -L prefix
sysLibPathsForMex = regexprep(sysLibPaths, '.*', '-L$0', 'once');

if any(strcmp(compToolChain, {'mingw64', 'unix', 'lcc'}))
    sysLibPathsForCompiler = regexprep(sysLibPaths, '.*', '-L"$0"', 'once');
else
    sysLibPathsForCompiler = regexprep(sysLibPaths, '.*', '/LIBPATH:"$0"', 'once');    
end


