
https://blog.spreendigital.de/2020/05/24/how-to-compile-lua-5-4-0-for-linux-as-a-shared-library/

1. Download and extract the Lua 5.4.0 source code

2. Edit the src/makefile and add the last line shown below “$(CC) -shared..” directly under the “$(RANLIB) $@” line. Be sure to use TAB for spacing!

$(LUA_A): $(BASE_O)
	$(AR) $@ $(BASE_O)
	$(RANLIB) $@
	$(CC) -shared -ldl -Wl,-soname,liblua$R.so -o liblua$R.so $? -lm $(MYLDFLAGS)
 
3. Open a terminal, navigate to the base folder and run

make "MYCFLAGS=-fPIC" "R=5.4.0"

You should now have a liblua5.4.0.so shared library in the src/ folder. 
