Makefile 2.4 KB
Newer Older
1
CC = gcc
2 3 4
ifeq ($(shell uname -s), Darwin)
CC = clang
endif
5
#DEBUG = -O0 -g
6
CFLAGS += -std=c99 -pedantic -Wall -Wextra -Werror
7
CFLAGS += $(DEBUG)
8
DEFINES = -D UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar
9 10 11 12 13
ifeq ($(OS),Windows_NT)
  DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar(int)
else
  DEFINES += -D UNITY_OUTPUT_CHAR_HEADER_DECLARATION=UnityOutputCharSpy_OutputChar\(int\)
endif
14 15 16 17 18 19 20 21
SRC = ../src/unity_fixture.c \
      ../../../src/unity.c   \
      unity_fixture_Test.c   \
      unity_fixture_TestRunner.c \
      unity_output_Spy.c     \
      main/AllTests.c

INC_DIR = -I../src -I../../../src/
22
BUILD_DIR = ../build
23
TARGET = ../build/fixture_tests.exe
24

25 26
all: default noStdlibMalloc 32bits

27 28
default: $(BUILD_DIR)
	$(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -D UNITY_SUPPORT_64
29 30 31
	@ echo "default build"
	./$(TARGET)

32
32bits: $(BUILD_DIR)
33 34
	$(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -m32
	@ echo "32bits build"
35
	./$(TARGET)
36

37
noStdlibMalloc: $(BUILD_DIR)
38 39 40 41
	$(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -D UNITY_EXCLUDE_STDLIB_MALLOC
	@ echo "build with noStdlibMalloc"
	./$(TARGET)

42 43 44 45 46
C89: CFLAGS += -D UNITY_EXCLUDE_STDINT_H # C89 did not have type 'long long', <stdint.h>
C89: $(BUILD_DIR)
	$(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -std=c89 && ./$(TARGET)
	$(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -D UNITY_EXCLUDE_STDLIB_MALLOC -std=c89
	./$(TARGET)
47

48 49
$(BUILD_DIR):
	mkdir -p $(BUILD_DIR)
50 51

clean:
52 53
	rm -f $(TARGET) $(BUILD_DIR)/*.gc*

54
cov: $(BUILD_DIR)
55 56 57 58 59 60 61
	cd $(BUILD_DIR) && \
	$(CC) $(DEFINES) $(foreach i, $(SRC), ../test/$(i)) $(INC_DIR) -o $(TARGET) -fprofile-arcs -ftest-coverage
	rm -f $(BUILD_DIR)/*.gcda
	./$(TARGET) > /dev/null ; ./$(TARGET) -v > /dev/null
	cd $(BUILD_DIR) && \
	gcov unity_fixture.c | head -3
	grep '###' $(BUILD_DIR)/unity_fixture.c.gcov -C2 || true # Show uncovered lines
62 63 64 65

# These extended flags DO get included before any target build runs
CFLAGS += -Wbad-function-cast
CFLAGS += -Wcast-qual
66
CFLAGS += -Wconversion
67 68 69 70 71 72 73 74 75
CFLAGS += -Wformat=2
CFLAGS += -Wmissing-prototypes
CFLAGS += -Wold-style-definition
CFLAGS += -Wpointer-arith
CFLAGS += -Wshadow
CFLAGS += -Wstrict-overflow=5
CFLAGS += -Wstrict-prototypes
CFLAGS += -Wswitch-default
CFLAGS += -Wundef
76
CFLAGS += -Wno-error=undef  # Warning only, this should not stop the build
J
jsalling 已提交
77
CFLAGS += -Wunreachable-code
78 79
CFLAGS += -Wunused
CFLAGS += -fstrict-aliasing