5 # This script automates creating universal binaries of LyX on Mac.
6 # Author: Bennett Helm (and extended by Konrad Hofbauer)
7 # modified by Stephan Witt
8 # Last modified: 6 June 2010
10 #Qt4SourceVersion="qt-everywhere-opensource-src-4.7.0-beta1"
11 #Qt4Build="qt4.7-beta"
14 # * a decent checkout of LyX sources (probably you have it already)
15 # * Qt4 - build with shared or static libraries for the used platforms (default: i386 and ppc)
16 # or - an unpacked source tree of Qt4 in $QT4SOURCEDIR or in the sibling directory (variable Qt4SourceVersion)
17 # * for aspell support:
18 # the aspell sources placed in a sibling directory (variable ASpellSourceVersion)
19 # * for hunspell support:
20 # the hunspell sources placed in a sibling directory (variable HunSpellSourceVersion)
21 # * for dictionary deployment:
22 # - aspell: the dictionary files of macports (in /opt/local/share/aspell and /opt/local/lib/aspell-0.60)
23 # - hunspell: the dictionary files in the sibling directory Dictionaries/dict
24 # - mythes: the data and idx files in the sibling directory Dictionaries/thes
26 LyXConfigureOptions="--enable-warnings --enable-optimization=-Os --with-included-gettext --x-includes=/usr/X11/include --x-libraries=/usr/X11/lib"
27 AspellConfigureOptions="--enable-warnings --enable-optimization=-O0 --enable-debug --disable-nls --enable-compile-in-filters --disable-pspell-compatibility"
28 HunspellConfigureOptions="--with-warnings --disable-nls --with-included-gettext --disable-static"
29 Qt4ConfigureOptions="-opensource -silent -shared -release -fast -no-exceptions"
30 Qt4ConfigureOptions="${Qt4ConfigureOptions} -no-webkit -no-qt3support -no-javascript-jit -no-dbus"
31 Qt4ConfigureOptions="${Qt4ConfigureOptions} -nomake examples -nomake demos -nomake docs -nomake tools"
33 aspell_deployment="yes"
34 hunspell_deployment="yes"
35 thesaurus_deployment="yes"
37 MACOSX_DEPLOYMENT_TARGET="10.4" # Tiger support is default
40 echo Build script for LyX on Mac OS X
42 echo Optional arguments:
43 echo " --aspell-deployment=yes|no ." default yes
44 echo " --qt4-deployment=yes|no ...." default yes
45 echo " --with-macosx-target=TARGET " default 10.4 "(Tiger)"
46 echo " --with-arch=ARCH ..........." default ppc,i386
47 echo " --with-build-path=PATH ....." default \${lyx-src-dir}/../lyx-build
48 echo " --with-dmg-location=PATH ..." default \${build-path}
50 echo "All other arguments with -- are passed to configure"
51 echo "including the defaults: ${LyXConfigureOptions}"
56 while [ $# -gt 0 ]; do
59 QTDIR=`echo ${1}|cut -d= -f2`
62 --with-macosx-target=*)
63 MACOSX_DEPLOYMENT_TARGET=`echo ${1}|cut -d= -f2`
66 --aspell-deployment=*)
67 aspell_deployment=`echo ${1}|cut -d= -f2`
70 --hunspell-deployment=*)
71 hunspell_deployment=`echo ${1}|cut -d= -f2`
74 --thesaurus-deployment=*)
75 thesaurus_deployment=`echo ${1}|cut -d= -f2`
79 qt4_deployment=`echo ${1}|cut -d= -f2`
83 ARCH=`echo ${1}|cut -d= -f2|tr ',' ' '`
84 ARCH_LIST="${ARCH_LIST} ${ARCH}"
87 --with-dmg-location=*)
88 DMGLocation=`echo ${1}|cut -d= -f2`
92 LyxBuildDir=`echo ${1}|cut -d= -f2`
99 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
100 aspell_deployment="no"
104 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
105 hunspell_deployment="no"
109 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
118 # Set these variables -- to
119 # (1) the location of your Qt4 installation
120 # (2) the location of resulting DMG
121 # (3) the version of private aspell installation
122 # (to define the location assign ASpellSourceDir instead)
123 # (4) the list of architectures to build for
125 QtInstallDir=${QTDIR:-"/opt/qt4"}
126 QtFrameworkVersion="4"
127 ASpellSourceVersion="aspell-0.60.6"
128 HunSpellSourceVersion="hunspell-1.2.9"
129 Qt4SourceVersion=${Qt4SourceVersion:-"qt-everywhere-opensource-src-4.6.2"}
131 ARCH_LIST=${ARCH_LIST:-"ppc i386"}
136 # detection of script home
137 LyxSourceDir=${1:-`dirname "$0"`}
138 if [ ! -d "${LyxSourceDir}" ]; then
139 echo Missing LyX source directory.
142 case "${LyxSourceDir}" in
144 LyxSourceDir=`dirname "${LyxSourceDir}"`
148 */development|development)
149 LyxSourceDir=`dirname "${LyxSourceDir}"`
150 LyxSourceDir=`cd "${LyxSourceDir}";pwd`
153 LyxSourceDir=`cd "${LyxSourceDir}";pwd`
157 LyxBuildDir=${LyxBuildDir:-`dirname "${LyxSourceDir}"`/lyx-build}
158 DMGLocation=${DMGLocation:-"${LyxBuildDir}"}
160 ASpellSourceDir=${ASPELLDIR:-`dirname "${LyxSourceDir}"`/${ASpellSourceVersion}}
161 ASpellInstallDir=${ASpellInstallDir:-"${LyxBuildDir}"/SpellChecker.lib}
162 HunSpellSourceDir=${HUNSPELLDIR:-`dirname "${LyxSourceDir}"`/${HunSpellSourceVersion}}
163 HunSpellInstallDir=${HunSpellInstallDir:-"${LyxBuildDir}"/SpellChecker.lib}
164 Qt4SourceDir=${QT4SOURCEDIR:-`dirname "${LyxSourceDir}"`/${Qt4SourceVersion}}
165 Qt4BuildDir=${Qt4BuildDir:-"${LyxBuildDir}"/${Qt4Build:-"qt4-build"}}
166 DictionarySourceDir=${DICTIONARYDIR:-`dirname "${LyxSourceDir}"`/Dictionaries}
168 ASpellInstallHdr="${ASpellInstallDir}/include/aspell.h"
169 HunSpellInstallHdr="${HunSpellInstallDir}/include/hunspell/hunspell.h"
171 if [ -z "${LyXVersion}" ]; then
172 LyXVersion=`grep AC_INIT "${LyxSourceDir}"/configure.ac | cut -d, -f2 | tr -d " ()"`
176 LyxBase="${LyxName}-${LyXVersion}"
177 LyxApp="${LyxBase}.app"
178 LyxAppDir="${LyxBuildDir}"/"${LyxBase}"
179 LyxBuildDir="${LyxAppDir}.build"
180 LyxAppPrefix="${LyxAppDir}.app"
181 # if zip file is needed... remove the comment sign
182 #LyxAppZip="${LyxAppPrefix}.zip"
184 BuildSystem=`"${LyxSourceDir}/config/config.guess"`
186 # ---------------------------------
187 # DON'T MODIFY ANYTHING BELOW HERE!
188 # ---------------------------------
190 # These variables define the identifiers of the
191 # system (both Intel and PowerPC) to compile for.
192 # (Note: darwin8 is 10.4; darwin9 is 10.5.)
193 # Only change these if necessary
195 HostSystem_i386="i686-apple-darwin8"
196 HostSystem_ppc="powerpc-apple-darwin8"
198 # don't change order here...
199 QtLibraries="QtSvg QtXml QtGui QtNetwork QtCore"
203 BACKGROUND="${LyxAppDir}.app/Contents/Resources/images/banner.png"
205 # Check for existing SDKs
206 SDKs=`echo /Developer/SDKs/MacOSX10*sdk`
209 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.5"}; export MACOSX_DEPLOYMENT_TARGET
210 case "${MACOSX_DEPLOYMENT_TARGET}" in
212 SDKROOT="/Developer/SDKs/MacOSX10.5.sdk"; export SDKROOT
215 SDKROOT="/Developer/SDKs/MacOSX10.4u.sdk"; export SDKROOT
216 CC=gcc-4.0 ; export CC
217 CXX=g++-4.0 ; export CXX
218 OBJC=gcc-4.0 ; export OBJC
223 MACOSX_DEPLOYMENT_TARGET="10.4"; export MACOSX_DEPLOYMENT_TARGET
224 SDKROOT="/Developer/SDKs/MacOSX10.4u.sdk"; export SDKROOT
227 echo Unknown or missing SDK for Mac OS X.
231 MYCFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}"
233 if [ -d "${Qt4SourceDir}" -a ! -d "${Qt4BuildDir}" ]; then
234 echo Build Qt4 library ${Qt4SourceDir}
237 mkdir -p "${Qt4BuildDir}" && cd "${Qt4BuildDir}"
238 for arch in ${ARCH_LIST} ; do
239 ARCHS="${ARCHS} -arch ${arch}"
241 echo configure options:
242 echo ${Qt4ConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
244 echo yes | "${Qt4SourceDir}"/configure ${Qt4ConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
247 cd "${QtInstallDir}" && (
250 for libnm in ${QtLibraries} ; do
251 test -d ${libnm} -o -L ${libnm} || ln -s ../lib/${libnm}.framework/Headers ${libnm}
256 if [ -d "${HunSpellSourceDir}" -a ! -f "${HunSpellInstallHdr}" ]; then
257 # we have a private HunSpell source tree at hand...
258 # so let's build and install it
259 if [ -z "${HunSpellVersion}" ]; then
260 HunSpellVersion=`grep AC_INIT "${HunSpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()"`
263 HunSpellName="Hunspell"
264 HunSpellBase="${HunSpellName}-${HunSpellVersion}"
266 echo Build hunspell library ${HunSpellBase}
267 echo configure options:
268 echo --prefix="${HunSpellInstallDir}" ${HunspellConfigureOptions}
270 cd "${HunSpellSourceDir}"
272 # ----------------------------------------
273 # Build HunSpell for different architectures
274 # ----------------------------------------
275 FILE_LIST="libhunspell-1.2.0.dylib"
277 for arch in ${ARCH_LIST} ; do
279 CPPFLAGS=" -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
280 LDFLAGS=" -arch ${arch}"; export LDFLAGS
281 HOSTSYSTEM=`eval "echo \\$HostSystem_$arch"`
282 "${HunSpellSourceDir}/configure"\
283 --prefix="${HunSpellInstallDir}"\
284 ${HunspellConfigureOptions}
285 #--host="${HOSTSYSTEM}" ${BuildSystem:+"--build=${BuildSystem}"}
286 make && make install${strip}
287 for file in ${FILE_LIST} ; do
288 if [ -f "${HunSpellInstallDir}"/lib/${file} ]; then
289 mv "${HunSpellInstallDir}"/lib/${file}\
290 "${HunSpellInstallDir}"/lib/${file}-${arch}
292 echo Cannot build and install HunSpell for ${arch}.
297 # -------------------------
298 # Create universal binaries
299 # -------------------------
300 for file in ${FILE_LIST} ; do
302 for arch in ${ARCH_LIST} ; do
303 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
306 cd "${HunSpellInstallDir}"
307 lipo -create ${OBJ_LIST} -o lib/${file}
308 # check for the "missing link"...
309 test -f lib/libhunspell.dylib || (cd lib ; ln -s libhunspell-1.2.dylib libhunspell.dylib)
315 for arch in ${ARCH_LIST} ; do
316 rm -f "${HunSpellInstallDir}"/lib/*-${arch}
323 if [ -d "${ASpellSourceDir}" -a ! -f "${ASpellInstallHdr}" -a "yes" = "${aspell_deployment}" ]; then
324 # we have a private ASpell source tree at hand...
325 # so let's build and install it
326 if [ -z "${ASpellVersion}" ]; then
327 ASpellVersion=`grep AC_INIT "${ASpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()"`
331 ASpellBase="${ASpellName}-${ASpellVersion}"
333 echo Build aspell library ${ASpellBase}
334 echo configure options:
335 echo --prefix="${ASpellInstallDir}" ${AspellConfigureOptions}
337 # ASpell builds inplace only :(
338 cd "${ASpellSourceDir}"
340 # ----------------------------------------
341 # Build ASpell for different architectures
342 # ----------------------------------------
343 FILE_LIST="libaspell.15.dylib"
345 for arch in ${ARCH_LIST} ; do
347 CPPFLAGS=" -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
348 LDFLAGS=" -arch ${arch}"; export LDFLAGS
349 HOSTSYSTEM=`eval "echo \\$HostSystem_$arch"`
350 CXXFLAGS=-g "${ASpellSourceDir}/configure"\
351 --prefix="${ASpellInstallDir}"\
352 ${AspellConfigureOptions}
353 #--host="${HOSTSYSTEM}" ${BuildSystem:+"--build=${BuildSystem}"}
354 make && make install${aspellstrip}
355 for file in ${FILE_LIST} ; do
356 if [ -f "${ASpellInstallDir}"/lib/${file} ]; then
357 mv "${ASpellInstallDir}"/lib/${file}\
358 "${ASpellInstallDir}"/lib/${file}-${arch}
360 echo Cannot build and install ASpell for ${arch}.
365 # -------------------------
366 # Create universal binaries
367 # -------------------------
368 for file in ${FILE_LIST} ; do
370 for arch in ${ARCH_LIST} ; do
371 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
374 cd "${ASpellInstallDir}"
375 lipo -create ${OBJ_LIST} -o lib/${file}
381 for arch in ${ARCH_LIST} ; do
382 rm -f "${ASpellInstallDir}"/lib/*-${arch}
387 echo "Frameworks/${1}.framework"
390 if [ ! -f "${LyxSourceDir}"/configure ]; then
391 ( cd "${LyxSourceDir}" && sh autogen.sh )
394 FILE_LIST="lyx lyxclient tex2lyx"
395 BUNDLE_PATH="Contents/MacOS"
396 LYX_BUNDLE_PATH="${LyxAppPrefix}/${BUNDLE_PATH}"
399 if [ -n "${LyxAppZip}" -a -f "${LyxAppZip}" ]; then rm "${LyxAppZip}"; fi
400 if [ -d "${LyxAppPrefix}" ]; then rm -rf "${LyxAppPrefix}"; fi
402 # -------------------------------------
403 # Build LyX for different architectures
404 # -------------------------------------
406 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
407 ASpellFramework=`framework_name Aspell`
408 ASpellFramework=`basename "${ASpellFramework}"`
409 ConfigureExtraInc="--with-extra-inc=${ASpellInstallDir}/include"
410 ConfigureExtraLib="--with-extra-lib=${ASpellInstallDir}/lib"
411 LyXConfigureOptions="${LyXConfigureOptions} --with-aspell-framework=${ASpellFramework}"
414 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
415 HunSpellFramework=`framework_name Hunspell`
416 HunSpellFramework=`basename "${HunSpellFramework}"`
417 ConfigureExtraInc="--with-extra-inc=${HunSpellInstallDir}/include"
418 ConfigureExtraLib="--with-extra-lib=${HunSpellInstallDir}/lib"
419 # LyXConfigureOptions="${LyXConfigureOptions} --with-hunspell-framework=${HunSpellFramework}"
421 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraInc}"
422 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraLib}"
424 for arch in ${ARCH_LIST} ; do
426 if [ -d "${LyxBuildDir}" ]; then rm -r "${LyxBuildDir}"; fi
427 mkdir "${LyxBuildDir}" && cd "${LyxBuildDir}"
429 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
430 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch}"; export LDFLAGS
431 HOSTSYSTEM=`eval "echo \\$HostSystem_$arch"`
433 echo LDFLAGS="${LDFLAGS}"
434 echo CPPFLAGS="${CPPFLAGS}"
435 echo CONFIGURE_OPTIONS="${LyXConfigureOptions}"
436 "${LyxSourceDir}/configure"\
437 --prefix="${LyxAppPrefix}" --with-version-suffix="-${LyXVersion}"\
438 ${QtInstallDir:+"--with-qt4-dir=${QtInstallDir}"} \
439 ${LyXConfigureOptions}\
440 --host="${HOSTSYSTEM}" --build="${BuildSystem}" --enable-build-type=rel && \
441 make && make install${strip}
442 for file in ${FILE_LIST} ; do
443 if [ -f "${LYX_BUNDLE_PATH}/${file}" ]; then
444 mv "${LYX_BUNDLE_PATH}/${file}"\
445 "${LYX_BUNDLE_PATH}/${file}-${arch}"
447 echo ERROR: Cannot build and install LyX for ${arch}.
454 content_directory() {
456 content=`dirname "${target}"`
457 content=`dirname "${content}"`
461 private_framework() {
462 fwdir=`framework_name "$1"`
465 condir=`content_directory "${target}"`
466 libnm=`basename "${source}"`
467 mkdir -p "${condir}/${fwdir}"
468 if [ ! -f "${condir}/${fwdir}/${libnm}" ]; then
469 cp -p "${source}" "${condir}/${fwdir}"
470 echo Set library id in "${condir}/${fwdir}/${libnm}"
471 install_name_tool -id "@executable_path/../${fwdir}/${libnm}" "${condir}/${fwdir}/${libnm}"
473 echo Correct library id reference to "${libnm}" in "${target}"
474 install_name_tool -change "${source}" "@executable_path/../${fwdir}/${libnm}" "${target}"
478 source="${QtInstallDir}"
480 version="Versions/${QtFrameworkVersion}/"
481 condir=`content_directory "${target}"`
482 mkdir -p "${condir}/Resources"
483 test -f "${condir}/Resources/qt.conf" || cat - > "${condir}/Resources/qt.conf" <<-EOF
487 if [ ! -d "${condir}/PlugIns" ]; then
488 mkdir -p "${condir}/PlugIns"
489 find "${source}/plugins" -name \*.dylib -print | while read libname ; do
490 echo Copy plugin "${libname}"
491 dylib=`basename "${libname}"`
492 dirname=`dirname "${libname}"`
493 dirname=`basename "${dirname}"`
494 mkdir -p "${condir}/PlugIns/${dirname}"
495 cp -p "${libname}" "${condir}/PlugIns/${dirname}"
498 for libnm in ${QtLibraries} ; do
499 fwdir=`framework_name "$libnm"`
500 dirname=`basename "${fwdir}"`
501 test -d "${condir}/${fwdir}" || (
502 echo Copy framework "${source}/lib/"`basename "${fwdir}"`
503 cp -pR "${source}/lib/"`basename "${fwdir}"` "${condir}/${fwdir}"
504 echo Set library id in "${condir}/${fwdir}/${version}${libnm}"
505 install_name_tool -id "@executable_path/../${fwdir}/${version}${libnm}" "${condir}/${fwdir}/${version}${libnm}"
506 find "${condir}/PlugIns" "${condir}/"`dirname "${fwdir}"` -name Headers -prune -o -type f -print | while read filename ; do
507 otool -L "${filename}" 2>/dev/null | while read library ; do
508 # pattern match for: /path/to/qt4/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.6.0, current version 4.6.2)
510 *"${libnm}"*"("*")"*)
511 echo Correct library id reference to "${libnm}" in "${filename}"
512 install_name_tool -change\
513 "${source}/lib/${dirname}/${version}${libnm}"\
514 "@executable_path/../${fwdir}/${version}${libnm}"\
521 echo Correct library id reference to "${libnm}" in "${target}"
522 install_name_tool -change\
523 "${source}/lib/${dirname}/${version}${libnm}"\
524 "@executable_path/../${fwdir}/${version}${libnm}"\
529 # -------------------------
530 # Create universal binaries
531 # -------------------------
532 convert_universal() {
534 for file in ${FILE_LIST} ; do
536 for arch in ${ARCH_LIST} ; do
537 if [ -f "${BUNDLE_PATH}/${file}-${arch}" ]; then
538 OBJ_LIST="${OBJ_LIST} ${BUNDLE_PATH}/${file}-${arch}"
541 if [ -n "${OBJ_LIST}" ]; then
542 lipo -create ${OBJ_LIST} -o "${BUNDLE_PATH}/${file}"
544 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
545 private_framework Aspell "${ASpellInstallDir}/lib/libaspell.15.dylib" "${LYX_BUNDLE_PATH}/${file}"
547 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
548 private_framework Hunspell "${HunSpellInstallDir}/lib/libhunspell-1.2.0.dylib" "${LYX_BUNDLE_PATH}/${file}"
550 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt4_deployment}" ]; then
551 deploy_qtlibs "${LYX_BUNDLE_PATH}/${file}"
553 otool -L "${BUNDLE_PATH}/${file}" | while read reference ; do
554 case "${reference}" in
555 *"${LyxBuildDir}"*"("*")")
556 echo ERROR: Bad reference to "${reference}" found!!
561 for arch in ${ARCH_LIST} ; do
562 rm -f ${BUNDLE_PATH}/*-${arch}
566 copy_dictionaries() {
567 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
568 ASpellFramework=`framework_name Aspell`
569 ASpellResources="${LyxAppPrefix}/Contents/${ASpellFramework}/Resources"
570 # try to reuse macports dictionaries for now
571 if [ -d /opt/local/lib/aspell-0.60 ]; then ASpellInstallDir=/opt/local ; fi
572 mkdir -p "${ASpellResources}"
573 echo Copy Aspell dictionaries from "${ASpellInstallDir}"
574 cp -p -r "${ASpellInstallDir}/lib/aspell-0.60" "${ASpellResources}"/data
575 cp -p -r "${ASpellInstallDir}/share/aspell" "${ASpellResources}"/dict
577 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
578 HunSpellResources="${LyxAppPrefix}/Contents/Resources"
579 if [ -d "${DictionarySourceDir}" ]; then
580 cp -p -r "${DictionarySourceDir}/dict" "${HunSpellResources}"
583 if [ -d "${DictionarySourceDir}" -a "yes" = "${thesaurus_deployment}" ]; then
584 MyThesResources="${LyxAppPrefix}/Contents/Resources"
585 cp -p -r "${DictionarySourceDir}/thes" "${MyThesResources}"
589 function set_bundle_display_options() {
591 tell application "Finder"
592 set f to POSIX file ("${1}" as string) as alias
595 tell container window
596 set toolbar visible to false
597 set statusbar visible to false
598 set current view to icon view
600 set the bounds to {20, 50, $2, $3}
603 set icon size of the icon view options of container window to 64
604 set arrangement of the icon view options of container window to not arranged
605 set position of item "${LyxName}.app" to {100,$4}
606 set position of item "Applications" to {280,$4}
607 set background picture of the icon view options\
608 of container window to file "background.png" of folder "Pictures"
609 set the bounds of the container window to {0, 0, $2, $3}
610 update without registering applications
619 function make_dmg() {
622 BGSIZE=`file "$BACKGROUND" | awk -F , '/PNG/{print $2 }' | tr x ' '`
623 BG_W=`echo ${BGSIZE} | awk '{print $1 }'`
624 BG_H=`echo ${BGSIZE} | awk '{h = $2 + 20 ;print h }'`
625 BG_Y=`echo ${BGSIZE} | awk '{y = $2 - 60 ;print y }'`
627 rm -f "${DMGNAME}.sparseimage" "${DMGNAME}.dmg"
629 hdiutil create -type SPARSE -size ${DMGSIZE:-"250m"} -fs HFS+ -volname "${LyxBase}" "${DMGNAME}"
630 # Unmount currently mounted disk image
631 test -d /Volumes/"${LyxBase}" && umount /Volumes/"${LyxBase}"
633 # Mount the disk image
634 hdiutil attach "${DMGNAME}.sparseimage"
636 # Obtain device information
637 DEVS=$(hdiutil attach "${DMGNAME}.sparseimage" | cut -f 1)
638 DEV=$(echo $DEVS | cut -f 1 -d ' ')
639 VOLUME=$(mount |grep ${DEV} | cut -f 3 -d ' ')
641 # copy in the application bundle
642 cp -Rp "${LyxAppDir}.app" "${VOLUME}/${LyxName}.app"
644 # copy in background image
645 mkdir -p "${VOLUME}/Pictures"
646 cp "${BACKGROUND}" "${VOLUME}/Pictures/background.png"
647 # symlink applications
648 ln -s /Applications/ "${VOLUME}"/Applications
649 set_bundle_display_options "${VOLUME}" ${BG_W} ${BG_H} ${BG_Y}
650 mv "${VOLUME}/Pictures" "${VOLUME}/.Pictures"
652 # Unmount the disk image
653 hdiutil detach ${DEV}
655 # Convert the disk image to read-only
656 hdiutil convert "${DMGNAME}.sparseimage" -format UDBZ -o "${DMGNAME}.dmg"
657 rm -f "${DMGNAME}.sparseimage"
664 # ------------------------------
665 # Building distribution packages
666 # ------------------------------
668 test -n "${LyxAppZip}" && (
669 cd "${LyxAppPrefix}" && zip -r "${LyxAppZip}" .
672 test -n "${DMGLocation}" && (
673 make_dmg "${DMGLocation}"
674 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt4_deployment}" ]; then
675 rm -f "${DMGLocation}/${DMGNAME}+qt4.dmg"
676 mv "${DMGLocation}/${DMGNAME}.dmg" "${DMGLocation}/${DMGNAME}+qt4.dmg"
677 for libnm in ${QtLibraries} ; do
678 fwdir=`framework_name "$libnm"`
679 rm -rf "${LyxAppDir}.app/Contents/${fwdir}"
681 make_dmg "${DMGLocation}"