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>
This README provides the instructions for building the unofficial Mac binaries using the Apple provided developer IDE named XCode. Establish a developer team in XCode =================================== Your first step should be to establish a developer team within XCode. Launch XCode and open the preferences dialog (XCode Menu->Preferences). Select the "Accounts" tab. Add an account (usually this should just be your apple ID account you used to setup the Mac). After adding the account, select the account and then add a team (usually this will be just a personal team for Mac Development). Obtain your developer team identifier ===================================== Your DEVELOPMENT_TEAM can be found by opening Keychain Access (found by Finder->Applications->Utilities). Click on "My Certificates". Look for your "Mac Developer" certificate. Right click on the certificate to open a dialog that shows certificate details. Look for "Organizational Unit" among the details. This ten digit value is your development team identifier. Create XCodeLocal.xcconfig file =============================== Now you need to create the XCodeLocal.xcconfig file that will be used by XCode to get your development team identifier. Create the file in sys/unix and add a single line such as: DEVELOPMENT_TEAM = XXXXXXXXXX Where XXXXXXXXXX is replaced with your development team identifier. Open the project and build ========================== In XCode open the project file sys/unix/NetHack.xcodeproj, select the product NetHack and build. The build results are placed in ~/nethackdir.