From caea069bcf9023bc12901b87a347b4d613e9ac73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Kijewski?= Date: Wed, 12 Feb 2014 17:32:34 +0100 Subject: [PATCH] Do not mandate input language An application might want to use C11 features. The user would assume that setting `CFLAGS=-std=gnu11` in the Makefile would work. It does not since the board's Makefile.include shadows the `-std` flag. This patch removes the `-std=gnu99` from the various Makefile.includes, and sets the flag in the common Makefile.include of RIOT instead. If an `-std` flag was provided by an earlier Makefile (the application, the board, or the CPU [whilst only the former one should]), then no additional flag is set. It is first tested if the supplied compiler understands `-std=gnu99`, then `-std=c99`. --- Makefile.include | 13 +++++++++++++ boards/chronos/Makefile.include | 2 +- boards/mbed_lpc1768/Makefile.include | 2 +- boards/msb-430-common/Makefile.include | 2 +- boards/msba2-common/Makefile.include | 2 +- boards/native/Makefile.include | 2 +- boards/redbee-econotag/Makefile.include | 2 +- boards/telosb/Makefile.include | 2 +- boards/wsn430-common/Makefile.include | 2 +- 9 files changed, 21 insertions(+), 8 deletions(-) diff --git a/Makefile.include b/Makefile.include index 3209ca8c80..acc1aea627 100644 --- a/Makefile.include +++ b/Makefile.include @@ -46,6 +46,19 @@ include $(RIOTBOARD)/$(BOARD)/Makefile.include include $(RIOTCPU)/$(CPU)/Makefile.include include $(RIOTBASE)/Makefile.dep +# Test if the input language was specified externally. +# Otherwise test if the compiler unterstands the "-std=gnu99" flag, and use it if so. +# Otherwise test if the compiler unterstands the "-std=c99" flag, and use it if so. +ifeq ($(filter -std=%,$(CFLAGS)),) +ifeq ($(shell $(CC) -std=gnu99 -E - 2>/dev/null >/dev/null /dev/null >/dev/null