#!/bin/bash

Projet=Medintux
MODULE=$1
export MODULE

# Debut  
# clear
 echo -e "--------------------------------------"
 echo -e "Debut commande modulepatch-Qt4 du module : $MODULE pour projet : $Projet"
 echo -e "--------------------------------------"

 if [ $MODULE == 'guinch' ]; then
     cd ../../Manager/bin/$MODULE.app/Contents/MacOS  # se mettre dans le bon endroit car on part de set_bases/bin/    
 else
     cd ../../$MODULE/bin/$MODULE.app/Contents/MacOS  # se mettre dans le bon endroit car on part de set_bases/bin/
 fi

MYSQL_LIB=libmysqlclient.18.dylib
export MYSQL_LIB

echo -e "................ $MODULE ................"
otool -L $MODULE                       # /Module/bin/Module.app/Contents/MacOS  ==>  /../../../../../
install_name_tool -change /usr/local/Trolltech/Qt-4.7.0/lib/libQtCLucene.4.dylib @executable_path/../../../../../Qt4-Mac/libQtCLucene.4.dylib $MODULE
install_name_tool -change /usr/local/Trolltech/Qt-4.7.0/lib/phonon.framework/Versions/4/phonon @executable_path/../../../../../Qt4-Mac/phonon $MODULE
install_name_tool -change /usr/local/Trolltech/Qt-4.7.0/lib/Qt3Support.framework/Versions/4/Qt3Support @executable_path/../../../../../Qt4-Mac/Qt3Support $MODULE
install_name_tool -change /usr/local/Trolltech/Qt-4.7.0/lib/QtCore.framework/Versions/4/QtCore @executable_path/../../../../../Qt4-Mac/QtCore $MODULE
install_name_tool -change /usr/local/Trolltech/Qt-4.7.0/lib/QtDeclarative.framework/Versions/4/QtDeclarative @executable_path/../../../../../Qt4-Mac/QtDeclarative $MODULE
install_name_tool -change /usr/local/Trolltech/Qt-4.7.0/lib/QtGui.framework/Versions/4/QtGui @executable_path/../../../../../Qt4-Mac/QtGui $MODULE
install_name_tool -change /usr/local/Trolltech/Qt-4.7.0/lib/QtHelp.framework/Versions/4/QtHelp @executable_path/../../../../../Qt4-Mac/QtHelp $MODULE
install_name_tool -change /usr/local/Trolltech/Qt-4.7.0/lib/QtMultimedia.framework/Versions/4/QtMultimedia @executable_path/../../../../../Qt4-Mac/QtMultimedia $MODULE
install_name_tool -change /usr/local/Trolltech/Qt-4.7.0/lib/QtNetwork.framework/Versions/4/QtNetwork @executable_path/../../../../../Qt4-Mac/QtNetwork $MODULE
install_name_tool -change /usr/local/Trolltech/Qt-4.7.0/lib/QtOpenGL.framework/Versions/4/QtOpenGL @executable_path/../../../../../Qt4-Mac/QtOpenGL $MODULE
install_name_tool -change /usr/local/Trolltech/Qt-4.7.0/lib/QtScript.framework/Versions/4/QtScript @executable_path/../../../../../Qt4-Mac/QtScript $MODULE
install_name_tool -change /usr/local/Trolltech/Qt-4.7.0/lib/QtScriptTools.framework/Versions/4/QtScriptTools @executable_path/../../../../../Qt4-Mac/QtScriptTools $MODULE
install_name_tool -change /usr/local/Trolltech/Qt-4.7.0/lib/QtSql.framework/Versions/4/QtSql @executable_path/../../../../../Qt4-Mac/QtSql $MODULE
install_name_tool -change /usr/local/Trolltech/Qt-4.7.0/lib/QtSvg.framework/Versions/4/QtSvg @executable_path/../../../../../Qt4-Mac/QtSvg $MODULE
install_name_tool -change /usr/local/Trolltech/Qt-4.7.0/lib/QtTest.framework/Versions/4/QtTest @executable_path/../../../../../Qt4-Mac/QtTest $MODULE
install_name_tool -change /usr/local/Trolltech/Qt-4.7.0/lib/QtWebKit.framework/Versions/4/QtWebKit @executable_path/../../../../../Qt4-Mac/QtWebKit $MODULE
install_name_tool -change /usr/local/Trolltech/Qt-4.7.0/lib/QtXml.framework/Versions/4/QtXml @executable_path/../../../../../Qt4-Mac/QtXml $MODULE
install_name_tool -change /usr/local/Trolltech/Qt-4.7.0/lib/QtXmlPatterns.framework/Versions/4/QtXmlPatterns @executable_path/../../../../../Qt4-Mac/QtXmlPatterns $MODULE
install_name_tool -change $MYSQL_LIB @executable_path/../../../../../Qt/lib/$MYSQL_LIB $MODULE
otool -L $MODULE

cd ../../../../../set_bases/bin/set_bases.app/Contents/MacOS  # se mettre dans le bon endroit pour revenir dans set_bases/bin/
echo -e "---------------------------------"
echo -e "Fin commande modulepatch-Qt4 du module : $MODULE pour projet : $Projet"
echo -e "---------------------------------"


