makefile 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. # ==========================================
  2. # Unity Project - A Test Framework for C
  3. # Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
  4. # [Released under MIT License. Please refer to license.txt for details]
  5. # ==========================================
  6. #We try to detect the OS we are running on, and adjust commands as needed
  7. ifeq ($(OS),Windows_NT)
  8. ifeq ($(shell uname -s),) # not in a bash-like shell
  9. CLEANUP = del /F /Q
  10. MKDIR = mkdir
  11. else # in a bash-like shell, like msys
  12. CLEANUP = rm -f
  13. MKDIR = mkdir -p
  14. endif
  15. TARGET_EXTENSION=.exe
  16. else
  17. CLEANUP = rm -f
  18. MKDIR = mkdir -p
  19. TARGET_EXTENSION=.out
  20. endif
  21. C_COMPILER=gcc
  22. ifeq ($(shell uname -s), Darwin)
  23. C_COMPILER=clang
  24. endif
  25. UNITY_ROOT=../..
  26. CFLAGS=-std=c89
  27. CFLAGS += -Wall
  28. CFLAGS += -Wextra
  29. CFLAGS += -Wpointer-arith
  30. CFLAGS += -Wcast-align
  31. CFLAGS += -Wwrite-strings
  32. CFLAGS += -Wswitch-default
  33. CFLAGS += -Wunreachable-code
  34. CFLAGS += -Winit-self
  35. CFLAGS += -Wmissing-field-initializers
  36. CFLAGS += -Wno-unknown-pragmas
  37. CFLAGS += -Wstrict-prototypes
  38. CFLAGS += -Wundef
  39. CFLAGS += -Wold-style-definition
  40. TARGET_BASE1=test1
  41. TARGET_BASE2=test2
  42. TARGET1 = $(TARGET_BASE1)$(TARGET_EXTENSION)
  43. TARGET2 = $(TARGET_BASE2)$(TARGET_EXTENSION)
  44. SRC_FILES1=$(UNITY_ROOT)/src/unity.c src/ProductionCode.c test/TestProductionCode.c test/test_runners/TestProductionCode_Runner.c
  45. SRC_FILES2=$(UNITY_ROOT)/src/unity.c src/ProductionCode2.c test/TestProductionCode2.c test/test_runners/TestProductionCode2_Runner.c
  46. INC_DIRS=-Isrc -I$(UNITY_ROOT)/src
  47. SYMBOLS=
  48. all: clean default
  49. default: $(SRC_FILES1) $(SRC_FILES2)
  50. $(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES1) -o $(TARGET1)
  51. $(C_COMPILER) $(CFLAGS) $(INC_DIRS) $(SYMBOLS) $(SRC_FILES2) -o $(TARGET2)
  52. - ./$(TARGET1)
  53. ./$(TARGET2)
  54. test/test_runners/TestProductionCode_Runner.c: test/TestProductionCode.c
  55. ruby $(UNITY_ROOT)/auto/generate_test_runner.rb test/TestProductionCode.c test/test_runners/TestProductionCode_Runner.c
  56. test/test_runners/TestProductionCode2_Runner.c: test/TestProductionCode2.c
  57. ruby $(UNITY_ROOT)/auto/generate_test_runner.rb test/TestProductionCode2.c test/test_runners/TestProductionCode2_Runner.c
  58. clean:
  59. $(CLEANUP) $(TARGET1) $(TARGET2)
  60. ci: CFLAGS += -Werror
  61. ci: default