#!/bin/sh

# copy executable to ${m}

# echo commands as they are executed
set -x

c=/Users/kevin/src/kc/build/osx/debug/bin/kc.app/Contents
m=${c}/MacOS
f=${c}/Frameworks

cp lib/libcm.0.dylib                ${f}
cp lib/libcmpp.0.dylib              ${f}
cp /opt/local/lib/libfftw3f.3.dylib ${f}
cp /opt/local/lib/libfftw3.3.dylib  ${f}
cp /opt/local/lib/libfltk.1.3.dylib ${f}
cp /usr/lib/libstdc++.6.dylib       ${f}
cp /usr/lib/libgcc_s.1.dylib        ${f}

install_name_tool -id @executable_path/../Frameworks/libcm.0.dylib     ${f}/libcm.0.dylib
install_name_tool -id @executable_path/../Frameworks/libcmpp.0.dylib   ${f}/libcmpp.0.dylib
install_name_tool -id @executable_path/../Frameworks/libfftw3f.3.dylib ${f}/libfftw3f.3.dylib
install_name_tool -id @executable_path/../Frameworks/libfftw3.3.dylib  ${f}/libfftw3.3.dylib
install_name_tool -id @executable_path/../Frameworks/libfltk.1.3.dylib ${f}/libfltk.1.3.dylib
install_name_tool -id @executable_path/../Frameworks/libstdc++.6.dylib ${f}/libstdc++.6.dylib
install_name_tool -id @executable_path/../Frameworks/libgcc_s.1.dylib  ${f}/libgcc_s.1.dylib

install_name_tool -change /opt/local/lib/libcm.0.dylib     @executable_path/../Frameworks/libcm.0.dylib     ${m}/kc
install_name_tool -change /opt/local/lib/libcmpp.0.dylib   @executable_path/../Frameworks/libcmpp.0.dylib   ${m}/kc
install_name_tool -change /opt/local/lib/libfftw3f.3.dylib @executable_path/../Frameworks/libfftw3f.3.dylib ${m}/kc
install_name_tool -change /opt/local/lib/libfftw3.3.dylib  @executable_path/../Frameworks/libfftw3.3.dylib  ${m}/kc
install_name_tool -change /opt/local/lib/libfltk.1.3.dylib @executable_path/../Frameworks/libfltk.1.3.dylib ${m}/kc
install_name_tool -change /usr/lib/libstdc++.6.dylib       @executable_path/../Frameworks/libstdc++.6.dylib ${m}/kc
install_name_tool -change /usr/lib/libgcc_s.1.dylib        @executable_path/../Frameworks/libgcc_s.1.dylib  ${m}/kc

set +x

# report the library paths
otool -L ${m}/kc

