Bump copyright date to 2018.
[luajit-2.0.git] / doc / install.html
blobbefffa731350dc5cc435fe08477cdc1b70b49e9d
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <title>Installation</title>
5 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
6 <meta name="Copyright" content="Copyright (C) 2005-2018">
7 <meta name="Language" content="en">
8 <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
9 <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
10 <style type="text/css">
11 table.compat {
12 line-height: 1.2;
13 font-size: 80%;
15 table.compat td {
16 border: 1px solid #bfcfff;
17 height: 2.5em;
19 table.compat tr.compathead td {
20 font-weight: bold;
21 border-bottom: 2px solid #bfcfff;
23 tr.compathead td.compatos {
24 vertical-align: top;
26 table.compat td.compatcpu {
27 width: 18%;
28 border-right: 2px solid #bfcfff;
30 td.compatos {
31 width: 21%;
32 vertical-align: middle;
34 td.compatno {
35 background-color: #d0d0d0;
37 </style>
38 </head>
39 <body>
40 <div id="site">
41 <a href="http://luajit.org"><span>Lua<span id="logo">JIT</span></span></a>
42 </div>
43 <div id="head">
44 <h1>Installation</h1>
45 </div>
46 <div id="nav">
47 <ul><li>
48 <a href="luajit.html">LuaJIT</a>
49 <ul><li>
50 <a href="http://luajit.org/download.html">Download <span class="ext">&raquo;</span></a>
51 </li><li>
52 <a class="current" href="install.html">Installation</a>
53 </li><li>
54 <a href="running.html">Running</a>
55 </li></ul>
56 </li><li>
57 <a href="extensions.html">Extensions</a>
58 <ul><li>
59 <a href="ext_ffi.html">FFI Library</a>
60 <ul><li>
61 <a href="ext_ffi_tutorial.html">FFI Tutorial</a>
62 </li><li>
63 <a href="ext_ffi_api.html">ffi.* API</a>
64 </li><li>
65 <a href="ext_ffi_semantics.html">FFI Semantics</a>
66 </li></ul>
67 </li><li>
68 <a href="ext_jit.html">jit.* Library</a>
69 </li><li>
70 <a href="ext_c_api.html">Lua/C API</a>
71 </li></ul>
72 </li><li>
73 <a href="status.html">Status</a>
74 <ul><li>
75 <a href="changes.html">Changes</a>
76 </li></ul>
77 </li><li>
78 <a href="faq.html">FAQ</a>
79 </li><li>
80 <a href="http://luajit.org/performance.html">Performance <span class="ext">&raquo;</span></a>
81 </li><li>
82 <a href="http://wiki.luajit.org/">Wiki <span class="ext">&raquo;</span></a>
83 </li><li>
84 <a href="http://luajit.org/list.html">Mailing List <span class="ext">&raquo;</span></a>
85 </li></ul>
86 </div>
87 <div id="main">
88 <p>
89 LuaJIT is only distributed as a source package. This page explains
90 how to build and install LuaJIT with different operating systems
91 and C&nbsp;compilers.
92 </p>
93 <p>
94 For the impatient (on POSIX systems):
95 </p>
96 <pre class="code">
97 make &amp;&amp; sudo make install
98 </pre>
99 <p>
100 LuaJIT currently builds out-of-the box on most systems.
101 Here's the compatibility matrix for the supported combinations of
102 operating systems, CPUs and compilers:
103 </p>
104 <table class="compat">
105 <tr class="compathead">
106 <td class="compatcpu">CPU / OS</td>
107 <td class="compatos"><a href="#posix">Linux</a> or<br><a href="#android">Android</a></td>
108 <td class="compatos"><a href="#posix">*BSD, Other</a></td>
109 <td class="compatos"><a href="#posix">OSX 10.4+</a> or<br><a href="#ios">iOS 3.0+</a></td>
110 <td class="compatos"><a href="#windows">Windows<br>XP/Vista/7</a></td>
111 </tr>
112 <tr class="odd separate">
113 <td class="compatcpu">x86 (32 bit)</td>
114 <td class="compatos">GCC 4.x+<br>GCC 3.4</td>
115 <td class="compatos">GCC 4.x+<br>GCC 3.4</td>
116 <td class="compatos">XCode 5.0+<br>Clang</td>
117 <td class="compatos">MSVC, MSVC/EE<br>WinSDK<br>MinGW, Cygwin</td>
118 </tr>
119 <tr class="even">
120 <td class="compatcpu">x64 (64 bit)</td>
121 <td class="compatos">GCC 4.x+</td>
122 <td class="compatos">ORBIS (<a href="#ps4">PS4</a>)</td>
123 <td class="compatos">XCode 5.0+<br>Clang</td>
124 <td class="compatos">MSVC + SDK v7.0<br>WinSDK v7.0</td>
125 </tr>
126 <tr class="odd">
127 <td class="compatcpu"><a href="#cross2">ARMv5+<br>ARM9E+</a></td>
128 <td class="compatos">GCC 4.2+</td>
129 <td class="compatos">GCC 4.2+<br>PSP2 (<a href="#psvita">PS VITA</a>)</td>
130 <td class="compatos">XCode 5.0+<br>Clang</td>
131 <td class="compatos compatno">&nbsp;</td>
132 </tr>
133 <tr class="even">
134 <td class="compatcpu"><a href="#cross2">PPC</a></td>
135 <td class="compatos">GCC 4.3+</td>
136 <td class="compatos">GCC 4.3+<br>GCC 4.1 (<a href="#ps3">PS3</a>)</td>
137 <td class="compatos compatno">&nbsp;</td>
138 <td class="compatos">XEDK (<a href="#xbox360">Xbox 360</a>)</td>
139 </tr>
140 <tr class="odd">
141 <td class="compatcpu"><a href="#cross2">PPC/e500v2</a></td>
142 <td class="compatos">GCC 4.3+</td>
143 <td class="compatos">GCC 4.3+</td>
144 <td class="compatos compatno">&nbsp;</td>
145 <td class="compatos compatno">&nbsp;</td>
146 </tr>
147 <tr class="even">
148 <td class="compatcpu"><a href="#cross2">MIPS</a></td>
149 <td class="compatos">GCC 4.3+</td>
150 <td class="compatos">GCC 4.3+</td>
151 <td class="compatos compatno">&nbsp;</td>
152 <td class="compatos compatno">&nbsp;</td>
153 </tr>
154 </table>
156 <h2>Configuring LuaJIT</h2>
158 The standard configuration should work fine for most installations.
159 Usually there is no need to tweak the settings. The following files
160 hold all user-configurable settings:
161 </p>
162 <ul>
163 <li><tt>src/luaconf.h</tt> sets some configuration variables.</li>
164 <li><tt>Makefile</tt> has settings for <b>installing</b> LuaJIT (POSIX
165 only).</li>
166 <li><tt>src/Makefile</tt> has settings for <b>compiling</b> LuaJIT
167 under POSIX, MinGW or Cygwin.</li>
168 <li><tt>src/msvcbuild.bat</tt> has settings for compiling LuaJIT with
169 MSVC or WinSDK.</li>
170 </ul>
172 Please read the instructions given in these files, before changing
173 any settings.
174 </p>
176 <h2 id="posix">POSIX Systems (Linux, OSX, *BSD etc.)</h2>
177 <h3>Prerequisites</h3>
179 Depending on your distribution, you may need to install a package for
180 GCC, the development headers and/or a complete SDK. E.g. on a current
181 Debian/Ubuntu, install <tt>libc6-dev</tt> with the package manager.
182 </p>
184 Download the current source package of LuaJIT (pick the .tar.gz),
185 if you haven't already done so. Move it to a directory of your choice,
186 open a terminal window and change to this directory. Now unpack the archive
187 and change to the newly created directory:
188 </p>
189 <pre class="code">
190 tar zxf LuaJIT-2.0.5.tar.gz
191 cd LuaJIT-2.0.5</pre>
192 <h3>Building LuaJIT</h3>
194 The supplied Makefiles try to auto-detect the settings needed for your
195 operating system and your compiler. They need to be run with GNU Make,
196 which is probably the default on your system, anyway. Simply run:
197 </p>
198 <pre class="code">
199 make
200 </pre>
202 This always builds a native x86, x64 or PPC binary, depending on the host OS
203 you're running this command on. Check the section on
204 <a href="#cross">cross-compilation</a> for more options.
205 </p>
207 By default, modules are only searched under the prefix <tt>/usr/local</tt>.
208 You can add an extra prefix to the search paths by appending the
209 <tt>PREFIX</tt> option, e.g.:
210 </p>
211 <pre class="code">
212 make PREFIX=/home/myself/lj2
213 </pre>
215 Note for OSX: if the <tt>MACOSX_DEPLOYMENT_TARGET</tt> environment
216 variable is not set, then it's forced to <tt>10.4</tt>.
217 </p>
218 <h3>Installing LuaJIT</h3>
220 The top-level Makefile installs LuaJIT by default under
221 <tt>/usr/local</tt>, i.e. the executable ends up in
222 <tt>/usr/local/bin</tt> and so on. You need root privileges
223 to write to this path. So, assuming sudo is installed on your system,
224 run the following command and enter your sudo password:
225 </p>
226 <pre class="code">
227 sudo make install
228 </pre>
230 Otherwise specify the directory prefix as an absolute path, e.g.:
231 </p>
232 <pre class="code">
233 make install PREFIX=/home/myself/lj2
234 </pre>
236 Obviously the prefixes given during build and installation need to be the same.
237 </p>
239 <h2 id="windows">Windows Systems</h2>
240 <h3>Prerequisites</h3>
242 Either install one of the open source SDKs
243 (<a href="http://mingw.org/"><span class="ext">&raquo;</span>&nbsp;MinGW</a> or
244 <a href="http://www.cygwin.com/"><span class="ext">&raquo;</span>&nbsp;Cygwin</a>), which come with a modified
245 GCC plus the required development headers.
246 </p>
248 Or install Microsoft's Visual C++ (MSVC). The freely downloadable
249 <a href="http://www.microsoft.com/Express/VC/"><span class="ext">&raquo;</span>&nbsp;Express Edition</a>
250 works just fine, but only contains an x86 compiler.
251 </p>
253 The freely downloadable
254 <a href="http://msdn.microsoft.com/en-us/windowsserver/bb980924.aspx"><span class="ext">&raquo;</span>&nbsp;Windows SDK</a>
255 only comes with command line tools, but this is all you need to build LuaJIT.
256 It contains x86 and x64 compilers.
257 </p>
259 Next, download the source package and unpack it using an archive manager
260 (e.g. the Windows Explorer) to a directory of your choice.
261 </p>
262 <h3>Building with MSVC</h3>
264 Open a "Visual Studio .NET Command Prompt", <tt>cd</tt> to the
265 directory where you've unpacked the sources and run these commands:
266 </p>
267 <pre class="code">
268 cd src
269 msvcbuild
270 </pre>
272 Then follow the installation instructions below.
273 </p>
274 <h3>Building with the Windows SDK</h3>
276 Open a "Windows SDK Command Shell" and select the x86 compiler:
277 </p>
278 <pre class="code">
279 setenv /release /x86
280 </pre>
282 Or select the x64 compiler:
283 </p>
284 <pre class="code">
285 setenv /release /x64
286 </pre>
288 Then <tt>cd</tt> to the directory where you've unpacked the sources
289 and run these commands:
290 </p>
291 <pre class="code">
292 cd src
293 msvcbuild
294 </pre>
296 Then follow the installation instructions below.
297 </p>
298 <h3>Building with MinGW or Cygwin</h3>
300 Open a command prompt window and make sure the MinGW or Cygwin programs
301 are in your path. Then <tt>cd</tt> to the directory where
302 you've unpacked the sources and run this command for MinGW:
303 </p>
304 <pre class="code">
305 mingw32-make
306 </pre>
308 Or this command for Cygwin:
309 </p>
310 <pre class="code">
311 make
312 </pre>
314 Then follow the installation instructions below.
315 </p>
316 <h3>Installing LuaJIT</h3>
318 Copy <tt>luajit.exe</tt> and <tt>lua51.dll</tt> (built in the <tt>src</tt>
319 directory) to a newly created directory (any location is ok).
320 Add <tt>lua</tt> and <tt>lua\jit</tt> directories below it and copy
321 all Lua files from the <tt>src\jit</tt> directory of the distribution
322 to the latter directory.
323 </p>
325 There are no hardcoded
326 absolute path names &mdash; all modules are loaded relative to the
327 directory where <tt>luajit.exe</tt> is installed
328 (see <tt>src/luaconf.h</tt>).
329 </p>
331 <h2 id="cross">Cross-compiling LuaJIT</h2>
333 The GNU Makefile-based build system allows cross-compiling on any host
334 for any supported target, as long as both architectures have the same
335 pointer size. If you want to cross-compile to any 32 bit target on an
336 x64 OS, you need to install the multilib development package (e.g.
337 <tt>libc6-dev-i386</tt> on Debian/Ubuntu) and build a 32 bit host part
338 (<tt>HOST_CC="gcc -m32"</tt>).
339 </p>
341 You need to specify <tt>TARGET_SYS</tt> whenever the host OS and the
342 target OS differ, or you'll get assembler or linker errors. E.g. if
343 you're compiling on a Windows or OSX host for embedded Linux or Android,
344 you need to add <tt>TARGET_SYS=Linux</tt> to the examples below. For a
345 minimal target OS, you may need to disable the built-in allocator in
346 <tt>src/Makefile</tt> and use <tt>TARGET_SYS=Other</tt>. Don't forget to
347 specify the same <tt>TARGET_SYS</tt> for the install step, too.
348 </p>
350 The examples below only show some popular targets &mdash; please check
351 the comments in <tt>src/Makefile</tt> for more details.
352 </p>
353 <pre class="code">
354 # Cross-compile to a 32 bit binary on a multilib x64 OS
355 make CC="gcc -m32"
357 # Cross-compile on Debian/Ubuntu for Windows (mingw32 package)
358 make HOST_CC="gcc -m32" CROSS=i586-mingw32msvc- TARGET_SYS=Windows
359 </pre>
360 <p id="cross2">
361 The <tt>CROSS</tt> prefix allows specifying a standard GNU cross-compile
362 toolchain (Binutils, GCC and a matching libc). The prefix may vary
363 depending on the <tt>--target</tt> the toolchain was built for (note the
364 <tt>CROSS</tt> prefix has a trailing <tt>"-"</tt>). The examples below
365 use the canonical toolchain triplets for Linux.
366 </p>
368 Since there's often no easy way to detect CPU features at runtime, it's
369 important to compile with the proper CPU or architecture settings. You
370 can specify these when building the toolchain yourself. Or add
371 <tt>-mcpu=...</tt> or <tt>-march=...</tt> to <tt>TARGET_CFLAGS</tt>. For
372 ARM it's important to have the correct <tt>-mfloat-abi=...</tt> setting,
373 too. Otherwise LuaJIT may not run at the full performance of your target
374 CPU.
375 </p>
376 <pre class="code">
377 # ARM soft-float
378 make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \
379 TARGET_CFLAGS="-mfloat-abi=soft"
381 # ARM soft-float ABI with VFP (example for Cortex-A8)
382 make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \
383 TARGET_CFLAGS="-mcpu=cortex-a8 -mfloat-abi=softfp"
385 # ARM hard-float ABI with VFP (armhf, requires recent toolchain)
386 make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabihf-
388 # PPC
389 make HOST_CC="gcc -m32" CROSS=powerpc-linux-gnu-
390 # PPC/e500v2 (fast interpreter only)
391 make HOST_CC="gcc -m32" CROSS=powerpc-e500v2-linux-gnuspe-
393 # MIPS big-endian
394 make HOST_CC="gcc -m32" CROSS=mips-linux-
395 # MIPS little-endian
396 make HOST_CC="gcc -m32" CROSS=mipsel-linux-
397 </pre>
399 You can cross-compile for <b id="android">Android</b> using the <a href="http://developer.android.com/sdk/ndk/index.html"><span class="ext">&raquo;</span>&nbsp;Android NDK</a>.
400 The environment variables need to match the install locations and the
401 desired target platform. E.g. Android&nbsp;4.0 corresponds to ABI level&nbsp;14.
402 For details check the folder <tt>docs</tt> in the NDK directory.
403 </p>
405 Only a few common variations for the different CPUs, ABIs and platforms
406 are listed. Please use your own judgement for which combination you want
407 to build/deploy or which lowest common denominator you want to pick:
408 </p>
409 <pre class="code">
410 # Android/ARM, armeabi (ARMv5TE soft-float), Android 2.2+ (Froyo)
411 NDK=/opt/android/ndk
412 NDKABI=8
413 NDKVER=$NDK/toolchains/arm-linux-androideabi-4.6
414 NDKP=$NDKVER/prebuilt/linux-x86/bin/arm-linux-androideabi-
415 NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-arm"
416 make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF"
418 # Android/ARM, armeabi-v7a (ARMv7 VFP), Android 4.0+ (ICS)
419 NDK=/opt/android/ndk
420 NDKABI=14
421 NDKVER=$NDK/toolchains/arm-linux-androideabi-4.6
422 NDKP=$NDKVER/prebuilt/linux-x86/bin/arm-linux-androideabi-
423 NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-arm"
424 NDKARCH="-march=armv7-a -mfloat-abi=softfp -Wl,--fix-cortex-a8"
425 make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF $NDKARCH"
427 # Android/MIPS, mips (MIPS32R1 hard-float), Android 4.0+ (ICS)
428 NDK=/opt/android/ndk
429 NDKABI=14
430 NDKVER=$NDK/toolchains/mipsel-linux-android-4.6
431 NDKP=$NDKVER/prebuilt/linux-x86/bin/mipsel-linux-android-
432 NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-mips"
433 make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF"
435 # Android/x86, x86 (i686 SSE3), Android 4.0+ (ICS)
436 NDK=/opt/android/ndk
437 NDKABI=14
438 NDKVER=$NDK/toolchains/x86-4.6
439 NDKP=$NDKVER/prebuilt/linux-x86/bin/i686-linux-android-
440 NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-x86"
441 make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF"
442 </pre>
444 You can cross-compile for <b id="ios">iOS 3.0+</b> (iPhone/iPad) using the <a href="http://developer.apple.com/devcenter/ios/index.action"><span class="ext">&raquo;</span>&nbsp;iOS SDK</a>:
445 </p>
446 <p style="font-size: 8pt;">
447 Note: <b>the JIT compiler is disabled for iOS</b>, because regular iOS Apps
448 are not allowed to generate code at runtime. You'll only get the performance
449 of the LuaJIT interpreter on iOS. This is still faster than plain Lua, but
450 much slower than the JIT compiler. Please complain to Apple, not me.
451 Or use Android. :-p
452 </p>
453 <pre class="code">
454 ISDKP=$(xcrun --sdk iphoneos --show-sdk-path)
455 ICC=$(xcrun --sdk iphoneos --find clang)
456 ISDKF="-arch armv7 -isysroot $ISDKP"
457 make DEFAULT_CC=clang HOST_CC="clang -m32 -arch i386" \
458 CROSS="$(dirname $ICC)/" TARGET_FLAGS="$ISDKF" TARGET_SYS=iOS
459 </pre>
461 <h3 id="consoles">Cross-compiling for consoles</h3>
463 Building LuaJIT for consoles requires both a supported host compiler
464 (x86 or x64) and a cross-compiler (to PPC or ARM) from the official
465 console SDK.
466 </p>
468 Due to restrictions on consoles, the JIT compiler is disabled and only
469 the fast interpreter is built. This is still faster than plain Lua,
470 but much slower than the JIT compiler. The FFI is disabled, too, since
471 it's not very useful in such an environment.
472 </p>
474 The following commands build a static library <tt>libluajit.a</tt>,
475 which can be linked against your game, just like the Lua library.
476 </p>
478 To cross-compile for <b id="ps3">PS3</b> from a Linux host (requires
479 32&nbsp;bit GCC, i.e. multilib Linux/x64) or a Windows host (requires
480 32&nbsp;bit MinGW), run this command:
481 </p>
482 <pre class="code">
483 make HOST_CC="gcc -m32" CROSS=ppu-lv2-
484 </pre>
486 To cross-compile for <b id="ps4">PS4</b> from a Windows host,
487 open a "Visual Studio .NET Command Prompt" (64&nbsp;bit host compiler),
488 <tt>cd</tt> to the directory where you've unpacked the sources and
489 run the following commands:
490 </p>
491 <pre class="code">
492 cd src
493 ps4build
494 </pre>
496 To cross-compile for <b id="psvita">PS Vita</b> from a Windows host,
497 open a "Visual Studio .NET Command Prompt" (32&nbsp;bit host compiler),
498 <tt>cd</tt> to the directory where you've unpacked the sources and
499 run the following commands:
500 </p>
501 <pre class="code">
502 cd src
503 psvitabuild
504 </pre>
506 To cross-compile for <b id="xbox360">Xbox 360</b> from a Windows host,
507 open a "Visual Studio .NET Command Prompt" (32&nbsp;bit host compiler),
508 <tt>cd</tt> to the directory where you've unpacked the sources and run
509 the following commands:
510 </p>
511 <pre class="code">
512 cd src
513 xedkbuild
514 </pre>
516 <h2 id="embed">Embedding LuaJIT</h2>
518 LuaJIT is API-compatible with Lua 5.1. If you've already embedded Lua
519 into your application, you probably don't need to do anything to switch
520 to LuaJIT, except link with a different library:
521 </p>
522 <ul>
523 <li>It's strongly suggested to build LuaJIT separately using the supplied
524 build system. Please do <em>not</em> attempt to integrate the individual
525 source files into your build tree. You'll most likely get the internal build
526 dependencies wrong or mess up the compiler flags. Treat LuaJIT like any
527 other external library and link your application with either the dynamic
528 or static library, depending on your needs.</li>
529 <li>If you want to load C modules compiled for plain Lua
530 with <tt>require()</tt>, you need to make sure the public symbols
531 (e.g. <tt>lua_pushnumber</tt>) are exported, too:
532 <ul><li>On POSIX systems you can either link to the shared library
533 or link the static library into your application. In the latter case
534 you'll need to export all public symbols from your main executable
535 (e.g. <tt>-Wl,-E</tt> on Linux) and add the external dependencies
536 (e.g. <tt>-lm -ldl</tt> on Linux).</li>
537 <li>Since Windows symbols are bound to a specific DLL name, you need to
538 link to the <tt>lua51.dll</tt> created by the LuaJIT build (do not rename
539 the DLL). You may link LuaJIT statically on Windows only if you don't
540 intend to load Lua/C modules at runtime.
541 </li></ul>
542 </li>
543 <li>
544 If you're building a 64 bit application on OSX which links directly or
545 indirectly against LuaJIT, you need to link your main executable
546 with these flags:
547 <pre class="code">
548 -pagezero_size 10000 -image_base 100000000
549 </pre>
550 Also, it's recommended to <tt>rebase</tt> all (self-compiled) shared libraries
551 which are loaded at runtime on OSX/x64 (e.g. C extension modules for Lua).
552 See: <tt>man rebase</tt>
553 </li>
554 </ul>
555 <p>Additional hints for initializing LuaJIT using the C API functions:</p>
556 <ul>
557 <li>Here's a
558 <a href="http://lua-users.org/wiki/SimpleLuaApiExample"><span class="ext">&raquo;</span>&nbsp;simple example</a>
559 for embedding Lua or LuaJIT into your application.</li>
560 <li>Make sure you use <tt>luaL_newstate</tt>. Avoid using
561 <tt>lua_newstate</tt>, since this uses the (slower) default memory
562 allocator from your system (no support for this on x64).</li>
563 <li>Make sure you use <tt>luaL_openlibs</tt> and not the old Lua 5.0 style
564 of calling <tt>luaopen_base</tt> etc. directly.</li>
565 <li>To change or extend the list of standard libraries to load, copy
566 <tt>src/lib_init.c</tt> to your project and modify it accordingly.
567 Make sure the <tt>jit</tt> library is loaded or the JIT compiler
568 will not be activated.</li>
569 <li>The <tt>bit.*</tt> module for bitwise operations
570 is already built-in. There's no need to statically link
571 <a href="http://bitop.luajit.org/"><span class="ext">&raquo;</span>&nbsp;Lua BitOp</a> to your application.</li>
572 </ul>
574 <h2 id="distro">Hints for Distribution Maintainers</h2>
576 The LuaJIT build system has extra provisions for the needs of most
577 POSIX-based distributions. If you're a package maintainer for
578 a distribution, <em>please</em> make use of these features and
579 avoid patching, subverting, autotoolizing or messing up the build system
580 in unspeakable ways.
581 </p>
583 There should be absolutely no need to patch <tt>luaconf.h</tt> or any
584 of the Makefiles. And please do not hand-pick files for your packages &mdash;
585 simply use whatever <tt>make install</tt> creates. There's a reason
586 for all of the files <em>and</em> directories it creates.
587 </p>
589 The build system uses GNU make and auto-detects most settings based on
590 the host you're building it on. This should work fine for native builds,
591 even when sandboxed. You may need to pass some of the following flags to
592 <em>both</em> the <tt>make</tt> and the <tt>make install</tt> command lines
593 for a regular distribution build:
594 </p>
595 <ul>
596 <li><tt>PREFIX</tt> overrides the installation path and should usually
597 be set to <tt>/usr</tt>. Setting this also changes the module paths and
598 the paths needed to locate the shared library.</li>
599 <li><tt>DESTDIR</tt> is an absolute path which allows you to install
600 to a shadow tree instead of the root tree of the build system.</li>
601 <li><tt>MULTILIB</tt> sets the architecture-specific library path component
602 for multilib systems. The default is <tt>lib</tt>.</li>
603 <li>Have a look at the top-level <tt>Makefile</tt> and <tt>src/Makefile</tt>
604 for additional variables to tweak. The following variables <em>may</em> be
605 overridden, but it's <em>not</em> recommended, except for special needs
606 like cross-builds:
607 <tt>BUILDMODE, CC, HOST_CC, STATIC_CC, DYNAMIC_CC, CFLAGS, HOST_CFLAGS,
608 TARGET_CFLAGS, LDFLAGS, HOST_LDFLAGS, TARGET_LDFLAGS, TARGET_SHLDFLAGS,
609 TARGET_FLAGS, LIBS, HOST_LIBS, TARGET_LIBS, CROSS, HOST_SYS, TARGET_SYS
610 </tt></li>
611 </ul>
613 The build system has a special target for an amalgamated build, i.e.
614 <tt>make amalg</tt>. This compiles the LuaJIT core as one huge C file
615 and allows GCC to generate faster and shorter code. Alas, this requires
616 lots of memory during the build. This may be a problem for some users,
617 that's why it's not enabled by default. But it shouldn't be a problem for
618 most build farms. It's recommended that binary distributions use this
619 target for their LuaJIT builds.
620 </p>
622 The tl;dr version of the above:
623 </p>
624 <pre class="code">
625 make amalg PREFIX=/usr && \
626 make install PREFIX=/usr DESTDIR=/tmp/buildroot
627 </pre>
629 Finally, if you encounter any difficulties, please
630 <a href="contact.html">contact me</a> first, instead of releasing a broken
631 package onto unsuspecting users. Because they'll usually gonna complain
632 to me (the upstream) and not you (the package maintainer), anyway.
633 </p>
634 <br class="flush">
635 </div>
636 <div id="foot">
637 <hr class="hide">
638 Copyright &copy; 2005-2018
639 <span class="noprint">
640 &middot;
641 <a href="contact.html">Contact</a>
642 </span>
643 </div>
644 </body>
645 </html>