From a0cb138533711c51edf7d82f57c6666b746d3241 Mon Sep 17 00:00:00 2001 From: jsalling Date: Thu, 29 Dec 2016 20:46:06 -0600 Subject: [PATCH] Organize Makefile so clang works on all platforms, warnings are set Delete warning flags included by -Wall, -Wextra, or produce false postives --- test/Makefile | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/test/Makefile b/test/Makefile index 6c1120f..c24d58a 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,18 +1,20 @@ CC = gcc ifeq ($(shell uname -s), Darwin) CC = clang -CFLAGS += -std=c99 -pedantic -Wall -Weverything -Werror -CFLAGS += -Wno-unknown-warning-option -Wno-switch-enum -CFLAGS += -Wno-padded -Wno-double-promotion -Wno-missing-noreturn -CFLAGS += -Wno-missing-prototypes endif -ifeq ($(shell uname -s), Linux) -CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror +ifeq ($(findstring clang, $(CC)), clang) +E = -Weverything +CFLAGS += $E -Wno-unknown-warning-option -Wno-missing-prototypes +CFLAGS += -Wno-unused-macros -Wno-padded -Wno-missing-noreturn endif +CFLAGS += -std=c99 -pedantic -Wall -Wextra -Wconversion -Werror +CFLAGS += -Wno-switch-enum -Wno-double-promotion +CFLAGS += -Wbad-function-cast -Wcast-qual -Wold-style-definition -Wshadow -Wstrict-overflow \ + -Wstrict-prototypes -Wswitch-default -Wundef #DEBUG = -O0 -g CFLAGS += $(DEBUG) DEFINES = -D UNITY_OUTPUT_CHAR=putcharSpy -DEFINES += -D UNITY_SUPPORT_64 -D UNITY_INCLUDE_DOUBLE -D UNITY_NO_WEAK +DEFINES += -D UNITY_SUPPORT_64 -D UNITY_INCLUDE_DOUBLE SRC = ../src/unity.c tests/testunity.c build/testunityRunner.c INC_DIR = -I ../src COV_FLAGS = -fprofile-arcs -ftest-coverage -I ../../src @@ -23,6 +25,7 @@ TARGET = build/testunity-cov.exe # For verbose output of all the tests, run 'make test'. default: coverage .PHONY: default coverage test clean +coverage: DEFINES += -D UNITY_NO_WEAK coverage: $(BUILD_DIR)/testunityRunner.c cd $(BUILD_DIR) && \ $(CC) $(CFLAGS) $(DEFINES) $(foreach i,$(SRC), ../$i) $(COV_FLAGS) -o ../$(TARGET) @@ -32,9 +35,6 @@ coverage: $(BUILD_DIR)/testunityRunner.c gcov unity.c | head -3 grep '###' $(BUILD_DIR)/unity.c.gcov -C2 || true -test: CFLAGS += -Wbad-function-cast -Wcast-qual -Wconversion -Wformat=2 -Wold-style-definition \ --Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-overflow=5 -Wstrict-prototypes \ --Wswitch-default -Wundef -Wunreachable-code -Wunused -fstrict-aliasing test: $(BUILD_DIR)/testunityRunner.c $(CC) $(CFLAGS) $(DEFINES) $(INC_DIR) $(SRC) -o $(TARGET) ./$(TARGET) @@ -50,11 +50,11 @@ $(BUILD_DIR)/testunityRunner.c: tests/testunity.c | $(BUILD_DIR) AWK_SCRIPT=\ '/^void test/{ declarations[d++]=$$0; gsub(/\(?void\)? ?/,""); tests[t++]=$$0; line[u++]=NR } \ - END{ print "\#include \"unity.h\" /* Autogenerated by awk in Makefile */" ; \ - for (i=0; i