Make - How to suppress make error messages without suppressing other output

Sam Marinelli

I'm implementing a simple build system that's actually just a wrapper around Make. Since this build system already emits its own error messages, I don't want Make to produce error messages like

make: *** [/cool/makefile:116: /fun/target.o] Error 1

on failure.

I'm already using the -s flag to suppress most of Make's output. And I don't want Make to ignore errors; I still want it to stop and exit with a status. I can't just kill all error output with make 2> /dev/null because I still want to see messages printed to stderr by the tasks Make is running.

Is there a way to do this without manually parsing and sanitizing Make's output? I'm using GNU Make 4.2.1, and I don't mind GNU Make-specific solutions.

Gilles 'SO- stop being evil'

Since your system is a wrapper around make, I presume that it generates the makefile. Tweak your generator to add 2>&3 to all the shell commands in the makefile, and make your program redirect file descriptor 3 to standard error (file descriptor 2) and file descriptor 2 to /dev/null. This way the make program itself will print to its standard error, which goes to /dev/null, and build commands will print to their standard error, which goes to the wrapper's standard error.

If you're using a handwritten makefile, you can transform it to add those redirections, assuming the makefile doesn't go too wild with syntax (e.g. no fancy GNU make macros that generate commands). For every line that starts with a tab and optionally @ or -, and where the previous line does not end with a backslash, add exec 2>&3; after the tab and optional @-.

Instead of changing the makefile, you can invoke it with the argument SHELL=/path/to/shell_wrapper where shell_wrapper is executes its argument with standard error redirected to a different descriptor, something like this:

#!/bin/sh
eval "$2" 2>&3

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Suppress make warning from not-yet-built include without suppressing error

From Dev

How to suppress Mavens INFO spam without suppressing normal output?

From Dev

Suppressing Error Messages in knitr

From Dev

How to suppress error messages in zsh?

From Dev

Suppressing PhantomJS error output

From Dev

How to make ajax call and show error messages

From Dev

How to make error messages disappear quicker

From Dev

How to make reliase without error?

From Dev

How to suppress messages output by ESAPI library

From Dev

Suppress Makefile output when calling Make

From Dev

Suppress xcodebuild output or make less verbose

From Dev

Need to make awk suppress the output to stdout

From Dev

Need to make awk suppress the output to stdout

From Dev

How to make diff with redirection from other program output work in make

From Dev

How can I suppress these error messages?

From Dev

How to suppress tar error messages in when piping

From Dev

How to restart GNU make (without causing an error)

From Dev

How to make a transparent canvas without error?

From Dev

suppress error messages in protractor

From Dev

How can I suppress the output messages of TCL procedures?

From Dev

How to record the output of a bash script from terminal without suppressing the terminal output?

From Dev

how to make terminal prompt messages?

From Dev

How to make a variable accessible by other classes without subclassing?

From Dev

How do I make values depend on other values without DataKinds?

From Dev

How can I make an array without one number of the other array?

From Dev

How to make colspan work without affecting width of the other rows

From Dev

how to make UILabel dynamically without overlapping with other UILabel

From Dev

How to make a div fit to screen without the other divs being visible

From Dev

How to make Ipython output a list without line breaks after elements?

Related Related

  1. 1

    Suppress make warning from not-yet-built include without suppressing error

  2. 2

    How to suppress Mavens INFO spam without suppressing normal output?

  3. 3

    Suppressing Error Messages in knitr

  4. 4

    How to suppress error messages in zsh?

  5. 5

    Suppressing PhantomJS error output

  6. 6

    How to make ajax call and show error messages

  7. 7

    How to make error messages disappear quicker

  8. 8

    How to make reliase without error?

  9. 9

    How to suppress messages output by ESAPI library

  10. 10

    Suppress Makefile output when calling Make

  11. 11

    Suppress xcodebuild output or make less verbose

  12. 12

    Need to make awk suppress the output to stdout

  13. 13

    Need to make awk suppress the output to stdout

  14. 14

    How to make diff with redirection from other program output work in make

  15. 15

    How can I suppress these error messages?

  16. 16

    How to suppress tar error messages in when piping

  17. 17

    How to restart GNU make (without causing an error)

  18. 18

    How to make a transparent canvas without error?

  19. 19

    suppress error messages in protractor

  20. 20

    How can I suppress the output messages of TCL procedures?

  21. 21

    How to record the output of a bash script from terminal without suppressing the terminal output?

  22. 22

    how to make terminal prompt messages?

  23. 23

    How to make a variable accessible by other classes without subclassing?

  24. 24

    How do I make values depend on other values without DataKinds?

  25. 25

    How can I make an array without one number of the other array?

  26. 26

    How to make colspan work without affecting width of the other rows

  27. 27

    how to make UILabel dynamically without overlapping with other UILabel

  28. 28

    How to make a div fit to screen without the other divs being visible

  29. 29

    How to make Ipython output a list without line breaks after elements?

HotTag

Archive