lua.SlackBuild 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #!/bin/bash
  2. # Slackware build script for Lua
  3. # Written by Menno Duursma
  4. # Modified by the SlackBuilds.org project
  5. # Modified by Aaron W. Hsu
  6. # Updated by Matteo Bernardini
  7. # This program is free software. It comes without any warranty.
  8. # Granted WTFPL, Version 2, as published by Sam Hocevar. See
  9. # http://sam.zoy.org/wtfpl/COPYING for more details.
  10. cd $(dirname $0) ; CWD=$(pwd)
  11. PRGNAM=lua
  12. VERSION=${VERSION:-5.1.5}
  13. BUILD=${BUILD:-1}
  14. TAG=${TAG:-_SBo}
  15. PKGTYPE=${PKGTYPE:-tgz}
  16. if [ -z "$ARCH" ]; then
  17. case "$( uname -m )" in
  18. i?86) ARCH=i586 ;;
  19. arm*) ARCH=arm ;;
  20. *) ARCH=$( uname -m ) ;;
  21. esac
  22. fi
  23. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  24. # the name of the created package would be, and then exit. This information
  25. # could be useful to other scripts.
  26. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  27. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  28. exit 0
  29. fi
  30. TMP=${TMP:-/tmp/SBo}
  31. PKG=$TMP/package-$PRGNAM
  32. OUTPUT=${OUTPUT:-/tmp}
  33. if [ "$ARCH" = "i586" ]; then
  34. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  35. LIBDIRSUFFIX=""
  36. elif [ "$ARCH" = "i686" ]; then
  37. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  38. LIBDIRSUFFIX=""
  39. elif [ "$ARCH" = "x86_64" ]; then
  40. SLKCFLAGS="-O2 -fPIC"
  41. LIBDIRSUFFIX="64"
  42. fi
  43. set -e
  44. rm -rf $PKG
  45. mkdir -p $TMP $PKG $OUTPUT
  46. cd $TMP
  47. rm -rf $PRGNAM-$VERSION
  48. tar xvf $CWD/$PRGNAM-${VERSION}.tar.gz
  49. cd $PRGNAM-$VERSION
  50. chown -R root:root .
  51. # Fix up a to-be-installed header and the pkgconfig file
  52. sed -i "s|/usr/local|/usr|" src/luaconf.h
  53. sed -i "s|lib/lua|lib$LIBDIRSUFFIX/lua|" src/luaconf.h
  54. sed -i "s|/usr/local|/usr|" etc/lua.pc
  55. sed -i "s|prefix}/lib|prefix}/lib${LIBDIRSUFFIX}|g" etc/lua.pc
  56. make linux \
  57. CFLAGS="$SLKCFLAGS \$(MYCFLAGS)" \
  58. INSTALL_TOP=/usr \
  59. INSTALL_LIB=/usr/lib${LIBDIRSUFFIX} \
  60. INSTALL_LMOD=/usr/share/lua/5.1 \
  61. INSTALL_CMOD=/usr/lib${LIBDIRSUFFIX}/lua/5.1
  62. make linux install \
  63. CFLAGS="$SLKCFLAGS \$(MYCFLAGS)" \
  64. INSTALL_TOP=$PKG/usr \
  65. INSTALL_LIB=$PKG/usr/lib${LIBDIRSUFFIX} \
  66. INSTALL_LMOD=$PKG/usr/share/lua/5.1 \
  67. INSTALL_CMOD=$PKG/usr/lib${LIBDIRSUFFIX}/lua/5.1
  68. # Now let's build the shared library
  69. mkdir -p shared
  70. cd shared
  71. ar -x $PKG/usr/lib${LIBDIRSUFFIX}/liblua.a
  72. gcc -ldl -lreadline -lhistory -lncurses -lm -shared *.o -o liblua.so.$VERSION
  73. cp -a liblua.so.$VERSION $PKG/usr/lib${LIBDIRSUFFIX}
  74. ( cd $PKG/usr/lib${LIBDIRSUFFIX}
  75. ln -s liblua.so.$VERSION liblua.so.5.1
  76. ln -s liblua.so.$VERSION liblua.so.5
  77. ln -s liblua.so.$VERSION liblua.so
  78. )
  79. cd ..
  80. # and install the pkgconfig file
  81. mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig
  82. cat etc/lua.pc > $PKG/usr/lib${LIBDIRSUFFIX}/pkgconfig/lua.pc
  83. find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
  84. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  85. find $PKG/usr/man -type f -exec gzip -9 {} \;
  86. for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
  87. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION/{extras,html}
  88. cp -a COPYRIGHT HISTORY INSTALL README $PKG/usr/doc/$PRGNAM-$VERSION
  89. cp -a doc/*.html doc/logo.gif doc/lua.css $PKG/usr/doc/$PRGNAM-$VERSION/html
  90. cp -a etc test $PKG/usr/doc/$PRGNAM-$VERSION/extras
  91. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  92. mkdir -p $PKG/install
  93. cat $CWD/slack-desc > $PKG/install/slack-desc
  94. cd $PKG
  95. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE