make: Define default rule for .c when V=1 or V=2

The default .o:.c rule passes a short file name to gcc to when doing
"make -C <dir>", we do this a lot for all the libraries.
The file names printed in gcc errors are relative to <dir> and this
prevents vim from navigating through errors.

This passes the full file name to gcc to make it print errors with
absolute path so vim can navigate through errors nicely.

This makes it optional when V=1 or V=2 is passed.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
This commit is contained in:
Alexey Kardashevskiy 2020-03-11 13:37:22 +11:00
parent 8e012d6fdd
commit 283d88c46c
1 changed files with 4 additions and 1 deletions

View File

@ -49,6 +49,10 @@ ifeq ($(V),0)
Q := @
MAKEFLAGS += --silent
MAKE += -s
else
CURDIR=$(shell pwd)
%.o: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $(CURDIR)/$<
endif
ifeq ($(V),1)
@ -78,4 +82,3 @@ CFLAGS ?= -g -O2 -fno-builtin -ffreestanding -nostdinc -msoft-float \
-fno-stack-protector -fno-asynchronous-unwind-tables $(WARNFLAGS)
export CC AS LD CLEAN OBJCOPY OBJDUMP STRIP AR RANLIB CFLAGS