function [MakeStrs,Vars,Vals] = getMakeVars(h)
%GETMAKEVARS - returns strings formatted for use as makefile variables    
%[MakeStrs, Vars, Vals] = getMakeVars()

% Copyright 2012-2019 The MathWorks, Inc.

    specDirs = h.Settings.getSpecialDirsAndTokens();
    
    sDirVals = specDirs.dirs;
    % strip off the '$(' and ')' delimiters from the token vars
    sDirVars =  regexprep(specDirs.toks,'\$\(([^<]*)\)','$1');    

    [toks, tokVals] = h.getKeyValuePair('type','Tokens','incGroups',{'makevar'});
    % strip off the '|>' and '<|' delimiters from the token vars
    tokVars = regexprep(toks,'\|>([^<]*)<\|','$1');    
    
    % get the buildArgs that are also makevars
    [bArgVars, bArgVals] = h.getKeyValuePair('type','BuildArgs','incGroups',{'makevar'});
        

    % get the additional makevars as well
    [mvKeys, mvVals] = h.getKeyValuePair('type','MakeVars');

    % loop through the link objects and create vars for the library folder 
    % and source file for libs that are 'BuildInPlace'
    loVars = {};
    loVals = {};
    for i=1:length(h.LinkObj)
        if (h.LinkObj(i).BuildInPlace == false)
            continue;
        end
        varRoot = h.LinkObj(i).getMakeVarRoot();
        % check for a var override in the makevars before adding them to the
        % list
        
        libVars = {[varRoot '_LIB']...
                   [varRoot '_SRC']...
                   [varRoot '_SRC_DIR']};
        if strcmp(h.Settings.FileSep,'\')
            regexp_filesep = '\\';
        else
            regexp_filesep = h.Settings.FileSep;
        end    
        libVals = {regexprep(fullfile(h.LinkObj(i).Path,h.LinkObj(i).Name),'[\\/]',regexp_filesep)...
                   regexprep(fullfile(h.LinkObj(i).Path,'*.c'),'[\\/]',regexp_filesep)...
                   h.LinkObj(i).Path};
        
        [~,idx] = setdiff(libVars,mvKeys);
        idx = sort(idx);
        libVars = libVars(idx);
        libVals = libVals(idx);
        
        if ~isempty(libVars)
            loVars = [loVars libVars{:}]; %#ok<AGROW>
            loVals = [loVals libVals{:}]; %#ok<AGROW>
        end        
    end

    Vars = [sDirVars(:)' tokVars(:)' bArgVars(:)' mvKeys(:)' loVars(:)'];
    Vals = [sDirVals(:)' tokVals(:)' bArgVals(:)' mvVals(:)' loVals(:)'];
    
    MakeStrs = strcat(Vars, {' = '}, Vals);
