summaryrefslogtreecommitdiff
path: root/tests/Makefile
blob: 3f89cba471f34e4c56f5613f67f539291bfbcf9d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
CC = gcc
CFLAGS	= 
INCLUDES = -I.
LDFLAGS = -L$(BUILDDIR)/cgreen/build-c/src -shared
LDLIBS = -lcgreen
UNITOBJ = $(BUILDDIR)/serialtest/unitobj
DEPDIR = $(BUILDDIR)/serialtest/unit.d
UNITTESTS = $(BUILDDIR)/serialtest/unittests
DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td
EXT = .so
UNAME := $(shell uname)
ifneq (, $(findstring MINGW, $(UNAME)))
	EXT = .dll
endif
ifneq (, $(findstring CYGWIN, $(UNAME)))
	EXT = .dll
endif
	
SRC = $(wildcard *.c)
TESTFILES = $(patsubst %.c, $(UNITTESTS)/%$(EXT), $(SRC))
$(shell mkdir -p $(DEPDIR) >/dev/null)

test: $(TESTFILES)
	@$(BUILDDIR)/cgreen/build-c/tools/cgreen-runner --color $(TESTFILES)

$(UNITTESTS)/%$(EXT): $(UNITOBJ)/%.o
	mkdir -p $(UNITTESTS)
	$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)

$(UNITOBJ)/%.o : %.c
$(UNITOBJ)/%.o: %.c $(DEPDIR)/%.d
	mkdir -p $(UNITOBJ)
	$(CC) $(CFLAGS) $(DEPFLAGS) -c $< -o $@
	mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d
	
$(DEPDIR)/%.d: ;
.PRECIOUS: $(DEPDIR)/%.d

-include $(patsubst %,$(DEPDIR)/%.d,$(basename $(SRC).c))