-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathrebar.config.script
67 lines (58 loc) · 2.15 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
%% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ft=erlang ts=4 sw=4 et
%%
%% check if we build it statically or not
IsStatic = case os:getenv("ENABLE_STATIC") of
"no" -> false;
_ -> true
end,
%% set common dor
{ok, Cwd} = file:get_cwd(),
StaticDir = filename:join([Cwd, "c_src", ".libs"]),
%% helpers
Include = fun(Name) ->
filename:join([StaticDir, Name, "include"])
end,
Lib = fun(Name, FName) ->
filename:join([StaticDir, Name, "lib", FName])
end,
%% set top directory environment used by build_czmq.sh
os:putenv("CORE_TOP", filename:join([Cwd, "c_src"])),
%% set the flags to build czmq_port and czmq_benchmark
PortEnv = case IsStatic of
true ->
[{"CFLAGS", "-Wall -c -g -O2" ++
" -I" ++ Include("libsodium") ++
" -I" ++ Include("libzmq") ++
" -I" ++ Include("czmq")},
{"LDFLAGS", "-lerl_interface -lei -lstdc++ -lpthread -lrt" ++
" " ++ Lib("czmq", "libczmq.a") ++
" " ++ Lib("libzmq", "libzmq.a") ++
" " ++ Lib("libsodium", "libsodium.a") ++
" -lstdc++"}];
false ->
[{"CFLAGS", "-Wall -c -g -O2"},
{"LDFLAGS", "-lerl_interface -lei -lstdc++ -lpthread -lczmq -lzmq"}]
end,
%% config to build czmq_port and czmq_benchmark
PortInfo0 = [{port_env, PortEnv},
{port_specs, [
{filename:join(["priv", "czmq-port"]),
["c_src/czmq_port.c",
"c_src/erl_czmq.c",
"c_src/vector.c"]},
{filename:join(["priv", "czmq-benchmark"]),
["c_src/czmq_benchmark.c",
"c_src/erl_czmq.c",
"c_src/vector.c"]}
]}],
PortInfo = case IsStatic of
true ->
PortInfo0 ++
[{pre_hooks, [{compile, "./c_src/build_czmq.sh"}]},
{post_hooks, [{clean, "./c_src/build_czmq.sh clean"}]}];
false ->
PortInfo0
end,
%% update the rebar config
lists:keymerge(1,lists:keysort(1, PortInfo), lists:keysort(1, CONFIG)).