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