Build w6a and w6l from package-main directories and expose the wcc backend through a narrow package API so w6c and wwdump no longer import implementation files. Retarget the remaining load-bearing fixtures and example sources to directory packages; retain the one intentional flat compiler collision as an explicitly composed raw unit.
53 lines
2.0 KiB
Makefile
53 lines
2.0 KiB
Makefile
# examples/lisp — tiny Lisp interpreter, built with the ww toolchain.
|
|
# No FFI: the program lives entirely on lib/* and libwwrt.a.
|
|
#
|
|
# Layout
|
|
# lisp.ww entry point. `use lispcore;` + `main()` = repl().
|
|
# lispcore/ interpreter package. Types/functions are `export`-ed
|
|
# so both lisp.ww and lisp_test.ww consume them via
|
|
# the same `use lispcore;`.
|
|
# lisp_test.ww in-process test driver, executed by `make test`
|
|
# (which invokes `ww test`).
|
|
#
|
|
# The absolute include root makes `import lispcore` resolve the canonical
|
|
# lispcore/ directory regardless of the caller's working directory.
|
|
|
|
# Drive the wwstage cgen (w6c_ww) by default. The C-stage cgen has
|
|
# unfixed silent-miscompilation traps that lispcore used to dodge by
|
|
# hand; with the wwstage fixes in place we can write the natural
|
|
# shape (no flattened sub-structs, no aliased global indexers, no
|
|
# `let p = xs[i];` per builtin) and lisp_test still passes.
|
|
WW := $(shell cd ../..; pwd)/out/bin/ww
|
|
W6CWW := $(shell cd ../..; pwd)/out/bin/w6c_ww
|
|
HERE := $(shell pwd)
|
|
WWENV := WW_W6C=$(W6CWW)
|
|
|
|
lisp: lisp.ww lispcore/lispcore.ww
|
|
$(WWENV) $(WW) build lisp.ww -I $(HERE)
|
|
|
|
# `ww test <file.ww>` in single-file mode discards extra args, so we
|
|
# can't pass `-I` through it. Build the test as a normal binary and
|
|
# exec it directly — exit 0 means all probes passed.
|
|
test: lisp_test lisp
|
|
./lisp_test
|
|
|
|
lisp_test: lisp_test.ww lispcore/lispcore.ww
|
|
$(WWENV) $(WW) build lisp_test.ww -I $(HERE)
|
|
|
|
# Demo programs in tree. `make demo` runs every test_*.lisp through
|
|
# the REPL; each prints its results to stdout (errors go to stderr
|
|
# and don't break the run). Useful as a smoke check after edits.
|
|
DEMOS := test_arith.lisp test_list.lisp test_lambda.lisp test_error.lisp test_tco.lisp
|
|
|
|
demo: lisp
|
|
@for f in $(DEMOS); do \
|
|
echo "==> $$f"; \
|
|
./lisp < $$f; \
|
|
done
|
|
|
|
clean:
|
|
rm -f lisp lisp.o lisp.s lisp.combined.ww \
|
|
lisp_test lisp_test.o lisp_test.s lisp_test.combined.ww
|
|
|
|
.PHONY: clean test demo
|