5 # This script automates creating universal binaries of LyX on Mac.
6 # Author: Bennett Helm (and extended by Konrad Hofbauer)
7 # latest changes by Stephan Witt
8 # Last modified: January 2011
12 Qt4SourceVersion="qt-everywhere-opensource-src-${Qt4Version}"
13 Qt4BuildSubDir="qt-${Qt4Version}-build${CARBON}"
16 # * a decent checkout of LyX sources (probably you have it already)
17 # * Qt4 - build with shared or static libraries for the used platforms (default: i386 and ppc)
18 # or - an unpacked source tree of Qt4 in $QT4SOURCEDIR or in the sibling directory (variable Qt4SourceVersion)
19 # * for aspell support:
20 # the aspell sources placed in a sibling directory (variable ASpellSourceVersion)
21 # * for hunspell support:
22 # the hunspell sources placed in a sibling directory (variable HunSpellSourceVersion)
23 # * for dictionary deployment (per default thesauri only):
24 # - aspell: the dictionary files of macports (in /opt/local/share/aspell and /opt/local/lib/aspell-0.60)
25 # - hunspell: the dictionary files in the sibling directory dictionaries/dicts
26 # - mythes: the data and idx files in the sibling directory dictionaries/thes
28 LyXConfigureOptions="--enable-warnings --enable-optimization=-Os --with-included-gettext --with-x=no"
29 AspellConfigureOptions="--enable-warnings --enable-optimization=-O0 --enable-debug --disable-nls --enable-compile-in-filters --disable-pspell-compatibility"
30 HunspellConfigureOptions="--with-warnings --disable-nls --with-included-gettext --disable-static"
31 Qt4ConfigureOptions="-opensource -silent -shared -release -fast -no-exceptions"
32 Qt4ConfigureOptions="${Qt4ConfigureOptions} -no-webkit -no-qt3support -no-javascript-jit -no-dbus"
33 Qt4ConfigureOptions="${Qt4ConfigureOptions} -nomake examples -nomake demos -nomake docs -nomake tools"
34 #Qt4ConfigureOptions="${Qt4ConfigureOptions} ${CARBON}"
36 aspell_dictionaries="no"
37 hunspell_dictionaries="no"
39 aspell_deployment="yes"
40 hunspell_deployment="yes"
41 thesaurus_deployment="yes"
45 MACOSX_DEPLOYMENT_TARGET="10.4" # Tiger support is default
46 SDKROOT="/Developer/SDKs/MacOSX10.5.sdk" # Leopard build is default
49 echo Build script for LyX on Mac OS X
51 echo Optional arguments:
52 echo " --aspell-deployment=yes|no ." default yes
53 echo " --with-qt4-frameworks=yes|no" default no
54 echo " --qt4-deployment=yes|no ...." default yes
55 echo " --with-macosx-target=TARGET " default 10.4 "(Tiger)"
56 echo " --with-sdkroot=SDKROOT ....." default 10.5 "(Leopard)"
57 echo " --with-arch=ARCH ..........." default ppc,i386
58 echo " --with-build-path=PATH ....." default \${lyx-src-dir}/../lyx-build
59 echo " --with-dmg-location=PATH ..." default \${build-path}
61 echo "All other arguments with -- are passed to configure"
62 echo "including the defaults: ${LyXConfigureOptions}"
67 while [ $# -gt 0 ]; do
69 --with-qt4-frameworks=*)
70 configure_qt4_frameworks=`echo ${1}|cut -d= -f2`
71 if [ "$configure_qt4_frameworks" = "yes" ]; then
78 QTDIR=`echo ${1}|cut -d= -f2`
81 --with-macosx-target=*)
82 MACOSX_DEPLOYMENT_TARGET=`echo ${1}|cut -d= -f2`
86 SDKROOT=`echo ${1}|cut -d= -f2`
89 SDKROOT="/Developer/SDKs/MacOSX10.4u.sdk"
95 SDKROOT="/Developer/SDKs/MacOSX${SDKROOT}.sdk"
103 --aspell-deployment=*)
104 aspell_deployment=`echo ${1}|cut -d= -f2`
105 aspell_dictionaries=$aspell_deployment
108 --hunspell-deployment=*)
109 hunspell_deployment=`echo ${1}|cut -d= -f2`
110 hunspell_dictionaries=$hunspell_deployment
113 --thesaurus-deployment=*)
114 thesaurus_deployment=`echo ${1}|cut -d= -f2`
118 qt4_deployment=`echo ${1}|cut -d= -f2`
122 ARCH=`echo ${1}|cut -d= -f2|tr ',' ' '`
123 ARCH_LIST="${ARCH_LIST} ${ARCH}"
126 --with-dmg-location=*)
127 DMGLocation=`echo ${1}|cut -d= -f2`
131 LyxBuildDir=`echo ${1}|cut -d= -f2`
138 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
139 aspell_deployment="no"
143 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
144 hunspell_deployment="no"
148 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
157 if [ "${configure_qt4_frameworks}" != "yes" ]; then
158 QtInstallDir=${QTDIR:-"/opt/qt4"}
160 QtFrameworkVersion="4"
161 ASpellSourceVersion="aspell-0.60.6"
162 HunSpellSourceVersion="hunspell-1.2.12"
164 ARCH_LIST=${ARCH_LIST:-"ppc i386"}
169 # detection of script home
170 LyxSourceDir=${1:-`dirname "$0"`}
171 if [ ! -d "${LyxSourceDir}" ]; then
172 echo Missing LyX source directory.
175 case "${LyxSourceDir}" in
177 LyxSourceDir=`dirname "${LyxSourceDir}"`
181 */development|development)
182 LyxSourceDir=`dirname "${LyxSourceDir}"`
183 LyxSourceDir=`cd "${LyxSourceDir}";pwd`
186 LyxSourceDir=`cd "${LyxSourceDir}";pwd`
190 LyxBuildDir=${LyxBuildDir:-`dirname "${LyxSourceDir}"`/lyx-build}
191 DMGLocation=${DMGLocation:-"${LyxBuildDir}"}
193 ASpellSourceDir=${ASPELLDIR:-`dirname "${LyxSourceDir}"`/${ASpellSourceVersion}}
194 ASpellInstallDir=${ASpellInstallDir:-"${LyxBuildDir}"/SpellChecker.lib}
195 HunSpellSourceDir=${HUNSPELLDIR:-`dirname "${LyxSourceDir}"`/${HunSpellSourceVersion}}
196 HunSpellInstallDir=${HunSpellInstallDir:-"${LyxBuildDir}"/SpellChecker.lib}
197 Qt4SourceDir=${QT4SOURCEDIR:-`dirname "${LyxSourceDir}"`/${Qt4SourceVersion}}
198 Qt4BuildDir=${Qt4BuildDir:-"${LyxBuildDir}"/${Qt4BuildSubDir:-"qt4-build"}}
199 DictionarySourceDir=${DICTIONARYDIR:-`dirname "${LyxSourceDir}"`/dictionaries}
201 ASpellInstallHdr="${ASpellInstallDir}/include/aspell.h"
202 HunSpellInstallHdr="${HunSpellInstallDir}/include/hunspell/hunspell.h"
204 if [ -z "${LyXVersion}" ]; then
205 LyXVersion=`grep AC_INIT "${LyxSourceDir}"/configure.ac | cut -d, -f2 | tr -d " ()"`
207 LyXVersionSuffix=${LyXVersionSuffix:-`echo "${LyXVersion}" | cut -d. -f1-2`}
210 LyxBase="${LyxName}-${LyXVersion}"
211 LyxApp="${LyxBase}.app"
212 LyxAppDir="${LyxBuildDir}"/"${LyxBase}"
213 LyxBuildDir="${LyxAppDir}.build"
214 LyxAppPrefix="${LyxAppDir}.app"
215 # if zip file is needed... remove the comment sign
216 #LyxAppZip="${LyxAppPrefix}.zip"
218 BuildSystem=`"${LyxSourceDir}/config/config.guess"`
220 # ---------------------------------
221 # DON'T MODIFY ANYTHING BELOW HERE!
222 # ---------------------------------
224 # don't change order here...
225 QtLibraries="QtSvg QtXml QtGui QtNetwork QtCore"
229 BACKGROUND="${LyxAppDir}.app/Contents/Resources/images/banner.png"
231 # Check for existing SDKs
232 SDKs=`echo /Developer/SDKs/MacOSX10*sdk`
237 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.5"}; export MACOSX_DEPLOYMENT_TARGET
238 case "${MACOSX_DEPLOYMENT_TARGET}" in
240 SDKROOT="/Developer/SDKs/MacOSX10.6.sdk"; export SDKROOT
243 SDKROOT=${SDKROOT:-"/Developer/SDKs/MacOSX10.5.sdk"}; export SDKROOT
248 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.4"}; export MACOSX_DEPLOYMENT_TARGET
249 SDKROOT=${SDKROOT:-"/Developer/SDKs/MacOSX10.5.sdk"}; export SDKROOT
252 echo Unknown or missing SDK for Mac OS X.
256 MYCFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}"
258 # These variables define the identifiers of the
259 # system (both Intel and PowerPC) to compile for.
260 # (Note: darwin8 is 10.4; darwin9 is 10.5.)
261 # Only change these if necessary
263 HostSystem_i386="i686-apple-darwin8"
264 HostSystem_ppc="powerpc-apple-darwin8"
266 if [ "${configure_qt4_frameworks}" != "yes" -a -d "${Qt4SourceDir}" -a ! \( -d "${Qt4BuildDir}" -a -d "${QtInstallDir}" \) ]; then
267 echo Build Qt4 library ${Qt4SourceDir}
268 if [ "${QtInstallDir}" = "${Qt4BuildDir}" ]; then
269 echo Bad install directory for Qt.
270 echo Must be different from build directory "${Qt4BuildDir}".
274 mkdir -p "${Qt4BuildDir}" && cd "${Qt4BuildDir}"
275 for arch in ${ARCH_LIST} ; do
276 ARCHS="${ARCHS} -arch ${arch}"
278 echo configure options:
279 echo ${Qt4ConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
280 echo yes | "${Qt4SourceDir}"/configure ${Qt4ConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
283 cd "${QtInstallDir}" && (
286 for libnm in ${QtLibraries} ; do
287 test -d ${libnm} -o -L ${libnm} || ln -s ../lib/${libnm}.framework/Headers ${libnm}
292 if [ -d "${HunSpellSourceDir}" -a ! -f "${HunSpellInstallHdr}" ]; then
293 # we have a private HunSpell source tree at hand...
294 # so let's build and install it
295 if [ -z "${HunSpellVersion}" ]; then
296 HunSpellVersion=`grep AC_INIT "${HunSpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()"`
299 HunSpellName="Hunspell"
300 HunSpellBase="${HunSpellName}-${HunSpellVersion}"
302 echo Build hunspell library ${HunSpellBase}
303 echo configure options:
304 echo --prefix="${HunSpellInstallDir}" ${HunspellConfigureOptions}
306 cd "${HunSpellSourceDir}"
308 # ----------------------------------------
309 # Build HunSpell for different architectures
310 # ----------------------------------------
311 FILE_LIST="libhunspell-1.2.0.dylib"
313 for arch in ${ARCH_LIST} ; do
315 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
316 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
317 HOSTSYSTEM=`eval "echo \\$HostSystem_$arch"`
318 "${HunSpellSourceDir}/configure"\
319 --prefix="${HunSpellInstallDir}"\
320 ${HunspellConfigureOptions}
321 #--host="${HOSTSYSTEM}" ${BuildSystem:+"--build=${BuildSystem}"}
322 make && make install${strip}
323 for file in ${FILE_LIST} ; do
324 if [ -f "${HunSpellInstallDir}"/lib/${file} ]; then
325 mv "${HunSpellInstallDir}"/lib/${file}\
326 "${HunSpellInstallDir}"/lib/${file}-${arch}
328 echo Cannot build and install HunSpell for ${arch}.
333 # -------------------------
334 # Create universal binaries
335 # -------------------------
336 for file in ${FILE_LIST} ; do
338 for arch in ${ARCH_LIST} ; do
339 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
342 cd "${HunSpellInstallDir}"
343 lipo -create ${OBJ_LIST} -o lib/${file}
344 # check for the "missing link"...
345 test -f lib/libhunspell.dylib || (cd lib ; ln -s libhunspell-1.2.dylib libhunspell.dylib)
351 for arch in ${ARCH_LIST} ; do
352 rm -f "${HunSpellInstallDir}"/lib/*-${arch}
356 if [ -d "${ASpellSourceDir}" -a ! -f "${ASpellInstallHdr}" -a "yes" = "${aspell_deployment}" ]; then
357 # we have a private ASpell source tree at hand...
358 # so let's build and install it
359 if [ -z "${ASpellVersion}" ]; then
360 ASpellVersion=`grep AC_INIT "${ASpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()"`
364 ASpellBase="${ASpellName}-${ASpellVersion}"
366 echo Build aspell library ${ASpellBase}
367 echo configure options:
368 echo --prefix="${ASpellInstallDir}" ${AspellConfigureOptions}
370 # ASpell builds inplace only :(
371 cd "${ASpellSourceDir}"
373 # ----------------------------------------
374 # Build ASpell for different architectures
375 # ----------------------------------------
376 FILE_LIST="libaspell.15.dylib"
378 for arch in ${ARCH_LIST} ; do
380 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
381 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
382 HOSTSYSTEM=`eval "echo \\$HostSystem_$arch"`
383 CXXFLAGS=-g "${ASpellSourceDir}/configure"\
384 --prefix="${ASpellInstallDir}"\
385 ${AspellConfigureOptions}
386 #--host="${HOSTSYSTEM}" ${BuildSystem:+"--build=${BuildSystem}"}
387 make && make install${aspellstrip}
388 for file in ${FILE_LIST} ; do
389 if [ -f "${ASpellInstallDir}"/lib/${file} ]; then
390 mv "${ASpellInstallDir}"/lib/${file}\
391 "${ASpellInstallDir}"/lib/${file}-${arch}
393 echo Cannot build and install ASpell for ${arch}.
398 # -------------------------
399 # Create universal binaries
400 # -------------------------
401 for file in ${FILE_LIST} ; do
403 for arch in ${ARCH_LIST} ; do
404 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
407 cd "${ASpellInstallDir}"
408 lipo -create ${OBJ_LIST} -o lib/${file}
414 for arch in ${ARCH_LIST} ; do
415 rm -f "${ASpellInstallDir}"/lib/*-${arch}
423 echo "Frameworks/${1}.framework"
426 if [ ! -f "${LyxSourceDir}"/configure -o "${LyxSourceDir}"/configure -ot "${LyxSourceDir}"/configure.ac ]; then
427 ( cd "${LyxSourceDir}" && sh autogen.sh )
429 find "${LyxSourceDir}" -name Makefile.am -print | while read file ; do
430 dname=`dirname "$file"`
431 if [ "$dname/Makefile.in" -ot "$file" ]; then
432 ( cd "${LyxSourceDir}" && sh autogen.sh )
438 FILE_LIST="lyx lyxclient tex2lyx"
439 BUNDLE_PATH="Contents/MacOS"
440 LYX_BUNDLE_PATH="${LyxAppPrefix}/${BUNDLE_PATH}"
443 if [ -n "${LyxAppZip}" -a -f "${LyxAppZip}" ]; then rm "${LyxAppZip}"; fi
444 if [ -d "${LyxAppPrefix}" ]; then rm -rf "${LyxAppPrefix}"; fi
446 # -------------------------------------
447 # Build LyX for different architectures
448 # -------------------------------------
450 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
451 ConfigureExtraInc="--with-extra-inc=${ASpellInstallDir}/include"
452 ConfigureExtraLib="--with-extra-lib=${ASpellInstallDir}/lib"
455 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
456 HunSpellFramework=`framework_name Hunspell`
457 HunSpellFramework=`basename "${HunSpellFramework}"`
458 ConfigureExtraInc="--with-extra-inc=${HunSpellInstallDir}/include"
459 ConfigureExtraLib="--with-extra-lib=${HunSpellInstallDir}/lib"
460 # LyXConfigureOptions="${LyXConfigureOptions} --with-hunspell-framework=${HunSpellFramework}"
462 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraInc}"
463 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraLib}"
465 for arch in ${ARCH_LIST} ; do
467 if [ -d "${LyxBuildDir}" ]; then rm -r "${LyxBuildDir}"; fi
468 mkdir -p "${LyxBuildDir}" && cd "${LyxBuildDir}"
470 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"
471 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"
472 HOSTSYSTEM=`eval "echo \\$HostSystem_$arch"`
474 if [ "$configure_qt4_frameworks" = "yes" ]; then
475 export QT4_CORE_CFLAGS="-FQtCore"
476 export QT4_CORE_LIBS="-framework QtCore"
477 export QT4_FRONTEND_CFLAGS="-FQtGui"
478 export QT4_FRONTEND_LIBS="-framework QtGui"
480 CPPFLAGS="${CPPFLAGS} -I${SDKROOT}/Library/Frameworks/QtCore.framework/Headers"
481 CPPFLAGS="${CPPFLAGS} -I${SDKROOT}/Library/Frameworks/QtGui.framework/Headers"
483 LDFLAGS="${LDFLAGS}"${CARBON:+" -framework Carbon"}
484 LDFLAGS="${LDFLAGS} -framework AppKit"
486 echo LDFLAGS="${LDFLAGS}"
488 echo CPPFLAGS="${CPPFLAGS}"
490 echo CONFIGURE_OPTIONS="${LyXConfigureOptions}" ${QtInstallDir:+"--with-qt4-dir=${QtInstallDir}"}
491 "${LyxSourceDir}/configure"\
492 --prefix="${LyxAppPrefix}" --with-version-suffix="-${LyXVersionSuffix}"\
493 ${QtInstallDir:+"--with-qt4-dir=${QtInstallDir}"} \
494 ${LyXConfigureOptions}\
495 --host="${HOSTSYSTEM}" --build="${BuildSystem}" --enable-build-type=rel && \
496 make -j2 && make install${strip}
497 for file in ${FILE_LIST} ; do
498 if [ -f "${LYX_BUNDLE_PATH}/${file}" ]; then
499 mv "${LYX_BUNDLE_PATH}/${file}"\
500 "${LYX_BUNDLE_PATH}/${file}-${arch}"
502 echo ERROR: Cannot build and install LyX for ${arch}.
509 content_directory() {
511 content=`dirname "${target}"`
512 content=`dirname "${content}"`
516 private_framework() {
517 fwdir=`framework_name "$1"`
520 condir=`content_directory "${target}"`
521 libnm=`basename "${source}"`
522 mkdir -p "${condir}/${fwdir}"
523 if [ ! -f "${condir}/${fwdir}/${libnm}" ]; then
524 cp -p "${source}" "${condir}/${fwdir}"
525 echo Set library id in "${condir}/${fwdir}/${libnm}"
526 install_name_tool -id "@executable_path/../${fwdir}/${libnm}" "${condir}/${fwdir}/${libnm}"
528 echo Correct library id reference to "${libnm}" in "${target}"
529 install_name_tool -change "${source}" "@executable_path/../${fwdir}/${libnm}" "${target}"
533 source="${QtInstallDir}"
535 version="Versions/${QtFrameworkVersion}/"
536 condir=`content_directory "${target}"`
537 mkdir -p "${condir}/Resources"
538 test -f "${condir}/Resources/qt.conf" || cat - > "${condir}/Resources/qt.conf" <<-EOF
542 if [ ! -d "${condir}/PlugIns" ]; then
543 mkdir -p "${condir}/PlugIns"
544 find "${source}/plugins" -name \*.dylib -print | while read libname ; do
545 echo Copy plugin "${libname}"
546 dylib=`basename "${libname}"`
547 dirname=`dirname "${libname}"`
548 dirname=`basename "${dirname}"`
549 mkdir -p "${condir}/PlugIns/${dirname}"
550 cp -p "${libname}" "${condir}/PlugIns/${dirname}"
553 for libnm in ${QtLibraries} ; do
554 fwdir=`framework_name "$libnm"`
555 dirname=`dirname "${fwdir}"`
556 mkdir -p "${condir}/${dirname}"
557 dirname=`basename "${fwdir}"`
558 test -d "${condir}/${fwdir}" || (
559 echo Copy framework "${source}/lib/"`basename "${fwdir}"`
560 cp -pR "${source}/lib/"`basename "${fwdir}"` "${condir}/${fwdir}"
561 echo Set library id in "${condir}/${fwdir}/${version}${libnm}"
562 install_name_tool -id "@executable_path/../${fwdir}/${version}${libnm}" "${condir}/${fwdir}/${version}${libnm}"
563 find "${condir}/PlugIns" "${condir}/"`dirname "${fwdir}"` -name Headers -prune -o -type f -print | while read filename ; do
564 otool -L "${filename}" 2>/dev/null | while read library ; do
565 # pattern match for: /path/to/qt4/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.6.0, current version 4.6.2)
567 *"${libnm}"*"("*")"*)
568 echo Correct library id reference to "${libnm}" in "${filename}"
569 install_name_tool -change\
570 "${source}/lib/${dirname}/${version}${libnm}"\
571 "@executable_path/../${fwdir}/${version}${libnm}"\
578 echo Correct library id reference to "${libnm}" in "${target}"
579 install_name_tool -change\
580 "${source}/lib/${dirname}/${version}${libnm}"\
581 "@executable_path/../${fwdir}/${version}${libnm}"\
586 # -------------------------
587 # Create universal binaries
588 # -------------------------
589 convert_universal() {
591 for file in ${FILE_LIST} ; do
593 for arch in ${ARCH_LIST} ; do
594 if [ -f "${BUNDLE_PATH}/${file}-${arch}" ]; then
595 OBJ_LIST="${OBJ_LIST} ${BUNDLE_PATH}/${file}-${arch}"
598 if [ -n "${OBJ_LIST}" ]; then
599 lipo -create ${OBJ_LIST} -o "${BUNDLE_PATH}/${file}"
601 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
602 private_framework Aspell "${ASpellInstallDir}/lib/libaspell.15.dylib" "${LYX_BUNDLE_PATH}/${file}"
604 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
605 private_framework Hunspell "${HunSpellInstallDir}/lib/libhunspell-1.2.0.dylib" "${LYX_BUNDLE_PATH}/${file}"
607 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt4_deployment}" ]; then
608 deploy_qtlibs "${LYX_BUNDLE_PATH}/${file}"
610 otool -L "${BUNDLE_PATH}/${file}" | while read reference ; do
611 case "${reference}" in
612 *"${LyxBuildDir}"*"("*")")
613 echo ERROR: Bad reference to "${reference}" found!!
618 for arch in ${ARCH_LIST} ; do
619 rm -f ${BUNDLE_PATH}/*-${arch}
623 copy_dictionaries() {
624 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_dictionaries}" ]; then
625 ASpellResources="${LyxAppPrefix}/Contents/Resources"
626 # try to reuse macports dictionaries for now
627 if [ -d /opt/local/lib/aspell-0.60 ]; then ASpellInstallDir=/opt/local ; fi
628 mkdir -p "${ASpellResources}"
629 echo Copy Aspell dictionaries from "${ASpellInstallDir}"
630 mkdir -p "${ASpellResources}"/data "${ASpellResources}"/dicts
631 cp -p -r "${ASpellInstallDir}/lib/aspell-0.60"/* "${ASpellResources}"/data
632 cp -p -r "${ASpellInstallDir}/share/aspell"/* "${ASpellResources}"/dicts
634 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_dictionaries}" ]; then
635 HunSpellResources="${LyxAppPrefix}/Contents/Resources"
636 if [ -d "${DictionarySourceDir}" ]; then
637 ( cd "${DictionarySourceDir}" && find dicts -name .svn -prune -o -type f -print | cpio -pmdv "${HunSpellResources}" )
640 if [ -d "${DictionarySourceDir}" -a "yes" = "${thesaurus_deployment}" ]; then
641 MyThesResources="${LyxAppPrefix}/Contents/Resources"
642 ( cd "${DictionarySourceDir}" && find thes -name .svn -prune -o -type f -print | cpio -pmdv "${MyThesResources}" )
646 function set_bundle_display_options() {
648 tell application "Finder"
649 set f to POSIX file ("${1}" as string) as alias
652 tell container window
653 set toolbar visible to false
654 set statusbar visible to false
655 set current view to icon view
657 set the bounds to {20, 50, $2, $3}
660 set icon size of the icon view options of container window to 64
661 set arrangement of the icon view options of container window to not arranged
662 set position of item "${LyxName}.app" to {100,$4}
663 set position of item "Applications" to {280,$4}
664 set background picture of the icon view options\
665 of container window to file "background.png" of folder "Pictures"
666 set the bounds of the container window to {0, 0, $2, $3}
667 update without registering applications
676 function make_dmg() {
679 BGSIZE=`file "$BACKGROUND" | awk -F , '/PNG/{print $2 }' | tr x ' '`
680 BG_W=`echo ${BGSIZE} | awk '{print $1 }'`
681 BG_H=`echo ${BGSIZE} | awk '{h = $2 + 20 ;print h }'`
682 BG_Y=`echo ${BGSIZE} | awk '{y = $2 - 60 ;print y }'`
684 rm -f "${DMGNAME}.sparseimage" "${DMGNAME}.dmg"
686 hdiutil create -type SPARSE -size ${DMGSIZE:-"250m"} -fs HFS+ -volname "${LyxBase}" "${DMGNAME}"
687 # Unmount currently mounted disk image
688 test -d /Volumes/"${LyxBase}" && umount /Volumes/"${LyxBase}"
690 # Mount the disk image
691 hdiutil attach "${DMGNAME}.sparseimage"
693 # Obtain device information
694 DEVS=$(hdiutil attach "${DMGNAME}.sparseimage" | cut -f 1)
695 DEV=$(echo $DEVS | cut -f 1 -d ' ')
696 VOLUME=$(mount |grep ${DEV} | cut -f 3 -d ' ')
698 # copy in the application bundle
699 cp -Rp "${LyxAppDir}.app" "${VOLUME}/${LyxName}.app"
701 # copy in background image
702 mkdir -p "${VOLUME}/Pictures"
703 cp "${BACKGROUND}" "${VOLUME}/Pictures/background.png"
704 # symlink applications
705 ln -s /Applications/ "${VOLUME}"/Applications
706 set_bundle_display_options "${VOLUME}" ${BG_W} ${BG_H} ${BG_Y}
707 mv "${VOLUME}/Pictures" "${VOLUME}/.Pictures"
709 # Unmount the disk image
710 hdiutil detach ${DEV}
712 # Convert the disk image to read-only
713 hdiutil convert "${DMGNAME}.sparseimage" -format UDBZ -o "${DMGNAME}.dmg"
714 rm -f "${DMGNAME}.sparseimage"
721 # ------------------------------
722 # Building distribution packages
723 # ------------------------------
725 test -n "${LyxAppZip}" && (
726 cd "${LyxAppPrefix}" && zip -r "${LyxAppZip}" .
729 test -n "${DMGLocation}" && (
730 make_dmg "${DMGLocation}"
731 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt4_deployment}" ]; then
732 rm -f "${DMGLocation}/${DMGNAME}+qt4.dmg"
733 echo move to "${DMGLocation}/${DMGNAME}+qt4.dmg"
734 mv "${DMGLocation}/${DMGNAME}.dmg" "${DMGLocation}/${DMGNAME}+qt4.dmg"
735 #for libnm in ${QtLibraries} ; do
736 # fwdir=`framework_name "$libnm"`
737 # rm -rf "${LyxAppDir}.app/Contents/${fwdir}"
739 #make_dmg "${DMGLocation}"