1 ################################################################################
3 # lua.cygclass - functions for installing Lua modules
5 # Part of cygport - Cygwin packaging application
6 # Copyright (C) 2006-2020 Cygport authors
7 # Provided by the Cygwin project <https://cygwin.com/>
9 # cygport is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
14 # cygport is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with cygport. If not, see <https://www.gnu.org/licenses/>.
22 ################################################################################
24 #****h* Cygclasses/lua.cygclass
28 # Lua is a lightweight programming language commonly used for embedded scripting
29 # support in a variety of programs. It is extensible through C/C++ modules
32 # This cygclass provides definitions used by packages depending on Lua.
37 # cross-compiling is not (yet?) supported
38 __cross_compiling_error
41 check_prog_req pkg-config
43 #****d* lua.cygclass/LUA
45 # Absolute path to the Lua interpreter.
49 #****d* lua.cygclass/LUAC
51 # Absolute path to the Lua bytecode compiler.
55 #****d* lua.cygclass/LUA_VERSION
57 # The major.minor version of the Lua interpreter.
59 LUA_VERSION=$(pkg-config --variable=V lua)
61 # FIXME: is this really needed for anything?
62 LUA_VERSION_NUM=${LUA_VERSION//./0}
64 #****d* lua.cygclass/LUA_INCLUDEDIR
66 # Path containing the Lua C library headers.
68 LUA_INCLUDEDIR=$(pkg-config --variable=INSTALL_INC lua)
70 #****d* lua.cygclass/LUA_LIBDIR
72 # Installation path for Lua C modules.
74 LUA_LIBDIR=$(pkg-config --variable=INSTALL_CMOD lua)
76 #****d* lua.cygclass/LUA_SCRIPTDIR
78 # Installation path for Lua script modules.
80 LUA_SCRIPTDIR=$(pkg-config --variable=INSTALL_LMOD lua)
82 #****d* lua.cygclass/LUA_CFLAGS
84 # Compile flags for the Lua C library.
86 LUA_CFLAGS=$(pkg-config --cflags lua)
88 #****d* lua.cygclass/LUA_LIBS
90 # Link flags for the Lua C library.
92 LUA_LIBS=$(pkg-config --libs lua)
94 #****I* lua.cygclass/luainto
96 # luainto SUBDIRECTORY
98 # Subdirectory of LUA_LIBDIR or LUA_SCRIPTDIR into which dolua should install.
99 # This is usually unnecessary.
104 error "luainto accepts exactly one argument";
108 /*) error "luainto argument should be only a subdirectory" ;;
114 #****I* lua.cygclass/dolua
116 # [luainto SUBDIRECTORY]
117 # dolua MODULE1 [MODULE2] ...
119 # Installs the given Lua module(s) (.lua or .dll) into LUA_LIBDIR or
120 # LUA_SCRIPTDIR under $D, depending on filetype, or a subdirectory thereof
121 # if luainto was previously called.
130 error "dolua: ${i}: file not found"
135 dodir ${LUA_LIBDIR}/${_luainto_dir}
136 __doinstall 0755 ${i} ${LUA_LIBDIR}/${_luainto_dir} || error "dolua ${i} failed"
139 dodir ${LUA_SCRIPTDIR}/${_luainto_dir}
140 __doinstall 0644 ${i} ${LUA_SCRIPTDIR}/${_luainto_dir} || error "dolua ${i} failed"
146 #****I* lua.cygclass/lua_fix_shebang
148 # lua_fix_shebang SCRIPT [SCRIPT ...]
150 # Fixes the designated interpreter of SCRIPT to LUA. This would be necessary
151 # if the original uses an incorrect path (e.g. /usr/local/bin) or an
152 # incorrectly versioned binary. SCRIPT need not be prefixed by $D.
157 __fix_shebang ${LUA} ${D}/${f#${D}}
161 readonly -f luainto dolua lua_fix_shebang