Subject: [bug#53186] [PATCH] gnu: lua: add lua version 5.4.3

From: Alex Devaure <[email-masked]>
Date: Tue, 11 Jan 2022 12:21:13 +0000

After submitting a patch to update the package darktable to the last
version, it appeared that the version 5.4 of lua is necessary. It is why
I am submitting that patch.
Kind regards,
Alex

---
 gnu/packages/lua.scm                         |  12 +++
 gnu/packages/patches/lua-5.4-liblua-so.patch |  31 ++++++
 gnu/packages/patches/lua-5.4-pkgconfig.patch | 106 +++++++++++++++++++
 3 files changed, 149 insertions(+)
 create mode 100644 gnu/packages/patches/lua-5.4-liblua-so.patch
 create mode 100644 gnu/packages/patches/lua-5.4-pkgconfig.patch

diff --git a/gnu/packages/lua.scm b/gnu/packages/lua.scm
index ff4d4824eb..99f09a26f1 100644
--- a/gnu/packages/lua.scm
+++ b/gnu/packages/lua.scm
@@ -105,6 +105,18 @@ (define-public lua
 for configuration, scripting, and rapid prototyping.")
     (license license:x11)))
 
+(define-public lua-5.4
+  (package (inherit lua)
+           (version "5.4.3")
+           (source (origin
+                     (method url-fetch)
+                     (uri (string-append "https://www.lua.org/ftp/lua-"
+                                         version ".tar.gz"))
+                     (sha256
+                      (base32 "1yxvjvnbg4nyrdv10bq42gz6dr66pyan28lgzfygqfwy2rv24qgq"))
+                     (patches (search-patches "lua-5.4-pkgconfig.patch"
+                                              "lua-5.4-liblua-so.patch"))))))
+
 (define-public lua-5.2
   (package (inherit lua)
            (version "5.2.4")
diff --git a/gnu/packages/patches/lua-5.4-liblua-so.patch b/gnu/packages/patches/lua-5.4-liblua-so.patch
new file mode 100644
index 0000000000..0f35887012
--- /dev/null
+++ b/gnu/packages/patches/lua-5.4-liblua-so.patch
@@ -0,0 +1,31 @@
+--- a/src/Makefile	2021-02-09 18:47:17.000000000 +0000
++++ b/src/Makefile	2022-01-03 11:30:36.964501941 +0000
+@@ -33,6 +33,7 @@
+ PLATS= guess aix bsd c89 freebsd generic 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.
+@@ -56,6 +57,11 @@
+ 
+ a:	$(ALL_A)
+ 
++$(LUA_SO): $(CORE_O) $(LIB_O)
++	$(CC) -shared -ldl -Wl,-soname,$(LUA_SO).$(V) -o $@.$(R) $? -lm $(MYLDFLAGS)
++	ln -sf $(LUA_SO).$(R) $(LUA_SO).$(V)
++	ln -sf $(LUA_SO).$(R) $(LUA_SO)
++
+ $(LUA_A): $(BASE_O)
+ 	$(AR) $@ $(BASE_O)
+ 	$(RANLIB) $@
diff --git a/gnu/packages/patches/lua-5.4-pkgconfig.patch b/gnu/packages/patches/lua-5.4-pkgconfig.patch
new file mode 100644
index 0000000000..0a80cef9db
--- /dev/null
+++ b/gnu/packages/patches/lua-5.4-pkgconfig.patch
@@ -0,0 +1,106 @@
+--- a/Makefile	2022-01-03 12:06:37.760402709 +0000
++++ b/Makefile	2022-01-03 12:06:49.568402167 +0000
+@@ -14,6 +14,7 @@
+ INSTALL_BIN= $(INSTALL_TOP)/bin
+ INSTALL_INC= $(INSTALL_TOP)/include
+ INSTALL_LIB= $(INSTALL_TOP)/lib
++INSTALL_PC= $(INSTALL_LIB)/pkgconfig
+ INSTALL_MAN= $(INSTALL_TOP)/man/man1
+ INSTALL_LMOD= $(INSTALL_TOP)/share/lua/$V
+ INSTALL_CMOD= $(INSTALL_TOP)/lib/lua/$V
+@@ -39,9 +40,12 @@
+ PLATS= guess aix bsd c89 freebsd generic linux linux-readline macosx mingw posix solaris
+ 
+ # What to install.
+-TO_BIN= lua luac
++INTERPRETER= lua
++COMPILER= luac
++TO_BIN= $(INTERPRETER) $(COMPILER)
+ TO_INC= lua.h luaconf.h lualib.h lauxlib.h lua.hpp
+-TO_LIB= liblua.a
++TO_LIB= liblua.a liblua.so liblua.so.${V}
++TO_PC=  lua-$(V).pc
+ TO_MAN= lua.1 luac.1
+ 
+ # Lua version and release.
+@@ -51,20 +55,26 @@
+ # Targets start here.
+ all:	$(PLAT)
+ 
+-$(PLATS) help test clean:
+-	@cd src && $(MAKE) $@
++$(PLATS):
++	@cd src && $(MAKE) $@ V=$(V) R=$(R)
+ 
+-install: dummy
+-	cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
++clean:
++	cd src && $(MAKE) $@
++	$(RM) $(TO_PC)
++	
++install: dummy $(TO_PC)
++	cd src && $(MKDIR) $(INSTALL_BIN) $(INSTALL_INC) $(INSTALL_LIB) $(INSTALL_PC) $(INSTALL_MAN) $(INSTALL_LMOD) $(INSTALL_CMOD)
+ 	cd src && $(INSTALL_EXEC) $(TO_BIN) $(INSTALL_BIN)
+ 	cd src && $(INSTALL_DATA) $(TO_INC) $(INSTALL_INC)
+-	cd src && $(INSTALL_DATA) $(TO_LIB) $(INSTALL_LIB)
++	cd src && $(INSTALL_EXEC) $(TO_LIB) $(INSTALL_LIB)
++	cd src && $(INSTALL_DATA) ../$(TO_PC) $(INSTALL_PC)
+ 	cd doc && $(INSTALL_DATA) $(TO_MAN) $(INSTALL_MAN)
+ 
+ uninstall:
+ 	cd src && cd $(INSTALL_BIN) && $(RM) $(TO_BIN)
+ 	cd src && cd $(INSTALL_INC) && $(RM) $(TO_INC)
+ 	cd src && cd $(INSTALL_LIB) && $(RM) $(TO_LIB)
++	cd src && cd $(INSTALL_PC)  && $(RM) $(TO_PC)
+ 	cd doc && cd $(INSTALL_MAN) && $(RM) $(TO_MAN)
+ 
+ local:
+@@ -82,11 +92,13 @@
+ 	@echo "TO_BIN= $(TO_BIN)"
+ 	@echo "TO_INC= $(TO_INC)"
+ 	@echo "TO_LIB= $(TO_LIB)"
++	@echo "TO_PC= $(TO_PC)"
+ 	@echo "TO_MAN= $(TO_MAN)"
+ 	@echo "INSTALL_TOP= $(INSTALL_TOP)"
+ 	@echo "INSTALL_BIN= $(INSTALL_BIN)"
+ 	@echo "INSTALL_INC= $(INSTALL_INC)"
+ 	@echo "INSTALL_LIB= $(INSTALL_LIB)"
++	@echo "INSTALL_PC= $(INSTALL_PC)"
+ 	@echo "INSTALL_MAN= $(INSTALL_MAN)"
+ 	@echo "INSTALL_LMOD= $(INSTALL_LMOD)"
+ 	@echo "INSTALL_CMOD= $(INSTALL_CMOD)"
+@@ -95,12 +107,29 @@
+ 
+ # Echo pkg-config data.
+ pc:
+-	@echo "version=$R"
+-	@echo "prefix=$(INSTALL_TOP)"
+-	@echo "libdir=$(INSTALL_LIB)"
+-	@echo "includedir=$(INSTALL_INC)"
++	@echo 'prefix=$(INSTALL_TOP)'
++	@echo 'libdir=$(INSTALL_LIB)'
++	@echo 'includedir=$(INSTALL_INC)'
++	@echo 'bindir=$(INSTALL_BIN)'
++	@echo
++	@echo 'INSTALL_LMOD=$(INSTALL_LMOD)'
++	@echo 'INSTALL_CMOD=$(INSTALL_CMOD)'
++	@echo 'INTERPRETER=$${bindir}/$(INTERPRETER)'
++	@echo 'COMPILER=$${bindir}/$(COMPILER)'
++	@echo
++	@echo 'Name: Lua'
++	@echo 'Description: A powerful, fast, lightweight, embeddable scripting language'
++	@echo 'Version: $(R)'
++	@echo
++	@echo 'Libs: -L$${libdir} -llua -lm'
++	@echo 'Cflags: -I$${includedir}'
++
++pkg-config: $(TO_PC)
++$(TO_PC):
++	@$(MAKE) -s pc > $@
++	
+ 
+ # Targets that do not create files (not all makes understand .PHONY).
+-.PHONY: all $(PLATS) help test clean install uninstall local dummy echo pc
++.PHONY: all $(PLATS) help test clean install uninstall local dummy echo pc pkg-config
+ 
+ # (end of Makefile)
-- 
2.34.0