#!/bin/bash

# See https://gist.github.com/anildigital/7c63b4e526017cea631db87d0cefefd0

RELATIVE_PATH=../bin/darwin/x64
INSTALL_PATH=`cd \`dirname "${RELATIVE_PATH}"\`; pwd`"/"`basename "${RELATIVE_PATH}"`

mkdir -p $INSTALL_PATH
rm -rf $INSTALL_PATH*

brew install jansson libnice openssl libusrsctp libwebsockets libmicrohttpd cmake rabbitmq-c sofia-sip opus libogg glib pkg-config gengetopt ffmpeg libconfig srtp

cd janus-gateway
sh autogen.sh
./configure --prefix=/tmp/janus --enable-post-processing PKG_CONFIG_PATH=/usr/local/opt/openssl/lib/pkgconfig
make
make install
make configs
cp -r /tmp/janus/ $INSTALL_PATH
make uninstall
make clean
