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: 9 July 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 (per default thesauri only):
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_dictionaries="no"
34 hunspell_dictionaries="no"
36 aspell_deployment="yes"
37 hunspell_deployment="yes"
38 thesaurus_deployment="yes"
42 MACOSX_DEPLOYMENT_TARGET="10.4" # Tiger support is default
45 echo Build script for LyX on Mac OS X
47 echo Optional arguments:
48 echo " --aspell-deployment=yes|no ." default yes
49 echo " --qt4-deployment=yes|no ...." default yes
50 echo " --with-macosx-target=TARGET " default 10.4 "(Tiger)"
51 echo " --with-arch=ARCH ..........." default ppc,i386
52 echo " --with-build-path=PATH ....." default \${lyx-src-dir}/../lyx-build
53 echo " --with-dmg-location=PATH ..." default \${build-path}
55 echo "All other arguments with -- are passed to configure"
56 echo "including the defaults: ${LyXConfigureOptions}"
61 while [ $# -gt 0 ]; do
64 QTDIR=`echo ${1}|cut -d= -f2`
67 --with-macosx-target=*)
68 MACOSX_DEPLOYMENT_TARGET=`echo ${1}|cut -d= -f2`
71 --aspell-deployment=*)
72 aspell_deployment=`echo ${1}|cut -d= -f2`
75 --hunspell-deployment=*)
76 hunspell_deployment=`echo ${1}|cut -d= -f2`
79 --thesaurus-deployment=*)
80 thesaurus_deployment=`echo ${1}|cut -d= -f2`
84 qt4_deployment=`echo ${1}|cut -d= -f2`
88 ARCH=`echo ${1}|cut -d= -f2|tr ',' ' '`
89 ARCH_LIST="${ARCH_LIST} ${ARCH}"
92 --with-dmg-location=*)
93 DMGLocation=`echo ${1}|cut -d= -f2`
97 LyxBuildDir=`echo ${1}|cut -d= -f2`
104 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
105 aspell_deployment="no"
109 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
110 hunspell_deployment="no"
114 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
123 # Set these variables -- to
124 # (1) the location of your Qt4 installation
125 # (2) the location of resulting DMG
126 # (3) the version of private aspell installation
127 # (to define the location assign ASpellSourceDir instead)
128 # (4) the list of architectures to build for
130 QtInstallDir=${QTDIR:-"/opt/qt4"}
131 QtFrameworkVersion="4"
132 ASpellSourceVersion="aspell-0.60.6"
133 HunSpellSourceVersion="hunspell-1.2.9"
134 Qt4SourceVersion=${Qt4SourceVersion:-"qt-everywhere-opensource-src-4.6.2"}
136 ARCH_LIST=${ARCH_LIST:-"ppc i386"}
141 # detection of script home
142 LyxSourceDir=${1:-`dirname "$0"`}
143 if [ ! -d "${LyxSourceDir}" ]; then
144 echo Missing LyX source directory.
147 case "${LyxSourceDir}" in
149 LyxSourceDir=`dirname "${LyxSourceDir}"`
153 */development|development)
154 LyxSourceDir=`dirname "${LyxSourceDir}"`
155 LyxSourceDir=`cd "${LyxSourceDir}";pwd`
158 LyxSourceDir=`cd "${LyxSourceDir}";pwd`
162 LyxBuildDir=${LyxBuildDir:-`dirname "${LyxSourceDir}"`/lyx-build}
163 DMGLocation=${DMGLocation:-"${LyxBuildDir}"}
165 ASpellSourceDir=${ASPELLDIR:-`dirname "${LyxSourceDir}"`/${ASpellSourceVersion}}
166 ASpellInstallDir=${ASpellInstallDir:-"${LyxBuildDir}"/SpellChecker.lib}
167 HunSpellSourceDir=${HUNSPELLDIR:-`dirname "${LyxSourceDir}"`/${HunSpellSourceVersion}}
168 HunSpellInstallDir=${HunSpellInstallDir:-"${LyxBuildDir}"/SpellChecker.lib}
169 Qt4SourceDir=${QT4SOURCEDIR:-`dirname "${LyxSourceDir}"`/${Qt4SourceVersion}}
170 Qt4BuildDir=${Qt4BuildDir:-"${LyxBuildDir}"/${Qt4Build:-"qt4-build"}}
171 DictionarySourceDir=${DICTIONARYDIR:-`dirname "${LyxSourceDir}"`/Dictionaries}
173 ASpellInstallHdr="${ASpellInstallDir}/include/aspell.h"
174 HunSpellInstallHdr="${HunSpellInstallDir}/include/hunspell/hunspell.h"
176 if [ -z "${LyXVersion}" ]; then
177 LyXVersion=`grep AC_INIT "${LyxSourceDir}"/configure.ac | cut -d, -f2 | tr -d " ()"`
181 LyxBase="${LyxName}-${LyXVersion}"
182 LyxApp="${LyxBase}.app"
183 LyxAppDir="${LyxBuildDir}"/"${LyxBase}"
184 LyxBuildDir="${LyxAppDir}.build"
185 LyxAppPrefix="${LyxAppDir}.app"
186 # if zip file is needed... remove the comment sign
187 #LyxAppZip="${LyxAppPrefix}.zip"
189 BuildSystem=`"${LyxSourceDir}/config/config.guess"`
191 # ---------------------------------
192 # DON'T MODIFY ANYTHING BELOW HERE!
193 # ---------------------------------
195 # These variables define the identifiers of the
196 # system (both Intel and PowerPC) to compile for.
197 # (Note: darwin8 is 10.4; darwin9 is 10.5.)
198 # Only change these if necessary
200 HostSystem_i386="i686-apple-darwin8"
201 HostSystem_ppc="powerpc-apple-darwin8"
203 # don't change order here...
204 QtLibraries="QtSvg QtXml QtGui QtNetwork QtCore"
208 BACKGROUND="${LyxAppDir}.app/Contents/Resources/images/banner.png"
210 # Check for existing SDKs
211 SDKs=`echo /Developer/SDKs/MacOSX10*sdk`
214 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.5"}; export MACOSX_DEPLOYMENT_TARGET
215 case "${MACOSX_DEPLOYMENT_TARGET}" in
217 SDKROOT="/Developer/SDKs/MacOSX10.5.sdk"; export SDKROOT
222 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.4"}; export MACOSX_DEPLOYMENT_TARGET
223 SDKROOT="/Developer/SDKs/MacOSX10.5.sdk"; export SDKROOT
226 echo Unknown or missing SDK for Mac OS X.
230 MYCFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}"
232 updateDictionaries() {
233 TMP_DIR="/tmp/lyx-build-$$"
234 mkdir -p "$1"/dict "$1"/thes
235 mkdir -p "$TMP_DIR" && (
236 for pack in "$1"/*.zip ; do
239 cd "$TMP_DIR" && unzip "${pack}" de_DE_comb.zip thes_de_DE_v2.zip
240 cd "$1"/dict && unzip -o "$TMP_DIR"/de_DE_comb.zip
241 cd "$1"/thes && unzip -o "$TMP_DIR"/thes_de_DE_v2.zip
244 cd "$TMP_DIR" && unzip "${pack}" pl_PL.zip thes_pl_PL_v2.zip
245 cd "$1"/dict && unzip -o "$TMP_DIR"/pl_PL.zip
246 cd "$1"/thes && unzip -o "$TMP_DIR"/thes_pl_PL_v2.zip
249 cd "$TMP_DIR" && unzip "${pack}" fr_FR.zip thes_fr_FR_v2.zip
250 cd "$1"/dict && unzip -o "$TMP_DIR"/fr_FR.zip
251 cd "$1"/thes && unzip -o "$TMP_DIR"/thes_fr_FR_v2.zip
254 cd "$TMP_DIR" && unzip "${pack}" es_ES.zip es_MX.zip thes_es_ES_v2.zip
255 cd "$1"/dict && unzip -o "$TMP_DIR"/es_ES.zip
256 cd "$1"/dict && unzip -o "$TMP_DIR"/es_MX.zip
257 cd "$1"/thes && unzip -o "$TMP_DIR"/thes_es_ES_v2.zip
260 cd "$TMP_DIR" && unzip "${pack}" pt_PT.zip
261 cd "$1"/dict && unzip -o "$TMP_DIR"/pt_PT.zip
262 cd "$1"/dict && unzip -o "$1"/pt_BR.zip
263 cd "$1"/thes && unzip -o "$1"/thes_pt_PT_v2.zip
266 cd "$TMP_DIR" && unzip "${pack}" it_IT.zip
267 cd "$1"/dict && unzip -o "$TMP_DIR"/it_IT.zip
268 cd "$1"/thes && unzip -o "$1"/thes_it_IT_v2.zip
271 cd "$TMP_DIR" && unzip "${pack}" ru_RU.zip
272 cd "$1"/dict && unzip -o "$TMP_DIR"/ru_RU.zip
273 cd "$1"/thes && tar xvf "$1"/thes_ru_RU_v2.tar.bz2
276 cd "$TMP_DIR" && unzip "${pack}" en_AU.zip en_CA.zip en_GB.zip en_NZ.zip en_US.zip
277 for zipfile in en_AU.zip en_CA.zip en_GB.zip en_NZ.zip en_US.zip ; do
278 ( cd "$1"/dict && unzip -o "$TMP_DIR/$zipfile" )
280 cd "$1"/thes && unzip -o "$1"/thes_en_US_v2.zip
283 cd "$TMP_DIR" && unzip -l "${pack}" | while read len date time zipfile ; do
287 cd "$TMP_DIR" && unzip -o "${pack}" "$zipfile"
288 cd "$1"/thes && unzip -o "$TMP_DIR"/"$zipfile"
290 [a-z][a-z]_[A-Z][A-Z].zip)
292 cd "$TMP_DIR" && unzip -o "${pack}" "$zipfile"
293 cd "$1"/dict && unzip -o "$TMP_DIR"/"$zipfile"
297 # echo Ignore dictionary package `basename "${pack}"`
305 if [ -d "${Qt4SourceDir}" -a ! -d "${Qt4BuildDir}" ]; then
306 echo Build Qt4 library ${Qt4SourceDir}
309 mkdir -p "${Qt4BuildDir}" && cd "${Qt4BuildDir}"
310 for arch in ${ARCH_LIST} ; do
311 ARCHS="${ARCHS} -arch ${arch}"
313 echo configure options:
314 echo ${Qt4ConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
316 echo yes | "${Qt4SourceDir}"/configure ${Qt4ConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
319 cd "${QtInstallDir}" && (
322 for libnm in ${QtLibraries} ; do
323 test -d ${libnm} -o -L ${libnm} || ln -s ../lib/${libnm}.framework/Headers ${libnm}
328 # updateDictionaries "${DictionarySourceDir}"
331 if [ -d "${HunSpellSourceDir}" -a ! -f "${HunSpellInstallHdr}" ]; then
332 # we have a private HunSpell source tree at hand...
333 # so let's build and install it
334 if [ -z "${HunSpellVersion}" ]; then
335 HunSpellVersion=`grep AC_INIT "${HunSpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()"`
338 HunSpellName="Hunspell"
339 HunSpellBase="${HunSpellName}-${HunSpellVersion}"
341 echo Build hunspell library ${HunSpellBase}
342 echo configure options:
343 echo --prefix="${HunSpellInstallDir}" ${HunspellConfigureOptions}
345 cd "${HunSpellSourceDir}"
347 # ----------------------------------------
348 # Build HunSpell for different architectures
349 # ----------------------------------------
350 FILE_LIST="libhunspell-1.2.0.dylib"
352 for arch in ${ARCH_LIST} ; do
354 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
355 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch}"; export LDFLAGS
356 HOSTSYSTEM=`eval "echo \\$HostSystem_$arch"`
357 "${HunSpellSourceDir}/configure"\
358 --prefix="${HunSpellInstallDir}"\
359 ${HunspellConfigureOptions}
360 #--host="${HOSTSYSTEM}" ${BuildSystem:+"--build=${BuildSystem}"}
361 make && make install${strip}
362 for file in ${FILE_LIST} ; do
363 if [ -f "${HunSpellInstallDir}"/lib/${file} ]; then
364 mv "${HunSpellInstallDir}"/lib/${file}\
365 "${HunSpellInstallDir}"/lib/${file}-${arch}
367 echo Cannot build and install HunSpell for ${arch}.
372 # -------------------------
373 # Create universal binaries
374 # -------------------------
375 for file in ${FILE_LIST} ; do
377 for arch in ${ARCH_LIST} ; do
378 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
381 cd "${HunSpellInstallDir}"
382 lipo -create ${OBJ_LIST} -o lib/${file}
383 # check for the "missing link"...
384 test -f lib/libhunspell.dylib || (cd lib ; ln -s libhunspell-1.2.dylib libhunspell.dylib)
390 for arch in ${ARCH_LIST} ; do
391 rm -f "${HunSpellInstallDir}"/lib/*-${arch}
395 if [ -d "${ASpellSourceDir}" -a ! -f "${ASpellInstallHdr}" -a "yes" = "${aspell_deployment}" ]; then
396 # we have a private ASpell source tree at hand...
397 # so let's build and install it
398 if [ -z "${ASpellVersion}" ]; then
399 ASpellVersion=`grep AC_INIT "${ASpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()"`
403 ASpellBase="${ASpellName}-${ASpellVersion}"
405 echo Build aspell library ${ASpellBase}
406 echo configure options:
407 echo --prefix="${ASpellInstallDir}" ${AspellConfigureOptions}
409 # ASpell builds inplace only :(
410 cd "${ASpellSourceDir}"
412 # ----------------------------------------
413 # Build ASpell for different architectures
414 # ----------------------------------------
415 FILE_LIST="libaspell.15.dylib"
417 for arch in ${ARCH_LIST} ; do
419 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
420 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch}"; export LDFLAGS
421 HOSTSYSTEM=`eval "echo \\$HostSystem_$arch"`
422 CXXFLAGS=-g "${ASpellSourceDir}/configure"\
423 --prefix="${ASpellInstallDir}"\
424 ${AspellConfigureOptions}
425 #--host="${HOSTSYSTEM}" ${BuildSystem:+"--build=${BuildSystem}"}
426 make && make install${aspellstrip}
427 for file in ${FILE_LIST} ; do
428 if [ -f "${ASpellInstallDir}"/lib/${file} ]; then
429 mv "${ASpellInstallDir}"/lib/${file}\
430 "${ASpellInstallDir}"/lib/${file}-${arch}
432 echo Cannot build and install ASpell for ${arch}.
437 # -------------------------
438 # Create universal binaries
439 # -------------------------
440 for file in ${FILE_LIST} ; do
442 for arch in ${ARCH_LIST} ; do
443 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
446 cd "${ASpellInstallDir}"
447 lipo -create ${OBJ_LIST} -o lib/${file}
453 for arch in ${ARCH_LIST} ; do
454 rm -f "${ASpellInstallDir}"/lib/*-${arch}
462 echo "Frameworks/${1}.framework"
465 if [ ! -f "${LyxSourceDir}"/configure -o "${LyxSourceDir}"/configure -ot "${LyxSourceDir}"/configure.ac ]; then
466 ( cd "${LyxSourceDir}" && sh autogen.sh )
469 FILE_LIST="lyx lyxclient tex2lyx"
470 BUNDLE_PATH="Contents/MacOS"
471 LYX_BUNDLE_PATH="${LyxAppPrefix}/${BUNDLE_PATH}"
474 if [ -n "${LyxAppZip}" -a -f "${LyxAppZip}" ]; then rm "${LyxAppZip}"; fi
475 if [ -d "${LyxAppPrefix}" ]; then rm -rf "${LyxAppPrefix}"; fi
477 # -------------------------------------
478 # Build LyX for different architectures
479 # -------------------------------------
481 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
482 ASpellFramework=`framework_name Aspell`
483 ASpellFramework=`basename "${ASpellFramework}"`
484 ConfigureExtraInc="--with-extra-inc=${ASpellInstallDir}/include"
485 ConfigureExtraLib="--with-extra-lib=${ASpellInstallDir}/lib"
486 LyXConfigureOptions="${LyXConfigureOptions} --with-aspell-framework=${ASpellFramework}"
489 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
490 HunSpellFramework=`framework_name Hunspell`
491 HunSpellFramework=`basename "${HunSpellFramework}"`
492 ConfigureExtraInc="--with-extra-inc=${HunSpellInstallDir}/include"
493 ConfigureExtraLib="--with-extra-lib=${HunSpellInstallDir}/lib"
494 # LyXConfigureOptions="${LyXConfigureOptions} --with-hunspell-framework=${HunSpellFramework}"
496 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraInc}"
497 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraLib}"
499 for arch in ${ARCH_LIST} ; do
501 if [ -d "${LyxBuildDir}" ]; then rm -r "${LyxBuildDir}"; fi
502 mkdir "${LyxBuildDir}" && cd "${LyxBuildDir}"
504 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
505 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch}"; export LDFLAGS
506 HOSTSYSTEM=`eval "echo \\$HostSystem_$arch"`
508 echo LDFLAGS="${LDFLAGS}"
509 echo CPPFLAGS="${CPPFLAGS}"
510 echo CONFIGURE_OPTIONS="${LyXConfigureOptions}"
511 "${LyxSourceDir}/configure"\
512 --prefix="${LyxAppPrefix}" --with-version-suffix="-${LyXVersion}"\
513 ${QtInstallDir:+"--with-qt4-dir=${QtInstallDir}"} \
514 ${LyXConfigureOptions}\
515 --host="${HOSTSYSTEM}" --build="${BuildSystem}" --enable-build-type=rel && \
516 make && make install${strip}
517 for file in ${FILE_LIST} ; do
518 if [ -f "${LYX_BUNDLE_PATH}/${file}" ]; then
519 mv "${LYX_BUNDLE_PATH}/${file}"\
520 "${LYX_BUNDLE_PATH}/${file}-${arch}"
522 echo ERROR: Cannot build and install LyX for ${arch}.
529 content_directory() {
531 content=`dirname "${target}"`
532 content=`dirname "${content}"`
536 private_framework() {
537 fwdir=`framework_name "$1"`
540 condir=`content_directory "${target}"`
541 libnm=`basename "${source}"`
542 mkdir -p "${condir}/${fwdir}"
543 if [ ! -f "${condir}/${fwdir}/${libnm}" ]; then
544 cp -p "${source}" "${condir}/${fwdir}"
545 echo Set library id in "${condir}/${fwdir}/${libnm}"
546 install_name_tool -id "@executable_path/../${fwdir}/${libnm}" "${condir}/${fwdir}/${libnm}"
548 echo Correct library id reference to "${libnm}" in "${target}"
549 install_name_tool -change "${source}" "@executable_path/../${fwdir}/${libnm}" "${target}"
553 source="${QtInstallDir}"
555 version="Versions/${QtFrameworkVersion}/"
556 condir=`content_directory "${target}"`
557 mkdir -p "${condir}/Resources"
558 test -f "${condir}/Resources/qt.conf" || cat - > "${condir}/Resources/qt.conf" <<-EOF
562 if [ ! -d "${condir}/PlugIns" ]; then
563 mkdir -p "${condir}/PlugIns"
564 find "${source}/plugins" -name \*.dylib -print | while read libname ; do
565 echo Copy plugin "${libname}"
566 dylib=`basename "${libname}"`
567 dirname=`dirname "${libname}"`
568 dirname=`basename "${dirname}"`
569 mkdir -p "${condir}/PlugIns/${dirname}"
570 cp -p "${libname}" "${condir}/PlugIns/${dirname}"
573 for libnm in ${QtLibraries} ; do
574 fwdir=`framework_name "$libnm"`
575 dirname=`basename "${fwdir}"`
576 test -d "${condir}/${fwdir}" || (
577 echo Copy framework "${source}/lib/"`basename "${fwdir}"`
578 cp -pR "${source}/lib/"`basename "${fwdir}"` "${condir}/${fwdir}"
579 echo Set library id in "${condir}/${fwdir}/${version}${libnm}"
580 install_name_tool -id "@executable_path/../${fwdir}/${version}${libnm}" "${condir}/${fwdir}/${version}${libnm}"
581 find "${condir}/PlugIns" "${condir}/"`dirname "${fwdir}"` -name Headers -prune -o -type f -print | while read filename ; do
582 otool -L "${filename}" 2>/dev/null | while read library ; do
583 # pattern match for: /path/to/qt4/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.6.0, current version 4.6.2)
585 *"${libnm}"*"("*")"*)
586 echo Correct library id reference to "${libnm}" in "${filename}"
587 install_name_tool -change\
588 "${source}/lib/${dirname}/${version}${libnm}"\
589 "@executable_path/../${fwdir}/${version}${libnm}"\
596 echo Correct library id reference to "${libnm}" in "${target}"
597 install_name_tool -change\
598 "${source}/lib/${dirname}/${version}${libnm}"\
599 "@executable_path/../${fwdir}/${version}${libnm}"\
604 # -------------------------
605 # Create universal binaries
606 # -------------------------
607 convert_universal() {
609 for file in ${FILE_LIST} ; do
611 for arch in ${ARCH_LIST} ; do
612 if [ -f "${BUNDLE_PATH}/${file}-${arch}" ]; then
613 OBJ_LIST="${OBJ_LIST} ${BUNDLE_PATH}/${file}-${arch}"
616 if [ -n "${OBJ_LIST}" ]; then
617 lipo -create ${OBJ_LIST} -o "${BUNDLE_PATH}/${file}"
619 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
620 private_framework Aspell "${ASpellInstallDir}/lib/libaspell.15.dylib" "${LYX_BUNDLE_PATH}/${file}"
622 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
623 private_framework Hunspell "${HunSpellInstallDir}/lib/libhunspell-1.2.0.dylib" "${LYX_BUNDLE_PATH}/${file}"
625 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt4_deployment}" ]; then
626 deploy_qtlibs "${LYX_BUNDLE_PATH}/${file}"
628 otool -L "${BUNDLE_PATH}/${file}" | while read reference ; do
629 case "${reference}" in
630 *"${LyxBuildDir}"*"("*")")
631 echo ERROR: Bad reference to "${reference}" found!!
636 for arch in ${ARCH_LIST} ; do
637 rm -f ${BUNDLE_PATH}/*-${arch}
641 copy_dictionaries() {
642 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_dictionaries}" ]; then
643 ASpellResources="${LyxAppPrefix}/Contents/Resources"
644 # try to reuse macports dictionaries for now
645 if [ -d /opt/local/lib/aspell-0.60 ]; then ASpellInstallDir=/opt/local ; fi
646 mkdir -p "${ASpellResources}"
647 echo Copy Aspell dictionaries from "${ASpellInstallDir}"
648 mkdir -p "${ASpellResources}"/data "${ASpellResources}"/dict
649 cp -p -r "${ASpellInstallDir}/lib/aspell-0.60"/* "${ASpellResources}"/data
650 cp -p -r "${ASpellInstallDir}/share/aspell"/* "${ASpellResources}"/dict
652 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_dictionaries}" ]; then
653 HunSpellResources="${LyxAppPrefix}/Contents/Resources"
654 if [ -d "${DictionarySourceDir}" ]; then
655 updateDictionaries "${DictionarySourceDir}"
656 cp -p -r "${DictionarySourceDir}/dict" "${HunSpellResources}"
659 if [ -d "${DictionarySourceDir}" -a "yes" = "${thesaurus_deployment}" ]; then
660 MyThesResources="${LyxAppPrefix}/Contents/Resources"
661 cp -p -r "${DictionarySourceDir}/thes" "${MyThesResources}"
665 function set_bundle_display_options() {
667 tell application "Finder"
668 set f to POSIX file ("${1}" as string) as alias
671 tell container window
672 set toolbar visible to false
673 set statusbar visible to false
674 set current view to icon view
676 set the bounds to {20, 50, $2, $3}
679 set icon size of the icon view options of container window to 64
680 set arrangement of the icon view options of container window to not arranged
681 set position of item "${LyxName}.app" to {100,$4}
682 set position of item "Applications" to {280,$4}
683 set background picture of the icon view options\
684 of container window to file "background.png" of folder "Pictures"
685 set the bounds of the container window to {0, 0, $2, $3}
686 update without registering applications
695 function make_dmg() {
698 BGSIZE=`file "$BACKGROUND" | awk -F , '/PNG/{print $2 }' | tr x ' '`
699 BG_W=`echo ${BGSIZE} | awk '{print $1 }'`
700 BG_H=`echo ${BGSIZE} | awk '{h = $2 + 20 ;print h }'`
701 BG_Y=`echo ${BGSIZE} | awk '{y = $2 - 60 ;print y }'`
703 rm -f "${DMGNAME}.sparseimage" "${DMGNAME}.dmg"
705 hdiutil create -type SPARSE -size ${DMGSIZE:-"250m"} -fs HFS+ -volname "${LyxBase}" "${DMGNAME}"
706 # Unmount currently mounted disk image
707 test -d /Volumes/"${LyxBase}" && umount /Volumes/"${LyxBase}"
709 # Mount the disk image
710 hdiutil attach "${DMGNAME}.sparseimage"
712 # Obtain device information
713 DEVS=$(hdiutil attach "${DMGNAME}.sparseimage" | cut -f 1)
714 DEV=$(echo $DEVS | cut -f 1 -d ' ')
715 VOLUME=$(mount |grep ${DEV} | cut -f 3 -d ' ')
717 # copy in the application bundle
718 cp -Rp "${LyxAppDir}.app" "${VOLUME}/${LyxName}.app"
720 # copy in background image
721 mkdir -p "${VOLUME}/Pictures"
722 cp "${BACKGROUND}" "${VOLUME}/Pictures/background.png"
723 # symlink applications
724 ln -s /Applications/ "${VOLUME}"/Applications
725 set_bundle_display_options "${VOLUME}" ${BG_W} ${BG_H} ${BG_Y}
726 mv "${VOLUME}/Pictures" "${VOLUME}/.Pictures"
728 # Unmount the disk image
729 hdiutil detach ${DEV}
731 # Convert the disk image to read-only
732 hdiutil convert "${DMGNAME}.sparseimage" -format UDBZ -o "${DMGNAME}.dmg"
733 rm -f "${DMGNAME}.sparseimage"
740 # ------------------------------
741 # Building distribution packages
742 # ------------------------------
744 test -n "${LyxAppZip}" && (
745 cd "${LyxAppPrefix}" && zip -r "${LyxAppZip}" .
748 test -n "${DMGLocation}" && (
749 make_dmg "${DMGLocation}"
750 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt4_deployment}" ]; then
751 rm -f "${DMGLocation}/${DMGNAME}+qt4.dmg"
752 mv "${DMGLocation}/${DMGNAME}.dmg" "${DMGLocation}/${DMGNAME}+qt4.dmg"
753 for libnm in ${QtLibraries} ; do
754 fwdir=`framework_name "$libnm"`
755 rm -rf "${LyxAppDir}.app/Contents/${fwdir}"
757 make_dmg "${DMGLocation}"