GNU make 4 –output-sync

The GNU make 4 --output-sync feature no longer mangles the output from multiple recipes run in parallel, which is great. However, tools will then typically stop to generate ANSI color codes, which is not so great.

But as I usually need to specify my local Clang trunk build in my LibreOffice autogen.input anyway, there is little trouble adding the -fcolor-diagnostics switch to force color codes back on:

CC=…/clang -fcolor-diagnostics
CXX=…/clang++ -fcolor-diagnostics

That solves the problem when running make from a terminal, but in turn spoils Emacs’s M-x compile. To fix that, add

(defun my-filter-ansi-color-codes-hook ()
  (goto-char compilation-filter-start)
  (while (re-search-forward "\e\\[\\([0-9]+\\(;[0-9]+\\)*\\)?m" nil t)
    (replace-match "" nil nil)))
(add-hook 'compilation-filter-hook 'my-filter-ansi-color-codes-hook)

to your .emacs. And while you’re at it, also add

  '(("^\\([^:\n]+\\):\\([1-9][0-9]*\\): recipe for target '[^'\n]+' failed$" 1 2
     nil 0 1))

to demote that (apparently new?) make error to a warning, so that, in combination with (setq compilation-skip-threshold 2), M-x next-error will skip it over.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s