# Development tasks. # # make list the targets # make build compile the library into build/libcepis.a # make test run the suite against the local fake API # make lint compile every unit for syntax and warnings, no output # make check lint, then test, then build # # Requires GnuCOBOL 3.x (cobc), a C compiler, libcurl with its headers and # python3 for the test server. Nothing else. COBC ?= cobc CC ?= cc PYTHON ?= python3 AR ?= ar COPYDIR := copy BUILDDIR := build # Free source format, GnuCOBOL's default dialect. -fstatic-call resolves # CALL "literal" at link time, which is what lets the archive below work # without a runtime module search path. COBFLAGS ?= -free -Wall -I $(COPYDIR) -fstatic-call CFLAGS ?= -O2 -Wall -Wextra LDLIBS ?= -lcurl MODULES := \ cepis-config \ cepis-normalize-cep \ cepis-json \ cepis-csv \ cepis-request \ cepis-lookup \ cepis-lookup-many \ cepis-health COBSRC := $(addprefix src/,$(addsuffix .cob,$(MODULES))) COBOBJ := $(addprefix $(BUILDDIR)/,$(addsuffix .o,$(MODULES))) COBJ := $(BUILDDIR)/cepis-http.o LIB := $(BUILDDIR)/libcepis.a TESTBIN := $(BUILDDIR)/cepis-tests COPYBOOKS := $(wildcard $(COPYDIR)/*.cpy) .DEFAULT_GOAL := help .PHONY: help build test lint check clean help: @echo 'Targets:' @echo ' build compile the library into $(LIB)' @echo ' test run the suite against the local fake API' @echo ' lint syntax and warning check only, writes nothing' @echo ' check lint + test + build, in that order' @echo ' clean remove build artefacts' @echo @echo 'COBOL has no standard formatter, so there is no format target.' build: $(LIB) $(LIB): $(COBOBJ) $(COBJ) $(AR) rcs $@ $^ $(BUILDDIR)/%.o: src/%.cob $(COPYBOOKS) @mkdir -p $(BUILDDIR) $(COBC) -c $(COBFLAGS) -o $@ $< $(COBJ): src/cepis-http.c @mkdir -p $(BUILDDIR) $(CC) $(CFLAGS) -c -o $@ $< $(TESTBIN): tests/cepis-tests.cob $(LIB) $(COBC) -x $(COBFLAGS) -o $@ $< $(LIB) $(LDLIBS) test: $(TESTBIN) $(PYTHON) tests/server.py ./$(TESTBIN) # Read-only by design, so it is safe in CI and in a pre-commit hook. lint: $(CC) $(CFLAGS) -fsyntax-only src/cepis-http.c $(COBC) -fsyntax-only $(COBFLAGS) $(COBSRC) $(COBC) -fsyntax-only $(COBFLAGS) tests/cepis-tests.cob # The order matters: lint is the fastest to fail, so a broken run reports # the cheapest problem first. check: lint test build clean: rm -rf $(BUILDDIR)