Unfortunately flattening the Makefile is not in the cards. I was able to get this to work by piping the make output through an external script like so:
// in the build system
"shell_cmd": "make -w 2>&1 | sublemake"
cdir = ""
enter_re = re.compile(r"make[0-9]+]: Entering directory\s+`(.*)'")
err_re = re.compile(r"(..^:\n]):([0-9]+:?[0-9]+?:? .)$")
for line in iter(sys.stdin.readline, b''):
err = re.match(err_re, line)
enter = re.match(enter_re, line)
cdir = os.path.relpath(enter.group(1))
Is there a way that I can write a plugin to capture the build output and modify it before going to the output view? Looking at Packages/Default/exec.py, I have an idea where that would go, but I'm not sure how to intercept that in a plugin. It would be nice if this functionality was all handled in sublime text, rather than needing an external tool on the PATH.