2020-02-10 00:54:45 +01:00
|
|
|
# minimal required settings
|
|
|
|
SNP_TESTLIB := $(if $(SNP_TESTLIB),$(SNP_TESTLIB),"SNP_TESTLIB-is-not-set")
|
|
|
|
SNP_DOXYFILE := $(if $(SNP_DOXYFILE),$(SNP_DOXYFILE),"SNP_DOXYFILE-is-not-set")
|
|
|
|
|
|
|
|
# directories to create (and remove upon cleanup)
|
|
|
|
CREATEDIRS := bin doc
|
|
|
|
|
|
|
|
# list of derived file names from the source names
|
|
|
|
OBJECTS := $(SOURCES:%.c=%.o) # list of gcc -c ... produced *.o files
|
|
|
|
DEPS := $(SOURCES:%.c=%.d) # list of gcc -MD ... produced *.d files
|
|
|
|
TSTOBJECTS := $(TSTSOURCES:%.c=%.o) # list of gcc -c ... produced *.o files
|
|
|
|
TSTDEPS := $(TSTSOURCES:%.c=%.d) # list of gcc -MD ... produced *.d files
|
|
|
|
TSTTARGET := $(CURDIR)/tests/runtest
|
|
|
|
|
|
|
|
# shared libs
|
|
|
|
TSTLIBDIR := $(SNP_TESTLIB)/lib
|
|
|
|
TSTINCDIR := $(SNP_TESTLIB)/include
|
|
|
|
|
|
|
|
# full path to the target
|
|
|
|
FULLTARGET := $(CURDIR)/$(TARGET)
|
|
|
|
|
|
|
|
# commands and flags
|
|
|
|
CC = gcc
|
|
|
|
CFLAGS = -std=c99 -Wall -pedantic -g
|
|
|
|
CPPFLAGS = -MD -Isrc -Itests -I$(TSTINCDIR) -DTARGET=$(FULLTARGET)
|
2020-02-22 01:52:51 +01:00
|
|
|
LDFLAGS = -static
|
2020-02-10 00:54:45 +01:00
|
|
|
|
|
|
|
# targets which get always visited (without checking any up-to-date state)
|
|
|
|
.PHONY: default clean test doc install mkdir
|
|
|
|
|
|
|
|
# targets
|
|
|
|
default: $(FULLTARGET)
|
|
|
|
@echo "#### $< built ####"
|
|
|
|
|
|
|
|
$(FULLTARGET): mkdir $(OBJECTS) Makefile
|
2020-02-29 23:42:32 +01:00
|
|
|
$(LINK.c) -o $@ $(OBJECTS) $(LIBS)
|
2020-02-10 00:54:45 +01:00
|
|
|
|
|
|
|
clean:
|
|
|
|
$(RM) $(TARGET) $(OBJECTS) $(DEPS) $(TSTTARGET) $(TSTOBJECTS) $(TSTDEPS) $(wildcard */*~ *~ tests/*.txt)
|
|
|
|
$(RM) -r $(CREATEDIRS)
|
|
|
|
@echo "#### $@ done ####"
|
|
|
|
|
|
|
|
doc:
|
|
|
|
doxygen $(SNP_DOXYFILE) > /dev/null
|
|
|
|
@echo "#### $@ done ####"
|
|
|
|
|
|
|
|
test: $(TSTTARGET)
|
|
|
|
(cd tests; $(TSTTARGET))
|
|
|
|
@echo "#### $< executed ####"
|
|
|
|
|
|
|
|
$(TSTTARGET): $(FULLTARGET) $(TSTOBJECTS)
|
2020-02-29 23:42:32 +01:00
|
|
|
$(LINK.c) -o $(TSTTARGET) $(TSTOBJECTS) $(LIBS) -lcunit -L$(TSTLIBDIR) -lsnptest
|
2020-02-10 00:54:45 +01:00
|
|
|
@echo "#### $@ built ####"
|
|
|
|
|
|
|
|
|
|
|
|
# create needed directories (ignoring any error)
|
|
|
|
mkdir:
|
|
|
|
-mkdir -p $(CREATEDIRS)
|
|
|
|
|
|
|
|
# read in the gcc -MD ... produced dependencies (ignoring any error)
|
|
|
|
-include $(DEPS) $(TSTDEPS)
|