rootdir="$(cd "${0%/*}" 2>/dev/null; echo "$PWD")" install_local_rebar() { if [ ! -x "${rootdir}/bin/rebar" ]; then if [ ! -d "${rootdir}/src/rebar" ]; then git clone --depth 1 https://github.com/apache/couchdb-rebar.git ${rootdir}/src/rebar fi make -C ${rootdir}/src/rebar if [ ! -d "${rootdir}/bin/" ]; then mkdir ${rootdir}/bin/ fi mv ${rootdir}/src/rebar/rebar ${rootdir}/bin/rebar make -C ${rootdir}/src/rebar clean rm -rf ${rootdir}/src/rebar fi } install_local_enc() { if [ ! -x "${rootdir}/bin/enc" ]; then if [ ! -d "${rootdir}/src/erlang-native-compiler" ]; then git clone --depth 1 https://github.com/davisp/erlang-native-compiler.git ${rootdir}/src/erlang-native-compiler fi make -C ${rootdir}/src/erlang-native-compiler if [ ! -d "${rootdir}/bin/" ]; then mkdir ${rootdir}/bin/ fi mv ${rootdir}/src/erlang-native-compiler/enc ${rootdir}/bin/enc make -C ${rootdir}/src/erlang-native-compiler clean rm -rf ${rootdir}/src/erlang-native-compiler fi } if [ -z "${REBAR}" ]; then install_local_rebar REBAR=${rootdir}/bin/rebar fi if [ -z "${ENC}" ]; then install_local_enc ENC=${rootdir}/bin/enc fi