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 --with-libiconv-prefix=/usr"
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
43 SDKROOT="/Developer/SDKs/MacOSX10.5.sdk" # Leopard build is default
46 echo Build script for LyX on Mac OS X
48 echo Optional arguments:
49 echo " --aspell-deployment=yes|no ." default yes
50 echo " --qt4-deployment=yes|no ...." default yes
51 echo " --with-macosx-target=TARGET " default 10.4 "(Tiger)"
52 echo " --with-sdkroot=SDKROOT ....." default 10.5 "(Leopard)"
53 echo " --with-arch=ARCH ..........." default ppc,i386
54 echo " --with-build-path=PATH ....." default \${lyx-src-dir}/../lyx-build
55 echo " --with-dmg-location=PATH ..." default \${build-path}
57 echo "All other arguments with -- are passed to configure"
58 echo "including the defaults: ${LyXConfigureOptions}"
63 while [ $# -gt 0 ]; do
66 QTDIR=`echo ${1}|cut -d= -f2`
69 --with-macosx-target=*)
70 MACOSX_DEPLOYMENT_TARGET=`echo ${1}|cut -d= -f2`
74 SDKROOT=`echo ${1}|cut -d= -f2`
77 SDKROOT="/Developer/SDKs/MacOSX10.4u.sdk"
80 SDKROOT="/Developer/SDKs/MacOSX${SDKROOT}.sdk"
88 --aspell-deployment=*)
89 aspell_deployment=`echo ${1}|cut -d= -f2`
90 aspell_dictionaries=$aspell_deployment
93 --hunspell-deployment=*)
94 hunspell_deployment=`echo ${1}|cut -d= -f2`
95 hunspell_dictionaries=$hunspell_deployment
98 --thesaurus-deployment=*)
99 thesaurus_deployment=`echo ${1}|cut -d= -f2`
103 qt4_deployment=`echo ${1}|cut -d= -f2`
107 ARCH=`echo ${1}|cut -d= -f2|tr ',' ' '`
108 ARCH_LIST="${ARCH_LIST} ${ARCH}"
111 --with-dmg-location=*)
112 DMGLocation=`echo ${1}|cut -d= -f2`
116 LyxBuildDir=`echo ${1}|cut -d= -f2`
123 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
124 aspell_deployment="no"
128 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
129 hunspell_deployment="no"
133 LyXConfigureOptions="${LyXConfigureOptions} ${1}"
142 # Set these variables -- to
143 # (1) the location of your Qt4 installation
144 # (2) the location of resulting DMG
145 # (3) the version of private aspell installation
146 # (to define the location assign ASpellSourceDir instead)
147 # (4) the list of architectures to build for
149 QtInstallDir=${QTDIR:-"/opt/qt4"}
150 QtFrameworkVersion="4"
151 ASpellSourceVersion="aspell-0.60.6"
152 HunSpellSourceVersion="hunspell-1.2.9"
153 Qt4SourceVersion=${Qt4SourceVersion:-"qt-everywhere-opensource-src-4.6.3"}
155 ARCH_LIST=${ARCH_LIST:-"ppc i386"}
160 # detection of script home
161 LyxSourceDir=${1:-`dirname "$0"`}
162 if [ ! -d "${LyxSourceDir}" ]; then
163 echo Missing LyX source directory.
166 case "${LyxSourceDir}" in
168 LyxSourceDir=`dirname "${LyxSourceDir}"`
172 */development|development)
173 LyxSourceDir=`dirname "${LyxSourceDir}"`
174 LyxSourceDir=`cd "${LyxSourceDir}";pwd`
177 LyxSourceDir=`cd "${LyxSourceDir}";pwd`
181 LyxBuildDir=${LyxBuildDir:-`dirname "${LyxSourceDir}"`/lyx-build}
182 DMGLocation=${DMGLocation:-"${LyxBuildDir}"}
184 ASpellSourceDir=${ASPELLDIR:-`dirname "${LyxSourceDir}"`/${ASpellSourceVersion}}
185 ASpellInstallDir=${ASpellInstallDir:-"${LyxBuildDir}"/SpellChecker.lib}
186 HunSpellSourceDir=${HUNSPELLDIR:-`dirname "${LyxSourceDir}"`/${HunSpellSourceVersion}}
187 HunSpellInstallDir=${HunSpellInstallDir:-"${LyxBuildDir}"/SpellChecker.lib}
188 Qt4SourceDir=${QT4SOURCEDIR:-`dirname "${LyxSourceDir}"`/${Qt4SourceVersion}}
189 Qt4BuildDir=${Qt4BuildDir:-"${LyxBuildDir}"/${Qt4Build:-"qt4-build"}}
190 DictionarySourceDir=${DICTIONARYDIR:-`dirname "${LyxSourceDir}"`/Dictionaries}
192 ASpellInstallHdr="${ASpellInstallDir}/include/aspell.h"
193 HunSpellInstallHdr="${HunSpellInstallDir}/include/hunspell/hunspell.h"
195 if [ -z "${LyXVersion}" ]; then
196 LyXVersion=`grep AC_INIT "${LyxSourceDir}"/configure.ac | cut -d, -f2 | tr -d " ()"`
197 LyXVersionSuffix=`echo "${LyXVersion}" | cut -d. -f1-2`
198 LyXVersionSuffix="${LyXVersionSuffix:-${LyXVersion}}"
202 LyxBase="${LyxName}-${LyXVersion}"
203 LyxApp="${LyxBase}.app"
204 LyxAppDir="${LyxBuildDir}"/"${LyxBase}"
205 LyxBuildDir="${LyxAppDir}.build"
206 LyxAppPrefix="${LyxAppDir}.app"
207 # if zip file is needed... remove the comment sign
208 #LyxAppZip="${LyxAppPrefix}.zip"
210 BuildSystem=`"${LyxSourceDir}/config/config.guess"`
212 # ---------------------------------
213 # DON'T MODIFY ANYTHING BELOW HERE!
214 # ---------------------------------
216 # don't change order here...
217 QtLibraries="QtSvg QtXml QtGui QtNetwork QtCore"
221 BACKGROUND="${LyxAppDir}.app/Contents/Resources/images/banner.png"
223 # Check for existing SDKs
224 SDKs=`echo /Developer/SDKs/MacOSX10*sdk`
229 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.5"}; export MACOSX_DEPLOYMENT_TARGET
230 case "${MACOSX_DEPLOYMENT_TARGET}" in
232 SDKROOT="/Developer/SDKs/MacOSX10.6.sdk"; export SDKROOT
235 SDKROOT=${SDKROOT:-"/Developer/SDKs/MacOSX10.5.sdk"}; export SDKROOT
240 MACOSX_DEPLOYMENT_TARGET=${MACOSX_DEPLOYMENT_TARGET:-"10.4"}; export MACOSX_DEPLOYMENT_TARGET
241 SDKROOT=${SDKROOT:-"/Developer/SDKs/MacOSX10.5.sdk"}; export SDKROOT
244 echo Unknown or missing SDK for Mac OS X.
248 MYCFLAGS="-mmacosx-version-min=${MACOSX_DEPLOYMENT_TARGET}"
250 # These variables define the identifiers of the
251 # system (both Intel and PowerPC) to compile for.
252 # (Note: darwin8 is 10.4; darwin9 is 10.5.)
253 # Only change these if necessary
255 HostSystem_i386="i686-apple-darwin8"
256 HostSystem_ppc="powerpc-apple-darwin8"
258 updateDictionaries() {
259 TMP_DIR="/tmp/lyx-build-$$"
260 mkdir -p "$1"/dict "$1"/thes
261 mkdir -p "$TMP_DIR" && (
262 for pack in "$1"/*.zip ; do
265 cd "$TMP_DIR" && unzip "${pack}" de_DE_comb.zip thes_de_DE_v2.zip
266 cd "$1"/dict && unzip -o "$TMP_DIR"/de_DE_comb.zip &&\
267 for suffix in .aff .dic ; do mv de_DE_comb$suffix de_DE$suffix; done
268 cd "$1"/thes && unzip -o "$TMP_DIR"/thes_de_DE_v2.zip
271 cd "$TMP_DIR" && unzip "${pack}" pl_PL.zip thes_pl_PL_v2.zip
272 cd "$1"/dict && unzip -o "$TMP_DIR"/pl_PL.zip
273 cd "$1"/thes && unzip -o "$TMP_DIR"/thes_pl_PL_v2.zip
276 cd "$TMP_DIR" && unzip "${pack}" fr_FR.zip thes_fr_FR_v2.zip
277 cd "$1"/dict && unzip -o "$TMP_DIR"/fr_FR.zip
278 cd "$1"/thes && unzip -o "$TMP_DIR"/thes_fr_FR_v2.zip
281 cd "$TMP_DIR" && unzip "${pack}" es_ES.zip es_MX.zip thes_es_ES_v2.zip
282 cd "$1"/dict && unzip -o "$TMP_DIR"/es_ES.zip
283 cd "$1"/dict && unzip -o "$TMP_DIR"/es_MX.zip
284 cd "$1"/thes && unzip -o "$TMP_DIR"/thes_es_ES_v2.zip
287 cd "$TMP_DIR" && unzip "${pack}" pt_PT.zip
288 cd "$1"/dict && unzip -o "$TMP_DIR"/pt_PT.zip
289 cd "$1"/dict && unzip -o "$1"/pt_BR.zip
290 cd "$1"/thes && unzip -o "$1"/thes_pt_PT_v2.zip
293 cd "$TMP_DIR" && unzip "${pack}" it_IT.zip
294 cd "$1"/dict && unzip -o "$TMP_DIR"/it_IT.zip
295 cd "$1"/thes && unzip -o "$1"/thes_it_IT_v2.zip
298 cd "$TMP_DIR" && unzip "${pack}" ru_RU.zip
299 cd "$1"/dict && unzip -o "$TMP_DIR"/ru_RU.zip
300 cd "$1"/thes && tar xvf "$1"/thes_ru_RU_v2.tar.bz2
303 cd "$TMP_DIR" && unzip "${pack}" en_AU.zip en_CA.zip en_GB.zip en_NZ.zip en_US.zip
304 for zipfile in en_AU.zip en_CA.zip en_GB.zip en_NZ.zip en_US.zip ; do
305 ( cd "$1"/dict && unzip -o "$TMP_DIR/$zipfile" )
307 cd "$1"/thes && unzip -o "$1"/thes_en_US_v2.zip
310 cd "$TMP_DIR" && unzip -l "${pack}" | while read len date time zipfile ; do
314 cd "$TMP_DIR" && unzip -o "${pack}" "$zipfile"
315 cd "$1"/thes && unzip -o "$TMP_DIR"/"$zipfile"
317 [a-z][a-z]_[A-Z][A-Z].zip)
319 cd "$TMP_DIR" && unzip -o "${pack}" "$zipfile"
320 cd "$1"/dict && unzip -o "$TMP_DIR"/"$zipfile"
324 # echo Ignore dictionary package `basename "${pack}"`
332 if [ -d "${Qt4SourceDir}" -a ! -d "${Qt4BuildDir}" ]; then
333 echo Build Qt4 library ${Qt4SourceDir}
336 mkdir -p "${Qt4BuildDir}" && cd "${Qt4BuildDir}"
337 for arch in ${ARCH_LIST} ; do
338 ARCHS="${ARCHS} -arch ${arch}"
340 echo configure options:
341 echo ${Qt4ConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
343 echo yes | "${Qt4SourceDir}"/configure ${Qt4ConfigureOptions} ${ARCHS} -prefix "${QtInstallDir}"
346 cd "${QtInstallDir}" && (
349 for libnm in ${QtLibraries} ; do
350 test -d ${libnm} -o -L ${libnm} || ln -s ../lib/${libnm}.framework/Headers ${libnm}
355 # updateDictionaries "${DictionarySourceDir}"
358 if [ -d "${HunSpellSourceDir}" -a ! -f "${HunSpellInstallHdr}" ]; then
359 # we have a private HunSpell source tree at hand...
360 # so let's build and install it
361 if [ -z "${HunSpellVersion}" ]; then
362 HunSpellVersion=`grep AC_INIT "${HunSpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()"`
365 HunSpellName="Hunspell"
366 HunSpellBase="${HunSpellName}-${HunSpellVersion}"
368 echo Build hunspell library ${HunSpellBase}
369 echo configure options:
370 echo --prefix="${HunSpellInstallDir}" ${HunspellConfigureOptions}
372 cd "${HunSpellSourceDir}"
374 # ----------------------------------------
375 # Build HunSpell for different architectures
376 # ----------------------------------------
377 FILE_LIST="libhunspell-1.2.0.dylib"
379 for arch in ${ARCH_LIST} ; do
381 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
382 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
383 HOSTSYSTEM=`eval "echo \\$HostSystem_$arch"`
384 "${HunSpellSourceDir}/configure"\
385 --prefix="${HunSpellInstallDir}"\
386 ${HunspellConfigureOptions}
387 #--host="${HOSTSYSTEM}" ${BuildSystem:+"--build=${BuildSystem}"}
388 make && make install${strip}
389 for file in ${FILE_LIST} ; do
390 if [ -f "${HunSpellInstallDir}"/lib/${file} ]; then
391 mv "${HunSpellInstallDir}"/lib/${file}\
392 "${HunSpellInstallDir}"/lib/${file}-${arch}
394 echo Cannot build and install HunSpell for ${arch}.
399 # -------------------------
400 # Create universal binaries
401 # -------------------------
402 for file in ${FILE_LIST} ; do
404 for arch in ${ARCH_LIST} ; do
405 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
408 cd "${HunSpellInstallDir}"
409 lipo -create ${OBJ_LIST} -o lib/${file}
410 # check for the "missing link"...
411 test -f lib/libhunspell.dylib || (cd lib ; ln -s libhunspell-1.2.dylib libhunspell.dylib)
417 for arch in ${ARCH_LIST} ; do
418 rm -f "${HunSpellInstallDir}"/lib/*-${arch}
422 if [ -d "${ASpellSourceDir}" -a ! -f "${ASpellInstallHdr}" -a "yes" = "${aspell_deployment}" ]; then
423 # we have a private ASpell source tree at hand...
424 # so let's build and install it
425 if [ -z "${ASpellVersion}" ]; then
426 ASpellVersion=`grep AC_INIT "${ASpellSourceDir}"/configure.ac | cut -d, -f2|tr -d " ()"`
430 ASpellBase="${ASpellName}-${ASpellVersion}"
432 echo Build aspell library ${ASpellBase}
433 echo configure options:
434 echo --prefix="${ASpellInstallDir}" ${AspellConfigureOptions}
436 # ASpell builds inplace only :(
437 cd "${ASpellSourceDir}"
439 # ----------------------------------------
440 # Build ASpell for different architectures
441 # ----------------------------------------
442 FILE_LIST="libaspell.15.dylib"
444 for arch in ${ARCH_LIST} ; do
446 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
447 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
448 HOSTSYSTEM=`eval "echo \\$HostSystem_$arch"`
449 CXXFLAGS=-g "${ASpellSourceDir}/configure"\
450 --prefix="${ASpellInstallDir}"\
451 ${AspellConfigureOptions}
452 #--host="${HOSTSYSTEM}" ${BuildSystem:+"--build=${BuildSystem}"}
453 make && make install${aspellstrip}
454 for file in ${FILE_LIST} ; do
455 if [ -f "${ASpellInstallDir}"/lib/${file} ]; then
456 mv "${ASpellInstallDir}"/lib/${file}\
457 "${ASpellInstallDir}"/lib/${file}-${arch}
459 echo Cannot build and install ASpell for ${arch}.
464 # -------------------------
465 # Create universal binaries
466 # -------------------------
467 for file in ${FILE_LIST} ; do
469 for arch in ${ARCH_LIST} ; do
470 OBJ_LIST="${OBJ_LIST} lib/${file}-${arch}"
473 cd "${ASpellInstallDir}"
474 lipo -create ${OBJ_LIST} -o lib/${file}
480 for arch in ${ARCH_LIST} ; do
481 rm -f "${ASpellInstallDir}"/lib/*-${arch}
489 echo "Frameworks/${1}.framework"
492 if [ ! -f "${LyxSourceDir}"/configure -o "${LyxSourceDir}"/configure -ot "${LyxSourceDir}"/configure.ac ]; then
493 ( cd "${LyxSourceDir}" && sh autogen.sh )
496 FILE_LIST="lyx lyxclient tex2lyx"
497 BUNDLE_PATH="Contents/MacOS"
498 LYX_BUNDLE_PATH="${LyxAppPrefix}/${BUNDLE_PATH}"
501 if [ -n "${LyxAppZip}" -a -f "${LyxAppZip}" ]; then rm "${LyxAppZip}"; fi
502 if [ -d "${LyxAppPrefix}" ]; then rm -rf "${LyxAppPrefix}"; fi
504 # -------------------------------------
505 # Build LyX for different architectures
506 # -------------------------------------
508 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
509 ASpellFramework=`framework_name Aspell`
510 ASpellFramework=`basename "${ASpellFramework}"`
511 ConfigureExtraInc="--with-extra-inc=${ASpellInstallDir}/include"
512 ConfigureExtraLib="--with-extra-lib=${ASpellInstallDir}/lib"
513 LyXConfigureOptions="${LyXConfigureOptions} --with-aspell-framework=${ASpellFramework}"
516 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
517 HunSpellFramework=`framework_name Hunspell`
518 HunSpellFramework=`basename "${HunSpellFramework}"`
519 ConfigureExtraInc="--with-extra-inc=${HunSpellInstallDir}/include"
520 ConfigureExtraLib="--with-extra-lib=${HunSpellInstallDir}/lib"
521 # LyXConfigureOptions="${LyXConfigureOptions} --with-hunspell-framework=${HunSpellFramework}"
523 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraInc}"
524 LyXConfigureOptions="${LyXConfigureOptions} ${ConfigureExtraLib}"
526 for arch in ${ARCH_LIST} ; do
528 if [ -d "${LyxBuildDir}" ]; then rm -r "${LyxBuildDir}"; fi
529 mkdir "${LyxBuildDir}" && cd "${LyxBuildDir}"
531 CPPFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export CPPFLAGS
532 LDFLAGS="${SDKROOT:+-isysroot ${SDKROOT}} -arch ${arch} ${MYCFLAGS}"; export LDFLAGS
533 HOSTSYSTEM=`eval "echo \\$HostSystem_$arch"`
535 echo LDFLAGS="${LDFLAGS}"
536 echo CPPFLAGS="${CPPFLAGS}"
537 echo CONFIGURE_OPTIONS="${LyXConfigureOptions}"
538 "${LyxSourceDir}/configure"\
539 --prefix="${LyxAppPrefix}" --with-version-suffix="-${LyXVersionSuffix}"\
540 ${QtInstallDir:+"--with-qt4-dir=${QtInstallDir}"} \
541 ${LyXConfigureOptions}\
542 --host="${HOSTSYSTEM}" --build="${BuildSystem}" --enable-build-type=rel && \
543 make -j2 && make install${strip}
544 for file in ${FILE_LIST} ; do
545 if [ -f "${LYX_BUNDLE_PATH}/${file}" ]; then
546 mv "${LYX_BUNDLE_PATH}/${file}"\
547 "${LYX_BUNDLE_PATH}/${file}-${arch}"
549 echo ERROR: Cannot build and install LyX for ${arch}.
556 content_directory() {
558 content=`dirname "${target}"`
559 content=`dirname "${content}"`
563 private_framework() {
564 fwdir=`framework_name "$1"`
567 condir=`content_directory "${target}"`
568 libnm=`basename "${source}"`
569 mkdir -p "${condir}/${fwdir}"
570 if [ ! -f "${condir}/${fwdir}/${libnm}" ]; then
571 cp -p "${source}" "${condir}/${fwdir}"
572 echo Set library id in "${condir}/${fwdir}/${libnm}"
573 install_name_tool -id "@executable_path/../${fwdir}/${libnm}" "${condir}/${fwdir}/${libnm}"
575 echo Correct library id reference to "${libnm}" in "${target}"
576 install_name_tool -change "${source}" "@executable_path/../${fwdir}/${libnm}" "${target}"
580 source="${QtInstallDir}"
582 version="Versions/${QtFrameworkVersion}/"
583 condir=`content_directory "${target}"`
584 mkdir -p "${condir}/Resources"
585 test -f "${condir}/Resources/qt.conf" || cat - > "${condir}/Resources/qt.conf" <<-EOF
589 if [ ! -d "${condir}/PlugIns" ]; then
590 mkdir -p "${condir}/PlugIns"
591 find "${source}/plugins" -name \*.dylib -print | while read libname ; do
592 echo Copy plugin "${libname}"
593 dylib=`basename "${libname}"`
594 dirname=`dirname "${libname}"`
595 dirname=`basename "${dirname}"`
596 mkdir -p "${condir}/PlugIns/${dirname}"
597 cp -p "${libname}" "${condir}/PlugIns/${dirname}"
600 for libnm in ${QtLibraries} ; do
601 fwdir=`framework_name "$libnm"`
602 dirname=`dirname "${fwdir}"`
603 mkdir -p "${condir}/${dirname}"
604 dirname=`basename "${fwdir}"`
605 test -d "${condir}/${fwdir}" || (
606 echo Copy framework "${source}/lib/"`basename "${fwdir}"`
607 cp -pR "${source}/lib/"`basename "${fwdir}"` "${condir}/${fwdir}"
608 echo Set library id in "${condir}/${fwdir}/${version}${libnm}"
609 install_name_tool -id "@executable_path/../${fwdir}/${version}${libnm}" "${condir}/${fwdir}/${version}${libnm}"
610 find "${condir}/PlugIns" "${condir}/"`dirname "${fwdir}"` -name Headers -prune -o -type f -print | while read filename ; do
611 otool -L "${filename}" 2>/dev/null | while read library ; do
612 # pattern match for: /path/to/qt4/lib/QtGui.framework/Versions/4/QtGui (compatibility version 4.6.0, current version 4.6.2)
614 *"${libnm}"*"("*")"*)
615 echo Correct library id reference to "${libnm}" in "${filename}"
616 install_name_tool -change\
617 "${source}/lib/${dirname}/${version}${libnm}"\
618 "@executable_path/../${fwdir}/${version}${libnm}"\
625 echo Correct library id reference to "${libnm}" in "${target}"
626 install_name_tool -change\
627 "${source}/lib/${dirname}/${version}${libnm}"\
628 "@executable_path/../${fwdir}/${version}${libnm}"\
633 # -------------------------
634 # Create universal binaries
635 # -------------------------
636 convert_universal() {
638 for file in ${FILE_LIST} ; do
640 for arch in ${ARCH_LIST} ; do
641 if [ -f "${BUNDLE_PATH}/${file}-${arch}" ]; then
642 OBJ_LIST="${OBJ_LIST} ${BUNDLE_PATH}/${file}-${arch}"
645 if [ -n "${OBJ_LIST}" ]; then
646 lipo -create ${OBJ_LIST} -o "${BUNDLE_PATH}/${file}"
648 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_deployment}" ]; then
649 private_framework Aspell "${ASpellInstallDir}/lib/libaspell.15.dylib" "${LYX_BUNDLE_PATH}/${file}"
651 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_deployment}" ]; then
652 private_framework Hunspell "${HunSpellInstallDir}/lib/libhunspell-1.2.0.dylib" "${LYX_BUNDLE_PATH}/${file}"
654 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt4_deployment}" ]; then
655 deploy_qtlibs "${LYX_BUNDLE_PATH}/${file}"
657 otool -L "${BUNDLE_PATH}/${file}" | while read reference ; do
658 case "${reference}" in
659 *"${LyxBuildDir}"*"("*")")
660 echo ERROR: Bad reference to "${reference}" found!!
665 for arch in ${ARCH_LIST} ; do
666 rm -f ${BUNDLE_PATH}/*-${arch}
670 copy_dictionaries() {
671 if [ -d "${ASpellInstallDir}" -a "yes" = "${aspell_dictionaries}" ]; then
672 ASpellResources="${LyxAppPrefix}/Contents/Resources"
673 # try to reuse macports dictionaries for now
674 if [ -d /opt/local/lib/aspell-0.60 ]; then ASpellInstallDir=/opt/local ; fi
675 mkdir -p "${ASpellResources}"
676 echo Copy Aspell dictionaries from "${ASpellInstallDir}"
677 mkdir -p "${ASpellResources}"/data "${ASpellResources}"/dict
678 cp -p -r "${ASpellInstallDir}/lib/aspell-0.60"/* "${ASpellResources}"/data
679 cp -p -r "${ASpellInstallDir}/share/aspell"/* "${ASpellResources}"/dict
681 if [ -d "${HunSpellInstallDir}" -a "yes" = "${hunspell_dictionaries}" ]; then
682 HunSpellResources="${LyxAppPrefix}/Contents/Resources"
683 if [ -d "${DictionarySourceDir}" ]; then
684 updateDictionaries "${DictionarySourceDir}"
685 cp -p -r "${DictionarySourceDir}/dict" "${HunSpellResources}"
688 if [ -d "${DictionarySourceDir}" -a "yes" = "${thesaurus_deployment}" ]; then
689 MyThesResources="${LyxAppPrefix}/Contents/Resources"
690 cp -p -r "${DictionarySourceDir}/thes" "${MyThesResources}"
694 function set_bundle_display_options() {
696 tell application "Finder"
697 set f to POSIX file ("${1}" as string) as alias
700 tell container window
701 set toolbar visible to false
702 set statusbar visible to false
703 set current view to icon view
705 set the bounds to {20, 50, $2, $3}
708 set icon size of the icon view options of container window to 64
709 set arrangement of the icon view options of container window to not arranged
710 set position of item "${LyxName}.app" to {100,$4}
711 set position of item "Applications" to {280,$4}
712 set background picture of the icon view options\
713 of container window to file "background.png" of folder "Pictures"
714 set the bounds of the container window to {0, 0, $2, $3}
715 update without registering applications
724 function make_dmg() {
727 BGSIZE=`file "$BACKGROUND" | awk -F , '/PNG/{print $2 }' | tr x ' '`
728 BG_W=`echo ${BGSIZE} | awk '{print $1 }'`
729 BG_H=`echo ${BGSIZE} | awk '{h = $2 + 20 ;print h }'`
730 BG_Y=`echo ${BGSIZE} | awk '{y = $2 - 60 ;print y }'`
732 rm -f "${DMGNAME}.sparseimage" "${DMGNAME}.dmg"
734 hdiutil create -type SPARSE -size ${DMGSIZE:-"250m"} -fs HFS+ -volname "${LyxBase}" "${DMGNAME}"
735 # Unmount currently mounted disk image
736 test -d /Volumes/"${LyxBase}" && umount /Volumes/"${LyxBase}"
738 # Mount the disk image
739 hdiutil attach "${DMGNAME}.sparseimage"
741 # Obtain device information
742 DEVS=$(hdiutil attach "${DMGNAME}.sparseimage" | cut -f 1)
743 DEV=$(echo $DEVS | cut -f 1 -d ' ')
744 VOLUME=$(mount |grep ${DEV} | cut -f 3 -d ' ')
746 # copy in the application bundle
747 cp -Rp "${LyxAppDir}.app" "${VOLUME}/${LyxName}.app"
749 # copy in background image
750 mkdir -p "${VOLUME}/Pictures"
751 cp "${BACKGROUND}" "${VOLUME}/Pictures/background.png"
752 # symlink applications
753 ln -s /Applications/ "${VOLUME}"/Applications
754 set_bundle_display_options "${VOLUME}" ${BG_W} ${BG_H} ${BG_Y}
755 mv "${VOLUME}/Pictures" "${VOLUME}/.Pictures"
757 # Unmount the disk image
758 hdiutil detach ${DEV}
760 # Convert the disk image to read-only
761 hdiutil convert "${DMGNAME}.sparseimage" -format UDBZ -o "${DMGNAME}.dmg"
762 rm -f "${DMGNAME}.sparseimage"
769 # ------------------------------
770 # Building distribution packages
771 # ------------------------------
773 test -n "${LyxAppZip}" && (
774 cd "${LyxAppPrefix}" && zip -r "${LyxAppZip}" .
777 test -n "${DMGLocation}" && (
778 make_dmg "${DMGLocation}"
779 if [ -d "${QtInstallDir}/lib/QtCore.framework/Versions/${QtFrameworkVersion}" -a "yes" = "${qt4_deployment}" ]; then
780 rm -f "${DMGLocation}/${DMGNAME}+qt4.dmg"
781 echo move to "${DMGLocation}/${DMGNAME}+qt4.dmg"
782 mv "${DMGLocation}/${DMGNAME}.dmg" "${DMGLocation}/${DMGNAME}+qt4.dmg"
783 #for libnm in ${QtLibraries} ; do
784 # fwdir=`framework_name "$libnm"`
785 # rm -rf "${LyxAppDir}.app/Contents/${fwdir}"
787 #make_dmg "${DMGLocation}"