summaryrefslogtreecommitdiff
path: root/devel/lua/MAKEPKG
blob: 940faebb9ec0ae70b2983d5fde26063bc0f62b32 (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
77
78
79
80
81
82
83
#!/bin/mkpkg
# description: Lightweight embeddable scripting language
# url: https://www.lua.org

name=lua
version=5.5.1
release=1
_basever=5.5
depends=()
source=(https://www.lua.org/ftp/$name-$version.tar.gz)

sha256sums=(
    "1c4b4068d67061f2a2231ad2b5422e77acea1487ea9890f6320af614f4373dce"
)

build() {
    cd $name-$version

    # patch Makefile for shared library and our flags
    sed -i src/Makefile \
        -e "s|^CC=.*|CC= ${CC:-cc}|" \
        -e "s|^CFLAGS=.*|CFLAGS= $CFLAGS -DLUA_COMPAT_5_3 -fPIC|" \
        -e "s|^MYCFLAGS=.*|MYCFLAGS=|" \
        -e "s|^MYLDFLAGS=.*|MYLDFLAGS= $LDFLAGS|"

    # build static lib and objects
    make -C src \
        SYSCFLAGS="-DLUA_USE_LINUX" \
        SYSLIBS="-ldl" \
        all

    # build shared library from objects (exclude lua.o and luac.o — binaries)
    objs=""
    for o in src/*.o; do
        case $o in */lua.o|*/luac.o) continue ;; esac
        objs="$objs $o"
    done
    ${CC:-cc} -shared -Wl,-soname,liblua.so.$_basever \
        -o src/liblua.so.$version $objs -lm -ldl

    make \
        INSTALL_TOP=$PKG/usr \
        INSTALL_MAN=$PKG/usr/share/man/man1 \
        install

    # shared library
    install -m 755 src/liblua.so.$version $PKG/usr/lib/liblua.so.$version
    ln -sf liblua.so.$version $PKG/usr/lib/liblua.so.$_basever
    ln -sf liblua.so.$version $PKG/usr/lib/liblua.so

    # pkg-config
    install -d $PKG/usr/lib/pkgconfig
    printf '%s\n' \
        "V=$_basever" \
        "R=$version" \
        '' \
        'prefix=/usr' \
        'exec_prefix=${prefix}' \
        'libdir=${exec_prefix}/lib' \
        'includedir=${prefix}/include' \
        '' \
        'Name: Lua' \
        'Description: An Extensible Extension Language' \
        'Version: ${R}' \
        'Libs: -L${libdir} -llua -lm -ldl' \
        'Cflags: -I${includedir}' \
        > $PKG/usr/lib/pkgconfig/lua.pc
    ln -sf lua.pc $PKG/usr/lib/pkgconfig/lua-$_basever.pc
    ln -sf lua.pc $PKG/usr/lib/pkgconfig/lua${_basever}.pc

    # remove static lib
    rm -f $PKG/usr/lib/liblua.a

    # remove html docs
    rm -rf $PKG/usr/share/doc
}

signify() {
    untrusted comment: public key
    RWTZ9IduCSQ/mL8337TEUinPwT92xFEUpD92hkS7IxcOnzTt9QdpohT3
}

# vim: filetype=sh