[fsverity-utils,PATCHv2] Makefile: improve the cc-option compatibility
diff mbox series

Message ID 20200803030736.6364-1-po-hsu.lin@canonical.com
State Accepted
Headers show
Series
  • [fsverity-utils,PATCHv2] Makefile: improve the cc-option compatibility
Related show

Commit Message

Po-Hsu Lin Aug. 3, 2020, 3:07 a.m. UTC
The build on Ubuntu Xenial with GCC 5.4.0 will fail with:
    cc: error: unrecognized command line option ‘-Wimplicit-fallthrough’

This unsupported flag is not skipped as expected.

It is because of the /bin/sh shell on Ubuntu, DASH, which does not
support this &> redirection. Use 2>&1 to solve this problem.

Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Eric Biggers Aug. 3, 2020, 4:34 p.m. UTC | #1
On Mon, Aug 03, 2020 at 11:07:36AM +0800, Po-Hsu Lin wrote:
> The build on Ubuntu Xenial with GCC 5.4.0 will fail with:
>     cc: error: unrecognized command line option ‘-Wimplicit-fallthrough’
> 
> This unsupported flag is not skipped as expected.
> 
> It is because of the /bin/sh shell on Ubuntu, DASH, which does not
> support this &> redirection. Use 2>&1 to solve this problem.
> 
> Signed-off-by: Po-Hsu Lin <po-hsu.lin@canonical.com>
> ---
>  Makefile | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/Makefile b/Makefile
> index e0a3938..ec23ed6 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -32,7 +32,7 @@
>  #
>  ##############################################################################
>  
> -cc-option = $(shell if $(CC) $(1) -c -x c /dev/null -o /dev/null &>/dev/null; \
> +cc-option = $(shell if $(CC) $(1) -c -x c /dev/null -o /dev/null > /dev/null 2>&1; \
>  	      then echo $(1); fi)
>  
>  CFLAGS ?= -O2 -Wall -Wundef					\
> -- 
> 2.17.1
> 

Thanks, applied.

- Eric

Patch
diff mbox series

diff --git a/Makefile b/Makefile
index e0a3938..ec23ed6 100644
--- a/Makefile
+++ b/Makefile
@@ -32,7 +32,7 @@ 
 #
 ##############################################################################
 
-cc-option = $(shell if $(CC) $(1) -c -x c /dev/null -o /dev/null &>/dev/null; \
+cc-option = $(shell if $(CC) $(1) -c -x c /dev/null -o /dev/null > /dev/null 2>&1; \
 	      then echo $(1); fi)
 
 CFLAGS ?= -O2 -Wall -Wundef					\