forked from saleyn/erlexec
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrebar.config.script
44 lines (37 loc) · 1.73 KB
/
rebar.config.script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
Arch = erlang:system_info(system_architecture),
Vsn = string:strip(os:cmd("git describe --always --tags --abbrev=0 | sed 's/^v//'"), right, $\n),
%% Check for Linux capability API (Install package: libcap-devel).
{LinCXX, LinLD} =
case file:read_file_info("/usr/include/sys/capability.h") of
{ok, _} ->
io:put_chars("INFO: Detected support of linux capabilities.\n"),
{" -DHAVE_CAP", " -lcap"};
_ ->
{"", ""}
end,
X64 = case Arch of
"x86_64" ++ _E -> " -m64";
_ -> ""
end,
% Replace configuration options read from rebar.config with those dynamically set below
lists:keymerge(1,
lists:keysort(1, [
{port_env, [{"solaris", "CXXFLAGS", "$CXXFLAGS -DHAVE_PTRACE" ++ X64},
{"solaris", "LDFLAGS", "$LDFLAGS -lrt" ++ X64},
{"darwin", "CXXFLAGS", "$CXXFLAGS -DHAVE_SETREUID -DHAVE_PTRACE" ++ X64},
{"darwin", "LDFLAGS", "$LDFLAGS" ++ X64},
{"linux", "CXXFLAGS", "$CXXFLAGS -DHAVE_SETRESUID -DHAVE_PTRACE" ++ LinCXX},
{"linux", "LDFLAGS", "$LDFLAGS" ++ LinLD},
{"CC", "g++"},
{"CXX", "g++"},
{"CXXFLAGS", "$CXXFLAGS -O0"}
]},
{port_specs,[{filename:join(["priv", Arch, "exec-port"]), ["c_src/*.cpp"]}]},
{edoc_opts, [{overview, "src/overview.edoc"},
{title, "The exec application"},
{includes, ["include"]},
{def, {vsn, Vsn}},
{stylesheet_file, "src/edoc.css"},
{app_default, "http://www.erlang.org/doc/man"}]}
]),
lists:keysort(1, CONFIG)).