Submitted By:            Xi Ruoyao <xry111 at xry111 dot site>
Date:                    2022-09-16
Initial Package Version: 5.4.4
Upstream Status:         Rejected
Origin:                  Arch Linux, with some modifications
Description:             2020-06-30 renodr:
                         Creates a shared liblua library, as well as
                         removes optimization since it causes SIGBUS errors,
                         and sets the search path to /usr from /usr/local.
                         The initial version of this patch was created by
                         Igor Zivkovic, before being rediffed for 5.4.0 by
                         myself with some modifications made.
                         2022-09-16 xry111:
                         Remove an extra newline before $(MYLDFLAGS).
                         MYLDFLAGS is empty by default so it does not break
                         BLFS build, but it may break a custom build with
                         tuning or hardening.

Updated By:              Bruce Dubbs <bdubbs at linuxfromscratch dot org>
Date:                    2026-11-17
Initial Package Version: 5.5.1
Upstream Status:         Rejected
Origin:                  Based on the BLFS lua-5.4 shared library patch,
                         originally from Arch Linux
Description:             Build a shared library (liblua.so) in addition to
                         the static library.

diff -Naur lua-5.5.1.orig/Makefile lua-5.5.1/Makefile
--- lua-5.5.1.orig/Makefile	2026-07-14 13:25:18.000000000 -0500
+++ lua-5.5.1/Makefile	2026-11-17 14:56:37.388798011 -0600
@@ -52,7 +52,7 @@
 all:	$(PLAT)
 
 $(PLATS) help test clean:
-	@cd src && $(MAKE) $@
+	@cd src && $(MAKE) $@ V=$(V) R=$(R)
 
 install: dummy
 	cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
diff -Naur lua-5.5.1.orig/src/Makefile lua-5.5.1/src/Makefile
--- lua-5.5.1.orig/src/Makefile	2026-07-15 15:17:33.000000000 -0500
+++ lua-5.5.1/src/Makefile	2026-11-17 14:56:37.389022089 -0600
@@ -7,7 +7,7 @@
 PLAT= guess
 
 CC= gcc -std=gnu99
-CFLAGS= -O2 -Wall -Wextra $(SYSCFLAGS) $(MYCFLAGS)
+CFLAGS= -fPIC -O2 -Wall -Wextra $(SYSCFLAGS) $(MYCFLAGS)
 LDFLAGS= $(SYSLDFLAGS) $(MYLDFLAGS)
 LIBS= -lm $(SYSLIBS) $(MYLIBS)
 
@@ -33,6 +33,7 @@
 PLATS= guess aix bsd c89 freebsd generic ios linux linux-readline macosx mingw posix solaris
 
 LUA_A=	liblua.a
+LUA_SO=	liblua.so
 CORE_O=	lapi.o lcode.o lctype.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o
 LIB_O=	lauxlib.o lbaselib.o lcorolib.o ldblib.o liolib.o lmathlib.o loadlib.o loslib.o lstrlib.o ltablib.o lutf8lib.o linit.o
 BASE_O= $(CORE_O) $(LIB_O) $(MYOBJS)
@@ -44,7 +45,7 @@
 LUAC_O=	luac.o
 
 ALL_O= $(BASE_O) $(LUA_O) $(LUAC_O)
-ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T)
+ALL_T= $(LUA_A) $(LUA_T) $(LUAC_T) $(LUA_SO)
 ALL_A= $(LUA_A)
 
 # Targets start here.
@@ -60,6 +61,11 @@
 	$(AR) $@ $(BASE_O)
 	$(RANLIB) $@
 
+$(LUA_SO): $(BASE_O)
+	$(CC) -shared -Wl,-soname,$(LUA_SO).$(V) -o $@.$(R) $(BASE_O) -lm -ldl $(MYLDFLAGS)
+	ln -sf $(LUA_SO).$(R) $(LUA_SO).$(V)
+	ln -sf $(LUA_SO).$(R) $(LUA_SO)
+
 $(LUA_T): $(LUA_O) $(LUA_A)
 	$(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS)
