diff options
author | Eric Hameleers <alien@slackware.com> | 2021-11-10 13:58:19 +0000 |
---|---|---|
committer | Eric Hameleers <alien@slackware.com> | 2021-11-10 13:58:19 +0000 |
commit | f239206250a57911384276fe9d0c679af2bdd9cc (patch) | |
tree | c03b6f6b8a237ad33f5329bdc2067f7e3e847324 /lua53/build | |
parent | 69f517494b8d5af1ddf168344f16cd22a629fa42 (diff) | |
download | asb-f239206250a57911384276fe9d0c679af2bdd9cc.tar.gz asb-f239206250a57911384276fe9d0c679af2bdd9cc.tar.xz |
Initial revision
Diffstat (limited to 'lua53/build')
-rw-r--r-- | lua53/build/lua.pc.in | 22 | ||||
-rwxr-xr-x | lua53/build/lua53.SlackBuild | 240 | ||||
-rw-r--r-- | lua53/build/patches/lua_shared.patch | 60 | ||||
-rw-r--r-- | lua53/build/slack-desc | 19 |
4 files changed, 341 insertions, 0 deletions
diff --git a/lua53/build/lua.pc.in b/lua53/build/lua.pc.in new file mode 100644 index 00000000..57bff4c8 --- /dev/null +++ b/lua53/build/lua.pc.in @@ -0,0 +1,22 @@ +V= @MAJVER@ +R= @VERSION@ + +prefix= /usr +INSTALL_BIN= ${prefix}/bin +INSTALL_INC= ${prefix}/include/lua${V} +INSTALL_LIB= ${prefix}/lib@LIBDIRSUFFIX@ +INSTALL_MAN= ${prefix}/man/man1 +INSTALL_LMOD= ${prefix}/share/lua/${V} +INSTALL_CMOD= ${prefix}/lib@LIBDIRSUFFIX@/lua/${V} + +# canonical vars +exec_prefix=${prefix} +libdir=${exec_prefix}/lib@LIBDIRSUFFIX@ +includedir=${prefix}/include/lua${V} + +Name: Lua +Description: An Extensible Extension Language +Version: ${R} +Requires: +Libs: -L${libdir} -llua${V} -lm +Cflags: -I${includedir} diff --git a/lua53/build/lua53.SlackBuild b/lua53/build/lua53.SlackBuild new file mode 100755 index 00000000..702f21fb --- /dev/null +++ b/lua53/build/lua53.SlackBuild @@ -0,0 +1,240 @@ +#!/bin/sh +# $Id$ +# Copyright 2021 Eric Hameleers, Eindhoven, NL +# All rights reserved. +# +# Permission to use, copy, modify, and distribute this software for +# any purpose with or without fee is hereby granted, provided that +# the above copyright notice and this permission notice appear in all +# copies. +# +# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR +# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF +# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT +# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# ----------------------------------------------------------------------------- +# +# Slackware SlackBuild script +# =========================== +# By: Eric Hameleers <alien@slackware.com> +# For: lua53 +# Descr: lightweight embeddable programming language +# URL: https://www.lua.org/ +# Build needs: +# Needs: +# Changelog: +# 5.3.6-1: 10/nov/2021 by Eric Hameleers <alien@slackware.com> +# * Initial build. This package will not conflict with +# earlier versions of Lua which may be installed; +# Lua 5.1 is still widely used. +# +# Run 'sh lua53.SlackBuild' to build a Slackware package. +# The package (.t?z) and .txt file as well as build logs are created in /tmp . +# Install the package using 'installpkg' or 'upgradepkg --install-new'. +# +# ----------------------------------------------------------------------------- + +PRGNAM=lua53 +SRCNAM=lua +VERSION=${VERSION:-5.3.6} +MAJVER=$(echo $VERSION |cut -d. -f1,2) +BUILD=${BUILD:-1} +TAG=${TAG:-alien} + +DOCS="README*" + +# Where do we look for sources? +SRCDIR=$(cd $(dirname $0); pwd) + +# Place to build (TMP) package (PKG) and output (OUTPUT) the program: +TMP=${TMP:-/tmp/build} +PKG=$TMP/package-$PRGNAM +OUTPUT=${OUTPUT:-/tmp} + +SOURCE="$SRCDIR/${SRCNAM}-${VERSION}.tar.gz" +SRCURL="https://www.lua.org/ftp/${SRCNAM}-${VERSION}.tar.gz" + +## +## --- with a little luck, you won't have to edit below this point --- ## +## + +# Automatically determine the architecture we're building on: +if [ -z "$ARCH" ]; then + case "$(uname -m)" in + i?86) ARCH=i586 ;; + arm*) readelf /usr/bin/file -A | egrep -q "Tag_CPU.*[4,5]" && ARCH=arm || ARCH=armv7hl ;; + # Unless $ARCH is already set, use uname -m for all other archs: + *) ARCH=$(uname -m) ;; + esac + export ARCH +fi +# Set CFLAGS/CXXFLAGS and LIBDIRSUFFIX: +case "$ARCH" in + i?86) SLKCFLAGS="-O2 -march=${ARCH} -mtune=i686" + SLKLDFLAGS=""; LIBDIRSUFFIX="" + ;; + x86_64) SLKCFLAGS="-O2 -fPIC" + SLKLDFLAGS="-L/usr/lib64"; LIBDIRSUFFIX="64" + ;; + armv7hl) SLKCFLAGS="-O2 -march=armv7-a -mfpu=vfpv3-d16" + SLKLDFLAGS=""; LIBDIRSUFFIX="" + ;; + *) SLKCFLAGS=${SLKCFLAGS:-"-O2"} + SLKLDFLAGS=${SLKLDFLAGS:-""}; LIBDIRSUFFIX=${LIBDIRSUFFIX:-""} + ;; +esac + +case "$ARCH" in + arm*) TARGET=$ARCH-slackware-linux-gnueabi ;; + *) TARGET=$ARCH-slackware-linux ;; +esac + +# Exit the script on errors: +set -e +trap 'echo "$0 FAILED at line ${LINENO}" | tee $OUTPUT/error-${PRGNAM}.log' ERR +# Catch unitialized variables: +set -u +P1=${1:-1} + +# Save old umask and set to 0022: +_UMASK_=$(umask) +umask 0022 + +# Create working directories: +mkdir -p $OUTPUT # place for the package to be saved +mkdir -p $TMP/tmp-$PRGNAM # location to build the source +mkdir -p $PKG # place for the package to be built +rm -rf $PKG/* # always erase old package's contents +rm -rf $TMP/tmp-$PRGNAM/* # remove the remnants of previous build +rm -rf $OUTPUT/{checkout,configure,make,install,error,makepkg,patch}-$PRGNAM.log + # remove old log files + +# Source file availability: +if ! [ -f ${SOURCE} ]; then + echo "Source '$(basename ${SOURCE})' not available yet..." + # Check if the $SRCDIR is writable at all - if not, download to $OUTPUT + [ -w "$SRCDIR" ] || SOURCE="$OUTPUT/$(basename $SOURCE)" + if [ -f ${SOURCE} ]; then echo "Ah, found it!"; continue; fi + if ! [ "x${SRCURL}" == "x" ]; then + echo "Will download file to $(dirname $SOURCE)" + wget --no-check-certificate -nv -T 20 -O "${SOURCE}" "${SRCURL}" || true + if [ $? -ne 0 -o ! -s "${SOURCE}" ]; then + echo "Downloading '$(basename ${SOURCE})' failed... aborting the build." + mv -f "${SOURCE}" "${SOURCE}".FAIL + exit 1 + fi + else + echo "File '$(basename ${SOURCE})' not available... aborting the build." + exit 1 + fi +fi + +if [ "$P1" == "--download" ]; then + echo "Download complete." + exit 0 +fi + +# --- PACKAGE BUILDING --- + +echo "++" +echo "|| $PRGNAM-$VERSION" +echo "++" + +cd $TMP/tmp-$PRGNAM +echo "Extracting the source archive(s) for $PRGNAM..." +tar -xvf ${SOURCE} +cd ${SRCNAM}-${VERSION} + +# We want a shared library as well (Arch Linux patch): +cat $SRCDIR/patches/lua_shared.patch | patch -p1 --verbose \ + 2>&1 | tee $OUTPUT/configure-${PRGNAM}.log + +# Fix the libdir: +sed -i src/luaconf.h \ + -e "s%lib/lua%lib${LIBDIRSUFFIX}/lua%" + +# Rename the binaries to avoid conflict: +sed -r -i src/Makefile \ + -e "/^LUA_(SO|A|T)=/ s/lua/lua$MAJVER/" \ + -e "/^LUAC_T=/ s/luac/luac$MAJVER/" + +chown -R root:root . +chmod -R u+w,go+r-w,a+rX-st . + +echo Building ... +export LDFLAGS="$SLKLDFLAGS" +export CXXFLAGS="$SLKCFLAGS" +export CFLAGS="$SLKCFLAGS" +make linux \ + MYCFLAGS="$SLKCFLAGS -DLUA_COMPAT_5_2 -DLUA_COMPAT_5_1" \ + MYLDFLAGS="$SLKLDFLAGS" \ + MYLIBS="-lncurses" \ + 2>&1 | tee $OUTPUT/make-${PRGNAM}.log +make linux install \ + TO_BIN="lua${MAJVER} luac${MAJVER}" \ + TO_LIB="liblua${MAJVER}.a liblua${MAJVER}.so liblua${MAJVER}.so.${MAJVER} liblua${MAJVER}.so.${VERSION}" \ + INSTALL_DATA="cp -d" \ + INSTALL_TOP="$PKG/usr" \ + INSTALL_LIB="$PKG/usr/lib${LIBDIRSUFFIX}" \ + INSTALL_CMOD="$PKG/usr/lib${LIBDIRSUFFIX}/lua/${MAJVER}" \ + INSTALL_INC="$PKG/usr/include/lua${MAJVER}" \ + 2>&1 | tee $OUTPUT/install-${PRGNAM}.log + +# Don't ship .la files: +rm -f $PKG/{,usr/}lib${LIBDIRSUFFIX}/*.la + +# Add a pkgconfig file: +mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig +cat $SRCDIR/${SRCNAM}.pc.in | sed \ + -e 's/@VERSION@/$VERSION/g' \ + -e 's/@MAJVER@/$MAJVER/g' \ + -e 's/@LIBDIRSUFFIX@/$LIBDIRSUFFIX/g' \ + > $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig/${PRGNAM}.pc +ln -s ${PRGNAM}.pc $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig/${SRCNAM}${MAJVER}.pc +ln -s ${PRGNAM}.pc $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig/${SRCNAM}-${MAJVER}.pc + +# Add documentation: +mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION +cp -a $DOCS $PKG/usr/doc/$PRGNAM-$VERSION || true +cat $SRCDIR/$(basename $0) > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild +chown -R root:root $PKG/usr/doc/$PRGNAM-$VERSION +find $PKG/usr/doc -type f -exec chmod 644 {} \; + +if [ -d $PKG/usr/man ]; then + # Rename the man pages so that they don't conflict with other packages: + cd $PKG/usr/man/man1 + mv lua.1 lua${MAJVER}.1 + mv luac.1 luac${MAJVER}.1 + cd - >/dev/null + # Compress the man page(s): + find $PKG/usr/man -type f -name "*.?" -exec gzip -9f {} \; + for i in $(find $PKG/usr/man -type l -name "*.?") ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done +fi + +# Strip binaries (if any): +find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \ + | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true + +# Add a package description: +mkdir -p $PKG/install +cat $SRCDIR/slack-desc > $PKG/install/slack-desc + +# Build the package: +cd $PKG +makepkg --linkadd y --chown n $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE:-txz} 2>&1 | tee $OUTPUT/makepkg-${PRGNAM}.log +cd $OUTPUT +md5sum ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE:-txz} > ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE:-txz}.md5 +cd - +cat $PKG/install/slack-desc | grep "^${PRGNAM}" > $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.txt + +# Restore the original umask: +umask ${_UMASK_} + diff --git a/lua53/build/patches/lua_shared.patch b/lua53/build/patches/lua_shared.patch new file mode 100644 index 00000000..f9e24f32 --- /dev/null +++ b/lua53/build/patches/lua_shared.patch @@ -0,0 +1,60 @@ +diff --git a/Makefile b/Makefile +index 7fa91c8..dccf485 100644 +--- a/Makefile ++++ b/Makefile +@@ -52,7 +52,7 @@ R= $V.0 + all: $(PLAT) + + $(PLATS) clean: +- cd src && $(MAKE) $@ ++ cd src && $(MAKE) $@ V=$(V) R=$(R) + + test: dummy + src/lua -v +diff --git a/src/Makefile b/src/Makefile +index 2e7a412..fa5769f 100644 +--- a/src/Makefile ++++ b/src/Makefile +@@ -29,6 +29,7 @@ MYOBJS= + PLATS= aix bsd c89 freebsd generic linux 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 +@@ -43,7 +44,7 @@ LUAC_T= luac + 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. +@@ -59,6 +60,12 @@ $(LUA_A): $(BASE_O) + $(AR) $@ $(BASE_O) + $(RANLIB) $@ + ++$(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_T): $(LUA_O) $(LUA_A) + $(CC) -o $@ $(LDFLAGS) $(LUA_O) $(LUA_A) $(LIBS) + +diff --git a/src/luaconf.h b/src/luaconf.h +index fd28d21..e2662cc 100644 +--- a/src/luaconf.h ++++ b/src/luaconf.h +@@ -175,7 +175,7 @@ + + #else /* }{ */ + +-#define LUA_ROOT "/usr/local/" ++#define LUA_ROOT "/usr/" + #define LUA_LDIR LUA_ROOT "share/lua/" LUA_VDIR "/" + #define LUA_CDIR LUA_ROOT "lib/lua/" LUA_VDIR "/" + #define LUA_PATH_DEFAULT \ diff --git a/lua53/build/slack-desc b/lua53/build/slack-desc new file mode 100644 index 00000000..29d0c5e7 --- /dev/null +++ b/lua53/build/slack-desc @@ -0,0 +1,19 @@ +# HOW TO EDIT THIS FILE: +# The "handy ruler" below makes it easier to edit a package description. Line +# up the first '|' above the ':' following the base package name, and the '|' +# on the right side marks the last column you can put a character in. You must +# make exactly 11 lines for the formatting to be correct. It's also +# customary to leave one space after the ':' except on otherwise blank lines. + + |-----handy-ruler------------------------------------------------------| +lua53: lua53 (lightweight embeddable programming language) +lua53: +lua53: Lua combines simple procedural syntax with powerful data description +lua53: constructs based on associative arrays and extensible semantics. +lua53: Lua is dynamically typed, runs by interpreting bytecode for a +lua53: register-based virtual machine, and has automatic memory management +lua53: with incremental garbage collection, making it ideal for +lua53: configuration, scripting, and rapid prototyping. +lua53: This Lua 5.3 does not conflict with other installed versions of Lua. +lua53: +lua53: See also: https://www.lua.org/ |