• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1CC = gcc
2ifeq ($(shell uname -s), Darwin)
3CC = clang
4endif
5#DEBUG = -O0 -g
6CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror -DUNITY_FIXTURE_NO_EXTRAS
7CFLAGS += $(DEBUG)
8SRC = ../src/unity_fixture.c \
9      ../../../src/unity.c   \
10      unity_fixture_Test.c   \
11      unity_fixture_TestRunner.c \
12      main/AllTests.c
13
14INC_DIR = -I../src -I../../../src/
15BUILD_DIR = ../build
16TARGET = ../build/fixture_tests.exe
17
18all: default noStdlibMalloc 32bits
19
20default: $(BUILD_DIR)
21	$(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -D UNITY_SUPPORT_64
22	@ echo "default build"
23	./$(TARGET)
24
2532bits: $(BUILD_DIR)
26	$(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -m32
27	@ echo "32bits build"
28	./$(TARGET)
29
30noStdlibMalloc: $(BUILD_DIR)
31	$(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -D UNITY_EXCLUDE_STDLIB_MALLOC
32	@ echo "build with noStdlibMalloc"
33	./$(TARGET)
34
35C89: CFLAGS += -D UNITY_EXCLUDE_STDINT_H # C89 did not have type 'long long', <stdint.h>
36C89: $(BUILD_DIR)
37	$(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -std=c89 && ./$(TARGET)
38	$(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -D UNITY_EXCLUDE_STDLIB_MALLOC -std=c89
39	./$(TARGET)
40
41$(BUILD_DIR):
42	mkdir -p $(BUILD_DIR)
43
44clean:
45	rm -f $(TARGET) $(BUILD_DIR)/*.gc*
46
47cov: $(BUILD_DIR)
48	cd $(BUILD_DIR) && \
49	$(CC) $(DEFINES) $(foreach i, $(SRC), ../test/$(i)) $(INC_DIR) -o $(TARGET) -fprofile-arcs -ftest-coverage
50	rm -f $(BUILD_DIR)/*.gcda
51	./$(TARGET) > /dev/null ; ./$(TARGET) -v > /dev/null
52	cd $(BUILD_DIR) && \
53	gcov unity_fixture.c | head -3
54	grep '###' $(BUILD_DIR)/unity_fixture.c.gcov -C2 || true # Show uncovered lines
55
56# These extended flags DO get included before any target build runs
57CFLAGS += -Wbad-function-cast
58CFLAGS += -Wcast-qual
59CFLAGS += -Wconversion
60CFLAGS += -Wformat=2
61CFLAGS += -Wmissing-prototypes
62CFLAGS += -Wold-style-definition
63CFLAGS += -Wpointer-arith
64CFLAGS += -Wshadow
65CFLAGS += -Wstrict-overflow=5
66CFLAGS += -Wstrict-prototypes
67CFLAGS += -Wswitch-default
68CFLAGS += -Wundef
69CFLAGS += -Wno-error=undef  # Warning only, this should not stop the build
70CFLAGS += -Wunreachable-code
71CFLAGS += -Wunused
72CFLAGS += -fstrict-aliasing
73