install.html 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  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="Author" content="Mike Pall">
  7. <meta name="Copyright" content="Copyright (C) 2005-2012, Mike Pall">
  8. <meta name="Language" content="en">
  9. <link rel="stylesheet" type="text/css" href="bluequad.css" media="screen">
  10. <link rel="stylesheet" type="text/css" href="bluequad-print.css" media="print">
  11. <style type="text/css">
  12. table.compat {
  13. line-height: 1.2;
  14. width: 600px;
  15. }
  16. table.compat td {
  17. border: 1px solid #bfcfff;
  18. font-size: 90%;
  19. height: 2.5em;
  20. }
  21. table.compat tr.compathead td {
  22. font-weight: bold;
  23. border-bottom: 2px solid #bfcfff;
  24. }
  25. tr.compathead td.compatos {
  26. vertical-align: top;
  27. }
  28. table.compat td.compatcpu {
  29. width: 16%;
  30. border-right: 2px solid #bfcfff;
  31. }
  32. td.compatos {
  33. width: 21%;
  34. vertical-align: middle;
  35. }
  36. td.compatno {
  37. background-color: #d0d0d0;
  38. }
  39. </style>
  40. </head>
  41. <body>
  42. <div id="site">
  43. <a href="http://luajit.org"><span>Lua<span id="logo">JIT</span></span></a>
  44. </div>
  45. <div id="head">
  46. <h1>Installation</h1>
  47. </div>
  48. <div id="nav">
  49. <ul><li>
  50. <a href="luajit.html">LuaJIT</a>
  51. <ul><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://luajit.org/download.html">Download <span class="ext">&raquo;</span></a>
  83. </li><li>
  84. <a href="http://wiki.luajit.org/">Wiki <span class="ext">&raquo;</span></a>
  85. </li><li>
  86. <a href="http://luajit.org/list.html">Mailing List <span class="ext">&raquo;</span></a>
  87. </li></ul>
  88. </div>
  89. <div id="main">
  90. <p>
  91. LuaJIT is only distributed as a source package. This page explains
  92. how to build and install LuaJIT with different operating systems
  93. and C&nbsp;compilers.
  94. </p>
  95. <p>
  96. For the impatient (on POSIX systems):
  97. </p>
  98. <pre class="code">
  99. make &amp;&amp; sudo make install
  100. </pre>
  101. <p>
  102. LuaJIT currently builds out-of-the box on most systems.
  103. Here's the compatibility matrix for the supported combinations of
  104. operating systems, CPUs and compilers:
  105. </p>
  106. <table class="compat">
  107. <tr class="compathead">
  108. <td class="compatcpu">CPU / OS</td>
  109. <td class="compatos"><a href="#posix">Linux</a> or<br><a href="#android">Android</a></td>
  110. <td class="compatos"><a href="#posix">*BSD, Other</a></td>
  111. <td class="compatos"><a href="#posix">OSX 10.4+</a> or<br><a href="#ios">iOS 3.0+</a></td>
  112. <td class="compatos"><a href="#windows">Windows<br>XP/Vista/7</a></td>
  113. </tr>
  114. <tr class="odd separate">
  115. <td class="compatcpu">x86 (32 bit)</td>
  116. <td class="compatos">GCC 4.x<br>GCC 3.4</td>
  117. <td class="compatos">GCC 4.x<br>GCC 3.4</td>
  118. <td class="compatos">GCC 4.x<br>GCC 3.4</td>
  119. <td class="compatos">MSVC, MSVC/EE<br>WinSDK<br>MinGW, Cygwin</td>
  120. </tr>
  121. <tr class="even">
  122. <td class="compatcpu">x64 (64 bit)</td>
  123. <td class="compatos">GCC 4.x</td>
  124. <td class="compatos compatno">&nbsp;</td>
  125. <td class="compatos">GCC 4.x</td>
  126. <td class="compatos">MSVC + SDK v7.0<br>WinSDK v7.0</td>
  127. </tr>
  128. <tr class="odd">
  129. <td class="compatcpu"><a href="#cross2">ARMv5+<br>ARM9E+</a></td>
  130. <td class="compatos">GCC 4.2+</td>
  131. <td class="compatos">GCC 4.2+</td>
  132. <td class="compatos">GCC 4.2+</td>
  133. <td class="compatos compatno">&nbsp;</td>
  134. </tr>
  135. <tr class="even">
  136. <td class="compatcpu"><a href="#cross2">PPC</a></td>
  137. <td class="compatos">GCC 4.3+</td>
  138. <td class="compatos">GCC 4.3+<br>GCC 4.1 (<a href="#cross2">PS3</a>)</td>
  139. <td class="compatos compatno">&nbsp;</td>
  140. <td class="compatos compatno">&nbsp;</td>
  141. </tr>
  142. <tr class="odd">
  143. <td class="compatcpu"><a href="#cross2">PPC/e500v2</a></td>
  144. <td class="compatos">GCC 4.3+</td>
  145. <td class="compatos">GCC 4.3+</td>
  146. <td class="compatos compatno">&nbsp;</td>
  147. <td class="compatos compatno">&nbsp;</td>
  148. </tr>
  149. <tr class="even">
  150. <td class="compatcpu"><a href="#cross2">MIPS</a></td>
  151. <td class="compatos">GCC 4.3+</td>
  152. <td class="compatos">GCC 4.3+</td>
  153. <td class="compatos compatno">&nbsp;</td>
  154. <td class="compatos compatno">&nbsp;</td>
  155. </tr>
  156. </table>
  157. <h2>Configuring LuaJIT</h2>
  158. <p>
  159. The standard configuration should work fine for most installations.
  160. Usually there is no need to tweak the settings. The following files
  161. hold all user-configurable settings:
  162. </p>
  163. <ul>
  164. <li><tt>src/luaconf.h</tt> sets some configuration variables.</li>
  165. <li><tt>Makefile</tt> has settings for <b>installing</b> LuaJIT (POSIX
  166. only).</li>
  167. <li><tt>src/Makefile</tt> has settings for <b>compiling</b> LuaJIT
  168. under POSIX, MinGW or Cygwin.</li>
  169. <li><tt>src/msvcbuild.bat</tt> has settings for compiling LuaJIT with
  170. MSVC or WinSDK.</li>
  171. </ul>
  172. <p>
  173. Please read the instructions given in these files, before changing
  174. any settings.
  175. </p>
  176. <h2 id="posix">POSIX Systems (Linux, OSX, *BSD etc.)</h2>
  177. <h3>Prerequisites</h3>
  178. <p>
  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>
  183. <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.0-beta10.tar.gz
  191. cd LuaJIT-2.0.0-beta10</pre>
  192. <h3>Building LuaJIT</h3>
  193. <p>
  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>
  201. <p>
  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>
  206. <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>
  214. <p>
  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>
  219. <p>
  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>
  229. <p>
  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>
  235. <p>
  236. Obviously the prefixes given during build and installation need to be the same.
  237. </p>
  238. <p style="color: #c00000;">
  239. Note: to avoid overwriting a previous version, the beta test releases
  240. only install the LuaJIT executable under the versioned name (i.e.
  241. <tt>luajit-2.0.0-beta10</tt>). You probably want to create a symlink
  242. for convenience, with a command like this:
  243. </p>
  244. <pre class="code" style="color: #c00000;">
  245. sudo ln -sf luajit-2.0.0-beta10&nbsp;/usr/local/bin/luajit
  246. </pre>
  247. <h2 id="windows">Windows Systems</h2>
  248. <h3>Prerequisites</h3>
  249. <p>
  250. Either install one of the open source SDKs
  251. (<a href="http://mingw.org/"><span class="ext">&raquo;</span>&nbsp;MinGW</a> or
  252. <a href="http://www.cygwin.com/"><span class="ext">&raquo;</span>&nbsp;Cygwin</a>), which come with a modified
  253. GCC plus the required development headers.
  254. </p>
  255. <p>
  256. Or install Microsoft's Visual C++ (MSVC). The freely downloadable
  257. <a href="http://www.microsoft.com/Express/VC/"><span class="ext">&raquo;</span>&nbsp;Express Edition</a>
  258. works just fine, but only contains an x86 compiler.
  259. </p>
  260. <p>
  261. The freely downloadable
  262. <a href="http://msdn.microsoft.com/en-us/windowsserver/bb980924.aspx"><span class="ext">&raquo;</span>&nbsp;Windows SDK</a>
  263. only comes with command line tools, but this is all you need to build LuaJIT.
  264. It contains x86 and x64 compilers.
  265. </p>
  266. <p>
  267. Next, download the source package and unpack it using an archive manager
  268. (e.g. the Windows Explorer) to a directory of your choice.
  269. </p>
  270. <h3>Building with MSVC</h3>
  271. <p>
  272. Open a "Visual Studio .NET Command Prompt", <tt>cd</tt> to the
  273. directory where you've unpacked the sources and run these commands:
  274. </p>
  275. <pre class="code">
  276. cd src
  277. msvcbuild
  278. </pre>
  279. <p>
  280. Then follow the installation instructions below.
  281. </p>
  282. <h3>Building with the Windows SDK</h3>
  283. <p>
  284. Open a "Windows SDK Command Shell" and select the x86 compiler:
  285. </p>
  286. <pre class="code">
  287. setenv /release /x86
  288. </pre>
  289. <p>
  290. Or select the x64 compiler:
  291. </p>
  292. <pre class="code">
  293. setenv /release /x64
  294. </pre>
  295. <p>
  296. Then <tt>cd</tt> to the directory where you've unpacked the sources
  297. and run these commands:
  298. </p>
  299. <pre class="code">
  300. cd src
  301. msvcbuild
  302. </pre>
  303. <p>
  304. Then follow the installation instructions below.
  305. </p>
  306. <h3>Building with MinGW or Cygwin</h3>
  307. <p>
  308. Open a command prompt window and make sure the MinGW or Cygwin programs
  309. are in your path. Then <tt>cd</tt> to the directory where
  310. you've unpacked the sources and run this command for MinGW:
  311. </p>
  312. <pre class="code">
  313. mingw32-make
  314. </pre>
  315. <p>
  316. Or this command for Cygwin:
  317. </p>
  318. <pre class="code">
  319. make
  320. </pre>
  321. <p>
  322. Then follow the installation instructions below.
  323. </p>
  324. <h3>Installing LuaJIT</h3>
  325. <p>
  326. Copy <tt>luajit.exe</tt> and <tt>lua51.dll</tt> (built in the <tt>src</tt>
  327. directory) to a newly created directory (any location is ok).
  328. Add <tt>lua</tt> and <tt>lua\jit</tt> directories below it and copy
  329. all Lua files from the <tt>src\jit</tt> directory of the distribution
  330. to the latter directory.
  331. </p>
  332. <p>
  333. There are no hardcoded
  334. absolute path names &mdash; all modules are loaded relative to the
  335. directory where <tt>luajit.exe</tt> is installed
  336. (see <tt>src/luaconf.h</tt>).
  337. </p>
  338. <h2 id="cross">Cross-compiling LuaJIT</h2>
  339. <p>
  340. The GNU Makefile-based build system allows cross-compiling on any host
  341. for any supported target, as long as both architectures have the same
  342. pointer size. If you want to cross-compile to any 32 bit target on an
  343. x64 OS, you need to install the multilib development package (e.g.
  344. <tt>libc6-dev-i386</tt> on Debian/Ubuntu) and build a 32 bit host part
  345. (<tt>HOST_CC="gcc -m32"</tt>).
  346. </p>
  347. <p>
  348. You need to specify <tt>TARGET_SYS</tt> whenever the host OS and the
  349. target OS differ, or you'll get assembler or linker errors. E.g. if
  350. you're compiling on a Windows or OSX host for embedded Linux or Android,
  351. you need to add <tt>TARGET_SYS=Linux</tt> to the examples below. For a
  352. minimal target OS, you may need to disable the built-in allocator in
  353. <tt>src/Makefile</tt> and use <tt>TARGET_SYS=Other</tt>. The examples
  354. below only show some popular targets &mdash; please check the comments
  355. in <tt>src/Makefile</tt> for more details.
  356. </p>
  357. <pre class="code">
  358. # Cross-compile to a 32 bit binary on a multilib x64 OS
  359. make CC="gcc -m32"
  360. # Cross-compile on Debian/Ubuntu for Windows (mingw32 package)
  361. make HOST_CC="gcc -m32" CROSS=i586-mingw32msvc- TARGET_SYS=Windows
  362. </pre>
  363. <p id="cross2">
  364. The <tt>CROSS</tt> prefix allows specifying a standard GNU cross-compile
  365. toolchain (Binutils, GCC and a matching libc). The prefix may vary
  366. depending on the <tt>--target</tt> the toolchain was built for (note the
  367. <tt>CROSS</tt> prefix has a trailing <tt>"-"</tt>). The examples below
  368. use the canonical toolchain triplets for Linux.
  369. </p>
  370. <p>
  371. Since there's often no easy way to detect CPU features at runtime, it's
  372. important to compile with the proper CPU or architecture settings. You
  373. can specify these when building the toolchain yourself. Or add
  374. <tt>-mcpu=...</tt> or <tt>-march=...</tt> to <tt>TARGET_CFLAGS</tt>. For
  375. ARM it's important to have the correct <tt>-mfloat-abi=...</tt> setting,
  376. too. Otherwise LuaJIT may not run at the full performance of your target
  377. CPU.
  378. </p>
  379. <pre class="code">
  380. # ARM soft-float
  381. make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \
  382. TARGET_CFLAGS="-mfloat-abi=soft"
  383. # ARM soft-float ABI with VFP (example for Cortex-a8)
  384. make HOST_CC="gcc -m32" CROSS=arm-linux-gnueabi- \
  385. TARGET_CFLAGS="-mcpu=cortex-a8 -mfloat-abi=softfp"
  386. # ARM hard-float ABI with VFP (armhf, requires recent toolchain)
  387. 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-
  392. # PS3 (fast interpreter only)
  393. make HOST_CC="gcc -m32" CROSS=ppu-lv2-
  394. # MIPS big-endian
  395. make HOST_CC="gcc -m32" CROSS=mips-linux-
  396. # MIPS little-endian
  397. make HOST_CC="gcc -m32" CROSS=mipsel-linux-
  398. </pre>
  399. <p>
  400. You can cross-compile for <b id="android">Android (ARM)</b> using the <a href="http://developer.android.com/sdk/ndk/index.html"><span class="ext">&raquo;</span>&nbsp;Android NDK</a>.
  401. The environment variables need to match the install locations and the
  402. desired target platform. E.g. Android&nbsp;2.2 corresponds to ABI level&nbsp;8:
  403. </p>
  404. <pre class="code">
  405. NDK=/opt/android/ndk
  406. NDKABI=8
  407. NDKVER=$NDK/toolchains/arm-linux-androideabi-4.4.3
  408. NDKP=$NDKVER/prebuilt/linux-x86/bin/arm-linux-androideabi-
  409. NDKF="--sysroot $NDK/platforms/android-$NDKABI/arch-arm"
  410. make HOST_CC="gcc -m32" CROSS=$NDKP TARGET_FLAGS="$NDKF"
  411. </pre>
  412. <p>
  413. 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>.
  414. The environment variables need to match the iOS SDK version:
  415. </p>
  416. <p style="font-size: 8pt;">
  417. Note: <b>the JIT compiler is disabled for iOS</b>, because regular iOS Apps
  418. are not allowed to generate code at runtime. You'll only get the performance
  419. of the LuaJIT interpreter on iOS. This is still faster than plain Lua, but
  420. much slower than the JIT compiler. Please complain to Apple, not me.
  421. Or use Android. :-p
  422. </p>
  423. <pre class="code">
  424. IXCODE=/Applications/Xcode45-DP4.app/Contents
  425. ISDK=$IXCODE/Developer/Platforms/iPhoneOS.platform/Developer
  426. ISDKVER=iPhoneOS6.0.sdk
  427. ISDKP=$ISDK/usr/bin/
  428. ISDKF="-arch armv7 -isysroot $ISDK/SDKs/$ISDKVER"
  429. make HOST_CC="gcc -m32 -arch i386" CROSS=$ISDKP TARGET_FLAGS="$ISDKF" \
  430. TARGET_SYS=iOS
  431. </pre>
  432. <h2 id="embed">Embedding LuaJIT</h2>
  433. <p>
  434. LuaJIT is API-compatible with Lua 5.1. If you've already embedded Lua
  435. into your application, you probably don't need to do anything to switch
  436. to LuaJIT, except link with a different library:
  437. </p>
  438. <ul>
  439. <li>It's strongly suggested to build LuaJIT separately using the supplied
  440. build system. Please do <em>not</em> attempt to integrate the individual
  441. source files into your build tree. You'll most likely get the internal build
  442. dependencies wrong or mess up the compiler flags. Treat LuaJIT like any
  443. other external library and link your application with either the dynamic
  444. or static library, depending on your needs.</li>
  445. <li>If you want to load C modules compiled for plain Lua
  446. with <tt>require()</tt>, you need to make sure the public symbols
  447. (e.g. <tt>lua_pushnumber</tt>) are exported, too:
  448. <ul><li>On POSIX systems you can either link to the shared library
  449. or link the static library into your application. In the latter case
  450. you'll need to export all public symbols from your main executable
  451. (e.g. <tt>-Wl,-E</tt> on Linux) and add the external dependencies
  452. (e.g. <tt>-lm -ldl</tt> on Linux).</li>
  453. <li>Since Windows symbols are bound to a specific DLL name, you need to
  454. link to the <tt>lua51.dll</tt> created by the LuaJIT build (do not rename
  455. the DLL). You may link LuaJIT statically on Windows only if you don't
  456. intend to load Lua/C modules at runtime.
  457. </li></ul>
  458. </li>
  459. <li>
  460. If you're building a 64 bit application on OSX which links directly or
  461. indirectly against LuaJIT, you need to link your main executable
  462. with these flags:
  463. <pre class="code">
  464. -pagezero_size 10000 -image_base 100000000
  465. </pre>
  466. Also, it's recommended to <tt>rebase</tt> all (self-compiled) shared libraries
  467. which are loaded at runtime on OSX/x64 (e.g. C extension modules for Lua).
  468. See: <tt>man rebase</tt>
  469. </li>
  470. </ul>
  471. <p>Additional hints for initializing LuaJIT using the C API functions:</p>
  472. <ul>
  473. <li>Here's a
  474. <a href="http://lua-users.org/wiki/SimpleLuaApiExample"><span class="ext">&raquo;</span>&nbsp;simple example</a>
  475. for embedding Lua or LuaJIT into your application.</li>
  476. <li>Make sure you use <tt>luaL_newstate</tt>. Avoid using
  477. <tt>lua_newstate</tt>, since this uses the (slower) default memory
  478. allocator from your system (no support for this on x64).</li>
  479. <li>Make sure you use <tt>luaL_openlibs</tt> and not the old Lua 5.0 style
  480. of calling <tt>luaopen_base</tt> etc. directly.</li>
  481. <li>To change or extend the list of standard libraries to load, copy
  482. <tt>src/lib_init.c</tt> to your project and modify it accordingly.
  483. Make sure the <tt>jit</tt> library is loaded or the JIT compiler
  484. will not be activated.</li>
  485. <li>The <tt>bit.*</tt> module for bitwise operations
  486. is already built-in. There's no need to statically link
  487. <a href="http://bitop.luajit.org/"><span class="ext">&raquo;</span>&nbsp;Lua BitOp</a> to your application.</li>
  488. </ul>
  489. <h2 id="distro">Hints for Distribution Maintainers</h2>
  490. <p>
  491. The LuaJIT build system has extra provisions for the needs of most
  492. POSIX-based distributions. If you're a package maintainer for
  493. a distribution, <em>please</em> make use of these features and
  494. avoid patching, subverting, autotoolizing or messing up the build system
  495. in unspeakable ways.
  496. </p>
  497. <p>
  498. There should be absolutely no need to patch <tt>luaconf.h</tt> or any
  499. of the Makefiles. And please do not hand-pick files for your packages &mdash;
  500. simply use whatever <tt>make install</tt> creates. There's a reason
  501. for all of the files <em>and</em> directories it creates.
  502. </p>
  503. <p>
  504. The build system uses GNU make and auto-detects most settings based on
  505. the host you're building it on. This should work fine for native builds,
  506. even when sandboxed. You may need to pass some of the following flags to
  507. <em>both</em> the <tt>make</tt> and the <tt>make install</tt> command lines
  508. for a regular distribution build:
  509. </p>
  510. <ul>
  511. <li><tt>PREFIX</tt> overrides the installation path and should usually
  512. be set to <tt>/usr</tt>. Setting this also changes the module paths and
  513. the <tt>-rpath</tt> of the shared library.</li>
  514. <li><tt>DESTDIR</tt> is an absolute path which allows you to install
  515. to a shadow tree instead of the root tree of the build system.</li>
  516. <li>Have a look at the top-level <tt>Makefile</tt> and <tt>src/Makefile</tt>
  517. for additional variables to tweak. The following variables <em>may</em> be
  518. overridden, but it's <em>not</em> recommended, except for special needs
  519. like cross-builds:
  520. <tt>BUILDMODE, CC, HOST_CC, STATIC_CC, DYNAMIC_CC, CFLAGS, HOST_CFLAGS,
  521. TARGET_CFLAGS, LDFLAGS, HOST_LDFLAGS, TARGET_LDFLAGS, TARGET_SHLDFLAGS,
  522. TARGET_FLAGS, LIBS, HOST_LIBS, TARGET_LIBS, CROSS, HOST_SYS, TARGET_SYS
  523. </tt></li>
  524. </ul>
  525. <p>
  526. The build system has a special target for an amalgamated build, i.e.
  527. <tt>make amalg</tt>. This compiles the LuaJIT core as one huge C file
  528. and allows GCC to generate faster and shorter code. Alas, this requires
  529. lots of memory during the build. This may be a problem for some users,
  530. that's why it's not enabled by default. But it shouldn't be a problem for
  531. most build farms. It's recommended that binary distributions use this
  532. target for their LuaJIT builds.
  533. </p>
  534. <p>
  535. The tl;dr version of the above:
  536. </p>
  537. <pre class="code">
  538. make amalg PREFIX=/usr && \
  539. make install PREFIX=/usr DESTDIR=/tmp/buildroot
  540. </pre>
  541. <p>
  542. Finally, if you encounter any difficulties, please
  543. <a href="contact.html">contact me</a> first, instead of releasing a broken
  544. package onto unsuspecting users. Because they'll usually gonna complain
  545. to me (the upstream) and not you (the package maintainer), anyway.
  546. </p>
  547. <br class="flush">
  548. </div>
  549. <div id="foot">
  550. <hr class="hide">
  551. Copyright &copy; 2005-2012 Mike Pall
  552. <span class="noprint">
  553. &middot;
  554. <a href="contact.html">Contact</a>
  555. </span>
  556. </div>
  557. </body>
  558. </html>