diff --git a/Makefile b/Makefile index 6a280ea1b4..bc0056be1a 100644 --- a/Makefile +++ b/Makefile @@ -106,6 +106,16 @@ ifneq ($(findstring Win32,$(OS)),) LDFLAGS += -mwindows endif +ifneq ($(CXX_BUILD), 1) + ifneq ($(C89_BUILD),) + CFLAGS += -std=c89 -ansi -pedantic -Werror=pedantic -Wno-long-long + else ifeq ($(HAVE_C99), 1) + CFLAGS += $(C99_CFLAGS) + endif + + CFLAGS += -D_GNU_SOURCE +endif + DEF_FLAGS += -Wall $(INCLUDE_DIRS) -I. -Ideps -Ideps/stb CFLAGS += $(DEF_FLAGS) @@ -127,20 +137,6 @@ else LINK = $(CC) endif -ifneq ($(CXX_BUILD), 1) - ifneq ($(GNU90_BUILD), 1) - ifneq ($(findstring icc,$(CC)),) - CFLAGS += -std=c99 -D_GNU_SOURCE - else - CFLAGS += -std=gnu99 -D_GNU_SOURCE - endif - endif - - ifneq ($(C89_BUILD),) - CFLAGS += -std=c89 -ansi -pedantic -Werror=pedantic -Wno-long-long - endif -endif - ifeq ($(NOUNUSED), yes) CFLAGS += -Wno-unused-result CXXFLAGS += -Wno-unused-result diff --git a/qb/config.libs.sh b/qb/config.libs.sh index b26065ca0a..19b58bffa4 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -4,7 +4,13 @@ # Only needed when check_enabled ($2), check_platform, check_lib, check_pkgconf, # check_header, check_macro and check_switch are not used. -check_switch '' C99 -std=gnu99 "Cannot find C99 compatible compiler." +check_switch '' C99 -std=gnu99 '' + +if [ "$HAVE_C99" = 'no' ]; then + HAVE_C99='auto' + check_switch '' C99 -std=c99 'Cannot find a C99 compatible compiler.' +fi + check_switch cxx CXX11 -std=c++11 '' check_switch '' NOUNUSED -Wno-unused-result '' add_define MAKEFILE NOUNUSED "$HAVE_NOUNUSED"