write a make rule for the modules a unit reads

An import pastes another file's forms into the output, so a Makefile
had to make every object depend on every .sex. --depfile names the
modules read, including those read only for an import's interface,
with an empty rule for each, as cc -MD -MP does.

Fixes #40.
This commit is contained in:
2026-10-09 17:44:36 +03:00
parent d94daa9066
commit 31d876e30e
5 changed files with 69 additions and 4 deletions

View File

@@ -20,6 +20,10 @@
# to a prototype and to an extern both have to look past. And a type the
# app cannot see -- private to greet, or from a module greet imports
# without `pub' -- crosses behind a pointer, declared and no more.
#
# The app's dependency rule names both modules: greet, which it imports,
# and ledger, which only greet does but which decides what the app is
# told of it.
SEXC ?= ../../sexc
@@ -28,7 +32,10 @@ EXPECTED = hello, world\nhello, sex\n2 greetings\ntext times \ntext times \nmood
check:
@$(SEXC) ledger.sex -c -o ledger.o
@$(SEXC) greet.sex -c -o greet.o
@$(SEXC) greet-app.sex -o greet-app -- greet.o ledger.o
@$(SEXC) greet-app.sex -o greet-app --depfile=greet-app.d -- greet.o ledger.o
@if ! head -1 greet-app.d | grep -q '^greet-app: greet-app.sex .*/greet.sex .*/ledger.sex$$'; then \
echo "modules FAILED, the dependency rule is:"; cat greet-app.d; $(MAKE) clean; exit 1; \
fi
@if [ "`./greet-app`" = "`printf '$(EXPECTED)\n'`" ]; then \
echo "modules ok"; \
else \
@@ -37,6 +44,6 @@ check:
@$(MAKE) --no-print-directory clean
clean:
@rm -f greet.o ledger.o greet-app
@rm -f greet.o ledger.o greet-app greet-app.d
.PHONY: check clean