%% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ft=erlang ts=4 sw=4 et
%%
{sys, [
        {lib_dirs, ["../deps", "../deps/refuge_spatial/apps",
                    "../deps/couch_core/apps"]},
        {rel, "rcouch", git,
            [
                kernel,
                stdlib,
                sasl,
                public_key,
                ssl,
                os_mon,
                crypto,
                inets,
                xmerl,
                runtime_tools,
                mochiweb,
                cowboy,
                mochicow,
                ibrowse,
                oauth,
                jiffy,
                snappy,
                couch_stats,
                couch,
                couch_httpd,
                couch_index,
                couch_mrview,
                couch_changes,
                couch_replicator,
                vtree,
                refuge_spatial,
                couch_randomdoc,
                couch_dbupdates
            ]},
        {rel, "start_clean", "", [kernel, stdlib]},
        {boot_rel, "rcouch"},
        {profile, embedded},
        {relocatable, true},
        {app_file, strip},
        {debug_info, strip},

        {excl_sys_filters, ["^bin/.*", "^erts.*/bin/(dialyzer|typer)"]},
        {excl_archive_filters, [".*"]},



        {app, sasl, [{incl_cond, include}]},
        {app, crypto, [{incl_cond, include}]},
        {app, public_key, [{incl_cond, include}]},
        {app, ssl, [{incl_cond, include}]},
        {app, xmerl, [{incl_cond, include}]},

        %% dependencies
        {app, lager, [{incl_cond, include}]},
        {app, mochiweb, [{incl_cond, include}]},
        {app, cowboy, [{incl_cond, include}]},
        {app, mochicow, [{incl_cond, include}]},
        {app, oauth, [{incl_cond, include}]},
        {app, jiffy, [{incl_cond, include}]},
        {app, snappy, [{incl_cond, include}]},
        {app, ibrowse, [{incl_cond, include}]},

        %% couchdb
        {app, couch_stats, [{incl_cond, include}]},
        {app, couch, [{incl_cond, include}]},
        {app, couch_httpd, [{incl_cond, include}]},
        {app, couch_index, [{incl_cond, include}]},
        {app, couch_mrview, [{incl_cond, include}]},
        {app, couch_changes, [{incl_cond, include}]},
        {app, couch_replicator, [{incl_cond, include}]},
        {app, vtree, [{incl_cond, include}]},
        {app, refuge_spatial, [{incl_cond, include}]},
        {app, couch_randomdoc, [{incl_cond, include}]},
        {app, couch_dbupdates, [{incl_cond, include}]}

    ]}.

{target_dir, "rcouch"}.

{overlay_vars, "rcouch.config"}.

{overlay, [
        {mkdir, "log"},
        {mkdir, "run"},
        {mkdir, "data"},
        {copy, "files/erl", "{{erts_vsn}}/bin/erl"},
        {template, "files/nodetool", "{{erts_vsn}}/bin/nodetool"},
        {template, "files/rcouch", "bin/rcouch"},
        {template, "files/app.config", "etc/app.config"},
        {template, "files/vm.args", "etc/vm.args"},
        {template, "files/default.ini", "etc/default.ini"},
        {template, "files/local.ini", "etc/local.ini"},
        {copy, "files/install_upgrade.escript", "bin/install_upgrade.escript"},
        {copy, "../deps/couch_core/apps/couch/share"},
        {copy, "../deps/couch_core/apps/couch_httpd/share/www", "share/www"},
        {copy, "../deps/couch_core/apps/couch/couchjs", "bin/couchjs"},
        {copy, "files/refuge_logo.png", "share/www/image/logo.png"}
    ]}.
