diff mbox series

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

Message ID 20200311023722.97494-1-aik@ozlabs.ru
State New
Headers show
Series make: Define default rule for .c when V=1 or V=2 | expand

Commit Message

Alexey Kardashevskiy March 11, 2020, 2:37 a.m. UTC
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>
---

Or there is a better way of doing this?

I find it very annoying to work with ./lib/xxxx as we chdir a lot
and gcc does not have a flag to print full file names.


---
 make.rules | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

Alexey Kardashevskiy March 30, 2020, 11:28 p.m. UTC | #1
On 11/03/2020 13:37, Alexey Kardashevskiy wrote:
> 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>
> ---
> 
> Or there is a better way of doing this?
> 
> I find it very annoying to work with ./lib/xxxx as we chdir a lot
> and gcc does not have a flag to print full file names.
> 

Ok, I'll push it out when qemu 5.1 starts.


> 
> ---
>  make.rules | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/make.rules b/make.rules
> index acbc8ab8ff5c..3dfbb5b136c2 100644
> --- a/make.rules
> +++ b/make.rules
> @@ -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
> -
>
diff mbox series

Patch

diff --git a/make.rules b/make.rules
index acbc8ab8ff5c..3dfbb5b136c2 100644
--- a/make.rules
+++ b/make.rules
@@ -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
-