1 |
commit: 819c21bf72b621771bd4ebd9ee53dc81604748d4 |
2 |
Author: David Seifert <soap <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Sep 6 15:37:52 2022 +0000 |
4 |
Commit: David Seifert <soap <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Sep 6 15:37:52 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/lua-patches.git/commit/?id=819c21bf |
7 |
|
8 |
Add Autotools |
9 |
|
10 |
* inspired by Fedora's patches, but mostly rewritten |
11 |
for Gentoo's multi-versioned approach. |
12 |
|
13 |
Signed-off-by: David Seifert <soap <AT> gentoo.org> |
14 |
|
15 |
Makefile.am | 72 +++++++++++++++++++++++++++++++++++++++++ |
16 |
configure.ac | 58 +++++++++++++++++++++++++++++++++ |
17 |
doc/{lua.1 => lua5.1.1} | 0 |
18 |
doc/{luac.1 => luac5.1.1} | 0 |
19 |
src/ldo.h | 2 +- |
20 |
src/lfunc.h | 2 +- |
21 |
src/lmem.h | 4 +-- |
22 |
src/lstring.h | 2 +- |
23 |
src/lua5.1.pc.in | 17 ++++++++++ |
24 |
src/luac.c | 1 - |
25 |
src/{luaconf.h => luaconf.h.in} | 12 ++----- |
26 |
src/lundump.h | 2 +- |
27 |
test-wrapper.sh | 13 ++++++++ |
28 |
13 files changed, 169 insertions(+), 16 deletions(-) |
29 |
|
30 |
diff --git a/Makefile.am b/Makefile.am |
31 |
new file mode 100644 |
32 |
index 0000000..cf85fa6 |
33 |
--- /dev/null |
34 |
+++ b/Makefile.am |
35 |
@@ -0,0 +1,72 @@ |
36 |
+######## |
37 |
+# doc/ # |
38 |
+######## |
39 |
+ |
40 |
+dist_doc_DATA = HISTORY README |
41 |
+dist_man1_MANS = doc/lua5.1.1 doc/luac5.1.1 |
42 |
+dist_html_DATA = \ |
43 |
+ doc/contents.html doc/cover.png doc/logo.gif doc/luac.html doc/lua.css \ |
44 |
+ doc/lua.html doc/manual.css doc/manual.html doc/readme.html |
45 |
+ |
46 |
+######## |
47 |
+# src/ # |
48 |
+######## |
49 |
+ |
50 |
+AM_CFLAGS = -Wall |
51 |
+AM_CPPFLAGS = -I$(builddir)/src # for luaconf.h |
52 |
+ |
53 |
+luadir = $(includedir)/lua5.1 |
54 |
+lua_HEADERS = src/lua.h src/lualib.h src/lauxlib.h etc/lua.hpp |
55 |
+nodist_lua_HEADERS = src/luaconf.h |
56 |
+ |
57 |
+lib_LTLIBRARIES = src/liblua5.1.la |
58 |
+src_liblua5_1_la_LIBADD = $(LIBM) |
59 |
+src_liblua5_1_la_SOURCES = \ |
60 |
+ src/lapi.c src/lapi.h src/lauxlib.c src/lbaselib.c src/lcode.c src/lcode.h \ |
61 |
+ src/ldblib.c src/ldebug.c src/ldebug.h src/ldo.c src/ldo.h src/ldump.c \ |
62 |
+ src/lfunc.c src/lfunc.h src/lgc.c src/lgc.h src/linit.c src/liolib.c \ |
63 |
+ src/llex.c src/llex.h src/llimits.h src/lmathlib.c src/lmem.c src/lmem.h \ |
64 |
+ src/loadlib.c src/lobject.c src/lobject.h src/lopcodes.c src/lopcodes.h \ |
65 |
+ src/loslib.c src/lparser.c src/lparser.h src/lstate.c src/lstate.h \ |
66 |
+ src/lstring.c src/lstring.h src/lstrlib.c src/ltable.c src/ltable.h \ |
67 |
+ src/ltablib.c src/ltm.c src/ltm.h src/lundump.c src/lundump.h src/lvm.c \ |
68 |
+ src/lvm.h src/lzio.c src/lzio.h |
69 |
+ |
70 |
+bin_PROGRAMS = lua5.1 luac5.1 |
71 |
+ |
72 |
+lua5_1_SOURCES = src/lua.c |
73 |
+lua5_1_CPPFLAGS = $(AM_CPPFLAGS) $(READLINE_CFLAGS) |
74 |
+lua5_1_LDADD = src/liblua5.1.la $(READLINE_LIBS) |
75 |
+ |
76 |
+luac5_1_SOURCES = src/luac.c |
77 |
+luac5_1_LDADD = src/liblua5.1.la |
78 |
+ |
79 |
+EXTRA_DIST = src/luaconf.h.in |
80 |
+BUILT_SOURCES = src/luaconf.h |
81 |
+CLEANFILES = $(BUILT_SOURCES) |
82 |
+ |
83 |
+pkgconfig_DATA = src/lua5.1.pc |
84 |
+ |
85 |
+edit = $(SED) \ |
86 |
+ -e 's,@prefix[@],$(prefix),g' \ |
87 |
+ -e 's,@datadir[@],$(datadir),g' \ |
88 |
+ -e 's,@libdir[@],$(libdir),g' |
89 |
+ |
90 |
+src/luaconf.h: $(srcdir)/src/luaconf.h.in |
91 |
+ rm -f $@ && $(edit) $(srcdir)/src/luaconf.h.in >$@ |
92 |
+ |
93 |
+######### |
94 |
+# test/ # |
95 |
+######### |
96 |
+ |
97 |
+TESTS = \ |
98 |
+ test/bisect.lua test/cf.lua test/echo.lua test/env.lua test/factorial.lua \ |
99 |
+ test/fib.lua test/fibfor.lua test/hello.lua test/printf.lua test/sieve.lua \ |
100 |
+ test/sort.lua test/trace-calls.lua test/trace-globals.lua |
101 |
+TESTS_ENVIRONMENT = env LUA=$(abs_builddir)/lua5.1 $(abs_srcdir)/test-wrapper.sh |
102 |
+ |
103 |
+EXTRA_DIST += test-wrapper.sh \ |
104 |
+ test/bisect.lua test/cf.lua test/echo.lua test/env.lua test/factorial.lua \ |
105 |
+ test/fibfor.lua test/fib.lua test/globals.lua test/hello.lua test/life.lua \ |
106 |
+ test/luac.lua test/printf.lua test/readonly.lua test/sieve.lua test/sort.lua \ |
107 |
+ test/table.lua test/trace-calls.lua test/trace-globals.lua test/xd.lua |
108 |
|
109 |
diff --git a/configure.ac b/configure.ac |
110 |
new file mode 100644 |
111 |
index 0000000..f030c88 |
112 |
--- /dev/null |
113 |
+++ b/configure.ac |
114 |
@@ -0,0 +1,58 @@ |
115 |
+AC_PREREQ([2.69]) |
116 |
+AC_INIT([lua5.1], [5.1.5], [https://bugs.gentoo.org/], [lua], [http://www.lua.org]) |
117 |
+ |
118 |
+AC_CONFIG_SRCDIR([src/lapi.c]) |
119 |
+AC_CONFIG_MACRO_DIR([m4]) |
120 |
+ |
121 |
+AM_INIT_AUTOMAKE([1.15 foreign dist-xz no-dist-gzip serial-tests subdir-objects -Wall]) |
122 |
+ |
123 |
+AC_PROG_CC |
124 |
+AC_PROG_SED |
125 |
+AM_PROG_AR |
126 |
+LT_INIT([disable-static]) |
127 |
+LT_LIB_M |
128 |
+ |
129 |
+PKG_INSTALLDIR |
130 |
+ |
131 |
+AC_ARG_ENABLE([deprecated], |
132 |
+ [AS_HELP_STRING([--disable-deprecated], [Disable deprecated APIs [default=yes]])]) |
133 |
+ |
134 |
+AS_IF([test "x$enable_deprecated" != "xno"], [ |
135 |
+ AC_DEFINE([LUA_COMPAT_VARARG], [1], [Compatibility with old vararg feature]) |
136 |
+ AC_DEFINE([LUA_COMPAT_MOD], [1], [Compatibility with old math.mod function]) |
137 |
+ AC_DEFINE([LUA_COMPAT_LSTR], [1], [Compatibility with old long string nesting facility]) |
138 |
+ AC_DEFINE([LUA_COMPAT_GFIND], [1], [Compatibility with old 'string.gfind' name]) |
139 |
+ AC_DEFINE([LUA_COMPAT_OPENLIB], [1], [Compatibility with old 'luaL_openlib' behavior]) |
140 |
+]) |
141 |
+ |
142 |
+AC_ARG_WITH([readline], |
143 |
+ [AS_HELP_STRING([--with-readline], [Use readline for interpreter input [default=yes]])]) |
144 |
+ |
145 |
+# Check for readline |
146 |
+AS_IF([test "x$with_readline" != "xno"], [ |
147 |
+ PKG_CHECK_MODULES([READLINE], [readline]) |
148 |
+ AC_DEFINE([LUA_USE_READLINE], [1], [Building with readline support]) |
149 |
+]) |
150 |
+ |
151 |
+AS_CASE([${host}], |
152 |
+ [*-mingw*], [ |
153 |
+ AC_DEFINE([LUA_BUILD_AS_DLL], [1], [Building a DLL under Win32]) |
154 |
+ ], |
155 |
+ [*-darwin*], [ |
156 |
+ AC_DEFINE([LUA_USE_MACOSX], [1], [Use macOS routines]) |
157 |
+ ], |
158 |
+ [*-linux*], [ |
159 |
+ AC_DEFINE([LUA_USE_LINUX], [1], [Use Linux routines]) |
160 |
+ AC_SEARCH_LIBS([dlopen], [dl dld], [], [ |
161 |
+ AC_MSG_ERROR([unable to find the dlopen() function]) |
162 |
+ ]) |
163 |
+ ], [ |
164 |
+ AC_DEFINE([LUA_USE_POSIX], [1], [Use POSIX routines]) |
165 |
+ AC_SEARCH_LIBS([dlopen], [dl dld], [], [ |
166 |
+ AC_MSG_ERROR([unable to find the dlopen() function]) |
167 |
+ ]) |
168 |
+ ] |
169 |
+) |
170 |
+ |
171 |
+AC_CONFIG_FILES([Makefile src/lua5.1.pc]) |
172 |
+AC_OUTPUT |
173 |
|
174 |
diff --git a/doc/lua.1 b/doc/lua5.1.1 |
175 |
similarity index 100% |
176 |
rename from doc/lua.1 |
177 |
rename to doc/lua5.1.1 |
178 |
|
179 |
diff --git a/doc/luac.1 b/doc/luac5.1.1 |
180 |
similarity index 100% |
181 |
rename from doc/luac.1 |
182 |
rename to doc/luac5.1.1 |
183 |
|
184 |
diff --git a/src/ldo.h b/src/ldo.h |
185 |
index 98fddac..bb56360 100644 |
186 |
--- a/src/ldo.h |
187 |
+++ b/src/ldo.h |
188 |
@@ -46,7 +46,7 @@ LUAI_FUNC int luaD_pcall (lua_State *L, Pfunc func, void *u, |
189 |
LUAI_FUNC int luaD_poscall (lua_State *L, StkId firstResult); |
190 |
LUAI_FUNC void luaD_reallocCI (lua_State *L, int newsize); |
191 |
LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize); |
192 |
-LUAI_FUNC void luaD_growstack (lua_State *L, int n); |
193 |
+void luaD_growstack (lua_State *L, int n); |
194 |
|
195 |
LUAI_FUNC void luaD_throw (lua_State *L, int errcode); |
196 |
LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud); |
197 |
|
198 |
diff --git a/src/lfunc.h b/src/lfunc.h |
199 |
index a68cf51..475edaf 100644 |
200 |
--- a/src/lfunc.h |
201 |
+++ b/src/lfunc.h |
202 |
@@ -18,7 +18,7 @@ |
203 |
cast(int, sizeof(TValue *)*((n)-1))) |
204 |
|
205 |
|
206 |
-LUAI_FUNC Proto *luaF_newproto (lua_State *L); |
207 |
+Proto *luaF_newproto (lua_State *L); |
208 |
LUAI_FUNC Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e); |
209 |
LUAI_FUNC Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e); |
210 |
LUAI_FUNC UpVal *luaF_newupval (lua_State *L); |
211 |
|
212 |
diff --git a/src/lmem.h b/src/lmem.h |
213 |
index 7c2dcb3..96575bc 100644 |
214 |
--- a/src/lmem.h |
215 |
+++ b/src/lmem.h |
216 |
@@ -38,9 +38,9 @@ |
217 |
((v)=cast(t *, luaM_reallocv(L, v, oldn, n, sizeof(t)))) |
218 |
|
219 |
|
220 |
-LUAI_FUNC void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, |
221 |
+void *luaM_realloc_ (lua_State *L, void *block, size_t oldsize, |
222 |
size_t size); |
223 |
-LUAI_FUNC void *luaM_toobig (lua_State *L); |
224 |
+void *luaM_toobig (lua_State *L); |
225 |
LUAI_FUNC void *luaM_growaux_ (lua_State *L, void *block, int *size, |
226 |
size_t size_elem, int limit, |
227 |
const char *errormsg); |
228 |
|
229 |
diff --git a/src/lstring.h b/src/lstring.h |
230 |
index 73a2ff8..70fd8e4 100644 |
231 |
--- a/src/lstring.h |
232 |
+++ b/src/lstring.h |
233 |
@@ -25,7 +25,7 @@ |
234 |
|
235 |
LUAI_FUNC void luaS_resize (lua_State *L, int newsize); |
236 |
LUAI_FUNC Udata *luaS_newudata (lua_State *L, size_t s, Table *e); |
237 |
-LUAI_FUNC TString *luaS_newlstr (lua_State *L, const char *str, size_t l); |
238 |
+TString *luaS_newlstr (lua_State *L, const char *str, size_t l); |
239 |
|
240 |
|
241 |
#endif |
242 |
|
243 |
diff --git a/src/lua5.1.pc.in b/src/lua5.1.pc.in |
244 |
new file mode 100644 |
245 |
index 0000000..9b5bec8 |
246 |
--- /dev/null |
247 |
+++ b/src/lua5.1.pc.in |
248 |
@@ -0,0 +1,17 @@ |
249 |
+prefix=@prefix@ |
250 |
+exec_prefix=@exec_prefix@ |
251 |
+libdir=@libdir@ |
252 |
+includedir=@includedir@/lua5.1 |
253 |
+datarootdir=@datarootdir@ |
254 |
+datadir=@datadir@ |
255 |
+ |
256 |
+Name: Lua |
257 |
+Description: An Extensible Extension Language |
258 |
+Version: @PACKAGE_VERSION@ |
259 |
+Libs: -L${libdir} -llua5.1 |
260 |
+Libs.private: @LIBM@ @LIBS@ |
261 |
+Cflags: -I${includedir} |
262 |
+ |
263 |
+# information required by lua-utils.eclass::_lua_export |
264 |
+INSTALL_LMOD=${datadir}/lua/5.1 |
265 |
+INSTALL_CMOD=${libdir}/lua/5.1 |
266 |
|
267 |
diff --git a/src/luac.c b/src/luac.c |
268 |
index d070173..86474c2 100644 |
269 |
--- a/src/luac.c |
270 |
+++ b/src/luac.c |
271 |
@@ -169,7 +169,6 @@ static int pmain(lua_State* L) |
272 |
if (luaL_loadfile(L,filename)!=0) fatal(lua_tostring(L,-1)); |
273 |
} |
274 |
f=combine(L,argc); |
275 |
- if (listing) luaU_print(f,listing>1); |
276 |
if (dumping) |
277 |
{ |
278 |
FILE* D= (output==NULL) ? stdout : fopen(output,"wb"); |
279 |
|
280 |
diff --git a/src/luaconf.h b/src/luaconf.h.in |
281 |
similarity index 98% |
282 |
rename from src/luaconf.h |
283 |
rename to src/luaconf.h.in |
284 |
index e2cb261..0947b47 100644 |
285 |
--- a/src/luaconf.h |
286 |
+++ b/src/luaconf.h.in |
287 |
@@ -36,7 +36,6 @@ |
288 |
#if defined(LUA_USE_LINUX) |
289 |
#define LUA_USE_POSIX |
290 |
#define LUA_USE_DLOPEN /* needs an extra library: -ldl */ |
291 |
-#define LUA_USE_READLINE /* needs some extra libraries */ |
292 |
#endif |
293 |
|
294 |
#if defined(LUA_USE_MACOSX) |
295 |
@@ -94,9 +93,9 @@ |
296 |
".\\?.dll;" LUA_CDIR"?.dll;" LUA_CDIR"loadall.dll" |
297 |
|
298 |
#else |
299 |
-#define LUA_ROOT "/usr/local/" |
300 |
-#define LUA_LDIR LUA_ROOT "share/lua/5.1/" |
301 |
-#define LUA_CDIR LUA_ROOT "lib/lua/5.1/" |
302 |
+#define LUA_ROOT "@prefix@/" |
303 |
+#define LUA_LDIR "@datadir@/lua/5.1/" |
304 |
+#define LUA_CDIR "@libdir@/lua/5.1/" |
305 |
#define LUA_PATH_DEFAULT \ |
306 |
"./?.lua;" LUA_LDIR"?.lua;" LUA_LDIR"?/init.lua;" \ |
307 |
LUA_CDIR"?.lua;" LUA_CDIR"?/init.lua" |
308 |
@@ -333,14 +332,12 @@ |
309 |
** CHANGE it to undefined as soon as your programs use only '...' to |
310 |
** access vararg parameters (instead of the old 'arg' table). |
311 |
*/ |
312 |
-#define LUA_COMPAT_VARARG |
313 |
|
314 |
/* |
315 |
@@ LUA_COMPAT_MOD controls compatibility with old math.mod function. |
316 |
** CHANGE it to undefined as soon as your programs use 'math.fmod' or |
317 |
** the new '%' operator instead of 'math.mod'. |
318 |
*/ |
319 |
-#define LUA_COMPAT_MOD |
320 |
|
321 |
/* |
322 |
@@ LUA_COMPAT_LSTR controls compatibility with old long string nesting |
323 |
@@ -348,14 +345,12 @@ |
324 |
** CHANGE it to 2 if you want the old behaviour, or undefine it to turn |
325 |
** off the advisory error when nesting [[...]]. |
326 |
*/ |
327 |
-#define LUA_COMPAT_LSTR 1 |
328 |
|
329 |
/* |
330 |
@@ LUA_COMPAT_GFIND controls compatibility with old 'string.gfind' name. |
331 |
** CHANGE it to undefined as soon as you rename 'string.gfind' to |
332 |
** 'string.gmatch'. |
333 |
*/ |
334 |
-#define LUA_COMPAT_GFIND |
335 |
|
336 |
/* |
337 |
@@ LUA_COMPAT_OPENLIB controls compatibility with old 'luaL_openlib' |
338 |
@@ -363,7 +358,6 @@ |
339 |
** CHANGE it to undefined as soon as you replace to 'luaL_register' |
340 |
** your uses of 'luaL_openlib' |
341 |
*/ |
342 |
-#define LUA_COMPAT_OPENLIB |
343 |
|
344 |
|
345 |
|
346 |
|
347 |
diff --git a/src/lundump.h b/src/lundump.h |
348 |
index c80189d..cb8376c 100644 |
349 |
--- a/src/lundump.h |
350 |
+++ b/src/lundump.h |
351 |
@@ -17,7 +17,7 @@ LUAI_FUNC Proto* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* n |
352 |
LUAI_FUNC void luaU_header (char* h); |
353 |
|
354 |
/* dump one chunk; from ldump.c */ |
355 |
-LUAI_FUNC int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); |
356 |
+int luaU_dump (lua_State* L, const Proto* f, lua_Writer w, void* data, int strip); |
357 |
|
358 |
#ifdef luac_c |
359 |
/* print one chunk; from print.c */ |
360 |
|
361 |
diff --git a/test-wrapper.sh b/test-wrapper.sh |
362 |
new file mode 100755 |
363 |
index 0000000..fe9309b |
364 |
--- /dev/null |
365 |
+++ b/test-wrapper.sh |
366 |
@@ -0,0 +1,13 @@ |
367 |
+#!/usr/bin/env sh |
368 |
+set -e |
369 |
+ |
370 |
+# https://www.lua.org/tests/ |
371 |
+# There are two sets: |
372 |
+# 1. basic |
373 |
+# 2. complete |
374 |
+# |
375 |
+# The basic subset is selected by passing -e'_U=true' |
376 |
+# The complete set is noted to contain tests that may consume too much memory or have non-portable tests. |
377 |
+# attrib.lua for example needs some multilib customization (have to compile the stuff in libs/ for each ABI) |
378 |
+ |
379 |
+cd "${srcdir}"/test && "${LUA}" -e_U=true $(basename ${1}) |