1*572c4311SfengbojiangINSTALL for Lua 5.1 2*572c4311Sfengbojiang 3*572c4311Sfengbojiang* Building Lua 4*572c4311Sfengbojiang ------------ 5*572c4311Sfengbojiang Lua is built in the src directory, but the build process can be 6*572c4311Sfengbojiang controlled from the top-level Makefile. 7*572c4311Sfengbojiang 8*572c4311Sfengbojiang Building Lua on Unix systems should be very easy. First do "make" and 9*572c4311Sfengbojiang see if your platform is listed. If so, just do "make xxx", where xxx 10*572c4311Sfengbojiang is your platform name. The platforms currently supported are: 11*572c4311Sfengbojiang aix ansi bsd freebsd generic linux macosx mingw posix solaris 12*572c4311Sfengbojiang 13*572c4311Sfengbojiang If your platform is not listed, try the closest one or posix, generic, 14*572c4311Sfengbojiang ansi, in this order. 15*572c4311Sfengbojiang 16*572c4311Sfengbojiang See below for customization instructions and for instructions on how 17*572c4311Sfengbojiang to build with other Windows compilers. 18*572c4311Sfengbojiang 19*572c4311Sfengbojiang If you want to check that Lua has been built correctly, do "make test" 20*572c4311Sfengbojiang after building Lua. Also, have a look at the example programs in test. 21*572c4311Sfengbojiang 22*572c4311Sfengbojiang* Installing Lua 23*572c4311Sfengbojiang -------------- 24*572c4311Sfengbojiang Once you have built Lua, you may want to install it in an official 25*572c4311Sfengbojiang place in your system. In this case, do "make install". The official 26*572c4311Sfengbojiang place and the way to install files are defined in Makefile. You must 27*572c4311Sfengbojiang have the right permissions to install files. 28*572c4311Sfengbojiang 29*572c4311Sfengbojiang If you want to build and install Lua in one step, do "make xxx install", 30*572c4311Sfengbojiang where xxx is your platform name. 31*572c4311Sfengbojiang 32*572c4311Sfengbojiang If you want to install Lua locally, then do "make local". This will 33*572c4311Sfengbojiang create directories bin, include, lib, man, and install Lua there as 34*572c4311Sfengbojiang follows: 35*572c4311Sfengbojiang 36*572c4311Sfengbojiang bin: lua luac 37*572c4311Sfengbojiang include: lua.h luaconf.h lualib.h lauxlib.h lua.hpp 38*572c4311Sfengbojiang lib: liblua.a 39*572c4311Sfengbojiang man/man1: lua.1 luac.1 40*572c4311Sfengbojiang 41*572c4311Sfengbojiang These are the only directories you need for development. 42*572c4311Sfengbojiang 43*572c4311Sfengbojiang There are man pages for lua and luac, in both nroff and html, and a 44*572c4311Sfengbojiang reference manual in html in doc, some sample code in test, and some 45*572c4311Sfengbojiang useful stuff in etc. You don't need these directories for development. 46*572c4311Sfengbojiang 47*572c4311Sfengbojiang If you want to install Lua locally, but in some other directory, do 48*572c4311Sfengbojiang "make install INSTALL_TOP=xxx", where xxx is your chosen directory. 49*572c4311Sfengbojiang 50*572c4311Sfengbojiang See below for instructions for Windows and other systems. 51*572c4311Sfengbojiang 52*572c4311Sfengbojiang* Customization 53*572c4311Sfengbojiang ------------- 54*572c4311Sfengbojiang Three things can be customized by editing a file: 55*572c4311Sfengbojiang - Where and how to install Lua -- edit Makefile. 56*572c4311Sfengbojiang - How to build Lua -- edit src/Makefile. 57*572c4311Sfengbojiang - Lua features -- edit src/luaconf.h. 58*572c4311Sfengbojiang 59*572c4311Sfengbojiang You don't actually need to edit the Makefiles because you may set the 60*572c4311Sfengbojiang relevant variables when invoking make. 61*572c4311Sfengbojiang 62*572c4311Sfengbojiang On the other hand, if you need to select some Lua features, you'll need 63*572c4311Sfengbojiang to edit src/luaconf.h. The edited file will be the one installed, and 64*572c4311Sfengbojiang it will be used by any Lua clients that you build, to ensure consistency. 65*572c4311Sfengbojiang 66*572c4311Sfengbojiang We strongly recommend that you enable dynamic loading. This is done 67*572c4311Sfengbojiang automatically for all platforms listed above that have this feature 68*572c4311Sfengbojiang (and also Windows). See src/luaconf.h and also src/Makefile. 69*572c4311Sfengbojiang 70*572c4311Sfengbojiang* Building Lua on Windows and other systems 71*572c4311Sfengbojiang ----------------------------------------- 72*572c4311Sfengbojiang If you're not using the usual Unix tools, then the instructions for 73*572c4311Sfengbojiang building Lua depend on the compiler you use. You'll need to create 74*572c4311Sfengbojiang projects (or whatever your compiler uses) for building the library, 75*572c4311Sfengbojiang the interpreter, and the compiler, as follows: 76*572c4311Sfengbojiang 77*572c4311Sfengbojiang library: lapi.c lcode.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c 78*572c4311Sfengbojiang lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c 79*572c4311Sfengbojiang ltable.c ltm.c lundump.c lvm.c lzio.c 80*572c4311Sfengbojiang lauxlib.c lbaselib.c ldblib.c liolib.c lmathlib.c loslib.c 81*572c4311Sfengbojiang ltablib.c lstrlib.c loadlib.c linit.c 82*572c4311Sfengbojiang 83*572c4311Sfengbojiang interpreter: library, lua.c 84*572c4311Sfengbojiang 85*572c4311Sfengbojiang compiler: library, luac.c print.c 86*572c4311Sfengbojiang 87*572c4311Sfengbojiang If you use Visual Studio .NET, you can use etc/luavs.bat in its 88*572c4311Sfengbojiang "Command Prompt". 89*572c4311Sfengbojiang 90*572c4311Sfengbojiang If all you want is to build the Lua interpreter, you may put all .c files 91*572c4311Sfengbojiang in a single project, except for luac.c and print.c. Or just use etc/all.c. 92*572c4311Sfengbojiang 93*572c4311Sfengbojiang To use Lua as a library in your own programs, you'll need to know how to 94*572c4311Sfengbojiang create and use libraries with your compiler. 95*572c4311Sfengbojiang 96*572c4311Sfengbojiang As mentioned above, you may edit luaconf.h to select some features before 97*572c4311Sfengbojiang building Lua. 98*572c4311Sfengbojiang 99*572c4311Sfengbojiang(end of INSTALL) 100