Lay foundation for unit test build framework.

GNU Make double colon rules, rule ;-)

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2015-08-22 21:59:52 +02:00
1 parent b7a8042c87
commit 2ea2357b62
3 files changed
+41 -44

No files matched your search

+35
View File
@@ -1,3 +1,23 @@
.PHONY: all clean distclean
# Figure out root of library, unless used as submodule
ROOTDIR ?= $(shell pwd)
# Default to silent build, use V=1 to get verbose mode.
ifeq ($V,1)
Q =
PRINT = @true
REDIRECT =
MAKEFLAGS =
else
Q = @
PRINT = @printf
REDIRECT = >/dev/null
MAKEFLAGS = --no-print-directory --silent
endif
export ROOTDIR Q PRINT MAKEFLAGS
# Pretty printing and GCC -M for auto dep files
%.o: %.c
$(PRINT) " CC $(subst $(ROOTDIR)/,,$(shell pwd)/)$@\n"
@@ -7,3 +27,18 @@
$(PRINT) " LINK $(subst $(ROOTDIR)/,,$(shell pwd)/)$@\n"
$(Q)$(CC) $(CFLAGS) $(LDFLAGS) -Wl,-Map,$@.map -o $@ $^ $(LDLIBS$(LDLIBS-$(@)))
%.test: %.c
$(PRINT) " TEST $(subst $(ROOTDIR)/,,$(shell pwd)/)$(@:.test=)\n"
$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -DUNITTEST $< $(OBJS)
$(Q)@./$@ $(REDIRECT)
# Default build rules for both main and unit test makefiles
all:: $(TARGET)
clean::
-$(Q)$(RM) $(OBJS) $(DEPS) $(TARGET) $(SOLIB) $(STATICLIB)
distclean::
-$(Q)$(RM) $(JUNK) unittest *.o *.a *.so* *.unittest *.test