ifeq ($(OS),Windows_NT) ifeq ($(shell uname -s),) # not in a bash-like shell CLEANUP = del /F /Q MKDIR = mkdir else # in a bash-like shell, like msys CLEANUP = rm -f MKDIR = mkdir -p endif TARGET_EXTENSION=.exe else CLEANUP = rm -f MKDIR = mkdir -p TARGET_EXTENSION=out endif .PHONY: runners .PHONY: clean .PHONY: test PATHU = unity/src/ PATHS = src/ PATHT = test/ PATHTR = test/runners/ PATHL = lib/ PATHB = build/ PATHD = build/depends/ PATHO = build/objs/ PATHR = build/results/ BUILD_PATHS = $(PATHB) $(PATHD) $(PATHO) $(PATHR) $(PATHL) RUNNERS = $(patsubst $(PATHT)%.c,$(PATHTR)%_Runner.c, $(wildcard $(PATHT)*.c)) runners: $(RUNNERS) test SRCTR = $(wildcard $(PATHTR)*.c) COMPILE = gcc -c LINK = gcc DEPEND = gcc -MM -MG -MF CFLAGS = -I. -I$(PATHU) -I$(PATHS) -I$(PATHL) -DTEST CFLAGS += -std=c99 CFLAGS += -Wall CFLAGS += -Wextra CFLAGS += -Wpointer-arith CFLAGS += -Wcast-align # CFLAGS += -Wwrite-strings CFLAGS += -Wswitch-default CFLAGS += -Wunreachable-code CFLAGS += -Winit-self CFLAGS += -Wmissing-field-initializers CFLAGS += -Wno-unknown-pragmas CFLAGS += -Wstrict-prototypes CFLAGS += -Wundef CFLAGS += -Wold-style-definition RESULTS = $(patsubst $(PATHTR)test_%_Runner.c,$(PATHR)test_%.txt,$(SRCTR)) PASSED = `grep -s PASS $(PATHR)*.txt` FAIL = `grep -s FAIL $(PATHR)*.txt` IGNORE = `grep -s IGNORE $(PATHR)*.txt` test: $(BUILD_PATHS) $(RESULTS) @echo "===============UNIT TEST RESULTS===============\n" @echo "---------------IGNORES---------------" @echo "$(IGNORE)" @echo "---------------FAILURES---------------" @echo "$(FAIL)" @echo "---------------PASSED---------------" @echo "$(PASSED)" @echo "\nDONE" $(PATHR)%.txt: $(PATHB)%.$(TARGET_EXTENSION) -./$< > $@ 2>&1 $(PATHB)test_%.$(TARGET_EXTENSION): $(PATHO)test_%.o $(PATHO)test_%_Runner.o $(PATHO)%.o $(PATHU)unity.o #$(PATHD)test_%.d $(LINK) -o $@ $^ $(PATHO)%.o: $(PATHTR)%.c $(COMPILE) $(CFLAGS) $< -o $@ $(PATHO)%.o:: $(PATHT)%.c $(COMPILE) $(CFLAGS) $< -o $@ $(PATHO)%.o:: $(PATHS)%.c $(COMPILE) $(CFLAGS) $< -o $@ $(PATHO)%.o:: $(PATHL)%.c $(COMPILE) $(CFLAGS) $< -o $@ $(PATHO)%.o:: $(PATHU)%.c $(PATHU)%.h $(COMPILE) $(CFLAGS) $< -o $@ $(PATHD)%.d:: $(PATHT)%.c $(DEPEND) $@ $< $(PATHTR)%.c: ruby unity/auto/generate_test_runner.rb $(patsubst $(PATHTR)%_Runner.c,$(PATHT)%.c, $@) $@ $(PATHB): $(MKDIR) $(PATHB) $(PATHD): $(MKDIR) $(PATHD) $(PATHO): $(MKDIR) $(PATHO) $(PATHR): $(MKDIR) $(PATHR) clean: $(CLEANUP) $(PATHO)*.o $(CLEANUP) $(PATHB)*.$(TARGET_EXTENSION) $(CLEANUP) $(PATHR)*.txt .PRECIOUS: $(PATHB)test_%.$(TARGET_EXTENSION) .PRECIOUS: $(PATHD)%.d .PRECIOUS: $(PATHO)%.o .PRECIOUS: $(PATHR)%.txt