forked from svn2github/fuserl
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrebar.config.script
More file actions
70 lines (60 loc) · 1.69 KB
/
rebar.config.script
File metadata and controls
70 lines (60 loc) · 1.69 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
CheckHeaders = [
{"limits.h", "HAVE_LIMITS_H"},
{"sys/param.h", "HAVE_SYS_PARAM_H"},
{"sys/xattr.h", "HAVE_SYS_XATTR_H"}
],
try
IncPathsTmp = case rebar_utils:sh("scripts/print-gcc-include-paths.sh",
[{use_stdout, false}, return_on_error]) of
{ok, Result1} -> Result1;
{error, Reason1} -> throw(Reason1)
end,
IncPaths = string:tokens(IncPathsTmp, "\n"),
Defs = lists:foldl(
fun({Header, Define}, Acc) ->
case lists:any(fun(P) -> filelib:is_file(P ++ "/" ++ Header) end, IncPaths) of
true -> " -D" ++ Define ++ Acc;
false -> Acc
end
end,
"",
CheckHeaders),
FuseCFlags0 = case rebar_utils:sh("pkg-config --cflags fuse",
[{use_stdout, false}, return_on_error]) of
{ok, Result2} -> Result2;
{error, Reason2} -> throw(Reason2)
end,
FuseLDFlags0 = case rebar_utils:sh("pkg-config --libs fuse",
[{use_stdout, false}, return_on_error]) of
{ok, Result3} -> Result3;
{error, Reason3} -> throw(Reason3)
end,
FuseCFlags = [ C || C <- FuseCFlags0, (C =/= 10) and (C =/= 13) ] ++
case os:type() of
{unix, darwin} -> " -DDARWIN_TWEAKS";
_ -> ""
end,
FuseLDFlags = [ C || C <- FuseLDFlags0, (C =/= 10) and (C =/= 13) ],
Config = [
{port_specs, [
{"priv/fuserl_drv.so", [
"c_src/fuserl.c",
"c_src/fuserl_portability.c"
]},
{"priv/fuserl", [
"c_src/fuserldrv.c",
"c_src/driver2pipe.c"
]}
]},
{port_env, [
{"CFLAGS", FuseCFlags ++ Defs},
{"LDFLAGS", FuseLDFlags}
]}
],
% io:format("config: ~p~n", [Config]),
Config
catch
throw:{_Code, Error} ->
io:format("Error in fuserl rebar config script: ~s", [Error]),
CONFIG
end.