Merge branch 'fix/libnh-native-build' of https://github.com/YttriumOx/NetHack into YttriumOx-fix/libnh-native-build

This commit is contained in:
nhmall
2026-05-06 21:07:23 -04:00
2 changed files with 25 additions and 7 deletions
+5 -5
View File
@@ -37,7 +37,7 @@ extern struct passwd *getpwnam(const char *);
#ifdef CHDIR
static void chdirx(const char *, boolean);
#endif /* CHDIR */
static boolean whoami(void);
boolean whoami(void);
static void process_options(int, char **);
#ifdef _M_UNIX
@@ -516,7 +516,7 @@ chdirx(const char *dir, boolean wr)
#endif /* CHDIR */
/* returns True iff we set plname[] to username which contains a hyphen */
static boolean
boolean
whoami(void)
{
/*
@@ -805,7 +805,7 @@ get_nhuuid(void)
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
char *uuid = (char *) &stmp[0];
#ifndef NONHUUID
#ifdef NHUUID
#ifdef __EMSCRIPTEN__
int uuid_available = 0;
#endif
#endif
@@ -814,7 +814,7 @@ get_nhuuid(void)
return;
#ifndef NONHUUID
#ifdef NHUUID
#ifdef __EMSCRIPTEN__
uuid_available = emscripten_run_script_int(
"typeof crypto !== 'undefined'"
" && typeof crypto.randomUUID === 'function'");
@@ -824,7 +824,7 @@ get_nhuuid(void)
uuid = (char *) &stmp[0];
}
}
#endif /* NHUUID */
#endif /* __EMSCRIPTEN__ */
#endif /* NONHUUID */
Snprintf(svn.nhuuid, sizeof svn.nhuuid, "%s", uuid);
}
+20 -2
View File
@@ -345,6 +345,12 @@ LIBNHSYSOBJ = $(TARGETPFX)libnhmain.o $(TARGETPFX)ioctl.o \
#without winshim
override GAME=
MOREALL += ( cd src ; $(MAKE) pregame ; $(MAKE) $(TARGETPFX)libnh.a )
# With $(GAME) empty, the regular `recover: $(GAME)` chain no longer
# triggers lua_support, but recover.c still pulls in hack.h -> nhlua.h
# transitively. Make recover depend on lua_support explicitly.
ifdef MAKEFILE_TOP
recover: lua_support
endif
endif # WANT_LIBNH
# Lua
@@ -568,8 +574,20 @@ $(TARGETPFX)macuuid.o: ../sys/unix/macuuid.m
endif
ifdef WANT_LIBNH
$(TARGETPFX)libnh.a: $(HOBJ) $(LIBNHSYSOBJ) ../lib/lua/liblua-$(LUA_VERSION).a
$(AR) rcs $@ $(HOBJ) $(LIBNHSYSOBJ) ../lib/lua/liblua-$(LUA_VERSION).a
# Build libnh.a by merging the engine objects, the shim windowport,
# date.o (separate from $(HOBJ) per Makefile.src), hacklib.a, and Lua's
# static archive. Use libtool -static rather than ar so hacklib.a and
# liblua-$(LUA_VERSION).a have their members merged in -- ar would archive
# them as opaque .a members and macOS ld can't dereference those.
# Depending on $(LUALIB) triggers the lua_support build (which generates
# include/nhlua.h); without it, $(HOBJ) won't compile.
# filter-out drops $(SYSOBJ) (which carries unixmain.o) and $(WINOBJ) (the
# tty windowport) from $(HOBJ); $(LIBNHSYSOBJ) supplies libnhmain.o and
# winshim.o in their place.
$(TARGETPFX)libnh.a: $(LUALIB) $(HOBJ) $(LIBNHSYSOBJ) $(DATE_O) $(TARGET_HACKLIB)
libtool -static -o $@ \
$(filter-out $(SYSOBJ) $(WINOBJ),$(HOBJ)) \
$(LIBNHSYSOBJ) $(DATE_O) $(TARGET_HACKLIB) $(LUALIB)
@echo "$@ built."
$(TARGETPFX)libnhmain.o : ../sys/libnh/libnhmain.c $(HACK_H)
$(CC) $(CFLAGS) -c -o$@ $<