2020-02-06 23:41:26 +01:00
|
|
|
# what to produce
|
2020-02-10 00:54:45 +01:00
|
|
|
TARGET := lib/libsnptest.a
|
2020-02-06 23:41:26 +01:00
|
|
|
|
|
|
|
# public headers
|
2020-02-10 00:11:44 +01:00
|
|
|
HEADERS := include/test_utils.h
|
2020-02-06 23:41:26 +01:00
|
|
|
|
|
|
|
# implementation files
|
|
|
|
SOURCES := src/test_utils.c
|
|
|
|
|
|
|
|
# test implementations
|
|
|
|
TSTSOURCES := tests/tests.c
|
|
|
|
|
|
|
|
# directories to create (and remove upon cleanup)
|
2020-02-10 00:11:44 +01:00
|
|
|
CREATEDIRS := lib doc
|
2020-02-06 23:41:26 +01:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
# full path to the target
|
|
|
|
FULLTARGET := $(CURDIR)/$(TARGET)
|
|
|
|
|
|
|
|
# commands and flags
|
|
|
|
CC = gcc
|
2020-02-10 00:11:44 +01:00
|
|
|
CFLAGS = -std=c99 -Wall -pedantic -g
|
|
|
|
CPPFLAGS = -MD -Isrc -Itests -Iinclude -DTARGET=$(FULLTARGET)
|
|
|
|
LDFLAGS =
|
2020-02-06 23:41:26 +01:00
|
|
|
ARFLAGS = rc
|
|
|
|
|
|
|
|
# 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
|
|
|
|
$(AR) $(ARFLAGS) $@ $(OBJECTS)
|
|
|
|
|
|
|
|
clean:
|
|
|
|
$(RM) $(TARGET) $(OBJECTS) $(DEPS) $(TSTTARGET) $(TSTOBJECTS) $(TSTDEPS) $(wildcard */*~ *~ tests/*.txt)
|
|
|
|
$(RM) -r $(CREATEDIRS)
|
|
|
|
@echo "#### $@ done ####"
|
|
|
|
|
|
|
|
install: $(FULLTARGET)
|
|
|
|
@echo "#### $< installed ####"
|
|
|
|
|
2020-02-10 00:11:44 +01:00
|
|
|
doc:
|
|
|
|
doxygen ../Doxyfile > /dev/null
|
|
|
|
@echo "#### $@ done ####"
|
|
|
|
|
2020-02-06 23:41:26 +01:00
|
|
|
test: $(TSTTARGET)
|
|
|
|
(cd tests; $(TSTTARGET))
|
|
|
|
@echo "#### $< executed ####"
|
|
|
|
|
|
|
|
$(TSTTARGET): $(FULLTARGET) $(TSTOBJECTS)
|
2020-02-10 00:11:44 +01:00
|
|
|
$(LINK.c) -o $(TSTTARGET) $(TSTOBJECTS) $(FULLTARGET) -lcunit
|
2020-02-06 23:41:26 +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)
|