Fixes four issues that prevented `make WANT_LIBNH=1 all` from producing
a libnh.a that could be linked into a host program on macOS. Before
these patches, it built but the resulting archive was unusable: macOS
ld errored on a nested liblua archive member, was missing date.o and
hacklib symbols (`populate_nomakedefs`, `eos`, `lcase`, `mungspaces`,
...), and had duplicate definitions of `main`, `whoami`, etc.
Specific changes:
1. sys/libnh/libnhmain.c: drop `static` on `whoami()`. src/earlyarg.c
declares it `extern` and calls it from `scores_only()`; the static
makes it file-local and that reference goes unresolved.
2. sys/libnh/libnhmain.c: gate the emscripten-only code in get_nhuuid
with `#ifdef __EMSCRIPTEN__` instead of `#ifdef NHUUID`. The macOS
hints define NHUUID for the libnh build (they did so unconditionally
before NO_NHUUID even existed), so on native builds the compiler
tried to call `emscripten_run_script_int` / `_string` and failed
with implicit-function-declaration errors. __EMSCRIPTEN__ is the
real signal for "this is being cross-compiled to WASM."
3. sys/unix/hints/macOS.500: in the WANT_LIBNH block, add an explicit
`recover: lua_support` dependency (gated by MAKEFILE_TOP). When
$(GAME) is overridden to empty, the regular `recover: $(GAME)` chain
no longer triggers `lua_support`, so include/nhlua.h never gets
generated and recover.c's transitive #include of hack.h fails.
4. sys/unix/hints/macOS.500: rewrite the libnh.a rule. The previous
`ar rcs libnh.a $(HOBJ) $(LIBNHSYSOBJ) liblua-$(LUA_VERSION).a` had
four problems: (a) ar archives liblua.a as a single opaque member
that macOS ld can't dereference, (b) date.o (DATE_O, kept separate
from HOBJ) was never archived, so `populate_nomakedefs` and
`nomakedefs` were missing, (c) hacklib.a was likewise omitted, and
(d) HOBJ already contains $(SYSOBJ) (with unixmain.o) and $(WINOBJ)
(the tty windowport), which duplicated symbols from libnhmain.o /
winshim.o.
The fix uses `libtool -static` so hacklib.a and liblua's archive
have their members merged rather than nested, depends on $(LUALIB)
so lua_support runs first, includes $(DATE_O) and $(TARGET_HACKLIB),
and uses $(filter-out $(SYSOBJ) $(WINOBJ),$(HOBJ)) to drop the
duplicates.
Verified by clean rebuild on macOS 26 (arm64, Apple clang 17):
make spotless
make fetch-Lua
make WANT_LIBNH=1 all
and link-tested with a tiny harness that calls
shim_graphics_set_callback() against the resulting libnh.a.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>