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 (CMAKE_CXX_COMPILER MATCHES "g\\+\\+-mp-4.[5-8]" OR
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}")
endif ()
endif (APPLE)

View File

@ -4,30 +4,26 @@ cwd="$(cd "$(dirname "$0")"; pwd)"
app="${cwd%/Contents/*}"
etc="${cwd}"/etc
#export DYLD_LIBRARY_PATH="${cwd}"/lib
export GTK_PATH="${cwd}"
# for different os x version (issue 1795)
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_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 GDK_PIXBUF_MODULE_FILE="${etc}"/gtk-2.0/gdk-pixbuf.loaders
export XDG_DATA_DIRS="${cwd}"/share
export PANGO_RC_FILE="${etc}"/pango/pangorc
# environment variables for X11 backend
if test -d "${etc}"/fonts; then
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
# strip out system arguments
case "$1" in -psn_*) shift;; esac
# strip out system argument
case $1 in -psn_*) shift;; esac
ln -sf "${app}" /tmp

View File

@ -10,28 +10,19 @@
# - PROC_BIT_DEPTH
# - GTK_PREFIX
# --------------------------------------
# Functions
# --------------------------------------
function message {
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 }'
}
function checkLink {
get_dependencies "$1" |
while read x
do
if test ! -f "${LIB}/${x##*/}"; then
ditto --arch ${arch} "${x}" "$_"
checkLink "$_"
fi
function CheckLink {
GetDependencies "$1" | while read; do
local dest="${LIB}/$(basename "${REPLY}")"
test -f "${dest}" || { ditto --arch ${arch} "${REPLY}" "${dest}"; CheckLink "${dest}"; }
done
}
# source check
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"
@ -39,15 +30,15 @@ if test ! -d "${CMAKE_BUILD_TYPE}"; then
fi
# update project version
if test -x `which hg` -a -d "${PROJECT_SOURCE_DIR}/.hg"; then
PROJECT_VERSION=`hg -R "${PROJECT_SOURCE_DIR}" parents --template "{latesttag}.{latesttagdistance}"`
if test -x $(which hg) -a -d "${PROJECT_SOURCE_DIR}/.hg"; then
PROJECT_VERSION=$(hg -R "${PROJECT_SOURCE_DIR}" parents --template "{latesttag}.{latesttagdistance}")
fi
# if not specify CMAKE_OSX_DEPLOYMENT_TARGET when compiling,
# '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
MINIMUM_SYSTEM_VERSION=`sw_vers -productVersion | cut -d. -f-2`
MINIMUM_SYSTEM_VERSION=$(sw_vers -productVersion | cut -d. -f-2)
fi
case ${PROC_BIT_DEPTH} in
@ -55,14 +46,16 @@ case ${PROC_BIT_DEPTH} in
32) arch=i386;;
esac
echo "PROJECT_NAME: ${PROJECT_NAME}"
echo "PROJECT_VERSION: ${PROJECT_VERSION}"
echo "PROJECT_SOURCE_DIR: ${PROJECT_SOURCE_DIR}"
echo "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}"
echo "PROC_BIT_DEPTH: ${PROC_BIT_DEPTH}"
echo "MINIMUM_SYSTEM_VERSION: ${MINIMUM_SYSTEM_VERSION}"
echo "GTK_PREFIX: ${GTK_PREFIX}"
echo "PWD: ${PWD}"
cat <<__EOS__
PROJECT_NAME: ${PROJECT_NAME}
PROJECT_VERSION: ${PROJECT_VERSION}
PROJECT_SOURCE_DIR: ${PROJECT_SOURCE_DIR}
CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}
PROC_BIT_DEPTH: ${PROC_BIT_DEPTH}
MINIMUM_SYSTEM_VERSION: ${MINIMUM_SYSTEM_VERSION}
GTK_PREFIX: ${GTK_PREFIX}
PWD: ${PWD}
__EOS__
APP="${PROJECT_NAME}".app
CONTENTS="${APP}"/Contents
@ -81,14 +74,11 @@ install -d "${RESOURCES}" \
"${LIB}" \
"${ETC}"
# set bundle attribute
setFile -a B "${APP}"
message "Copying release files"
ditto --arch ${arch} "${CMAKE_BUILD_TYPE}" "${MACOS}"
ditto "${CMAKE_BUILD_TYPE}" "${MACOS}"
message "Copying dependencies from ${GTK_PREFIX}"
checkLink "${EXECUTABLE}"
CheckLink "${EXECUTABLE}"
message "Copying library modules from ${GTK_PREFIX}"
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
printf "[Pango]\nModuleFiles = /tmp/${ETC}/pango/pango.modules" > "${ETC}"/pango/pangorc
message "Copying shared files from ${GTK_PREFIX}"
cp -R "${GTK_PREFIX}"/share/mime "${MACOS}"/share
# gtk themes
ditto {/opt/local,"${MACOS}"}/share/themes/Mac/gtk-2.0-key/gtkrc
ditto {/opt/local,"${MACOS}"}/share/themes/Clearlooks/gtk-2.0/gtkrc
install -d "${MACOS}"/share/themes/Raleigh/gtk-2.0 && (
cd "$_" &&
ln -s ../../Clearlooks/gtk-2.0/gtkrc
)
ditto {"${GTK_PREFIX}","${MACOS}"}/share/themes/Mac/gtk-2.0-key/gtkrc
ditto {"${GTK_PREFIX}","${MACOS}"}/share/themes/Clearlooks/gtk-2.0/gtkrc
install -d "${MACOS}"/share/themes/Raleigh/gtk-2.0
(cd "${MACOS}"/share/themes/Raleigh/gtk-2.0 && ln -s ../../Clearlooks/gtk-2.0/gtkrc)
# fontconfig files (X11 backend only)
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.)"
cp -RL "${GTK_PREFIX}"/etc/fonts "${ETC}"
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}"
{
# id (dylib file only)
case "${x}" in (*.dylib)
printf ' install_name_tool -id "%s" "%s"\n' "@rpath/${x##*/}" "${x}";;
esac
# dependencies
get_dependencies "${x}" | while read y; do
printf ' install_name_tool -change "%s" "%s" "%s"\n' "${y}" "@rpath/${y##*/}" "${x}"
# id
case ${x} in *.dylib) echo " install_name_tool -id '@rpath/$(basename "${x}")' '${x}'";; esac
# names
GetDependencies "${x}" | while read y; do
echo " install_name_tool -change '${y}' '@rpath/$(basename "${y}")' '${x}'"
done
} | bash -v
done
# @loader_path
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"
PROJECT_SOURCE_DATA_DIR="${PROJECT_SOURCE_DIR}"/rtdata/osx
## executable and executable loader
# executable loader
# note: executable is renamed to 'rawtherapee-bin'.
mv "${MACOS}"/rawtherapee{,-bin}
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}"
# PkgInfo
cp "${PROJECT_SOURCE_DATA_DIR}"/PkgInfo "${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}|" \
-e "s|@shortVersion@|`echo ${PROJECT_VERSION} | cut -d. -f-3`|" \
-e "s|@arch@|${arch}|" \
sed -i "" -e "s|@version@|${PROJECT_VERSION}|
s|@shortVersion@|$(echo ${PROJECT_VERSION} | cut -d. -f-3)|
s|@arch@|${arch}|" \
"${CONTENTS}"/Info.plist
# specify min version
#defaults write "${PWD}/${CONTENTS}"/Info LSMinimumSystemVersion "${MINIMUM_SYSTEM_VERSION}"
plutil -convert binary1 "${CONTENTS}"/Info.plist
# --------------------------------------
# disk image
# --------------------------------------
## cache directory
DMG_SOURCE_DIR=/tmp/`uuidgen`
function CreateDmg {
local srcdir=$(mktemp -dt $$)
## disk image name
# space and comma will be replaced.
# example: RawTherapee_OSX108_4.0.10.1_Release.dmg
DMG="${PROJECT_NAME// /_}_OSX${MINIMUM_SYSTEM_VERSION//.}_${PROJECT_VERSION}_${CMAKE_BUILD_TYPE}".dmg
# --------------------------------------
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 "Preparing disk image sources at ${srcdir}"
mv "${APP}" ${srcdir}
cp AboutThisBuild.txt ${srcdir}
ln -s /Applications ${srcdir}
# web bookmarks
function CreateWebloc {
defaults write ${srcdir}/"$1" URL "$2"
mv ${srcdir}/"$1".{plist,webloc}
}
CreateWebloc 'RawTherapee Blog' 'http://www.rawtherapee.com'
CreateWebloc 'Online Manual' 'https://docs.google.com/document/d/1DHLb_6xNQsEInxiuU8pz1-sWNinnj09bpBUA4_Vl8w8/edit'
# disk image name
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
# -format: defaut is 'UDZO'(zip compress). 'UDBZ' is bzip2 compress.
# -volname: example, RawTherapee_4.0.10.1
hdiutil create -format UDBZ \
-srcdir ${DMG_SOURCE_DIR} \
-volname "${PROJECT_NAME}_${PROJECT_VERSION}" \
"${DMG}"
hdiutil create -format UDBZ -srcdir ${srcdir} -volname "${PROJECT_NAME}_${PROJECT_VERSION}" "${dmg_name}".dmg
message "Cleaning disk image caches"
rm -rf ${DMG_SOURCE_DIR}
message "Removing disk image caches"
rm -rf ${srcdir}
}
CreateDmg