Makefile 2.3 KB

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