forked from msantos/epcap
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrebar.config.script
More file actions
48 lines (48 loc) · 1.45 KB
/
rebar.config.script
File metadata and controls
48 lines (48 loc) · 1.45 KB
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
PFRING = fun(CONFIG) -> case os:getenv("PFRING") of
false ->
CONFIG;
Value ->
case filelib:is_dir(Value) of
true ->
case lists:keysearch(port_env, 1, CONFIG) of
{value, {port_env, Flags}} ->
{"EXE_LDFLAGS", LDFLAGS} = hd(Flags),
NewFlags = LDFLAGS ++ " -L " ++ Value ++ " -lpfring -lpthread -lnuma -lrt",
NewLDFLAGS = lists:keyreplace("EXE_LDFLAGS", 1, Flags, {"EXE_LDFLAGS", NewFlags}),
lists:keyreplace(port_env, 1, CONFIG, {port_env, NewLDFLAGS});
_ -> CONFIG
end;
_ -> CONFIG
end
end
end,
Pcap_create = fun(CONFIG) ->
Check = "
#include <pcap.h>
int main(int argc, char *argv[])
{
char errbuf[PCAP_ERRBUF_SIZE];
(void)pcap_create(NULL, errbuf);
return 0;
}",
ok = file:write_file("test_pcap_create.c", Check),
Retval = os:cmd("cc -o /dev/null test_pcap_create.c -lpcap > /dev/null 2>&1; printf \"%d\" $?"),
file:delete("test_pcap_create.c"),
case Retval of
"0" ->
Env = case os:getenv("EPCAP_CFLAGS") of
false -> "";
N -> N
end,
os:putenv("EPCAP_CFLAGS", Env ++ " -DHAVE_PCAP_CREATE"),
CONFIG;
_ ->
CONFIG
end
end,
lists:foldl(fun(Fun, Cfg) ->
Fun(Cfg)
end,
CONFIG,
[PFRING, Pcap_create]
).