Files

87 lines
2.5 KiB
Makefile
Raw Permalink Normal View History

# 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)/$(KLAMMERTEXT_LIBFILE)
# 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$(JOBS) 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)