aboutsummaryrefslogtreecommitdiff
path: root/docs/paths_and_external_dependencies.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/paths_and_external_dependencies.md')
-rw-r--r--docs/paths_and_external_dependencies.md43
1 files changed, 43 insertions, 0 deletions
diff --git a/docs/paths_and_external_dependencies.md b/docs/paths_and_external_dependencies.md
new file mode 100644
index 00000000..c7a59408
--- /dev/null
+++ b/docs/paths_and_external_dependencies.md
@@ -0,0 +1,43 @@
1# Paths and external dependencies
2
3Many Lua rocks are bindings to C libraries: for example,
4[luaossl](https://luarocks.org/modules/daurnimator/luaossl) is a binding
5library to the [OpenSSL](https://openssl.org) library. This means that, in our
6example, luaossl _depends on_ OpenSSL. But since this is not a regular
7rock-to-rock dependency (if it were, LuaRocks could solve this by itself), we
8call this an **external dependency**.
9
10When building a rock with external dependencies, LuaRocks needs to make sure
11the necessary C libraries and headers are installed, and know where those C
12libraries are.
13
14## Specifying external dependencies in your rockspecs
15
16When writing a rock with external dependencies, one needs to be careful to
17avoid the "works on my machine" situation: when you write code that hardcodes
18the location of external dependencies as they are in your system, but then
19fails to build in other people's systems.
20
21The way to avoid this problem is to avoid any hardcoded paths. Instead, the
22`build` section of a [rockspec](rockspec_format.md) should make use of path
23variables. If not using the `builtin` build type, paths set by the module's
24own build system must not be relied on and explicit paths should be passed to
25it by the rockspec instead.
26
27Paths where LuaRocks should install files into are defined as the `PREFIX`,
28`LUADIR`, `LIBDIR` and `BINDIR` variables. (See the [Config file
29format](config_file_format.md) page for details.)
30
31Paths for external dependencies (such as C libraries used in the compilation
32of modules) are generated from the `external_dependencies` section of the
33rockspec (see the [Rockspec format](rockspec_format.md) page for details.) Lua
34itself is considered a special external dependency.
35
36These path variables are set in the global `variables` table defined in the
37[config file](config_file_format.md). Their values are populated automatically
38by LuaRocks, but can be overriden by the user (either by setting them directly
39in the config file, or by passing them through the "luarocks" command line).
40
41The `variables` table always contains entries for `LUA_BINDIR`, `LUA_INCDIR`
42and `LUA_LIBDIR`. Like the other external dependency variables, these can be
43overriden in the LuaRocks config file or in the command line. \ No newline at end of file