%%%------------------------------------------------------------------- %%% @author Evgeniy Khramtsov %%% @copyright (C) 2013, Evgeniy Khramtsov %%% @doc %%% %%% @end %%% Created : 1 May 2013 by Evgeniy Khramtsov %%%------------------------------------------------------------------- Cfg = case file:consult("vars.config") of {ok, Terms} -> Terms; _Err -> [] end, Macros = lists:flatmap( fun({roster_gateway_workaround, true}) -> [{d, 'ROSTER_GATEWAY_WORKAROUND'}]; ({flash_hack, true}) -> [{d, 'ENABLE_FLASH_HACK'}]; ({transient_supervisors, true}) -> [{d, 'NO_TRANSIENT_SUPERVISORS'}]; ({nif, true}) -> [{d, 'NIF'}]; ({db_type, mssql}) -> [{d, 'mssql'}]; (_) -> [] end, Cfg), DebugInfo = case lists:keysearch(debug, 1, Cfg) of {value, {debug, true}} -> [debug_info]; _ -> [] end, HiPE = case lists:keysearch(hipe, 1, Cfg) of {value, {hipe, true}} -> [native]; _ -> [] end, Includes = [{i, "include"}, {i, filename:join(["deps", "logger", "include"])}, {i, filename:join(["deps", "xml", "include"])}], SrcDirs = lists:foldl( fun({pubsub_ng, true}, Acc) -> [mod_pubsub_ng|Acc]; (_, Acc) -> Acc end, [], Cfg), Deps = [{logger, ".*", {git, "git://github.com/processone/p1_logger"}}, {cache_tab, ".*", {git, "git://github.com/processone/cache_tab"}}, {tls, ".*", {git, "git://github.com/processone/tls"}}, {stringprep, ".*", {git, "git://github.com/processone/stringprep"}}, {xml, ".*", {git, "git://github.com/processone/xml"}}, {xmlrpc, ".*", {git, "git://github.com/etnt/xmlrpc"}}], ConfigureCmd = fun(Pkg, Flags) -> {'get-deps', "sh -c 'cd deps/" ++ Pkg ++ " && ./configure" ++ Flags ++ "'"} end, XMLFlags = lists:foldl( fun({nif, true}, Acc) -> Acc ++ " --enable-nif"; ({full_xml, true}, Acc) -> Acc ++ " --enable-full-xml"; (_, Acc) -> Acc end, "", Cfg), PostHooks = [ConfigureCmd("tls", ""), ConfigureCmd("stringprep", ""), ConfigureCmd("xml", XMLFlags)], CfgDeps = lists:flatmap( fun({mysql, true}) -> [{mysql, ".*", {git, "git://github.com/processone/mysql"}}]; ({pgsql, true}) -> [{pgsql, ".*", {git, "git://github.com/processone/pgsql"}}]; ({pam, true}) -> [{epam, ".*", {git, "git://github.com/processone/epam"}}]; ({zlib, true}) -> [{ezlib, ".*", {git, "git://github.com/processone/zlib"}}]; ({stun, true}) -> [{stun, ".*", {git, "git://github.com/processone/stun"}}]; ({riak, true}) -> [{riakc, ".*", {git, "git://github.com/basho/riak-erlang-client"}}]; ({json, true}) -> [{jiffy, ".*", {git, "git://github.com/davisp/jiffy"}}]; ({iconv, true}) -> [{iconv, ".*", {git, "git://github.com/processone/eiconv"}}]; ({http, true}) -> [{ibrowse, ".*", {git, "git://github.com/cmullaparthi/ibrowse"}}, {lhttpc, ".*", {git, "git://github.com/esl/lhttpc"}}]; (_) -> [] end, Cfg), CfgPostHooks = lists:flatmap( fun({pam, true}) -> [ConfigureCmd("epam", "")]; ({zlib, true}) -> [ConfigureCmd("ezlib", "")]; ({iconv, true}) -> [ConfigureCmd("iconv", "")]; (_) -> [] end, Cfg), Config = [{erl_opts, Includes ++ Macros ++ HiPE ++ DebugInfo}, {src_dirs, [asn1, src | SrcDirs]}, {sub_dirs, ["rel"]}, {post_hooks, PostHooks ++ CfgPostHooks}, {deps, Deps ++ CfgDeps}], %%io:format("ejabberd configuration:~n ~p~n", [Config]), Config. %% Local Variables: %% mode: erlang %% End: %% vim: set filetype=erlang tabstop=8: