[PATCH] Makefile: Use -std=gnu99 if -std=gnu11 is not supported.

Vinson Lee <[email protected]> Mon, 8 Feb 2016 21:24:41 +0100
Newsgroups org.kernel.vger.trinity
Message-ID <[email protected]>
-std=gnu11 is not available with gcc < 4.7.

Signed-off-by: Vinson Lee <[email protected]>
---
 Makefile |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index a47e248..9fbdb94 100644
--- a/Makefile
+++ b/Makefile
@@ -10,7 +10,9 @@ endif
 CC := $(CROSS_COMPILE)$(CC)
 LD := $(CROSS_COMPILE)$(LD)
 
-CFLAGS += -Wall -Wextra -g -O2 -I. -Iinclude/ -Wimplicit -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D__linux__ -std=gnu11
+CFLAGS += -Wall -Wextra -g -O2 -I. -Iinclude/ -Wimplicit -D_FORTIFY_SOURCE=2 -D_GNU_SOURCE -D__linux__
+
+CFLAGS += $(shell if $(CC) -std=gnu11 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-std=gnu11"; else echo "-std=gnu99"; fi)
 
 # Only enabled during development, and on gcc 4.9+
 CPP_MAJOR := $(shell $(CPP) -dumpversion 2>&1 | cut -d'.' -f1)
-- 
1.7.9.5