make: CURSES_LIB/CURSES_DEP -- the package build links the base curses

The pkgsrc recipe passes CURSES_LIB=-lcurses -lterminfo and CURSES_DEP=
to get NetBSD's own curses instead of the vendored tree, whose nbperf and
host_tic have to run while building -- a cross build cannot run them
(it compiled nbperf with the target compiler and got 'nbperf/nbperf:
not found', build/logs/release-2026-11-23k-cross.log:91).  The Makefile
ignored both and always built vendor/netbsd-curses.

Verified: default build still builds and links the vendored tree (make
clean && make -j8 rc=0, splinter runs); with CURSES_LIB='-lcurses
-lterminfo' CURSES_DEP='' no GNUmakefile is invoked and
src/frontend/curses.c compiles against NetBSD's curses.h (rc=0).
This commit is contained in:
lotherk committed 2026-11-23 13:13:28 +00:00
1 parent f7158d34d2
commit 35d4e1bc53
1 file changed
+21 -12
+21 -12
View File
@@ -19,9 +19,16 @@ LDFLAGS ?=
LIBS ?= -lpthread
PREFIX ?= /usr/local
# Curses: the vendored NetBSD tree by default. A package build sets
# CURSES_LIB and CURSES_DEP instead and gets the base system's curses: the
# vendored tree needs host tools (nbperf, host_tic) that a cross build cannot
# run, and on NetBSD the base already has libcurses and libterminfo
# (ext/src/splinter/pkgsrc/Makefile). CURSES_LIB is what to link, CURSES_DEP
# the file that has to exist first -- empty means "nothing to build".
CURSES_DIR = vendor/netbsd-curses
CURSES_A = $(CURSES_DIR)/libcurses/libcurses.a \
$(CURSES_DIR)/libterminfo/libterminfo.a
CURSES_LIB ?= $(CURSES_DIR)/libcurses/libcurses.a \
$(CURSES_DIR)/libterminfo/libterminfo.a
CURSES_DEP ?= $(CURSES_LIB)
LIB = libsplinter.so
LIBOBJ = src/backend/buf.o src/backend/tool.o src/backend/session.o src/backend/conv.o src/backend/compact.o src/backend/transport.o \
@@ -61,11 +68,13 @@ all: $(LIB) $(BIN) $(CLIENT) $(PLUGIN)
# The vendored tree ships a GNUmakefile; this is the only place that needs GNU
# make, and it is why the comment above says so out loud.
$(CURSES_A):
# Only when the vendored tree is what is wanted: CURSES_DEP names a file
# that already exists when the base system's curses is linked.
$(CURSES_LIB):
cd $(CURSES_DIR) && $(MAKE) -f GNUmakefile libcurses/libcurses.a \
libterminfo/libterminfo.a
curses: $(CURSES_A)
curses: $(CURSES_LIB)
src/backend/catalogs.c: share/locale/de.msg share/locale/en.msg share/locale/pt_BR.msg tools/embed_catalogs.sh
sh tools/embed_catalogs.sh share/locale/*.msg > $@
@@ -84,8 +93,8 @@ src/backend/buildinfo.c: $(LIBOBJ) $(BINOBJ)
"`date '+%Y-%m-%d %H:%M:%S %Z'`" "$$rev"; \
} > $@
$(LIB): $(LIBOBJ_ALL) $(CURSES_A)
$(CC) -shared -o $@ $(LIBOBJ_ALL) $(CURSES_A) $(LIBS)
$(LIB): $(LIBOBJ_ALL) $(CURSES_DEP)
$(CC) -shared -o $@ $(LIBOBJ_ALL) $(CURSES_LIB) $(LIBS)
# curses belongs to the front end, not to the library: a plugin that drew into
# a WINDOW would be a plugin holding the UI thread's state.
@@ -95,9 +104,9 @@ $(CLIENT): $(CLIENTOBJ) $(LIB)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(CLIENTOBJ) -L. -lsplinter $(RPATH) \
$(LIBS)
$(BIN): $(BINOBJ) $(LIB)
$(BIN): $(BINOBJ) $(LIB) $(CURSES_DEP)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(BINOBJ) -L. -lsplinter $(RPATH) \
$(CURSES_A) $(LIBS)
$(CURSES_LIB) $(LIBS)
plugins/clock/clock.so: plugins/clock/clock.c $(LIB)
$(CC) $(CFLAGS) -shared -o $@ plugins/clock/clock.c -L. -lsplinter \
@@ -245,9 +254,9 @@ tests/test_ack: tests/test_ack.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_ack.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_i18n: tests/test_i18n.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_i18n.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_ascii: tests/test_ascii.c $(LIB) $(BINOBJ)
tests/test_ascii: tests/test_ascii.c $(LIB) $(BINOBJ) $(CURSES_DEP)
$(CC) $(CFLAGS) -o $@ tests/test_ascii.c src/frontend/curses.o -L. -lsplinter \
$(TEST_RPATH) $(CURSES_A) $(LIBS)
$(TEST_RPATH) $(CURSES_LIB) $(LIBS)
tests/test_md: tests/test_md.c $(LIB)
$(CC) $(CFLAGS) -o $@ tests/test_md.c -L. -lsplinter $(TEST_RPATH) $(LIBS)
tests/test_tgmd: tests/test_tgmd.c $(LIB)
@@ -388,12 +397,12 @@ print-tests:
# executing, which killed a gateway that was up while make install ran
# (SIGSEGV at a nonsense address). A rename swaps the directory entry and
# leaves the mapped inode alone.
install: all
install: all $(CURSES_DEP)
mkdir -p $(DESTDIR)$(PREFIX)/bin $(DESTDIR)$(PREFIX)/lib \
$(DESTDIR)$(PREFIX)/lib/splinter/plugins
$(CC) $(CFLAGS) $(LDFLAGS) -Wl,-rpath,'$$ORIGIN/../lib' \
-o $(DESTDIR)$(PREFIX)/bin/.splinter.new $(BINOBJ) -L. -lsplinter \
$(CURSES_A) $(LIBS)
$(CURSES_LIB) $(LIBS)
mv -f $(DESTDIR)$(PREFIX)/bin/.splinter.new \
$(DESTDIR)$(PREFIX)/bin/splinter
$(CC) $(CFLAGS) $(LDFLAGS) -Wl,-rpath,'$$ORIGIN/../lib' \