diff options
| author | Murilo Ijanc <[email protected]> | 2026-07-26 12:49:48 -0300 |
|---|---|---|
| committer | Murilo Ijanc <[email protected]> | 2026-07-26 12:49:48 -0300 |
| commit | f979d07d23098b96e758b3feb555cd06d85d9b2d (patch) | |
| tree | 47298197a17a3d6c438a1f4cc7cb61afd390cf05 /Makefile | |
| download | cobol-0.1.0.tar.gz | |
Initial importv0.1.0
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..1de6116 --- /dev/null +++ b/Makefile @@ -0,0 +1,87 @@ +# 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) |