#!/bin/sh
#
BUILD_DIR=$(cd "$(dirname "$0")"; pwd)
PYROGENESIS_EXECUTABLE_DIR="$BUILD_DIR/pyrogenesis.app/Contents/MacOS/"
PYROGENESIS_EXECUTABLE="pyrogenesis"

# Copy all dylib files in MacOS subdirectory
cp -P "$BUILD_DIR/"*.dylib "$PYROGENESIS_EXECUTABLE_DIR"

# Change install name for some libraries
executables_to_change="$PYROGENESIS_EXECUTABLE libnvmath.dylib libnvimage.dylib libnvtt.dylib"
libraries="libnvcore.dylib libnvmath.dylib libnvimage.dylib libnvtt.dylib"
for executable in $executables_to_change
do
	for library in $libraries
	do
		install_name_tool -change $library @executable_path/$library "$PYROGENESIS_EXECUTABLE_DIR/$executable" 
	done
done

echo "done"
