0
Files
slackbuilds/lua/lua.SlackBuild
2023-11-19 18:01:40 +03:00

123 lines
4.1 KiB
Bash
Executable File

#!/bin/sh
# Slackware build script for lua
# Copyright 2023 Sergei Fedosoff <eleksir@gmail.com>
# All rights reserved.
#
# * Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# * Redistributions of source code must retain the above copyright notice
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED ''AS IS'' AND ANY EXPRESS 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
# COPYRIGHT HOLDER 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.
PRGNAM=lua
VERSION=${VERSION:-5.1.5}
BUILD=${BUILD:-2}
TAG=${TAG:-_EXs}
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
i?86) ARCH=i486 ;;
arm*) ARCH=arm ;;
*) ARCH=$( uname -m ) ;;
esac
fi
CWD=$(pwd)
TMP=${TMP:-/tmp/EXs}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
if [ "$ARCH" = "i486" ]; then
SLKCFLAGS="-O2 -march=i486 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC -rdynamic"
LIBDIRSUFFIX="64"
fi
set -e
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
tar xf $CWD/$PRGNAM-${VERSION}.tar.gz
cd $PRGNAM-$VERSION
chown -R root:root .
find -L . \
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 -o -perm 511 \) \
-exec chmod 755 {} \+ -o \
\( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
-exec chmod 644 {} \+
patch --verbose -p1 -i $CWD/path${LIBDIRSUFFIX}.patch
#sed -i 's/CFLAGS= -O2 -Wall $(MYCFLAGS)/CFLAGS= $(SLKCFLAGS) $(MYCFLAGS)/' src/Makefile
export SLKCFLAGS
export SLKLDFLAGS="-rdynamic -Wl,--export-dynamic -Wl,-E -Wl,--no-as-needed -Wl,-O2"
make -j$(nproc) linux \
INSTALL_TOP=/usr \
INSTALL_LIB=/usr/lib${LIBDIRSUFFIX} \
INSTALL_LMOD=/usr/share/lua/5.1 \
INSTALL_CMOD=/usr/lib${LIBDIRSUFFIX}/lua/5.1
make -j$(nproc) linux install \
INSTALL_TOP=$PKG/usr \
INSTALL_LIB=$PKG/usr/lib${LIBDIRSUFFIX} \
INSTALL_LMOD=$PKG/usr/share/lua/5.1 \
INSTALL_CMOD=$PKG/usr/lib${LIBDIRSUFFIX}/lua/5.1
# Now let's build the shared library
mkdir -p shared
cd shared
ar -x $PKG/usr/lib${LIBDIRSUFFIX}/liblua.a
gcc -ldl -lreadline -lhistory -lncurses -lm -shared *.o -o liblua.so.$VERSION
install -Dpm 0755 liblua.so.$VERSION $PKG/usr/lib${LIBDIRSUFFIX}
( cd $PKG/usr/lib${LIBDIRSUFFIX}
ln -s liblua.so.$VERSION liblua.so.5.1
ln -s liblua.so.$VERSION liblua.so.5
ln -s liblua.so.$VERSION liblua.so
)
cd ..
# and install the pkgconfig file
install -Dpm 0644 etc/lua.pc $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig/lua.pc
find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
find $PKG/usr/man -type f -exec gzip -9 {} \+
for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION/{extras,html}
cp -a COPYRIGHT HISTORY INSTALL README $PKG/usr/doc/$PRGNAM-$VERSION
cp -a doc/*.html doc/logo.gif doc/lua.css $PKG/usr/doc/$PRGNAM-$VERSION/html
cp -a etc test $PKG/usr/doc/$PRGNAM-$VERSION/extras
install -Dpm 0644 $CWD/$PRGNAM.SlackBuild $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
install -Dpm 0644 $CWD/slack-desc $PKG/install/slack-desc
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}