Files
klammertext/com/Makefile
Andy Kopra c42981f7e2 release: parallel command links, nine-level list nesting
Two development changes since the last snapshot.

perf(build): com/Makefile's recursive $(MAKE) commands inherited no
jobserver, so kdiag, kdesc and ktext linked one after another even though
they are independent links against the already-built library.  A clean
rebuild drops from 27.9 s to 23.1 s on an i9-14900KF and from 16.4 s to
13.8 s on an M5 Pro.

fix(list): LaTeX's built-in enumerate and itemize stop at four levels, so
a deeper @ol or @ul failed with "Too deeply nested".  sks/list/sty/list.sty
now redefines both through enumitem to allow nine, with explicit per-level
itemize markers, since \renewlist discards the built-in ones.

(from dev 15b822f06ee0)

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-07-29 19:22:59 +02:00

105 lines
3.2 KiB
Makefile

# Klammertext com/ Makefile
# Improved version with automatic header dependency tracking
K := $(KLAMMERTEXT_HOME)
KS := $(K)/sks
KM := $(K)/mac
include $(K)/env/makefile.env
# Commands to build
COMMANDS := kdiag kdesc ktext
# Build output directory: commands are linked directly into ../bin, so there is
# exactly one copy of each (no redundant executables in com/) and make still
# tracks them by path for incremental builds.
BINDIR := ../bin
BINCOMMANDS := $(addprefix $(BINDIR)/,$(COMMANDS))
# System install location (out-of-tree). Override on the command line, e.g.
# make install PREFIX=/opt DESTDIR=/tmp/stage
PREFIX ?= /usr/local
DESTDIR ?=
# Shared library location
LIBDIR := ../lib
LIBRARY := $(LIBDIR)/libklammertext.so
# Linker flags for commands
COM_LDFLAGS := $(EXPORT_DYNAMIC) -Wl,-rpath,'$(ORIGIN)/../lib' -L$(LIBDIR)
# Dependency files for command sources
DEPFILES := $(addsuffix .d,$(COMMANDS))
# Compiler flags for dependency generation ($(@F) keeps the .d files in com/,
# not in the ../bin output directory).
DEPFLAGS = -MMD -MP -MF $(@F).d
.PHONY: all clean redo clang mac sks install
# Default target: build dependencies first, then commands. The commands are
# three independent links against the finished library, so they run in
# parallel (as mac/ and the sks/ components already do) rather than one after
# another -- the serial links were about a quarter of a clean rebuild.
all : | mac sks
$(MAKE) -j commands
# Separate target to build commands (called after dependencies are ready)
.PHONY: commands
commands : $(BINCOMMANDS)
# Ensure the output directory exists before linking into it.
$(BINDIR) :
mkdir -p $@
# Build mac/ objects
mac :
$(MAKE) -C $(KM) -j
# Build sks/ components (depends on mac)
sks : | mac
$(MAKE) -C $(KS)/kutil -j
$(MAKE) -C $(KS)/target -j
$(MAKE) -C $(KS)/document
# Explicit rules for each command - link against shared library, output to bin/
$(BINDIR)/kdiag : kdiag.cpp $(LIBRARY) | $(BINDIR)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(DEPFLAGS) $(COM_LDFLAGS) $(LDFLAGS) $< -o $@ -lklammertext $(LDLIBS)
$(BINDIR)/kdesc : kdesc.cpp $(LIBRARY) | $(BINDIR)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(DEPFLAGS) $(COM_LDFLAGS) $(LDFLAGS) $< -o $@ -lklammertext $(LDLIBS)
$(BINDIR)/ktext : ktext.cpp $(LIBRARY) | $(BINDIR)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(DEPFLAGS) $(COM_LDFLAGS) $(LDFLAGS) $< -o $@ -lklammertext $(LDLIBS)
# Out-of-tree system install (copies; the build tree stays intact). The
# installed commands still need KLAMMERTEXT_HOME pointing at a Klammertext tree
# for sks/ and the Python modules; their rpath finds libklammertext.so in
# $(PREFIX)/lib.
install : all
install -d $(DESTDIR)$(PREFIX)/bin $(DESTDIR)$(PREFIX)/lib
install -m755 $(BINCOMMANDS) $(DESTDIR)$(PREFIX)/bin
install -m755 $(LIBRARY) $(DESTDIR)$(PREFIX)/lib
clean :
rm -f $(BINCOMMANDS) $(DEPFILES) *~
redo :
ifneq ($(filter clang,$(MAKECMDGOALS)),)
@:
else
$(MAKE) -C $(KM) clean
$(MAKE) -C $(KS)/kutil clean
$(MAKE) -C $(KS)/target clean
$(MAKE) -C $(KS)/document clean
$(MAKE) clean
$(MAKE) 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)