xref: /freebsd/contrib/lua/doc/readme.html (revision 61e21613)
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2<HTML>
3<HEAD>
4<TITLE>Lua 5.4 readme</TITLE>
5<LINK REL="stylesheet" TYPE="text/css" HREF="lua.css">
6<META HTTP-EQUIV="content-type" CONTENT="text/html; charset=iso-8859-1">
7<STYLE TYPE="text/css">
8blockquote, .display {
9	border: solid #a0a0a0 2px ;
10	border-radius: 8px ;
11	padding: 1em ;
12	margin: 0px ;
13}
14
15.display {
16	word-spacing: 0.25em ;
17}
18
19dl.display dd {
20	padding-bottom: 0.2em ;
21}
22
23tt, kbd, code {
24	font-size: 12pt ;
25}
26</STYLE>
27</HEAD>
28
29<BODY>
30
31<H1>
32<A HREF="http://www.lua.org/"><IMG SRC="logo.gif" ALT="Lua"></A>
33Welcome to Lua 5.4
34</H1>
35
36<DIV CLASS="menubar">
37<A HREF="#about">about</A>
38&middot;
39<A HREF="#install">installation</A>
40&middot;
41<A HREF="#changes">changes</A>
42&middot;
43<A HREF="#license">license</A>
44&middot;
45<A HREF="contents.html">reference manual</A>
46</DIV>
47
48<H2><A NAME="about">About Lua</A></H2>
49<P>
50Lua is a powerful, efficient, lightweight, embeddable scripting language
51developed by a
52<A HREF="http://www.lua.org/authors.html">team</A>
53at
54<A HREF="http://www.puc-rio.br/">PUC-Rio</A>,
55the Pontifical Catholic University of Rio de Janeiro in Brazil.
56Lua is
57<A HREF="#license">free software</A>
58used in
59<A HREF="http://www.lua.org/uses.html">many products and projects</A>
60around the world.
61
62<P>
63Lua's
64<A HREF="http://www.lua.org/">official web site</A>
65provides complete information
66about Lua,
67including
68an
69<A HREF="http://www.lua.org/about.html">executive summary</A>
70and
71updated
72<A HREF="http://www.lua.org/docs.html">documentation</A>,
73especially the
74<A HREF="http://www.lua.org/manual/5.4/">reference manual</A>,
75which may differ slightly from the
76<A HREF="contents.html">local copy</A>
77distributed in this package.
78
79<H2><A NAME="install">Installing Lua</A></H2>
80<P>
81Lua is distributed in
82<A HREF="http://www.lua.org/ftp/">source</A>
83form.
84You need to build it before using it.
85Building Lua should be straightforward
86because
87Lua is implemented in pure ANSI C and compiles unmodified in all known
88platforms that have an ANSI C compiler.
89Lua also compiles unmodified as C++.
90The instructions given below for building Lua are for Unix-like platforms,
91such as Linux and Mac OS X.
92See also
93<A HREF="#other">instructions for other systems</A>
94and
95<A HREF="#customization">customization options</A>.
96
97<P>
98If you don't have the time or the inclination to compile Lua yourself,
99get a binary from
100<A HREF="http://lua-users.org/wiki/LuaBinaries">LuaBinaries</A>.
101
102<H3>Building Lua</H3>
103<P>
104In most common Unix-like platforms, simply do "<KBD>make</KBD>".
105Here are the details.
106
107<OL>
108<LI>
109Open a terminal window and move to
110the top-level directory, which is named <TT>lua-5.4.6</TT>.
111The <TT>Makefile</TT> there controls both the build process and the installation process.
112<P>
113<LI>
114  Do "<KBD>make</KBD>". The <TT>Makefile</TT> will guess your platform and build Lua for it.
115<P>
116<LI>
117  If the guess failed, do "<KBD>make help</KBD>" and see if your platform is listed.
118  The platforms currently supported are:
119<P>
120<P CLASS="display">
121   guess aix bsd c89 freebsd generic ios linux linux-readline macosx mingw posix solaris
122</P>
123<P>
124  If your platform is listed, just do "<KBD>make xxx</KBD>", where xxx
125  is your platform name.
126<P>
127  If your platform is not listed, try the closest one or posix, generic,
128  c89, in this order.
129<P>
130<LI>
131The compilation takes only a few moments
132and produces three files in the <TT>src</TT> directory:
133lua (the interpreter),
134luac (the compiler),
135and liblua.a (the library).
136<P>
137<LI>
138  To check that Lua has been built correctly, do "<KBD>make test</KBD>"
139  after building Lua. This will run the interpreter and print its version.
140</OL>
141<P>
142If you're running Linux, try "<KBD>make linux-readline</KBD>" to build the interactive Lua interpreter with handy line-editing and history capabilities.
143If you get compilation errors,
144make sure you have installed the <TT>readline</TT> development package
145(which is probably named <TT>libreadline-dev</TT> or <TT>readline-devel</TT>).
146If you get link errors after that,
147then try "<KBD>make linux-readline MYLIBS=-ltermcap</KBD>".
148
149<H3>Installing Lua</H3>
150<P>
151  Once you have built Lua, you may want to install it in an official
152  place in your system. In this case, do "<KBD>make install</KBD>". The official
153  place and the way to install files are defined in the <TT>Makefile</TT>. You'll
154  probably need the right permissions to install files, and so may need to do "<KBD>sudo make install</KBD>".
155
156<P>
157  To build and install Lua in one step, do "<KBD>make all install</KBD>",
158  or "<KBD>make xxx install</KBD>",
159  where xxx is your platform name.
160
161<P>
162  To install Lua locally after building it, do "<KBD>make local</KBD>".
163  This will create a directory <TT>install</TT> with subdirectories
164  <TT>bin</TT>, <TT>include</TT>, <TT>lib</TT>, <TT>man</TT>, <TT>share</TT>,
165  and install Lua as listed below.
166
167  To install Lua locally, but in some other directory, do
168  "<KBD>make install INSTALL_TOP=xxx</KBD>", where xxx is your chosen directory.
169  The installation starts in the <TT>src</TT> and <TT>doc</TT> directories,
170  so take care if <TT>INSTALL_TOP</TT> is not an absolute path.
171
172<DL CLASS="display">
173<DT>
174    bin:
175<DD>
176    lua luac
177<DT>
178    include:
179<DD>
180    lua.h luaconf.h lualib.h lauxlib.h lua.hpp
181<DT>
182    lib:
183<DD>
184    liblua.a
185<DT>
186    man/man1:
187<DD>
188    lua.1 luac.1
189</DL>
190
191<P>
192  These are the only directories you need for development.
193  If you only want to run Lua programs,
194  you only need the files in <TT>bin</TT> and <TT>man</TT>.
195  The files in <TT>include</TT> and <TT>lib</TT> are needed for
196  embedding Lua in C or C++ programs.
197
198<H3><A NAME="customization">Customization</A></H3>
199<P>
200  Three kinds of things can be customized by editing a file:
201<UL>
202    <LI> Where and how to install Lua &mdash; edit <TT>Makefile</TT>.
203    <LI> How to build Lua &mdash; edit <TT>src/Makefile</TT>.
204    <LI> Lua features &mdash; edit <TT>src/luaconf.h</TT>.
205</UL>
206
207<P>
208  You don't actually need to edit the Makefiles because you may set the
209  relevant variables in the command line when invoking make.
210  Nevertheless, it's probably best to edit and save the Makefiles to
211  record the changes you've made.
212
213<P>
214  On the other hand, if you need to customize some Lua features, you'll need
215  to edit <TT>src/luaconf.h</TT> before building and installing Lua.
216  The edited file will be the one installed, and
217  it will be used by any Lua clients that you build, to ensure consistency.
218  Further customization is available to experts by editing the Lua sources.
219
220<H3><A NAME="other">Building Lua on other systems</A></H3>
221<P>
222  If you're not using the usual Unix tools, then the instructions for
223  building Lua depend on the compiler you use. You'll need to create
224  projects (or whatever your compiler uses) for building the library,
225  the interpreter, and the compiler, as follows:
226
227<DL CLASS="display">
228<DT>
229library:
230<DD>
231lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c ltable.c ltm.c lundump.c lvm.c lzio.c
232lauxlib.c lbaselib.c lcorolib.c ldblib.c liolib.c lmathlib.c loadlib.c loslib.c lstrlib.c ltablib.c lutf8lib.c linit.c
233<DT>
234interpreter:
235<DD>
236  library, lua.c
237<DT>
238compiler:
239<DD>
240  library, luac.c
241</DL>
242
243<P>
244  To use Lua as a library in your own programs, you'll need to know how to
245  create and use libraries with your compiler. Moreover, to dynamically load
246  C libraries for Lua, you'll need to know how to create dynamic libraries
247  and you'll need to make sure that the Lua API functions are accessible to
248  those dynamic libraries &mdash; but <EM>don't</EM> link the Lua library
249  into each dynamic library. For Unix, we recommend that the Lua library
250  be linked statically into the host program and its symbols exported for
251  dynamic linking; <TT>src/Makefile</TT> does this for the Lua interpreter.
252  For Windows, we recommend that the Lua library be a DLL.
253  In all cases, the compiler luac should be linked statically.
254
255<P>
256  As mentioned above, you may edit <TT>src/luaconf.h</TT> to customize
257  some features before building Lua.
258
259<H2><A NAME="changes">Changes since Lua 5.3</A></H2>
260<P>
261Here are the main changes introduced in Lua 5.4.
262The
263<A HREF="contents.html">reference manual</A>
264lists the
265<A HREF="manual.html#8">incompatibilities</A> that had to be introduced.
266
267<H3>Main changes</H3>
268<UL>
269<LI> new generational mode for garbage collection
270<LI> to-be-closed variables
271<LI> const variables
272<LI> userdata can have multiple user values
273<LI> new implementation for math.random
274<LI> warning system
275<LI> debug information about function arguments and returns
276<LI> new semantics for the integer 'for' loop
277<LI> optional 'init' argument to 'string.gmatch'
278<LI> new functions 'lua_resetthread' and 'coroutine.close'
279<LI> string-to-number coercions moved to the string library
280<LI> allocation function allowed to fail when shrinking a memory block
281<LI> new format '%p' in 'string.format'
282<LI> utf8 library accepts codepoints up to 2^31
283</UL>
284
285<H2><A NAME="license">License</A></H2>
286<P>
287<A HREF="http://www.opensource.org/docs/definition.php">
288<IMG SRC="osi-certified-72x60.png" ALIGN="right" ALT="[osi certified]" STYLE="padding-left: 30px ;">
289</A>
290Lua is free software distributed under the terms of the
291<A HREF="http://www.opensource.org/licenses/mit-license.html">MIT license</A>
292reproduced below;
293it may be used for any purpose, including commercial purposes,
294at absolutely no cost without having to ask us.
295
296The only requirement is that if you do use Lua,
297then you should give us credit by including the appropriate copyright notice somewhere in your product or its documentation.
298
299For details, see
300<A HREF="http://www.lua.org/license.html">this</A>.
301
302<BLOCKQUOTE STYLE="padding-bottom: 0em">
303Copyright &copy; 1994&ndash;2023 Lua.org, PUC-Rio.
304
305<P>
306Permission is hereby granted, free of charge, to any person obtaining a copy
307of this software and associated documentation files (the "Software"), to deal
308in the Software without restriction, including without limitation the rights
309to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
310copies of the Software, and to permit persons to whom the Software is
311furnished to do so, subject to the following conditions:
312
313<P>
314The above copyright notice and this permission notice shall be included in
315all copies or substantial portions of the Software.
316
317<P>
318THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
319IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
320FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
321AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
322LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
323OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
324THE SOFTWARE.
325</BLOCKQUOTE>
326<P>
327
328<P CLASS="footer">
329Last update:
330Tue May  2 20:08:55 UTC 2023
331</P>
332<!--
333Last change: revised for Lua 5.4.6
334-->
335
336</BODY>
337</HTML>
338