{
    "name": "lua-5.1",
    "buildsystem": "simple",
    "build-commands": [
        "make -j $FLATPAK_BUILDER_N_JOBS CFLAGS=\"$CFLAGS -fPIC -DLUA_USE_LINUX\" linux",
        "make INSTALL_TOP=$FLATPAK_DEST TO_LIB='liblua.a liblua.so.5.1.5' install",
        "ln -sf liblua.so.5.1.5 $FLATPAK_DEST/lib/liblua.so",
        "ln -sf liblua.so.5.1.5 $FLATPAK_DEST/lib/liblua.so.5.1",
        "install -Dm0644 etc/lua.pc $FLATPAK_DEST/lib/pkgconfig/lua.pc",
        "ln -sf lua.pc $FLATPAK_DEST/lib/pkgconfig/lua51.pc",
        "ln -sf lua.pc $FLATPAK_DEST/lib/pkgconfig/lua5.1.pc",
        "ln -sf lua.pc $FLATPAK_DEST/lib/pkgconfig/lua-5.1.pc"
    ],
    "sources": [
        {
            "type": "archive",
            "url": "https://www.lua.org/ftp/lua-5.1.5.tar.gz",
            "sha256": "2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333"
        },
        {
            "type": "patch",
            "path": "lua-5.1.5-so.patch"
        },
        {
            "type": "patch",
            "path": "0004-Fix-stack-overflow-in-vararg-functions.patch"
        },
        {
            "type": "shell",
            "commands": [
                "sed -i \"s|/usr/local|$FLATPAK_DEST|\" etc/lua.pc src/luaconf.h"
            ]
        }
    ],
    "cleanup": [
        "*.a",
        "/bin",
        "/include",
        "/lib/pkgconfig",
        "/man"
    ]
}
