#!/bin/sh set -e # delete old vpm.d if another run left it in /tmp rm -f /tmp/vpm.d # find the executable location (note: must stay mac compatible here) VIBEBINARY=$(readlink "$0" || true) if [ ! -n "$VIBEBINARY" ]; then VIBEBINARY="$0"; fi VIBEPATH=$(dirname "$VIBEBINARY") # use pkg-config if possible or fallback to default flags LIBS=$(pkg-config --libs libevent libevent_pthreads libssl 2>/dev/null || echo "-levent_pthreads -levent -lssl -lcrypto") LIBS=$(echo "$LIBS" | sed 's/^-L/-L-L/; s/ -L/ -L-L/g; s/^-l/-L-l/; s/ -l/ -L-l/g') export LIBS # generate a file name for the temporary compile/run script START_SCRIPT=`mktemp -t vpm.start.XXXXXXXX` # copy vpm.d to /tmp and make it deletable by anyone cp -p "$VIBEPATH"/vpm.d /tmp/vpm.d chmod 666 /tmp/vpm.d # run VPM and delete the vpm.d file again, VPM will output the compile/run script rdmd -g -w -property -I"$VIBEPATH"/../source $LIBS -Jviews -Isource /tmp/vpm.d "$VIBEPATH" "$START_SCRIPT" $1 $2 $3 $4 $5 $6 $7 $8 $9 rm /tmp/vpm.d # compile/run the application chmod +x "$START_SCRIPT" "$START_SCRIPT" rm "$START_SCRIPT"