• 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
7CFLAGS += $(DEBUG)
8DEFINES = -D UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar
9ifeq ($(OS),Windows_NT)
10  DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar(int)
11else
12  DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\)
13endif
14SRC = ../src/unity_memory.c \
15      ../../../src/unity.c   \
16      unity_memory_Test.c   \
17      unity_memory_TestRunner.c \
18      unity_output_Spy.c     \
19
20INC_DIR = -I../src -I../../../src/
21BUILD_DIR = ../build
22TARGET = ../build/memory_tests.exe
23
24all: default noStdlibMalloc 32bits
25
26default: $(BUILD_DIR)
27	$(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -D UNITY_SUPPORT_64
28	@ echo "default build"
29	./$(TARGET)
30
3132bits: $(BUILD_DIR)
32	$(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -m32
33	@ echo "32bits build"
34	./$(TARGET)
35
36noStdlibMalloc: $(BUILD_DIR)
37	$(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -D UNITY_EXCLUDE_STDLIB_MALLOC
38	@ echo "build with noStdlibMalloc"
39	./$(TARGET)
40
41C89: CFLAGS += -D UNITY_EXCLUDE_STDINT_H # C89 did not have type 'long long', <stdint.h>
42C89: $(BUILD_DIR)
43	$(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -std=c89 && ./$(TARGET)
44	$(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -D UNITY_EXCLUDE_STDLIB_MALLOC -std=c89
45	./$(TARGET)
46
47$(BUILD_DIR):
48	mkdir -p $(BUILD_DIR)
49
50clean:
51	rm -f $(TARGET) $(BUILD_DIR)/*.gc*
52
53cov: $(BUILD_DIR)
54	cd $(BUILD_DIR) && \
55	$(CC) $(DEFINES) $(foreach i, $(SRC), ../test/$(i)) $(INC_DIR) -o $(TARGET) -fprofile-arcs -ftest-coverage
56	rm -f $(BUILD_DIR)/*.gcda
57	./$(TARGET) > /dev/null ; ./$(TARGET) -v > /dev/null
58	cd $(BUILD_DIR) && \
59	gcov unity_memory.c | head -3
60	grep '###' $(BUILD_DIR)/unity_memory.c.gcov -C2 || true # Show uncovered lines
61
62# These extended flags DO get included before any target build runs
63CFLAGS += -Wbad-function-cast
64CFLAGS += -Wcast-qual
65CFLAGS += -Wconversion
66CFLAGS += -Wformat=2
67CFLAGS += -Wmissing-prototypes
68CFLAGS += -Wold-style-definition
69CFLAGS += -Wpointer-arith
70CFLAGS += -Wshadow
71CFLAGS += -Wstrict-overflow=5
72CFLAGS += -Wstrict-prototypes
73CFLAGS += -Wswitch-default
74CFLAGS += -Wundef
75CFLAGS += -Wno-error=undef  # Warning only, this should not stop the build
76CFLAGS += -Wunreachable-code
77CFLAGS += -Wunused
78CFLAGS += -fstrict-aliasing
79