Add some support for Alpine Linux system Lua package

Requires apk add lua5.4-dev (for the C Lua headers)
This commit is contained in:
nhmall
2026-05-19 00:49:30 -04:00
parent 721dc27f26
commit 5333747f02
4 changed files with 48 additions and 14 deletions
+2 -2
View File
@@ -673,8 +673,8 @@ Sysatt: $(HOSTOBJ) $(HOBJ) $(TARGET_HACKLIB) $(GENTILEOFILE) \
$(DATE_O) $(BUILDMORE) Makefile
@echo "Loading $(GAME)."
$(AT)$(LD) $(TARGET_LFLAGS) /lib/crt0s.o /lib/shlib.ifile \
-o $(GAMEBIN) $(HOSTOBJ) $(HOBJ) $(DATE_O) $(TARGET_HACKLIB) \
$(LUALIBS)
-o $(GAMEBIN) $(HOSTOBJ) $(HOBJ) $(DATE_O) \
$(TARGET_HACKLIB) $(LUALIBS)
@touch Sysatt
Systos: $(HOSTOBJ) $(HOBJ) $(TARGET_HACKLIB) $(GENTILEOFILE) \
+11 -10
View File
@@ -121,13 +121,14 @@ DAT = $(DATNODLB) $(DATDLB)
RECOVERBIN = recover
# Lua
LUAHEADERS = lib/lua-$(LUA_VERSION)/src
LUATESTTARGET = $(LUAHEADERS)/lua.h
LUATOP = $(LUAHEADERS)
LUAMAKEFLAGS = CC='$(CC)' SYSCFLAGS='$(SYSCFLAGS)'
LUA2NHTOP = ../../..
LUABASELIB = liblua-$(LUA_VERSION).a
TOPLUALIB = lib/lua/$(LUABASELIB)
LUAHEADERS ?= lib/lua-$(LUA_VERSION)/src
LUATESTTARGET ?= $(LUAHEADERS)/lua.h
LUATOP ?= $(LUAHEADERS)
LUAMAKEFLAGS ?= CC='$(CC)' SYSCFLAGS='$(SYSCFLAGS)'
LUA2NHTOP ?= ../../..
LUABASELIB ?= liblua-$(LUA_VERSION).a
TOPLUALIB ?= lib/lua/$(LUABASELIB)
LUAHPREFIX ?= ../
ALLDEP = $(PRECHECK) $(GAME) recover Guidebook $(VARDAT) spec_levs check-dlb
@@ -149,12 +150,12 @@ $(TOPLUALIB): $(LUATOP)/liblua.a
include/nhlua.h: $(TOPLUALIB)
echo '/* nhlua.h - generated by top Makefile */' > $@
@echo '#include "../$(LUAHEADERS)/lua.h"' >> $@
@echo '#include "$(LUAHPREFIX)$(LUAHEADERS)/lua.h"' >> $@
@sed -e '/(lua_error)/!d' \
-e '/(lua_error)/s/LUA_API/ATTRNORETURN LUA_API/1' \
-e '/(lua_error)/s/;/ NORETURN;/1' < $(LUAHEADERS)/lua.h >> $@
@echo '#include "../$(LUAHEADERS)/lualib.h"' >> $@
@echo '#include "../$(LUAHEADERS)/lauxlib.h"' >> $@
@echo '#include "$(LUAHPREFIX)$(LUAHEADERS)/lualib.h"' >> $@
@echo '#include "$(LUAHPREFIX)$(LUAHEADERS)/lauxlib.h"' >> $@
@echo '/*nhlua.h*/' >> $@
# LUATESTTARGET is this by default
lib/lua-$(LUA_VERSION)/src/lua.h:
+2
View File
@@ -49,6 +49,8 @@ make musl=1 Build with settings appropriate for linking with
musl libc, instead of glibc. This causes
NOCRASHREPORT to be defined, and avoids the use
of 'col' during the build.
make WANT_SYSTEM_LUA=1 Attempt to use an existing Lua package already
on the system (initially for Alpine Linux).
make resp=1 Place the majority of the compiler switches into
a response file to de-clutter the build compiler
command lines and eliminate some of the
+33 -2
View File
@@ -23,6 +23,7 @@
HINTSVERSION := 500
ifdef MAKEFILE_TOP
LUA_VERSION=5.4.8
ifeq ($(MAKELEVEL),0)
PRECHECK+=checkmakefiles
# all files included from this hints file get listed
@@ -67,6 +68,35 @@ USE_NOSTATICFN = 1
#-INCLUDE compiler.500
ifdef WANT_SYSTEM_LUA
OS_ID := $(shell grep -E '^ID=' /etc/os-release 2>/dev/null | cut -d= -f2)
ifeq ($(OS_ID),alpine)
USE_SYSTEM_LUA=1
CURSPKG = ncurses
endif # Alpine Linux
ifeq "$(USE_SYSTEM_LUA)" "1"
#5.4.8
ifndef LUA_VERSION
LUA_VERSION := 5.4.8
endif
LUASUBDELIM := $(subst ., ,$(LUA_VERSION))
LUASHVER := $(word 1, $(LUASUBDELIM)).$(word 2, $(LUASUBDELIM))
LUAHEADERS := /usr/include/lua$(LUASHVER)
LUATESTTARGET := $(LUAHEADERS)/lua.h
LUAHPREFIX :=
LUAFLAGS := $(shell pkg-config --cflags lua-$(LUASHVER))
LUALIBS := $(shell pkg-config --libs lua-$(LUASHVER))
CFLAGS += $(LUAFLAGS)
LUATOP=
LUAMAKEFLAGS=
LUA2NHTOP=
LUABASELIB=
TOPLUALIB=
LUALIB=
endif # USE_SYSTEM_LUA
endif # WANT_SYSTEM_LUA
ifdef WANT_WIN_QT
ifdef WANT_WIN_QT5
QTDIR=/usr
@@ -96,6 +126,7 @@ LFLAGS+=-fsanitize=undefined
endif
ifeq "$(USE_CURSESLIB)" "1"
CURSPKG ?= ncursesw
# default
CURSESLIB = -lncurses -ltinfo
# If CURSES_UNICODE is defined, we need ncursesw.
@@ -103,8 +134,8 @@ CURSESLIB = -lncurses -ltinfo
# CURSESLIB = -lncurses -ltinfo
ifdef MAKEFILE_SRC
comma:=,
NCURSES_LFLAGS = $(shell pkg-config ncursesw --libs)
NCURSES_CFLAGS = $(shell pkg-config ncursesw --cflags)
NCURSES_LFLAGS = $(shell pkg-config $(CURSPKG) --libs)
NCURSES_CFLAGS = $(shell pkg-config $(CURSPKG) --cflags)
ifeq (,$(findstring ncursesw, $(NCURSES_LFLAGS)))
ifeq (,$(findstring ncurses, $(NCURSES_LFLAGS)))
#this indicates that pkg-config itself was unavailable