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: 17 April 2010
11 # * a decent checkout of LyX sources (probably you have it already)
12 # * Qt4 - build with shared or static libraries for the used platforms (default: i386 and ppc)
13 # or - an unpacked source tree of Qt4 in $QT4SOURCEDIR or in the sibling directory (variable Qt4SourceVersion)
14 # * for aspell support:
15 # the aspell sources placed in a sibling directory (variable ASpellSourceVersion)
16 # * for hunspell support:
17 # the hunspell sources placed in a sibling directory (variable HunSpellSourceVersion)
18 # * for dictionary deployment:
19 # - aspell: the dictionary files of macports (in /opt/local/share/aspell and /opt/local/lib/aspell-0.60)
20 # - hunspell: the dictionary files in the sibling directory Dictionaries/dict
21 # - mythes: the data and idx files in the sibling directory Dictionaries/thes
23 LyXConfigureOptions="--enable-warnings --enable-optimization=-Os --with-included-gettext"
24 AspellConfigureOptions="--enable-warnings --disable-nls --enable-compile-in-filters --disable-pspell-compatibility"
25 HunspellConfigureOptions="--with-warnings --disable-nls --with-included-gettext --disable-static"
26 Qt4ConfigureOptions="-opensource -silent -shared -release -fast -no-exceptions"
27 Qt4ConfigureOptions="${Qt4ConfigureOptions} -no-webkit -no-qt3support -no-javascript-jit -no-dbus"
28 Qt4ConfigureOptions="${Qt4ConfigureOptions} -nomake examples -nomake demos -nomake docs -nomake tools"
30 aspell_deployment="yes"
31 hunspell_deployment="yes"
32 thesaurus_deployment="yes"
34 MACOSX_DEPLOYMENT_TARGET="10.4" # Tiger support is default
37 echo Build script for LyX on Mac OS X
39 echo Optional arguments:
40 echo " --aspell-deployment=yes|no ." default yes
41 echo " --qt4-deployment=yes|no ...." default yes
42 echo " --with-macosx-target=TARGET " default 10.4 "(Tiger)"
43 echo " --with-arch=ARCH ..........." default ppc,i386
44 echo " --with-build-path=PATH ....." default \${lyx-src-dir}/../lyx-build
45 echo " --with-dmg-location=PATH ..." default \${build-path}
47 echo "All other arguments with -- are passed to configure"
48 echo "including the defaults: ${LyXConfigureOptions}"
53 while [ $# -gt 0 ]; do
56 QTDIR=`echo ${1}|cut -d= -f2`
59 --with-macosx-target=*)
60 MACOSX_DEPLOYMENT_TARGET=`echo ${1}|cut -d= -f2`
63 --aspell-deployment=*)
64 aspell_deployment=`echo ${1}|cut -d= -f2`
67 --hunspell-deployment=*)
68 hunspell_deployment=`echo ${1}|cut -d= -f2`
71 --thesaurus-deployment=*)
72 thesaurus_deployment=`echo ${1}|cut -d= -f2`
76 qt4_deployment=`echo ${1}|cut -d= -f2`
80 ARCH=`echo ${1}|cut -d= -f2|tr ',' ' '`
81 ARCH_LIST="${ARCH_LIST} ${ARCH}"
84 --with-dmg-location=*)
85 DMGLocation=`echo ${1}|cut -d= -f2`
89 LyxBuildDir=`echo ${1}|cut -d= -f2`
96 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
97 aspell_deployment="no"
101 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
102 hunspell_deployment="no"
106 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
115 # Set these variables -- to
116 # (1) the location of your Qt4 installation
117 # (2) the location of resulting DMG
118 # (3) the version of private aspell installation
119 # (to define the location assign ASpellSourceDir instead)
120 # (4) the list of architectures to build for
122 QtInstallDir=${QTDIR:-"/opt/qt4"}
123 QtFrameworkVersion="4"
124 ASpellSourceVersion="aspell-0.60.6"
125 HunSpellSourceVersion="hunspell-1.2.9"
126 Qt4SourceVersion="qt-everywhere-opensource-src-4.6.2"
128 ARCH_LIST=${ARCH_LIST:-"ppc i386"}
132 # detection of script home
133 LyxSourceDir=${1:-`dirname "$0"`}
134 if [ ! -d "${LyxSourceDir}" ]; then
135 echo Missing LyX source directory.
138 case "${LyxSourceDir}" in
140 LyxSourceDir=`dirname "${LyxSourceDir}"`
144 */development|development)
145 LyxSourceDir=`dirname "${LyxSourceDir}"`
146 LyxSourceDir=`cd "${LyxSourceDir}";pwd`
149 LyxSourceDir=`cd "${LyxSourceDir}";pwd`
153 LyxBuildDir=${LyxBuildDir:-`dirname "${LyxSourceDir}"`/lyx-build}
154 DMGLocation=${DMGLocation:-"${LyxBuildDir}"}
156 ASpellSourceDir=${ASPELLDIR:-`dirname "${LyxSourceDir}"`/${ASpellSourceVersion}}
157 ASpellInstallDir=${ASpellInstallDir:-"${LyxBuildDir}"/SpellChecker.lib}
158 HunSpellSourceDir=${HUNSPELLDIR:-`dirname "${LyxSourceDir}"`/${HunSpellSourceVersion}}
159 HunSpellInstallDir=${HunSpellInstallDir:-"${LyxBuildDir}"/SpellChecker.lib}
160 Qt4SourceDir=${QT4SOURCEDIR:-`dirname "${LyxSourceDir}"`/${Qt4SourceVersion}}
161 Qt4BuildDir="${LyxBuildDir}/qt4-build"
162 DictionarySourceDir=${DICTIONARYDIR:-`dirname "${LyxSourceDir}"`/Dictionaries}
164 ASpellInstallHdr="${ASpellInstallDir}/include/aspell.h"
165 HunSpellInstallHdr="${HunSpellInstallDir}/include/hunspell/hunspell.h"
167 if [ -z "${LyXVersion}" ]; then
168 LyXVersion=`grep AC_INIT "${LyxSourceDir}"/configure.ac | cut -d, -f2 | tr -d " ()"`
172 LyxBase="${LyxName}-${LyXVersion}"
173 LyxApp="${LyxBase}.app"
174 LyxAppDir="${LyxBuildDir}"/"${LyxBase}"
175 LyxBuildDir="${LyxAppDir}.build"
176 LyxAppPrefix="${LyxAppDir}.app"
177 # if zip file is needed... remove the comment sign
178 #LyxAppZip="${LyxAppPrefix}.zip"
180 BuildSystem=`"${LyxSourceDir}/config/config.guess"`
182 # ---------------------------------
183 # DON'T MODIFY ANYTHING BELOW HERE!
184 # ---------------------------------
186 # These variables define the identifiers of the
187 # system (both Intel and PowerPC) to compile for.
188 # (Note: darwin8 is 10.4; darwin9 is 10.5.)
189 # Only change these if necessary
191 HostSystem_i386="i686-apple-darwin8"
192 HostSystem_ppc="powerpc-apple-darwin8"
194 # don't change order here...
195 QtLibraries="QtSvg QtXml QtGui QtNetwork QtCore"
199 BACKGROUND="${LyxAppDir}.app/Contents/Resources/images/banner.png"
201 # Check for existing SDKs
202 SDKs=`echo /Developer/SDKs/MacOSX10*sdk`
205 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.5"}; export MACOSX_DEPLOYMENT_TARGET
206 case "${MACOSX_DEPLOYMENT_TARGET}" in
208 SDKROOT="/Developer/SDKs/MacOSX10.5.sdk"; export SDKROOT
211 SDKROOT="/Developer/SDKs/MacOSX10.4u.sdk"; export SDKROOT
212 CC=gcc-4.0 ; export CC
213 CXX=g++-4.0 ; export CXX
214 OBJC=gcc-4.0 ; export OBJC
219 MACOSX_DEPLOYMENT_TARGET="10.4"; export MACOSX_DEPLOYMENT_TARGET
220 SDKROOT="/Developer/SDKs/MacOSX10.4u.sdk"; export SDKROOT
223 echo Unknown or missing SDK for Mac OS X.
227 MYCFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}"
229 if [ -d "${Qt4SourceDir}" -a ! -d "${Qt4BuildDir}" ]; then
230 echo Build Qt4 library ${Qt4SourceDir}
233 mkdir -p "${Qt4BuildDir}" && cd "${Qt4BuildDir}"
234 for arch in ${ARCH_LIST} ; do
235 ARCHS="${ARCHS} -arch ${arch}"
237 echo configure options:
238 echo ${Qt4ConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
240 echo yes | "${Qt4SourceDir}"/configure ${Qt4ConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
243 cd "${QtInstallDir}" && (
246 for libnm in ${QtLibraries} ; do
247 test -d ${libnm} -o -L ${libnm} || ln -s ../lib/${libnm}.framework/Headers ${libnm}
252 if [ -d "${HunSpellSourceDir}" -a ! -f "${HunSpellInstallHdr}" ]; then
253 # we have a private HunSpell source tree at hand...
254 # so let's build and install it
255 if [ -z "${HunSpellVersion}" ]; then
256 HunSpellVersion=`grep AC_INIT "${HunSpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()"`
259 HunSpellName="Hunspell"
260 HunSpellBase="${HunSpellName}-${HunSpellVersion}"
262 echo Build hunspell library ${HunSpellBase}
263 echo configure options:
264 echo --prefix="${HunSpellInstallDir}" ${HunspellConfigureOptions}
266 cd "${HunSpellSourceDir}"
268 # ----------------------------------------
269 # Build HunSpell for different architectures
270 # ----------------------------------------
271 FILE_LIST="libhunspell-1.2.0.dylib"
273 for arch in ${ARCH_LIST} ; do
275 CPPFLAGS=" -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
276 LDFLAGS=" -arch ${arch}"; export LDFLAGS
277 HOSTSYSTEM=`eval "echo \\$HostSystem_$arch"`
278 "${HunSpellSourceDir}/configure"\
279 --prefix="${HunSpellInstallDir}"\
280 ${HunspellConfigureOptions}
281 #--host="${HOSTSYSTEM}" ${BuildSystem:+"--build=${BuildSystem}"}
282 make && make install${strip}
283 for file in ${FILE_LIST} ; do
284 if [ -f "${HunSpellInstallDir}"/lib/${file} ]; then
285 mv "${HunSpellInstallDir}"/lib/${file}\
286 "${HunSpellInstallDir}"/lib/${file}-${arch}
288 echo Cannot build and install HunSpell for ${arch}.
293 # -------------------------
294 # Create universal binaries
295 # -------------------------
296 for file in ${FILE_LIST} ; do
298 for arch in ${ARCH_LIST} ; do
299 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
302 cd "${HunSpellInstallDir}"
303 lipo -create ${OBJ_LIST} -o lib/${file}
304 # check for the "missing link"...
305 test -f lib/libhunspell.dylib || (cd lib ; ln -s libhunspell-1.2.dylib libhunspell.dylib)
311 for arch in ${ARCH_LIST} ; do
312 rm -f "${HunSpellInstallDir}"/lib/*-${arch}
319 if [ -d "${ASpellSourceDir}" -a ! -f "${ASpellInstallHdr}" -a "yes" = "${aspell_deployment}" ]; then
320 # we have a private ASpell source tree at hand...
321 # so let's build and install it
322 if [ -z "${ASpellVersion}" ]; then
323 ASpellVersion=`grep AC_INIT "${ASpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()"`
327 ASpellBase="${ASpellName}-${ASpellVersion}"
329 echo Build aspell library ${ASpellBase}
330 echo configure options:
331 echo --prefix="${ASpellInstallDir}" ${AspellConfigureOptions}
333 # ASpell builds inplace only :(
334 cd "${ASpellSourceDir}"
336 # ----------------------------------------
337 # Build ASpell for different architectures
338 # ----------------------------------------
339 FILE_LIST="libaspell.15.dylib"
341 for arch in ${ARCH_LIST} ; do
343 CPPFLAGS=" -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
344 LDFLAGS=" -arch ${arch}"; export LDFLAGS
345 HOSTSYSTEM=`eval "echo \\$HostSystem_$arch"`
346 "${ASpellSourceDir}/configure"\
347 --prefix="${ASpellInstallDir}"\
348 ${AspellConfigureOptions}
349 #--host="${HOSTSYSTEM}" ${BuildSystem:+"--build=${BuildSystem}"}
350 make && make install${strip}
351 for file in ${FILE_LIST} ; do
352 if [ -f "${ASpellInstallDir}"/lib/${file} ]; then
353 mv "${ASpellInstallDir}"/lib/${file}\
354 "${ASpellInstallDir}"/lib/${file}-${arch}
356 echo Cannot build and install ASpell for ${arch}.
361 # -------------------------
362 # Create universal binaries
363 # -------------------------
364 for file in ${FILE_LIST} ; do
366 for arch in ${ARCH_LIST} ; do
367 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
370 cd "${ASpellInstallDir}"
371 lipo -create ${OBJ_LIST} -o lib/${file}
377 for arch in ${ARCH_LIST} ; do
378 rm -f "${ASpellInstallDir}"/lib/*-${arch}
383 echo "Frameworks/${1}.framework"
386 if [ ! -f "${LyxSourceDir}"/configure ]; then
387 ( cd "${LyxSourceDir}" && sh autogen.sh )
390 FILE_LIST="lyx lyxclient tex2lyx"
391 BUNDLE_PATH="Contents/MacOS"
392 LYX_BUNDLE_PATH="${LyxAppPrefix}/${BUNDLE_PATH}"
395 if [ -n "${LyxAppZip}" -a -f "${LyxAppZip}" ]; then rm "${LyxAppZip}"; fi
396 if [ -d "${LyxAppPrefix}" ]; then rm -rf "${LyxAppPrefix}"; fi
398 # -------------------------------------
399 # Build LyX for different architectures
400 # -------------------------------------
402 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
403 ASpellFramework=`framework_name Aspell`
404 ASpellFramework=`basename "${ASpellFramework}"`
405 ConfigureExtraInc="--with-extra-inc=${ASpellInstallDir}/include"
406 ConfigureExtraLib="--with-extra-lib=${ASpellInstallDir}/lib"
407 LyXConfigureOptions="${LyXConfigureOptions} --with-aspell-framework=${ASpellFramework}"
410 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
411 HunSpellFramework=`framework_name Hunspell`
412 HunSpellFramework=`basename "${HunSpellFramework}"`
413 ConfigureExtraInc="--with-extra-inc=${HunSpellInstallDir}/include"
414 ConfigureExtraLib="--with-extra-lib=${HunSpellInstallDir}/lib"
415 # LyXConfigureOptions="${LyXConfigureOptions} --with-hunspell-framework=${HunSpellFramework}"
417 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraInc}"
418 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraLib}"
420 for arch in ${ARCH_LIST} ; do
422 if [ -d "${LyxBuildDir}" ]; then rm -r "${LyxBuildDir}"; fi
423 mkdir "${LyxBuildDir}" && cd "${LyxBuildDir}"
425 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
426 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch}"; export LDFLAGS
427 HOSTSYSTEM=`eval "echo \\$HostSystem_$arch"`
429 echo LDFLAGS="${LDFLAGS}"
430 echo CPPFLAGS="${CPPFLAGS}"
431 echo CONFIGURE_OPTIONS="${LyXConfigureOptions}"
432 "${LyxSourceDir}/configure"\
433 --prefix="${LyxAppPrefix}" --with-version-suffix="-${LyXVersion}"\
434 ${QtInstallDir:+"--with-qt4-dir=${QtInstallDir}"} \
435 ${LyXConfigureOptions}\
436 --host="${HOSTSYSTEM}" --build="${BuildSystem}" --enable-build-type=rel
437 make && make install${strip}
438 for file in ${FILE_LIST} ; do
439 if [ -f "${LYX_BUNDLE_PATH}/${file}" ]; then
440 mv "${LYX_BUNDLE_PATH}/${file}"\
441 "${LYX_BUNDLE_PATH}/${file}-${arch}"
443 echo ERROR: Cannot build and install LyX for ${arch}.
450 content_directory() {
452 content=`dirname "${target}"`
453 content=`dirname "${content}"`
457 private_framework() {
458 fwdir=`framework_name "$1"`
461 condir=`content_directory "${target}"`
462 libnm=`basename "${source}"`
463 mkdir -p "${condir}/${fwdir}"
464 if [ ! -f "${condir}/${fwdir}/${libnm}" ]; then
465 cp -p "${source}" "${condir}/${fwdir}"
466 echo Set library id in "${condir}/${fwdir}/${libnm}"
467 install_name_tool -id "@executable_path/../${fwdir}/${libnm}" "${condir}/${fwdir}/${libnm}"
469 echo Correct library id reference to "${libnm}" in "${target}"
470 install_name_tool -change "${source}" "@executable_path/../${fwdir}/${libnm}" "${target}"
474 source="${QtInstallDir}"
476 version="Versions/${QtFrameworkVersion}/"
477 condir=`content_directory "${target}"`
478 mkdir -p "${condir}/Resources"
479 test -f "${condir}/Resources/qt.conf" || cat - > "${condir}/Resources/qt.conf" <<-EOF
483 if [ ! -d "${condir}/PlugIns" ]; then
484 mkdir -p "${condir}/PlugIns"
485 find "${source}/plugins" -name \*.dylib -print | while read libname ; do
486 echo Copy plugin "${libname}"
487 dylib=`basename "${libname}"`
488 dirname=`dirname "${libname}"`
489 dirname=`basename "${dirname}"`
490 mkdir -p "${condir}/PlugIns/${dirname}"
491 cp -p "${libname}" "${condir}/PlugIns/${dirname}"
494 for libnm in ${QtLibraries} ; do
495 fwdir=`framework_name "$libnm"`
496 dirname=`basename "${fwdir}"`
497 test -d "${condir}/${fwdir}" || (
498 echo Copy framework "${source}/lib/"`basename "${fwdir}"`
499 cp -pR "${source}/lib/"`basename "${fwdir}"` "${condir}/${fwdir}"
500 echo Set library id in "${condir}/${fwdir}/${version}${libnm}"
501 install_name_tool -id "@executable_path/../${fwdir}/${version}${libnm}" "${condir}/${fwdir}/${version}${libnm}"
502 find "${condir}/PlugIns" "${condir}/"`dirname "${fwdir}"` -name Headers -prune -o -type f -print | while read filename ; do
503 otool -L "${filename}" 2>/dev/null | while read library ; do
504 # pattern match for: /path/to/qt4/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.6.0, current version 4.6.2)
506 *"${libnm}"*"("*")"*)
507 echo Correct library id reference to "${libnm}" in "${filename}"
508 install_name_tool -change\
509 "${source}/lib/${dirname}/${version}${libnm}"\
510 "@executable_path/../${fwdir}/${version}${libnm}"\
517 echo Correct library id reference to "${libnm}" in "${target}"
518 install_name_tool -change\
519 "${source}/lib/${dirname}/${version}${libnm}"\
520 "@executable_path/../${fwdir}/${version}${libnm}"\
525 # -------------------------
526 # Create universal binaries
527 # -------------------------
528 convert_universal() {
530 for file in ${FILE_LIST} ; do
532 for arch in ${ARCH_LIST} ; do
533 if [ -f "${BUNDLE_PATH}/${file}-${arch}" ]; then
534 OBJ_LIST="${OBJ_LIST} ${BUNDLE_PATH}/${file}-${arch}"
537 if [ -n "${OBJ_LIST}" ]; then
538 lipo -create ${OBJ_LIST} -o "${BUNDLE_PATH}/${file}"
540 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
541 private_framework Aspell "${ASpellInstallDir}/lib/libaspell.15.dylib" "${LYX_BUNDLE_PATH}/${file}"
543 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
544 private_framework Hunspell "${HunSpellInstallDir}/lib/libhunspell-1.2.0.dylib" "${LYX_BUNDLE_PATH}/${file}"
546 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt4_deployment}" ]; then
547 deploy_qtlibs "${LYX_BUNDLE_PATH}/${file}"
549 otool -L "${BUNDLE_PATH}/${file}" | while read reference ; do
550 case "${reference}" in
551 *"${LyxBuildDir}"*"("*")")
552 echo ERROR: Bad reference to "${reference}" found!!
557 for arch in ${ARCH_LIST} ; do
558 rm -f ${BUNDLE_PATH}/*-${arch}
562 copy_dictionaries() {
563 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
564 ASpellFramework=`framework_name Aspell`
565 ASpellResources="${LyxAppPrefix}/Contents/${ASpellFramework}/Resources"
566 # try to reuse macports dictionaries for now
567 if [ -d /opt/local/lib/aspell-0.60 ]; then ASpellInstallDir=/opt/local ; fi
568 mkdir -p "${ASpellResources}"
569 echo Copy Aspell dictionaries from "${ASpellInstallDir}"
570 cp -p -r "${ASpellInstallDir}/lib/aspell-0.60" "${ASpellResources}"/data
571 cp -p -r "${ASpellInstallDir}/share/aspell" "${ASpellResources}"/dict
573 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
574 HunSpellResources="${LyxAppPrefix}/Contents/Resources"
575 if [ -d "${DictionarySourceDir}" ]; then
576 cp -p -r "${DictionarySourceDir}/dict" "${HunSpellResources}"
579 if [ -d "${DictionarySourceDir}" -a "yes" = "${thesaurus_deployment}" ]; then
580 MyThesResources="${LyxAppPrefix}/Contents/Resources"
581 cp -p -r "${DictionarySourceDir}/thes" "${MyThesResources}"
585 function set_bundle_display_options() {
587 tell application "Finder"
588 set f to POSIX file ("${1}" as string) as alias
591 tell container window
592 set toolbar visible to false
593 set statusbar visible to false
594 set current view to icon view
596 set the bounds to {20, 50, $2, $3}
599 set icon size of the icon view options of container window to 64
600 set arrangement of the icon view options of container window to not arranged
601 set position of item "${LyxName}.app" to {100,$4}
602 set position of item "Applications" to {280,$4}
603 set background picture of the icon view options\
604 of container window to file "background.png" of folder "Pictures"
605 set the bounds of the container window to {0, 0, $2, $3}
606 update without registering applications
615 function make_dmg() {
618 BGSIZE=`file "$BACKGROUND" | awk -F , '/PNG/{print $2 }' | tr x ' '`
619 BG_W=`echo ${BGSIZE} | awk '{print $1 }'`
620 BG_H=`echo ${BGSIZE} | awk '{h = $2 + 20 ;print h }'`
621 BG_Y=`echo ${BGSIZE} | awk '{y = $2 - 60 ;print y }'`
623 rm -f "${DMGNAME}.sparseimage" "${DMGNAME}.dmg"
625 hdiutil create -type SPARSE -size ${DMGSIZE:-"250m"} -fs HFS+ -volname "${LyxBase}" "${DMGNAME}"
626 # Unmount currently mounted disk image
627 test -d /Volumes/"${LyxBase}" && umount /Volumes/"${LyxBase}"
629 # Mount the disk image
630 hdiutil attach "${DMGNAME}.sparseimage"
632 # Obtain device information
633 DEVS=$(hdiutil attach "${DMGNAME}.sparseimage" | cut -f 1)
634 DEV=$(echo $DEVS | cut -f 1 -d ' ')
635 VOLUME=$(mount |grep ${DEV} | cut -f 3 -d ' ')
637 # copy in the application bundle
638 cp -Rp "${LyxAppDir}.app" "${VOLUME}/${LyxName}.app"
640 # copy in background image
641 mkdir -p "${VOLUME}/Pictures"
642 cp "${BACKGROUND}" "${VOLUME}/Pictures/background.png"
643 # symlink applications
644 ln -s /Applications/ "${VOLUME}"/Applications
645 set_bundle_display_options "${VOLUME}" ${BG_W} ${BG_H} ${BG_Y}
646 mv "${VOLUME}/Pictures" "${VOLUME}/.Pictures"
648 # Unmount the disk image
649 hdiutil detach ${DEV}
651 # Convert the disk image to read-only
652 hdiutil convert "${DMGNAME}.sparseimage" -format UDBZ -o "${DMGNAME}.dmg"
653 rm -f "${DMGNAME}.sparseimage"
660 # ------------------------------
661 # Building distribution packages
662 # ------------------------------
664 test -n "${LyxAppZip}" && (
665 cd "${LyxAppPrefix}" && zip -r "${LyxAppZip}" .
668 test -n "${DMGLocation}" && (
669 make_dmg "${DMGLocation}"
670 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt4_deployment}" ]; then
671 rm -f "${DMGLocation}/${DMGNAME}+qt4.dmg"
672 mv "${DMGLocation}/${DMGNAME}.dmg" "${DMGLocation}/${DMGNAME}+qt4.dmg"
673 for libnm in ${QtLibraries} ; do
674 fwdir=`framework_name "$libnm"`
675 rm -rf "${LyxAppDir}.app/Contents/${fwdir}"
677 make_dmg "${DMGLocation}"