recipe 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. # Build recipe for lua.
  2. #
  3. # Copyright (C) 2020 Kevin "The Nuclear" Bloom, <kevin.bloom@posteo.net>.
  4. # Copyright (c) 2020-2022 Matias Fonzo, <selk@dragora.org>.
  5. #
  6. # Licensed under the Apache License, Version 2.0 (the "License");
  7. # you may not use this file except in compliance with the License.
  8. # You may obtain a copy of the License at
  9. #
  10. # http://www.apache.org/licenses/LICENSE-2.0
  11. #
  12. # Unless required by applicable law or agreed to in writing, software
  13. # distributed under the License is distributed on an "AS IS" BASIS,
  14. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. # See the License for the specific language governing permissions and
  16. # limitations under the License.
  17. # Exit immediately on any error
  18. set -e
  19. program=lua
  20. version=5.4.3
  21. short_version="${version%.*}"
  22. release=1
  23. # Set custom package name to avoid conflicts on package upgrades
  24. pkgname="lua${short_version%.*}"
  25. # Define a category for the output of the package name
  26. pkgcategory=lua
  27. tarname=${program}-${version}.tar.gz
  28. # Remote source(s)
  29. fetch=https://www.lua.org/ftp/${tarname}
  30. description="
  31. A lightweight programming language designed for extending applications.
  32. Lua is a powerful, efficient, lightweight, embeddable scripting language.
  33. It supports procedural programming, object-oriented programming, functional
  34. programming, data-driven programming, and data description.
  35. "
  36. homepage=https://www.lua.org/
  37. license="MIT License"
  38. # Source documentation
  39. docs="doc/*.html doc/*.css doc/*.gif doc/*.png"
  40. docsdir="${docdir}/${pkgname}-${version}"
  41. _make_target()
  42. {
  43. make -j${jobs} \
  44. MYCFLAGS="$QICFLAGS -DLUA_COMPAT_5_2 -DLUA_COMPAT_5_1 -fPIC" \
  45. MYLDFLAGS="$QILDFLAGS" \
  46. INSTALL_LIB="${destdir}/usr/lib${libSuffix}" \
  47. INSTALL_LMOD="${destdir}/usr/share/lua/${short_version}" \
  48. INSTALL_CMOD="${destdir}/usr/lib${libSuffix}/lua/${short_version}" \
  49. INSTALL_DATA="cp -d" \
  50. INSTALL_MAN="${destdir}/${mandir}/man1" \
  51. INSTALL_TOP="${destdir}/usr" "$@"
  52. }
  53. build()
  54. {
  55. unpack "${tardir}/$tarname"
  56. cd "$srcdir"
  57. # Set sane permissions
  58. chmod -R u+w,go-w,a+rX-s .
  59. patch -Np1 -i "${worktree}/patches/lua/lua-5.4.2-shared_library-1.patch"
  60. # Adjust Lua search path
  61. sed -e 's#/usr/local/#/usr/#' \
  62. -e "s#lib/lua#lib${libSuffix}/lua#" \
  63. -i src/luaconf.h
  64. _make_target linux
  65. _make_target install
  66. # Now build the shared library
  67. make clean
  68. _make_target TO_LIB="liblua.so liblua.so.${short_version} liblua.so.${version}" linux
  69. _make_target TO_LIB="liblua.so liblua.so.${short_version} liblua.so.${version}" install
  70. unset -v make_target
  71. # Strip remaining binaries and libraries
  72. find "$destdir" -type f | xargs file | \
  73. awk '/ELF/ && /executable/ || /shared object/' | \
  74. cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
  75. # Install a pkg-config file
  76. mkdir -p "${destdir}/usr/lib${libSuffix}/pkgconfig"
  77. cat << EOF > "${destdir}/usr/lib${libSuffix}/pkgconfig/lua.pc"
  78. prefix=/usr
  79. INSTALL_BIN=\${prefix}/bin
  80. INSTALL_INC=\${prefix}/include
  81. INSTALL_LIB=\${prefix}/lib
  82. INSTALL_MAN=\${prefix}/share/man/man1
  83. INSTALL_LMOD=\${prefix}/share/lua/${short_version}
  84. INSTALL_CMOD=\${prefix}/lib${libSuffix}/lua/${short_version}
  85. exec_prefix=\${prefix}
  86. libdir=\${exec_prefix}/lib${libSuffix}
  87. includedir=\${prefix}/include
  88. Name: Lua
  89. Description: An Extensible Extension Language
  90. Version: ${version}
  91. Requires:
  92. Libs: -L\${libdir} -llua -lm -ldl
  93. Cflags: -I\${includedir}
  94. EOF
  95. unset -v short_version
  96. # Compress manual page(s)
  97. lzip -9 "${destdir}/${mandir}"/man1/*
  98. # Copy documentation
  99. mkdir -p "${destdir}/$docsdir"
  100. cp -p $docs "${destdir}/$docsdir"
  101. }