From 747b08bee0cc1e481b9bd08acb881bc5b9ab18d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=BE=89?= Date: Tue, 4 Jan 2022 20:05:00 +0800 Subject: [PATCH] Fix C11_ATOMIC detection on GNU Make 4.3 (#10033) Older version of GNU Make (<4.3) required quoting of number signs (#) to avoid them being treated as a comment. Newer versions will treat this quote as a literal. This issue and a proposed solution is discussed here: https://lists.gnu.org/archive/html/info-gnu/2020-01/msg00004.html Co-authored-by: Yossi Gottlieb --- src/Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Makefile b/src/Makefile index e9e93a96a..a6e4b2098 100644 --- a/src/Makefile +++ b/src/Makefile @@ -34,8 +34,10 @@ endif WARN=-Wall -W -Wno-missing-field-initializers OPT=$(OPTIMIZATION) -# Detect if the compiler supports C11 _Atomic -C11_ATOMIC := $(shell sh -c 'echo "\#include " > foo.c; \ +# Detect if the compiler supports C11 _Atomic. +# NUMBER_SIGN_CHAR is a workaround to support both GNU Make 4.3 and older versions. +NUMBER_SIGN_CHAR := \# +C11_ATOMIC := $(shell sh -c 'echo "$(NUMBER_SIGN_CHAR)include " > foo.c; \ $(CC) -std=c11 -c foo.c -o foo.o > /dev/null 2>&1; \ if [ -f foo.o ]; then echo "yes"; rm foo.o; fi; rm foo.c') ifeq ($(C11_ATOMIC),yes)