Initial Homebrew on OSX Lion patch

This commit is contained in:
tresf
2015-08-16 04:43:33 -04:00
parent 5449706527
commit 2035ff3e3c
10 changed files with 121 additions and 220 deletions

View File

@@ -7,6 +7,9 @@ SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" ${CMAKE_MODULE_PATH})
IF(COMMAND CMAKE_POLICY)
CMAKE_POLICY(SET CMP0005 NEW)
CMAKE_POLICY(SET CMP0003 NEW)
IF (CMAKE_MAJOR_VERSION GREATER 2)
CMAKE_POLICY(SET CMP0026 OLD)
ENDIF()
ENDIF(COMMAND CMAKE_POLICY)
INCLUDE(AddFileDependencies)
@@ -68,8 +71,6 @@ IF(LMMS_BUILD_APPLE)
SET(STATUS_ALSA "<not supported on this platform>")
SET(STATUS_PULSEAUDIO "<not supported on this platform>")
SET(STATUS_APPLEMIDI "OK")
# MacPorts: /opt/local/lib
LINK_DIRECTORIES(${LINK_DIRECTORIES} /opt/local/lib)
ENDIF(LMMS_BUILD_APPLE)
@@ -448,11 +449,15 @@ ADD_SUBDIRECTORY(tests)
ADD_SUBDIRECTORY(data)
ADD_SUBDIRECTORY(doc)
# post-install tasks
ADD_SUBDIRECTORY(cmake/postinstall)
ADD_CUSTOM_COMMAND(OUTPUT "${CMAKE_BINARY_DIR}/lmms.1.gz"
COMMAND gzip -c "\"${CMAKE_SOURCE_DIR}/doc/lmms.1\"" > "\"${CMAKE_BINARY_DIR}/lmms.1.gz\""
DEPENDS "${CMAKE_SOURCE_DIR}/doc/lmms.1"
COMMENT "Generating lmms.1.gz")
ADD_CUSTOM_TARGET(manpage ALL
DEPENDS "${CMAKE_BINARY_DIR}/lmms.1.gz")

View File

@@ -12,13 +12,19 @@ SET(MACOSX_BUNDLE_PROJECT_URL "${PROJECT_URL}")
CONFIGURE_FILE("lmms.plist.in" "${CMAKE_INSTALL_PREFIX}/Info.plist")
CONFIGURE_FILE("install_apple.sh.in" "${CMAKE_BINARY_DIR}/install_apple.sh" @ONLY)
CONFIGURE_FILE("package_apple.sh.in" "${CMAKE_BINARY_DIR}/package_apple.sh" @ONLY)
# Add execute permissions to install script
EXECUTE_PROCESS(COMMAND chmod u+x ${CMAKE_BINARY_DIR}/install_apple.sh)
INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_BINARY_DIR}/install_apple.sh)")
# TODO: Add PACKAGE target using package_apple_dmg.sh
CONFIGURE_FILE("package_apple.json.in" "${CMAKE_BINARY_DIR}/package_apple.json" @ONLY)
# DMG creation target
SET(DMG_FILE "${CMAKE_BINARY_DIR}/${CMAKE_PROJECT_NAME}-${VERSION}-mac${APPLE_OS_VER}.dmg")
FILE(REMOVE "${DMG_FILE}")
ADD_CUSTOM_TARGET(removedmg
COMMAND touch "\"${DMG_FILE}\"" && rm "\"${DMG_FILE}\""
COMMENT "Removing old DMG")
ADD_CUSTOM_TARGET(dmg
COMMAND appdmg "\"${CMAKE_BINARY_DIR}/package_apple.json\"" "\"${DMG_FILE}\""
DEPENDS "${CMAKE_BINARY_DIR}/package_apple.json"
COMMENT "Generating DMG")
ADD_DEPENDENCIES(dmg removedmg)
# see also ../postinstall/CMakeLists.txt

