Makefile 2.1 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 9 10 11 12 13 14
SRC = ../src/unity_fixture.c \
      ../../../src/unity.c   \
      unity_fixture_Test.c   \
      unity_fixture_TestRunner.c \
      main/AllTests.c

INC_DIR = -I../src -I../../../src/
15
BUILD_DIR = ../build
16
TARGET = ../build/fixture_tests.exe
17

18 19
all: default noStdlibMalloc 32bits

20 21
default: $(BUILD_DIR)
	$(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -D UNITY_SUPPORT_64
22 23 24
	@ echo "default build"
	./$(TARGET)

25
32bits: $(BUILD_DIR)
26 27
	$(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -m32
	@ echo "32bits build"
28
	./$(TARGET)
29

30
noStdlibMalloc: $(BUILD_DIR)
31 32 33 34
	$(CC) $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -D UNITY_EXCLUDE_STDLIB_MALLOC
	@ echo "build with noStdlibMalloc"
	./$(TARGET)

35 36 37 38 39
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)
40

41 42
$(BUILD_DIR):
	mkdir -p $(BUILD_DIR)
43 44

clean:
45 46
	rm -f $(TARGET) $(BUILD_DIR)/*.gc*

47
cov: $(BUILD_DIR)
48 49 50 51 52 53 54
	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
55 56 57 58

# These extended flags DO get included before any target build runs
CFLAGS += -Wbad-function-cast
CFLAGS += -Wcast-qual
59
CFLAGS += -Wconversion
60 61 62 63 64 65 66 67 68
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
69
CFLAGS += -Wno-error=undef  # Warning only, this should not stop the build
J
jsalling 已提交
70
CFLAGS += -Wunreachable-code
71 72
CFLAGS += -Wunused
CFLAGS += -fstrict-aliasing