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 case "${MACOSX_DEPLOYMENT_TARGET}" in
233 MYCFLAGS="-DLYX_PLATFORM_DARWIN10=4"
236 MYCFLAGS="-DLYX_PLATFORM_DARWIN10=5"
239 MYCFLAGS="-DLYX_PLATFORM_DARWIN10=6"
242 MYCFLAGS="$MYCFLAGS -mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}"
244 updateDictionaries() {
245 TMP_DIR="/tmp/lyx-build-$$"
246 mkdir -p "$1"/dict "$1"/thes
247 mkdir -p "$TMP_DIR" && (
248 for pack in "$1"/*.zip ; do
251 cd "$TMP_DIR" && unzip "${pack}" de_DE_comb.zip thes_de_DE_v2.zip
252 cd "$1"/dict && unzip -o "$TMP_DIR"/de_DE_comb.zip
253 cd "$1"/thes && unzip -o "$TMP_DIR"/thes_de_DE_v2.zip
256 cd "$TMP_DIR" && unzip "${pack}" pl_PL.zip thes_pl_PL_v2.zip
257 cd "$1"/dict && unzip -o "$TMP_DIR"/pl_PL.zip
258 cd "$1"/thes && unzip -o "$TMP_DIR"/thes_pl_PL_v2.zip
261 cd "$TMP_DIR" && unzip "${pack}" fr_FR.zip thes_fr_FR_v2.zip
262 cd "$1"/dict && unzip -o "$TMP_DIR"/fr_FR.zip
263 cd "$1"/thes && unzip -o "$TMP_DIR"/thes_fr_FR_v2.zip
266 cd "$TMP_DIR" && unzip "${pack}" es_ES.zip es_MX.zip thes_es_ES_v2.zip
267 cd "$1"/dict && unzip -o "$TMP_DIR"/es_ES.zip
268 cd "$1"/dict && unzip -o "$TMP_DIR"/es_MX.zip
269 cd "$1"/thes && unzip -o "$TMP_DIR"/thes_es_ES_v2.zip
272 cd "$TMP_DIR" && unzip "${pack}" pt_PT.zip
273 cd "$1"/dict && unzip -o "$TMP_DIR"/pt_PT.zip
274 cd "$1"/dict && unzip -o "$1"/pt_BR.zip
275 cd "$1"/thes && unzip -o "$1"/thes_pt_PT_v2.zip
278 cd "$TMP_DIR" && unzip "${pack}" it_IT.zip
279 cd "$1"/dict && unzip -o "$TMP_DIR"/it_IT.zip
280 cd "$1"/thes && unzip -o "$1"/thes_it_IT_v2.zip
283 cd "$TMP_DIR" && unzip "${pack}" ru_RU.zip
284 cd "$1"/dict && unzip -o "$TMP_DIR"/ru_RU.zip
285 cd "$1"/thes && tar xvf "$1"/thes_ru_RU_v2.tar.bz2
288 cd "$TMP_DIR" && unzip "${pack}" en_AU.zip en_CA.zip en_GB.zip en_NZ.zip en_US.zip
289 for zipfile in en_AU.zip en_CA.zip en_GB.zip en_NZ.zip en_US.zip ; do
290 ( cd "$1"/dict && unzip -o "$TMP_DIR/$zipfile" )
292 cd "$1"/thes && unzip -o "$1"/thes_en_US_v2.zip
295 cd "$TMP_DIR" && unzip -l "${pack}" | while read len date time zipfile ; do
299 cd "$TMP_DIR" && unzip -o "${pack}" "$zipfile"
300 cd "$1"/thes && unzip -o "$TMP_DIR"/"$zipfile"
302 [a-z][a-z]_[A-Z][A-Z].zip)
304 cd "$TMP_DIR" && unzip -o "${pack}" "$zipfile"
305 cd "$1"/dict && unzip -o "$TMP_DIR"/"$zipfile"
309 # echo Ignore dictionary package `basename "${pack}"`
317 if [ -d "${Qt4SourceDir}" -a ! -d "${Qt4BuildDir}" ]; then
318 echo Build Qt4 library ${Qt4SourceDir}
321 mkdir -p "${Qt4BuildDir}" && cd "${Qt4BuildDir}"
322 for arch in ${ARCH_LIST} ; do
323 ARCHS="${ARCHS} -arch ${arch}"
325 echo configure options:
326 echo ${Qt4ConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
328 echo yes | "${Qt4SourceDir}"/configure ${Qt4ConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
331 cd "${QtInstallDir}" && (
334 for libnm in ${QtLibraries} ; do
335 test -d ${libnm} -o -L ${libnm} || ln -s ../lib/${libnm}.framework/Headers ${libnm}
340 # updateDictionaries "${DictionarySourceDir}"
343 if [ -d "${HunSpellSourceDir}" -a ! -f "${HunSpellInstallHdr}" ]; then
344 # we have a private HunSpell source tree at hand...
345 # so let's build and install it
346 if [ -z "${HunSpellVersion}" ]; then
347 HunSpellVersion=`grep AC_INIT "${HunSpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()"`
350 HunSpellName="Hunspell"
351 HunSpellBase="${HunSpellName}-${HunSpellVersion}"
353 echo Build hunspell library ${HunSpellBase}
354 echo configure options:
355 echo --prefix="${HunSpellInstallDir}" ${HunspellConfigureOptions}
357 cd "${HunSpellSourceDir}"
359 # ----------------------------------------
360 # Build HunSpell for different architectures
361 # ----------------------------------------
362 FILE_LIST="libhunspell-1.2.0.dylib"
364 for arch in ${ARCH_LIST} ; do
366 CPPFLAGS=" -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
367 LDFLAGS=" -arch ${arch}"; export LDFLAGS
368 HOSTSYSTEM=`eval "echo \\$HostSystem_$arch"`
369 "${HunSpellSourceDir}/configure"\
370 --prefix="${HunSpellInstallDir}"\
371 ${HunspellConfigureOptions}
372 #--host="${HOSTSYSTEM}" ${BuildSystem:+"--build=${BuildSystem}"}
373 make && make install${strip}
374 for file in ${FILE_LIST} ; do
375 if [ -f "${HunSpellInstallDir}"/lib/${file} ]; then
376 mv "${HunSpellInstallDir}"/lib/${file}\
377 "${HunSpellInstallDir}"/lib/${file}-${arch}
379 echo Cannot build and install HunSpell for ${arch}.
384 # -------------------------
385 # Create universal binaries
386 # -------------------------
387 for file in ${FILE_LIST} ; do
389 for arch in ${ARCH_LIST} ; do
390 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
393 cd "${HunSpellInstallDir}"
394 lipo -create ${OBJ_LIST} -o lib/${file}
395 # check for the "missing link"...
396 test -f lib/libhunspell.dylib || (cd lib ; ln -s libhunspell-1.2.dylib libhunspell.dylib)
402 for arch in ${ARCH_LIST} ; do
403 rm -f "${HunSpellInstallDir}"/lib/*-${arch}
407 if [ -d "${ASpellSourceDir}" -a ! -f "${ASpellInstallHdr}" -a "yes" = "${aspell_deployment}" ]; then
408 # we have a private ASpell source tree at hand...
409 # so let's build and install it
410 if [ -z "${ASpellVersion}" ]; then
411 ASpellVersion=`grep AC_INIT "${ASpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()"`
415 ASpellBase="${ASpellName}-${ASpellVersion}"
417 echo Build aspell library ${ASpellBase}
418 echo configure options:
419 echo --prefix="${ASpellInstallDir}" ${AspellConfigureOptions}
421 # ASpell builds inplace only :(
422 cd "${ASpellSourceDir}"
424 # ----------------------------------------
425 # Build ASpell for different architectures
426 # ----------------------------------------
427 FILE_LIST="libaspell.15.dylib"
429 for arch in ${ARCH_LIST} ; do
431 CPPFLAGS=" -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
432 LDFLAGS=" -arch ${arch}"; export LDFLAGS
433 HOSTSYSTEM=`eval "echo \\$HostSystem_$arch"`
434 CXXFLAGS=-g "${ASpellSourceDir}/configure"\
435 --prefix="${ASpellInstallDir}"\
436 ${AspellConfigureOptions}
437 #--host="${HOSTSYSTEM}" ${BuildSystem:+"--build=${BuildSystem}"}
438 make && make install${aspellstrip}
439 for file in ${FILE_LIST} ; do
440 if [ -f "${ASpellInstallDir}"/lib/${file} ]; then
441 mv "${ASpellInstallDir}"/lib/${file}\
442 "${ASpellInstallDir}"/lib/${file}-${arch}
444 echo Cannot build and install ASpell for ${arch}.
449 # -------------------------
450 # Create universal binaries
451 # -------------------------
452 for file in ${FILE_LIST} ; do
454 for arch in ${ARCH_LIST} ; do
455 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
458 cd "${ASpellInstallDir}"
459 lipo -create ${OBJ_LIST} -o lib/${file}
465 for arch in ${ARCH_LIST} ; do
466 rm -f "${ASpellInstallDir}"/lib/*-${arch}
474 echo "Frameworks/${1}.framework"
477 if [ ! -f "${LyxSourceDir}"/configure -o "${LyxSourceDir}"/configure -ot "${LyxSourceDir}"/configure.ac ]; then
478 ( cd "${LyxSourceDir}" && sh autogen.sh )
481 FILE_LIST="lyx lyxclient tex2lyx"
482 BUNDLE_PATH="Contents/MacOS"
483 LYX_BUNDLE_PATH="${LyxAppPrefix}/${BUNDLE_PATH}"
486 if [ -n "${LyxAppZip}" -a -f "${LyxAppZip}" ]; then rm "${LyxAppZip}"; fi
487 if [ -d "${LyxAppPrefix}" ]; then rm -rf "${LyxAppPrefix}"; fi
489 # -------------------------------------
490 # Build LyX for different architectures
491 # -------------------------------------
493 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
494 ASpellFramework=`framework_name Aspell`
495 ASpellFramework=`basename "${ASpellFramework}"`
496 ConfigureExtraInc="--with-extra-inc=${ASpellInstallDir}/include"
497 ConfigureExtraLib="--with-extra-lib=${ASpellInstallDir}/lib"
498 LyXConfigureOptions="${LyXConfigureOptions} --with-aspell-framework=${ASpellFramework}"
501 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
502 HunSpellFramework=`framework_name Hunspell`
503 HunSpellFramework=`basename "${HunSpellFramework}"`
504 ConfigureExtraInc="--with-extra-inc=${HunSpellInstallDir}/include"
505 ConfigureExtraLib="--with-extra-lib=${HunSpellInstallDir}/lib"
506 # LyXConfigureOptions="${LyXConfigureOptions} --with-hunspell-framework=${HunSpellFramework}"
508 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraInc}"
509 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraLib}"
511 for arch in ${ARCH_LIST} ; do
513 if [ -d "${LyxBuildDir}" ]; then rm -r "${LyxBuildDir}"; fi
514 mkdir "${LyxBuildDir}" && cd "${LyxBuildDir}"
516 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
517 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch}"; export LDFLAGS
518 HOSTSYSTEM=`eval "echo \\$HostSystem_$arch"`
520 echo LDFLAGS="${LDFLAGS}"
521 echo CPPFLAGS="${CPPFLAGS}"
522 echo CONFIGURE_OPTIONS="${LyXConfigureOptions}"
523 "${LyxSourceDir}/configure"\
524 --prefix="${LyxAppPrefix}" --with-version-suffix="-${LyXVersion}"\
525 ${QtInstallDir:+"--with-qt4-dir=${QtInstallDir}"} \
526 ${LyXConfigureOptions}\
527 --host="${HOSTSYSTEM}" --build="${BuildSystem}" --enable-build-type=rel && \
528 make && make install${strip}
529 for file in ${FILE_LIST} ; do
530 if [ -f "${LYX_BUNDLE_PATH}/${file}" ]; then
531 mv "${LYX_BUNDLE_PATH}/${file}"\
532 "${LYX_BUNDLE_PATH}/${file}-${arch}"
534 echo ERROR: Cannot build and install LyX for ${arch}.
541 content_directory() {
543 content=`dirname "${target}"`
544 content=`dirname "${content}"`
548 private_framework() {
549 fwdir=`framework_name "$1"`
552 condir=`content_directory "${target}"`
553 libnm=`basename "${source}"`
554 mkdir -p "${condir}/${fwdir}"
555 if [ ! -f "${condir}/${fwdir}/${libnm}" ]; then
556 cp -p "${source}" "${condir}/${fwdir}"
557 echo Set library id in "${condir}/${fwdir}/${libnm}"
558 install_name_tool -id "@executable_path/../${fwdir}/${libnm}" "${condir}/${fwdir}/${libnm}"
560 echo Correct library id reference to "${libnm}" in "${target}"
561 install_name_tool -change "${source}" "@executable_path/../${fwdir}/${libnm}" "${target}"
565 source="${QtInstallDir}"
567 version="Versions/${QtFrameworkVersion}/"
568 condir=`content_directory "${target}"`
569 mkdir -p "${condir}/Resources"
570 test -f "${condir}/Resources/qt.conf" || cat - > "${condir}/Resources/qt.conf" <<-EOF
574 if [ ! -d "${condir}/PlugIns" ]; then
575 mkdir -p "${condir}/PlugIns"
576 find "${source}/plugins" -name \*.dylib -print | while read libname ; do
577 echo Copy plugin "${libname}"
578 dylib=`basename "${libname}"`
579 dirname=`dirname "${libname}"`
580 dirname=`basename "${dirname}"`
581 mkdir -p "${condir}/PlugIns/${dirname}"
582 cp -p "${libname}" "${condir}/PlugIns/${dirname}"
585 for libnm in ${QtLibraries} ; do
586 fwdir=`framework_name "$libnm"`
587 dirname=`basename "${fwdir}"`
588 test -d "${condir}/${fwdir}" || (
589 echo Copy framework "${source}/lib/"`basename "${fwdir}"`
590 cp -pR "${source}/lib/"`basename "${fwdir}"` "${condir}/${fwdir}"
591 echo Set library id in "${condir}/${fwdir}/${version}${libnm}"
592 install_name_tool -id "@executable_path/../${fwdir}/${version}${libnm}" "${condir}/${fwdir}/${version}${libnm}"
593 find "${condir}/PlugIns" "${condir}/"`dirname "${fwdir}"` -name Headers -prune -o -type f -print | while read filename ; do
594 otool -L "${filename}" 2>/dev/null | while read library ; do
595 # pattern match for: /path/to/qt4/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.6.0, current version 4.6.2)
597 *"${libnm}"*"("*")"*)
598 echo Correct library id reference to "${libnm}" in "${filename}"
599 install_name_tool -change\
600 "${source}/lib/${dirname}/${version}${libnm}"\
601 "@executable_path/../${fwdir}/${version}${libnm}"\
608 echo Correct library id reference to "${libnm}" in "${target}"
609 install_name_tool -change\
610 "${source}/lib/${dirname}/${version}${libnm}"\
611 "@executable_path/../${fwdir}/${version}${libnm}"\
616 # -------------------------
617 # Create universal binaries
618 # -------------------------
619 convert_universal() {
621 for file in ${FILE_LIST} ; do
623 for arch in ${ARCH_LIST} ; do
624 if [ -f "${BUNDLE_PATH}/${file}-${arch}" ]; then
625 OBJ_LIST="${OBJ_LIST} ${BUNDLE_PATH}/${file}-${arch}"
628 if [ -n "${OBJ_LIST}" ]; then
629 lipo -create ${OBJ_LIST} -o "${BUNDLE_PATH}/${file}"
631 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
632 private_framework Aspell "${ASpellInstallDir}/lib/libaspell.15.dylib" "${LYX_BUNDLE_PATH}/${file}"
634 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
635 private_framework Hunspell "${HunSpellInstallDir}/lib/libhunspell-1.2.0.dylib" "${LYX_BUNDLE_PATH}/${file}"
637 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt4_deployment}" ]; then
638 deploy_qtlibs "${LYX_BUNDLE_PATH}/${file}"
640 otool -L "${BUNDLE_PATH}/${file}" | while read reference ; do
641 case "${reference}" in
642 *"${LyxBuildDir}"*"("*")")
643 echo ERROR: Bad reference to "${reference}" found!!
648 for arch in ${ARCH_LIST} ; do
649 rm -f ${BUNDLE_PATH}/*-${arch}
653 copy_dictionaries() {
654 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
655 ASpellResources="${LyxAppPrefix}/Contents/Resources"
656 # try to reuse macports dictionaries for now
657 if [ -d /opt/local/lib/aspell-0.60 ]; then ASpellInstallDir=/opt/local ; fi
658 mkdir -p "${ASpellResources}"
659 echo Copy Aspell dictionaries from "${ASpellInstallDir}"
660 mkdir -p "${ASpellResources}"/data "${ASpellResources}"/dict
661 cp -p -r "${ASpellInstallDir}/lib/aspell-0.60"/* "${ASpellResources}"/data
662 cp -p -r "${ASpellInstallDir}/share/aspell"/* "${ASpellResources}"/dict
664 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
665 HunSpellResources="${LyxAppPrefix}/Contents/Resources"
666 if [ -d "${DictionarySourceDir}" ]; then
667 updateDictionaries "${DictionarySourceDir}"
668 cp -p -r "${DictionarySourceDir}/dict" "${HunSpellResources}"
671 if [ -d "${DictionarySourceDir}" -a "yes" = "${thesaurus_deployment}" ]; then
672 MyThesResources="${LyxAppPrefix}/Contents/Resources"
673 cp -p -r "${DictionarySourceDir}/thes" "${MyThesResources}"
677 function set_bundle_display_options() {
679 tell application "Finder"
680 set f to POSIX file ("${1}" as string) as alias
683 tell container window
684 set toolbar visible to false
685 set statusbar visible to false
686 set current view to icon view
688 set the bounds to {20, 50, $2, $3}
691 set icon size of the icon view options of container window to 64
692 set arrangement of the icon view options of container window to not arranged
693 set position of item "${LyxName}.app" to {100,$4}
694 set position of item "Applications" to {280,$4}
695 set background picture of the icon view options\
696 of container window to file "background.png" of folder "Pictures"
697 set the bounds of the container window to {0, 0, $2, $3}
698 update without registering applications
707 function make_dmg() {
710 BGSIZE=`file "$BACKGROUND" | awk -F , '/PNG/{print $2 }' | tr x ' '`
711 BG_W=`echo ${BGSIZE} | awk '{print $1 }'`
712 BG_H=`echo ${BGSIZE} | awk '{h = $2 + 20 ;print h }'`
713 BG_Y=`echo ${BGSIZE} | awk '{y = $2 - 60 ;print y }'`
715 rm -f "${DMGNAME}.sparseimage" "${DMGNAME}.dmg"
717 hdiutil create -type SPARSE -size ${DMGSIZE:-"250m"} -fs HFS+ -volname "${LyxBase}" "${DMGNAME}"
718 # Unmount currently mounted disk image
719 test -d /Volumes/"${LyxBase}" && umount /Volumes/"${LyxBase}"
721 # Mount the disk image
722 hdiutil attach "${DMGNAME}.sparseimage"
724 # Obtain device information
725 DEVS=$(hdiutil attach "${DMGNAME}.sparseimage" | cut -f 1)
726 DEV=$(echo $DEVS | cut -f 1 -d ' ')
727 VOLUME=$(mount |grep ${DEV} | cut -f 3 -d ' ')
729 # copy in the application bundle
730 cp -Rp "${LyxAppDir}.app" "${VOLUME}/${LyxName}.app"
732 # copy in background image
733 mkdir -p "${VOLUME}/Pictures"
734 cp "${BACKGROUND}" "${VOLUME}/Pictures/background.png"
735 # symlink applications
736 ln -s /Applications/ "${VOLUME}"/Applications
737 set_bundle_display_options "${VOLUME}" ${BG_W} ${BG_H} ${BG_Y}
738 mv "${VOLUME}/Pictures" "${VOLUME}/.Pictures"
740 # Unmount the disk image
741 hdiutil detach ${DEV}
743 # Convert the disk image to read-only
744 hdiutil convert "${DMGNAME}.sparseimage" -format UDBZ -o "${DMGNAME}.dmg"
745 rm -f "${DMGNAME}.sparseimage"
752 # ------------------------------
753 # Building distribution packages
754 # ------------------------------
756 test -n "${LyxAppZip}" && (
757 cd "${LyxAppPrefix}" && zip -r "${LyxAppZip}" .
760 test -n "${DMGLocation}" && (
761 make_dmg "${DMGLocation}"
762 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt4_deployment}" ]; then
763 rm -f "${DMGLocation}/${DMGNAME}+qt4.dmg"
764 mv "${DMGLocation}/${DMGNAME}.dmg" "${DMGLocation}/${DMGNAME}+qt4.dmg"
765 for libnm in ${QtLibraries} ; do
766 fwdir=`framework_name "$libnm"`
767 rm -rf "${LyxAppDir}.app/Contents/${fwdir}"
769 make_dmg "${DMGLocation}"