#!/usr/bin/awk -f BEGIN { max_context = 2; context[""] = 0; } function print_context() { for (i = 0; i < max_context; i++) if (context[i]) print context[i]; } function print_error() { print; delete context; next; } /: ((internal compiler |Internal )?error|sorry, unimplemented):| needs unknown symbol | modversion changed |: undefined reference / { print_error(); } # we might not know what caused this error, better print some context /^make.*: \*\*\*/ { print_context(); print_error(); } { for (i = 0; i < max_context - 1; i++) context[i] = context[i + 1]; context[max_context - 1] = $0; }