% vim: set ft=erlang:
case erlang:function_exported(rebar3, main, 1) of
    true ->
        % rebar3
        CONFIG;
    false ->
        % rebar 2.x
        {_, ErlOpts} = lists:keyfind(erl_opts, 1, CONFIG),
        OverridenErlOpts = ErlOpts -- [warn_missing_spec],
        OverridenDeps =
            [{stacktrace_compat, ".*", {git, "https://github.com/g-andrade/stacktrace_compat.git",
                                        {tag, "1.0.2"}}},
             {certifi, ".*", {git, "https://github.com/certifi/erlang-certifi.git",
                              {tag, "2.4.2"}}},
             %% XXX we don't actually need parse_trans, but certifi imports it
             %% from hex.pm, which would make it impossible to build it on rebar 2.
             {parse_trans, ".*", {git, "https://github.com/uwiger/parse_trans.git",
                                  {tag, "3.3.0"}}},
             {ssl_verify_fun, ".*", {git, "https://github.com/deadtrickster/ssl_verify_fun.erl.git",
                                     {tag, "1.1.4"}}}],

        Config2 = lists:keystore(deps, 1, CONFIG, {deps,OverridenDeps}),
        lists:keystore(erl_opts, 1, Config2, {erl_opts,OverridenErlOpts})
end.
