# Lua 5.4.7 (2024-06-xx)
# =========
# Release date June 2024
# (The source README and web site download page say 2024-06-13
# The Version history page and lua-l announcement say 2024-06-25)
# As of 2024-07-01, Slackware-current|Slackware64-current includes a 'lua'
# package
# Below are instructions for installing Lua. Some things that support Lua
# that I have HOWTOs for are:
#
# kdelibs
# links-lua
# swig
# Nmap
# Wireshark
# xapian-bindings
#
# For a list of lots more, see this page at the Lua site.
# Get the tarball
cd
test -f installed/lua-5.4.7.tar.gz && mv installed/lua-5.4.7.tar.gz .
test ! -f lua-5.4.7.tar.gz &&
wget https://www.lua.org/ftp/lua-5.4.7.tar.gz
# Change lib to lib64 in a few places to avoid having to use
# INSTALL_LIB, INSTALL_CMOD and update src/luaconf.h
# The patch for 5.4.6 works for 5.4.7 too
wget -nc https://englanders.us/pub/linux/patches/lua-5.4.6.patch &&
patch -p1 < lua-5.4.6.patch
# Run this to see how everything is configured
make echo
# If you want lua to search in /usr and /usr/local you will also need to
# update src/luaconf.h for that. See the following Slackware patch:
# http://ftp.slackware.com/pub/slackware/slackware64-current/source/d/lua/
# lua.usr.local.patch
# Build Lua for Linux with readline support, 64-bit
test $(uname -m) = 'x86_64' &&
make linux-readline MYLIBS=-ltermcap \
MYCFLAGS="-O2 -march=x86-64 -mtune=generic -fPIC"
# Build Lua for Linux with readline support, anything else
test $(uname -m) != 'x86_64' &&
make linux-readline MYLIBS=-ltermcap \
MYCFLAGS="-O2"
# Test the build
# (runs 'src/lua -v')
make test
# Build the shared library (optional)
mkdir shared && cd shared
ar -x ../src/liblua.a
gcc -ldl -lreadline -lhistory -lncurses -lm -shared \
-Wl,-soname,liblua.so.5 *.o -o liblua.so.5
cd ..
# Become root to install it
su
# Old files from previous versions would be here, if you need to clean
# up anything, or need to make note of anything Lua-based that needs to
# be rebuilt:
#
# /usr/local/bin/{lua,luac}
# /usr/local/include/{luaconf.h,lualib.h,lauxlib.h,lua.hpp}
# /usr/local/lib64/lua/
# /usr/local/lib64/liblua.a
# /usr/local/man/man1/{lua.1,luac.1}
# /usr/local/share/lua/x.x/
# Install it
make install
# Install the shared library, if you compiled it
test -f shared/liblua.so.5 &&
(test $(uname -m) = 'x86_64' &&
install -m 755 shared/liblua.so.5 /usr/local/lib64/ &&
cd /usr/local/lib64 &&
ln -s liblua.so.5 liblua.so
test $(uname -m) != 'x86_64' &&
install -m 755 shared/liblua.so.5 /usr/local/lib/ &&
cd /usr/local/lib &&
ln -s liblua.so.5 liblua.so )
ldconfig
# If you installed the shared library, you may or may not want to remove
# the static one
rm -f /usr/local/lib*/liblua.a
# Manually create a pkg-config .pc file using 'make pc' and adding to it
make pc > lua.pc
echo >> lua.pc
echo "Name: Lua" >> lua.pc
echo "Description: Fast, lightweight, embeddable scripting language" \
>> lua.pc
echo "Version: \${version}" >> lua.pc
echo "Libs: -L\${libdir} -llua -lm" >> lua.pc
echo "Cflags: -I\${includedir}" >> lua.pc
echo "URL: https://www.lua.org/" >> lua.pc
test -s lua.pc &&
(test $(uname -m) = 'x86_64' &&
test -d /usr/local/lib64/pkgconfig &&
cp lua.pc /usr/local/lib64/pkgconfig/
test $(uname -m) != 'x86_64' &&
test -d /usr/local/lib/pkgconfig &&
cp lua.pc /usr/local/lib/pkgconfig/ )
# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .
# Become your non-root user again
exit
# Save the source for later
cd
mkdir -p -m 0700 installed
rm -f installed/lua-*.tar.*
mv lua-5.4.7.tar.gz installed/
# If you ever want to uninstall Lua, this should do it:
su
( /usr/local/bin ; rm -f lua luac )
( cd /usr/local/include
rm -f lua.h luaconf.h lualib.h lauxlib.h lua.hpp )
( cd /usr/local/lib ; rm -f liblua.* liblualib.* )
( cd /usr/local/lib64 ; rm -f liblua.* liblualib.* )
test -d /usr/local/lib/lua && rm -r /usr/local/lib/lua
test -d /usr/local/lib64/lua && rm -r /usr/local/lib64/lua
( cd /usr/local/man/man1 ; rm -f lua.1 luac.1 )
test -d /usr/local/share/lua && rm -r /usr/local/share/lua
ldconfig
exit
find ~/src -maxdepth 1 -type d -name "lua-*" -exec rm -r {} \;
rm -f ~/installed/lua-*.tar.*