Permalink
Fetching contributors…
Cannot retrieve contributors at this time
78 lines (67 sloc) 2.86 KB
%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ft=erlang ts=4 sw=4 et
UpdateDeps = fun(Config, NewDeps) ->
case lists:keyfind(deps, 1, Config) of
{deps, Deps} ->
NDeps = Deps ++ NewDeps,
lists:keyreplace(deps, 1, Config, {deps, NDeps});
false ->
Config ++ [{deps, NewDeps}]
end
end,
Dir = filename:dirname(SCRIPT),
ErtsVsn = case string:tokens(erlang:system_info(version), ".") of
[A,B] ->
{list_to_integer(A), list_to_integer(B), 0};
[A,B,C|_] ->
{list_to_integer(A), list_to_integer(B), list_to_integer(C)}
end.
%% generate a charset include file
ok = file:write_file(filename:join(Dir, "src/yaws_charset.hrl"),
case os:getenv("YAWS_CHARSET") of
false ->
<<"-define(YAWS_CHARSET, undefined).\n">>;
Charset ->
[<<"-define(YAWS_CHARSET, \"">>,
Charset, <<"\").\n">>]
end),
SoapDeps = [{erlsom, ".*", {git, "git://github.com/willemdj/erlsom.git", {branch, "master"}}},
{xmlrpc, ".*", {git, "git://github.com/rwbr/exmlrpc.git", {branch, "master"}}}],
Cfg0 = case os:getenv("YAWS_SOAP") of
false ->
CONFIG;
_ ->
UpdateDeps(CONFIG, SoapDeps)
end,
ErlOpts = case lists:keyfind(erl_opts, 1, Cfg0) of
{erl_opts, EOpts} -> EOpts;
false -> []
end,
PortEnv0 = case lists:keyfind(port_env, 1, Cfg0) of
{port_env, PEnv} -> PEnv;
false -> []
end,
PortSpecs0 = case lists:keyfind(port_specs, 1, Cfg0) of
{port_specs, PSpecs} ->
case os:getenv("YAWS_DISABLE_PAM") of
false ->
PSpecs;
_ ->
lists:keydelete("priv/lib/epam.so", 1, PSpecs)
end;
false -> []
end,
HaveSendFile = lists:keymember('HAVE_SENDFILE', 3, ErlOpts),
{PortEnv1, PortSpecs1} =
if
HaveSendFile ->
{PortEnv0 ++ [{"DRV_CFLAGS", "$DRV_CFLAGS -DHAVE_SENDFILE"}],
PortSpecs0 ++ [{"priv/lib/yaws_sendfile_drv.so",
["c_src/yaws_sendfile_drv.c", "c_src/hashtable.c"]}]};
true ->
{PortEnv0, PortSpecs0}
end,
Cfg1 = lists:keyreplace(erl_opts, 1, Cfg0, {erl_opts, ErlOpts}),
Cfg2 = lists:keyreplace(port_env, 1, Cfg1, {port_env, PortEnv1}),
Cfg3 = lists:keyreplace(port_specs, 1, Cfg2, {port_specs, PortSpecs1}),
Cfg3.