Update to Mac OS X build system, courtesy of mattintosh4, issue 1795

This commit is contained in:
DrSlony 2013-04-22 01:04:20 +01:00
parent dadf0f91c3
commit 2a24da5ffb
3 changed files with 86 additions and 123 deletions

View File

@ -62,7 +62,7 @@ endif (WIN32)
if (APPLE) if (APPLE)
if (CMAKE_CXX_COMPILER MATCHES "g\\+\\+-mp-4.[5-8]" OR if (CMAKE_CXX_COMPILER MATCHES "g\\+\\+-mp-4.[5-8]" OR
CMAKE_CXX_COMPILER_ARG1 MATCHES "g\\+\\+-mp-4.[5-8]") CMAKE_CXX_COMPILER_ARG1 MATCHES "g\\+\\+-mp-4.[5-8]")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-weak_library,/usr/lib/libstdc++.6.dylib") set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /usr/lib/libstdc++.6.dylib")
message (STATUS "CMAKE_CXX_COMPILER is MacPorts GCC.\n CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}") message (STATUS "CMAKE_CXX_COMPILER is MacPorts GCC.\n CMAKE_EXE_LINKER_FLAGS: ${CMAKE_EXE_LINKER_FLAGS}")
endif () endif ()
endif (APPLE) endif (APPLE)

View File

@ -4,30 +4,26 @@ cwd="$(cd "$(dirname "$0")"; pwd)"
app="${cwd%/Contents/*}" app="${cwd%/Contents/*}"
etc="${cwd}"/etc etc="${cwd}"/etc
#export DYLD_LIBRARY_PATH="${cwd}"/lib # for different os x version (issue 1795)
export GTK_PATH="${cwd}" cups_dir=/tmp/RT4
install -d ${cups_dir}
cp -f /usr/lib/libcups.2.dylib ${cups_dir}
export DYLD_LIBRARY_PATH="${cwd}"/lib:${cups_dir}
export GTK_EXE_PREFIX="${cwd}" export GTK_EXE_PREFIX="${cwd}"
export GTK_DATA_PREFIX="${cwd}" export GTK_DATA_PREFIX="${cwd}"
export GTK_DATA_DIRS="${cwd}"
export XDG_DATA_DIRS="${cwd}"/share
export GTK2_RC_FILES="${etc}"/gtk-2.0/gtkrc
export GTK_IM_MODULE_FILE="${etc}"/gtk-2.0/gtk.immodules export GTK_IM_MODULE_FILE="${etc}"/gtk-2.0/gtk.immodules
export GDK_PIXBUF_MODULE_FILE="${etc}"/gtk-2.0/gdk-pixbuf.loaders export GDK_PIXBUF_MODULE_FILE="${etc}"/gtk-2.0/gdk-pixbuf.loaders
export XDG_DATA_DIRS="${cwd}"/share
export PANGO_RC_FILE="${etc}"/pango/pangorc export PANGO_RC_FILE="${etc}"/pango/pangorc
# environment variables for X11 backend # environment variables for X11 backend
if test -d "${etc}"/fonts; then if test -d "${etc}"/fonts; then
export FONTCONFIG_PATH="${etc}"/fonts export FONTCONFIG_PATH="${etc}"/fonts
_DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH"
DYLD_LIBRARY_PATH=/tmp/`uuidgen`
mkdir $DYLD_LIBRARY_PATH
cp /usr/lib/libcups.2.dylib $DYLD_LIBRARY_PATH
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:$_DYLD_LIBRARY_PATH"
fi fi
# strip out system arguments # strip out system argument
case "$1" in -psn_*) shift;; esac case $1 in -psn_*) shift;; esac
ln -sf "${app}" /tmp ln -sf "${app}" /tmp

View File

