#!/bin/sh set -eu src="${TMPDIR-/tmp}/mcpu-cpp-predef-redef-$$.c" out="${TMPDIR-/tmp}/mcpu-cpp-predef-redef-$$.out" err="${TMPDIR-/tmp}/mcpu-cpp-predef-redef-$$.err" trap 'rm -f "$src" "$out" "$err"' EXIT HUP INT TERM cat > "$src" <<'EOT' before = __LINE__; #define __LINE__ 77 after = __LINE__; #undef __LINE__ literal = __LINE__; "__FILE__ __LINE__ __MCPU_CPP_VERSION__" EOT "$MCPU_CPP" --no-config "$src" -o "$out" 2>"$err" grep '^before = 1;$' "$out" >/dev/null grep '^literal = __LINE__;$' "$out" >/dev/null grep '^after = 77;$' "$out" >/dev/null grep '^"__FILE__ __LINE__ __MCPU_CPP_VERSION__"$' "$out" >/dev/null grep "warning: macro '__LINE__' redefined" "$err" >/dev/null