Assembled from klammertext-dev ed13dfaa5b7a. kpy/klammertext.cpp is a CPython extension module giving a Python script an instance of the Machine class -- ktext in-process, set up through the same functions the command uses. Errors map one-to-one to Python exceptions under the C++ names; an @eval's Python exception is chained as __cause__. Built by make -C mac, found through PYTHONPATH (env/runtime.env sets it), tested by tst/kpy_test.sh. Three engine changes came with it: Error::message(), set_command_state(), and the @eval error report carrying its traceback. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Uv7KWxafinDPraswEf4GsC
88 lines
2.5 KiB
Makefile
88 lines
2.5 KiB
Makefile
# Klammertext mac/ Makefile
|
|
# Improved version with automatic header dependency tracking
|
|
|
|
K := $(KLAMMERTEXT_HOME)
|
|
KS := $(K)/sks
|
|
|
|
include $(K)/env/makefile.env
|
|
|
|
# Source files
|
|
BASENAMES := util error locator file argv character ktype katom katom_process \
|
|
katomize katom_rewrite_rules katom_matching \
|
|
log show command argument argument_set argtype argtype_registry \
|
|
state eval eval_python eval_cpp klammer klammer_registry klammerset klammerset_registry \
|
|
option_set option_set_registry deftype \
|
|
target target_registry machine font_store check coverage
|
|
|
|
SOURCES := $(addsuffix .cpp,$(BASENAMES))
|
|
OBJECTS := $(addsuffix .o,$(BASENAMES))
|
|
HEADERS := $(addsuffix .h,$(BASENAMES))
|
|
DEPFILES := $(addsuffix .d,$(BASENAMES))
|
|
|
|
# Shared library
|
|
LIBDIR := ../lib
|
|
LIBRARY := $(LIBDIR)/libklammertext.so
|
|
|
|
# Compiler flags for dependency generation
|
|
DEPFLAGS = -MMD -MP -MF $(@:.o=.d)
|
|
|
|
# Pattern rule for object files with automatic dependency generation
|
|
%.o : %.cpp
|
|
$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $(DEPFLAGS) $< -o $@
|
|
|
|
# Default target
|
|
.PHONY: all sks ref kpy clean redo clang
|
|
|
|
all : $(LIBRARY)
|
|
$(MAKE) sks
|
|
$(MAKE) ref
|
|
$(MAKE) kpy
|
|
|
|
# Create lib directory
|
|
$(LIBDIR):
|
|
mkdir -p $(LIBDIR)
|
|
|
|
# Build shared library
|
|
$(LIBRARY): $(OBJECTS) | $(LIBDIR)
|
|
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(SHARED) $(SONAME) -o $@ $(OBJECTS) $(LDLIBS)
|
|
|
|
# Build sks components
|
|
sks :
|
|
$(MAKE) -C $(KS)/kutil
|
|
$(MAKE) -C $(KS)/target
|
|
$(MAKE) -C $(KS)/document
|
|
|
|
# ref/ is NOT part of a klammer set: it is the reflection library, whose
|
|
# C++ reads the engine's OWN registries and character tables and returns
|
|
# Klammertext. It is built here because, like the sks DSOs, it links
|
|
# against libklammertext.so -- but it is a separate target so it does not
|
|
# become "part of sks" by association, which is exactly the confusion the
|
|
# klammer-set naming is trying to undo.
|
|
ref :
|
|
$(MAKE) -C $(K)/ref
|
|
|
|
# kpy/ is the Python binding: a CPython extension module that links against
|
|
# libklammertext.so and shares its class layouts, like the sks DSOs and
|
|
# ref/. A fourth consumer of the library, and neither a command nor a
|
|
# klammer set.
|
|
kpy :
|
|
$(MAKE) -C $(K)/kpy
|
|
|
|
clean :
|
|
rm -f $(OBJECTS) $(DEPFILES) $(LIBRARY) *~
|
|
|
|
redo :
|
|
ifneq ($(filter clang,$(MAKECMDGOALS)),)
|
|
@:
|
|
else
|
|
$(MAKE) clean
|
|
$(MAKE) -j all
|
|
endif
|
|
|
|
# "make clang" = incremental build; "make clang redo" = full clean rebuild
|
|
clang :
|
|
$(MAKE) $(or $(filter-out clang,$(MAKECMDGOALS)),all) COMPILER=clang
|
|
|
|
# Include generated dependency files (if they exist)
|
|
-include $(DEPFILES)
|