View File

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -9,113 +9,95 @@
#notes :Troubleshooting try: export DYLD_PRINT_LIBRARIES=1; export VERBOSE=1;
#requires :deploymacqt
#=========================================================================================
# MacPorts Location
MACPORTS=/opt/local
# LMMS project root directory (extracted source)
CMAKE_SRC=@CMAKE_SOURCE_DIR@
# LMMS compiled (install) resources
CMAKE_INSTALL=@CMAKE_INSTALL_PREFIX@
# LMMS working build directory
CMAKE_BUILD=$(cd @CMAKE_CURRENT_BINARY_DIR@/../..; pwd)
# STK rawwaves directory
STK_RAWWAVE=${HOME}/stk-*/rawwaves
STK_RAWWAVE=$HOME/stk-*/rawwaves
# Place to create ".app" bundle
APP=${HOME}/Desktop/LMMS.app
APP="@CMAKE_BINARY_DIR@/@PROJECT_NAME_UCASE@.app"
# MacPorts installs libreadline with wrong permissions
LIBREADLINE=${MACPORTS}/lib/libreadline.6.2.dylib
# The DMG packager script location
DMG_SCRIPT_SRC=${CMAKE_BUILD}/package_apple.sh
DMG_SCRIPT_DST=${HOME}/Desktop/package_apple.sh
LIBREADLINE="libreadline.6.2.dylib"
#=========================================================================================
MSG_COLOR='\x1B[1;36m'
COLOR_RESET='\x1B[0m'
echo -e "${MSG_COLOR}\n\nCreating App Bundle \"${APP}\"...${COLOR_RESET}"
echo -e "$MSG_COLOR\n\nCreating App Bundle \"$APP\"...$COLOR_RESET"
# Check for u+w permissions on libreadline
CHECKREADLINE=$(stat -f "%p" $LIBREADLINE)
CHECKREADLINE=${CHECKREADLINE:3:1}
if [ "${CHECKREADLINE}" != "7" ]
then
echo -e "\n\n\t\t\t\t***********\n\t\t\t\t* WARNING *\n\t\t\t\t***********"
echo -e "File ${LIBREADLINE} is not marked as user writable."
echo -e "This will break macdeployqt's linking process after it is copied."
echo -e "A sudo password is required to elevate and fix using chmod u+w."
echo -e "\nPLEASE ENTER SUDO PASSWORD:"
sudo chmod u+w "${MACPORTS}/lib/libreadline.6.2.dylib"
# MacPorts only - check for u+w permissions on libreadline
if [ -f "@APPLE_PREFIX@/lib/$LIBREADLINE" ]; then
CHECKREADLINE=$(stat -f "%p" @APPLE_PREFIX@/lib/$LIBREADLINE)
CHECKREADLINE=${CHECKREADLINE:3:1}
if [ "${CHECKREADLINE}" != "7" ]; then
echo -e "\n\n\t\t\t\t***********\n\t\t\t\t* WARNING *\n\t\t\t\t***********"
echo -e "File $LIBREADLINE is not marked as user writable."
echo -e "This will break macdeployqt's linking process after it is copied."
echo -e "A sudo password is required to elevate and fix using chmod u+w."
echo -e "\nPLEASE ENTER SUDO PASSWORD:"
sudo chmod u+w "@APPLE_PREFIX@/lib/$LIBREADLINE"
fi
fi
# Remove any old .app bundles
rm -Rf ${APP}
rm -Rf "$APP"
# Create new bundle, copy our built code to it
mkdir -p ${APP}
cd ${CMAKE_INSTALL}
mkdir ${APP}/Contents
cp -R * ${APP}/Contents
mkdir -p "$APP"
cd "@CMAKE_INSTALL_PREFIX@"
mkdir "$APP/Contents"
cp -R * "$APP/Contents"
# Manually copy STK rawwaves
mkdir -p ${APP}/Contents/share/stk/rawwaves
cp ${STK_RAWWAVE}/*.raw ${APP}/Contents/share/stk/rawwaves
mkdir -p "$APP/Contents/share/stk/rawwaves"
cp $STK_RAWWAVE/*.raw "$APP/Contents/share/stk/rawwaves"
# Make all libraries writable for macdeployqt
cd ${APP}
cd "$APP"
find . -type f -print0 | xargs -0 chmod u+w
# Move lmms binary to the proper location
mkdir -p ${APP}/Contents/MacOS
mv ${APP}/Contents/bin/lmms ${APP}/Contents/MacOS
rm -rf ${APP}/Contents/bin
mkdir -p "$APP/Contents/MacOS"
mv "$APP/Contents/bin/lmms" "$APP/Contents/MacOS/lmms"
rm -rf "$APP/Contents/bin"
# Move libraries to proper locations
mkdir -p ${APP}/Contents/Frameworks
mv ${APP}/Contents/lib/lmms/libZynAddSubFxCore.dylib \
${APP}/Contents/Frameworks/libZynAddSubFxCore.dylib
mkdir -p "$APP/Contents/Frameworks"
mv "$APP/Contents/lib/lmms/libZynAddSubFxCore.dylib" \
"$APP/Contents/Frameworks/libZynAddSubFxCore.dylib"
mv ${APP}/Contents/lib/lmms/RemoteZynAddSubFx \
${APP}/Contents/MacOS/RemoteZynAddSubFx
mv "$APP/Contents/lib/lmms/RemoteZynAddSubFx" \
"$APP/Contents/MacOS/RemoteZynAddSubFx"
# Fix more Zyn Linking issues
install_name_tool -change libZynAddSubFxCore.dylib \
install_name_tool -change @rpath/libZynAddSubFxCore.dylib \
@loader_path/../../Frameworks/libZynAddSubFxCore.dylib \
${APP}/Contents/lib/lmms/libzynaddsubfx.so
"$APP/Contents/lib/lmms/libzynaddsubfx.so"
install_name_tool -change ${CMAKE_BUILD}/plugins/zynaddsubfx/libZynAddSubFxCore.dylib \
install_name_tool -change @CMAKE_BINARY_DIR@/plugins/zynaddsubfx/libZynAddSubFxCore.dylib \
@loader_path/../../Frameworks/libZynAddSubFxCore.dylib \
${APP}/Contents/MacOS/RemoteZynAddSubFx
"$APP/Contents/MacOS/RemoteZynAddSubFx"
# Build a list of shared objects in target/lib/lmms
for file in ${APP}/Contents/lib/lmms/*.so; do
_executables="${_executables} -executable=${APP}/Contents/lib/lmms/${file##*/}"
for file in "$APP/Contents/lib/lmms/"*.so; do
_thisfile="$APP/Contents/lib/lmms/${file##*/}"
_executables="${_executables} -executable=$_thisfile"
done
# Build a list of shared objects in target/lib/lmms/ladspa
for file in ${APP}/Contents/lib/lmms/ladspa/*.so; do
_executables="${_executables} -executable=${APP}/Contents/lib/lmms/ladspa/${file##*/}"
for file in "$APP/Contents/lib/lmms/ladspa/"*.so; do
_thisfile="$APP/Contents/lib/lmms/ladspa/${file##*/}"
_executables="${_executables} -executable=$_thisfile"
done
# Additional binaries that require linking
_executables="${_executables} -executable=${APP}/Contents/MacOS/RemoteZynAddSubFx"
_executables="${_executables} -executable=${APP}/Contents/Frameworks/libZynAddSubFxCore.dylib"
_executables="${_executables} -executable=$APP/Contents/MacOS/RemoteZynAddSubFx"
_executables="${_executables} -executable=$APP/Contents/Frameworks/libZynAddSubFxCore.dylib"
# Build our App Package using "macdeployqt"
macdeployqt ${APP} $_executables
macdeployqt "$APP" $_executables
# OS X Specific Artwork
cp ${CMAKE_SRC}/cmake/apple/*.icns ${APP}/Contents/Resources/
mkdir -p "$APP/Contents/Resources"
cp "@CMAKE_SOURCE_DIR@/cmake/apple/"*.icns "$APP/Contents/Resources/"
# Done. Ready to build DMG
echo -e "\nFinished.\n\nYou may run LMMS from the Desktop."
echo -e "\nTo create an Apple DMG Package run ${MSG_COLOR}\"${DMG_SCRIPT_DST}\"${COLOR_RESET}.\n"
echo -e "(Note: You can drag/drop the script directly into this terminal window.)\n"
cp ${DMG_SCRIPT_SRC} ${DMG_SCRIPT_DST}
chmod +x ${DMG_SCRIPT_DST}
echo -e "\nFinished.\n\n"

View File

@@ -0,0 +1,10 @@
{
"title": "@MACOSX_BUNDLE_BUNDLE_NAME@ @MACOSX_BUNDLE_LONG_VERSION_STRING@",
"icon": "@CMAKE_SOURCE_DIR@/cmake/apple/lmms.icns",
"background": "@CMAKE_SOURCE_DIR@/cmake/apple/dmg_branding.png",
"icon-size": 72,
"contents": [
{ "x": 460, "y": 260, "type": "link", "path": "/Applications" },
{ "x": 220, "y": 260, "type": "file", "path": "@CMAKE_BINARY_DIR@/@MACOSX_BUNDLE_BUNDLE_NAME@.app" }
]
}

View File

@@ -1,140 +0,0 @@
#!/bin/bash
# by Andy Maloney
# http://asmaloney.com/2013/07/howto/packaging-a-mac-os-x-application-using-a-dmg/
# make sure we are in the correct dir when we double-click a .command file
dir=${0%/*}
if [ -d "$dir" ]; then
cd "$dir"
fi
# set up your app name, version number, and background image file name
APP_NAME="@MACOSX_BUNDLE_BUNDLE_NAME@"
VERSION="@MACOSX_BUNDLE_LONG_VERSION_STRING@"
DMG_BACKGROUND_IMG="dmg_branding.png"
cp "@CMAKE_SOURCE_DIR@/cmake/apple/${DMG_BACKGROUND_IMG}" .
# you should not need to change these
OS_VER=`sw_vers -productVersion|cut -d"." -f1-2`
APP_LOWERCASE=$(echo $APP_NAME|tr '[:upper:]' '[:lower:]')
APP_EXE="${APP_NAME}.app/Contents/MacOS/${APP_LOWERCASE}"
VOL_NAME="${APP_LOWERCASE}-${VERSION}-mac${OS_VER}" # volume name will be "SuperCoolApp 1.0.0"
DMG_TMP="${VOL_NAME}-temp.dmg"
DMG_FINAL="${VOL_NAME}.dmg" # final DMG name will be "SuperCoolApp 1.0.0.dmg"
STAGING_DIR="./Install" # we copy all our stuff into this dir
# Check the background image DPI and convert it if it isn't 72x72
_BACKGROUND_IMAGE_DPI_H=`sips -g dpiHeight ${DMG_BACKGROUND_IMG} | grep -Eo '[0-9]+\.[0-9]+'`
_BACKGROUND_IMAGE_DPI_W=`sips -g dpiWidth ${DMG_BACKGROUND_IMG} | grep -Eo '[0-9]+\.[0-9]+'`
if [ $(echo " $_BACKGROUND_IMAGE_DPI_H != 72.0 " | bc) -eq 1 -o $(echo " $_BACKGROUND_IMAGE_DPI_W != 72.0 " | bc) -eq 1 ]; then
echo "WARNING: The background image's DPI is not 72. This will result in distorted backgrounds on Mac OS X 10.7+."
echo " I will convert it to 72 DPI for you."
_DMG_BACKGROUND_TMP="${DMG_BACKGROUND_IMG%.*}"_dpifix."${DMG_BACKGROUND_IMG##*.}"
sips -s dpiWidth 72 -s dpiHeight 72 ${DMG_BACKGROUND_IMG} --out ${_DMG_BACKGROUND_TMP}
DMG_BACKGROUND_IMG="${_DMG_BACKGROUND_TMP}"
fi
# clear out any old data
rm -rf "${STAGING_DIR}" "${DMG_TMP}" "${DMG_FINAL}"
# copy over the stuff we want in the final disk image to our staging dir
mkdir -p "${STAGING_DIR}"
cp -rpf "${APP_NAME}.app" "${STAGING_DIR}"
# ... cp anything else you want in the DMG - documentation, etc.
pushd "${STAGING_DIR}"
# strip the executable
echo "Stripping ${APP_EXE}..."
strip -u -r "${APP_EXE}"
# compress the executable if we have upx in PATH
# UPX: http://upx.sourceforge.net/
if hash upx 2>/dev/null; then
echo "Compressing (UPX) ${APP_EXE}..."
upx -9 "${APP_EXE}"
fi
# ... perform any other stripping/compressing of libs and executables
popd
# figure out how big our DMG needs to be
# assumes our contents are at least 1M!
SIZE=`du -sh "${STAGING_DIR}" | sed 's/\([0-9\.]*\)M\(.*\)/\1/'`
SIZE=`echo "${SIZE} + 5.0" | bc | awk '{print int($1+0.5)}'`
if [ $? -ne 0 ]; then
echo "Error: Cannot compute size of staging dir"
exit
fi
# create the temp DMG file
hdiutil create -srcfolder "${STAGING_DIR}" -volname "${VOL_NAME}" -fs HFS+ \
-fsargs "-c c=64,a=16,e=16" -format UDRW -size ${SIZE}M "${DMG_TMP}"
echo "Created DMG: ${DMG_TMP}"
# mount it and save the device
DEVICE=$(hdiutil attach -readwrite -noverify "${DMG_TMP}" | \
egrep '^/dev/' | sed 1q | awk '{print $1}')
sleep 2
# add a link to the Applications dir
echo "Add link to /Applications"
pushd /Volumes/"${VOL_NAME}"
ln -s /Applications
popd
# add a background image
mkdir /Volumes/"${VOL_NAME}"/.background
cp "${DMG_BACKGROUND_IMG}" /Volumes/"${VOL_NAME}"/.background/
# tell the Finder to resize the window, set the background,
# change the icon size, place the icons in the right position, etc.
echo '
tell application "Finder"
tell disk "'${VOL_NAME}'"
open
set current view of container window to icon view
set toolbar visible of container window to false
set statusbar visible of container window to false
set the bounds of container window to {400, 100, 920, 440}
set viewOptions to the icon view options of container window
set arrangement of viewOptions to not arranged
set icon size of viewOptions to 72
set background picture of viewOptions to file ".background:'${DMG_BACKGROUND_IMG}'"
set position of item "'${APP_NAME}'.app" of container window to {160, 205}
set position of item "Applications" of container window to {360, 205}
close
open
update without registering applications
delay 2
end tell
end tell
' | osascript
sync
# unmount it
hdiutil detach "${DEVICE}"
# now make the final image a compressed disk image
echo "Creating compressed image"
hdiutil convert "${DMG_TMP}" -format UDZO -imagekey zlib-level=9 -o "${DMG_FINAL}"
# clean up
rm -rf "${DMG_TMP}"
rm -rf "${STAGING_DIR}"
rm -rf "${DMG_BACKGROUND_IMG}"
echo 'Done.'
exit

View File

@@ -8,6 +8,10 @@ ELSE()
SET(LMMS_BUILD_LINUX 1)
ENDIF(WIN32)
IF(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
SET(LMMS_BUILD_CLANG 1)
ENDIF()
MESSAGE("PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
SET(LMMS_HOST_X86 FALSE)
SET(LMMS_HOST_X86_64 FALSE)
@@ -55,4 +59,23 @@ ELSE(LMMS_BUILD_WIN32)
SET(LMMS_DATA_DIR ${DATA_DIR}/lmms)
ENDIF(LMMS_BUILD_WIN32)
IF(LMMS_BUILD_APPLE)
# Detect Homebrew versus Macports environment
EXECUTE_PROCESS(COMMAND brew --prefix RESULT_VARIABLE DETECT_HOMEBREW OUTPUT_VARIABLE HOMEBREW_PREFIX ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
EXECUTE_PROCESS(COMMAND which port RESULT_VARIABLE DETECT_MACPORTS OUTPUT_VARIABLE MACPORTS_PREFIX ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
IF(${DETECT_HOMEBREW} EQUAL 0)
SET(HOMEBREW 1)
SET(APPLE_PREFIX "${HOMEBREW_PREFIX}")
ELSEIF(${DETECT_MACPORTS} EQUAL 0)
SET(MACPORTS 1)
GET_FILENAME_COMPONENT(MACPORTS_PREFIX ${MACPORTS_PREFIX} DIRECTORY)
GET_FILENAME_COMPONENT(MACPORTS_PREFIX ${MACPORTS_PREFIX} DIRECTORY)
SET(APPLE_PREFIX "${MACPORTS_PREFIX}")
LINK_DIRECTORIES(${LINK_DIRECTORIES} ${APPLE_PREFIX}/lib)
ENDIF()
# Detect OS Version
EXECUTE_PROCESS(COMMAND sw_vers -productVersion OUTPUT_VARIABLE APPLE_OS_VER ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
STRING(REGEX REPLACE "\\.[0-9]*$" "" APPLE_OS_VER "${APPLE_OS_VER}")
SET(CMAKE_MACOSX_RPATH 1)
ENDIF()

View File

@@ -0,0 +1,4 @@
IF(LMMS_BUILD_APPLE)
INSTALL(CODE "EXECUTE_PROCESS(COMMAND chmod u+x ${CMAKE_BINARY_DIR}/install_apple.sh)")
INSTALL(CODE "EXECUTE_PROCESS(COMMAND ${CMAKE_BINARY_DIR}/install_apple.sh)")
ENDIF()

View File

@@ -2,5 +2,12 @@ INCLUDE(BuildPlugin)
INCLUDE_DIRECTORIES(unrtf)
ADD_DEFINITIONS(--std=c++0x)
# Enable C++11
ADD_DEFINITIONS(-std=c++0x)
IF(LMMS_BUILD_CLANG)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
ENDIF()
BUILD_PLUGIN(flpimport FlpImport.cpp unrtf.cpp FlpImport.h)

View File

@@ -7,6 +7,13 @@ SET(LMMS_UIS "")
SET(CMAKE_AUTOMOC ON)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
# Enable C++11
ADD_DEFINITIONS(-std=c++0x)
IF(LMMS_BUILD_CLANG)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
ENDIF()
ADD_SUBDIRECTORY(core)
ADD_SUBDIRECTORY(gui)
ADD_SUBDIRECTORY(tracks)
@@ -64,9 +71,6 @@ IF(NOT ("${OGGVORBIS_INCLUDE_DIR}" STREQUAL ""))
INCLUDE_DIRECTORIES("${OGGVORBIS_INCLUDE_DIR}")
ENDIF()
# Enable C++11
ADD_DEFINITIONS("-std=c++0x")
# ADD_LIBRARY's OBJECT is only supported in CMake >=2.8.8
IF(CMAKE_VERSION VERSION_GREATER "2.8.7")