# Install jackdmp and owerwrite jack installation

# Plug-ins
[ -d Panda.framework ] && sudo cp -r Panda.framework /Library/Frameworks
[ -d JackRouter.plugin ] && sudo cp -r JackRouter.plugin /Library/Audio/Plug-Ins/HAL/

# Copy libraries and exe
sudo cp -r Jackmp.framework /Library/Frameworks/  
sudo cp -r Jackservermp.framework /Library/Frameworks/  
sudo cp -r Jacknet.framework /Library/Frameworks/   
sudo install -d /usr/local/bin 
sudo cp jackdmp /usr/local/bin  
[ -f jack_load ] && sudo cp jack_load /usr/local/bin 
[ -f jack_unload ] && sudo cp jack_unload /usr/local/bin 
[ -f jack_netsource ] && sudo cp jack_netsource /usr/local/bin 

# Copy drivers
sudo install -d  /usr/local/lib/jackmp 
sudo cp  jack_coreaudio.so  /usr/local/lib/jackmp 
sudo cp  jack_coremidi.so  /usr/local/lib/jackmp
sudo cp  jack_dummy.so  /usr/local/lib/jackmp
sudo cp  jack_loopback.so  /usr/local/lib/jackmp
[ -f jack_net.so ] && sudo cp jack_net.so /usr/local/lib/jackmp
[ -f jack_netone.so ] && sudo cp jack_netone.so /usr/local/lib/jackmp

# Copy tools
[ -f netmanager.so ] && sudo cp  netmanager.so /usr/local/lib/jackmp
[ -f netadapter.so ] && sudo cp  netadapter.so /usr/local/lib/jackmp
[ -f audioadapter.so ] && sudo cp  audioadapter.so /usr/local/lib/jackmp

# Create links to jackmp ressources
cd /usr/local/lib && [ -f libjack.0.dylib ] && sudo mv -f libjack.0.dylib tmp_libjack.0.dylib 
cd /usr/local/lib && [ -f jackd ] && sudo mv -f jackd tmp_jackd 
cd /usr/local/lib && [ -f libjack.dylib ] && sudo rm libjack.dylib
cd /usr/local/lib && [ -f libjacknet.dylib ] && sudo rm libjacknet.dylib
cd /usr/local/lib && [ -f libjacknet.0.dylib ] && sudo rm libjacknet.0.dylib
cd /usr/local/bin && [ -f jackd ] && sudo rm jackd
cd /usr/local/lib && sudo ln -s /Library/Frameworks/Jackmp.framework/Jackmp libjack.dylib
cd /usr/local/lib && sudo ln -s /Library/Frameworks/Jackmp.framework/Jackmp libjack.0.dylib
cd /usr/local/lib && sudo ln -s /Library/Frameworks/Jacknet.framework/Jacknet libjacknet.dylib
cd /usr/local/lib && sudo ln -s /Library/Frameworks/Jacknet.framework/Jacknet libjacknet.0.dylib
cd /usr/local/bin && sudo ln -s jackdmp jackd


