Makefile 2.2 KB

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