aboutsummaryrefslogtreecommitdiff
path: root/docs/platform_agnostic_external_dependencies.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/platform_agnostic_external_dependencies.md')
-rw-r--r--docs/platform_agnostic_external_dependencies.md93
1 files changed, 93 insertions, 0 deletions
diff --git a/docs/platform_agnostic_external_dependencies.md b/docs/platform_agnostic_external_dependencies.md
new file mode 100644
index 00000000..97f983fa
--- /dev/null
+++ b/docs/platform_agnostic_external_dependencies.md
@@ -0,0 +1,93 @@
1# Platform-agnostic external dependencies
2
3Since 0.6, LuaRocks supports specifying files for external dependency search
4in a platform-agnostic way. When filenames given in the
5`external_dependencies` section of a [rockspec](rockspec_format.md) don't
6have any dot (".") characters, their contents are substituted according to the
7patterns given in the `external_deps_patterns` table of the [configuration
8file](config_file_format.md).
9
10These patterns will typically not be used in the configuration file, as
11LuaRocks provides sensible defaults. The default patterns defined on Unix are:
12
13```
14bin = {"?"}
15lib = {"lib?.a", "lib?.so"}
16include = {"?.h"}
17```
18
19On Windows the defaults are:
20
21```
22bin = {"?.exe", "?.bat"}
23lib = {"?.lib", "?.dll"}
24include = {"?.h"}
25```
26
27For example, a [rockspec](rockspec_format.md) can define an external
28dependency like this:
29
30```
31external_dependencies = {
32 FOO = {
33 library = "foo"
34 }
35 }
36```
37
38and this will result in searches for libfoo.a or libfoo.so on Unix systems,
39and foo.lib or foo.dll on Windows. For entries that have more than one
40pattern, such as lib, only one entry needs to be satisfied.
41
42In other words, the value "foo" you see in the
43external_dependencies.FOO.library entry is the same value you would use when
44linking the library, for example -lfoo. In addition, once you added FOO in the
45external_dependencies, this means you can pass entries such as FOO_DIR and
46FOO_LIBDIR to the `luarocks` command-line tool, in case you have these
47libraries in non-standard locations. For example, if the user installed the
48library in a custom location in their own home directory, it would still be
49usable, like this:
50
51```
52luarocks install my_rockspec_using_foo-1.0-1.rockspec FOO_LIBDIR=/home/joeuser/foo/lib
53```
54
55When performing external dependency checks during installation (as opposed to
56build) of rocks, static libraries and headers are not searched. The
57`runtime_external_deps_patterns` table is used instead.
58
59Since 3.4.0, the variable DEPS_DIR which doesn't depend on the name FOO, could
60also used, like this:
61
62```
63luarocks install my_rockspec_using_foo-1.0-1.rockspec DEPS_DIR=/home/joeuser/foo/lib
64```
65
66# When filenames don't match
67
68If the pattern system is not enough to hide platform differences, you can
69always resort to [per-platform overrides](platform_overrides.md). For example:
70
71```
72external_dependencies = {
73 FOO = {
74 library = "foo"
75 }
76 platforms = {
77 win32 = {
78 FOO = {
79 library = "winfoo32.dll"
80 }
81 }
82 }
83}
84```
85
86# Statically linked libraries and dependencies
87
88If your rock links a library statically, avoid adding a library search in its
89[rockspec](rockspec_format.md)'s `external_dependencies` table. Search for a
90header instead, so that the external dependency search does not fail when
91users install a binary rock and they don't have the library installed
92separately.
93