-
Notifications
You must be signed in to change notification settings - Fork 177
/
rebar.config.script
43 lines (41 loc) · 1.44 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
%%-*- mode: erlang -*-
AddPortEnv = fun(Config, Flags, NewValue) ->
{port_env, Vals} = lists:keyfind(port_env, 1, Config),
Fold = fun({Flag, Val}, Acc) ->
case lists:member(Flag, Flags) of
true ->
[{Flag, Val ++ NewValue} | Acc];
false ->
Acc
end
end,
NewVals = lists:foldl(Fold, [], Vals),
lists:keyreplace(port_env, 1, Config, {port_env, NewVals})
end.
%% Set the minimum Mac target to 10.8 for 10.9 or greater. This runtime
%% check is needed since rebar's system_architecture check looks only at
%% the version of the OS used to build the Erlang runtime, not the version
%% actually running.
case os:type() of
{unix, darwin} ->
NewerOsxOpts = " -mmacosx-version-min=10.8 -stdlib=libc++",
BrewLibsOpts =
case os:find_executable("brew") of
false ->
"";
_Brew ->
HomebrewPrefix = string:trim(os:cmd("brew --prefix")),
" -L" ++ HomebrewPrefix ++ "/lib"
end,
[Mjr | _] = string:tokens(os:cmd("/usr/bin/uname -r"), "."),
Major = list_to_integer(Mjr),
Flags = ["CFLAGS", "CXXFLAGS", "LDFLAGS"],
if
Major >= 13 ->
AddPortEnv(CONFIG, Flags, NewerOsxOpts ++ BrewLibsOpts);
true ->
AddPortEnv(CONFIG, Flags, BrewLibsOpts)
end;
_ ->
CONFIG
end.