recipes: lua/luarocks: Adjust build recipe, set for latest version
[dragora.git] / recipes / lua / lua5 / recipe
blob5dac45c9b8e0c36afed410099d756647c1f1ab4e
1 # Build recipe for lua.
3 # Copyright (C) 2020 Kevin "The Nuclear" Bloom, <kevin.bloom@posteo.net>.
4 # Copyright (c) 2020 Matias Fonzo, <selk@dragora.org>.
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
10 #    http://www.apache.org/licenses/LICENSE-2.0
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.
18 program=lua
19 version=5.3.5
20 short_version="${version%.*}"
21 release=5
23 # Set custom package name to avoid conflicts on package upgrades
24 pkgname="lua${short_version%.*}"
26 # Set 'outdir' for a nice and well-organized output directory
27 outdir="${outdir}/${arch}/lua"
29 tarname=${program}-${version}.tar.gz
31 # Remote source(s)
32 fetch=http://www.lua.org/ftp/${tarname}
34 description="
35 A lightweight programming language designed for extending applications.
37 Lua is a powerful, efficient, lightweight, embeddable scripting language.
38 It supports procedural programming, object-oriented programming, functional
39 programming, data-driven programming, and data description.
42 homepage=http://www.lua.org/
43 license="MIT License"
45 # Source documentation
46 docs="doc/*.html doc/*.css doc/*.gif doc/*.png"
47 docsdir="${docdir}/${pkgname}-${version}"
49 _make_target()
51     make -j${jobs} \
52      MYCFLAGS="$QICFLAGS -DLUA_COMPAT_5_2 -DLUA_COMPAT_5_1" \
53      MYLDFLAGS="$QILDFLAGS" \
54      INSTALL_LIB="${destdir}/usr/lib${libSuffix}" \
55      INSTALL_LMOD="${destdir}/usr/share/lua/${short_version}" \
56      INSTALL_CMOD="${destdir}/usr/lib${libSuffix}/lua/${short_version}" \
57      INSTALL_DATA="cp -d" \
58      INSTALL_MAN="${destdir}/${mandir}/man1" \
59      INSTALL_TOP="${destdir}/usr" "$@"
62 build()
64     set -e
66     unpack "${tardir}/$tarname"
68     cd "$srcdir"
70     # Set sane permissions
71     chmod -R u+w,go-w,a+rX-s .
73     # Adjust Lua search path
74     sed \
75      -e 's#/usr/local/#/usr/#' \
76      -e "s#lib/lua#lib${libSuffix}/lua#" \
77      -i src/luaconf.h
79     # Fix release number
80     sed -i "/R= /s|\$V\.4|${version}|" Makefile
82     _make_target linux
83     _make_target install
85     # Now build the shared library
87     make clean
88     patch -Np1 -i "${worktree}/patches/lua/lua-5.3.5-shared_library-1.patch"
90     _make_target TO_LIB="liblua.so liblua.so.${short_version} liblua.so.${version}" linux
91     _make_target TO_LIB="liblua.so liblua.so.${short_version} liblua.so.${version}" install
93     unset make_target
95     # Install a pkg-config file
96     mkdir -p "${destdir}/usr/lib${libSuffix}/pkgconfig"
97     cat << EOF > "${destdir}/usr/lib${libSuffix}/pkgconfig/lua.pc"
98 prefix=/usr
99 INSTALL_BIN=\${prefix}/bin
100 INSTALL_INC=\${prefix}/include
101 INSTALL_LIB=\${prefix}/lib
102 INSTALL_MAN=\${prefix}/share/man/man1
103 INSTALL_LMOD=\${prefix}/share/lua/${short_version}
104 INSTALL_CMOD=\${prefix}/lib${libSuffix}/lua/${short_version}
105 exec_prefix=\${prefix}
106 libdir=\${exec_prefix}/lib${libSuffix}
107 includedir=\${prefix}/include
109 Name: Lua
110 Description: An Extensible Extension Language
111 Version: ${version}
112 Requires:
113 Libs: -L\${libdir} -llua -lm -ldl
114 Cflags: -I\${includedir}
117     unset short_version
119     # Compress manual page(s)
120     lzip -9 "${destdir}/${mandir}"/man1/*
122     # Copy documentation
123     mkdir -p "${destdir}${docsdir}"
124     cp -p $docs "${destdir}${docsdir}"