Make script to silence output unless errors and always recompile

From Tech Wiki
Jump to navigation Jump to search

Here is the script to silence output when running make unless their are errors, it will also always recompile too:

#!/bin/bash

# Ensure no targets end with .c
args=""
invalid_args=0
for arg; do
    case "$arg" in
        (*.c) arg=${arg%.c}; invalid_args=1;;
    esac
    args="$args $arg"
done
if [ $invalid_args -eq 1 ]; then
    echo "Did you mean 'make$args'?"
    exit 1
fi

# Run make
/usr/bin/make -B -s $*

Copy the above into the below file:

/usr/local/bin/make

Then run:

sudo chmod +x /usr/local/bin/make