Datasheet

You’ll use the make utility to control the build process. This utility reads a script, typically named
makefile, that describes the dependency relationships between the various source files and intermedi-
ate and final targets. For example, one of the lines in Lua’s
makefile is as follows:
lua.o: lua.c lua.h luaconf.h lauxlib.h lualib.h
Here, lua.o is the object file that corresponds to lua.c, the main source file of the Lua interpreter. The
other files that have the extension .h are header files that contain definitions and prototypes. This line
is interpreted as: If
lua.o is missing or if its timestamp is older than any of the timestamps of lua.c,
lua.h, luaconf.h, lauxlib.h, or lualib.h, then invoke the appropriate rule to generate lua.o. The
make utility is indispensable for keeping track of this kind of dependency and for automating the build
process.
If you type
make by itself, as shown in the following line, you get a list of the various platforms on
which you can build Lua:
make
The output looks like this:
Please do
make PLATFORM
where PLATFORM is one of these:
aix ansi bsd generic linux macosx mingw posix solaris
Select the platform that you’re on. For example, if you are compiling on Linux, execute the following
command:
make linux
You’ll see the commands displayed on the console as they are executed.
If you are familiar with building other open-source packages, you’ll notice that Lua’s approach is a little
different. There is no configuration stage to identify the characteristics of the system and create a tailor-
made makefile. Instead, the platform argument you provide is all the information make needs to select
the correct commands and parameters.
Because Lua has such standard requirements, it is unlikely that you will encounter any problems build-
ing it. If errors do occur at this stage, they are likely to be related to an incomplete installation of the C
development tools or incorrectly configured search paths for header files or libraries. If that happens,
read the documentation for your operating system distribution to install and configure the development
tools properly.
With the default settings used here,
make will generate the Lua interpreter (lua) and the Lua byte-code
compiler (
luac). These will be created in the src subdirectory. No shared libraries will be created all
of the Lua internals required by each of these executables will be statically linked. For example, compo-
nents such as the parser will be embedded into both
lua and luac, but the byte-code interpreter will be
embedded only into
lua.
9
Chapter 1: Getting Situated
04_069172 ch01.qxp 1/2/07 7:53 PM Page 9