diff mbox series

[kvm-unit-tests] Makefile: Add -MP to $(autodepend-flags)

Message ID 402218a490f286c039d4072be7f7d7b3f3216c49.camel@infradead.org (mailing list archive)
State New, archived
Headers show
Series [kvm-unit-tests] Makefile: Add -MP to $(autodepend-flags) | expand

Commit Message

David Woodhouse Sept. 13, 2023, 7:29 a.m. UTC
From: David Woodhouse <dwmw@amazon.co.uk>

The -MP flag instructs the compiler to emit phony targets for each header
file that it lists as a dependency, so that if a header file is *absent*
from the next build (because it's been deleted and the C file no longer
includes it), the build doesn't gratuitously fail when make thinks it's
needed and can't work out how to create it.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Thomas Huth Sept. 18, 2023, 5:42 p.m. UTC | #1
On 13/09/2023 09.29, David Woodhouse wrote:
> From: David Woodhouse <dwmw@amazon.co.uk>
> 
> The -MP flag instructs the compiler to emit phony targets for each header
> file that it lists as a dependency, so that if a header file is *absent*
> from the next build (because it's been deleted and the C file no longer
> includes it), the build doesn't gratuitously fail when make thinks it's
> needed and can't work out how to create it.
> 
> Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
> ---
>   Makefile | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index e7998a4..101c028 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -90,7 +90,7 @@ CFLAGS += $(wmissing_parameter_type)
>   CFLAGS += $(wold_style_declaration)
>   CFLAGS += -Woverride-init -Wmissing-prototypes -Wstrict-prototypes
>   
> -autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d
> +autodepend-flags = -MMD -MP -MF $(dir $*).$(notdir $*).d
>   
>   LDFLAGS += -nostdlib $(no_pie) -z noexecstack
>   

Tested-by: Thomas Huth <thuth@redhat.com>

Thanks, I've pushed it to the repository now!
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index e7998a4..101c028 100644
--- a/Makefile
+++ b/Makefile
@@ -90,7 +90,7 @@  CFLAGS += $(wmissing_parameter_type)
 CFLAGS += $(wold_style_declaration)
 CFLAGS += -Woverride-init -Wmissing-prototypes -Wstrict-prototypes
 
-autodepend-flags = -MMD -MF $(dir $*).$(notdir $*).d
+autodepend-flags = -MMD -MP -MF $(dir $*).$(notdir $*).d
 
 LDFLAGS += -nostdlib $(no_pie) -z noexecstack