summaryrefslogtreecommitdiff
path: root/repo/lua/lua.xibuild
blob: 738241db54437bd2bb1cc88593cd179f07564ad7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/sh

MAKEDEPS="make "
DEPS="readline"

PKG_VER=5.4.4
SOURCE=https://www.lua.org/ftp/lua-$PKG_VER.tar.gz
ADDITIONAL="
    lua5.4.pc

CVE-2022-28805.patch
extern-c-for-cpp.patch
fix-double-free.patch
lua-5.4.4-shared_library-1.patch
    "

DESC="A powerful lightweight scripting language"

prepare () {
    apply_patches 
    sed -e "s|@MAJOR_VER@|${PKG_VER%.*}|g" \
		-e "s|@MINOR_VER@|${PKG_VER}|g" \
		-i lua5.4.pc

	cat > configure.ac <<-EOF
		top_buildir=.

		AC_INIT(src/luaconf.h)
		AC_PROG_LIBTOOL
		AC_OUTPUT()
	EOF
	libtoolize --force --install && aclocal && autoconf


}

build () {
    ./configure \
		--prefix=/usr
    cd src
        CFLAGS="$CFLAGS -DLUA_USE_LINUX -DLUA_COMPAT_5_2" \
		SYSLDFLAGS="$LDFLAGS" \
        LIB_LIBS="-lpthread -lm -ldl -lreadline" \
		RPATH="/usr/lib" make
}

package () {
    cd ..
    sed -i "s/INSTALL= install -p/INSTALL= install/g" Makefile
    mkdir -p $PKG_DEST/usr/lib
    mkdir -p $PKG_DEST/usr/bin
    make V=$PKG_VER \
		INSTALL_TOP="$PKG_DEST/usr" \
		INSTALL_INC="$PKG_DEST/usr/include" \
		INSTALL_LIB="$PKG_DEST/usr/lib" \
        install

    install -D -m 644 src/liblua.so.5.4.4.4 "$PKG_DEST"/usr/lib/liblua.so.5.4.4.4
    ln -sf liblua.so.5.4.4.4 $PKG_DEST/usr/lib/liblua.so.5.4.4
    ln -sf liblua.so.5.4.4.4 $PKG_DEST/usr/lib/liblua.so


    install -D -m 644 lua5.4.pc "$PKG_DEST"/usr/lib/pkgconfig/lua${PKG_VER%.*}.pc
	install -D -m 644 doc/lua.1 "$PKG_DEST"/usr/share/man/man1/lua$PKG_VER
	install -D -m 644 doc/luac.1 "$PKG_DEST"/usr/share/man/man1/luac$PKG_VER

	mkdir -p "$PKG_DEST"/usr/share/doc/lua5-3/
	install -m644 doc/*.html doc/*.css doc/logo.gif doc/cover.png \
		"$PKG_DEST"/usr/share/doc/lua5-3/

	ln -s lua${PKG_VER%.*} "$PKG_DEST"/usr/bin/lua
	ln -s luac${PKG_VER%.*}.a "$PKG_DEST"/usr/bin/luac
	ln -s lua${PKG_VER%.*}.pc "$PKG_DEST"/usr/lib/pkgconfig/lua.pc
	ln -s lua${PKG_VER} "$PKG_DEST"/usr/share/man/man1/lua.1
	ln -s luac${PKG_VER} "$PKG_DEST"/usr/share/man/man1/luac.1
}