Makefile 2.2 KB
Newer Older
1
CC = gcc
2 3 4
ifeq ($(shell uname -s), Darwin)
CC = clang
endif
5
#DEBUG = -O0 -g
6 7
CFLAGS += -std=c99
CFLAGS += -pedantic
8 9 10 11
CFLAGS += -Wall
CFLAGS += -Wextra
CFLAGS += -Werror
CFLAGS += $(DEBUG)
12 13 14 15 16 17 18 19 20
DEFINES = -D UNITY_OUTPUT_CHAR=UnityOutputCharSpy_OutputChar
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/
21
BUILD_DIR = ../build
22
TARGET = ../build/fixture_tests.exe
23

24 25
all: default noStdlibMalloc 32bits

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

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

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

41 42 43 44 45
clang89: ../build/
	clang $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -m32 -std=c89 -Wno-comment
	clang $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -m32 \
		-D UNITY_EXCLUDE_STDLIB_MALLOC -std=c89 -Wno-comment ; ./$(TARGET)

46
clangEverything:
47
	clang $(CFLAGS) $(DEFINES) $(SRC) $(INC_DIR) -o $(TARGET) -Weverything
48

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

clean:
53 54 55 56 57 58 59 60 61 62
	rm -f $(TARGET) $(BUILD_DIR)/*.gc*

coverage: $(BUILD_DIR)
	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
63 64 65 66

# These extended flags DO get included before any target build runs
CFLAGS += -Wbad-function-cast
CFLAGS += -Wcast-qual
67
CFLAGS += -Wconversion
68 69 70 71 72 73 74 75 76
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
77
CFLAGS += -Wno-error=undef  # Warning only, this should not stop the build
78 79
CFLAGS += -Wunused
CFLAGS += -fstrict-aliasing