1#!/bin/bash
2
3set -e
4
5PYTHON=$(which python3 2>/dev/null)
6
7if [ ! -f ${PYTHON} ]; then
8  PYTHON=python
9fi
10
11if [ "$1" = "--gdb" ]; then
12  PYTHON="gdb --args $PYTHON"
13fi
14
15INSTALL_ARGS="--with-appname="${0}""
16
17if [ -f "$(dirname ${0})/carla-utils.pc" ]; then
18    cd "$(dirname ${0})/.."
19    INSTALL_PREFIX="$(pwd)"
20    INSTALL_FRONTENDDIR="${INSTALL_PREFIX}/source/frontend"
21else
22    INSTALL_PREFIX="X-PREFIX-X"
23    INSTALL_FRONTENDDIR="${INSTALL_PREFIX}/share/carla"
24    INSTALL_ARGS="${INSTALL_ARGS} --with-libprefix="${INSTALL_PREFIX}""
25fi
26
27if lsof -i:21337 > /dev/null; then
28    echo "NOTICE: Backend already running"
29else
30    ${PYTHON} "${INSTALL_FRONTENDDIR}/carla" ${INSTALL_ARGS} --osc-gui=21337 "$@" --with-appname="carla-osc-dsp"
31    echo "NOTICE: Backend was not running yet, start was triggered now"
32fi
33
34exec ${PYTHON} "${INSTALL_FRONTENDDIR}/carla-control" ${INSTALL_ARGS} osc.tcp://127.0.0.1:21337/Carla "$@"
35