1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
|
#!/bin/bash
# //TODO: Add Icon File and copy it to the bundle
# This script attempts to copy needed 3rd party libraries and frameworks into
# the application bundle. It will then attempt to set the 'install_name' for
# each library so that it references either the PlugIns or Frameworks directory.
# The Script will change the JPEG, TIFF, and PNG, and Boost libraries. Each of these
# libraries is assumed to have been built with some sort of rpath already. We are
# dependant on that fact.
BASE_DIR="@CMAKE_CURRENT_BINARY_DIR@"
cd ${BASE_DIR}
dylib=".dylib"
PLUGINS_DIR_NAME="Lib"
APPLICATION_APP_BUNDLE="@PROGNAME@.app"
APPLICATION_BINDIR="${APPLICATION_APP_BUNDLE}/Contents/MacOS"
APPLICATION_APP_NAME="${APPLICATION_BINDIR}/@PROGNAME@"
PLUGINS_PATH="${APPLICATION_APP_BUNDLE}/Contents/${PLUGINS_DIR_NAME}"
FRAMEWORKS_PATH="${APPLICATION_APP_BUNDLE}/Contents/Frameworks"
RPATH_PLUGIN_PATH="@executable_path/../${PLUGINS_DIR_NAME}"
RPATH_FRAMEWORK_PATH="@executable_path/../Frameworks"
DEBUG=0
echo "*-----------------------------------------------------------*"
echo "* Copying Support Libraries for ${APPLICATION_APP_BUNDLE}"
echo "* Located in ${BASE_DIR}"
# Create the PlugIns and Frameworks Directories
mkdir -p "${PLUGINS_PATH}"
mkdir -p "${FRAMEWORKS_PATH}"
get_libraries() {
#echo "-----------getting libraries for $1"
LIBRARIES=$(echo $(otool -X -L $1 | grep -v ${RPATH_PLUGIN_PATH} | grep -v \/System\/Library | grep -v \/usr\/lib | sed -e 's/(.*)//' | sort -u))
if [ -n "$LIBRARIES" ]; then
for library in $LIBRARIES
do
update_library $library $1
done
fi
#echo "----finished getting libraries for $1"
}
update_library() {
lib="$1"
path=$(dirname ${lib})
file=$(basename ${lib})
if [ ! -f "${BASE_DIR}/${PLUGINS_PATH}/${file}" ]
then
echo "* Installing Library -->$1<-- into ${APPLICATION_APP_BUNDLE} "
cp "${lib}" "${BASE_DIR}/${PLUGINS_PATH}" || exit 1
#chmod 755 "${BASE_DIR}/${PLUGINS_PATH}/${file}"
install_name_tool -id "${RPATH_PLUGIN_PATH}/${file}" "${BASE_DIR}/${PLUGINS_PATH}/${file}"
install_name_tool -change "${lib}" "${RPATH_PLUGIN_PATH}/${file}" "$2"
get_libraries "${BASE_DIR}/${PLUGINS_PATH}/${file}"
else
# Change internal id of the Library
install_name_tool -id "${RPATH_PLUGIN_PATH}/${file}" "${BASE_DIR}/${PLUGINS_PATH}/${file}"
# Change the hugin executable to have the proper rpath for the Library
#echo "updating $2 to use ${RPATH_PLUGIN_PATH}/${file} for ${lib}"
install_name_tool -change "${lib}" "${RPATH_PLUGIN_PATH}/${file}" "$2"
fi
}
add_executable() {
# -----------------------------------------------------------------------------
# Copy the executable into the App package
# -----------------------------------------------------------------------------
echo "* Installing Binary -->$1<-- into ${APPLICATION_APP_BUNDLE} "
cp "$1" "${BASE_DIR}/${APPLICATION_BINDIR}" || exit 1
get_libraries "${BASE_DIR}/${APPLICATION_BINDIR}/$(basename $1)"
}
get_libraries "${BASE_DIR}/${APPLICATION_BINDIR}/@PROGNAME@"
add_executable "${BASE_DIR}/../../tools/nona"
add_executable "${BASE_DIR}/../../deghosting/hugin_hdrmerge"
add_executable "${BASE_DIR}/../stitch_project/hugin_stitch_project"
add_executable "$(which msgfmt)"
add_executable "$(which PTroller)"
add_executable "$(which PTmasker)"
add_executable "$(which PTtiff2psd)"
add_executable "$(which enblend)"
add_executable "$(which enfuse)"
echo "*-----------------------------------------------------------*"
echo "* Creating DMG file: @CMAKE_INSTALL_PREFIX@/@PROGNAME@.dmg "
mkdmg -zlib -s "${BASE_DIR}/${APPLICATION_APP_BUNDLE}" -i "@CMAKE_INSTALL_PREFIX@/@PROGNAME@.dmg"
echo ""
|