+}
+
+content_directory() {
+ target="$1"
+ content=`dirname "${target}"`
+ content=`dirname "${content}"`
+ echo "${content}"
+}
+
+private_framework() {
+ fwdir=`framework_name "$1"`
+ source="$2"
+ target="$3"
+ condir=`content_directory "${target}"`
+ libnm=`basename "${source}"`
+ mkdir -p "${condir}/${fwdir}"
+ if [ ! -f "${condir}/${fwdir}/${libnm}" ]; then
+ cp -p "${source}" "${condir}/${fwdir}"
+ echo Set library id in "${condir}/${fwdir}/${libnm}"
+ install_name_tool -id "@executable_path/../${fwdir}/${libnm}" "${condir}/${fwdir}/${libnm}"
+ fi
+ echo Correct library id reference to "${libnm}" in "${target}"
+ install_name_tool -change "${source}" "@executable_path/../${fwdir}/${libnm}" "${target}"
+}
+
+deploy_qtlibs() {
+ source="${QtInstallDir}"
+ target="$1"
+ version="Versions/${QtFrameworkVersion}/"
+ condir=`content_directory "${target}"`
+ mkdir -p "${condir}/Resources"
+ test -f "${condir}/Resources/qt.conf" || cat - > "${condir}/Resources/qt.conf" <<-EOF
+[Paths]
+Plugins = PlugIns
+EOF
+ if [ ! -d "${condir}/PlugIns" ]; then
+ mkdir -p "${condir}/PlugIns"
+ find "${source}/plugins" -name \*.dylib -print | while read libname ; do
+ echo Copy plugin "${libname}"
+ dylib=`basename "${libname}"`
+ dirname=`dirname "${libname}"`
+ dirname=`basename "${dirname}"`
+ mkdir -p "${condir}/PlugIns/${dirname}"
+ cp -p "${libname}" "${condir}/PlugIns/${dirname}"
+ done
+ fi
+ # don't change order here...
+ for libnm in QtSvg QtXml QtGui QtNetwork QtCore ; do
+ fwdir=`framework_name "$libnm"`
+ dirname=`basename "${fwdir}"`
+ test -d "${condir}/${fwdir}" || (
+ echo Copy framework "${source}/lib/"`basename "${fwdir}"`
+ cp -pR "${source}/lib/"`basename "${fwdir}"` "${condir}/${fwdir}"
+ echo Set library id in "${condir}/${fwdir}/${version}${libnm}"
+ install_name_tool -id "@executable_path/../${fwdir}/${version}${libnm}" "${condir}/${fwdir}/${version}${libnm}"
+ find "${condir}/PlugIns" "${condir}/"`dirname "${fwdir}"` -name Headers -prune -o -type f -print | while read filename ; do
+ otool -L "${filename}" 2>/dev/null | while read library ; do
+ # pattern match for: /path/to/qt4/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.6.0, current version 4.6.2)
+ case "${library}" in
+ *"${libnm}"*"("*")"*)
+ echo Correct library id reference to "${libnm}" in "${filename}"
+ install_name_tool -change\
+ "${source}/lib/${dirname}/${version}${libnm}"\
+ "@executable_path/../${fwdir}/${version}${libnm}"\
+ "${filename}"
+ ;;
+ esac
+ done
+ done
+ )
+ echo Correct library id reference to "${libnm}" in "${target}"
+ install_name_tool -change\
+ "${source}/lib/${dirname}/${version}${libnm}"\
+ "@executable_path/../${fwdir}/${version}${libnm}"\
+ "${target}"
+ done
+}