@ -10,28 +10,19 @@
# - PROC_BIT_DEPTH # - PROC_BIT_DEPTH
# - GTK_PREFIX # - GTK_PREFIX
# --------------------------------------
# Functions
# --------------------------------------
function message { function message {
printf '\e[34m-- %s\e[m\n' "$*" printf '\e[34m-- %s\e[m\n' "$*"
} }
function get_dependencies { function GetDependencies {
otool -L "$1" | awk 'NR >= 2 && $1 !~ /^(\/usr\/lib|\/System|@executable_path|@rpath)\// { print $1 }' otool -L "$1" | awk 'NR >= 2 && $1 !~ /^(\/usr\/lib|\/System|@executable_path|@rpath)\// { print $1 }'
} }
function checkLink { function CheckLink {
get_dependencies "$1" | GetDependencies "$1" | while read; do
while read x local dest="${LIB}/$(basename "${REPLY}")"
do test -f "${dest}" || { ditto --arch ${arch} "${REPLY}" "${dest}"; CheckLink "${dest}"; }
if test ! -f "${LIB}/${x##*/}"; then
ditto --arch ${arch} "${x}" "$_"
checkLink "$_"
fi
done done
} }
# source check # source check
if test ! -d "${CMAKE_BUILD_TYPE}"; then if test ! -d "${CMAKE_BUILD_TYPE}"; then
printf "\e[31m${PWD}/${CMAKE_BUILD_TYPE} directory is not found. Please execute 'make install' first.\e[m\n" printf "\e[31m${PWD}/${CMAKE_BUILD_TYPE} directory is not found. Please execute 'make install' first.\e[m\n"
@ -39,15 +30,15 @@ if test ! -d "${CMAKE_BUILD_TYPE}"; then
fi fi
# update project version # update project version
if test -x `which hg` -a -d "${PROJECT_SOURCE_DIR}/.hg"; then if test -x $(which hg) -a -d "${PROJECT_SOURCE_DIR}/.hg"; then
PROJECT_VERSION=`hg -R "${PROJECT_SOURCE_DIR}" parents --template "{latesttag}.{latesttagdistance}"` PROJECT_VERSION=$(hg -R "${PROJECT_SOURCE_DIR}" parents --template "{latesttag}.{latesttagdistance}")
fi fi
# if not specify CMAKE_OSX_DEPLOYMENT_TARGET when compiling, # if not specify CMAKE_OSX_DEPLOYMENT_TARGET when compiling,
# 'MINIMUM_VERSION' will be used host OS X version. # 'MINIMUM_VERSION' will be used host OS X version.
MINIMUM_SYSTEM_VERSION=`otool -l "${CMAKE_BUILD_TYPE}"/rawtherapee | grep -A2 'LC_VERSION_MIN_MACOSX' | awk '$1 ~ /version/ { printf $2 }'` MINIMUM_SYSTEM_VERSION=$(otool -l "${CMAKE_BUILD_TYPE}"/rawtherapee | grep -A2 'LC_VERSION_MIN_MACOSX' | awk '$1 ~ /version/ { printf $2 }')
if test ! -n "${MINIMUM_SYSTEM_VERSION}"; then if test ! -n "${MINIMUM_SYSTEM_VERSION}"; then
MINIMUM_SYSTEM_VERSION=`sw_vers -productVersion | cut -d. -f-2` MINIMUM_SYSTEM_VERSION=$(sw_vers -productVersion | cut -d. -f-2)
fi fi
case ${PROC_BIT_DEPTH} in case ${PROC_BIT_DEPTH} in
@ -55,14 +46,16 @@ case ${PROC_BIT_DEPTH} in
32) arch=i386;; 32) arch=i386;;
esac esac
echo "PROJECT_NAME: ${PROJECT_NAME}" cat <<__EOS__
echo "PROJECT_VERSION: ${PROJECT_VERSION}" PROJECT_NAME: ${PROJECT_NAME}
echo "PROJECT_SOURCE_DIR: ${PROJECT_SOURCE_DIR}" PROJECT_VERSION: ${PROJECT_VERSION}
echo "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}" PROJECT_SOURCE_DIR: ${PROJECT_SOURCE_DIR}
echo "PROC_BIT_DEPTH: ${PROC_BIT_DEPTH}" CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}
echo "MINIMUM_SYSTEM_VERSION: ${MINIMUM_SYSTEM_VERSION}" PROC_BIT_DEPTH: ${PROC_BIT_DEPTH}
echo "GTK_PREFIX: ${GTK_PREFIX}" MINIMUM_SYSTEM_VERSION: ${MINIMUM_SYSTEM_VERSION}
echo "PWD: ${PWD}" GTK_PREFIX: ${GTK_PREFIX}
PWD: ${PWD}
__EOS__
APP="${PROJECT_NAME}".app APP="${PROJECT_NAME}".app
CONTENTS="${APP}"/Contents CONTENTS="${APP}"/Contents
@ -81,14 +74,11 @@ install -d "${RESOURCES}" \
"${LIB}" \ "${LIB}" \
"${ETC}" "${ETC}"
# set bundle attribute
setFile -a B "${APP}"
message "Copying release files" message "Copying release files"
ditto --arch ${arch} "${CMAKE_BUILD_TYPE}" "${MACOS}" ditto "${CMAKE_BUILD_TYPE}" "${MACOS}"
message "Copying dependencies from ${GTK_PREFIX}" message "Copying dependencies from ${GTK_PREFIX}"
checkLink "${EXECUTABLE}" CheckLink "${EXECUTABLE}"
message "Copying library modules from ${GTK_PREFIX}" message "Copying library modules from ${GTK_PREFIX}"
ditto --arch ${arch} {"${GTK_PREFIX}"/lib,"${LIB}"}/gdk-pixbuf-2.0 ditto --arch ${arch} {"${GTK_PREFIX}"/lib,"${LIB}"}/gdk-pixbuf-2.0
@ -109,108 +99,85 @@ sed -i "" -e "s|${PWD}|/tmp|" "${ETC}"/gtk-2.0/gdk-pixbuf.loaders \
"${ETC}"/pango/pango.modules "${ETC}"/pango/pango.modules
printf "[Pango]\nModuleFiles = /tmp/${ETC}/pango/pango.modules" > "${ETC}"/pango/pangorc printf "[Pango]\nModuleFiles = /tmp/${ETC}/pango/pango.modules" > "${ETC}"/pango/pangorc
message "Copying shared files from ${GTK_PREFIX}" message "Copying shared files from ${GTK_PREFIX}"
cp -R "${GTK_PREFIX}"/share/mime "${MACOS}"/share cp -R "${GTK_PREFIX}"/share/mime "${MACOS}"/share
# gtk themes # gtk themes
ditto {/opt/local,"${MACOS}"}/share/themes/Mac/gtk-2.0-key/gtkrc ditto {"${GTK_PREFIX}","${MACOS}"}/share/themes/Mac/gtk-2.0-key/gtkrc
ditto {/opt/local,"${MACOS}"}/share/themes/Clearlooks/gtk-2.0/gtkrc ditto {"${GTK_PREFIX}","${MACOS}"}/share/themes/Clearlooks/gtk-2.0/gtkrc
install -d "${MACOS}"/share/themes/Raleigh/gtk-2.0 && ( install -d "${MACOS}"/share/themes/Raleigh/gtk-2.0
cd "$_" && (cd "${MACOS}"/share/themes/Raleigh/gtk-2.0 && ln -s ../../Clearlooks/gtk-2.0/gtkrc)
ln -s ../../Clearlooks/gtk-2.0/gtkrc
)
# fontconfig files (X11 backend only) # fontconfig files (X11 backend only)
if otool -L "${EXECUTABLE}" | grep -sq 'libgtk-x11-2.0'; then if otool -L "${EXECUTABLE}" | grep -sq 'libgtk-x11-2.0'; then
message "Installing fontconfig files (Your library is X11 backend. 'FONTCONFIG_PATH' will be set by executable loader.)" message "Installing fontconfig files (Your library is X11 backend. 'FONTCONFIG_PATH' will be set by executable loader.)"
cp -RL "${GTK_PREFIX}"/etc/fonts "${ETC}" cp -RL "${GTK_PREFIX}"/etc/fonts "${ETC}"
fi fi
# --------------------------------------
# Install names
# --------------------------------------
## install_name_tool
# this command replaces install names. you will not need to set 'DYLD_LIBRARY_PATH'
# '@rpath' is replaced '@loader_path' when execute.
# @rpath
find -E "${MACOS}" -type f -regex '.*(rawtherapee|\.dylib|\.so)$' | while read x; do # install names
find -E "${MACOS}" -type f -regex '.*/(rawtherapee|.*\.(dylib|so))' | while read x; do
message "Modifying install names: ${x}" message "Modifying install names: ${x}"
{ {
# id (dylib file only) # id
case "${x}" in (*.dylib) case ${x} in *.dylib) echo " install_name_tool -id '@rpath/$(basename "${x}")' '${x}'";; esac
printf ' install_name_tool -id "%s" "%s"\n' "@rpath/${x##*/}" "${x}";; # names
esac GetDependencies "${x}" | while read y; do
echo " install_name_tool -change '${y}' '@rpath/$(basename "${y}")' '${x}'"
# dependencies
get_dependencies "${x}" | while read y; do
printf ' install_name_tool -change "%s" "%s" "%s"\n' "${y}" "@rpath/${y##*/}" "${x}"
done done
} | bash -v } | bash -v
done done
# @loader_path
message "Registering @loader_path into the executable" message "Registering @loader_path into the executable"
printf ' install_name_tool -add_rpath @loader_path/lib "%s"' "${EXECUTABLE}" | bash -v echo " install_name_tool -add_rpath @loader_path/lib '${EXECUTABLE}'" | bash -v
# --------------------------------------
# required files
# --------------------------------------
message "Installing required application bundle files" message "Installing required application bundle files"
PROJECT_SOURCE_DATA_DIR="${PROJECT_SOURCE_DIR}"/rtdata/osx PROJECT_SOURCE_DATA_DIR="${PROJECT_SOURCE_DIR}"/rtdata/osx
# executable loader
## executable and executable loader
# note: executable is renamed to 'rawtherapee-bin'. # note: executable is renamed to 'rawtherapee-bin'.
mv "${MACOS}"/rawtherapee{,-bin} mv "${MACOS}"/rawtherapee{,-bin}
install -m 0755 "${PROJECT_SOURCE_DATA_DIR}"/executable_loader.in "${MACOS}"/rawtherapee install -m 0755 "${PROJECT_SOURCE_DATA_DIR}"/executable_loader.in "${MACOS}"/rawtherapee
# icons # app bundle resources
cp "${PROJECT_SOURCE_DATA_DIR}"/{rawtherapee,profile}.icns "${RESOURCES}" cp "${PROJECT_SOURCE_DATA_DIR}"/{rawtherapee,profile}.icns "${RESOURCES}"
# PkgInfo
cp "${PROJECT_SOURCE_DATA_DIR}"/PkgInfo "${CONTENTS}" cp "${PROJECT_SOURCE_DATA_DIR}"/PkgInfo "${CONTENTS}"
# Info.plist
install -m 0644 "${PROJECT_SOURCE_DATA_DIR}"/Info.plist.in "${CONTENTS}"/Info.plist install -m 0644 "${PROJECT_SOURCE_DATA_DIR}"/Info.plist.in "${CONTENTS}"/Info.plist
# configure property values sed -i "" -e "s|@version@|${PROJECT_VERSION}|
sed -i "" -e "s|@version@|${PROJECT_VERSION}|" \ s|@shortVersion@|$(echo ${PROJECT_VERSION} | cut -d. -f-3)|
-e "s|@shortVersion@|`echo ${PROJECT_VERSION} | cut -d. -f-3`|" \ s|@arch@|${arch}|" \
-e "s|@arch@|${arch}|" \
"${CONTENTS}"/Info.plist "${CONTENTS}"/Info.plist
# specify min version
#defaults write "${PWD}/${CONTENTS}"/Info LSMinimumSystemVersion "${MINIMUM_SYSTEM_VERSION}"
plutil -convert binary1 "${CONTENTS}"/Info.plist plutil -convert binary1 "${CONTENTS}"/Info.plist
# -------------------------------------- function CreateDmg {
# disk image local srcdir=$(mktemp -dt $$)
# --------------------------------------
## cache directory
DMG_SOURCE_DIR=/tmp/`uuidgen`
## disk image name message "Preparing disk image sources at ${srcdir}"
# space and comma will be replaced. mv "${APP}" ${srcdir}
# example: RawTherapee_OSX108_4.0.10.1_Release.dmg cp AboutThisBuild.txt ${srcdir}
DMG="${PROJECT_NAME// /_}_OSX${MINIMUM_SYSTEM_VERSION//.}_${PROJECT_VERSION}_${CMAKE_BUILD_TYPE}".dmg ln -s /Applications ${srcdir}
# --------------------------------------
message "Preparing disk image sources at ${DMG_SOURCE_DIR}"
install -d ${DMG_SOURCE_DIR}
mv "${APP}" ${DMG_SOURCE_DIR}
cp AboutThisBuild.txt ${DMG_SOURCE_DIR}
# symlink to /Applications dir
ln -s /Applications ${DMG_SOURCE_DIR}
# .webloc files
defaults write ${DMG_SOURCE_DIR}/"RawTherapee Blog" URL 'http://www.rawtherapee.com'
mv ${DMG_SOURCE_DIR}/"RawTherapee Blog".{plist,webloc}
defaults write ${DMG_SOURCE_DIR}/"Online Manual" URL 'https://docs.google.com/document/d/1DHLb_6xNQsEInxiuU8pz1-sWNinnj09bpBUA4_Vl8w8/edit'
mv ${DMG_SOURCE_DIR}/"Online Manual".{plist,webloc}
message "Creating disk image" # web bookmarks
## hdiutil function CreateWebloc {
# -format: defaut is 'UDZO'(zip compress). 'UDBZ' is bzip2 compress. defaults write ${srcdir}/"$1" URL "$2"
# -volname: example, RawTherapee_4.0.10.1 mv ${srcdir}/"$1".{plist,webloc}
hdiutil create -format UDBZ \ }
-srcdir ${DMG_SOURCE_DIR} \ CreateWebloc 'RawTherapee Blog' 'http://www.rawtherapee.com'
-volname "${PROJECT_NAME}_${PROJECT_VERSION}" \ CreateWebloc 'Online Manual' 'https://docs.google.com/document/d/1DHLb_6xNQsEInxiuU8pz1-sWNinnj09bpBUA4_Vl8w8/edit'
"${DMG}"
message "Cleaning disk image caches" # disk image name
rm -rf ${DMG_SOURCE_DIR} dmg_name="${PROJECT_NAME// /_}_OSX_${MINIMUM_SYSTEM_VERSION}_${PROC_BIT_DEPTH}_${PROJECT_VERSION}"
if ! echo ${CMAKE_BUILD_TYPE} | grep -sqi "release"; then
dmg_name="${dmg_name}_$(echo ${CMAKE_BUILD_TYPE} | tr '[:upper:]' '[:lower:]')"
fi
message "Creating disk image"
hdiutil create -format UDBZ -srcdir ${srcdir} -volname "${PROJECT_NAME}_${PROJECT_VERSION}" "${dmg_name}".dmg
message "Removing disk image caches"
rm -rf ${srcdir}
}
CreateDmg