2016-02-13 23:20:14 +01:00
|
|
|
CC = gcc
|
|
|
|
CFLAGS =
|
|
|
|
INCLUDES = -I.
|
2016-02-14 00:58:26 +01:00
|
|
|
LDFLAGS = -L$(BUILDDIR)/cgreen/build-c/src -shared
|
2016-02-13 23:20:14 +01:00
|
|
|
LDLIBS = -lcgreen
|
2016-02-14 00:58:26 +01:00
|
|
|
UNITOBJ = $(BUILDDIR)/serialtest/unitobj
|
|
|
|
DEPDIR = $(BUILDDIR)/serialtest/unit.d
|
|
|
|
UNITTESTS = $(BUILDDIR)/serialtest/unittests
|
2016-02-13 23:20:14 +01:00
|
|
|
DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td
|
2016-02-14 00:58:26 +01:00
|
|
|
EXT = .so
|
2016-02-13 23:20:14 +01:00
|
|
|
UNAME := $(shell uname)
|
2016-02-14 00:58:26 +01:00
|
|
|
ifneq (, $(findstring MINGW, $(UNAME)))
|
|
|
|
EXT = .dll
|
2016-02-13 23:20:14 +01:00
|
|
|
endif
|
2016-02-14 00:58:26 +01:00
|
|
|
ifneq (, $(findstring CYGWIN, $(UNAME)))
|
|
|
|
EXT = .dll
|
2016-02-13 23:20:14 +01:00
|
|
|
endif
|
|
|
|
|
|
|
|
SRC = $(wildcard *.c)
|
2016-02-14 00:58:26 +01:00
|
|
|
TESTFILES = $(patsubst %.c, $(UNITTESTS)/%$(EXT), $(SRC))
|
2016-02-13 23:20:14 +01:00
|
|
|
$(shell mkdir -p $(DEPDIR) >/dev/null)
|
|
|
|
|
2016-02-14 00:58:26 +01:00
|
|
|
test: $(TESTFILES)
|
|
|
|
@$(BUILDDIR)/cgreen/build-c/tools/cgreen-runner --color $(TESTFILES)
|
2016-02-13 23:20:14 +01:00
|
|
|
|
2016-02-14 00:58:26 +01:00
|
|
|
$(UNITTESTS)/%$(EXT): $(UNITOBJ)/%.o
|
|
|
|
mkdir -p $(UNITTESTS)
|
2016-02-13 23:20:14 +01:00
|
|
|
$(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))
|